@agent-native/core 0.157.18 → 0.157.20

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.
@@ -3,6 +3,7 @@ export type { A2ATokenPayload } from "./server.js";
3
3
  export { generateAgentCard } from "./agent-card.js";
4
4
  export { A2A_AGENT_ACTIVITY_KIND, A2A_AGENT_ACTIVITY_VERSION, MAX_A2A_ACTIVITY_REASONING_CHARS, MAX_A2A_ACTIVITY_REASONING_SEGMENTS, MAX_A2A_ACTIVITY_RESPONSE_CHARS, MAX_A2A_ACTIVITY_TOOL_CALLS, MAX_A2A_ACTIVITY_TOTAL_CHARS, MAX_A2A_ACTIVITY_TOOL_ID_CHARS, MAX_A2A_ACTIVITY_TOOL_INPUT_CHARS, MAX_A2A_ACTIVITY_TOOL_NAME_CHARS, MAX_A2A_ACTIVITY_TOOL_PAYLOAD_CHARS, MAX_A2A_ACTIVITY_TOOL_RESULT_CHARS, applyA2AAgentActivityEvent, buildA2AAgentActivityPart, buildA2AAgentActivitySnapshot, createA2AAgentActivityState, parseA2AAgentActivityPart, } from "./activity.js";
5
5
  export { A2AClient, callAction, callAgent, signA2AToken } from "./client.js";
6
+ export { canonicalA2AAudience } from "./audience.js";
6
7
  export { resolveA2ACallerAuth } from "./caller-auth.js";
7
8
  export type { A2ACallerAuth } from "./caller-auth.js";
8
9
  export { AgentInvocationError, buildAgentInvocationPrompt, invokeAgent, invokeAgentAction, looksLikeAgentUrl, resolveAgentInvocationTarget, } from "./invoke.js";
package/dist/a2a/index.js CHANGED
@@ -4,5 +4,6 @@ export { generateAgentCard } from "./agent-card.js";
4
4
  export { A2A_AGENT_ACTIVITY_KIND, A2A_AGENT_ACTIVITY_VERSION, MAX_A2A_ACTIVITY_REASONING_CHARS, MAX_A2A_ACTIVITY_REASONING_SEGMENTS, MAX_A2A_ACTIVITY_RESPONSE_CHARS, MAX_A2A_ACTIVITY_TOOL_CALLS, MAX_A2A_ACTIVITY_TOTAL_CHARS, MAX_A2A_ACTIVITY_TOOL_ID_CHARS, MAX_A2A_ACTIVITY_TOOL_INPUT_CHARS, MAX_A2A_ACTIVITY_TOOL_NAME_CHARS, MAX_A2A_ACTIVITY_TOOL_PAYLOAD_CHARS, MAX_A2A_ACTIVITY_TOOL_RESULT_CHARS, applyA2AAgentActivityEvent, buildA2AAgentActivityPart, buildA2AAgentActivitySnapshot, createA2AAgentActivityState, parseA2AAgentActivityPart, } from "./activity.js";
5
5
  // Client
6
6
  export { A2AClient, callAction, callAgent, signA2AToken } from "./client.js";
7
+ export { canonicalA2AAudience } from "./audience.js";
7
8
  export { resolveA2ACallerAuth } from "./caller-auth.js";
8
9
  export { AgentInvocationError, buildAgentInvocationPrompt, invokeAgent, invokeAgentAction, looksLikeAgentUrl, resolveAgentInvocationTarget, } from "./invoke.js";
@@ -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;
66
65
  states: {
67
66
  clientId: number;
68
67
  state: string;
69
68
  }[];
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;
81
80
  users: {
82
81
  clientId: number;
83
82
  lastSeen: number;
84
83
  }[];
84
+ error?: undefined;
85
85
  }>>;
@@ -13,8 +13,8 @@
13
13
  * Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
14
14
  */
15
15
  export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
16
- ok?: undefined;
17
16
  error: string;
17
+ ok?: undefined;
18
18
  } | {
19
19
  error?: undefined;
20
20
  ok: boolean;
@@ -41,27 +41,27 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- ok?: undefined;
45
- error?: undefined;
46
44
  summary: import("./types.js").TraceSummary;
47
45
  spans: import("./types.js").TraceSpan[];
48
46
  id?: undefined;
49
- } | {
50
- ok?: undefined;
51
47
  error?: undefined;
48
+ ok?: undefined;
49
+ } | {
52
50
  summary?: undefined;
53
51
  spans?: undefined;
54
52
  id: string;
55
- } | {
53
+ error?: undefined;
56
54
  ok?: undefined;
55
+ } | {
57
56
  summary?: undefined;
58
57
  spans?: undefined;
59
58
  id?: undefined;
60
59
  error: any;
60
+ ok?: undefined;
61
61
  } | {
62
- error?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
65
64
  id?: undefined;
66
65
  ok: boolean;
66
+ error?: undefined;
67
67
  }>>;
