@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,47 @@
1
+ /**
2
+ * Does this turn still show the working indicator ("Figuring out what's
3
+ * next…", the dot matrix, the live duration)?
4
+ *
5
+ * A turn that has reported an error is OVER: `session.error` terminates the
6
+ * turn the runtime was running. Rendering the spinner beside the failure says
7
+ * two contradictory things at once, and it is what the 2026-08-19 report
8
+ * showed — a `ModelNotFound` line pinned under a spinner that never stopped,
9
+ * because the turn's authority (a `GET .../turn` read of a control-plane row
10
+ * the daemon had not yet closed) still reported the turn open.
11
+ *
12
+ * The one exception is a RETRY. The gateway's retry state is an error that has
13
+ * not finished: the session status is `retry`, the countdown
14
+ * (`SessionRetryDisplay`) renders inside this same block, and the turn really
15
+ * is still going. So an error suppresses the indicator only when nothing is
16
+ * being retried.
17
+ *
18
+ * A turn WAITING ON THE USER is suppressed for the same reason as the error,
19
+ * and it is the only one of these states with no upper bound. The runtime's
20
+ * `question` tool and its permission prompts park the turn inside its own loop
21
+ * and block until someone answers: no `session.idle` frame is emitted, the
22
+ * control plane's turn row stays `active`, and every observer in
23
+ * `projectWorking` is therefore correctly reporting `working`. The agent,
24
+ * however, is not working — the next move is the reader's — so the shimmer and
25
+ * its ticking clock claim progress that is not happening, directly above the
26
+ * card asking them to act.
27
+ *
28
+ * MEASURED, local stack 2026-09-22 (session 8d807956): one prompt, the agent
29
+ * answered and then asked a 2-option question. The control-plane row stayed
30
+ * `active` for 12m22s while the question sat unanswered on screen, and the
31
+ * transcript shimmered "Working on it" with a clock that reached 7m55s before
32
+ * the screenshot was taken. Nothing would have ended it but answering — which
33
+ * is what "loading forever" looks like from the other side of the screen.
34
+ *
35
+ * The composer already knows this (`lockForQuestion` / `lockForApproval` swap
36
+ * Stop for the question's own control); this is the transcript catching up.
37
+ */
38
+ export function showTurnBusyIndicator(input) {
39
+ if (!input.working)
40
+ return false;
41
+ if (input.awaitingUser)
42
+ return false;
43
+ if (input.isRetrying)
44
+ return true;
45
+ return !input.hasError;
46
+ }
47
+ //# sourceMappingURL=turn-busy-visibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-busy-visibility.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/turn-busy-visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAYrC;IACC,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,KAAK,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IACrC,IAAI,KAAK,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAClC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;AACzB,CAAC"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * WHICH turn is the one the agent is working on.
3
+ *
4
+ * It used to be "the last one", by definition — and that was true until a
5
+ * prompt could be queued mid-turn. Now the transcript can end with one or
6
+ * more user messages the agent has not reached yet: OpenCode persists a
7
+ * queued prompt as a user message the moment the server forwards it, and
8
+ * the agent picks it up between steps, minutes later. During that window
9
+ * the LAST turn is a bubble with nothing under it, and the turn that is
10
+ * actually streaming (with its "Thinking" burst, its tool calls) sits one
11
+ * or more turns UP. Pinning the working indicator to the last turn painted
12
+ * "Figuring out what's next…" under a message nobody had started, and left
13
+ * the live turn looking settled.
14
+ *
15
+ * The rule, in order:
16
+ *
17
+ * 1. The working projection names a turn. This is the server's current turn
18
+ * or this tab's fresh send receipt. It outranks incomplete transcript
19
+ * metadata because message completion can arrive one frame late.
20
+ * 2. The newest turn that has any assistant content. If its newest
21
+ * assistant message is still open (no `time.completed`), that is the
22
+ * working turn — the agent is visibly writing there. Older turns with an
23
+ * open assistant message are husks (a box that died mid-turn); the
24
+ * newest turn with content outranks them.
25
+ * 3. Otherwise the NEWEST pending turn. OpenCode parents the next step to
26
+ * the latest user message and answers every queued message before it in
27
+ * that same step — so that is where the shimmer lands, and the ones
28
+ * before it are already taken (bright, no indicator of their own).
29
+ * 4. No pending turns: the newest turn with content (its step just ended;
30
+ * the next one has not opened yet — the indicator stays put instead of
31
+ * flickering).
32
+ *
33
+ * `null` for an empty transcript — and for a transcript with no assistant
34
+ * content at all whose every prompt the server is still holding: there is no
35
+ * turn the agent is on, only pending ones.
36
+ */
37
+ interface TurnLike {
38
+ userMessage: {
39
+ info: {
40
+ id: string;
41
+ };
42
+ };
43
+ assistantMessages: ReadonlyArray<{
44
+ info: {
45
+ time?: {
46
+ completed?: number;
47
+ } | object;
48
+ error?: unknown;
49
+ };
50
+ }>;
51
+ }
52
+ export interface WorkingTurnResolution {
53
+ /** The user message id of the working turn, or null for no turns. */
54
+ workingTurnId: string | null;
55
+ /** User message ids of the turns AFTER the working one that have no
56
+ * assistant content — prompts the agent has not reached. */
57
+ pendingTurnIds: string[];
58
+ }
59
+ /** A completed assistant message can be an intermediate step of an active
60
+ * turn. The working turn yields its row only on evidence: pending delivery, or
61
+ * a projection naming a different active turn. A null active id is a gap
62
+ * between readings; suppressing on it moved Thinking below queued bubbles. */
63
+ export declare function shouldSuppressWorkingTurnBusy(input: {
64
+ hasPendingTurns: boolean;
65
+ newestAssistantCompleted: boolean;
66
+ workingTurnId: string;
67
+ activeTurnId: string | null;
68
+ pendingDelivery: boolean;
69
+ /** A queued prompt after this turn is being delivered to the runtime now. */
70
+ deliveringBelow?: boolean;
71
+ }): boolean;
72
+ interface QueuedTurnInput {
73
+ pendingTurnIds: ReadonlySet<string>;
74
+ /** Every id an inbox prompt can render under. */
75
+ pendingPromptIds: {
76
+ has(id: string): boolean;
77
+ };
78
+ }
79
+ /** Ids a prompt the inbox is delivering right now can render under. */
80
+ interface DeliveringTurnInput {
81
+ deliveringPromptIds: {
82
+ has(id: string): boolean;
83
+ };
84
+ }
85
+ /**
86
+ * Where the fallback Thinking row goes when no turn draws its own. A prompt
87
+ * the inbox is delivering is the work in progress, so the row sits directly
88
+ * under its bubble. Otherwise it follows the last turn before the first queued
89
+ * bubble, so it never sits under prompts the agent has not reached. `null` puts
90
+ * it at the transcript's end: nothing is queued, or the queue starts the
91
+ * transcript.
92
+ */
93
+ export declare function fallbackBusyRowAfterTurnId(input: QueuedTurnInput & DeliveringTurnInput & {
94
+ turns: ReadonlyArray<TurnLike>;
95
+ }): string | null;
96
+ /**
97
+ * Has the server confirmed this turn is the one running? Only then does it drop
98
+ * its pending bubble presentation before the next inbox poll. A fresh send the
99
+ * inbox still holds is the working turn too, and keeps its tint and pending id
100
+ * beside its Thinking row until delivery.
101
+ */
102
+ export declare function turnIsConfirmedActive(input: {
103
+ isTurnWorking: boolean;
104
+ turnId: string;
105
+ activeTurnId: string | null;
106
+ pendingDelivery: boolean;
107
+ }): boolean;
108
+ /**
109
+ * Does the working turn draw the Thinking row itself? It does not when it has
110
+ * no id, when a finished answer yields it to the queue, or when its reply
111
+ * reported an error that is not being retried. Then the fallback row draws, so
112
+ * a busy session (Stop visible) never shows zero rows.
113
+ *
114
+ * `awaitingUser` is the one input that must NOT hand the row to the fallback:
115
+ * a turn parked on a question draws no row anywhere, because the session is
116
+ * not working. The caller gates its fallback on the same fact — see
117
+ * `showFallbackBusyRow` in `session-chat.tsx`.
118
+ */
119
+ export declare function workingTurnDrawsBusyRow(input: {
120
+ lastTurnWorking: boolean;
121
+ workingTurnId: string | null;
122
+ suppressed: boolean;
123
+ workingTurnHasError: boolean;
124
+ isRetrying: boolean;
125
+ /** The runtime is parked on a question or a permission prompt. */
126
+ awaitingUser?: boolean;
127
+ }): boolean;
128
+ /**
129
+ * The hint for an idle send this tab just made, while the projection names no
130
+ * turn: the sent turn's CURRENT id, until that turn has an answer.
131
+ *
132
+ * `projectWorking` drops its receipt the moment the runtime emits anything
133
+ * (`activityAfterIdle` → `turnId: null`) — and the first thing an idle send
134
+ * makes the runtime emit is the echo of the user's own prompt, a
135
+ * `message.part.updated` that lands BEFORE the assistant message exists. In
136
+ * that window the optimistic inbox row still reads `queued`, so the
137
+ * `unrunTurnIds` skip below classified the prompt the agent is about to answer
138
+ * as held: the bubble dimmed for a frame and the transcript's scroll anchor
139
+ * fell back to the previous answer — then snapped forward again when the answer
140
+ * opened. That is the double jump on send.
141
+ *
142
+ * Only an IDLE send qualifies (the caller records it; a send into a running
143
+ * turn is genuinely queued and must stay dimmed), and only while the turn is
144
+ * unanswered — once it has an assistant message, rule 1/2 decide on their own.
145
+ * `isSentTurn` matches the sent id OR its re-minted echo alias.
146
+ */
147
+ export declare function freshSendHint(turns: ReadonlyArray<TurnLike>, isSentTurn: (userMessageId: string) => boolean): string | null;
148
+ export declare function resolveWorkingTurn(input: {
149
+ turns: ReadonlyArray<TurnLike>;
150
+ /** `WorkingProjection.turnId` — the server's or the receipt's answer for
151
+ * which prompt opened the running turn. Often null (triggers, `/` commands). */
152
+ hintMessageId: string | null | undefined;
153
+ /**
154
+ * User message ids whose prompt the SERVER still holds in its inbox —
155
+ * `queued`, `waiting`, or `delivering`. Each is a turn the agent provably has
156
+ * not reached, so none of them may be chosen as the working turn by the
157
+ * transcript-only fallback below.
158
+ *
159
+ * Optional: a caller with no inbox (a sub-session, a test) gets the old
160
+ * transcript-only answer.
161
+ */
162
+ unrunTurnIds?: ReadonlySet<string>;
163
+ }): WorkingTurnResolution;
164
+ export {};
165
+ //# sourceMappingURL=working-turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-turn.d.ts","sourceRoot":"","sources":["../../../../src/core/turns/segments/working-turn.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,UAAU,QAAQ;IAChB,WAAW,EAAE;QAAE,IAAI,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACtC,iBAAiB,EAAE,aAAa,CAAC;QAC/B,IAAI,EAAE;YAAE,IAAI,CAAC,EAAE;gBAAE,SAAS,CAAC,EAAE,MAAM,CAAA;aAAE,GAAG,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;KACnE,CAAC,CAAC;CACJ;AAKD,MAAM,WAAW,qBAAqB;IACpC,qEAAqE;IACrE,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;iEAC6D;IAC7D,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;8EAG8E;AAC9E,wBAAgB,6BAA6B,CAAC,KAAK,EAAE;IACnD,eAAe,EAAE,OAAO,CAAC;IACzB,wBAAwB,EAAE,OAAO,CAAC;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,6EAA6E;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAOV;AAED,UAAU,eAAe;IACvB,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,iDAAiD;IACjD,gBAAgB,EAAE;QAAE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAChD;AAED,uEAAuE;A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AqB,CAyExB"}
@@ -0,0 +1,168 @@
1
+ import { showTurnBusyIndicator } from './turn-busy-visibility.js';
2
+ const completedAt = (info) => info.time?.completed;
3
+ /** A completed assistant message can be an intermediate step of an active
4
+ * turn. The working turn yields its row only on evidence: pending delivery, or
5
+ * a projection naming a different active turn. A null active id is a gap
6
+ * between readings; suppressing on it moved Thinking below queued bubbles. */
7
+ export function shouldSuppressWorkingTurnBusy(input) {
8
+ if (!input.hasPendingTurns || !input.newestAssistantCompleted)
9
+ return false;
10
+ return (input.pendingDelivery ||
11
+ !!input.deliveringBelow ||
12
+ (input.activeTurnId !== null && input.activeTurnId !== input.workingTurnId));
13
+ }
14
+ /** The transcript's `pending` bubble rule for a turn nobody is working on. */
15
+ function isQueuedTurn(turn, input) {
16
+ const id = turn.userMessage.info.id;
17
+ return (input.pendingTurnIds.has(id) ||
18
+ (turn.assistantMessages.length === 0 && input.pendingPromptIds.has(id)));
19
+ }
20
+ /**
21
+ * Where the fallback Thinking row goes when no turn draws its own. A prompt
22
+ * the inbox is delivering is the work in progress, so the row sits directly
23
+ * under its bubble. Otherwise it follows the last turn before the first queued
24
+ * bubble, so it never sits under prompts the agent has not reached. `null` puts
25
+ * it at the transcript's end: nothing is queued, or the queue starts the
26
+ * transcript.
27
+ */
28
+ export function fallbackBusyRowAfterTurnId(input) {
29
+ const delivering = input.turns.find((turn) => input.deliveringPromptIds.has(turn.userMessage.info.id));
30
+ if (delivering)
31
+ return delivering.userMessage.info.id;
32
+ const firstQueued = input.turns.findIndex((turn) => isQueuedTurn(turn, input));
33
+ if (firstQueued <= 0)
34
+ return null;
35
+ return input.turns[firstQueued - 1].userMessage.info.id;
36
+ }
37
+ /**
38
+ * Has the server confirmed this turn is the one running? Only then does it drop
39
+ * its pending bubble presentation before the next inbox poll. A fresh send the
40
+ * inbox still holds is the working turn too, and keeps its tint and pending id
41
+ * beside its Thinking row until delivery.
42
+ */
43
+ export function turnIsConfirmedActive(input) {
44
+ return input.isTurnWorking && !input.pendingDelivery && input.activeTurnId === input.turnId;
45
+ }
46
+ /**
47
+ * Does the working turn draw the Thinking row itself? It does not when it has
48
+ * no id, when a finished answer yields it to the queue, or when its reply
49
+ * reported an error that is not being retried. Then the fallback row draws, so
50
+ * a busy session (Stop visible) never shows zero rows.
51
+ *
52
+ * `awaitingUser` is the one input that must NOT hand the row to the fallback:
53
+ * a turn parked on a question draws no row anywhere, because the session is
54
+ * not working. The caller gates its fallback on the same fact — see
55
+ * `showFallbackBusyRow` in `session-chat.tsx`.
56
+ */
57
+ export function workingTurnDrawsBusyRow(input) {
58
+ if (!input.lastTurnWorking || input.workingTurnId === null || input.suppressed)
59
+ return false;
60
+ return showTurnBusyIndicator({
61
+ working: true,
62
+ hasError: input.workingTurnHasError,
63
+ isRetrying: input.isRetrying,
64
+ awaitingUser: input.awaitingUser,
65
+ });
66
+ }
67
+ /**
68
+ * The hint for an idle send this tab just made, while the projection names no
69
+ * turn: the sent turn's CURRENT id, until that turn has an answer.
70
+ *
71
+ * `projectWorking` drops its receipt the moment the runtime emits anything
72
+ * (`activityAfterIdle` → `turnId: null`) — and the first thing an idle send
73
+ * makes the runtime emit is the echo of the user's own prompt, a
74
+ * `message.part.updated` that lands BEFORE the assistant message exists. In
75
+ * that window the optimistic inbox row still reads `queued`, so the
76
+ * `unrunTurnIds` skip below classified the prompt the agent is about to answer
77
+ * as held: the bubble dimmed for a frame and the transcript's scroll anchor
78
+ * fell back to the previous answer — then snapped forward again when the answer
79
+ * opened. That is the double jump on send.
80
+ *
81
+ * Only an IDLE send qualifies (the caller records it; a send into a running
82
+ * turn is genuinely queued and must stay dimmed), and only while the turn is
83
+ * unanswered — once it has an assistant message, rule 1/2 decide on their own.
84
+ * `isSentTurn` matches the sent id OR its re-minted echo alias.
85
+ */
86
+ export function freshSendHint(turns, isSentTurn) {
87
+ for (let i = turns.length - 1; i >= 0; i--) {
88
+ const id = turns[i].userMessage.info.id;
89
+ if (!isSentTurn(id))
90
+ continue;
91
+ return turns[i].assistantMessages.length === 0 ? id : null;
92
+ }
93
+ return null;
94
+ }
95
+ export function resolveWorkingTurn(input) {
96
+ const { turns } = input;
97
+ if (turns.length === 0)
98
+ return { workingTurnId: null, pendingTurnIds: [] };
99
+ let newestWithContent = -1;
100
+ for (let i = turns.length - 1; i >= 0; i--) {
101
+ if (turns[i].assistantMessages.length > 0) {
102
+ newestWithContent = i;
103
+ break;
104
+ }
105
+ }
106
+ const pendingIds = turns.slice(newestWithContent + 1).map((t) => t.userMessage.info.id);
107
+ const pick = (index) => ({
108
+ workingTurnId: turns[index].userMessage.info.id,
109
+ pendingTurnIds: turns.slice(index + 1).map((t) => t.userMessage.info.id),
110
+ });
111
+ const hint = input.hintMessageId ?? null;
112
+ if (hint) {
113
+ if (newestWithContent >= 0 && turns[newestWithContent].userMessage.info.id === hint) {
114
+ return pick(newestWithContent);
115
+ }
116
+ const idx = pendingIds.indexOf(hint);
117
+ if (idx >= 0)
118
+ return pick(newestWithContent + 1 + idx);
119
+ }
120
+ if (newestWithContent >= 0) {
121
+ const t = turns[newestWithContent];
122
+ const newest = t.assistantMessages[t.assistantMessages.length - 1];
123
+ // An errored reply (an abort, a provider failure) ended its turn even when
124
+ // its completion stamp has not reached this tab.
125
+ if (!completedAt(newest.info) && !newest.info.error)
126
+ return pick(newestWithContent);
127
+ }
128
+ // Rule 3, with the one fact the transcript cannot hold: the SERVER still has
129
+ // this prompt in its inbox, so the agent provably has not reached it.
130
+ //
131
+ // Picking the newest pending turn is right when the transcript is all we
132
+ // have — OpenCode parents its next step to the latest user message. It is
133
+ // WRONG for a prompt the control plane is still holding: `GET .../prompts`
134
+ // lists it `queued` / `waiting (older_prompt_pending)` / `delivering`, which
135
+ // is the server saying, in as many words, that it has not run yet.
136
+ //
137
+ // MEASURED, local stack 2026-08-26 (session 65216cc6): two sends 700ms
138
+ // apart, the first not yet streaming. `GET .../prompts` reported the second
139
+ // `queued`, then `waiting: older_prompt_pending`, then `delivering` — while
140
+ // the transcript rendered it at full opacity with no "Queued" label, because
141
+ // it had been made the WORKING turn here. The working projection's hint is
142
+ // null in that window (the inbox, not the ledger, is what decides `working`
143
+ // right after a send — `projectWorking`), so nothing else could correct it.
144
+ //
145
+ // Skipping the held ones only moves the shimmer; it never hides a turn. When
146
+ // every pending turn is held, the working indicator falls back to the newest
147
+ // turn with content (rule 4) and all of them read as queued — which is
148
+ // exactly the state the server is describing.
149
+ const unrun = input.unrunTurnIds;
150
+ if (pendingIds.length > 0) {
151
+ for (let i = turns.length - 1; i > newestWithContent; i--) {
152
+ if (!unrun?.has(turns[i].userMessage.info.id))
153
+ return pick(i);
154
+ }
155
+ }
156
+ // Rule 4 has no turn to fall back to when NOTHING in the transcript has
157
+ // assistant content and the server is holding every prompt: there is no
158
+ // "newest turn with content". Nothing is working, and every turn is pending
159
+ // — which is exactly what the inbox is saying. `pick(-1)` read `turns[-1]`
160
+ // and threw `Cannot read properties of undefined (reading 'userMessage')`,
161
+ // which the error boundary turned into "Something went wrong" over the whole
162
+ // session view (observed on a real thread whose tail page was all unanswered
163
+ // prompts).
164
+ if (newestWithContent < 0)
165
+ return { workingTurnId: null, pendingTurnIds: pendingIds };
166
+ return pick(newestWithContent);
167
+ }
168
+ //# sourceMappingURL=working-turn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-turn.js","sourceRoot":"","sources":["../../../../src/core/turns/segments/working-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AA8C/D,MAAM,WAAW,GAAG,CAAC,IAAuB,EAAsB,EAAE,CACjE,IAAI,CAAC,IAA2C,EAAE,SAAS,CAAC;AAU/D;;;8EAG8E;AAC9E,MAAM,UAAU,6BAA6B,CAAC,KAQ7C;IACC,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,wBAAwB;QAAE,OAAO,KAAK,CAAC;IAC5E,OAAO,CACL,KAAK,CAAC,eAAe;QACrB,CAAC,CAAC,KAAK,C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cAAc,EAAE,UAAU,EAAE,CAAC;IACtF,OAAO,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Linear-time string scanners for the tool-output parsers in `core/turns`.
3
+ *
4
+ * Each function replaces one regex that CodeQL flags as polynomial ReDoS
5
+ * (js/polynomial-redos) now that these parsers are exported library functions
6
+ * whose input is arbitrary tool output. Each returns exactly what the regex it
7
+ * replaces returned — `text-scan.test.ts` runs the old regex as the oracle over
8
+ * seeded random inputs — so call sites change their expression, not their
9
+ * behaviour. Internal: not exported from the package.
10
+ */
11
+ /** `s.replace(/\/+$/, '')` */
12
+ export declare function stripTrailingSlashes(s: string): string;
13
+ /** `s.replace(/^\/+|\/+$/g, '')` */
14
+ export declare function stripEdgeSlashes(s: string): string;
15
+ /** Capture of `/open([\s\S]*?)close/` for literal `open` and `close`, or null. */
16
+ export declare function textBetween(s: string, open: string, close: string): string | null;
17
+ /** Capture of `/<tag>\n?([\s\S]*?)\n?<\/tag>/`, or null. */
18
+ export declare function tagBodyTrimNewline(s: string, tag: string): string | null;
19
+ /** Capture of `/<tag([^>]*)>/`, or null. */
20
+ export declare function tagAttributes(s: string, tag: string): string | null;
21
+ /** Capture of `/<tag[^>]*>([\s\S]*?)<\/tag>/`, or null. */
22
+ export declare function tagBody(s: string, tag: string): string | null;
23
+ /** `s.replace(/<tag[^>]*>[\s\S]*?<\/tag>/g, '')` */
24
+ export declare function removeTagBlocks(s: string, tag: string): string;
25
+ /**
26
+ * Every capture of `/open(.*?)close/g`. `.` never crosses a line terminator,
27
+ * so every match lies inside one line: scan line by line.
28
+ */
29
+ export declare function textItems(s: string, open: string, close: string): string[];
30
+ /**
31
+ * Capture of `/:\s*(\{[\s\S]*\})\s*$/`: the `{…}` tail after the first colon
32
+ * that is followed (past whitespace) by `{`, when the string ends in `}`.
33
+ */
34
+ export declare function jsonTail(s: string): string | null;
35
+ /**
36
+ * `/content of .* with line numbers/i.test(s)` for `first` and `second` in
37
+ * place of the two phrases: `first`, then any run without a line terminator,
38
+ * then `second`, case-insensitively.
39
+ */
40
+ export declare function hasPhrasePair(s: string, first: string, second: string): boolean;
41
+ /**
42
+ * Capture of `/^\s*(?:L1|L2|…)\s*:\s*(.+?)\s*$/im` for the given labels.
43
+ *
44
+ * `^` is a line start, and every `\s*` may cross newlines. The value is the
45
+ * rest of the line where it starts, less trailing whitespace. When only
46
+ * whitespace follows the colon, the regex backtracks one character into the
47
+ * value; that case is reproduced below.
48
+ */
49
+ export declare function labelledValue(s: string, labels: readonly string[]): string | null;
50
+ /**
51
+ * Captures of `/\*\*(task-[a-z0-9]+)\*\*\s+(.+?)\s+—\s+(\w+)/` as
52
+ * `{ id, title, status }`, or null. Reproduces the regex's backtracking: the
53
+ * title may begin inside the whitespace run after the id when the first
54
+ * non-space character is the dash itself.
55
+ */
56
+ export declare function taskRow(s: string): {
57
+ id: string;
58
+ title: string;
59
+ status: string;
60
+ } | null;
61
+ /**
62
+ * `s.replace(/^(?:\s*Error:\s*)+/i, '').replace(/(?:\bError:\s*){2,}/gi, '')`
63
+ */
64
+ export declare function stripErrorPrefixes(s: string): string;
65
+ //# sourceMappingURL=text-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-scan.d.ts","sourceRoot":"","sources":["../../../src/core/turns/text-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAqCH,8BAA8B;AAC9B,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,oCAAoC;AACpC,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKjF;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EA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