@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
@@ -0,0 +1,477 @@
1
+ // What the agent did, as the ask sheet shows it.
2
+ //
3
+ // The framework's agent-chat stream already carries tool calls, their results,
4
+ // and server-authored progress labels — see the `AgentChatEvent` union in
5
+ // `packages/core/src/agent/types.ts`, which core's own `sse-event-processor`
6
+ // renders in full for the web chat. The pill consumed `text` plus `activity`
7
+ // and dropped the rest, which is why a working agent looked like it sat there
8
+ // doing nothing and then answered.
9
+ //
10
+ // The desktop app deliberately carries no `@agent-native/core` dependency
11
+ // (overlay bundle weight), so the frames it reads are re-declared here. Keep
12
+ // this union a strict subset of the framework's: a frame that changes shape
13
+ // upstream must fail to parse here, not render as something plausible.
14
+
15
+ /** The subset of the framework's stream frames the pill presents. */
16
+ export type AgentFrame =
17
+ | { type: "text"; text: string }
18
+ | { type: "thinking"; text: string }
19
+ | { type: "activity"; label: string; tool?: string }
20
+ | { type: "tool_start"; tool: string; id?: string }
21
+ | {
22
+ type: "tool_done";
23
+ tool: string;
24
+ id?: string;
25
+ result?: unknown;
26
+ isError?: boolean;
27
+ }
28
+ | {
29
+ type: "approval_required";
30
+ tool: string;
31
+ /** Echoed back as `approvedToolCalls` to let the paused call run. Kept
32
+ * because a step that drops it can never be resumed by anything. */
33
+ approvalKey: string;
34
+ toolCallId?: string;
35
+ /** Distinguishes THIS gate hit from an earlier ask for the same call. */
36
+ askId?: string;
37
+ input?: Record<string, string>;
38
+ }
39
+ | { type: "error"; error?: string }
40
+ | { type: "missing_api_key" }
41
+ /** Terminal, and NOT a finished answer: the run was cut at a continuation
42
+ * boundary (timeout, token budget, no progress). See `ContinuationReason`
43
+ * in the framework's `agent/types.ts`. */
44
+ | { type: "auto_continue"; reason: string }
45
+ /** Terminal, and NOT a finished answer: the loop hit its iteration cap. */
46
+ | { type: "loop_limit"; maxIterations?: number }
47
+ | { type: "done" };
48
+
49
+ export type AgentStepStatus = "running" | "done" | "error" | "blocked";
50
+
51
+ /**
52
+ * What kind of work a step is, which is all the icon strip shows.
53
+ *
54
+ * Every tool the agent can reach falls into one of these, so a run reads as a
55
+ * short sequence of shapes — read, think, write — instead of a paragraph of
56
+ * tool names nobody scans.
57
+ */
58
+ export type AgentStepKind =
59
+ | "think"
60
+ | "read"
61
+ | "search"
62
+ | "write"
63
+ | "call"
64
+ | "wait";
65
+
66
+ /** One row in the sheet's step list. */
67
+ export interface AgentStep {
68
+ /** Tool-call id when the stream gave one, else derived from the tool name. */
69
+ key: string;
70
+ label: string;
71
+ kind: AgentStepKind;
72
+ status: AgentStepStatus;
73
+ /** One line about the outcome, only when the result actually says something. */
74
+ detail?: string;
75
+ }
76
+
77
+ /**
78
+ * Frames arrive as untyped JSON. Anything unrecognized returns null so it is
79
+ * skipped rather than rendered as an empty step.
80
+ */
81
+ export function parseAgentFrame(raw: unknown): AgentFrame | null {
82
+ if (!raw || typeof raw !== "object") return null;
83
+ const ev = raw as Record<string, unknown>;
84
+ const type = typeof ev.type === "string" ? ev.type : null;
85
+ if (!type) return null;
86
+ // For identifiers and labels, where blank means absent.
87
+ const str = (value: unknown): string | undefined =>
88
+ typeof value === "string" && value.trim() ? value : undefined;
89
+ // For stream deltas, where blank means a space. Model chunks are not
90
+ // word-aligned, so " " and "\n" arrive as deltas of their own; dropping them
91
+ // is what runs two words together. `tail()` below already preserves this
92
+ // seam once the text is in — it never gets the chance if the frame is
93
+ // discarded here first.
94
+ const delta = (value: unknown): string | undefined =>
95
+ typeof value === "string" && value.length > 0 ? value : undefined;
96
+
97
+ switch (type) {
98
+ case "text": {
99
+ const text = delta(ev.text);
100
+ return text === undefined ? null : { type, text };
101
+ }
102
+ case "thinking": {
103
+ const text = delta(ev.text);
104
+ return text === undefined ? null : { type, text };
105
+ }
106
+ case "activity":
107
+ return str(ev.label)
108
+ ? { type, label: ev.label as string, tool: str(ev.tool) }
109
+ : null;
110
+ case "tool_start":
111
+ return str(ev.tool)
112
+ ? { type, tool: ev.tool as string, id: str(ev.id) }
113
+ : null;
114
+ case "tool_done":
115
+ return str(ev.tool)
116
+ ? {
117
+ type,
118
+ tool: ev.tool as string,
119
+ id: str(ev.id),
120
+ result: ev.result,
121
+ isError: ev.isError === true,
122
+ }
123
+ : null;
124
+ case "approval_required": {
125
+ const tool = str(ev.tool);
126
+ const approvalKey = str(ev.approvalKey);
127
+ // Both are required upstream. A frame missing either cannot be resumed
128
+ // by anyone, so rendering a "waiting for approval" row from it would be
129
+ // a spinner with nothing behind it — exactly the plausible-looking state
130
+ // this parser exists to refuse.
131
+ if (!tool || !approvalKey) return null;
132
+ return {
133
+ type,
134
+ tool,
135
+ approvalKey,
136
+ toolCallId: str(ev.toolCallId),
137
+ askId: str(ev.askId),
138
+ input: stringRecord(ev.input),
139
+ };
140
+ }
141
+ case "error":
142
+ return { type, error: str(ev.error) };
143
+ case "auto_continue":
144
+ return { type, reason: str(ev.reason) ?? "unknown" };
145
+ case "loop_limit":
146
+ return {
147
+ type,
148
+ maxIterations:
149
+ typeof ev.maxIterations === "number" &&
150
+ Number.isFinite(ev.maxIterations)
151
+ ? ev.maxIterations
152
+ : undefined,
153
+ };
154
+ case "missing_api_key":
155
+ case "done":
156
+ return { type };
157
+ default:
158
+ return null;
159
+ }
160
+ }
161
+
162
+ function stringRecord(value: unknown): Record<string, string> | undefined {
163
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
164
+ return undefined;
165
+ }
166
+ const out: Record<string, string> = {};
167
+ for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {
168
+ if (typeof entry === "string") out[key] = entry;
169
+ }
170
+ return Object.keys(out).length ? out : undefined;
171
+ }
172
+
173
+ /**
174
+ * Why a run ended without finishing, or null when it finished cleanly.
175
+ *
176
+ * The stream closes the same way whether the agent answered or was cut off at
177
+ * a timeout, a loop cap, or an approval gate. Only the terminal frame tells
178
+ * those apart, so whatever text arrived before one of these is a fragment, not
179
+ * the answer — presenting it as the answer is the bug this guards.
180
+ */
181
+ export interface AskIncomplete {
182
+ kind: "auto_continue" | "loop_limit" | "approval_required" | "error";
183
+ /** One line to show under whatever text did arrive. */
184
+ message: string;
185
+ }
186
+
187
+ export function askIncompleteForFrame(frame: AgentFrame): AskIncomplete | null {
188
+ switch (frame.type) {
189
+ case "auto_continue":
190
+ return {
191
+ kind: "auto_continue",
192
+ message: "The agent ran out of time before finishing this answer.",
193
+ };
194
+ case "loop_limit":
195
+ return {
196
+ kind: "loop_limit",
197
+ message: "The agent hit its step limit before finishing this answer.",
198
+ };
199
+ case "approval_required":
200
+ return {
201
+ kind: "approval_required",
202
+ message: `This needs approval to run ${labelForTool(frame.tool).toLowerCase()}. Open Clips to approve it.`,
203
+ };
204
+ default:
205
+ return null;
206
+ }
207
+ }
208
+
209
+ const TOOL_LABELS: Record<string, string> = {
210
+ "get-meeting": "Reading this meeting",
211
+ "list-meetings": "Checking your meetings",
212
+ "search-meetings": "Searching past meetings",
213
+ "update-meeting": "Updating the meeting",
214
+ "create-meeting": "Creating a meeting",
215
+ "finalize-meeting": "Wrapping up the meeting",
216
+ "search-recordings": "Searching recordings",
217
+ "get-recording-player-data": "Reading a recording",
218
+ "add-comment": "Adding a comment",
219
+ "view-screen": "Checking the current screen",
220
+ "tool-search": "Finding the right tool",
221
+ "provider-api-catalog": "Checking connected apps",
222
+ "provider-api-docs": "Reading the provider's API",
223
+ "provider-api-request": "Calling a connected app",
224
+ };
225
+
226
+ /**
227
+ * A readable label for a tool row. Unknown tools fall back to their own id
228
+ * rather than a generic "Working", so a new action is still legible.
229
+ */
230
+ export function labelForTool(tool: string): string {
231
+ const known = TOOL_LABELS[tool];
232
+ if (known) return known;
233
+ const words = tool.replace(/[-_]+/g, " ").trim();
234
+ if (!words) return "Working";
235
+ return words.charAt(0).toUpperCase() + words.slice(1);
236
+ }
237
+
238
+ /** Verb-first classification. A tool absent here is read-only by default:
239
+ * claiming the agent wrote something it only looked at is the worse error. */
240
+ const WRITE_PREFIXES = [
241
+ "create-",
242
+ "update-",
243
+ "add-",
244
+ "delete-",
245
+ "trash-",
246
+ "archive-",
247
+ "restore-",
248
+ "move-",
249
+ "finalize-",
250
+ "share-",
251
+ "set-",
252
+ "send-",
253
+ "import-",
254
+ "export-",
255
+ "trim-",
256
+ "split-",
257
+ "remove-",
258
+ "cleanup-",
259
+ "regenerate-",
260
+ "prepare-",
261
+ ];
262
+
263
+ export function kindForTool(tool: string): AgentStepKind {
264
+ if (!tool) return "think";
265
+ if (tool.startsWith("provider-api-") || tool.startsWith("integration")) {
266
+ return "call";
267
+ }
268
+ if (WRITE_PREFIXES.some((prefix) => tool.startsWith(prefix))) return "write";
269
+ // Searching and reading are the same to the code and different to the
270
+ // reader: a magnifier over "Reading" is the mismatch that reads as a bug.
271
+ if (tool.startsWith("search-") || tool.startsWith("find-")) return "search";
272
+ return "read";
273
+ }
274
+
275
+ const DETAIL_MAX = 80;
276
+ const COUNTABLE_KEYS = [
277
+ "meetings",
278
+ "recordings",
279
+ "results",
280
+ "items",
281
+ "rows",
282
+ "comments",
283
+ "events",
284
+ ];
285
+
286
+ /**
287
+ * One line about what a tool returned, or nothing.
288
+ *
289
+ * Nothing is the common case on purpose: a result is arbitrary JSON, and a
290
+ * stringified blob under a step row reads as detail while saying less than the
291
+ * row above it. Only a plain string or a countable collection qualifies.
292
+ */
293
+ export function summarizeToolResult(result: unknown): string | undefined {
294
+ if (typeof result === "string") {
295
+ const line = result.trim().split("\n")[0]?.trim();
296
+ if (!line) return undefined;
297
+ return line.length > DETAIL_MAX ? `${line.slice(0, DETAIL_MAX)}…` : line;
298
+ }
299
+ if (Array.isArray(result)) return countLabel(result.length);
300
+ if (result && typeof result === "object") {
301
+ const obj = result as Record<string, unknown>;
302
+ for (const key of COUNTABLE_KEYS) {
303
+ const value = obj[key];
304
+ if (Array.isArray(value)) return countLabel(value.length);
305
+ }
306
+ if (typeof obj.count === "number" && Number.isFinite(obj.count)) {
307
+ return countLabel(obj.count);
308
+ }
309
+ }
310
+ return undefined;
311
+ }
312
+
313
+ /** Newest reasoning, bounded to what a small overlay can show. */
314
+ const THINKING_TAIL = 220;
315
+
316
+ function tail(text: string): string | undefined {
317
+ // Only the leading edge is trimmed. Trailing whitespace is the seam between
318
+ // two deltas — trimming it here is what runs the next word into this one.
319
+ const collapsed = text.replace(/\s+/g, " ").replace(/^ /, "");
320
+ if (!collapsed.trim()) return undefined;
321
+ return collapsed.length > THINKING_TAIL
322
+ ? `…${collapsed.slice(-THINKING_TAIL)}`
323
+ : collapsed;
324
+ }
325
+
326
+ function countLabel(count: number): string {
327
+ return count === 1 ? "1 result" : `${count} results`;
328
+ }
329
+
330
+ function keyFor(tool: string, id?: string): string {
331
+ return id ? `id:${id}` : `tool:${tool}`;
332
+ }
333
+
334
+ /**
335
+ * Fold one frame into the step list, returning the same array when the frame
336
+ * changes nothing so React can skip the render.
337
+ */
338
+ export function applyFrame(steps: AgentStep[], frame: AgentFrame): AgentStep[] {
339
+ switch (frame.type) {
340
+ case "tool_start": {
341
+ const key = keyFor(frame.tool, frame.id);
342
+ if (steps.some((s) => s.key === key && s.status === "running")) {
343
+ return steps;
344
+ }
345
+ return [
346
+ ...steps,
347
+ {
348
+ key,
349
+ label: labelForTool(frame.tool),
350
+ kind: kindForTool(frame.tool),
351
+ status: "running",
352
+ },
353
+ ];
354
+ }
355
+ case "tool_done": {
356
+ const key = keyFor(frame.tool, frame.id);
357
+ const status: AgentStepStatus = frame.isError ? "error" : "done";
358
+ const detail = frame.isError
359
+ ? undefined
360
+ : summarizeToolResult(frame.result);
361
+ const index = lastIndexWhere(
362
+ steps,
363
+ (s) => s.key === key && s.status === "running",
364
+ );
365
+ // A result with no matching start still gets a row: a step that only ever
366
+ // reports its outcome is worth showing, and dropping it would hide work.
367
+ if (index < 0) {
368
+ return [
369
+ ...steps,
370
+ {
371
+ key,
372
+ label: labelForTool(frame.tool),
373
+ kind: kindForTool(frame.tool),
374
+ status,
375
+ detail,
376
+ },
377
+ ];
378
+ }
379
+ const next = [...steps];
380
+ next[index] = { ...next[index], status, detail };
381
+ return next;
382
+ }
383
+ case "thinking": {
384
+ // Reasoning streams in deltas. Only the tail is kept: the strip shows
385
+ // what the agent is thinking now, not a transcript of how it got there.
386
+ const index = lastIndexWhere(
387
+ steps,
388
+ (s) => s.kind === "think" && s.status === "running",
389
+ );
390
+ if (index < 0) {
391
+ return [
392
+ ...steps,
393
+ {
394
+ key: `thinking:${steps.length}`,
395
+ label: "Thought",
396
+ kind: "think",
397
+ status: "running",
398
+ detail: tail(frame.text),
399
+ },
400
+ ];
401
+ }
402
+ const next = [...steps];
403
+ next[index] = {
404
+ ...next[index],
405
+ detail: tail(`${next[index].detail ?? ""}${frame.text}`),
406
+ };
407
+ return next;
408
+ }
409
+ case "activity": {
410
+ // Server-authored progress. It renames the work already in flight when
411
+ // there is some, and stands alone when the agent is between tools.
412
+ const index = lastIndexWhere(steps, (s) => s.status === "running");
413
+ if (index < 0) {
414
+ return [
415
+ ...steps,
416
+ {
417
+ key: `activity:${steps.length}`,
418
+ label: frame.label,
419
+ kind: frame.tool ? kindForTool(frame.tool) : "think",
420
+ status: "running",
421
+ },
422
+ ];
423
+ }
424
+ if (steps[index].label === frame.label) return steps;
425
+ const next = [...steps];
426
+ next[index] = { ...next[index], label: frame.label };
427
+ return next;
428
+ }
429
+ case "approval_required": {
430
+ // Keyed by the call, not by position: a failed resume re-emits the same
431
+ // approval with a fresh `askId`, and stacking a second identical row
432
+ // would read as the agent asking twice.
433
+ const key = `approval:${frame.approvalKey}`;
434
+ const step: AgentStep = {
435
+ key,
436
+ label: `Needs approval: ${labelForTool(frame.tool)}`,
437
+ kind: "wait",
438
+ status: "blocked",
439
+ };
440
+ const index = steps.findIndex((s) => s.key === key);
441
+ if (index < 0) return [...steps, step];
442
+ const next = [...steps];
443
+ next[index] = step;
444
+ return next;
445
+ }
446
+ default:
447
+ return steps;
448
+ }
449
+ }
450
+
451
+ /**
452
+ * Close out the list when the stream ends. A step left spinning after the
453
+ * answer arrived would claim work is still running forever — the stream's own
454
+ * end is the only signal that it is not.
455
+ *
456
+ * `incomplete` is what the run ended on. A run cut at a timeout, a loop cap, or
457
+ * an approval gate did NOT finish the tool it was in the middle of, so those
458
+ * steps settle as blocked rather than done: "Searched" under an answer that was
459
+ * truncated mid-search is the same lie as calling the fragment an answer.
460
+ */
461
+ export function settleSteps(
462
+ steps: AgentStep[],
463
+ incomplete?: AskIncomplete | null,
464
+ ): AgentStep[] {
465
+ if (!steps.some((s) => s.status === "running")) return steps;
466
+ const settled: AgentStepStatus = incomplete ? "blocked" : "done";
467
+ return steps.map((s) =>
468
+ s.status === "running" ? { ...s, status: settled } : s,
469
+ );
470
+ }
471
+
472
+ function lastIndexWhere<T>(items: T[], match: (item: T) => boolean): number {
473
+ for (let i = items.length - 1; i >= 0; i -= 1) {
474
+ if (match(items[i])) return i;
475
+ }
476
+ return -1;
477
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * How the expanded meeting panel is divided between the live transcript and
3
+ * the answer sheet.
4
+ *
5
+ * The sheet shares the column rather than covering it: the transcript follows
6
+ * its newest line, so anything laid over the bottom hides exactly the part of
7
+ * the session the user is still watching. A ratio alone is not enough either —
8
+ * one that leaves room on a tall window starves the feed on a short one — so
9
+ * the transcript also keeps a floor in pixels.
10
+ */
11
+
12
+ export const ASK_SHEET_DEFAULT = 0.45;
13
+ export const ASK_SHEET_MIN = 0.2;
14
+ export const ASK_SHEET_MAX = 0.7;
15
+ export const TRANSCRIPT_MIN_PX = 104;
16
+
17
+ /** Below this the drag is a dismissal, not a resize. */
18
+ export const ASK_SHEET_DISMISS_AT = ASK_SHEET_MIN + 0.02;
19
+
20
+ /** Travel past which a grip gesture is a resize rather than a tap. Matches the
21
+ * capsule's own `DIRECT_CLICK_MAX_TRAVEL_PX`. */
22
+ export const SHEET_DRAG_SLOP_PX = 5;
23
+
24
+ /** How far off the bottom of a scroller still counts as following its live
25
+ * edge. Matches the transcript's `PIN_SLACK_PX`. */
26
+ export const ASK_PIN_SLACK_PX = 28;
27
+
28
+ /**
29
+ * Whether a grip gesture is a tap — the gesture that dismisses the sheet —
30
+ * rather than a resize.
31
+ *
32
+ * Measured as travel, because travel is the only thing still true when the
33
+ * decision has to be made. `click` fires after `pointerup`, so a guard that
34
+ * reads whether a drag is in progress always sees "no" and lets every resize,
35
+ * including one that grew the sheet, close it on release.
36
+ */
37
+ export function isSheetGripTap(deltaY: number): boolean {
38
+ return Math.abs(deltaY) <= SHEET_DRAG_SLOP_PX;
39
+ }
40
+
41
+ /**
42
+ * Whether a scroller is at its live edge, so incoming content should follow it.
43
+ *
44
+ * A stream that scrolls to the bottom on every delta makes reading anything
45
+ * above it impossible for as long as the answer is arriving.
46
+ */
47
+ export function isPinnedToBottom(metrics: {
48
+ scrollHeight: number;
49
+ scrollTop: number;
50
+ clientHeight: number;
51
+ }): boolean {
52
+ return (
53
+ metrics.scrollHeight - metrics.scrollTop - metrics.clientHeight <=
54
+ ASK_PIN_SLACK_PX
55
+ );
56
+ }
57
+
58
+ export function clampAskSheetHeight(
59
+ fraction: number,
60
+ panelHeight: number,
61
+ ): number {
62
+ const roomForTranscript =
63
+ panelHeight > 0
64
+ ? (panelHeight - TRANSCRIPT_MIN_PX) / panelHeight
65
+ : ASK_SHEET_MAX;
66
+ const max = Math.max(
67
+ ASK_SHEET_MIN,
68
+ Math.min(ASK_SHEET_MAX, roomForTranscript),
69
+ );
70
+ return Math.min(max, Math.max(ASK_SHEET_MIN, fraction));
71
+ }