@kabmo-labs/kabmo 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +547 -528
- package/dist/client/static/js/{CsvGrid-xb429wvb.js → CsvGrid-90zfbn7f.js} +1 -1
- package/dist/client/static/js/{DocxView-g58e0bs7.js → DocxView-vwq2rf16.js} +2 -2
- package/dist/client/static/js/{DrawioView-1j66avvy.js → DrawioView-bvx7eqcz.js} +1 -1
- package/dist/client/static/js/{ImageView-kraqkypn.js → ImageView-q6xfmbrq.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-85dhbn62.js → LayoutWrapper-qatdaw3n.js} +2 -2
- package/dist/client/static/js/{Modal-f0nfya07.js → Modal-6jx1fvfb.js} +15 -15
- package/dist/client/static/js/{PdfView-nddkrky9.js → PdfView-tkv2d2zs.js} +1 -1
- package/dist/client/static/js/{SessionsView-a595m6g1.js → SessionsView-rbnecykz.js} +1 -1
- package/dist/client/static/js/{SheetView-s2p4sk6b.js → SheetView-t08g8kdr.js} +1 -1
- package/dist/client/static/js/{SvgPreview-ppdx4yb9.js → SvgPreview-9vh6mdcp.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-5cjzxcaq.js → abnfDiagram-O67JEVCF-bxcn33e1.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-40ggw6e8.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-k41cvjrd.js} +6 -6
- package/dist/client/static/js/c-jkdstn33.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rf9xkmrm.js → c4Diagram-YGBWAQC7-rdcmn6ac.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-zfm2cj2a.js → classDiagram-v2-NBCMYWYE-txbmbkxv.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-fmgpv55e.js → cose-bilkent-JH36ORCC-bxzh3qj1.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-abx5343b.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-w370qmgj.js → dagre-6A5THRUB-baj278kt.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-sfvfjjsy.js → diagram-22UHCM2B-vqvhdc5m.js} +7 -7
- package/dist/client/static/js/{diagram-3UASUU5V-3r2c8s14.js → diagram-3UASUU5V-w328rfx0.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-yathy97a.js → diagram-ATOU4E4O-zzcmwnm8.js} +2 -2
- package/dist/client/static/js/{diagram-CDSNMT55-kk437kxq.js → diagram-CDSNMT55-8yw39mmj.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-qdxfjjhf.js → diagram-MLGK6HIB-zgc386pv.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-dfqeqa1d.js → diagram-MPIPVDR6-efmvvscm.js} +1 -1
- package/dist/client/static/js/{dockerfile-yxrt509r.js → dockerfile-bp5dre33.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s0b0vv4k.js → ebnfDiagram-ZINNZB2B-p66h0dzq.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-g0jjxcqd.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-agjdsm1b.js → erDiagram-OPXOYQCR-39gat96z.js} +4 -4
- package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-z6ywqqc1.js → ganttDiagram-FUAMR5RP-nsjv1zt4.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-r4vnkcy3.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-83ts8zmk.js → index-0kxqzafy.js} +1 -1
- package/dist/client/static/js/{index-kzhtmrh0.js → index-11bdd235.js} +1 -1
- package/dist/client/static/js/{index-we1rpftn.js → index-1qszrvzk.js} +2 -2
- package/dist/client/static/js/{index-21b3zyrd.js → index-24yyj78e.js} +2 -2
- package/dist/client/static/js/{index-nmc30xaz.js → index-2drjp9ks.js} +1 -1
- package/dist/client/static/js/{index-w9zxmev3.js → index-2ndq1ngv.js} +1 -1
- package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
- package/dist/client/static/js/{index-8e0s9p45.js → index-50z4ek83.js} +1 -1
- package/dist/client/static/js/{index-sezz011q.js → index-5ebhb94w.js} +1 -1
- package/dist/client/static/js/{index-302d35e5.js → index-5y0bvq4q.js} +34 -34
- package/dist/client/static/js/{index-jpkj6vqp.js → index-6ax2z70w.js} +1 -1
- package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
- package/dist/client/static/js/{index-09gx6edj.js → index-73jwm4d5.js} +1 -1
- package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
- package/dist/client/static/js/{index-m3j5yx5f.js → index-9wtg6ywn.js} +4 -4
- package/dist/client/static/js/{index-j7r414hf.js → index-a74k07z2.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-cx89yk15.js → index-c15r8jd3.js} +2 -2
- package/dist/client/static/js/{index-49dhv8ry.js → index-da10qpns.js} +2 -2
- package/dist/client/static/js/{index-xearvz2z.js → index-dfgdn3fj.js} +7 -7
- package/dist/client/static/js/{index-0mvcbbmy.js → index-dkseg29t.js} +9 -9
- package/dist/client/static/js/{index-0sqa91wb.js → index-e1pr3k50.js} +2 -2
- package/dist/client/static/js/{index-k06med7d.js → index-fghst0kd.js} +12 -12
- package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
- package/dist/client/static/js/{index-5fn0agag.js → index-gwhx66f4.js} +1 -1
- package/dist/client/static/js/{index-z7qnffwj.js → index-h8h5c2r8.js} +1 -1
- package/dist/client/static/js/{index-qz8mbxm9.js → index-ha75kff0.js} +2 -2
- package/dist/client/static/js/{index-z0frtyje.js → index-hzx81cjq.js} +4 -4
- package/dist/client/static/js/{index-es3pt29g.js → index-k9xsvab3.js} +1 -1
- package/dist/client/static/js/{index-15zn3sns.js → index-nd4p98mc.js} +1 -1
- package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
- package/dist/client/static/js/{index-64mb65wx.js → index-r83kr4s5.js} +2 -2
- package/dist/client/static/js/{index-pd0140dx.js → index-ra38ggke.js} +1 -1
- package/dist/client/static/js/{index-m87yykre.js → index-rf0p3v7q.js} +5 -5
- package/dist/client/static/js/{index-1tyvk778.js → index-rgp69pa8.js} +1 -1
- package/dist/client/static/js/{index-actppd4z.js → index-rqrcw8nj.js} +2 -2
- package/dist/client/static/js/{index-qznwd6g8.js → index-st202rjv.js} +184 -184
- package/dist/client/static/js/{index-6q80csr0.js → index-t5t71dhp.js} +2 -2
- package/dist/client/static/js/{index-ntxm8pw3.js → index-tfsaj5d1.js} +2 -2
- package/dist/client/static/js/{index-059qyaj0.js → index-tv61v3t3.js} +1 -1
- package/dist/client/static/js/index-tzm90bsz.js +1 -0
- package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
- package/dist/client/static/js/{index-t07b31ny.js → index-vnn7m9yp.js} +3 -3
- package/dist/client/static/js/{index-hbtk0c12.js → index-vxd4gykh.js} +2 -2
- package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
- package/dist/client/static/js/{index-7sa2e8mn.js → index-z0cpp5bc.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-58bv28d4.js → infoDiagram-VRGFBTTK-e39pvm4j.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-tz6b0caw.js → ishikawaDiagram-OU5B5YK6-rqhszgvp.js} +2 -2
- package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ydamm17a.js → journeyDiagram-ZHPQQLJL-wgy5qrsv.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-b8bxn0h1.js} +3 -3
- package/dist/client/static/js/lua-86fjqj8v.js +1 -0
- package/dist/client/static/js/{mermaid.core-vty0aq6f.js → mermaid.core-vb5ehtre.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ra4wrts4.js → mindmap-definition-NLK3R4M7-t4p38s38.js} +2 -2
- package/dist/client/static/js/one-dark-pro-dhybn1ff.js +1 -0
- package/dist/client/static/js/one-light-bqg77ay0.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-3gp4madx.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-0cbm773h.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-4mhbag8n.js → quadrantDiagram-O4NWA36T-jwg7fc9f.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-38xh691s.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-jhfhp4eq.js → requirementDiagram-PLB6GJNP-gpddawxh.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-bx3ecv4n.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-qrfxzvp3.js → sankeyDiagram-IPEJSGJF-s6t6bbhk.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-wkq51pmb.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-3hz930jg.js → sizeCapture-INFHLROL-xtwexf8k.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-2m99syxm.js → stateDiagram-v2-GCMORJYK-jnwsqa7y.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-mnkkqcbx.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-a8b7z74e.js → swimlanesDiagram-TC7HE7FX-6xmrz03n.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-765y3ssa.js → timeline-definition-EJHVYXUP-rxq6heqh.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-dz94f57t.js} +13 -13
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-wd51qq26.js → vennDiagram-UO4OBE2U-5mmvkhsq.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-dctdntpa.js} +1 -1
- package/dist/client/static/js/xml-3dd1pter.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-kcz8y04e.js → xychartDiagram-PMCCYNJV-njyfrqkv.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 +106 -0
- package/src/server/lib/changes/capture-fs.server.ts +64 -0
- package/src/server/lib/changes/capture-runs.test.ts +136 -0
- package/src/server/lib/changes/capture-test-util.ts +46 -0
- package/src/server/lib/changes/capture-types.ts +62 -0
- package/src/server/lib/changes/capture.server.ts +333 -0
- package/src/server/lib/changes/capture.test.ts +245 -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 +183 -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/paths.server.ts +37 -0
- package/src/server/lib/changes/purge.server.ts +32 -0
- package/src/server/lib/changes/reader.server.ts +322 -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 +89 -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,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Turn a session's live frames into journal records.
|
|
8
|
+
*
|
|
9
|
+
* Three capture layers, in order of authority:
|
|
10
|
+
*
|
|
11
|
+
* 1. **tool adapter** — `edit`/`write`/`ast_edit`/native edit ops name their
|
|
12
|
+
* path in `args`, so the before/after pair is exact.
|
|
13
|
+
* 2. **shell trace** — a `bash` call's `details.trace` gives one `simple`
|
|
14
|
+
* node per command with `argv` and exit status. The classifier reads it,
|
|
15
|
+
* and the script text (tokenized at start) supplies the redirects the
|
|
16
|
+
* trace does not model.
|
|
17
|
+
* 3. **git scan** — an opaque command (`git reset --hard`, an install, a
|
|
18
|
+
* script) is reconciled from a `git status` snapshot before and after.
|
|
19
|
+
* A command the scan cannot cover is a `note`, never a guess.
|
|
20
|
+
*
|
|
21
|
+
* The before snapshot is taken at `tool_execution_start`, before the tool runs.
|
|
22
|
+
* The frame is emitted by the child before it executes, so the read usually
|
|
23
|
+
* wins; when it does not, an `edit` is reconstructed from `old_string`/
|
|
24
|
+
* `new_string` (the tool's own replacement), and a `write` whose content is
|
|
25
|
+
* already on disk is left alone rather than journaled as a no-op.
|
|
26
|
+
*
|
|
27
|
+
* The trace is read BEFORE the first `await` in `#end`: `EventFanout` strips it
|
|
28
|
+
* from the frame in place right after the raw listeners return.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import path from 'node:path';
|
|
32
|
+
import { isRecord } from '@/shared/lib/util/guards';
|
|
33
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
34
|
+
import { classifyCommand } from '@/server/lib/changes/classify-command';
|
|
35
|
+
import { captureBashChanges, type BashCaptureHost } from '@/server/lib/changes/capture-bash.server';
|
|
36
|
+
import {
|
|
37
|
+
defaultReadFile,
|
|
38
|
+
defaultStatFile,
|
|
39
|
+
displayPathFor,
|
|
40
|
+
extractTrace,
|
|
41
|
+
MUTATING_TOOL,
|
|
42
|
+
SCAN_COMMAND,
|
|
43
|
+
} from '@/server/lib/changes/capture-fs.server';
|
|
44
|
+
import type {
|
|
45
|
+
CaptureDeps,
|
|
46
|
+
ChangeExtra,
|
|
47
|
+
ChangeSource,
|
|
48
|
+
PendingCall,
|
|
49
|
+
ShellTrace,
|
|
50
|
+
} from '@/server/lib/changes/capture-types';
|
|
51
|
+
import { readHeadContent, takeGitScan, type GitScan } from '@/server/lib/changes/scan.server';
|
|
52
|
+
import { MAX_BLOB_BYTES } from '@/server/lib/changes/blobs.server';
|
|
53
|
+
|
|
54
|
+
export class ChangeCapture {
|
|
55
|
+
readonly #pending = new Map<string, PendingCall>();
|
|
56
|
+
readonly #tasks = new Set<Promise<void>>();
|
|
57
|
+
readonly #readFile: (absolute: string) => Promise<string | null>;
|
|
58
|
+
readonly #statFile: (absolute: string) => Promise<{ mtimeMs: number; size: number } | null>;
|
|
59
|
+
readonly #takeScan: (cwd: string) => Promise<GitScan | null>;
|
|
60
|
+
readonly #readHead: (root: string, absolute: string) => Promise<string | null>;
|
|
61
|
+
/** The open run; kept after a terminal end so a late subagent keeps its id. */
|
|
62
|
+
#runId: string | null = null;
|
|
63
|
+
#runAt = 0;
|
|
64
|
+
#runClosed = false;
|
|
65
|
+
|
|
66
|
+
constructor(private readonly deps: CaptureDeps) {
|
|
67
|
+
this.#readFile = deps.readFile ?? defaultReadFile;
|
|
68
|
+
this.#statFile = deps.statFile ?? defaultStatFile;
|
|
69
|
+
this.#takeScan = deps.takeScan ?? takeGitScan;
|
|
70
|
+
this.#readHead = deps.readHead ?? readHeadContent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
onFrame(event: AgentEvent): void {
|
|
74
|
+
switch (event.type) {
|
|
75
|
+
case 'agent_start':
|
|
76
|
+
this.#openRun();
|
|
77
|
+
break;
|
|
78
|
+
case 'agent_end':
|
|
79
|
+
this.#closeRun(event);
|
|
80
|
+
break;
|
|
81
|
+
case 'tool_execution_start':
|
|
82
|
+
this.#track(this.#start(event));
|
|
83
|
+
break;
|
|
84
|
+
case 'tool_execution_end':
|
|
85
|
+
this.#track(this.#end(event));
|
|
86
|
+
break;
|
|
87
|
+
case 'subagent_event':
|
|
88
|
+
this.#subagent(event);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Await every in-flight capture and the journal's own append chain. */
|
|
94
|
+
async flush(): Promise<void> {
|
|
95
|
+
await Promise.all([...this.#tasks]);
|
|
96
|
+
await this.deps.journal.flush();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
#track(task: Promise<void>): void {
|
|
100
|
+
this.#tasks.add(task);
|
|
101
|
+
void task.finally(() => this.#tasks.delete(task));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A new run opens on `agent_start` unless one is already open. A retry or a
|
|
106
|
+
* continuation re-enters `agent_start` without a terminal `agent_end`, and
|
|
107
|
+
* that is the SAME run — a new id there would split one run's files in two.
|
|
108
|
+
*/
|
|
109
|
+
#openRun(): void {
|
|
110
|
+
if (this.#runId !== null && !this.#runClosed) return;
|
|
111
|
+
this.#runId = `r-${Bun.randomUUIDv7()}`;
|
|
112
|
+
this.#runAt = Date.now();
|
|
113
|
+
this.#runClosed = false;
|
|
114
|
+
void this.deps.journal.recordRun({ at: this.#runAt, phase: 'start', runId: this.#runId });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Only a TERMINAL `agent_end` closes the run. omp emits a non-terminal one
|
|
119
|
+
* when an async subagent is still working; closing there would put the
|
|
120
|
+
* subagent's later writes in the next run. The id is deliberately NOT
|
|
121
|
+
* cleared: a change that lands after the end still belongs to this run.
|
|
122
|
+
*/
|
|
123
|
+
#closeRun(event: AgentEvent): void {
|
|
124
|
+
if (event.isTerminal === false) return;
|
|
125
|
+
if (this.#runId === null || this.#runClosed) return;
|
|
126
|
+
this.#runClosed = true;
|
|
127
|
+
void this.deps.journal.recordRun({ at: Date.now(), phase: 'end', runId: this.#runId });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async #start(event: AgentEvent): Promise<void> {
|
|
131
|
+
const toolCallId = typeof event.toolCallId === 'string' ? event.toolCallId : '';
|
|
132
|
+
if (!toolCallId) return;
|
|
133
|
+
const tool = typeof event.toolName === 'string' ? event.toolName : 'unknown';
|
|
134
|
+
const args = isRecord(event.args) ? event.args : {};
|
|
135
|
+
const agent = typeof event.agent === 'string' ? event.agent : 'Main';
|
|
136
|
+
const parent = typeof event.parent === 'string' ? event.parent : undefined;
|
|
137
|
+
const runId = this.#runId ?? undefined;
|
|
138
|
+
const runAt = this.#runId !== null ? this.#runAt : undefined;
|
|
139
|
+
const pending: PendingCall = {
|
|
140
|
+
toolCallId,
|
|
141
|
+
...(runId ? { runId, runAt } : {}),
|
|
142
|
+
tool,
|
|
143
|
+
agent,
|
|
144
|
+
...(parent ? { parent } : {}),
|
|
145
|
+
startedAt: Date.now(),
|
|
146
|
+
args,
|
|
147
|
+
before: new Map(),
|
|
148
|
+
ready: Promise.resolve(),
|
|
149
|
+
};
|
|
150
|
+
this.#pending.set(toolCallId, pending);
|
|
151
|
+
void this.deps.journal.recordCall({
|
|
152
|
+
at: pending.startedAt,
|
|
153
|
+
...(runId ? { runId, runAt } : {}),
|
|
154
|
+
toolCallId,
|
|
155
|
+
agent,
|
|
156
|
+
...(parent ? { parent } : {}),
|
|
157
|
+
tool,
|
|
158
|
+
...(typeof event.intent === 'string' ? { intent: event.intent } : {}),
|
|
159
|
+
args,
|
|
160
|
+
});
|
|
161
|
+
pending.ready = this.#snapshotBefore(pending);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async #snapshotBefore(pending: PendingCall): Promise<void> {
|
|
165
|
+
if (pending.tool === 'bash') {
|
|
166
|
+
const command = typeof pending.args.command === 'string' ? pending.args.command : '';
|
|
167
|
+
pending.command = command;
|
|
168
|
+
pending.plan = classifyCommand(command, this.deps.cwd, this.deps.home);
|
|
169
|
+
if (pending.plan.opaque && SCAN_COMMAND.test(command)) {
|
|
170
|
+
pending.scan = await this.#takeScan(this.deps.cwd);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const absolute of this.#targets(pending)) {
|
|
174
|
+
if (pending.before.has(absolute)) continue;
|
|
175
|
+
const info = await this.#statFile(absolute);
|
|
176
|
+
const text = await this.#readCapped(absolute);
|
|
177
|
+
pending.before.set(absolute, { text, ...(info ? { mtimeMs: info.mtimeMs } : {}) });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#targets(pending: PendingCall): string[] {
|
|
182
|
+
if (pending.tool === 'bash') {
|
|
183
|
+
const paths: string[] = [];
|
|
184
|
+
for (const mutation of pending.plan?.mutations ?? []) {
|
|
185
|
+
paths.push(mutation.path);
|
|
186
|
+
if (mutation.from) paths.push(mutation.from);
|
|
187
|
+
}
|
|
188
|
+
return paths;
|
|
189
|
+
}
|
|
190
|
+
const args = pending.args;
|
|
191
|
+
const raw: unknown[] = [args.path, args.file_path, args.moveTo, args.destination];
|
|
192
|
+
if (Array.isArray(args.paths)) raw.push(...args.paths);
|
|
193
|
+
if (Array.isArray(args.files)) raw.push(...args.files);
|
|
194
|
+
const paths: string[] = [];
|
|
195
|
+
for (const value of raw) {
|
|
196
|
+
if (typeof value !== 'string' || !value || value.includes('://')) continue;
|
|
197
|
+
paths.push(path.isAbsolute(value) ? path.normalize(value) : path.resolve(this.deps.cwd, value));
|
|
198
|
+
}
|
|
199
|
+
return paths;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async #end(event: AgentEvent): Promise<void> {
|
|
203
|
+
const toolCallId = typeof event.toolCallId === 'string' ? event.toolCallId : '';
|
|
204
|
+
if (!toolCallId) return;
|
|
205
|
+
const pending = this.#pending.get(toolCallId);
|
|
206
|
+
if (!pending) return;
|
|
207
|
+
this.#pending.delete(toolCallId);
|
|
208
|
+
// Read the trace BEFORE the first await: `EventFanout` strips it from the
|
|
209
|
+
// frame in place right after the raw listeners return, and this function
|
|
210
|
+
// resumes later.
|
|
211
|
+
const trace = extractTrace(event);
|
|
212
|
+
await pending.ready;
|
|
213
|
+
if (pending.tool === 'bash') await this.#endBash(pending, trace);
|
|
214
|
+
else await this.#endFileTool(pending);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async #endFileTool(pending: PendingCall): Promise<void> {
|
|
218
|
+
const targets = this.#targets(pending);
|
|
219
|
+
if (targets.length === 0) {
|
|
220
|
+
// A read-only tool (`read`, `glob`, `grep`) has no adapter and no
|
|
221
|
+
// mutation; only a tool whose NAME promises a write is worth a note.
|
|
222
|
+
if (MUTATING_TOOL.test(pending.tool)) {
|
|
223
|
+
await this.deps.journal.recordNote({
|
|
224
|
+
at: Date.now(),
|
|
225
|
+
...(pending.runId ? { runId: pending.runId, runAt: pending.runAt } : {}),
|
|
226
|
+
toolCallId: pending.toolCallId,
|
|
227
|
+
reason: 'unknown-tool',
|
|
228
|
+
detail: pending.tool,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
for (const absolute of targets) {
|
|
234
|
+
const entry = pending.before.get(absolute);
|
|
235
|
+
const before = entry ? entry.text : null;
|
|
236
|
+
const after = await this.#readCapped(absolute);
|
|
237
|
+
if (before === after) {
|
|
238
|
+
const reconstructed = this.#reconstructEdit(pending, after);
|
|
239
|
+
if (reconstructed === null) continue;
|
|
240
|
+
await this.#writeChange(pending, absolute, reconstructed, after, 'tool');
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
await this.#writeChange(pending, absolute, before, after, 'tool');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Read a file unless it is over the blob cap; `undefined` means not stored. */
|
|
248
|
+
async #readCapped(absolute: string): Promise<string | null | undefined> {
|
|
249
|
+
const info = await this.#statFile(absolute);
|
|
250
|
+
if (info && info.size > MAX_BLOB_BYTES) return undefined;
|
|
251
|
+
return this.#readFile(absolute);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** The before side of an `edit` whose write landed before the snapshot. */
|
|
255
|
+
#reconstructEdit(pending: PendingCall, after: string | null | undefined): string | null {
|
|
256
|
+
if (after === null || after === undefined) return null;
|
|
257
|
+
const oldString = pending.args.old_string;
|
|
258
|
+
const newString = pending.args.new_string;
|
|
259
|
+
if (typeof oldString !== 'string' || typeof newString !== 'string' || !newString) return null;
|
|
260
|
+
if (!after.includes(newString)) return null;
|
|
261
|
+
return after.replace(newString, oldString);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async #endBash(pending: PendingCall, trace: ShellTrace | null): Promise<void> {
|
|
265
|
+
const host: BashCaptureHost = {
|
|
266
|
+
cwd: this.deps.cwd,
|
|
267
|
+
home: this.deps.home,
|
|
268
|
+
readFile: (absolute) => this.#readCapped(absolute),
|
|
269
|
+
takeScan: this.#takeScan,
|
|
270
|
+
readHead: this.#readHead,
|
|
271
|
+
writeChange: (call, absolute, before, after, source, extra) =>
|
|
272
|
+
this.#writeChange(call, absolute, before, after, source, extra),
|
|
273
|
+
note: (call, reason, detail) =>
|
|
274
|
+
this.deps.journal.recordNote({
|
|
275
|
+
at: Date.now(),
|
|
276
|
+
...(call.runId ? { runId: call.runId, runAt: call.runAt } : {}),
|
|
277
|
+
toolCallId: call.toolCallId,
|
|
278
|
+
reason,
|
|
279
|
+
...(detail ? { detail } : {}),
|
|
280
|
+
}),
|
|
281
|
+
};
|
|
282
|
+
await captureBashChanges(pending, trace, host);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async #writeChange(
|
|
286
|
+
pending: PendingCall,
|
|
287
|
+
absolute: string,
|
|
288
|
+
before: string | null | undefined,
|
|
289
|
+
after: string | null | undefined,
|
|
290
|
+
source: ChangeSource,
|
|
291
|
+
extra: ChangeExtra = {},
|
|
292
|
+
): Promise<void> {
|
|
293
|
+
// Two unknown sides are not proof of no change; only two known equal sides are.
|
|
294
|
+
if (before === after && before !== undefined) return;
|
|
295
|
+
const op = before === null ? 'create' : after === null ? 'delete' : 'update';
|
|
296
|
+
const beforeInfo = pending.before.get(absolute);
|
|
297
|
+
const afterInfo = await this.#statFile(absolute);
|
|
298
|
+
await this.deps.journal.recordChange({
|
|
299
|
+
at: Date.now(),
|
|
300
|
+
...(pending.runId ? { runId: pending.runId, runAt: pending.runAt } : {}),
|
|
301
|
+
toolCallId: pending.toolCallId,
|
|
302
|
+
agent: pending.agent,
|
|
303
|
+
...(pending.parent ? { parent: pending.parent } : {}),
|
|
304
|
+
tool: pending.tool,
|
|
305
|
+
op,
|
|
306
|
+
path: absolute,
|
|
307
|
+
...(extra.from ? { from: extra.from } : {}),
|
|
308
|
+
displayPath: displayPathFor(absolute, this.deps.cwd),
|
|
309
|
+
before,
|
|
310
|
+
after,
|
|
311
|
+
...(beforeInfo?.mtimeMs !== undefined ? { beforeMtimeMs: beforeInfo.mtimeMs } : {}),
|
|
312
|
+
...(afterInfo ? { afterMtimeMs: afterInfo.mtimeMs } : {}),
|
|
313
|
+
source,
|
|
314
|
+
...(extra.command ? { command: extra.command } : {}),
|
|
315
|
+
...(extra.exit !== undefined ? { exit: extra.exit } : {}),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
#subagent(event: AgentEvent): void {
|
|
320
|
+
const payload = event.payload;
|
|
321
|
+
if (!isRecord(payload)) return;
|
|
322
|
+
const frame = isRecord(payload.data) && typeof payload.data.type === 'string' ? payload.data : payload;
|
|
323
|
+
const type = frame.type;
|
|
324
|
+
if (type !== 'tool_execution_start' && type !== 'tool_execution_end') return;
|
|
325
|
+
const agent = typeof payload.agent === 'string'
|
|
326
|
+
? payload.agent
|
|
327
|
+
: typeof payload.subagentId === 'string'
|
|
328
|
+
? payload.subagentId
|
|
329
|
+
: 'Subagent';
|
|
330
|
+
const parent = typeof payload.parent === 'string' ? payload.parent : undefined;
|
|
331
|
+
this.onFrame({ ...frame, type, agent, ...(parent ? { parent } : {}) });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The capture layer: a tool call's frames become journal records.
|
|
8
|
+
*
|
|
9
|
+
* The cases are the ones the feature exists for — an `edit`, a `write`, a
|
|
10
|
+
* `bash rm`, a `sed -i`, a redirect — plus the two honest failures: an opaque
|
|
11
|
+
* command is a `note`, and a subagent's write is attributed to the child.
|
|
12
|
+
*
|
|
13
|
+
* The fake filesystem is a `Map`, so the before/after pair is deterministic:
|
|
14
|
+
* `flush()` after the start frame proves the snapshot ran before the test
|
|
15
|
+
* changes the file. Every path goes through `at()`, so the fixture is native
|
|
16
|
+
* on Windows too.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
20
|
+
import * as fsp from 'node:fs/promises';
|
|
21
|
+
import * as os from 'node:os';
|
|
22
|
+
import * as path from 'node:path';
|
|
23
|
+
import { makeCapture, records, REPO } from '@/server/lib/changes/capture-test-util';
|
|
24
|
+
import { readSessionChangeDiff } from '@/server/lib/changes/reader.server';
|
|
25
|
+
|
|
26
|
+
let dataDir = '';
|
|
27
|
+
let original: string | undefined;
|
|
28
|
+
|
|
29
|
+
beforeAll(async () => {
|
|
30
|
+
original = Bun.env.KABMO_DATA_DIR;
|
|
31
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-capture-'));
|
|
32
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterAll(async () => {
|
|
36
|
+
if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
37
|
+
else Bun.env.KABMO_DATA_DIR = original;
|
|
38
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const WINDOW_END = Date.now() + 60_000;
|
|
42
|
+
|
|
43
|
+
/** A path inside the fixture repo, spelled the way the host spells it. */
|
|
44
|
+
function at(relative: string): string {
|
|
45
|
+
return path.join(REPO, relative);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe('tool adapters', () => {
|
|
49
|
+
test('edit records the before and after text', async () => {
|
|
50
|
+
const files = new Map([[at('a.ts'), 'old']]);
|
|
51
|
+
const capture = makeCapture('cap-edit', files);
|
|
52
|
+
capture.onFrame({
|
|
53
|
+
type: 'tool_execution_start',
|
|
54
|
+
toolCallId: 'c1',
|
|
55
|
+
toolName: 'edit',
|
|
56
|
+
args: { path: 'a.ts', old_string: 'old', new_string: 'new' },
|
|
57
|
+
});
|
|
58
|
+
await capture.flush();
|
|
59
|
+
files.set(at('a.ts'), 'new');
|
|
60
|
+
capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'edit' });
|
|
61
|
+
await capture.flush();
|
|
62
|
+
|
|
63
|
+
const diff = await readSessionChangeDiff('cap-edit', at('a.ts'), 0, WINDOW_END);
|
|
64
|
+
expect(diff?.status).toBe('modified');
|
|
65
|
+
expect(diff?.oldContent).toBe('old');
|
|
66
|
+
expect(diff?.newContent).toBe('new');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('write of a new file is a create', async () => {
|
|
70
|
+
const files = new Map<string, string>();
|
|
71
|
+
const capture = makeCapture('cap-write', files);
|
|
72
|
+
capture.onFrame({
|
|
73
|
+
type: 'tool_execution_start',
|
|
74
|
+
toolCallId: 'c1',
|
|
75
|
+
toolName: 'write',
|
|
76
|
+
args: { path: 'b.ts', content: 'B' },
|
|
77
|
+
});
|
|
78
|
+
await capture.flush();
|
|
79
|
+
files.set(at('b.ts'), 'B');
|
|
80
|
+
capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'write' });
|
|
81
|
+
await capture.flush();
|
|
82
|
+
|
|
83
|
+
const diff = await readSessionChangeDiff('cap-write', at('b.ts'), 0, WINDOW_END);
|
|
84
|
+
expect(diff?.status).toBe('added');
|
|
85
|
+
expect(diff?.newContent).toBe('B');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('bash capture', () => {
|
|
90
|
+
test('rm is a delete, from the trace argv', async () => {
|
|
91
|
+
const files = new Map([[at('c.ts'), 'C']]);
|
|
92
|
+
const capture = makeCapture('cap-rm', files);
|
|
93
|
+
capture.onFrame({
|
|
94
|
+
type: 'tool_execution_start',
|
|
95
|
+
toolCallId: 'c1',
|
|
96
|
+
toolName: 'bash',
|
|
97
|
+
args: { command: 'rm -f c.ts' },
|
|
98
|
+
});
|
|
99
|
+
await capture.flush();
|
|
100
|
+
files.delete(at('c.ts'));
|
|
101
|
+
capture.onFrame({
|
|
102
|
+
type: 'tool_execution_end',
|
|
103
|
+
toolCallId: 'c1',
|
|
104
|
+
toolName: 'bash',
|
|
105
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['rm', '-f', 'c.ts'], st: 0 }] }] } } },
|
|
106
|
+
});
|
|
107
|
+
await capture.flush();
|
|
108
|
+
|
|
109
|
+
const diff = await readSessionChangeDiff('cap-rm', at('c.ts'), 0, WINDOW_END);
|
|
110
|
+
expect(diff?.status).toBe('deleted');
|
|
111
|
+
expect(diff?.oldContent).toBe('C');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('sed -i is an update', async () => {
|
|
115
|
+
const files = new Map([[at('d.ts'), 'a']]);
|
|
116
|
+
const capture = makeCapture('cap-sed', files);
|
|
117
|
+
capture.onFrame({
|
|
118
|
+
type: 'tool_execution_start',
|
|
119
|
+
toolCallId: 'c1',
|
|
120
|
+
toolName: 'bash',
|
|
121
|
+
args: { command: "sed -i 's/a/b/' d.ts" },
|
|
122
|
+
});
|
|
123
|
+
await capture.flush();
|
|
124
|
+
files.set(at('d.ts'), 'b');
|
|
125
|
+
capture.onFrame({
|
|
126
|
+
type: 'tool_execution_end',
|
|
127
|
+
toolCallId: 'c1',
|
|
128
|
+
toolName: 'bash',
|
|
129
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['sed', '-i', 's/a/b/', 'd.ts'], st: 0 }] }] } } },
|
|
130
|
+
});
|
|
131
|
+
await capture.flush();
|
|
132
|
+
|
|
133
|
+
const diff = await readSessionChangeDiff('cap-sed', at('d.ts'), 0, WINDOW_END);
|
|
134
|
+
expect(diff?.status).toBe('modified');
|
|
135
|
+
expect(diff?.oldContent).toBe('a');
|
|
136
|
+
expect(diff?.newContent).toBe('b');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('a redirect is a create the trace does not name', async () => {
|
|
140
|
+
const files = new Map<string, string>();
|
|
141
|
+
const capture = makeCapture('cap-redirect', files);
|
|
142
|
+
capture.onFrame({
|
|
143
|
+
type: 'tool_execution_start',
|
|
144
|
+
toolCallId: 'c1',
|
|
145
|
+
toolName: 'bash',
|
|
146
|
+
args: { command: 'echo hi > e.txt' },
|
|
147
|
+
});
|
|
148
|
+
await capture.flush();
|
|
149
|
+
files.set(at('e.txt'), 'hi\n');
|
|
150
|
+
capture.onFrame({
|
|
151
|
+
type: 'tool_execution_end',
|
|
152
|
+
toolCallId: 'c1',
|
|
153
|
+
toolName: 'bash',
|
|
154
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['echo', 'hi'], st: 0 }] }] } } },
|
|
155
|
+
});
|
|
156
|
+
await capture.flush();
|
|
157
|
+
|
|
158
|
+
const diff = await readSessionChangeDiff('cap-redirect', at('e.txt'), 0, WINDOW_END);
|
|
159
|
+
expect(diff?.status).toBe('added');
|
|
160
|
+
expect(diff?.newContent).toBe('hi\n');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('an opaque command is a note, not a guess', async () => {
|
|
164
|
+
const files = new Map<string, string>();
|
|
165
|
+
const capture = makeCapture('cap-opaque', files);
|
|
166
|
+
capture.onFrame({
|
|
167
|
+
type: 'tool_execution_start',
|
|
168
|
+
toolCallId: 'c1',
|
|
169
|
+
toolName: 'bash',
|
|
170
|
+
args: { command: 'bun test' },
|
|
171
|
+
});
|
|
172
|
+
await capture.flush();
|
|
173
|
+
capture.onFrame({
|
|
174
|
+
type: 'tool_execution_end',
|
|
175
|
+
toolCallId: 'c1',
|
|
176
|
+
toolName: 'bash',
|
|
177
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['bun', 'test'], st: 0 }] }] } } },
|
|
178
|
+
});
|
|
179
|
+
await capture.flush();
|
|
180
|
+
|
|
181
|
+
const lines = await records('cap-opaque');
|
|
182
|
+
expect(lines.some((line) => line.type === 'change')).toBe(false);
|
|
183
|
+
const note = lines.find((line) => line.type === 'note');
|
|
184
|
+
expect(note?.type).toBe('note');
|
|
185
|
+
if (note?.type !== 'note') throw new Error('expected a note');
|
|
186
|
+
expect(note.reason).toBe('opaque-command');
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('scan pass', () => {
|
|
191
|
+
test('an opaque git reset is reconciled from the two snapshots', async () => {
|
|
192
|
+
const files = new Map([[at('g.ts'), 'old']]);
|
|
193
|
+
const scans = [
|
|
194
|
+
{ root: REPO, dirty: new Map([[at('g.ts'), 'old']]), truncated: false },
|
|
195
|
+
{ root: REPO, dirty: new Map([[at('g.ts'), 'new']]), truncated: false },
|
|
196
|
+
];
|
|
197
|
+
const capture = makeCapture('cap-scan', files, {
|
|
198
|
+
takeScan: async () => scans.shift() ?? null,
|
|
199
|
+
readHead: async () => null,
|
|
200
|
+
});
|
|
201
|
+
capture.onFrame({
|
|
202
|
+
type: 'tool_execution_start',
|
|
203
|
+
toolCallId: 'c1',
|
|
204
|
+
toolName: 'bash',
|
|
205
|
+
args: { command: 'git reset --hard' },
|
|
206
|
+
});
|
|
207
|
+
await capture.flush();
|
|
208
|
+
files.set(at('g.ts'), 'new');
|
|
209
|
+
capture.onFrame({
|
|
210
|
+
type: 'tool_execution_end',
|
|
211
|
+
toolCallId: 'c1',
|
|
212
|
+
toolName: 'bash',
|
|
213
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['git', 'reset', '--hard'], st: 0 }] }] } } },
|
|
214
|
+
});
|
|
215
|
+
await capture.flush();
|
|
216
|
+
|
|
217
|
+
const diff = await readSessionChangeDiff('cap-scan', at('g.ts'), 0, WINDOW_END);
|
|
218
|
+
expect(diff?.status).toBe('modified');
|
|
219
|
+
expect(diff?.oldContent).toBe('old');
|
|
220
|
+
expect(diff?.newContent).toBe('new');
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
describe('subagents', () => {
|
|
225
|
+
test('a child edit is attributed to the child', async () => {
|
|
226
|
+
const files = new Map([[at('f.ts'), 'old']]);
|
|
227
|
+
const capture = makeCapture('cap-sub', files);
|
|
228
|
+
capture.onFrame({
|
|
229
|
+
type: 'subagent_event',
|
|
230
|
+
payload: { type: 'tool_execution_start', toolCallId: 's1', toolName: 'edit', args: { path: 'f.ts' }, agent: 'Child' },
|
|
231
|
+
});
|
|
232
|
+
await capture.flush();
|
|
233
|
+
files.set(at('f.ts'), 'new');
|
|
234
|
+
capture.onFrame({
|
|
235
|
+
type: 'subagent_event',
|
|
236
|
+
payload: { type: 'tool_execution_end', toolCallId: 's1', toolName: 'edit', agent: 'Child' },
|
|
237
|
+
});
|
|
238
|
+
await capture.flush();
|
|
239
|
+
|
|
240
|
+
const change = (await records('cap-sub')).find((line) => line.type === 'change');
|
|
241
|
+
expect(change?.type).toBe('change');
|
|
242
|
+
if (change?.type !== 'change') throw new Error('expected a change');
|
|
243
|
+
expect(change.agent).toBe('Child');
|
|
244
|
+
});
|
|
245
|
+
});
|