@adminide-stack/yantra-mobile 12.0.141-alpha.1 → 12.0.142-alpha.0

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 (227) hide show
  1. package/lib/features/agent-chat/NativeAgentChat.js +21 -4
  2. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  3. package/lib/features/chat/ApprovalCard.js +353 -0
  4. package/lib/features/chat/ApprovalCard.js.map +1 -0
  5. package/lib/features/chat/AskUserCard.js +9 -2
  6. package/lib/features/chat/AskUserCard.js.map +1 -1
  7. package/lib/features/chat/askUser.js +25 -3
  8. package/lib/features/chat/askUser.js.map +1 -1
  9. package/lib/features/chat/queuedFollowUpRows.js +13 -0
  10. package/lib/features/chat/queuedFollowUpRows.js.map +1 -0
  11. package/lib/features/dictate/DictateExperience.js +59 -7
  12. package/lib/features/dictate/DictateExperience.js.map +1 -1
  13. package/lib/features/dictate/components/NoteView.js +227 -12
  14. package/lib/features/dictate/components/NoteView.js.map +1 -1
  15. package/lib/features/dictate/dictateClient.js +93 -23
  16. package/lib/features/dictate/dictateClient.js.map +1 -1
  17. package/lib/features/dictate/dictatePreference.js +19 -0
  18. package/lib/features/dictate/dictatePreference.js.map +1 -0
  19. package/lib/features/dictate/noteText.js +17 -2
  20. package/lib/features/dictate/noteText.js.map +1 -1
  21. package/lib/features/dictate/privacy.js +96 -0
  22. package/lib/features/dictate/privacy.js.map +1 -0
  23. package/lib/features/dictate/shownNote.js +24 -0
  24. package/lib/features/dictate/shownNote.js.map +1 -0
  25. package/lib/features/discover/DiscoverArticle.js +105 -92
  26. package/lib/features/discover/DiscoverArticle.js.map +1 -1
  27. package/lib/features/discover/DiscoverFeed.js +97 -48
  28. package/lib/features/discover/DiscoverFeed.js.map +1 -1
  29. package/lib/features/discover/DiscoverFollowUp.js +135 -0
  30. package/lib/features/discover/DiscoverFollowUp.js.map +1 -0
  31. package/lib/features/discover/DiscoverSidebar.js +555 -0
  32. package/lib/features/discover/DiscoverSidebar.js.map +1 -0
  33. package/lib/features/discover/DiscoverSkeletons.js +123 -0
  34. package/lib/features/discover/DiscoverSkeletons.js.map +1 -0
  35. package/lib/features/discover/DiscoverStoryCards.js +193 -87
  36. package/lib/features/discover/DiscoverStoryCards.js.map +1 -1
  37. package/lib/features/discover/followUpQuery.js +42 -0
  38. package/lib/features/discover/followUpQuery.js.map +1 -0
  39. package/lib/features/discover/markets.js +37 -0
  40. package/lib/features/discover/markets.js.map +1 -0
  41. package/lib/features/discover/useDiscoverSidebar.js +148 -0
  42. package/lib/features/discover/useDiscoverSidebar.js.map +1 -0
  43. package/lib/features/discover/weather.js +42 -0
  44. package/lib/features/discover/weather.js.map +1 -0
  45. package/lib/features/expenses/ExpensesAgentChatPane.js +1 -1
  46. package/lib/features/expenses/ExpensesAgentChatPane.js.map +1 -1
  47. package/lib/features/inbox/InboxAgentChatPane.js +1 -1
  48. package/lib/features/inbox/InboxAgentChatPane.js.map +1 -1
  49. package/lib/features/job-search/JobSearchAgentChatPane.js +1 -0
  50. package/lib/features/job-search/JobSearchAgentChatPane.js.map +1 -1
  51. package/lib/features/local-services/LocalServicesAgentChatPane.js +1 -1
  52. package/lib/features/local-services/LocalServicesAgentChatPane.js.map +1 -1
  53. package/lib/features/movies/MoviesAgentChatPane.js +1 -1
  54. package/lib/features/movies/MoviesAgentChatPane.js.map +1 -1
  55. package/lib/features/notion/NotionBlockSheets.js +206 -0
  56. package/lib/features/notion/NotionBlockSheets.js.map +1 -0
  57. package/lib/features/notion/NotionBlockView.js +36 -0
  58. package/lib/features/notion/NotionBlockView.js.map +1 -0
  59. package/lib/features/notion/NotionCommentsSheet.js +461 -0
  60. package/lib/features/notion/NotionCommentsSheet.js.map +1 -0
  61. package/lib/features/notion/NotionConnectionsSheet.js +244 -0
  62. package/lib/features/notion/NotionConnectionsSheet.js.map +1 -0
  63. package/lib/features/notion/NotionHistorySheet.js +439 -0
  64. package/lib/features/notion/NotionHistorySheet.js.map +1 -0
  65. package/lib/features/notion/NotionMediaBlocks.js +803 -0
  66. package/lib/features/notion/NotionMediaBlocks.js.map +1 -0
  67. package/lib/features/notion/NotionMentionSheet.js +279 -0
  68. package/lib/features/notion/NotionMentionSheet.js.map +1 -0
  69. package/lib/features/notion/NotionPageMenu.js +585 -0
  70. package/lib/features/notion/NotionPageMenu.js.map +1 -0
  71. package/lib/features/notion/NotionPageTree.js +220 -0
  72. package/lib/features/notion/NotionPageTree.js.map +1 -0
  73. package/lib/features/notion/NotionPageView.js +1253 -152
  74. package/lib/features/notion/NotionPageView.js.map +1 -1
  75. package/lib/features/notion/NotionShareSheet.js +606 -0
  76. package/lib/features/notion/NotionShareSheet.js.map +1 -0
  77. package/lib/features/notion/NotionSheets.js +87 -15
  78. package/lib/features/notion/NotionSheets.js.map +1 -1
  79. package/lib/features/notion/NotionSidebarSections.js +492 -0
  80. package/lib/features/notion/NotionSidebarSections.js.map +1 -0
  81. package/lib/features/notion/NotionWorkspaceAdmin.js +659 -0
  82. package/lib/features/notion/NotionWorkspaceAdmin.js.map +1 -0
  83. package/lib/features/notion/NotionWorkspaceView.js +257 -45
  84. package/lib/features/notion/NotionWorkspaceView.js.map +1 -1
  85. package/lib/features/notion/database/DatabaseCells.js +554 -0
  86. package/lib/features/notion/database/DatabaseCells.js.map +1 -0
  87. package/lib/features/notion/database/DatabaseDateLayouts.js +792 -0
  88. package/lib/features/notion/database/DatabaseDateLayouts.js.map +1 -0
  89. package/lib/features/notion/database/DatabaseLayouts.js +461 -0
  90. package/lib/features/notion/database/DatabaseLayouts.js.map +1 -0
  91. package/lib/features/notion/database/DatabaseSheets.js +791 -0
  92. package/lib/features/notion/database/DatabaseSheets.js.map +1 -0
  93. package/lib/features/notion/database/NotionDatabaseView.js +817 -0
  94. package/lib/features/notion/database/NotionDatabaseView.js.map +1 -0
  95. package/lib/features/notion/database/RowPropertiesPanel.js +162 -0
  96. package/lib/features/notion/database/RowPropertiesPanel.js.map +1 -0
  97. package/lib/features/notion/database/chartData.js +89 -0
  98. package/lib/features/notion/database/chartData.js.map +1 -0
  99. package/lib/features/notion/database/chartView.js +112 -0
  100. package/lib/features/notion/database/chartView.js.map +1 -0
  101. package/lib/features/notion/database/connectorButton.js +33 -0
  102. package/lib/features/notion/database/connectorButton.js.map +1 -0
  103. package/lib/features/notion/database/databaseCalc.js +208 -0
  104. package/lib/features/notion/database/databaseCalc.js.map +1 -0
  105. package/lib/features/notion/database/databaseCalendar.js +157 -0
  106. package/lib/features/notion/database/databaseCalendar.js.map +1 -0
  107. package/lib/features/notion/database/databaseCsv.js +98 -0
  108. package/lib/features/notion/database/databaseCsv.js.map +1 -0
  109. package/lib/features/notion/database/databaseCsvActions.js +58 -0
  110. package/lib/features/notion/database/databaseCsvActions.js.map +1 -0
  111. package/lib/features/notion/database/databaseFilter.js +473 -0
  112. package/lib/features/notion/database/databaseFilter.js.map +1 -0
  113. package/lib/features/notion/database/databaseFormula.js +1072 -0
  114. package/lib/features/notion/database/databaseFormula.js.map +1 -0
  115. package/lib/features/notion/database/databaseGroup.js +151 -0
  116. package/lib/features/notion/database/databaseGroup.js.map +1 -0
  117. package/lib/features/notion/database/databaseRollup.js +58 -0
  118. package/lib/features/notion/database/databaseRollup.js.map +1 -0
  119. package/lib/features/notion/database/databaseTimeline.js +156 -0
  120. package/lib/features/notion/database/databaseTimeline.js.map +1 -0
  121. package/lib/features/notion/database/databaseView.js +1188 -0
  122. package/lib/features/notion/database/databaseView.js.map +1 -0
  123. package/lib/features/notion/database/databaseViews.js +310 -0
  124. package/lib/features/notion/database/databaseViews.js.map +1 -0
  125. package/lib/features/notion/database/relationSource.js +92 -0
  126. package/lib/features/notion/database/relationSource.js.map +1 -0
  127. package/lib/features/notion/database/uniqueId.js +17 -0
  128. package/lib/features/notion/database/uniqueId.js.map +1 -0
  129. package/lib/features/notion/database/useNotionDatabase.js +617 -0
  130. package/lib/features/notion/database/useNotionDatabase.js.map +1 -0
  131. package/lib/features/notion/notionAgentRunStatus.js +39 -0
  132. package/lib/features/notion/notionAgentRunStatus.js.map +1 -0
  133. package/lib/features/notion/notionCodeLanguages.js +112 -0
  134. package/lib/features/notion/notionCodeLanguages.js.map +1 -0
  135. package/lib/features/notion/notionComments.js +86 -0
  136. package/lib/features/notion/notionComments.js.map +1 -0
  137. package/lib/features/notion/notionConnections.js +74 -0
  138. package/lib/features/notion/notionConnections.js.map +1 -0
  139. package/lib/features/notion/notionDocuments.js +453 -1
  140. package/lib/features/notion/notionDocuments.js.map +1 -1
  141. package/lib/features/notion/notionEditorModel.js +142 -7
  142. package/lib/features/notion/notionEditorModel.js.map +1 -1
  143. package/lib/features/notion/notionMarkdownShortcuts.js +51 -0
  144. package/lib/features/notion/notionMarkdownShortcuts.js.map +1 -0
  145. package/lib/features/notion/notionMedia.js +119 -0
  146. package/lib/features/notion/notionMedia.js.map +1 -0
  147. package/lib/features/notion/notionMentionDate.js +32 -0
  148. package/lib/features/notion/notionMentionDate.js.map +1 -0
  149. package/lib/features/notion/notionMentionOptions.js +162 -0
  150. package/lib/features/notion/notionMentionOptions.js.map +1 -0
  151. package/lib/features/notion/notionNotesAgent.js +445 -0
  152. package/lib/features/notion/notionNotesAgent.js.map +1 -0
  153. package/lib/features/notion/notionPageAccess.js +168 -0
  154. package/lib/features/notion/notionPageAccess.js.map +1 -0
  155. package/lib/features/notion/notionPageActions.js +138 -0
  156. package/lib/features/notion/notionPageActions.js.map +1 -0
  157. package/lib/features/notion/notionPageHistory.js +154 -0
  158. package/lib/features/notion/notionPageHistory.js.map +1 -0
  159. package/lib/features/notion/notionPageKinds.js +200 -0
  160. package/lib/features/notion/notionPageKinds.js.map +1 -0
  161. package/lib/features/notion/notionRecents.js +48 -0
  162. package/lib/features/notion/notionRecents.js.map +1 -0
  163. package/lib/features/notion/notionRichText.js +177 -0
  164. package/lib/features/notion/notionRichText.js.map +1 -0
  165. package/lib/features/notion/notionRichTitle.js +336 -0
  166. package/lib/features/notion/notionRichTitle.js.map +1 -0
  167. package/lib/features/notion/useNotionWorkspace.js +272 -13
  168. package/lib/features/notion/useNotionWorkspace.js.map +1 -1
  169. package/lib/features/notion/usePageActions.js +155 -0
  170. package/lib/features/notion/usePageActions.js.map +1 -0
  171. package/lib/features/resume/ResumeAgentChatPane.js +1 -1
  172. package/lib/features/resume/ResumeAgentChatPane.js.map +1 -1
  173. package/lib/features/shopping/ShoppingAgentChatPane.js +1 -1
  174. package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
  175. package/lib/features/study/StudyAgentChatPane.js +1 -1
  176. package/lib/features/study/StudyAgentChatPane.js.map +1 -1
  177. package/lib/features/travel/TravelAgentChatPane.js +1 -1
  178. package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
  179. package/lib/features/webbuilder/WebBuilderExperience.js +40 -8
  180. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  181. package/lib/features/webbuilder/buildFragments.js +1 -1
  182. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  183. package/lib/features/webbuilder/codeFiles.js +302 -0
  184. package/lib/features/webbuilder/codeFiles.js.map +1 -0
  185. package/lib/features/webbuilder/codeHighlight.js +209 -0
  186. package/lib/features/webbuilder/codeHighlight.js.map +1 -0
  187. package/lib/features/webbuilder/components/CodeView.js +682 -52
  188. package/lib/features/webbuilder/components/CodeView.js.map +1 -1
  189. package/lib/features/webbuilder/components/PreviewScreen.js +59 -38
  190. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  191. package/lib/features/webbuilder/components/ProjectChat.js +3 -3
  192. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  193. package/lib/features/webbuilder/stepLabels.js +68 -0
  194. package/lib/features/webbuilder/stepLabels.js.map +1 -0
  195. package/lib/hooks/useHostChatSteering.js +45 -0
  196. package/lib/hooks/useHostChatSteering.js.map +1 -0
  197. package/lib/screens/Chat/index.js +2 -12
  198. package/lib/screens/Chat/index.js.map +1 -1
  199. package/lib/screens/ExpensesNative/useExpensesHostChat.js +25 -5
  200. package/lib/screens/ExpensesNative/useExpensesHostChat.js.map +1 -1
  201. package/lib/screens/InboxNative/useInboxHostChat.js +25 -5
  202. package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -1
  203. package/lib/screens/JobSearchNative/useJobSearchHostChat.js +25 -5
  204. package/lib/screens/JobSearchNative/useJobSearchHostChat.js.map +1 -1
  205. package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js +25 -5
  206. package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js.map +1 -1
  207. package/lib/screens/MoviesNative/useMoviesHostChat.js +25 -5
  208. package/lib/screens/MoviesNative/useMoviesHostChat.js.map +1 -1
  209. package/lib/screens/NotionPage/index.js +2 -2
  210. package/lib/screens/NotionPage/index.js.map +1 -1
  211. package/lib/screens/ResumeNative/useResumeHostChat.js +25 -5
  212. package/lib/screens/ResumeNative/useResumeHostChat.js.map +1 -1
  213. package/lib/screens/ShoppingNative/useShoppingHostChat.js +25 -5
  214. package/lib/screens/ShoppingNative/useShoppingHostChat.js.map +1 -1
  215. package/lib/screens/StudyNative/useStudyHostChat.js +25 -5
  216. package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -1
  217. package/lib/screens/TravelNative/useTravelHostChat.js +25 -5
  218. package/lib/screens/TravelNative/useTravelHostChat.js.map +1 -1
  219. package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +222 -0
  220. package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -0
  221. package/lib/screens/WebBuilderNative/index.js +1 -1
  222. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  223. package/lib/screens/WebBuilderNative/sandboxProxyApi.js +126 -4
  224. package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
  225. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +120 -11
  226. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  227. package/package.json +3 -3
