@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
@@ -35,6 +35,12 @@ export declare function getTraceSummaries(opts: {
35
35
  excludeSpanName?: string;
36
36
  requireReviewContext?: boolean;
37
37
  }): Promise<TraceSummary[]>;
38
+ export declare function getRecentReviewRunsForThreads(opts: {
39
+ orgId: string;
40
+ threadIds: readonly string[];
41
+ sinceMs: number;
42
+ perThreadLimit?: number;
43
+ }): Promise<TraceSummary[]>;
38
44
  export declare function getTraceSummary(runId: string, opts?: {
39
45
  userId?: string;
40
46
  orgId?: string;
@@ -45,10 +51,15 @@ export declare function getOrgScopedReviewThreads(orgId: string, requested: read
45
51
  ownerEmail: string;
46
52
  threadId: string;
47
53
  }[]): Promise<Map<string, {
54
+ ownerEmail: string;
48
55
  threadData: string | null;
49
56
  title: string | null;
57
+ scopeType: string | null;
58
+ scopeId: string | null;
59
+ scopeLabel: string | null;
50
60
  }>>;
51
61
  export declare function getHumanReviewSummaries(orgId: string, runIds?: readonly string[]): Promise<Map<string, HumanReviewSummary>>;
62
+ export declare function getHumanReviewSummariesForThreads(orgId: string, threadIds: readonly string[]): Promise<Map<string, HumanReviewSummary>>;
52
63
  export declare function upsertHumanReviewSummary(summary: HumanReviewSummary): Promise<boolean>;
53
64
  /** Latest completed response in a thread, always scoped to its owner. */
54
65
  export declare function getLatestTraceSummaryForThread(threadId: string, opts: {
@@ -65,6 +76,8 @@ export declare function getFeedback(opts: {
65
76
  orgId?: string;
66
77
  source?: FeedbackEntry["source"];
67
78
  runIds?: readonly string[];
79
+ threadIds?: readonly string[];
80
+ perThreadLimit?: number;
68
81
  }): Promise<FeedbackEntry[]>;
69
82
  export declare function getFeedbackStats(sinceMs: number, opts?: {
70
83
  userId?: string;
@@ -83,6 +96,8 @@ export declare function getInstructionUpdates(opts: {
83
96
  limit?: number;
84
97
  userId?: string;
85
98
  orgId?: string;
99
+ threadIds?: readonly string[];
100
+ perThreadLimit?: number;
86
101
  }): Promise<InstructionUpdate[]>;
87
102
  export declare function upsertSatisfactionScore(score: SatisfactionScore): Promise<void>;
88
103
  export declare function getSatisfactionScores(opts: {
@@ -38,7 +38,7 @@ const persistedHumanReviewArtifactSchema = z
38
38
  const paths = {
39
39
  design: new RegExp(`^/(?:design|present)/${id}$`),
40
40
  slides: new RegExp(`^/deck/${id}(?:/present)?$`),
41
- analytics: new RegExp(`^/(?:dashboards|analyses|adhoc)/${id}$`),
41
+ analytics: new RegExp(`^(?:/(?:dashboards|analyses|adhoc)/${id}|/api/media/${id})$`),
42
42
  };
43
43
  if (!paths[artifact.appId].test(artifact.path)) {
44
44
  ctx.addIssue({
@@ -518,13 +518,29 @@ export async function getTraceSummaries(opts) {
518
518
  )
519
519
  )`
520
520
  : "";
521
- const { rows } = await client.execute({
522
- sql: `SELECT * FROM agent_trace_summaries
521
+ const select = opts.requireReviewContext
522
+ ? `SELECT * FROM (
523
+ SELECT agent_trace_summaries.*,
524
+ COUNT(*) OVER (PARTITION BY thread_id) AS run_count,
525
+ ROW_NUMBER() OVER (
526
+ PARTITION BY thread_id ORDER BY created_at DESC, run_id DESC
527
+ ) AS review_row_number
528
+ FROM agent_trace_summaries
529
+ WHERE ${where}
530
+ ${exclude}
531
+ ${reviewContext}
532
+ ) AS review_rollups
533
+ WHERE review_row_number = 1
534
+ ORDER BY created_at DESC
535
+ LIMIT ?`
536
+ : `SELECT * FROM agent_trace_summaries
523
537
  WHERE ${where}
524
538
  ${exclude}
525
539
  ${reviewContext}
526
540
  ORDER BY created_at DESC
527
- LIMIT ?`,
541
+ LIMIT ?`;
542
+ const { rows } = await client.execute({
543
+ sql: select,
528
544
  args: [
529
545
  ...args,
530
546
  ...(opts.excludeSpanName
@@ -538,6 +554,37 @@ export async function getTraceSummaries(opts) {
538
554
  });
539
555
  return rows.map(rowToTraceSummary);
540
556
  }
557
+ export async function getRecentReviewRunsForThreads(opts) {
558
+ const threadIds = [...new Set(opts.threadIds.filter(Boolean))].slice(0, 100);
559
+ if (!opts.orgId || threadIds.length === 0)
560
+ return [];
561
+ await ensureObservabilityTables();
562
+ const limit = Math.max(1, Math.min(opts.perThreadLimit ?? 6, 12));
563
+ const { rows } = await getDbExec().execute({
564
+ sql: `SELECT * FROM (
565
+ SELECT summary.*,
566
+ ROW_NUMBER() OVER (
567
+ PARTITION BY summary.thread_id
568
+ ORDER BY summary.created_at DESC, summary.run_id DESC
569
+ ) AS review_run_number
570
+ FROM agent_trace_summaries summary
571
+ INNER JOIN chat_threads thread
572
+ ON thread.id = summary.thread_id AND thread.org_id = summary.org_id
573
+ AND LOWER(thread.owner_email) = LOWER(summary.user_id)
574
+ WHERE summary.org_id = ? AND summary.created_at >= ?
575
+ AND summary.thread_id IN (${threadIds.map(() => "?").join(", ")})
576
+ AND summary.run_id NOT IN (
577
+ SELECT run_id FROM agent_trace_spans
578
+ WHERE org_id = ? AND span_type = 'agent_run'
579
+ AND name = 'agent_run:observability:human-review-summary'
580
+ )
581
+ ) AS review_runs
582
+ WHERE review_run_number <= ?
583
+ ORDER BY thread_id, created_at DESC, run_id DESC`,
584
+ args: [opts.orgId, opts.sinceMs, ...threadIds, opts.orgId, limit],
585
+ });
586
+ return rows.map(rowToTraceSummary);
587
+ }
541
588
  export async function getTraceSummary(runId, opts = {}) {
542
589
  await ensureObservabilityTables();
543
590
  const client = getDbExec();
@@ -594,9 +641,9 @@ export async function getOrgScopedReviewThreads(orgId, requested) {
594
641
  return new Map();
595
642
  const client = getDbExec();
596
643
  const { rows } = await client.execute({
597
- sql: `SELECT id,
644
+ sql: `SELECT id, owner_email,
598
645
  CASE WHEN OCTET_LENGTH(thread_data) <= ? THEN thread_data ELSE NULL END AS thread_data,
599
- title FROM chat_threads
646
+ title, scope_type, scope_id, scope_label FROM chat_threads
600
647
  WHERE org_id = ? AND (${keys
601
648
  .map(() => "(LOWER(owner_email) = LOWER(?) AND id = ?)")
602
649
  .join(" OR ")})`,
@@ -609,8 +656,14 @@ export async function getOrgScopedReviewThreads(orgId, requested) {
609
656
  return new Map(rows.map((row) => [
610
657
  String(row.id),
611
658
  {
659
+ ownerEmail: String(row.owner_email),
612
660
  threadData: typeof row.thread_data === "string" ? row.thread_data : null,
613
661
  title: typeof row.title === "string" ? row.title.slice(0, 240) : null,
662
+ scopeType: typeof row.scope_type === "string" ? row.scope_type : null,
663
+ scopeId: typeof row.scope_id === "string" ? row.scope_id : null,
664
+ scopeLabel: typeof row.scope_label === "string"
665
+ ? row.scope_label.slice(0, 240)
666
+ : null,
614
667
  },
615
668
  ]));
616
669
  }
@@ -634,6 +687,32 @@ export async function getHumanReviewSummaries(orgId, runIds) {
634
687
  return [summary.runId, summary];
635
688
  }));
636
689
  }
690
+ export async function getHumanReviewSummariesForThreads(orgId, threadIds) {
691
+ const ids = [...new Set(threadIds.filter(Boolean))];
692
+ if (!orgId || ids.length === 0)
693
+ return new Map();
694
+ await ensureObservabilityTables();
695
+ const { rows } = await getDbExec().execute({
696
+ sql: `SELECT review.*, trace.thread_id AS review_thread_id
697
+ FROM agent_human_review_summaries review
698
+ INNER JOIN agent_trace_summaries trace
699
+ ON trace.run_id = review.run_id AND trace.org_id = review.org_id
700
+ INNER JOIN chat_threads thread
701
+ ON thread.id = trace.thread_id AND thread.org_id = trace.org_id
702
+ AND LOWER(thread.owner_email) = LOWER(trace.user_id)
703
+ WHERE review.org_id = ? AND trace.thread_id IN (${ids.map(() => "?").join(", ")})
704
+ ORDER BY review.updated_at DESC, review.run_id DESC`,
705
+ args: [orgId, ...ids],
706
+ });
707
+ const summaries = new Map();
708
+ for (const row of rows) {
709
+ const threadId = String(row.review_thread_id ?? "");
710
+ if (threadId && !summaries.has(threadId)) {
711
+ summaries.set(threadId, parseHumanReviewSummaryRow(row));
712
+ }
713
+ }
714
+ return summaries;
715
+ }
637
716
  export async function upsertHumanReviewSummary(summary) {
638
717
  await ensureObservabilityTables();
639
718
  const client = getDbExec();
@@ -704,6 +783,11 @@ export async function getFeedback(opts) {
704
783
  : undefined;
705
784
  if (runIds?.length === 0)
706
785
  return [];
786
+ const threadIds = opts.threadIds
787
+ ? [...new Set(opts.threadIds.filter(Boolean))]
788
+ : undefined;
789
+ if (threadIds?.length === 0)
790
+ return [];
707
791
  await ensureObservabilityTables();
708
792
  const client = getDbExec();
709
793
  const conditions = [];
@@ -716,6 +800,10 @@ export async function getFeedback(opts) {
716
800
  conditions.push(`run_id IN (${runIds.map(() => "?").join(", ")})`);
717
801
  args.push(...runIds);
718
802
  }
803
+ if (threadIds) {
804
+ conditions.push(`thread_id IN (${threadIds.map(() => "?").join(", ")})`);
805
+ args.push(...threadIds);
806
+ }
719
807
  if (opts.sinceMs) {
720
808
  conditions.push("created_at >= ?");
721
809
  args.push(opts.sinceMs);
@@ -737,10 +825,21 @@ export async function getFeedback(opts) {
737
825
  args.push(opts.source);
738
826
  }
739
827
  const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
740
- const limit = opts.limit ?? 100;
828
+ const perThreadLimit = Math.max(1, Math.min(opts.perThreadLimit ?? 6, 12));
741
829
  const { rows } = await client.execute({
742
- sql: `SELECT * FROM agent_feedback ${where} ORDER BY created_at DESC LIMIT ?`,
743
- args: [...args, limit],
830
+ sql: threadIds
831
+ ? `SELECT * FROM (
832
+ SELECT agent_feedback.*,
833
+ ROW_NUMBER() OVER (
834
+ PARTITION BY thread_id ORDER BY created_at DESC, id DESC
835
+ ) AS feedback_row_number
836
+ FROM agent_feedback ${where}
837
+ ) AS review_feedback
838
+ WHERE feedback_row_number <= ?
839
+ ORDER BY created_at DESC, id DESC`
840
+ : `SELECT * FROM agent_feedback ${where}
841
+ ORDER BY created_at DESC LIMIT ?`,
842
+ args: [...args, threadIds ? perThreadLimit : (opts.limit ?? 100)],
744
843
  });
745
844
  return rows.map(rowToFeedback);
746
845
  }
@@ -798,6 +897,11 @@ export async function getInstructionUpdates(opts) {
798
897
  : undefined;
799
898
  if (runIds?.length === 0)
800
899
  return [];
900
+ const threadIds = opts.threadIds
901
+ ? [...new Set(opts.threadIds.filter(Boolean))]
902
+ : undefined;
903
+ if (threadIds?.length === 0)
904
+ return [];
801
905
  await ensureObservabilityTables();
802
906
  const client = getDbExec();
803
907
  const conditions = [];
@@ -810,6 +914,10 @@ export async function getInstructionUpdates(opts) {
810
914
  conditions.push(`run_id IN (${runIds.map(() => "?").join(", ")})`);
811
915
  args.push(...runIds);
812
916
  }
917
+ if (threadIds) {
918
+ conditions.push(`thread_id IN (${threadIds.map(() => "?").join(", ")})`);
919
+ args.push(...threadIds);
920
+ }
813
921
  if (opts.sinceMs) {
814
922
  conditions.push("updated_at >= ?");
815
923
  args.push(opts.sinceMs);
@@ -823,10 +931,21 @@ export async function getInstructionUpdates(opts) {
823
931
  args.push(opts.orgId);
824
932
  }
825
933
  const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
934
+ const perThreadLimit = Math.max(1, Math.min(opts.perThreadLimit ?? 1, 12));
826
935
  const { rows } = await client.execute({
827
- sql: `SELECT * FROM agent_instruction_updates ${where}
936
+ sql: threadIds
937
+ ? `SELECT * FROM (
938
+ SELECT agent_instruction_updates.*,
939
+ ROW_NUMBER() OVER (
940
+ PARTITION BY thread_id ORDER BY updated_at DESC, id DESC
941
+ ) AS update_row_number
942
+ FROM agent_instruction_updates ${where}
943
+ ) AS review_updates
944
+ WHERE update_row_number <= ?
945
+ ORDER BY updated_at DESC, id DESC`
946
+ : `SELECT * FROM agent_instruction_updates ${where}
828
947
  ORDER BY updated_at DESC LIMIT ?`,
829
- args: [...args, opts.limit ?? 500],
948
+ args: [...args, threadIds ? perThreadLimit : (opts.limit ?? 500)],
830
949
  });
831
950
  return rows.map(rowToInstructionUpdate);
832
951
  }
@@ -1266,6 +1385,7 @@ function rowToTraceSummary(row) {
1266
1385
  totalOutputTokens: Number(row.total_output_tokens ?? 0),
1267
1386
  model: String(row.model ?? ""),
1268
1387
  createdAt: Number(row.created_at),
1388
+ ...(row.run_count == null ? {} : { runCount: Number(row.run_count) }),
1269
1389
  };
1270
1390
  }
1271
1391
  function rowToFeedback(row) {
@@ -50,6 +50,8 @@ export interface TraceSummary {
50
50
  totalOutputTokens: number;
51
51
  model: string;
52
52
  createdAt: number;
53
+ /** Populated by the human-review thread rollup query. */
54
+ runCount?: number;
53
55
  }
54
56
  export type FeedbackType = "thumbs_up" | "thumbs_down" | "category" | "text";
55
57
  export interface FeedbackEntry {
@@ -90,11 +92,21 @@ export interface OutputReviewListRow {
90
92
  inlineAppTitle?: string;
91
93
  threadTitle: string;
92
94
  summary: HumanReviewSummaryPayload | null;
95
+ artifacts: HumanReviewArtifactRef[];
96
+ runs: OutputReviewRun[];
97
+ runCount: number;
98
+ authorName?: string;
99
+ authorAvatar?: string;
93
100
  model: string;
94
101
  createdAt: number;
95
102
  feedback: FeedbackEntry[];
96
103
  instructionUpdate: InstructionUpdate | null;
97
104
  }
105
+ export interface OutputReviewRun {
106
+ runId: string;
107
+ model: string;
108
+ createdAt: number;
109
+ }
98
110
  export interface HumanReviewArtifactRef {
99
111
  appId: "design" | "slides" | "analytics";
100
112
  artifactId: string;
@@ -116,10 +128,16 @@ export interface HumanReviewSummary extends HumanReviewSummaryPayload {
116
128
  export interface OutputReviewThreadMessage {
117
129
  role: "user" | "assistant";
118
130
  text: string;
131
+ toolCalls?: string[];
119
132
  }
120
133
  export interface OutputReviewDetail {
134
+ runId: string;
121
135
  app: AgentMcpAppPayload | null;
122
136
  messages: OutputReviewThreadMessage[];
137
+ artifacts: HumanReviewArtifactRef[];
138
+ summary: HumanReviewSummaryPayload | null;
139
+ ask: string;
140
+ answer: string;
123
141
  }
124
142
  /** @deprecated Use OutputReviewListRow for list data. */
125
143
  export interface OutputReviewRow extends OutputReviewListRow {
@@ -74,9 +74,9 @@ export declare const setWorkspaceAppDefaultVisibilityHandler: import("h3").Event
74
74
  /** POST /_agent-native/org — create a new organization */
75
75
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
76
76
  success: boolean;
77
+ id?: undefined;
77
78
  name?: undefined;
78
79
  role?: undefined;
79
- id?: undefined;
80
80
  } | {
81
81
  success?: undefined;
82
82
  id: string;
@@ -172,9 +172,9 @@ export declare const getMyOrgHandler: import("h3").EventHandlerWithFetch<import(
172
172
  a2aSecretSet: boolean | undefined;
173
173
  }>>;
174
174
  export declare const createOrgHandler: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
175
+ success: boolean;
175
176
  id?: undefined;
176
177
  name?: undefined;
177
- success: boolean;
178
178
  role?: undefined;
179
179
  } | {
180
180
  success?: undefined;
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- error?: undefined;
19
18
  ok: boolean;
19
+ error?: undefined;
20
20
  }>>;
@@ -75,8 +75,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- id?: undefined;
79
78
  message?: undefined;
79
+ id?: undefined;
80
80
  deleted?: undefined;
81
81
  providers: {
82
82
  id: string;
@@ -93,10 +93,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
93
93
  registered?: undefined;
94
94
  label?: undefined;
95
95
  } | {
96
- id?: undefined;
97
96
  message?: undefined;
98
- count?: undefined;
97
+ id?: undefined;
99
98
  deleted?: undefined;
99
+ count?: undefined;
100
100
  providers?: undefined;
101
101
  found: boolean;
102
102
  provider: import("../custom-registry.js").CustomProviderConfig;
@@ -104,8 +104,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
104
104
  label?: undefined;
105
105
  } | {
106
106
  message?: undefined;
107
- count?: undefined;
108
107
  deleted?: undefined;
108
+ count?: undefined;
109
109
  providers?: undefined;
110
110
  provider?: undefined;
111
111
  found: boolean;
@@ -123,8 +123,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
123
123
  registered?: undefined;
124
124
  label?: undefined;
125
125
  } | {
126
- count?: undefined;
127
126
  deleted?: undefined;
127
+ count?: undefined;
128
128
  providers?: undefined;
129
129
  provider?: undefined;
130
130
  found?: undefined;
@@ -313,6 +313,7 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
313
313
  }, {
314
314
  id?: undefined;
315
315
  deleted?: undefined;
316
+ provider?: undefined;
316
317
  providers: {
317
318
  id: string;
318
319
  label: string;
@@ -323,7 +324,6 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
323
324
  updatedAt: number;
324
325
  }[];
325
326
  count: number;
326
- provider?: undefined;
327
327
  found?: undefined;
328
328
  registered?: undefined;
329
329
  label?: undefined;
@@ -331,8 +331,8 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
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,18 +340,18 @@ 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;
353
+ providers?: undefined;
354
+ count?: undefined;
355
355
  found?: undefined;
356
356
  deleted: boolean;
357
357
  id: string;
@@ -360,9 +360,9 @@ 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;
364
+ providers?: undefined;
365
+ count?: undefined;
366
366
  found?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
@@ -57,16 +57,16 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
57
57
  /** POST /_agent-native/secrets/:key — write a secret. */
58
58
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
59
59
  error: string;
60
- status?: undefined;
61
60
  ok?: undefined;
61
+ status?: undefined;
62
62
  } | {
63
63
  ok: boolean;
64
64
  status: string;
65
65
  error?: undefined;
66
66
  } | {
67
+ ok?: undefined;
67
68
  error: string;
68
69
  removed?: undefined;
69
- ok?: undefined;
70
70
  } | {
71
71
  ok: boolean;
72
72
  removed: boolean;
@@ -77,9 +77,9 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
77
77
  * or the current stored value without changing anything.
78
78
  */
79
79
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
80
+ ok?: undefined;
80
81
  error: string;
81
82
  note?: undefined;
82
- ok?: undefined;
83
83
  } | {
84
84
  ok: boolean;
85
85
  note?: undefined;
@@ -1,6 +1,6 @@
1
1
  import type { ActionEntry, AgentLoopFinalResponseGuard, ProductionAgentOptions } from "../../agent/production-agent.js";
2
2
  import type { ActiveRun } from "../../agent/run-manager.js";
3
- import type { AgentChatAttachment, AgentChatReference, AgentChatScope, MentionProvider } from "../../agent/types.js";
3
+ import type { AgentChatScope, MentionProvider } from "../../agent/types.js";
4
4
  import type { FrameworkToolsConfig } from "../../framework-tools.js";
5
5
  import type { McpActionEntryOptions } from "../../mcp-client/index.js";
6
6
  import type { ExternalAgentPolicy } from "../../mcp/external-agent-policy.js";
@@ -19,6 +19,8 @@ export interface AgentChatPluginOptions {
19
19
  * reported by the framework without failing the completed chat turn.
20
20
  */
21
21
  onAgentTurnComplete?: (scope: AgentChatScope, run: ActiveRun) => void | Promise<void>;
22
+ /** Best-effort observer called after thread persistence for every completed agent run, including read-only runs. */
23
+ onAgentRunComplete?: (scope: AgentChatScope | null | undefined, run: ActiveRun) => void | Promise<void>;
22
24
  /** Template-specific actions (email ops, booking ops, etc.) */
23
25
  actions?: Record<string, ActionEntry> | (() => Record<string, ActionEntry> | Promise<Record<string, ActionEntry>>);
24
26
  /** @deprecated Use `actions` instead */
@@ -183,25 +185,7 @@ export interface AgentChatPluginOptions {
183
185
  * before the model sees the message, so apps can translate chat attachments
184
186
  * into template-native file handles while preserving the user's visible text.
185
187
  */
186
- prepareRequest?: (details: {
187
- event: any;
188
- ownerEmail: string | null;
189
- message: string;
190
- displayMessage?: string;
191
- attachments: AgentChatAttachment[];
192
- references: AgentChatReference[];
193
- threadId?: string;
194
- internalContinuation?: boolean;
195
- mode: "act" | "plan";
196
- }) => void | {
197
- message?: string;
198
- displayMessage?: string;
199
- attachments?: AgentChatAttachment[];
200
- } | Promise<void | {
201
- message?: string;
202
- displayMessage?: string;
203
- attachments?: AgentChatAttachment[];
204
- }>;
188
+ prepareRequest?: ProductionAgentOptions["prepareRequest"];
205
189
  /**
206
190
  * Resolve the exact native action surface for each interactive chat request.
207
191
  * Omitted allowlist names are not sent to the model or discoverable through
@@ -1,3 +1,4 @@
1
+ import { type JevCandidate } from "../../agent/jev-tool-prefetch.js";
1
2
  import { type FrameworkToolGroup } from "../../framework-tools.js";
2
3
  import type { ContextGovernanceTier, ContextManifestSourceRef, ContextSystemProvenance } from "../../shared/context-xray.js";
3
4
  import type { BuilderGatewayAuth } from "../credential-provider.js";
@@ -24,6 +25,13 @@ export interface PromptContextProvider {
24
25
  /** Register a package-owned, request-scoped system-context contribution. */
25
26
  export declare function registerPromptContextProvider(provider: PromptContextProvider): () => void;
26
27
  export declare function compactPromptLine(value: string, maxChars: number): string;
28
+ export interface JevPromptContextCandidate extends JevCandidate {
29
+ kind?: string;
30
+ name: string;
31
+ scope: string;
32
+ path?: string;
33
+ content: string;
34
+ }
27
35
  export interface PromptResourceManifestSection {
28
36
  label: string;
29
37
  provenance: ContextSystemProvenance;
@@ -82,11 +90,19 @@ export declare function resourceScopeForOwner(owner: string, currentOwner?: stri
82
90
  /** Rank and inline a few optional context sources before the first model call. */
83
91
  export declare function preloadJevContextForPrompt(options: {
84
92
  request: string;
93
+ appId?: string;
94
+ owner?: string;
95
+ orgId?: string | null;
85
96
  apiKey?: string;
86
97
  personalApiKey?: string;
87
98
  builderAuth?: BuilderGatewayAuth | null;
99
+ candidates?: readonly JevPromptContextCandidate[];
100
+ fallbackCandidateIds?: readonly string[];
88
101
  compact?: boolean;
89
102
  maxChars?: number;
103
+ contextPrefetchDeadlineAt?: number;
104
+ dispatchToBackground?: boolean;
105
+ internalContinuation?: boolean;
90
106
  }): Promise<string>;
91
107
  /**
92
108
  * Pre-load the agent's context: AGENTS.md (workspace/template/runtime