@loopstack/loopstack-studio 0.31.0 → 0.32.0

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.
@@ -48,7 +48,10 @@ var coreRendererRegistry = new Map([
48
48
  ["error", ({ document: e }) => /* @__PURE__ */ jsx(ErrorMessageRenderer_default, { document: e })],
49
49
  ["plain", ({ document: e }) => /* @__PURE__ */ jsx(PlainMessageRenderer_default, { document: e })],
50
50
  ["markdown", ({ document: e }) => /* @__PURE__ */ jsx(MarkdownMessageRenderer_default, { document: e })],
51
- ["link", ({ document: e }) => /* @__PURE__ */ jsx(LinkMessageRenderer_default, { document: e })],
51
+ ["link", ({ workflow: e, document: _ }) => /* @__PURE__ */ jsx(LinkMessageRenderer_default, {
52
+ workflow: e,
53
+ document: _
54
+ })],
52
55
  ["oauth-prompt", ({ parentWorkflow: e, workflow: _, document: y, isActive: b }) => /* @__PURE__ */ jsx(OAuthPromptRenderer_default, {
53
56
  parentWorkflow: e,
54
57
  workflow: _,
@@ -10,37 +10,38 @@ function summarizeDocumentContent(e) {
10
10
  };
11
11
  if (typeof e != "object") return { kind: "unknown" };
12
12
  let t = e;
13
- if ("role" in t && "content" in t) {
14
- let e = String(t.role), n = typeof t.id == "string" ? t.id : void 0, r = typeof t.stopReason == "string" ? t.stopReason : void 0, i = t.content;
15
- if (typeof i == "string") return {
16
- kind: "ui-message",
17
- role: e,
18
- messageId: n,
19
- stopReason: r,
20
- charCount: i.length
21
- };
22
- if (Array.isArray(i)) {
23
- let t = i, a = /* @__PURE__ */ new Map();
24
- for (let e of t) {
25
- let t = a.get(e.type) ?? {
13
+ if ("role" in t && ("text" in t || "blocks" in t)) {
14
+ let e = String(t.role), n = typeof t.id == "string" ? t.id : void 0, r = typeof t.stopReason == "string" ? t.stopReason : void 0, i = typeof t.text == "string" ? t.text : void 0, a = Array.isArray(t.blocks) ? t.blocks : void 0;
15
+ if (a && a.length > 0) {
16
+ let t = /* @__PURE__ */ new Map();
17
+ for (let e of a) {
18
+ let n = t.get(e.type) ?? {
26
19
  count: 0,
27
20
  labels: []
28
21
  };
29
- t.count += 1, (e.type === "tool_call" || e.type === "server_tool_use") && t.labels.push(e.name), a.set(e.type, t);
22
+ n.count += 1, (e.type === "tool_call" || e.type === "server_tool_use") && n.labels.push(e.name), t.set(e.type, n);
30
23
  }
24
+ let o = a.reduce((e, t) => t.type === "text" || t.type === "thinking" ? e + t.text.length : t.type === "tool_result" ? e + t.content.length : e, 0);
31
25
  return {
32
26
  kind: "ui-message",
33
27
  role: e,
34
28
  messageId: n,
35
29
  stopReason: r,
36
- charCount: t.reduce((e, t) => t.type === "text" || t.type === "thinking" ? e + t.text.length : t.type === "tool_result" ? e + t.content.length : e, 0),
37
- blocks: [...a.entries()].map(([e, { count: t, labels: n }]) => ({
30
+ charCount: i?.length ?? o,
31
+ blocks: [...t.entries()].map(([e, { count: t, labels: n }]) => ({
38
32
  type: e,
39
33
  count: t,
40
34
  labels: n.length > 0 ? n : void 0
41
35
  }))
42
36
  };
43
37
  }
38
+ return {
39
+ kind: "ui-message",
40
+ role: e,
41
+ messageId: n,
42
+ stopReason: r,
43
+ charCount: i?.length ?? 0
44
+ };
44
45
  }
45
46
  return {
46
47
  kind: "object",
@@ -1,10 +1,22 @@
1
1
  import CompletionMessagePaper_default from "../../../components/messages/CompletionMessagePaper.js";
2
- import AiMessageContent_default from "./AiMessageContent.js";
2
+ import MarkdownContent_default from "../../../components/dynamic-form/MarkdownContent.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import React from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
- var DocumentMessageRenderer_default = (i) => {
7
- let a = c(2), { document: o } = i, s = o.content, l;
8
- return a[0] === s ? l = a[1] : (l = /* @__PURE__ */ jsx(CompletionMessagePaper_default, { children: /* @__PURE__ */ jsx(AiMessageContent_default, { message: s }) }), a[0] = s, a[1] = l), l;
6
+ var KNOWN_ROLES = [
7
+ "system",
8
+ "user",
9
+ "assistant",
10
+ "tool",
11
+ "error",
12
+ "document"
13
+ ], DocumentMessageRenderer_default = (a) => {
14
+ let o = c(5), { document: s } = a, { role: l, text: u } = s.content, d = KNOWN_ROLES.includes(l ?? "") ? l : void 0, f = u ?? "", p;
15
+ o[0] === f ? p = o[1] : (p = /* @__PURE__ */ jsx(MarkdownContent_default, { content: f }), o[0] = f, o[1] = p);
16
+ let m;
17
+ return o[2] !== d || o[3] !== p ? (m = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
18
+ role: d,
19
+ children: p
20
+ }), o[2] = d, o[3] = p, o[4] = m) : m = o[4], m;
9
21
  };
10
22
  export { DocumentMessageRenderer_default as default };
@@ -1,15 +1,28 @@
1
+ import { useChildWorkflows } from "../../../hooks/useWorkflows.js";
2
+ import { WorkflowState } from "../../../packages/contracts/dist/enums/workflow-state.enum.js";
3
+ import "../../../packages/contracts/dist/enums/index.js";
1
4
  import link_default from "../../../components/loopstack-elements/link.js";
2
5
  import { c } from "react/compiler-runtime";
3
6
  import React from "react";
4
7
  import { jsx } from "react/jsx-runtime";
5
- var LinkMessageRenderer_default = (r) => {
6
- let i = c(6), { document: a } = r, { status: o, label: s, workflowId: l, embed: u, expanded: d } = a.content, f = l ? `/workflows/${l}` : void 0, p;
7
- return i[0] !== u || i[1] !== d || i[2] !== f || i[3] !== s || i[4] !== o ? (p = /* @__PURE__ */ jsx(link_default, {
8
- href: f,
9
- label: s,
10
- status: o,
11
- embed: u,
12
- defaultExpanded: d
13
- }), i[0] = u, i[1] = d, i[2] = f, i[3] = s, i[4] = o, i[5] = p) : p = i[5], p;
8
+ function mapWorkflowStateToStatus(e) {
9
+ switch (e) {
10
+ case WorkflowState.Completed: return "success";
11
+ case WorkflowState.Failed:
12
+ case WorkflowState.Canceled: return "failure";
13
+ default: return "pending";
14
+ }
15
+ }
16
+ var LinkMessageRenderer_default = (a) => {
17
+ let o = c(9), { workflow: s, document: l } = a, { label: u, workflowId: d, embed: f, expanded: p } = l.content, m = d ? `/workflows/${d}` : void 0, h = useChildWorkflows(s.id), g;
18
+ o[0] !== h || o[1] !== d ? (g = mapWorkflowStateToStatus((d ? h.data?.find((e) => e.id === d) : void 0)?.status), o[0] = h, o[1] = d, o[2] = g) : g = o[2];
19
+ let _ = g, v;
20
+ return o[3] !== f || o[4] !== p || o[5] !== m || o[6] !== u || o[7] !== _ ? (v = /* @__PURE__ */ jsx(link_default, {
21
+ href: m,
22
+ label: u,
23
+ status: _,
24
+ embed: f,
25
+ defaultExpanded: p
26
+ }), o[3] = f, o[4] = p, o[5] = m, o[6] = u, o[7] = _, o[8] = v) : v = o[8], v;
14
27
  };
15
28
  export { LinkMessageRenderer_default as default };
@@ -8,87 +8,98 @@ import { Fragment } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  import { CopyIcon } from "lucide-react";
10
10
  var CopyActions = (e) => {
11
- let g = c(5), { text: _ } = e, v;
12
- g[0] === _ ? v = g[1] : (v = () => void navigator.clipboard.writeText(_), g[0] = _, g[1] = v);
13
- let y;
14
- g[2] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ jsx(CopyIcon, { className: "size-3" }), g[2] = y) : y = g[2];
11
+ let _ = c(5), { text: v } = e, y;
12
+ _[0] === v ? y = _[1] : (y = () => void navigator.clipboard.writeText(v), _[0] = v, _[1] = y);
15
13
  let b;
16
- return g[3] === v ? b = g[4] : (b = /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
17
- onClick: v,
14
+ _[2] === Symbol.for("react.memo_cache_sentinel") ? (b = /* @__PURE__ */ jsx(CopyIcon, { className: "size-3" }), _[2] = b) : b = _[2];
15
+ let x;
16
+ return _[3] === y ? x = _[4] : (x = /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
17
+ onClick: y,
18
18
  label: "Copy",
19
- children: y
20
- }) }) }), g[3] = v, g[4] = b), b;
21
- }, LlmMessage_default = (m) => {
22
- let h = c(18), { document: x } = m, S = x.content, C = S.id ?? x.id, w = !!x.meta?.streaming;
23
- if (typeof S.content == "string") {
24
- let m;
25
- h[0] !== w || h[1] !== S.content ? (m = /* @__PURE__ */ jsx(MessageContent, { children: w ? /* @__PURE__ */ jsx(StreamingText, { text: S.content }) : /* @__PURE__ */ jsx(MessageResponse, { children: S.content }) }), h[0] = w, h[1] = S.content, h[2] = m) : m = h[2];
26
- let v;
27
- h[3] !== w || h[4] !== S.content || h[5] !== S.role ? (v = S.role === "assistant" && !w && /* @__PURE__ */ jsx(CopyActions, { text: S.content }), h[3] = w, h[4] = S.content, h[5] = S.role, h[6] = v) : v = h[6];
28
- let y;
29
- return h[7] !== S.role || h[8] !== m || h[9] !== v ? (y = /* @__PURE__ */ jsxs(Message, {
30
- from: S.role,
31
- children: [m, v]
32
- }), h[7] = S.role, h[8] = m, h[9] = v, h[10] = y) : y = h[10], y;
19
+ children: b
20
+ }) }) }), _[3] = y, _[4] = x), x;
21
+ };
22
+ function hasStructuredBlocks(e) {
23
+ return !!e?.some((e) => e.type !== "text");
24
+ }
25
+ function textFromBlocks(e) {
26
+ return (e ?? []).filter((e) => e.type === "text").map((e) => e.text).join("\n");
27
+ }
28
+ var LlmMessage_default = (h) => {
29
+ let g = c(23), { document: C } = h, w = C.content, T = w.id ?? C.id, E = !!C.meta?.streaming;
30
+ if (!hasStructuredBlocks(w.blocks)) {
31
+ let h;
32
+ g[0] !== w.blocks || g[1] !== w.text ? (h = w.text ?? textFromBlocks(w.blocks), g[0] = w.blocks, g[1] = w.text, g[2] = h) : h = g[2];
33
+ let y = h, b;
34
+ g[3] !== E || g[4] !== y ? (b = /* @__PURE__ */ jsx(MessageContent, { children: E ? /* @__PURE__ */ jsx(StreamingText, { text: y }) : /* @__PURE__ */ jsx(MessageResponse, { children: y }) }), g[3] = E, g[4] = y, g[5] = b) : b = g[5];
35
+ let x;
36
+ g[6] !== E || g[7] !== w.role || g[8] !== y ? (x = w.role === "assistant" && !E && /* @__PURE__ */ jsx(CopyActions, { text: y }), g[6] = E, g[7] = w.role, g[8] = y, g[9] = x) : x = g[9];
37
+ let S;
38
+ return g[10] !== w.role || g[11] !== b || g[12] !== x ? (S = /* @__PURE__ */ jsxs(Message, {
39
+ from: w.role,
40
+ children: [b, x]
41
+ }), g[10] = w.role, g[11] = b, g[12] = x, g[13] = S) : S = g[13], S;
33
42
  }
34
- let T = S.content, E;
35
- h[11] !== T || h[12] !== w || h[13] !== S.role || h[14] !== C ? (E = T.map((m, h) => {
36
- switch (m.type) {
43
+ let D;
44
+ g[14] === w.blocks ? D = g[15] : (D = w.blocks ?? [], g[14] = w.blocks, g[15] = D);
45
+ let O = D, k;
46
+ g[16] !== O || g[17] !== E || g[18] !== w.role || g[19] !== T ? (k = O.map((h, g) => {
47
+ switch (h.type) {
37
48
  case "text": return /* @__PURE__ */ jsxs(Message, {
38
- from: S.role,
39
- children: [/* @__PURE__ */ jsx(MessageContent, { children: w ? /* @__PURE__ */ jsx(StreamingText, { text: m.text }) : /* @__PURE__ */ jsx(MessageResponse, { children: m.text }) }), S.role === "assistant" && !w && /* @__PURE__ */ jsx(CopyActions, { text: m.text })]
40
- }, `${C}-${h}`);
49
+ from: w.role,
50
+ children: [/* @__PURE__ */ jsx(MessageContent, { children: E ? /* @__PURE__ */ jsx(StreamingText, { text: h.text }) : /* @__PURE__ */ jsx(MessageResponse, { children: h.text }) }), w.role === "assistant" && !E && /* @__PURE__ */ jsx(CopyActions, { text: h.text })]
51
+ }, `${T}-${g}`);
41
52
  case "thinking": return /* @__PURE__ */ jsxs(Reasoning, {
42
53
  className: "w-full",
43
- isStreaming: w,
44
- children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: m.text })]
45
- }, `${C}-${h}`);
54
+ isStreaming: E,
55
+ children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: h.text })]
56
+ }, `${T}-${g}`);
46
57
  case "tool_call": return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
