@agent-native/core 0.157.14 → 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.
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-chat/plugin-options.d.ts +5 -0
- package/dist/server/agent-chat-plugin.js +4 -1
- package/dist/server/auth.d.ts +4 -3
- package/dist/server/auth.js +30 -22
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -42,22 +42,22 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
|
|
|
42
42
|
avgEvalScore: number;
|
|
43
43
|
} | {
|
|
44
44
|
error?: undefined;
|
|
45
|
-
ok?: undefined;
|
|
46
45
|
summary: import("./types.js").TraceSummary;
|
|
47
46
|
spans: import("./types.js").TraceSpan[];
|
|
48
47
|
id?: undefined;
|
|
48
|
+
ok?: undefined;
|
|
49
49
|
} | {
|
|
50
50
|
error?: undefined;
|
|
51
|
-
ok?: 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;
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -34,37 +34,37 @@ 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
|
-
error?: undefined;
|
|
41
40
|
ok: boolean;
|
|
42
41
|
status: string;
|
|
42
|
+
error?: undefined;
|
|
43
43
|
} | {
|
|
44
|
-
ok?: undefined;
|
|
45
44
|
error: string;
|
|
46
45
|
removed?: undefined;
|
|
46
|
+
ok?: undefined;
|
|
47
47
|
} | {
|
|
48
|
-
error?: undefined;
|
|
49
48
|
ok: boolean;
|
|
50
49
|
removed: boolean;
|
|
50
|
+
error?: undefined;
|
|
51
51
|
}>>;
|
|
52
52
|
/**
|
|
53
53
|
* POST /_agent-native/secrets/:key/test — validate an optional candidate value
|
|
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
|
-
error?: undefined;
|
|
62
61
|
ok: boolean;
|
|
63
62
|
note?: undefined;
|
|
64
|
-
} | {
|
|
65
63
|
error?: undefined;
|
|
64
|
+
} | {
|
|
66
65
|
ok: boolean;
|
|
67
66
|
note: string;
|
|
67
|
+
error?: undefined;
|
|
68
68
|
} | {
|
|
69
69
|
note?: undefined;
|
|
70
70
|
ok: boolean;
|
|
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
|
|
|
95
95
|
export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
|
|
96
96
|
error: string;
|
|
97
97
|
} | {
|
|
98
|
-
error?: undefined;
|
|
99
98
|
ok: boolean;
|
|
100
99
|
key: string;
|
|
101
|
-
} | {
|
|
102
100
|
error?: undefined;
|
|
101
|
+
} | {
|
|
103
102
|
ok: boolean;
|
|
104
103
|
removed: boolean;
|
|
104
|
+
error?: undefined;
|
|
105
105
|
}>>;
|
|
@@ -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,
|
package/dist/server/auth.d.ts
CHANGED
|
@@ -225,9 +225,10 @@ 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
|
|
229
|
-
* routes can be mounted after the auth
|
|
230
|
-
* workspace deployments that do not own a
|
|
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
233
|
export declare function registerAuthPublicPaths(paths: readonly string[], app?: object): void;
|
|
233
234
|
export interface DesktopExchangeErrorPayload {
|
package/dist/server/auth.js
CHANGED
|
@@ -965,21 +965,21 @@ let _authGuardConfig = null;
|
|
|
965
965
|
// Scope entries by H3 app so a route registered by one app cannot become public
|
|
966
966
|
// in another app that happens to share the same Node realm.
|
|
967
967
|
const AUTH_PUBLIC_PATHS_REGISTRY_KEY = Symbol.for("@agent-native/core/auth.publicPaths");
|
|
968
|
-
const
|
|
968
|
+
const _registeredAuthExactPublicPaths = new Set();
|
|
969
969
|
function getAuthPublicPathRegistry() {
|
|
970
970
|
const globals = globalThis;
|
|
971
971
|
return (globals[AUTH_PUBLIC_PATHS_REGISTRY_KEY] ??= {
|
|
972
|
-
|
|
972
|
+
exactPathsByApp: new WeakMap(),
|
|
973
973
|
});
|
|
974
974
|
}
|
|
975
|
-
function
|
|
975
|
+
function getRegisteredAuthExactPaths(app) {
|
|
976
976
|
if (!app)
|
|
977
|
-
return
|
|
977
|
+
return _registeredAuthExactPublicPaths;
|
|
978
978
|
const registry = getAuthPublicPathRegistry();
|
|
979
|
-
let paths = registry.
|
|
979
|
+
let paths = registry.exactPathsByApp.get(app);
|
|
980
980
|
if (!paths) {
|
|
981
981
|
paths = new Set();
|
|
982
|
-
registry.
|
|
982
|
+
registry.exactPathsByApp.set(app, paths);
|
|
983
983
|
}
|
|
984
984
|
return paths;
|
|
985
985
|
}
|
|
@@ -988,12 +988,13 @@ const _genericGoogleOAuthRoutesEnabled = new WeakMap();
|
|
|
988
988
|
* Allow framework routes with their own non-cookie authentication to reach
|
|
989
989
|
* the handler. The handler remains responsible for verifying the credential.
|
|
990
990
|
*
|
|
991
|
-
* This is registered separately from
|
|
992
|
-
* routes can be mounted after the auth
|
|
993
|
-
* workspace deployments that do not own a
|
|
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.
|
|
994
995
|
*/
|
|
995
996
|
export function registerAuthPublicPaths(paths, app) {
|
|
996
|
-
const registeredPaths =
|
|
997
|
+
const registeredPaths = getRegisteredAuthExactPaths(app);
|
|
997
998
|
for (const path of paths) {
|
|
998
999
|
const normalized = typeof path === "string" ? path.trim() : "";
|
|
999
1000
|
if (!normalized.startsWith("/"))
|
|
@@ -1001,12 +1002,14 @@ export function registerAuthPublicPaths(paths, app) {
|
|
|
1001
1002
|
registeredPaths.add(normalized);
|
|
1002
1003
|
}
|
|
1003
1004
|
}
|
|
1004
|
-
function resolveAuthPublicPaths(paths
|
|
1005
|
+
function resolveAuthPublicPaths(paths) {
|
|
1006
|
+
return [...new Set(paths ?? [])];
|
|
1007
|
+
}
|
|
1008
|
+
function resolveAuthExactPublicPaths(app) {
|
|
1005
1009
|
return [
|
|
1006
1010
|
...new Set([
|
|
1007
|
-
...
|
|
1008
|
-
...
|
|
1009
|
-
...(app ? getRegisteredAuthPublicPaths(app) : []),
|
|
1011
|
+
..._registeredAuthExactPublicPaths,
|
|
1012
|
+
...(app ? getRegisteredAuthExactPaths(app) : []),
|
|
1010
1013
|
]),
|
|
1011
1014
|
];
|
|
1012
1015
|
}
|
|
@@ -1596,7 +1599,8 @@ function createAuthGuardFn(app) {
|
|
|
1596
1599
|
return;
|
|
1597
1600
|
// Resolve on every request because a framework route can be mounted by a
|
|
1598
1601
|
// different Core module instance after this auth guard is initialized.
|
|
1599
|
-
const publicPaths = resolveAuthPublicPaths(config.publicPaths
|
|
1602
|
+
const publicPaths = resolveAuthPublicPaths(config.publicPaths);
|
|
1603
|
+
const exactPublicPaths = resolveAuthExactPublicPaths(app);
|
|
1600
1604
|
const url = event.node?.req?.url ?? event.path ?? "/";
|
|
1601
1605
|
const queryStart = url.indexOf("?");
|
|
1602
1606
|
const rawPath = queryStart >= 0 ? url.slice(0, queryStart) : url;
|
|
@@ -1875,7 +1879,7 @@ function createAuthGuardFn(app) {
|
|
|
1875
1879
|
if (getMethod(event) === "GET" && p.startsWith("/_agent-native/avatar/")) {
|
|
1876
1880
|
return;
|
|
1877
1881
|
}
|
|
1878
|
-
if (isPublicPath(normalizedUrl, publicPaths))
|
|
1882
|
+
if (isPublicPath(normalizedUrl, publicPaths, exactPublicPaths))
|
|
1879
1883
|
return;
|
|
1880
1884
|
if (shouldBypassAuthForBuilderConnect(event, p))
|
|
1881
1885
|
return;
|
|
@@ -2494,15 +2498,19 @@ function isHttpsRequest(event) {
|
|
|
2494
2498
|
// ---------------------------------------------------------------------------
|
|
2495
2499
|
// Public path matching
|
|
2496
2500
|
// ---------------------------------------------------------------------------
|
|
2497
|
-
function isPublicPath(url, publicPaths) {
|
|
2501
|
+
function isPublicPath(url, publicPaths, exactPublicPaths = []) {
|
|
2498
2502
|
const p = url.split("?")[0];
|
|
2503
|
+
if (exactPublicPaths.some((candidate) => normalizePath(candidate) === p)) {
|
|
2504
|
+
return true;
|
|
2505
|
+
}
|
|
2499
2506
|
return matchesPathList(p, publicPaths);
|
|
2500
2507
|
}
|
|
2508
|
+
function normalizePath(path) {
|
|
2509
|
+
return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
|
|
2510
|
+
}
|
|
2501
2511
|
function matchesPathList(path, paths) {
|
|
2502
2512
|
return paths.some((candidate) => {
|
|
2503
|
-
const normalized = candidate
|
|
2504
|
-
? candidate.slice(0, -1)
|
|
2505
|
-
: candidate;
|
|
2513
|
+
const normalized = normalizePath(candidate);
|
|
2506
2514
|
return path === normalized || path.startsWith(normalized + "/");
|
|
2507
2515
|
});
|
|
2508
2516
|
}
|
|
@@ -2629,7 +2637,7 @@ function getCustomAuthRequiredHtml() {
|
|
|
2629
2637
|
// mountBetterAuthRoutes — Better Auth powered auth with backward-compat routes
|
|
2630
2638
|
// ---------------------------------------------------------------------------
|
|
2631
2639
|
async function mountBetterAuthRoutes(app, options) {
|
|
2632
|
-
const publicPaths = resolveAuthPublicPaths(options.publicPaths
|
|
2640
|
+
const publicPaths = resolveAuthPublicPaths(options.publicPaths);
|
|
2633
2641
|
const workspaceAppAudience = resolveWorkspaceAppAudience(options);
|
|
2634
2642
|
const workspaceAppRouteAccess = resolveWorkspaceAppRouteAccess(options);
|
|
2635
2643
|
// The A2A agent card is part of an open protocol — other agents must be
|
|
@@ -3862,7 +3870,7 @@ export async function autoMountAuth(app, options = {}) {
|
|
|
3862
3870
|
// Reset globals
|
|
3863
3871
|
customGetSession = null;
|
|
3864
3872
|
sessionMaxAge = options.maxAge ?? DEFAULT_MAX_AGE;
|
|
3865
|
-
const publicPaths = resolveAuthPublicPaths(options.publicPaths
|
|
3873
|
+
const publicPaths = resolveAuthPublicPaths(options.publicPaths);
|
|
3866
3874
|
const workspaceAppAudience = resolveWorkspaceAppAudience(options);
|
|
3867
3875
|
const workspaceAppRouteAccess = resolveWorkspaceAppRouteAccess(options);
|
|
3868
3876
|
mountAuthCorsMiddleware(app);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.157.
|
|
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": {
|