@marimo-team/frontend 0.24.1-dev57 → 0.24.1-dev59
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/assets/add-cell-with-ai-DVGZNNUv.js +76 -0
- package/dist/assets/{agent-panel-D7mo8YLQ.js → agent-panel-BTY3oeHD.js} +3 -3
- package/dist/assets/cell-editor-D3YsOG7a.js +21 -0
- package/dist/assets/{chat-display-Cgg0xLir.js → chat-display-NTNQQyoE.js} +1 -1
- package/dist/assets/chat-panel-Bow0QKrA.js +4 -0
- package/dist/assets/{chat-ui-DYLpA8l4.js → chat-ui-Cg69zAqt.js} +4 -4
- package/dist/assets/{command-palette-DiT0E_K7.js → command-palette-QFmIvDcT.js} +1 -1
- package/dist/assets/{edit-page-DAC4cNKe.js → edit-page-ds4edlkF.js} +6 -6
- package/dist/assets/{index-DTQ4RS9q.js → index-B36dhEV6.js} +3 -3
- package/dist/assets/index-ecw9ngZu.css +2 -0
- package/dist/assets/{layout-D3zwsTvR.js → layout-iNJ-1JI2.js} +2 -2
- package/dist/assets/{panels-ChFSBlsU.js → panels-BbkuRtEi.js} +1 -1
- package/dist/assets/{reveal-component-BFRmOcQr.js → reveal-component-C4pF9OE7.js} +1 -1
- package/dist/assets/{run-page-MZCCEXct.js → run-page-Bo57bjbp.js} +1 -1
- package/dist/assets/{scratchpad-panel-BqYT2vj3.js → scratchpad-panel-vBIq9BfA.js} +1 -1
- package/dist/assets/{skeleton-gmxAkHfa.js → skeleton-B5iAa5n_.js} +1 -1
- package/dist/assets/{useNotebookActions-BoFJmccb.js → useNotebookActions-DGuDG0Px.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +0 -178
- package/src/components/editor/ai/__tests__/staged-cell-submission.test.ts +106 -0
- package/src/components/editor/ai/add-cell-with-ai.tsx +83 -62
- package/src/components/editor/ai/ai-completion-editor.tsx +71 -37
- package/src/components/editor/ai/completion-handlers.tsx +4 -0
- package/src/components/editor/ai/completion-utils.ts +0 -92
- package/src/components/editor/ai/staged-cell-submission.ts +46 -0
- package/src/components/editor/cell/StagedAICell.tsx +4 -2
- package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +64 -0
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +77 -0
- package/src/components/editor/chrome/wrapper/pending-ai-cells.tsx +8 -2
- package/src/core/ai/__tests__/staged-cells.test.ts +442 -125
- package/src/core/ai/__tests__/stream-completion-text.test.ts +74 -0
- package/src/core/ai/completion-output.ts +56 -0
- package/src/core/ai/staged-cells.ts +245 -164
- package/src/core/ai/stream-completion-text.ts +23 -6
- package/src/css/globals.css +1 -0
- package/dist/assets/add-cell-with-ai-0dqk0f7O.js +0 -77
- package/dist/assets/cell-editor-e7_o4mEh.js +0 -24
- package/dist/assets/chat-panel-BaG-5LiN.js +0 -4
- package/dist/assets/index-BrmH4-pI.css +0 -2
- package/src/core/ai/__tests__/strip-wrapping-backticks.test.ts +0 -133
- package/src/core/ai/strip-wrapping-backticks.ts +0 -88
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { consumeStream, parseJsonEventStream, uiMessageChunkSchema } from "ai";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CELL_COMPLETION_DATA_TYPE,
|
|
6
|
+
cellCompletionSchema,
|
|
7
|
+
isDataChunk,
|
|
8
|
+
} from "./completion-output";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
|
-
* Read an AI SDK UI message stream response and return
|
|
11
|
+
* Read an AI SDK UI message stream response and return validated cell code.
|
|
8
12
|
*/
|
|
9
13
|
export async function streamCompletionText(
|
|
10
14
|
response: Response,
|
|
@@ -17,7 +21,8 @@ export async function streamCompletionText(
|
|
|
17
21
|
throw new Error("Failed to get response body");
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
let result =
|
|
24
|
+
let result: string | null = null;
|
|
25
|
+
let finishedSuccessfully = false;
|
|
21
26
|
|
|
22
27
|
await consumeStream({
|
|
23
28
|
stream: parseJsonEventStream({
|
|
@@ -31,10 +36,15 @@ export async function streamCompletionText(
|
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
const streamPart = part.value;
|
|
34
|
-
if (
|
|
35
|
-
|
|
39
|
+
if (
|
|
40
|
+
isDataChunk(streamPart) &&
|
|
41
|
+
streamPart.type === CELL_COMPLETION_DATA_TYPE
|
|
42
|
+
) {
|
|
43
|
+
result = cellCompletionSchema.parse(streamPart.data).code;
|
|
36
44
|
} else if (streamPart.type === "error") {
|
|
37
45
|
throw new Error(streamPart.errorText);
|
|
46
|
+
} else if (streamPart.type === "finish") {
|
|
47
|
+
finishedSuccessfully = streamPart.finishReason === "stop";
|
|
38
48
|
}
|
|
39
49
|
},
|
|
40
50
|
}),
|
|
@@ -44,5 +54,12 @@ export async function streamCompletionText(
|
|
|
44
54
|
},
|
|
45
55
|
});
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
if (!finishedSuccessfully) {
|
|
58
|
+
throw new Error("AI completion ended before final validation");
|
|
59
|
+
}
|
|
60
|
+
if (result === null) {
|
|
61
|
+
throw new Error("AI completion returned no cell code");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return result;
|
|
48
65
|
}
|