@agent-native/core 0.233.0 → 0.233.1-nightly-20261124212349
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/client/application-state.js +38 -7
- package/dist/client/feature-flags/use-feature-flag.js +3 -0
- package/dist/client/labs/use-lab.js +2 -0
- package/dist/client/use-action.d.ts +1 -0
- package/dist/client/use-action.js +4 -2
- package/dist/framework-package-versions.json +7 -7
- package/package.json +3 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { APP_STATE_BATCH_ROUTE_HEADER, APP_STATE_SEQ_HEADER, APP_STATE_WRITER_HEADER, TAB_SCOPED_APP_STATE_KEYS, } from "../shared/app-state-routes.js";
|
|
2
|
+
import { readSessionInvalidationMarker, SESSION_BOOTSTRAP_INVALIDATION_GLOBAL, } from "../shared/ssr-session-bootstrap.js";
|
|
2
3
|
import { agentNativePath } from "./api-path.js";
|
|
3
4
|
import { assertAgentNativeApiEnabled } from "./api-surface.js";
|
|
4
5
|
import { getBrowserTabId, isBrowserTabIdForCurrentDocument, } from "./browser-tab-id.js";
|
|
5
6
|
import { availableKeepaliveBytes, reserveKeepaliveBytes, } from "./keepalive-budget.js";
|
|
6
7
|
import { recordStateWrite } from "./recorder.js";
|
|
7
|
-
import { currentSessionIdentity, currentSessionScope, subscribeSessionScope, } from "./session-identity.js";
|
|
8
|
+
import { currentSessionIdentity, currentSessionScope, subscribeSessionInvalidation, subscribeSessionScope, } from "./session-identity.js";
|
|
8
9
|
const APP_STATE_KEY_PATTERN = /^[a-zA-Z0-9_:-]+$/;
|
|
9
10
|
const CORE_BEFORE_TURN_STATE_KEYS = [
|
|
10
11
|
"navigation",
|
|
@@ -18,6 +19,32 @@ const beforeTurnContexts = new WeakMap();
|
|
|
18
19
|
const mutationRevisions = new Map();
|
|
19
20
|
const requestSessionIds = new WeakMap();
|
|
20
21
|
let nextRequestSessionId = 0;
|
|
22
|
+
let appStateSessionScope = currentSessionScope();
|
|
23
|
+
let awaitingInitialSession = currentSessionIdentity() === undefined;
|
|
24
|
+
const initialInvalidationMarker = typeof window === "undefined"
|
|
25
|
+
? undefined
|
|
26
|
+
: (window[SESSION_BOOTSTRAP_INVALIDATION_GLOBAL] ??
|
|
27
|
+
readSessionInvalidationMarker());
|
|
28
|
+
if (typeof window === "undefined" ||
|
|
29
|
+
typeof window.addEventListener === "function") {
|
|
30
|
+
subscribeSessionInvalidation(() => {
|
|
31
|
+
if (awaitingInitialSession) {
|
|
32
|
+
awaitingInitialSession = false;
|
|
33
|
+
appStateSessionScope = {};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
subscribeSessionScope(() => {
|
|
38
|
+
const identity = currentSessionIdentity();
|
|
39
|
+
if (!awaitingInitialSession ||
|
|
40
|
+
identity === undefined ||
|
|
41
|
+
(initialInvalidationMarker !== undefined &&
|
|
42
|
+
initialInvalidationMarker !== readSessionInvalidationMarker())) {
|
|
43
|
+
appStateSessionScope = currentSessionScope();
|
|
44
|
+
}
|
|
45
|
+
if (identity !== undefined)
|
|
46
|
+
awaitingInitialSession = false;
|
|
47
|
+
});
|
|
21
48
|
function appStateUrl(key) {
|
|
22
49
|
if (!APP_STATE_KEY_PATTERN.test(key)) {
|
|
23
50
|
throw new TypeError("Application state keys may only contain letters, numbers, underscores, hyphens, and colons.");
|
|
@@ -69,7 +96,7 @@ function browserTabHeaders() {
|
|
|
69
96
|
// Identifies the server row a key reaches, so writes and reads through
|
|
70
97
|
// `navigation` and through `navigation:<this tab>` wait on each other.
|
|
71
98
|
function requestKey(key) {
|
|
72
|
-
const session =
|
|
99
|
+
const session = appStateSessionScope;
|
|
73
100
|
let sessionId = requestSessionIds.get(session);
|
|
74
101
|
if (sessionId === undefined) {
|
|
75
102
|
sessionId = ++nextRequestSessionId;
|
|
@@ -91,7 +118,7 @@ function appStateTurnScope() {
|
|
|
91
118
|
]);
|
|
92
119
|
}
|
|
93
120
|
function currentBeforeTurnContext() {
|
|
94
|
-
const session =
|
|
121
|
+
const session = appStateSessionScope;
|
|
95
122
|
let contexts = beforeTurnContexts.get(session);
|
|
96
123
|
if (!contexts) {
|
|
97
124
|
contexts = new Map();
|
|
@@ -731,8 +758,10 @@ const MAX_BATCH_KEYS = 100;
|
|
|
731
758
|
export async function readClientAppStateMany(keys, options = {}) {
|
|
732
759
|
assertAgentNativeApiEnabled(`read application state [${keys.join(", ")}]`);
|
|
733
760
|
const context = currentBeforeTurnContext();
|
|
761
|
+
const session = currentSessionScope();
|
|
734
762
|
const assertScope = () => {
|
|
735
|
-
if (currentBeforeTurnContext() !== context
|
|
763
|
+
if (currentBeforeTurnContext() !== context ||
|
|
764
|
+
currentSessionScope() !== session) {
|
|
736
765
|
throw new AppStateScopeChangedError();
|
|
737
766
|
}
|
|
738
767
|
};
|
|
@@ -790,7 +819,8 @@ export async function readClientAppStateMany(keys, options = {}) {
|
|
|
790
819
|
let pendingBatch;
|
|
791
820
|
function scheduleBatchedRead(key) {
|
|
792
821
|
const context = currentBeforeTurnContext();
|
|
793
|
-
|
|
822
|
+
const session = currentSessionScope();
|
|
823
|
+
if (pendingBatch?.context === context && pendingBatch.session === session) {
|
|
794
824
|
pendingBatch.keys.add(key);
|
|
795
825
|
return pendingBatch.promise;
|
|
796
826
|
}
|
|
@@ -799,14 +829,15 @@ function scheduleBatchedRead(key) {
|
|
|
799
829
|
setTimeout(() => {
|
|
800
830
|
if (pendingBatch?.promise === promise)
|
|
801
831
|
pendingBatch = undefined;
|
|
802
|
-
if (currentBeforeTurnContext() !== context
|
|
832
|
+
if (currentBeforeTurnContext() !== context ||
|
|
833
|
+
currentSessionScope() !== session) {
|
|
803
834
|
reject(new AppStateScopeChangedError());
|
|
804
835
|
return;
|
|
805
836
|
}
|
|
806
837
|
readClientAppStateMany([...keys]).then(resolve, reject);
|
|
807
838
|
}, 0);
|
|
808
839
|
});
|
|
809
|
-
pendingBatch = { keys, promise, context };
|
|
840
|
+
pendingBatch = { keys, promise, context, session };
|
|
810
841
|
return promise;
|
|
811
842
|
}
|
|
812
843
|
function awaitWithAbort(promise, signal) {
|
|
@@ -8,6 +8,7 @@ export function useFeatureFlag(key) {
|
|
|
8
8
|
const { status } = useSession();
|
|
9
9
|
const query = useActionQuery("get-feature-flags", undefined, {
|
|
10
10
|
enabled: status === "authenticated",
|
|
11
|
+
batchInitial: true,
|
|
11
12
|
refetchInterval: retryUnavailableFlags,
|
|
12
13
|
});
|
|
13
14
|
if (RETIRED_ENABLED_FLAG_KEYS.has(key))
|
|
@@ -30,6 +31,7 @@ export function useFeatureFlagState(key, options) {
|
|
|
30
31
|
]);
|
|
31
32
|
const query = useActionQuery("get-feature-flags", undefined, {
|
|
32
33
|
enabled: status === "authenticated",
|
|
34
|
+
batchInitial: true,
|
|
33
35
|
refetchInterval: retryUnavailableFlags,
|
|
34
36
|
...(options?.freshOnMount
|
|
35
37
|
? {
|
|
@@ -65,6 +67,7 @@ export function useFeatureFlags() {
|
|
|
65
67
|
const { status } = useSession();
|
|
66
68
|
const query = useActionQuery("get-feature-flags", undefined, {
|
|
67
69
|
enabled: status === "authenticated",
|
|
70
|
+
batchInitial: true,
|
|
68
71
|
refetchInterval: retryUnavailableFlags,
|
|
69
72
|
});
|
|
70
73
|
return query.isError ? {} : evaluatedFeatureFlagValues(query.data);
|
|
@@ -12,6 +12,7 @@ export function useLabState(lab) {
|
|
|
12
12
|
const { status } = useSession();
|
|
13
13
|
const query = useActionQuery("get-lab-states", undefined, {
|
|
14
14
|
enabled: status === "authenticated",
|
|
15
|
+
batchInitial: true,
|
|
15
16
|
});
|
|
16
17
|
const state = query.data?.[key];
|
|
17
18
|
const stateFailed = state !== undefined && "error" in state;
|
|
@@ -56,6 +57,7 @@ export function useLabStates() {
|
|
|
56
57
|
const { status } = useSession();
|
|
57
58
|
const query = useActionQuery("get-lab-states", undefined, {
|
|
58
59
|
enabled: status === "authenticated",
|
|
60
|
+
batchInitial: true,
|
|
59
61
|
});
|
|
60
62
|
return query.data ?? {};
|
|
61
63
|
}
|
|
@@ -226,6 +226,7 @@ export declare function useActionQuery<TResult = undefined, TName extends Action
|
|
|
226
226
|
* than waiting on the other reads in their batch.
|
|
227
227
|
*/
|
|
228
228
|
batchRefetches?: boolean;
|
|
229
|
+
batchInitial?: boolean;
|
|
229
230
|
/** Captures a local projection fence before the authorized read starts. */
|
|
230
231
|
onRequestStart?: () => unknown;
|
|
231
232
|
/** Receives canonical responses only, never optimistic query-cache writes. */
|
|
@@ -1375,7 +1375,7 @@ function canBatchActionQueryFetch(query) {
|
|
|
1375
1375
|
!query.observers.some((observer) => observer.options.meta?.[UNBATCHED_REFETCHES_META_KEY] === true));
|
|
1376
1376
|
}
|
|
1377
1377
|
export function useActionQuery(actionName, params, options) {
|
|
1378
|
-
const { refetchInterval, interactive = false, foregroundRefetch = false, retry: callerRetry, enabled: callerEnabled, queryKeyScope, resources, batchRefetches, onRequestStart, onServerResult, onServerError, method = "GET", beforeSend, uiOnly, retryUiCapability, ...restOptions } = options ?? {};
|
|
1378
|
+
const { refetchInterval, interactive = false, foregroundRefetch = false, retry: callerRetry, enabled: callerEnabled, queryKeyScope, resources, batchRefetches, batchInitial, onRequestStart, onServerResult, onServerError, method = "GET", beforeSend, uiOnly, retryUiCapability, ...restOptions } = options ?? {};
|
|
1379
1379
|
const queryKey = ["action", actionName, params, ...(queryKeyScope ?? [])];
|
|
1380
1380
|
const queryClient = useQueryClient();
|
|
1381
1381
|
const errorI18n = useContext(I18nContext)?.i18n;
|
|
@@ -1440,7 +1440,9 @@ export function useActionQuery(actionName, params, options) {
|
|
|
1440
1440
|
visibleOnly: !restOptions.refetchIntervalInBackground,
|
|
1441
1441
|
uiOnly: uiOnly || interactive,
|
|
1442
1442
|
...(retryUiCapability === undefined ? {} : { retryUiCapability }),
|
|
1443
|
-
batch: method === "GET" &&
|
|
1443
|
+
batch: method === "GET" &&
|
|
1444
|
+
((batchInitial === true && query?.state.data === undefined) ||
|
|
1445
|
+
canBatchActionQueryFetch(query)),
|
|
1444
1446
|
onResponse: (response) => {
|
|
1445
1447
|
lastResponse = response;
|
|
1446
1448
|
onResponse(response);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@agent-native/agentkit": "0.233.
|
|
2
|
+
"@agent-native/agentkit": "0.233.1-nightly-20261124212349",
|
|
3
3
|
"@agent-native/code-agents-ui": "0.1.75",
|
|
4
|
-
"@agent-native/core": "0.233.
|
|
5
|
-
"@agent-native/core-corpus": "0.233.
|
|
4
|
+
"@agent-native/core": "0.233.1-nightly-20261124212349",
|
|
5
|
+
"@agent-native/core-corpus": "0.233.1-nightly-20261124212349",
|
|
6
6
|
"@agent-native/creative-context": "0.8.77",
|
|
7
|
-
"@agent-native/design-system": "0.233.
|
|
8
|
-
"@agent-native/dispatch": "0.43.
|
|
7
|
+
"@agent-native/design-system": "0.233.1-nightly-20261124212349",
|
|
8
|
+
"@agent-native/dispatch": "0.43.2-nightly-20261124212349",
|
|
9
9
|
"@agent-native/embedding": "0.2.0",
|
|
10
10
|
"@agent-native/migrate": "0.0.7",
|
|
11
11
|
"@agent-native/otel": "0.1.44",
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"@agent-native/recap-cli": "0.5.108",
|
|
14
14
|
"@agent-native/scheduling": "0.4.1",
|
|
15
15
|
"@agent-native/shared-app-config": "0.1.2",
|
|
16
|
-
"@agent-native/skills": "0.4.
|
|
17
|
-
"@agent-native/toolkit": "0.233.
|
|
16
|
+
"@agent-native/skills": "0.4.13-nightly-20261124212349",
|
|
17
|
+
"@agent-native/toolkit": "0.233.1-nightly-20261124212349"
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.233.
|
|
3
|
+
"version": "0.233.1-nightly-20261124212349",
|
|
4
4
|
"description": "The agentic application framework for building autonomous agents with intuitive UIs",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -823,7 +823,7 @@
|
|
|
823
823
|
"yaml": "^2.9.0",
|
|
824
824
|
"yjs": "^13.6.33",
|
|
825
825
|
"zod": "^4.3.6",
|
|
826
|
-
"@agent-native/agentkit": "^0.233.
|
|
826
|
+
"@agent-native/agentkit": "^0.233.1-nightly-20261124212349",
|
|
827
827
|
"@agent-native/recap-cli": "^0.5.108"
|
|
828
828
|
},
|
|
829
829
|
"devDependencies": {
|
|
@@ -898,7 +898,7 @@
|
|
|
898
898
|
"xlsx": "^0.18.5"
|
|
899
899
|
},
|
|
900
900
|
"peerDependencies": {
|
|
901
|
-
"@agent-native/core-corpus": "
|
|
901
|
+
"@agent-native/core-corpus": "0.233.1-nightly-20261124212349",
|
|
902
902
|
"@ai-sdk/anthropic": ">=3",
|
|
903
903
|
"@ai-sdk/cohere": ">=3",
|
|
904
904
|
"@ai-sdk/google": ">=3",
|