@kabmo-labs/kabmo 0.37.0 → 0.38.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 +551 -531
- package/dist/client/static/js/{CsvGrid-xb429wvb.js → CsvGrid-t1n057vw.js} +1 -1
- package/dist/client/static/js/{DocxView-g58e0bs7.js → DocxView-c9g6teks.js} +2 -2
- package/dist/client/static/js/{DrawioView-1j66avvy.js → DrawioView-gd14j54m.js} +1 -1
- package/dist/client/static/js/{ImageView-kraqkypn.js → ImageView-57f1ecdp.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-85dhbn62.js → LayoutWrapper-x7srbpz1.js} +2 -2
- package/dist/client/static/js/{Modal-f0nfya07.js → Modal-0bn3f77b.js} +15 -15
- package/dist/client/static/js/{PdfView-nddkrky9.js → PdfView-cybz0xbj.js} +1 -1
- package/dist/client/static/js/{SessionsView-a595m6g1.js → SessionsView-gx5q68tp.js} +1 -1
- package/dist/client/static/js/{SheetView-s2p4sk6b.js → SheetView-1kk5y326.js} +1 -1
- package/dist/client/static/js/{SvgPreview-ppdx4yb9.js → SvgPreview-mp4tk37p.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-5cjzxcaq.js → abnfDiagram-O67JEVCF-78qb3can.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-62mygavm.js → architectureDiagram-NJMV4G6O-n0fr4hb6.js} +2 -2
- package/dist/client/static/js/{astro-80bs6hvg.js → astro-p3f5p9p2.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-s5yz9hcd.js → blockDiagram-BEXU5L5S-2xemfrzh.js} +6 -6
- package/dist/client/static/js/c-jkdstn33.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rf9xkmrm.js → c4Diagram-YGBWAQC7-zxfdx3eb.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-zfm2cj2a.js → classDiagram-v2-NBCMYWYE-z9sasy3k.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-fmgpv55e.js → cose-bilkent-JH36ORCC-9byp0czh.js} +1 -1
- package/dist/client/static/js/cpp-9d3xdpe3.js +1 -0
- package/dist/client/static/js/css-r3wja1ze.js +1 -0
- package/dist/client/static/js/css-sebxkh5f.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-468r5xc2.js → cynefinDiagram-VND7K2PF-gnm129fx.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-w370qmgj.js → dagre-6A5THRUB-sc5tfv1w.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-sfvfjjsy.js → diagram-22UHCM2B-hq11eek7.js} +7 -7
- package/dist/client/static/js/{diagram-3UASUU5V-3r2c8s14.js → diagram-3UASUU5V-7bk532gd.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-yathy97a.js → diagram-ATOU4E4O-yt8wxttm.js} +2 -2
- package/dist/client/static/js/{diagram-CDSNMT55-kk437kxq.js → diagram-CDSNMT55-n3978w6p.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-qdxfjjhf.js → diagram-MLGK6HIB-004x4gyw.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-dfqeqa1d.js → diagram-MPIPVDR6-498nt489.js} +1 -1
- package/dist/client/static/js/{dockerfile-yxrt509r.js → dockerfile-6hbcmkc8.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s0b0vv4k.js → ebnfDiagram-ZINNZB2B-5fkmymqn.js} +1 -1
- package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-jwphgp8j.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-mtpw0spa.js → elk-276RUBZZ-6xrfa2kd.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-agjdsm1b.js → erDiagram-OPXOYQCR-byz4zbkn.js} +4 -4
- package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-s3fbfwrz.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-z6ywqqc1.js → ganttDiagram-FUAMR5RP-4fkw1k01.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-bvbmfw6h.js → gitGraphDiagram-X574FWY7-19g84yw8.js} +2 -2
- package/dist/client/static/js/graphql-p4cskvad.js +1 -0
- package/dist/client/static/js/html-f26r6vv5.js +1 -0
- package/dist/client/static/js/{index-z0frtyje.js → index-0v8b5pzb.js} +4 -4
- package/dist/client/static/js/{index-z7qnffwj.js → index-1j1s91c4.js} +1 -1
- package/dist/client/static/js/{index-jpkj6vqp.js → index-20vhkcb9.js} +1 -1
- package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
- package/dist/client/static/js/{index-qznwd6g8.js → index-3wpsr2bc.js} +184 -184
- package/dist/client/static/js/{index-09gx6edj.js → index-3y6krykq.js} +1 -1
- package/dist/client/static/js/{index-we1rpftn.js → index-4jbbdq6n.js} +2 -2
- package/dist/client/static/js/{index-ntxm8pw3.js → index-4qt2e84b.js} +2 -2
- package/dist/client/static/js/{index-49dhv8ry.js → index-57z8mtmx.js} +2 -2
- package/dist/client/static/js/{index-qz8mbxm9.js → index-5gn56236.js} +2 -2
- package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
- package/dist/client/static/js/{index-es3pt29g.js → index-74scnfpk.js} +1 -1
- package/dist/client/static/js/{index-0mvcbbmy.js → index-7kafzae0.js} +9 -9
- package/dist/client/static/js/{index-pd0140dx.js → index-89a2702q.js} +1 -1
- package/dist/client/static/js/{index-059qyaj0.js → index-8j90mdgz.js} +1 -1
- package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
- package/dist/client/static/js/{index-a0bdavdr.js → index-ashpbfqv.js} +1 -1
- package/dist/client/static/js/{index-72t6kqjx.js → index-b9b2nwdd.js} +2 -2
- package/dist/client/static/js/{index-8e0s9p45.js → index-baet2nv8.js} +1 -1
- package/dist/client/static/js/{index-j7r414hf.js → index-bhng2dax.js} +2 -2
- package/dist/client/static/js/{index-21b3zyrd.js → index-cj9193d5.js} +2 -2
- package/dist/client/static/js/{index-sezz011q.js → index-dd4q54y0.js} +1 -1
- package/dist/client/static/js/{index-xearvz2z.js → index-e3w46vsc.js} +7 -7
- package/dist/client/static/js/{index-1tyvk778.js → index-e99ec2f0.js} +1 -1
- package/dist/client/static/js/{index-w9zxmev3.js → index-ehnztdd2.js} +1 -1
- package/dist/client/static/js/{index-actppd4z.js → index-epbqzayj.js} +2 -2
- package/dist/client/static/js/{index-k06med7d.js → index-fghst0kd.js} +12 -12
- package/dist/client/static/js/{index-t07b31ny.js → index-fpf1jkwd.js} +3 -3
- package/dist/client/static/js/{index-hbtk0c12.js → index-g252205p.js} +2 -2
- package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
- package/dist/client/static/js/{index-kzhtmrh0.js → index-gxtgyya0.js} +1 -1
- package/dist/client/static/js/index-j314me09.js +1 -0
- package/dist/client/static/js/{index-5fn0agag.js → index-jbwns6sc.js} +1 -1
- package/dist/client/static/js/{index-cx89yk15.js → index-kdgcbt17.js} +2 -2
- package/dist/client/static/js/{index-m87yykre.js → index-m4bjsyj2.js} +5 -5
- package/dist/client/static/js/{index-15zn3sns.js → index-nd4p98mc.js} +1 -1
- package/dist/client/static/js/{index-nmc30xaz.js → index-pfwd0160.js} +1 -1
- package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
- package/dist/client/static/js/{index-0sqa91wb.js → index-qntytvt0.js} +2 -2
- package/dist/client/static/js/{index-64mb65wx.js → index-r83kr4s5.js} +2 -2
- package/dist/client/static/js/{index-7sa2e8mn.js → index-rgdhyry3.js} +2 -2
- package/dist/client/static/js/{index-m3j5yx5f.js → index-sjnnv1gd.js} +4 -4
- package/dist/client/static/js/{index-6q80csr0.js → index-t5t71dhp.js} +2 -2
- package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
- package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
- package/dist/client/static/js/{index-302d35e5.js → index-zj45wj1x.js} +34 -34
- package/dist/client/static/js/{index-83ts8zmk.js → index-zw7qjx65.js} +1 -1
- package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-58bv28d4.js → infoDiagram-VRGFBTTK-aw6ter0a.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-tz6b0caw.js → ishikawaDiagram-OU5B5YK6-62gst5wh.js} +2 -2
- package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ydamm17a.js → journeyDiagram-ZHPQQLJL-6kgv5a4j.js} +3 -3
- package/dist/client/static/js/{julia-v7j460gw.js → julia-237yk557.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-7jxfsf17.js → kanban-definition-PNTS6WVX-8p3515b7.js} +3 -3
- package/dist/client/static/js/lua-86fjqj8v.js +1 -0
- package/dist/client/static/js/{mermaid.core-vty0aq6f.js → mermaid.core-b6ga2y8y.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ra4wrts4.js → mindmap-definition-NLK3R4M7-na9e9b4a.js} +2 -2
- package/dist/client/static/js/one-dark-pro-xp6ssk4z.js +1 -0
- package/dist/client/static/js/one-light-xgab7b02.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-ydjcfea9.js → pegDiagram-GJSIUBJH-d1hk7fnq.js} +1 -1
- package/dist/client/static/js/{perl-gg4jdkcr.js → perl-dvz4y1tb.js} +1 -1
- package/dist/client/static/js/{php-2q8fm6k8.js → php-n6y7dzhm.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-wh04y7wp.js → pieDiagram-5QR66LMP-7b9f4x0y.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-4mhbag8n.js → quadrantDiagram-O4NWA36T-q4wxgmhg.js} +1 -1
- package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-pagmr4hc.js → railroadDiagram-XR7U4H2S-jngq1qx4.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-jhfhp4eq.js → requirementDiagram-PLB6GJNP-6xph3b72.js} +4 -4
- package/dist/client/static/js/{ruby-vag6a82m.js → ruby-7zye3g0e.js} +1 -1
- package/dist/client/static/js/{rust-yntkm6hw.js → rust-w6hen2h4.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-qrfxzvp3.js → sankeyDiagram-IPEJSGJF-ncfzgdj8.js} +1 -1
- package/dist/client/static/js/{sass-kbwea482.js → sass-m0h9yzfb.js} +1 -1
- package/dist/client/static/js/{scss-zphrqp25.js → scss-2pwwfkvn.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-fpznwnva.js → sequenceDiagram-PO4LG4MO-sqz0yfg0.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-3hz930jg.js → sizeCapture-INFHLROL-vt8qp04d.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-2m99syxm.js → stateDiagram-v2-GCMORJYK-myjtrmfe.js} +3 -3
- package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-x8f8c8hq.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-hmhd360r.js → swimlanes-2SLR337P-z9vx7z4j.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-a8b7z74e.js → swimlanesDiagram-TC7HE7FX-5vha7thx.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-765y3ssa.js → timeline-definition-EJHVYXUP-z815np57.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +1 -0
- package/dist/client/static/js/typescript-5nmrzgkj.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-rex2j507.js → usecaseDiagram-POWQR4AR-06ntggng.js} +13 -13
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-wd51qq26.js → vennDiagram-UO4OBE2U-nmtaf5rp.js} +1 -1
- package/dist/client/static/js/{vue-j8vb9d7r.js → vue-myjjd0gd.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-6jdqn8f7.js → wardleyDiagram-VNRHLVJA-zgsxmak8.js} +1 -1
- package/dist/client/static/js/xml-3dd1pter.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-kcz8y04e.js → xychartDiagram-PMCCYNJV-8bg9qdra.js} +2 -2
- package/package.json +1 -1
- package/src/client/components/common/ComposerPicker.tsx +24 -12
- package/src/client/components/common/ComposerTextarea.tsx +1 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.test.tsx +210 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +342 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/LooseFieldAsk.tsx +44 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.test.tsx +44 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +10 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/PluginPendingInteractions.test.ts +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/form-picks.ts +52 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +53 -4
- package/src/client/components/workspace/model-dropdown/index.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +3 -32
- package/src/client/data/settings/omp-schema.json +55 -1
- package/src/client/hooks/chat/composer/harness-model-picker.ts +84 -0
- package/src/client/hooks/chat/composer/index.ts +26 -6
- package/src/client/hooks/chat/timeline/ask-frames.test.ts +80 -7
- package/src/client/hooks/chat/timeline/ask-frames.ts +95 -21
- package/src/client/hooks/models/use-harnesses.ts +15 -2
- package/src/server/lib/auth/agent-gate.server.ts +64 -0
- package/src/server/lib/auth/agent-tree-gate.test.ts +121 -0
- package/src/server/lib/auth/guard.test.ts +18 -18
- package/src/server/lib/auth/guard.ts +15 -11
- package/src/server/lib/auth/handover-guard.test.ts +1 -1
- package/src/server/lib/changes/attach.server.ts +57 -0
- package/src/server/lib/changes/attach.test.ts +94 -0
- package/src/server/lib/changes/blobs.server.ts +52 -0
- package/src/server/lib/changes/capture-bash.server.ts +171 -0
- package/src/server/lib/changes/capture-fs.server.ts +64 -0
- package/src/server/lib/changes/capture-races.test.ts +107 -0
- package/src/server/lib/changes/capture-runs.test.ts +136 -0
- package/src/server/lib/changes/capture-scan.test.ts +157 -0
- package/src/server/lib/changes/capture-test-util.ts +46 -0
- package/src/server/lib/changes/capture-types.ts +64 -0
- package/src/server/lib/changes/capture-write.server.ts +50 -0
- package/src/server/lib/changes/capture.server.ts +349 -0
- package/src/server/lib/changes/capture.test.ts +293 -0
- package/src/server/lib/changes/classify-command.test.ts +172 -0
- package/src/server/lib/changes/classify-command.ts +272 -0
- package/src/server/lib/changes/classify-git.ts +88 -0
- package/src/server/lib/changes/classify-paths.ts +112 -0
- package/src/server/lib/changes/classify-tokenize.ts +185 -0
- package/src/server/lib/changes/journal.server.ts +185 -0
- package/src/server/lib/changes/journal.test.ts +125 -0
- package/src/server/lib/changes/merge.test.ts +137 -0
- package/src/server/lib/changes/omp-fallback.server.ts +48 -0
- package/src/server/lib/changes/omp-fallback.test.ts +75 -0
- package/src/server/lib/changes/paths.server.ts +37 -0
- package/src/server/lib/changes/purge.server.ts +32 -0
- package/src/server/lib/changes/reader.server.ts +350 -0
- package/src/server/lib/changes/reader.test.ts +137 -0
- package/src/server/lib/changes/records.ts +120 -0
- package/src/server/lib/changes/scan.server.ts +139 -0
- package/src/server/lib/changes/sessions.server.ts +65 -0
- package/src/server/lib/changes/sessions.test.ts +52 -0
- package/src/server/lib/harness/register.server.ts +3 -0
- package/src/server/lib/omp/rpc/event-fanout.test.ts +58 -0
- package/src/server/lib/omp/rpc/event-fanout.ts +19 -0
- package/src/server/lib/omp/rpc/manager.ts +4 -3
- package/src/server/lib/omp/rpc/session-registration.ts +5 -0
- package/src/server/lib/omp/rpc/session-registry.ts +4 -5
- package/src/server/lib/omp/session/delete.server.ts +4 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +28 -5
- package/src/server/lib/sessions/agent-token.server.ts +42 -6
- package/src/server/lib/sessions/relation-access.server.test.ts +96 -0
- package/src/server/lib/sessions/relation-access.server.ts +71 -0
- package/src/server/routes/sessions/changes.ts +1 -1
- package/src/shared/lib/chat/ask-form/fields.ts +1 -0
- package/src/shared/lib/chat/ask-form/types.ts +6 -0
- package/src/shared/lib/chat/ask-questions.ts +56 -3
- package/src/shared/lib/chat/composer/delegation.ts +2 -13
- package/src/shared/lib/chat/composer/filter.test.ts +39 -0
- package/src/shared/lib/chat/composer/filter.ts +23 -13
- package/src/shared/lib/chat/composer/harness-model-items.test.ts +54 -0
- package/src/shared/lib/chat/composer/harness-model-items.ts +41 -0
- package/src/shared/lib/chat/composer/trigger.test.ts +50 -0
- package/src/shared/lib/chat/composer/trigger.ts +29 -1
- package/src/shared/lib/chat/timeline/changed-files.test.ts +16 -0
- package/src/shared/lib/chat/timeline/changed-files.ts +102 -25
- package/src/shared/lib/harness/catalog.ts +21 -0
- package/src/{client/components/workspace/model-dropdown/harness-models.test.ts → shared/lib/harness/models.test.ts} +1 -1
- package/src/shared/lib/models/option.ts +46 -0
- package/src/shared/lib/omp/config/schema.test.ts +20 -0
- package/src/shared/types/chat.ts +12 -6
- package/src/shared/types/omp/agent.ts +9 -0
- package/src/shared/types/session-changes.ts +4 -0
- package/dist/client/static/js/architecture-7GRP2DOG-7ewrw5vc.js +0 -1
- package/dist/client/static/js/c-wkgxb1t1.js +0 -1
- package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
- package/dist/client/static/js/css-r2nhvzff.js +0 -1
- package/dist/client/static/js/css-tf1s0nb7.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-yyyx3px0.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-cx3ztxfz.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-267mw6sv.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-eg9r85ak.js +0 -1
- package/dist/client/static/js/graphql-skw5krjr.js +0 -1
- package/dist/client/static/js/html-pv88ny12.js +0 -1
- package/dist/client/static/js/index-tcegdd2t.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-7qhah7fs.js +0 -1
- package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
- package/dist/client/static/js/lua-ke895s2q.js +0 -1
- package/dist/client/static/js/one-dark-pro-2pywnqrh.js +0 -1
- package/dist/client/static/js/one-light-vfgdt4wf.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-ag2g7tbk.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-nqcyj3x1.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-60gby7be.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-cnkmcjse.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-qgfdnazd.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-609h6cpx.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-xqnytjhg.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-8djqab8k.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-hdztnffk.js +0 -1
- package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-avby77vv.js +0 -1
- package/dist/client/static/js/xml-81hxjjt4.js +0 -1
- /package/src/{client/components/workspace/model-dropdown/harness-models.ts → shared/lib/harness/models.ts} +0 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A small shell tokenizer, enough to find a command's words and its output
|
|
8
|
+
* redirects.
|
|
9
|
+
*
|
|
10
|
+
* It is not a shell: no expansion, no substitution, no heredoc body. It exists
|
|
11
|
+
* because omp's trace models `argv` but not redirections (measured: `bun test >
|
|
12
|
+
* /tmp/n1.log 2>&1` yields only `and_or`/`pipeline`/`simple`/`word` nodes), and
|
|
13
|
+
* a redirect is a file write the journal must see.
|
|
14
|
+
*
|
|
15
|
+
* `2>&1` and `>&2` are fd duplications, not file targets, so they become a
|
|
16
|
+
* `fddup` operator the splitter drops. `2>` and `2>>` are output redirects on
|
|
17
|
+
* descriptor 2 and keep their target.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export interface Token {
|
|
21
|
+
kind: 'word' | 'op';
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SimpleCommand {
|
|
26
|
+
words: string[];
|
|
27
|
+
redirects: { op: string; target: string }[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Tokenize a shell script into words and operators. */
|
|
31
|
+
export function tokenizeCommand(script: string): Token[] {
|
|
32
|
+
const tokens: Token[] = [];
|
|
33
|
+
let word = '';
|
|
34
|
+
let hasWord = false;
|
|
35
|
+
const flush = (): void => {
|
|
36
|
+
if (!hasWord) return;
|
|
37
|
+
tokens.push({ kind: 'word', value: word });
|
|
38
|
+
word = '';
|
|
39
|
+
hasWord = false;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < script.length; i++) {
|
|
43
|
+
const ch = script[i];
|
|
44
|
+
if (ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r') {
|
|
45
|
+
flush();
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (ch === '#' && !hasWord) {
|
|
49
|
+
while (i < script.length && script[i] !== '\n') i++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (ch === "'") {
|
|
53
|
+
hasWord = true;
|
|
54
|
+
i++;
|
|
55
|
+
while (i < script.length && script[i] !== "'") word += script[i++];
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (ch === '"') {
|
|
59
|
+
hasWord = true;
|
|
60
|
+
i++;
|
|
61
|
+
while (i < script.length && script[i] !== '"') {
|
|
62
|
+
if (script[i] === '\\' && i + 1 < script.length) {
|
|
63
|
+
i++;
|
|
64
|
+
word += script[i++];
|
|
65
|
+
} else {
|
|
66
|
+
word += script[i++];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (ch === '\\' && i + 1 < script.length) {
|
|
72
|
+
hasWord = true;
|
|
73
|
+
word += script[++i];
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
// `2>&1` / `>&2` are fd duplications, not file targets.
|
|
77
|
+
if (!hasWord && ch === '2' && script[i + 1] === '>' && script[i + 2] === '&') {
|
|
78
|
+
let j = i + 3;
|
|
79
|
+
while (j < script.length && /[0-9-]/.test(script[j])) j++;
|
|
80
|
+
tokens.push({ kind: 'op', value: 'fddup' });
|
|
81
|
+
i = j - 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (!hasWord && ch === '&' && script[i + 1] === '>') {
|
|
85
|
+
if (script[i + 2] === '&') {
|
|
86
|
+
tokens.push({ kind: 'op', value: '&>>' });
|
|
87
|
+
i += 2;
|
|
88
|
+
} else {
|
|
89
|
+
tokens.push({ kind: 'op', value: '&>' });
|
|
90
|
+
i += 1;
|
|
91
|
+
}
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// `2>` / `2>>` — the `2` is a descriptor, not an argument.
|
|
95
|
+
if (ch === '2' && script[i + 1] === '>' && (!hasWord || word === '2')) {
|
|
96
|
+
if (word === '2') {
|
|
97
|
+
word = '';
|
|
98
|
+
hasWord = false;
|
|
99
|
+
}
|
|
100
|
+
const op = script[i + 2] === '>' ? '2>>' : '2>';
|
|
101
|
+
tokens.push({ kind: 'op', value: op });
|
|
102
|
+
i += op.length - 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (ch === '|' || ch === '&' || ch === ';' || ch === '<' || ch === '>') {
|
|
106
|
+
flush();
|
|
107
|
+
const two = script.slice(i, i + 2);
|
|
108
|
+
if (two === '&&' || two === '||' || two === '>>' || two === '<<' || two === '>&') {
|
|
109
|
+
tokens.push({ kind: 'op', value: two });
|
|
110
|
+
i++;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
tokens.push({ kind: 'op', value: ch });
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
hasWord = true;
|
|
117
|
+
word += ch;
|
|
118
|
+
}
|
|
119
|
+
flush();
|
|
120
|
+
return tokens;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Drop heredoc BODIES, keeping the command line that opens them.
|
|
125
|
+
*
|
|
126
|
+
* A heredoc body is data, not shell: `cat > f <<'EOF'` followed by lines that
|
|
127
|
+
* happen to contain `>` or `rm` must not be parsed as commands. Measured on a
|
|
128
|
+
* real session: an `AGENTS.md` heredoc whose prose named a file produced a
|
|
129
|
+
* phantom `cat > Panduan` mutation. The delimiter line itself is dropped too.
|
|
130
|
+
*/
|
|
131
|
+
export function stripHeredocs(script: string): string {
|
|
132
|
+
const lines = script.split('\n');
|
|
133
|
+
const out: string[] = [];
|
|
134
|
+
let pending: string | null = null;
|
|
135
|
+
let stripTabs = false;
|
|
136
|
+
for (const line of lines) {
|
|
137
|
+
if (pending !== null) {
|
|
138
|
+
const candidate = stripTabs ? line.replace(/^\t+/, '') : line;
|
|
139
|
+
if (candidate === pending) pending = null;
|
|
140
|
+
out.push('');
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
out.push(line);
|
|
144
|
+
const match = /<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/.exec(line);
|
|
145
|
+
if (match?.[2]) {
|
|
146
|
+
pending = match[2];
|
|
147
|
+
stripTabs = line.includes('<<-');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return out.join('\n');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Split tokens into simple commands, keeping each command's output redirects. */
|
|
154
|
+
export function splitCommands(tokens: Token[]): SimpleCommand[] {
|
|
155
|
+
const commands: SimpleCommand[] = [];
|
|
156
|
+
let current: SimpleCommand = { words: [], redirects: [] };
|
|
157
|
+
const push = (): void => {
|
|
158
|
+
if (current.words.length > 0 || current.redirects.length > 0) commands.push(current);
|
|
159
|
+
current = { words: [], redirects: [] };
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
163
|
+
const token = tokens[i];
|
|
164
|
+
if (token.kind === 'word') {
|
|
165
|
+
current.words.push(token.value);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (token.value === ';' || token.value === '&&' || token.value === '||' || token.value === '|' || token.value === '&') {
|
|
169
|
+
push();
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (token.value === 'fddup') continue;
|
|
173
|
+
if (token.value === '<' || token.value === '<<' || token.value === '>&') {
|
|
174
|
+
i++;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const target = tokens[i + 1];
|
|
178
|
+
if (target?.kind === 'word') {
|
|
179
|
+
current.redirects.push({ op: token.value, target: target.value });
|
|
180
|
+
i++;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
push();
|
|
184
|
+
return commands;
|
|
185
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Kabmo change journal writer: one append-only JSONL per session.
|
|
8
|
+
*
|
|
9
|
+
* Every append goes through one promise chain, so two parallel subagents cannot
|
|
10
|
+
* interleave a half line. A failed append is logged and swallowed — the journal
|
|
11
|
+
* is an annotation on a run, and a full disk must not kill the run it reports
|
|
12
|
+
* on. A torn final line is tolerated by the reader, the same rule omp's own
|
|
13
|
+
* journal follows.
|
|
14
|
+
*
|
|
15
|
+
* The directory is created lazily, on the first record: a session that never
|
|
16
|
+
* calls a tool writes nothing, which is what keeps a test that spawns a fake
|
|
17
|
+
* child from touching the developer's real `~/.kabmo`.
|
|
18
|
+
*
|
|
19
|
+
* Rotation: when the journal passes 20 MB it is renamed to
|
|
20
|
+
* `changes.<epoch>.jsonl` and a fresh `changes.jsonl` starts with a new header.
|
|
21
|
+
* The reader reads every `changes*.jsonl` in name order, so a rotated file is
|
|
22
|
+
* older than the current one and the sequence is preserved.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { appendFile, mkdir, rename, stat } from 'node:fs/promises';
|
|
26
|
+
import path from 'node:path';
|
|
27
|
+
import { blobsDir, journalPath, sessionChangesDir } from '@/server/lib/changes/paths.server';
|
|
28
|
+
import { writeBlob } from '@/server/lib/changes/blobs.server';
|
|
29
|
+
import type { MutationOp } from '@/server/lib/changes/classify-command';
|
|
30
|
+
import type {
|
|
31
|
+
JournalCallRecord,
|
|
32
|
+
JournalChangeRecord,
|
|
33
|
+
JournalNoteRecord,
|
|
34
|
+
JournalRecord,
|
|
35
|
+
JournalRunRecord,
|
|
36
|
+
JournalSessionRecord,
|
|
37
|
+
} from '@/server/lib/changes/records';
|
|
38
|
+
|
|
39
|
+
const MAX_JOURNAL_BYTES = 20 * 1024 * 1024;
|
|
40
|
+
const MAX_ARGS_BYTES = 4 * 1024;
|
|
41
|
+
|
|
42
|
+
export interface ChangeInput {
|
|
43
|
+
at: number;
|
|
44
|
+
runId?: string;
|
|
45
|
+
runAt?: number;
|
|
46
|
+
toolCallId?: string;
|
|
47
|
+
agent: string;
|
|
48
|
+
parent?: string;
|
|
49
|
+
tool: string;
|
|
50
|
+
op: MutationOp;
|
|
51
|
+
path: string;
|
|
52
|
+
from?: string;
|
|
53
|
+
displayPath: string;
|
|
54
|
+
/** Full text before the write; `null` absent, `undefined` not stored. */
|
|
55
|
+
before: string | null | undefined;
|
|
56
|
+
/** Full text after the write; `null` absent, `undefined` not stored. */
|
|
57
|
+
after: string | null | undefined;
|
|
58
|
+
beforeMtimeMs?: number;
|
|
59
|
+
afterMtimeMs?: number;
|
|
60
|
+
source: JournalChangeRecord['source'];
|
|
61
|
+
command?: string;
|
|
62
|
+
exit?: number;
|
|
63
|
+
/** Why a side is `undefined`; defaults to the blob cap. */
|
|
64
|
+
unavailableReason?: 'too-large' | 'snapshot-race';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class ChangeJournal {
|
|
68
|
+
readonly dir: string;
|
|
69
|
+
readonly #startedAt = Date.now();
|
|
70
|
+
#chain: Promise<void> = Promise.resolve();
|
|
71
|
+
#ready: Promise<void> | null = null;
|
|
72
|
+
#closed = false;
|
|
73
|
+
#bytes = 0;
|
|
74
|
+
|
|
75
|
+
constructor(
|
|
76
|
+
readonly sessionId: string,
|
|
77
|
+
readonly cwd: string,
|
|
78
|
+
) {
|
|
79
|
+
this.dir = sessionChangesDir(sessionId);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
recordCall(input: Omit<JournalCallRecord, 'v' | 'type'>): Promise<void> {
|
|
83
|
+
const args = truncateArgs(input.args);
|
|
84
|
+
return this.#enqueue(() => this.#appendLine({ v: 1, type: 'call', ...input, ...args }));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
recordChange(input: ChangeInput): Promise<void> {
|
|
88
|
+
return this.#enqueue(async () => {
|
|
89
|
+
const before = input.before === null || input.before === undefined
|
|
90
|
+
? input.before
|
|
91
|
+
: await this.#blob(input.before);
|
|
92
|
+
const after = input.after === null || input.after === undefined
|
|
93
|
+
? input.after
|
|
94
|
+
: await this.#blob(input.after);
|
|
95
|
+
if (before === undefined || after === undefined) {
|
|
96
|
+
await this.#appendLine({
|
|
97
|
+
v: 1,
|
|
98
|
+
type: 'note',
|
|
99
|
+
at: input.at,
|
|
100
|
+
...(input.toolCallId ? { toolCallId: input.toolCallId } : {}),
|
|
101
|
+
reason: input.unavailableReason ?? 'too-large',
|
|
102
|
+
detail: input.path,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
await this.#appendLine({ v: 1, type: 'change', ...input, before, after });
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
recordNote(input: Omit<JournalNoteRecord, 'v' | 'type'>): Promise<void> {
|
|
110
|
+
return this.#enqueue(() => this.#appendLine({ v: 1, type: 'note', ...input }));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
recordRun(input: Omit<JournalRunRecord, 'v' | 'type'>): Promise<void> {
|
|
114
|
+
return this.#enqueue(() => this.#appendLine({ v: 1, type: 'run', ...input }));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
flush(): Promise<void> {
|
|
118
|
+
return this.#chain;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
close(): void {
|
|
122
|
+
this.#closed = true;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#enqueue(task: () => Promise<void>): Promise<void> {
|
|
126
|
+
this.#chain = this.#chain.then(task).catch((error: unknown) => {
|
|
127
|
+
console.error(`[changes] journal append failed for ${this.sessionId}:`, error);
|
|
128
|
+
});
|
|
129
|
+
return this.#chain;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async #blob(text: string): Promise<string | null | undefined> {
|
|
133
|
+
const key = await writeBlob(blobsDir(this.sessionId), text);
|
|
134
|
+
return key === null ? undefined : key;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async #appendLine(record: JournalRecord): Promise<void> {
|
|
138
|
+
if (this.#closed) return;
|
|
139
|
+
await this.#ensure();
|
|
140
|
+
const line = `${JSON.stringify(record)}\n`;
|
|
141
|
+
await appendFile(journalPath(this.sessionId), line);
|
|
142
|
+
this.#bytes += Buffer.byteLength(line);
|
|
143
|
+
if (this.#bytes >= MAX_JOURNAL_BYTES) await this.#rotate();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
#ensure(): Promise<void> {
|
|
147
|
+
if (!this.#ready) this.#ready = this.#init();
|
|
148
|
+
return this.#ready;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async #init(): Promise<void> {
|
|
152
|
+
await mkdir(this.dir, { recursive: true, mode: 0o700 });
|
|
153
|
+
await mkdir(blobsDir(this.sessionId), { recursive: true, mode: 0o700 });
|
|
154
|
+
const file = journalPath(this.sessionId);
|
|
155
|
+
const info = await stat(file).catch(() => null);
|
|
156
|
+
this.#bytes = info?.size ?? 0;
|
|
157
|
+
if (!info) await this.#writeHeader(file);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async #writeHeader(file: string): Promise<void> {
|
|
161
|
+
const header: JournalSessionRecord = {
|
|
162
|
+
v: 1,
|
|
163
|
+
type: 'session',
|
|
164
|
+
at: this.#startedAt,
|
|
165
|
+
sessionId: this.sessionId,
|
|
166
|
+
cwd: this.cwd,
|
|
167
|
+
};
|
|
168
|
+
const line = `${JSON.stringify(header)}\n`;
|
|
169
|
+
await Bun.write(file, line);
|
|
170
|
+
this.#bytes = Buffer.byteLength(line);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async #rotate(): Promise<void> {
|
|
174
|
+
const file = journalPath(this.sessionId);
|
|
175
|
+
await rename(file, path.join(this.dir, `changes.${Date.now()}.jsonl`));
|
|
176
|
+
await this.#writeHeader(file);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function truncateArgs(args: unknown): { args?: unknown; argsTruncated?: boolean } {
|
|
181
|
+
if (args === undefined) return {};
|
|
182
|
+
const json = JSON.stringify(args);
|
|
183
|
+
if (json.length <= MAX_ARGS_BYTES) return { args };
|
|
184
|
+
return { args: json.slice(0, MAX_ARGS_BYTES), argsTruncated: true };
|
|
185
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The journal writer: one append-only JSONL, content-addressed blobs, and the
|
|
8
|
+
* two rules a reader depends on — a header on the first line and a torn line
|
|
9
|
+
* that never poisons the rest.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
13
|
+
import * as fsp from 'node:fs/promises';
|
|
14
|
+
import * as os from 'node:os';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
17
|
+
import { blobsDir, journalPath } from '@/server/lib/changes/paths.server';
|
|
18
|
+
import { parseJournalLine, type JournalRecord } from '@/server/lib/changes/records';
|
|
19
|
+
|
|
20
|
+
let dataDir = '';
|
|
21
|
+
let original: string | undefined;
|
|
22
|
+
|
|
23
|
+
beforeAll(async () => {
|
|
24
|
+
original = Bun.env.KABMO_DATA_DIR;
|
|
25
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-'));
|
|
26
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterAll(async () => {
|
|
30
|
+
if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
31
|
+
else Bun.env.KABMO_DATA_DIR = original;
|
|
32
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
async function readLines(sessionId: string): Promise<JournalRecord[]> {
|
|
36
|
+
const text = await Bun.file(journalPath(sessionId)).text();
|
|
37
|
+
return text.split('\n').map(parseJournalLine).filter((line): line is JournalRecord => line !== null);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('ChangeJournal', () => {
|
|
41
|
+
test('writes a session header, then the change with blob keys', async () => {
|
|
42
|
+
const journal = new ChangeJournal('sess-write', '/repo');
|
|
43
|
+
await journal.recordChange({
|
|
44
|
+
at: 100,
|
|
45
|
+
agent: 'Main',
|
|
46
|
+
tool: 'edit',
|
|
47
|
+
op: 'update',
|
|
48
|
+
path: '/repo/a.ts',
|
|
49
|
+
displayPath: 'a.ts',
|
|
50
|
+
before: 'old',
|
|
51
|
+
after: 'new',
|
|
52
|
+
source: 'tool',
|
|
53
|
+
});
|
|
54
|
+
await journal.flush();
|
|
55
|
+
|
|
56
|
+
const lines = await readLines('sess-write');
|
|
57
|
+
expect(lines[0]?.type).toBe('session');
|
|
58
|
+
const change = lines[1];
|
|
59
|
+
expect(change?.type).toBe('change');
|
|
60
|
+
if (change?.type !== 'change') throw new Error('expected a change record');
|
|
61
|
+
expect(change.before).toMatch(/^3-/);
|
|
62
|
+
expect(change.after).toMatch(/^3-/);
|
|
63
|
+
expect(change.before).not.toBe(change.after);
|
|
64
|
+
|
|
65
|
+
const blobs = await fsp.readdir(blobsDir('sess-write'));
|
|
66
|
+
expect(blobs.length).toBe(2);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('reuses a blob for the same content', async () => {
|
|
70
|
+
const journal = new ChangeJournal('sess-dedupe', '/repo');
|
|
71
|
+
await journal.recordChange({
|
|
72
|
+
at: 1, agent: 'Main', tool: 'edit', op: 'update', path: '/repo/a.ts',
|
|
73
|
+
displayPath: 'a.ts', before: 'same', after: 'one', source: 'tool',
|
|
74
|
+
});
|
|
75
|
+
await journal.recordChange({
|
|
76
|
+
at: 2, agent: 'Main', tool: 'edit', op: 'update', path: '/repo/b.ts',
|
|
77
|
+
displayPath: 'b.ts', before: 'same', after: 'two', source: 'tool',
|
|
78
|
+
});
|
|
79
|
+
await journal.flush();
|
|
80
|
+
|
|
81
|
+
const blobs = await fsp.readdir(blobsDir('sess-dedupe'));
|
|
82
|
+
// 'same' once, 'one' once, 'two' once.
|
|
83
|
+
expect(blobs.length).toBe(3);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('truncates a large call argument bag and says so', async () => {
|
|
87
|
+
const journal = new ChangeJournal('sess-call', '/repo');
|
|
88
|
+
await journal.recordCall({
|
|
89
|
+
at: 1,
|
|
90
|
+
toolCallId: 'c1',
|
|
91
|
+
agent: 'Main',
|
|
92
|
+
tool: 'bash',
|
|
93
|
+
args: { command: 'x'.repeat(5000) },
|
|
94
|
+
});
|
|
95
|
+
await journal.flush();
|
|
96
|
+
|
|
97
|
+
const call = (await readLines('sess-call')).find((line) => line.type === 'call');
|
|
98
|
+
expect(call?.type).toBe('call');
|
|
99
|
+
if (call?.type !== 'call') throw new Error('expected a call record');
|
|
100
|
+
expect(call.argsTruncated).toBe(true);
|
|
101
|
+
expect(typeof call.args).toBe('string');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('records a note without inventing a change', async () => {
|
|
105
|
+
const journal = new ChangeJournal('sess-note', '/repo');
|
|
106
|
+
await journal.recordNote({ at: 1, toolCallId: 'c1', reason: 'opaque-command', detail: 'bun test' });
|
|
107
|
+
await journal.flush();
|
|
108
|
+
|
|
109
|
+
const lines = await readLines('sess-note');
|
|
110
|
+
expect(lines.map((line) => line.type)).toEqual(['session', 'note']);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('a torn final line is skipped by the parser', async () => {
|
|
114
|
+
const journal = new ChangeJournal('sess-torn', '/repo');
|
|
115
|
+
await journal.recordChange({
|
|
116
|
+
at: 1, agent: 'Main', tool: 'edit', op: 'create', path: '/repo/a.ts',
|
|
117
|
+
displayPath: 'a.ts', before: null, after: 'A', source: 'tool',
|
|
118
|
+
});
|
|
119
|
+
await journal.flush();
|
|
120
|
+
await fsp.appendFile(journalPath('sess-torn'), '{"v":1,"type":"change"');
|
|
121
|
+
|
|
122
|
+
const lines = await readLines('sess-torn');
|
|
123
|
+
expect(lines.map((line) => line.type)).toEqual(['session', 'change']);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A session that spans the feature: it ran before the Kabmo journal existed and
|
|
8
|
+
* continued after it.
|
|
9
|
+
*
|
|
10
|
+
* The Kabmo journal starts mid-session, so the omp records older than its first
|
|
11
|
+
* line are merged in. A diff whose two sides straddle the boundary must read
|
|
12
|
+
* the omp blob for the `before` and the Kabmo blob for the `after` — the two
|
|
13
|
+
* stores are separate directories.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import * as fsp from 'node:fs/promises';
|
|
18
|
+
import * as os from 'node:os';
|
|
19
|
+
import * as path from 'node:path';
|
|
20
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
21
|
+
import {
|
|
22
|
+
readSessionChangeDiff,
|
|
23
|
+
readSessionChangeList,
|
|
24
|
+
} from '@/server/lib/changes/reader.server';
|
|
25
|
+
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
26
|
+
|
|
27
|
+
const SESSION = 'merge-1';
|
|
28
|
+
const CWD = '/repo';
|
|
29
|
+
let dataDir = '';
|
|
30
|
+
let agentDir = '';
|
|
31
|
+
let ompJournalDir = '';
|
|
32
|
+
let originalData: string | undefined;
|
|
33
|
+
let originalAgent: string | undefined;
|
|
34
|
+
|
|
35
|
+
async function ompBlob(key: string, text: string): Promise<void> {
|
|
36
|
+
await fsp.mkdir(path.join(ompJournalDir, 'blobs'), { recursive: true });
|
|
37
|
+
await fsp.writeFile(path.join(ompJournalDir, 'blobs', key), Bun.gzipSync(Buffer.from(text, 'utf8')));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function ompChange(record: Record<string, unknown>): Promise<void> {
|
|
41
|
+
await fsp.appendFile(path.join(ompJournalDir, 'changes.jsonl'), `${JSON.stringify(record)}\n`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
beforeAll(async () => {
|
|
45
|
+
originalData = Bun.env.KABMO_DATA_DIR;
|
|
46
|
+
originalAgent = Bun.env.PI_CODING_AGENT_DIR;
|
|
47
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-merge-data-'));
|
|
48
|
+
agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-merge-agent-'));
|
|
49
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
50
|
+
Bun.env.PI_CODING_AGENT_DIR = agentDir;
|
|
51
|
+
clearSessionFileCaches();
|
|
52
|
+
|
|
53
|
+
const projectDir = path.join(agentDir, 'sessions', '-repo');
|
|
54
|
+
await fsp.mkdir(projectDir, { recursive: true });
|
|
55
|
+
const sessionFile = path.join(projectDir, `2026-01-01T00-00-00-000Z_${SESSION}.jsonl`);
|
|
56
|
+
await fsp.writeFile(
|
|
57
|
+
sessionFile,
|
|
58
|
+
`${JSON.stringify({ type: 'session', version: 3, id: SESSION, timestamp: '2026-01-01T00:00:00.000Z', cwd: CWD })}\n`,
|
|
59
|
+
);
|
|
60
|
+
ompJournalDir = sessionFile.slice(0, -'.jsonl'.length);
|
|
61
|
+
await fsp.mkdir(ompJournalDir, { recursive: true });
|
|
62
|
+
|
|
63
|
+
// The pre-feature half: an omp create and an omp update.
|
|
64
|
+
await ompBlob('omp-a', 'A');
|
|
65
|
+
await ompBlob('omp-b1', 'B1');
|
|
66
|
+
await ompBlob('omp-b2', 'B2');
|
|
67
|
+
await ompChange({ type: 'change', at: 100, agent: 'Main', tool: 'edit', path: '/repo/a.ts', before: null, after: 'omp-a' });
|
|
68
|
+
await ompChange({ type: 'change', at: 110, agent: 'Main', tool: 'edit', path: '/repo/b.ts', before: 'omp-b1', after: 'omp-b2' });
|
|
69
|
+
// After the first Kabmo line: must NOT be merged.
|
|
70
|
+
await ompChange({ type: 'change', at: 300, agent: 'Main', tool: 'edit', path: '/repo/d.ts', before: null, after: 'omp-a' });
|
|
71
|
+
// A pre-feature creation whose file is gone: the omp heuristic drops it.
|
|
72
|
+
await ompChange({ type: 'change', at: 120, agent: 'Main', tool: 'edit', path: '/repo/e.ts', before: null, after: 'omp-a' });
|
|
73
|
+
|
|
74
|
+
// The post-feature half: a Kabmo update of a.ts and b.ts, plus a new c.ts.
|
|
75
|
+
const journal = new ChangeJournal(SESSION, CWD);
|
|
76
|
+
await journal.recordChange({
|
|
77
|
+
at: 200, agent: 'Main', tool: 'bash', op: 'update', path: '/repo/a.ts',
|
|
78
|
+
displayPath: 'a.ts', before: 'A', after: 'A2', source: 'trace', command: 'sed -i s/A/A2/ a.ts',
|
|
79
|
+
});
|
|
80
|
+
await journal.recordChange({
|
|
81
|
+
at: 210, agent: 'Main', tool: 'bash', op: 'update', path: '/repo/b.ts',
|
|
82
|
+
displayPath: 'b.ts', before: 'B2', after: 'B3', source: 'trace', command: 'sed -i s/B2/B3/ b.ts',
|
|
83
|
+
});
|
|
84
|
+
await journal.recordChange({
|
|
85
|
+
at: 220, agent: 'Main', tool: 'write', op: 'create', path: '/repo/c.ts',
|
|
86
|
+
displayPath: 'c.ts', before: null, after: 'C', source: 'tool',
|
|
87
|
+
});
|
|
88
|
+
await journal.flush();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
afterAll(async () => {
|
|
92
|
+
if (originalData === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
93
|
+
else Bun.env.KABMO_DATA_DIR = originalData;
|
|
94
|
+
if (originalAgent === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
95
|
+
else Bun.env.PI_CODING_AGENT_DIR = originalAgent;
|
|
96
|
+
clearSessionFileCaches();
|
|
97
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
98
|
+
await fsp.rm(agentDir, { recursive: true, force: true });
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('a session that spans the feature', () => {
|
|
102
|
+
test('merges the omp records older than the first Kabmo line', async () => {
|
|
103
|
+
const records = await readSessionChangeList(SESSION);
|
|
104
|
+
expect(records.map((record) => record.path)).toEqual([
|
|
105
|
+
'/repo/a.ts',
|
|
106
|
+
'/repo/b.ts',
|
|
107
|
+
'/repo/a.ts',
|
|
108
|
+
'/repo/b.ts',
|
|
109
|
+
'/repo/c.ts',
|
|
110
|
+
]);
|
|
111
|
+
// The omp record after the boundary is not merged.
|
|
112
|
+
expect(records.some((record) => record.path === '/repo/d.ts')).toBe(false);
|
|
113
|
+
// A pre-feature creation whose file is gone is dropped by the omp heuristic.
|
|
114
|
+
expect(records.some((record) => record.path === '/repo/e.ts')).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('a diff straddling the boundary reads each side from its own store', async () => {
|
|
118
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/b.ts', 0, 1000);
|
|
119
|
+
expect(diff?.status).toBe('modified');
|
|
120
|
+
expect(diff?.oldContent).toBe('B1');
|
|
121
|
+
expect(diff?.newContent).toBe('B3');
|
|
122
|
+
expect(diff?.unavailable).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('a create before the boundary and an update after it is one added file', async () => {
|
|
126
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/a.ts', 0, 1000);
|
|
127
|
+
expect(diff?.status).toBe('added');
|
|
128
|
+
expect(diff?.oldContent).toBe('');
|
|
129
|
+
expect(diff?.newContent).toBe('A2');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('a Kabmo-only path reads the Kabmo store', async () => {
|
|
133
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/c.ts', 0, 1000);
|
|
134
|
+
expect(diff?.status).toBe('added');
|
|
135
|
+
expect(diff?.newContent).toBe('C');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The omp journal as a fallback for a raced `write` snapshot.
|
|
8
|
+
*
|
|
9
|
+
* omp records `write`/`edit` before/after blobs itself, and it reads the file
|
|
10
|
+
* inside the tool — before the write — so its `before` is exact where Kabmo's
|
|
11
|
+
* start-frame snapshot can lose the race. When a `write`'s before and after are
|
|
12
|
+
* equal, the capture asks this module for the omp record of the same path near
|
|
13
|
+
* the call's start time and reads its `before` blob.
|
|
14
|
+
*
|
|
15
|
+
* A missing record answers `undefined` (unknown), not `null` (absent): the
|
|
16
|
+
* caller must not turn "I could not find it" into "the file did not exist".
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
import { readBlob } from '@/server/lib/changes/blobs.server';
|
|
21
|
+
import { readSessionChangeIndex } from '@/server/lib/omp/session/changes';
|
|
22
|
+
import { findSessionFileById } from '@/server/lib/omp/session/locator';
|
|
23
|
+
import { siblingDirForSession } from '@/server/lib/omp/subagent/history/paths';
|
|
24
|
+
|
|
25
|
+
/** How far the omp record's write time may sit from the call's start frame. */
|
|
26
|
+
const MATCH_WINDOW_MS = 10_000;
|
|
27
|
+
|
|
28
|
+
export async function readOmpBefore(
|
|
29
|
+
sessionId: string,
|
|
30
|
+
absolute: string,
|
|
31
|
+
at: number,
|
|
32
|
+
): Promise<string | null | undefined> {
|
|
33
|
+
const records = await readSessionChangeIndex(sessionId);
|
|
34
|
+
let best: { before: string | null | undefined; delta: number } | null = null;
|
|
35
|
+
for (const record of records) {
|
|
36
|
+
if (record.path !== absolute) continue;
|
|
37
|
+
if (record.before === undefined) continue;
|
|
38
|
+
const delta = Math.abs(record.at - at);
|
|
39
|
+
if (delta > MATCH_WINDOW_MS) continue;
|
|
40
|
+
if (!best || delta < best.delta) best = { before: record.before, delta };
|
|
41
|
+
}
|
|
42
|
+
if (!best) return undefined;
|
|
43
|
+
if (best.before === null) return null;
|
|
44
|
+
|
|
45
|
+
const sessionFile = await findSessionFileById(sessionId);
|
|
46
|
+
if (!sessionFile) return undefined;
|
|
47
|
+
return readBlob(path.join(siblingDirForSession(sessionFile), 'blobs'), best.before);
|
|
48
|
+
}
|