@adminide-stack/yantra-mobile 12.0.173 → 12.0.174-alpha.1

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 (140) hide show
  1. package/lib/compute.js +54 -1
  2. package/lib/compute.js.map +1 -1
  3. package/lib/features/apps/AppsCatalog.js +10 -0
  4. package/lib/features/apps/AppsCatalog.js.map +1 -1
  5. package/lib/features/apps/mobileAppCatalog.js +6 -1
  6. package/lib/features/apps/mobileAppCatalog.js.map +1 -1
  7. package/lib/features/apps/nativeAppHandoff.js +4 -1
  8. package/lib/features/apps/nativeAppHandoff.js.map +1 -1
  9. package/lib/features/apps/nativeSurfaceTwin.js +2 -1
  10. package/lib/features/apps/nativeSurfaceTwin.js.map +1 -1
  11. package/lib/features/channels/ChannelIcon.js +13 -3
  12. package/lib/features/channels/ChannelIcon.js.map +1 -1
  13. package/lib/features/channels/ConnectAppsSheet.js +5 -5
  14. package/lib/features/channels/ConnectAppsSheet.js.map +1 -1
  15. package/lib/features/channels/HomeImessage.js +5 -3
  16. package/lib/features/channels/HomeImessage.js.map +1 -1
  17. package/lib/features/channels/channelLinks.js +13 -1
  18. package/lib/features/channels/channelLinks.js.map +1 -1
  19. package/lib/features/computer/ComputerAgentChatPane.js +45 -0
  20. package/lib/features/computer/ComputerAgentChatPane.js.map +1 -0
  21. package/lib/features/computer/ComputerDesktop.js +164 -0
  22. package/lib/features/computer/ComputerDesktop.js.map +1 -0
  23. package/lib/features/computer/ComputerExperience.js +79 -0
  24. package/lib/features/computer/ComputerExperience.js.map +1 -0
  25. package/lib/features/computer/ComputerHandoff.js +142 -0
  26. package/lib/features/computer/ComputerHandoff.js.map +1 -0
  27. package/lib/features/computer/FilesPane.js +179 -0
  28. package/lib/features/computer/FilesPane.js.map +1 -0
  29. package/lib/features/computer/LivePage.js +1093 -0
  30. package/lib/features/computer/LivePage.js.map +1 -0
  31. package/lib/features/computer/TerminalPane.js +139 -0
  32. package/lib/features/computer/TerminalPane.js.map +1 -0
  33. package/lib/features/computer/computerApi.js +819 -0
  34. package/lib/features/computer/computerApi.js.map +1 -0
  35. package/lib/features/computer/computerChat.js +42 -0
  36. package/lib/features/computer/computerChat.js.map +1 -0
  37. package/lib/features/computer/computerControls.js +227 -0
  38. package/lib/features/computer/computerControls.js.map +1 -0
  39. package/lib/features/computer/computerStyles.js +384 -0
  40. package/lib/features/computer/computerStyles.js.map +1 -0
  41. package/lib/features/computer/computerTheme.js +133 -0
  42. package/lib/features/computer/computerTheme.js.map +1 -0
  43. package/lib/features/computer/handoff.js +73 -0
  44. package/lib/features/computer/handoff.js.map +1 -0
  45. package/lib/features/computer/inputLane.js +171 -0
  46. package/lib/features/computer/inputLane.js.map +1 -0
  47. package/lib/features/computer/inputPump.js +77 -0
  48. package/lib/features/computer/inputPump.js.map +1 -0
  49. package/lib/features/computer/inputSocket.js +148 -0
  50. package/lib/features/computer/inputSocket.js.map +1 -0
  51. package/lib/features/computer/keyboardBridge.js +176 -0
  52. package/lib/features/computer/keyboardBridge.js.map +1 -0
  53. package/lib/features/computer/pageCoordinates.js +19 -0
  54. package/lib/features/computer/pageCoordinates.js.map +1 -0
  55. package/lib/features/computer/pageZoom.js +12 -0
  56. package/lib/features/computer/pageZoom.js.map +1 -0
  57. package/lib/features/computer/pictureGeometry.js +68 -0
  58. package/lib/features/computer/pictureGeometry.js.map +1 -0
  59. package/lib/features/computer/tabsState.js +7 -0
  60. package/lib/features/computer/tabsState.js.map +1 -0
  61. package/lib/features/computer/useComputerHooks.js +146 -0
  62. package/lib/features/computer/useComputerHooks.js.map +1 -0
  63. package/lib/features/games/cubeforgeFriends.js +14 -1
  64. package/lib/features/games/cubeforgeFriends.js.map +1 -1
  65. package/lib/features/games/useCubeforgeFriends.js +5 -2
  66. package/lib/features/games/useCubeforgeFriends.js.map +1 -1
  67. package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +146 -37
  68. package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -1
  69. package/lib/features/games/vendored/ui/theme.js +3 -1
  70. package/lib/features/games/vendored/ui/theme.js.map +1 -1
  71. package/lib/features/links/openInApp.js +10 -1
  72. package/lib/features/links/openInApp.js.map +1 -1
  73. package/lib/features/webbuilder/WebBuilderExperience.js +180 -44
  74. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  75. package/lib/features/webbuilder/buildFragments.js +16 -3
  76. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  77. package/lib/features/webbuilder/codezenHandoff.js +29 -1
  78. package/lib/features/webbuilder/codezenHandoff.js.map +1 -1
  79. package/lib/features/webbuilder/components/CodeView.js +69 -23
  80. package/lib/features/webbuilder/components/CodeView.js.map +1 -1
  81. package/lib/features/webbuilder/components/PreviewFrame.js +62 -2
  82. package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
  83. package/lib/features/webbuilder/components/PreviewScreen.js +37 -2
  84. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  85. package/lib/features/webbuilder/components/ProjectChat.js +2 -1
  86. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  87. package/lib/features/webbuilder/components/ProjectSheets.js +147 -57
  88. package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
  89. package/lib/features/webbuilder/components/PublishSheet.js +106 -2
  90. package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
  91. package/lib/features/webbuilder/components/ReferenceModeChoice.js +105 -0
  92. package/lib/features/webbuilder/components/ReferenceModeChoice.js.map +1 -0
  93. package/lib/features/webbuilder/components/RetentionBanner.js +17 -6
  94. package/lib/features/webbuilder/components/RetentionBanner.js.map +1 -1
  95. package/lib/features/webbuilder/components/SiteUploadSheet.js +327 -0
  96. package/lib/features/webbuilder/components/SiteUploadSheet.js.map +1 -0
  97. package/lib/features/webbuilder/components/StreamStallNote.js +38 -0
  98. package/lib/features/webbuilder/components/StreamStallNote.js.map +1 -0
  99. package/lib/features/webbuilder/components/StudioHome.js +18 -8
  100. package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
  101. package/lib/features/webbuilder/previewRoutes.js +30 -1
  102. package/lib/features/webbuilder/previewRoutes.js.map +1 -1
  103. package/lib/features/webbuilder/studioCatalog.js +9 -2
  104. package/lib/features/webbuilder/studioCatalog.js.map +1 -1
  105. package/lib/features/webbuilder/web/chat/referenceMode.js +11 -0
  106. package/lib/features/webbuilder/web/chat/referenceMode.js.map +1 -0
  107. package/lib/features/webbuilder/web/chat/siteCopy.js +5 -2
  108. package/lib/features/webbuilder/web/chat/siteCopy.js.map +1 -1
  109. package/lib/features/webbuilder/web/chat/streamStall.js +6 -0
  110. package/lib/features/webbuilder/web/chat/streamStall.js.map +1 -0
  111. package/lib/features/webbuilder/web/code/savedCode.js +7 -0
  112. package/lib/features/webbuilder/web/code/savedCode.js.map +1 -0
  113. package/lib/features/webbuilder/web/design/directions.js.map +1 -1
  114. package/lib/features/webbuilder/web/history/versions.js.map +1 -1
  115. package/lib/features/webbuilder/web/import/websiteImport.js +27 -0
  116. package/lib/features/webbuilder/web/import/websiteImport.js.map +1 -0
  117. package/lib/features/webbuilder/web/preview/setupPhase.js +31 -0
  118. package/lib/features/webbuilder/web/preview/setupPhase.js.map +1 -0
  119. package/lib/features/webbuilder/web/publish/siteInsights.js +23 -1
  120. package/lib/features/webbuilder/web/publish/siteInsights.js.map +1 -1
  121. package/lib/features/webbuilder/web/upload/sitePhotos.js +102 -0
  122. package/lib/features/webbuilder/web/upload/sitePhotos.js.map +1 -0
  123. package/lib/routes.json +54 -0
  124. package/lib/screens/ComputerNative/index.js +124 -0
  125. package/lib/screens/ComputerNative/index.js.map +1 -0
  126. package/lib/screens/ComputerNative/useComputerHostChat.js +83 -0
  127. package/lib/screens/ComputerNative/useComputerHostChat.js.map +1 -0
  128. package/lib/screens/GamesNative/index.js +1 -1
  129. package/lib/screens/GamesNative/index.js.map +1 -1
  130. package/lib/screens/Home/components/homeCatalog.js +2 -1
  131. package/lib/screens/Home/components/homeCatalog.js.map +1 -1
  132. package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +6 -2
  133. package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -1
  134. package/lib/screens/WebBuilderNative/index.js +15 -3
  135. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  136. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +18 -3
  137. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  138. package/lib/screens/WebBuilderNative/webbuilderTransport.js +16 -7
  139. package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
  140. package/package.json +4 -4
@@ -129,7 +129,7 @@ function displayAgentText(text) {
129
129
  const link = sandboxLinkSource(publicSandboxDomain());
130
130
  return (
131
131
  // The agent's [ASK_USER] question is a card, not prose (also while it streams).
132
- rewritePagesDevLinks(renderWidgetBlocks(stripAskUser(text))).replace(/(restore point) \(snapshot `[^`]+`\)/gi, "$1").replace(/\s*\(preview `[^`]+`\)/gi, "").replace(/^[ \t>]*⚠?\s*billing policy check unavailable\b[^\n]*\n?/gim, "").replace(new RegExp(String.raw`\[([^\]]+)\]\(${link}\)`, "gi"), "$1").replace(new RegExp(String.raw`:?[ \t]*<?${link}>?`, "gi"), "").replace(/^[ \t>*_-]*(?:\*\*)?live preview:?(?:\*\*)?[ \t]*(?:\n|$)/gim, "").trim()
132
+ rewritePagesDevLinks(renderWidgetBlocks(stripAskUser(text))).replace(/\s*\(snapshot `[^`]*(?:`\)?|$)/gi, "").replace(/\s*`[a-z0-9][\w.-]*\/[\w.-]+:default`/gi, "").replace(/\s*\(preview `[^`]*(?:`\)?|$)/gi, "").replace(/^[ \t>]*⚠?\s*billing policy check unavailable\b[^\n]*\n?/gim, "").replace(new RegExp(String.raw`\[([^\]]+)\]\(${link}\)`, "gi"), "$1").replace(new RegExp(String.raw`:?[ \t]*<?${link}>?`, "gi"), "").replace(/^[ \t>*_-]*(?:\*\*)?live preview:?(?:\*\*)?[ \t]*(?:\n|$)/gim, "").trim()
133
133
  );
134
134
  }
135
135
  function linkFragment(post) {
@@ -220,13 +220,13 @@ function pendingWork(posts) {
220
220
  function isGenericTitle(title) {
221
221
  const t = (title || "").trim().toLowerCase();
222
222
  return !t || t === "generated page" || t === "generated project" || t === "generated with cdecli" || t === "ai assistant" || t === "web app" || // The placeholder a site carries before it has a name; a saved one is not a rename.
223
- /^new (site|app)$/.test(t) || /^build \d+$/.test(t) || /^build\s+me\b/.test(t) || /^remix\s+the\b/.test(t) || /^(build|chat)[- ]channel\b/.test(t) || t.startsWith("selected skill") || /^code[\s_-]?assist/.test(t);
223
+ /^new (site|app)$/.test(t) || /^build \d+$/.test(t) || /^build\s+me\b/.test(t) || /^remix\s+the\b/.test(t) || /^(build|chat)[- ]channel\b/.test(t) || /^deep-search-[0-9a-f]{8}-/.test(t) || t.startsWith("selected skill") || /^code[\s_-]?assist/.test(t);
224
224
  }
225
225
  const TITLE_STOP_WORDS = /* @__PURE__ */ new Set(["a", "an", "the", "create", "build", "make", "please", "me", "my", "for", "with", "simple", "using", "from", "template", "to", "and", "or", "remix", "yantra"]);
226
226
  function titleCase(words) {
227
227
  return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ");
228
228
  }
229
- const KNOWN_NOTE_RE = /^\[(?:Project channelId=[^\]\n]*|Database slug=[^\]\n]*|\d+ attachment\(s\)|Mode: [a-z]+|Project instructions|Approved plan|Reference site|UI kit|Style direction|Database|AI in the app|Integrations|Element|Fix error|Hand edits|Open build|Open site|Inspired by|New site|Template|Brand kit|Imported project|Export|Asset|Figma|File text|Mentions|Draft|Image edit)\]/;
229
+ const KNOWN_NOTE_RE = /^\[(?:Project channelId=[^\]\n]*|Database slug=[^\]\n]*|\d+ attachment\(s\)|Mode: [a-z]+|Project instructions|Approved plan|Reference site|UI kit|Style direction|Database|AI in the app|Integrations|Element|Fix error|Hand edits|Open build|Open site|Inspired by|New site|Template|Brand kit|Imported project|Export|Asset|Figma|File text|Mentions|Draft|Image edit|Site media)\]/;
230
230
  const NOTE_LINE_RE = /^\[(?:[A-Z][A-Za-z]*(?: [A-Za-z]+){0,3}|[A-Z][A-Za-z ]*=[^\]\n]*|\d+ attachment\(s\))\]/;
231
231
  const LEGACY_BRAND_BLOCK_RE = /^Brand kit \(follow it\):\s*$/;
232
232
  const REFERENCE_WRAPPER_RE = /^Using “[^”]*” as reference \(do not edit that sandbox\)\.\nCreate a new app from the user request below\.\n\n/;
@@ -286,10 +286,23 @@ function businessNameFrom(text) {
286
286
  }
287
287
  return null;
288
288
  }
