owndesign 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/dist/index.js +1 -2
  2. package/dist/server/index.js +453 -584
  3. package/dist/web/assets/{angular-html-jsvfn4Rt.js → angular-html-CoTKBCTn.js} +1 -1
  4. package/dist/web/assets/{angular-ts-DJPGWFWG.js → angular-ts-B6lkmQt5.js} +1 -1
  5. package/dist/web/assets/{apl-CrzMWZIQ.js → apl-DdUDDcTX.js} +1 -1
  6. package/dist/web/assets/{arc-Bn4NjwpQ.js → arc-CpC_-kIU.js} +1 -1
  7. package/dist/web/assets/architecture-7EHR7CIX-BuetZCIk.js +1 -0
  8. package/dist/web/assets/{architectureDiagram-3BPJPVTR-CHuzKteg.js → architectureDiagram-3BPJPVTR-BFC9sw4f.js} +1 -1
  9. package/dist/web/assets/{astro-B7XSlDgT.js → astro-D8dj_1e3.js} +1 -1
  10. package/dist/web/assets/{blade-FbLBnnn0.js → blade-BOBPcO2h.js} +1 -1
  11. package/dist/web/assets/{blockDiagram-GPEHLZMM-D-s6XCnt.js → blockDiagram-GPEHLZMM-Dm-IZ0OK.js} +1 -1
  12. package/dist/web/assets/{c-BXLwv45V.js → c-BuJlpWo1.js} +1 -1
  13. package/dist/web/assets/{c4Diagram-AAUBKEIU-suyA814q.js → c4Diagram-AAUBKEIU-D_naMOBh.js} +1 -1
  14. package/dist/web/assets/channel-CD2ivr_e.js +1 -0
  15. package/dist/web/assets/{chunk-2J33WTMH-B1BjDPc8.js → chunk-2J33WTMH-Br9TjHyg.js} +1 -1
  16. package/dist/web/assets/{chunk-4BX2VUAB-CaKhvcR-.js → chunk-4BX2VUAB-BKXeBOxn.js} +1 -1
  17. package/dist/web/assets/{chunk-55IACEB6-rDi25oNw.js → chunk-55IACEB6-D3MxtENu.js} +1 -1
  18. package/dist/web/assets/{chunk-727SXJPM-DbTxAzFr.js → chunk-727SXJPM-9i7OtYmm.js} +1 -1
  19. package/dist/web/assets/{chunk-AQP2D5EJ-Cx54fayY.js → chunk-AQP2D5EJ-C1rNd_R7.js} +1 -1
  20. package/dist/web/assets/{chunk-FMBD7UC4-D0cOuWPI.js → chunk-FMBD7UC4-fJyYpXV-.js} +1 -1
  21. package/dist/web/assets/{chunk-ND2GUHAM-DE9Fzr-c.js → chunk-ND2GUHAM-DNlEVqx2.js} +1 -1
  22. package/dist/web/assets/chunk-QZHKN3VN-Bf-N5Jmd.js +1 -0
  23. package/dist/web/assets/classDiagram-4FO5ZUOK-F8ONWgXY.js +1 -0
  24. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-F8ONWgXY.js +1 -0
  25. package/dist/web/assets/{cobol-GYycObeh.js → cobol-ClEhNYgi.js} +1 -1
  26. package/dist/web/assets/{coffee-DpR39k3Z.js → coffee-DKH3A-3k.js} +1 -1
  27. package/dist/web/assets/{cose-bilkent-S5V4N54A-HMWRsi3j.js → cose-bilkent-S5V4N54A-CKEXfMFa.js} +1 -1
  28. package/dist/web/assets/{cpp-BVpb95O2.js → cpp-Dg0_NLWR.js} +1 -1
  29. package/dist/web/assets/{crystal--BRTwmLk.js → crystal-B-pl8MQM.js} +1 -1
  30. package/dist/web/assets/{css-CtgfTqN7.js → css-Q2XFe7KV.js} +1 -1
  31. package/dist/web/assets/{dagre-BM42HDAG-BmP8Xfpr.js → dagre-BM42HDAG-CGLXhpG-.js} +1 -1
  32. package/dist/web/assets/{diagram-2AECGRRQ-CaOzrqeF.js → diagram-2AECGRRQ-Yz0i_67x.js} +1 -1
  33. package/dist/web/assets/{diagram-5GNKFQAL-DTur4WjM.js → diagram-5GNKFQAL-BnSJ2Z2M.js} +1 -1
  34. package/dist/web/assets/{diagram-KO2AKTUF-DPqtezbZ.js → diagram-KO2AKTUF-B15W-hhD.js} +1 -1
  35. package/dist/web/assets/{diagram-LMA3HP47-ChfIjJjB.js → diagram-LMA3HP47-BLsYWrS9.js} +1 -1
  36. package/dist/web/assets/{diagram-OG6HWLK6-mElCK9q8.js → diagram-OG6HWLK6-73omsPnV.js} +1 -1
  37. package/dist/web/assets/{edge-qTMbtksj.js → edge-Dhh-Fs5C.js} +1 -1
  38. package/dist/web/assets/{elixir-D3ulijxT.js → elixir-COHWreUF.js} +1 -1
  39. package/dist/web/assets/{elm-tsW4I1jV.js → elm-CYxhy8U2.js} +1 -1
  40. package/dist/web/assets/{erDiagram-TEJ5UH35-yRD3kuoC.js → erDiagram-TEJ5UH35-a5r4A3JM.js} +1 -1
  41. package/dist/web/assets/{erb-BA-HEniM.js → erb-Dl2ohr-E.js} +1 -1
  42. package/dist/web/assets/eventmodeling-FCH6USID-C5QIAlur.js +1 -0
  43. package/dist/web/assets/{flowDiagram-I6XJVG4X-B6OtVWCG.js → flowDiagram-I6XJVG4X-Dmc3vUIl.js} +1 -1
  44. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BKQELgWf.js → ganttDiagram-6RSMTGT7-CRZVm0L0.js} +1 -1
  45. package/dist/web/assets/{git-rebase-BaeXTags.js → git-rebase-DpESal6m.js} +1 -1
  46. package/dist/web/assets/gitGraph-WXDBUCRP-Broa5-99.js +1 -0
  47. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DLFySfm6.js → gitGraphDiagram-PVQCEYII-DhRyyOcn.js} +1 -1
  48. package/dist/web/assets/{glimmer-js-D99CurU1.js → glimmer-js-X_N0IQZ1.js} +1 -1
  49. package/dist/web/assets/{glimmer-ts-DiXlCbsk.js → glimmer-ts-CoiHLEBh.js} +1 -1
  50. package/dist/web/assets/{glsl-BesQQ3D3.js → glsl-jTdcbPse.js} +1 -1
  51. package/dist/web/assets/{graphql-WTzBw63J.js → graphql-CSN8TYN_.js} +1 -1
  52. package/dist/web/assets/{hack-CgMBYqE_.js → hack-Dv67vUdK.js} +1 -1
  53. package/dist/web/assets/{haml-CVkZ8xGr.js → haml-BFAyoHic.js} +1 -1
  54. package/dist/web/assets/{handlebars-DEZhToSV.js → handlebars-DsO_0Mb7.js} +1 -1
  55. package/dist/web/assets/{highlighted-body-OFNGDK62-C1vbmqaL.js → highlighted-body-OFNGDK62-Bsqvzkqq.js} +1 -1
  56. package/dist/web/assets/{html-derivative-C6yFe2Kr.js → html-derivative-nsyf9xDk.js} +1 -1
  57. package/dist/web/assets/{html-CZY9Keai.js → html-hcrGAGxi.js} +1 -1
  58. package/dist/web/assets/{http-B-YQYmoh.js → http-CQ7kMaQ9.js} +1 -1
  59. package/dist/web/assets/{hurl-DwCR30Gk.js → hurl-w8EbNg5E.js} +1 -1
  60. package/dist/web/assets/{index-RGvTNHCk.js → index-DAN9Q3vY.js} +178 -178
  61. package/dist/web/assets/info-J43DQDTF-5yru-lYW.js +1 -0
  62. package/dist/web/assets/{infoDiagram-5YYISTIA-FbnwyL1q.js → infoDiagram-5YYISTIA-C2F76qt2.js} +1 -1
  63. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DifZwUFe.js → ishikawaDiagram-YF4QCWOH-CZ272mnP.js} +1 -1
  64. package/dist/web/assets/{java-DQDexwWI.js → java-BL-j72lp.js} +1 -1
  65. package/dist/web/assets/{javascript-m4oKbUOH.js → javascript-D-RCZsZB.js} +1 -1
  66. package/dist/web/assets/{jinja-bMd7FxcZ.js → jinja-3re3UTai.js} +1 -1
  67. package/dist/web/assets/{jison-Donet0uo.js → jison-aPrUrs4_.js} +1 -1
  68. package/dist/web/assets/{journeyDiagram-JHISSGLW-CEWe0m8S.js → journeyDiagram-JHISSGLW-Kbp9PKPx.js} +1 -1
  69. package/dist/web/assets/{json-DvDVCJtO.js → json-DVgA95cK.js} +1 -1
  70. package/dist/web/assets/{jsx-DqXV0M3u.js → jsx-CTgF7iub.js} +1 -1
  71. package/dist/web/assets/{julia-BLIZFOZF.js → julia-Deji7okx.js} +1 -1
  72. package/dist/web/assets/{just-CBmUd3mb.js → just-CaYOtqeh.js} +1 -1
  73. package/dist/web/assets/{kanban-definition-UN3LZRKU-BP7cxrre.js → kanban-definition-UN3LZRKU-zVFckm48.js} +1 -1
  74. package/dist/web/assets/{latex-Cy1xyr0T.js → latex-DjTDu_8e.js} +1 -1
  75. package/dist/web/assets/{linear-CjIRJFVE.js → linear-HBblcI1g.js} +1 -1
  76. package/dist/web/assets/{liquid-DOWkRs5J.js → liquid-BcpQGDFc.js} +1 -1
  77. package/dist/web/assets/{lua-2D444Lxv.js → lua-CuYpYTBI.js} +1 -1
  78. package/dist/web/assets/{marko-B2Dmq5Yz.js → marko-DgfLsR3g.js} +1 -1
  79. package/dist/web/assets/{mdc-DEaLIxN0.js → mdc-CJyxXGTG.js} +1 -1
  80. package/dist/web/assets/mermaid-GHXKKRXX-tc_NirJc.js +1 -0
  81. package/dist/web/assets/{mermaid-parser.core-Dmmi41d9.js → mermaid-parser.core-I66T9jsL.js} +2 -2
  82. package/dist/web/assets/{mindmap-definition-RKZ34NQL-CdNWcprP.js → mindmap-definition-RKZ34NQL-DaGOAyRB.js} +1 -1
  83. package/dist/web/assets/{nginx-CeAvtuC8.js → nginx-BoUl7sBZ.js} +1 -1
  84. package/dist/web/assets/{nim-BqlmNno2.js → nim-CrEFP-aj.js} +1 -1
  85. package/dist/web/assets/packet-YPE3B663-eYBiCMjG.js +1 -0
  86. package/dist/web/assets/{perl-D7NeCsVf.js → perl-CZELP4Ds.js} +1 -1
  87. package/dist/web/assets/{php-D5zmfZnA.js → php-CWKE0mzg.js} +1 -1
  88. package/dist/web/assets/pie-LRSECV5Y-CEs_o2N-.js +1 -0
  89. package/dist/web/assets/{pieDiagram-4H26LBE5-DAmVxi-T.js → pieDiagram-4H26LBE5-CZEnKsEr.js} +1 -1
  90. package/dist/web/assets/{pug-V7ao1GPA.js → pug-ZalflcaW.js} +1 -1
  91. package/dist/web/assets/{qml-Bm2ZBf1J.js → qml-D8g9QUr3.js} +1 -1
  92. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DisJQ6k7.js → quadrantDiagram-W4KKPZXB-DsVGBWIs.js} +1 -1
  93. package/dist/web/assets/{r-D97_-xYI.js → r-t-w7nxIu.js} +1 -1
  94. package/dist/web/assets/radar-GUYGQ44K-D6SysS4p.js +1 -0
  95. package/dist/web/assets/{razor-DSkw2G0O.js → razor-KKTzZ9mx.js} +1 -1
  96. package/dist/web/assets/{regexp-Bc_HmDkA.js → regexp-a1jUuWbn.js} +1 -1
  97. package/dist/web/assets/{requirementDiagram-4Y6WPE33-BGeUfRNj.js → requirementDiagram-4Y6WPE33-BTfqkfe2.js} +1 -1
  98. package/dist/web/assets/{rst-HeE3bPLr.js → rst-aqfBGGXb.js} +1 -1
  99. package/dist/web/assets/{ruby-D1hbEP5U.js → ruby-BEZTW4wN.js} +1 -1
  100. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-DxkCaEDD.js → sankeyDiagram-5OEKKPKP-DypLejq4.js} +1 -1
  101. package/dist/web/assets/{sas-B5odaEYk.js → sas-C6p8OBCV.js} +1 -1
  102. package/dist/web/assets/{scss-DAOx_LcY.js → scss-C8GTc8vc.js} +1 -1
  103. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BjyW4Lrn.js → sequenceDiagram-3UESZ5HK-DNDK0sjs.js} +1 -1
  104. package/dist/web/assets/{shellscript-C12cH9Wq.js → shellscript-CDcqP7X6.js} +1 -1
  105. package/dist/web/assets/{shellsession-B9R0VJUT.js → shellsession-CWzpCh1C.js} +1 -1
  106. package/dist/web/assets/{soy-Bw9Ab61t.js → soy-CepCYBkA.js} +1 -1
  107. package/dist/web/assets/{sql-BuNNSgJh.js → sql-CAysnE0k.js} +1 -1
  108. package/dist/web/assets/{stata-DKqDiYZE.js → stata-BGr_WZqN.js} +1 -1
  109. package/dist/web/assets/{stateDiagram-AJRCARHV-BULieDpc.js → stateDiagram-AJRCARHV-CnSW064B.js} +1 -1
  110. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BtuE7Ay0.js +1 -0
  111. package/dist/web/assets/{surrealql-CmO_9B8u.js → surrealql-C7gNmBEt.js} +1 -1
  112. package/dist/web/assets/{svelte-mVjE-waC.js → svelte-D-4kj-uB.js} +1 -1
  113. package/dist/web/assets/{templ-C536sOWS.js → templ-BP_fNCUb.js} +1 -1
  114. package/dist/web/assets/{tex-noYEVnyG.js → tex-vDHHhfH8.js} +1 -1
  115. package/dist/web/assets/{timeline-definition-PNZ67QCA-gCvdo5yW.js → timeline-definition-PNZ67QCA-RE08Mx9v.js} +1 -1
  116. package/dist/web/assets/treeView-BLDUP644-DEYw0jRo.js +1 -0
  117. package/dist/web/assets/treemap-LRROVOQU-BaQ1oGDR.js +1 -0
  118. package/dist/web/assets/{ts-tags-BHLoJadi.js → ts-tags-BhUtB8KF.js} +1 -1
  119. package/dist/web/assets/{tsx-D0BqKins.js → tsx-CYOMJ3wf.js} +1 -1
  120. package/dist/web/assets/{twig-BazH_M3o.js → twig-DMJPvFzt.js} +1 -1
  121. package/dist/web/assets/{typescript-zAIgs1Bg.js → typescript-JJOZ5Q74.js} +1 -1
  122. package/dist/web/assets/{vennDiagram-CIIHVFJN-_GmnWXrN.js → vennDiagram-CIIHVFJN-CTiIiyn-.js} +1 -1
  123. package/dist/web/assets/{vue-DiStCAGA.js → vue-D6hN_u9i.js} +1 -1
  124. package/dist/web/assets/{vue-html-BycBfJiP.js → vue-html-B8MKJvvw.js} +1 -1
  125. package/dist/web/assets/{vue-vine-Bzt8hn7y.js → vue-vine-BZtSJFfi.js} +1 -1
  126. package/dist/web/assets/wardley-L42UT6IY-F8LWMBYs.js +1 -0
  127. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CQDeXjJA.js → wardleyDiagram-YWT4CUSO-CpT1RVZp.js} +1 -1
  128. package/dist/web/assets/{xml-DKXhkAsJ.js → xml-Detdg-FS.js} +1 -1
  129. package/dist/web/assets/{xsl-CNq-a0yX.js → xsl-CWUN_pbH.js} +1 -1
  130. package/dist/web/assets/{xychartDiagram-2RQKCTM6-ClV8rcpV.js → xychartDiagram-2RQKCTM6-C8BtIz3X.js} +1 -1
  131. package/dist/web/assets/{yaml-BdbHds_c.js → yaml-8W-QgFv_.js} +1 -1
  132. package/dist/web/favicon.ico +0 -0
  133. package/dist/web/index.html +1 -1
  134. package/package.json +1 -1
  135. package/dist/web/assets/architecture-7EHR7CIX-Dmcr3pOj.js +0 -1
  136. package/dist/web/assets/channel-lKa7V-Vy.js +0 -1
  137. package/dist/web/assets/chunk-QZHKN3VN-CLLRYgAk.js +0 -1
  138. package/dist/web/assets/classDiagram-4FO5ZUOK-BGMCFaw3.js +0 -1
  139. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BGMCFaw3.js +0 -1
  140. package/dist/web/assets/eventmodeling-FCH6USID-1xLvS7Py.js +0 -1
  141. package/dist/web/assets/gitGraph-WXDBUCRP-DDLWLcGD.js +0 -1
  142. package/dist/web/assets/info-J43DQDTF-qGIMNcUJ.js +0 -1
  143. package/dist/web/assets/mermaid-GHXKKRXX-CQXzNDpn.js +0 -1
  144. package/dist/web/assets/packet-YPE3B663-ChxpMni-.js +0 -1
  145. package/dist/web/assets/pie-LRSECV5Y-y5EjkD0h.js +0 -1
  146. package/dist/web/assets/radar-GUYGQ44K-Du-8nFyw.js +0 -1
  147. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-IQQ2dYr9.js +0 -1
  148. package/dist/web/assets/treeView-BLDUP644-D-0UN-Tb.js +0 -1
  149. package/dist/web/assets/treemap-LRROVOQU-CaUFuBcw.js +0 -1
  150. package/dist/web/assets/wardley-L42UT6IY-C-z6FcCV.js +0 -1
