@agent-native/core 0.236.0 → 0.236.1-nightly-20261130212440

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "@agent-native/actions": "0.1.1",
3
- "@agent-native/agentkit": "0.236.0",
3
+ "@agent-native/agentkit": "0.236.1-nightly-20261130212440",
4
4
  "@agent-native/code-agents-ui": "0.1.75",
5
- "@agent-native/core": "0.236.0",
6
- "@agent-native/core-corpus": "0.236.0",
5
+ "@agent-native/core": "0.236.1-nightly-20261130212440",
6
+ "@agent-native/core-corpus": "0.236.1-nightly-20261130212440",
7
7
  "@agent-native/creative-context": "0.8.81",
8
- "@agent-native/design-system": "0.236.0",
9
- "@agent-native/dispatch": "0.43.5",
8
+ "@agent-native/design-system": "0.236.1-nightly-20261130212440",
9
+ "@agent-native/dispatch": "0.43.6-nightly-20261130212440",
10
10
  "@agent-native/embedding": "0.2.0",
11
11
  "@agent-native/migrate": "0.0.7",
12
12
  "@agent-native/otel": "0.1.48",
@@ -14,6 +14,6 @@
14
14
  "@agent-native/recap-cli": "0.5.112",
15
15
  "@agent-native/scheduling": "0.4.5",
16
16
  "@agent-native/shared-app-config": "0.1.2",
17
- "@agent-native/skills": "0.4.16",
18
- "@agent-native/toolkit": "0.236.0"
17
+ "@agent-native/skills": "0.4.17-nightly-20261130212440",
18
+ "@agent-native/toolkit": "0.236.1-nightly-20261130212440"
19
19
  }
@@ -42,6 +42,15 @@
42
42
  * Those are listed in `CSRF_ALLOWLIST_PREFIXES` below; if you add a new
43
43
  * cross-origin-callable route, add it there.
44
44
  */
45
+ /**
46
+ * Exempts one exact app `/api/*` path from the CSRF check. No patterns,
47
+ * parameters, prefixes, or trailing slash. Requests to an exempt path reach
48
+ * the handler without cookies or a session, so it must authenticate on the
49
+ * request itself, such as a public ingestion key or a signature. Where the
50
+ * runtime's request headers are immutable, a cookie-carrying request to an
51
+ * exempt path is refused with 403 instead.
52
+ */
53
+ export declare function registerCsrfExemptPath(path: string): void;
45
54
  export declare function createCsrfMiddleware(frameworkPrefix?: string): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, {
46
55
  error: string;
47
56
  } | undefined>;
@@ -98,6 +98,42 @@ const CSRF_ALLOWLIST_PREFIXES = [
98
98
  "/builder/callback",
99
99
  ];
100
100
  const STATE_CHANGING_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
