@agent-native/core 0.232.0 → 0.233.0-nightly-20261124004026
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/dist/a2a/handlers.js +60 -1
- package/dist/a2a/server.js +9 -0
- package/dist/action-call-classification.d.ts +9 -0
- package/dist/action-call-classification.js +18 -0
- package/dist/action-conformance.d.ts +81 -0
- package/dist/action-conformance.js +392 -0
- package/dist/action.d.ts +18 -0
- package/dist/action.js +68 -5
- package/dist/agent/execution-fence.d.ts +3 -1
- package/dist/agent/execution-fence.js +13 -2
- package/dist/agent/production-agent.d.ts +3 -0
- package/dist/agent/production-agent.js +301 -145
- package/dist/agent/run-store.js +11 -0
- package/dist/agent/thread-data-builder.d.ts +2 -0
- package/dist/agent/thread-data-builder.js +5 -1
- package/dist/app-config/schema.d.ts +24 -1
- package/dist/application-state/handlers.d.ts +1 -1
- package/dist/application-state/navigate-write-guard.d.ts +4 -1
- package/dist/application-state/navigate-write-guard.js +15 -1
- package/dist/cli/design-connect.js +5 -1
- package/dist/cli/matched-check.d.ts +1 -0
- package/dist/cli/matched-check.js +76 -0
- package/dist/client/agent-chat/index.d.ts +1 -1
- package/dist/client/agent-chat/index.js +1 -1
- package/dist/client/analytics/index.d.ts +1 -1
- package/dist/client/analytics.d.ts +13 -1
- package/dist/client/analytics.js +5 -2
- package/dist/client/application-state.d.ts +11 -0
- package/dist/client/application-state.js +219 -23
- package/dist/client/chat/agentkit-agent-native.js +52 -11
- package/dist/client/chat/agentkit-protocol.js +23 -2
- package/dist/client/chat-first-state.d.ts +6 -0
- package/dist/client/chat-first-state.js +36 -1
- package/dist/client/feature-flags/use-feature-flag.js +14 -6
- package/dist/client/navigation/index.d.ts +2 -0
- package/dist/client/navigation/index.js +2 -0
- package/dist/client/route-state.js +60 -18
- package/dist/client/screen-settled.d.ts +71 -1
- package/dist/client/screen-settled.js +221 -3
- package/dist/client/sse-event-processor.d.ts +1 -0
- package/dist/client/sse-event-processor.js +89 -10
- package/dist/client/theme.d.ts +6 -0
- package/dist/client/theme.js +7 -1
- package/dist/client/use-action.js +32 -10
- package/dist/client/use-session.js +36 -18
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.js +2 -2
- package/dist/db/errors.d.ts +2 -0
- package/dist/db/errors.js +38 -6
- package/dist/feature-flags/actions/get-feature-flags.js +9 -2
- package/dist/file-upload/actions/upload-image.d.ts +2 -2
- package/dist/framework-package-versions.json +8 -8
- package/dist/ingestion/index.d.ts +1 -0
- package/dist/ingestion/index.js +1 -0
- package/dist/ingestion/matched-capture.d.ts +173 -0
- package/dist/ingestion/matched-capture.js +574 -0
- package/dist/ingestion/pptx.d.ts +1 -0
- package/dist/ingestion/pptx.js +4 -2
- package/dist/labs/store.d.ts +3 -1
- package/dist/labs/store.js +8 -4
- package/dist/manifest/index.d.ts +142 -3
- package/dist/manifest/index.js +249 -19
- package/dist/mcp/build-server.d.ts +2 -0
- package/dist/mcp/build-server.js +8 -1
- package/dist/mcp/server.js +3 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/metrics.d.ts +2 -0
- package/dist/observability/metrics.js +7 -0
- package/dist/org/index.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +10 -10
- package/dist/provider-api/actions/provider-api.d.ts +14 -14
- package/dist/server/action-routes.js +9 -0
- package/dist/server/agent-chat/prompt-resources.js +107 -83
- package/dist/server/agent-run-context.d.ts +3 -0
- package/dist/server/agent-run-context.js +7 -0
- package/dist/server/builder-oauth.d.ts +1 -0
- package/dist/server/builder-oauth.js +40 -2
- package/dist/server/filesystem-action-entry.js +5 -0
- package/dist/server/first-touch-route.d.ts +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/open-route.js +10 -4
- package/dist/server/poll.d.ts +3 -0
- package/dist/server/poll.js +74 -14
- package/dist/server/request-context.d.ts +16 -6
- package/dist/server/request-context.js +4 -0
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/shared/analytics-events.d.ts +7 -0
- package/dist/shared/viewport-mode.d.ts +2 -0
- package/dist/shared/viewport-mode.js +9 -0
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +1 -0
- package/dist/templates/chat/.agents/skills/build-an-app/SKILL.md +38 -17
- package/dist/templates/chat/.agents/skills/shadcn-ui/SKILL.md +3 -2
- package/dist/templates/default/.agents/skills/actions/SKILL.md +1 -0
- package/dist/templates/default/.agents/skills/build-an-app/SKILL.md +38 -17
- package/dist/templates/default/.agents/skills/shadcn-ui/SKILL.md +3 -2
- package/dist/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +3 -2
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +1 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +1 -0
- package/dist/templates/workspace-core/.agents/skills/build-an-app/SKILL.md +38 -17
- package/dist/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +3 -2
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +1 -0
- package/dist/tracking/action-lifecycle.d.ts +2 -0
- package/dist/tracking/action-lifecycle.js +16 -5
- package/docs/content/actions-defining.mdx +7 -0
- package/docs/content/custom-design-system.mdx +4 -2
- package/package.json +3 -3
- package/src/templates/chat/.agents/skills/actions/SKILL.md +1 -0
- package/src/templates/chat/.agents/skills/build-an-app/SKILL.md +38 -17
- package/src/templates/chat/.agents/skills/shadcn-ui/SKILL.md +3 -2
- package/src/templates/default/.agents/skills/actions/SKILL.md +1 -0
- package/src/templates/default/.agents/skills/build-an-app/SKILL.md +38 -17
- package/src/templates/default/.agents/skills/shadcn-ui/SKILL.md +3 -2
- package/src/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +3 -2
- package/src/templates/headless/.agents/skills/actions/SKILL.md +1 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +1 -0
- package/src/templates/workspace-core/.agents/skills/build-an-app/SKILL.md +38 -17
- package/src/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +3 -2
package/dist/client/theme.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export type ThemePreference = "light" | "dark" | "system";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function themeStorageKeyForApp(appId?: string | null): string;
|
|
7
7
|
export type ResolvedTheme = "light" | "dark";
|
|
8
|
+
/**
|
|
9
|
+
* The early head script names, on the root element, the storage key it read
|
|
10
|
+
* the preference from. The server renders that script without the compiled app
|
|
11
|
+
* id, so the key can differ from the one the browser bundle would derive.
|
|
12
|
+
*/
|
|
13
|
+
export declare const THEME_STORAGE_KEY_ATTRIBUTE = "data-theme-storage-key";
|
|
8
14
|
export declare const EMBEDDED_THEME_UPDATE_MESSAGE = "agent-native-theme-update";
|
|
9
15
|
export declare const EMBEDDED_THEME_CHANGE_EVENT = "agent-native:theme-change";
|
|
10
16
|
export interface EmbeddedThemeUpdate {
|
package/dist/client/theme.js
CHANGED
|
@@ -10,6 +10,12 @@ export function themeStorageKeyForApp(appId) {
|
|
|
10
10
|
const normalizedAppId = appId?.trim().toLowerCase();
|
|
11
11
|
return normalizedAppId ? `${normalizedAppId}:theme` : "theme";
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* The early head script names, on the root element, the storage key it read
|
|
15
|
+
* the preference from. The server renders that script without the compiled app
|
|
16
|
+
* id, so the key can differ from the one the browser bundle would derive.
|
|
17
|
+
*/
|
|
18
|
+
export const THEME_STORAGE_KEY_ATTRIBUTE = "data-theme-storage-key";
|
|
13
19
|
export const EMBEDDED_THEME_UPDATE_MESSAGE = "agent-native-theme-update";
|
|
14
20
|
export const EMBEDDED_THEME_CHANGE_EVENT = "agent-native:theme-change";
|
|
15
21
|
function isRecord(value) {
|
|
@@ -80,7 +86,7 @@ export function getThemeInitScript(defaultTheme = "system", enableSystem = true,
|
|
|
80
86
|
(resolvedStorageKey === "theme" ? null : "theme");
|
|
81
87
|
const storageKey = JSON.stringify(resolvedStorageKey);
|
|
82
88
|
const legacyStorageKey = JSON.stringify(resolvedLegacyStorageKey);
|
|
83
|
-
const themeScript = `${getThemeFamilyInitScript(themeFamilyAppId, themeFamilyConfig)}\n(function(){function m(){var d={};return{get length(){return Object.keys(d).length},key:function(i){return Object.keys(d)[i]||null},getItem:function(k){k=String(k);return Object.prototype.hasOwnProperty.call(d,k)?d[k]:null},setItem:function(k,v){d[String(k)]=String(v)},removeItem:function(k){delete d[k]},clear:function(){d={}}}}function s(n){try{var x=window[n],p='__an_storage_probe__';x.setItem(p,'1');x.removeItem(p)}catch(e){try{Object.defineProperty(window,n,{configurable:true,value:m()})}catch(_){}}}s('localStorage');s('sessionStorage');try{var defaultTheme=${JSON.stringify(safeDefaultTheme)};var enableSystem=${systemEnabled};var key=${storageKey},legacyKey=${legacyStorageKey};var stored=window.localStorage.getItem(key);var validStored=stored==='light'||stored==='dark'||stored==='system'||stored==='auto';if(legacyKey&&legacyKey!==key){var legacy=window.localStorage.getItem(legacyKey);if(legacy==='light'||legacy==='dark'||legacy==='system'||legacy==='auto'){stored=legacy;validStored=true}}var mode=validStored?stored:defaultTheme;if(mode==='auto')mode='system';if(!enableSystem&&mode==='system')mode=defaultTheme==='system'?'light':defaultTheme;if(!validStored){window.localStorage.removeItem(key)}else if(window.localStorage.getItem(key)!==mode){window.localStorage.setItem(key,mode)}if(legacyKey&&legacyKey!==key){window.localStorage.removeItem(legacyKey)}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){document.documentElement.setAttribute('data-theme-status','unreadable')}})();`;
|
|
89
|
+
const themeScript = `${getThemeFamilyInitScript(themeFamilyAppId, themeFamilyConfig)}\n(function(){function m(){var d={};return{get length(){return Object.keys(d).length},key:function(i){return Object.keys(d)[i]||null},getItem:function(k){k=String(k);return Object.prototype.hasOwnProperty.call(d,k)?d[k]:null},setItem:function(k,v){d[String(k)]=String(v)},removeItem:function(k){delete d[k]},clear:function(){d={}}}}function s(n){try{var x=window[n],p='__an_storage_probe__';x.setItem(p,'1');x.removeItem(p)}catch(e){try{Object.defineProperty(window,n,{configurable:true,value:m()})}catch(_){}}}s('localStorage');s('sessionStorage');try{var defaultTheme=${JSON.stringify(safeDefaultTheme)};var enableSystem=${systemEnabled};var key=${storageKey},legacyKey=${legacyStorageKey};var stored=window.localStorage.getItem(key);var validStored=stored==='light'||stored==='dark'||stored==='system'||stored==='auto';if(legacyKey&&legacyKey!==key){var legacy=window.localStorage.getItem(legacyKey);if(legacy==='light'||legacy==='dark'||legacy==='system'||legacy==='auto'){stored=legacy;validStored=true}}var mode=validStored?stored:defaultTheme;if(mode==='auto')mode='system';if(!enableSystem&&mode==='system')mode=defaultTheme==='system'?'light':defaultTheme;if(!validStored){window.localStorage.removeItem(key)}else if(window.localStorage.getItem(key)!==mode){window.localStorage.setItem(key,mode)}if(legacyKey&&legacyKey!==key){window.localStorage.removeItem(legacyKey)}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.setAttribute('data-theme-storage-key',key);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){document.documentElement.setAttribute('data-theme-status','unreadable')}})();`;
|
|
84
90
|
// Keep this a direct `import.meta.env?.DEV` read (no alias): only then can the
|
|
85
91
|
// bundler fold it and drop the dev recovery script from production client
|
|
86
92
|
// bundles. `env` is optional because the production SSR build loads core
|
|
@@ -157,13 +157,6 @@ const UI_CAPABILITY_MINT_TIMEOUT_MS = 10_000;
|
|
|
157
157
|
let uiCapabilityRequest;
|
|
158
158
|
let uiCapabilityRequestIdentity;
|
|
159
159
|
let abortUiCapabilityRequest;
|
|
160
|
-
/** A caller asked to share a mint another identity's session is waiting on. */
|
|
161
|
-
class UiCapabilityIdentityError extends Error {
|
|
162
|
-
constructor() {
|
|
163
|
-
super("A UI capability for a different user is still being established; retry once it settles.");
|
|
164
|
-
this.name = "UiCapabilityIdentityError";
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
160
|
// The capability is the Set-Cookie header, so the mint is answered by its
|
|
168
161
|
// status. Its body must still be read, or the request stays open and the page
|
|
169
162
|
// never reaches network idle, and a cancelled body is reported as an aborted
|
|
@@ -261,6 +254,27 @@ function abandonUiCapabilityMint() {
|
|
|
261
254
|
abortUiCapabilityRequest = undefined;
|
|
262
255
|
uiCapabilityRequest = undefined;
|
|
263
256
|
}
|
|
257
|
+
class UiCapabilityIdentityError extends Error {
|
|
258
|
+
constructor() {
|
|
259
|
+
super("The signed-in session changed while waiting for the UI capability.");
|
|
260
|
+
this.name = "UiCapabilityIdentityError";
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function waitForUiCapabilityMint(request, signal) {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
const onAbort = () => {
|
|
266
|
+
signal?.removeEventListener("abort", onAbort);
|
|
267
|
+
reject(signal?.reason);
|
|
268
|
+
};
|
|
269
|
+
if (signal?.aborted)
|
|
270
|
+
return reject(signal.reason);
|
|
271
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
272
|
+
void request
|
|
273
|
+
.then(() => undefined, () => undefined)
|
|
274
|
+
.then(resolve)
|
|
275
|
+
.finally(() => signal?.removeEventListener("abort", onAbort));
|
|
276
|
+
});
|
|
277
|
+
}
|
|
264
278
|
// The mint is shared by concurrent callers, so one caller's abort rejects only
|
|
265
279
|
// its own wait and never cancels the request the others are waiting on.
|
|
266
280
|
function ensureUiActionCapability(signal) {
|
|
@@ -270,7 +284,13 @@ function ensureUiActionCapability(signal) {
|
|
|
270
284
|
// A pending mint was sent with the cookies of the session that started it.
|
|
271
285
|
// Another identity waiting on it would act under that session's capability.
|
|
272
286
|
if (uiCapabilityRequest && uiCapabilityRequestIdentity !== identity) {
|
|
273
|
-
|
|
287
|
+
const scope = currentSessionScope();
|
|
288
|
+
return waitForUiCapabilityMint(uiCapabilityRequest, signal).then(() => {
|
|
289
|
+
if (currentSessionScope() !== scope) {
|
|
290
|
+
throw new UiCapabilityIdentityError();
|
|
291
|
+
}
|
|
292
|
+
return ensureUiActionCapability(signal);
|
|
293
|
+
});
|
|
274
294
|
}
|
|
275
295
|
if (!uiCapabilityRequest) {
|
|
276
296
|
uiCapabilityRequestIdentity = identity;
|
|
@@ -379,6 +399,7 @@ onSessionIdentityPublished((scope) => {
|
|
|
379
399
|
*/
|
|
380
400
|
function presentUiCapability(method, options, signal) {
|
|
381
401
|
const identity = currentSessionIdentity();
|
|
402
|
+
const scope = currentSessionScope();
|
|
382
403
|
const headers = new Headers(options?.headers);
|
|
383
404
|
const interactiveRead = method === "GET" && headers.get("x-agent-native-interactive") === "1";
|
|
384
405
|
let pending;
|
|
@@ -396,14 +417,15 @@ function presentUiCapability(method, options, signal) {
|
|
|
396
417
|
}
|
|
397
418
|
else {
|
|
398
419
|
pending = ensureUiActionCapability(signal).catch((error) => {
|
|
399
|
-
if (signal?.aborted
|
|
420
|
+
if (signal?.aborted)
|
|
400
421
|
throw error;
|
|
401
422
|
});
|
|
402
423
|
}
|
|
403
424
|
// The request leaves only after the mint, using the browser’s current
|
|
404
425
|
// cookies. Never send it under an identity that changed while waiting.
|
|
405
426
|
return pending.then(() => {
|
|
406
|
-
if (currentSessionIdentity() !== identity
|
|
427
|
+
if (currentSessionIdentity() !== identity ||
|
|
428
|
+
currentSessionScope() !== scope) {
|
|
407
429
|
throw new Error("The signed-in user changed before this action was sent.");
|
|
408
430
|
}
|
|
409
431
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
2
2
|
import { navigateForSession as navigateForSessionOnce, readSessionInvalidationMarker, SESSION_BOOTSTRAP_INVALIDATION_GLOBAL, SESSION_INVALIDATION_STORAGE_KEY, } from "../shared/ssr-session-bootstrap.js";
|
|
3
|
-
import { setSentryUser, trackEvent, trackSessionStatus } from "./analytics.js";
|
|
3
|
+
import { setSentryUser, trackEvent, trackSessionStatus, } from "./analytics.js";
|
|
4
4
|
import { agentNativeApiDisabledReason } from "./api-surface.js";
|
|
5
5
|
import { expireClientStatusResult, fetchAuthSessionStatus, invalidateClientStatusRequest, SESSION_RESULT_LIFETIME_MS, statusResultAnsweredAt, } from "./client-status-requests.js";
|
|
6
6
|
import { FETCH_TRANSPORT_CHANGED_EVENT, fetchTransport, } from "./fetch-transport.js";
|
|
@@ -58,6 +58,9 @@ let sessionRequest;
|
|
|
58
58
|
let sessionRequestTransport;
|
|
59
59
|
let trackedSessionIdentity;
|
|
60
60
|
let trackedSessionAuthUserId;
|
|
61
|
+
let sessionReadTrigger = "load";
|
|
62
|
+
let sessionReadTriggerReported = false;
|
|
63
|
+
let sessionAnswerReported = false;
|
|
61
64
|
// The page load's own session read is the only one sent with the cookies a
|
|
62
65
|
// request made before the session was known also carried. A retry or a reset
|
|
63
66
|
// replaces it for the life of the document.
|
|
@@ -127,7 +130,7 @@ function hasFreshSessionCache() {
|
|
|
127
130
|
return (cachedSession !== undefined &&
|
|
128
131
|
Date.now() - cachedSessionAt < SESSION_CACHE_TTL_MS);
|
|
129
132
|
}
|
|
130
|
-
function publishSessionIdentity(session) {
|
|
133
|
+
function publishSessionIdentity(session, trigger) {
|
|
131
134
|
const identity = session?.userId ?? session?.email ?? null;
|
|
132
135
|
const authUserId = session?.authUserId;
|
|
133
136
|
recordSessionIdentity(identity, session?.orgId ?? null, session?.authUserId ?? session?.userId, session?.email);
|
|
@@ -151,7 +154,7 @@ function publishSessionIdentity(session) {
|
|
|
151
154
|
setSentryUser(null, null);
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
|
-
trackSessionStatus(Boolean(session));
|
|
157
|
+
trackSessionStatus(Boolean(session), trigger);
|
|
155
158
|
}
|
|
156
159
|
function notifyParentAuthState(status) {
|
|
157
160
|
if (typeof window === "undefined" || window.parent === window)
|
|
@@ -226,7 +229,16 @@ function notifySessionSubscribers() {
|
|
|
226
229
|
}
|
|
227
230
|
return resolveSession();
|
|
228
231
|
}
|
|
229
|
-
function
|
|
232
|
+
function noteSessionReadCause(trigger, replacesPending) {
|
|
233
|
+
if (!sessionAnswerReported)
|
|
234
|
+
return;
|
|
235
|
+
if (!replacesPending && !sessionReadTriggerReported)
|
|
236
|
+
return;
|
|
237
|
+
sessionReadTrigger = trigger;
|
|
238
|
+
sessionReadTriggerReported = false;
|
|
239
|
+
}
|
|
240
|
+
function invalidateSessionCache(trigger) {
|
|
241
|
+
noteSessionReadCause(trigger, true);
|
|
230
242
|
resetSessionCache();
|
|
231
243
|
invalidateClientStatusRequest(SESSION_STATUS_PATH);
|
|
232
244
|
return notifySessionSubscribers();
|
|
@@ -234,7 +246,8 @@ function invalidateSessionCache() {
|
|
|
234
246
|
// A routine re-check: its read opens a provisional generation, and what is
|
|
235
247
|
// accepted stays shown while it is out (see "Whom a request was answered
|
|
236
248
|
// for").
|
|
237
|
-
function rereadSession() {
|
|
249
|
+
function rereadSession(trigger) {
|
|
250
|
+
noteSessionReadCause(snapshotListeners.size > 0 ? trigger : "expired", false);
|
|
238
251
|
cachedSessionAt = 0;
|
|
239
252
|
clearTimeout(staleSessionRecheck);
|
|
240
253
|
staleSessionRecheck = undefined;
|
|
@@ -254,7 +267,7 @@ function rereadSession() {
|
|
|
254
267
|
*/
|
|
255
268
|
function revalidateStaleSession() {
|
|
256
269
|
if (!hasFreshSessionCache() || !cachedSession) {
|
|
257
|
-
rereadSession();
|
|
270
|
+
rereadSession("focus");
|
|
258
271
|
return;
|
|
259
272
|
}
|
|
260
273
|
if (staleSessionRecheck !== undefined)
|
|
@@ -268,7 +281,7 @@ function revalidateStaleSession() {
|
|
|
268
281
|
if (document.visibilityState !== "visible" || !document.hasFocus()) {
|
|
269
282
|
return;
|
|
270
283
|
}
|
|
271
|
-
rereadSession();
|
|
284
|
+
rereadSession("focus");
|
|
272
285
|
}, Math.max(0, answeredAt + SESSION_CACHE_TTL_MS - Date.now()));
|
|
273
286
|
}
|
|
274
287
|
function installSessionInvalidationListeners() {
|
|
@@ -284,8 +297,8 @@ function installSessionInvalidationListeners() {
|
|
|
284
297
|
window.addEventListener(FETCH_TRANSPORT_CHANGED_EVENT, () => queueMicrotask(recheckSessionTransport));
|
|
285
298
|
window.addEventListener("storage", (event) => {
|
|
286
299
|
if (event.key === SESSION_INVALIDATION_STORAGE_KEY) {
|
|
287
|
-
void invalidateSessionCache();
|
|
288
|
-
setTimeout(() => void invalidateSessionCache(), SESSION_CACHE_TTL_MS);
|
|
300
|
+
void invalidateSessionCache("auth_change");
|
|
301
|
+
setTimeout(() => void invalidateSessionCache("auth_change"), SESSION_CACHE_TTL_MS);
|
|
289
302
|
}
|
|
290
303
|
});
|
|
291
304
|
document.addEventListener("visibilitychange", () => {
|
|
@@ -300,7 +313,7 @@ function installSessionInvalidationListeners() {
|
|
|
300
313
|
// first read any more, and the session is read again.
|
|
301
314
|
if (firstSessionReadAnswer() !== "replaced" &&
|
|
302
315
|
bootstrapInvalidationMissed()) {
|
|
303
|
-
void invalidateSessionCache();
|
|
316
|
+
void invalidateSessionCache("auth_change");
|
|
304
317
|
}
|
|
305
318
|
}
|
|
306
319
|
function bootstrapInvalidationMissed() {
|
|
@@ -316,7 +329,7 @@ export function notifySessionInvalidated() {
|
|
|
316
329
|
return Promise.resolve();
|
|
317
330
|
announceSessionInvalidated();
|
|
318
331
|
installSessionInvalidationListeners();
|
|
319
|
-
const reread = invalidateSessionCache();
|
|
332
|
+
const reread = invalidateSessionCache("auth_change");
|
|
320
333
|
try {
|
|
321
334
|
window.localStorage.setItem(SESSION_INVALIDATION_STORAGE_KEY, `${Date.now()}:${Math.random()}`);
|
|
322
335
|
}
|
|
@@ -388,7 +401,7 @@ function sessionTransportChanged(transport) {
|
|
|
388
401
|
}
|
|
389
402
|
function recheckSessionTransport() {
|
|
390
403
|
if (sessionTransportChanged(currentFetchTransport())) {
|
|
391
|
-
void invalidateSessionCache();
|
|
404
|
+
void invalidateSessionCache("transport_change");
|
|
392
405
|
}
|
|
393
406
|
}
|
|
394
407
|
/**
|
|
@@ -479,15 +492,15 @@ export function recheckSessionAfterUnauthorized() {
|
|
|
479
492
|
}
|
|
480
493
|
lastUnauthorizedRecheckAt = now;
|
|
481
494
|
installSessionInvalidationListeners();
|
|
482
|
-
void invalidateSessionCache();
|
|
495
|
+
void invalidateSessionCache("unauthorized");
|
|
483
496
|
}
|
|
484
497
|
export function beginSignOut() {
|
|
485
498
|
signingOut = true;
|
|
486
|
-
publishSessionIdentity(null);
|
|
499
|
+
publishSessionIdentity(null, "auth_change");
|
|
487
500
|
snapshot = { session: null, status: "signing-out", error: null };
|
|
488
501
|
for (const listener of snapshotListeners)
|
|
489
502
|
listener();
|
|
490
|
-
void invalidateSessionCache();
|
|
503
|
+
void invalidateSessionCache("auth_change");
|
|
491
504
|
}
|
|
492
505
|
export function completeSignOut() {
|
|
493
506
|
notifyParentAuthState("unauthenticated");
|
|
@@ -507,8 +520,10 @@ function fetchSharedSession() {
|
|
|
507
520
|
// signs the page's requests with its bearer token they are B's, even while
|
|
508
521
|
// the cookie read said A. Neither that answer nor a read still out on that
|
|
509
522
|
// transport is reused; the session is read again over this one.
|
|
510
|
-
if (sessionTransportChanged(transport))
|
|
523
|
+
if (sessionTransportChanged(transport)) {
|
|
524
|
+
noteSessionReadCause("transport_change", true);
|
|
511
525
|
resetSessionCache();
|
|
526
|
+
}
|
|
512
527
|
if (hasFreshSessionCache()) {
|
|
513
528
|
return Promise.resolve({
|
|
514
529
|
state: "resolved",
|
|
@@ -529,6 +544,7 @@ function fetchSharedSession() {
|
|
|
529
544
|
const requestAttempt = sessionReadAttempt;
|
|
530
545
|
const firstRead = firstSessionReadUnsent;
|
|
531
546
|
firstSessionReadUnsent = false;
|
|
547
|
+
const trigger = sessionReadTrigger;
|
|
532
548
|
let request;
|
|
533
549
|
const requestResult = (async () => {
|
|
534
550
|
try {
|
|
@@ -588,7 +604,9 @@ function fetchSharedSession() {
|
|
|
588
604
|
: result.state === "unavailable"
|
|
589
605
|
? "http_401"
|
|
590
606
|
: "signed_out_body";
|
|
591
|
-
publishSessionIdentity(session);
|
|
607
|
+
publishSessionIdentity(session, trigger);
|
|
608
|
+
sessionReadTriggerReported = true;
|
|
609
|
+
sessionAnswerReported = true;
|
|
592
610
|
if (firstSessionReadAnswer() !== answerBefore) {
|
|
593
611
|
notifyFirstSessionReadAnswer();
|
|
594
612
|
}
|
|
@@ -710,7 +728,7 @@ function subscribeSession(listener) {
|
|
|
710
728
|
}
|
|
711
729
|
else if (!hasFreshSessionCache()) {
|
|
712
730
|
// The answer outlived its lifetime: keep showing it and re-check.
|
|
713
|
-
rereadSession();
|
|
731
|
+
rereadSession("expired");
|
|
714
732
|
}
|
|
715
733
|
}
|
|
716
734
|
return () => {
|
|
@@ -13,9 +13,9 @@ export declare const postCollabPatch: import("h3").EventHandlerWithFetch<import(
|
|
|
13
13
|
ok: boolean;
|
|
14
14
|
}>>;
|
|
15
15
|
export declare const getCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
data?: undefined;
|
|
17
16
|
error: string;
|
|
18
17
|
docId?: undefined;
|
|
18
|
+
data?: undefined;
|
|
19
19
|
} | {
|
|
20
20
|
error?: undefined;
|
|
21
21
|
docId: string;
|
package/dist/db/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { isConnectionError } from "./errors.js";
|
|
3
|
+
import { isConnectionError, isRetryableConnectionError } from "./errors.js";
|
|
4
4
|
export { isConnectionError, isTransientDatabaseError } from "./errors.js";
|
|
5
5
|
import { withoutWriteObservation } from "../action-frame.js";
|
|
6
6
|
import { getAppConfig } from "../app-config/index.js";
|
|
@@ -914,7 +914,7 @@ export async function retryOnConnectionError(fn, maxAttempts = 3) {
|
|
|
914
914
|
}
|
|
915
915
|
catch (e) {
|
|
916
916
|
last = e;
|
|
917
|
-
if (!
|
|
917
|
+
if (!isRetryableConnectionError(e) ||
|
|
918
918
|
attempt === maxAttempts - 1 ||
|
|
919
919
|
!hasRetryBudgetFor(startedAt)) {
|
|
920
920
|
throw e;
|
package/dist/db/errors.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function isConnectionError(value: unknown): boolean;
|
|
2
2
|
export declare function withDatabaseErrorProvenance<T>(operation: () => Promise<T>): Promise<T>;
|
|
3
|
+
/** For retry loops that wrap only database operations, so provenance is given. */
|
|
4
|
+
export declare function isRetryableConnectionError(err: unknown): boolean;
|
|
3
5
|
export declare function isTransientDatabaseError(err: unknown, context?: {
|
|
4
6
|
source: "database";
|
|
5
7
|
}): boolean;
|
package/dist/db/errors.js
CHANGED
|
@@ -10,13 +10,30 @@ const CONNECTION_ERROR_CODES = new Set([
|
|
|
10
10
|
"CONNECTION_DESTROYED",
|
|
11
11
|
"CONNECTION_CLOSED",
|
|
12
12
|
]);
|
|
13
|
+
const SQLSTATE = /^(?:[0-5][0-9A-Z]|F0|HV|P0|XX)[0-9A-Z]{3}$/;
|
|
14
|
+
function isTransientSqlState(code) {
|
|
15
|
+
return (code === "53300" ||
|
|
16
|
+
code === "57014" ||
|
|
17
|
+
/^08/.test(code) ||
|
|
18
|
+
/^57P0[123]$/.test(code));
|
|
19
|
+
}
|
|
20
|
+
function driverError(err) {
|
|
21
|
+
const wrapper = err;
|
|
22
|
+
return typeof wrapper?.query === "string" &&
|
|
23
|
+
Array.isArray(wrapper.params) &&
|
|
24
|
+
wrapper.cause != null
|
|
25
|
+
? wrapper.cause
|
|
26
|
+
: err;
|
|
27
|
+
}
|
|
13
28
|
export function isConnectionError(value) {
|
|
14
|
-
const err = value;
|
|
29
|
+
const err = driverError(value);
|
|
15
30
|
if (!err)
|
|
16
31
|
return false;
|
|
17
32
|
const code = err.code || err.cause?.code;
|
|
18
33
|
if (code && CONNECTION_ERROR_CODES.has(code))
|
|
19
34
|
return true;
|
|
35
|
+
if (code && SQLSTATE.test(code) && !isTransientSqlState(code))
|
|
36
|
+
return false;
|
|
20
37
|
const name = err.name || err.cause?.name || "";
|
|
21
38
|
if (name === "ErrorEvent")
|
|
22
39
|
return true;
|
|
@@ -53,19 +70,32 @@ const DATABASE_NETWORK_ERROR_CODES = new Set([
|
|
|
53
70
|
"ENETDOWN",
|
|
54
71
|
"ECONNABORTED",
|
|
55
72
|
]);
|
|
73
|
+
const CONNECT_REFUSAL_CODES = new Set([
|
|
74
|
+
"57P03",
|
|
75
|
+
"08001",
|
|
76
|
+
"08004",
|
|
77
|
+
"ECONNREFUSED",
|
|
78
|
+
"EAI_AGAIN",
|
|
79
|
+
]);
|
|
80
|
+
/** For retry loops that wrap only database operations, so provenance is given. */
|
|
81
|
+
export function isRetryableConnectionError(err) {
|
|
82
|
+
if (isConnectionError(err))
|
|
83
|
+
return true;
|
|
84
|
+
const error = driverError(err);
|
|
85
|
+
return CONNECT_REFUSAL_CODES.has(String(error?.code ?? error?.cause?.code ?? ""));
|
|
86
|
+
}
|
|
56
87
|
// Query boundaries can establish database origin when a transport error has no driver frames.
|
|
57
88
|
export function isTransientDatabaseError(err, context) {
|
|
58
|
-
const error = err;
|
|
89
|
+
const error = driverError(err);
|
|
59
90
|
const code = String(error?.code ?? error?.cause?.code ?? "");
|
|
60
91
|
if (code === "ECHECKOUTTIMEOUT" ||
|
|
61
92
|
code === "DB_CONNECT_COOLDOWN" ||
|
|
62
93
|
code === "EMAXCONN" ||
|
|
63
|
-
code
|
|
64
|
-
code === "57014" ||
|
|
65
|
-
/^08/.test(code) ||
|
|
66
|
-
/^57P0[123]$/.test(code)) {
|
|
94
|
+
isTransientSqlState(code)) {
|
|
67
95
|
return true;
|
|
68
96
|
}
|
|
97
|
+
if (SQLSTATE.test(code))
|
|
98
|
+
return false;
|
|
69
99
|
const message = [error?.message, error?.cause?.message]
|
|
70
100
|
.filter((value) => typeof value === "string")
|
|
71
101
|
.join(" ");
|
|
@@ -82,6 +112,8 @@ export function isTransientDatabaseError(err, context) {
|
|
|
82
112
|
.join(" ");
|
|
83
113
|
return ((isConnectionError(error) || DATABASE_NETWORK_ERROR_CODES.has(code)) &&
|
|
84
114
|
(context?.source === "database" ||
|
|
115
|
+
error !== err ||
|
|
116
|
+
hasDatabaseOrigin(err) ||
|
|
85
117
|
hasDatabaseOrigin(error) ||
|
|
86
118
|
hasDatabaseOrigin(error?.cause) ||
|
|
87
119
|
/@neondatabase|\bpostgres(?:ql)?\b|\bpg-pool\b|drizzle-orm|\/db\/client\.[cm]?[jt]s/i.test(databaseSurface)));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineAction } from "../../action.js";
|
|
3
|
+
import { isTransientDatabaseError } from "../../db/errors.js";
|
|
3
4
|
import { getLabForLegacyFlag } from "../../labs/registry.js";
|
|
4
5
|
import { getUserLabStates } from "../../labs/store.js";
|
|
5
6
|
import { captureError } from "../../server/capture-error.js";
|
|
@@ -17,6 +18,8 @@ export default defineAction({
|
|
|
17
18
|
};
|
|
18
19
|
const definitions = listFeatureFlags();
|
|
19
20
|
const rules = await getFeatureFlagRulesForKeys(definitions.map(({ key }) => key), scope).catch(async (error) => {
|
|
21
|
+
if (isTransientDatabaseError(error, { source: "database" }))
|
|
22
|
+
throw error;
|
|
20
23
|
captureError(error, {
|
|
21
24
|
tags: { source: "feature-flags", op: "get-feature-flags" },
|
|
22
25
|
});
|
|
@@ -25,7 +28,9 @@ export default defineAction({
|
|
|
25
28
|
try {
|
|
26
29
|
fallback.set(key, featureFlagRuleInEffect(await readFeatureFlagRuleLayers(key, scope)));
|
|
27
30
|
}
|
|
28
|
-
catch {
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (isTransientDatabaseError(error, { source: "database" }))
|
|
33
|
+
throw error;
|
|
29
34
|
// coercion-ok: this flag's own read also failed; it evaluates
|
|
30
35
|
// off below, the same false-on-error outcome evaluateFeatureFlag
|
|
31
36
|
// gives any other caller.
|
|
@@ -50,7 +55,9 @@ export default defineAction({
|
|
|
50
55
|
.filter((key) => getLabForLegacyFlag(key));
|
|
51
56
|
if (migratedKeys.length === 0 || !scope.userEmail)
|
|
52
57
|
return values;
|
|
53
|
-
const labStates = await getUserLabStates(scope.userEmail, scope
|
|
58
|
+
const labStates = await getUserLabStates(scope.userEmail, scope, {
|
|
59
|
+
propagateTransientErrors: true,
|
|
60
|
+
});
|
|
54
61
|
for (const key of migratedKeys) {
|
|
55
62
|
const lab = getLabForLegacyFlag(key);
|
|
56
63
|
if (!lab)
|
|
@@ -33,9 +33,9 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
33
33
|
idempotencyKey: string;
|
|
34
34
|
deleted: boolean;
|
|
35
35
|
} | {
|
|
36
|
-
id?: undefined;
|
|
37
36
|
error: string;
|
|
38
37
|
url?: undefined;
|
|
38
|
+
id?: undefined;
|
|
39
39
|
provider?: undefined;
|
|
40
40
|
configured?: undefined;
|
|
41
41
|
} | {
|
|
@@ -45,8 +45,8 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
45
45
|
provider: string;
|
|
46
46
|
configured?: undefined;
|
|
47
47
|
} | {
|
|
48
|
-
id?: undefined;
|
|
49
48
|
url?: undefined;
|
|
49
|
+
id?: undefined;
|
|
50
50
|
provider?: undefined;
|
|
51
51
|
error: string;
|
|
52
52
|
configured: boolean;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@agent-native/agentkit": "0.
|
|
2
|
+
"@agent-native/agentkit": "0.233.0-nightly-20261124004026",
|
|
3
3
|
"@agent-native/code-agents-ui": "0.1.75",
|
|
4
|
-
"@agent-native/core": "0.
|
|
5
|
-
"@agent-native/core-corpus": "0.
|
|
4
|
+
"@agent-native/core": "0.233.0-nightly-20261124004026",
|
|
5
|
+
"@agent-native/core-corpus": "0.233.0-nightly-20261124004026",
|
|
6
6
|
"@agent-native/creative-context": "0.8.76",
|
|
7
|
-
"@agent-native/design-system": "0.
|
|
8
|
-
"@agent-native/dispatch": "0.43.
|
|
7
|
+
"@agent-native/design-system": "0.233.0-nightly-20261124004026",
|
|
8
|
+
"@agent-native/dispatch": "0.43.1-nightly-20261124004026",
|
|
9
9
|
"@agent-native/embedding": "0.2.0",
|
|
10
10
|
"@agent-native/migrate": "0.0.7",
|
|
11
11
|
"@agent-native/otel": "0.1.43",
|
|
12
12
|
"@agent-native/pinpoint": "0.1.119",
|
|
13
13
|
"@agent-native/recap-cli": "0.5.107",
|
|
14
|
-
"@agent-native/scheduling": "0.4.
|
|
14
|
+
"@agent-native/scheduling": "0.4.1-nightly-20261124004026",
|
|
15
15
|
"@agent-native/shared-app-config": "0.1.2",
|
|
16
|
-
"@agent-native/skills": "0.4.
|
|
17
|
-
"@agent-native/toolkit": "0.
|
|
16
|
+
"@agent-native/skills": "0.4.12-nightly-20261124004026",
|
|
17
|
+
"@agent-native/toolkit": "0.233.0-nightly-20261124004026"
|
|
18
18
|
}
|
|
@@ -8,5 +8,6 @@ export { cssBlendMode, gradientAngleDegreesFromHandles, gradientGeometryFromTran
|
|
|
8
8
|
export { assertFigmaNodeTreeComplexity, collectFallbackNodeIds, collectFontUsage, collectImageFillRefs, figmaDrawnText, hasPrivateUseCharacters, gradientAngleDegrees, mapFigmaNodeToHtml, textDecorationCss, textUnderlinePositionCss, textTransformCss, FIGMA_BLUR_RADIUS_TO_CSS_BLUR, type FidelityEntry, type FidelityLevel, type FidelityReport, type FigmaBoundingBox, type FigmaColor, type FigmaColorStop, type FigmaEffect, type FigmaFontUsage, type FigmaImageFilter, type FigmaIndividualStrokeWeights, type FigmaNode, type FigmaPaint, type FigmaTypeStyle, type MapFigmaNodeOptions, type MapFigmaNodeResult, } from "./figma-node-to-html.js";
|
|
9
9
|
export { notionBlocksToMarkdown, notionBlockToMarkdown, type NotionMarkdownResult, type NotionMarkdownSection, } from "./notion.js";
|
|
10
10
|
export { compareRasterImages, cropImageRegion, downscaleImageToFit, extractCssColors, extractDominantColors, fingerprintMedia, rankColorSamples, readBoundedResponseBytes, type CroppedImageRegion, type MediaFingerprint, type ResizedImage, } from "./media.js";
|
|
11
|
+
export { BREAKPOINT_PRESETS, createPlaywrightCapturer, resolveBreakpoint, runMatchedCheck, summarizeResults, type BreakpointRecord, type BreakpointResult, type ClockStrategy, type MatchedCheckInput, type MatchedCheckReport, type SideCapture, type SideCapturer, } from "./matched-capture.js";
|
|
11
12
|
export { extractStaticWebsiteContext, type WebsiteAsset, type WebsiteDesignTokens, type WebsiteExtraction, } from "./website.js";
|
|
12
13
|
export { selectInventoryForHydration, type IngestionHydrationPolicy, type IngestionHydrationSelection, type IngestionInventoryCandidate, } from "./selection.js";
|
package/dist/ingestion/index.js
CHANGED
|
@@ -8,5 +8,6 @@ export { cssBlendMode, gradientAngleDegreesFromHandles, gradientGeometryFromTran
|
|
|
8
8
|
export { assertFigmaNodeTreeComplexity, collectFallbackNodeIds, collectFontUsage, collectImageFillRefs, figmaDrawnText, hasPrivateUseCharacters, gradientAngleDegrees, mapFigmaNodeToHtml, textDecorationCss, textUnderlinePositionCss, textTransformCss, FIGMA_BLUR_RADIUS_TO_CSS_BLUR, } from "./figma-node-to-html.js";
|
|
9
9
|
export { notionBlocksToMarkdown, notionBlockToMarkdown, } from "./notion.js";
|
|
10
10
|
export { compareRasterImages, cropImageRegion, downscaleImageToFit, extractCssColors, extractDominantColors, fingerprintMedia, rankColorSamples, readBoundedResponseBytes, } from "./media.js";
|
|
11
|
+
export { BREAKPOINT_PRESETS, createPlaywrightCapturer, resolveBreakpoint, runMatchedCheck, summarizeResults, } from "./matched-capture.js";
|
|
11
12
|
export { extractStaticWebsiteContext, } from "./website.js";
|
|
12
13
|
export { selectInventoryForHydration, } from "./selection.js";
|