@sixb/app 0.2.3 → 0.2.5

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 (329) hide show
  1. package/assets/connector-icons/README.md +1 -0
  2. package/assets/connector-icons/ctm.png +0 -0
  3. package/dist/agent/activity-label.d.ts.map +1 -1
  4. package/dist/agent/agent-chat.d.ts +3 -1
  5. package/dist/agent/agent-chat.d.ts.map +1 -1
  6. package/dist/agent/agent-panel.d.ts.map +1 -1
  7. package/dist/agent/artifact-panel.d.ts +3 -1
  8. package/dist/agent/artifact-panel.d.ts.map +1 -1
  9. package/dist/agent/background/background-tool-row.d.ts.map +1 -1
  10. package/dist/agent/background/interpret.d.ts +1 -1
  11. package/dist/agent/background/interpret.d.ts.map +1 -1
  12. package/dist/agent/components/composer-settings.d.ts +1 -1
  13. package/dist/agent/components/composer-settings.d.ts.map +1 -1
  14. package/dist/agent/components/composer.d.ts +22 -5
  15. package/dist/agent/components/composer.d.ts.map +1 -1
  16. package/dist/agent/components/context-meter.d.ts +1 -1
  17. package/dist/agent/components/context-meter.d.ts.map +1 -1
  18. package/dist/agent/components/conversation-panel.d.ts +8 -2
  19. package/dist/agent/components/conversation-panel.d.ts.map +1 -1
  20. package/dist/agent/components/message-parts.d.ts +2 -1
  21. package/dist/agent/components/message-parts.d.ts.map +1 -1
  22. package/dist/agent/components/message-view.d.ts.map +1 -1
  23. package/dist/agent/components/pending-messages.d.ts +20 -0
  24. package/dist/agent/components/pending-messages.d.ts.map +1 -0
  25. package/dist/agent/components/sandbox-recovery.d.ts +11 -2
  26. package/dist/agent/components/sandbox-recovery.d.ts.map +1 -1
  27. package/dist/agent/components/threads-button.d.ts +1 -1
  28. package/dist/agent/components/threads-button.d.ts.map +1 -1
  29. package/dist/agent/components/transcript.d.ts +5 -0
  30. package/dist/agent/components/transcript.d.ts.map +1 -1
  31. package/dist/agent/conversation.d.ts +3 -6
  32. package/dist/agent/conversation.d.ts.map +1 -1
  33. package/dist/agent/delegation/agent-exchange.d.ts +16 -0
  34. package/dist/agent/delegation/agent-exchange.d.ts.map +1 -0
  35. package/dist/agent/delegation/child-card.d.ts +3 -3
  36. package/dist/agent/delegation/child-card.d.ts.map +1 -1
  37. package/dist/agent/delegation/child-parts.d.ts +1 -10
  38. package/dist/agent/delegation/child-parts.d.ts.map +1 -1
  39. package/dist/agent/delegation/child-work.d.ts.map +1 -1
  40. package/dist/agent/delegation/interpret.d.ts +9 -10
  41. package/dist/agent/delegation/interpret.d.ts.map +1 -1
  42. package/dist/agent/delegation/use-children.d.ts.map +1 -1
  43. package/dist/agent/file-edits/file-edit-tool-view.d.ts +10 -0
  44. package/dist/agent/file-edits/file-edit-tool-view.d.ts.map +1 -0
  45. package/dist/agent/file-edits/interpret.d.ts +25 -0
  46. package/dist/agent/file-edits/interpret.d.ts.map +1 -0
  47. package/dist/agent/hooks/use-agent-conversation.d.ts +16 -4
  48. package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
  49. package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -1
  50. package/dist/agent/hooks/use-thread-stream.d.ts.map +1 -1
  51. package/dist/agent/i18n/en.d.ts +114 -5
  52. package/dist/agent/i18n/en.d.ts.map +1 -1
  53. package/dist/agent/i18n/fr.d.ts.map +1 -1
  54. package/dist/agent/i18n/index.d.ts +190 -8
  55. package/dist/agent/i18n/index.d.ts.map +1 -1
  56. package/dist/agent/inbox-handoff.d.ts +10 -0
  57. package/dist/agent/inbox-handoff.d.ts.map +1 -0
  58. package/dist/agent/live-run.d.ts +8 -1
  59. package/dist/agent/live-run.d.ts.map +1 -1
  60. package/dist/agent/message-agent/interpret.d.ts +2 -2
  61. package/dist/agent/message-agent/interpret.d.ts.map +1 -1
  62. package/dist/agent/publish-artifact/interpret.d.ts +1 -1
  63. package/dist/agent/publish-artifact/interpret.d.ts.map +1 -1
  64. package/dist/agent/questions/interpret.d.ts +31 -0
  65. package/dist/agent/questions/interpret.d.ts.map +1 -0
  66. package/dist/agent/questions/question-card.d.ts +16 -0
  67. package/dist/agent/questions/question-card.d.ts.map +1 -0
  68. package/dist/agent/questions/question-composer.d.ts +15 -0
  69. package/dist/agent/questions/question-composer.d.ts.map +1 -0
  70. package/dist/agent/read/interpret.d.ts +8 -1
  71. package/dist/agent/read/interpret.d.ts.map +1 -1
  72. package/dist/agent/read/read-tool-view.d.ts.map +1 -1
  73. package/dist/agent/search/interpret.d.ts +101 -0
  74. package/dist/agent/search/interpret.d.ts.map +1 -0
  75. package/dist/agent/search/search-tool-view.d.ts +10 -0
  76. package/dist/agent/search/search-tool-view.d.ts.map +1 -0
  77. package/dist/agent/thread-state.d.ts +26 -0
  78. package/dist/agent/thread-state.d.ts.map +1 -0
  79. package/dist/agent/tool-views/built-in.d.ts.map +1 -1
  80. package/dist/agent/tool-views/registry.d.ts +5 -6
  81. package/dist/agent/tool-views/registry.d.ts.map +1 -1
  82. package/dist/agent/types.d.ts +5 -1
  83. package/dist/agent/types.d.ts.map +1 -1
  84. package/dist/agent/view-file/view-file-tool-view.d.ts +2 -1
  85. package/dist/agent/view-file/view-file-tool-view.d.ts.map +1 -1
  86. package/dist/agent/waits.d.ts +14 -0
  87. package/dist/agent/waits.d.ts.map +1 -0
  88. package/dist/artifacts/card-preview.d.ts.map +1 -1
  89. package/dist/artifacts/edit-session.d.ts +11 -1
  90. package/dist/artifacts/edit-session.d.ts.map +1 -1
  91. package/dist/artifacts/editor/block-handle.d.ts +20 -0
  92. package/dist/artifacts/editor/block-handle.d.ts.map +1 -0
  93. package/dist/artifacts/editor/blocks.d.ts +34 -0
  94. package/dist/artifacts/editor/blocks.d.ts.map +1 -0
  95. package/dist/artifacts/editor/callout-view.d.ts +7 -0
  96. package/dist/artifacts/editor/callout-view.d.ts.map +1 -0
  97. package/dist/artifacts/editor/document-editor.d.ts +30 -0
  98. package/dist/artifacts/editor/document-editor.d.ts.map +1 -0
  99. package/dist/artifacts/editor/figure-view.d.ts +12 -0
  100. package/dist/artifacts/editor/figure-view.d.ts.map +1 -0
  101. package/dist/artifacts/editor/find-blocks.d.ts +6 -0
  102. package/dist/artifacts/editor/find-blocks.d.ts.map +1 -0
  103. package/dist/artifacts/editor/markdown-document.d.ts +12 -0
  104. package/dist/artifacts/editor/markdown-document.d.ts.map +1 -0
  105. package/dist/artifacts/editor/messages.d.ts +4 -0
  106. package/dist/artifacts/editor/messages.d.ts.map +1 -0
  107. package/dist/artifacts/editor/schema.d.ts +21 -0
  108. package/dist/artifacts/editor/schema.d.ts.map +1 -0
  109. package/dist/artifacts/editor/selection-toolbar.d.ts +35 -0
  110. package/dist/artifacts/editor/selection-toolbar.d.ts.map +1 -0
  111. package/dist/artifacts/editor/slash-menu.d.ts +43 -0
  112. package/dist/artifacts/editor/slash-menu.d.ts.map +1 -0
  113. package/dist/artifacts/editor/upload.d.ts +12 -0
  114. package/dist/artifacts/editor/upload.d.ts.map +1 -0
  115. package/dist/artifacts/file-source.d.ts +5 -0
  116. package/dist/artifacts/file-source.d.ts.map +1 -1
  117. package/dist/artifacts/frame-editor/bundle.d.ts +7 -0
  118. package/dist/artifacts/frame-editor/bundle.d.ts.map +1 -0
  119. package/dist/artifacts/frame-editor/commands.d.ts +93 -0
  120. package/dist/artifacts/frame-editor/commands.d.ts.map +1 -0
  121. package/dist/artifacts/frame-editor/entry.d.ts +2 -0
  122. package/dist/artifacts/frame-editor/entry.d.ts.map +1 -0
  123. package/dist/artifacts/frame-editor/frame.d.ts +5 -0
  124. package/dist/artifacts/frame-editor/frame.d.ts.map +1 -0
  125. package/dist/artifacts/frame-editor/keys.d.ts +8 -0
  126. package/dist/artifacts/frame-editor/keys.d.ts.map +1 -0
  127. package/dist/artifacts/frame-editor/protocol.d.ts +186 -0
  128. package/dist/artifacts/frame-editor/protocol.d.ts.map +1 -0
  129. package/dist/artifacts/frame-editor/schema.d.ts +34 -0
  130. package/dist/artifacts/frame-editor/schema.d.ts.map +1 -0
  131. package/dist/artifacts/frame-editor/style.d.ts +2 -0
  132. package/dist/artifacts/frame-editor/style.d.ts.map +1 -0
  133. package/dist/artifacts/frame.d.ts +2 -2
  134. package/dist/artifacts/frame.d.ts.map +1 -1
  135. package/dist/artifacts/live/boards.d.ts +2 -0
  136. package/dist/artifacts/live/boards.d.ts.map +1 -1
  137. package/dist/artifacts/live/document.d.ts +32 -0
  138. package/dist/artifacts/live/document.d.ts.map +1 -0
  139. package/dist/artifacts/live/header.d.ts +4 -4
  140. package/dist/artifacts/live/header.d.ts.map +1 -1
  141. package/dist/artifacts/live/presence.d.ts.map +1 -1
  142. package/dist/artifacts/live/session.d.ts +2 -0
  143. package/dist/artifacts/live/session.d.ts.map +1 -1
  144. package/dist/artifacts/live/view.d.ts +4 -3
  145. package/dist/artifacts/live/view.d.ts.map +1 -1
  146. package/dist/artifacts/messages.d.ts +278 -2
  147. package/dist/artifacts/messages.d.ts.map +1 -1
  148. package/dist/artifacts/pdf.d.ts +8 -0
  149. package/dist/artifacts/pdf.d.ts.map +1 -0
  150. package/dist/artifacts/queries.d.ts +80 -0
  151. package/dist/artifacts/queries.d.ts.map +1 -1
  152. package/dist/artifacts/references/references.d.ts +3 -3
  153. package/dist/artifacts/references/references.d.ts.map +1 -1
  154. package/dist/artifacts/renderers/canvas/board-editor.d.ts +11 -4
  155. package/dist/artifacts/renderers/canvas/board-editor.d.ts.map +1 -1
  156. package/dist/artifacts/renderers/canvas/board.d.ts +14 -2
  157. package/dist/artifacts/renderers/canvas/board.d.ts.map +1 -1
  158. package/dist/artifacts/renderers/canvas/canvas.d.ts +4 -3
  159. package/dist/artifacts/renderers/canvas/canvas.d.ts.map +1 -1
  160. package/dist/artifacts/renderers/canvas/comment-pins.d.ts +4 -2
  161. package/dist/artifacts/renderers/canvas/comment-pins.d.ts.map +1 -1
  162. package/dist/artifacts/renderers/canvas/comments-panel.d.ts.map +1 -1
  163. package/dist/artifacts/renderers/canvas/comments.d.ts +2 -1
  164. package/dist/artifacts/renderers/canvas/comments.d.ts.map +1 -1
  165. package/dist/artifacts/renderers/canvas/controls.d.ts +15 -4
  166. package/dist/artifacts/renderers/canvas/controls.d.ts.map +1 -1
  167. package/dist/artifacts/renderers/canvas/focus.d.ts +19 -5
  168. package/dist/artifacts/renderers/canvas/focus.d.ts.map +1 -1
  169. package/dist/artifacts/renderers/canvas/gestures.d.ts +46 -0
  170. package/dist/artifacts/renderers/canvas/gestures.d.ts.map +1 -0
  171. package/dist/artifacts/renderers/canvas/page-resize.d.ts +21 -0
  172. package/dist/artifacts/renderers/canvas/page-resize.d.ts.map +1 -0
  173. package/dist/artifacts/renderers/canvas/page-size-controls.d.ts +21 -0
  174. package/dist/artifacts/renderers/canvas/page-size-controls.d.ts.map +1 -0
  175. package/dist/artifacts/renderers/canvas/page-size.d.ts +93 -0
  176. package/dist/artifacts/renderers/canvas/page-size.d.ts.map +1 -0
  177. package/dist/artifacts/renderers/canvas/page-zoom.d.ts +64 -0
  178. package/dist/artifacts/renderers/canvas/page-zoom.d.ts.map +1 -0
  179. package/dist/artifacts/renderers/canvas/shown-size.d.ts +26 -0
  180. package/dist/artifacts/renderers/canvas/shown-size.d.ts.map +1 -0
  181. package/dist/artifacts/renderers/designed-document.d.ts +28 -0
  182. package/dist/artifacts/renderers/designed-document.d.ts.map +1 -0
  183. package/dist/artifacts/renderers/document-tree.d.ts +2 -0
  184. package/dist/artifacts/renderers/document-tree.d.ts.map +1 -1
  185. package/dist/artifacts/renderers/document.d.ts +9 -1
  186. package/dist/artifacts/renderers/document.d.ts.map +1 -1
  187. package/dist/artifacts/renderers/live-frame.d.ts +145 -0
  188. package/dist/artifacts/renderers/live-frame.d.ts.map +1 -0
  189. package/dist/artifacts/renderers/page-editor.d.ts +16 -0
  190. package/dist/artifacts/renderers/page-editor.d.ts.map +1 -0
  191. package/dist/artifacts/renderers/page.d.ts +10 -1
  192. package/dist/artifacts/renderers/page.d.ts.map +1 -1
  193. package/dist/artifacts/viewer.d.ts.map +1 -1
  194. package/dist/{chunk-001c4gnk.js → chunk-4fex83k2.js} +19965 -13027
  195. package/dist/chunk-4fex83k2.js.map +239 -0
  196. package/dist/{chunk-5crvhjp2.js → chunk-4wm09prf.js} +1633 -1999
  197. package/dist/chunk-4wm09prf.js.map +27 -0
  198. package/dist/{chunk-fwb9mxwm.js → chunk-5sgac68y.js} +1 -1
  199. package/dist/{chunk-kes4ygmz.js → chunk-69qgh20f.js} +1 -1
  200. package/dist/chunk-y51c4tsz.js +11 -0
  201. package/dist/chunk-y51c4tsz.js.map +10 -0
  202. package/dist/index.d.ts +4 -1
  203. package/dist/index.d.ts.map +1 -1
  204. package/dist/index.js +13 -6
  205. package/dist/index.js.map +5 -5
  206. package/dist/pages/console/data/messages.d.ts +6 -0
  207. package/dist/pages/console/data/messages.d.ts.map +1 -1
  208. package/dist/pages/console/data/shared.d.ts.map +1 -1
  209. package/dist/pages.js +12 -5
  210. package/dist/pages.js.map +6 -6
  211. package/dist/shell/search-command.d.ts.map +1 -1
  212. package/package.json +22 -5
  213. package/src/agent/activity-label.ts +9 -1
  214. package/src/agent/agent-chat.tsx +57 -37
  215. package/src/agent/agent-execution-trace.tsx +2 -2
  216. package/src/agent/agent-panel.tsx +6 -4
  217. package/src/agent/agent.css +254 -0
  218. package/src/agent/artifact-panel.tsx +77 -22
  219. package/src/agent/background/background-tool-row.tsx +24 -10
  220. package/src/agent/background/interpret.ts +60 -51
  221. package/src/agent/components/composer-settings.tsx +20 -10
  222. package/src/agent/components/composer.tsx +342 -104
  223. package/src/agent/components/context-meter.tsx +7 -3
  224. package/src/agent/components/conversation-panel.tsx +96 -37
  225. package/src/agent/components/message-parts.tsx +390 -64
  226. package/src/agent/components/message-view.tsx +12 -2
  227. package/src/agent/components/pending-messages.tsx +338 -0
  228. package/src/agent/components/sandbox-recovery.tsx +36 -17
  229. package/src/agent/components/threads-button.tsx +3 -2
  230. package/src/agent/components/transcript.tsx +92 -45
  231. package/src/agent/conversation.ts +203 -54
  232. package/src/agent/delegation/agent-exchange.tsx +53 -0
  233. package/src/agent/delegation/child-card.tsx +6 -40
  234. package/src/agent/delegation/child-parts.tsx +1 -84
  235. package/src/agent/delegation/child-work.tsx +19 -5
  236. package/src/agent/delegation/interpret.ts +64 -61
  237. package/src/agent/delegation/model.ts +1 -1
  238. package/src/agent/file-edits/file-edit-tool-view.tsx +126 -0
  239. package/src/agent/file-edits/interpret.ts +120 -0
  240. package/src/agent/hooks/use-agent-conversation.ts +360 -92
  241. package/src/agent/hooks/use-thread-stream.ts +10 -0
  242. package/src/agent/i18n/en.ts +134 -16
  243. package/src/agent/i18n/fr.ts +122 -16
  244. package/src/agent/inbox-handoff.ts +47 -0
  245. package/src/agent/live-run.ts +23 -2
  246. package/src/agent/message-agent/interpret.ts +4 -3
  247. package/src/agent/publish-artifact/interpret.ts +14 -5
  248. package/src/agent/publish-artifact/publish-artifact-tool-view.tsx +2 -2
  249. package/src/agent/questions/interpret.ts +90 -0
  250. package/src/agent/questions/question-card.tsx +57 -0
  251. package/src/agent/questions/question-composer.tsx +257 -0
  252. package/src/agent/react-router.tsx +2 -2
  253. package/src/agent/read/interpret.ts +34 -1
  254. package/src/agent/read/read-tool-view.tsx +20 -4
  255. package/src/agent/search/interpret.ts +367 -0
  256. package/src/agent/search/search-tool-view.tsx +235 -0
  257. package/src/agent/thread-state.ts +114 -0
  258. package/src/agent/tool-views/built-in.tsx +33 -6
  259. package/src/agent/tool-views/registry.tsx +28 -2
  260. package/src/agent/types.ts +7 -0
  261. package/src/agent/view-file/view-file-tool-view.tsx +33 -19
  262. package/src/agent/waits.ts +50 -0
  263. package/src/artifacts/artifacts.css +434 -0
  264. package/src/artifacts/card-preview.tsx +6 -1
  265. package/src/artifacts/edit-session.tsx +15 -1
  266. package/src/artifacts/editor/block-handle.tsx +278 -0
  267. package/src/artifacts/editor/blocks.ts +216 -0
  268. package/src/artifacts/editor/callout-view.tsx +31 -0
  269. package/src/artifacts/editor/document-editor.tsx +484 -0
  270. package/src/artifacts/editor/figure-view.tsx +66 -0
  271. package/src/artifacts/editor/find-blocks.ts +19 -0
  272. package/src/artifacts/editor/markdown-document.tsx +72 -0
  273. package/src/artifacts/editor/messages.ts +4 -0
  274. package/src/artifacts/editor/schema.ts +159 -0
  275. package/src/artifacts/editor/selection-toolbar.tsx +364 -0
  276. package/src/artifacts/editor/slash-menu.tsx +251 -0
  277. package/src/artifacts/editor/upload.ts +40 -0
  278. package/src/artifacts/file-source.ts +11 -0
  279. package/src/artifacts/frame-editor/bundle.ts +8 -0
  280. package/src/artifacts/frame-editor/commands.ts +565 -0
  281. package/src/artifacts/frame-editor/entry.ts +6 -0
  282. package/src/artifacts/frame-editor/frame.ts +847 -0
  283. package/src/artifacts/frame-editor/generated/editor.txt +149 -0
  284. package/src/artifacts/frame-editor/generated.d.ts +5 -0
  285. package/src/artifacts/frame-editor/keys.ts +323 -0
  286. package/src/artifacts/frame-editor/protocol.ts +151 -0
  287. package/src/artifacts/frame-editor/schema.ts +293 -0
  288. package/src/artifacts/frame-editor/style.ts +58 -0
  289. package/src/artifacts/frame.tsx +14 -5
  290. package/src/artifacts/live/boards.ts +46 -3
  291. package/src/artifacts/live/document.ts +89 -0
  292. package/src/artifacts/live/header.tsx +9 -14
  293. package/src/artifacts/live/presence.ts +5 -1
  294. package/src/artifacts/live/session.ts +4 -2
  295. package/src/artifacts/live/view.ts +14 -8
  296. package/src/artifacts/messages.ts +192 -2
  297. package/src/artifacts/pdf.ts +50 -0
  298. package/src/artifacts/references/references.tsx +46 -11
  299. package/src/artifacts/renderers/canvas/board-editor.tsx +44 -155
  300. package/src/artifacts/renderers/canvas/board.tsx +70 -8
  301. package/src/artifacts/renderers/canvas/canvas.tsx +66 -15
  302. package/src/artifacts/renderers/canvas/comment-pins.tsx +5 -0
  303. package/src/artifacts/renderers/canvas/comments-panel.tsx +58 -1
  304. package/src/artifacts/renderers/canvas/comments.ts +8 -4
  305. package/src/artifacts/renderers/canvas/controls.tsx +64 -30
  306. package/src/artifacts/renderers/canvas/focus.tsx +200 -56
  307. package/src/artifacts/renderers/canvas/gestures.ts +265 -0
  308. package/src/artifacts/renderers/canvas/page-resize.tsx +542 -0
  309. package/src/artifacts/renderers/canvas/page-size-controls.tsx +193 -0
  310. package/src/artifacts/renderers/canvas/page-size.ts +218 -0
  311. package/src/artifacts/renderers/canvas/page-zoom.ts +280 -0
  312. package/src/artifacts/renderers/canvas/shown-size.ts +105 -0
  313. package/src/artifacts/renderers/designed-document.tsx +277 -0
  314. package/src/artifacts/renderers/document-tree.ts +9 -0
  315. package/src/artifacts/renderers/document.tsx +13 -102
  316. package/src/artifacts/renderers/live-frame.ts +163 -0
  317. package/src/artifacts/renderers/page-editor.tsx +613 -0
  318. package/src/artifacts/renderers/page.tsx +21 -4
  319. package/src/artifacts/viewer.tsx +101 -41
  320. package/src/index.ts +8 -0
  321. package/src/pages/console/data/messages.ts +6 -0
  322. package/src/pages/console/data/projections.tsx +4 -0
  323. package/src/pages/console/data/shared.tsx +1 -0
  324. package/src/pages/console/ontology/lineage/trail.tsx +3 -0
  325. package/src/shell/search-command.tsx +2 -0
  326. package/dist/chunk-001c4gnk.js.map +0 -204
  327. package/dist/chunk-5crvhjp2.js.map +0 -28
  328. /package/dist/{chunk-fwb9mxwm.js.map → chunk-5sgac68y.js.map} +0 -0
  329. /package/dist/{chunk-kes4ygmz.js.map → chunk-69qgh20f.js.map} +0 -0