289
+ const OWN_BUSINESS_NAME_RE = /\b(?:my|our)\s+(?:bakery|cafe|café|coffee shop|restaurant|shop|store|boutique|studio|salon|spa|clinic|gym|agency|business|company|brand|startup|practice|firm)\s+(?!(?:with|in|at|for|that|which|near|and|to|a|an|the|where|selling|serving)\b)([a-z][\w&'’-]*(?:\s+(?!(?:with|in|at|for|that|which|near|and|to|where|selling|serving)\b)[a-z][\w&'’-]*){0,2})(?=\s+(?:in|at|near|with|for|that|which|selling|serving)\b|\s*[,.;!?]|\s*$)/i;
290
+ const COPIED_SITE_RE = /^\s*Copy my website (https:\/\/\S+)/i;
291
+ function copiedSiteName(text) {
292
+ var _a, _b;
293
+ const url = (_a = COPIED_SITE_RE.exec(text)) == null ? void 0 : _a[1];
294
+ if (!url) return null;
295
+ const host = (_b = /^https:\/\/([^/?#]+)/i.exec(url)) == null ? void 0 : _b[1];
296
+ return host ? host.replace(/^www\./, "") : null;
297
+ }
289
298
  function siteNameFromRequest(text) {
290
299
  var _a, _b, _c, _d;
291
300
  const t = String(text != null ? text : "");
301
+ const copied = copiedSiteName(t);
302
+ if (copied) return copied;
292
303
  const m = (_c = (_b = (_a = t.match(/^[ \t-]*Brand name:\s*([^\n]{2,40})$/im)) != null ? _a : t.match(/\b(?:called|named)\s+["“'‘]([^"”'’\n]{2,40})["”'’]/i)) != null ? _b : t.match(/\b(?:called|named)\s+([A-Z0-9][\w&'’.-]*(?:\s+(?:&|and|[A-Z0-9][\w&'’.-]*))*)/)) != null ? _c : t.match(/\b(?:site|website|page|app)\s+for\s+([A-Z0-9][\w&'’.-]*(?:\s+(?:&|and|[A-Z0-9][\w&'’.-]*)){0,4})/);
304
+ const lower = m ? null : OWN_BUSINESS_NAME_RE.exec(t);
305
+ if (lower) return lower[1].trim().replace(/\b([a-z])/g, (c) => c.toUpperCase());
293
306
  const name = (_d = m == null ? void 0 : m[1]) == null ? void 0 : _d.split(/[.!?]\s/)[0].replace(/\s+(?:&|and)$/i, "").replace(/[.,;:!?]+$/, "").trim();
294
307
  if (name && name.length >= 2) return name;
