@athenaintel/react 0.10.25 → 0.10.27
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/index.cjs +1500 -466
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +1501 -467
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -3936,407 +3936,6 @@ function cn(...inputs) {
|
|
|
3936
3936
|
function isRecord(value) {
|
|
3937
3937
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3938
3938
|
}
|
|
3939
|
-
const { fromThreadMessageLike, getAutoStatus } = react$1.INTERNAL;
|
|
3940
|
-
const joinExternalMessages = (messages) => {
|
|
3941
|
-
var _a2;
|
|
3942
|
-
const assistantMessage = {
|
|
3943
|
-
role: "assistant",
|
|
3944
|
-
content: []
|
|
3945
|
-
};
|
|
3946
|
-
let firstAssistantId;
|
|
3947
|
-
let lastAssistantId;
|
|
3948
|
-
let assistantMessageCount = 0;
|
|
3949
|
-
for (const output of messages) {
|
|
3950
|
-
if (!output || !("role" in output)) {
|
|
3951
|
-
continue;
|
|
3952
|
-
}
|
|
3953
|
-
if (output.role === "tool") {
|
|
3954
|
-
const toolCallIdx = assistantMessage.content.findIndex(
|
|
3955
|
-
(c) => c.type === "tool-call" && c.toolCallId === output.toolCallId
|
|
3956
|
-
);
|
|
3957
|
-
if (toolCallIdx !== -1) {
|
|
3958
|
-
const toolCall = assistantMessage.content[toolCallIdx];
|
|
3959
|
-
if (output.toolName != null) {
|
|
3960
|
-
if (toolCall.toolName !== output.toolName)
|
|
3961
|
-
console.error(
|
|
3962
|
-
Error(
|
|
3963
|
-
`Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`
|
|
3964
|
-
)
|
|
3965
|
-
);
|
|
3966
|
-
}
|
|
3967
|
-
const { messages: existingMessages, ...toolCallRest } = toolCall;
|
|
3968
|
-
const updatedToolCall = {
|
|
3969
|
-
...toolCallRest,
|
|
3970
|
-
result: output.result,
|
|
3971
|
-
artifact: output.artifact,
|
|
3972
|
-
isError: output.isError,
|
|
3973
|
-
...(output.messages ?? existingMessages) !== void 0 && {
|
|
3974
|
-
messages: output.messages ?? existingMessages
|
|
3975
|
-
}
|
|
3976
|
-
};
|
|
3977
|
-
react$1.bindExternalStoreMessage(updatedToolCall, [
|
|
3978
|
-
...react$1.getExternalStoreMessages(toolCallRest),
|
|
3979
|
-
output
|
|
3980
|
-
]);
|
|
3981
|
-
assistantMessage.content[toolCallIdx] = updatedToolCall;
|
|
3982
|
-
} else {
|
|
3983
|
-
console.warn(
|
|
3984
|
-
`Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`
|
|
3985
|
-
);
|
|
3986
|
-
}
|
|
3987
|
-
} else {
|
|
3988
|
-
const role = output.role;
|
|
3989
|
-
const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
|
|
3990
|
-
const content = rawContent.flatMap((c) => {
|
|
3991
|
-
if (!c || typeof c !== "object") {
|
|
3992
|
-
return [];
|
|
3993
|
-
}
|
|
3994
|
-
const mapped = { ...c };
|
|
3995
|
-
react$1.bindExternalStoreMessage(mapped, output);
|
|
3996
|
-
return [mapped];
|
|
3997
|
-
});
|
|
3998
|
-
switch (role) {
|
|
3999
|
-
case "system":
|
|
4000
|
-
case "user":
|
|
4001
|
-
return {
|
|
4002
|
-
...output,
|
|
4003
|
-
content
|
|
4004
|
-
};
|
|
4005
|
-
case "assistant":
|
|
4006
|
-
if (output.id) {
|
|
4007
|
-
lastAssistantId = output.id;
|
|
4008
|
-
assistantMessageCount++;
|
|
4009
|
-
}
|
|
4010
|
-
if (assistantMessage.content.length === 0) {
|
|
4011
|
-
firstAssistantId = output.id;
|
|
4012
|
-
assistantMessage.createdAt ?? (assistantMessage.createdAt = output.createdAt);
|
|
4013
|
-
assistantMessage.status ?? (assistantMessage.status = output.status);
|
|
4014
|
-
if (output.attachments) {
|
|
4015
|
-
assistantMessage.attachments = [
|
|
4016
|
-
...assistantMessage.attachments ?? [],
|
|
4017
|
-
...output.attachments
|
|
4018
|
-
];
|
|
4019
|
-
}
|
|
4020
|
-
if (output.metadata) {
|
|
4021
|
-
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
4022
|
-
if (output.metadata.unstable_state) {
|
|
4023
|
-
assistantMessage.metadata.unstable_state = output.metadata.unstable_state;
|
|
4024
|
-
}
|
|
4025
|
-
if (output.metadata.unstable_annotations) {
|
|
4026
|
-
assistantMessage.metadata.unstable_annotations = [
|
|
4027
|
-
...assistantMessage.metadata.unstable_annotations ?? [],
|
|
4028
|
-
...output.metadata.unstable_annotations
|
|
4029
|
-
];
|
|
4030
|
-
}
|
|
4031
|
-
if (output.metadata.unstable_data) {
|
|
4032
|
-
assistantMessage.metadata.unstable_data = [
|
|
4033
|
-
...assistantMessage.metadata.unstable_data ?? [],
|
|
4034
|
-
...output.metadata.unstable_data
|
|
4035
|
-
];
|
|
4036
|
-
}
|
|
4037
|
-
if (output.metadata.steps) {
|
|
4038
|
-
assistantMessage.metadata.steps = [
|
|
4039
|
-
...assistantMessage.metadata.steps ?? [],
|
|
4040
|
-
...output.metadata.steps
|
|
4041
|
-
];
|
|
4042
|
-
}
|
|
4043
|
-
if (output.metadata.custom) {
|
|
4044
|
-
assistantMessage.metadata.custom = {
|
|
4045
|
-
...assistantMessage.metadata.custom ?? {},
|
|
4046
|
-
...output.metadata.custom
|
|
4047
|
-
};
|
|
4048
|
-
}
|
|
4049
|
-
if (output.metadata.submittedFeedback) {
|
|
4050
|
-
assistantMessage.metadata.submittedFeedback = output.metadata.submittedFeedback;
|
|
4051
|
-
}
|
|
4052
|
-
}
|
|
4053
|
-
} else {
|
|
4054
|
-
if ((_a2 = output.metadata) == null ? void 0 : _a2.custom) {
|
|
4055
|
-
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
4056
|
-
assistantMessage.metadata.custom = {
|
|
4057
|
-
...assistantMessage.metadata.custom ?? {},
|
|
4058
|
-
...output.metadata.custom
|
|
4059
|
-
};
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
assistantMessage.content.push(...content);
|
|
4063
|
-
break;
|
|
4064
|
-
default: {
|
|
4065
|
-
const unsupportedRole = role;
|
|
4066
|
-
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
|
4067
|
-
}
|
|
4068
|
-
}
|
|
4069
|
-
}
|
|
4070
|
-
}
|
|
4071
|
-
assistantMessage.id = lastAssistantId ?? firstAssistantId;
|
|
4072
|
-
if (assistantMessageCount > 1) {
|
|
4073
|
-
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
4074
|
-
assistantMessage.metadata.custom = {
|
|
4075
|
-
...assistantMessage.metadata.custom ?? {},
|
|
4076
|
-
_firstMessageId: firstAssistantId,
|
|
4077
|
-
_lastMessageId: lastAssistantId,
|
|
4078
|
-
_joinedMessageCount: assistantMessageCount
|
|
4079
|
-
};
|
|
4080
|
-
}
|
|
4081
|
-
return assistantMessage;
|
|
4082
|
-
};
|
|
4083
|
-
const chunkExternalMessages = (callbackResults, _joinStrategy) => {
|
|
4084
|
-
var _a2;
|
|
4085
|
-
const results = [];
|
|
4086
|
-
let isAssistant = false;
|
|
4087
|
-
let pendingNone = false;
|
|
4088
|
-
let inputs = [];
|
|
4089
|
-
let outputs = [];
|
|
4090
|
-
const flush2 = () => {
|
|
4091
|
-
if (outputs.length) {
|
|
4092
|
-
results.push({
|
|
4093
|
-
inputs,
|
|
4094
|
-
outputs
|
|
4095
|
-
});
|
|
4096
|
-
}
|
|
4097
|
-
inputs = [];
|
|
4098
|
-
outputs = [];
|
|
4099
|
-
isAssistant = false;
|
|
4100
|
-
pendingNone = false;
|
|
4101
|
-
};
|
|
4102
|
-
for (const callbackResult of callbackResults) {
|
|
4103
|
-
for (const output of callbackResult.outputs) {
|
|
4104
|
-
if (!output || !("role" in output)) {
|
|
4105
|
-
continue;
|
|
4106
|
-
}
|
|
4107
|
-
if (pendingNone && output.role !== "tool" || !isAssistant || output.role === "user" || output.role === "system") {
|
|
4108
|
-
flush2();
|
|
4109
|
-
}
|
|
4110
|
-
isAssistant = output.role === "assistant" || output.role === "tool";
|
|
4111
|
-
if (inputs.at(-1) !== callbackResult.input) {
|
|
4112
|
-
inputs.push(callbackResult.input);
|
|
4113
|
-
}
|
|
4114
|
-
outputs.push(output);
|
|
4115
|
-
if (output.role === "assistant" && (((_a2 = output.convertConfig) == null ? void 0 : _a2.joinStrategy) === "none" || _joinStrategy === "none")) {
|
|
4116
|
-
pendingNone = true;
|
|
4117
|
-
}
|
|
4118
|
-
}
|
|
4119
|
-
}
|
|
4120
|
-
flush2();
|
|
4121
|
-
return results;
|
|
4122
|
-
};
|
|
4123
|
-
const convertExternalMessages = (messages, callback, isRunning, metadata) => {
|
|
4124
|
-
const callbackResults = [];
|
|
4125
|
-
for (const message of messages) {
|
|
4126
|
-
const output = callback(message, metadata);
|
|
4127
|
-
const rawOutputs = Array.isArray(output) ? output : [output];
|
|
4128
|
-
const outputs = rawOutputs.filter(
|
|
4129
|
-
(candidate) => candidate != null
|
|
4130
|
-
);
|
|
4131
|
-
if (outputs.length === 0) {
|
|
4132
|
-
continue;
|
|
4133
|
-
}
|
|
4134
|
-
const result = { input: message, outputs };
|
|
4135
|
-
callbackResults.push(result);
|
|
4136
|
-
}
|
|
4137
|
-
const chunks = chunkExternalMessages(callbackResults);
|
|
4138
|
-
return chunks.map((message, idx) => {
|
|
4139
|
-
const isLast = idx === chunks.length - 1;
|
|
4140
|
-
const joined = joinExternalMessages(message.outputs);
|
|
4141
|
-
const hasPendingToolCalls = typeof joined.content === "object" && joined.content.some((c) => c.type === "tool-call" && c.result === void 0);
|
|
4142
|
-
const autoStatus = getAutoStatus(isLast, isRunning, hasPendingToolCalls, hasPendingToolCalls);
|
|
4143
|
-
const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
|
|
4144
|
-
react$1.bindExternalStoreMessage(newMessage, message.inputs);
|
|
4145
|
-
return newMessage;
|
|
4146
|
-
});
|
|
4147
|
-
};
|
|
4148
|
-
const warnedMessagePartTypes = /* @__PURE__ */ new Set();
|
|
4149
|
-
const warnForUnknownMessagePartType = (type) => {
|
|
4150
|
-
if (warnedMessagePartTypes.has(type)) return;
|
|
4151
|
-
warnedMessagePartTypes.add(type);
|
|
4152
|
-
console.warn(`Unknown message part type: ${type}`);
|
|
4153
|
-
};
|
|
4154
|
-
const contentToParts = (content) => {
|
|
4155
|
-
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
4156
|
-
return content.flatMap((part) => {
|
|
4157
|
-
if (!part || typeof part !== "object" || !("type" in part)) {
|
|
4158
|
-
return [];
|
|
4159
|
-
}
|
|
4160
|
-
const type = part.type;
|
|
4161
|
-
switch (type) {
|
|
4162
|
-
case "text":
|
|
4163
|
-
return [{ type: "text", text: part.text }];
|
|
4164
|
-
case "text_delta":
|
|
4165
|
-
return [{ type: "text", text: part.text }];
|
|
4166
|
-
case "image_url":
|
|
4167
|
-
if (typeof part.image_url === "string") {
|
|
4168
|
-
return [{ type: "image", image: part.image_url }];
|
|
4169
|
-
}
|
|
4170
|
-
return [{
|
|
4171
|
-
type: "image",
|
|
4172
|
-
image: part.image_url.url
|
|
4173
|
-
}];
|
|
4174
|
-
case "thinking":
|
|
4175
|
-
return [{ type: "reasoning", text: part.thinking }];
|
|
4176
|
-
case "reasoning":
|
|
4177
|
-
return [{
|
|
4178
|
-
type: "reasoning",
|
|
4179
|
-
text: part.summary.map((s) => s.text).join("\n\n\n")
|
|
4180
|
-
}];
|
|
4181
|
-
case "tool_use":
|
|
4182
|
-
return [];
|
|
4183
|
-
case "input_json_delta":
|
|
4184
|
-
return [];
|
|
4185
|
-
default:
|
|
4186
|
-
warnForUnknownMessagePartType(type);
|
|
4187
|
-
return [];
|
|
4188
|
-
}
|
|
4189
|
-
});
|
|
4190
|
-
};
|
|
4191
|
-
const getNumberAtPath = (value, path) => {
|
|
4192
|
-
let current = value;
|
|
4193
|
-
for (const segment of path) {
|
|
4194
|
-
if (!isRecord(current)) {
|
|
4195
|
-
return void 0;
|
|
4196
|
-
}
|
|
4197
|
-
current = current[segment];
|
|
4198
|
-
}
|
|
4199
|
-
return typeof current === "number" && Number.isFinite(current) ? current : void 0;
|
|
4200
|
-
};
|
|
4201
|
-
const extractReasoningTokens = ({
|
|
4202
|
-
usageMetadata,
|
|
4203
|
-
responseMetadata
|
|
4204
|
-
}) => {
|
|
4205
|
-
const rawReasoningTokens = getNumberAtPath(usageMetadata, ["output_token_details", "reasoning"]) ?? getNumberAtPath(usageMetadata, ["output_token_details", "reasoning_tokens"]) ?? getNumberAtPath(usageMetadata, ["reasoning_tokens"]) ?? getNumberAtPath(responseMetadata, ["output_token_details", "reasoning"]) ?? getNumberAtPath(responseMetadata, ["output_token_details", "reasoning_tokens"]) ?? getNumberAtPath(responseMetadata, ["token_usage", "output_token_details", "reasoning"]) ?? getNumberAtPath(responseMetadata, ["token_usage", "output_token_details", "reasoning_tokens"]);
|
|
4206
|
-
return rawReasoningTokens !== void 0 && rawReasoningTokens > 0 ? rawReasoningTokens : void 0;
|
|
4207
|
-
};
|
|
4208
|
-
const buildCustomMetadata = ({
|
|
4209
|
-
additionalKwargs,
|
|
4210
|
-
usageMetadata,
|
|
4211
|
-
responseMetadata
|
|
4212
|
-
}) => {
|
|
4213
|
-
const customMetadata = additionalKwargs ? { ...additionalKwargs } : {};
|
|
4214
|
-
const reasoningTokens = extractReasoningTokens({ usageMetadata, responseMetadata });
|
|
4215
|
-
const existingAthenaMetadata = isRecord(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
4216
|
-
const athenaMetadata = {
|
|
4217
|
-
...existingAthenaMetadata ?? {}
|
|
4218
|
-
};
|
|
4219
|
-
if (usageMetadata) {
|
|
4220
|
-
athenaMetadata.rawUsageMetadata = usageMetadata;
|
|
4221
|
-
}
|
|
4222
|
-
if (responseMetadata) {
|
|
4223
|
-
athenaMetadata.rawResponseMetadata = responseMetadata;
|
|
4224
|
-
}
|
|
4225
|
-
if (reasoningTokens !== void 0) {
|
|
4226
|
-
athenaMetadata.reasoningTokens = reasoningTokens;
|
|
4227
|
-
}
|
|
4228
|
-
if (Object.keys(athenaMetadata).length > 0) {
|
|
4229
|
-
customMetadata._athena = athenaMetadata;
|
|
4230
|
-
}
|
|
4231
|
-
return Object.keys(customMetadata).length > 0 ? customMetadata : void 0;
|
|
4232
|
-
};
|
|
4233
|
-
const convertLangChainMessage = (message) => {
|
|
4234
|
-
var _a2, _b, _c;
|
|
4235
|
-
switch (message.type) {
|
|
4236
|
-
case "system": {
|
|
4237
|
-
const customMetadata = buildCustomMetadata({
|
|
4238
|
-
additionalKwargs: message.additional_kwargs
|
|
4239
|
-
});
|
|
4240
|
-
return {
|
|
4241
|
-
role: "system",
|
|
4242
|
-
id: message.id,
|
|
4243
|
-
content: [{ type: "text", text: message.content }],
|
|
4244
|
-
...customMetadata && {
|
|
4245
|
-
metadata: {
|
|
4246
|
-
custom: customMetadata
|
|
4247
|
-
}
|
|
4248
|
-
}
|
|
4249
|
-
};
|
|
4250
|
-
}
|
|
4251
|
-
case "human": {
|
|
4252
|
-
const customMetadata = buildCustomMetadata({
|
|
4253
|
-
additionalKwargs: message.additional_kwargs
|
|
4254
|
-
});
|
|
4255
|
-
return {
|
|
4256
|
-
role: "user",
|
|
4257
|
-
id: message.id,
|
|
4258
|
-
content: contentToParts(message.content),
|
|
4259
|
-
...customMetadata && {
|
|
4260
|
-
metadata: {
|
|
4261
|
-
custom: customMetadata
|
|
4262
|
-
}
|
|
4263
|
-
}
|
|
4264
|
-
};
|
|
4265
|
-
}
|
|
4266
|
-
case "ai": {
|
|
4267
|
-
const customMetadata = buildCustomMetadata({
|
|
4268
|
-
additionalKwargs: message.additional_kwargs,
|
|
4269
|
-
usageMetadata: message.usage_metadata,
|
|
4270
|
-
responseMetadata: message.response_metadata
|
|
4271
|
-
});
|
|
4272
|
-
const toolCallParts = ((_a2 = message.tool_calls) == null ? void 0 : _a2.map((chunk) => {
|
|
4273
|
-
var _a3, _b2;
|
|
4274
|
-
let argsText;
|
|
4275
|
-
if (typeof chunk.args === "string") {
|
|
4276
|
-
argsText = chunk.args;
|
|
4277
|
-
} else {
|
|
4278
|
-
const rawString = chunk.partial_json ?? ((_b2 = (_a3 = message.tool_call_chunks) == null ? void 0 : _a3.find((c) => c.id === chunk.id)) == null ? void 0 : _b2.args) ?? JSON.stringify(chunk.args);
|
|
4279
|
-
argsText = rawString;
|
|
4280
|
-
}
|
|
4281
|
-
return {
|
|
4282
|
-
type: "tool-call",
|
|
4283
|
-
toolCallId: chunk.id,
|
|
4284
|
-
toolName: chunk.name,
|
|
4285
|
-
args: typeof chunk.args === "string" ? parsePartialJsonObject(argsText) ?? {} : chunk.args,
|
|
4286
|
-
argsText
|
|
4287
|
-
};
|
|
4288
|
-
})) ?? [];
|
|
4289
|
-
const normalizedContent = typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content;
|
|
4290
|
-
const allContent = [
|
|
4291
|
-
(_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
|
|
4292
|
-
...normalizedContent,
|
|
4293
|
-
...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
|
|
4294
|
-
].filter((c) => c != null);
|
|
4295
|
-
return {
|
|
4296
|
-
role: "assistant",
|
|
4297
|
-
id: message.id,
|
|
4298
|
-
content: [...contentToParts(allContent), ...toolCallParts],
|
|
4299
|
-
...message.status && { status: message.status },
|
|
4300
|
-
...customMetadata && {
|
|
4301
|
-
metadata: {
|
|
4302
|
-
custom: customMetadata
|
|
4303
|
-
}
|
|
4304
|
-
}
|
|
4305
|
-
};
|
|
4306
|
-
}
|
|
4307
|
-
case "tool": {
|
|
4308
|
-
return {
|
|
4309
|
-
role: "tool",
|
|
4310
|
-
toolName: message.name,
|
|
4311
|
-
toolCallId: message.tool_call_id,
|
|
4312
|
-
result: message.content,
|
|
4313
|
-
artifact: message.artifact,
|
|
4314
|
-
isError: message.status === "error"
|
|
4315
|
-
};
|
|
4316
|
-
}
|
|
4317
|
-
default:
|
|
4318
|
-
return null;
|
|
4319
|
-
}
|
|
4320
|
-
};
|
|
4321
|
-
const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
|
|
4322
|
-
const validToolCallIds = /* @__PURE__ */ new Set();
|
|
4323
|
-
for (const message of messages) {
|
|
4324
|
-
if (message.type === "ai" && message.tool_calls) {
|
|
4325
|
-
for (const tc of message.tool_calls) {
|
|
4326
|
-
if (tc.id) {
|
|
4327
|
-
validToolCallIds.add(tc.id);
|
|
4328
|
-
}
|
|
4329
|
-
}
|
|
4330
|
-
}
|
|
4331
|
-
}
|
|
4332
|
-
const filteredMessages = messages.filter((message) => {
|
|
4333
|
-
if (message.type === "tool" && message.tool_call_id && !validToolCallIds.has(message.tool_call_id)) {
|
|
4334
|
-
return false;
|
|
4335
|
-
}
|
|
4336
|
-
return true;
|
|
4337
|
-
});
|
|
4338
|
-
return convertExternalMessages(filteredMessages, convertLangChainMessage, isRunning, metadata);
|
|
4339
|
-
};
|
|
4340
3939
|
function $constructor(name, initializer2, params) {
|
|
4341
3940
|
function init2(inst, def) {
|
|
4342
3941
|
if (!inst._zod) {
|
|
@@ -8504,6 +8103,451 @@ const parseLangGraphState = (state) => {
|
|
|
8504
8103
|
}
|
|
8505
8104
|
return result;
|
|
8506
8105
|
};
|
|
8106
|
+
const { fromThreadMessageLike, getAutoStatus } = react$1.INTERNAL;
|
|
8107
|
+
const joinExternalMessages = (messages) => {
|
|
8108
|
+
var _a2;
|
|
8109
|
+
const assistantMessage = {
|
|
8110
|
+
role: "assistant",
|
|
8111
|
+
content: []
|
|
8112
|
+
};
|
|
8113
|
+
let firstAssistantId;
|
|
8114
|
+
let lastAssistantId;
|
|
8115
|
+
let assistantMessageCount = 0;
|
|
8116
|
+
for (const output of messages) {
|
|
8117
|
+
if (!output || !("role" in output)) {
|
|
8118
|
+
continue;
|
|
8119
|
+
}
|
|
8120
|
+
if (output.role === "tool") {
|
|
8121
|
+
const toolCallIdx = assistantMessage.content.findIndex(
|
|
8122
|
+
(c) => c.type === "tool-call" && c.toolCallId === output.toolCallId
|
|
8123
|
+
);
|
|
8124
|
+
if (toolCallIdx !== -1) {
|
|
8125
|
+
const toolCall = assistantMessage.content[toolCallIdx];
|
|
8126
|
+
if (output.toolName != null) {
|
|
8127
|
+
if (toolCall.toolName !== output.toolName)
|
|
8128
|
+
console.error(
|
|
8129
|
+
Error(
|
|
8130
|
+
`Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`
|
|
8131
|
+
)
|
|
8132
|
+
);
|
|
8133
|
+
}
|
|
8134
|
+
const { messages: existingMessages, ...toolCallRest } = toolCall;
|
|
8135
|
+
const updatedToolCall = {
|
|
8136
|
+
...toolCallRest,
|
|
8137
|
+
result: output.result,
|
|
8138
|
+
artifact: output.artifact,
|
|
8139
|
+
isError: output.isError,
|
|
8140
|
+
...(output.messages ?? existingMessages) !== void 0 && {
|
|
8141
|
+
messages: output.messages ?? existingMessages
|
|
8142
|
+
}
|
|
8143
|
+
};
|
|
8144
|
+
react$1.bindExternalStoreMessage(updatedToolCall, [
|
|
8145
|
+
...react$1.getExternalStoreMessages(toolCallRest),
|
|
8146
|
+
output
|
|
8147
|
+
]);
|
|
8148
|
+
assistantMessage.content[toolCallIdx] = updatedToolCall;
|
|
8149
|
+
} else {
|
|
8150
|
+
console.warn(
|
|
8151
|
+
`Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`
|
|
8152
|
+
);
|
|
8153
|
+
}
|
|
8154
|
+
} else {
|
|
8155
|
+
const role = output.role;
|
|
8156
|
+
const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
|
|
8157
|
+
const content = rawContent.flatMap((c) => {
|
|
8158
|
+
if (!c || typeof c !== "object") {
|
|
8159
|
+
return [];
|
|
8160
|
+
}
|
|
8161
|
+
const mapped = { ...c };
|
|
8162
|
+
react$1.bindExternalStoreMessage(mapped, output);
|
|
8163
|
+
return [mapped];
|
|
8164
|
+
});
|
|
8165
|
+
switch (role) {
|
|
8166
|
+
case "system":
|
|
8167
|
+
case "user":
|
|
8168
|
+
return {
|
|
8169
|
+
...output,
|
|
8170
|
+
content
|
|
8171
|
+
};
|
|
8172
|
+
case "assistant":
|
|
8173
|
+
if (output.id) {
|
|
8174
|
+
lastAssistantId = output.id;
|
|
8175
|
+
assistantMessageCount++;
|
|
8176
|
+
}
|
|
8177
|
+
if (assistantMessage.content.length === 0) {
|
|
8178
|
+
firstAssistantId = output.id;
|
|
8179
|
+
assistantMessage.createdAt ?? (assistantMessage.createdAt = output.createdAt);
|
|
8180
|
+
assistantMessage.status ?? (assistantMessage.status = output.status);
|
|
8181
|
+
if (output.attachments) {
|
|
8182
|
+
assistantMessage.attachments = [
|
|
8183
|
+
...assistantMessage.attachments ?? [],
|
|
8184
|
+
...output.attachments
|
|
8185
|
+
];
|
|
8186
|
+
}
|
|
8187
|
+
if (output.metadata) {
|
|
8188
|
+
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
8189
|
+
if (output.metadata.unstable_state) {
|
|
8190
|
+
assistantMessage.metadata.unstable_state = output.metadata.unstable_state;
|
|
8191
|
+
}
|
|
8192
|
+
if (output.metadata.unstable_annotations) {
|
|
8193
|
+
assistantMessage.metadata.unstable_annotations = [
|
|
8194
|
+
...assistantMessage.metadata.unstable_annotations ?? [],
|
|
8195
|
+
...output.metadata.unstable_annotations
|
|
8196
|
+
];
|
|
8197
|
+
}
|
|
8198
|
+
if (output.metadata.unstable_data) {
|
|
8199
|
+
assistantMessage.metadata.unstable_data = [
|
|
8200
|
+
...assistantMessage.metadata.unstable_data ?? [],
|
|
8201
|
+
...output.metadata.unstable_data
|
|
8202
|
+
];
|
|
8203
|
+
}
|
|
8204
|
+
if (output.metadata.steps) {
|
|
8205
|
+
assistantMessage.metadata.steps = [
|
|
8206
|
+
...assistantMessage.metadata.steps ?? [],
|
|
8207
|
+
...output.metadata.steps
|
|
8208
|
+
];
|
|
8209
|
+
}
|
|
8210
|
+
if (output.metadata.custom) {
|
|
8211
|
+
assistantMessage.metadata.custom = {
|
|
8212
|
+
...assistantMessage.metadata.custom ?? {},
|
|
8213
|
+
...output.metadata.custom
|
|
8214
|
+
};
|
|
8215
|
+
}
|
|
8216
|
+
if (output.metadata.submittedFeedback) {
|
|
8217
|
+
assistantMessage.metadata.submittedFeedback = output.metadata.submittedFeedback;
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
8220
|
+
} else {
|
|
8221
|
+
if ((_a2 = output.metadata) == null ? void 0 : _a2.custom) {
|
|
8222
|
+
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
8223
|
+
assistantMessage.metadata.custom = {
|
|
8224
|
+
...assistantMessage.metadata.custom ?? {},
|
|
8225
|
+
...output.metadata.custom
|
|
8226
|
+
};
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8229
|
+
assistantMessage.content.push(...content);
|
|
8230
|
+
break;
|
|
8231
|
+
default: {
|
|
8232
|
+
const unsupportedRole = role;
|
|
8233
|
+
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
|
8234
|
+
}
|
|
8235
|
+
}
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
assistantMessage.id = lastAssistantId ?? firstAssistantId;
|
|
8239
|
+
if (assistantMessageCount > 1) {
|
|
8240
|
+
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
8241
|
+
assistantMessage.metadata.custom = {
|
|
8242
|
+
...assistantMessage.metadata.custom ?? {},
|
|
8243
|
+
_firstMessageId: firstAssistantId,
|
|
8244
|
+
_lastMessageId: lastAssistantId,
|
|
8245
|
+
_joinedMessageCount: assistantMessageCount
|
|
8246
|
+
};
|
|
8247
|
+
}
|
|
8248
|
+
return assistantMessage;
|
|
8249
|
+
};
|
|
8250
|
+
const chunkExternalMessages = (callbackResults, _joinStrategy) => {
|
|
8251
|
+
var _a2;
|
|
8252
|
+
const results = [];
|
|
8253
|
+
let isAssistant = false;
|
|
8254
|
+
let pendingNone = false;
|
|
8255
|
+
let inputs = [];
|
|
8256
|
+
let outputs = [];
|
|
8257
|
+
const flush2 = () => {
|
|
8258
|
+
if (outputs.length) {
|
|
8259
|
+
results.push({
|
|
8260
|
+
inputs,
|
|
8261
|
+
outputs
|
|
8262
|
+
});
|
|
8263
|
+
}
|
|
8264
|
+
inputs = [];
|
|
8265
|
+
outputs = [];
|
|
8266
|
+
isAssistant = false;
|
|
8267
|
+
pendingNone = false;
|
|
8268
|
+
};
|
|
8269
|
+
for (const callbackResult of callbackResults) {
|
|
8270
|
+
for (const output of callbackResult.outputs) {
|
|
8271
|
+
if (!output || !("role" in output)) {
|
|
8272
|
+
continue;
|
|
8273
|
+
}
|
|
8274
|
+
if (pendingNone && output.role !== "tool" || !isAssistant || output.role === "user" || output.role === "system") {
|
|
8275
|
+
flush2();
|
|
8276
|
+
}
|
|
8277
|
+
isAssistant = output.role === "assistant" || output.role === "tool";
|
|
8278
|
+
if (inputs.at(-1) !== callbackResult.input) {
|
|
8279
|
+
inputs.push(callbackResult.input);
|
|
8280
|
+
}
|
|
8281
|
+
outputs.push(output);
|
|
8282
|
+
if (output.role === "assistant" && (((_a2 = output.convertConfig) == null ? void 0 : _a2.joinStrategy) === "none" || _joinStrategy === "none")) {
|
|
8283
|
+
pendingNone = true;
|
|
8284
|
+
}
|
|
8285
|
+
}
|
|
8286
|
+
}
|
|
8287
|
+
flush2();
|
|
8288
|
+
return results;
|
|
8289
|
+
};
|
|
8290
|
+
const convertExternalMessages = (messages, callback, isRunning, metadata) => {
|
|
8291
|
+
const callbackResults = [];
|
|
8292
|
+
for (const message of messages) {
|
|
8293
|
+
const output = callback(message, metadata);
|
|
8294
|
+
const rawOutputs = Array.isArray(output) ? output : [output];
|
|
8295
|
+
const outputs = rawOutputs.filter(
|
|
8296
|
+
(candidate) => candidate != null
|
|
8297
|
+
);
|
|
8298
|
+
if (outputs.length === 0) {
|
|
8299
|
+
continue;
|
|
8300
|
+
}
|
|
8301
|
+
const result = { input: message, outputs };
|
|
8302
|
+
callbackResults.push(result);
|
|
8303
|
+
}
|
|
8304
|
+
const chunks = chunkExternalMessages(callbackResults);
|
|
8305
|
+
return chunks.map((message, idx) => {
|
|
8306
|
+
const isLast = idx === chunks.length - 1;
|
|
8307
|
+
const joined = joinExternalMessages(message.outputs);
|
|
8308
|
+
const hasPendingToolCalls = typeof joined.content === "object" && joined.content.some((c) => c.type === "tool-call" && c.result === void 0);
|
|
8309
|
+
const autoStatus = getAutoStatus(isLast, isRunning, hasPendingToolCalls, hasPendingToolCalls);
|
|
8310
|
+
const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
|
|
8311
|
+
react$1.bindExternalStoreMessage(newMessage, message.inputs);
|
|
8312
|
+
return newMessage;
|
|
8313
|
+
});
|
|
8314
|
+
};
|
|
8315
|
+
const PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE = "Sub-call did not complete before the parent tool returned.";
|
|
8316
|
+
const autoCloseInFlightSubgraphMessages = (msgs) => {
|
|
8317
|
+
const beginIds = /* @__PURE__ */ new Set();
|
|
8318
|
+
const endIds = /* @__PURE__ */ new Set();
|
|
8319
|
+
for (const message of msgs) {
|
|
8320
|
+
if (!isRecord(message)) continue;
|
|
8321
|
+
if (message.type === "ai" && Array.isArray(message.tool_calls)) {
|
|
8322
|
+
for (const toolCall of message.tool_calls) {
|
|
8323
|
+
if (!isRecord(toolCall)) continue;
|
|
8324
|
+
const id = toolCall.id;
|
|
8325
|
+
if (typeof id === "string") beginIds.add(id);
|
|
8326
|
+
}
|
|
8327
|
+
} else if (message.type === "tool" && typeof message.tool_call_id === "string") {
|
|
8328
|
+
endIds.add(message.tool_call_id);
|
|
8329
|
+
}
|
|
8330
|
+
}
|
|
8331
|
+
const unmatchedIds = [...beginIds].filter((id) => !endIds.has(id));
|
|
8332
|
+
if (unmatchedIds.length === 0) return [...msgs];
|
|
8333
|
+
return [
|
|
8334
|
+
...msgs,
|
|
8335
|
+
...unmatchedIds.map((toolCallId) => ({
|
|
8336
|
+
type: "tool",
|
|
8337
|
+
tool_call_id: toolCallId,
|
|
8338
|
+
content: PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE,
|
|
8339
|
+
status: "error"
|
|
8340
|
+
}))
|
|
8341
|
+
];
|
|
8342
|
+
};
|
|
8343
|
+
const warnedMessagePartTypes = /* @__PURE__ */ new Set();
|
|
8344
|
+
const warnForUnknownMessagePartType = (type) => {
|
|
8345
|
+
if (warnedMessagePartTypes.has(type)) return;
|
|
8346
|
+
warnedMessagePartTypes.add(type);
|
|
8347
|
+
console.warn(`Unknown message part type: ${type}`);
|
|
8348
|
+
};
|
|
8349
|
+
const contentToParts = (content) => {
|
|
8350
|
+
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
8351
|
+
return content.flatMap((part) => {
|
|
8352
|
+
if (!part || typeof part !== "object" || !("type" in part)) {
|
|
8353
|
+
return [];
|
|
8354
|
+
}
|
|
8355
|
+
const type = part.type;
|
|
8356
|
+
switch (type) {
|
|
8357
|
+
case "text":
|
|
8358
|
+
return [{ type: "text", text: part.text }];
|
|
8359
|
+
case "text_delta":
|
|
8360
|
+
return [{ type: "text", text: part.text }];
|
|
8361
|
+
case "image_url":
|
|
8362
|
+
if (typeof part.image_url === "string") {
|
|
8363
|
+
return [{ type: "image", image: part.image_url }];
|
|
8364
|
+
}
|
|
8365
|
+
return [{
|
|
8366
|
+
type: "image",
|
|
8367
|
+
image: part.image_url.url
|
|
8368
|
+
}];
|
|
8369
|
+
case "thinking":
|
|
8370
|
+
return [{ type: "reasoning", text: part.thinking }];
|
|
8371
|
+
case "reasoning":
|
|
8372
|
+
return [{
|
|
8373
|
+
type: "reasoning",
|
|
8374
|
+
text: part.summary.map((s) => s.text).join("\n\n\n")
|
|
8375
|
+
}];
|
|
8376
|
+
case "tool_use":
|
|
8377
|
+
return [];
|
|
8378
|
+
case "input_json_delta":
|
|
8379
|
+
return [];
|
|
8380
|
+
default:
|
|
8381
|
+
warnForUnknownMessagePartType(type);
|
|
8382
|
+
return [];
|
|
8383
|
+
}
|
|
8384
|
+
});
|
|
8385
|
+
};
|
|
8386
|
+
const getNumberAtPath = (value, path) => {
|
|
8387
|
+
let current = value;
|
|
8388
|
+
for (const segment of path) {
|
|
8389
|
+
if (!isRecord(current)) {
|
|
8390
|
+
return void 0;
|
|
8391
|
+
}
|
|
8392
|
+
current = current[segment];
|
|
8393
|
+
}
|
|
8394
|
+
return typeof current === "number" && Number.isFinite(current) ? current : void 0;
|
|
8395
|
+
};
|
|
8396
|
+
const extractReasoningTokens = ({
|
|
8397
|
+
usageMetadata,
|
|
8398
|
+
responseMetadata
|
|
8399
|
+
}) => {
|
|
8400
|
+
const rawReasoningTokens = getNumberAtPath(usageMetadata, ["output_token_details", "reasoning"]) ?? getNumberAtPath(usageMetadata, ["output_token_details", "reasoning_tokens"]) ?? getNumberAtPath(usageMetadata, ["reasoning_tokens"]) ?? getNumberAtPath(responseMetadata, ["output_token_details", "reasoning"]) ?? getNumberAtPath(responseMetadata, ["output_token_details", "reasoning_tokens"]) ?? getNumberAtPath(responseMetadata, ["token_usage", "output_token_details", "reasoning"]) ?? getNumberAtPath(responseMetadata, ["token_usage", "output_token_details", "reasoning_tokens"]);
|
|
8401
|
+
return rawReasoningTokens !== void 0 && rawReasoningTokens > 0 ? rawReasoningTokens : void 0;
|
|
8402
|
+
};
|
|
8403
|
+
const buildCustomMetadata = ({
|
|
8404
|
+
additionalKwargs,
|
|
8405
|
+
usageMetadata,
|
|
8406
|
+
responseMetadata
|
|
8407
|
+
}) => {
|
|
8408
|
+
const customMetadata = additionalKwargs ? { ...additionalKwargs } : {};
|
|
8409
|
+
const reasoningTokens = extractReasoningTokens({ usageMetadata, responseMetadata });
|
|
8410
|
+
const existingAthenaMetadata = isRecord(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
8411
|
+
const athenaMetadata = {
|
|
8412
|
+
...existingAthenaMetadata ?? {}
|
|
8413
|
+
};
|
|
8414
|
+
if (usageMetadata) {
|
|
8415
|
+
athenaMetadata.rawUsageMetadata = usageMetadata;
|
|
8416
|
+
}
|
|
8417
|
+
if (responseMetadata) {
|
|
8418
|
+
athenaMetadata.rawResponseMetadata = responseMetadata;
|
|
8419
|
+
}
|
|
8420
|
+
if (reasoningTokens !== void 0) {
|
|
8421
|
+
athenaMetadata.reasoningTokens = reasoningTokens;
|
|
8422
|
+
}
|
|
8423
|
+
if (Object.keys(athenaMetadata).length > 0) {
|
|
8424
|
+
customMetadata._athena = athenaMetadata;
|
|
8425
|
+
}
|
|
8426
|
+
return Object.keys(customMetadata).length > 0 ? customMetadata : void 0;
|
|
8427
|
+
};
|
|
8428
|
+
const getSubgraphMessages = (artifact) => {
|
|
8429
|
+
if (!isRecord(artifact)) return void 0;
|
|
8430
|
+
const subgraphState = artifact.subgraph_state;
|
|
8431
|
+
if (!isRecord(subgraphState)) return void 0;
|
|
8432
|
+
const messages = subgraphState.messages;
|
|
8433
|
+
return Array.isArray(messages) && messages.length > 0 ? messages : void 0;
|
|
8434
|
+
};
|
|
8435
|
+
const convertLangChainMessage = (message) => {
|
|
8436
|
+
var _a2, _b, _c;
|
|
8437
|
+
switch (message.type) {
|
|
8438
|
+
case "system": {
|
|
8439
|
+
const customMetadata = buildCustomMetadata({
|
|
8440
|
+
additionalKwargs: message.additional_kwargs
|
|
8441
|
+
});
|
|
8442
|
+
return {
|
|
8443
|
+
role: "system",
|
|
8444
|
+
id: message.id,
|
|
8445
|
+
content: [{ type: "text", text: message.content }],
|
|
8446
|
+
...customMetadata && {
|
|
8447
|
+
metadata: {
|
|
8448
|
+
custom: customMetadata
|
|
8449
|
+
}
|
|
8450
|
+
}
|
|
8451
|
+
};
|
|
8452
|
+
}
|
|
8453
|
+
case "human": {
|
|
8454
|
+
const customMetadata = buildCustomMetadata({
|
|
8455
|
+
additionalKwargs: message.additional_kwargs
|
|
8456
|
+
});
|
|
8457
|
+
return {
|
|
8458
|
+
role: "user",
|
|
8459
|
+
id: message.id,
|
|
8460
|
+
content: contentToParts(message.content),
|
|
8461
|
+
...customMetadata && {
|
|
8462
|
+
metadata: {
|
|
8463
|
+
custom: customMetadata
|
|
8464
|
+
}
|
|
8465
|
+
}
|
|
8466
|
+
};
|
|
8467
|
+
}
|
|
8468
|
+
case "ai": {
|
|
8469
|
+
const customMetadata = buildCustomMetadata({
|
|
8470
|
+
additionalKwargs: message.additional_kwargs,
|
|
8471
|
+
usageMetadata: message.usage_metadata,
|
|
8472
|
+
responseMetadata: message.response_metadata
|
|
8473
|
+
});
|
|
8474
|
+
const toolCallParts = ((_a2 = message.tool_calls) == null ? void 0 : _a2.map((chunk) => {
|
|
8475
|
+
var _a3, _b2;
|
|
8476
|
+
let argsText;
|
|
8477
|
+
if (typeof chunk.args === "string") {
|
|
8478
|
+
argsText = chunk.args;
|
|
8479
|
+
} else {
|
|
8480
|
+
const rawString = chunk.partial_json ?? ((_b2 = (_a3 = message.tool_call_chunks) == null ? void 0 : _a3.find((c) => c.id === chunk.id)) == null ? void 0 : _b2.args) ?? JSON.stringify(chunk.args);
|
|
8481
|
+
argsText = rawString;
|
|
8482
|
+
}
|
|
8483
|
+
return {
|
|
8484
|
+
type: "tool-call",
|
|
8485
|
+
toolCallId: chunk.id,
|
|
8486
|
+
toolName: chunk.name,
|
|
8487
|
+
args: typeof chunk.args === "string" ? parsePartialJsonObject(argsText) ?? {} : chunk.args,
|
|
8488
|
+
argsText
|
|
8489
|
+
};
|
|
8490
|
+
})) ?? [];
|
|
8491
|
+
const normalizedContent = typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content;
|
|
8492
|
+
const allContent = [
|
|
8493
|
+
(_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
|
|
8494
|
+
...normalizedContent,
|
|
8495
|
+
...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
|
|
8496
|
+
].filter((c) => c != null);
|
|
8497
|
+
return {
|
|
8498
|
+
role: "assistant",
|
|
8499
|
+
id: message.id,
|
|
8500
|
+
content: [...contentToParts(allContent), ...toolCallParts],
|
|
8501
|
+
...message.status && { status: message.status },
|
|
8502
|
+
...customMetadata && {
|
|
8503
|
+
metadata: {
|
|
8504
|
+
custom: customMetadata
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
};
|
|
8508
|
+
}
|
|
8509
|
+
case "tool": {
|
|
8510
|
+
const subgraphMessages = getSubgraphMessages(message.artifact);
|
|
8511
|
+
const parentEnded = message.content !== void 0 && message.content !== null;
|
|
8512
|
+
const nestedMessages = subgraphMessages !== void 0 ? convertLangChainToThreadMessages(
|
|
8513
|
+
parseMessages(
|
|
8514
|
+
parentEnded ? autoCloseInFlightSubgraphMessages(subgraphMessages) : subgraphMessages
|
|
8515
|
+
),
|
|
8516
|
+
!parentEnded
|
|
8517
|
+
) : void 0;
|
|
8518
|
+
return {
|
|
8519
|
+
role: "tool",
|
|
8520
|
+
toolName: message.name,
|
|
8521
|
+
toolCallId: message.tool_call_id,
|
|
8522
|
+
result: message.content,
|
|
8523
|
+
artifact: message.artifact,
|
|
8524
|
+
isError: message.status === "error",
|
|
8525
|
+
...nestedMessages !== void 0 && { messages: nestedMessages }
|
|
8526
|
+
};
|
|
8527
|
+
}
|
|
8528
|
+
default:
|
|
8529
|
+
return null;
|
|
8530
|
+
}
|
|
8531
|
+
};
|
|
8532
|
+
const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
|
|
8533
|
+
const validToolCallIds = /* @__PURE__ */ new Set();
|
|
8534
|
+
for (const message of messages) {
|
|
8535
|
+
if (message.type === "ai" && message.tool_calls) {
|
|
8536
|
+
for (const tc of message.tool_calls) {
|
|
8537
|
+
if (tc.id) {
|
|
8538
|
+
validToolCallIds.add(tc.id);
|
|
8539
|
+
}
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
}
|
|
8543
|
+
const filteredMessages = messages.filter((message) => {
|
|
8544
|
+
if (message.type === "tool" && message.tool_call_id && !validToolCallIds.has(message.tool_call_id)) {
|
|
8545
|
+
return false;
|
|
8546
|
+
}
|
|
8547
|
+
return true;
|
|
8548
|
+
});
|
|
8549
|
+
return convertExternalMessages(filteredMessages, convertLangChainMessage, isRunning, metadata);
|
|
8550
|
+
};
|
|
8507
8551
|
function getAuthHeaders(auth) {
|
|
8508
8552
|
if (auth.token) {
|
|
8509
8553
|
return { Authorization: `Bearer ${auth.token}` };
|
|
@@ -9093,12 +9137,12 @@ function useComposedRefs(...refs) {
|
|
|
9093
9137
|
return React__namespace.useCallback(composeRefs(...refs), refs);
|
|
9094
9138
|
}
|
|
9095
9139
|
// @__NO_SIDE_EFFECTS__
|
|
9096
|
-
function createSlot(ownerName) {
|
|
9097
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
9140
|
+
function createSlot$7(ownerName) {
|
|
9141
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$7(ownerName);
|
|
9098
9142
|
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9099
9143
|
const { children, ...slotProps } = props;
|
|
9100
9144
|
const childrenArray = React__namespace.Children.toArray(children);
|
|
9101
|
-
const slottable = childrenArray.find(isSlottable);
|
|
9145
|
+
const slottable = childrenArray.find(isSlottable$7);
|
|
9102
9146
|
if (slottable) {
|
|
9103
9147
|
const newElement = slottable.props.children;
|
|
9104
9148
|
const newChildren = childrenArray.map((child) => {
|
|
@@ -9116,14 +9160,13 @@ function createSlot(ownerName) {
|
|
|
9116
9160
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
9117
9161
|
return Slot2;
|
|
9118
9162
|
}
|
|
9119
|
-
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
9120
9163
|
// @__NO_SIDE_EFFECTS__
|
|
9121
|
-
function createSlotClone(ownerName) {
|
|
9164
|
+
function createSlotClone$7(ownerName) {
|
|
9122
9165
|
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9123
9166
|
const { children, ...slotProps } = props;
|
|
9124
9167
|
if (React__namespace.isValidElement(children)) {
|
|
9125
|
-
const childrenRef = getElementRef$
|
|
9126
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
9168
|
+
const childrenRef = getElementRef$8(children);
|
|
9169
|
+
const props2 = mergeProps$7(slotProps, children.props);
|
|
9127
9170
|
if (children.type !== React__namespace.Fragment) {
|
|
9128
9171
|
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9129
9172
|
}
|
|
@@ -9134,21 +9177,11 @@ function createSlotClone(ownerName) {
|
|
|
9134
9177
|
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9135
9178
|
return SlotClone;
|
|
9136
9179
|
}
|
|
9137
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
const Slottable2 = ({ children }) => {
|
|
9141
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
9142
|
-
};
|
|
9143
|
-
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
9144
|
-
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
9145
|
-
return Slottable2;
|
|
9180
|
+
var SLOTTABLE_IDENTIFIER$7 = Symbol("radix.slottable");
|
|
9181
|
+
function isSlottable$7(child) {
|
|
9182
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$7;
|
|
9146
9183
|
}
|
|
9147
|
-
|
|
9148
|
-
function isSlottable(child) {
|
|
9149
|
-
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
9150
|
-
}
|
|
9151
|
-
function mergeProps(slotProps, childProps) {
|
|
9184
|
+
function mergeProps$7(slotProps, childProps) {
|
|
9152
9185
|
const overrideProps = { ...childProps };
|
|
9153
9186
|
for (const propName in childProps) {
|
|
9154
9187
|
const slotPropValue = slotProps[propName];
|
|
@@ -9172,7 +9205,7 @@ function mergeProps(slotProps, childProps) {
|
|
|
9172
9205
|
}
|
|
9173
9206
|
return { ...slotProps, ...overrideProps };
|
|
9174
9207
|
}
|
|
9175
|
-
function getElementRef$
|
|
9208
|
+
function getElementRef$8(element) {
|
|
9176
9209
|
var _a2, _b;
|
|
9177
9210
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9178
9211
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9206,7 +9239,7 @@ var NODES$6 = [
|
|
|
9206
9239
|
"ul"
|
|
9207
9240
|
];
|
|
9208
9241
|
var Primitive$6 = NODES$6.reduce((primitive, node) => {
|
|
9209
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9242
|
+
const Slot2 = /* @__PURE__ */ createSlot$7(`Primitive.${node}`);
|
|
9210
9243
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9211
9244
|
const { asChild, ...primitiveProps } = props;
|
|
9212
9245
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9381,6 +9414,89 @@ function composeContextScopes$2(...scopes) {
|
|
|
9381
9414
|
createScope.scopeName = baseScope.scopeName;
|
|
9382
9415
|
return createScope;
|
|
9383
9416
|
}
|
|
9417
|
+
// @__NO_SIDE_EFFECTS__
|
|
9418
|
+
function createSlot$6(ownerName) {
|
|
9419
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$6(ownerName);
|
|
9420
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9421
|
+
const { children, ...slotProps } = props;
|
|
9422
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
9423
|
+
const slottable = childrenArray.find(isSlottable$6);
|
|
9424
|
+
if (slottable) {
|
|
9425
|
+
const newElement = slottable.props.children;
|
|
9426
|
+
const newChildren = childrenArray.map((child) => {
|
|
9427
|
+
if (child === slottable) {
|
|
9428
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
9429
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
9430
|
+
} else {
|
|
9431
|
+
return child;
|
|
9432
|
+
}
|
|
9433
|
+
});
|
|
9434
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
9435
|
+
}
|
|
9436
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9437
|
+
});
|
|
9438
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
9439
|
+
return Slot2;
|
|
9440
|
+
}
|
|
9441
|
+
// @__NO_SIDE_EFFECTS__
|
|
9442
|
+
function createSlotClone$6(ownerName) {
|
|
9443
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9444
|
+
const { children, ...slotProps } = props;
|
|
9445
|
+
if (React__namespace.isValidElement(children)) {
|
|
9446
|
+
const childrenRef = getElementRef$7(children);
|
|
9447
|
+
const props2 = mergeProps$6(slotProps, children.props);
|
|
9448
|
+
if (children.type !== React__namespace.Fragment) {
|
|
9449
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9450
|
+
}
|
|
9451
|
+
return React__namespace.cloneElement(children, props2);
|
|
9452
|
+
}
|
|
9453
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
9454
|
+
});
|
|
9455
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9456
|
+
return SlotClone;
|
|
9457
|
+
}
|
|
9458
|
+
var SLOTTABLE_IDENTIFIER$6 = Symbol("radix.slottable");
|
|
9459
|
+
function isSlottable$6(child) {
|
|
9460
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$6;
|
|
9461
|
+
}
|
|
9462
|
+
function mergeProps$6(slotProps, childProps) {
|
|
9463
|
+
const overrideProps = { ...childProps };
|
|
9464
|
+
for (const propName in childProps) {
|
|
9465
|
+
const slotPropValue = slotProps[propName];
|
|
9466
|
+
const childPropValue = childProps[propName];
|
|
9467
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
9468
|
+
if (isHandler) {
|
|
9469
|
+
if (slotPropValue && childPropValue) {
|
|
9470
|
+
overrideProps[propName] = (...args) => {
|
|
9471
|
+
const result = childPropValue(...args);
|
|
9472
|
+
slotPropValue(...args);
|
|
9473
|
+
return result;
|
|
9474
|
+
};
|
|
9475
|
+
} else if (slotPropValue) {
|
|
9476
|
+
overrideProps[propName] = slotPropValue;
|
|
9477
|
+
}
|
|
9478
|
+
} else if (propName === "style") {
|
|
9479
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9480
|
+
} else if (propName === "className") {
|
|
9481
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9482
|
+
}
|
|
9483
|
+
}
|
|
9484
|
+
return { ...slotProps, ...overrideProps };
|
|
9485
|
+
}
|
|
9486
|
+
function getElementRef$7(element) {
|
|
9487
|
+
var _a2, _b;
|
|
9488
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9489
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9490
|
+
if (mayWarn) {
|
|
9491
|
+
return element.ref;
|
|
9492
|
+
}
|
|
9493
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9494
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9495
|
+
if (mayWarn) {
|
|
9496
|
+
return element.props.ref;
|
|
9497
|
+
}
|
|
9498
|
+
return element.props.ref || element.ref;
|
|
9499
|
+
}
|
|
9384
9500
|
var NODES$5 = [
|
|
9385
9501
|
"a",
|
|
9386
9502
|
"button",
|
|
@@ -9401,7 +9517,7 @@ var NODES$5 = [
|
|
|
9401
9517
|
"ul"
|
|
9402
9518
|
];
|
|
9403
9519
|
var Primitive$5 = NODES$5.reduce((primitive, node) => {
|
|
9404
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9520
|
+
const Slot2 = /* @__PURE__ */ createSlot$6(`Primitive.${node}`);
|
|
9405
9521
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9406
9522
|
const { asChild, ...primitiveProps } = props;
|
|
9407
9523
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9423,7 +9539,7 @@ var Presence = (props) => {
|
|
|
9423
9539
|
const { present, children } = props;
|
|
9424
9540
|
const presence = usePresence(present);
|
|
9425
9541
|
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React__namespace.Children.only(children);
|
|
9426
|
-
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
9542
|
+
const ref = useComposedRefs(presence.ref, getElementRef$6(child));
|
|
9427
9543
|
const forceMount = typeof children === "function";
|
|
9428
9544
|
return forceMount || presence.isPresent ? React__namespace.cloneElement(child, { ref }) : null;
|
|
9429
9545
|
};
|
|
@@ -9522,7 +9638,7 @@ function usePresence(present) {
|
|
|
9522
9638
|
function getAnimationName(styles) {
|
|
9523
9639
|
return (styles == null ? void 0 : styles.animationName) || "none";
|
|
9524
9640
|
}
|
|
9525
|
-
function getElementRef(element) {
|
|
9641
|
+
function getElementRef$6(element) {
|
|
9526
9642
|
var _a2, _b;
|
|
9527
9643
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9528
9644
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9675,6 +9791,89 @@ function getState(open) {
|
|
|
9675
9791
|
return open ? "open" : "closed";
|
|
9676
9792
|
}
|
|
9677
9793
|
var Root$1 = Collapsible$1;
|
|
9794
|
+
// @__NO_SIDE_EFFECTS__
|
|
9795
|
+
function createSlot$5(ownerName) {
|
|
9796
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$5(ownerName);
|
|
9797
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9798
|
+
const { children, ...slotProps } = props;
|
|
9799
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
9800
|
+
const slottable = childrenArray.find(isSlottable$5);
|
|
9801
|
+
if (slottable) {
|
|
9802
|
+
const newElement = slottable.props.children;
|
|
9803
|
+
const newChildren = childrenArray.map((child) => {
|
|
9804
|
+
if (child === slottable) {
|
|
9805
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
9806
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
9807
|
+
} else {
|
|
9808
|
+
return child;
|
|
9809
|
+
}
|
|
9810
|
+
});
|
|
9811
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
9812
|
+
}
|
|
9813
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9814
|
+
});
|
|
9815
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
9816
|
+
return Slot2;
|
|
9817
|
+
}
|
|
9818
|
+
// @__NO_SIDE_EFFECTS__
|
|
9819
|
+
function createSlotClone$5(ownerName) {
|
|
9820
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9821
|
+
const { children, ...slotProps } = props;
|
|
9822
|
+
if (React__namespace.isValidElement(children)) {
|
|
9823
|
+
const childrenRef = getElementRef$5(children);
|
|
9824
|
+
const props2 = mergeProps$5(slotProps, children.props);
|
|
9825
|
+
if (children.type !== React__namespace.Fragment) {
|
|
9826
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9827
|
+
}
|
|
9828
|
+
return React__namespace.cloneElement(children, props2);
|
|
9829
|
+
}
|
|
9830
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
9831
|
+
});
|
|
9832
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9833
|
+
return SlotClone;
|
|
9834
|
+
}
|
|
9835
|
+
var SLOTTABLE_IDENTIFIER$5 = Symbol("radix.slottable");
|
|
9836
|
+
function isSlottable$5(child) {
|
|
9837
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$5;
|
|
9838
|
+
}
|
|
9839
|
+
function mergeProps$5(slotProps, childProps) {
|
|
9840
|
+
const overrideProps = { ...childProps };
|
|
9841
|
+
for (const propName in childProps) {
|
|
9842
|
+
const slotPropValue = slotProps[propName];
|
|
9843
|
+
const childPropValue = childProps[propName];
|
|
9844
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
9845
|
+
if (isHandler) {
|
|
9846
|
+
if (slotPropValue && childPropValue) {
|
|
9847
|
+
overrideProps[propName] = (...args) => {
|
|
9848
|
+
const result = childPropValue(...args);
|
|
9849
|
+
slotPropValue(...args);
|
|
9850
|
+
return result;
|
|
9851
|
+
};
|
|
9852
|
+
} else if (slotPropValue) {
|
|
9853
|
+
overrideProps[propName] = slotPropValue;
|
|
9854
|
+
}
|
|
9855
|
+
} else if (propName === "style") {
|
|
9856
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9857
|
+
} else if (propName === "className") {
|
|
9858
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9859
|
+
}
|
|
9860
|
+
}
|
|
9861
|
+
return { ...slotProps, ...overrideProps };
|
|
9862
|
+
}
|
|
9863
|
+
function getElementRef$5(element) {
|
|
9864
|
+
var _a2, _b;
|
|
9865
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9866
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9867
|
+
if (mayWarn) {
|
|
9868
|
+
return element.ref;
|
|
9869
|
+
}
|
|
9870
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9871
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9872
|
+
if (mayWarn) {
|
|
9873
|
+
return element.props.ref;
|
|
9874
|
+
}
|
|
9875
|
+
return element.props.ref || element.ref;
|
|
9876
|
+
}
|
|
9678
9877
|
var NODES$4 = [
|
|
9679
9878
|
"a",
|
|
9680
9879
|
"button",
|
|
@@ -9695,7 +9894,7 @@ var NODES$4 = [
|
|
|
9695
9894
|
"ul"
|
|
9696
9895
|
];
|
|
9697
9896
|
var Primitive$4 = NODES$4.reduce((primitive, node) => {
|
|
9698
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9897
|
+
const Slot2 = /* @__PURE__ */ createSlot$5(`Primitive.${node}`);
|
|
9699
9898
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9700
9899
|
const { asChild, ...primitiveProps } = props;
|
|
9701
9900
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9933,6 +10132,89 @@ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
|
9933
10132
|
target.dispatchEvent(event);
|
|
9934
10133
|
}
|
|
9935
10134
|
}
|
|
10135
|
+
// @__NO_SIDE_EFFECTS__
|
|
10136
|
+
function createSlot$4(ownerName) {
|
|
10137
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$4(ownerName);
|
|
10138
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10139
|
+
const { children, ...slotProps } = props;
|
|
10140
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
10141
|
+
const slottable = childrenArray.find(isSlottable$4);
|
|
10142
|
+
if (slottable) {
|
|
10143
|
+
const newElement = slottable.props.children;
|
|
10144
|
+
const newChildren = childrenArray.map((child) => {
|
|
10145
|
+
if (child === slottable) {
|
|
10146
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
10147
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
10148
|
+
} else {
|
|
10149
|
+
return child;
|
|
10150
|
+
}
|
|
10151
|
+
});
|
|
10152
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
10153
|
+
}
|
|
10154
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10155
|
+
});
|
|
10156
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
10157
|
+
return Slot2;
|
|
10158
|
+
}
|
|
10159
|
+
// @__NO_SIDE_EFFECTS__
|
|
10160
|
+
function createSlotClone$4(ownerName) {
|
|
10161
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10162
|
+
const { children, ...slotProps } = props;
|
|
10163
|
+
if (React__namespace.isValidElement(children)) {
|
|
10164
|
+
const childrenRef = getElementRef$4(children);
|
|
10165
|
+
const props2 = mergeProps$4(slotProps, children.props);
|
|
10166
|
+
if (children.type !== React__namespace.Fragment) {
|
|
10167
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10168
|
+
}
|
|
10169
|
+
return React__namespace.cloneElement(children, props2);
|
|
10170
|
+
}
|
|
10171
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
10172
|
+
});
|
|
10173
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10174
|
+
return SlotClone;
|
|
10175
|
+
}
|
|
10176
|
+
var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
|
|
10177
|
+
function isSlottable$4(child) {
|
|
10178
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
|
|
10179
|
+
}
|
|
10180
|
+
function mergeProps$4(slotProps, childProps) {
|
|
10181
|
+
const overrideProps = { ...childProps };
|
|
10182
|
+
for (const propName in childProps) {
|
|
10183
|
+
const slotPropValue = slotProps[propName];
|
|
10184
|
+
const childPropValue = childProps[propName];
|
|
10185
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
10186
|
+
if (isHandler) {
|
|
10187
|
+
if (slotPropValue && childPropValue) {
|
|
10188
|
+
overrideProps[propName] = (...args) => {
|
|
10189
|
+
const result = childPropValue(...args);
|
|
10190
|
+
slotPropValue(...args);
|
|
10191
|
+
return result;
|
|
10192
|
+
};
|
|
10193
|
+
} else if (slotPropValue) {
|
|
10194
|
+
overrideProps[propName] = slotPropValue;
|
|
10195
|
+
}
|
|
10196
|
+
} else if (propName === "style") {
|
|
10197
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10198
|
+
} else if (propName === "className") {
|
|
10199
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10200
|
+
}
|
|
10201
|
+
}
|
|
10202
|
+
return { ...slotProps, ...overrideProps };
|
|
10203
|
+
}
|
|
10204
|
+
function getElementRef$4(element) {
|
|
10205
|
+
var _a2, _b;
|
|
10206
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10207
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10208
|
+
if (mayWarn) {
|
|
10209
|
+
return element.ref;
|
|
10210
|
+
}
|
|
10211
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10212
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10213
|
+
if (mayWarn) {
|
|
10214
|
+
return element.props.ref;
|
|
10215
|
+
}
|
|
10216
|
+
return element.props.ref || element.ref;
|
|
10217
|
+
}
|
|
9936
10218
|
var NODES$3 = [
|
|
9937
10219
|
"a",
|
|
9938
10220
|
"button",
|
|
@@ -9953,7 +10235,7 @@ var NODES$3 = [
|
|
|
9953
10235
|
"ul"
|
|
9954
10236
|
];
|
|
9955
10237
|
var Primitive$3 = NODES$3.reduce((primitive, node) => {
|
|
9956
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
10238
|
+
const Slot2 = /* @__PURE__ */ createSlot$4(`Primitive.${node}`);
|
|
9957
10239
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
9958
10240
|
const { asChild, ...primitiveProps } = props;
|
|
9959
10241
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9975,6 +10257,100 @@ var Portal$1 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
|
9975
10257
|
return container ? ReactDOM.createPortal(/* @__PURE__ */ jsxRuntime.jsx(Primitive$3.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
9976
10258
|
});
|
|
9977
10259
|
Portal$1.displayName = PORTAL_NAME$1;
|
|
10260
|
+
// @__NO_SIDE_EFFECTS__
|
|
10261
|
+
function createSlot$3(ownerName) {
|
|
10262
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$3(ownerName);
|
|
10263
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10264
|
+
const { children, ...slotProps } = props;
|
|
10265
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
10266
|
+
const slottable = childrenArray.find(isSlottable$3);
|
|
10267
|
+
if (slottable) {
|
|
10268
|
+
const newElement = slottable.props.children;
|
|
10269
|
+
const newChildren = childrenArray.map((child) => {
|
|
10270
|
+
if (child === slottable) {
|
|
10271
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
10272
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
10273
|
+
} else {
|
|
10274
|
+
return child;
|
|
10275
|
+
}
|
|
10276
|
+
});
|
|
10277
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
10278
|
+
}
|
|
10279
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10280
|
+
});
|
|
10281
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
10282
|
+
return Slot2;
|
|
10283
|
+
}
|
|
10284
|
+
var Slot = /* @__PURE__ */ createSlot$3("Slot");
|
|
10285
|
+
// @__NO_SIDE_EFFECTS__
|
|
10286
|
+
function createSlotClone$3(ownerName) {
|
|
10287
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
10288
|
+
const { children, ...slotProps } = props;
|
|
10289
|
+
if (React__namespace.isValidElement(children)) {
|
|
10290
|
+
const childrenRef = getElementRef$3(children);
|
|
10291
|
+
const props2 = mergeProps$3(slotProps, children.props);
|
|
10292
|
+
if (children.type !== React__namespace.Fragment) {
|
|
10293
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10294
|
+
}
|
|
10295
|
+
return React__namespace.cloneElement(children, props2);
|
|
10296
|
+
}
|
|
10297
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
10298
|
+
});
|
|
10299
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10300
|
+
return SlotClone;
|
|
10301
|
+
}
|
|
10302
|
+
var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
|
|
10303
|
+
// @__NO_SIDE_EFFECTS__
|
|
10304
|
+
function createSlottable$1(ownerName) {
|
|
10305
|
+
const Slottable2 = ({ children }) => {
|
|
10306
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
10307
|
+
};
|
|
10308
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
10309
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER$3;
|
|
10310
|
+
return Slottable2;
|
|
10311
|
+
}
|
|
10312
|
+
var Slottable$1 = /* @__PURE__ */ createSlottable$1("Slottable");
|
|
10313
|
+
function isSlottable$3(child) {
|
|
10314
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
|
|
10315
|
+
}
|
|
10316
|
+
function mergeProps$3(slotProps, childProps) {
|
|
10317
|
+
const overrideProps = { ...childProps };
|
|
10318
|
+
for (const propName in childProps) {
|
|
10319
|
+
const slotPropValue = slotProps[propName];
|
|
10320
|
+
const childPropValue = childProps[propName];
|
|
10321
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
10322
|
+
if (isHandler) {
|
|
10323
|
+
if (slotPropValue && childPropValue) {
|
|
10324
|
+
overrideProps[propName] = (...args) => {
|
|
10325
|
+
const result = childPropValue(...args);
|
|
10326
|
+
slotPropValue(...args);
|
|
10327
|
+
return result;
|
|
10328
|
+
};
|
|
10329
|
+
} else if (slotPropValue) {
|
|
10330
|
+
overrideProps[propName] = slotPropValue;
|
|
10331
|
+
}
|
|
10332
|
+
} else if (propName === "style") {
|
|
10333
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10334
|
+
} else if (propName === "className") {
|
|
10335
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10336
|
+
}
|
|
10337
|
+
}
|
|
10338
|
+
return { ...slotProps, ...overrideProps };
|
|
10339
|
+
}
|
|
10340
|
+
function getElementRef$3(element) {
|
|
10341
|
+
var _a2, _b;
|
|
10342
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10343
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10344
|
+
if (mayWarn) {
|
|
10345
|
+
return element.ref;
|
|
10346
|
+
}
|
|
10347
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10348
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10349
|
+
if (mayWarn) {
|
|
10350
|
+
return element.props.ref;
|
|
10351
|
+
}
|
|
10352
|
+
return element.props.ref || element.ref;
|
|
10353
|
+
}
|
|
9978
10354
|
var shim$1 = { exports: {} };
|
|
9979
10355
|
var useSyncExternalStoreShim_production = {};
|
|
9980
10356
|
/**
|
|
@@ -12067,6 +12443,89 @@ const arrow$2 = (options, deps) => {
|
|
|
12067
12443
|
options: [options, deps]
|
|
12068
12444
|
};
|
|
12069
12445
|
};
|
|
12446
|
+
// @__NO_SIDE_EFFECTS__
|
|
12447
|
+
function createSlot$2(ownerName) {
|
|
12448
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$2(ownerName);
|
|
12449
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12450
|
+
const { children, ...slotProps } = props;
|
|
12451
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
12452
|
+
const slottable = childrenArray.find(isSlottable$2);
|
|
12453
|
+
if (slottable) {
|
|
12454
|
+
const newElement = slottable.props.children;
|
|
12455
|
+
const newChildren = childrenArray.map((child) => {
|
|
12456
|
+
if (child === slottable) {
|
|
12457
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
12458
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
12459
|
+
} else {
|
|
12460
|
+
return child;
|
|
12461
|
+
}
|
|
12462
|
+
});
|
|
12463
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
12464
|
+
}
|
|
12465
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12466
|
+
});
|
|
12467
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
12468
|
+
return Slot2;
|
|
12469
|
+
}
|
|
12470
|
+
// @__NO_SIDE_EFFECTS__
|
|
12471
|
+
function createSlotClone$2(ownerName) {
|
|
12472
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12473
|
+
const { children, ...slotProps } = props;
|
|
12474
|
+
if (React__namespace.isValidElement(children)) {
|
|
12475
|
+
const childrenRef = getElementRef$2(children);
|
|
12476
|
+
const props2 = mergeProps$2(slotProps, children.props);
|
|
12477
|
+
if (children.type !== React__namespace.Fragment) {
|
|
12478
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12479
|
+
}
|
|
12480
|
+
return React__namespace.cloneElement(children, props2);
|
|
12481
|
+
}
|
|
12482
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
12483
|
+
});
|
|
12484
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12485
|
+
return SlotClone;
|
|
12486
|
+
}
|
|
12487
|
+
var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
|
|
12488
|
+
function isSlottable$2(child) {
|
|
12489
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
|
|
12490
|
+
}
|
|
12491
|
+
function mergeProps$2(slotProps, childProps) {
|
|
12492
|
+
const overrideProps = { ...childProps };
|
|
12493
|
+
for (const propName in childProps) {
|
|
12494
|
+
const slotPropValue = slotProps[propName];
|
|
12495
|
+
const childPropValue = childProps[propName];
|
|
12496
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
12497
|
+
if (isHandler) {
|
|
12498
|
+
if (slotPropValue && childPropValue) {
|
|
12499
|
+
overrideProps[propName] = (...args) => {
|
|
12500
|
+
const result = childPropValue(...args);
|
|
12501
|
+
slotPropValue(...args);
|
|
12502
|
+
return result;
|
|
12503
|
+
};
|
|
12504
|
+
} else if (slotPropValue) {
|
|
12505
|
+
overrideProps[propName] = slotPropValue;
|
|
12506
|
+
}
|
|
12507
|
+
} else if (propName === "style") {
|
|
12508
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12509
|
+
} else if (propName === "className") {
|
|
12510
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12511
|
+
}
|
|
12512
|
+
}
|
|
12513
|
+
return { ...slotProps, ...overrideProps };
|
|
12514
|
+
}
|
|
12515
|
+
function getElementRef$2(element) {
|
|
12516
|
+
var _a2, _b;
|
|
12517
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12518
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12519
|
+
if (mayWarn) {
|
|
12520
|
+
return element.ref;
|
|
12521
|
+
}
|
|
12522
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12523
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12524
|
+
if (mayWarn) {
|
|
12525
|
+
return element.props.ref;
|
|
12526
|
+
}
|
|
12527
|
+
return element.props.ref || element.ref;
|
|
12528
|
+
}
|
|
12070
12529
|
var NODES$2 = [
|
|
12071
12530
|
"a",
|
|
12072
12531
|
"button",
|
|
@@ -12087,7 +12546,7 @@ var NODES$2 = [
|
|
|
12087
12546
|
"ul"
|
|
12088
12547
|
];
|
|
12089
12548
|
var Primitive$2 = NODES$2.reduce((primitive, node) => {
|
|
12090
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12549
|
+
const Slot2 = /* @__PURE__ */ createSlot$2(`Primitive.${node}`);
|
|
12091
12550
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12092
12551
|
const { asChild, ...primitiveProps } = props;
|
|
12093
12552
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -12176,6 +12635,89 @@ function composeContextScopes$1(...scopes) {
|
|
|
12176
12635
|
createScope.scopeName = baseScope.scopeName;
|
|
12177
12636
|
return createScope;
|
|
12178
12637
|
}
|
|
12638
|
+
// @__NO_SIDE_EFFECTS__
|
|
12639
|
+
function createSlot$1(ownerName) {
|
|
12640
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
|
|
12641
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12642
|
+
const { children, ...slotProps } = props;
|
|
12643
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
12644
|
+
const slottable = childrenArray.find(isSlottable$1);
|
|
12645
|
+
if (slottable) {
|
|
12646
|
+
const newElement = slottable.props.children;
|
|
12647
|
+
const newChildren = childrenArray.map((child) => {
|
|
12648
|
+
if (child === slottable) {
|
|
12649
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
12650
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
12651
|
+
} else {
|
|
12652
|
+
return child;
|
|
12653
|
+
}
|
|
12654
|
+
});
|
|
12655
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
12656
|
+
}
|
|
12657
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12658
|
+
});
|
|
12659
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
12660
|
+
return Slot2;
|
|
12661
|
+
}
|
|
12662
|
+
// @__NO_SIDE_EFFECTS__
|
|
12663
|
+
function createSlotClone$1(ownerName) {
|
|
12664
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12665
|
+
const { children, ...slotProps } = props;
|
|
12666
|
+
if (React__namespace.isValidElement(children)) {
|
|
12667
|
+
const childrenRef = getElementRef$1(children);
|
|
12668
|
+
const props2 = mergeProps$1(slotProps, children.props);
|
|
12669
|
+
if (children.type !== React__namespace.Fragment) {
|
|
12670
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12671
|
+
}
|
|
12672
|
+
return React__namespace.cloneElement(children, props2);
|
|
12673
|
+
}
|
|
12674
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
12675
|
+
});
|
|
12676
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12677
|
+
return SlotClone;
|
|
12678
|
+
}
|
|
12679
|
+
var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
|
|
12680
|
+
function isSlottable$1(child) {
|
|
12681
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
|
|
12682
|
+
}
|
|
12683
|
+
function mergeProps$1(slotProps, childProps) {
|
|
12684
|
+
const overrideProps = { ...childProps };
|
|
12685
|
+
for (const propName in childProps) {
|
|
12686
|
+
const slotPropValue = slotProps[propName];
|
|
12687
|
+
const childPropValue = childProps[propName];
|
|
12688
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
12689
|
+
if (isHandler) {
|
|
12690
|
+
if (slotPropValue && childPropValue) {
|
|
12691
|
+
overrideProps[propName] = (...args) => {
|
|
12692
|
+
const result = childPropValue(...args);
|
|
12693
|
+
slotPropValue(...args);
|
|
12694
|
+
return result;
|
|
12695
|
+
};
|
|
12696
|
+
} else if (slotPropValue) {
|
|
12697
|
+
overrideProps[propName] = slotPropValue;
|
|
12698
|
+
}
|
|
12699
|
+
} else if (propName === "style") {
|
|
12700
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12701
|
+
} else if (propName === "className") {
|
|
12702
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12703
|
+
}
|
|
12704
|
+
}
|
|
12705
|
+
return { ...slotProps, ...overrideProps };
|
|
12706
|
+
}
|
|
12707
|
+
function getElementRef$1(element) {
|
|
12708
|
+
var _a2, _b;
|
|
12709
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12710
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12711
|
+
if (mayWarn) {
|
|
12712
|
+
return element.ref;
|
|
12713
|
+
}
|
|
12714
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12715
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12716
|
+
if (mayWarn) {
|
|
12717
|
+
return element.props.ref;
|
|
12718
|
+
}
|
|
12719
|
+
return element.props.ref || element.ref;
|
|
12720
|
+
}
|
|
12179
12721
|
var NODES$1 = [
|
|
12180
12722
|
"a",
|
|
12181
12723
|
"button",
|
|
@@ -12196,7 +12738,7 @@ var NODES$1 = [
|
|
|
12196
12738
|
"ul"
|
|
12197
12739
|
];
|
|
12198
12740
|
var Primitive$1 = NODES$1.reduce((primitive, node) => {
|
|
12199
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12741
|
+
const Slot2 = /* @__PURE__ */ createSlot$1(`Primitive.${node}`);
|
|
12200
12742
|
const Node4 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
12201
12743
|
const { asChild, ...primitiveProps } = props;
|
|
12202
12744
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -12538,6 +13080,98 @@ function composeContextScopes(...scopes) {
|
|
|
12538
13080
|
createScope.scopeName = baseScope.scopeName;
|
|
12539
13081
|
return createScope;
|
|
12540
13082
|
}
|
|
13083
|
+
// @__NO_SIDE_EFFECTS__
|
|
13084
|
+
function createSlot(ownerName) {
|
|
13085
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
13086
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
13087
|
+
const { children, ...slotProps } = props;
|
|
13088
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
13089
|
+
const slottable = childrenArray.find(isSlottable);
|
|
13090
|
+
if (slottable) {
|
|
13091
|
+
const newElement = slottable.props.children;
|
|
13092
|
+
const newChildren = childrenArray.map((child) => {
|
|
13093
|
+
if (child === slottable) {
|
|
13094
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
13095
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
13096
|
+
} else {
|
|
13097
|
+
return child;
|
|
13098
|
+
}
|
|
13099
|
+
});
|
|
13100
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
13101
|
+
}
|
|
13102
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
13103
|
+
});
|
|
13104
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
13105
|
+
return Slot2;
|
|
13106
|
+
}
|
|
13107
|
+
// @__NO_SIDE_EFFECTS__
|
|
13108
|
+
function createSlotClone(ownerName) {
|
|
13109
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
13110
|
+
const { children, ...slotProps } = props;
|
|
13111
|
+
if (React__namespace.isValidElement(children)) {
|
|
13112
|
+
const childrenRef = getElementRef(children);
|
|
13113
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
13114
|
+
if (children.type !== React__namespace.Fragment) {
|
|
13115
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
13116
|
+
}
|
|
13117
|
+
return React__namespace.cloneElement(children, props2);
|
|
13118
|
+
}
|
|
13119
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
13120
|
+
});
|
|
13121
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
13122
|
+
return SlotClone;
|
|
13123
|
+
}
|
|
13124
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
13125
|
+
// @__NO_SIDE_EFFECTS__
|
|
13126
|
+
function createSlottable(ownerName) {
|
|
13127
|
+
const Slottable2 = ({ children }) => {
|
|
13128
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
13129
|
+
};
|
|
13130
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
13131
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
13132
|
+
return Slottable2;
|
|
13133
|
+
}
|
|
13134
|
+
function isSlottable(child) {
|
|
13135
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
13136
|
+
}
|
|
13137
|
+
function mergeProps(slotProps, childProps) {
|
|
13138
|
+
const overrideProps = { ...childProps };
|
|
13139
|
+
for (const propName in childProps) {
|
|
13140
|
+
const slotPropValue = slotProps[propName];
|
|
13141
|
+
const childPropValue = childProps[propName];
|
|
13142
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
13143
|
+
if (isHandler) {
|
|
13144
|
+
if (slotPropValue && childPropValue) {
|
|
13145
|
+
overrideProps[propName] = (...args) => {
|
|
13146
|
+
const result = childPropValue(...args);
|
|
13147
|
+
slotPropValue(...args);
|
|
13148
|
+
return result;
|
|
13149
|
+
};
|
|
13150
|
+
} else if (slotPropValue) {
|
|
13151
|
+
overrideProps[propName] = slotPropValue;
|
|
13152
|
+
}
|
|
13153
|
+
} else if (propName === "style") {
|
|
13154
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
13155
|
+
} else if (propName === "className") {
|
|
13156
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
13157
|
+
}
|
|
13158
|
+
}
|
|
13159
|
+
return { ...slotProps, ...overrideProps };
|
|
13160
|
+
}
|
|
13161
|
+
function getElementRef(element) {
|
|
13162
|
+
var _a2, _b;
|
|
13163
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
13164
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13165
|
+
if (mayWarn) {
|
|
13166
|
+
return element.ref;
|
|
13167
|
+
}
|
|
13168
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
13169
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13170
|
+
if (mayWarn) {
|
|
13171
|
+
return element.props.ref;
|
|
13172
|
+
}
|
|
13173
|
+
return element.props.ref || element.ref;
|
|
13174
|
+
}
|
|
12541
13175
|
var NODES = [
|
|
12542
13176
|
"a",
|
|
12543
13177
|
"button",
|
|
@@ -13518,14 +14152,20 @@ const useAssetPanelStore = create()(
|
|
|
13518
14152
|
const existing = s.tabs.find((t) => t.id === assetId);
|
|
13519
14153
|
if (existing) {
|
|
13520
14154
|
const tabs = meta ? s.tabs.map(
|
|
13521
|
-
(t) => t.id === assetId ? {
|
|
14155
|
+
(t) => t.id === assetId ? {
|
|
14156
|
+
...t,
|
|
14157
|
+
name: meta.name ?? t.name,
|
|
14158
|
+
type: meta.type ?? t.type,
|
|
14159
|
+
slideNumber: meta.slideNumber ?? t.slideNumber
|
|
14160
|
+
} : t
|
|
13522
14161
|
) : s.tabs;
|
|
13523
14162
|
return { isOpen: true, tabs, activeTabId: assetId };
|
|
13524
14163
|
}
|
|
13525
14164
|
const newTab = {
|
|
13526
14165
|
id: assetId,
|
|
13527
14166
|
name: (meta == null ? void 0 : meta.name) ?? null,
|
|
13528
|
-
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
14167
|
+
type: (meta == null ? void 0 : meta.type) ?? "unknown",
|
|
14168
|
+
slideNumber: meta == null ? void 0 : meta.slideNumber
|
|
13529
14169
|
};
|
|
13530
14170
|
return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
|
|
13531
14171
|
}),
|
|
@@ -48926,6 +49566,43 @@ function CollapsibleTrigger({ ...props }) {
|
|
|
48926
49566
|
function CollapsibleContent({ ...props }) {
|
|
48927
49567
|
return /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent$1, { "data-slot": "collapsible-content", ...props });
|
|
48928
49568
|
}
|
|
49569
|
+
const NestedPtcComponentsContext = React.createContext(null);
|
|
49570
|
+
const NestedPtcComponentsProvider = ({ components, children }) => /* @__PURE__ */ jsxRuntime.jsx(NestedPtcComponentsContext.Provider, { value: components, children });
|
|
49571
|
+
const useNestedPtcComponents = (fallback) => {
|
|
49572
|
+
const components = React.useContext(NestedPtcComponentsContext);
|
|
49573
|
+
return React.useMemo(() => {
|
|
49574
|
+
const standardComponents = components && "ChainOfThought" in components && components.ChainOfThought ? void 0 : components;
|
|
49575
|
+
return {
|
|
49576
|
+
...standardComponents ?? {},
|
|
49577
|
+
tools: {
|
|
49578
|
+
...(standardComponents == null ? void 0 : standardComponents.tools) ?? {},
|
|
49579
|
+
Fallback: fallback
|
|
49580
|
+
}
|
|
49581
|
+
};
|
|
49582
|
+
}, [components, fallback]);
|
|
49583
|
+
};
|
|
49584
|
+
const EmptyComponent = () => null;
|
|
49585
|
+
const NestedPtcMessages = ({
|
|
49586
|
+
components,
|
|
49587
|
+
messageClassName
|
|
49588
|
+
}) => {
|
|
49589
|
+
const propsRef = React.useRef({ components, messageClassName });
|
|
49590
|
+
propsRef.current = { components, messageClassName };
|
|
49591
|
+
const messageComponents = React.useMemo(() => {
|
|
49592
|
+
const NestedMessage = () => {
|
|
49593
|
+
const { components: components2, messageClassName: messageClassName2 } = propsRef.current;
|
|
49594
|
+
const parts = /* @__PURE__ */ jsxRuntime.jsx(
|
|
49595
|
+
react$1.MessagePrimitive.Parts,
|
|
49596
|
+
{
|
|
49597
|
+
components: { Empty: EmptyComponent, ...components2 }
|
|
49598
|
+
}
|
|
49599
|
+
);
|
|
49600
|
+
return messageClassName2 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: messageClassName2, children: parts }) : parts;
|
|
49601
|
+
};
|
|
49602
|
+
return { Message: NestedMessage };
|
|
49603
|
+
}, []);
|
|
49604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.MessagePartPrimitive.Messages, { components: messageComponents });
|
|
49605
|
+
};
|
|
48929
49606
|
const ANIMATION_DURATION = 200;
|
|
48930
49607
|
function truncateLine(text2, max2 = 70) {
|
|
48931
49608
|
const oneLine = text2.replace(/\s+/g, " ").trim();
|
|
@@ -49474,16 +50151,20 @@ const ToolFallbackImpl = ({
|
|
|
49474
50151
|
status
|
|
49475
50152
|
}) => {
|
|
49476
50153
|
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
50154
|
+
const nestedComponents = useNestedPtcComponents(ToolFallback);
|
|
49477
50155
|
if (isAssetTool(toolName, result)) {
|
|
49478
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
49479
|
-
|
|
49480
|
-
|
|
49481
|
-
|
|
49482
|
-
|
|
49483
|
-
|
|
49484
|
-
|
|
49485
|
-
|
|
49486
|
-
|
|
50156
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
50157
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
50158
|
+
AssetToolCard,
|
|
50159
|
+
{
|
|
50160
|
+
toolName,
|
|
50161
|
+
argsText,
|
|
50162
|
+
result,
|
|
50163
|
+
status
|
|
50164
|
+
}
|
|
50165
|
+
),
|
|
50166
|
+
/* @__PURE__ */ jsxRuntime.jsx(NestedPtcMessages, { components: nestedComponents })
|
|
50167
|
+
] });
|
|
49487
50168
|
}
|
|
49488
50169
|
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
49489
50170
|
const resultAssetId = extractAssetId$1(result);
|
|
@@ -49508,6 +50189,7 @@ const ToolFallbackImpl = ({
|
|
|
49508
50189
|
}
|
|
49509
50190
|
),
|
|
49510
50191
|
!isCancelled && /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackResult, { result }),
|
|
50192
|
+
/* @__PURE__ */ jsxRuntime.jsx(NestedPtcMessages, { components: nestedComponents }),
|
|
49511
50193
|
!isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end px-3 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(CopyToolSpec, { toolName, argsText, result }) })
|
|
49512
50194
|
] })
|
|
49513
50195
|
]
|
|
@@ -50228,6 +50910,68 @@ function extractAssetId(result) {
|
|
|
50228
50910
|
function resetAssetAutoOpen() {
|
|
50229
50911
|
useAssetPanelStore.getState().resetAutoOpen();
|
|
50230
50912
|
}
|
|
50913
|
+
function getStringField(source, keys2) {
|
|
50914
|
+
if (!source) return null;
|
|
50915
|
+
for (const key of keys2) {
|
|
50916
|
+
const value = source[key];
|
|
50917
|
+
if (typeof value === "string" && value.trim()) {
|
|
50918
|
+
return value;
|
|
50919
|
+
}
|
|
50920
|
+
}
|
|
50921
|
+
return null;
|
|
50922
|
+
}
|
|
50923
|
+
function getNumberField(source, keys2) {
|
|
50924
|
+
if (!source) return null;
|
|
50925
|
+
for (const key of keys2) {
|
|
50926
|
+
const value = source[key];
|
|
50927
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
50928
|
+
return value;
|
|
50929
|
+
}
|
|
50930
|
+
}
|
|
50931
|
+
return null;
|
|
50932
|
+
}
|
|
50933
|
+
function getStudioAssetId({
|
|
50934
|
+
args,
|
|
50935
|
+
result
|
|
50936
|
+
}) {
|
|
50937
|
+
const id = getStringField(result, ["asset_id", "assetId", "id"]) ?? getStringField(args, ["asset_id", "assetId", "id"]);
|
|
50938
|
+
return (id == null ? void 0 : id.startsWith("asset_")) ? id : null;
|
|
50939
|
+
}
|
|
50940
|
+
function getSlideNumber(args) {
|
|
50941
|
+
const explicit = getNumberField(args, ["slideNumber", "slide_number"]);
|
|
50942
|
+
if (explicit != null && Number.isInteger(explicit) && explicit >= 1) {
|
|
50943
|
+
return explicit;
|
|
50944
|
+
}
|
|
50945
|
+
const zeroBasedIndex = getNumberField(args, ["index", "slideIndex", "slide_index"]);
|
|
50946
|
+
if (zeroBasedIndex != null && Number.isInteger(zeroBasedIndex) && zeroBasedIndex >= 0) {
|
|
50947
|
+
return zeroBasedIndex + 1;
|
|
50948
|
+
}
|
|
50949
|
+
return void 0;
|
|
50950
|
+
}
|
|
50951
|
+
const completedStudioToolEffects = /* @__PURE__ */ new Set();
|
|
50952
|
+
const MAX_COMPLETED_STUDIO_TOOL_EFFECTS = 500;
|
|
50953
|
+
function markStudioToolEffect(key) {
|
|
50954
|
+
if (completedStudioToolEffects.has(key)) {
|
|
50955
|
+
return false;
|
|
50956
|
+
}
|
|
50957
|
+
if (completedStudioToolEffects.size >= MAX_COMPLETED_STUDIO_TOOL_EFFECTS) {
|
|
50958
|
+
const oldest = completedStudioToolEffects.values().next().value;
|
|
50959
|
+
if (oldest) completedStudioToolEffects.delete(oldest);
|
|
50960
|
+
}
|
|
50961
|
+
completedStudioToolEffects.add(key);
|
|
50962
|
+
return true;
|
|
50963
|
+
}
|
|
50964
|
+
function dispatchPresentationNavigate(assetId, slideNumber) {
|
|
50965
|
+
const targetSlide = slideNumber;
|
|
50966
|
+
if (typeof targetSlide !== "number" || !Number.isInteger(targetSlide) || targetSlide < 1) {
|
|
50967
|
+
return;
|
|
50968
|
+
}
|
|
50969
|
+
window.dispatchEvent(
|
|
50970
|
+
new CustomEvent("pptx-studio-navigate", {
|
|
50971
|
+
detail: { assetId, slideNumber: targetSlide }
|
|
50972
|
+
})
|
|
50973
|
+
);
|
|
50974
|
+
}
|
|
50231
50975
|
function CreateAssetToolUIImpl({
|
|
50232
50976
|
icon: Icon2,
|
|
50233
50977
|
assetType,
|
|
@@ -50337,6 +51081,238 @@ const CreatePresentationToolUI = React.memo(
|
|
|
50337
51081
|
CreatePresentationToolUIImpl
|
|
50338
51082
|
);
|
|
50339
51083
|
CreatePresentationToolUI.displayName = "CreatePresentationToolUI";
|
|
51084
|
+
function StudioPtcToolUI({
|
|
51085
|
+
config: config2,
|
|
51086
|
+
toolName,
|
|
51087
|
+
toolCallId,
|
|
51088
|
+
args,
|
|
51089
|
+
result,
|
|
51090
|
+
status
|
|
51091
|
+
}) {
|
|
51092
|
+
var _a2, _b;
|
|
51093
|
+
const typedArgs = args;
|
|
51094
|
+
const data = React.useMemo(() => normalizeResult(result), [result]);
|
|
51095
|
+
const slideNumber = (_a2 = config2.getSlideNumber) == null ? void 0 : _a2.call(config2, typedArgs);
|
|
51096
|
+
const assetId = getStudioAssetId({ args: typedArgs, result: data });
|
|
51097
|
+
const subtitle = (_b = config2.getSubtitle) == null ? void 0 : _b.call(config2, typedArgs, data, slideNumber);
|
|
51098
|
+
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
51099
|
+
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
51100
|
+
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
51101
|
+
const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? String(status.error ?? status.reason ?? "Tool failed") : null;
|
|
51102
|
+
const openAsset = useAssetPanelStore((s) => s.openAsset);
|
|
51103
|
+
const handleOpen = React.useCallback(() => {
|
|
51104
|
+
if (!assetId) return;
|
|
51105
|
+
openAsset(assetId, {
|
|
51106
|
+
type: config2.assetType,
|
|
51107
|
+
slideNumber
|
|
51108
|
+
});
|
|
51109
|
+
if (config2.assetType === "presentation") {
|
|
51110
|
+
dispatchPresentationNavigate(assetId, slideNumber);
|
|
51111
|
+
}
|
|
51112
|
+
}, [assetId, config2.assetType, openAsset, slideNumber]);
|
|
51113
|
+
React.useEffect(() => {
|
|
51114
|
+
if (!config2.autoOpen || !isComplete || isCancelled || !assetId) {
|
|
51115
|
+
return;
|
|
51116
|
+
}
|
|
51117
|
+
const effectKey = toolCallId ?? `${toolName ?? "studio-tool"}:${assetId}:${slideNumber ?? "asset"}`;
|
|
51118
|
+
if (!markStudioToolEffect(effectKey)) {
|
|
51119
|
+
return;
|
|
51120
|
+
}
|
|
51121
|
+
const store = useAssetPanelStore.getState();
|
|
51122
|
+
store.openAsset(assetId, {
|
|
51123
|
+
type: config2.assetType,
|
|
51124
|
+
slideNumber
|
|
51125
|
+
});
|
|
51126
|
+
if (config2.assetType === "presentation") {
|
|
51127
|
+
dispatchPresentationNavigate(assetId, slideNumber);
|
|
51128
|
+
}
|
|
51129
|
+
}, [
|
|
51130
|
+
assetId,
|
|
51131
|
+
config2.assetType,
|
|
51132
|
+
config2.autoOpen,
|
|
51133
|
+
isCancelled,
|
|
51134
|
+
isComplete,
|
|
51135
|
+
slideNumber,
|
|
51136
|
+
toolCallId,
|
|
51137
|
+
toolName
|
|
51138
|
+
]);
|
|
51139
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
51140
|
+
ToolCard,
|
|
51141
|
+
{
|
|
51142
|
+
icon: config2.icon,
|
|
51143
|
+
status: (status == null ? void 0 : status.type) ?? "complete",
|
|
51144
|
+
title: isRunning ? config2.runningLabel(typedArgs) : config2.doneLabel(typedArgs, slideNumber),
|
|
51145
|
+
subtitle,
|
|
51146
|
+
badge: config2.badge,
|
|
51147
|
+
toolName,
|
|
51148
|
+
args: typedArgs,
|
|
51149
|
+
result,
|
|
51150
|
+
error: errorMsg,
|
|
51151
|
+
children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
51152
|
+
"button",
|
|
51153
|
+
{
|
|
51154
|
+
type: "button",
|
|
51155
|
+
onClick: handleOpen,
|
|
51156
|
+
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
51157
|
+
children: [
|
|
51158
|
+
/* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3" }),
|
|
51159
|
+
config2.openLabel(slideNumber)
|
|
51160
|
+
]
|
|
51161
|
+
}
|
|
51162
|
+
) })
|
|
51163
|
+
}
|
|
51164
|
+
);
|
|
51165
|
+
}
|
|
51166
|
+
function createStudioPtcToolUI(displayName, config2) {
|
|
51167
|
+
const Component = (props) => /* @__PURE__ */ jsxRuntime.jsx(StudioPtcToolUI, { config: config2, ...props });
|
|
51168
|
+
const Memoized = React.memo(Component);
|
|
51169
|
+
Memoized.displayName = displayName;
|
|
51170
|
+
return Memoized;
|
|
51171
|
+
}
|
|
51172
|
+
const getNameSubtitle = (args, result) => getStringField(result, ["title", "name", "asset_name"]) ?? getStringField(args, ["title", "name"]) ?? void 0;
|
|
51173
|
+
const getParagraphSubtitle = (args) => {
|
|
51174
|
+
const text2 = getStringField(args, ["text"]);
|
|
51175
|
+
return text2 ? truncate(text2, 80) : void 0;
|
|
51176
|
+
};
|
|
51177
|
+
const getSlideSubtitle = (args, _result, slideNumber) => {
|
|
51178
|
+
const layout = getStringField(args, ["layoutName", "layout_name"]) ?? getStringField(args, ["layoutPath", "layout_path"]);
|
|
51179
|
+
const slideLabel = slideNumber ? `Slide ${slideNumber}` : null;
|
|
51180
|
+
if (slideLabel && layout) return `${slideLabel} - ${truncate(layout, 48)}`;
|
|
51181
|
+
return slideLabel ?? (layout ? truncate(layout, 64) : void 0);
|
|
51182
|
+
};
|
|
51183
|
+
const StudioCreateWorkbookToolUI = createStudioPtcToolUI(
|
|
51184
|
+
"StudioCreateWorkbookToolUI",
|
|
51185
|
+
{
|
|
51186
|
+
icon: ChartColumn,
|
|
51187
|
+
assetType: "spreadsheet",
|
|
51188
|
+
badge: "Sheet",
|
|
51189
|
+
runningLabel: (args) => {
|
|
51190
|
+
const title = getStringField(args, ["title", "name"]);
|
|
51191
|
+
return title ? `Creating workbook "${title}"...` : "Creating workbook...";
|
|
51192
|
+
},
|
|
51193
|
+
doneLabel: () => "Workbook created",
|
|
51194
|
+
getSubtitle: getNameSubtitle,
|
|
51195
|
+
openLabel: () => "Open workbook",
|
|
51196
|
+
autoOpen: true
|
|
51197
|
+
}
|
|
51198
|
+
);
|
|
51199
|
+
const StudioAddSheetToolUI = createStudioPtcToolUI(
|
|
51200
|
+
"StudioAddSheetToolUI",
|
|
51201
|
+
{
|
|
51202
|
+
icon: ChartColumn,
|
|
51203
|
+
assetType: "spreadsheet",
|
|
51204
|
+
badge: "Sheet",
|
|
51205
|
+
runningLabel: (args) => {
|
|
51206
|
+
const name = getStringField(args, ["name", "sheetName", "sheet_name"]);
|
|
51207
|
+
return name ? `Adding sheet "${name}"...` : "Adding sheet...";
|
|
51208
|
+
},
|
|
51209
|
+
doneLabel: (args) => {
|
|
51210
|
+
const name = getStringField(args, ["name", "sheetName", "sheet_name"]);
|
|
51211
|
+
return name ? `Sheet added: ${name}` : "Sheet added";
|
|
51212
|
+
},
|
|
51213
|
+
getSubtitle: (args) => getStringField(args, ["name", "sheetName", "sheet_name"]) ?? void 0,
|
|
51214
|
+
openLabel: () => "Open workbook",
|
|
51215
|
+
autoOpen: true
|
|
51216
|
+
}
|
|
51217
|
+
);
|
|
51218
|
+
const StudioOpenWorkbookToolUI = createStudioPtcToolUI(
|
|
51219
|
+
"StudioOpenWorkbookToolUI",
|
|
51220
|
+
{
|
|
51221
|
+
icon: ChartColumn,
|
|
51222
|
+
assetType: "spreadsheet",
|
|
51223
|
+
badge: "Sheet",
|
|
51224
|
+
runningLabel: () => "Opening workbook...",
|
|
51225
|
+
doneLabel: () => "Workbook opened",
|
|
51226
|
+
openLabel: () => "Open workbook",
|
|
51227
|
+
autoOpen: true
|
|
51228
|
+
}
|
|
51229
|
+
);
|
|
51230
|
+
const StudioCreatePresentationToolUI = createStudioPtcToolUI(
|
|
51231
|
+
"StudioCreatePresentationToolUI",
|
|
51232
|
+
{
|
|
51233
|
+
icon: Presentation,
|
|
51234
|
+
assetType: "presentation",
|
|
51235
|
+
badge: "Deck",
|
|
51236
|
+
runningLabel: (args) => {
|
|
51237
|
+
const title = getStringField(args, ["title", "name"]);
|
|
51238
|
+
return title ? `Creating presentation "${title}"...` : "Creating presentation...";
|
|
51239
|
+
},
|
|
51240
|
+
doneLabel: () => "Presentation created",
|
|
51241
|
+
getSubtitle: getNameSubtitle,
|
|
51242
|
+
getSlideNumber: () => 1,
|
|
51243
|
+
openLabel: () => "Open presentation",
|
|
51244
|
+
autoOpen: true
|
|
51245
|
+
}
|
|
51246
|
+
);
|
|
51247
|
+
const StudioOpenPresentationToolUI = createStudioPtcToolUI(
|
|
51248
|
+
"StudioOpenPresentationToolUI",
|
|
51249
|
+
{
|
|
51250
|
+
icon: Presentation,
|
|
51251
|
+
assetType: "presentation",
|
|
51252
|
+
badge: "Deck",
|
|
51253
|
+
runningLabel: () => "Opening presentation...",
|
|
51254
|
+
doneLabel: () => "Presentation opened",
|
|
51255
|
+
getSlideNumber: () => 1,
|
|
51256
|
+
getSubtitle: (_args, _result, slideNumber) => slideNumber ? `Slide ${slideNumber}` : void 0,
|
|
51257
|
+
openLabel: () => "Open presentation",
|
|
51258
|
+
autoOpen: true
|
|
51259
|
+
}
|
|
51260
|
+
);
|
|
51261
|
+
const StudioAddSlideToolUI = createStudioPtcToolUI(
|
|
51262
|
+
"StudioAddSlideToolUI",
|
|
51263
|
+
{
|
|
51264
|
+
icon: Presentation,
|
|
51265
|
+
assetType: "presentation",
|
|
51266
|
+
badge: "Deck",
|
|
51267
|
+
runningLabel: () => "Adding slide...",
|
|
51268
|
+
doneLabel: (_args, slideNumber) => slideNumber ? `Slide ${slideNumber} added` : "Slide added",
|
|
51269
|
+
getSubtitle: getSlideSubtitle,
|
|
51270
|
+
getSlideNumber,
|
|
51271
|
+
openLabel: (slideNumber) => slideNumber ? `Open slide ${slideNumber}` : "Open presentation",
|
|
51272
|
+
autoOpen: true
|
|
51273
|
+
}
|
|
51274
|
+
);
|
|
51275
|
+
const StudioCreateDocumentToolUI = createStudioPtcToolUI(
|
|
51276
|
+
"StudioCreateDocumentToolUI",
|
|
51277
|
+
{
|
|
51278
|
+
icon: FileText,
|
|
51279
|
+
assetType: "document",
|
|
51280
|
+
badge: "Doc",
|
|
51281
|
+
runningLabel: (args) => {
|
|
51282
|
+
const title = getStringField(args, ["title", "name"]);
|
|
51283
|
+
return title ? `Creating document "${title}"...` : "Creating document...";
|
|
51284
|
+
},
|
|
51285
|
+
doneLabel: () => "Document created",
|
|
51286
|
+
getSubtitle: getNameSubtitle,
|
|
51287
|
+
openLabel: () => "Open document",
|
|
51288
|
+
autoOpen: true
|
|
51289
|
+
}
|
|
51290
|
+
);
|
|
51291
|
+
const StudioCreateParagraphToolUI = createStudioPtcToolUI(
|
|
51292
|
+
"StudioCreateParagraphToolUI",
|
|
51293
|
+
{
|
|
51294
|
+
icon: FileText,
|
|
51295
|
+
assetType: "document",
|
|
51296
|
+
badge: "Doc",
|
|
51297
|
+
runningLabel: () => "Adding paragraph...",
|
|
51298
|
+
doneLabel: () => "Paragraph added",
|
|
51299
|
+
getSubtitle: getParagraphSubtitle,
|
|
51300
|
+
openLabel: () => "Open document",
|
|
51301
|
+
autoOpen: true
|
|
51302
|
+
}
|
|
51303
|
+
);
|
|
51304
|
+
const StudioOpenDocumentToolUI = createStudioPtcToolUI(
|
|
51305
|
+
"StudioOpenDocumentToolUI",
|
|
51306
|
+
{
|
|
51307
|
+
icon: FileText,
|
|
51308
|
+
assetType: "document",
|
|
51309
|
+
badge: "Doc",
|
|
51310
|
+
runningLabel: () => "Opening document...",
|
|
51311
|
+
doneLabel: () => "Document opened",
|
|
51312
|
+
openLabel: () => "Open document",
|
|
51313
|
+
autoOpen: true
|
|
51314
|
+
}
|
|
51315
|
+
);
|
|
50340
51316
|
const CreateEmailDraftToolUIImpl = ({
|
|
50341
51317
|
toolName,
|
|
50342
51318
|
args,
|
|
@@ -51780,6 +52756,16 @@ const TOOL_UI_REGISTRY = {
|
|
|
51780
52756
|
create_new_sheet: CreateSheetToolUI,
|
|
51781
52757
|
create_powerpoint_deck: CreatePresentationToolUI,
|
|
51782
52758
|
create_new_notebook: CreateNotebookToolUI,
|
|
52759
|
+
// Studio SDK nested PTC tools
|
|
52760
|
+
CreateWorkbook: StudioCreateWorkbookToolUI,
|
|
52761
|
+
AddSheet: StudioAddSheetToolUI,
|
|
52762
|
+
OpenWorkbook: StudioOpenWorkbookToolUI,
|
|
52763
|
+
CreatePresentation: StudioCreatePresentationToolUI,
|
|
52764
|
+
OpenPresentation: StudioOpenPresentationToolUI,
|
|
52765
|
+
AddSlide: StudioAddSlideToolUI,
|
|
52766
|
+
CreateDocument: StudioCreateDocumentToolUI,
|
|
52767
|
+
OpenDocument: StudioOpenDocumentToolUI,
|
|
52768
|
+
CreateParagraph: StudioCreateParagraphToolUI,
|
|
51783
52769
|
execute_presentation_code: ExecutePresentationCodeToolUI,
|
|
51784
52770
|
run_python_code: RunPythonCodeToolUI,
|
|
51785
52771
|
open_asset_in_workspace: OpenAssetToolUI,
|
|
@@ -52400,14 +53386,14 @@ const useAthenaChatDefaultComponents = () => {
|
|
|
52400
53386
|
return value;
|
|
52401
53387
|
};
|
|
52402
53388
|
const AthenaDefaultAssistantMessage = () => {
|
|
52403
|
-
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent, ActionBarComponent } = useAthenaChatDefaultComponents();
|
|
53389
|
+
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent } = useAthenaChatDefaultComponents();
|
|
52404
53390
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
52405
53391
|
AthenaAssistantMessage,
|
|
52406
53392
|
{
|
|
52407
53393
|
toolUIs,
|
|
52408
53394
|
TextComponent,
|
|
52409
53395
|
ReasoningComponent,
|
|
52410
|
-
EmptyComponent,
|
|
53396
|
+
EmptyComponent: EmptyComponent2,
|
|
52411
53397
|
ActionBarComponent
|
|
52412
53398
|
}
|
|
52413
53399
|
);
|
|
@@ -52432,6 +53418,16 @@ const getReasoningTokensFromMetadata = (metadata) => {
|
|
|
52432
53418
|
return typeof reasoningTokens === "number" && Number.isFinite(reasoningTokens) ? reasoningTokens : void 0;
|
|
52433
53419
|
};
|
|
52434
53420
|
const formatReasoningTokens = (reasoningTokens) => `${reasoningTokens.toLocaleString("en-US")} ${reasoningTokens === 1 ? "token" : "tokens"}`;
|
|
53421
|
+
const withNestedPtcMessages = (ToolUI) => {
|
|
53422
|
+
const ToolUIWithNestedPtcMessages = (props) => {
|
|
53423
|
+
const nestedComponents = useNestedPtcComponents(ToolFallback);
|
|
53424
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53425
|
+
/* @__PURE__ */ jsxRuntime.jsx(ToolUI, { ...props }),
|
|
53426
|
+
/* @__PURE__ */ jsxRuntime.jsx(NestedPtcMessages, { components: nestedComponents })
|
|
53427
|
+
] });
|
|
53428
|
+
};
|
|
53429
|
+
return ToolUIWithNestedPtcMessages;
|
|
53430
|
+
};
|
|
52435
53431
|
const SuggestionCard = ({
|
|
52436
53432
|
suggestion,
|
|
52437
53433
|
index: index2
|
|
@@ -52787,10 +53783,29 @@ const AthenaAssistantMessage = ({
|
|
|
52787
53783
|
toolUIs,
|
|
52788
53784
|
TextComponent = TiptapText,
|
|
52789
53785
|
ReasoningComponent,
|
|
52790
|
-
EmptyComponent = AthenaAssistantMessageEmpty,
|
|
53786
|
+
EmptyComponent: EmptyComponent2 = AthenaAssistantMessageEmpty,
|
|
52791
53787
|
ActionBarComponent = AthenaAssistantActionBar
|
|
52792
53788
|
}) => {
|
|
52793
53789
|
const effectiveReasoningComponent = ReasoningComponent ?? AthenaReasoningPart;
|
|
53790
|
+
const toolUIsWithNestedMessages = React.useMemo(() => {
|
|
53791
|
+
const wrappedToolUIs = {};
|
|
53792
|
+
for (const [toolName, ToolUI] of Object.entries(toolUIs)) {
|
|
53793
|
+
wrappedToolUIs[toolName] = withNestedPtcMessages(ToolUI);
|
|
53794
|
+
}
|
|
53795
|
+
return wrappedToolUIs;
|
|
53796
|
+
}, [toolUIs]);
|
|
53797
|
+
const partsComponents = React.useMemo(
|
|
53798
|
+
() => ({
|
|
53799
|
+
Text: TextComponent,
|
|
53800
|
+
Reasoning: effectiveReasoningComponent,
|
|
53801
|
+
tools: {
|
|
53802
|
+
Fallback: ToolFallback,
|
|
53803
|
+
by_name: toolUIsWithNestedMessages
|
|
53804
|
+
},
|
|
53805
|
+
Empty: EmptyComponent2
|
|
53806
|
+
}),
|
|
53807
|
+
[EmptyComponent2, TextComponent, effectiveReasoningComponent, toolUIsWithNestedMessages]
|
|
53808
|
+
);
|
|
52794
53809
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
52795
53810
|
react$1.MessagePrimitive.Root,
|
|
52796
53811
|
{
|
|
@@ -52798,20 +53813,7 @@ const AthenaAssistantMessage = ({
|
|
|
52798
53813
|
"data-role": "assistant",
|
|
52799
53814
|
children: [
|
|
52800
53815
|
/* @__PURE__ */ jsxRuntime.jsx(AthenaReasoningTextComponentContext.Provider, { value: TextComponent, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aui-assistant-message-content wrap-break-word px-2 text-foreground leading-relaxed", children: [
|
|
52801
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
52802
|
-
react$1.MessagePrimitive.Parts,
|
|
52803
|
-
{
|
|
52804
|
-
components: {
|
|
52805
|
-
Text: TextComponent,
|
|
52806
|
-
Reasoning: effectiveReasoningComponent,
|
|
52807
|
-
tools: {
|
|
52808
|
-
Fallback: ToolFallback,
|
|
52809
|
-
by_name: toolUIs
|
|
52810
|
-
},
|
|
52811
|
-
Empty: EmptyComponent
|
|
52812
|
-
}
|
|
52813
|
-
}
|
|
52814
|
-
),
|
|
53816
|
+
/* @__PURE__ */ jsxRuntime.jsx(NestedPtcComponentsProvider, { components: partsComponents, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.MessagePrimitive.Parts, { components: partsComponents }) }),
|
|
52815
53817
|
/* @__PURE__ */ jsxRuntime.jsx(MessageError, {})
|
|
52816
53818
|
] }) }),
|
|
52817
53819
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-assistant-message-footer mt-1 ml-2 flex", children: /* @__PURE__ */ jsxRuntime.jsx(ActionBarComponent, {}) })
|
|
@@ -52948,6 +53950,26 @@ function useAssetEmbed(assetId, options = {
|
|
|
52948
53950
|
}, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, hasToken]);
|
|
52949
53951
|
return { embedUrl, isLoading, error: error2 };
|
|
52950
53952
|
}
|
|
53953
|
+
const ABSOLUTE_URL_PATTERN = /^[a-zA-Z][a-zA-Z\d+\-.]*:/;
|
|
53954
|
+
function buildAssetIframeSrc({
|
|
53955
|
+
embedUrl,
|
|
53956
|
+
assetType,
|
|
53957
|
+
slideNumber
|
|
53958
|
+
}) {
|
|
53959
|
+
const targetSlide = slideNumber;
|
|
53960
|
+
if (assetType !== "presentation" || typeof targetSlide !== "number" || !Number.isInteger(targetSlide) || targetSlide < 1) {
|
|
53961
|
+
return embedUrl;
|
|
53962
|
+
}
|
|
53963
|
+
try {
|
|
53964
|
+
const isAbsolute = ABSOLUTE_URL_PATTERN.test(embedUrl);
|
|
53965
|
+
const url = new URL(embedUrl, "https://athena.local");
|
|
53966
|
+
url.searchParams.set("slide", String(targetSlide));
|
|
53967
|
+
return isAbsolute ? url.toString() : `${url.pathname}${url.search}${url.hash}`;
|
|
53968
|
+
} catch {
|
|
53969
|
+
const separator = embedUrl.includes("?") ? "&" : "?";
|
|
53970
|
+
return `${embedUrl}${separator}slide=${targetSlide}`;
|
|
53971
|
+
}
|
|
53972
|
+
}
|
|
52951
53973
|
const ASSET_TYPE_CONFIG = {
|
|
52952
53974
|
presentation: { icon: Presentation, label: "Presentation" },
|
|
52953
53975
|
spreadsheet: { icon: FileSpreadsheet, label: "Spreadsheet" },
|
|
@@ -52956,13 +53978,21 @@ const ASSET_TYPE_CONFIG = {
|
|
|
52956
53978
|
unknown: { icon: File$1, label: "Asset" }
|
|
52957
53979
|
};
|
|
52958
53980
|
const AssetIframe = React.memo(
|
|
52959
|
-
({
|
|
53981
|
+
({ tab }) => {
|
|
52960
53982
|
const { backendUrl, apiKey, token } = useAthenaConfig();
|
|
52961
|
-
const { embedUrl, isLoading, error: error2 } = useAssetEmbed(
|
|
53983
|
+
const { embedUrl, isLoading, error: error2 } = useAssetEmbed(tab.id, {
|
|
52962
53984
|
backendUrl,
|
|
52963
53985
|
apiKey,
|
|
52964
53986
|
token
|
|
52965
53987
|
});
|
|
53988
|
+
const iframeSrc = React.useMemo(
|
|
53989
|
+
() => embedUrl ? buildAssetIframeSrc({
|
|
53990
|
+
embedUrl,
|
|
53991
|
+
assetType: tab.type,
|
|
53992
|
+
slideNumber: tab.slideNumber
|
|
53993
|
+
}) : null,
|
|
53994
|
+
[embedUrl, tab.slideNumber, tab.type]
|
|
53995
|
+
);
|
|
52966
53996
|
if (isLoading) {
|
|
52967
53997
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
52968
53998
|
/* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { className: "mx-auto size-6 animate-spin text-muted-foreground" }),
|
|
@@ -52976,16 +54006,16 @@ const AssetIframe = React.memo(
|
|
|
52976
54006
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 line-clamp-2 break-words text-[10px] text-muted-foreground", children: error2 })
|
|
52977
54007
|
] }) });
|
|
52978
54008
|
}
|
|
52979
|
-
if (!
|
|
54009
|
+
if (!iframeSrc) return null;
|
|
52980
54010
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
52981
54011
|
"iframe",
|
|
52982
54012
|
{
|
|
52983
|
-
src:
|
|
54013
|
+
src: iframeSrc,
|
|
52984
54014
|
width: "100%",
|
|
52985
54015
|
height: "100%",
|
|
52986
54016
|
frameBorder: "0",
|
|
52987
54017
|
allow: "fullscreen",
|
|
52988
|
-
title:
|
|
54018
|
+
title: tab.name ?? `Asset ${tab.id}`,
|
|
52989
54019
|
className: "h-full w-full"
|
|
52990
54020
|
}
|
|
52991
54021
|
);
|
|
@@ -53047,7 +54077,7 @@ const PanelContent = ({
|
|
|
53047
54077
|
}
|
|
53048
54078
|
)
|
|
53049
54079
|
] }),
|
|
53050
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, {
|
|
54080
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, { tab }) })
|
|
53051
54081
|
]
|
|
53052
54082
|
},
|
|
53053
54083
|
tab.id
|
|
@@ -53057,7 +54087,7 @@ const PanelContent = ({
|
|
|
53057
54087
|
"div",
|
|
53058
54088
|
{
|
|
53059
54089
|
className: isActive2 ? "h-full w-full" : "hidden",
|
|
53060
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, {
|
|
54090
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, { tab })
|
|
53061
54091
|
},
|
|
53062
54092
|
tab.id
|
|
53063
54093
|
);
|
|
@@ -53318,7 +54348,9 @@ exports.ExpandableSection = ExpandableSection;
|
|
|
53318
54348
|
exports.FileUploadButton = FileUploadButton;
|
|
53319
54349
|
exports.GetDatabaseTableSchemaToolUI = GetDatabaseTableSchemaToolUI;
|
|
53320
54350
|
exports.ListDatabaseTablesToolUI = ListDatabaseTablesToolUI;
|
|
54351
|
+
exports.NestedPtcMessages = NestedPtcMessages;
|
|
53321
54352
|
exports.OpenAssetToolUI = OpenAssetToolUI;
|
|
54353
|
+
exports.PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE = PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE;
|
|
53322
54354
|
exports.ReadAssetToolUI = ReadAssetToolUI;
|
|
53323
54355
|
exports.RunPythonCodeToolUI = RunPythonCodeToolUI;
|
|
53324
54356
|
exports.RunSqlToolUI = RunSqlToolUI;
|
|
@@ -53343,9 +54375,11 @@ exports.TooltipTrigger = TooltipTrigger;
|
|
|
53343
54375
|
exports.UpdateSheetRangeToolUI = UpdateSheetRangeToolUI;
|
|
53344
54376
|
exports.WebSearchToolUI = WebSearchToolUI;
|
|
53345
54377
|
exports.archiveThread = archiveThread;
|
|
54378
|
+
exports.autoCloseInFlightSubgraphMessages = autoCloseInFlightSubgraphMessages;
|
|
53346
54379
|
exports.buttonVariants = buttonVariants;
|
|
53347
54380
|
exports.clearAutoOpenedAssets = clearAutoOpenedAssets;
|
|
53348
54381
|
exports.cn = cn;
|
|
54382
|
+
exports.convertLangChainToThreadMessages = convertLangChainToThreadMessages;
|
|
53349
54383
|
exports.createAssetToolUI = createAssetToolUI;
|
|
53350
54384
|
exports.createThread = createThread;
|
|
53351
54385
|
exports.formatToolName = formatToolName;
|