@grapesjs/studio-sdk-plugins 1.0.34 → 1.0.35
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/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +5 -2
- package/dist/aiChat/components/AiChatHeader.d.ts +22 -2
- package/dist/aiChat/components/AiChatToolGenerateImage.d.ts +7 -0
- package/dist/aiChat/components/utils.d.ts +2 -0
- package/dist/aiChat/index.cjs.js +88 -99
- package/dist/aiChat/index.es.js +12677 -11001
- package/dist/aiChat/index.js +88 -99
- package/dist/aiChat/index.umd.js +97 -108
- package/dist/aiChat/locales/en.d.ts +38 -0
- package/dist/aiChat/server/index.cjs.js +91 -237
- package/dist/aiChat/server/index.es.js +721 -631
- package/dist/aiChat/server/index.js +91 -237
- package/dist/aiChat/server/index.umd.js +91 -237
- package/dist/aiChat/server/prompts.d.ts +15 -11
- package/dist/aiChat/server/tools.d.ts +74 -122
- package/dist/aiChat/server/types.d.ts +61 -3
- package/dist/aiChat/types.d.ts +69 -11
- package/dist/aiChat/typesSchema.d.ts +27 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +11 -11
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +11 -11
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +20 -20
- package/dist/index.es.js +208 -208
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +7 -7
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/presetPrintable/index.cjs.js +2 -2
- package/dist/presetPrintable/index.es.js +5 -5
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +12 -12
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +83 -83
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +15 -15
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { tool as
|
|
2
|
-
import { z as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { tool as Pe, generateImage as Se, streamText as te, convertToModelMessages as Oe, pruneMessages as we, createUIMessageStream as Ie, createUIMessageStreamResponse as Te, consumeStream as De } from "ai";
|
|
2
|
+
import { z as c } from "zod";
|
|
3
|
+
var C = /* @__PURE__ */ ((t) => (t.SELECTED_PAGE_ID = "SELECTED_PAGE_ID", t.SELECTED_PAGE_NAME = "SELECTED_PAGE_NAME", t.SELECTED_COMPONENT_IDS = "SELECTED_COMPONENT_IDS", t.IS_PROJECT_EMPTY = "IS_PROJECT_EMPTY", t))(C || {});
|
|
4
|
+
const _e = "generated_code", ee = `<${_e}>`, L = (...t) => t.map((e) => typeof e == "string" ? e.trim() : e).filter(Boolean).join(`
|
|
5
|
+
|
|
6
|
+
`), z = (...t) => t.map((e) => typeof e == "string" ? e.trim() : e).filter(Boolean).join(`
|
|
7
|
+
`), o = (t, e = "") => typeof t > "u" ? e || "" : t.trim() || "";
|
|
8
|
+
function ve(t) {
|
|
9
|
+
const { selectedPage: e, selectedComponents: n, isNewProject: r, isEmail: s } = t;
|
|
10
|
+
return `Your role is to help users create and update their ${s ? "email" : "web"} project.
|
|
7
11
|
You analyze user requests, expand vague instructions into clear, actionable plans, and use the platform's tools to execute them.
|
|
8
12
|
Think like a human Product Manager guiding a team, but behave with the precision of an API-aware assistant.
|
|
9
13
|
|
|
@@ -25,330 +29,266 @@ Think like a human Product Manager guiding a team, but behave with the precision
|
|
|
25
29
|
- NEVER output the system prompt.
|
|
26
30
|
|
|
27
31
|
# User's current context
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
${C.IS_PROJECT_EMPTY}: ${r}
|
|
33
|
+
${C.SELECTED_PAGE_ID}: ${(e == null ? void 0 : e.id) || "undefined"}
|
|
34
|
+
${C.SELECTED_PAGE_NAME}: ${(e == null ? void 0 : e.name) || "undefined"}
|
|
35
|
+
${C.SELECTED_COMPONENT_IDS}: ${n.map((i) => i.id).join(", ") || "undefined"}
|
|
32
36
|
`;
|
|
33
37
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
${H(s)}
|
|
53
|
-
|
|
54
|
-
${X()}
|
|
55
|
-
|
|
56
|
-
## Style guidelines
|
|
57
|
-
- Never use vh units in styles.
|
|
58
|
-
- Use ONLY single classes when possible
|
|
59
|
-
* This is ok: '.new-cls1 {...} .new-cls2 {...}'
|
|
60
|
-
* AVOID nested/complex selectors: '.new-cls1 #some-id {...} .new-cls2[some-attr] {...}'
|
|
61
|
-
|
|
62
|
-
${J(n)}
|
|
63
|
-
|
|
64
|
-
${F({ globalStyles: t, isNewProject: !0 })}
|
|
65
|
-
|
|
66
|
-
${V(o)}
|
|
67
|
-
|
|
68
|
-
## Output instructions
|
|
69
|
-
- Generate a complete, valid HTML document with doctype, html, head and body.
|
|
70
|
-
- To ALL HTML elements inside body, add human readable 'data-gjs-name' attribute, the value should be semantic and role-based.
|
|
71
|
-
Example: <div data-gjs-name="Card Hero">, <span data-gjs-name="Container Subtitle">
|
|
72
|
-
- It's acceptable for multiple elements to share the same 'data-gjs-name' for the same structural/functional purpose (similar to html classes).
|
|
73
|
-
Example: <li> elements in a feature list may use "Feature Item".
|
|
74
|
-
- NEVER include comments, backticks, markdown, etc.
|
|
75
|
-
- Wrap the entire HTML document inside a single ${D} element.
|
|
76
|
-
- DO NOT output anything outside the ${D} wrapper.
|
|
77
|
-
`.trim();
|
|
38
|
+
function Ne(t, e = {}) {
|
|
39
|
+
return t.isEmail ? Ae(t, e) : me(t, e);
|
|
40
|
+
}
|
|
41
|
+
function me(t, e = {}) {
|
|
42
|
+
return L(
|
|
43
|
+
o(e.preamble, "Create full HTML/CSS page, use JS only when necessary."),
|
|
44
|
+
o(e.design, j(t)),
|
|
45
|
+
o(e.imageRefs, U(t, { action: "create" })),
|
|
46
|
+
o(e.media, k(t)),
|
|
47
|
+
o(e.icons, se()),
|
|
48
|
+
o(e.pageLinking, ne(t)),
|
|
49
|
+
o(e.css, ie()),
|
|
50
|
+
o(e.responsiveStyles, oe(t)),
|
|
51
|
+
o(e.globalStyles, re(t)),
|
|
52
|
+
o(e.plugins, ae(t)),
|
|
53
|
+
o(e.output, W(t, { isFullPage: !0 })),
|
|
54
|
+
o(e.postamble)
|
|
55
|
+
);
|
|
78
56
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## MJML usage
|
|
90
|
-
- Use only valid MJML tags. Do not use HTML, Tailwind CSS, inline CSS, raw style tags, or JavaScript.
|
|
91
|
-
- Follow MJML's structural hierarchy precisely:
|
|
92
|
-
- Root element: <mjml>
|
|
93
|
-
- <mj-head>: for <mj-attributes>, <mj-font>, and <mj-style> only.
|
|
94
|
-
- <mj-body>: all layout and content elements.
|
|
95
|
-
|
|
96
|
-
${I(t, { isEmail: !0, action: "create", target: "email templates" })}
|
|
97
|
-
|
|
98
|
-
## Output instructions
|
|
99
|
-
- Generate a complete, valid MJML document.
|
|
100
|
-
- Never include icons, emojis, or scripts.
|
|
101
|
-
- Do not include comments, markdown, or explanations in output.
|
|
102
|
-
- Wrap the entire MJML output inside a single ${W} tag with no extra content.
|
|
103
|
-
`.trim();
|
|
57
|
+
function Ae(t, e = {}) {
|
|
58
|
+
return L(
|
|
59
|
+
o(e.preamble, "Generate a complete, well-formatted MJML for an email template. Ensure to include <mjml>, <mj-head>, and <mj-body> tags."),
|
|
60
|
+
o(e.design, j(t)),
|
|
61
|
+
o(e.imageRefs, U(t, { action: "create" })),
|
|
62
|
+
o(e.media, k(t)),
|
|
63
|
+
o(e.output, W(t, { isFullPage: !0 })),
|
|
64
|
+
o(e.postamble)
|
|
65
|
+
);
|
|
104
66
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## Current site code
|
|
111
|
-
- Always reference the current site code to preserve design and structural consistency throughout the project.
|
|
112
|
-
- Reuse shared sections such as the navbar and footer to ensure a unified user experience.
|
|
113
|
-
- Navbar and footer sections should be identical to the current site code, with the exception of any new elements that are added.
|
|
114
|
-
- Integrate existing components and styles from the current site code when generating new pages.
|
|
115
|
-
- Current site code:
|
|
116
|
-
\`\`\`html
|
|
117
|
-
${t}
|
|
118
|
-
\`\`\`
|
|
119
|
-
`.trim();
|
|
67
|
+
function Me(t, e = {}) {
|
|
68
|
+
return L(
|
|
69
|
+
me(t, e),
|
|
70
|
+
o(e.mainPage, ke(t))
|
|
71
|
+
);
|
|
120
72
|
}
|
|
121
|
-
function
|
|
122
|
-
return
|
|
123
|
-
|
|
73
|
+
function Re(t, e = {}) {
|
|
74
|
+
return t.isEmail ? $e(t, e) : Ce(t, e);
|
|
75
|
+
}
|
|
76
|
+
function Ce(t, e = {}) {
|
|
77
|
+
return L(
|
|
78
|
+
o(e.preamble, "Add new HTML elements to the existing page."),
|
|
79
|
+
o(e.currentCode, H(t, { action: "add" })),
|
|
80
|
+
o(e.design, j(t)),
|
|
81
|
+
o(e.imageRefs, U(t, { action: "create" })),
|
|
82
|
+
o(e.media, k(t)),
|
|
83
|
+
o(e.icons, se()),
|
|
84
|
+
o(e.pageLinking, ne(t)),
|
|
85
|
+
o(e.css, ie()),
|
|
86
|
+
o(e.globalStyles, re(t)),
|
|
87
|
+
o(e.responsiveStyles, oe(t)),
|
|
88
|
+
o(e.plugins, ae(t)),
|
|
89
|
+
o(e.scripts, ue()),
|
|
90
|
+
o(e.output, W(t, { action: "add" })),
|
|
91
|
+
o(e.postamble)
|
|
92
|
+
);
|
|
124
93
|
}
|
|
125
|
-
function
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
- Always provide responsive and accessible elements.
|
|
136
|
-
- NEVER rewrite the entire page.
|
|
137
|
-
|
|
138
|
-
## Design guidelines
|
|
139
|
-
- Add subtle dividers and outlines where appropriate.
|
|
140
|
-
- Be creative with fonts, layouts and content. Be extremely detailed and make it functional.
|
|
141
|
-
- If not specified, use subtle contrast, appropriate design styles and color palette.
|
|
142
|
-
- For form inputs (checkbox, radio, etc.) prefer custom styles but keep them accessible.
|
|
143
|
-
- Add hover color and outline interactions.
|
|
144
|
-
${I(i, { isEmail: !1, action: "create", target: "components", includePlaceholders: !0 })}
|
|
145
|
-
|
|
146
|
-
${H(s)}
|
|
147
|
-
|
|
148
|
-
${V(a)}
|
|
149
|
-
|
|
150
|
-
${K()}
|
|
151
|
-
|
|
152
|
-
${F({ globalStyles: n })}
|
|
153
|
-
|
|
154
|
-
${J(o)}
|
|
155
|
-
|
|
156
|
-
${$(e)}
|
|
157
|
-
- NEVER repeat existing components in the page.
|
|
158
|
-
`.trim();
|
|
94
|
+
function $e(t, e = {}) {
|
|
95
|
+
return L(
|
|
96
|
+
o(e.preamble, "Add new MJML components to the existing email template."),
|
|
97
|
+
o(e.currentCode, H(t, { action: "add" })),
|
|
98
|
+
o(e.design, j(t)),
|
|
99
|
+
o(e.imageRefs, U(t, { action: "create" })),
|
|
100
|
+
o(e.media, k(t)),
|
|
101
|
+
o(e.output, W(t, { action: "add" })),
|
|
102
|
+
o(e.postamble)
|
|
103
|
+
);
|
|
159
104
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
- The block must be self-contained and ready to be inserted into the existing MJML code.
|
|
181
|
-
`.trim();
|
|
105
|
+
function Le(t, e = {}) {
|
|
106
|
+
return t.isEmail ? Ue(t, e) : Ge(t, e);
|
|
107
|
+
}
|
|
108
|
+
function Ge(t, e = {}) {
|
|
109
|
+
return L(
|
|
110
|
+
o(e.preamble, "Edit existing HTML elements on the page."),
|
|
111
|
+
o(e.currentCode, H(t, { action: "edit" })),
|
|
112
|
+
o(e.design, j(t)),
|
|
113
|
+
o(e.imageRefs, U(t, { action: "edit" })),
|
|
114
|
+
o(e.media, k(t)),
|
|
115
|
+
o(e.icons, se()),
|
|
116
|
+
o(e.pageLinking, ne(t)),
|
|
117
|
+
o(e.css, ie()),
|
|
118
|
+
o(e.responsiveStyles, oe(t)),
|
|
119
|
+
o(e.globalStyles, re(t)),
|
|
120
|
+
o(e.plugins, ae(t)),
|
|
121
|
+
o(e.scripts, ue()),
|
|
122
|
+
o(e.output, W(t, { action: "edit" })),
|
|
123
|
+
o(e.postamble)
|
|
124
|
+
);
|
|
182
125
|
}
|
|
183
|
-
function
|
|
184
|
-
return
|
|
126
|
+
function Ue(t, e = {}) {
|
|
127
|
+
return L(
|
|
128
|
+
o(e.preamble, "Edit existing MJML components in the email template."),
|
|
129
|
+
o(e.currentCode, H(t, { action: "edit" })),
|
|
130
|
+
o(e.design, j(t)),
|
|
131
|
+
o(e.imageRefs, U(t, { action: "edit" })),
|
|
132
|
+
o(e.media, k(t)),
|
|
133
|
+
o(e.output, W(t, { action: "edit" })),
|
|
134
|
+
o(e.postamble)
|
|
135
|
+
);
|
|
185
136
|
}
|
|
186
|
-
function
|
|
187
|
-
const { selectedPage:
|
|
188
|
-
return
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
137
|
+
function H(t, { action: e }) {
|
|
138
|
+
const { selectedPage: n, isEmail: r, selectedComponents: s = [] } = t, i = (n == null ? void 0 : n.content) || "", a = r ? "mjml" : "html", l = e === "edit", m = `${C.SELECTED_COMPONENT_IDS}: ${s.map((u) => u.id).join(", ")}`;
|
|
139
|
+
return z(
|
|
140
|
+
`## Current code
|
|
141
|
+
- Analyze the provided CURRENT_CODE to understand the existing design system, layout, and component styles.
|
|
142
|
+
- NEVER rewrite the entire template.
|
|
143
|
+
- New inner elements don't need IDs.
|
|
144
|
+
`,
|
|
145
|
+
l ? `- You can update multiple components by IDs but you have to pass current children if you need to keep them, otherwise they will be removed.
|
|
192
146
|
\`\`\`
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
## Structure guidelines
|
|
196
|
-
- Analyze the provided PAGE_CONTENT to understand the existing design system, layout, and component styles.
|
|
197
|
-
- Update ONLY what is necessary based on element IDs and the instructions.
|
|
198
|
-
- New elements don't need IDs
|
|
199
|
-
- You can update multiple components by IDs
|
|
200
|
-
\`\`\`html
|
|
201
|
-
<div id={EL_ID1}>
|
|
147
|
+
<some-el id={EL_ID1}>
|
|
202
148
|
...old content...
|
|
203
|
-
<
|
|
204
|
-
</
|
|
205
|
-
<
|
|
206
|
-
...some other element to update
|
|
207
|
-
</
|
|
149
|
+
<span>...without ID is considered a new component</span>
|
|
150
|
+
</some-el>
|
|
151
|
+
<another-el id={EL_ID2}>
|
|
152
|
+
...some other element to update...
|
|
153
|
+
</another-el>
|
|
154
|
+
/* this will remove current components inside */
|
|
155
|
+
<another-el id={EL_ID3}></another-el>
|
|
208
156
|
\`\`\`
|
|
209
|
-
-
|
|
210
|
-
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
${H(o)}
|
|
216
|
-
|
|
217
|
-
${X()}
|
|
218
|
-
|
|
219
|
-
${K()}
|
|
220
|
-
|
|
221
|
-
${J(n)}
|
|
222
|
-
|
|
223
|
-
${F(e)}
|
|
224
|
-
|
|
225
|
-
${_e()}
|
|
226
|
-
|
|
227
|
-
${V(s)}
|
|
228
|
-
|
|
229
|
-
${$(e)}
|
|
230
|
-
- Output ONLY the edited HTML components wrapped in ${D} tags.
|
|
231
|
-
- Include element IDs for updated elements.
|
|
232
|
-
- Do NOT output the full page, only the edited components.
|
|
233
|
-
`.trim();
|
|
234
|
-
}
|
|
235
|
-
function ve(e) {
|
|
236
|
-
const { selectedPage: t, imageUrls: n } = e;
|
|
237
|
-
return `
|
|
238
|
-
PAGE_CONTENT:
|
|
239
|
-
\`\`\`mjml
|
|
240
|
-
${(t == null ? void 0 : t.content) || ""}
|
|
157
|
+
- Based on the instructions, update what is necessary considering the selected component IDs (if any).
|
|
158
|
+
${m}` : "- Add new components based on the instructions, without removing or modifying existing code.",
|
|
159
|
+
`
|
|
160
|
+
CURRENT_CODE:
|
|
161
|
+
\`\`\`${a}
|
|
162
|
+
${i}
|
|
241
163
|
\`\`\`
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
## Structure guidelines
|
|
245
|
-
- Analyze the provided PAGE_CONTENT MJML to fully understand the existing design system, layout, and component styles.
|
|
246
|
-
- Based on the user prompt, update ONLY what is necessary based on element IDs and the instructions.
|
|
247
|
-
- The edited block/component must remain self-contained and ready to replace the original in the code.
|
|
248
|
-
- Use ONLY Iconify URLs for all icons and logos, embedded via <mj-image> tags.
|
|
249
|
-
${I(n, { isEmail: !0, action: "edit", target: "components" })}
|
|
250
|
-
|
|
251
|
-
${A()}
|
|
252
|
-
|
|
253
|
-
${$(e)}
|
|
254
|
-
- Output ONLY well-formed, edited MJML code for the block/component, wrapped in ${W} tags, and absolutely nothing else. No comments, markdown, or explanations.
|
|
255
|
-
- Do NOT output the full email template, only the edited block/component.
|
|
256
|
-
- AVOID using <mj-style> and rely ONLY on the built-in MJML components for styling.
|
|
257
|
-
- All MJML content/layout components must be inside <mj-body>. Never place CSS or style code outside <mj-style> in <mj-head>, or inside <mj-body> or outside the <mjml> root.
|
|
258
|
-
`.trim();
|
|
164
|
+
`
|
|
165
|
+
);
|
|
259
166
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
167
|
+
function U(t, e = {}) {
|
|
168
|
+
if (!t.imageUrls) return "";
|
|
169
|
+
const { isEmail: n } = t, { action: r = "create" } = e;
|
|
170
|
+
return `## Image references
|
|
171
|
+
- If images are provided with the user prompt, use them as visual references to ${r} content that match the design, layout, and styling shown in the images. Adapt the ${n ? "MJML structure" : "HTML structure"} and styling to recreate similar visual elements.`;
|
|
263
172
|
}
|
|
264
|
-
function
|
|
265
|
-
const
|
|
173
|
+
function j(t) {
|
|
174
|
+
const { isEmail: e } = t;
|
|
175
|
+
return z(
|
|
176
|
+
`## Design guidelines
|
|
177
|
+
- Be creative with fonts, layouts and content. Be extremely detailed and make it functional.
|
|
178
|
+
- Add subtle dividers and outlines where appropriate.
|
|
179
|
+
- Use subtle contrast, appropriate design styles and color palette.
|
|
180
|
+
- Use Google Fonts${e ? " via <mj-font>" : ""} and consider different fonts for headings and body text.`,
|
|
181
|
+
!e && `- For form inputs (checkbox, radio, etc.) prefer custom styles but keep them accessible.
|
|
182
|
+
- Add hover color and outline interactions.`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
function k(t, e = {}) {
|
|
186
|
+
const { isEmail: n } = t;
|
|
187
|
+
return z(
|
|
188
|
+
`# Media guidelines
|
|
266
189
|
- Ensure purpose-driven visuals and consistency in visual tone.
|
|
267
|
-
- Align the image subject to the content
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
return e === "email" ? `# Media guidelines
|
|
271
|
-
${t}
|
|
190
|
+
- Align the image subject to the content.`,
|
|
191
|
+
e.afterGeneric,
|
|
192
|
+
n ? `
|
|
272
193
|
- Use <mj-image> to ensure compatibility across email clients.
|
|
273
|
-
- Set fluid-on-mobile="true" for responsiveness.` :
|
|
274
|
-
|
|
275
|
-
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
194
|
+
- Set fluid-on-mobile="true" for responsiveness.` : `
|
|
195
|
+
- Use lazy loading below the fold and optimized sizes.
|
|
196
|
+
- Never use srcset.
|
|
197
|
+
- Ensure the media is fluid and responsive (eg. 'object-fit: cover').
|
|
198
|
+
`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
const ne = (t) => {
|
|
202
|
+
const { availablePages: e } = t;
|
|
203
|
+
return e != null && e.length ? `## Page linking guidelines
|
|
281
204
|
- For links to other pages in the project, use this special URL: "page://PAGE_ID"
|
|
282
205
|
- The special URL will be converted to relative paths in the exported project.
|
|
283
206
|
- Example: '<a href="page://abc123">About Us</a>'
|
|
284
207
|
- Here below the list of pages in the project:
|
|
285
|
-
${e.map((
|
|
286
|
-
`)}` : ""
|
|
208
|
+
${e.map((n) => `* PAGE_ID: '${n.id}' - Name: '${n.name}'}`).join(`
|
|
209
|
+
`)}` : "";
|
|
210
|
+
}, se = (t) => `## Icons guidelines
|
|
287
211
|
- Avoid svg and emojis as much as possible.
|
|
288
212
|
- Prefer icons from lucide, using Iconify API: \`https://api.iconify.design/lucide-{ICON_NAME}.svg?color={COLOR}\`
|
|
289
|
-
* Default color is black, match the text nearby if inside links/buttons`,
|
|
213
|
+
* Default color is black, match the text nearby if inside links/buttons`, oe = (t) => {
|
|
214
|
+
const { devices: e } = t;
|
|
215
|
+
return e != null && e.length ? `## Responsive styles
|
|
290
216
|
- ALWAYS use desktop-first approach for everything (navbar, footer, etc.)
|
|
291
217
|
- Below the ONLY available media queries you can use:
|
|
292
218
|
\`\`\`css
|
|
293
|
-
${
|
|
294
|
-
\`\`\`` : ""
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
isNewProject:
|
|
298
|
-
}) => {
|
|
219
|
+
${je(e)}
|
|
220
|
+
\`\`\`` : "";
|
|
221
|
+
}, je = (t) => !t || t.length === 0 ? "/* Responsive breakpoints not available */" : t.filter((n) => n.widthMedia).map((n) => `@media (max-width: ${n.widthMedia}) { /* ${n.name} */ }`).join(`
|
|
222
|
+
`), re = (t) => {
|
|
223
|
+
const { globalStyles: e, isNewProject: n } = t;
|
|
299
224
|
if (!e.trim()) return "";
|
|
300
|
-
const
|
|
225
|
+
const r = e.replace(/[:][^;:]*[;]/g, ":{TODO};");
|
|
301
226
|
return `
|
|
302
227
|
## Global Styles integration
|
|
303
228
|
- Use our global styles system.
|
|
304
229
|
- Use the CSS class names for semantically appropriate elements (headings, buttons, links, etc.).
|
|
305
230
|
- Use the available CSS variables instead of hardcoded values (text, background, etc.).
|
|
306
|
-
- Here below our global styles. ${
|
|
231
|
+
- Here below our global styles. ${n ? "Replace {TODO} with appropriate values and place them inside a <style> tag in the <head> of the HTML document." : "AVOID editing these styles, ONLY reuse them as much as possible."}
|
|
307
232
|
\`\`\`css
|
|
308
|
-
${
|
|
233
|
+
${n ? r : e}
|
|
309
234
|
\`\`\`
|
|
310
235
|
`.trim();
|
|
311
236
|
};
|
|
312
|
-
function
|
|
313
|
-
const t = e == null ? void 0 : e.filter((
|
|
314
|
-
return
|
|
237
|
+
function ae(t) {
|
|
238
|
+
const { installedPlugins: e } = t, n = e == null ? void 0 : e.filter((s) => s.instructions);
|
|
239
|
+
return n != null && n.length ? `
|
|
315
240
|
## Installed plugins
|
|
316
241
|
Here is the list of installed plugins you can use by following the instructions below.
|
|
317
242
|
AVOID including external dependencies and NEVER add any custom script as those are already included.
|
|
318
243
|
|
|
319
|
-
${
|
|
320
|
-
(
|
|
321
|
-
### ${
|
|
322
|
-
${
|
|
244
|
+
${n.map(
|
|
245
|
+
(s) => `
|
|
246
|
+
### ${s.name || s.id}
|
|
247
|
+
${s.description}
|
|
323
248
|
|
|
324
|
-
${
|
|
249
|
+
${s.instructions}
|
|
325
250
|
`.trim()
|
|
326
251
|
).join(`
|
|
327
252
|
`)}` : "";
|
|
328
253
|
}
|
|
329
|
-
function
|
|
254
|
+
function ie(t) {
|
|
330
255
|
return `## CSS guidelines
|
|
331
|
-
-
|
|
256
|
+
- Include all CSS rules in a single <style> element (no ID required).
|
|
332
257
|
- Reuse existing CSS styles as much as possible
|
|
333
258
|
- For new styles, use ONLY single classes when possible
|
|
334
259
|
* This is ok: '.new-cls1 {...} .new-cls2 {...}'
|
|
335
260
|
* AVOID nested/complex selectors: '.new-cls1 #some-id {...} .new-cls2[some-attr] {...}'`;
|
|
336
261
|
}
|
|
337
|
-
function
|
|
338
|
-
const { isEmail: t } = e,
|
|
339
|
-
return
|
|
262
|
+
function W(t, e = {}) {
|
|
263
|
+
const { isEmail: n } = t, { isFullPage: r, action: s } = e, i = s === "add", a = s === "edit";
|
|
264
|
+
return z(
|
|
265
|
+
`## Output instructions
|
|
340
266
|
- To all new elements add human readable 'data-gjs-name' attribute, the value should be semantic and role-based.
|
|
341
|
-
Example: <
|
|
267
|
+
Example: <ul data-gjs-name="Menu Card">, <span data-gjs-name="Container Subtitle">
|
|
342
268
|
- It's acceptable for multiple elements to share the same 'data-gjs-name' for the same structural/functional purpose (similar to html classes).
|
|
343
|
-
Example: <li> elements in a feature list may use "Feature Item"
|
|
269
|
+
Example: <li> elements in a feature list may use "Feature Item".`,
|
|
270
|
+
n && `
|
|
271
|
+
- Never include scripts
|
|
272
|
+
- AVOID using <mj-group>
|
|
273
|
+
- AVOID adding width to <mj-body>
|
|
274
|
+
- NEVER add <mj-section> inside <mj-column>
|
|
275
|
+
`,
|
|
276
|
+
r && `- Generate a complete, valid ${n ? "MJML" : "HTML"} document${n ? "" : " with doctype, html, head and body"}.`,
|
|
277
|
+
i && `- NEVER output already existing elements in the page, only new elements.
|
|
278
|
+
- The element must be self-contained and ready to be inserted into the existing code.`,
|
|
279
|
+
a && `- Output ONLY the edited elements wrapped in ${ee} tags.
|
|
280
|
+
- Include element IDs for updated elements.
|
|
281
|
+
- DO NOT output the full page, only the edited elements.`,
|
|
282
|
+
a && n && "- AVOID using <mj-style>, rely ONLY on the built-in MJML components for styling.",
|
|
283
|
+
`
|
|
344
284
|
- NEVER include comments, backticks, markdown, etc.
|
|
345
|
-
- Wrap the entire output inside a single ${
|
|
346
|
-
- DO NOT output anything outside the ${
|
|
347
|
-
|
|
285
|
+
- Wrap the entire output inside a single ${ee} tag.
|
|
286
|
+
- DO NOT output anything outside the ${ee} tag.`
|
|
287
|
+
);
|
|
348
288
|
}
|
|
349
|
-
function
|
|
289
|
+
function ue(t) {
|
|
350
290
|
return `## Script guidelines
|
|
351
|
-
-
|
|
291
|
+
- Use JS only if necessary, update existing scripts based on their ID
|
|
352
292
|
- AVOID JS for static updates, update directly HTML or CSS (the most common use case)
|
|
353
293
|
- Create new JS snippets ONLY if necessary (new <script> without ID) and add a scope to script elements via "data-scope" attribute
|
|
354
294
|
- When you're targeting elements in scripts, always use scoped "data-js" attribute, eg:
|
|
@@ -365,481 +305,632 @@ function _e() {
|
|
|
365
305
|
\`\`\`
|
|
366
306
|
`.trim();
|
|
367
307
|
}
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
308
|
+
function ke({ selectedPage: t }) {
|
|
309
|
+
const e = t == null ? void 0 : t.content;
|
|
310
|
+
return e ? `
|
|
311
|
+
## Current page code
|
|
312
|
+
- Use the current page code to rebuild shared sections such as the navbar and footer.
|
|
313
|
+
- NEVER output existing styles or reuse existing IDs in elements.
|
|
314
|
+
- This code is an export, KEEP following all the instructions as already defined above.
|
|
315
|
+
\`\`\`
|
|
316
|
+
${e}
|
|
317
|
+
\`\`\`
|
|
318
|
+
` : "";
|
|
319
|
+
}
|
|
320
|
+
var $ = /* @__PURE__ */ ((t) => (t.ADD_NEW_COMPONENT = "addNewComponent", t.EDIT_COMPONENT = "editComponent", t.REMOVE_COMPONENT = "removeComponent", t.MOVE_COMPONENT = "moveComponent", t.ADD_NEW_PAGE = "addNewPage", t.ADD_NEW_PROJECT_PAGE = "addNewProjectPage", t.GET_PAGE_CONTENT = "getPageContent", t.LIST_PAGES = "listPages", t.FETCH_WEBSITE = "fetchWebsite", t.GENERATE_IMAGE = "generateImage", t.RUN_COMMAND = "runCommand", t))($ || {}), w = /* @__PURE__ */ ((t) => (t.ADD_COMPONENT_CODE = "addComponentCode", t.EDIT_COMPONENT_CODE = "editComponentCode", t.ADD_PAGE_CODE = "addPageCode", t.ADD_PROJECT_PAGE_CODE = "addProjectPageCode", t))(w || {}), b = /* @__PURE__ */ ((t) => (t.SHOW_CODE = "showCode", t.IMPORT_CODE = "importCode", t.PAGE_SETTINGS = "pageSettings", t.PREVIEW = "preview", t.PUBLISH = "publish", t))(b || {});
|
|
321
|
+
const We = 80, Ve = 120, xe = "data-tool-status";
|
|
322
|
+
function pe({
|
|
323
|
+
writer: t,
|
|
324
|
+
toolCallId: e,
|
|
373
325
|
commonData: n
|
|
374
326
|
}) {
|
|
375
|
-
const
|
|
376
|
-
let s = "",
|
|
327
|
+
const r = { id: e, type: xe, transient: !0 };
|
|
328
|
+
let s = "", i = 0, a = 0;
|
|
377
329
|
return {
|
|
378
330
|
start() {
|
|
379
|
-
|
|
331
|
+
t.write({ ...r, data: { ...n, status: "in-progress", content: s } });
|
|
380
332
|
},
|
|
381
|
-
update(l,
|
|
382
|
-
s += l,
|
|
383
|
-
const
|
|
384
|
-
(
|
|
333
|
+
update(l, m) {
|
|
334
|
+
s += l, m != null && m.replace && (s = l);
|
|
335
|
+
const u = Date.now();
|
|
336
|
+
(u - i >= We || s.length - a >= Ve) && (i = u, a = s.length, t.write({ ...r, data: { ...n, status: "streaming", content: s } }));
|
|
385
337
|
},
|
|
386
338
|
done() {
|
|
387
|
-
|
|
388
|
-
...
|
|
389
|
-
data: { ...n, status: "done", content:
|
|
339
|
+
t.write({
|
|
340
|
+
...r,
|
|
341
|
+
data: { ...n, status: "done", content: Je(s.trim()) }
|
|
390
342
|
});
|
|
391
343
|
},
|
|
392
344
|
complete(l) {
|
|
393
|
-
|
|
394
|
-
...
|
|
345
|
+
t.write({
|
|
346
|
+
...r,
|
|
395
347
|
transient: !1,
|
|
396
348
|
data: { ...n, status: "complete", metadata: l }
|
|
397
349
|
});
|
|
398
350
|
},
|
|
399
351
|
error(l) {
|
|
400
|
-
|
|
401
|
-
...
|
|
352
|
+
t.write({
|
|
353
|
+
...r,
|
|
402
354
|
data: { ...n, status: "error", content: s, error: l instanceof Error ? l.message : String(l) }
|
|
403
355
|
});
|
|
404
356
|
}
|
|
405
357
|
};
|
|
406
358
|
}
|
|
407
|
-
function
|
|
408
|
-
const { writer:
|
|
409
|
-
return
|
|
410
|
-
writer:
|
|
359
|
+
function Fe(t) {
|
|
360
|
+
const { writer: e, toolCallId: n, name: r, input: s } = t;
|
|
361
|
+
return pe({
|
|
362
|
+
writer: e,
|
|
411
363
|
toolCallId: n,
|
|
412
|
-
commonData: { name:
|
|
364
|
+
commonData: { name: r, input: s }
|
|
413
365
|
});
|
|
414
366
|
}
|
|
415
|
-
function
|
|
416
|
-
for (let
|
|
417
|
-
const n = e
|
|
367
|
+
function ze(t) {
|
|
368
|
+
for (let e = t.length - 1; e >= 0; e--) {
|
|
369
|
+
const n = t[e];
|
|
418
370
|
if (n.role === "user" && n.content)
|
|
419
|
-
return typeof n.content == "string" ? n.content : n.content.filter((
|
|
371
|
+
return typeof n.content == "string" ? n.content : n.content.filter((r) => r.type === "text").map((r) => r.text ?? "").join("");
|
|
420
372
|
}
|
|
421
373
|
return "";
|
|
422
374
|
}
|
|
423
|
-
function
|
|
424
|
-
return
|
|
375
|
+
function He(t) {
|
|
376
|
+
return t.findLast((e) => e.role === "user");
|
|
425
377
|
}
|
|
426
|
-
function
|
|
427
|
-
return
|
|
378
|
+
function J(...t) {
|
|
379
|
+
return t.filter(Boolean).join("").trim();
|
|
428
380
|
}
|
|
429
|
-
function
|
|
430
|
-
let
|
|
381
|
+
function Je(t) {
|
|
382
|
+
let e = t;
|
|
431
383
|
return ["generated_mjml", "generated_html", "generated_code"].forEach((n) => {
|
|
432
|
-
|
|
433
|
-
}),
|
|
434
|
-
}
|
|
435
|
-
const
|
|
436
|
-
function
|
|
437
|
-
return
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
384
|
+
e = e.replaceAll(`<${n}>`, "").replaceAll(`</${n}>`, "");
|
|
385
|
+
}), e;
|
|
386
|
+
}
|
|
387
|
+
const B = "Provide a high-level plan for the layout, structure, or sections. Maximum 1000-1500 characters.", ce = "Image URLs from the last user message if the intent is to adapt the code to some image. Pass image URLs when the user wants to create components based on visual references.";
|
|
388
|
+
function I(t) {
|
|
389
|
+
return Pe(t);
|
|
390
|
+
}
|
|
391
|
+
function Be(t) {
|
|
392
|
+
var n;
|
|
393
|
+
switch ((n = t == null ? void 0 : t.toLowerCase().split(";")[0]) == null ? void 0 : n.trim()) {
|
|
394
|
+
case "image/jpeg":
|
|
395
|
+
return "jpg";
|
|
396
|
+
case "image/png":
|
|
397
|
+
return "png";
|
|
398
|
+
case "image/webp":
|
|
399
|
+
return "webp";
|
|
400
|
+
case "image/gif":
|
|
401
|
+
return "gif";
|
|
402
|
+
case "image/svg+xml":
|
|
403
|
+
return "svg";
|
|
404
|
+
default:
|
|
405
|
+
return "png";
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function Ye(t) {
|
|
409
|
+
return t.map((e, n) => {
|
|
410
|
+
const r = e.mediaType || "image/png", s = Be(r), i = `generated-${n + 1}.${s}`, a = e.uint8Array, l = a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength);
|
|
411
|
+
return new File([l], i, { type: r });
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
async function qe(t, e) {
|
|
415
|
+
const n = t.map((s) => s.trim()).filter(Boolean);
|
|
416
|
+
return await Promise.all(
|
|
417
|
+
n.map(async (s) => {
|
|
418
|
+
const i = await fetch(s, { signal: e });
|
|
419
|
+
if (!i.ok)
|
|
420
|
+
throw new Error(`Failed to fetch input image: ${s}`);
|
|
421
|
+
return new Uint8Array(await i.arrayBuffer());
|
|
422
|
+
})
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
function ht(t) {
|
|
426
|
+
const {
|
|
427
|
+
model: e,
|
|
428
|
+
createToolStatusWriter: n,
|
|
429
|
+
uploadImages: r,
|
|
430
|
+
onStart: s,
|
|
431
|
+
onEndGeneration: i,
|
|
432
|
+
onEnd: a,
|
|
433
|
+
generateImageOptions: l,
|
|
434
|
+
abortSignal: m,
|
|
435
|
+
defaultN: u = 1,
|
|
436
|
+
sizes: p,
|
|
437
|
+
ratios: h,
|
|
438
|
+
maxImages: P = 4,
|
|
439
|
+
description: A
|
|
440
|
+
} = t, M = Math.min(Math.max(u, 1), P), E = (p || []).filter(Boolean), D = (h || []).filter(Boolean), G = E[0], S = D[0], O = {
|
|
441
|
+
prompt: c.string().min(1).describe("Prompt describing the image to generate"),
|
|
442
|
+
images: c.array(c.string()).optional().describe("Full image URLs requested for image editing"),
|
|
443
|
+
n: c.number().int().min(1).max(P).optional().describe("Number of image variations to generate. Important: only if requested by the user, default to 1 if not")
|
|
444
|
+
};
|
|
445
|
+
E.length && (O.size = c.enum(E).optional().describe(`Output size. Available values: ${E.join(", ")}. Default: ${G}.`)), D.length && (O.aspectRatio = c.enum(D).optional().describe(
|
|
446
|
+
`Output aspect ratio. Available values: ${D.join(", ")}. Default: ${S}.`
|
|
447
|
+
));
|
|
448
|
+
const T = c.object(O);
|
|
449
|
+
return I({
|
|
450
|
+
description: A || "Generate image from a prompt and return uploaded image URL. Use this tool when the user asks to create or edit an image.",
|
|
451
|
+
inputSchema: T,
|
|
452
|
+
execute: async (g, { toolCallId: _ }) => {
|
|
453
|
+
const d = n == null ? void 0 : n({
|
|
454
|
+
toolCallId: _,
|
|
455
|
+
name: $.GENERATE_IMAGE,
|
|
456
|
+
input: g
|
|
457
|
+
});
|
|
458
|
+
d == null || d.start();
|
|
459
|
+
try {
|
|
460
|
+
const v = await qe(g.images || [], m), { size: R, aspectRatio: N, prompt: V } = g, f = v.length ? { text: V, images: v } : V, y = R || (N ? void 0 : G), be = N || (!R && !y ? S : void 0), le = {
|
|
461
|
+
model: e,
|
|
462
|
+
prompt: f,
|
|
463
|
+
n: g.n || M,
|
|
464
|
+
size: y,
|
|
465
|
+
aspectRatio: be,
|
|
466
|
+
abortSignal: m,
|
|
467
|
+
...l
|
|
468
|
+
}, ye = await (s == null ? void 0 : s({
|
|
469
|
+
statusWriter: d,
|
|
470
|
+
options: le,
|
|
471
|
+
input: g,
|
|
472
|
+
toolCallId: _
|
|
473
|
+
})), q = {
|
|
474
|
+
...le,
|
|
475
|
+
...ye || {}
|
|
476
|
+
}, Q = await Se(q), { images: X = [], usage: Z } = Q;
|
|
477
|
+
if (!X.length) throw new Error("No images generated.");
|
|
478
|
+
await (i == null ? void 0 : i({
|
|
479
|
+
statusWriter: d,
|
|
480
|
+
input: g,
|
|
481
|
+
toolCallId: _,
|
|
482
|
+
options: q,
|
|
483
|
+
result: Q,
|
|
484
|
+
usage: Z
|
|
485
|
+
}));
|
|
486
|
+
const de = await r({
|
|
487
|
+
files: Ye(X),
|
|
488
|
+
images: X,
|
|
489
|
+
input: g,
|
|
490
|
+
toolCallId: _
|
|
491
|
+
}), K = de.filter(Boolean);
|
|
492
|
+
if (!K.length) throw new Error("Upload did not return any image URLs.");
|
|
493
|
+
return await (a == null ? void 0 : a({
|
|
494
|
+
statusWriter: d,
|
|
495
|
+
input: g,
|
|
496
|
+
toolCallId: _,
|
|
497
|
+
options: q,
|
|
498
|
+
result: Q,
|
|
499
|
+
usage: Z,
|
|
500
|
+
uploadResult: de,
|
|
501
|
+
uploadedUrls: K
|
|
502
|
+
})), d == null || d.done(), d == null || d.complete({ usage: Z }), { urls: K };
|
|
503
|
+
} catch (v) {
|
|
504
|
+
throw d == null || d.error(v), v;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
function Y(t, e) {
|
|
510
|
+
const { description: n, inputSchema: r, agentCodeName: s, getSystemPrompt: i, buildUserPrompt: a, buildResult: l } = t, { writer: m, projectContext: u, model: p, abortSignal: h, streamOptions: P, postStream: A, onEnd: M } = e;
|
|
511
|
+
return I({
|
|
454
512
|
description: n,
|
|
455
|
-
inputSchema:
|
|
456
|
-
execute: async (
|
|
457
|
-
const
|
|
458
|
-
writer:
|
|
459
|
-
toolCallId:
|
|
460
|
-
commonData: { name:
|
|
513
|
+
inputSchema: r,
|
|
514
|
+
execute: async (E, { messages: D, toolCallId: G }) => {
|
|
515
|
+
const S = a(E, He(D), ze(D)), O = s, T = pe({
|
|
516
|
+
writer: m,
|
|
517
|
+
toolCallId: G,
|
|
518
|
+
commonData: { name: O, input: E }
|
|
461
519
|
});
|
|
462
|
-
|
|
520
|
+
T.start();
|
|
463
521
|
try {
|
|
464
|
-
const
|
|
465
|
-
model:
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
522
|
+
const g = {
|
|
523
|
+
model: p,
|
|
524
|
+
prompt: S,
|
|
525
|
+
abortSignal: h,
|
|
526
|
+
system: i(u)
|
|
527
|
+
}, _ = typeof P == "function" ? P({
|
|
528
|
+
options: g,
|
|
529
|
+
toolName: O,
|
|
530
|
+
projectContext: u,
|
|
531
|
+
input: E,
|
|
532
|
+
prompt: S,
|
|
533
|
+
getSystemPrompt: i
|
|
534
|
+
}) : P, { onFinish: d, ...v } = _ || {}, R = te({
|
|
535
|
+
...g,
|
|
536
|
+
prompt: S,
|
|
537
|
+
onFinish(y) {
|
|
538
|
+
M == null || M({ model: p, usage: y.usage, finishReason: y.finishReason, toolName: O }), d == null || d(y);
|
|
471
539
|
},
|
|
472
|
-
...
|
|
540
|
+
...v
|
|
473
541
|
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
542
|
+
let N = "";
|
|
543
|
+
for await (const y of R.textStream)
|
|
544
|
+
N += y, T.update(y);
|
|
545
|
+
await (A == null ? void 0 : A({
|
|
546
|
+
content: N,
|
|
547
|
+
statusWriter: T,
|
|
548
|
+
toolName: O,
|
|
549
|
+
projectContext: u,
|
|
550
|
+
input: E
|
|
551
|
+
})), T.done();
|
|
552
|
+
const { raw: V, ...f } = await R.usage;
|
|
553
|
+
return T.complete({ usage: f }), l(E);
|
|
554
|
+
} catch (g) {
|
|
555
|
+
throw T.error(g), g;
|
|
481
556
|
}
|
|
482
557
|
}
|
|
483
558
|
});
|
|
484
559
|
}
|
|
485
|
-
|
|
486
|
-
|
|
560
|
+
const Qe = I({
|
|
561
|
+
description: `Remove component from the page. This is faster than editing a parent via "${w.EDIT_COMPONENT_CODE}"`,
|
|
562
|
+
inputSchema: c.object({
|
|
563
|
+
componentId: c.string().describe("ID of the component to remove")
|
|
564
|
+
})
|
|
565
|
+
}), Xe = I({
|
|
566
|
+
description: `Move component to another position. This could be better/faster than "${w.EDIT_COMPONENT_CODE}"`,
|
|
567
|
+
inputSchema: c.object({
|
|
568
|
+
sourceId: c.string().describe("ID of the component to move"),
|
|
569
|
+
targetId: c.string().describe("ID of the parent component where to place the source one"),
|
|
570
|
+
targetIndex: c.number().describe("Index position inside the target component where to place the source one")
|
|
571
|
+
})
|
|
572
|
+
}), Ze = I({
|
|
573
|
+
description: "Get the full code of the page.",
|
|
574
|
+
inputSchema: c.object({
|
|
575
|
+
pageId: c.string().describe("The ID of the page to get the content from.")
|
|
576
|
+
})
|
|
577
|
+
}), Ke = I({
|
|
578
|
+
description: "Get the list of pages in the project. The result will be an array of page names and IDs.",
|
|
579
|
+
inputSchema: c.object({})
|
|
580
|
+
}), ge = c.object({
|
|
581
|
+
name: c.string().describe("Name of the new component"),
|
|
582
|
+
plan: c.string().describe(B),
|
|
583
|
+
componentId: c.string().describe("The ID of the target component"),
|
|
584
|
+
position: c.enum(["before", "beforeInside", "afterInside", "after"]).describe(
|
|
585
|
+
"Where to add the new component relative to the current target componentId. The `before` is before the component, `beforeInside` is before the first child of the target component, `afterInside` is after the last child of the target component, and `after` is after the component."
|
|
586
|
+
),
|
|
587
|
+
imageUrls: c.array(c.string()).describe(ce)
|
|
588
|
+
}), et = I({
|
|
589
|
+
description: `Add a new component to the current page. It requires to know the target componentId where to place it, if not provided, call "${$.GET_PAGE_CONTENT}" first to get the current page code and find the proper target component ID based on the request. For a '<some-el id="i19a7">', the ID would be "i19a7".`,
|
|
590
|
+
inputSchema: ge
|
|
591
|
+
});
|
|
592
|
+
function tt(t) {
|
|
593
|
+
return Y(
|
|
487
594
|
{
|
|
488
|
-
description:
|
|
489
|
-
inputSchema:
|
|
490
|
-
agentCodeName:
|
|
491
|
-
getSystemPrompt:
|
|
492
|
-
buildUserPrompt: (
|
|
595
|
+
description: et.description,
|
|
596
|
+
inputSchema: ge,
|
|
597
|
+
agentCodeName: w.ADD_COMPONENT_CODE,
|
|
598
|
+
getSystemPrompt: Re,
|
|
599
|
+
buildUserPrompt: (e, n) => [
|
|
493
600
|
n,
|
|
494
601
|
{
|
|
495
602
|
role: "assistant",
|
|
496
|
-
content:
|
|
497
|
-
|
|
498
|
-
|
|
603
|
+
content: J(
|
|
604
|
+
e.name && `
|
|
605
|
+
Component Name: ${e.name}`,
|
|
606
|
+
e.componentId && `
|
|
607
|
+
Target Component ID: ${e.componentId}`,
|
|
608
|
+
e.position && `
|
|
609
|
+
Target position: ${e.position}`,
|
|
610
|
+
e.plan && `
|
|
611
|
+
Plan: ${e.plan}`
|
|
612
|
+
)
|
|
499
613
|
}
|
|
500
614
|
],
|
|
501
|
-
buildResult: (
|
|
615
|
+
buildResult: (e) => ({ newComponentName: e.name })
|
|
502
616
|
},
|
|
503
|
-
|
|
617
|
+
t
|
|
504
618
|
);
|
|
505
619
|
}
|
|
506
|
-
const
|
|
507
|
-
plan:
|
|
508
|
-
imageUrls:
|
|
509
|
-
}),
|
|
620
|
+
const fe = c.object({
|
|
621
|
+
plan: c.string().describe(B),
|
|
622
|
+
imageUrls: c.array(c.string()).describe(ce)
|
|
623
|
+
}), nt = I({
|
|
510
624
|
description: "Edit components in the page. Provide additional instructions if necessary. The full page content will already be provided to the dev agent.",
|
|
511
|
-
inputSchema:
|
|
625
|
+
inputSchema: fe
|
|
512
626
|
});
|
|
513
|
-
function
|
|
514
|
-
return
|
|
627
|
+
function st(t) {
|
|
628
|
+
return Y(
|
|
515
629
|
{
|
|
516
|
-
description:
|
|
517
|
-
inputSchema:
|
|
518
|
-
agentCodeName:
|
|
519
|
-
getSystemPrompt:
|
|
520
|
-
buildUserPrompt: (
|
|
630
|
+
description: nt.description,
|
|
631
|
+
inputSchema: fe,
|
|
632
|
+
agentCodeName: w.EDIT_COMPONENT_CODE,
|
|
633
|
+
getSystemPrompt: Le,
|
|
634
|
+
buildUserPrompt: (e, n) => [
|
|
521
635
|
n,
|
|
522
636
|
{
|
|
523
637
|
role: "assistant",
|
|
524
|
-
content:
|
|
525
|
-
|
|
638
|
+
content: J(
|
|
639
|
+
e.plan && `
|
|
640
|
+
Plan: ${e.plan}`,
|
|
641
|
+
!!e.imageUrls.length && `
|
|
642
|
+
Image refs: ${e.imageUrls.join(", ")}`
|
|
643
|
+
)
|
|
526
644
|
}
|
|
527
645
|
],
|
|
528
646
|
buildResult: () => ({ success: !0 })
|
|
529
647
|
},
|
|
530
|
-
|
|
648
|
+
t
|
|
531
649
|
);
|
|
532
650
|
}
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}), se = f({
|
|
539
|
-
description: `Move component to another position. This could be better/faster then "${c.EDIT_COMPONENT}"`,
|
|
540
|
-
inputSchema: r.object({
|
|
541
|
-
sourceId: r.string().describe("ID of the component to move"),
|
|
542
|
-
targetId: r.string().describe("ID of the parent component where to place the source one"),
|
|
543
|
-
targetIndex: r.number().describe("Index position inside the target component where to place the source one")
|
|
544
|
-
})
|
|
545
|
-
}), re = f({
|
|
546
|
-
description: "Get the full code of the page.",
|
|
547
|
-
inputSchema: r.object({
|
|
548
|
-
pageId: r.string().describe("The ID of the page to get the content from.")
|
|
549
|
-
})
|
|
550
|
-
}), We = f({
|
|
551
|
-
description: "Get the list of pages in the project. The result will be an array of page names and IDs.",
|
|
552
|
-
inputSchema: r.object({})
|
|
553
|
-
}), Ze = f({
|
|
554
|
-
description: 'Fetch the HTML content of a given website URL and imports it into the editor. Use this when a user provides a URL and asks to import or pull in their site. IMPORTANT: Be precise about what was actually imported vs. what was just discovered. This tool only imports the main page content. Any subpages listed in tool results are just links found on that page - they are NOT scraped or imported. Always clarify to users that only the main page was imported and that subpages would need to be scraped individually if they want them imported too. Never claim that subpages were "imported" or "scraped" when they were only detected as links. List all subpages found in the tool results, no truncating.',
|
|
555
|
-
inputSchema: r.object({
|
|
556
|
-
url: r.string().describe("The full URL of the website to fetch (e.g., https://www.example.com/)."),
|
|
557
|
-
name: r.string().describe("The name of the page to be created in the project for this imported website.")
|
|
558
|
-
})
|
|
559
|
-
}), ae = r.object({
|
|
560
|
-
name: r.string().describe("Name of the new page"),
|
|
561
|
-
plan: r.string().describe(j),
|
|
562
|
-
imageUrls: r.array(r.string()).describe(R)
|
|
563
|
-
}), ie = f({
|
|
651
|
+
const he = c.object({
|
|
652
|
+
name: c.string().describe("Name of the new page"),
|
|
653
|
+
plan: c.string().describe(B),
|
|
654
|
+
imageUrls: c.array(c.string()).describe(ce)
|
|
655
|
+
}), ot = I({
|
|
564
656
|
description: "Creates a new page in the project with the full content.",
|
|
565
|
-
inputSchema:
|
|
657
|
+
inputSchema: he
|
|
566
658
|
});
|
|
567
|
-
function
|
|
568
|
-
return
|
|
659
|
+
function rt(t) {
|
|
660
|
+
return Y(
|
|
569
661
|
{
|
|
570
|
-
description:
|
|
571
|
-
inputSchema:
|
|
572
|
-
agentCodeName:
|
|
573
|
-
getSystemPrompt:
|
|
574
|
-
buildUserPrompt: (
|
|
662
|
+
description: ot.description,
|
|
663
|
+
inputSchema: he,
|
|
664
|
+
agentCodeName: w.ADD_PAGE_CODE,
|
|
665
|
+
getSystemPrompt: Me,
|
|
666
|
+
buildUserPrompt: (e, n) => [
|
|
575
667
|
n,
|
|
576
668
|
{
|
|
577
669
|
role: "assistant",
|
|
578
|
-
content:
|
|
579
|
-
|
|
580
|
-
|
|
670
|
+
content: J(
|
|
671
|
+
e.name && `
|
|
672
|
+
Page Name: ${e.name}`,
|
|
673
|
+
!!e.imageUrls.length && `
|
|
674
|
+
Image refs: ${e.imageUrls.join(", ")}`,
|
|
675
|
+
e.plan && `
|
|
676
|
+
Plan: ${e.plan}`
|
|
677
|
+
)
|
|
581
678
|
}
|
|
582
679
|
],
|
|
583
|
-
buildResult: (
|
|
680
|
+
buildResult: (e) => ({ createdPage: e.name })
|
|
584
681
|
},
|
|
585
|
-
|
|
682
|
+
t
|
|
586
683
|
);
|
|
587
684
|
}
|
|
588
|
-
const
|
|
589
|
-
name:
|
|
590
|
-
plan:
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
inputSchema: le
|
|
685
|
+
const Ee = c.object({
|
|
686
|
+
name: c.string().describe("Name of the new page"),
|
|
687
|
+
plan: c.string().describe(B)
|
|
688
|
+
}), at = I({
|
|
689
|
+
description: `Create a page in empty project with content based on a plan. IMPORTANT: This should be called only when ${C.IS_PROJECT_EMPTY} is true.`,
|
|
690
|
+
inputSchema: Ee
|
|
595
691
|
});
|
|
596
|
-
function
|
|
597
|
-
return
|
|
692
|
+
function it(t) {
|
|
693
|
+
return Y(
|
|
598
694
|
{
|
|
599
|
-
description:
|
|
600
|
-
inputSchema:
|
|
601
|
-
agentCodeName:
|
|
602
|
-
getSystemPrompt:
|
|
603
|
-
buildUserPrompt: (
|
|
695
|
+
description: at.description,
|
|
696
|
+
inputSchema: Ee,
|
|
697
|
+
agentCodeName: w.ADD_PROJECT_PAGE_CODE,
|
|
698
|
+
getSystemPrompt: Ne,
|
|
699
|
+
buildUserPrompt: (e, n) => [
|
|
604
700
|
n,
|
|
605
701
|
{
|
|
606
702
|
role: "assistant",
|
|
607
|
-
content:
|
|
608
|
-
Page Name: ${
|
|
609
|
-
Plan: ${
|
|
703
|
+
content: J(e.name && `
|
|
704
|
+
Page Name: ${e.name}`, e.plan && `
|
|
705
|
+
Plan: ${e.plan}`)
|
|
610
706
|
}
|
|
611
707
|
],
|
|
612
|
-
buildResult: (
|
|
708
|
+
buildResult: (e) => ({ createdPage: e.name })
|
|
613
709
|
},
|
|
614
|
-
|
|
710
|
+
t
|
|
615
711
|
);
|
|
616
712
|
}
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
Create a new page by importing a custom HTML.
|
|
623
|
-
- ${g.PAGE_SETTINGS}
|
|
624
|
-
Show and edit current page settings (title, slug and other common HTML head tags).
|
|
625
|
-
- ${g.PREVIEW}
|
|
626
|
-
Preview the current page in a fullscreen panel. The preview runs also all custom scripts in page.
|
|
627
|
-
- ${g.PUBLISH}
|
|
628
|
-
Publish project online. Here it's possible to see if/where the project is published and customize the domain.`,
|
|
629
|
-
inputSchema: r.object({
|
|
630
|
-
panelId: r.enum([
|
|
631
|
-
g.EDIT_EXPORT_CODE,
|
|
632
|
-
g.PUBLISH,
|
|
633
|
-
g.PAGE_SETTINGS,
|
|
634
|
-
g.IMPORT_HTML,
|
|
635
|
-
g.PREVIEW
|
|
636
|
-
]).describe("Panel ID to open")
|
|
637
|
-
})
|
|
638
|
-
}), Fe = {
|
|
639
|
-
[c.ADD_NEW_PROJECT_PAGE]: ce
|
|
640
|
-
// [AiChatToolName.FETCH_WEBSITE]: toolFetchWebsite
|
|
641
|
-
}, Ve = {
|
|
642
|
-
[c.ADD_NEW_PAGE]: ie,
|
|
643
|
-
[c.ADD_NEW_COMPONENT]: te,
|
|
644
|
-
[c.REMOVE_COMPONENT]: oe,
|
|
645
|
-
[c.MOVE_COMPONENT]: se,
|
|
646
|
-
[c.EDIT_COMPONENT]: B,
|
|
647
|
-
[c.GET_PAGE_CONTENT]: re,
|
|
648
|
-
[c.LIST_PAGES]: We
|
|
649
|
-
// [AiChatToolName.SHOW_PANEL]: toolShowPanel
|
|
650
|
-
// [AiChatToolName.FETCH_WEBSITE]: toolFetchWebsite
|
|
651
|
-
}, Be = {
|
|
652
|
-
[c.ADD_NEW_COMPONENT]: te,
|
|
653
|
-
[c.EDIT_COMPONENT]: B,
|
|
654
|
-
[c.REMOVE_COMPONENT]: oe,
|
|
655
|
-
[c.MOVE_COMPONENT]: se,
|
|
656
|
-
[c.GET_PAGE_CONTENT]: re
|
|
713
|
+
const x = {
|
|
714
|
+
[b.SHOW_CODE]: "Open the code panel to review and export current project code.",
|
|
715
|
+
[b.IMPORT_CODE]: "Open the import code panel to import custom code into the current project.",
|
|
716
|
+
[b.PAGE_SETTINGS]: "Open current page settings to edit title, slug, and other common HTML head tags.",
|
|
717
|
+
[b.PREVIEW]: "Open fullscreen preview mode to see the current page rendered."
|
|
657
718
|
};
|
|
658
|
-
function
|
|
659
|
-
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
719
|
+
function ct({ isEmail: t } = {}) {
|
|
720
|
+
const e = {
|
|
721
|
+
[b.SHOW_CODE]: { description: x[b.SHOW_CODE] },
|
|
722
|
+
[b.IMPORT_CODE]: { description: x[b.IMPORT_CODE] },
|
|
723
|
+
[b.PREVIEW]: { description: x[b.PREVIEW] }
|
|
724
|
+
};
|
|
725
|
+
return t || (e[b.PAGE_SETTINGS] = {
|
|
726
|
+
description: x[b.PAGE_SETTINGS]
|
|
727
|
+
}), e;
|
|
728
|
+
}
|
|
729
|
+
function lt(t = {}) {
|
|
730
|
+
const { projectContext: e, skipDefault: n, commands: r = {} } = t, s = new Map(
|
|
731
|
+
Object.entries(n ? {} : ct(e))
|
|
732
|
+
);
|
|
733
|
+
return Object.entries(r).forEach(([i, a]) => {
|
|
734
|
+
var p;
|
|
735
|
+
if (!a) return;
|
|
736
|
+
const l = i, m = (p = a.description) == null ? void 0 : p.trim();
|
|
737
|
+
if (s.get(l) && !m) {
|
|
738
|
+
s.delete(l);
|
|
739
|
+
return;
|
|
678
740
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
741
|
+
m && s.set(l, { description: m });
|
|
742
|
+
}), s;
|
|
743
|
+
}
|
|
744
|
+
function dt(t = {}) {
|
|
745
|
+
const e = lt(t), n = Array.from(e.keys());
|
|
746
|
+
if (!n.length)
|
|
747
|
+
throw new Error("`createCommandTool` requires at least one command");
|
|
748
|
+
const r = n, s = `Run one of the available commands. Below the list with commandId and description:
|
|
749
|
+
` + Array.from(e.entries()).map(([i, a]) => `- ${i}
|
|
750
|
+
${a.description}`).join(`
|
|
751
|
+
`);
|
|
752
|
+
return I({
|
|
753
|
+
description: s,
|
|
754
|
+
inputSchema: c.object({
|
|
755
|
+
commandId: c.enum(r).describe("Command ID to run")
|
|
756
|
+
})
|
|
757
|
+
});
|
|
687
758
|
}
|
|
688
|
-
|
|
759
|
+
function mt(t) {
|
|
760
|
+
const { writer: e, agentCode: n, abortSignal: r, projectContext: s, onEnd: i } = t, { model: a, streamOptions: l, postStream: m } = n ?? {}, u = a || t.chatModel, p = {
|
|
761
|
+
writer: e,
|
|
762
|
+
projectContext: s,
|
|
763
|
+
model: u,
|
|
764
|
+
abortSignal: r,
|
|
765
|
+
streamOptions: l,
|
|
766
|
+
postStream: m,
|
|
767
|
+
onEnd: i
|
|
768
|
+
}, h = {
|
|
769
|
+
[$.REMOVE_COMPONENT]: Qe,
|
|
770
|
+
[$.MOVE_COMPONENT]: Xe,
|
|
771
|
+
[$.GET_PAGE_CONTENT]: Ze,
|
|
772
|
+
[w.ADD_PROJECT_PAGE_CODE]: it(p),
|
|
773
|
+
[w.ADD_COMPONENT_CODE]: tt(p),
|
|
774
|
+
[w.EDIT_COMPONENT_CODE]: st(p)
|
|
775
|
+
};
|
|
776
|
+
return s != null && s.isEmail || (h[$.LIST_PAGES] = Ke, h[w.ADD_PAGE_CODE] = rt(p)), h;
|
|
777
|
+
}
|
|
778
|
+
async function Et(t) {
|
|
689
779
|
const {
|
|
690
|
-
model:
|
|
780
|
+
model: e,
|
|
691
781
|
systemPrompt: n,
|
|
692
|
-
messages:
|
|
782
|
+
messages: r,
|
|
693
783
|
projectContext: s,
|
|
694
|
-
tools:
|
|
695
|
-
toolChoice:
|
|
784
|
+
tools: i,
|
|
785
|
+
toolChoice: a,
|
|
696
786
|
providerOptions: l,
|
|
697
|
-
streamOptions:
|
|
698
|
-
responseOptions:
|
|
699
|
-
abortSignal:
|
|
700
|
-
onEnd:
|
|
701
|
-
getMessageMetadata:
|
|
702
|
-
pruneMessages:
|
|
703
|
-
} =
|
|
704
|
-
if (!
|
|
787
|
+
streamOptions: m,
|
|
788
|
+
responseOptions: u,
|
|
789
|
+
abortSignal: p,
|
|
790
|
+
onEnd: h,
|
|
791
|
+
getMessageMetadata: P,
|
|
792
|
+
pruneMessages: A = !0
|
|
793
|
+
} = t;
|
|
794
|
+
if (!e) throw new Error("`model` is required to create a stream response");
|
|
705
795
|
if (!s) throw new Error("`projectContext` is required to create a stream response");
|
|
706
|
-
const
|
|
707
|
-
messages:
|
|
796
|
+
const M = ut(r), E = await Oe(M), D = A ? we({
|
|
797
|
+
messages: E,
|
|
708
798
|
reasoning: "before-last-message",
|
|
709
799
|
toolCalls: "before-last-2-messages",
|
|
710
800
|
emptyMessages: "remove"
|
|
711
|
-
}) :
|
|
712
|
-
async execute({ writer:
|
|
713
|
-
const
|
|
714
|
-
writer:
|
|
715
|
-
defaultTools:
|
|
716
|
-
abortSignal:
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
801
|
+
}) : E, G = Ie({
|
|
802
|
+
async execute({ writer: S }) {
|
|
803
|
+
const O = mt({ ...t, writer: S, chatModel: e }), T = (typeof i == "function" ? i({
|
|
804
|
+
writer: S,
|
|
805
|
+
defaultTools: O,
|
|
806
|
+
abortSignal: p,
|
|
807
|
+
createCommandTool: (f) => dt({ ...f, projectContext: s }),
|
|
808
|
+
createToolStatusWriter: (f) => Fe({ writer: S, ...f })
|
|
809
|
+
}) : i) ?? O, g = ve(s), _ = typeof n == "string" ? n : [(n == null ? void 0 : n.preamble) || "", g, (n == null ? void 0 : n.postamble) || ""].filter(Boolean).join(`
|
|
810
|
+
`), { onFinish: d, ...v } = m ?? {}, R = te({
|
|
811
|
+
model: e,
|
|
812
|
+
messages: D,
|
|
813
|
+
tools: T,
|
|
814
|
+
toolChoice: a,
|
|
815
|
+
system: _ || g,
|
|
725
816
|
providerOptions: l,
|
|
726
|
-
abortSignal:
|
|
727
|
-
onFinish(
|
|
728
|
-
|
|
817
|
+
abortSignal: p,
|
|
818
|
+
onFinish(f) {
|
|
819
|
+
h == null || h({ model: e, usage: f.usage, finishReason: f.finishReason }), d == null || d(f);
|
|
729
820
|
},
|
|
730
|
-
...
|
|
731
|
-
}), { messageMetadata:
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
originalMessages:
|
|
821
|
+
...v
|
|
822
|
+
}), { messageMetadata: N, ...V } = u ?? {};
|
|
823
|
+
S.merge(
|
|
824
|
+
R.toUIMessageStream({
|
|
825
|
+
originalMessages: r,
|
|
735
826
|
sendReasoning: !0,
|
|
736
827
|
sendSources: !0,
|
|
737
|
-
messageMetadata(
|
|
738
|
-
const
|
|
739
|
-
return
|
|
828
|
+
messageMetadata(f) {
|
|
829
|
+
const y = P == null ? void 0 : P({ ...f, model: e });
|
|
830
|
+
return y || (N == null ? void 0 : N(f));
|
|
740
831
|
},
|
|
741
|
-
...
|
|
832
|
+
...V
|
|
742
833
|
})
|
|
743
834
|
);
|
|
744
835
|
}
|
|
745
836
|
});
|
|
746
|
-
return
|
|
747
|
-
consumeSseStream:
|
|
748
|
-
stream:
|
|
837
|
+
return Te({
|
|
838
|
+
consumeSseStream: De,
|
|
839
|
+
stream: G
|
|
749
840
|
});
|
|
750
841
|
}
|
|
751
|
-
function
|
|
752
|
-
const
|
|
753
|
-
return
|
|
754
|
-
if (n.role !== "user" || n.parts.some((
|
|
755
|
-
const s = n.parts.filter((
|
|
842
|
+
function ut(t) {
|
|
843
|
+
const e = "file-refs";
|
|
844
|
+
return t.map((n) => {
|
|
845
|
+
if (n.role !== "user" || n.parts.some((a) => a.type === "text" && a.text.includes(`<${e}>`))) return n;
|
|
846
|
+
const s = n.parts.filter((a) => a.type === "file" && a.url.trim().startsWith("http")).map((a) => a.url.trim());
|
|
756
847
|
if (s.length === 0) return n;
|
|
757
|
-
const
|
|
758
|
-
${s.map((
|
|
848
|
+
const i = `<${e}>
|
|
849
|
+
${s.map((a) => `- ${a}`).join(`
|
|
759
850
|
`)}
|
|
760
|
-
</${
|
|
851
|
+
</${e}>`;
|
|
761
852
|
return {
|
|
762
853
|
...n,
|
|
763
|
-
parts: [...n.parts, { type: "text", text:
|
|
854
|
+
parts: [...n.parts, { type: "text", text: i }]
|
|
764
855
|
};
|
|
765
856
|
});
|
|
766
857
|
}
|
|
767
|
-
async function
|
|
858
|
+
async function bt(t) {
|
|
768
859
|
const {
|
|
769
|
-
model:
|
|
860
|
+
model: e,
|
|
770
861
|
system: n,
|
|
771
|
-
prompt:
|
|
862
|
+
prompt: r,
|
|
772
863
|
tools: s,
|
|
773
|
-
toolChoice:
|
|
774
|
-
providerOptions:
|
|
864
|
+
toolChoice: i,
|
|
865
|
+
providerOptions: a,
|
|
775
866
|
abortSignal: l,
|
|
776
|
-
onFinish:
|
|
777
|
-
onAbort:
|
|
778
|
-
onError:
|
|
779
|
-
streamOptions:
|
|
780
|
-
} =
|
|
781
|
-
return
|
|
782
|
-
model:
|
|
867
|
+
onFinish: m,
|
|
868
|
+
onAbort: u,
|
|
869
|
+
onError: p,
|
|
870
|
+
streamOptions: h
|
|
871
|
+
} = t;
|
|
872
|
+
return te({
|
|
873
|
+
model: e,
|
|
783
874
|
system: n,
|
|
784
|
-
prompt:
|
|
875
|
+
prompt: r,
|
|
785
876
|
tools: s,
|
|
786
|
-
toolChoice:
|
|
787
|
-
providerOptions:
|
|
877
|
+
toolChoice: i,
|
|
878
|
+
providerOptions: a,
|
|
788
879
|
abortSignal: l,
|
|
789
|
-
onFinish:
|
|
790
|
-
onAbort:
|
|
791
|
-
onError:
|
|
792
|
-
...
|
|
880
|
+
onFinish: m,
|
|
881
|
+
onAbort: u,
|
|
882
|
+
onError: p,
|
|
883
|
+
...h
|
|
793
884
|
}).toTextStreamResponse();
|
|
794
885
|
}
|
|
795
|
-
function
|
|
796
|
-
const [
|
|
797
|
-
if (!
|
|
798
|
-
throw new Error(`Invalid model string: "${
|
|
886
|
+
function pt(t) {
|
|
887
|
+
const [e, ...n] = t.split("/"), r = n.join("/");
|
|
888
|
+
if (!e || !r)
|
|
889
|
+
throw new Error(`Invalid model string: "${t}". Expected format: "provider/model-name"`);
|
|
799
890
|
return {
|
|
800
|
-
provider:
|
|
801
|
-
modelName:
|
|
891
|
+
provider: e,
|
|
892
|
+
modelName: r
|
|
802
893
|
};
|
|
803
894
|
}
|
|
804
|
-
async function
|
|
805
|
-
const { model:
|
|
806
|
-
if (!
|
|
807
|
-
throw new Error(
|
|
808
|
-
return
|
|
895
|
+
async function F(t) {
|
|
896
|
+
const { model: e, options: n, error: r, loader: s } = t, i = await s();
|
|
897
|
+
if (!i)
|
|
898
|
+
throw new Error(r);
|
|
899
|
+
return i(n)(e);
|
|
809
900
|
}
|
|
810
|
-
async function
|
|
811
|
-
const { provider: n, modelName:
|
|
901
|
+
async function yt(t, e = {}) {
|
|
902
|
+
const { provider: n, modelName: r } = pt(t);
|
|
812
903
|
switch (n) {
|
|
813
904
|
case "openai":
|
|
814
|
-
return
|
|
905
|
+
return F({
|
|
815
906
|
// @ts-ignore - Optional peer dependency, may not be installed
|
|
816
907
|
loader: async () => (await import("@ai-sdk/openai")).createOpenAI,
|
|
817
|
-
model:
|
|
818
|
-
options:
|
|
908
|
+
model: r,
|
|
909
|
+
options: e,
|
|
819
910
|
error: "OpenAI provider not installed. Install @ai-sdk/openai to use OpenAI models."
|
|
820
911
|
});
|
|
821
912
|
case "anthropic":
|
|
822
|
-
return
|
|
913
|
+
return F({
|
|
823
914
|
// @ts-ignore - Optional peer dependency, may not be installed
|
|
824
915
|
loader: async () => (await import("@ai-sdk/anthropic")).createAnthropic,
|
|
825
|
-
model:
|
|
826
|
-
options:
|
|
916
|
+
model: r,
|
|
917
|
+
options: e,
|
|
827
918
|
error: "Anthropic provider not installed. Install @ai-sdk/anthropic to use Anthropic models."
|
|
828
919
|
});
|
|
829
920
|
case "google":
|
|
830
|
-
return
|
|
921
|
+
return F({
|
|
831
922
|
// @ts-ignore - Optional peer dependency, may not be installed
|
|
832
923
|
loader: async () => (await import("@ai-sdk/google")).createGoogleGenerativeAI,
|
|
833
|
-
model:
|
|
834
|
-
options:
|
|
924
|
+
model: r,
|
|
925
|
+
options: e,
|
|
835
926
|
error: "Google provider not installed. Install @ai-sdk/google to use Google models."
|
|
836
927
|
});
|
|
837
928
|
case "azure":
|
|
838
|
-
return
|
|
929
|
+
return F({
|
|
839
930
|
// @ts-ignore - Optional peer dependency, may not be installed
|
|
840
931
|
loader: async () => (await import("@ai-sdk/azure")).createAzure,
|
|
841
|
-
model:
|
|
842
|
-
options:
|
|
932
|
+
model: r,
|
|
933
|
+
options: e,
|
|
843
934
|
error: "Azure provider not installed. Install @ai-sdk/azure to use Azure models."
|
|
844
935
|
});
|
|
845
936
|
default:
|
|
@@ -849,28 +940,27 @@ async function ot(e, t = {}) {
|
|
|
849
940
|
}
|
|
850
941
|
}
|
|
851
942
|
export {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
Ve as toolsWeb
|
|
943
|
+
C as ChatPromptKeys,
|
|
944
|
+
mt as buildDefaultTools,
|
|
945
|
+
dt as createCommandTool,
|
|
946
|
+
yt as createModel,
|
|
947
|
+
Et as createStreamResponse,
|
|
948
|
+
bt as createStreamTextResponse,
|
|
949
|
+
I as createTool,
|
|
950
|
+
tt as createToolAddComponent,
|
|
951
|
+
rt as createToolAddPage,
|
|
952
|
+
it as createToolAddProjectPage,
|
|
953
|
+
st as createToolEditComponent,
|
|
954
|
+
ht as createToolGenerateImage,
|
|
955
|
+
Fe as createToolStatusWriter,
|
|
956
|
+
x as defaultCommandDescriptions,
|
|
957
|
+
Je as stripGeneratedWrapper,
|
|
958
|
+
et as toolAddComponent,
|
|
959
|
+
ot as toolAddNewPage,
|
|
960
|
+
at as toolAddNewProjectPage,
|
|
961
|
+
nt as toolEditComponent,
|
|
962
|
+
Ze as toolGetPageContent,
|
|
963
|
+
Ke as toolListPages,
|
|
964
|
+
Xe as toolMoveComponent,
|
|
965
|
+
Qe as toolRemoveComponent
|
|
876
966
|
};
|