@marimo-team/islands 0.25.3-dev189 → 0.25.3-dev191

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.
Files changed (77) hide show
  1. package/dist/{ConnectedDataExplorerComponent-Le_OBfmt.js → ConnectedDataExplorerComponent-BBbOElk3.js} +4 -4
  2. package/dist/{ErrorBoundary-CWtCjh3m.js → ErrorBoundary--X0z83Yx.js} +2 -2
  3. package/dist/{abnfDiagram-VCTEODGH-Tf1ghyQQ.js → abnfDiagram-VCTEODGH-DhMT6Uhd.js} +2 -2
  4. package/dist/{architectureDiagram-5GKGNRK7-xlnbTG0T.js → architectureDiagram-5GKGNRK7-BVbEiJLq.js} +1 -1
  5. package/dist/assets/__vite-browser-external-C8gQho07.js +1 -0
  6. package/dist/assets/{worker-C1pfNBsx.js → worker-C6e9ERyd.js} +2 -2
  7. package/dist/{chat-ui-X-cWrL9u.js → chat-ui-BguxTQEL.js} +7 -7
  8. package/dist/{chunk-IMKFNOWR-Cmd4a5jy.js → chunk-IMKFNOWR-By5hSbJJ.js} +1 -1
  9. package/dist/{chunk-SHT3W25Y-mSNp-WpO.js → chunk-SHT3W25Y-DFrEYG54.js} +1 -1
  10. package/dist/{chunk-SVP7TREG-CWC49D8X.js → chunk-SVP7TREG-DFXGc9ew.js} +1 -1
  11. package/dist/{chunk-TICWLB2K-De9FINtG.js → chunk-TICWLB2K-DZdNIpoZ.js} +1 -1
  12. package/dist/{classDiagram-ZZMXUADV-DweTkYdp.js → classDiagram-ZZMXUADV-Cgj_eEQA.js} +2 -2
  13. package/dist/{classDiagram-v2-VYDZK3BY-A6MR2TiE.js → classDiagram-v2-VYDZK3BY-DLAUrSqj.js} +2 -2
  14. package/dist/{code-visibility-BZDPS5dP.js → code-visibility-uDyLo9_i.js} +4 -4
  15. package/dist/{common-rusLIanu.js → common-DWKY45Md.js} +9 -9
  16. package/dist/{cynefinDiagram-5FMLGOSQ-BSvo5le-.js → cynefinDiagram-5FMLGOSQ-Cikf9AKa.js} +1 -1
  17. package/dist/{dagre-GXQ25YYZ-tXRQslO6.js → dagre-GXQ25YYZ-C5KEi5_l.js} +1 -1
  18. package/dist/{data-grid-overlay-editor-Dc_HCUPe.js → data-grid-overlay-editor-CRnYWD1L.js} +1 -1
  19. package/dist/{diagram-S7CK7UJ4-r3t5VtwI.js → diagram-S7CK7UJ4-BaoBTQjR.js} +1 -1
  20. package/dist/{diagram-UQ7AKVKN-qgbC8YnT.js → diagram-UQ7AKVKN-DDufBsUA.js} +1 -1
  21. package/dist/{diagram-VX7I27RA-CiHxEwtp.js → diagram-VX7I27RA-CY6RALJ8.js} +1 -1
  22. package/dist/{diagram-Z3DM3KII-D95u15Ev.js → diagram-Z3DM3KII-Bc-LHsD6.js} +1 -1
  23. package/dist/{dropdown-menu-DCMbbQ35.js → dropdown-menu-drDjxJyV.js} +1 -1
  24. package/dist/{ebnfDiagram-PWID7BFC-P7e4bryK.js → ebnfDiagram-PWID7BFC-Cz0J-tcC.js} +2 -2
  25. package/dist/{erDiagram-RLTQ6QDP-CUHZcmRj.js → erDiagram-RLTQ6QDP-DTXTDgFu.js} +1 -1
  26. package/dist/{error-entries-mpoD5t79.js → error-entries-CZ1NQ6Kv.js} +4 -4
  27. package/dist/{feedback-button-C3gqiY5b.js → feedback-button-CDf1yRm_.js} +5 -5
  28. package/dist/{flowDiagram-HODETNUW-BGZ95AzI.js → flowDiagram-HODETNUW-RbwWf2zc.js} +2 -2
  29. package/dist/{formats-DI7HEVv7.js → formats-DbXnijtH.js} +1 -1
  30. package/dist/{glide-data-editor-defMDM3B.js → glide-data-editor-CvRiA49N.js} +5 -5
  31. package/dist/{globals-D9kDDdYk.js → globals-BR4CmGOS.js} +2 -2
  32. package/dist/{html-to-image-BoZthB4P.js → html-to-image-D_4_hQ8U.js} +5 -5
  33. package/dist/{infoDiagram-27XIBGKW-BF0YX70D.js → infoDiagram-27XIBGKW-DlmzZjmI.js} +1 -1
  34. package/dist/{ishikawaDiagram-5VMMS53U-_itsAAn-.js → ishikawaDiagram-5VMMS53U-EN3TYP_q.js} +1 -1
  35. package/dist/{kanban-definition-UXKFOSKX-VNW2Beqh.js → kanban-definition-UXKFOSKX-CK_-Ru7Q.js} +1 -1
  36. package/dist/main.js +22 -22
  37. package/dist/{mermaid-CZ6FrClS.js → mermaid-DU9ZRmkG.js} +34 -34
  38. package/dist/{mindmap-definition-YA3MSWOX-DR4ripvd.js → mindmap-definition-YA3MSWOX-C-hqgUvF.js} +1 -1
  39. package/dist/{number-overlay-editor-CR5KeIcI.js → number-overlay-editor-DiYGbxNa.js} +1 -1
  40. package/dist/{pegDiagram-XKGWAZYB-CFr3XlGl.js → pegDiagram-XKGWAZYB-BiMejYPB.js} +2 -2
  41. package/dist/{pieDiagram-E7YTZNPT-j91XYSLY.js → pieDiagram-E7YTZNPT-B1zCZ1eq.js} +1 -1
  42. package/dist/{process-output-DLS4Mqg_.js → process-output-DxSCHBWp.js} +2 -2
  43. package/dist/{railroadDiagram-O6MQD6OU-Cd47ZV9E.js → railroadDiagram-O6MQD6OU-BLcfaASl.js} +2 -2
  44. package/dist/{requirementDiagram-BXWQKSXE-eJH6gLtX.js → requirementDiagram-BXWQKSXE-DtBOf52-.js} +1 -1
  45. package/dist/{reveal-component-DxZaPN5S.js → reveal-component-D3DsXPIm.js} +6 -6
  46. package/dist/{sequenceDiagram-WJ2MYXX4-DdfFEIrm.js → sequenceDiagram-WJ2MYXX4-DIwF19_n.js} +1 -1
  47. package/dist/{spec-h69nC3SI.js → spec-DZDnnlgT.js} +1 -1
  48. package/dist/{stateDiagram-D77RDMKH-DkjDvip8.js → stateDiagram-D77RDMKH-sWk1AdYL.js} +2 -2
  49. package/dist/{stateDiagram-v2-MP3YSRHH-DBHACnOo.js → stateDiagram-v2-MP3YSRHH-CiNo-OI7.js} +2 -2
  50. package/dist/style.css +1 -1
  51. package/dist/{swimlanes-42K2YHIH-ogImlOmp.js → swimlanes-42K2YHIH-Bj3hiOY5.js} +1 -1
  52. package/dist/{swimlanesDiagram-VR7AAH4N-D6x-zsci.js → swimlanesDiagram-VR7AAH4N-BzEo2r_N.js} +2 -2
  53. package/dist/{timeline-definition-24CTP7MA-DQpLtsHD.js → timeline-definition-24CTP7MA-CrPQk42H.js} +1 -1
  54. package/dist/{toDate-CDzoofJo.js → toDate-Cu2pIZcC.js} +1 -1
  55. package/dist/{useAsyncData-Bn8SxUqM.js → useAsyncData-DEhLdRIu.js} +1 -1
  56. package/dist/{useDeepCompareMemoize-CC2tnPCk.js → useDeepCompareMemoize-RjZGVhBV.js} +1 -1
  57. package/dist/{useLifecycle-BJlxHqWa.js → useLifecycle-DtcB2s1z.js} +1 -1
  58. package/dist/{useTheme-DMfQYmlG.js → useTheme-CoEtr4mK.js} +1 -1
  59. package/dist/{vega-component-CovWHi60.js → vega-component-BhjTrP9-.js} +5 -5
  60. package/dist/{vennDiagram-4TSXK5OY-BD-SL_vq.js → vennDiagram-4TSXK5OY-BaYMoIpj.js} +1 -1
  61. package/dist/{wardleyDiagram-VM6X3IG4-BDgJV4ah.js → wardleyDiagram-VM6X3IG4-DjHeuj8p.js} +1 -1
  62. package/dist/{xychartDiagram-S5SC5T6Z-1hIHN6Rl.js → xychartDiagram-S5SC5T6Z-Bc_hcuXS.js} +1 -1
  63. package/package.json +1 -1
  64. package/src/components/chat/__tests__/notebook-access-selector.test.tsx +64 -0
  65. package/src/components/chat/chat-panel.tsx +9 -91
  66. package/src/components/chat/notebook-access-selector.stories.tsx +22 -0
  67. package/src/components/chat/notebook-access-selector.tsx +100 -0
  68. package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +1 -5
  69. package/src/core/ai/tools/__tests__/registry.test.ts +17 -0
  70. package/src/core/ai/tools/base.ts +0 -6
  71. package/src/core/ai/tools/edit-notebook-tool.ts +1 -2
  72. package/src/core/ai/tools/registry.ts +0 -2
  73. package/src/core/config/__tests__/config-schema.test.ts +7 -2
  74. package/src/core/config/config-schema.ts +4 -1
  75. package/dist/assets/__vite-browser-external-DVeFf2e7.js +0 -1
  76. package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +0 -656
  77. package/src/core/ai/tools/run-cells-tool.ts +0 -303
