@loopstack/loopstack-studio 0.36.0 → 0.38.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.
- package/dist/features/documents/DocumentRenderer.js +46 -44
- package/dist/features/documents/renderers/DocumentMessageRenderer.js +23 -9
- package/dist/features/documents/renderers/LlmMessage.js +90 -50
- package/dist/features/documents/renderers/TerminalMessageRenderer.js +51 -0
- package/dist/features/documents/renderers/ansi.js +77 -0
- package/dist/features/file-explorer/components/FileExplorerPanel.js +66 -73
- package/dist/features/file-explorer/hooks/useFileExplorer.js +29 -25
- package/dist/features/file-explorer/providers/FileExplorerProvider.js +53 -53
- package/dist/features/git/components/WorkbenchGitPanel.js +36 -33
- package/dist/features/git/hooks/useGit.js +36 -33
- package/dist/features/run-view/RunView.js +1 -1
- package/dist/features/workbench/components/EnvironmentSelector.js +46 -0
- package/dist/features/workbench/components/WorkbenchPreviewPanel.js +1 -1
- package/dist/features/workbench/providers/WorkbenchLayoutProvider.js +64 -55
- package/dist/hooks/useEnvironments.js +25 -31
- package/dist/node_modules/es-toolkit/dist/_internal/globalThis.js +1 -1
- package/dist/node_modules/es-toolkit/dist/compat/object/clone.js +2 -2
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js +11 -11
- package/dist/node_modules/es-toolkit/dist/compat/object/mergeWith.js +8 -8
- package/dist/node_modules/es-toolkit/dist/compat/predicate/isEmpty.js +3 -3
- package/dist/node_modules/es-toolkit/dist/object/clone.js +2 -7
- package/dist/node_modules/es-toolkit/dist/object/cloneDeepWith.js +65 -65
- package/dist/packages/client/dist/queries/query-keys.js +5 -0
- package/dist/packages/client/dist/stream/invalidations.js +1 -0
- package/dist/packages/contracts/dist/events/client-message.schema.js +2 -1
- package/dist/packages/contracts/dist/events/index.js +1 -1
- package/dist/packages/contracts/dist/events/workspace-events.schema.js +2 -2
- package/dist/packages/contracts/dist/types/types/ui-message.type.js +15 -2
- package/package.json +4 -4
- /package/dist/features/run-view/{transcript.js → transcript-model.js} +0 -0
|
@@ -15,85 +15,87 @@ import "../oauth/index.js";
|
|
|
15
15
|
import ChoicesRenderer_default from "./renderers/ChoicesRenderer.js";
|
|
16
16
|
import ConfirmPromptRenderer_default from "./renderers/ConfirmPromptRenderer.js";
|
|
17
17
|
import LinkMessageRenderer_default from "./renderers/LinkMessageRenderer.js";
|
|
18
|
+
import TerminalMessageRenderer_default from "./renderers/TerminalMessageRenderer.js";
|
|
18
19
|
import TextPromptRenderer_default from "./renderers/TextPromptRenderer.js";
|
|
19
20
|
import { c } from "react/compiler-runtime";
|
|
20
21
|
import React, { useMemo } from "react";
|
|
21
22
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
22
23
|
var coreRendererRegistry = new Map([
|
|
23
|
-
["ai-message", ({ document: e, isLastItem:
|
|
24
|
+
["ai-message", ({ document: e, isLastItem: _ }) => /* @__PURE__ */ jsx(AiMessage_default, {
|
|
24
25
|
document: e,
|
|
25
|
-
isLastItem:
|
|
26
|
+
isLastItem: _
|
|
26
27
|
})],
|
|
27
|
-
["llm-message", ({ document: e, isLastItem:
|
|
28
|
+
["llm-message", ({ document: e, isLastItem: _ }) => /* @__PURE__ */ jsx(LlmMessage_default, {
|
|
28
29
|
document: e,
|
|
29
|
-
isLastItem:
|
|
30
|
+
isLastItem: _
|
|
30
31
|
})],
|
|
31
32
|
["debug", ({ document: e }) => /* @__PURE__ */ jsx("div", {
|
|
32
33
|
className: "mb-4 flex",
|
|
33
34
|
children: /* @__PURE__ */ jsx(DocumentDebugRenderer_default, { document: e })
|
|
34
35
|
})],
|
|
35
|
-
["form", ({ parentWorkflow: e, workflow:
|
|
36
|
+
["form", ({ parentWorkflow: e, workflow: v, document: y, isActive: b }) => /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
|
|
36
37
|
role: "document",
|
|
37
38
|
fullWidth: !0,
|
|
38
|
-
timestamp: new Date(
|
|
39
|
+
timestamp: new Date(y.createdAt),
|
|
39
40
|
children: /* @__PURE__ */ jsx(DocumentFormRenderer_default, {
|
|
40
41
|
parentWorkflow: e,
|
|
41
|
-
workflow:
|
|
42
|
-
document:
|
|
43
|
-
enabled:
|
|
44
|
-
viewOnly: !
|
|
42
|
+
workflow: v,
|
|
43
|
+
document: y,
|
|
44
|
+
enabled: b,
|
|
45
|
+
viewOnly: !b
|
|
45
46
|
})
|
|
46
47
|
})],
|
|
47
48
|
["message", ({ document: e }) => /* @__PURE__ */ jsx(DocumentMessageRenderer_default, { document: e })],
|
|
48
49
|
["error", ({ document: e }) => /* @__PURE__ */ jsx(ErrorMessageRenderer_default, { document: e })],
|
|
49
50
|
["plain", ({ document: e }) => /* @__PURE__ */ jsx(PlainMessageRenderer_default, { document: e })],
|
|
50
51
|
["markdown", ({ document: e }) => /* @__PURE__ */ jsx(MarkdownMessageRenderer_default, { document: e })],
|
|
51
|
-
["
|
|
52
|
+
["terminal", ({ document: e }) => /* @__PURE__ */ jsx(TerminalMessageRenderer_default, { document: e })],
|
|
53
|
+
["link", ({ workflow: e, document: _ }) => /* @__PURE__ */ jsx(LinkMessageRenderer_default, {
|
|
52
54
|
workflow: e,
|
|
53
|
-
document:
|
|
55
|
+
document: _
|
|
54
56
|
})],
|
|
55
|
-
["oauth-prompt", ({ parentWorkflow: e, workflow:
|
|
57
|
+
["oauth-prompt", ({ parentWorkflow: e, workflow: _, document: v, isActive: y }) => /* @__PURE__ */ jsx(OAuthPromptRenderer_default, {
|
|
56
58
|
parentWorkflow: e,
|
|
57
|
-
workflow:
|
|
58
|
-
document:
|
|
59
|
-
isActive:
|
|
59
|
+
workflow: _,
|
|
60
|
+
document: v,
|
|
61
|
+
isActive: y
|
|
60
62
|
})],
|
|
61
|
-
["text-prompt", ({ parentWorkflow: e, workflow:
|
|
63
|
+
["text-prompt", ({ parentWorkflow: e, workflow: _, document: v, isActive: y }) => /* @__PURE__ */ jsx(TextPromptRenderer_default, {
|
|
62
64
|
parentWorkflow: e,
|
|
63
|
-
workflow:
|
|
64
|
-
document:
|
|
65
|
-
isActive:
|
|
65
|
+
workflow: _,
|
|
66
|
+
document: v,
|
|
67
|
+
isActive: y
|
|
66
68
|
})],
|
|
67
|
-
["choices", ({ parentWorkflow: e, workflow:
|
|
69
|
+
["choices", ({ parentWorkflow: e, workflow: _, document: v, isActive: y }) => /* @__PURE__ */ jsx(ChoicesRenderer_default, {
|
|
68
70
|
parentWorkflow: e,
|
|
69
|
-
workflow:
|
|
70
|
-
document:
|
|
71
|
-
isActive:
|
|
71
|
+
workflow: _,
|
|
72
|
+
document: v,
|
|
73
|
+
isActive: y
|
|
72
74
|
})],
|
|
73
|
-
["confirm-prompt", ({ parentWorkflow: e, workflow:
|
|
75
|
+
["confirm-prompt", ({ parentWorkflow: e, workflow: _, document: v, isActive: y }) => /* @__PURE__ */ jsx(ConfirmPromptRenderer_default, {
|
|
74
76
|
parentWorkflow: e,
|
|
75
|
-
workflow:
|
|
76
|
-
document:
|
|
77
|
-
isActive:
|
|
77
|
+
workflow: _,
|
|
78
|
+
document: v,
|
|
79
|
+
isActive: y
|
|
78
80
|
})]
|
|
79
81
|
]);
|
|
80
82
|
function resolveWidgetName(e) {
|
|
81
|
-
let
|
|
82
|
-
return
|
|
83
|
+
let _ = e;
|
|
84
|
+
return _?.widgets?.[0]?.widget ? _.widgets[0].widget : _?.form?.widget ? _.form.widget : "form";
|
|
83
85
|
}
|
|
84
|
-
var DocumentRenderer_default = (
|
|
85
|
-
let
|
|
86
|
-
if (
|
|
87
|
-
let e = resolveWidgetName(
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
for (let e of
|
|
91
|
-
|
|
92
|
-
} else
|
|
93
|
-
let
|
|
94
|
-
|
|
95
|
-
} else
|
|
96
|
-
let
|
|
97
|
-
return
|
|
86
|
+
var DocumentRenderer_default = (_) => {
|
|
87
|
+
let y = c(9), b = useFeatureRegistry(), x = useDocumentConfigs(), S = _.document, C;
|
|
88
|
+
if (y[0] !== S.documentName || y[1] !== x || y[2] !== b) {
|
|
89
|
+
let e = resolveWidgetName(x.get(S.documentName)?.ui), _;
|
|
90
|
+
if (y[4] !== b) {
|
|
91
|
+
_ = /* @__PURE__ */ new Map();
|
|
92
|
+
for (let e of b) if (e.documentRenderers) for (let [v, y] of Object.entries(e.documentRenderers)) _.set(v, y);
|
|
93
|
+
y[4] = b, y[5] = _;
|
|
94
|
+
} else _ = y[5];
|
|
95
|
+
let v = _;
|
|
96
|
+
C = coreRendererRegistry.get(e) ?? v.get(e), y[0] = S.documentName, y[1] = x, y[2] = b, y[3] = C;
|
|
97
|
+
} else C = y[3];
|
|
98
|
+
let w = C, T;
|
|
99
|
+
return y[6] !== w || y[7] !== _ ? (T = /* @__PURE__ */ jsx("div", { children: w ? /* @__PURE__ */ jsx(w, { ..._ }) : /* @__PURE__ */ jsx(Fragment$1, { children: "unknown document type" }) }), y[6] = w, y[7] = _, y[8] = T) : T = y[8], T;
|
|
98
100
|
};
|
|
99
101
|
export { DocumentRenderer_default as default };
|
|
@@ -2,7 +2,8 @@ import CompletionMessagePaper_default from "../../../components/messages/Complet
|
|
|
2
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
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Info } from "lucide-react";
|
|
6
7
|
var KNOWN_ROLES = [
|
|
7
8
|
"system",
|
|
8
9
|
"user",
|
|
@@ -10,13 +11,26 @@ var KNOWN_ROLES = [
|
|
|
10
11
|
"tool",
|
|
11
12
|
"error",
|
|
12
13
|
"document"
|
|
13
|
-
], DocumentMessageRenderer_default = (
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
], DocumentMessageRenderer_default = (s) => {
|
|
15
|
+
let l = c(8), { document: u } = s, { role: d, text: f } = u.content, p = KNOWN_ROLES.includes(d ?? "") ? d : void 0;
|
|
16
|
+
if (p === "system") {
|
|
17
|
+
let e;
|
|
18
|
+
l[0] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ jsx(Info, { className: "mt-0.5 size-3.5 shrink-0 opacity-70" }), l[0] = e) : e = l[0];
|
|
19
|
+
let o = f ?? "", s;
|
|
20
|
+
return l[1] === o ? s = l[2] : (s = /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
className: "text-muted-foreground flex items-start gap-1.5 px-1 py-0.5 text-sm leading-relaxed [&_p]:m-0",
|
|
22
|
+
children: [e, /* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: "min-w-0",
|
|
24
|
+
children: /* @__PURE__ */ jsx(MarkdownContent_default, { content: o })
|
|
25
|
+
})]
|
|
26
|
+
}), l[1] = o, l[2] = s), s;
|
|
27
|
+
}
|
|
28
|
+
let m = f ?? "", h;
|
|
29
|
+
l[3] === m ? h = l[4] : (h = /* @__PURE__ */ jsx(MarkdownContent_default, { content: m }), l[3] = m, l[4] = h);
|
|
30
|
+
let g;
|
|
31
|
+
return l[5] !== p || l[6] !== h ? (g = /* @__PURE__ */ jsx(CompletionMessagePaper_default, {
|
|
32
|
+
role: p,
|
|
33
|
+
children: h
|
|
34
|
+
}), l[5] = p, l[6] = h, l[7] = g) : g = l[7], g;
|
|
21
35
|
};
|
|
22
36
|
export { DocumentMessageRenderer_default as default };
|
|
@@ -8,16 +8,50 @@ 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
|
|
12
|
-
|
|
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];
|
|
13
15
|
let b;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return _[3] === y ? x = _[4] : (x = /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
|
|
17
|
-
onClick: y,
|
|
16
|
+
return g[3] === v ? b = g[4] : (b = /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(MessageActions, { children: /* @__PURE__ */ jsx(MessageAction, {
|
|
17
|
+
onClick: v,
|
|
18
18
|
label: "Copy",
|
|
19
|
-
children:
|
|
20
|
-
}) }) }),
|
|
19
|
+
children: y
|
|
20
|
+
}) }) }), g[3] = v, g[4] = b), b;
|
|
21
|
+
};
|
|
22
|
+
function formatTokens(e) {
|
|
23
|
+
return e == null ? null : e >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : String(e);
|
|
24
|
+
}
|
|
25
|
+
var CompletionMeta = (e) => {
|
|
26
|
+
let m = c(21), { meta: h } = e, g;
|
|
27
|
+
if (m[0] !== h.costUsd || m[1] !== h.durationMs || m[2] !== h.model || m[3] !== h.numTurns || m[4] !== h.usage?.cacheCreationInputTokens || m[5] !== h.usage?.cacheReadInputTokens || m[6] !== h.usage?.inputTokens || m[7] !== h.usage?.outputTokens) {
|
|
28
|
+
if (g = [], h.numTurns != null && g.push(`${h.numTurns} turn${h.numTurns === 1 ? "" : "s"}`), h.costUsd != null) {
|
|
29
|
+
let e;
|
|
30
|
+
m[9] === h.costUsd ? e = m[10] : (e = h.costUsd.toFixed(4), m[9] = h.costUsd, m[10] = e), g.push(`$${e}`);
|
|
31
|
+
}
|
|
32
|
+
let e = h.usage?.inputTokens, _;
|
|
33
|
+
m[11] === e ? _ = m[12] : (_ = formatTokens(e), m[11] = e, m[12] = _);
|
|
34
|
+
let v = _, y = h.usage?.outputTokens, b;
|
|
35
|
+
m[13] === y ? b = m[14] : (b = formatTokens(y), m[13] = y, m[14] = b);
|
|
36
|
+
let x = b;
|
|
37
|
+
v && x && g.push(`${v} in / ${x} out`);
|
|
38
|
+
let S = (h.usage?.cacheReadInputTokens ?? 0) + (h.usage?.cacheCreationInputTokens ?? 0);
|
|
39
|
+
if (S) {
|
|
40
|
+
let e;
|
|
41
|
+
m[15] === S ? e = m[16] : (e = formatTokens(S), m[15] = S, m[16] = e), g.push(`${e} cache`);
|
|
42
|
+
}
|
|
43
|
+
if (h.durationMs != null) {
|
|
44
|
+
let e = h.durationMs / 1e3, _;
|
|
45
|
+
m[17] === e ? _ = m[18] : (_ = e.toFixed(1), m[17] = e, m[18] = _), g.push(`${_}s`);
|
|
46
|
+
}
|
|
47
|
+
h.model && g.push(h.model), m[0] = h.costUsd, m[1] = h.durationMs, m[2] = h.model, m[3] = h.numTurns, m[4] = h.usage?.cacheCreationInputTokens, m[5] = h.usage?.cacheReadInputTokens, m[6] = h.usage?.inputTokens, m[7] = h.usage?.outputTokens, m[8] = g;
|
|
48
|
+
} else g = m[8];
|
|
49
|
+
if (!g.length) return null;
|
|
50
|
+
let _ = g.join(" · "), v;
|
|
51
|
+
return m[19] === _ ? v = m[20] : (v = /* @__PURE__ */ jsx("div", {
|
|
52
|
+
className: "text-muted-foreground mt-1 px-1 font-mono text-xs",
|
|
53
|
+
children: _
|
|
54
|
+
}), m[19] = _, m[20] = v), v;
|
|
21
55
|
};
|
|
22
56
|
function hasStructuredBlocks(e) {
|
|
23
57
|
return !!e?.some((e) => e.type !== "text");
|
|
@@ -25,81 +59,87 @@ function hasStructuredBlocks(e) {
|
|
|
25
59
|
function textFromBlocks(e) {
|
|
26
60
|
return (e ?? []).filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
27
61
|
}
|
|
28
|
-
var LlmMessage_default = (
|
|
29
|
-
let
|
|
30
|
-
if (!hasStructuredBlocks(
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
62
|
+
var LlmMessage_default = (m) => {
|
|
63
|
+
let h = c(31), { document: w } = m, T = w.content, E = T.id ?? w.id, D = !!w.meta?.streaming;
|
|
64
|
+
if (!hasStructuredBlocks(T.blocks)) {
|
|
65
|
+
let m;
|
|
66
|
+
h[0] !== T.blocks || h[1] !== T.text ? (m = T.text ?? textFromBlocks(T.blocks), h[0] = T.blocks, h[1] = T.text, h[2] = m) : m = h[2];
|
|
67
|
+
let v = m, y;
|
|
68
|
+
h[3] !== D || h[4] !== v ? (y = /* @__PURE__ */ jsx(MessageContent, { children: D ? /* @__PURE__ */ jsx(StreamingText, { text: v }) : /* @__PURE__ */ jsx(MessageResponse, { children: v }) }), h[3] = D, h[4] = v, h[5] = y) : y = h[5];
|
|
69
|
+
let b;
|
|
70
|
+
h[6] !== D || h[7] !== T.role || h[8] !== v ? (b = T.role === "assistant" && !D && /* @__PURE__ */ jsx(CopyActions, { text: v }), h[6] = D, h[7] = T.role, h[8] = v, h[9] = b) : b = h[9];
|
|
35
71
|
let x;
|
|
36
|
-
|
|
72
|
+
h[10] !== T.role || h[11] !== y || h[12] !== b ? (x = /* @__PURE__ */ jsxs(Message, {
|
|
73
|
+
from: T.role,
|
|
74
|
+
children: [y, b]
|
|
75
|
+
}), h[10] = T.role, h[11] = y, h[12] = b, h[13] = x) : x = h[13];
|
|
37
76
|
let S;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}), g[10] = w.role, g[11] = b, g[12] = x, g[13] = S) : S = g[13], S;
|
|
77
|
+
h[14] === T.meta ? S = h[15] : (S = T.meta && /* @__PURE__ */ jsx(CompletionMeta, { meta: T.meta }), h[14] = T.meta, h[15] = S);
|
|
78
|
+
let C;
|
|
79
|
+
return h[16] !== x || h[17] !== S ? (C = /* @__PURE__ */ jsxs(Fragment, { children: [x, S] }), h[16] = x, h[17] = S, h[18] = C) : C = h[18], C;
|
|
42
80
|
}
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
switch (
|
|
81
|
+
let O;
|
|
82
|
+
h[19] === T.blocks ? O = h[20] : (O = T.blocks ?? [], h[19] = T.blocks, h[20] = O);
|
|
83
|
+
let k = O, A;
|
|
84
|
+
h[21] !== k || h[22] !== D || h[23] !== T.role || h[24] !== E ? (A = k.map((m, h) => {
|
|
85
|
+
switch (m.type) {
|
|
48
86
|
case "text": return /* @__PURE__ */ jsxs(Message, {
|
|
49
|
-
from:
|
|
50
|
-
children: [/* @__PURE__ */ jsx(MessageContent, { children:
|
|
51
|
-
}, `${
|
|
87
|
+
from: T.role,
|
|
88
|
+
children: [/* @__PURE__ */ jsx(MessageContent, { children: D ? /* @__PURE__ */ jsx(StreamingText, { text: m.text }) : /* @__PURE__ */ jsx(MessageResponse, { children: m.text }) }), T.role === "assistant" && !D && /* @__PURE__ */ jsx(CopyActions, { text: m.text })]
|
|
89
|
+
}, `${E}-${h}`);
|
|
52
90
|
case "thinking": return /* @__PURE__ */ jsxs(Reasoning, {
|
|
53
91
|
className: "w-full",
|
|
54
|
-
isStreaming:
|
|
55
|
-
children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children:
|
|
56
|
-
}, `${
|
|
92
|
+
isStreaming: D,
|
|
93
|
+
children: [/* @__PURE__ */ jsx(ReasoningTrigger, {}), /* @__PURE__ */ jsx(ReasoningContent, { children: m.text })]
|
|
94
|
+
}, `${E}-${h}`);
|
|
57
95
|
case "tool_call": return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
|
|
58
96
|
from: "assistant",
|
|
59
97
|
children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
|
|
60
98
|
state: "input-available",
|
|
61
|
-
title:
|
|
99
|
+
title: m.name,
|
|
62
100
|
type: "tool-call"
|
|
63
|
-
}), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolInput, { input:
|
|
64
|
-
}) }, `${
|
|
101
|
+
}), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolInput, { input: m.args }) })] })
|
|
102
|
+
}) }, `${E}-${h}`);
|
|
65
103
|
case "tool_result": {
|
|
66
|
-
let
|
|
104
|
+
let g;
|
|
67
105
|
try {
|
|
68
|
-
|
|
106
|
+
g = JSON.parse(m.content);
|
|
69
107
|
} catch {
|
|
70
|
-
|
|
108
|
+
g = m.content;
|
|
71
109
|
}
|
|
72
110
|
return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
|
|
73
111
|
from: "assistant",
|
|
74
112
|
children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
|
|
75
|
-
state:
|
|
113
|
+
state: m.isError ? "output-error" : "output-available",
|
|
76
114
|
title: "Tool Result",
|
|
77
115
|
type: "tool-call"
|
|
78
116
|
}), /* @__PURE__ */ jsx(ToolContent, { children: /* @__PURE__ */ jsx(ToolOutput, {
|
|
79
|
-
output:
|
|
80
|
-
errorText:
|
|
117
|
+
output: g,
|
|
118
|
+
errorText: m.isError ? m.content : ""
|
|
81
119
|
}) })] })
|
|
82
|
-
}) }, `${
|
|
120
|
+
}) }, `${E}-${h}`);
|
|
83
121
|
}
|
|
84
122
|
case "server_tool_use": {
|
|
85
|
-
let
|
|
123
|
+
let g = k.find((e) => e.type === "server_tool_result" && e.toolUseId === m.id);
|
|
86
124
|
return /* @__PURE__ */ jsx(FadeInBlock, { children: /* @__PURE__ */ jsx(Message, {
|
|
87
125
|
from: "assistant",
|
|
88
126
|
children: /* @__PURE__ */ jsxs(Tool, { children: [/* @__PURE__ */ jsx(ToolHeader, {
|
|
89
|
-
state:
|
|
90
|
-
title:
|
|
127
|
+
state: g ? "output-available" : "input-available",
|
|
128
|
+
title: m.name,
|
|
91
129
|
type: "tool-call"
|
|
92
|
-
}), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, { input:
|
|
93
|
-
output:
|
|
130
|
+
}), /* @__PURE__ */ jsxs(ToolContent, { children: [/* @__PURE__ */ jsx(ToolInput, { input: m.input }), g && /* @__PURE__ */ jsx(ToolOutput, {
|
|
131
|
+
output: g.content,
|
|
94
132
|
errorText: ""
|
|
95
133
|
})] })] })
|
|
96
|
-
}) }, `${
|
|
134
|
+
}) }, `${E}-${h}`);
|
|
97
135
|
}
|
|
98
136
|
case "server_tool_result": return null;
|
|
99
137
|
default: return null;
|
|
100
138
|
}
|
|
101
|
-
}),
|
|
102
|
-
let
|
|
103
|
-
|
|
139
|
+
}), h[21] = k, h[22] = D, h[23] = T.role, h[24] = E, h[25] = A) : A = h[25];
|
|
140
|
+
let j;
|
|
141
|
+
h[26] === T.meta ? j = h[27] : (j = T.meta && /* @__PURE__ */ jsx(CompletionMeta, { meta: T.meta }), h[26] = T.meta, h[27] = j);
|
|
142
|
+
let M;
|
|
143
|
+
return h[28] !== A || h[29] !== j ? (M = /* @__PURE__ */ jsxs(Fragment, { children: [A, j] }), h[28] = A, h[29] = j, h[30] = M) : M = h[30], M;
|
|
104
144
|
};
|
|
105
145
|
export { LlmMessage_default as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { parseAnsi } from "./ansi.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var TerminalMessageRenderer_default = (s) => {
|
|
6
|
+
let l = c(14), { document: u } = s, { text: d, title: f } = u.content, p = d ?? "", m;
|
|
7
|
+
l[0] === p ? m = l[1] : (m = parseAnsi(p), l[0] = p, l[1] = m);
|
|
8
|
+
let h = m, g = useRef(null), _;
|
|
9
|
+
l[2] === Symbol.for("react.memo_cache_sentinel") ? (_ = () => {
|
|
10
|
+
let e = g.current;
|
|
11
|
+
e && (e.scrollTop = e.scrollHeight);
|
|
12
|
+
}, l[2] = _) : _ = l[2];
|
|
13
|
+
let v;
|
|
14
|
+
l[3] === d ? v = l[4] : (v = [d], l[3] = d, l[4] = v), useEffect(_, v);
|
|
15
|
+
let y;
|
|
16
|
+
l[5] === f ? y = l[6] : (y = f && /* @__PURE__ */ jsxs("div", {
|
|
17
|
+
className: "flex items-center gap-2 border-b border-white/10 px-3 py-1.5",
|
|
18
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
19
|
+
className: "flex gap-1.5",
|
|
20
|
+
"aria-hidden": !0,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsx("span", { className: "h-2.5 w-2.5 rounded-full bg-[#ff5f56]" }),
|
|
23
|
+
/* @__PURE__ */ jsx("span", { className: "h-2.5 w-2.5 rounded-full bg-[#ffbd2e]" }),
|
|
24
|
+
/* @__PURE__ */ jsx("span", { className: "h-2.5 w-2.5 rounded-full bg-[#27c93f]" })
|
|
25
|
+
]
|
|
26
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
27
|
+
className: "font-mono text-xs text-white/60",
|
|
28
|
+
children: f
|
|
29
|
+
})]
|
|
30
|
+
}), l[5] = f, l[6] = y);
|
|
31
|
+
let b;
|
|
32
|
+
l[7] === h ? b = l[8] : (b = h.map(_temp), l[7] = h, l[8] = b);
|
|
33
|
+
let x;
|
|
34
|
+
l[9] === b ? x = l[10] : (x = /* @__PURE__ */ jsx("pre", {
|
|
35
|
+
ref: g,
|
|
36
|
+
className: "max-h-96 overflow-auto px-3 py-2 font-mono text-xs leading-relaxed whitespace-pre-wrap text-[#d4d4d4]",
|
|
37
|
+
children: b
|
|
38
|
+
}), l[9] = b, l[10] = x);
|
|
39
|
+
let S;
|
|
40
|
+
return l[11] !== y || l[12] !== x ? (S = /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: "mb-4 overflow-hidden rounded-lg border border-black/30 bg-[#1e1e1e] shadow-sm",
|
|
42
|
+
children: [y, x]
|
|
43
|
+
}), l[11] = y, l[12] = x, l[13] = S) : S = l[13], S;
|
|
44
|
+
};
|
|
45
|
+
function _temp(e, o) {
|
|
46
|
+
return /* @__PURE__ */ jsx("span", {
|
|
47
|
+
style: e.style,
|
|
48
|
+
children: e.text
|
|
49
|
+
}, o);
|
|
50
|
+
}
|
|
51
|
+
export { TerminalMessageRenderer_default as default };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var PALETTE_16 = [
|
|
2
|
+
"#000000",
|
|
3
|
+
"#cd3131",
|
|
4
|
+
"#0dbc79",
|
|
5
|
+
"#e5e510",
|
|
6
|
+
"#2472c8",
|
|
7
|
+
"#bc3fbc",
|
|
8
|
+
"#11a8cd",
|
|
9
|
+
"#e5e5e5",
|
|
10
|
+
"#666666",
|
|
11
|
+
"#f14c4c",
|
|
12
|
+
"#23d18b",
|
|
13
|
+
"#f5f543",
|
|
14
|
+
"#3b8eea",
|
|
15
|
+
"#d670d6",
|
|
16
|
+
"#29b8db",
|
|
17
|
+
"#ffffff"
|
|
18
|
+
], CUBE_STEPS = [
|
|
19
|
+
0,
|
|
20
|
+
95,
|
|
21
|
+
135,
|
|
22
|
+
175,
|
|
23
|
+
215,
|
|
24
|
+
255
|
|
25
|
+
];
|
|
26
|
+
function xterm256ToHex(n) {
|
|
27
|
+
if (n < 16) return PALETTE_16[n];
|
|
28
|
+
if (n <= 231) {
|
|
29
|
+
let e = n - 16;
|
|
30
|
+
return `rgb(${CUBE_STEPS[Math.floor(e / 36) % 6]}, ${CUBE_STEPS[Math.floor(e / 6) % 6]}, ${CUBE_STEPS[e % 6]})`;
|
|
31
|
+
}
|
|
32
|
+
let r = 8 + (n - 232) * 10;
|
|
33
|
+
return `rgb(${r}, ${r}, ${r})`;
|
|
34
|
+
}
|
|
35
|
+
function apply(t, r) {
|
|
36
|
+
for (let i = 0; i < r.length; i++) {
|
|
37
|
+
let a = r[i];
|
|
38
|
+
if (a === 0) t.fg = t.bg = void 0, t.bold = t.dim = t.italic = t.underline = !1;
|
|
39
|
+
else if (a === 1) t.bold = !0;
|
|
40
|
+
else if (a === 2) t.dim = !0;
|
|
41
|
+
else if (a === 3) t.italic = !0;
|
|
42
|
+
else if (a === 4) t.underline = !0;
|
|
43
|
+
else if (a === 22) t.bold = t.dim = !1;
|
|
44
|
+
else if (a === 23) t.italic = !1;
|
|
45
|
+
else if (a === 24) t.underline = !1;
|
|
46
|
+
else if (a >= 30 && a <= 37) t.fg = PALETTE_16[a - 30];
|
|
47
|
+
else if (a >= 90 && a <= 97) t.fg = PALETTE_16[a - 90 + 8];
|
|
48
|
+
else if (a === 39) t.fg = void 0;
|
|
49
|
+
else if (a >= 40 && a <= 47) t.bg = PALETTE_16[a - 40];
|
|
50
|
+
else if (a >= 100 && a <= 107) t.bg = PALETTE_16[a - 100 + 8];
|
|
51
|
+
else if (a === 49) t.bg = void 0;
|
|
52
|
+
else if (a === 38 || a === 48) {
|
|
53
|
+
let e = a === 38 ? "fg" : "bg";
|
|
54
|
+
r[i + 1] === 5 ? (t[e] = xterm256ToHex(r[i + 2]), i += 2) : r[i + 1] === 2 && (t[e] = `rgb(${r[i + 2]}, ${r[i + 3]}, ${r[i + 4]})`, i += 4);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function toStyle(t) {
|
|
59
|
+
let n = {}, r = t.fg;
|
|
60
|
+
if (t.bold && r) {
|
|
61
|
+
let t = PALETTE_16.indexOf(r);
|
|
62
|
+
t >= 0 && t < 8 && (r = PALETTE_16[t + 8]);
|
|
63
|
+
}
|
|
64
|
+
return r && (n.color = r), t.bg && (n.backgroundColor = t.bg), t.bold && (n.fontWeight = 700), t.dim && (n.opacity = .6), t.italic && (n.fontStyle = "italic"), t.underline && (n.textDecoration = "underline"), n;
|
|
65
|
+
}
|
|
66
|
+
var SGR = /\x1b\[([0-9;]*)m/g;
|
|
67
|
+
function parseAnsi(e) {
|
|
68
|
+
let t = [], n = {}, o = 0, s, c = (e) => {
|
|
69
|
+
e && t.push({
|
|
70
|
+
text: e,
|
|
71
|
+
style: toStyle(n)
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
for (SGR.lastIndex = 0; (s = SGR.exec(e)) !== null;) c(e.slice(o, s.index)), apply(n, s[1] === "" ? [0] : s[1].split(";").map((e) => Number(e) || 0)), o = SGR.lastIndex;
|
|
75
|
+
return c(e.slice(o)), t;
|
|
76
|
+
}
|
|
77
|
+
export { parseAnsi };
|