@getmateo/protocol 0.0.0-stage → 0.18.0

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 (179) hide show
  1. package/LICENSE +211 -0
  2. package/README.md +11 -2
  3. package/dist/addresses.d.ts +6 -0
  4. package/dist/addresses.js +2 -0
  5. package/dist/agent-attention-notification.d.ts +57 -0
  6. package/dist/agent-attention-notification.js +177 -0
  7. package/dist/agent-deep-link.d.ts +8 -0
  8. package/dist/agent-deep-link.js +49 -0
  9. package/dist/agent-labels.d.ts +14 -0
  10. package/dist/agent-labels.js +38 -0
  11. package/dist/agent-lifecycle.d.ts +3 -0
  12. package/dist/agent-lifecycle.js +8 -0
  13. package/dist/agent-message.d.ts +20 -0
  14. package/dist/agent-message.js +12 -0
  15. package/dist/agent-profile.d.ts +31 -0
  16. package/dist/agent-profile.js +32 -0
  17. package/dist/agent-runtime-config.d.ts +4 -0
  18. package/dist/agent-runtime-config.js +5 -0
  19. package/dist/agent-shells.d.ts +25 -0
  20. package/dist/agent-shells.js +17 -0
  21. package/dist/agent-state-bucket.d.ts +15 -0
  22. package/dist/agent-state-bucket.js +41 -0
  23. package/dist/agent-title-limits.d.ts +2 -0
  24. package/dist/agent-title-limits.js +2 -0
  25. package/dist/agent-types.d.ts +484 -0
  26. package/dist/agent-types.js +33 -0
  27. package/dist/binary-frames/demux.d.ts +15 -0
  28. package/dist/binary-frames/demux.js +28 -0
  29. package/dist/binary-frames/file-transfer.d.ts +51 -0
  30. package/dist/binary-frames/file-transfer.js +108 -0
  31. package/dist/binary-frames/host-route.d.ts +13 -0
  32. package/dist/binary-frames/host-route.js +39 -0
  33. package/dist/binary-frames/index.d.ts +5 -0
  34. package/dist/binary-frames/index.js +5 -0
  35. package/dist/binary-frames/terminal.d.ts +35 -0
  36. package/dist/binary-frames/terminal.js +100 -0
  37. package/dist/branch-slug.d.ts +14 -0
  38. package/dist/branch-slug.js +49 -0
  39. package/dist/browser-automation/capabilities.d.ts +7 -0
  40. package/dist/browser-automation/capabilities.js +31 -0
  41. package/dist/browser-automation/rpc-schemas.d.ts +1224 -0
  42. package/dist/browser-automation/rpc-schemas.js +497 -0
  43. package/dist/browser-download-rules.d.ts +21 -0
  44. package/dist/browser-download-rules.js +54 -0
  45. package/dist/build-metadata.d.ts +17 -0
  46. package/dist/build-metadata.js +61 -0
  47. package/dist/chat/rpc-schemas.d.ts +158 -0
  48. package/dist/chat/rpc-schemas.js +104 -0
  49. package/dist/chat/types.d.ts +30 -0
  50. package/dist/chat/types.js +23 -0
  51. package/dist/check-traits.d.ts +11 -0
  52. package/dist/check-traits.js +10 -0
  53. package/dist/chunked-transport.d.ts +42 -0
  54. package/dist/chunked-transport.js +277 -0
  55. package/dist/client-capabilities.d.ts +24 -0
  56. package/dist/client-capabilities.js +52 -0
  57. package/dist/connection-offer.d.ts +36 -0
  58. package/dist/connection-offer.js +53 -0
  59. package/dist/daemon-auth.d.ts +548 -0
  60. package/dist/daemon-auth.js +152 -0
  61. package/dist/daemon-endpoints.d.ts +54 -0
  62. package/dist/daemon-endpoints.js +243 -0
  63. package/dist/error-utils.d.ts +11 -0
  64. package/dist/error-utils.js +27 -0
  65. package/dist/fleet.d.ts +381 -0
  66. package/dist/fleet.js +134 -0
  67. package/dist/forge-manifest.d.ts +66 -0
  68. package/dist/forge-manifest.js +92 -0
  69. package/dist/generated/validation/ws-outbound-schema-metadata.d.ts +14187 -0
  70. package/dist/generated/validation/ws-outbound-schema-metadata.js +262 -0
  71. package/dist/generated/validation/ws-outbound.aot.d.ts +520 -0
  72. package/dist/generated/validation/ws-outbound.aot.js +106677 -0
  73. package/dist/git-remote.d.ts +33 -0
  74. package/dist/git-remote.js +94 -0
  75. package/dist/gitea-status.d.ts +10 -0
  76. package/dist/gitea-status.js +23 -0
  77. package/dist/gitlab-pipeline.d.ts +10 -0
  78. package/dist/gitlab-pipeline.js +17 -0
  79. package/dist/global-terminal.d.ts +3 -0
  80. package/dist/global-terminal.js +8 -0
  81. package/dist/host-connection-schema.d.ts +11 -0
  82. package/dist/host-connection-schema.js +9 -0
  83. package/dist/host-target.d.ts +20 -0
  84. package/dist/host-target.js +137 -0
  85. package/dist/hosts.d.ts +133 -0
  86. package/dist/hosts.js +82 -0
  87. package/dist/literal-union.d.ts +2 -0
  88. package/dist/literal-union.js +2 -0
  89. package/dist/loop/rpc-schemas.d.ts +636 -0
  90. package/dist/loop/rpc-schemas.js +164 -0
  91. package/dist/mateo-config-schema.d.ts +138 -0
  92. package/dist/mateo-config-schema.js +98 -0
  93. package/dist/mateo-tool-call-detail.d.ts +2 -0
  94. package/dist/mateo-tool-call-detail.js +3 -0
  95. package/dist/mateo-tool-presentation/agent-message.d.ts +10 -0
  96. package/dist/mateo-tool-presentation/agent-message.js +23 -0
  97. package/dist/mateo-tool-presentation/catalog.d.ts +321 -0
  98. package/dist/mateo-tool-presentation/catalog.js +319 -0
  99. package/dist/mateo-tool-presentation/detail-sections.d.ts +15 -0
  100. package/dist/mateo-tool-presentation/detail-sections.js +161 -0
  101. package/dist/mateo-tool-presentation/index.d.ts +22 -0
  102. package/dist/mateo-tool-presentation/index.js +62 -0
  103. package/dist/mateo-tool-presentation/summary-text.d.ts +7 -0
  104. package/dist/mateo-tool-presentation/summary-text.js +22 -0
  105. package/dist/messages.d.ts +70260 -0
  106. package/dist/messages.js +6740 -0
  107. package/dist/path-utils.d.ts +2 -0
  108. package/dist/path-utils.js +16 -0
  109. package/dist/plugin-browser-consent-copy.d.ts +193 -0
  110. package/dist/plugin-browser-consent-copy.js +109 -0
  111. package/dist/plugin-browser-grants.d.ts +48 -0
  112. package/dist/plugin-browser-grants.js +56 -0
  113. package/dist/plugin-browser.d.ts +321 -0
  114. package/dist/plugin-browser.js +109 -0
  115. package/dist/plugin-config.d.ts +18 -0
  116. package/dist/plugin-config.js +13 -0
  117. package/dist/plugin-overview.d.ts +12 -0
  118. package/dist/plugin-overview.js +50 -0
  119. package/dist/plugin-registry.d.ts +153 -0
  120. package/dist/plugin-registry.js +83 -0
  121. package/dist/plugin-requirements.d.ts +11 -0
  122. package/dist/plugin-requirements.js +26 -0
  123. package/dist/plugin-source-reference.d.ts +11 -0
  124. package/dist/plugin-source-reference.js +68 -0
  125. package/dist/provider-config.d.ts +141 -0
  126. package/dist/provider-config.js +113 -0
  127. package/dist/provider-icon-names.d.ts +5 -0
  128. package/dist/provider-icon-names.js +54 -0
  129. package/dist/provider-manifest.d.ts +30 -0
  130. package/dist/provider-manifest.js +247 -0
  131. package/dist/provider-snapshot-codec.d.ts +18 -0
  132. package/dist/provider-snapshot-codec.js +71 -0
  133. package/dist/schedule/cadence.d.ts +6 -0
  134. package/dist/schedule/cadence.js +28 -0
  135. package/dist/schedule/cron-expression.d.ts +14 -0
  136. package/dist/schedule/cron-expression.js +107 -0
  137. package/dist/schedule/rpc-schemas.d.ts +570 -0
  138. package/dist/schedule/rpc-schemas.js +158 -0
  139. package/dist/schedule/types.d.ts +201 -0
  140. package/dist/schedule/types.js +68 -0
  141. package/dist/search/text-match.d.ts +78 -0
  142. package/dist/search/text-match.js +330 -0
  143. package/dist/service-defaults.d.ts +3 -0
  144. package/dist/service-defaults.js +5 -0
  145. package/dist/ssh-transport.d.ts +11 -0
  146. package/dist/ssh-transport.js +72 -0
  147. package/dist/terminal-activity.d.ts +21 -0
  148. package/dist/terminal-activity.js +25 -0
  149. package/dist/terminal-input-mode.d.ts +30 -0
  150. package/dist/terminal-input-mode.js +180 -0
  151. package/dist/terminal-key-input.d.ts +13 -0
  152. package/dist/terminal-key-input.js +210 -0
  153. package/dist/terminal-profile.d.ts +10 -0
  154. package/dist/terminal-profile.js +11 -0
  155. package/dist/terminal-profiles.d.ts +41 -0
  156. package/dist/terminal-profiles.js +276 -0
  157. package/dist/terminal-snapshot.d.ts +4 -0
  158. package/dist/terminal-snapshot.js +220 -0
  159. package/dist/terminal-stream-protocol.d.ts +2 -0
  160. package/dist/terminal-stream-protocol.js +2 -0
  161. package/dist/terminal-subscription-key.d.ts +2 -0
  162. package/dist/terminal-subscription-key.js +9 -0
  163. package/dist/timeline-identity.d.ts +3 -0
  164. package/dist/timeline-identity.js +8 -0
  165. package/dist/tool-call-display.d.ts +13 -0
  166. package/dist/tool-call-display.js +144 -0
  167. package/dist/tool-name-normalization.d.ts +9 -0
  168. package/dist/tool-name-normalization.js +82 -0
  169. package/dist/user-agent.d.ts +26 -0
  170. package/dist/user-agent.js +101 -0
  171. package/dist/validation/ws-outbound-envelope.d.ts +13413 -0
  172. package/dist/validation/ws-outbound-envelope.js +17 -0
  173. package/dist/validation/ws-outbound.d.ts +12 -0
  174. package/dist/validation/ws-outbound.js +38 -0
  175. package/dist/websocket-message-limit.d.ts +5 -0
  176. package/dist/websocket-message-limit.js +5 -0
  177. package/dist/workspace-labels.d.ts +9 -0
  178. package/dist/workspace-labels.js +19 -0
  179. package/package.json +48 -4