47
58
  from: "assistant",
48
59
  children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
49
60
  state: "input-available",
50
- title: m.name,
61
+ title: h.name,
51
62
  type: "tool-call"
52
- }), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolInput, { input: m.args }) })] })
53
- }) }, `${C}-${h}`);
63
+ }), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolInput, { input: h.args }) })] })
64
+ }) }, `${T}-${g}`);
54
65
  case "tool_result": {
55
- let g;
66
+ let _;
56
67
  try {
57
- g = JSON.parse(m.content);
68
+ _ = JSON.parse(h.content);
58
69
  } catch {
59
- g = m.content;
70
+ _ = h.content;
60
71
  }
61
72
  return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
62
73
  from: "assistant",
63
74
  children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
64
- state: m.isError ? "output-error" : "output-available",
75
+ state: h.isError ? "output-error" : "output-available",
65
76
  title: "Tool Result",
66
77
  type: "tool-call"
67
78
  }), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolOutput, {
68
- output: g,
69
- errorText: m.isError ? m.content : ""
79
+ output: _,
80
+ errorText: h.isError ? h.content : ""
70
81
  }) })] })
71
- }) }, `${C}-${h}`);
82
+ }) }, `${T}-${g}`);
72
83
  }
73
84
  case "server_tool_use": {
74
- let g = T.find((e) => e.type === "server_tool_result" && e.toolUseId === m.id);
85
+ let _ = O.find((e) => e.type === "server_tool_result" && e.toolUseId === h.id);
75
86
  return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
76
87
  from: "assistant",
77
88
  children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
78
- state: g ? "output-available" : "input-available",
79
- title: m.name,
89
+ state: _ ? "output-available" : "input-available",
90
+ title: h.name,
80
91
  type: "tool-call"
81
- }), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, { input: m.input }), g && /* @__PURE__ */ jsx(ToolOutput, {
82
- output: g.content,
92
+ }), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, { input: h.input }), _ && /* @__PURE__ */ jsx(ToolOutput, {
93
+ output: _.content,
83
94
  errorText: ""
84
95
  })] })] })
