@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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +479 -479
- package/dist/client/static/js/{Body-x5grdps8.js → Body-jfy4bhk2.js} +1 -1
- package/dist/client/static/js/{CsvGrid-248v9yzf.js → CsvGrid-4c5t668z.js} +1 -1
- package/dist/client/static/js/{DocxView-5we92k2h.js → DocxView-3x7whtvq.js} +1 -1
- package/dist/client/static/js/{DrawioView-c6xmw4qq.js → DrawioView-tbkc5dfz.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-r3qxgqg6.js → HtmlPreview-egxkayya.js} +1 -1
- package/dist/client/static/js/{ImageView-cr4fea18.js → ImageView-swhzvw2p.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-j12z0djx.js → LayoutWrapper-sangsrt5.js} +2 -2
- package/dist/client/static/js/MergeDiffView-bv00y63x.js +1 -0
- package/dist/client/static/js/{Modal-cqceypcn.js → Modal-1fj8kvme.js} +16 -16
- package/dist/client/static/js/{PdfView-xdgn31cm.js → PdfView-0k2egsbz.js} +1 -1
- package/dist/client/static/js/{SessionsView-ms6z44e2.js → SessionsView-t547rqeb.js} +1 -1
- package/dist/client/static/js/{SheetView-peqm9vft.js → SheetView-anb3gavm.js} +1 -1
- package/dist/client/static/js/{SvgPreview-rdf4wbzr.js → SvgPreview-e2wrj2hj.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-48z2x5vg.js → abnfDiagram-O67JEVCF-0rs86b68.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-n1pr5s6j.js → architectureDiagram-NJMV4G6O-0k3zzxz1.js} +3 -3
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-p19shaft.js → blockDiagram-BEXU5L5S-t1n1fx96.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-qcd46ts2.js → c4Diagram-YGBWAQC7-93b7eds9.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-scyhe133.js → classDiagram-v2-NBCMYWYE-bnf85z0f.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-srnnj3f7.js → cose-bilkent-JH36ORCC-e290161f.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-1zfrnyay.js → cynefinDiagram-VND7K2PF-s13ra9ag.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-hepk25pz.js → dagre-6A5THRUB-83wshh5e.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-wy2y0323.js → diagram-22UHCM2B-ywh4wqna.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-j904f93p.js → diagram-3UASUU5V-cb53z698.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-2mmxccm2.js → diagram-ATOU4E4O-btf55c44.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-cfhk73ty.js → diagram-CDSNMT55-p6tbbm1n.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-ryf8j6hf.js → diagram-MLGK6HIB-6kzssf4y.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-8k5e36sd.js → diagram-MPIPVDR6-4v0yncvv.js} +1 -1
- package/dist/client/static/js/{dockerfile-1e7deann.js → dockerfile-r422htmd.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-5kkbbbhv.js → ebnfDiagram-ZINNZB2B-mw1gh30z.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-jqc4mzvc.js → elk-276RUBZZ-1pe786ap.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-kx15t6f0.js → erDiagram-OPXOYQCR-x7rk70q6.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-kfwaac44.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-3hv8pej4.js → ganttDiagram-FUAMR5RP-j3m5km4p.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-a4mq8vwz.js → gitGraphDiagram-X574FWY7-fd1kebdy.js} +1 -1
- package/dist/client/static/js/{index-fanhvjk8.js → index-004x0a3p.js} +1 -1
- package/dist/client/static/js/{index-exyg9sna.js → index-0mhxw0a1.js} +1 -1
- package/dist/client/static/js/{index-51wzt3ma.js → index-22frp78d.js} +1 -1
- package/dist/client/static/js/{index-x5c5yxhj.js → index-29b1ysz6.js} +1 -1
- package/dist/client/static/js/{index-br27jz2t.js → index-3hrvhyym.js} +1 -1
- package/dist/client/static/js/{index-kvker1ps.js → index-3k45gspr.js} +1 -1
- package/dist/client/static/js/{index-vxe4e903.js → index-473wm10a.js} +1 -1
- package/dist/client/static/js/{index-demg0p74.js → index-4acka5fn.js} +1 -1
- package/dist/client/static/js/{index-40ydm28n.js → index-4dzvjfkd.js} +1 -1
- package/dist/client/static/js/{index-n5194pe6.js → index-4fpyzg5e.js} +7 -7
- package/dist/client/static/js/{index-n4pm0hrh.js → index-4jg10xtp.js} +1 -1
- package/dist/client/static/js/{index-937bn0d2.js → index-4nyajpeg.js} +1 -1
- package/dist/client/static/js/{index-8hnem33f.js → index-5fxm2tpg.js} +1 -1
- package/dist/client/static/js/{index-pszsxhjr.js → index-72v57e07.js} +1 -1
- package/dist/client/static/js/{index-0j5ng1qc.js → index-7tsdw8wt.js} +1 -1
- package/dist/client/static/js/{index-k4kwrze2.js → index-8e66p2a7.js} +1 -1
- package/dist/client/static/js/{index-317v49ey.js → index-8n4qwd64.js} +2 -2
- package/dist/client/static/js/{index-w4dep7k6.js → index-bnamrpm6.js} +1 -1
- package/dist/client/static/js/{index-01rdknec.js → index-bxhszdcz.js} +1 -1
- package/dist/client/static/js/{index-n3cts2j1.js → index-cbbwq25c.js} +1 -1
- package/dist/client/static/js/{index-kevqayd9.js → index-dfha2z56.js} +1 -1
- package/dist/client/static/js/{index-e2y4hkps.js → index-drsy400d.js} +1 -1
- package/dist/client/static/js/{index-4kchzh9y.js → index-e4yj4kbe.js} +8 -8
- package/dist/client/static/js/{index-bf54x0w8.js → index-g84dwmvr.js} +1 -1
- package/dist/client/static/js/index-gedsa0z7.css +1 -0
- package/dist/client/static/js/{index-x3g8fwkc.js → index-hge0y4vn.js} +2 -2
- package/dist/client/static/js/{index-9cr6p86f.js → index-hgsjynb0.js} +1 -1
- package/dist/client/static/js/{index-0z7kerp1.js → index-j1prebvy.js} +2 -2
- package/dist/client/static/js/{index-rtfw07hy.js → index-jbaceghb.js} +1 -1
- package/dist/client/static/js/{index-v90zd3sq.js → index-jtyzeynv.js} +2 -2
- package/dist/client/static/js/{index-p8bta9ae.js → index-kbk0vmex.js} +4 -4
- package/dist/client/static/js/{index-40fdtqvw.js → index-q178zgxp.js} +1 -1
- package/dist/client/static/js/{index-eb43hnd3.js → index-q4t5j3x7.js} +1 -1
- package/dist/client/static/js/{index-xhcbaaga.js → index-qdabc51h.js} +3 -3
- package/dist/client/static/js/{index-jvn2xfpt.js → index-qrwjxqdh.js} +168 -166
- package/dist/client/static/js/{index-3kenmzbe.js → index-rm5b3kn8.js} +1 -1
- package/dist/client/static/js/{index-g3x4w48f.js → index-s4v3vcsn.js} +1 -1
- package/dist/client/static/js/{index-kz5d00m5.js → index-s6nv35dv.js} +1 -1
- package/dist/client/static/js/{index-1ye834yz.js → index-satnfvaz.js} +1 -1
- package/dist/client/static/js/{index-m85c740p.js → index-tcp5cp53.js} +1 -1
- package/dist/client/static/js/{index-9gddw5qy.js → index-zkef5q39.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-wtnqb06v.js → infoDiagram-VRGFBTTK-1m0br602.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-eta0jnvr.js → ishikawaDiagram-OU5B5YK6-zryzhpq6.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-4e572kkp.js → journeyDiagram-ZHPQQLJL-6apqr7h4.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-yrtnn4zy.js → kanban-definition-PNTS6WVX-am385c1e.js} +1 -1
- package/dist/client/static/js/{mermaid.core-195b0fb6.js → mermaid.core-k937exrm.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-pphjnkvt.js → mindmap-definition-NLK3R4M7-hx8qq866.js} +1 -1
- package/dist/client/static/js/one-dark-pro-phxqe9mx.js +1 -0
- package/dist/client/static/js/one-light-vhwh499y.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-kgffb9p3.js → pegDiagram-GJSIUBJH-1hasj2h7.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-efech3mm.js → pieDiagram-5QR66LMP-x5nwff8r.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-khf9cv3t.js → quadrantDiagram-O4NWA36T-gmrcr5jb.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-ye68kdx2.js → railroadDiagram-XR7U4H2S-rdznfhfb.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-3s4smnme.js → requirementDiagram-PLB6GJNP-v9wb3ppf.js} +1 -1
- package/dist/client/static/js/{rust-tdrnaxp3.js → rust-9cgnbbcs.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-9pqd25mc.js → sankeyDiagram-IPEJSGJF-3p4ddd2h.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-rka8ct43.js → sequenceDiagram-PO4LG4MO-wfcqxjfq.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-g5wkzry8.js → sizeCapture-INFHLROL-g02k0k8x.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gy1zab2j.js → stateDiagram-v2-GCMORJYK-7k449yvg.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-kr35nmd2.js → swimlanes-2SLR337P-zkf2bgm8.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-qnhxxmjr.js → swimlanesDiagram-TC7HE7FX-yex8g4fx.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-sg151mkc.js → timeline-definition-EJHVYXUP-qsfpjr1c.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-f91g61p3.js → usecaseDiagram-POWQR4AR-b2vprhsr.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-zbhr4eqf.js → vennDiagram-UO4OBE2U-x0ffeg2t.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-6302414n.js → wardleyDiagram-VNRHLVJA-hsnhaf4f.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-0a47th65.js → xychartDiagram-PMCCYNJV-90f9aadp.js} +1 -1
- package/package.json +5 -5
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +5 -3
- package/src/client/components/workspace/chat-timeline/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +41 -21
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +16 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +105 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +59 -8
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.test.tsx +54 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.test.tsx +91 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +8 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +9 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +16 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.test.tsx +59 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +11 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.test.ts +81 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.ts +139 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +14 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +22 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +14 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +36 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +10 -5
- package/src/client/data/settings/omp-schema.json +445 -165
- package/src/client/hooks/chat/timeline/ask-frame-buckets.ts +14 -4
- package/src/client/hooks/chat/timeline/ask-frames-context.ts +3 -1
- package/src/client/hooks/chat/timeline/ask-frames-grouped.test.ts +31 -0
- package/src/client/hooks/chat/timeline/ask-frames.ts +12 -3
- package/src/client/hooks/chat/timeline/send-props.ts +1 -2
- package/src/server/lib/harness/acp/client-capabilities.test.ts +3 -2
- package/src/server/lib/sessions/last-opened.server.test.ts +26 -7
- package/src/server/lib/sessions/last-opened.server.ts +19 -4
- package/src/server/routes/fs/raw.test.ts +33 -0
- package/src/server/routes/fs/raw.ts +31 -11
- package/src/shared/lib/chat/ask-questions.test.ts +29 -0
- package/src/shared/lib/chat/ask-questions.ts +44 -3
- package/src/shared/lib/chat/ask-results.test.ts +66 -0
- package/src/shared/lib/chat/ask-results.ts +58 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +4 -4
- package/src/shared/lib/chat/timeline/tool-phrases.test.ts +4 -0
- package/src/shared/lib/chat/timeline/tool-phrases.ts +2 -0
- package/src/shared/lib/models/provider/glyph.test.ts +13 -11
- package/src/shared/lib/models/provider/glyph.ts +1 -0
- package/src/shared/lib/models/provider/label.ts +3 -0
- package/src/shared/lib/omp/config/schema-releases-19-3.test.ts +64 -0
- package/src/shared/lib/omp/config/schema-releases.test.ts +6 -4
- package/src/shared/lib/omp/session/wait-idle.test.ts +12 -2
- package/src/shared/lib/omp/session/wait-idle.ts +11 -6
- package/tsconfig.json +6 -0
- package/dist/client/static/js/MergeDiffView-y0we0194.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-dpjz82p8.js +0 -1
- package/dist/client/static/js/index-4m2d73m3.css +0 -1
- package/dist/client/static/js/one-dark-pro-asy2qj2p.js +0 -1
- package/dist/client/static/js/one-light-fya1pbbx.js +0 -1
package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx
CHANGED
|
@@ -49,6 +49,17 @@ interface GroupedAskProps {
|
|
|
49
49
|
*/
|
|
50
50
|
submitted?: { id: string; selectedOptions: string[]; customInput?: string }[] | null;
|
|
51
51
|
onRespond: (response: ExtensionDialogResponse) => void;
|
|
52
|
+
/**
|
|
53
|
+
* An ACP ask answers by sending a prompt, not by replying to a frame. These
|
|
54
|
+
* flags let the same card lock while that send is on the wire, hide the
|
|
55
|
+
* omp-only Dismiss button, and label the action for what it does.
|
|
56
|
+
*/
|
|
57
|
+
busy?: boolean;
|
|
58
|
+
readOnly?: boolean;
|
|
59
|
+
dismissible?: boolean;
|
|
60
|
+
submitLabel?: string;
|
|
61
|
+
/** Every question needs an answer (an ACP adapter reads one message). */
|
|
62
|
+
requireAll?: boolean;
|
|
52
63
|
/**
|
|
53
64
|
* The `pendingInteraction` slot's controls, if any.
|
|
54
65
|
*
|
|
@@ -141,7 +152,7 @@ function QuestionRow({
|
|
|
141
152
|
);
|
|
142
153
|
}
|
|
143
154
|
|
|
144
|
-
export function GroupedAsk({ frame, recorded, submitted, onRespond, interactions }: GroupedAskProps) {
|
|
155
|
+
export function GroupedAsk({ frame, recorded, submitted, onRespond, interactions, busy, readOnly, dismissible, submitLabel, requireAll }: GroupedAskProps) {
|
|
145
156
|
const questions = useMemo(() => frame.questions ?? [], [frame.questions]);
|
|
146
157
|
const [drafts, setDrafts] = useState<Record<string, Draft>>({});
|
|
147
158
|
|
|
@@ -188,9 +199,14 @@ export function GroupedAsk({ frame, recorded, submitted, onRespond, interactions
|
|
|
188
199
|
};
|
|
189
200
|
});
|
|
190
201
|
const anyAnswer = answers.some((answer) => answer.selectedOptions.length > 0 || answer.customInput);
|
|
202
|
+
// An ACP adapter reads ONE prompt as the answer, so every question must carry
|
|
203
|
+
// one; omp's grouped frame keeps its original "any answer" rule.
|
|
204
|
+
const everyAnswer = answers.every((answer) => answer.selectedOptions.length > 0 || answer.customInput);
|
|
205
|
+
const ready = requireAll ? everyAnswer : anyAnswer;
|
|
191
206
|
// Every question carries an answer once a submit is in flight, so the card
|
|
192
207
|
// stops drawing controls and shows what was sent.
|
|
193
208
|
const settled = submitted !== null && questions.every((question, index) => answerFor(question, index) !== null);
|
|
209
|
+
const locked = settled || busy === true || readOnly === true;
|
|
194
210
|
|
|
195
211
|
return (
|
|
196
212
|
<div className="space-y-2">
|
|
@@ -202,31 +218,35 @@ export function GroupedAsk({ frame, recorded, submitted, onRespond, interactions
|
|
|
202
218
|
total={questions.length}
|
|
203
219
|
draft={draftFor(question)}
|
|
204
220
|
answer={answerFor(question, index)}
|
|
205
|
-
locked={
|
|
221
|
+
locked={locked}
|
|
206
222
|
onToggle={(label) => toggle(question, label)}
|
|
207
223
|
onText={(value) => setText(question, value)}
|
|
208
224
|
/>
|
|
209
225
|
))}
|
|
210
226
|
{interactions}
|
|
211
|
-
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
{readOnly !== true && (
|
|
228
|
+
<div className="flex items-center justify-end gap-2">
|
|
229
|
+
{dismissible !== false && (
|
|
230
|
+
<button
|
|
231
|
+
type="button"
|
|
232
|
+
disabled={locked}
|
|
233
|
+
onClick={() => onRespond({ cancelled: true })}
|
|
234
|
+
className="cursor-pointer rounded-md border border-ink/15 px-3 py-1 text-[11.5px] font-medium text-ink/70 transition-colors hover:border-ink/30 hover:text-ink disabled:cursor-default disabled:opacity-40"
|
|
235
|
+
>
|
|
236
|
+
Dismiss
|
|
237
|
+
</button>
|
|
238
|
+
)}
|
|
239
|
+
<button
|
|
240
|
+
type="button"
|
|
241
|
+
disabled={!ready || locked}
|
|
242
|
+
onClick={() => onRespond({ answers })}
|
|
243
|
+
className="flex cursor-pointer items-center gap-1.5 rounded-md bg-ink px-3 py-1 text-[11.5px] font-semibold text-paper transition-opacity hover:opacity-90 disabled:opacity-40"
|
|
244
|
+
>
|
|
245
|
+
<CornerDownLeft size={11} />
|
|
246
|
+
<span>{submitLabel ?? 'Submit answers'}</span>
|
|
247
|
+
</button>
|
|
248
|
+
</div>
|
|
249
|
+
)}
|
|
230
250
|
</div>
|
|
231
251
|
);
|
|
232
252
|
}
|
package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* both of omp's shapes.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { Ban, CheckCircle2, Clock } from 'lucide-preact';
|
|
18
|
+
import { Ban, CheckCircle2, Clock, MessageSquare } from 'lucide-preact';
|
|
19
19
|
import type { ComponentChildren } from 'preact';
|
|
20
20
|
import type { ExtensionUiDialogRequest } from '@kabmo-labs/kabmo-chat/contracts/agent';
|
|
21
21
|
import type { AskAnswer, AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
@@ -40,6 +40,12 @@ interface QuestionBlockProps {
|
|
|
40
40
|
* anything.
|
|
41
41
|
*/
|
|
42
42
|
settled: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Where an unanswered question is answered. ACP ask tools have no dialog:
|
|
45
|
+
* their adapter reads the next user message, so the card names the composer
|
|
46
|
+
* instead of promising a control it cannot draw.
|
|
47
|
+
*/
|
|
48
|
+
answerChannel?: 'dialog' | 'message';
|
|
43
49
|
/** Labels toggled locally on a multi-select question. */
|
|
44
50
|
multiSelected: string[];
|
|
45
51
|
/**
|
|
@@ -69,6 +75,7 @@ export function QuestionBlock({
|
|
|
69
75
|
draft,
|
|
70
76
|
passed,
|
|
71
77
|
settled,
|
|
78
|
+
answerChannel = 'dialog',
|
|
72
79
|
multiSelected,
|
|
73
80
|
interactions,
|
|
74
81
|
onAnswer,
|
|
@@ -143,8 +150,14 @@ export function QuestionBlock({
|
|
|
143
150
|
))}
|
|
144
151
|
{/* "Waiting for the previous answer" is only true while the ask
|
|
145
152
|
is still running: once it settles nothing is being asked, and
|
|
146
|
-
the question was abandoned unanswered.
|
|
147
|
-
|
|
153
|
+
the question was abandoned unanswered. An ACP ask never has a
|
|
154
|
+
dialog at all, so it names the channel that actually works. */}
|
|
155
|
+
{answerChannel === 'message' ? (
|
|
156
|
+
<div className="flex items-center gap-1.5 pt-0.5 text-[10.5px] text-ink/40">
|
|
157
|
+
<MessageSquare size={10} className="shrink-0" />
|
|
158
|
+
<span>This harness has no inline control for this question.</span>
|
|
159
|
+
</div>
|
|
160
|
+
) : settled ? (
|
|
148
161
|
<div className="flex items-center gap-1.5 pt-0.5 text-[10.5px] text-ink/40">
|
|
149
162
|
<Ban size={10} className="shrink-0" />
|
|
150
163
|
<span>Not answered: the ask was cut short.</span>
|
package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts
CHANGED
|
@@ -53,9 +53,20 @@ function mountFromFrame(frame: IncomingExtensionUiRequest): ExtensionUiDialogReq
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/** Mount the card with an explicit frame queue and tool, keeping it mounted. */
|
|
56
|
-
function paint(
|
|
56
|
+
function paint(
|
|
57
|
+
queue: ExtensionUiDialogRequest[],
|
|
58
|
+
tool: ToolCallData = ASK_TOOL,
|
|
59
|
+
harness?: string,
|
|
60
|
+
): void {
|
|
57
61
|
const split = splitAskFrames([MESSAGE], queue, true);
|
|
58
|
-
const handle: AskFramesHandle = {
|
|
62
|
+
const handle: AskFramesHandle = {
|
|
63
|
+
framesByTool: split.framesByTool,
|
|
64
|
+
looseByTool: split.looseByTool,
|
|
65
|
+
orphanAsks: [],
|
|
66
|
+
formByTool: new Map(),
|
|
67
|
+
...(harness ? { harness } : {}),
|
|
68
|
+
respond: () => {},
|
|
69
|
+
};
|
|
59
70
|
act(() => { render(h(AskFramesContext.Provider, { value: handle }, h(AskPanel, { tool })), container); });
|
|
60
71
|
}
|
|
61
72
|
|
|
@@ -140,3 +151,95 @@ describe('grouped ask frame end to end', () => {
|
|
|
140
151
|
expect(container.querySelector('[title="the warm one"]')).toBeNull();
|
|
141
152
|
});
|
|
142
153
|
});
|
|
154
|
+
|
|
155
|
+
describe('external ACP ask tool call', () => {
|
|
156
|
+
test('renders questions read-only when no elicitation frame has arrived', () => {
|
|
157
|
+
const external: ToolCallData = {
|
|
158
|
+
id: 'call-acp-ask',
|
|
159
|
+
type: 'other',
|
|
160
|
+
title: 'Run AskUserQuestion',
|
|
161
|
+
name: 'AskUserQuestion',
|
|
162
|
+
status: 'running',
|
|
163
|
+
input: {
|
|
164
|
+
questions: [{
|
|
165
|
+
header: 'Approach',
|
|
166
|
+
question: 'Which strategy?',
|
|
167
|
+
multiSelect: true,
|
|
168
|
+
options: [
|
|
169
|
+
{ label: 'Conservative', description: 'small steps' },
|
|
170
|
+
{ label: 'Balanced' },
|
|
171
|
+
],
|
|
172
|
+
}],
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
paint([], external);
|
|
177
|
+
|
|
178
|
+
const text = container.textContent ?? '';
|
|
179
|
+
expect(text).toContain('Which strategy?');
|
|
180
|
+
expect(text).toContain('Conservative');
|
|
181
|
+
expect(text).toContain('small steps');
|
|
182
|
+
expect(text).toContain('This harness has no inline control for this question.');
|
|
183
|
+
expect(text).not.toContain('Waiting for the previous answer');
|
|
184
|
+
expect(text).not.toContain('Submit answers');
|
|
185
|
+
expect(text).not.toContain('Send answer');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('omp-acp’s exact `ask` name is recognized as an external ask', () => {
|
|
189
|
+
// omp's own tool is `ask`; over ACP the only signal is the chat's harness.
|
|
190
|
+
paint([], ASK_TOOL, 'omp-acp');
|
|
191
|
+
|
|
192
|
+
const text = container.textContent ?? '';
|
|
193
|
+
expect(text).toContain('waiting for your answer.');
|
|
194
|
+
expect(text).toContain('This harness has no inline control for this question.');
|
|
195
|
+
expect(text).not.toContain('Waiting for the previous answer');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test('a completed external ask renders the answers its result carries', () => {
|
|
199
|
+
// The reported opencode/claude symptom: the answer was delivered and the
|
|
200
|
+
// tool completed, but the card still drew the question as unanswered.
|
|
201
|
+
const external: ToolCallData = {
|
|
202
|
+
id: 'call-acp-answered',
|
|
203
|
+
type: 'other',
|
|
204
|
+
title: 'question',
|
|
205
|
+
name: 'question',
|
|
206
|
+
status: 'success',
|
|
207
|
+
input: {
|
|
208
|
+
questions: [
|
|
209
|
+
{ question: 'Koneksi ini buat ngoding stack apa?', options: [{ label: 'TypeScript / JS' }, { label: 'Go' }] },
|
|
210
|
+
{ question: 'Gaya respons yang kamu mau?', options: [{ label: 'Singkat & langsung' }, { label: 'Detail' }] },
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
output: 'Your questions have been answered: "Koneksi ini buat ngoding stack apa?"="TypeScript / JS", "Gaya respons yang kamu mau?"="Singkat & langsung". You can now continue with the user\'s answers in mind.',
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
paint([], external);
|
|
217
|
+
|
|
218
|
+
const text = container.textContent ?? '';
|
|
219
|
+
expect(text).toContain('TypeScript / JS');
|
|
220
|
+
expect(text).toContain('Singkat & langsung');
|
|
221
|
+
expect(text).not.toContain('Input needed');
|
|
222
|
+
expect(text).not.toContain('Send answer');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test('reads a single-question shape from an adapter that does not use questions[]', () => {
|
|
226
|
+
const external: ToolCallData = {
|
|
227
|
+
id: 'call-acp-single',
|
|
228
|
+
type: 'other',
|
|
229
|
+
title: 'Run ask_question',
|
|
230
|
+
name: 'ask_question',
|
|
231
|
+
status: 'success',
|
|
232
|
+
input: { question: 'Lanjut tes yang mana?', options: ['Image generation', 'Selesai'] },
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
paint([], external);
|
|
236
|
+
|
|
237
|
+
const text = container.textContent ?? '';
|
|
238
|
+
expect(text).toContain('Lanjut tes yang mana?');
|
|
239
|
+
expect(text).toContain('Image generation');
|
|
240
|
+
expect(text).toContain('Selesai');
|
|
241
|
+
expect(text).toContain('This harness has no inline control for this question.');
|
|
242
|
+
expect(text).not.toContain('Not answered: the ask was cut short.');
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
@@ -20,13 +20,19 @@
|
|
|
20
20
|
* writes no result until the tool call finishes — so without the hold the card
|
|
21
21
|
* redrew as unanswered (every question back to "Waiting for the previous
|
|
22
22
|
* answer…") for the whole stretch the agent spent acting on the answers.
|
|
23
|
+
*
|
|
24
|
+
* An ACP agent's own ask (`ask_question`, `question`, `AskUserQuestion`, …)
|
|
25
|
+
* is the THIRD shape: a tool call with no dialog at all. The card draws its
|
|
26
|
+
* questions and names the composer, because the adapter reads the next user
|
|
27
|
+
* message as the answer — promising a dialog that cannot arrive left the card
|
|
28
|
+
* waiting forever.
|
|
23
29
|
*/
|
|
24
30
|
|
|
25
31
|
import { useState } from 'preact/hooks';
|
|
26
32
|
import { HelpCircle, XCircle } from 'lucide-preact';
|
|
27
33
|
import type { ToolCallData } from '@/shared/types';
|
|
28
34
|
import type { ExtensionUiDialogRequest } from '@kabmo-labs/kabmo-chat/contracts/agent';
|
|
29
|
-
import { isAskSettled, parseAskQuestions } from '@/shared/lib/chat/ask-questions';
|
|
35
|
+
import { isAskSettled, isExternalAskTool, parseAskQuestions } from '@/shared/lib/chat/ask-questions';
|
|
30
36
|
import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
31
37
|
import { parseAskResult } from '@/shared/lib/chat/ask-results';
|
|
32
38
|
import { useAskFrames } from '@/client/hooks/chat/timeline/ask-frames-context';
|
|
@@ -61,10 +67,21 @@ interface SubmittedAsk {
|
|
|
61
67
|
export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
62
68
|
const questions = parseAskQuestions(tool);
|
|
63
69
|
const recorded = parseAskResult(tool, questions);
|
|
64
|
-
const { framesByTool, looseByTool, formByTool, respond } = useAskFrames();
|
|
70
|
+
const { framesByTool, looseByTool, formByTool, harness, orphanAsks, respond } = useAskFrames();
|
|
65
71
|
const groups = framesByTool.get(tool.id) ?? NO_GROUPS;
|
|
66
72
|
const loose = looseByTool.get(tool.id) ?? NO_FRAMES;
|
|
67
|
-
|
|
73
|
+
// An ACP agent's own ask (`ask_question`, `question`, `AskUserQuestion`, …)
|
|
74
|
+
// reaches this card as a TOOL CALL with no extension dialog: the protocol
|
|
75
|
+
// has no ask frame, and the adapter reads the next user message as the
|
|
76
|
+
// answer. `omp-acp` may spell it exactly `ask`, so the chat's harness is the
|
|
77
|
+
// second half of the test. It must never enter the form/per-question paths,
|
|
78
|
+
// which wait for frames that cannot arrive.
|
|
79
|
+
const externalAsk = isExternalAskTool(tool)
|
|
80
|
+
|| (harness !== undefined && harness !== 'omp-rpc'
|
|
81
|
+
&& (typeof tool.name === 'string' ? tool.name : '').toLowerCase() === 'ask');
|
|
82
|
+
// A completed ACP call already took the next message as its answer; only
|
|
83
|
+
// omp's `success` is ambiguous (a reloaded mid-ask call reads back as one).
|
|
84
|
+
const settled = isAskSettled(tool) || (externalAsk && tool.status === 'success');
|
|
68
85
|
// omp 19.1.0's whole-form dialog answers every control in ONE `{ data }`
|
|
69
86
|
// reply; it is not part of the per-field walk at all.
|
|
70
87
|
const formFrame = formByTool.get(tool.id) ?? null;
|
|
@@ -73,8 +90,10 @@ export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
|
73
90
|
// restored draft the moment its frame arrives, which would answer question 1
|
|
74
91
|
// before the user could reach the form's Submit.
|
|
75
92
|
const groupedForm =
|
|
76
|
-
!formFrame && !settled && questions.length > 1 && recorded.some((answer) => answer === null);
|
|
93
|
+
!externalAsk && !formFrame && !settled && questions.length > 1 && recorded.some((answer) => answer === null);
|
|
77
94
|
const [submitted, setSubmitted] = useState<SubmittedAsk | null>(null);
|
|
95
|
+
const [externalSent, setExternalSent] = useState(false);
|
|
96
|
+
const [externalDismissed, setExternalDismissed] = useState(false);
|
|
78
97
|
const { drafts, multiSelected, commit, toggleMulti } = useAskDrafts({
|
|
79
98
|
toolId: tool.id,
|
|
80
99
|
questions: groupedForm ? NO_QUESTIONS : questions,
|
|
@@ -100,11 +119,17 @@ export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
|
100
119
|
// question must stay answerable.
|
|
101
120
|
const waiting =
|
|
102
121
|
!settled &&
|
|
103
|
-
(
|
|
122
|
+
(externalAsk
|
|
123
|
+
? !externalSent && !externalDismissed && recorded.some((answer) => answer === null)
|
|
124
|
+
: formFrame !== null || groups.some((frames, index) => frames.length > 0 && !recorded[index]));
|
|
104
125
|
// omp asks in order and blocks on each, so the earliest question holding a
|
|
105
126
|
// dialog is the only open one: everything before it is answered, whether or
|
|
106
127
|
// not this client still has the text.
|
|
107
128
|
const askingIndex = groups.findIndex((frames) => frames.length > 0);
|
|
129
|
+
const recordedAll = recorded.length > 0 && recorded.every((answer) => answer !== null);
|
|
130
|
+
// An elicitation with no usable toolCallId is drawn as an orphan at the end
|
|
131
|
+
// of the timeline. Point the tool card there instead of leaving it silent.
|
|
132
|
+
const questionElsewhere = externalAsk && orphanAsks.some((frame) => frame.toolCallId === tool.id);
|
|
108
133
|
|
|
109
134
|
// A GROUPED ask (`method:"ask"`) covers every question at once, so it renders
|
|
110
135
|
// its own card instead of one control per question. `splitAskFrames` places
|
|
@@ -121,13 +146,25 @@ export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
|
121
146
|
const heldFrame = submitted && recorded.every((answer) => answer === null) ? submitted.frame : null;
|
|
122
147
|
const card = groupedFrame ?? heldFrame;
|
|
123
148
|
|
|
124
|
-
|
|
149
|
+
// A pending ACP elicitation outranks the tool status: the frame is what the
|
|
150
|
+
// agent is actually blocked on, even if the adapter marked the call done.
|
|
151
|
+
if (card && (!settled || externalAsk)) {
|
|
125
152
|
const answered = submitted && submitted.frame.id === card.id ? submitted.answers : null;
|
|
126
153
|
// The recorded flags and the answer path are shared with the plugin slot:
|
|
127
154
|
// a plugin's response must be the frame the Submit button would have sent,
|
|
128
155
|
// through the same sender, or omp receives something it did not expect.
|
|
129
156
|
const answer = (response: ExtensionDialogResponse) => {
|
|
130
|
-
if ('answers' in response)
|
|
157
|
+
if ('answers' in response) {
|
|
158
|
+
setSubmitted({ frame: card, answers: response.answers });
|
|
159
|
+
// An ACP elicitation took the answer: its frame leaves the queue as
|
|
160
|
+
// soon as the JSON-RPC result is on the wire, so the banner must not
|
|
161
|
+
// keep claiming the agent is blocked.
|
|
162
|
+
if (externalAsk) setExternalSent(true);
|
|
163
|
+
} else if ('cancelled' in response && externalAsk) {
|
|
164
|
+
// The elicitation was declined. Its frame is gone, so the card must not
|
|
165
|
+
// fall through to the prompt fallback as if it still had a question.
|
|
166
|
+
setExternalDismissed(true);
|
|
167
|
+
}
|
|
131
168
|
respond(card, response);
|
|
132
169
|
};
|
|
133
170
|
return (
|
|
@@ -138,11 +175,16 @@ export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
|
138
175
|
<span>Input needed: the agent is blocked until you answer.</span>
|
|
139
176
|
</div>
|
|
140
177
|
)}
|
|
178
|
+
{externalSent && !settled && (
|
|
179
|
+
<p className="text-[10.5px] text-ink/45">Answer sent — the agent is continuing…</p>
|
|
180
|
+
)}
|
|
141
181
|
<GroupedAsk
|
|
142
182
|
frame={card}
|
|
143
183
|
recorded={recorded}
|
|
144
184
|
submitted={answered}
|
|
145
185
|
onRespond={answer}
|
|
186
|
+
readOnly={externalAsk && (answered !== null || recordedAll)}
|
|
187
|
+
submitLabel={externalAsk ? 'Send answer' : undefined}
|
|
146
188
|
interactions={
|
|
147
189
|
<PluginPendingInteractions
|
|
148
190
|
frame={card}
|
|
@@ -224,10 +266,18 @@ export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
|
224
266
|
{waiting && (
|
|
225
267
|
<div className="flex items-center gap-1.5 text-[10.5px] text-ink/50">
|
|
226
268
|
<HelpCircle size={11} className="shrink-0" />
|
|
227
|
-
<span>
|
|
269
|
+
<span>
|
|
270
|
+
{externalAsk
|
|
271
|
+
? 'Input needed: the agent is waiting for your answer.'
|
|
272
|
+
: 'Input needed: the agent is blocked until you answer.'}
|
|
273
|
+
</span>
|
|
228
274
|
</div>
|
|
229
275
|
)}
|
|
230
276
|
|
|
277
|
+
{questionElsewhere && (
|
|
278
|
+
<p className="text-[10.5px] text-ink/45">The agent's question is shown at the end of the timeline.</p>
|
|
279
|
+
)}
|
|
280
|
+
|
|
231
281
|
{questions.map((question, index) => {
|
|
232
282
|
const live = liveFrame(groups, index);
|
|
233
283
|
const answer = (response: ExtensionDialogResponse) => {
|
|
@@ -244,6 +294,7 @@ export function AskPanel({ tool }: { tool: ToolCallData }) {
|
|
|
244
294
|
draft={drafts[index]}
|
|
245
295
|
passed={askingIndex !== -1 && index < askingIndex}
|
|
246
296
|
settled={settled}
|
|
297
|
+
answerChannel={externalAsk ? 'message' : 'dialog'}
|
|
247
298
|
multiSelected={multiSelected[index] ?? NO_LABELS}
|
|
248
299
|
onAnswer={(value) => commit(index, value)}
|
|
249
300
|
onToggle={(label) => toggleMulti(index, label)}
|
|
@@ -34,6 +34,7 @@ import { Resolve } from '@/client/components/workspace/chat-timeline/tool-render
|
|
|
34
34
|
import { ManageSkill } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/ManageSkill';
|
|
35
35
|
import { SearchFs } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/SearchFs';
|
|
36
36
|
import { AskPanel } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel';
|
|
37
|
+
import { AgentAdmin } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin';
|
|
37
38
|
import { Think } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/Think';
|
|
38
39
|
import { Read } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/Read';
|
|
39
40
|
import { Edit } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/Edit';
|
|
@@ -77,6 +78,7 @@ const PANELS: Record<ToolPanelKind, (props: { tool: ToolCallData }) => ReactNode
|
|
|
77
78
|
think: Think,
|
|
78
79
|
mcp: Mcp,
|
|
79
80
|
wait: Wait,
|
|
81
|
+
agent_admin: AgentAdmin,
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
/** File a tool call targets: explicit `target`, result details, its arguments
|
package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.test.tsx
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The agent-control card, mounted with the arguments measured on `agy acp`
|
|
8
|
+
* 1.5.3. The helper's own suite pins the normalization; this one proves the
|
|
9
|
+
* card actually paints it (the body is the only surface these calls have).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
13
|
+
import { Window } from 'happy-dom';
|
|
14
|
+
import { h, render } from 'preact';
|
|
15
|
+
import { act } from 'preact/test-utils';
|
|
16
|
+
import { AgentAdmin } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin';
|
|
17
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
18
|
+
import type { ToolCallData } from '@kabmo-labs/kabmo-chat/contracts/chat';
|
|
19
|
+
|
|
20
|
+
let container: HTMLElement;
|
|
21
|
+
|
|
22
|
+
beforeAll(() => installDomGlobals(new Window()));
|
|
23
|
+
afterAll(() => restoreDomGlobals());
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
container = document.createElement('div');
|
|
26
|
+
document.body.appendChild(container);
|
|
27
|
+
});
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
render(null, container);
|
|
30
|
+
container.remove();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function paint(tool: ToolCallData): string {
|
|
34
|
+
act(() => { render(h(AgentAdmin, { tool }), container); });
|
|
35
|
+
return container.textContent ?? '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function agentTool(partial: Partial<ToolCallData> & Pick<ToolCallData, 'name'>): ToolCallData {
|
|
39
|
+
return { id: 'a1', type: 'other', title: `Run ${partial.name}`, status: 'success', ...partial } as ToolCallData;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('AgentAdmin panel', () => {
|
|
43
|
+
test('draws a background-task call and says the result is missing', () => {
|
|
44
|
+
const text = paint(agentTool({
|
|
45
|
+
name: 'manage_task',
|
|
46
|
+
input: { Action: 'kill', TaskId: '8b46…/task-23' },
|
|
47
|
+
}));
|
|
48
|
+
expect(text).toContain('Background task');
|
|
49
|
+
expect(text).toContain('kill');
|
|
50
|
+
expect(text).toContain('Task id');
|
|
51
|
+
expect(text).toContain('8b46…/task-23');
|
|
52
|
+
expect(text).toContain('did not report a result');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The card for the agent's own control plane.
|
|
8
|
+
*
|
|
9
|
+
* `agent_admin` is the renderer family for tools that manipulate the agent
|
|
10
|
+
* (background tasks, subagents, schedules, messages), which antigravity sends
|
|
11
|
+
* with no result payload. The card therefore draws the ARGUMENTS as structure —
|
|
12
|
+
* action, target, brief — and says when a result was not reported, instead of
|
|
13
|
+
* rendering a guessed Bash/Task body or an unreadable JSON document.
|
|
14
|
+
*
|
|
15
|
+
* The agent's ask is NOT one of these verbs: it has its own card (`ask-panel`),
|
|
16
|
+
* which is the one place the questions and their answer channel are drawn.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ToolCallData } from '@/shared/types';
|
|
20
|
+
import { FallbackOutput } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackOutput';
|
|
21
|
+
import { agentAdminView } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows';
|
|
22
|
+
|
|
23
|
+
export function AgentAdmin({ tool }: { tool: ToolCallData }) {
|
|
24
|
+
const view = agentAdminView(tool);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="space-y-2">
|
|
28
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
29
|
+
<span className="text-[10px] font-semibold uppercase tracking-[0.14em] text-ink/45">
|
|
30
|
+
{view.title}
|
|
31
|
+
</span>
|
|
32
|
+
{view.action && (
|
|
33
|
+
<span className="rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[10px] text-ink/60">
|
|
34
|
+
{view.action}
|
|
35
|
+
</span>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{view.fields.map((field) => (
|
|
40
|
+
field.block ? (
|
|
41
|
+
<div key={field.label} className="space-y-1">
|
|
42
|
+
<div className="text-[10px] font-semibold uppercase tracking-[0.14em] text-ink/40">
|
|
43
|
+
{field.label}
|
|
44
|
+
</div>
|
|
45
|
+
<pre className="max-h-64 overflow-auto rounded-lg border border-ink/8 bg-canvas/40 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/80 select-text">
|
|
46
|
+
{field.value}
|
|
47
|
+
</pre>
|
|
48
|
+
</div>
|
|
49
|
+
) : (
|
|
50
|
+
<div key={field.label} className="flex items-start gap-2 text-[11.5px]">
|
|
51
|
+
<span className="w-24 shrink-0 text-[10px] font-semibold uppercase tracking-[0.14em] text-ink/40">
|
|
52
|
+
{field.label}
|
|
53
|
+
</span>
|
|
54
|
+
<span
|
|
55
|
+
className={field.mono
|
|
56
|
+
? 'min-w-0 flex-1 break-all font-mono text-[11px] text-ink/80 select-text'
|
|
57
|
+
: 'min-w-0 flex-1 whitespace-pre-wrap text-ink/80 select-text'}
|
|
58
|
+
>
|
|
59
|
+
{field.value}
|
|
60
|
+
</span>
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
))}
|
|
64
|
+
|
|
65
|
+
{view.note && (
|
|
66
|
+
<p className="text-[10.5px] leading-relaxed text-ink/45">{view.note}</p>
|
|
67
|
+
)}
|
|
68
|
+
|
|
69
|
+
{tool.output && <FallbackOutput text={tool.output} />}
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The MCP panel's two argument surfaces.
|
|
8
|
+
*
|
|
9
|
+
* The legacy `write xd://mcp__…` transport carries the call's arguments as a
|
|
10
|
+
* JSON string in `content`; an ACP `mcp__` call carries the same facts as a
|
|
11
|
+
* structured `rawInput` object. The panel read only `content`, so an ACP MCP
|
|
12
|
+
* call drew its header and result but never the arguments it asked with —
|
|
13
|
+
* measured on opencode 2.2.5, whose bare server names (`envsitter_validate`)
|
|
14
|
+
* now resolve to this panel.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { Window } from 'happy-dom';
|
|
19
|
+
import { h, render } from 'preact';
|
|
20
|
+
import { act } from 'preact/test-utils';
|
|
21
|
+
import { Mcp } from './Mcp';
|
|
22
|
+
import type { ToolCallData } from '@kabmo-labs/kabmo-chat/contracts/chat';
|
|
23
|
+
|
|
24
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
|
|
25
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
26
|
+
|
|
27
|
+
beforeAll(() => {
|
|
28
|
+
const win = new Window({ url: 'http://localhost' });
|
|
29
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
30
|
+
for (const key of DOM_GLOBALS) {
|
|
31
|
+
nativeGlobals[key] = target[key];
|
|
32
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterAll(() => {
|
|
37
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
38
|
+
for (const key of DOM_GLOBALS) {
|
|
39
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
40
|
+
else target[key] = nativeGlobals[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
async function mount(call: ToolCallData): Promise<HTMLElement> {
|
|
45
|
+
const container = document.createElement('div');
|
|
46
|
+
document.body.appendChild(container);
|
|
47
|
+
await act(async () => {
|
|
48
|
+
render(h(Mcp, { tool: call }), container);
|
|
49
|
+
});
|
|
50
|
+
return container;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function tool(partial: Partial<ToolCallData>): ToolCallData {
|
|
54
|
+
return {
|
|
55
|
+
id: 'm1',
|
|
56
|
+
type: 'other',
|
|
57
|
+
name: 'mcp__sqlite_query',
|
|
58
|
+
title: 'sqlite_query',
|
|
59
|
+
status: 'success',
|
|
60
|
+
...partial,
|
|
61
|
+
} as ToolCallData;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
describe('Mcp panel', () => {
|
|
65
|
+
test('a structured rawInput is drawn per key', async () => {
|
|
66
|
+
const el = await mount(tool({
|
|
67
|
+
name: 'envsitter_validate',
|
|
68
|
+
input: { filePath: '/repo/.env' },
|
|
69
|
+
output: '{"ok":true,"issues":[]}',
|
|
70
|
+
}));
|
|
71
|
+
const text = el.textContent ?? '';
|
|
72
|
+
expect(text).toContain('envsitter_validate');
|
|
73
|
+
expect(text).toContain('filePath');
|
|
74
|
+
expect(text).toContain('/repo/.env');
|
|
75
|
+
expect(text).toContain('ok');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('the legacy write xd:// shape still parses its content JSON', async () => {
|
|
79
|
+
const el = await mount(tool({
|
|
80
|
+
type: 'write',
|
|
81
|
+
name: 'write',
|
|
82
|
+
target: 'xd://mcp__codegraph_explore',
|
|
83
|
+
input: { path: 'xd://mcp__codegraph_explore', content: '{"query":"tool renderers"}' },
|
|
84
|
+
output: '{"items":[]}',
|
|
85
|
+
}));
|
|
86
|
+
const text = el.textContent ?? '';
|
|
87
|
+
expect(text).toContain('codegraph_explore');
|
|
88
|
+
expect(text).toContain('query');
|
|
89
|
+
expect(text).toContain('tool renderers');
|
|
90
|
+
});
|
|
91
|
+
});
|