@agent-native/core 0.158.4 → 0.158.5

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,16 +41,16 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- error?: undefined;
45
44
  summary: import("./types.js").TraceSummary;
46
45
  spans: import("./types.js").TraceSpan[];
47
46
  id?: undefined;
47
+ error?: undefined;
48
48
  ok?: undefined;
49
49
  } | {
50
- error?: undefined;
51
50
  summary?: undefined;
52
51
  spans?: undefined;
53
52
  id: string;
53
+ error?: undefined;
54
54
  ok?: undefined;
55
55
  } | {
56
56
  summary?: undefined;
@@ -59,9 +59,9 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
59
59
  error: any;
60
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
  }>>;
@@ -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
  }>>;
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
48
48
  }>;
49
49
  /** DELETE /_agent-native/resources/:id — delete a resource */
50
50
  export declare function handleDeleteResource(event: any): Promise<{
51
- ok?: undefined;
52
51
  error: string;
52
+ ok?: undefined;
53
53
  } | {
54
54
  error?: undefined;
55
55
  ok: boolean;
@@ -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 {};
@@ -1538,9 +1538,44 @@ function escapeHtmlAttr(value) {
1538
1538
  const DESKTOP_MAGIC_LINK_CALLBACK_PATH = "/_agent-native/auth/magic-link/desktop-callback";
1539
1539
  const DESKTOP_MAGIC_LINK_LANDING_PATH = "/_agent-native/auth/magic-link/desktop-landing";
1540
1540
  const BETTER_AUTH_MAGIC_LINK_VERIFY_PATH = "/_agent-native/auth/ba/magic-link/verify";
1541
- function desktopMagicLinkLandingPage(verificationUrl) {
1542
- const safeVerificationUrl = escapeHtmlAttr(verificationUrl);
1543
- const html = `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Continue sign-in</title></head><body><main><h1>Continue signing in</h1><p>Click continue to finish signing in to the Agent Native desktop app.</p><form method="get" action="${safeVerificationUrl}"><button type="submit">Continue</button></form></main></body></html>`;
1541
+ function desktopMagicLinkVerificationUrl(event, values) {
1542
+ const value = (key) => typeof values[key] === "string" ? values[key] : "";
1543
+ const token = value("token").trim();
1544
+ const callbackURL = value("callbackURL");
1545
+ if (!token || !callbackURL)
1546
+ return undefined;
1547
+ try {
1548
+ const callback = new URL(callbackURL, getOrigin(event));
1549
+ if (callback.origin !== new URL(getOrigin(event)).origin ||
1550
+ !callback.pathname.endsWith(DESKTOP_MAGIC_LINK_CALLBACK_PATH) ||
1551
+ !normalizeDesktopFlowId(callback.searchParams.get("flow_id")) ||
1552
+ !normalizeDesktopFlowVerifier(callback.searchParams.get("verifier"))) {
1553
+ return undefined;
1554
+ }
1555
+ const verificationURL = new URL(getAppUrl(event, BETTER_AUTH_MAGIC_LINK_VERIFY_PATH));
1556
+ verificationURL.searchParams.set("token", token);
1557
+ for (const key of [
1558
+ "callbackURL",
1559
+ "newUserCallbackURL",
1560
+ "errorCallbackURL",
1561
+ ]) {
1562
+ const queryValue = value(key);
1563
+ if (queryValue)
1564
+ verificationURL.searchParams.set(key, queryValue);
1565
+ }
1566
+ return verificationURL;
1567
+ // coercion-ok: malformed user-supplied callback data is rejected as absent.
1568
+ }
1569
+ catch {
1570
+ return undefined;
1571
+ }
1572
+ }
1573
+ function desktopMagicLinkLandingPage(actionUrl, fields) {
1574
+ const safeActionUrl = escapeHtmlAttr(actionUrl);
1575
+ const hiddenInputs = Object.entries(fields)
1576
+ .map(([name, value]) => `<input type="hidden" name="${escapeHtmlAttr(name)}" value="${escapeHtmlAttr(value)}">`)
1577
+ .join("");
1578
+ const html = `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Continue sign-in</title></head><body><main><h1>Continue signing in</h1><p>Click continue to finish signing in to the Agent Native desktop app.</p><form method="post" action="${safeActionUrl}" autocomplete="off">${hiddenInputs}<button type="submit">Continue</button></form></main></body></html>`;
1544
1579
  return new Response(html, {
1545
1580
  status: 200,
1546
1581
  headers: {
@@ -3054,47 +3089,45 @@ async function mountBetterAuthRoutes(app, options) {
3054
3089
  // on the first verification GET. The explicit form action below is the only
3055
3090
  // request that reaches Better Auth's consuming verification endpoint.
3056
3091
  app.use(DESKTOP_MAGIC_LINK_LANDING_PATH, defineEventHandler((event) => {
3092
+ if (getMethod(event) === "POST") {
3093
+ return readBody(event).then((body) => {
3094
+ const verificationURL = desktopMagicLinkVerificationUrl(event, body);
3095
+ if (!verificationURL) {
3096
+ setResponseStatus(event, 400);
3097
+ return { error: "Invalid desktop magic-link" };
3098
+ }
3099
+ return new Response(null, {
3100
+ status: 303,
3101
+ headers: {
3102
+ "cache-control": "no-store",
3103
+ location: verificationURL.toString(),
3104
+ "referrer-policy": "no-referrer",
3105
+ },
3106
+ });
3107
+ });
3108
+ }
3057
3109
  if (!isReadMethod(event)) {
3058
3110
  setResponseStatus(event, 405);
3059
3111
  return { error: "Method not allowed" };
3060
3112
  }
3061
3113
  const query = getQuery(event);
3062
- const token = typeof query.token === "string" ? query.token.trim() : "";
3063
- const callbackURL = typeof query.callbackURL === "string" ? query.callbackURL : "";
3064
- if (!token || !callbackURL) {
3065
- setResponseStatus(event, 400);
3066
- return { error: "Invalid desktop magic-link" };
3067
- }
3068
- let callback;
3069
- try {
3070
- callback = new URL(callbackURL, getOrigin(event));
3071
- }
3072
- catch {
3073
- setResponseStatus(event, 400);
3074
- return { error: "Invalid desktop magic-link" };
3075
- }
3076
- if (callback.origin !== new URL(getOrigin(event)).origin ||
3077
- !callback.pathname.endsWith(DESKTOP_MAGIC_LINK_CALLBACK_PATH) ||
3078
- !normalizeDesktopFlowId(callback.searchParams.get("flow_id")) ||
3079
- !normalizeDesktopFlowVerifier(callback.searchParams.get("verifier"))) {
3114
+ const verificationURL = desktopMagicLinkVerificationUrl(event, query);
3115
+ if (!verificationURL) {
3080
3116
  setResponseStatus(event, 400);
3081
3117
  return { error: "Invalid desktop magic-link" };
3082
3118
  }
3083
- const verificationURL = new URL(getOrigin(event));
3084
- verificationURL.pathname =
3085
- getAppBasePath() + BETTER_AUTH_MAGIC_LINK_VERIFY_PATH;
3086
- verificationURL.searchParams.set("token", token);
3119
+ const fields = {};
3087
3120
  for (const key of [
3121
+ "token",
3088
3122
  "callbackURL",
3089
3123
  "newUserCallbackURL",
3090
3124
  "errorCallbackURL",
3091
3125
  ]) {
3092
- const value = query[key];
3093
- if (typeof value === "string" && value) {
3094
- verificationURL.searchParams.set(key, value);
3126
+ if (typeof query[key] === "string" && query[key]) {
3127
+ fields[key] = query[key];
3095
3128
  }
3096
3129
  }
3097
- return desktopMagicLinkLandingPage(verificationURL.toString());
3130
+ return desktopMagicLinkLandingPage(getAppUrl(event, DESKTOP_MAGIC_LINK_LANDING_PATH), fields);
3098
3131
  }));
3099
3132
  app.use("/_agent-native/auth/magic-link/desktop-callback", defineEventHandler(async (event) => {
3100
3133
  if (!isReadMethod(event)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.158.4",
3
+ "version": "0.158.5",
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": {