owndesign 0.1.3 → 0.1.4
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/server/index.js +453 -584
- package/dist/web/assets/{angular-html-jsvfn4Rt.js → angular-html-jQS2hAnh.js} +1 -1
- package/dist/web/assets/{angular-ts-DJPGWFWG.js → angular-ts-DXCIRK8J.js} +1 -1
- package/dist/web/assets/{apl-CrzMWZIQ.js → apl-uLTVM0SV.js} +1 -1
- package/dist/web/assets/{arc-Bn4NjwpQ.js → arc-C6K-4bbh.js} +1 -1
- package/dist/web/assets/architecture-7EHR7CIX-BUVdwEbF.js +1 -0
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-CHuzKteg.js → architectureDiagram-3BPJPVTR-Nra6nVfI.js} +1 -1
- package/dist/web/assets/{astro-B7XSlDgT.js → astro-QydxzDKL.js} +1 -1
- package/dist/web/assets/{blade-FbLBnnn0.js → blade-g81cs1jW.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-D-s6XCnt.js → blockDiagram-GPEHLZMM-Ei76DVKM.js} +1 -1
- package/dist/web/assets/{c-BXLwv45V.js → c-CV8Fejge.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-suyA814q.js → c4Diagram-AAUBKEIU-oIOIFFc0.js} +1 -1
- package/dist/web/assets/channel-DC7LeJJp.js +1 -0
- package/dist/web/assets/{chunk-2J33WTMH-B1BjDPc8.js → chunk-2J33WTMH-BokYjerh.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-CaKhvcR-.js → chunk-4BX2VUAB-CW80cEPP.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-rDi25oNw.js → chunk-55IACEB6-cqUqIGMR.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-DbTxAzFr.js → chunk-727SXJPM-en_nLLtx.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-Cx54fayY.js → chunk-AQP2D5EJ-E7hL18Vm.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-D0cOuWPI.js → chunk-FMBD7UC4-D2Mn_3Ze.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-DE9Fzr-c.js → chunk-ND2GUHAM-BxpfbjDb.js} +1 -1
- package/dist/web/assets/chunk-QZHKN3VN-DTMt_eZs.js +1 -0
- package/dist/web/assets/classDiagram-4FO5ZUOK-jfKwbhh5.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-jfKwbhh5.js +1 -0
- package/dist/web/assets/{cobol-GYycObeh.js → cobol-CMtH7Q60.js} +1 -1
- package/dist/web/assets/{coffee-DpR39k3Z.js → coffee-Dd2oge0M.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-HMWRsi3j.js → cose-bilkent-S5V4N54A-DlIl_zlL.js} +1 -1
- package/dist/web/assets/{cpp-BVpb95O2.js → cpp-BxOkDHcj.js} +1 -1
- package/dist/web/assets/{crystal--BRTwmLk.js → crystal-CP-EFrvi.js} +1 -1
- package/dist/web/assets/{css-CtgfTqN7.js → css-56wYI_pE.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-BmP8Xfpr.js → dagre-BM42HDAG-DPLYcjid.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-CaOzrqeF.js → diagram-2AECGRRQ-BCMoYOQK.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-DTur4WjM.js → diagram-5GNKFQAL-CLKyT-zH.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-DPqtezbZ.js → diagram-KO2AKTUF-aunZGxvu.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-ChfIjJjB.js → diagram-LMA3HP47-BYp0cf90.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-mElCK9q8.js → diagram-OG6HWLK6-M3iTfH5g.js} +1 -1
- package/dist/web/assets/{edge-qTMbtksj.js → edge-DpKZbKMc.js} +1 -1
- package/dist/web/assets/{elixir-D3ulijxT.js → elixir-CzSMdKdn.js} +1 -1
- package/dist/web/assets/{elm-tsW4I1jV.js → elm-CPk9x22f.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-yRD3kuoC.js → erDiagram-TEJ5UH35-BX0VkvGe.js} +1 -1
- package/dist/web/assets/{erb-BA-HEniM.js → erb-TQAaZlNV.js} +1 -1
- package/dist/web/assets/eventmodeling-FCH6USID-CelVcBa9.js +1 -0
- package/dist/web/assets/{flowDiagram-I6XJVG4X-B6OtVWCG.js → flowDiagram-I6XJVG4X-Bvl7AO6M.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-BKQELgWf.js → ganttDiagram-6RSMTGT7-Bcc6aiz3.js} +1 -1
- package/dist/web/assets/{git-rebase-BaeXTags.js → git-rebase-C36akiNM.js} +1 -1
- package/dist/web/assets/gitGraph-WXDBUCRP-D9mlI27B.js +1 -0
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DLFySfm6.js → gitGraphDiagram-PVQCEYII-DwIrICP0.js} +1 -1
- package/dist/web/assets/{glimmer-js-D99CurU1.js → glimmer-js-ZijKRLl6.js} +1 -1
- package/dist/web/assets/{glimmer-ts-DiXlCbsk.js → glimmer-ts-DngRkkD1.js} +1 -1
- package/dist/web/assets/{glsl-BesQQ3D3.js → glsl-BaB0p3pF.js} +1 -1
- package/dist/web/assets/{graphql-WTzBw63J.js → graphql-Betoeq1K.js} +1 -1
- package/dist/web/assets/{hack-CgMBYqE_.js → hack-CE6PSHKG.js} +1 -1
- package/dist/web/assets/{haml-CVkZ8xGr.js → haml-SuyMrzSD.js} +1 -1
- package/dist/web/assets/{handlebars-DEZhToSV.js → handlebars-JDrZp4fR.js} +1 -1
- package/dist/web/assets/{highlighted-body-OFNGDK62-C1vbmqaL.js → highlighted-body-OFNGDK62-CgC4ngzm.js} +1 -1
- package/dist/web/assets/{html-CZY9Keai.js → html-DC1Ltqmc.js} +1 -1
- package/dist/web/assets/{html-derivative-C6yFe2Kr.js → html-derivative-iG8t5u5_.js} +1 -1
- package/dist/web/assets/{http-B-YQYmoh.js → http-C40sH4NS.js} +1 -1
- package/dist/web/assets/{hurl-DwCR30Gk.js → hurl-CmUE8H3s.js} +1 -1
- package/dist/web/assets/index-Bz6PFGaR.js +977 -0
- package/dist/web/assets/info-J43DQDTF-DmWxkfWc.js +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-FbnwyL1q.js → infoDiagram-5YYISTIA-D92ErDLp.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DifZwUFe.js → ishikawaDiagram-YF4QCWOH-COfhdNCZ.js} +1 -1
- package/dist/web/assets/{java-DQDexwWI.js → java-Jk3c_AWT.js} +1 -1
- package/dist/web/assets/{javascript-m4oKbUOH.js → javascript-D7j9lLtB.js} +1 -1
- package/dist/web/assets/{jinja-bMd7FxcZ.js → jinja-KOP4LHnr.js} +1 -1
- package/dist/web/assets/{jison-Donet0uo.js → jison-CsByL99k.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-CEWe0m8S.js → journeyDiagram-JHISSGLW-BAaoSHcS.js} +1 -1
- package/dist/web/assets/{json-DvDVCJtO.js → json-bLUVjOwA.js} +1 -1
- package/dist/web/assets/{jsx-DqXV0M3u.js → jsx-B-ZJ5sYl.js} +1 -1
- package/dist/web/assets/{julia-BLIZFOZF.js → julia-DLZVVunR.js} +1 -1
- package/dist/web/assets/{just-CBmUd3mb.js → just-CTVFuTGe.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BP7cxrre.js → kanban-definition-UN3LZRKU-txA385kR.js} +1 -1
- package/dist/web/assets/{latex-Cy1xyr0T.js → latex-BQMKb74T.js} +1 -1
- package/dist/web/assets/{linear-CjIRJFVE.js → linear-D7ZS4umN.js} +1 -1
- package/dist/web/assets/{liquid-DOWkRs5J.js → liquid-CG92kJNU.js} +1 -1
- package/dist/web/assets/{lua-2D444Lxv.js → lua-BVSZYGx9.js} +1 -1
- package/dist/web/assets/{marko-B2Dmq5Yz.js → marko-DEmKFKi0.js} +1 -1
- package/dist/web/assets/{mdc-DEaLIxN0.js → mdc-Do8EO_lC.js} +1 -1
- package/dist/web/assets/mermaid-GHXKKRXX-L1cLS261.js +1 -0
- package/dist/web/assets/{mermaid-parser.core-Dmmi41d9.js → mermaid-parser.core-BaLOFMn_.js} +2 -2
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CdNWcprP.js → mindmap-definition-RKZ34NQL-D-yV4PLs.js} +1 -1
- package/dist/web/assets/{nginx-CeAvtuC8.js → nginx-BKSyUILj.js} +1 -1
- package/dist/web/assets/{nim-BqlmNno2.js → nim-DnJRnIIP.js} +1 -1
- package/dist/web/assets/packet-YPE3B663-CrP5sMYi.js +1 -0
- package/dist/web/assets/{perl-D7NeCsVf.js → perl-3bt2qR9m.js} +1 -1
- package/dist/web/assets/{php-D5zmfZnA.js → php-BzdDALOQ.js} +1 -1
- package/dist/web/assets/pie-LRSECV5Y-Di4KiVyS.js +1 -0
- package/dist/web/assets/{pieDiagram-4H26LBE5-DAmVxi-T.js → pieDiagram-4H26LBE5-Bd114I4X.js} +1 -1
- package/dist/web/assets/{pug-V7ao1GPA.js → pug-DdwUkMw4.js} +1 -1
- package/dist/web/assets/{qml-Bm2ZBf1J.js → qml-DP4is7YC.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DisJQ6k7.js → quadrantDiagram-W4KKPZXB-bREh_EBC.js} +1 -1
- package/dist/web/assets/{r-D97_-xYI.js → r-BF_jXTwW.js} +1 -1
- package/dist/web/assets/radar-GUYGQ44K-BWc_UrwT.js +1 -0
- package/dist/web/assets/{razor-DSkw2G0O.js → razor-3soncf9G.js} +1 -1
- package/dist/web/assets/{regexp-Bc_HmDkA.js → regexp-EYBuLXF9.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-BGeUfRNj.js → requirementDiagram-4Y6WPE33-VtNiXWaP.js} +1 -1
- package/dist/web/assets/{rst-HeE3bPLr.js → rst-C71o5usK.js} +1 -1
- package/dist/web/assets/{ruby-D1hbEP5U.js → ruby-w0pHTyII.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-DxkCaEDD.js → sankeyDiagram-5OEKKPKP-CPbj-Xb-.js} +1 -1
- package/dist/web/assets/{sas-B5odaEYk.js → sas-DXIh1KZ4.js} +1 -1
- package/dist/web/assets/{scss-DAOx_LcY.js → scss-C4aItG-0.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BjyW4Lrn.js → sequenceDiagram-3UESZ5HK-DwH_u_zz.js} +1 -1
- package/dist/web/assets/{shellscript-C12cH9Wq.js → shellscript-BV5fN4m0.js} +1 -1
- package/dist/web/assets/{shellsession-B9R0VJUT.js → shellsession-COL1kA2z.js} +1 -1
- package/dist/web/assets/{soy-Bw9Ab61t.js → soy-Ccpzfdcl.js} +1 -1
- package/dist/web/assets/{sql-BuNNSgJh.js → sql-DCE87e5l.js} +1 -1
- package/dist/web/assets/{stata-DKqDiYZE.js → stata-CEWTedB6.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-BULieDpc.js → stateDiagram-AJRCARHV-B3VdYVO-.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-C7wmfqKn.js +1 -0
- package/dist/web/assets/{surrealql-CmO_9B8u.js → surrealql-CUKNwDpQ.js} +1 -1
- package/dist/web/assets/{svelte-mVjE-waC.js → svelte-DONiSH1x.js} +1 -1
- package/dist/web/assets/{templ-C536sOWS.js → templ-B_johG2O.js} +1 -1
- package/dist/web/assets/{tex-noYEVnyG.js → tex-Dh316BCp.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-gCvdo5yW.js → timeline-definition-PNZ67QCA-Blixs7cX.js} +1 -1
- package/dist/web/assets/treeView-BLDUP644-DRpNUAD5.js +1 -0
- package/dist/web/assets/treemap-LRROVOQU-CRkuQjMq.js +1 -0
- package/dist/web/assets/{ts-tags-BHLoJadi.js → ts-tags-CWDOkWop.js} +1 -1
- package/dist/web/assets/{tsx-D0BqKins.js → tsx-STHGXrTg.js} +1 -1
- package/dist/web/assets/{twig-BazH_M3o.js → twig-DeYz4MvR.js} +1 -1
- package/dist/web/assets/{typescript-zAIgs1Bg.js → typescript-BkMW9mh2.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-_GmnWXrN.js → vennDiagram-CIIHVFJN-OUEEmD5m.js} +1 -1
- package/dist/web/assets/{vue-DiStCAGA.js → vue-BhG5XYAd.js} +1 -1
- package/dist/web/assets/{vue-html-BycBfJiP.js → vue-html-Cw0OXIMV.js} +1 -1
- package/dist/web/assets/{vue-vine-Bzt8hn7y.js → vue-vine-DxYQGujI.js} +1 -1
- package/dist/web/assets/wardley-L42UT6IY-AM6lsfHi.js +1 -0
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CQDeXjJA.js → wardleyDiagram-YWT4CUSO-CbSRnjwb.js} +1 -1
- package/dist/web/assets/{xml-DKXhkAsJ.js → xml-Co1Haim6.js} +1 -1
- package/dist/web/assets/{xsl-CNq-a0yX.js → xsl-Dyxp9ECK.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-ClV8rcpV.js → xychartDiagram-2RQKCTM6-PQFpoSrS.js} +1 -1
- package/dist/web/assets/{yaml-BdbHds_c.js → yaml-DfBwtMv_.js} +1 -1
- package/dist/web/favicon.ico +0 -0
- package/dist/web/index.html +1 -1
- package/package.json +2 -2
- package/dist/web/assets/architecture-7EHR7CIX-Dmcr3pOj.js +0 -1
- package/dist/web/assets/channel-lKa7V-Vy.js +0 -1
- package/dist/web/assets/chunk-QZHKN3VN-CLLRYgAk.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BGMCFaw3.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BGMCFaw3.js +0 -1
- package/dist/web/assets/eventmodeling-FCH6USID-1xLvS7Py.js +0 -1
- package/dist/web/assets/gitGraph-WXDBUCRP-DDLWLcGD.js +0 -1
- package/dist/web/assets/index-RGvTNHCk.js +0 -977
- package/dist/web/assets/info-J43DQDTF-qGIMNcUJ.js +0 -1
- package/dist/web/assets/mermaid-GHXKKRXX-CQXzNDpn.js +0 -1
- package/dist/web/assets/packet-YPE3B663-ChxpMni-.js +0 -1
- package/dist/web/assets/pie-LRSECV5Y-y5EjkD0h.js +0 -1
- package/dist/web/assets/radar-GUYGQ44K-Du-8nFyw.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-IQQ2dYr9.js +0 -1
- package/dist/web/assets/treeView-BLDUP644-D-0UN-Tb.js +0 -1
- package/dist/web/assets/treemap-LRROVOQU-CaUFuBcw.js +0 -1
- package/dist/web/assets/wardley-L42UT6IY-C-z6FcCV.js +0 -1
package/dist/server/index.js
CHANGED
|
@@ -48170,6 +48170,20 @@ function isLegacyMessage(message) {
|
|
|
48170
48170
|
return typeof message === "object" && message !== null && "content" in message && typeof message.content === "string" && "role" in message && (message.role === "assistant" || message.role === "user");
|
|
48171
48171
|
}
|
|
48172
48172
|
|
|
48173
|
+
// ../core/src/conversations/default-title.ts
|
|
48174
|
+
var FALLBACK_CONVERSATION_TITLE = "\u65B0\u5EFA\u4F1A\u8BDD";
|
|
48175
|
+
var DEFAULT_CONVERSATION_TITLES = {
|
|
48176
|
+
"en-US": "",
|
|
48177
|
+
"zh-CN": FALLBACK_CONVERSATION_TITLE
|
|
48178
|
+
};
|
|
48179
|
+
function getDefaultConversationTitle(language) {
|
|
48180
|
+
return DEFAULT_CONVERSATION_TITLES[language] || FALLBACK_CONVERSATION_TITLE;
|
|
48181
|
+
}
|
|
48182
|
+
function normalizeDefaultConversationTitle(title) {
|
|
48183
|
+
const trimmedTitle = title?.trim();
|
|
48184
|
+
return trimmedTitle || FALLBACK_CONVERSATION_TITLE;
|
|
48185
|
+
}
|
|
48186
|
+
|
|
48173
48187
|
// ../../node_modules/.pnpm/@ai-sdk+anthropic@3.0.81_zod@4.4.3/node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
48174
48188
|
var VERSION5 = true ? "3.0.81" : "0.0.0-test";
|
|
48175
48189
|
var anthropicErrorDataSchema = lazySchema(
|
|
@@ -56628,199 +56642,49 @@ function isMissingPathError(error51) {
|
|
|
56628
56642
|
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
56629
56643
|
}
|
|
56630
56644
|
|
|
56631
|
-
// ../core/src/
|
|
56632
|
-
|
|
56633
|
-
|
|
56634
|
-
|
|
56635
|
-
|
|
56636
|
-
|
|
56637
|
-
|
|
56638
|
-
additionalProperties: false
|
|
56645
|
+
// ../core/src/agent/tools/core.ts
|
|
56646
|
+
function createWorkspaceToolRegistry(definitions, context2) {
|
|
56647
|
+
const tools = {};
|
|
56648
|
+
const metadata = {};
|
|
56649
|
+
for (const definition of definitions) {
|
|
56650
|
+
if (tools[definition.name]) {
|
|
56651
|
+
throw new Error(`Project Workspace tool already registered: ${definition.name}`);
|
|
56639
56652
|
}
|
|
56640
|
-
|
|
56641
|
-
|
|
56642
|
-
|
|
56643
|
-
|
|
56644
|
-
|
|
56645
|
-
|
|
56646
|
-
|
|
56647
|
-
|
|
56648
|
-
|
|
56653
|
+
metadata[definition.name] = {
|
|
56654
|
+
parallelSafe: definition.parallelSafe
|
|
56655
|
+
};
|
|
56656
|
+
tools[definition.name] = tool({
|
|
56657
|
+
description: definition.description,
|
|
56658
|
+
inputSchema: definition.inputSchema,
|
|
56659
|
+
execute: async (input) => {
|
|
56660
|
+
const startedAt = performance.now();
|
|
56661
|
+
try {
|
|
56662
|
+
const parsedInput = definition.inputSchema.parse(input);
|
|
56663
|
+
definition.validate?.(parsedInput);
|
|
56664
|
+
const output = await definition.execute(parsedInput, context2);
|
|
56665
|
+
return {
|
|
56666
|
+
ok: true,
|
|
56667
|
+
output,
|
|
56668
|
+
wallTimeMs: elapsedWallTime(startedAt)
|
|
56669
|
+
};
|
|
56670
|
+
} catch (error51) {
|
|
56671
|
+
return {
|
|
56672
|
+
error: error51 instanceof Error ? error51.message : String(error51),
|
|
56673
|
+
ok: false,
|
|
56674
|
+
wallTimeMs: elapsedWallTime(startedAt)
|
|
56675
|
+
};
|
|
56649
56676
|
}
|
|
56650
|
-
},
|
|
56651
|
-
required: ["path"],
|
|
56652
|
-
additionalProperties: false
|
|
56653
|
-
}
|
|
56654
|
-
}
|
|
56655
|
-
};
|
|
56656
|
-
var FRONTEND_CAPABILITY_IDS = Object.keys(
|
|
56657
|
-
FRONTEND_CAPABILITIES
|
|
56658
|
-
);
|
|
56659
|
-
function isFrontendCapabilityId(value) {
|
|
56660
|
-
return typeof value === "string" && FRONTEND_CAPABILITY_IDS.includes(value);
|
|
56661
|
-
}
|
|
56662
|
-
function validateFrontendCapabilityPayload(capability, payload) {
|
|
56663
|
-
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
56664
|
-
throw new Error(`Frontend capability payload must be an object: ${capability}`);
|
|
56665
|
-
}
|
|
56666
|
-
if (capability === "preview.refresh") {
|
|
56667
|
-
if (Object.keys(payload).length > 0) {
|
|
56668
|
-
throw new Error("preview.refresh payload must be empty.");
|
|
56669
|
-
}
|
|
56670
|
-
return {};
|
|
56671
|
-
}
|
|
56672
|
-
if (!("path" in payload) || typeof payload.path !== "string" || !payload.path.trim()) {
|
|
56673
|
-
throw new Error("preview.switchHtml payload.path must be a non-empty string.");
|
|
56674
|
-
}
|
|
56675
|
-
return {
|
|
56676
|
-
path: payload.path
|
|
56677
|
-
};
|
|
56678
|
-
}
|
|
56679
|
-
function buildFrontendCapabilityPrompt() {
|
|
56680
|
-
return [
|
|
56681
|
-
"## Frontend Capabilities",
|
|
56682
|
-
"Use `callFrontendCapability` only to notify the browser UI after Project Workspace file changes are complete. It does not create, edit, or validate files.",
|
|
56683
|
-
"After successful previewable HTML changes, call exactly one preview capability before the final user-facing summary.",
|
|
56684
|
-
"Do not call a preview capability when no previewable HTML file changed or the file operation failed.",
|
|
56685
|
-
"Use the current user request to decide which capability is needed:",
|
|
56686
|
-
"- Use `preview.switchHtml` only when the Preview Pane should move to a different existing relative `.html` file inside the Project Workspace.",
|
|
56687
|
-
"- Use `preview.refresh` when the Preview Pane is already showing the correct page and only needs to reload changed HTML.",
|
|
56688
|
-
"Do not use workspace file tools to simulate preview switching or refreshing.",
|
|
56689
|
-
"Available capabilities:",
|
|
56690
|
-
...FRONTEND_CAPABILITY_IDS.map((capability) => {
|
|
56691
|
-
const schema = JSON.stringify(
|
|
56692
|
-
FRONTEND_CAPABILITIES[capability].payloadSchema
|
|
56693
|
-
);
|
|
56694
|
-
return `- ${capability}: ${FRONTEND_CAPABILITIES[capability].description} Payload schema: ${schema}`;
|
|
56695
|
-
})
|
|
56696
|
-
].join("\n");
|
|
56697
|
-
}
|
|
56698
|
-
|
|
56699
|
-
// ../core/src/realtime/frontend-command-bus.ts
|
|
56700
|
-
var KEEPALIVE_INTERVAL_MS = 15e3;
|
|
56701
|
-
var FrontendCommandBus = class {
|
|
56702
|
-
connections = /* @__PURE__ */ new Map();
|
|
56703
|
-
registerConnection({
|
|
56704
|
-
frontendTabId,
|
|
56705
|
-
projectId,
|
|
56706
|
-
signal
|
|
56707
|
-
}) {
|
|
56708
|
-
const key = buildConnectionKey(projectId, frontendTabId);
|
|
56709
|
-
const encoder = new TextEncoder();
|
|
56710
|
-
let connection;
|
|
56711
|
-
const stream2 = new ReadableStream({
|
|
56712
|
-
start: (controller) => {
|
|
56713
|
-
this.unregisterConnection(projectId, frontendTabId);
|
|
56714
|
-
connection = {
|
|
56715
|
-
controller,
|
|
56716
|
-
encoder,
|
|
56717
|
-
keepaliveTimer: setInterval(() => {
|
|
56718
|
-
enqueueSseComment(controller, encoder, "keepalive");
|
|
56719
|
-
}, KEEPALIVE_INTERVAL_MS)
|
|
56720
|
-
};
|
|
56721
|
-
connection.keepaliveTimer.unref?.();
|
|
56722
|
-
this.connections.set(key, connection);
|
|
56723
|
-
enqueueSseComment(controller, encoder, "connected");
|
|
56724
|
-
signal?.addEventListener(
|
|
56725
|
-
"abort",
|
|
56726
|
-
() => {
|
|
56727
|
-
this.unregisterConnection(projectId, frontendTabId);
|
|
56728
|
-
},
|
|
56729
|
-
{ once: true }
|
|
56730
|
-
);
|
|
56731
|
-
},
|
|
56732
|
-
cancel: () => {
|
|
56733
|
-
this.unregisterConnection(projectId, frontendTabId);
|
|
56734
56677
|
}
|
|
56735
56678
|
});
|
|
56736
|
-
return stream2;
|
|
56737
|
-
}
|
|
56738
|
-
sendCommand({
|
|
56739
|
-
capability,
|
|
56740
|
-
frontendTabId,
|
|
56741
|
-
payload,
|
|
56742
|
-
projectId
|
|
56743
|
-
}) {
|
|
56744
|
-
const connection = this.connections.get(
|
|
56745
|
-
buildConnectionKey(projectId, frontendTabId)
|
|
56746
|
-
);
|
|
56747
|
-
if (!connection) {
|
|
56748
|
-
return {
|
|
56749
|
-
delivered: false,
|
|
56750
|
-
command: void 0
|
|
56751
|
-
};
|
|
56752
|
-
}
|
|
56753
|
-
const command = {
|
|
56754
|
-
capability,
|
|
56755
|
-
id: createCommandId(),
|
|
56756
|
-
payload
|
|
56757
|
-
};
|
|
56758
|
-
enqueueSseEvent(
|
|
56759
|
-
connection.controller,
|
|
56760
|
-
connection.encoder,
|
|
56761
|
-
"frontend-command",
|
|
56762
|
-
command
|
|
56763
|
-
);
|
|
56764
|
-
return {
|
|
56765
|
-
command,
|
|
56766
|
-
delivered: true
|
|
56767
|
-
};
|
|
56768
|
-
}
|
|
56769
|
-
unregisterConnection(projectId, frontendTabId) {
|
|
56770
|
-
const key = buildConnectionKey(projectId, frontendTabId);
|
|
56771
|
-
const connection = this.connections.get(key);
|
|
56772
|
-
if (!connection) {
|
|
56773
|
-
return;
|
|
56774
|
-
}
|
|
56775
|
-
this.connections.delete(key);
|
|
56776
|
-
clearInterval(connection.keepaliveTimer);
|
|
56777
|
-
try {
|
|
56778
|
-
connection.controller.close();
|
|
56779
|
-
} catch {
|
|
56780
|
-
}
|
|
56781
|
-
}
|
|
56782
|
-
hasConnection(projectId, frontendTabId) {
|
|
56783
|
-
return this.connections.has(buildConnectionKey(projectId, frontendTabId));
|
|
56784
|
-
}
|
|
56785
|
-
clear() {
|
|
56786
|
-
for (const key of Array.from(this.connections.keys())) {
|
|
56787
|
-
const [projectId, frontendTabId] = parseConnectionKey(key);
|
|
56788
|
-
this.unregisterConnection(projectId, frontendTabId);
|
|
56789
|
-
}
|
|
56790
56679
|
}
|
|
56791
|
-
|
|
56792
|
-
|
|
56793
|
-
|
|
56794
|
-
|
|
56795
|
-
|
|
56796
|
-
function registerFrontendConnection(input) {
|
|
56797
|
-
return getFrontendCommandBus().registerConnection(input);
|
|
56798
|
-
}
|
|
56799
|
-
function sendFrontendCommand(input) {
|
|
56800
|
-
return getFrontendCommandBus().sendCommand(input);
|
|
56801
|
-
}
|
|
56802
|
-
function enqueueSseEvent(controller, encoder, event, data) {
|
|
56803
|
-
controller.enqueue(
|
|
56804
|
-
encoder.encode(`event: ${event}
|
|
56805
|
-
data: ${JSON.stringify(data)}
|
|
56806
|
-
|
|
56807
|
-
`)
|
|
56808
|
-
);
|
|
56809
|
-
}
|
|
56810
|
-
function enqueueSseComment(controller, encoder, comment) {
|
|
56811
|
-
controller.enqueue(encoder.encode(`: ${comment}
|
|
56812
|
-
|
|
56813
|
-
`));
|
|
56814
|
-
}
|
|
56815
|
-
function buildConnectionKey(projectId, frontendTabId) {
|
|
56816
|
-
return `${encodeURIComponent(projectId)}:${encodeURIComponent(frontendTabId)}`;
|
|
56817
|
-
}
|
|
56818
|
-
function parseConnectionKey(key) {
|
|
56819
|
-
const [projectId = "", frontendTabId = ""] = key.split(":");
|
|
56820
|
-
return [decodeURIComponent(projectId), decodeURIComponent(frontendTabId)];
|
|
56680
|
+
Object.defineProperty(tools, "__metadata", {
|
|
56681
|
+
enumerable: false,
|
|
56682
|
+
value: metadata
|
|
56683
|
+
});
|
|
56684
|
+
return tools;
|
|
56821
56685
|
}
|
|
56822
|
-
function
|
|
56823
|
-
return
|
|
56686
|
+
function elapsedWallTime(startedAt) {
|
|
56687
|
+
return Math.max(0, Math.round((performance.now() - startedAt) * 100) / 100);
|
|
56824
56688
|
}
|
|
56825
56689
|
|
|
56826
56690
|
// ../core/src/agent/page-edit-mode.ts
|
|
@@ -57230,7 +57094,7 @@ async function readRequiredHtmlFile(workspaceStore, projectId, relativePath, mod
|
|
|
57230
57094
|
async function resolveUniqueCopyPath(workspaceStore, projectId, sourcePath) {
|
|
57231
57095
|
const parsed = path3.posix.parse(sourcePath);
|
|
57232
57096
|
const directory = parsed.dir ? `${parsed.dir}/` : "";
|
|
57233
|
-
const baseName = parsed.name;
|
|
57097
|
+
const baseName = normalizeCopyBaseName(parsed.name);
|
|
57234
57098
|
const extension = parsed.ext || ".html";
|
|
57235
57099
|
for (let index = 1; index < 1e3; index += 1) {
|
|
57236
57100
|
const suffix = index === 1 ? "copy" : `copy-${index}`;
|
|
@@ -57243,184 +57107,49 @@ async function resolveUniqueCopyPath(workspaceStore, projectId, sourcePath) {
|
|
|
57243
57107
|
}
|
|
57244
57108
|
throw new Error(`Could not create a unique copy path for ${sourcePath}.`);
|
|
57245
57109
|
}
|
|
57110
|
+
function normalizeCopyBaseName(baseName) {
|
|
57111
|
+
return baseName.replace(/\.copy(?:-\d+)?$/, "");
|
|
57112
|
+
}
|
|
57246
57113
|
|
|
57247
|
-
// ../core/src/agent/tools/
|
|
57248
|
-
function
|
|
57114
|
+
// ../core/src/agent/tools/copy-file.ts
|
|
57115
|
+
function createCopyFileToolDefinition() {
|
|
57249
57116
|
return {
|
|
57250
|
-
description: "
|
|
57251
|
-
inputSchema: {
|
|
57252
|
-
|
|
57253
|
-
|
|
57254
|
-
|
|
57255
|
-
|
|
57256
|
-
enum: FRONTEND_CAPABILITY_IDS,
|
|
57257
|
-
description: "Frontend capability ID to call."
|
|
57258
|
-
},
|
|
57259
|
-
payload: {
|
|
57260
|
-
type: "object",
|
|
57261
|
-
description: "Capability-specific payload."
|
|
57262
|
-
}
|
|
57263
|
-
},
|
|
57264
|
-
required: ["capability", "payload"],
|
|
57265
|
-
additionalProperties: false
|
|
57266
|
-
},
|
|
57267
|
-
name: "callFrontendCapability",
|
|
57117
|
+
description: "Copy one UTF-8 text file inside the current Project Workspace to a new path. Never overwrites existing files.",
|
|
57118
|
+
inputSchema: external_exports.object({
|
|
57119
|
+
sourcePath: external_exports.string().describe("Relative source file path inside the Project Workspace."),
|
|
57120
|
+
targetPath: external_exports.string().describe("Relative destination file path inside the Project Workspace. Must not already exist.")
|
|
57121
|
+
}).strict(),
|
|
57122
|
+
name: "copyFile",
|
|
57268
57123
|
parallelSafe: false,
|
|
57269
|
-
execute: async (
|
|
57270
|
-
|
|
57271
|
-
|
|
57272
|
-
|
|
57273
|
-
|
|
57274
|
-
|
|
57124
|
+
execute: async ({ sourcePath, targetPath }, { approvedCdnUrls, pageEditModePolicy, projectId, workspaceStore }) => {
|
|
57125
|
+
const normalizedSourcePath = normalizeToolPath(sourcePath);
|
|
57126
|
+
const normalizedTargetPath = normalizeToolPath(targetPath);
|
|
57127
|
+
assertCopyFileAllowed(
|
|
57128
|
+
pageEditModePolicy,
|
|
57129
|
+
normalizedSourcePath,
|
|
57130
|
+
normalizedTargetPath
|
|
57131
|
+
);
|
|
57132
|
+
const existingTarget = await readProjectWorkspaceFileIfExists(
|
|
57133
|
+
workspaceStore,
|
|
57134
|
+
projectId,
|
|
57135
|
+
normalizedTargetPath
|
|
57136
|
+
);
|
|
57137
|
+
if (existingTarget !== void 0) {
|
|
57138
|
+
throw new Error(
|
|
57139
|
+
`Project Workspace file already exists: ${normalizedTargetPath}`
|
|
57140
|
+
);
|
|
57275
57141
|
}
|
|
57276
|
-
const
|
|
57277
|
-
|
|
57278
|
-
|
|
57279
|
-
|
|
57280
|
-
|
|
57281
|
-
|
|
57282
|
-
|
|
57283
|
-
|
|
57284
|
-
|
|
57285
|
-
|
|
57286
|
-
|
|
57287
|
-
const validated = validateFrontendCapabilityPayload(capability, payload);
|
|
57288
|
-
if (capability === "preview.refresh") {
|
|
57289
|
-
return validated;
|
|
57290
|
-
}
|
|
57291
|
-
const targetPath = normalizeToolPath(validated.path);
|
|
57292
|
-
if (!targetPath || targetPath === ".") {
|
|
57293
|
-
throw new Error("Preview switch target path must not be empty.");
|
|
57294
|
-
}
|
|
57295
|
-
if (!isHtmlPath(targetPath)) {
|
|
57296
|
-
throw new Error(`Preview switch target must end with .html: ${targetPath}`);
|
|
57297
|
-
}
|
|
57298
|
-
const previewPath = resolveHtmlOperationPathForPageEditModePolicy(
|
|
57299
|
-
context2.pageEditModePolicy,
|
|
57300
|
-
"preview",
|
|
57301
|
-
targetPath
|
|
57302
|
-
);
|
|
57303
|
-
const htmlFiles = await context2.workspaceStore.listProjectHtmlFiles(
|
|
57304
|
-
context2.projectId
|
|
57305
|
-
);
|
|
57306
|
-
if (!htmlFiles.includes(previewPath)) {
|
|
57307
|
-
throw new Error(`Project Workspace HTML file was not found: ${previewPath}`);
|
|
57308
|
-
}
|
|
57309
|
-
return {
|
|
57310
|
-
path: previewPath
|
|
57311
|
-
};
|
|
57312
|
-
}
|
|
57313
|
-
function sendCapabilityCommand(capability, payload, context2) {
|
|
57314
|
-
if (capability === "preview.refresh") {
|
|
57315
|
-
return sendFrontendCommand({
|
|
57316
|
-
capability,
|
|
57317
|
-
frontendTabId: context2.frontendTabId ?? "",
|
|
57318
|
-
payload,
|
|
57319
|
-
projectId: context2.projectId
|
|
57320
|
-
});
|
|
57321
|
-
}
|
|
57322
|
-
return sendFrontendCommand({
|
|
57323
|
-
capability,
|
|
57324
|
-
frontendTabId: context2.frontendTabId ?? "",
|
|
57325
|
-
payload,
|
|
57326
|
-
projectId: context2.projectId
|
|
57327
|
-
});
|
|
57328
|
-
}
|
|
57329
|
-
|
|
57330
|
-
// ../core/src/agent/tools/core.ts
|
|
57331
|
-
function createWorkspaceToolRegistry(definitions, context2) {
|
|
57332
|
-
const tools = {};
|
|
57333
|
-
const metadata = {};
|
|
57334
|
-
for (const definition of definitions) {
|
|
57335
|
-
if (tools[definition.name]) {
|
|
57336
|
-
throw new Error(`Project Workspace tool already registered: ${definition.name}`);
|
|
57337
|
-
}
|
|
57338
|
-
metadata[definition.name] = {
|
|
57339
|
-
parallelSafe: definition.parallelSafe
|
|
57340
|
-
};
|
|
57341
|
-
tools[definition.name] = tool({
|
|
57342
|
-
description: definition.description,
|
|
57343
|
-
inputSchema: jsonSchema(definition.inputSchema),
|
|
57344
|
-
execute: async (input) => {
|
|
57345
|
-
const startedAt = performance.now();
|
|
57346
|
-
try {
|
|
57347
|
-
definition.validate?.(input);
|
|
57348
|
-
const output = await definition.execute(input, context2);
|
|
57349
|
-
return {
|
|
57350
|
-
ok: true,
|
|
57351
|
-
output,
|
|
57352
|
-
wallTimeMs: elapsedWallTime(startedAt)
|
|
57353
|
-
};
|
|
57354
|
-
} catch (error51) {
|
|
57355
|
-
return {
|
|
57356
|
-
error: error51 instanceof Error ? error51.message : String(error51),
|
|
57357
|
-
ok: false,
|
|
57358
|
-
wallTimeMs: elapsedWallTime(startedAt)
|
|
57359
|
-
};
|
|
57360
|
-
}
|
|
57361
|
-
}
|
|
57362
|
-
});
|
|
57363
|
-
}
|
|
57364
|
-
Object.defineProperty(tools, "__metadata", {
|
|
57365
|
-
enumerable: false,
|
|
57366
|
-
value: metadata
|
|
57367
|
-
});
|
|
57368
|
-
return tools;
|
|
57369
|
-
}
|
|
57370
|
-
function elapsedWallTime(startedAt) {
|
|
57371
|
-
return Math.max(0, Math.round((performance.now() - startedAt) * 100) / 100);
|
|
57372
|
-
}
|
|
57373
|
-
|
|
57374
|
-
// ../core/src/agent/tools/copy-file.ts
|
|
57375
|
-
function createCopyFileToolDefinition() {
|
|
57376
|
-
return {
|
|
57377
|
-
description: "Copy one UTF-8 text file inside the current Project Workspace to a new path. Never overwrites existing files.",
|
|
57378
|
-
inputSchema: {
|
|
57379
|
-
type: "object",
|
|
57380
|
-
properties: {
|
|
57381
|
-
sourcePath: {
|
|
57382
|
-
type: "string",
|
|
57383
|
-
description: "Relative source file path inside the Project Workspace."
|
|
57384
|
-
},
|
|
57385
|
-
targetPath: {
|
|
57386
|
-
type: "string",
|
|
57387
|
-
description: "Relative destination file path inside the Project Workspace. Must not already exist."
|
|
57388
|
-
}
|
|
57389
|
-
},
|
|
57390
|
-
required: ["sourcePath", "targetPath"],
|
|
57391
|
-
additionalProperties: false
|
|
57392
|
-
},
|
|
57393
|
-
name: "copyFile",
|
|
57394
|
-
parallelSafe: false,
|
|
57395
|
-
execute: async ({ sourcePath, targetPath }, { approvedCdnUrls, pageEditModePolicy, projectId, workspaceStore }) => {
|
|
57396
|
-
const normalizedSourcePath = normalizeToolPath(sourcePath);
|
|
57397
|
-
const normalizedTargetPath = normalizeToolPath(targetPath);
|
|
57398
|
-
assertCopyFileAllowed(
|
|
57399
|
-
pageEditModePolicy,
|
|
57400
|
-
normalizedSourcePath,
|
|
57401
|
-
normalizedTargetPath
|
|
57402
|
-
);
|
|
57403
|
-
const existingTarget = await readProjectWorkspaceFileIfExists(
|
|
57404
|
-
workspaceStore,
|
|
57405
|
-
projectId,
|
|
57406
|
-
normalizedTargetPath
|
|
57407
|
-
);
|
|
57408
|
-
if (existingTarget !== void 0) {
|
|
57409
|
-
throw new Error(
|
|
57410
|
-
`Project Workspace file already exists: ${normalizedTargetPath}`
|
|
57411
|
-
);
|
|
57412
|
-
}
|
|
57413
|
-
const sourceContent = await workspaceStore.readProjectWorkspaceFile(
|
|
57414
|
-
projectId,
|
|
57415
|
-
normalizedSourcePath
|
|
57416
|
-
);
|
|
57417
|
-
return writeProjectWorkspaceFileWithCdnGuard(
|
|
57418
|
-
workspaceStore,
|
|
57419
|
-
projectId,
|
|
57420
|
-
normalizedTargetPath,
|
|
57421
|
-
sourceContent,
|
|
57422
|
-
approvedCdnUrls
|
|
57423
|
-
);
|
|
57142
|
+
const sourceContent = await workspaceStore.readProjectWorkspaceFile(
|
|
57143
|
+
projectId,
|
|
57144
|
+
normalizedSourcePath
|
|
57145
|
+
);
|
|
57146
|
+
return writeProjectWorkspaceFileWithCdnGuard(
|
|
57147
|
+
workspaceStore,
|
|
57148
|
+
projectId,
|
|
57149
|
+
normalizedTargetPath,
|
|
57150
|
+
sourceContent,
|
|
57151
|
+
approvedCdnUrls
|
|
57152
|
+
);
|
|
57424
57153
|
}
|
|
57425
57154
|
};
|
|
57426
57155
|
}
|
|
@@ -57430,29 +57159,12 @@ var DEFAULT_TITLE = "OwnDesign Preview";
|
|
|
57430
57159
|
function createCreateHtmlToolDefinition() {
|
|
57431
57160
|
return {
|
|
57432
57161
|
description: "Create a new previewable HTML file from the configured resource template before designing a missing target HTML page. Never overwrites existing files.",
|
|
57433
|
-
inputSchema: {
|
|
57434
|
-
|
|
57435
|
-
|
|
57436
|
-
|
|
57437
|
-
|
|
57438
|
-
|
|
57439
|
-
},
|
|
57440
|
-
iconLibraryName: {
|
|
57441
|
-
type: "string",
|
|
57442
|
-
description: "Optional configured icon library name. Omit to use the default icon library. Pass an empty string to disable icon resources."
|
|
57443
|
-
},
|
|
57444
|
-
path: {
|
|
57445
|
-
type: "string",
|
|
57446
|
-
description: "Relative HTML file path inside the Project Workspace, such as index.html or pages/detail.html."
|
|
57447
|
-
},
|
|
57448
|
-
title: {
|
|
57449
|
-
type: "string",
|
|
57450
|
-
description: "Optional document title. Defaults to OwnDesign Preview."
|
|
57451
|
-
}
|
|
57452
|
-
},
|
|
57453
|
-
required: ["path"],
|
|
57454
|
-
additionalProperties: false
|
|
57455
|
-
},
|
|
57162
|
+
inputSchema: external_exports.object({
|
|
57163
|
+
fontLibraryName: external_exports.string().describe("Optional configured font library name. Omit to use the default font library. Pass an empty string to disable font resources.").optional(),
|
|
57164
|
+
iconLibraryName: external_exports.string().describe("Optional configured icon library name. Omit to use the default icon library. Pass an empty string to disable icon resources.").optional(),
|
|
57165
|
+
path: external_exports.string().describe("Relative HTML file path inside the Project Workspace, such as index.html or pages/detail.html."),
|
|
57166
|
+
title: external_exports.string().describe("Optional document title. Defaults to OwnDesign Preview.").optional()
|
|
57167
|
+
}).strict(),
|
|
57456
57168
|
name: "createHtml",
|
|
57457
57169
|
parallelSafe: false,
|
|
57458
57170
|
execute: async (input, {
|
|
@@ -57571,17 +57283,9 @@ function escapeHtmlText(value) {
|
|
|
57571
57283
|
function createDeleteToolDefinition() {
|
|
57572
57284
|
return {
|
|
57573
57285
|
description: "Recursively delete a file or directory from the current Project Workspace.",
|
|
57574
|
-
inputSchema: {
|
|
57575
|
-
|
|
57576
|
-
|
|
57577
|
-
path: {
|
|
57578
|
-
type: "string",
|
|
57579
|
-
description: "Relative file or directory path inside the Project Workspace."
|
|
57580
|
-
}
|
|
57581
|
-
},
|
|
57582
|
-
required: ["path"],
|
|
57583
|
-
additionalProperties: false
|
|
57584
|
-
},
|
|
57286
|
+
inputSchema: external_exports.object({
|
|
57287
|
+
path: external_exports.string().describe("Relative file or directory path inside the Project Workspace.")
|
|
57288
|
+
}).strict(),
|
|
57585
57289
|
name: "delete",
|
|
57586
57290
|
parallelSafe: false,
|
|
57587
57291
|
execute: async ({ path: path16 }, {
|
|
@@ -57599,29 +57303,12 @@ function createDeleteToolDefinition() {
|
|
|
57599
57303
|
function createEditToolDefinition() {
|
|
57600
57304
|
return {
|
|
57601
57305
|
description: "Edit one UTF-8 text file by replacing oldString with newString. By default oldString must occur exactly once; set replaceAll to replace every occurrence.",
|
|
57602
|
-
inputSchema: {
|
|
57603
|
-
|
|
57604
|
-
|
|
57605
|
-
|
|
57606
|
-
|
|
57607
|
-
|
|
57608
|
-
},
|
|
57609
|
-
oldString: {
|
|
57610
|
-
type: "string",
|
|
57611
|
-
description: "Text to replace."
|
|
57612
|
-
},
|
|
57613
|
-
path: {
|
|
57614
|
-
type: "string",
|
|
57615
|
-
description: "Relative file path inside the Project Workspace."
|
|
57616
|
-
},
|
|
57617
|
-
replaceAll: {
|
|
57618
|
-
type: "boolean",
|
|
57619
|
-
description: "Replace every occurrence of oldString instead of requiring exactly one match."
|
|
57620
|
-
}
|
|
57621
|
-
},
|
|
57622
|
-
required: ["path", "oldString", "newString"],
|
|
57623
|
-
additionalProperties: false
|
|
57624
|
-
},
|
|
57306
|
+
inputSchema: external_exports.object({
|
|
57307
|
+
newString: external_exports.string().describe("Replacement text."),
|
|
57308
|
+
oldString: external_exports.string().describe("Text to replace."),
|
|
57309
|
+
path: external_exports.string().describe("Relative file path inside the Project Workspace."),
|
|
57310
|
+
replaceAll: external_exports.boolean().describe("Replace every occurrence of oldString instead of requiring exactly one match.").optional()
|
|
57311
|
+
}).strict(),
|
|
57625
57312
|
name: "edit",
|
|
57626
57313
|
parallelSafe: false,
|
|
57627
57314
|
execute: async ({ newString, oldString, path: path16, replaceAll }, {
|
|
@@ -57652,21 +57339,10 @@ function createEditToolDefinition() {
|
|
|
57652
57339
|
function createGlobToolDefinition() {
|
|
57653
57340
|
return {
|
|
57654
57341
|
description: "Find files and directories in the current Project Workspace by glob pattern, sorted by most recently modified first.",
|
|
57655
|
-
inputSchema: {
|
|
57656
|
-
|
|
57657
|
-
|
|
57658
|
-
|
|
57659
|
-
type: "string",
|
|
57660
|
-
description: "Optional relative directory path inside the Project Workspace to search from."
|
|
57661
|
-
},
|
|
57662
|
-
pattern: {
|
|
57663
|
-
type: "string",
|
|
57664
|
-
description: 'Glob pattern such as "**/*.html", "assets/*.{css,js}", or "index.html".'
|
|
57665
|
-
}
|
|
57666
|
-
},
|
|
57667
|
-
required: ["pattern"],
|
|
57668
|
-
additionalProperties: false
|
|
57669
|
-
},
|
|
57342
|
+
inputSchema: external_exports.object({
|
|
57343
|
+
path: external_exports.string().describe("Optional relative directory path inside the Project Workspace to search from.").optional(),
|
|
57344
|
+
pattern: external_exports.string().describe('Glob pattern such as "**/*.html", "assets/*.{css,js}", or "index.html".')
|
|
57345
|
+
}).strict(),
|
|
57670
57346
|
name: "glob",
|
|
57671
57347
|
parallelSafe: true,
|
|
57672
57348
|
execute: async ({ path: path16, pattern }, {
|
|
@@ -57686,25 +57362,11 @@ function createGlobToolDefinition() {
|
|
|
57686
57362
|
function createGrepToolDefinition() {
|
|
57687
57363
|
return {
|
|
57688
57364
|
description: "Search UTF-8 text files in the current Project Workspace using a JavaScript regular expression.",
|
|
57689
|
-
inputSchema: {
|
|
57690
|
-
|
|
57691
|
-
|
|
57692
|
-
|
|
57693
|
-
|
|
57694
|
-
description: 'Optional file glob to include, such as "*.html" or "**/*.{css,js}".'
|
|
57695
|
-
},
|
|
57696
|
-
path: {
|
|
57697
|
-
type: "string",
|
|
57698
|
-
description: "Optional relative file or directory path inside the Project Workspace to search."
|
|
57699
|
-
},
|
|
57700
|
-
pattern: {
|
|
57701
|
-
type: "string",
|
|
57702
|
-
description: "JavaScript regular expression pattern to search for."
|
|
57703
|
-
}
|
|
57704
|
-
},
|
|
57705
|
-
required: ["pattern"],
|
|
57706
|
-
additionalProperties: false
|
|
57707
|
-
},
|
|
57365
|
+
inputSchema: external_exports.object({
|
|
57366
|
+
include: external_exports.string().describe('Optional file glob to include, such as "*.html" or "**/*.{css,js}".').optional(),
|
|
57367
|
+
path: external_exports.string().describe("Optional relative file or directory path inside the Project Workspace to search.").optional(),
|
|
57368
|
+
pattern: external_exports.string().describe("JavaScript regular expression pattern to search for.")
|
|
57369
|
+
}).strict(),
|
|
57708
57370
|
name: "grep",
|
|
57709
57371
|
parallelSafe: true,
|
|
57710
57372
|
execute: async ({ include, path: path16, pattern }, {
|
|
@@ -57723,51 +57385,33 @@ function createGrepToolDefinition() {
|
|
|
57723
57385
|
function createPatchToolDefinition() {
|
|
57724
57386
|
return {
|
|
57725
57387
|
description: "Apply coordinated UTF-8 file changes inside the current Project Workspace. Supports add/write, edit, and delete changes.",
|
|
57726
|
-
inputSchema: {
|
|
57727
|
-
|
|
57728
|
-
|
|
57729
|
-
|
|
57730
|
-
|
|
57731
|
-
|
|
57732
|
-
|
|
57733
|
-
|
|
57734
|
-
|
|
57735
|
-
|
|
57736
|
-
|
|
57737
|
-
|
|
57738
|
-
|
|
57739
|
-
|
|
57740
|
-
|
|
57741
|
-
|
|
57742
|
-
|
|
57743
|
-
|
|
57744
|
-
|
|
57745
|
-
|
|
57746
|
-
|
|
57747
|
-
|
|
57748
|
-
|
|
57749
|
-
|
|
57750
|
-
|
|
57751
|
-
path: {
|
|
57752
|
-
type: "string",
|
|
57753
|
-
description: "Relative file or directory path inside the Project Workspace."
|
|
57754
|
-
},
|
|
57755
|
-
replaceAll: {
|
|
57756
|
-
type: "boolean",
|
|
57757
|
-
description: "For edit operations, replace every occurrence of oldString."
|
|
57758
|
-
}
|
|
57759
|
-
},
|
|
57760
|
-
required: ["operation", "path"],
|
|
57761
|
-
additionalProperties: false
|
|
57762
|
-
}
|
|
57763
|
-
}
|
|
57764
|
-
},
|
|
57765
|
-
required: ["changes"],
|
|
57766
|
-
additionalProperties: false
|
|
57767
|
-
},
|
|
57388
|
+
inputSchema: external_exports.object({
|
|
57389
|
+
changes: external_exports.array(external_exports.discriminatedUnion("operation", [
|
|
57390
|
+
external_exports.object({
|
|
57391
|
+
content: external_exports.string().describe("Complete file content for add operations."),
|
|
57392
|
+
operation: external_exports.literal("add"),
|
|
57393
|
+
path: external_exports.string().describe("Relative file or directory path inside the Project Workspace.")
|
|
57394
|
+
}).strict(),
|
|
57395
|
+
external_exports.object({
|
|
57396
|
+
content: external_exports.string().describe("Complete file content for write operations."),
|
|
57397
|
+
operation: external_exports.literal("write"),
|
|
57398
|
+
path: external_exports.string().describe("Relative file or directory path inside the Project Workspace.")
|
|
57399
|
+
}).strict(),
|
|
57400
|
+
external_exports.object({
|
|
57401
|
+
newString: external_exports.string().describe("Replacement text for edit operations."),
|
|
57402
|
+
oldString: external_exports.string().describe("Text to replace for edit operations."),
|
|
57403
|
+
operation: external_exports.literal("edit"),
|
|
57404
|
+
path: external_exports.string().describe("Relative file or directory path inside the Project Workspace."),
|
|
57405
|
+
replaceAll: external_exports.boolean().describe("For edit operations, replace every occurrence of oldString.").optional()
|
|
57406
|
+
}).strict(),
|
|
57407
|
+
external_exports.object({
|
|
57408
|
+
operation: external_exports.literal("delete"),
|
|
57409
|
+
path: external_exports.string().describe("Relative file or directory path inside the Project Workspace.")
|
|
57410
|
+
}).strict()
|
|
57411
|
+
])).min(1)
|
|
57412
|
+
}).strict(),
|
|
57768
57413
|
name: "patch",
|
|
57769
57414
|
parallelSafe: false,
|
|
57770
|
-
validate: validatePatchInput,
|
|
57771
57415
|
execute: async ({ changes }, { approvedCdnUrls, pageEditModePolicy, projectId, workspaceStore }) => {
|
|
57772
57416
|
const resolvedChanges = changes.map((change) => ({
|
|
57773
57417
|
...change,
|
|
@@ -57786,66 +57430,217 @@ function createPatchToolDefinition() {
|
|
|
57786
57430
|
}
|
|
57787
57431
|
};
|
|
57788
57432
|
}
|
|
57789
|
-
|
|
57790
|
-
|
|
57791
|
-
|
|
57433
|
+
|
|
57434
|
+
// ../core/src/realtime/frontend-command-bus.ts
|
|
57435
|
+
var KEEPALIVE_INTERVAL_MS = 15e3;
|
|
57436
|
+
var FrontendCommandBus = class {
|
|
57437
|
+
connections = /* @__PURE__ */ new Map();
|
|
57438
|
+
registerConnection({
|
|
57439
|
+
frontendTabId,
|
|
57440
|
+
projectId,
|
|
57441
|
+
signal
|
|
57442
|
+
}) {
|
|
57443
|
+
const key = buildConnectionKey(projectId, frontendTabId);
|
|
57444
|
+
const encoder = new TextEncoder();
|
|
57445
|
+
let connection;
|
|
57446
|
+
const stream2 = new ReadableStream({
|
|
57447
|
+
start: (controller) => {
|
|
57448
|
+
this.unregisterConnection(projectId, frontendTabId);
|
|
57449
|
+
connection = {
|
|
57450
|
+
controller,
|
|
57451
|
+
encoder,
|
|
57452
|
+
keepaliveTimer: setInterval(() => {
|
|
57453
|
+
enqueueSseComment(controller, encoder, "keepalive");
|
|
57454
|
+
}, KEEPALIVE_INTERVAL_MS)
|
|
57455
|
+
};
|
|
57456
|
+
connection.keepaliveTimer.unref?.();
|
|
57457
|
+
this.connections.set(key, connection);
|
|
57458
|
+
enqueueSseComment(controller, encoder, "connected");
|
|
57459
|
+
signal?.addEventListener(
|
|
57460
|
+
"abort",
|
|
57461
|
+
() => {
|
|
57462
|
+
this.unregisterConnection(projectId, frontendTabId);
|
|
57463
|
+
},
|
|
57464
|
+
{ once: true }
|
|
57465
|
+
);
|
|
57466
|
+
},
|
|
57467
|
+
cancel: () => {
|
|
57468
|
+
this.unregisterConnection(projectId, frontendTabId);
|
|
57469
|
+
}
|
|
57470
|
+
});
|
|
57471
|
+
return stream2;
|
|
57792
57472
|
}
|
|
57793
|
-
|
|
57794
|
-
|
|
57795
|
-
|
|
57796
|
-
|
|
57473
|
+
sendCommand({
|
|
57474
|
+
capability,
|
|
57475
|
+
frontendTabId,
|
|
57476
|
+
payload,
|
|
57477
|
+
projectId
|
|
57478
|
+
}) {
|
|
57479
|
+
const connection = this.connections.get(
|
|
57480
|
+
buildConnectionKey(projectId, frontendTabId)
|
|
57481
|
+
);
|
|
57482
|
+
if (!connection) {
|
|
57483
|
+
return {
|
|
57484
|
+
delivered: false,
|
|
57485
|
+
command: void 0
|
|
57486
|
+
};
|
|
57797
57487
|
}
|
|
57798
|
-
|
|
57799
|
-
|
|
57800
|
-
|
|
57801
|
-
|
|
57802
|
-
|
|
57803
|
-
|
|
57804
|
-
|
|
57805
|
-
|
|
57488
|
+
const command = {
|
|
57489
|
+
capability,
|
|
57490
|
+
id: createCommandId(),
|
|
57491
|
+
payload
|
|
57492
|
+
};
|
|
57493
|
+
enqueueSseEvent(
|
|
57494
|
+
connection.controller,
|
|
57495
|
+
connection.encoder,
|
|
57496
|
+
"frontend-command",
|
|
57497
|
+
command
|
|
57498
|
+
);
|
|
57499
|
+
return {
|
|
57500
|
+
command,
|
|
57501
|
+
delivered: true
|
|
57502
|
+
};
|
|
57503
|
+
}
|
|
57504
|
+
unregisterConnection(projectId, frontendTabId) {
|
|
57505
|
+
const key = buildConnectionKey(projectId, frontendTabId);
|
|
57506
|
+
const connection = this.connections.get(key);
|
|
57507
|
+
if (!connection) {
|
|
57508
|
+
return;
|
|
57509
|
+
}
|
|
57510
|
+
this.connections.delete(key);
|
|
57511
|
+
clearInterval(connection.keepaliveTimer);
|
|
57512
|
+
try {
|
|
57513
|
+
connection.controller.close();
|
|
57514
|
+
} catch {
|
|
57515
|
+
}
|
|
57516
|
+
}
|
|
57517
|
+
hasConnection(projectId, frontendTabId) {
|
|
57518
|
+
return this.connections.has(buildConnectionKey(projectId, frontendTabId));
|
|
57519
|
+
}
|
|
57520
|
+
clear() {
|
|
57521
|
+
for (const key of Array.from(this.connections.keys())) {
|
|
57522
|
+
const [projectId, frontendTabId] = parseConnectionKey(key);
|
|
57523
|
+
this.unregisterConnection(projectId, frontendTabId);
|
|
57524
|
+
}
|
|
57525
|
+
}
|
|
57526
|
+
};
|
|
57527
|
+
function getFrontendCommandBus() {
|
|
57528
|
+
globalThis.__owndesignFrontendCommandBus ??= new FrontendCommandBus();
|
|
57529
|
+
return globalThis.__owndesignFrontendCommandBus;
|
|
57530
|
+
}
|
|
57531
|
+
function registerFrontendConnection(input) {
|
|
57532
|
+
return getFrontendCommandBus().registerConnection(input);
|
|
57533
|
+
}
|
|
57534
|
+
function sendFrontendCommand(input) {
|
|
57535
|
+
return getFrontendCommandBus().sendCommand(input);
|
|
57536
|
+
}
|
|
57537
|
+
function enqueueSseEvent(controller, encoder, event, data) {
|
|
57538
|
+
controller.enqueue(
|
|
57539
|
+
encoder.encode(`event: ${event}
|
|
57540
|
+
data: ${JSON.stringify(data)}
|
|
57541
|
+
|
|
57542
|
+
`)
|
|
57543
|
+
);
|
|
57544
|
+
}
|
|
57545
|
+
function enqueueSseComment(controller, encoder, comment) {
|
|
57546
|
+
controller.enqueue(encoder.encode(`: ${comment}
|
|
57547
|
+
|
|
57548
|
+
`));
|
|
57549
|
+
}
|
|
57550
|
+
function buildConnectionKey(projectId, frontendTabId) {
|
|
57551
|
+
return `${encodeURIComponent(projectId)}:${encodeURIComponent(frontendTabId)}`;
|
|
57552
|
+
}
|
|
57553
|
+
function parseConnectionKey(key) {
|
|
57554
|
+
const [projectId = "", frontendTabId = ""] = key.split(":");
|
|
57555
|
+
return [decodeURIComponent(projectId), decodeURIComponent(frontendTabId)];
|
|
57556
|
+
}
|
|
57557
|
+
function createCommandId() {
|
|
57558
|
+
return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
57559
|
+
}
|
|
57560
|
+
|
|
57561
|
+
// ../core/src/agent/tools/preview-refresh.ts
|
|
57562
|
+
function createPreviewRefreshToolDefinition() {
|
|
57563
|
+
return {
|
|
57564
|
+
description: "Refresh the current Preview Pane after successful previewable HTML changes without changing HTML file.",
|
|
57565
|
+
inputSchema: external_exports.object({}).strict(),
|
|
57566
|
+
name: "previewRefresh",
|
|
57567
|
+
parallelSafe: false,
|
|
57568
|
+
execute: (_input, context2) => {
|
|
57569
|
+
if (!context2.frontendTabId) {
|
|
57570
|
+
throw new Error("Frontend tab id is required to refresh the preview.");
|
|
57571
|
+
}
|
|
57572
|
+
const payload = {};
|
|
57573
|
+
const result = sendFrontendCommand({
|
|
57574
|
+
capability: "preview.refresh",
|
|
57575
|
+
frontendTabId: context2.frontendTabId,
|
|
57576
|
+
payload,
|
|
57577
|
+
projectId: context2.projectId
|
|
57578
|
+
});
|
|
57579
|
+
return {
|
|
57580
|
+
capability: "preview.refresh",
|
|
57581
|
+
delivered: result?.delivered ?? false,
|
|
57582
|
+
payload
|
|
57583
|
+
};
|
|
57806
57584
|
}
|
|
57807
|
-
|
|
57808
|
-
|
|
57809
|
-
|
|
57585
|
+
};
|
|
57586
|
+
}
|
|
57587
|
+
|
|
57588
|
+
// ../core/src/agent/tools/preview-switch-html.ts
|
|
57589
|
+
function createPreviewSwitchHtmlToolDefinition() {
|
|
57590
|
+
return {
|
|
57591
|
+
description: "Switch the Preview Pane to an existing HTML file after successful previewable HTML changes.",
|
|
57592
|
+
inputSchema: external_exports.object({
|
|
57593
|
+
path: external_exports.string().describe("Relative HTML file path inside the Project Workspace to show in the Preview Pane.")
|
|
57594
|
+
}).strict(),
|
|
57595
|
+
name: "previewSwitchHtml",
|
|
57596
|
+
parallelSafe: false,
|
|
57597
|
+
execute: async ({ path: path16 }, context2) => {
|
|
57598
|
+
if (!context2.frontendTabId) {
|
|
57599
|
+
throw new Error("Frontend tab id is required to switch the preview.");
|
|
57810
57600
|
}
|
|
57811
|
-
|
|
57812
|
-
|
|
57601
|
+
const targetPath = normalizeToolPath(path16);
|
|
57602
|
+
if (!targetPath || targetPath === ".") {
|
|
57603
|
+
throw new Error("Preview switch target path must not be empty.");
|
|
57813
57604
|
}
|
|
57814
|
-
|
|
57815
|
-
|
|
57816
|
-
if (change.operation === "delete") {
|
|
57817
|
-
if ("content" in change || "oldString" in change || "newString" in change || "replaceAll" in change) {
|
|
57818
|
-
throw new Error(`${label} delete changes must not include content or edit fields.`);
|
|
57605
|
+
if (!isHtmlPath(targetPath)) {
|
|
57606
|
+
throw new Error(`Preview switch target must end with .html: ${targetPath}`);
|
|
57819
57607
|
}
|
|
57820
|
-
|
|
57608
|
+
const previewPath = resolveHtmlOperationPathForPageEditModePolicy(
|
|
57609
|
+
context2.pageEditModePolicy,
|
|
57610
|
+
"preview",
|
|
57611
|
+
targetPath
|
|
57612
|
+
);
|
|
57613
|
+
const htmlFiles = await context2.workspaceStore.listProjectHtmlFiles(
|
|
57614
|
+
context2.projectId
|
|
57615
|
+
);
|
|
57616
|
+
if (!htmlFiles.includes(previewPath)) {
|
|
57617
|
+
throw new Error(`Project Workspace HTML file was not found: ${previewPath}`);
|
|
57618
|
+
}
|
|
57619
|
+
const payload = { path: previewPath };
|
|
57620
|
+
const result = sendFrontendCommand({
|
|
57621
|
+
capability: "preview.switchHtml",
|
|
57622
|
+
frontendTabId: context2.frontendTabId,
|
|
57623
|
+
payload,
|
|
57624
|
+
projectId: context2.projectId
|
|
57625
|
+
});
|
|
57626
|
+
return {
|
|
57627
|
+
capability: "preview.switchHtml",
|
|
57628
|
+
delivered: result?.delivered ?? false,
|
|
57629
|
+
payload
|
|
57630
|
+
};
|
|
57821
57631
|
}
|
|
57822
|
-
|
|
57823
|
-
}
|
|
57632
|
+
};
|
|
57824
57633
|
}
|
|
57825
57634
|
|
|
57826
57635
|
// ../core/src/agent/tools/read.ts
|
|
57827
57636
|
function createReadToolDefinition() {
|
|
57828
57637
|
return {
|
|
57829
57638
|
description: "Read one UTF-8 file or directory from the current Project Workspace. Files are returned with 1-indexed line numbers.",
|
|
57830
|
-
inputSchema: {
|
|
57831
|
-
|
|
57832
|
-
|
|
57833
|
-
|
|
57834
|
-
|
|
57835
|
-
description: "Maximum number of lines or directory entries to read. Defaults to 2000."
|
|
57836
|
-
},
|
|
57837
|
-
offset: {
|
|
57838
|
-
type: "number",
|
|
57839
|
-
description: "1-indexed line or directory-entry offset to start reading from. Defaults to 1."
|
|
57840
|
-
},
|
|
57841
|
-
path: {
|
|
57842
|
-
type: "string",
|
|
57843
|
-
description: "Relative file or directory path inside the Project Workspace."
|
|
57844
|
-
}
|
|
57845
|
-
},
|
|
57846
|
-
required: ["path"],
|
|
57847
|
-
additionalProperties: false
|
|
57848
|
-
},
|
|
57639
|
+
inputSchema: external_exports.object({
|
|
57640
|
+
limit: external_exports.number().describe("Maximum number of lines or directory entries to read. Defaults to 2000.").optional(),
|
|
57641
|
+
offset: external_exports.number().describe("1-indexed line or directory-entry offset to start reading from. Defaults to 1.").optional(),
|
|
57642
|
+
path: external_exports.string().describe("Relative file or directory path inside the Project Workspace.")
|
|
57643
|
+
}).strict(),
|
|
57849
57644
|
name: "read",
|
|
57850
57645
|
parallelSafe: true,
|
|
57851
57646
|
execute: async ({ limit, offset, path: path16 }, {
|
|
@@ -57868,21 +57663,10 @@ function createReadToolDefinition() {
|
|
|
57868
57663
|
function createWriteToolDefinition() {
|
|
57869
57664
|
return {
|
|
57870
57665
|
description: "Create or overwrite one UTF-8 text file in the current Project Workspace.",
|
|
57871
|
-
inputSchema: {
|
|
57872
|
-
|
|
57873
|
-
|
|
57874
|
-
|
|
57875
|
-
type: "string",
|
|
57876
|
-
description: "Complete UTF-8 text file content."
|
|
57877
|
-
},
|
|
57878
|
-
path: {
|
|
57879
|
-
type: "string",
|
|
57880
|
-
description: "Relative file path inside the Project Workspace."
|
|
57881
|
-
}
|
|
57882
|
-
},
|
|
57883
|
-
required: ["path", "content"],
|
|
57884
|
-
additionalProperties: false
|
|
57885
|
-
},
|
|
57666
|
+
inputSchema: external_exports.object({
|
|
57667
|
+
content: external_exports.string().describe("Complete UTF-8 text file content."),
|
|
57668
|
+
path: external_exports.string().describe("Relative file path inside the Project Workspace.")
|
|
57669
|
+
}).strict(),
|
|
57886
57670
|
name: "write",
|
|
57887
57671
|
parallelSafe: false,
|
|
57888
57672
|
execute: async ({ content, path: path16 }, {
|
|
@@ -57910,7 +57694,6 @@ function createWriteToolDefinition() {
|
|
|
57910
57694
|
// ../core/src/agent/tools/project-workspace-tools.ts
|
|
57911
57695
|
function createProjectWorkspaceToolDefinitions() {
|
|
57912
57696
|
return [
|
|
57913
|
-
createCallFrontendCapabilityToolDefinition(),
|
|
57914
57697
|
createCopyFileToolDefinition(),
|
|
57915
57698
|
createCreateHtmlToolDefinition(),
|
|
57916
57699
|
createDeleteToolDefinition(),
|
|
@@ -57918,6 +57701,8 @@ function createProjectWorkspaceToolDefinitions() {
|
|
|
57918
57701
|
createGlobToolDefinition(),
|
|
57919
57702
|
createGrepToolDefinition(),
|
|
57920
57703
|
createPatchToolDefinition(),
|
|
57704
|
+
createPreviewRefreshToolDefinition(),
|
|
57705
|
+
createPreviewSwitchHtmlToolDefinition(),
|
|
57921
57706
|
createReadToolDefinition(),
|
|
57922
57707
|
createWriteToolDefinition()
|
|
57923
57708
|
];
|
|
@@ -57964,6 +57749,54 @@ function isNotFoundError(error51) {
|
|
|
57964
57749
|
return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "ENOENT";
|
|
57965
57750
|
}
|
|
57966
57751
|
|
|
57752
|
+
// ../core/src/realtime/frontend-capabilities.ts
|
|
57753
|
+
var FRONTEND_CAPABILITIES = {
|
|
57754
|
+
"preview.refresh": {
|
|
57755
|
+
description: "Refresh the current Preview Pane without changing HTML file.",
|
|
57756
|
+
payloadSchema: {
|
|
57757
|
+
type: "object",
|
|
57758
|
+
properties: {},
|
|
57759
|
+
additionalProperties: false
|
|
57760
|
+
}
|
|
57761
|
+
},
|
|
57762
|
+
"preview.switchHtml": {
|
|
57763
|
+
description: "Switch the Preview Pane to an existing HTML file.",
|
|
57764
|
+
payloadSchema: {
|
|
57765
|
+
type: "object",
|
|
57766
|
+
properties: {
|
|
57767
|
+
path: {
|
|
57768
|
+
type: "string",
|
|
57769
|
+
description: "Relative HTML file path inside the Project Workspace to show in the Preview Pane."
|
|
57770
|
+
}
|
|
57771
|
+
},
|
|
57772
|
+
required: ["path"],
|
|
57773
|
+
additionalProperties: false
|
|
57774
|
+
}
|
|
57775
|
+
}
|
|
57776
|
+
};
|
|
57777
|
+
var FRONTEND_CAPABILITY_IDS = Object.keys(
|
|
57778
|
+
FRONTEND_CAPABILITIES
|
|
57779
|
+
);
|
|
57780
|
+
function buildFrontendCapabilityPrompt() {
|
|
57781
|
+
return [
|
|
57782
|
+
"## Frontend Capabilities",
|
|
57783
|
+
"Use preview tools only to notify the browser UI after Project Workspace file changes are complete. They do not create, edit, or validate files.",
|
|
57784
|
+
"After successful previewable HTML changes, call exactly one preview tool before the final user-facing summary.",
|
|
57785
|
+
"Do not call a preview tool when no previewable HTML file changed or the file operation failed.",
|
|
57786
|
+
"Use the current user request to decide which preview tool is needed:",
|
|
57787
|
+
"- Use `previewSwitchHtml` only when the Preview Pane should move to a different existing relative `.html` file inside the Project Workspace.",
|
|
57788
|
+
"- Use `previewRefresh` when the Preview Pane is already showing the correct page and only needs to reload changed HTML.",
|
|
57789
|
+
"Do not use workspace file tools to simulate preview switching or refreshing.",
|
|
57790
|
+
"Available capabilities:",
|
|
57791
|
+
...FRONTEND_CAPABILITY_IDS.map((capability) => {
|
|
57792
|
+
const schema = JSON.stringify(
|
|
57793
|
+
FRONTEND_CAPABILITIES[capability].payloadSchema
|
|
57794
|
+
);
|
|
57795
|
+
return `- ${capability}: ${FRONTEND_CAPABILITIES[capability].description} Payload schema: ${schema}`;
|
|
57796
|
+
})
|
|
57797
|
+
].join("\n");
|
|
57798
|
+
}
|
|
57799
|
+
|
|
57967
57800
|
// ../core/src/agent/design-page-agent.ts
|
|
57968
57801
|
var DESIGN_PAGE_AGENT_PROMPT_VERSION = 1;
|
|
57969
57802
|
var AiSdkDesignPageAgent = class {
|
|
@@ -58317,6 +58150,7 @@ import path5 from "node:path";
|
|
|
58317
58150
|
var DEFAULT_CLEANUP_INTERVAL_MS = 3e4;
|
|
58318
58151
|
var DEFAULT_LEASE_TTL_MS = 9e4;
|
|
58319
58152
|
var PREVIEW_HOST = "127.0.0.1";
|
|
58153
|
+
var PREVIEW_CACHE_CONTROL = "no-store";
|
|
58320
58154
|
var PreviewServerManager = class {
|
|
58321
58155
|
cleanupIntervalMs;
|
|
58322
58156
|
entries = /* @__PURE__ */ new Map();
|
|
@@ -58427,6 +58261,10 @@ var PreviewServerManager = class {
|
|
|
58427
58261
|
"/index.html",
|
|
58428
58262
|
async () => htmlResponse(await readIndexHtmlOrEmptyPreview(workspaceDirectory, entry))
|
|
58429
58263
|
);
|
|
58264
|
+
app2.use("*", async (context2, next) => {
|
|
58265
|
+
context2.header("Cache-Control", PREVIEW_CACHE_CONTROL);
|
|
58266
|
+
await next();
|
|
58267
|
+
});
|
|
58430
58268
|
app2.use("*", serveStatic({
|
|
58431
58269
|
onFound: (filePath) => {
|
|
58432
58270
|
recordServedStaticPath(entry, workspaceDirectory, filePath);
|
|
@@ -58469,6 +58307,7 @@ var PreviewServerManager = class {
|
|
|
58469
58307
|
function htmlResponse(html) {
|
|
58470
58308
|
return new Response(html, {
|
|
58471
58309
|
headers: {
|
|
58310
|
+
"Cache-Control": PREVIEW_CACHE_CONTROL,
|
|
58472
58311
|
"Content-Type": "text/html; charset=utf-8"
|
|
58473
58312
|
}
|
|
58474
58313
|
});
|
|
@@ -58673,7 +58512,7 @@ function buildWorkspaceHref({
|
|
|
58673
58512
|
}
|
|
58674
58513
|
|
|
58675
58514
|
// ../core/src/conversations/conversation-service.ts
|
|
58676
|
-
var DEFAULT_CONVERSATION_TITLE =
|
|
58515
|
+
var DEFAULT_CONVERSATION_TITLE = FALLBACK_CONVERSATION_TITLE;
|
|
58677
58516
|
var ConversationService = class {
|
|
58678
58517
|
workspaceStore;
|
|
58679
58518
|
now;
|
|
@@ -58685,12 +58524,12 @@ var ConversationService = class {
|
|
|
58685
58524
|
this.createId = options.createId ?? (() => crypto.randomUUID());
|
|
58686
58525
|
this.designPageAgent = options.designPageAgent ?? new AiSdkDesignPageAgent(this.workspaceStore);
|
|
58687
58526
|
}
|
|
58688
|
-
async createConversation(projectId) {
|
|
58527
|
+
async createConversation(projectId, defaultTitle) {
|
|
58689
58528
|
const timestamp = this.now();
|
|
58690
58529
|
const conversation = {
|
|
58691
58530
|
id: this.createId(),
|
|
58692
58531
|
projectId,
|
|
58693
|
-
title:
|
|
58532
|
+
title: normalizeDefaultConversationTitle(defaultTitle),
|
|
58694
58533
|
createdAt: timestamp,
|
|
58695
58534
|
updatedAt: timestamp,
|
|
58696
58535
|
messages: []
|
|
@@ -58789,13 +58628,16 @@ var ConversationService = class {
|
|
|
58789
58628
|
updatedConversation
|
|
58790
58629
|
);
|
|
58791
58630
|
}
|
|
58792
|
-
async deleteConversation(projectId, conversationId) {
|
|
58631
|
+
async deleteConversation(projectId, conversationId, defaultTitle) {
|
|
58793
58632
|
await this.workspaceStore.deleteConversation(projectId, conversationId);
|
|
58794
58633
|
let remainingConversations = await this.workspaceStore.listConversations(
|
|
58795
58634
|
projectId
|
|
58796
58635
|
);
|
|
58797
58636
|
if (remainingConversations.length === 0) {
|
|
58798
|
-
const replacementConversation = await this.createConversation(
|
|
58637
|
+
const replacementConversation = await this.createConversation(
|
|
58638
|
+
projectId,
|
|
58639
|
+
defaultTitle
|
|
58640
|
+
);
|
|
58799
58641
|
remainingConversations = [replacementConversation];
|
|
58800
58642
|
}
|
|
58801
58643
|
return remainingConversations;
|
|
@@ -58846,7 +58688,7 @@ var ProjectService = class {
|
|
|
58846
58688
|
const conversation = {
|
|
58847
58689
|
id: this.createId(),
|
|
58848
58690
|
projectId: project.id,
|
|
58849
|
-
title:
|
|
58691
|
+
title: normalizeDefaultConversationTitle(input.defaultConversationTitle),
|
|
58850
58692
|
createdAt: timestamp,
|
|
58851
58693
|
updatedAt: timestamp,
|
|
58852
58694
|
messages: []
|
|
@@ -61015,6 +60857,9 @@ function createOwnDesignApp(options = {}) {
|
|
|
61015
60857
|
modelConfigurations
|
|
61016
60858
|
});
|
|
61017
60859
|
const result = await services.projectService.createProject({
|
|
60860
|
+
defaultConversationTitle: getDefaultConversationTitle(
|
|
60861
|
+
input.interfaceLanguage === "en-US" ? "en-US" : "zh-CN"
|
|
60862
|
+
),
|
|
61018
60863
|
name: "helloworld"
|
|
61019
60864
|
});
|
|
61020
60865
|
return context2.json({
|
|
@@ -61030,7 +60875,12 @@ function createOwnDesignApp(options = {}) {
|
|
|
61030
60875
|
if (!trimmedName) {
|
|
61031
60876
|
return context2.json({}, 400);
|
|
61032
60877
|
}
|
|
61033
|
-
const
|
|
60878
|
+
const services = createOwnDesignServices(options);
|
|
60879
|
+
const settings = await services.settingsService.getSettings();
|
|
60880
|
+
const result = await services.projectService.createProject({
|
|
60881
|
+
defaultConversationTitle: getDefaultConversationTitle(
|
|
60882
|
+
settings.interfaceLanguage
|
|
60883
|
+
),
|
|
61034
60884
|
name: trimmedName,
|
|
61035
60885
|
description: asNonEmptyString(body.description)
|
|
61036
60886
|
});
|
|
@@ -61071,7 +60921,12 @@ function createOwnDesignApp(options = {}) {
|
|
|
61071
60921
|
});
|
|
61072
60922
|
app2.post("/api/projects/:projectId/conversations", async (context2) => {
|
|
61073
60923
|
const projectId = context2.req.param("projectId");
|
|
61074
|
-
const
|
|
60924
|
+
const services = createOwnDesignServices(options);
|
|
60925
|
+
const settings = await services.settingsService.getSettings();
|
|
60926
|
+
const conversation = await services.conversationService.createConversation(
|
|
60927
|
+
projectId,
|
|
60928
|
+
getDefaultConversationTitle(settings.interfaceLanguage)
|
|
60929
|
+
);
|
|
61075
60930
|
return context2.json({
|
|
61076
60931
|
href: buildWorkspaceHref({
|
|
61077
60932
|
conversationId: conversation.id,
|
|
@@ -61120,9 +60975,12 @@ function createOwnDesignApp(options = {}) {
|
|
|
61120
60975
|
const projectId = context2.req.param("projectId");
|
|
61121
60976
|
const conversationId = context2.req.param("conversationId");
|
|
61122
60977
|
const currentConversationId = context2.req.query("currentConversationId");
|
|
61123
|
-
const
|
|
60978
|
+
const services = createOwnDesignServices(options);
|
|
60979
|
+
const settings = await services.settingsService.getSettings();
|
|
60980
|
+
const remainingConversations = await services.conversationService.deleteConversation(
|
|
61124
60981
|
projectId,
|
|
61125
|
-
conversationId
|
|
60982
|
+
conversationId,
|
|
60983
|
+
getDefaultConversationTitle(settings.interfaceLanguage)
|
|
61126
60984
|
);
|
|
61127
60985
|
const nextConversationId = currentConversationId === conversationId ? remainingConversations[0]?.id : currentConversationId;
|
|
61128
60986
|
return context2.json({
|
|
@@ -61139,7 +60997,8 @@ function createOwnDesignApp(options = {}) {
|
|
|
61139
60997
|
const conversationId = asNonEmptyString(body.conversationId);
|
|
61140
60998
|
const requestedPreviewPath = asNonEmptyString(body.previewPath);
|
|
61141
60999
|
const pageEditMode = parsePageEditMode(body.pageEditMode);
|
|
61142
|
-
|
|
61000
|
+
const currentUserMessage = createCurrentUserMessage(body.message);
|
|
61001
|
+
if (!projectId || !conversationId || !currentUserMessage) {
|
|
61143
61002
|
return context2.text("Invalid chat request.", 400);
|
|
61144
61003
|
}
|
|
61145
61004
|
if (!pageEditMode) {
|
|
@@ -61155,9 +61014,6 @@ function createOwnDesignApp(options = {}) {
|
|
|
61155
61014
|
if (chatRunManager.getActiveRun(projectId)) {
|
|
61156
61015
|
return context2.text("\u5F53\u524D\u9879\u76EE\u5DF2\u6709\u4EFB\u52A1\u6B63\u5728\u6267\u884C\u3002", 409);
|
|
61157
61016
|
}
|
|
61158
|
-
const incomingMessages = normalizeConversationMessages(
|
|
61159
|
-
body.messages
|
|
61160
|
-
);
|
|
61161
61017
|
let conversation = await workspaceStore.getConversation(
|
|
61162
61018
|
projectId,
|
|
61163
61019
|
conversationId
|
|
@@ -61165,10 +61021,10 @@ function createOwnDesignApp(options = {}) {
|
|
|
61165
61021
|
const storedMessages = normalizeConversationMessages(
|
|
61166
61022
|
conversation.messages
|
|
61167
61023
|
);
|
|
61168
|
-
let messages =
|
|
61169
|
-
storedMessages,
|
|
61170
|
-
|
|
61171
|
-
|
|
61024
|
+
let messages = [
|
|
61025
|
+
...storedMessages,
|
|
61026
|
+
currentUserMessage
|
|
61027
|
+
];
|
|
61172
61028
|
let agentContext;
|
|
61173
61029
|
try {
|
|
61174
61030
|
agentContext = await createDesignPageAgentContext({
|
|
@@ -61591,15 +61447,28 @@ async function readJson(request) {
|
|
|
61591
61447
|
return void 0;
|
|
61592
61448
|
}
|
|
61593
61449
|
}
|
|
61594
|
-
function
|
|
61595
|
-
if (
|
|
61596
|
-
return
|
|
61450
|
+
function createCurrentUserMessage(value) {
|
|
61451
|
+
if (!isRecord2(value)) {
|
|
61452
|
+
return void 0;
|
|
61597
61453
|
}
|
|
61598
|
-
const
|
|
61599
|
-
|
|
61600
|
-
|
|
61601
|
-
|
|
61454
|
+
const id = asNonEmptyString(value.id);
|
|
61455
|
+
const text2 = typeof value.text === "string" ? value.text : "";
|
|
61456
|
+
const files = Array.isArray(value.files) ? value.files.filter(isFileUIPart2) : [];
|
|
61457
|
+
const parts = [
|
|
61458
|
+
...text2 ? [{ text: text2, type: "text" }] : [],
|
|
61459
|
+
...files
|
|
61602
61460
|
];
|
|
61461
|
+
if (!id || parts.length === 0) {
|
|
61462
|
+
return void 0;
|
|
61463
|
+
}
|
|
61464
|
+
return {
|
|
61465
|
+
id,
|
|
61466
|
+
parts,
|
|
61467
|
+
role: "user"
|
|
61468
|
+
};
|
|
61469
|
+
}
|
|
61470
|
+
function isFileUIPart2(value) {
|
|
61471
|
+
return isRecord2(value) && value.type === "file";
|
|
61603
61472
|
}
|
|
61604
61473
|
async function rewriteLastUserMessageForDesignAgent({
|
|
61605
61474
|
agentContext,
|