@agent-native/core 0.164.22 → 0.164.23

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.
@@ -63,7 +63,8 @@ interface EditorSidebarProps {
63
63
  aspectRatio?: AspectRatio;
64
64
  /** Active deck design system used by slide content tokens. */
65
65
  designSystem?: DesignSystemData;
66
- /** The next slide while the agent is preparing its HTML. */
66
+ /** The next slide while the agent is preparing its HTML. Omitted when the
67
+ * agent is filling a placeholder that already has a row in this rail. */
67
68
  generatingSlide?: { index: number };
68
69
  generatingSlideSelected?: boolean;
69
70
  onSelectGeneratingSlide?: () => void;
@@ -75,8 +76,15 @@ interface EditorSidebarProps {
75
76
  /** Clears `describeSlideId` in the parent when the popover closes. */
76
77
  onCloseDescribe: () => void;
77
78
  /** Reports add-slide generation state up so the toolbar's New Slide button
78
- * can disable itself while a request is in flight. */
79
- onAddSlideGeneratingChange?: (generating: boolean) => void;
79
+ * can disable itself while a request is in flight. `targetSlideId` is the
80
+ * placeholder the agent was asked to fill, so the parent can mark that row
81
+ * as the AI-active one instead of appending a second generating row. */
82
+ onAddSlideGeneratingChange?: (
83
+ generating: boolean,
84
+ targetSlideId: string | null,
85
+ ) => void;
86
+ /** Slide the agent is filling in place, marked as AI-active in the rail. */
87
+ aiGeneratingSlideId?: string | null;
80
88
  /** Resolves once a just-inserted blank slide has actually reached the
81
89
  * server, so the agent's update-slide request can't race the add-slide
82
90
  * persistence. */
@@ -199,6 +207,7 @@ function SortableSlideThumb({
199
207
  onOverflowChange,
200
208
  readOnly = false,
201
209
  aiEditing = false,
210
+ isFillingPlaceholder = false,
202
211
  canDelete = true,
203
212
  hasSlideClipboard = false,
204
213
  onCutSlide,
@@ -219,7 +228,11 @@ function SortableSlideThumb({
219
228
  aspectRatio?: AspectRatio;
220
229
  designSystem?: DesignSystemData;
221
230
  onOverflowChange: (info: SlideOverflowInfo) => void;
231
+ /** A recent edit attributed to the agent — a lingering highlight, not a live signal. */
222
232
  aiEditing?: boolean;
233
+ /** This exact slide is the placeholder the agent is filling right now — the
234
+ * one case where the shimmer belongs even without live presence. */
235
+ isFillingPlaceholder?: boolean;
223
236
  /** False when this is the deck's last remaining slide — Cut/Delete stay enabled elsewhere but must not remove it. */
224
237
  canDelete?: boolean;
225
238
  hasSlideClipboard?: boolean;
@@ -255,7 +268,11 @@ function SortableSlideThumb({
255
268
  const humanPresenceUsers = presenceUsers.filter(
256
269
  (user) => !isAgentPresenceUser(user),
257
270
  );
258
- const showAiMarker = aiEditing || agentPresent;
271
+ const showAiMarker = aiEditing || agentPresent || isFillingPlaceholder;
272
+ // Narrower than the badge above: `aiEditing` also covers a slide's lingering
273
+ // post-edit highlight, which is "recently done," not "in progress." The
274
+ // shimmer should only run while the agent is actually live on this slide.
275
+ const showGeneratingShimmer = agentPresent || isFillingPlaceholder;
259
276
 
260
277
  return (
261
278
  <div ref={setNodeRef} style={style}>
@@ -331,6 +348,12 @@ function SortableSlideThumb({
331
348
  designSystem={designSystem}
332
349
  onOverflowChange={onOverflowChange}
333
350
  />
351
+ {showGeneratingShimmer && (
352
+ <div
353
+ aria-hidden="true"
354
+ className="slide-thumbnail-ai-shimmer pointer-events-none absolute inset-0 z-10"
355
+ />
356
+ )}
334
357
  {slide.skipped && (
335
358
  // guard:allow-raw-color — dims an arbitrary-colored slide render, not app chrome; must stay black regardless of theme
336
359
  <div className="absolute inset-0 z-10 flex items-center justify-center bg-black/40">
@@ -454,6 +477,7 @@ export default function EditorSidebar({
454
477
  describeSlideId,
455
478
  onCloseDescribe,
456
479
  onAddSlideGeneratingChange,
480
+ aiGeneratingSlideId,
457
481
  onAwaitAddSlidePersisted,
458
482
  onRemoveFailedSlide,
459
483
  addSlideAgentSubmit,
@@ -662,6 +686,7 @@ export default function EditorSidebar({
662
686
  aspectRatio={aspectRatio}
663
687
  designSystem={designSystem}
664
688
  aiEditing={aiEditedSlideIds.has(slide.id)}
689
+ isFillingPlaceholder={slide.id === aiGeneratingSlideId}
665
690
  canDelete={slides.length > 1}
666
691
  hasSlideClipboard={hasSlideClipboard}
667
692
  onCutSlide={onCutSlide}
@@ -706,12 +731,12 @@ export default function EditorSidebar({
706
731
  slideCount={slides.length}
707
732
  targetSlideId={describeSlideId}
708
733
  agentSubmit={async (message, context) => {
709
- onAddSlideGeneratingChange?.(true);
734
+ onAddSlideGeneratingChange?.(true, describeSlideId);
710
735
  try {
711
736
  await onAwaitAddSlidePersisted?.();
712
737
  } catch (error) {
713
738
  console.error("Failed to persist new slide:", error);
714
- onAddSlideGeneratingChange?.(false);
739
+ onAddSlideGeneratingChange?.(false, null);
715
740
  // The popover already closed (AddSlidePopover doesn't wait on
716
741
  // this async callback), so the typed prompt is gone either
717
742
  // way. Only remove the placeholder if it's still untouched —
@@ -1167,6 +1167,35 @@ button[title="Open agent sidebar"] {
1167
1167
  }
1168
1168
  }
1169
1169
 
1170
+ /* Sweeps across a slide thumbnail while the agent is generating its content.
1171
+ Sits above the rendered slide so it reads as "in progress" instead of a
1172
+ static placeholder for the length of the generation run. */
1173
+ .slide-thumbnail-ai-shimmer {
1174
+ background: linear-gradient(
1175
+ 100deg,
1176
+ transparent 30%,
1177
+ rgba(255, 255, 255, 0.16) 50%,
1178
+ transparent 70%
1179
+ );
1180
+ background-size: 200% 100%;
1181
+ animation: slide-thumbnail-shimmer 1.6s ease-in-out infinite;
1182
+ }
1183
+
1184
+ @keyframes slide-thumbnail-shimmer {
1185
+ from {
1186
+ background-position: 150% 0;
1187
+ }
1188
+ to {
1189
+ background-position: -50% 0;
1190
+ }
1191
+ }
1192
+
1193
+ @media (prefers-reduced-motion: reduce) {
1194
+ .slide-thumbnail-ai-shimmer {
1195
+ animation: none;
1196
+ }
1197
+ }
1198
+
1170
1199
  .image-overlay-btn {
1171
1200
  display: flex;
1172
1201
  align-items: center;
@@ -26,6 +26,31 @@ export function shouldShowNewDeckGeneratingProgress({
26
26
  return generating && isNewDeckCreation;
27
27
  }
28
28
 
29
+ /** The blank placeholder "New slide" inserted and handed to the agent to fill.
30
+ * While one is live the rail marks that existing row as AI-active; appending
31
+ * the synthetic generating row too would read as a second, duplicate slide.
32
+ * Returns null once the placeholder leaves the deck, or once its content is
33
+ * no longer the blank stand-in: the fill is done, presence/recent-edit
34
+ * tracking picks up that slide's own marker from there, and if the same run
35
+ * goes on to `add-slide` more slides (a multi-slide request), those are
36
+ * genuinely new and should get the trailing generating row again. */
37
+ export function slideBeingFilledInPlace({
38
+ addSlideGenerating,
39
+ addSlideTargetId,
40
+ slides,
41
+ blankContent,
42
+ }: {
43
+ addSlideGenerating: boolean;
44
+ addSlideTargetId: string | null;
45
+ slides: { id: string; content: string }[];
46
+ blankContent: string;
47
+ }): string | null {
48
+ if (!addSlideGenerating || !addSlideTargetId) return null;
49
+ const target = slides.find((slide) => slide.id === addSlideTargetId);
50
+ if (!target || target.content !== blankContent) return null;
51
+ return addSlideTargetId;
52
+ }
53
+
29
54
  export function shouldClearNewDeckGeneratingState({
30
55
  generating,
31
56
  generationStarted,
@@ -65,6 +65,7 @@ import { Button } from "@/components/ui/button";
65
65
  import {
66
66
  clearSlideEditingActive,
67
67
  deckIdFromPathname,
68
+ defaultSlideContent,
68
69
  hasUnsavedDeckChanges,
69
70
  markSlideEditingActive,
70
71
  type Slide,
@@ -100,6 +101,7 @@ import {
100
101
  shouldClearNewDeckGeneratingState,
101
102
  shouldShowNewDeckGeneratingOverlay,
102
103
  shouldShowNewDeckGeneratingProgress,
104
+ slideBeingFilledInPlace,
103
105
  } from "@/lib/generation-state";
104
106
  import { isMissingUploadProviderError } from "@/lib/image-drop-to-agent";
105
107
  import {
@@ -172,6 +174,14 @@ export default function DeckEditor() {
172
174
  const [activeSlideId, setActiveSlideId] = useState<string | null>(null);
173
175
  const [inlineEditActive, setInlineEditActive] = useState(false);
174
176
  const [addSlideGenerating, setAddSlideGenerating] = useState(false);
177
+ // The blank placeholder the agent was asked to fill in place. The rail must
178
+ // light THAT row up as AI-active instead of appending a synthetic generating
179
+ // row, which reads as a second, duplicate slide.
180
+ const [addSlideTargetId, setAddSlideTargetId] = useState<string | null>(null);
181
+ const endAddSlideGeneration = useCallback(() => {
182
+ setAddSlideGenerating(false);
183
+ setAddSlideTargetId(null);
184
+ }, []);
175
185
  const [generatingSlideSelected, setGeneratingSlideSelected] = useState(false);
176
186
  const { hasUnsavedChanges: hasUnsavedSave } = useSaveState();
177
187
  const hasPendingDeckEdits =
@@ -207,17 +217,37 @@ export default function DeckEditor() {
207
217
  // tracking correct across a remount.
208
218
  const { generating: addSlideAgentGenerating, submit: addSlideAgentSubmit } =
209
219
  useAgentGenerating();
220
+ // Neither hook above is actually scoped to THIS run until its own submit()
221
+ // call has fired: before that, `activeTabRef` inside useAgentGenerating is
222
+ // still null, so both hooks report on ANY chat activity system-wide, same
223
+ // as the broad instance. The target is set (and the popover's persistence
224
+ // wait starts) well before that submit call, so an unrelated run finishing
225
+ // during that wait could otherwise satisfy either "seen true" guard below
226
+ // and clear the freshly-set target before this run ever sent a request.
227
+ // Both cleanup effects stay inert until this flips true.
228
+ const addSlideRequestSentRef = useRef(false);
210
229
  const sawAddSlideAgentGeneratingRef = useRef(false);
211
230
  useEffect(() => {
231
+ if (!addSlideRequestSentRef.current) return;
212
232
  if (addSlideAgentGenerating) {
213
233
  sawAddSlideAgentGeneratingRef.current = true;
214
234
  return;
215
235
  }
216
236
  if (addSlideGenerating && sawAddSlideAgentGeneratingRef.current) {
217
237
  sawAddSlideAgentGeneratingRef.current = false;
218
- setAddSlideGenerating(false);
238
+ endAddSlideGeneration();
219
239
  }
220
- }, [addSlideGenerating, addSlideAgentGenerating]);
240
+ }, [addSlideGenerating, addSlideAgentGenerating, endAddSlideGeneration]);
241
+ // Same guard for the broad `generating` signal below, which is never scoped
242
+ // to this run at all (by design — it reflects ANY agent chat activity).
243
+ const sawGeneratingRef = useRef(false);
244
+ const submitAddSlideAgent = useCallback(
245
+ (message: string, context: string) => {
246
+ addSlideRequestSentRef.current = true;
247
+ addSlideAgentSubmit(message, context);
248
+ },
249
+ [addSlideAgentSubmit],
250
+ );
221
251
  // Generation intent can arrive after this route mounts because the user
222
252
  // answers pre-generation questions from the empty editor.
223
253
  const wasNewDeckCreation = useRef(searchParams.get("generating") === "1");
@@ -371,10 +401,18 @@ export default function DeckEditor() {
371
401
  });
372
402
 
373
403
  const showQuestionFlow = Boolean(questionFlowQuestions?.length);
404
+ const fillingPlaceholderSlideId = slideBeingFilledInPlace({
405
+ addSlideGenerating,
406
+ addSlideTargetId,
407
+ slides: deck?.slides ?? [],
408
+ blankContent: defaultSlideContent.blank,
409
+ });
374
410
  const generatingSlideVisible =
375
411
  canEdit &&
376
412
  !showQuestionFlow &&
377
- (isNewDeckGenerating || addSlideGenerating || showNewDeckGeneratingOverlay);
413
+ (isNewDeckGenerating ||
414
+ (addSlideGenerating && !fillingPlaceholderSlideId) ||
415
+ showNewDeckGeneratingOverlay);
378
416
  const showCurrentSlideEditor =
379
417
  !generatingSlideSelected &&
380
418
  !showNewDeckGeneratingOverlay &&
@@ -385,10 +423,20 @@ export default function DeckEditor() {
385
423
  }, [generatingSlideVisible]);
386
424
 
387
425
  // The add-slide request is finished once the agent stops generating, so the
388
- // rail's placeholder must not outlive it.
426
+ // rail's placeholder must not outlive it. Mirrors the "seen true first"
427
+ // guard above so this backstop can't fire while `generating` just hasn't
428
+ // caught up with a run that hasn't started sending yet.
389
429
  useEffect(() => {
390
- if (!generating) setAddSlideGenerating(false);
391
- }, [generating]);
430
+ if (!addSlideRequestSentRef.current) return;
431
+ if (generating) {
432
+ sawGeneratingRef.current = true;
433
+ return;
434
+ }
435
+ if (addSlideGenerating && sawGeneratingRef.current) {
436
+ sawGeneratingRef.current = false;
437
+ endAddSlideGeneration();
438
+ }
439
+ }, [generating, addSlideGenerating, endAddSlideGeneration]);
392
440
 
393
441
  // Below `md` the rail is a drawer behind a full-viewport dimming scrim; at
394
442
  // `md` and up it's docked with no scrim. `sidebarOpen` is seeded from the
@@ -1606,8 +1654,22 @@ export default function DeckEditor() {
1606
1654
  onCloseDescribe={() => setDescribeSlideId(null)}
1607
1655
  onAwaitAddSlidePersisted={() => flushDeckSave(id)}
1608
1656
  onRemoveFailedSlide={(slideId) => deleteSlide(id, slideId)}
1609
- addSlideAgentSubmit={addSlideAgentSubmit}
1610
- onAddSlideGeneratingChange={setAddSlideGenerating}
1657
+ addSlideAgentSubmit={submitAddSlideAgent}
1658
+ onAddSlideGeneratingChange={(isGenerating, targetSlideId) => {
1659
+ if (isGenerating) {
1660
+ // A new run starts clean: neither guard's "seen true"
1661
+ // state may carry over from an unrelated chat run, or
1662
+ // from whatever state the previous add-slide run left
1663
+ // behind, or the auto-clear effects below could fire on
1664
+ // stale state before this run even sends its request.
1665
+ sawGeneratingRef.current = false;
1666
+ sawAddSlideAgentGeneratingRef.current = false;
1667
+ addSlideRequestSentRef.current = false;
1668
+ }
1669
+ setAddSlideGenerating(isGenerating);
1670
+ setAddSlideTargetId(isGenerating ? targetSlideId : null);
1671
+ }}
1672
+ aiGeneratingSlideId={fillingPlaceholderSlideId}
1611
1673
  onSelectSlide={(slideId) => {
1612
1674
  setGeneratingSlideSelected(false);
1613
1675
  setActiveSlideId(slideId);
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
+ error?: undefined;
65
66
  states: {
66
67
  clientId: number;
67
68
  state: string;
68
69
  }[];
69
- error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
+ error?: undefined;
80
81
  users: {
81
82
  clientId: number;
82
83
  lastSeen: number;
83
84
  }[];
84
- error?: undefined;
85
85
  }>>;
@@ -13,8 +13,8 @@
13
13
  * Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
14
14
  */
15
15
  export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
16
- error: string;
17
16
  ok?: undefined;
17
+ error: string;
18
18
  } | {
19
19
  error?: undefined;
20
20
  ok: boolean;
@@ -11,23 +11,23 @@
11
11
  * DELETE /_agent-native/notifications/:id — delete
12
12
  */
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
+ error?: undefined;
14
15
  count: number;
15
16
  updated?: undefined;
16
- error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
- count?: undefined;
20
- updated: number;
21
19
  error?: undefined;
20
+ updated: number;
22
21
  ok?: undefined;
23
- } | {
24
22
  count?: undefined;
23
+ } | {
25
24
  updated?: undefined;
26
25
  error: string;
27
26
  ok?: undefined;
28
- } | {
29
27
  count?: undefined;
30
- updated?: undefined;
28
+ } | {
31
29
  error?: undefined;
30
+ updated?: undefined;
32
31
  ok: boolean;
32
+ count?: undefined;
33
33
  }>>;
@@ -41,14 +41,14 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- ok?: undefined;
45
44
  error?: undefined;
45
+ ok?: undefined;
46
46
  summary: import("./types.js").TraceSummary;
47
47
  spans: import("./types.js").TraceSpan[];
48
48
  id?: undefined;
49
49
  } | {
50
- ok?: undefined;
51
50
  error?: undefined;
51
+ ok?: undefined;
52
52
  summary?: undefined;
53
53
  spans?: undefined;
54
54
  id: string;
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- ok: boolean;
19
18
  error?: undefined;
19
+ ok: boolean;
20
20
  }>>;
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- status?: undefined;
38
37
  ok?: undefined;
38
+ status?: undefined;
39
39
  } | {
40
+ error?: undefined;
40
41
  ok: boolean;
41
42
  status: string;
42
- error?: undefined;
43
43
  } | {
44
+ ok?: undefined;
44
45
  error: string;
45
46
  removed?: undefined;
46
- ok?: undefined;
47
47
  } | {
48
+ error?: undefined;
48
49
  ok: boolean;
49
50
  removed: boolean;
50
- error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — validate an optional candidate value
54
54
  * or the current stored value without changing anything.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
+ ok?: undefined;
57
58
  error: string;
58
59
  note?: undefined;
59
- ok?: undefined;
60
60
  } | {
61
+ error?: undefined;
61
62
  ok: boolean;
62
63
  note?: undefined;
63
- error?: undefined;
64
64
  } | {
65
+ error?: undefined;
65
66
  ok: boolean;
66
67
  note: string;
67
- error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
+ error?: undefined;
98
99
  ok: boolean;
99
100
  key: string;
100
- error?: undefined;
101
101
  } | {
102
+ error?: undefined;
102
103
  ok: boolean;
103
104
  removed: boolean;
104
- error?: undefined;
105
105
  }>>;
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
27
27
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
28
28
  error: any;
29
29
  } | {
30
+ error?: undefined;
30
31
  ok: boolean;
31
32
  key: string;
32
33
  baseUrlKey?: string;
33
34
  scope: AgentEngineApiKeyScope;
34
- error?: undefined;
35
35
  }>>;
36
36
  export {};
@@ -60,6 +60,7 @@ import { getConfiguredAppBasePath } from "./app-base-path.js";
60
60
  import { getAppProductionUrl } from "./app-url.js";
61
61
  import { readAnalyticsAnonymousId, readFirstTouchAttribution, signupAttributionFromCookieHeader, } from "./attribution.js";
62
62
  import { getAuthLoginMode } from "./auth-login-mode.js";
63
+ import { injectBetaOptOutPersistence } from "./beta-opt-out-html.js";
63
64
  import { createBetterAuthSessionForEmail, ensureGoogleAuthIdentity, getAuthSecret, getBetterAuth, getBetterAuthSync, isDeployPreview, } from "./better-auth-instance.js";
64
65
  import { BUILDER_CONNECT_PARAM, BUILDER_RELAY_PATH, BUILDER_RELAY_STATE_PARAM, verifyBuilderConnectTokenAndGetOwner, verifyBuilderPreviewRelayStateForCallback, } from "./builder-browser.js";
65
66
  import { resolveAuthCookieNamespace } from "./cookie-namespace.js";
@@ -346,7 +347,9 @@ export function getConfiguredLoginHtml(event) {
346
347
  const queryStart = url.indexOf("?");
347
348
  const rawPath = queryStart >= 0 ? url.slice(0, queryStart) : url;
348
349
  const loginHtml = config.getLoginHtml?.(event, rawPath) ?? config.loginHtml ?? null;
349
- return loginHtml ? injectLoginSocialImageMeta(loginHtml, event) : null;
350
+ return loginHtml
351
+ ? injectLoginSocialImageMeta(injectBetaOptOutPersistence(loginHtml), event)
352
+ : null;
350
353
  }
351
354
  /**
352
355
  * True only when the request originates from the local machine — the raw
@@ -1934,7 +1937,7 @@ function injectLoginSocialImageMeta(loginHtml, event) {
1934
1937
  loginHtml.slice(headCloseIdx));
1935
1938
  }
1936
1939
  function loginHtmlResponse(loginHtml, event) {
1937
- return new Response(injectAnalyticsIntoHtml(injectLoginSocialImageMeta(loginHtml, event)), {
1940
+ return new Response(injectAnalyticsIntoHtml(injectLoginSocialImageMeta(injectBetaOptOutPersistence(loginHtml), event)), {
1938
1941
  status: 200,
1939
1942
  headers: {
1940
1943
  "Content-Type": "text/html; charset=utf-8",
@@ -0,0 +1,7 @@
1
+ export declare const BETA_OPT_OUT_PERSISTENCE_MARKER = "Persist the beta opt-out before authentication";
2
+ /**
3
+ * Custom auth pages do not necessarily use the framework onboarding shell.
4
+ * Keep the production switcher's one-time opt-out behavior at the shared auth
5
+ * response boundary so those pages cannot drop the handoff before sign-in.
6
+ */
7
+ export declare function injectBetaOptOutPersistence(loginHtml: string): string;
@@ -0,0 +1,53 @@
1
+ import { BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, } from "../shared/environment-lanes.js";
2
+ export const BETA_OPT_OUT_PERSISTENCE_MARKER = "Persist the beta opt-out before authentication";
3
+ /**
4
+ * Custom auth pages do not necessarily use the framework onboarding shell.
5
+ * Keep the production switcher's one-time opt-out behavior at the shared auth
6
+ * response boundary so those pages cannot drop the handoff before sign-in.
7
+ */
8
+ export function injectBetaOptOutPersistence(loginHtml) {
9
+ if (loginHtml.includes(BETA_OPT_OUT_PERSISTENCE_MARKER))
10
+ return loginHtml;
11
+ const script = `<script data-agent-native-beta-opt-out>
12
+ // ${BETA_OPT_OUT_PERSISTENCE_MARKER}.
13
+ (function __anPersistBetaOptOut() {
14
+ try {
15
+ var optOutUrl = new URL(window.location.href);
16
+ var optOutValue = optOutUrl.searchParams.get(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
17
+ if (optOutValue === null) return;
18
+ var optOutExpiry = Number(optOutValue);
19
+ var optOutStorageReady = false;
20
+ try {
21
+ if (Number.isFinite(optOutExpiry) && optOutExpiry > Date.now()) {
22
+ window.localStorage.setItem(
23
+ ${JSON.stringify(BETA_OPT_OUT_STORAGE_KEY)},
24
+ String(optOutExpiry),
25
+ );
26
+ }
27
+ optOutStorageReady = true;
28
+ } catch (error) {
29
+ void error;
30
+ }
31
+ if (optOutStorageReady) {
32
+ optOutUrl.searchParams.delete(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
33
+ window.history.replaceState(null, '', optOutUrl.toString());
34
+ }
35
+ } catch (error) {
36
+ void error;
37
+ }
38
+ })();
39
+ </script>`;
40
+ const bodyCloseIndex = loginHtml.indexOf("</body>");
41
+ if (bodyCloseIndex >= 0) {
42
+ return (loginHtml.slice(0, bodyCloseIndex) +
43
+ script +
44
+ loginHtml.slice(bodyCloseIndex));
45
+ }
46
+ const headCloseIndex = loginHtml.indexOf("</head>");
47
+ if (headCloseIndex >= 0) {
48
+ return (loginHtml.slice(0, headCloseIndex) +
49
+ script +
50
+ loginHtml.slice(headCloseIndex));
51
+ }
52
+ return loginHtml + script;
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.164.22",
3
+ "version": "0.164.23",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {