@agent-native/core 0.15.0 → 0.15.2

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.
@@ -8,7 +8,7 @@ function normalizeDefaultTheme(theme) {
8
8
  export function getThemeInitScript(defaultTheme = "system", enableSystem = true) {
9
9
  const safeDefaultTheme = normalizeDefaultTheme(defaultTheme);
10
10
  const systemEnabled = enableSystem ? "true" : "false";
11
- const themeScript = `(function(){try{var defaultTheme=${JSON.stringify(safeDefaultTheme)};var enableSystem=${systemEnabled};var stored=window.localStorage.getItem('theme');var valid=stored==='light'||stored==='dark'||stored==='system'||stored==='auto';var mode=valid?stored:defaultTheme;if(mode==='auto')mode='system';if(!enableSystem&&mode==='system')mode=defaultTheme==='system'?'light':defaultTheme;if(!valid){window.localStorage.removeItem('theme')}else if(stored!==mode){window.localStorage.setItem('theme',mode)}var prefersDark=enableSystem&&mode==='system'&&window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches;var resolved=mode==='system'?(prefersDark?'dark':'light'):mode;var root=document.documentElement;root.classList.remove('light','dark');root.classList.add(resolved);if(mode==='system'){root.removeAttribute('data-theme')}else{root.setAttribute('data-theme',mode)}root.style.colorScheme=resolved;var appearance=window.localStorage.getItem('appearance');var appearanceValid=appearance==='warm'||appearance==='ocean'||appearance==='forest'||appearance==='rose'||appearance==='slate';if(appearanceValid){root.setAttribute('data-appearance',appearance)}else{root.removeAttribute('data-appearance');if(appearance!==null)window.localStorage.removeItem('appearance')}}catch(e){}})();`;
11
+ const themeScript = `(function(){try{var defaultTheme=${JSON.stringify(safeDefaultTheme)};var enableSystem=${systemEnabled};var stored=window.localStorage.getItem('theme');var valid=stored==='light'||stored==='dark'||stored==='system'||stored==='auto';var mode=valid?stored:defaultTheme;if(mode==='auto')mode='system';if(!enableSystem&&mode==='system')mode=defaultTheme==='system'?'light':defaultTheme;if(!valid){window.localStorage.removeItem('theme')}else if(stored!==mode){window.localStorage.setItem('theme',mode)}var prefersDark=enableSystem&&mode==='system'&&window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches;var resolved=mode==='system'?(prefersDark?'dark':'light'):mode;var root=document.documentElement;root.classList.remove('light','dark');root.classList.add(resolved);root.setAttribute('data-theme',resolved);root.style.colorScheme=resolved;var appearance=window.localStorage.getItem('appearance');var appearanceValid=appearance==='warm'||appearance==='ocean'||appearance==='forest'||appearance==='rose'||appearance==='slate';if(appearanceValid){root.setAttribute('data-appearance',appearance)}else{root.removeAttribute('data-appearance');if(appearance!==null)window.localStorage.removeItem('appearance')}}catch(e){}})();`;
12
12
  if (!shouldInlineViteDevRecoveryScript())
13
13
  return themeScript;
14
14
  return `${themeScript}\n${getViteDevRecoveryScript()}`;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/client/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AAIvC,SAAS,qBAAqB,CAAC,KAAsB;IACnD,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,eAAgC,QAAQ,EACxC,YAAY,GAAG,IAAI;IAEnB,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAEtD,MAAM,WAAW,GAAG,oCAAoC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,qBAAqB,aAAa,0qCAA0qC,CAAC;IACryC,IAAI,CAAC,iCAAiC,EAAE;QAAE,OAAO,WAAW,CAAC;IAC7D,OAAO,GAAG,WAAW,KAAK,wBAAwB,EAAE,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC","sourcesContent":["import {\n getViteDevRecoveryScript,\n shouldInlineViteDevRecoveryScript,\n} from \"./vite-dev-recovery-script.js\";\n\nexport type ThemePreference = \"light\" | \"dark\" | \"system\";\n\nfunction normalizeDefaultTheme(theme: ThemePreference): ThemePreference {\n if (theme === \"light\" || theme === \"dark\" || theme === \"system\") {\n return theme;\n }\n return \"system\";\n}\n\nexport function getThemeInitScript(\n defaultTheme: ThemePreference = \"system\",\n enableSystem = true,\n) {\n const safeDefaultTheme = normalizeDefaultTheme(defaultTheme);\n const systemEnabled = enableSystem ? \"true\" : \"false\";\n\n const themeScript = `(function(){try{var defaultTheme=${JSON.stringify(safeDefaultTheme)};var enableSystem=${systemEnabled};var stored=window.localStorage.getItem('theme');var valid=stored==='light'||stored==='dark'||stored==='system'||stored==='auto';var mode=valid?stored:defaultTheme;if(mode==='auto')mode='system';if(!enableSystem&&mode==='system')mode=defaultTheme==='system'?'light':defaultTheme;if(!valid){window.localStorage.removeItem('theme')}else if(stored!==mode){window.localStorage.setItem('theme',mode)}var prefersDark=enableSystem&&mode==='system'&&window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches;var resolved=mode==='system'?(prefersDark?'dark':'light'):mode;var root=document.documentElement;root.classList.remove('light','dark');root.classList.add(resolved);if(mode==='system'){root.removeAttribute('data-theme')}else{root.setAttribute('data-theme',mode)}root.style.colorScheme=resolved;var appearance=window.localStorage.getItem('appearance');var appearanceValid=appearance==='warm'||appearance==='ocean'||appearance==='forest'||appearance==='rose'||appearance==='slate';if(appearanceValid){root.setAttribute('data-appearance',appearance)}else{root.removeAttribute('data-appearance');if(appearance!==null)window.localStorage.removeItem('appearance')}}catch(e){}})();`;\n if (!shouldInlineViteDevRecoveryScript()) return themeScript;\n return `${themeScript}\\n${getViteDevRecoveryScript()}`;\n}\n\nexport const themeInitScript = getThemeInitScript();\n"]}
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/client/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AAIvC,SAAS,qBAAqB,CAAC,KAAsB;IACnD,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,eAAgC,QAAQ,EACxC,YAAY,GAAG,IAAI;IAEnB,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAEtD,MAAM,WAAW,GAAG,oCAAoC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,qBAAqB,aAAa,knCAAknC,CAAC;IAC7uC,IAAI,CAAC,iCAAiC,EAAE;QAAE,OAAO,WAAW,CAAC;IAC7D,OAAO,GAAG,WAAW,KAAK,wBAAwB,EAAE,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC","sourcesContent":["import {\n getViteDevRecoveryScript,\n shouldInlineViteDevRecoveryScript,\n} from \"./vite-dev-recovery-script.js\";\n\nexport type ThemePreference = \"light\" | \"dark\" | \"system\";\n\nfunction normalizeDefaultTheme(theme: ThemePreference): ThemePreference {\n if (theme === \"light\" || theme === \"dark\" || theme === \"system\") {\n return theme;\n }\n return \"system\";\n}\n\nexport function getThemeInitScript(\n defaultTheme: ThemePreference = \"system\",\n enableSystem = true,\n) {\n const safeDefaultTheme = normalizeDefaultTheme(defaultTheme);\n const systemEnabled = enableSystem ? \"true\" : \"false\";\n\n const themeScript = `(function(){try{var defaultTheme=${JSON.stringify(safeDefaultTheme)};var enableSystem=${systemEnabled};var stored=window.localStorage.getItem('theme');var valid=stored==='light'||stored==='dark'||stored==='system'||stored==='auto';var mode=valid?stored:defaultTheme;if(mode==='auto')mode='system';if(!enableSystem&&mode==='system')mode=defaultTheme==='system'?'light':defaultTheme;if(!valid){window.localStorage.removeItem('theme')}else if(stored!==mode){window.localStorage.setItem('theme',mode)}var prefersDark=enableSystem&&mode==='system'&&window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches;var resolved=mode==='system'?(prefersDark?'dark':'light'):mode;var root=document.documentElement;root.classList.remove('light','dark');root.classList.add(resolved);root.setAttribute('data-theme',resolved);root.style.colorScheme=resolved;var appearance=window.localStorage.getItem('appearance');var appearanceValid=appearance==='warm'||appearance==='ocean'||appearance==='forest'||appearance==='rose'||appearance==='slate';if(appearanceValid){root.setAttribute('data-appearance',appearance)}else{root.removeAttribute('data-appearance');if(appearance!==null)window.localStorage.removeItem('appearance')}}catch(e){}})();`;\n if (!shouldInlineViteDevRecoveryScript()) return themeScript;\n return `${themeScript}\\n${getViteDevRecoveryScript()}`;\n}\n\nexport const themeInitScript = getThemeInitScript();\n"]}
@@ -123,11 +123,10 @@ export interface AuthOptions {
123
123
  /**
124
124
  * Google sign-in flow: `'popup'`, `'redirect'`, or `'auto'` (default).
125
125
  *
126
- * - `'auto'` — popup in normal browsers, redirect in Electron. Always uses
127
- * popup inside the Builder.io browser iframe (Google blocks framing).
126
+ * - `'auto'` — popup in normal browsers, redirect in Electron and Builder.io
127
+ * preview/editor surfaces.
128
128
  * - `'popup'` — force popup everywhere.
129
- * - `'redirect'` — force redirect everywhere except the Builder.io browser
130
- * iframe, which stays popup for technical reasons.
129
+ * - `'redirect'` — force redirect everywhere.
131
130
  *
132
131
  * Falls back to the `GOOGLE_AUTH_MODE` env var, then `'auto'`.
133
132
  */
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/server/auth.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE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AAM,GAAG,IAAI,CAAC,CAmB3E;AAsED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAmBD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,QAWd;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,2BAA2B,QAOnC;AAmGD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAG5C;AAsbD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAqE5E;AA0CD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAS7E;AAu2CD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,KAAK,EACV,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,OAAO,CAAC,CAmMlB;AAMD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAEzE"}
@@ -1693,10 +1693,6 @@ async function mountBetterAuthRoutes(app, options) {
1693
1693
  try {
1694
1694
  const query = getQuery(event);
1695
1695
  const code = query.code;
1696
- if (!code) {
1697
- setResponseStatus(event, 400);
1698
- return { error: "Missing authorization code" };
1699
- }
1700
1696
  const { redirectUri, desktop, returnUrl, flowId } = decodeOAuthState(query.state, getAppUrl(event, "/_agent-native/google/callback"));
1701
1697
  callbackFlowId = flowId;
1702
1698
  callbackDesktop = desktop;
@@ -1707,14 +1703,50 @@ async function mountBetterAuthRoutes(app, options) {
1707
1703
  hasCode: !!code,
1708
1704
  returnUrl,
1709
1705
  });
1706
+ if (!code) {
1707
+ const providerError = typeof query.error === "string" && query.error
1708
+ ? query.error
1709
+ : undefined;
1710
+ const providerDescription = typeof query.error_description === "string" &&
1711
+ query.error_description
1712
+ ? query.error_description
1713
+ : undefined;
1714
+ const msg = providerDescription ||
1715
+ providerError ||
1716
+ "Missing authorization code";
1717
+ if (flowId) {
1718
+ setDesktopExchangeError(flowId, {
1719
+ message: `Google sign-in failed: ${msg}`,
1720
+ code: providerError || "missing_authorization_code",
1721
+ });
1722
+ }
1723
+ logGoogleOAuthDebug(event, "callback-error", {
1724
+ flowId,
1725
+ desktop,
1726
+ message: msg,
1727
+ code: providerError,
1728
+ });
1729
+ return oauthErrorPage(`Connection failed: ${msg}`);
1730
+ }
1710
1731
  // Defence in depth: the state is HMAC-signed, but if the signing
1711
1732
  // key ever leaked an attacker could mint state with their own
1712
1733
  // redirect_uri. Re-validate against the same allowlist used at
1713
1734
  // auth-url time so the token exchange is always sent to a URI we
1714
1735
  // own.
1715
1736
  if (!isAllowedOAuthRedirectUri(redirectUri, event)) {
1716
- setResponseStatus(event, 400);
1717
- return { error: "Invalid redirect_uri in state" };
1737
+ const msg = "Invalid Google OAuth redirect URI in state. Restart sign-in from this app.";
1738
+ if (flowId) {
1739
+ setDesktopExchangeError(flowId, {
1740
+ message: msg,
1741
+ code: "invalid_redirect_uri",
1742
+ });
1743
+ }
1744
+ logGoogleOAuthDebug(event, "callback-error", {
1745
+ flowId,
1746
+ desktop,
1747
+ message: msg,
1748
+ });
1749
+ return oauthErrorPage(`Connection failed: ${msg}`);
1718
1750
  }
1719
1751
  const tokenRes = await fetch("https://oauth2.googleapis.com/token", {
1720
1752
  method: "POST",
@@ -1785,6 +1817,12 @@ async function mountBetterAuthRoutes(app, options) {
1785
1817
  }
1786
1818
  catch (error) {
1787
1819
  const msg = error.message || "Unknown error";
1820
+ if (callbackFlowId) {
1821
+ setDesktopExchangeError(callbackFlowId, {
1822
+ message: `Google sign-in failed: ${msg}`,
1823
+ code: "callback_error",
1824
+ });
1825
+ }
1788
1826
  logGoogleOAuthDebug(event, "callback-error", {
1789
1827
  flowId: callbackFlowId,
1790
1828
  desktop: callbackDesktop,