@widgetic/creator 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,122 @@
1
+ Widgetic Integration License
2
+ Version 1.0
3
+
4
+ Copyright (c) Widgetic. All rights reserved.
5
+
6
+ This license covers the software package that it came with, in source and
7
+ compiled form, together with its documentation (the "Software"). By
8
+ installing, copying or using the Software you accept this license. If you do
9
+ not accept it, do not install or use the Software.
10
+
11
+ In this license, "Widgetic" is the company that publishes the Software, "you"
12
+ is the person or organization that uses it, and "Your Application" is an
13
+ application, website, product or service that you build or operate, for
14
+ yourself or for a client. "Widgetic Services" are the services that Widgetic
15
+ operates: the Widgetic API, widgets, compositions, embeds, editors, file
16
+ browser, chat and AI creator, and the other services that can be reached from
17
+ widgetic.com or its API hosts.
18
+
19
+ 1. What you may do
20
+
21
+ Widgetic grants you a worldwide, non-exclusive, non-transferable and
22
+ non-sublicensable license to use the Software, unmodified, for one purpose: to
23
+ integrate the Widgetic Services into Your Application. Within that purpose you
24
+ may:
25
+
26
+ (a) install the Software and run it in Your Application, in development,
27
+ testing and production;
28
+
29
+ (b) use it to call the Widgetic API, to show Widgetic widgets and
30
+ compositions, and to open Widgetic's editors, file browser, chat and AI
31
+ creator inside Your Application;
32
+
33
+ (c) bundle, minify and tree-shake the Software with the build tools of Your
34
+ Application, deliver the result to the people who use Your Application as a
35
+ part of it, and let them run it there;
36
+
37
+ (d) keep the copies of the Software that (a), (b) and (c) need, including
38
+ copies in your version control, your build systems and your backups.
39
+
40
+ 2. What you may not do
41
+
42
+ You may not, and may not allow anyone else to:
43
+
44
+ (a) use the Software for any purpose other than the one in section 1;
45
+
46
+ (b) use the Software to build, run or improve a service that offers what the
47
+ Widgetic Services offer, or to connect Your Application to anything other than
48
+ the Widgetic Services (a proxy of yours that forwards calls to the Widgetic
49
+ Services is fine);
50
+
51
+ (c) copy, modify, translate, adapt or make derivative works of the Software,
52
+ except as section 1(c) allows;
53
+
54
+ (d) publish, sell, rent, lease, sublicense or distribute the Software on its
55
+ own, or inside a library, SDK, template or product that others could use for
56
+ anything other than integrating the Widgetic Services, including by
57
+ publishing it, or a copy of it, to a package registry or a public CDN;
58
+
59
+ (e) reverse engineer, decompile or disassemble the Software, or try to get at
60
+ its source code, except as far as the law lets you despite this restriction;
61
+
62
+ (f) remove or change a copyright, license or attribution notice in the
63
+ Software;
64
+
65
+ (g) bypass, disable or interfere with the authentication, rate limits, quotas,
66
+ credits, plan limits or other protections of the Widgetic Services, or help
67
+ anyone else to;
68
+
69
+ (h) use the name, logo or trademarks of Widgetic, except to say truthfully
70
+ that Your Application integrates Widgetic.
71
+
72
+ 3. The Widgetic Services are separate
73
+
74
+ This license is for the Software only. It does not give you the right to use
75
+ the Widgetic Services. That right comes from your account or agreement with
76
+ Widgetic and from Widgetic's Terms of Service (https://widgetic.com/terms),
77
+ which this license does not change.
78
+
79
+ 4. Ownership
80
+
81
+ The Software is licensed to you, not sold. Widgetic and its licensors keep all
82
+ rights in it. Any right that this license does not give you in plain words is
83
+ reserved to Widgetic.
84
+
85
+ 5. Third-party software
86
+
87
+ The Software may include or depend on software from others. That software is
88
+ under its own license, which applies to it instead of this one, and nothing in
89
+ this license limits your rights under it.
90
+
91
+ 6. How long it lasts
92
+
93
+ This license lasts while you follow it and while you are entitled to use the
94
+ Widgetic Services. It ends on its own if you break it or that entitlement
95
+ ends. When it ends, you stop using the Software and delete your copies of it,
96
+ except copies that the law requires you to keep. Sections 4, 8 and 9 still
97
+ apply after it has ended.
98
+
99
+ 7. Versions
100
+
101
+ This license applies to the version of the Software that it came with and to
102
+ later versions that carry it. A version that Widgetic published under another
103
+ license stays under that license, for the copies of it that you already have.
104
+
105
+ 8. No warranty
106
+
107
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
108
+ IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
109
+ PURPOSE AND NON-INFRINGEMENT.
110
+
111
+ 9. Limit of liability
112
+
113
+ TO THE EXTENT THE LAW ALLOWS, WIDGETIC IS NOT LIABLE FOR ANY INDIRECT,
114
+ INCIDENTAL, SPECIAL, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR FOR LOST PROFITS,
115
+ REVENUE, DATA OR GOODWILL, THAT ARISE FROM THE SOFTWARE OR FROM THIS LICENSE,
116
+ EVEN IF IT HAS BEEN TOLD THAT THEY ARE POSSIBLE. NOTHING IN THIS LICENSE
117
+ LIMITS A LIABILITY THAT THE LAW DOES NOT ALLOW TO BE LIMITED.
118
+
119
+ 10. Questions
120
+
121
+ If you need to do something that this license does not allow, ask first:
122
+ support@widgetic.com.
package/README.md CHANGED
@@ -246,3 +246,7 @@ alias goes away by itself once dev-tools has it.
246
246
  ## Publishing
