@agent-native/core 0.201.0 → 0.201.1-nightly-20261005213104

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.
@@ -11,9 +11,9 @@ declare const _default: import("../../action.js").ActionDefinition<{
11
11
  enabled?: undefined;
12
12
  nextRun?: undefined;
13
13
  } | {
14
+ deleted?: undefined;
14
15
  name: string;
15
16
  enabled: boolean;
16
17
  nextRun: string;
17
- deleted?: undefined;
18
18
  }>;
19
19
  export default _default;
@@ -849,7 +849,7 @@ function openAiWidgetCsp(cspConfig, requestMeta) {
849
849
  csp.frame_domains = frameDomains;
850
850
  return Object.keys(csp).length > 0 ? csp : undefined;
851
851
  }
852
- function mcpAppUiMeta(resource, resolvedCsp, requestMeta, description, widgetDomain) {
852
+ function mcpAppUiMeta(resource, resolvedCsp, requestMeta, description, widgetDomain, directoryMode = false) {
853
853
  const base = resource._meta && typeof resource._meta === "object"
854
854
  ? { ...resource._meta }
855
855
  : {};
@@ -858,13 +858,28 @@ function mcpAppUiMeta(resource, resolvedCsp, requestMeta, description, widgetDom
858
858
  : {};
859
859
  const ui = { ...existingUi };
860
860
  delete ui.domain;
861
+ if (directoryMode &&
862
+ ui.csp &&
863
+ typeof ui.csp === "object" &&
864
+ !Array.isArray(ui.csp)) {
865
+ const csp = { ...ui.csp };
866
+ delete csp.baseUriDomains;
867
+ ui.csp = csp;
868
+ }
861
869
  if (resolvedCsp) {
870
+ const csp = { ...resolvedCsp };
871
+ if (directoryMode)
872
+ delete csp.baseUriDomains;
862
873
  ui.csp = {
863
- ...resolvedCsp,
874
+ ...csp,
864
875
  connectDomains: expandRequestOriginSources(resolvedCsp.connectDomains, requestMeta),
865
876
  resourceDomains: expandRequestOriginSources(resolvedCsp.resourceDomains, requestMeta),
866
877
  frameDomains: expandRequestOriginSources(resolvedCsp.frameDomains, requestMeta),
867
- baseUriDomains: expandRequestOriginSources(resolvedCsp.baseUriDomains, requestMeta),
878
+ ...(!directoryMode
879
+ ? {
880
+ baseUriDomains: expandRequestOriginSources(resolvedCsp.baseUriDomains, requestMeta),
881
+ }
882
+ : {}),
868
883
  };
869
884
  }
870
885
  if (resource.permissions)
@@ -923,7 +938,7 @@ async function resolveMcpAppResource(config, actionName, entry, requestMeta) {
923
938
  requestOrigin: requestMeta?.origin,
924
939
  catalogMode: config.catalogMode,
925
940
  });
926
- const resourceMeta = mcpAppUiMeta(resource, resolvedCsp, requestMeta, description, config.catalogMode === "directory" ? config.widgetDomain : undefined);
941
+ const resourceMeta = mcpAppUiMeta(resource, resolvedCsp, requestMeta, description, config.catalogMode === "directory" ? config.widgetDomain : undefined, config.catalogMode === "directory");
927
942
  return {
928
943
  uri: resolvedUri.uri,
929
944
  ...(resolvedUri.legacyUris ? { legacyUris: resolvedUri.legacyUris } : {}),
@@ -98,7 +98,6 @@ export function embedApp(options = {}) {
98
98
  const nativeBridgeInitializeTimeoutMs = 5000;
99
99
  const nativeBridgeRequestTimeoutMs = 30000;
100
100
  const wrapperRequestTimeoutMs = 5000;
101
- const remoteBridgeFallbackEnabled = ${remoteBridgeFallbackEnabled};
102
101
  let app = null;
103
102
  let appConnectPromise = null;
104
103
  let openAiBridge = null;
@@ -2144,7 +2143,8 @@ export function embedApp(options = {}) {
2144
2143
  sendHostContext();
2145
2144
  }
2146
2145
 
2147
- async function startMcpAppsBridge() {
2146
+ ${remoteBridgeFallbackEnabled
2147
+ ? `async function startMcpAppsBridge() {
2148
2148
  const { App } = await import("${MCP_APP_IMPORT}");
2149
2149
  app = new App(
2150
2150
  { name: "Agent-Native Embed", version: "1.0.0" },
@@ -2174,7 +2174,8 @@ export function embedApp(options = {}) {
2174
2174
  updateDisplayButton();
2175
2175
  notifyHostHeight();
2176
2176
  sendHostContext();
2177
- }
2177
+ }`
2178
+ : ""}
2178
2179
 
2179
2180
  try {
2180
2181
  const initialOpenAiBridge = await waitForOpenAiBridge();
@@ -2183,8 +2184,7 @@ export function embedApp(options = {}) {
2183
2184
  await startNativeMcpAppsBridge();
2184
2185
  } catch (nativeErr) {
2185
2186
  console.warn("[agent-native] native MCP Apps bridge failed", nativeErr);
2186
- if (!remoteBridgeFallbackEnabled) throw nativeErr;
2187
- await startMcpAppsBridge();
2187
+ ${remoteBridgeFallbackEnabled ? "await startMcpAppsBridge();" : "throw nativeErr;"}
2188
2188
  }
2189
2189
  }
2190
2190
  } catch (err) {
@@ -2,24 +2,6 @@ import type { H3Event } from "h3";
2
2
  import { createMCPServerForRequest, verifyAuth, getAccessTokens, resolveOrgIdFromDomain, buildLinkArtifacts, type MCPConfig, type MCPCallerIdentity, type MCPRequestMeta } from "./build-server.js";
3
3
  export { createMCPServerForRequest, verifyAuth, getAccessTokens, resolveOrgIdFromDomain, buildLinkArtifacts, };
4
4
  export type { MCPConfig, MCPCallerIdentity, MCPRequestMeta };
5
- /**
6
- * Handle a single `{routePrefix}/mcp` request on either runtime.
7
- *
8
- * Builds one request-scoped MCP `Server` from the verified caller identity and
9
- * drives it through the SDK's v2 `createMcpHandler`. That entry serves native
10
- * 2026-07-28 envelopes and stateless 2025-era traffic from the same factory,
11
- * so protocol generations cannot drift apart.
12
- *
13
- * The handler is Web Standard on every runtime. H3 owns the Node response when
14
- * one exists, avoiding the double-write race from a transport writing directly
15
- * to `node.res`.
16
- *
17
- * Returns:
18
- * - `undefined` when the request targets a sub-route (so management/status
19
- * routes mounted under `/_agent-native/mcp/*` handle it themselves) — the
20
- * h3 mount falls through to the next handler.
21
- * - a Web `Response` or an auth-error object otherwise.
22
- */
23
5
  export declare function handleMcpRequest(event: H3Event, config: MCPConfig, routePath?: string): Promise<Response | string | {
24
6
  error: string;
25
7
  } | Record<string, unknown> | undefined>;
@@ -121,6 +121,51 @@ function buildUnauthorizedBody(event, routePath = MCP_PUBLIC_ROUTE_PREFIX) {
121
121
  };
122
122
  }
123
123
  const loggedDirectoryProfileFailures = new Set();
124
+ const directoryLogMethods = new Set([
125
+ "initialize",
126
+ "notifications/initialized",
127
+ "server/discover",
128
+ "tools/list",
129
+ "tools/call",
130
+ "resources/list",
131
+ "resources/templates/list",
132
+ "resources/read",
133
+ "prompts/list",
134
+ "prompts/get",
135
+ "ping",
136
+ ]);
137
+ function directoryLogMethod(body) {
138
+ if (!body || typeof body !== "object")
139
+ return undefined;
140
+ if (Array.isArray(body))
141
+ return "batch";
142
+ const method = body.method;
143
+ if (typeof method !== "string")
144
+ return "other";
145
+ return directoryLogMethods.has(method) ? method : "other";
146
+ }
147
+ function responseStatusFromEvent(event) {
148
+ const status = event.res?.status ??
149
+ event.node?.res?.statusCode ??
150
+ event._status;
151
+ return typeof status === "number" && Number.isInteger(status) && status > 0
152
+ ? status
153
+ : 200;
154
+ }
155
+ function responseStatusFromError(error) {
156
+ if (!error || typeof error !== "object")
157
+ return undefined;
158
+ const status = error;
159
+ for (const candidate of [status.status, status.statusCode]) {
160
+ if (typeof candidate === "number" &&
161
+ Number.isInteger(candidate) &&
162
+ candidate >= 100 &&
163
+ candidate <= 599) {
164
+ return candidate;
165
+ }
166
+ }
167
+ return undefined;
168
+ }
124
169
  function directoryProfileUnavailable(event, validationError) {
125
170
  const failureKey = `${validationError.code}\0${validationError.message}`;
126
171
  if (!loggedDirectoryProfileFailures.has(failureKey)) {
@@ -155,7 +200,7 @@ function directoryProfileUnavailable(event, validationError) {
155
200
  * h3 mount falls through to the next handler.
156
201
  * - a Web `Response` or an auth-error object otherwise.
157
202
  */
158
- export async function handleMcpRequest(event, config, routePath = MCP_PUBLIC_ROUTE_PREFIX) {
203
+ async function handleMcpRequestInternal(event, config, routePath = MCP_PUBLIC_ROUTE_PREFIX, onMcpMethod) {
159
204
  const pathname = event.url?.pathname || "/";
160
205
  const subpath = pathname.replace(/^\/+/, "").replace(/\/+$/, "");
161
206
  if (subpath) {
@@ -207,6 +252,7 @@ export async function handleMcpRequest(event, config, routePath = MCP_PUBLIC_ROU
207
252
  return buildUnauthorizedBody(event, routePath);
208
253
  }
209
254
  const body = method === "POST" ? await readBody(event) : undefined;
255
+ onMcpMethod?.(directoryLogMethod(body) ?? method);
210
256
  const initializeRequest = body
211
257
  ? (Array.isArray(body) ? body : [body]).find((m) => typeof m === "object" &&
212
258
  m !== null &&
@@ -266,6 +312,37 @@ export async function handleMcpRequest(event, config, routePath = MCP_PUBLIC_ROU
266
312
  const webRequest = buildWebRequest(event, method, routePath);
267
313
  return handler.fetch(webRequest, method === "POST" ? { parsedBody: body } : undefined);
268
314
  }
315
+ export async function handleMcpRequest(event, config, routePath = MCP_PUBLIC_ROUTE_PREFIX) {
316
+ const pathname = event.url?.pathname || "/";
317
+ const subpath = pathname.replace(/^\/+/, "").replace(/\/+$/, "");
318
+ const isDirectoryRequest = routePath === MCP_DIRECTORY_ROUTE_PREFIX && !subpath;
319
+ const startedAt = performance.now();
320
+ let method = getMethod(event);
321
+ let status = 500;
322
+ try {
323
+ const result = await handleMcpRequestInternal(event, config, routePath, (requestMethod) => {
324
+ method = requestMethod;
325
+ });
326
+ status =
327
+ result instanceof Response
328
+ ? result.status
329
+ : responseStatusFromEvent(event);
330
+ return result;
331
+ }
332
+ catch (error) {
333
+ status = responseStatusFromError(error) ?? 500;
334
+ throw error;
335
+ }
336
+ finally {
337
+ if (isDirectoryRequest) {
338
+ console.info("[mcp:directory] request", {
339
+ method,
340
+ status,
341
+ durationMs: Math.max(0, Math.round(performance.now() - startedAt)),
342
+ });
343
+ }
344
+ }
345
+ }
269
346
  export function mountMCP(nitroApp, config, routePrefix = "/_agent-native") {
270
347
  const routePaths = routePrefix === "/_agent-native"
271
348
  ? [...MCP_ROUTE_PREFIXES]
@@ -1,13 +1,13 @@
1
1
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
2
2
  count: number;
3
3
  updated?: undefined;
4
- ok?: undefined;
5
4
  error?: undefined;
5
+ ok?: undefined;
6
6
  } | {
7
7
  count?: undefined;
8
8
  updated: number;
9
- ok?: undefined;
10
9
  error?: undefined;
10
+ ok?: undefined;
11
11
  } | {
12
12
  count?: undefined;
13
13
  updated?: undefined;
@@ -16,6 +16,6 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
16
16
  } | {
17
17
  count?: undefined;
18
18
  updated?: undefined;
19
- ok: boolean;
20
19
  error?: undefined;
20
+ ok: boolean;
21
21
  }>>;
@@ -27,38 +27,38 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
27
27
  thumbsUpRate: number;
28
28
  avgEvalScore: number;
29
29
  } | {
30
+ id?: undefined;
31
+ ok?: undefined;
30
32
  error: string;
31
33
  message: string;
32
34
  summary?: undefined;
33
35
  spans?: undefined;
36
+ } | {
34
37
  id?: undefined;
38
+ error?: undefined;
35
39
  ok?: undefined;
36
- } | {
37
40
  message?: undefined;
38
41
  summary: import("./types.js").TraceSummary;
39
42
  spans: import("./types.js").TraceSpan[];
40
- id?: undefined;
43
+ } | {
41
44
  error?: undefined;
42
45
  ok?: undefined;
43
- } | {
44
46
  message?: undefined;
45
47
  summary?: undefined;
46
48
  spans?: undefined;
47
49
  id: string;
48
- error?: undefined;
49
- ok?: undefined;
50
50
  } | {
51
+ id?: undefined;
52
+ ok?: undefined;
51
53
  message?: undefined;
52
54
  summary?: undefined;
53
55
  spans?: undefined;
54
- id?: undefined;
55
56
  error: any;
56
- ok?: undefined;
57
57
  } | {
58
+ id?: undefined;
59
+ error?: undefined;
58
60
  message?: undefined;
59
61
  summary?: undefined;
60
62
  spans?: undefined;
61
- id?: undefined;
62
- error?: undefined;
63
63
  ok: boolean;
64
64
  }>>;
@@ -72,9 +72,9 @@ export declare const setWorkspaceAppDefaultVisibilityHandler: import("h3").Event
72
72
  }>>;
73
73
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
74
74
  success: boolean;
75
+ id?: undefined;
75
76
  name?: undefined;
76
77
  role?: undefined;
77
- id?: undefined;
78
78
  } | {
79
79
  success?: undefined;
80
80
  id: string;
@@ -2,6 +2,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
2
2
  error: string;
3
3
  ok?: undefined;
4
4
  } | {
5
- ok: boolean;
6
5
  error?: undefined;
6
+ ok: boolean;
7
7
  }>>;
@@ -39,8 +39,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
39
39
  error: string;
40
40
  }>;
41
41
  export declare function handleDeleteResource(event: any): Promise<{
42
- error: string;
43
42
  ok?: undefined;
43
+ error: string;
44
44
  } | {
45
45
  error?: undefined;
46
46
  ok: boolean;
@@ -65,6 +65,7 @@ export declare function createAgentEngineApiKeyHandler(): import("h3").EventHand
65
65
  error: any;
66
66
  code: any;
67
67
  } | {
68
+ error?: undefined;
68
69
  errorCode?: undefined;
69
70
  code?: undefined;
70
71
  ok: boolean;
@@ -72,6 +73,5 @@ export declare function createAgentEngineApiKeyHandler(): import("h3").EventHand
72
73
  baseUrlKey?: string;
73
74
  scope: AgentEngineApiKeyScope;
74
75
  defaultModel?: import("./agent-engine-default-model-route.js").SavedKeyDefaultModelOutcome;
75
- error?: undefined;
76
76
  }>>;
77
77
  export {};
@@ -8,17 +8,17 @@ export declare const AGENT_ENGINE_API_KEY_ACTION_NAME = "agent-engine-api-key";
8
8
  * resolveEngine's credential detection.
9
9
  */
10
10
  export declare function createAgentEngineDisconnectHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
11
- error: string;
12
11
  ok?: undefined;
12
+ error: string;
13
13
  scope?: undefined;
14
14
  } | {
15
15
  ok: boolean;
16
16
  error: any;
17
17
  scope?: undefined;
18
18
  } | {
19
+ error?: undefined;
19
20
  ok: boolean;
20
21
  scope: "org" | "user";
21
- error?: undefined;
22
22
  }>>;
23
23
  export interface DefaultModelSelectionRequest {
24
24
  engine: string;
@@ -1,9 +1,9 @@
1
1
  export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
2
2
  error: string;
3
- models?: undefined;
4
3
  ok?: undefined;
4
+ models?: undefined;
5
5
  } | {
6
+ error?: undefined;
6
7
  ok: boolean;
7
8
  models: string[];
8
- error?: undefined;
9
9
  }>>;
@@ -13,6 +13,8 @@ declare const _default: import("../../action.js").ActionDefinition<{
13
13
  executionEngine?: string;
14
14
  executionCwd?: string;
15
15
  }, {
16
+ deleted?: undefined;
17
+ enabled?: undefined;
16
18
  created: boolean;
17
19
  name: string;
18
20
  scope: "organization" | "personal";
@@ -23,33 +25,31 @@ declare const _default: import("../../action.js").ActionDefinition<{
23
25
  reasoningEffort: "auto" | "high" | "low" | "max" | "medium" | "minimal" | "none" | "xhigh";
24
26
  webhookPath: string;
25
27
  nextRun: string;
26
- deleted?: undefined;
27
- enabled?: undefined;
28
28
  executionHostId?: undefined;
29
29
  executionEngine?: undefined;
30
30
  executionCwd?: undefined;
31
31
  } | {
32
+ enabled?: undefined;
33
+ nextRun?: undefined;
32
34
  created?: undefined;
33
35
  scope?: undefined;
34
36
  triggerType?: undefined;
35
37
  event?: undefined;
36
38
  deleted: boolean;
37
39
  name: string;
38
- enabled?: undefined;
39
40
  schedule?: undefined;
40
41
  timezone?: undefined;
41
42
  reasoningEffort?: undefined;
42
43
  executionHostId?: undefined;
43
44
  executionEngine?: undefined;
44
45
  executionCwd?: undefined;
45
- nextRun?: undefined;
46
46
  webhookPath?: undefined;
47
47
  } | {
48
+ deleted?: undefined;
48
49
  created?: undefined;
49
50
  scope?: undefined;
50
51
  triggerType?: undefined;
51
52
  event?: undefined;
52
- deleted?: undefined;
53
53
  name: string;
54
54
  enabled: boolean;
55
55
  schedule: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.201.0",
3
+ "version": "0.201.1-nightly-20261005213104",
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": {
@@ -669,7 +669,7 @@
669
669
  "yaml": "^2.9.0",
670
670
  "yjs": "^13.6.33",
671
671
  "zod": "^4.3.6",
672
- "@agent-native/agentkit": "^0.201.0",
672
+ "@agent-native/agentkit": "^0.201.1-nightly-20261005213104",
673
673
  "@agent-native/recap-cli": "^0.5.61"
674
674
  },
675
675
  "devDependencies": {
@@ -740,7 +740,7 @@
740
740
  "xlsx": "^0.18.5"
741
741
  },
742
742
  "peerDependencies": {
743
- "@agent-native/core-corpus": ">=0.196.0",
743
+ "@agent-native/core-corpus": "0.201.1-nightly-20261005213104",
744
744
  "@ai-sdk/anthropic": ">=3",
745
745
  "@ai-sdk/cohere": ">=3",
746
746
  "@ai-sdk/google": ">=3",