@agent-native/core 0.157.13 → 0.157.15

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.
@@ -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;
65
66
  states: {
66
67
  clientId: number;
67
68
  state: string;
68
69
  }[];
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;
80
81
  users: {
81
82
  clientId: number;
82
83
  lastSeen: number;
83
84
  }[];
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;
@@ -17,11 +17,11 @@ declare const _default: import("../../action.js").ActionDefinition<{
17
17
  id?: undefined;
18
18
  provider?: undefined;
19
19
  } | {
20
+ error?: undefined;
20
21
  configured?: undefined;
21
22
  connectPath?: undefined;
22
23
  url: string;
23
24
  id: string;
24
25
  provider: string;
25
- error?: undefined;
26
26
  }>;
27
27
  export default _default;
@@ -137,13 +137,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
137
137
  inputSchema: {
138
138
  type: string;
139
139
  properties: {
140
+ count?: undefined;
140
141
  query?: undefined;
141
142
  minutes?: undefined;
142
143
  limit?: undefined;
143
144
  clientHint?: undefined;
144
145
  timestamp?: undefined;
145
146
  chapterId?: undefined;
146
- count?: undefined;
147
147
  startAt?: undefined;
148
148
  endAt?: undefined;
149
149
  reason?: undefined;
@@ -159,6 +159,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
159
159
  inputSchema: {
160
160
  type: string;
161
161
  properties: {
162
+ count?: undefined;
162
163
  query: {
163
164
  type: string;
164
165
  description: string;
@@ -174,7 +175,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
174
175
  clientHint?: undefined;
175
176
  timestamp?: undefined;
176
177
  chapterId?: undefined;
177
- count?: undefined;
178
178
  startAt?: undefined;
179
179
  endAt?: undefined;
180
180
  reason?: undefined;
@@ -190,6 +190,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
190
190
  inputSchema: {
191
191
  type: string;
192
192
  properties: {
193
+ count?: undefined;
193
194
  minutes: {
194
195
  type: string;
195
196
  description: string;
@@ -199,7 +200,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
199
200
  clientHint?: undefined;
200
201
  timestamp?: undefined;
201
202
  chapterId?: undefined;
202
- count?: undefined;
203
203
  startAt?: undefined;
204
204
  endAt?: undefined;
205
205
  reason?: undefined;
@@ -216,6 +216,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
216
216
  type: string;
217
217
  required: string[];
218
218
  properties: {
219
+ count?: undefined;
219
220
  query: {
220
221
  type: string;
221
222
  description: string;
@@ -234,7 +235,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
234
235
  };
235
236
  timestamp?: undefined;
236
237
  chapterId?: undefined;
237
- count?: undefined;
238
238
  startAt?: undefined;
239
239
  endAt?: undefined;
240
240
  reason?: undefined;
@@ -250,6 +250,7 @@ export declare function screenMemoryMcpToolDefinitions(): ({
250
250
  type: string;
251
251
  required: string[];
252
252
  properties: {
253
+ count?: undefined;
253
254
  query?: undefined;
254
255
  minutes?: undefined;
255
256
  limit?: undefined;
@@ -263,7 +264,6 @@ export declare function screenMemoryMcpToolDefinitions(): ({
263
264
  description: string;
264
265
  };
265
266
  chapterId?: undefined;
266
- count?: undefined;
267
267
  startAt?: undefined;
268
268
  endAt?: undefined;
269
269
  includeMicrophone?: undefined;
@@ -314,13 +314,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
314
314
  type: string;
315
315
  required: string[];
316
316
  properties: {
317
+ count?: undefined;
317
318
  query?: undefined;
318
319
  minutes?: undefined;
319
320
  limit?: undefined;
320
321
  clientHint?: undefined;
321
322
  timestamp?: undefined;
322
323
  chapterId?: undefined;
323
- count?: undefined;
324
324
  startAt: {
325
325
  type: string;
326
326
  description: string;
@@ -349,13 +349,13 @@ export declare function screenMemoryMcpToolDefinitions(): ({
349
349
  type: string;
350
350
  required: string[];
351
351
  properties: {
352
+ count?: undefined;
352
353
  query?: undefined;
353
354
  minutes?: undefined;
354
355
  limit?: undefined;
355
356
  clientHint?: undefined;
356
357
  timestamp?: undefined;
357
358
  chapterId?: undefined;
358
- count?: undefined;
359
359
  startAt?: undefined;
360
360
  endAt?: undefined;
361
361
  reason?: undefined;
@@ -16,18 +16,18 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
16
16
  error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
+ count?: undefined;
19
20
  updated: number;
20
21
  error?: undefined;
21
22
  ok?: undefined;
22
- count?: undefined;
23
23
  } | {
24
+ count?: undefined;
24
25
  updated?: undefined;
25
26
  error: string;
26
27
  ok?: undefined;
27
- count?: undefined;
28
28
  } | {
29
+ count?: undefined;
29
30
  updated?: undefined;
30
31
  error?: undefined;
31
32
  ok: boolean;
32
- count?: undefined;
33
33
  }>>;
@@ -41,23 +41,23 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- ok?: undefined;
45
44
  error?: undefined;
46
45
  summary: import("./types.js").TraceSummary;
47
46
  spans: import("./types.js").TraceSpan[];
48
47
  id?: undefined;
49
- } | {
50
48
  ok?: undefined;
49
+ } | {
51
50
  error?: undefined;
52
51
  summary?: undefined;
53
52
  spans?: undefined;
54
53
  id: string;
55
- } | {
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
62
  error?: undefined;
63
63
  summary?: undefined;
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- error?: undefined;
19
18
  ok: boolean;
19
+ error?: undefined;
20
20
  }>>;
@@ -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;
@@ -238,6 +238,7 @@ async function resolveRequestAuthCapability(event) {
238
238
  */
239
239
  export function mountActionRoutes(nitroApp, actions, options) {
240
240
  const mounted = [];
241
+ const app = getH3App(nitroApp);
241
242
  for (const [name, entry] of Object.entries(actions)) {
242
243
  // Skip agent-only actions
243
244
  if (entry.http === false)
@@ -250,9 +251,9 @@ export function mountActionRoutes(nitroApp, actions, options) {
250
251
  // auth guard rejects it; the action route still fails closed on invalid
251
252
  // or missing credentials.
252
253
  if (name === "list-feature-flags" || name === "set-feature-flag") {
253
- registerAuthPublicPaths([routePath]);
254
+ registerAuthPublicPaths([routePath], app);
254
255
  }
255
- getH3App(nitroApp).use(routePath, defineEventHandler(async (event) => {
256
+ app.use(routePath, defineEventHandler(async (event) => {
256
257
  const reqMethod = getMethod(event);
257
258
  const effectiveMethod = reqMethod === "HEAD" && method === "GET" ? "GET" : reqMethod;
258
259
  if (reqMethod === "OPTIONS") {
@@ -117,6 +117,11 @@ export interface AgentChatPluginOptions {
117
117
  * See {@link import("../action-routes.js").ActionRouteAuthAdapter}.
118
118
  */
119
119
  actionRouteAuth?: import("../action-routes.js").ActionRouteAuthAdapter;
120
+ /**
121
+ * Framework action paths that use `actionRouteAuth` instead of the browser
122
+ * session guard. The route handler still owns credential verification.
123
+ */
124
+ actionRoutePublicPaths?: string[];
120
125
  /**
121
126
  * Optional callback to append template-specific context to the system
122
127
  * prompt on each request. Runs after AGENTS.md / skills / memory are
@@ -41,7 +41,7 @@ import { handleSharedThreadRequest, } from "./agent-chat/shared-thread.js";
41
41
  import { discoverAgents } from "./agent-discovery.js";
42
42
  import { resolveAgentRunOwnerContext, runWithAgentRunContext, seedBackgroundAgentRunOwnerContext, } from "./agent-run-context.js";
43
43
  import { AGENT_TEAM_PROCESS_RUN_PATH, getCurrentDelegationDepth, processAgentTeamRun, reconcileAgentTeamRunsForOwner, } from "./agent-teams.js";
44
- import { getSession } from "./auth.js";
44
+ import { getSession, registerAuthPublicPaths } from "./auth.js";
45
45
  import { captureError } from "./capture-error.js";
46
46
  import { getH3App, markDefaultPluginProvided, trackPluginInit, } from "./framework-request-handler.js";
47
47
  import { getOrigin } from "./google-oauth.js";
@@ -2035,6 +2035,9 @@ export function createAgentChatPlugin(options) {
2035
2035
  }
2036
2036
  if (Object.keys(httpActions).length > 0) {
2037
2037
  const { mountActionRoutes } = await import("./action-routes.js");
2038
+ if (options?.actionRoutePublicPaths?.length) {
2039
+ registerAuthPublicPaths(options.actionRoutePublicPaths, getH3App(nitroApp));
2040
+ }
2038
2041
  mountActionRoutes(nitroApp, httpActions, {
2039
2042
  getOwnerFromEvent,
2040
2043
  getUserNameFromEvent,
@@ -225,11 +225,12 @@ export declare function getSessionEmail(token: string): Promise<string | null>;
225
225
  * Allow framework routes with their own non-cookie authentication to reach
226
226
  * the handler. The handler remains responsible for verifying the credential.
227
227
  *
228
- * This is registered separately from template auth options because framework
229
- * routes can be mounted after the auth plugin and must also work in custom
230
- * workspace deployments that do not own a template auth file.
228
+ * Registered paths are exact matches. This is registered separately from
229
+ * template auth options because framework routes can be mounted after the auth
230
+ * plugin and must also work in custom workspace deployments that do not own a
231
+ * template auth file.
231
232
  */
232
- export declare function registerAuthPublicPaths(paths: readonly string[]): void;
233
+ export declare function registerAuthPublicPaths(paths: readonly string[], app?: object): void;
233
234
  export interface DesktopExchangeErrorPayload {
234
235
  message: string;
235
236
  code?: string;
@@ -960,30 +960,58 @@ export async function getSessionEmail(token) {
960
960
  // ---------------------------------------------------------------------------
961
961
  let customGetSession = null;
962
962
  let _authGuardConfig = null;
963
- const _registeredAuthPublicPaths = new Set();
963
+ // Pin the registry to globalThis so template plugins and framework routes that
964
+ // load Core through different SSR bundle or pnpm peer graphs still share it.
965
+ // Scope entries by H3 app so a route registered by one app cannot become public
966
+ // in another app that happens to share the same Node realm.
967
+ const AUTH_PUBLIC_PATHS_REGISTRY_KEY = Symbol.for("@agent-native/core/auth.publicPaths");
968
+ const _registeredAuthExactPublicPaths = new Set();
969
+ function getAuthPublicPathRegistry() {
970
+ const globals = globalThis;
971
+ return (globals[AUTH_PUBLIC_PATHS_REGISTRY_KEY] ??= {
972
+ exactPathsByApp: new WeakMap(),
973
+ });
974
+ }
975
+ function getRegisteredAuthExactPaths(app) {
976
+ if (!app)
977
+ return _registeredAuthExactPublicPaths;
978
+ const registry = getAuthPublicPathRegistry();
979
+ let paths = registry.exactPathsByApp.get(app);
980
+ if (!paths) {
981
+ paths = new Set();
982
+ registry.exactPathsByApp.set(app, paths);
983
+ }
984
+ return paths;
985
+ }
964
986
  const _genericGoogleOAuthRoutesEnabled = new WeakMap();
965
987
  /**
966
988
  * Allow framework routes with their own non-cookie authentication to reach
967
989
  * the handler. The handler remains responsible for verifying the credential.
968
990
  *
969
- * This is registered separately from template auth options because framework
970
- * routes can be mounted after the auth plugin and must also work in custom
971
- * workspace deployments that do not own a template auth file.
991
+ * Registered paths are exact matches. This is registered separately from
992
+ * template auth options because framework routes can be mounted after the auth
993
+ * plugin and must also work in custom workspace deployments that do not own a
994
+ * template auth file.
972
995
  */
973
- export function registerAuthPublicPaths(paths) {
996
+ export function registerAuthPublicPaths(paths, app) {
997
+ const registeredPaths = getRegisteredAuthExactPaths(app);
974
998
  for (const path of paths) {
975
999
  const normalized = typeof path === "string" ? path.trim() : "";
976
1000
  if (!normalized.startsWith("/"))
977
1001
  continue;
978
- _registeredAuthPublicPaths.add(normalized);
979
- if (_authGuardConfig &&
980
- !_authGuardConfig.publicPaths.includes(normalized)) {
981
- _authGuardConfig.publicPaths.push(normalized);
982
- }
1002
+ registeredPaths.add(normalized);
983
1003
  }
984
1004
  }
985
1005
  function resolveAuthPublicPaths(paths) {
986
- return [...new Set([...(paths ?? []), ..._registeredAuthPublicPaths])];
1006
+ return [...new Set(paths ?? [])];
1007
+ }
1008
+ function resolveAuthExactPublicPaths(app) {
1009
+ return [
1010
+ ...new Set([
1011
+ ..._registeredAuthExactPublicPaths,
1012
+ ...(app ? getRegisteredAuthExactPaths(app) : []),
1013
+ ]),
1014
+ ];
987
1015
  }
988
1016
  function getRequestHost(event) {
989
1017
  return (getHeader(event, "x-forwarded-host") ??
@@ -1564,12 +1592,15 @@ function isHtmlDocumentRequest(event, pathname) {
1564
1592
  const accept = getHeader(event, "accept")?.toLowerCase();
1565
1593
  return !accept || accept.includes("text/html") || accept.includes("*/*");
1566
1594
  }
1567
- function createAuthGuardFn() {
1595
+ function createAuthGuardFn(app) {
1568
1596
  return async (event) => {
1569
1597
  const config = _authGuardConfig;
1570
1598
  if (!config)
1571
1599
  return;
1572
- const { publicPaths } = config;
1600
+ // Resolve on every request because a framework route can be mounted by a
1601
+ // different Core module instance after this auth guard is initialized.
1602
+ const publicPaths = resolveAuthPublicPaths(config.publicPaths);
1603
+ const exactPublicPaths = resolveAuthExactPublicPaths(app);
1573
1604
  const url = event.node?.req?.url ?? event.path ?? "/";
1574
1605
  const queryStart = url.indexOf("?");
1575
1606
  const rawPath = queryStart >= 0 ? url.slice(0, queryStart) : url;
@@ -1848,7 +1879,7 @@ function createAuthGuardFn() {
1848
1879
  if (getMethod(event) === "GET" && p.startsWith("/_agent-native/avatar/")) {
1849
1880
  return;
1850
1881
  }
1851
- if (isPublicPath(normalizedUrl, publicPaths))
1882
+ if (isPublicPath(normalizedUrl, publicPaths, exactPublicPaths))
1852
1883
  return;
1853
1884
  if (shouldBypassAuthForBuilderConnect(event, p))
1854
1885
  return;
@@ -2467,15 +2498,19 @@ function isHttpsRequest(event) {
2467
2498
  // ---------------------------------------------------------------------------
2468
2499
  // Public path matching
2469
2500
  // ---------------------------------------------------------------------------
2470
- function isPublicPath(url, publicPaths) {
2501
+ function isPublicPath(url, publicPaths, exactPublicPaths = []) {
2471
2502
  const p = url.split("?")[0];
2503
+ if (exactPublicPaths.some((candidate) => normalizePath(candidate) === p)) {
2504
+ return true;
2505
+ }
2472
2506
  return matchesPathList(p, publicPaths);
2473
2507
  }
2508
+ function normalizePath(path) {
2509
+ return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
2510
+ }
2474
2511
  function matchesPathList(path, paths) {
2475
2512
  return paths.some((candidate) => {
2476
- const normalized = candidate.length > 1 && candidate.endsWith("/")
2477
- ? candidate.slice(0, -1)
2478
- : candidate;
2513
+ const normalized = normalizePath(candidate);
2479
2514
  return path === normalized || path.startsWith(normalized + "/");
2480
2515
  });
2481
2516
  }
@@ -3612,7 +3647,7 @@ async function mountBetterAuthRoutes(app, options) {
3612
3647
  workspaceAppPublicPaths: workspaceAppRouteAccess.publicPaths,
3613
3648
  workspaceAppProtectedPaths: workspaceAppRouteAccess.protectedPaths,
3614
3649
  };
3615
- const guardFn = createAuthGuardFn();
3650
+ const guardFn = createAuthGuardFn(app);
3616
3651
  _authGuardFn = guardFn;
3617
3652
  app.use(defineEventHandler(guardFn));
3618
3653
  }
@@ -3880,7 +3915,7 @@ export async function autoMountAuth(app, options = {}) {
3880
3915
  workspaceAppPublicPaths: workspaceAppRouteAccess.publicPaths,
3881
3916
  workspaceAppProtectedPaths: workspaceAppRouteAccess.protectedPaths,
3882
3917
  };
3883
- const guardFn = createAuthGuardFn();
3918
+ const guardFn = createAuthGuardFn(app);
3884
3919
  _authGuardFn = guardFn;
3885
3920
  app.use(defineEventHandler(guardFn));
3886
3921
  if (process.env.DEBUG)
@@ -3907,7 +3942,7 @@ export async function autoMountAuth(app, options = {}) {
3907
3942
  workspaceAppPublicPaths: workspaceAppRouteAccess.publicPaths,
3908
3943
  workspaceAppProtectedPaths: workspaceAppRouteAccess.protectedPaths,
3909
3944
  };
3910
- const guardFn = createAuthGuardFn();
3945
+ const guardFn = createAuthGuardFn(app);
3911
3946
  _authGuardFn = guardFn;
3912
3947
  app.use(defineEventHandler(guardFn));
3913
3948
  console.log("[agent-native] Auth guard registered despite init failure — app is locked.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.157.13",
3
+ "version": "0.157.15",
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": {