@agent-native/core 0.189.0 → 0.190.0-nightly-20260925211446

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 (233) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +10 -0
  3. package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +1 -1
  4. package/corpus/templates/analytics/AGENTS.md +11 -22
  5. package/corpus/templates/analytics/actions/list-data-dictionary.ts +7 -9
  6. package/corpus/templates/analytics/actions/search-analytics-query-catalog.ts +1 -1
  7. package/corpus/templates/analytics/app/components/AnalyticsReviewArtifactPreview.tsx +201 -0
  8. package/corpus/templates/analytics/app/i18n/en-US.ts +2 -0
  9. package/corpus/templates/analytics/app/pages/Settings.tsx +50 -3
  10. package/corpus/templates/analytics/changelog/2026-09-25-first-run-onboarding-records-setup-choices-and-builder-conne.md +6 -0
  11. package/corpus/templates/analytics/changelog/2026-09-25-human-review-previews-analytics-dashboards-as-real-charts.md +6 -0
  12. package/corpus/templates/analytics/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
  13. package/corpus/templates/analytics/changelog/2026-09-25-proactive-query-context.md +6 -0
  14. package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +98 -2
  15. package/corpus/templates/analytics/server/lib/analytics-agent-context.ts +557 -0
  16. package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +217 -46
  17. package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +2 -2
  18. package/corpus/templates/analytics/server/lib/dashboards-store.ts +39 -5
  19. package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +4 -0
  20. package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +268 -2
  21. package/corpus/templates/analytics/server/plugins/agent-chat.ts +44 -9
  22. package/corpus/templates/calendar/AGENTS.md +5 -0
  23. package/corpus/templates/calendar/CHANGELOG.md +6 -0
  24. package/corpus/templates/calendar/actions/get-event-rules-status.ts +47 -0
  25. package/corpus/templates/calendar/actions/list-events.ts +50 -4
  26. package/corpus/templates/calendar/actions/undo-calendar-event-rule.ts +229 -0
  27. package/corpus/templates/calendar/actions/update-settings.ts +8 -0
  28. package/corpus/templates/calendar/app/i18n/en-US.ts +27 -0
  29. package/corpus/templates/calendar/app/pages/Settings.tsx +196 -1
  30. package/corpus/templates/calendar/changelog/2026-09-25-calendar-feeds-with-the-same-url-keep-their-own-names-and-co.md +6 -0
  31. package/corpus/templates/calendar/changelog/2026-09-25-calendar-invitation-rules-surface-expired-connections-and-un.md +6 -0
  32. package/corpus/templates/calendar/changelog/2026-09-25-restore-locally-hidden-events-from-activity-after-disconnect.md +6 -0
  33. package/corpus/templates/calendar/server/lib/calendar-settings.ts +44 -10
  34. package/corpus/templates/calendar/server/lib/google-api.ts +15 -1
  35. package/corpus/templates/calendar/server/lib/google-calendar.ts +1 -1
  36. package/corpus/templates/calendar/server/plugins/event-rules.ts +628 -0
  37. package/corpus/templates/calendar/shared/api.ts +13 -0
  38. package/corpus/templates/calendar/shared/settings.ts +71 -1
  39. package/corpus/templates/clips/actions/create-recording.ts +83 -2
  40. package/corpus/templates/clips/actions/finalize-recording.ts +610 -110
  41. package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -0
  42. package/corpus/templates/clips/actions/import-loom-recording.ts +2 -0
  43. package/corpus/templates/clips/actions/lib/create-recording-schema.ts +7 -0
  44. package/corpus/templates/clips/actions/lib/loom-import-job.ts +15 -1
  45. package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +126 -26
  46. package/corpus/templates/clips/app/hooks/use-drop-video-upload.ts +75 -15
  47. package/corpus/templates/clips/app/routes/_app.r.$recordingId.tsx +5 -1
  48. package/corpus/templates/clips/app/routes/record.tsx +134 -40
  49. package/corpus/templates/clips/chrome-extension/src/background.ts +3 -0
  50. package/corpus/templates/clips/chrome-extension/src/offscreen.ts +73 -16
  51. package/corpus/templates/clips/desktop/src/lib/recorder.ts +188 -18
  52. package/corpus/templates/clips/desktop/src/lib/recording-request.ts +1 -0
  53. package/corpus/templates/clips/server/db/schema.ts +4 -0
  54. package/corpus/templates/clips/server/jobs/media-verification.ts +78 -4
  55. package/corpus/templates/clips/server/jobs/recording-failure-backfill.ts +142 -0
  56. package/corpus/templates/clips/server/lib/media-verification-state.ts +29 -0
  57. package/corpus/templates/clips/server/lib/post-finalize-dispatch.ts +2 -0
  58. package/corpus/templates/clips/server/lib/recording-failures.ts +111 -0
  59. package/corpus/templates/clips/server/lib/recordings.ts +6 -1
  60. package/corpus/templates/clips/server/lib/s3-upload-provider.ts +8 -3
  61. package/corpus/templates/clips/server/lib/upload-lease.ts +25 -6
  62. package/corpus/templates/clips/server/plugins/calendar-jobs.ts +2 -0
  63. package/corpus/templates/clips/server/plugins/db.ts +18 -0
  64. package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +48 -5
  65. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +322 -31
  66. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +223 -61
  67. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +62 -4
  68. package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +74 -7
  69. package/corpus/templates/clips/shared/recording-core.ts +27 -0
  70. package/corpus/templates/design/actions/get-design.ts +35 -6
  71. package/corpus/templates/mail/.agents/skills/inbox-automations/SKILL.md +4 -0
  72. package/corpus/templates/mail/actions/consolidate-ai-filter-rules.ts +41 -0
  73. package/corpus/templates/mail/actions/get-ai-priority.ts +48 -8
  74. package/corpus/templates/mail/actions/record-ai-priority-feedback.ts +69 -0
  75. package/corpus/templates/mail/actions/update-mail-preferences.ts +2 -0
  76. package/corpus/templates/mail/app/components/email/EmailList.tsx +179 -32
  77. package/corpus/templates/mail/app/components/email/EmailListItem.tsx +97 -9
  78. package/corpus/templates/mail/app/components/email/EmailThread.tsx +55 -1
  79. package/corpus/templates/mail/app/components/email/ImportanceFeedbackMenu.tsx +52 -0
  80. package/corpus/templates/mail/app/components/email/compose-autocomplete.ts +2 -1
  81. package/corpus/templates/mail/app/components/layout/AppLayout.tsx +219 -188
  82. package/corpus/templates/mail/app/components/onboarding/AiInboxSetup.tsx +338 -0
  83. package/corpus/templates/mail/app/components/settings/AiFilterSection.tsx +597 -781
  84. package/corpus/templates/mail/app/components/settings/AiRulePromptField.tsx +37 -0
  85. package/corpus/templates/mail/app/global.css +42 -26
  86. package/corpus/templates/mail/app/hooks/use-ai-priority-feedback.ts +43 -0
  87. package/corpus/templates/mail/app/hooks/use-automations.ts +23 -0
  88. package/corpus/templates/mail/app/i18n/en-US.ts +58 -3
  89. package/corpus/templates/mail/app/pages/InboxPage.tsx +47 -10
  90. package/corpus/templates/mail/changelog/2026-09-25-editing-importance-rules-preserves-disabled-instructions-and.md +6 -0
  91. package/corpus/templates/mail/changelog/2026-09-25-handle-astral-unicode-letters-in-autocomplete-word-boundarie.md +6 -0
  92. package/corpus/templates/mail/changelog/2026-09-25-jev-priority-feedback-and-inbox-settings.md +6 -0
  93. package/corpus/templates/mail/changelog/2026-09-25-keep-existing-ai-filter-rules-intact-when-saving-a-prompt.md +6 -0
  94. package/corpus/templates/mail/server/lib/automation-engine.ts +21 -12
  95. package/corpus/templates/mail/server/lib/automations.ts +100 -1
  96. package/corpus/templates/mail/shared/types.ts +3 -0
  97. package/corpus/templates/plan/app/i18n/en-US.ts +6 -0
  98. package/corpus/templates/plan/app/lib/plan-invite-suggestion.ts +43 -0
  99. package/corpus/templates/plan/app/pages/PlansPage.tsx +249 -4
  100. package/corpus/templates/slides/actions/create-deck.ts +11 -1
  101. package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +117 -1
  102. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +373 -330
  103. package/corpus/templates/slides/app/components/design-system/builder-index-response.ts +36 -5
  104. package/corpus/templates/slides/app/components/editor/BlockBubbleMenu.tsx +21 -53
  105. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +347 -671
  106. package/corpus/templates/slides/app/components/editor/bullet-editing.ts +55 -8
  107. package/corpus/templates/slides/app/components/editor/in-place-text-session.ts +2082 -0
  108. package/corpus/templates/slides/app/components/editor/list-editing.ts +174 -16
  109. package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +497 -62
  110. package/corpus/templates/slides/app/components/editor/slide-text-targets.ts +102 -20
  111. package/corpus/templates/slides/app/context/DeckContext.tsx +9 -4
  112. package/corpus/templates/slides/app/global.css +7 -219
  113. package/corpus/templates/slides/app/i18n/en-US.ts +3 -0
  114. package/corpus/templates/slides/app/lib/sanitize-slide-html.ts +7 -0
  115. package/corpus/templates/slides/app/lib/slide-image-replacement.ts +203 -1
  116. package/corpus/templates/slides/app/lib/slide-source-map.ts +43 -0
  117. package/corpus/templates/slides/app/pages/DeckEditor.tsx +182 -4
  118. package/corpus/templates/slides/app/routes/settings.tsx +33 -2
  119. package/corpus/templates/slides/changelog/2026-09-25-improve-slides-design-system-setup-feedback.md +6 -0
  120. package/corpus/templates/slides/changelog/2026-09-25-org-admins-can-review-agent-runs-from-settings.md +6 -0
  121. package/corpus/templates/slides/changelog/2026-09-25-text-on-a-slide-is-now-edited-in-place-clicking-into-it-chan.md +6 -0
  122. package/corpus/templates/slides/package.json +0 -12
  123. package/corpus/templates/slides/scripts/edit-fidelity/README.md +4 -2
  124. package/corpus/templates/slides/scripts/edit-fidelity/run.ts +12 -3
  125. package/corpus/templates/slides/vite.config.ts +1 -10
  126. package/dist/agent/jev-tool-prefetch.d.ts +29 -3
  127. package/dist/agent/jev-tool-prefetch.js +161 -34
  128. package/dist/agent/production-agent.d.ts +11 -0
  129. package/dist/agent/production-agent.js +39 -8
  130. package/dist/app-config/runtime.d.ts +1 -0
  131. package/dist/app-config/runtime.js +4 -0
  132. package/dist/app-config/schema.d.ts +1 -0
  133. package/dist/client/AgentSidebar.d.ts +3 -1
  134. package/dist/client/AgentSidebar.js +8 -12
  135. package/dist/client/analytics/index.d.ts +1 -1
  136. package/dist/client/analytics/index.js +1 -1
  137. package/dist/client/analytics.d.ts +2 -0
  138. package/dist/client/analytics.js +9 -0
  139. package/dist/client/api-path.js +5 -2
  140. package/dist/client/chat/run-recovery.d.ts +0 -3
  141. package/dist/client/chat/run-recovery.js +13 -23
  142. package/dist/client/index.d.ts +1 -1
  143. package/dist/client/index.js +1 -1
  144. package/dist/client/observability/ObservabilityDashboard.d.ts +3 -0
  145. package/dist/client/observability/ObservabilityDashboard.js +366 -71
  146. package/dist/client/observability/ObservabilityReviewSummaryButton.d.ts +4 -1
  147. package/dist/client/observability/ObservabilityReviewSummaryButton.js +13 -9
  148. package/dist/client/observability/OutputPreview.d.ts +9 -4
  149. package/dist/client/observability/OutputPreview.js +230 -52
  150. package/dist/client/onboarding/FirstRunOnboarding.js +67 -4
  151. package/dist/client/onboarding/use-onboarding.js +2 -0
  152. package/dist/client/sharing/ShareButton.d.ts +2 -0
  153. package/dist/client/sharing/ShareButton.js +1 -0
  154. package/dist/client/sharing/useShareButtonController.d.ts +1 -0
  155. package/dist/client/sharing/useShareButtonController.js +29 -8
  156. package/dist/collab/awareness.d.ts +2 -2
  157. package/dist/collab/struct-routes.d.ts +1 -1
  158. package/dist/deploy/build.js +9 -1
  159. package/dist/embeddings/index.d.ts +3 -1
  160. package/dist/embeddings/index.js +20 -10
  161. package/dist/jobs/sweep-hooks.d.ts +7 -0
  162. package/dist/jobs/sweep-hooks.js +28 -0
  163. package/dist/localization/default-messages.d.ts +1 -0
  164. package/dist/localization/default-messages.js +1 -0
  165. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  166. package/dist/notifications/routes.d.ts +1 -1
  167. package/dist/observability/actions/authorization.d.ts +1 -0
  168. package/dist/observability/actions/authorization.js +22 -0
  169. package/dist/observability/actions/get-observability-review-detail.d.ts +5 -0
  170. package/dist/observability/actions/get-observability-review-detail.js +10 -2
  171. package/dist/observability/actions/get-observability-review-summary-source.d.ts +2 -0
  172. package/dist/observability/actions/get-observability-review-summary-source.js +3 -2
  173. package/dist/observability/actions/save-observability-instruction-update.js +2 -1
  174. package/dist/observability/actions/save-observability-review-summary.js +21 -10
  175. package/dist/observability/migrations.js +25 -0
  176. package/dist/observability/reviews.d.ts +3 -1
  177. package/dist/observability/reviews.js +410 -53
  178. package/dist/observability/routes.d.ts +6 -6
  179. package/dist/observability/store.d.ts +15 -0
  180. package/dist/observability/store.js +131 -11
  181. package/dist/observability/types.d.ts +18 -0
  182. package/dist/org/handlers.d.ts +1 -1
  183. package/dist/org/index.d.ts +1 -1
  184. package/dist/progress/routes.d.ts +1 -1
  185. package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
  186. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  187. package/dist/secrets/routes.d.ts +3 -3
  188. package/dist/server/agent-chat/plugin-options.d.ts +4 -20
  189. package/dist/server/agent-chat/prompt-resources.d.ts +16 -0
  190. package/dist/server/agent-chat/prompt-resources.js +385 -22
  191. package/dist/server/agent-chat-plugin.d.ts +3 -1
  192. package/dist/server/agent-chat-plugin.js +149 -27
  193. package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
  194. package/dist/server/index.d.ts +3 -0
  195. package/dist/server/index.js +3 -0
  196. package/dist/server/prompts/framework-core-compact.js +1 -1
  197. package/dist/server/prompts/framework-core.js +1 -1
  198. package/dist/server/realtime-token.d.ts +1 -1
  199. package/dist/server/request-context.d.ts +6 -3
  200. package/dist/server/transcribe-voice.d.ts +1 -1
  201. package/dist/settings/org-settings.d.ts +4 -2
  202. package/dist/settings/org-settings.js +3 -3
  203. package/dist/settings/store.d.ts +3 -1
  204. package/dist/settings/store.js +8 -3
  205. package/dist/styles/agent-native.css +5 -0
  206. package/dist/templates/default/app/i18n/ar-SA.ts +1 -0
  207. package/dist/templates/default/app/i18n/de-DE.ts +1 -0
  208. package/dist/templates/default/app/i18n/en-US.ts +1 -0
  209. package/dist/templates/default/app/i18n/es-ES.ts +1 -0
  210. package/dist/templates/default/app/i18n/fr-FR.ts +1 -0
  211. package/dist/templates/default/app/i18n/hi-IN.ts +1 -0
  212. package/dist/templates/default/app/i18n/ja-JP.ts +1 -0
  213. package/dist/templates/default/app/i18n/ko-KR.ts +1 -0
  214. package/dist/templates/default/app/i18n/pt-BR.ts +1 -0
  215. package/dist/templates/default/app/i18n/zh-CN.ts +1 -0
  216. package/dist/templates/default/app/i18n/zh-TW.ts +1 -0
  217. package/dist/tracking/registry.js +11 -4
  218. package/package.json +4 -3
  219. package/src/templates/default/app/i18n/ar-SA.ts +1 -0
  220. package/src/templates/default/app/i18n/de-DE.ts +1 -0
  221. package/src/templates/default/app/i18n/en-US.ts +1 -0
  222. package/src/templates/default/app/i18n/es-ES.ts +1 -0
  223. package/src/templates/default/app/i18n/fr-FR.ts +1 -0
  224. package/src/templates/default/app/i18n/hi-IN.ts +1 -0
  225. package/src/templates/default/app/i18n/ja-JP.ts +1 -0
  226. package/src/templates/default/app/i18n/ko-KR.ts +1 -0
  227. package/src/templates/default/app/i18n/pt-BR.ts +1 -0
  228. package/src/templates/default/app/i18n/zh-CN.ts +1 -0
  229. package/src/templates/default/app/i18n/zh-TW.ts +1 -0
  230. package/corpus/templates/slides/app/components/editor/SlideBubbleMenu.tsx +0 -488
  231. package/corpus/templates/slides/app/components/editor/SlideInlineEditor.tsx +0 -589
  232. package/corpus/templates/slides/app/components/editor/SlideRichTextEditor.tsx +0 -1347
  233. package/corpus/templates/slides/app/components/editor/SlideSlashMenu.tsx +0 -373