247
247
 
248
248
  GitLab CI on `main` publishes `@widgetic/creator`. Bump `version` in `package.json` and push `main`. The job is an npm Trusted Publisher (`NPM_ID_TOKEN`) and skips a version that is already on npm. A laptop publish is the fallback when CI minutes are gone. The token stays in `~/.npmrc` and is never committed.
249
+
250
+ ## License
251
+
252
+ This package is licensed under the Widgetic Integration License (see the `LICENSE` file in the package): you may use it to integrate Widgetic into your own application, and for nothing else. It is not open source. For any other use, write to support@widgetic.com.
@@ -34,6 +34,8 @@
34
34
  AgentModelsGet200ResponseModelsInner
35
35
  } from '@widgetic/api-sdk';
36
36
  import { parseVersionPreviewError } from './utils/versionPreviewError.js';
37
+ import { widgetBuilderRequestInit } from './utils/widgetBuilderRequest.js';
38
+ import { gzipRequestBodyMiddleware } from './utils/gzipRequestMiddleware.js';
37
39
  import BrandKitPanel from './components/BrandKitPanel.svelte';
38
40
 
39
41
  /**
@@ -160,7 +162,11 @@
160
162
  shouldUseTusForChatUpload,
161
163
  uploadChatFileToWidgeticApi
162
164
  } from './utils/widgeticChatUpload.js';
163
- import { tryPartnerMediaUpload, uploadFromMediaLibrary } from './utils/partnerMediaUpload.js';
165
+ import {
166
+ PARTNER_UPLOAD_FAILED_MESSAGE,
167
+ tryPartnerMediaUpload,
168
+ uploadFromMediaLibrary
169
+ } from './utils/partnerMediaUpload.js';
164
170
  import { persistWidgetThumbnail } from './utils/persistWidgetThumbnail.js';
165
171
  import { nativeScrollbarPadding } from './utils/nativeScrollbarPadding.js';
166
172
  import { pinScrollToBottom } from './utils/pinScrollToBottom.js';
@@ -338,8 +344,8 @@
338
344
  * last, so it reads the answer to the request that was sent again with a fresh token, not the refusal before it.
339
345
  */
340
346
  const clientMiddleware: Middleware[] = partnerMode
341
- ? [idempotencyKeyMiddleware, hostTokenRefreshMiddleware, limitReachedMiddleware]
342
- : [idempotencyKeyMiddleware];
347
+ ? [idempotencyKeyMiddleware, gzipRequestBodyMiddleware, hostTokenRefreshMiddleware, limitReachedMiddleware]
348
+ : [idempotencyKeyMiddleware, gzipRequestBodyMiddleware];
343
349
 
344
350
  // Opt-in Dexie owner — reactive to prop changes without $effect (would force runes mode).
345
351
  $: setEnableLocalCache(!!enableLocalCache);
@@ -750,17 +756,7 @@
750
756
  if (partnerMode) return hasValidToken;
751
757
  const synced = syncSessionFromSiteAuth();
752
758
  if (!synced) return false;