101
+ const CSRF_EXEMPT_API_PATHS = new Set();
102
+ const EXACT_API_PATH = /^\/api(?:\/[A-Za-z0-9._~-]+)+$/;
103
+ /**
104
+ * Exempts one exact app `/api/*` path from the CSRF check. No patterns,
105
+ * parameters, prefixes, or trailing slash. Requests to an exempt path reach
106
+ * the handler without cookies or a session, so it must authenticate on the
107
+ * request itself, such as a public ingestion key or a signature. Where the
108
+ * runtime's request headers are immutable, a cookie-carrying request to an
109
+ * exempt path is refused with 403 instead.
110
+ */
111
+ export function registerCsrfExemptPath(path) {
112
+ if (!EXACT_API_PATH.test(path) ||
113
+ path.split("/").some((segment) => segment === "." || segment === "..")) {
114
+ throw new Error(`registerCsrfExemptPath: "${path}" must be one exact /api/* path, with no patterns, parameters, or trailing slash.`);
115
+ }
116
+ CSRF_EXEMPT_API_PATHS.add(path);
117
+ }
118
+ function deleteCookieHeader(headers) {
119
+ try {
120
+ headers.delete("cookie");
121
+ }
122
+ catch (error) {
123
+ if (error instanceof TypeError)
124
+ return false;
125
+ throw error;
126
+ }
127
+ return !headers.has("cookie");
128
+ }
129
+ function isCsrfExemptApiPath(pathname) {
130
+ if (CSRF_EXEMPT_API_PATHS.has(pathname))
131
+ return true;
132
+ const basePath = getConfiguredAppBasePath();
133
+ return (Boolean(basePath) &&
134
+ pathname.startsWith(`${basePath}/`) &&
135
+ CSRF_EXEMPT_API_PATHS.has(pathname.slice(basePath.length)));
136
+ }
101
137
  function looksFirstParty(event) {
102
138
  const sfs = getRequestHeader(event, "sec-fetch-site");
103
139
  if (sfs === "same-origin" || sfs === "none") {
@@ -180,6 +216,16 @@ export function createCsrfMiddleware(frameworkPrefix = "/_agent-native") {
180
216
  else if (!isTemplateApiPath(pathname)) {
181
217
  return undefined;
182
218
  }
219
+ else if (isCsrfExemptApiPath(pathname)) {
220
+ if (!requestHasCookies(event))
221
+ return undefined;
222
+ if (deleteCookieHeader(event.req.headers))
223
+ return undefined;
224
+ setResponseStatus(event, 403);
225
+ return {
226
+ error: 'CSRF check failed: this route accepts no cookies, and this runtime could not remove them. Send the request with credentials: "omit".',
227
+ };
228
+ }
183
229
  if (!requestHasCookies(event))
184
230
  return undefined;
185
231
  if (looksFirstParty(event))
@@ -135,6 +135,7 @@ export { scheduledTriggerAvailability, type ScheduledTriggerAvailability, } from
135
135
  export { getAppProductionUrl, getFirstPartyProdUrl, resolveAppRuntimeUrl, } from "./app-url.js";
136
136
  export { getForwardedRequestOrigin, getForwardedRequestURL, } from "./request-origin.js";
137
137
  export { getConfiguredAppBasePath, normalizeAppBasePath, withConfiguredAppBasePath, } from "./app-base-path.js";
138
+ export { registerCsrfExemptPath } from "./csrf.js";
138
139
  export { signShortLivedToken, verifyShortLivedToken, type ShortLivedTokenClaims, type ShortLivedTokenKeyOptions, type VerifyResult as ShortLivedTokenVerifyResult, } from "./short-lived-token.js";
139
140
  export { AGENT_ACCESS_PARAM, DEFAULT_AGENT_ACCESS_TTL_SECONDS, appendAgentAccessParam, buildAgentAccessApiUrl, buildAgentAccessUrl, createScopedAgentAccessGrant, normalizeAgentAccessBasePath, normalizeAgentAccessOrigin, scopedAgentAccessResourceId, signScopedAgentAccessToken, toAgentAccessUrl, verifyScopedAgentAccessToken, type AgentAccessApiUrlOptions, type AgentAccessResourceScope, type AgentAccessUrlOptions, type ScopedAgentAccessGrant, type ScopedAgentAccessTokenOptions, } from "./agent-access.js";
140
141
  export { AGENT_READABLE_RESOURCE_PAYLOAD_TYPE, AGENT_READABLE_RESOURCE_SCRIPT_TYPE, buildAgentReadableResourceDiscovery, renderAgentReadableResourceDiscoveryScript, safeJsonForHtml, type AgentReadableResourceDiscovery, type BuildAgentReadableResourceDiscoveryOptions, } from "../shared/agent-readable-resource.js";
@@ -128,6 +128,7 @@ export { scheduledTriggerAvailability, } from "./agent-chat/recurring-jobs-runti
128
128
  export { getAppProductionUrl, getFirstPartyProdUrl, resolveAppRuntimeUrl, } from "./app-url.js";
129
129
  export { getForwardedRequestOrigin, getForwardedRequestURL, } from "./request-origin.js";
130
130
  export { getConfiguredAppBasePath, normalizeAppBasePath, withConfiguredAppBasePath, } from "./app-base-path.js";
131
+ export { registerCsrfExemptPath } from "./csrf.js";
131
132
  export { signShortLivedToken, verifyShortLivedToken, } from "./short-lived-token.js";
132
133
  export { AGENT_ACCESS_PARAM, DEFAULT_AGENT_ACCESS_TTL_SECONDS, appendAgentAccessParam, buildAgentAccessApiUrl, buildAgentAccessUrl, createScopedAgentAccessGrant, normalizeAgentAccessBasePath, normalizeAgentAccessOrigin, scopedAgentAccessResourceId, signScopedAgentAccessToken, toAgentAccessUrl, verifyScopedAgentAccessToken, } from "./agent-access.js";
133
134
  export { AGENT_READABLE_RESOURCE_PAYLOAD_TYPE, AGENT_READABLE_RESOURCE_SCRIPT_TYPE, buildAgentReadableResourceDiscovery, renderAgentReadableResourceDiscoveryScript, safeJsonForHtml, } from "../shared/agent-readable-resource.js";
package/dist/testing.d.ts CHANGED
@@ -2,6 +2,7 @@ export { createGetDb } from "./db/create-get-db.js";
2
2
  export { AGENT_PATH_PROVIDERS, conformanceMcpConfig, DIRECTORY_PROFILE_MODULE, listAgentToolSchemas, listMcpCatalogTools, loadTemplateDirectoryProfile, loadTemplateMcpActions, loadTemplateMcpConformance, MCP_CATALOG_MODES, PROVIDER_SCHEMA_RULES, providerSchemaViolations, SCHEMA_PROVIDERS, templateMcpCatalogModes, type AgentToolSchema, type McpCatalogMode, type McpDirectoryProfileFixture, type ProviderRuleBasis, type ProviderSchemaRule, type ProviderSchemaViolation, type SchemaProvider, type TemplateMcpConformance, } from "./mcp/provider-schema-conformance.js";
3
3
  export { startLocalPlanBridge } from "./cli/plan-local.js";
4
4
  export { readDevActionDiscoveryFile } from "./server/dev-action-discovery.js";
5
+ export { createCsrfMiddleware } from "./server/csrf.js";
5
6
  export { prepareDesignConnectManifest, startDesignConnectBridge, type DesignConnectBridge, } from "./cli/design-connect.js";
6
7
  export { assertNoInlineImageBytes } from "./shared/inline-bytes.js";
7
8
  export { createMemorySearchVectorStore, type MemorySearchVectorStore, } from "./search/memory-vector-store.js";
package/dist/testing.js CHANGED
@@ -2,6 +2,7 @@ export { createGetDb } from "./db/create-get-db.js";
2
2
  export { AGENT_PATH_PROVIDERS, conformanceMcpConfig, DIRECTORY_PROFILE_MODULE, listAgentToolSchemas, listMcpCatalogTools, loadTemplateDirectoryProfile, loadTemplateMcpActions, loadTemplateMcpConformance, MCP_CATALOG_MODES, PROVIDER_SCHEMA_RULES, providerSchemaViolations, SCHEMA_PROVIDERS, templateMcpCatalogModes, } from "./mcp/provider-schema-conformance.js";
3
3
  export { startLocalPlanBridge } from "./cli/plan-local.js";
4
4
  export { readDevActionDiscoveryFile } from "./server/dev-action-discovery.js";
5
+ export { createCsrfMiddleware } from "./server/csrf.js";
5
6
  export { prepareDesignConnectManifest, startDesignConnectBridge, } from "./cli/design-connect.js";
6
7
  export { assertNoInlineImageBytes } from "./shared/inline-bytes.js";
7
8
  export { createMemorySearchVectorStore, } from "./search/memory-vector-store.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.236.0",
3
+ "version": "0.236.1-nightly-20261130212440",
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": {
@@ -833,7 +833,7 @@
833
833
  "yjs": "^13.6.33",
834
834
  "zod": "^4.3.6",
835
835
  "@agent-native/actions": "^0.1.1",
836
- "@agent-native/agentkit": "^0.236.0",
836
+ "@agent-native/agentkit": "^0.236.1-nightly-20261130212440",
837
837
  "@agent-native/recap-cli": "^0.5.112"
838
838
  },
839
839
  "devDependencies": {
@@ -908,7 +908,7 @@
908
908
  "xlsx": "^0.18.5"
909
909
  },
910
910
  "peerDependencies": {
911
- "@agent-native/core-corpus": ">=0.196.0",
911
+ "@agent-native/core-corpus": "0.236.1-nightly-20261130212440",
912
912
  "@ai-sdk/anthropic": ">=3",
913
913
  "@ai-sdk/cohere": ">=3",
914
914
  "@ai-sdk/google": ">=3",