@kabmo-labs/kabmo 0.42.0 → 0.42.2
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-g6rek8y9.js} +1 -1
- package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-41t9ryws.js} +2 -2
- package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-mfxhfz1h.js} +1 -1
- package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-bxqw3t4k.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-zt14rv9m.js} +2 -2
- package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-cm35g20x.js} +10 -10
- package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-bek8k888.js} +1 -1
- package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-gn53zyn7.js} +1 -1
- package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-vezssf6b.js} +1 -1
- package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-f1qaw73k.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-4qn94h52.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-tbewzdya.js} +3 -3
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-njgnwckz.js} +2 -2
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-f58pcvbk.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-52g73vyw.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-ptdnshzh.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-qabfdkzr.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-kyf5jetf.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-bxrsjtv9.js} +4 -4
- package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-0f41s00j.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-0z1zx9h1.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-znrmr6bk.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-jfe2jhk0.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-2kaawmwa.js} +1 -1
- package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-12exatm9.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-s5n37rfp.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-433rd9fp.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-key6ah0b.js} +2 -2
- package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-4efkhmca.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-ac376y2k.js} +1 -1
- package/dist/client/static/js/html-tbz83eke.js +1 -0
- package/dist/client/static/js/{index-13xbwcbz.js → index-02543wk3.js} +1 -1
- package/dist/client/static/js/{index-sx809d6d.js → index-0e9nkc0g.js} +1 -1
- package/dist/client/static/js/{index-1c0pnsjd.js → index-0gbj4270.js} +1 -1
- package/dist/client/static/js/{index-z6kpc98a.js → index-0pabfaac.js} +1 -1
- package/dist/client/static/js/{index-4mstdh41.js → index-1t5ybx9v.js} +1 -1
- package/dist/client/static/js/{index-9vdbnvmk.js → index-1y3rzw6b.js} +1 -1
- package/dist/client/static/js/{index-qj34r6d0.js → index-38xv8h4t.js} +1 -1
- package/dist/client/static/js/{index-4j8rgr4p.js → index-50mdqev0.js} +1 -1
- package/dist/client/static/js/{index-zvazj4va.js → index-5jnvz9hw.js} +1 -1
- package/dist/client/static/js/{index-97qst4k9.js → index-77t0nvt1.js} +1 -1
- package/dist/client/static/js/{index-x7f5ysch.js → index-7a2efrbj.js} +1 -1
- package/dist/client/static/js/{index-yvxa7hd8.js → index-82vk27q1.js} +1 -1
- package/dist/client/static/js/{index-nbexks3x.js → index-8k7vjp8b.js} +1 -1
- package/dist/client/static/js/{index-sq3r1xhf.js → index-8kbp24xg.js} +1 -1
- package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
- package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
- package/dist/client/static/js/{index-13dr1t1r.js → index-cz50ha6x.js} +23 -23
- package/dist/client/static/js/{index-8jqawh3r.js → index-dtj73vs1.js} +1 -1
- package/dist/client/static/js/{index-7t63akyt.js → index-dzmar8jr.js} +1 -1
- package/dist/client/static/js/{index-2x9eqztp.js → index-f33c4paw.js} +1 -1
- package/dist/client/static/js/{index-xxe52zrm.js → index-fb6pw9xb.js} +1 -1
- package/dist/client/static/js/{index-6ge6gk9w.js → index-gp57dx2v.js} +1 -1
- package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
- package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
- package/dist/client/static/js/{index-8hgm0abr.js → index-pzvr1699.js} +187 -183
- package/dist/client/static/js/{index-dydwcp3n.js → index-r9db1gsf.js} +1 -1
- package/dist/client/static/js/{index-b4y5g48d.js → index-raca8tsh.js} +1 -1
- package/dist/client/static/js/{index-95en3p3g.js → index-rf29f3fq.js} +4 -4
- package/dist/client/static/js/{index-sz3mxjvy.js → index-s4gv0rpk.js} +1 -1
- package/dist/client/static/js/{index-a9t9gdew.js → index-v3f7we4n.js} +4 -4
- package/dist/client/static/js/{index-ejdnjh5c.js → index-yjmm73jm.js} +1 -1
- package/dist/client/static/js/{index-1rxa9zxp.js → index-ykfd2fyj.js} +1 -1
- package/dist/client/static/js/{index-4z4ax55k.js → index-yzda8j2d.js} +6 -6
- package/dist/client/static/js/{index-vcn1kcpy.js → index-z78bzryw.js} +3 -3
- package/dist/client/static/js/{index-tqycj126.js → index-zndbhb9w.js} +1 -1
- package/dist/client/static/js/{index-ka2rc2cr.js → index-zs73zwjz.js} +3 -3
- package/dist/client/static/js/{index-xe5cqwnf.js → index-zs7sjv6x.js} +1 -1
- package/dist/client/static/js/{index-hzwr5fm9.js → index-zw621xez.js} +3 -3
- package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-4e7ej63f.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-k3yet1ec.js} +2 -2
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-qe352kyd.js} +2 -2
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-58hag75n.js} +4 -4
- package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-6e89h6vm.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-ncsam2fm.js} +1 -1
- package/dist/client/static/js/one-dark-pro-qmyne0tn.js +1 -0
- package/dist/client/static/js/one-light-dj0ecjcj.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-b5ckc39d.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-s4d47ve8.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-zm0ekvjz.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-52vdqf53.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-7kf8bmk9.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-q98kssv3.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-bcb9f54a.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-76ywvj7g.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-p9bsf5dc.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-1ecfb3fs.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-2pyjr946.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-qr5hdxm4.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-4csxwmn2.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-0p1jnbsn.js} +7 -7
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-y1hgdet4.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-p578yrgm.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-b08b4ah0.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/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +45 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +14 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -12
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +42 -38
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +25 -21
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +41 -29
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +47 -43
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +136 -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/omp/session/scan.ts +15 -2
- package/src/server/lib/omp/session/session-discovery.test.ts +21 -0
- 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/chat/timeline/tool-render-mode.ts +3 -3
- package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
- package/src/shared/lib/omp/session/operator-title.test.ts +21 -0
- package/src/shared/lib/omp/session/operator-title.ts +28 -0
- 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
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
22
22
|
import { AcpRequestError } from '@/server/lib/harness/acp/calls';
|
|
23
23
|
import { turnEndFrame } from '@/server/lib/harness/acp/frames';
|
|
24
|
+
import { TurnSilence } from '@/server/lib/harness/acp/turn-silence';
|
|
25
|
+
import { deriveTurnError } from '@/shared/lib/omp/session/turn-error';
|
|
26
|
+
|
|
27
|
+
const STRANDED_REASON = 'The agent stopped reporting progress; the turn was closed after a long silence.';
|
|
24
28
|
|
|
25
29
|
/** What a closed turn reports to its session and the parent notice. */
|
|
26
30
|
export interface AcpTurnEndInfo {
|
|
@@ -30,6 +34,8 @@ export interface AcpTurnEndInfo {
|
|
|
30
34
|
cancelled?: boolean;
|
|
31
35
|
failed?: boolean;
|
|
32
36
|
failure?: string | null;
|
|
37
|
+
/** Closed by the silence ceiling, not by the agent. */
|
|
38
|
+
stranded?: boolean;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
export interface AcpTurnSeams {
|
|
@@ -75,8 +81,27 @@ export class AcpTurns {
|
|
|
75
81
|
private promptText = '';
|
|
76
82
|
/** Set by a local cancel: non-idle states are the cancelled run, not new work. */
|
|
77
83
|
private awaitingCancellation = false;
|
|
84
|
+
/** The silence ceiling for the open turn — see `turn-silence.ts`. */
|
|
85
|
+
readonly #silence: TurnSilence;
|
|
86
|
+
|
|
87
|
+
constructor(private readonly seams: AcpTurnSeams, options: { silenceMs?: number } = {}) {
|
|
88
|
+
this.#silence = new TurnSilence(() => this.strand(), options.silenceMs);
|
|
89
|
+
}
|
|
78
90
|
|
|
79
|
-
|
|
91
|
+
/** Any frame from the agent defers the silence ceiling. */
|
|
92
|
+
noteActivity(): void {
|
|
93
|
+
if (this.open !== null) this.#silence.arm();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Close a turn the agent stopped reporting on. Public so a caller that has
|
|
98
|
+
* its own evidence (a probe, a shutdown) can settle it the same way.
|
|
99
|
+
*/
|
|
100
|
+
strand(): void {
|
|
101
|
+
if (this.open === null) return;
|
|
102
|
+
const turnId = this.open;
|
|
103
|
+
this.settle(turnId, () => this.finish(undefined, false, STRANDED_REASON, true));
|
|
104
|
+
}
|
|
80
105
|
|
|
81
106
|
/** The same field omp puts on its ack, so a client that inspects it reads one
|
|
82
107
|
* vocabulary whichever transport served the chat. */
|
|
@@ -90,6 +115,7 @@ export class AcpTurns {
|
|
|
90
115
|
this.awaitingCancellation = false;
|
|
91
116
|
this.isPromptRunning = true;
|
|
92
117
|
this.isStreaming = true;
|
|
118
|
+
this.#silence.arm();
|
|
93
119
|
this.seams.emit({ type: 'agent_start' });
|
|
94
120
|
this.seams.emit({ type: 'turn_start' });
|
|
95
121
|
|
|
@@ -152,6 +178,7 @@ export class AcpTurns {
|
|
|
152
178
|
return;
|
|
153
179
|
}
|
|
154
180
|
this.open = null;
|
|
181
|
+
this.#silence.stop();
|
|
155
182
|
this.seams.cancelAgent();
|
|
156
183
|
this.seams.abandonPrompt();
|
|
157
184
|
this.finish({ stopReason: 'cancelled' });
|
|
@@ -210,6 +237,7 @@ export class AcpTurns {
|
|
|
210
237
|
this.promptText = '';
|
|
211
238
|
this.isPromptRunning = true;
|
|
212
239
|
this.isStreaming = true;
|
|
240
|
+
this.#silence.arm();
|
|
213
241
|
this.seams.resetMapper();
|
|
214
242
|
this.seams.emit({ type: 'agent_start' });
|
|
215
243
|
this.seams.emit({ type: 'turn_start' });
|
|
@@ -228,7 +256,13 @@ export class AcpTurns {
|
|
|
228
256
|
* going to report an end for work it abandoned. `reported` says the caller
|
|
229
257
|
* already emitted the failure reason, so only this module's generic silent
|
|
230
258
|
* verdict is suppressed. */
|
|
231
|
-
private finish(
|
|
259
|
+
private finish(
|
|
260
|
+
result: { stopReason?: string } | undefined,
|
|
261
|
+
reported = false,
|
|
262
|
+
failure?: string,
|
|
263
|
+
stranded = false,
|
|
264
|
+
): void {
|
|
265
|
+
this.#silence.stop();
|
|
232
266
|
const flushed = this.seams.closeMessage();
|
|
233
267
|
for (const event of flushed) this.seams.emit(event);
|
|
234
268
|
const closed = flushed.find((event) => event.type === 'message_end')?.message;
|
|
@@ -249,10 +283,19 @@ export class AcpTurns {
|
|
|
249
283
|
const slash = this.promptText.trimStart().startsWith('/');
|
|
250
284
|
// v2 says clients cannot infer failure from an idle without a stop reason;
|
|
251
285
|
// the "silent answer is a failure" rule is a v1 agent behaviour (pi-acp).
|
|
286
|
+
// `stopReason: 'error'` is a failure even when the agent DID send a partial
|
|
287
|
+
// message: a v1 agent answers `{stopReason: 'error'}` with whatever it had
|
|
288
|
+
// streamed, and reading only "did it answer" reported that turn as
|
|
289
|
+
// completed — so a delegated worker whose provider failed mid-answer told
|
|
290
|
+
// its coordinator it had finished.
|
|
252
291
|
const failed = !cancelled && !slash
|
|
253
|
-
&& (reported || (this.completion === 'response' && !answered));
|
|
292
|
+
&& (stranded || reported || result?.stopReason === 'error' || (this.completion === 'response' && !answered));
|
|
254
293
|
const reason = failed
|
|
255
|
-
? failure ??
|
|
294
|
+
? failure ?? (stranded
|
|
295
|
+
? STRANDED_REASON
|
|
296
|
+
: closedFailure(closed) ?? (result?.stopReason === 'error'
|
|
297
|
+
? 'The agent ended the turn with an error'
|
|
298
|
+
: 'The agent ended the turn without sending an answer'))
|
|
256
299
|
: null;
|
|
257
300
|
if (failed && !reported && !slash) {
|
|
258
301
|
this.seams.emit({
|
|
@@ -268,11 +311,26 @@ export class AcpTurns {
|
|
|
268
311
|
closedMessage: flushed.some((event) => event.type === 'message_end'),
|
|
269
312
|
...(closed ? { message: closed } : {}),
|
|
270
313
|
...(cancelled ? { cancelled: true } : {}),
|
|
314
|
+
...(stranded ? { stranded: true } : {}),
|
|
271
315
|
...(failed ? { failed: true, failure: reason } : {}),
|
|
272
316
|
});
|
|
273
317
|
}
|
|
274
318
|
}
|
|
275
319
|
|
|
320
|
+
/**
|
|
321
|
+
* The reason the CLOSED message names, when it named one.
|
|
322
|
+
*
|
|
323
|
+
* The same rule as omp's: an agent records `stopReason` / `errorMessage` flat on
|
|
324
|
+
* the assistant message, and reading only the envelope's stop reason threw the
|
|
325
|
+
* provider's own words away — a coordinator was told "the agent ended the turn
|
|
326
|
+
* with an error" over a transcript that said which.
|
|
327
|
+
*/
|
|
328
|
+
function closedFailure(message: unknown): string | null {
|
|
329
|
+
if (!message || typeof message !== 'object' || Array.isArray(message)) return null;
|
|
330
|
+
const error = deriveTurnError(message as Record<string, unknown>);
|
|
331
|
+
return error?.message?.trim() || null;
|
|
332
|
+
}
|
|
333
|
+
|
|
276
334
|
/** Does the closed message carry anything the timeline draws? A whitespace-only
|
|
277
335
|
* chunk (or one that carried only an empty text block) opens a message row
|
|
278
336
|
* that renders nothing, which is the same operator-visible failure as no frame
|
|
@@ -36,6 +36,7 @@ import { startPluginScheduleRuntime, stopPluginScheduleRuntime } from '@/server/
|
|
|
36
36
|
import { startScheduleRuntime, stopScheduleRuntime } from '@/server/lib/schedule/runtime.server';
|
|
37
37
|
import { ensureTray, readTrayAppearance } from '@/server/lib/tray/runtime.server';
|
|
38
38
|
import { startWaitingRuntime, stopWaitingRuntime } from '@/server/lib/waiting/runtime.server';
|
|
39
|
+
import { drainPendingNotices } from '@/server/lib/sessions/notify.server';
|
|
39
40
|
|
|
40
41
|
/** What the tray needs from the listener that is already up. */
|
|
41
42
|
export interface AfterListenTarget {
|
|
@@ -69,6 +70,15 @@ export async function runAfterListenTasks(target: AfterListenTarget): Promise<vo
|
|
|
69
70
|
// Same shape and placement — its first sweep may spawn an omp child.
|
|
70
71
|
startWaitingRuntime();
|
|
71
72
|
|
|
73
|
+
// A child outcome is staged in `session_notices` and delivered by a 2s timer
|
|
74
|
+
// that dies with the process. Anything a previous process staged — a child
|
|
75
|
+
// that finished during a restart, or across a `bun --hot` reload — is still
|
|
76
|
+
// there, and without this pass its coordinator never hears from the worker
|
|
77
|
+
// it delegated to. Cheap: one query that is usually empty.
|
|
78
|
+
await drainPendingNotices().catch((error) => {
|
|
79
|
+
console.error('[sessions] stranded child outcomes skipped:', error);
|
|
80
|
+
});
|
|
81
|
+
|
|
72
82
|
await syncBundledPluginsAndReport();
|
|
73
83
|
await loadPluginServerHalves();
|
|
74
84
|
// After the halves: a schedule exists only once its plugin's factory ran.
|
|
@@ -26,6 +26,27 @@ export interface SessionFrameHost extends AutoTitleHost, QueueDeliveryHost {
|
|
|
26
26
|
compacting: boolean;
|
|
27
27
|
/** Abort verdict of the current run — see `endedAborted` in `terminal-settle.ts`. */
|
|
28
28
|
runAborted: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The provider failure the run's last settled assistant message carried, in
|
|
31
|
+
* omp's own words (`errorMessage` / `errorStatus`).
|
|
32
|
+
*
|
|
33
|
+
* Captured at `message_end` for the same reason `runAborted` is: omp compacts
|
|
34
|
+
* an oversized terminal frame by dropping the messages it already delivered,
|
|
35
|
+
* so the reason a run failed is routinely absent from `agent_end.messages`.
|
|
36
|
+
* Cleared by a later assistant message that did not fail — that is the proof
|
|
37
|
+
* the run recovered.
|
|
38
|
+
*/
|
|
39
|
+
runFailure: string | null;
|
|
40
|
+
/** True between `auto_retry_start` and `auto_retry_end`. omp keeps the RUN
|
|
41
|
+
* open across a retry saga, so nothing may report an outcome while this is
|
|
42
|
+
* set. */
|
|
43
|
+
retrySagaOpen: boolean;
|
|
44
|
+
/** The reason the last retry saga closed with, when it closed as a failure
|
|
45
|
+
* (`Retry budget exhausted after 3 retries: …`). */
|
|
46
|
+
retryFinalError: string | null;
|
|
47
|
+
/** Set once this run has told its coordinator how it ended; cleared at
|
|
48
|
+
* `agent_start` so a queued follow-up run reports its own outcome. */
|
|
49
|
+
runOutcomeReported: boolean;
|
|
29
50
|
awaitingAgentStart: boolean;
|
|
30
51
|
awaitingAgentStartDeadline: number;
|
|
31
52
|
continuationGraceUntil: number;
|
|
@@ -30,6 +30,10 @@ export function makeHost(overrides: Partial<SessionFrameHost> = {}): SessionFram
|
|
|
30
30
|
streaming: false,
|
|
31
31
|
compacting: false,
|
|
32
32
|
runAborted: false,
|
|
33
|
+
runFailure: null,
|
|
34
|
+
retrySagaOpen: false,
|
|
35
|
+
retryFinalError: null,
|
|
36
|
+
runOutcomeReported: false,
|
|
33
37
|
awaitingAgentStart: false,
|
|
34
38
|
awaitingAgentStartDeadline: 0,
|
|
35
39
|
continuationGraceUntil: 0,
|
|
@@ -29,7 +29,8 @@ import { releasesStreamRowOnPromptResult } from '@/shared/lib/omp/session/stream
|
|
|
29
29
|
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
30
30
|
import { publishSidebarStructure } from '@/server/lib/realtime/topics.server';
|
|
31
31
|
import { NON_TERMINAL_CONTINUATION_GRACE_MS, type AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
32
|
-
import { settleTerminalRun } from '@/server/lib/omp/rpc/terminal-settle';
|
|
32
|
+
import { assistantFailure, settleTerminalRun } from '@/server/lib/omp/rpc/terminal-settle';
|
|
33
|
+
import { noteRetryFrame } from '@/server/lib/omp/rpc/retry-saga';
|
|
33
34
|
import { parseModeMarker } from '@/shared/lib/omp/mode/markers';
|
|
34
35
|
import { SKILL_PROMPT_CUSTOM_TYPE } from '@/shared/lib/omp/session/operator-title';
|
|
35
36
|
import type { FrameFoldResult, SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold-contract';
|
|
@@ -61,6 +62,15 @@ import type { FrameFoldResult, SessionFrameHost } from '@/server/lib/omp/rpc/fra
|
|
|
61
62
|
function handleMessageEnd(host: SessionFrameHost, event: AgentEvent): void {
|
|
62
63
|
const message = event.message as Record<string, unknown> | undefined;
|
|
63
64
|
if (message?.role === 'assistant' && message.stopReason === 'aborted') host.runAborted = true;
|
|
65
|
+
// The failure is captured HERE, not at `agent_end`: omp compacts an oversized
|
|
66
|
+
// terminal frame by dropping what it already delivered through
|
|
67
|
+
// `message_end`, and the failed assistant message is one of them (see
|
|
68
|
+
// `endedAborted` for the same measurement). An assistant message that ended
|
|
69
|
+
// normally CLEARS the capture — a retried run that recovered must not report
|
|
70
|
+
// the reason its first attempt died.
|
|
71
|
+
if (message?.role === 'assistant') {
|
|
72
|
+
host.runFailure = assistantFailure(message);
|
|
73
|
+
}
|
|
64
74
|
if (message?.role === 'user') void triggerAutoSessionTitle(host, 'opening');
|
|
65
75
|
else if (message?.role === 'custom' && message.customType === SKILL_PROMPT_CUSTOM_TYPE) {
|
|
66
76
|
void triggerAutoSessionTitle(host, 'opening');
|
|
@@ -164,6 +174,13 @@ export function foldSessionFrame(host: SessionFrameHost, event: AgentEvent): Fra
|
|
|
164
174
|
host.promptRunning = true;
|
|
165
175
|
host.streaming = true;
|
|
166
176
|
host.runAborted = false;
|
|
177
|
+
// A new run owns its own outcome. A retry's `agent_start` also lands
|
|
178
|
+
// here, and that is correct: the attempt that follows either fails again
|
|
179
|
+
// (its `message_end` re-captures the reason) or succeeds (which clears
|
|
180
|
+
// it), so nothing from the previous attempt can be reported as this
|
|
181
|
+
// run's ending.
|
|
182
|
+
host.runFailure = null;
|
|
183
|
+
host.runOutcomeReported = false;
|
|
167
184
|
host.awaitingAgentStart = false;
|
|
168
185
|
host.awaitingAgentStartDeadline = 0;
|
|
169
186
|
host.continuationGraceUntil = 0;
|
|
@@ -216,7 +233,7 @@ export function foldSessionFrame(host: SessionFrameHost, event: AgentEvent): Fra
|
|
|
216
233
|
host.awaitingAgentStartDeadline = 0;
|
|
217
234
|
host.continuationGraceUntil = 0;
|
|
218
235
|
clearSessionFileCaches();
|
|
219
|
-
settleTerminalRun(host, event.messages);
|
|
236
|
+
void settleTerminalRun(host, event.messages);
|
|
220
237
|
} else {
|
|
221
238
|
host.continuationGraceUntil = Date.now() + NON_TERMINAL_CONTINUATION_GRACE_MS;
|
|
222
239
|
}
|
|
@@ -253,6 +270,12 @@ export function foldSessionFrame(host: SessionFrameHost, event: AgentEvent): Fra
|
|
|
253
270
|
// correlation id, so attribution is by the request window.
|
|
254
271
|
result.suppressForward = consumeAutoTitleOutput(host);
|
|
255
272
|
break;
|
|
273
|
+
// omp keeps the RUN open across a retry saga, so the run's outcome must not
|
|
274
|
+
// be reported until the saga closes — see `retry-saga.ts`.
|
|
275
|
+
case 'auto_retry_start':
|
|
276
|
+
case 'auto_retry_end':
|
|
277
|
+
noteRetryFrame(host, event);
|
|
278
|
+
break;
|
|
256
279
|
case 'model_changed':
|
|
257
280
|
// omp swapped the model under us: a retry under `retry.fallbackChains`
|
|
258
281
|
// picks the next eligible model when the primary fails, and can do it
|
|
@@ -59,6 +59,11 @@ export class AgentSessionWrapper {
|
|
|
59
59
|
streaming = false;
|
|
60
60
|
compacting = false;
|
|
61
61
|
runAborted = false;
|
|
62
|
+
// How this run ended, documented once on `SessionFrameHost`.
|
|
63
|
+
runFailure: string | null = null;
|
|
64
|
+
retrySagaOpen = false;
|
|
65
|
+
retryFinalError: string | null = null;
|
|
66
|
+
runOutcomeReported = false;
|
|
62
67
|
fastModeEnabled = false;
|
|
63
68
|
runModel: SessionRunModel | null = null;
|
|
64
69
|
private onDestroyCallback: (() => void) | null = null;
|
|
@@ -172,12 +177,8 @@ export class AgentSessionWrapper {
|
|
|
172
177
|
);
|
|
173
178
|
}
|
|
174
179
|
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
* object (`AgentStartWatchdog`) because "did it actually settle?" is a
|
|
178
|
-
* question only this wrapper can answer; this method only feeds it the flags.
|
|
179
|
-
* See that module for the failure it exists to close.
|
|
180
|
-
*/
|
|
180
|
+
/** Feed the dispatch watchdog its flags; it owns the deadline and the
|
|
181
|
+
* answer to "did the turn actually open?" (`agent-start-watchdog.ts`). */
|
|
181
182
|
armAgentStartWatchdog(): void {
|
|
182
183
|
this.agentStartWatchdog.arm();
|
|
183
184
|
}
|
|
@@ -221,7 +222,7 @@ export class AgentSessionWrapper {
|
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
handleProcessExit(stderrTail: string): void {
|
|
224
|
-
handleChildExit(this, stderrTail);
|
|
225
|
+
void handleChildExit(this, stderrTail);
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
/** SessionFrameHost adapter: remember a blocking dialog for reattaching clients. */
|
|
@@ -242,7 +243,7 @@ export class AgentSessionWrapper {
|
|
|
242
243
|
// The fold owns the state machine; this method only bookkeeps around it.
|
|
243
244
|
const { suppressForward } = foldSessionFrame(this, event);
|
|
244
245
|
// A refused prompt opens no turn; no agent_end will settle it.
|
|
245
|
-
noteRefusedPrompt(event, this.sessionId);
|
|
246
|
+
void noteRefusedPrompt(event, this.sessionId);
|
|
246
247
|
// The run-settle clock reads every frame: it is what tells a quiet run from
|
|
247
248
|
// one whose event stream stopped, and it is fed the retry waits omp
|
|
248
249
|
// announces. See `run-settle.server.ts`.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* omp's retry lifecycle, as the SERVER tracks it.
|
|
8
|
+
*
|
|
9
|
+
* omp retries a transient provider failure by itself and keeps the RUN open
|
|
10
|
+
* across the attempts: each attempt announces `auto_retry_start` and opens a
|
|
11
|
+
* fresh `agent_start`, with no terminal `agent_end` in between, and the saga
|
|
12
|
+
* closes with `auto_retry_end` — carrying `finalError` when the budget ran out.
|
|
13
|
+
*
|
|
14
|
+
* That shape is what a coordinator must not be told about per attempt: the
|
|
15
|
+
* outcome of a delegated child is reported at its TERMINAL end, and a report
|
|
16
|
+
* per attempt said "failed" while omp was still working, which is what made a
|
|
17
|
+
* coordinator resend the task. The two flags below are the fold's half:
|
|
18
|
+
* `retrySagaOpen` says the run is not over, `retryFinalError` says why it
|
|
19
|
+
* ended once it is.
|
|
20
|
+
*
|
|
21
|
+
* The client folds the same frames for the indicator and the transcript notice
|
|
22
|
+
* (`shared/lib/chat/timeline/provider-retry.ts`); this module is the server's,
|
|
23
|
+
* and the two read one wire format.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export interface RetrySagaHost {
|
|
27
|
+
/** True between `auto_retry_start` and `auto_retry_end`. */
|
|
28
|
+
retrySagaOpen: boolean;
|
|
29
|
+
/** The reason the last saga closed with, when it closed as a failure. */
|
|
30
|
+
retryFinalError: string | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Fold one retry frame. Returns false for any other frame type. */
|
|
34
|
+
export function noteRetryFrame(host: RetrySagaHost, event: Record<string, unknown>): boolean {
|
|
35
|
+
if (event.type === 'auto_retry_start') {
|
|
36
|
+
host.retrySagaOpen = true;
|
|
37
|
+
// A new saga has no verdict yet; the previous run's reason must not leak
|
|
38
|
+
// into this one.
|
|
39
|
+
host.retryFinalError = null;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (event.type === 'auto_retry_end') {
|
|
43
|
+
// Either an attempt succeeded — the run continues, and its own terminal
|
|
44
|
+
// frame decides the outcome — or the budget is spent and the run is about
|
|
45
|
+
// to end, and then THIS is the reason it did.
|
|
46
|
+
host.retrySagaOpen = false;
|
|
47
|
+
host.retryFinalError =
|
|
48
|
+
event.success === false && typeof event.finalError === 'string' && event.finalError.trim()
|
|
49
|
+
? event.finalError.trim()
|
|
50
|
+
: null;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
import type { RpcProcess } from '@/server/lib/omp/rpc/process';
|
|
49
|
+
import { noteRunEndedWithoutFrame } from '@/server/lib/omp/rpc/terminal-settle';
|
|
49
50
|
import { buildWebState, type WebStateHost } from '@/server/lib/omp/rpc/web-state';
|
|
50
51
|
import { GET_STATE_TIMEOUT_MS, SUBAGENT_STALE_MS, type AgentEvent, type RpcSessionState } from '@/server/lib/omp/rpc/constants';
|
|
51
52
|
import { markStreamStatus } from '@/shared/lib/omp/session/stream-state.server';
|
|
@@ -76,6 +77,8 @@ export interface RunSettleHost extends WebStateHost {
|
|
|
76
77
|
awaitingAgentStartDeadline: number;
|
|
77
78
|
continuationGraceUntil: number;
|
|
78
79
|
restarting: boolean;
|
|
80
|
+
/** Set once this run has told its coordinator how it ended. */
|
|
81
|
+
runOutcomeReported: boolean;
|
|
79
82
|
proc: RpcProcess;
|
|
80
83
|
isAlive(): boolean;
|
|
81
84
|
isRunning(): boolean;
|
|
@@ -95,6 +98,8 @@ export interface ChildExitHost {
|
|
|
95
98
|
restarting: boolean;
|
|
96
99
|
streaming: boolean;
|
|
97
100
|
promptRunning: boolean;
|
|
101
|
+
/** Set once this run has told its coordinator how it ended. */
|
|
102
|
+
runOutcomeReported: boolean;
|
|
98
103
|
isAlive(): boolean;
|
|
99
104
|
emit(event: AgentEvent): void;
|
|
100
105
|
destroy(): void;
|
|
@@ -120,6 +125,9 @@ export class RunSettle {
|
|
|
120
125
|
/** Epoch ms until which omp announced it is waiting (a provider retry). */
|
|
121
126
|
#quietUntil = 0;
|
|
122
127
|
#probing = false;
|
|
128
|
+
/** The reconcile this clock started on its own. A caller that must observe
|
|
129
|
+
* the settle — a test, a shutdown — awaits it instead of guessing at ticks. */
|
|
130
|
+
#pending: Promise<boolean> | null = null;
|
|
123
131
|
readonly #host: RunSettleHost;
|
|
124
132
|
readonly #silenceMs: number;
|
|
125
133
|
readonly #retrySlackMs: number;
|
|
@@ -147,6 +155,11 @@ export class RunSettle {
|
|
|
147
155
|
this.#arm();
|
|
148
156
|
}
|
|
149
157
|
|
|
158
|
+
/** Await the reconcile this clock started, if one is still running. */
|
|
159
|
+
async whenSettled(): Promise<void> {
|
|
160
|
+
await this.#pending?.catch(() => false);
|
|
161
|
+
}
|
|
162
|
+
|
|
150
163
|
/** Stop watching (the run ended, or the wrapper is going away). */
|
|
151
164
|
stop(): void {
|
|
152
165
|
clearTimeout(this.#timer);
|
|
@@ -208,7 +221,7 @@ export class RunSettle {
|
|
|
208
221
|
this.#arm();
|
|
209
222
|
return false;
|
|
210
223
|
}
|
|
211
|
-
this.#settle(state);
|
|
224
|
+
await this.#settle(state);
|
|
212
225
|
return true;
|
|
213
226
|
} catch {
|
|
214
227
|
// A wedged child (or a probe that queued behind a long handler and timed
|
|
@@ -251,7 +264,7 @@ export class RunSettle {
|
|
|
251
264
|
* Land the settle: reconcile the flags from omp's truth, write the terminal
|
|
252
265
|
* badge, and hand every attached client the terminal frame a real end sends.
|
|
253
266
|
*/
|
|
254
|
-
#settle(state: RpcSessionState): void {
|
|
267
|
+
async #settle(state: RpcSessionState): Promise<void> {
|
|
255
268
|
const host = this.#host;
|
|
256
269
|
const sessionId = host.sessionId;
|
|
257
270
|
buildWebState(host, state);
|
|
@@ -270,6 +283,15 @@ export class RunSettle {
|
|
|
270
283
|
// footer armed forever; the terminal frame is what releases them, and
|
|
271
284
|
// nothing else will ever send one.
|
|
272
285
|
host.emit({ type: 'agent_end', isTerminal: true, messages: [] });
|
|
286
|
+
// The frame above reaches CLIENTS only — it never passes through the frame
|
|
287
|
+
// fold, so the child outcome a real `agent_end` reports would be lost and
|
|
288
|
+
// the coordinator would wait for a worker that has already stopped. Report
|
|
289
|
+
// it here, as an interruption: nothing observed this run finish.
|
|
290
|
+
await noteRunEndedWithoutFrame(
|
|
291
|
+
host,
|
|
292
|
+
'interrupted',
|
|
293
|
+
'The run stopped reporting progress; open the session to read its output.',
|
|
294
|
+
);
|
|
273
295
|
}
|
|
274
296
|
|
|
275
297
|
/** (Re-)arm the deadline. Never keeps the event loop alive on its own. */
|
|
@@ -280,7 +302,7 @@ export class RunSettle {
|
|
|
280
302
|
const delayMs = Math.max(this.#silenceMs, this.#quietUntil - Date.now());
|
|
281
303
|
const timer = setTimeout(() => {
|
|
282
304
|
this.#timer = undefined;
|
|
283
|
-
|
|
305
|
+
this.#pending = this.reconcile('idle');
|
|
284
306
|
}, delayMs);
|
|
285
307
|
timer.unref?.();
|
|
286
308
|
this.#timer = timer;
|
|
@@ -292,9 +314,10 @@ export class RunSettle {
|
|
|
292
314
|
* its terminal frame, so the row and the clients are settled here. Moved out of
|
|
293
315
|
* the wrapper (which is at the repo's per-file ceiling) with behavior unchanged.
|
|
294
316
|
*/
|
|
295
|
-
export function handleChildExit(host: ChildExitHost, stderrTail: string): void {
|
|
296
|
-
if (!host.isAlive() || host.restarting) return;
|
|
317
|
+
export function handleChildExit(host: ChildExitHost, stderrTail: string): Promise<void> {
|
|
318
|
+
if (!host.isAlive() || host.restarting) return Promise.resolve();
|
|
297
319
|
const detail = stderrTail.trim().split('\n').pop() ?? '';
|
|
320
|
+
let reported: Promise<void> = Promise.resolve();
|
|
298
321
|
host.emit({
|
|
299
322
|
type: 'notice',
|
|
300
323
|
level: 'error',
|
|
@@ -302,6 +325,15 @@ export function handleChildExit(host: ChildExitHost, stderrTail: string): void {
|
|
|
302
325
|
});
|
|
303
326
|
if (host.streaming || host.promptRunning) {
|
|
304
327
|
host.emit({ type: 'agent_end', isTerminal: true, messages: [] });
|
|
328
|
+
// Same reason as the reconcile settle: this frame bypasses the fold, so the
|
|
329
|
+
// outcome is reported explicitly. A dead process is a FAILURE, and the
|
|
330
|
+
// stderr tail is the only detail anyone has. Started, not awaited: the
|
|
331
|
+
// latch is set synchronously and the wrapper still gets torn down now.
|
|
332
|
+
reported = noteRunEndedWithoutFrame(
|
|
333
|
+
host,
|
|
334
|
+
'failed',
|
|
335
|
+
`The omp process for this session exited unexpectedly${detail ? `: ${detail}` : '.'}`,
|
|
336
|
+
);
|
|
305
337
|
// The run's own process died mid-flight: that is a failure, not a normal
|
|
306
338
|
// finish, and the reason the notification shows is the one above.
|
|
307
339
|
if (host.sessionId) {
|
|
@@ -314,4 +346,5 @@ export function handleChildExit(host: ChildExitHost, stderrTail: string): void {
|
|
|
314
346
|
}
|
|
315
347
|
}
|
|
316
348
|
host.destroy();
|
|
349
|
+
return reported;
|
|
317
350
|
}
|
|
@@ -87,6 +87,7 @@ function makeHost(state: RpcSessionState | (() => Promise<RpcSessionState>)) {
|
|
|
87
87
|
continuationGraceUntil: 0,
|
|
88
88
|
fastModeEnabled: false,
|
|
89
89
|
restarting: false,
|
|
90
|
+
runOutcomeReported: false,
|
|
90
91
|
proc: {
|
|
91
92
|
isAlive: true,
|
|
92
93
|
sendCommand(command: { type: string }) {
|
|
@@ -204,7 +205,9 @@ describe('settling a run omp no longer owns', () => {
|
|
|
204
205
|
const clock = settle(host, { silenceMs: 10 });
|
|
205
206
|
clock.noteFrame({ type: 'turn_start' } as AgentEvent);
|
|
206
207
|
vi.advanceTimersByTime(50);
|
|
207
|
-
|
|
208
|
+
// Await the settle the clock started, not a guessed number of ticks: the
|
|
209
|
+
// outcome write is a database round trip.
|
|
210
|
+
await clock.whenSettled();
|
|
208
211
|
expect(host.streaming).toBe(false);
|
|
209
212
|
expect(emitted).toEqual([{ type: 'agent_end', isTerminal: true, messages: [] }]);
|
|
210
213
|
clock.stop();
|
|
@@ -225,7 +228,7 @@ describe('settling a run omp no longer owns', () => {
|
|
|
225
228
|
const clock = settle(host, { silenceMs: 10 });
|
|
226
229
|
clock.arm();
|
|
227
230
|
vi.advanceTimersByTime(50);
|
|
228
|
-
await
|
|
231
|
+
await clock.whenSettled();
|
|
229
232
|
expect(host.streaming).toBe(false);
|
|
230
233
|
expect(host.promptRunning).toBe(false);
|
|
231
234
|
expect(emitted).toEqual([{ type: 'agent_end', isTerminal: true, messages: [] }]);
|
|
@@ -31,35 +31,21 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
34
|
-
import { mkdtempSync } from 'node:fs';
|
|
35
|
-
import { tmpdir } from 'node:os';
|
|
36
|
-
import { join } from 'node:path';
|
|
37
34
|
|
|
38
35
|
import { dispatchSessionCommand } from '@/server/lib/omp/rpc/session-commands';
|
|
39
36
|
import { RpcCommandTimeoutError } from '@/server/lib/omp/rpc/process';
|
|
40
37
|
import { WebRpcError } from '@/server/lib/omp/rpc/constants';
|
|
41
38
|
import { cancelQueuedDelivery } from '@/server/lib/queue/delivery.server';
|
|
42
39
|
import { makeHarness, rejectionOf } from '@/server/lib/omp/rpc/session-commands-harness';
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
beforeEach(() => {
|
|
49
|
-
root = mkdtempSync(join(tmpdir(), 'kabmo-test-'));
|
|
50
|
-
savedDbPath = Bun.env.KABMO_DB_PATH;
|
|
51
|
-
// The stream-status writes resolve the database; point them at the temp tree
|
|
52
|
-
// so the real `~/.kabmo` is never created or opened.
|
|
53
|
-
Bun.env.KABMO_DB_PATH = join(root, 'db.sqlite');
|
|
54
|
-
delete globalThis.__kabmoDb;
|
|
40
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
41
|
+
|
|
42
|
+
beforeEach(async () => {
|
|
43
|
+
await isolateDb();
|
|
55
44
|
});
|
|
56
45
|
|
|
57
|
-
afterEach(() => {
|
|
46
|
+
afterEach(async () => {
|
|
58
47
|
cancelQueuedDelivery('sess-1');
|
|
59
|
-
|
|
60
|
-
if (savedDbPath === undefined) delete Bun.env.KABMO_DB_PATH;
|
|
61
|
-
else Bun.env.KABMO_DB_PATH = savedDbPath;
|
|
62
|
-
removeDir(root);
|
|
48
|
+
await releaseDb();
|
|
63
49
|
});
|
|
64
50
|
|
|
65
51
|
describe('steer and follow_up', () => {
|