753
- try {
754
- const sessionStr = creatorStorage.getItem('session');
755
- const session = sessionStr ? JSON.parse(sessionStr) : null;
756
- currentUserToken =
757
- session?.accessToken ||
758
- session?.access_token ||
759
- creatorStorage.getItem('jwt') ||
760
- currentUserToken;
761
- } catch {
762
- currentUserToken = creatorStorage.getItem('jwt') || currentUserToken;
763
- }
759
+ currentUserToken = get(userSession)?.jwt || currentUserToken;
764
760
  if (currentUserToken) {
765
761
  authenticatedClientsToken = null;
766
762
  initializeAuthenticatedClients(currentUserToken);
@@ -1515,6 +1511,18 @@
1515
1511
  return null;
1516
1512
  }
1517
1513
 
1514
+ /**
1515
+ * What a visitor reads when the partner's upload of a chat attachment failed: the message of the partner's own error
1516
+ * (the partner words it, in the language of its page), or the creator's sentence, in the page's language, when the
1517
+ * error has no message or is one of ours (an answer that is not a file).
1518
+ */
1519
+ function partnerUploadFailureText(error: unknown): string {
1520
+ const partnerMessage = error instanceof Error ? error.message : '';
1521
+ return partnerMessage && partnerMessage !== PARTNER_UPLOAD_FAILED_MESSAGE
1522
+ ? partnerMessage
1523
+ : $t('creator.general.uploadFailed');
1524
+ }
1525
+
1518
1526
  async function handleChatUploadFile(
1519
1527
  file: File,
1520
1528
  options?: {
@@ -1557,7 +1565,7 @@
1557
1565
  onProgress: options?.onProgress,
1558
1566
  signal: uploadAbortSignal,
1559
1567
  },
1560
- { storeFileUrl, warnings: partnerUploadWarnings },
1568
+ { originalFile: file, storeFileUrl, warnings: partnerUploadWarnings },
1561
1569
  );
1562
1570
  } catch (error) {
1563
1571
  if (
@@ -1566,6 +1574,11 @@
1566
1574
  ) {
1567
1575
  throw new Error('Upload cancelled.');
1568
1576
  }
1577
+ // The chat treats a failed upload as soft (it keeps the local file and says nothing), so the visitor is told
1578
+ // here, with the words of the partner's own error. Saving the message tries once more: no second toast then.
1579
+ if (options?.source !== 'chat-message-persist') {
1580
+ showToast('error', partnerUploadFailureText(error), { duration: 4000 });
1581
+ }
1569
1582
  throw error;
1570
1583
  }
1571
1584
  if (partnerFile) {
@@ -2027,6 +2040,10 @@
2027
2040
  const widgetId = sourceWidgetId ?? selectedWidgetId;
2028
2041
  if (suppressChatDraftSync || !widgetId) return;
2029
2042
  syncPromptDraftFromChat(widgetId);
2043
+ const draftText = (getChatMethodsForWidget(widgetId)?.getDraftText?.() ?? '').trim();
2044
+ if (draftText.length >= 2) {
2045
+ void prewarmWidgetCodegenOnTyping(widgetId);
2046
+ }
2030
2047
  }
2031
2048
 
2032
2049
  /** Push confirm-dialog / local prompt into chat input (not as a sent message). */
@@ -2195,6 +2212,20 @@
2195
2212
  }
2196
2213
  }
2197
2214
 
