@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,109 @@
|
|
|
1
|
+
"""Minimal stdlib HTML tree parser.
|
|
2
|
+
|
|
3
|
+
Replaces BeautifulSoup. Builds just enough of a DOM -- a tree of Node
|
|
4
|
+
objects with tag/attrs/children/parent/text -- to support link/image/text
|
|
5
|
+
extraction and section classification by ancestor class/id tokens.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from html.parser import HTMLParser
|
|
11
|
+
from typing import Iterator, Optional
|
|
12
|
+
|
|
13
|
+
VOID_ELEMENTS = {
|
|
14
|
+
"area", "base", "br", "col", "embed", "hr", "img", "input",
|
|
15
|
+
"link", "meta", "param", "source", "track", "wbr",
|
|
16
|
+
}
|
|
17
|
+
IGNORED_TEXT_TAGS = {"script", "style", "noscript", "template", "svg"}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Node:
|
|
21
|
+
__slots__ = ("tag", "attrs", "children", "parent", "text")
|
|
22
|
+
|
|
23
|
+
def __init__(self, tag: str, attrs: dict[str, str], parent: Optional["Node"]):
|
|
24
|
+
self.tag = tag
|
|
25
|
+
self.attrs = attrs
|
|
26
|
+
self.children: list["Node"] = []
|
|
27
|
+
self.parent = parent
|
|
28
|
+
self.text = ""
|
|
29
|
+
|
|
30
|
+
def get(self, key: str, default: str = "") -> str:
|
|
31
|
+
return self.attrs.get(key, default)
|
|
32
|
+
|
|
33
|
+
def walk(self) -> Iterator["Node"]:
|
|
34
|
+
yield self
|
|
35
|
+
for child in self.children:
|
|
36
|
+
yield from child.walk()
|
|
37
|
+
|
|
38
|
+
def find_all(self, *tags: str) -> list["Node"]:
|
|
39
|
+
tagset = set(tags)
|
|
40
|
+
return [n for n in self.walk() if n.tag in tagset]
|
|
41
|
+
|
|
42
|
+
def ancestor_tokens(self) -> list[str]:
|
|
43
|
+
"""Lowercased class / id / tag tokens from this node up to the root.
|
|
44
|
+
|
|
45
|
+
Tokenized (split on whitespace and common separators) so classifiers
|
|
46
|
+
can match whole tokens like ``nav`` instead of fragile substring
|
|
47
|
+
patterns such as ``\" nav \"``.
|
|
48
|
+
"""
|
|
49
|
+
tokens: list[str] = []
|
|
50
|
+
node: Optional[Node] = self
|
|
51
|
+
while node is not None:
|
|
52
|
+
for raw in (node.attrs.get("class", ""), node.attrs.get("id", "")):
|
|
53
|
+
for part in raw.replace("_", "-").replace("/", " ").split():
|
|
54
|
+
for piece in part.split("-"):
|
|
55
|
+
piece = piece.strip().lower()
|
|
56
|
+
if piece:
|
|
57
|
+
tokens.append(piece)
|
|
58
|
+
if node.tag and node.tag != "root":
|
|
59
|
+
tokens.append(node.tag.lower())
|
|
60
|
+
node = node.parent
|
|
61
|
+
return tokens
|
|
62
|
+
|
|
63
|
+
def ancestor_context(self) -> str:
|
|
64
|
+
"""Space-joined ancestor tokens (compat string for keyword `in` checks)."""
|
|
65
|
+
return " ".join(self.ancestor_tokens())
|
|
66
|
+
|
|
67
|
+
def text_content(self) -> str:
|
|
68
|
+
parts = [n.text for n in self.walk() if n.tag not in IGNORED_TEXT_TAGS]
|
|
69
|
+
return " ".join(p for p in parts if p)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class _TreeBuilder(HTMLParser):
|
|
73
|
+
def __init__(self) -> None:
|
|
74
|
+
super().__init__(convert_charrefs=True)
|
|
75
|
+
self.root = Node("root", {}, None)
|
|
76
|
+
self._stack: list[Node] = [self.root]
|
|
77
|
+
|
|
78
|
+
def handle_starttag(self, tag: str, attrs_list) -> None:
|
|
79
|
+
attrs = {k: (v or "") for k, v in attrs_list}
|
|
80
|
+
node = Node(tag, attrs, self._stack[-1])
|
|
81
|
+
self._stack[-1].children.append(node)
|
|
82
|
+
if tag not in VOID_ELEMENTS:
|
|
83
|
+
self._stack.append(node)
|
|
84
|
+
|
|
85
|
+
def handle_startendtag(self, tag: str, attrs_list) -> None:
|
|
86
|
+
attrs = {k: (v or "") for k, v in attrs_list}
|
|
87
|
+
self._stack[-1].children.append(Node(tag, attrs, self._stack[-1]))
|
|
88
|
+
|
|
89
|
+
def handle_endtag(self, tag: str) -> None:
|
|
90
|
+
# Walk back to the nearest matching open tag; tolerate mismatched
|
|
91
|
+
# or unclosed tags instead of raising.
|
|
92
|
+
for i in range(len(self._stack) - 1, 0, -1):
|
|
93
|
+
if self._stack[i].tag == tag:
|
|
94
|
+
del self._stack[i + 1:]
|
|
95
|
+
self._stack.pop()
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
def handle_data(self, data: str) -> None:
|
|
99
|
+
top = self._stack[-1]
|
|
100
|
+
if top.tag in IGNORED_TEXT_TAGS:
|
|
101
|
+
return
|
|
102
|
+
if data.strip():
|
|
103
|
+
top.text = f"{top.text} {data}".strip() if top.text else data.strip()
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def parse(html: str) -> Node:
|
|
107
|
+
builder = _TreeBuilder()
|
|
108
|
+
builder.feed(html)
|
|
109
|
+
return builder.root
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Image dimensions + optimization via macOS sips (fail-loud when missing)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import shutil
|
|
6
|
+
import struct
|
|
7
|
+
import subprocess
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
_SIPS_PATH = shutil.which("sips")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def sips_available() -> bool:
|
|
14
|
+
return _SIPS_PATH is not None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def read_dimensions(path: Path) -> tuple[int, int] | None:
|
|
18
|
+
"""Return (width, height) from PNG/JPEG headers; None for unsupported formats."""
|
|
19
|
+
try:
|
|
20
|
+
data = path.read_bytes()
|
|
21
|
+
except OSError:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
if data[:8] == b"\x89PNG\r\n\x1a\n":
|
|
25
|
+
if len(data) >= 24 and data[12:16] == b"IHDR":
|
|
26
|
+
width, height = struct.unpack(">II", data[16:24])
|
|
27
|
+
return width, height
|
|
28
|
+
return None
|
|
29
|
+
|
|
30
|
+
if data[:2] == b"\xff\xd8": # JPEG SOI
|
|
31
|
+
i = 2
|
|
32
|
+
while i + 4 <= len(data):
|
|
33
|
+
if data[i] != 0xFF:
|
|
34
|
+
i += 1
|
|
35
|
+
continue
|
|
36
|
+
marker = data[i + 1]
|
|
37
|
+
if marker in (0xD8, 0x01) or 0xD0 <= marker <= 0xD7:
|
|
38
|
+
i += 2
|
|
39
|
+
continue
|
|
40
|
+
if i + 4 > len(data):
|
|
41
|
+
break
|
|
42
|
+
segment_len = struct.unpack(">H", data[i + 2:i + 4])[0]
|
|
43
|
+
if marker in (0xC0, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCD, 0xCE, 0xCF):
|
|
44
|
+
if i + 9 <= len(data):
|
|
45
|
+
height, width = struct.unpack(">HH", data[i + 5:i + 9])
|
|
46
|
+
return width, height
|
|
47
|
+
return None
|
|
48
|
+
i += 2 + segment_len
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
# WebP VP8 / VP8L / VP8X (optional — avoids unknown aspect on Wix CDNs)
|
|
52
|
+
if data[:4] == b"RIFF" and len(data) >= 30 and data[8:12] == b"WEBP":
|
|
53
|
+
chunk = data[12:16]
|
|
54
|
+
if chunk == b"VP8 " and len(data) >= 30:
|
|
55
|
+
width = struct.unpack("<H", data[26:28])[0] & 0x3FFF
|
|
56
|
+
height = struct.unpack("<H", data[28:30])[0] & 0x3FFF
|
|
57
|
+
return width, height
|
|
58
|
+
if chunk == b"VP8L" and len(data) >= 25:
|
|
59
|
+
bits = struct.unpack("<I", data[21:25])[0]
|
|
60
|
+
width = (bits & 0x3FFF) + 1
|
|
61
|
+
height = ((bits >> 14) & 0x3FFF) + 1
|
|
62
|
+
return width, height
|
|
63
|
+
if chunk == b"VP8X" and len(data) >= 30:
|
|
64
|
+
width = 1 + int.from_bytes(data[24:27], "little")
|
|
65
|
+
height = 1 + int.from_bytes(data[27:30], "little")
|
|
66
|
+
return width, height
|
|
67
|
+
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def sniff_image_ext(data: bytes) -> str | None:
|
|
72
|
+
"""Return a file extension from magic bytes, or None if not a known image."""
|
|
73
|
+
if len(data) < 12:
|
|
74
|
+
return None
|
|
75
|
+
if data[:8] == b"\x89PNG\r\n\x1a\n":
|
|
76
|
+
return ".png"
|
|
77
|
+
if data[:2] == b"\xff\xd8":
|
|
78
|
+
return ".jpg"
|
|
79
|
+
if data[:6] in (b"GIF87a", b"GIF89a"):
|
|
80
|
+
return ".gif"
|
|
81
|
+
if data[:4] == b"RIFF" and data[8:12] == b"WEBP":
|
|
82
|
+
return ".webp"
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def optimize_image(
|
|
87
|
+
src: Path,
|
|
88
|
+
dst: Path,
|
|
89
|
+
max_long_edge: int,
|
|
90
|
+
jpeg_quality: int,
|
|
91
|
+
*,
|
|
92
|
+
allow_unoptimized: bool = False,
|
|
93
|
+
) -> str:
|
|
94
|
+
"""Resize/recompress with sips. Fail loud if sips missing unless allowed."""
|
|
95
|
+
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
96
|
+
|
|
97
|
+
if _SIPS_PATH is None:
|
|
98
|
+
if not allow_unoptimized:
|
|
99
|
+
raise RuntimeError(
|
|
100
|
+
"sips not found — image optimization requires macOS sips. "
|
|
101
|
+
"Pass --no-optimize or --allow-unoptimized to continue with copies."
|
|
102
|
+
)
|
|
103
|
+
shutil.copyfile(src, dst)
|
|
104
|
+
return "copied:no-sips"
|
|
105
|
+
|
|
106
|
+
suffix = src.suffix.lower()
|
|
107
|
+
if suffix not in (".jpg", ".jpeg", ".png"):
|
|
108
|
+
shutil.copyfile(src, dst)
|
|
109
|
+
return "copied:unsupported-format"
|
|
110
|
+
|
|
111
|
+
shutil.copyfile(src, dst)
|
|
112
|
+
cmd = [_SIPS_PATH, "-Z", str(max_long_edge)]
|
|
113
|
+
if suffix in (".jpg", ".jpeg"):
|
|
114
|
+
cmd += ["-s", "formatOptions", str(jpeg_quality)]
|
|
115
|
+
cmd += [str(dst)]
|
|
116
|
+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
|
|
117
|
+
if result.returncode != 0:
|
|
118
|
+
if not allow_unoptimized:
|
|
119
|
+
raise RuntimeError(f"sips failed: {result.stderr.strip()[:200]}")
|
|
120
|
+
return f"copied:sips-failed:{result.stderr.strip()[:200]}"
|
|
121
|
+
return "optimized"
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""Non-interactive `--json` run: discover -> crawl (pages only) -> canonical receipt on stdout.
|
|
2
|
+
|
|
3
|
+
All logging goes to stderr so stdout is exactly one JSON document.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
import time
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from . import net
|
|
15
|
+
from .contract import build_result
|
|
16
|
+
from .crawl import CrawlResult, crawl, discover
|
|
17
|
+
from .pageextract import clean_url
|
|
18
|
+
from .ssrf import assert_public_http_url
|
|
19
|
+
from .__main__ import _slugify_target_name
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def run_json(args) -> int:
|
|
23
|
+
try:
|
|
24
|
+
if not args.url:
|
|
25
|
+
print("--json requires a seed URL.", file=sys.stderr)
|
|
26
|
+
return 2
|
|
27
|
+
seed_url = clean_url(args.url)
|
|
28
|
+
assert_public_http_url(seed_url, context="seed")
|
|
29
|
+
except ValueError as exc:
|
|
30
|
+
print(str(exc), file=sys.stderr)
|
|
31
|
+
return 2
|
|
32
|
+
|
|
33
|
+
if not 1 <= args.max_pages <= 5000 or args.delay < 0:
|
|
34
|
+
print("--max-pages must be 1..5000 and --delay must be nonnegative", file=sys.stderr)
|
|
35
|
+
return 2
|
|
36
|
+
|
|
37
|
+
started = time.time()
|
|
38
|
+
session = net.new_session()
|
|
39
|
+
robots = net.Robots(session)
|
|
40
|
+
found = discover(seed_url, session, robots, args.ignore_robots)
|
|
41
|
+
if found.fetch_error:
|
|
42
|
+
print(f"Discovery failed: {found.fetch_error}", file=sys.stderr)
|
|
43
|
+
result = CrawlResult(target=_slugify_target_name(seed_url), seed_urls=[seed_url],
|
|
44
|
+
errors=[{"url": seed_url, "error": found.fetch_error}], pages_visited=1)
|
|
45
|
+
receipt = build_result(result, started_at=started, completed_at=time.time(),
|
|
46
|
+
scope={"sameSite": True, "maxPages": args.max_pages},
|
|
47
|
+
policy={"respectRobots": not args.ignore_robots, "hostDelayMs": int(args.delay * 1000)},
|
|
48
|
+
capture={"metadata": True, "text": False, "html": False, "assets": False})
|
|
49
|
+
if getattr(args, "archive_dir", None):
|
|
50
|
+
from .evidence import stage_evidence, upload_evidence
|
|
51
|
+
try:
|
|
52
|
+
staged = stage_evidence(result, receipt, account_id=args.account_id,
|
|
53
|
+
project_id=args.project_id,
|
|
54
|
+
archive_dir=Path(args.archive_dir))
|
|
55
|
+
print(f"Failed crawl evidence staged: {staged['root']}", file=sys.stderr)
|
|
56
|
+
receipt["storage"] = {"status": "staged", "prefix": staged["prefix"]}
|
|
57
|
+
if getattr(args, "upload_archive", False):
|
|
58
|
+
from .storage import resolve_evidence_bucket
|
|
59
|
+
choice = resolve_evidence_bucket(Path(args.repo_root), selected_bucket=args.archive_bucket,
|
|
60
|
+
wrangler_config=getattr(args, "wrangler_config", None))
|
|
61
|
+
uploaded = upload_evidence(staged["root"], bucket=choice["bucket"],
|
|
62
|
+
repo_root=Path(args.repo_root),
|
|
63
|
+
wrangler_config=getattr(args, "wrangler_config", None))
|
|
64
|
+
receipt["storage"] = {"status": "uploaded", "prefix": staged["prefix"],
|
|
65
|
+
"bucket": uploaded["bucket"]}
|
|
66
|
+
print(f"Private evidence uploaded: {uploaded['bucket']}/{uploaded['manifest_key']}", file=sys.stderr)
|
|
67
|
+
except Exception as exc:
|
|
68
|
+
receipt["storage"] = {"status": "failed", "error": str(exc)}
|
|
69
|
+
print(f"Evidence archive failed: {exc}", file=sys.stderr)
|
|
70
|
+
json.dump(receipt, sys.stdout, ensure_ascii=False)
|
|
71
|
+
sys.stdout.write("\n")
|
|
72
|
+
return 1
|
|
73
|
+
|
|
74
|
+
seeds, seen = [], set()
|
|
75
|
+
for u in [seed_url, *found.nav_candidates, *found.other_candidates]:
|
|
76
|
+
if u not in seen:
|
|
77
|
+
seen.add(u)
|
|
78
|
+
seeds.append(u)
|
|
79
|
+
|
|
80
|
+
with tempfile.TemporaryDirectory(prefix="agentsam-site-scrape-") as tmp:
|
|
81
|
+
result = crawl(
|
|
82
|
+
_slugify_target_name(seed_url),
|
|
83
|
+
seeds,
|
|
84
|
+
Path(tmp),
|
|
85
|
+
expand_domain=args.expand_domain,
|
|
86
|
+
max_pages=args.max_pages,
|
|
87
|
+
delay=args.delay,
|
|
88
|
+
download_images=getattr(args, "capture_assets", False),
|
|
89
|
+
optimize=not getattr(args, "no_optimize", False),
|
|
90
|
+
image_workers=getattr(args, "workers", 8),
|
|
91
|
+
allow_unoptimized=getattr(args, "allow_unoptimized", False),
|
|
92
|
+
ignore_robots=args.ignore_robots,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
receipt = build_result(
|
|
96
|
+
result,
|
|
97
|
+
started_at=started,
|
|
98
|
+
completed_at=time.time(),
|
|
99
|
+
scope={"sameSite": True, "maxPages": args.max_pages},
|
|
100
|
+
policy={"respectRobots": not args.ignore_robots, "hostDelayMs": int(args.delay * 1000)},
|
|
101
|
+
capture={"metadata": True, "text": False, "html": False,
|
|
102
|
+
"assets": getattr(args, "capture_assets", False)},
|
|
103
|
+
)
|
|
104
|
+
if getattr(args, "archive_dir", None):
|
|
105
|
+
from .evidence import stage_evidence, upload_evidence
|
|
106
|
+
try:
|
|
107
|
+
staged = stage_evidence(result, receipt, account_id=args.account_id,
|
|
108
|
+
project_id=args.project_id,
|
|
109
|
+
archive_dir=Path(args.archive_dir))
|
|
110
|
+
receipt["storage"] = {"status": "staged", "prefix": staged["prefix"]}
|
|
111
|
+
print(f"Private evidence staged: {staged['root']}", file=sys.stderr)
|
|
112
|
+
if getattr(args, "upload_archive", False):
|
|
113
|
+
from .storage import resolve_evidence_bucket
|
|
114
|
+
choice = resolve_evidence_bucket(Path(args.repo_root), selected_bucket=args.archive_bucket,
|
|
115
|
+
wrangler_config=getattr(args, "wrangler_config", None))
|
|
116
|
+
uploaded = upload_evidence(staged["root"], bucket=choice["bucket"],
|
|
117
|
+
repo_root=Path(args.repo_root),
|
|
118
|
+
wrangler_config=getattr(args, "wrangler_config", None))
|
|
119
|
+
receipt["storage"] = {"status": "uploaded", "prefix": staged["prefix"],
|
|
120
|
+
"bucket": uploaded["bucket"]}
|
|
121
|
+
print(f"Private evidence uploaded: {uploaded['bucket']}/{uploaded['manifest_key']}", file=sys.stderr)
|
|
122
|
+
except Exception as exc:
|
|
123
|
+
receipt["storage"] = {"status": "failed", "error": str(exc)}
|
|
124
|
+
print(f"Evidence archive failed: {exc}", file=sys.stderr)
|
|
125
|
+
json.dump(receipt, sys.stdout, indent=2, ensure_ascii=False)
|
|
126
|
+
sys.stdout.write("\n")
|
|
127
|
+
return 1 if receipt["status"] == "failed" or receipt.get("storage", {}).get("status") == "failed" else 0
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""HTTP layer: retrying requests session + robots.txt gate + thread-local sessions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import random
|
|
6
|
+
import threading
|
|
7
|
+
import time
|
|
8
|
+
from urllib.parse import urlparse, urljoin
|
|
9
|
+
|
|
10
|
+
from .ssrf import assert_public_http_url
|
|
11
|
+
from urllib.robotparser import RobotFileParser
|
|
12
|
+
|
|
13
|
+
import requests
|
|
14
|
+
|
|
15
|
+
from .config import MAX_RETRIES, REQUEST_TIMEOUT, RETRY_BACKOFF_BASE, USER_AGENT
|
|
16
|
+
|
|
17
|
+
RETRYABLE_STATUS = {429, 500, 502, 503, 504}
|
|
18
|
+
|
|
19
|
+
_thread_local = threading.local()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def new_session() -> requests.Session:
|
|
23
|
+
session = requests.Session()
|
|
24
|
+
session.headers.update({"User-Agent": USER_AGENT, "Accept-Language": "en-US,en;q=0.9"})
|
|
25
|
+
return session
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def thread_session() -> requests.Session:
|
|
29
|
+
"""Per-thread Session — requests.Session is not thread-safe."""
|
|
30
|
+
session = getattr(_thread_local, "session", None)
|
|
31
|
+
if session is None:
|
|
32
|
+
session = new_session()
|
|
33
|
+
_thread_local.session = session
|
|
34
|
+
return session
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _sleep_backoff(attempt: int) -> None:
|
|
38
|
+
delay = RETRY_BACKOFF_BASE * (2 ** attempt) + random.uniform(0, 0.25)
|
|
39
|
+
time.sleep(delay)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_with_retry(
|
|
43
|
+
session: requests.Session,
|
|
44
|
+
url: str,
|
|
45
|
+
*,
|
|
46
|
+
stream: bool = False,
|
|
47
|
+
max_retries: int = MAX_RETRIES,
|
|
48
|
+
) -> requests.Response:
|
|
49
|
+
"""GET with exponential backoff on timeouts/connection errors and 429/5xx."""
|
|
50
|
+
last_exc: Exception | None = None
|
|
51
|
+
for attempt in range(max_retries + 1):
|
|
52
|
+
try:
|
|
53
|
+
current = assert_public_http_url(url, context="request")
|
|
54
|
+
visited = set()
|
|
55
|
+
for redirect_number in range(11):
|
|
56
|
+
if current in visited:
|
|
57
|
+
raise ValueError("redirect_loop")
|
|
58
|
+
visited.add(current)
|
|
59
|
+
# Requests MUST NOT follow redirects automatically: validate each next hop
|
|
60
|
+
# *before* any network request is made to that destination.
|
|
61
|
+
response = session.get(current, timeout=REQUEST_TIMEOUT, allow_redirects=False, stream=stream)
|
|
62
|
+
if response.status_code not in (301, 302, 303, 307, 308):
|
|
63
|
+
break
|
|
64
|
+
location = response.headers.get("location")
|
|
65
|
+
if not location:
|
|
66
|
+
break
|
|
67
|
+
try:
|
|
68
|
+
next_url = assert_public_http_url(urljoin(current, location), context="redirect")
|
|
69
|
+
finally:
|
|
70
|
+
response.close()
|
|
71
|
+
current = next_url
|
|
72
|
+
else:
|
|
73
|
+
raise ValueError("too_many_redirects")
|
|
74
|
+
except (requests.ConnectionError, requests.Timeout) as exc:
|
|
75
|
+
last_exc = exc
|
|
76
|
+
if attempt < max_retries:
|
|
77
|
+
_sleep_backoff(attempt)
|
|
78
|
+
continue
|
|
79
|
+
raise
|
|
80
|
+
if response.status_code in RETRYABLE_STATUS and attempt < max_retries:
|
|
81
|
+
# Drain/close before retry — especially important for stream=True.
|
|
82
|
+
try:
|
|
83
|
+
response.close()
|
|
84
|
+
except Exception: # noqa: BLE001
|
|
85
|
+
pass
|
|
86
|
+
retry_after = response.headers.get("retry-after")
|
|
87
|
+
if retry_after and retry_after.isdigit():
|
|
88
|
+
time.sleep(min(int(retry_after), 30))
|
|
89
|
+
else:
|
|
90
|
+
_sleep_backoff(attempt)
|
|
91
|
+
continue
|
|
92
|
+
return response
|
|
93
|
+
assert last_exc is not None
|
|
94
|
+
raise last_exc
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class Robots:
|
|
98
|
+
"""Per-host robots.txt cache (pages + images — each host gets its own lookup)."""
|
|
99
|
+
|
|
100
|
+
def __init__(self, session: requests.Session):
|
|
101
|
+
self.session = session
|
|
102
|
+
self.cache: dict[str, RobotFileParser | None] = {}
|
|
103
|
+
self._lock = threading.Lock()
|
|
104
|
+
|
|
105
|
+
def allowed(self, url: str) -> bool:
|
|
106
|
+
p = urlparse(url)
|
|
107
|
+
root = f"{p.scheme}://{p.netloc}"
|
|
108
|
+
with self._lock:
|
|
109
|
+
if root not in self.cache:
|
|
110
|
+
rp = RobotFileParser()
|
|
111
|
+
try:
|
|
112
|
+
response = get_with_retry(self.session, root + "/robots.txt", max_retries=0)
|
|
113
|
+
if response.ok:
|
|
114
|
+
rp.parse(response.text.splitlines())
|
|
115
|
+
self.cache[root] = rp
|
|
116
|
+
else:
|
|
117
|
+
self.cache[root] = None
|
|
118
|
+
except requests.RequestException:
|
|
119
|
+
self.cache[root] = None
|
|
120
|
+
rp = self.cache[root]
|
|
121
|
+
return True if rp is None else rp.can_fetch(USER_AGENT, url)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""URL normalization and single-page content/link/image extraction."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import re
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Iterable
|
|
10
|
+
from urllib.parse import parse_qsl, urlencode, urljoin, urlparse, urlunparse
|
|
11
|
+
|
|
12
|
+
from .config import SKIP_EXTENSIONS, SKIP_SCHEMES, TRACKING_PARAMS
|
|
13
|
+
from .htmlparse import Node, parse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def clean_url(url: str, base: str | None = None) -> str:
|
|
17
|
+
if base:
|
|
18
|
+
url = urljoin(base, url)
|
|
19
|
+
url = (url or "").strip()
|
|
20
|
+
if not url or url.startswith(SKIP_SCHEMES):
|
|
21
|
+
return ""
|
|
22
|
+
p = urlparse(url)
|
|
23
|
+
if p.scheme not in ("http", "https"):
|
|
24
|
+
return ""
|
|
25
|
+
query = [(k, v) for k, v in parse_qsl(p.query, keep_blank_values=True)
|
|
26
|
+
if k.lower() not in TRACKING_PARAMS]
|
|
27
|
+
host = (p.hostname or "").lower()
|
|
28
|
+
port = p.port
|
|
29
|
+
netloc = f"[{host}]" if ":" in host else host
|
|
30
|
+
if port and not ((p.scheme == "https" and port == 443) or (p.scheme == "http" and port == 80)):
|
|
31
|
+
netloc += f":{port}"
|
|
32
|
+
p = p._replace(fragment="", query=urlencode(query, doseq=True), scheme=p.scheme.lower(),
|
|
33
|
+
netloc=netloc, path=p.path or "/")
|
|
34
|
+
return urlunparse(p)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def canonical_host(url: str) -> str:
|
|
38
|
+
host = urlparse(url).netloc.lower()
|
|
39
|
+
return host[4:] if host.startswith("www.") else host
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def same_site(a: str, b: str) -> bool:
|
|
43
|
+
return canonical_host(a) == canonical_host(b)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def likely_html_page(url: str) -> bool:
|
|
47
|
+
suffix = Path(urlparse(url).path.lower()).suffix
|
|
48
|
+
return not suffix or suffix not in SKIP_EXTENSIONS
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def safe_slug(url: str) -> str:
|
|
52
|
+
p = urlparse(url)
|
|
53
|
+
path = p.path.strip("/") or "home"
|
|
54
|
+
raw = f"{p.netloc}_{path}"
|
|
55
|
+
slug = re.sub(r"[^a-zA-Z0-9._-]+", "-", raw).strip("-").lower()
|
|
56
|
+
digest = hashlib.sha1(url.encode("utf-8")).hexdigest()[:8]
|
|
57
|
+
return f"{slug[:110]}-{digest}"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def page_slug(url: str) -> str:
|
|
61
|
+
"""Short slug for naming, e.g. 'home', 'about-us' — used in image filenames."""
|
|
62
|
+
p = urlparse(url)
|
|
63
|
+
path = p.path.strip("/")
|
|
64
|
+
if not path:
|
|
65
|
+
return "home"
|
|
66
|
+
slug = re.sub(r"[^a-zA-Z0-9-]+", "-", path.replace("/", "-")).strip("-").lower()
|
|
67
|
+
return slug[:60] or hashlib.sha1(url.encode("utf-8")).hexdigest()[:8]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def text_clean(value: str) -> str:
|
|
71
|
+
return re.sub(r"\s+", " ", value or "").strip()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def unique(items: Iterable[str]) -> list[str]:
|
|
75
|
+
out, seen = [], set()
|
|
76
|
+
for item in items:
|
|
77
|
+
if item and item not in seen:
|
|
78
|
+
seen.add(item)
|
|
79
|
+
out.append(item)
|
|
80
|
+
return out
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def parse_srcset(value: str) -> list[str]:
|
|
84
|
+
return [part.strip().split(" ")[0] for part in (value or "").split(",") if part.strip()]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def extract_background_urls(value: str) -> list[str]:
|
|
88
|
+
return [m.strip(" \"'") for m in re.findall(r"url\(([^)]+)\)", value or "", flags=re.I)]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
IMAGE_SRC_ATTRS = ("src", "data-src", "data-lazy-src", "data-original", "data-image", "data-bg", "data-background-image")
|
|
92
|
+
IMAGE_SRCSET_ATTRS = ("srcset", "data-srcset")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def best_image_urls(node: Node, page_url: str) -> list[str]:
|
|
96
|
+
candidates: list[str] = []
|
|
97
|
+
for attr in IMAGE_SRC_ATTRS:
|
|
98
|
+
value = node.get(attr)
|
|
99
|
+
if value:
|
|
100
|
+
candidates.append(value)
|
|
101
|
+
for attr in IMAGE_SRCSET_ATTRS:
|
|
102
|
+
value = node.get(attr)
|
|
103
|
+
if value:
|
|
104
|
+
candidates.extend(parse_srcset(value))
|
|
105
|
+
style = node.get("style")
|
|
106
|
+
if style:
|
|
107
|
+
candidates.extend(extract_background_urls(style))
|
|
108
|
+
return unique(clean_url(x, page_url) for x in candidates if clean_url(x, page_url))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@dataclass
|
|
112
|
+
class ImageRef:
|
|
113
|
+
url: str
|
|
114
|
+
alt: str
|
|
115
|
+
title: str
|
|
116
|
+
ancestor_context: str # for section classification downstream
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@dataclass
|
|
120
|
+
class LinkRef:
|
|
121
|
+
url: str
|
|
122
|
+
text: str
|
|
123
|
+
ancestor_context: str
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@dataclass
|
|
127
|
+
class PageExtract:
|
|
128
|
+
url: str
|
|
129
|
+
title: str
|
|
130
|
+
meta: dict[str, str] = field(default_factory=dict)
|
|
131
|
+
content: list[dict[str, str]] = field(default_factory=list)
|
|
132
|
+
links: list[LinkRef] = field(default_factory=list)
|
|
133
|
+
images: list[ImageRef] = field(default_factory=list)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def extract_page(html: str, page_url: str) -> PageExtract:
|
|
137
|
+
root = parse(html)
|
|
138
|
+
|
|
139
|
+
title_node = next(iter(root.find_all("title")), None)
|
|
140
|
+
title = text_clean(title_node.text_content()) if title_node else ""
|
|
141
|
+
|
|
142
|
+
meta: dict[str, str] = {}
|
|
143
|
+
for node in root.find_all("meta"):
|
|
144
|
+
key = node.get("name") or node.get("property")
|
|
145
|
+
value = node.get("content")
|
|
146
|
+
if key and value:
|
|
147
|
+
meta[key] = text_clean(value)
|
|
148
|
+
|
|
149
|
+
links: list[LinkRef] = []
|
|
150
|
+
for node in root.find_all("a"):
|
|
151
|
+
href = clean_url(node.get("href"), page_url)
|
|
152
|
+
if href:
|
|
153
|
+
links.append(LinkRef(
|
|
154
|
+
url=href,
|
|
155
|
+
text=text_clean(node.text_content()),
|
|
156
|
+
ancestor_context=node.ancestor_context(),
|
|
157
|
+
))
|
|
158
|
+
|
|
159
|
+
by_url: dict[str, ImageRef] = {}
|
|
160
|
+
for node in root.find_all("img", "source"):
|
|
161
|
+
for url in best_image_urls(node, page_url):
|
|
162
|
+
ref = ImageRef(
|
|
163
|
+
url=url,
|
|
164
|
+
alt=text_clean(node.get("alt")),
|
|
165
|
+
title=text_clean(node.get("title")),
|
|
166
|
+
ancestor_context=node.ancestor_context(),
|
|
167
|
+
)
|
|
168
|
+
existing = by_url.get(url)
|
|
169
|
+
if existing is None or (ref.alt and not existing.alt):
|
|
170
|
+
by_url[url] = ref
|
|
171
|
+
|
|
172
|
+
for node in root.walk():
|
|
173
|
+
style = node.get("style")
|
|
174
|
+
if not style:
|
|
175
|
+
continue
|
|
176
|
+
for raw in extract_background_urls(style):
|
|
177
|
+
url = clean_url(raw, page_url)
|
|
178
|
+
if url and url not in by_url:
|
|
179
|
+
by_url[url] = ImageRef(
|
|
180
|
+
url=url, alt="", title="css-background",
|
|
181
|
+
ancestor_context=node.ancestor_context(),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
for key in ("og:image", "og:image:url", "twitter:image", "twitter:image:src"):
|
|
185
|
+
if meta.get(key):
|
|
186
|
+
url = clean_url(meta[key], page_url)
|
|
187
|
+
if url and url not in by_url:
|
|
188
|
+
by_url[url] = ImageRef(
|
|
189
|
+
url=url, alt="", title=key, ancestor_context="og-meta hero",
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
content: list[dict[str, str]] = []
|
|
193
|
+
for node in root.find_all("h1", "h2", "h3", "h4", "h5", "h6", "p", "li", "blockquote", "address"):
|
|
194
|
+
# Prefer full descendant text — nested <span>/<strong> is common on builders.
|
|
195
|
+
text = text_clean(node.text_content() or node.text)
|
|
196
|
+
if text:
|
|
197
|
+
content.append({"type": node.tag, "text": text})
|
|
198
|
+
|
|
199
|
+
return PageExtract(
|
|
200
|
+
url=page_url, title=title, meta=meta, content=content,
|
|
201
|
+
links=links, images=list(by_url.values()),
|
|
202
|
+
)
|