@@ -1,303 +0,0 @@
1
- /* Copyright 2026 Marimo. All rights reserved. */
2
-
3
- import type { FileUIPart } from "ai";
4
- import { z } from "zod";
5
- import { runCells } from "@/components/editor/cell/useRunCells";
6
- import { notebookAtom } from "@/core/cells/cells";
7
- import type { CellId } from "@/core/cells/ids";
8
- import { staleCellIds } from "@/core/cells/utils";
9
- import { type JotaiStore, waitFor } from "@/core/state/jotai";
10
- import {
11
- type BaseOutput,
12
- getCellContextData,
13
- } from "../context/providers/cell-output";
14
- import {
15
- type AiTool,
16
- type EmptyToolInput,
17
- type ToolDescription,
18
- type ToolNotebookContext,
19
- type ToolOutputBase,
20
- toolOutputBaseSchema,
21
- } from "./base";
22
- import type { CopilotMode } from "./registry";
23
-
24
- const POST_EXECUTION_DELAY = 200;
25
- const WAIT_FOR_CELLS_TIMEOUT = 30_000;
26
-
27
- // Output size limits to prevent exceeding LLM token limits.
28
- const MAX_TEXT_OUTPUT_CHARS = 2000;
29
- const MAX_ERROR_OUTPUT_CHARS = 3000;
30
- const MAX_TOOL_OUTPUT_CHARS = 40_000;
31
-
32
- interface CellOutput {
33
- consoleOutput?: string;
34
- cellOutput?: string;
35
- }
36
-
37
- // Must use Record instead of Map because Map serializes to JSON as {}
38
- interface RunStaleCellsOutput extends ToolOutputBase {
39
- cellsToOutput?: Record<CellId, CellOutput | null>;
40
- }
41
-
42
- const description: ToolDescription = {
43
- baseDescription:
44
- "Run cells in the current notebook that are stale. Stale cells are cells that have been edited or newly added. You can run this tool after editing the notebook or when requested. The output of the ran cells will be returned alongside metadata.",
45
- };
46
-
47
- const filePartSchema = z.object({
48
- type: z.literal("file"),
49
- url: z.string(),
50
- mediaType: z.string(),
51
- }) satisfies z.ZodType<FileUIPart>;
52
-
53
- export class RunStaleCellsTool implements AiTool<
54
- EmptyToolInput,
55
- RunStaleCellsOutput
56
- > {
57
- public readonly name = "run_stale_cells_tool";
58
- public readonly description = description;
59
- public readonly schema = z.object({});
60
- public readonly outputSchema = toolOutputBaseSchema.extend({
61
- cellsToOutput: z
62
- .record(
63
- z.string(),
64
- z
65
- .object({
66
- consoleOutput: z.string().optional(),
67
- cellOutput: z.string().optional(),
68
- consoleAttachments: z.array(filePartSchema).optional(),
69
- cellAttachments: z.array(filePartSchema).optional(),
70
- })
71
- .nullable(),
72
- )
73
- .optional(),
74
- }) satisfies z.ZodType<RunStaleCellsOutput>;
75
- public readonly mode: CopilotMode[] = ["agent"];
76
-
77
- private readonly postExecutionDelay: number;
78
-
79
- public constructor(opts?: { postExecutionDelay?: number }) {
80
- this.postExecutionDelay = opts?.postExecutionDelay ?? POST_EXECUTION_DELAY;
81
- }
82
-
83
- public handler = async (
84
- _args: EmptyToolInput,
85
- toolContext: ToolNotebookContext,
86
- ): Promise<RunStaleCellsOutput> => {
87
- const { prepareForRun, sendRun, store } = toolContext;
88
-
89
- const notebook = store.get(notebookAtom);
90
- const staleCells = staleCellIds(notebook);
91
-
92
- if (staleCells.length === 0) {
93
- return {
94
- status: "success",
95
- message: "No stale cells found.",
96
- };
97
- }
98
-
99
- await runCells({
100
- cellIds: staleCells,
101
- sendRun,
102
- prepareForRun,
103
- notebook,
104
- });
105
-
106
- // Wait for all cells to finish executing
107
- const allCellsFinished = await this.waitForCellsToFinish(
108
- store,
109
- staleCells,
110
- WAIT_FOR_CELLS_TIMEOUT,
111
- this.postExecutionDelay,
112
- );
113
- if (!allCellsFinished) {
114
- return {
115
- status: "success",
116
- message:
117
- "No output was returned because some cells have not finished executing",
118
- };
119
- }
120
-
121
- // Get notebook state after cells have finished
122
- const updatedNotebook = store.get(notebookAtom);
123
-
124
- const cellsToOutput = new Map<CellId, CellOutput | null>();
125
- let outputHasErrors = false;
126
- let hasAnyConsoleOutput = false;
127
- let totalOutputChars = 0;
128
-
129
- for (const cellId of staleCells) {
130
- const cellContextData = getCellContextData(cellId, updatedNotebook, {
131
- includeConsoleOutput: true,
132
- });
133
-
134
- const cellOutput = cellContextData.cellOutput;
135
- const consoleOutputs = cellContextData.consoleOutputs;
136
- const hasConsoleOutput = consoleOutputs && consoleOutputs.length > 0;
137
-
138
- // Track errors regardless of budget
139
- if (
140
- (cellOutput && this.outputHasErrors(cellOutput)) ||
141
- (hasConsoleOutput &&
142
- consoleOutputs.some((output) => this.outputHasErrors(output)))
143
- ) {
144
- outputHasErrors = true;
145
- }
146
-
147
- if (!cellOutput && !hasConsoleOutput) {
148
- cellsToOutput.set(cellId, null);
149
- continue;
150
- }
151
-
152
- // If total budget exceeded, summarize remaining cells
153
- if (totalOutputChars >= MAX_TOOL_OUTPUT_CHARS) {
154
- cellsToOutput.set(cellId, {
155
- cellOutput: "Cell executed (output omitted due to context limits).",
156
- });
157
- continue;
158
- }
159
-
160
- let cellOutputString: string | undefined;
161
- let consoleOutputString: string | undefined;
162
-
163
- if (cellOutput) {
164
- cellOutputString = this.formatOutputString(cellOutput);
165
- totalOutputChars += cellOutputString.length;
166
- }
167
-
168
- if (hasConsoleOutput) {
169
- hasAnyConsoleOutput = true;
170
- consoleOutputString = consoleOutputs
171
- .map((output) => this.formatOutputString(output))
172
- .join("\n");
173
- consoleOutputString = this.truncateString(
174
- consoleOutputString,
175
- MAX_TEXT_OUTPUT_CHARS,
176
- );
177
- totalOutputChars += consoleOutputString.length;
178
- }
179
-
180
- cellsToOutput.set(cellId, {
181
- cellOutput: cellOutputString,
182
- consoleOutput: consoleOutputString,
183
- });
184
- }
185
-
186
- if (cellsToOutput.size === 0) {
187
- return {
188
- status: "success",
189
- message: "Stale cells have been run. No output was returned.",
190
- };
191
- }
192
-
193
- const nextSteps = [
194
- "Review the output of the cells. The CellId is the key of the result object.",
195
- outputHasErrors
196
- ? "There are errors in the cells. Please fix them by using the edit notebook tool and the given CellIds."
197
- : "You may edit the notebook further with the given CellIds.",
198
- ];
199
-
200
- return {
201
- status: "success",
202
- cellsToOutput: Object.fromEntries(cellsToOutput),
203
- message: hasAnyConsoleOutput
204
- ? "Console output represents the stdout or stderr of the cell (eg. print statements)."
205
- : undefined,
206
- next_steps: nextSteps,
207
- };
208
- };
209
-
210
- private outputHasErrors(cellOutput: BaseOutput): boolean {
211
- return (
212
- cellOutput.output.mimetype === "application/vnd.marimo+error" ||
213
- cellOutput.output.mimetype === "application/vnd.marimo+traceback"
214
- );
215
- }
216
-
217
- private formatOutputString(cellOutput: BaseOutput): string {
218
- const { outputType, processedContent, imageUrl, output } = cellOutput;
219
-
220
- if (outputType === "media") {
221
- const base = `Media Output: Contains ${output.mimetype} content`;
222
- return imageUrl ? `${base}\nImage URL: ${imageUrl}` : base;
223
- }
224
-
225
- if (output.mimetype === "text/html") {
226
- // text/html (e.g. plotly figures, rich dataframes) can be millions of
227
- // chars and is not interpretable by LLMs — summarize instead
228
- const dataLength =
229
- typeof output.data === "string"
230
- ? output.data.length
231
- : JSON.stringify(output.data).length;
232
- return `HTML Output: text/html content (${dataLength.toLocaleString()} chars). Full output visible in notebook UI.`;
233
- }
234
-
235
- const maxChars = this.outputHasErrors(cellOutput)
236
- ? MAX_ERROR_OUTPUT_CHARS
237
- : MAX_TEXT_OUTPUT_CHARS;
238
-
239
- let content = processedContent;
240
- if (!content) {
241
- content =
242
- typeof output.data === "string"
243
- ? output.data
244
- : JSON.stringify(output.data);
245
- }
246
- return `Output:\n${this.truncateString(content, maxChars)}`;
247
- }
248
-
249
- private truncateString(str: string, maxLength: number): string {
250
- if (str.length <= maxLength) {
251
- return str;
252
- }
253
- return `${str.slice(0, maxLength)}\n\n[TRUNCATED: ${str.length.toLocaleString()} → ${maxLength.toLocaleString()} chars. Full output visible in the notebook UI.]`;
254
- }
255
- /**
256
- * Wait for cells to finish executing (status becomes "idle")
257
- * Returns true if all cells finished executing, false if the timeout was reached
258
- */
259
- private async waitForCellsToFinish(
260
- store: JotaiStore,
261
- cellIds: CellId[],
262
- timeout: number,
263
- postExecutionDelay: number,
264
- ): Promise<boolean> {
265
- const checkAllFinished = (
266
- notebook: ReturnType<typeof notebookAtom.read>,
267
- ) => {
268
- return cellIds.every((cellId) => {
269
- const cellRuntime = notebook.cellRuntime[cellId];
270
- return (
271
- cellRuntime?.status !== "running" && cellRuntime?.status !== "queued"
272
- );
273
- });
274
- };
275
-
276
- // Add a small delay after cells finish to allow console outputs to arrive
277
- // Console outputs are streamed and might still be in-flight
278
- const delayForConsoleOutputs = async () => {
279
- if (postExecutionDelay > 0) {
280
- await new Promise((resolve) => setTimeout(resolve, postExecutionDelay));
281
- }
282
- return true;
283
- };
284
-
285
- // Return immediately if all cells are finished
286
- if (checkAllFinished(store.get(notebookAtom))) {
287
- return await delayForConsoleOutputs();
288
- }
289
-
290
- // Wait for notebook state changes with timeout
291
- try {
292
- await Promise.race([
293
- waitFor(notebookAtom, checkAllFinished),
294
- new Promise<never>((_, reject) =>
295
- setTimeout(() => reject(new Error("timeout")), timeout),
296
- ),
297
- ]);
298
- return await delayForConsoleOutputs();
299
- } catch {
300
- return false;
301
- }
302
- }
303
- }