2215
+ /**
2216
+ * Tracks the most recent user message persisted via `handleSaveMessage` so
2217
+ * `ensureCodegenUserMessagePersisted` can skip redundant `GET /v1/conversations`
2218
+ * + `GET /v1/conversations/{id}/messages` round-trips when `Chat.svelte` just
2219
+ * saved the user turn immediately before invoking `onSendMessage`.
2220
+ */
2221
+ let lastPersistedUserTurn: {
2222
+ conversationId: string;
2223
+ content: string;
2224
+ attachmentCount: number;
2225
+ hasRemoteImage: boolean;
2226
+ timestamp: number;
2227
+ } | null = null;
2228
+
2198
2229
  async function ensureCodegenUserMessagePersisted(
2199
2230
  widgetId: string,
2200
2231
  prompt: string,
@@ -2216,6 +2247,26 @@
2216
2247
  panelChat?.getConversationId?.() ??
2217
2248
  getPanelState(widgetId).currentChatConversationId ??
2218
2249
  null;
2250
+ const persistImages = uniquePersistImageUrls([
2251
+ ...(imageUrls || []),
2252
+ ...(getPanelState(widgetId).promptImages ?? []),
2253
+ ]);
2254
+ const promptTrimmed = (prompt || '').trim();
2255
+ if (
2256
+ visibleConversationId &&
2257
+ !isLocalOnlyConversationId(visibleConversationId) &&
2258
+ lastPersistedUserTurn &&
2259
+ lastPersistedUserTurn.conversationId === visibleConversationId &&
2260
+ Date.now() - lastPersistedUserTurn.timestamp < 30_000 &&
2261
+ (lastPersistedUserTurn.content === promptTrimmed ||
2262
+ lastPersistedUserTurn.content.endsWith(promptTrimmed)) &&
2263
+ (forkUserMessage ||
2264
+ lastPersistedUserTurn.hasRemoteImage ||
2265
+ (persistImages.length === 0 && (!fileAttachments || fileAttachments.length === 0)) ||
2266
+ lastPersistedUserTurn.attachmentCount >= persistImages.length + (fileAttachments?.length || 0))
2267
+ ) {
2268
+ return;
2269
+ }
2219
2270
  const convos = await handleLoadConversations(widgetId);
2220
2271
  let convId =
2221
2272
  (visibleConversationId && convos?.some((c) => c.id === visibleConversationId))
@@ -2231,10 +2282,6 @@
2231
2282
  // The new bubble was already saved by addUserMessage. Do not patch the previous turn with the sketch.
2232
2283
  if (forkUserMessage) return;
2233
2284
 
2234
- const persistImages = uniquePersistImageUrls([
2235
- ...(imageUrls || []),
2236
- ...(getPanelState(widgetId).promptImages ?? []),
2237
- ]);
2238
2285
  const compressedPersistImages: string[] = [];
2239
2286
  for (const url of persistImages) {
2240
2287
  if (typeof url === 'string' && url.startsWith('data:image/')) {
@@ -3076,9 +3123,22 @@
3076
3123
  const json = await response.raw.json();
3077
3124
  const saved = json?.data || json;
3078
3125
  const savedAtt = saved?.attachments;
3126
+ const resolvedAttachments =
3127
+ Array.isArray(savedAtt) && savedAtt.length > 0 ? savedAtt : (payload.attachments || []);
3128
+ if (messageType === 'user') {
3129
+ lastPersistedUserTurn = {
3130
+ conversationId,
3131
+ content: (content || '').trim(),
3132
+ attachmentCount: resolvedAttachments.length,
3133
+ hasRemoteImage: resolvedAttachments.some(
3134
+ (att: { url?: unknown }) => typeof att?.url === 'string' && /^https?:\/\//i.test(att.url)
3135
+ ),
3136
+ timestamp: Date.now(),
3137
+ };
3138
+ }
3079
3139
  return {
3080
3140
  ...saved,
3081
- attachments: (Array.isArray(savedAtt) && savedAtt.length > 0) ? savedAtt : (payload.attachments || []),
3141
+ attachments: resolvedAttachments,
3082
3142
  };
3083
3143
  };
3084
3144
  try {
@@ -3122,7 +3182,7 @@
3122
3182
  conversation_id: conversationId,
3123
3183
  checkpoint_message_id: checkpointMessageId
3124
3184
  }
3125
- });
3185
+ }, widgetBuilderRequestInit(widgetBuilderPreviewBaseUrl()));
3126
3186
  const json = await response.raw.json();
3127
3187
  const data = json?.data || json;
3128
3188
  // console.log('[Chat→Backend] Checkpoint restored:', data);
@@ -8878,7 +8938,7 @@
8878
8938
  purpose: 'canvas',
8879
8939
  signal: mountUploadAbortController?.signal ?? undefined,
8880
8940
  },
8881
- { storeFileUrl, warnings: partnerUploadWarnings },
8941
+ { originalFile: file, storeFileUrl, warnings: partnerUploadWarnings },
8882
8942
  );
8883
8943
  if (partnerImage?.url && /^https?:\/\//i.test(partnerImage.url)) {
8884
8944
  return partnerImage.url;
@@ -10027,8 +10087,12 @@ Requirements:
10027
10087
  promptImagesOverride?: string[];
10028
10088
  /** Skip the server's intent gate — the clarification card's explicit "generate anyway" choice. */
10029
10089
  skipIntentGate?: boolean;
10090
+ /** Sent to the model. The chat row keeps `prompt`. */
10091
+ promptForModel?: string;
10030
10092
  /** The tapped chip's structured intent, declared so the server measures the chip conversion without matching copy. */
10031
10093
  chipIntent?: ClarificationSuggestion['intent'];
10094
+ /** Successful retry: a new user row already exists. Do not attach images to the previous turn. */
10095
+ forkUserMessage?: boolean;
10032
10096
  persistFileAttachments?: Array<{
10033
10097
  url?: string;
10034
10098
  file?: File;
@@ -10302,7 +10366,7 @@ Requirements:
10302
10366
  language: languageForGeneration(generationWidgetId),
10303
10367
  brandKit: brandKitForRequest(),
10304
10368
  } as GenerateCodeRequest
10305
- });
10369
+ }, widgetBuilderRequestInit(widgetBuilderPreviewBaseUrl()));
10306
10370
  let response: { data?: Record<string, unknown>; error?: string; message?: string } | null = null;
