@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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Attach a change journal to a live session.
|
|
8
|
+
*
|
|
9
|
+
* The subscription is the RAW frame stream when the transport has one: omp's
|
|
10
|
+
* `bash` trace is stripped before ordinary subscribers see it (it is ~a second
|
|
11
|
+
* copy of the output), and the trace is the only structured record of what a
|
|
12
|
+
* shell command ran. A transport without a raw stream (ACP) falls back to
|
|
13
|
+
* `onEvent`; its tool frames still carry `args`, so the tool adapters work and
|
|
14
|
+
* only the shell layer is weaker.
|
|
15
|
+
*
|
|
16
|
+
* The journal is lazy: a session that never calls a tool writes nothing, so a
|
|
17
|
+
* test that spawns a fake child does not touch the developer's real `~/.kabmo`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import os from 'node:os';
|
|
21
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
22
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
23
|
+
import { ChangeCapture } from '@/server/lib/changes/capture.server';
|
|
24
|
+
|
|
25
|
+
export interface JournalSession {
|
|
26
|
+
readonly sessionId: string;
|
|
27
|
+
readonly cwd: string;
|
|
28
|
+
onEvent(listener: (event: AgentEvent) => void): () => void;
|
|
29
|
+
onRawEvent?(listener: (event: AgentEvent) => void): () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface JournalAttachment {
|
|
33
|
+
/** Stop listening; the journal flushes and closes in the background. */
|
|
34
|
+
detach(): void;
|
|
35
|
+
/** Await every in-flight capture and append (tests and shutdown). */
|
|
36
|
+
flush(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Start journaling `session`. */
|
|
40
|
+
export function attachChangeJournal(session: JournalSession): JournalAttachment {
|
|
41
|
+
const noop: JournalAttachment = { detach: () => {}, flush: async () => {} };
|
|
42
|
+
if (!session.sessionId) return noop;
|
|
43
|
+
const journal = new ChangeJournal(session.sessionId, session.cwd);
|
|
44
|
+
const capture = new ChangeCapture({ journal, cwd: session.cwd, home: os.homedir() });
|
|
45
|
+
const subscribe = session.onRawEvent ?? session.onEvent;
|
|
46
|
+
// A test double (or a transport that exposes no frame stream) has neither;
|
|
47
|
+
// the journal is an annotation, not a reason to fail a registration.
|
|
48
|
+
if (typeof subscribe !== 'function') return noop;
|
|
49
|
+
const off = subscribe.call(session, (event) => capture.onFrame(event));
|
|
50
|
+
return {
|
|
51
|
+
detach: () => {
|
|
52
|
+
off();
|
|
53
|
+
void capture.flush().finally(() => journal.close());
|
|
54
|
+
},
|
|
55
|
+
flush: () => capture.flush(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The attach seam: a live session's raw frames reach the journal.
|
|
8
|
+
*
|
|
9
|
+
* The unit tests for the capture and the reader prove the two halves; this one
|
|
10
|
+
* proves the wire between them — `onRawEvent` is the subscription, the real
|
|
11
|
+
* filesystem is the source, and a `bash rm` lands as a `delete` record.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
15
|
+
import * as fsp from 'node:fs/promises';
|
|
16
|
+
import * as os from 'node:os';
|
|
17
|
+
import * as path from 'node:path';
|
|
18
|
+
import { attachChangeJournal } from '@/server/lib/changes/attach.server';
|
|
19
|
+
import { journalPath } from '@/server/lib/changes/paths.server';
|
|
20
|
+
import { parseJournalLine, type JournalRecord } from '@/server/lib/changes/records';
|
|
21
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
22
|
+
|
|
23
|
+
let dataDir = '';
|
|
24
|
+
let cwd = '';
|
|
25
|
+
let original: string | undefined;
|
|
26
|
+
|
|
27
|
+
beforeAll(async () => {
|
|
28
|
+
original = Bun.env.KABMO_DATA_DIR;
|
|
29
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-attach-'));
|
|
30
|
+
cwd = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-cwd-'));
|
|
31
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterAll(async () => {
|
|
35
|
+
if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
36
|
+
else Bun.env.KABMO_DATA_DIR = original;
|
|
37
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
38
|
+
await fsp.rm(cwd, { recursive: true, force: true });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('attachChangeJournal', () => {
|
|
42
|
+
test('subscribes to the raw stream and journals a bash delete', async () => {
|
|
43
|
+
const file = path.join(cwd, 'a.txt');
|
|
44
|
+
await fsp.writeFile(file, 'old');
|
|
45
|
+
const listeners: ((event: AgentEvent) => void)[] = [];
|
|
46
|
+
const session = {
|
|
47
|
+
sessionId: 'attach-1',
|
|
48
|
+
cwd,
|
|
49
|
+
onEvent: () => () => {},
|
|
50
|
+
onRawEvent: (listener: (event: AgentEvent) => void) => {
|
|
51
|
+
listeners.push(listener);
|
|
52
|
+
return () => {};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const attachment = attachChangeJournal(session);
|
|
57
|
+
expect(listeners.length).toBe(1);
|
|
58
|
+
|
|
59
|
+
listeners[0]({
|
|
60
|
+
type: 'tool_execution_start',
|
|
61
|
+
toolCallId: 'c1',
|
|
62
|
+
toolName: 'bash',
|
|
63
|
+
args: { command: 'rm -f a.txt' },
|
|
64
|
+
});
|
|
65
|
+
await attachment.flush();
|
|
66
|
+
await fsp.rm(file);
|
|
67
|
+
listeners[0]({
|
|
68
|
+
type: 'tool_execution_end',
|
|
69
|
+
toolCallId: 'c1',
|
|
70
|
+
toolName: 'bash',
|
|
71
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['rm', '-f', 'a.txt'], st: 0 }] }] } } },
|
|
72
|
+
});
|
|
73
|
+
await attachment.flush();
|
|
74
|
+
attachment.detach();
|
|
75
|
+
|
|
76
|
+
const text = await Bun.file(journalPath('attach-1')).text();
|
|
77
|
+
const records = text.split('\n').map(parseJournalLine).filter((line): line is JournalRecord => line !== null);
|
|
78
|
+
const change = records.find((line) => line.type === 'change');
|
|
79
|
+
expect(change?.type).toBe('change');
|
|
80
|
+
if (change?.type !== 'change') throw new Error('expected a change record');
|
|
81
|
+
expect(change.op).toBe('delete');
|
|
82
|
+
expect(change.path).toBe(file);
|
|
83
|
+
expect(change.source).toBe('trace');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('a session with no frame stream is a no-op, not a crash', () => {
|
|
87
|
+
const attachment = attachChangeJournal({
|
|
88
|
+
sessionId: 'attach-2',
|
|
89
|
+
cwd,
|
|
90
|
+
onEvent: undefined as never,
|
|
91
|
+
});
|
|
92
|
+
expect(() => attachment.detach()).not.toThrow();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Content-addressed gzip blobs for the change journal.
|
|
8
|
+
*
|
|
9
|
+
* The key is `<byteLength base36>-<Bun.hash base36>`, the same shape omp uses,
|
|
10
|
+
* so a blob written by either writer is recognisable. The cap is 32 MB — four
|
|
11
|
+
* times omp's 8 MB — because the journal's job is to answer "what did this run
|
|
12
|
+
* do", and a 10 MB file is exactly the case the old cap could not answer. A
|
|
13
|
+
* file over the cap is not stored: the record carries `undefined`, and the
|
|
14
|
+
* reader reports the two sides as unknown rather than inventing them.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { mkdir } from 'node:fs/promises';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
|
|
20
|
+
export const MAX_BLOB_BYTES = 32 * 1024 * 1024;
|
|
21
|
+
|
|
22
|
+
export function blobKey(text: string): string {
|
|
23
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
24
|
+
return `${bytes.byteLength.toString(36)}-${Bun.hash(bytes).toString(36)}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Store `text` and return its key; `null` when it exceeds the cap. */
|
|
28
|
+
export async function writeBlob(dir: string, text: string): Promise<string | null> {
|
|
29
|
+
const bytes = Buffer.from(text, 'utf8');
|
|
30
|
+
if (bytes.byteLength > MAX_BLOB_BYTES) return null;
|
|
31
|
+
const key = blobKey(text);
|
|
32
|
+
const file = path.join(dir, key);
|
|
33
|
+
if (await Bun.file(file).exists()) return key;
|
|
34
|
+
await mkdir(dir, { recursive: true, mode: 0o700 });
|
|
35
|
+
await Bun.write(file, Bun.gzipSync(bytes));
|
|
36
|
+
return key;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Blob content for a key; `null` = absent file, `undefined` = not stored/missing. */
|
|
40
|
+
export async function readBlob(
|
|
41
|
+
dir: string,
|
|
42
|
+
key: string | null | undefined,
|
|
43
|
+
): Promise<string | null | undefined> {
|
|
44
|
+
if (key === null) return null;
|
|
45
|
+
if (key === undefined) return undefined;
|
|
46
|
+
try {
|
|
47
|
+
const bytes = await Bun.file(path.join(dir, key)).bytes();
|
|
48
|
+
return new TextDecoder().decode(Bun.gunzipSync(bytes));
|
|
49
|
+
} catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `bash` half of the capture layer: what a shell command changed.
|
|
8
|
+
*
|
|
9
|
+
* Two sources, merged: the script text tokenized at start (which names the
|
|
10
|
+
* redirects the trace does not model) and the trace's `simple` nodes at end
|
|
11
|
+
* (which name the `argv` that actually ran). A rename becomes two records so
|
|
12
|
+
* the existing A/M/D list can render it. An opaque command is reconciled from
|
|
13
|
+
* the two git snapshots, and a command the scan could not cover is a note.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
classifyArgv,
|
|
18
|
+
classifyCommand,
|
|
19
|
+
type CommandMutation,
|
|
20
|
+
} from '@/server/lib/changes/classify-command';
|
|
21
|
+
import type {
|
|
22
|
+
ChangeExtra,
|
|
23
|
+
ChangeSource,
|
|
24
|
+
PendingCall,
|
|
25
|
+
ShellTrace,
|
|
26
|
+
} from '@/server/lib/changes/capture-types';
|
|
27
|
+
import type { GitScan } from '@/server/lib/changes/scan.server';
|
|
28
|
+
import { readSessionChangeLast, readSessionChangePaths } from '@/server/lib/changes/reader.server';
|
|
29
|
+
import { blobKey } from '@/server/lib/changes/blobs.server';
|
|
30
|
+
import { sessionsInCwd } from '@/server/lib/changes/sessions.server';
|
|
31
|
+
|
|
32
|
+
export interface BashCaptureHost {
|
|
33
|
+
sessionId: string;
|
|
34
|
+
cwd: string;
|
|
35
|
+
home: string;
|
|
36
|
+
readFile(absolute: string): Promise<string | null | undefined>;
|
|
37
|
+
statFile(absolute: string): Promise<{ mtimeMs: number; size: number; birthtimeMs: number } | null>;
|
|
38
|
+
takeScan(cwd: string): Promise<GitScan | null>;
|
|
39
|
+
readHead(root: string, absolute: string): Promise<string | null>;
|
|
40
|
+
writeChange(
|
|
41
|
+
pending: PendingCall,
|
|
42
|
+
absolute: string,
|
|
43
|
+
before: string | null | undefined,
|
|
44
|
+
after: string | null | undefined,
|
|
45
|
+
source: ChangeSource,
|
|
46
|
+
extra?: ChangeExtra,
|
|
47
|
+
): Promise<void>;
|
|
48
|
+
note(pending: PendingCall, reason: 'opaque-command' | 'scan-budget', detail?: string): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function captureBashChanges(
|
|
52
|
+
pending: PendingCall,
|
|
53
|
+
trace: ShellTrace | null,
|
|
54
|
+
host: BashCaptureHost,
|
|
55
|
+
): Promise<void> {
|
|
56
|
+
const plan = pending.plan ?? classifyCommand(pending.command ?? '', host.cwd, host.home);
|
|
57
|
+
const mutations = new Map<string, CommandMutation>();
|
|
58
|
+
const remember = (mutation: CommandMutation): void => {
|
|
59
|
+
mutations.set(`${mutation.op}:${mutation.from ?? ''}:${mutation.path}`, mutation);
|
|
60
|
+
};
|
|
61
|
+
for (const mutation of plan.mutations) remember(mutation);
|
|
62
|
+
if (trace) {
|
|
63
|
+
for (const unit of trace.units ?? []) {
|
|
64
|
+
for (const node of unit.nodes ?? []) {
|
|
65
|
+
if (node.k !== 'simple' || !Array.isArray(node.argv) || node.argv.length === 0) continue;
|
|
66
|
+
const argv = node.argv.filter((value): value is string => typeof value === 'string');
|
|
67
|
+
for (const mutation of classifyArgv(argv, host.cwd, host.home).mutations) remember(mutation);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const exit = typeof trace?.status === 'number' ? trace.status : undefined;
|
|
73
|
+
// Paths the trace already handled; the scan must not record them again.
|
|
74
|
+
const written = new Set<string>();
|
|
75
|
+
for (const mutation of mutations.values()) {
|
|
76
|
+
written.add(mutation.path);
|
|
77
|
+
if (mutation.from) written.add(mutation.from);
|
|
78
|
+
if (mutation.op === 'rename' && mutation.from) {
|
|
79
|
+
const fromEntry = pending.before.get(mutation.from);
|
|
80
|
+
const before = fromEntry ? fromEntry.text : null;
|
|
81
|
+
const after = await host.readFile(mutation.path);
|
|
82
|
+
if (before === after) {
|
|
83
|
+
const info = await host.statFile(mutation.path);
|
|
84
|
+
if (info && info.mtimeMs >= pending.startedAt) {
|
|
85
|
+
const created = info.birthtimeMs >= pending.startedAt;
|
|
86
|
+
await host.writeChange(pending, mutation.from, created ? null : undefined, null, 'trace', { command: pending.command, exit, ...(created ? {} : { unavailableReason: 'snapshot-race' }) });
|
|
87
|
+
await host.writeChange(pending, mutation.path, null, after, 'trace', { command: pending.command, exit, from: mutation.from });
|
|
88
|
+
}
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// Two records, so the existing A/M/D list can render a rename.
|
|
92
|
+
await host.writeChange(pending, mutation.from, before, null, 'trace', { command: pending.command, exit });
|
|
93
|
+
await host.writeChange(pending, mutation.path, null, after, 'trace', { command: pending.command, exit, from: mutation.from });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const pathEntry = pending.before.get(mutation.path);
|
|
97
|
+
const before = pathEntry ? pathEntry.text : null;
|
|
98
|
+
const after = await host.readFile(mutation.path);
|
|
99
|
+
if (before === after) {
|
|
100
|
+
// A fast command can finish before the start-frame snapshot reads the
|
|
101
|
+
// file. The mtime proves the command touched it; the birth time says
|
|
102
|
+
// whether it created the file (A) or rewrote an existing one (M).
|
|
103
|
+
const info = await host.statFile(mutation.path);
|
|
104
|
+
if (info && info.mtimeMs >= pending.startedAt) {
|
|
105
|
+
const created = info.birthtimeMs >= pending.startedAt;
|
|
106
|
+
await host.writeChange(
|
|
107
|
+
pending,
|
|
108
|
+
mutation.path,
|
|
109
|
+
created ? null : undefined,
|
|
110
|
+
after,
|
|
111
|
+
'trace',
|
|
112
|
+
created ? { command: pending.command, exit } : { command: pending.command, exit, unavailableReason: 'snapshot-race' },
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
await host.writeChange(pending, mutation.path, before, after, 'trace', { command: pending.command, exit });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (pending.scan) await reconcileScan(pending, pending.scan, host, written);
|
|
121
|
+
if (plan.opaque) await host.note(pending, 'opaque-command', pending.command);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Journal the delta an opaque command made, from the two git snapshots. */
|
|
125
|
+
async function reconcileScan(
|
|
126
|
+
pending: PendingCall,
|
|
127
|
+
start: GitScan,
|
|
128
|
+
host: BashCaptureHost,
|
|
129
|
+
skip: Set<string>,
|
|
130
|
+
): Promise<void> {
|
|
131
|
+
const after = await host.takeScan(host.cwd);
|
|
132
|
+
if (!after) return;
|
|
133
|
+
if (start.truncated || after.truncated) await host.note(pending, 'scan-budget', pending.command);
|
|
134
|
+
|
|
135
|
+
// A concurrent session in the same cwd may have written a path the scan
|
|
136
|
+
// sees. Its own journal is the exact record; skip what it already claimed.
|
|
137
|
+
const from = pending.startedAt - 1000;
|
|
138
|
+
const to = Date.now() + 1000;
|
|
139
|
+
const claimed = new Set<string>();
|
|
140
|
+
for (const sessionId of await sessionsInCwd(host.cwd, host.sessionId)) {
|
|
141
|
+
for (const path of await readSessionChangePaths(sessionId, from, to)) claimed.add(path);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const paths = new Set([...start.dirty.keys(), ...after.dirty.keys()]);
|
|
145
|
+
for (const absolute of paths) {
|
|
146
|
+
if (skip.has(absolute)) continue;
|
|
147
|
+
if (claimed.has(absolute)) continue;
|
|
148
|
+
const before = start.dirty.has(absolute)
|
|
149
|
+
? start.dirty.get(absolute) ?? null
|
|
150
|
+
: await host.readHead(start.root, absolute);
|
|
151
|
+
const afterText = after.dirty.has(absolute)
|
|
152
|
+
? after.dirty.get(absolute) ?? null
|
|
153
|
+
: await host.readFile(absolute);
|
|
154
|
+
if (before === afterText) {
|
|
155
|
+
// A fast command can create the file before the start scan reads the
|
|
156
|
+
// directory, so both snapshots hold the after content. The birth time
|
|
157
|
+
// still proves the command created it.
|
|
158
|
+
const info = await host.statFile(absolute);
|
|
159
|
+
if (info && info.birthtimeMs >= pending.startedAt) {
|
|
160
|
+
await host.writeChange(pending, absolute, null, afterText, 'scan');
|
|
161
|
+
}
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
// A later opaque command's scan sees files an earlier call already
|
|
165
|
+
// recorded. Same content means no new change; skip the duplicate.
|
|
166
|
+
const last = await readSessionChangeLast(host.sessionId, absolute);
|
|
167
|
+
const afterKey = afterText === null || afterText === undefined ? afterText : blobKey(afterText);
|
|
168
|
+
if (last && last.after === afterKey) continue;
|
|
169
|
+
await host.writeChange(pending, absolute, before, afterText, 'scan');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The filesystem half of the capture layer: reading a file, statting it, and
|
|
8
|
+
* the two constants that decide when a tool or a command is worth a note.
|
|
9
|
+
*
|
|
10
|
+
* `displayPathFor` is the one display rule: a path inside the session cwd is
|
|
11
|
+
* shown relative with `/` separators, anything else stays absolute. The chat
|
|
12
|
+
* list and the diff header both read it, so a Windows `src\a.ts` never appears
|
|
13
|
+
* beside a forward-slash path from another producer.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { stat } from 'node:fs/promises';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { isRecord } from '@/shared/lib/util/guards';
|
|
19
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
20
|
+
import type { ShellTrace } from '@/server/lib/changes/capture-types';
|
|
21
|
+
|
|
22
|
+
/** A tool whose name promises a write; only these earn an `unknown-tool` note. */
|
|
23
|
+
export const MUTATING_TOOL = /(edit|write|replace|patch|create|delete|remove|move|rename|apply|insert|append)/i;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An opaque command worth a filesystem snapshot. A test runner is opaque but
|
|
27
|
+
* usually does not rewrite the tree, and scanning on every `bun test` would
|
|
28
|
+
* cost two git processes per run; a reset, an install or a script is the case
|
|
29
|
+
* the scan exists for.
|
|
30
|
+
*/
|
|
31
|
+
export const SCAN_COMMAND = /^(?:git\s+(?:reset|clean|checkout|restore|stash|apply|rebase|merge|pull|cherry-pick|revert)|(?:npm|pnpm|yarn|bun)\s+(?:install|i|add|remove|uninstall)|make|cargo\s+(?:build|run)|go\s+(?:build|run)|(?:sh|bash|zsh|python3?|node)\s)/;
|
|
32
|
+
|
|
33
|
+
export async function defaultReadFile(absolute: string): Promise<string | null> {
|
|
34
|
+
try {
|
|
35
|
+
return await Bun.file(absolute).text();
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function defaultStatFile(absolute: string): Promise<{ mtimeMs: number; size: number; birthtimeMs: number } | null> {
|
|
42
|
+
try {
|
|
43
|
+
const info = await stat(absolute);
|
|
44
|
+
return { mtimeMs: info.mtimeMs, size: info.size, birthtimeMs: info.birthtimeMs };
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** `path` relative to the session cwd when inside it, else unchanged. */
|
|
51
|
+
export function displayPathFor(absolute: string, cwd: string): string {
|
|
52
|
+
const relative = path.relative(cwd, absolute);
|
|
53
|
+
if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) return absolute;
|
|
54
|
+
return relative.replaceAll('\\', '/');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The shell trace on a `bash` result, wherever the transport nested it. */
|
|
58
|
+
export function extractTrace(event: AgentEvent): ShellTrace | null {
|
|
59
|
+
const result = isRecord(event.result) ? event.result : undefined;
|
|
60
|
+
const nested = result && isRecord(result.details) ? result.details : undefined;
|
|
61
|
+
const details = nested ?? (isRecord(event.details) ? event.details : undefined);
|
|
62
|
+
const trace = details && isRecord(details.trace) ? details.trace : undefined;
|
|
63
|
+
return trace ? (trace as ShellTrace) : null;
|
|
64
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Snapshot races: the start-frame read lost to the tool's own write.
|
|
8
|
+
*
|
|
9
|
+
* A `write` whose before snapshot already holds the after content, and a fast
|
|
10
|
+
* `bash` command that finishes before the snapshot reads the file, must not be
|
|
11
|
+
* dropped. The birth time decides create (A) from rewrite (M), and a rewrite
|
|
12
|
+
* with no omp record is an unknown before plus a `snapshot-race` note.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
16
|
+
import * as fsp from 'node:fs/promises';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import { makeCapture, records, REPO } from '@/server/lib/changes/capture-test-util';
|
|
20
|
+
|
|
21
|
+
// The capture journals the host's spelling of the path: a literal `/repo` never
|
|
22
|
+
// matches on Windows.
|
|
23
|
+
const RACE = path.join(REPO, 'race.txt');
|
|
24
|
+
|
|
25
|
+
let dataDir = '';
|
|
26
|
+
let agentDir = '';
|
|
27
|
+
let original: string | undefined;
|
|
28
|
+
let originalAgent: string | undefined;
|
|
29
|
+
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
original = Bun.env.KABMO_DATA_DIR;
|
|
32
|
+
originalAgent = Bun.env.PI_CODING_AGENT_DIR;
|
|
33
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-races-'));
|
|
34
|
+
agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-races-agent-'));
|
|
35
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
36
|
+
Bun.env.PI_CODING_AGENT_DIR = agentDir;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterAll(async () => {
|
|
40
|
+
if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
41
|
+
else Bun.env.KABMO_DATA_DIR = original;
|
|
42
|
+
if (originalAgent === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
43
|
+
else Bun.env.PI_CODING_AGENT_DIR = originalAgent;
|
|
44
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
45
|
+
await fsp.rm(agentDir, { recursive: true, force: true });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('snapshot races', () => {
|
|
49
|
+
test('a write whose snapshot raced is recorded with an unknown before', async () => {
|
|
50
|
+
const files = new Map([[RACE, 'content']]);
|
|
51
|
+
const capture = makeCapture('cap-write-race', files);
|
|
52
|
+
capture.onFrame({
|
|
53
|
+
type: 'tool_execution_start',
|
|
54
|
+
toolCallId: 'c1',
|
|
55
|
+
toolName: 'write',
|
|
56
|
+
args: { path: 'race.txt', content: 'content' },
|
|
57
|
+
});
|
|
58
|
+
await capture.flush();
|
|
59
|
+
// The file already holds the content: the snapshot read the after state.
|
|
60
|
+
capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'write' });
|
|
61
|
+
await capture.flush();
|
|
62
|
+
|
|
63
|
+
const lines = await records('cap-write-race');
|
|
64
|
+
const change = lines.find((line) => line.type === 'change');
|
|
65
|
+
expect(change?.type).toBe('change');
|
|
66
|
+
if (change?.type !== 'change') throw new Error('expected a change');
|
|
67
|
+
expect(change.before).toBeUndefined();
|
|
68
|
+
expect(typeof change.after).toBe('string');
|
|
69
|
+
const note = lines.find((line) => line.type === 'note');
|
|
70
|
+
expect(note?.type).toBe('note');
|
|
71
|
+
if (note?.type !== 'note') throw new Error('expected a note');
|
|
72
|
+
expect(note.reason).toBe('snapshot-race');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('a fast bash create whose snapshot raced is recorded as a create', async () => {
|
|
76
|
+
const files = new Map([[RACE, 'hi\n']]);
|
|
77
|
+
const capture = makeCapture('cap-bash-race', files, {
|
|
78
|
+
statFile: async (absolute) =>
|
|
79
|
+
files.has(absolute)
|
|
80
|
+
? { mtimeMs: Date.now() + 1000, size: files.get(absolute)?.length ?? 0, birthtimeMs: Date.now() + 1000 }
|
|
81
|
+
: null,
|
|
82
|
+
});
|
|
83
|
+
capture.onFrame({
|
|
84
|
+
type: 'tool_execution_start',
|
|
85
|
+
toolCallId: 'c1',
|
|
86
|
+
toolName: 'bash',
|
|
87
|
+
args: { command: 'echo hi > race.txt' },
|
|
88
|
+
});
|
|
89
|
+
await capture.flush();
|
|
90
|
+
capture.onFrame({
|
|
91
|
+
type: 'tool_execution_end',
|
|
92
|
+
toolCallId: 'c1',
|
|
93
|
+
toolName: 'bash',
|
|
94
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['echo', 'hi'], st: 0 }] }] } } },
|
|
95
|
+
});
|
|
96
|
+
await capture.flush();
|
|
97
|
+
|
|
98
|
+
const lines = await records('cap-bash-race');
|
|
99
|
+
const change = lines.find((line) => line.type === 'change');
|
|
100
|
+
expect(change?.type).toBe('change');
|
|
101
|
+
if (change?.type !== 'change') throw new Error('expected a change');
|
|
102
|
+
expect(change.before).toBeNull();
|
|
103
|
+
expect(typeof change.after).toBe('string');
|
|
104
|
+
expect(lines.some((line) => line.type === 'note')).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|