295
308
  return businessNameFrom(t.split(/\n\n\[/)[0]);
@@ -1 +1 @@
1
- {"version":3,"file":"buildFragments.js","sources":["../../../src/features/webbuilder/buildFragments.ts"],"sourcesContent":["/**\n * Reads builds out of a build chat's posts.\n *\n * The build workflow posts its result as a \"fragment\" on an assistant post:\n * sandbox id and preview URL, the source files, and after a publish the live\n * address. Native twin of the web host's `creationsFromMessages`\n * (browser `pages/webbuilder/remoteWebbuilder.ts`) and the surface's\n * `extractFragmentFromSource` lookup order: `propsConfiguration.contents`\n * first (where the real fragment lives; `props` is account-scoped), then the\n * post's own fields. Pure but for the platform's sandbox domain, read from\n * config (publicSandboxDomain), so the host and jest can both use it.\n */\nimport type { WebBuilderBuild, WebBuilderProject } from './types';\nimport { rewritePagesDevLinks, shownLiveUrl, siteAddress } from './siteAddress';\nimport { publicSandboxDomain } from './publicSandboxDomain';\nimport {\n DEFAULT_E2B_SANDBOX_DOMAIN,\n previewDomainFor,\n sandboxPreviewDomainsSource,\n sandboxPreviewLinkRe,\n sandboxPreviewUrlFor,\n withPublicSandboxHosts,\n} from './sandboxPublicHost';\nimport { renderWidgetBlocks } from './widgetBlocks';\nimport { stripAskUser } from '../chat/askUser';\n\ntype Loose = Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\ninterface Fragment {\n sandboxUrl?: string;\n sandboxId?: string;\n liveUrl?: string;\n files?: Record<string, string> | null;\n title?: string;\n projectId?: string;\n /** Stack the build was made from (`vite-react`, `nextjs`), shown on the tile. */\n template?: string;\n /** Screenshot of the build: an object key or a full URL. */\n coverImageUrl?: string;\n /** CDN origin the cover key was stored under. */\n coverImagePath?: string;\n /** The agent's restore point for this build (design-pro snapshots after each turn). */\n snapshotId?: string;\n /** Read from the agent's words (the agent-chat lane), not a workflow fragment. */\n fromReply?: boolean;\n isCreatingSandbox: boolean;\n isDeploying: boolean;\n}\n\n/** `contents` arrives as an object or, from some resolvers, as JSON text. */\nfunction asObject(value: unknown): Loose | null {\n if (!value) return null;\n if (typeof value === 'object') return Array.isArray(value) ? null : (value as Loose);\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (!trimmed.startsWith('{')) return null;\n try {\n const parsed = JSON.parse(trimmed);\n return parsed && typeof parsed === 'object' ? (parsed as Loose) : null;\n } catch {\n return null;\n }\n }\n return null;\n}\n\nfunction str(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\n/** `props` is account-scoped (`props[\"<accountId>\"] = {…}`): the records one level down. */\nfunction accountRecords(record: Loose): Loose[] {\n return Object.values(record)\n .map((v) => asObject(v))\n .filter((v): v is Loose => v !== null);\n}\n\n/** First non-empty string among `key` on each record (and on its `fragment`). */\nfunction pick(records: Loose[], key: string): string | undefined {\n for (const record of records) {\n const value = str(record[key]) || str(asObject(record.fragment)?.[key]);\n if (value) return value;\n }\n return undefined;\n}\n\n/** A live sandbox URL (`https://3000-<id>.sb.yantra.app`, `.e2b.dev`, any domain) - never a cover. */\nconst LIVE_SANDBOX = /^https?:\\/\\/\\d+-[a-z0-9]+(\\.|\\/|$)/i;\n\n/**\n * The preview origin for a sandbox. A bare `https://3000-<id>` (no domain) is\n * the E2B default domain, as the surface's `liveSandboxIframeSrc` maps it. An\n * e2b cloud preview is shown on the platform's sandbox domain when one is set\n * (`E2B_SANDBOX_DOMAIN`), and so is a preview named only by its sandbox id.\n */\nexport function sandboxPreviewUrl(url: string | undefined, sandboxId: string | undefined): string | null {\n const domain = publicSandboxDomain();\n const given = str(url);\n if (given) {\n if (/^https?:\\/\\/\\d+-[a-z0-9]+\\/?$/i.test(given)) {\n return `${given.replace(/\\/$/, '')}.${previewDomainFor(DEFAULT_E2B_SANDBOX_DOMAIN, domain)}`;\n }\n return withPublicSandboxHosts(given, domain);\n }\n const id = str(sandboxId);\n return id ? sandboxPreviewUrlFor(id, domain) : null;\n}\n\nfunction httpOrigin(value: string | undefined): string | null {\n const match = /^(https?:\\/\\/[^/?#]+)/i.exec((value ?? '').trim());\n return match && !LIVE_SANDBOX.test(match[1]) ? match[1] : null;\n}\n\n/**\n * The image to show for a cover - the web `resolveCoverDisplayUrl`: an object\n * key joined to the origin it was stored under, else to the app's CDN, else a\n * full https URL as given. A live sandbox URL is never a cover.\n */\nexport function coverDisplayUrl(cover: string | undefined, path?: string, cdnOrigin?: string): string | null {\n const raw = str(cover);\n if (!raw || LIVE_SANDBOX.test(raw)) return null;\n if (/^https?:\\/\\//i.test(raw)) return raw.split('?')[0];\n const key = raw.replace(/^\\/+/, '');\n if (!/\\/uploads\\//i.test(`/${key}`) && !/\\.(png|jpe?g|webp|gif|svg)$/i.test(key)) return null;\n const origin = httpOrigin(path) || httpOrigin(cdnOrigin);\n return origin ? `${origin}/${key}` : null;\n}\n\nexport function readFragment(post: unknown): Fragment | null {\n if (!post || typeof post !== 'object') return null;\n const p = post as Loose;\n const cfg: Loose = p.propsConfiguration || {};\n const contents: Loose = asObject(cfg.contents) || asObject(cfg.content) || {};\n const contentsProps: Loose = asObject(contents.props) || {};\n const props: Loose = asObject(p.props) || {};\n const fragment: Loose | null =\n asObject(contentsProps.fragment) ||\n asObject(contents.fragment) ||\n asObject(cfg.fragment) ||\n asObject(props.fragment) ||\n asObject(p.fragment) ||\n null;\n const f: Loose = fragment || {};\n const sandboxUrl = str(f.sandboxUrl) || str(f.url) || str(p.sandboxUrl) || str(contents.sandboxUrl);\n const sandboxId = str(f.sandboxId) || str(p.sandboxId) || str(contents.sandboxId) || str(cfg.sandboxId);\n const publish = asObject(f.publish);\n // A record taken offline after (or when) it was published is not live (web 0.8.30 `isPublishOffline`).\n const offAt = Date.parse(str(publish?.unpublishedAt));\n const onAt = Date.parse(str(publish?.publishedAt));\n const offline = Number.isFinite(offAt) && (!Number.isFinite(onAt) || offAt >= onAt);\n // Shown on the custom or company domain, never pages.dev (web `siteAddress`, #446).\n const liveUrl = offline\n ? undefined\n : siteAddress({\n customDomainUrl: str(f.customDomainUrl),\n urls: [str(f.cloudflareUrl), str(f.deployUrl), str(publish?.url)],\n projectName: str(publish?.projectName) || str(f.projectName),\n }) || undefined;\n const attachment = asObject(props.attachment) || asObject(contents.attachment) || {};\n const isCreatingSandbox =\n f.isCreatingSandbox === true || contents.isCreatingSandbox === true || p.isCreatingSandbox === true;\n const isDeploying = attachment.isDeploying === true || f.isDeploying === true;\n if (!sandboxUrl && !sandboxId && !liveUrl && !fragment && !isCreatingSandbox && !isDeploying) return null;\n const files = f.files && typeof f.files === 'object' ? (f.files as Record<string, string>) : null;\n // The cover rides on the fragment, the post's props, or an account record of either.\n const coverSources = [f, props, contents, contentsProps, p, ...accountRecords(props), ...accountRecords(contents)];\n const coverImageUrl = [\n pick(coverSources, 'coverImageUrl'),\n pick(coverSources, 'previewImageUrl'),\n str(f.cover),\n ].find((c) => c && !LIVE_SANDBOX.test(c));\n return {\n sandboxUrl,\n sandboxId,\n liveUrl,\n files,\n title: str(f.title),\n projectId: str(f.projectId) || str(contentsProps.projectId),\n template: str(f.templateId) || str(f.template) || str(contentsProps.template) || str(contents.template),\n coverImageUrl,\n coverImagePath: pick(coverSources, 'coverImagePath'),\n isCreatingSandbox,\n isDeploying,\n };\n}\n\n/**\n * Published addresses the agent names (web `chat/agentBuild.ts`); its sandbox previews are\n * `sandboxPreviewLinkRe`: on e2b's domains or the platform's sandbox domain, never another host.\n */\nconst LIVE_URL_RE = /https:\\/\\/([a-z0-9][a-z0-9-]{1,60})\\.(?:pages\\.dev|yarntra\\.com)\\b[^\\s)\\]\"'<>*`]*/gi;\nconst RESTORE_POINT_RE = /restore point \\(snapshot `([^`\\s]{4,200})`\\)/gi;\n\nconst trimUrl = (url: string) => url.replace(/[.,;:!?]+$/, '');\n\n/**\n * The last sandbox preview link in the text (the agent's latest), with its sandbox id.\n * An e2b link comes back on the platform's sandbox domain when one is set.\n */\nexport function previewFrom(text: string): { url: string; sandboxId: string } | null {\n const domain = publicSandboxDomain();\n const all = Array.from(text.matchAll(sandboxPreviewLinkRe(domain)));\n const last = all[all.length - 1];\n return last ? { url: withPublicSandboxHosts(trimUrl(last[0]), domain), sandboxId: last[2] } : null;\n}\n\n/** The published address the agent reports: `<name>.yarntra.com` first, pages.dev only when it is the only one (web #428). */\nexport function liveUrlFrom(text: string): string | null {\n const hits = Array.from(text.matchAll(LIVE_URL_RE)).map((m) => trimUrl(m[0]));\n if (!hits.length) return null;\n const hit = hits.find((h) => h.includes('.yarntra.com')) ?? hits[0];\n return shownLiveUrl(hit) ?? hit;\n}\n\n/** The restore point the skill reports: \"Saved a restore point (snapshot `<id>`).\" (design-pro 3.3, #388). */\nexport function snapshotFrom(text: string): string | null {\n const all = Array.from(text.matchAll(RESTORE_POINT_RE));\n return all.length ? all[all.length - 1][1] : null;\n}\n\n/** \"Your Lotus Flow site is built…\", \"**Lotus Flow** is live\" -> \"Lotus Flow\". */\nexport function siteNameFrom(text: string): string | null {\n const m =\n text.match(\n /\\bYour ([A-Z][\\w&'’ .-]{1,40}?)(?: (?:yoga|coffee|wedding|photography|bakery))? (?:site|website|app) is (?:built|ready|live|running)/,\n ) ??\n text.match(/\\*\\*([A-Z][^*\\n]{1,40})\\*\\* is (?:live|ready|built)/) ??\n text.match(/^([A-Z][\\w&'’ .-]{1,40}?) is live at\\b/m);\n return m ? m[1].trim() : null;\n}\n\n/** A sandbox preview link (e2b's or the platform's domain), without the sentence's closing punctuation. */\nfunction sandboxLinkSource(domain: string): string {\n return String.raw`https:\\/\\/\\d{2,5}-[a-z0-9]{8,40}\\.${sandboxPreviewDomainsSource(domain)}\\b(?:[^\\s)\\]\"'<>*\\x60]*[^\\s)\\]\"'<>*\\x60.,;:!?])?`;\n}\n\n/**\n * The agent's reply as the reader sees it. The restore point's id and the sandbox\n * preview are for the builder, not them (web `assistantBubbleContent`, design-pro\n * 3.11): a sandbox link dies with the sandbox (\"Sandbox not found\"), so the site\n * card's Preview, which can wake it, is the way in. Replies from before 3.11 wrote\n * the link in the prose; it goes too, keeping a markdown link's words.\n */\nexport function displayAgentText(text: string): string {\n const link = sandboxLinkSource(publicSandboxDomain());\n // Widget blocks (logo designs) show as their picture, not JSON (web #469); pages.dev is\n // shown as the site's company address (web #446).\n return (\n // The agent's [ASK_USER] question is a card, not prose (also while it streams).\n rewritePagesDevLinks(renderWidgetBlocks(stripAskUser(text)))\n .replace(/(restore point) \\(snapshot `[^`]+`\\)/gi, '$1')\n .replace(/\\s*\\(preview `[^`]+`\\)/gi, '')\n // cdecli's \"billing policy check unavailable … allowing metered action\" is an operator\n // notice, not the answer (a real refusal says \"billing policy blocks\" and stays).\n .replace(/^[ \\t>]*⚠?\\s*billing policy check unavailable\\b[^\\n]*\\n?/gim, '')\n .replace(new RegExp(String.raw`\\[([^\\]]+)\\]\\(${link}\\)`, 'gi'), '$1')\n .replace(new RegExp(String.raw`:?[ \\t]*<?${link}>?`, 'gi'), '')\n // A \"Live preview:\" label left with nothing after it once its link is gone (web #bae473ca).\n .replace(/^[ \\t>*_-]*(?:\\*\\*)?live preview:?(?:\\*\\*)?[ \\t]*(?:\\n|$)/gim, '')\n .trim()\n );\n}\n\n/**\n * A build named only in the agent's words: the agent-chat lane (template remix,\n * building from chat) replies with the preview link, the live address once it\n * publishes, and its restore point - no fragment - so those are the build.\n */\nfunction linkFragment(post: unknown): Fragment | null {\n const p = (post ?? {}) as Loose;\n const text = typeof p.message === 'string' ? p.message : '';\n const preview = previewFrom(text);\n const liveUrl = liveUrlFrom(text) ?? undefined;\n const snapshotId = snapshotFrom(text) ?? undefined;\n if (!preview && !liveUrl && !snapshotId) return null;\n return {\n sandboxUrl: preview?.url,\n sandboxId: preview?.sandboxId,\n liveUrl,\n snapshotId,\n title: siteNameFrom(text) ?? undefined,\n fromReply: true,\n isCreatingSandbox: false,\n isDeploying: false,\n };\n}\n\nfunction postTime(post: unknown): number {\n const p = (post ?? {}) as Loose;\n const raw = p.updatedAt || p.createdAt;\n const ms = typeof raw === 'number' ? raw : Date.parse(String(raw ?? ''));\n return Number.isFinite(ms) ? ms : 0;\n}\n\n/** Posts in the order they happened (the query is not sorted). */\nfunction chronological(posts: readonly unknown[]): unknown[] {\n return [...posts].sort((a, b) => postTime(a) - postTime(b));\n}\n\nfunction isUserPost(post: unknown): boolean {\n const p = (post ?? {}) as Loose;\n const contents = asObject(p.propsConfiguration?.contents) || {};\n const props = asObject(p.props) || {};\n const role = String(props.role ?? contents.role ?? asObject(contents.props)?.role ?? '').toUpperCase();\n return role === 'USER';\n}\n\n/** The stack label the web tile shows when a build does not name one. */\nexport const DEFAULT_TEMPLATE = 'vite-react';\n\n/**\n * Newest-first builds of one site. A later post about the same sandbox (a\n * publish, a re-post, its screenshot) updates that build.\n */\nexport function buildsFromPosts(\n posts: readonly unknown[],\n fallbackTitle?: string,\n cdnOrigin?: string,\n): WebBuilderBuild[] {\n const fallback = fallbackTitle ?? 'Web app';\n const byKey = new Map<string, WebBuilderBuild>();\n let lastKey: string | null = null;\n // The web hydrate's rule: a build is an ASSISTANT post with something to show - a\n // preview URL, a live address or a screenshot. A user turn carries the sandbox it\n // edits (and a bare sandbox id is a turn in flight), neither is a build.\n const fragments = chronological(posts)\n .filter((post) => !isUserPost(post))\n .map((post) => ({ post, fragment: readFragment(post) ?? linkFragment(post) }))\n .filter(\n (row): row is { post: unknown; fragment: Fragment } =>\n row.fragment !== null &&\n Boolean(\n row.fragment.sandboxUrl ||\n row.fragment.liveUrl ||\n row.fragment.coverImageUrl ||\n row.fragment.snapshotId,\n ),\n );\n for (const { post, fragment } of fragments) {\n const previewUrl = sandboxPreviewUrl(fragment.sandboxUrl, fragment.sandboxId);\n const key = fragment.sandboxId || previewUrl || '';\n // A publish or screenshot post may name no sandbox: it belongs to the latest build.\n const target: string | null =\n key || (fragment.liveUrl || fragment.coverImageUrl || fragment.snapshotId ? lastKey : null);\n if (target) {\n const existing = byKey.get(target);\n byKey.set(target, {\n key: target,\n // A workflow fragment names the build; a reply's site name only names a build with none yet.\n title:\n (fragment.fromReply ? existing?.title || fragment.title : fragment.title || existing?.title) ||\n fallback,\n previewUrl: previewUrl || existing?.previewUrl || null,\n sandboxId: fragment.sandboxId || existing?.sandboxId || null,\n projectId: fragment.projectId || existing?.projectId || null,\n liveUrl: fragment.liveUrl || existing?.liveUrl || null,\n files: fragment.files || existing?.files || null,\n snapshotId: fragment.snapshotId || existing?.snapshotId || null,\n origin: existing?.origin === 'workflow' || !fragment.fromReply ? 'workflow' : 'agent',\n templateId: fragment.template || existing?.templateId || DEFAULT_TEMPLATE,\n coverUrl:\n coverDisplayUrl(fragment.coverImageUrl, fragment.coverImagePath, cdnOrigin) ||\n existing?.coverUrl ||\n null,\n updatedAt: Math.max(postTime(post), existing?.updatedAt ?? 0),\n });\n lastKey = target;\n }\n }\n return [...byKey.values()].filter((b) => b.previewUrl || b.liveUrl).sort((a, b) => b.updatedAt - a.updatedAt);\n}\n\n/** The newest post flags a sandbox still being created or a publish still running. */\nexport function pendingWork(posts: readonly unknown[]): 'creating' | 'publishing' | null {\n const newest = chronological(posts)\n .map((post) => readFragment(post))\n .filter((f): f is Fragment => f !== null)\n .pop();\n if (!newest) return null;\n if (newest.isCreatingSandbox && !newest.sandboxUrl && !newest.sandboxId) return 'creating';\n if (newest.isDeploying && !newest.liveUrl) return 'publishing';\n return null;\n}\n\n// ── Titles: the web surface's `resolveArtifactTitle` rules ─────────────────\n\n/** Not a product name: what the workflow and the chat call a site before it has one. */\nexport function isGenericTitle(title?: string | null): boolean {\n const t = (title || '').trim().toLowerCase();\n return (\n !t ||\n t === 'generated page' ||\n t === 'generated project' ||\n t === 'generated with cdecli' ||\n t === 'ai assistant' ||\n t === 'web app' ||\n // The placeholder a site carries before it has a name; a saved one is not a rename.\n /^new (site|app)$/.test(t) ||\n /^build \\d+$/.test(t) ||\n /^build\\s+me\\b/.test(t) ||\n /^remix\\s+the\\b/.test(t) ||\n /^(build|chat)[- ]channel\\b/.test(t) ||\n t.startsWith('selected skill') ||\n /^code[\\s_-]?assist/.test(t)\n );\n}\n\nconst TITLE_STOP_WORDS = new Set([\n 'a',\n 'an',\n 'the',\n 'create',\n 'build',\n 'make',\n 'please',\n 'me',\n 'my',\n 'for',\n 'with',\n 'simple',\n 'using',\n 'from',\n 'template',\n 'to',\n 'and',\n 'or',\n 'remix',\n 'yantra',\n]);\n\nfunction titleCase(words: string[]): string {\n return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(' ');\n}\n\n// Every note a turn carries after the person's words (the web's and this app's); older posts too.\nconst KNOWN_NOTE_RE =\n /^\\[(?:Project channelId=[^\\]\\n]*|Database slug=[^\\]\\n]*|\\d+ attachment\\(s\\)|Mode: [a-z]+|Project instructions|Approved plan|Reference site|UI kit|Style direction|Database|AI in the app|Integrations|Element|Fix error|Hand edits|Open build|Open site|Inspired by|New site|Template|Brand kit|Imported project|Export|Asset|Figma|File text|Mentions|Draft|Image edit)\\]/;\nconst NOTE_LINE_RE = /^\\[(?:[A-Z][A-Za-z]*(?: [A-Za-z]+){0,3}|[A-Z][A-Za-z ]*=[^\\]\\n]*|\\d+ attachment\\(s\\))\\]/;\n// The studio's old brand block, sent as part of the message before it became a note.\nconst LEGACY_BRAND_BLOCK_RE = /^Brand kit \\(follow it\\):\\s*$/;\n// The web's \"New from this\" wrapper around a remix ask.\nconst REFERENCE_WRAPPER_RE =\n /^Using “[^”]*” as reference \\(do not edit that sandbox\\)\\.\\nCreate a new app from the user request below\\.\\n\\n/;\n\n/**\n * The person's words, without the notes a turn carries for the agent (web `stripSurfaceNotes`):\n * everything from the first note on - a known `[Tag]` line, the old brand block, or any\n * `[Tag]` line after a blank one (notes follow one). A \"Build me:\" brief keeps its prefix.\n */\nexport function stripAgentNote(content: string): string {\n const lines = String(content || '')\n .replace(REFERENCE_WRAPPER_RE, '')\n .replace(/\\r\\n?/g, '\\n')\n .split('\\n');\n let cut = lines.length;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trimStart();\n if (\n KNOWN_NOTE_RE.test(line) ||\n LEGACY_BRAND_BLOCK_RE.test(line) ||\n (i > 0 && !lines[i - 1].trim() && NOTE_LINE_RE.test(line))\n ) {\n cut = i;\n break;\n }\n }\n return lines.slice(0, cut).join('\\n').trim();\n}\n\n/** What the person wrote, as their bubble shows it: no notes, no studio \"Build me:\" prefix. */\nexport function userBubbleText(content: string): string {\n return stripAgentNote(content).replace(/^\\s*Build me:\\s*/i, '');\n}\n\n/** The person's words, without the internal lines a turn carries. */\nexport function cleanPrompt(text: string): string {\n return text\n .replace(/^\\[webbuilder context:[^\\]]*\\]\\s*/i, '')\n .replace(/^build\\s*me\\s*:\\s*/i, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/**\n * Product name from a brief: \"Build me: todo app\" -> \"Todo App\". An edit\n * (\"make the header blue\") is not a name.\n */\nexport function titleFromPrompt(message?: string | null): string | null {\n const raw = (message || '').replace(/^\\[webbuilder context:[^\\]]*\\]\\s*/i, '').trim();\n if (!raw) return null;\n const buildMe = raw.match(/^\\s*Build me:\\s*(.+)$/im)?.[1]?.trim();\n if (!buildMe && /^(change|update|rename|fix|edit|add|remove|delete|improve|make|refactor)\\b/i.test(raw)) {\n return null;\n }\n const source = (buildMe || raw.split(/\\n+/)[0] || '').replace(/^[\"']|[\"']$/g, '');\n const words = source\n .replace(/[^\\w\\s-]/g, ' ')\n .split(/\\s+/)\n .filter((w) => w.length > 1 && !TITLE_STOP_WORDS.has(w.toLowerCase()))\n .slice(0, 3);\n if (!words.length) return null;\n const title = titleCase(words);\n return isGenericTitle(title) ? null : title;\n}\n\n/** `package.json` name of the build (\"bakery-site\" -> \"Bakery Site\"). */\nfunction titleFromPackageJson(files?: Record<string, string> | null): string | null {\n if (!files) return null;\n const raw = Object.entries(files).find(([path]) => /(^|\\/)package\\.json$/.test(path))?.[1];\n if (!raw) return null;\n try {\n const name = String((JSON.parse(raw) as { name?: string }).name || '').trim();\n if (!name || name === 'vite-react' || name === 'project') return null;\n return name\n .replace(/^@[^/]+\\//, '')\n .replace(/[-_]+/g, ' ')\n .replace(/\\b\\w/g, (c) => c.toUpperCase());\n } catch {\n return null;\n }\n}\n\n/** The build's own title, then the brief's product name, the chat's name, the package name. */\n/**\n * \"a bakery called Crumb & Co\", \"named 'Lotus Flow'\", \"Brand name: Crumb & Co\", \"a site for Tidewater Coffee, a\n * coffee cart\" -> the name the person gave the site (web, #49f607ee). Lower case after \"for\" is a description.\n */\n// A business name in a brief (web 0.9, `businessNameFrom`): capitalised words, joined by &, and, of or the\n// (\"Paws & Polish\", \"House of Bao\"). Letters without \\p{L}, which older Hermes builds may not have.\nconst BUSINESS_NAME = String.raw`[A-Z][A-Za-zÀ-ÖØ-öø-ÿ\\d'’.-]*(?:\\s+(?:&|and|of|the|de|la|[A-Z][A-Za-zÀ-ÖØ-öø-ÿ\\d'’.-]*))*`;\nconst BUSINESS_NAME_RES = [\n new RegExp(String.raw`\\b(?:called|named)\\s+[\"“]?(${BUSINESS_NAME})`),\n new RegExp(String.raw`\\bfor\\s+[\"“]?(${BUSINESS_NAME})[\"”]?\\s*(?:,|\\(|-|–|—|\\bin\\b|\\ba\\b|\\ban\\b|$)`),\n];\n\n/** The business the brief names (\"…for Paws & Polish, a dog grooming salon\" -> \"Paws & Polish\"), else null. */\nexport function businessNameFrom(text: string): string | null {\n const one = text.replace(/\\s+/g, ' ').trim();\n for (const re of BUSINESS_NAME_RES) {\n const name = one\n .match(re)?.[1]\n ?.trim()\n .replace(/\\s+(?:&|and|of|the|de|la)$/i, '');\n if (name && name.length >= 3 && name.length <= 40 && !/^(?:My|Our|Your|The|A|An)$/.test(name)) return name;\n }\n return null;\n}\n\nexport function siteNameFromRequest(text: string | null | undefined): string | null {\n const t = String(text ?? '');\n const m =\n t.match(/^[ \\t-]*Brand name:\\s*([^\\n]{2,40})$/im) ??\n t.match(/\\b(?:called|named)\\s+[\"“'‘]([^\"”'’\\n]{2,40})[\"”'’]/i) ??\n t.match(/\\b(?:called|named)\\s+([A-Z0-9][\\w&'’.-]*(?:\\s+(?:&|and|[A-Z0-9][\\w&'’.-]*))*)/) ??\n t.match(/\\b(?:site|website|page|app)\\s+for\\s+([A-Z0-9][\\w&'’.-]*(?:\\s+(?:&|and|[A-Z0-9][\\w&'’.-]*)){0,4})/);\n const name = m?.[1]\n ?.split(/[.!?]\\s/)[0]\n .replace(/\\s+(?:&|and)$/i, '')\n .replace(/[.,;:!?]+$/, '')\n .trim();\n if (name && name.length >= 2) return name;\n return businessNameFrom(t.split(/\\n\\n\\[/)[0]);\n}\n\nexport function resolveSiteTitle(opts: {\n fragmentTitle?: string | null;\n channelTitle?: string | null;\n userPrompt?: string | null;\n /** The first request as sent (its brand kit note too): the name the person gave the site. */\n requestText?: string | null;\n files?: Record<string, string> | null;\n}): string {\n const candidates = [\n opts.fragmentTitle,\n siteNameFromRequest(opts.requestText),\n titleFromPrompt(opts.userPrompt),\n opts.channelTitle,\n titleFromPackageJson(opts.files),\n ];\n const found = candidates.find((c) => c && !isGenericTitle(c));\n return (found || 'Generated Page').trim();\n}\n\n// ── Sites ──────────────────────────────────────────────────────────────────\n\nexport interface ChannelLike {\n id?: string | null;\n title?: string | null;\n displayName?: string | null;\n updatedAt?: unknown;\n createdAt?: unknown;\n lastMessage?: unknown;\n}\n\n/** True when the newest build in `lastMessage` already carries a cover - the web skips the thread read then. */\nexport function lastMessageHasCover(channel: ChannelLike): boolean {\n return Boolean(readFragment(channel.lastMessage)?.coverImageUrl);\n}\n\n/**\n * A site from one chat's posts, the way the web gallery hydrates a tile: only\n * a chat with a build is a site; its name follows `resolveSiteTitle`.\n */\nexport function projectFromPosts(\n channel: ChannelLike,\n posts: readonly unknown[],\n cdnOrigin?: string,\n): WebBuilderProject | null {\n const channelId = str(channel.id);\n if (!channelId) return null;\n const builds = buildsFromPosts(posts, '', cdnOrigin);\n const latest = builds[0];\n if (!latest) return null;\n const userPosts = chronological(posts).filter((post) => isUserPost(post) && str((post as Loose).message));\n const userPrompts = userPosts\n // The person's own words: a note sent along (a brand kit) is not a title source.\n .map((post) => stripAgentNote(String((post as Loose).message)))\n .filter(Boolean);\n // The brief names the product (\"Build me: …\"); a later message (\"the live preview is\n // not loading\") never does, so only the brief - or failing that the first ask - counts.\n const brief = userPrompts.find((m) => /build\\s*me\\s*:/i.test(m)) ?? userPrompts[0];\n const rawChannelTitle = [channel.displayName, channel.title]\n .map((t) => str(t))\n .find((t) => t && !isGenericTitle(t));\n // A chat named after its brief (\"Build simple calculator app\") gives the product name, not the sentence.\n const channelTitle =\n rawChannelTitle && /^(build|create|make)\\b/i.test(rawChannelTitle)\n ? (titleFromPrompt(rawChannelTitle) ?? rawChannelTitle)\n : rawChannelTitle;\n const title = resolveSiteTitle({\n fragmentTitle: latest.title,\n channelTitle,\n userPrompt: brief,\n requestText: userPosts.length ? String((userPosts[0] as Loose).message) : null,\n files: latest.files,\n });\n const updated = Date.parse(String(channel.updatedAt ?? channel.createdAt ?? ''));\n return {\n channelId,\n title,\n updatedAt: Math.max(Number.isFinite(updated) ? updated : 0, latest.updatedAt),\n previewUrl: latest.previewUrl,\n liveUrl: builds.find((b) => b.liveUrl)?.liveUrl ?? null,\n coverUrl: builds.find((b) => b.coverUrl)?.coverUrl ?? null,\n templateId: latest.templateId,\n };\n}\n\n/** `?wb=<n>` on the preview so a rebuilt sandbox is fetched again, not served from cache. */\nexport function cacheBustedUrl(url: string, nonce: number | string): string {\n const [base, hash = ''] = url.split('#');\n const clean = base.replace(/([?&])wb=[^&]*(&|$)/, '$1').replace(/[?&]$/, '');\n const sep = clean.includes('?') ? '&' : '?';\n return `${clean}${sep}wb=${nonce}${hash ? `#${hash}` : ''}`;\n}\n\n/**\n * The publish name the web dialog suggests: the site's title as a slug,\n * `[a-z0-9-]`, at most 58 characters (`<name>.yarntra.com`).\n */\nexport function publishSlug(title: string): string {\n const slug = title\n .toLowerCase()\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 58)\n .replace(/-+$/, '');\n return slug || 'my-site';\n}\n\nexport function isValidPublishSlug(value: string): boolean {\n return /^[a-z0-9](?:[a-z0-9-]{0,56}[a-z0-9])?$/.test(value);\n}\n\n/** Display host of a URL: `https://bakery.pages.dev/` -> `bakery.pages.dev`. */\nexport function displayHost(url: string | null | undefined): string {\n const match = /^https?:\\/\\/([^/?#]+)/i.exec((url ?? '').trim());\n return match ? match[1] : (url ?? '').trim();\n}\n\n/** \"just now\", \"5 min ago\", \"3 h ago\", \"Yesterday\", \"12 Oct\". */\nexport function relativeTime(ms: number, now = Date.now()): string {\n if (!ms) return '';\n const diff = Math.max(0, now - ms);\n const min = Math.floor(diff / 60_000);\n if (min < 1) return 'just now';\n if (min < 60) return `${min} min ago`;\n const hours = Math.floor(min / 60);\n if (hours < 24) return `${hours} h ago`;\n if (hours < 48) return 'Yesterday';\n const d = new Date(ms);\n const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n return `${d.getDate()} ${months[d.getMonth()]}`;\n}\n\n// ── The agent transcript: the build chat's posts, as the web Agent pane shows them ──\n\n/** A live progress row (web `isThinkingPost`): shown as the agent's status, never kept. */\nexport function isThinkingPost(post: unknown): boolean {\n const p = (post ?? {}) as Loose;\n const props = asObject(p.props) || {};\n const attachment = asObject(props.attachment) || {};\n const msg = String(p.message ?? '')\n .trim()\n .toLowerCase();\n return (\n String(p.type ?? '').toUpperCase() === 'THINKING' ||\n Boolean(props.thinking ?? props.isThinking) ||\n props.kind === 'thinking' ||\n Boolean(attachment.isThinking) ||\n msg === 'thinking...' ||\n msg === 'initializing...' ||\n msg === 'initializing…'\n );\n}\n\nfunction readFragmentStatus(p: Loose): string | undefined {\n const contents = asObject(p.propsConfiguration?.contents) || {};\n return (\n str(asObject(asObject(contents.props)?.fragment)?.statusText) || str(asObject(contents.fragment)?.statusText)\n );\n}\n\n/** The workflow's progress line on a post: its thought, else the fragment's status. */\nexport function progressText(post: unknown): string | null {\n const p = (post ?? {}) as Loose;\n const props = asObject(p.props) || {};\n const thought = str(asObject(props.attachment)?.thought);\n if (thought) return thought;\n const status = str(asObject(props.fragment)?.statusText) || str(readFragmentStatus(p));\n if (status) return status;\n return isThinkingPost(post) ? (str(p.message) ?? null) : null;\n}\n\n/** A post the workflow wrote when the build failed (`fragment.isError` / `type: 'error'`). */\nexport function isErrorPost(post: unknown): boolean {\n const p = (post ?? {}) as Loose;\n const props = asObject(p.props) || {};\n const contents = asObject(p.propsConfiguration?.contents) || {};\n const f =\n asObject(props.fragment) || asObject(asObject(contents.props)?.fragment) || asObject(contents.fragment) || {};\n return f.isError === true || f.type === 'error';\n}\n\nexport interface TranscriptMessage {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n createdAt: number;\n}\n\n/**\n * The conversation in a build chat: the person's turns and the agent's replies,\n * oldest first, without progress rows or empty build markers.\n */\nexport function transcriptFromPosts(posts: readonly unknown[]): TranscriptMessage[] {\n const out: TranscriptMessage[] = [];\n for (const post of chronological(posts)) {\n const p = post as Loose;\n const text = str(p.message);\n if (text && !isThinkingPost(post)) {\n const user = isUserPost(post);\n out.push({\n id: String(p.id ?? `${user ? 'u' : 'a'}-${out.length}`),\n role: user ? 'user' : 'assistant',\n content: user ? cleanPrompt(text) || text : text,\n createdAt: postTime(post),\n });\n }\n }\n return out;\n}\n\n/**\n * How a turn started at `since` is going, read from the posts that arrived after it.\n * `heard` is whether the build posted anything back yet (a progress row, an answer).\n */\nexport function turnState(\n posts: readonly unknown[],\n since: number,\n): { status: 'running' | 'done' | 'failed'; progress: string | null; error: string | null; heard: boolean } {\n // A clock skew allowance, as the web ignores posts older than start - 2 s.\n const after = chronological(posts).filter((post) => postTime(post) >= since - 2_000);\n let progress: string | null = null;\n for (const post of after) {\n if (!isUserPost(post)) {\n if (isErrorPost(post)) {\n const p = post as Loose;\n return { status: 'failed', progress: null, error: str(p.message) ?? 'The build failed.', heard: true };\n }\n const fragment = readFragment(post);\n if (fragment && (fragment.sandboxUrl || fragment.liveUrl) && !isThinkingPost(post)) {\n return { status: 'done', progress: null, error: null, heard: true };\n }\n progress = progressText(post) ?? progress;\n }\n }\n // A plain answer (the agent asked a question, or replied without building) ends\n // the turn too - unless progress rows keep arriving after it.\n const newest = after.filter((post) => !isUserPost(post)).pop() as Loose | undefined;\n if (newest && !isThinkingPost(newest) && !progressText(newest) && str(newest.message)) {\n return { status: 'done', progress: null, error: null, heard: true };\n }\n return { status: 'running', progress, error: null, heard: Boolean(newest) };\n}\n\n/**\n * A turn sent through the build workflow: its USER post carries the workflow's\n * route (`templateTarget`). A blank build sends an empty fragment, which\n * the server drops, so this post is the only workflow mark until a build lands.\n */\nfunction isWorkflowTurnPost(post: unknown): boolean {\n if (!post || typeof post !== 'object') return false;\n const p = post as Loose;\n const contents = asObject(p.propsConfiguration?.contents) || {};\n return Boolean(str(asObject(p.props)?.templateTarget) || str(asObject(contents.props)?.templateTarget));\n}\n\n/**\n * The chat was built through the build workflow (its posts carry fragments or\n * the workflow's route): edits go back through the workflow. A chat without\n * any is an agent-chat site (a template remix), and its turns stay in the\n * agent chat.\n */\nexport function hasWorkflowPosts(posts: readonly unknown[]): boolean {\n return posts.some((post) => readFragment(post) !== null || isWorkflowTurnPost(post));\n}\n"],"names":["_a"],"mappings":"uZA0CA,SAAS,SAAS,KAA8B,EAAA;AAC9C,EAAI,IAAA,CAAC,OAAc,OAAA,IAAA;AACnB,EAAI,IAAA,OAAO,UAAU,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AAA,GAAA,MAAA,GAAA,EAAA,CAA0B,cAAc,CAAC,CAAA;AACxG;AAQO,SAAS,iBAAiB,KAAoC,EAAA;AACnE,EAAO,OAAA,KAAA,CAAM,KAAK,CAAQ,IAAA,KAAA,YAAA,CAAa,IAAI,CAAM,KAAA,IAAA,IAAQ,kBAAmB,CAAA,IAAI,CAAC,CAAA;AACnF"}
1
+ {"version":3,"file":"buildFragments.js","sources":["../../../src/features/webbuilder/buildFragments.ts"],"sourcesContent":["/**\n * Reads builds out of a build chat's posts.\n *\n * The build workflow posts its result as a \"fragment\" on an assistant post:\n * sandbox id and preview URL, the source files, and after a publish the live\n * address. Native twin of the web host's `creationsFromMessages`\n * (browser `pages/webbuilder/remoteWebbuilder.ts`) and the surface's\n * `extractFragmentFromSource` lookup order: `propsConfiguration.contents`\n * first (where the real fragment lives; `props` is account-scoped), then the\n * post's own fields. Pure but for the platform's sandbox domain, read from\n * config (publicSandboxDomain), so the host and jest can both use it.\n */\nimport type { WebBuilderBuild, WebBuilderProject } from './types';\nimport { rewritePagesDevLinks, shownLiveUrl, siteAddress } from './siteAddress';\nimport { publicSandboxDomain } from './publicSandboxDomain';\nimport {\n DEFAULT_E2B_SANDBOX_DOMAIN,\n previewDomainFor,\n sandboxPreviewDomainsSource,\n sandboxPreviewLinkRe,\n sandboxPreviewUrlFor,\n withPublicSandboxHosts,\n} from './sandboxPublicHost';\nimport { renderWidgetBlocks } from './widgetBlocks';\nimport { stripAskUser } from '../chat/askUser';\n\ntype Loose = Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\ninterface Fragment {\n sandboxUrl?: string;\n sandboxId?: string;\n liveUrl?: string;\n files?: Record<string, string> | null;\n title?: string;\n projectId?: string;\n /** Stack the build was made from (`vite-react`, `nextjs`), shown on the tile. */\n template?: string;\n /** Screenshot of the build: an object key or a full URL. */\n coverImageUrl?: string;\n /** CDN origin the cover key was stored under. */\n coverImagePath?: string;\n /** The agent's restore point for this build (design-pro snapshots after each turn). */\n snapshotId?: string;\n /** Read from the agent's words (the agent-chat lane), not a workflow fragment. */\n fromReply?: boolean;\n isCreatingSandbox: boolean;\n isDeploying: boolean;\n}\n\n/** `contents` arrives as an object or, from some resolvers, as JSON text. */\nfunction asObject(value: unknown): Loose | null {\n if (!value) return null;\n if (typeof value === 'object') return Array.isArray(value) ? null : (value as Loose);\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (!trimmed.startsWith('{')) return null;\n try {\n const parsed = JSON.parse(trimmed);\n return parsed && typeof parsed === 'object' ? (parsed as Loose) : null;\n } catch {\n return null;\n }\n }\n return null;\n}\n\nfunction str(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\n/** `props` is account-scoped (`props[\"<accountId>\"] = {…}`): the records one level down. */\nfunction accountRecords(record: Loose): Loose[] {\n return Object.values(record)\n .map((v) => asObject(v))\n .filter((v): v is Loose => v !== null);\n}\n\n/** First non-empty string among `key` on each record (and on its `fragment`). */\nfunction pick(records: Loose[], key: string): string | undefined {\n for (const record of records) {\n const value = str(record[key]) || str(asObject(record.fragment)?.[key]);\n if (value) return value;\n }\n return undefined;\n}\n\n/** A live sandbox URL (`https://3000-<id>.sb.yantra.app`, `.e2b.dev`, any domain) - never a cover. */\nconst LIVE_SANDBOX = /^https?:\\/\\/\\d+-[a-z0-9]+(\\.|\\/|$)/i;\n\n/**\n * The preview origin for a sandbox. A bare `https://3000-<id>` (no domain) is\n * the E2B default domain, as the surface's `liveSandboxIframeSrc` maps it. An\n * e2b cloud preview is shown on the platform's sandbox domain when one is set\n * (`E2B_SANDBOX_DOMAIN`), and so is a preview named only by its sandbox id.\n */\nexport function sandboxPreviewUrl(url: string | undefined, sandboxId: string | undefined): string | null {\n const domain = publicSandboxDomain();\n const given = str(url);\n if (given) {\n if (/^https?:\\/\\/\\d+-[a-z0-9]+\\/?$/i.test(given)) {\n return `${given.replace(/\\/$/, '')}.${previewDomainFor(DEFAULT_E2B_SANDBOX_DOMAIN, domain)}`;\n }\n return withPublicSandboxHosts(given, domain);\n }\n const id = str(sandboxId);\n return id ? sandboxPreviewUrlFor(id, domain) : null;\n}\n\nfunction httpOrigin(value: string | undefined): string | null {\n const match = /^(https?:\\/\\/[^/?#]+)/i.exec((value ?? '').trim());\n return match && !LIVE_SANDBOX.test(match[1]) ? match[1] : null;\n}\n\n/**\n * The image to show for a cover - the web `resolveCoverDisplayUrl`: an object\n * key joined to the origin it was stored under, else to the app's CDN, else a\n * full https URL as given. A live sandbox URL is never a cover.\n */\nexport function coverDisplayUrl(cover: string | undefined, path?: string, cdnOrigin?: string): string | null {\n const raw = str(cover);\n if (!raw || LIVE_SANDBOX.test(raw)) return null;\n if (/^https?:\\/\\//i.test(raw)) return raw.split('?')[0];\n const key = raw.replace(/^\\/+/, '');\n if (!/\\/uploads\\//i.test(`/${key}`) && !/\\.(png|jpe?g|webp|gif|svg)$/i.test(key)) return null;\n const origin = httpOrigin(path) || httpOrigin(cdnOrigin);\n return origin ? `${origin}/${key}` : null;\n}\n\nexport function readFragment(post: unknown): Fragment | null {\n if (!post || typeof post !== 'object') return null;\n const p = post as Loose;\n const cfg: Loose = p.propsConfiguration || {};\n const contents: Loose = asObject(cfg.contents) || asObject(cfg.content) || {};\n const contentsProps: Loose = asObject(contents.props) || {};\n const props: Loose = asObject(p.props) || {};\n const fragment: Loose | null =\n asObject(contentsProps.fragment) ||\n asObject(contents.fragment) ||\n asObject(cfg.fragment) ||\n asObject(props.fragment) ||\n asObject(p.fragment) ||\n null;\n const f: Loose = fragment || {};\n const sandboxUrl = str(f.sandboxUrl) || str(f.url) || str(p.sandboxUrl) || str(contents.sandboxUrl);\n const sandboxId = str(f.sandboxId) || str(p.sandboxId) || str(contents.sandboxId) || str(cfg.sandboxId);\n const publish = asObject(f.publish);\n // A record taken offline after (or when) it was published is not live (web 0.8.30 `isPublishOffline`).\n const offAt = Date.parse(str(publish?.unpublishedAt));\n const onAt = Date.parse(str(publish?.publishedAt));\n const offline = Number.isFinite(offAt) && (!Number.isFinite(onAt) || offAt >= onAt);\n // Shown on the custom or company domain, never pages.dev (web `siteAddress`, #446).\n const liveUrl = offline\n ? undefined\n : siteAddress({\n customDomainUrl: str(f.customDomainUrl),\n urls: [str(f.cloudflareUrl), str(f.deployUrl), str(publish?.url)],\n projectName: str(publish?.projectName) || str(f.projectName),\n }) || undefined;\n const attachment = asObject(props.attachment) || asObject(contents.attachment) || {};\n const isCreatingSandbox =\n f.isCreatingSandbox === true || contents.isCreatingSandbox === true || p.isCreatingSandbox === true;\n const isDeploying = attachment.isDeploying === true || f.isDeploying === true;\n if (!sandboxUrl && !sandboxId && !liveUrl && !fragment && !isCreatingSandbox && !isDeploying) return null;\n const files = f.files && typeof f.files === 'object' ? (f.files as Record<string, string>) : null;\n // The cover rides on the fragment, the post's props, or an account record of either.\n const coverSources = [f, props, contents, contentsProps, p, ...accountRecords(props), ...accountRecords(contents)];\n const coverImageUrl = [\n pick(coverSources, 'coverImageUrl'),\n pick(coverSources, 'previewImageUrl'),\n str(f.cover),\n ].find((c) => c && !LIVE_SANDBOX.test(c));\n return {\n sandboxUrl,\n sandboxId,\n liveUrl,\n files,\n title: str(f.title),\n projectId: str(f.projectId) || str(contentsProps.projectId),\n template: str(f.templateId) || str(f.template) || str(contentsProps.template) || str(contents.template),\n coverImageUrl,\n coverImagePath: pick(coverSources, 'coverImagePath'),\n isCreatingSandbox,\n isDeploying,\n };\n}\n\n/**\n * Published addresses the agent names (web `chat/agentBuild.ts`); its sandbox previews are\n * `sandboxPreviewLinkRe`: on e2b's domains or the platform's sandbox domain, never another host.\n */\nconst LIVE_URL_RE = /https:\\/\\/([a-z0-9][a-z0-9-]{1,60})\\.(?:pages\\.dev|yarntra\\.com)\\b[^\\s)\\]\"'<>*`]*/gi;\nconst RESTORE_POINT_RE = /restore point \\(snapshot `([^`\\s]{4,200})`\\)/gi;\n\nconst trimUrl = (url: string) => url.replace(/[.,;:!?]+$/, '');\n\n/**\n * The last sandbox preview link in the text (the agent's latest), with its sandbox id.\n * An e2b link comes back on the platform's sandbox domain when one is set.\n */\nexport function previewFrom(text: string): { url: string; sandboxId: string } | null {\n const domain = publicSandboxDomain();\n const all = Array.from(text.matchAll(sandboxPreviewLinkRe(domain)));\n const last = all[all.length - 1];\n return last ? { url: withPublicSandboxHosts(trimUrl(last[0]), domain), sandboxId: last[2] } : null;\n}\n\n/** The published address the agent reports: `<name>.yarntra.com` first, pages.dev only when it is the only one (web #428). */\nexport function liveUrlFrom(text: string): string | null {\n const hits = Array.from(text.matchAll(LIVE_URL_RE)).map((m) => trimUrl(m[0]));\n if (!hits.length) return null;\n const hit = hits.find((h) => h.includes('.yarntra.com')) ?? hits[0];\n return shownLiveUrl(hit) ?? hit;\n}\n\n/** The restore point the skill reports: \"Saved a restore point (snapshot `<id>`).\" (design-pro 3.3, #388). */\nexport function snapshotFrom(text: string): string | null {\n const all = Array.from(text.matchAll(RESTORE_POINT_RE));\n return all.length ? all[all.length - 1][1] : null;\n}\n\n/** \"Your Lotus Flow site is built…\", \"**Lotus Flow** is live\" -> \"Lotus Flow\". */\nexport function siteNameFrom(text: string): string | null {\n const m =\n text.match(\n /\\bYour ([A-Z][\\w&'’ .-]{1,40}?)(?: (?:yoga|coffee|wedding|photography|bakery))? (?:site|website|app) is (?:built|ready|live|running)/,\n ) ??\n text.match(/\\*\\*([A-Z][^*\\n]{1,40})\\*\\* is (?:live|ready|built)/) ??\n text.match(/^([A-Z][\\w&'’ .-]{1,40}?) is live at\\b/m);\n return m ? m[1].trim() : null;\n}\n\n/** A sandbox preview link (e2b's or the platform's domain), without the sentence's closing punctuation. */\nfunction sandboxLinkSource(domain: string): string {\n return String.raw`https:\\/\\/\\d{2,5}-[a-z0-9]{8,40}\\.${sandboxPreviewDomainsSource(domain)}\\b(?:[^\\s)\\]\"'<>*\\x60]*[^\\s)\\]\"'<>*\\x60.,;:!?])?`;\n}\n\n/**\n * The agent's reply as the reader sees it. The restore point's id and the sandbox\n * preview are for the builder, not them (web `assistantBubbleContent`, design-pro\n * 3.11): a sandbox link dies with the sandbox (\"Sandbox not found\"), so the site\n * card's Preview, which can wake it, is the way in. Replies from before 3.11 wrote\n * the link in the prose; it goes too, keeping a markdown link's words.\n */\nexport function displayAgentText(text: string): string {\n const link = sandboxLinkSource(publicSandboxDomain());\n // Widget blocks (logo designs) show as their picture, not JSON (web #469); pages.dev is\n // shown as the site's company address (web #446).\n return (\n // The agent's [ASK_USER] question is a card, not prose (also while it streams).\n rewritePagesDevLinks(renderWidgetBlocks(stripAskUser(text)))\n // Any language (web 1e4cd6ba): \"punto de restauración (snapshot `team/site-x:default`)\" keeps the words.\n .replace(/\\s*\\(snapshot `[^`]*(?:`\\)?|$)/gi, '')\n .replace(/\\s*`[a-z0-9][\\w.-]*\\/[\\w.-]+:default`/gi, '')\n .replace(/\\s*\\(preview `[^`]*(?:`\\)?|$)/gi, '')\n // cdecli's \"billing policy check unavailable … allowing metered action\" is an operator\n // notice, not the answer (a real refusal says \"billing policy blocks\" and stays).\n .replace(/^[ \\t>]*⚠?\\s*billing policy check unavailable\\b[^\\n]*\\n?/gim, '')\n .replace(new RegExp(String.raw`\\[([^\\]]+)\\]\\(${link}\\)`, 'gi'), '$1')\n .replace(new RegExp(String.raw`:?[ \\t]*<?${link}>?`, 'gi'), '')\n // A \"Live preview:\" label left with nothing after it once its link is gone (web #bae473ca).\n .replace(/^[ \\t>*_-]*(?:\\*\\*)?live preview:?(?:\\*\\*)?[ \\t]*(?:\\n|$)/gim, '')\n .trim()\n );\n}\n\n/**\n * A build named only in the agent's words: the agent-chat lane (template remix,\n * building from chat) replies with the preview link, the live address once it\n * publishes, and its restore point - no fragment - so those are the build.\n */\nfunction linkFragment(post: unknown): Fragment | null {\n const p = (post ?? {}) as Loose;\n const text = typeof p.message === 'string' ? p.message : '';\n const preview = previewFrom(text);\n const liveUrl = liveUrlFrom(text) ?? undefined;\n const snapshotId = snapshotFrom(text) ?? undefined;\n if (!preview && !liveUrl && !snapshotId) return null;\n return {\n sandboxUrl: preview?.url,\n sandboxId: preview?.sandboxId,\n liveUrl,\n snapshotId,\n title: siteNameFrom(text) ?? undefined,\n fromReply: true,\n isCreatingSandbox: false,\n isDeploying: false,\n };\n}\n\nfunction postTime(post: unknown): number {\n const p = (post ?? {}) as Loose;\n const raw = p.updatedAt || p.createdAt;\n const ms = typeof raw === 'number' ? raw : Date.parse(String(raw ?? ''));\n return Number.isFinite(ms) ? ms : 0;\n}\n\n/** Posts in the order they happened (the query is not sorted). */\nfunction chronological(posts: readonly unknown[]): unknown[] {\n return [...posts].sort((a, b) => postTime(a) - postTime(b));\n}\n\nfunction isUserPost(post: unknown): boolean {\n const p = (post ?? {}) as Loose;\n const contents = asObject(p.propsConfiguration?.contents) || {};\n const props = asObject(p.props) || {};\n const role = String(props.role ?? contents.role ?? asObject(contents.props)?.role ?? '').toUpperCase();\n return role === 'USER';\n}\n\n/** The stack label the web tile shows when a build does not name one. */\nexport const DEFAULT_TEMPLATE = 'vite-react';\n\n/**\n * Newest-first builds of one site. A later post about the same sandbox (a\n * publish, a re-post, its screenshot) updates that build.\n */\nexport function buildsFromPosts(\n posts: readonly unknown[],\n fallbackTitle?: string,\n cdnOrigin?: string,\n): WebBuilderBuild[] {\n const fallback = fallbackTitle ?? 'Web app';\n const byKey = new Map<string, WebBuilderBuild>();\n let lastKey: string | null = null;\n // The web hydrate's rule: a build is an ASSISTANT post with something to show - a\n // preview URL, a live address or a screenshot. A user turn carries the sandbox it\n // edits (and a bare sandbox id is a turn in flight), neither is a build.\n const fragments = chronological(posts)\n .filter((post) => !isUserPost(post))\n .map((post) => ({ post, fragment: readFragment(post) ?? linkFragment(post) }))\n .filter(\n (row): row is { post: unknown; fragment: Fragment } =>\n row.fragment !== null &&\n Boolean(\n row.fragment.sandboxUrl ||\n row.fragment.liveUrl ||\n row.fragment.coverImageUrl ||\n row.fragment.snapshotId,\n ),\n );\n for (const { post, fragment } of fragments) {\n const previewUrl = sandboxPreviewUrl(fragment.sandboxUrl, fragment.sandboxId);\n const key = fragment.sandboxId || previewUrl || '';\n // A publish or screenshot post may name no sandbox: it belongs to the latest build.\n const target: string | null =\n key || (fragment.liveUrl || fragment.coverImageUrl || fragment.snapshotId ? lastKey : null);\n if (target) {\n const existing = byKey.get(target);\n byKey.set(target, {\n key: target,\n // A workflow fragment names the build; a reply's site name only names a build with none yet.\n title:\n (fragment.fromReply ? existing?.title || fragment.title : fragment.title || existing?.title) ||\n fallback,\n previewUrl: previewUrl || existing?.previewUrl || null,\n sandboxId: fragment.sandboxId || existing?.sandboxId || null,\n projectId: fragment.projectId || existing?.projectId || null,\n liveUrl: fragment.liveUrl || existing?.liveUrl || null,\n files: fragment.files || existing?.files || null,\n snapshotId: fragment.snapshotId || existing?.snapshotId || null,\n origin: existing?.origin === 'workflow' || !fragment.fromReply ? 'workflow' : 'agent',\n templateId: fragment.template || existing?.templateId || DEFAULT_TEMPLATE,\n coverUrl:\n coverDisplayUrl(fragment.coverImageUrl, fragment.coverImagePath, cdnOrigin) ||\n existing?.coverUrl ||\n null,\n updatedAt: Math.max(postTime(post), existing?.updatedAt ?? 0),\n });\n lastKey = target;\n }\n }\n return [...byKey.values()].filter((b) => b.previewUrl || b.liveUrl).sort((a, b) => b.updatedAt - a.updatedAt);\n}\n\n/** The newest post flags a sandbox still being created or a publish still running. */\nexport function pendingWork(posts: readonly unknown[]): 'creating' | 'publishing' | null {\n const newest = chronological(posts)\n .map((post) => readFragment(post))\n .filter((f): f is Fragment => f !== null)\n .pop();\n if (!newest) return null;\n if (newest.isCreatingSandbox && !newest.sandboxUrl && !newest.sandboxId) return 'creating';\n if (newest.isDeploying && !newest.liveUrl) return 'publishing';\n return null;\n}\n\n// ── Titles: the web surface's `resolveArtifactTitle` rules ─────────────────\n\n/** Not a product name: what the workflow and the chat call a site before it has one. */\nexport function isGenericTitle(title?: string | null): boolean {\n const t = (title || '').trim().toLowerCase();\n return (\n !t ||\n t === 'generated page' ||\n t === 'generated project' ||\n t === 'generated with cdecli' ||\n t === 'ai assistant' ||\n t === 'web app' ||\n // The placeholder a site carries before it has a name; a saved one is not a rename.\n /^new (site|app)$/.test(t) ||\n /^build \\d+$/.test(t) ||\n /^build\\s+me\\b/.test(t) ||\n /^remix\\s+the\\b/.test(t) ||\n /^(build|chat)[- ]channel\\b/.test(t) ||\n /^deep-search-[0-9a-f]{8}-/.test(t) ||\n t.startsWith('selected skill') ||\n /^code[\\s_-]?assist/.test(t)\n );\n}\n\nconst TITLE_STOP_WORDS = new Set([\n 'a',\n 'an',\n 'the',\n 'create',\n 'build',\n 'make',\n 'please',\n 'me',\n 'my',\n 'for',\n 'with',\n 'simple',\n 'using',\n 'from',\n 'template',\n 'to',\n 'and',\n 'or',\n 'remix',\n 'yantra',\n]);\n\nfunction titleCase(words: string[]): string {\n return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(' ');\n}\n\n// Every note a turn carries after the person's words (the web's and this app's); older posts too.\nconst KNOWN_NOTE_RE =\n /^\\[(?:Project channelId=[^\\]\\n]*|Database slug=[^\\]\\n]*|\\d+ attachment\\(s\\)|Mode: [a-z]+|Project instructions|Approved plan|Reference site|UI kit|Style direction|Database|AI in the app|Integrations|Element|Fix error|Hand edits|Open build|Open site|Inspired by|New site|Template|Brand kit|Imported project|Export|Asset|Figma|File text|Mentions|Draft|Image edit|Site media)\\]/;\nconst NOTE_LINE_RE = /^\\[(?:[A-Z][A-Za-z]*(?: [A-Za-z]+){0,3}|[A-Z][A-Za-z ]*=[^\\]\\n]*|\\d+ attachment\\(s\\))\\]/;\n// The studio's old brand block, sent as part of the message before it became a note.\nconst LEGACY_BRAND_BLOCK_RE = /^Brand kit \\(follow it\\):\\s*$/;\n// The web's \"New from this\" wrapper around a remix ask.\nconst REFERENCE_WRAPPER_RE =\n /^Using “[^”]*” as reference \\(do not edit that sandbox\\)\\.\\nCreate a new app from the user request below\\.\\n\\n/;\n\n/**\n * The person's words, without the notes a turn carries for the agent (web `stripSurfaceNotes`):\n * everything from the first note on - a known `[Tag]` line, the old brand block, or any\n * `[Tag]` line after a blank one (notes follow one). A \"Build me:\" brief keeps its prefix.\n */\nexport function stripAgentNote(content: string): string {\n const lines = String(content || '')\n .replace(REFERENCE_WRAPPER_RE, '')\n .replace(/\\r\\n?/g, '\\n')\n .split('\\n');\n let cut = lines.length;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trimStart();\n if (\n KNOWN_NOTE_RE.test(line) ||\n LEGACY_BRAND_BLOCK_RE.test(line) ||\n (i > 0 && !lines[i - 1].trim() && NOTE_LINE_RE.test(line))\n ) {\n cut = i;\n break;\n }\n }\n return lines.slice(0, cut).join('\\n').trim();\n}\n\n/** What the person wrote, as their bubble shows it: no notes, no studio \"Build me:\" prefix. */\nexport function userBubbleText(content: string): string {\n return stripAgentNote(content).replace(/^\\s*Build me:\\s*/i, '');\n}\n\n/** The person's words, without the internal lines a turn carries. */\nexport function cleanPrompt(text: string): string {\n return text\n .replace(/^\\[webbuilder context:[^\\]]*\\]\\s*/i, '')\n .replace(/^build\\s*me\\s*:\\s*/i, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/**\n * Product name from a brief: \"Build me: todo app\" -> \"Todo App\". An edit\n * (\"make the header blue\") is not a name.\n */\nexport function titleFromPrompt(message?: string | null): string | null {\n const raw = (message || '').replace(/^\\[webbuilder context:[^\\]]*\\]\\s*/i, '').trim();\n if (!raw) return null;\n const buildMe = raw.match(/^\\s*Build me:\\s*(.+)$/im)?.[1]?.trim();\n if (!buildMe && /^(change|update|rename|fix|edit|add|remove|delete|improve|make|refactor)\\b/i.test(raw)) {\n return null;\n }\n const source = (buildMe || raw.split(/\\n+/)[0] || '').replace(/^[\"']|[\"']$/g, '');\n const words = source\n .replace(/[^\\w\\s-]/g, ' ')\n .split(/\\s+/)\n .filter((w) => w.length > 1 && !TITLE_STOP_WORDS.has(w.toLowerCase()))\n .slice(0, 3);\n if (!words.length) return null;\n const title = titleCase(words);\n return isGenericTitle(title) ? null : title;\n}\n\n/** `package.json` name of the build (\"bakery-site\" -> \"Bakery Site\"). */\nfunction titleFromPackageJson(files?: Record<string, string> | null): string | null {\n if (!files) return null;\n const raw = Object.entries(files).find(([path]) => /(^|\\/)package\\.json$/.test(path))?.[1];\n if (!raw) return null;\n try {\n const name = String((JSON.parse(raw) as { name?: string }).name || '').trim();\n if (!name || name === 'vite-react' || name === 'project') return null;\n return name\n .replace(/^@[^/]+\\//, '')\n .replace(/[-_]+/g, ' ')\n .replace(/\\b\\w/g, (c) => c.toUpperCase());\n } catch {\n return null;\n }\n}\n\n/** The build's own title, then the brief's product name, the chat's name, the package name. */\n/**\n * \"a bakery called Crumb & Co\", \"named 'Lotus Flow'\", \"Brand name: Crumb & Co\", \"a site for Tidewater Coffee, a\n * coffee cart\" -> the name the person gave the site (web, #49f607ee). Lower case after \"for\" is a description.\n */\n// A business name in a brief (web 0.9, `businessNameFrom`): capitalised words, joined by &, and, of or the\n// (\"Paws & Polish\", \"House of Bao\"). Letters without \\p{L}, which older Hermes builds may not have.\nconst BUSINESS_NAME = String.raw`[A-Z][A-Za-zÀ-ÖØ-öø-ÿ\\d'’.-]*(?:\\s+(?:&|and|of|the|de|la|[A-Z][A-Za-zÀ-ÖØ-öø-ÿ\\d'’.-]*))*`;\nconst BUSINESS_NAME_RES = [\n new RegExp(String.raw`\\b(?:called|named)\\s+[\"“]?(${BUSINESS_NAME})`),\n new RegExp(String.raw`\\bfor\\s+[\"“]?(${BUSINESS_NAME})[\"”]?\\s*(?:,|\\(|-|–|—|\\bin\\b|\\ba\\b|\\ban\\b|$)`),\n];\n\n/** The business the brief names (\"…for Paws & Polish, a dog grooming salon\" -> \"Paws & Polish\"), else null. */\nexport function businessNameFrom(text: string): string | null {\n const one = text.replace(/\\s+/g, ' ').trim();\n for (const re of BUSINESS_NAME_RES) {\n const name = one\n .match(re)?.[1]\n ?.trim()\n .replace(/\\s+(?:&|and|of|the|de|la)$/i, '');\n if (name && name.length >= 3 && name.length <= 40 && !/^(?:My|Our|Your|The|A|An)$/.test(name)) return name;\n }\n return null;\n}\n\n// \"my bakery sweet crumbs in pune\" (web 0.17, 76d57d73): the words after the kind of business, up to the place.\nconst OWN_BUSINESS_NAME_RE =\n /\\b(?:my|our)\\s+(?:bakery|cafe|café|coffee shop|restaurant|shop|store|boutique|studio|salon|spa|clinic|gym|agency|business|company|brand|startup|practice|firm)\\s+(?!(?:with|in|at|for|that|which|near|and|to|a|an|the|where|selling|serving)\\b)([a-z][\\w&'’-]*(?:\\s+(?!(?:with|in|at|for|that|which|near|and|to|where|selling|serving)\\b)[a-z][\\w&'’-]*){0,2})(?=\\s+(?:in|at|near|with|for|that|which|selling|serving)\\b|\\s*[,.;!?]|\\s*$)/i;\n\n// The website import's own line (websiteImportBrief): \"Copy my website https://www.cafe.com/ here, page for page…\".\nconst COPIED_SITE_RE = /^\\s*Copy my website (https:\\/\\/\\S+)/i;\n\n/** The site a copy starts from goes by its address: \"cafe.com\". */\nfunction copiedSiteName(text: string): string | null {\n const url = COPIED_SITE_RE.exec(text)?.[1];\n if (!url) return null;\n const host = /^https:\\/\\/([^/?#]+)/i.exec(url)?.[1];\n return host ? host.replace(/^www\\./, '') : null;\n}\n\nexport function siteNameFromRequest(text: string | null | undefined): string | null {\n const t = String(text ?? '');\n const copied = copiedSiteName(t);\n if (copied) return copied;\n const m =\n t.match(/^[ \\t-]*Brand name:\\s*([^\\n]{2,40})$/im) ??\n t.match(/\\b(?:called|named)\\s+[\"“'‘]([^\"”'’\\n]{2,40})[\"”'’]/i) ??\n t.match(/\\b(?:called|named)\\s+([A-Z0-9][\\w&'’.-]*(?:\\s+(?:&|and|[A-Z0-9][\\w&'’.-]*))*)/) ??\n t.match(/\\b(?:site|website|page|app)\\s+for\\s+([A-Z0-9][\\w&'’.-]*(?:\\s+(?:&|and|[A-Z0-9][\\w&'’.-]*)){0,4})/);\n const lower = m ? null : OWN_BUSINESS_NAME_RE.exec(t);\n if (lower) return lower[1].trim().replace(/\\b([a-z])/g, (c) => c.toUpperCase());\n const name = m?.[1]\n ?.split(/[.!?]\\s/)[0]\n .replace(/\\s+(?:&|and)$/i, '')\n .replace(/[.,;:!?]+$/, '')\n .trim();\n if (name && name.length >= 2) return name;\n return businessNameFrom(t.split(/\\n\\n\\[/)[0]);\n}\n\nexport function resolveSiteTitle(opts: {\n fragmentTitle?: string | null;\n channelTitle?: string | null;\n userPrompt?: string | null;\n /** The first request as sent (its brand kit note too): the name the person gave the site. */\n requestText?: string | null;\n files?: Record<string, string> | null;\n}): string {\n const candidates = [\n opts.fragmentTitle,\n siteNameFromRequest(opts.requestText),\n titleFromPrompt(opts.userPrompt),\n opts.channelTitle,\n titleFromPackageJson(opts.files),\n ];\n const found = candidates.find((c) => c && !isGenericTitle(c));\n return (found || 'Generated Page').trim();\n}\n\n// ── Sites ──────────────────────────────────────────────────────────────────\n\nexport interface ChannelLike {\n id?: string | null;\n title?: string | null;\n displayName?: string | null;\n updatedAt?: unknown;\n createdAt?: unknown;\n lastMessage?: unknown;\n}\n\n/** True when the newest build in `lastMessage` already carries a cover - the web skips the thread read then. */\nexport function lastMessageHasCover(channel: ChannelLike): boolean {\n return Boolean(readFragment(channel.lastMessage)?.coverImageUrl);\n}\n\n/**\n * A site from one chat's posts, the way the web gallery hydrates a tile: only\n * a chat with a build is a site; its name follows `resolveSiteTitle`.\n */\nexport function projectFromPosts(\n channel: ChannelLike,\n posts: readonly unknown[],\n cdnOrigin?: string,\n): WebBuilderProject | null {\n const channelId = str(channel.id);\n if (!channelId) return null;\n const builds = buildsFromPosts(posts, '', cdnOrigin);\n const latest = builds[0];\n if (!latest) return null;\n const userPosts = chronological(posts).filter((post) => isUserPost(post) && str((post as Loose).message));\n const userPrompts = userPosts\n // The person's own words: a note sent along (a brand kit) is not a title source.\n .map((post) => stripAgentNote(String((post as Loose).message)))\n .filter(Boolean);\n // The brief names the product (\"Build me: …\"); a later message (\"the live preview is\n // not loading\") never does, so only the brief - or failing that the first ask - counts.\n const brief = userPrompts.find((m) => /build\\s*me\\s*:/i.test(m)) ?? userPrompts[0];\n const rawChannelTitle = [channel.displayName, channel.title]\n .map((t) => str(t))\n .find((t) => t && !isGenericTitle(t));\n // A chat named after its brief (\"Build simple calculator app\") gives the product name, not the sentence.\n const channelTitle =\n rawChannelTitle && /^(build|create|make)\\b/i.test(rawChannelTitle)\n ? (titleFromPrompt(rawChannelTitle) ?? rawChannelTitle)\n : rawChannelTitle;\n const title = resolveSiteTitle({\n fragmentTitle: latest.title,\n channelTitle,\n userPrompt: brief,\n requestText: userPosts.length ? String((userPosts[0] as Loose).message) : null,\n files: latest.files,\n });\n const updated = Date.parse(String(channel.updatedAt ?? channel.createdAt ?? ''));\n return {\n channelId,\n title,\n updatedAt: Math.max(Number.isFinite(updated) ? updated : 0, latest.updatedAt),\n previewUrl: latest.previewUrl,\n liveUrl: builds.find((b) => b.liveUrl)?.liveUrl ?? null,\n coverUrl: builds.find((b) => b.coverUrl)?.coverUrl ?? null,\n templateId: latest.templateId,\n };\n}\n\n/** `?wb=<n>` on the preview so a rebuilt sandbox is fetched again, not served from cache. */\nexport function cacheBustedUrl(url: string, nonce: number | string): string {\n const [base, hash = ''] = url.split('#');\n const clean = base.replace(/([?&])wb=[^&]*(&|$)/, '$1').replace(/[?&]$/, '');\n const sep = clean.includes('?') ? '&' : '?';\n return `${clean}${sep}wb=${nonce}${hash ? `#${hash}` : ''}`;\n}\n\n/**\n * The publish name the web dialog suggests: the site's title as a slug,\n * `[a-z0-9-]`, at most 58 characters (`<name>.yarntra.com`).\n */\nexport function publishSlug(title: string): string {\n const slug = title\n .toLowerCase()\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 58)\n .replace(/-+$/, '');\n return slug || 'my-site';\n}\n\nexport function isValidPublishSlug(value: string): boolean {\n return /^[a-z0-9](?:[a-z0-9-]{0,56}[a-z0-9])?$/.test(value);\n}\n\n/** Display host of a URL: `https://bakery.pages.dev/` -> `bakery.pages.dev`. */\nexport function displayHost(url: string | null | undefined): string {\n const match = /^https?:\\/\\/([^/?#]+)/i.exec((url ?? '').trim());\n return match ? match[1] : (url ?? '').trim();\n}\n\n/** \"just now\", \"5 min ago\", \"3 h ago\", \"Yesterday\", \"12 Oct\". */\nexport function relativeTime(ms: number, now = Date.now()): string {\n if (!ms) return '';\n const diff = Math.max(0, now - ms);\n const min = Math.floor(diff / 60_000);\n if (min < 1) return 'just now';\n if (min < 60) return `${min} min ago`;\n const hours = Math.floor(min / 60);\n if (hours < 24) return `${hours} h ago`;\n if (hours < 48) return 'Yesterday';\n const d = new Date(ms);\n const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n return `${d.getDate()} ${months[d.getMonth()]}`;\n}\n\n// ── The agent transcript: the build chat's posts, as the web Agent pane shows them ──\n\n/** A live progress row (web `isThinkingPost`): shown as the agent's status, never kept. */\nexport function isThinkingPost(post: unknown): boolean {\n const p = (post ?? {}) as Loose;\n const props = asObject(p.props) || {};\n const attachment = asObject(props.attachment) || {};\n const msg = String(p.message ?? '')\n .trim()\n .toLowerCase();\n return (\n String(p.type ?? '').toUpperCase() === 'THINKING' ||\n Boolean(props.thinking ?? props.isThinking) ||\n props.kind === 'thinking' ||\n Boolean(attachment.isThinking) ||\n msg === 'thinking...' ||\n msg === 'initializing...' ||\n msg === 'initializing…'\n );\n}\n\nfunction readFragmentStatus(p: Loose): string | undefined {\n const contents = asObject(p.propsConfiguration?.contents) || {};\n return (\n str(asObject(asObject(contents.props)?.fragment)?.statusText) || str(asObject(contents.fragment)?.statusText)\n );\n}\n\n/** The workflow's progress line on a post: its thought, else the fragment's status. */\nexport function progressText(post: unknown): string | null {\n const p = (post ?? {}) as Loose;\n const props = asObject(p.props) || {};\n const thought = str(asObject(props.attachment)?.thought);\n if (thought) return thought;\n const status = str(asObject(props.fragment)?.statusText) || str(readFragmentStatus(p));\n if (status) return status;\n return isThinkingPost(post) ? (str(p.message) ?? null) : null;\n}\n\n/** A post the workflow wrote when the build failed (`fragment.isError` / `type: 'error'`). */\nexport function isErrorPost(post: unknown): boolean {\n const p = (post ?? {}) as Loose;\n const props = asObject(p.props) || {};\n const contents = asObject(p.propsConfiguration?.contents) || {};\n const f =\n asObject(props.fragment) || asObject(asObject(contents.props)?.fragment) || asObject(contents.fragment) || {};\n return f.isError === true || f.type === 'error';\n}\n\nexport interface TranscriptMessage {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n createdAt: number;\n}\n\n/**\n * The conversation in a build chat: the person's turns and the agent's replies,\n * oldest first, without progress rows or empty build markers.\n */\nexport function transcriptFromPosts(posts: readonly unknown[]): TranscriptMessage[] {\n const out: TranscriptMessage[] = [];\n for (const post of chronological(posts)) {\n const p = post as Loose;\n const text = str(p.message);\n if (text && !isThinkingPost(post)) {\n const user = isUserPost(post);\n out.push({\n id: String(p.id ?? `${user ? 'u' : 'a'}-${out.length}`),\n role: user ? 'user' : 'assistant',\n content: user ? cleanPrompt(text) || text : text,\n createdAt: postTime(post),\n });\n }\n }\n return out;\n}\n\n/**\n * How a turn started at `since` is going, read from the posts that arrived after it.\n * `heard` is whether the build posted anything back yet (a progress row, an answer).\n */\nexport function turnState(\n posts: readonly unknown[],\n since: number,\n): { status: 'running' | 'done' | 'failed'; progress: string | null; error: string | null; heard: boolean } {\n // A clock skew allowance, as the web ignores posts older than start - 2 s.\n const after = chronological(posts).filter((post) => postTime(post) >= since - 2_000);\n let progress: string | null = null;\n for (const post of after) {\n if (!isUserPost(post)) {\n if (isErrorPost(post)) {\n const p = post as Loose;\n return { status: 'failed', progress: null, error: str(p.message) ?? 'The build failed.', heard: true };\n }\n const fragment = readFragment(post);\n if (fragment && (fragment.sandboxUrl || fragment.liveUrl) && !isThinkingPost(post)) {\n return { status: 'done', progress: null, error: null, heard: true };\n }\n progress = progressText(post) ?? progress;\n }\n }\n // A plain answer (the agent asked a question, or replied without building) ends\n // the turn too - unless progress rows keep arriving after it.\n const newest = after.filter((post) => !isUserPost(post)).pop() as Loose | undefined;\n if (newest && !isThinkingPost(newest) && !progressText(newest) && str(newest.message)) {\n return { status: 'done', progress: null, error: null, heard: true };\n }\n return { status: 'running', progress, error: null, heard: Boolean(newest) };\n}\n\n/**\n * A turn sent through the build workflow: its USER post carries the workflow's\n * route (`templateTarget`). A blank build sends an empty fragment, which\n * the server drops, so this post is the only workflow mark until a build lands.\n */\nfunction isWorkflowTurnPost(post: unknown): boolean {\n if (!post || typeof post !== 'object') return false;\n const p = post as Loose;\n const contents = asObject(p.propsConfiguration?.contents) || {};\n return Boolean(str(asObject(p.props)?.templateTarget) || str(asObject(contents.props)?.templateTarget));\n}\n\n/**\n * The chat was built through the build workflow (its posts carry fragments or\n * the workflow's route): edits go back through the workflow. A chat without\n * any is an agent-chat site (a template remix), and its turns stay in the\n * agent chat.\n */\nexport function hasWorkflowPosts(posts: readonly unknown[]): boolean {\n return posts.some((post) => readFragment(post) !== null || isWorkflowTurnPost(post));\n}\n"],"names":["_a"],"mappings":"uZA0CA,SAAS,SAAS,KAA8B,EAAA;AAC9C,EAAI,IAAA,CAAC,OAAc,OAAA,IAAA;AACnB,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA,OAAO,MAAM,OAAQ,CAAA,KAAK,IAAI,IAAO,GAAA,KAAA;AACpE,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,IAAM,MAAA,OAAA,GAAU,MAAM,IAAK,EAAA;AAC3B,IAAA,IAAI,CAAC,OAAA,CAAQ,UAAW,CAAA,GAAG,GAAU,OAAA,IAAA;AACrC,IAAI,IAAA;AACF,MAAM,MAAA,MAAA,GAAS,IAAK,CAAA,KAAA,CAAM,OAAO,CAAA;AACjC,MAAA,OAAO,MAAU,IAAA,OAAO,MAAW,KAAA,QAAA,GAAW,MAAkB,GAAA,IAAA;AAAA,KAC1D,CAAA,OAAA,CAAA,EAAA;AACN,MAA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,QAAQ,MAAM;AAAA,GACvB;AACF;AAOA,SAAS,mBAAmB,IAAwB,EAAA;AAzrBpD,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AA0rBE,EAAA,IAAI,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,UAAiB,OAAA,KAAA;AAC9C,EAAA,MAAM,CAAI,GAAA,IAAA;AACV,EAAA,MAAM,WAAW,QAAS,CAAA,CAAA,EAAA,GAAA,CAAA,CAAE,uBAAF,IAAsB,GAAA,MAAA,GAAA,EAAA,CAAA,QAAQ,KAAK,EAAC;AAC9D,EAAA,OAAO,QAAQ,GAAI,CAAA,CAAA,EAAA,GAAA,QAAA,CAAS,CAAE,CAAA,KAAK,MAAhB,IAAmB,GAAA,MAAA,GAAA,EAAA,CAAA,cAAc,CAAK,IAAA,GAAA,CAAA,CAAI,cAAS,QAAS,CAAA,KAAK,CAAvB,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAA0B,cAAc,CAAC,CAAA;AACxG;AAQO,SAAS,iBAAiB,KAAoC,EAAA;AACnE,EAAO,OAAA,KAAA,CAAM,KAAK,CAAQ,IAAA,KAAA,YAAA,CAAa,IAAI,CAAM,KAAA,IAAA,IAAQ,kBAAmB,CAAA,IAAI,CAAC,CAAA;AACnF"}
@@ -111,4 +111,32 @@ function encodeCodezenHandoff(handoff) {
111
111
  throw new Error("This build is too large to send to Codezen in one go.");
112
112
  }
113
113
  return fragment;
114
- }export{CODEZEN_DEV_URL,CODEZEN_HANDOFF_MAX_CHARS,CODEZEN_TEMPLATE_PARAM,demoVideoSource,encodeCodezenHandoff,isServerFetchableUrl,toBase64Url,webbuilderDemoHandoff};//# sourceMappingURL=codezenHandoff.js.map
114
+ }
115
+ const CODEZEN_REPO_PARAM = "codezen_repo";
116
+ const GITHUB_REPO_URL_RE = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/;
117
+ const BRANCH_RE = /^[A-Za-z0-9._/-]{1,200}$/;
118
+ function codezenRepoHandoff(repoUrl, opts = {}) {
119
+ var _a, _b;
120
+ const m = String(repoUrl != null ? repoUrl : "").trim().match(GITHUB_REPO_URL_RE);
121
+ if (!m) return null;
122
+ const branch = String((_a = opts.branch) != null ? _a : "").trim();
123
+ const title = String((_b = opts.title) != null ? _b : "").replace(/\s+/g, " ").trim().slice(0, 200);
124
+ return __spreadProps(__spreadValues(__spreadValues({
125
+ v: 1,
126
+ repoUrl: `https://github.com/${m[1]}/${m[2]}`
127
+ }, branch && BRANCH_RE.test(branch) && !branch.includes("..") ? {
128
+ branch
129
+ } : {}), title ? {
130
+ title
131
+ } : {}), {
132
+ from: "webbuilder"
133
+ });
134
+ }
135
+ function codezenRepoFragment(handoff) {
136
+ return `${CODEZEN_REPO_PARAM}=${toBase64Url(JSON.stringify(handoff))}`;
137
+ }
138
+ function isUserOwnedRepo(repoUrl) {
139
+ const m = String(repoUrl != null ? repoUrl : "").match(GITHUB_REPO_URL_RE);
140
+ return Boolean(m && m[1].toLowerCase() !== "yantra-userbase");
141
+ }
142
+ const CODEZEN_NEEDS_GITHUB = "Your code is saved, but Codezen needs your own GitHub. Connect your GitHub account in Yantra, then choose Code in Codezen again.";export{CODEZEN_DEV_URL,CODEZEN_HANDOFF_MAX_CHARS,CODEZEN_NEEDS_GITHUB,CODEZEN_REPO_PARAM,CODEZEN_TEMPLATE_PARAM,codezenRepoFragment,codezenRepoHandoff,demoVideoSource,encodeCodezenHandoff,isServerFetchableUrl,isUserOwnedRepo,toBase64Url,webbuilderDemoHandoff};//# sourceMappingURL=codezenHandoff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codezenHandoff.js","sources":["../../../src/features/webbuilder/codezenHandoff.ts"],"sourcesContent":["/* eslint-disable no-bitwise -- UTF-8 and base64url are byte arithmetic */\n/**\n * \"Demo video\": hand a build to Codezen, which builds a repo from its\n * `demo-video` template and films the app into an MP4 + GIF (web 0.5.0\n * `utils/codezenHandoff.ts`). Pure, so the remote and its tests share it.\n *\n * The wire format is a fragment on the Codezen page:\n *\n * #codezen_template=<base64url(UTF-8 JSON of a CodezenHandoff), no padding>\n *\n * Codezen's sandbox opens the app minutes later from a server, so the link must\n * be public https: the published site when there is one (stable), else the live\n * E2B preview (works while the sandbox is awake).\n */\n\nexport const CODEZEN_TEMPLATE_PARAM = 'codezen_template';\n/** The longest fragment handed over (same cap as the kit). */\nexport const CODEZEN_HANDOFF_MAX_CHARS = 60_000;\nexport const CODEZEN_DEV_URL = 'https://codezen-surface.yantra-app-v1.cdebase.dev/';\n\nexport interface CodezenHandoff {\n v: 1;\n template: 'demo-video';\n title?: string;\n brief?: string;\n source:\n | {\n kind: 'url';\n url: string;\n displayUrl?: string;\n from: 'webbuilder';\n }\n | {\n /** One picture per page, in order (a design's pages). */\n kind: 'images';\n urls: string[];\n titles?: string[];\n from: 'canvas';\n };\n options?: { aspect?: '16:9' | '1:1' | '4:5' | '9:16' };\n}\n\nexport interface DemoVideoSource {\n url: string;\n /** The host to show instead of a long URL - set for a published site. */\n displayUrl?: string;\n /** Published: the link outlives the sandbox. False = the live preview. */\n stable: boolean;\n}\n\nfunction hostOf(url: string): string | null {\n const match = /^https:\\/\\/([^/?#\\s]+)/i.exec(url.trim());\n return match ? match[1].toLowerCase() : null;\n}\n\n/** A URL a server can fetch: absolute https, nothing local to this device. */\nexport function isServerFetchableUrl(raw: string | null | undefined): boolean {\n if (!raw || raw.length > 4096) return false;\n const host = hostOf(raw)?.replace(/:\\d+$/, '');\n if (!host) return false;\n return host !== 'localhost' && !host.endsWith('.localhost') && host !== '127.0.0.1';\n}\n\n/**\n * Which link Codezen films: the published site when there is one, else the live\n * preview without the `?wb=` cache-bust. Null when neither is public https.\n */\nexport function demoVideoSource(\n published: string | null | undefined,\n preview: string | null | undefined,\n): DemoVideoSource | null {\n if (published && isServerFetchableUrl(published)) {\n return { url: published.trim(), displayUrl: hostOf(published) ?? undefined, stable: true };\n }\n const live = (preview ?? '').trim();\n if (!live || !isServerFetchableUrl(live)) return null;\n const [base, hash = ''] = live.split('#');\n const [path, query = ''] = base.split('?');\n const kept = query.split('&').filter((part) => part && !/^wb=/.test(part));\n return { url: `${path}${kept.length ? `?${kept.join('&')}` : ''}${hash ? `#${hash}` : ''}`, stable: false };\n}\n\n/** The handoff for one build. A web app films best wide, so 16:9. */\nexport function webbuilderDemoHandoff(title: string, source: DemoVideoSource): CodezenHandoff {\n const name = title.replace(/\\s+/g, ' ').trim().slice(0, 200);\n return {\n v: 1,\n template: 'demo-video',\n ...(name ? { title: name } : {}),\n source: {\n kind: 'url',\n url: source.url,\n ...(source.displayUrl ? { displayUrl: source.displayUrl } : {}),\n from: 'webbuilder',\n },\n options: { aspect: '16:9' },\n };\n}\n\nfunction utf8Bytes(text: string): number[] {\n const bytes: number[] = [];\n for (const char of text) {\n const code = char.codePointAt(0) ?? 0;\n if (code < 0x80) bytes.push(code);\n else if (code < 0x800) bytes.push(0xc0 | (code >> 6), 0x80 | (code & 63));\n else if (code < 0x10000) bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));\n else bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 63), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));\n }\n return bytes;\n}\n\nconst B64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\n\n/** base64url without padding (no `btoa`/`TextEncoder`, which Hermes may lack). */\nexport function toBase64Url(text: string): string {\n const bytes = utf8Bytes(text);\n let out = '';\n for (let i = 0; i < bytes.length; i += 3) {\n const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);\n out += B64URL[(n >> 18) & 63] + B64URL[(n >> 12) & 63];\n if (i + 1 < bytes.length) out += B64URL[(n >> 6) & 63];\n if (i + 2 < bytes.length) out += B64URL[n & 63];\n }\n return out;\n}\n\n/** `codezen_template=<payload>` (no leading `#`). Throws an Error whose message is safe to show. */\nexport function encodeCodezenHandoff(handoff: CodezenHandoff): string {\n const { source } = handoff;\n if (source.kind === 'images') {\n if (source.urls.length === 0) throw new Error('Codezen needs at least one page.');\n if (!source.urls.every(isServerFetchableUrl)) throw new Error('A page has no public link Codezen can open.');\n } else if (!isServerFetchableUrl(source.url)) {\n throw new Error('The app link must be a public https link Codezen can open.');\n }\n const fragment = `${CODEZEN_TEMPLATE_PARAM}=${toBase64Url(JSON.stringify(handoff))}`;\n if (fragment.length > CODEZEN_HANDOFF_MAX_CHARS) {\n throw new Error('This build is too large to send to Codezen in one go.');\n }\n return fragment;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAeO,MAAM,sBAAyB,GAAA;AAE/B,MAAM,yBAA4B,GAAA;AAClC,MAAM,eAAkB,GAAA;AA6B/B,SAAS,OAAO,GAA4B,EAAA;AAC1C,EAAA,MAAM,KAAQ,GAAA,yBAAA,CAA0B,IAAK,CAAA,GAAA,CAAI,MAAM,CAAA;AACvD,EAAA,OAAO,KAAQ,GAAA,KAAA,CAAM,CAAC,CAAA,CAAE,aAAgB,GAAA,IAAA;AAC1C;AAGO,SAAS,qBAAqB,GAAyC,EAAA;AArD9E,EAAA,IAAA,EAAA;AAsDE,EAAA,IAAI,CAAC,GAAA,IAAO,GAAI,CAAA,MAAA,GAAS,MAAa,OAAA,KAAA;AACtC,EAAA,MAAM,QAAO,EAAO,GAAA,MAAA,CAAA,GAAG,CAAV,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAa,QAAQ,OAAS,EAAA,EAAA,CAAA;AAC3C,EAAI,IAAA,CAAC,MAAa,OAAA,KAAA;AAClB,EAAA,OAAO,SAAS,WAAe,IAAA,CAAC,KAAK,QAAS,CAAA,YAAY,KAAK,IAAS,KAAA,WAAA;AAC1E;AAMgB,SAAA,eAAA,CAAgB,WAAsC,OAA4D,EAAA;AAhElI,EAAA,IAAA,EAAA;AAiEE,EAAI,IAAA,SAAA,IAAa,oBAA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,CAAA,KAAA,CAAM,oBAAoB,CAAG,EAAA,MAAM,IAAI,KAAA,CAAM,6CAA6C,CAAA;AAAA,GAClG,MAAA,IAAA,CAAC,oBAAqB,CAAA,MAAA,CAAO,GAAG,CAAG,EAAA;AAC5C,IAAM,MAAA,IAAI,MAAM,4DAA4D,CAAA;AAAA;AAE9E,EAAM,MAAA,QAAA,GAAW,GAAG,sBAAsB,CAAA,CAAA,EAAI,YAAY,IAAK,CAAA,SAAA,CAAU,OAAO,CAAC,CAAC,CAAA,CAAA;AAClF,EAAI,IAAA,QAAA,CAAS,SAAS,yBAA2B,EAAA;AAC/C,IAAM,MAAA,IAAI,MAAM,uDAAuD,CAAA;AAAA;AAEzE,EAAO,OAAA,QAAA;AACT"}
1
+ {"version":3,"file":"codezenHandoff.js","sources":["../../../src/features/webbuilder/codezenHandoff.ts"],"sourcesContent":["/* eslint-disable no-bitwise -- UTF-8 and base64url are byte arithmetic */\n/**\n * \"Demo video\": hand a build to Codezen, which builds a repo from its\n * `demo-video` template and films the app into an MP4 + GIF (web 0.5.0\n * `utils/codezenHandoff.ts`). Pure, so the remote and its tests share it.\n *\n * The wire format is a fragment on the Codezen page:\n *\n * #codezen_template=<base64url(UTF-8 JSON of a CodezenHandoff), no padding>\n *\n * Codezen's sandbox opens the app minutes later from a server, so the link must\n * be public https: the published site when there is one (stable), else the live\n * E2B preview (works while the sandbox is awake).\n */\n\nexport const CODEZEN_TEMPLATE_PARAM = 'codezen_template';\n/** The longest fragment handed over (same cap as the kit). */\nexport const CODEZEN_HANDOFF_MAX_CHARS = 60_000;\nexport const CODEZEN_DEV_URL = 'https://codezen-surface.yantra-app-v1.cdebase.dev/';\n\nexport interface CodezenHandoff {\n v: 1;\n template: 'demo-video';\n title?: string;\n brief?: string;\n source:\n | {\n kind: 'url';\n url: string;\n displayUrl?: string;\n from: 'webbuilder';\n }\n | {\n /** One picture per page, in order (a design's pages). */\n kind: 'images';\n urls: string[];\n titles?: string[];\n from: 'canvas';\n };\n options?: { aspect?: '16:9' | '1:1' | '4:5' | '9:16' };\n}\n\nexport interface DemoVideoSource {\n url: string;\n /** The host to show instead of a long URL - set for a published site. */\n displayUrl?: string;\n /** Published: the link outlives the sandbox. False = the live preview. */\n stable: boolean;\n}\n\nfunction hostOf(url: string): string | null {\n const match = /^https:\\/\\/([^/?#\\s]+)/i.exec(url.trim());\n return match ? match[1].toLowerCase() : null;\n}\n\n/** A URL a server can fetch: absolute https, nothing local to this device. */\nexport function isServerFetchableUrl(raw: string | null | undefined): boolean {\n if (!raw || raw.length > 4096) return false;\n const host = hostOf(raw)?.replace(/:\\d+$/, '');\n if (!host) return false;\n return host !== 'localhost' && !host.endsWith('.localhost') && host !== '127.0.0.1';\n}\n\n/**\n * Which link Codezen films: the published site when there is one, else the live\n * preview without the `?wb=` cache-bust. Null when neither is public https.\n */\nexport function demoVideoSource(\n published: string | null | undefined,\n preview: string | null | undefined,\n): DemoVideoSource | null {\n if (published && isServerFetchableUrl(published)) {\n return { url: published.trim(), displayUrl: hostOf(published) ?? undefined, stable: true };\n }\n const live = (preview ?? '').trim();\n if (!live || !isServerFetchableUrl(live)) return null;\n const [base, hash = ''] = live.split('#');\n const [path, query = ''] = base.split('?');\n const kept = query.split('&').filter((part) => part && !/^wb=/.test(part));\n return { url: `${path}${kept.length ? `?${kept.join('&')}` : ''}${hash ? `#${hash}` : ''}`, stable: false };\n}\n\n/** The handoff for one build. A web app films best wide, so 16:9. */\nexport function webbuilderDemoHandoff(title: string, source: DemoVideoSource): CodezenHandoff {\n const name = title.replace(/\\s+/g, ' ').trim().slice(0, 200);\n return {\n v: 1,\n template: 'demo-video',\n ...(name ? { title: name } : {}),\n source: {\n kind: 'url',\n url: source.url,\n ...(source.displayUrl ? { displayUrl: source.displayUrl } : {}),\n from: 'webbuilder',\n },\n options: { aspect: '16:9' },\n };\n}\n\nfunction utf8Bytes(text: string): number[] {\n const bytes: number[] = [];\n for (const char of text) {\n const code = char.codePointAt(0) ?? 0;\n if (code < 0x80) bytes.push(code);\n else if (code < 0x800) bytes.push(0xc0 | (code >> 6), 0x80 | (code & 63));\n else if (code < 0x10000) bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));\n else bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 63), 0x80 | ((code >> 6) & 63), 0x80 | (code & 63));\n }\n return bytes;\n}\n\nconst B64URL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\n\n/** base64url without padding (no `btoa`/`TextEncoder`, which Hermes may lack). */\nexport function toBase64Url(text: string): string {\n const bytes = utf8Bytes(text);\n let out = '';\n for (let i = 0; i < bytes.length; i += 3) {\n const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8) | (bytes[i + 2] ?? 0);\n out += B64URL[(n >> 18) & 63] + B64URL[(n >> 12) & 63];\n if (i + 1 < bytes.length) out += B64URL[(n >> 6) & 63];\n if (i + 2 < bytes.length) out += B64URL[n & 63];\n }\n return out;\n}\n\n/** `codezen_template=<payload>` (no leading `#`). Throws an Error whose message is safe to show. */\nexport function encodeCodezenHandoff(handoff: CodezenHandoff): string {\n const { source } = handoff;\n if (source.kind === 'images') {\n if (source.urls.length === 0) throw new Error('Codezen needs at least one page.');\n if (!source.urls.every(isServerFetchableUrl)) throw new Error('A page has no public link Codezen can open.');\n } else if (!isServerFetchableUrl(source.url)) {\n throw new Error('The app link must be a public https link Codezen can open.');\n }\n const fragment = `${CODEZEN_TEMPLATE_PARAM}=${toBase64Url(JSON.stringify(handoff))}`;\n if (fragment.length > CODEZEN_HANDOFF_MAX_CHARS) {\n throw new Error('This build is too large to send to Codezen in one go.');\n }\n return fragment;\n}\n\n/*\n * \"Code in Codezen\" (web 0.14-0.15): the whole app in Codezen's coding workspace, for what the builder doesn't run\n * (another stack, an API server next to the site, scripts). Codezen opens with `#codezen_repo=<base64url JSON>`\n * and opens that GitHub repo (and branch) in a workspace.\n */\nexport const CODEZEN_REPO_PARAM = 'codezen_repo';\n\nexport interface CodezenRepoHandoff {\n v: 1;\n /** https://github.com/<owner>/<repo> */\n repoUrl: string;\n branch?: string;\n title?: string;\n from: 'webbuilder';\n}\n\nconst GITHUB_REPO_URL_RE = /^https:\\/\\/github\\.com\\/([A-Za-z0-9_.-]+)\\/([A-Za-z0-9_.-]+?)(?:\\.git)?\\/?$/;\nconst BRANCH_RE = /^[A-Za-z0-9._/-]{1,200}$/;\n\n/** The handoff for a GitHub repo, or null when it isn't one. */\nexport function codezenRepoHandoff(\n repoUrl: string | null | undefined,\n opts: { branch?: string | null; title?: string | null } = {},\n): CodezenRepoHandoff | null {\n const m = String(repoUrl ?? '')\n .trim()\n .match(GITHUB_REPO_URL_RE);\n if (!m) return null;\n const branch = String(opts.branch ?? '').trim();\n const title = String(opts.title ?? '')\n .replace(/\\s+/g, ' ')\n .trim()\n .slice(0, 200);\n return {\n v: 1,\n repoUrl: `https://github.com/${m[1]}/${m[2]}`,\n ...(branch && BRANCH_RE.test(branch) && !branch.includes('..') ? { branch } : {}),\n ...(title ? { title } : {}),\n from: 'webbuilder',\n };\n}\n\n/** `codezen_repo=<payload>` (no leading `#`). */\nexport function codezenRepoFragment(handoff: CodezenRepoHandoff): string {\n return `${CODEZEN_REPO_PARAM}=${toBase64Url(JSON.stringify(handoff))}`;\n}\n\n/** The person's own repo, not the platform's private backup (`yantra-userbase`), which Codezen can't open as theirs. */\nexport function isUserOwnedRepo(repoUrl: string | null | undefined): boolean {\n const m = String(repoUrl ?? '').match(GITHUB_REPO_URL_RE);\n return Boolean(m && m[1].toLowerCase() !== 'yantra-userbase');\n}\n\nexport const CODEZEN_NEEDS_GITHUB =\n 'Your code is saved, but Codezen needs your own GitHub. Connect your GitHub account in Yantra, then choose Code in Codezen again.';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAeO,MAAM,sBAAyB,GAAA;AAE/B,MAAM,yBAA4B,GAAA;AAClC,MAAM,eAAkB,GAAA;AA6B/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