@kortix/sdk 0.13.29 → 0.13.30

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 (156) hide show
  1. package/dist/core/client/kortix.d.ts +4 -0
  2. package/dist/core/client/kortix.d.ts.map +1 -1
  3. package/dist/core/client/kortix.js +2 -0
  4. package/dist/core/client/kortix.js.map +1 -1
  5. package/dist/core/http/api-client.js.map +1 -1
  6. package/dist/core/rest/projects-client/accounts.d.ts +5 -0
  7. package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
  8. package/dist/core/rest/projects-client/accounts.js.map +1 -1
  9. package/dist/core/rest/projects-client/agent-config.d.ts +8 -0
  10. package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
  11. package/dist/core/rest/projects-client/agent-config.js.map +1 -1
  12. package/dist/core/rest/projects-client/apps.d.ts +14 -0
  13. package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
  14. package/dist/core/rest/projects-client/apps.js +4 -0
  15. package/dist/core/rest/projects-client/apps.js.map +1 -1
  16. package/dist/core/rest/projects-client/audit.d.ts +4 -0
  17. package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
  18. package/dist/core/rest/projects-client/audit.js.map +1 -1
  19. package/dist/core/rest/projects-client/gateway.d.ts +4 -8
  20. package/dist/core/rest/projects-client/gateway.d.ts.map +1 -1
  21. package/dist/core/rest/projects-client/gateway.js.map +1 -1
  22. package/dist/core/rest/projects-client/index.d.ts +1 -0
  23. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  24. package/dist/core/rest/projects-client/index.js +1 -0
  25. package/dist/core/rest/projects-client/index.js.map +1 -1
  26. package/dist/core/rest/projects-client/projects.d.ts +15 -1
  27. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  28. package/dist/core/rest/projects-client/projects.js +1 -0
  29. package/dist/core/rest/projects-client/projects.js.map +1 -1
  30. package/dist/core/rest/projects-client/review-items.d.ts +173 -0
  31. package/dist/core/rest/projects-client/review-items.d.ts.map +1 -0
  32. package/dist/core/rest/projects-client/review-items.js +260 -0
  33. package/dist/core/rest/projects-client/review-items.js.map +1 -0
  34. package/dist/core/rest/projects-client/session-costs.d.ts +7 -9
  35. package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
  36. package/dist/core/rest/projects-client/session-costs.js.map +1 -1
  37. package/dist/core/turns/index.d.ts +3 -0
  38. package/dist/core/turns/index.d.ts.map +1 -1
  39. package/dist/core/turns/index.js +2 -0
  40. package/dist/core/turns/index.js.map +1 -1
  41. package/dist/core/turns/segments/burst-summary.d.ts +49 -0
  42. package/dist/core/turns/segments/burst-summary.d.ts.map +1 -0
  43. package/dist/core/turns/segments/burst-summary.js +64 -0
  44. package/dist/core/turns/segments/burst-summary.js.map +1 -0
  45. package/dist/core/turns/segments/compaction-state.d.ts +44 -0
  46. package/dist/core/turns/segments/compaction-state.d.ts.map +1 -0
  47. package/dist/core/turns/segments/compaction-state.js +79 -0
  48. package/dist/core/turns/segments/compaction-state.js.map +1 -0
  49. package/dist/core/turns/segments/group-steps.d.ts +22 -0
  50. package/dist/core/turns/segments/group-steps.d.ts.map +1 -0
  51. package/dist/core/turns/segments/group-steps.js +89 -0
  52. package/dist/core/turns/segments/group-steps.js.map +1 -0
  53. package/dist/core/turns/segments/index.d.ts +21 -0
  54. package/dist/core/turns/segments/index.d.ts.map +1 -0
  55. package/dist/core/turns/segments/index.js +21 -0
  56. package/dist/core/turns/segments/index.js.map +1 -0
  57. package/dist/core/turns/segments/merge-steps.d.ts +79 -0
  58. package/dist/core/turns/segments/merge-steps.d.ts.map +1 -0
  59. package/dist/core/turns/segments/merge-steps.js +190 -0
  60. package/dist/core/turns/segments/merge-steps.js.map +1 -0
  61. package/dist/core/turns/segments/message-time.d.ts +86 -0
  62. package/dist/core/turns/segments/message-time.d.ts.map +1 -0
  63. package/dist/core/turns/segments/message-time.js +196 -0
  64. package/dist/core/turns/segments/message-time.js.map +1 -0
  65. package/dist/core/turns/segments/narration.d.ts +71 -0
  66. package/dist/core/turns/segments/narration.d.ts.map +1 -0
  67. package/dist/core/turns/segments/narration.js +836 -0
  68. package/dist/core/turns/segments/narration.js.map +1 -0
  69. package/dist/core/turns/segments/segment-turn.d.ts +26 -0
  70. package/dist/core/turns/segments/segment-turn.d.ts.map +1 -0
  71. package/dist/core/turns/segments/segment-turn.js +36 -0
  72. package/dist/core/turns/segments/segment-turn.js.map +1 -0
  73. package/dist/core/turns/segments/session-activity-groups.d.ts +93 -0
  74. package/dist/core/turns/segments/session-activity-groups.d.ts.map +1 -0
  75. package/dist/core/turns/segments/session-activity-groups.js +127 -0
  76. package/dist/core/turns/segments/session-activity-groups.js.map +1 -0
  77. package/dist/core/turns/segments/step-label.d.ts +44 -0
  78. package/dist/core/turns/segments/step-label.d.ts.map +1 -0
  79. package/dist/core/turns/segments/step-label.js +129 -0
  80. package/dist/core/turns/segments/step-label.js.map +1 -0
  81. package/dist/core/turns/segments/turn-busy-visibility.d.ts +51 -0
  82. package/dist/core/turns/segments/turn-busy-visibility.d.ts.map +1 -0
  83. package/dist/core/turns/segments/turn-busy-visibility.js +47 -0
  84. package/dist/core/turns/segments/turn-busy-visibility.js.map +1 -0
  85. package/dist/core/turns/segments/working-turn.d.ts +165 -0
  86. package/dist/core/turns/segments/working-turn.d.ts.map +1 -0
  87. package/dist/core/turns/segments/working-turn.js +168 -0
  88. package/dist/core/turns/segments/working-turn.js.map +1 -0
  89. package/dist/core/turns/text-scan.d.ts +65 -0
  90. package/dist/core/turns/text-scan.d.ts.map +1 -0
  91. package/dist/core/turns/text-scan.js +344 -0
  92. package/dist/core/turns/text-scan.js.map +1 -0
  93. package/dist/core/turns/tools/agent-helpers.d.ts +10 -0
  94. package/dist/core/turns/tools/agent-helpers.d.ts.map +1 -0
  95. package/dist/core/turns/tools/agent-helpers.js +54 -0
  96. package/dist/core/turns/tools/agent-helpers.js.map +1 -0
  97. package/dist/core/turns/tools/file-verb.d.ts +81 -0
  98. package/dist/core/turns/tools/file-verb.d.ts.map +1 -0
  99. package/dist/core/turns/tools/file-verb.js +70 -0
  100. package/dist/core/turns/tools/file-verb.js.map +1 -0
  101. package/dist/core/turns/tools/index.d.ts +22 -0
  102. package/dist/core/turns/tools/index.d.ts.map +1 -0
  103. package/dist/core/turns/tools/index.js +22 -0
  104. package/dist/core/turns/tools/index.js.map +1 -0
  105. package/dist/core/turns/tools/memory-helpers.d.ts +16 -0
  106. package/dist/core/turns/tools/memory-helpers.d.ts.map +1 -0
  107. package/dist/core/turns/tools/memory-helpers.js +55 -0
  108. package/dist/core/turns/tools/memory-helpers.js.map +1 -0
  109. package/dist/core/turns/tools/patch-summary.d.ts +53 -0
  110. package/dist/core/turns/tools/patch-summary.d.ts.map +1 -0
  111. package/dist/core/turns/tools/patch-summary.js +71 -0
  112. package/dist/core/turns/tools/patch-summary.js.map +1 -0
  113. package/dist/core/turns/tools/presentation-helpers.d.ts +16 -0
  114. package/dist/core/turns/tools/presentation-helpers.d.ts.map +1 -0
  115. package/dist/core/turns/tools/presentation-helpers.js +18 -0
  116. package/dist/core/turns/tools/presentation-helpers.js.map +1 -0
  117. package/dist/core/turns/tools/question-helpers.d.ts +10 -0
  118. package/dist/core/turns/tools/question-helpers.d.ts.map +1 -0
  119. package/dist/core/turns/tools/question-helpers.js +13 -0
  120. package/dist/core/turns/tools/question-helpers.js.map +1 -0
  121. package/dist/core/turns/tools/read-helpers.d.ts +8 -0
  122. package/dist/core/turns/tools/read-helpers.d.ts.map +1 -0
  123. package/dist/core/turns/tools/read-helpers.js +25 -0
  124. package/dist/core/turns/tools/read-helpers.js.map +1 -0
  125. package/dist/core/turns/tools/search-query.d.ts +28 -0
  126. package/dist/core/turns/tools/search-query.d.ts.map +1 -0
  127. package/dist/core/turns/tools/search-query.js +137 -0
  128. package/dist/core/turns/tools/search-query.js.map +1 -0
  129. package/dist/core/turns/tools/show-availability.d.ts +53 -0
  130. package/dist/core/turns/tools/show-availability.d.ts.map +1 -0
  131. package/dist/core/turns/tools/show-availability.js +110 -0
  132. package/dist/core/turns/tools/show-availability.js.map +1 -0
  133. package/dist/core/turns/tools/skill-helpers.d.ts +35 -0
  134. package/dist/core/turns/tools/skill-helpers.d.ts.map +1 -0
  135. package/dist/core/turns/tools/skill-helpers.js +129 -0
  136. package/dist/core/turns/tools/skill-helpers.js.map +1 -0
  137. package/dist/core/turns/tools/tool-meta.d.ts +72 -0
  138. package/dist/core/turns/tools/tool-meta.d.ts.map +1 -0
  139. package/dist/core/turns/tools/tool-meta.js +174 -0
  140. package/dist/core/turns/tools/tool-meta.js.map +1 -0
  141. package/dist/core/turns/tools/tool-outcome.d.ts +78 -0
  142. package/dist/core/turns/tools/tool-outcome.d.ts.map +1 -0
  143. package/dist/core/turns/tools/tool-outcome.js +244 -0
  144. package/dist/core/turns/tools/tool-outcome.js.map +1 -0
  145. package/dist/core/turns/tools/tool-output-format.d.ts +63 -0
  146. package/dist/core/turns/tools/tool-output-format.d.ts.map +1 -0
  147. package/dist/core/turns/tools/tool-output-format.js +174 -0
  148. package/dist/core/turns/tools/tool-output-format.js.map +1 -0
  149. package/dist/core/turns/tools/web-helpers.d.ts +40 -0
  150. package/dist/core/turns/tools/web-helpers.d.ts.map +1 -0
  151. package/dist/core/turns/tools/web-helpers.js +297 -0
  152. package/dist/core/turns/tools/web-helpers.js.map +1 -0
  153. package/dist/kortix.esm.min.js +42 -26
  154. package/dist/kortix.global.js +42 -26
  155. package/dist/react/sign-in-with-kortix.d.ts +3 -3
  156. package/package.json +2 -2
