@agent-native/core 0.187.0 → 0.187.1-nightly-20260925003003

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.
Files changed (158) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +4 -3
  3. package/corpus/templates/analytics/changelog/2026-09-24-analytics-sidebar-footer-aligns-consistently.md +6 -0
  4. package/corpus/templates/analytics/changelog/2026-09-24-dashboard-emails-match-stacked-area-totals.md +6 -0
  5. package/corpus/templates/analytics/server/lib/report-chart-svg.ts +47 -20
  6. package/corpus/templates/calendar/app/components/calendar/AttendeeAutocomplete.tsx +1 -1
  7. package/corpus/templates/calendar/changelog/2026-09-24-guest-inputs-wrap-beneath-existing-guests-so-the-active-inpu.md +6 -0
  8. package/corpus/templates/clips/app/components/editor/stitch-manager.tsx +8 -3
  9. package/corpus/templates/clips/app/lib/recording-link.ts +21 -0
  10. package/corpus/templates/clips/app/routes/record.tsx +27 -8
  11. package/corpus/templates/clips/changelog/2026-09-24-the-camera-bubble-stays-visible-while-you-reposition-it-befo.md +6 -0
  12. package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +7 -0
  13. package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +63 -55
  14. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +251 -74
  15. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +66 -56
  16. package/corpus/templates/design/app/components/design/EditPanel.tsx +19 -0
  17. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +59 -9
  18. package/corpus/templates/design/app/components/design/edit-panel/interaction-state-helpers.ts +4 -0
  19. package/corpus/templates/design/app/components/design/edit-panel/layout-properties.tsx +119 -0
  20. package/corpus/templates/design/app/components/design/edit-panel/stroke-properties.tsx +48 -51
  21. package/corpus/templates/design/app/components/design/edit-panel/style-change-types.ts +1 -0
  22. package/corpus/templates/design/app/components/design/inspector/AutoLayoutMatrix.tsx +298 -187
  23. package/corpus/templates/design/app/components/design/inspector/GradientEditor.tsx +2 -2
  24. package/corpus/templates/design/app/components/design/inspector/index.ts +4 -0
  25. package/corpus/templates/design/app/components/design/multi-screen/types.ts +4 -2
  26. package/corpus/templates/design/app/i18n/en-US.ts +6 -0
  27. package/corpus/templates/design/app/pages/Present.tsx +101 -87
  28. package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +75 -14
  29. package/corpus/templates/design/app/pages/design-editor/commands/README.md +1 -0
  30. package/corpus/templates/design/app/pages/design-editor/commands/commit-relative-style-delta-to-selected-layers.ts +69 -56
  31. package/corpus/templates/design/app/pages/design-editor/commands/mode-change.ts +16 -0
  32. package/corpus/templates/design/app/pages/design-editor/commands/scale-selection.ts +17 -2
  33. package/corpus/templates/design/app/pages/design-editor/commands/styles-change.ts +23 -30
  34. package/corpus/templates/design/app/pages/design-editor/commands/swap-fill-stroke.ts +105 -0
  35. package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +21 -0
  36. package/corpus/templates/design/app/pages/present-review-state.ts +7 -1
  37. package/corpus/templates/design/changelog/2026-09-24-a-vector-s-stroke-row-shows-position-beside-weight-instead-o.md +6 -0
  38. package/corpus/templates/design/changelog/2026-09-24-css-margins-can-be-adjusted-on-the-canvas-and-in-the-layout-.md +6 -0
  39. package/corpus/templates/design/changelog/2026-09-24-design-reviews-show-the-real-canvas-beside-its-conversation.md +6 -0
  40. package/corpus/templates/design/changelog/2026-09-24-double-clicking-text-or-a-vector-on-the-board-starts-editing.md +6 -0
  41. package/corpus/templates/design/changelog/2026-09-24-interact-opens-a-focused-responsive-preview-without-reloadin.md +6 -0
  42. package/corpus/templates/design/changelog/2026-09-24-keep-gradient-values-visible-and-limit-canvas-paints-to-supp.md +6 -0
  43. package/corpus/templates/design/changelog/2026-09-24-open-pen-paths-no-longer-paint-a-filled-triangle-after-shift.md +6 -0
  44. package/corpus/templates/design/changelog/2026-09-24-re-clicking-the-active-responsive-preview-returns-to-the-can.md +6 -0
  45. package/corpus/templates/design/changelog/2026-09-24-resized-vectors-can-be-point-edited-and-the-k-scale-tool-sho.md +6 -0
  46. package/corpus/templates/design/changelog/2026-09-24-while-editing-text-click-to-place-the-caret-and-double-click.md +6 -0
  47. package/corpus/templates/design/e2e/helpers.ts +19 -2
  48. package/corpus/templates/mail/app/components/email/ComposeModal.tsx +1 -1
  49. package/corpus/templates/mail/changelog/2026-09-24-gmail-push-ack.md +6 -0
  50. package/corpus/templates/mail/changelog/2026-09-24-the-composer-keeps-its-taller-layout-in-a-narrower-window.md +6 -0
  51. package/corpus/templates/mail/server/db/schema.ts +26 -1
  52. package/corpus/templates/mail/server/lib/inbox-store.ts +68 -23
  53. package/corpus/templates/mail/server/lib/inbox-sync.ts +43 -17
  54. package/corpus/templates/mail/server/plugins/db.ts +19 -0
  55. package/corpus/templates/mail/server/routes/api/gmail/push.post.ts +4 -15
  56. package/corpus/templates/slides/.agents/skills/create-deck/SKILL.md +45 -30
  57. package/corpus/templates/slides/.agents/skills/slide-editing/SKILL.md +18 -2
  58. package/corpus/templates/slides/actions/export-html.ts +28 -17
  59. package/corpus/templates/slides/app/hooks/use-deck-design-system.ts +27 -15
  60. package/corpus/templates/slides/app/pages/DeckEditor.tsx +1 -1
  61. package/corpus/templates/slides/changelog/2026-09-23-decks-with-no-design-system-now-follow-a-theme-chosen-for-th.md +6 -0
  62. package/corpus/templates/slides/shared/slide-background.ts +3 -1
  63. package/dist/agent/engine/builder-engine.js +11 -0
  64. package/dist/agent/engine/types.d.ts +1 -0
  65. package/dist/agent/production-agent.d.ts +2 -0
  66. package/dist/agent/production-agent.js +32 -4
  67. package/dist/agent/run-loop-with-resume.js +6 -0
  68. package/dist/cli/index.js +4 -4
  69. package/dist/cli/process.d.ts +10 -1
  70. package/dist/cli/process.js +66 -0
  71. package/dist/cli/workspace-dev.js +2 -0
  72. package/dist/client/agent-chat.js +13 -14
  73. package/dist/client/error-format.js +4 -4
  74. package/dist/client/observability/ObservabilityDashboard.js +95 -65
  75. package/dist/client/observability/OutputPreview.d.ts +2 -1
  76. package/dist/client/observability/OutputPreview.js +64 -7
  77. package/dist/client/observability/useObservability.d.ts +2 -1
  78. package/dist/client/observability/useObservability.js +5 -1
  79. package/dist/client/settings/UsageSection.js +105 -17
  80. package/dist/collab/routes.d.ts +1 -1
  81. package/dist/collab/struct-routes.d.ts +1 -1
  82. package/dist/db/client.d.ts +44 -0
  83. package/dist/db/client.js +62 -3
  84. package/dist/db/create-get-db.js +23 -1
  85. package/dist/db/embedded-runtime.d.ts +21 -0
  86. package/dist/db/embedded-runtime.js +27 -0
  87. package/dist/db/migrations.js +2 -0
  88. package/dist/db/server-runtime.d.ts +22 -0
  89. package/dist/db/server-runtime.js +26 -0
  90. package/dist/deploy/build.d.ts +29 -0
  91. package/dist/deploy/build.js +204 -121
  92. package/dist/feature-flags/index.d.ts +1 -1
  93. package/dist/feature-flags/index.js +1 -1
  94. package/dist/feature-flags/registry.d.ts +1 -0
  95. package/dist/feature-flags/registry.js +5 -0
  96. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  97. package/dist/index.d.ts +1 -1
  98. package/dist/index.js +1 -1
  99. package/dist/integrations/webhook-handler.js +4 -1
  100. package/dist/jobs/background-automation-runner.js +6 -1
  101. package/dist/localization/core-messages/ar-SA.js +9 -1
  102. package/dist/localization/core-messages/de-DE.js +9 -1
  103. package/dist/localization/core-messages/en-US.d.ts +9 -1
  104. package/dist/localization/core-messages/en-US.js +9 -1
  105. package/dist/localization/core-messages/es-ES.js +9 -1
  106. package/dist/localization/core-messages/fr-FR.js +9 -1
  107. package/dist/localization/core-messages/hi-IN.js +9 -1
  108. package/dist/localization/core-messages/ja-JP.js +9 -1
  109. package/dist/localization/core-messages/ko-KR.js +9 -1
  110. package/dist/localization/core-messages/pt-BR.js +9 -1
  111. package/dist/localization/core-messages/supplemental/ar-SA.js +1 -0
  112. package/dist/localization/core-messages/supplemental/de-DE.js +1 -0
  113. package/dist/localization/core-messages/supplemental/en-US.js +1 -0
  114. package/dist/localization/core-messages/supplemental/es-ES.js +1 -0
  115. package/dist/localization/core-messages/supplemental/fr-FR.js +1 -0
  116. package/dist/localization/core-messages/supplemental/hi-IN.js +1 -0
  117. package/dist/localization/core-messages/supplemental/ja-JP.js +1 -0
  118. package/dist/localization/core-messages/supplemental/ko-KR.js +1 -0
  119. package/dist/localization/core-messages/supplemental/pt-BR.js +1 -0
  120. package/dist/localization/core-messages/supplemental/zh-CN.js +1 -0
  121. package/dist/localization/core-messages/supplemental/zh-TW.js +1 -0
  122. package/dist/localization/core-messages/zh-CN.js +9 -1
  123. package/dist/localization/core-messages/zh-TW.js +9 -1
  124. package/dist/localization/core-messages.d.ts +9 -1
  125. package/dist/localization/mcp-settings-messages.d.ts +1 -0
  126. package/dist/mcp/connect-route.js +45 -8
  127. package/dist/mcp/connect-store.d.ts +7 -5
  128. package/dist/mcp/connect-store.js +30 -39
  129. package/dist/notifications/routes.d.ts +3 -3
  130. package/dist/observability/actions/get-observability-review-detail.d.ts +7 -0
  131. package/dist/observability/actions/get-observability-review-detail.js +25 -0
  132. package/dist/observability/reviews.d.ts +9 -1
  133. package/dist/observability/reviews.js +20 -0
  134. package/dist/observability/routes.d.ts +3 -3
  135. package/dist/observability/types.d.ts +8 -0
  136. package/dist/org/handlers.d.ts +1 -1
  137. package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
  138. package/dist/provider-api/actions/provider-api.d.ts +9 -9
  139. package/dist/scripts/db/query.js +6 -1
  140. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  141. package/dist/server/agent-engine-ollama-models-route.d.ts +2 -2
  142. package/dist/server/agent-teams.js +4 -1
  143. package/dist/server/auth.js +60 -20
  144. package/dist/server/better-auth-instance.js +7 -1
  145. package/dist/server/core-routes-plugin.d.ts +1 -1
  146. package/dist/server/core-routes-plugin.js +2 -0
  147. package/dist/server/embedded.js +6 -0
  148. package/dist/server/framework-request-handler.js +6 -0
  149. package/dist/server/realtime-token.d.ts +1 -1
  150. package/dist/usage/actions/get-usage-metrics.js +4 -1
  151. package/dist/usage/metrics-store.d.ts +19 -0
  152. package/dist/usage/metrics-store.js +106 -14
  153. package/dist/usage/store.d.ts +7 -2
  154. package/dist/usage/store.js +25 -4
  155. package/dist/vite/action-types-plugin.js +4 -0
  156. package/dist/vite/client.d.ts +6 -1
  157. package/dist/vite/client.js +40 -1
  158. package/package.json +4 -3
