@agent-native/core 0.175.4 → 0.175.5-nightly-20260827014436

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 (202) hide show
  1. package/corpus/templates/analytics/actions/get-explorer-dashboard.ts +1 -0
  2. package/corpus/templates/analytics/app/components/auth/AuthProvider.tsx +8 -6
  3. package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +32 -0
  4. package/corpus/templates/analytics/app/components/layout/Layout.tsx +1 -1
  5. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +66 -7
  6. package/corpus/templates/analytics/app/lib/prefetch-keys.ts +10 -0
  7. package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +9 -7
  8. package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +10 -11
  9. package/corpus/templates/analytics/changelog/2026-08-24-feature-flag-changes-recover-from-temporary-workspace-direct.md +6 -0
  10. package/corpus/templates/analytics/changelog/2026-08-26-analytics-distinguishes-daily-from-weekly-activity-shows-sta.md +6 -0
  11. package/corpus/templates/analytics/changelog/2026-08-26-dashboard-metadata-now-shows-the-original-creator-separately.md +6 -0
  12. package/corpus/templates/analytics/changelog/2026-08-26-dashboard-names-stay-editable-when-the-analytics-sidebar-ref.md +6 -0
  13. package/corpus/templates/analytics/changelog/2026-08-26-fixed-the-agent-re-asking-dashboard-scope-questions-you-had-.md +6 -0
  14. package/corpus/templates/analytics/server/db/schema.ts +2 -0
  15. package/corpus/templates/analytics/server/lib/agent-readable-resource-context.ts +8 -2
  16. package/corpus/templates/analytics/server/lib/dashboards-store.ts +5 -0
  17. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +6 -4
  18. package/corpus/templates/analytics/server/lib/migrate-analytics-artifacts.ts +19 -1
  19. package/corpus/templates/analytics/server/lib/workspace-feature-flags.ts +40 -9
  20. package/corpus/templates/analytics/server/plugins/db.ts +10 -0
  21. package/corpus/templates/analytics/server/routes/api/dashboard-agent-context.json.get.ts +1 -0
  22. package/corpus/templates/analytics/shared/feature-flags.ts +11 -1
  23. package/corpus/templates/calendar/app/components/calendar/GoogleConnectBanner.tsx +2 -9
  24. package/corpus/templates/clips/.agents/skills/ai-video-tools/SKILL.md +8 -7
  25. package/corpus/templates/clips/.agents/skills/recording/SKILL.md +9 -8
  26. package/corpus/templates/clips/actions/import-loom-recording.ts +1 -1
  27. package/corpus/templates/clips/actions/lib/loom-import-job.ts +52 -35
  28. package/corpus/templates/clips/actions/request-transcript.ts +6 -183
  29. package/corpus/templates/clips/app/components/clips-avatar.tsx +46 -0
  30. package/corpus/templates/clips/app/components/library/recording-card.tsx +8 -7
  31. package/corpus/templates/clips/app/components/library/space-card.tsx +8 -5
  32. package/corpus/templates/clips/app/components/meetings/attendee-stack.tsx +7 -8
  33. package/corpus/templates/clips/app/components/meetings/transcript-bubbles.tsx +19 -12
  34. package/corpus/templates/clips/app/components/player/transcript-panel.tsx +128 -94
  35. package/corpus/templates/clips/app/components/recorder/microphone-visualizer.tsx +25 -104
  36. package/corpus/templates/clips/app/components/workspace/members-list.tsx +8 -6
  37. package/corpus/templates/clips/app/components/workspace/notifications-list.tsx +8 -6
  38. package/corpus/templates/clips/app/components/workspace/top-creators-table.tsx +8 -6
  39. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +8 -7
  40. package/corpus/templates/clips/app/routes/_app.settings._index.tsx +0 -26
  41. package/corpus/templates/clips/app/routes/r.$recordingId.tsx +1 -4
  42. package/corpus/templates/clips/changelog/2026-08-26-detected-calls-no-longer-duplicate-meetings-or-strand-the-prompt.md +6 -0
  43. package/corpus/templates/clips/desktop/src/app.tsx +8 -10
  44. package/corpus/templates/clips/desktop/src/components/live-waveform.tsx +99 -0
  45. package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +248 -55
  46. package/corpus/templates/clips/desktop/src/lib/agent-steps.ts +477 -0
  47. package/corpus/templates/clips/desktop/src/lib/ask-sheet-layout.ts +71 -0
  48. package/corpus/templates/clips/desktop/src/lib/meeting-ask.ts +297 -0
  49. package/corpus/templates/clips/desktop/src/lib/url.ts +24 -0
  50. package/corpus/templates/clips/desktop/src/overlays/ask-steps.tsx +155 -0
  51. package/corpus/templates/clips/desktop/src/overlays/flow-bar.tsx +7 -81
  52. package/corpus/templates/clips/desktop/src/overlays/live-transcript.tsx +29 -2
  53. package/corpus/templates/clips/desktop/src/overlays/meeting-notification.tsx +80 -22
  54. package/corpus/templates/clips/desktop/src/overlays/record-pill.tsx +13 -53
  55. package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +1017 -82
  56. package/corpus/templates/clips/desktop/src/styles.css +796 -57
  57. package/corpus/templates/clips/desktop/src/tailwind.css +23 -2
  58. package/corpus/templates/clips/desktop/src-tauri/src/adhoc_meetings_watcher.rs +1765 -219
  59. package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +6 -0
  60. package/corpus/templates/clips/desktop/src-tauri/src/meetings_watcher.rs +45 -30
  61. package/corpus/templates/clips/desktop/src-tauri/src/native_screen/custom_capture.rs +5 -3
  62. package/corpus/templates/clips/desktop/src-tauri/src/notifications.rs +91 -0
  63. package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +123 -27
  64. package/corpus/templates/clips/server/routes/_agent-native/google/callback.get.ts +16 -0
  65. package/corpus/templates/clips/shared/audio-meter.ts +145 -0
  66. package/corpus/templates/clips/shared/clips-ai-prefs.ts +0 -1
  67. package/corpus/templates/clips/shared/live-waveform.tsx +119 -0
  68. package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +44 -22
  69. package/corpus/templates/content/app/components/ui/avatar.tsx +1 -0
  70. package/corpus/templates/design/app/components/visual-editor/ReviewCanvasPins.tsx +4 -1
  71. package/corpus/templates/design/app/hooks/use-question-flow.ts +9 -2
  72. package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +111 -37
  73. package/corpus/templates/design/changelog/2026-08-26-design-no-longer-asks-users-to-confirm-guided-questions-they-have-already-answered.md +6 -0
  74. package/corpus/templates/dispatch/changelog/2026-08-26-signing-out-goes-straight-to-the-sign-in-page.md +5 -0
  75. package/corpus/templates/dispatch/server/lib/org-apps-directory.ts +96 -47
  76. package/corpus/templates/dispatch/server/plugins/org-apps-directory.ts +73 -29
  77. package/corpus/templates/factory/.env.example +6 -2
  78. package/corpus/templates/factory/AGENTS.md +3 -3
  79. package/corpus/templates/factory/README.md +4 -2
  80. package/corpus/templates/factory/server/connectors/credentials.ts +70 -4
  81. package/corpus/templates/mail/actions/get-email.ts +68 -21
  82. package/corpus/templates/mail/actions/get-thread.ts +92 -51
  83. package/corpus/templates/mail/app/components/GoogleConnectBanner.tsx +2 -9
  84. package/corpus/templates/mail/app/hooks/use-emails.ts +7 -4
  85. package/corpus/templates/mail/server/lib/mail-connector-catalog.ts +7 -4
  86. package/corpus/templates/plan/app/pages/PlansPage.tsx +23 -15
  87. package/corpus/templates/slides/actions/add-deck.ts +20 -0
  88. package/corpus/templates/slides/actions/create-deck.ts +17 -7
  89. package/corpus/templates/slides/actions/delete-deck.ts +45 -5
  90. package/corpus/templates/slides/actions/get-deck.ts +77 -11
  91. package/corpus/templates/slides/actions/patch-deck.ts +14 -2
  92. package/corpus/templates/slides/actions/save-deck.ts +20 -0
  93. package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +18 -7
  94. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +38 -14
  95. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +2 -2
  96. package/corpus/templates/slides/app/components/ui/avatar.tsx +1 -0
  97. package/corpus/templates/slides/server/handlers/decks.ts +10 -0
  98. package/corpus/templates/slides/shared/slide-ids.ts +133 -0
  99. package/corpus/templates/tasks/DEVELOPING.md +8 -0
  100. package/corpus/templates/tasks/drizzle.config.ts +3 -1
  101. package/corpus/templates/tasks/drizzle.local.config.ts +6 -0
  102. package/corpus/templates/tasks/package.json +2 -1
  103. package/corpus/templates/tasks/server/db/migrations/meta/0000_snapshot.json +234 -0
  104. package/corpus/templates/tasks/server/db/migrations/meta/_journal.json +13 -0
  105. package/corpus/templates/tasks/server/db/migrations.ts +110 -0
  106. package/corpus/templates/tasks/server/plugins/db.ts +3 -87
  107. package/dist/client/AssistantChat.js +3 -10
  108. package/dist/client/guided-questions.d.ts +11 -1
  109. package/dist/client/guided-questions.js +24 -7
  110. package/dist/client/hooks/index.d.ts +2 -1
  111. package/dist/client/hooks/index.js +2 -1
  112. package/dist/client/org/OrgSwitcher.js +3 -17
  113. package/dist/client/review/ReviewThreadPanel.js +4 -2
  114. package/dist/client/sign-out.d.ts +15 -0
  115. package/dist/client/sign-out.js +82 -0
  116. package/dist/client/use-action.d.ts +2 -0
  117. package/dist/client/use-action.js +4 -2
  118. package/dist/client/use-session.d.ts +23 -1
  119. package/dist/client/use-session.js +46 -0
  120. package/dist/collab/client.js +20 -5
  121. package/dist/collab/presence.d.ts +3 -1
  122. package/dist/collab/presence.js +48 -45
  123. package/dist/collab/routes.d.ts +1 -1
  124. package/dist/db/drizzle-config.d.ts +7 -0
  125. package/dist/db/drizzle-config.js +35 -9
  126. package/dist/db/drizzle-migrations.d.ts +28 -0
  127. package/dist/db/drizzle-migrations.js +81 -0
  128. package/dist/db/index.d.ts +1 -1
  129. package/dist/db/migrations.d.ts +13 -1
  130. package/dist/db/migrations.js +60 -31
  131. package/dist/db/schema.js +4 -1
  132. package/dist/deploy/build.d.ts +6 -0
  133. package/dist/deploy/build.js +41 -0
  134. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  135. package/dist/mcp/index.d.ts +1 -1
  136. package/dist/mcp/index.js +1 -1
  137. package/dist/mcp/org-directory.d.ts +19 -7
  138. package/dist/mcp/org-directory.js +92 -68
  139. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  140. package/dist/notifications/routes.d.ts +3 -3
  141. package/dist/org/context.d.ts +6 -0
  142. package/dist/org/context.js +22 -0
  143. package/dist/org/index.d.ts +1 -1
  144. package/dist/org/index.js +1 -1
  145. package/dist/resources/store.d.ts +12 -0
  146. package/dist/resources/store.js +55 -0
  147. package/dist/server/agent-discovery.d.ts +18 -2
  148. package/dist/server/agent-discovery.js +191 -22
  149. package/dist/server/auth.js +3 -2
  150. package/dist/server/builder-browser.d.ts +0 -4
  151. package/dist/server/builder-browser.js +23 -8
  152. package/dist/server/google-oauth.d.ts +18 -0
  153. package/dist/server/google-oauth.js +3 -3
  154. package/dist/server/onboarding-html.js +3 -3
  155. package/dist/server/poll.d.ts +4 -2
  156. package/dist/server/poll.js +8 -3
  157. package/dist/server/realtime-token.d.ts +1 -1
  158. package/dist/server/short-lived-token.d.ts +1 -1
  159. package/dist/server/short-lived-token.js +1 -1
  160. package/dist/shared/environment-lanes.d.ts +1 -0
  161. package/dist/shared/environment-lanes.js +1 -0
  162. package/dist/shared/google-profile-image.d.ts +2 -0
  163. package/dist/shared/google-profile-image.js +24 -0
  164. package/dist/shared/index.d.ts +1 -0
  165. package/dist/shared/index.js +1 -0
  166. package/dist/styles/agent-conversation.css +13 -0
  167. package/docs/content/creating-templates.mdx +10 -1
  168. package/docs/content/server-database.mdx +49 -3
  169. package/docs/content/server-plugins.mdx +39 -3
  170. package/docs/content/webmcp.mdx +2 -0
  171. package/package.json +2 -1
  172. package/corpus/templates/analytics/data/explorer-configs/_autosave.json +0 -18
  173. package/corpus/templates/analytics/data/explorer-configs/steve-chart.json +0 -18
  174. package/corpus/templates/analytics/data/explorer-dashboards/dashboard-1773260837897.json +0 -10
  175. package/corpus/templates/analytics/data/sync-config.json +0 -8
  176. package/corpus/templates/brain/data/sync-config.json +0 -1
  177. package/corpus/templates/calendar/data/availability.json +0 -32
  178. package/corpus/templates/calendar/data/settings.json +0 -6
  179. package/corpus/templates/calendar/data/sync-config.json +0 -10
  180. package/corpus/templates/chat/data/sync-config.json +0 -1
  181. package/corpus/templates/clips/data/sync-config.json +0 -1
  182. package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +0 -80
  183. package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +0 -113
  184. package/corpus/templates/design/data/sync-config.json +0 -1
  185. package/corpus/templates/factory/data/sync-config.json +0 -1
  186. package/corpus/templates/forms/data/settings.json +0 -8
  187. package/corpus/templates/forms/data/sync-config.json +0 -3
  188. package/corpus/templates/macros/data/sync-config.json +0 -4
  189. package/corpus/templates/mail/data/emails.defaults.json +0 -1
  190. package/corpus/templates/mail/data/labels.defaults.json +0 -59
  191. package/corpus/templates/mail/data/settings.defaults.json +0 -9
  192. package/corpus/templates/mail/data/sync-config.json +0 -8
  193. package/corpus/templates/slides/data/sync-config.json +0 -8
  194. package/corpus/templates/tasks/data/sync-config.json +0 -1
  195. package/dist/templates/chat/data/.gitkeep +0 -0
  196. package/dist/templates/chat/data/sync-config.json +0 -1
  197. package/dist/templates/default/data/.gitkeep +0 -0
  198. package/dist/templates/default/data/sync-config.json +0 -1
  199. package/src/templates/chat/data/.gitkeep +0 -0
  200. package/src/templates/chat/data/sync-config.json +0 -1
  201. package/src/templates/default/data/.gitkeep +0 -0
  202. package/src/templates/default/data/sync-config.json +0 -1
