@tequila99/githuman 0.11.0 → 0.12.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/README.md +62 -2
- package/dist/cli/commands/mcp.js +112 -0
- package/dist/cli/commands/pi-acp.js +21 -0
- package/dist/cli/config.js +7 -1
- package/dist/cli/index.js +19 -8
- package/dist/cli/server-runtime.js +1 -0
- package/dist/server/adapters/agents/artifact-permission.js +88 -0
- package/dist/server/adapters/pi-acp/agent.js +98 -0
- package/dist/server/adapters/pi-acp/compatibility.js +57 -0
- package/dist/server/adapters/pi-acp/control.js +76 -0
- package/dist/server/adapters/pi-acp/errors.js +17 -0
- package/dist/server/adapters/pi-acp/extension.js +255 -0
- package/dist/server/adapters/pi-acp/launch.js +16 -0
- package/dist/server/adapters/pi-acp/mcp.js +153 -0
- package/dist/server/adapters/pi-acp/process.js +199 -0
- package/dist/server/adapters/pi-acp/session.js +409 -0
- package/dist/server/adapters/pi-acp/vendor/LICENSE +21 -0
- package/dist/server/adapters/pi-acp/vendor/README.md +29 -0
- package/dist/server/adapters/pi-acp/vendor/prompt.js +56 -0
- package/dist/server/app.js +94 -5
- package/dist/server/config/agents.js +4 -6
- package/dist/server/db/artifact-graph-migrations.js +56 -0
- package/dist/server/db/artifact-migrations.js +70 -0
- package/dist/server/db/artifact-review-migrations.js +24 -0
- package/dist/server/db/artifact-search-migrations.js +31 -0
- package/dist/server/db/artifact-validation-migrations.js +70 -0
- package/dist/server/db/index.js +3 -0
- package/dist/server/db/migrations.js +10 -0
- package/dist/server/db/sqlite-error.js +15 -0
- package/dist/server/db/transaction.js +40 -0
- package/dist/server/errors/artifacts.js +28 -0
- package/dist/server/errors/database.js +2 -0
- package/dist/server/hooks/access/require-access.js +8 -0
- package/dist/server/repositories/artifact-catalog.repo.js +283 -0
- package/dist/server/repositories/artifact-files.repo.js +181 -0
- package/dist/server/repositories/artifact-graph.repo.js +50 -0
- package/dist/server/repositories/artifact-search.repo.js +192 -0
- package/dist/server/repositories/artifact-transition.repo.js +85 -0
- package/dist/server/repositories/artifact-validation.repo.js +146 -0
- package/dist/server/repositories/notes-catalog.repo.js +2 -10
- package/dist/server/repositories/task.repo.js +114 -0
- package/dist/server/routes/agent.js +8 -1
- package/dist/server/routes/artifact-actions.js +129 -0
- package/dist/server/routes/artifact-agent.js +183 -0
- package/dist/server/routes/artifact-definitions.js +163 -0
- package/dist/server/routes/artifact-transitions.js +80 -0
- package/dist/server/routes/artifacts.js +111 -0
- package/dist/server/routes/events.js +5 -1
- package/dist/server/routes/project-files.js +90 -0
- package/dist/server/services/agent/agent-session.js +180 -10
- package/dist/server/services/agent/context-builder.js +30 -2
- package/dist/server/services/agent/session-registry.js +106 -2
- package/dist/server/services/agent/turn-task-context.js +1 -0
- package/dist/server/services/artifact-authorization.service.js +174 -0
- package/dist/server/services/artifact-definition.service.js +96 -0
- package/dist/server/services/artifact-export.service.js +44 -0
- package/dist/server/services/artifact-graph-validation.js +497 -0
- package/dist/server/services/artifact-graph.service.js +81 -0
- package/dist/server/services/artifact-lifecycle.service.js +343 -0
- package/dist/server/services/artifact-maintenance.service.js +55 -0
- package/dist/server/services/artifact-search.service.js +331 -0
- package/dist/server/services/artifact-storage.service.js +646 -0
- package/dist/server/services/artifact-transition.service.js +607 -0
- package/dist/server/services/artifact-type.service.js +74 -0
- package/dist/server/services/artifact-validation-jobs.service.js +518 -0
- package/dist/server/services/device-connections.js +9 -1
- package/dist/server/services/project-files.service.js +144 -0
- package/dist/server/services/review.service.js +6 -5
- package/dist/server/services/task.service.js +225 -0
- package/dist/server/utils/artifact-actor.js +13 -0
- package/dist/server/utils/artifact-page.js +42 -0
- package/dist/server/utils/take-within-bytes.js +16 -0
- package/dist/server/utils/text.js +7 -0
- package/dist/shared/agents/schemas.js +27 -0
- package/dist/shared/app/storage-constants.js +2 -0
- package/dist/shared/artifact-tools/descriptions.js +11 -0
- package/dist/shared/artifact-tools/instructions.js +14 -0
- package/dist/shared/artifact-tools/schemas.js +119 -0
- package/dist/shared/artifact-transitions/constants.js +21 -0
- package/dist/shared/artifact-transitions/schemas.js +111 -0
- package/dist/shared/artifact-transitions/transitions.js +61 -0
- package/dist/shared/artifact-transitions/types.js +1 -0
- package/dist/shared/artifacts/constants.js +34 -0
- package/dist/shared/artifacts/mcp-constants.js +24 -0
- package/dist/shared/artifacts/normalize.js +9 -0
- package/dist/shared/artifacts/schemas.js +820 -0
- package/dist/shared/artifacts/search.js +101 -0
- package/dist/shared/artifacts/types.js +1 -0
- package/dist/shared/events/schemas.js +1 -1
- package/dist/shared/events/types.js +1 -0
- package/dist/shared/git/constants.js +2 -0
- package/dist/shared/project-files/constants.js +18 -0
- package/dist/shared/project-files/schemas.js +35 -0
- package/dist/shared/project-files/types.js +1 -0
- package/dist/shared/tasks/schemas.js +261 -0
- package/dist/shared/tasks/types.js +1 -0
- package/dist/shared/utils/artifact-body.js +10 -0
- package/dist/shared/utils/canonical-json.js +22 -0
- package/dist/shared/utils/is-safe-prefixed-filename.js +10 -0
- package/dist/shared/utils/is-uuid.js +4 -2
- package/dist/shared/utils/is-valid-artifact-type-id.js +9 -0
- package/dist/shared/utils/is-valid-filename-prefix.js +13 -0
- package/dist/shared/utils/markdown-path.js +4 -0
- package/dist/shared/utils/pdf-path.js +4 -0
- package/dist/web/assets/AccessPage-Dvj0aCkm.js +1 -0
- package/dist/web/assets/AddButton-CMC9qf51.js +4 -0
- package/dist/web/assets/AddToAgentButton-BitTdCEg.js +1 -0
- package/dist/web/assets/AppPage-Cozv2vqG.js +1 -0
- package/dist/web/assets/ArtifactDefinitionPicker-BQOoU60k.js +3 -0
- package/dist/web/assets/ArtifactDefinitionPicker-D3qdrxlC.css +1 -0
- package/dist/web/assets/ArtifactsPage-BJR-XYYs.js +2 -0
- package/dist/web/assets/ArtifactsPage-Cu1xdYNf.css +1 -0
- package/dist/web/assets/CancelButton-mkxRHwoZ.js +1 -0
- package/dist/web/assets/ClosePopup-BtDeDZsk.js +1 -0
- package/dist/web/assets/CreateButton-zCmb7snC.js +1 -0
- package/dist/web/assets/CreateReviewFabButton-BCg1TvFh.js +1 -0
- package/dist/web/assets/DialogHeader-CPL9OtDV.css +1 -0
- package/dist/web/assets/DialogHeader-CQvAZVx7.js +1 -0
- package/dist/web/assets/{ErrorNotFound-DtnO85PU.js → ErrorNotFound-fXS367lZ.js} +1 -1
- package/dist/web/assets/{IndexPage-D5PvyGrX.css → IndexPage-5V5GLtgi.css} +1 -1
- package/dist/web/assets/IndexPage-DMTZyWQA.js +1 -0
- package/dist/web/assets/MainLayout-DWJ_-EMV.js +7 -0
- package/dist/web/assets/MainLayout-Dy74m_q1.css +1 -0
- package/dist/web/assets/NoteVisualEditor-5rHBQ3j0.js +1054 -0
- package/dist/web/assets/{NoteVisualEditor-BYikrY7Q.css → NoteVisualEditor-DE4ACTRJ.css} +1 -1
- package/dist/web/assets/NotesPage-C_eoCUl7.css +1 -0
- package/dist/web/assets/NotesPage-CjaxjLBW.js +4 -0
- package/dist/web/assets/{PdfPreview-kL_nk9my.js → PdfPreview-2NQ5gkjh.js} +2 -2
- package/dist/web/assets/ProjectFilePage-B-WUUxnq.js +1 -0
- package/dist/web/assets/QBtn-V3VXtJXi.js +1 -0
- package/dist/web/assets/QFab-CxpedhPI.js +1 -0
- package/dist/web/assets/QForm-ClpSneeD.js +1 -0
- package/dist/web/assets/QInput-BnqLJGXl.js +1 -0
- package/dist/web/assets/QScrollArea-js5dkUz1.js +1 -0
- package/dist/web/assets/QSpace-C7iAnGlU.js +1 -0
- package/dist/web/assets/QTabs-DIy5gWMb.js +1 -0
- package/dist/web/assets/QVirtualScroll-DkD0TczV.js +1 -0
- package/dist/web/assets/ReviewDetailPage-BgxcsTqY.css +1 -0
- package/dist/web/assets/ReviewDetailPage-Bmc8DmSu.js +1 -0
- package/dist/web/assets/ReviewsPage-DR1IWCmu.js +1 -0
- package/dist/web/assets/SearchInput-BRyN93Z1.js +1 -0
- package/dist/web/assets/StatusSwitcher-CpkH8BuC.js +1 -0
- package/dist/web/assets/{StatusSwitcher-D6i8_OfR.css → StatusSwitcher-DaE1ufAA.css} +1 -1
- package/dist/web/assets/TagFilterField-Bl3FBkB5.js +1 -0
- package/dist/web/assets/TagFilterField-DjUH0m3_.css +1 -0
- package/dist/web/assets/{TerminalView-617DZuPt.css → TerminalView-BCeke4xd.css} +1 -1
- package/dist/web/assets/{TerminalView-BsO_SZut.js → TerminalView-tEyLM5qZ.js} +12 -12
- package/dist/web/assets/{abnfDiagram-O67JEVCF-qUSrlp_c.js → abnfDiagram-O67JEVCF-DN9xiV9p.js} +1 -1
- package/dist/web/assets/{access-store-Q8nkv4Nb.js → access-store-CwkOl71l.js} +1 -1
- package/dist/web/assets/{agent-store-D2jgeBgi.js → agent-store-Grbx4jkz.js} +5 -5
- package/dist/web/assets/architecture-7GRP2DOG-DmaYCP8T.js +1 -0
- package/dist/web/assets/{architectureDiagram-NJMV4G6O-D7RC6OS2.js → architectureDiagram-NJMV4G6O-BVAJOucG.js} +1 -1
- package/dist/web/assets/{blockDiagram-BEXU5L5S-CmNtTpfK.js → blockDiagram-BEXU5L5S-TJAfSX44.js} +1 -1
- package/dist/web/assets/{c4Diagram-YGBWAQC7-CKCcu1qx.js → c4Diagram-YGBWAQC7-5UHyT_tW.js} +1 -1
- package/dist/web/assets/channel-B4_5H-fb.js +1 -0
- package/dist/web/assets/{chunk-3FUC2YCW-Drz6oeKx.js → chunk-3FUC2YCW-CelgLyJi.js} +1 -1
- package/dist/web/assets/{chunk-5DYCD2WN-RItzEgV_.js → chunk-5DYCD2WN-bhEAVIbQ.js} +1 -1
- package/dist/web/assets/{chunk-742MDFTN-D6hKdOv7.js → chunk-742MDFTN-ByLz4EcD.js} +1 -1
- package/dist/web/assets/{chunk-7INBJB4K-Dk7-Eior.js → chunk-7INBJB4K-CK2i0csa.js} +1 -1
- package/dist/web/assets/{chunk-7M6MHVWA-Cw8E0Nkn.js → chunk-7M6MHVWA-CoCiujjC.js} +1 -1
- package/dist/web/assets/{chunk-7PRAP22T-t-mTeNXF.js → chunk-7PRAP22T-CY4NCrCY.js} +1 -1
- package/dist/web/assets/{chunk-GTNCS2PH-C7j2atV8.js → chunk-GTNCS2PH-DMB7bQGB.js} +1 -1
- package/dist/web/assets/{chunk-GWA4HPMP-CH9T9LZO.js → chunk-GWA4HPMP-F6qclPTR.js} +1 -1
- package/dist/web/assets/{chunk-MBY4JIJT-yXOO37xD.js → chunk-MBY4JIJT-CSiiBtlX.js} +1 -1
- package/dist/web/assets/{chunk-NETBCI7D-C-s2UtAR.js → chunk-NETBCI7D-CBh7GChL.js} +1 -1
- package/dist/web/assets/{chunk-O7XYJQB3-5Me_aV8o.js → chunk-O7XYJQB3-B2aqz0sN.js} +1 -1
- package/dist/web/assets/{chunk-UA2S7LBM-BQaibeff.js → chunk-UA2S7LBM-B_-P_eR0.js} +1 -1
- package/dist/web/assets/{chunk-WEXAMYUT-UBcOE4Lf.js → chunk-WEXAMYUT-19nMFxzK.js} +1 -1
- package/dist/web/assets/{chunk-Z7XXMR3K-BsA8o3Pt.js → chunk-Z7XXMR3K-Co7gzRY1.js} +1 -1
- package/dist/web/assets/{chunk-ZIGJFQKS--KwSI1U0.js → chunk-ZIGJFQKS-Eoi4K5bK.js} +1 -1
- package/dist/web/assets/{classDiagram-v2-NBCMYWYE-pMF8oCmq.js → classDiagram-v2-NBCMYWYE-CfFGzL-A.js} +1 -1
- package/dist/web/assets/copy-code-DaqEfdXL.js +1 -0
- package/dist/web/assets/create-DedXY-KP.js +1 -0
- package/dist/web/assets/{cynefin-OW5HDTMX-DFgtXolF.js → cynefin-OW5HDTMX-DdZXl3KU.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-VND7K2PF-CPY0JRyq.js → cynefinDiagram-VND7K2PF-WU21nYH-.js} +1 -1
- package/dist/web/assets/{dagre-6A5THRUB-KdjJKAB7.js → dagre-6A5THRUB-48z3F8Pl.js} +1 -1
- package/dist/web/assets/date-DZIuZp-w.js +1 -0
- package/dist/web/assets/devices-store-Bfk2wdrQ.js +1 -0
- package/dist/web/assets/{diagram-22UHCM2B-BDcOcvF_.js → diagram-22UHCM2B-B0AZgJW9.js} +1 -1
- package/dist/web/assets/{diagram-3UASUU5V-6j2nlZL3.js → diagram-3UASUU5V-CzEzrxuO.js} +1 -1
- package/dist/web/assets/{diagram-ATOU4E4O-BN8cdxED.js → diagram-ATOU4E4O-w6h1bD3w.js} +1 -1
- package/dist/web/assets/{diagram-CDSNMT55-cWPiXHkr.js → diagram-CDSNMT55-BdTHQd_o.js} +1 -1
- package/dist/web/assets/{diagram-MLGK6HIB-DcgkH_Vl.js → diagram-MLGK6HIB-pB4cj6c2.js} +1 -1
- package/dist/web/assets/{diagram-MPIPVDR6-D_e86L99.js → diagram-MPIPVDR6-C7C06qyV.js} +1 -1
- package/dist/web/assets/diff-store-DBDL5Hw5.js +93 -0
- package/dist/web/assets/{dist-Bdsq-Ze1.js → dist-B7Cu0FBW.js} +1 -1
- package/dist/web/assets/{dist-BVVhgjWT.js → dist-B8i8y3GY.js} +1 -1
- package/dist/web/assets/{dist-CjkUzU4s.js → dist-BNgPhnKo.js} +1 -1
- package/dist/web/assets/{dist-Bz40Nd9I.js → dist-BWoPV5P3.js} +1 -1
- package/dist/web/assets/{dist-BP40mvwJ.js → dist-CJ7isxli.js} +1 -1
- package/dist/web/assets/{dist-C9enVshI.js → dist-CTJJYvYG.js} +1 -1
- package/dist/web/assets/{dist-BwpyANeW.js → dist-CZz0KXAA.js} +1 -1
- package/dist/web/assets/{dist-CU43ytsh.js → dist-DNpwgDba.js} +1 -1
- package/dist/web/assets/{dist-BMFtkY2y.js → dist-DWCdhk-O.js} +1 -1
- package/dist/web/assets/{dist-MUQaJRtC.js → dist-DqSUdjG9.js} +1 -1
- package/dist/web/assets/{dist-CLCP7f3x.js → dist-Dy9K9LOR.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-ZINNZB2B-D8xHOFOi.js → ebnfDiagram-ZINNZB2B-75vt7539.js} +1 -1
- package/dist/web/assets/{elk-276RUBZZ-JiDwNyLy.js → elk-276RUBZZ-DXDjJVTy.js} +1 -1
- package/dist/web/assets/{erDiagram-OPXOYQCR-D3J6u81a.js → erDiagram-OPXOYQCR-tNNInTmk.js} +1 -1
- package/dist/web/assets/eventmodeling-NTZA5JFV-QMRehQtM.js +1 -0
- package/dist/web/assets/flowDiagram-KWPJA3E3-DJAgsbXC.js +1 -0
- package/dist/web/assets/{ganttDiagram-FUAMR5RP-nvAVhbgI.js → ganttDiagram-FUAMR5RP-h3E8lnCd.js} +1 -1
- package/dist/web/assets/{gitGraph-4MIJSDKK-Bv_wkB2T.js → gitGraph-4MIJSDKK-BUwY-iv2.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-X574FWY7-DxxwadhH.js → gitGraphDiagram-X574FWY7-C0AgQH5k.js} +1 -1
- package/dist/web/assets/i18n-CfTd46OX.js +1 -0
- package/dist/web/assets/icons-BoaZfGBj.js +1 -0
- package/dist/web/assets/index-BQU3KK1E.css +1 -0
- package/dist/web/assets/index-BTpokWxr.js +2 -0
- package/dist/web/assets/{info-A6RAGUB7-Dw18yeIE.js → info-A6RAGUB7-DVMZ4hdK.js} +1 -1
- package/dist/web/assets/{infoDiagram-VRGFBTTK-C3BrgjYg.js → infoDiagram-VRGFBTTK-kLaGXGQ2.js} +1 -1
- package/dist/web/assets/init-app-Bxc_l2yT.js +1 -0
- package/dist/web/assets/{is-D0waCELe.js → is-B1kBQ5Va.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-OU5B5YK6-DU2p9szX.js → ishikawaDiagram-OU5B5YK6-Oj7bZlyo.js} +1 -1
- package/dist/web/assets/{journeyDiagram-ZHPQQLJL-Bs2zQnew.js → journeyDiagram-ZHPQQLJL-BG7V2Srs.js} +1 -1
- package/dist/web/assets/{kanban-definition-PNTS6WVX-pqXd5uNi.js → kanban-definition-PNTS6WVX-CIJiDE6d.js} +1 -1
- package/dist/web/assets/{line-CN4Dxpei.js → line-D2vEKYRZ.js} +1 -1
- package/dist/web/assets/markdown-Bm2wfvok.js +16 -0
- package/dist/web/assets/mdi-Byw1NZrZ.js +1 -0
- package/dist/web/assets/{mermaid-parser.core-DZqDOGRM.js → mermaid-parser.core-BcBEWjW6.js} +3 -3
- package/dist/web/assets/{mermaid.core-CUndCvkz.js → mermaid.core-DobO0deo.js} +4 -4
- package/dist/web/assets/{mindmap-definition-NLK3R4M7-DyK7YqB7.js → mindmap-definition-NLK3R4M7-y7Qz5gBF.js} +1 -1
- package/dist/web/assets/{packet-AYTQ26CC-DvlW_0BP.js → packet-AYTQ26CC-oRQgKr9d.js} +1 -1
- package/dist/web/assets/{pegDiagram-GJSIUBJH-k2e_-FWQ.js → pegDiagram-GJSIUBJH-RIU8XOHq.js} +1 -1
- package/dist/web/assets/{pie-WAS4IAKB-B99zaYjO.js → pie-WAS4IAKB-qmOlsLkx.js} +1 -1
- package/dist/web/assets/{pieDiagram-5QR66LMP-BPbS05lK.js → pieDiagram-5QR66LMP-BM932TDA.js} +1 -1
- package/dist/web/assets/pinia-BfqEuvsi.js +1 -0
- package/dist/web/assets/pinia-Cmp1GI8k.js +1 -0
- package/dist/web/assets/preview-store-D7qF6SgX.js +2 -0
- package/dist/web/assets/project-files-store-OhGs_H7U.js +1 -0
- package/dist/web/assets/{quadrantDiagram-O4NWA36T-DqNNdsd2.js → quadrantDiagram-O4NWA36T-qQZYwTy7.js} +1 -1
- package/dist/web/assets/{radar-RG4KPBEZ-BIAAr9LO.js → radar-RG4KPBEZ-Kdglk6eY.js} +1 -1
- package/dist/web/assets/{railroad-74A4TZTK-DYxr-1-f.js → railroad-74A4TZTK-kVhMYx4I.js} +1 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-MiKgjOXr.js +1 -0
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-BFL9h7Zx.js +1 -0
- package/dist/web/assets/railroad-peg-WCYAUIDC-ChGGfIn7.js +1 -0
- package/dist/web/assets/{railroadDiagram-XR7U4H2S-TNg-LqRR.js → railroadDiagram-XR7U4H2S-K9SrOGcT.js} +1 -1
- package/dist/web/assets/render-Brao9Nj2.js +1 -0
- package/dist/web/assets/repository-store-DZgQ5H7J.js +1 -0
- package/dist/web/assets/{requirementDiagram-PLB6GJNP-hKAyJR6W.js → requirementDiagram-PLB6GJNP-CtA9ZKEx.js} +1 -1
- package/dist/web/assets/runtime-core.esm-bundler-DDnHUoIy.js +1 -0
- package/dist/web/assets/{safe-storage-B1Aq5CGi.js → safe-storage-CvVvrm4v.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-IPEJSGJF-_MSL-tES.js → sankeyDiagram-IPEJSGJF-BH_t4exx.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-PO4LG4MO-Byq-joBG.js → sequenceDiagram-PO4LG4MO-hPNPqpDa.js} +1 -1
- package/dist/web/assets/single-flight-CyDZB3rb.js +1 -0
- package/dist/web/assets/{stateDiagram-v2-GCMORJYK-BR2jAgaa.js → stateDiagram-v2-GCMORJYK-BVmjZDRD.js} +1 -1
- package/dist/web/assets/{swimlanes-2SLR337P-Nt8ojGKK.js → swimlanes-2SLR337P-Tgk8-6jj.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-TC7HE7FX-W1zDrK61.js +8 -0
- package/dist/web/assets/{terminal-store-D0abibMa.js → terminal-store-CKgJjtC6.js} +1 -1
- package/dist/web/assets/theme-slSxLNv6.js +1 -0
- package/dist/web/assets/{timeline-definition-EJHVYXUP-BtihLvxk.js → timeline-definition-EJHVYXUP-lAIHEGe8.js} +1 -1
- package/dist/web/assets/{treeView-Q6P3EWNA-D5HzXeKd.js → treeView-Q6P3EWNA-CdvzKtWf.js} +1 -1
- package/dist/web/assets/{treemap-WGGIJYW6-Dovjuutg.js → treemap-WGGIJYW6-BxDSJfrJ.js} +1 -1
- package/dist/web/assets/uid-B1JNhznI.js +1 -0
- package/dist/web/assets/use-add-agent-context-BSHGL5iV.js +1 -0
- package/dist/web/assets/use-app-theme-fmVV2QM8.js +1 -0
- package/dist/web/assets/use-countdown-D6_qSOZJ.js +1 -0
- package/dist/web/assets/use-notify-error-Dx2D9IEP.js +1 -0
- package/dist/web/assets/use-panel-width-BYOPuHat.js +1 -0
- package/dist/web/assets/use-router-link-D7geCGQI.js +1 -0
- package/dist/web/assets/use-row-height-BK8kNihW.js +1 -0
- package/dist/web/assets/use-server-events-CvcbsbIf.js +1 -0
- package/dist/web/assets/use-virtual-scroll-DixIsJk4.js +1 -0
- package/dist/web/assets/use-workspace-navigation-AaRMWmjQ.js +1 -0
- package/dist/web/assets/{usecaseDiagram-POWQR4AR-DSwRE8zj.js → usecaseDiagram-POWQR4AR-BH3KvMpz.js} +1 -1
- package/dist/web/assets/{vennDiagram-UO4OBE2U-C-B8yP1K.js → vennDiagram-UO4OBE2U-Dfi-raKp.js} +1 -1
- package/dist/web/assets/viewport-store-NqQS7itT.js +1 -0
- package/dist/web/assets/{vue-i18n.runtime-CEtihHHL.js → vue-i18n.runtime-JOo8b7-t.js} +2 -2
- package/dist/web/assets/{wardley-WFR3VGLG-wWgaZuh6.js → wardley-WFR3VGLG-DmbtSM24.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-VNRHLVJA-DbhenrHd.js → wardleyDiagram-VNRHLVJA-DIzhGvI7.js} +1 -1
- package/dist/web/assets/weighted-lru-BFtZKA_y.js +1 -0
- package/dist/web/assets/workspace-navigation-xfxULfM7.js +1 -0
- package/dist/web/assets/{xychartDiagram-PMCCYNJV-CxFDmAEt.js → xychartDiagram-PMCCYNJV-XgqSHH_N.js} +1 -1
- package/dist/web/index.html +10 -8
- package/package.json +5 -3
- package/dist/web/assets/AccessPage-_OKn9U0P.js +0 -1
- package/dist/web/assets/AppPage-oQ9Rz0be.js +0 -1
- package/dist/web/assets/CreateButton-D1EtoicG.js +0 -1
- package/dist/web/assets/CreateReviewFabButton-BxvT3i9e.js +0 -1
- package/dist/web/assets/IndexPage-gdD7BHxA.js +0 -1
- package/dist/web/assets/MainLayout-47PTLKZf.js +0 -6
- package/dist/web/assets/MainLayout-ikSrFqBh.css +0 -1
- package/dist/web/assets/NoteVisualEditor-BQ6mVfj0.js +0 -1054
- package/dist/web/assets/NotesPage-DNR9iW_G.js +0 -4
- package/dist/web/assets/NotesPage-_8naQciW.css +0 -1
- package/dist/web/assets/PanelResize-CAQFVc8b.js +0 -1
- package/dist/web/assets/QBtn-CB-yw_iP.js +0 -1
- package/dist/web/assets/QExpansionItem-Dr5oXO0m.js +0 -4
- package/dist/web/assets/QFab-DPz8RiP0.js +0 -1
- package/dist/web/assets/QForm-CASiKhGm.js +0 -1
- package/dist/web/assets/QInput-k34nCPWg.js +0 -1
- package/dist/web/assets/QSelect-CaKn9Tkg.js +0 -1
- package/dist/web/assets/QSpace-Di_bZQY6.js +0 -1
- package/dist/web/assets/QVirtualScroll-oGN_Tl5J.js +0 -1
- package/dist/web/assets/ReviewDetailPage-BKgIprY0.js +0 -1
- package/dist/web/assets/ReviewDetailPage-CkCilMNW.css +0 -1
- package/dist/web/assets/ReviewsPage-6PJ6wofN.js +0 -1
- package/dist/web/assets/StatusSwitcher-s9w6iKpR.js +0 -1
- package/dist/web/assets/architecture-7GRP2DOG-D6PShS0_.js +0 -1
- package/dist/web/assets/channel-D6lb5DbY.js +0 -1
- package/dist/web/assets/create-B9Tn5Xvi.js +0 -1
- package/dist/web/assets/devices-store-CrZ4MxyY.js +0 -1
- package/dist/web/assets/diff-store-ByxMCKoa.js +0 -93
- package/dist/web/assets/eventmodeling-NTZA5JFV-QCwZLvmm.js +0 -1
- package/dist/web/assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNa-Dr0goTwe.woff +0 -0
- package/dist/web/assets/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ-D-x-0Q06.woff2 +0 -0
- package/dist/web/assets/flowDiagram-KWPJA3E3-CgF90hDi.js +0 -1
- package/dist/web/assets/i18n-DDCqtTTW.js +0 -1
- package/dist/web/assets/index-BNHt6zmP.js +0 -2
- package/dist/web/assets/index-BwbM_RKi.css +0 -1
- package/dist/web/assets/init-app-BouXTk8p.js +0 -1
- package/dist/web/assets/markdown-jR0fhe4d.js +0 -15
- package/dist/web/assets/pinia-BETEFLDG.js +0 -1
- package/dist/web/assets/pinia-DO0AdKGg.js +0 -1
- package/dist/web/assets/railroad-abnf-HS5TGJTU-GESjhc3t.js +0 -1
- package/dist/web/assets/railroad-ebnf-LZEXJU2U-Cybu0A7J.js +0 -1
- package/dist/web/assets/railroad-peg-WCYAUIDC-DCHxrtbI.js +0 -1
- package/dist/web/assets/runtime-core.esm-bundler-CAvPiMpd.js +0 -1
- package/dist/web/assets/single-flight-DLCbzLI3.js +0 -1
- package/dist/web/assets/swimlanesDiagram-TC7HE7FX-Ds1hVYqh.js +0 -8
- package/dist/web/assets/theme-QEcOl0lf.js +0 -1
- package/dist/web/assets/use-add-agent-context-BaPUIO93.js +0 -1
- package/dist/web/assets/use-app-theme-B1cdbnHn.js +0 -1
- package/dist/web/assets/use-countdown-CTag4T13.js +0 -1
- package/dist/web/assets/use-panel-width-CB-0S3zX.js +0 -1
- package/dist/web/assets/use-router-link-Dr9wnnyZ.js +0 -1
- package/dist/web/assets/use-row-height-DQHVMtUe.js +0 -1
- package/dist/web/assets/use-server-events-BrBCbeHu.js +0 -1
- package/dist/web/assets/use-virtual-scroll-DG0UKjVk.js +0 -1
- package/dist/web/assets/weighted-lru-BSxRnMHR.js +0 -1
- /package/dist/web/assets/{PanelResize-XjrbOj2S.css → AddToAgentButton-XjrbOj2S.css} +0 -0
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
import { ArtifactSearchService } from "./artifact-search.service.js";
|
|
2
|
+
import { ArtifactLifecycleService } from "./artifact-lifecycle.service.js";
|
|
3
|
+
import { takeWithinBytes } from "../utils/take-within-bytes.js";
|
|
4
|
+
import { ArtifactTypeService } from "./artifact-type.service.js";
|
|
5
|
+
import { TaskService } from "./task.service.js";
|
|
6
|
+
import { ArtifactGraphService } from "./artifact-graph.service.js";
|
|
7
|
+
import { artifactIssues } from "./artifact-graph-validation.js";
|
|
8
|
+
import { ArtifactGraphRepository } from "../repositories/artifact-graph.repo.js";
|
|
9
|
+
import { TaskRepository } from "../repositories/task.repo.js";
|
|
10
|
+
import { normalizeArtifact } from "../../shared/artifacts/normalize.js";
|
|
11
|
+
import { ArtifactGraphFields } from "../../shared/artifacts/schemas.js";
|
|
12
|
+
import { randomUUID } from 'node:crypto';
|
|
13
|
+
import { stringify } from 'yaml';
|
|
14
|
+
import { Value } from '@sinclair/typebox/value';
|
|
15
|
+
import { ArtifactActorSchema, ArtifactMetadataInputSchema } from "../../shared/artifacts/schemas.js";
|
|
16
|
+
import { MAX_ARTIFACT_BODY_BYTES, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_CHUNK_BYTES, MAX_ARTIFACT_METADATA_BYTES, MAX_ARTIFACT_PAGE_SIZE } from "../../shared/artifacts/constants.js";
|
|
17
|
+
import { isUuid } from "../../shared/utils/is-uuid.js";
|
|
18
|
+
import { ArtifactConflictError, ArtifactInputError, ArtifactIntegrityError, ArtifactNotFoundError, ArtifactTooLargeError } from "../errors/artifacts.js";
|
|
19
|
+
import { ArtifactCatalogRepository } from "../repositories/artifact-catalog.repo.js";
|
|
20
|
+
import { ArtifactFilesRepository } from "../repositories/artifact-files.repo.js";
|
|
21
|
+
import { sha256Hex } from "../utils/hash.js";
|
|
22
|
+
// Recover a stopped owner without taking an active writer's operation.
|
|
23
|
+
const OPERATION_LEASE_MS = 30_000;
|
|
24
|
+
// Fix the property order so equal identities give equal payload hashes.
|
|
25
|
+
function canonicalActor(actor) {
|
|
26
|
+
return { kind: actor.kind, id: actor.id };
|
|
27
|
+
}
|
|
28
|
+
// Compare code units, not locale rules, so hashes do not depend on the locale.
|
|
29
|
+
function compareText(left, right) {
|
|
30
|
+
if (left === right)
|
|
31
|
+
return 0;
|
|
32
|
+
return left < right ? -1 : 1;
|
|
33
|
+
}
|
|
34
|
+
// Task and relation lists are sets: their order must not change a request hash.
|
|
35
|
+
function sortedTaskIds(taskIds) {
|
|
36
|
+
return [...taskIds].sort(compareText);
|
|
37
|
+
}
|
|
38
|
+
function sortedRelations(relations) {
|
|
39
|
+
return relations
|
|
40
|
+
.map(relation => ({ kind: relation.kind, targetId: relation.targetId }))
|
|
41
|
+
.sort((left, right) => compareText(`${left.kind}:${left.targetId}`, `${right.kind}:${right.targetId}`));
|
|
42
|
+
}
|
|
43
|
+
function graphPayload(metadata) {
|
|
44
|
+
return {
|
|
45
|
+
...(metadata.sourcePath === undefined
|
|
46
|
+
? {}
|
|
47
|
+
: { sourcePath: metadata.sourcePath }),
|
|
48
|
+
...(metadata.typeId === undefined ? {} : { typeId: metadata.typeId }),
|
|
49
|
+
...(metadata.taskIds === undefined
|
|
50
|
+
? {}
|
|
51
|
+
: { taskIds: sortedTaskIds(metadata.taskIds) }),
|
|
52
|
+
...(metadata.relations === undefined
|
|
53
|
+
? {}
|
|
54
|
+
: { relations: sortedRelations(metadata.relations) })
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export class ArtifactStorageService {
|
|
58
|
+
search;
|
|
59
|
+
lifecycle;
|
|
60
|
+
files;
|
|
61
|
+
types;
|
|
62
|
+
tasks;
|
|
63
|
+
graph;
|
|
64
|
+
graphRepository;
|
|
65
|
+
definitions;
|
|
66
|
+
catalog;
|
|
67
|
+
owner = randomUUID();
|
|
68
|
+
options;
|
|
69
|
+
now;
|
|
70
|
+
observedEpoch;
|
|
71
|
+
constructor(options) {
|
|
72
|
+
this.options = options;
|
|
73
|
+
this.now = options.now ?? Date.now;
|
|
74
|
+
this.files = new ArtifactFilesRepository(options.repositoryPath, options.prefix);
|
|
75
|
+
this.catalog = new ArtifactCatalogRepository(options.db, this.files.repositoryPath, options.prefix);
|
|
76
|
+
this.search = new ArtifactSearchService(this, options.db);
|
|
77
|
+
this.catalog.onMetadata = artifact => this.search.index(artifact);
|
|
78
|
+
this.definitions = new TaskRepository(options.db, this.storeId);
|
|
79
|
+
const definitions = {
|
|
80
|
+
repository: this.definitions,
|
|
81
|
+
catalog: this.catalog,
|
|
82
|
+
onChange: () => this.pollChanges(),
|
|
83
|
+
now: this.now
|
|
84
|
+
};
|
|
85
|
+
this.types = new ArtifactTypeService(definitions);
|
|
86
|
+
this.tasks = new TaskService(definitions);
|
|
87
|
+
this.graphRepository = new ArtifactGraphRepository(options.db, this.catalog);
|
|
88
|
+
this.graph = new ArtifactGraphService(this);
|
|
89
|
+
this.lifecycle = new ArtifactLifecycleService(this, options.db, this.now);
|
|
90
|
+
this.observedEpoch = this.catalog.epoch();
|
|
91
|
+
}
|
|
92
|
+
get storeId() {
|
|
93
|
+
return this.catalog.storeId;
|
|
94
|
+
}
|
|
95
|
+
validate(requestId, metadata, actor) {
|
|
96
|
+
if (typeof requestId !== 'string' ||
|
|
97
|
+
requestId.length < 1 ||
|
|
98
|
+
requestId.length > 128) {
|
|
99
|
+
throw new ArtifactInputError('Invalid artifact request identifier.');
|
|
100
|
+
}
|
|
101
|
+
if (!Value.Check(ArtifactMetadataInputSchema, metadata) ||
|
|
102
|
+
!metadata.title.trim()) {
|
|
103
|
+
throw new ArtifactInputError('Invalid artifact metadata.');
|
|
104
|
+
}
|
|
105
|
+
if (!Value.Check(ArtifactActorSchema, actor)) {
|
|
106
|
+
throw new ArtifactInputError('Invalid artifact actor.');
|
|
107
|
+
}
|
|
108
|
+
if (Buffer.byteLength(JSON.stringify(metadata)) > MAX_ARTIFACT_METADATA_BYTES) {
|
|
109
|
+
throw new ArtifactTooLargeError();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
fileName(id) {
|
|
113
|
+
if (!isUuid(id)) {
|
|
114
|
+
throw new ArtifactInputError('Invalid artifact identifier.');
|
|
115
|
+
}
|
|
116
|
+
return `${this.files.prefix}${id}.md`;
|
|
117
|
+
}
|
|
118
|
+
document(artifact, body) {
|
|
119
|
+
const header = stringify({
|
|
120
|
+
schema_version: 1,
|
|
121
|
+
store_id: this.storeId,
|
|
122
|
+
artifact_id: artifact.id,
|
|
123
|
+
title: artifact.title,
|
|
124
|
+
...(artifact.sourcePath === undefined
|
|
125
|
+
? {}
|
|
126
|
+
: { source_path: artifact.sourcePath }),
|
|
127
|
+
type_id: artifact.typeId,
|
|
128
|
+
status: artifact.status,
|
|
129
|
+
created_at: artifact.createdAt,
|
|
130
|
+
metadata_updated_at: artifact.createdAt,
|
|
131
|
+
task_ids: artifact.taskIds ?? [],
|
|
132
|
+
tags: artifact.tags,
|
|
133
|
+
relations: (artifact.relations ?? []).map(relation => ({
|
|
134
|
+
kind: relation.kind,
|
|
135
|
+
target_id: relation.targetId
|
|
136
|
+
})),
|
|
137
|
+
revision_of: artifact.revisionOf ?? []
|
|
138
|
+
});
|
|
139
|
+
return Buffer.from(`---\n${header}---\n${body}`, 'utf8');
|
|
140
|
+
}
|
|
141
|
+
create(input, suppliedActor, turn) {
|
|
142
|
+
return this.createArtifact(input, suppliedActor, undefined, turn);
|
|
143
|
+
}
|
|
144
|
+
// Recovery must wait for the caller to recheck its scope and join this commit.
|
|
145
|
+
createWithCommit(input, suppliedActor, commit) {
|
|
146
|
+
return this.createArtifact(input, suppliedActor, commit);
|
|
147
|
+
}
|
|
148
|
+
createArtifact(input, suppliedActor, commit, turn) {
|
|
149
|
+
this.validate(input.requestId, input.metadata, suppliedActor);
|
|
150
|
+
const actor = canonicalActor(suppliedActor);
|
|
151
|
+
if (!Value.Check(ArtifactGraphFields.revisionOf, input.revisionOf ?? [])) {
|
|
152
|
+
throw new ArtifactInputError('Invalid revision lineage.');
|
|
153
|
+
}
|
|
154
|
+
if (typeof input.body !== 'string' || input.body.includes('\0')) {
|
|
155
|
+
throw new ArtifactInputError('Artifact body must be valid UTF-8 text without NUL.');
|
|
156
|
+
}
|
|
157
|
+
if (Buffer.byteLength(input.body) > MAX_ARTIFACT_BODY_BYTES) {
|
|
158
|
+
throw new ArtifactTooLargeError();
|
|
159
|
+
}
|
|
160
|
+
if (Buffer.from(input.body).toString('utf8') !== input.body) {
|
|
161
|
+
throw new ArtifactInputError('Artifact body must be valid UTF-8 text.');
|
|
162
|
+
}
|
|
163
|
+
const payloadHash = sha256Hex(JSON.stringify({
|
|
164
|
+
kind: 'create',
|
|
165
|
+
body: input.body,
|
|
166
|
+
title: input.metadata.title,
|
|
167
|
+
tags: input.metadata.tags,
|
|
168
|
+
...graphPayload(input.metadata),
|
|
169
|
+
...(input.revisionOf === undefined
|
|
170
|
+
? {}
|
|
171
|
+
: { revisionOf: input.revisionOf }),
|
|
172
|
+
actor
|
|
173
|
+
}));
|
|
174
|
+
const operation = this.catalog.transaction(() => {
|
|
175
|
+
this.definitions.assertArtifactRequest(input.requestId);
|
|
176
|
+
const previous = this.catalog.operation(input.requestId);
|
|
177
|
+
if (previous) {
|
|
178
|
+
this.checkReplay(previous, payloadHash);
|
|
179
|
+
if (previous.data.callerCommit && !commit) {
|
|
180
|
+
throw new ArtifactConflictError('This artifact requires its caller commit.');
|
|
181
|
+
}
|
|
182
|
+
if (previous.state !== 'committed') {
|
|
183
|
+
this.catalog.claim(input.requestId, this.owner, this.now(), OPERATION_LEASE_MS);
|
|
184
|
+
}
|
|
185
|
+
return previous;
|
|
186
|
+
}
|
|
187
|
+
// Resolve only new operations; retries retain the originally reserved task IDs.
|
|
188
|
+
const inherited = input.metadata.taskIds === undefined &&
|
|
189
|
+
actor.kind === 'agent' &&
|
|
190
|
+
turn?.sessionId === actor.id &&
|
|
191
|
+
turn.taskIds.length === 1;
|
|
192
|
+
const taskIds = input.metadata.taskIds ?? (inherited ? turn.taskIds : []);
|
|
193
|
+
const now = new Date(this.now()).toISOString();
|
|
194
|
+
const artifact = {
|
|
195
|
+
storeId: this.storeId,
|
|
196
|
+
id: randomUUID(),
|
|
197
|
+
sha256: '',
|
|
198
|
+
bytes: 0,
|
|
199
|
+
bodyStartLine: 0,
|
|
200
|
+
createdAt: now,
|
|
201
|
+
metadataVersion: 1,
|
|
202
|
+
metadataUpdatedAt: now,
|
|
203
|
+
title: input.metadata.title,
|
|
204
|
+
...(input.metadata.sourcePath === undefined
|
|
205
|
+
? {}
|
|
206
|
+
: { sourcePath: input.metadata.sourcePath }),
|
|
207
|
+
tags: [...input.metadata.tags],
|
|
208
|
+
typeId: input.metadata.typeId ?? 'generic',
|
|
209
|
+
taskIds: [...taskIds],
|
|
210
|
+
relations: structuredClone(input.metadata.relations ?? []),
|
|
211
|
+
revisionOf: [...(input.revisionOf ?? [])],
|
|
212
|
+
status: 'draft'
|
|
213
|
+
};
|
|
214
|
+
this.validateGraph(artifact);
|
|
215
|
+
const content = this.document(artifact, input.body);
|
|
216
|
+
if (content.length > MAX_ARTIFACT_BYTES)
|
|
217
|
+
throw new ArtifactTooLargeError();
|
|
218
|
+
const headerBytes = content.length - Buffer.byteLength(input.body);
|
|
219
|
+
artifact.sha256 = sha256Hex(content);
|
|
220
|
+
artifact.bytes = content.length;
|
|
221
|
+
artifact.bodyStartLine = content
|
|
222
|
+
.subarray(0, headerBytes)
|
|
223
|
+
.toString('utf8')
|
|
224
|
+
.split('\n').length;
|
|
225
|
+
const fileName = this.fileName(artifact.id);
|
|
226
|
+
const data = {
|
|
227
|
+
artifact,
|
|
228
|
+
taskBinding: inherited
|
|
229
|
+
? turn.source === 'turn_activation'
|
|
230
|
+
? {
|
|
231
|
+
source: 'turn_activation',
|
|
232
|
+
sessionId: turn.sessionId,
|
|
233
|
+
turnId: turn.turnId,
|
|
234
|
+
assignmentVersion: turn.assignmentVersion,
|
|
235
|
+
activationRequestId: turn.activationRequestId
|
|
236
|
+
}
|
|
237
|
+
: {
|
|
238
|
+
source: 'turn_assignment',
|
|
239
|
+
sessionId: turn.sessionId,
|
|
240
|
+
turnId: turn.turnId,
|
|
241
|
+
assignmentVersion: turn.assignmentVersion
|
|
242
|
+
}
|
|
243
|
+
: {
|
|
244
|
+
source: input.metadata.taskIds === undefined
|
|
245
|
+
? 'legacy_default'
|
|
246
|
+
: 'explicit'
|
|
247
|
+
},
|
|
248
|
+
actor: { ...actor },
|
|
249
|
+
fileName,
|
|
250
|
+
tempName: `${fileName}.${randomUUID()}.tmp`,
|
|
251
|
+
...(commit ? { callerCommit: true } : {})
|
|
252
|
+
};
|
|
253
|
+
const created = {
|
|
254
|
+
requestId: input.requestId,
|
|
255
|
+
payloadHash,
|
|
256
|
+
artifactId: artifact.id,
|
|
257
|
+
kind: 'create',
|
|
258
|
+
data,
|
|
259
|
+
state: 'pending'
|
|
260
|
+
};
|
|
261
|
+
this.catalog.reserve(created, now);
|
|
262
|
+
this.catalog.claim(input.requestId, this.owner, this.now(), OPERATION_LEASE_MS);
|
|
263
|
+
return created;
|
|
264
|
+
});
|
|
265
|
+
if (operation.state === 'committed') {
|
|
266
|
+
this.files.verify(operation.data.fileName, operation.data.artifact.sha256, operation.data.artifact.bytes);
|
|
267
|
+
const artifact = normalizeArtifact(operation.data.artifact);
|
|
268
|
+
if (commit)
|
|
269
|
+
this.catalog.transaction(() => commit(artifact));
|
|
270
|
+
return artifact;
|
|
271
|
+
}
|
|
272
|
+
this.checkpoint('reserved', operation.data);
|
|
273
|
+
const content = this.document(operation.data.artifact, input.body);
|
|
274
|
+
if (sha256Hex(content) !== operation.data.artifact.sha256) {
|
|
275
|
+
throw new ArtifactIntegrityError('Reserved artifact content cannot be reproduced.');
|
|
276
|
+
}
|
|
277
|
+
return this.finish(operation, content, commit);
|
|
278
|
+
}
|
|
279
|
+
checkReplay(operation, payloadHash) {
|
|
280
|
+
if (operation.payloadHash !== payloadHash) {
|
|
281
|
+
throw new ArtifactConflictError('Request identifier was already used for a different operation.');
|
|
282
|
+
}
|
|
283
|
+
if (operation.state === 'failed') {
|
|
284
|
+
throw new ArtifactIntegrityError('Artifact operation failed; inspect storage diagnostics.');
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
checkpoint(phase, data) {
|
|
288
|
+
this.options.checkpoint?.(phase, data);
|
|
289
|
+
}
|
|
290
|
+
finish(operation, supplied, commit) {
|
|
291
|
+
const data = operation.data;
|
|
292
|
+
const { artifact } = data;
|
|
293
|
+
this.catalog.assertOwner(operation.requestId, this.owner, this.now());
|
|
294
|
+
const final = this.files.read(data.fileName);
|
|
295
|
+
if (final) {
|
|
296
|
+
this.files.verify(data.fileName, artifact.sha256, artifact.bytes);
|
|
297
|
+
this.files.syncFile(data.fileName);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
const temp = this.files.read(data.tempName);
|
|
301
|
+
if (!temp ||
|
|
302
|
+
temp.length !== artifact.bytes ||
|
|
303
|
+
sha256Hex(temp) !== artifact.sha256) {
|
|
304
|
+
if (!supplied) {
|
|
305
|
+
throw new ArtifactInputError('Artifact content must be supplied again.');
|
|
306
|
+
}
|
|
307
|
+
this.catalog.assertOwner(operation.requestId, this.owner, this.now());
|
|
308
|
+
if (temp)
|
|
309
|
+
this.files.removeTemp(data.tempName);
|
|
310
|
+
this.files.writeTemp(data.tempName, supplied);
|
|
311
|
+
}
|
|
312
|
+
this.checkpoint('temp_synced', data);
|
|
313
|
+
this.catalog.assertOwner(operation.requestId, this.owner, this.now());
|
|
314
|
+
this.files.publish(data.tempName, data.fileName, artifact.sha256, artifact.bytes);
|
|
315
|
+
}
|
|
316
|
+
this.checkpoint('published', data);
|
|
317
|
+
this.checkpoint('before_commit', data);
|
|
318
|
+
this.catalog.transaction(() => {
|
|
319
|
+
this.catalog.assertOwner(operation.requestId, this.owner, this.now());
|
|
320
|
+
this.files.verify(data.fileName, artifact.sha256, artifact.bytes);
|
|
321
|
+
commit?.(normalizeArtifact(artifact));
|
|
322
|
+
this.catalog.insertArtifact(data);
|
|
323
|
+
this.graphRepository.appendLineage(normalizeArtifact(artifact));
|
|
324
|
+
this.catalog.appendMetadata(normalizeArtifact(artifact), operation.requestId, data.actor, 'created');
|
|
325
|
+
this.catalog.transition(operation.requestId, 'committed', new Date(this.now()).toISOString());
|
|
326
|
+
this.catalog.release(operation.requestId, this.owner);
|
|
327
|
+
});
|
|
328
|
+
this.checkpoint('after_commit', data);
|
|
329
|
+
this.files.removeTemp(data.tempName);
|
|
330
|
+
this.pollChanges();
|
|
331
|
+
return normalizeArtifact(artifact);
|
|
332
|
+
}
|
|
333
|
+
recover(cleanupCommitted = true) {
|
|
334
|
+
const result = {
|
|
335
|
+
recovered: [],
|
|
336
|
+
awaitingRetry: [],
|
|
337
|
+
failed: [],
|
|
338
|
+
busy: []
|
|
339
|
+
};
|
|
340
|
+
const failures = [];
|
|
341
|
+
for (const operation of this.catalog.operations(cleanupCommitted)) {
|
|
342
|
+
try {
|
|
343
|
+
this.recoverOne(operation, result);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
// One failed operation must not block the operations after it.
|
|
347
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
348
|
+
failures.push(new Error(`Artifact operation ${operation.requestId}: ${cause.message}`, {
|
|
349
|
+
cause
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (failures.length === 1)
|
|
354
|
+
throw failures[0].cause;
|
|
355
|
+
if (failures.length > 1) {
|
|
356
|
+
throw new AggregateError(failures.map(failure => failure.cause), failures.map(failure => failure.message).join('; '));
|
|
357
|
+
}
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
recoverOne(listed, result) {
|
|
361
|
+
let operation = listed;
|
|
362
|
+
if (operation.state === 'failed') {
|
|
363
|
+
result.failed.push(operation.artifactId);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
if (operation.state === 'committed') {
|
|
367
|
+
this.files.removeTemp(operation.data.tempName);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
try {
|
|
371
|
+
operation = this.catalog.transaction(() => {
|
|
372
|
+
const current = this.catalog.operation(operation.requestId);
|
|
373
|
+
if (current.state !== 'committed' && current.state !== 'failed') {
|
|
374
|
+
this.catalog.claim(current.requestId, this.owner, this.now(), OPERATION_LEASE_MS);
|
|
375
|
+
}
|
|
376
|
+
return current;
|
|
377
|
+
});
|
|
378
|
+
if (operation.state === 'committed' || operation.state === 'failed') {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
if (!(error instanceof ArtifactConflictError))
|
|
384
|
+
throw error;
|
|
385
|
+
result.busy.push(operation.artifactId);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (operation.data.callerCommit) {
|
|
389
|
+
this.catalog.transaction(() => {
|
|
390
|
+
this.catalog.assertOwner(operation.requestId, this.owner, this.now());
|
|
391
|
+
if (operation.state !== 'awaiting_retry') {
|
|
392
|
+
this.catalog.transition(operation.requestId, 'awaiting_retry', new Date(this.now()).toISOString());
|
|
393
|
+
}
|
|
394
|
+
this.catalog.release(operation.requestId, this.owner);
|
|
395
|
+
});
|
|
396
|
+
result.awaitingRetry.push(operation.artifactId);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
try {
|
|
400
|
+
this.finish(operation);
|
|
401
|
+
result.recovered.push(operation.artifactId);
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
if (this.catalog.operation(operation.requestId)?.state === 'committed') {
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
407
|
+
if (!(error instanceof ArtifactInputError) &&
|
|
408
|
+
!(error instanceof ArtifactIntegrityError)) {
|
|
409
|
+
try {
|
|
410
|
+
this.catalog.release(operation.requestId, this.owner);
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
// The original failure is the useful one; the lease expires by itself.
|
|
414
|
+
}
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
417
|
+
const state = error instanceof ArtifactInputError ? 'awaiting_retry' : 'failed';
|
|
418
|
+
this.catalog.transaction(() => {
|
|
419
|
+
this.catalog.assertOwner(operation.requestId, this.owner, this.now());
|
|
420
|
+
if (operation.state !== state) {
|
|
421
|
+
this.catalog.transition(operation.requestId, state, new Date(this.now()).toISOString());
|
|
422
|
+
}
|
|
423
|
+
this.catalog.release(operation.requestId, this.owner);
|
|
424
|
+
});
|
|
425
|
+
result[state === 'awaiting_retry' ? 'awaitingRetry' : 'failed'].push(operation.artifactId);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
diagnostics() {
|
|
429
|
+
const operations = this.catalog.operations();
|
|
430
|
+
const known = new Set(operations.flatMap(operation => [
|
|
431
|
+
operation.data.fileName,
|
|
432
|
+
operation.data.tempName
|
|
433
|
+
]));
|
|
434
|
+
return {
|
|
435
|
+
orphanFiles: this.files.names().filter(name => !known.has(name)),
|
|
436
|
+
operations: operations.map(operation => ({
|
|
437
|
+
artifactId: operation.artifactId,
|
|
438
|
+
state: operation.state
|
|
439
|
+
}))
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
get(id) {
|
|
443
|
+
this.fileName(id);
|
|
444
|
+
const artifact = this.catalog.get(id);
|
|
445
|
+
if (!artifact)
|
|
446
|
+
throw new ArtifactNotFoundError();
|
|
447
|
+
return artifact;
|
|
448
|
+
}
|
|
449
|
+
readVerifiedFile(id) {
|
|
450
|
+
const artifact = this.get(id);
|
|
451
|
+
const content = this.files.verify(this.fileName(id), artifact.sha256, artifact.bytes);
|
|
452
|
+
return { artifact, content };
|
|
453
|
+
}
|
|
454
|
+
readContent(id, offset = 0, limit = MAX_ARTIFACT_CHUNK_BYTES) {
|
|
455
|
+
if (!Number.isSafeInteger(offset) ||
|
|
456
|
+
offset < 0 ||
|
|
457
|
+
!Number.isInteger(limit) ||
|
|
458
|
+
limit < 4 ||
|
|
459
|
+
limit > MAX_ARTIFACT_CHUNK_BYTES) {
|
|
460
|
+
throw new ArtifactInputError('Invalid content range.');
|
|
461
|
+
}
|
|
462
|
+
const { artifact, content } = this.readVerifiedFile(id);
|
|
463
|
+
if (offset > content.length ||
|
|
464
|
+
(offset < content.length && (content[offset] & 0xc0) === 0x80)) {
|
|
465
|
+
throw new ArtifactInputError('Content offset must be a UTF-8 boundary.');
|
|
466
|
+
}
|
|
467
|
+
let end = Math.min(offset + limit, content.length);
|
|
468
|
+
while (end < content.length && (content[end] & 0xc0) === 0x80)
|
|
469
|
+
end--;
|
|
470
|
+
return {
|
|
471
|
+
storeId: this.storeId,
|
|
472
|
+
id,
|
|
473
|
+
sha256: artifact.sha256,
|
|
474
|
+
bodyStartLine: artifact.bodyStartLine,
|
|
475
|
+
totalBytes: content.length,
|
|
476
|
+
offset,
|
|
477
|
+
nextOffset: end < content.length ? end : null,
|
|
478
|
+
text: content.subarray(offset, end).toString('utf8')
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
list(limit = 50, cursor) {
|
|
482
|
+
return this.catalog.readSnapshot(() => this.listSnapshot(limit, cursor));
|
|
483
|
+
}
|
|
484
|
+
listSnapshot(limit, cursor) {
|
|
485
|
+
this.assertLimit(limit);
|
|
486
|
+
const epoch = this.catalog.epoch();
|
|
487
|
+
let after;
|
|
488
|
+
if (cursor) {
|
|
489
|
+
let decoded;
|
|
490
|
+
try {
|
|
491
|
+
decoded = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
|
|
492
|
+
}
|
|
493
|
+
catch {
|
|
494
|
+
throw new ArtifactInputError('Invalid artifact cursor.');
|
|
495
|
+
}
|
|
496
|
+
if (!decoded ||
|
|
497
|
+
decoded.storeId !== this.storeId ||
|
|
498
|
+
typeof decoded.createdAt !== 'string' ||
|
|
499
|
+
!isUuid(decoded.id)) {
|
|
500
|
+
throw new ArtifactInputError('Invalid artifact cursor.');
|
|
501
|
+
}
|
|
502
|
+
if (decoded.epoch !== epoch) {
|
|
503
|
+
throw new ArtifactConflictError('Artifact catalog changed. Restart pagination.');
|
|
504
|
+
}
|
|
505
|
+
after = { createdAt: decoded.createdAt, id: decoded.id };
|
|
506
|
+
}
|
|
507
|
+
const rows = this.catalog.list(limit + 1, after);
|
|
508
|
+
const items = takeWithinBytes(rows, limit);
|
|
509
|
+
const last = items.at(-1);
|
|
510
|
+
const nextCursor = rows.length > items.length && last
|
|
511
|
+
? Buffer.from(JSON.stringify({
|
|
512
|
+
storeId: this.storeId,
|
|
513
|
+
epoch,
|
|
514
|
+
createdAt: last.createdAt,
|
|
515
|
+
id: last.id
|
|
516
|
+
})).toString('base64url')
|
|
517
|
+
: null;
|
|
518
|
+
return { storeId: this.storeId, storeEpoch: epoch, items, nextCursor };
|
|
519
|
+
}
|
|
520
|
+
history(id, afterSeq = 0, limit = 50) {
|
|
521
|
+
this.get(id);
|
|
522
|
+
this.assertLimit(limit);
|
|
523
|
+
if (!Number.isSafeInteger(afterSeq) || afterSeq < 0) {
|
|
524
|
+
throw new ArtifactInputError('Invalid history sequence.');
|
|
525
|
+
}
|
|
526
|
+
const rows = this.catalog.history(id, afterSeq, limit + 1);
|
|
527
|
+
const items = takeWithinBytes(rows, limit);
|
|
528
|
+
return {
|
|
529
|
+
storeId: this.storeId,
|
|
530
|
+
items,
|
|
531
|
+
nextAfterSeq: rows.length > items.length ? items.at(-1).seq : null
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
updateMetadata(id, input, suppliedActor) {
|
|
535
|
+
this.validate(input.requestId, input.metadata, suppliedActor);
|
|
536
|
+
const actor = canonicalActor(suppliedActor);
|
|
537
|
+
this.fileName(id);
|
|
538
|
+
if (!Number.isSafeInteger(input.expectedVersion) ||
|
|
539
|
+
input.expectedVersion < 1) {
|
|
540
|
+
throw new ArtifactInputError('Invalid metadata version.');
|
|
541
|
+
}
|
|
542
|
+
const payloadHash = sha256Hex(JSON.stringify({
|
|
543
|
+
kind: 'metadata',
|
|
544
|
+
id,
|
|
545
|
+
expectedVersion: input.expectedVersion,
|
|
546
|
+
title: input.metadata.title,
|
|
547
|
+
tags: input.metadata.tags,
|
|
548
|
+
...graphPayload(input.metadata),
|
|
549
|
+
actor
|
|
550
|
+
}));
|
|
551
|
+
const result = this.catalog.transaction(() => {
|
|
552
|
+
this.definitions.assertArtifactRequest(input.requestId);
|
|
553
|
+
const existing = this.catalog.operation(input.requestId);
|
|
554
|
+
if (existing) {
|
|
555
|
+
this.checkReplay(existing, payloadHash);
|
|
556
|
+
return normalizeArtifact(existing.data.artifact);
|
|
557
|
+
}
|
|
558
|
+
const previous = this.get(id);
|
|
559
|
+
if (previous.metadataVersion !== input.expectedVersion) {
|
|
560
|
+
throw new ArtifactConflictError('Artifact metadata version changed.');
|
|
561
|
+
}
|
|
562
|
+
this.files.verify(this.fileName(id), previous.sha256, previous.bytes);
|
|
563
|
+
const updated = {
|
|
564
|
+
...previous,
|
|
565
|
+
...(input.metadata.sourcePath === undefined
|
|
566
|
+
? {}
|
|
567
|
+
: { sourcePath: input.metadata.sourcePath }),
|
|
568
|
+
title: input.metadata.title,
|
|
569
|
+
tags: [...input.metadata.tags],
|
|
570
|
+
typeId: input.metadata.typeId ?? previous.typeId,
|
|
571
|
+
taskIds: [...(input.metadata.taskIds ?? previous.taskIds)],
|
|
572
|
+
relations: structuredClone(input.metadata.relations ?? previous.relations),
|
|
573
|
+
metadataVersion: previous.metadataVersion + 1,
|
|
574
|
+
metadataUpdatedAt: new Date(this.now()).toISOString()
|
|
575
|
+
};
|
|
576
|
+
if (previous.status === 'accepted' &&
|
|
577
|
+
(JSON.stringify(sortedRelations(updated.relations)) !==
|
|
578
|
+
JSON.stringify(sortedRelations(previous.relations)) ||
|
|
579
|
+
JSON.stringify(sortedTaskIds(updated.taskIds)) !==
|
|
580
|
+
JSON.stringify(sortedTaskIds(previous.taskIds)))) {
|
|
581
|
+
throw new ArtifactConflictError('Active graph changes require a validated change set.');
|
|
582
|
+
}
|
|
583
|
+
this.validateGraph(updated, previous);
|
|
584
|
+
this.catalog.reserve({
|
|
585
|
+
requestId: input.requestId,
|
|
586
|
+
kind: 'metadata',
|
|
587
|
+
payloadHash,
|
|
588
|
+
artifactId: id,
|
|
589
|
+
data: {
|
|
590
|
+
artifact: updated,
|
|
591
|
+
actor,
|
|
592
|
+
fileName: this.fileName(id),
|
|
593
|
+
tempName: ''
|
|
594
|
+
}
|
|
595
|
+
}, updated.metadataUpdatedAt);
|
|
596
|
+
this.catalog.appendMetadata(updated, input.requestId, actor, 'metadata_updated');
|
|
597
|
+
this.catalog.transition(input.requestId, 'committed', updated.metadataUpdatedAt);
|
|
598
|
+
return updated;
|
|
599
|
+
});
|
|
600
|
+
this.pollChanges();
|
|
601
|
+
return result;
|
|
602
|
+
}
|
|
603
|
+
// A missing reference in the request body is bad input, not a missing resource.
|
|
604
|
+
reference(read, kind, id) {
|
|
605
|
+
try {
|
|
606
|
+
return read();
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
if (error instanceof ArtifactNotFoundError) {
|
|
610
|
+
throw new ArtifactInputError(`Unknown artifact ${kind} "${id}".`);
|
|
611
|
+
}
|
|
612
|
+
throw error;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
validateGraph(artifact, previous) {
|
|
616
|
+
const type = this.reference(() => this.types.get(artifact.typeId), 'type', artifact.typeId);
|
|
617
|
+
if (!type.active && (!previous || previous.typeId !== artifact.typeId)) {
|
|
618
|
+
throw new ArtifactInputError('Artifact type is inactive.');
|
|
619
|
+
}
|
|
620
|
+
for (const taskId of artifact.taskIds) {
|
|
621
|
+
this.reference(() => this.tasks.get(taskId), 'task', taskId);
|
|
622
|
+
}
|
|
623
|
+
const issues = artifactIssues(artifact, id => this.catalog.get(id), this.storeId);
|
|
624
|
+
if (issues.length) {
|
|
625
|
+
throw new ArtifactInputError(issues.map(issue => issue.message).join(' '));
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
assertLimit(limit) {
|
|
629
|
+
if (!Number.isInteger(limit) ||
|
|
630
|
+
limit < 1 ||
|
|
631
|
+
limit > MAX_ARTIFACT_PAGE_SIZE) {
|
|
632
|
+
throw new ArtifactInputError('Invalid page size.');
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
pollChanges() {
|
|
636
|
+
const epoch = this.catalog.epoch();
|
|
637
|
+
if (epoch === this.observedEpoch)
|
|
638
|
+
return;
|
|
639
|
+
this.observedEpoch = epoch;
|
|
640
|
+
this.options.eventBus?.publish({
|
|
641
|
+
type: 'artifacts:changed',
|
|
642
|
+
storeId: this.storeId,
|
|
643
|
+
storeEpoch: epoch
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
}
|