@@ -0,0 +1,229 @@
1
+ import { randomUUID } from "node:crypto";
2
+
3
+ import { defineAction, fail } from "@agent-native/core/action";
4
+ import { getRequestUserEmail } from "@agent-native/core/server";
5
+ import { mutateUserSetting } from "@agent-native/core/settings";
6
+ import { z } from "zod";
7
+
8
+ import * as googleCalendar from "../server/lib/google-calendar.js";
9
+ import { normalizeCalendarSettings } from "../shared/settings.js";
10
+ import { resolveOwnedAccountEmail } from "./event-action-helpers.js";
11
+
12
+ const UNDO_CLAIMS_KEY = "__calendarEventRuleUndoClaims";
13
+ const UNDO_CLAIM_TTL_MS = 5 * 60 * 1000;
14
+ const EVENT_RULES_RUNTIME_KEY = "calendar-event-rules-runtime";
15
+
16
+ type UndoClaim = { token: string; expiresAt: number };
17
+
18
+ function readUndoClaims(value: unknown): Record<string, UndoClaim> {
19
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
20
+ return Object.fromEntries(
21
+ Object.entries(value).flatMap(([id, claim]) => {
22
+ if (
23
+ !claim ||
24
+ typeof claim !== "object" ||
25
+ typeof (claim as UndoClaim).token !== "string" ||
26
+ !Number.isFinite((claim as UndoClaim).expiresAt)
27
+ ) {
28
+ return [];
29
+ }
30
+ return [[id, claim as UndoClaim]];
31
+ }),
32
+ );
33
+ }
34
+
35
+ function conflict(): never {
36
+ return fail("This calendar action is already being undone.", {
37
+ errorCode: "conflict",
38
+ statusCode: 409,
39
+ });
40
+ }
41
+
42
+ function eventRuleKey(accountEmail: string, eventId: string) {
43
+ return `google:${accountEmail.toLowerCase()}:primary:${eventId}`;
44
+ }
45
+
46
+ export default defineAction({
47
+ description:
48
+ "Undo one recent automatic calendar invitation action, restoring its prior RSVP or removing its hidden state.",
49
+ schema: z.object({
50
+ activityId: z
51
+ .string()
52
+ .min(1)
53
+ .max(2048)
54
+ .describe("Activity id returned by get-settings for the current user"),
55
+ }),
56
+ run: async ({ activityId }) => {
57
+ const ownerEmail = getRequestUserEmail();
58
+ if (!ownerEmail) fail("Unauthenticated", { errorCode: "unauthenticated" });
59
+ const claimToken = randomUUID();
60
+ const claimed = await mutateUserSetting(
61
+ ownerEmail,
62
+ "calendar-settings",
63
+ (current) => {
64
+ const record = (current ?? {}) as Record<string, unknown>;
65
+ const latest = normalizeCalendarSettings(record);
66
+ const activity = latest.eventRuleActivity?.find(
67
+ (entry) => entry.id === activityId,
68
+ );
69
+ if (!activity)
70
+ fail("Calendar rule activity was not found or was already undone.", {
71
+ errorCode: "not_found",
72
+ statusCode: 404,
73
+ });
74
+
75
+ const now = Date.now();
76
+ const activityIds = new Set(
77
+ latest.eventRuleActivity?.map((entry) => entry.id),
78
+ );
79
+ const claims = Object.fromEntries(
80
+ Object.entries(readUndoClaims(record[UNDO_CLAIMS_KEY])).filter(
81
+ ([id, claim]) => activityIds.has(id) && claim.expiresAt > now,
82
+ ),
83
+ );
84
+ if (Object.prototype.hasOwnProperty.call(claims, activityId))
85
+ conflict();
86
+ return {
87
+ ...record,
88
+ [UNDO_CLAIMS_KEY]: {
89
+ ...claims,
90
+ [activityId]: {
91
+ token: claimToken,
92
+ expiresAt: now + UNDO_CLAIM_TTL_MS,
93
+ },
94
+ },
95
+ };
96
+ },
97
+ );
98
+ const activity = normalizeCalendarSettings(claimed).eventRuleActivity?.find(
99
+ (entry) => entry.id === activityId,
100
+ );
101
+ if (!activity) conflict();
102
+
103
+ let providerWriteAttempted = false;
104
+ let undoSuppressionKey: string | undefined;
105
+ try {
106
+ if (activity.action === "accepted" || activity.action === "declined") {
107
+ const accountEmail = await resolveOwnedAccountEmail(
108
+ activity.accountEmail,
109
+ ownerEmail,
110
+ );
111
+ const event = await googleCalendar.getEvent(activity.eventId, {
112
+ ownerEmail,
113
+ accountEmail,
114
+ });
115
+ const responseStatus =
116
+ event.responseStatus ??
117
+ event.attendees?.find(
118
+ (attendee) =>
119
+ attendee.self ||
120
+ attendee.email?.toLowerCase() === accountEmail.toLowerCase(),
121
+ )?.responseStatus;
122
+ if (
123
+ responseStatus === activity.action ||
124
+ responseStatus === "needsAction"
125
+ ) {
126
+ undoSuppressionKey = eventRuleKey(accountEmail, activity.eventId);
127
+ await mutateUserSetting(
128
+ ownerEmail,
129
+ EVENT_RULES_RUNTIME_KEY,
130
+ (current) => {
131
+ const record = (current ?? {}) as Record<string, any>;
132
+ const suppressions = {
133
+ ...(record.undoRsvpSuppressions ?? {}),
134
+ };
135
+ delete suppressions[undoSuppressionKey!];
136
+ suppressions[undoSuppressionKey!] = { token: claimToken };
137
+ return {
138
+ ...record,
139
+ undoRsvpSuppressions: Object.fromEntries(
140
+ Object.entries(suppressions).slice(-5000),
141
+ ),
142
+ };
143
+ },
144
+ );
145
+ }
146
+ if (responseStatus === activity.action) {
147
+ providerWriteAttempted = true;
148
+ await googleCalendar.rsvpEvent(
149
+ activity.eventId,
150
+ "needsAction",
151
+ { ownerEmail, accountEmail },
152
+ "single",
153
+ undefined,
154
+ "none",
155
+ );
156
+ } else if (responseStatus === "needsAction") {
157
+ // A previous request may have completed the RSVP before its settings
158
+ // write failed. Finalize it without sending the RSVP a second time.
159
+ providerWriteAttempted = true;
160
+ } else {
161
+ fail("Could not undo this action.", {
162
+ errorCode: "conflict",
163
+ statusCode: 409,
164
+ });
165
+ }
166
+ }
167
+
168
+ await mutateUserSetting(ownerEmail, "calendar-settings", (current) => {
169
+ const record = (current ?? {}) as Record<string, unknown>;
170
+ const latest = normalizeCalendarSettings(record);
171
+ const claims = readUndoClaims(record[UNDO_CLAIMS_KEY]);
172
+ if (
173
+ !Object.prototype.hasOwnProperty.call(claims, activityId) ||
174
+ claims[activityId]?.token !== claimToken
175
+ )
176
+ conflict();
177
+ const nextClaims = { ...claims };
178
+ delete nextClaims[activityId];
179
+ return {
180
+ ...record,
181
+ [UNDO_CLAIMS_KEY]: nextClaims,
182
+ eventRuleActivity: latest.eventRuleActivity?.filter(
183
+ (entry) => entry.id !== activityId,
184
+ ),
185
+ ...(activity.action === "hidden"
186
+ ? {
187
+ hiddenEventKeys: latest.hiddenEventKeys?.filter(
188
+ (key) => key !== activity.hiddenEventKey,
189
+ ),
190
+ }
191
+ : {}),
192
+ };
193
+ });
194
+ return { success: true, activityId };
195
+ } catch (error) {
196
+ if (!providerWriteAttempted) {
197
+ if (undoSuppressionKey) {
198
+ await mutateUserSetting(
199
+ ownerEmail,
200
+ EVENT_RULES_RUNTIME_KEY,
201
+ (current) => {
202
+ const record = (current ?? {}) as Record<string, any>;
203
+ const suppressions = {
204
+ ...(record.undoRsvpSuppressions ?? {}),
205
+ };
206
+ if (suppressions[undoSuppressionKey!]?.token !== claimToken)
207
+ return record;
208
+ delete suppressions[undoSuppressionKey!];
209
+ return { ...record, undoRsvpSuppressions: suppressions };
210
+ },
211
+ );
212
+ }
213
+ await mutateUserSetting(ownerEmail, "calendar-settings", (current) => {
214
+ const record = (current ?? {}) as Record<string, unknown>;
215
+ const claims = readUndoClaims(record[UNDO_CLAIMS_KEY]);
216
+ if (
217
+ !Object.prototype.hasOwnProperty.call(claims, activityId) ||
218
+ claims[activityId]?.token !== claimToken
219
+ )
220
+ return record;
221
+ const nextClaims = { ...claims };
222
+ delete nextClaims[activityId];
223
+ return { ...record, [UNDO_CLAIMS_KEY]: nextClaims };
224
+ });
225
+ }
226
+ throw error;
227
+ }
228
+ },
229
+ });
@@ -31,6 +31,14 @@ export default defineAction({
31
31
  .enum(["sunday", "monday"])
32
32
  .optional()
33
33
  .describe("First day shown in calendar weeks"),
34
+ eventRules: z
35
+ .object({
36
+ accept: z.string().max(2000).optional(),
37
+ decline: z.string().max(2000).optional(),
38
+ hide: z.string().max(2000).optional(),
39
+ })
40
+ .optional()
41
+ .describe("Jev rules for new calendar invitations"),
34
42
  }),