@@ -11,10 +11,10 @@
11
11
  * the OAuth 2.0 device-authorization-style CLI flow. Single-use
12
12
  * (`consumed_at`), rate-limited at creation.
13
13
  *
14
- * Mirrors `application-state/store.ts`: lazy `ensureTable()`, `getDbExec()`,
15
- * `isConnectionError()` swallow so a transient Neon WS drop never 500s.
16
- * `CREATE TABLE IF NOT EXISTS` only — strictly additive, never DROP / ALTER
17
- * (shared prod DB rule).
14
+ * Mirrors `application-state/store.ts`: lazy `ensureTable()` and `getDbExec()`.
15
+ * Device-code reads propagate connection errors so unreadable cannot look
16
+ * like an absent authorization. `CREATE TABLE IF NOT EXISTS` only — strictly
17
+ * additive, never DROP / ALTER (shared prod DB rule).
18
18
  */
19
19
  import { randomBytes, randomUUID } from "node:crypto";
20
20
  import { getDbExec, isConnectionError } from "../db/client.js";
@@ -73,6 +73,7 @@ export async function ensureTable() {
73
73
  org_id TEXT,
74
74
  status TEXT NOT NULL DEFAULT 'pending',
75
75
  token_jti TEXT,
76
+ catalog_scope TEXT,
76
77
  created_at BIGINT,
77
78
  expires_at BIGINT,
78
79
  consumed_at BIGINT
@@ -83,6 +84,7 @@ export async function ensureTable() {
83
84
  await ensureColumnExists("mcp_connect_tokens", "service_name", `ALTER TABLE mcp_connect_tokens ADD COLUMN IF NOT EXISTS service_name TEXT`);
84
85
  await ensureColumnExists("mcp_connect_tokens", "created_by", `ALTER TABLE mcp_connect_tokens ADD COLUMN IF NOT EXISTS created_by TEXT`);
85
86
  await ensureTableExists("mcp_device_codes", createDeviceCodesSql);
87
+ await ensureColumnExists("mcp_device_codes", "catalog_scope", `ALTER TABLE mcp_device_codes ADD COLUMN IF NOT EXISTS catalog_scope TEXT`);
86
88
  })().catch((err) => {
87
89
  // Don't cache a rejected init. A transient DB blip should let the next
88
90
  // connect/mint/revoke call retry rather than wedging the process.
@@ -329,7 +331,7 @@ function generateDeviceCode() {
329
331
  * Throws `RATE_LIMITED` when the cap is exceeded so the route can map it to a
330
332
  * 429.
331
333
  */
332
- export async function createDeviceCode() {
334
+ export async function createDeviceCode(catalogScope = null) {
333
335
  await ensureTable();
334
336
  const client = getDbExec();
335
337
  const now = Date.now();
@@ -353,7 +355,7 @@ export async function createDeviceCode() {
353
355
  const userCode = generateUserCode();
354
356
  const expiresAt = now + DEVICE_CODE_TTL_MS;
355
357
  await client.execute({
356
- sql: `INSERT INTO mcp_device_codes (device_code, user_code, owner_email, org_id, status, token_jti, created_at, expires_at, consumed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
358
+ sql: `INSERT INTO mcp_device_codes (device_code, user_code, owner_email, org_id, status, token_jti, catalog_scope, created_at, expires_at, consumed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
357
359
  args: [
358
360
  deviceCode,
359
361
  userCode,
@@ -361,6 +363,7 @@ export async function createDeviceCode() {
361
363
  null,
362
364
  "pending",
363
365
  null,
366
+ catalogScope,
364
367
  now,
365
368
  expiresAt,
366
369
  null,
@@ -373,6 +376,7 @@ export async function createDeviceCode() {
373
376
  orgId: null,
374
377
  status: "pending",
375
378
  tokenJti: null,
379
+ catalogScope,
376
380
  createdAt: now,
377
381
  expiresAt,
378
382
  consumedAt: null,
@@ -386,46 +390,33 @@ function mapDeviceRow(r) {
386
390
  orgId: (r.org_id ?? r.orgId ?? null),
387
391
  status: (r.status ?? "pending"),
388
392
  tokenJti: (r.token_jti ?? r.tokenJti ?? null),
393
+ catalogScope: (r.catalog_scope ?? r.catalogScope) === "full" ? "full" : null,
389
394
  createdAt: numOrNull(r.created_at ?? r.createdAt),
390
395
  expiresAt: numOrNull(r.expires_at ?? r.expiresAt),
391
396
  consumedAt: numOrNull(r.consumed_at ?? r.consumedAt),
392
397
  };
393
398
  }
394
399
  export async function getDeviceCode(deviceCode) {
395
- try {
396
- await ensureTable();
397
- const client = getDbExec();
398
- const { rows } = await client.execute({
399
- sql: `SELECT * FROM mcp_device_codes WHERE device_code = ?`,
400
- args: [deviceCode],
401
- });
402
- if (rows.length === 0)
403
- return null;
404
- return mapDeviceRow(rows[0]);
405
- }
406
- catch (err) {
407
- if (isConnectionError(err))
408
- return null;
409
- throw err;
410
- }
400
+ await ensureTable();
401
+ const client = getDbExec();
402
+ const { rows } = await client.execute({
403
+ sql: `SELECT * FROM mcp_device_codes WHERE device_code = ?`,
404
+ args: [deviceCode],
405
+ });
406
+ if (rows.length === 0)
407
+ return null;
408
+ return mapDeviceRow(rows[0]);
411
409
  }
412
- async function getDeviceCodeByUserCode(userCode) {
413
- try {
414
- await ensureTable();
415
- const client = getDbExec();
416
- const { rows } = await client.execute({
417
- sql: `SELECT * FROM mcp_device_codes WHERE user_code = ?`,
418
- args: [userCode],
419
- });
420
- if (rows.length === 0)
421
- return null;
422
- return mapDeviceRow(rows[0]);
423
- }
424
- catch (err) {
425
- if (isConnectionError(err))
426
- return null;
427
- throw err;
428
- }
410
+ export async function getDeviceCodeByUserCode(userCode) {
411
+ await ensureTable();
412
+ const client = getDbExec();
413
+ const { rows } = await client.execute({
414
+ sql: `SELECT * FROM mcp_device_codes WHERE user_code = ?`,
415
+ args: [userCode],
416
+ });
417
+ if (rows.length === 0)
418
+ return null;
419
+ return mapDeviceRow(rows[0]);
429
420
  }
430
421
  /**
431
422
  * Bind the logged-in user (email + org) to a pending device code, identified
@@ -11,14 +11,14 @@
11
11
  * DELETE /_agent-native/notifications/:id — delete
12
12
  */
13
13
  export declare function createNotificationsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<"" | import("./types.js").Notification[] | {
14
- error?: undefined;
15
14
  count: number;
16
15
  updated?: undefined;
16
+ error?: undefined;
17
17
  ok?: undefined;
18
18
  } | {
19
- error?: undefined;
20
19
  count?: undefined;
21
20
  updated: number;
21
+ error?: undefined;
22
22
  ok?: undefined;
23
23
  } | {
24
24
  count?: undefined;
@@ -26,8 +26,8 @@ export declare function createNotificationsHandler(): import("h3").EventHandlerW
26
26
  error: string;
27
27
  ok?: undefined;
28
28
  } | {
29
- error?: undefined;
30
29
  count?: undefined;
31
30
  updated?: undefined;
31
+ error?: undefined;
32
32
  ok: boolean;
33
33
  }>>;
@@ -0,0 +1,7 @@
1
+ declare const _default: import("../../action.js").ActionDefinition<{
2
+ runId: string;
3
+ }, {
4
+ app: import("../../mcp-client/app-result.js").AgentMcpAppPayload | null;
5
+ messages: import("../types.js").OutputReviewThreadMessage[];
6
+ }>;
7
+ export default _default;
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import { fail, defineAction } from "../../action.js";
3
+ import { getOutputReviewDetailForRun } from "../reviews.js";
4
+ export default defineAction({
5
+ description: "Load the saved preview and full chat transcript for one human-review run.",
6
+ schema: z.object({
7
+ runId: z.string().trim().min(1).max(200).describe("Agent review run ID."),
8
+ }),
9
+ http: { method: "GET" },
10
+ agentTool: false,
11
+ readOnly: true,
12
+ parallelSafe: true,
13
+ run: async (args, ctx) => {
14
+ const userId = ctx?.userEmail;
15
+ if (!userId)
16
+ fail("Sign in to view review details.", { statusCode: 401 });
17
+ const result = await getOutputReviewDetailForRun({
18
+ runId: args.runId,
19
+ userId,
20
+ });
21
+ if (!result.found)
22
+ fail("That agent output is no longer available.", { statusCode: 404 });
23
+ return { app: result.app, messages: result.messages };
24
+ },
25
+ });
@@ -1,5 +1,5 @@
1
1
  import type { AgentMcpAppPayload } from "../mcp-client/app-result.js";
2
- import type { OutputReviewListRow } from "./types.js";
2
+ import type { OutputReviewDetail, OutputReviewListRow } from "./types.js";
3
3
  export declare function getOutputReviewAppForRun(opts: {
4
4
  runId: string;
5
5
  userId: string;
@@ -9,6 +9,14 @@ export declare function getOutputReviewAppForRun(opts: {
9
9
  found: true;
10
10
  app: AgentMcpAppPayload | null;
11
11
  }>;
12
+ export declare function getOutputReviewDetailForRun(opts: {
13
+ runId: string;
14
+ userId: string;
15
+ }): Promise<{
16
+ found: false;
17
+ } | ({
18
+ found: true;
19
+ } & OutputReviewDetail)>;
12
20
  export declare function listOutputReviews(opts: {
13
21
  sinceMs: number;
14
22
  limit: number;
@@ -157,6 +157,26 @@ export async function getOutputReviewAppForRun(opts) {
157
157
  app: getInlineAppForRun(summary, thread.threadData ?? null),
158
158
  };
159
159
  }
160
+ export async function getOutputReviewDetailForRun(opts) {
161
+ const summary = await getTraceSummary(opts.runId, { userId: opts.userId });
162
+ if (!summary)
163
+ return { found: false };
164
+ if (!summary.threadId) {
165
+ return { found: true, app: null, messages: [] };
166
+ }
167
+ const threads = await resolveThreadsAccess(opts.userId, [summary.threadId]);
168
+ const thread = threads.get(summary.threadId);
169
+ if (!thread)
170
+ return { found: false };
171
+ const threadMessages = thread.threadData
172
+ ? readThreadMessages(thread.threadData)
173
+ : [];
174
+ return {
175
+ found: true,
176
+ app: getInlineAppForRun(summary, thread.threadData ?? null),
177
+ messages: threadMessages.map(({ role, text }) => ({ role, text })),
178
+ };
179
+ }
160
180
  export async function listOutputReviews(opts) {
161
181
  const summaries = await getTraceSummaries({
162
182
  sinceMs: opts.sinceMs,
@@ -41,9 +41,9 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- id?: undefined;
45
44
  summary: import("./types.js").TraceSummary;
46
45
  spans: import("./types.js").TraceSpan[];
46
+ id?: undefined;
47
47
  error?: undefined;
48
48
  ok?: undefined;
49
49
  } | {
@@ -53,15 +53,15 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
53
53
  error?: undefined;
54
54
  ok?: undefined;
55
55
  } | {
56
- id?: undefined;
57
56
  summary?: undefined;
58
57
  spans?: undefined;
58
+ id?: undefined;
59
59
  error: any;
60
60
  ok?: undefined;
61
61
  } | {
62
- id?: undefined;
63
62
  summary?: undefined;
64
63
  spans?: undefined;
64
+ id?: undefined;
65
65
  error?: undefined;
66
66
  ok: boolean;
67
67
  }>>;
@@ -85,6 +85,14 @@ export interface OutputReviewListRow {
85
85
  feedback: FeedbackEntry[];
86
86
  instructionUpdate: InstructionUpdate | null;
87
87
  }
88
+ export interface OutputReviewThreadMessage {
89
+ role: "user" | "assistant";
90
+ text: string;
91
+ }
92
+ export interface OutputReviewDetail {
93
+ app: AgentMcpAppPayload | null;
94
+ messages: OutputReviewThreadMessage[];
95
+ }
88
96
  /** @deprecated Use OutputReviewListRow for list data. */
89
97
  export interface OutputReviewRow extends OutputReviewListRow {
90
98
  inlineApp?: AgentMcpAppPayload;
@@ -53,9 +53,9 @@ export declare const setWorkspaceAppDefaultVisibilityHandler: import("h3").Event
53
53
  /** POST /_agent-native/org — create a new organization */
54
54
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
55
55
  success: boolean;
56
- id?: undefined;
57
56
  name?: undefined;
58
57
  role?: undefined;
58
+ id?: undefined;
59
59
  } | {
60
60
  success?: undefined;
61
61
  id: string;
@@ -75,8 +75,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- message?: undefined;
79
78
  id?: undefined;
79
+ found?: undefined;
80
80
  deleted?: undefined;
81
81
  providers: {
82
82
  id: string;
@@ -89,11 +89,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
89
89
  }[];
90
90
  count: number;
91
91
  provider?: undefined;
92
- found?: undefined;
93
92
  registered?: undefined;
94
93
  label?: undefined;
95
- } | {
96
94
  message?: undefined;
95
+ } | {
97
96
  id?: undefined;
98
97
  count?: undefined;
99
98
  deleted?: undefined;
@@ -102,8 +101,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
102
101
  provider: import("../custom-registry.js").CustomProviderConfig;
103
102
  registered?: undefined;
104
103
  label?: undefined;
105
- } | {
106
104
  message?: undefined;
105
+ } | {
107
106
  count?: undefined;
108
107
  deleted?: undefined;
109
108
  providers?: undefined;
@@ -112,22 +111,23 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
112
111
  id: string;
113
112
  registered?: undefined;
114
113
  label?: undefined;
115
- } | {
116
114
  message?: undefined;
115
+ } | {
116
+ found?: undefined;
117
117
  count?: undefined;
118
118
  providers?: undefined;
119
119
  provider?: undefined;
120
- found?: undefined;
121
120
  deleted: boolean;
122
121
  id: string;
123
122
  registered?: undefined;
124
123
  label?: undefined;
124
+ message?: undefined;
125
125
  } | {
126
+ found?: undefined;
126
127
  count?: undefined;
127
128
  deleted?: undefined;
128
129
  providers?: undefined;
129
130
  provider?: undefined;
130
- found?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
133
133
  label: string;
@@ -313,6 +313,8 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
313
313
  }, {
314
314
  id?: undefined;
315
315
  deleted?: undefined;
316
+ provider?: undefined;
317
+ found?: undefined;
316
318
  providers: {
317
319
  id: string;
318
320
  label: string;
@@ -323,16 +325,14 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
323
325
  updatedAt: number;
324
326
  }[];
325
327
  count: number;
326
- provider?: undefined;
327
- found?: undefined;
328
328
  registered?: undefined;
329
329
  label?: undefined;
330
330
  message?: undefined;
331
331
  } | {
332
332
  id?: undefined;
333
333
  deleted?: undefined;
334
- count?: undefined;
335
334
  providers?: undefined;
335
+ count?: undefined;
336
336
  found: boolean;
337
337
  provider: import("../custom-registry.js").CustomProviderConfig;
338
338
  registered?: undefined;
@@ -340,19 +340,19 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
340
340
  message?: undefined;
341
341
  } | {
342
342
  deleted?: undefined;
343
- count?: undefined;
344
- providers?: undefined;
345
343
  provider?: undefined;
344
+ providers?: undefined;
345
+ count?: undefined;
346
346
  found: boolean;
347
347
  id: string;
348
348
  registered?: undefined;
349
349
  label?: undefined;
350
350
  message?: undefined;
351
351
  } | {
352
- count?: undefined;
353
- providers?: undefined;
354
352
  provider?: undefined;
355
353
  found?: undefined;
354
+ providers?: undefined;
355
+ count?: undefined;
356
356
  deleted: boolean;
357
357
  id: string;
358
358
  registered?: undefined;
@@ -360,10 +360,10 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
360
360
  message?: undefined;
361
361
  } | {
362
362
  deleted?: undefined;
363
- count?: undefined;
364
- providers?: undefined;
365
363
  provider?: undefined;
366
364
  found?: undefined;
365
+ providers?: undefined;
366
+ count?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
369
369
  label: string;
@@ -5,7 +5,7 @@
5
5
  * execution uses PGlite and hosted execution uses PostgreSQL.
6
6
  */
7
7
  import path from "node:path";
8
- import { getRuntimeDatabaseUrl, toPostgresParams } from "../../db/client.js";
8
+ import { assertHostedRuntimeDatabase, getRuntimeDatabaseUrl, toPostgresParams, } from "../../db/client.js";
9
9
  import { getRequestOrgId, getRequestUserEmail, } from "../../server/request-context.js";
10
10
  import { parseArgs, fail } from "../utils.js";
11
11
  import { tryForwardDbQueryToDevServer } from "./dev-query-proxy.js";
@@ -78,6 +78,11 @@ export async function runDbQuery(options) {
78
78
  !/\bLIMIT\b/i.test(stripped)) {
79
79
  query = `${options.sql} LIMIT ${options.limit}`;
80
80
  }
81
+ // Only guarded when falling back to the ambient resolution: an explicit
82
+ // options.databaseUrl (e.g. --db pointing at a snapshot directory) is a
83
+ // deliberate operator choice, not the silent fallback this guards against.
84
+ if (!options.databaseUrl)
85
+ assertHostedRuntimeDatabase();
81
86
  // Must match the resolver `tryForwardDbQueryToDevServer` hashes for its
82
87
  // forward-eligibility check (dev-query-proxy.ts) — otherwise the same
83
88
  // command reads a different database depending on whether forwarding
@@ -56,10 +56,10 @@ export declare function createAgentEngineApiKeyHandler(): import("h3").EventHand
56
56
  ok: boolean;
57
57
  error: string;
58
58
  } | {
59
+ error?: undefined;
59
60
  ok: boolean;
60
61
  key: string;
61
62
  baseUrlKey?: string;
62
63
  scope: AgentEngineApiKeyScope;
63
- error?: undefined;
64
64
  }>>;
65
65
  export {};
@@ -6,10 +6,10 @@
6
6
  */
7
7
  export declare function createAgentEngineOllamaModelsHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
8
8
  error: string;
9
- ok?: undefined;
10
9
  models?: undefined;
10
+ ok?: undefined;
11
11
  } | {
12
- error?: undefined;
13
12
  ok: boolean;
14
13
  models: string[];
14
+ error?: undefined;
15
15
  }>>;
@@ -1419,7 +1419,8 @@ export async function processAgentTeamRun(opts) {
1419
1419
  if (u.inputTokens > 0 ||
1420
1420
  u.outputTokens > 0 ||
1421
1421
  u.cacheReadTokens > 0 ||
1422
- u.cacheWriteTokens > 0) {
1422
+ u.cacheWriteTokens > 0 ||
1423
+ u.builderCreditsUsed != null) {
1423
1424
  const { recordUsage } = await import("../usage/store.js");
1424
1425
  const label = payload.name
1425
1426
  ? `agent-team:${payload.name}`
@@ -1430,6 +1431,8 @@ export async function processAgentTeamRun(opts) {
1430
1431
  outputTokens: u.outputTokens,
1431
1432
  cacheReadTokens: u.cacheReadTokens,
1432
1433
  cacheWriteTokens: u.cacheWriteTokens,
1434
+ builderCreditsUsed: u.builderCreditsUsed,
1435
+ engineName: u.engineName ?? config.engine.name,
1433
1436
  model: u.model,
1434
1437
  label,
1435
1438
  });
@@ -672,6 +672,22 @@ function forwardBetterAuthSetCookies(event, result, options = {}) {
672
672
  }
673
673
  }
674
674
  }
675
+ async function rotateTwoFactorSession(event, session, result) {
676
+ const headers = result?.headers;
677
+ const cookieToken = headers && extractSessionTokenFromSetCookies({ headers });
678
+ if (!cookieToken)
679
+ return;
680
+ if (!session.token)
681
+ throw new Error("The current session token is missing.");
682
+ const replacement = await resolveBetterAuthSessionToken(cookieToken);
683
+ if (!replacement) {
684
+ throw new Error("Better Auth replaced the session without a resolvable token.");
685
+ }
686
+ if (replacement.token === session.token)
687
+ return;
688
+ await replaceSession(session.token, replacement.token, replacement.email);
689
+ setFrameworkSessionCookie(event, replacement.token);
690
+ }
675
691
  function betterAuthApiBody(result) {
676
692
  if (!result || typeof result !== "object")
677
693
  return {};
@@ -872,8 +888,13 @@ function appendVerifiedParamToLocation(location) {
872
888
  return `${beforeHash}${sep}verified=1${hash}`;
873
889
  }
874
890
  async function ensureEmailVerifiedForRedirect(request, response) {
875
- const email = (await emailFromVerificationResponseSession(response)) ??
876
- decodeEmailVerificationTokenEmail(request);
891
+ let email = decodeEmailVerificationTokenEmail(request);
892
+ try {
893
+ email = (await emailFromVerificationResponseSession(response)) ?? email;
894
+ }
895
+ catch (error) {
896
+ console.warn("[auth] could not resolve the magic-link session for verification repair:", error instanceof Error ? error.constructor.name : typeof error);
897
+ }
877
898
  if (!email)
878
899
  return;
879
900
  try {
@@ -909,17 +930,12 @@ async function ensureEmailVerifiedForRedirect(request, response) {
909
930
  }
910
931
  }
911
932
  async function emailFromBetterAuthSessionToken(token) {
912
- try {
913
- const db = getDbExec();
914
- const { rows } = await db.execute({
915
- sql: 'SELECT u.email FROM "session" s JOIN "user" u ON u.id = s.user_id WHERE s.token = ? LIMIT 1',
916
- args: [token],
917
- });
918
- return normalizeAuthEmail(rows[0]?.email ?? rows[0]?.[0]);
919
- }
920
- catch {
921
- return null;
922
- }
933
+ const db = getDbExec();
934
+ const { rows } = await db.execute({
935
+ sql: 'SELECT u.email FROM "session" s JOIN "user" u ON u.id = s.user_id WHERE s.token = ? LIMIT 1',
936
+ args: [token],
937
+ });
938
+ return normalizeAuthEmail(rows[0]?.email ?? rows[0]?.[0]);
923
939
  }
924
940
  async function emailFromVerificationResponseSession(response) {
925
941
  const sessionToken = extractSessionTokenFromAuthResponse(response);
@@ -1019,7 +1035,15 @@ async function persistMagicLinkLegacySession(event, response) {
1019
1035
  const rawToken = extractSessionTokenFromAuthResponse(response);
1020
1036
  if (!rawToken)
1021
1037
  return;
1022
- const resolved = await resolveBetterAuthSessionToken(rawToken);
1038
+ let resolved;
1039
+ try {
1040
+ resolved = await resolveBetterAuthSessionToken(rawToken);
1041
+ }
1042
+ catch (error) {
1043
+ console.error("[auth] failed to resolve magic-link session:", error instanceof Error ? error.constructor.name : typeof error);
1044
+ setFrameworkSessionCookie(event, decodeSessionCookieValue(rawToken));
1045
+ return;
1046
+ }
1023
1047
  const token = resolved?.token ?? decodeSessionCookieValue(rawToken);
1024
1048
  setFrameworkSessionCookie(event, token);
1025
1049
  if (!resolved)
@@ -1342,6 +1366,24 @@ export async function addSession(token, email) {
1342
1366
  // resolution for it is now wrong.
1343
1367
  invalidateSessionEmailCache();
1344
1368
  }
1369
+ async function replaceSession(oldToken, newToken, email) {
1370
+ await ensureSessionTable();
1371
+ const client = getDbExec();
1372
+ if (!client.transaction) {
1373
+ throw new Error("Session rotation requires database transactions.");
1374
+ }
1375
+ await retryIfSessionsMissing(() => client.transaction(async (tx) => {
1376
+ await tx.execute({
1377
+ sql: `INSERT INTO sessions (token, email, created_at) VALUES (?, ?, ?) ON CONFLICT (token) DO UPDATE SET email=EXCLUDED.email, created_at=EXCLUDED.created_at`,
1378
+ args: [newToken, email ?? null, Date.now()],
1379
+ });
1380
+ await tx.execute({
1381
+ sql: `DELETE FROM sessions WHERE token = ?`,
1382
+ args: [oldToken],
1383
+ });
1384
+ }));
1385
+ invalidateSessionEmailCache();
1386
+ }
1345
1387
  export async function hasLegacySessionForEmail(email) {
1346
1388
  await ensureSessionTable();
1347
1389
  const client = getDbExec();
@@ -4594,9 +4636,8 @@ async function mountBetterAuthRoutes(app, options) {
4594
4636
  headers: betterAuthHeadersForSession(event, session.token),
4595
4637
  returnHeaders: true,
4596
4638
  });
4597
- forwardBetterAuthSetCookies(event, result, {
4598
- excludeSessionCookies: true,
4599
- });
4639
+ await rotateTwoFactorSession(event, session, result);
4640
+ forwardBetterAuthSetCookies(event, result);
4600
4641
  return betterAuthApiBody(result);
4601
4642
  }
4602
4643
  catch (error) {
@@ -4619,9 +4660,8 @@ async function mountBetterAuthRoutes(app, options) {
4619
4660
  headers: betterAuthHeadersForSession(event, session.token),
4620
4661
  returnHeaders: true,
4621
4662
  });
4622
- forwardBetterAuthSetCookies(event, result, {
4623
- excludeSessionCookies: true,
4624
- });
4663
+ await rotateTwoFactorSession(event, session, result);
4664
+ forwardBetterAuthSetCookies(event, result);
4625
4665
  return betterAuthApiBody(result);
4626
4666
  }
4627
4667
  catch (error) {
@@ -25,7 +25,7 @@ import { setCookie } from "h3";
25
25
  import { enterpriseAuthAdaptersBuilt, getAppConfig, } from "../app-config/index.js";
26
26
  import { TEMPLATES } from "../cli/templates-meta.js";
27
27
  import { getDbExec } from "../db/client.js";
28
- import { getRuntimeDatabaseUrl, getPgliteClient, isPgliteUrl, loadPgliteDrizzle, pgliteDrizzleClient, pgPoolOptions, neonPoolOptions, guardNeonPool, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, } from "../db/client.js";
28
+ import { assertHostedRuntimeDatabase, getRuntimeDatabaseUrl, getPgliteClient, isPgliteUrl, loadPgliteDrizzle, pgliteDrizzleClient, pgPoolOptions, neonPoolOptions, guardNeonPool, sharedDbPool, onSharedDbPoolsClosed, onSharedDbPoolReplaced, } from "../db/client.js";
29
29
  import { CORE_CHANGE_EMAIL_CONFIRMATION_EMAIL_ID, CORE_CHANGE_EMAIL_VERIFICATION_EMAIL_ID, CORE_MAGIC_LINK_EMAIL_ID, CORE_RESET_PASSWORD_EMAIL_ID, CORE_VERIFY_SIGNUP_EMAIL_ID, } from "../email-catalog/system-emails.js";
30
30
  import { executeIdentityRekey, rekeyIdentity, resumePendingIdentityRekeys, verifiedEmailChangeFromToken, } from "../identity/rekey.js";
31
31
  import { saveOAuthTokens } from "../oauth-tokens/store.js";
@@ -2010,6 +2010,12 @@ async function createBetterAuthInstance(config) {
2010
2010
  return auth;
2011
2011
  }
2012
2012
  export async function buildDatabaseConfig() {
2013
+ // getDbExec() (client.ts's initClient) and createGetDb()'s Drizzle opener
2014
+ // both refuse a hosted invocation with no database URL before resolving
2015
+ // it. This adapter resolves the same runtime URL but used to skip the
2016
+ // refusal entirely, so signup/login reaching this opener first silently
2017
+ // opened the ephemeral per-instance PGlite file instead of failing loudly.
2018
+ assertHostedRuntimeDatabase();
2013
2019
  const url = getRuntimeDatabaseUrl("pglite:./data/pglite");
2014
2020
  const { buildResilientNeonPool, buildResilientPostgresJsClient, isNeonUrl } = await import("../db/create-get-db.js");
2015
2021
  if (isPgliteUrl(url)) {
@@ -419,8 +419,8 @@ export declare function createPublicRemoteAgentsHandler(discover?: PublicAgentDi
419
419
  error: string;
420
420
  agents?: undefined;
421
421
  } | {
422
- agents: Omit<import("./agent-discovery.js").DiscoveredAgent, "auth" | "kind">[];
423
422
  error?: undefined;
423
+ agents: Omit<import("./agent-discovery.js").DiscoveredAgent, "auth" | "kind">[];
424
424
  }>>;
425
425
  export declare function getBuilderConnectErrorDisposition(error: unknown, connectAttemptId: string | null): "correlated" | "legacy" | null;
426
426
  export declare function getBuilderConnectErrorKey(ownerEmail: string, connectAttemptId?: string | null): string;