@@ -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/realtime/frontend-capabilities.ts
56632
- var FRONTEND_CAPABILITIES = {
56633
- "preview.refresh": {
56634
- description: "Refresh the current Preview Pane without changing HTML file.",
56635
- payloadSchema: {
56636
- type: "object",
56637
- properties: {},
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
- "preview.switchHtml": {
56642
- description: "Switch the Preview Pane to an existing HTML file.",
56643
- payloadSchema: {
56644
- type: "object",
56645
- properties: {
56646
- path: {
56647
- type: "string",
56648
- description: "Relative HTML file path inside the Project Workspace to show in the Preview Pane."
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
- function getFrontendCommandBus() {
56793
- globalThis.__owndesignFrontendCommandBus ??= new FrontendCommandBus();
56794
- return globalThis.__owndesignFrontendCommandBus;
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 createCommandId() {
56823
- return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
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/call-frontend-capability.ts
57248
- function createCallFrontendCapabilityToolDefinition() {
57114
+ // ../core/src/agent/tools/copy-file.ts
57115
+ function createCopyFileToolDefinition() {
57249
57116
  return {
57250
- description: "Call a fixed frontend browser capability for the active tab, such as switching or refreshing the Preview Pane.",
57251
- inputSchema: {
57252
- type: "object",
57253
- properties: {
57254
- capability: {
57255
- type: "string",
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 (input, context2) => {
57270
- if (!context2.frontendTabId) {
57271
- throw new Error("Frontend tab id is required to call frontend capabilities.");
57272
- }
57273
- if (!isFrontendCapabilityId(input.capability)) {
57274
- throw new Error(`Unknown frontend capability: ${input.capability}`);
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 payload = await normalizePayload(input.capability, input.payload, context2);
57277
- const result = sendCapabilityCommand(input.capability, payload, context2);
57278
- return {
57279
- capability: input.capability,
57280
- delivered: result?.delivered ?? false,
57281
- payload
57282
- };
57283
- }
57284
- };
57285
- }
57286
- async function normalizePayload(capability, payload, context2) {
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
- type: "object",
57435
- properties: {
57436
- fontLibraryName: {
57437
- type: "string",
57438
- description: "Optional configured font library name. Omit to use the default font library. Pass an empty string to disable font resources."
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
- type: "object",
57576
- properties: {
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
- type: "object",
57604
- properties: {
57605
- newString: {
57606
- type: "string",
57607
- description: "Replacement text."
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
- type: "object",
57657
- properties: {
57658
- path: {
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
- type: "object",
57691
- properties: {
57692
- include: {
57693
- type: "string",
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
- type: "object",
57728
- properties: {
57729
- changes: {
57730
- type: "array",
57731
- minItems: 1,
57732
- items: {
57733
- type: "object",
57734
- properties: {
57735
- content: {
57736
- type: "string",
57737
- description: "Complete file content for add or write operations."
57738
- },
57739
- newString: {
57740
- type: "string",
57741
- description: "Replacement text for edit operations."
57742
- },
57743
- oldString: {
57744
- type: "string",
57745
- description: "Text to replace for edit operations."
57746
- },
57747
- operation: {
57748
- type: "string",
57749
- enum: ["add", "write", "edit", "delete"]
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
- function validatePatchInput(input) {
57790
- if (!Array.isArray(input.changes) || input.changes.length === 0) {
57791
- throw new Error("patch.changes must include at least one change.");
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
- for (const [index, change] of input.changes.entries()) {
57794
- const label = `patch.changes[${index}]`;
57795
- if (!change.path) {
57796
- throw new Error(`${label}.path must not be empty.`);
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
- if (change.operation === "edit") {
57799
- if (typeof change.oldString !== "string" || typeof change.newString !== "string") {
57800
- throw new Error(`${label} edit changes require oldString and newString.`);
57801
- }
57802
- if ("content" in change) {
57803
- throw new Error(`${label} edit changes must not include content.`);
57804
- }
57805
- continue;
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
- if (change.operation === "add" || change.operation === "write") {
57808
- if (typeof change.content !== "string") {
57809
- throw new Error(`${label} ${change.operation} changes require content.`);
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
- if ("oldString" in change || "newString" in change || "replaceAll" in change) {
57812
- throw new Error(`${label} ${change.operation} changes must not include edit fields.`);
57601
+ const targetPath = normalizeToolPath(path16);
57602
+ if (!targetPath || targetPath === ".") {
57603
+ throw new Error("Preview switch target path must not be empty.");
57813
57604
  }
57814
- continue;
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
- continue;
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
- throw new Error(`${label}.operation is not supported.`);
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
- type: "object",
57832
- properties: {
57833
- limit: {
57834
- type: "number",
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
- type: "object",
57873
- properties: {
57874
- content: {
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 = "\u65B0\u5EFA\u4F1A\u8BDD";
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: DEFAULT_CONVERSATION_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(projectId);
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: "\u65B0\u5EFA\u4F1A\u8BDD",
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 result = await createProjectService(options).createProject({
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 conversation = await createConversationService(options).createConversation(projectId);
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 remainingConversations = await createConversationService(options).deleteConversation(
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
- if (!projectId || !conversationId || !Array.isArray(body.messages)) {
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 = mergeStoredAndIncomingMessages(
61169
- storedMessages,
61170
- incomingMessages
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 mergeStoredAndIncomingMessages(storedMessages, incomingMessages) {
61595
- if (storedMessages.length === 0) {
61596
- return incomingMessages;
61450
+ function createCurrentUserMessage(value) {
61451
+ if (!isRecord2(value)) {
61452
+ return void 0;
61597
61453
  }
61598
- const storedIds = new Set(storedMessages.map((message) => message.id));
61599
- return [
61600
- ...storedMessages,
61601
- ...incomingMessages.filter((message) => !storedIds.has(message.id))
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,