@@ -0,0 +1,367 @@
1
+ import { humanize } from "../bash/interpret"
2
+ import { type AgentMessages, en } from "../i18n/en"
3
+ import { memoryFile } from "../memory-paths"
4
+ import type { NormalizedTool } from "../parts"
5
+
6
+ /** What `glob` stores: the files whose path matched, sorted. */
7
+ export interface GlobOutput {
8
+ readonly files: readonly string[]
9
+ /** More files match than the ones listed. */
10
+ readonly truncated: boolean
11
+ /** The search stopped at its deadline. */
12
+ readonly incomplete: boolean
13
+ }
14
+
15
+ export interface GrepMatch {
16
+ readonly path: string
17
+ readonly line: number
18
+ readonly text: string
19
+ }
20
+
21
+ /** What `grep` stores: the matching lines, grouped by file in order. */
22
+ export interface GrepOutput {
23
+ readonly matches: readonly GrepMatch[]
24
+ /** How many files the matches are in. */
25
+ readonly files: number
26
+ /** Matching lines past the ones a file shows, by path. */
27
+ readonly more: Readonly<Record<string, number>>
28
+ /** Another file matches past the lines shown. */
29
+ readonly truncated: boolean
30
+ /** The search stopped at its deadline. */
31
+ readonly incomplete: boolean
32
+ }
33
+
34
+ /**
35
+ * Where a search looked, as the chat names it: the Agent's memory, its guides and its ontology
36
+ * read as themselves, as `read` names their files; anywhere else is files.
37
+ */
38
+ export type SearchPlace =
39
+ | { readonly kind: "files" }
40
+ | { readonly kind: "memory"; readonly project: boolean }
41
+ | { readonly kind: "guide"; readonly name: string }
42
+ | { readonly kind: "ontology" }
43
+
44
+ export interface SearchDescription {
45
+ readonly place: SearchPlace
46
+ readonly title: string
47
+ readonly runningTitle: string
48
+ readonly failedTitle: string
49
+ /** What came of it, once it has a result: `8 matches in 3 files`. */
50
+ readonly detail?: string
51
+ /** The pattern as the call wrote it, or empty until it streams in. */
52
+ readonly pattern: string
53
+ /** The folder or file it looked in, as the call named it; absent for the working folder. */
54
+ readonly path?: string
55
+ /** The files `grep` was limited to. */
56
+ readonly include?: string
57
+ /** What the results leave out, in plain words. */
58
+ readonly notes: readonly string[]
59
+ }
60
+
61
+ export interface GlobDescription extends SearchDescription {
62
+ /** Relative to the folder searched, which the header names. */
63
+ readonly files: readonly string[]
64
+ }
65
+
66
+ /** The matches of one file, in the order `grep` found them. */
67
+ export interface GrepGroup {
68
+ /** Relative to the folder searched, which the header names. */
69
+ readonly path: string
70
+ readonly matches: readonly Omit<GrepMatch, "path">[]
71
+ /** Matching lines past the ones shown. */
72
+ readonly more: number
73
+ }
74
+
75
+ export interface GrepDescription extends SearchDescription {
76
+ readonly groups: readonly GrepGroup[]
77
+ /** The search as a regular expression, to mark where each line first matched. */
78
+ readonly highlight?: RegExp
79
+ }
80
+
81
+ /** One run of a line's text: what the search matched, or what surrounds it. */
82
+ export interface LineSegment {
83
+ readonly text: string
84
+ readonly match: boolean
85
+ }
86
+
87
+ export function coerceGlobOutput(value: unknown): GlobOutput | null {
88
+ if (
89
+ !isRecord(value) ||
90
+ !Array.isArray(value.files) ||
91
+ !value.files.every((file) => typeof file === "string") ||
92
+ typeof value.truncated !== "boolean"
93
+ ) {
94
+ return null
95
+ }
96
+ return { files: value.files, truncated: value.truncated, incomplete: value.incomplete === true }
97
+ }
98
+
99
+ export function coerceGrepOutput(value: unknown): GrepOutput | null {
100
+ if (
101
+ !isRecord(value) ||
102
+ !Array.isArray(value.matches) ||
103
+ !value.matches.every(isGrepMatch) ||
104
+ typeof value.files !== "number" ||
105
+ typeof value.truncated !== "boolean"
106
+ ) {
107
+ return null
108
+ }
109
+
110
+ const more = isRecord(value.more)
111
+ ? Object.fromEntries(
112
+ Object.entries(value.more).filter(
113
+ (entry): entry is [string, number] => typeof entry[1] === "number"
114
+ )
115
+ )
116
+ : {}
117
+
118
+ return {
119
+ matches: value.matches,
120
+ files: value.files,
121
+ more,
122
+ truncated: value.truncated,
123
+ incomplete: value.incomplete === true,
124
+ }
125
+ }
126
+
127
+ /** A search for files by name: `Found 12 files`, or where it looked when that has a name. */
128
+ export function describeGlob(
129
+ tool: Pick<NormalizedTool, "input" | "output">,
130
+ messages: AgentMessages = en
131
+ ): GlobDescription {
132
+ const m = messages.search
133
+ const call = searchCall(tool.input)
134
+ const output = coerceGlobOutput(tool.output)
135
+ const place = searchPlace(call.path)
136
+ const named = placeTitles(place, m)
137
+
138
+ const files = output?.files ?? []
139
+ const shown = output?.truncated ? m.moreFiles(files.length) : m.files(files.length)
140
+
141
+ const title = named
142
+ ? named.title
143
+ : !output
144
+ ? m.looked
145
+ : output.truncated
146
+ ? m.foundMore(files.length)
147
+ : m.found(files.length)
148
+
149
+ return {
150
+ ...call,
151
+ place,
152
+ title,
153
+ runningTitle: named?.running ?? m.looking,
154
+ failedTitle: named?.failed ?? m.lookFailed,
155
+ ...(named && output ? { detail: shown } : {}),
156
+ notes: [
157
+ ...(output?.truncated ? [m.truncatedFiles(files.length)] : []),
158
+ ...(output?.incomplete ? [m.incomplete] : []),
159
+ ],
160
+ files: files.map((file) => underSearched(file, call.path)),
161
+ }
162
+ }
163
+
164
+ /**
165
+ * A search for text: `Searched for “retries” · 8 matches in 3 files`. The pattern names the step
166
+ * only when it reads as words; a regular expression stays behind the disclosure.
167
+ */
168
+ export function describeGrep(
169
+ tool: Pick<NormalizedTool, "input" | "output">,
170
+ messages: AgentMessages = en
171
+ ): GrepDescription {
172
+ const m = messages.search
173
+ const call = searchCall(tool.input)
174
+ const literal = isRecord(tool.input) && tool.input.literal === true
175
+ const output = coerceGrepOutput(tool.output)
176
+ const place = searchPlace(call.path)
177
+ const named = placeTitles(place, m)
178
+ const term = plainTerm(call.pattern, literal)
179
+
180
+ const extra = Object.values(output?.more ?? {}).reduce((sum, count) => sum + count, 0)
181
+ const total = (output?.matches.length ?? 0) + extra
182
+ const found = !output
183
+ ? undefined
184
+ : total === 0
185
+ ? m.noMatches
186
+ : output.truncated
187
+ ? m.moreMatches(total)
188
+ : m.matches(total, output.files)
189
+
190
+ const detail = named && term && found ? `${m.term(term)} · ${found}` : found
191
+ const highlight = searchRegex(call.pattern, literal)
192
+
193
+ return {
194
+ ...call,
195
+ place,
196
+ title: named?.title ?? (term ? m.searchedFor(term) : m.searched),
197
+ runningTitle: named?.running ?? m.searching,
198
+ failedTitle: named?.failed ?? m.searchFailed(term),
199
+ ...(detail ? { detail } : {}),
200
+ notes: [
201
+ ...(output?.truncated ? [m.truncatedMatches(output.matches.length)] : []),
202
+ ...(output?.incomplete ? [m.incomplete] : []),
203
+ ],
204
+ groups: output ? grepGroups(output, call.path) : [],
205
+ ...(highlight ? { highlight } : {}),
206
+ }
207
+ }
208
+
209
+ /**
210
+ * A line cut where the search first matched it, so the match can be marked. Only the first: it is
211
+ * the work the search did on the line and finished, while matching on through the rest of the line
212
+ * can backtrack without end on a pattern such as `(a|a)+b`, and again on every render.
213
+ */
214
+ export function highlightLine(text: string, regex: RegExp | undefined): LineSegment[] {
215
+ const found = regex && text ? regex.exec(text) : null
216
+
217
+ // An empty match, as `^` or `x*` gives, marks nothing.
218
+ if (!found || found[0].length === 0) return [{ text, match: false }]
219
+
220
+ const start = found.index
221
+ const end = start + found[0].length
222
+ return [
223
+ ...(start > 0 ? [{ text: text.slice(0, start), match: false }] : []),
224
+ { text: text.slice(start, end), match: true },
225
+ ...(end < text.length ? [{ text: text.slice(end), match: false }] : []),
226
+ ]
227
+ }
228
+
229
+ /** A path's folder and its name, so the name can stand out. */
230
+ export function splitPath(path: string): { readonly folder: string; readonly name: string } {
231
+ const cut = path.lastIndexOf("/", path.length - 2)
232
+ return cut < 0
233
+ ? { folder: "", name: path }
234
+ : { folder: path.slice(0, cut + 1), name: path.slice(cut + 1) }
235
+ }
236
+
237
+ function searchCall(input: unknown): Pick<SearchDescription, "pattern" | "path" | "include"> {
238
+ const record = isRecord(input) ? input : {}
239
+ const pattern = typeof record.pattern === "string" ? record.pattern : ""
240
+ const path = givenString(record.path)
241
+ const include = givenString(record.include)
242
+ return {
243
+ pattern,
244
+ ...(path === undefined || path === "." || path === "./" ? {} : { path }),
245
+ ...(include === undefined ? {} : { include }),
246
+ }
247
+ }
248
+
249
+ /** A string the call gave: models send `"null"` and `"undefined"` for nothing, as the tools read. */
250
+ function givenString(value: unknown): string | undefined {
251
+ if (typeof value !== "string") return undefined
252
+ const trimmed = value.trim()
253
+ return trimmed === "" || trimmed === "null" || trimmed === "undefined" ? undefined : trimmed
254
+ }
255
+
256
+ function searchPlace(path: string | undefined): SearchPlace {
257
+ if (!path) return { kind: "files" }
258
+
259
+ const memory = memoryFile(path)
260
+ if (memory) return { kind: "memory", project: memory.repo === "project" }
261
+
262
+ const skill = path.match(/(?:^|\/)\.sixb\/agent\/skills(?:\/([^/]+))?/)
263
+ if (skill)
264
+ return { kind: "guide", name: skill[1] ? humanize(skill[1].replace(/^sixb-/, "")) : "" }
265
+
266
+ if (/(?:^|\/)\.sixb\/agent\/ontology(?:\/|$)/.test(path)) return { kind: "ontology" }
267
+ return { kind: "files" }
268
+ }
269
+
270
+ function placeTitles(
271
+ place: SearchPlace,
272
+ m: AgentMessages["search"]
273
+ ): { readonly title: string; readonly running: string; readonly failed: string } | null {
274
+ switch (place.kind) {
275
+ case "memory":
276
+ return {
277
+ title: m.memory.title(place.project),
278
+ running: m.memory.running(place.project),
279
+ failed: m.memory.failed(place.project),
280
+ }
281
+ case "guide":
282
+ return {
283
+ title: m.guide.title(place.name),
284
+ running: m.guide.running(place.name),
285
+ failed: m.guide.failed(place.name),
286
+ }
287
+ case "ontology":
288
+ return { title: m.ontology.title, running: m.ontology.running, failed: m.ontology.failed }
289
+ default:
290
+ return null
291
+ }
292
+ }
293
+
294
+ const TERM_MAX = 40
295
+
296
+ /**
297
+ * The pattern as words, when it reads as them: literal text, or a pattern with no regular
298
+ * expression syntax past escaped punctuation. A lone `.` stays, as people write it.
299
+ */
300
+ function plainTerm(pattern: string, literal: boolean): string | undefined {
301
+ const unescaped = literal ? pattern : pattern.replace(/\\([^A-Za-z0-9])/g, "$1")
302
+ if (!literal && /[\\^$*+?()[\]{}|]/.test(pattern.replace(/\\[^A-Za-z0-9]/g, ""))) {
303
+ return undefined
304
+ }
305
+
306
+ const term = unescaped.replace(/\s+/g, " ").trim()
307
+ if (!term) return undefined
308
+ return term.length > TERM_MAX ? `${term.slice(0, TERM_MAX - 1).trimEnd()}…` : term
309
+ }
310
+
311
+ /** The regular expression `grep` ran, case included, global to find every match of a line. */
312
+ function searchRegex(pattern: string, literal: boolean): RegExp | undefined {
313
+ if (!pattern) return undefined
314
+
315
+ const source = literal ? pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : pattern
316
+ const written = literal ? pattern : pattern.replace(/\\(?:[pP]\{[^}]*\}|.)/g, "")
317
+ // Not global: a line is matched once, as the search matched it.
318
+ const flags = /\p{Lu}/u.test(written) ? "" : "i"
319
+
320
+ for (const unicode of ["u", ""]) {
321
+ try {
322
+ return new RegExp(source, `${flags}${unicode}`)
323
+ } catch {}
324
+ }
325
+ return undefined
326
+ }
327
+
328
+ function grepGroups(output: GrepOutput, searched: string | undefined): GrepGroup[] {
329
+ const groups: { path: string; matches: Omit<GrepMatch, "path">[]; more: number }[] = []
330
+ for (const { path: found, line, text } of output.matches) {
331
+ const path = underSearched(found, searched)
332
+ const last = groups.at(-1)
333
+ if (last?.path === path) {
334
+ last.matches.push({ line, text })
335
+ } else {
336
+ groups.push({ path, matches: [{ line, text }], more: output.more[found] ?? 0 })
337
+ }
338
+ }
339
+ return groups
340
+ }
341
+
342
+ /**
343
+ * A path a search found, as it reads under the search's header: relative to the folder searched,
344
+ * which the header names once, so `.sixb/agent/ontology/` is not said before every file.
345
+ */
346
+ function underSearched(path: string, searched: string | undefined): string {
347
+ const folder = searched?.replace(/^(?:\.\/)+/, "").replace(/\/+$/, "")
348
+ if (!folder) return path
349
+
350
+ // The search names its matches by their real path: `/var/…` is `/private/var/…` on a Mac.
351
+ const prefixes = folder.startsWith("/") ? [folder, `/private${folder}`] : [folder]
352
+ const prefix = prefixes.find((candidate) => path.startsWith(`${candidate}/`))
353
+ return prefix ? path.slice(prefix.length + 1) : path
354
+ }
355
+
356
+ function isGrepMatch(value: unknown): value is GrepMatch {
357
+ return (
358
+ isRecord(value) &&
359
+ typeof value.path === "string" &&
360
+ typeof value.line === "number" &&
361
+ typeof value.text === "string"
362
+ )
363
+ }
364
+
365
+ function isRecord(value: unknown): value is Record<string, unknown> {
366
+ return typeof value === "object" && value !== null && !Array.isArray(value)
367
+ }
@@ -0,0 +1,235 @@
1
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@sixb/ui/components"
2
+ import {
3
+ Bookmark,
4
+ BookOpen,
5
+ Boxes,
6
+ ChevronRight,
7
+ FolderSearch,
8
+ type LucideIcon,
9
+ TextSearch,
10
+ } from "lucide-react"
11
+ import type { ReactNode } from "react"
12
+ import { ActivityStatusText } from "../components/activity-status"
13
+ import { useAgentMessages } from "../i18n"
14
+ import type { NormalizedTool } from "../parts"
15
+ import {
16
+ describeGlob,
17
+ describeGrep,
18
+ type GrepGroup,
19
+ highlightLine,
20
+ type SearchDescription,
21
+ type SearchPlace,
22
+ splitPath,
23
+ } from "./interpret"
24
+
25
+ /** Files the agent found by name: `Found 12 files`, opening to the list. */
26
+ export function GlobToolView({ tool }: { tool: NormalizedTool }) {
27
+ const messages = useAgentMessages()
28
+ const description = describeGlob(tool, messages)
29
+ return (
30
+ <SearchRow
31
+ tool={tool}
32
+ description={description}
33
+ icon={placeIcon(description.place, FolderSearch)}
34
+ >
35
+ {description.files.length > 0 ? (
36
+ <ResultBlock>
37
+ {description.files.map((path) => (
38
+ <div key={path} className="min-w-max px-2.5">
39
+ <PathText path={path} />
40
+ </div>
41
+ ))}
42
+ </ResultBlock>
43
+ ) : (
44
+ <p className="text-muted-foreground/60">{messages.search.noFiles}</p>
45
+ )}
46
+ </SearchRow>
47
+ )
48
+ }
49
+
50
+ /** Text the agent searched for: `Searched for “retries” · 8 matches in 3 files`, opening to them. */
51
+ export function GrepToolView({ tool }: { tool: NormalizedTool }) {
52
+ const messages = useAgentMessages()
53
+ const description = describeGrep(tool, messages)
54
+ return (
55
+ <SearchRow
56
+ tool={tool}
57
+ description={description}
58
+ icon={placeIcon(description.place, TextSearch)}
59
+ >
60
+ {description.groups.length > 0 ? (
61
+ <ResultBlock>
62
+ {description.groups.map((group) => (
63
+ <MatchGroup
64
+ key={group.path}
65
+ group={group}
66
+ highlight={description.highlight}
67
+ more={messages.search.moreInFile(group.more)}
68
+ />
69
+ ))}
70
+ </ResultBlock>
71
+ ) : (
72
+ <p className="text-muted-foreground/60">{messages.search.noLines}</p>
73
+ )}
74
+ </SearchRow>
75
+ )
76
+ }
77
+
78
+ function placeIcon(place: SearchPlace, files: LucideIcon): LucideIcon {
79
+ switch (place.kind) {
80
+ case "memory":
81
+ return Bookmark
82
+ case "guide":
83
+ return BookOpen
84
+ case "ontology":
85
+ return Boxes
86
+ default:
87
+ return files
88
+ }
89
+ }
90
+
91
+ /**
92
+ * The step as one quiet line, as `read` shows; open, what the search was, then what it found, and
93
+ * what that leaves out.
94
+ */
95
+ function SearchRow({
96
+ tool,
97
+ description,
98
+ icon: Icon,
99
+ children,
100
+ }: {
101
+ tool: NormalizedTool
102
+ description: SearchDescription
103
+ icon: LucideIcon
104
+ children: ReactNode
105
+ }) {
106
+ const messages = useAgentMessages()
107
+ const running = tool.state === "input-streaming" || tool.state === "input-available"
108
+ const error = tool.state === "output-error"
109
+
110
+ if (running) {
111
+ return (
112
+ <div className="flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground">
113
+ <Icon className="size-3.5 shrink-0" />
114
+ <ActivityStatusText label={description.runningTitle} className="font-medium shimmer" />
115
+ </div>
116
+ )
117
+ }
118
+
119
+ const label = error ? description.failedTitle : description.title
120
+ const query = [
121
+ description.pattern,
122
+ description.include,
123
+ description.path ? messages.search.in(description.path) : undefined,
124
+ ].filter(Boolean)
125
+
126
+ return (
127
+ <Collapsible>
128
+ <CollapsibleTrigger className="group flex w-fit max-w-full items-center gap-1.5 text-[13px] leading-normal text-muted-foreground transition-colors hover:text-foreground">
129
+ <Icon className="size-3.5 shrink-0" />
130
+ {/* On a narrow screen the detail gives way first, so the step keeps its name: the name
131
+ shrinks only past the room the icon and the chevron leave. */}
132
+ <span className="max-w-[calc(100%-2.5rem)] shrink-0 truncate font-medium">{label}</span>
133
+ {description.detail && !error ? (
134
+ <span className="min-w-0 shrink truncate text-muted-foreground/60">
135
+ {description.detail}
136
+ </span>
137
+ ) : null}
138
+ <ChevronRight className="size-3.5 shrink-0 opacity-0 transition-all group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[state=open]:rotate-90 group-data-[state=open]:opacity-100" />
139
+ </CollapsibleTrigger>
140
+ <CollapsibleContent>
141
+ <div className="mt-3 min-w-0 space-y-2 text-xs">
142
+ {query.length > 0 ? (
143
+ <p className="truncate font-mono text-[10px] text-muted-foreground/60">
144
+ {query.join(" · ")}
145
+ </p>
146
+ ) : null}
147
+ {error ? (
148
+ <pre className="scrollbar-thin max-h-60 overflow-auto rounded bg-muted/50 p-2 text-[11px] leading-relaxed whitespace-pre-wrap text-foreground">
149
+ {tool.errorText?.trim() || messages.search.error}
150
+ </pre>
151
+ ) : (
152
+ children
153
+ )}
154
+ {error
155
+ ? null
156
+ : description.notes.map((note) => (
157
+ <p key={note} className="text-muted-foreground/60">
158
+ {note}
159
+ </p>
160
+ ))}
161
+ </div>
162
+ </CollapsibleContent>
163
+ </Collapsible>
164
+ )
165
+ }
166
+
167
+ function ResultBlock({ children }: { children: ReactNode }) {
168
+ return (
169
+ <div className="scrollbar-thin max-h-60 overflow-auto rounded bg-muted/50 py-1.5 font-mono text-[11px] leading-relaxed">
170
+ {children}
171
+ </div>
172
+ )
173
+ }
174
+
175
+ /** A path with its folder quiet, so the file's name is what the eye finds. */
176
+ function PathText({ path }: { path: string }) {
177
+ const { folder, name } = splitPath(path)
178
+ return (
179
+ <>
180
+ {folder ? <span className="text-muted-foreground/70">{folder}</span> : null}
181
+ <span className="text-foreground">{name}</span>
182
+ </>
183
+ )
184
+ }
185
+
186
+ function MatchGroup({
187
+ group,
188
+ highlight,
189
+ more,
190
+ }: {
191
+ group: GrepGroup
192
+ highlight: RegExp | undefined
193
+ more: string
194
+ }) {
195
+ // Every number of the file takes the width of the longest, so the lines start in one column.
196
+ const width = `${String(Math.max(...group.matches.map((match) => match.line))).length}ch`
197
+ return (
198
+ <div className="pb-1.5 last:pb-0">
199
+ <div className="min-w-max px-2.5 font-medium">
200
+ <PathText path={group.path} />
201
+ </div>
202
+ {group.matches.map((match) => (
203
+ <div key={match.line} className="flex min-w-max gap-3 px-2.5">
204
+ <span
205
+ className="shrink-0 select-none text-right text-muted-foreground/50 tabular-nums"
206
+ style={{ width }}
207
+ >
208
+ {match.line}
209
+ </span>
210
+ <span className="whitespace-pre text-foreground/80">
211
+ {highlightLine(match.text, highlight).map((segment, index) =>
212
+ segment.match ? (
213
+ // Runs of one line never reorder: the index is their identity.
214
+ <mark
215
+ key={index}
216
+ className="rounded-[3px] bg-amber-400/30 text-foreground dark:bg-amber-300/25"
217
+ >
218
+ {segment.text}
219
+ </mark>
220
+ ) : (
221
+ <span key={index}>{segment.text}</span>
222
+ )
223
+ )}
224
+ </span>
225
+ </div>
226
+ ))}
227
+ {group.more > 0 ? (
228
+ <div className="min-w-max px-2.5 text-muted-foreground/60 italic">
229
+ <span className="inline-block select-none" style={{ width, marginRight: "0.75rem" }} />
230
+ {more}
231
+ </div>
232
+ ) : null}
233
+ </div>
234
+ )
235
+ }