@cadraos/sdk 0.1.10 → 0.1.11-test
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/dist/chat/index.cjs +157 -50
- package/dist/chat/index.cjs.map +1 -1
- package/dist/chat/index.d.cts +58 -23
- package/dist/chat/index.d.ts +58 -23
- package/dist/chat/index.js +156 -51
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -0
- package/dist/index.cjs +52 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -29
- package/dist/index.d.ts +29 -29
- package/dist/index.js +49 -29
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/chat/index.js
CHANGED
|
@@ -58,7 +58,7 @@ var BaseResourceAPI = class {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
// src/errors/sdk-errors.ts
|
|
61
|
-
var
|
|
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 = "
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
280
|
+
return url;
|
|
275
281
|
}
|
|
276
282
|
/**
|
|
277
283
|
* Make an HTTP request
|
|
@@ -671,7 +677,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
671
677
|
return Promise.resolve(this.finalExecution);
|
|
672
678
|
}
|
|
673
679
|
if (this.finalError) {
|
|
674
|
-
return Promise.reject(new
|
|
680
|
+
return Promise.reject(new CadraError(
|
|
675
681
|
this.finalError.error,
|
|
676
682
|
this.finalError.errorCode ?? "execution_error",
|
|
677
683
|
500
|
|
@@ -690,7 +696,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
690
696
|
* Connect to SSE endpoint
|
|
691
697
|
*/
|
|
692
698
|
async connectSSE() {
|
|
693
|
-
const
|
|
699
|
+
const base = this.options.baseUrl.replace(/\/+$/, "");
|
|
700
|
+
const url = `${base}/api/v1/agents/runs/${this.options.executionId}/stream`;
|
|
694
701
|
let authToken = this.options.apiKey;
|
|
695
702
|
if (!authToken && this.options.tokenProvider) {
|
|
696
703
|
authToken = await this.options.tokenProvider();
|
|
@@ -925,7 +932,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
925
932
|
this.finalError = error;
|
|
926
933
|
this.emit("error", error);
|
|
927
934
|
if (this.waitReject) {
|
|
928
|
-
this.waitReject(new
|
|
935
|
+
this.waitReject(new CadraError(
|
|
929
936
|
error.error,
|
|
930
937
|
error.errorCode ?? "execution_error",
|
|
931
938
|
500
|
|
@@ -1043,7 +1050,7 @@ function createExecutionStreamController(options) {
|
|
|
1043
1050
|
// src/resources/agents.ts
|
|
1044
1051
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1045
1052
|
constructor(http, getStreamConfig) {
|
|
1046
|
-
super(http, "/agents");
|
|
1053
|
+
super(http, "/api/v1/agents");
|
|
1047
1054
|
this.getStreamConfig = getStreamConfig;
|
|
1048
1055
|
}
|
|
1049
1056
|
// ===== LIST Operations =====
|
|
@@ -1319,7 +1326,7 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1319
1326
|
// src/resources/skills.ts
|
|
1320
1327
|
var SkillsAPI = class extends BaseResourceAPI {
|
|
1321
1328
|
constructor(http) {
|
|
1322
|
-
super(http, "/skills");
|
|
1329
|
+
super(http, "/api/v1/skills");
|
|
1323
1330
|
}
|
|
1324
1331
|
// ===== LIST Operations =====
|
|
1325
1332
|
/**
|
|
@@ -1463,7 +1470,7 @@ var SkillsAPI = class extends BaseResourceAPI {
|
|
|
1463
1470
|
// src/resources/tools.ts
|
|
1464
1471
|
var ToolsAPI = class extends BaseResourceAPI {
|
|
1465
1472
|
constructor(http) {
|
|
1466
|
-
super(http, "/tools");
|
|
1473
|
+
super(http, "/api/v1/tools");
|
|
1467
1474
|
}
|
|
1468
1475
|
// ===== LIST Operations =====
|
|
1469
1476
|
/**
|
|
@@ -1626,7 +1633,7 @@ var ToolsAPI = class extends BaseResourceAPI {
|
|
|
1626
1633
|
// src/resources/artifacts.ts
|
|
1627
1634
|
var ArtifactsAPI = class extends BaseResourceAPI {
|
|
1628
1635
|
constructor(http) {
|
|
1629
|
-
super(http, "/artifacts");
|
|
1636
|
+
super(http, "/api/v1/artifacts");
|
|
1630
1637
|
}
|
|
1631
1638
|
// ===== LIST Operations =====
|
|
1632
1639
|
/**
|
|
@@ -1822,7 +1829,7 @@ var ArtifactsAPI = class extends BaseResourceAPI {
|
|
|
1822
1829
|
// src/resources/sessions.ts
|
|
1823
1830
|
var SessionsAPI = class extends BaseResourceAPI {
|
|
1824
1831
|
constructor(http, getStreamConfig) {
|
|
1825
|
-
super(http, "/sessions");
|
|
1832
|
+
super(http, "/api/v1/sessions");
|
|
1826
1833
|
this.getStreamConfig = getStreamConfig;
|
|
1827
1834
|
}
|
|
1828
1835
|
// ===== LIST Operations =====
|
|
@@ -2053,9 +2060,9 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2053
2060
|
};
|
|
2054
2061
|
|
|
2055
2062
|
// src/client.ts
|
|
2056
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
2063
|
+
var DEFAULT_BASE_URL = "https://api.cadraos.com";
|
|
2057
2064
|
var DEFAULT_TIMEOUT = 3e4;
|
|
2058
|
-
var
|
|
2065
|
+
var CadraClient = class {
|
|
2059
2066
|
httpClient;
|
|
2060
2067
|
config;
|
|
2061
2068
|
/**
|
|
@@ -2086,19 +2093,19 @@ var AISaaSClient = class {
|
|
|
2086
2093
|
* @example
|
|
2087
2094
|
* ```typescript
|
|
2088
2095
|
* // API key authentication
|
|
2089
|
-
* const client = new
|
|
2096
|
+
* const client = new CadraClient({
|
|
2090
2097
|
* apiKey: 'sk_...',
|
|
2091
2098
|
* orgId: 123,
|
|
2092
2099
|
* });
|
|
2093
2100
|
*
|
|
2094
2101
|
* // OAuth token authentication
|
|
2095
|
-
* const client = new
|
|
2102
|
+
* const client = new CadraClient({
|
|
2096
2103
|
* token: 'eyJ...',
|
|
2097
2104
|
* orgId: 123,
|
|
2098
2105
|
* });
|
|
2099
2106
|
*
|
|
2100
2107
|
* // Token provider (for automatic refresh)
|
|
2101
|
-
* const client = new
|
|
2108
|
+
* const client = new CadraClient({
|
|
2102
2109
|
* tokenProvider: async () => myAuth.getAccessToken(),
|
|
2103
2110
|
* orgId: 123,
|
|
2104
2111
|
* });
|
|
@@ -2106,6 +2113,19 @@ var AISaaSClient = class {
|
|
|
2106
2113
|
*/
|
|
2107
2114
|
constructor(options) {
|
|
2108
2115
|
this.validateOptions(options);
|
|
2116
|
+
if (options.baseUrl) {
|
|
2117
|
+
try {
|
|
2118
|
+
const parsed = new URL(options.baseUrl);
|
|
2119
|
+
if (/\/(api|v\d)/.test(parsed.pathname)) {
|
|
2120
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
2121
|
+
console.warn(
|
|
2122
|
+
`[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}"`
|
|
2123
|
+
);
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
} catch {
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2109
2129
|
this.config = {
|
|
2110
2130
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
2111
2131
|
orgId: options.orgId,
|
|
@@ -2178,21 +2198,21 @@ function resolveClient(config) {
|
|
|
2178
2198
|
throw new Error("DefaultAdapterConfig requires 'orgId' when 'client' is not provided");
|
|
2179
2199
|
}
|
|
2180
2200
|
if (config.apiKey) {
|
|
2181
|
-
return new
|
|
2201
|
+
return new CadraClient({
|
|
2182
2202
|
apiKey: config.apiKey,
|
|
2183
2203
|
orgId: config.orgId,
|
|
2184
2204
|
baseUrl: config.baseUrl
|
|
2185
2205
|
});
|
|
2186
2206
|
}
|
|
2187
2207
|
if (config.token) {
|
|
2188
|
-
return new
|
|
2208
|
+
return new CadraClient({
|
|
2189
2209
|
token: config.token,
|
|
2190
2210
|
orgId: config.orgId,
|
|
2191
2211
|
baseUrl: config.baseUrl
|
|
2192
2212
|
});
|
|
2193
2213
|
}
|
|
2194
2214
|
if (config.tokenProvider) {
|
|
2195
|
-
return new
|
|
2215
|
+
return new CadraClient({
|
|
2196
2216
|
tokenProvider: config.tokenProvider,
|
|
2197
2217
|
orgId: config.orgId,
|
|
2198
2218
|
baseUrl: config.baseUrl
|
|
@@ -2204,7 +2224,7 @@ function resolveClient(config) {
|
|
|
2204
2224
|
}
|
|
2205
2225
|
function resolveBaseUrl(config) {
|
|
2206
2226
|
if (config.baseUrl) return config.baseUrl;
|
|
2207
|
-
return "https://api.
|
|
2227
|
+
return "https://api.cadraos.com";
|
|
2208
2228
|
}
|
|
2209
2229
|
async function getAuthHeaders(config) {
|
|
2210
2230
|
const headers = {
|
|
@@ -2313,7 +2333,7 @@ function createDefaultAdapter(config) {
|
|
|
2313
2333
|
// Attachment Methods (raw fetch — CadraClient has no AttachmentsAPI yet)
|
|
2314
2334
|
// -------------------------------------------------------------------------
|
|
2315
2335
|
async getUploadUrl(input) {
|
|
2316
|
-
return rawRequest(config, "POST", "/attachments/upload-url", {
|
|
2336
|
+
return rawRequest(config, "POST", "/api/v1/attachments/upload-url", {
|
|
2317
2337
|
sessionId: input.sessionId,
|
|
2318
2338
|
filename: input.filename,
|
|
2319
2339
|
mimeType: input.mimeType,
|
|
@@ -2321,10 +2341,10 @@ function createDefaultAdapter(config) {
|
|
|
2321
2341
|
});
|
|
2322
2342
|
},
|
|
2323
2343
|
async confirmUpload(uuid) {
|
|
2324
|
-
await rawRequest(config, "POST", `/attachments/${uuid}/confirm`);
|
|
2344
|
+
await rawRequest(config, "POST", `/api/v1/attachments/${uuid}/confirm`);
|
|
2325
2345
|
},
|
|
2326
2346
|
async getDownloadUrl(uuid) {
|
|
2327
|
-
const result = await rawRequest(config, "GET", `/attachments/${uuid}/download-url`);
|
|
2347
|
+
const result = await rawRequest(config, "GET", `/api/v1/attachments/${uuid}/download-url`);
|
|
2328
2348
|
return result.url;
|
|
2329
2349
|
},
|
|
2330
2350
|
// -------------------------------------------------------------------------
|
|
@@ -2405,7 +2425,7 @@ function createDefaultAdapter(config) {
|
|
|
2405
2425
|
);
|
|
2406
2426
|
}
|
|
2407
2427
|
}
|
|
2408
|
-
return `${baseUrl}/agents/runs/${executionId}/stream`;
|
|
2428
|
+
return `${baseUrl}/api/v1/agents/runs/${executionId}/stream`;
|
|
2409
2429
|
},
|
|
2410
2430
|
// -------------------------------------------------------------------------
|
|
2411
2431
|
// Secure SSE Streaming (Recommended)
|
|
@@ -2905,12 +2925,16 @@ function useAgentChat(options) {
|
|
|
2905
2925
|
});
|
|
2906
2926
|
});
|
|
2907
2927
|
}, []);
|
|
2908
|
-
const finalizeStreamingMessage = useCallback(() => {
|
|
2928
|
+
const finalizeStreamingMessage = useCallback((terminalStatus = "completed") => {
|
|
2909
2929
|
if (!streamingMessageIdRef.current) return;
|
|
2910
2930
|
setMessages(
|
|
2911
|
-
(prev) => prev.map(
|
|
2912
|
-
(msg
|
|
2913
|
-
|
|
2931
|
+
(prev) => prev.map((msg) => {
|
|
2932
|
+
if (msg.id !== streamingMessageIdRef.current) return msg;
|
|
2933
|
+
const updatedToolCalls = msg.toolCalls?.map(
|
|
2934
|
+
(tc) => tc.status === "running" || tc.status === "pending" ? { ...tc, status: terminalStatus } : tc
|
|
2935
|
+
);
|
|
2936
|
+
return { ...msg, isStreaming: false, toolCalls: updatedToolCalls };
|
|
2937
|
+
})
|
|
2914
2938
|
);
|
|
2915
2939
|
streamingMessageIdRef.current = null;
|
|
2916
2940
|
streamingContentRef.current = "";
|
|
@@ -3135,7 +3159,7 @@ function useAgentChat(options) {
|
|
|
3135
3159
|
setError(chatError);
|
|
3136
3160
|
setIsLoading(false);
|
|
3137
3161
|
setIsStreamControllerConnected(false);
|
|
3138
|
-
finalizeStreamingMessage();
|
|
3162
|
+
finalizeStreamingMessage("failed");
|
|
3139
3163
|
setCurrentExecutionId(null);
|
|
3140
3164
|
streamControllerRef.current = null;
|
|
3141
3165
|
onError?.(chatError);
|
|
@@ -5500,6 +5524,36 @@ function MarkdownContent({
|
|
|
5500
5524
|
}
|
|
5501
5525
|
) });
|
|
5502
5526
|
}
|
|
5527
|
+
var INTERNAL_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
5528
|
+
"update_task_list",
|
|
5529
|
+
"create_task",
|
|
5530
|
+
"mark_task_complete",
|
|
5531
|
+
"handoff_to_agent",
|
|
5532
|
+
"delegate_to_agent",
|
|
5533
|
+
"delegate_task",
|
|
5534
|
+
"get_tool_info",
|
|
5535
|
+
"get_tools",
|
|
5536
|
+
"list_tools",
|
|
5537
|
+
"call_tool",
|
|
5538
|
+
"invoke_tool",
|
|
5539
|
+
"execute_tool",
|
|
5540
|
+
"check_task_status",
|
|
5541
|
+
"assign_task",
|
|
5542
|
+
"update_plan",
|
|
5543
|
+
"check_delegations"
|
|
5544
|
+
]);
|
|
5545
|
+
function isInternalTool(toolName) {
|
|
5546
|
+
if (!toolName) return false;
|
|
5547
|
+
const lower = toolName.toLowerCase();
|
|
5548
|
+
if (INTERNAL_TOOL_NAMES.has(lower)) return true;
|
|
5549
|
+
for (const internal of INTERNAL_TOOL_NAMES) {
|
|
5550
|
+
if (lower.endsWith(internal) && lower.length > internal.length) {
|
|
5551
|
+
const charBefore = lower[lower.length - internal.length - 1];
|
|
5552
|
+
if (charBefore === "_" || charBefore === ".") return true;
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
return false;
|
|
5556
|
+
}
|
|
5503
5557
|
function cn7(...classes) {
|
|
5504
5558
|
return classes.filter(Boolean).join(" ");
|
|
5505
5559
|
}
|
|
@@ -5605,7 +5659,8 @@ function ToolCallEntry({
|
|
|
5605
5659
|
toolCall,
|
|
5606
5660
|
className,
|
|
5607
5661
|
showFullJson = true,
|
|
5608
|
-
onImageClick
|
|
5662
|
+
onImageClick,
|
|
5663
|
+
compact = false
|
|
5609
5664
|
}) {
|
|
5610
5665
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
5611
5666
|
const formattedName = useMemo(
|
|
@@ -5645,6 +5700,22 @@ function ToolCallEntry({
|
|
|
5645
5700
|
return "border-gray-200 dark:border-gray-700";
|
|
5646
5701
|
}
|
|
5647
5702
|
}, [toolCall.status]);
|
|
5703
|
+
if (compact && (toolCall.status === "completed" || toolCall.status === "failed")) {
|
|
5704
|
+
return /* @__PURE__ */ jsxs(
|
|
5705
|
+
"div",
|
|
5706
|
+
{
|
|
5707
|
+
className: cn7(
|
|
5708
|
+
"inline-flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",
|
|
5709
|
+
className
|
|
5710
|
+
),
|
|
5711
|
+
children: [
|
|
5712
|
+
/* @__PURE__ */ jsx("span", { className: "flex-shrink-0", children: statusIcon }),
|
|
5713
|
+
/* @__PURE__ */ jsx("span", { children: formattedName }),
|
|
5714
|
+
toolCall.durationMs !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-gray-400 dark:text-gray-500", children: formatDuration(toolCall.durationMs) })
|
|
5715
|
+
]
|
|
5716
|
+
}
|
|
5717
|
+
);
|
|
5718
|
+
}
|
|
5648
5719
|
return /* @__PURE__ */ jsxs(
|
|
5649
5720
|
"div",
|
|
5650
5721
|
{
|
|
@@ -5735,6 +5806,7 @@ function ChatMessage({
|
|
|
5735
5806
|
message,
|
|
5736
5807
|
enableMarkdown = true,
|
|
5737
5808
|
showToolCalls = true,
|
|
5809
|
+
toolCallVerbosity,
|
|
5738
5810
|
className,
|
|
5739
5811
|
markdownComponents,
|
|
5740
5812
|
markdownUrlTransform,
|
|
@@ -5799,14 +5871,42 @@ function ChatMessage({
|
|
|
5799
5871
|
},
|
|
5800
5872
|
block.id
|
|
5801
5873
|
)) }),
|
|
5802
|
-
showToolCalls && message.toolCalls && message.toolCalls.length > 0 &&
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5874
|
+
showToolCalls && toolCallVerbosity !== "hidden" && message.toolCalls && message.toolCalls.length > 0 && (() => {
|
|
5875
|
+
const verbosity = toolCallVerbosity ?? "verbose";
|
|
5876
|
+
const filteredToolCalls = verbosity === "compact" ? message.toolCalls.filter((tc) => !isInternalTool(tc.name)) : message.toolCalls;
|
|
5877
|
+
if (filteredToolCalls.length === 0) return null;
|
|
5878
|
+
if (verbosity === "compact") {
|
|
5879
|
+
const runningTools = filteredToolCalls.filter((tc) => tc.status === "pending" || tc.status === "running");
|
|
5880
|
+
const doneTools = filteredToolCalls.filter((tc) => tc.status === "completed" || tc.status === "failed");
|
|
5881
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
5882
|
+
doneTools.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1", children: doneTools.map((toolCall) => /* @__PURE__ */ jsx(
|
|
5883
|
+
ToolCallEntry,
|
|
5884
|
+
{
|
|
5885
|
+
toolCall,
|
|
5886
|
+
onImageClick,
|
|
5887
|
+
compact: true
|
|
5888
|
+
},
|
|
5889
|
+
toolCall.id
|
|
5890
|
+
)) }),
|
|
5891
|
+
runningTools.map((toolCall) => /* @__PURE__ */ jsx(
|
|
5892
|
+
ToolCallEntry,
|
|
5893
|
+
{
|
|
5894
|
+
toolCall,
|
|
5895
|
+
onImageClick
|
|
5896
|
+
},
|
|
5897
|
+
toolCall.id
|
|
5898
|
+
))
|
|
5899
|
+
] });
|
|
5900
|
+
}
|
|
5901
|
+
return /* @__PURE__ */ jsx("div", { className: "space-y-2", children: filteredToolCalls.map((toolCall) => /* @__PURE__ */ jsx(
|
|
5902
|
+
ToolCallEntry,
|
|
5903
|
+
{
|
|
5904
|
+
toolCall,
|
|
5905
|
+
onImageClick
|
|
5906
|
+
},
|
|
5907
|
+
toolCall.id
|
|
5908
|
+
)) });
|
|
5909
|
+
})(),
|
|
5810
5910
|
message.content && /* @__PURE__ */ jsx(
|
|
5811
5911
|
"div",
|
|
5812
5912
|
{
|
|
@@ -5852,6 +5952,7 @@ function MessageList({
|
|
|
5852
5952
|
isLoadingHistory = false,
|
|
5853
5953
|
enableMarkdown = true,
|
|
5854
5954
|
showToolCalls = true,
|
|
5955
|
+
toolCallVerbosity,
|
|
5855
5956
|
className,
|
|
5856
5957
|
markdownComponents,
|
|
5857
5958
|
markdownUrlTransform,
|
|
@@ -5887,6 +5988,7 @@ function MessageList({
|
|
|
5887
5988
|
message,
|
|
5888
5989
|
enableMarkdown,
|
|
5889
5990
|
showToolCalls,
|
|
5991
|
+
toolCallVerbosity,
|
|
5890
5992
|
markdownComponents,
|
|
5891
5993
|
markdownUrlTransform,
|
|
5892
5994
|
markdownContentTransform,
|
|
@@ -5952,6 +6054,7 @@ function AgentChat({
|
|
|
5952
6054
|
enableAttachments = false,
|
|
5953
6055
|
enableMarkdown = true,
|
|
5954
6056
|
showToolCalls = true,
|
|
6057
|
+
toolCallVerbosity,
|
|
5955
6058
|
markdownComponents,
|
|
5956
6059
|
markdownUrlTransform,
|
|
5957
6060
|
markdownContentTransform,
|
|
@@ -5984,6 +6087,7 @@ function AgentChat({
|
|
|
5984
6087
|
onToolResult,
|
|
5985
6088
|
onClarification
|
|
5986
6089
|
});
|
|
6090
|
+
const effectiveVerbosity = showToolCalls === false ? "hidden" : toolCallVerbosity ?? "compact";
|
|
5987
6091
|
const dropZoneRef = useRef(null);
|
|
5988
6092
|
const attachments = useFileAttachments({
|
|
5989
6093
|
onUpload: enableAttachments && adapter ? async (_file, meta) => {
|
|
@@ -6028,6 +6132,7 @@ function AgentChat({
|
|
|
6028
6132
|
isLoadingHistory,
|
|
6029
6133
|
enableMarkdown,
|
|
6030
6134
|
showToolCalls,
|
|
6135
|
+
toolCallVerbosity: effectiveVerbosity,
|
|
6031
6136
|
markdownComponents,
|
|
6032
6137
|
markdownUrlTransform,
|
|
6033
6138
|
markdownContentTransform,
|
|
@@ -6208,6 +6313,6 @@ if (typeof window !== "undefined") {
|
|
|
6208
6313
|
setTimeout(showDeprecationWarning, 0);
|
|
6209
6314
|
}
|
|
6210
6315
|
|
|
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 };
|
|
6316
|
+
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, INTERNAL_TOOL_NAMES, ImageIcon, ImagesIcon, ListTodoIcon, LoadingSpinner, MarkdownContent, Maximize2Icon, MessageCircleIcon, MessageList, Minimize2Icon, PaperclipIcon, SendIcon, SparklesIcon, StopCircleIcon, TodoList, ToolCallEntry, UserIcon, XIcon, ZoomInIcon, ZoomOutIcon, compressImage, createDefaultAdapter, isInternalTool, useAgentChat, useChatConfig, useChatConfigOptional, useExecutionStream, useFileAttachments };
|
|
6212
6317
|
//# sourceMappingURL=index.js.map
|
|
6213
6318
|
//# sourceMappingURL=index.js.map
|