@@ -4,17 +4,27 @@ import { getUserSetting } from "@agent-native/core/settings";
4
4
  import { z } from "zod";
5
5
 
6
6
  import { gmailGetThread } from "../server/lib/google-api.js";
7
- import { gmailToEmailMessage, isConnected } from "../server/lib/google-auth.js";
8
- import { getAccessTokens, fetchLabelMap } from "./helpers.js";
7
+ import {
8
+ getClientsWithErrors,
9
+ gmailToEmailMessage,
10
+ isConnected,
11
+ } from "../server/lib/google-auth.js";
12
+ import { fetchLabelMap } from "./helpers.js";
9
13
 
10
14
  const cliBoolean = z
11
15
  .union([z.boolean(), z.enum(["true", "false"])])
12
16
  .transform((value) => value === true || value === "true");
13
17
 
18
+ const accountCoordinate = z.union([z.string().email(), z.literal("local")]);
19
+
14
20
  export default defineAction({
15
- description: "Get all messages in an email thread by thread ID.",
21
+ description:
22
+ "Read one exact email thread without changing UNREAD or any other mailbox label.",
16
23
  schema: z.object({
17
- id: z.string().optional().describe("Thread ID"),
24
+ accountEmail: accountCoordinate.describe(
25
+ 'Connected account email, or "local" for the synthetic mailbox',
26
+ ),
27
+ id: z.string().min(1).describe("Provider-scoped email thread ID"),
18
28
  compact: cliBoolean.optional().describe("Set to true for compact summary"),
19
29
  }),
20
30
  http: { method: "GET" },
@@ -33,9 +43,9 @@ export default defineAction({
33
43
  view: "inbox",
34
44
  };
35
45
  },
36
- run: async (args) => {
37
- if (!args.id) throw new Error("--id is required");
46
+ run: async (args, ctx) => {
38
47
  const compact = args.compact === true;
48
+ const requestedAccount = args.accountEmail.toLowerCase();
39
49
 
40
50
  const ownerEmail = getRequestUserEmail();
41
51
  if (!ownerEmail) throw new Error("no authenticated user");
@@ -43,8 +53,20 @@ export default defineAction({
43
53
  const data = await getUserSetting(ownerEmail, "local-emails");
44
54
  const emails =
45
55
  data && Array.isArray((data as any).emails) ? (data as any).emails : [];
56
+ const localAccounts = new Set(
57
+ emails.map(
58
+ (email: any) => email.accountEmail?.toLowerCase() ?? "local",
59
+ ),
60
+ );
61
+ if (!localAccounts.has(requestedAccount)) {
62
+ throw new Error("Requested local account is not connected.");
63
+ }
46
64
  const messages = emails
47
- .filter((e: any) => e.threadId === args.id)
65
+ .filter(
66
+ (e: any) =>
67
+ e.threadId === args.id &&
68
+ (e.accountEmail?.toLowerCase() ?? "local") === requestedAccount,
69
+ )
48
70
  .sort(
49
71
  (a: any, b: any) =>
50
72
  new Date(a.date).getTime() - new Date(b.date).getTime(),
@@ -61,56 +83,75 @@ export default defineAction({
61
83
  date: m.date,
62
84
  }))
63
85
  : messages;
64
- return JSON.stringify(result, null, 2);
86
+ return ctx?.caller === "mcp"
87
+ ? {
88
+ accountEmail: args.accountEmail,
89
+ messages: result,
90
+ readOnlyGuarantee: {
91
+ mailboxLabels: "preserved",
92
+ gmailModifyOperations: 0,
93
+ },
94
+ }
95
+ : result;
65
96
  }
66
97
 
67
- const accounts = await getAccessTokens();
68
- if (accounts.length === 0) throw new Error("No Google account connected.");
69
-
70
- const labelMap = new Map<string, string>();
71
- await Promise.all(
72
- accounts.map(async ({ accessToken }) => {
73
- try {
74
- const map = await fetchLabelMap(accessToken);
75
- for (const [id, name] of map) labelMap.set(id, name);
76
- } catch {}
77
- }),
98
+ const { clients, errors } = await getClientsWithErrors(ownerEmail, [
99
+ requestedAccount,
100
+ ]);
101
+ const account = clients.find(
102
+ ({ email }) => email.toLowerCase() === requestedAccount,
78
103
  );
104
+ if (!account) {
105
+ if (errors[0]) throw new Error(errors[0].error);
106
+ throw new Error("Requested Google account is not connected.");
107
+ }
79
108
 
80
- for (const { email, accessToken } of accounts) {
81
- try {
82
- const threadRes = await gmailGetThread(accessToken, args.id, "full");
83
- const messages = (threadRes.messages || [])
84
- .map((m: any) =>
85
- gmailToEmailMessage(
86
- { ...m, _accountEmail: email },
87
- email,
88
- labelMap,
89
- ),
90
- )
91
- .sort(
92
- (a: any, b: any) =>
93
- new Date(a.date).getTime() - new Date(b.date).getTime(),
94
- );
109
+ const labelMap = await fetchLabelMap(account.accessToken);
95
110
 
96
- const result = compact
97
- ? messages.map((m: any) => ({
98
- id: m.id,
99
- from: m.from.name
100
- ? `${m.from.name} <${m.from.email}>`
101
- : m.from.email,
102
- subject: m.subject,
103
- snippet: m.snippet,
104
- date: m.date,
105
- }))
106
- : messages;
111
+ try {
112
+ const threadRes = await gmailGetThread(
113
+ account.accessToken,
114
+ args.id,
115
+ "full",
116
+ );
117
+ const messages = (threadRes.messages || [])
118
+ .map((m: any) =>
119
+ gmailToEmailMessage(
120
+ { ...m, _accountEmail: account.email },
121
+ account.email,
122
+ labelMap,
123
+ ),
124
+ )
125
+ .sort(
126
+ (a: any, b: any) =>
127
+ new Date(a.date).getTime() - new Date(b.date).getTime(),
128
+ );
107
129
 
108
- return JSON.stringify(result, null, 2);
109
- } catch (err: any) {
110
- if (err?.message?.includes("404")) continue;
111
- throw new Error(err?.message ?? "Gmail API error");
112
- }
130
+ const result = compact
131
+ ? messages.map((m: any) => ({
132
+ id: m.id,
133
+ from: m.from.name
134
+ ? `${m.from.name} <${m.from.email}>`
135
+ : m.from.email,
136
+ subject: m.subject,
137
+ snippet: m.snippet,
138
+ date: m.date,
139
+ }))
140
+ : messages;
141
+
142
+ return ctx?.caller === "mcp"
143
+ ? {
144
+ accountEmail: account.email,
145
+ messages: result,
146
+ readOnlyGuarantee: {
147
+ mailboxLabels: "preserved",
148
+ gmailModifyOperations: 0,
149
+ },
150
+ }
151
+ : result;
152
+ } catch (err: any) {
153
+ if (err?.message?.includes("404")) throw new Error("Thread not found.");
154
+ throw new Error(err?.message ?? "Gmail API error");
113
155
  }
114
- throw new Error("Thread not found in any connected account.");
115
156
  },
116
157
  });
@@ -1,4 +1,5 @@
1
1
  import { agentNativePath } from "@agent-native/core/client/api-path";
2
+ import { signOut } from "@agent-native/core/client/hooks";
2
3
  import {
3
4
  isInBuilderFrame,
4
5
  oauthRedirectUri,
@@ -363,15 +364,7 @@ export function GoogleConnectBanner({
363
364
  envStatus.length > 0 && envStatus.every((k) => k.configured);
364
365
 
365
366
  const handleSignOutForGoogle = useCallback(async () => {
366
- try {
367
- await fetch(agentNativePath("/_agent-native/auth/logout"), {
368
- method: "POST",
369
- credentials: "include",
370
- });
371
- } catch {
372
- // Reload below still lands on the auth screen if the local cookie changed.
373
- }
374
- window.location.reload();
367
+ await signOut();
375
368
  }, []);
376
369
 
377
370
  // When add-account URL is ready, open it and poll for new account.
@@ -587,16 +587,19 @@ export function useEmails(
587
587
  };
588
588
  }
589
589
 
590
- export function useEmail(id: string | undefined) {
590
+ export function useEmail(
591
+ id: string | undefined,
592
+ accountEmail: string | undefined,
593
+ ) {
591
594
  return useQuery<EmailMessage>({
592
- queryKey: ["email", id],
595
+ queryKey: ["email", accountEmail, id],
593
596
  queryFn: () =>
594
597
  callAction<EmailMessage>(
595
598
  "get-email",
596
- { id: id! },
599
+ { accountEmail: accountEmail!, id: id! },
597
600
  { method: "GET" },
598
601
  ).then(assertActionSuccess),
599
- enabled: !!id,
602
+ enabled: !!id && !!accountEmail,
600
603
  retry: (failureCount, error) => !isAuthFailure(error) && failureCount < 1,
601
604
  });
602
605
  }
@@ -1,12 +1,15 @@
1
1
  /**
2
2
  * Deliberately narrow authenticated MCP surface for Mail.
3
3
  *
4
- * External callers may read inbox coverage and mint a short-lived attachment
5
- * upload capability. Other actions remain available through the in-app agent,
6
- * ask_app, or an explicit full-catalog connection; tool-search alone never
7
- * makes them callable.
4
+ * External callers may read inbox coverage, retrieve exact account-scoped
5
+ * message or thread bodies, and mint a short-lived attachment upload
6
+ * capability. Other actions remain available through the in-app agent, ask_app,
7
+ * or an explicit full-catalog connection; tool-search alone never makes them
8
+ * callable.
8
9
  */
9
10
  export const MAIL_CONNECTOR_CATALOG = [
10
11
  "list-emails",
12
+ "get-email",
13
+ "get-thread",
11
14
  "create-attachment-upload",
12
15
  ] as const;
@@ -10,7 +10,11 @@ import { appPath, agentNativePath } from "@agent-native/core/client/api-path";
10
10
  import { writeClipboardText } from "@agent-native/core/client/clipboard";
11
11
  import { emailToColor, emailToName } from "@agent-native/core/client/collab";
12
12
  import { PromptComposer } from "@agent-native/core/client/composer";
13
- import { useActionQuery, useSession } from "@agent-native/core/client/hooks";
13
+ import {
14
+ useActionQuery,
15
+ useAvatarUrl,
16
+ useSession,
17
+ } from "@agent-native/core/client/hooks";
14
18
  import { useT } from "@agent-native/core/client/i18n";
15
19
  import {
16
20
  InlineMarkdown,
@@ -7505,6 +7509,23 @@ function LoggedOutEmptyPlan() {
7505
7509
 
7506
7510
  type OverviewFilter = "all" | "plans" | "recaps" | "archived" | "deleted";
7507
7511
 
7512
+ function PlanOwnerAvatar({ email }: { email: string }) {
7513
+ const avatarUrl = useAvatarUrl(email);
7514
+ const name = emailToName(email);
7515
+
7516
+ return (
7517
+ <Avatar className="size-5">
7518
+ {avatarUrl ? <AvatarImage src={avatarUrl} alt={name} /> : null}
7519
+ <AvatarFallback
7520
+ className="text-[9px] font-semibold text-primary-foreground"
7521
+ style={{ backgroundColor: emailToColor(email) }}
7522
+ >
7523
+ {commentAuthorInitials(name)}
7524
+ </AvatarFallback>
7525
+ </Avatar>
7526
+ );
7527
+ }
7528
+
7508
7529
  function PlansOverview({
7509
7530
  plans,
7510
7531
  isLoading,
@@ -7785,20 +7806,7 @@ function PlansOverview({
7785
7806
  className="flex min-w-0 items-center gap-1.5"
7786
7807
  title={plan.ownerEmail}
7787
7808
  >
7788
- <Avatar className="size-5">
7789
- <AvatarFallback
7790
- className="text-[9px] font-semibold text-white"
7791
- style={{
7792
- backgroundColor: emailToColor(
7793
- plan.ownerEmail,
7794
- ),
7795
- }}
7796
- >
7797
- {commentAuthorInitials(
7798
- emailToName(plan.ownerEmail),
7799
- )}
7800
- </AvatarFallback>
7801
- </Avatar>
7809
+ <PlanOwnerAvatar email={plan.ownerEmail} />
7802
7810
  <span className="truncate">
7803
7811
  {emailToName(plan.ownerEmail)}
7804
7812
  </span>
@@ -17,6 +17,10 @@ import { z } from "zod";
17
17
  import { getDb, schema } from "../server/db/index.js";
18
18
  import { notifyClients } from "../server/handlers/decks.js";
19
19
  import { assertHumanReadableDeckTitle } from "../shared/deck-title.js";
20
+ import {
21
+ ensureUniqueSlideIds,
22
+ repairDeckSlideReferences,
23
+ } from "../shared/slide-ids.js";
20
24
  import {
21
25
  assertDesignSystemReadable,
22
26
  assertValidAspectRatio,
@@ -37,6 +41,22 @@ export default defineAction({
37
41
  agentTool: false,
38
42
  run: async (args) => {
39
43
  const deck = args.deck as DeckPayload;
44
+ if (Array.isArray(deck.slides)) {
45
+ const normalized = ensureUniqueSlideIds(
46
+ deck.slides as Array<{ id?: unknown }>,
47
+ );
48
+ deck.slides = normalized.slides;
49
+ if (normalized.changed) {
50
+ Object.assign(
51
+ deck,
52
+ repairDeckSlideReferences(
53
+ deck,
54
+ normalized.slides,
55
+ normalized.originalIds,
56
+ ),
57
+ );
58
+ }
59
+ }
40
60
  const id = deck.id;
41
61
  if (typeof id !== "string" || !id) {
42
62
  throw deckHttpError(400, "Deck must have an id");
@@ -24,6 +24,10 @@ import {
24
24
  assertHumanReadableDeckTitle,
25
25
  repairGeneratedDeckTitle,
26
26
  } from "../shared/deck-title.js";
27
+ import {
28
+ ensureUniqueSlideIds,
29
+ rebindCreativeContextSlideLabels,
30
+ } from "../shared/slide-ids.js";
27
31
  import { getDeckUrl } from "./_app-url.js";
28
32
 
29
33
  const ReuseLabelSchema = z
@@ -159,6 +163,16 @@ export default defineAction({
159
163
  }) => {
160
164
  const db = getDb();
161
165
  const now = new Date().toISOString();
166
+ const normalizedSlides = ensureUniqueSlideIds(
167
+ rawSlides.map((s) => ({
168
+ ...s,
169
+ content: normalizeSlidePadding(s.content),
170
+ })),
171
+ );
172
+ const slides = rebindCreativeContextSlideLabels(
173
+ normalizedSlides.slides,
174
+ normalizedSlides.originalIds,
175
+ );
162
176
  const validatedCreativeContext = await validateGenerationCreativeContext({
163
177
  contextPackId,
164
178
  contextModeOverride,
@@ -166,7 +180,7 @@ export default defineAction({
166
180
  new Map(
167
181
  [
168
182
  ...reuseLabels,
169
- ...rawSlides.flatMap(
183
+ ...slides.flatMap(
170
184
  (slide) => slide.creativeContextReuseLabels ?? [],
171
185
  ),
172
186
  ].map((label) => [`${label.itemId}:${label.itemVersionId}`, label]),
@@ -186,7 +200,7 @@ export default defineAction({
186
200
  ...(label.itemVersionId ? { itemVersionId: label.itemVersionId } : {}),
187
201
  label: label.label,
188
202
  })),
189
- ...rawSlides.flatMap((slide) => {
203
+ ...slides.flatMap((slide) => {
190
204
  const labels = slide.creativeContextReuseLabels ?? [];
191
205
  return labels.length
192
206
  ? labels.map((label) => ({
@@ -206,7 +220,7 @@ export default defineAction({
206
220
  },
207
221
  ];
208
222
  }),
209
- ...(reuseLabels.length === 0 && rawSlides.length === 0
223
+ ...(reuseLabels.length === 0 && slides.length === 0
210
224
  ? [
211
225
  {
212
226
  elementId: "deck",
@@ -217,10 +231,6 @@ export default defineAction({
217
231
  : []),
218
232
  ];
219
233
 
220
- const slides = rawSlides.map((s) => ({
221
- ...s,
222
- content: normalizeSlidePadding(s.content),
223
- }));
224
234
  const firstSlideContent = slides[0]?.content;
225
235
  const resolvedTitle =
226
236
  repairGeneratedDeckTitle(title, firstSlideContent) ?? title;
@@ -27,16 +27,47 @@ export default defineAction({
27
27
  // this resource — it must run BEFORE the delete so we don't leak
28
28
  // existence to callers who lack access.
29
29
  const access = await assertAccess("deck", id, "admin");
30
+ const owner = access.resource.ownerEmail as string;
31
+ const orgId =
32
+ typeof access.resource.orgId === "string"
33
+ ? access.resource.orgId
34
+ : undefined;
30
35
  const db = getDb();
36
+ const shares = await db
37
+ .select({
38
+ principalType: schema.deckShares.principalType,
39
+ principalId: schema.deckShares.principalId,
40
+ })
41
+ .from(schema.deckShares)
42
+ .where(eq(schema.deckShares.resourceId, id));
43
+ const ownerRecipients = new Set<string>();
44
+ const orgRecipients = new Set<string>();
45
+ const normalizedOwner = owner.trim().toLowerCase();
46
+ if (normalizedOwner) ownerRecipients.add(normalizedOwner);
47
+ if (access.resource.visibility === "org" && orgId) {
48
+ orgRecipients.add(orgId);
49
+ }
50
+ for (const share of shares) {
51
+ if (
52
+ share.principalType === "user" &&
53
+ typeof share.principalId === "string"
54
+ ) {
55
+ const recipient = share.principalId.trim().toLowerCase();
56
+ if (recipient) ownerRecipients.add(recipient);
57
+ } else if (
58
+ share.principalType === "org" &&
59
+ typeof share.principalId === "string"
60
+ ) {
61
+ const recipient = share.principalId.trim();
62
+ if (recipient) orgRecipients.add(recipient);
63
+ }
64
+ }
31
65
  await db
32
66
  .delete(schema.deckVersions)
33
67
  .where(
34
68
  and(
35
69
  eq(schema.deckVersions.deckId, id),
36
- eq(
37
- schema.deckVersions.ownerEmail,
38
- access.resource.ownerEmail as string,
39
- ),
70
+ eq(schema.deckVersions.ownerEmail, owner),
40
71
  ),
41
72
  );
42
73
  const result = await db
@@ -47,7 +78,16 @@ export default defineAction({
47
78
  if (result.length === 0) {
48
79
  throw deckHttpError(404, "Deck not found");
49
80
  }
50
- notifyClients(id, "deck-deleted");
81
+ if (access.resource.visibility === "public") {
82
+ notifyClients(id, { type: "deck-deleted", visibility: "public" });
83
+ } else {
84
+ for (const recipient of ownerRecipients) {
85
+ notifyClients(id, { type: "deck-deleted", owner: recipient });
86
+ }
87
+ for (const recipient of orgRecipients) {
88
+ notifyClients(id, { type: "deck-deleted", orgId: recipient });
89
+ }
90
+ }
51
91
  return { success: true };
52
92
  } catch (err) {
53
93
  // 404 rather than 403 so callers can't probe for decks they can't see.
@@ -2,13 +2,88 @@ import { defineAction, embedApp } from "@agent-native/core";
2
2
  import { buildDeepLink } from "@agent-native/core/server";
3
3
  import { getRequestUserEmail } from "@agent-native/core/server/request-context";
4
4
  import { resolveAccess } from "@agent-native/core/sharing";
5
+ import { and, eq, isNull } from "drizzle-orm";
5
6
  import { z } from "zod";
6
7
 
8
+ import { getDb, schema } from "../server/db/index.js";
9
+ import { notifyClients } from "../server/handlers/decks.js";
7
10
  import { formatSlideHtml } from "../server/lib/slide-content-patch.js";
8
11
  import { summarizeSlideAnimationTargets } from "../server/lib/validate-slide-animations.js";
9
12
  import { normalizeOwnerEmail } from "../shared/ownership.js";
10
13
  import { hashSlideContent } from "../shared/slide-fit.js";
11
- import "../server/db/index.js"; // ensure registerShareableResource runs
14
+ import {
15
+ ensureUniqueSlideIds,
16
+ repairDeckSlideReferences,
17
+ } from "../shared/slide-ids.js";
18
+ import { withDeckLock } from "./patch-deck.js";
19
+
20
+ const MAX_REPAIR_ATTEMPTS = 3;
21
+
22
+ async function readDeck(deckId: string) {
23
+ const access = await resolveAccess("deck", deckId);
24
+ if (!access) {
25
+ // 404 rather than 403/500 so HTTP callers can't probe for decks they
26
+ // can't see, and so the slide preview can tell "missing" from "broken".
27
+ throw Object.assign(new Error("Deck not found"), { statusCode: 404 });
28
+ }
29
+
30
+ const row = access.resource;
31
+ const data = JSON.parse(row.data);
32
+ const normalized = ensureUniqueSlideIds(
33
+ Array.isArray(data?.slides) ? data.slides : [],
34
+ );
35
+ return { row, data, ...normalized };
36
+ }
37
+
38
+ async function loadDeckWithUniqueSlideIds(deckId: string) {
39
+ for (let attempt = 0; attempt < MAX_REPAIR_ATTEMPTS; attempt += 1) {
40
+ const snapshot = await readDeck(deckId);
41
+ if (!snapshot.changed) return { ...snapshot, repaired: false };
42
+
43
+ const repaired = await withDeckLock(deckId, async () => {
44
+ const lockedSnapshot = await readDeck(deckId);
45
+ if (!lockedSnapshot.changed) {
46
+ return { ...lockedSnapshot, repaired: false };
47
+ }
48
+
49
+ const repairedData = {
50
+ ...repairDeckSlideReferences(
51
+ lockedSnapshot.data,
52
+ lockedSnapshot.slides,
53
+ lockedSnapshot.originalIds,
54
+ ),
55
+ updatedAt: new Date().toISOString(),
56
+ };
57
+ const versionCondition =
58
+ typeof lockedSnapshot.row.updatedAt !== "string"
59
+ ? isNull(schema.decks.updatedAt)
60
+ : eq(schema.decks.updatedAt, lockedSnapshot.row.updatedAt);
61
+ await getDb()
62
+ .update(schema.decks)
63
+ .set({
64
+ data: JSON.stringify(repairedData),
65
+ updatedAt: repairedData.updatedAt,
66
+ })
67
+ .where(
68
+ and(
69
+ eq(schema.decks.id, lockedSnapshot.row.id),
70
+ versionCondition,
71
+ eq(schema.decks.data, lockedSnapshot.row.data),
72
+ ),
73
+ );
74
+
75
+ const confirmed = await readDeck(deckId);
76
+ return confirmed.changed ? null : { ...confirmed, repaired: true };
77
+ });
78
+
79
+ if (repaired) {
80
+ if (repaired.repaired) notifyClients(deckId);
81
+ return repaired;
82
+ }
83
+ }
84
+
85
+ throw new Error(`Could not repair duplicate slide IDs for deck ${deckId}.`);
86
+ }
12
87
 
13
88
  function stripHtml(html: string): string {
14
89
  return html
@@ -102,16 +177,7 @@ export default defineAction({
102
177
  throw new Error("--id is required.");
103
178
  }
104
179
 
105
- const access = await resolveAccess("deck", args.id);
106
- if (!access) {
107
- // 404 rather than 403/500 so HTTP callers can't probe for decks they
108
- // can't see, and so the slide preview can tell "missing" from "broken".
109
- throw Object.assign(new Error("Deck not found"), { statusCode: 404 });
110
- }
111
-
112
- const row = access.resource;
113
- const data = JSON.parse(row.data);
114
- const slides = data?.slides || [];
180
+ const { row, data, slides } = await loadDeckWithUniqueSlideIds(args.id);
115
181
  const ownerEmail = getRequestUserEmail();
116
182
  const normalizedOwnerEmail = normalizeOwnerEmail(ownerEmail);
117
183
  const selectedSlideIndex =
@@ -861,8 +861,6 @@ export default defineAction({
861
861
  // fast render landing before this line isn't discarded as stale.
862
862
  const fitSince = Date.now();
863
863
 
864
- notifyClients(deckId);
865
-
866
864
  const updatedSlideIds = [
867
865
  ...new Set(
868
866
  operations.flatMap((operation) =>
@@ -872,6 +870,20 @@ export default defineAction({
872
870
  ),
873
871
  ),
874
872
  ];
873
+ const hasMixedStructuralOperation = operations.some(
874
+ (operation) =>
875
+ operation.op === "delete-slide" ||
876
+ operation.op === "reorder-slides" ||
877
+ operation.op === "patch-deck-fields",
878
+ );
879
+ if (updatedSlideIds.length === 1 && !hasMixedStructuralOperation) {
880
+ notifyClients(deckId, {
881
+ slideId: updatedSlideIds[0],
882
+ actor: isAgentCaller ? "agent" : "human",
883
+ });
884
+ } else {
885
+ notifyClients(deckId);
886
+ }
875
887
 
876
888
  // Only slides whose HTML actually changed can newly overflow — an
877
889
  // add-slide always sets content; a patch-slide only when this batch's
@@ -23,6 +23,10 @@ import {
23
23
  assertHumanReadableDeckTitle,
24
24
  repairGeneratedDeckTitle,
25
25
  } from "../shared/deck-title.js";
26
+ import {
27
+ ensureUniqueSlideIds,
28
+ repairDeckSlideReferences,
29
+ } from "../shared/slide-ids.js";
26
30
  import {
27
31
  assertDesignSystemReadable,
28
32
  assertValidAspectRatio,
@@ -68,6 +72,22 @@ export default defineAction({
68
72
  withDeckLock(args.deckId, async () => {
69
73
  const deckId = args.deckId;
70
74
  const deck = args.deck as DeckPayload;
75
+ if (Array.isArray(deck.slides)) {
76
+ const normalized = ensureUniqueSlideIds(
77
+ deck.slides as Array<{ id?: unknown }>,
78
+ );
79
+ deck.slides = normalized.slides;
80
+ if (normalized.changed) {
81
+ Object.assign(
82
+ deck,
83
+ repairDeckSlideReferences(
84
+ deck,
85
+ normalized.slides,
86
+ normalized.originalIds,
87
+ ),
88
+ );
89
+ }
90
+ }
71
91
  assertValidAspectRatio(deck);
72
92
 
73
93
  const db = getDb();