@@ -0,0 +1,836 @@
1
+ /**
2
+ * Plain-language narration for Easy mode.
3
+ *
4
+ * Turns the 104 registered tools into sentences a non-technical user can read.
5
+ * The registry holds ~200 keys because every tool registers snake_case,
6
+ * kebab-case and an `oc-` alias — `normalizeName` collapses those first.
7
+ *
8
+ * The `other` fallback is load-bearing: MCP tools have arbitrary `server/tool`
9
+ * names that cannot be enumerated, and tools added after this ships are unknown
10
+ * here. Neither may ever surface a raw identifier.
11
+ *
12
+ * GOVERNING RULE: narration must never mislead. A tool's family and sentence
13
+ * are decided by what its registered component actually renders/does (see
14
+ * apps/web/src/features/session/tool/tools/*.tsx), not by how its name reads.
15
+ * Several tools register the *same* component under multiple aliases (e.g.
16
+ * `task_create` and `agent_task_create` both render `AgentSpawnTool`) — those
17
+ * aliases must always resolve to the same family and the same sentence.
18
+ */
19
+ import { getToolPrimaryArg, normalizeName } from '../tools/tool-meta.js';
20
+ import { parseWebSearchOutput, wsDomain } from '../tools/web-helpers.js';
21
+ import { stripTrailingSlashes } from '../text-scan.js';
22
+ /** An absolute http(s) URL, normalised, or `null` for anything else. */
23
+ function safeHttpUrl(value) {
24
+ if (typeof value !== 'string' || !value.trim())
25
+ return null;
26
+ try {
27
+ const url = new URL(value.trim());
28
+ return url.protocol === 'http:' || url.protocol === 'https:' ? url.toString() : null;
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ /** Context-engine bookkeeping — meaningless to this audience, so Easy mode omits it. */
35
+ const HIDDEN = new Set(['prune', 'distill', 'compress', 'context_info']);
36
+ const FAMILY_BY_TOOL = {};
37
+ function assign(family, tools) {
38
+ for (const t of tools)
39
+ FAMILY_BY_TOOL[t] = family;
40
+ }
41
+ assign('explore', ['read', 'glob', 'grep', 'list']);
42
+ assign('edit', ['write', 'edit', 'morph_edit', 'apply_patch']);
43
+ assign('run', ['bash', 'pty_spawn', 'pty_read', 'pty_write', 'pty_input', 'pty_kill']);
44
+ assign('web', [
45
+ 'web_search',
46
+ 'websearch',
47
+ 'web_fetch',
48
+ 'webfetch',
49
+ 'scrape_webpage',
50
+ 'scrapewebpage',
51
+ 'image_search',
52
+ ]);
53
+ assign('create', ['image_gen', 'video_gen', 'presentation_gen', 'show', 'show_user']);
54
+ // `todo_write` is the model's own step checklist — nothing is delegated to
55
+ // another agent. This is the ONLY thing left in `plan`; every `task_*` /
56
+ // `agent_task_*` alias below shares a component with an explicit agent_*
57
+ // delegation tool, so it belongs in `delegate`, not here.
58
+ assign('plan', ['todo_write', 'todowrite']);
59
+ // Every one of these renders one of: AgentSpawnTool, AgentTaskUpdateTool,
60
+ // AgentMessageTool, TaskDoneTool, AgentStopTool, AgentStatusTool, or
61
+ // TaskListTool — the same components the bare `agent_*` tools render. A
62
+ // `task_*` alias and its `agent_task_*` twin MUST land here together, or the
63
+ // same backend action narrates two different ways depending on which the
64
+ // model happened to emit.
65
+ assign('delegate', [
66
+ // spawn a helper agent to do work (renders AgentSpawnTool / SessionSpawnTool)
67
+ 'agent_spawn',
68
+ 'agent_task',
69
+ 'agent_task_create',
70
+ 'agent_task_start',
71
+ 'task',
72
+ 'task_create',
73
+ 'task_start',
74
+ 'session_spawn',
75
+ 'session_start_background',
76
+ // send an instruction/update to a running helper (AgentMessageTool / AgentTaskUpdateTool)
77
+ 'agent_message',
78
+ 'agent_task_message',
79
+ 'task_message',
80
+ 'agent_task_update',
81
+ 'task_update',
82
+ 'session_message',
83
+ // read-only status check on helpers/tasks (AgentStatusTool / TaskListTool)
84
+ 'agent_status',
85
+ 'agent_task_list',
86
+ 'agent_task_get',
87
+ 'task_list',
88
+ 'task_get',
89
+ // stop a running helper (AgentStopTool)
90
+ 'agent_stop',
91
+ 'agent_task_cancel',
92
+ 'task_cancel',
93
+ // mark a helper's task done (TaskDoneTool)
94
+ 'agent_task_approve',
95
+ 'task_approve',
96
+ 'task_done',
97
+ // remove a task (TaskDeleteTool)
98
+ 'task_delete',
99
+ ]);
100
+ // Genuine read-only lookups of past/other session state — no delegation happens here.
101
+ assign('sessions', [
102
+ 'session_get',
103
+ 'session_read',
104
+ 'session_search',
105
+ 'session_lineage',
106
+ 'session_stats',
107
+ 'session_list',
108
+ 'session_list_background',
109
+ 'session_list_spawned',
110
+ ]);
111
+ assign('memory', ['memory', 'memory_search', 'mem_search', 'ltm_search', 'get_mem']);
112
+ assign('connectors', [
113
+ 'connector_get',
114
+ 'connector_list',
115
+ 'connector_setup',
116
+ 'kortix_connector_call',
117
+ 'kortix_connectors',
118
+ 'kortix_connectors_connectors',
119
+ 'kortix_connectors_discover',
120
+ 'kortix_connectors_describe',
121
+ 'kortix_connectors_call',
122
+ 'kortix_connector_describe',
123
+ 'kortix_connector_discover',
124
+ ]);
125
+ assign('automations', [
126
+ 'triggers',
127
+ 'trigger_create',
128
+ 'trigger_delete',
129
+ 'trigger_get',
130
+ 'trigger_list',
131
+ 'trigger_pause',
132
+ 'trigger_resume',
133
+ 'trigger_test',
134
+ 'trigger_update',
135
+ ]);
136
+ assign('projects', [
137
+ 'project_create',
138
+ 'project_delete',
139
+ 'project_get',
140
+ 'project_list',
141
+ 'project_select',
142
+ 'project_update',
143
+ ]);
144
+ assign('skills', ['skill']);
145
+ assign('ask', ['question', 'ask']);
146
+ assign('retired', [
147
+ 'integration_list',
148
+ 'integration_connect',
149
+ 'integration_search',
150
+ 'integration_actions',
151
+ 'integration_run',
152
+ 'integration_request',
153
+ 'integration_exec',
154
+ ]);
155
+ export function familyForTool(toolName) {
156
+ const n = normalizeName(toolName);
157
+ if (HIDDEN.has(n))
158
+ return 'hidden';
159
+ return FAMILY_BY_TOOL[n] ?? 'other';
160
+ }
161
+ /**
162
+ * `linear/create_issue` → `Create Issue`. Never returns a raw identifier.
163
+ *
164
+ * Named `narrationToolName`, not `humanizeToolName`: the SDK already exports a
165
+ * `humanizeToolName` (tool-registry) that keeps the server segment
166
+ * (`linear/create_issue` → "Linear/create Issue"). This one names only the
167
+ * leaf, which is what a narrated sentence wants.
168
+ *
169
+ * MCP tool ids also arrive as `mcp__server__tool_name` — `__` is that
170
+ * format's hierarchy separator, the same role `/` plays elsewhere. Without
171
+ * normalizing it first, only the trailing `_` gets word-split, leaving the
172
+ * server segment glued onto the leaf ("Mcp Linear Create Issue", still
173
+ * effectively the raw identifier) — collapsing `__` to `/` first lets the
174
+ * existing leaf-splitting logic below do the same job it already does for
175
+ * `linear/create_issue`.
176
+ */
177
+ export function narrationToolName(toolName) {
178
+ const n = normalizeName(toolName).replace(/__+/g, '/');
179
+ const leaf = n.includes('/') ? n.slice(n.lastIndexOf('/') + 1) : n;
180
+ return leaf
181
+ .replace(/_/g, ' ')
182
+ .trim()
183
+ .replace(/\b\w/g, (c) => c.toUpperCase());
184
+ }
185
+ /**
186
+ * The label a Context row wears for a tool, in plain language.
187
+ *
188
+ * Keyed on FAMILY, never on the tool name. A second per-tool table would be
189
+ * exactly the duplication `FAMILY_BY_TOOL` exists to prevent, and it would
190
+ * drift the moment another spelling of an existing tool lands. Two families
191
+ * earn an override; every other one keeps `narrationToolName`, where the tool's
192
+ * own name is still the most truthful thing to call it.
193
+ *
194
+ * - `run` — `bash` humanizes to "Bash", the name of a shell. A reader who has
195
+ * never opened one still knows what a terminal is.
196
+ * - `memory` — `memory`, `memory_search`, `mem_search`, `ltm_search` and
197
+ * `get_mem` are five spellings of ONE thing. Humanized per tool they split
198
+ * into "Memory", "Memory Search", "Get Mem", … as separate rows sitting
199
+ * beside each other; `deriveContext` folds by label, so one label is what
200
+ * makes them one row.
201
+ */
202
+ const CONTEXT_LABEL_BY_FAMILY = {
203
+ run: 'Terminal',
204
+ memory: 'Memory',
205
+ };
206
+ export function contextLabelForTool(toolName) {
207
+ const family = familyForTool(toolName);
208
+ const label = family === 'hidden' ? undefined : CONTEXT_LABEL_BY_FAMILY[family];
209
+ return label ?? narrationToolName(toolName);
210
+ }
211
+ function plural(n, one, many) {
212
+ return n === 1 ? one : many;
213
+ }
214
+ /** `["a"]` → `"a"`; `["a","b"]` → `"a and b"`; `["a","b","c"]` → `"a, b, and c"`. */
215
+ function joinWithAnd(items) {
216
+ if (items.length === 0)
217
+ return '';
218
+ if (items.length === 1)
219
+ return items[0];
220
+ if (items.length === 2)
221
+ return `${items[0]} and ${items[1]}`;
222
+ return `${items.slice(0, -1).join(', ')}, and ${items[items.length - 1]}`;
223
+ }
224
+ /** The primary arg of the first part, if it has one (a filename, a query, …). */
225
+ function firstArg(parts) {
226
+ return parts.length ? getToolPrimaryArg(parts[0]) : '';
227
+ }
228
+ /** Raw tool input, for the rare case a sentence must depend on an argument
229
+ * rather than the tool name (e.g. the bare `triggers` tool's `action` field). */
230
+ function rawInput(part) {
231
+ const state = (part.state ?? {});
232
+ return state.input ?? {};
233
+ }
234
+ const DELEGATE_ACTION = {
235
+ agent_spawn: 'spawn',
236
+ agent_task: 'spawn',
237
+ agent_task_create: 'spawn',
238
+ agent_task_start: 'spawn',
239
+ task: 'spawn',
240
+ task_create: 'spawn',
241
+ task_start: 'spawn',
242
+ session_spawn: 'spawn',
243
+ session_start_background: 'spawn',
244
+ agent_message: 'message',
245
+ agent_task_message: 'message',
246
+ task_message: 'message',
247
+ // agent_task_update / task_update are NOT looked up here — they're
248
+ // themselves action-multiplexed, and `delegateAction` below resolves them
249
+ // from their own `action` field before ever consulting this table.
250
+ session_message: 'message',
251
+ agent_status: 'status',
252
+ agent_task_list: 'status',
253
+ agent_task_get: 'status',
254
+ task_list: 'status',
255
+ task_get: 'status',
256
+ agent_stop: 'stop',
257
+ agent_task_cancel: 'stop',
258
+ task_cancel: 'stop',
259
+ agent_task_approve: 'done',
260
+ task_approve: 'done',
261
+ task_done: 'done',
262
+ task_delete: 'delete',
263
+ };
264
+ /**
265
+ * `agent_task_update` / `task_update` are themselves action-multiplexed: the
266
+ * same tool name further dispatches on its own `action` field to render one
267
+ * of four unrelated components (AgentSpawnTool / AgentMessageTool /
268
+ * AgentStopTool / TaskDoneTool — see AgentTaskUpdateTool). The static
269
+ * DELEGATE_ACTION table can't see that field, so resolve it here first;
270
+ * every other delegate tool keeps its fixed table lookup. Default ('message')
271
+ * matches the component's own default branch.
272
+ */
273
+ function delegateAction(part) {
274
+ const t = normalizeName(part.tool);
275
+ if (t === 'agent_task_update' || t === 'task_update') {
276
+ switch (rawInput(part).action || '') {
277
+ case 'start':
278
+ return 'spawn';
279
+ case 'cancel':
280
+ return 'stop';
281
+ case 'approve':
282
+ return 'done';
283
+ default:
284
+ return 'message';
285
+ }
286
+ }
287
+ return DELEGATE_ACTION[t] ?? 'message';
288
+ }
289
+ function classifyAutomationAction(action) {
290
+ switch (action) {
291
+ case 'create':
292
+ return 'create';
293
+ case 'update':
294
+ return 'update';
295
+ case 'delete':
296
+ return 'delete';
297
+ case 'test':
298
+ // A dry run: the trigger's component title is literally "Test Trigger"
299
+ // and nothing is created, paused, or resumed. Must stay distinct from
300
+ // 'control' or a dry run reads as a real mutation.
301
+ return 'test';
302
+ case 'pause':
303
+ case 'resume':
304
+ return 'control';
305
+ case 'list':
306
+ case 'get':
307
+ return 'read';
308
+ default:
309
+ // An action the bare `triggers` tool doesn't recognize either — its own
310
+ // default branch (TriggersTool) renders a generic "Triggers" title, NOT
311
+ // the list branch, so narration must not guess 'read' here or a real
312
+ // mutation under an unrecognized name could pass as a "Checked" no-op.
313
+ return 'unknown';
314
+ }
315
+ }
316
+ function automationAction(part) {
317
+ const t = normalizeName(part.tool);
318
+ if (t === 'triggers') {
319
+ // The tool's own default is 'list' when the model omits the field —
320
+ // match that exactly so the narration can never disagree with the UI.
321
+ const action = rawInput(part).action || 'list';
322
+ return classifyAutomationAction(action);
323
+ }
324
+ const m = t.match(/^trigger_(.+)$/);
325
+ return classifyAutomationAction(m ? m[1] : 'list');
326
+ }
327
+ const CONNECTOR_ACTION = {
328
+ connector_setup: 'connect',
329
+ connector_get: 'read',
330
+ connector_list: 'read',
331
+ kortix_connector_discover: 'read',
332
+ kortix_connector_describe: 'read',
333
+ kortix_connectors: 'read',
334
+ kortix_connectors_connectors: 'read',
335
+ kortix_connectors_discover: 'read',
336
+ kortix_connectors_describe: 'read',
337
+ kortix_connector_call: 'call',
338
+ // The name the runtime registers today. Unmapped, it fell through to 'read'
339
+ // and a real call was narrated as "Checked".
340
+ kortix_connectors_call: 'call',
341
+ };
342
+ function connectorAction(part) {
343
+ return CONNECTOR_ACTION[normalizeName(part.tool)] ?? 'read';
344
+ }
345
+ const PROJECT_ACTION = {
346
+ project_get: 'open',
347
+ project_list: 'open',
348
+ project_select: 'open',
349
+ // A real mutation — renames the project and can change its default_branch /
350
+ // manifest_path (PATCH /v1/projects/:projectId) — never "opened".
351
+ project_update: 'update',
352
+ project_create: 'create',
353
+ project_delete: 'delete',
354
+ };
355
+ function projectAction(part) {
356
+ return PROJECT_ACTION[normalizeName(part.tool)] ?? 'open';
357
+ }
358
+ function allSame(items) {
359
+ return items.every((i) => i === items[0]);
360
+ }
361
+ const MEMORY_COMMAND_ACTION = {
362
+ view: 'read',
363
+ create: 'write',
364
+ str_replace: 'write',
365
+ insert: 'write',
366
+ rename: 'write',
367
+ delete: 'delete',
368
+ };
369
+ function memoryAction(part) {
370
+ const t = normalizeName(part.tool);
371
+ if (t !== 'memory')
372
+ return 'read'; // memory_search/mem_search/ltm_search/get_mem
373
+ const command = rawInput(part).command;
374
+ return (command && MEMORY_COMMAND_ACTION[command]) || 'unknown';
375
+ }
376
+ // ─── create: image_gen/presentation_gen multiplex over `action` too ────────
377
+ // (see titleMap in image-gen-tool.tsx and the action switch in
378
+ // presentation-gen-tool.tsx). A per-tool action→sentence table, each with a
379
+ // vague-but-true default for a missing/unrecognized action, keeps this from
380
+ // turning into a pile of one-off `if` branches.
381
+ const IMAGE_GEN_ACTION_SENTENCE = {
382
+ generate: 'Made an image',
383
+ edit: 'Edited an image',
384
+ upscale: 'Upscaled an image',
385
+ remove_bg: 'Removed an image background',
386
+ };
387
+ const PRESENTATION_GEN_ACTION_SENTENCE = {
388
+ create_slide: 'Added a slide to a presentation',
389
+ list_slides: "Checked a presentation's slides",
390
+ list_presentations: 'Checked your presentations',
391
+ delete_slide: 'Deleted a slide from a presentation',
392
+ delete_presentation: 'Deleted a presentation',
393
+ validate_slide: 'Checked a slide',
394
+ export_pdf: 'Exported a presentation to PDF',
395
+ export_pptx: 'Exported a presentation to PPTX',
396
+ preview: 'Previewed a presentation',
397
+ serve: 'Previewed a presentation',
398
+ };
399
+ /** Last path segment, tolerant of both `/` and `\` separators — mirrors the
400
+ * private helper `tool-meta.ts`/`derive-panels.ts` each keep their own copy
401
+ * of, rather than exporting one from the off-limits `tool/` directory. */
402
+ function basename(p) {
403
+ const cleaned = stripTrailingSlashes(p.replace(/\\/g, '/'));
404
+ const idx = cleaned.lastIndexOf('/');
405
+ return idx >= 0 ? cleaned.slice(idx + 1) : cleaned;
406
+ }
407
+ /**
408
+ * `show`/`show_user` display an existing result — a file, a link, a block of
409
+ * text. `getToolPrimaryArg` has no case for them, so it used to fall through
410
+ * to its generic fallback-key list, which returns `input.path`/`input.url`
411
+ * completely verbatim (a real sandbox path or e2b preview URL straight to a
412
+ * non-technical user — rule 2 forbids exactly this). ShowTool itself renders
413
+ * `input.title` as its own heading, so prefer that; then a description; and
414
+ * only when neither exists fall back to a BASENAME or DOMAIN — never the raw
415
+ * path/URL itself. `wsDomain` echoes its input verbatim when URL parsing
416
+ * fails, so the url fallback is gated through `safeHttpUrl` first (the same
417
+ * pattern show-tool.tsx uses): a relative path, embedded token, or
418
+ * scheme-less string never reaches this always-visible sentence — it
419
+ * degrades to the generic 'a link'.
420
+ */
421
+ function showLabel(part) {
422
+ const input = rawInput(part);
423
+ const title = typeof input.title === 'string' ? input.title.trim() : '';
424
+ if (title)
425
+ return title;
426
+ const description = typeof input.description === 'string' ? input.description.trim() : '';
427
+ if (description)
428
+ return truncate(description, 60);
429
+ const path = typeof input.path === 'string' ? input.path : '';
430
+ if (path)
431
+ return basename(path);
432
+ const url = typeof input.url === 'string' ? input.url : '';
433
+ if (url) {
434
+ const safeUrl = safeHttpUrl(url);
435
+ return safeUrl ? wsDomain(safeUrl) : 'a link';
436
+ }
437
+ return '';
438
+ }
439
+ /** Trim + collapse-whitespace + ellipsize a free-text label. Mirrors the
440
+ * private helper of the same name in `tool-meta.ts`/`derive-panels.ts`. */
441
+ function truncate(s, max = 60) {
442
+ const trimmed = s.replace(/\s+/g, ' ').trim();
443
+ return trimmed.length > max ? trimmed.slice(0, max - 1) + '…' : trimmed;
444
+ }
445
+ function imageGenSentence(part) {
446
+ const action = rawInput(part).action;
447
+ return (action && IMAGE_GEN_ACTION_SENTENCE[action]) || 'Worked on an image';
448
+ }
449
+ function presentationGenSentence(part) {
450
+ const action = rawInput(part).action;
451
+ return (action && PRESENTATION_GEN_ACTION_SENTENCE[action]) || 'Worked on a presentation';
452
+ }
453
+ function createMediaOf(key) {
454
+ return key.slice(0, key.indexOf(':'));
455
+ }
456
+ const IMAGE_GEN_ACTION_KEY = {
457
+ generate: 'image:generate',
458
+ edit: 'image:edit',
459
+ upscale: 'image:upscale',
460
+ remove_bg: 'image:remove_bg',
461
+ };
462
+ const PRESENTATION_GEN_ACTION_KEY = {
463
+ create_slide: 'presentation:create_slide',
464
+ list_slides: 'presentation:list_slides',
465
+ list_presentations: 'presentation:list_presentations',
466
+ delete_slide: 'presentation:delete_slide',
467
+ delete_presentation: 'presentation:delete_presentation',
468
+ validate_slide: 'presentation:validate_slide',
469
+ export_pdf: 'presentation:export_pdf',
470
+ export_pptx: 'presentation:export_pptx',
471
+ preview: 'presentation:preview',
472
+ serve: 'presentation:preview', // same component, same sentence
473
+ };
474
+ /** Classify one part into a `media:action` key. Every key this can return
475
+ * has a matching entry in `CREATE_GROUP_SENTENCE` below. */
476
+ function createPartKey(part) {
477
+ const t = normalizeName(part.tool);
478
+ if (t === 'image_gen') {
479
+ const action = rawInput(part).action;
480
+ return (action && IMAGE_GEN_ACTION_KEY[action]) || 'image:unknown';
481
+ }
482
+ if (t === 'video_gen')
483
+ return 'video:create';
484
+ if (t === 'presentation_gen') {
485
+ const action = rawInput(part).action;
486
+ return (action && PRESENTATION_GEN_ACTION_KEY[action]) || 'presentation:unknown';
487
+ }
488
+ // `show` / `show_user` never multiplex on an action, and any future tool
489
+ // this file hasn't been told about yet falls here too — never a raw name.
490
+ return 'shown:result';
491
+ }
492
+ /** presentation_gen actions that extend or export the deck itself. The other
493
+ * six actions are pure reads (list_slides, list_presentations,
494
+ * validate_slide, preview, serve) or destructive (delete_slide,
495
+ * delete_presentation) — none of those produced anything the agent made. */
496
+ const PRESENTATION_GEN_ARTIFACT_ACTIONS = new Set(['create_slide', 'export_pdf', 'export_pptx']);
497
+ /**
498
+ * The kind of artifact this call produced, or `null` if it did not make
499
+ * anything worth surfacing in Outputs (a delete, a listing, a preview, …).
500
+ *
501
+ * `image_gen` has no pure-read action — generate/edit/upscale/remove_bg (and
502
+ * a missing/unrecognized action) all leave behind a real image file the user
503
+ * asked for and will want to open (see ImageGenTool, which renders a
504
+ * resulting image for every one of these). Only the LABEL differs by action
505
+ * (see `imageGenSentence` — calling an edit "Made an image" would be a lie);
506
+ * the artifact itself must always surface here, or a user who asks to
507
+ * edit/upscale/remove a background gets an empty Outputs card despite the
508
+ * agent having actually produced something.
509
+ */
510
+ export function createArtifactKind(part) {
511
+ const t = normalizeName(part.tool);
512
+ if (t === 'image_gen')
513
+ return 'image';
514
+ if (t === 'video_gen')
515
+ return 'video';
516
+ if (t === 'presentation_gen') {
517
+ const action = rawInput(part).action;
518
+ if (!action)
519
+ return 'presentation';
520
+ return PRESENTATION_GEN_ARTIFACT_ACTIONS.has(action) ? 'presentation' : null;
521
+ }
522
+ // `show` / `show_user` display an existing result rather than make a new
523
+ // artifact, and any future `create`-family tool this file hasn't been
524
+ // taught about yet falls here too — never guess it made something.
525
+ return null;
526
+ }
527
+ /** One truthful, count-aware sentence per key, used only when every part in
528
+ * the group shares the exact same key (see `narrateStep`'s 'create' case). */
529
+ const CREATE_GROUP_SENTENCE = {
530
+ 'image:generate': (n) => `Made ${n} images`,
531
+ 'image:edit': (n) => `Edited ${n} images`,
532
+ 'image:upscale': (n) => `Upscaled ${n} images`,
533
+ 'image:remove_bg': (n) => `Removed backgrounds from ${n} images`,
534
+ 'image:unknown': (n) => `Worked on ${n} images`,
535
+ 'video:create': (n) => `Made ${n} videos`,
536
+ 'presentation:create_slide': (n) => `Added ${n} slides`,
537
+ 'presentation:delete_slide': (n) => `Deleted ${n} slides`,
538
+ 'presentation:delete_presentation': (n) => `Deleted ${n} presentations`,
539
+ 'presentation:list_slides': () => "Checked a presentation's slides",
540
+ 'presentation:list_presentations': () => 'Checked your presentations',
541
+ 'presentation:validate_slide': () => 'Checked slides',
542
+ 'presentation:export_pdf': (n) => `Exported ${n} presentations to PDF`,
543
+ 'presentation:export_pptx': (n) => `Exported ${n} presentations to PPTX`,
544
+ 'presentation:preview': (n) => `Previewed ${n} presentations`,
545
+ 'presentation:unknown': (n) => `Worked on ${n} presentations`,
546
+ 'shown:result': (n) => `Showed you ${n} results`,
547
+ };
548
+ const CREATE_MEDIA_NOUN = {
549
+ image: 'image',
550
+ video: 'video',
551
+ presentation: 'presentation',
552
+ shown: 'result',
553
+ };
554
+ /** The group's actions (or its media types) genuinely differ — say only what
555
+ * was touched, in neutral terms that hold no matter which specific action
556
+ * each part turns out to be. Vague-but-true always beats specific-but-false. */
557
+ function mixedCreateSentence(keys) {
558
+ const counts = { image: 0, video: 0, presentation: 0, shown: 0 };
559
+ for (const key of keys)
560
+ counts[createMediaOf(key)]++;
561
+ const segments = [];
562
+ Object.keys(counts).forEach((media) => {
563
+ const c = counts[media];
564
+ if (c)
565
+ segments.push(`${c} ${plural(c, CREATE_MEDIA_NOUN[media], `${CREATE_MEDIA_NOUN[media]}s`)}`);
566
+ });
567
+ return `Worked on ${joinWithAnd(segments)}`;
568
+ }
569
+ /**
570
+ * One sentence for a group of same-family calls.
571
+ * `parts` is guaranteed non-empty and homogeneous by `group-steps` — homogeneous
572
+ * by *family*, not by tool, so a single call can still mix several distinct
573
+ * tools (e.g. `image_gen` + `video_gen`, or `connector_get` + `connector_setup`).
574
+ * Every branch below inspects every part, never just `parts[0]`.
575
+ */
576
+ export function narrateStep(family, parts) {
577
+ const n = parts.length;
578
+ const arg = firstArg(parts);
579
+ switch (family) {
580
+ case 'explore': {
581
+ const reads = parts.filter((p) => normalizeName(p.tool) === 'read').length;
582
+ if (reads === n)
583
+ return `Read ${n} ${plural(n, 'file', 'files')}`;
584
+ if (reads === 0)
585
+ return 'Looked through your files';
586
+ return `Looked through your files · ${reads} read`;
587
+ }
588
+ case 'edit': {
589
+ if (n === 1) {
590
+ const verb = normalizeName(parts[0].tool) === 'write' ? 'Wrote' : 'Updated';
591
+ return arg ? `${verb} ${arg}` : `${verb} a file`;
592
+ }
593
+ const writes = parts.filter((p) => normalizeName(p.tool) === 'write').length;
594
+ return writes === n ? `Wrote ${n} files` : `Updated ${n} files`;
595
+ }
596
+ case 'run':
597
+ return n === 1 ? 'Ran a command' : `Ran ${n} commands`;
598
+ case 'web': {
599
+ const isSearch = (p) => {
600
+ const t = normalizeName(p.tool);
601
+ return t === 'web_search' || t === 'websearch' || t === 'image_search';
602
+ };
603
+ const searches = parts.filter(isSearch).length;
604
+ if (searches === n)
605
+ return `Searched the web · ${n} ${plural(n, 'query', 'queries')}`;
606
+ if (searches === 0)
607
+ return `Read ${n} ${plural(n, 'page', 'pages')}`;
608
+ // Mixed step: "sources" means pages, so count distinct page URLs —
609
+ // every search result plus every fetched URL — never tool calls.
610
+ // Unparseable outputs fall back to the call count (still a floor, not a lie).
611
+ const urls = new Set();
612
+ for (const p of parts) {
613
+ if (isSearch(p)) {
614
+ const raw = p.state?.output;
615
+ for (const src of parseWebSearchOutput(raw).flatMap((q) => q.sources)) {
616
+ if (src.url)
617
+ urls.add(src.url);
618
+ }
619
+ }
620
+ else {
621
+ const url = p.state?.input?.url;
622
+ if (typeof url === 'string' && url)
623
+ urls.add(url);
624
+ }
625
+ }
626
+ const count = urls.size || n;
627
+ return `Searched and read ${count} ${plural(count, 'source', 'sources')}`;
628
+ }
629
+ case 'create': {
630
+ if (n === 1) {
631
+ const p = parts[0];
632
+ const t = normalizeName(p.tool);
633
+ if (t === 'image_gen')
634
+ return imageGenSentence(p);
635
+ if (t === 'video_gen')
636
+ return 'Made a video';
637
+ if (t === 'presentation_gen')
638
+ return presentationGenSentence(p);
639
+ // `show` / `show_user`, and any future create-family tool this file
640
+ // hasn't been taught about yet — never route through the generic
641
+ // `getToolPrimaryArg` fallback (it returns raw paths/URLs verbatim).
642
+ const label = showLabel(p);
643
+ return label ? `Showed you ${label}` : 'Showed you the result';
644
+ }
645
+ const keys = parts.map(createPartKey);
646
+ if (allSame(keys))
647
+ return CREATE_GROUP_SENTENCE[keys[0]](n);
648
+ return mixedCreateSentence(keys);
649
+ }
650
+ case 'plan':
651
+ return n === 1 ? 'Planned the work' : `Planned the work · ${n} steps`;
652
+ case 'delegate': {
653
+ const actions = parts.map(delegateAction);
654
+ if (allSame(actions)) {
655
+ switch (actions[0]) {
656
+ case 'spawn':
657
+ return n === 1 ? 'Asked a helper agent' : `Worked with ${n} helper agents`;
658
+ case 'message':
659
+ return n === 1
660
+ ? 'Sent instructions to a helper agent'
661
+ : `Sent instructions to ${n} helper agents`;
662
+ case 'status':
663
+ return 'Checked on a helper agent';
664
+ case 'stop':
665
+ return n === 1 ? 'Stopped a helper agent' : `Stopped ${n} helper agents`;
666
+ case 'done':
667
+ return n === 1 ? 'A helper agent finished a task' : `Helper agents finished ${n} tasks`;
668
+ case 'delete':
669
+ return n === 1 ? 'Removed a task' : `Removed ${n} tasks`;
670
+ }
671
+ }
672
+ return n === 1 ? 'Worked with a helper agent' : `Worked with helper agents · ${n} steps`;
673
+ }
674
+ case 'sessions':
675
+ return 'Checked earlier work';
676
+ case 'memory': {
677
+ const actions = parts.map(memoryAction);
678
+ if (allSame(actions)) {
679
+ switch (actions[0]) {
680
+ case 'write':
681
+ return n === 1 ? 'Wrote to its memory' : `Wrote to its memory · ${n} updates`;
682
+ case 'delete':
683
+ return n === 1 ? 'Deleted from its memory' : `Deleted ${n} things from its memory`;
684
+ case 'read':
685
+ return 'Recalled what you told it before';
686
+ }
687
+ }
688
+ return 'Worked with its memory';
689
+ }
690
+ case 'connectors': {
691
+ const actions = parts.map(connectorAction);
692
+ if (allSame(actions)) {
693
+ switch (actions[0]) {
694
+ case 'connect':
695
+ if (n === 1)
696
+ return arg ? `Connected to ${arg}` : 'Connected a connector';
697
+ return `Connected ${n} connectors`;
698
+ case 'call':
699
+ // `n` counts calls, not distinct connectors: two calls to Gmail
700
+ // are not "2 connectors".
701
+ return n === 1 ? 'Used a connector' : `Made ${n} connector calls`;
702
+ case 'read':
703
+ return 'Checked your connectors';
704
+ }
705
+ }
706
+ return 'Worked with your connectors';
707
+ }
708
+ case 'automations': {
709
+ const actions = parts.map(automationAction);
710
+ if (allSame(actions)) {
711
+ switch (actions[0]) {
712
+ case 'create':
713
+ return n === 1 ? 'Set up an automation' : `Set up ${n} automations`;
714
+ case 'update':
715
+ return n === 1 ? 'Updated an automation' : `Updated ${n} automations`;
716
+ case 'delete':
717
+ return n === 1 ? 'Deleted an automation' : `Deleted ${n} automations`;
718
+ case 'control':
719
+ return n === 1 ? 'Adjusted an automation' : `Adjusted ${n} automations`;
720
+ case 'test':
721
+ // A dry run — nothing is created, changed, or paused.
722
+ return n === 1 ? 'Tested an automation' : `Tested ${n} automations`;
723
+ case 'read':
724
+ return 'Checked your automations';
725
+ case 'unknown':
726
+ // An action neither this file nor the tool's own component
727
+ // recognizes — never guess it's a harmless read.
728
+ return 'Worked with your automations';
729
+ }
730
+ }
731
+ return 'Worked with your automations';
732
+ }
733
+ case 'projects': {
734
+ const actions = parts.map(projectAction);
735
+ if (allSame(actions)) {
736
+ switch (actions[0]) {
737
+ case 'delete':
738
+ return n === 1
739
+ ? "Tried to delete a project — deletion isn't allowed"
740
+ : `Tried to delete ${n} projects — deletion isn't allowed`;
741
+ case 'create':
742
+ if (n === 1)
743
+ return arg ? `Created ${arg}` : 'Created a project';
744
+ return `Created ${n} projects`;
745
+ case 'update':
746
+ // A real mutation (rename / default_branch / manifest_path) — never "opened".
747
+ if (n === 1)
748
+ return arg ? `Updated ${arg}` : 'Updated your project';
749
+ return `Updated ${n} projects`;
750
+ case 'open':
751
+ if (n === 1)
752
+ return arg ? `Opened ${arg}` : 'Opened your project';
753
+ return `Opened ${n} projects`;
754
+ }
755
+ }
756
+ return arg ? `Worked in ${arg}` : 'Worked in your project';
757
+ }
758
+ case 'skills': {
759
+ if (n === 1)
760
+ return arg ? `Used the ${arg} skill` : 'Used a skill';
761
+ return `Used ${n} skills`;
762
+ }
763
+ case 'ask':
764
+ return 'Asked you a question';
765
+ case 'retired':
766
+ return 'Used a connector that has since been removed';
767
+ case 'other': {
768
+ if (n === 1)
769
+ return `Used ${narrationToolName(parts[0].tool)}`;
770
+ // Never inspect only parts[0] — a mixed group of unrecognized/MCP tools
771
+ // must name every distinct one, not silently drop the rest.
772
+ const names = Array.from(new Set(parts.map((p) => narrationToolName(p.tool))));
773
+ if (names.length === 1)
774
+ return `Used ${names[0]} · ${n} times`;
775
+ return `Used ${joinWithAnd(names)}`;
776
+ }
777
+ }
778
+ }
779
+ /**
780
+ * The failure phrasing for a step whose status is 'error' (W7). Same rules as
781
+ * `narrateStep` — plain language, never a raw identifier, never an error code.
782
+ * Grouped steps can mix one failure among successes; the step-level status is
783
+ * already 'error' (see group-steps.statusOf), so the sentence owns the whole
784
+ * step: vague-but-true beats specific-but-false here exactly as everywhere else.
785
+ */
786
+ export function narrateFailedStep(family, parts) {
787
+ const arg = firstArg(parts);
788
+ switch (family) {
789
+ case 'explore':
790
+ return "Couldn't read your files";
791
+ case 'edit': {
792
+ if (parts.length === 1) {
793
+ const verb = normalizeName(parts[0].tool) === 'write' ? 'write' : 'update';
794
+ return arg ? `Couldn't ${verb} ${arg}` : `Couldn't ${verb} a file`;
795
+ }
796
+ return "Couldn't update some files";
797
+ }
798
+ case 'run':
799
+ return 'A command failed';
800
+ case 'web':
801
+ return "Couldn't finish searching the web";
802
+ case 'create':
803
+ return "Couldn't finish making that";
804
+ case 'plan':
805
+ return "Couldn't update the plan";
806
+ case 'delegate':
807
+ return 'A helper agent hit a problem';
808
+ case 'sessions':
809
+ return "Couldn't check earlier work";
810
+ case 'memory':
811
+ return "Couldn't reach its memory";
812
+ case 'connectors':
813
+ return "Couldn't reach a connector";
814
+ case 'automations':
815
+ return 'Hit a problem with your automations';
816
+ case 'projects':
817
+ return 'Hit a problem with your project';
818
+ case 'skills':
819
+ return "Couldn't use a skill";
820
+ case 'ask':
821
+ return "Couldn't ask you a question";
822
+ case 'retired':
823
+ return 'Used a connector that has since been removed';
824
+ case 'other': {
825
+ // 'other' is the catch-all family, so a grouped step can hold several
826
+ // distinct tools of which only one errored — naming parts[0] would blame
827
+ // the wrong tool by name. Prefer the parts that actually failed, and
828
+ // name every distinct one, mirroring narrateStep's own 'other' handling.
829
+ const failed = parts.filter((p) => p.state?.status === 'error');
830
+ const source = failed.length ? failed : parts;
831
+ const names = Array.from(new Set(source.map((p) => narrationToolName(p.tool))));
832
+ return `Couldn't finish using ${joinWithAnd(names)}`;
833
+ }
834
+ }
835
+ }
836
+ //# sourceMappingURL=narration.js.map