@agent-native/core 0.176.4-nightly-20260902022549 → 0.176.4-nightly-20260902024948

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.
@@ -1,5 +1,5 @@
1
1
  import type { AgentNativeDeploymentEnvironment, AgentNativeConfig } from "../config.js";
2
- export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, buildEnvironmentOptOutUrl, buildEnvironmentUrl, resolveEnvironmentTargets, type EnvironmentBadgeTargets, } from "../shared/environment-lanes.js";
2
+ export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, BETA_REDIRECT_DURATION_MS, BETA_REDIRECT_STORAGE_KEY, buildEnvironmentOptOutUrl, buildEnvironmentUrl, resolveEnvironmentTargets, type EnvironmentBadgeTargets, } from "../shared/environment-lanes.js";
3
3
  export declare function isBuilderIoEmployee(email: string | null | undefined): boolean;
4
4
  export declare function isAgentNativeDesktopUserAgent(userAgent: string | undefined): boolean;
5
5
  export declare function resolveEnvironmentChannel(config: AgentNativeConfig, hostname: string | undefined): Extract<AgentNativeDeploymentEnvironment, "local" | "beta" | "production"> | null;
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button } from "@agent-native/toolkit/ui/button";
3
3
  import { Popover, PopoverContent, PopoverTrigger, } from "@agent-native/toolkit/ui/popover";
4
4
  import { useEffect, useMemo, useRef, useState } from "react";
5
- import { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, buildEnvironmentOptOutUrl, buildEnvironmentUrl, resolveEnvironmentTargets, } from "../shared/environment-lanes.js";
5
+ import { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, BETA_REDIRECT_DURATION_MS, BETA_REDIRECT_STORAGE_KEY, buildEnvironmentOptOutUrl, buildEnvironmentUrl, resolveEnvironmentTargets, } from "../shared/environment-lanes.js";
6
6
  import { trackEvent } from "./analytics.js";
7
7
  import { injectedAgentNativeConfig } from "./app-config.js";
8
8
  import { useSession } from "./use-session.js";
9
9
  import { cn } from "./utils.js";
10
- export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, buildEnvironmentOptOutUrl, buildEnvironmentUrl, resolveEnvironmentTargets, } from "../shared/environment-lanes.js";
10
+ export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, BETA_REDIRECT_DURATION_MS, BETA_REDIRECT_STORAGE_KEY, buildEnvironmentOptOutUrl, buildEnvironmentUrl, resolveEnvironmentTargets, } from "../shared/environment-lanes.js";
11
11
  export function isBuilderIoEmployee(email) {
12
12
  return email?.trim().toLowerCase().endsWith("@builder.io") ?? false;
13
13
  }
@@ -50,6 +50,16 @@ function readBetaOptOutUntil(now = Date.now()) {
50
50
  }
51
51
  return null;
52
52
  }