35
43
  run: async (args) => {
36
44
  const email = getRequestUserEmail();
@@ -249,6 +249,33 @@ export default {
249
249
  weekStartLabel: "Week starts on",
250
250
  weekStartSunday: "Sunday - Saturday",
251
251
  weekStartMonday: "Monday - Sunday",
252
+ eventRules: "Invitation rules",
253
+ eventRuleAccept: "Auto accept",
254
+ eventRuleDecline: "Auto decline",
255
+ eventRuleHide: "Auto hide",
256
+ eventRulePlaceholderAccept: "Example: Accept one-on-ones from my team",
257
+ eventRulePlaceholderDecline:
258
+ "Example: Decline vendor demos and after-hours events",
259
+ eventRulePlaceholderHide: "Example: Hide focus blocks and reminders",
260
+ eventRulesSave: "Save rules",
261
+ eventRulesRecentActivity: "Recent activity",
262
+ eventRulesNoActivity: "No activity yet",
263
+ eventRuleActivityAccepted: "Accepted",
264
+ eventRuleActivityDeclined: "Declined",
265
+ eventRuleActivityHidden: "Hidden",
266
+ eventRuleUndoDone: "Action undone",
267
+ eventRuleUndoFailed: "Could not undo this action",
268
+ eventRulesActive:
269
+ "Rules run every 5 minutes on connected accounts' primary calendars.",
270
+ eventRulesDisabled:
271
+ "Enable RUN_BACKGROUND_JOBS=1 on a long-lived Calendar worker.",
272
+ eventRulesDeploymentDisabled:
273
+ "Scheduled automation is disabled for this deployment.",
274
+ eventRulesChecking: "Checking automation status…",
275
+ eventRulesConflict:
276
+ "An invitation was skipped because accept and decline both matched.",
277
+ eventRulesUnregistered:
278
+ "Calendar automation is not registered in this server.",
252
279
  },
253
280
  eventDialog: {
254
281
  eventUpdated: "Event updated",
@@ -1,5 +1,10 @@
1
1
  import { ChangelogSettingsCard } from "@agent-native/core/client/changelog";
2
- import { callAction } from "@agent-native/core/client/hooks";
2
+ import {
3
+ callAction,
4
+ useActionMutation,
5
+ useActionQuery,
6
+ actionErrorMessage,
7
+ } from "@agent-native/core/client/hooks";
3
8
  import { LanguagePicker, useT } from "@agent-native/core/client/i18n";
4
9
  import { startWorkspaceProviderOAuth } from "@agent-native/core/client/integrations";
5
10
  import { TeamPage } from "@agent-native/core/client/org";
@@ -76,6 +81,28 @@ export default function Settings() {
76
81
  const agentSettingsTabs = useAgentSettingsTabs();
77
82
  const { data: settings } = useSettings();
78
83
  const updateSettings = useUpdateSettings();
84
+ const eventRulesStatus = useActionQuery<{
85
+ enabled: boolean;
86
+ intervalMinutes: number | null;
87
+ message: string | null;
88
+ lastError: string | null;
89
+ accountRefreshErrors: Array<{ email: string; error: string }>;
90
+ conflictsSkipped: boolean;
91
+ reason: string | null;
92
+ registered: boolean;
93
+ }>("get-event-rules-status");
94
+ const undoEventRuleActivity = useActionMutation<
95
+ { success: boolean; activityId: string },
96
+ { activityId: string }
97
+ >("undo-calendar-event-rule", {
98
+ onSuccess: () => toast.success(t("settings.eventRuleUndoDone")),
99
+ onError: (error) => {
100
+ const code = (error as { errorCode?: unknown } | null)?.errorCode;
101
+ const message =
102
+ code === "conflict" ? undefined : actionErrorMessage(error);
103
+ toast.error(message ?? t("settings.eventRuleUndoFailed"));
104
+ },
105
+ });
79
106
  const googleStatus = useGoogleAuthStatus();
80
107
  const disconnectGoogle = useDisconnectGoogle();
81
108
  const {
@@ -97,6 +124,26 @@ export default function Settings() {
97
124
  const [bookingDescription, setBookingDescription] = useState("");
98
125
  const [defaultDuration, setDefaultDuration] = useState(30);
99
126
  const [weekStart, setWeekStart] = useState<CalendarWeekStart>("sunday");
127
+ const [eventRules, setEventRules] = useState({
128
+ accept: "",
129
+ decline: "",
130
+ hide: "",
131
+ });
132
+ const eventRuleLabels = {
133
+ accept: t("settings.eventRuleAccept"),
134
+ decline: t("settings.eventRuleDecline"),
135
+ hide: t("settings.eventRuleHide"),
136
+ };
137
+ const eventRulePlaceholders = {
138
+ accept: t("settings.eventRulePlaceholderAccept"),
139
+ decline: t("settings.eventRulePlaceholderDecline"),
140
+ hide: t("settings.eventRulePlaceholderHide"),
141
+ };
142
+ const eventRuleActivityLabels = {
143
+ accepted: t("settings.eventRuleActivityAccepted"),
144
+ declined: t("settings.eventRuleActivityDeclined"),
145
+ hidden: t("settings.eventRuleActivityHidden"),
146
+ };
100
147
  const [notificationPermission, setNotificationPermission] =
101
148
  useState<NotificationPermission | null>(() =>
102
149
  getMeetingStartNotificationPermission(),
@@ -113,6 +160,18 @@ export default function Settings() {
113
160
  setWeekStart(
114
161
  isCalendarWeekStart(settings.weekStart) ? settings.weekStart : "sunday",
115
162
  );
163
+ const nextEventRules = {
164
+ accept: settings.eventRules?.accept ?? "",
165
+ decline: settings.eventRules?.decline ?? "",
166
+ hide: settings.eventRules?.hide ?? "",
167
+ };
168
+ setEventRules((current) =>
169
+ current.accept === nextEventRules.accept &&
170
+ current.decline === nextEventRules.decline &&
171
+ current.hide === nextEventRules.hide
172
+ ? current
173
+ : nextEventRules,
174
+ );
116
175
  }
117
176
  }, [settings]);
118
177
 
@@ -132,6 +191,16 @@ export default function Settings() {
132
191
  );
133
192
  }
134
193
 
194
+ function handleSaveRules() {
195
+ updateSettings.mutate(
196
+ { eventRules },
197
+ {
198
+ onSuccess: () => toast.success(t("settings.saved")),
199
+ onError: () => toast.error(t("settings.saveFailed")),
200
+ },
201
+ );
202
+ }
203
+
135
204
  function handleConnect() {
136
205
  if (isDesktopGoogleAuth) {
137
206
  startDesktopGoogleAuth({
@@ -223,6 +292,12 @@ export default function Settings() {
223
292
  "timezone week start sunday monday booking duration defaults general",
224
293
  hash: "general-settings",
225
294
  },
295
+ {
296
+ id: "calendar-event-rules",
297
+ label: t("settings.eventRules"),
298
+ keywords: "jev invitation rules accept decline hide",
299
+ hash: "event-rules",
300
+ },
226
301
  {
227
302
  id: "calendar-availability",
228
303
  label: t("bookingLinks.availability"),
@@ -244,6 +319,24 @@ export default function Settings() {
244
319
  ],
245
320
  [t],
246
321
  );
322
+ const hasEventRules = Object.values(eventRules).some((rule) => rule.trim());
323
+ const statusData = eventRulesStatus.data;
324
+ const unavailableRulesMessage =
325
+ statusData?.enabled === false && hasEventRules
326
+ ? t(
327
+ !statusData.registered
328
+ ? "settings.eventRulesUnregistered"
329
+ : statusData.reason === "disabled-by-env"
330
+ ? "settings.eventRulesDeploymentDisabled"
331
+ : "settings.eventRulesDisabled",
332
+ )
333
+ : null;
334
+ const eventRulesStatusError = eventRulesStatus.isError
335
+ ? t("common.loadFailed")
336
+ : (statusData?.lastError ??
337
+ (statusData?.conflictsSkipped
338
+ ? t("settings.eventRulesConflict")
339
+ : unavailableRulesMessage));
247
340
 
248
341
  return (
249
342
  <SettingsTabsPage
@@ -324,6 +417,108 @@ export default function Settings() {
324
417
  />
325
418
  </SettingsGroup>
326
419
 
420
+ <Card id="event-rules" className="scroll-mt-16">
421
+ <CardHeader>
422
+ <CardTitle className="text-lg">
423
+ {t("settings.eventRules")}
424
+ </CardTitle>
425
+ </CardHeader>
426
+ <CardContent className="space-y-4">
427
+ {eventRulesStatusError ? (
428
+ <p className="text-sm text-destructive" role="status">
429
+ {eventRulesStatusError}
430
+ </p>
431
+ ) : null}
432
+ {statusData?.accountRefreshErrors.map(({ email, error }) => (
433
+ <p
434
+ key={email}
435
+ className="text-sm text-destructive"
436
+ role="status"
437
+ >
438
+ {email}: {error}
439
+ </p>
440
+ ))}
441
+ {(["accept", "decline", "hide"] as const).map((rule) => (
442
+ <div key={rule} className="space-y-2">
443
+ <Label htmlFor={`event-rule-${rule}`}>
444
+ {eventRuleLabels[rule]}
445
+ </Label>
446
+ <Textarea
447
+ id={`event-rule-${rule}`}
448
+ value={eventRules[rule]}
449
+ onChange={(event) =>
450
+ setEventRules((current) => ({
451
+ ...current,
452
+ [rule]: event.target.value,
453
+ }))
454
+ }
455
+ placeholder={eventRulePlaceholders[rule]}
456
+ maxLength={2000}
457
+ rows={2}
458
+ />
459
+ </div>
460
+ ))}
461
+ <Button
462
+ size="sm"
463
+ onClick={handleSaveRules}
464
+ disabled={updateSettings.isPending}
465
+ >
466
+ {t("settings.eventRulesSave")}
467
+ </Button>
468
+ <details className="border-t pt-3">
469
+ <summary className="cursor-pointer text-sm font-medium">
470
+ {t("settings.eventRulesRecentActivity")}
471
+ </summary>
472
+ {settings?.eventRuleActivity?.length ? (
473
+ <ul className="mt-2 divide-y">
474
+ {[...settings.eventRuleActivity].reverse().map((entry) => (
475
+ <li
476
+ key={entry.id}
477
+ className="flex min-w-0 items-center gap-2 py-2 text-xs"
478
+ >
479
+ <span className="min-w-0 flex-1 truncate">
480
+ {entry.title || t("eventForm.ai.untitledEvent")}
481
+ </span>
482
+ <span className="shrink-0 text-muted-foreground">
483
+ {eventRuleActivityLabels[entry.action]}
484
+ </span>
485
+ <time className="shrink-0 text-muted-foreground">
486
+ {new Date(entry.occurredAt).toLocaleString(
487
+ undefined,
488
+ {
489
+ month: "short",
490
+ day: "numeric",
491
+ hour: "numeric",
492
+ minute: "2-digit",
493
+ },
494
+ )}
495
+ </time>
496
+ <Button
497
+ type="button"
498
+ variant="ghost"
499
+ size="sm"
500
+ className="h-7 shrink-0 px-2"
501
+ disabled={undoEventRuleActivity.isPending}
502
+ onClick={() =>
503
+ undoEventRuleActivity.mutate({
504
+ activityId: entry.id,
505
+ })
506
+ }
507
+ >
508
+ {t("calendarView.undo")}
509
+ </Button>
510
+ </li>
511
+ ))}
512
+ </ul>
513
+ ) : (
514
+ <p className="mt-2 text-xs text-muted-foreground">
515
+ {t("settings.eventRulesNoActivity")}
516
+ </p>
517
+ )}
518
+ </details>
519
+ </CardContent>
520
+ </Card>
521
+
327
522
  {/* Google Calendar Connection */}
328
523
  {(googleStatus.isError ||
329
524
  googleStatus.data?.connected ||
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-09-25
4
+ ---
5
+
6
+ Calendar feeds with the same URL keep their own names and colors.
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-09-25
4
+ ---
5
+
6
+ Calendar invitation rules surface expired connections and undo safely without duplicate RSVP updates
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-09-25
4
+ ---
5
+
6
+ Restore locally hidden events from activity after disconnecting an account
@@ -4,7 +4,6 @@ import {
4
4
  getUserSetting,
5
5
  mutateUserSetting,
6
6
  putSetting,
7
- putUserSetting,
8
7
  } from "@agent-native/core/settings";
9
8
 
10
9
  import type { Settings } from "../../shared/api.js";
@@ -73,16 +72,51 @@ export async function saveCalendarSettings(
73
72
  email: string,
74
73
  patch: unknown,
75
74
  ): Promise<Settings> {
76
- const settings = normalizeCalendarSettings({
77
- ...(await readCalendarSettings(email)),
78
- ...(patch && typeof patch === "object" ? patch : {}),
79
- });
75
+ const patchRecord =
76
+ patch && typeof patch === "object"
77
+ ? (patch as Record<string, unknown>)
78
+ : {};
79
+ const storedSettings = await mutateUserSetting(
80
+ email,
81
+ SETTINGS_KEY,
82
+ (current) => {
83
+ const currentRecord = current ?? {};
84
+ const currentSettings = normalizeCalendarSettings(currentRecord, {
85
+ timezone: callerTimezone(),
86
+ });
87
+ return {
88
+ ...normalizeCalendarSettings(
89
+ {
90
+ ...currentSettings,
91
+ ...patchRecord,
92
+ eventRules: {
93
+ ...currentSettings.eventRules,
94
+ ...((patchRecord.eventRules as
95
+ | Record<string, unknown>
96
+ | undefined) ?? {}),
97
+ },
98
+ },
99
+ { timezone: callerTimezone() },
100
+ ),
101
+ ...(currentRecord.__calendarEventRuleUndoClaims !== undefined
102
+ ? {
103
+ __calendarEventRuleUndoClaims:
104
+ currentRecord.__calendarEventRuleUndoClaims,
105
+ }
106
+ : {}),
107
+ } as unknown as Record<string, unknown>;
108
+ },
109
+ );
110
+ const settings = normalizeCalendarSettings(storedSettings);
80
111
  const record = settings as unknown as Record<string, unknown>;
81
- await Promise.all([
82
- putUserSetting(email, SETTINGS_KEY, record),
83
- // Also write the global key so the public booking page can read it.
84
- putSetting(SETTINGS_KEY, record),
85
- ]);
112
+ const publicRecord = { ...record };
113
+ delete publicRecord.eventRules;
114
+ delete publicRecord.hiddenEventKeys;
115
+ delete publicRecord.eventRuleActivity;
116
+ // `mutateUserSetting` already persisted the private record atomically. A
117
+ // second whole-record write here could overwrite activity recorded between
118
+ // the mutation and this public-settings update.
119
+ await putSetting(SETTINGS_KEY, publicRecord);
86
120
  return settings;
87
121
  }
88
122
 
@@ -6,6 +6,13 @@ const PEOPLE_BASE = "https://people.googleapis.com/v1";
6
6
  const CALENDAR_BASE = "https://www.googleapis.com/calendar/v3";
7
7
  const OAUTH_TOKEN_URL = "https://oauth2.googleapis.com/token";
8
8
  const OAUTH_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth";
9
+ // Keep provider requests shorter than the calendar Undo claim lease.
10
+ const GOOGLE_REQUEST_TIMEOUT_MS = 30_000;
11
+
12
+ function googleRequestSignal(signal?: AbortSignal): AbortSignal {
13
+ const timeout = AbortSignal.timeout(GOOGLE_REQUEST_TIMEOUT_MS);
14
+ return signal ? AbortSignal.any([signal, timeout]) : timeout;
15
+ }
9
16
 
10
17
  // ---------------------------------------------------------------------------
11
18
  // OAuth2 helpers
@@ -39,6 +46,7 @@ export function createOAuth2Client(
39
46
  const res = await fetch(OAUTH_TOKEN_URL, {
40
47
  method: "POST",
41
48
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
49
+ signal: googleRequestSignal(),
42
50
  body: new URLSearchParams({
43
51
  code,
44
52
  client_id: clientId,
@@ -77,6 +85,7 @@ export function createOAuth2Client(
77
85
  const res = await fetch(OAUTH_TOKEN_URL, {
78
86
  method: "POST",
79
87
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
88
+ signal: googleRequestSignal(),
80
89
  body: new URLSearchParams({
81
90
  refresh_token: refreshToken,
82
91
  client_id: clientId,
@@ -146,7 +155,11 @@ export async function googleFetch(
146
155
  const headers = new Headers(opts?.headers);
147
156
  headers.set("Authorization", `Bearer ${accessToken}`);
148
157
 
149
- const res = await fetch(url, { ...opts, headers });
158
+ const res = await fetch(url, {
159
+ ...opts,
160
+ headers,
161
+ signal: googleRequestSignal(opts?.signal ?? undefined),
162
+ });
150
163
 
151
164
  // 204 No Content — return null
152
165
  if (res.status === 204) return null;
@@ -377,6 +390,7 @@ export function calendarListEvents(
377
390
  maxResults?: number;
378
391
  pageToken?: string;
379
392
  eventTypes?: string[];
393
+ syncToken?: string;
380
394
  } = {},
381
395
  ) {
382
396
  return googleFetch(
@@ -2499,7 +2499,7 @@ async function rsvpSingleEvent(
2499
2499
  */
2500
2500
  export async function rsvpEvent(
2501
2501
  googleEventId: string,
2502
- responseStatus: "accepted" | "declined" | "tentative",
2502
+ responseStatus: "accepted" | "declined" | "tentative" | "needsAction",
2503
2503
  account: GoogleAccountSelection,
2504
2504
  scope: "single" | "all" | "thisAndFollowing" = "single",
2505
2505
  comment?: string,