10307
10371
  try {
10308
10372
  response = await accepted.raw.json();
@@ -10940,6 +11004,11 @@ Requirements:
10940
11004
  return;
10941
11005
  }
10942
11006
 
11007
+ if (httpStatus === 404) {
11008
+ const staleRepoId = resolveRepositoryIdForWidget(generationWidgetId);
11009
+ if (staleRepoId) verifiedRepositoryIds.delete(staleRepoId);
11010
+ }
11011
+
10943
11012
  // Handle validation error (400) — log full response for debugging
10944
11013
  if (httpStatus === 400) {
10945
11014
  let body400 = '(no body)';
@@ -11248,7 +11317,7 @@ Requirements:
11248
11317
  // version's commit and stamps it Live instead of minting a new one.
11249
11318
  version: targetVersion ?? undefined
11250
11319
  } as unknown as Parameters<typeof agentClient.agentWidgetBuilderPublishWidgetIdPost>[0]['agentWidgetBuilderPublishWidgetIdPostRequest']
11251
- });
11320
+ }, widgetBuilderRequestInit(widgetBuilderPreviewBaseUrl()));
11252
11321
  // console.log('[Publish] Widget Builder publish completed:', publishData);
11253
11322
 
11254
11323
  publishWidgetStatus = null;
@@ -12969,7 +13038,7 @@ Requirements:
12969
13038
  syncWidgetShapeLivePreviews();
12970
13039
  panelDisplayRevision += 1;
12971
13040
  try {
12972
- const response = await agentClient.previewWidgetVersion({ widgetId, version });
13041
+ const response = await agentClient.previewWidgetVersion({ widgetId, version }, widgetBuilderRequestInit(widgetBuilderPreviewBaseUrl()));
12973
13042
  const previewUrl = response?.data?.previewUrl ?? null;
12974
13043
  const commitSha = response?.data?.commitSha ?? null;
12975
13044
  // Drop stale responses: the selector may have moved on (or away) meanwhile.
@@ -16726,6 +16795,59 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16726
16795
  }
16727
16796
  }
16728
16797
 