@@ -1,8 +1,62 @@
1
- import {useRef,useCallback,useMemo}from'react';import {useApolloClient,gql}from'@apollo/client/index.js';import {publicSandboxDomain}from'../../features/webbuilder/publicSandboxDomain.js';import {withPublicSandboxHosts}from'../../features/webbuilder/sandboxPublicHost.js';import {OUTDATED_SERVER_RE,proxyResult}from'./webbuilderTransport.js';const SANDBOX_ACTION_MUTATION = gql`
1
+ import {useRef,useCallback,useMemo}from'react';import {useApolloClient,gql}from'@apollo/client/index.js';import {publicSandboxDomain}from'../../features/webbuilder/publicSandboxDomain.js';import {withPublicSandboxHosts}from'../../features/webbuilder/sandboxPublicHost.js';import {OUTDATED_SERVER_RE,proxyResult}from'./webbuilderTransport.js';var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ const SANDBOX_ACTION_MUTATION = gql`
2
18
  mutation aiCodeSandboxAction($channelId: String!, $sandboxId: String!, $action: String!, $params: JSON) {
3
19
  aiCodeSandboxAction(channelId: $channelId, sandboxId: $sandboxId, action: $action, params: $params)
4
20
  }
5
21
  `;
22
+ const ADOPT_AGENT_PROJECT = gql`
23
+ mutation AdoptAgentProject($channelId: ID!, $title: String) {
24
+ aiCodeAdoptAgentProject(channelId: $channelId, title: $title) {
25
+ channelId
26
+ projectId
27
+ adopted
28
+ }
29
+ }
30
+ `;
31
+ const RECORD_AGENT_BUILD = gql`
32
+ mutation RecordAgentBuild($channelId: ID!, $input: AgentBuildInput!) {
33
+ aiCodeRecordAgentBuild(channelId: $channelId, input: $input) {
34
+ ok
35
+ error
36
+ }
37
+ }
38
+ `;
39
+ const RETENTION_QUERY = gql`
40
+ query webbuilderRetention($channelId: String!) {
41
+ webbuilderRetention(channelId: $channelId)
42
+ }
43
+ `;
44
+ function backupRepoFromRetention(raw) {
45
+ let value = raw;
46
+ if (typeof value === "string") {
47
+ try {
48
+ value = JSON.parse(value);
49
+ } catch (e) {
50
+ return null;
51
+ }
52
+ }
53
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
54
+ const top = value;
55
+ if (top.ok === false) return null;
56
+ const state = top.state && typeof top.state === "object" ? top.state : {};
57
+ const repo = typeof state.backupRepo === "string" ? state.backupRepo : top.backupRepo;
58
+ return typeof repo === "string" && repo.trim() ? repo.trim() : null;
59
+ }
6
60
  const PERSIST_SANDBOX_MUTATION = gql`