53
+ function rememberBetaRedirectPreference() {
54
+ if (typeof window === "undefined")
55
+ return;
56
+ try {
57
+ window.localStorage.setItem(BETA_REDIRECT_STORAGE_KEY, String(Date.now() + BETA_REDIRECT_DURATION_MS));
58
+ }
59
+ catch {
60
+ // coercion-ok: the marker is only a performance hint; session auth remains authoritative.
61
+ }
62
+ }
53
63
  function rememberForcedProductionSession(sourceHref) {
54
64
  let forcedByQuery = false;
55
65
  try {
@@ -90,6 +100,7 @@ function consumeBetaOptOutQueryParam(sourceHref, now = Date.now()) {
90
100
  try {
91
101
  if (active) {
92
102
  window.localStorage.setItem(BETA_OPT_OUT_STORAGE_KEY, String(Number(rawExpiry)));
103
+ window.localStorage.removeItem(BETA_REDIRECT_STORAGE_KEY);
93
104
  }
94
105
  window.history.replaceState(null, "", target.toString());
95
106
  }
@@ -151,6 +162,7 @@ function ProductionEnvironmentBadge({ targets, }) {
151
162
  const betaHref = buildEnvironmentUrl(window.location.href, targets.betaHost);
152
163
  if (!betaHref || typeof window.location.replace !== "function")
153
164
  return;
165
+ rememberBetaRedirectPreference();
154
166
  didAutoRedirect.current = true;
155
167
  trackEvent("environment switched", {
156
168
  from_environment: "production",
@@ -23,6 +23,7 @@ declare global {
23
23
  workspaceGatewayUrl?: string;
24
24
  workspaceOAuthOrigin?: string;
25
25
  workspaceRuntime?: boolean;
26
+ workspaceAppMountPaths?: string[];
26
27
  sentryDsn?: string;
27
28
  sentryEnvironment?: string;
28
29
  deploymentEnvironment?: string;
@@ -56,6 +56,8 @@ import { ThemeProvider, useTheme } from "next-themes";
56
56
  import { useEffect, useRef } from "react";
57
57
  import { useInRouterContext } from "react-router";
58
58
  import { isHumanReadableDocumentTitle, normalizeDocumentTitle, } from "../shared/document-title.js";
59
+ import { getSsrBetaRedirectScriptBody } from "../shared/ssr-beta-redirect.js";
60
+ import { agentNativePath } from "./api-path.js";
59
61
  import { ClientOnly } from "./ClientOnly.js";
60
62
  import { DefaultSpinner } from "./DefaultSpinner.js";
61
63
  import { EnvironmentBadge } from "./EnvironmentBadge.js";
@@ -68,6 +70,11 @@ import { RuntimeConfigNotice } from "./RuntimeConfigNotice.js";
68
70
  import { EMBEDDED_THEME_CHANGE_EVENT, applyEmbeddedThemeUpdate, parseEmbeddedThemeUpdate, } from "./theme.js";
69
71
  import { createAgentNativeServerActionWebMcpRegistration } from "./webmcp.js";
70
72
  const DEFAULT_TOASTER = (_jsx(Toaster, { richColors: true, position: "bottom-left", offset: { bottom: 44, left: 32 }, mobileOffset: { bottom: 44, left: 16 } }));
73
+ function EarlyBetaRedirectScript() {
74
+ return (_jsx("script", { "data-agent-native-beta-redirect": "1", dangerouslySetInnerHTML: {
75
+ __html: getSsrBetaRedirectScriptBody(agentNativePath("/_agent-native/auth/session")),
76
+ } }));
77
+ }
71
78
  function RoutedAppEnhancements() {
72
79
  const isInRouter = useInRouterContext();
73
80
  if (!isInRouter)
@@ -165,5 +172,7 @@ export function AppProviders({ queryClient, isPublicPath = false, clientOnlyFall
165
172
  if (isPublicPath) {
166
173
  return (_jsx(ProvidersInner, { queryClient: queryClient, defaultTheme: defaultTheme, themeAttribute: themeAttribute, tooltipDelayDuration: tooltipDelayDuration, toaster: toaster, disableThemeTransitions: disableThemeTransitions, i18n: i18n, documentTitleFallback: documentTitleFallback, showProductionEnvironmentBadge: false, children: children }));
167
174
  }
168
- return (_jsx(ClientOnly, { fallback: fallback, children: _jsx(ProvidersInner, { queryClient: queryClient, defaultTheme: defaultTheme, themeAttribute: themeAttribute, tooltipDelayDuration: tooltipDelayDuration, toaster: toaster, disableThemeTransitions: disableThemeTransitions, i18n: i18n, documentTitleFallback: documentTitleFallback, showProductionEnvironmentBadge: !sessionBypass, children: _jsx(RequireSession, { bypass: sessionBypass, fallback: fallback, children: sessionBypass ? (children) : (_jsxs(FirstRunOnboardingStartupGate, { children: [_jsx(AutomaticWebMcpActionRegistration, {}), children] })) }) }) }));
175
+ // Keep the bootstrap outside ClientOnly so the HTML parser can run it before
176
+ // the authenticated client bundle starts.
177
+ return (_jsxs(_Fragment, { children: [!sessionBypass && _jsx(EarlyBetaRedirectScript, {}), _jsx(ClientOnly, { fallback: fallback, children: _jsx(ProvidersInner, { queryClient: queryClient, defaultTheme: defaultTheme, themeAttribute: themeAttribute, tooltipDelayDuration: tooltipDelayDuration, toaster: toaster, disableThemeTransitions: disableThemeTransitions, i18n: i18n, documentTitleFallback: documentTitleFallback, showProductionEnvironmentBadge: !sessionBypass, children: _jsx(RequireSession, { bypass: sessionBypass, fallback: fallback, children: sessionBypass ? (children) : (_jsxs(FirstRunOnboardingStartupGate, { children: [_jsx(AutomaticWebMcpActionRegistration, {}), children] })) }) }) })] }));
169
178
  }
@@ -1,3 +1,4 @@
1
+ import { BETA_REDIRECT_SIGN_OUT_STORAGE_KEY, BETA_REDIRECT_STORAGE_KEY, } from "../shared/environment-lanes.js";
1
2
  /**
2
3
  * The one client-side sign-out.
3
4
  *
@@ -27,6 +28,34 @@ import { beginSignOut, completeSignOut } from "./use-session.js";
27
28
  const LOGOUT_PATH = "/_agent-native/auth/logout";
28
29
  const SIGN_OUT_REQUEST_TIMEOUT_MS = 15_000;
29
30
  let signOutOperation = null;
31
+ function setBetaRedirectSignOutSignal() {
32
+ const signOutWindow = window;
33
+ signOutWindow.__agentNativeBetaRedirectSignOutStarted = true;
34
+ try {
35
+ window.sessionStorage.setItem(BETA_REDIRECT_SIGN_OUT_STORAGE_KEY, "1");
36
+ }
37
+ catch {
38
+ // coercion-ok: the in-memory signal still protects this document when storage is unavailable.
39
+ }
40
+ }
41
+ function clearBetaRedirectSignOutSignal() {
42
+ const signOutWindow = window;
43
+ signOutWindow.__agentNativeBetaRedirectSignOutStarted = false;
44
+ try {
45
+ window.sessionStorage.removeItem(BETA_REDIRECT_SIGN_OUT_STORAGE_KEY);
46
+ }
47
+ catch {
48
+ // coercion-ok: sign-out navigation must not depend on optional storage.
49
+ }
50
+ }
51
+ function clearBetaRedirectMarker() {
52
+ try {
53
+ window.localStorage.removeItem(BETA_REDIRECT_STORAGE_KEY);
54
+ }
55
+ catch {
56
+ // coercion-ok: local storage is optional; sign-out must still complete.
57
+ }
58
+ }
30
59
  /**
31
60
  * Sign the current user out and leave for the sign-in page when revocation
32
61
  * succeeds. A failed revoke reloads the current document instead.
@@ -41,6 +70,7 @@ export function signOut(options = {}) {
41
70
  return signOutOperation;
42
71
  }
43
72
  async function signOutFlow(options) {
73
+ setBetaRedirectSignOutSignal();
44
74
  beginSignOut();
45
75
  const controller = new AbortController();
46
76
  const timeout = setTimeout(() => controller.abort(), SIGN_OUT_REQUEST_TIMEOUT_MS);
@@ -69,6 +99,8 @@ async function signOutFlow(options) {
69
99
  if (!revoked) {
70
100
  // Do not send an unrevoked session through sign-in's continuation, which
71
101
  // can immediately authenticate it again.
102
+ clearBetaRedirectSignOutSignal();
103
+ clearBetaRedirectMarker();
72
104
  window.location.reload();
73
105
  return;
74
106
  }
@@ -78,5 +110,7 @@ async function signOutFlow(options) {
78
110
  completeSignOut();
79
111
  // `replace`, not `assign`: the dead authenticated URL must not stay in
80
112
  // history, or Back lands on a shell with no session.
113
+ clearBetaRedirectSignOutSignal();
114
+ clearBetaRedirectMarker();
81
115
  window.location.replace(options.redirectTo ?? buildSignInReturnHref());
82
116
  }
@@ -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
  }>>;
@@ -1363,6 +1363,43 @@ function getAppOriginClientConfigScript() {
1363
1363
  env.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON,
1364
1364
  ),
1365
1365
  );
1366
+ const workspaceAppMountPaths = (() => {
1367
+ const raw = firstNonEmpty(
1368
+ env.AGENT_NATIVE_WORKSPACE_APPS_JSON,
1369
+ env.VITE_AGENT_NATIVE_WORKSPACE_APPS_JSON,
1370
+ );
1371
+ if (!raw) return;
1372
+ try {
1373
+ const parsed = JSON.parse(raw);
1374
+ const entries = Array.isArray(parsed)
1375
+ ? parsed
1376
+ : parsed && typeof parsed === "object" && "apps" in parsed
1377
+ ? parsed.apps
1378
+ : null;
1379
+ if (!Array.isArray(entries)) return;
1380
+ const paths = Array.from(
1381
+ new Set(
1382
+ entries
1383
+ .map((entry) => {
1384
+ if (!entry || typeof entry !== "object") return null;
1385
+ const rawPath =
1386
+ typeof entry.path === "string"
1387
+ ? entry.path
1388
+ : typeof entry.id === "string"
1389
+ ? "/" + entry.id
1390
+ : null;
1391
+ if (!rawPath) return null;
1392
+ const normalized = normalizeAppBasePath(rawPath);
1393
+ return normalized || null;
1394
+ })
1395
+ .filter(Boolean),
1396
+ ),
1397
+ );
1398
+ return paths.length ? paths : undefined;
1399
+ } catch {
1400
+ return;
1401
+ }
1402
+ })();
1366
1403
  const appHomePath = resolveAgentNativeAppHomePath(getAgentNativeAppConfig().app);
1367
1404
  const config = {
1368
1405
  appHomePath,
@@ -1370,6 +1407,7 @@ function getAppOriginClientConfigScript() {
1370
1407
  ...(workspaceGatewayUrl ? { workspaceGatewayUrl } : {}),
1371
1408
  ...(workspaceOAuthOrigin ? { workspaceOAuthOrigin } : {}),
1372
1409
  ...(workspaceRuntime ? { workspaceRuntime: true } : {}),
1410
+ ...(workspaceAppMountPaths ? { workspaceAppMountPaths } : {}),
1373
1411
  };
1374
1412
  if (Object.keys(config).length === 0) return null;
1375
1413
  return (
@@ -11,14 +11,14 @@
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
+ error?: undefined;
19
20
  count?: undefined;
20
21
  updated: number;
21
- error?: undefined;
22
22
  ok?: undefined;
23
23
  } | {
24
24
  count?: undefined;
@@ -26,8 +26,8 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
26
26
  error: string;
27
27
  ok?: undefined;
28
28
  } | {
29
+ error?: undefined;
29
30
  count?: undefined;
30
31
  updated?: undefined;
31
- error?: undefined;
32
32
  ok: boolean;
33
33
  }>>;
@@ -41,16 +41,16 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- error?: undefined;
45
44
  summary: import("./types.js").TraceSummary;
46
45
  spans: import("./types.js").TraceSpan[];
47
46
  id?: undefined;
47
+ error?: undefined;
48
48
  ok?: undefined;
49
49
  } | {
50
- error?: undefined;
51
50
  summary?: undefined;
52
51
  spans?: undefined;
53
52
  id: string;
53
+ error?: undefined;
54
54
  ok?: undefined;
55
55
  } | {
56
56
  summary?: undefined;
@@ -59,9 +59,9 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
59
59
  error: any;
60
60
  ok?: undefined;
61
61
  } | {
62
- error?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
65
64
  id?: undefined;
65
+ error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
@@ -75,9 +75,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
+ deleted?: undefined;
78
79
  id?: undefined;
80
+ found?: undefined;
79
81
  message?: undefined;
80
- deleted?: undefined;
81
82
  providers: {
82
83
  id: string;
83
84
  label: string;
@@ -89,13 +90,12 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
89
90
  }[];
90
91
  count: number;
91
92
  provider?: undefined;
92
- found?: undefined;
93
93
  registered?: undefined;
94
94
  label?: undefined;
95
95
  } | {
96
+ deleted?: undefined;
96
97
  id?: undefined;
97
98
  message?: undefined;
98
- deleted?: undefined;
99
99
  providers?: undefined;
100
100
  count?: undefined;
101
101
  found: boolean;
@@ -103,8 +103,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
103
103
  registered?: undefined;
104
104
  label?: undefined;
105
105
  } | {
106
- message?: undefined;
107
106
  deleted?: undefined;
107
+ message?: undefined;
108
108
  providers?: undefined;
109
109
  count?: undefined;
110
110
  provider?: undefined;
@@ -113,21 +113,21 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
113
113
  registered?: undefined;
114
114
  label?: undefined;
115
115
  } | {
116
+ found?: undefined;
116
117
  message?: undefined;
117
118
  providers?: undefined;
118
119
  count?: undefined;
119
120
  provider?: undefined;
120
- found?: undefined;
121
121
  deleted: boolean;
122
122
  id: string;
123
123
  registered?: undefined;
124
124
  label?: undefined;
125
125
  } | {
126
126
  deleted?: undefined;
127
+ found?: undefined;
127
128
  providers?: undefined;
128
129
  count?: undefined;
129
130
  provider?: undefined;
130
- found?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -311,9 +311,9 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
311
311
  notes?: string | undefined;
312
312
  scope?: "org" | "user" | undefined;
313
313
  }, {
314
- deleted?: undefined;
315
314
  id?: undefined;
316
- provider?: undefined;
315
+ deleted?: undefined;
316
+ found?: undefined;
317
317
  providers: {
318
318
  id: string;
319
319
  label: string;
@@ -324,13 +324,13 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
324
324
  updatedAt: number;
325
325
  }[];
326
326
  count: number;
327
- found?: undefined;
327
+ provider?: undefined;
328
328
  registered?: undefined;
329
329
  label?: undefined;
330
330
  message?: undefined;
331
331
  } | {
332
- deleted?: undefined;
333
332
  id?: undefined;
333
+ deleted?: undefined;
334
334
  providers?: undefined;
335
335
  count?: undefined;
336
336
  found: boolean;
@@ -340,19 +340,19 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
340
340
  message?: undefined;
341
341
  } | {
342
342
  deleted?: undefined;
343
- provider?: undefined;
344
343
  providers?: undefined;
345
344
  count?: undefined;
345
+ provider?: undefined;
346
346
  found: boolean;
347
347
  id: string;
348
348
  registered?: undefined;
349
349
  label?: undefined;
350
350
  message?: undefined;
351
351
  } | {
352
- provider?: undefined;
352
+ found?: undefined;
353
353
  providers?: undefined;
354
354
  count?: undefined;
355
- found?: undefined;
355
+ provider?: undefined;
356
356
  deleted: boolean;
357
357
  id: string;
358
358
  registered?: undefined;
@@ -360,10 +360,10 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
360
360
  message?: undefined;
361
361
  } | {
362
362
  deleted?: undefined;
363
- provider?: undefined;
363
+ found?: undefined;
364
364
  providers?: undefined;
365
365
  count?: undefined;
366
- found?: undefined;
366
+ provider?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -73,6 +73,7 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
73
73
  offset?: unknown;
74
74
  limit?: unknown;
75
75
  }, {
76
+ deleted?: undefined;
76
77
  jobs: {
77
78
  id: string;
78
79
  name: string;
@@ -83,7 +84,6 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
83
84
  updatedAt: string;
84
85
  }[];
85
86
  total: number;
86
- deleted?: undefined;
87
87
  jobId?: undefined;
88
88
  } | {
89
89
  jobs?: undefined;
@@ -91,9 +91,9 @@ export declare function createProviderCorpusJobAction(options: CreateProviderCor
91
91
  deleted: boolean;
92
92
  jobId: string;
93
93
  } | {
94
+ deleted?: undefined;
94
95
  jobs?: undefined;
95
96
  total?: undefined;
96
- deleted?: undefined;
97
97
  jobId?: undefined;
98
98
  hits: Record<string, unknown>[];
99
99
  offset: number;
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
48
48
  }>;
49
49
  /** DELETE /_agent-native/resources/:id — delete a resource */
50
50
  export declare function handleDeleteResource(event: any): Promise<{
51
- ok?: undefined;
52
51
  error: string;
52
+ ok?: undefined;
53
53
  } | {
54
54
  error?: undefined;
55
55
  ok: boolean;
@@ -37,17 +37,17 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
37
37
  ok?: undefined;
38
38
  status?: undefined;
39
39
  } | {
40
+ error?: undefined;
40
41
  ok: boolean;
41
42
  status: string;
42
- error?: undefined;
43
43
  } | {
44
44
  ok?: undefined;
45
45
  error: string;
46
46
  removed?: 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
@@ -58,13 +58,13 @@ export declare function createTestSecretHandler(): import("h3").EventHandlerWith
58
58
  error: string;
59
59
  note?: 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
  }>>;
@@ -34,10 +34,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
34
34
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
35
35
  error: any;
36
36
  } | {
37
- error?: undefined;
38
37
  ok: boolean;
39
38
  key: string;
40
39
  baseUrlKey?: string;
41
40
  scope: AgentEngineApiKeyScope;
41
+ error?: undefined;
42
42
  }>>;
43
43
  export {};
@@ -21,5 +21,6 @@ export declare function resolvePublicAppOriginConfig(): {
21
21
  workspaceGatewayUrl?: string;
22
22
  workspaceOAuthOrigin?: string;
23
23
  workspaceRuntime?: boolean;
24
+ workspaceAppMountPaths?: string[];
24
25
  } | null;
25
26
  export declare function getAppOriginClientConfigScript(): string | null;
@@ -1,4 +1,38 @@
1
1
  import { getAppConfig, resolveAppHomePath } from "../app-config/index.js";
2
+ import { normalizeAppBasePath } from "./app-base-path.js";
3
+ function workspaceAppMountPathsFromJson(value) {
4
+ if (!value?.trim())
5
+ return undefined;
6
+ try {
7
+ const parsed = JSON.parse(value);
8
+ const entries = Array.isArray(parsed)
9
+ ? parsed
10
+ : parsed && typeof parsed === "object" && "apps" in parsed
11
+ ? parsed.apps
12
+ : null;
13
+ if (!Array.isArray(entries))
14
+ return undefined;
15
+ const paths = entries
16
+ .map((entry) => {
17
+ if (!entry || typeof entry !== "object")
18
+ return null;
19
+ const record = entry;
20
+ const rawPath = typeof record.path === "string"
21
+ ? record.path
22
+ : typeof record.id === "string"
23
+ ? `/${record.id}`
24
+ : undefined;
25
+ const normalized = normalizeAppBasePath(rawPath);
26
+ return normalized || null;
27
+ })
28
+ .filter((path) => Boolean(path));
29
+ return paths.length ? Array.from(new Set(paths)) : undefined;
30
+ }
31
+ catch {
32
+ // coercion-ok: malformed manifests omit optional mount hints; the browser falls back to the live segment.
33
+ return undefined;
34
+ }
35
+ }
2
36
  /**
3
37
  * Project this app's origins into the client shell.
4
38
  *
@@ -20,6 +54,7 @@ export function resolvePublicAppOriginConfig() {
20
54
  const config = getAppConfig();
21
55
  const workspaceRuntime = config.workspace.isWorkspace === true ||
22
56
  typeof config.workspace.appsJson === "string";
57
+ const workspaceAppMountPaths = workspaceAppMountPathsFromJson(config.workspace.appsJson);
23
58
  const resolved = {
24
59
  appHomePath: resolveAppHomePath(config.app),
25
60
  ...(config.app.url ? { appUrl: config.app.url } : {}),
@@ -30,6 +65,7 @@ export function resolvePublicAppOriginConfig() {
30
65
  ? { workspaceOAuthOrigin: config.workspace.oauthOrigin }
31
66
  : {}),
32
67
  ...(workspaceRuntime ? { workspaceRuntime: true } : {}),
68
+ ...(workspaceAppMountPaths ? { workspaceAppMountPaths } : {}),
33
69
  };
34
70
  return Object.keys(resolved).length > 0 ? resolved : null;
35
71
  }
@@ -419,12 +419,10 @@ export function getConfiguredLoginHtml(event) {
419
419
  const config = _authGuardConfig;
420
420
  if (!config)
421
421
  return null;
422
- const url = event.node?.req?.url ?? event.path ?? "/";
423
- const queryStart = url.indexOf("?");
424
- const rawPath = queryStart >= 0 ? url.slice(0, queryStart) : url;
422
+ const { rawPath } = getRequestPathAndSearch(event);
425
423
  const loginHtml = config.getLoginHtml?.(event, rawPath) ?? config.loginHtml ?? null;
426
424
  return loginHtml
427
- ? injectLoginSocialImageMeta(injectBetaOptOutPersistence(loginHtml), event)
425
+ ? injectLoginSocialImageMeta(injectBetaOptOutPersistence(loginHtml, rawPath), event)
428
426
  : null;
429
427
  }
430
428
  /**
@@ -2273,7 +2271,7 @@ function injectHeadScript(html, script) {
2273
2271
  return `<!doctype html><html><head>${script}</head><body>${html}</body></html>`;
2274
2272
  }
2275
2273
  function loginHtmlResponse(loginHtml, event, options = {}) {
2276
- let html = injectLoginSocialImageMeta(injectBetaOptOutPersistence(loginHtml), options.requestIndependent ? undefined : event);
2274
+ let html = injectLoginSocialImageMeta(injectBetaOptOutPersistence(loginHtml, getRequestPathAndSearch(event).rawPath), options.requestIndependent ? undefined : event);
2277
2275
  if (options.includeRootAuthRedirect) {
2278
2276
  html = injectHeadScript(html, getSsrAuthRedirectScript(SESSION_HINT_COOKIE, resolveAppHomePath(getAppConfig().app)));
2279
2277
  }
@@ -4,4 +4,4 @@ export declare const BETA_OPT_OUT_PERSISTENCE_MARKER = "Persist the beta opt-out
4
4
  * Keep the production switcher's one-time opt-out behavior at the shared auth
5
5
  * response boundary so those pages cannot drop the handoff before sign-in.
6
6
  */
7
- export declare function injectBetaOptOutPersistence(loginHtml: string): string;
7
+ export declare function injectBetaOptOutPersistence(loginHtml: string, requestPath?: string): string;
@@ -1,4 +1,7 @@
1
- import { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, } from "../shared/environment-lanes.js";
1
+ import { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, BETA_REDIRECT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, } from "../shared/environment-lanes.js";
2
+ import { getSsrBetaRedirectScript, SSR_BETA_REDIRECT_MARKER, } from "../shared/ssr-beta-redirect.js";
3
+ import { getAppBasePathFromViteEnv } from "./app-base-path.js";
4
+ import { workspaceBasePathFromRequest } from "./onboarding-html.js";
2
5
  export const BETA_OPT_OUT_PERSISTENCE_MARKER = "Persist the beta opt-out before authentication";
3
6
  const ENVIRONMENT_SWITCHER_MARKER = 'data-agent-native-environment-switcher="1"';
4
7
  const ENVIRONMENT_SWITCHER_STYLE_MARKER = 'data-agent-native-environment-switcher-style="1"';
@@ -190,6 +193,7 @@ const betaOptOutPersistenceScript = `<script data-agent-native-beta-opt-out>
190
193
  ${JSON.stringify(BETA_OPT_OUT_STORAGE_KEY)},
191
194
  String(optOutExpiry),
192
195
  );
196
+ window.localStorage.removeItem(${JSON.stringify(BETA_REDIRECT_STORAGE_KEY)});
193
197
  }
194
198
  optOutStorageReady = true;
195
199
  } catch (error) {
@@ -209,8 +213,12 @@ const betaOptOutPersistenceScript = `<script data-agent-native-beta-opt-out>
209
213
  * Keep the production switcher's one-time opt-out behavior at the shared auth
210
214
  * response boundary so those pages cannot drop the handoff before sign-in.
211
215
  */
212
- export function injectBetaOptOutPersistence(loginHtml) {
216
+ export function injectBetaOptOutPersistence(loginHtml, requestPath) {
213
217
  let html = loginHtml;
218
+ if (!html.includes(SSR_BETA_REDIRECT_MARKER)) {
219
+ const appBasePath = workspaceBasePathFromRequest(requestPath) || getAppBasePathFromViteEnv();
220
+ html = insertBeforeClosingTag(html, getSsrBetaRedirectScript(`${appBasePath}/_agent-native/auth/session`), "</head>");
221
+ }
214
222
  if (!html.includes(BETA_OPT_OUT_PERSISTENCE_MARKER)) {
215
223
  html = insertBeforeClosingTag(html, betaOptOutPersistenceScript, "</body>");
216
224
  }
@@ -1,4 +1,5 @@
1
1
  import { type GoogleAuthMode } from "./google-auth-mode.js";
2
+ export declare function workspaceBasePathFromRequest(requestPath: string | undefined): string;
2
3
  export interface SignupLegalNoticeOptions {
3
4
  termsUrl: string;
4
5
  privacyUrl: string;
@@ -52,7 +52,7 @@ function isWorkspaceRuntime() {
52
52
  const workspace = getAppConfig().workspace;
53
53
  return (workspace.isWorkspace === true || typeof workspace.appsJson === "string");
54
54
  }
55
- function workspaceBasePathFromRequest(requestPath) {
55
+ export function workspaceBasePathFromRequest(requestPath) {
56
56
  if (!isWorkspaceRuntime() || !requestPath)
57
57
  return "";
58
58
  const pathname = requestPath.split(/[?#]/, 1)[0] || "/";
@@ -26,8 +26,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
26
26
  expiresAt?: undefined;
27
27
  ttlSeconds?: undefined;
28
28
  } | {
29
+ error?: undefined;
29
30
  token: string;
30
31
  expiresAt: string;
31
32
  ttlSeconds: number;
32
- error?: undefined;
33
33
  }>>;
@@ -20,6 +20,6 @@ export declare function createTranscribeVoiceHandler(): import("h3").EventHandle
20
20
  error: string;
21
21
  text?: undefined;
22
22
  } | {
23
- error?: undefined;
24
23
  text: string;
24
+ error?: undefined;
25
25
  }>>;
@@ -1,6 +1,9 @@
1
1
  export declare const BETA_OPT_OUT_QUERY_PARAM = "agentNativeBetaOptOut";
2
2
  export declare const BETA_OPT_OUT_DURATION_MS: number;
3
3
  export declare const BETA_OPT_OUT_STORAGE_KEY = "agent-native:beta-opt-out-until";
4
+ export declare const BETA_REDIRECT_DURATION_MS: number;
5
+ export declare const BETA_REDIRECT_STORAGE_KEY = "agent-native:beta-redirect-until";
6
+ export declare const BETA_REDIRECT_SIGN_OUT_STORAGE_KEY = "agent-native:beta-redirect-signing-out";
4
7
  export declare const BETA_FORCE_QUERY_PARAM = "force";
5
8
  export declare const BETA_FORCE_SESSION_STORAGE_KEY = "agent-native:force-production";
6
9
  export declare const ENVIRONMENT_BETA_HOSTS: {
@@ -1,6 +1,9 @@
1
1
  export const BETA_OPT_OUT_QUERY_PARAM = "agentNativeBetaOptOut";
2
2
  export const BETA_OPT_OUT_DURATION_MS = 8 * 60 * 60 * 1000;
3
3
  export const BETA_OPT_OUT_STORAGE_KEY = "agent-native:beta-opt-out-until";
4
+ export const BETA_REDIRECT_DURATION_MS = 30 * 24 * 60 * 60 * 1000;
5
+ export const BETA_REDIRECT_STORAGE_KEY = "agent-native:beta-redirect-until";
6
+ export const BETA_REDIRECT_SIGN_OUT_STORAGE_KEY = "agent-native:beta-redirect-signing-out";
4
7
  export const BETA_FORCE_QUERY_PARAM = "force";
5
8
  export const BETA_FORCE_SESSION_STORAGE_KEY = "agent-native:force-production";
6
9
  export const ENVIRONMENT_BETA_HOSTS = {
@@ -7,7 +7,7 @@ export { truncate } from "./truncate.js";
7
7
  export { isHumanReadableDocumentTitle, normalizeDocumentTitle, } from "./document-title.js";
8
8
  export { injectDocumentMarkup } from "./html-document.js";
9
9
  export { withBuilderUtmTrackingParams } from "./builder-link-tracking.js";
10
- export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, resolveEnvironmentTargets, type EnvironmentBadgeTargets, } from "./environment-lanes.js";
10
+ export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_REDIRECT_DURATION_MS, BETA_REDIRECT_STORAGE_KEY, BETA_REDIRECT_SIGN_OUT_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, resolveEnvironmentTargets, type EnvironmentBadgeTargets, } from "./environment-lanes.js";
11
11
  export { SSR_HTML_CONTENT_TYPE, SSR_QUERY_CACHE_KEY_HEADER, type SsrHtmlContentTypeOptions, withSsrHtmlContentType, } from "./cache-control.js";
12
12
  export { SURFACE_HIDDEN_FLAG, SURFACE_VISIBILITY_EVENT, addSurfaceVisibilityListener, buildSurfaceVisibilityScript, isHostSurfaceHidden, isSurfaceHidden, } from "./surface-visibility.js";
13
13
  export { AGENT_NATIVE_DOCS_ORIGIN, docsUrl, type DocsUrlOptions, } from "./docs-url.js";
@@ -7,7 +7,7 @@ export { truncate } from "./truncate.js";
7
7
  export { isHumanReadableDocumentTitle, normalizeDocumentTitle, } from "./document-title.js";
8
8
  export { injectDocumentMarkup } from "./html-document.js";
9
9
  export { withBuilderUtmTrackingParams } from "./builder-link-tracking.js";
10
- export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, resolveEnvironmentTargets, } from "./environment-lanes.js";
10
+ export { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_REDIRECT_DURATION_MS, BETA_REDIRECT_STORAGE_KEY, BETA_REDIRECT_SIGN_OUT_STORAGE_KEY, BETA_OPT_OUT_DURATION_MS, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, resolveEnvironmentTargets, } from "./environment-lanes.js";
11
11
  export { SSR_HTML_CONTENT_TYPE, SSR_QUERY_CACHE_KEY_HEADER, withSsrHtmlContentType, } from "./cache-control.js";
12
12
  export { SURFACE_HIDDEN_FLAG, SURFACE_VISIBILITY_EVENT, addSurfaceVisibilityListener, buildSurfaceVisibilityScript, isHostSurfaceHidden, isSurfaceHidden, } from "./surface-visibility.js";
13
13
  export { AGENT_NATIVE_DOCS_ORIGIN, docsUrl, } from "./docs-url.js";
@@ -0,0 +1,8 @@
1
+ export declare const SSR_BETA_REDIRECT_MARKER = "data-agent-native-beta-redirect=\"1\"";
2
+ /**
3
+ * The marker is a performance hint set after the client verifies a Builder
4
+ * employee session. The browser re-checks the current session before using
5
+ * it, so it never becomes an authorization check.
6
+ */
7
+ export declare function getSsrBetaRedirectScriptBody(sessionPath?: string): string;
8
+ export declare function getSsrBetaRedirectScript(sessionPath?: string): string;
@@ -0,0 +1,215 @@
1
+ import { safeJsonForHtml } from "./agent-readable-resource.js";
2
+ import { BETA_FORCE_QUERY_PARAM, BETA_FORCE_SESSION_STORAGE_KEY, BETA_OPT_OUT_QUERY_PARAM, BETA_OPT_OUT_STORAGE_KEY, BETA_REDIRECT_STORAGE_KEY, BETA_REDIRECT_SIGN_OUT_STORAGE_KEY, ENVIRONMENT_BETA_HOSTS, } from "./environment-lanes.js";
3
+ export const SSR_BETA_REDIRECT_MARKER = 'data-agent-native-beta-redirect="1"';
4
+ /**
5
+ * The marker is a performance hint set after the client verifies a Builder
6
+ * employee session. The browser re-checks the current session before using
7
+ * it, so it never becomes an authorization check.
8
+ */
9
+ export function getSsrBetaRedirectScriptBody(sessionPath = "/_agent-native/auth/session") {
10
+ return `(function __anEarlyBetaRedirect() {
11
+ if (window.__agentNativeBetaRedirectStarted) return;
12
+ window.__agentNativeBetaRedirectStarted = true;
13
+ if (window.parent !== window) return;
14
+
15
+ var betaHosts = ${JSON.stringify(ENVIRONMENT_BETA_HOSTS)};
16
+ var hostname = (window.location.hostname || '').toLowerCase().replace(/\\.$/, '');
17
+ var productionHost = hostname.indexOf('beta.') === 0 ? hostname.slice(5) : hostname;
18
+ var betaHost = betaHosts[productionHost];
19
+ if (typeof betaHost !== 'string' || betaHost === hostname) return;
20
+
21
+ var currentUrl;
22
+ try {
23
+ currentUrl = new URL(window.location.href);
24
+ } catch (error) {
25
+ void error;
26
+ return;
27
+ }
28
+
29
+ if (currentUrl.searchParams.get(${JSON.stringify(BETA_FORCE_QUERY_PARAM)}) === 'true') {
30
+ try {
31
+ window.sessionStorage.setItem(${JSON.stringify(BETA_FORCE_SESSION_STORAGE_KEY)}, '1');
32
+ } catch (error) {
33
+ void error;
34
+ }
35
+ return;
36
+ }
37
+
38
+ try {
39
+ if (window.sessionStorage.getItem(${JSON.stringify(BETA_FORCE_SESSION_STORAGE_KEY)}) === '1') return;
40
+ } catch (error) {
41
+ void error;
42
+ }
43
+
44
+ if (/AgentNativeDesktop/i.test((window.navigator && window.navigator.userAgent) || '')) return;
45
+
46
+ var optOutValue = currentUrl.searchParams.get(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
47
+ if (optOutValue !== null) {
48
+ var optOutExpiry = Number(optOutValue);
49
+ if (Number.isFinite(optOutExpiry) && optOutExpiry > Date.now()) {
50
+ try {
51
+ window.localStorage.setItem(
52
+ ${JSON.stringify(BETA_OPT_OUT_STORAGE_KEY)},
53
+ String(optOutExpiry),
54
+ );
55
+ window.localStorage.removeItem(${JSON.stringify(BETA_REDIRECT_STORAGE_KEY)});
56
+ } catch (error) {
57
+ void error;
58
+ return;
59
+ }
60
+ currentUrl.searchParams.delete(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
61
+ try {
62
+ window.history.replaceState(null, '', currentUrl.toString());
63
+ } catch (error) {
64
+ void error;
65
+ }
66
+ return;
67
+ }
68
+
69
+ currentUrl.searchParams.delete(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
70
+ try {
71
+ window.history.replaceState(null, '', currentUrl.toString());
72
+ } catch (error) {
73
+ void error;
74
+ }
75
+ }
76
+
77
+ var storedOptOut;
78
+ var storedRedirect;
79
+ try {
80
+ storedOptOut = window.localStorage.getItem(${JSON.stringify(BETA_OPT_OUT_STORAGE_KEY)});
81
+ if (storedOptOut !== null) {
82
+ var storedOptOutExpiry = Number(storedOptOut);
83
+ if (Number.isFinite(storedOptOutExpiry) && storedOptOutExpiry > Date.now()) return;
84
+ window.localStorage.removeItem(${JSON.stringify(BETA_OPT_OUT_STORAGE_KEY)});
85
+ }
86
+ storedRedirect = window.localStorage.getItem(${JSON.stringify(BETA_REDIRECT_STORAGE_KEY)});
87
+ } catch (error) {
88
+ void error;
89
+ return;
90
+ }
91
+
92
+ var redirectExpiry = Number(storedRedirect);
93
+ function clearRedirectMarker() {
94
+ try {
95
+ window.localStorage.removeItem(${JSON.stringify(BETA_REDIRECT_STORAGE_KEY)});
96
+ } catch (error) {
97
+ void error;
98
+ }
99
+ }
100
+
101
+ function isSignOutStarted() {
102
+ if (window.__agentNativeBetaRedirectSignOutStarted === true) return true;
103
+ try {
104
+ return window.sessionStorage.getItem(${JSON.stringify(BETA_REDIRECT_SIGN_OUT_STORAGE_KEY)}) === '1';
105
+ } catch (error) {
106
+ void error;
107
+ return false;
108
+ }
109
+ }
110
+
111
+ if (!Number.isFinite(redirectExpiry) || redirectExpiry <= Date.now()) {
112
+ if (storedRedirect !== null) clearRedirectMarker();
113
+ return;
114
+ }
115
+
116
+ if (isSignOutStarted()) return;
117
+
118
+ if (typeof window.fetch !== 'function') return;
119
+
120
+ var sessionProbePath = ${safeJsonForHtml(sessionPath)};
121
+ var appConfig = window.__AGENT_NATIVE_CONFIG__;
122
+ if (appConfig && appConfig.workspaceRuntime === true) {
123
+ var frameworkSessionPath = '/_agent-native/auth/session';
124
+ var mountSegment = currentUrl.pathname.split('/').find(function (segment) {
125
+ return segment;
126
+ });
127
+ var workspaceMount = mountSegment &&
128
+ mountSegment !== '_agent-native' &&
129
+ mountSegment !== 'api' &&
130
+ mountSegment !== 'sign-in' &&
131
+ mountSegment !== 'login' &&
132
+ mountSegment !== 'signup'
133
+ ? '/' + mountSegment
134
+ : '';
135
+ var knownWorkspaceMounts = Array.isArray(appConfig.workspaceAppMountPaths)
136
+ ? appConfig.workspaceAppMountPaths
137
+ : null;
138
+ var knownWorkspaceMount = !knownWorkspaceMounts ||
139
+ knownWorkspaceMounts.indexOf(workspaceMount) !== -1;
140
+ if (
141
+ workspaceMount &&
142
+ knownWorkspaceMount &&
143
+ typeof sessionProbePath === 'string' &&
144
+ sessionProbePath.endsWith(frameworkSessionPath)
145
+ ) {
146
+ var configuredWorkspaceMount = sessionProbePath.slice(
147
+ 0,
148
+ -frameworkSessionPath.length,
149
+ );
150
+ if (configuredWorkspaceMount !== workspaceMount) {
151
+ sessionProbePath = workspaceMount + frameworkSessionPath;
152
+ }
153
+ }
154
+ }
155
+
156
+ window.fetch(sessionProbePath, {
157
+ credentials: 'same-origin',
158
+ cache: 'no-store',
159
+ headers: { 'Accept': 'application/json' }
160
+ }).then(function (response) {
161
+ if (!response || !response.ok) {
162
+ if (response && (response.status === 401 || response.status === 403)) {
163
+ clearRedirectMarker();
164
+ return null;
165
+ }
166
+ return undefined;
167
+ }
168
+ return response.json();
169
+ }).then(function (session) {
170
+ if (session === undefined) return;
171
+ var email = session && !session.error && typeof session.email === 'string'
172
+ ? session.email.trim().toLowerCase()
173
+ : '';
174
+ if (!email.endsWith('@builder.io')) {
175
+ clearRedirectMarker();
176
+ return;
177
+ }
178
+
179
+ if (isSignOutStarted()) return;
180
+
181
+ var latestUrl;
182
+ try {
183
+ latestUrl = new URL(window.location.href);
184
+ } catch (error) {
185
+ void error;
186
+ return;
187
+ }
188
+ var latestHostname = (latestUrl.hostname || '').toLowerCase().replace(/\\.$/, '');
189
+ var latestProductionHost = latestHostname.indexOf('beta.') === 0
190
+ ? latestHostname.slice(5)
191
+ : latestHostname;
192
+ if (latestHostname !== hostname || betaHosts[latestProductionHost] !== betaHost) return;
193
+ if (latestUrl.searchParams.get(${JSON.stringify(BETA_FORCE_QUERY_PARAM)}) === 'true') return;
194
+ var latestOptOut = latestUrl.searchParams.get(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
195
+ if (latestOptOut !== null && Number(latestOptOut) > Date.now()) return;
196
+
197
+ latestUrl.protocol = 'https:';
198
+ latestUrl.hostname = betaHost;
199
+ latestUrl.port = '';
200
+ latestUrl.searchParams.delete(${JSON.stringify(BETA_OPT_OUT_QUERY_PARAM)});
201
+ try {
202
+ window.location.replace(latestUrl.toString());
203
+ } catch (error) {
204
+ void error;
205
+ }
206
+ }).catch(function (error) {
207
+ void error;
208
+ // A transient session failure must leave production usable; retry the hint
209
+ // on a later navigation instead of redirecting without a current session.
210
+ });
211
+ })();`;
212
+ }
213
+ export function getSsrBetaRedirectScript(sessionPath = "/_agent-native/auth/session") {
214
+ return `<script ${SSR_BETA_REDIRECT_MARKER}>${getSsrBetaRedirectScriptBody(sessionPath)}</script>`;
215
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.176.4-nightly-20260902022549",
3
+ "version": "0.176.4-nightly-20260902024948",
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": {