@athenaintel/react 0.9.15 → 0.9.17

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.js CHANGED
@@ -19849,14 +19849,20 @@ const joinExternalMessages = (messages) => {
19849
19849
  )
19850
19850
  );
19851
19851
  }
19852
+ const { messages: existingMessages, ...toolCallRest } = toolCall;
19852
19853
  const updatedToolCall = {
19853
- ...toolCall,
19854
+ ...toolCallRest,
19854
19855
  result: output.result,
19855
19856
  artifact: output.artifact,
19856
19857
  isError: output.isError,
19857
- messages: output.messages
19858
+ ...(output.messages ?? existingMessages) !== void 0 && {
19859
+ messages: output.messages ?? existingMessages
19860
+ }
19858
19861
  };
19859
- bindExternalStoreMessage(updatedToolCall, [...getExternalStoreMessages(toolCall), output]);
19862
+ bindExternalStoreMessage(updatedToolCall, [
19863
+ ...getExternalStoreMessages(toolCallRest),
19864
+ output
19865
+ ]);
19860
19866
  assistantMessage.content[toolCallIdx] = updatedToolCall;
19861
19867
  } else {
19862
19868
  console.warn(
@@ -19865,10 +19871,14 @@ const joinExternalMessages = (messages) => {
19865
19871
  }
19866
19872
  } else {
19867
19873
  const role = output.role;
19868
- const content = (typeof output.content === "string" ? [{ type: "text", text: output.content }] : output.content).map((c) => {
19874
+ const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
19875
+ const content = rawContent.flatMap((c) => {
19876
+ if (!c || typeof c !== "object") {
19877
+ return [];
19878
+ }
19869
19879
  const mapped = { ...c };
19870
19880
  bindExternalStoreMessage(mapped, output);
19871
- return mapped;
19881
+ return [mapped];
19872
19882
  });
19873
19883
  switch (role) {
19874
19884
  case "system":
@@ -19999,7 +20009,13 @@ const convertExternalMessages = (messages, callback, isRunning, metadata) => {
19999
20009
  const callbackResults = [];
20000
20010
  for (const message of messages) {
20001
20011
  const output = callback(message, metadata);
20002
- const outputs = Array.isArray(output) ? output : [output];
20012
+ const rawOutputs = Array.isArray(output) ? output : [output];
20013
+ const outputs = rawOutputs.filter(
20014
+ (candidate) => candidate != null
20015
+ );
20016
+ if (outputs.length === 0) {
20017
+ continue;
20018
+ }
20003
20019
  const result = { input: message, outputs };
20004
20020
  callbackResults.push(result);
20005
20021
  }
@@ -20022,37 +20038,40 @@ const warnForUnknownMessagePartType = (type) => {
20022
20038
  };
20023
20039
  const contentToParts = (content) => {
20024
20040
  if (typeof content === "string") return [{ type: "text", text: content }];
20025
- return content.map((part) => {
20041
+ return content.flatMap((part) => {
20042
+ if (!part || typeof part !== "object" || !("type" in part)) {
20043
+ return [];
20044
+ }
20026
20045
  const type = part.type;
20027
20046
  switch (type) {
20028
20047
  case "text":
20029
- return { type: "text", text: part.text };
20048
+ return [{ type: "text", text: part.text }];
20030
20049
  case "text_delta":
20031
- return { type: "text", text: part.text };
20050
+ return [{ type: "text", text: part.text }];
20032
20051
  case "image_url":
20033
20052
  if (typeof part.image_url === "string") {
20034
- return { type: "image", image: part.image_url };
20053
+ return [{ type: "image", image: part.image_url }];
20035
20054
  }
20036
- return {
20055
+ return [{
20037
20056
  type: "image",
20038
20057
  image: part.image_url.url
20039
- };
20058
+ }];
20040
20059
  case "thinking":
20041
- return { type: "reasoning", text: part.thinking };
20060
+ return [{ type: "reasoning", text: part.thinking }];
20042
20061
  case "reasoning":
20043
- return {
20062
+ return [{
20044
20063
  type: "reasoning",
20045
20064
  text: part.summary.map((s) => s.text).join("\n\n\n")
20046
- };
20065
+ }];
20047
20066
  case "tool_use":
20048
- return null;
20067
+ return [];
20049
20068
  case "input_json_delta":
20050
- return null;
20069
+ return [];
20051
20070
  default:
20052
20071
  warnForUnknownMessagePartType(type);
20053
- return null;
20072
+ return [];
20054
20073
  }
20055
- }).filter((a) => a !== null);
20074
+ });
20056
20075
  };
20057
20076
  const getNumberAtPath = (value, path) => {
20058
20077
  let current = value;
@@ -20157,7 +20176,7 @@ const convertLangChainMessage = (message) => {
20157
20176
  (_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
20158
20177
  ...normalizedContent,
20159
20178
  ...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
20160
- ].filter((c) => c !== void 0);
20179
+ ].filter((c) => c != null);
20161
20180
  return {
20162
20181
  role: "assistant",
20163
20182
  id: message.id,
@@ -20180,6 +20199,8 @@ const convertLangChainMessage = (message) => {
20180
20199
  isError: message.status === "error"
20181
20200
  };
20182
20201
  }
20202
+ default:
20203
+ return null;
20183
20204
  }
20184
20205
  };
20185
20206
  const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {