@marimo-team/islands 0.25.3-dev402 → 0.25.3-dev408
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/{ConnectedDataExplorerComponent-1DGGwl88.js → ConnectedDataExplorerComponent-DCW4bXq-.js} +1 -1
- package/dist/{ErrorBoundary-DfbzIKA3.js → ErrorBoundary-W6a-7ong.js} +1 -1
- package/dist/{chat-ui-r3PPIMn0.js → chat-ui-BGEXB6V4.js} +1354 -1320
- package/dist/{code-visibility-CXijswY7.js → code-visibility-0v5rL9iu.js} +1 -1
- package/dist/{common-Cm5ENbUw.js → common-B7sS0asw.js} +1 -1
- package/dist/{data-grid-overlay-editor-Dv0TkGKt.js → data-grid-overlay-editor-DtWpYC-j.js} +1 -1
- package/dist/{feedback-button-Xk-mOev4.js → feedback-button-KVSGwnVr.js} +2 -2
- package/dist/{glide-data-editor-DdxBDWAj.js → glide-data-editor-D0dykzDr.js} +3 -3
- package/dist/{globals-DR3VVkF6.js → globals-DOi11Nup.js} +1 -1
- package/dist/main.js +6160 -6141
- package/dist/{number-overlay-editor-Cc5gJryh.js → number-overlay-editor-DoR-BTMn.js} +1 -1
- package/dist/{process-output-39KkAXSF.js → process-output-BvCDoG-m.js} +14 -25
- package/dist/{reveal-component-Dm5K9KPi.js → reveal-component-Vu8VncD4.js} +2 -2
- package/dist/{spec-Ww0JjShW.js → spec-DV8oNpRR.js} +46 -49
- package/dist/{semaphore-8KhQouXt.js → useDeepCompareMemoize-C90a6_io.js} +15 -5
- package/dist/{vega-component-DQZhTzVQ.js → vega-component-ArEoBGzQ.js} +197 -198
- package/package.json +1 -1
- package/src/components/chat/__tests__/chat-utils.test.ts +48 -0
- package/src/components/chat/__tests__/message-queue.test.tsx +94 -1
- package/src/components/chat/__tests__/pending-chat-prompt.test.tsx +568 -0
- package/src/components/chat/__tests__/useFileState.test.tsx +176 -15
- package/src/components/chat/chat-components.tsx +3 -2
- package/src/components/chat/chat-panel.tsx +199 -74
- package/src/components/chat/chat-utils.ts +148 -34
- package/src/components/chat/user-message.tsx +15 -6
- package/src/components/data-table/charts/__tests__/altair-generator.test.ts +42 -27
- package/src/components/data-table/charts/chart-spec/altair-generator.ts +2 -6
- package/src/core/ai/__tests__/attachments.test.ts +153 -0
- package/src/core/ai/attachments.ts +80 -0
- package/src/utils/python-poet/poet.ts +12 -2
- package/dist/useDeepCompareMemoize-Bvrue1iy.js +0 -11
|
@@ -9,7 +9,7 @@ import { d as de } from "./select-DW32QOzC.js";
|
|
|
9
9
|
import { Cn as fe, _ as pe, f as me, h as he, i as ge, n as _e, t as ve, xn as ye } from "./dropdown-menu-CmgUseHo.js";
|
|
10
10
|
import { a as be, l as xe } from "./config-DOwBtRkI.js";
|
|
11
11
|
import { $ as Se, Ct as Ce, P as we, Rt as Te, W as Ee, en as De, h as Oe, i as ke, j as Ae, ot as je, r as Me, t as Ne } from "./error-entries-5kRrE4vX.js";
|
|
12
|
-
import {
|
|
12
|
+
import { c as Pe, d as Fe, l as Ie, n as Le, t as Re, u as ze } from "./process-output-BvCDoG-m.js";
|
|
13
13
|
import { t as Be } from "./pencil-CijoRsa3.js";
|
|
14
14
|
import { n as Ve, r as He, s as Ue } from "./assertNever-DXGfUmPW.js";
|
|
15
15
|
import { t as We } from "./jsx-runtime-D8btoEHk.js";
|
|
@@ -3684,1263 +3684,1297 @@ function ja() {
|
|
|
3684
3684
|
return Date.now();
|
|
3685
3685
|
}
|
|
3686
3686
|
//#endregion
|
|
3687
|
-
//#region src/
|
|
3688
|
-
var Ma =
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
let e = this.store.get(Oe);
|
|
3698
|
-
return e.cellIds.map((t, n) => {
|
|
3699
|
-
let r = e.cellData[t];
|
|
3700
|
-
return {
|
|
3701
|
-
uri: this.asURI(t),
|
|
3702
|
-
name: je(r.name, n),
|
|
3703
|
-
type: this.contextType,
|
|
3704
|
-
description: "Cell code",
|
|
3705
|
-
data: {
|
|
3706
|
-
cellId: t,
|
|
3707
|
-
code: r.code
|
|
3708
|
-
}
|
|
3709
|
-
};
|
|
3710
|
-
});
|
|
3711
|
-
}
|
|
3712
|
-
formatCompletion(e) {
|
|
3713
|
-
return {
|
|
3714
|
-
...this.createBasicCompletion(e),
|
|
3715
|
-
label: `${this.mentionPrefix}${e.name}`
|
|
3716
|
-
};
|
|
3687
|
+
//#region src/components/chat/chat-components.tsx
|
|
3688
|
+
var Ma = (e) => {
|
|
3689
|
+
let t = (0, I.c)(6), { attachment: n } = e;
|
|
3690
|
+
if (n.mediaType?.startsWith("image/")) {
|
|
3691
|
+
let e = n.filename || "Attachment", r;
|
|
3692
|
+
return t[0] !== n.url || t[1] !== e ? (r = /* @__PURE__ */ (0, Z.jsx)("img", {
|
|
3693
|
+
src: n.url,
|
|
3694
|
+
alt: e,
|
|
3695
|
+
className: "max-h-[100px] max-w-[100px] object-contain mb-1.5"
|
|
3696
|
+
}), t[0] = n.url, t[1] = e, t[2] = r) : r = t[2], r;
|
|
3717
3697
|
}
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3698
|
+
let r;
|
|
3699
|
+
t[3] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ (0, Z.jsx)(Fe, { className: "h-3 w-3 mt-0.5" }), t[3] = r) : r = t[3];
|
|
3700
|
+
let i = n.filename || "Attachment", a;
|
|
3701
|
+
return t[4] === i ? a = t[5] : (a = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3702
|
+
className: "flex flex-row gap-1 items-center text-xs",
|
|
3703
|
+
children: [r, i]
|
|
3704
|
+
}), t[4] = i, t[5] = a), a;
|
|
3705
|
+
}, Na = (e) => {
|
|
3706
|
+
let t = (0, I.c)(15), { icon: n, title: r, subtitle: i, href: a } = e, o;
|
|
3707
|
+
t[0] === r ? o = t[1] : (o = /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
3708
|
+
className: "truncate font-medium",
|
|
3709
|
+
children: r
|
|
3710
|
+
}), t[0] = r, t[1] = o);
|
|
3711
|
+
let s;
|
|
3712
|
+
t[2] === i ? s = t[3] : (s = i && /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
3713
|
+
className: "truncate opacity-70",
|
|
3714
|
+
children: [
|
|
3715
|
+
"(",
|
|
3716
|
+
i,
|
|
3717
|
+
")"
|
|
3718
|
+
]
|
|
3719
|
+
}), t[2] = i, t[3] = s);
|
|
3720
|
+
let c;
|
|
3721
|
+
t[4] !== n || t[5] !== o || t[6] !== s ? (c = /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [
|
|
3722
|
+
n,
|
|
3723
|
+
o,
|
|
3724
|
+
s
|
|
3725
|
+
] }), t[4] = n, t[5] = o, t[6] = s, t[7] = c) : c = t[7];
|
|
3726
|
+
let l = c;
|
|
3727
|
+
if (a && be(a)) {
|
|
3728
|
+
let e = i ?? r, n;
|
|
3729
|
+
return t[8] !== l || t[9] !== a || t[10] !== e ? (n = /* @__PURE__ */ (0, Z.jsx)("a", {
|
|
3730
|
+
href: a,
|
|
3731
|
+
target: "_blank",
|
|
3732
|
+
rel: "noopener noreferrer",
|
|
3733
|
+
title: e,
|
|
3734
|
+
className: "inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",
|
|
3735
|
+
children: l
|
|
3736
|
+
}), t[8] = l, t[9] = a, t[10] = e, t[11] = n) : n = t[11], n;
|
|
3727
3737
|
}
|
|
3738
|
+
let u = i ?? r, d;
|
|
3739
|
+
return t[12] !== l || t[13] !== u ? (d = /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
3740
|
+
className: "inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground",
|
|
3741
|
+
title: u,
|
|
3742
|
+
children: l
|
|
3743
|
+
}), t[12] = l, t[13] = u, t[14] = d) : d = t[14], d;
|
|
3728
3744
|
};
|
|
3729
3745
|
//#endregion
|
|
3730
|
-
//#region src/
|
|
3731
|
-
function
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
].some((t) => e.startsWith(t)) || ["svg", "vega"].some((t) => e.includes(t)) || e === "text/html" && [
|
|
3738
|
-
"<img",
|
|
3739
|
-
"<video",
|
|
3740
|
-
"<audio",
|
|
3741
|
-
"<iframe",
|
|
3742
|
-
"<canvas",
|
|
3743
|
-
"<svg",
|
|
3744
|
-
"<marimo-ui-element"
|
|
3745
|
-
].some((e) => t.includes(e))) : !1;
|
|
3746
|
-
}
|
|
3747
|
-
var Pa = class extends A {
|
|
3748
|
-
title = "Cell Outputs";
|
|
3749
|
-
mentionPrefix = "@";
|
|
3750
|
-
contextType = "cell-output";
|
|
3751
|
-
store;
|
|
3752
|
-
constructor(e) {
|
|
3753
|
-
super(), this.store = e;
|
|
3754
|
-
}
|
|
3755
|
-
getItems() {
|
|
3756
|
-
let e = this.store.get(Oe), t = [];
|
|
3757
|
-
for (let n of e.cellIds) {
|
|
3758
|
-
let r = La(n, e, this.store.get(Te(n))), i = r.cellOutput;
|
|
3759
|
-
if (!i) continue;
|
|
3760
|
-
let a = i.output.mimetype || "unknown";
|
|
3761
|
-
t.push({
|
|
3762
|
-
uri: this.asURI(n),
|
|
3763
|
-
name: r.cellName,
|
|
3764
|
-
type: this.contextType,
|
|
3765
|
-
description: `Cell output (${a})`,
|
|
3766
|
-
data: {
|
|
3767
|
-
...r,
|
|
3768
|
-
cellOutput: i
|
|
3769
|
-
}
|
|
3770
|
-
});
|
|
3771
|
-
}
|
|
3772
|
-
return t;
|
|
3773
|
-
}
|
|
3774
|
-
formatCompletion(e) {
|
|
3775
|
-
let { cellOutput: t, cellName: n, cellCode: r } = e.data;
|
|
3776
|
-
return {
|
|
3777
|
-
label: `@${n}`,
|
|
3778
|
-
displayLabel: n,
|
|
3779
|
-
detail: `${t.outputType} output`,
|
|
3780
|
-
boost: t.outputType === "media" ? O.HIGH : O.MEDIUM,
|
|
3781
|
-
type: this.contextType,
|
|
3782
|
-
section: P.CELL_OUTPUT,
|
|
3783
|
-
apply: `@${n}`,
|
|
3784
|
-
info: () => {
|
|
3785
|
-
let e = document.createElement("div");
|
|
3786
|
-
e.classList.add("mo-cm-tooltip", "docs-documentation", "min-w-[300px]", "max-w-[500px]", "flex", "flex-col", "gap-2");
|
|
3787
|
-
let i = document.createElement("div");
|
|
3788
|
-
i.classList.add("flex", "flex-col", "gap-1");
|
|
3789
|
-
let a = document.createElement("div");
|
|
3790
|
-
a.classList.add("font-bold", "text-base"), a.textContent = n, i.append(a);
|
|
3791
|
-
let o = document.createElement("div");
|
|
3792
|
-
if (o.classList.add("text-sm", "text-muted-foreground"), i.append(o), e.append(i), r) {
|
|
3793
|
-
let t = document.createElement("div");
|
|
3794
|
-
t.classList.add("text-xs", "font-medium", "text-muted-foreground"), t.textContent = "Code:", e.append(t);
|
|
3795
|
-
let n = document.createElement("div");
|
|
3796
|
-
n.classList.add("text-xs", "font-mono", "bg-muted", "p-2", "rounded", "max-h-20", "overflow-y-auto"), n.textContent = r.slice(0, 200) + (r.length > 200 ? "..." : ""), e.append(n);
|
|
3797
|
-
}
|
|
3798
|
-
if (t.processedContent) {
|
|
3799
|
-
let n = document.createElement("div");
|
|
3800
|
-
n.classList.add("text-xs", "font-medium", "text-muted-foreground", "mt-2"), n.textContent = "Output Preview:", e.append(n);
|
|
3801
|
-
let r = document.createElement("div");
|
|
3802
|
-
r.classList.add("text-xs", "bg-muted", "p-2", "rounded", "max-h-24", "overflow-y-auto", "mb-2"), r.textContent = t.processedContent.slice(0, 300) + (t.processedContent.length > 300 ? "..." : ""), e.append(r);
|
|
3803
|
-
}
|
|
3804
|
-
if (t.outputType === "media") {
|
|
3805
|
-
let t = document.createElement("div");
|
|
3806
|
-
t.classList.add("text-xs", "text-muted-foreground", "italic", "mb-2"), t.textContent = "A screenshot of the output will be attached", e.append(t);
|
|
3807
|
-
}
|
|
3808
|
-
return e;
|
|
3809
|
-
}
|
|
3810
|
-
};
|
|
3811
|
-
}
|
|
3812
|
-
formatContext(e) {
|
|
3813
|
-
let { cellOutput: t, cellName: n, cellId: r, cellCode: i } = e.data, a = {
|
|
3814
|
-
name: n,
|
|
3815
|
-
cellId: r,
|
|
3816
|
-
outputType: t.outputType,
|
|
3817
|
-
mimetype: t.output.mimetype
|
|
3818
|
-
}, o = `Cell Code:\n${i}\n\n`;
|
|
3819
|
-
return t.outputType === "text" && t.processedContent ? o += `Output:\n${t.processedContent}` : t.outputType === "media" && (o += `Media Output: Contains ${t.output.mimetype} content`, t.imageUrl && (o += `\nImage URL: ${t.imageUrl}`)), N({
|
|
3820
|
-
type: this.contextType,
|
|
3821
|
-
data: a,
|
|
3822
|
-
details: o
|
|
3823
|
-
});
|
|
3824
|
-
}
|
|
3825
|
-
async getAttachments(e) {
|
|
3826
|
-
let t = e[0].data.cellId, n = e[0].data.cellName;
|
|
3827
|
-
return Fa(e.map((e) => e.data.cellOutput), t, n);
|
|
3828
|
-
}
|
|
3829
|
-
};
|
|
3830
|
-
async function Fa(e, t, r) {
|
|
3831
|
-
let i = e.filter((e) => e.shouldDownloadImage && e.outputType === "media");
|
|
3832
|
-
if (i.length === 0) return [];
|
|
3833
|
-
let a = i.flatMap((e) => {
|
|
3834
|
-
let i = document.getElementById(Ce.create(t));
|
|
3835
|
-
return i ? {
|
|
3836
|
-
cellId: t,
|
|
3837
|
-
cellName: r,
|
|
3838
|
-
mimetype: e.output.mimetype,
|
|
3839
|
-
element: i
|
|
3840
|
-
} : (n.warn(`Output element not found for cell ${t}`), []);
|
|
3841
|
-
});
|
|
3842
|
-
try {
|
|
3843
|
-
return await Promise.all(a.map(async (e) => ({
|
|
3844
|
-
type: "file",
|
|
3845
|
-
filename: `${r}-output-screenshot`,
|
|
3846
|
-
mediaType: "image/png",
|
|
3847
|
-
url: await ie(e.element)
|
|
3848
|
-
})));
|
|
3849
|
-
} catch (e) {
|
|
3850
|
-
return n.error("Error downloading cell output images:", e), [];
|
|
3851
|
-
}
|
|
3746
|
+
//#region src/components/chat/chat-markdown.tsx
|
|
3747
|
+
function Pa(e) {
|
|
3748
|
+
let t = (0, I.c)(3), { content: n } = e, r = Ze(ut)?.mode, i = r !== "agent" && r !== "code_mode", a;
|
|
3749
|
+
return t[0] !== n || t[1] !== i ? (a = /* @__PURE__ */ (0, Z.jsx)(re, {
|
|
3750
|
+
content: n,
|
|
3751
|
+
allowNotebookInsertion: i
|
|
3752
|
+
}), t[0] = n, t[1] = i, t[2] = a) : a = t[2], a;
|
|
3852
3753
|
}
|
|
3754
|
+
//#endregion
|
|
3755
|
+
//#region src/components/chat/tool-call/shared.ts
|
|
3756
|
+
var Fa = /* @__PURE__ */ new Set([
|
|
3757
|
+
"input-streaming",
|
|
3758
|
+
"input-available",
|
|
3759
|
+
"approval-responded"
|
|
3760
|
+
]);
|
|
3853
3761
|
function Ia(e) {
|
|
3854
|
-
|
|
3855
|
-
let t = e.mimetype, n = Na(t, String(e.data)) ? "media" : "text", r = Re(e), i, a = !1;
|
|
3856
|
-
return n === "media" && (typeof e.data == "string" && e.data.startsWith("data:") || typeof e.data == "string" && e.data.startsWith("http") ? i = e.data : a = !0), {
|
|
3857
|
-
processedContent: r,
|
|
3858
|
-
imageUrl: i,
|
|
3859
|
-
shouldDownloadImage: a,
|
|
3860
|
-
outputType: n,
|
|
3861
|
-
output: e
|
|
3862
|
-
};
|
|
3863
|
-
}
|
|
3864
|
-
function La(e, t, n, r) {
|
|
3865
|
-
let { includeConsoleOutput: i = !1 } = r || {}, a = t.cellRuntime[e], o = t.cellData[e], s = t.cellIds.indexOf(e), c = je(o.name, s), l;
|
|
3866
|
-
i && (l = a.consoleOutputs.map((e) => Ia(e)).filter((e) => e !== null));
|
|
3867
|
-
let u;
|
|
3868
|
-
return n !== null && !T(n) && (u = Ia(n) ?? void 0), {
|
|
3869
|
-
cellId: e,
|
|
3870
|
-
cellName: c,
|
|
3871
|
-
cellCode: o.code,
|
|
3872
|
-
cellOutput: u,
|
|
3873
|
-
consoleOutputs: l
|
|
3874
|
-
};
|
|
3762
|
+
return e.replace("tool-", "");
|
|
3875
3763
|
}
|
|
3876
3764
|
//#endregion
|
|
3877
|
-
//#region src/
|
|
3878
|
-
|
|
3879
|
-
let n =
|
|
3880
|
-
if (
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
}
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3765
|
+
//#region src/components/chat/tool-call/tool-args.tsx
|
|
3766
|
+
var La = (e) => {
|
|
3767
|
+
let t = (0, I.c)(9), { input: n, label: r } = e, i = r === void 0 ? "Tool Request" : r;
|
|
3768
|
+
if (n == null) return null;
|
|
3769
|
+
let a;
|
|
3770
|
+
t[0] === i ? a = t[1] : (a = /* @__PURE__ */ (0, Z.jsx)("h3", {
|
|
3771
|
+
className: "text-xs font-semibold text-muted-foreground",
|
|
3772
|
+
children: i
|
|
3773
|
+
}), t[0] = i, t[1] = a);
|
|
3774
|
+
let o;
|
|
3775
|
+
t[2] === n ? o = t[3] : (o = JSON.stringify(n, null, 2), t[2] = n, t[3] = o);
|
|
3776
|
+
let s;
|
|
3777
|
+
t[4] === o ? s = t[5] : (s = /* @__PURE__ */ (0, Z.jsx)("pre", {
|
|
3778
|
+
className: "bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64",
|
|
3779
|
+
children: o
|
|
3780
|
+
}), t[4] = o, t[5] = s);
|
|
3781
|
+
let c;
|
|
3782
|
+
return t[6] !== a || t[7] !== s ? (c = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3783
|
+
className: "space-y-2",
|
|
3784
|
+
children: [a, s]
|
|
3785
|
+
}), t[6] = a, t[7] = s, t[8] = c) : c = t[8], c;
|
|
3786
|
+
}, Ra = (e) => {
|
|
3787
|
+
let t = (0, I.c)(27), { toolName: n, input: i, approval: o, onApprove: s, className: c } = e, l;
|
|
3788
|
+
t[0] === c ? l = t[1] : (l = r("rounded-md border border-(--amber-6) bg-(--amber-2) p-3 space-y-3", c), t[0] = c, t[1] = l);
|
|
3789
|
+
let u;
|
|
3790
|
+
t[2] === n ? u = t[3] : (u = Ia(n), t[2] = n, t[3] = u);
|
|
3791
|
+
let d = `Approval required for ${u}`, f;
|
|
3792
|
+
t[4] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ (0, Z.jsx)(Qt, { className: "h-4 w-4 text-(--amber-11) mt-0.5 shrink-0" }), t[4] = f) : f = t[4];
|
|
3793
|
+
let p;
|
|
3794
|
+
t[5] === Symbol.for("react.memo_cache_sentinel") ? (p = /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
3795
|
+
className: "font-semibold",
|
|
3796
|
+
children: "Approval required:"
|
|
3797
|
+
}), t[5] = p) : p = t[5];
|
|
3798
|
+
let m;
|
|
3799
|
+
t[6] === n ? m = t[7] : (m = Ia(n), t[6] = n, t[7] = m);
|
|
3800
|
+
let h;
|
|
3801
|
+
t[8] === m ? h = t[9] : (h = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3802
|
+
className: "flex items-start gap-2",
|
|
3803
|
+
children: [f, /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3804
|
+
className: "text-xs text-(--amber-11) leading-relaxed",
|
|
3805
|
+
children: [
|
|
3806
|
+
p,
|
|
3807
|
+
" ",
|
|
3808
|
+
/* @__PURE__ */ (0, Z.jsx)("code", {
|
|
3809
|
+
className: "font-mono",
|
|
3810
|
+
children: m
|
|
3811
|
+
})
|
|
3812
|
+
]
|
|
3813
|
+
})]
|
|
3814
|
+
}), t[8] = m, t[9] = h);
|
|
3815
|
+
let g;
|
|
3816
|
+
t[10] === i ? g = t[11] : (g = /* @__PURE__ */ (0, Z.jsx)(La, { input: i }), t[10] = i, t[11] = g);
|
|
3817
|
+
let _;
|
|
3818
|
+
t[12] !== o.id || t[13] !== s ? (_ = /* @__PURE__ */ (0, Z.jsx)(a, {
|
|
3819
|
+
size: "xs",
|
|
3820
|
+
variant: "outline",
|
|
3821
|
+
onClick: () => s({
|
|
3822
|
+
id: o.id,
|
|
3823
|
+
approved: !1
|
|
3824
|
+
}),
|
|
3825
|
+
children: "Deny"
|
|
3826
|
+
}), t[12] = o.id, t[13] = s, t[14] = _) : _ = t[14];
|
|
3827
|
+
let v;
|
|
3828
|
+
t[15] !== o.id || t[16] !== s ? (v = /* @__PURE__ */ (0, Z.jsx)(a, {
|
|
3829
|
+
size: "xs",
|
|
3830
|
+
onClick: () => s({
|
|
3831
|
+
id: o.id,
|
|
3832
|
+
approved: !0
|
|
3833
|
+
}),
|
|
3834
|
+
children: "Approve"
|
|
3835
|
+
}), t[15] = o.id, t[16] = s, t[17] = v) : v = t[17];
|
|
3836
|
+
let y;
|
|
3837
|
+
t[18] !== v || t[19] !== _ ? (y = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3838
|
+
className: "flex items-center justify-end gap-2",
|
|
3839
|
+
children: [_, v]
|
|
3840
|
+
}), t[18] = v, t[19] = _, t[20] = y) : y = t[20];
|
|
3841
|
+
let b;
|
|
3842
|
+
return t[21] !== l || t[22] !== y || t[23] !== d || t[24] !== h || t[25] !== g ? (b = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3843
|
+
className: l,
|
|
3844
|
+
role: "alertdialog",
|
|
3845
|
+
"aria-label": d,
|
|
3846
|
+
children: [
|
|
3847
|
+
h,
|
|
3848
|
+
g,
|
|
3849
|
+
y
|
|
3850
|
+
]
|
|
3851
|
+
}), t[21] = l, t[22] = y, t[23] = d, t[24] = h, t[25] = g, t[26] = b) : b = t[26], b;
|
|
3852
|
+
}, za = {
|
|
3853
|
+
get_marimo_rules: {
|
|
3854
|
+
running: "Reading marimo guidelines",
|
|
3855
|
+
done: "Read marimo guidelines",
|
|
3856
|
+
icon: zt
|
|
3857
|
+
},
|
|
3858
|
+
get_active_notebooks: {
|
|
3859
|
+
running: "Listing notebooks",
|
|
3860
|
+
done: "Listed notebooks",
|
|
3861
|
+
icon: Kt
|
|
3862
|
+
},
|
|
3863
|
+
get_lightweight_cell_map: {
|
|
3864
|
+
running: "Reading notebook",
|
|
3865
|
+
done: "Read notebook",
|
|
3866
|
+
icon: Wt
|
|
3867
|
+
},
|
|
3868
|
+
get_cell_runtime_data: {
|
|
3869
|
+
running: "Inspecting cells",
|
|
3870
|
+
done: "Inspected cells",
|
|
3871
|
+
icon: Yt
|
|
3872
|
+
},
|
|
3873
|
+
get_cell_outputs: {
|
|
3874
|
+
running: "Reading cell outputs",
|
|
3875
|
+
done: "Read cell outputs",
|
|
3876
|
+
icon: Yt
|
|
3877
|
+
},
|
|
3878
|
+
get_tables_and_variables: {
|
|
3879
|
+
running: "Reading variables",
|
|
3880
|
+
done: "Read variables",
|
|
3881
|
+
icon: p
|
|
3882
|
+
},
|
|
3883
|
+
get_database_tables: {
|
|
3884
|
+
running: "Reading database tables",
|
|
3885
|
+
done: "Read database tables",
|
|
3886
|
+
icon: le
|
|
3887
|
+
},
|
|
3888
|
+
get_notebook_errors: {
|
|
3889
|
+
running: "Checking for errors",
|
|
3890
|
+
done: "Checked for errors",
|
|
3891
|
+
icon: Ht
|
|
3892
|
+
},
|
|
3893
|
+
lint_notebook: {
|
|
3894
|
+
running: "Linting notebook",
|
|
3895
|
+
done: "Linted notebook",
|
|
3896
|
+
icon: Gt
|
|
3897
|
+
},
|
|
3898
|
+
get_cell_dependency_graph: {
|
|
3899
|
+
running: "Reading dependency graph",
|
|
3900
|
+
done: "Read dependency graph",
|
|
3901
|
+
icon: v
|
|
3909
3902
|
}
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
name: Va(n),
|
|
3926
|
-
type: this.contextType,
|
|
3927
|
-
data: {
|
|
3928
|
-
type: "cell-error",
|
|
3929
|
-
error: n
|
|
3930
|
-
},
|
|
3931
|
-
description: Ba(n)
|
|
3932
|
-
});
|
|
3933
|
-
return t;
|
|
3903
|
+
}, Ba = {
|
|
3904
|
+
add_cell: {
|
|
3905
|
+
running: "Adding cell",
|
|
3906
|
+
done: "Added cell",
|
|
3907
|
+
icon: ye
|
|
3908
|
+
},
|
|
3909
|
+
update_cell: {
|
|
3910
|
+
running: "Editing cell",
|
|
3911
|
+
done: "Edited cell",
|
|
3912
|
+
icon: Be
|
|
3913
|
+
},
|
|
3914
|
+
delete_cell: {
|
|
3915
|
+
running: "Deleting cell",
|
|
3916
|
+
done: "Deleted cell",
|
|
3917
|
+
icon: f
|
|
3934
3918
|
}
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
e.classList.add("mo-cm-tooltip", "docs-documentation", "min-w-[200px]", "flex", "flex-col", "gap-1", "p-2");
|
|
3948
|
-
let n = document.createElement("div");
|
|
3949
|
-
n.classList.add("flex", "flex-col", "gap-1");
|
|
3950
|
-
let r = document.createElement("div");
|
|
3951
|
-
r.classList.add("font-bold", "text-base"), r.textContent = "Errors", n.append(r);
|
|
3952
|
-
let i = document.createElement("div");
|
|
3953
|
-
return i.classList.add("text-sm", "text-muted-foreground"), i.textContent = `${t} ${Ha.pluralize(t)}`, n.append(i), e.append(n), e;
|
|
3954
|
-
}
|
|
3955
|
-
};
|
|
3956
|
-
}
|
|
3957
|
-
if (e.data.type === "cell-error") {
|
|
3958
|
-
let { error: t } = e.data;
|
|
3919
|
+
};
|
|
3920
|
+
function Va(e, t, n) {
|
|
3921
|
+
let r = Ia(e);
|
|
3922
|
+
if (r === "execute_code") return {
|
|
3923
|
+
label: n === "running" ? "Running code" : "Ran code",
|
|
3924
|
+
detail: Wa(t) ? Ua(t.code) : void 0,
|
|
3925
|
+
icon: j
|
|
3926
|
+
};
|
|
3927
|
+
if (r === "edit_notebook_tool") {
|
|
3928
|
+
let e = Ha(t);
|
|
3929
|
+
if (e) {
|
|
3930
|
+
let t = Ba[e.type];
|
|
3959
3931
|
return {
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
}),
|
|
3964
|
-
section: P.ERROR
|
|
3932
|
+
label: t[n],
|
|
3933
|
+
detail: Ua(e.code),
|
|
3934
|
+
icon: t.icon
|
|
3965
3935
|
};
|
|
3966
3936
|
}
|
|
3967
3937
|
return {
|
|
3968
|
-
label: "
|
|
3969
|
-
|
|
3970
|
-
section: P.ERROR
|
|
3938
|
+
label: n === "running" ? "Editing notebook" : "Edited notebook",
|
|
3939
|
+
icon: Be
|
|
3971
3940
|
};
|
|
3972
3941
|
}
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
defaultResultsLimit: 5,
|
|
3980
|
-
includeDirectories: !1
|
|
3981
|
-
}, Ka = class extends A {
|
|
3982
|
-
title = "Files";
|
|
3983
|
-
mentionPrefix = "#";
|
|
3984
|
-
contextType = "file";
|
|
3985
|
-
apiRequests;
|
|
3986
|
-
config;
|
|
3987
|
-
constructor(e, t = Ga) {
|
|
3988
|
-
super(), this.apiRequests = e, this.config = t;
|
|
3942
|
+
if (Object.hasOwn(za, r)) {
|
|
3943
|
+
let e = za[r];
|
|
3944
|
+
return {
|
|
3945
|
+
label: e[n],
|
|
3946
|
+
icon: e.icon
|
|
3947
|
+
};
|
|
3989
3948
|
}
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
let r = t.text;
|
|
3995
|
-
if (!r.startsWith("#")) return null;
|
|
3996
|
-
let i = r.slice(1);
|
|
3997
|
-
if (i.length === 0) return this.getDefaultCompletions(t);
|
|
3998
|
-
try {
|
|
3999
|
-
let e = (await this.searchFiles(i) || []).map((e) => {
|
|
4000
|
-
let t = {
|
|
4001
|
-
uri: this.asURI(e.path),
|
|
4002
|
-
name: e.name,
|
|
4003
|
-
type: this.contextType,
|
|
4004
|
-
description: e.isDirectory ? "Directory" : "File",
|
|
4005
|
-
data: {
|
|
4006
|
-
path: e.path,
|
|
4007
|
-
isDirectory: e.isDirectory
|
|
4008
|
-
}
|
|
4009
|
-
};
|
|
4010
|
-
return this.formatCompletion(t);
|
|
4011
|
-
});
|
|
4012
|
-
return {
|
|
4013
|
-
from: t.from,
|
|
4014
|
-
options: e
|
|
4015
|
-
};
|
|
4016
|
-
} catch (e) {
|
|
4017
|
-
return n.error("Failed to search files:", e), null;
|
|
4018
|
-
}
|
|
4019
|
-
};
|
|
4020
|
-
}
|
|
4021
|
-
searchFiles = async (e, t = {}) => {
|
|
4022
|
-
let { maxDepth: n, maxResults: r, includeDirectories: i } = {
|
|
4023
|
-
...this.config,
|
|
4024
|
-
...t
|
|
4025
|
-
};
|
|
4026
|
-
return (await this.apiRequests.sendSearchFiles({
|
|
4027
|
-
query: e,
|
|
4028
|
-
includeFiles: !0,
|
|
4029
|
-
includeDirectories: i,
|
|
4030
|
-
depth: n,
|
|
4031
|
-
limit: r
|
|
4032
|
-
})).files;
|
|
3949
|
+
return {
|
|
3950
|
+
label: n === "running" ? "Calling" : "Called",
|
|
3951
|
+
detail: r,
|
|
3952
|
+
icon: b
|
|
4033
3953
|
};
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
}
|
|
4117
|
-
};
|
|
4118
|
-
}
|
|
4119
|
-
formatContext(e) {
|
|
4120
|
-
let { data: t, name: n } = e;
|
|
4121
|
-
return N({
|
|
4122
|
-
type: this.contextType,
|
|
4123
|
-
data: {
|
|
4124
|
-
name: n,
|
|
4125
|
-
path: t.path,
|
|
4126
|
-
isDirectory: t.isDirectory
|
|
4127
|
-
},
|
|
4128
|
-
details: t.isDirectory ? "Directory containing files and subdirectories" : "File"
|
|
4129
|
-
});
|
|
4130
|
-
}
|
|
4131
|
-
}, qa = class extends A {
|
|
4132
|
-
title = "Tables";
|
|
4133
|
-
mentionPrefix = "@";
|
|
4134
|
-
contextType = "data";
|
|
4135
|
-
tablesMap;
|
|
4136
|
-
constructor(e) {
|
|
4137
|
-
super(), this.tablesMap = e;
|
|
4138
|
-
}
|
|
4139
|
-
getItems() {
|
|
4140
|
-
return [...this.tablesMap.entries()].map(([e, t]) => ({
|
|
4141
|
-
uri: this.asURI(e),
|
|
4142
|
-
name: e,
|
|
4143
|
-
type: this.contextType,
|
|
4144
|
-
description: t.source === "memory" ? "in-memory" : t.source,
|
|
4145
|
-
data: t
|
|
4146
|
-
}));
|
|
4147
|
-
}
|
|
4148
|
-
formatContext(e) {
|
|
4149
|
-
let { data: t } = e, { columns: n, source: r, num_rows: i, num_columns: a, name: o, variable_name: s } = t, c = [i == null ? void 0 : `${i} rows`, a == null ? void 0 : `${a} columns`].filter(Boolean).join(", "), l = "";
|
|
4150
|
-
if (c && (l += `Shape: ${c}\n`), s && (l += `Variable: ${s}\n`), n && n.length > 0) {
|
|
4151
|
-
l += "Columns:\n";
|
|
4152
|
-
for (let e of n) {
|
|
4153
|
-
let t = ` ${e.name} (${e.type})`;
|
|
4154
|
-
if (e.sample_values && e.sample_values.length > 0) {
|
|
4155
|
-
let n = e.sample_values.slice(0, 3).map((e) => e === null ? "null" : String(e)).join(", ");
|
|
4156
|
-
t += ` - samples: [${n}]`;
|
|
4157
|
-
}
|
|
4158
|
-
l += `${t}\n`;
|
|
4159
|
-
}
|
|
4160
|
-
}
|
|
4161
|
-
return N({
|
|
4162
|
-
type: this.contextType,
|
|
4163
|
-
data: {
|
|
4164
|
-
name: o,
|
|
4165
|
-
source: r ?? "unknown"
|
|
4166
|
-
},
|
|
4167
|
-
details: l.trim()
|
|
4168
|
-
});
|
|
4169
|
-
}
|
|
4170
|
-
formatCompletion(e) {
|
|
4171
|
-
let t = e.data.name, n = e.data;
|
|
4172
|
-
return {
|
|
4173
|
-
label: `@${t}`,
|
|
4174
|
-
displayLabel: t,
|
|
4175
|
-
detail: n.source === "memory" ? "in-memory" : n.source,
|
|
4176
|
-
boost: n.source_type === "local" ? O.LOCAL_TABLE : O.REMOTE_TABLE,
|
|
4177
|
-
type: ae(n),
|
|
4178
|
-
apply: `@${t}`,
|
|
4179
|
-
section: {
|
|
4180
|
-
name: ae(n) === "dataframe" ? "Dataframe" : "Table",
|
|
4181
|
-
rank: P.TABLE.rank
|
|
4182
|
-
},
|
|
4183
|
-
info: () => this.createTableInfoElement(t, n)
|
|
4184
|
-
};
|
|
4185
|
-
}
|
|
4186
|
-
createTableInfoElement(e, t) {
|
|
4187
|
-
let n = document.createElement("div");
|
|
4188
|
-
n.classList.add("mo-cm-tooltip", "docs-documentation", "min-w-[200px]", "flex", "flex-col", "gap-1", "p-2");
|
|
4189
|
-
let r = document.createElement("div");
|
|
4190
|
-
r.classList.add("flex", "flex-col", "gap-1");
|
|
4191
|
-
let i = document.createElement("div");
|
|
4192
|
-
if (i.classList.add("font-bold", "text-base"), i.textContent = e, r.append(i), t.source) {
|
|
4193
|
-
let e = document.createElement("div");
|
|
4194
|
-
e.classList.add("text-xs", "text-muted-foreground"), e.textContent = `Source: ${t.source}`, r.append(e);
|
|
4195
|
-
}
|
|
4196
|
-
n.append(r);
|
|
4197
|
-
let a = [t.num_rows == null ? void 0 : `${t.num_rows} rows`, t.num_columns == null ? void 0 : `${t.num_columns} columns`].filter(Boolean).join(", ");
|
|
4198
|
-
if (a) {
|
|
4199
|
-
let e = document.createElement("div");
|
|
4200
|
-
e.classList.add("text-xs", "bg-muted", "px-2", "py-1", "rounded"), e.textContent = a, n.append(e);
|
|
4201
|
-
}
|
|
4202
|
-
if (t.columns && t.columns.length > 0) {
|
|
4203
|
-
let e = document.createElement("div");
|
|
4204
|
-
e.classList.add("overflow-auto", "max-h-60");
|
|
4205
|
-
let r = document.createElement("table");
|
|
4206
|
-
r.classList.add("w-full", "text-xs", "border-collapse");
|
|
4207
|
-
let i = r.insertRow();
|
|
4208
|
-
i.classList.add("bg-muted");
|
|
4209
|
-
let a = i.insertCell();
|
|
4210
|
-
a.classList.add("p-2", "font-medium", "text-left"), a.textContent = "Column";
|
|
4211
|
-
let o = i.insertCell();
|
|
4212
|
-
o.classList.add("p-2", "font-medium", "text-left"), o.textContent = "Type";
|
|
4213
|
-
let s = t.columns.some((e) => this.getItemMetadata(t, e) !== void 0), c;
|
|
4214
|
-
s && (c = i.insertCell(), c.classList.add("p-2", "font-medium", "text-left"), c.textContent = "Metadata"), t.columns.forEach((e, n) => {
|
|
4215
|
-
let i = r.insertRow();
|
|
4216
|
-
i.classList.add(n % 2 == 0 ? "bg-background" : "bg-muted/30");
|
|
4217
|
-
let a = i.insertCell();
|
|
4218
|
-
a.classList.add("p-2", "font-mono"), a.textContent = e.name;
|
|
4219
|
-
let o = i.insertCell();
|
|
4220
|
-
if (o.classList.add("p-2", "text-muted-foreground"), o.textContent = e.type, s) {
|
|
4221
|
-
let n = i.insertCell();
|
|
4222
|
-
n.classList.add("p-2");
|
|
4223
|
-
let r = this.getItemMetadata(t, e);
|
|
4224
|
-
r && n.append(r);
|
|
4225
|
-
}
|
|
4226
|
-
}), e.append(r), n.append(e);
|
|
4227
|
-
}
|
|
4228
|
-
return n;
|
|
4229
|
-
}
|
|
4230
|
-
getItemMetadata(e, t) {
|
|
4231
|
-
let n = e.primary_keys?.includes(t.name), r = e.indexes?.includes(t.name);
|
|
4232
|
-
if (n || r) {
|
|
4233
|
-
let e = document.createElement("span");
|
|
4234
|
-
e.textContent = n ? "PK" : "IDX";
|
|
4235
|
-
let t = n ? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200" : "bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";
|
|
4236
|
-
return e.classList.add("text-xs", "px-1.5", "py-0.5", "rounded-full", "font-medium", ...t.split(" ")), e;
|
|
4237
|
-
}
|
|
3954
|
+
}
|
|
3955
|
+
function Ha(e) {
|
|
3956
|
+
if (!Wa(e) || !Wa(e.edit)) return;
|
|
3957
|
+
let { type: t, code: n } = e.edit;
|
|
3958
|
+
if (typeof t == "string" && Object.hasOwn(Ba, t)) return {
|
|
3959
|
+
type: t,
|
|
3960
|
+
code: typeof n == "string" ? n : void 0
|
|
3961
|
+
};
|
|
3962
|
+
}
|
|
3963
|
+
function Ua(e) {
|
|
3964
|
+
if (typeof e != "string") return;
|
|
3965
|
+
let t = e.split("\n").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
3966
|
+
return t.find((e) => !/^(import\s|from\s|#)/.test(e)) ?? t[0];
|
|
3967
|
+
}
|
|
3968
|
+
function Wa(e) {
|
|
3969
|
+
return typeof e == "object" && !!e;
|
|
3970
|
+
}
|
|
3971
|
+
//#endregion
|
|
3972
|
+
//#region src/components/chat/tool-call/tool-result.tsx
|
|
3973
|
+
function Ga(e) {
|
|
3974
|
+
return e == null || typeof e == "object" && gt(e);
|
|
3975
|
+
}
|
|
3976
|
+
var Ka = rt({
|
|
3977
|
+
status: it().default("success"),
|
|
3978
|
+
auth_required: qe().default(!1),
|
|
3979
|
+
action_url: Qe().optional(),
|
|
3980
|
+
next_steps: Qe().optional(),
|
|
3981
|
+
meta: Qe().optional(),
|
|
3982
|
+
message: it().nullish()
|
|
3983
|
+
}), qa = (e) => {
|
|
3984
|
+
let t = (0, I.c)(12), { data: n } = e, r;
|
|
3985
|
+
if (t[0] !== n) {
|
|
3986
|
+
let { status: e, auth_required: i, action_url: a, meta: o, next_steps: s, message: c, ...l } = n, u;
|
|
3987
|
+
t[2] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ (0, Z.jsx)("h3", {
|
|
3988
|
+
className: "text-xs font-semibold text-muted-foreground",
|
|
3989
|
+
children: "Tool Result"
|
|
3990
|
+
}), t[2] = u) : u = t[2];
|
|
3991
|
+
let d;
|
|
3992
|
+
t[3] === e ? d = t[4] : (d = /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
3993
|
+
className: "text-xs text-muted-foreground capitalize",
|
|
3994
|
+
children: e
|
|
3995
|
+
}), t[3] = e, t[4] = d);
|
|
3996
|
+
let f;
|
|
3997
|
+
t[5] === i ? f = t[6] : (f = i && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
3998
|
+
className: "text-xs px-2 py-0.5 bg-(--amber-2) text-(--amber-11) rounded-full",
|
|
3999
|
+
children: "Auth Required"
|
|
4000
|
+
}), t[5] = i, t[6] = f);
|
|
4001
|
+
let p;
|
|
4002
|
+
t[7] !== d || t[8] !== f ? (p = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4003
|
+
className: "flex items-center justify-between",
|
|
4004
|
+
children: [u, /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4005
|
+
className: "flex items-center gap-2",
|
|
4006
|
+
children: [d, f]
|
|
4007
|
+
})]
|
|
4008
|
+
}), t[7] = d, t[8] = f, t[9] = p) : p = t[9];
|
|
4009
|
+
let h;
|
|
4010
|
+
t[10] === c ? h = t[11] : (h = c && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4011
|
+
className: "flex items-start gap-2",
|
|
4012
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(m, { className: "h-3 w-3 text-(--blue-11) mt-0.5 shrink-0" }), /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4013
|
+
className: "text-xs text-foreground",
|
|
4014
|
+
children: c
|
|
4015
|
+
})]
|
|
4016
|
+
}), t[10] = c, t[11] = h), r = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4017
|
+
className: "flex flex-col gap-1.5",
|
|
4018
|
+
children: [
|
|
4019
|
+
p,
|
|
4020
|
+
h,
|
|
4021
|
+
l && /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4022
|
+
className: "space-y-3",
|
|
4023
|
+
children: Object.entries(l).map(Ya)
|
|
4024
|
+
})
|
|
4025
|
+
]
|
|
4026
|
+
}), t[0] = n, t[1] = r;
|
|
4027
|
+
} else r = t[1];
|
|
4028
|
+
return r;
|
|
4029
|
+
}, Ja = (e) => {
|
|
4030
|
+
let t = (0, I.c)(8), { result: n } = e, r;
|
|
4031
|
+
t[0] === n ? r = t[1] : (r = Ka.safeParse(n), t[0] = n, t[1] = r);
|
|
4032
|
+
let i = r;
|
|
4033
|
+
if (i.success) {
|
|
4034
|
+
let e;
|
|
4035
|
+
return t[2] === i.data ? e = t[3] : (e = /* @__PURE__ */ (0, Z.jsx)(qa, { data: i.data }), t[2] = i.data, t[3] = e), e;
|
|
4238
4036
|
}
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4037
|
+
let a;
|
|
4038
|
+
t[4] === n ? a = t[5] : (a = typeof n == "string" ? n : JSON.stringify(n, null, 2), t[4] = n, t[5] = a);
|
|
4039
|
+
let o;
|
|
4040
|
+
return t[6] === a ? o = t[7] : (o = /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4041
|
+
className: "text-xs font-medium text-muted-foreground mb-1 max-h-64 overflow-y-auto scrollbar-thin",
|
|
4042
|
+
children: a
|
|
4043
|
+
}), t[6] = a, t[7] = o), o;
|
|
4044
|
+
};
|
|
4045
|
+
function Ya(e) {
|
|
4046
|
+
let [t, n] = e;
|
|
4047
|
+
return Ga(n) ? null : /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4048
|
+
className: "space-y-1.5",
|
|
4049
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4050
|
+
className: "text-xs text-muted-foreground",
|
|
4051
|
+
children: t
|
|
4052
|
+
}), /* @__PURE__ */ (0, Z.jsx)("pre", {
|
|
4053
|
+
className: "bg-(--slate-2) p-2 text-muted-foreground border border-(--slate-4) rounded text-xs overflow-auto scrollbar-thin max-h-64",
|
|
4054
|
+
children: JSON.stringify(n, null, 2)
|
|
4055
|
+
})]
|
|
4056
|
+
}, t);
|
|
4057
|
+
}
|
|
4058
|
+
//#endregion
|
|
4059
|
+
//#region src/components/chat/tool-call/tool-step.tsx
|
|
4060
|
+
var Xa = (e) => {
|
|
4061
|
+
let t = (0, I.c)(58), { toolName: n, state: i, input: a, result: o, errorText: s, approval: c, isActive: l, className: u } = e, d = l === void 0 || l, [f, p] = X.useState(!1), m, h, g, _, v, y, b, x, S, C, w;
|
|
4062
|
+
if (t[0] !== u || t[1] !== a || t[2] !== d || t[3] !== f || t[4] !== i || t[5] !== n) {
|
|
4063
|
+
let e = Fa.has(i), { label: o, detail: s, icon: c } = Va(n, a, e ? "running" : "done");
|
|
4064
|
+
g = o, h = s, _ = Za(i, e && !d, c);
|
|
4065
|
+
let l = i === "output-error";
|
|
4066
|
+
t[17] === u ? w = t[18] : (w = r("w-full", u), t[17] = u, t[18] = w), b = "button", t[19] === Symbol.for("react.memo_cache_sentinel") ? (x = () => p($a), t[19] = x) : x = t[19], S = f;
|
|
4067
|
+
let T = f && "text-foreground", E = l && "text-(--red-11) hover:bg-(--red-3) hover:text-(--red-11)";
|
|
4068
|
+
t[20] !== T || t[21] !== E ? (C = r("group/step -mx-1.5 flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left text-xs leading-4 text-muted-foreground transition-colors hover:bg-foreground/6 hover:text-foreground focus-visible:outline-1 focus-visible:outline-(--slate-8)", T, E), t[20] = T, t[21] = E, t[22] = C) : C = t[22], m = _.icon, v = !0, y = r("-ml-px size-3 shrink-0", _.spinning && "animate-spin"), t[0] = u, t[1] = a, t[2] = d, t[3] = f, t[4] = i, t[5] = n, t[6] = m, t[7] = h, t[8] = g, t[9] = _, t[10] = v, t[11] = y, t[12] = b, t[13] = x, t[14] = S, t[15] = C, t[16] = w;
|
|
4069
|
+
} else m = t[6], h = t[7], g = t[8], _ = t[9], v = t[10], y = t[11], b = t[12], x = t[13], S = t[14], C = t[15], w = t[16];
|
|
4070
|
+
let T;
|
|
4071
|
+
t[23] !== m || t[24] !== v || t[25] !== y ? (T = /* @__PURE__ */ (0, Z.jsx)(m, {
|
|
4072
|
+
"aria-hidden": v,
|
|
4073
|
+
className: y
|
|
4074
|
+
}), t[23] = m, t[24] = v, t[25] = y, t[26] = T) : T = t[26];
|
|
4075
|
+
let E;
|
|
4076
|
+
t[27] === g ? E = t[28] : (E = /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4077
|
+
className: "shrink-0",
|
|
4078
|
+
children: g
|
|
4079
|
+
}), t[27] = g, t[28] = E);
|
|
4080
|
+
let D;
|
|
4081
|
+
t[29] === h ? D = t[30] : (D = h && /* @__PURE__ */ (0, Z.jsx)("code", {
|
|
4082
|
+
className: "min-w-0 truncate font-mono text-[0.6875rem] opacity-80",
|
|
4083
|
+
children: h
|
|
4084
|
+
}), t[29] = h, t[30] = D);
|
|
4085
|
+
let O;
|
|
4086
|
+
t[31] === _.suffix ? O = t[32] : (O = _.suffix && /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
4087
|
+
className: "shrink-0 opacity-80",
|
|
4088
|
+
children: ["· ", _.suffix]
|
|
4089
|
+
}), t[31] = _.suffix, t[32] = O);
|
|
4090
|
+
let k = f && "rotate-90 opacity-100", A;
|
|
4091
|
+
t[33] === k ? A = t[34] : (A = r("size-3 shrink-0 opacity-40 transition-transform group-hover/step:opacity-100", k), t[33] = k, t[34] = A);
|
|
4092
|
+
let j;
|
|
4093
|
+
t[35] === A ? j = t[36] : (j = /* @__PURE__ */ (0, Z.jsx)(fe, {
|
|
4094
|
+
"aria-hidden": !0,
|
|
4095
|
+
className: A
|
|
4096
|
+
}), t[35] = A, t[36] = j);
|
|
4097
|
+
let M;
|
|
4098
|
+
t[37] !== E || t[38] !== D || t[39] !== O || t[40] !== j || t[41] !== b || t[42] !== x || t[43] !== S || t[44] !== C || t[45] !== T ? (M = /* @__PURE__ */ (0, Z.jsxs)("button", {
|
|
4099
|
+
type: b,
|
|
4100
|
+
onClick: x,
|
|
4101
|
+
"aria-expanded": S,
|
|
4102
|
+
className: C,
|
|
4103
|
+
children: [
|
|
4104
|
+
T,
|
|
4105
|
+
E,
|
|
4106
|
+
D,
|
|
4107
|
+
O,
|
|
4108
|
+
j
|
|
4109
|
+
]
|
|
4110
|
+
}), t[37] = E, t[38] = D, t[39] = O, t[40] = j, t[41] = b, t[42] = x, t[43] = S, t[44] = C, t[45] = T, t[46] = M) : M = t[46];
|
|
4111
|
+
let N;
|
|
4112
|
+
t[47] !== c || t[48] !== s || t[49] !== a || t[50] !== f || t[51] !== o || t[52] !== i ? (N = f && /* @__PURE__ */ (0, Z.jsx)(Qa, {
|
|
4113
|
+
state: i,
|
|
4114
|
+
input: a,
|
|
4115
|
+
result: o,
|
|
4116
|
+
errorText: s,
|
|
4117
|
+
approval: c
|
|
4118
|
+
}), t[47] = c, t[48] = s, t[49] = a, t[50] = f, t[51] = o, t[52] = i, t[53] = N) : N = t[53];
|
|
4119
|
+
let ee;
|
|
4120
|
+
return t[54] !== M || t[55] !== N || t[56] !== w ? (ee = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4121
|
+
className: w,
|
|
4122
|
+
children: [M, N]
|
|
4123
|
+
}), t[54] = M, t[55] = N, t[56] = w, t[57] = ee) : ee = t[57], ee;
|
|
4124
|
+
};
|
|
4125
|
+
function Za(e, t, n) {
|
|
4126
|
+
if (t) return {
|
|
4127
|
+
icon: Ut,
|
|
4128
|
+
suffix: "Stopped"
|
|
4129
|
+
};
|
|
4130
|
+
switch (e) {
|
|
4131
|
+
case "output-error": return {
|
|
4132
|
+
icon: C,
|
|
4133
|
+
suffix: "Failed"
|
|
4134
|
+
};
|
|
4135
|
+
case "output-denied": return {
|
|
4136
|
+
icon: Rt,
|
|
4137
|
+
suffix: "Denied"
|
|
4138
|
+
};
|
|
4139
|
+
case "output-available": return { icon: n };
|
|
4140
|
+
default: return {
|
|
4141
|
+
icon: y,
|
|
4142
|
+
spinning: !0
|
|
4143
|
+
};
|
|
4247
4144
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4145
|
+
}
|
|
4146
|
+
var Qa = (e) => {
|
|
4147
|
+
let t = (0, I.c)(16), { state: n, input: r, result: i, errorText: a, approval: o } = e, s;
|
|
4148
|
+
t[0] === r ? s = t[1] : (s = /* @__PURE__ */ (0, Z.jsx)(La, { input: r }), t[0] = r, t[1] = s);
|
|
4149
|
+
let c;
|
|
4150
|
+
t[2] !== i || t[3] !== n ? (c = n === "output-available" && i != null && /* @__PURE__ */ (0, Z.jsx)(Ja, { result: i }), t[2] = i, t[3] = n, t[4] = c) : c = t[4];
|
|
4151
|
+
let l;
|
|
4152
|
+
t[5] !== a || t[6] !== n ? (l = n === "output-error" && a && /* @__PURE__ */ (0, Z.jsx)("pre", {
|
|
4153
|
+
className: "max-h-64 overflow-auto rounded border border-(--red-6) bg-(--red-2) p-2 text-xs leading-relaxed whitespace-pre-wrap text-(--red-11) scrollbar-thin",
|
|
4154
|
+
children: a
|
|
4155
|
+
}), t[5] = a, t[6] = n, t[7] = l) : l = t[7];
|
|
4156
|
+
let u;
|
|
4157
|
+
t[8] !== o || t[9] !== n ? (u = n === "output-denied" && /* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
4158
|
+
className: "text-xs text-muted-foreground",
|
|
4159
|
+
children: ["Tool execution was denied", o?.reason ? `: ${o.reason}` : "."]
|
|
4160
|
+
}), t[8] = o, t[9] = n, t[10] = u) : u = t[10];
|
|
4161
|
+
let d;
|
|
4162
|
+
return t[11] !== s || t[12] !== c || t[13] !== l || t[14] !== u ? (d = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4163
|
+
className: "mt-1 mb-2 ml-5.5 space-y-3",
|
|
4164
|
+
children: [
|
|
4165
|
+
s,
|
|
4166
|
+
c,
|
|
4167
|
+
l,
|
|
4168
|
+
u
|
|
4169
|
+
]
|
|
4170
|
+
}), t[11] = s, t[12] = c, t[13] = l, t[14] = u, t[15] = d) : d = t[15], d;
|
|
4171
|
+
};
|
|
4172
|
+
function $a(e) {
|
|
4173
|
+
return !e;
|
|
4174
|
+
}
|
|
4175
|
+
//#endregion
|
|
4176
|
+
//#region src/components/chat/tool-call/tool-call-view.tsx
|
|
4177
|
+
var eo = (e) => {
|
|
4178
|
+
let t = (0, I.c)(16), n, r, i, a, o;
|
|
4179
|
+
if (t[0] === e ? (n = t[1], r = t[2], i = t[3], a = t[4], o = t[5]) : ({toolName: o, state: a, approval: n, onApprove: r, ...i} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i, t[4] = a, t[5] = o), a === "approval-requested") {
|
|
4180
|
+
let e;
|
|
4181
|
+
return t[6] !== n || t[7] !== r || t[8] !== i || t[9] !== o ? (e = n != null && r != null ? /* @__PURE__ */ (0, Z.jsx)(Ra, {
|
|
4182
|
+
toolName: o,
|
|
4183
|
+
input: i.input,
|
|
4184
|
+
approval: n,
|
|
4185
|
+
onApprove: r,
|
|
4186
|
+
className: i.className
|
|
4187
|
+
}) : /* @__PURE__ */ (0, Z.jsx)(Xa, {
|
|
4188
|
+
...i,
|
|
4189
|
+
toolName: o,
|
|
4190
|
+
state: "input-available"
|
|
4191
|
+
}), t[6] = n, t[7] = r, t[8] = i, t[9] = o, t[10] = e) : e = t[10], e;
|
|
4258
4192
|
}
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4193
|
+
let s;
|
|
4194
|
+
return t[11] !== n || t[12] !== i || t[13] !== a || t[14] !== o ? (s = /* @__PURE__ */ (0, Z.jsx)(Xa, {
|
|
4195
|
+
...i,
|
|
4196
|
+
toolName: o,
|
|
4197
|
+
state: a,
|
|
4198
|
+
approval: n
|
|
4199
|
+
}), t[11] = n, t[12] = i, t[13] = a, t[14] = o, t[15] = s) : s = t[15], s;
|
|
4200
|
+
}, to = ({ message: e, isLast: t, isActive: n, turnStartedAt: r, addToolApprovalResponse: i }) => {
|
|
4201
|
+
let a = n && t, { work: o, rest: s } = no(e.parts), c = [];
|
|
4202
|
+
if (o.length > 0 || a && s.length === 0) {
|
|
4203
|
+
let t = o.flatMap(({ part: e }) => ao(e) ? [e] : []), n = a && r != null ? { startedAt: r } : wa(e);
|
|
4204
|
+
c.push(/* @__PURE__ */ (0, Z.jsx)(Ea, {
|
|
4205
|
+
running: a,
|
|
4206
|
+
thinking: s.length === 0 && (o.length === 0 || o.at(-1)?.part.type === "reasoning"),
|
|
4207
|
+
interrupted: !a && (n?.stopped === !0 || t.some((e) => Fa.has(e.state))),
|
|
4208
|
+
defaultOpen: !s.some(({ part: e }) => !ro(e)),
|
|
4209
|
+
timing: n,
|
|
4210
|
+
toolCount: t.length,
|
|
4211
|
+
failedCount: t.filter((e) => e.state === "output-error").length,
|
|
4212
|
+
steps: o.map(({ part: e, index: t }) => l(e, t, !0))
|
|
4213
|
+
}, "activity"));
|
|
4269
4214
|
}
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4215
|
+
for (let { part: e, index: t } of s) c.push(l(e, t, !1));
|
|
4216
|
+
return c;
|
|
4217
|
+
function l(e, t, n) {
|
|
4218
|
+
if (oo(e) || e.type === "dynamic-tool") return /* @__PURE__ */ (0, Z.jsx)(eo, {
|
|
4219
|
+
toolName: e.type === "dynamic-tool" ? e.toolName : e.type,
|
|
4220
|
+
result: e.output,
|
|
4221
|
+
errorText: e.state === "output-error" ? e.errorText : void 0,
|
|
4222
|
+
state: e.state,
|
|
4223
|
+
input: e.input,
|
|
4224
|
+
approval: e.approval,
|
|
4225
|
+
onApprove: i,
|
|
4226
|
+
isActive: a,
|
|
4227
|
+
className: n ? void 0 : "my-1"
|
|
4228
|
+
}, t);
|
|
4229
|
+
if (so(e)) return null;
|
|
4230
|
+
switch (e.type) {
|
|
4231
|
+
case "text": return e.text.includes("<marimo-") ? /* @__PURE__ */ (0, Z.jsx)(X.Fragment, { children: _({ html: e.text }) }, t) : /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4232
|
+
className: n ? "py-1.5" : void 0,
|
|
4233
|
+
children: /* @__PURE__ */ (0, Z.jsx)(Pa, { content: e.text })
|
|
4234
|
+
}, t);
|
|
4235
|
+
case "reasoning": return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4236
|
+
className: "flex gap-1.5 py-1.5 text-muted-foreground",
|
|
4237
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(Vt, {
|
|
4238
|
+
"aria-hidden": !0,
|
|
4239
|
+
className: "-ml-px mt-1 size-3 shrink-0"
|
|
4240
|
+
}), /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4241
|
+
className: "min-w-0 italic [&_p]:my-1 [&_p:first-child]:mt-0",
|
|
4242
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4243
|
+
className: "sr-only",
|
|
4244
|
+
children: "Reasoning: "
|
|
4245
|
+
}), /* @__PURE__ */ (0, Z.jsx)(Pa, { content: e.text })]
|
|
4246
|
+
})]
|
|
4247
|
+
}, t);
|
|
4248
|
+
case "file": return /* @__PURE__ */ (0, Z.jsx)(Ma, { attachment: e }, t);
|
|
4249
|
+
case "reasoning-file": return /* @__PURE__ */ (0, Z.jsx)(Ma, { attachment: {
|
|
4250
|
+
type: "file",
|
|
4251
|
+
mediaType: e.mediaType,
|
|
4252
|
+
url: e.url
|
|
4253
|
+
} }, t);
|
|
4254
|
+
case "source-document": return /* @__PURE__ */ (0, Z.jsx)(Na, {
|
|
4255
|
+
icon: /* @__PURE__ */ (0, Z.jsx)(g, { className: "h-3 w-3 shrink-0" }),
|
|
4256
|
+
title: e.title,
|
|
4257
|
+
subtitle: e.filename
|
|
4258
|
+
}, t);
|
|
4259
|
+
case "source-url": return /* @__PURE__ */ (0, Z.jsx)(Na, {
|
|
4260
|
+
icon: /* @__PURE__ */ (0, Z.jsx)(De, { className: "h-3 w-3 shrink-0" }),
|
|
4261
|
+
title: e.title ?? e.url,
|
|
4262
|
+
subtitle: e.title ? e.url : void 0,
|
|
4263
|
+
href: e.url
|
|
4264
|
+
}, t);
|
|
4265
|
+
case "custom": return /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4266
|
+
className: "text-sm text-muted-foreground",
|
|
4267
|
+
children: e.kind
|
|
4268
|
+
}, t);
|
|
4269
|
+
case "step-start": return null;
|
|
4270
|
+
default: return Ve(e), null;
|
|
4271
|
+
}
|
|
4280
4272
|
}
|
|
4281
4273
|
};
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4274
|
+
function no(e) {
|
|
4275
|
+
let t = e.map((e, t) => ({
|
|
4276
|
+
part: e,
|
|
4277
|
+
index: t
|
|
4278
|
+
})).filter(({ part: e }) => io(e)), n = t.findLastIndex(({ part: e }) => e.type === "reasoning" || ao(e) && !ro(e));
|
|
4279
|
+
return {
|
|
4280
|
+
work: t.filter(({ part: e }, t) => t <= n && !ro(e)),
|
|
4281
|
+
rest: t.filter(({ part: e }, t) => t > n || ro(e))
|
|
4282
|
+
};
|
|
4287
4283
|
}
|
|
4288
|
-
function
|
|
4289
|
-
return
|
|
4284
|
+
function ro(e) {
|
|
4285
|
+
return ao(e) && e.state === "approval-requested";
|
|
4290
4286
|
}
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
return !
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4287
|
+
function io(e) {
|
|
4288
|
+
switch (e.type) {
|
|
4289
|
+
case "step-start": return !1;
|
|
4290
|
+
case "text": return e.text.trim().length > 0;
|
|
4291
|
+
case "reasoning": return e.text.trim().length > 0;
|
|
4292
|
+
default: return !so(e);
|
|
4293
|
+
}
|
|
4294
|
+
}
|
|
4295
|
+
function ao(e) {
|
|
4296
|
+
return oo(e) || e.type === "dynamic-tool";
|
|
4297
|
+
}
|
|
4298
|
+
function oo(e) {
|
|
4299
|
+
return e.type.startsWith("tool-");
|
|
4300
|
+
}
|
|
4301
|
+
function so(e) {
|
|
4302
|
+
return e.type.startsWith("data-");
|
|
4301
4303
|
}
|
|
4302
4304
|
//#endregion
|
|
4303
|
-
//#region src/
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4305
|
+
//#region src/core/ai/attachments.ts
|
|
4306
|
+
var co = /[\x00-\x08\x0B\x0E-\x1F]/, lo = [
|
|
4307
|
+
"text/*",
|
|
4308
|
+
"application/json",
|
|
4309
|
+
"application/xml",
|
|
4310
|
+
"application/toml",
|
|
4311
|
+
"application/yaml",
|
|
4312
|
+
"application/x-yaml"
|
|
4313
|
+
];
|
|
4314
|
+
function uo(e) {
|
|
4315
|
+
let t = e.split(";", 1)[0].trim().toLowerCase();
|
|
4316
|
+
return /^(image|audio|video)\//.test(t) ? t : po(t, lo) || t.endsWith("+json") || t.endsWith("+xml") ? "text/plain" : t;
|
|
4311
4317
|
}
|
|
4312
|
-
function
|
|
4313
|
-
let t = e.
|
|
4314
|
-
if (
|
|
4315
|
-
|
|
4316
|
-
|
|
4318
|
+
async function fo(e) {
|
|
4319
|
+
let t = uo(e.type);
|
|
4320
|
+
if (t !== "text/plain" && !/^(image|audio|video)\//.test(t) && t !== "application/pdf") {
|
|
4321
|
+
let n = new Uint8Array(await e.arrayBuffer());
|
|
4322
|
+
try {
|
|
4323
|
+
let e = new TextDecoder("utf-8", { fatal: !0 }).decode(n);
|
|
4324
|
+
co.test(e) || (t = "text/plain");
|
|
4325
|
+
} catch {}
|
|
4326
|
+
}
|
|
4327
|
+
return t === e.type ? e : new File([e], e.name, {
|
|
4328
|
+
type: t,
|
|
4329
|
+
lastModified: e.lastModified
|
|
4330
|
+
});
|
|
4331
|
+
}
|
|
4332
|
+
function po(e, t) {
|
|
4333
|
+
return t.some((t) => t.endsWith("/*") ? e.startsWith(t.slice(0, -1)) : e === t);
|
|
4317
4334
|
}
|
|
4318
4335
|
//#endregion
|
|
4319
|
-
//#region src/
|
|
4320
|
-
var
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
className: "max-h-[100px] max-w-[100px] object-contain mb-1.5"
|
|
4328
|
-
}), t[0] = n.url, t[1] = e, t[2] = r) : r = t[2], r;
|
|
4336
|
+
//#region src/core/ai/context/providers/cell.ts
|
|
4337
|
+
var mo = class extends A {
|
|
4338
|
+
title = "Cells";
|
|
4339
|
+
mentionPrefix = "@";
|
|
4340
|
+
contextType = "cell";
|
|
4341
|
+
store;
|
|
4342
|
+
constructor(e) {
|
|
4343
|
+
super(), this.store = e;
|
|
4329
4344
|
}
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
}
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
return t[8] !== l || t[9] !== a || t[10] !== e ? (n = /* @__PURE__ */ (0, Z.jsx)("a", {
|
|
4362
|
-
href: a,
|
|
4363
|
-
target: "_blank",
|
|
4364
|
-
rel: "noopener noreferrer",
|
|
4365
|
-
title: e,
|
|
4366
|
-
className: "inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",
|
|
4367
|
-
children: l
|
|
4368
|
-
}), t[8] = l, t[9] = a, t[10] = e, t[11] = n) : n = t[11], n;
|
|
4345
|
+
getItems() {
|
|
4346
|
+
let e = this.store.get(Oe);
|
|
4347
|
+
return e.cellIds.map((t, n) => {
|
|
4348
|
+
let r = e.cellData[t];
|
|
4349
|
+
return {
|
|
4350
|
+
uri: this.asURI(t),
|
|
4351
|
+
name: je(r.name, n),
|
|
4352
|
+
type: this.contextType,
|
|
4353
|
+
description: "Cell code",
|
|
4354
|
+
data: {
|
|
4355
|
+
cellId: t,
|
|
4356
|
+
code: r.code
|
|
4357
|
+
}
|
|
4358
|
+
};
|
|
4359
|
+
});
|
|
4360
|
+
}
|
|
4361
|
+
formatCompletion(e) {
|
|
4362
|
+
return {
|
|
4363
|
+
...this.createBasicCompletion(e),
|
|
4364
|
+
label: `${this.mentionPrefix}${e.name}`
|
|
4365
|
+
};
|
|
4366
|
+
}
|
|
4367
|
+
formatContext(e) {
|
|
4368
|
+
return N({
|
|
4369
|
+
type: "cell",
|
|
4370
|
+
data: {
|
|
4371
|
+
cellId: e.data.cellId,
|
|
4372
|
+
name: e.name
|
|
4373
|
+
},
|
|
4374
|
+
details: e.data.code || "This cell is empty."
|
|
4375
|
+
});
|
|
4369
4376
|
}
|
|
4370
|
-
let u = i ?? r, d;
|
|
4371
|
-
return t[12] !== l || t[13] !== u ? (d = /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4372
|
-
className: "inline-flex max-w-full items-center gap-1.5 rounded-md border bg-muted/50 px-2 py-1 my-1 text-xs text-muted-foreground",
|
|
4373
|
-
title: u,
|
|
4374
|
-
children: l
|
|
4375
|
-
}), t[12] = l, t[13] = u, t[14] = d) : d = t[14], d;
|
|
4376
4377
|
};
|
|
4377
4378
|
//#endregion
|
|
4378
|
-
//#region src/
|
|
4379
|
-
function
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
return e.replace("tool-", "");
|
|
4379
|
+
//#region src/core/ai/context/providers/cell-output.ts
|
|
4380
|
+
function ho(e, t) {
|
|
4381
|
+
return e ? !!([
|
|
4382
|
+
"image/",
|
|
4383
|
+
"video/",
|
|
4384
|
+
"audio/",
|
|
4385
|
+
"application/pdf"
|
|
4386
|
+
].some((t) => e.startsWith(t)) || ["svg", "vega"].some((t) => e.includes(t)) || e === "text/html" && [
|
|
4387
|
+
"<img",
|
|
4388
|
+
"<video",
|
|
4389
|
+
"<audio",
|
|
4390
|
+
"<iframe",
|
|
4391
|
+
"<canvas",
|
|
4392
|
+
"<svg",
|
|
4393
|
+
"<marimo-ui-element"
|
|
4394
|
+
].some((e) => t.includes(e))) : !1;
|
|
4395
4395
|
}
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
" ",
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
let b;
|
|
4474
|
-
return t[21] !== l || t[22] !== y || t[23] !== d || t[24] !== h || t[25] !== g ? (b = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4475
|
-
className: l,
|
|
4476
|
-
role: "alertdialog",
|
|
4477
|
-
"aria-label": d,
|
|
4478
|
-
children: [
|
|
4479
|
-
h,
|
|
4480
|
-
g,
|
|
4481
|
-
y
|
|
4482
|
-
]
|
|
4483
|
-
}), t[21] = l, t[22] = y, t[23] = d, t[24] = h, t[25] = g, t[26] = b) : b = t[26], b;
|
|
4484
|
-
}, so = {
|
|
4485
|
-
get_marimo_rules: {
|
|
4486
|
-
running: "Reading marimo guidelines",
|
|
4487
|
-
done: "Read marimo guidelines",
|
|
4488
|
-
icon: zt
|
|
4489
|
-
},
|
|
4490
|
-
get_active_notebooks: {
|
|
4491
|
-
running: "Listing notebooks",
|
|
4492
|
-
done: "Listed notebooks",
|
|
4493
|
-
icon: Kt
|
|
4494
|
-
},
|
|
4495
|
-
get_lightweight_cell_map: {
|
|
4496
|
-
running: "Reading notebook",
|
|
4497
|
-
done: "Read notebook",
|
|
4498
|
-
icon: Wt
|
|
4499
|
-
},
|
|
4500
|
-
get_cell_runtime_data: {
|
|
4501
|
-
running: "Inspecting cells",
|
|
4502
|
-
done: "Inspected cells",
|
|
4503
|
-
icon: Yt
|
|
4504
|
-
},
|
|
4505
|
-
get_cell_outputs: {
|
|
4506
|
-
running: "Reading cell outputs",
|
|
4507
|
-
done: "Read cell outputs",
|
|
4508
|
-
icon: Yt
|
|
4509
|
-
},
|
|
4510
|
-
get_tables_and_variables: {
|
|
4511
|
-
running: "Reading variables",
|
|
4512
|
-
done: "Read variables",
|
|
4513
|
-
icon: p
|
|
4514
|
-
},
|
|
4515
|
-
get_database_tables: {
|
|
4516
|
-
running: "Reading database tables",
|
|
4517
|
-
done: "Read database tables",
|
|
4518
|
-
icon: le
|
|
4519
|
-
},
|
|
4520
|
-
get_notebook_errors: {
|
|
4521
|
-
running: "Checking for errors",
|
|
4522
|
-
done: "Checked for errors",
|
|
4523
|
-
icon: Ht
|
|
4524
|
-
},
|
|
4525
|
-
lint_notebook: {
|
|
4526
|
-
running: "Linting notebook",
|
|
4527
|
-
done: "Linted notebook",
|
|
4528
|
-
icon: Gt
|
|
4529
|
-
},
|
|
4530
|
-
get_cell_dependency_graph: {
|
|
4531
|
-
running: "Reading dependency graph",
|
|
4532
|
-
done: "Read dependency graph",
|
|
4533
|
-
icon: v
|
|
4396
|
+
var go = class extends A {
|
|
4397
|
+
title = "Cell Outputs";
|
|
4398
|
+
mentionPrefix = "@";
|
|
4399
|
+
contextType = "cell-output";
|
|
4400
|
+
store;
|
|
4401
|
+
constructor(e) {
|
|
4402
|
+
super(), this.store = e;
|
|
4403
|
+
}
|
|
4404
|
+
getItems() {
|
|
4405
|
+
let e = this.store.get(Oe), t = [];
|
|
4406
|
+
for (let n of e.cellIds) {
|
|
4407
|
+
let r = yo(n, e, this.store.get(Te(n))), i = r.cellOutput;
|
|
4408
|
+
if (!i) continue;
|
|
4409
|
+
let a = i.output.mimetype || "unknown";
|
|
4410
|
+
t.push({
|
|
4411
|
+
uri: this.asURI(n),
|
|
4412
|
+
name: r.cellName,
|
|
4413
|
+
type: this.contextType,
|
|
4414
|
+
description: `Cell output (${a})`,
|
|
4415
|
+
data: {
|
|
4416
|
+
...r,
|
|
4417
|
+
cellOutput: i
|
|
4418
|
+
}
|
|
4419
|
+
});
|
|
4420
|
+
}
|
|
4421
|
+
return t;
|
|
4422
|
+
}
|
|
4423
|
+
formatCompletion(e) {
|
|
4424
|
+
let { cellOutput: t, cellName: n, cellCode: r } = e.data;
|
|
4425
|
+
return {
|
|
4426
|
+
label: `@${n}`,
|
|
4427
|
+
displayLabel: n,
|
|
4428
|
+
detail: `${t.outputType} output`,
|
|
4429
|
+
boost: t.outputType === "media" ? O.HIGH : O.MEDIUM,
|
|
4430
|
+
type: this.contextType,
|
|
4431
|
+
section: P.CELL_OUTPUT,
|
|
4432
|
+
apply: `@${n}`,
|
|
4433
|
+
info: () => {
|
|
4434
|
+
let e = document.createElement("div");
|
|
4435
|
+
e.classList.add("mo-cm-tooltip", "docs-documentation", "min-w-[300px]", "max-w-[500px]", "flex", "flex-col", "gap-2");
|
|
4436
|
+
let i = document.createElement("div");
|
|
4437
|
+
i.classList.add("flex", "flex-col", "gap-1");
|
|
4438
|
+
let a = document.createElement("div");
|
|
4439
|
+
a.classList.add("font-bold", "text-base"), a.textContent = n, i.append(a);
|
|
4440
|
+
let o = document.createElement("div");
|
|
4441
|
+
if (o.classList.add("text-sm", "text-muted-foreground"), i.append(o), e.append(i), r) {
|
|
4442
|
+
let t = document.createElement("div");
|
|
4443
|
+
t.classList.add("text-xs", "font-medium", "text-muted-foreground"), t.textContent = "Code:", e.append(t);
|
|
4444
|
+
let n = document.createElement("div");
|
|
4445
|
+
n.classList.add("text-xs", "font-mono", "bg-muted", "p-2", "rounded", "max-h-20", "overflow-y-auto"), n.textContent = r.slice(0, 200) + (r.length > 200 ? "..." : ""), e.append(n);
|
|
4446
|
+
}
|
|
4447
|
+
if (t.processedContent) {
|
|
4448
|
+
let n = document.createElement("div");
|
|
4449
|
+
n.classList.add("text-xs", "font-medium", "text-muted-foreground", "mt-2"), n.textContent = "Output Preview:", e.append(n);
|
|
4450
|
+
let r = document.createElement("div");
|
|
4451
|
+
r.classList.add("text-xs", "bg-muted", "p-2", "rounded", "max-h-24", "overflow-y-auto", "mb-2"), r.textContent = t.processedContent.slice(0, 300) + (t.processedContent.length > 300 ? "..." : ""), e.append(r);
|
|
4452
|
+
}
|
|
4453
|
+
if (t.outputType === "media") {
|
|
4454
|
+
let t = document.createElement("div");
|
|
4455
|
+
t.classList.add("text-xs", "text-muted-foreground", "italic", "mb-2"), t.textContent = "A screenshot of the output will be attached", e.append(t);
|
|
4456
|
+
}
|
|
4457
|
+
return e;
|
|
4458
|
+
}
|
|
4459
|
+
};
|
|
4460
|
+
}
|
|
4461
|
+
formatContext(e) {
|
|
4462
|
+
let { cellOutput: t, cellName: n, cellId: r, cellCode: i } = e.data, a = {
|
|
4463
|
+
name: n,
|
|
4464
|
+
cellId: r,
|
|
4465
|
+
outputType: t.outputType,
|
|
4466
|
+
mimetype: t.output.mimetype
|
|
4467
|
+
}, o = `Cell Code:\n${i}\n\n`;
|
|
4468
|
+
return t.outputType === "text" && t.processedContent ? o += `Output:\n${t.processedContent}` : t.outputType === "media" && (o += `Media Output: Contains ${t.output.mimetype} content`, t.imageUrl && (o += `\nImage URL: ${t.imageUrl}`)), N({
|
|
4469
|
+
type: this.contextType,
|
|
4470
|
+
data: a,
|
|
4471
|
+
details: o
|
|
4472
|
+
});
|
|
4534
4473
|
}
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
done: "Added cell",
|
|
4539
|
-
icon: ye
|
|
4540
|
-
},
|
|
4541
|
-
update_cell: {
|
|
4542
|
-
running: "Editing cell",
|
|
4543
|
-
done: "Edited cell",
|
|
4544
|
-
icon: Be
|
|
4545
|
-
},
|
|
4546
|
-
delete_cell: {
|
|
4547
|
-
running: "Deleting cell",
|
|
4548
|
-
done: "Deleted cell",
|
|
4549
|
-
icon: f
|
|
4474
|
+
async getAttachments(e) {
|
|
4475
|
+
let t = e[0].data.cellId, n = e[0].data.cellName;
|
|
4476
|
+
return _o(e.map((e) => e.data.cellOutput), t, n);
|
|
4550
4477
|
}
|
|
4551
4478
|
};
|
|
4552
|
-
function
|
|
4553
|
-
let
|
|
4554
|
-
if (
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4479
|
+
async function _o(e, t, r) {
|
|
4480
|
+
let i = e.filter((e) => e.shouldDownloadImage && e.outputType === "media");
|
|
4481
|
+
if (i.length === 0) return [];
|
|
4482
|
+
let a = i.flatMap((e) => {
|
|
4483
|
+
let i = document.getElementById(Ce.create(t));
|
|
4484
|
+
return i ? {
|
|
4485
|
+
cellId: t,
|
|
4486
|
+
cellName: r,
|
|
4487
|
+
mimetype: e.output.mimetype,
|
|
4488
|
+
element: i
|
|
4489
|
+
} : (n.warn(`Output element not found for cell ${t}`), []);
|
|
4490
|
+
});
|
|
4491
|
+
try {
|
|
4492
|
+
return await Promise.all(a.map(async (e) => ({
|
|
4493
|
+
type: "file",
|
|
4494
|
+
filename: `${r}-output-screenshot`,
|
|
4495
|
+
mediaType: "image/png",
|
|
4496
|
+
url: await ie(e.element)
|
|
4497
|
+
})));
|
|
4498
|
+
} catch (e) {
|
|
4499
|
+
return n.error("Error downloading cell output images:", e), [];
|
|
4500
|
+
}
|
|
4501
|
+
}
|
|
4502
|
+
function vo(e) {
|
|
4503
|
+
if (T(e)) return null;
|
|
4504
|
+
let t = e.mimetype, n = ho(t, String(e.data)) ? "media" : "text", r = Re(e), i, a = !1;
|
|
4505
|
+
return n === "media" && (typeof e.data == "string" && e.data.startsWith("data:") || typeof e.data == "string" && e.data.startsWith("http") ? i = e.data : a = !0), {
|
|
4506
|
+
processedContent: r,
|
|
4507
|
+
imageUrl: i,
|
|
4508
|
+
shouldDownloadImage: a,
|
|
4509
|
+
outputType: n,
|
|
4510
|
+
output: e
|
|
4558
4511
|
};
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4512
|
+
}
|
|
4513
|
+
function yo(e, t, n, r) {
|
|
4514
|
+
let { includeConsoleOutput: i = !1 } = r || {}, a = t.cellRuntime[e], o = t.cellData[e], s = t.cellIds.indexOf(e), c = je(o.name, s), l;
|
|
4515
|
+
i && (l = a.consoleOutputs.map((e) => vo(e)).filter((e) => e !== null));
|
|
4516
|
+
let u;
|
|
4517
|
+
return n !== null && !T(n) && (u = vo(n) ?? void 0), {
|
|
4518
|
+
cellId: e,
|
|
4519
|
+
cellName: c,
|
|
4520
|
+
cellCode: o.code,
|
|
4521
|
+
cellOutput: u,
|
|
4522
|
+
consoleOutputs: l
|
|
4523
|
+
};
|
|
4524
|
+
}
|
|
4525
|
+
//#endregion
|
|
4526
|
+
//#region src/core/ai/context/providers/error.ts
|
|
4527
|
+
function bo(e, t) {
|
|
4528
|
+
let n = [`Code:\n${e.cellCode}`];
|
|
4529
|
+
if (e.tracebackHtml && n.push(`Traceback:\n${Se(e.tracebackHtml)}`), e.errorData.length > 0 && n.push(e.errorData.map((e) => Me(e)).join("\n\n")), e.errorData.some((e) => e.type === "sql-error")) {
|
|
4530
|
+
let r = oe(e.cellId, t);
|
|
4531
|
+
r && n.push(`Database schema:\n${r}`);
|
|
4532
|
+
}
|
|
4533
|
+
return n.join("\n\n");
|
|
4534
|
+
}
|
|
4535
|
+
function xo(e, t) {
|
|
4536
|
+
return N({
|
|
4537
|
+
type: "error",
|
|
4538
|
+
data: {
|
|
4539
|
+
name: e.cellName || `Cell ${e.cellId}`,
|
|
4540
|
+
cellId: e.cellId
|
|
4541
|
+
},
|
|
4542
|
+
details: bo(e, t)
|
|
4543
|
+
});
|
|
4544
|
+
}
|
|
4545
|
+
function So(e) {
|
|
4546
|
+
return e.errorData.length === 1 ? Ne(e.errorData[0]) : e.errorData.length > 1 ? `${e.errorData.length} errors` : e.tracebackHtml ? Se(e.tracebackHtml).trim().split("\n").find((e) => e.trim())?.trim() || "traceback" : "error";
|
|
4547
|
+
}
|
|
4548
|
+
function Co(e) {
|
|
4549
|
+
return `Error: ${e.cellName || `Cell ${e.cellId}`}`;
|
|
4550
|
+
}
|
|
4551
|
+
var wo = new h("error", "errors"), To = class extends A {
|
|
4552
|
+
title = "Errors";
|
|
4553
|
+
mentionPrefix = "@";
|
|
4554
|
+
contextType = "error";
|
|
4555
|
+
store;
|
|
4556
|
+
constructor(e) {
|
|
4557
|
+
super(), this.store = e;
|
|
4558
|
+
}
|
|
4559
|
+
getItems() {
|
|
4560
|
+
let e = ke(this.store);
|
|
4561
|
+
if (e.length === 0) return [];
|
|
4562
|
+
let t = [{
|
|
4563
|
+
uri: this.asURI("all"),
|
|
4564
|
+
name: "Errors",
|
|
4565
|
+
type: this.contextType,
|
|
4566
|
+
data: {
|
|
4567
|
+
type: "all-errors",
|
|
4568
|
+
errors: e
|
|
4569
|
+
},
|
|
4570
|
+
description: "All errors in the notebook"
|
|
4571
|
+
}];
|
|
4572
|
+
for (let n of e) t.push({
|
|
4573
|
+
uri: this.asURI(n.cellId),
|
|
4574
|
+
name: Co(n),
|
|
4575
|
+
type: this.contextType,
|
|
4576
|
+
data: {
|
|
4577
|
+
type: "cell-error",
|
|
4578
|
+
error: n
|
|
4579
|
+
},
|
|
4580
|
+
description: So(n)
|
|
4581
|
+
});
|
|
4582
|
+
return t;
|
|
4583
|
+
}
|
|
4584
|
+
formatCompletion(e) {
|
|
4585
|
+
if (e.data.type === "all-errors") {
|
|
4586
|
+
let t = e.data.errors.length;
|
|
4563
4587
|
return {
|
|
4564
|
-
label:
|
|
4565
|
-
|
|
4566
|
-
|
|
4588
|
+
label: "@Errors",
|
|
4589
|
+
displayLabel: "Errors",
|
|
4590
|
+
detail: `${t} ${wo.pluralize(t)}`,
|
|
4591
|
+
type: "error",
|
|
4592
|
+
apply: "@error://all",
|
|
4593
|
+
section: P.ERROR,
|
|
4594
|
+
info: () => {
|
|
4595
|
+
let e = document.createElement("div");
|
|
4596
|
+
e.classList.add("mo-cm-tooltip", "docs-documentation", "min-w-[200px]", "flex", "flex-col", "gap-1", "p-2");
|
|
4597
|
+
let n = document.createElement("div");
|
|
4598
|
+
n.classList.add("flex", "flex-col", "gap-1");
|
|
4599
|
+
let r = document.createElement("div");
|
|
4600
|
+
r.classList.add("font-bold", "text-base"), r.textContent = "Errors", n.append(r);
|
|
4601
|
+
let i = document.createElement("div");
|
|
4602
|
+
return i.classList.add("text-sm", "text-muted-foreground"), i.textContent = `${t} ${wo.pluralize(t)}`, n.append(i), e.append(n), e;
|
|
4603
|
+
}
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4606
|
+
if (e.data.type === "cell-error") {
|
|
4607
|
+
let { error: t } = e.data;
|
|
4608
|
+
return {
|
|
4609
|
+
...this.createBasicCompletion(e, {
|
|
4610
|
+
detail: So(t),
|
|
4611
|
+
type: "error"
|
|
4612
|
+
}),
|
|
4613
|
+
section: P.ERROR
|
|
4567
4614
|
};
|
|
4568
4615
|
}
|
|
4569
4616
|
return {
|
|
4570
|
-
label:
|
|
4571
|
-
|
|
4617
|
+
label: "Error",
|
|
4618
|
+
displayLabel: "Error",
|
|
4619
|
+
section: P.ERROR
|
|
4620
|
+
};
|
|
4621
|
+
}
|
|
4622
|
+
formatContext(e) {
|
|
4623
|
+
return (e.data.type === "all-errors" ? e.data.errors : [e.data.error]).map((e) => xo(e, this.store)).join("\n\n");
|
|
4624
|
+
}
|
|
4625
|
+
}, Eo = E(), Do = {
|
|
4626
|
+
maxDepth: 3,
|
|
4627
|
+
maxResults: 20,
|
|
4628
|
+
defaultResultsLimit: 5,
|
|
4629
|
+
includeDirectories: !1
|
|
4630
|
+
}, Oo = class extends A {
|
|
4631
|
+
title = "Files";
|
|
4632
|
+
mentionPrefix = "#";
|
|
4633
|
+
contextType = "file";
|
|
4634
|
+
apiRequests;
|
|
4635
|
+
config;
|
|
4636
|
+
constructor(e, t = Do) {
|
|
4637
|
+
super(), this.apiRequests = e, this.config = t;
|
|
4638
|
+
}
|
|
4639
|
+
createCompletionSource() {
|
|
4640
|
+
return async (e) => {
|
|
4641
|
+
let t = e.matchBefore(/#[^\s#]*/);
|
|
4642
|
+
if (!t) return null;
|
|
4643
|
+
let r = t.text;
|
|
4644
|
+
if (!r.startsWith("#")) return null;
|
|
4645
|
+
let i = r.slice(1);
|
|
4646
|
+
if (i.length === 0) return this.getDefaultCompletions(t);
|
|
4647
|
+
try {
|
|
4648
|
+
let e = (await this.searchFiles(i) || []).map((e) => {
|
|
4649
|
+
let t = {
|
|
4650
|
+
uri: this.asURI(e.path),
|
|
4651
|
+
name: e.name,
|
|
4652
|
+
type: this.contextType,
|
|
4653
|
+
description: e.isDirectory ? "Directory" : "File",
|
|
4654
|
+
data: {
|
|
4655
|
+
path: e.path,
|
|
4656
|
+
isDirectory: e.isDirectory
|
|
4657
|
+
}
|
|
4658
|
+
};
|
|
4659
|
+
return this.formatCompletion(t);
|
|
4660
|
+
});
|
|
4661
|
+
return {
|
|
4662
|
+
from: t.from,
|
|
4663
|
+
options: e
|
|
4664
|
+
};
|
|
4665
|
+
} catch (e) {
|
|
4666
|
+
return n.error("Failed to search files:", e), null;
|
|
4667
|
+
}
|
|
4668
|
+
};
|
|
4669
|
+
}
|
|
4670
|
+
searchFiles = async (e, t = {}) => {
|
|
4671
|
+
let { maxDepth: n, maxResults: r, includeDirectories: i } = {
|
|
4672
|
+
...this.config,
|
|
4673
|
+
...t
|
|
4572
4674
|
};
|
|
4675
|
+
return (await this.apiRequests.sendSearchFiles({
|
|
4676
|
+
query: e,
|
|
4677
|
+
includeFiles: !0,
|
|
4678
|
+
includeDirectories: i,
|
|
4679
|
+
depth: n,
|
|
4680
|
+
limit: r
|
|
4681
|
+
})).files;
|
|
4682
|
+
};
|
|
4683
|
+
async getDefaultCompletions(e) {
|
|
4684
|
+
try {
|
|
4685
|
+
for (let t of [
|
|
4686
|
+
"py",
|
|
4687
|
+
"md",
|
|
4688
|
+
"csv"
|
|
4689
|
+
]) try {
|
|
4690
|
+
let n = await this.searchFiles(t, {
|
|
4691
|
+
maxDepth: 1,
|
|
4692
|
+
maxResults: 5
|
|
4693
|
+
});
|
|
4694
|
+
if (n && n.length > 0) {
|
|
4695
|
+
let t = n.map((e) => {
|
|
4696
|
+
let t = {
|
|
4697
|
+
uri: this.asURI(e.path),
|
|
4698
|
+
name: e.name,
|
|
4699
|
+
type: this.contextType,
|
|
4700
|
+
description: e.isDirectory ? "Directory" : "File",
|
|
4701
|
+
data: {
|
|
4702
|
+
path: e.path,
|
|
4703
|
+
isDirectory: e.isDirectory
|
|
4704
|
+
}
|
|
4705
|
+
};
|
|
4706
|
+
return this.formatCompletion(t);
|
|
4707
|
+
});
|
|
4708
|
+
return {
|
|
4709
|
+
from: e.from,
|
|
4710
|
+
options: t
|
|
4711
|
+
};
|
|
4712
|
+
}
|
|
4713
|
+
} catch (e) {
|
|
4714
|
+
n.error("Failed to get default file completions:", e);
|
|
4715
|
+
}
|
|
4716
|
+
return {
|
|
4717
|
+
from: e.from,
|
|
4718
|
+
options: []
|
|
4719
|
+
};
|
|
4720
|
+
} catch (e) {
|
|
4721
|
+
return n.error("Failed to get default file completions:", e), null;
|
|
4722
|
+
}
|
|
4573
4723
|
}
|
|
4574
|
-
|
|
4575
|
-
|
|
4724
|
+
getItems() {
|
|
4725
|
+
return [];
|
|
4726
|
+
}
|
|
4727
|
+
formatCompletion(e) {
|
|
4728
|
+
let { data: t, name: r } = e, i = t.isDirectory ? "📁" : "📄";
|
|
4576
4729
|
return {
|
|
4577
|
-
|
|
4578
|
-
|
|
4730
|
+
...this.createBasicCompletion(e),
|
|
4731
|
+
type: "file",
|
|
4732
|
+
section: P.FILE,
|
|
4733
|
+
boost: t.isDirectory ? O.MEDIUM : O.LOW,
|
|
4734
|
+
detail: t.path,
|
|
4735
|
+
displayLabel: `${i} ${r}`,
|
|
4736
|
+
apply: async (e, i, a, o) => {
|
|
4737
|
+
let s = e.state.facet(Eo)?.addAttachment;
|
|
4738
|
+
if (!s) {
|
|
4739
|
+
n.warn("No addAttachment callback provided");
|
|
4740
|
+
return;
|
|
4741
|
+
}
|
|
4742
|
+
let l = await this.apiRequests.sendFileDetails({ path: t.path }).catch((e) => (c({
|
|
4743
|
+
title: "Failed to get file details",
|
|
4744
|
+
description: e.message
|
|
4745
|
+
}), null));
|
|
4746
|
+
if (!l) return;
|
|
4747
|
+
let u = l.mimeType || "text/plain", d = Pe({
|
|
4748
|
+
contents: l.contents ?? "",
|
|
4749
|
+
mimeType: u,
|
|
4750
|
+
isBase64: l.isBase64 ?? !1
|
|
4751
|
+
});
|
|
4752
|
+
s(new File([d], r, { type: u })), e.dispatch({ changes: {
|
|
4753
|
+
from: a,
|
|
4754
|
+
to: o,
|
|
4755
|
+
insert: ""
|
|
4756
|
+
} }), Mt(e);
|
|
4757
|
+
},
|
|
4758
|
+
info: () => {
|
|
4759
|
+
let e = document.createElement("div");
|
|
4760
|
+
e.classList.add("flex", "flex-col", "gap-1", "p-2");
|
|
4761
|
+
let n = document.createElement("div");
|
|
4762
|
+
n.classList.add("font-bold"), n.textContent = r, e.append(n);
|
|
4763
|
+
let i = document.createElement("div");
|
|
4764
|
+
return i.classList.add("text-xs", "text-muted-foreground"), i.textContent = t.path, e.append(i), e;
|
|
4765
|
+
}
|
|
4579
4766
|
};
|
|
4580
4767
|
}
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
code: typeof n == "string" ? n : void 0
|
|
4593
|
-
};
|
|
4594
|
-
}
|
|
4595
|
-
function fo(e) {
|
|
4596
|
-
if (typeof e != "string") return;
|
|
4597
|
-
let t = e.split("\n").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
4598
|
-
return t.find((e) => !/^(import\s|from\s|#)/.test(e)) ?? t[0];
|
|
4599
|
-
}
|
|
4600
|
-
function po(e) {
|
|
4601
|
-
return typeof e == "object" && !!e;
|
|
4602
|
-
}
|
|
4603
|
-
//#endregion
|
|
4604
|
-
//#region src/components/chat/tool-call/tool-result.tsx
|
|
4605
|
-
function mo(e) {
|
|
4606
|
-
return e == null || typeof e == "object" && gt(e);
|
|
4607
|
-
}
|
|
4608
|
-
var ho = rt({
|
|
4609
|
-
status: it().default("success"),
|
|
4610
|
-
auth_required: qe().default(!1),
|
|
4611
|
-
action_url: Qe().optional(),
|
|
4612
|
-
next_steps: Qe().optional(),
|
|
4613
|
-
meta: Qe().optional(),
|
|
4614
|
-
message: it().nullish()
|
|
4615
|
-
}), go = (e) => {
|
|
4616
|
-
let t = (0, I.c)(12), { data: n } = e, r;
|
|
4617
|
-
if (t[0] !== n) {
|
|
4618
|
-
let { status: e, auth_required: i, action_url: a, meta: o, next_steps: s, message: c, ...l } = n, u;
|
|
4619
|
-
t[2] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ (0, Z.jsx)("h3", {
|
|
4620
|
-
className: "text-xs font-semibold text-muted-foreground",
|
|
4621
|
-
children: "Tool Result"
|
|
4622
|
-
}), t[2] = u) : u = t[2];
|
|
4623
|
-
let d;
|
|
4624
|
-
t[3] === e ? d = t[4] : (d = /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4625
|
-
className: "text-xs text-muted-foreground capitalize",
|
|
4626
|
-
children: e
|
|
4627
|
-
}), t[3] = e, t[4] = d);
|
|
4628
|
-
let f;
|
|
4629
|
-
t[5] === i ? f = t[6] : (f = i && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4630
|
-
className: "text-xs px-2 py-0.5 bg-(--amber-2) text-(--amber-11) rounded-full",
|
|
4631
|
-
children: "Auth Required"
|
|
4632
|
-
}), t[5] = i, t[6] = f);
|
|
4633
|
-
let p;
|
|
4634
|
-
t[7] !== d || t[8] !== f ? (p = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4635
|
-
className: "flex items-center justify-between",
|
|
4636
|
-
children: [u, /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4637
|
-
className: "flex items-center gap-2",
|
|
4638
|
-
children: [d, f]
|
|
4639
|
-
})]
|
|
4640
|
-
}), t[7] = d, t[8] = f, t[9] = p) : p = t[9];
|
|
4641
|
-
let h;
|
|
4642
|
-
t[10] === c ? h = t[11] : (h = c && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4643
|
-
className: "flex items-start gap-2",
|
|
4644
|
-
children: [/* @__PURE__ */ (0, Z.jsx)(m, { className: "h-3 w-3 text-(--blue-11) mt-0.5 shrink-0" }), /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4645
|
-
className: "text-xs text-foreground",
|
|
4646
|
-
children: c
|
|
4647
|
-
})]
|
|
4648
|
-
}), t[10] = c, t[11] = h), r = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4649
|
-
className: "flex flex-col gap-1.5",
|
|
4650
|
-
children: [
|
|
4651
|
-
p,
|
|
4652
|
-
h,
|
|
4653
|
-
l && /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4654
|
-
className: "space-y-3",
|
|
4655
|
-
children: Object.entries(l).map(vo)
|
|
4656
|
-
})
|
|
4657
|
-
]
|
|
4658
|
-
}), t[0] = n, t[1] = r;
|
|
4659
|
-
} else r = t[1];
|
|
4660
|
-
return r;
|
|
4661
|
-
}, _o = (e) => {
|
|
4662
|
-
let t = (0, I.c)(8), { result: n } = e, r;
|
|
4663
|
-
t[0] === n ? r = t[1] : (r = ho.safeParse(n), t[0] = n, t[1] = r);
|
|
4664
|
-
let i = r;
|
|
4665
|
-
if (i.success) {
|
|
4666
|
-
let e;
|
|
4667
|
-
return t[2] === i.data ? e = t[3] : (e = /* @__PURE__ */ (0, Z.jsx)(go, { data: i.data }), t[2] = i.data, t[3] = e), e;
|
|
4768
|
+
formatContext(e) {
|
|
4769
|
+
let { data: t, name: n } = e;
|
|
4770
|
+
return N({
|
|
4771
|
+
type: this.contextType,
|
|
4772
|
+
data: {
|
|
4773
|
+
name: n,
|
|
4774
|
+
path: t.path,
|
|
4775
|
+
isDirectory: t.isDirectory
|
|
4776
|
+
},
|
|
4777
|
+
details: t.isDirectory ? "Directory containing files and subdirectories" : "File"
|
|
4778
|
+
});
|
|
4668
4779
|
}
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
})
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
})
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
let E;
|
|
4708
|
-
t[27] === g ? E = t[28] : (E = /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4709
|
-
className: "shrink-0",
|
|
4710
|
-
children: g
|
|
4711
|
-
}), t[27] = g, t[28] = E);
|
|
4712
|
-
let D;
|
|
4713
|
-
t[29] === h ? D = t[30] : (D = h && /* @__PURE__ */ (0, Z.jsx)("code", {
|
|
4714
|
-
className: "min-w-0 truncate font-mono text-[0.6875rem] opacity-80",
|
|
4715
|
-
children: h
|
|
4716
|
-
}), t[29] = h, t[30] = D);
|
|
4717
|
-
let O;
|
|
4718
|
-
t[31] === _.suffix ? O = t[32] : (O = _.suffix && /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
4719
|
-
className: "shrink-0 opacity-80",
|
|
4720
|
-
children: ["· ", _.suffix]
|
|
4721
|
-
}), t[31] = _.suffix, t[32] = O);
|
|
4722
|
-
let k = f && "rotate-90 opacity-100", A;
|
|
4723
|
-
t[33] === k ? A = t[34] : (A = r("size-3 shrink-0 opacity-40 transition-transform group-hover/step:opacity-100", k), t[33] = k, t[34] = A);
|
|
4724
|
-
let j;
|
|
4725
|
-
t[35] === A ? j = t[36] : (j = /* @__PURE__ */ (0, Z.jsx)(fe, {
|
|
4726
|
-
"aria-hidden": !0,
|
|
4727
|
-
className: A
|
|
4728
|
-
}), t[35] = A, t[36] = j);
|
|
4729
|
-
let M;
|
|
4730
|
-
t[37] !== E || t[38] !== D || t[39] !== O || t[40] !== j || t[41] !== b || t[42] !== x || t[43] !== S || t[44] !== C || t[45] !== T ? (M = /* @__PURE__ */ (0, Z.jsxs)("button", {
|
|
4731
|
-
type: b,
|
|
4732
|
-
onClick: x,
|
|
4733
|
-
"aria-expanded": S,
|
|
4734
|
-
className: C,
|
|
4735
|
-
children: [
|
|
4736
|
-
T,
|
|
4737
|
-
E,
|
|
4738
|
-
D,
|
|
4739
|
-
O,
|
|
4740
|
-
j
|
|
4741
|
-
]
|
|
4742
|
-
}), t[37] = E, t[38] = D, t[39] = O, t[40] = j, t[41] = b, t[42] = x, t[43] = S, t[44] = C, t[45] = T, t[46] = M) : M = t[46];
|
|
4743
|
-
let N;
|
|
4744
|
-
t[47] !== c || t[48] !== s || t[49] !== a || t[50] !== f || t[51] !== o || t[52] !== i ? (N = f && /* @__PURE__ */ (0, Z.jsx)(xo, {
|
|
4745
|
-
state: i,
|
|
4746
|
-
input: a,
|
|
4747
|
-
result: o,
|
|
4748
|
-
errorText: s,
|
|
4749
|
-
approval: c
|
|
4750
|
-
}), t[47] = c, t[48] = s, t[49] = a, t[50] = f, t[51] = o, t[52] = i, t[53] = N) : N = t[53];
|
|
4751
|
-
let ee;
|
|
4752
|
-
return t[54] !== M || t[55] !== N || t[56] !== w ? (ee = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4753
|
-
className: w,
|
|
4754
|
-
children: [M, N]
|
|
4755
|
-
}), t[54] = M, t[55] = N, t[56] = w, t[57] = ee) : ee = t[57], ee;
|
|
4756
|
-
};
|
|
4757
|
-
function bo(e, t, n) {
|
|
4758
|
-
if (t) return {
|
|
4759
|
-
icon: Ut,
|
|
4760
|
-
suffix: "Stopped"
|
|
4761
|
-
};
|
|
4762
|
-
switch (e) {
|
|
4763
|
-
case "output-error": return {
|
|
4764
|
-
icon: C,
|
|
4765
|
-
suffix: "Failed"
|
|
4766
|
-
};
|
|
4767
|
-
case "output-denied": return {
|
|
4768
|
-
icon: Rt,
|
|
4769
|
-
suffix: "Denied"
|
|
4770
|
-
};
|
|
4771
|
-
case "output-available": return { icon: n };
|
|
4772
|
-
default: return {
|
|
4773
|
-
icon: y,
|
|
4774
|
-
spinning: !0
|
|
4775
|
-
};
|
|
4780
|
+
}, ko = class extends A {
|
|
4781
|
+
title = "Tables";
|
|
4782
|
+
mentionPrefix = "@";
|
|
4783
|
+
contextType = "data";
|
|
4784
|
+
tablesMap;
|
|
4785
|
+
constructor(e) {
|
|
4786
|
+
super(), this.tablesMap = e;
|
|
4787
|
+
}
|
|
4788
|
+
getItems() {
|
|
4789
|
+
return [...this.tablesMap.entries()].map(([e, t]) => ({
|
|
4790
|
+
uri: this.asURI(e),
|
|
4791
|
+
name: e,
|
|
4792
|
+
type: this.contextType,
|
|
4793
|
+
description: t.source === "memory" ? "in-memory" : t.source,
|
|
4794
|
+
data: t
|
|
4795
|
+
}));
|
|
4796
|
+
}
|
|
4797
|
+
formatContext(e) {
|
|
4798
|
+
let { data: t } = e, { columns: n, source: r, num_rows: i, num_columns: a, name: o, variable_name: s } = t, c = [i == null ? void 0 : `${i} rows`, a == null ? void 0 : `${a} columns`].filter(Boolean).join(", "), l = "";
|
|
4799
|
+
if (c && (l += `Shape: ${c}\n`), s && (l += `Variable: ${s}\n`), n && n.length > 0) {
|
|
4800
|
+
l += "Columns:\n";
|
|
4801
|
+
for (let e of n) {
|
|
4802
|
+
let t = ` ${e.name} (${e.type})`;
|
|
4803
|
+
if (e.sample_values && e.sample_values.length > 0) {
|
|
4804
|
+
let n = e.sample_values.slice(0, 3).map((e) => e === null ? "null" : String(e)).join(", ");
|
|
4805
|
+
t += ` - samples: [${n}]`;
|
|
4806
|
+
}
|
|
4807
|
+
l += `${t}\n`;
|
|
4808
|
+
}
|
|
4809
|
+
}
|
|
4810
|
+
return N({
|
|
4811
|
+
type: this.contextType,
|
|
4812
|
+
data: {
|
|
4813
|
+
name: o,
|
|
4814
|
+
source: r ?? "unknown"
|
|
4815
|
+
},
|
|
4816
|
+
details: l.trim()
|
|
4817
|
+
});
|
|
4776
4818
|
}
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
}), t[8] = o, t[9] = n, t[10] = u) : u = t[10];
|
|
4793
|
-
let d;
|
|
4794
|
-
return t[11] !== s || t[12] !== c || t[13] !== l || t[14] !== u ? (d = /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4795
|
-
className: "mt-1 mb-2 ml-5.5 space-y-3",
|
|
4796
|
-
children: [
|
|
4797
|
-
s,
|
|
4798
|
-
c,
|
|
4799
|
-
l,
|
|
4800
|
-
u
|
|
4801
|
-
]
|
|
4802
|
-
}), t[11] = s, t[12] = c, t[13] = l, t[14] = u, t[15] = d) : d = t[15], d;
|
|
4803
|
-
};
|
|
4804
|
-
function So(e) {
|
|
4805
|
-
return !e;
|
|
4806
|
-
}
|
|
4807
|
-
//#endregion
|
|
4808
|
-
//#region src/components/chat/tool-call/tool-call-view.tsx
|
|
4809
|
-
var Co = (e) => {
|
|
4810
|
-
let t = (0, I.c)(16), n, r, i, a, o;
|
|
4811
|
-
if (t[0] === e ? (n = t[1], r = t[2], i = t[3], a = t[4], o = t[5]) : ({toolName: o, state: a, approval: n, onApprove: r, ...i} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i, t[4] = a, t[5] = o), a === "approval-requested") {
|
|
4812
|
-
let e;
|
|
4813
|
-
return t[6] !== n || t[7] !== r || t[8] !== i || t[9] !== o ? (e = n != null && r != null ? /* @__PURE__ */ (0, Z.jsx)(oo, {
|
|
4814
|
-
toolName: o,
|
|
4815
|
-
input: i.input,
|
|
4816
|
-
approval: n,
|
|
4817
|
-
onApprove: r,
|
|
4818
|
-
className: i.className
|
|
4819
|
-
}) : /* @__PURE__ */ (0, Z.jsx)(yo, {
|
|
4820
|
-
...i,
|
|
4821
|
-
toolName: o,
|
|
4822
|
-
state: "input-available"
|
|
4823
|
-
}), t[6] = n, t[7] = r, t[8] = i, t[9] = o, t[10] = e) : e = t[10], e;
|
|
4819
|
+
formatCompletion(e) {
|
|
4820
|
+
let t = e.data.name, n = e.data;
|
|
4821
|
+
return {
|
|
4822
|
+
label: `@${t}`,
|
|
4823
|
+
displayLabel: t,
|
|
4824
|
+
detail: n.source === "memory" ? "in-memory" : n.source,
|
|
4825
|
+
boost: n.source_type === "local" ? O.LOCAL_TABLE : O.REMOTE_TABLE,
|
|
4826
|
+
type: ae(n),
|
|
4827
|
+
apply: `@${t}`,
|
|
4828
|
+
section: {
|
|
4829
|
+
name: ae(n) === "dataframe" ? "Dataframe" : "Table",
|
|
4830
|
+
rank: P.TABLE.rank
|
|
4831
|
+
},
|
|
4832
|
+
info: () => this.createTableInfoElement(t, n)
|
|
4833
|
+
};
|
|
4824
4834
|
}
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4835
|
+
createTableInfoElement(e, t) {
|
|
4836
|
+
let n = document.createElement("div");
|
|
4837
|
+
n.classList.add("mo-cm-tooltip", "docs-documentation", "min-w-[200px]", "flex", "flex-col", "gap-1", "p-2");
|
|
4838
|
+
let r = document.createElement("div");
|
|
4839
|
+
r.classList.add("flex", "flex-col", "gap-1");
|
|
4840
|
+
let i = document.createElement("div");
|
|
4841
|
+
if (i.classList.add("font-bold", "text-base"), i.textContent = e, r.append(i), t.source) {
|
|
4842
|
+
let e = document.createElement("div");
|
|
4843
|
+
e.classList.add("text-xs", "text-muted-foreground"), e.textContent = `Source: ${t.source}`, r.append(e);
|
|
4844
|
+
}
|
|
4845
|
+
n.append(r);
|
|
4846
|
+
let a = [t.num_rows == null ? void 0 : `${t.num_rows} rows`, t.num_columns == null ? void 0 : `${t.num_columns} columns`].filter(Boolean).join(", ");
|
|
4847
|
+
if (a) {
|
|
4848
|
+
let e = document.createElement("div");
|
|
4849
|
+
e.classList.add("text-xs", "bg-muted", "px-2", "py-1", "rounded"), e.textContent = a, n.append(e);
|
|
4850
|
+
}
|
|
4851
|
+
if (t.columns && t.columns.length > 0) {
|
|
4852
|
+
let e = document.createElement("div");
|
|
4853
|
+
e.classList.add("overflow-auto", "max-h-60");
|
|
4854
|
+
let r = document.createElement("table");
|
|
4855
|
+
r.classList.add("w-full", "text-xs", "border-collapse");
|
|
4856
|
+
let i = r.insertRow();
|
|
4857
|
+
i.classList.add("bg-muted");
|
|
4858
|
+
let a = i.insertCell();
|
|
4859
|
+
a.classList.add("p-2", "font-medium", "text-left"), a.textContent = "Column";
|
|
4860
|
+
let o = i.insertCell();
|
|
4861
|
+
o.classList.add("p-2", "font-medium", "text-left"), o.textContent = "Type";
|
|
4862
|
+
let s = t.columns.some((e) => this.getItemMetadata(t, e) !== void 0), c;
|
|
4863
|
+
s && (c = i.insertCell(), c.classList.add("p-2", "font-medium", "text-left"), c.textContent = "Metadata"), t.columns.forEach((e, n) => {
|
|
4864
|
+
let i = r.insertRow();
|
|
4865
|
+
i.classList.add(n % 2 == 0 ? "bg-background" : "bg-muted/30");
|
|
4866
|
+
let a = i.insertCell();
|
|
4867
|
+
a.classList.add("p-2", "font-mono"), a.textContent = e.name;
|
|
4868
|
+
let o = i.insertCell();
|
|
4869
|
+
if (o.classList.add("p-2", "text-muted-foreground"), o.textContent = e.type, s) {
|
|
4870
|
+
let n = i.insertCell();
|
|
4871
|
+
n.classList.add("p-2");
|
|
4872
|
+
let r = this.getItemMetadata(t, e);
|
|
4873
|
+
r && n.append(r);
|
|
4874
|
+
}
|
|
4875
|
+
}), e.append(r), n.append(e);
|
|
4876
|
+
}
|
|
4877
|
+
return n;
|
|
4846
4878
|
}
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
state: e.state,
|
|
4855
|
-
input: e.input,
|
|
4856
|
-
approval: e.approval,
|
|
4857
|
-
onApprove: i,
|
|
4858
|
-
isActive: a,
|
|
4859
|
-
className: n ? void 0 : "my-1"
|
|
4860
|
-
}, t);
|
|
4861
|
-
if (Ao(e)) return null;
|
|
4862
|
-
switch (e.type) {
|
|
4863
|
-
case "text": return e.text.includes("<marimo-") ? /* @__PURE__ */ (0, Z.jsx)(X.Fragment, { children: _({ html: e.text }) }, t) : /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4864
|
-
className: n ? "py-1.5" : void 0,
|
|
4865
|
-
children: /* @__PURE__ */ (0, Z.jsx)(no, { content: e.text })
|
|
4866
|
-
}, t);
|
|
4867
|
-
case "reasoning": return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4868
|
-
className: "flex gap-1.5 py-1.5 text-muted-foreground",
|
|
4869
|
-
children: [/* @__PURE__ */ (0, Z.jsx)(Vt, {
|
|
4870
|
-
"aria-hidden": !0,
|
|
4871
|
-
className: "-ml-px mt-1 size-3 shrink-0"
|
|
4872
|
-
}), /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
4873
|
-
className: "min-w-0 italic [&_p]:my-1 [&_p:first-child]:mt-0",
|
|
4874
|
-
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
4875
|
-
className: "sr-only",
|
|
4876
|
-
children: "Reasoning: "
|
|
4877
|
-
}), /* @__PURE__ */ (0, Z.jsx)(no, { content: e.text })]
|
|
4878
|
-
})]
|
|
4879
|
-
}, t);
|
|
4880
|
-
case "file": return /* @__PURE__ */ (0, Z.jsx)(eo, { attachment: e }, t);
|
|
4881
|
-
case "reasoning-file": return /* @__PURE__ */ (0, Z.jsx)(eo, { attachment: {
|
|
4882
|
-
type: "file",
|
|
4883
|
-
mediaType: e.mediaType,
|
|
4884
|
-
url: e.url
|
|
4885
|
-
} }, t);
|
|
4886
|
-
case "source-document": return /* @__PURE__ */ (0, Z.jsx)(to, {
|
|
4887
|
-
icon: /* @__PURE__ */ (0, Z.jsx)(g, { className: "h-3 w-3 shrink-0" }),
|
|
4888
|
-
title: e.title,
|
|
4889
|
-
subtitle: e.filename
|
|
4890
|
-
}, t);
|
|
4891
|
-
case "source-url": return /* @__PURE__ */ (0, Z.jsx)(to, {
|
|
4892
|
-
icon: /* @__PURE__ */ (0, Z.jsx)(De, { className: "h-3 w-3 shrink-0" }),
|
|
4893
|
-
title: e.title ?? e.url,
|
|
4894
|
-
subtitle: e.title ? e.url : void 0,
|
|
4895
|
-
href: e.url
|
|
4896
|
-
}, t);
|
|
4897
|
-
case "custom": return /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
4898
|
-
className: "text-sm text-muted-foreground",
|
|
4899
|
-
children: e.kind
|
|
4900
|
-
}, t);
|
|
4901
|
-
case "step-start": return null;
|
|
4902
|
-
default: return Ve(e), null;
|
|
4879
|
+
getItemMetadata(e, t) {
|
|
4880
|
+
let n = e.primary_keys?.includes(t.name), r = e.indexes?.includes(t.name);
|
|
4881
|
+
if (n || r) {
|
|
4882
|
+
let e = document.createElement("span");
|
|
4883
|
+
e.textContent = n ? "PK" : "IDX";
|
|
4884
|
+
let t = n ? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200" : "bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200";
|
|
4885
|
+
return e.classList.add("text-xs", "px-1.5", "py-0.5", "rounded-full", "font-medium", ...t.split(" ")), e;
|
|
4903
4886
|
}
|
|
4904
4887
|
}
|
|
4888
|
+
}, Ao = class extends A {
|
|
4889
|
+
title = "Variables";
|
|
4890
|
+
mentionPrefix = "@";
|
|
4891
|
+
contextType = "variable";
|
|
4892
|
+
variables;
|
|
4893
|
+
tablesMap;
|
|
4894
|
+
constructor(e, t) {
|
|
4895
|
+
super(), this.variables = e, this.tablesMap = t;
|
|
4896
|
+
}
|
|
4897
|
+
getItems() {
|
|
4898
|
+
let e = new Set(this.tablesMap.keys());
|
|
4899
|
+
return Object.entries(this.variables).flatMap(([t, n]) => e.has(t) ? [] : [{
|
|
4900
|
+
uri: this.asURI(t),
|
|
4901
|
+
name: t,
|
|
4902
|
+
type: this.contextType,
|
|
4903
|
+
description: n.dataType ?? "",
|
|
4904
|
+
dataType: n.dataType,
|
|
4905
|
+
data: { variable: n }
|
|
4906
|
+
}]);
|
|
4907
|
+
}
|
|
4908
|
+
formatCompletion(e) {
|
|
4909
|
+
let { data: t } = e, { variable: n } = t;
|
|
4910
|
+
return {
|
|
4911
|
+
label: `@${n.name}`,
|
|
4912
|
+
displayLabel: n.name,
|
|
4913
|
+
detail: n.dataType ?? "",
|
|
4914
|
+
type: this.contextType,
|
|
4915
|
+
section: P.VARIABLE,
|
|
4916
|
+
info: () => ne(n)
|
|
4917
|
+
};
|
|
4918
|
+
}
|
|
4919
|
+
formatContext(e) {
|
|
4920
|
+
let { data: t } = e, { variable: n } = t;
|
|
4921
|
+
return N({
|
|
4922
|
+
type: this.contextType,
|
|
4923
|
+
data: {
|
|
4924
|
+
name: n.name,
|
|
4925
|
+
dataType: n.dataType
|
|
4926
|
+
},
|
|
4927
|
+
details: n.value == null ? void 0 : JSON.stringify(n.value)
|
|
4928
|
+
});
|
|
4929
|
+
}
|
|
4905
4930
|
};
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
return {
|
|
4912
|
-
work: t.filter(({ part: e }, t) => t <= n && !Eo(e)),
|
|
4913
|
-
rest: t.filter(({ part: e }, t) => t > n || Eo(e))
|
|
4914
|
-
};
|
|
4915
|
-
}
|
|
4916
|
-
function Eo(e) {
|
|
4917
|
-
return Oo(e) && e.state === "approval-requested";
|
|
4931
|
+
//#endregion
|
|
4932
|
+
//#region src/core/ai/context/context.ts
|
|
4933
|
+
function jo(e) {
|
|
4934
|
+
let t = e.get(D), n = e.get(u), r = e.get(ee);
|
|
4935
|
+
return new k().register(new ko(n)).register(new Ao(r, n)).register(new To(e)).register(new go(e)).register(new mo(e)).register(new M(t.connectionsMap, n));
|
|
4918
4936
|
}
|
|
4919
|
-
function
|
|
4920
|
-
|
|
4921
|
-
case "step-start": return !1;
|
|
4922
|
-
case "text": return e.text.trim().length > 0;
|
|
4923
|
-
case "reasoning": return e.text.trim().length > 0;
|
|
4924
|
-
default: return !Ao(e);
|
|
4925
|
-
}
|
|
4937
|
+
function Mo() {
|
|
4938
|
+
return new Oo(Ee());
|
|
4926
4939
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4940
|
+
//#endregion
|
|
4941
|
+
//#region src/components/editor/ai/completion-utils.ts
|
|
4942
|
+
function No(e, t = []) {
|
|
4943
|
+
return (n) => {
|
|
4944
|
+
let r = e.map((e) => n.matchBefore(e)).find(Boolean);
|
|
4945
|
+
return !r || r && r.from === r.to && !n.explicit ? null : {
|
|
4946
|
+
from: r?.from,
|
|
4947
|
+
options: [...t]
|
|
4948
|
+
};
|
|
4949
|
+
};
|
|
4929
4950
|
}
|
|
4930
|
-
|
|
4931
|
-
|
|
4951
|
+
//#endregion
|
|
4952
|
+
//#region src/components/chat/chat-utils.ts
|
|
4953
|
+
async function Po(e) {
|
|
4954
|
+
return await Promise.all(e.map(async (e) => {
|
|
4955
|
+
let t = await fo(e);
|
|
4956
|
+
return {
|
|
4957
|
+
type: "file",
|
|
4958
|
+
mediaType: t.type,
|
|
4959
|
+
filename: e.name,
|
|
4960
|
+
url: await Ie(t)
|
|
4961
|
+
};
|
|
4962
|
+
}));
|
|
4932
4963
|
}
|
|
4933
|
-
function
|
|
4934
|
-
|
|
4964
|
+
function Fo(e) {
|
|
4965
|
+
let t = e.at(-1);
|
|
4966
|
+
if (!t || t.role !== "assistant") return !1;
|
|
4967
|
+
let n = t.parts.at(-1);
|
|
4968
|
+
return !n || !Y(n) ? !1 : sa({ messages: e }) || oa({ messages: e }) || n.state === "output-denied" && !n.providerExecuted;
|
|
4935
4969
|
}
|
|
4936
4970
|
//#endregion
|
|
4937
4971
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-ai@0.3.10_@codemirror+state@6.7.6_@codemirror+view@6.43.13/node_modules/@marimo-team/codemirror-ai/dist/utils/facet.js
|
|
4938
|
-
function
|
|
4972
|
+
function Io(e) {
|
|
4939
4973
|
return At.define({ combine: (t) => t[0] ?? e });
|
|
4940
4974
|
}
|
|
4941
4975
|
//#endregion
|
|
4942
4976
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-ai@0.3.10_@codemirror+state@6.7.6_@codemirror+view@6.43.13/node_modules/@marimo-team/codemirror-ai/dist/prompt-history/extension.js
|
|
4943
|
-
var
|
|
4977
|
+
var Lo = Io({}), Ro = St.define(), zo = St.define(), Bo = 50, Vo = Tt.define({
|
|
4944
4978
|
create() {
|
|
4945
4979
|
return {
|
|
4946
4980
|
prompts: [],
|
|
@@ -4950,15 +4984,15 @@ var Mo = jo({}), No = St.define(), Po = St.define(), Fo = 50, Io = Tt.define({
|
|
|
4950
4984
|
},
|
|
4951
4985
|
update(e, t) {
|
|
4952
4986
|
let n = { ...e };
|
|
4953
|
-
t.docChanged && e.navigationIndex !== -1 && (t.effects.some((e) => e.is(
|
|
4954
|
-
for (let r of t.effects) if (r.is(
|
|
4987
|
+
t.docChanged && e.navigationIndex !== -1 && (t.effects.some((e) => e.is(zo) || e.is(Ro)) || (n.navigationIndex = -1, n.originalText = ""));
|
|
4988
|
+
for (let r of t.effects) if (r.is(Ro)) {
|
|
4955
4989
|
let i = r.value.trim();
|
|
4956
|
-
i && (n.prompts = [i, ...e.prompts.filter((e) => e !== i)].slice(0,
|
|
4957
|
-
} else r.is(
|
|
4990
|
+
i && (n.prompts = [i, ...e.prompts.filter((e) => e !== i)].slice(0, Bo), t.state.facet(Lo).save?.(n.prompts)), n.navigationIndex = -1, n.originalText = "";
|
|
4991
|
+
} else r.is(zo) && (n.navigationIndex = r.value.index, n.originalText = r.value.originalText);
|
|
4958
4992
|
return n;
|
|
4959
4993
|
}
|
|
4960
|
-
}),
|
|
4961
|
-
let t = e.state.field(
|
|
4994
|
+
}), Ho = (e) => {
|
|
4995
|
+
let t = e.state.field(Vo), n = e.state.doc;
|
|
4962
4996
|
if (t.prompts.length === 0) return !1;
|
|
4963
4997
|
let r, i = t.originalText;
|
|
4964
4998
|
if (t.navigationIndex === -1) {
|
|
@@ -4972,13 +5006,13 @@ var Mo = jo({}), No = St.define(), Po = St.define(), Fo = 50, Io = Tt.define({
|
|
|
4972
5006
|
to: e.state.doc.length,
|
|
4973
5007
|
insert: a
|
|
4974
5008
|
},
|
|
4975
|
-
effects:
|
|
5009
|
+
effects: zo.of({
|
|
4976
5010
|
index: r,
|
|
4977
5011
|
originalText: i
|
|
4978
5012
|
})
|
|
4979
5013
|
}), !0;
|
|
4980
|
-
},
|
|
4981
|
-
let t = e.state.field(
|
|
5014
|
+
}, Uo = (e) => {
|
|
5015
|
+
let t = e.state.field(Vo);
|
|
4982
5016
|
if (t.navigationIndex === -1) return !1;
|
|
4983
5017
|
let n, r;
|
|
4984
5018
|
return t.navigationIndex === 0 ? (n = t.originalText, r = -1) : (r = t.navigationIndex - 1, n = t.prompts[r] ?? ""), e.dispatch({
|
|
@@ -4987,41 +5021,41 @@ var Mo = jo({}), No = St.define(), Po = St.define(), Fo = 50, Io = Tt.define({
|
|
|
4987
5021
|
to: e.state.doc.length,
|
|
4988
5022
|
insert: n
|
|
4989
5023
|
},
|
|
4990
|
-
effects:
|
|
5024
|
+
effects: zo.of({
|
|
4991
5025
|
index: r,
|
|
4992
5026
|
originalText: t.originalText
|
|
4993
5027
|
})
|
|
4994
5028
|
}), !0;
|
|
4995
5029
|
};
|
|
4996
|
-
function
|
|
4997
|
-
let { storage: t, defaultKeymap: n = !0 } = e, r = [
|
|
5030
|
+
function Wo(e = {}) {
|
|
5031
|
+
let { storage: t, defaultKeymap: n = !0 } = e, r = [Vo.init(() => ({
|
|
4998
5032
|
prompts: t?.load?.() ?? [],
|
|
4999
5033
|
navigationIndex: -1,
|
|
5000
5034
|
originalText: ""
|
|
5001
|
-
})),
|
|
5035
|
+
})), Lo.of(t ?? {})];
|
|
5002
5036
|
return n && r.push(Ot.of([{
|
|
5003
5037
|
key: "ArrowUp",
|
|
5004
|
-
run:
|
|
5038
|
+
run: Ho
|
|
5005
5039
|
}, {
|
|
5006
5040
|
key: "ArrowDown",
|
|
5007
|
-
run:
|
|
5041
|
+
run: Uo
|
|
5008
5042
|
}])), r;
|
|
5009
5043
|
}
|
|
5010
5044
|
//#endregion
|
|
5011
5045
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-mcp@0.1.7_@codemirror+autocomplete@6.20.3_@codemirror+state@6.7_6b342e94e942eed410acc909cdad6bca/node_modules/@marimo-team/codemirror-mcp/dist/state.js
|
|
5012
|
-
var
|
|
5046
|
+
var Go = St.define(), Q = Tt.define({
|
|
5013
5047
|
create() {
|
|
5014
5048
|
return /* @__PURE__ */ new Map();
|
|
5015
5049
|
},
|
|
5016
5050
|
update(e, t) {
|
|
5017
5051
|
let n = !1, r = e;
|
|
5018
|
-
for (let i of t.effects) if (i.is(
|
|
5052
|
+
for (let i of t.effects) if (i.is(Go)) {
|
|
5019
5053
|
n ||= (r = new Map(e), !0);
|
|
5020
5054
|
for (let [e, t] of i.value) r.set(e, t);
|
|
5021
5055
|
}
|
|
5022
5056
|
return r;
|
|
5023
5057
|
}
|
|
5024
|
-
}),
|
|
5058
|
+
}), Ko = Tt.define({
|
|
5025
5059
|
create() {
|
|
5026
5060
|
return {
|
|
5027
5061
|
onResourceClick: void 0,
|
|
@@ -5033,14 +5067,14 @@ var Bo = St.define(), Q = Tt.define({
|
|
|
5033
5067
|
update(e) {
|
|
5034
5068
|
return e;
|
|
5035
5069
|
}
|
|
5036
|
-
}),
|
|
5070
|
+
}), qo = St.define();
|
|
5037
5071
|
Tt.define({
|
|
5038
5072
|
create() {
|
|
5039
5073
|
return /* @__PURE__ */ new Map();
|
|
5040
5074
|
},
|
|
5041
5075
|
update(e, t) {
|
|
5042
5076
|
let n = !1, r = e;
|
|
5043
|
-
for (let i of t.effects) if (i.is(
|
|
5077
|
+
for (let i of t.effects) if (i.is(qo)) {
|
|
5044
5078
|
n ||= (r = new Map(e), !0);
|
|
5045
5079
|
for (let [e, t] of i.value) r.set(e, t);
|
|
5046
5080
|
}
|
|
@@ -5049,12 +5083,12 @@ Tt.define({
|
|
|
5049
5083
|
});
|
|
5050
5084
|
//#endregion
|
|
5051
5085
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-mcp@0.1.7_@codemirror+autocomplete@6.20.3_@codemirror+state@6.7_6b342e94e942eed410acc909cdad6bca/node_modules/@marimo-team/codemirror-mcp/dist/resources/completion.js
|
|
5052
|
-
var
|
|
5086
|
+
var Jo = (e, t) => async (n) => {
|
|
5053
5087
|
let r = n.matchBefore(/@(\w+)?/);
|
|
5054
5088
|
if (!r || r.from === r.to && !n.explicit) return null;
|
|
5055
5089
|
let i = await e();
|
|
5056
5090
|
if (i.length === 0) return null;
|
|
5057
|
-
let a =
|
|
5091
|
+
let a = Go.of(new Map(i.map((e) => [e.uri, e])));
|
|
5058
5092
|
n.view && n.view.dispatch({ effects: a });
|
|
5059
5093
|
let o = i.map((e) => ({
|
|
5060
5094
|
label: `@${e.name}`,
|
|
@@ -5076,13 +5110,13 @@ var Uo = (e, t) => async (n) => {
|
|
|
5076
5110
|
from: r.from,
|
|
5077
5111
|
options: o
|
|
5078
5112
|
};
|
|
5079
|
-
},
|
|
5113
|
+
}, Yo = /@[\w-]+:\/\/(?!\/)[^\s]+/;
|
|
5080
5114
|
function $(e) {
|
|
5081
|
-
return e.matchAll(new RegExp(
|
|
5115
|
+
return e.matchAll(new RegExp(Yo.source, "g"));
|
|
5082
5116
|
}
|
|
5083
5117
|
//#endregion
|
|
5084
5118
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-mcp@0.1.7_@codemirror+autocomplete@6.20.3_@codemirror+state@6.7_6b342e94e942eed410acc909cdad6bca/node_modules/@marimo-team/codemirror-mcp/dist/resources/decoration.js
|
|
5085
|
-
var
|
|
5119
|
+
var Xo = class extends Ct {
|
|
5086
5120
|
resource;
|
|
5087
5121
|
view;
|
|
5088
5122
|
constructor(e, t) {
|
|
@@ -5094,7 +5128,7 @@ var Go = class extends Ct {
|
|
|
5094
5128
|
toDOM() {
|
|
5095
5129
|
let e = document.createElement("span");
|
|
5096
5130
|
e.className = "cm-resource-widget", e.textContent = `@${this.resource.name}`;
|
|
5097
|
-
let t = this.view.state.field(
|
|
5131
|
+
let t = this.view.state.field(Ko, !1), n = t?.onResourceClick, r = t?.onResourceMouseOver, i = t?.onResourceMouseOut;
|
|
5098
5132
|
return n && (e.style.cursor = "pointer", e.addEventListener("click", (e) => {
|
|
5099
5133
|
e.preventDefault(), e.stopPropagation(), n(this.resource);
|
|
5100
5134
|
})), r && e.addEventListener("mouseover", (e) => {
|
|
@@ -5103,7 +5137,7 @@ var Go = class extends Ct {
|
|
|
5103
5137
|
e.preventDefault(), e.stopPropagation(), i(this.resource);
|
|
5104
5138
|
}), e;
|
|
5105
5139
|
}
|
|
5106
|
-
},
|
|
5140
|
+
}, Zo = class extends Ct {
|
|
5107
5141
|
uri;
|
|
5108
5142
|
view;
|
|
5109
5143
|
constructor(e, t) {
|
|
@@ -5117,29 +5151,29 @@ var Go = class extends Ct {
|
|
|
5117
5151
|
return e.className = "cm-not-found-resource-widget", e.textContent = `@${this.uri.split("://")[1] ?? this.uri}`, e;
|
|
5118
5152
|
}
|
|
5119
5153
|
};
|
|
5120
|
-
function
|
|
5154
|
+
function Qo(e) {
|
|
5121
5155
|
let t = e.state.field(Q), n = [];
|
|
5122
5156
|
for (let { from: r, to: i } of e.visibleRanges) {
|
|
5123
5157
|
let a = e.state.doc.sliceString(r, i);
|
|
5124
5158
|
for (let i of $(a)) {
|
|
5125
5159
|
let a = r + i.index, o = i[0].slice(1), s = t.get(o);
|
|
5126
|
-
s ? n.push(bt.replace({ widget: new
|
|
5160
|
+
s ? n.push(bt.replace({ widget: new Xo(s, e) }).range(a, a + i[0].length)) : n.push(bt.replace({ widget: new Zo(o, e) }).range(a, a + i[0].length));
|
|
5127
5161
|
}
|
|
5128
5162
|
}
|
|
5129
5163
|
return bt.set(n);
|
|
5130
5164
|
}
|
|
5131
|
-
var
|
|
5165
|
+
var $o = Et.fromClass(class {
|
|
5132
5166
|
decorations;
|
|
5133
5167
|
constructor(e) {
|
|
5134
|
-
this.decorations =
|
|
5168
|
+
this.decorations = Qo(e);
|
|
5135
5169
|
}
|
|
5136
5170
|
update(e) {
|
|
5137
|
-
(e.docChanged || e.viewportChanged || e.transactions.some((e) => e.effects.some((e) => e.is(
|
|
5171
|
+
(e.docChanged || e.viewportChanged || e.transactions.some((e) => e.effects.some((e) => e.is(Go)))) && (this.decorations = Qo(e.view));
|
|
5138
5172
|
}
|
|
5139
5173
|
}, { decorations: (e) => e.decorations });
|
|
5140
5174
|
//#endregion
|
|
5141
5175
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-mcp@0.1.7_@codemirror+autocomplete@6.20.3_@codemirror+state@6.7_6b342e94e942eed410acc909cdad6bca/node_modules/@marimo-team/codemirror-mcp/dist/resources/hover.js
|
|
5142
|
-
function
|
|
5176
|
+
function es(e) {
|
|
5143
5177
|
let t = document.createElement("div");
|
|
5144
5178
|
t.className = "cm-tooltip-cursor";
|
|
5145
5179
|
let n = document.createElement("div");
|
|
@@ -5153,7 +5187,7 @@ function Yo(e) {
|
|
|
5153
5187
|
}
|
|
5154
5188
|
return { dom: t };
|
|
5155
5189
|
}
|
|
5156
|
-
function
|
|
5190
|
+
function ts(e, t, n, r = 0) {
|
|
5157
5191
|
for (let i of $(e)) {
|
|
5158
5192
|
let e = r + i.index, a = e + i[0].length;
|
|
5159
5193
|
if (t >= e && t <= a) {
|
|
@@ -5167,22 +5201,22 @@ function Xo(e, t, n, r = 0) {
|
|
|
5167
5201
|
}
|
|
5168
5202
|
return null;
|
|
5169
5203
|
}
|
|
5170
|
-
function
|
|
5204
|
+
function ns(e) {
|
|
5171
5205
|
return kt((t, n) => {
|
|
5172
|
-
let { from: r, text: i } = t.state.doc.lineAt(n), a =
|
|
5206
|
+
let { from: r, text: i } = t.state.doc.lineAt(n), a = ts(i, n, t.state.field(Q), r);
|
|
5173
5207
|
return a ? {
|
|
5174
5208
|
pos: a.start,
|
|
5175
5209
|
end: a.end,
|
|
5176
5210
|
above: !0,
|
|
5177
5211
|
create() {
|
|
5178
|
-
return (e.createTooltip ??
|
|
5212
|
+
return (e.createTooltip ?? es)(a.resource);
|
|
5179
5213
|
}
|
|
5180
5214
|
} : null;
|
|
5181
5215
|
});
|
|
5182
5216
|
}
|
|
5183
5217
|
//#endregion
|
|
5184
5218
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-mcp@0.1.7_@codemirror+autocomplete@6.20.3_@codemirror+state@6.7_6b342e94e942eed410acc909cdad6bca/node_modules/@marimo-team/codemirror-mcp/dist/resources/input-filter.js
|
|
5185
|
-
function
|
|
5219
|
+
function rs(e, t) {
|
|
5186
5220
|
let n = e.field(Q), r = e.doc, i = r.lineAt(t), a = r.sliceString(i.from, i.to), o = Array.from($(a));
|
|
5187
5221
|
if (o.length === 0) return null;
|
|
5188
5222
|
for (let e of o) {
|
|
@@ -5195,7 +5229,7 @@ function Qo(e, t) {
|
|
|
5195
5229
|
}
|
|
5196
5230
|
return null;
|
|
5197
5231
|
}
|
|
5198
|
-
function
|
|
5232
|
+
function is(e, t) {
|
|
5199
5233
|
let n = e.field(Q), r = e.doc, i = r.lineAt(t).to, a = r.sliceString(t, i), o = Array.from($(a));
|
|
5200
5234
|
if (o.length === 0) return null;
|
|
5201
5235
|
let s = o[0];
|
|
@@ -5207,7 +5241,7 @@ function $o(e, t) {
|
|
|
5207
5241
|
uri: u
|
|
5208
5242
|
} : null;
|
|
5209
5243
|
}
|
|
5210
|
-
function
|
|
5244
|
+
function as(e, t) {
|
|
5211
5245
|
let n = e.field(Q), r = e.doc, i = r.lineAt(t), a = r.sliceString(i.from, i.to), o = Array.from($(a));
|
|
5212
5246
|
for (let e of o) {
|
|
5213
5247
|
let r = i.from + e.index, a = r + e[0].length, o = e[0].slice(1);
|
|
@@ -5219,7 +5253,7 @@ function es(e, t) {
|
|
|
5219
5253
|
}
|
|
5220
5254
|
return null;
|
|
5221
5255
|
}
|
|
5222
|
-
function
|
|
5256
|
+
function os(e, t) {
|
|
5223
5257
|
let n = e.field(Q), r = e.doc, i = r.lineAt(t), a = r.sliceString(i.from, t), o = Array.from($(a)), s = null;
|
|
5224
5258
|
for (let e of o) {
|
|
5225
5259
|
let r = i.from + e.index, a = r + e[0].length, o = e[0].slice(1);
|
|
@@ -5227,7 +5261,7 @@ function ts(e, t) {
|
|
|
5227
5261
|
}
|
|
5228
5262
|
return s;
|
|
5229
5263
|
}
|
|
5230
|
-
function
|
|
5264
|
+
function ss(e, t) {
|
|
5231
5265
|
let n = e.field(Q), r = e.doc, i = r.lineAt(t), a = r.sliceString(i.from, i.to), o = Array.from($(a));
|
|
5232
5266
|
for (let e of o) {
|
|
5233
5267
|
let r = i.from + e.index, a = r + e[0].length, o = e[0].slice(1);
|
|
@@ -5238,7 +5272,7 @@ function ns(e, t) {
|
|
|
5238
5272
|
}
|
|
5239
5273
|
return null;
|
|
5240
5274
|
}
|
|
5241
|
-
var
|
|
5275
|
+
var cs = Dt.transactionFilter.of((e) => {
|
|
5242
5276
|
let t = e.annotation(yt.userEvent);
|
|
5243
5277
|
if (!t) return e;
|
|
5244
5278
|
let n = e.startState.selection.main;
|
|
@@ -5287,7 +5321,7 @@ var rs = Dt.transactionFilter.of((e) => {
|
|
|
5287
5321
|
}
|
|
5288
5322
|
if (t === "delete.backward" || t === "delete.forward") {
|
|
5289
5323
|
let r = null;
|
|
5290
|
-
return t === "delete.backward" ? r =
|
|
5324
|
+
return t === "delete.backward" ? r = rs(e.startState, n.head) : t === "delete.forward" && (r = is(e.startState, n.head)), r ? [{
|
|
5291
5325
|
changes: {
|
|
5292
5326
|
from: r.from,
|
|
5293
5327
|
to: r.to,
|
|
@@ -5300,11 +5334,11 @@ var rs = Dt.transactionFilter.of((e) => {
|
|
|
5300
5334
|
if (e.selection?.main.empty && n.empty && !t.startsWith("input") && t !== "input.type") {
|
|
5301
5335
|
let t = n.head, r = e.selection.main.head, i = null;
|
|
5302
5336
|
if (r < t) {
|
|
5303
|
-
let n =
|
|
5304
|
-
i = n && t > n.from ? n.from :
|
|
5337
|
+
let n = as(e.startState, t);
|
|
5338
|
+
i = n && t > n.from ? n.from : os(e.startState, t);
|
|
5305
5339
|
} else if (r > t) {
|
|
5306
|
-
let n =
|
|
5307
|
-
i = n && t < n.to ? n.to :
|
|
5340
|
+
let n = as(e.startState, t);
|
|
5341
|
+
i = n && t < n.to ? n.to : ss(e.startState, t);
|
|
5308
5342
|
}
|
|
5309
5343
|
if (i !== null && i !== r) return [{
|
|
5310
5344
|
selection: { anchor: i },
|
|
@@ -5312,8 +5346,8 @@ var rs = Dt.transactionFilter.of((e) => {
|
|
|
5312
5346
|
}];
|
|
5313
5347
|
}
|
|
5314
5348
|
return e;
|
|
5315
|
-
}),
|
|
5316
|
-
function
|
|
5349
|
+
}), ls = 150;
|
|
5350
|
+
function us(e, t) {
|
|
5317
5351
|
let n = /* @__PURE__ */ new Set();
|
|
5318
5352
|
for (let r of $(e)) {
|
|
5319
5353
|
let e = r[0].slice(1);
|
|
@@ -5321,13 +5355,13 @@ function as(e, t) {
|
|
|
5321
5355
|
}
|
|
5322
5356
|
return [...n];
|
|
5323
5357
|
}
|
|
5324
|
-
function
|
|
5358
|
+
function ds(e) {
|
|
5325
5359
|
return [...e].sort().join("\n");
|
|
5326
5360
|
}
|
|
5327
|
-
function
|
|
5361
|
+
function fs(e) {
|
|
5328
5362
|
return !$(e).next().done;
|
|
5329
5363
|
}
|
|
5330
|
-
function
|
|
5364
|
+
function ps(e) {
|
|
5331
5365
|
let t = [], n = [];
|
|
5332
5366
|
return e.changes.iterChanges((r, i, a, o) => {
|
|
5333
5367
|
let s = e.startState.doc.lineAt(r), c = e.startState.doc.lineAt(i === r ? r : i - 1);
|
|
@@ -5339,8 +5373,8 @@ function cs(e) {
|
|
|
5339
5373
|
after: n.join("\n")
|
|
5340
5374
|
};
|
|
5341
5375
|
}
|
|
5342
|
-
function
|
|
5343
|
-
let n = t.debounceMs ??
|
|
5376
|
+
function ms(e, t) {
|
|
5377
|
+
let n = t.debounceMs ?? ls, { logger: r, resolve: i } = t;
|
|
5344
5378
|
return class {
|
|
5345
5379
|
view;
|
|
5346
5380
|
timer;
|
|
@@ -5353,8 +5387,8 @@ function ls(e, t) {
|
|
|
5353
5387
|
}
|
|
5354
5388
|
update(e) {
|
|
5355
5389
|
if (e.docChanged) {
|
|
5356
|
-
let t =
|
|
5357
|
-
if (
|
|
5390
|
+
let t = ps(e);
|
|
5391
|
+
if (fs(t.before)) {
|
|
5358
5392
|
this.maybeSchedule(e.view);
|
|
5359
5393
|
return;
|
|
5360
5394
|
}
|
|
@@ -5366,11 +5400,11 @@ function ls(e, t) {
|
|
|
5366
5400
|
}
|
|
5367
5401
|
maybeSchedule(e, t) {
|
|
5368
5402
|
let r = t ?? e.state.doc.toString();
|
|
5369
|
-
if (!
|
|
5403
|
+
if (!fs(r)) {
|
|
5370
5404
|
t === void 0 && (this.lastKey = "", this.clearTimer());
|
|
5371
5405
|
return;
|
|
5372
5406
|
}
|
|
5373
|
-
let i =
|
|
5407
|
+
let i = ds(us(r, e.state.field(Q)));
|
|
5374
5408
|
i === "" ? t === void 0 && (this.lastKey = "", this.clearTimer()) : i === this.lastKey ? this.clearTimer() : (this.clearTimer(), this.timer = setTimeout(() => {
|
|
5375
5409
|
this.timer = void 0, this.run(e);
|
|
5376
5410
|
}, n));
|
|
@@ -5386,12 +5420,12 @@ function ls(e, t) {
|
|
|
5386
5420
|
try {
|
|
5387
5421
|
do {
|
|
5388
5422
|
this.rerun = !1;
|
|
5389
|
-
let n =
|
|
5423
|
+
let n = us(t.state.doc.toString(), t.state.field(Q));
|
|
5390
5424
|
if (n.length === 0) {
|
|
5391
5425
|
this.lastKey = "";
|
|
5392
5426
|
break;
|
|
5393
5427
|
}
|
|
5394
|
-
this.lastKey =
|
|
5428
|
+
this.lastKey = ds(n);
|
|
5395
5429
|
let r = i ? await i(n) : await e();
|
|
5396
5430
|
if (this.destroyed) return;
|
|
5397
5431
|
let a = new Set(n), o = r.filter((e) => a.has(e.uri));
|
|
@@ -5399,7 +5433,7 @@ function ls(e, t) {
|
|
|
5399
5433
|
if (this.rerun) continue;
|
|
5400
5434
|
break;
|
|
5401
5435
|
}
|
|
5402
|
-
t.dispatch({ effects:
|
|
5436
|
+
t.dispatch({ effects: Go.of(new Map(o.map((e) => [e.uri, e]))) }), this.rerun = !0;
|
|
5403
5437
|
} while (this.rerun);
|
|
5404
5438
|
} catch (e) {
|
|
5405
5439
|
this.lastKey = "", r?.error("Failed to sync resources:", e);
|
|
@@ -5411,12 +5445,12 @@ function ls(e, t) {
|
|
|
5411
5445
|
}
|
|
5412
5446
|
};
|
|
5413
5447
|
}
|
|
5414
|
-
function
|
|
5415
|
-
return Et.fromClass(
|
|
5448
|
+
function hs(e, t = {}) {
|
|
5449
|
+
return Et.fromClass(ms(e, t));
|
|
5416
5450
|
}
|
|
5417
5451
|
//#endregion
|
|
5418
5452
|
//#region ../node_modules/.pnpm/@marimo-team+codemirror-mcp@0.1.7_@codemirror+autocomplete@6.20.3_@codemirror+state@6.7_6b342e94e942eed410acc909cdad6bca/node_modules/@marimo-team/codemirror-mcp/dist/theme.js
|
|
5419
|
-
var
|
|
5453
|
+
var gs = wt.baseTheme({
|
|
5420
5454
|
".cm-resource-widget": {
|
|
5421
5455
|
background: "light-dark(rgba(86,156,214,0.08),rgba(86,156,214,0.18))",
|
|
5422
5456
|
borderRadius: "4px",
|
|
@@ -5432,71 +5466,71 @@ var ds = wt.baseTheme({
|
|
|
5432
5466
|
color: "light-dark(#b00020,#ff8080)",
|
|
5433
5467
|
fontWeight: "500"
|
|
5434
5468
|
}
|
|
5435
|
-
}),
|
|
5469
|
+
}), _s = "_none_", vs = [{
|
|
5436
5470
|
uri: "",
|
|
5437
5471
|
name: "No resources",
|
|
5438
|
-
type:
|
|
5472
|
+
type: _s,
|
|
5439
5473
|
data: {}
|
|
5440
|
-
}],
|
|
5474
|
+
}], ys = {
|
|
5441
5475
|
info: "Variables, dataframes, and tables will appear here.",
|
|
5442
5476
|
apply: () => {}
|
|
5443
5477
|
};
|
|
5444
|
-
function
|
|
5445
|
-
let t =
|
|
5446
|
-
return t.length === 0 ?
|
|
5478
|
+
function bs(e) {
|
|
5479
|
+
let t = jo(e).getAllItems();
|
|
5480
|
+
return t.length === 0 ? vs : t;
|
|
5447
5481
|
}
|
|
5448
|
-
function
|
|
5449
|
-
let { language: t, store: r, onAddFiles: i } = e, a = () =>
|
|
5482
|
+
function xs(e) {
|
|
5483
|
+
let { language: t, store: r, onAddFiles: i } = e, a = () => bs(r);
|
|
5450
5484
|
return [
|
|
5451
|
-
t.data.of({ autocomplete:
|
|
5485
|
+
t.data.of({ autocomplete: Jo(async () => a(), (e) => e.type === _s ? ys : jo(r).getProvider(e.type)?.formatCompletion(e) || {}) }),
|
|
5452
5486
|
xt.high(Ot.of([{
|
|
5453
5487
|
key: "Tab",
|
|
5454
5488
|
preventDefault: !0,
|
|
5455
5489
|
run: (e) => jt(e)
|
|
5456
5490
|
}])),
|
|
5457
|
-
|
|
5458
|
-
...i ? [t.data.of({ autocomplete:
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5491
|
+
Eo.of({ addAttachment: (e) => i?.([e]) }),
|
|
5492
|
+
...i ? [t.data.of({ autocomplete: Mo().createCompletionSource() })] : [],
|
|
5493
|
+
$o,
|
|
5494
|
+
cs,
|
|
5495
|
+
hs(a, { logger: n }),
|
|
5462
5496
|
Q.init(() => {
|
|
5463
|
-
let e =
|
|
5497
|
+
let e = bs(r);
|
|
5464
5498
|
return new Map(e.map((e) => [e.uri, e]));
|
|
5465
5499
|
}),
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
let t =
|
|
5469
|
-
if (!t) return n.warn("No provider found for resource", e),
|
|
5500
|
+
gs,
|
|
5501
|
+
ns({ createTooltip: (e) => {
|
|
5502
|
+
let t = jo(r).getProvider(e.type);
|
|
5503
|
+
if (!t) return n.warn("No provider found for resource", e), Ss(e.description || e.name);
|
|
5470
5504
|
let i = t.formatCompletion(e), a = e.description || e.name;
|
|
5471
|
-
if (!i?.info) return
|
|
5472
|
-
if (typeof i.info == "string") return
|
|
5505
|
+
if (!i?.info) return Ss(a);
|
|
5506
|
+
if (typeof i.info == "string") return Ss(i.info);
|
|
5473
5507
|
let o = i.info(i);
|
|
5474
|
-
return o ? "dom" in o ? { dom: o.dom } : "then" in o ? (n.warn("info is a promise. This is not supported", o),
|
|
5508
|
+
return o ? "dom" in o ? { dom: o.dom } : "then" in o ? (n.warn("info is a promise. This is not supported", o), Ss(a)) : { dom: o } : Ss(a);
|
|
5475
5509
|
} })
|
|
5476
5510
|
];
|
|
5477
5511
|
}
|
|
5478
|
-
function
|
|
5512
|
+
function Ss(e) {
|
|
5479
5513
|
let t = document.createElement("div");
|
|
5480
5514
|
return t.textContent = e, { dom: t };
|
|
5481
5515
|
}
|
|
5482
5516
|
//#endregion
|
|
5483
5517
|
//#region src/components/editor/ai/prompt-input.tsx
|
|
5484
|
-
var
|
|
5518
|
+
var Cs = "marimo:ai-prompt-history", ws = new we(et(it()), () => []), Ts = (e) => {
|
|
5485
5519
|
let t = (0, I.c)(35), { value: n, placeholder: i, inputRef: a, className: o, onChange: s, onSubmit: c, onKeyDown: l, onClose: u, onAddFiles: d, additionalCompletions: f, maxHeight: p } = e, m = vt(c), h = vt(u), g = Ye(), { theme: _ } = ot(), v;
|
|
5486
|
-
t[0] === f ? v = t[1] : (v = (e) => f ?
|
|
5520
|
+
t[0] === f ? v = t[1] : (v = (e) => f ? No([f.triggerCompletionRegex], f.completions)(e) : null, t[0] = f, t[1] = v);
|
|
5487
5521
|
let y = vt(v), b, x, S, C;
|
|
5488
5522
|
if (t[2] !== y || t[3] !== d || t[4] !== g) {
|
|
5489
5523
|
let e = Pt();
|
|
5490
|
-
t[9] === Symbol.for("react.memo_cache_sentinel") ? (b = Nt({}), t[9] = b) : b = t[9], x = e, S =
|
|
5524
|
+
t[9] === Symbol.for("react.memo_cache_sentinel") ? (b = Nt({}), t[9] = b) : b = t[9], x = e, S = xs({
|
|
5491
5525
|
language: e.language,
|
|
5492
5526
|
store: g,
|
|
5493
5527
|
onAddFiles: d
|
|
5494
5528
|
}), C = e.language.data.of({ autocomplete: y }), t[2] = y, t[3] = d, t[4] = g, t[5] = b, t[6] = x, t[7] = S, t[8] = C;
|
|
5495
5529
|
} else b = t[5], x = t[6], S = t[7], C = t[8];
|
|
5496
5530
|
let w;
|
|
5497
|
-
t[10] === Symbol.for("react.memo_cache_sentinel") ? (w =
|
|
5498
|
-
load:
|
|
5499
|
-
save:
|
|
5531
|
+
t[10] === Symbol.for("react.memo_cache_sentinel") ? (w = Wo({ storage: {
|
|
5532
|
+
load: Es,
|
|
5533
|
+
save: Ds
|
|
5500
5534
|
} }), t[10] = w) : w = t[10];
|
|
5501
5535
|
let T;
|
|
5502
5536
|
t[11] === Symbol.for("react.memo_cache_sentinel") ? (T = Ft(), t[11] = T) : T = t[11];
|
|
@@ -5545,21 +5579,21 @@ var vs = "marimo:ai-prompt-history", ys = new we(et(it()), () => []), bs = (e) =
|
|
|
5545
5579
|
placeholder: M
|
|
5546
5580
|
}), t[25] = k, t[26] = a, t[27] = p, t[28] = s, t[29] = l, t[30] = A, t[31] = j, t[32] = M, t[33] = n, t[34] = N) : N = t[34], N;
|
|
5547
5581
|
};
|
|
5548
|
-
function
|
|
5549
|
-
return
|
|
5582
|
+
function Es() {
|
|
5583
|
+
return ws.get(Cs);
|
|
5550
5584
|
}
|
|
5551
|
-
function
|
|
5552
|
-
return
|
|
5585
|
+
function Ds(e) {
|
|
5586
|
+
return ws.set(Cs, e);
|
|
5553
5587
|
}
|
|
5554
5588
|
//#endregion
|
|
5555
5589
|
//#region src/plugins/impl/chat/chat-ui.tsx
|
|
5556
|
-
var
|
|
5590
|
+
var Os = d, ks = mt({
|
|
5557
5591
|
type: tt("stream_chunk"),
|
|
5558
5592
|
message_id: it(),
|
|
5559
5593
|
content: Qe().nullable().transform((e) => e),
|
|
5560
5594
|
is_final: qe().optional()
|
|
5561
5595
|
});
|
|
5562
|
-
function
|
|
5596
|
+
function As(e, t) {
|
|
5563
5597
|
let { controllerRef: r, activeRequestIdRef: i } = t, a = r.current;
|
|
5564
5598
|
if (a === null) return "dropped-no-controller";
|
|
5565
5599
|
let o = i.current;
|
|
@@ -5568,7 +5602,7 @@ function Ts(e, t) {
|
|
|
5568
5602
|
activeRequestId: o
|
|
5569
5603
|
}), "dropped-stale") : (e.content && a.enqueue(e.content), e.is_final ? (a.close(), r.current = null, i.current = null, "closed") : "enqueued");
|
|
5570
5604
|
}
|
|
5571
|
-
var
|
|
5605
|
+
var js = (e) => {
|
|
5572
5606
|
let [t, o] = (0, X.useState)(""), [s, c] = (0, X.useState)(e.config), [u, d] = (0, X.useState)(e.config), [p, m] = (0, X.useState)(void 0), h = (0, X.useRef)(null), g = (0, X.useRef)(null), _ = (0, X.useRef)(null), v = (0, X.useRef)(null);
|
|
5573
5607
|
Object.keys(e.config).some((t) => e.config[t] !== u[t]) && (c(e.config), d(e.config));
|
|
5574
5608
|
let y = (0, X.useRef)(s);
|
|
@@ -5578,7 +5612,7 @@ var Es = (e) => {
|
|
|
5578
5612
|
let b = (0, X.useRef)(null), x = (0, X.useRef)(null), S = (0, X.useRef)(null), [C, w] = (0, X.useState)(null), T = () => {
|
|
5579
5613
|
S.current = null, w(null);
|
|
5580
5614
|
}, { data: E } = Lt(async () => (await e.get_chat_history({})).messages, []), D = e.value.length > 0 ? e.value : E, { messages: O, sendMessage: k, setMessages: A, status: j, stop: M, error: N, regenerate: ee, clearError: ne, addToolApprovalResponse: P } = ya({
|
|
5581
|
-
sendAutomaticallyWhen: ({ messages: e }) =>
|
|
5615
|
+
sendAutomaticallyWhen: ({ messages: e }) => Fo(e),
|
|
5582
5616
|
transport: new ia({ fetch: async (t, r) => {
|
|
5583
5617
|
if (r === void 0) return fetch(t);
|
|
5584
5618
|
let i = JSON.parse(r.body), a = r.signal, o = {
|
|
@@ -5653,14 +5687,14 @@ var Es = (e) => {
|
|
|
5653
5687
|
n.error("An error occurred:", e);
|
|
5654
5688
|
}
|
|
5655
5689
|
});
|
|
5656
|
-
i(e.host,
|
|
5657
|
-
let t =
|
|
5690
|
+
i(e.host, Le.TYPE, (e) => {
|
|
5691
|
+
let t = ks.safeParse(e.detail.message);
|
|
5658
5692
|
if (t.success) {
|
|
5659
5693
|
if (t.data.content && t.data.message_id === x.current) {
|
|
5660
5694
|
let e = xa(t.data.content);
|
|
5661
5695
|
e !== void 0 && (S.current = e);
|
|
5662
5696
|
}
|
|
5663
|
-
|
|
5697
|
+
As(t.data, {
|
|
5664
5698
|
controllerRef: b,
|
|
5665
5699
|
activeRequestIdRef: x
|
|
5666
5700
|
});
|
|
@@ -5739,7 +5773,7 @@ var Es = (e) => {
|
|
|
5739
5773
|
className: r("flex flex-col group gap-2", e.role === "user" ? "items-end" : "items-start"),
|
|
5740
5774
|
children: [/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
5741
5775
|
className: `max-w-[80%] p-3 rounded-lg ${e.role === "user" ? "bg-(--sky-11) text-(--slate-1) whitespace-pre-wrap" : "bg-(--slate-4) text-(--slate-12) [--muted-foreground:var(--slate-11)]"}`,
|
|
5742
|
-
children:
|
|
5776
|
+
children: to({
|
|
5743
5777
|
message: e,
|
|
5744
5778
|
isLast: i,
|
|
5745
5779
|
isActive: re,
|
|
@@ -5786,7 +5820,7 @@ var Es = (e) => {
|
|
|
5786
5820
|
/* @__PURE__ */ (0, Z.jsxs)("form", {
|
|
5787
5821
|
onSubmit: async (n) => {
|
|
5788
5822
|
if (n.preventDefault(), e.disabled) return;
|
|
5789
|
-
let r = p ? await
|
|
5823
|
+
let r = p ? await Po(p) : void 0;
|
|
5790
5824
|
k({
|
|
5791
5825
|
role: "user",
|
|
5792
5826
|
parts: [{
|
|
@@ -5799,11 +5833,11 @@ var Es = (e) => {
|
|
|
5799
5833
|
inert: e.disabled || void 0,
|
|
5800
5834
|
className: r("flex w-full border-t border-(--slate-6) px-2 py-1 items-center", e.disabled && "opacity-50 cursor-not-allowed"),
|
|
5801
5835
|
children: [
|
|
5802
|
-
e.showConfigurationControls && /* @__PURE__ */ (0, Z.jsx)(
|
|
5836
|
+
e.showConfigurationControls && /* @__PURE__ */ (0, Z.jsx)(Ns, {
|
|
5803
5837
|
config: s,
|
|
5804
5838
|
onChange: c
|
|
5805
5839
|
}),
|
|
5806
|
-
e.prompts.length > 0 && /* @__PURE__ */ (0, Z.jsx)(
|
|
5840
|
+
e.prompts.length > 0 && /* @__PURE__ */ (0, Z.jsx)(Ps, {
|
|
5807
5841
|
prompts: e.prompts,
|
|
5808
5842
|
onSelect: (e) => {
|
|
5809
5843
|
o(e), requestAnimationFrame(() => {
|
|
@@ -5812,7 +5846,7 @@ var Es = (e) => {
|
|
|
5812
5846
|
});
|
|
5813
5847
|
}
|
|
5814
5848
|
}),
|
|
5815
|
-
/* @__PURE__ */ (0, Z.jsx)(
|
|
5849
|
+
/* @__PURE__ */ (0, Z.jsx)(Ts, {
|
|
5816
5850
|
className: "rounded-sm mr-2",
|
|
5817
5851
|
placeholder: ce,
|
|
5818
5852
|
value: t,
|
|
@@ -5868,7 +5902,7 @@ var Es = (e) => {
|
|
|
5868
5902
|
size: "xs",
|
|
5869
5903
|
onClick: () => M(),
|
|
5870
5904
|
className: "text-(--red-9) hover:text-(--red-11)",
|
|
5871
|
-
children: /* @__PURE__ */ (0, Z.jsx)(
|
|
5905
|
+
children: /* @__PURE__ */ (0, Z.jsx)(ze, { className: "h-4 w-4 fill-current" })
|
|
5872
5906
|
})
|
|
5873
5907
|
}) : /* @__PURE__ */ (0, Z.jsx)(a, {
|
|
5874
5908
|
type: "submit",
|
|
@@ -5883,7 +5917,7 @@ var Es = (e) => {
|
|
|
5883
5917
|
})
|
|
5884
5918
|
]
|
|
5885
5919
|
});
|
|
5886
|
-
},
|
|
5920
|
+
}, Ms = {
|
|
5887
5921
|
max_tokens: {
|
|
5888
5922
|
min: 1,
|
|
5889
5923
|
max: 4096,
|
|
@@ -5916,12 +5950,12 @@ var Es = (e) => {
|
|
|
5916
5950
|
max: 2,
|
|
5917
5951
|
description: "Penalizes new tokens (-2: favor, 2: avoid)"
|
|
5918
5952
|
}
|
|
5919
|
-
},
|
|
5953
|
+
}, Ns = (e) => {
|
|
5920
5954
|
let t = (0, I.c)(16), { config: n, onChange: r } = e, [i, o] = (0, X.useState)(!1), s;
|
|
5921
5955
|
t[0] !== n || t[1] !== r ? (s = (e, t) => {
|
|
5922
5956
|
let i = t === null || Number.isNaN(t) ? null : t;
|
|
5923
5957
|
if (i !== null) {
|
|
5924
|
-
let { min: t, max: n } =
|
|
5958
|
+
let { min: t, max: n } = Ms[e];
|
|
5925
5959
|
i = Math.max(t, Math.min(n, i));
|
|
5926
5960
|
}
|
|
5927
5961
|
let a = {
|
|
@@ -5967,7 +6001,7 @@ var Es = (e) => {
|
|
|
5967
6001
|
side: "top",
|
|
5968
6002
|
content: /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
5969
6003
|
className: "text-xs flex flex-col",
|
|
5970
|
-
children:
|
|
6004
|
+
children: Ms[t].description
|
|
5971
6005
|
}),
|
|
5972
6006
|
children: /* @__PURE__ */ (0, Z.jsx)(xe, { className: "h-3 w-3 cursor-help text-muted-foreground hover:text-foreground" })
|
|
5973
6007
|
})]
|
|
@@ -5976,9 +6010,9 @@ var Es = (e) => {
|
|
|
5976
6010
|
"aria-label": t,
|
|
5977
6011
|
value: n ?? NaN,
|
|
5978
6012
|
placeholder: "null",
|
|
5979
|
-
minValue:
|
|
5980
|
-
maxValue:
|
|
5981
|
-
step:
|
|
6013
|
+
minValue: Ms[t].min,
|
|
6014
|
+
maxValue: Ms[t].max,
|
|
6015
|
+
step: Ms[t].step ?? 1,
|
|
5982
6016
|
onChange: (e) => c(t, e),
|
|
5983
6017
|
onKeyDown: u,
|
|
5984
6018
|
className: "col-span-3"
|
|
@@ -6000,7 +6034,7 @@ var Es = (e) => {
|
|
|
6000
6034
|
onOpenChange: o,
|
|
6001
6035
|
children: [d, m]
|
|
6002
6036
|
}), t[13] = i, t[14] = m, t[15] = h) : h = t[15], h;
|
|
6003
|
-
},
|
|
6037
|
+
}, Ps = (e) => {
|
|
6004
6038
|
let t = (0, I.c)(18), { prompts: n, onSelect: r } = e, [i, o] = (0, X.useState)(!1), [s, c] = (0, X.useState)(""), l;
|
|
6005
6039
|
t[0] === r ? l = t[1] : (l = (e) => {
|
|
6006
6040
|
[...e.matchAll(/{{(\w+)}}/g)].length > 0 ? (c(e), o(!0)) : r(e);
|
|
@@ -6028,10 +6062,10 @@ var Es = (e) => {
|
|
|
6028
6062
|
}, t), t[6] = u, t[7] = e), f = n.map(e), t[3] = u, t[4] = n, t[5] = f;
|
|
6029
6063
|
} else f = t[5];
|
|
6030
6064
|
let p;
|
|
6031
|
-
t[8] === f ? p = t[9] : (p = /* @__PURE__ */ (0, Z.jsx)(
|
|
6065
|
+
t[8] === f ? p = t[9] : (p = /* @__PURE__ */ (0, Z.jsx)(Os, { children: /* @__PURE__ */ (0, Z.jsxs)(ve, { children: [d, /* @__PURE__ */ (0, Z.jsx)(_e, {
|
|
6032
6066
|
side: "right",
|
|
6033
6067
|
align: "end",
|
|
6034
|
-
onCloseAutoFocus:
|
|
6068
|
+
onCloseAutoFocus: Is,
|
|
6035
6069
|
className: "w-64 max-h-96 overflow-y-auto",
|
|
6036
6070
|
children: f
|
|
6037
6071
|
})] }) }), t[8] = f, t[9] = p);
|
|
@@ -6042,7 +6076,7 @@ var Es = (e) => {
|
|
|
6042
6076
|
side: "right",
|
|
6043
6077
|
align: "end",
|
|
6044
6078
|
className: "min-w-80 px-2",
|
|
6045
|
-
children: /* @__PURE__ */ (0, Z.jsx)(
|
|
6079
|
+
children: /* @__PURE__ */ (0, Z.jsx)(Fs, {
|
|
6046
6080
|
prompt: s,
|
|
6047
6081
|
onClose: m,
|
|
6048
6082
|
onSelect: r
|
|
@@ -6054,9 +6088,9 @@ var Es = (e) => {
|
|
|
6054
6088
|
onOpenChange: o,
|
|
6055
6089
|
children: [p, h]
|
|
6056
6090
|
}), t[14] = i, t[15] = p, t[16] = h, t[17] = g) : g = t[17], g;
|
|
6057
|
-
},
|
|
6091
|
+
}, Fs = (e) => {
|
|
6058
6092
|
let t = (0, I.c)(30), { prompt: n, onClose: r, onSelect: i } = e, o;
|
|
6059
|
-
t[0] === n ? o = t[1] : (o = () => [...n.matchAll(/{{(\w+)}}/g)].reduce(
|
|
6093
|
+
t[0] === n ? o = t[1] : (o = () => [...n.matchAll(/{{(\w+)}}/g)].reduce(Ls, {}), t[0] = n, t[1] = o);
|
|
6060
6094
|
let [s, c] = (0, X.useState)(o), l;
|
|
6061
6095
|
t[2] === Symbol.for("react.memo_cache_sentinel") ? (l = (e, t) => {
|
|
6062
6096
|
c((n) => ({
|
|
@@ -6072,7 +6106,7 @@ var Es = (e) => {
|
|
|
6072
6106
|
t[7] === s ? r = t[8] : (r = (e, t) => s[t] || `{{${t}}}`, t[7] = s, t[8] = r), d = n.replaceAll(e, r), t[3] = n, t[4] = s, t[5] = d;
|
|
6073
6107
|
} else d = t[5];
|
|
6074
6108
|
let f = d, p;
|
|
6075
|
-
t[9] === s ? p = t[10] : (p = Object.values(s).some(
|
|
6109
|
+
t[9] === s ? p = t[10] : (p = Object.values(s).some(Rs), t[9] = s, t[10] = p);
|
|
6076
6110
|
let m = p, h;
|
|
6077
6111
|
t[11] !== r || t[12] !== i || t[13] !== f ? (h = () => {
|
|
6078
6112
|
i(f), r();
|
|
@@ -6127,14 +6161,14 @@ var Es = (e) => {
|
|
|
6127
6161
|
]
|
|
6128
6162
|
}), t[26] = v, t[27] = y, t[28] = b, t[29] = x) : x = t[29], x;
|
|
6129
6163
|
};
|
|
6130
|
-
function
|
|
6164
|
+
function Is(e) {
|
|
6131
6165
|
return e.preventDefault();
|
|
6132
6166
|
}
|
|
6133
|
-
function
|
|
6167
|
+
function Ls(e, t) {
|
|
6134
6168
|
return e[t[1]] = "", e;
|
|
6135
6169
|
}
|
|
6136
|
-
function
|
|
6170
|
+
function Rs(e) {
|
|
6137
6171
|
return e == null || e.trim() === "";
|
|
6138
6172
|
}
|
|
6139
6173
|
//#endregion
|
|
6140
|
-
export {
|
|
6174
|
+
export { js as Chatbot };
|