@kabmo-labs/kabmo 0.54.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +479 -479
  3. package/dist/client/static/js/{Body-x5grdps8.js → Body-jfy4bhk2.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-248v9yzf.js → CsvGrid-4c5t668z.js} +1 -1
  5. package/dist/client/static/js/{DocxView-5we92k2h.js → DocxView-3x7whtvq.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-c6xmw4qq.js → DrawioView-tbkc5dfz.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-r3qxgqg6.js → HtmlPreview-egxkayya.js} +1 -1
  8. package/dist/client/static/js/{ImageView-cr4fea18.js → ImageView-swhzvw2p.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-j12z0djx.js → LayoutWrapper-sangsrt5.js} +2 -2
  10. package/dist/client/static/js/MergeDiffView-bv00y63x.js +1 -0
  11. package/dist/client/static/js/{Modal-cqceypcn.js → Modal-1fj8kvme.js} +16 -16
  12. package/dist/client/static/js/{PdfView-xdgn31cm.js → PdfView-0k2egsbz.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-ms6z44e2.js → SessionsView-t547rqeb.js} +1 -1
  14. package/dist/client/static/js/{SheetView-peqm9vft.js → SheetView-anb3gavm.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-rdf4wbzr.js → SvgPreview-e2wrj2hj.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-48z2x5vg.js → abnfDiagram-O67JEVCF-0rs86b68.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-n1pr5s6j.js → architectureDiagram-NJMV4G6O-0k3zzxz1.js} +3 -3
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-p19shaft.js → blockDiagram-BEXU5L5S-t1n1fx96.js} +1 -1
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-qcd46ts2.js → c4Diagram-YGBWAQC7-93b7eds9.js} +1 -1
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-scyhe133.js → classDiagram-v2-NBCMYWYE-bnf85z0f.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-srnnj3f7.js → cose-bilkent-JH36ORCC-e290161f.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-1zfrnyay.js → cynefinDiagram-VND7K2PF-s13ra9ag.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-hepk25pz.js → dagre-6A5THRUB-83wshh5e.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-wy2y0323.js → diagram-22UHCM2B-ywh4wqna.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-j904f93p.js → diagram-3UASUU5V-cb53z698.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-2mmxccm2.js → diagram-ATOU4E4O-btf55c44.js} +1 -1
  27. package/dist/client/static/js/{diagram-CDSNMT55-cfhk73ty.js → diagram-CDSNMT55-p6tbbm1n.js} +1 -1
  28. package/dist/client/static/js/{diagram-MLGK6HIB-ryf8j6hf.js → diagram-MLGK6HIB-6kzssf4y.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-8k5e36sd.js → diagram-MPIPVDR6-4v0yncvv.js} +1 -1
  30. package/dist/client/static/js/{dockerfile-1e7deann.js → dockerfile-r422htmd.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-5kkbbbhv.js → ebnfDiagram-ZINNZB2B-mw1gh30z.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-jqc4mzvc.js → elk-276RUBZZ-1pe786ap.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-kx15t6f0.js → erDiagram-OPXOYQCR-x7rk70q6.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-kfwaac44.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-3hv8pej4.js → ganttDiagram-FUAMR5RP-j3m5km4p.js} +1 -1
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-a4mq8vwz.js → gitGraphDiagram-X574FWY7-fd1kebdy.js} +1 -1
  37. package/dist/client/static/js/{index-fanhvjk8.js → index-004x0a3p.js} +1 -1
  38. package/dist/client/static/js/{index-exyg9sna.js → index-0mhxw0a1.js} +1 -1
  39. package/dist/client/static/js/{index-51wzt3ma.js → index-22frp78d.js} +1 -1
  40. package/dist/client/static/js/{index-x5c5yxhj.js → index-29b1ysz6.js} +1 -1
  41. package/dist/client/static/js/{index-br27jz2t.js → index-3hrvhyym.js} +1 -1
  42. package/dist/client/static/js/{index-kvker1ps.js → index-3k45gspr.js} +1 -1
  43. package/dist/client/static/js/{index-vxe4e903.js → index-473wm10a.js} +1 -1
  44. package/dist/client/static/js/{index-demg0p74.js → index-4acka5fn.js} +1 -1
  45. package/dist/client/static/js/{index-40ydm28n.js → index-4dzvjfkd.js} +1 -1
  46. package/dist/client/static/js/{index-n5194pe6.js → index-4fpyzg5e.js} +7 -7
  47. package/dist/client/static/js/{index-n4pm0hrh.js → index-4jg10xtp.js} +1 -1
  48. package/dist/client/static/js/{index-937bn0d2.js → index-4nyajpeg.js} +1 -1
  49. package/dist/client/static/js/{index-8hnem33f.js → index-5fxm2tpg.js} +1 -1
  50. package/dist/client/static/js/{index-pszsxhjr.js → index-72v57e07.js} +1 -1
  51. package/dist/client/static/js/{index-0j5ng1qc.js → index-7tsdw8wt.js} +1 -1
  52. package/dist/client/static/js/{index-k4kwrze2.js → index-8e66p2a7.js} +1 -1
  53. package/dist/client/static/js/{index-317v49ey.js → index-8n4qwd64.js} +2 -2
  54. package/dist/client/static/js/{index-w4dep7k6.js → index-bnamrpm6.js} +1 -1
  55. package/dist/client/static/js/{index-01rdknec.js → index-bxhszdcz.js} +1 -1
  56. package/dist/client/static/js/{index-n3cts2j1.js → index-cbbwq25c.js} +1 -1
  57. package/dist/client/static/js/{index-kevqayd9.js → index-dfha2z56.js} +1 -1
  58. package/dist/client/static/js/{index-e2y4hkps.js → index-drsy400d.js} +1 -1
  59. package/dist/client/static/js/{index-4kchzh9y.js → index-e4yj4kbe.js} +8 -8
  60. package/dist/client/static/js/{index-bf54x0w8.js → index-g84dwmvr.js} +1 -1
  61. package/dist/client/static/js/index-gedsa0z7.css +1 -0
  62. package/dist/client/static/js/{index-x3g8fwkc.js → index-hge0y4vn.js} +2 -2
  63. package/dist/client/static/js/{index-9cr6p86f.js → index-hgsjynb0.js} +1 -1
  64. package/dist/client/static/js/{index-0z7kerp1.js → index-j1prebvy.js} +2 -2
  65. package/dist/client/static/js/{index-rtfw07hy.js → index-jbaceghb.js} +1 -1
  66. package/dist/client/static/js/{index-v90zd3sq.js → index-jtyzeynv.js} +2 -2
  67. package/dist/client/static/js/{index-p8bta9ae.js → index-kbk0vmex.js} +4 -4
  68. package/dist/client/static/js/{index-40fdtqvw.js → index-q178zgxp.js} +1 -1
  69. package/dist/client/static/js/{index-eb43hnd3.js → index-q4t5j3x7.js} +1 -1
  70. package/dist/client/static/js/{index-xhcbaaga.js → index-qdabc51h.js} +3 -3
  71. package/dist/client/static/js/{index-jvn2xfpt.js → index-qrwjxqdh.js} +168 -166
  72. package/dist/client/static/js/{index-3kenmzbe.js → index-rm5b3kn8.js} +1 -1
  73. package/dist/client/static/js/{index-g3x4w48f.js → index-s4v3vcsn.js} +1 -1
  74. package/dist/client/static/js/{index-kz5d00m5.js → index-s6nv35dv.js} +1 -1
  75. package/dist/client/static/js/{index-1ye834yz.js → index-satnfvaz.js} +1 -1
  76. package/dist/client/static/js/{index-m85c740p.js → index-tcp5cp53.js} +1 -1
  77. package/dist/client/static/js/{index-9gddw5qy.js → index-zkef5q39.js} +1 -1
  78. package/dist/client/static/js/{infoDiagram-VRGFBTTK-wtnqb06v.js → infoDiagram-VRGFBTTK-1m0br602.js} +1 -1
  79. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-eta0jnvr.js → ishikawaDiagram-OU5B5YK6-zryzhpq6.js} +1 -1
  80. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-4e572kkp.js → journeyDiagram-ZHPQQLJL-6apqr7h4.js} +1 -1
  81. package/dist/client/static/js/{kanban-definition-PNTS6WVX-yrtnn4zy.js → kanban-definition-PNTS6WVX-am385c1e.js} +1 -1
  82. package/dist/client/static/js/{mermaid.core-195b0fb6.js → mermaid.core-k937exrm.js} +2 -2
  83. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-pphjnkvt.js → mindmap-definition-NLK3R4M7-hx8qq866.js} +1 -1
  84. package/dist/client/static/js/one-dark-pro-phxqe9mx.js +1 -0
  85. package/dist/client/static/js/one-light-vhwh499y.js +1 -0
  86. package/dist/client/static/js/{pegDiagram-GJSIUBJH-kgffb9p3.js → pegDiagram-GJSIUBJH-1hasj2h7.js} +1 -1
  87. package/dist/client/static/js/{pieDiagram-5QR66LMP-efech3mm.js → pieDiagram-5QR66LMP-x5nwff8r.js} +1 -1
  88. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-khf9cv3t.js → quadrantDiagram-O4NWA36T-gmrcr5jb.js} +1 -1
  89. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-ye68kdx2.js → railroadDiagram-XR7U4H2S-rdznfhfb.js} +1 -1
  90. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-3s4smnme.js → requirementDiagram-PLB6GJNP-v9wb3ppf.js} +1 -1
  91. package/dist/client/static/js/{rust-tdrnaxp3.js → rust-9cgnbbcs.js} +1 -1
  92. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-9pqd25mc.js → sankeyDiagram-IPEJSGJF-3p4ddd2h.js} +1 -1
  93. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-rka8ct43.js → sequenceDiagram-PO4LG4MO-wfcqxjfq.js} +1 -1
  94. package/dist/client/static/js/{sizeCapture-INFHLROL-g5wkzry8.js → sizeCapture-INFHLROL-g02k0k8x.js} +1 -1
  95. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gy1zab2j.js → stateDiagram-v2-GCMORJYK-7k449yvg.js} +1 -1
  96. package/dist/client/static/js/{swimlanes-2SLR337P-kr35nmd2.js → swimlanes-2SLR337P-zkf2bgm8.js} +1 -1
  97. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-qnhxxmjr.js → swimlanesDiagram-TC7HE7FX-yex8g4fx.js} +1 -1
  98. package/dist/client/static/js/{timeline-definition-EJHVYXUP-sg151mkc.js → timeline-definition-EJHVYXUP-qsfpjr1c.js} +1 -1
  99. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-f91g61p3.js → usecaseDiagram-POWQR4AR-b2vprhsr.js} +1 -1
  100. package/dist/client/static/js/{vennDiagram-UO4OBE2U-zbhr4eqf.js → vennDiagram-UO4OBE2U-x0ffeg2t.js} +1 -1
  101. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-6302414n.js → wardleyDiagram-VNRHLVJA-hsnhaf4f.js} +1 -1
  102. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-0a47th65.js → xychartDiagram-PMCCYNJV-90f9aadp.js} +1 -1
  103. package/package.json +5 -5
  104. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +1 -1
  105. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +5 -3
  106. package/src/client/components/workspace/chat-timeline/index.tsx +1 -1
  107. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +41 -21
  108. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +16 -3
  109. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +105 -2
  110. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +59 -8
  111. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -0
  112. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.test.tsx +54 -0
  113. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.tsx +72 -0
  114. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.test.tsx +91 -0
  115. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +8 -2
  116. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +9 -0
  117. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +16 -1
  118. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.test.tsx +59 -0
  119. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +11 -1
  120. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.test.ts +81 -0
  121. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.ts +139 -0
  122. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +14 -2
  123. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +22 -0
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +14 -0
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +36 -1
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +10 -5
  127. package/src/client/data/settings/omp-schema.json +445 -165
  128. package/src/client/hooks/chat/timeline/ask-frame-buckets.ts +14 -4
  129. package/src/client/hooks/chat/timeline/ask-frames-context.ts +3 -1
  130. package/src/client/hooks/chat/timeline/ask-frames-grouped.test.ts +31 -0
  131. package/src/client/hooks/chat/timeline/ask-frames.ts +12 -3
  132. package/src/client/hooks/chat/timeline/send-props.ts +1 -2
  133. package/src/server/lib/harness/acp/client-capabilities.test.ts +3 -2
  134. package/src/server/lib/sessions/last-opened.server.test.ts +26 -7
  135. package/src/server/lib/sessions/last-opened.server.ts +19 -4
  136. package/src/server/routes/fs/raw.test.ts +33 -0
  137. package/src/server/routes/fs/raw.ts +31 -11
  138. package/src/shared/lib/chat/ask-questions.test.ts +29 -0
  139. package/src/shared/lib/chat/ask-questions.ts +44 -3
  140. package/src/shared/lib/chat/ask-results.test.ts +66 -0
  141. package/src/shared/lib/chat/ask-results.ts +58 -0
  142. package/src/shared/lib/chat/timeline/block-chrome.ts +4 -4
  143. package/src/shared/lib/chat/timeline/tool-phrases.test.ts +4 -0
  144. package/src/shared/lib/chat/timeline/tool-phrases.ts +2 -0
  145. package/src/shared/lib/models/provider/glyph.test.ts +13 -11
  146. package/src/shared/lib/models/provider/glyph.ts +1 -0
  147. package/src/shared/lib/models/provider/label.ts +3 -0
  148. package/src/shared/lib/omp/config/schema-releases-19-3.test.ts +64 -0
  149. package/src/shared/lib/omp/config/schema-releases.test.ts +6 -4
  150. package/src/shared/lib/omp/session/wait-idle.test.ts +12 -2
  151. package/src/shared/lib/omp/session/wait-idle.ts +11 -6
  152. package/tsconfig.json +6 -0
  153. package/dist/client/static/js/MergeDiffView-y0we0194.js +0 -1
  154. package/dist/client/static/js/flowDiagram-KWPJA3E3-dpjz82p8.js +0 -1
  155. package/dist/client/static/js/index-4m2d73m3.css +0 -1
  156. package/dist/client/static/js/one-dark-pro-asy2qj2p.js +0 -1
  157. package/dist/client/static/js/one-light-fya1pbbx.js +0 -1
