@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
|
@@ -23,11 +23,15 @@
|
|
|
23
23
|
* answers"), leaving the run parked.
|
|
24
24
|
*
|
|
25
25
|
* The claim walks two keys, because omp gives the frame less than the tool call
|
|
26
|
-
* does: the question
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
26
|
+
* does: the question TEXT (what omp's own per-question loop matches on, with a
|
|
27
|
+
* context prefix and a decorated suffix both accepted) and the offered ROWS.
|
|
28
|
+
* A frame that names a question of an ask we know but no OPEN card owns is an
|
|
29
|
+
* inline orphan, never a modal. A field frame that matches neither key is still
|
|
30
|
+
* owned by the only open ask when its title shares a content word with one of
|
|
31
|
+
* that ask's questions — omp's ask tool is exclusive, so nothing else can be
|
|
32
|
+
* asking, and this is what keeps a parser-drift question on the timeline.
|
|
33
|
+
* Everything that matches nothing ask-shaped (a ratchet approval, an extension
|
|
34
|
+
* picker) keeps the modal.
|
|
31
35
|
*
|
|
32
36
|
* The modal is also held until the session's own history has loaded. Ownership
|
|
33
37
|
* is decided against the ask tool calls in `messages`, and on session open the
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
import { createContext, useContext } from 'preact/compat';
|
|
43
47
|
import type { ChatMessageData } from '@/shared/types';
|
|
44
48
|
import type { ExtensionUiDialogRequest } from '@/shared/types/omp/agent';
|
|
45
|
-
import { askQuestionForOptions, askQuestionForTitle, groupAskFrames, isAskSettled, isAskToolCall, normalizeAskText, parseAskQuestions } from '@/shared/lib/chat/ask-questions';
|
|
49
|
+
import { askQuestionForFrame, askQuestionForOptions, askQuestionForTitle, askQuestionSharesText, groupAskFrames, isAskSettled, isAskToolCall, normalizeAskText, parseAskQuestions } from '@/shared/lib/chat/ask-questions';
|
|
46
50
|
import { parseAskResult } from '@/shared/lib/chat/ask-results';
|
|
47
51
|
import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
48
52
|
import { isApprovalGateFrame } from '@/shared/lib/chat/omp/approval-gate';
|
|
@@ -51,6 +55,13 @@ import type { ExtensionDialogResponse } from '@/client/components/workspace/chat
|
|
|
51
55
|
export interface AskFramesSplit {
|
|
52
56
|
/** The ask's dialogs, bucketed per question, keyed by ask tool-call id. */
|
|
53
57
|
framesByTool: Map<string, ExtensionUiDialogRequest[][]>;
|
|
58
|
+
/**
|
|
59
|
+
* Field dialogs that belong to an open ask but matched no question, keyed by
|
|
60
|
+
* tool id. A form parser can drift from omp's on a shape neither was written
|
|
61
|
+
* for; the frame must still be answerable on the card, and the modal has no
|
|
62
|
+
* field body. The card draws these last, as the live control.
|
|
63
|
+
*/
|
|
64
|
+
looseByTool: Map<string, ExtensionUiDialogRequest[]>;
|
|
54
65
|
/** Ask dialogs no card can own — the timeline draws them inline. */
|
|
55
66
|
orphanAsks: ExtensionUiDialogRequest[];
|
|
56
67
|
/** Oldest non-ask request nothing claimed — the one the modal renders. */
|
|
@@ -59,13 +70,15 @@ export interface AskFramesSplit {
|
|
|
59
70
|
|
|
60
71
|
export interface AskFramesHandle {
|
|
61
72
|
framesByTool: AskFramesSplit['framesByTool'];
|
|
73
|
+
/** Ask field dialogs a card owns but no question matched (see `looseByTool`). */
|
|
74
|
+
looseByTool: AskFramesSplit['looseByTool'];
|
|
62
75
|
/** Ask dialogs with no tool card to render them (see `orphanAsks`). */
|
|
63
76
|
orphanAsks: AskFramesSplit['orphanAsks'];
|
|
64
77
|
/** Answer one ask dialog and drop it from the pending queue. */
|
|
65
78
|
respond: (request: ExtensionUiDialogRequest, response: ExtensionDialogResponse) => void;
|
|
66
79
|
}
|
|
67
80
|
|
|
68
|
-
const EMPTY: AskFramesHandle = { framesByTool: new Map(), orphanAsks: [], respond: () => {} };
|
|
81
|
+
const EMPTY: AskFramesHandle = { framesByTool: new Map(), looseByTool: new Map(), orphanAsks: [], respond: () => {} };
|
|
69
82
|
|
|
70
83
|
export const AskFramesContext = createContext<AskFramesHandle>(EMPTY);
|
|
71
84
|
|
|
@@ -82,7 +95,8 @@ export function splitAskFrames(
|
|
|
82
95
|
historyLoaded: boolean,
|
|
83
96
|
): AskFramesSplit {
|
|
84
97
|
const framesByTool = new Map<string, ExtensionUiDialogRequest[][]>();
|
|
85
|
-
|
|
98
|
+
const looseByTool = new Map<string, ExtensionUiDialogRequest[]>();
|
|
99
|
+
if (pending.length === 0) return { framesByTool, looseByTool, orphanAsks: [], modalRequest: null };
|
|
86
100
|
|
|
87
101
|
// Match against the asks that can still own a dialog: a reloaded session
|
|
88
102
|
// reads its tool calls back from the JSONL, where a call still parked on a
|
|
@@ -97,21 +111,29 @@ export function splitAskFrames(
|
|
|
97
111
|
// therefore not a candidate at all. A parked call read back from the JSONL is
|
|
98
112
|
// neither: omp writes no result until the question is answered.
|
|
99
113
|
const openAsks: { toolId: string; questions: AskQuestion[] }[] = [];
|
|
114
|
+
// Every ask, settled ones included: a dialog whose call just failed is still
|
|
115
|
+
// the ask's dialog, so it belongs on the timeline (an inline orphan), never
|
|
116
|
+
// in the modal. Keeping them apart from `openAsks` is what lets ownership
|
|
117
|
+
// prefer the live call while recognition still avoids the modal.
|
|
118
|
+
const allAsks: { toolId: string; questions: AskQuestion[] }[] = [];
|
|
100
119
|
for (const message of messages) {
|
|
101
120
|
for (const tool of message.toolCalls ?? []) {
|
|
102
121
|
if (!isAskToolCall(tool)) continue;
|
|
103
|
-
if (isAskSettled(tool)) continue;
|
|
104
122
|
const questions = parseAskQuestions(tool);
|
|
105
123
|
if (questions.length === 0) continue;
|
|
124
|
+
allAsks.push({ toolId: tool.id, questions });
|
|
125
|
+
if (isAskSettled(tool)) continue;
|
|
106
126
|
if (parseAskResult(tool, questions).every((answer) => answer !== null)) continue;
|
|
107
127
|
openAsks.push({ toolId: tool.id, questions });
|
|
108
128
|
}
|
|
109
129
|
}
|
|
110
130
|
|
|
111
131
|
const owned = new Map<string, ExtensionUiDialogRequest[]>();
|
|
112
|
-
const
|
|
132
|
+
const handled = new Set<ExtensionUiDialogRequest>();
|
|
113
133
|
/** Frames claimed by their option rows, with the question index they name. */
|
|
114
134
|
const optionPlacements = new Map<ExtensionUiDialogRequest, number>();
|
|
135
|
+
/** Owned frames whose title and rows both missed — drawn as the live control. */
|
|
136
|
+
const unplaced = new Map<string, ExtensionUiDialogRequest[]>();
|
|
115
137
|
const orphanAsks: ExtensionUiDialogRequest[] = [];
|
|
116
138
|
let lastOwner: string | null = null;
|
|
117
139
|
|
|
@@ -150,7 +172,7 @@ export function splitAskFrames(
|
|
|
150
172
|
);
|
|
151
173
|
}
|
|
152
174
|
if (groupedOwner) {
|
|
153
|
-
|
|
175
|
+
handled.add(request);
|
|
154
176
|
lastOwner = groupedOwner.toolId;
|
|
155
177
|
owned.set(groupedOwner.toolId, [...(owned.get(groupedOwner.toolId) ?? []), request]);
|
|
156
178
|
}
|
|
@@ -165,11 +187,15 @@ export function splitAskFrames(
|
|
|
165
187
|
// lands, so drawing it now would paint the question at the tail of the
|
|
166
188
|
// timeline and then move it onto its card. The frame stays queued, so
|
|
167
189
|
// nothing is lost — the split simply re-runs.
|
|
168
|
-
if (!groupedOwner && historyLoaded)
|
|
190
|
+
if (!groupedOwner && historyLoaded) {
|
|
191
|
+
orphanAsks.push(request);
|
|
192
|
+
handled.add(request);
|
|
193
|
+
}
|
|
169
194
|
continue;
|
|
170
195
|
}
|
|
171
196
|
|
|
172
197
|
let owner: string | null = null;
|
|
198
|
+
let titleMatched = false;
|
|
173
199
|
if (typeof request.title === 'string' && request.title) {
|
|
174
200
|
// Newest first: omp asks one question at a time and blocks on it, so when
|
|
175
201
|
// two live calls name the same question the later one is the one in
|
|
@@ -178,6 +204,7 @@ export function splitAskFrames(
|
|
|
178
204
|
const candidate = openAsks[index];
|
|
179
205
|
if (askQuestionForTitle(candidate.questions, request.title) !== -1) {
|
|
180
206
|
owner = candidate.toolId;
|
|
207
|
+
titleMatched = true;
|
|
181
208
|
break;
|
|
182
209
|
}
|
|
183
210
|
}
|
|
@@ -197,25 +224,64 @@ export function splitAskFrames(
|
|
|
197
224
|
// are the question's rows: the two parsers can disagree on a form shape
|
|
198
225
|
// neither was written for, and the title is the only key that drifts. The
|
|
199
226
|
// option list is the same list either way, so it is the fallback key — and
|
|
200
|
-
// an exact set match
|
|
201
|
-
// picker or a gate.
|
|
227
|
+
// an exact set match cannot steal an extension picker or a gate.
|
|
202
228
|
if (!owner && request.method === 'select' && !isApprovalGateFrame(request)) {
|
|
203
229
|
for (let index = openAsks.length - 1; index >= 0; index -= 1) {
|
|
204
230
|
const candidate = openAsks[index];
|
|
205
231
|
const matched = askQuestionForOptions(candidate.questions, request.options);
|
|
206
232
|
if (matched === -1) continue;
|
|
207
233
|
owner = candidate.toolId;
|
|
208
|
-
// The title walk already
|
|
209
|
-
// by its rows has no title to place by, so its row is
|
|
234
|
+
// The title walk already places a title match in `groupAskFrames`; a
|
|
235
|
+
// frame claimed by its rows has no title to place by, so its row is
|
|
236
|
+
// recorded here.
|
|
210
237
|
optionPlacements.set(request, matched);
|
|
211
238
|
break;
|
|
212
239
|
}
|
|
213
240
|
}
|
|
214
|
-
if (!owner && request.method !== 'confirm' && !isApprovalGateFrame(request))
|
|
241
|
+
if (!owner && request.method !== 'confirm' && !isApprovalGateFrame(request)) {
|
|
242
|
+
// The frame names a question of an ask this client knows, but that ask is
|
|
243
|
+
// not a live owner (it failed, was aborted, or already has every answer).
|
|
244
|
+
// It is still an ask dialog: show it inline and leave the modal to
|
|
245
|
+
// extension pickers, which have no card.
|
|
246
|
+
const knownAsk = [...allAsks].reverse().some(
|
|
247
|
+
(candidate) => askQuestionForFrame(candidate.questions, request) !== -1,
|
|
248
|
+
);
|
|
249
|
+
if (knownAsk) {
|
|
250
|
+
if (historyLoaded) {
|
|
251
|
+
orphanAsks.push(request);
|
|
252
|
+
handled.add(request);
|
|
253
|
+
}
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
// A continuation of the ask that spoke last (the free-text dialog opened
|
|
257
|
+
// by an "Other" row) can arrive with a decorated title that names nothing.
|
|
258
|
+
// An approval gate is never part of an ask, so it keeps its own modal.
|
|
259
|
+
if (lastOwner && openAsks.some((candidate) => candidate.toolId === lastOwner)) {
|
|
260
|
+
owner = lastOwner;
|
|
261
|
+
} else if (
|
|
262
|
+
openAsks.length === 1 &&
|
|
263
|
+
request.secret !== true &&
|
|
264
|
+
(request.method === 'select' || request.method === 'input' || request.method === 'editor') &&
|
|
265
|
+
askQuestionSharesText(openAsks[0].questions, request.title)
|
|
266
|
+
) {
|
|
267
|
+
// The ask tool is EXCLUSIVE: while it blocks on a field, no extension
|
|
268
|
+
// tool can raise a dialog of its own. A single open ask therefore owns
|
|
269
|
+
// an unclaimed field dialog whose title still shares a content word
|
|
270
|
+
// with one of its questions — this is the guarantee that a question
|
|
271
|
+
// whose derived text drifted can never open as a modal. A dialog with
|
|
272
|
+
// no shared word is someone else's (an extension picker) and keeps the
|
|
273
|
+
// modal.
|
|
274
|
+
owner = openAsks[0].toolId;
|
|
275
|
+
}
|
|
276
|
+
if (!owner) continue;
|
|
277
|
+
}
|
|
215
278
|
if (!owner) continue;
|
|
216
|
-
|
|
279
|
+
handled.add(request);
|
|
217
280
|
lastOwner = owner;
|
|
218
281
|
owned.set(owner, [...(owned.get(owner) ?? []), request]);
|
|
282
|
+
if (!titleMatched && !optionPlacements.has(request)) {
|
|
283
|
+
unplaced.set(owner, [...(unplaced.get(owner) ?? []), request]);
|
|
284
|
+
}
|
|
219
285
|
}
|
|
220
286
|
|
|
221
287
|
for (const [toolId, frames] of owned) {
|
|
@@ -224,6 +290,7 @@ export function splitAskFrames(
|
|
|
224
290
|
// on each question it names rather than in a single bucket.
|
|
225
291
|
const placed: ExtensionUiDialogRequest[][] = questions.map((): ExtensionUiDialogRequest[] => []);
|
|
226
292
|
const loose: ExtensionUiDialogRequest[] = [];
|
|
293
|
+
const unmatched = new Set(unplaced.get(toolId) ?? []);
|
|
227
294
|
for (const frame of frames) {
|
|
228
295
|
if (Array.isArray(frame.questions) && frame.questions.length > 0) {
|
|
229
296
|
for (const grouped of frame.questions) {
|
|
@@ -240,20 +307,27 @@ export function splitAskFrames(
|
|
|
240
307
|
else loose.push(frame);
|
|
241
308
|
continue;
|
|
242
309
|
}
|
|
310
|
+
// A frame with neither a title nor a row match has no question to walk
|
|
311
|
+
// to; the card draws it as the live control (see `looseByTool`) rather
|
|
312
|
+
// than guessing a question and printing the wrong one as open.
|
|
313
|
+
if (unmatched.has(frame)) continue;
|
|
243
314
|
loose.push(frame);
|
|
244
315
|
}
|
|
245
316
|
// Everything that was not part of a grouped frame keeps the per-question
|
|
246
317
|
// walk it has always used.
|
|
247
318
|
const walked = groupAskFrames(questions, loose);
|
|
248
319
|
framesByTool.set(toolId, questions.map((_, index) => [...placed[index], ...walked[index]]));
|
|
320
|
+
const unplacedFrames = unplaced.get(toolId);
|
|
321
|
+
if (unplacedFrames && unplacedFrames.length > 0) looseByTool.set(toolId, unplacedFrames);
|
|
249
322
|
}
|
|
250
323
|
|
|
251
324
|
// The frame stays queued either way — only the modal waits for the history,
|
|
252
325
|
// so nothing is dropped and nothing flashes. An `ask` frame is excluded here
|
|
253
326
|
// in BOTH states: it is answered by a card or by the orphan row, and the
|
|
254
|
-
// modal has no body for it.
|
|
327
|
+
// modal has no body for it. Anything this split already handed to an inline
|
|
328
|
+
// surface is excluded too — a dialog must never be drawn twice.
|
|
255
329
|
const modalRequest = historyLoaded
|
|
256
|
-
? pending.find((request) => !
|
|
330
|
+
? pending.find((request) => !handled.has(request) && request.method !== 'ask') ?? null
|
|
257
331
|
: null;
|
|
258
|
-
return { framesByTool, orphanAsks, modalRequest };
|
|
332
|
+
return { framesByTool, looseByTool, orphanAsks, modalRequest };
|
|
259
333
|
}
|
|
@@ -174,10 +174,23 @@ async function setHarnessEnabled(id: string, enabled: boolean): Promise<string |
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
export
|
|
177
|
+
export interface UseHarnessesOptions {
|
|
178
|
+
/**
|
|
179
|
+
* Read `/api/harness` and follow its changes. Defaults to true.
|
|
180
|
+
*
|
|
181
|
+
* The composer's `@harness:<id>:` completion mounts this hook on EVERY
|
|
182
|
+
* composer, but only needs the catalogue once a model trigger is active;
|
|
183
|
+
* disabling until then keeps an idle draft from issuing a request (and a
|
|
184
|
+
* caller that stubs one endpoint from seeing a second).
|
|
185
|
+
*/
|
|
186
|
+
enabled?: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function useHarnesses({ enabled = true }: UseHarnessesOptions = {}): HarnessesController {
|
|
178
190
|
const [snapshot, setSnapshot] = useState(() => ({ ...store }));
|
|
179
191
|
|
|
180
192
|
useEffect(() => {
|
|
193
|
+
if (!enabled) return;
|
|
181
194
|
const sync = () => setSnapshot({ ...store });
|
|
182
195
|
listeners.add(sync);
|
|
183
196
|
// A subscriber that arrives after the first read has to see the catalog the
|
|
@@ -194,7 +207,7 @@ export function useHarnesses(): HarnessesController {
|
|
|
194
207
|
listeners.delete(sync);
|
|
195
208
|
offModels();
|
|
196
209
|
};
|
|
197
|
-
}, []);
|
|
210
|
+
}, [enabled]);
|
|
198
211
|
|
|
199
212
|
return {
|
|
200
213
|
harnesses: snapshot.harnesses,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The agent-token half of the gate: may this subprocess touch that session?
|
|
8
|
+
*
|
|
9
|
+
* Split out of `guard.ts` for two reasons. The file ceiling is one, but the
|
|
10
|
+
* real one is that this is a different question from "is there a UI session":
|
|
11
|
+
* a browser cookie is all-or-nothing, while an agent token is scoped to a
|
|
12
|
+
* session TREE. Keeping the two rules in one function made the tree rule look
|
|
13
|
+
* like a path check, which is exactly the bug it replaces.
|
|
14
|
+
*
|
|
15
|
+
* Three outcomes, because the caller must distinguish "not an agent request"
|
|
16
|
+
* (fall through to the device/401 path) from "an agent request that is allowed"
|
|
17
|
+
* (stop, allow) and "an agent request that is refused" (stop, 403).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
agentTokenScopeForPath,
|
|
22
|
+
bearerToken,
|
|
23
|
+
lookupAgentToken,
|
|
24
|
+
} from '@/server/lib/sessions/agent-token.server';
|
|
25
|
+
import { resolveAgentAccess } from '@/server/lib/sessions/relation-access.server';
|
|
26
|
+
|
|
27
|
+
export type AgentGateOutcome =
|
|
28
|
+
| { kind: 'none' }
|
|
29
|
+
| { kind: 'pass' }
|
|
30
|
+
| { kind: 'deny'; response: Response };
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The answer for a valid agent token naming a session outside its tree.
|
|
34
|
+
*
|
|
35
|
+
* Deliberately identical for "exists but is not yours" and "does not exist": a
|
|
36
|
+
* gate that distinguished them would be an id oracle for any agent process. The
|
|
37
|
+
* routes keep their own 404 for callers that already passed this check.
|
|
38
|
+
*/
|
|
39
|
+
function refusal(): Response {
|
|
40
|
+
return new Response(
|
|
41
|
+
JSON.stringify({ error: 'That session is not in this session’s tree', code: 'session_not_in_tree' }),
|
|
42
|
+
{ status: 403, headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } },
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolve one request against the agent-token rule.
|
|
48
|
+
*
|
|
49
|
+
* Spawn is the one path any token may call (a child must be able to create its
|
|
50
|
+
* own children); every other agent path names a session that must be in the
|
|
51
|
+
* token's tree — itself, an ancestor, or a descendant. The lookup falls back to
|
|
52
|
+
* the table so a peer instance that never saw the spawn still recognises the
|
|
53
|
+
* token.
|
|
54
|
+
*/
|
|
55
|
+
export async function agentGate(request: Request, pathname: string): Promise<AgentGateOutcome> {
|
|
56
|
+
const scope = agentTokenScopeForPath(pathname);
|
|
57
|
+
if (!scope) return { kind: 'none' };
|
|
58
|
+
|
|
59
|
+
const agentSession = await lookupAgentToken(bearerToken(request));
|
|
60
|
+
if (!agentSession) return { kind: 'none' };
|
|
61
|
+
if (scope.kind === 'any') return { kind: 'pass' };
|
|
62
|
+
if (await resolveAgentAccess(agentSession, scope.target)) return { kind: 'pass' };
|
|
63
|
+
return { kind: 'deny', response: refusal() };
|
|
64
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The gate with a password armed and an agent token in hand.
|
|
8
|
+
*
|
|
9
|
+
* This is the case that could not pass before: the scope was the id in the path,
|
|
10
|
+
* compared to the token's session, so a coordinator could not read its worker
|
|
11
|
+
* and a worker could not tell its coordinator. The measured three-worker run
|
|
12
|
+
* only worked because the gate returns before the token check when
|
|
13
|
+
* authentication is off — which is exactly the configuration a real install
|
|
14
|
+
* does not use.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
18
|
+
import fs from 'node:fs';
|
|
19
|
+
import os from 'node:os';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
|
|
22
|
+
import { authGate, initAuth } from '@/server/lib/auth/guard';
|
|
23
|
+
import { createAgentToken, rememberAgentToken } from '@/server/lib/sessions/agent-token.server';
|
|
24
|
+
import { ensureSessionRelationsSchema } from '@/server/lib/sessions/schema.server';
|
|
25
|
+
import { getDb } from '@/server/db.server';
|
|
26
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
27
|
+
|
|
28
|
+
let dataDir: string | null = null;
|
|
29
|
+
let tokenC = '';
|
|
30
|
+
let tokenW1 = '';
|
|
31
|
+
|
|
32
|
+
async function relation(sessionId: string, parentSessionId: string | null): Promise<void> {
|
|
33
|
+
const db = await getDb();
|
|
34
|
+
await db.run(
|
|
35
|
+
'INSERT INTO session_relations (session_id, parent_session_id, created_at) VALUES (?, ?, ?)',
|
|
36
|
+
[sessionId, parentSessionId, Date.now()],
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function request(pathname: string, token?: string): Request {
|
|
41
|
+
return new Request(`http://localhost${pathname}`, {
|
|
42
|
+
headers: token ? { authorization: `Bearer ${token}` } : {},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
beforeEach(async () => {
|
|
47
|
+
await isolateDb();
|
|
48
|
+
await ensureSessionRelationsSchema(await getDb());
|
|
49
|
+
dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-tree-gate-'));
|
|
50
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
51
|
+
globalThis.__kabmoAgentTokens = undefined;
|
|
52
|
+
|
|
53
|
+
await relation('C', null);
|
|
54
|
+
await relation('W1', 'C');
|
|
55
|
+
await relation('W2', 'C');
|
|
56
|
+
|
|
57
|
+
tokenC = createAgentToken();
|
|
58
|
+
tokenW1 = createAgentToken();
|
|
59
|
+
await rememberAgentToken('C', tokenC);
|
|
60
|
+
await rememberAgentToken('W1', tokenW1);
|
|
61
|
+
|
|
62
|
+
await initAuth('correct-horse');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterEach(async () => {
|
|
66
|
+
await initAuth(null);
|
|
67
|
+
globalThis.__kabmoAgentTokens = undefined;
|
|
68
|
+
delete Bun.env.KABMO_DATA_DIR;
|
|
69
|
+
if (dataDir) fs.rmSync(dataDir, { recursive: true, force: true });
|
|
70
|
+
dataDir = null;
|
|
71
|
+
await releaseDb();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('an agent token reaches its tree', () => {
|
|
75
|
+
test('a coordinator may read its worker', async () => {
|
|
76
|
+
expect(await authGate(request('/api/chat/W1', tokenC))).toBeUndefined();
|
|
77
|
+
expect(await authGate(request('/api/agent/W1', tokenC))).toBeUndefined();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('a worker may tell its coordinator', async () => {
|
|
81
|
+
expect(await authGate(request('/api/agent/C', tokenW1))).toBeUndefined();
|
|
82
|
+
expect(await authGate(request('/api/sessions/C/relations', tokenW1))).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('any token may spawn under itself', async () => {
|
|
86
|
+
expect(await authGate(request('/api/sessions/spawn', tokenW1))).toBeUndefined();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('a token minted by another process is accepted from the table', async () => {
|
|
90
|
+
// Simulates the peer instance: the cache is empty, the row is not.
|
|
91
|
+
globalThis.__kabmoAgentTokens = undefined;
|
|
92
|
+
expect(await authGate(request('/api/chat/W1', tokenC))).toBeUndefined();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('an agent token reaches nothing else', () => {
|
|
97
|
+
test('a sibling is refused with a typed code', async () => {
|
|
98
|
+
const response = await authGate(request('/api/chat/W2', tokenW1));
|
|
99
|
+
expect(response?.status).toBe(403);
|
|
100
|
+
expect(await response?.json()).toEqual({
|
|
101
|
+
error: 'That session is not in this session’s tree',
|
|
102
|
+
code: 'session_not_in_tree',
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('an unknown session answers the same refusal, not a 404', async () => {
|
|
107
|
+
// Identical to the sibling case on purpose: the gate must not become an id
|
|
108
|
+
// oracle for an agent process.
|
|
109
|
+
const response = await authGate(request('/api/chat/does-not-exist', tokenW1));
|
|
110
|
+
expect(response?.status).toBe(403);
|
|
111
|
+
expect((await response?.json()) as { code?: string }).toEqual(expect.objectContaining({ code: 'session_not_in_tree' }));
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a token is not a UI credential', async () => {
|
|
115
|
+
expect((await authGate(request('/api/settings', tokenC)))?.status).toBe(401);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('a request with no token is still a 401', async () => {
|
|
119
|
+
expect((await authGate(request('/api/chat/W1')))?.status).toBe(401);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -134,10 +134,10 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
134
134
|
// REAL file into a throwaway data directory and asserts that the gate ignores
|
|
135
135
|
// it — a stubbed file reader would prove nothing about that.
|
|
136
136
|
|
|
137
|
-
test('no password means the gate lets everything through', () => {
|
|
137
|
+
test('no password means the gate lets everything through', async () => {
|
|
138
138
|
expect(isAuthEnabled()).toBe(false);
|
|
139
139
|
const request = new Request('http://localhost/api/settings');
|
|
140
|
-
expect(authGate(request)).toBeUndefined();
|
|
140
|
+
expect(await authGate(request)).toBeUndefined();
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
test('a stored secret alone does NOT enable authentication', async () => {
|
|
@@ -153,7 +153,7 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
153
153
|
}));
|
|
154
154
|
|
|
155
155
|
expect(isAuthEnabled()).toBe(false);
|
|
156
|
-
expect(authGate(new Request('http://localhost/api/settings'))).toBeUndefined();
|
|
156
|
+
expect(await authGate(new Request('http://localhost/api/settings'))).toBeUndefined();
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
test('initAuth turns the gate on, and it rejects a request with no cookie', async () => {
|
|
@@ -161,7 +161,7 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
161
161
|
await initAuth('correct-horse');
|
|
162
162
|
|
|
163
163
|
expect(isAuthEnabled()).toBe(true);
|
|
164
|
-
const response = authGate(new Request('http://localhost/api/settings'));
|
|
164
|
+
const response = await authGate(new Request('http://localhost/api/settings'));
|
|
165
165
|
expect(response?.status).toBe(401);
|
|
166
166
|
});
|
|
167
167
|
|
|
@@ -176,16 +176,16 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
176
176
|
useTempDataDir();
|
|
177
177
|
await initAuth('correct-horse');
|
|
178
178
|
|
|
179
|
-
expect(authGate(new Request('http://localhost/api/updates/android'))).toBeUndefined();
|
|
180
|
-
expect(authGate(new Request('http://localhost/api/updates/ios'))).toBeUndefined();
|
|
181
|
-
expect(authGate(new Request('http://localhost/api/updates/desktop?kind=macos'))?.status).toBe(401);
|
|
179
|
+
expect(await authGate(new Request('http://localhost/api/updates/android'))).toBeUndefined();
|
|
180
|
+
expect(await authGate(new Request('http://localhost/api/updates/ios'))).toBeUndefined();
|
|
181
|
+
expect((await authGate(new Request('http://localhost/api/updates/desktop?kind=macos')))?.status).toBe(401);
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
test('a document request is redirected to the login screen, not answered 401', async () => {
|
|
185
185
|
useTempDataDir();
|
|
186
186
|
await initAuth('correct-horse');
|
|
187
187
|
|
|
188
|
-
const response = authGate(new Request('http://localhost/', { headers: { accept: 'text/html' } }));
|
|
188
|
+
const response = await authGate(new Request('http://localhost/', { headers: { accept: 'text/html' } }));
|
|
189
189
|
// A document has no body to render an error into, so it is sent to the
|
|
190
190
|
// screen that can ask for the password.
|
|
191
191
|
expect(response?.status).toBe(302);
|
|
@@ -224,7 +224,7 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
// The token is good before the revocation…
|
|
227
|
-
expect(authGate(withCookie())).toBeUndefined();
|
|
227
|
+
expect(await authGate(withCookie())).toBeUndefined();
|
|
228
228
|
|
|
229
229
|
const result = await revokeAllSessions();
|
|
230
230
|
expect(result.revoked).toBe(true);
|
|
@@ -232,7 +232,7 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
232
232
|
// …and dead after it, without the password having changed. This is the only
|
|
233
233
|
// revocation a stateless token admits, and it is what makes "sign out
|
|
234
234
|
// everywhere" possible at all.
|
|
235
|
-
expect(authGate(withCookie())?.status).toBe(401);
|
|
235
|
+
expect((await authGate(withCookie()))?.status).toBe(401);
|
|
236
236
|
|
|
237
237
|
// The new secret is persisted, so the revocation survives a restart rather
|
|
238
238
|
// than being undone by the old secret being read back from disk.
|
|
@@ -256,7 +256,7 @@ describe('authentication is per run, never inherited from disk', () => {
|
|
|
256
256
|
headers: { cookie: `omp_session=${fresh}` },
|
|
257
257
|
});
|
|
258
258
|
// Revoking everywhere must not lock out the browser that asked for it.
|
|
259
|
-
expect(authGate(request)).toBeUndefined();
|
|
259
|
+
expect(await authGate(request)).toBeUndefined();
|
|
260
260
|
});
|
|
261
261
|
});
|
|
262
262
|
|
|
@@ -267,7 +267,7 @@ describe('a session outlives the process that minted it', () => {
|
|
|
267
267
|
const first = loadAuthConfig()!;
|
|
268
268
|
const token = sessionTokenFor(first);
|
|
269
269
|
const request = new Request('http://localhost/api/settings', { headers: { cookie: `omp_session=${token}` } });
|
|
270
|
-
expect(authGate(request)).toBeUndefined();
|
|
270
|
+
expect(await authGate(request)).toBeUndefined();
|
|
271
271
|
|
|
272
272
|
// The second boot, in the same process: exactly what `bun --hot` does on
|
|
273
273
|
// every save, and what restarting a daemon does. The secret is read back
|
|
@@ -281,7 +281,7 @@ describe('a session outlives the process that minted it', () => {
|
|
|
281
281
|
// every session — the persisted secret never delivered its documented "a
|
|
282
282
|
// restart keeps its sessions".
|
|
283
283
|
expect(second.credentialKey).toBe(first.credentialKey);
|
|
284
|
-
expect(authGate(request)).toBeUndefined();
|
|
284
|
+
expect(await authGate(request)).toBeUndefined();
|
|
285
285
|
});
|
|
286
286
|
|
|
287
287
|
test('a restart with a DIFFERENT password revokes them', async () => {
|
|
@@ -293,7 +293,7 @@ describe('a session outlives the process that minted it', () => {
|
|
|
293
293
|
// Stable for an unchanged password, still bound to it: replacing the
|
|
294
294
|
// password is exactly what a session's death must follow.
|
|
295
295
|
const request = new Request('http://localhost/api/settings', { headers: { cookie: `omp_session=${token}` } });
|
|
296
|
-
expect(authGate(request)?.status).toBe(401);
|
|
296
|
+
expect((await authGate(request))?.status).toBe(401);
|
|
297
297
|
});
|
|
298
298
|
});
|
|
299
299
|
|
|
@@ -303,7 +303,7 @@ describe('the login screen is only for a visitor without a session', () => {
|
|
|
303
303
|
await initAuth('correct-horse');
|
|
304
304
|
const token = sessionTokenFor(loadAuthConfig()!);
|
|
305
305
|
|
|
306
|
-
const response = authGate(new Request('http://localhost/login', {
|
|
306
|
+
const response = await authGate(new Request('http://localhost/login', {
|
|
307
307
|
headers: { cookie: `omp_session=${token}`, accept: 'text/html' },
|
|
308
308
|
}));
|
|
309
309
|
|
|
@@ -319,14 +319,14 @@ describe('the login screen is only for a visitor without a session', () => {
|
|
|
319
319
|
|
|
320
320
|
// `/login` stays public — it IS the way in — so the gate must let it
|
|
321
321
|
// through to the shell that renders the form.
|
|
322
|
-
expect(authGate(new Request('http://localhost/login', { headers: { accept: 'text/html' } }))).toBeUndefined();
|
|
322
|
+
expect(await authGate(new Request('http://localhost/login', { headers: { accept: 'text/html' } }))).toBeUndefined();
|
|
323
323
|
});
|
|
324
324
|
|
|
325
|
-
test('with authentication off there is nothing to log into', () => {
|
|
325
|
+
test('with authentication off there is nothing to log into', async () => {
|
|
326
326
|
useTempDataDir();
|
|
327
327
|
// No password armed: every request counts as authenticated, which makes
|
|
328
328
|
// `/login` a URL with no meaning rather than a screen.
|
|
329
|
-
const response = authGate(new Request('http://localhost/login', { headers: { accept: 'text/html' } }));
|
|
329
|
+
const response = await authGate(new Request('http://localhost/login', { headers: { accept: 'text/html' } }));
|
|
330
330
|
expect(response?.status).toBe(302);
|
|
331
331
|
expect(response?.headers.get('location')).toBe('/');
|
|
332
332
|
});
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
|
|
30
30
|
import { hashPassword, deriveCredentialKey, readSessionSecret, writeSessionSecret, type ActiveAuthConfig } from '@/server/lib/auth/config';
|
|
31
31
|
import { readSessionCookie, verifySessionToken } from '@/server/lib/auth/token';
|
|
32
|
-
import {
|
|
32
|
+
import { agentGate } from '@/server/lib/auth/agent-gate.server';
|
|
33
|
+
import { bearerToken } from '@/server/lib/sessions/agent-token.server';
|
|
33
34
|
import { verifyDeviceToken, readDeviceCookie } from '@/server/lib/connect/devices.server';
|
|
34
35
|
import { rememberClientAddress } from '@/server/lib/auth/client-address';
|
|
35
36
|
import type { CredentialHandover } from '@/shared/lib/auth/handover';
|
|
@@ -275,7 +276,13 @@ function rejectionResponse(pathname: string, wantsHtml: boolean): Response {
|
|
|
275
276
|
}
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
|
-
* The gate itself.
|
|
279
|
+
* The gate itself. Resolves to a `Response` to reject, or `undefined` to
|
|
280
|
+
* continue.
|
|
281
|
+
*
|
|
282
|
+
* Async because the agent-token rule is a tree question, and answering it needs
|
|
283
|
+
* one indexed read of `session_relations`. The gate still never touches the
|
|
284
|
+
* request body: the measured Elysia trap is about passing the context to a
|
|
285
|
+
* helper, not about awaiting.
|
|
279
286
|
*
|
|
280
287
|
* `clientAddress` comes from the socket (Elysia's `server.requestIP`) and is
|
|
281
288
|
* recorded for the login route, which throttles by it. It is optional so a test
|
|
@@ -285,7 +292,7 @@ function rejectionResponse(pathname: string, wantsHtml: boolean): Response {
|
|
|
285
292
|
* the routes that matter are same-origin, so rejecting it would only break
|
|
286
293
|
* browsers that probe.
|
|
287
294
|
*/
|
|
288
|
-
export function authGate(request: Request, clientAddress?: string): Response | undefined {
|
|
295
|
+
export async function authGate(request: Request, clientAddress?: string): Promise<Response | undefined> {
|
|
289
296
|
if (request.method === 'OPTIONS') return undefined;
|
|
290
297
|
|
|
291
298
|
rememberClientAddress(request, clientAddress);
|
|
@@ -314,14 +321,11 @@ export function authGate(request: Request, clientAddress?: string): Response | u
|
|
|
314
321
|
return undefined;
|
|
315
322
|
}
|
|
316
323
|
|
|
317
|
-
// An agent subprocess carries a bearer token instead of a cookie.
|
|
318
|
-
//
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
const agentSession = verifyAgentToken(bearerToken(request));
|
|
323
|
-
if (agentSession && (scope === 'any' || scope === agentSession)) return undefined;
|
|
324
|
-
}
|
|
324
|
+
// An agent subprocess carries a bearer token instead of a cookie. The rule is
|
|
325
|
+
// a session TREE, not a path id — see `agent-gate.server.ts` for why.
|
|
326
|
+
const agent = await agentGate(request, pathname);
|
|
327
|
+
if (agent.kind === 'pass') return undefined;
|
|
328
|
+
if (agent.kind === 'deny') return agent.response;
|
|
325
329
|
|
|
326
330
|
// A paired device carries its own token, and it is good for the whole console
|
|
327
331
|
// rather than one path: the device is a browser, not a subprocess. Revoking
|
|
@@ -76,7 +76,7 @@ describe('initAuthFromHandover', () => {
|
|
|
76
76
|
|
|
77
77
|
// A restart must not sign the user out: this is the property the key +
|
|
78
78
|
// secret pair exists to preserve.
|
|
79
|
-
const response = authGate(new Request('http://localhost/api/folders', {
|
|
79
|
+
const response = await authGate(new Request('http://localhost/api/folders', {
|
|
80
80
|
headers: { cookie: `omp_session=${token}` },
|
|
81
81
|
}));
|
|
82
82
|
expect(response).toBeUndefined();
|