@cadraos/sdk 0.1.10 → 0.1.12

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.
@@ -58,7 +58,7 @@ var BaseResourceAPI = class {
58
58
  };
59
59
 
60
60
  // src/errors/sdk-errors.ts
61
- var AISaaSError = class extends Error {
61
+ var CadraError = class extends Error {
62
62
  /** Error code */
63
63
  code;
64
64
  /** HTTP status code */
@@ -69,7 +69,7 @@ var AISaaSError = class extends Error {
69
69
  requestId;
70
70
  constructor(message, code, status, details, requestId) {
71
71
  super(message);
72
- this.name = "AISaaSError";
72
+ this.name = "CadraError";
73
73
  this.code = code;
74
74
  this.status = status;
75
75
  this.details = details;
@@ -79,25 +79,25 @@ var AISaaSError = class extends Error {
79
79
  }
80
80
  }
81
81
  };
82
- var AuthenticationError = class extends AISaaSError {
82
+ var AuthenticationError = class extends CadraError {
83
83
  constructor(message = "Authentication failed", code = "authentication_error", details, requestId) {
84
84
  super(message, code, 401, details, requestId);
85
85
  this.name = "AuthenticationError";
86
86
  }
87
87
  };
88
- var AuthorizationError = class extends AISaaSError {
88
+ var AuthorizationError = class extends CadraError {
89
89
  constructor(message = "Access denied", code = "authorization_error", details, requestId) {
90
90
  super(message, code, 403, details, requestId);
91
91
  this.name = "AuthorizationError";
92
92
  }
93
93
  };
94
- var NotFoundError = class extends AISaaSError {
94
+ var NotFoundError = class extends CadraError {
95
95
  constructor(message = "Resource not found", code = "not_found", details, requestId) {
96
96
  super(message, code, 404, details, requestId);
97
97
  this.name = "NotFoundError";
98
98
  }
99
99
  };
100
- var ValidationError = class extends AISaaSError {
100
+ var ValidationError = class extends CadraError {
101
101
  /** Field-level validation errors */
102
102
  errors;
103
103
  constructor(message = "Validation failed", errors = [], details, requestId) {
@@ -106,7 +106,7 @@ var ValidationError = class extends AISaaSError {
106
106
  this.errors = errors;
107
107
  }
108
108
  };
109
- var RateLimitError = class extends AISaaSError {
109
+ var RateLimitError = class extends CadraError {
110
110
  /** Seconds until rate limit resets */
111
111
  retryAfter;
112
112
  constructor(message = "Rate limit exceeded", retryAfter, details, requestId) {
@@ -115,25 +115,25 @@ var RateLimitError = class extends AISaaSError {
115
115
  this.retryAfter = retryAfter;
116
116
  }
117
117
  };
118
- var ServerError = class extends AISaaSError {
118
+ var ServerError = class extends CadraError {
119
119
  constructor(message = "Server error", status = 500, details, requestId) {
120
120
  super(message, "server_error", status, details, requestId);
121
121
  this.name = "ServerError";
122
122
  }
123
123
  };
124
- var ConflictError = class extends AISaaSError {
124
+ var ConflictError = class extends CadraError {
125
125
  constructor(message = "Resource conflict", details, requestId) {
126
126
  super(message, "conflict", 409, details, requestId);
127
127
  this.name = "ConflictError";
128
128
  }
129
129
  };
130
- var TimeoutError = class extends AISaaSError {
130
+ var TimeoutError = class extends CadraError {
131
131
  constructor(message = "Request timed out", details, requestId) {
132
132
  super(message, "timeout", 408, details, requestId);
133
133
  this.name = "TimeoutError";
134
134
  }
135
135
  };
136
- var NetworkError = class extends AISaaSError {
136
+ var NetworkError = class extends CadraError {
137
137
  constructor(message = "Network error", details) {
138
138
  super(message, "network_error", 0, details);
139
139
  this.name = "NetworkError";
@@ -175,7 +175,7 @@ function parseApiError(status, body, requestId) {
175
175
  if (status >= 500) {
176
176
  return new ServerError(message, status, details, requestId);
177
177
  }
178
- return new AISaaSError(message, code, status, details, requestId);
178
+ return new CadraError(message, code, status, details, requestId);
179
179
  }
180
180
  }
181
181
 
@@ -263,15 +263,21 @@ var HttpClient = class {
263
263
  * Build full URL with query parameters
264
264
  */
265
265
  buildUrl(path, query) {
266
- const url = new URL(path, this.config.baseUrl);
266
+ const base = this.config.baseUrl.replace(/\/+$/, "");
267
+ let url = `${base}${path}`;
267
268
  if (query) {
269
+ const params = new URLSearchParams();
268
270
  for (const [key, value] of Object.entries(query)) {
269
271
  if (value !== void 0) {
270
- url.searchParams.set(key, String(value));
272
+ params.set(key, String(value));
271
273
  }
272
274
  }
275
+ const qs = params.toString();
276
+ if (qs) {
277
+ url += `?${qs}`;
278
+ }
273
279
  }
274
- return url.toString();
280
+ return url;
275
281
  }
276
282
  /**
277
283
  * Make an HTTP request
@@ -575,9 +581,11 @@ var DEFAULT_STREAMING_CONFIG = {
575
581
  activityTimeoutMs: 3e4,
576
582
  pollingIntervalMs: 2e3
577
583
  };
584
+ var DEFAULT_POLLING_ENABLED = true;
578
585
  var ExecutionStreamControllerImpl = class {
579
586
  options;
580
587
  config;
588
+ pollingEnabled;
581
589
  sseClient = null;
582
590
  status = "connecting";
583
591
  reconnectAttempts = 0;
@@ -611,6 +619,7 @@ var ExecutionStreamControllerImpl = class {
611
619
  constructor(options) {
612
620
  this.options = options;
613
621
  this.config = { ...DEFAULT_STREAMING_CONFIG, ...options.config };
622
+ this.pollingEnabled = options.pollingEnabled ?? DEFAULT_POLLING_ENABLED;
614
623
  }
615
624
  /**
616
625
  * Get the last event ID (for resume support)
@@ -671,7 +680,7 @@ var ExecutionStreamControllerImpl = class {
671
680
  return Promise.resolve(this.finalExecution);
672
681
  }
673
682
  if (this.finalError) {
674
- return Promise.reject(new AISaaSError(
683
+ return Promise.reject(new CadraError(
675
684
  this.finalError.error,
676
685
  this.finalError.errorCode ?? "execution_error",
677
686
  500
@@ -690,7 +699,8 @@ var ExecutionStreamControllerImpl = class {
690
699
  * Connect to SSE endpoint
691
700
  */
692
701
  async connectSSE() {
693
- const url = `${this.options.baseUrl}/agents/runs/${this.options.executionId}/stream`;
702
+ const base = this.options.baseUrl.replace(/\/+$/, "");
703
+ const url = `${base}/api/v1/agents/runs/${this.options.executionId}/stream`;
694
704
  let authToken = this.options.apiKey;
695
705
  if (!authToken && this.options.tokenProvider) {
696
706
  authToken = await this.options.tokenProvider();
@@ -925,7 +935,7 @@ var ExecutionStreamControllerImpl = class {
925
935
  this.finalError = error;
926
936
  this.emit("error", error);
927
937
  if (this.waitReject) {
928
- this.waitReject(new AISaaSError(
938
+ this.waitReject(new CadraError(
929
939
  error.error,
930
940
  error.errorCode ?? "execution_error",
931
941
  500
@@ -950,15 +960,61 @@ var ExecutionStreamControllerImpl = class {
950
960
  if (this.status === "closed") {
951
961
  return;
952
962
  }
963
+ await this.recoverState();
964
+ if (this.status === "closed") {
965
+ return;
966
+ }
953
967
  try {
954
968
  await this.connectSSE();
955
969
  } catch {
956
970
  await this.handleConnectionError(error);
957
971
  }
958
972
  } else {
959
- this.status = "fallback_polling";
960
- this.emit("connectionChange", { connected: false, usingFallback: true });
961
- this.startPolling();
973
+ if (this.pollingEnabled) {
974
+ this.status = "fallback_polling";
975
+ this.emit("connectionChange", { connected: false, usingFallback: true });
976
+ this.startPolling();
977
+ } else {
978
+ this.handleError({
979
+ error: "SSE connection failed and polling is disabled",
980
+ errorCode: "connection_failed"
981
+ });
982
+ }
983
+ }
984
+ }
985
+ /**
986
+ * Recover state by checking execution status.
987
+ *
988
+ * Called during reconnection to catch any events missed while SSE was down.
989
+ * If the execution completed while disconnected, emits completion immediately.
990
+ * Otherwise, emits any new logs that weren't seen via SSE.
991
+ */
992
+ async recoverState() {
993
+ try {
994
+ const execution = await this.options.getExecution(this.options.executionId);
995
+ if (execution.logs) {
996
+ for (const log of execution.logs) {
997
+ if (!this.seenEventIds.has(log.uuid)) {
998
+ this.seenEventIds.add(log.uuid);
999
+ this.emit("log", log);
1000
+ }
1001
+ }
1002
+ }
1003
+ if (execution.status === "completed") {
1004
+ this.stopPolling();
1005
+ this.handleComplete(execution);
1006
+ return;
1007
+ }
1008
+ if (execution.status === "failed" || execution.status === "cancelled") {
1009
+ this.stopPolling();
1010
+ this.handleError({
1011
+ error: execution.error ?? `Execution ${execution.status}`,
1012
+ errorCode: execution.status
1013
+ });
1014
+ return;
1015
+ }
1016
+ } catch (err) {
1017
+ console.warn("[SDK:StreamController] State recovery failed (non-fatal):", err);
962
1018
  }
963
1019
  }
964
1020
  /**
@@ -1043,7 +1099,7 @@ function createExecutionStreamController(options) {
1043
1099
  // src/resources/agents.ts
1044
1100
  var AgentsAPI = class extends BaseResourceAPI {
1045
1101
  constructor(http, getStreamConfig) {
1046
- super(http, "/agents");
1102
+ super(http, "/api/v1/agents");
1047
1103
  this.getStreamConfig = getStreamConfig;
1048
1104
  }
1049
1105
  // ===== LIST Operations =====
@@ -1319,7 +1375,7 @@ var AgentsAPI = class extends BaseResourceAPI {
1319
1375
  // src/resources/skills.ts
1320
1376
  var SkillsAPI = class extends BaseResourceAPI {
1321
1377
  constructor(http) {
1322
- super(http, "/skills");
1378
+ super(http, "/api/v1/skills");
1323
1379
  }
1324
1380
  // ===== LIST Operations =====
1325
1381
  /**
@@ -1463,7 +1519,7 @@ var SkillsAPI = class extends BaseResourceAPI {
1463
1519
  // src/resources/tools.ts
1464
1520
  var ToolsAPI = class extends BaseResourceAPI {
1465
1521
  constructor(http) {
1466
- super(http, "/tools");
1522
+ super(http, "/api/v1/tools");
1467
1523
  }
1468
1524
  // ===== LIST Operations =====
1469
1525
  /**
@@ -1626,7 +1682,7 @@ var ToolsAPI = class extends BaseResourceAPI {
1626
1682
  // src/resources/artifacts.ts
1627
1683
  var ArtifactsAPI = class extends BaseResourceAPI {
1628
1684
  constructor(http) {
1629
- super(http, "/artifacts");
1685
+ super(http, "/api/v1/artifacts");
1630
1686
  }
1631
1687
  // ===== LIST Operations =====
1632
1688
  /**
@@ -1822,7 +1878,7 @@ var ArtifactsAPI = class extends BaseResourceAPI {
1822
1878
  // src/resources/sessions.ts
1823
1879
  var SessionsAPI = class extends BaseResourceAPI {
1824
1880
  constructor(http, getStreamConfig) {
1825
- super(http, "/sessions");
1881
+ super(http, "/api/v1/sessions");
1826
1882
  this.getStreamConfig = getStreamConfig;
1827
1883
  }
1828
1884
  // ===== LIST Operations =====
@@ -2053,9 +2109,9 @@ var SessionsAPI = class extends BaseResourceAPI {
2053
2109
  };
2054
2110
 
2055
2111
  // src/client.ts
2056
- var DEFAULT_BASE_URL = "https://api.aisaas.com/v1";
2112
+ var DEFAULT_BASE_URL = "https://api.cadraos.com";
2057
2113
  var DEFAULT_TIMEOUT = 3e4;
2058
- var AISaaSClient = class {
2114
+ var CadraClient = class {
2059
2115
  httpClient;
2060
2116
  config;
2061
2117
  /**
@@ -2086,19 +2142,19 @@ var AISaaSClient = class {
2086
2142
  * @example
2087
2143
  * ```typescript
2088
2144
  * // API key authentication
2089
- * const client = new AISaaSClient({
2145
+ * const client = new CadraClient({
2090
2146
  * apiKey: 'sk_...',
2091
2147
  * orgId: 123,
2092
2148
  * });
2093
2149
  *
2094
2150
  * // OAuth token authentication
2095
- * const client = new AISaaSClient({
2151
+ * const client = new CadraClient({
2096
2152
  * token: 'eyJ...',
2097
2153
  * orgId: 123,
2098
2154
  * });
2099
2155
  *
2100
2156
  * // Token provider (for automatic refresh)
2101
- * const client = new AISaaSClient({
2157
+ * const client = new CadraClient({
2102
2158
  * tokenProvider: async () => myAuth.getAccessToken(),
2103
2159
  * orgId: 123,
2104
2160
  * });
@@ -2106,6 +2162,19 @@ var AISaaSClient = class {
2106
2162
  */
2107
2163
  constructor(options) {
2108
2164
  this.validateOptions(options);
2165
+ if (options.baseUrl) {
2166
+ try {
2167
+ const parsed = new URL(options.baseUrl);
2168
+ if (/\/(api|v\d)/.test(parsed.pathname)) {
2169
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
2170
+ console.warn(
2171
+ `[CadraOS SDK] baseUrl should be the origin only (e.g., "https://api.cadraos.com" or "http://localhost:3000"). The SDK automatically prepends "/api/v1/" to all requests. Received: "${options.baseUrl}"`
2172
+ );
2173
+ }
2174
+ }
2175
+ } catch {
2176
+ }
2177
+ }
2109
2178
  this.config = {
2110
2179
  baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
2111
2180
  orgId: options.orgId,
@@ -2178,21 +2247,21 @@ function resolveClient(config) {
2178
2247
  throw new Error("DefaultAdapterConfig requires 'orgId' when 'client' is not provided");
2179
2248
  }
2180
2249
  if (config.apiKey) {
2181
- return new AISaaSClient({
2250
+ return new CadraClient({
2182
2251
  apiKey: config.apiKey,
2183
2252
  orgId: config.orgId,
2184
2253
  baseUrl: config.baseUrl
2185
2254
  });
2186
2255
  }
2187
2256
  if (config.token) {
2188
- return new AISaaSClient({
2257
+ return new CadraClient({
2189
2258
  token: config.token,
2190
2259
  orgId: config.orgId,
2191
2260
  baseUrl: config.baseUrl
2192
2261
  });
2193
2262
  }
2194
2263
  if (config.tokenProvider) {
2195
- return new AISaaSClient({
2264
+ return new CadraClient({
2196
2265
  tokenProvider: config.tokenProvider,
2197
2266
  orgId: config.orgId,
2198
2267
  baseUrl: config.baseUrl
@@ -2204,7 +2273,7 @@ function resolveClient(config) {
2204
2273
  }
2205
2274
  function resolveBaseUrl(config) {
2206
2275
  if (config.baseUrl) return config.baseUrl;
2207
- return "https://api.cadra.io/v1";
2276
+ return "https://api.cadraos.com";
2208
2277
  }
2209
2278
  async function getAuthHeaders(config) {
2210
2279
  const headers = {
@@ -2313,7 +2382,7 @@ function createDefaultAdapter(config) {
2313
2382
  // Attachment Methods (raw fetch — CadraClient has no AttachmentsAPI yet)
2314
2383
  // -------------------------------------------------------------------------
2315
2384
  async getUploadUrl(input) {
2316
- return rawRequest(config, "POST", "/attachments/upload-url", {
2385
+ return rawRequest(config, "POST", "/api/v1/attachments/upload-url", {
2317
2386
  sessionId: input.sessionId,
2318
2387
  filename: input.filename,
2319
2388
  mimeType: input.mimeType,
@@ -2321,10 +2390,10 @@ function createDefaultAdapter(config) {
2321
2390
  });
2322
2391
  },
2323
2392
  async confirmUpload(uuid) {
2324
- await rawRequest(config, "POST", `/attachments/${uuid}/confirm`);
2393
+ await rawRequest(config, "POST", `/api/v1/attachments/${uuid}/confirm`);
2325
2394
  },
2326
2395
  async getDownloadUrl(uuid) {
2327
- const result = await rawRequest(config, "GET", `/attachments/${uuid}/download-url`);
2396
+ const result = await rawRequest(config, "GET", `/api/v1/attachments/${uuid}/download-url`);
2328
2397
  return result.url;
2329
2398
  },
2330
2399
  // -------------------------------------------------------------------------
@@ -2405,7 +2474,7 @@ function createDefaultAdapter(config) {
2405
2474
  );
2406
2475
  }
2407
2476
  }
2408
- return `${baseUrl}/agents/runs/${executionId}/stream`;
2477
+ return `${baseUrl}/api/v1/agents/runs/${executionId}/stream`;
2409
2478
  },
2410
2479
  // -------------------------------------------------------------------------
2411
2480
  // Secure SSE Streaming (Recommended)
@@ -2797,12 +2866,54 @@ function useExecutionStream(options) {
2797
2866
  }
2798
2867
 
2799
2868
  // src/chat/hooks/useAgentChat.ts
2869
+ var __DEV__ = typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
2800
2870
  var SILENT_TOOL_NAMES = /* @__PURE__ */ new Set([
2801
2871
  "check_delegations"
2802
2872
  ]);
2803
2873
  function generateId() {
2804
2874
  return `msg-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
2805
2875
  }
2876
+ function extractImagesFromResult(result, sourceToolCallId) {
2877
+ if (!result) return [];
2878
+ let data = result;
2879
+ if (typeof result === "string") {
2880
+ try {
2881
+ data = JSON.parse(result);
2882
+ } catch {
2883
+ if (/\.(png|jpg|jpeg|gif|webp|svg|bmp)(\?.*)?$/i.test(result) || result.startsWith("data:image/")) {
2884
+ return [{ url: result, sourceToolCallId }];
2885
+ }
2886
+ return [];
2887
+ }
2888
+ }
2889
+ if (typeof data !== "object" || data === null) return [];
2890
+ const obj = data;
2891
+ if (Array.isArray(obj.images)) {
2892
+ return obj.images.filter((img) => typeof img.url === "string").map((img) => ({
2893
+ url: img.url,
2894
+ alt: img.alt || img.prompt || void 0,
2895
+ filename: img.filename,
2896
+ sourceToolCallId
2897
+ }));
2898
+ }
2899
+ if (typeof obj.url === "string" && /\.(png|jpg|jpeg|gif|webp|svg|bmp)(\?.*)?$/i.test(obj.url)) {
2900
+ return [{ url: obj.url, alt: obj.alt, sourceToolCallId }];
2901
+ }
2902
+ if (typeof obj.imageUrl === "string") {
2903
+ return [{ url: obj.imageUrl, alt: obj.alt, sourceToolCallId }];
2904
+ }
2905
+ return [];
2906
+ }
2907
+ function deriveImagesFromToolCalls(toolCalls) {
2908
+ if (!toolCalls) return [];
2909
+ const images = [];
2910
+ for (const tc of toolCalls) {
2911
+ if (tc.status === "completed" && tc.result) {
2912
+ images.push(...extractImagesFromResult(tc.result, tc.id));
2913
+ }
2914
+ }
2915
+ return images;
2916
+ }
2806
2917
  function historyToMessage(historyMsg) {
2807
2918
  return {
2808
2919
  id: historyMsg.uuid,
@@ -2843,7 +2954,9 @@ function useAgentChat(options) {
2843
2954
  // Deprecated, but still supported
2844
2955
  onToolCall,
2845
2956
  onToolResult,
2846
- onClarification
2957
+ onClarification,
2958
+ pollingInterval,
2959
+ pollingEnabled
2847
2960
  } = options;
2848
2961
  const contextConfig = useChatConfigOptional();
2849
2962
  const adapter = propsAdapter ?? contextConfig?.adapter;
@@ -2875,8 +2988,14 @@ function useAgentChat(options) {
2875
2988
  const streamingMessageIdRef = useRef(null);
2876
2989
  const pendingToolCallsRef = useRef(/* @__PURE__ */ new Map());
2877
2990
  const lastMessageContentRef = useRef("");
2991
+ const finalizedRef = useRef(false);
2878
2992
  const firedToolResultsRef = useRef(/* @__PURE__ */ new Set());
2879
2993
  const streamControllerRef = useRef(null);
2994
+ const pendingDelegationsRef = useRef(/* @__PURE__ */ new Map());
2995
+ const onDelegationRef = useRef(options.onDelegation);
2996
+ useEffect(() => {
2997
+ onDelegationRef.current = options.onDelegation;
2998
+ }, [options.onDelegation]);
2880
2999
  const updateStreamingMessage = useCallback((content) => {
2881
3000
  if (!streamingMessageIdRef.current) return;
2882
3001
  setMessages(
@@ -2905,21 +3024,72 @@ function useAgentChat(options) {
2905
3024
  });
2906
3025
  });
2907
3026
  }, []);
2908
- const finalizeStreamingMessage = useCallback(() => {
3027
+ const addDelegationEvent = useCallback((delegation) => {
3028
+ setMessages((prev) => {
3029
+ const targetId = streamingMessageIdRef.current ?? [...prev].reverse().find((m) => m.role === "assistant")?.id;
3030
+ if (!targetId) return prev;
3031
+ return prev.map((msg) => {
3032
+ if (msg.id !== targetId) return msg;
3033
+ const existing = msg.delegationEvents ?? [];
3034
+ if (delegation.type === "delegation_completed" && delegation.handoffId) {
3035
+ const updatedEvents = existing.map(
3036
+ (de) => de.handoffId === delegation.handoffId ? { ...de, ...delegation, status: delegation.status ?? "completed" } : de
3037
+ );
3038
+ const hasMatch = existing.some((de) => de.handoffId === delegation.handoffId);
3039
+ return {
3040
+ ...msg,
3041
+ delegationEvents: hasMatch ? updatedEvents : [...existing, delegation]
3042
+ };
3043
+ }
3044
+ return { ...msg, delegationEvents: [...existing, delegation] };
3045
+ });
3046
+ });
3047
+ }, []);
3048
+ const updateMessageImages = useCallback(() => {
3049
+ setMessages((prev) => {
3050
+ const targetId = streamingMessageIdRef.current ?? [...prev].reverse().find((m) => m.role === "assistant")?.id;
3051
+ if (!targetId) return prev;
3052
+ return prev.map((msg) => {
3053
+ if (msg.id !== targetId) return msg;
3054
+ const images = deriveImagesFromToolCalls(msg.toolCalls);
3055
+ return images.length > 0 ? { ...msg, images } : msg;
3056
+ });
3057
+ });
3058
+ }, []);
3059
+ const finalizeStreamingMessage = useCallback((finalOutput) => {
2909
3060
  if (!streamingMessageIdRef.current) return;
2910
- setMessages(
2911
- (prev) => prev.map(
2912
- (msg) => msg.id === streamingMessageIdRef.current ? { ...msg, isStreaming: false } : msg
2913
- )
2914
- );
3061
+ finalizedRef.current = true;
3062
+ const streamMsgId = streamingMessageIdRef.current;
3063
+ setMessages((prev) => {
3064
+ const resolvedContent = finalOutput || streamingContentRef.current || "";
3065
+ const duplicateExists = resolvedContent && prev.some(
3066
+ (msg) => msg.id !== streamMsgId && msg.role === "assistant" && !msg.isStreaming && msg.content === resolvedContent
3067
+ );
3068
+ if (duplicateExists) {
3069
+ return prev.filter((msg) => msg.id !== streamMsgId);
3070
+ }
3071
+ return prev.map((msg) => {
3072
+ if (msg.id !== streamMsgId) return msg;
3073
+ const updatedToolCalls = msg.toolCalls?.map(
3074
+ (tc) => tc.status === "running" || tc.status === "pending" ? { ...tc, status: "completed" } : tc
3075
+ );
3076
+ return {
3077
+ ...msg,
3078
+ content: resolvedContent || msg.content,
3079
+ isStreaming: false,
3080
+ toolCalls: updatedToolCalls
3081
+ };
3082
+ });
3083
+ });
2915
3084
  streamingMessageIdRef.current = null;
2916
3085
  streamingContentRef.current = "";
2917
3086
  pendingToolCallsRef.current.clear();
2918
3087
  firedToolResultsRef.current.clear();
3088
+ pendingDelegationsRef.current.clear();
2919
3089
  }, []);
2920
3090
  const handleExecutionLog = useCallback(
2921
3091
  (log) => {
2922
- console.log("[useAgentChat] handleExecutionLog:", log.type, log.metadata);
3092
+ if (__DEV__) console.log("[useAgentChat] handleExecutionLog:", log.type, log.metadata);
2923
3093
  switch (log.type) {
2924
3094
  // Primary handlers for ai-saas-api worker log types
2925
3095
  case "llm_response": {
@@ -2939,11 +3109,46 @@ function useAgentChat(options) {
2939
3109
  }
2940
3110
  break;
2941
3111
  }
3112
+ case "delegation": {
3113
+ const delegationType = log.metadata?.delegationType;
3114
+ if (delegationType === "started" || delegationType === "delegation_started") {
3115
+ const delegation = {
3116
+ type: "delegation_started",
3117
+ handoffId: log.metadata?.handoffId,
3118
+ toAgent: log.metadata?.targetAgentName || log.metadata?.targetAgentUuid,
3119
+ targetAgentUuid: log.metadata?.targetAgentUuid,
3120
+ taskPreview: log.metadata?.taskPreview,
3121
+ timestamp: new Date(log.timestamp || Date.now()),
3122
+ status: "active"
3123
+ };
3124
+ if (delegation.handoffId) {
3125
+ pendingDelegationsRef.current.set(delegation.handoffId, delegation);
3126
+ }
3127
+ addDelegationEvent(delegation);
3128
+ onDelegationRef.current?.(delegation);
3129
+ } else if (delegationType === "completed" || delegationType === "delegation_completed") {
3130
+ const delegation = {
3131
+ type: "delegation_completed",
3132
+ handoffId: log.metadata?.handoffId,
3133
+ resultPreview: log.metadata?.resultPreview,
3134
+ timestamp: new Date(log.timestamp || Date.now()),
3135
+ status: log.metadata?.status === "failed" ? "failed" : "completed",
3136
+ durationMs: log.durationMs
3137
+ };
3138
+ if (delegation.handoffId) {
3139
+ pendingDelegationsRef.current.delete(delegation.handoffId);
3140
+ }
3141
+ addDelegationEvent(delegation);
3142
+ onDelegationRef.current?.(delegation);
3143
+ }
3144
+ break;
3145
+ }
2942
3146
  case "info":
2943
3147
  case "system":
2944
- console.log("[useAgentChat] Status:", log.type, log.title);
3148
+ if (__DEV__) console.log("[useAgentChat] Status:", log.type, log.title);
2945
3149
  break;
2946
3150
  case "tool_call": {
3151
+ if (finalizedRef.current) break;
2947
3152
  const toolName = log.metadata?.toolName;
2948
3153
  if (SILENT_TOOL_NAMES.has(toolName)) break;
2949
3154
  const toolCallId = log.metadata?.toolCallId || `tool-${Date.now()}`;
@@ -2998,17 +3203,18 @@ function useAgentChat(options) {
2998
3203
  firedToolResultsRef.current.add(resultToolCallId);
2999
3204
  }
3000
3205
  onToolResultRef.current?.(resultToolName, result, durationMs);
3206
+ updateMessageImages();
3001
3207
  break;
3002
3208
  }
3003
3209
  default:
3004
- console.log("[useAgentChat] Unhandled log type:", log.type, log);
3210
+ if (__DEV__) console.log("[useAgentChat] Unhandled log type:", log.type, log);
3005
3211
  }
3006
3212
  },
3007
- [updateStreamingMessage, updateToolCall]
3213
+ [updateStreamingMessage, updateToolCall, updateMessageImages, addDelegationEvent]
3008
3214
  );
3009
3215
  const handleStreamLog = useCallback(
3010
3216
  (log) => {
3011
- console.log("[useAgentChat] handleStreamLog:", log.logType, log.metadata);
3217
+ if (__DEV__) console.log("[useAgentChat] handleStreamLog:", log.logType, log.metadata);
3012
3218
  switch (log.logType) {
3013
3219
  case "llm_response": {
3014
3220
  const llmText = log.metadata?.text || "";
@@ -3027,9 +3233,42 @@ function useAgentChat(options) {
3027
3233
  }
3028
3234
  break;
3029
3235
  }
3236
+ case "delegation_started": {
3237
+ const delegation = {
3238
+ type: "delegation_started",
3239
+ handoffId: log.metadata?.handoffId,
3240
+ toAgent: log.metadata?.targetAgentName || log.metadata?.targetAgentUuid,
3241
+ targetAgentUuid: log.metadata?.targetAgentUuid,
3242
+ taskPreview: log.metadata?.taskPreview,
3243
+ timestamp: new Date(log.timestamp || Date.now()),
3244
+ status: "active"
3245
+ };
3246
+ if (delegation.handoffId) {
3247
+ pendingDelegationsRef.current.set(delegation.handoffId, delegation);
3248
+ }
3249
+ addDelegationEvent(delegation);
3250
+ onDelegationRef.current?.(delegation);
3251
+ break;
3252
+ }
3253
+ case "delegation_completed": {
3254
+ const delegation = {
3255
+ type: "delegation_completed",
3256
+ handoffId: log.metadata?.handoffId,
3257
+ resultPreview: log.metadata?.resultPreview,
3258
+ timestamp: new Date(log.timestamp || Date.now()),
3259
+ status: log.metadata?.status === "failed" ? "failed" : "completed",
3260
+ durationMs: log.durationMs
3261
+ };
3262
+ if (delegation.handoffId) {
3263
+ pendingDelegationsRef.current.delete(delegation.handoffId);
3264
+ }
3265
+ addDelegationEvent(delegation);
3266
+ onDelegationRef.current?.(delegation);
3267
+ break;
3268
+ }
3030
3269
  case "info":
3031
3270
  case "system":
3032
- console.log("[useAgentChat] Status:", log.logType, log.message);
3271
+ if (__DEV__) console.log("[useAgentChat] Status:", log.logType, log.message);
3033
3272
  break;
3034
3273
  case "response_text":
3035
3274
  case "text_chunk": {
@@ -3039,6 +3278,7 @@ function useAgentChat(options) {
3039
3278
  break;
3040
3279
  }
3041
3280
  case "tool_call": {
3281
+ if (finalizedRef.current) break;
3042
3282
  const toolName = log.metadata?.toolName;
3043
3283
  if (SILENT_TOOL_NAMES.has(toolName)) break;
3044
3284
  const toolCallId = log.metadata?.toolCallId || `tool-${Date.now()}`;
@@ -3093,6 +3333,7 @@ function useAgentChat(options) {
3093
3333
  firedToolResultsRef.current.add(resultToolCallId);
3094
3334
  }
3095
3335
  onToolResultRef.current?.(resultToolName, result, durationMs);
3336
+ updateMessageImages();
3096
3337
  break;
3097
3338
  }
3098
3339
  case "final_response": {
@@ -3104,10 +3345,10 @@ function useAgentChat(options) {
3104
3345
  break;
3105
3346
  }
3106
3347
  default:
3107
- console.log("[useAgentChat] Unknown log type:", log.logType, log);
3348
+ if (__DEV__) console.log("[useAgentChat] Unknown log type:", log.logType, log);
3108
3349
  }
3109
3350
  },
3110
- [updateStreamingMessage, updateToolCall]
3351
+ [updateStreamingMessage, updateToolCall, updateMessageImages, addDelegationEvent]
3111
3352
  );
3112
3353
  const handleClarification = useCallback(
3113
3354
  (data) => {
@@ -3116,17 +3357,23 @@ function useAgentChat(options) {
3116
3357
  },
3117
3358
  [onClarification]
3118
3359
  );
3119
- const handleComplete = useCallback(() => {
3120
- console.log("[useAgentChat] handleComplete called");
3360
+ const completedRef = useRef(false);
3361
+ const handleComplete = useCallback((finalOutput) => {
3362
+ if (completedRef.current) {
3363
+ if (__DEV__) console.log("[useAgentChat] handleComplete: skipping duplicate complete");
3364
+ return;
3365
+ }
3366
+ completedRef.current = true;
3367
+ if (__DEV__) console.log("[useAgentChat] handleComplete called");
3121
3368
  setIsLoading(false);
3122
3369
  setIsStreamControllerConnected(false);
3123
- finalizeStreamingMessage();
3370
+ finalizeStreamingMessage(finalOutput);
3124
3371
  setCurrentExecutionId(null);
3125
3372
  streamControllerRef.current = null;
3126
3373
  }, [finalizeStreamingMessage]);
3127
3374
  const handleError = useCallback(
3128
3375
  (errorMsg) => {
3129
- console.log("[useAgentChat] handleError called:", errorMsg);
3376
+ if (__DEV__) console.log("[useAgentChat] handleError called:", errorMsg);
3130
3377
  const chatError = {
3131
3378
  code: "EXECUTION_ERROR",
3132
3379
  message: errorMsg,
@@ -3165,43 +3412,39 @@ function useAgentChat(options) {
3165
3412
  if (pollingExecutionIdRef.current === executionId) return;
3166
3413
  stopPolling();
3167
3414
  pollingExecutionIdRef.current = executionId;
3168
- console.log("[useAgentChat] Starting polling fallback for:", executionId);
3415
+ if (__DEV__) console.log("[useAgentChat] Starting polling fallback for:", executionId);
3169
3416
  const poll = async () => {
3170
3417
  if (pollingExecutionIdRef.current !== executionId) return;
3171
3418
  try {
3172
3419
  const execution = await adapter.getExecution(executionId);
3173
3420
  if (execution.status === "completed") {
3174
- console.log("[useAgentChat] Polling: execution completed");
3175
- if (execution.result) {
3176
- streamingContentRef.current = execution.result;
3177
- updateStreamingMessage(execution.result);
3178
- }
3421
+ if (__DEV__) console.log("[useAgentChat] Polling: execution completed");
3179
3422
  stopPolling();
3180
- handleComplete();
3423
+ handleComplete(execution.result || void 0);
3181
3424
  } else if (execution.status === "failed") {
3182
- console.log("[useAgentChat] Polling: execution failed");
3425
+ if (__DEV__) console.log("[useAgentChat] Polling: execution failed");
3183
3426
  stopPolling();
3184
3427
  handleError(execution.error || "Execution failed");
3185
3428
  }
3186
3429
  } catch (err) {
3187
- console.warn("[useAgentChat] Polling error (will retry):", err);
3430
+ if (__DEV__) console.warn("[useAgentChat] Polling error (will retry):", err);
3188
3431
  }
3189
3432
  };
3190
3433
  poll();
3191
- pollingIntervalRef.current = setInterval(poll, 2e3);
3192
- }, [adapter, stopPolling, updateStreamingMessage, handleComplete, handleError]);
3434
+ pollingIntervalRef.current = setInterval(poll, pollingInterval ?? 2e3);
3435
+ }, [adapter, stopPolling, handleComplete, handleError, pollingInterval]);
3193
3436
  useEffect(() => {
3194
- if (!useStreamController && isUsingFallback && currentExecutionId && isLoading) {
3195
- console.log("[useAgentChat] SSE fallback detected, activating polling");
3437
+ if (!useStreamController && isUsingFallback && currentExecutionId && isLoading && pollingEnabled !== false) {
3438
+ if (__DEV__) console.log("[useAgentChat] SSE fallback detected, activating polling");
3196
3439
  startPolling(currentExecutionId);
3197
3440
  }
3198
- }, [useStreamController, isUsingFallback, currentExecutionId, isLoading, startPolling]);
3441
+ }, [useStreamController, isUsingFallback, currentExecutionId, isLoading, startPolling, pollingEnabled]);
3199
3442
  const sseTimeoutRef = useRef(null);
3200
3443
  useEffect(() => {
3201
- if (!useStreamController && currentExecutionId && isLoading && !legacyIsConnected && !isUsingFallback) {
3444
+ if (!useStreamController && currentExecutionId && isLoading && !legacyIsConnected && !isUsingFallback && pollingEnabled !== false) {
3202
3445
  sseTimeoutRef.current = setTimeout(() => {
3203
3446
  if (!legacyIsConnected && currentExecutionId && isLoading) {
3204
- console.log("[useAgentChat] SSE connection timeout, activating polling fallback");
3447
+ if (__DEV__) console.log("[useAgentChat] SSE connection timeout, activating polling fallback");
3205
3448
  startPolling(currentExecutionId);
3206
3449
  }
3207
3450
  }, 1e4);
@@ -3212,7 +3455,7 @@ function useAgentChat(options) {
3212
3455
  sseTimeoutRef.current = null;
3213
3456
  }
3214
3457
  };
3215
- }, [useStreamController, currentExecutionId, isLoading, legacyIsConnected, isUsingFallback, startPolling]);
3458
+ }, [useStreamController, currentExecutionId, isLoading, legacyIsConnected, isUsingFallback, startPolling, pollingEnabled]);
3216
3459
  useEffect(() => {
3217
3460
  if (!currentExecutionId) {
3218
3461
  stopPolling();
@@ -3228,7 +3471,7 @@ function useAgentChat(options) {
3228
3471
  streamControllerRef.current.cancel();
3229
3472
  streamControllerRef.current = null;
3230
3473
  }
3231
- console.log("[useAgentChat] Creating stream controller for:", executionId);
3474
+ if (__DEV__) console.log("[useAgentChat] Creating stream controller for:", executionId);
3232
3475
  const controller = adapter.createStream(executionId, sessionId);
3233
3476
  streamControllerRef.current = controller;
3234
3477
  controller.on("log", (log) => {
@@ -3279,6 +3522,34 @@ function useAgentChat(options) {
3279
3522
  }
3280
3523
  firedToolResultsRef.current.add(toolCallId);
3281
3524
  onToolResultRef.current?.(toolName, data.result, data.durationMs);
3525
+ updateMessageImages();
3526
+ });
3527
+ controller.on("delegationStarted", (data) => {
3528
+ const delegation = {
3529
+ type: "delegation_started",
3530
+ handoffId: data.handoffId,
3531
+ toAgent: data.targetAgentName || data.targetAgentUuid,
3532
+ targetAgentUuid: data.targetAgentUuid,
3533
+ taskPreview: data.taskPreview,
3534
+ timestamp: new Date(data.timestamp),
3535
+ status: "active"
3536
+ };
3537
+ pendingDelegationsRef.current.set(data.handoffId, delegation);
3538
+ addDelegationEvent(delegation);
3539
+ onDelegationRef.current?.(delegation);
3540
+ });
3541
+ controller.on("delegationCompleted", (data) => {
3542
+ const delegation = {
3543
+ type: "delegation_completed",
3544
+ handoffId: data.handoffId,
3545
+ resultPreview: data.resultPreview,
3546
+ timestamp: new Date(data.timestamp),
3547
+ status: data.status === "failed" ? "failed" : "completed",
3548
+ durationMs: data.durationMs
3549
+ };
3550
+ pendingDelegationsRef.current.delete(data.handoffId);
3551
+ addDelegationEvent(delegation);
3552
+ onDelegationRef.current?.(delegation);
3282
3553
  });
3283
3554
  controller.on("textDelta", (data) => {
3284
3555
  streamingContentRef.current += data.delta;
@@ -3292,11 +3563,8 @@ function useAgentChat(options) {
3292
3563
  });
3293
3564
  });
3294
3565
  controller.on("complete", ({ execution }) => {
3295
- if (execution?.output && !streamingContentRef.current) {
3296
- streamingContentRef.current = execution.output;
3297
- updateStreamingMessage(execution.output);
3298
- }
3299
- handleComplete();
3566
+ const output = execution?.output || void 0;
3567
+ handleComplete(output);
3300
3568
  });
3301
3569
  controller.on("error", (errorEvent) => {
3302
3570
  handleError(errorEvent.error);
@@ -3310,7 +3578,7 @@ function useAgentChat(options) {
3310
3578
  });
3311
3579
  setIsStreamControllerConnected(true);
3312
3580
  },
3313
- [adapter, handleExecutionLog, updateStreamingMessage, updateToolCall, handleClarification, handleComplete, handleError]
3581
+ [adapter, handleExecutionLog, updateStreamingMessage, updateToolCall, updateMessageImages, addDelegationEvent, handleClarification, handleComplete, handleError]
3314
3582
  );
3315
3583
  const sendMessage = useCallback(
3316
3584
  async (content, options2) => {
@@ -3340,8 +3608,10 @@ function useAgentChat(options) {
3340
3608
  setMessages((prev) => [...prev, assistantMessage]);
3341
3609
  streamingMessageIdRef.current = assistantMessageId;
3342
3610
  streamingContentRef.current = "";
3611
+ completedRef.current = false;
3612
+ finalizedRef.current = false;
3343
3613
  try {
3344
- console.log("[useAgentChat] Starting execution...", { agentId, sessionId: currentSessionId });
3614
+ if (__DEV__) console.log("[useAgentChat] Starting execution...", { agentId, sessionId: currentSessionId });
3345
3615
  const result = await adapter.startExecution({
3346
3616
  agentId,
3347
3617
  teamId,
@@ -3349,7 +3619,7 @@ function useAgentChat(options) {
3349
3619
  content: content.trim(),
3350
3620
  attachmentUuids
3351
3621
  });
3352
- console.log("[useAgentChat] Execution started:", result);
3622
+ if (__DEV__) console.log("[useAgentChat] Execution started:", result);
3353
3623
  if (!currentSessionId && result.sessionId) {
3354
3624
  internallyCreatedSessionRef.current = result.sessionId;
3355
3625
  setCurrentSessionId(result.sessionId);
@@ -3360,7 +3630,7 @@ function useAgentChat(options) {
3360
3630
  connectStreamController(result.executionId, result.sessionId || currentSessionId || void 0);
3361
3631
  setCurrentExecutionId(result.executionId);
3362
3632
  } else {
3363
- console.log("[useAgentChat] Setting executionId:", result.executionId);
3633
+ if (__DEV__) console.log("[useAgentChat] Setting executionId:", result.executionId);
3364
3634
  setCurrentExecutionId(result.executionId);
3365
3635
  }
3366
3636
  } catch (err) {
@@ -3420,6 +3690,7 @@ function useAgentChat(options) {
3420
3690
  setMessages([]);
3421
3691
  setCurrentSessionId(null);
3422
3692
  hasLoadedInitialSession.current = false;
3693
+ lastLoadedSessionRef.current = null;
3423
3694
  internallyCreatedSessionRef.current = null;
3424
3695
  }, []);
3425
3696
  const loadSession = useCallback(
@@ -3515,15 +3786,20 @@ function useAgentChat(options) {
3515
3786
  },
3516
3787
  [adapter, onError]
3517
3788
  );
3789
+ const lastLoadedSessionRef = useRef(null);
3518
3790
  useEffect(() => {
3519
- if (initialSessionId && !hasLoadedInitialSession.current) {
3520
- if (internallyCreatedSessionRef.current === initialSessionId) {
3521
- hasLoadedInitialSession.current = true;
3522
- return;
3523
- }
3791
+ if (!initialSessionId) return;
3792
+ if (internallyCreatedSessionRef.current === initialSessionId) {
3793
+ lastLoadedSessionRef.current = initialSessionId;
3524
3794
  hasLoadedInitialSession.current = true;
3525
- loadSession(initialSessionId);
3795
+ return;
3796
+ }
3797
+ if (lastLoadedSessionRef.current === initialSessionId && hasLoadedInitialSession.current) {
3798
+ return;
3526
3799
  }
3800
+ lastLoadedSessionRef.current = initialSessionId;
3801
+ hasLoadedInitialSession.current = true;
3802
+ loadSession(initialSessionId);
3527
3803
  }, [initialSessionId, loadSession]);
3528
3804
  useEffect(() => {
3529
3805
  return () => {
@@ -3539,6 +3815,16 @@ function useAgentChat(options) {
3539
3815
  }
3540
3816
  return !!currentExecutionId && legacyIsConnected;
3541
3817
  }, [useStreamController, currentExecutionId, isStreamControllerConnected, legacyIsConnected]);
3818
+ const activeDelegation = useMemo(() => {
3819
+ for (let i = messages.length - 1; i >= 0; i--) {
3820
+ const msg = messages[i];
3821
+ if (msg.delegationEvents) {
3822
+ const active = msg.delegationEvents.find((de) => de.status === "active");
3823
+ if (active) return active;
3824
+ }
3825
+ }
3826
+ return null;
3827
+ }, [messages]);
3542
3828
  return {
3543
3829
  messages,
3544
3830
  isLoading,
@@ -3547,6 +3833,7 @@ function useAgentChat(options) {
3547
3833
  error,
3548
3834
  sessionId: currentSessionId,
3549
3835
  clarification,
3836
+ activeDelegation,
3550
3837
  sendMessage,
3551
3838
  respondToClarification,
3552
3839
  cancel,
@@ -4402,18 +4689,30 @@ function ChatContainer({
4402
4689
  children,
4403
4690
  maxHeight = "600px",
4404
4691
  className,
4405
- theme = "system"
4692
+ theme = "system",
4693
+ layout = "fixed"
4406
4694
  }) {
4407
4695
  const maxHeightValue = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
4696
+ const isFill = layout === "fill";
4408
4697
  return /* @__PURE__ */ jsx(
4409
4698
  "div",
4410
4699
  {
4411
4700
  className: cn2(
4412
- "flex flex-col bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",
4701
+ "cadra-chat-container flex flex-col overflow-hidden",
4702
+ // Default colors use CSS custom properties with Tailwind fallbacks.
4703
+ // Consumers can override via CSS: --chat-bg, --chat-border, --chat-border-radius
4704
+ !isFill && "rounded-lg border",
4705
+ isFill && "flex-1 min-h-0",
4413
4706
  className
4414
4707
  ),
4415
- style: { maxHeight: maxHeightValue },
4708
+ style: {
4709
+ ...!isFill ? { maxHeight: maxHeightValue } : void 0,
4710
+ // CSS custom properties for theming — consumers set these to override
4711
+ backgroundColor: "var(--chat-bg, var(--background, #fff))",
4712
+ borderColor: !isFill ? "var(--chat-border, var(--border, #e5e7eb))" : void 0
4713
+ },
4416
4714
  "data-theme": theme,
4715
+ "data-layout": layout,
4417
4716
  children
4418
4717
  }
4419
4718
  );
@@ -5100,7 +5399,7 @@ var FileDropZone = forwardRef(
5100
5399
  {
5101
5400
  ref: dropZoneRef,
5102
5401
  "data-dropzone": "wrapper",
5103
- className: cn4("relative w-full h-full", className),
5402
+ className: cn4("relative flex flex-col flex-1 min-h-0", className),
5104
5403
  style: { minHeight: "inherit" },
5105
5404
  children: [
5106
5405
  /* @__PURE__ */ jsx(
@@ -5385,6 +5684,312 @@ function AskUserPrompt({
5385
5684
  function cn6(...classes) {
5386
5685
  return classes.filter(Boolean).join(" ");
5387
5686
  }
5687
+ function formatDuration(ms) {
5688
+ if (ms < 1e3) return `${ms}ms`;
5689
+ return `${(ms / 1e3).toFixed(1)}s`;
5690
+ }
5691
+ function DelegationProgress({
5692
+ event,
5693
+ className
5694
+ }) {
5695
+ const statusIcon = useMemo(() => {
5696
+ switch (event.status) {
5697
+ case "active":
5698
+ return /* @__PURE__ */ jsx(LoadingSpinner, { className: "h-4 w-4 text-blue-500" });
5699
+ case "completed":
5700
+ return /* @__PURE__ */ jsx(CheckCircleIcon, { className: "h-4 w-4 text-green-500" });
5701
+ case "failed":
5702
+ return /* @__PURE__ */ jsx(AlertCircleIcon, { className: "h-4 w-4 text-red-500" });
5703
+ default:
5704
+ return /* @__PURE__ */ jsx(LoadingSpinner, { className: "h-4 w-4 text-gray-400" });
5705
+ }
5706
+ }, [event.status]);
5707
+ const statusColor = useMemo(() => {
5708
+ switch (event.status) {
5709
+ case "active":
5710
+ return "border-blue-200 dark:border-blue-800 bg-blue-50/50 dark:bg-blue-950/20";
5711
+ case "completed":
5712
+ return "border-green-200 dark:border-green-800 bg-green-50/50 dark:bg-green-950/20";
5713
+ case "failed":
5714
+ return "border-red-200 dark:border-red-800 bg-red-50/50 dark:bg-red-950/20";
5715
+ default:
5716
+ return "border-gray-200 dark:border-gray-700";
5717
+ }
5718
+ }, [event.status]);
5719
+ return /* @__PURE__ */ jsx(
5720
+ "div",
5721
+ {
5722
+ className: cn6(
5723
+ "rounded-lg border text-sm px-3 py-2",
5724
+ statusColor,
5725
+ className
5726
+ ),
5727
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5728
+ statusIcon,
5729
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
5730
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
5731
+ event.fromAgent && /* @__PURE__ */ jsxs(Fragment, { children: [
5732
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-700 dark:text-gray-300 truncate", children: event.fromAgent }),
5733
+ /* @__PURE__ */ jsx("span", { className: "text-gray-400 dark:text-gray-500 flex-shrink-0", children: "\u2192" })
5734
+ ] }),
5735
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-900 dark:text-gray-100 truncate", children: event.toAgent || event.targetAgentUuid || "Specialist" })
5736
+ ] }),
5737
+ event.taskPreview && event.status === "active" && /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 truncate mt-0.5", children: event.taskPreview }),
5738
+ event.resultPreview && event.status === "completed" && /* @__PURE__ */ jsx("p", { className: "text-xs text-green-600 dark:text-green-400 truncate mt-0.5", children: event.resultPreview })
5739
+ ] }),
5740
+ event.durationMs !== void 0 && event.status !== "active" && /* @__PURE__ */ jsx("span", { className: "text-xs text-gray-500 dark:text-gray-400 flex-shrink-0", children: formatDuration(event.durationMs) })
5741
+ ] })
5742
+ }
5743
+ );
5744
+ }
5745
+ function DelegationProgressList({
5746
+ events,
5747
+ className
5748
+ }) {
5749
+ if (!events || events.length === 0) return null;
5750
+ return /* @__PURE__ */ jsx("div", { className: cn6("space-y-2", className), children: events.map((event, index) => /* @__PURE__ */ jsx(
5751
+ DelegationProgress,
5752
+ {
5753
+ event
5754
+ },
5755
+ event.handoffId || `delegation-${index}`
5756
+ )) });
5757
+ }
5758
+ function ImageLightbox({
5759
+ images,
5760
+ currentIndex,
5761
+ onClose,
5762
+ onPrev,
5763
+ onNext,
5764
+ className
5765
+ }) {
5766
+ const currentImage = images[currentIndex];
5767
+ const hasMultiple = images.length > 1;
5768
+ useEffect(() => {
5769
+ function handleKeyDown(e) {
5770
+ switch (e.key) {
5771
+ case "Escape":
5772
+ onClose();
5773
+ break;
5774
+ case "ArrowLeft":
5775
+ if (hasMultiple) onPrev();
5776
+ break;
5777
+ case "ArrowRight":
5778
+ if (hasMultiple) onNext();
5779
+ break;
5780
+ }
5781
+ }
5782
+ document.addEventListener("keydown", handleKeyDown);
5783
+ return () => document.removeEventListener("keydown", handleKeyDown);
5784
+ }, [onClose, onPrev, onNext, hasMultiple]);
5785
+ useEffect(() => {
5786
+ const originalOverflow = document.body.style.overflow;
5787
+ document.body.style.overflow = "hidden";
5788
+ return () => {
5789
+ document.body.style.overflow = originalOverflow;
5790
+ };
5791
+ }, []);
5792
+ const handleDownload = useCallback(() => {
5793
+ if (!currentImage) return;
5794
+ const link = document.createElement("a");
5795
+ link.href = currentImage.url;
5796
+ link.download = currentImage.filename || `image-${currentIndex + 1}`;
5797
+ link.target = "_blank";
5798
+ link.rel = "noopener noreferrer";
5799
+ document.body.appendChild(link);
5800
+ link.click();
5801
+ document.body.removeChild(link);
5802
+ }, [currentImage, currentIndex]);
5803
+ if (!currentImage) return null;
5804
+ return /* @__PURE__ */ jsxs(
5805
+ "div",
5806
+ {
5807
+ className: `fixed inset-0 z-50 flex items-center justify-center bg-black/80 ${className || ""}`,
5808
+ onClick: onClose,
5809
+ children: [
5810
+ /* @__PURE__ */ jsxs("div", { className: "absolute top-0 left-0 right-0 flex items-center justify-between p-4 z-10", children: [
5811
+ /* @__PURE__ */ jsx("div", { className: "text-white text-sm", children: hasMultiple && /* @__PURE__ */ jsxs("span", { children: [
5812
+ currentIndex + 1,
5813
+ " / ",
5814
+ images.length
5815
+ ] }) }),
5816
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5817
+ /* @__PURE__ */ jsx(
5818
+ "button",
5819
+ {
5820
+ type: "button",
5821
+ onClick: (e) => {
5822
+ e.stopPropagation();
5823
+ handleDownload();
5824
+ },
5825
+ className: "p-2 rounded-full bg-black/50 hover:bg-black/70 text-white transition-colors",
5826
+ "aria-label": "Download image",
5827
+ children: /* @__PURE__ */ jsx(DownloadIcon, { className: "h-5 w-5" })
5828
+ }
5829
+ ),
5830
+ /* @__PURE__ */ jsx(
5831
+ "button",
5832
+ {
5833
+ type: "button",
5834
+ onClick: (e) => {
5835
+ e.stopPropagation();
5836
+ onClose();
5837
+ },
5838
+ className: "p-2 rounded-full bg-black/50 hover:bg-black/70 text-white transition-colors",
5839
+ "aria-label": "Close lightbox",
5840
+ children: /* @__PURE__ */ jsx(XIcon, { className: "h-5 w-5" })
5841
+ }
5842
+ )
5843
+ ] })
5844
+ ] }),
5845
+ hasMultiple && /* @__PURE__ */ jsx(
5846
+ "button",
5847
+ {
5848
+ type: "button",
5849
+ onClick: (e) => {
5850
+ e.stopPropagation();
5851
+ onPrev();
5852
+ },
5853
+ className: "absolute left-4 top-1/2 -translate-y-1/2 p-2 rounded-full bg-black/50 hover:bg-black/70 text-white transition-colors z-10",
5854
+ "aria-label": "Previous image",
5855
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "h-6 w-6" })
5856
+ }
5857
+ ),
5858
+ /* @__PURE__ */ jsx(
5859
+ "img",
5860
+ {
5861
+ src: currentImage.url,
5862
+ alt: currentImage.alt || `Image ${currentIndex + 1}`,
5863
+ className: "max-w-[90vw] max-h-[85vh] object-contain",
5864
+ onClick: (e) => e.stopPropagation()
5865
+ }
5866
+ ),
5867
+ hasMultiple && /* @__PURE__ */ jsx(
5868
+ "button",
5869
+ {
5870
+ type: "button",
5871
+ onClick: (e) => {
5872
+ e.stopPropagation();
5873
+ onNext();
5874
+ },
5875
+ className: "absolute right-4 top-1/2 -translate-y-1/2 p-2 rounded-full bg-black/50 hover:bg-black/70 text-white transition-colors z-10",
5876
+ "aria-label": "Next image",
5877
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-6 w-6" })
5878
+ }
5879
+ ),
5880
+ currentImage.alt && /* @__PURE__ */ jsx("div", { className: "absolute bottom-0 left-0 right-0 p-4 text-center z-10", children: /* @__PURE__ */ jsx("p", { className: "text-white text-sm bg-black/50 inline-block px-3 py-1 rounded-full", children: currentImage.alt }) })
5881
+ ]
5882
+ }
5883
+ );
5884
+ }
5885
+ function cn7(...classes) {
5886
+ return classes.filter(Boolean).join(" ");
5887
+ }
5888
+ function ImageWithLoading({ src, alt, className, onClick }) {
5889
+ const [isLoaded, setIsLoaded] = useState(false);
5890
+ const [hasError, setHasError] = useState(false);
5891
+ return /* @__PURE__ */ jsxs(
5892
+ "div",
5893
+ {
5894
+ className: cn7(
5895
+ "relative overflow-hidden bg-gray-100 dark:bg-gray-800",
5896
+ className
5897
+ ),
5898
+ children: [
5899
+ !isLoaded && !hasError && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 animate-pulse bg-gray-200 dark:bg-gray-700" }),
5900
+ hasError && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-sm", children: "Failed to load" }),
5901
+ /* @__PURE__ */ jsx(
5902
+ "img",
5903
+ {
5904
+ src,
5905
+ alt,
5906
+ loading: "lazy",
5907
+ className: cn7(
5908
+ "w-full h-auto max-h-[300px] object-contain transition-opacity duration-200",
5909
+ isLoaded ? "opacity-100" : "opacity-0"
5910
+ ),
5911
+ onLoad: () => setIsLoaded(true),
5912
+ onError: () => setHasError(true),
5913
+ onClick,
5914
+ style: onClick ? { cursor: "pointer" } : void 0
5915
+ }
5916
+ )
5917
+ ]
5918
+ }
5919
+ );
5920
+ }
5921
+ function ImageGallery({
5922
+ images,
5923
+ onImageClick,
5924
+ className
5925
+ }) {
5926
+ const [lightboxIndex, setLightboxIndex] = useState(null);
5927
+ const handleImageClick = useCallback(
5928
+ (image, index) => {
5929
+ if (onImageClick) {
5930
+ onImageClick(image);
5931
+ } else {
5932
+ setLightboxIndex(index);
5933
+ }
5934
+ },
5935
+ [onImageClick]
5936
+ );
5937
+ const handleLightboxClose = useCallback(() => {
5938
+ setLightboxIndex(null);
5939
+ }, []);
5940
+ const handleLightboxPrev = useCallback(() => {
5941
+ setLightboxIndex(
5942
+ (prev) => prev !== null ? (prev - 1 + images.length) % images.length : null
5943
+ );
5944
+ }, [images.length]);
5945
+ const handleLightboxNext = useCallback(() => {
5946
+ setLightboxIndex(
5947
+ (prev) => prev !== null ? (prev + 1) % images.length : null
5948
+ );
5949
+ }, [images.length]);
5950
+ if (!images || images.length === 0) return null;
5951
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5952
+ /* @__PURE__ */ jsx(
5953
+ "div",
5954
+ {
5955
+ className: cn7(
5956
+ "grid gap-2",
5957
+ images.length === 1 ? "grid-cols-1" : images.length === 2 ? "grid-cols-2" : "grid-cols-2 sm:grid-cols-3",
5958
+ className
5959
+ ),
5960
+ children: images.map((image, index) => /* @__PURE__ */ jsx(
5961
+ "button",
5962
+ {
5963
+ type: "button",
5964
+ onClick: () => handleImageClick(image, index),
5965
+ className: "block rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700 hover:border-blue-400 dark:hover:border-blue-600 transition-colors text-left",
5966
+ children: /* @__PURE__ */ jsx(
5967
+ ImageWithLoading,
5968
+ {
5969
+ src: image.url,
5970
+ alt: image.alt || `Image ${index + 1}`
5971
+ }
5972
+ )
5973
+ },
5974
+ `${image.url}-${index}`
5975
+ ))
5976
+ }
5977
+ ),
5978
+ lightboxIndex !== null && !onImageClick && /* @__PURE__ */ jsx(
5979
+ ImageLightbox,
5980
+ {
5981
+ images,
5982
+ currentIndex: lightboxIndex,
5983
+ onClose: handleLightboxClose,
5984
+ onPrev: handleLightboxPrev,
5985
+ onNext: handleLightboxNext
5986
+ }
5987
+ )
5988
+ ] });
5989
+ }
5990
+ function cn8(...classes) {
5991
+ return classes.filter(Boolean).join(" ");
5992
+ }
5388
5993
  function MarkdownContent({
5389
5994
  content,
5390
5995
  className,
@@ -5404,11 +6009,11 @@ function MarkdownContent({
5404
6009
  h3: ({ children }) => /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mt-3 mb-1 first:mt-0", children }),
5405
6010
  h4: ({ children }) => /* @__PURE__ */ jsx("h4", { className: "text-base font-semibold mt-2 mb-1 first:mt-0", children }),
5406
6011
  // Paragraphs
5407
- p: ({ children }) => /* @__PURE__ */ jsx("p", { className: "mb-2 last:mb-0 leading-relaxed", children }),
6012
+ p: ({ children }) => /* @__PURE__ */ jsx("p", { className: "mb-1.5 last:mb-0", children }),
5408
6013
  // Lists
5409
- ul: ({ children }) => /* @__PURE__ */ jsx("ul", { className: "list-disc list-inside mb-2 space-y-1", children }),
5410
- ol: ({ children }) => /* @__PURE__ */ jsx("ol", { className: "list-decimal list-inside mb-2 space-y-1", children }),
5411
- li: ({ children }) => /* @__PURE__ */ jsx("li", { className: "leading-relaxed", children }),
6014
+ ul: ({ children }) => /* @__PURE__ */ jsx("ul", { className: "list-disc list-inside mb-1.5 last:mb-0", children }),
6015
+ ol: ({ children }) => /* @__PURE__ */ jsx("ol", { className: "list-decimal list-inside mb-1.5 last:mb-0", children }),
6016
+ li: ({ children }) => /* @__PURE__ */ jsx("li", { className: "", children }),
5412
6017
  // Links
5413
6018
  a: ({ href, children }) => /* @__PURE__ */ jsx(
5414
6019
  "a",
@@ -5443,7 +6048,7 @@ function MarkdownContent({
5443
6048
  if (isCodeBlock) {
5444
6049
  return /* @__PURE__ */ jsxs("div", { className: "relative my-2", children: [
5445
6050
  language && /* @__PURE__ */ jsx("div", { className: "absolute top-0 right-0 px-2 py-1 text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-bl rounded-tr border-b border-l border-gray-200 dark:border-gray-700", children: language }),
5446
- /* @__PURE__ */ jsx("pre", { className: "bg-gray-100 dark:bg-gray-800 rounded-lg p-4 overflow-x-auto text-sm", children: /* @__PURE__ */ jsx("code", { className: cn6("font-mono", codeClassName), ...props, children }) })
6051
+ /* @__PURE__ */ jsx("pre", { className: "bg-gray-100 dark:bg-gray-800 rounded-lg p-4 overflow-x-auto text-sm", children: /* @__PURE__ */ jsx("code", { className: cn8("font-mono", codeClassName), ...props, children }) })
5447
6052
  ] });
5448
6053
  }
5449
6054
  return /* @__PURE__ */ jsx(
@@ -5490,7 +6095,7 @@ function MarkdownContent({
5490
6095
  () => customComponents ? { ...defaultComponents, ...customComponents } : defaultComponents,
5491
6096
  [defaultComponents, customComponents]
5492
6097
  );
5493
- return /* @__PURE__ */ jsx("div", { className: cn6("prose prose-sm dark:prose-invert max-w-none", className), children: /* @__PURE__ */ jsx(
6098
+ return /* @__PURE__ */ jsx("div", { className: cn8("max-w-none text-sm leading-relaxed", className), children: /* @__PURE__ */ jsx(
5494
6099
  ReactMarkdown,
5495
6100
  {
5496
6101
  remarkPlugins: [remarkGfm],
@@ -5500,7 +6105,89 @@ function MarkdownContent({
5500
6105
  }
5501
6106
  ) });
5502
6107
  }
5503
- function cn7(...classes) {
6108
+ function cn9(...classes) {
6109
+ return classes.filter(Boolean).join(" ");
6110
+ }
6111
+ function ThinkingBlock({
6112
+ block,
6113
+ defaultExpanded = false,
6114
+ className
6115
+ }) {
6116
+ const [isExpanded, setIsExpanded] = useState(defaultExpanded);
6117
+ return /* @__PURE__ */ jsxs(
6118
+ "div",
6119
+ {
6120
+ className: cn9(
6121
+ "rounded-lg border",
6122
+ "border-purple-200 dark:border-purple-800",
6123
+ "bg-purple-50/50 dark:bg-purple-950/20",
6124
+ className
6125
+ ),
6126
+ children: [
6127
+ /* @__PURE__ */ jsxs(
6128
+ "button",
6129
+ {
6130
+ type: "button",
6131
+ onClick: () => setIsExpanded(!isExpanded),
6132
+ className: "w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-purple-100/50 dark:hover:bg-purple-900/30 transition-colors rounded-lg",
6133
+ children: [
6134
+ isExpanded ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-purple-400 flex-shrink-0" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-purple-400 flex-shrink-0" }),
6135
+ /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4 text-purple-500 flex-shrink-0" }),
6136
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-purple-700 dark:text-purple-300", children: "Thinking" })
6137
+ ]
6138
+ }
6139
+ ),
6140
+ isExpanded && /* @__PURE__ */ jsx("div", { className: "px-3 pb-3 border-t border-purple-200 dark:border-purple-800", children: /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-purple-800 dark:text-purple-200 whitespace-pre-wrap font-mono leading-relaxed", children: block.content }) })
6141
+ ]
6142
+ }
6143
+ );
6144
+ }
6145
+ function ThinkingBlockList({
6146
+ blocks,
6147
+ defaultExpanded = false,
6148
+ className
6149
+ }) {
6150
+ if (!blocks || blocks.length === 0) return null;
6151
+ return /* @__PURE__ */ jsx("div", { className: cn9("space-y-2", className), children: blocks.map((block) => /* @__PURE__ */ jsx(
6152
+ ThinkingBlock,
6153
+ {
6154
+ block,
6155
+ defaultExpanded
6156
+ },
6157
+ block.id
6158
+ )) });
6159
+ }
6160
+ var INTERNAL_TOOL_NAMES = /* @__PURE__ */ new Set([
6161
+ "update_task_list",
6162
+ "create_task",
6163
+ "mark_task_complete",
6164
+ "handoff_to_agent",
6165
+ "delegate_to_agent",
6166
+ "delegate_task",
6167
+ "get_tool_info",
6168
+ "get_tools",
6169
+ "list_tools",
6170
+ "call_tool",
6171
+ "invoke_tool",
6172
+ "execute_tool",
6173
+ "check_task_status",
6174
+ "assign_task",
6175
+ "update_plan",
6176
+ "check_delegations"
6177
+ ]);
6178
+ function isInternalTool(toolName) {
6179
+ if (!toolName) return false;
6180
+ const lower = toolName.toLowerCase();
6181
+ if (INTERNAL_TOOL_NAMES.has(lower)) return true;
6182
+ for (const internal of INTERNAL_TOOL_NAMES) {
6183
+ if (lower.endsWith(internal) && lower.length > internal.length) {
6184
+ const charBefore = lower[lower.length - internal.length - 1];
6185
+ if (charBefore === "_" || charBefore === ".") return true;
6186
+ }
6187
+ }
6188
+ return false;
6189
+ }
6190
+ function cn10(...classes) {
5504
6191
  return classes.filter(Boolean).join(" ");
5505
6192
  }
5506
6193
  function formatToolName(toolName) {
@@ -5549,7 +6236,7 @@ function formatToolName(toolName) {
5549
6236
  }
5550
6237
  return uniqueWords.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
5551
6238
  }
5552
- function formatDuration(ms) {
6239
+ function formatDuration2(ms) {
5553
6240
  if (ms < 1e3) {
5554
6241
  return `${ms}ms`;
5555
6242
  }
@@ -5570,7 +6257,7 @@ function formatJsonPreview(data, maxLength = 100) {
5570
6257
  return String(data);
5571
6258
  }
5572
6259
  }
5573
- function extractImagesFromResult(result) {
6260
+ function extractImagesFromResult2(result) {
5574
6261
  if (!result) return [];
5575
6262
  let data = result;
5576
6263
  if (typeof result === "string") {
@@ -5605,7 +6292,8 @@ function ToolCallEntry({
5605
6292
  toolCall,
5606
6293
  className,
5607
6294
  showFullJson = true,
5608
- onImageClick
6295
+ onImageClick,
6296
+ compact = false
5609
6297
  }) {
5610
6298
  const [isExpanded, setIsExpanded] = useState(false);
5611
6299
  const formattedName = useMemo(
@@ -5613,7 +6301,7 @@ function ToolCallEntry({
5613
6301
  [toolCall.name]
5614
6302
  );
5615
6303
  const resultImages = useMemo(
5616
- () => toolCall.status === "completed" && toolCall.result ? extractImagesFromResult(toolCall.result) : [],
6304
+ () => toolCall.status === "completed" && toolCall.result ? extractImagesFromResult2(toolCall.result) : [],
5617
6305
  [toolCall.status, toolCall.result]
5618
6306
  );
5619
6307
  const hasImages = resultImages.length > 0;
@@ -5645,10 +6333,26 @@ function ToolCallEntry({
5645
6333
  return "border-gray-200 dark:border-gray-700";
5646
6334
  }
5647
6335
  }, [toolCall.status]);
6336
+ if (compact && (toolCall.status === "completed" || toolCall.status === "failed")) {
6337
+ return /* @__PURE__ */ jsxs(
6338
+ "div",
6339
+ {
6340
+ className: cn10(
6341
+ "inline-flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",
6342
+ className
6343
+ ),
6344
+ children: [
6345
+ /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: statusIcon }),
6346
+ /* @__PURE__ */ jsx("span", { children: formattedName }),
6347
+ toolCall.durationMs !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-gray-400 dark:text-gray-500", children: formatDuration2(toolCall.durationMs) })
6348
+ ]
6349
+ }
6350
+ );
6351
+ }
5648
6352
  return /* @__PURE__ */ jsxs(
5649
6353
  "div",
5650
6354
  {
5651
- className: cn7(
6355
+ className: cn10(
5652
6356
  "rounded-lg border text-sm",
5653
6357
  statusColor,
5654
6358
  className
@@ -5664,12 +6368,12 @@ function ToolCallEntry({
5664
6368
  isExpanded ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-gray-400 flex-shrink-0" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-gray-400 flex-shrink-0" }),
5665
6369
  /* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: statusIcon }),
5666
6370
  /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-900 dark:text-gray-100 truncate", children: formattedName }),
5667
- toolCall.status === "completed" && toolCall.durationMs !== void 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-gray-500 dark:text-gray-400 flex-shrink-0", children: formatDuration(toolCall.durationMs) }),
6371
+ toolCall.status === "completed" && toolCall.durationMs !== void 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-gray-500 dark:text-gray-400 flex-shrink-0", children: formatDuration2(toolCall.durationMs) }),
5668
6372
  toolCall.status === "failed" && toolCall.error && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-red-600 dark:text-red-400 truncate max-w-[150px]", children: toolCall.error })
5669
6373
  ]
5670
6374
  }
5671
6375
  ),
5672
- hasImages && /* @__PURE__ */ jsx("div", { className: "px-3 pb-2", children: /* @__PURE__ */ jsx("div", { className: cn7(
6376
+ hasImages && /* @__PURE__ */ jsx("div", { className: "px-3 pb-2", children: /* @__PURE__ */ jsx("div", { className: cn10(
5673
6377
  "grid gap-2",
5674
6378
  resultImages.length === 1 ? "grid-cols-1" : "grid-cols-2"
5675
6379
  ), children: resultImages.map((img, idx) => {
@@ -5728,21 +6432,28 @@ function ToolCallEntry({
5728
6432
  }
5729
6433
  );
5730
6434
  }
5731
- function cn8(...classes) {
6435
+ function cn11(...classes) {
5732
6436
  return classes.filter(Boolean).join(" ");
5733
6437
  }
5734
6438
  function ChatMessage({
5735
6439
  message,
5736
6440
  enableMarkdown = true,
5737
6441
  showToolCalls = true,
6442
+ toolCallVerbosity: _toolCallVerbosity,
5738
6443
  className,
5739
6444
  markdownComponents,
5740
6445
  markdownUrlTransform,
5741
6446
  markdownContentTransform,
5742
- onImageClick
6447
+ onImageClick,
6448
+ showThinking = true,
6449
+ showDelegation = true,
6450
+ showImages = true,
6451
+ renderToolCall,
6452
+ variant = "bubble"
5743
6453
  }) {
5744
6454
  const isUser = message.role === "user";
5745
6455
  const isAssistant = message.role === "assistant";
6456
+ const isFlat = variant === "flat";
5746
6457
  const formattedTime = useMemo(() => {
5747
6458
  const date = message.timestamp instanceof Date ? message.timestamp : new Date(message.timestamp);
5748
6459
  return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
@@ -5750,85 +6461,124 @@ function ChatMessage({
5750
6461
  return /* @__PURE__ */ jsxs(
5751
6462
  "div",
5752
6463
  {
5753
- className: cn8(
5754
- "flex gap-3 p-4",
5755
- isUser ? "flex-row-reverse" : "flex-row",
6464
+ className: cn11(
6465
+ "cadra-chat-message flex gap-3",
6466
+ isFlat ? "py-5 px-4" : "p-4",
6467
+ // Bubble: user messages right-aligned. Flat: always left-aligned.
6468
+ !isFlat && isUser ? "flex-row-reverse" : "flex-row",
6469
+ // Flat variant: subtle row background for user messages
6470
+ isFlat && isUser && "chat-message-user-row",
5756
6471
  className
5757
6472
  ),
6473
+ style: isFlat && isUser ? {
6474
+ backgroundColor: "var(--chat-user-row-bg, rgba(128, 128, 128, 0.08))"
6475
+ } : void 0,
6476
+ "data-role": message.role,
5758
6477
  children: [
5759
6478
  /* @__PURE__ */ jsx(
5760
6479
  "div",
5761
6480
  {
5762
- className: cn8(
5763
- "flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center",
5764
- isUser ? "bg-blue-500 text-white" : "bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300"
5765
- ),
6481
+ className: "flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center shadow-sm",
6482
+ style: {
6483
+ backgroundColor: isUser ? "var(--chat-user-avatar-bg, #3b82f6)" : "var(--chat-assistant-avatar-bg, #e5e7eb)",
6484
+ color: isUser ? "var(--chat-user-avatar-text, #fff)" : "var(--chat-assistant-avatar-text, #4b5563)"
6485
+ },
5766
6486
  children: isUser ? /* @__PURE__ */ jsx(UserIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(BotIcon, { className: "h-4 w-4" })
5767
6487
  }
5768
6488
  ),
5769
6489
  /* @__PURE__ */ jsxs(
5770
6490
  "div",
5771
6491
  {
5772
- className: cn8(
5773
- "flex-1 min-w-0 space-y-2",
5774
- isUser ? "text-right" : "text-left"
6492
+ className: cn11(
6493
+ "flex-1 min-w-0",
6494
+ isFlat ? "pt-0.5" : "space-y-2",
6495
+ !isFlat && isUser ? "text-right" : "text-left"
5775
6496
  ),
5776
6497
  children: [
5777
6498
  /* @__PURE__ */ jsxs(
5778
6499
  "div",
5779
6500
  {
5780
- className: cn8(
5781
- "flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",
5782
- isUser ? "justify-end" : "justify-start"
6501
+ className: cn11(
6502
+ "flex items-center gap-2 text-xs",
6503
+ isFlat ? "mb-1.5" : "",
6504
+ !isFlat && isUser ? "justify-end" : "justify-start"
5783
6505
  ),
6506
+ style: { color: "var(--chat-meta-text, #6b7280)" },
5784
6507
  children: [
5785
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: isUser ? "You" : "Assistant" }),
6508
+ /* @__PURE__ */ jsx("span", { className: "font-medium", style: { color: "var(--chat-label-text, inherit)" }, children: isUser ? "You" : "Assistant" }),
5786
6509
  /* @__PURE__ */ jsx("span", { children: formattedTime }),
5787
6510
  message.isStreaming && /* @__PURE__ */ jsx(LoadingSpinner, { className: "h-3 w-3" })
5788
6511
  ]
5789
6512
  }
5790
6513
  ),
5791
- message.thinkingBlocks && message.thinkingBlocks.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: message.thinkingBlocks.map((block) => /* @__PURE__ */ jsxs(
5792
- "div",
5793
- {
5794
- className: "bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-3 text-sm text-purple-800 dark:text-purple-200",
5795
- children: [
5796
- /* @__PURE__ */ jsx("div", { className: "text-xs font-medium text-purple-600 dark:text-purple-400 mb-1", children: "Thinking..." }),
5797
- /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: block.content })
5798
- ]
5799
- },
5800
- block.id
5801
- )) }),
5802
- showToolCalls && message.toolCalls && message.toolCalls.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: message.toolCalls.map((toolCall) => /* @__PURE__ */ jsx(
5803
- ToolCallEntry,
5804
- {
5805
- toolCall,
5806
- onImageClick
5807
- },
5808
- toolCall.id
5809
- )) }),
5810
- message.content && /* @__PURE__ */ jsx(
5811
- "div",
6514
+ showThinking && message.thinkingBlocks && message.thinkingBlocks.length > 0 && /* @__PURE__ */ jsx(ThinkingBlockList, { blocks: message.thinkingBlocks }),
6515
+ showDelegation && message.delegationEvents && message.delegationEvents.length > 0 && /* @__PURE__ */ jsx(DelegationProgressList, { events: message.delegationEvents }),
6516
+ showToolCalls && message.toolCalls && message.toolCalls.length > 0 && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: message.toolCalls.map((toolCall) => {
6517
+ const defaultRender = () => /* @__PURE__ */ jsx(
6518
+ ToolCallEntry,
6519
+ {
6520
+ toolCall,
6521
+ onImageClick
6522
+ },
6523
+ toolCall.id
6524
+ );
6525
+ if (renderToolCall) {
6526
+ return /* @__PURE__ */ jsx("div", { children: renderToolCall(toolCall, defaultRender) }, toolCall.id);
6527
+ }
6528
+ return defaultRender();
6529
+ }) }),
6530
+ showImages && message.images && message.images.length > 0 && /* @__PURE__ */ jsx(
6531
+ ImageGallery,
5812
6532
  {
5813
- className: cn8(
5814
- "rounded-lg p-3",
5815
- isUser ? "bg-blue-500 text-white" : "bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100"
5816
- ),
5817
- children: isAssistant && enableMarkdown ? /* @__PURE__ */ jsx(
5818
- MarkdownContent,
5819
- {
5820
- content: message.content,
5821
- components: markdownComponents,
5822
- urlTransform: markdownUrlTransform,
5823
- contentTransform: markdownContentTransform
5824
- }
5825
- ) : /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: message.content })
6533
+ images: message.images,
6534
+ onImageClick: onImageClick ? (img) => onImageClick({ url: img.url, alt: img.alt, filename: img.filename }) : void 0
5826
6535
  }
5827
6536
  ),
6537
+ message.content && (isFlat ? (
6538
+ // Flat variant: no bubble, just text with theme-aware color
6539
+ /* @__PURE__ */ jsx(
6540
+ "div",
6541
+ {
6542
+ className: cn11("text-sm break-words", !(isAssistant && enableMarkdown) && "whitespace-pre-wrap"),
6543
+ style: { color: "var(--chat-content-text, inherit)" },
6544
+ children: isAssistant && enableMarkdown ? /* @__PURE__ */ jsx(
6545
+ MarkdownContent,
6546
+ {
6547
+ content: message.content,
6548
+ components: markdownComponents,
6549
+ urlTransform: markdownUrlTransform,
6550
+ contentTransform: markdownContentTransform
6551
+ }
6552
+ ) : /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: message.content })
6553
+ }
6554
+ )
6555
+ ) : (
6556
+ // Bubble variant: colored bubble backgrounds
6557
+ /* @__PURE__ */ jsx(
6558
+ "div",
6559
+ {
6560
+ className: "rounded-lg p-3",
6561
+ style: {
6562
+ backgroundColor: isUser ? "var(--chat-user-bg, #3b82f6)" : "var(--chat-assistant-bg, #f3f4f6)",
6563
+ color: isUser ? "var(--chat-user-text, #fff)" : "var(--chat-assistant-text, #111827)"
6564
+ },
6565
+ children: isAssistant && enableMarkdown ? /* @__PURE__ */ jsx(
6566
+ MarkdownContent,
6567
+ {
6568
+ content: message.content,
6569
+ components: markdownComponents,
6570
+ urlTransform: markdownUrlTransform,
6571
+ contentTransform: markdownContentTransform
6572
+ }
6573
+ ) : /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap", children: message.content })
6574
+ }
6575
+ )
6576
+ )),
5828
6577
  message.attachments && message.attachments.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: message.attachments.map((attachment) => /* @__PURE__ */ jsx(
5829
6578
  "div",
5830
6579
  {
5831
- className: "flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm",
6580
+ className: "flex items-center gap-2 rounded-lg px-3 py-2 text-sm",
6581
+ style: { backgroundColor: "var(--chat-assistant-bg, #f3f4f6)" },
5832
6582
  children: /* @__PURE__ */ jsx("span", { className: "truncate max-w-[150px]", children: attachment.filename })
5833
6583
  },
5834
6584
  attachment.uuid
@@ -5840,7 +6590,7 @@ function ChatMessage({
5840
6590
  }
5841
6591
  );
5842
6592
  }
5843
- function cn9(...classes) {
6593
+ function cn12(...classes) {
5844
6594
  return classes.filter(Boolean).join(" ");
5845
6595
  }
5846
6596
  function MessageList({
@@ -5852,11 +6602,18 @@ function MessageList({
5852
6602
  isLoadingHistory = false,
5853
6603
  enableMarkdown = true,
5854
6604
  showToolCalls = true,
6605
+ toolCallVerbosity,
5855
6606
  className,
5856
6607
  markdownComponents,
5857
6608
  markdownUrlTransform,
5858
6609
  markdownContentTransform,
5859
6610
  onImageClick,
6611
+ showThinking = true,
6612
+ showDelegation = true,
6613
+ showImages = true,
6614
+ renderMessage,
6615
+ renderToolCall,
6616
+ messageVariant = "bubble",
5860
6617
  sendMessage
5861
6618
  }) {
5862
6619
  const scrollRef = useRef(null);
@@ -5870,7 +6627,7 @@ function MessageList({
5870
6627
  "div",
5871
6628
  {
5872
6629
  ref: scrollRef,
5873
- className: cn9(
6630
+ className: cn12(
5874
6631
  "flex-1 overflow-y-auto",
5875
6632
  className
5876
6633
  ),
@@ -5881,19 +6638,31 @@ function MessageList({
5881
6638
  ] }) }),
5882
6639
  messages.length === 0 && !isLoading && !isLoadingHistory && (renderWelcome ? /* @__PURE__ */ jsx(Fragment, { children: typeof renderWelcome === "function" ? renderWelcome({ sendMessage: sendMessage || (() => {
5883
6640
  }) }) : renderWelcome }) : /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full p-8", children: /* @__PURE__ */ jsx("div", { className: "text-center text-gray-500 dark:text-gray-400", children: /* @__PURE__ */ jsx("p", { className: "text-lg", children: welcomeMessage }) }) })),
5884
- /* @__PURE__ */ jsx("div", { className: "divide-y divide-gray-100 dark:divide-gray-800", children: messages.map((message) => /* @__PURE__ */ jsx(
5885
- ChatMessage,
5886
- {
5887
- message,
5888
- enableMarkdown,
5889
- showToolCalls,
5890
- markdownComponents,
5891
- markdownUrlTransform,
5892
- markdownContentTransform,
5893
- onImageClick
5894
- },
5895
- message.id
5896
- )) }),
6641
+ /* @__PURE__ */ jsx("div", { className: "divide-y divide-gray-100 dark:divide-gray-800", children: messages.map((message) => {
6642
+ const defaultRender = () => /* @__PURE__ */ jsx(
6643
+ ChatMessage,
6644
+ {
6645
+ message,
6646
+ enableMarkdown,
6647
+ showToolCalls,
6648
+ toolCallVerbosity,
6649
+ markdownComponents,
6650
+ markdownUrlTransform,
6651
+ markdownContentTransform,
6652
+ onImageClick,
6653
+ showThinking,
6654
+ showDelegation,
6655
+ showImages,
6656
+ renderToolCall,
6657
+ variant: messageVariant
6658
+ },
6659
+ message.id
6660
+ );
6661
+ if (renderMessage) {
6662
+ return /* @__PURE__ */ jsx("div", { children: renderMessage(message, defaultRender) }, message.id);
6663
+ }
6664
+ return defaultRender();
6665
+ }) }),
5897
6666
  isLoading && !isStreaming && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 p-4", children: [
5898
6667
  /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 w-8 h-8 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center", children: /* @__PURE__ */ jsx(LoadingSpinner, { className: "h-4 w-4 text-gray-600 dark:text-gray-300" }) }),
5899
6668
  /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Thinking..." })
@@ -5949,13 +6718,28 @@ function AgentChat({
5949
6718
  maxHeight = "600px",
5950
6719
  className,
5951
6720
  theme = "system",
6721
+ layout = "fixed",
5952
6722
  enableAttachments = false,
5953
6723
  enableMarkdown = true,
5954
6724
  showToolCalls = true,
6725
+ toolCallVerbosity,
5955
6726
  markdownComponents,
5956
6727
  markdownUrlTransform,
5957
6728
  markdownContentTransform,
5958
- onImageClick
6729
+ onImageClick,
6730
+ // Extension props
6731
+ hideHeader,
6732
+ renderAboveInput,
6733
+ renderBelowMessages,
6734
+ renderMessage,
6735
+ renderToolCall,
6736
+ messageVariant = "bubble",
6737
+ showThinking = true,
6738
+ showDelegation = true,
6739
+ showImages = true,
6740
+ pollingInterval,
6741
+ pollingEnabled,
6742
+ onDelegation
5959
6743
  }) {
5960
6744
  const {
5961
6745
  messages,
@@ -5982,8 +6766,12 @@ function AgentChat({
5982
6766
  onSessionStart,
5983
6767
  onToolCall,
5984
6768
  onToolResult,
5985
- onClarification
6769
+ onClarification,
6770
+ onDelegation,
6771
+ pollingInterval,
6772
+ pollingEnabled
5986
6773
  });
6774
+ const effectiveVerbosity = showToolCalls === false ? "hidden" : toolCallVerbosity ?? "compact";
5987
6775
  const dropZoneRef = useRef(null);
5988
6776
  const attachments = useFileAttachments({
5989
6777
  onUpload: enableAttachments && adapter ? async (_file, meta) => {
@@ -6010,50 +6798,31 @@ function AgentChat({
6010
6798
  },
6011
6799
  [enableAttachments, attachments, sendMessage]
6012
6800
  );
6013
- return /* @__PURE__ */ jsxs(ChatContainer, { maxHeight, className, theme, children: [
6014
- enableAttachments ? /* @__PURE__ */ jsx(
6015
- FileDropZone,
6016
- {
6017
- ref: dropZoneRef,
6018
- ...attachments.dropZoneProps,
6019
- disabled: isLoading || !!clarification || isLoadingHistory,
6020
- children: /* @__PURE__ */ jsx(
6021
- MessageList,
6022
- {
6023
- messages,
6024
- welcomeMessage,
6025
- renderWelcome,
6026
- isLoading,
6027
- isStreaming,
6028
- isLoadingHistory,
6029
- enableMarkdown,
6030
- showToolCalls,
6031
- markdownComponents,
6032
- markdownUrlTransform,
6033
- markdownContentTransform,
6034
- onImageClick,
6035
- sendMessage: handleSend
6036
- }
6037
- )
6038
- }
6039
- ) : /* @__PURE__ */ jsx(
6040
- MessageList,
6041
- {
6042
- messages,
6043
- welcomeMessage,
6044
- renderWelcome,
6045
- isLoading,
6046
- isStreaming,
6047
- isLoadingHistory,
6048
- enableMarkdown,
6049
- showToolCalls,
6050
- markdownComponents,
6051
- markdownUrlTransform,
6052
- markdownContentTransform,
6053
- onImageClick,
6054
- sendMessage: handleSend
6055
- }
6056
- ),
6801
+ const messageListProps = {
6802
+ messages,
6803
+ welcomeMessage: hideHeader ? void 0 : welcomeMessage,
6804
+ renderWelcome: hideHeader ? void 0 : renderWelcome,
6805
+ isLoading,
6806
+ isStreaming,
6807
+ isLoadingHistory,
6808
+ enableMarkdown,
6809
+ showToolCalls,
6810
+ toolCallVerbosity: effectiveVerbosity,
6811
+ markdownComponents,
6812
+ markdownUrlTransform,
6813
+ markdownContentTransform,
6814
+ onImageClick,
6815
+ showThinking,
6816
+ showDelegation,
6817
+ showImages,
6818
+ renderMessage,
6819
+ renderToolCall,
6820
+ messageVariant,
6821
+ sendMessage: handleSend
6822
+ };
6823
+ const chatContent = /* @__PURE__ */ jsxs(Fragment, { children: [
6824
+ /* @__PURE__ */ jsx(MessageList, { ...messageListProps }),
6825
+ renderBelowMessages?.(),
6057
6826
  clarification && /* @__PURE__ */ jsx("div", { className: "border-t border-gray-200 dark:border-gray-700 p-4", children: /* @__PURE__ */ jsx(
6058
6827
  AskUserPrompt,
6059
6828
  {
@@ -6063,6 +6832,7 @@ function AgentChat({
6063
6832
  }
6064
6833
  ) }),
6065
6834
  error && /* @__PURE__ */ jsx(ErrorBanner, { error, onRetry: retry, onDismiss: clearError }),
6835
+ renderAboveInput?.(),
6066
6836
  /* @__PURE__ */ jsx(
6067
6837
  ChatInput,
6068
6838
  {
@@ -6079,8 +6849,17 @@ function AgentChat({
6079
6849
  }
6080
6850
  )
6081
6851
  ] });
6852
+ return /* @__PURE__ */ jsx(ChatContainer, { maxHeight, className, theme, layout, children: enableAttachments ? /* @__PURE__ */ jsx(
6853
+ FileDropZone,
6854
+ {
6855
+ ref: dropZoneRef,
6856
+ ...attachments.dropZoneProps,
6857
+ disabled: isLoading || !!clarification || isLoadingHistory,
6858
+ children: chatContent
6859
+ }
6860
+ ) : chatContent });
6082
6861
  }
6083
- function cn10(...classes) {
6862
+ function cn13(...classes) {
6084
6863
  return classes.filter(Boolean).join(" ");
6085
6864
  }
6086
6865
  function TodoList({
@@ -6109,7 +6888,7 @@ function TodoList({
6109
6888
  return /* @__PURE__ */ jsxs(
6110
6889
  "div",
6111
6890
  {
6112
- className: cn10(
6891
+ className: cn13(
6113
6892
  "rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",
6114
6893
  className
6115
6894
  ),
@@ -6117,7 +6896,7 @@ function TodoList({
6117
6896
  /* @__PURE__ */ jsxs(
6118
6897
  "div",
6119
6898
  {
6120
- className: cn10(
6899
+ className: cn13(
6121
6900
  "flex items-center gap-2 px-3 py-2 bg-gray-50 dark:bg-gray-800/50",
6122
6901
  collapsible && "cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800"
6123
6902
  ),
@@ -6148,7 +6927,7 @@ function TodoList({
6148
6927
  !isCollapsed && /* @__PURE__ */ jsx("ul", { className: "divide-y divide-gray-100 dark:divide-gray-700", children: todos.map((todo, idx) => /* @__PURE__ */ jsxs(
6149
6928
  "li",
6150
6929
  {
6151
- className: cn10(
6930
+ className: cn13(
6152
6931
  "px-3 py-2 flex items-start gap-2 text-sm",
6153
6932
  todo.status === "in_progress" && "bg-blue-50/50 dark:bg-blue-950/20",
6154
6933
  todo.status === "completed" && "opacity-60"
@@ -6158,7 +6937,7 @@ function TodoList({
6158
6937
  /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsx(
6159
6938
  "p",
6160
6939
  {
6161
- className: cn10(
6940
+ className: cn13(
6162
6941
  "text-gray-700 dark:text-gray-300",
6163
6942
  todo.status === "completed" && "line-through"
6164
6943
  ),
@@ -6175,39 +6954,6 @@ function TodoList({
6175
6954
  );
6176
6955
  }
6177
6956
 
6178
- // src/chat/index.ts
6179
- var DEPRECATION_WARNING = `
6180
- [@cadraos/sdk/chat] DEPRECATION WARNING
6181
-
6182
- This module is deprecated and will be removed in a future version.
6183
- Please migrate to @cadraos/react for:
6184
- - Simpler setup with CadraCopilot
6185
- - Better security (header-based SSE auth)
6186
- - Scoped CSS that won't conflict with your app
6187
-
6188
- Migration steps:
6189
- 1. npm install @cadraos/react
6190
- 2. import '@cadraos/react/styles.css'
6191
- 3. Replace <AgentChat> with <CadraCopilot> or <CadraChat>
6192
-
6193
- See: https://github.com/cadraos/cadra-sdk/blob/main/packages/react/MIGRATION.md
6194
- `;
6195
- var hasWarned = false;
6196
- function showDeprecationWarning() {
6197
- if (hasWarned) return;
6198
- hasWarned = true;
6199
- if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") {
6200
- return;
6201
- }
6202
- if (typeof window === "undefined") {
6203
- return;
6204
- }
6205
- console.warn(DEPRECATION_WARNING);
6206
- }
6207
- if (typeof window !== "undefined") {
6208
- setTimeout(showDeprecationWarning, 0);
6209
- }
6210
-
6211
- export { AgentChat, AlertCircleIcon, AskUserPrompt, BotIcon, ChatConfigProvider, ChatContainer, ChatInput, ChatMessage, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, DownloadIcon, ExternalLinkIcon, FileDropZone, FileIcon, FileTextIcon, HelpCircleIcon, ImageIcon, ImagesIcon, ListTodoIcon, LoadingSpinner, MarkdownContent, Maximize2Icon, MessageCircleIcon, MessageList, Minimize2Icon, PaperclipIcon, SendIcon, SparklesIcon, StopCircleIcon, TodoList, ToolCallEntry, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments };
6957
+ export { AgentChat, AlertCircleIcon, AskUserPrompt, BotIcon, ChatConfigProvider, ChatContainer, ChatInput, ChatMessage, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CircleIcon, ClockIcon, CodeIcon, CopyIcon, DatabaseIcon, DelegationProgress, DelegationProgressList, DownloadIcon, ExternalLinkIcon, FileDropZone, FileIcon, FileTextIcon, HelpCircleIcon, INTERNAL_TOOL_NAMES, ImageGallery, ImageIcon, ImageLightbox, ImagesIcon, ListTodoIcon, LoadingSpinner, MarkdownContent, Maximize2Icon, MessageCircleIcon, MessageList, Minimize2Icon, PaperclipIcon, SendIcon, SparklesIcon, StopCircleIcon, ThinkingBlock, ThinkingBlockList, TodoList, ToolCallEntry, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments };
6212
6958
  //# sourceMappingURL=index.js.map
6213
6959
  //# sourceMappingURL=index.js.map