@@ -26,7 +26,7 @@
26
26
 
27
27
  import type { ExtensionUiDialogRequest } from '@kabmo-labs/kabmo-chat/contracts/agent';
28
28
  import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
29
- import { groupAskFrames } from '@/shared/lib/chat/ask-questions';
29
+ import { askQuestionForTitle, groupAskFrames } from '@/shared/lib/chat/ask-questions';
30
30
 
31
31
  export interface BucketedFrames {
32
32
  /** One bucket per question, in form order. */
@@ -53,10 +53,20 @@ export function bucketAskFrames(
53
53
  const unplaced: ExtensionUiDialogRequest[] = [];
54
54
  for (const frame of frames) {
55
55
  if (Array.isArray(frame.questions) && frame.questions.length > 0) {
56
+ const indexes = new Set<number>();
56
57
  for (const grouped of frame.questions) {
57
- const index = questions.findIndex((question) => question.id === grouped.id);
58
- if (index >= 0) placed[index].push(frame);
59
- else walking.push(frame);
58
+ const byId = questions.findIndex((question) => question.id === grouped.id);
59
+ const index = byId >= 0 ? byId : askQuestionForTitle(questions, grouped.question);
60
+ if (index >= 0) indexes.add(index);
61
+ }
62
+ // A grouped frame covers every question it names. An ACP elicitation's
63
+ // ids are schema names (`q0`), so the tool call's question text is often
64
+ // the only shared key; if even that missed, the first bucket draws the
65
+ // card and `GroupedAsk` renders the frame's whole question set.
66
+ if (indexes.size === 0) {
67
+ if (placed[0]) placed[0].push(frame);
68
+ } else {
69
+ for (const index of indexes) placed[index].push(frame);
60
70
  }
61
71
  continue;
62
72
  }
@@ -48,7 +48,9 @@ export interface AskFramesHandle {
48
48
  orphanAsks: AskFramesSplit['orphanAsks'];
49
49
  /** The ask's whole-form dialog, when it has one (see `formByTool`). */
50
50
  formByTool: AskFramesSplit['formByTool'];
51
- /** Answer one ask dialog and drop it from the pending queue. */
51
+ /** The chat's harness. An ACP chat has no ask dialog frames; an `ask`
52
+ * tool call there answers from the next user message, not the card. */
53
+ harness?: string; /** Answer one ask dialog and drop it from the pending queue. */
52
54
  respond: (request: ExtensionUiDialogRequest, response: ExtensionDialogResponse) => void;
53
55
  }
54
56
 
@@ -104,6 +104,37 @@ describe('splitAskFrames with a grouped ask frame', () => {
104
104
  expect(split.modalRequest).toBeNull();
105
105
  });
106
106
 
107
+ test('an ACP elicitation claims its tool call by toolCallId', () => {
108
+ // opencode sends `question` as a normal tool call and the form separately;
109
+ // its schema ids (`q0`) are not the tool's arguments. The explicit
110
+ // toolCallId is the only exact key, and it must win over text matching.
111
+ const tool = {
112
+ id: 'call-question',
113
+ type: 'custom' as const,
114
+ title: 'question',
115
+ name: 'question',
116
+ status: 'running' as const,
117
+ input: { questions: [{ question: 'Which color should I use?', options: [{ label: 'Red' }, { label: 'Blue' }] }] },
118
+ };
119
+ const frame: ExtensionUiDialogRequest = {
120
+ type: 'extension_ui_request',
121
+ id: '9',
122
+ method: 'ask',
123
+ title: 'Questions',
124
+ toolCallId: 'call-question',
125
+ questions: [
126
+ { id: 'q0', question: 'Which color should I use?', options: [{ label: 'Red' }, { label: 'Blue' }] },
127
+ { id: 'q0_custom', question: 'Type your own answer', options: [] },
128
+ ],
129
+ };
130
+ const history = { id: 'm1', role: 'ai', content: '', toolCalls: [tool] } as unknown as ChatMessageData;
131
+
132
+ const split = splitAskFrames([history], [frame], true);
133
+ expect(split.framesByTool.get('call-question')?.flat()).toEqual([frame]);
134
+ expect(split.orphanAsks).toEqual([]);
135
+ expect(split.modalRequest).toBeNull();
136
+ });
137
+
107
138
  test('a grouped frame matches its card by question text when ids differ', () => {
108
139
  const retitled: ExtensionUiDialogRequest = {
109
140
  ...grouped,
@@ -105,10 +105,19 @@ export function splitAskFrames(
105
105
  continue;
106
106
  }
107
107
  if (grouped) {
108
+ // The ACP elicitation names the tool call outright; that is the exact
109
+ // owner and it survives a schema whose question text differs from the
110
+ // tool's own arguments.
111
+ const addressed = typeof request.toolCallId === 'string' ? request.toolCallId : '';
108
112
  const ids = new Set(grouped.map((question) => question.id).filter(Boolean));
109
- let groupedOwner = [...openAsks].reverse().find((candidate) =>
110
- candidate.questions.some((question) => question.id && ids.has(question.id)),
111
- );
113
+ let groupedOwner = addressed
114
+ ? [...openAsks].reverse().find((candidate) => candidate.toolId === addressed)
115
+ : undefined;
116
+ if (!groupedOwner) {
117
+ groupedOwner = [...openAsks].reverse().find((candidate) =>
118
+ candidate.questions.some((question) => question.id && ids.has(question.id)),
119
+ );
120
+ }
112
121
  // The id walk is the exact key, but it is not the only one omp gives us:
113
122
  // a call whose questions carry no `id` (measured on 2 of 161 real `ask`
114
123
  // calls) yields an empty id set, and the frame then matched nothing and
@@ -103,5 +103,4 @@ export interface ChatTimelineSendResult {
103
103
  text: string,
104
104
  attachments: Attachment[],
105
105
  options?: { model?: QueuedMessageModel | null; harness?: string | null },
106
- ) => Promise<PromptDispatchResult>;
107
- }
106
+ ) => Promise<PromptDispatchResult>;}
@@ -25,10 +25,11 @@ describe('client capabilities', () => {
25
25
  expect(KABMO_CLIENT_CAPABILITIES.session.notices).toEqual({});
26
26
  });
27
27
 
28
- test('does not advertise surfaces with no bridge', () => {
28
+ test('advertises the form elicitation the ask card can draw, but not URL mode', () => {
29
29
  const advertised = KABMO_CLIENT_CAPABILITIES as Record<string, unknown>;
30
30
  expect(advertised.terminal).toBeUndefined();
31
- expect(advertised.elicitation).toBeUndefined();
31
+ expect(advertised.elicitation).toEqual({ form: {} });
32
+ expect((advertised.elicitation as { url?: unknown }).url).toBeUndefined();
32
33
  });
33
34
  });
34
35
 
@@ -30,6 +30,8 @@ import {
30
30
  const SESSION_ID = '42';
31
31
  const CLIENT = '11111111-2222-4333-8444-555555555555';
32
32
  const OTHER_CLIENT = '99999999-8888-4777-8666-555555555555';
33
+ /** No session is held by another process in these cases; ownership has its own. */
34
+ const free = async () => false;
33
35
  let db: DbClient;
34
36
  let priorMock: string | undefined;
35
37
 
@@ -58,13 +60,13 @@ afterAll(() => {
58
60
 
59
61
  describe('lastOpenedSession', () => {
60
62
  test('no record yet means no session to restore', async () => {
61
- expect(await lastOpenedSession(CLIENT)).toBeNull();
63
+ expect(await lastOpenedSession(CLIENT, free)).toBeNull();
62
64
  });
63
65
 
64
66
  test('a recorded session that still exists is restored', async () => {
65
67
  expect(await recordLastOpenedSession(CLIENT, SESSION_ID)).toBe(true);
66
68
  expect(await readLastOpenedSessionId(CLIENT)).toBe(SESSION_ID);
67
- expect(await lastOpenedSession(CLIENT)).toBe(SESSION_ID);
69
+ expect(await lastOpenedSession(CLIENT, free)).toBe(SESSION_ID);
68
70
  });
69
71
 
70
72
  test('two clients keep separate pointers at one console', async () => {
@@ -72,15 +74,32 @@ describe('lastOpenedSession', () => {
72
74
 
73
75
  // The second install never opened anything, so it restores the landing even
74
76
  // though the first install has a record.
75
- expect(await lastOpenedSession(OTHER_CLIENT)).toBeNull();
77
+ expect(await lastOpenedSession(OTHER_CLIENT, free)).toBeNull();
76
78
  expect(await readLastOpenedSessionId(OTHER_CLIENT)).toBeNull();
77
79
  });
78
80
 
81
+ // A session another instance is running must not be restored HERE: the tab
82
+ // would be redirected to that owner, and a password-protected owner turns the
83
+ // shell's launch into a navigation the user cannot complete — the reported
84
+ // reload loop. The row is NOT deleted: the session is valid, just unavailable
85
+ // until the writer lets it go.
86
+ test('a session another instance is writing is skipped and kept', async () => {
87
+ await recordLastOpenedSession(CLIENT, SESSION_ID);
88
+ expect(await lastOpenedSession(CLIENT, async () => true)).toBeNull();
89
+ expect(await readLastOpenedSessionId(CLIENT)).toBe(SESSION_ID);
90
+ });
91
+
92
+ test('the same record restores once the other instance releases it', async () => {
93
+ await recordLastOpenedSession(CLIENT, SESSION_ID);
94
+ expect(await lastOpenedSession(CLIENT, async () => true)).toBeNull();
95
+ expect(await lastOpenedSession(CLIENT, free)).toBe(SESSION_ID);
96
+ });
97
+
79
98
  test('an archived session is refused and its record cleared', async () => {
80
99
  await recordLastOpenedSession(CLIENT, SESSION_ID);
81
100
  await db.run('INSERT OR IGNORE INTO archived_sessions (session_id) VALUES (?)', [SESSION_ID]);
82
101
 
83
- expect(await lastOpenedSession(CLIENT)).toBeNull();
102
+ expect(await lastOpenedSession(CLIENT, free)).toBeNull();
84
103
  expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
85
104
  });
86
105
 
@@ -88,7 +107,7 @@ describe('lastOpenedSession', () => {
88
107
  await recordLastOpenedSession(CLIENT, SESSION_ID);
89
108
  await db.run('INSERT OR IGNORE INTO deleted_sessions (session_id) VALUES (?)', [SESSION_ID]);
90
109
 
91
- expect(await lastOpenedSession(CLIENT)).toBeNull();
110
+ expect(await lastOpenedSession(CLIENT, free)).toBeNull();
92
111
  expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
93
112
  });
94
113
 
@@ -96,14 +115,14 @@ describe('lastOpenedSession', () => {
96
115
  await recordLastOpenedSession(CLIENT, SESSION_ID);
97
116
  await db.run('DELETE FROM sessions WHERE id = ?', [SESSION_ID]);
98
117
 
99
- expect(await lastOpenedSession(CLIENT)).toBeNull();
118
+ expect(await lastOpenedSession(CLIENT, free)).toBeNull();
100
119
  expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
101
120
  });
102
121
 
103
122
  test('clearing leaves the next launch on the empty workspace', async () => {
104
123
  await recordLastOpenedSession(CLIENT, SESSION_ID);
105
124
  await clearLastOpenedSession(CLIENT);
106
- expect(await lastOpenedSession(CLIENT)).toBeNull();
125
+ expect(await lastOpenedSession(CLIENT, free)).toBeNull();
107
126
  });
108
127
  });
109
128
 
@@ -46,6 +46,7 @@ import { isMockMode } from '@kabmo-labs/kabmo-runtime-flags';
46
46
  import { isSinglePathSegment } from '@kabmo-labs/kabmo-paths/path-segment';
47
47
  import { getDb } from '@/server/db.server';
48
48
  import { isSessionArchived, sessionExists } from '@/server/lib/sessions/resolve.server';
49
+ import { isSessionOwnedElsewhere } from '@/server/lib/omp/session/ownership.server';
49
50
 
50
51
  /** The stored id for one client, or null when there is none. */
51
52
  export async function readLastOpenedSessionId(clientId: string): Promise<string | null> {
@@ -119,11 +120,25 @@ async function sessionCanOpen(sessionId: string): Promise<boolean> {
119
120
  *
120
121
  * A stale record is DELETED, not merely skipped: every later launch would
121
122
  * otherwise repeat the same check for a session that can never come back.
123
+ *
124
+ * A session another process is WRITING is skipped but KEPT. Restoring it would
125
+ * bounce the tab to the owning instance — and when that peer is a
126
+ * password-protected Kabmo, the shell's launch has already been consumed by a
127
+ * navigation the user cannot complete, which reads as a reload loop on every
128
+ * start. The answer is the empty workspace, and the next launch after the owner
129
+ * lets the session go restores it again: the record is still valid, only
130
+ * unavailable now.
122
131
  */
123
- export async function lastOpenedSession(clientId: string): Promise<string | null> {
132
+ export async function lastOpenedSession(
133
+ clientId: string,
134
+ ownedElsewhere: (sessionId: string) => Promise<boolean> = isSessionOwnedElsewhere,
135
+ ): Promise<string | null> {
124
136
  const sessionId = await readLastOpenedSessionId(clientId);
125
137
  if (!sessionId) return null;
126
- if (await sessionCanOpen(sessionId)) return sessionId;
127
- await clearLastOpenedSession(clientId);
128
- return null;
138
+ if (!(await sessionCanOpen(sessionId))) {
139
+ await clearLastOpenedSession(clientId);
140
+ return null;
141
+ }
142
+ if (await ownedElsewhere(sessionId)) return null;
143
+ return sessionId;
129
144
  }
@@ -39,6 +39,14 @@ async function raw(relPath: string, init?: RequestInit) {
39
39
  return res;
40
40
  }
41
41
 
42
+ /** An ABSOLUTE reference: `root` is deliberately absent. */
43
+ async function rawReference(reference: string) {
44
+ const url = new URL('http://localhost/api/fs/raw');
45
+ url.searchParams.set('path', reference);
46
+ const res = await serveRawFile({ request: new Request(url) } as never);
47
+ return res;
48
+ }
49
+
42
50
  function write(relPath: string, bytes: Uint8Array) {
43
51
  const target = path.join(DIR, relPath);
44
52
  fs.mkdirSync(path.dirname(target), { recursive: true });
@@ -117,6 +125,31 @@ describe('fs raw route', () => {
117
125
  expect(res.headers.get('content-disposition')).toContain('report.pdf');
118
126
  });
119
127
 
128
+ // An ACP `read_file` names its file ABSOLUTELY (`locations[].path`), and the
129
+ // reader paints an image from this route. Stripping the leading `/` pointed
130
+ // it at `<root>/Users/…` — a 404 over a file that exists.
131
+ test('an absolute path inside an allowed root is served', async () => {
132
+ const target = write('abs.png', new Uint8Array([0x89, 0x50, 0x4e, 0x47]));
133
+ const res = await rawReference(target);
134
+
135
+ expect(res.status).toBe(200);
136
+ expect(res.headers.get('content-type')).toBe('image/png');
137
+ });
138
+
139
+ test('a file:// reference is served under the same allow-list', async () => {
140
+ const target = write('abs-ref.png', new Uint8Array([0x89, 0x50, 0x4e, 0x47]));
141
+ const res = await rawReference(`file://${target}`);
142
+
143
+ expect(res.status).toBe(200);
144
+ });
145
+
146
+ test('an absolute path outside every allowed root is refused', async () => {
147
+ // `/etc/hosts` exists on every POSIX host; it is not on the allow-list.
148
+ const res = await rawReference('/etc/hosts');
149
+
150
+ expect(res.status).toBe(403);
151
+ });
152
+
120
153
  // The HTML preview loads a page's relative assets through this route, inside
121
154
  // a sandboxed frame where the browser enforces strict MIME checking: a
122
155
  // stylesheet served as `application/octet-stream` is refused and the page
@@ -4,9 +4,10 @@
4
4
  */
5
5
 
6
6
  import { json, type LoaderFunctionArgs } from '@kabmo-labs/kabmo-http';
7
+ import path from 'path';
7
8
  import { errorResponse } from '@/server/lib/route-adapter';
8
9
  import { isMockMode } from '@kabmo-labs/kabmo-runtime-flags';
9
- import { getDefaultFsRoot, resolveRoot, resolveWithinRoot } from '@kabmo-labs/kabmo-workspace/root/root';
10
+ import { getDefaultFsRoot, resolveReferencedPath, resolveRoot, resolveWithinRoot } from '@kabmo-labs/kabmo-workspace/root/root';
10
11
  import { EDITOR_MAX_BYTES_BY_EXT, unsupportedEditorMessage } from '@kabmo-labs/kabmo-fs/media/file-kind';
11
12
  import { getFileExtension, getRawContentType } from '@kabmo-labs/kabmo-fs/media/mime';
12
13
 
@@ -26,7 +27,10 @@ import { getFileExtension, getRawContentType } from '@kabmo-labs/kabmo-fs/media/
26
27
  *
27
28
  * Scope resolution is identical to `/api/fs/read` (same root allow-list, same
28
29
  * `resolveWithinRoot` containment), so a path that reads as text can be served
29
- * as bytes and vice versa.
30
+ * as bytes and vice versa. An ABSOLUTE reference is resolved through
31
+ * `resolveReferencedPath` (the drop allow-list) instead of being made relative
32
+ * to `root`: an ACP `locations[].path` is absolute, and stripping its leading
33
+ * `/` pointed the `<img>` at `<root>/Users/…` — a 404 over a file that exists.
30
34
  */
31
35
  export async function serveRawFile({ request }: LoaderFunctionArgs) {
32
36
  const url = new URL(request.url);
@@ -36,18 +40,34 @@ export async function serveRawFile({ request }: LoaderFunctionArgs) {
36
40
  return json({ error: 'Missing path' }, { status: 400 });
37
41
  }
38
42
 
39
- let baseDir = await resolveRoot(url.searchParams.get('root'), await getDefaultFsRoot(isMockMode()));
43
+ // An absolute path is a REFERENCE, not a path relative to `root`: resolve it
44
+ // against the same allow-list a dropped file uses. A relative one keeps the
45
+ // Files panel's scoped resolution (`root` + nested `repo`).
46
+ const reference = /^file:\/\//i.test(filePath)
47
+ ? filePath.replace(/^file:\/\//, '')
48
+ : path.isAbsolute(filePath)
49
+ ? filePath
50
+ : null;
40
51
 
41
- const repo = url.searchParams.get('repo');
42
- if (repo && repo !== '.') {
43
- const repoDir = resolveWithinRoot(baseDir, repo);
44
- if (repoDir) {
45
- baseDir = repoDir;
52
+ let cleanPath: string;
53
+ let fullPath: string | null;
54
+ if (reference) {
55
+ cleanPath = reference;
56
+ fullPath = await resolveReferencedPath(reference);
57
+ } else {
58
+ let baseDir = await resolveRoot(url.searchParams.get('root'), await getDefaultFsRoot(isMockMode()));
59
+
60
+ const repo = url.searchParams.get('repo');
61
+ if (repo && repo !== '.') {
62
+ const repoDir = resolveWithinRoot(baseDir, repo);
63
+ if (repoDir) {
64
+ baseDir = repoDir;
65
+ }
46
66
  }
47
- }
48
67
 
49
- const cleanPath = filePath.replace(/^\/+/, '');
50
- const fullPath = resolveWithinRoot(baseDir, cleanPath);
68
+ cleanPath = filePath.replace(/^\/+/, '');
69
+ fullPath = resolveWithinRoot(baseDir, cleanPath);
70
+ }
51
71
 
52
72
  if (!fullPath) {
53
73
  return json({ error: 'Invalid path' }, { status: 403 });
@@ -9,6 +9,7 @@ import type { ToolCallData } from '@/shared/types';
9
9
  import type { ExtensionUiDialogRequest } from '@kabmo-labs/kabmo-chat/contracts/agent';
10
10
  import {
11
11
  groupAskFrames,
12
+ isExternalAskTool,
12
13
  parseAskQuestions,
13
14
  normalizeAskText,
14
15
  } from '@/shared/lib/chat/ask-questions';
@@ -54,6 +55,34 @@ describe('parseAskQuestions', () => {
54
55
  const questions = parseAskQuestions(askTool({ questions: [{ id: 'a' }, { id: 'b', question: ' Keep me ' }] }));
55
56
  expect(questions).toEqual([expect.objectContaining({ id: 'b', question: 'Keep me' })]);
56
57
  });
58
+
59
+ test('reads a non-omp ask, including claude’s multiSelect and a single question', () => {
60
+ const claude = parseAskQuestions(askTool(
61
+ { questions: [{ header: 'Approach', question: 'Which strategy?', multiSelect: true, options: [{ label: 'Balanced' }] }] },
62
+ { name: 'AskUserQuestion' },
63
+ ));
64
+ expect(claude).toEqual([expect.objectContaining({ header: 'Approach', question: 'Which strategy?', multi: true })]);
65
+
66
+ const single = parseAskQuestions(askTool(
67
+ { question: 'Lanjut tes yang mana?', options: ['Image generation', 'Selesai'] },
68
+ { name: 'ask_question' },
69
+ ));
70
+ expect(single).toEqual([expect.objectContaining({
71
+ question: 'Lanjut tes yang mana?',
72
+ options: [{ label: 'Image generation' }, { label: 'Selesai' }],
73
+ })]);
74
+ });
75
+
76
+ test('keeps the legacy omp single-question payload out of the ask card', () => {
77
+ expect(parseAskQuestions(askTool({ question: 'single legacy shape', options: ['A'] }))).toEqual([]);
78
+ });
79
+
80
+ test('classifies only the adapter ask names as external', () => {
81
+ for (const name of ['ask_question', 'question', 'AskUserQuestion', 'ask_user', 'ask_user_question', 'request_user_input']) {
82
+ expect(isExternalAskTool({ ...askTool(undefined), name })).toBe(true);
83
+ }
84
+ expect(isExternalAskTool(askTool(undefined))).toBe(false);
85
+ });
57
86
  });
58
87
 
59
88
  describe('the 18.18.3 html form shape', () => {
@@ -108,10 +108,28 @@ function readOption(raw: unknown): AskOption | null {
108
108
  };
109
109
  }
110
110
 
111
- /** True for a tool call that is omp's `ask` tool. */
111
+ /** True for a tool call whose question an ask frame may answer. */
112
112
  export function isAskToolCall(tool: ToolCallData): boolean {
113
113
  const name = typeof tool.name === 'string' && tool.name ? tool.name : tool.type;
114
- return name === 'ask' || tool.title === 'ask';
114
+ return name === 'ask' || tool.title === 'ask' || isExternalAskTool(tool);
115
+ }
116
+
117
+ /** The names non-omp ACP adapters use for their own ask tool. The panel table
118
+ * maps every one to the ask card; the raw name is kept so the card knows the
119
+ * harness exposes no dialog and cannot be waited on. */
120
+ const EXTERNAL_ASK_NAMES: Readonly<Record<string, true>> = {
121
+ ask_question: true,
122
+ question: true,
123
+ askuserquestion: true,
124
+ ask_user: true,
125
+ ask_user_question: true,
126
+ request_user_input: true,
127
+ };
128
+
129
+ /** True when this call is an ACP agent's own ask, not omp's `ask`. */
130
+ export function isExternalAskTool(tool: ToolCallData): boolean {
131
+ const name = typeof tool.name === 'string' && tool.name ? tool.name : '';
132
+ return EXTERNAL_ASK_NAMES[name.toLowerCase()] === true;
115
133
  }
116
134
 
117
135
  /**
@@ -225,12 +243,35 @@ export function parseAskQuestions(tool: ToolCallData): AskQuestion[] {
225
243
  options: Array.isArray(question.options)
226
244
  ? question.options.map(readOption).filter((option): option is AskOption => option !== null)
227
245
  : [],
228
- multi: question.multi === true,
246
+ // claude's AskUserQuestion spells the flag `multiSelect`, antigravity
247
+ // `is_multi_select`; omp spells it `multi`.
248
+ multi: question.multi === true || question.multiSelect === true || question.is_multi_select === true,
229
249
  recommended: typeof question.recommended === 'number' ? question.recommended : undefined,
230
250
  kind: 'choice',
231
251
  });
232
252
  }
233
253
 
254
+ // A non-omp adapter may spell one question as a single object rather than
255
+ // an array. That shape never means anything for omp's own `ask` (the legacy
256
+ // single-question payload is deliberately ignored), so it is read only for
257
+ // the external names — the difference between a question card and raw JSON.
258
+ if (questions.length === 0 && record && isExternalAskTool(tool)) {
259
+ const text = typeof record.question === 'string' ? record.question.trim() : '';
260
+ const options = Array.isArray(record.options)
261
+ ? record.options
262
+ : Array.isArray(record.choices) ? record.choices : [];
263
+ if (text) {
264
+ questions.push({
265
+ id: typeof record.id === 'string' ? record.id : undefined,
266
+ header: typeof record.header === 'string' && record.header.trim() ? record.header.trim() : undefined,
267
+ question: text,
268
+ options: options.map(readOption).filter((option): option is AskOption => option !== null),
269
+ multi: record.multi === true || record.multiSelect === true || record.is_multi_select === true,
270
+ kind: 'choice',
271
+ });
272
+ }
273
+ }
274
+
234
275
  return questions;
235
276
  }
236
277
 
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The result shapes the ACP adapters actually send.
8
+ *
9
+ * opencode records the picked labels positionally in
10
+ * `rawOutput.metadata.answers` and prints `"question"="answer"` prose; claude
11
+ * only prints the prose. Both completed the tool, so the card must show the
12
+ * answer it already delivered instead of redrawing the question as unanswered.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+ import { parseAskResult } from './ask-results';
17
+ import type { ToolCallData } from '@/shared/types';
18
+
19
+ const QUESTIONS = [
20
+ { question: 'Koneksi ini buat ngoding stack apa?', header: 'Stack', options: [{ label: 'TypeScript / JS' }, { label: 'Go' }] },
21
+ { question: 'Gaya respons yang kamu mau?', header: 'Gaya Respons', options: [{ label: 'Singkat & langsung (Recommended)' }, { label: 'Detail' }] },
22
+ { question: 'Mau aku lanjut ngerjain apa setelah ini?', header: 'Lanjutan', options: [{ label: 'Cek repo/folder ini dulu' }] },
23
+ ];
24
+
25
+ function askTool(overrides: Record<string, unknown>): ToolCallData {
26
+ return {
27
+ id: 'call_question',
28
+ type: 'other',
29
+ title: 'question',
30
+ name: 'question',
31
+ status: 'success',
32
+ input: { questions: QUESTIONS },
33
+ ...overrides,
34
+ } as ToolCallData;
35
+ }
36
+
37
+ describe('parseAskResult', () => {
38
+ test('opencode: positional metadata.answers align with the questions', () => {
39
+ const answers = parseAskResult(askTool({
40
+ details: {
41
+ answers: [
42
+ ['TypeScript / JS'],
43
+ ['Singkat & langsung (Recommended)'],
44
+ ['Cek repo/folder ini dulu'],
45
+ ],
46
+ },
47
+ }), QUESTIONS as never);
48
+ expect(answers).toEqual([
49
+ { selectedOptions: ['TypeScript / JS'], timedOut: false },
50
+ { selectedOptions: ['Singkat & langsung (Recommended)'], timedOut: false },
51
+ { selectedOptions: ['Cek repo/folder ini dulu'], timedOut: false },
52
+ ]);
53
+ });
54
+
55
+ test('opencode/claude: the `"question"="answer"` prose is parsed when metadata is absent', () => {
56
+ const answers = parseAskResult(askTool({
57
+ name: 'AskUserQuestion',
58
+ output: 'Your questions have been answered: "Koneksi ini buat ngoding stack apa?"="TypeScript / JS", "Gaya respons yang kamu mau?"="Singkat & langsung (Recommended)", "Mau aku lanjut ngerjain apa setelah ini?"="Cek repo/folder ini dulu". You can now continue with the user\'s answers in mind.',
59
+ }), QUESTIONS as never);
60
+ expect(answers.map((answer) => answer?.selectedOptions[0])).toEqual([
61
+ 'TypeScript / JS',
62
+ 'Singkat & langsung (Recommended)',
63
+ 'Cek repo/folder ini dulu',
64
+ ]);
65
+ });
66
+ });
@@ -55,6 +55,33 @@ function toAnswer(value: string, multi: boolean): AskAnswer {
55
55
  */
56
56
  /** The form result's prose: the submitted JSON is the last `{…}` in the text. */
57
57
  const FORM_RESULT = /(?:User answers:|submitted the form's current values:)[\s\S]*?(\{[\s\S]*\})\s*$/;
58
+ /** opencode and claude both print `"question"="answer"` pairs after a marker. */
59
+ const ANSWER_PAIRS = /"((?:[^"\\]|\\.)*)"\s*=\s*"((?:[^"\\]|\\.)*)"/g;
60
+ const ANSWER_PAIRS_MARKER = /(?:answered your questions|questions have been answered)/i;
61
+
62
+ function unescapePair(value: string): string {
63
+ return value.replace(/\\(["\\])/g, '$1');
64
+ }
65
+
66
+ /** One picked/custom answer in the `"Q"="A"` prose shape. */
67
+ function fromProseAnswer(question: AskQuestion, raw: string): AskAnswer | null {
68
+ const answer = unescapePair(raw).trim();
69
+ if (!answer) return null;
70
+ const other = OTHER_ANSWER.exec(answer);
71
+ if (other) return { selectedOptions: [], customInput: other[1].trim() || undefined };
72
+ const parts = question.multi ? answer.split(', ') : [answer];
73
+ const selectedOptions: string[] = [];
74
+ const typed: string[] = [];
75
+ for (const part of parts) {
76
+ const label = question.options.find((option) => option.label === part.trim())?.label;
77
+ if (label) selectedOptions.push(label);
78
+ else if (part.trim()) typed.push(part.trim());
79
+ }
80
+ if (selectedOptions.length > 0 || question.options.length === 0) {
81
+ return { selectedOptions, ...(typed.length > 0 ? { customInput: typed.join(', ') } : {}) };
82
+ }
83
+ return { selectedOptions: [], customInput: typed.join(', ') || answer };
84
+ }
58
85
 
59
86
  function parseAskOutputAnswers(output: string, questions: AskQuestion[]): (AskAnswer | null)[] {
60
87
  const answers = questions.map((): AskAnswer | null => null);
@@ -76,6 +103,24 @@ function parseAskOutputAnswers(output: string, questions: AskQuestion[]): (AskAn
76
103
  }
77
104
  }
78
105
 
106
+ if (ANSWER_PAIRS_MARKER.test(text)) {
107
+ let cursor = 0;
108
+ let matched = false;
109
+ for (const pair of text.matchAll(ANSWER_PAIRS)) {
110
+ const questionText = unescapePair(pair[1]);
111
+ let index = questions.findIndex((question) => normalizeAskText(question.question) === normalizeAskText(questionText));
112
+ if (index === -1) index = questions.findIndex((question) => question.header && normalizeAskText(question.header) === normalizeAskText(questionText));
113
+ if (index === -1) index = cursor;
114
+ cursor = index + 1;
115
+ const answer = fromProseAnswer(questions[index], pair[2]);
116
+ if (answer) {
117
+ answers[index] = answer;
118
+ matched = true;
119
+ }
120
+ }
121
+ if (matched) return answers;
122
+ }
123
+
79
124
  const byId = new Map<string, AskAnswer>();
80
125
  for (const line of text.split('\n')) {
81
126
  const match = ANSWER_LINE.exec(line.trim());
@@ -161,6 +206,19 @@ export function parseAskResult(tool: ToolCallData, questions: AskQuestion[]): (A
161
206
  const formAnswers = Array.isArray(details.answers) ? (details.answers as Record<string, unknown>[]) : null;
162
207
  if (formAnswers && formAnswers.length > 0) {
163
208
  const timedOut = details.timedOut === true;
209
+ // opencode's question tool records `metadata.answers` as one string[] per
210
+ // question, in order. Read positionally before the named-row shape below.
211
+ if (formAnswers.every((row) => Array.isArray(row))) {
212
+ for (let index = 0; index < answers.length; index += 1) {
213
+ const row = formAnswers[index];
214
+ if (!Array.isArray(row)) continue;
215
+ answers[index] = {
216
+ selectedOptions: row.filter((label): label is string => typeof label === 'string' && label.length > 0),
217
+ timedOut,
218
+ };
219
+ }
220
+ return answers;
221
+ }
164
222
  for (const row of formAnswers) {
165
223
  if (!row || typeof row !== 'object') continue;
166
224
  const name = typeof row.name === 'string' ? row.name : '';
@@ -95,7 +95,7 @@ const MINIMAL: BlockChrome = {
95
95
  /**
96
96
  * `tui` — omp's terminal transcript. A block is a LINE of coloured text, not a
97
97
  * box: the tool row draws its own status line (`styles/Tui.tsx`), and a
98
- * thinking block or a notice wears the same frameless shape in the terminal's
98
+ * thinking block or a notice wears the same frameless shape, in the transcript's
99
99
  * own type, with its name in the accent and its subject in the meta hue. The
100
100
  * body hangs off a hairline rule, the way a terminal prints output under the
101
101
  * command that produced it.
@@ -103,11 +103,11 @@ const MINIMAL: BlockChrome = {
103
103
  const TUI: BlockChrome = {
104
104
  root: '',
105
105
  frame: '',
106
- header: 'flex w-full items-center gap-2 px-1 py-0.5 text-left transition-colors font-mono',
106
+ header: 'flex w-full items-center gap-2 px-1 py-0.5 text-left transition-colors',
107
107
  icon: 'flex shrink-0 items-center justify-center',
108
- title: 'shrink-0 text-[11.5px] font-semibold text-info',
108
+ title: 'shrink-0 text-[12px] font-semibold text-info',
109
109
  subtitle: 'min-w-0 truncate font-mono text-[10.5px] text-meta',
110
- body: 'my-1.5 ml-2 overflow-hidden border-l border-ink/10 py-1.5 pl-3 font-mono',
110
+ body: 'my-1.5 ml-2 overflow-hidden border-l border-ink/10 py-1.5 pl-3',
111
111
  };
112
112
 
113
113
  const BY_MODE: Record<ToolRenderMode, BlockChrome> = {