16798
+ /**
16799
+ * Session-level cache of repository IDs verified for the current user session,
16800
+ * plus typing-triggered pre-warm state so pressing Send in Canvas Chat does not
16801
+ * block on a synchronous `GET /v1/agent/repositories/{repoId}` waterfall.
16802
+ */
16803
+ const verifiedRepositoryIds = new Set<string>();
16804
+ const typingPrewarmTimestamps = new Map<string, number>();
16805
+ const typingPrewarmInFlight = new Set<string>();
16806
+ const TYPING_PREWARM_COOLDOWN_MS = 45_000;
16807
+
16808
+ async function prewarmWidgetCodegenOnTyping(widgetId: string): Promise<void> {
16809
+ if (!widgetId || isDraftConvertId(widgetId) || !agentClient) return;
16810
+ if (generatingWidgetIds[widgetId] || typingPrewarmInFlight.has(widgetId)) return;
16811
+ const widget = getWidgetById(widgetId);
16812
+ if (!widget) return;
16813
+
16814
+ const existingRepoId = normalizeRepositoryId(widget);
16815
+ const now = Date.now();
16816
+ const lastWarm = typingPrewarmTimestamps.get(widgetId) ?? 0;
16817
+ if (existingRepoId && verifiedRepositoryIds.has(existingRepoId) && now - lastWarm < TYPING_PREWARM_COOLDOWN_MS) {
16818
+ return;
16819
+ }
16820
+
16821
+ typingPrewarmInFlight.add(widgetId);
16822
+ typingPrewarmTimestamps.set(widgetId, now);
16823
+ try {
16824
+ if (existingRepoId && verifiedRepositoryIds.has(existingRepoId)) {
16825
+ // Repo was verified earlier in the session; ping GET /repositories/{repoId}
16826
+ // in the background so the backend's GitService file/diff caches are hot.
16827
+ void agentClient.agentRepositoriesRepoIdGet({ repoId: existingRepoId }).catch(() => {});
16828
+ } else {
16829
+ await ensureWidgetRepository(widget, { silent: true });
16830
+ }
16831
+
16832
+ const panelChat = getChatMethodsForWidget(widgetId);
16833
+ const visibleConvId =
16834
+ panelChat?.getConversationId?.() ??
16835
+ getPanelState(widgetId).currentChatConversationId ??
16836
+ null;
16837
+ if (
16838
+ (!visibleConvId || isLocalOnlyConversationId(visibleConvId)) &&
16839
+ (conversationsByWidgetId[widgetId]?.length ?? 0) === 0 &&
16840
+ conversationsClient
16841
+ ) {
16842
+ void handleLoadConversations(widgetId).catch(() => {});
16843
+ }
16844
+ } catch {
16845
+ // Best-effort background pre-warm; Send path handles errors explicitly.
16846
+ } finally {
16847
+ typingPrewarmInFlight.delete(widgetId);
16848
+ }
16849
+ }
16850
+
16729
16851
  async function ensureWidgetRepository(
16730
16852
  widget: WidgetSummary | null | undefined,
16731
16853
  options: { forceRecreate?: boolean; silent?: boolean } = {}
@@ -16733,10 +16855,21 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16733
16855
  const { forceRecreate = false, silent = false } = options;
16734
16856
  const existingRepoId = normalizeRepositoryId(widget);
16735
16857
 
16858
+ if (existingRepoId && forceRecreate) {
16859
+ verifiedRepositoryIds.delete(existingRepoId);
16860
+ }
16861
+
16736
16862
  if (existingRepoId && !forceRecreate) {
16863
+ if (verifiedRepositoryIds.has(existingRepoId)) {
16864
+ if (widget?.id) stampWidgetRepositoryId(widget.id, existingRepoId);
16865
+ else currentRepositoryId = existingRepoId;
16866
+ return existingRepoId;
16867
+ }
16868
+
16737
16869
  const repoExists = await verifyRepository(existingRepoId, silent);
16738
16870
 
16739
16871
  if (repoExists) {
16872
+ verifiedRepositoryIds.add(existingRepoId);
16740
16873
  if (widget.id) stampWidgetRepositoryId(widget.id, existingRepoId);
16741
16874
  else currentRepositoryId = existingRepoId;
16742
16875
  return existingRepoId;
@@ -16753,6 +16886,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16753
16886
  const repoDetails = await agentClient.agentRepositoriesRepoIdGet({ repoId });
16754
16887
 
16755
16888
  if (!repoDetails?.id) {
16889
+ verifiedRepositoryIds.delete(repoId);
16756
16890
  return false;
16757
16891
  }
16758
16892
 
@@ -16762,6 +16896,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16762
16896
  const repoOwnerMatches = partnerMode || repoDetails.userId === $userSession.user?.id;
16763
16897
  // if the repository does not belong to the current user, show a warning and return false
16764
16898
  if (!repoOwnerMatches) {
16899
+ verifiedRepositoryIds.delete(repoId);
16765
16900
  console.warn('Repository belongs to a different user. Re-creating.', {
16766
16901
  repoId,
16767
16902
  repoOwner: repoDetails.userId,
@@ -16777,6 +16912,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16777
16912
  return false;
16778
16913
  }
16779
16914
 
16915
+ verifiedRepositoryIds.add(repoId);
16780
16916
  if (!silent) {
16781
16917
  showToast('info', $t('creator.codegen.repositoryFound'), {
16782
16918
  description: $t('creator.codegen.linkedToRepository', { id: repoDetails.id.slice(0, 8) })
@@ -16784,6 +16920,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16784
16920
  }
16785
16921
  return true;
16786
16922
  } catch (error) {
16923
+ verifiedRepositoryIds.delete(repoId);
16787
16924
  if (error instanceof ResponseError) {
16788
16925
  const status = error.response?.status;
16789
16926
  if (status === 401) {
@@ -16793,7 +16930,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16793
16930
  applySiteSessionToCreator();
16794
16931
  try {
16795
16932
  const retryDetails = await agentClient.agentRepositoriesRepoIdGet({ repoId });
16796
- if (retryDetails?.id) return true;
16933
+ if (retryDetails?.id) {
16934
+ verifiedRepositoryIds.add(repoId);
16935
+ return true;
16936
+ }
16797
16937
  } catch (retryError) {
16798
16938
  if (retryError instanceof ResponseError && retryError.response?.status === 401) {
16799
16939
  if (partnerMode) {
@@ -16868,6 +17008,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
16868
17008
  return null;
16869
17009
  }
16870
17010
 
17011
+ verifiedRepositoryIds.add(repoId);
16871
17012
  if (widget.id) stampWidgetRepositoryId(widget.id, repoId);
16872
17013
  else currentRepositoryId = repoId;
16873
17014
 
@@ -18307,7 +18448,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18307
18448
  locale={locale}
18308
18449
  messages={chatMessages}
18309
18450
  storedLineLabel={(line) => conversationLineLabel(line, $t)}
18310
- actionBarExtras={generationOptionChecks}
18451
+ actionBarExtras={generationOptionChecks as any}
18311
18452
  style="height: 100%; min-height: {chatUserHeight == null ? CHAT_AUTO_MIN_HEIGHT : CHAT_MIN_HEIGHT}px;"
18312
18453
  resizeExpandsContainer={true}
18313
18454
  renderDesignControls={renderDesignControls as any}
@@ -18469,6 +18610,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18469
18610
  class="fix-compile-in-create-btn w-fit"
18470
18611
  onclick={() => fixWidgetCompileError(panelWidgetId, getPanelPreviewCompileError(panelWidgetId))}
18471
18612
  >
18613
+ <span aria-hidden="true">🔧</span>
18472
18614
  {$t('creator.general.fixInCreate')}
18473
18615
  </Button>
18474
18616
  </div>
@@ -18483,7 +18625,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18483
18625
  type="button"
18484
18626
  class="ms-2 underline font-medium cursor-pointer"
18485
18627
  onclick={() => fixWidgetCompileError(panelWidgetId, getPanelPreviewCompileError(panelWidgetId))}
18486
- >{$t('creator.general.fixInCreate2')}</button>
18628
+ >{$t('creator.general.fixInCreate')}</button>
18487
18629
  </div>
18488
18630
  {/if}
18489
18631
 
@@ -18534,7 +18676,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18534
18676
  </svg>
18535
18677
  {/if}
18536
18678
  {#if compositionSaving}
18537
- {$t('creator.general.saving2')}
18679
+ {$t('creator.general.saving')}
18538
18680
  {:else if ps.selectedComposition}
18539
18681
  {ps.compositionDirty ? $t('creator.general.save') : $t('creator.general.saved')}
18540
18682
  {:else}
@@ -18699,7 +18841,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18699
18841
  class="embed-save-dims-btn ms-auto px-2.5 py-1 text-[10px] font-medium rounded border border-blue-500 text-blue-600 hover:bg-blue-50 transition-colors cursor-pointer"
18700
18842
  onclick={saveEmbedDimensions}
18701
18843
  >
18702
- {isSavingEmbedDims ? $t('creator.general.saving2') : $t('creator.general.save')}
18844
+ {isSavingEmbedDims ? $t('creator.general.saving') : $t('creator.general.save')}
18703
18845
  </button>
18704
18846
  {/if}
18705
18847
  </div>
@@ -18719,7 +18861,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
18719
18861
  })}
18720
18862
  {@const effectiveEmbedCode = embedCodeResult.code}
18721
18863
  {@const effectiveFormat = embedCodeResult.effectiveFormat}
18722
- {@const testPageHref = `/test-widget?widgetId=${encodeURIComponent(panelWidgetId)}&version=${encodeURIComponent(String(ps.lastPublishedVersion))}&w=${embedWidth}&h=${embedHeight}&url=${encodeURIComponent(embedSrc)}${selectedComposition?.id ? `&compositionId=${encodeURIComponent(selectedComposition.id)}` : ''}`}
18864
+ {@const testPageHref = `/test-embed?widgetId=${encodeURIComponent(panelWidgetId)}&version=${encodeURIComponent(String(ps.lastPublishedVersion))}&w=${embedWidth}&h=${embedHeight}&url=${encodeURIComponent(embedSrc)}${selectedComposition?.id ? `&compositionId=${encodeURIComponent(selectedComposition.id)}` : ''}`}
18723
18865
  <!-- Embed Code Block -->
18724
18866
  <div class="embed-code-ct flex flex-col gap-2">
18725
18867
  <div class="embed-code-header flex items-center justify-between">
@@ -10,6 +10,6 @@ interface Props {
10
10
  urlPlaceholder?: string;
11
11
  accept?: string;
12
12
  }
13
- declare const FileUrlSourceControl: import("svelte").Component<Props, {}, "fileName" | "fileContent" | "fileEncoding" | "url">;
13
+ declare const FileUrlSourceControl: import("svelte").Component<Props, {}, "url" | "fileName" | "fileContent" | "fileEncoding">;
14
14
  type FileUrlSourceControl = ReturnType<typeof FileUrlSourceControl>;
15
15
  export default FileUrlSourceControl;
@@ -23,6 +23,7 @@
23
23
  sanitizePreviewBuildError,
24
24
  isInfrastructurePreviewError
25
25
  } from '../pageHelpers.js';
26
+ import { widgetBuilderRequestInit } from '../utils/widgetBuilderRequest.js';
26
27
  import {
27
28
  widgetPublishStatus,
28
29
  codeGenerationStatus,
@@ -1414,7 +1415,7 @@
1414
1415
  async function requestBuildFromRepo(widgetId: string): Promise<any> {
1415
1416
  const anyClient = agentClient as any;
1416
1417
  if (typeof anyClient.agentWidgetBuilderBuildFromRepoWidgetIdPost === 'function') {
1417
- return anyClient.agentWidgetBuilderBuildFromRepoWidgetIdPost({ widgetId });
1418
+ return anyClient.agentWidgetBuilderBuildFromRepoWidgetIdPost({ widgetId }, widgetBuilderRequestInit(widgetBuilderPublicBaseUrl));
1418
1419
  }
1419
1420
  const cfg = anyClient.configuration || {};
1420
1421
  const builderBasePath = String(cfg.basePath || '').replace(/\/v1\/?$/, '') || undefined;
@@ -1429,7 +1430,7 @@
1429
1430
  // builderBasePath,
1430
1431
  // sdkPath: '/v1/agent/widget-builder/build-from-repo/{widgetId}',
1431
1432
  // });
1432
- return builder.buildWidgetFromRepo({ widgetId });
1433
+ return builder.buildWidgetFromRepo({ widgetId }, widgetBuilderRequestInit(widgetBuilderPublicBaseUrl));
1433
1434
  }
1434
1435
 
1435
1436
  export async function triggerBuildFromRepo(options?: { force?: boolean }): Promise<void> {
@@ -39,7 +39,7 @@
39
39
  /** Resolve a live preview URL for a widget (CDN published or Worker preview). */
40
40
  resolveUrl?: ((widgetId: string) => string | null) | null;
41
41
  /** Keep chrome visible while a historical build is pending or failed. */
42
- resolvePreviewState?: ((widgetId: string) => { loading: boolean; error: string | null } | null) | null;
42
+ resolvePreviewState?: ((widgetId: string) => { url?: string | null; loading: boolean; error: string | null } | null) | null;
43
43
  /** Retry the selected historical version; never refresh shared HEAD. */
44
44
  onRetryPreview?: ((widgetId: string) => void) | null;
45
45
  /** Currently selected WidgetShape id (highlights chrome). */
@@ -36,6 +36,7 @@ interface Props {
36
36
  resolveUrl?: ((widgetId: string) => string | null) | null;
37
37
  /** Keep chrome visible while a historical build is pending or failed. */
38
38
  resolvePreviewState?: ((widgetId: string) => {
39
+ url?: string | null;
39
40
  loading: boolean;
40
41
  error: string | null;
41
42
  } | null) | null;
@@ -72,9 +72,10 @@ export interface CreatorAppProps {
72
72
  * The page's own media library for the file pickers of the editor (the image, video and file settings of a widget):
73
73
  * their files are listed, uploaded, renamed and deleted through these functions instead of the visitor's Widgetic
74
74
  * uploads. When `upload` is given, chat attachments and prompt/canvas image drops call it once per file with
75
- * `{ file, purpose: 'chat' | 'canvas', onProgress?, signal? }` (file fields use `purpose: 'field'`). The transfer
76
- * has no time limit of ours: it ends when your promise settles or when `signal` aborts. On failure or an invalid
77
- * result the upload is reported to the visitor and Widgetic's storage is not used.
75
+ * `{ file, purpose: 'chat' | 'canvas', onProgress?, signal? }` (file fields use `purpose: 'field'`); a file that
76
+ * is attached and then sent is not uploaded again. The transfer has no time limit of ours: it ends when your
77
+ * promise settles or when `signal` aborts. On failure or an invalid result the visitor is shown the message of
78
+ * your error ("The upload failed." when it has none) and Widgetic's storage is not used.
78
79
  */
79
80
  mediaLibrary?: MediaLibraryProvider;
80
81
  /** File pickers in widget settings; when set, overrides `mediaLibrary` there only (chat/canvas still use `mediaLibrary`). */