@@ -0,0 +1,220 @@
1
+ const DEFAULT_STYLE = {
2
+ fg: undefined,
3
+ bg: undefined,
4
+ fgMode: undefined,
5
+ bgMode: undefined,
6
+ bold: false,
7
+ italic: false,
8
+ underline: false,
9
+ dim: false,
10
+ inverse: false,
11
+ strikethrough: false,
12
+ };
13
+ export function renderTerminalMouseModesToAnsi(modes) {
14
+ // COMPAT(terminalMouseSnapshot): added in v0.11.2, remove after 2027-04-16 once hosts send mouseModes.
15
+ if (!modes)
16
+ return "";
17
+ const trackingMode = { none: 0, x10: 9, vt200: 1000, drag: 1002, any: 1003 }[modes.tracking];
18
+ const encodingMode = { default: 0, sgr: 1006, sgrPixels: 1016 }[modes.encoding];
19
+ // Explicitly clear modes on live reattach, which need not reset the renderer.
20
+ return ("\u001b[?9;1000;1002;1003;1006;1016l" +
21
+ (trackingMode ? `\u001b[?${trackingMode}h` : "") +
22
+ (encodingMode ? `\u001b[?${encodingMode}h` : ""));
23
+ }
24
+ export function renderTerminalSnapshotToAnsi(state) {
25
+ // COMPAT(terminalBufferSnapshot): added in v0.11.2, remove after 2027-04-16 once hosts send activeBuffer.
26
+ // An older snapshot only describes its visible screen; do not invent hidden history.
27
+ if (state.activeBuffer !== "alternate") {
28
+ return renderBufferToAnsi(state) + renderTerminalMouseModesToAnsi(state.mouseModes);
29
+ }
30
+ const output = [];
31
+ if (state.normalBuffer) {
32
+ const normal = state.normalBuffer;
33
+ output.push(renderBufferToAnsi({ ...state, ...normal }));
34
+ if (normal.savedCursor) {
35
+ output.push(renderCursorPositionToAnsi(normal.savedCursor), "\u001b7");
36
+ output.push(renderCursorPositionToAnsi(normal.cursor));
37
+ }
38
+ }
39
+ // 47 switches buffers without overwriting the normal buffer's saved cursor.
40
+ // 1049 would replace it, breaking applications that used 47/1047 and ESC 7.
41
+ output.push("\u001b[?47h\u001b[H", renderBufferToAnsi(state), renderTerminalMouseModesToAnsi(state.mouseModes));
42
+ return output.join("");
43
+ }
44
+ function renderCursorPositionToAnsi(cursor) {
45
+ return `\u001b[${cursor.row + 1};${cursor.col + 1}H`;
46
+ }
47
+ function renderBufferToAnsi(state) {
48
+ const rows = [...state.scrollback, ...state.grid];
49
+ const wrapFlags = [...(state.scrollbackWrapped ?? []), ...(state.gridWrapped ?? [])];
50
+ // Soft-wrapped lines can only be re-wrapped on resize when we know which rows
51
+ // were continuations. With that per-row flag we replay each logical line as one
52
+ // unbroken run (autowrap on) so xterm marks the continuations wrapped and reflows
53
+ // them. Without it (old daemon) we keep the verbatim per-row replay: autowrap off
54
+ // plus a hard newline per row.
55
+ const hasWrapInfo = wrapFlags.length === rows.length;
56
+ const lines = hasWrapInfo ? [] : ["\u001b[?7l"];
57
+ for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
58
+ const row = rows[rowIndex] ?? [];
59
+ const continuesToNextRow = hasWrapInfo && wrapFlags[rowIndex] === true;
60
+ // A continuation row must fill the full width so the next row first cell
61
+ // triggers xterm auto-wrap, which is what marks the row wrapped/reflowable.
62
+ const wideWrapPadding = continuesToNextRow && hasWideWrapPadding(row[state.cols - 1], rows[rowIndex + 1]?.[0]);
63
+ const rowWidth = wideWrapPadding ? state.cols - 1 : state.cols;
64
+ const replayRow = wideWrapPadding ? row.slice(0, rowWidth) : row;
65
+ lines.push(renderTerminalRow(replayRow, continuesToNextRow ? rowWidth : undefined));
66
+ if (rowIndex < rows.length - 1 && !continuesToNextRow) {
67
+ lines.push("\r\n");
68
+ }
69
+ }
70
+ lines.push("\u001b[0m");
71
+ const cursorPresentationAnsi = renderCursorPresentationToAnsi(state.cursor);
72
+ if (cursorPresentationAnsi) {
73
+ lines.push(cursorPresentationAnsi);
74
+ }
75
+ lines.push(renderCursorPositionToAnsi(state.cursor));
76
+ lines.push(state.cursor.hidden ? "\u001b[?25l" : "\u001b[?25h");
77
+ if (!hasWrapInfo) {
78
+ lines.push("\u001b[?7h");
79
+ }
80
+ return lines.join("");
81
+ }
82
+ function renderCursorPresentationToAnsi(cursor) {
83
+ if (!cursor.style) {
84
+ return null;
85
+ }
86
+ const cursorStyleCode = (() => {
87
+ if (cursor.style === "block") {
88
+ return cursor.blink === false ? 2 : 1;
89
+ }
90
+ if (cursor.style === "underline") {
91
+ return cursor.blink === false ? 4 : 3;
92
+ }
93
+ return cursor.blink === false ? 6 : 5;
94
+ })();
95
+ return `\u001b[${cursorStyleCode} q`;
96
+ }
97
+ function hasWideWrapPadding(last, next) {
98
+ return last?.width === 1 && last.char === "" && next?.width === 2;
99
+ }
100
+ function renderTerminalRow(row, padToCols) {
101
+ const output = [];
102
+ const contentLength = getTerminalRowLength(row);
103
+ const length = padToCols !== undefined ? Math.max(contentLength, padToCols) : contentLength;
104
+ let previousStyle = DEFAULT_STYLE;
105
+ for (let index = 0; index < length; index += 1) {
106
+ const cell = row[index] ?? { char: " " };
107
+ if (cell.width === 0)
108
+ continue;
109
+ const nextStyle = getTerminalStyle(cell);
110
+ if (!terminalStylesEqual(previousStyle, nextStyle)) {
111
+ output.push(styleToAnsi(nextStyle));
112
+ previousStyle = nextStyle;
113
+ }
114
+ output.push(cell.char || " ");
115
+ }
116
+ if (!terminalStylesEqual(previousStyle, DEFAULT_STYLE)) {
117
+ output.push("\u001b[0m");
118
+ }
119
+ return output.join("");
120
+ }
121
+ function getTerminalRowLength(row) {
122
+ for (let index = row.length - 1; index >= 0; index -= 1) {
123
+ const cell = row[index];
124
+ if (!cell || cell.width === 0) {
125
+ continue;
126
+ }
127
+ if (cell.char !== " " && cell.char !== "") {
128
+ return index + 1;
129
+ }
130
+ if (cell.fg !== undefined ||
131
+ cell.bg !== undefined ||
132
+ cell.fgMode !== undefined ||
133
+ cell.bgMode !== undefined ||
134
+ cell.bold ||
135
+ cell.italic ||
136
+ cell.underline ||
137
+ cell.dim ||
138
+ cell.inverse ||
139
+ cell.strikethrough) {
140
+ return index + 1;
141
+ }
142
+ }
143
+ return 0;
144
+ }
145
+ function getTerminalStyle(cell) {
146
+ return {
147
+ fg: cell.fg,
148
+ bg: cell.bg,
149
+ fgMode: cell.fgMode,
150
+ bgMode: cell.bgMode,
151
+ bold: Boolean(cell.bold),
152
+ italic: Boolean(cell.italic),
153
+ underline: Boolean(cell.underline),
154
+ dim: Boolean(cell.dim),
155
+ inverse: Boolean(cell.inverse),
156
+ strikethrough: Boolean(cell.strikethrough),
157
+ };
158
+ }
159
+ function terminalStylesEqual(left, right) {
160
+ return (left.fg === right.fg &&
161
+ left.bg === right.bg &&
162
+ left.fgMode === right.fgMode &&
163
+ left.bgMode === right.bgMode &&
164
+ left.bold === right.bold &&
165
+ left.italic === right.italic &&
166
+ left.underline === right.underline &&
167
+ left.dim === right.dim &&
168
+ left.inverse === right.inverse &&
169
+ left.strikethrough === right.strikethrough);
170
+ }
171
+ function styleToAnsi(style) {
172
+ const codes = ["0"];
173
+ if (style.bold) {
174
+ codes.push("1");
175
+ }
176
+ if (style.dim) {
177
+ codes.push("2");
178
+ }
179
+ if (style.italic) {
180
+ codes.push("3");
181
+ }
182
+ if (style.underline) {
183
+ codes.push("4");
184
+ }
185
+ if (style.inverse) {
186
+ codes.push("7");
187
+ }
188
+ if (style.strikethrough) {
189
+ codes.push("9");
190
+ }
191
+ if (style.fg !== undefined && style.fgMode !== undefined) {
192
+ codes.push(...colorToSgr(style.fgMode, style.fg, false));
193
+ }
194
+ if (style.bg !== undefined && style.bgMode !== undefined) {
195
+ codes.push(...colorToSgr(style.bgMode, style.bg, true));
196
+ }
197
+ return `\u001b[${codes.join(";")}m`;
198
+ }
199
+ function colorToSgr(mode, value, background) {
200
+ if (mode === 1) {
201
+ if (value >= 8) {
202
+ return [String((background ? 100 : 90) + (value - 8))];
203
+ }
204
+ return [String((background ? 40 : 30) + value)];
205
+ }
206
+ if (mode === 2) {
207
+ return [background ? "48" : "38", "5", String(value)];
208
+ }
209
+ if (mode === 3) {
210
+ return [
211
+ background ? "48" : "38",
212
+ "2",
213
+ String((value >> 16) & 0xff),
214
+ String((value >> 8) & 0xff),
215
+ String(value & 0xff),
216
+ ];
217
+ }
218
+ return [];
219
+ }
220
+ //# sourceMappingURL=terminal-snapshot.js.map
@@ -0,0 +1,2 @@
1
+ export * from "./binary-frames/terminal.js";
2
+ //# sourceMappingURL=terminal-stream-protocol.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "./binary-frames/terminal.js";
2
+ //# sourceMappingURL=terminal-stream-protocol.js.map
@@ -0,0 +1,2 @@
1
+ export declare function terminalSubscriptionKey(cwd: string, workspaceId: string | undefined): string;
2
+ //# sourceMappingURL=terminal-subscription-key.d.ts.map
@@ -0,0 +1,9 @@
1
+ // A terminal directory subscription is scoped to a (cwd, workspaceId) pair, not
2
+ // cwd alone: under Model B two workspaces can share a cwd, and each must track
3
+ // and tear down its own live subscription without disturbing the other. An
4
+ // absent workspaceId (old clients) keys to the cwd on its own. The `::`
5
+ // separator cannot collide with a workspace id, which is always `wks_<hex>`.
6
+ export function terminalSubscriptionKey(cwd, workspaceId) {
7
+ return workspaceId === undefined ? cwd : `${workspaceId}::${cwd}`;
8
+ }
9
+ //# sourceMappingURL=terminal-subscription-key.js.map
@@ -0,0 +1,3 @@
1
+ import type { AgentTimelineItem } from "./agent-types.js";
2
+ export declare function timelineItemIdentity(item: AgentTimelineItem): string | null;
3
+ //# sourceMappingURL=timeline-identity.d.ts.map
@@ -0,0 +1,8 @@
1
+ export function timelineItemIdentity(item) {
2
+ if (item.type === "tool_call")
3
+ return item.callId;
4
+ if (item.type === "plugin")
5
+ return `${item.pluginId}/${item.id}`;
6
+ return null;
7
+ }
8
+ //# sourceMappingURL=timeline-identity.js.map
@@ -0,0 +1,13 @@
1
+ import type { ToolCallTimelineItem } from "./agent-types.js";
2
+ export type ToolCallDisplayInput = Pick<ToolCallTimelineItem, "name" | "status" | "error" | "metadata" | "detail" | "agentMessage"> & {
3
+ cwd?: string;
4
+ /** Title of the agent a Mateo call targets, when the caller knows it. */
5
+ targetAgentTitle?: string;
6
+ };
7
+ export interface ToolCallDisplayModel {
8
+ displayName: string;
9
+ summary?: string;
10
+ errorText?: string;
11
+ }
12
+ export declare function buildToolCallDisplayModel(input: ToolCallDisplayInput): ToolCallDisplayModel;
13
+ //# sourceMappingURL=tool-call-display.d.ts.map
@@ -0,0 +1,144 @@
1
+ import { buildAgentMessageDisplay, buildMateoToolDisplay, } from "./mateo-tool-presentation/index.js";
2
+ import { stripCwdPrefix } from "./path-utils.js";
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5
+ }
6
+ function readString(value) {
7
+ return typeof value === "string" && value.length > 0 ? value : undefined;
8
+ }
9
+ function humanizeToolName(name) {
10
+ const trimmed = name.trim();
11
+ if (!trimmed) {
12
+ return name;
13
+ }
14
+ if (/[:./]/.test(trimmed) || trimmed.includes("__")) {
15
+ return trimmed;
16
+ }
17
+ return trimmed
18
+ .replace(/[._-]+/g, " ")
19
+ .split(" ")
20
+ .filter((segment) => segment.length > 0)
21
+ .join(" ")
22
+ .toLowerCase()
23
+ .replace(/^./, (character) => character.toUpperCase());
24
+ }
25
+ function formatErrorText(error) {
26
+ if (error === null || error === undefined) {
27
+ return undefined;
28
+ }
29
+ if (typeof error === "string") {
30
+ return error;
31
+ }
32
+ if (isRecord(error) && typeof error.content === "string") {
33
+ return error.content;
34
+ }
35
+ try {
36
+ return JSON.stringify(error, null, 2);
37
+ }
38
+ catch {
39
+ return String(error);
40
+ }
41
+ }
42
+ function buildFilePathDisplay(displayName, filePath, cwd) {
43
+ return {
44
+ displayName,
45
+ summary: stripCwdPrefix(filePath, cwd),
46
+ };
47
+ }
48
+ function buildCanonicalDetailDisplay(input) {
49
+ switch (input.detail.type) {
50
+ case "shell":
51
+ return {
52
+ displayName: "Shell",
53
+ summary: input.detail.command,
54
+ };
55
+ case "read":
56
+ return buildFilePathDisplay("Read", input.detail.filePath, input.cwd);
57
+ case "edit":
58
+ return buildFilePathDisplay("Edit", input.detail.filePath, input.cwd);
59
+ case "write":
60
+ return buildFilePathDisplay("Write", input.detail.filePath, input.cwd);
61
+ case "search":
62
+ return {
63
+ displayName: "Search",
64
+ summary: input.detail.query,
65
+ };
66
+ case "fetch":
67
+ return {
68
+ displayName: "Fetch",
69
+ summary: input.detail.url,
70
+ };
71
+ case "worktree_setup":
72
+ return {
73
+ displayName: "Worktree setup",
74
+ summary: input.detail.branchName,
75
+ };
76
+ case "sub_agent":
77
+ return {
78
+ displayName: readString(input.detail.subAgentType) ?? "Task",
79
+ summary: readString(input.detail.description),
80
+ };
81
+ case "plain_text":
82
+ return {
83
+ summary: input.detail.label,
84
+ };
85
+ case "plan":
86
+ return {
87
+ displayName: "Plan",
88
+ };
89
+ case "unknown":
90
+ return {};
91
+ default:
92
+ throw new Error("unreachable");
93
+ }
94
+ }
95
+ function buildUnknownDetailOverride(input) {
96
+ const lowerName = input.name.trim().toLowerCase();
97
+ if (input.detail.type === "unknown" && lowerName === "task") {
98
+ return {
99
+ displayName: "Task",
100
+ summary: isRecord(input.metadata) ? readString(input.metadata.subAgentActivity) : undefined,
101
+ };
102
+ }
103
+ if (input.detail.type === "unknown" && lowerName === "thinking") {
104
+ return {
105
+ displayName: "Thinking",
106
+ };
107
+ }
108
+ if (lowerName === "terminal") {
109
+ return {
110
+ displayName: "Terminal",
111
+ summary: input.detail.type === "plain_text" ? readString(input.detail.label) : undefined,
112
+ };
113
+ }
114
+ return {};
115
+ }
116
+ export function buildToolCallDisplayModel(input) {
117
+ const errorText = input.status === "failed" ? formatErrorText(input.error) : undefined;
118
+ const mateoDisplay = input.agentMessage
119
+ ? buildAgentMessageDisplay(input.agentMessage)
120
+ : buildMateoToolDisplay({
121
+ toolName: input.name,
122
+ detail: input.detail,
123
+ targetAgentTitle: input.targetAgentTitle,
124
+ });
125
+ if (mateoDisplay) {
126
+ return {
127
+ displayName: mateoDisplay.displayName,
128
+ ...(mateoDisplay.summary ? { summary: mateoDisplay.summary } : {}),
129
+ ...(errorText ? { errorText } : {}),
130
+ };
131
+ }
132
+ const canonicalDisplay = buildCanonicalDetailDisplay(input);
133
+ const unknownDetailOverride = buildUnknownDetailOverride(input);
134
+ const displayName = unknownDetailOverride.displayName ??
135
+ canonicalDisplay.displayName ??
136
+ humanizeToolName(input.name);
137
+ const summary = unknownDetailOverride.summary ?? canonicalDisplay.summary;
138
+ return {
139
+ displayName,
140
+ ...(summary ? { summary } : {}),
141
+ ...(errorText ? { errorText } : {}),
142
+ };
143
+ }
144
+ //# sourceMappingURL=tool-call-display.js.map
@@ -0,0 +1,9 @@
1
+ export declare function normalizeToolName(name: string): string;
2
+ export declare function tokenizeToolName(name: string): string[];
3
+ export declare function getToolLeafName(name: string): string | null;
4
+ export declare function isSpeakToolName(name: string): boolean;
5
+ export declare function isLikelyNamespacedToolName(name: string): boolean;
6
+ export declare function isMateoToolName(name: string): boolean;
7
+ export declare function getMateoToolLeafName(name: string): string | null;
8
+ export declare function isLikelyExternalToolName(name: string): boolean;
9
+ //# sourceMappingURL=tool-name-normalization.d.ts.map
@@ -0,0 +1,82 @@
1
+ const TOOL_TOKEN_REGEX = /[a-z0-9]+/g;
2
+ const STANDARD_NAMESPACE_SEPARATOR_REGEX = /[.:/]/;
3
+ export function normalizeToolName(name) {
4
+ return name.trim().toLowerCase();
5
+ }
6
+ export function tokenizeToolName(name) {
7
+ const normalized = normalizeToolName(name);
8
+ return normalized.match(TOOL_TOKEN_REGEX) ?? [];
9
+ }
10
+ export function getToolLeafName(name) {
11
+ const tokens = tokenizeToolName(name);
12
+ return tokens.length > 0 ? tokens[tokens.length - 1] : null;
13
+ }
14
+ export function isSpeakToolName(name) {
15
+ return getToolLeafName(name) === "speak";
16
+ }
17
+ export function isLikelyNamespacedToolName(name) {
18
+ const normalized = normalizeToolName(name);
19
+ if (STANDARD_NAMESPACE_SEPARATOR_REGEX.test(normalized)) {
20
+ return true;
21
+ }
22
+ if (!normalized.includes("__")) {
23
+ return false;
24
+ }
25
+ // Keep `__` handling strict to avoid false positives on arbitrary custom names.
26
+ const segments = normalized.split("__").filter((segment) => segment.length > 0);
27
+ if (segments.length >= 3) {
28
+ return true;
29
+ }
30
+ if (segments.length === 2 && segments[1].includes("_")) {
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+ export function isMateoToolName(name) {
36
+ const normalized = normalizeToolName(name);
37
+ if (isSpeakToolName(normalized)) {
38
+ return false;
39
+ }
40
+ if (normalized.includes("__")) {
41
+ const segments = normalized.split("__").filter((s) => s.length > 0);
42
+ return (segments.length >= 3 &&
43
+ segments[0] === "mcp" &&
44
+ (segments[1] === "mateo" || segments[1].startsWith("mateo_")));
45
+ }
46
+ if (normalized.includes(".")) {
47
+ const firstSegment = normalized.split(".")[0];
48
+ return firstSegment === "mateo" || firstSegment.startsWith("mateo_");
49
+ }
50
+ return false;
51
+ }
52
+ export function getMateoToolLeafName(name) {
53
+ const normalized = normalizeToolName(name);
54
+ if (normalized.includes("__")) {
55
+ const segments = normalized.split("__").filter((s) => s.length > 0);
56
+ if (segments.length >= 3 &&
57
+ segments[0] === "mcp" &&
58
+ (segments[1] === "mateo" || segments[1].startsWith("mateo_"))) {
59
+ return segments.slice(2).join("__");
60
+ }
61
+ return null;
62
+ }
63
+ if (normalized.includes(".")) {
64
+ const firstSegment = normalized.split(".")[0];
65
+ if (firstSegment === "mateo" || firstSegment.startsWith("mateo_")) {
66
+ return normalized.split(".").slice(1).join(".");
67
+ }
68
+ return null;
69
+ }
70
+ return null;
71
+ }
72
+ export function isLikelyExternalToolName(name) {
73
+ const normalized = normalizeToolName(name);
74
+ if (!normalized) {
75
+ return false;
76
+ }
77
+ if (isSpeakToolName(normalized)) {
78
+ return true;
79
+ }
80
+ return isLikelyNamespacedToolName(normalized);
81
+ }
82
+ //# sourceMappingURL=tool-name-normalization.js.map
@@ -0,0 +1,26 @@
1
+ /** Browser and operating system product names read from a browser's user agent. */
2
+ export interface UserAgentSummary {
3
+ browser?: string;
4
+ os?: string;
5
+ osVersion?: string;
6
+ }
7
+ /** The subset of `navigator.userAgentData` Chromium browsers expose without a permission. */
8
+ export interface UserAgentClientHints {
9
+ brands?: readonly {
10
+ brand: string;
11
+ version: string;
12
+ }[];
13
+ platform?: string;
14
+ mobile?: boolean;
15
+ }
16
+ /**
17
+ * Names the browser and operating system behind a user agent, e.g. Chrome on macOS. Prefers
18
+ * client hints, which name Edge and Opera even where the user agent string is frozen, and never
19
+ * probes `window.chrome`, which headless Chrome and some embedded views omit.
20
+ */
21
+ export declare function parseUserAgent(input: {
22
+ userAgent: string;
23
+ hints?: UserAgentClientHints | null;
24
+ maxTouchPoints?: number;
25
+ }): UserAgentSummary;
26
+ //# sourceMappingURL=user-agent.d.ts.map
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Product tokens in match order. Chromium derivatives append their own token after "Chrome/",
3
+ * so they come first; Safari is last because every WebKit and Blink browser says "Safari/".
4
+ * Headless Chrome reports "HeadlessChrome/" and is still Chrome.
5
+ */
6
+ const BROWSER_TOKENS = [
7
+ [/\bEdg(?:e|A|iOS)?\//, "Edge"],
8
+ [/\bOPR\/|\bOPiOS\//, "Opera"],
9
+ [/\bSamsungBrowser\//, "Samsung Internet"],
10
+ [/\bVivaldi\//, "Vivaldi"],
11
+ [/\bYaBrowser\//, "Yandex"],
12
+ [/\bFirefox\/|\bFxiOS\//, "Firefox"],
13
+ [/\bElectron\//, "Electron"],
14
+ [/\bCriOS\/|\b(?:Headless)?Chrome\/|\bChromium\//, "Chrome"],
15
+ [/\bVersion\/[\d.]+.*\bSafari\//, "Safari"],
16
+ ];
17
+ const CLIENT_HINT_BRANDS = {
18
+ "Microsoft Edge": "Edge",
19
+ Opera: "Opera",
20
+ Vivaldi: "Vivaldi",
21
+ Yandex: "Yandex",
22
+ "Google Chrome": "Chrome",
23
+ Chromium: "Chrome",
24
+ };
25
+ const CLIENT_HINT_PLATFORMS = {
26
+ macOS: "macOS",
27
+ Windows: "Windows",
28
+ Linux: "Linux",
29
+ "Chrome OS": "ChromeOS",
30
+ ChromeOS: "ChromeOS",
31
+ Android: "Android",
32
+ iOS: "iOS",
33
+ };
34
+ function underscoredVersion(raw) {
35
+ if (!raw)
36
+ return undefined;
37
+ const version = raw.replaceAll("_", ".");
38
+ return version.replace(/\.0$/, "") || undefined;
39
+ }
40
+ function parseOs(userAgent, touchPoints) {
41
+ const ios = userAgent.match(/\b(iPhone|iPad|iPod)\b.*?\bOS (\d+(?:_\d+)*)/);
42
+ if (ios) {
43
+ const os = ios[1] === "iPad" ? "iPadOS" : "iOS";
44
+ return { os, osVersion: underscoredVersion(ios[2]) };
45
+ }
46
+ const android = userAgent.match(/\bAndroid(?: (\d+(?:\.\d+)*))?/);
47
+ if (android)
48
+ return { os: "Android", ...(android[1] ? { osVersion: android[1] } : {}) };
49
+ if (/\bCrOS\b/.test(userAgent))
50
+ return { os: "ChromeOS" };
51
+ const mac = userAgent.match(/\bMac OS X(?: (\d+(?:[._]\d+)*))?/);
52
+ if (mac) {
53
+ // iPadOS 13+ asks for desktop sites and reports a Mac; only a touch screen tells them apart.
54
+ if (touchPoints > 1)
55
+ return { os: "iPadOS" };
56
+ // Browsers freeze the reported macOS version at 10.15.7, so it says nothing about the host.
57
+ return { os: "macOS" };
58
+ }
59
+ const windows = userAgent.match(/\bWindows NT (\d+\.\d+)/);
60
+ if (windows) {
61
+ // Windows 11 still reports NT 10.0; only client hints can tell, so name no version.
62
+ const legacy = { "6.1": "7", "6.2": "8", "6.3": "8.1" };
63
+ const version = legacy[windows[1] ?? ""];
64
+ return { os: "Windows", ...(version ? { osVersion: version } : {}) };
65
+ }
66
+ if (/\bWindows\b/.test(userAgent))
67
+ return { os: "Windows" };
68
+ if (/\bLinux\b|\bX11\b/.test(userAgent))
69
+ return { os: "Linux" };
70
+ return {};
71
+ }
72
+ /**
73
+ * Names the browser and operating system behind a user agent, e.g. Chrome on macOS. Prefers
74
+ * client hints, which name Edge and Opera even where the user agent string is frozen, and never
75
+ * probes `window.chrome`, which headless Chrome and some embedded views omit.
76
+ */
77
+ export function parseUserAgent(input) {
78
+ const userAgent = input.userAgent;
79
+ const summary = parseOs(userAgent, input.maxTouchPoints ?? 0);
80
+ const hintPlatform = input.hints?.platform ? CLIENT_HINT_PLATFORMS[input.hints.platform] : null;
81
+ if (hintPlatform && hintPlatform !== summary.os) {
82
+ summary.os = hintPlatform;
83
+ delete summary.osVersion;
84
+ }
85
+ for (const [pattern, browser] of BROWSER_TOKENS) {
86
+ if (pattern.test(userAgent)) {
87
+ summary.browser = browser;
88
+ break;
89
+ }
90
+ }
91
+ for (const { brand } of input.hints?.brands ?? []) {
92
+ const browser = CLIENT_HINT_BRANDS[brand];
93
+ if (!browser)
94
+ continue;
95
+ summary.browser = browser;
96
+ if (browser !== "Chrome")
97
+ break;
98
+ }
99
+ return summary;
100
+ }
101
+ //# sourceMappingURL=user-agent.js.map