@kabmo-labs/kabmo 0.42.0 → 0.42.1
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 +592 -593
- package/dist/client/static/js/{CsvGrid-20k047ht.js → CsvGrid-8gdp5b49.js} +1 -1
- package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-j9sphgra.js} +2 -2
- package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-xsgjc7d8.js} +1 -1
- package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-ve9hc519.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-5mqffvkc.js} +2 -2
- package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-50whypff.js} +10 -10
- package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-afd5cg54.js} +1 -1
- package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-7719nvy0.js} +1 -1
- package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-gfzgxb4r.js} +1 -1
- package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-225pkb99.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-z70sk69m.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-m98sgh3c.js → architectureDiagram-NJMV4G6O-pf1gpkje.js} +3 -3
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-sr25kbn6.js} +2 -2
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-znstpg86.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-7n0pdcd8.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-zn3qw4c4.js} +1 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-4k0k429c.js → cynefinDiagram-VND7K2PF-3z41vtzs.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-5j3zn883.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-ryw1w2kh.js} +4 -4
- package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-p91q4gkh.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-22dn73g4.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-589p9n53.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-ezw06wbx.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-cfwrsvk1.js} +1 -1
- package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-r4k7q34y.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-3rv2wvbf.js} +1 -1
- package/dist/client/static/js/{elixir-mabagxwa.js → elixir-szk51ehr.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-xam60ktz.js → elk-276RUBZZ-ma40kneq.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-xwstsfqa.js} +2 -2
- package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-evp84v09.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-qxyx9tr9.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fmwjkgh6.js → gitGraphDiagram-X574FWY7-v6sg7bkh.js} +1 -1
- package/dist/client/static/js/html-tbz83eke.js +1 -0
- package/dist/client/static/js/{index-xxe52zrm.js → index-001vebsp.js} +1 -1
- package/dist/client/static/js/{index-4j8rgr4p.js → index-0nca2nhp.js} +1 -1
- package/dist/client/static/js/{index-nbexks3x.js → index-0p43qr4k.js} +1 -1
- package/dist/client/static/js/{index-yvxa7hd8.js → index-2w9j2nj4.js} +1 -1
- package/dist/client/static/js/{index-2x9eqztp.js → index-313ctswm.js} +1 -1
- package/dist/client/static/js/{index-ka2rc2cr.js → index-3d40c0a7.js} +3 -3
- package/dist/client/static/js/{index-sq3r1xhf.js → index-4y0ayjfx.js} +1 -1
- package/dist/client/static/js/{index-qj34r6d0.js → index-5599dngt.js} +1 -1
- package/dist/client/static/js/{index-hzwr5fm9.js → index-5asf5625.js} +3 -3
- package/dist/client/static/js/{index-dydwcp3n.js → index-6dxs0tvg.js} +1 -1
- package/dist/client/static/js/{index-a9t9gdew.js → index-6eq445nn.js} +4 -4
- package/dist/client/static/js/{index-4z4ax55k.js → index-869bpqcs.js} +6 -6
- package/dist/client/static/js/{index-97qst4k9.js → index-8fvmyv7t.js} +1 -1
- package/dist/client/static/js/{index-vcn1kcpy.js → index-8pdz41yh.js} +3 -3
- package/dist/client/static/js/{index-zvazj4va.js → index-9hzfvjrb.js} +1 -1
- package/dist/client/static/js/{index-9vdbnvmk.js → index-9ss64g4g.js} +1 -1
- package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
- package/dist/client/static/js/{index-ejdnjh5c.js → index-b37ewyvk.js} +1 -1
- package/dist/client/static/js/{index-z6kpc98a.js → index-b3d2k7ec.js} +1 -1
- package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
- package/dist/client/static/js/{index-1c0pnsjd.js → index-cqaz1281.js} +1 -1
- package/dist/client/static/js/{index-sx809d6d.js → index-df4yxfzd.js} +1 -1
- package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
- package/dist/client/static/js/{index-sz3mxjvy.js → index-kh6vp5w5.js} +1 -1
- package/dist/client/static/js/{index-x7f5ysch.js → index-mphhvgm9.js} +1 -1
- package/dist/client/static/js/{index-13xbwcbz.js → index-mq6s2faf.js} +1 -1
- package/dist/client/static/js/{index-xe5cqwnf.js → index-mvykbyhe.js} +1 -1
- package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
- package/dist/client/static/js/{index-tqycj126.js → index-q3qpm7jn.js} +1 -1
- package/dist/client/static/js/{index-6ge6gk9w.js → index-qh753ynv.js} +1 -1
- package/dist/client/static/js/{index-8hgm0abr.js → index-rt6ac0kk.js} +175 -171
- package/dist/client/static/js/{index-b4y5g48d.js → index-sr7sdm2t.js} +1 -1
- package/dist/client/static/js/{index-8jqawh3r.js → index-v5dbrq83.js} +1 -1
- package/dist/client/static/js/{index-1rxa9zxp.js → index-w5q9ymf4.js} +1 -1
- package/dist/client/static/js/{index-4mstdh41.js → index-x7a5jpvq.js} +1 -1
- package/dist/client/static/js/{index-7t63akyt.js → index-x7m6dmt4.js} +1 -1
- package/dist/client/static/js/{index-13dr1t1r.js → index-xsts4pqm.js} +23 -23
- package/dist/client/static/js/{index-95en3p3g.js → index-y1p3bdsw.js} +4 -4
- package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-0anekyhb.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-zxpmfkjb.js} +2 -2
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-1e86fzra.js} +2 -2
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-e85hhmr1.js} +4 -4
- package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-jpcrnzyw.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-xwy5928e.js} +1 -1
- package/dist/client/static/js/one-dark-pro-r0tswz8r.js +1 -0
- package/dist/client/static/js/one-light-xzcfrptf.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-dfg2j0zc.js → pegDiagram-GJSIUBJH-7dy6pw26.js} +1 -1
- package/dist/client/static/js/{perl-5vxax0nr.js → perl-dtn1fccw.js} +1 -1
- package/dist/client/static/js/{php-hgrgdq63.js → php-7av78hch.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-pshd1j79.js → pieDiagram-5QR66LMP-nrv2t5yn.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-3nt63xr8.js} +1 -1
- package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-h53p3sha.js → railroadDiagram-XR7U4H2S-evm05hzp.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-tzrcmktj.js} +1 -1
- package/dist/client/static/js/{ruby-8pxcn21w.js → ruby-s2bqr910.js} +1 -1
- package/dist/client/static/js/{rust-j80dxgjg.js → rust-pcvgybk3.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-jvjd5rz8.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-0zvjwx29.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-6t6g0edv.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-nb13b23a.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-ef8vmg6f.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-f4sx355z.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-3bfph698.js} +3 -3
- package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0gpn21p7.js → usecaseDiagram-POWQR4AR-vj6yj6tc.js} +7 -7
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-9xyyabaq.js} +2 -2
- package/dist/client/static/js/{vue-xm1dxpmy.js → vue-cbqm4bed.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-745xr2pa.js → wardleyDiagram-VNRHLVJA-zpcwgv9d.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-pdr2rms2.js} +3 -3
- package/package.json +1 -1
- package/src/cli/lib/commands/session.js +12 -1
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
- package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
- package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
- package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
- package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
- package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
- package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
- package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
- package/src/server/lib/harness/acp/session-exit.ts +39 -5
- package/src/server/lib/harness/acp/session-turns.ts +67 -12
- package/src/server/lib/harness/acp/session.test.ts +61 -0
- package/src/server/lib/harness/acp/session.ts +15 -25
- package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
- package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
- package/src/server/lib/harness/acp/turn-silence.ts +52 -0
- package/src/server/lib/harness/acp/turn.test.ts +85 -3
- package/src/server/lib/harness/acp/turn.ts +62 -4
- package/src/server/lib/lifecycle/after-listen.ts +10 -0
- package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +25 -2
- package/src/server/lib/omp/rpc/manager.ts +9 -8
- package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
- package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
- package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
- package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
- package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
- package/src/server/lib/omp/rpc/session-commands.ts +38 -17
- package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
- package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
- package/src/server/lib/sessions/notify.server.test.ts +11 -3
- package/src/server/lib/sessions/notify.server.ts +67 -42
- package/src/server/lib/sessions/spawn.server.test.ts +5 -1
- package/src/server/lib/sessions/spawn.server.ts +8 -3
- package/src/server/routes/sessions/answer.test.ts +62 -0
- package/src/server/routes/sessions/answer.ts +13 -2
- package/src/shared/lib/chat/composer/delegation.ts +11 -7
- package/src/shared/lib/chat/export-markdown.ts +19 -0
- package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
- package/src/shared/lib/chat/orchestration/notice.ts +183 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
- package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
- package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +0 -1
- package/dist/client/static/js/html-bwyt0ayy.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +0 -1
- package/dist/client/static/js/one-dark-pro-9tt0a020.js +0 -1
- package/dist/client/static/js/one-light-5fg4r0ra.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The verb→RPC mapping of the session command dispatcher, and the two
|
|
8
|
+
* non-command verbs: answering a parked extension dialog and the verbatim
|
|
9
|
+
* passthrough.
|
|
10
|
+
*
|
|
11
|
+
* Every case is a place where a wrong mapping is a user-visible lie — a rename
|
|
12
|
+
* that keeps its padding, a model identity the ack did not resolve, an
|
|
13
|
+
* `abort_compaction` that arrives as something else, a shell command admitted
|
|
14
|
+
* over a live turn. Split from `session-commands.test.ts` so that suite stays
|
|
15
|
+
* under the repo's per-file size ceiling; the host and the process are fakes, no
|
|
16
|
+
* omp child is spawned.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
20
|
+
|
|
21
|
+
import { dispatchSessionCommand } from '@/server/lib/omp/rpc/session-commands';
|
|
22
|
+
import { cancelQueuedDelivery } from '@/server/lib/queue/delivery.server';
|
|
23
|
+
import { makeHarness, rejectionOf } from '@/server/lib/omp/rpc/session-commands-harness';
|
|
24
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
25
|
+
|
|
26
|
+
beforeEach(async () => {
|
|
27
|
+
await isolateDb();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(async () => {
|
|
31
|
+
cancelQueuedDelivery('sess-1');
|
|
32
|
+
await releaseDb();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('argument mapping', () => {
|
|
36
|
+
test('set_session_name trims and refuses a blank name', async () => {
|
|
37
|
+
const h = makeHarness();
|
|
38
|
+
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'set_session_name', name: ' ' })))).toContain(
|
|
39
|
+
'Session name cannot be empty',
|
|
40
|
+
);
|
|
41
|
+
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'set_session_name' })))).toContain(
|
|
42
|
+
'Session name cannot be empty',
|
|
43
|
+
);
|
|
44
|
+
expect(h.calls).toEqual([]);
|
|
45
|
+
await dispatchSessionCommand(h.host, { type: 'set_session_name', name: ' My chat ' });
|
|
46
|
+
expect(h.calls).toEqual([{ type: 'set_session_name', name: 'My chat' }]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('set_model returns only the identity pair, and read/abort aliases map correctly', async () => {
|
|
50
|
+
const h = makeHarness();
|
|
51
|
+
h.respond(() => ({ id: 'm1', provider: 'p1', name: 'ignored', contextWindow: 1 }));
|
|
52
|
+
expect(await dispatchSessionCommand(h.host, { type: 'set_model', provider: 'p1', modelId: 'm1' })).toEqual({
|
|
53
|
+
id: 'm1',
|
|
54
|
+
provider: 'p1',
|
|
55
|
+
});
|
|
56
|
+
// The ack's RESOLVED pair is what a later prompt dispatch persists on the
|
|
57
|
+
// stream row for the generating indicator.
|
|
58
|
+
expect(h.host.runModel).toEqual({ provider: 'p1', modelId: 'm1' });
|
|
59
|
+
expect(await dispatchSessionCommand(h.host, { type: 'abort_compaction' })).toBeNull();
|
|
60
|
+
h.respond(() => ({ commands: [{ name: 'x' }] }));
|
|
61
|
+
expect(await dispatchSessionCommand(h.host, { type: 'get_commands' })).toEqual({ commands: [{ name: 'x' }] });
|
|
62
|
+
expect(h.calls).toEqual([
|
|
63
|
+
{ type: 'set_model', provider: 'p1', modelId: 'm1' },
|
|
64
|
+
{ type: 'abort' },
|
|
65
|
+
{ type: 'get_available_commands' },
|
|
66
|
+
]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('set_fast_mode only treats the literal true as enabled', async () => {
|
|
70
|
+
const h = makeHarness();
|
|
71
|
+
h.respond(() => ({}));
|
|
72
|
+
expect(await dispatchSessionCommand(h.host, { type: 'set_fast_mode', enabled: 'yes' })).toEqual({ enabled: false, active: false });
|
|
73
|
+
h.respond(() => ({ enabled: true, active: true }));
|
|
74
|
+
expect(await dispatchSessionCommand(h.host, { type: 'set_fast_mode', enabled: true })).toEqual({ enabled: true, active: true });
|
|
75
|
+
expect(h.host.fastModeEnabled).toBe(true);
|
|
76
|
+
expect(h.calls).toEqual([{ type: 'set_fast_mode', enabled: false }, { type: 'set_fast_mode', enabled: true }]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('compact forwards custom instructions only when present', async () => {
|
|
80
|
+
const h = makeHarness();
|
|
81
|
+
await dispatchSessionCommand(h.host, { type: 'compact' });
|
|
82
|
+
await dispatchSessionCommand(h.host, { type: 'compact', customInstructions: 'keep the plan' });
|
|
83
|
+
expect(h.calls).toEqual([{ type: 'compact' }, { type: 'compact', customInstructions: 'keep the plan' }]);
|
|
84
|
+
expect(h.host.compacting).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('bash refuses while the session is busy and clears the flag after', async () => {
|
|
88
|
+
const h = makeHarness({ isRunning: () => true });
|
|
89
|
+
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'bash', command: 'ls' })))).toContain(
|
|
90
|
+
'Cannot run a shell command while the session is busy',
|
|
91
|
+
);
|
|
92
|
+
const idle = makeHarness();
|
|
93
|
+
await dispatchSessionCommand(idle.host, { type: 'bash', command: 'ls' });
|
|
94
|
+
expect(idle.calls).toEqual([{ type: 'bash', command: 'ls' }]);
|
|
95
|
+
expect(idle.host.bashRunning).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('force_reset destroys the session without sending anything', async () => {
|
|
99
|
+
const h = makeHarness();
|
|
100
|
+
expect(await dispatchSessionCommand(h.host, { type: 'force_reset' })).toBeNull();
|
|
101
|
+
expect(h.counters.destroys).toBe(1);
|
|
102
|
+
expect(h.calls).toEqual([]);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('extension_ui_response', () => {
|
|
107
|
+
test('requires an id and otherwise writes a frame without awaiting a response', async () => {
|
|
108
|
+
const h = makeHarness();
|
|
109
|
+
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'extension_ui_response', result: 'ok' })))).toContain(
|
|
110
|
+
'extension_ui_response requires an id',
|
|
111
|
+
);
|
|
112
|
+
expect(await dispatchSessionCommand(h.host, { type: 'extension_ui_response', id: 'ui-1', result: 'ok' })).toBeNull();
|
|
113
|
+
expect(h.calls).toEqual([]);
|
|
114
|
+
expect(h.frames).toEqual([{ type: 'extension_ui_response', id: 'ui-1', result: 'ok' }]);
|
|
115
|
+
expect(h.counters.resolvedDialogs).toEqual(['ui-1']);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('passthrough', () => {
|
|
120
|
+
test('the command is forwarded verbatim and an empty ack reads as null', async () => {
|
|
121
|
+
const h = makeHarness();
|
|
122
|
+
expect(await dispatchSessionCommand(h.host, { type: 'get_messages', limit: 5 })).toBeNull();
|
|
123
|
+
expect(h.calls).toEqual([{ type: 'get_messages', limit: 5 }]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('the ack payload is returned unchanged', async () => {
|
|
127
|
+
const h = makeHarness();
|
|
128
|
+
h.respond(() => ({ messages: ['a'] }));
|
|
129
|
+
expect(await dispatchSessionCommand(h.host, { type: 'get_messages_page' })).toEqual({ messages: ['a'] });
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -15,35 +15,37 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
18
|
-
import { mkdtempSync } from 'node:fs';
|
|
19
|
-
import { tmpdir } from 'node:os';
|
|
20
|
-
import { join } from 'node:path';
|
|
21
18
|
|
|
22
19
|
import { dispatchSessionCommand } from '@/server/lib/omp/rpc/session-commands';
|
|
20
|
+
import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
|
|
21
|
+
import type { SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold-contract';
|
|
22
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
23
23
|
import { RpcCommandError, RpcCommandTimeoutError } from '@/server/lib/omp/rpc/process';
|
|
24
24
|
import { AGENT_BUSY_MESSAGE, AWAITING_AGENT_START_TIMEOUT_MS, RESTARTING_MESSAGE, SESSION_BUSY_MESSAGE, WebRpcError } from '@/server/lib/omp/rpc/constants';
|
|
25
25
|
import { cancelQueuedDelivery } from '@/server/lib/queue/delivery.server';
|
|
26
26
|
import { makeHarness, rejectionOf } from '@/server/lib/omp/rpc/session-commands-harness';
|
|
27
|
-
import {
|
|
27
|
+
import { getDb } from '@/server/db.server';
|
|
28
|
+
import { loadStreamStates } from '@/shared/lib/omp/session/stream-state.server';
|
|
29
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Isolated through the shared helper, not by hand.
|
|
33
|
+
*
|
|
34
|
+
* The stream-status writes resolve the database, so every case runs against a
|
|
35
|
+
* temp tree and the real `~/.kabmo` is never opened. Clearing
|
|
36
|
+
* `globalThis.__kabmoDb` is NOT a teardown: it drops the reference while the
|
|
37
|
+
* SQLite handle stays open, and Windows then refuses to delete the temp tree —
|
|
38
|
+
* measured on the Release gate as `EBUSY … a handle outlived its test` after the
|
|
39
|
+
* full 5 s retry window, reported against the case that had just opened the
|
|
40
|
+
* database. `releaseDb` closes the handle before deleting.
|
|
41
|
+
*/
|
|
42
|
+
beforeEach(async () => {
|
|
43
|
+
await isolateDb();
|
|
39
44
|
});
|
|
40
45
|
|
|
41
|
-
afterEach(() => {
|
|
46
|
+
afterEach(async () => {
|
|
42
47
|
cancelQueuedDelivery('sess-1');
|
|
43
|
-
|
|
44
|
-
if (savedDbPath === undefined) delete Bun.env.KABMO_DB_PATH;
|
|
45
|
-
else Bun.env.KABMO_DB_PATH = savedDbPath;
|
|
46
|
-
removeDir(root);
|
|
48
|
+
await releaseDb();
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
describe('guards before dispatch', () => {
|
|
@@ -130,6 +132,80 @@ describe('prompt', () => {
|
|
|
130
132
|
expect(h.events).toEqual([{ type: 'prompt_result', agentInvoked: false }]);
|
|
131
133
|
});
|
|
132
134
|
|
|
135
|
+
/**
|
|
136
|
+
* A slash command may not claim the turn slot.
|
|
137
|
+
*
|
|
138
|
+
* Real omp 18.22.2 answers an EXTENSION command (`/kabmo-mode plan
|
|
139
|
+
* republish`) with a BARE ack and a later `prompt_result
|
|
140
|
+
* {agentInvoked:false}` — measured on a real child. The optimistic claim read
|
|
141
|
+
* that bare ack as an admitted turn: it wrote a `stream` row and held
|
|
142
|
+
* `promptRunning` until the 10 s agent-start watchdog, while the frame that
|
|
143
|
+
* proved no turn opened was suppressed by the run-attribution rule. The
|
|
144
|
+
* sidebar spinner and the docked indicator therefore kept turning over a
|
|
145
|
+
* session that had already finished — reproduced by merely OPENING a settled
|
|
146
|
+
* session, because `usePlanReview` dispatches that republish on mount.
|
|
147
|
+
*/
|
|
148
|
+
test('a slash command with a bare ack claims nothing and writes no stream row', async () => {
|
|
149
|
+
const h = makeHarness();
|
|
150
|
+
// The status writes resolve the database; open it first so the assertion
|
|
151
|
+
// below reads a settled handle rather than racing the first open.
|
|
152
|
+
await getDb();
|
|
153
|
+
h.respond(() => ({}));
|
|
154
|
+
expect(await dispatchSessionCommand(h.host, { type: 'prompt', message: '/kabmo-mode plan republish' })).toBeNull();
|
|
155
|
+
expect(h.host.promptRunning).toBe(false);
|
|
156
|
+
expect(h.host.awaitingAgentStart).toBe(false);
|
|
157
|
+
expect(h.counters.watchdogs).toBe(0);
|
|
158
|
+
expect(h.events).toEqual([]);
|
|
159
|
+
// The row is fire-and-forget; flush it so a write that DID happen would be
|
|
160
|
+
// visible here.
|
|
161
|
+
for (let turn = 0; turn < 40; turn += 1) await Promise.resolve();
|
|
162
|
+
expect(await loadStreamStates()).toEqual({});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('a local builtin settles the client without writing a stream row', async () => {
|
|
166
|
+
const h = makeHarness();
|
|
167
|
+
await getDb();
|
|
168
|
+
// `/usage` is a LOCAL builtin: omp acks `agentInvoked:false` and sends no
|
|
169
|
+
// `prompt_result`, so this branch is the only settle path.
|
|
170
|
+
h.respond(() => ({ agentInvoked: false }));
|
|
171
|
+
await dispatchSessionCommand(h.host, { type: 'prompt', message: '/usage' });
|
|
172
|
+
expect(h.host.promptRunning).toBe(false);
|
|
173
|
+
expect(h.counters.watchdogs).toBe(0);
|
|
174
|
+
expect(h.events).toEqual([{ type: 'prompt_result', agentInvoked: false }]);
|
|
175
|
+
for (let turn = 0; turn < 40; turn += 1) await Promise.resolve();
|
|
176
|
+
expect(await loadStreamStates()).toEqual({});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('a PLAIN prompt still claims the slot on a bare ack', async () => {
|
|
180
|
+
// The claim exists for this case: a real turn acks bare and only announces
|
|
181
|
+
// itself at `agent_start`, and the window between them is where the sidebar
|
|
182
|
+
// must already show a spinner.
|
|
183
|
+
const h = makeHarness();
|
|
184
|
+
h.respond(() => ({}));
|
|
185
|
+
await dispatchSessionCommand(h.host, { type: 'prompt', message: 'hello' });
|
|
186
|
+
expect(h.host.promptRunning).toBe(true);
|
|
187
|
+
expect(h.host.awaitingAgentStart).toBe(true);
|
|
188
|
+
expect(h.counters.watchdogs).toBe(1);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('the prompt_result that follows a bare-acked command reaches the client', async () => {
|
|
192
|
+
// The composition is the bug: the dispatch must not claim the slot, or the
|
|
193
|
+
// fold suppresses the very frame that proves no turn opened. With the claim
|
|
194
|
+
// in place this frame was swallowed and the row stayed `stream` until the
|
|
195
|
+
// 10 s watchdog — the spinner over a finished session.
|
|
196
|
+
const h = makeHarness();
|
|
197
|
+
h.respond(() => ({}));
|
|
198
|
+
await dispatchSessionCommand(h.host, { type: 'prompt', message: '/kabmo-mode plan republish' });
|
|
199
|
+
const { suppressForward } = foldSessionFrame(
|
|
200
|
+
h.host as unknown as SessionFrameHost,
|
|
201
|
+
{ type: 'prompt_result', agentInvoked: false } as AgentEvent,
|
|
202
|
+
);
|
|
203
|
+
// The manager forwards a frame the fold did not suppress; the fold itself
|
|
204
|
+
// only decides. `true` here is the bug: the client never learns the prompt
|
|
205
|
+
// opened no turn.
|
|
206
|
+
expect(suppressForward).toBe(false);
|
|
207
|
+
});
|
|
208
|
+
|
|
133
209
|
test('a streamingBehavior prompt does not claim the turn flags', async () => {
|
|
134
210
|
const h = makeHarness();
|
|
135
211
|
h.respond(() => ({ agentInvoked: true }));
|
|
@@ -226,100 +302,3 @@ describe('prompt', () => {
|
|
|
226
302
|
});
|
|
227
303
|
});
|
|
228
304
|
|
|
229
|
-
describe('argument mapping', () => {
|
|
230
|
-
test('set_session_name trims and refuses a blank name', async () => {
|
|
231
|
-
const h = makeHarness();
|
|
232
|
-
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'set_session_name', name: ' ' })))).toContain(
|
|
233
|
-
'Session name cannot be empty',
|
|
234
|
-
);
|
|
235
|
-
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'set_session_name' })))).toContain(
|
|
236
|
-
'Session name cannot be empty',
|
|
237
|
-
);
|
|
238
|
-
expect(h.calls).toEqual([]);
|
|
239
|
-
await dispatchSessionCommand(h.host, { type: 'set_session_name', name: ' My chat ' });
|
|
240
|
-
expect(h.calls).toEqual([{ type: 'set_session_name', name: 'My chat' }]);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
test('set_model returns only the identity pair, and read/abort aliases map correctly', async () => {
|
|
244
|
-
const h = makeHarness();
|
|
245
|
-
h.respond(() => ({ id: 'm1', provider: 'p1', name: 'ignored', contextWindow: 1 }));
|
|
246
|
-
expect(await dispatchSessionCommand(h.host, { type: 'set_model', provider: 'p1', modelId: 'm1' })).toEqual({
|
|
247
|
-
id: 'm1',
|
|
248
|
-
provider: 'p1',
|
|
249
|
-
});
|
|
250
|
-
// The ack's RESOLVED pair is what a later prompt dispatch persists on the
|
|
251
|
-
// stream row for the generating indicator.
|
|
252
|
-
expect(h.host.runModel).toEqual({ provider: 'p1', modelId: 'm1' });
|
|
253
|
-
expect(await dispatchSessionCommand(h.host, { type: 'abort_compaction' })).toBeNull();
|
|
254
|
-
h.respond(() => ({ commands: [{ name: 'x' }] }));
|
|
255
|
-
expect(await dispatchSessionCommand(h.host, { type: 'get_commands' })).toEqual({ commands: [{ name: 'x' }] });
|
|
256
|
-
expect(h.calls).toEqual([
|
|
257
|
-
{ type: 'set_model', provider: 'p1', modelId: 'm1' },
|
|
258
|
-
{ type: 'abort' },
|
|
259
|
-
{ type: 'get_available_commands' },
|
|
260
|
-
]);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test('set_fast_mode only treats the literal true as enabled', async () => {
|
|
264
|
-
const h = makeHarness();
|
|
265
|
-
h.respond(() => ({}));
|
|
266
|
-
expect(await dispatchSessionCommand(h.host, { type: 'set_fast_mode', enabled: 'yes' })).toEqual({ enabled: false, active: false });
|
|
267
|
-
h.respond(() => ({ enabled: true, active: true }));
|
|
268
|
-
expect(await dispatchSessionCommand(h.host, { type: 'set_fast_mode', enabled: true })).toEqual({ enabled: true, active: true });
|
|
269
|
-
expect(h.host.fastModeEnabled).toBe(true);
|
|
270
|
-
expect(h.calls).toEqual([{ type: 'set_fast_mode', enabled: false }, { type: 'set_fast_mode', enabled: true }]);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
test('compact forwards custom instructions only when present', async () => {
|
|
274
|
-
const h = makeHarness();
|
|
275
|
-
await dispatchSessionCommand(h.host, { type: 'compact' });
|
|
276
|
-
await dispatchSessionCommand(h.host, { type: 'compact', customInstructions: 'keep the plan' });
|
|
277
|
-
expect(h.calls).toEqual([{ type: 'compact' }, { type: 'compact', customInstructions: 'keep the plan' }]);
|
|
278
|
-
expect(h.host.compacting).toBe(false);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
test('bash refuses while the session is busy and clears the flag after', async () => {
|
|
282
|
-
const h = makeHarness({ isRunning: () => true });
|
|
283
|
-
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'bash', command: 'ls' })))).toContain(
|
|
284
|
-
'Cannot run a shell command while the session is busy',
|
|
285
|
-
);
|
|
286
|
-
const idle = makeHarness();
|
|
287
|
-
await dispatchSessionCommand(idle.host, { type: 'bash', command: 'ls' });
|
|
288
|
-
expect(idle.calls).toEqual([{ type: 'bash', command: 'ls' }]);
|
|
289
|
-
expect(idle.host.bashRunning).toBe(false);
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
test('force_reset destroys the session without sending anything', async () => {
|
|
293
|
-
const h = makeHarness();
|
|
294
|
-
expect(await dispatchSessionCommand(h.host, { type: 'force_reset' })).toBeNull();
|
|
295
|
-
expect(h.counters.destroys).toBe(1);
|
|
296
|
-
expect(h.calls).toEqual([]);
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
describe('extension_ui_response', () => {
|
|
301
|
-
test('requires an id and otherwise writes a frame without awaiting a response', async () => {
|
|
302
|
-
const h = makeHarness();
|
|
303
|
-
expect(String(await rejectionOf(dispatchSessionCommand(h.host, { type: 'extension_ui_response', result: 'ok' })))).toContain(
|
|
304
|
-
'extension_ui_response requires an id',
|
|
305
|
-
);
|
|
306
|
-
expect(await dispatchSessionCommand(h.host, { type: 'extension_ui_response', id: 'ui-1', result: 'ok' })).toBeNull();
|
|
307
|
-
expect(h.calls).toEqual([]);
|
|
308
|
-
expect(h.frames).toEqual([{ type: 'extension_ui_response', id: 'ui-1', result: 'ok' }]);
|
|
309
|
-
expect(h.counters.resolvedDialogs).toEqual(['ui-1']);
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
describe('passthrough', () => {
|
|
314
|
-
test('the command is forwarded verbatim and an empty ack reads as null', async () => {
|
|
315
|
-
const h = makeHarness();
|
|
316
|
-
expect(await dispatchSessionCommand(h.host, { type: 'get_messages', limit: 5 })).toBeNull();
|
|
317
|
-
expect(h.calls).toEqual([{ type: 'get_messages', limit: 5 }]);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
test('the ack payload is returned unchanged', async () => {
|
|
321
|
-
const h = makeHarness();
|
|
322
|
-
h.respond(() => ({ messages: ['a'] }));
|
|
323
|
-
expect(await dispatchSessionCommand(h.host, { type: 'get_messages_page' })).toEqual({ messages: ['a'] });
|
|
324
|
-
});
|
|
325
|
-
});
|
|
@@ -53,6 +53,22 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
|
|
|
53
53
|
// bounded so a wedged child cannot hold the operator's prompt.
|
|
54
54
|
await awaitTitleDispatch(host);
|
|
55
55
|
const streamingBehavior = command.streamingBehavior as 'steer' | 'followUp' | undefined;
|
|
56
|
+
// A slash command is Kabmo's control channel or one of omp's builtins, and
|
|
57
|
+
// NEITHER opens a turn on its own. Measured against omp 18.22.2:
|
|
58
|
+
// - a LOCAL builtin (`/rename`, `/usage`) acks `{agentInvoked:false}` and
|
|
59
|
+
// sends no `prompt_result`;
|
|
60
|
+
// - an EXTENSION command (`/kabmo-mode plan republish`) acks BARE
|
|
61
|
+
// (`{"type":"response","command":"prompt","success":true}`) and reports
|
|
62
|
+
// `prompt_result {agentInvoked:false}` afterwards.
|
|
63
|
+
// So a slash command must not claim the turn slot optimistically. The
|
|
64
|
+
// claim wrote a `stream` row and held `promptRunning` for the agent-start
|
|
65
|
+
// watchdog, while the frame that proved no turn opened was suppressed by
|
|
66
|
+
// the run-attribution rule — the sidebar spinner and the docked indicator
|
|
67
|
+
// kept turning for 10 s over a session that had already finished
|
|
68
|
+
// (reproduced on mount: the plan-review `republish`). A slash command that
|
|
69
|
+
// DOES open a turn is covered by the frames: its `agent_start` sets both
|
|
70
|
+
// flags and writes the row itself, milliseconds later.
|
|
71
|
+
const looksLikeCommand = typeof command.message === 'string' && command.message.trimStart().startsWith('/');
|
|
56
72
|
// The live `stream` row starts with the DISPATCH, not with agent_start:
|
|
57
73
|
// the spawn/ack round trip that precedes agent_start must not read as
|
|
58
74
|
// "nothing happened" in the sidebar after the user hit send. Skipped
|
|
@@ -63,19 +79,20 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
|
|
|
63
79
|
// so a dispatch that arrives DURING the ack round trip of an earlier one
|
|
64
80
|
// saw `streaming === false` and claimed the turn slot for itself. The
|
|
65
81
|
// own `/kabmo-mode` commands are dispatched on that path (the
|
|
66
|
-
// plan-review `republish`, a mode toggle)
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
const
|
|
82
|
+
// plan-review `republish`, a mode toggle), so the claim made them release
|
|
83
|
+
// the RUNNING turn's `stream` row and emit a `prompt_result` — which the
|
|
84
|
+
// client folds as "the run settled", blanking the generating indicator
|
|
85
|
+
// mid-answer. `isRunning()` is true for the whole dispatch (promptRunning
|
|
86
|
+
// is set before the ack), so a secondary command now owns nothing and
|
|
87
|
+
// settles nothing.
|
|
88
|
+
const ownsSlot = !streamingBehavior && !host.isRunning() && Boolean(host.sessionId);
|
|
89
|
+
const ownsStreamRow = ownsSlot && !looksLikeCommand;
|
|
73
90
|
// A prompt that never started a turn leaves no run behind, so the row we
|
|
74
91
|
// wrote must go — unless a turn began meanwhile, which owns it now.
|
|
75
92
|
const releaseStreamRow = (): void => {
|
|
76
93
|
if (ownsStreamRow && !host.streaming) void clearStreamStatus(host.sessionId);
|
|
77
94
|
};
|
|
78
|
-
if (!streamingBehavior) {
|
|
95
|
+
if (!streamingBehavior && !looksLikeCommand) {
|
|
79
96
|
host.promptRunning = true;
|
|
80
97
|
host.promptDispatchPendingCount += 1;
|
|
81
98
|
host.awaitingAgentStart = false;
|
|
@@ -98,14 +115,15 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
|
|
|
98
115
|
...(streamingBehavior ? { streamingBehavior } : {}),
|
|
99
116
|
}, promptAckTimeoutMs(command.images));
|
|
100
117
|
if (ack?.agentInvoked === false && !streamingBehavior) {
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
|
|
118
|
+
// omp's own word that this prompt opened no turn. Settle the dispatch
|
|
119
|
+
// and tell the client, which is what releases its optimistic turn.
|
|
120
|
+
// Gated on the slot being FREE when the prompt arrived: a local
|
|
121
|
+
// builtin dispatched mid-turn (a `/usage` typed while a run streams)
|
|
122
|
+
// must not settle the run the operator is watching. A slash command
|
|
123
|
+
// never claimed the slot, so this branch is its only settle path for
|
|
124
|
+
// the `{agentInvoked:false}` ack — the row was never written, and the
|
|
125
|
+
// client still needs the frame.
|
|
126
|
+
if (ownsSlot) {
|
|
109
127
|
host.promptRunning = false;
|
|
110
128
|
host.awaitingAgentStart = false;
|
|
111
129
|
host.awaitingAgentStartDeadline = 0;
|
|
@@ -157,7 +175,10 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
|
|
|
157
175
|
}
|
|
158
176
|
throw error;
|
|
159
177
|
} finally {
|
|
160
|
-
|
|
178
|
+
// Only a dispatch that INCREMENTED the count may decrement it: a slash
|
|
179
|
+
// command never claims the slot, and its `finally` would otherwise
|
|
180
|
+
// consume a concurrent plain prompt's pending count.
|
|
181
|
+
if (!streamingBehavior && !looksLikeCommand) {
|
|
161
182
|
host.promptDispatchPendingCount = Math.max(0, host.promptDispatchPendingCount - 1);
|
|
162
183
|
}
|
|
163
184
|
}
|