@inneranimalmedia/agentsam-sdk 2.6.12 → 2.6.13
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/AGENTSAM.md +32 -0
- package/DEVELOPMENT.md +69 -74
- package/README.md +11 -0
- package/apps/cad-creator/README.md +12 -0
- package/apps/cad-creator/shared/cad/package.json +1 -1
- package/apps/cad-creator/shared/cad/src/domain/project-contract.js +2 -75
- package/apps/cad-creator/shared/cad/src/domain/project-tools.js +2 -24
- package/apps/cad-creator/shared/cad/src/types.ts +2 -2
- package/apps/client-cms-editor/backend/package.json +2 -2
- package/apps/client-cms-editor/frontend/package.json +3 -3
- package/apps/client-cms-editor/frontend/src/adapters/http.ts +25 -13
- package/apps/client-cms-editor/frontend/src/editor/CmsEditor.tsx +7 -4
- package/apps/client-cms-editor/frontend/src/editor/canvas/PreviewCanvas.tsx +31 -3
- package/apps/client-cms-editor/frontend/src/editor/host-preview.test.tsx +104 -0
- package/apps/client-cms-editor/package-lock.json +8 -8
- package/apps/client-cms-editor/package.json +2 -1
- package/apps/client-cms-editor/shared/cms/package.json +1 -1
- package/docs/AUTORAG.md +2 -0
- package/docs/CAPABILITIES.md +28 -0
- package/docs/adr/ADR-0003-copro-clean-room-product-architecture.md +6 -0
- package/docs/architecture/AGENTSAM-CANONICAL-DISCOVERY-FIRST-SLICE.md +70 -0
- package/docs/architecture/AGENTSAM-REGISTRY-CLI-AGENT-PARITY.md +133 -0
- package/docs/architecture/AGENTSAM_APPLICATION_CONTRACT.md +6 -0
- package/docs/architecture/CAD_OPERATOR_CAPABILITIES.md +64 -0
- package/docs/architecture/CAD_ROBOTICS_RELEASE_LEDGER_20261016.md +43 -0
- package/docs/architecture/CAD_RUN_MODES.md +34 -0
- package/docs/architecture/CLI-BOOT-REMOTE-DB-READINESS-20261015.md +65 -0
- package/docs/architecture/EXISTING-MCP-D1-AGENT-BRIDGE.md +47 -0
- package/docs/architecture/PLAN-PORTABILITY-SAM-FIRST-SPRINT-20261015.md +36 -0
- package/docs/architecture/PLUGIN-PRODUCTIZATION-SPINE.md +101 -0
- package/docs/architecture/SAMOS_PRODUCT_MODEL.md +49 -0
- package/docs/architecture/SAM_KERNEL.md +40 -0
- package/docs/architecture/SAM_RESOURCE_CRUD_STANDARD.md +96 -0
- package/docs/architecture/SAM_SYSTEMATIC_AUTONOMOUS_MACHINERY.md +79 -0
- package/docs/architecture/USER_GLOBAL_AGENT_INSTRUCTIONS.md +55 -0
- package/docs/autorag-workflow.md +13 -0
- package/docs/brand/AGENT_SAM_ICON_GRAMMAR.md +4 -0
- package/docs/contracts/capability-install-planner.md +66 -38
- package/docs/contracts/environment-vocabulary.md +5 -5
- package/docs/engineering/SUPERBASH_LOCAL_RUNTIME.md +100 -0
- package/docs/generated/SDK_CAPABILITY_INVENTORY.md +313 -0
- package/docs/handoffs/AGENT_HANDOFF_SUPERBASH_AND_MODEL_PERFORMANCE_2026-10-14.md +134 -0
- package/docs/intake/product-capabilities.proposed.ts +232 -0
- package/docs/knowledge-supabase-node-api.md +51 -0
- package/docs/plans/MEDIA_TRUTH_SOURCE_RECOVERY_20261008.md +31 -0
- package/docs/plans/OFFLINE_CLI_KNOWLEDGE_AGENT_HANDOFF.md +104 -0
- package/docs/plans/OFFLINE_CLI_KNOWLEDGE_RUNBOOK.md +81 -0
- package/docs/plans/SAM_EXPERIENCE_AGENT_DISPATCH_2026-10-15.md +107 -0
- package/docs/plans/SAM_MACHINERY_TO_EXPERIENCE_2026-10-15.md +172 -0
- package/docs/plans/UI_POLISH_DESKTOP_2026-10-16.md +102 -0
- package/docs/plans/WORK-UX-REMASTER-2026-10-15.md +48 -0
- package/docs/plans/WORK-WORKSPACE-PLAN-2026-10-14.md +212 -0
- package/docs/product/AGENTSAM-UI-QUALITY-GATE.md +148 -0
- package/docs/product/AGENTSAM_PRODUCT_EXPERIENCE_STANDARD.md +2 -0
- package/docs/product/MEDIA-PRODUCTION-FAMILY.md +47 -0
- package/docs/product/OFFER-PORTFOLIO.md +14 -0
- package/docs/product/PACKAGE-TAXONOMY.md +17 -0
- package/docs/product/PLUGIN-GALLERY-DISCOVERY-AND-INSTALL.md +97 -0
- package/docs/product/README.md +2 -0
- package/docs/product/WIDGET-GALLERY-PHASE-ONE.md +43 -0
- package/docs/reference/AGENTSAM-CLI-WORKFLOWS.md +73 -0
- package/docs/reference/AGENTSAM-ERROR-REASONS.md +267 -0
- package/docs/reference/AGENTSAM-REGISTRY.generated.md +288 -0
- package/docs/reference/INNERANIMALMEDIA_EXPERIENCE_ACCEPTANCE_2026-10-15.md +99 -0
- package/docs/releases/cad-v2-sdk-2.6.13.md +25 -0
- package/docs/roadmaps/ROAD_TO_REAL_DISTRIBUTION.md +97 -0
- package/docs/robotics-chess-handoff.md +15 -0
- package/docs/standards/DELIVERY_CLOSURE.md +33 -0
- package/docs/standards/SAM_MACHINE_BUILD_AND_GAPS.md +91 -0
- package/docs/workflows/ISSUE_TO_SAMOS.md +59 -0
- package/package.json +60 -8
- package/packages/agentsam-brand/package.json +1 -1
- package/packages/agentsam-cms/README.md +56 -0
- package/packages/agentsam-cms/agentsam.package.json +46 -0
- package/packages/agentsam-cms/package.json +36 -0
- package/packages/agentsam-cms/src/aliases.js +74 -0
- package/packages/agentsam-cms/src/contracts.js +105 -0
- package/packages/agentsam-cms/src/index.d.ts +80 -0
- package/packages/agentsam-cms/src/index.js +3 -0
- package/packages/agentsam-cms/src/machine.js +221 -0
- package/packages/agentsam-cms/src/node-sqlite-repository.js +148 -0
- package/packages/agentsam-cms/src/node.d.ts +7 -0
- package/packages/agentsam-cms/src/node.js +1 -0
- package/packages/agentsam-cms/src/schema/cms-local-runtime.v1.sql +365 -0
- package/packages/agentsam-cms/test/standalone.test.mjs +28 -0
- package/packages/agentsam-contracts/agentsam.package.json +43 -0
- package/packages/agentsam-contracts/dist/errors.d.ts +1 -1
- package/packages/agentsam-contracts/dist/widgets.d.ts +7 -0
- package/packages/agentsam-contracts/package.json +1 -1
- package/packages/agentsam-contracts/src/errors.ts +1 -1
- package/packages/agentsam-contracts/src/widgets.ts +7 -0
- package/packages/agentsam-desktop-shell/README.md +38 -0
- package/packages/agentsam-desktop-shell/scripts/app-discovery.mjs +43 -0
- package/packages/agentsam-errors/README.md +14 -0
- package/packages/agentsam-errors/agentsam.package.json +43 -0
- package/packages/agentsam-errors/package.json +1 -1
- package/packages/agentsam-errors/protocol/error-catalog.json +12 -0
- package/packages/agentsam-errors/src/cli.js +56 -0
- package/packages/agentsam-errors/src/index.js +2 -0
- package/packages/agentsam-errors/src/vocabulary.js +2 -0
- package/packages/agentsam-errors/test/approval-contract.test.mjs +12 -0
- package/packages/agentsam-errors/types/index.d.ts +5 -1
- package/packages/agentsam-goap/agentsam.package.json +42 -0
- package/packages/agentsam-goap/package.json +2 -2
- package/packages/agentsam-hooks/agentsam.package.json +45 -0
- package/packages/agentsam-hooks/bindings/go/errors_generated.go +1 -0
- package/packages/agentsam-hooks/bindings/rust/src/errors_generated.rs +1 -0
- package/packages/agentsam-hooks/package.json +1 -1
- package/packages/agentsam-hooks/src/errors-generated.js +10 -0
- package/packages/agentsam-ide/README.md +59 -0
- package/packages/agentsam-ide/src/lsp/host.d.mts +13 -0
- package/packages/agentsam-ide/src/lsp/host.mjs +133 -0
- package/packages/agentsam-knowledge/agentsam.package.json +42 -0
- package/packages/agentsam-knowledge/package.json +1 -1
- package/packages/agentsam-knowledge/src/autorag/index.js +25 -4
- package/packages/agentsam-knowledge/src/backends/index.js +21 -1
- package/packages/agentsam-knowledge/src/backends/supabase-node-api.js +91 -0
- package/packages/agentsam-knowledge/test/autorag.test.mjs +13 -0
- package/packages/agentsam-knowledge/test/supabase-node-api.test.mjs +59 -0
- package/packages/agentsam-merch/agentsam.package.json +43 -0
- package/packages/agentsam-merch/package.json +1 -1
- package/packages/agentsam-nav/dist/browser.global.js +18 -21
- package/packages/agentsam-nav/dist/browser.js +4 -3
- package/packages/agentsam-nav/dist/index.js +4 -3
- package/packages/agentsam-nav/package.json +1 -1
- package/packages/agentsam-queue-control/agentsam.package.json +42 -0
- package/packages/agentsam-queue-control/package.json +1 -1
- package/packages/agentsam-rapid-rust/Cargo.toml +5 -0
- package/packages/agentsam-rapid-rust/agentsam.package.json +42 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/0b22ca9c5f8cddc15e6816df4a2467a28d41aa174361cdfed9019ee4e04dfbb8.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/0c5064875a5d7645013880f04d71f56c0dfa1bc87ac9fd59adc3e9a93a2745da.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/11ebd15702c169ee0666656be851cc549f70f84498dbca3c5b72d2ceaa91c851.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/1d7f2c8ad9588cd2077a1d07fce156e0bd47be686d8c9f26885bab14874c4ab5.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/1f21ba21e7b631b0d4893cbdd7a6bb7345d34e8b1a0ee9cf644cc30aeb3c8b8d.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/23f4d4b90def0782de32e7a57558cba24525f12ba3c009728ea4881259a74099.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/26b60985b6ef62e4f20e06c37e47c6996c1a2f457335fa9eb4a68d1288e18490.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/2b27d15a1b8c3637a56f631d583cc9ba584bed2b7018dd962a9340d5e1c50a1d.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/3110a5568a544c4c38de6585dcdabc21fa5f54a5772ecf4e1f4076ee0d49e933.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/357ce3db8299e01866bf4fc3d8ee1c784ef53c7455cf86bb17c52f3dad20d050.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/4516c6e03636538cacc7a6e4063d98a7ed2f0090c3a02c5ee817f1c512b1070e.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/649e02dbaec2edabbd40372e0c5f72f114164fe7704e7825220b1955f6a7c74e.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/81c266d4c150a4f6c5a73c9c4fef6541577fd0acd8c1f911f02781deb5f0be0f.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/86b4b8de30eed9902750b3de9fb54276d229244671a8b6035345bbe705463d82.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/8a877fdc5dbc6a66c344b4ebc4d9b746d47f95153e98872210becd85ca941ddd.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/96a11200f7b42ddd1281e4f749e88dcb8455ab0e3883f943934e0a9a7935147a.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/9e2df2335cfc73ec021bdd6b2d34af798f6ed9c52e3061ce16b6ceabae4e275f.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/a405fe3addeaab2908ed58836997be3b679d990ec9102d06bece3569e4bd4a81.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/a63915da0a45f86a5938ba9a2b2e87d469e7d07f7ea9cc531136fdc9e055557e.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/a8452c2dcaa959ced25e3597931b311999c0aa5b257ca8610fe415e8cfa598cc.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/b35fc2ae65ea07fbbfdd242a3d76489947462399e7a2db91f8545ca50d97d86f.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/b966932defe9c7b5ec9599c9276d333bd09ad1605adae80300d825d2161ad20c.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/ca9060e5ccb91f3a2663f57afd47a25099b6b3313c2a7436c4634993ff6e9afc.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/d0eba82a259be203c68c3ebf6d5b8a376f31a3b84fad418fdb9b5e2715c59869.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/d8838513009c65079aba67314ab130920484c674c5f0b8a356c8777eb6174eb2.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/dda01925b7f0a213215b983979ce23625dd0f6cfdb49c483ec1ff73e64def56f.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/e4956d8f97608f8324607b22cc93635d8183b23021d79cb4c21668c8b8a6ce87.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/e80c1e517e7173dcbde78869d2bf67a24a11b0bb9df5a87fb12934e39497abc8.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/eeeaa9394ac979eb4ffa557e97d67ed96dbd61437e09058f7c776bdc0483f050.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/f9264d8d7d1ccfb415362a28b4a1b4fa0dfbdf828ff970d1aaecfb0ebe208978.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/cache/machine-parser.v1/f957a80b89d32af4f33f9f840b4795af1b5145fc44780ad88a6a3b1b3a7ea3bc.json +1 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2b0d196f16961f88/asset-manifest.json +418 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2b0d196f16961f88/findings.json +308 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2b0d196f16961f88/frontend-manifest.json +70 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2b0d196f16961f88/graph.json +322 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2b0d196f16961f88/inventory.json +932 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2b0d196f16961f88/summary.json +21 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2d70e3d4fe8290fb/asset-manifest.json +418 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2d70e3d4fe8290fb/findings.json +308 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2d70e3d4fe8290fb/frontend-manifest.json +70 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2d70e3d4fe8290fb/graph.json +322 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2d70e3d4fe8290fb/inventory.json +932 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_2d70e3d4fe8290fb/summary.json +21 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_63fab76b2f18c2f0/asset-manifest.json +418 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_63fab76b2f18c2f0/findings.json +308 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_63fab76b2f18c2f0/frontend-manifest.json +70 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_63fab76b2f18c2f0/graph.json +322 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_63fab76b2f18c2f0/inventory.json +932 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_63fab76b2f18c2f0/summary.json +21 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_72fe856b80b0c46f/asset-manifest.json +418 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_72fe856b80b0c46f/findings.json +300 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_72fe856b80b0c46f/frontend-manifest.json +70 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_72fe856b80b0c46f/graph.json +322 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_72fe856b80b0c46f/inventory.json +932 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_72fe856b80b0c46f/summary.json +21 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_a5834156504f3050/asset-manifest.json +418 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_a5834156504f3050/findings.json +308 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_a5834156504f3050/frontend-manifest.json +70 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_a5834156504f3050/graph.json +322 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_a5834156504f3050/inventory.json +932 -0
- package/packages/agentsam-repository/.agentsam/machine/runs/run_a5834156504f3050/summary.json +21 -0
- package/packages/agentsam-repository/README.md +25 -0
- package/packages/agentsam-repository/agentsam.package.json +42 -0
- package/packages/agentsam-repository/package.json +6 -3
- package/packages/agentsam-repository/src/crawl.js +220 -0
- package/packages/agentsam-repository/src/index.js +3 -0
- package/packages/agentsam-repository/src/merkle/semantic.js +20 -0
- package/packages/agentsam-repository/src/refinery.js +96 -0
- package/packages/agentsam-repository/test/crawl-refinery.test.mjs +113 -0
- package/packages/agentsam-site-scrape/README.md +357 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/__init__.py +4 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/__main__.py +349 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/classify.py +80 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/config.py +83 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/contract.py +108 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/crawl.py +395 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/evidence.py +226 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/htmlparse.py +109 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/imageops.py +121 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/jsonrun.py +127 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/net.py +121 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/pageextract.py +202 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/r2_upload.py +140 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/ssrf.py +57 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/storage.py +57 -0
- package/packages/agentsam-site-scrape/agentsam_site_scrape/wrangler_bucket.py +98 -0
- package/packages/agentsam-site-scrape/pyproject.toml +21 -0
- package/packages/agentsam-site-scrape/runtime/client.mjs +32 -0
- package/packages/agentsam-site-scrape/runtime/core.mjs +211 -0
- package/packages/agentsam-site-scrape/runtime/index.mjs +31 -0
- package/packages/agentsam-site-scrape/runtime/knowledge.mjs +38 -0
- package/packages/agentsam-site-scrape/runtime/node-runner.mjs +231 -0
- package/packages/agentsam-site-scrape/runtime/node-storage.mjs +146 -0
- package/packages/agentsam-site-scrape/runtime/project-site.mjs +74 -0
- package/packages/agentsam-site-scrape/runtime/secure-fetch.mjs +88 -0
- package/packages/agentsam-site-scrape/runtime/test/knowledge-handoff.test.mjs +51 -0
- package/packages/agentsam-site-scrape/runtime/test/project-index-command.test.mjs +109 -0
- package/packages/agentsam-site-scrape/runtime/test/runtime.test.mjs +145 -0
- package/packages/agentsam-site-scrape/tests/__init__.py +0 -0
- package/packages/agentsam-site-scrape/tests/test_contract.py +83 -0
- package/packages/agentsam-site-scrape/tests/test_core.py +119 -0
- package/packages/agentsam-site-scrape/tests/test_evidence.py +88 -0
- package/packages/agentsam-site-scrape/tests/test_evidence_pipeline.py +112 -0
- package/packages/agentsam-site-scrape/tests/test_jsonrun.py +63 -0
- package/packages/agentsam-site-scrape/tests/test_redirects.py +68 -0
- package/packages/agentsam-site-scrape/tests/test_storage.py +34 -0
- package/packages/agentsam-site-scrape/worker/index.mjs +259 -0
- package/packages/agentsam-site-scrape/worker/project-config.mjs +57 -0
- package/packages/agentsam-site-scrape/worker/test/worker.test.mjs +191 -0
- package/packages/agentsam-vault/package.json +1 -1
- package/packages/agentsam-workbench/README.md +18 -0
- package/packages/agentsam-workbench/package.json +13 -4
- package/packages/agentsam-workbench/src/agent/capability-catalog.ts +96 -0
- package/packages/agentsam-workbench/src/agent/index.ts +2 -0
- package/packages/agentsam-workbench/src/knowledge/AutoRagWorkflowDialog.tsx +166 -0
- package/packages/agentsam-workbench/src/knowledge/README.md +14 -0
- package/packages/agentsam-workbench/src/knowledge/autorag-workflow.css +6 -0
- package/packages/agentsam-workbench/src/knowledge/index.ts +2 -0
- package/packages/agentsam-workbench/src/widgets/registry.ts +266 -1
- package/packages/catalog/README.md +69 -0
- package/packages/catalog/assist/questions.json +205 -0
- package/packages/catalog/assist/rules.json +149 -0
- package/packages/catalog/doctor/toolchains.json +12 -0
- package/packages/catalog/evidence/agentsam-abs.json +76 -0
- package/packages/catalog/evidence/agentsam-analytics.json +59 -0
- package/packages/catalog/evidence/agentsam-assets-core.json +38 -0
- package/packages/catalog/evidence/agentsam-brand.json +73 -0
- package/packages/catalog/evidence/agentsam-browser-surface.json +42 -0
- package/packages/catalog/evidence/agentsam-campaign.json +48 -0
- package/packages/catalog/evidence/agentsam-cloudflare-images.json +38 -0
- package/packages/catalog/evidence/agentsam-content-studio.json +42 -0
- package/packages/catalog/evidence/agentsam-content.json +70 -0
- package/packages/catalog/evidence/agentsam-contracts.json +92 -0
- package/packages/catalog/evidence/agentsam-database-editor.json +82 -0
- package/packages/catalog/evidence/agentsam-desktop-shell.json +56 -0
- package/packages/catalog/evidence/agentsam-docs-theme.json +35 -0
- package/packages/catalog/evidence/agentsam-errors.json +42 -0
- package/packages/catalog/evidence/agentsam-goap.json +52 -0
- package/packages/catalog/evidence/agentsam-hooks.json +100 -0
- package/packages/catalog/evidence/agentsam-ide.json +64 -0
- package/packages/catalog/evidence/agentsam-identity.json +91 -0
- package/packages/catalog/evidence/agentsam-key-manager.json +46 -0
- package/packages/catalog/evidence/agentsam-knowledge.json +42 -0
- package/packages/catalog/evidence/agentsam-loading-scene.json +54 -0
- package/packages/catalog/evidence/agentsam-merch.json +68 -0
- package/packages/catalog/evidence/agentsam-nav.json +63 -0
- package/packages/catalog/evidence/agentsam-queue-control.json +60 -0
- package/packages/catalog/evidence/agentsam-rapid-rust.json +46 -0
- package/packages/catalog/evidence/agentsam-repository.json +56 -0
- package/packages/catalog/evidence/agentsam-scoring.json +39 -0
- package/packages/catalog/evidence/agentsam-sections.json +52 -0
- package/packages/catalog/evidence/agentsam-settings.json +58 -0
- package/packages/catalog/evidence/agentsam-shell-kit.json +56 -0
- package/packages/catalog/evidence/agentsam-vault.json +61 -0
- package/packages/catalog/evidence/agentsam-work-graph.json +51 -0
- package/packages/catalog/evidence/agentsam-work.json +64 -0
- package/packages/catalog/evidence/agentsam-workbench.json +96 -0
- package/packages/catalog/evidence/analytics-ui.json +43 -0
- package/packages/catalog/evidence/cms-runtime.json +49 -0
- package/packages/catalog/evidence/copro-editor.json +42 -0
- package/packages/catalog/evidence/copro-media.json +42 -0
- package/packages/catalog/evidence/copro-project.json +42 -0
- package/packages/catalog/evidence/copro-proof.json +48 -0
- package/packages/catalog/evidence/copro-provider-contracts.json +40 -0
- package/packages/catalog/evidence/copro-render.json +40 -0
- package/packages/catalog/evidence/copro-storage.json +44 -0
- package/packages/catalog/evidence/copro-templates.json +42 -0
- package/packages/catalog/evidence/copro-timeline.json +44 -0
- package/packages/catalog/evidence/copro-ui.json +52 -0
- package/packages/catalog/evidence/fnf-theme.json +34 -0
- package/packages/catalog/evidence/theme-contract.json +34 -0
- package/packages/catalog/evidence/theme-cypress.json +41 -0
- package/packages/catalog/evidence/theme-ember.json +41 -0
- package/packages/catalog/evidence/theme-forge.json +41 -0
- package/packages/catalog/evidence/theme-grove.json +41 -0
- package/packages/catalog/evidence/theme-harbor.json +41 -0
- package/packages/catalog/evidence/theme-heuristic.json +50 -0
- package/packages/catalog/evidence/theme-iasf.json +48 -0
- package/packages/catalog/evidence/theme-resolve.json +41 -0
- package/packages/catalog/evidence/theme-scenes.json +68 -0
- package/packages/catalog/evidence/theme-summit.json +41 -0
- package/packages/catalog/evidence/theme-violet.json +41 -0
- package/packages/catalog/generated/packages.json +2649 -0
- package/packages/catalog/topics/runtime.json +33 -0
- package/packages/connectors/cfoa/agentsam.package.json +46 -0
- package/packages/connectors/cfoa/package.json +1 -1
- package/packages/connectors/cfoa/src/capabilities.js +22 -2
- package/packages/connectors/cfoa/src/families/analytics-sql.js +44 -0
- package/packages/connectors/cfoa/src/families/basin.js +30 -0
- package/packages/connectors/cfoa/src/index.js +3 -0
- package/packages/connectors/cfoa/src/routes.js +11 -2
- package/packages/connectors/cfoa/test/analytics-sql.test.mjs +27 -0
- package/packages/connectors/cfoa/test/basin.test.mjs +30 -0
- package/packages/heuristic-theme/README.md +14 -0
- package/packages/heuristic-theme/agentsam.package.json +42 -0
- package/packages/heuristic-theme/contracts/README.md +15 -0
- package/packages/heuristic-theme/contracts/block.schema.json +33 -0
- package/packages/heuristic-theme/contracts/header-presets.json +20 -0
- package/packages/heuristic-theme/contracts/page.schema.json +18 -0
- package/packages/heuristic-theme/contracts/preset.schema.json +18 -0
- package/packages/heuristic-theme/contracts/section.schema.json +83 -0
- package/packages/heuristic-theme/package.json +13 -3
- package/packages/heuristic-theme/presets/fuel-free-time/assets.json +8 -0
- package/packages/heuristic-theme/presets/fuel-free-time/globals/shell.json +30 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/about.json +4 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/cart.json +4 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/collection.json +4 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/collections.json +4 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/community.json +4 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/home.json +92 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/order-confirmation.json +39 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/product.json +4 -0
- package/packages/heuristic-theme/presets/fuel-free-time/pages/shop.json +9 -0
- package/packages/heuristic-theme/presets/fuel-free-time/preset.json +23 -0
- package/packages/heuristic-theme/presets/fuel-free-time/tokens.json +23 -0
- package/packages/heuristic-theme/storefront/about.html +1103 -0
- package/packages/heuristic-theme/storefront/assets/presets/fuel-free-time/GENERATED-ASSETS.md +15 -0
- package/packages/heuristic-theme/storefront/assets/presets/fuel-free-time/earned-hours-hero.webp +0 -0
- package/packages/heuristic-theme/storefront/assets/presets/fuel-free-time/essentials.webp +0 -0
- package/packages/heuristic-theme/storefront/assets/presets/fuel-free-time/masters.webp +0 -0
- package/packages/heuristic-theme/storefront/cart.html +64 -0
- package/packages/heuristic-theme/storefront/collaborate.html +58 -0
- package/packages/heuristic-theme/storefront/collection.html +10 -0
- package/packages/heuristic-theme/storefront/collections.html +10 -0
- package/packages/heuristic-theme/storefront/community.html +921 -0
- package/packages/heuristic-theme/storefront/css/content-page.css +199 -0
- package/packages/heuristic-theme/storefront/css/global-footer.css +401 -0
- package/packages/heuristic-theme/storefront/css/heuristic-theme.css +81 -0
- package/packages/heuristic-theme/storefront/css/page-composer.css +76 -0
- package/packages/heuristic-theme/storefront/css/shop-hero.css +230 -0
- package/packages/heuristic-theme/storefront/css/store-cart.css +422 -0
- package/packages/heuristic-theme/storefront/css/store-collections.css +36 -0
- package/packages/heuristic-theme/storefront/css/store-pdp.css +459 -0
- package/packages/heuristic-theme/storefront/css/store-shell.css +474 -0
- package/packages/heuristic-theme/storefront/css/store-shop.css +117 -0
- package/packages/heuristic-theme/storefront/home.html +25 -0
- package/packages/heuristic-theme/storefront/js/cms-hydrate.js +395 -0
- package/packages/heuristic-theme/storefront/js/cms-structure.js +85 -0
- package/packages/heuristic-theme/storefront/js/fnf-attribution.js +98 -0
- package/packages/heuristic-theme/storefront/js/fnf-head.js +47 -0
- package/packages/heuristic-theme/storefront/js/fnf-newsletter.js +64 -0
- package/packages/heuristic-theme/storefront/js/global-footer.js +277 -0
- package/packages/heuristic-theme/storefront/js/heuristic-runtime.js +78 -0
- package/packages/heuristic-theme/storefront/js/order-confirmation.js +109 -0
- package/packages/heuristic-theme/storefront/js/page-composer.js +310 -0
- package/packages/heuristic-theme/storefront/js/shop-hero.js +85 -0
- package/packages/heuristic-theme/storefront/js/store-cart.js +276 -0
- package/packages/heuristic-theme/storefront/js/store-catalog.js +140 -0
- package/packages/heuristic-theme/storefront/js/store-collections.js +45 -0
- package/packages/heuristic-theme/storefront/js/store-product.js +287 -0
- package/packages/heuristic-theme/storefront/js/store-shell.js +449 -0
- package/packages/heuristic-theme/storefront/order-confirmation.html +30 -0
- package/packages/heuristic-theme/storefront/policies.html +43 -0
- package/packages/heuristic-theme/storefront/product.html +27 -0
- package/packages/heuristic-theme/storefront/shop.html +113 -0
- package/packages/heuristic-theme/storefront/terms.html +45 -0
- package/packages/heuristic-theme/test/commerce-portability.test.mjs +16 -0
- package/packages/heuristic-theme/theme.json +55 -0
- package/packages/heuristic-theme/theme.schema.json +32 -0
- package/packages/identity/agentsam.package.json +42 -0
- package/packages/identity/package.json +1 -1
- package/packages/identity/src/oauth/iam-platform.js +4 -2
- package/packages/identity/src/recovery/password-reset.js +8 -8
- package/packages/identity/src/server/worker-router.js +63 -1
- package/packages/identity/tests/lane1-packed-consumer.test.mjs +12 -1
- package/packages/identity/tests/password-enrollment.test.mjs +82 -0
- package/packages/identity/tests/password-reset.test.mjs +43 -0
- package/packages/providers/completeful/package.json +1 -1
- package/packages/theme-cypress/agentsam.package.json +42 -0
- package/packages/theme-cypress/package.json +1 -1
- package/packages/theme-ember/agentsam.package.json +42 -0
- package/packages/theme-ember/package.json +1 -1
- package/packages/theme-forge/agentsam.package.json +42 -0
- package/packages/theme-forge/package.json +1 -1
- package/packages/theme-grove/agentsam.package.json +42 -0
- package/packages/theme-grove/package.json +1 -1
- package/packages/theme-harbor/agentsam.package.json +42 -0
- package/packages/theme-harbor/package.json +1 -1
- package/packages/theme-resolve/agentsam.package.json +42 -0
- package/packages/theme-resolve/package.json +1 -1
- package/packages/theme-scenes/agentsam.package.json +42 -0
- package/packages/theme-scenes/package.json +1 -1
- package/packages/theme-summit/agentsam.package.json +42 -0
- package/packages/theme-summit/package.json +1 -1
- package/packages/theme-violet/agentsam.package.json +42 -0
- package/packages/theme-violet/package.json +1 -1
- package/packages/work-graph/agentsam.package.json +42 -0
- package/packages/work-graph/package.json +1 -1
- package/protocol/apps/agentsam.app.v1.schema.json +27 -1
- package/protocol/cad/README.md +77 -0
- package/protocol/cad/cad.project.v2.schema.json +451 -0
- package/protocol/cad/v2/core/artifact-receipt.schema.json +126 -0
- package/protocol/cad/v2/core/coordinate-system.schema.json +364 -0
- package/protocol/cad/v2/core/geometry-constraint.schema.json +136 -0
- package/protocol/cad/v2/core/geometry-entity.schema.json +73 -0
- package/protocol/cad/v2/core/geometry-feature.schema.json +115 -0
- package/protocol/cad/v2/core/geometry-relationship.schema.json +67 -0
- package/protocol/cad/v2/core/project-revision.schema.json +111 -0
- package/protocol/cad/v2/core/topology-reference.schema.json +80 -0
- package/protocol/cad/v2/intent/design-decision.schema.json +126 -0
- package/protocol/cad/v2/intent/design-option.schema.json +88 -0
- package/protocol/cad/v2/interchange/ifc-mapping.schema.json +145 -0
- package/protocol/cad/v2/interchange/native-document.schema.json +130 -0
- package/protocol/cad/v2/interchange/reference-model.schema.json +141 -0
- package/protocol/cad/v2/modules/architecture.v1.schema.json +278 -0
- package/protocol/cad/v2/modules/landscape.v1.schema.json +157 -0
- package/protocol/cad/v2/modules/mechanical.v1.schema.json +325 -0
- package/protocol/cad/v2/modules/parametric.v1.schema.json +89 -0
- package/protocol/cad/v2/modules/product-design.v1.schema.json +178 -0
- package/protocol/cad/v2/modules/robotics.v1.schema.json +246 -0
- package/protocol/cad/v2/presentation/camera-path.schema.json +143 -0
- package/protocol/cad/v2/presentation/drawing.schema.json +162 -0
- package/protocol/cad/v2/presentation/production.schema.json +166 -0
- package/protocol/cad/v2/presentation/scene.schema.json +198 -0
- package/protocol/cad/v2/presentation/sheet.schema.json +254 -0
- package/protocol/cad/v2/presentation/view.schema.json +190 -0
- package/protocol/cad/v2/presentation/walkthrough.schema.json +199 -0
- package/protocol/cad/v2/schema-pack.manifest.json +189 -0
- package/protocol/cad/v2/validation/deliverable-manifest.schema.json +199 -0
- package/protocol/cad/v2/validation/result.schema.json +141 -0
- package/protocol/capabilities/evidence-manifest.schema.json +404 -0
- package/protocol/capabilities/manifest.json +101 -10
- package/protocol/capabilities/repository-crawl-input.schema.json +17 -0
- package/protocol/capabilities/repository-crawl-result.schema.json +79 -0
- package/protocol/capabilities/repository-mine-input.schema.json +27 -0
- package/protocol/capabilities/repository-mine-result.schema.json +51 -0
- package/protocol/capabilities/site-index.schema.json +15 -0
- package/protocol/capabilities/site-scrape-evidence-manifest.schema.json +114 -0
- package/protocol/capabilities/site-scrape-input.schema.json +90 -0
- package/protocol/capabilities/site-scrape-project-authority.schema.json +15 -0
- package/protocol/capabilities/site-scrape-result.schema.json +198 -0
- package/protocol/capabilities/site-scrape-worker-job.schema.json +18 -0
- package/protocol/errors/error-catalog.json +12 -0
- package/protocol/governance/distribution-roadmap.v1.json +335 -0
- package/protocol/governance/github-labels.v1.json +232 -0
- package/protocol/models/workers-ai-curated.mjs +14 -0
- package/protocol/plugins/agentsam.plugin-evidence-bundle.v1.schema.json +55 -0
- package/protocol/plugins/agentsam.plugin-product.v1.schema.json +227 -0
- package/protocol/plugins/agentsam.plugin-quality-evidence.v1.schema.json +47 -0
- package/protocol/plugins/agentsam.plugin-quality-receipt.v1.schema.json +160 -0
- package/protocol/ui/agentsam.ui-quality.v1.schema.json +31 -0
- package/python/agentsam_sdk/__init__.py +4 -0
- package/python/agentsam_sdk/client.py +202 -0
- package/python/agentsam_sdk/errors/vocabulary.py +10 -0
- package/python/tests/test_public_client.py +82 -0
- package/services/cad/blender/adapter.py +0 -0
- package/services/cad/occt/CMakeLists.txt +43 -0
- package/services/cad/occt/README.md +38 -0
- package/services/cad/occt/main.cpp +95 -0
- package/services/cad/server.py +103 -21
- package/skills/README.md +6 -0
- package/skills/agentsam-cad/SKILL.md +59 -0
- package/skills/agentsam-plan-and-goap/SKILL.md +77 -0
- package/skills/agentsam-repo-recon/SKILL.md +63 -0
- package/skills/agentsam-sam-operations/SKILL.md +71 -0
- package/skills/agentsam-sdk-orientation/SKILL.md +75 -0
- package/skills/catalog.json +85 -0
- package/src/AgentSam.js +2 -0
- package/src/agent/capability-adapter.js +207 -9
- package/src/agent/index.js +1 -0
- package/src/agent/intent.js +12 -0
- package/src/agent/project-discovery.js +47 -0
- package/src/agent/project-resources.js +157 -0
- package/src/agent/responses-runner.js +64 -12
- package/src/capabilities/cloudflare-d1-provision.js +48 -0
- package/src/capabilities/knowledge-operations.js +87 -0
- package/src/capabilities/local-sqlite-resources.js +124 -0
- package/src/capabilities/machine-inspect.js +28 -0
- package/src/capabilities/mcp-d1-bridge.js +98 -0
- package/src/capabilities/plan-operation-ids.js +6 -0
- package/src/capabilities/plan-operations.js +85 -0
- package/src/capabilities/repository-awareness.js +52 -0
- package/src/capabilities/test-run.js +10 -0
- package/src/capabilities/workspace-files.js +125 -0
- package/src/cli/command-catalog.js +16 -3
- package/src/cli.js +71 -116
- package/src/commands/app.js +43 -44
- package/src/commands/autorag-node-api.js +96 -0
- package/src/commands/autorag.js +178 -17
- package/src/commands/catalog-doctor.js +52 -0
- package/src/commands/catalog.js +151 -0
- package/src/commands/cheat-sheet.js +92 -63
- package/src/commands/cloudflare.js +64 -2
- package/src/commands/codebaseindex.js +2 -2
- package/src/commands/db.js +17 -0
- package/src/commands/goap-world.js +4 -0
- package/src/commands/interactive.js +21 -1
- package/src/commands/knowledge.js +8 -3
- package/src/commands/machine-binary.js +3 -2
- package/src/commands/machine.js +66 -15
- package/src/commands/mcp.js +98 -8
- package/src/commands/plan-ledger.js +60 -22
- package/src/commands/plan.js +3 -3
- package/src/commands/plugins.js +34 -2
- package/src/commands/product.js +21 -0
- package/src/commands/rust.js +4 -1
- package/src/commands/sam-evidence.js +87 -0
- package/src/commands/sam-media.js +78 -0
- package/src/commands/sam.js +117 -0
- package/src/commands/shell.js +97 -8
- package/src/commands/site-scrape.js +9 -0
- package/src/context/resolve.js +5 -1
- package/src/index.js +13 -0
- package/src/knowledge/d1-schema.js +65 -0
- package/src/knowledge/engine.js +55 -15
- package/src/knowledge/source.js +8 -0
- package/src/knowledge/store-discovery.js +9 -3
- package/src/knowledge/stores/sqlite.js +8 -0
- package/src/knowledge/wrangler-binding-discovery.js +43 -0
- package/src/lib/agent-instructions.js +29 -5
- package/src/lib/auth.js +46 -7
- package/src/lib/cad/delivery-profiles.d.ts +7 -0
- package/src/lib/cad/delivery-profiles.js +122 -0
- package/src/lib/cad/docker-executor.js +1 -1
- package/src/lib/cad/editable-project-contract.js +75 -0
- package/src/lib/cad/index.js +6 -0
- package/src/lib/cad/occt-native-provider.mjs +138 -0
- package/src/lib/cad/openscad.js +13 -1
- package/src/lib/cad/production-operations.d.ts +8 -0
- package/src/lib/cad/production-operations.js +74 -0
- package/src/lib/cad/project-cli.d.ts +1 -1
- package/src/lib/cad/project-contract.js +1 -1
- package/src/lib/cad/project-runtime.d.ts +1 -1
- package/src/lib/cad/project-runtime.js +48 -3
- package/src/lib/cad/project-tools.js +24 -0
- package/src/lib/cad/project-v2.d.ts +48 -0
- package/src/lib/cad/project-v2.js +288 -0
- package/src/lib/cad-docker.js +48 -4
- package/src/lib/dockerize.js +3 -3
- package/src/lib/execution-approvals.js +29 -3
- package/src/local-fs/capability.js +5 -0
- package/src/local-lsp/host.js +2 -0
- package/src/local-pty/server.js +21 -0
- package/src/mcp/client.js +2 -1
- package/src/mcp/oauth-connection.js +109 -0
- package/src/models/inventory-core.js +2 -10
- package/src/plugins/index.js +13 -0
- package/src/plugins/productization.js +348 -0
- package/src/providers/gemini-generate-content.js +18 -0
- package/src/registry/generated/inventory.json +4266 -0
- package/src/registry/index.js +96 -0
- package/src/registry/turn-one.js +45 -0
- package/src/sam/adapters/local-media-store.js +71 -0
- package/src/sam/adapters/local-script-runtime.js +122 -0
- package/src/sam/adapters/local-script-store.js +103 -0
- package/src/sam/adapters/object-media-store.js +89 -0
- package/src/sam/adapters/workspace-media.js +78 -0
- package/src/sam/artifacts/render.js +94 -0
- package/src/sam/bridge/stdio.mjs +59 -0
- package/src/sam/client.js +269 -22
- package/src/sam/index.js +30 -1
- package/src/sam/local-execution.js +8 -0
- package/src/sam/media/environment.js +96 -0
- package/src/sam/model-adapter.js +45 -0
- package/src/sam/operation-packs/generated-v2/background.js +54 -0
- package/src/sam/operation-packs/generated-v2/catalog.js +1746 -0
- package/src/sam/operation-packs/generated-v2/generated-execution-policies.json +401 -0
- package/src/sam/operation-packs/generated-v2/generated-tool-descriptors.json +1352 -0
- package/src/sam/operation-packs/generated-v2/glb.js +41 -0
- package/src/sam/operation-packs/generated-v2/inneranimalmedia-provider.js +24 -0
- package/src/sam/operation-packs/generated-v2/operation-pack.js +126 -0
- package/src/sam/operation-packs/generated-v2/raster.js +140 -0
- package/src/sam/operation-packs/generated-v2/scripts.js +63 -0
- package/src/sam/operation-packs/generated-v2/sdk-adapter.js +9 -0
- package/src/sam/operation-packs/generated-v2/test/alias-runtime.test.mjs +51 -0
- package/src/sam/operation-packs/generated-v2/test/background.test.mjs +19 -0
- package/src/sam/operation-packs/generated-v2/test/glb.test.mjs +19 -0
- package/src/sam/operation-packs/generated-v2/test/raster.test.mjs +38 -0
- package/src/sam/operation-packs/generated-v2/test/real-asset-bindings.test.mjs +74 -0
- package/src/sam/operation-packs/generated-v2/test/registration.test.mjs +65 -0
- package/src/sam/operation-packs/generated-v2/test/scripts.test.mjs +32 -0
- package/src/sam/operation-packs/generated-v2/test/superbash-client-integration.test.mjs +215 -0
- package/src/sam/operation-packs/generated-v2/tool-types.d.ts +53 -0
- package/src/sam/operations/artifact-render.js +13 -0
- package/src/sam/operations/repository-inspect.js +12 -2
- package/src/sam/operations/robotics.js +45 -0
- package/src/sam/os.js +117 -0
- package/src/sam/packs/authoring/README.md +13 -0
- package/src/sam/packs/authoring/index.js +108 -0
- package/src/sam/packs/cad/http-ports.js +55 -0
- package/src/sam/packs/cad/index.js +158 -0
- package/src/sam/packs/cad/model-tools.js +22 -0
- package/src/sam/packs/cad/modes.js +87 -0
- package/src/sam/packs/cms/aliases.js +1 -0
- package/src/sam/packs/cms/contracts.js +1 -0
- package/src/sam/packs/cms/machine.js +6 -0
- package/src/sam/packs/cms/node.js +1 -0
- package/src/sam/packs/core.js +27 -0
- package/src/sam/packs/evidence/README.md +65 -0
- package/src/sam/packs/evidence/compare.js +98 -0
- package/src/sam/packs/evidence/contract.js +56 -0
- package/src/sam/packs/evidence/derive.js +59 -0
- package/src/sam/packs/evidence/driver-blender.js +96 -0
- package/src/sam/packs/evidence/driver-playwright.js +91 -0
- package/src/sam/packs/evidence/exporter-copro.js +70 -0
- package/src/sam/packs/evidence/facts.js +37 -0
- package/src/sam/packs/evidence/host-local.js +74 -0
- package/src/sam/packs/evidence/index.js +494 -0
- package/src/sam/packs/evidence/media.js +44 -0
- package/src/sam/packs/evidence/naming.js +67 -0
- package/src/sam/packs/evidence/normalize.js +117 -0
- package/src/sam/packs/evidence/review-page.js +102 -0
- package/src/sam/packs/evidence/screenplay.js +34 -0
- package/src/sam/packs/evidence/seal.js +55 -0
- package/src/sam/packs/evidence/serve.js +74 -0
- package/src/sam/packs/evidence/store.js +93 -0
- package/src/sam/packs/evidence/viewports.js +23 -0
- package/src/sam/robotics/chess-adapter.js +14 -0
- package/src/sam/robotics/franka.js +44 -0
- package/src/sam/robotics/index.js +4 -0
- package/src/sam/robotics/receipt.js +21 -0
- package/src/sam/robotics/world.js +57 -0
- package/src/sam/seed.js +10 -40
- package/src/sam/shell-host.js +120 -0
- package/src/sam/validation.js +40 -0
- package/src/security/local-vault.js +6 -1
- package/src/ui/cli/help.js +6 -0
- package/templates/clay/clay-blueprint-template.html +481 -0
- package/templates/clay/clay-case-study-blueprint.html +269 -0
- package/templates/clay/conversion-showcase-section.html +534 -0
- package/templates/clay/enhancing-conversion-section.html +141 -0
- package/templates/clay/nuant-wireframe.html +117 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { readFile, readdir, realpath, stat } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { defineSamOperation } from '../../define.js';
|
|
5
|
+
import {
|
|
6
|
+
EVIDENCE_BUILD_PHASE, EVIDENCE_CAPTURE_SCHEMA, EVIDENCE_FLOW_MAP_SCHEMA, EVIDENCE_KINDS, EVIDENCE_SCHEMA,
|
|
7
|
+
EXT_TYPES, evidenceError, renderEvidenceReadme,
|
|
8
|
+
} from './contract.js';
|
|
9
|
+
import {
|
|
10
|
+
CAMEL_RE, DATE_RE, PROJECT_RE, RUN_ID_RE, SLUG_RE, VIEWPORT_DIR_RE, assertSafeKey, captureFilename, flowDirName, makeRunId, plainFilename, stateId, utcDate,
|
|
11
|
+
} from './naming.js';
|
|
12
|
+
import { computeStatus, findNoncanonical, isBrowserDecodable, renderSrt } from './seal.js';
|
|
13
|
+
import { startEvidenceServer } from './serve.js';
|
|
14
|
+
import { resolveViewport } from './viewports.js';
|
|
15
|
+
import { planIngest } from './normalize.js';
|
|
16
|
+
import { renderScreenplay } from './screenplay.js';
|
|
17
|
+
import { renderReviewHtml } from './review-page.js';
|
|
18
|
+
import { compareRuns } from './compare.js';
|
|
19
|
+
|
|
20
|
+
const MAX_INLINE_BYTES = 50 * 1024 * 1024;
|
|
21
|
+
const MAX_INGEST_FILES = 5000;
|
|
22
|
+
const CAPTURE_PHASES = ['01-Brief', '02-Recon', EVIDENCE_BUILD_PHASE];
|
|
23
|
+
const STILL_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp']);
|
|
24
|
+
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
25
|
+
const isIndex = (n) => Number.isInteger(n) && n >= 0 && n <= 999;
|
|
26
|
+
const invalidFlows = (detail) => evidenceError('evidence_flow_map_invalid', detail);
|
|
27
|
+
|
|
28
|
+
function resolveProject(value) {
|
|
29
|
+
if (value === undefined || value === null) return null;
|
|
30
|
+
const spec = typeof value === 'string' ? { id: value, slug: value } : value;
|
|
31
|
+
if (typeof spec !== 'object' || typeof spec.slug !== 'string' || !PROJECT_RE.test(spec.slug)) throw evidenceError('evidence_project_invalid');
|
|
32
|
+
if (spec.id !== undefined && typeof spec.id !== 'string') throw evidenceError('evidence_project_invalid');
|
|
33
|
+
return { id: spec.id ?? spec.slug, slug: spec.slug };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function validateFlows(flows) {
|
|
37
|
+
if (!Array.isArray(flows) || flows.length === 0 || flows.length > 64) throw invalidFlows('flows');
|
|
38
|
+
const seenFlows = new Set();
|
|
39
|
+
let states = 0;
|
|
40
|
+
const out = flows.map((flow) => {
|
|
41
|
+
if (!isIndex(flow?.flow) || !CAMEL_RE.test(flow?.name ?? '') || seenFlows.has(flow.flow) || !Array.isArray(flow.steps) || flow.steps.length === 0) throw invalidFlows('flow');
|
|
42
|
+
seenFlows.add(flow.flow);
|
|
43
|
+
const seenSteps = new Set();
|
|
44
|
+
return {
|
|
45
|
+
flow: flow.flow, name: flow.name,
|
|
46
|
+
steps: flow.steps.map((step) => {
|
|
47
|
+
if (!isIndex(step?.step) || seenSteps.has(step.step) || (step.name !== undefined && !CAMEL_RE.test(step.name)) || !Array.isArray(step.states) || step.states.length === 0) throw invalidFlows('step');
|
|
48
|
+
seenSteps.add(step.step);
|
|
49
|
+
const seenStates = new Set();
|
|
50
|
+
return {
|
|
51
|
+
step: step.step, ...(step.name ? { name: step.name } : {}),
|
|
52
|
+
states: step.states.map((state) => {
|
|
53
|
+
if (!isIndex(state?.state) || seenStates.has(state.state) || !CAMEL_RE.test(state?.name ?? '')) throw invalidFlows('state');
|
|
54
|
+
seenStates.add(state.state);
|
|
55
|
+
states += 1;
|
|
56
|
+
return { state: state.state, name: state.name };
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
return { flows: out, states };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function validateViewports(list) {
|
|
66
|
+
if (list === undefined) return [];
|
|
67
|
+
if (!Array.isArray(list) || list.length > 7) throw evidenceError('evidence_viewports_invalid');
|
|
68
|
+
const ids = list.map((id) => resolveViewport(id).id);
|
|
69
|
+
if (new Set(ids).size !== ids.length) throw evidenceError('evidence_viewports_invalid');
|
|
70
|
+
return ids;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function validateChecks(checks = []) {
|
|
74
|
+
if (!Array.isArray(checks) || checks.length > 64) throw evidenceError('evidence_check_invalid');
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
return checks.map((check) => {
|
|
77
|
+
if (typeof check?.id !== 'string' || !SLUG_RE.test(check.id) || seen.has(check.id)) throw evidenceError('evidence_check_invalid');
|
|
78
|
+
seen.add(check.id);
|
|
79
|
+
return { id: check.id, description: typeof check.description === 'string' ? check.description : '' };
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function declaredStates(flowMap) {
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const flow of flowMap.flows) for (const step of flow.steps) for (const state of step.states) out.push({ id: stateId(flow.flow, step.step, state.state), flow, step, state });
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Every declared state, times every declared viewport when a matrix was declared. */
|
|
90
|
+
function expectedCaptures(flowMap) {
|
|
91
|
+
const viewports = flowMap.viewports ?? [];
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const s of declaredStates(flowMap)) for (const v of viewports.length > 0 ? viewports : [null]) out.push({ ...s, viewport: v, key: v ? `${s.id}@${v}` : s.id });
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const assetDate = (asset) => (asset.phase === '01-Brief' ? asset.capturedAt.slice(0, 10) : asset.key.split('/')[1]);
|
|
98
|
+
|
|
99
|
+
async function listFiles(directory) {
|
|
100
|
+
const found = [];
|
|
101
|
+
const walk = async (dir, rel) => {
|
|
102
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
103
|
+
if (entry.name.startsWith('.')) continue;
|
|
104
|
+
const childRel = rel ? `${rel}/${entry.name}` : entry.name;
|
|
105
|
+
const abs = path.join(dir, entry.name);
|
|
106
|
+
if (entry.isDirectory()) await walk(abs, childRel);
|
|
107
|
+
else if (entry.isFile()) {
|
|
108
|
+
if (found.length >= MAX_INGEST_FILES) throw evidenceError('evidence_ingest_too_many_files');
|
|
109
|
+
const info = await stat(abs);
|
|
110
|
+
found.push({ path: childRel, abs, mtime: info.mtimeMs, bytes: info.size });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
await walk(directory, '');
|
|
115
|
+
return found;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Evidence operations: begin -> capture (xN, across viewports) -> seal -> deliver; plus compare and ingest.
|
|
120
|
+
*
|
|
121
|
+
* Host-injected, like the other packs: a store, a trusted principal and an authorizer. The project comes from
|
|
122
|
+
* the caller or the host principal, never from a default. Capture drivers (screen, renderer) are injected via
|
|
123
|
+
* `sources`; `media` verifies video; `derive` writes web copies and covers; `images` ({ sharp }) powers compare;
|
|
124
|
+
* `facts` computes progression facts; `exporters` write editor projects. Everything optional stays optional.
|
|
125
|
+
*/
|
|
126
|
+
export function createEvidenceOperations({
|
|
127
|
+
store, resolveTrustedContext, authorize, sources = {}, media = null, derive = null, images = null, facts = null,
|
|
128
|
+
exporters = {}, readableRoots = [], now = () => new Date(), nonce = () => randomBytes(8).toString('hex'),
|
|
129
|
+
} = {}) {
|
|
130
|
+
for (const name of ['put', 'get', 'has', 'list']) {
|
|
131
|
+
if (typeof store?.[name] !== 'function') throw new Error(`sam_evidence_store_missing:${name}`);
|
|
132
|
+
}
|
|
133
|
+
if (typeof resolveTrustedContext !== 'function' || typeof authorize !== 'function') {
|
|
134
|
+
throw new Error('sam_evidence_requires_trusted_principal_and_authorization');
|
|
135
|
+
}
|
|
136
|
+
for (const root of readableRoots) if (typeof root !== 'string' || !path.isAbsolute(root)) throw new Error('sam_evidence_readable_root_invalid');
|
|
137
|
+
const servers = new Set();
|
|
138
|
+
|
|
139
|
+
async function principalFor(action, input, ctx) {
|
|
140
|
+
const principal = await resolveTrustedContext(ctx);
|
|
141
|
+
if (!principal || typeof principal !== 'object' || !principal.actorId) throw evidenceError('evidence_trusted_principal_required');
|
|
142
|
+
const project = resolveProject(input.project ?? principal.project);
|
|
143
|
+
if (!project) throw evidenceError('evidence_project_unresolved');
|
|
144
|
+
return { principal, project, action };
|
|
145
|
+
}
|
|
146
|
+
async function permit({ principal, project, action }, runId) {
|
|
147
|
+
if ((await authorize({ principal, action, project: project.id, projectSlug: project.slug, runId })) !== true) throw evidenceError('evidence_access_denied');
|
|
148
|
+
}
|
|
149
|
+
async function runFor(action, input, ctx) {
|
|
150
|
+
const who = await principalFor(action, input, ctx);
|
|
151
|
+
if (typeof input.runId !== 'string' || !RUN_ID_RE.test(input.runId)) throw evidenceError('evidence_run_id_invalid');
|
|
152
|
+
await permit(who, input.runId);
|
|
153
|
+
const root = `${who.project.slug}/${input.runId}`;
|
|
154
|
+
const raw = await store.get(`${root}/03-Flow/flow.map.json`);
|
|
155
|
+
if (!raw) throw evidenceError('evidence_run_unknown');
|
|
156
|
+
return { ...who, root, flowMap: JSON.parse(raw.toString('utf8')) };
|
|
157
|
+
}
|
|
158
|
+
async function readJson(key, fallback) {
|
|
159
|
+
const raw = await store.get(key);
|
|
160
|
+
return raw ? JSON.parse(raw.toString('utf8')) : fallback;
|
|
161
|
+
}
|
|
162
|
+
async function insideReadable(candidate) {
|
|
163
|
+
if (readableRoots.length === 0) throw evidenceError('evidence_source_unsupported');
|
|
164
|
+
const real = await realpath(candidate);
|
|
165
|
+
const allowed = await Promise.all(readableRoots.map((root) => realpath(root)));
|
|
166
|
+
if (!allowed.some((root) => real === root || real.startsWith(root + path.sep))) throw evidenceError('evidence_source_outside_readable_roots');
|
|
167
|
+
return real;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function inlineSource({ source }) {
|
|
171
|
+
const ext = String(source.ext ?? '').toLowerCase();
|
|
172
|
+
if (!/^[a-z0-9]{2,5}$/.test(ext) || typeof source.data !== 'string') throw evidenceError('evidence_source_invalid');
|
|
173
|
+
const bytes = Buffer.from(source.data, 'base64');
|
|
174
|
+
if (bytes.length === 0 || bytes.length > MAX_INLINE_BYTES) throw evidenceError('evidence_source_invalid');
|
|
175
|
+
return { bytes, ext, durationMs: source.durationMs };
|
|
176
|
+
}
|
|
177
|
+
async function fileSource({ source }) {
|
|
178
|
+
if (typeof source.path !== 'string' || !path.isAbsolute(source.path)) throw evidenceError('evidence_source_invalid');
|
|
179
|
+
const real = await insideReadable(source.path);
|
|
180
|
+
return { bytes: await readFile(real), ext: path.extname(real).slice(1).toLowerCase(), durationMs: source.durationMs };
|
|
181
|
+
}
|
|
182
|
+
const drivers = { inline: inlineSource, ...(readableRoots.length > 0 ? { file: fileSource } : {}), ...sources };
|
|
183
|
+
|
|
184
|
+
async function writeReview(root, manifest, compareDocs) {
|
|
185
|
+
const screenplay = renderScreenplay(manifest);
|
|
186
|
+
await store.put(`${root}/review.html`, renderReviewHtml({ manifest, screenplay: screenplay.json, derivatives: manifest.derivatives ?? [], compare: compareDocs }));
|
|
187
|
+
return screenplay;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const op = (id, action, risk, summary, handler, extra = {}) => defineSamOperation({
|
|
191
|
+
id, module: 'evidence', action, summary,
|
|
192
|
+
purpose: 'Systematic, labeled capture of agent work so one capture feeds QA, changelogs, case studies and editors.',
|
|
193
|
+
execution: { lanes: ['local'], model: 'never', network: 'none', sideEffects: 'local_write' },
|
|
194
|
+
risk, capabilities: [risk === 'read_only' ? 'evidence.read' : 'evidence.write'], status: 'experimental', handler, ...extra,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const begin = op('sam.evidence.begin', 'begin', 'write',
|
|
198
|
+
'Declare the flows, steps, states, viewports and checks a run must produce before anything is captured.',
|
|
199
|
+
async (input = {}, ctx = {}) => {
|
|
200
|
+
const who = await principalFor('evidence.write', input, ctx);
|
|
201
|
+
const startedDate = input.startedAt === undefined ? now() : new Date(input.startedAt);
|
|
202
|
+
if (Number.isNaN(startedDate.getTime())) throw evidenceError('evidence_started_at_invalid');
|
|
203
|
+
const startedAt = startedDate.toISOString();
|
|
204
|
+
const { flows, states } = validateFlows(input.flows);
|
|
205
|
+
const viewports = validateViewports(input.viewports);
|
|
206
|
+
const checks = validateChecks(input.checks);
|
|
207
|
+
const runId = makeRunId({ subject: input.subject, project: who.project.slug, startedAt, nonce: input.nonce ?? nonce() });
|
|
208
|
+
await permit(who, runId);
|
|
209
|
+
const root = `${who.project.slug}/${runId}`;
|
|
210
|
+
if (await store.has(`${root}/03-Flow/flow.map.json`)) throw evidenceError('evidence_run_exists');
|
|
211
|
+
const flowMap = {
|
|
212
|
+
schema: EVIDENCE_FLOW_MAP_SCHEMA, runId, subject: input.subject, project: who.project, startedAt,
|
|
213
|
+
profile: typeof input.profile === 'string' ? input.profile : 'web-review', flows, checks, ...(viewports.length > 0 ? { viewports } : {}),
|
|
214
|
+
};
|
|
215
|
+
await store.put(`${root}/03-Flow/flow.map.json`, json(flowMap));
|
|
216
|
+
await store.put(`${root}/README.md`, renderEvidenceReadme({ runId, subject: input.subject, project: who.project, startedAt }));
|
|
217
|
+
return { ok: true, runId, prefix: root, declaredStates: states, expectedCaptures: states * Math.max(viewports.length, 1) };
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
async function captureOne({ run, phase, found, kind, date, viewport, input }) {
|
|
221
|
+
const tag = viewport ? { viewport } : {};
|
|
222
|
+
try {
|
|
223
|
+
const got = await drivers[input.source.kind]({ source: input.source, input, flowMap: run.flowMap, viewport });
|
|
224
|
+
if (!Buffer.isBuffer(got?.bytes) || !/^[a-z0-9]{2,5}$/.test(got.ext ?? '')) throw evidenceError('evidence_source_invalid');
|
|
225
|
+
let relative;
|
|
226
|
+
let filename;
|
|
227
|
+
let flowDir = null;
|
|
228
|
+
if (phase === EVIDENCE_BUILD_PHASE) {
|
|
229
|
+
filename = captureFilename({ flow: found.flow.flow, step: found.step.step, state: found.state.state, variant: input.variant, name: found.state.name, ext: got.ext });
|
|
230
|
+
flowDir = flowDirName(found.flow.flow, found.flow.name);
|
|
231
|
+
relative = `${phase}/${date}/${flowDir}${viewport ? `/${viewport}` : ''}/${filename}`;
|
|
232
|
+
} else {
|
|
233
|
+
filename = plainFilename({ name: input.name, ext: got.ext });
|
|
234
|
+
relative = phase === '02-Recon' ? `${phase}/${date}/${filename}` : `${phase}/${filename}`;
|
|
235
|
+
}
|
|
236
|
+
const key = `${run.root}/${relative}`;
|
|
237
|
+
if (await store.has(key)) return { ok: false, error: 'evidence_capture_exists', ...tag };
|
|
238
|
+
const stored = await store.put(key, got.bytes);
|
|
239
|
+
const meta = got.meta !== undefined && JSON.stringify(got.meta).length <= 16384 ? got.meta : undefined;
|
|
240
|
+
await store.put(`${key}.evidence.json`, json({
|
|
241
|
+
schema: EVIDENCE_CAPTURE_SCHEMA, key: relative, file: filename, phase, flow: found?.flow.flow ?? null, step: found?.step.step ?? null, state: found?.state.state ?? null,
|
|
242
|
+
stateId: found?.id ?? null, variant: input.variant ?? null, viewport: viewport ?? null, name: found?.state.name ?? input.name, kind,
|
|
243
|
+
contentType: EXT_TYPES[got.ext] ?? 'application/octet-stream', bytes: stored.bytes, sha256: stored.sha256, capturedAt: now().toISOString(),
|
|
244
|
+
source: { kind: input.source.kind }, ...(input.caption ? { caption: input.caption } : {}),
|
|
245
|
+
...(Number.isFinite(got.durationMs) ? { durationMs: got.durationMs } : {}), ...(meta !== undefined ? { meta } : {}),
|
|
246
|
+
}));
|
|
247
|
+
if (input.beat && flowDir) {
|
|
248
|
+
const beatsKey = `${run.root}/${phase}/${date}/${flowDir}${viewport ? `/${viewport}` : ''}/${flowDir}.beats.json`;
|
|
249
|
+
const beats = await readJson(beatsKey, []);
|
|
250
|
+
beats.push({ state: found.id, label: String(input.beat.label ?? found.state.name), ...(Number.isFinite(input.beat.atMs) ? { atMs: input.beat.atMs } : {}), at: now().toISOString() });
|
|
251
|
+
await store.put(beatsKey, json(beats));
|
|
252
|
+
}
|
|
253
|
+
return { ok: true, key: relative, sha256: stored.sha256, bytes: stored.bytes, ...tag };
|
|
254
|
+
} catch (error) {
|
|
255
|
+
const code = String(error?.code ?? '').startsWith('evidence_') ? error.code : 'evidence_capture_failed';
|
|
256
|
+
if (found) {
|
|
257
|
+
const errorsKey = `${run.root}/${EVIDENCE_BUILD_PHASE}/capture-errors.json`;
|
|
258
|
+
await readJson(errorsKey, []).then((list) => store.put(errorsKey, json([...list, { stateId: found.id, ...(viewport ? { viewport } : {}), error: code, at: now().toISOString() }]))).catch(() => {});
|
|
259
|
+
}
|
|
260
|
+
return { ok: false, error: code, ...tag };
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const capture = op('sam.evidence.capture', 'capture', 'write',
|
|
265
|
+
'Capture one asset against a declared state (optionally across the declared viewport matrix), or a brief/recon asset. Operational failures return ok:false.',
|
|
266
|
+
async (input = {}, ctx = {}) => {
|
|
267
|
+
const run = await runFor('evidence.write', input, ctx);
|
|
268
|
+
const phase = input.phase ?? EVIDENCE_BUILD_PHASE;
|
|
269
|
+
if (!CAPTURE_PHASES.includes(phase)) return { ok: false, error: 'evidence_phase_unsupported' };
|
|
270
|
+
const kind = input.kind ?? 'still';
|
|
271
|
+
const date = input.date ?? utcDate(now());
|
|
272
|
+
if (!EVIDENCE_KINDS.includes(kind) || !DATE_RE.test(date) || (input.caption !== undefined && (typeof input.caption !== 'string' || input.caption.length > 200))) {
|
|
273
|
+
return { ok: false, error: 'evidence_capture_invalid' };
|
|
274
|
+
}
|
|
275
|
+
if (!drivers[input.source?.kind]) return { ok: false, error: 'evidence_source_unsupported' };
|
|
276
|
+
let found = null;
|
|
277
|
+
let viewports = [null];
|
|
278
|
+
if (phase === EVIDENCE_BUILD_PHASE) {
|
|
279
|
+
found = declaredStates(run.flowMap).find((s) => s.flow.flow === input.flow && s.step.step === input.step && s.state.state === input.state);
|
|
280
|
+
if (!found) return { ok: false, error: 'evidence_state_undeclared' };
|
|
281
|
+
if (input.name !== undefined && input.name !== found.state.name) return { ok: false, error: 'evidence_name_mismatch' };
|
|
282
|
+
const declared = run.flowMap.viewports ?? [];
|
|
283
|
+
const asked = Array.isArray(input.viewports) ? input.viewports : input.viewport !== undefined ? [input.viewport] : declared.length > 0 ? declared : [null];
|
|
284
|
+
if (asked.length === 0) return { ok: false, error: 'evidence_viewport_unknown' };
|
|
285
|
+
try { for (const v of asked) if (v !== null) resolveViewport(v); } catch { return { ok: false, error: 'evidence_viewport_unknown' }; }
|
|
286
|
+
if (declared.length > 0 && asked.some((v) => !declared.includes(v))) return { ok: false, error: 'evidence_viewport_undeclared' };
|
|
287
|
+
viewports = asked;
|
|
288
|
+
} else if (!CAMEL_RE.test(input.name ?? '')) {
|
|
289
|
+
return { ok: false, error: 'evidence_name_invalid' };
|
|
290
|
+
}
|
|
291
|
+
const results = [];
|
|
292
|
+
for (const viewport of viewports) results.push(await captureOne({ run, phase, found, kind, date, viewport, input }));
|
|
293
|
+
return results.length === 1 ? results[0] : { ok: results.every((r) => r.ok), captures: results };
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const seal = op('sam.evidence.seal', 'seal', 'write',
|
|
297
|
+
'Verify declared coverage and codecs, derive web copies and covers, compute facts, write screenplay and review page, then the manifest last. Status is computed.',
|
|
298
|
+
async (input = {}, ctx = {}) => {
|
|
299
|
+
const run = await runFor('evidence.write', input, ctx);
|
|
300
|
+
const manifestKey = `${run.root}/evidence.manifest.json`;
|
|
301
|
+
if (await store.has(manifestKey)) throw evidenceError('evidence_already_sealed');
|
|
302
|
+
const rel = (key) => key.slice(run.root.length + 1);
|
|
303
|
+
const relKeys = [];
|
|
304
|
+
for (const phase of CAPTURE_PHASES) relKeys.push(...(await store.list(`${run.root}/${phase}`)).map(rel));
|
|
305
|
+
const assets = [];
|
|
306
|
+
for (const key of relKeys.filter((k) => k.endsWith('.evidence.json'))) assets.push(JSON.parse((await store.get(`${run.root}/${key}`)).toString('utf8')));
|
|
307
|
+
assets.sort((a, b) => a.key.localeCompare(b.key));
|
|
308
|
+
|
|
309
|
+
const reasons = [];
|
|
310
|
+
const noncanonical = findNoncanonical(relKeys);
|
|
311
|
+
if (noncanonical.length > 0) reasons.push(`noncanonical_files:${noncanonical.length}`);
|
|
312
|
+
const flowAssets = assets.filter((a) => a.phase === EVIDENCE_BUILD_PHASE);
|
|
313
|
+
const captured = new Set(flowAssets.map((a) => (a.viewport ? `${a.stateId}@${a.viewport}` : a.stateId)));
|
|
314
|
+
const missing = expectedCaptures(run.flowMap).map((e) => e.key).filter((k) => !captured.has(k)).sort();
|
|
315
|
+
const results = input.results && typeof input.results === 'object' ? input.results : {};
|
|
316
|
+
const checks = run.flowMap.checks.map((check) => {
|
|
317
|
+
const result = results[check.id];
|
|
318
|
+
return { ...check, status: result === undefined ? 'not_reported' : result.passed === true ? 'passed' : 'failed', ...(result?.detail ? { detail: String(result.detail) } : {}) };
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
for (const asset of assets.filter((a) => a.contentType.startsWith('video/'))) {
|
|
322
|
+
if (typeof media?.probe !== 'function') { if (!reasons.includes('media_unverified')) reasons.push('media_unverified'); continue; }
|
|
323
|
+
const fullKey = `${run.root}/${asset.key}`;
|
|
324
|
+
const info = await media.probe({ key: fullKey, path: typeof store.localPath === 'function' ? await store.localPath(fullKey) : null, contentType: asset.contentType });
|
|
325
|
+
asset.media = info;
|
|
326
|
+
if (!isBrowserDecodable(info)) reasons.push(`codec_not_browser_decodable:${asset.stateId ?? asset.file}`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const derivatives = [];
|
|
330
|
+
if (derive) {
|
|
331
|
+
const putDerived = async (relKey, file, of) => {
|
|
332
|
+
const out = await store.put(`${run.root}/${relKey}`, file.bytes);
|
|
333
|
+
derivatives.push({ key: relKey, of, format: file.format, ...(file.width ? { width: file.width } : {}), bytes: out.bytes, sha256: out.sha256 });
|
|
334
|
+
};
|
|
335
|
+
for (const asset of assets) {
|
|
336
|
+
const base = asset.phase === EVIDENCE_BUILD_PHASE ? `05-Review/${asset.key.slice(EVIDENCE_BUILD_PHASE.length + 1)}` : `05-Review/${asset.key}`;
|
|
337
|
+
const dir = base.split('/').slice(0, -1).join('/');
|
|
338
|
+
const stem = asset.file.replace(/\.[^.]+$/, '');
|
|
339
|
+
try {
|
|
340
|
+
if (STILL_TYPES.has(asset.contentType) && typeof derive.stills === 'function') {
|
|
341
|
+
for (const file of await derive.stills({ bytes: await store.get(`${run.root}/${asset.key}`), stem })) await putDerived(`${dir}/${file.name}`, file, asset.key);
|
|
342
|
+
} else if (asset.contentType.startsWith('video/') && typeof derive.video === 'function' && typeof store.localPath === 'function') {
|
|
343
|
+
for (const file of await derive.video({ path: await store.localPath(`${run.root}/${asset.key}`), stem })) await putDerived(`${dir}/${file.name}`, file, asset.key);
|
|
344
|
+
}
|
|
345
|
+
} catch { reasons.push(`derive_failed:${asset.stateId ?? asset.file}`); }
|
|
346
|
+
}
|
|
347
|
+
const stills = flowAssets.filter((a) => STILL_TYPES.has(a.contentType));
|
|
348
|
+
const wanted = input.cover && typeof input.cover === 'object' ? stills.find((a) => a.stateId === input.cover.stateId && (a.viewport ?? null) === (input.cover.viewport ?? null)) : null;
|
|
349
|
+
const cover = wanted ?? stills.find((a) => a.viewport === 'desktop-1440x900') ?? stills[0];
|
|
350
|
+
if (cover && typeof derive.covers === 'function') {
|
|
351
|
+
try { for (const file of await derive.covers({ bytes: await store.get(`${run.root}/${cover.key}`) })) await putDerived(`06-Handoff/covers/${file.name}`, file, cover.key); } catch { reasons.push('derive_failed:covers'); }
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
let factsRef = null;
|
|
356
|
+
if (typeof facts === 'function') {
|
|
357
|
+
try {
|
|
358
|
+
const computed = await facts();
|
|
359
|
+
const out = await store.put(`${run.root}/facts.json`, json(computed));
|
|
360
|
+
factsRef = { key: 'facts.json', sha256: out.sha256 };
|
|
361
|
+
} catch { reasons.push('facts_failed'); }
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const handoff = [];
|
|
365
|
+
const beats = {};
|
|
366
|
+
for (const key of relKeys.filter((k) => k.endsWith('.beats.json'))) {
|
|
367
|
+
beats[key] = JSON.parse((await store.get(`${run.root}/${key}`)).toString('utf8'));
|
|
368
|
+
const srt = renderSrt(beats[key]);
|
|
369
|
+
if (!srt) continue;
|
|
370
|
+
const parts = key.split('/');
|
|
371
|
+
const suffix = VIEWPORT_DIR_RE.test(parts.at(-2)) ? `.${parts.at(-2)}` : '';
|
|
372
|
+
const name = `markers.${parts.at(-1).replace('.beats.json', '')}${suffix}.srt`;
|
|
373
|
+
const put = await store.put(`${run.root}/06-Handoff/${name}`, srt);
|
|
374
|
+
handoff.push({ key: `06-Handoff/${name}`, bytes: put.bytes, sha256: put.sha256 });
|
|
375
|
+
}
|
|
376
|
+
for (const [name, exporter] of Object.entries(exporters)) {
|
|
377
|
+
try {
|
|
378
|
+
const out = await exporter({ store, root: run.root, flowMap: run.flowMap, assets, runId: input.runId, beats });
|
|
379
|
+
for (const file of out?.files ?? []) {
|
|
380
|
+
assertSafeKey(`06-Handoff/${file.name}`);
|
|
381
|
+
const put = await store.put(`${run.root}/06-Handoff/${file.name}`, file.body);
|
|
382
|
+
handoff.push({ key: `06-Handoff/${file.name}`, bytes: put.bytes, sha256: put.sha256, exporter: name });
|
|
383
|
+
}
|
|
384
|
+
} catch { reasons.push(`exporter_failed:${name}`); }
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const final = [];
|
|
388
|
+
const approve = input.approve === 'all' ? 'all' : Array.isArray(input.approve) ? new Set(input.approve) : null;
|
|
389
|
+
if (approve) {
|
|
390
|
+
const approved = flowAssets.filter((a) => approve === 'all' || approve.has(a.stateId));
|
|
391
|
+
const keys = new Set(approved.map((a) => a.key));
|
|
392
|
+
for (const asset of approved) {
|
|
393
|
+
const out = await store.put(`${run.root}/05-Review/Final/${asset.key.slice(EVIDENCE_BUILD_PHASE.length + 1)}`, await store.get(`${run.root}/${asset.key}`));
|
|
394
|
+
final.push({ key: `05-Review/Final/${asset.key.slice(EVIDENCE_BUILD_PHASE.length + 1)}`, of: asset.key, sha256: out.sha256 });
|
|
395
|
+
}
|
|
396
|
+
for (const d of derivatives.filter((x) => keys.has(x.of) && x.key.startsWith('05-Review/'))) {
|
|
397
|
+
const target = `05-Review/Final/${d.key.slice('05-Review/'.length)}`;
|
|
398
|
+
const out = await store.put(`${run.root}/${target}`, await store.get(`${run.root}/${d.key}`));
|
|
399
|
+
final.push({ key: target, of: d.of, sha256: out.sha256 });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const perDate = {};
|
|
404
|
+
for (const asset of assets) { const date = assetDate(asset); perDate[date] = (perDate[date] ?? 0) + 1; }
|
|
405
|
+
const expected = expectedCaptures(run.flowMap);
|
|
406
|
+
const status = computeStatus({ assets: flowAssets, missing, checks, reasons });
|
|
407
|
+
const manifest = {
|
|
408
|
+
schema: EVIDENCE_SCHEMA, runId: input.runId, subject: run.flowMap.subject, project: run.flowMap.project, startedAt: run.flowMap.startedAt,
|
|
409
|
+
sealedAt: now().toISOString(), status, reasons, ...(run.flowMap.viewports ? { viewports: run.flowMap.viewports } : {}),
|
|
410
|
+
flows: run.flowMap.flows, checks, missing, errors: await readJson(`${run.root}/${EVIDENCE_BUILD_PHASE}/capture-errors.json`, []),
|
|
411
|
+
noncanonical, assets, derivatives, final, handoff, ...(factsRef ? { facts: factsRef } : {}),
|
|
412
|
+
answers: { daysOfWork: Object.keys(perDate).sort(), capturedPerDate: perDate, declaredStates: declaredStates(run.flowMap).length, capturedStates: expected.length - missing.length, missingStates: missing },
|
|
413
|
+
};
|
|
414
|
+
const screenplay = await writeReview(run.root, manifest, []);
|
|
415
|
+
for (const [name, body] of [['screenplay.md', screenplay.md], ['screenplay.json', json(screenplay.json)]]) {
|
|
416
|
+
const put = await store.put(`${run.root}/06-Handoff/${name}`, body);
|
|
417
|
+
manifest.handoff.push({ key: `06-Handoff/${name}`, bytes: put.bytes, sha256: put.sha256 });
|
|
418
|
+
}
|
|
419
|
+
manifest.review = { key: 'review.html' };
|
|
420
|
+
await store.put(manifestKey, json(manifest)); // written LAST: the completion marker
|
|
421
|
+
return { ok: true, status, reasons, missing, manifestKey: 'evidence.manifest.json', assets: assets.length, derivatives: derivatives.length, final: final.length };
|
|
422
|
+
}, { artifacts: ['evidence.manifest'] });
|
|
423
|
+
|
|
424
|
+
const deliver = op('sam.evidence.deliver', 'deliver', 'write',
|
|
425
|
+
'Serve a sealed run read-only on loopback (port 0 unless requested) and return the manifest and review-page URLs.',
|
|
426
|
+
async (input = {}, ctx = {}) => {
|
|
427
|
+
const run = await runFor('evidence.read', input, ctx);
|
|
428
|
+
if (!(await store.has(`${run.root}/evidence.manifest.json`))) throw evidenceError('evidence_not_sealed');
|
|
429
|
+
if (input.port !== undefined && !(Number.isInteger(input.port) && input.port >= 0 && input.port <= 65535)) throw evidenceError('evidence_port_invalid');
|
|
430
|
+
const ttlSeconds = Math.min(Math.max(Number(input.ttlSeconds ?? 900), 30), 3600);
|
|
431
|
+
const server = await startEvidenceServer({ store, prefix: run.root, port: input.port ?? 0, ttlMs: ttlSeconds * 1000 });
|
|
432
|
+
servers.add(server);
|
|
433
|
+
server.onClose(() => servers.delete(server));
|
|
434
|
+
const manifestUrl = `${server.origin}/evidence.manifest.json`;
|
|
435
|
+
let viewerLink;
|
|
436
|
+
if (input.viewerUrl !== undefined) {
|
|
437
|
+
const viewer = new URL(String(input.viewerUrl));
|
|
438
|
+
if (viewer.protocol !== 'http:' && viewer.protocol !== 'https:') { await server.close(); throw evidenceError('evidence_viewer_url_invalid'); }
|
|
439
|
+
viewer.searchParams.set('evidence', manifestUrl);
|
|
440
|
+
viewerLink = viewer.toString();
|
|
441
|
+
}
|
|
442
|
+
return { ok: true, url: server.url, manifestUrl, reviewUrl: `${server.origin}/review.html`, ...(viewerLink ? { viewerLink } : {}), expiresAt: server.expiresAt, ttlSeconds };
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const compare = op('sam.evidence.compare', 'compare', 'write',
|
|
446
|
+
'Pair the same state across two sealed runs of one project and crop what changed (then | now). Results are written under the newer run.',
|
|
447
|
+
async (input = {}, ctx = {}) => {
|
|
448
|
+
if (typeof images?.sharp !== 'function') throw evidenceError('evidence_image_engine_unavailable');
|
|
449
|
+
const who = await principalFor('evidence.write', input, ctx);
|
|
450
|
+
for (const id of [input.a, input.b]) if (typeof id !== 'string' || !RUN_ID_RE.test(id)) throw evidenceError('evidence_run_id_invalid');
|
|
451
|
+
if (input.a === input.b) throw evidenceError('evidence_compare_same_run');
|
|
452
|
+
await permit(who, input.b);
|
|
453
|
+
const rootA = `${who.project.slug}/${input.a}`;
|
|
454
|
+
const rootB = `${who.project.slug}/${input.b}`;
|
|
455
|
+
const [manifestA, manifestB] = await Promise.all([readJson(`${rootA}/evidence.manifest.json`, null), readJson(`${rootB}/evidence.manifest.json`, null)]);
|
|
456
|
+
if (!manifestA || !manifestB) throw evidenceError('evidence_not_sealed');
|
|
457
|
+
const result = await compareRuns({ sharp: images.sharp, store, rootA, rootB, runA: input.a, manifestA, manifestB, now });
|
|
458
|
+
await writeReview(rootB, manifestB, [result]);
|
|
459
|
+
const count = (status) => result.pairs.filter((p) => p.status === status).length;
|
|
460
|
+
return { ok: true, key: result.key, changed: count('changed'), unchanged: count('unchanged'), dimensionChanged: count('dimension_changed'), unmatchedA: result.unmatchedA.length, unmatchedB: result.unmatchedB.length };
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
const ingest = op('sam.evidence.ingest', 'ingest', 'write',
|
|
464
|
+
'Plan (default) or apply the import of an existing folder of captures into the canonical layout. Originals are never moved or renamed.',
|
|
465
|
+
async (input = {}, ctx = {}) => {
|
|
466
|
+
await principalFor('evidence.write', input, ctx);
|
|
467
|
+
const dir = input.source?.path;
|
|
468
|
+
if (typeof dir !== 'string' || !path.isAbsolute(dir)) throw evidenceError('evidence_source_invalid');
|
|
469
|
+
const real = await insideReadable(dir);
|
|
470
|
+
const files = await listFiles(real);
|
|
471
|
+
const plan = planIngest(files.map((f) => ({ path: f.path, mtime: f.mtime })), { flowName: input.flowName });
|
|
472
|
+
if (input.apply !== true) return { ok: true, applied: false, plan };
|
|
473
|
+
if (plan.flows.length === 0) return { ok: false, applied: false, error: 'evidence_ingest_nothing_to_import', plan };
|
|
474
|
+
const begun = await begin.handler({ subject: input.subject, project: input.project, flows: plan.flows, viewports: plan.viewports }, ctx);
|
|
475
|
+
const byPath = new Map(files.map((f) => [f.path, f]));
|
|
476
|
+
const results = [];
|
|
477
|
+
for (const c of plan.captures) {
|
|
478
|
+
const outcome = await capture.handler({
|
|
479
|
+
runId: begun.runId, project: input.project, phase: c.phase, flow: c.flow, step: c.step, state: c.state, name: c.name, variant: c.variant,
|
|
480
|
+
viewport: c.viewport ?? undefined, kind: c.kind, date: c.date, source: { kind: 'file', path: byPath.get(c.from).abs },
|
|
481
|
+
}, ctx);
|
|
482
|
+
results.push({ from: c.from, ...outcome });
|
|
483
|
+
}
|
|
484
|
+
const failed = results.filter((r) => !r.ok);
|
|
485
|
+
return { ok: failed.length === 0, applied: true, runId: begun.runId, prefix: begun.prefix, imported: results.length - failed.length, failed, skipped: plan.skipped, notes: plan.notes };
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
const operations = [begin, capture, seal, deliver, compare, ingest];
|
|
489
|
+
operations.shutdown = async () => {
|
|
490
|
+
await Promise.all([...servers].map((server) => server.close()));
|
|
491
|
+
await Promise.all(Object.values(drivers).map((driver) => driver.close?.()));
|
|
492
|
+
};
|
|
493
|
+
return operations;
|
|
494
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { evidenceError } from './contract.js';
|
|
4
|
+
|
|
5
|
+
const defaultExec = promisify(execFile);
|
|
6
|
+
const BIG = { maxBuffer: 32 * 1024 * 1024 };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Media adapter for `seal`: probes a stored video and proves it decodes. A passing probe is a
|
|
10
|
+
* decoder smoke check, not visual parity. Browser recordings often lack a duration header, so the
|
|
11
|
+
* duration falls back to what the decoder actually read.
|
|
12
|
+
*/
|
|
13
|
+
export function createFfprobeMedia({ ffprobe = 'ffprobe', ffmpeg = 'ffmpeg', decode = true, exec = defaultExec } = {}) {
|
|
14
|
+
return {
|
|
15
|
+
async probe({ path: file }) {
|
|
16
|
+
if (typeof file !== 'string' || file.length === 0) throw evidenceError('evidence_media_path_required');
|
|
17
|
+
const { stdout } = await exec(ffprobe, ['-v', 'error', '-show_format', '-show_streams', '-of', 'json', file], BIG);
|
|
18
|
+
const meta = JSON.parse(stdout);
|
|
19
|
+
const streams = meta.streams ?? [];
|
|
20
|
+
const video = streams.find((s) => s.codec_type === 'video');
|
|
21
|
+
const audio = streams.find((s) => s.codec_type === 'audio');
|
|
22
|
+
let seconds = Number(meta.format?.duration ?? video?.duration);
|
|
23
|
+
let decoded = null;
|
|
24
|
+
if (decode && video) {
|
|
25
|
+
try {
|
|
26
|
+
const { stderr } = await exec(ffmpeg, ['-nostdin', '-v', 'error', '-xerror', '-stats', '-i', file, '-map', '0:v:0', '-f', 'null', '-'], BIG);
|
|
27
|
+
decoded = true;
|
|
28
|
+
if (!Number.isFinite(seconds) || seconds <= 0) {
|
|
29
|
+
const times = [...String(stderr).matchAll(/time=(\d+):(\d+):(\d+(?:\.\d+)?)/g)];
|
|
30
|
+
const last = times.at(-1);
|
|
31
|
+
if (last) seconds = Number(last[1]) * 3600 + Number(last[2]) * 60 + Number(last[3]);
|
|
32
|
+
}
|
|
33
|
+
} catch { decoded = false; }
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
container: meta.format?.format_name ?? null,
|
|
37
|
+
durationMs: Number.isFinite(seconds) && seconds > 0 ? Math.round(seconds * 1000) : null,
|
|
38
|
+
video: video ? { codec: video.codec_name, width: video.width, height: video.height, frames: video.nb_frames ? Number(video.nb_frames) : null } : null,
|
|
39
|
+
audio: audio ? { codec: audio.codec_name, channels: audio.channels } : null,
|
|
40
|
+
decoded,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { evidenceError } from './contract.js';
|
|
3
|
+
|
|
4
|
+
export const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
5
|
+
export const PROJECT_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
6
|
+
export const CAMEL_RE = /^[A-Z][A-Za-z0-9]{0,47}$/;
|
|
7
|
+
export const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
8
|
+
export const RUN_ID_RE = /^[a-z0-9][a-z0-9-]{0,62}--\d{8}--[a-f0-9]{7}$/;
|
|
9
|
+
export const CAPTURE_FILE_RE = /^\d{2,3}-\d{2,3}-\d{2,3}[a-z]?-[A-Z][A-Za-z0-9]*\.[a-z0-9]{2,5}$/;
|
|
10
|
+
export const PLAIN_FILE_RE = /^[A-Z][A-Za-z0-9]{0,47}\.[a-z0-9]{2,5}$/;
|
|
11
|
+
export const VIEWPORT_DIR_RE = /^(mobile|tablet|desktop)-\d{3,4}x\d{3,4}$/;
|
|
12
|
+
|
|
13
|
+
// Dates and versions live in the run id and the series, never in a subject name.
|
|
14
|
+
const DATE_TOKEN = /(^|-)(19|20)\d{6}(-|$)/;
|
|
15
|
+
const VERSION_TOKEN = /(^|-)v\d+(-|$)/;
|
|
16
|
+
|
|
17
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
18
|
+
|
|
19
|
+
export const stateId = (flow, step, state) => `${pad(flow)}-${pad(step)}-${pad(state)}`;
|
|
20
|
+
export const flowDirName = (flow, name) => `${pad(flow)}-${name}`;
|
|
21
|
+
|
|
22
|
+
/** UTC calendar date. `compact` gives YYYYMMDD, otherwise YYYY-MM-DD. */
|
|
23
|
+
export function utcDate(value, compact = false) {
|
|
24
|
+
const iso = new Date(value).toISOString().slice(0, 10);
|
|
25
|
+
return compact ? iso.replaceAll('-', '') : iso;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function assertSubject(subject) {
|
|
29
|
+
if (typeof subject !== 'string' || !SLUG_RE.test(subject)) throw evidenceError('evidence_subject_invalid');
|
|
30
|
+
if (DATE_TOKEN.test(subject)) throw evidenceError('evidence_subject_contains_date');
|
|
31
|
+
if (VERSION_TOKEN.test(subject)) throw evidenceError('evidence_subject_contains_version');
|
|
32
|
+
return subject;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `<subject>--<YYYYMMDD>--<run7>`. run7 hashes the inputs plus a nonce, so ids never depend on
|
|
37
|
+
* git state or any host. The subject is always caller-supplied.
|
|
38
|
+
*/
|
|
39
|
+
export function makeRunId({ subject, project, startedAt, nonce }) {
|
|
40
|
+
assertSubject(subject);
|
|
41
|
+
const suffix = createHash('sha256').update([subject, project, startedAt, nonce].join('\0')).digest('hex').slice(0, 7);
|
|
42
|
+
return `${subject}--${utcDate(startedAt, true)}--${suffix}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Zero-padded, CamelCase file name; the write-time guard against bad names. */
|
|
46
|
+
export function captureFilename({ flow, step, state, variant, name, ext }) {
|
|
47
|
+
if (variant !== undefined && !/^[a-z]$/.test(variant)) throw evidenceError('evidence_name_invalid', 'variant');
|
|
48
|
+
const file = `${stateId(flow, step, state)}${variant ?? ''}-${name}.${ext}`;
|
|
49
|
+
if (!CAPTURE_FILE_RE.test(file)) throw evidenceError('evidence_name_invalid', file);
|
|
50
|
+
return file;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Brief and recon assets are not part of a flow: CamelCase name plus extension. */
|
|
54
|
+
export function plainFilename({ name, ext }) {
|
|
55
|
+
const file = `${name}.${ext}`;
|
|
56
|
+
if (!PLAIN_FILE_RE.test(file)) throw evidenceError('evidence_name_invalid', file);
|
|
57
|
+
return file;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Keys are relative, slash-separated, never absolute, never contain "..". */
|
|
61
|
+
export function assertSafeKey(key) {
|
|
62
|
+
if (typeof key !== 'string' || key.length === 0 || key.length > 512) throw evidenceError('evidence_key_invalid');
|
|
63
|
+
for (const segment of key.split('/')) {
|
|
64
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(segment) || segment.includes('..')) throw evidenceError('evidence_key_invalid');
|
|
65
|
+
}
|
|
66
|
+
return key;
|
|
67
|
+
}
|