@@ -34,16 +34,16 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- ok?: undefined;
38
37
  status?: undefined;
38
+ ok?: undefined;
39
39
  } | {
40
40
  ok: boolean;
41
41
  status: string;
42
42
  error?: undefined;
43
43
  } | {
44
- ok?: undefined;
45
44
  error: string;
46
45
  removed?: undefined;
46
+ ok?: undefined;
47
47
  } | {
48
48
  ok: boolean;
49
49
  removed: boolean;
@@ -54,9 +54,9 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
54
54
  * or the current stored value without changing anything.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
- ok?: undefined;
58
57
  error: string;
59
58
  note?: undefined;
59
+ ok?: undefined;
60
60
  } | {
61
61
  ok: boolean;
62
62
  note?: undefined;
@@ -143,7 +143,10 @@ function getAllowedCorsOrigin(origin) {
143
143
  // keeps production from trusting arbitrary localhost callers.
144
144
  });
145
145
  if (allowedOrigin) {
146
- return { origin: allowedOrigin, credentials: true };
146
+ return {
147
+ origin: allowedOrigin,
148
+ credentials: shouldAllowMcpEmbedCredentials(allowedOrigin),
149
+ };
147
150
  }
148
151
  if (origin && isMcpEmbedCorsOrigin(origin)) {
149
152
  return {
@@ -27,10 +27,10 @@ export declare function resolveAgentEngineApiKeyWriteTarget(event: H3Event, scop
27
27
  export declare function createAgentEngineApiKeyHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
28
28
  error: any;
29
29
  } | {
30
- error?: undefined;
31
30
  ok: boolean;
32
31
  key: string;
33
32
  baseUrlKey?: string;
34
33
  scope: AgentEngineApiKeyScope;
34
+ error?: undefined;
35
35
  }>>;
36
36
  export {};
@@ -1394,7 +1394,6 @@ function applyCorsHeaders(event) {
1394
1394
  Boolean(getHeader(event, "authorization")));
1395
1395
  const allowedOrigin = getAllowedCorsOrigin(origin, {
1396
1396
  allowedOrigins: readCorsAllowedOrigins(),
1397
- allowLocalhostWhenNoAllowlist: true,
1398
1397
  });
1399
1398
  const responseOrigin = mcpEmbedCorsRequest ? origin : allowedOrigin;
1400
1399
  if (!responseOrigin)
@@ -1103,7 +1103,6 @@ export function createCoreRoutesPlugin(options = {}) {
1103
1103
  : getAllowedCorsOrigin(origin, {
1104
1104
  allowedOrigins: allowlist,
1105
1105
  allowAnyOriginWhenNoAllowlist: false,
1106
- allowLocalhostWhenNoAllowlist: true,
1107
1106
  });
1108
1107
  // Reject preflights from disallowed cross-origin callers BEFORE
1109
1108
  // returning 204. Previously the OPTIONS short-circuit returned 204
@@ -1,8 +1,9 @@
1
1
  import { defineEventHandler, getHeader, getMethod, getQuery, setResponseHeader, } from "h3";
2
2
  import { withCollapsedAgentSidebarParam } from "../shared/agent-sidebar-url.js";
3
3
  import { EMBED_MODE_QUERY_PARAM, EMBED_START_PATH, EMBED_TOKEN_QUERY_PARAM, MCP_APP_CHAT_BRIDGE_QUERY_PARAM, } from "../shared/embed-auth.js";
4
- import { isMcpEmbedCorsOrigin, MCP_EMBED_CORS_ALLOW_HEADERS, } from "../shared/mcp-embed-headers.js";
4
+ import { isMcpEmbedTransplantOrigin, MCP_EMBED_CORS_ALLOW_HEADERS, } from "../shared/mcp-embed-headers.js";
5
5
  import { getConfiguredAppBasePath } from "./app-base-path.js";
6
+ import { readCorsAllowedOrigins } from "./cors-origins.js";
6
7
  import { consumeEmbedSessionTicket, isEmbedCapabilityScope, normalizeEmbedTargetPath, setEmbedSessionCookie, signEmbedSessionToken, } from "./embed-session.js";
7
8
  function withConfiguredBasePath(path) {
8
9
  const base = getConfiguredAppBasePath();
@@ -48,7 +49,13 @@ function setEmbedStartResponseHeaders(event) {
48
49
  }
49
50
  function embedStartCorsOrigin(event) {
50
51
  const origin = getHeader(event, "origin");
51
- return isMcpEmbedCorsOrigin(origin) ? (origin ?? null) : null;
52
+ if (!origin)
53
+ return null;
54
+ if (origin === "null")
55
+ return origin;
56
+ if (isMcpEmbedTransplantOrigin(origin))
57
+ return origin;
58
+ return readCorsAllowedOrigins().includes(origin) ? origin : null;
52
59
  }
53
60
  function embedStartResponseHeaders(event, init = {}) {
54
61
  const headers = new Headers({
@@ -138,6 +145,16 @@ function firstQueryValue(value) {
138
145
  : "";
139
146
  }
140
147
  function wantsTransplantLocationResponse(event) {
148
+ const origin = getHeader(event, "origin");
149
+ const fetchDestination = getHeader(event, "sec-fetch-dest")?.toLowerCase();
150
+ if (fetchDestination !== "document" && fetchDestination !== "iframe") {
151
+ return false;
152
+ }
153
+ const canReadLocation = !origin ||
154
+ (origin !== "null" && embedStartCorsOrigin(event) !== null) ||
155
+ isMcpEmbedTransplantOrigin(origin);
156
+ if (!canReadLocation)
157
+ return false;
141
158
  if (getHeader(event, "x-agent-native-embed-transplant") === "1") {
142
159
  return true;
143
160
  }
@@ -7,6 +7,13 @@ export declare function isMcpProductHostOrigin(origin: string | null | undefined
7
7
  export declare function isAgentNativeFirstPartyAppOrigin(origin: string | null | undefined): boolean;
8
8
  export declare function isBuilderIoEmbedOrigin(origin: string | null | undefined): boolean;
9
9
  export declare function isMcpEmbedCorsOrigin(origin: string | null | undefined): boolean;
10
+ /**
11
+ * Origins allowed to read the one-time embed location returned by a browser
12
+ * transplant request. Builder and localhost origins may use the broader MCP
13
+ * CORS surface, but must not receive a reusable session location unless they
14
+ * are explicitly configured through CORS_ALLOWED_ORIGINS.
15
+ */
16
+ export declare function isMcpEmbedTransplantOrigin(origin: string | null | undefined): boolean;
10
17
  export declare function shouldAllowMcpEmbedCredentials(origin: string | null | undefined): boolean;
11
18
  export declare const MCP_EMBED_STATIC_ASSET_HEADERS: {
12
19
  readonly "Access-Control-Allow-Origin": "*";
@@ -8,6 +8,14 @@ const MCP_PRODUCT_HOST_ORIGINS = new Set([
8
8
  "https://chatgpt.com",
9
9
  "https://claude.ai",
10
10
  ]);
11
+ const TRUSTED_NATIVE_APP_ORIGIN_RE = /^(?:tauri:\/\/localhost|https?:\/\/tauri\.localhost(?::\d+)?)$/;
12
+ function isExplicitCorsAllowedOrigin(origin) {
13
+ return (process.env.CORS_ALLOWED_ORIGINS ?? "")
14
+ .split(",")
15
+ .map((value) => value.trim())
16
+ .filter(Boolean)
17
+ .includes(origin);
18
+ }
11
19
  export function isLocalMcpEmbedOrigin(origin) {
12
20
  if (!origin)
13
21
  return false;
@@ -97,12 +105,27 @@ export function isMcpEmbedCorsOrigin(origin) {
97
105
  isAgentNativeFirstPartyAppOrigin(origin) ||
98
106
  isBuilderIoEmbedOrigin(origin));
99
107
  }
108
+ /**
109
+ * Origins allowed to read the one-time embed location returned by a browser
110
+ * transplant request. Builder and localhost origins may use the broader MCP
111
+ * CORS surface, but must not receive a reusable session location unless they
112
+ * are explicitly configured through CORS_ALLOWED_ORIGINS.
113
+ */
114
+ export function isMcpEmbedTransplantOrigin(origin) {
115
+ return (isClaudeMcpContentOrigin(origin) ||
116
+ isChatGptMcpSandboxOrigin(origin) ||
117
+ isMcpProductHostOrigin(origin) ||
118
+ isAgentNativeFirstPartyAppOrigin(origin));
119
+ }
100
120
  export function shouldAllowMcpEmbedCredentials(origin) {
101
- return (origin !== "null" &&
102
- !isClaudeMcpContentOrigin(origin) &&
103
- !isChatGptMcpSandboxOrigin(origin) &&
104
- !isMcpProductHostOrigin(origin) &&
105
- !isAgentNativeFirstPartyAppOrigin(origin));
121
+ if (!origin || origin === "null")
122
+ return false;
123
+ // Credentialed CORS is an explicit deployment decision. MCP product,
124
+ // Builder, localhost, and arbitrary origins use bearer/embed credentials;
125
+ // only the configured browser allowlist and the framework's exact native
126
+ // app origins may receive cookies.
127
+ return (TRUSTED_NATIVE_APP_ORIGIN_RE.test(origin) ||
128
+ isExplicitCorsAllowedOrigin(origin));
106
129
  }
107
130
  // These paths are served straight off the CDN, so the security-headers h3
108
131
  // middleware never runs for them — anything it sets that must also hold for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.157.18",
3
+ "version": "0.157.20",
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": {