85
- }) }, `${C}-${h}`);
96
+ }) }, `${T}-${g}`);
86
97
  }
87
98
  case "server_tool_result": return null;
88
99
  default: return null;
89
100
  }
90
- }), h[11] = T, h[12] = w, h[13] = S.role, h[14] = C, h[15] = E) : E = h[15];
91
- let D;
92
- return h[16] === E ? D = h[17] : (D = /* @__PURE__ */ jsx(Fragment, { children: E }), h[16] = E, h[17] = D), D;
101
+ }), g[16] = O, g[17] = E, g[18] = w.role, g[19] = T, g[20] = k) : k = g[20];
102
+ let A;
103
+ return g[21] === k ? A = g[22] : (A = /* @__PURE__ */ jsx(Fragment, { children: k }), g[21] = k, g[22] = A), A;
93
104
  };
94
105
  export { LlmMessage_default as default };
@@ -15,18 +15,21 @@ function createStreamingDocument(e, r, i) {
15
15
  i.thinking && a.push({
16
16
  type: "thinking",
17
17
  text: i.thinking
18
- }), a.push({
18
+ });
19
+ let o = i.error ? `Error while streaming response: ${i.error}` : i.text;
20
+ a.push({
19
21
  type: "text",
20
- text: i.error ? `Error while streaming response: ${i.error}` : i.text
22
+ text: o
21
23
  }), a.push(...i.toolCalls);
22
- let o = /* @__PURE__ */ new Date();
24
+ let s = /* @__PURE__ */ new Date();
23
25
  return {
24
26
  id: `streaming-${i.messageId}`,
25
27
  documentName: "llm_message",
26
28
  content: {
27
29
  id: i.messageId,
28
30
  role: "assistant",
29
- content: a
31
+ text: o,
32
+ blocks: a
30
33
  },
31
34
  validationError: null,
32
35
  meta: {
@@ -39,8 +42,8 @@ function createStreamingDocument(e, r, i) {
39
42
  place: r,
40
43
  labels: [],
41
44
  tags: ["message"],
42
- createdAt: o,
43
- updatedAt: o,
45
+ createdAt: s,
46
+ updatedAt: s,
44
47
  workspaceId: "",
45
48
  workflowId: e
46
49
  };
package/dist/index.d.ts CHANGED
@@ -1341,10 +1341,6 @@ export declare const StudioSidebar: () => JSX.Element;
1341
1341
 
1342
1342
  declare interface StudioUiConfig {
1343
1343
  widgets?: StudioWidgetConfig[];
1344
- sidebar?: boolean;
1345
- workflowHistory?: boolean;
1346
- workflowNavigation?: boolean;
1347
- debugWorkflow?: boolean;
1348
1344
  }
1349
1345
 
1350
1346
  declare interface StudioWidgetConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loopstack/loopstack-studio",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "repository": "loopstack-ai/loopstack-studio",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@fontsource/roboto": "^5.2.10",
28
28
  "@hookform/resolvers": "^5.2.2",
29
- "@loopstack/contracts": "^0.32.0",
29
+ "@loopstack/contracts": "^0.34.0",
30
30
  "@radix-ui/react-accordion": "^1.2.12",
31
31
  "@radix-ui/react-alert-dialog": "^1.1.15",
32
32
  "@radix-ui/react-avatar": "^1.1.11",
@@ -1,172 +0,0 @@
1
- import MarkdownContent_default from "../../../components/dynamic-form/MarkdownContent.js";
2
- import { c } from "react/compiler-runtime";
3
- import React from "react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- var getDataUrl = (e, r) => e instanceof URL ? e.toString() : typeof e == "string" ? `data:${r || "application/octet-stream"};base64,${e}` : "#", TextPartRenderer = (e) => {
6
- let i = c(2), { part: a } = e, o;
7
- return i[0] === a.text ? o = i[1] : (o = /* @__PURE__ */ jsx("div", {
8
- className: "text-sm leading-relaxed whitespace-pre-wrap",
9
- children: a.text
10
- }), i[0] = a.text, i[1] = o), o;
11
- }, ImagePartRenderer = (e) => {
12
- let i = c(11), { part: s } = e, l;
13
- i[0] !== s.image || i[1] !== s.mediaType ? (l = getDataUrl(s.image, s.mediaType), i[0] = s.image, i[1] = s.mediaType, i[2] = l) : l = i[2];
14
- let u;
15
- i[3] === Symbol.for("react.memo_cache_sentinel") ? (u = { maxHeight: "400px" }, i[3] = u) : u = i[3];
16
- let d;
17
- i[4] === l ? d = i[5] : (d = /* @__PURE__ */ jsx("img", {
18
- src: l,
19
- alt: "Uploaded image",
20
- className: "h-auto max-w-full rounded-lg border shadow-sm",
21
- style: u
22
- }), i[4] = l, i[5] = d);
23
- let f;
24
- i[6] === s.mediaType ? f = i[7] : (f = s.mediaType && /* @__PURE__ */ jsxs("div", {
25
- className: "mt-1 text-xs text-gray-500",
26
- children: ["Type: ", s.mediaType]
27
- }), i[6] = s.mediaType, i[7] = f);
28
- let p;
29
- return i[8] !== d || i[9] !== f ? (p = /* @__PURE__ */ jsxs("div", { children: [d, f] }), i[8] = d, i[9] = f, i[10] = p) : p = i[10], p;
30
- }, FilePartRenderer = (e) => {
31
- let i = c(8), { part: o } = e, s;
32
- i[0] === Symbol.for("react.memo_cache_sentinel") ? (s = /* @__PURE__ */ jsx("div", {
33
- className: "text-2xl",
34
- children: "📎"
35
- }), i[0] = s) : s = i[0];
36
- let l = o.filename || "Unnamed file", u;
37
- i[1] === l ? u = i[2] : (u = /* @__PURE__ */ jsx("div", {
38
- className: "text-sm font-medium",
39
- children: l
40
- }), i[1] = l, i[2] = u);
41
- let d;
42
- i[3] === o.mediaType ? d = i[4] : (d = /* @__PURE__ */ jsx("div", {
43
- className: "text-xs text-gray-500",
44
- children: o.mediaType
45
- }), i[3] = o.mediaType, i[4] = d);
46
- let f;
47
- return i[5] !== u || i[6] !== d ? (f = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", {
48
- className: "flex items-center space-x-2",
49
- children: [s, /* @__PURE__ */ jsxs("div", { children: [u, d] })]
50
- }) }), i[5] = u, i[6] = d, i[7] = f) : f = i[7], f;
51
- }, ReasoningPartRenderer = (e) => {
52
- let i = c(2), { part: o } = e, s;
53
- return i[0] === o.text ? s = i[1] : (s = o.text ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
54
- className: "mb-2 flex items-center space-x-2",
55
- children: /* @__PURE__ */ jsx("div", {
56
- className: "text-sm font-medium text-purple-600",
57
- children: "Reasoning"
58
- })
59
- }), /* @__PURE__ */ jsx("div", {
60
- className: "text-sm whitespace-pre-wrap text-purple-800",
61
- children: o.text
62
- })] }) : "", i[0] = o.text, i[1] = s), s;
63
- }, ToolCallPartRenderer = (e) => {
64
- let i = c(17), { part: o } = e, s;
65
- i[0] === o.toolName ? s = i[1] : (s = /* @__PURE__ */ jsx("div", {
66
- className: "text-sm font-medium",
67
- children: o.toolName
68
- }), i[0] = o.toolName, i[1] = s);
69
- let l;
70
- i[2] === o.providerExecuted ? l = i[3] : (l = o.providerExecuted && /* @__PURE__ */ jsx("span", {
71
- className: "rounded bg-green-100 px-2 py-1 text-xs text-green-800",
72
- children: "Executed"
73
- }), i[2] = o.providerExecuted, i[3] = l);
74
- let u;
75
- i[4] !== s || i[5] !== l ? (u = /* @__PURE__ */ jsxs("div", {
76
- className: "flex items-center space-x-2",
77
- children: [s, l]
78
- }), i[4] = s, i[5] = l, i[6] = u) : u = i[6];
79
- let d;
80
- i[7] === o.toolCallId ? d = i[8] : (d = /* @__PURE__ */ jsxs("div", {
81
- className: "ml-5 font-mono text-xs text-gray-500",
82
- children: ["ID: ", o.toolCallId]
83
- }), i[7] = o.toolCallId, i[8] = d);
84
- let f;
85
- i[9] !== u || i[10] !== d ? (f = /* @__PURE__ */ jsxs("div", {
86
- className: "mb-2 flex items-center justify-between",
87
- children: [u, d]
88
- }), i[9] = u, i[10] = d, i[11] = f) : f = i[11];
89
- let p;
90
- i[12] === o.input ? p = i[13] : (p = o.input ? /* @__PURE__ */ jsxs("div", {
91
- className: "rounded border bg-white p-2 text-xs",
92
- children: [/* @__PURE__ */ jsx("div", {
93
- className: "mb-1 text-gray-600",
94
- children: "Input:"
95
- }), /* @__PURE__ */ jsx("pre", {
96
- className: "overflow-x-auto whitespace-pre-wrap",
97
- children: JSON.stringify(o.input, null, 2)
98
- })]
99
- }) : "", i[12] = o.input, i[13] = p);
100
- let m;
101
- return i[14] !== f || i[15] !== p ? (m = /* @__PURE__ */ jsxs("div", { children: [f, p] }), i[14] = f, i[15] = p, i[16] = m) : m = i[16], m;
102
- }, ToolResultPartRenderer = (e) => {
103
- let i = c(14), { part: o } = e, s;
104
- i[0] === o.toolName ? s = i[1] : (s = /* @__PURE__ */ jsxs("div", {
105
- className: "text-sm font-medium",
106
- children: [o.toolName, " Result"]
107
- }), i[0] = o.toolName, i[1] = s);
108
- let l;
109
- i[2] === o.toolCallId ? l = i[3] : (l = /* @__PURE__ */ jsxs("div", {
110
- className: "ml-5 font-mono text-xs text-gray-500",
111
- children: ["ID: ", o.toolCallId]
112
- }), i[2] = o.toolCallId, i[3] = l);
113
- let u;
114
- i[4] !== s || i[5] !== l ? (u = /* @__PURE__ */ jsxs("div", {
115
- className: "mb-2 flex items-center justify-between",
116
- children: [s, l]
117
- }), i[4] = s, i[5] = l, i[6] = u) : u = i[6];
118
- let d;
119
- i[7] === o.output ? d = i[8] : (d = JSON.stringify(o.output, null, 2), i[7] = o.output, i[8] = d);
120
- let f;
121
- i[9] === d ? f = i[10] : (f = /* @__PURE__ */ jsx("div", {
122
- className: "rounded border bg-white p-2 text-xs",
123
- children: /* @__PURE__ */ jsx("pre", {
124
- className: "overflow-x-auto whitespace-pre-wrap",
125
- children: d
126
- })
127
- }), i[9] = d, i[10] = f);
128
- let p;
129
- return i[11] !== u || i[12] !== f ? (p = /* @__PURE__ */ jsxs("div", { children: [u, f] }), i[11] = u, i[12] = f, i[13] = p) : p = i[13], p;
130
- }, AiMessageContent_default = (i) => {
131
- let o = c(4), { message: s } = i, l = _temp, u;
132
- o[0] === s ? u = o[1] : (u = () => {
133
- if (s.role === "system") return /* @__PURE__ */ jsxs("div", {
134
- className: "rounded-lg border-l-4 border-gray-400 bg-gray-50 p-3 text-sm text-gray-600 italic",
135
- children: [/* @__PURE__ */ jsx("div", {
136
- className: "mb-1 font-medium",
137
- children: "System"
138
- }), /* @__PURE__ */ jsx("div", {
139
- className: "whitespace-pre-wrap",
140
- children: s.content
141
- })]
142
- });
143
- let { content: r } = s;
144
- return typeof r == "string" ? /* @__PURE__ */ jsx(MarkdownContent_default, { content: r }) : Array.isArray(r) ? /* @__PURE__ */ jsx("div", {
145
- className: "space-y-2",
146
- children: r.map((e, r) => l(e, r))
147
- }) : /* @__PURE__ */ jsx("div", {
148
- className: "text-sm text-red-600",
149
- children: "Invalid content format"
150
- });
151
- }, o[0] = s, o[1] = u);
152
- let d = u, f;
153
- return o[2] === d ? f = o[3] : (f = /* @__PURE__ */ jsx("div", {
154
- className: "message-content",
155
- children: d()
156
- }), o[2] = d, o[3] = f), f;
157
- };
158
- function _temp(e, r) {
159
- switch (e.type) {
160
- case "text": return /* @__PURE__ */ jsx(TextPartRenderer, { part: e }, r);
161
- case "image": return /* @__PURE__ */ jsx(ImagePartRenderer, { part: e }, r);
162
- case "file": return /* @__PURE__ */ jsx(FilePartRenderer, { part: e }, r);
163
- case "reasoning": return /* @__PURE__ */ jsx(ReasoningPartRenderer, { part: e }, r);
164
- case "tool-call": return /* @__PURE__ */ jsx(ToolCallPartRenderer, { part: e }, r);
165
- case "tool-result": return /* @__PURE__ */ jsx(ToolResultPartRenderer, { part: e }, r);
166
- default: return /* @__PURE__ */ jsxs("div", {
167
- className: "rounded bg-gray-100 p-2 text-sm",
168
- children: ["Unknown content type: ", e.type]
169
- }, r);
170
- }
171
- }
172
- export { AiMessageContent_default as default };