@kortix/sdk 0.13.29 → 0.13.31

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 (257) hide show
  1. package/README.md +9 -1
  2. package/dist/browser/stores/sync-store/delta-event-window.d.ts +10 -0
  3. package/dist/browser/stores/sync-store/delta-event-window.d.ts.map +1 -0
  4. package/dist/browser/stores/sync-store/delta-event-window.js +10 -0
  5. package/dist/browser/stores/sync-store/delta-event-window.js.map +1 -0
  6. package/dist/browser/stores/sync-store.d.ts.map +1 -1
  7. package/dist/browser/stores/sync-store.js +48 -5
  8. package/dist/browser/stores/sync-store.js.map +1 -1
  9. package/dist/core/client/kortix.d.ts +5 -0
  10. package/dist/core/client/kortix.d.ts.map +1 -1
  11. package/dist/core/client/kortix.js +3 -0
  12. package/dist/core/client/kortix.js.map +1 -1
  13. package/dist/core/http/api-client.d.ts.map +1 -1
  14. package/dist/core/http/api-client.js +26 -1
  15. package/dist/core/http/api-client.js.map +1 -1
  16. package/dist/core/rest/platform-client/host-boundary.d.ts +25 -7
  17. package/dist/core/rest/platform-client/host-boundary.d.ts.map +1 -1
  18. package/dist/core/rest/platform-client/host-boundary.js.map +1 -1
  19. package/dist/core/rest/projects-client/accounts.d.ts +5 -0
  20. package/dist/core/rest/projects-client/accounts.d.ts.map +1 -1
  21. package/dist/core/rest/projects-client/accounts.js.map +1 -1
  22. package/dist/core/rest/projects-client/agent-config.d.ts +8 -0
  23. package/dist/core/rest/projects-client/agent-config.d.ts.map +1 -1
  24. package/dist/core/rest/projects-client/agent-config.js.map +1 -1
  25. package/dist/core/rest/projects-client/apps.d.ts +14 -0
  26. package/dist/core/rest/projects-client/apps.d.ts.map +1 -1
  27. package/dist/core/rest/projects-client/apps.js +4 -0
  28. package/dist/core/rest/projects-client/apps.js.map +1 -1
  29. package/dist/core/rest/projects-client/audit.d.ts +9 -3
  30. package/dist/core/rest/projects-client/audit.d.ts.map +1 -1
  31. package/dist/core/rest/projects-client/audit.js.map +1 -1
  32. package/dist/core/rest/projects-client/connectors.d.ts +31 -0
  33. package/dist/core/rest/projects-client/connectors.d.ts.map +1 -1
  34. package/dist/core/rest/projects-client/connectors.js +15 -0
  35. package/dist/core/rest/projects-client/connectors.js.map +1 -1
  36. package/dist/core/rest/projects-client/gateway.d.ts +4 -8
  37. package/dist/core/rest/projects-client/gateway.d.ts.map +1 -1
  38. package/dist/core/rest/projects-client/gateway.js.map +1 -1
  39. package/dist/core/rest/projects-client/iam.d.ts +2 -2
  40. package/dist/core/rest/projects-client/iam.d.ts.map +1 -1
  41. package/dist/core/rest/projects-client/index.d.ts +1 -0
  42. package/dist/core/rest/projects-client/index.d.ts.map +1 -1
  43. package/dist/core/rest/projects-client/index.js +1 -0
  44. package/dist/core/rest/projects-client/index.js.map +1 -1
  45. package/dist/core/rest/projects-client/projects.d.ts +15 -1
  46. package/dist/core/rest/projects-client/projects.d.ts.map +1 -1
  47. package/dist/core/rest/projects-client/projects.js +1 -0
  48. package/dist/core/rest/projects-client/projects.js.map +1 -1
  49. package/dist/core/rest/projects-client/review-items.d.ts +173 -0
  50. package/dist/core/rest/projects-client/review-items.d.ts.map +1 -0
  51. package/dist/core/rest/projects-client/review-items.js +260 -0
  52. package/dist/core/rest/projects-client/review-items.js.map +1 -0
  53. package/dist/core/rest/projects-client/session-attachments.d.ts +37 -0
  54. package/dist/core/rest/projects-client/session-attachments.d.ts.map +1 -1
  55. package/dist/core/rest/projects-client/session-attachments.js +134 -0
  56. package/dist/core/rest/projects-client/session-attachments.js.map +1 -1
  57. package/dist/core/rest/projects-client/session-costs.d.ts +7 -9
  58. package/dist/core/rest/projects-client/session-costs.d.ts.map +1 -1
  59. package/dist/core/rest/projects-client/session-costs.js.map +1 -1
  60. package/dist/core/runtime/attachment-part.d.ts +1 -1
  61. package/dist/core/runtime/attachment-part.js +1 -1
  62. package/dist/core/session/connection.d.ts +1 -1
  63. package/dist/core/session/project-session-read.d.ts +24 -0
  64. package/dist/core/session/project-session-read.d.ts.map +1 -0
  65. package/dist/core/session/project-session-read.js +29 -0
  66. package/dist/core/session/project-session-read.js.map +1 -0
  67. package/dist/core/session/single-flight.d.ts +20 -0
  68. package/dist/core/session/single-flight.d.ts.map +1 -0
  69. package/dist/core/session/single-flight.js +39 -0
  70. package/dist/core/session/single-flight.js.map +1 -0
  71. package/dist/core/session/wake-escalation.d.ts +2 -2
  72. package/dist/core/session/wake-escalation.js +2 -2
  73. package/dist/core/session/wire-message-id.d.ts +73 -0
  74. package/dist/core/session/wire-message-id.d.ts.map +1 -0
  75. package/dist/core/session/wire-message-id.js +120 -0
  76. package/dist/core/session/wire-message-id.js.map +1 -0
  77. package/dist/core/session/working.d.ts +2 -2
  78. package/dist/core/session-sync/session-sync-controller.d.ts +1 -1
  79. package/dist/core/session-sync/session-sync-controller.js +2 -2
  80. package/dist/core/turns/grouping.d.ts.map +1 -1
  81. package/dist/core/turns/grouping.js +46 -2
  82. package/dist/core/turns/grouping.js.map +1 -1
  83. package/dist/core/turns/index.d.ts +3 -0
  84. package/dist/core/turns/index.d.ts.map +1 -1
  85. package/dist/core/turns/index.js +2 -0
  86. package/dist/core/turns/index.js.map +1 -1
  87. package/dist/core/turns/segments/burst-summary.d.ts +49 -0
  88. package/dist/core/turns/segments/burst-summary.d.ts.map +1 -0
  89. package/dist/core/turns/segments/burst-summary.js +64 -0
  90. package/dist/core/turns/segments/burst-summary.js.map +1 -0
  91. package/dist/core/turns/segments/compaction-state.d.ts +44 -0
  92. package/dist/core/turns/segments/compaction-state.d.ts.map +1 -0
  93. package/dist/core/turns/segments/compaction-state.js +79 -0
  94. package/dist/core/turns/segments/compaction-state.js.map +1 -0
  95. package/dist/core/turns/segments/group-steps.d.ts +22 -0
  96. package/dist/core/turns/segments/group-steps.d.ts.map +1 -0
  97. package/dist/core/turns/segments/group-steps.js +89 -0
  98. package/dist/core/turns/segments/group-steps.js.map +1 -0
  99. package/dist/core/turns/segments/index.d.ts +21 -0
  100. package/dist/core/turns/segments/index.d.ts.map +1 -0
  101. package/dist/core/turns/segments/index.js +21 -0
  102. package/dist/core/turns/segments/index.js.map +1 -0
  103. package/dist/core/turns/segments/merge-steps.d.ts +79 -0
  104. package/dist/core/turns/segments/merge-steps.d.ts.map +1 -0
  105. package/dist/core/turns/segments/merge-steps.js +190 -0
  106. package/dist/core/turns/segments/merge-steps.js.map +1 -0
  107. package/dist/core/turns/segments/message-time.d.ts +86 -0
  108. package/dist/core/turns/segments/message-time.d.ts.map +1 -0
  109. package/dist/core/turns/segments/message-time.js +196 -0
  110. package/dist/core/turns/segments/message-time.js.map +1 -0
  111. package/dist/core/turns/segments/narration.d.ts +71 -0
  112. package/dist/core/turns/segments/narration.d.ts.map +1 -0
  113. package/dist/core/turns/segments/narration.js +836 -0
  114. package/dist/core/turns/segments/narration.js.map +1 -0
  115. package/dist/core/turns/segments/segment-turn.d.ts +26 -0
  116. package/dist/core/turns/segments/segment-turn.d.ts.map +1 -0
  117. package/dist/core/turns/segments/segment-turn.js +36 -0
  118. package/dist/core/turns/segments/segment-turn.js.map +1 -0
  119. package/dist/core/turns/segments/session-activity-groups.d.ts +93 -0
  120. package/dist/core/turns/segments/session-activity-groups.d.ts.map +1 -0
  121. package/dist/core/turns/segments/session-activity-groups.js +127 -0
  122. package/dist/core/turns/segments/session-activity-groups.js.map +1 -0
  123. package/dist/core/turns/segments/step-label.d.ts +44 -0
  124. package/dist/core/turns/segments/step-label.d.ts.map +1 -0
  125. package/dist/core/turns/segments/step-label.js +129 -0
  126. package/dist/core/turns/segments/step-label.js.map +1 -0
  127. package/dist/core/turns/segments/turn-busy-visibility.d.ts +51 -0
  128. package/dist/core/turns/segments/turn-busy-visibility.d.ts.map +1 -0
  129. package/dist/core/turns/segments/turn-busy-visibility.js +47 -0
  130. package/dist/core/turns/segments/turn-busy-visibility.js.map +1 -0
  131. package/dist/core/turns/segments/working-turn.d.ts +165 -0
  132. package/dist/core/turns/segments/working-turn.d.ts.map +1 -0
  133. package/dist/core/turns/segments/working-turn.js +168 -0
  134. package/dist/core/turns/segments/working-turn.js.map +1 -0
  135. package/dist/core/turns/text-scan.d.ts +65 -0
  136. package/dist/core/turns/text-scan.d.ts.map +1 -0
  137. package/dist/core/turns/text-scan.js +344 -0
  138. package/dist/core/turns/text-scan.js.map +1 -0
  139. package/dist/core/turns/tools/agent-helpers.d.ts +10 -0
  140. package/dist/core/turns/tools/agent-helpers.d.ts.map +1 -0
  141. package/dist/core/turns/tools/agent-helpers.js +54 -0
  142. package/dist/core/turns/tools/agent-helpers.js.map +1 -0
  143. package/dist/core/turns/tools/file-verb.d.ts +81 -0
  144. package/dist/core/turns/tools/file-verb.d.ts.map +1 -0
  145. package/dist/core/turns/tools/file-verb.js +70 -0
  146. package/dist/core/turns/tools/file-verb.js.map +1 -0
  147. package/dist/core/turns/tools/index.d.ts +22 -0
  148. package/dist/core/turns/tools/index.d.ts.map +1 -0
  149. package/dist/core/turns/tools/index.js +22 -0
  150. package/dist/core/turns/tools/index.js.map +1 -0
  151. package/dist/core/turns/tools/memory-helpers.d.ts +16 -0
  152. package/dist/core/turns/tools/memory-helpers.d.ts.map +1 -0
  153. package/dist/core/turns/tools/memory-helpers.js +55 -0
  154. package/dist/core/turns/tools/memory-helpers.js.map +1 -0
  155. package/dist/core/turns/tools/patch-summary.d.ts +53 -0
  156. package/dist/core/turns/tools/patch-summary.d.ts.map +1 -0
  157. package/dist/core/turns/tools/patch-summary.js +71 -0
  158. package/dist/core/turns/tools/patch-summary.js.map +1 -0
  159. package/dist/core/turns/tools/presentation-helpers.d.ts +16 -0
  160. package/dist/core/turns/tools/presentation-helpers.d.ts.map +1 -0
  161. package/dist/core/turns/tools/presentation-helpers.js +18 -0
  162. package/dist/core/turns/tools/presentation-helpers.js.map +1 -0
  163. package/dist/core/turns/tools/question-helpers.d.ts +10 -0
  164. package/dist/core/turns/tools/question-helpers.d.ts.map +1 -0
  165. package/dist/core/turns/tools/question-helpers.js +13 -0
  166. package/dist/core/turns/tools/question-helpers.js.map +1 -0
  167. package/dist/core/turns/tools/read-helpers.d.ts +8 -0
  168. package/dist/core/turns/tools/read-helpers.d.ts.map +1 -0
  169. package/dist/core/turns/tools/read-helpers.js +25 -0
  170. package/dist/core/turns/tools/read-helpers.js.map +1 -0
  171. package/dist/core/turns/tools/search-query.d.ts +28 -0
  172. package/dist/core/turns/tools/search-query.d.ts.map +1 -0
  173. package/dist/core/turns/tools/search-query.js +137 -0
  174. package/dist/core/turns/tools/search-query.js.map +1 -0
  175. package/dist/core/turns/tools/show-availability.d.ts +53 -0
  176. package/dist/core/turns/tools/show-availability.d.ts.map +1 -0
  177. package/dist/core/turns/tools/show-availability.js +110 -0
  178. package/dist/core/turns/tools/show-availability.js.map +1 -0
  179. package/dist/core/turns/tools/skill-helpers.d.ts +35 -0
  180. package/dist/core/turns/tools/skill-helpers.d.ts.map +1 -0
  181. package/dist/core/turns/tools/skill-helpers.js +129 -0
  182. package/dist/core/turns/tools/skill-helpers.js.map +1 -0
  183. package/dist/core/turns/tools/tool-meta.d.ts +72 -0
  184. package/dist/core/turns/tools/tool-meta.d.ts.map +1 -0
  185. package/dist/core/turns/tools/tool-meta.js +174 -0
  186. package/dist/core/turns/tools/tool-meta.js.map +1 -0
  187. package/dist/core/turns/tools/tool-outcome.d.ts +78 -0
  188. package/dist/core/turns/tools/tool-outcome.d.ts.map +1 -0
  189. package/dist/core/turns/tools/tool-outcome.js +244 -0
  190. package/dist/core/turns/tools/tool-outcome.js.map +1 -0
  191. package/dist/core/turns/tools/tool-output-format.d.ts +63 -0
  192. package/dist/core/turns/tools/tool-output-format.d.ts.map +1 -0
  193. package/dist/core/turns/tools/tool-output-format.js +174 -0
  194. package/dist/core/turns/tools/tool-output-format.js.map +1 -0
  195. package/dist/core/turns/tools/web-helpers.d.ts +40 -0
  196. package/dist/core/turns/tools/web-helpers.d.ts.map +1 -0
  197. package/dist/core/turns/tools/web-helpers.js +297 -0
  198. package/dist/core/turns/tools/web-helpers.js.map +1 -0
  199. package/dist/index.d.ts +6 -0
  200. package/dist/index.d.ts.map +1 -1
  201. package/dist/index.js +5 -0
  202. package/dist/index.js.map +1 -1
  203. package/dist/kortix.esm.min.js +42 -26
  204. package/dist/kortix.global.js +42 -26
  205. package/dist/node/app-viewer.js +1 -1
  206. package/dist/platform/auth-core.d.ts +1 -1
  207. package/dist/platform/auth-core.js +1 -1
  208. package/dist/react/bedrock-invokable.d.ts +2 -2
  209. package/dist/react/bedrock-invokable.js +2 -2
  210. package/dist/react/opencode.d.ts +2 -0
  211. package/dist/react/opencode.d.ts.map +1 -1
  212. package/dist/react/opencode.js +2 -0
  213. package/dist/react/opencode.js.map +1 -1
  214. package/dist/react/prefetch-session-open.d.ts +20 -0
  215. package/dist/react/prefetch-session-open.d.ts.map +1 -0
  216. package/dist/react/prefetch-session-open.js +54 -0
  217. package/dist/react/prefetch-session-open.js.map +1 -0
  218. package/dist/react/provider-refresh.d.ts.map +1 -1
  219. package/dist/react/provider-refresh.js +24 -14
  220. package/dist/react/provider-refresh.js.map +1 -1
  221. package/dist/react/provider-selection.d.ts +4 -0
  222. package/dist/react/provider-selection.d.ts.map +1 -1
  223. package/dist/react/provider-selection.js +6 -2
  224. package/dist/react/provider-selection.js.map +1 -1
  225. package/dist/react/session-transcript-subscription.d.ts +29 -0
  226. package/dist/react/session-transcript-subscription.d.ts.map +1 -0
  227. package/dist/react/session-transcript-subscription.js +94 -0
  228. package/dist/react/session-transcript-subscription.js.map +1 -0
  229. package/dist/react/sign-in-with-kortix.d.ts +3 -3
  230. package/dist/react/use-model-store.d.ts +1 -1
  231. package/dist/react/use-model-store.js +1 -1
  232. package/dist/react/use-opencode-sessions/messages.d.ts +14 -3
  233. package/dist/react/use-opencode-sessions/messages.d.ts.map +1 -1
  234. package/dist/react/use-opencode-sessions/messages.js +92 -115
  235. package/dist/react/use-opencode-sessions/messages.js.map +1 -1
  236. package/dist/react/use-project-session.d.ts.map +1 -1
  237. package/dist/react/use-project-session.js +10 -2
  238. package/dist/react/use-project-session.js.map +1 -1
  239. package/dist/react/use-session-messages.d.ts +37 -0
  240. package/dist/react/use-session-messages.d.ts.map +1 -0
  241. package/dist/react/use-session-messages.js +83 -0
  242. package/dist/react/use-session-messages.js.map +1 -0
  243. package/dist/react/use-session-prompts.d.ts.map +1 -1
  244. package/dist/react/use-session-prompts.js +11 -2
  245. package/dist/react/use-session-prompts.js.map +1 -1
  246. package/dist/react/use-session-sync.d.ts +9 -0
  247. package/dist/react/use-session-sync.d.ts.map +1 -1
  248. package/dist/react/use-session-sync.js +6 -2
  249. package/dist/react/use-session-sync.js.map +1 -1
  250. package/dist/react/use-session-working.d.ts.map +1 -1
  251. package/dist/react/use-session-working.js +20 -10
  252. package/dist/react/use-session-working.js.map +1 -1
  253. package/dist/react/use-session.d.ts +18 -0
  254. package/dist/react/use-session.d.ts.map +1 -1
  255. package/dist/react/use-session.js +9 -1
  256. package/dist/react/use-session.js.map +1 -1
  257. package/package.json +2 -2
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Availability gating for `show` tool cards.
3
+ *
4
+ * A `show` tool call points at an artifact — a generated file, an image, a
5
+ * rendered iframe preview, etc. Artifacts get renamed, regenerated, or deleted
6
+ * as a session progresses, so a `show` from earlier in the run can end up
7
+ * pointing at something that no longer loads (a 404'd file, an unhealthy
8
+ * preview). Rather than render a broken "File not found" card for these dead
9
+ * references, the renderer hides them entirely and only keeps the `show` cards
10
+ * whose content actually loaded.
11
+ *
12
+ * This module holds the pure decision used by `ShowTool`, kept separate so it
13
+ * can be unit-tested without rendering the (async, data-fetching) tree.
14
+ */
15
+ /**
16
+ * Decide whether a single-item `show` card should be hidden because its
17
+ * underlying artifact failed to load.
18
+ *
19
+ * Rules:
20
+ * - While the tool is still running, never hide — the file may still be
21
+ * materializing, and a transient 404 shouldn't make the card flicker away.
22
+ * - Carousels are never hidden wholesale (they navigate between items).
23
+ * - A website/iframe preview is hidden only when it actually errored AND it
24
+ * isn't a deliberate link-only fallback.
25
+ * - Otherwise the card is hidden when its file/media content errored (e.g. the
26
+ * file was renamed or deleted → 404).
27
+ */
28
+ export function isShowContentUnavailable(input) {
29
+ const { running, isCarousel, contentStatus, isWebsitePreview, previewHasError, previewIsLinkOnly, } = input;
30
+ if (running || isCarousel)
31
+ return false;
32
+ if (isWebsitePreview)
33
+ return previewHasError && !previewIsLinkOnly;
34
+ return contentStatus === 'error';
35
+ }
36
+ // ═══════════════════════════════════════════════════════════════════════════
37
+ // Emptiness — a different question from availability
38
+ // ═══════════════════════════════════════════════════════════════════════════
39
+ //
40
+ // The gate above answers "the artifact failed to load"; that failure is worth a
41
+ // line in the transcript, because the agent DID hand something over and the
42
+ // reference went dead.
43
+ //
44
+ // This one answers "there was never an artifact at all". The show tool
45
+ // validates its own arguments (`packages/starter/templates/base/.kortix/
46
+ // opencode/tools/show.ts`) and returns a plain `Error: 'content' is required…`
47
+ // string when a required field is missing — but the tool part still carries the
48
+ // arguments the model sent, so the renderer happily draws a card for
49
+ // `{ type: 'markdown' }`: a header reading "Output", and under it nothing at
50
+ // all. Every branch of `ShowContentRenderer` is guarded on `content`/`path`, so
51
+ // the cascade falls through to a fallback whose four sub-conditions are all
52
+ // false, and the body renders as an empty box.
53
+ //
54
+ // A card with no body is not a deliverable, so it does not get a row.
55
+ /** True for a string that carries something. Blank strings are absence. */
56
+ function isFilled(value) {
57
+ return typeof value === 'string' && value.trim().length > 0;
58
+ }
59
+ /**
60
+ * The three fields a `show` can carry an artifact in.
61
+ *
62
+ * `title`, `description`, `type`, `language` and `aspect_ratio` are metadata
63
+ * ABOUT an artifact — never one themselves. A `show` holding only those has
64
+ * nothing to render.
65
+ */
66
+ function hasShowArtifact(payload) {
67
+ if (!payload || typeof payload !== 'object')
68
+ return false;
69
+ const { path, url, content } = payload;
70
+ return isFilled(path) || isFilled(url) || isFilled(content);
71
+ }
72
+ /**
73
+ * `items` reaches the UI as EITHER an array or a JSON string — the model
74
+ * serializes it and nothing downstream normalizes that before it lands in
75
+ * `state.input`. Both `ShowTool` and the Outputs derivation already handle both
76
+ * shapes; this parses defensively for the same reason.
77
+ *
78
+ * Malformed or half-streamed JSON yields `null`, which pushes the caller back
79
+ * onto the single-item fields. That is safe because emptiness is only ever
80
+ * judged on a SETTLED call — a mid-stream fragment is never the final answer.
81
+ */
82
+ function parseShowItemsPayload(raw) {
83
+ if (Array.isArray(raw))
84
+ return raw.length > 0 ? raw : null;
85
+ if (typeof raw !== 'string' || !raw.trim())
86
+ return null;
87
+ try {
88
+ const parsed = JSON.parse(raw);
89
+ return Array.isArray(parsed) && parsed.length > 0 ? parsed : null;
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ }
95
+ /**
96
+ * True when a `show` has no artifact to render — no `items`, no `path`, no
97
+ * `url`, no `content`.
98
+ *
99
+ * A carousel is empty only when NONE of its items carries an artifact; one good
100
+ * item keeps the whole carousel, since paging is how the rest are reached.
101
+ */
102
+ export function isShowPayloadEmpty(input) {
103
+ if (!input)
104
+ return true;
105
+ const items = parseShowItemsPayload(input.items);
106
+ if (items)
107
+ return !items.some(hasShowArtifact);
108
+ return !hasShowArtifact(input);
109
+ }
110
+ //# sourceMappingURL=show-availability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show-availability.js","sourceRoot":"","sources":["../../../../src/core/turns/tools/show-availability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoBH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAA4B;IACnE,MAAM,EACJ,OAAO,EACP,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,GAAG,KAAK,CAAC;IAEV,IAAI,OAAO,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,gBAAgB;QAAE,OAAO,eAAe,IAAI,CAAC,iBAAiB,CAAC;IACnE,OAAO,aAAa,KAAK,OAAO,CAAC;AACnC,CAAC;AAED,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAC9E,EAA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AM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiD;IAClF,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/C,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,35 @@
1
+ export declare function extractSkillContent(output: string): string;
2
+ export declare function extractSkillFiles(output: string): string[];
3
+ /**
4
+ * The skill's base directory, from wherever the tool happened to put it.
5
+ */
6
+ export declare function extractSkillBaseDir(output: string): string;
7
+ /**
8
+ * The directory carried on the call's INPUT, under any of the names the runtime
9
+ * might use. Same reasoning as above: probe, do not assume.
10
+ */
11
+ export declare function skillInputDir(input: Record<string, unknown>): string;
12
+ /**
13
+ * The file to show when a skill row is clicked, or null when there is none.
14
+ *
15
+ * A skill IS a document, so clicking one opens that document in the session's
16
+ * detail panel exactly as clicking a file in a read row does. Resolution order,
17
+ * most trustworthy first:
18
+ *
19
+ * 1. a location the tool actually stated — a tag attribute, a `Base
20
+ * directory:` line, or a directory on the call's input;
21
+ * 2. `.kortix/opencode/skills/<name>/`, where this product installs skills;
22
+ * 3. nothing, and only when there is no usable name either.
23
+ *
24
+ * (3) is now nearly unreachable, and that matters more than it looks. The row
25
+ * takes a click ONLY when this returns a path — `BasicTool` renders a plain
26
+ * button when handed `onClick` and a disclosure otherwise — so every earlier
27
+ * version, which resolved from the payload alone and got '' from it, silently
28
+ * degraded to the inline collapsible this was meant to replace.
29
+ *
30
+ * A `SKILL.md` listed in `<skill_files>` still names the document, since a
31
+ * listing is the runtime being explicit; it resolves against whichever base
32
+ * won above.
33
+ */
34
+ export declare function skillDocumentPath(output: string, inputDir?: string, skillName?: string): string | null;
35
+ //# sourceMappingURL=skill-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/tools/skill-helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAI1D;AA6BD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAMpE;AAuCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAWf"}
@@ -0,0 +1,129 @@
1
+ import { labelledValue, stripEdgeSlashes, stripTrailingSlashes, tagAttributes, tagBody, textBetween, textItems } from '../text-scan.js';
2
+ export function extractSkillContent(output) {
3
+ const body = tagBody(output, 'skill_content');
4
+ return body !== null ? body.trim() : output;
5
+ }
6
+ export function extractSkillFiles(output) {
7
+ const listing = textBetween(output, '<skill_files>', '</skill_files>');
8
+ if (listing === null)
9
+ return [];
10
+ return textItems(listing, '<file>', '</file>').map((file) => file.trim());
11
+ }
12
+ /**
13
+ * Every place the skill tool might have told us where the skill lives.
14
+ *
15
+ * The producer is the OpenCode runtime, not this repo, so its exact payload
16
+ * cannot be read from source — which is precisely why this probes rather than
17
+ * assumes. The first attempt keyed off `input.dir` alone, that field was absent
18
+ * in practice, and clicking a skill silently did nothing.
19
+ *
20
+ * Three sources, and the tag attributes are the one the old code was already
21
+ * hinting at: `extractSkillContent` matches `<skill_content[^>]*>`, and nobody
22
+ * writes `[^>]*` for a tag that has no attributes.
23
+ */
24
+ function attributeDir(output) {
25
+ const attributes = tagAttributes(output, 'skill_content');
26
+ if (attributes === null)
27
+ return '';
28
+ for (const key of ['dir', 'directory', 'path', 'base', 'baseDir', 'base_dir']) {
29
+ const found = attributes.match(new RegExp(`\\b${key}\\s*=\\s*["']([^"']+)["']`, 'i'));
30
+ if (found?.[1]?.trim())
31
+ return found[1].trim();
32
+ }
33
+ return '';
34
+ }
35
+ /** The `Base directory:` line the component already strips out of the markdown. */
36
+ function labelledDir(output) {
37
+ return labelledValue(output, ['Base directory', 'Directory', 'Skill directory'])?.trim() ?? '';
38
+ }
39
+ /**
40
+ * The skill's base directory, from wherever the tool happened to put it.
41
+ */
42
+ export function extractSkillBaseDir(output) {
43
+ return stripTrailingSlashes(attributeDir(output) || labelledDir(output));
44
+ }
45
+ /**
46
+ * The directory carried on the call's INPUT, under any of the names the runtime
47
+ * might use. Same reasoning as above: probe, do not assume.
48
+ */
49
+ export function skillInputDir(input) {
50
+ for (const key of ['dir', 'directory', 'path', 'skillPath', 'location']) {
51
+ const value = input[key];
52
+ if (typeof value === 'string' && value.trim())
53
+ return stripTrailingSlashes(value.trim());
54
+ }
55
+ return '';
56
+ }
57
+ /**
58
+ * Where this product installs a skill, relative to the workspace root.
59
+ *
60
+ * Not a guess and not a convention borrowed from upstream — it is this repo's
61
+ * own layout, asserted in three places: `injectManagedSkills` copies each skill
62
+ * to `<configDir>/skills/<name>/` (kortix-sandbox-agent-server), that configDir
63
+ * falls back to `.kortix/opencode` (`resolveOpencodeConfigDir`), and the product
64
+ * tells users the same path in prose (`entity-modal.tsx`, `use-configure-thread`).
65
+ *
66
+ * The panel takes workspace-relative paths — `apply-patch-tool` already hands it
67
+ * one — so this needs no sandbox prefix.
68
+ */
69
+ const SKILLS_DIR = '.kortix/opencode/skills';
70
+ /**
71
+ * The directory a named skill occupies, or '' when the name cannot be trusted.
72
+ *
73
+ * The directory is flat, so a namespaced name contributes only its last segment.
74
+ * A name that tries to climb out of the skills directory is refused outright
75
+ * rather than normalised — the click's whole job is to open a skill, and there
76
+ * is no reading of `..` under which it still does that.
77
+ */
78
+ function conventionalSkillDir(skillName) {
79
+ const raw = stripEdgeSlashes(skillName?.trim() ?? '');
80
+ // `SkillTool` renders `input.name || 'skill'`, so the placeholder reaches here
81
+ // meaning "no name was sent" and must not resolve to a directory called that.
82
+ if (!raw || raw.toLowerCase() === 'skill')
83
+ return '';
84
+ const segments = raw.split('/').map((s) => s.trim());
85
+ // Judged over EVERY segment, not just the one that survives. Keeping the last
86
+ // segment of `../../etc/passwd` yields `passwd` — inside the skills directory,
87
+ // so harmless, but it quietly answers a nonsense name with a confident path.
88
+ if (segments.some((s) => s === '..' || s === '.'))
89
+ return '';
90
+ const leaf = segments.at(-1) ?? '';
91
+ if (!leaf)
92
+ return '';
93
+ return `${SKILLS_DIR}/${leaf}`;
94
+ }
95
+ /**
96
+ * The file to show when a skill row is clicked, or null when there is none.
97
+ *
98
+ * A skill IS a document, so clicking one opens that document in the session's
99
+ * detail panel exactly as clicking a file in a read row does. Resolution order,
100
+ * most trustworthy first:
101
+ *
102
+ * 1. a location the tool actually stated — a tag attribute, a `Base
103
+ * directory:` line, or a directory on the call's input;
104
+ * 2. `.kortix/opencode/skills/<name>/`, where this product installs skills;
105
+ * 3. nothing, and only when there is no usable name either.
106
+ *
107
+ * (3) is now nearly unreachable, and that matters more than it looks. The row
108
+ * takes a click ONLY when this returns a path — `BasicTool` renders a plain
109
+ * button when handed `onClick` and a disclosure otherwise — so every earlier
110
+ * version, which resolved from the payload alone and got '' from it, silently
111
+ * degraded to the inline collapsible this was meant to replace.
112
+ *
113
+ * A `SKILL.md` listed in `<skill_files>` still names the document, since a
114
+ * listing is the runtime being explicit; it resolves against whichever base
115
+ * won above.
116
+ */
117
+ export function skillDocumentPath(output, inputDir, skillName) {
118
+ const stated = stripTrailingSlashes(inputDir?.trim() ?? '') || extractSkillBaseDir(output);
119
+ const base = stated || conventionalSkillDir(skillName);
120
+ const listed = extractSkillFiles(output).find((f) => /(^|\/)SKILL\.md$/i.test(f));
121
+ if (listed) {
122
+ if (listed.startsWith('/'))
123
+ return listed;
124
+ if (base)
125
+ return `${base}/${listed}`;
126
+ }
127
+ return base ? `${base}/SKILL.md` : null;
128
+ }
129
+ //# sourceMappingURL=skill-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-helpers.js","sourceRoot":"","sources":["../../../../src/core/turns/tools/skill-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAErI,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC9C,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;IACvE,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAChC,OAAO,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1D,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE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MAAM,CAAC;QAC1C,IAAI,IAAI;YAAE,OAAO,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;IACvC,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Minimal tool metadata — matches the reference opencode implementation.
3
+ *
4
+ * Only two concerns:
5
+ * 1. Which tools group into a "context" block (read, glob, grep, list).
6
+ * 2. Extracting a one-line identity for any tool call (primary arg).
7
+ */
8
+ import type { ToolPart } from '../../runtime/client.js';
9
+ export declare const CONTEXT_TOOLS: Set<string>;
10
+ /** Normalize `oc-foo_bar` → `foo_bar`, `foo-bar` → `foo_bar`. */
11
+ export declare function normalizeName(name: string): string;
12
+ export declare function isContextTool(toolName: string): boolean;
13
+ /**
14
+ * Summary counts for a context group: { read: N, search: N, list: N }.
15
+ * "search" covers both glob and grep.
16
+ */
17
+ export declare function contextToolSummary(parts: ToolPart[]): {
18
+ read: number;
19
+ search: number;
20
+ list: number;
21
+ };
22
+ /**
23
+ * Extract the one thing that identifies a tool call in a one-liner.
24
+ * Used for context-group item labels and any future compact views.
25
+ */
26
+ export declare function getToolPrimaryArg(part: ToolPart): string;
27
+ /**
28
+ * The titles `contextToolTrigger` gives the tools it knows by name.
29
+ *
30
+ * Every field is optional: a host passes its translated strings and keeps the
31
+ * English default for any it omits. The defaults are the exact strings the
32
+ * web app's `en` locale renders.
33
+ */
34
+ export interface ContextToolTriggerLabels {
35
+ /** `read` */
36
+ read: string;
37
+ /** `glob`, `grep` */
38
+ search: string;
39
+ /** `list` */
40
+ list: string;
41
+ /** `bash` */
42
+ shell: string;
43
+ /** `edit`, `morph_edit` */
44
+ edit: string;
45
+ /** `write` */
46
+ write: string;
47
+ /** `webfetch`, `web_fetch` */
48
+ fetch: string;
49
+ /** `websearch`, `web_search` */
50
+ webSearch: string;
51
+ /** `scrape`, `scrape_webpage` */
52
+ scrape: string;
53
+ /** `apply_patch` */
54
+ applyPatch: string;
55
+ /** `task` */
56
+ task: string;
57
+ /** `session_spawn`, `session_start_background` */
58
+ worker: string;
59
+ /** `project_select`, `project_list` */
60
+ workspace: string;
61
+ }
62
+ export declare const DEFAULT_CONTEXT_TOOL_TRIGGER_LABELS: Readonly<ContextToolTriggerLabels>;
63
+ /**
64
+ * Build a trigger { title, subtitle } for any tool inside the expanded
65
+ * UnifiedGroup. Context tools get friendly names; others use their
66
+ * canonical name in Title Case.
67
+ */
68
+ export declare function contextToolTrigger(part: ToolPart, labels?: Partial<ContextToolTriggerLabels>): {
69
+ title: string;
70
+ subtitle: string;
71
+ };
72
+ //# sourceMappingURL=tool-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-meta.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/tools/tool-meta.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMrD,eAAO,MAAM,aAAa,aAA4C,CAAC;AAEvE,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAWA;AAiBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAoDxD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,aAAa;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa;IACb,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa;IACb,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CAAC,wBAAwB,CAclF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,MAAM,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC7C;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CA2CA"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Minimal tool metadata — matches the reference opencode implementation.
3
+ *
4
+ * Only two concerns:
5
+ * 1. Which tools group into a "context" block (read, glob, grep, list).
6
+ * 2. Extracting a one-line identity for any tool call (primary arg).
7
+ */
8
+ import { humanizeSearchQuery } from './search-query.js';
9
+ import { stripTrailingSlashes } from '../text-scan.js';
10
+ // ─── Context tool grouping ───────────────────────────────────────────────
11
+ export const CONTEXT_TOOLS = new Set(['read', 'glob', 'grep', 'list']);
12
+ /** Normalize `oc-foo_bar` → `foo_bar`, `foo-bar` → `foo_bar`. */
13
+ export function normalizeName(name) {
14
+ return name.replace(/^oc-/, '').replace(/-/g, '_');
15
+ }
16
+ export function isContextTool(toolName) {
17
+ const n = normalizeName(toolName);
18
+ return CONTEXT_TOOLS.has(n);
19
+ }
20
+ /**
21
+ * Summary counts for a context group: { read: N, search: N, list: N }.
22
+ * "search" covers both glob and grep.
23
+ */
24
+ export function contextToolSummary(parts) {
25
+ let read = 0;
26
+ let search = 0;
27
+ let list = 0;
28
+ for (const part of parts) {
29
+ const n = normalizeName(part.tool);
30
+ if (n === 'read')
31
+ read++;
32
+ else if (n === 'glob' || n === 'grep')
33
+ search++;
34
+ else if (n === 'list')
35
+ list++;
36
+ }
37
+ return { read, search, list };
38
+ }
39
+ // ─── Primary-arg extraction ──────────────────────────────────────────────
40
+ function basename(p) {
41
+ if (!p)
42
+ return '';
43
+ const cleaned = stripTrailingSlashes(p.replace(/\\/g, '/'));
44
+ const idx = cleaned.lastIndexOf('/');
45
+ return idx >= 0 ? cleaned.slice(idx + 1) : cleaned;
46
+ }
47
+ function truncate(s, max = 60) {
48
+ if (!s)
49
+ return '';
50
+ const trimmed = s.replace(/\s+/g, ' ').trim();
51
+ return trimmed.length > max ? `${trimmed.slice(0, max)}…` : trimmed;
52
+ }
53
+ /**
54
+ * Extract the one thing that identifies a tool call in a one-liner.
55
+ * Used for context-group item labels and any future compact views.
56
+ */
57
+ export function getToolPrimaryArg(part) {
58
+ const state = (part.state ?? {});
59
+ const input = (state.input ?? {});
60
+ const key = normalizeName(part.tool);
61
+ switch (key) {
62
+ case 'read':
63
+ case 'edit':
64
+ case 'write':
65
+ case 'morph_edit': {
66
+ const p = input.filePath ?? input.file_path ?? input.path;
67
+ return p ? basename(String(p)) : '';
68
+ }
69
+ case 'glob':
70
+ return input.pattern ? String(input.pattern) : '';
71
+ case 'grep': {
72
+ const pat = input.pattern ?? input.query;
73
+ const where = input.path ?? input.include;
74
+ if (pat && where)
75
+ return `"${truncate(String(pat), 40)}" in ${basename(String(where))}`;
76
+ if (pat)
77
+ return `"${truncate(String(pat), 60)}"`;
78
+ return '';
79
+ }
80
+ case 'list':
81
+ return input.path ? basename(String(input.path)) : '';
82
+ case 'bash':
83
+ return truncate(String(input.command ?? ''), 80);
84
+ default:
85
+ break;
86
+ }
87
+ // Generic fallback: first meaningful input key (matches reference's `label()` helper)
88
+ const fallbackKeys = [
89
+ 'description',
90
+ 'query',
91
+ 'url',
92
+ 'filePath',
93
+ 'file_path',
94
+ 'path',
95
+ 'pattern',
96
+ 'name',
97
+ 'prompt',
98
+ ];
99
+ for (const k of fallbackKeys) {
100
+ const v = input[k];
101
+ if (typeof v === 'string' && v.length > 0) {
102
+ // A query reaches the screen as prose, so it drops its engine operators
103
+ // first — `site:daytona.io foo` is an instruction, not a subject. See
104
+ // `humanizeSearchQuery`.
105
+ return truncate(k === 'query' ? humanizeSearchQuery(v) || v : v, 60);
106
+ }
107
+ }
108
+ return '';
109
+ }
110
+ export const DEFAULT_CONTEXT_TOOL_TRIGGER_LABELS = {
111
+ read: 'Read',
112
+ search: 'Search',
113
+ list: 'List',
114
+ shell: 'Shell',
115
+ edit: 'Edit',
116
+ write: 'Write',
117
+ fetch: 'Fetch',
118
+ webSearch: 'Web Search',
119
+ scrape: 'Scrape',
120
+ applyPatch: 'Apply Patch',
121
+ task: 'Task',
122
+ worker: 'Worker',
123
+ workspace: 'Workspace',
124
+ };
125
+ /**
126
+ * Build a trigger { title, subtitle } for any tool inside the expanded
127
+ * UnifiedGroup. Context tools get friendly names; others use their
128
+ * canonical name in Title Case.
129
+ */
130
+ export function contextToolTrigger(part, labels = {}) {
131
+ const l = { ...DEFAULT_CONTEXT_TOOL_TRIGGER_LABELS, ...labels };
132
+ const n = normalizeName(part.tool);
133
+ const sub = getToolPrimaryArg(part);
134
+ switch (n) {
135
+ case 'read':
136
+ return { title: l.read, subtitle: sub };
137
+ case 'glob':
138
+ case 'grep':
139
+ return { title: l.search, subtitle: sub };
140
+ case 'list':
141
+ return { title: l.list, subtitle: sub };
142
+ case 'bash':
143
+ return { title: l.shell, subtitle: sub };
144
+ case 'edit':
145
+ case 'morph_edit':
146
+ return { title: l.edit, subtitle: sub };
147
+ case 'write':
148
+ return { title: l.write, subtitle: sub };
149
+ case 'webfetch':
150
+ case 'web_fetch':
151
+ return { title: l.fetch, subtitle: sub };
152
+ case 'websearch':
153
+ case 'web_search':
154
+ return { title: l.webSearch, subtitle: sub };
155
+ case 'scrape':
156
+ case 'scrape_webpage':
157
+ return { title: l.scrape, subtitle: sub };
158
+ case 'apply_patch':
159
+ return { title: l.applyPatch, subtitle: sub };
160
+ case 'task':
161
+ return { title: l.task, subtitle: sub };
162
+ case 'session_spawn':
163
+ case 'session_start_background':
164
+ return { title: l.worker, subtitle: sub };
165
+ case 'project_select':
166
+ case 'project_list':
167
+ return { title: l.workspace, subtitle: sub };
168
+ default: {
169
+ const display = n.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
170
+ return { title: display, subtitle: sub };
171
+ }
172
+ }
173
+ }
174
+ //# sourceMappingURL=tool-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-meta.js","sourceRoot":"","sources":["../../../../src/core/turns/tools/tool-meta.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,4EAA4E;AAE5E,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvE,iEAAiE;AACjE,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAClC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAKlD,IAA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E,GAAG,EAAE,CAAC;QAC/C,KAAK,QAAQ,CAAC;QACd,KAAK,gBAAgB;YACnB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAC5C,KAAK,aAAa;YAChB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAChD,KAAK,MAAM;YACT,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAC1C,KAAK,eAAe,CAAC;QACrB,KAAK,0BAA0B;YAC7B,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAC5C,KAAK,gBAAgB,CAAC;QACtB,KAAK,cAAc;YACjB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAC/C,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAC3C,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Tool-outcome + JSON-failure parsing — pure helpers, no React.
3
+ *
4
+ * Extracted from `infrastructure.tsx` so the verdict logic (the predicates
5
+ * every tool renderer shares) and the `{success:false,error}` failure
6
+ * contract parser are testable WITHOUT loading the 1500-line React module
7
+ * that renders them. `infrastructure.tsx` re-exports everything here so
8
+ * existing call sites keep their imports unchanged.
9
+ *
10
+ * No React / DOM / framework imports allowed — type-only imports only.
11
+ */
12
+ import type { ToolPart } from '../../runtime/client.js';
13
+ /** The `{success:false,error,hint?}` failure contract, parsed. */
14
+ export interface ParsedJsonFailure {
15
+ errorSummary: string;
16
+ hint?: string;
17
+ status?: number;
18
+ nestedMessage?: string;
19
+ nestedError?: boolean;
20
+ }
21
+ export type ToolOutcome = 'ok' | 'partial' | 'failed';
22
+ export declare function looksLikeError(text: string): boolean;
23
+ /**
24
+ * True when a completed tool's output is an error rather than a result —
25
+ * either a plain error/traceback string or the `{success:false,error}` contract.
26
+ * Tools whose own parser returns nothing should fall back to rendering the
27
+ * error (via `ToolOutputFallback`) instead of a blank panel.
28
+ */
29
+ export declare function isErrorOutput(output: string): boolean;
30
+ /**
31
+ * Whether a settled tool call succeeded, half-succeeded, or failed.
32
+ *
33
+ * Three different shapes mean "this failed", and only the first of them used to
34
+ * reach the row's icon:
35
+ * - the call threw — `state.status === 'error'`
36
+ * - the call RETURNED the error — completed, output is `Error: …` or the
37
+ * `{success:false,error}` contract
38
+ * - the call returned a batch — completed, `results[]` with some or all
39
+ * items `success:false` (scrape_webpage over three URLs, one dead host)
40
+ *
41
+ * Every tool renderer hardcodes its own leading icon — `GlobeIcon` for scrape,
42
+ * a favicon for web_fetch, a terminal for bash — and none of them read the
43
+ * output, so shapes two and three kept drawing "web page" over a failure. This
44
+ * is the one predicate they all share; see {@link ToolOutcomeContext}.
45
+ *
46
+ * A running call is `ok`: it has no verdict yet. The shimmer already says
47
+ * "in flight", and painting a warning on unfinished work is a worse lie than
48
+ * the one this fixes.
49
+ */
50
+ export declare function partOutcome(part: Pick<ToolPart, 'state'>): ToolOutcome;
51
+ /**
52
+ * Parse the `{success:false,error,hint?}` failure contract out of a tool's
53
+ * output. Returns null when the output isn't that contract.
54
+ *
55
+ * The parsed JSON must be a plain OBJECT before any field is read. A tool that
56
+ * returns the literal `null` (or any JSON value that parses to a non-object —
57
+ * `true`, `5`, `"x"`, …) used to reach `parsed.success` on `null` and throw
58
+ * `Cannot read properties of null (reading 'success')`, which crashed the
59
+ * session page's turn render via `partOutcome` → `isErrorOutput` → here
60
+ * (Better Stack patterns `487ae241…` / `ce68779d…`, prod v0.12.4). Any value
61
+ * that isn't an object is, by definition, not the failure contract → null.
62
+ */
63
+ export declare function parseJsonFailure(output: string): ParsedJsonFailure | null;
64
+ /**
65
+ * Normalize a backend error string for display: strip the noisy, often
66
+ * duplicated `Error:` prefixes (e.g. "Error: … Error: Error: …") and collapse
67
+ * whitespace, so the panel shows one calm sentence instead of stack-y jargon.
68
+ * Falls back to the trimmed original if cleaning would empty the string.
69
+ */
70
+ export declare function cleanErrorMessage(raw: string): string;
71
+ /**
72
+ * Format the `{success:false,error,hint?}` failure contract as a plain text
73
+ * block (error + nested message + hint). Returns null when the output isn't
74
+ * that contract. Same null-object guard as {@link parseJsonFailure} — a tool
75
+ * that returns the literal `null` is not the failure contract.
76
+ */
77
+ export declare function formatJsonFailureOutput(output: string): string | null;
78
+ //# sourceMappingURL=tool-outcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-outcome.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/tools/tool-outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrD,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;AAOtD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQpD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,WAAW,CAStE;AAiFD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAoCzE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsCrE"}