@athenaintel/react 0.10.25 → 0.10.26
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 +1153 -457
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +1154 -458
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment as Fragment$1, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { bindExternalStoreMessage, getExternalStoreMessages, INTERNAL, useAssistantTransportRuntime, useAuiState, useAssistantRuntime, useThread, useThreadList, unstable_useRemoteThreadListRuntime, Tools, useAui, AssistantRuntimeProvider, useComposerRuntime, useScrollLock, ActionBarPrimitive, AuiIf, ActionBarMorePrimitive,
|
|
2
|
+
import { bindExternalStoreMessage, getExternalStoreMessages, INTERNAL, useAssistantTransportRuntime, useAuiState, useAssistantRuntime, useThread, useThreadList, unstable_useRemoteThreadListRuntime, Tools, useAui, AssistantRuntimeProvider, useComposerRuntime, MessagePartPrimitive, MessagePrimitive, useScrollLock, ActionBarPrimitive, AuiIf, ActionBarMorePrimitive, ThreadPrimitive, ComposerPrimitive, ErrorPrimitive, ThreadListPrimitive, ThreadListItemPrimitive } from "@assistant-ui/react";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import React__default, { useMemo, useState, useRef, useEffect, useLayoutEffect, useContext, createContext, useCallback, useDebugValue, forwardRef, createRef, memo, createElement, version as version$1, useImperativeHandle } from "react";
|
|
5
5
|
import { A as AthenaAuthContext } from "./AthenaAuthContext-DQsdayH2.js";
|
|
@@ -3896,407 +3896,6 @@ function cn(...inputs) {
|
|
|
3896
3896
|
function isRecord(value) {
|
|
3897
3897
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3898
3898
|
}
|
|
3899
|
-
const { fromThreadMessageLike, getAutoStatus } = INTERNAL;
|
|
3900
|
-
const joinExternalMessages = (messages) => {
|
|
3901
|
-
var _a2;
|
|
3902
|
-
const assistantMessage = {
|
|
3903
|
-
role: "assistant",
|
|
3904
|
-
content: []
|
|
3905
|
-
};
|
|
3906
|
-
let firstAssistantId;
|
|
3907
|
-
let lastAssistantId;
|
|
3908
|
-
let assistantMessageCount = 0;
|
|
3909
|
-
for (const output of messages) {
|
|
3910
|
-
if (!output || !("role" in output)) {
|
|
3911
|
-
continue;
|
|
3912
|
-
}
|
|
3913
|
-
if (output.role === "tool") {
|
|
3914
|
-
const toolCallIdx = assistantMessage.content.findIndex(
|
|
3915
|
-
(c) => c.type === "tool-call" && c.toolCallId === output.toolCallId
|
|
3916
|
-
);
|
|
3917
|
-
if (toolCallIdx !== -1) {
|
|
3918
|
-
const toolCall = assistantMessage.content[toolCallIdx];
|
|
3919
|
-
if (output.toolName != null) {
|
|
3920
|
-
if (toolCall.toolName !== output.toolName)
|
|
3921
|
-
console.error(
|
|
3922
|
-
Error(
|
|
3923
|
-
`Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`
|
|
3924
|
-
)
|
|
3925
|
-
);
|
|
3926
|
-
}
|
|
3927
|
-
const { messages: existingMessages, ...toolCallRest } = toolCall;
|
|
3928
|
-
const updatedToolCall = {
|
|
3929
|
-
...toolCallRest,
|
|
3930
|
-
result: output.result,
|
|
3931
|
-
artifact: output.artifact,
|
|
3932
|
-
isError: output.isError,
|
|
3933
|
-
...(output.messages ?? existingMessages) !== void 0 && {
|
|
3934
|
-
messages: output.messages ?? existingMessages
|
|
3935
|
-
}
|
|
3936
|
-
};
|
|
3937
|
-
bindExternalStoreMessage(updatedToolCall, [
|
|
3938
|
-
...getExternalStoreMessages(toolCallRest),
|
|
3939
|
-
output
|
|
3940
|
-
]);
|
|
3941
|
-
assistantMessage.content[toolCallIdx] = updatedToolCall;
|
|
3942
|
-
} else {
|
|
3943
|
-
console.warn(
|
|
3944
|
-
`Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`
|
|
3945
|
-
);
|
|
3946
|
-
}
|
|
3947
|
-
} else {
|
|
3948
|
-
const role = output.role;
|
|
3949
|
-
const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
|
|
3950
|
-
const content = rawContent.flatMap((c) => {
|
|
3951
|
-
if (!c || typeof c !== "object") {
|
|
3952
|
-
return [];
|
|
3953
|
-
}
|
|
3954
|
-
const mapped = { ...c };
|
|
3955
|
-
bindExternalStoreMessage(mapped, output);
|
|
3956
|
-
return [mapped];
|
|
3957
|
-
});
|
|
3958
|
-
switch (role) {
|
|
3959
|
-
case "system":
|
|
3960
|
-
case "user":
|
|
3961
|
-
return {
|
|
3962
|
-
...output,
|
|
3963
|
-
content
|
|
3964
|
-
};
|
|
3965
|
-
case "assistant":
|
|
3966
|
-
if (output.id) {
|
|
3967
|
-
lastAssistantId = output.id;
|
|
3968
|
-
assistantMessageCount++;
|
|
3969
|
-
}
|
|
3970
|
-
if (assistantMessage.content.length === 0) {
|
|
3971
|
-
firstAssistantId = output.id;
|
|
3972
|
-
assistantMessage.createdAt ?? (assistantMessage.createdAt = output.createdAt);
|
|
3973
|
-
assistantMessage.status ?? (assistantMessage.status = output.status);
|
|
3974
|
-
if (output.attachments) {
|
|
3975
|
-
assistantMessage.attachments = [
|
|
3976
|
-
...assistantMessage.attachments ?? [],
|
|
3977
|
-
...output.attachments
|
|
3978
|
-
];
|
|
3979
|
-
}
|
|
3980
|
-
if (output.metadata) {
|
|
3981
|
-
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
3982
|
-
if (output.metadata.unstable_state) {
|
|
3983
|
-
assistantMessage.metadata.unstable_state = output.metadata.unstable_state;
|
|
3984
|
-
}
|
|
3985
|
-
if (output.metadata.unstable_annotations) {
|
|
3986
|
-
assistantMessage.metadata.unstable_annotations = [
|
|
3987
|
-
...assistantMessage.metadata.unstable_annotations ?? [],
|
|
3988
|
-
...output.metadata.unstable_annotations
|
|
3989
|
-
];
|
|
3990
|
-
}
|
|
3991
|
-
if (output.metadata.unstable_data) {
|
|
3992
|
-
assistantMessage.metadata.unstable_data = [
|
|
3993
|
-
...assistantMessage.metadata.unstable_data ?? [],
|
|
3994
|
-
...output.metadata.unstable_data
|
|
3995
|
-
];
|
|
3996
|
-
}
|
|
3997
|
-
if (output.metadata.steps) {
|
|
3998
|
-
assistantMessage.metadata.steps = [
|
|
3999
|
-
...assistantMessage.metadata.steps ?? [],
|
|
4000
|
-
...output.metadata.steps
|
|
4001
|
-
];
|
|
4002
|
-
}
|
|
4003
|
-
if (output.metadata.custom) {
|
|
4004
|
-
assistantMessage.metadata.custom = {
|
|
4005
|
-
...assistantMessage.metadata.custom ?? {},
|
|
4006
|
-
...output.metadata.custom
|
|
4007
|
-
};
|
|
4008
|
-
}
|
|
4009
|
-
if (output.metadata.submittedFeedback) {
|
|
4010
|
-
assistantMessage.metadata.submittedFeedback = output.metadata.submittedFeedback;
|
|
4011
|
-
}
|
|
4012
|
-
}
|
|
4013
|
-
} else {
|
|
4014
|
-
if ((_a2 = output.metadata) == null ? void 0 : _a2.custom) {
|
|
4015
|
-
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
4016
|
-
assistantMessage.metadata.custom = {
|
|
4017
|
-
...assistantMessage.metadata.custom ?? {},
|
|
4018
|
-
...output.metadata.custom
|
|
4019
|
-
};
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
4022
|
-
assistantMessage.content.push(...content);
|
|
4023
|
-
break;
|
|
4024
|
-
default: {
|
|
4025
|
-
const unsupportedRole = role;
|
|
4026
|
-
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
}
|
|
4030
|
-
}
|
|
4031
|
-
assistantMessage.id = lastAssistantId ?? firstAssistantId;
|
|
4032
|
-
if (assistantMessageCount > 1) {
|
|
4033
|
-
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
4034
|
-
assistantMessage.metadata.custom = {
|
|
4035
|
-
...assistantMessage.metadata.custom ?? {},
|
|
4036
|
-
_firstMessageId: firstAssistantId,
|
|
4037
|
-
_lastMessageId: lastAssistantId,
|
|
4038
|
-
_joinedMessageCount: assistantMessageCount
|
|
4039
|
-
};
|
|
4040
|
-
}
|
|
4041
|
-
return assistantMessage;
|
|
4042
|
-
};
|
|
4043
|
-
const chunkExternalMessages = (callbackResults, _joinStrategy) => {
|
|
4044
|
-
var _a2;
|
|
4045
|
-
const results = [];
|
|
4046
|
-
let isAssistant = false;
|
|
4047
|
-
let pendingNone = false;
|
|
4048
|
-
let inputs = [];
|
|
4049
|
-
let outputs = [];
|
|
4050
|
-
const flush2 = () => {
|
|
4051
|
-
if (outputs.length) {
|
|
4052
|
-
results.push({
|
|
4053
|
-
inputs,
|
|
4054
|
-
outputs
|
|
4055
|
-
});
|
|
4056
|
-
}
|
|
4057
|
-
inputs = [];
|
|
4058
|
-
outputs = [];
|
|
4059
|
-
isAssistant = false;
|
|
4060
|
-
pendingNone = false;
|
|
4061
|
-
};
|
|
4062
|
-
for (const callbackResult of callbackResults) {
|
|
4063
|
-
for (const output of callbackResult.outputs) {
|
|
4064
|
-
if (!output || !("role" in output)) {
|
|
4065
|
-
continue;
|
|
4066
|
-
}
|
|
4067
|
-
if (pendingNone && output.role !== "tool" || !isAssistant || output.role === "user" || output.role === "system") {
|
|
4068
|
-
flush2();
|
|
4069
|
-
}
|
|
4070
|
-
isAssistant = output.role === "assistant" || output.role === "tool";
|
|
4071
|
-
if (inputs.at(-1) !== callbackResult.input) {
|
|
4072
|
-
inputs.push(callbackResult.input);
|
|
4073
|
-
}
|
|
4074
|
-
outputs.push(output);
|
|
4075
|
-
if (output.role === "assistant" && (((_a2 = output.convertConfig) == null ? void 0 : _a2.joinStrategy) === "none" || _joinStrategy === "none")) {
|
|
4076
|
-
pendingNone = true;
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
|
-
}
|
|
4080
|
-
flush2();
|
|
4081
|
-
return results;
|
|
4082
|
-
};
|
|
4083
|
-
const convertExternalMessages = (messages, callback, isRunning, metadata) => {
|
|
4084
|
-
const callbackResults = [];
|
|
4085
|
-
for (const message of messages) {
|
|
4086
|
-
const output = callback(message, metadata);
|
|
4087
|
-
const rawOutputs = Array.isArray(output) ? output : [output];
|
|
4088
|
-
const outputs = rawOutputs.filter(
|
|
4089
|
-
(candidate) => candidate != null
|
|
4090
|
-
);
|
|
4091
|
-
if (outputs.length === 0) {
|
|
4092
|
-
continue;
|
|
4093
|
-
}
|
|
4094
|
-
const result = { input: message, outputs };
|
|
4095
|
-
callbackResults.push(result);
|
|
4096
|
-
}
|
|
4097
|
-
const chunks = chunkExternalMessages(callbackResults);
|
|
4098
|
-
return chunks.map((message, idx) => {
|
|
4099
|
-
const isLast = idx === chunks.length - 1;
|
|
4100
|
-
const joined = joinExternalMessages(message.outputs);
|
|
4101
|
-
const hasPendingToolCalls = typeof joined.content === "object" && joined.content.some((c) => c.type === "tool-call" && c.result === void 0);
|
|
4102
|
-
const autoStatus = getAutoStatus(isLast, isRunning, hasPendingToolCalls, hasPendingToolCalls);
|
|
4103
|
-
const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
|
|
4104
|
-
bindExternalStoreMessage(newMessage, message.inputs);
|
|
4105
|
-
return newMessage;
|
|
4106
|
-
});
|
|
4107
|
-
};
|
|
4108
|
-
const warnedMessagePartTypes = /* @__PURE__ */ new Set();
|
|
4109
|
-
const warnForUnknownMessagePartType = (type) => {
|
|
4110
|
-
if (warnedMessagePartTypes.has(type)) return;
|
|
4111
|
-
warnedMessagePartTypes.add(type);
|
|
4112
|
-
console.warn(`Unknown message part type: ${type}`);
|
|
4113
|
-
};
|
|
4114
|
-
const contentToParts = (content) => {
|
|
4115
|
-
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
4116
|
-
return content.flatMap((part) => {
|
|
4117
|
-
if (!part || typeof part !== "object" || !("type" in part)) {
|
|
4118
|
-
return [];
|
|
4119
|
-
}
|
|
4120
|
-
const type = part.type;
|
|
4121
|
-
switch (type) {
|
|
4122
|
-
case "text":
|
|
4123
|
-
return [{ type: "text", text: part.text }];
|
|
4124
|
-
case "text_delta":
|
|
4125
|
-
return [{ type: "text", text: part.text }];
|
|
4126
|
-
case "image_url":
|
|
4127
|
-
if (typeof part.image_url === "string") {
|
|
4128
|
-
return [{ type: "image", image: part.image_url }];
|
|
4129
|
-
}
|
|
4130
|
-
return [{
|
|
4131
|
-
type: "image",
|
|
4132
|
-
image: part.image_url.url
|
|
4133
|
-
}];
|
|
4134
|
-
case "thinking":
|
|
4135
|
-
return [{ type: "reasoning", text: part.thinking }];
|
|
4136
|
-
case "reasoning":
|
|
4137
|
-
return [{
|
|
4138
|
-
type: "reasoning",
|
|
4139
|
-
text: part.summary.map((s) => s.text).join("\n\n\n")
|
|
4140
|
-
}];
|
|
4141
|
-
case "tool_use":
|
|
4142
|
-
return [];
|
|
4143
|
-
case "input_json_delta":
|
|
4144
|
-
return [];
|
|
4145
|
-
default:
|
|
4146
|
-
warnForUnknownMessagePartType(type);
|
|
4147
|
-
return [];
|
|
4148
|
-
}
|
|
4149
|
-
});
|
|
4150
|
-
};
|
|
4151
|
-
const getNumberAtPath = (value, path) => {
|
|
4152
|
-
let current = value;
|
|
4153
|
-
for (const segment of path) {
|
|
4154
|
-
if (!isRecord(current)) {
|
|
4155
|
-
return void 0;
|
|
4156
|
-
}
|
|
4157
|
-
current = current[segment];
|
|
4158
|
-
}
|
|
4159
|
-
return typeof current === "number" && Number.isFinite(current) ? current : void 0;
|
|
4160
|
-
};
|
|
4161
|
-
const extractReasoningTokens = ({
|
|
4162
|
-
usageMetadata,
|
|
4163
|
-
responseMetadata
|
|
4164
|
-
}) => {
|
|
4165
|
-
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"]);
|
|
4166
|
-
return rawReasoningTokens !== void 0 && rawReasoningTokens > 0 ? rawReasoningTokens : void 0;
|
|
4167
|
-
};
|
|
4168
|
-
const buildCustomMetadata = ({
|
|
4169
|
-
additionalKwargs,
|
|
4170
|
-
usageMetadata,
|
|
4171
|
-
responseMetadata
|
|
4172
|
-
}) => {
|
|
4173
|
-
const customMetadata = additionalKwargs ? { ...additionalKwargs } : {};
|
|
4174
|
-
const reasoningTokens = extractReasoningTokens({ usageMetadata, responseMetadata });
|
|
4175
|
-
const existingAthenaMetadata = isRecord(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
4176
|
-
const athenaMetadata = {
|
|
4177
|
-
...existingAthenaMetadata ?? {}
|
|
4178
|
-
};
|
|
4179
|
-
if (usageMetadata) {
|
|
4180
|
-
athenaMetadata.rawUsageMetadata = usageMetadata;
|
|
4181
|
-
}
|
|
4182
|
-
if (responseMetadata) {
|
|
4183
|
-
athenaMetadata.rawResponseMetadata = responseMetadata;
|
|
4184
|
-
}
|
|
4185
|
-
if (reasoningTokens !== void 0) {
|
|
4186
|
-
athenaMetadata.reasoningTokens = reasoningTokens;
|
|
4187
|
-
}
|
|
4188
|
-
if (Object.keys(athenaMetadata).length > 0) {
|
|
4189
|
-
customMetadata._athena = athenaMetadata;
|
|
4190
|
-
}
|
|
4191
|
-
return Object.keys(customMetadata).length > 0 ? customMetadata : void 0;
|
|
4192
|
-
};
|
|
4193
|
-
const convertLangChainMessage = (message) => {
|
|
4194
|
-
var _a2, _b, _c;
|
|
4195
|
-
switch (message.type) {
|
|
4196
|
-
case "system": {
|
|
4197
|
-
const customMetadata = buildCustomMetadata({
|
|
4198
|
-
additionalKwargs: message.additional_kwargs
|
|
4199
|
-
});
|
|
4200
|
-
return {
|
|
4201
|
-
role: "system",
|
|
4202
|
-
id: message.id,
|
|
4203
|
-
content: [{ type: "text", text: message.content }],
|
|
4204
|
-
...customMetadata && {
|
|
4205
|
-
metadata: {
|
|
4206
|
-
custom: customMetadata
|
|
4207
|
-
}
|
|
4208
|
-
}
|
|
4209
|
-
};
|
|
4210
|
-
}
|
|
4211
|
-
case "human": {
|
|
4212
|
-
const customMetadata = buildCustomMetadata({
|
|
4213
|
-
additionalKwargs: message.additional_kwargs
|
|
4214
|
-
});
|
|
4215
|
-
return {
|
|
4216
|
-
role: "user",
|
|
4217
|
-
id: message.id,
|
|
4218
|
-
content: contentToParts(message.content),
|
|
4219
|
-
...customMetadata && {
|
|
4220
|
-
metadata: {
|
|
4221
|
-
custom: customMetadata
|
|
4222
|
-
}
|
|
4223
|
-
}
|
|
4224
|
-
};
|
|
4225
|
-
}
|
|
4226
|
-
case "ai": {
|
|
4227
|
-
const customMetadata = buildCustomMetadata({
|
|
4228
|
-
additionalKwargs: message.additional_kwargs,
|
|
4229
|
-
usageMetadata: message.usage_metadata,
|
|
4230
|
-
responseMetadata: message.response_metadata
|
|
4231
|
-
});
|
|
4232
|
-
const toolCallParts = ((_a2 = message.tool_calls) == null ? void 0 : _a2.map((chunk) => {
|
|
4233
|
-
var _a3, _b2;
|
|
4234
|
-
let argsText;
|
|
4235
|
-
if (typeof chunk.args === "string") {
|
|
4236
|
-
argsText = chunk.args;
|
|
4237
|
-
} else {
|
|
4238
|
-
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);
|
|
4239
|
-
argsText = rawString;
|
|
4240
|
-
}
|
|
4241
|
-
return {
|
|
4242
|
-
type: "tool-call",
|
|
4243
|
-
toolCallId: chunk.id,
|
|
4244
|
-
toolName: chunk.name,
|
|
4245
|
-
args: typeof chunk.args === "string" ? parsePartialJsonObject(argsText) ?? {} : chunk.args,
|
|
4246
|
-
argsText
|
|
4247
|
-
};
|
|
4248
|
-
})) ?? [];
|
|
4249
|
-
const normalizedContent = typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content;
|
|
4250
|
-
const allContent = [
|
|
4251
|
-
(_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
|
|
4252
|
-
...normalizedContent,
|
|
4253
|
-
...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
|
|
4254
|
-
].filter((c) => c != null);
|
|
4255
|
-
return {
|
|
4256
|
-
role: "assistant",
|
|
4257
|
-
id: message.id,
|
|
4258
|
-
content: [...contentToParts(allContent), ...toolCallParts],
|
|
4259
|
-
...message.status && { status: message.status },
|
|
4260
|
-
...customMetadata && {
|
|
4261
|
-
metadata: {
|
|
4262
|
-
custom: customMetadata
|
|
4263
|
-
}
|
|
4264
|
-
}
|
|
4265
|
-
};
|
|
4266
|
-
}
|
|
4267
|
-
case "tool": {
|
|
4268
|
-
return {
|
|
4269
|
-
role: "tool",
|
|
4270
|
-
toolName: message.name,
|
|
4271
|
-
toolCallId: message.tool_call_id,
|
|
4272
|
-
result: message.content,
|
|
4273
|
-
artifact: message.artifact,
|
|
4274
|
-
isError: message.status === "error"
|
|
4275
|
-
};
|
|
4276
|
-
}
|
|
4277
|
-
default:
|
|
4278
|
-
return null;
|
|
4279
|
-
}
|
|
4280
|
-
};
|
|
4281
|
-
const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
|
|
4282
|
-
const validToolCallIds = /* @__PURE__ */ new Set();
|
|
4283
|
-
for (const message of messages) {
|
|
4284
|
-
if (message.type === "ai" && message.tool_calls) {
|
|
4285
|
-
for (const tc of message.tool_calls) {
|
|
4286
|
-
if (tc.id) {
|
|
4287
|
-
validToolCallIds.add(tc.id);
|
|
4288
|
-
}
|
|
4289
|
-
}
|
|
4290
|
-
}
|
|
4291
|
-
}
|
|
4292
|
-
const filteredMessages = messages.filter((message) => {
|
|
4293
|
-
if (message.type === "tool" && message.tool_call_id && !validToolCallIds.has(message.tool_call_id)) {
|
|
4294
|
-
return false;
|
|
4295
|
-
}
|
|
4296
|
-
return true;
|
|
4297
|
-
});
|
|
4298
|
-
return convertExternalMessages(filteredMessages, convertLangChainMessage, isRunning, metadata);
|
|
4299
|
-
};
|
|
4300
3899
|
function $constructor(name, initializer2, params) {
|
|
4301
3900
|
function init2(inst, def) {
|
|
4302
3901
|
if (!inst._zod) {
|
|
@@ -8464,6 +8063,451 @@ const parseLangGraphState = (state) => {
|
|
|
8464
8063
|
}
|
|
8465
8064
|
return result;
|
|
8466
8065
|
};
|
|
8066
|
+
const { fromThreadMessageLike, getAutoStatus } = INTERNAL;
|
|
8067
|
+
const joinExternalMessages = (messages) => {
|
|
8068
|
+
var _a2;
|
|
8069
|
+
const assistantMessage = {
|
|
8070
|
+
role: "assistant",
|
|
8071
|
+
content: []
|
|
8072
|
+
};
|
|
8073
|
+
let firstAssistantId;
|
|
8074
|
+
let lastAssistantId;
|
|
8075
|
+
let assistantMessageCount = 0;
|
|
8076
|
+
for (const output of messages) {
|
|
8077
|
+
if (!output || !("role" in output)) {
|
|
8078
|
+
continue;
|
|
8079
|
+
}
|
|
8080
|
+
if (output.role === "tool") {
|
|
8081
|
+
const toolCallIdx = assistantMessage.content.findIndex(
|
|
8082
|
+
(c) => c.type === "tool-call" && c.toolCallId === output.toolCallId
|
|
8083
|
+
);
|
|
8084
|
+
if (toolCallIdx !== -1) {
|
|
8085
|
+
const toolCall = assistantMessage.content[toolCallIdx];
|
|
8086
|
+
if (output.toolName != null) {
|
|
8087
|
+
if (toolCall.toolName !== output.toolName)
|
|
8088
|
+
console.error(
|
|
8089
|
+
Error(
|
|
8090
|
+
`Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`
|
|
8091
|
+
)
|
|
8092
|
+
);
|
|
8093
|
+
}
|
|
8094
|
+
const { messages: existingMessages, ...toolCallRest } = toolCall;
|
|
8095
|
+
const updatedToolCall = {
|
|
8096
|
+
...toolCallRest,
|
|
8097
|
+
result: output.result,
|
|
8098
|
+
artifact: output.artifact,
|
|
8099
|
+
isError: output.isError,
|
|
8100
|
+
...(output.messages ?? existingMessages) !== void 0 && {
|
|
8101
|
+
messages: output.messages ?? existingMessages
|
|
8102
|
+
}
|
|
8103
|
+
};
|
|
8104
|
+
bindExternalStoreMessage(updatedToolCall, [
|
|
8105
|
+
...getExternalStoreMessages(toolCallRest),
|
|
8106
|
+
output
|
|
8107
|
+
]);
|
|
8108
|
+
assistantMessage.content[toolCallIdx] = updatedToolCall;
|
|
8109
|
+
} else {
|
|
8110
|
+
console.warn(
|
|
8111
|
+
`Tool call ${output.toolCallId} ${output.toolName} not found in assistant message`
|
|
8112
|
+
);
|
|
8113
|
+
}
|
|
8114
|
+
} else {
|
|
8115
|
+
const role = output.role;
|
|
8116
|
+
const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
|
|
8117
|
+
const content = rawContent.flatMap((c) => {
|
|
8118
|
+
if (!c || typeof c !== "object") {
|
|
8119
|
+
return [];
|
|
8120
|
+
}
|
|
8121
|
+
const mapped = { ...c };
|
|
8122
|
+
bindExternalStoreMessage(mapped, output);
|
|
8123
|
+
return [mapped];
|
|
8124
|
+
});
|
|
8125
|
+
switch (role) {
|
|
8126
|
+
case "system":
|
|
8127
|
+
case "user":
|
|
8128
|
+
return {
|
|
8129
|
+
...output,
|
|
8130
|
+
content
|
|
8131
|
+
};
|
|
8132
|
+
case "assistant":
|
|
8133
|
+
if (output.id) {
|
|
8134
|
+
lastAssistantId = output.id;
|
|
8135
|
+
assistantMessageCount++;
|
|
8136
|
+
}
|
|
8137
|
+
if (assistantMessage.content.length === 0) {
|
|
8138
|
+
firstAssistantId = output.id;
|
|
8139
|
+
assistantMessage.createdAt ?? (assistantMessage.createdAt = output.createdAt);
|
|
8140
|
+
assistantMessage.status ?? (assistantMessage.status = output.status);
|
|
8141
|
+
if (output.attachments) {
|
|
8142
|
+
assistantMessage.attachments = [
|
|
8143
|
+
...assistantMessage.attachments ?? [],
|
|
8144
|
+
...output.attachments
|
|
8145
|
+
];
|
|
8146
|
+
}
|
|
8147
|
+
if (output.metadata) {
|
|
8148
|
+
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
8149
|
+
if (output.metadata.unstable_state) {
|
|
8150
|
+
assistantMessage.metadata.unstable_state = output.metadata.unstable_state;
|
|
8151
|
+
}
|
|
8152
|
+
if (output.metadata.unstable_annotations) {
|
|
8153
|
+
assistantMessage.metadata.unstable_annotations = [
|
|
8154
|
+
...assistantMessage.metadata.unstable_annotations ?? [],
|
|
8155
|
+
...output.metadata.unstable_annotations
|
|
8156
|
+
];
|
|
8157
|
+
}
|
|
8158
|
+
if (output.metadata.unstable_data) {
|
|
8159
|
+
assistantMessage.metadata.unstable_data = [
|
|
8160
|
+
...assistantMessage.metadata.unstable_data ?? [],
|
|
8161
|
+
...output.metadata.unstable_data
|
|
8162
|
+
];
|
|
8163
|
+
}
|
|
8164
|
+
if (output.metadata.steps) {
|
|
8165
|
+
assistantMessage.metadata.steps = [
|
|
8166
|
+
...assistantMessage.metadata.steps ?? [],
|
|
8167
|
+
...output.metadata.steps
|
|
8168
|
+
];
|
|
8169
|
+
}
|
|
8170
|
+
if (output.metadata.custom) {
|
|
8171
|
+
assistantMessage.metadata.custom = {
|
|
8172
|
+
...assistantMessage.metadata.custom ?? {},
|
|
8173
|
+
...output.metadata.custom
|
|
8174
|
+
};
|
|
8175
|
+
}
|
|
8176
|
+
if (output.metadata.submittedFeedback) {
|
|
8177
|
+
assistantMessage.metadata.submittedFeedback = output.metadata.submittedFeedback;
|
|
8178
|
+
}
|
|
8179
|
+
}
|
|
8180
|
+
} else {
|
|
8181
|
+
if ((_a2 = output.metadata) == null ? void 0 : _a2.custom) {
|
|
8182
|
+
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
8183
|
+
assistantMessage.metadata.custom = {
|
|
8184
|
+
...assistantMessage.metadata.custom ?? {},
|
|
8185
|
+
...output.metadata.custom
|
|
8186
|
+
};
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8189
|
+
assistantMessage.content.push(...content);
|
|
8190
|
+
break;
|
|
8191
|
+
default: {
|
|
8192
|
+
const unsupportedRole = role;
|
|
8193
|
+
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
|
8194
|
+
}
|
|
8195
|
+
}
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
assistantMessage.id = lastAssistantId ?? firstAssistantId;
|
|
8199
|
+
if (assistantMessageCount > 1) {
|
|
8200
|
+
assistantMessage.metadata ?? (assistantMessage.metadata = {});
|
|
8201
|
+
assistantMessage.metadata.custom = {
|
|
8202
|
+
...assistantMessage.metadata.custom ?? {},
|
|
8203
|
+
_firstMessageId: firstAssistantId,
|
|
8204
|
+
_lastMessageId: lastAssistantId,
|
|
8205
|
+
_joinedMessageCount: assistantMessageCount
|
|
8206
|
+
};
|
|
8207
|
+
}
|
|
8208
|
+
return assistantMessage;
|
|
8209
|
+
};
|
|
8210
|
+
const chunkExternalMessages = (callbackResults, _joinStrategy) => {
|
|
8211
|
+
var _a2;
|
|
8212
|
+
const results = [];
|
|
8213
|
+
let isAssistant = false;
|
|
8214
|
+
let pendingNone = false;
|
|
8215
|
+
let inputs = [];
|
|
8216
|
+
let outputs = [];
|
|
8217
|
+
const flush2 = () => {
|
|
8218
|
+
if (outputs.length) {
|
|
8219
|
+
results.push({
|
|
8220
|
+
inputs,
|
|
8221
|
+
outputs
|
|
8222
|
+
});
|
|
8223
|
+
}
|
|
8224
|
+
inputs = [];
|
|
8225
|
+
outputs = [];
|
|
8226
|
+
isAssistant = false;
|
|
8227
|
+
pendingNone = false;
|
|
8228
|
+
};
|
|
8229
|
+
for (const callbackResult of callbackResults) {
|
|
8230
|
+
for (const output of callbackResult.outputs) {
|
|
8231
|
+
if (!output || !("role" in output)) {
|
|
8232
|
+
continue;
|
|
8233
|
+
}
|
|
8234
|
+
if (pendingNone && output.role !== "tool" || !isAssistant || output.role === "user" || output.role === "system") {
|
|
8235
|
+
flush2();
|
|
8236
|
+
}
|
|
8237
|
+
isAssistant = output.role === "assistant" || output.role === "tool";
|
|
8238
|
+
if (inputs.at(-1) !== callbackResult.input) {
|
|
8239
|
+
inputs.push(callbackResult.input);
|
|
8240
|
+
}
|
|
8241
|
+
outputs.push(output);
|
|
8242
|
+
if (output.role === "assistant" && (((_a2 = output.convertConfig) == null ? void 0 : _a2.joinStrategy) === "none" || _joinStrategy === "none")) {
|
|
8243
|
+
pendingNone = true;
|
|
8244
|
+
}
|
|
8245
|
+
}
|
|
8246
|
+
}
|
|
8247
|
+
flush2();
|
|
8248
|
+
return results;
|
|
8249
|
+
};
|
|
8250
|
+
const convertExternalMessages = (messages, callback, isRunning, metadata) => {
|
|
8251
|
+
const callbackResults = [];
|
|
8252
|
+
for (const message of messages) {
|
|
8253
|
+
const output = callback(message, metadata);
|
|
8254
|
+
const rawOutputs = Array.isArray(output) ? output : [output];
|
|
8255
|
+
const outputs = rawOutputs.filter(
|
|
8256
|
+
(candidate) => candidate != null
|
|
8257
|
+
);
|
|
8258
|
+
if (outputs.length === 0) {
|
|
8259
|
+
continue;
|
|
8260
|
+
}
|
|
8261
|
+
const result = { input: message, outputs };
|
|
8262
|
+
callbackResults.push(result);
|
|
8263
|
+
}
|
|
8264
|
+
const chunks = chunkExternalMessages(callbackResults);
|
|
8265
|
+
return chunks.map((message, idx) => {
|
|
8266
|
+
const isLast = idx === chunks.length - 1;
|
|
8267
|
+
const joined = joinExternalMessages(message.outputs);
|
|
8268
|
+
const hasPendingToolCalls = typeof joined.content === "object" && joined.content.some((c) => c.type === "tool-call" && c.result === void 0);
|
|
8269
|
+
const autoStatus = getAutoStatus(isLast, isRunning, hasPendingToolCalls, hasPendingToolCalls);
|
|
8270
|
+
const newMessage = fromThreadMessageLike(joined, idx.toString(), autoStatus);
|
|
8271
|
+
bindExternalStoreMessage(newMessage, message.inputs);
|
|
8272
|
+
return newMessage;
|
|
8273
|
+
});
|
|
8274
|
+
};
|
|
8275
|
+
const PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE = "Sub-call did not complete before the parent tool returned.";
|
|
8276
|
+
const autoCloseInFlightSubgraphMessages = (msgs) => {
|
|
8277
|
+
const beginIds = /* @__PURE__ */ new Set();
|
|
8278
|
+
const endIds = /* @__PURE__ */ new Set();
|
|
8279
|
+
for (const message of msgs) {
|
|
8280
|
+
if (!isRecord(message)) continue;
|
|
8281
|
+
if (message.type === "ai" && Array.isArray(message.tool_calls)) {
|
|
8282
|
+
for (const toolCall of message.tool_calls) {
|
|
8283
|
+
if (!isRecord(toolCall)) continue;
|
|
8284
|
+
const id = toolCall.id;
|
|
8285
|
+
if (typeof id === "string") beginIds.add(id);
|
|
8286
|
+
}
|
|
8287
|
+
} else if (message.type === "tool" && typeof message.tool_call_id === "string") {
|
|
8288
|
+
endIds.add(message.tool_call_id);
|
|
8289
|
+
}
|
|
8290
|
+
}
|
|
8291
|
+
const unmatchedIds = [...beginIds].filter((id) => !endIds.has(id));
|
|
8292
|
+
if (unmatchedIds.length === 0) return [...msgs];
|
|
8293
|
+
return [
|
|
8294
|
+
...msgs,
|
|
8295
|
+
...unmatchedIds.map((toolCallId) => ({
|
|
8296
|
+
type: "tool",
|
|
8297
|
+
tool_call_id: toolCallId,
|
|
8298
|
+
content: PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE,
|
|
8299
|
+
status: "error"
|
|
8300
|
+
}))
|
|
8301
|
+
];
|
|
8302
|
+
};
|
|
8303
|
+
const warnedMessagePartTypes = /* @__PURE__ */ new Set();
|
|
8304
|
+
const warnForUnknownMessagePartType = (type) => {
|
|
8305
|
+
if (warnedMessagePartTypes.has(type)) return;
|
|
8306
|
+
warnedMessagePartTypes.add(type);
|
|
8307
|
+
console.warn(`Unknown message part type: ${type}`);
|
|
8308
|
+
};
|
|
8309
|
+
const contentToParts = (content) => {
|
|
8310
|
+
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
8311
|
+
return content.flatMap((part) => {
|
|
8312
|
+
if (!part || typeof part !== "object" || !("type" in part)) {
|
|
8313
|
+
return [];
|
|
8314
|
+
}
|
|
8315
|
+
const type = part.type;
|
|
8316
|
+
switch (type) {
|
|
8317
|
+
case "text":
|
|
8318
|
+
return [{ type: "text", text: part.text }];
|
|
8319
|
+
case "text_delta":
|
|
8320
|
+
return [{ type: "text", text: part.text }];
|
|
8321
|
+
case "image_url":
|
|
8322
|
+
if (typeof part.image_url === "string") {
|
|
8323
|
+
return [{ type: "image", image: part.image_url }];
|
|
8324
|
+
}
|
|
8325
|
+
return [{
|
|
8326
|
+
type: "image",
|
|
8327
|
+
image: part.image_url.url
|
|
8328
|
+
}];
|
|
8329
|
+
case "thinking":
|
|
8330
|
+
return [{ type: "reasoning", text: part.thinking }];
|
|
8331
|
+
case "reasoning":
|
|
8332
|
+
return [{
|
|
8333
|
+
type: "reasoning",
|
|
8334
|
+
text: part.summary.map((s) => s.text).join("\n\n\n")
|
|
8335
|
+
}];
|
|
8336
|
+
case "tool_use":
|
|
8337
|
+
return [];
|
|
8338
|
+
case "input_json_delta":
|
|
8339
|
+
return [];
|
|
8340
|
+
default:
|
|
8341
|
+
warnForUnknownMessagePartType(type);
|
|
8342
|
+
return [];
|
|
8343
|
+
}
|
|
8344
|
+
});
|
|
8345
|
+
};
|
|
8346
|
+
const getNumberAtPath = (value, path) => {
|
|
8347
|
+
let current = value;
|
|
8348
|
+
for (const segment of path) {
|
|
8349
|
+
if (!isRecord(current)) {
|
|
8350
|
+
return void 0;
|
|
8351
|
+
}
|
|
8352
|
+
current = current[segment];
|
|
8353
|
+
}
|
|
8354
|
+
return typeof current === "number" && Number.isFinite(current) ? current : void 0;
|
|
8355
|
+
};
|
|
8356
|
+
const extractReasoningTokens = ({
|
|
8357
|
+
usageMetadata,
|
|
8358
|
+
responseMetadata
|
|
8359
|
+
}) => {
|
|
8360
|
+
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"]);
|
|
8361
|
+
return rawReasoningTokens !== void 0 && rawReasoningTokens > 0 ? rawReasoningTokens : void 0;
|
|
8362
|
+
};
|
|
8363
|
+
const buildCustomMetadata = ({
|
|
8364
|
+
additionalKwargs,
|
|
8365
|
+
usageMetadata,
|
|
8366
|
+
responseMetadata
|
|
8367
|
+
}) => {
|
|
8368
|
+
const customMetadata = additionalKwargs ? { ...additionalKwargs } : {};
|
|
8369
|
+
const reasoningTokens = extractReasoningTokens({ usageMetadata, responseMetadata });
|
|
8370
|
+
const existingAthenaMetadata = isRecord(customMetadata._athena) ? customMetadata._athena : void 0;
|
|
8371
|
+
const athenaMetadata = {
|
|
8372
|
+
...existingAthenaMetadata ?? {}
|
|
8373
|
+
};
|
|
8374
|
+
if (usageMetadata) {
|
|
8375
|
+
athenaMetadata.rawUsageMetadata = usageMetadata;
|
|
8376
|
+
}
|
|
8377
|
+
if (responseMetadata) {
|
|
8378
|
+
athenaMetadata.rawResponseMetadata = responseMetadata;
|
|
8379
|
+
}
|
|
8380
|
+
if (reasoningTokens !== void 0) {
|
|
8381
|
+
athenaMetadata.reasoningTokens = reasoningTokens;
|
|
8382
|
+
}
|
|
8383
|
+
if (Object.keys(athenaMetadata).length > 0) {
|
|
8384
|
+
customMetadata._athena = athenaMetadata;
|
|
8385
|
+
}
|
|
8386
|
+
return Object.keys(customMetadata).length > 0 ? customMetadata : void 0;
|
|
8387
|
+
};
|
|
8388
|
+
const getSubgraphMessages = (artifact) => {
|
|
8389
|
+
if (!isRecord(artifact)) return void 0;
|
|
8390
|
+
const subgraphState = artifact.subgraph_state;
|
|
8391
|
+
if (!isRecord(subgraphState)) return void 0;
|
|
8392
|
+
const messages = subgraphState.messages;
|
|
8393
|
+
return Array.isArray(messages) && messages.length > 0 ? messages : void 0;
|
|
8394
|
+
};
|
|
8395
|
+
const convertLangChainMessage = (message) => {
|
|
8396
|
+
var _a2, _b, _c;
|
|
8397
|
+
switch (message.type) {
|
|
8398
|
+
case "system": {
|
|
8399
|
+
const customMetadata = buildCustomMetadata({
|
|
8400
|
+
additionalKwargs: message.additional_kwargs
|
|
8401
|
+
});
|
|
8402
|
+
return {
|
|
8403
|
+
role: "system",
|
|
8404
|
+
id: message.id,
|
|
8405
|
+
content: [{ type: "text", text: message.content }],
|
|
8406
|
+
...customMetadata && {
|
|
8407
|
+
metadata: {
|
|
8408
|
+
custom: customMetadata
|
|
8409
|
+
}
|
|
8410
|
+
}
|
|
8411
|
+
};
|
|
8412
|
+
}
|
|
8413
|
+
case "human": {
|
|
8414
|
+
const customMetadata = buildCustomMetadata({
|
|
8415
|
+
additionalKwargs: message.additional_kwargs
|
|
8416
|
+
});
|
|
8417
|
+
return {
|
|
8418
|
+
role: "user",
|
|
8419
|
+
id: message.id,
|
|
8420
|
+
content: contentToParts(message.content),
|
|
8421
|
+
...customMetadata && {
|
|
8422
|
+
metadata: {
|
|
8423
|
+
custom: customMetadata
|
|
8424
|
+
}
|
|
8425
|
+
}
|
|
8426
|
+
};
|
|
8427
|
+
}
|
|
8428
|
+
case "ai": {
|
|
8429
|
+
const customMetadata = buildCustomMetadata({
|
|
8430
|
+
additionalKwargs: message.additional_kwargs,
|
|
8431
|
+
usageMetadata: message.usage_metadata,
|
|
8432
|
+
responseMetadata: message.response_metadata
|
|
8433
|
+
});
|
|
8434
|
+
const toolCallParts = ((_a2 = message.tool_calls) == null ? void 0 : _a2.map((chunk) => {
|
|
8435
|
+
var _a3, _b2;
|
|
8436
|
+
let argsText;
|
|
8437
|
+
if (typeof chunk.args === "string") {
|
|
8438
|
+
argsText = chunk.args;
|
|
8439
|
+
} else {
|
|
8440
|
+
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);
|
|
8441
|
+
argsText = rawString;
|
|
8442
|
+
}
|
|
8443
|
+
return {
|
|
8444
|
+
type: "tool-call",
|
|
8445
|
+
toolCallId: chunk.id,
|
|
8446
|
+
toolName: chunk.name,
|
|
8447
|
+
args: typeof chunk.args === "string" ? parsePartialJsonObject(argsText) ?? {} : chunk.args,
|
|
8448
|
+
argsText
|
|
8449
|
+
};
|
|
8450
|
+
})) ?? [];
|
|
8451
|
+
const normalizedContent = typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content;
|
|
8452
|
+
const allContent = [
|
|
8453
|
+
(_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
|
|
8454
|
+
...normalizedContent,
|
|
8455
|
+
...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
|
|
8456
|
+
].filter((c) => c != null);
|
|
8457
|
+
return {
|
|
8458
|
+
role: "assistant",
|
|
8459
|
+
id: message.id,
|
|
8460
|
+
content: [...contentToParts(allContent), ...toolCallParts],
|
|
8461
|
+
...message.status && { status: message.status },
|
|
8462
|
+
...customMetadata && {
|
|
8463
|
+
metadata: {
|
|
8464
|
+
custom: customMetadata
|
|
8465
|
+
}
|
|
8466
|
+
}
|
|
8467
|
+
};
|
|
8468
|
+
}
|
|
8469
|
+
case "tool": {
|
|
8470
|
+
const subgraphMessages = getSubgraphMessages(message.artifact);
|
|
8471
|
+
const parentEnded = message.content !== void 0 && message.content !== null;
|
|
8472
|
+
const nestedMessages = subgraphMessages !== void 0 ? convertLangChainToThreadMessages(
|
|
8473
|
+
parseMessages(
|
|
8474
|
+
parentEnded ? autoCloseInFlightSubgraphMessages(subgraphMessages) : subgraphMessages
|
|
8475
|
+
),
|
|
8476
|
+
!parentEnded
|
|
8477
|
+
) : void 0;
|
|
8478
|
+
return {
|
|
8479
|
+
role: "tool",
|
|
8480
|
+
toolName: message.name,
|
|
8481
|
+
toolCallId: message.tool_call_id,
|
|
8482
|
+
result: message.content,
|
|
8483
|
+
artifact: message.artifact,
|
|
8484
|
+
isError: message.status === "error",
|
|
8485
|
+
...nestedMessages !== void 0 && { messages: nestedMessages }
|
|
8486
|
+
};
|
|
8487
|
+
}
|
|
8488
|
+
default:
|
|
8489
|
+
return null;
|
|
8490
|
+
}
|
|
8491
|
+
};
|
|
8492
|
+
const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
|
|
8493
|
+
const validToolCallIds = /* @__PURE__ */ new Set();
|
|
8494
|
+
for (const message of messages) {
|
|
8495
|
+
if (message.type === "ai" && message.tool_calls) {
|
|
8496
|
+
for (const tc of message.tool_calls) {
|
|
8497
|
+
if (tc.id) {
|
|
8498
|
+
validToolCallIds.add(tc.id);
|
|
8499
|
+
}
|
|
8500
|
+
}
|
|
8501
|
+
}
|
|
8502
|
+
}
|
|
8503
|
+
const filteredMessages = messages.filter((message) => {
|
|
8504
|
+
if (message.type === "tool" && message.tool_call_id && !validToolCallIds.has(message.tool_call_id)) {
|
|
8505
|
+
return false;
|
|
8506
|
+
}
|
|
8507
|
+
return true;
|
|
8508
|
+
});
|
|
8509
|
+
return convertExternalMessages(filteredMessages, convertLangChainMessage, isRunning, metadata);
|
|
8510
|
+
};
|
|
8467
8511
|
function getAuthHeaders(auth) {
|
|
8468
8512
|
if (auth.token) {
|
|
8469
8513
|
return { Authorization: `Bearer ${auth.token}` };
|
|
@@ -9053,12 +9097,12 @@ function useComposedRefs(...refs) {
|
|
|
9053
9097
|
return React.useCallback(composeRefs(...refs), refs);
|
|
9054
9098
|
}
|
|
9055
9099
|
// @__NO_SIDE_EFFECTS__
|
|
9056
|
-
function createSlot(ownerName) {
|
|
9057
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
9100
|
+
function createSlot$7(ownerName) {
|
|
9101
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$7(ownerName);
|
|
9058
9102
|
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
9059
9103
|
const { children, ...slotProps } = props;
|
|
9060
9104
|
const childrenArray = React.Children.toArray(children);
|
|
9061
|
-
const slottable = childrenArray.find(isSlottable);
|
|
9105
|
+
const slottable = childrenArray.find(isSlottable$7);
|
|
9062
9106
|
if (slottable) {
|
|
9063
9107
|
const newElement = slottable.props.children;
|
|
9064
9108
|
const newChildren = childrenArray.map((child) => {
|
|
@@ -9076,14 +9120,13 @@ function createSlot(ownerName) {
|
|
|
9076
9120
|
Slot2.displayName = `${ownerName}.Slot`;
|
|
9077
9121
|
return Slot2;
|
|
9078
9122
|
}
|
|
9079
|
-
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
9080
9123
|
// @__NO_SIDE_EFFECTS__
|
|
9081
|
-
function createSlotClone(ownerName) {
|
|
9124
|
+
function createSlotClone$7(ownerName) {
|
|
9082
9125
|
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
9083
9126
|
const { children, ...slotProps } = props;
|
|
9084
9127
|
if (React.isValidElement(children)) {
|
|
9085
|
-
const childrenRef = getElementRef$
|
|
9086
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
9128
|
+
const childrenRef = getElementRef$8(children);
|
|
9129
|
+
const props2 = mergeProps$7(slotProps, children.props);
|
|
9087
9130
|
if (children.type !== React.Fragment) {
|
|
9088
9131
|
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9089
9132
|
}
|
|
@@ -9094,21 +9137,11 @@ function createSlotClone(ownerName) {
|
|
|
9094
9137
|
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9095
9138
|
return SlotClone;
|
|
9096
9139
|
}
|
|
9097
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
const Slottable2 = ({ children }) => {
|
|
9101
|
-
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
9102
|
-
};
|
|
9103
|
-
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
9104
|
-
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
9105
|
-
return Slottable2;
|
|
9106
|
-
}
|
|
9107
|
-
var Slottable$1 = /* @__PURE__ */ createSlottable("Slottable");
|
|
9108
|
-
function isSlottable(child) {
|
|
9109
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
9140
|
+
var SLOTTABLE_IDENTIFIER$7 = Symbol("radix.slottable");
|
|
9141
|
+
function isSlottable$7(child) {
|
|
9142
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$7;
|
|
9110
9143
|
}
|
|
9111
|
-
function mergeProps(slotProps, childProps) {
|
|
9144
|
+
function mergeProps$7(slotProps, childProps) {
|
|
9112
9145
|
const overrideProps = { ...childProps };
|
|
9113
9146
|
for (const propName in childProps) {
|
|
9114
9147
|
const slotPropValue = slotProps[propName];
|
|
@@ -9132,7 +9165,7 @@ function mergeProps(slotProps, childProps) {
|
|
|
9132
9165
|
}
|
|
9133
9166
|
return { ...slotProps, ...overrideProps };
|
|
9134
9167
|
}
|
|
9135
|
-
function getElementRef$
|
|
9168
|
+
function getElementRef$8(element) {
|
|
9136
9169
|
var _a2, _b;
|
|
9137
9170
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9138
9171
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9166,7 +9199,7 @@ var NODES$6 = [
|
|
|
9166
9199
|
"ul"
|
|
9167
9200
|
];
|
|
9168
9201
|
var Primitive$6 = NODES$6.reduce((primitive, node) => {
|
|
9169
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9202
|
+
const Slot2 = /* @__PURE__ */ createSlot$7(`Primitive.${node}`);
|
|
9170
9203
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9171
9204
|
const { asChild, ...primitiveProps } = props;
|
|
9172
9205
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9341,6 +9374,89 @@ function composeContextScopes$2(...scopes) {
|
|
|
9341
9374
|
createScope.scopeName = baseScope.scopeName;
|
|
9342
9375
|
return createScope;
|
|
9343
9376
|
}
|
|
9377
|
+
// @__NO_SIDE_EFFECTS__
|
|
9378
|
+
function createSlot$6(ownerName) {
|
|
9379
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$6(ownerName);
|
|
9380
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
9381
|
+
const { children, ...slotProps } = props;
|
|
9382
|
+
const childrenArray = React.Children.toArray(children);
|
|
9383
|
+
const slottable = childrenArray.find(isSlottable$6);
|
|
9384
|
+
if (slottable) {
|
|
9385
|
+
const newElement = slottable.props.children;
|
|
9386
|
+
const newChildren = childrenArray.map((child) => {
|
|
9387
|
+
if (child === slottable) {
|
|
9388
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
9389
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
9390
|
+
} else {
|
|
9391
|
+
return child;
|
|
9392
|
+
}
|
|
9393
|
+
});
|
|
9394
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
9395
|
+
}
|
|
9396
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9397
|
+
});
|
|
9398
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
9399
|
+
return Slot2;
|
|
9400
|
+
}
|
|
9401
|
+
// @__NO_SIDE_EFFECTS__
|
|
9402
|
+
function createSlotClone$6(ownerName) {
|
|
9403
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
9404
|
+
const { children, ...slotProps } = props;
|
|
9405
|
+
if (React.isValidElement(children)) {
|
|
9406
|
+
const childrenRef = getElementRef$7(children);
|
|
9407
|
+
const props2 = mergeProps$6(slotProps, children.props);
|
|
9408
|
+
if (children.type !== React.Fragment) {
|
|
9409
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9410
|
+
}
|
|
9411
|
+
return React.cloneElement(children, props2);
|
|
9412
|
+
}
|
|
9413
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
9414
|
+
});
|
|
9415
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9416
|
+
return SlotClone;
|
|
9417
|
+
}
|
|
9418
|
+
var SLOTTABLE_IDENTIFIER$6 = Symbol("radix.slottable");
|
|
9419
|
+
function isSlottable$6(child) {
|
|
9420
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$6;
|
|
9421
|
+
}
|
|
9422
|
+
function mergeProps$6(slotProps, childProps) {
|
|
9423
|
+
const overrideProps = { ...childProps };
|
|
9424
|
+
for (const propName in childProps) {
|
|
9425
|
+
const slotPropValue = slotProps[propName];
|
|
9426
|
+
const childPropValue = childProps[propName];
|
|
9427
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
9428
|
+
if (isHandler) {
|
|
9429
|
+
if (slotPropValue && childPropValue) {
|
|
9430
|
+
overrideProps[propName] = (...args) => {
|
|
9431
|
+
const result = childPropValue(...args);
|
|
9432
|
+
slotPropValue(...args);
|
|
9433
|
+
return result;
|
|
9434
|
+
};
|
|
9435
|
+
} else if (slotPropValue) {
|
|
9436
|
+
overrideProps[propName] = slotPropValue;
|
|
9437
|
+
}
|
|
9438
|
+
} else if (propName === "style") {
|
|
9439
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9440
|
+
} else if (propName === "className") {
|
|
9441
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9442
|
+
}
|
|
9443
|
+
}
|
|
9444
|
+
return { ...slotProps, ...overrideProps };
|
|
9445
|
+
}
|
|
9446
|
+
function getElementRef$7(element) {
|
|
9447
|
+
var _a2, _b;
|
|
9448
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9449
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9450
|
+
if (mayWarn) {
|
|
9451
|
+
return element.ref;
|
|
9452
|
+
}
|
|
9453
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9454
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9455
|
+
if (mayWarn) {
|
|
9456
|
+
return element.props.ref;
|
|
9457
|
+
}
|
|
9458
|
+
return element.props.ref || element.ref;
|
|
9459
|
+
}
|
|
9344
9460
|
var NODES$5 = [
|
|
9345
9461
|
"a",
|
|
9346
9462
|
"button",
|
|
@@ -9361,7 +9477,7 @@ var NODES$5 = [
|
|
|
9361
9477
|
"ul"
|
|
9362
9478
|
];
|
|
9363
9479
|
var Primitive$5 = NODES$5.reduce((primitive, node) => {
|
|
9364
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9480
|
+
const Slot2 = /* @__PURE__ */ createSlot$6(`Primitive.${node}`);
|
|
9365
9481
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9366
9482
|
const { asChild, ...primitiveProps } = props;
|
|
9367
9483
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9383,7 +9499,7 @@ var Presence = (props) => {
|
|
|
9383
9499
|
const { present, children } = props;
|
|
9384
9500
|
const presence = usePresence(present);
|
|
9385
9501
|
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
|
|
9386
|
-
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
9502
|
+
const ref = useComposedRefs(presence.ref, getElementRef$6(child));
|
|
9387
9503
|
const forceMount = typeof children === "function";
|
|
9388
9504
|
return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
|
|
9389
9505
|
};
|
|
@@ -9482,7 +9598,7 @@ function usePresence(present) {
|
|
|
9482
9598
|
function getAnimationName(styles) {
|
|
9483
9599
|
return (styles == null ? void 0 : styles.animationName) || "none";
|
|
9484
9600
|
}
|
|
9485
|
-
function getElementRef(element) {
|
|
9601
|
+
function getElementRef$6(element) {
|
|
9486
9602
|
var _a2, _b;
|
|
9487
9603
|
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9488
9604
|
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
@@ -9635,6 +9751,89 @@ function getState(open) {
|
|
|
9635
9751
|
return open ? "open" : "closed";
|
|
9636
9752
|
}
|
|
9637
9753
|
var Root$1 = Collapsible$1;
|
|
9754
|
+
// @__NO_SIDE_EFFECTS__
|
|
9755
|
+
function createSlot$5(ownerName) {
|
|
9756
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$5(ownerName);
|
|
9757
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
9758
|
+
const { children, ...slotProps } = props;
|
|
9759
|
+
const childrenArray = React.Children.toArray(children);
|
|
9760
|
+
const slottable = childrenArray.find(isSlottable$5);
|
|
9761
|
+
if (slottable) {
|
|
9762
|
+
const newElement = slottable.props.children;
|
|
9763
|
+
const newChildren = childrenArray.map((child) => {
|
|
9764
|
+
if (child === slottable) {
|
|
9765
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
9766
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
9767
|
+
} else {
|
|
9768
|
+
return child;
|
|
9769
|
+
}
|
|
9770
|
+
});
|
|
9771
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
9772
|
+
}
|
|
9773
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
9774
|
+
});
|
|
9775
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
9776
|
+
return Slot2;
|
|
9777
|
+
}
|
|
9778
|
+
// @__NO_SIDE_EFFECTS__
|
|
9779
|
+
function createSlotClone$5(ownerName) {
|
|
9780
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
9781
|
+
const { children, ...slotProps } = props;
|
|
9782
|
+
if (React.isValidElement(children)) {
|
|
9783
|
+
const childrenRef = getElementRef$5(children);
|
|
9784
|
+
const props2 = mergeProps$5(slotProps, children.props);
|
|
9785
|
+
if (children.type !== React.Fragment) {
|
|
9786
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
9787
|
+
}
|
|
9788
|
+
return React.cloneElement(children, props2);
|
|
9789
|
+
}
|
|
9790
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
9791
|
+
});
|
|
9792
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
9793
|
+
return SlotClone;
|
|
9794
|
+
}
|
|
9795
|
+
var SLOTTABLE_IDENTIFIER$5 = Symbol("radix.slottable");
|
|
9796
|
+
function isSlottable$5(child) {
|
|
9797
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$5;
|
|
9798
|
+
}
|
|
9799
|
+
function mergeProps$5(slotProps, childProps) {
|
|
9800
|
+
const overrideProps = { ...childProps };
|
|
9801
|
+
for (const propName in childProps) {
|
|
9802
|
+
const slotPropValue = slotProps[propName];
|
|
9803
|
+
const childPropValue = childProps[propName];
|
|
9804
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
9805
|
+
if (isHandler) {
|
|
9806
|
+
if (slotPropValue && childPropValue) {
|
|
9807
|
+
overrideProps[propName] = (...args) => {
|
|
9808
|
+
const result = childPropValue(...args);
|
|
9809
|
+
slotPropValue(...args);
|
|
9810
|
+
return result;
|
|
9811
|
+
};
|
|
9812
|
+
} else if (slotPropValue) {
|
|
9813
|
+
overrideProps[propName] = slotPropValue;
|
|
9814
|
+
}
|
|
9815
|
+
} else if (propName === "style") {
|
|
9816
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
9817
|
+
} else if (propName === "className") {
|
|
9818
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
return { ...slotProps, ...overrideProps };
|
|
9822
|
+
}
|
|
9823
|
+
function getElementRef$5(element) {
|
|
9824
|
+
var _a2, _b;
|
|
9825
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
9826
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9827
|
+
if (mayWarn) {
|
|
9828
|
+
return element.ref;
|
|
9829
|
+
}
|
|
9830
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
9831
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
9832
|
+
if (mayWarn) {
|
|
9833
|
+
return element.props.ref;
|
|
9834
|
+
}
|
|
9835
|
+
return element.props.ref || element.ref;
|
|
9836
|
+
}
|
|
9638
9837
|
var NODES$4 = [
|
|
9639
9838
|
"a",
|
|
9640
9839
|
"button",
|
|
@@ -9655,7 +9854,7 @@ var NODES$4 = [
|
|
|
9655
9854
|
"ul"
|
|
9656
9855
|
];
|
|
9657
9856
|
var Primitive$4 = NODES$4.reduce((primitive, node) => {
|
|
9658
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
9857
|
+
const Slot2 = /* @__PURE__ */ createSlot$5(`Primitive.${node}`);
|
|
9659
9858
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9660
9859
|
const { asChild, ...primitiveProps } = props;
|
|
9661
9860
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9893,6 +10092,89 @@ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
|
9893
10092
|
target.dispatchEvent(event);
|
|
9894
10093
|
}
|
|
9895
10094
|
}
|
|
10095
|
+
// @__NO_SIDE_EFFECTS__
|
|
10096
|
+
function createSlot$4(ownerName) {
|
|
10097
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$4(ownerName);
|
|
10098
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
10099
|
+
const { children, ...slotProps } = props;
|
|
10100
|
+
const childrenArray = React.Children.toArray(children);
|
|
10101
|
+
const slottable = childrenArray.find(isSlottable$4);
|
|
10102
|
+
if (slottable) {
|
|
10103
|
+
const newElement = slottable.props.children;
|
|
10104
|
+
const newChildren = childrenArray.map((child) => {
|
|
10105
|
+
if (child === slottable) {
|
|
10106
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
10107
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
10108
|
+
} else {
|
|
10109
|
+
return child;
|
|
10110
|
+
}
|
|
10111
|
+
});
|
|
10112
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
10113
|
+
}
|
|
10114
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10115
|
+
});
|
|
10116
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
10117
|
+
return Slot2;
|
|
10118
|
+
}
|
|
10119
|
+
// @__NO_SIDE_EFFECTS__
|
|
10120
|
+
function createSlotClone$4(ownerName) {
|
|
10121
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
10122
|
+
const { children, ...slotProps } = props;
|
|
10123
|
+
if (React.isValidElement(children)) {
|
|
10124
|
+
const childrenRef = getElementRef$4(children);
|
|
10125
|
+
const props2 = mergeProps$4(slotProps, children.props);
|
|
10126
|
+
if (children.type !== React.Fragment) {
|
|
10127
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10128
|
+
}
|
|
10129
|
+
return React.cloneElement(children, props2);
|
|
10130
|
+
}
|
|
10131
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
10132
|
+
});
|
|
10133
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10134
|
+
return SlotClone;
|
|
10135
|
+
}
|
|
10136
|
+
var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
|
|
10137
|
+
function isSlottable$4(child) {
|
|
10138
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
|
|
10139
|
+
}
|
|
10140
|
+
function mergeProps$4(slotProps, childProps) {
|
|
10141
|
+
const overrideProps = { ...childProps };
|
|
10142
|
+
for (const propName in childProps) {
|
|
10143
|
+
const slotPropValue = slotProps[propName];
|
|
10144
|
+
const childPropValue = childProps[propName];
|
|
10145
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
10146
|
+
if (isHandler) {
|
|
10147
|
+
if (slotPropValue && childPropValue) {
|
|
10148
|
+
overrideProps[propName] = (...args) => {
|
|
10149
|
+
const result = childPropValue(...args);
|
|
10150
|
+
slotPropValue(...args);
|
|
10151
|
+
return result;
|
|
10152
|
+
};
|
|
10153
|
+
} else if (slotPropValue) {
|
|
10154
|
+
overrideProps[propName] = slotPropValue;
|
|
10155
|
+
}
|
|
10156
|
+
} else if (propName === "style") {
|
|
10157
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10158
|
+
} else if (propName === "className") {
|
|
10159
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10160
|
+
}
|
|
10161
|
+
}
|
|
10162
|
+
return { ...slotProps, ...overrideProps };
|
|
10163
|
+
}
|
|
10164
|
+
function getElementRef$4(element) {
|
|
10165
|
+
var _a2, _b;
|
|
10166
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10167
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10168
|
+
if (mayWarn) {
|
|
10169
|
+
return element.ref;
|
|
10170
|
+
}
|
|
10171
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10172
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10173
|
+
if (mayWarn) {
|
|
10174
|
+
return element.props.ref;
|
|
10175
|
+
}
|
|
10176
|
+
return element.props.ref || element.ref;
|
|
10177
|
+
}
|
|
9896
10178
|
var NODES$3 = [
|
|
9897
10179
|
"a",
|
|
9898
10180
|
"button",
|
|
@@ -9913,7 +10195,7 @@ var NODES$3 = [
|
|
|
9913
10195
|
"ul"
|
|
9914
10196
|
];
|
|
9915
10197
|
var Primitive$3 = NODES$3.reduce((primitive, node) => {
|
|
9916
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
10198
|
+
const Slot2 = /* @__PURE__ */ createSlot$4(`Primitive.${node}`);
|
|
9917
10199
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
9918
10200
|
const { asChild, ...primitiveProps } = props;
|
|
9919
10201
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -9935,6 +10217,100 @@ var Portal$1 = React.forwardRef((props, forwardedRef) => {
|
|
|
9935
10217
|
return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive$3.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
9936
10218
|
});
|
|
9937
10219
|
Portal$1.displayName = PORTAL_NAME$1;
|
|
10220
|
+
// @__NO_SIDE_EFFECTS__
|
|
10221
|
+
function createSlot$3(ownerName) {
|
|
10222
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$3(ownerName);
|
|
10223
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
10224
|
+
const { children, ...slotProps } = props;
|
|
10225
|
+
const childrenArray = React.Children.toArray(children);
|
|
10226
|
+
const slottable = childrenArray.find(isSlottable$3);
|
|
10227
|
+
if (slottable) {
|
|
10228
|
+
const newElement = slottable.props.children;
|
|
10229
|
+
const newChildren = childrenArray.map((child) => {
|
|
10230
|
+
if (child === slottable) {
|
|
10231
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
10232
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
10233
|
+
} else {
|
|
10234
|
+
return child;
|
|
10235
|
+
}
|
|
10236
|
+
});
|
|
10237
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
10238
|
+
}
|
|
10239
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
10240
|
+
});
|
|
10241
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
10242
|
+
return Slot2;
|
|
10243
|
+
}
|
|
10244
|
+
var Slot = /* @__PURE__ */ createSlot$3("Slot");
|
|
10245
|
+
// @__NO_SIDE_EFFECTS__
|
|
10246
|
+
function createSlotClone$3(ownerName) {
|
|
10247
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
10248
|
+
const { children, ...slotProps } = props;
|
|
10249
|
+
if (React.isValidElement(children)) {
|
|
10250
|
+
const childrenRef = getElementRef$3(children);
|
|
10251
|
+
const props2 = mergeProps$3(slotProps, children.props);
|
|
10252
|
+
if (children.type !== React.Fragment) {
|
|
10253
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
10254
|
+
}
|
|
10255
|
+
return React.cloneElement(children, props2);
|
|
10256
|
+
}
|
|
10257
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
10258
|
+
});
|
|
10259
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
10260
|
+
return SlotClone;
|
|
10261
|
+
}
|
|
10262
|
+
var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
|
|
10263
|
+
// @__NO_SIDE_EFFECTS__
|
|
10264
|
+
function createSlottable$1(ownerName) {
|
|
10265
|
+
const Slottable2 = ({ children }) => {
|
|
10266
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
10267
|
+
};
|
|
10268
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
10269
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER$3;
|
|
10270
|
+
return Slottable2;
|
|
10271
|
+
}
|
|
10272
|
+
var Slottable$1 = /* @__PURE__ */ createSlottable$1("Slottable");
|
|
10273
|
+
function isSlottable$3(child) {
|
|
10274
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
|
|
10275
|
+
}
|
|
10276
|
+
function mergeProps$3(slotProps, childProps) {
|
|
10277
|
+
const overrideProps = { ...childProps };
|
|
10278
|
+
for (const propName in childProps) {
|
|
10279
|
+
const slotPropValue = slotProps[propName];
|
|
10280
|
+
const childPropValue = childProps[propName];
|
|
10281
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
10282
|
+
if (isHandler) {
|
|
10283
|
+
if (slotPropValue && childPropValue) {
|
|
10284
|
+
overrideProps[propName] = (...args) => {
|
|
10285
|
+
const result = childPropValue(...args);
|
|
10286
|
+
slotPropValue(...args);
|
|
10287
|
+
return result;
|
|
10288
|
+
};
|
|
10289
|
+
} else if (slotPropValue) {
|
|
10290
|
+
overrideProps[propName] = slotPropValue;
|
|
10291
|
+
}
|
|
10292
|
+
} else if (propName === "style") {
|
|
10293
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
10294
|
+
} else if (propName === "className") {
|
|
10295
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
10296
|
+
}
|
|
10297
|
+
}
|
|
10298
|
+
return { ...slotProps, ...overrideProps };
|
|
10299
|
+
}
|
|
10300
|
+
function getElementRef$3(element) {
|
|
10301
|
+
var _a2, _b;
|
|
10302
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
10303
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10304
|
+
if (mayWarn) {
|
|
10305
|
+
return element.ref;
|
|
10306
|
+
}
|
|
10307
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
10308
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
10309
|
+
if (mayWarn) {
|
|
10310
|
+
return element.props.ref;
|
|
10311
|
+
}
|
|
10312
|
+
return element.props.ref || element.ref;
|
|
10313
|
+
}
|
|
9938
10314
|
var shim$1 = { exports: {} };
|
|
9939
10315
|
var useSyncExternalStoreShim_production = {};
|
|
9940
10316
|
/**
|
|
@@ -12027,6 +12403,89 @@ const arrow$2 = (options, deps) => {
|
|
|
12027
12403
|
options: [options, deps]
|
|
12028
12404
|
};
|
|
12029
12405
|
};
|
|
12406
|
+
// @__NO_SIDE_EFFECTS__
|
|
12407
|
+
function createSlot$2(ownerName) {
|
|
12408
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$2(ownerName);
|
|
12409
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
12410
|
+
const { children, ...slotProps } = props;
|
|
12411
|
+
const childrenArray = React.Children.toArray(children);
|
|
12412
|
+
const slottable = childrenArray.find(isSlottable$2);
|
|
12413
|
+
if (slottable) {
|
|
12414
|
+
const newElement = slottable.props.children;
|
|
12415
|
+
const newChildren = childrenArray.map((child) => {
|
|
12416
|
+
if (child === slottable) {
|
|
12417
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
12418
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
12419
|
+
} else {
|
|
12420
|
+
return child;
|
|
12421
|
+
}
|
|
12422
|
+
});
|
|
12423
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
12424
|
+
}
|
|
12425
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12426
|
+
});
|
|
12427
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
12428
|
+
return Slot2;
|
|
12429
|
+
}
|
|
12430
|
+
// @__NO_SIDE_EFFECTS__
|
|
12431
|
+
function createSlotClone$2(ownerName) {
|
|
12432
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
12433
|
+
const { children, ...slotProps } = props;
|
|
12434
|
+
if (React.isValidElement(children)) {
|
|
12435
|
+
const childrenRef = getElementRef$2(children);
|
|
12436
|
+
const props2 = mergeProps$2(slotProps, children.props);
|
|
12437
|
+
if (children.type !== React.Fragment) {
|
|
12438
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12439
|
+
}
|
|
12440
|
+
return React.cloneElement(children, props2);
|
|
12441
|
+
}
|
|
12442
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
12443
|
+
});
|
|
12444
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12445
|
+
return SlotClone;
|
|
12446
|
+
}
|
|
12447
|
+
var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
|
|
12448
|
+
function isSlottable$2(child) {
|
|
12449
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
|
|
12450
|
+
}
|
|
12451
|
+
function mergeProps$2(slotProps, childProps) {
|
|
12452
|
+
const overrideProps = { ...childProps };
|
|
12453
|
+
for (const propName in childProps) {
|
|
12454
|
+
const slotPropValue = slotProps[propName];
|
|
12455
|
+
const childPropValue = childProps[propName];
|
|
12456
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
12457
|
+
if (isHandler) {
|
|
12458
|
+
if (slotPropValue && childPropValue) {
|
|
12459
|
+
overrideProps[propName] = (...args) => {
|
|
12460
|
+
const result = childPropValue(...args);
|
|
12461
|
+
slotPropValue(...args);
|
|
12462
|
+
return result;
|
|
12463
|
+
};
|
|
12464
|
+
} else if (slotPropValue) {
|
|
12465
|
+
overrideProps[propName] = slotPropValue;
|
|
12466
|
+
}
|
|
12467
|
+
} else if (propName === "style") {
|
|
12468
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12469
|
+
} else if (propName === "className") {
|
|
12470
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12471
|
+
}
|
|
12472
|
+
}
|
|
12473
|
+
return { ...slotProps, ...overrideProps };
|
|
12474
|
+
}
|
|
12475
|
+
function getElementRef$2(element) {
|
|
12476
|
+
var _a2, _b;
|
|
12477
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12478
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12479
|
+
if (mayWarn) {
|
|
12480
|
+
return element.ref;
|
|
12481
|
+
}
|
|
12482
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12483
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12484
|
+
if (mayWarn) {
|
|
12485
|
+
return element.props.ref;
|
|
12486
|
+
}
|
|
12487
|
+
return element.props.ref || element.ref;
|
|
12488
|
+
}
|
|
12030
12489
|
var NODES$2 = [
|
|
12031
12490
|
"a",
|
|
12032
12491
|
"button",
|
|
@@ -12047,7 +12506,7 @@ var NODES$2 = [
|
|
|
12047
12506
|
"ul"
|
|
12048
12507
|
];
|
|
12049
12508
|
var Primitive$2 = NODES$2.reduce((primitive, node) => {
|
|
12050
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12509
|
+
const Slot2 = /* @__PURE__ */ createSlot$2(`Primitive.${node}`);
|
|
12051
12510
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
12052
12511
|
const { asChild, ...primitiveProps } = props;
|
|
12053
12512
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -12136,6 +12595,89 @@ function composeContextScopes$1(...scopes) {
|
|
|
12136
12595
|
createScope.scopeName = baseScope.scopeName;
|
|
12137
12596
|
return createScope;
|
|
12138
12597
|
}
|
|
12598
|
+
// @__NO_SIDE_EFFECTS__
|
|
12599
|
+
function createSlot$1(ownerName) {
|
|
12600
|
+
const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
|
|
12601
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
12602
|
+
const { children, ...slotProps } = props;
|
|
12603
|
+
const childrenArray = React.Children.toArray(children);
|
|
12604
|
+
const slottable = childrenArray.find(isSlottable$1);
|
|
12605
|
+
if (slottable) {
|
|
12606
|
+
const newElement = slottable.props.children;
|
|
12607
|
+
const newChildren = childrenArray.map((child) => {
|
|
12608
|
+
if (child === slottable) {
|
|
12609
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
12610
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
12611
|
+
} else {
|
|
12612
|
+
return child;
|
|
12613
|
+
}
|
|
12614
|
+
});
|
|
12615
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
12616
|
+
}
|
|
12617
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
12618
|
+
});
|
|
12619
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
12620
|
+
return Slot2;
|
|
12621
|
+
}
|
|
12622
|
+
// @__NO_SIDE_EFFECTS__
|
|
12623
|
+
function createSlotClone$1(ownerName) {
|
|
12624
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
12625
|
+
const { children, ...slotProps } = props;
|
|
12626
|
+
if (React.isValidElement(children)) {
|
|
12627
|
+
const childrenRef = getElementRef$1(children);
|
|
12628
|
+
const props2 = mergeProps$1(slotProps, children.props);
|
|
12629
|
+
if (children.type !== React.Fragment) {
|
|
12630
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
12631
|
+
}
|
|
12632
|
+
return React.cloneElement(children, props2);
|
|
12633
|
+
}
|
|
12634
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
12635
|
+
});
|
|
12636
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
12637
|
+
return SlotClone;
|
|
12638
|
+
}
|
|
12639
|
+
var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
|
|
12640
|
+
function isSlottable$1(child) {
|
|
12641
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
|
|
12642
|
+
}
|
|
12643
|
+
function mergeProps$1(slotProps, childProps) {
|
|
12644
|
+
const overrideProps = { ...childProps };
|
|
12645
|
+
for (const propName in childProps) {
|
|
12646
|
+
const slotPropValue = slotProps[propName];
|
|
12647
|
+
const childPropValue = childProps[propName];
|
|
12648
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
12649
|
+
if (isHandler) {
|
|
12650
|
+
if (slotPropValue && childPropValue) {
|
|
12651
|
+
overrideProps[propName] = (...args) => {
|
|
12652
|
+
const result = childPropValue(...args);
|
|
12653
|
+
slotPropValue(...args);
|
|
12654
|
+
return result;
|
|
12655
|
+
};
|
|
12656
|
+
} else if (slotPropValue) {
|
|
12657
|
+
overrideProps[propName] = slotPropValue;
|
|
12658
|
+
}
|
|
12659
|
+
} else if (propName === "style") {
|
|
12660
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
12661
|
+
} else if (propName === "className") {
|
|
12662
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
12663
|
+
}
|
|
12664
|
+
}
|
|
12665
|
+
return { ...slotProps, ...overrideProps };
|
|
12666
|
+
}
|
|
12667
|
+
function getElementRef$1(element) {
|
|
12668
|
+
var _a2, _b;
|
|
12669
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
12670
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12671
|
+
if (mayWarn) {
|
|
12672
|
+
return element.ref;
|
|
12673
|
+
}
|
|
12674
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
12675
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
12676
|
+
if (mayWarn) {
|
|
12677
|
+
return element.props.ref;
|
|
12678
|
+
}
|
|
12679
|
+
return element.props.ref || element.ref;
|
|
12680
|
+
}
|
|
12139
12681
|
var NODES$1 = [
|
|
12140
12682
|
"a",
|
|
12141
12683
|
"button",
|
|
@@ -12156,7 +12698,7 @@ var NODES$1 = [
|
|
|
12156
12698
|
"ul"
|
|
12157
12699
|
];
|
|
12158
12700
|
var Primitive$1 = NODES$1.reduce((primitive, node) => {
|
|
12159
|
-
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
12701
|
+
const Slot2 = /* @__PURE__ */ createSlot$1(`Primitive.${node}`);
|
|
12160
12702
|
const Node4 = React.forwardRef((props, forwardedRef) => {
|
|
12161
12703
|
const { asChild, ...primitiveProps } = props;
|
|
12162
12704
|
const Comp = asChild ? Slot2 : node;
|
|
@@ -12498,6 +13040,98 @@ function composeContextScopes(...scopes) {
|
|
|
12498
13040
|
createScope.scopeName = baseScope.scopeName;
|
|
12499
13041
|
return createScope;
|
|
12500
13042
|
}
|
|
13043
|
+
// @__NO_SIDE_EFFECTS__
|
|
13044
|
+
function createSlot(ownerName) {
|
|
13045
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
13046
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
13047
|
+
const { children, ...slotProps } = props;
|
|
13048
|
+
const childrenArray = React.Children.toArray(children);
|
|
13049
|
+
const slottable = childrenArray.find(isSlottable);
|
|
13050
|
+
if (slottable) {
|
|
13051
|
+
const newElement = slottable.props.children;
|
|
13052
|
+
const newChildren = childrenArray.map((child) => {
|
|
13053
|
+
if (child === slottable) {
|
|
13054
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
13055
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
13056
|
+
} else {
|
|
13057
|
+
return child;
|
|
13058
|
+
}
|
|
13059
|
+
});
|
|
13060
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
13061
|
+
}
|
|
13062
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
13063
|
+
});
|
|
13064
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
13065
|
+
return Slot2;
|
|
13066
|
+
}
|
|
13067
|
+
// @__NO_SIDE_EFFECTS__
|
|
13068
|
+
function createSlotClone(ownerName) {
|
|
13069
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
13070
|
+
const { children, ...slotProps } = props;
|
|
13071
|
+
if (React.isValidElement(children)) {
|
|
13072
|
+
const childrenRef = getElementRef(children);
|
|
13073
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
13074
|
+
if (children.type !== React.Fragment) {
|
|
13075
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
13076
|
+
}
|
|
13077
|
+
return React.cloneElement(children, props2);
|
|
13078
|
+
}
|
|
13079
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
13080
|
+
});
|
|
13081
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
13082
|
+
return SlotClone;
|
|
13083
|
+
}
|
|
13084
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
13085
|
+
// @__NO_SIDE_EFFECTS__
|
|
13086
|
+
function createSlottable(ownerName) {
|
|
13087
|
+
const Slottable2 = ({ children }) => {
|
|
13088
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
13089
|
+
};
|
|
13090
|
+
Slottable2.displayName = `${ownerName}.Slottable`;
|
|
13091
|
+
Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
|
|
13092
|
+
return Slottable2;
|
|
13093
|
+
}
|
|
13094
|
+
function isSlottable(child) {
|
|
13095
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
13096
|
+
}
|
|
13097
|
+
function mergeProps(slotProps, childProps) {
|
|
13098
|
+
const overrideProps = { ...childProps };
|
|
13099
|
+
for (const propName in childProps) {
|
|
13100
|
+
const slotPropValue = slotProps[propName];
|
|
13101
|
+
const childPropValue = childProps[propName];
|
|
13102
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
13103
|
+
if (isHandler) {
|
|
13104
|
+
if (slotPropValue && childPropValue) {
|
|
13105
|
+
overrideProps[propName] = (...args) => {
|
|
13106
|
+
const result = childPropValue(...args);
|
|
13107
|
+
slotPropValue(...args);
|
|
13108
|
+
return result;
|
|
13109
|
+
};
|
|
13110
|
+
} else if (slotPropValue) {
|
|
13111
|
+
overrideProps[propName] = slotPropValue;
|
|
13112
|
+
}
|
|
13113
|
+
} else if (propName === "style") {
|
|
13114
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
13115
|
+
} else if (propName === "className") {
|
|
13116
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
13117
|
+
}
|
|
13118
|
+
}
|
|
13119
|
+
return { ...slotProps, ...overrideProps };
|
|
13120
|
+
}
|
|
13121
|
+
function getElementRef(element) {
|
|
13122
|
+
var _a2, _b;
|
|
13123
|
+
let getter = (_a2 = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a2.get;
|
|
13124
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13125
|
+
if (mayWarn) {
|
|
13126
|
+
return element.ref;
|
|
13127
|
+
}
|
|
13128
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
13129
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
13130
|
+
if (mayWarn) {
|
|
13131
|
+
return element.props.ref;
|
|
13132
|
+
}
|
|
13133
|
+
return element.props.ref || element.ref;
|
|
13134
|
+
}
|
|
12501
13135
|
var NODES = [
|
|
12502
13136
|
"a",
|
|
12503
13137
|
"button",
|
|
@@ -48886,6 +49520,43 @@ function CollapsibleTrigger({ ...props }) {
|
|
|
48886
49520
|
function CollapsibleContent({ ...props }) {
|
|
48887
49521
|
return /* @__PURE__ */ jsx(CollapsibleContent$1, { "data-slot": "collapsible-content", ...props });
|
|
48888
49522
|
}
|
|
49523
|
+
const NestedPtcComponentsContext = createContext(null);
|
|
49524
|
+
const NestedPtcComponentsProvider = ({ components, children }) => /* @__PURE__ */ jsx(NestedPtcComponentsContext.Provider, { value: components, children });
|
|
49525
|
+
const useNestedPtcComponents = (fallback) => {
|
|
49526
|
+
const components = useContext(NestedPtcComponentsContext);
|
|
49527
|
+
return useMemo(() => {
|
|
49528
|
+
const standardComponents = components && "ChainOfThought" in components && components.ChainOfThought ? void 0 : components;
|
|
49529
|
+
return {
|
|
49530
|
+
...standardComponents ?? {},
|
|
49531
|
+
tools: {
|
|
49532
|
+
...(standardComponents == null ? void 0 : standardComponents.tools) ?? {},
|
|
49533
|
+
Fallback: fallback
|
|
49534
|
+
}
|
|
49535
|
+
};
|
|
49536
|
+
}, [components, fallback]);
|
|
49537
|
+
};
|
|
49538
|
+
const EmptyComponent = () => null;
|
|
49539
|
+
const NestedPtcMessages = ({
|
|
49540
|
+
components,
|
|
49541
|
+
messageClassName
|
|
49542
|
+
}) => {
|
|
49543
|
+
const propsRef = useRef({ components, messageClassName });
|
|
49544
|
+
propsRef.current = { components, messageClassName };
|
|
49545
|
+
const messageComponents = useMemo(() => {
|
|
49546
|
+
const NestedMessage = () => {
|
|
49547
|
+
const { components: components2, messageClassName: messageClassName2 } = propsRef.current;
|
|
49548
|
+
const parts = /* @__PURE__ */ jsx(
|
|
49549
|
+
MessagePrimitive.Parts,
|
|
49550
|
+
{
|
|
49551
|
+
components: { Empty: EmptyComponent, ...components2 }
|
|
49552
|
+
}
|
|
49553
|
+
);
|
|
49554
|
+
return messageClassName2 ? /* @__PURE__ */ jsx("div", { className: messageClassName2, children: parts }) : parts;
|
|
49555
|
+
};
|
|
49556
|
+
return { Message: NestedMessage };
|
|
49557
|
+
}, []);
|
|
49558
|
+
return /* @__PURE__ */ jsx(MessagePartPrimitive.Messages, { components: messageComponents });
|
|
49559
|
+
};
|
|
48889
49560
|
const ANIMATION_DURATION = 200;
|
|
48890
49561
|
function truncateLine(text2, max2 = 70) {
|
|
48891
49562
|
const oneLine = text2.replace(/\s+/g, " ").trim();
|
|
@@ -49434,16 +50105,20 @@ const ToolFallbackImpl = ({
|
|
|
49434
50105
|
status
|
|
49435
50106
|
}) => {
|
|
49436
50107
|
const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
|
|
50108
|
+
const nestedComponents = useNestedPtcComponents(ToolFallback);
|
|
49437
50109
|
if (isAssetTool(toolName, result)) {
|
|
49438
|
-
return /* @__PURE__ */
|
|
49439
|
-
|
|
49440
|
-
|
|
49441
|
-
|
|
49442
|
-
|
|
49443
|
-
|
|
49444
|
-
|
|
49445
|
-
|
|
49446
|
-
|
|
50110
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
50111
|
+
/* @__PURE__ */ jsx(
|
|
50112
|
+
AssetToolCard,
|
|
50113
|
+
{
|
|
50114
|
+
toolName,
|
|
50115
|
+
argsText,
|
|
50116
|
+
result,
|
|
50117
|
+
status
|
|
50118
|
+
}
|
|
50119
|
+
),
|
|
50120
|
+
/* @__PURE__ */ jsx(NestedPtcMessages, { components: nestedComponents })
|
|
50121
|
+
] });
|
|
49447
50122
|
}
|
|
49448
50123
|
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
49449
50124
|
const resultAssetId = extractAssetId$1(result);
|
|
@@ -49468,6 +50143,7 @@ const ToolFallbackImpl = ({
|
|
|
49468
50143
|
}
|
|
49469
50144
|
),
|
|
49470
50145
|
!isCancelled && /* @__PURE__ */ jsx(ToolFallbackResult, { result }),
|
|
50146
|
+
/* @__PURE__ */ jsx(NestedPtcMessages, { components: nestedComponents }),
|
|
49471
50147
|
!isCancelled && /* @__PURE__ */ jsx("div", { className: "flex justify-end px-3 pt-1", children: /* @__PURE__ */ jsx(CopyToolSpec, { toolName, argsText, result }) })
|
|
49472
50148
|
] })
|
|
49473
50149
|
]
|
|
@@ -52360,14 +53036,14 @@ const useAthenaChatDefaultComponents = () => {
|
|
|
52360
53036
|
return value;
|
|
52361
53037
|
};
|
|
52362
53038
|
const AthenaDefaultAssistantMessage = () => {
|
|
52363
|
-
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent, ActionBarComponent } = useAthenaChatDefaultComponents();
|
|
53039
|
+
const { toolUIs, TextComponent, ReasoningComponent, EmptyComponent: EmptyComponent2, ActionBarComponent } = useAthenaChatDefaultComponents();
|
|
52364
53040
|
return /* @__PURE__ */ jsx(
|
|
52365
53041
|
AthenaAssistantMessage,
|
|
52366
53042
|
{
|
|
52367
53043
|
toolUIs,
|
|
52368
53044
|
TextComponent,
|
|
52369
53045
|
ReasoningComponent,
|
|
52370
|
-
EmptyComponent,
|
|
53046
|
+
EmptyComponent: EmptyComponent2,
|
|
52371
53047
|
ActionBarComponent
|
|
52372
53048
|
}
|
|
52373
53049
|
);
|
|
@@ -52392,6 +53068,16 @@ const getReasoningTokensFromMetadata = (metadata) => {
|
|
|
52392
53068
|
return typeof reasoningTokens === "number" && Number.isFinite(reasoningTokens) ? reasoningTokens : void 0;
|
|
52393
53069
|
};
|
|
52394
53070
|
const formatReasoningTokens = (reasoningTokens) => `${reasoningTokens.toLocaleString("en-US")} ${reasoningTokens === 1 ? "token" : "tokens"}`;
|
|
53071
|
+
const withNestedPtcMessages = (ToolUI) => {
|
|
53072
|
+
const ToolUIWithNestedPtcMessages = (props) => {
|
|
53073
|
+
const nestedComponents = useNestedPtcComponents(ToolFallback);
|
|
53074
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
53075
|
+
/* @__PURE__ */ jsx(ToolUI, { ...props }),
|
|
53076
|
+
/* @__PURE__ */ jsx(NestedPtcMessages, { components: nestedComponents })
|
|
53077
|
+
] });
|
|
53078
|
+
};
|
|
53079
|
+
return ToolUIWithNestedPtcMessages;
|
|
53080
|
+
};
|
|
52395
53081
|
const SuggestionCard = ({
|
|
52396
53082
|
suggestion,
|
|
52397
53083
|
index: index2
|
|
@@ -52747,10 +53433,29 @@ const AthenaAssistantMessage = ({
|
|
|
52747
53433
|
toolUIs,
|
|
52748
53434
|
TextComponent = TiptapText,
|
|
52749
53435
|
ReasoningComponent,
|
|
52750
|
-
EmptyComponent = AthenaAssistantMessageEmpty,
|
|
53436
|
+
EmptyComponent: EmptyComponent2 = AthenaAssistantMessageEmpty,
|
|
52751
53437
|
ActionBarComponent = AthenaAssistantActionBar
|
|
52752
53438
|
}) => {
|
|
52753
53439
|
const effectiveReasoningComponent = ReasoningComponent ?? AthenaReasoningPart;
|
|
53440
|
+
const toolUIsWithNestedMessages = useMemo(() => {
|
|
53441
|
+
const wrappedToolUIs = {};
|
|
53442
|
+
for (const [toolName, ToolUI] of Object.entries(toolUIs)) {
|
|
53443
|
+
wrappedToolUIs[toolName] = withNestedPtcMessages(ToolUI);
|
|
53444
|
+
}
|
|
53445
|
+
return wrappedToolUIs;
|
|
53446
|
+
}, [toolUIs]);
|
|
53447
|
+
const partsComponents = useMemo(
|
|
53448
|
+
() => ({
|
|
53449
|
+
Text: TextComponent,
|
|
53450
|
+
Reasoning: effectiveReasoningComponent,
|
|
53451
|
+
tools: {
|
|
53452
|
+
Fallback: ToolFallback,
|
|
53453
|
+
by_name: toolUIsWithNestedMessages
|
|
53454
|
+
},
|
|
53455
|
+
Empty: EmptyComponent2
|
|
53456
|
+
}),
|
|
53457
|
+
[EmptyComponent2, TextComponent, effectiveReasoningComponent, toolUIsWithNestedMessages]
|
|
53458
|
+
);
|
|
52754
53459
|
return /* @__PURE__ */ jsxs(
|
|
52755
53460
|
MessagePrimitive.Root,
|
|
52756
53461
|
{
|
|
@@ -52758,20 +53463,7 @@ const AthenaAssistantMessage = ({
|
|
|
52758
53463
|
"data-role": "assistant",
|
|
52759
53464
|
children: [
|
|
52760
53465
|
/* @__PURE__ */ jsx(AthenaReasoningTextComponentContext.Provider, { value: TextComponent, children: /* @__PURE__ */ jsxs("div", { className: "aui-assistant-message-content wrap-break-word px-2 text-foreground leading-relaxed", children: [
|
|
52761
|
-
/* @__PURE__ */ jsx(
|
|
52762
|
-
MessagePrimitive.Parts,
|
|
52763
|
-
{
|
|
52764
|
-
components: {
|
|
52765
|
-
Text: TextComponent,
|
|
52766
|
-
Reasoning: effectiveReasoningComponent,
|
|
52767
|
-
tools: {
|
|
52768
|
-
Fallback: ToolFallback,
|
|
52769
|
-
by_name: toolUIs
|
|
52770
|
-
},
|
|
52771
|
-
Empty: EmptyComponent
|
|
52772
|
-
}
|
|
52773
|
-
}
|
|
52774
|
-
),
|
|
53466
|
+
/* @__PURE__ */ jsx(NestedPtcComponentsProvider, { components: partsComponents, children: /* @__PURE__ */ jsx(MessagePrimitive.Parts, { components: partsComponents }) }),
|
|
52775
53467
|
/* @__PURE__ */ jsx(MessageError, {})
|
|
52776
53468
|
] }) }),
|
|
52777
53469
|
/* @__PURE__ */ jsx("div", { className: "aui-assistant-message-footer mt-1 ml-2 flex", children: /* @__PURE__ */ jsx(ActionBarComponent, {}) })
|
|
@@ -53279,7 +53971,9 @@ export {
|
|
|
53279
53971
|
FileUploadButton,
|
|
53280
53972
|
GetDatabaseTableSchemaToolUI,
|
|
53281
53973
|
ListDatabaseTablesToolUI,
|
|
53974
|
+
NestedPtcMessages,
|
|
53282
53975
|
OpenAssetToolUI,
|
|
53976
|
+
PTC_SUBCALL_DID_NOT_COMPLETE_MESSAGE,
|
|
53283
53977
|
ReadAssetToolUI,
|
|
53284
53978
|
RunPythonCodeToolUI,
|
|
53285
53979
|
RunSqlToolUI,
|
|
@@ -53304,9 +53998,11 @@ export {
|
|
|
53304
53998
|
UpdateSheetRangeToolUI,
|
|
53305
53999
|
WebSearchToolUI,
|
|
53306
54000
|
archiveThread,
|
|
54001
|
+
autoCloseInFlightSubgraphMessages,
|
|
53307
54002
|
buttonVariants,
|
|
53308
54003
|
clearAutoOpenedAssets,
|
|
53309
54004
|
cn,
|
|
54005
|
+
convertLangChainToThreadMessages,
|
|
53310
54006
|
createAssetToolUI,
|
|
53311
54007
|
createThread,
|
|
53312
54008
|
formatToolName,
|