@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.cjs
CHANGED
|
@@ -65,7 +65,7 @@ var BaseResourceAPI = class {
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// src/errors/sdk-errors.ts
|
|
68
|
-
var
|
|
68
|
+
var CadraError = class extends Error {
|
|
69
69
|
/** Error code */
|
|
70
70
|
code;
|
|
71
71
|
/** HTTP status code */
|
|
@@ -76,7 +76,7 @@ var AISaaSError = class extends Error {
|
|
|
76
76
|
requestId;
|
|
77
77
|
constructor(message, code, status, details, requestId) {
|
|
78
78
|
super(message);
|
|
79
|
-
this.name = "
|
|
79
|
+
this.name = "CadraError";
|
|
80
80
|
this.code = code;
|
|
81
81
|
this.status = status;
|
|
82
82
|
this.details = details;
|
|
@@ -86,25 +86,25 @@ var AISaaSError = class extends Error {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
-
var AuthenticationError = class extends
|
|
89
|
+
var AuthenticationError = class extends CadraError {
|
|
90
90
|
constructor(message = "Authentication failed", code = "authentication_error", details, requestId) {
|
|
91
91
|
super(message, code, 401, details, requestId);
|
|
92
92
|
this.name = "AuthenticationError";
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
var AuthorizationError = class extends
|
|
95
|
+
var AuthorizationError = class extends CadraError {
|
|
96
96
|
constructor(message = "Access denied", code = "authorization_error", details, requestId) {
|
|
97
97
|
super(message, code, 403, details, requestId);
|
|
98
98
|
this.name = "AuthorizationError";
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
var NotFoundError = class extends
|
|
101
|
+
var NotFoundError = class extends CadraError {
|
|
102
102
|
constructor(message = "Resource not found", code = "not_found", details, requestId) {
|
|
103
103
|
super(message, code, 404, details, requestId);
|
|
104
104
|
this.name = "NotFoundError";
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
var ValidationError = class extends
|
|
107
|
+
var ValidationError = class extends CadraError {
|
|
108
108
|
/** Field-level validation errors */
|
|
109
109
|
errors;
|
|
110
110
|
constructor(message = "Validation failed", errors = [], details, requestId) {
|
|
@@ -113,7 +113,7 @@ var ValidationError = class extends AISaaSError {
|
|
|
113
113
|
this.errors = errors;
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
var RateLimitError = class extends
|
|
116
|
+
var RateLimitError = class extends CadraError {
|
|
117
117
|
/** Seconds until rate limit resets */
|
|
118
118
|
retryAfter;
|
|
119
119
|
constructor(message = "Rate limit exceeded", retryAfter, details, requestId) {
|
|
@@ -122,25 +122,25 @@ var RateLimitError = class extends AISaaSError {
|
|
|
122
122
|
this.retryAfter = retryAfter;
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
var ServerError = class extends
|
|
125
|
+
var ServerError = class extends CadraError {
|
|
126
126
|
constructor(message = "Server error", status = 500, details, requestId) {
|
|
127
127
|
super(message, "server_error", status, details, requestId);
|
|
128
128
|
this.name = "ServerError";
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
|
-
var ConflictError = class extends
|
|
131
|
+
var ConflictError = class extends CadraError {
|
|
132
132
|
constructor(message = "Resource conflict", details, requestId) {
|
|
133
133
|
super(message, "conflict", 409, details, requestId);
|
|
134
134
|
this.name = "ConflictError";
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
var TimeoutError = class extends
|
|
137
|
+
var TimeoutError = class extends CadraError {
|
|
138
138
|
constructor(message = "Request timed out", details, requestId) {
|
|
139
139
|
super(message, "timeout", 408, details, requestId);
|
|
140
140
|
this.name = "TimeoutError";
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
var NetworkError = class extends
|
|
143
|
+
var NetworkError = class extends CadraError {
|
|
144
144
|
constructor(message = "Network error", details) {
|
|
145
145
|
super(message, "network_error", 0, details);
|
|
146
146
|
this.name = "NetworkError";
|
|
@@ -182,7 +182,7 @@ function parseApiError(status, body, requestId) {
|
|
|
182
182
|
if (status >= 500) {
|
|
183
183
|
return new ServerError(message, status, details, requestId);
|
|
184
184
|
}
|
|
185
|
-
return new
|
|
185
|
+
return new CadraError(message, code, status, details, requestId);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -270,15 +270,21 @@ var HttpClient = class {
|
|
|
270
270
|
* Build full URL with query parameters
|
|
271
271
|
*/
|
|
272
272
|
buildUrl(path, query) {
|
|
273
|
-
const
|
|
273
|
+
const base = this.config.baseUrl.replace(/\/+$/, "");
|
|
274
|
+
let url = `${base}${path}`;
|
|
274
275
|
if (query) {
|
|
276
|
+
const params = new URLSearchParams();
|
|
275
277
|
for (const [key, value] of Object.entries(query)) {
|
|
276
278
|
if (value !== void 0) {
|
|
277
|
-
|
|
279
|
+
params.set(key, String(value));
|
|
278
280
|
}
|
|
279
281
|
}
|
|
282
|
+
const qs = params.toString();
|
|
283
|
+
if (qs) {
|
|
284
|
+
url += `?${qs}`;
|
|
285
|
+
}
|
|
280
286
|
}
|
|
281
|
-
return url
|
|
287
|
+
return url;
|
|
282
288
|
}
|
|
283
289
|
/**
|
|
284
290
|
* Make an HTTP request
|
|
@@ -678,7 +684,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
678
684
|
return Promise.resolve(this.finalExecution);
|
|
679
685
|
}
|
|
680
686
|
if (this.finalError) {
|
|
681
|
-
return Promise.reject(new
|
|
687
|
+
return Promise.reject(new CadraError(
|
|
682
688
|
this.finalError.error,
|
|
683
689
|
this.finalError.errorCode ?? "execution_error",
|
|
684
690
|
500
|
|
@@ -697,7 +703,8 @@ var ExecutionStreamControllerImpl = class {
|
|
|
697
703
|
* Connect to SSE endpoint
|
|
698
704
|
*/
|
|
699
705
|
async connectSSE() {
|
|
700
|
-
const
|
|
706
|
+
const base = this.options.baseUrl.replace(/\/+$/, "");
|
|
707
|
+
const url = `${base}/api/v1/agents/runs/${this.options.executionId}/stream`;
|
|
701
708
|
let authToken = this.options.apiKey;
|
|
702
709
|
if (!authToken && this.options.tokenProvider) {
|
|
703
710
|
authToken = await this.options.tokenProvider();
|
|
@@ -932,7 +939,7 @@ var ExecutionStreamControllerImpl = class {
|
|
|
932
939
|
this.finalError = error;
|
|
933
940
|
this.emit("error", error);
|
|
934
941
|
if (this.waitReject) {
|
|
935
|
-
this.waitReject(new
|
|
942
|
+
this.waitReject(new CadraError(
|
|
936
943
|
error.error,
|
|
937
944
|
error.errorCode ?? "execution_error",
|
|
938
945
|
500
|
|
@@ -1050,7 +1057,7 @@ function createExecutionStreamController(options) {
|
|
|
1050
1057
|
// src/resources/agents.ts
|
|
1051
1058
|
var AgentsAPI = class extends BaseResourceAPI {
|
|
1052
1059
|
constructor(http, getStreamConfig) {
|
|
1053
|
-
super(http, "/agents");
|
|
1060
|
+
super(http, "/api/v1/agents");
|
|
1054
1061
|
this.getStreamConfig = getStreamConfig;
|
|
1055
1062
|
}
|
|
1056
1063
|
// ===== LIST Operations =====
|
|
@@ -1326,7 +1333,7 @@ var AgentsAPI = class extends BaseResourceAPI {
|
|
|
1326
1333
|
// src/resources/skills.ts
|
|
1327
1334
|
var SkillsAPI = class extends BaseResourceAPI {
|
|
1328
1335
|
constructor(http) {
|
|
1329
|
-
super(http, "/skills");
|
|
1336
|
+
super(http, "/api/v1/skills");
|
|
1330
1337
|
}
|
|
1331
1338
|
// ===== LIST Operations =====
|
|
1332
1339
|
/**
|
|
@@ -1470,7 +1477,7 @@ var SkillsAPI = class extends BaseResourceAPI {
|
|
|
1470
1477
|
// src/resources/tools.ts
|
|
1471
1478
|
var ToolsAPI = class extends BaseResourceAPI {
|
|
1472
1479
|
constructor(http) {
|
|
1473
|
-
super(http, "/tools");
|
|
1480
|
+
super(http, "/api/v1/tools");
|
|
1474
1481
|
}
|
|
1475
1482
|
// ===== LIST Operations =====
|
|
1476
1483
|
/**
|
|
@@ -1633,7 +1640,7 @@ var ToolsAPI = class extends BaseResourceAPI {
|
|
|
1633
1640
|
// src/resources/artifacts.ts
|
|
1634
1641
|
var ArtifactsAPI = class extends BaseResourceAPI {
|
|
1635
1642
|
constructor(http) {
|
|
1636
|
-
super(http, "/artifacts");
|
|
1643
|
+
super(http, "/api/v1/artifacts");
|
|
1637
1644
|
}
|
|
1638
1645
|
// ===== LIST Operations =====
|
|
1639
1646
|
/**
|
|
@@ -1829,7 +1836,7 @@ var ArtifactsAPI = class extends BaseResourceAPI {
|
|
|
1829
1836
|
// src/resources/sessions.ts
|
|
1830
1837
|
var SessionsAPI = class extends BaseResourceAPI {
|
|
1831
1838
|
constructor(http, getStreamConfig) {
|
|
1832
|
-
super(http, "/sessions");
|
|
1839
|
+
super(http, "/api/v1/sessions");
|
|
1833
1840
|
this.getStreamConfig = getStreamConfig;
|
|
1834
1841
|
}
|
|
1835
1842
|
// ===== LIST Operations =====
|
|
@@ -2060,9 +2067,9 @@ var SessionsAPI = class extends BaseResourceAPI {
|
|
|
2060
2067
|
};
|
|
2061
2068
|
|
|
2062
2069
|
// src/client.ts
|
|
2063
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
2070
|
+
var DEFAULT_BASE_URL = "https://api.cadraos.com";
|
|
2064
2071
|
var DEFAULT_TIMEOUT = 3e4;
|
|
2065
|
-
var
|
|
2072
|
+
var CadraClient = class {
|
|
2066
2073
|
httpClient;
|
|
2067
2074
|
config;
|
|
2068
2075
|
/**
|
|
@@ -2093,19 +2100,19 @@ var AISaaSClient = class {
|
|
|
2093
2100
|
* @example
|
|
2094
2101
|
* ```typescript
|
|
2095
2102
|
* // API key authentication
|
|
2096
|
-
* const client = new
|
|
2103
|
+
* const client = new CadraClient({
|
|
2097
2104
|
* apiKey: 'sk_...',
|
|
2098
2105
|
* orgId: 123,
|
|
2099
2106
|
* });
|
|
2100
2107
|
*
|
|
2101
2108
|
* // OAuth token authentication
|
|
2102
|
-
* const client = new
|
|
2109
|
+
* const client = new CadraClient({
|
|
2103
2110
|
* token: 'eyJ...',
|
|
2104
2111
|
* orgId: 123,
|
|
2105
2112
|
* });
|
|
2106
2113
|
*
|
|
2107
2114
|
* // Token provider (for automatic refresh)
|
|
2108
|
-
* const client = new
|
|
2115
|
+
* const client = new CadraClient({
|
|
2109
2116
|
* tokenProvider: async () => myAuth.getAccessToken(),
|
|
2110
2117
|
* orgId: 123,
|
|
2111
2118
|
* });
|
|
@@ -2113,6 +2120,19 @@ var AISaaSClient = class {
|
|
|
2113
2120
|
*/
|
|
2114
2121
|
constructor(options) {
|
|
2115
2122
|
this.validateOptions(options);
|
|
2123
|
+
if (options.baseUrl) {
|
|
2124
|
+
try {
|
|
2125
|
+
const parsed = new URL(options.baseUrl);
|
|
2126
|
+
if (/\/(api|v\d)/.test(parsed.pathname)) {
|
|
2127
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
2128
|
+
console.warn(
|
|
2129
|
+
`[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}"`
|
|
2130
|
+
);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
} catch {
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2116
2136
|
this.config = {
|
|
2117
2137
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
2118
2138
|
orgId: options.orgId,
|
|
@@ -2185,21 +2205,21 @@ function resolveClient(config) {
|
|
|
2185
2205
|
throw new Error("DefaultAdapterConfig requires 'orgId' when 'client' is not provided");
|
|
2186
2206
|
}
|
|
2187
2207
|
if (config.apiKey) {
|
|
2188
|
-
return new
|
|
2208
|
+
return new CadraClient({
|
|
2189
2209
|
apiKey: config.apiKey,
|
|
2190
2210
|
orgId: config.orgId,
|
|
2191
2211
|
baseUrl: config.baseUrl
|
|
2192
2212
|
});
|
|
2193
2213
|
}
|
|
2194
2214
|
if (config.token) {
|
|
2195
|
-
return new
|
|
2215
|
+
return new CadraClient({
|
|
2196
2216
|
token: config.token,
|
|
2197
2217
|
orgId: config.orgId,
|
|
2198
2218
|
baseUrl: config.baseUrl
|
|
2199
2219
|
});
|
|
2200
2220
|
}
|
|
2201
2221
|
if (config.tokenProvider) {
|
|
2202
|
-
return new
|
|
2222
|
+
return new CadraClient({
|
|
2203
2223
|
tokenProvider: config.tokenProvider,
|
|
2204
2224
|
orgId: config.orgId,
|
|
2205
2225
|
baseUrl: config.baseUrl
|
|
@@ -2211,7 +2231,7 @@ function resolveClient(config) {
|
|
|
2211
2231
|
}
|
|
2212
2232
|
function resolveBaseUrl(config) {
|
|
2213
2233
|
if (config.baseUrl) return config.baseUrl;
|
|
2214
|
-
return "https://api.
|
|
2234
|
+
return "https://api.cadraos.com";
|
|
2215
2235
|
}
|
|
2216
2236
|
async function getAuthHeaders(config) {
|
|
2217
2237
|
const headers = {
|
|
@@ -2320,7 +2340,7 @@ function createDefaultAdapter(config) {
|
|
|
2320
2340
|
// Attachment Methods (raw fetch — CadraClient has no AttachmentsAPI yet)
|
|
2321
2341
|
// -------------------------------------------------------------------------
|
|
2322
2342
|
async getUploadUrl(input) {
|
|
2323
|
-
return rawRequest(config, "POST", "/attachments/upload-url", {
|
|
2343
|
+
return rawRequest(config, "POST", "/api/v1/attachments/upload-url", {
|
|
2324
2344
|
sessionId: input.sessionId,
|
|
2325
2345
|
filename: input.filename,
|
|
2326
2346
|
mimeType: input.mimeType,
|
|
@@ -2328,10 +2348,10 @@ function createDefaultAdapter(config) {
|
|
|
2328
2348
|
});
|
|
2329
2349
|
},
|
|
2330
2350
|
async confirmUpload(uuid) {
|
|
2331
|
-
await rawRequest(config, "POST", `/attachments/${uuid}/confirm`);
|
|
2351
|
+
await rawRequest(config, "POST", `/api/v1/attachments/${uuid}/confirm`);
|
|
2332
2352
|
},
|
|
2333
2353
|
async getDownloadUrl(uuid) {
|
|
2334
|
-
const result = await rawRequest(config, "GET", `/attachments/${uuid}/download-url`);
|
|
2354
|
+
const result = await rawRequest(config, "GET", `/api/v1/attachments/${uuid}/download-url`);
|
|
2335
2355
|
return result.url;
|
|
2336
2356
|
},
|
|
2337
2357
|
// -------------------------------------------------------------------------
|
|
@@ -2412,7 +2432,7 @@ function createDefaultAdapter(config) {
|
|
|
2412
2432
|
);
|
|
2413
2433
|
}
|
|
2414
2434
|
}
|
|
2415
|
-
return `${baseUrl}/agents/runs/${executionId}/stream`;
|
|
2435
|
+
return `${baseUrl}/api/v1/agents/runs/${executionId}/stream`;
|
|
2416
2436
|
},
|
|
2417
2437
|
// -------------------------------------------------------------------------
|
|
2418
2438
|
// Secure SSE Streaming (Recommended)
|
|
@@ -2912,12 +2932,16 @@ function useAgentChat(options) {
|
|
|
2912
2932
|
});
|
|
2913
2933
|
});
|
|
2914
2934
|
}, []);
|
|
2915
|
-
const finalizeStreamingMessage = react.useCallback(() => {
|
|
2935
|
+
const finalizeStreamingMessage = react.useCallback((terminalStatus = "completed") => {
|
|
2916
2936
|
if (!streamingMessageIdRef.current) return;
|
|
2917
2937
|
setMessages(
|
|
2918
|
-
(prev) => prev.map(
|
|
2919
|
-
(msg
|
|
2920
|
-
|
|
2938
|
+
(prev) => prev.map((msg) => {
|
|
2939
|
+
if (msg.id !== streamingMessageIdRef.current) return msg;
|
|
2940
|
+
const updatedToolCalls = msg.toolCalls?.map(
|
|
2941
|
+
(tc) => tc.status === "running" || tc.status === "pending" ? { ...tc, status: terminalStatus } : tc
|
|
2942
|
+
);
|
|
2943
|
+
return { ...msg, isStreaming: false, toolCalls: updatedToolCalls };
|
|
2944
|
+
})
|
|
2921
2945
|
);
|
|
2922
2946
|
streamingMessageIdRef.current = null;
|
|
2923
2947
|
streamingContentRef.current = "";
|
|
@@ -3142,7 +3166,7 @@ function useAgentChat(options) {
|
|
|
3142
3166
|
setError(chatError);
|
|
3143
3167
|
setIsLoading(false);
|
|
3144
3168
|
setIsStreamControllerConnected(false);
|
|
3145
|
-
finalizeStreamingMessage();
|
|
3169
|
+
finalizeStreamingMessage("failed");
|
|
3146
3170
|
setCurrentExecutionId(null);
|
|
3147
3171
|
streamControllerRef.current = null;
|
|
3148
3172
|
onError?.(chatError);
|
|
@@ -5507,6 +5531,36 @@ function MarkdownContent({
|
|
|
5507
5531
|
}
|
|
5508
5532
|
) });
|
|
5509
5533
|
}
|
|
5534
|
+
var INTERNAL_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
5535
|
+
"update_task_list",
|
|
5536
|
+
"create_task",
|
|
5537
|
+
"mark_task_complete",
|
|
5538
|
+
"handoff_to_agent",
|
|
5539
|
+
"delegate_to_agent",
|
|
5540
|
+
"delegate_task",
|
|
5541
|
+
"get_tool_info",
|
|
5542
|
+
"get_tools",
|
|
5543
|
+
"list_tools",
|
|
5544
|
+
"call_tool",
|
|
5545
|
+
"invoke_tool",
|
|
5546
|
+
"execute_tool",
|
|
5547
|
+
"check_task_status",
|
|
5548
|
+
"assign_task",
|
|
5549
|
+
"update_plan",
|
|
5550
|
+
"check_delegations"
|
|
5551
|
+
]);
|
|
5552
|
+
function isInternalTool(toolName) {
|
|
5553
|
+
if (!toolName) return false;
|
|
5554
|
+
const lower = toolName.toLowerCase();
|
|
5555
|
+
if (INTERNAL_TOOL_NAMES.has(lower)) return true;
|
|
5556
|
+
for (const internal of INTERNAL_TOOL_NAMES) {
|
|
5557
|
+
if (lower.endsWith(internal) && lower.length > internal.length) {
|
|
5558
|
+
const charBefore = lower[lower.length - internal.length - 1];
|
|
5559
|
+
if (charBefore === "_" || charBefore === ".") return true;
|
|
5560
|
+
}
|
|
5561
|
+
}
|
|
5562
|
+
return false;
|
|
5563
|
+
}
|
|
5510
5564
|
function cn7(...classes) {
|
|
5511
5565
|
return classes.filter(Boolean).join(" ");
|
|
5512
5566
|
}
|
|
@@ -5612,7 +5666,8 @@ function ToolCallEntry({
|
|
|
5612
5666
|
toolCall,
|
|
5613
5667
|
className,
|
|
5614
5668
|
showFullJson = true,
|
|
5615
|
-
onImageClick
|
|
5669
|
+
onImageClick,
|
|
5670
|
+
compact = false
|
|
5616
5671
|
}) {
|
|
5617
5672
|
const [isExpanded, setIsExpanded] = react.useState(false);
|
|
5618
5673
|
const formattedName = react.useMemo(
|
|
@@ -5652,6 +5707,22 @@ function ToolCallEntry({
|
|
|
5652
5707
|
return "border-gray-200 dark:border-gray-700";
|
|
5653
5708
|
}
|
|
5654
5709
|
}, [toolCall.status]);
|
|
5710
|
+
if (compact && (toolCall.status === "completed" || toolCall.status === "failed")) {
|
|
5711
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5712
|
+
"div",
|
|
5713
|
+
{
|
|
5714
|
+
className: cn7(
|
|
5715
|
+
"inline-flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",
|
|
5716
|
+
className
|
|
5717
|
+
),
|
|
5718
|
+
children: [
|
|
5719
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: statusIcon }),
|
|
5720
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formattedName }),
|
|
5721
|
+
toolCall.durationMs !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 dark:text-gray-500", children: formatDuration(toolCall.durationMs) })
|
|
5722
|
+
]
|
|
5723
|
+
}
|
|
5724
|
+
);
|
|
5725
|
+
}
|
|
5655
5726
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5656
5727
|
"div",
|
|
5657
5728
|
{
|
|
@@ -5742,6 +5813,7 @@ function ChatMessage({
|
|
|
5742
5813
|
message,
|
|
5743
5814
|
enableMarkdown = true,
|
|
5744
5815
|
showToolCalls = true,
|
|
5816
|
+
toolCallVerbosity,
|
|
5745
5817
|
className,
|
|
5746
5818
|
markdownComponents,
|
|
5747
5819
|
markdownUrlTransform,
|
|
@@ -5806,14 +5878,42 @@ function ChatMessage({
|
|
|
5806
5878
|
},
|
|
5807
5879
|
block.id
|
|
5808
5880
|
)) }),
|
|
5809
|
-
showToolCalls && message.toolCalls && message.toolCalls.length > 0 &&
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5881
|
+
showToolCalls && toolCallVerbosity !== "hidden" && message.toolCalls && message.toolCalls.length > 0 && (() => {
|
|
5882
|
+
const verbosity = toolCallVerbosity ?? "verbose";
|
|
5883
|
+
const filteredToolCalls = verbosity === "compact" ? message.toolCalls.filter((tc) => !isInternalTool(tc.name)) : message.toolCalls;
|
|
5884
|
+
if (filteredToolCalls.length === 0) return null;
|
|
5885
|
+
if (verbosity === "compact") {
|
|
5886
|
+
const runningTools = filteredToolCalls.filter((tc) => tc.status === "pending" || tc.status === "running");
|
|
5887
|
+
const doneTools = filteredToolCalls.filter((tc) => tc.status === "completed" || tc.status === "failed");
|
|
5888
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
5889
|
+
doneTools.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1", children: doneTools.map((toolCall) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5890
|
+
ToolCallEntry,
|
|
5891
|
+
{
|
|
5892
|
+
toolCall,
|
|
5893
|
+
onImageClick,
|
|
5894
|
+
compact: true
|
|
5895
|
+
},
|
|
5896
|
+
toolCall.id
|
|
5897
|
+
)) }),
|
|
5898
|
+
runningTools.map((toolCall) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5899
|
+
ToolCallEntry,
|
|
5900
|
+
{
|
|
5901
|
+
toolCall,
|
|
5902
|
+
onImageClick
|
|
5903
|
+
},
|
|
5904
|
+
toolCall.id
|
|
5905
|
+
))
|
|
5906
|
+
] });
|
|
5907
|
+
}
|
|
5908
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: filteredToolCalls.map((toolCall) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5909
|
+
ToolCallEntry,
|
|
5910
|
+
{
|
|
5911
|
+
toolCall,
|
|
5912
|
+
onImageClick
|
|
5913
|
+
},
|
|
5914
|
+
toolCall.id
|
|
5915
|
+
)) });
|
|
5916
|
+
})(),
|
|
5817
5917
|
message.content && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5818
5918
|
"div",
|
|
5819
5919
|
{
|
|
@@ -5859,6 +5959,7 @@ function MessageList({
|
|
|
5859
5959
|
isLoadingHistory = false,
|
|
5860
5960
|
enableMarkdown = true,
|
|
5861
5961
|
showToolCalls = true,
|
|
5962
|
+
toolCallVerbosity,
|
|
5862
5963
|
className,
|
|
5863
5964
|
markdownComponents,
|
|
5864
5965
|
markdownUrlTransform,
|
|
@@ -5894,6 +5995,7 @@ function MessageList({
|
|
|
5894
5995
|
message,
|
|
5895
5996
|
enableMarkdown,
|
|
5896
5997
|
showToolCalls,
|
|
5998
|
+
toolCallVerbosity,
|
|
5897
5999
|
markdownComponents,
|
|
5898
6000
|
markdownUrlTransform,
|
|
5899
6001
|
markdownContentTransform,
|
|
@@ -5959,6 +6061,7 @@ function AgentChat({
|
|
|
5959
6061
|
enableAttachments = false,
|
|
5960
6062
|
enableMarkdown = true,
|
|
5961
6063
|
showToolCalls = true,
|
|
6064
|
+
toolCallVerbosity,
|
|
5962
6065
|
markdownComponents,
|
|
5963
6066
|
markdownUrlTransform,
|
|
5964
6067
|
markdownContentTransform,
|
|
@@ -5991,6 +6094,7 @@ function AgentChat({
|
|
|
5991
6094
|
onToolResult,
|
|
5992
6095
|
onClarification
|
|
5993
6096
|
});
|
|
6097
|
+
const effectiveVerbosity = showToolCalls === false ? "hidden" : toolCallVerbosity ?? "compact";
|
|
5994
6098
|
const dropZoneRef = react.useRef(null);
|
|
5995
6099
|
const attachments = useFileAttachments({
|
|
5996
6100
|
onUpload: enableAttachments && adapter ? async (_file, meta) => {
|
|
@@ -6035,6 +6139,7 @@ function AgentChat({
|
|
|
6035
6139
|
isLoadingHistory,
|
|
6036
6140
|
enableMarkdown,
|
|
6037
6141
|
showToolCalls,
|
|
6142
|
+
toolCallVerbosity: effectiveVerbosity,
|
|
6038
6143
|
markdownComponents,
|
|
6039
6144
|
markdownUrlTransform,
|
|
6040
6145
|
markdownContentTransform,
|
|
@@ -6239,6 +6344,7 @@ exports.FileDropZone = FileDropZone;
|
|
|
6239
6344
|
exports.FileIcon = FileIcon;
|
|
6240
6345
|
exports.FileTextIcon = FileTextIcon;
|
|
6241
6346
|
exports.HelpCircleIcon = HelpCircleIcon;
|
|
6347
|
+
exports.INTERNAL_TOOL_NAMES = INTERNAL_TOOL_NAMES;
|
|
6242
6348
|
exports.ImageIcon = ImageIcon;
|
|
6243
6349
|
exports.ImagesIcon = ImagesIcon;
|
|
6244
6350
|
exports.ListTodoIcon = ListTodoIcon;
|
|
@@ -6260,6 +6366,7 @@ exports.ZoomInIcon = ZoomInIcon;
|
|
|
6260
6366
|
exports.ZoomOutIcon = ZoomOutIcon;
|
|
6261
6367
|
exports.compressImage = compressImage;
|
|
6262
6368
|
exports.createDefaultAdapter = createDefaultAdapter;
|
|
6369
|
+
exports.isInternalTool = isInternalTool;
|
|
6263
6370
|
exports.useAgentChat = useAgentChat;
|
|
6264
6371
|
exports.useChatConfig = useChatConfig;
|
|
6265
6372
|
exports.useChatConfigOptional = useChatConfigOptional;
|