7
61
  mutation aiCodePersistSandboxIdentity(
8
62
  $channelId: String!
@@ -112,9 +166,77 @@ function useSandboxProxyApi() {
112
166
  };
113
167
  }
114
168
  }, [client]);
169
+ const backupRepo = useCallback(async (channelId) => {
170
+ var _a;
171
+ try {
172
+ const result = await client.query({
173
+ query: RETENTION_QUERY,
174
+ variables: {
175
+ channelId
176
+ },
177
+ fetchPolicy: "network-only",
178
+ errorPolicy: "all"
179
+ });
180
+ return backupRepoFromRetention((_a = result.data) == null ? void 0 : _a.webbuilderRetention);
181
+ } catch (e) {
182
+ return null;
183
+ }
184
+ }, [client]);
185
+ const adoptAgentProject = useCallback(async (channelId, title) => {
186
+ var _a, _b;
187
+ try {
188
+ const result = await client.mutate({
189
+ mutation: ADOPT_AGENT_PROJECT,
190
+ variables: {
191
+ channelId,
192
+ title: title.slice(0, 80) || void 0
193
+ },
194
+ fetchPolicy: "no-cache",
195
+ errorPolicy: "all"
196
+ });
197
+ return Boolean((_b = (_a = result.data) == null ? void 0 : _a.aiCodeAdoptAgentProject) == null ? void 0 : _b.adopted);
198
+ } catch (e) {
199
+ return false;
200
+ }
201
+ }, [client]);
202
+ const recordAgentBuild = useCallback(async (channelId, input) => {
203
+ var _a, _b, _c, _d;
204
+ try {
205
+ const result = await client.mutate({
206
+ mutation: RECORD_AGENT_BUILD,
207
+ variables: {
208
+ channelId,
209
+ input: __spreadValues(__spreadValues(__spreadValues({
210
+ sandboxId: input.sandboxId
211
+ }, input.previewUrl && /^https:\/\//i.test(input.previewUrl) ? {
212
+ previewUrl: input.previewUrl.split("?")[0]
213
+ } : {}), input.title ? {
214
+ title: input.title.slice(0, 80)
215
+ } : {}), input.snapshotId ? {
216
+ snapshotId: input.snapshotId
217
+ } : {})
218
+ },
219
+ fetchPolicy: "no-cache",
220
+ errorPolicy: "all"
221
+ });
222
+ const reply = (_a = result.data) == null ? void 0 : _a.aiCodeRecordAgentBuild;
223
+ return {
224
+ ok: Boolean(reply == null ? void 0 : reply.ok),
225
+ error: (_d = reply == null ? void 0 : reply.error) != null ? _d : (_c = (_b = result.errors) == null ? void 0 : _b[0]) == null ? void 0 : _c.message
226
+ };
227
+ } catch (err) {
228
+ return {
229
+ ok: false,
230
+ error: messageOf(err)
231
+ };
232
+ }
233
+ }, [client]);
115
234
  return useMemo(() => ({
116
235
  proxy,
117
236
  persist,
118
- proxyMissing
119
- }), [proxy, persist]);
120
- }export{useSandboxProxyApi};//# sourceMappingURL=sandboxProxyApi.js.map
237
+ proxyMissing,
238
+ backupRepo,
239
+ adoptAgentProject,
240
+ recordAgentBuild
241
+ }), [proxy, persist, backupRepo, adoptAgentProject, recordAgentBuild]);
242
+ }export{backupRepoFromRetention,useSandboxProxyApi};//# sourceMappingURL=sandboxProxyApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxProxyApi.js","sources":["../../../src/screens/WebBuilderNative/sandboxProxyApi.ts"],"sourcesContent":["/**\n * The two backend fields a preview restore goes through (web `sandbox/sandboxProxy.ts`,\n * `previewDeployApi.persistSandboxIdentity`), on the app's Apollo client - the\n * backend that owns the build channels:\n *\n * - `aiCodeSandboxAction`: one connector action on a project's sandbox. The server\n * adds the sandbox key from the channel's settings (an agent build's too), so\n * the app never holds a key; a CREATE through it records the new sandbox.\n * - `aiCodePersistSandboxIdentity`: the new sandbox (and its preview) after a\n * restore, so the web and other devices open it instead of the expired one.\n * The preview is saved on the platform's sandbox domain when one is set.\n *\n * Neither has a generated hook in `common/graphql`, so the documents live here.\n */\nimport { useCallback, useMemo, useRef } from 'react';\nimport { gql, useApolloClient } from '@apollo/client';\nimport { publicSandboxDomain } from '../../features/webbuilder/publicSandboxDomain';\nimport { withPublicSandboxHosts } from '../../features/webbuilder/sandboxPublicHost';\nimport { OUTDATED_SERVER_RE, proxyResult, type SandboxProxyCall } from './webbuilderTransport';\n\nconst SANDBOX_ACTION_MUTATION = gql`\n mutation aiCodeSandboxAction($channelId: String!, $sandboxId: String!, $action: String!, $params: JSON) {\n aiCodeSandboxAction(channelId: $channelId, sandboxId: $sandboxId, action: $action, params: $params)\n }\n`;\n\nconst PERSIST_SANDBOX_MUTATION = gql`\n mutation aiCodePersistSandboxIdentity(\n $channelId: String!\n $sandboxId: String!\n $sandboxUrl: String\n $snapshotId: String\n $previousSandboxId: String\n ) {\n aiCodePersistSandboxIdentity(\n channelId: $channelId\n sandboxId: $sandboxId\n sandboxUrl: $sandboxUrl\n snapshotId: $snapshotId\n previousSandboxId: $previousSandboxId\n ) {\n success\n message\n }\n }\n`;\n\nfunction messageOf(err: unknown): string {\n const e = err as { graphQLErrors?: Array<{ message?: string }>; message?: string } | null;\n return e?.graphQLErrors?.find((g) => g?.message)?.message || e?.message || String(err);\n}\n\nexport interface PersistSandboxInput {\n channelId: string;\n sandboxId: string;\n sandboxUrl?: string | null;\n snapshotId?: string | null;\n previousSandboxId?: string | null;\n}\n\nexport function useSandboxProxyApi() {\n const client = useApolloClient();\n /** Set once a server answers without the proxy: the session stays direct (web router `missing`). */\n const proxyMissing = useRef(false);\n\n const proxy = useCallback<SandboxProxyCall>(\n async (variables, timeoutMs) => {\n const controller = new AbortController();\n // The proxy waits for the connector: allow its timeout plus a margin (web: +30 s).\n const timer = setTimeout(() => controller.abort(), timeoutMs + 30_000);\n try {\n const result = await client.mutate({\n mutation: SANDBOX_ACTION_MUTATION,\n variables,\n fetchPolicy: 'no-cache',\n errorPolicy: 'all',\n context: { fetchOptions: { signal: controller.signal } },\n });\n const first = result.errors?.find((e) => e?.message)?.message;\n if (first) {\n if (OUTDATED_SERVER_RE.test(first)) return { outdated: true };\n return { outdated: false, result: { successful: false, error: first } };\n }\n return {\n outdated: false,\n result: proxyResult((result.data as { aiCodeSandboxAction?: unknown } | null)?.aiCodeSandboxAction),\n };\n } catch (err) {\n const message = messageOf(err);\n if (OUTDATED_SERVER_RE.test(message)) return { outdated: true };\n return { outdated: false, result: { successful: false, error: message } };\n } finally {\n clearTimeout(timer);\n }\n },\n [client],\n );\n\n const persist = useCallback(\n async (input: PersistSandboxInput): Promise<{ ok: boolean; message?: string }> => {\n try {\n const result = await client.mutate({\n mutation: PERSIST_SANDBOX_MUTATION,\n variables: {\n channelId: input.channelId,\n sandboxId: input.sandboxId,\n sandboxUrl: input.sandboxUrl\n ? withPublicSandboxHosts(input.sandboxUrl, publicSandboxDomain())\n : undefined,\n snapshotId: input.snapshotId || undefined,\n previousSandboxId: input.previousSandboxId || undefined,\n },\n fetchPolicy: 'no-cache',\n errorPolicy: 'all',\n });\n const first = result.errors?.find((e) => e?.message)?.message;\n if (first) return { ok: false, message: first };\n const payload = (\n result.data as { aiCodePersistSandboxIdentity?: { success?: boolean; message?: string } } | null\n )?.aiCodePersistSandboxIdentity;\n return { ok: payload?.success !== false, message: payload?.message };\n } catch (err) {\n return { ok: false, message: messageOf(err) };\n }\n },\n [client],\n );\n\n return useMemo(() => ({ proxy, persist, proxyMissing }), [proxy, persist]);\n}\n"],"names":[],"mappings":"sVAmBA,MAAM,uBAA0B,GAAA,GAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAKhC,MAAM,wBAA2B,GAAA,GAAA;AAAA;AAAA;AAAA;AAAA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F,EAAG,CAAC,MAAM,CAAC,CAAA;AACX,EAAA,OAAO,QAAQ,OAAO;AAAA,IACpB,KAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACE,CAAA,EAAA,CAAC,KAAO,EAAA,OAAO,CAAC,CAAA;AACtB"}
1
+ {"version":3,"file":"sandboxProxyApi.js","sources":["../../../src/screens/WebBuilderNative/sandboxProxyApi.ts"],"sourcesContent":["/**\n * The two backend fields a preview restore goes through (web `sandbox/sandboxProxy.ts`,\n * `previewDeployApi.persistSandboxIdentity`), on the app's Apollo client - the\n * backend that owns the build channels:\n *\n * - `aiCodeSandboxAction`: one connector action on a project's sandbox. The server\n * adds the sandbox key from the channel's settings (an agent build's too), so\n * the app never holds a key; a CREATE through it records the new sandbox.\n * - `aiCodePersistSandboxIdentity`: the new sandbox (and its preview) after a\n * restore, so the web and other devices open it instead of the expired one.\n * The preview is saved on the platform's sandbox domain when one is set.\n *\n * Neither has a generated hook in `common/graphql`, so the documents live here.\n */\nimport { useCallback, useMemo, useRef } from 'react';\nimport { gql, useApolloClient } from '@apollo/client';\nimport { publicSandboxDomain } from '../../features/webbuilder/publicSandboxDomain';\nimport { withPublicSandboxHosts } from '../../features/webbuilder/sandboxPublicHost';\nimport { OUTDATED_SERVER_RE, proxyResult, type SandboxProxyCall } from './webbuilderTransport';\n\nconst SANDBOX_ACTION_MUTATION = gql`\n mutation aiCodeSandboxAction($channelId: String!, $sandboxId: String!, $action: String!, $params: JSON) {\n aiCodeSandboxAction(channelId: $channelId, sandboxId: $sandboxId, action: $action, params: $params)\n }\n`;\n\n/**\n * An agent-chat site as a page-creator project (web `agentProjectApi`, #388): adopting it lets\n * its builds be recorded on the channel (sandbox, key, restore point), which is what the project\n * proxy checks - an unadopted channel answers \"Sandbox not found in this project.\".\n */\nconst ADOPT_AGENT_PROJECT = gql`\n mutation AdoptAgentProject($channelId: ID!, $title: String) {\n aiCodeAdoptAgentProject(channelId: $channelId, title: $title) {\n channelId\n projectId\n adopted\n }\n }\n`;\n\n/** Record a build on its project: one RESULT post per sandbox (the first one of an adopted project is accepted). */\nconst RECORD_AGENT_BUILD = gql`\n mutation RecordAgentBuild($channelId: ID!, $input: AgentBuildInput!) {\n aiCodeRecordAgentBuild(channelId: $channelId, input: $input) {\n ok\n error\n }\n }\n`;\n\n/** The project's retention record (web `project/retention.ts`): `backupRepo` is where FINISH saved its code. */\nconst RETENTION_QUERY = gql`\n query webbuilderRetention($channelId: String!) {\n webbuilderRetention(channelId: $channelId)\n }\n`;\n\n/** `backupRepo` from the retention answer (top level or under `state`); null when none or refused. */\nexport function backupRepoFromRetention(raw: unknown): string | null {\n let value = raw;\n if (typeof value === 'string') {\n try {\n value = JSON.parse(value);\n } catch {\n return null;\n }\n }\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null;\n const top = value as Record<string, unknown>;\n if (top.ok === false) return null;\n const state = top.state && typeof top.state === 'object' ? (top.state as Record<string, unknown>) : {};\n const repo = typeof state.backupRepo === 'string' ? state.backupRepo : top.backupRepo;\n return typeof repo === 'string' && repo.trim() ? repo.trim() : null;\n}\n\nconst PERSIST_SANDBOX_MUTATION = gql`\n mutation aiCodePersistSandboxIdentity(\n $channelId: String!\n $sandboxId: String!\n $sandboxUrl: String\n $snapshotId: String\n $previousSandboxId: String\n ) {\n aiCodePersistSandboxIdentity(\n channelId: $channelId\n sandboxId: $sandboxId\n sandboxUrl: $sandboxUrl\n snapshotId: $snapshotId\n previousSandboxId: $previousSandboxId\n ) {\n success\n message\n }\n }\n`;\n\nfunction messageOf(err: unknown): string {\n const e = err as { graphQLErrors?: Array<{ message?: string }>; message?: string } | null;\n return e?.graphQLErrors?.find((g) => g?.message)?.message || e?.message || String(err);\n}\n\nexport interface PersistSandboxInput {\n channelId: string;\n sandboxId: string;\n sandboxUrl?: string | null;\n snapshotId?: string | null;\n previousSandboxId?: string | null;\n}\n\nexport function useSandboxProxyApi() {\n const client = useApolloClient();\n /** Set once a server answers without the proxy: the session stays direct (web router `missing`). */\n const proxyMissing = useRef(false);\n\n const proxy = useCallback<SandboxProxyCall>(\n async (variables, timeoutMs) => {\n const controller = new AbortController();\n // The proxy waits for the connector: allow its timeout plus a margin (web: +30 s).\n const timer = setTimeout(() => controller.abort(), timeoutMs + 30_000);\n try {\n const result = await client.mutate({\n mutation: SANDBOX_ACTION_MUTATION,\n variables,\n fetchPolicy: 'no-cache',\n errorPolicy: 'all',\n context: { fetchOptions: { signal: controller.signal } },\n });\n const first = result.errors?.find((e) => e?.message)?.message;\n if (first) {\n if (OUTDATED_SERVER_RE.test(first)) return { outdated: true };\n return { outdated: false, result: { successful: false, error: first } };\n }\n return {\n outdated: false,\n result: proxyResult((result.data as { aiCodeSandboxAction?: unknown } | null)?.aiCodeSandboxAction),\n };\n } catch (err) {\n const message = messageOf(err);\n if (OUTDATED_SERVER_RE.test(message)) return { outdated: true };\n return { outdated: false, result: { successful: false, error: message } };\n } finally {\n clearTimeout(timer);\n }\n },\n [client],\n );\n\n const persist = useCallback(\n async (input: PersistSandboxInput): Promise<{ ok: boolean; message?: string }> => {\n try {\n const result = await client.mutate({\n mutation: PERSIST_SANDBOX_MUTATION,\n variables: {\n channelId: input.channelId,\n sandboxId: input.sandboxId,\n sandboxUrl: input.sandboxUrl\n ? withPublicSandboxHosts(input.sandboxUrl, publicSandboxDomain())\n : undefined,\n snapshotId: input.snapshotId || undefined,\n previousSandboxId: input.previousSandboxId || undefined,\n },\n fetchPolicy: 'no-cache',\n errorPolicy: 'all',\n });\n const first = result.errors?.find((e) => e?.message)?.message;\n if (first) return { ok: false, message: first };\n const payload = (\n result.data as { aiCodePersistSandboxIdentity?: { success?: boolean; message?: string } } | null\n )?.aiCodePersistSandboxIdentity;\n return { ok: payload?.success !== false, message: payload?.message };\n } catch (err) {\n return { ok: false, message: messageOf(err) };\n }\n },\n [client],\n );\n\n /** The repo the project's code was backed up to (null: none recorded, or a server without the field). */\n const backupRepo = useCallback(\n async (channelId: string): Promise<string | null> => {\n try {\n const result = await client.query({\n query: RETENTION_QUERY,\n variables: { channelId },\n fetchPolicy: 'network-only',\n errorPolicy: 'all',\n });\n return backupRepoFromRetention(\n (result.data as { webbuilderRetention?: unknown } | null)?.webbuilderRetention,\n );\n } catch {\n return null;\n }\n },\n [client],\n );\n\n const adoptAgentProject = useCallback(\n async (channelId: string, title: string): Promise<boolean> => {\n try {\n const result = await client.mutate({\n mutation: ADOPT_AGENT_PROJECT,\n variables: { channelId, title: title.slice(0, 80) || undefined },\n fetchPolicy: 'no-cache',\n errorPolicy: 'all',\n });\n return Boolean(\n (result.data as { aiCodeAdoptAgentProject?: { adopted?: boolean } } | null)?.aiCodeAdoptAgentProject\n ?.adopted,\n );\n } catch {\n return false;\n }\n },\n [client],\n );\n\n const recordAgentBuild = useCallback(\n async (\n channelId: string,\n input: { sandboxId: string; previewUrl?: string | null; title?: string | null; snapshotId?: string | null },\n ): Promise<{ ok: boolean; error?: string }> => {\n try {\n const result = await client.mutate({\n mutation: RECORD_AGENT_BUILD,\n variables: {\n channelId,\n input: {\n sandboxId: input.sandboxId,\n ...(input.previewUrl && /^https:\\/\\//i.test(input.previewUrl)\n ? { previewUrl: input.previewUrl.split('?')[0] }\n : {}),\n ...(input.title ? { title: input.title.slice(0, 80) } : {}),\n ...(input.snapshotId ? { snapshotId: input.snapshotId } : {}),\n },\n },\n fetchPolicy: 'no-cache',\n errorPolicy: 'all',\n });\n const reply = (result.data as { aiCodeRecordAgentBuild?: { ok?: boolean; error?: string } } | null)\n ?.aiCodeRecordAgentBuild;\n return { ok: Boolean(reply?.ok), error: reply?.error ?? result.errors?.[0]?.message };\n } catch (err) {\n return { ok: false, error: messageOf(err) };\n }\n },\n [client],\n );\n\n return useMemo(\n () => ({ proxy, persist, proxyMissing, backupRepo, adoptAgentProject, recordAgentBuild }),\n [proxy, persist, backupRepo, adoptAgentProject, recordAgentBuild],\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,uBAA0B,GAAA,GAAA;AAAA;AAAA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AA;AAAA,QACL,EAAI,EAAA,KAAA;AAAA,QACJ,KAAA,EAAO,UAAU,GAAG;AAAA,OACtB;AAAA;AACF,GACF,EAAG,CAAC,MAAM,CAAC,CAAA;AACX,EAAA,OAAO,QAAQ,OAAO;AAAA,IACpB,KAAA;AAAA,IACA,OAAA;AAAA,IACA,YAAA;AAAA,IACA,UAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,MACE,CAAC,KAAA,EAAO,SAAS,UAAY,EAAA,iBAAA,EAAmB,gBAAgB,CAAC,CAAA;AACvE"}
@@ -1,4 +1,4 @@
1
- import {useRef,useState,useMemo,useEffect,useCallback,useSyncExternalStore}from'react';import {useAiCodeDeployToCloudflareMutation}from'common/graphql';import {v4}from'uuid';import {useCdecliConnection}from'../../contexts/CdecliConnectionContext.js';import {useChatStream}from'../../hooks/useChatStream.js';import {useHostChatChannel}from'../../hooks/useHostChatChannel.js';import {config}from'../../config/env-config.js';import {useChatMessages,subscribeRememberedHistory,historyRunningChannelIds}from'../../hooks/useChatApi.js';import {usePrerequisiteIds}from'../../hooks/usePrerequisiteIds.js';import {useCanvasSession}from'../../features/canvas/useCanvasSession.js';import {tokenClaims}from'../../features/canvas/sessionIdentity.js';import {buildsFromPosts,hasWorkflowPosts,projectFromPosts,turnState,pendingWork,transcriptFromPosts,stripAgentNote,displayAgentText}from'../../features/webbuilder/buildFragments.js';import {WEBBUILDER_CHAT_SKILL,buildTriggerParams,templateRemixNote,newObjectId}from'../../features/webbuilder/workflow.js';import {useWebBuilderGallery}from'./useWebBuilderGallery.js';import {agentEditNote,agentPublishMessage}from'../../features/webbuilder/webbuilderPrompts.js';import {useCodeAssistantCatalog}from'./useCodeAssistantCatalog.js';import {uploadAttachment,triggerBuild,createSandboxRouter,directSandboxRun,restoreSandbox}from'./webbuilderTransport.js';import {useSandboxProxyApi}from'./sandboxProxyApi.js';import {useSandboxKeepAlive}from'./useSandboxKeepAlive.js';import {pendingAskUser}from'../../features/chat/askUser.js';import {runningBuild,useRunningBuilds,markBuildDone}from'./runningBuilds.js';import {isAgentSite}from'./siteLane.js';import {undoLastChange,redoChange}from'./versionUndo.js';import {WEBBUILDER_EXPORT_ZIP_ACTION,exportZipParams,exportZipUrl}from'../../features/webbuilder/exportCode.js';import {useRestoredSandboxes,applyRestored}from'./useRestoredSandboxes.js';import {useWebBuilderJobs}from'./useWebBuilderJobs.js';var __defProp = Object.defineProperty;
1
+ import {useRef,useState,useMemo,useEffect,useCallback,useSyncExternalStore}from'react';import {useAiCodeDeployToCloudflareMutation}from'common/graphql';import {v4}from'uuid';import AsyncStorage from'@react-native-async-storage/async-storage';import {useCdecliConnection}from'../../contexts/CdecliConnectionContext.js';import {useChatStream}from'../../hooks/useChatStream.js';import {useHostChatChannel}from'../../hooks/useHostChatChannel.js';import {config}from'../../config/env-config.js';import {useChatMessages,subscribeRememberedHistory,historyRunningChannelIds}from'../../hooks/useChatApi.js';import {usePrerequisiteIds}from'../../hooks/usePrerequisiteIds.js';import {useCanvasSession}from'../../features/canvas/useCanvasSession.js';import {tokenClaims}from'../../features/canvas/sessionIdentity.js';import {buildsFromPosts,hasWorkflowPosts,titleFromPrompt,stripAgentNote,projectFromPosts,turnState,pendingWork,transcriptFromPosts,displayAgentText}from'../../features/webbuilder/buildFragments.js';import {handEditsNote,savedCodeSource}from'../../features/webbuilder/codeFiles.js';import {createCodeWorkspace}from'./codeWorkspaceApi.js';import {WEBBUILDER_CHAT_SKILL,buildTriggerParams,templateRemixNote,newObjectId}from'../../features/webbuilder/workflow.js';import {useWebBuilderGallery}from'./useWebBuilderGallery.js';import {agentEditNote,agentPublishMessage}from'../../features/webbuilder/webbuilderPrompts.js';import {useCodeAssistantCatalog}from'./useCodeAssistantCatalog.js';import {uploadAttachment,triggerBuild,createSandboxRouter,directSandboxRun,restoreSandbox}from'./webbuilderTransport.js';import {useSandboxProxyApi}from'./sandboxProxyApi.js';import {useSandboxKeepAlive}from'./useSandboxKeepAlive.js';import {pendingAskUser}from'../../features/chat/askUser.js';import {runningBuild,useRunningBuilds,markBuildDone}from'./runningBuilds.js';import {isAgentSite}from'./siteLane.js';import {undoLastChange,redoChange}from'./versionUndo.js';import {WEBBUILDER_EXPORT_ZIP_ACTION,exportZipParams,exportZipUrl}from'../../features/webbuilder/exportCode.js';import {useRestoredSandboxes,applyRestored}from'./useRestoredSandboxes.js';import {useWebBuilderJobs}from'./useWebBuilderJobs.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -18,6 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  const POLL_MS = 2500;
21
+ const ADOPTED_KEY = "yantra.webbuilder.adopted.v1";
21
22
  const TURN_TIMEOUT_MS = 15 * 60 * 1e3;
22
23
  const NO_REPLY_TIMEOUT_MS = 3 * 60 * 1e3;
23
24
  function notSetUp(org) {
@@ -29,7 +30,7 @@ function failureText(error) {
29
30
  return "The build didn't start. Try again.";
30
31
  }
31
32
  function useWebBuilderHost(routeOrg) {
32
- var _a, _b, _c, _d, _e, _f, _g, _h;
33
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
33
34
  const {
34
35
  orgName,
35
36
  projectId: appProjectId
@@ -68,6 +69,7 @@ function useWebBuilderHost(routeOrg) {
68
69
  } = cdecli;
69
70
  const [agentChannelId, setAgentChannelId] = useState(() => v4());
70
71
  const pendingAskRef = useRef(null);
72
+ const handEditsRef = useRef([]);
71
73
  const agentChannels = useRef(/* @__PURE__ */ new Set());
72
74
  const unsavedAgentChannels = useRef(/* @__PURE__ */ new Set());
73
75
  const pendingAgentTurn = useRef(null);
@@ -114,6 +116,32 @@ function useWebBuilderHost(routeOrg) {
114
116
  });
115
117
  }
116
118
  const agentBusy = agentLane && (chat.isLoading || chat.isStreaming);
119
+ const sandboxApi = useSandboxProxyApi();
120
+ const adoptedRef = useRef(/* @__PURE__ */ new Set());
121
+ const adoptingRef = useRef(/* @__PURE__ */ new Map());
122
+ useEffect(() => {
123
+ AsyncStorage.getItem(ADOPTED_KEY).then((raw) => {
124
+ const ids = raw ? JSON.parse(raw) : [];
125
+ if (Array.isArray(ids)) ids.forEach((id) => typeof id === "string" && adoptedRef.current.add(id));
126
+ }).catch(() => void 0);
127
+ }, []);
128
+ const {
129
+ adoptAgentProject
130
+ } = sandboxApi;
131
+ const ensureAdopted = useCallback((channelId, title) => {
132
+ if (adoptedRef.current.has(channelId)) return Promise.resolve(true);
133
+ const pending = adoptingRef.current.get(channelId);
134
+ if (pending) return pending;
135
+ const run = adoptAgentProject(channelId, title).then((adopted) => {
136
+ if (adopted) {
137
+ adoptedRef.current.add(channelId);
138
+ AsyncStorage.setItem(ADOPTED_KEY, JSON.stringify([...adoptedRef.current].slice(-500))).catch(() => void 0);
139
+ }
140
+ return adopted;
141
+ }).finally(() => adoptingRef.current.delete(channelId));
142
+ adoptingRef.current.set(channelId, run);
143
+ return run;
144
+ }, [adoptAgentProject]);
117
145
  const jobs = useWebBuilderJobs(effectiveOrg);
118
146
  const agentJob = useRef(null);
119
147
  const sendAgentTurn = useCallback((channelId, text, files, task) => {
@@ -126,7 +154,8 @@ function useWebBuilderHost(routeOrg) {
126
154
  lane: "agent",
127
155
  startedAt: Date.now()
128
156
  }) : Promise.resolve(null);
129
- Promise.all([ready, recorded]).then(([, job]) => {
157
+ const adopted = ready.then(() => ensureAdopted(channelId, (task == null ? void 0 : task.siteTitle) || titleFromPrompt(stripAgentNote(text)) || "New site").catch(() => false));
158
+ Promise.all([adopted, recorded]).then(([, job]) => {
130
159
  unsavedAgentChannels.current.delete(channelId);
131
160
  if (job) agentJob.current = {
132
161
  channelId,
@@ -145,7 +174,7 @@ function useWebBuilderHost(routeOrg) {
145
174
  });
146
175
  agentJob.current = null;
147
176
  }).catch(() => void 0);
148
- }, [chat, ensureChannel, jobs]);
177
+ }, [chat, ensureChannel, jobs, ensureAdopted]);
149
178
  useEffect(() => {
150
179
  const pending = pendingAgentTurn.current;
151
180
  if (!pending || pending.channelId !== agentChannelId) return;
@@ -491,10 +520,15 @@ ${templateRemixNote(request.template)}` : request.text,
491
520
  return;
492
521
  }
493
522
  const workflowReady = Boolean((_a2 = catalog.defaults) == null ? void 0 : _a2.formExtensionId);
523
+ const edits = handEditsNote(handEditsRef.current);
524
+ handEditsRef.current = [];
525
+ const editsNote = edits ? `
526
+
527
+ ${edits}` : "";
494
528
  if (agentLane || !workflowReady) {
495
- const note = target ? `
529
+ const note = `${target ? `
496
530
 
497
- ${agentEditNote(target)}` : "";
531
+ ${agentEditNote(target)}` : ""}${editsNote}`;
498
532
  const task = {
499
533
  mode: target || builds.length ? "edit" : "new",
500
534
  siteTitle: (activeProject == null ? void 0 : activeProject.title) || (target == null ? void 0 : target.title) || ((_b2 = builds[0]) == null ? void 0 : _b2.title) || null
@@ -520,7 +554,7 @@ ${agentEditNote(target)}` : "";
520
554
  runTurn({
521
555
  channelId,
522
556
  projectId,
523
- text,
557
+ text: `${text}${editsNote}`,
524
558
  template: null,
525
559
  edit: target != null ? target : null,
526
560
  attachments
@@ -565,7 +599,34 @@ ${agentEditNote(target)}` : "";
565
599
  ask: pendingAsk,
566
600
  send
567
601
  }, [agentLane, agentMessages, pendingAsk, withOpenRun, openRunStreaming, openRunPending, chat.response, agentBusy, chat.error, cdecli.channelConnected, messages, running, progress, building == null ? void 0 : building.statusText, turnError, session.ready, session.error, token, send]);
568
- const sandboxApi = useSandboxProxyApi();
602
+ const recordedSandboxRef = useRef(/* @__PURE__ */ new Set());
603
+ const {
604
+ recordAgentBuild
605
+ } = sandboxApi;
606
+ const latestBuild = (_g = builds[0]) != null ? _g : null;
607
+ useEffect(() => {
608
+ const channelId = activeChannelId;
609
+ const sandboxId = latestBuild == null ? void 0 : latestBuild.sandboxId;
610
+ if (!channelId || !agentLane || !sandboxId || agentBusy) return;
611
+ const key = `${channelId}:${sandboxId}`;
612
+ if (recordedSandboxRef.current.has(key)) return;
613
+ recordedSandboxRef.current.add(key);
614
+ const title = (activeProject == null ? void 0 : activeProject.title) || latestBuild.title || "New site";
615
+ ensureAdopted(channelId, title).then((adopted) => adopted ? recordAgentBuild(channelId, {
616
+ sandboxId,
617
+ previewUrl: latestBuild.previewUrl,
618
+ title,
619
+ snapshotId: latestBuild.snapshotId
620
+ }) : null).then((outcome) => {
621
+ if (__DEV__ && outcome && !outcome.ok) {
622
+ console.warn("[WebBuilderNative] record build", {
623
+ channelId,
624
+ sandboxId,
625
+ error: outcome.error
626
+ });
627
+ }
628
+ }).catch(() => void 0);
629
+ }, [activeChannelId, agentLane, agentBusy, latestBuild, activeProject == null ? void 0 : activeProject.title, ensureAdopted, recordAgentBuild]);
569
630
  const sandboxCall = useMemo(() => createSandboxRouter({
570
631
  channelId: activeChannelId,
571
632
  proxy: sandboxApi.proxy,
@@ -577,8 +638,8 @@ ${agentEditNote(target)}` : "";
577
638
  }), [activeChannelId, token, indexUrl, sandboxApi]);
578
639
  const keepAlive = useSandboxKeepAlive({
579
640
  run: token || activeChannelId ? sandboxCall : null,
580
- sandboxId: (_g = builds[0]) == null ? void 0 : _g.sandboxId,
581
- live: activeChannelId !== null && Boolean((_h = builds[0]) == null ? void 0 : _h.sandboxId)
641
+ sandboxId: (_h = builds[0]) == null ? void 0 : _h.sandboxId,
642
+ live: activeChannelId !== null && Boolean((_i = builds[0]) == null ? void 0 : _i.sandboxId)
582
643
  });
583
644
  const {
584
645
  noteActivity
@@ -653,6 +714,53 @@ ${agentEditNote(target)}` : "";
653
714
  const result = await sandboxCall(WEBBUILDER_EXPORT_ZIP_ACTION, exportZipParams(build.sandboxId, build.title), 10 * 60 * 1e3).catch(() => null);
654
715
  return exportZipUrl(result);
655
716
  }, [sandboxCall, noteActivity]);
717
+ const codeApi = useMemo(() => createCodeWorkspace(sandboxCall, (edit) => {
718
+ handEditsRef.current = [...handEditsRef.current.filter((e) => e.file !== edit.file), edit];
719
+ }), [sandboxCall]);
720
+ const siteLiveUrl = (_j = activeProject == null ? void 0 : activeProject.liveUrl) != null ? _j : null;
721
+ const [backupRepo, setBackupRepo] = useState(null);
722
+ const readBackupRepo = sandboxApi.backupRepo;
723
+ const newestBuildAt = (_k = builds[0]) == null ? void 0 : _k.updatedAt;
724
+ useEffect(() => {
725
+ if (!activeChannelId) return void 0;
726
+ let live = true;
727
+ readBackupRepo(activeChannelId).then((repo) => {
728
+ if (live) setBackupRepo({
729
+ channelId: activeChannelId,
730
+ repo
731
+ });
732
+ }).catch(() => void 0);
733
+ return () => {
734
+ live = false;
735
+ };
736
+ }, [activeChannelId, readBackupRepo, newestBuildAt]);
737
+ const siteBackupRepo = (backupRepo == null ? void 0 : backupRepo.channelId) === activeChannelId ? backupRepo.repo : null;
738
+ const code = useMemo(() => {
739
+ const target = (build) => ({
740
+ sandboxId: build.sandboxId,
741
+ savedSource: savedCodeSource({
742
+ backupRepo: siteBackupRepo,
743
+ liveUrl: build.liveUrl || siteLiveUrl
744
+ })
745
+ });
746
+ return {
747
+ listFiles: async (build) => {
748
+ var _a2, _b2;
749
+ const r = await codeApi.listFiles(target(build));
750
+ return {
751
+ ok: r.ok,
752
+ files: (_a2 = r.tree) == null ? void 0 : _a2.files,
753
+ partial: (_b2 = r.tree) == null ? void 0 : _b2.partial,
754
+ saved: r.saved,
755
+ asleep: r.asleep,
756
+ error: r.error
757
+ };
758
+ },
759
+ readFile: (build, path, saved) => codeApi.readFile(target(build), path, saved),
760
+ saveFile: (build, path, base, draft, force) => codeApi.saveFile(target(build), path, base, draft, force),
761
+ search: (build, query, live, openDocs) => codeApi.search(target(build), query, live, openDocs)
762
+ };
763
+ }, [codeApi, siteLiveUrl, siteBackupRepo]);
656
764
  const [deployToCloudflare] = useAiCodeDeployToCloudflareMutation({});
657
765
  const publish = useCallback(async (build, projectName) => {
658
766
  var _a2;
@@ -723,6 +831,7 @@ ${agentEditNote(target)}` : "";
723
831
  resumePreview,
724
832
  undo,
725
833
  redo,
726
- downloadCode
834
+ downloadCode,
835
+ code
727
836
  };
728
837
  }export{useWebBuilderHost};//# sourceMappingURL=useWebBuilderHost.js.map