@agent-native/core 0.201.0 → 0.201.1
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 +96 -44
- package/dist/a2a/organization-identity.d.ts +9 -0
- package/dist/a2a/organization-identity.js +34 -0
- package/dist/a2a/server.d.ts +13 -7
- package/dist/a2a/server.js +187 -88
- package/dist/a2a/task-store.d.ts +7 -2
- package/dist/a2a/task-store.js +23 -8
- package/dist/a2a-claims.js +12 -2
- package/dist/app-config/mcp.d.ts +4 -0
- package/dist/app-config/mcp.js +7 -0
- package/dist/app-config/schema.d.ts +3 -0
- package/dist/app-config/schema.js +2 -0
- package/dist/automation/index.d.ts +1 -1
- package/dist/client/route-chunk-recovery.js +75 -11
- package/dist/client/route-warmup.d.ts +2 -0
- package/dist/client/route-warmup.js +3 -0
- package/dist/client/vite-dev-recovery-script.js +85 -17
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.js +3 -1
- package/dist/feature-flags/a2a-action-route.js +3 -4
- package/dist/mcp/build-server.d.ts +4 -0
- package/dist/mcp/build-server.js +152 -43
- package/dist/mcp/embed-app.js +5 -5
- package/dist/mcp/server.d.ts +0 -18
- package/dist/mcp/server.js +99 -9
- package/dist/onboarding/app-profile.js +2 -1
- package/dist/onboarding/workspace-services.js +3 -0
- package/dist/org/context.d.ts +13 -0
- package/dist/org/context.js +60 -0
- package/dist/org/handlers.d.ts +1 -1
- package/dist/org/index.d.ts +1 -1
- package/dist/org/membership.d.ts +6 -0
- package/dist/org/membership.js +23 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
- package/dist/provider-api/actions/provider-api.d.ts +6 -6
- package/dist/secrets/routes.d.ts +11 -11
- package/dist/server/action-routes.js +12 -5
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agent-engine-default-model-route.d.ts +1 -1
- package/dist/server/builder-browser.d.ts +4 -2
- package/dist/server/builder-browser.js +147 -9
- package/dist/server/core-routes-plugin.js +13 -6
- package/dist/server/entry-server.js +43 -2
- package/dist/server/sentry.js +9 -1
- package/dist/server/ssr-handler.d.ts +1 -1
- package/dist/server/ssr-handler.js +3 -7
- package/dist/shared/cache-control.d.ts +4 -1
- package/dist/shared/cache-control.js +11 -6
- package/dist/shared/route-chunk-recovery-bootstrap.d.ts +7 -0
- package/dist/shared/route-chunk-recovery-bootstrap.js +38 -0
- package/package.json +5 -3
|
@@ -2,8 +2,49 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import ReactDOMServer from "react-dom/server.browser";
|
|
3
3
|
const { renderToReadableStream } = ReactDOMServer;
|
|
4
4
|
import { isbot } from "isbot";
|
|
5
|
+
import { ROUTE_CHUNK_RECOVERY_BOOTSTRAP_SCRIPT } from "../shared/route-chunk-recovery-bootstrap.js";
|
|
5
6
|
import { wrapWithAnalytics } from "./analytics.js";
|
|
6
7
|
export const streamTimeout = 5_000;
|
|
8
|
+
const HEAD_OPEN_PATTERN = /<head\b[^>]*>/i;
|
|
9
|
+
const CHUNK_RECOVERY_BOOTSTRAP_TAG = `<script data-agent-native-chunk-recovery-bootstrap>${ROUTE_CHUNK_RECOVERY_BOOTSTRAP_SCRIPT}</script>`;
|
|
10
|
+
function installEarlyChunkRecoveryBootstrap(body) {
|
|
11
|
+
const decoder = new TextDecoder();
|
|
12
|
+
const encoder = new TextEncoder();
|
|
13
|
+
let pending = "";
|
|
14
|
+
let injected = false;
|
|
15
|
+
return body.pipeThrough(new TransformStream({
|
|
16
|
+
transform(chunk, controller) {
|
|
17
|
+
pending += decoder.decode(chunk, { stream: true });
|
|
18
|
+
if (!injected) {
|
|
19
|
+
const headOpenMatch = HEAD_OPEN_PATTERN.exec(pending);
|
|
20
|
+
if (!headOpenMatch || headOpenMatch.index === undefined)
|
|
21
|
+
return;
|
|
22
|
+
const headEnd = headOpenMatch.index + headOpenMatch[0].length;
|
|
23
|
+
controller.enqueue(encoder.encode(pending.slice(0, headEnd) + CHUNK_RECOVERY_BOOTSTRAP_TAG));
|
|
24
|
+
pending = pending.slice(headEnd);
|
|
25
|
+
injected = true;
|
|
26
|
+
}
|
|
27
|
+
if (pending) {
|
|
28
|
+
controller.enqueue(encoder.encode(pending));
|
|
29
|
+
pending = "";
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
flush(controller) {
|
|
33
|
+
pending += decoder.decode();
|
|
34
|
+
if (!injected) {
|
|
35
|
+
const headOpenMatch = HEAD_OPEN_PATTERN.exec(pending);
|
|
36
|
+
if (headOpenMatch && headOpenMatch.index !== undefined) {
|
|
37
|
+
const headEnd = headOpenMatch.index + headOpenMatch[0].length;
|
|
38
|
+
controller.enqueue(encoder.encode(pending.slice(0, headEnd) + CHUNK_RECOVERY_BOOTSTRAP_TAG));
|
|
39
|
+
pending = pending.slice(headEnd);
|
|
40
|
+
injected = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (pending)
|
|
44
|
+
controller.enqueue(encoder.encode(pending));
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
7
48
|
export function createDocumentRequestHandler(ServerRouter) {
|
|
8
49
|
return async function handleDocumentRequest(request, responseStatusCode, responseHeaders, routerContext, _loadContext) {
|
|
9
50
|
if (request.method.toUpperCase() === "HEAD") {
|
|
@@ -33,8 +74,8 @@ export function createDocumentRequestHandler(ServerRouter) {
|
|
|
33
74
|
if (waitForAll) {
|
|
34
75
|
await body.allReady;
|
|
35
76
|
}
|
|
36
|
-
responseHeaders.set("Content-Type", "text/html");
|
|
37
|
-
return new Response(wrapWithAnalytics(body), {
|
|
77
|
+
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
|
|
78
|
+
return new Response(wrapWithAnalytics(installEarlyChunkRecoveryBootstrap(body)), {
|
|
38
79
|
headers: responseHeaders,
|
|
39
80
|
status: responseStatusCode,
|
|
40
81
|
});
|
package/dist/server/sentry.js
CHANGED
|
@@ -258,8 +258,10 @@ export function setSentryRequestContext(ctx) {
|
|
|
258
258
|
export function captureAuthError(error, context) {
|
|
259
259
|
if (getRequestContext()?.isSyntheticTraffic)
|
|
260
260
|
return undefined;
|
|
261
|
-
if (!_initSucceeded || !Sentry)
|
|
261
|
+
if (!_initSucceeded || !Sentry) {
|
|
262
|
+
logSignupErrorWhenSentryUnavailable(context.route);
|
|
262
263
|
return undefined;
|
|
264
|
+
}
|
|
263
265
|
const sentry = Sentry;
|
|
264
266
|
try {
|
|
265
267
|
return sentry.withScope((scope) => {
|
|
@@ -274,9 +276,15 @@ export function captureAuthError(error, context) {
|
|
|
274
276
|
});
|
|
275
277
|
}
|
|
276
278
|
catch {
|
|
279
|
+
logSignupErrorWhenSentryUnavailable(context.route);
|
|
277
280
|
return undefined;
|
|
278
281
|
}
|
|
279
282
|
}
|
|
283
|
+
function logSignupErrorWhenSentryUnavailable(route) {
|
|
284
|
+
if (route !== "signup")
|
|
285
|
+
return;
|
|
286
|
+
console.error("[agent-native][auth] signup error (Sentry unavailable)");
|
|
287
|
+
}
|
|
280
288
|
export function captureRouteError(error, context = {}) {
|
|
281
289
|
if (getRequestContext()?.isSyntheticTraffic)
|
|
282
290
|
return undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DEFAULT_SSR_CACHE_HEADERS, DEFAULT_SPECULATION_RULES_HEADER, DEFAULT_SSR_CACHE_CONTROL, DISABLED_SSR_CACHE_HEADERS, isSsrCacheEnabled, resolveSsrCacheHeaders, resolveSsrCacheKeyHeaders, SSR_CACHE_ENV_VAR, } from "../shared/cache-control.js";
|
|
1
|
+
export { DEFAULT_SSR_CACHE_HEADERS, DEFAULT_SPECULATION_RULES_HEADER, DEFAULT_SSR_CACHE_CONTROL, DISABLED_SSR_CACHE_HEADERS, isSsrCacheEnabled, resolveSsrCacheHeaders, resolveSsrCacheKeyHeaders, resolveSsrNetlifyQueryVary, SSR_CACHE_ENV_VAR, } from "../shared/cache-control.js";
|
|
2
2
|
export declare function createH3SSRHandler(getBuild: () => unknown): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<Response>>;
|
|
@@ -13,7 +13,7 @@ import { getFrameworkRoutePrefix } from "./framework-route-prefix.js";
|
|
|
13
13
|
import { getPostHogClientConfigScript } from "./posthog-config.js";
|
|
14
14
|
import { runWithRequestContext } from "./request-context.js";
|
|
15
15
|
import { getRealtimeClientConfigScript, getSentryClientConfigScript, } from "./sentry-config.js";
|
|
16
|
-
export { DEFAULT_SSR_CACHE_HEADERS, DEFAULT_SPECULATION_RULES_HEADER, DEFAULT_SSR_CACHE_CONTROL, DISABLED_SSR_CACHE_HEADERS, isSsrCacheEnabled, resolveSsrCacheHeaders, resolveSsrCacheKeyHeaders, SSR_CACHE_ENV_VAR, } from "../shared/cache-control.js";
|
|
16
|
+
export { DEFAULT_SSR_CACHE_HEADERS, DEFAULT_SPECULATION_RULES_HEADER, DEFAULT_SSR_CACHE_CONTROL, DISABLED_SSR_CACHE_HEADERS, isSsrCacheEnabled, resolveSsrCacheHeaders, resolveSsrCacheKeyHeaders, resolveSsrNetlifyQueryVary, SSR_CACHE_ENV_VAR, } from "../shared/cache-control.js";
|
|
17
17
|
function getAppBasePath() {
|
|
18
18
|
return getAppBasePathFromViteEnv();
|
|
19
19
|
}
|
|
@@ -215,12 +215,8 @@ function applyDefaultSsrCacheHeader(headers, status, pathname) {
|
|
|
215
215
|
for (const [name, value] of Object.entries(resolveSsrCacheHeaders())) {
|
|
216
216
|
headers.set(name, value);
|
|
217
217
|
}
|
|
218
|
-
const cacheKeyHeaders = resolveSsrCacheKeyHeaders();
|
|
219
|
-
const netlifyVary =
|
|
220
|
-
? cacheKeyHeaders["netlify-vary"]
|
|
221
|
-
? "query"
|
|
222
|
-
: undefined
|
|
223
|
-
: cacheKeyHeaders["netlify-vary"];
|
|
218
|
+
const cacheKeyHeaders = resolveSsrCacheKeyHeaders(undefined, { varyByQuery });
|
|
219
|
+
const netlifyVary = cacheKeyHeaders["netlify-vary"];
|
|
224
220
|
if (netlifyVary)
|
|
225
221
|
headers.set("netlify-vary", netlifyVary);
|
|
226
222
|
else
|
|
@@ -32,7 +32,10 @@ export type SsrCacheHeaders = Record<"cache-control" | "cdn-cache-control" | "ne
|
|
|
32
32
|
export declare function parseSsrCacheSetting(raw: string | undefined | null): SsrCachePolicy;
|
|
33
33
|
export declare function ssrCacheHeadersForPolicy(policy: SsrCachePolicy): SsrCacheHeaders;
|
|
34
34
|
export declare function resolveSsrCacheHeaders(env?: Record<string, string | undefined>): Readonly<SsrCacheHeaders>;
|
|
35
|
-
export declare function
|
|
35
|
+
export declare function resolveSsrNetlifyQueryVary(varyByQuery?: boolean): string;
|
|
36
|
+
export declare function resolveSsrCacheKeyHeaders(env?: Record<string, string | undefined>, options?: {
|
|
37
|
+
varyByQuery?: boolean;
|
|
38
|
+
}): Readonly<Record<string, string>>;
|
|
36
39
|
export declare function isSsrCacheEnabled(env?: Record<string, string | undefined>): boolean;
|
|
37
40
|
export declare const DEFAULT_SPECULATION_RULES_PATH = "/_agent-native/speculation-rules.json";
|
|
38
41
|
export declare const DEFAULT_SPECULATION_RULES_HEADER = "\"/_agent-native/speculation-rules.json\"";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CHUNK_RECOVERY_QUERY_PARAM } from "./route-chunk-recovery-bootstrap.js";
|
|
1
2
|
export const DEFAULT_PUBLIC_CACHE_CONTROL = "public, max-age=600, stale-while-revalidate=604800, stale-if-error=3600";
|
|
2
3
|
export const DEFAULT_SSR_CACHE_CONTROL = DEFAULT_PUBLIC_CACHE_CONTROL;
|
|
3
4
|
export const DEFAULT_SSR_CDN_CACHE_CONTROL = DEFAULT_SSR_CACHE_CONTROL;
|
|
@@ -83,19 +84,23 @@ export function resolveSsrCacheHeaders(env = typeof process === "undefined"
|
|
|
83
84
|
memoizedHeaders = Object.freeze(ssrCacheHeadersForPolicy(parseSsrCacheSetting(raw)));
|
|
84
85
|
return memoizedHeaders;
|
|
85
86
|
}
|
|
87
|
+
export function resolveSsrNetlifyQueryVary(varyByQuery = false) {
|
|
88
|
+
if (varyByQuery)
|
|
89
|
+
return "query";
|
|
90
|
+
return `query=_routes|index|${CHUNK_RECOVERY_QUERY_PARAM}`;
|
|
91
|
+
}
|
|
86
92
|
export function resolveSsrCacheKeyHeaders(env = typeof process === "undefined"
|
|
87
93
|
? {}
|
|
88
|
-
: process.env) {
|
|
94
|
+
: process.env, options = {}) {
|
|
89
95
|
const explicitlyNotNetlify = env.NETLIFY_LOCAL === "true" || env.NETLIFY === "false";
|
|
90
96
|
const onNetlify = !explicitlyNotNetlify && (Boolean(env.NETLIFY) || Boolean(env.SITE_ID)); // guard:allow-env-credential -- Netlify's public runtime host marker, not a credential.
|
|
91
97
|
const none = Object.freeze({});
|
|
92
98
|
if (!onNetlify)
|
|
93
99
|
return none;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return Object.freeze({ "netlify-vary": "query=_routes|index" });
|
|
100
|
+
return Object.freeze({
|
|
101
|
+
// guard:allow-ssr-shell-exception — one fixed, public recovery cache-key variant
|
|
102
|
+
"netlify-vary": resolveSsrNetlifyQueryVary(options.varyByQuery),
|
|
103
|
+
});
|
|
99
104
|
}
|
|
100
105
|
export function isSsrCacheEnabled(env = typeof process === "undefined"
|
|
101
106
|
? {}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const STALE_CHUNK_RELOAD_AT_KEY = "__agentNativeStaleChunkReloadAt";
|
|
2
|
+
export declare const STALE_CHUNK_RELOAD_COOLDOWN_MS = 10000;
|
|
3
|
+
export declare const CHUNK_RECOVERY_QUERY_PARAM = "__agentNativeChunkRecovery";
|
|
4
|
+
export declare const CHUNK_RECOVERY_QUERY_VALUE = "1";
|
|
5
|
+
export declare const CHUNK_RECOVERY_CACHE_BUSTER_PARAM = "__agentNativeChunkRecoveryRequest";
|
|
6
|
+
export declare const ROUTE_WARMUP_PRELOAD_ATTRIBUTE = "data-agent-native-route-warmup";
|
|
7
|
+
export declare const ROUTE_CHUNK_RECOVERY_BOOTSTRAP_SCRIPT: string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const STALE_CHUNK_RELOAD_AT_KEY = "__agentNativeStaleChunkReloadAt";
|
|
2
|
+
export const STALE_CHUNK_RELOAD_COOLDOWN_MS = 10_000;
|
|
3
|
+
export const CHUNK_RECOVERY_QUERY_PARAM = "__agentNativeChunkRecovery";
|
|
4
|
+
export const CHUNK_RECOVERY_QUERY_VALUE = "1";
|
|
5
|
+
export const CHUNK_RECOVERY_CACHE_BUSTER_PARAM = "__agentNativeChunkRecoveryRequest";
|
|
6
|
+
export const ROUTE_WARMUP_PRELOAD_ATTRIBUTE = "data-agent-native-route-warmup";
|
|
7
|
+
export const ROUTE_CHUNK_RECOVERY_BOOTSTRAP_SCRIPT = `(()=>{
|
|
8
|
+
const queryParam=${JSON.stringify(CHUNK_RECOVERY_QUERY_PARAM)};
|
|
9
|
+
const queryValue=${JSON.stringify(CHUNK_RECOVERY_QUERY_VALUE)};
|
|
10
|
+
const cacheBusterParam=${JSON.stringify(CHUNK_RECOVERY_CACHE_BUSTER_PARAM)};
|
|
11
|
+
const reloadKey=${JSON.stringify(STALE_CHUNK_RELOAD_AT_KEY)};
|
|
12
|
+
const warmupAttr=${JSON.stringify(ROUTE_WARMUP_PRELOAD_ATTRIBUTE)};
|
|
13
|
+
document.addEventListener("error",event=>{
|
|
14
|
+
const target=event.target;
|
|
15
|
+
const tag=target?.tagName?.toUpperCase();
|
|
16
|
+
const failedModuleScript=tag==="SCRIPT"&&target.type?.toLowerCase()==="module";
|
|
17
|
+
const failedModulePreload=tag==="LINK"&&/(?:^|\\s)modulepreload(?:\\s|$)/i.test(target.getAttribute?.("rel")||target.rel||"")&&!target.hasAttribute?.(warmupAttr);
|
|
18
|
+
if(!failedModuleScript&&!failedModulePreload||/AgentNativeDesktop/i.test(navigator.userAgent))return;
|
|
19
|
+
if(/^(localhost|127\\.0\\.0\\.1|\\[::1\\])$/.test(location.hostname))return;
|
|
20
|
+
const url=new URL(location.href);
|
|
21
|
+
if(url.searchParams.get(queryParam)===queryValue)return;
|
|
22
|
+
const now=Date.now();
|
|
23
|
+
let last=Number(window[reloadKey])||0;
|
|
24
|
+
try{
|
|
25
|
+
last=Math.max(last,Number(sessionStorage.getItem(reloadKey))||0);
|
|
26
|
+
if(last>0&&now-last<=${STALE_CHUNK_RELOAD_COOLDOWN_MS})return;
|
|
27
|
+
sessionStorage.setItem(reloadKey,String(now));
|
|
28
|
+
}catch{
|
|
29
|
+
last=Number(window[reloadKey])||0;
|
|
30
|
+
if(last>0&&now-last<=${STALE_CHUNK_RELOAD_COOLDOWN_MS})return;
|
|
31
|
+
}
|
|
32
|
+
window[reloadKey]=now;
|
|
33
|
+
url.searchParams.set(queryParam,queryValue);
|
|
34
|
+
url.searchParams.set(cacheBusterParam,Date.now().toString(36)+"-"+Math.random().toString(36).slice(2));
|
|
35
|
+
location.assign(url.href);
|
|
36
|
+
event.stopImmediatePropagation();
|
|
37
|
+
},true);
|
|
38
|
+
})();`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.201.
|
|
3
|
+
"version": "0.201.1",
|
|
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": {
|
|
@@ -458,6 +458,7 @@
|
|
|
458
458
|
"./triggers": "./dist/triggers/index.js",
|
|
459
459
|
"./terminal": "./dist/client/terminal/index.js",
|
|
460
460
|
"./terminal/server": "./dist/terminal/index.js",
|
|
461
|
+
"./terminal/pty-server": "./dist/terminal/pty-server.js",
|
|
461
462
|
"./tailwind": "./dist/tailwind.preset.js",
|
|
462
463
|
"./agent/engine": "./dist/agent/engine/index.js",
|
|
463
464
|
"./agent/engine/error-detail": "./dist/agent/engine/error-detail.js",
|
|
@@ -578,6 +579,7 @@
|
|
|
578
579
|
"./shared/app-status": "./dist/shared/app-status.js",
|
|
579
580
|
"./shared/auth-page-types": "./dist/shared/auth-page-types.js",
|
|
580
581
|
"./shared/builder-referrals": "./dist/shared/builder-referrals.js",
|
|
582
|
+
"./shared/chat-first-app-creation": "./dist/shared/chat-first-app-creation.js",
|
|
581
583
|
"./shared/context-xray": "./dist/shared/context-xray.js",
|
|
582
584
|
"./shared/docs-url": "./dist/shared/docs-url.js",
|
|
583
585
|
"./shared/document-title": "./dist/shared/document-title.js",
|
|
@@ -669,8 +671,8 @@
|
|
|
669
671
|
"yaml": "^2.9.0",
|
|
670
672
|
"yjs": "^13.6.33",
|
|
671
673
|
"zod": "^4.3.6",
|
|
672
|
-
"@agent-native/agentkit": "^0.201.
|
|
673
|
-
"@agent-native/recap-cli": "^0.5.
|
|
674
|
+
"@agent-native/agentkit": "^0.201.1",
|
|
675
|
+
"@agent-native/recap-cli": "^0.5.62"
|
|
674
676
|
},
|
|
675
677
|
"devDependencies": {
|
|
676
678
|
"@ai-sdk/anthropic": "^3.0.71",
|