@inneranimalmedia/agentsam-sdk 2.6.17 → 2.6.18
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 +19 -0
- package/README.md +15 -0
- package/apps/agentsam-copro-studio/agentsam.app.json +125 -0
- package/apps/cad-creator/agentsam.app.json +230 -0
- package/apps/cad-creator/shared/cad/package.json +1 -1
- package/apps/cad-creator/shared/cad/src/index.ts +1 -0
- package/apps/cad-creator/shared/cad/src/lighting.test.ts +32 -0
- package/apps/cad-creator/shared/cad/src/lighting.ts +79 -0
- package/apps/cad-creator/shared/cad/src/types.ts +106 -4
- package/apps/design-canvas/agentsam.app.json +144 -0
- package/apps/ecommerce-cms-agentsam/agentsam.app.json +658 -0
- package/apps/local-studio/agentsam.app.json +271 -0
- package/apps/samsketch/agentsam.app.json +136 -0
- package/contracts/source-types.v2.json +86 -1
- package/docs/CAPABILITIES.md +56 -0
- package/docs/PRODUCT_LIFECYCLE.md +2 -0
- package/docs/REPOSITORY_KNOWLEDGE.md +24 -0
- package/docs/adr/ADR-0010-widget-contributions-registry-persistence.md +60 -0
- package/docs/architecture/ACP_D1_HOSTING.md +67 -0
- package/docs/architecture/AGENTSAM-PRODUCT-CATALOG-RELEASES-20261028.md +3 -1
- package/docs/architecture/AGENTSAM_APPLICATION_CONTRACT.md +6 -2
- package/docs/architecture/AGENTSAM_APPLICATION_INVENTORY.md +135 -0
- package/docs/architecture/AGENTSAM_DISTRIBUTION_OWNERSHIP.md +1 -1
- package/docs/architecture/AGENTSAM_GO_RUNTIME.md +1 -1
- package/docs/architecture/APP_PRODUCT_DATA_MODEL.md +121 -0
- package/docs/architecture/BRAND_WORKSPACE_V1.md +71 -0
- package/docs/architecture/CANONICAL_CAD_FORMAT_SPINE.md +79 -0
- package/docs/architecture/ECOMMERCE_THEME_START_FLOW.md +31 -0
- package/docs/architecture/LIVE_AST_AND_CREATIVE_RESOURCE_GRAPH.md +129 -0
- package/docs/architecture/PRIMETECH_SCENE_V2_READINESS.md +89 -0
- package/docs/architecture/PYTHON_CAD_SERVICE_TRANSPORT.md +116 -0
- package/docs/architecture/SCHEMA_AUTHORITIES.md +83 -0
- package/docs/architecture/app-module-plugin-classification.md +71 -0
- package/docs/architecture/primetech/BARNDOMINIUM_BIM_BUILDOUT_RUNBOOK_20261123.md +139 -0
- package/docs/architecture/primetech/BARNDOMINIUM_SPACE_DELIVERY_20261123.md +58 -0
- package/docs/architecture/primetech/CAPABILITY_AND_ACCEPTANCE_MATRIX.md +176 -0
- package/docs/architecture/primetech/IMPLEMENTATION_WAVES.md +203 -0
- package/docs/architecture/primetech/PORTABLE_EDITOR_CONTRACTS.md +192 -0
- package/docs/architecture/primetech/README.md +65 -0
- package/docs/architecture/universal-registry-recovery.md +62 -0
- package/docs/audits/2026-11-22-sdk-d1-registry-parity.md +116 -0
- package/docs/brand/BRAND_CAPABILITY_INVENTORY.md +160 -0
- package/docs/cad/FORMAT_SUPPORT.md +46 -0
- package/docs/cad/LIB_CAD_REMASTER_AUDIT.md +49 -0
- package/docs/engineering/CMS_DATA_AUTHORITY_2026-11-03.md +4 -2
- package/docs/generated/SDK_CAPABILITY_INVENTORY.md +10 -10
- package/docs/intake/product-capabilities.proposed.ts +6 -6
- package/docs/operations/CLOUDFLARE-QUEUE-OBSERVABILITY.md +1 -1
- package/docs/product/AGENTSAM_PRODUCT_EXPERIENCE_STANDARD.md +1 -1
- package/docs/reference/AGENTSAM-CLI-WORKFLOWS.md +1 -1
- package/docs/reference/AGENTSAM-REGISTRY.generated.md +25 -16
- package/docs/sam/opencv-media.md +63 -0
- package/docs/standards/DESKTOP_WEB_PARITY_ACCEPTANCE.md +42 -0
- package/migrations/d1/0001_agentsam_plugin_runtime.sql +0 -2
- package/migrations/d1/0028_drop_unused_tool_handler_families.sql +4 -0
- package/migrations/d1/0029_agentsam_tools_account_plugin_key_unique.sql +26 -0
- package/migrations/d1/0030_cad_engine_plugins_contract_agnostic.sql +21 -0
- package/migrations/d1/0031_ops_trail_single_tool_call_source.sql +13 -0
- package/migrations/d1/0033_service_registry_model_discovery.sql +50 -0
- package/migrations/d1/20261123_skill_package_staging.sql +64 -0
- package/migrations/d1/20261123_universal_registry_stage.sql +58 -0
- package/migrations/d1/20261126_agentsam_tool_legacy_metadata_compact.sql +6 -0
- package/migrations/d1/20261126_agentsam_tools_archive_legacy_metadata.sql +20 -0
- package/migrations/d1/20261126_agentsam_tools_normalize_intent_tags.sql +49 -0
- package/migrations/d1/20261126_agentsam_tools_normalize_policy_health.sql +89 -0
- package/migrations/d1/20261126_agentsam_tools_remove_legacy_scope_keys.sql +29 -0
- package/migrations/d1/20261126_agentsam_tools_runtime_view_compat.sql +65 -0
- package/migrations/d1/generated/20261123_portable_cli_seed.sql +97 -0
- package/migrations/d1/generated/20261123_source_skill_seed.sql +3881 -0
- package/migrations/runtime/0012_agent_run_event_sequence.sql +27 -0
- package/package.json +57 -17
- package/packages/agentsam-3d-viewer/README.md +5 -0
- package/packages/agentsam-3d-viewer/package.json +1 -1
- package/packages/agentsam-3d-viewer/src/atmosphere.js +90 -0
- package/packages/agentsam-3d-viewer/src/gltf-loader.js +42 -0
- package/packages/agentsam-3d-viewer/src/index.d.ts +53 -1
- package/packages/agentsam-3d-viewer/src/index.js +18 -3
- package/packages/agentsam-3d-viewer/src/pbr-materials.js +330 -0
- package/packages/agentsam-3d-viewer/src/procedural-material.js +96 -0
- package/packages/agentsam-3d-viewer/src/procedural-textures.js +334 -0
- package/packages/agentsam-3d-viewer/src/renderer-capabilities.js +12 -0
- package/packages/agentsam-3d-viewer/src/stroke-geometry.js +4 -0
- package/packages/agentsam-3d-viewer/src/studio-finishes.js +67 -0
- package/packages/agentsam-3d-viewer/test/atmosphere.test.mjs +17 -0
- package/packages/agentsam-3d-viewer/test/gltf-loader.test.mjs +49 -0
- package/packages/agentsam-3d-viewer/test/pbr-mined-presets.test.mjs +44 -0
- package/packages/agentsam-3d-viewer/test/procedural-material.test.mjs +56 -0
- package/packages/agentsam-3d-viewer/test/renderer-capabilities.test.mjs +18 -0
- package/packages/agentsam-3d-viewer/test/studio-shared.test.mjs +23 -0
- package/packages/agentsam-architectural-intelligence/package.json +1 -1
- package/packages/agentsam-brand/package.json +3 -2
- package/packages/agentsam-brand/src/core/capabilities.js +108 -48
- package/packages/agentsam-brand/src/extract.js +6 -1
- package/packages/agentsam-brand/src/index.js +1 -0
- package/packages/agentsam-brand/src/public.js +15 -1
- package/packages/agentsam-brand/src/scan.js +47 -0
- package/packages/agentsam-brand/src/workspace.d.ts +19 -0
- package/packages/agentsam-brand/src/workspace.js +166 -0
- package/packages/agentsam-cms/README.md +11 -0
- package/packages/agentsam-cms/package.json +4 -3
- package/packages/agentsam-cms/src/contracts.js +16 -0
- package/packages/agentsam-cms/src/studio-bridge-protocol.js +113 -0
- package/packages/agentsam-cms/test/standalone.test.mjs +7 -3
- package/packages/agentsam-cms/test/studio-bridge-protocol.test.mjs +26 -0
- package/packages/agentsam-communications/package.json +3 -2
- package/packages/agentsam-communications/src/samspeaks-runtime.js +126 -0
- package/packages/agentsam-contracts/README.md +67 -0
- package/packages/agentsam-contracts/agentsam.package.json +46 -12
- package/packages/agentsam-contracts/dist/agent.d.ts +6 -3
- package/packages/agentsam-contracts/dist/agent.js +20 -0
- package/packages/agentsam-contracts/dist/bim-model.d.ts +95 -0
- package/packages/agentsam-contracts/dist/bim-model.js +57 -0
- package/packages/agentsam-contracts/dist/cad-source-formats.d.ts +55 -0
- package/packages/agentsam-contracts/dist/cad-source-formats.js +9617 -0
- package/packages/agentsam-contracts/dist/design-workspace.d.ts +13 -1
- package/packages/agentsam-contracts/dist/index.d.ts +6 -0
- package/packages/agentsam-contracts/dist/index.js +17836 -349
- package/packages/agentsam-contracts/dist/json-schema.d.ts +8 -0
- package/packages/agentsam-contracts/dist/json-schema.js +7787 -0
- package/packages/agentsam-contracts/dist/operations.d.ts +6 -1
- package/packages/agentsam-contracts/dist/operations.js +7795 -5
- package/packages/agentsam-contracts/dist/resource-ref.d.ts +21 -0
- package/packages/agentsam-contracts/dist/resource-ref.js +23 -0
- package/packages/agentsam-contracts/dist/run.d.ts +91 -3
- package/packages/agentsam-contracts/dist/run.js +28 -0
- package/packages/agentsam-contracts/dist/scene-document.d.ts +32 -0
- package/packages/agentsam-contracts/dist/scene-document.js +30 -0
- package/packages/agentsam-contracts/dist/scene-format.d.ts +44 -0
- package/packages/agentsam-contracts/dist/scene-format.js +35 -0
- package/packages/agentsam-contracts/dist/source-types-registry.d.ts +9 -0
- package/packages/agentsam-contracts/dist/source-types-registry.js +9512 -0
- package/packages/agentsam-contracts/dist/tools.d.ts +2 -1
- package/packages/agentsam-contracts/dist/tools.js +7794 -9
- package/packages/agentsam-contracts/dist/widgets.d.ts +2 -0
- package/packages/agentsam-contracts/package.json +42 -3
- package/packages/agentsam-contracts/schemas/activity.v1.schema.json +142 -0
- package/packages/agentsam-contracts/schemas/bim-model.v1.schema.json +76 -0
- package/packages/agentsam-contracts/schemas/resource-ref.v1.schema.json +18 -0
- package/packages/agentsam-contracts/schemas/run-receipt.v1.schema.json +411 -0
- package/packages/agentsam-contracts/schemas/run-start.v1.schema.json +40 -0
- package/packages/agentsam-contracts/schemas/run.v1.schema.json +243 -0
- package/packages/agentsam-contracts/schemas/sam-operation.v1.schema.json +8 -0
- package/packages/agentsam-contracts/schemas/scene-document.v2.schema.json +212 -0
- package/packages/agentsam-contracts/schemas/scene-format.v1.schema.json +173 -0
- package/packages/agentsam-contracts/schemas/source-types.v2.json +86 -1
- package/packages/agentsam-contracts/scripts/build.mjs +2 -1
- package/packages/agentsam-contracts/src/agent.ts +10 -18
- package/packages/agentsam-contracts/src/bim-model.ts +143 -0
- package/packages/agentsam-contracts/src/cad-source-formats.ts +195 -0
- package/packages/agentsam-contracts/src/design-workspace.ts +9 -0
- package/packages/agentsam-contracts/src/index.ts +6 -0
- package/packages/agentsam-contracts/src/json-schema.ts +37 -0
- package/packages/agentsam-contracts/src/operations.ts +12 -1
- package/packages/agentsam-contracts/src/resource-ref.ts +36 -0
- package/packages/agentsam-contracts/src/run.ts +93 -16
- package/packages/agentsam-contracts/src/scene-document.ts +58 -0
- package/packages/agentsam-contracts/src/scene-format.ts +91 -0
- package/packages/agentsam-contracts/src/source-types-registry.ts +65 -0
- package/packages/agentsam-contracts/src/tools.ts +4 -1
- package/packages/agentsam-contracts/src/widgets.ts +2 -0
- package/packages/agentsam-contracts/test/bim-model.test.mjs +66 -0
- package/packages/agentsam-contracts/test/cad-source-formats.test.mjs +103 -0
- package/packages/agentsam-contracts/test/contracts.test.mjs +23 -1
- package/packages/agentsam-contracts/test/resource-ref.test.mjs +29 -0
- package/packages/agentsam-contracts/test/run-contract.test.mjs +44 -0
- package/packages/agentsam-contracts/test/scene-document.test.mjs +30 -0
- package/packages/agentsam-contracts/test/scene-format.test.mjs +40 -0
- package/packages/agentsam-contracts/test/source-types.test.mjs +29 -0
- package/packages/agentsam-desktop-shell/scripts/app-discovery.mjs +36 -25
- package/packages/agentsam-errors/package.json +1 -1
- package/packages/agentsam-goalguru/agentsam.app.json +97 -0
- package/packages/agentsam-goap/package.json +2 -2
- package/packages/agentsam-hooks/package.json +1 -1
- package/packages/agentsam-knowledge/package.json +1 -1
- package/packages/agentsam-merch/package.json +1 -1
- package/packages/agentsam-nav/dist/Surfaces.d.ts +14 -4
- package/packages/agentsam-nav/dist/browser.global.js +16 -16
- package/packages/agentsam-nav/dist/browser.js +65 -22
- package/packages/agentsam-nav/dist/contracts.d.ts +2 -0
- package/packages/agentsam-nav/dist/index.d.ts +1 -1
- package/packages/agentsam-nav/dist/index.js +62 -21
- package/packages/agentsam-nav/dist/shell.css +149 -4
- package/packages/agentsam-nav/dist/theme.css +149 -4
- package/packages/agentsam-nav/dist/useAdminApps.d.ts +21 -2
- package/packages/agentsam-nav/package.json +1 -1
- package/packages/agentsam-occt/dist/native-provider.d.mts +1 -1
- package/packages/agentsam-occt/dist/native-provider.mjs +1 -1
- package/packages/agentsam-occt/package.json +1 -1
- package/packages/agentsam-occt/src/native-provider.mjs +1 -1
- package/packages/agentsam-queue-control/package.json +1 -1
- package/packages/agentsam-queue-control/src/adapters/sqlite.js +8 -6
- package/packages/agentsam-repository/package.json +1 -1
- package/packages/agentsam-vault/package.json +5 -1
- package/packages/agentsam-vault/src/crypto/aes-gcm.d.ts +25 -0
- package/packages/agentsam-vault/src/crypto/aes-gcm.js +149 -0
- package/packages/agentsam-vault/src/crypto/classify.d.ts +22 -0
- package/packages/agentsam-vault/src/crypto/classify.js +83 -0
- package/packages/agentsam-vault/src/crypto/oauth-envelope.d.ts +7 -0
- package/packages/agentsam-vault/src/index.js +10 -0
- package/packages/agentsam-vault/src/providers/registry.js +8 -0
- package/packages/agentsam-workbench/README.md +27 -3
- package/packages/agentsam-workbench/package.json +26 -4
- package/packages/agentsam-workbench/src/agent/AskAgentSamPill.tsx +17 -0
- package/packages/agentsam-workbench/src/agent/MiniAgentSam.tsx +144 -20
- package/packages/agentsam-workbench/src/agent/contextual-composer.css +7 -0
- package/packages/agentsam-workbench/src/agent/index.ts +1 -0
- package/packages/agentsam-workbench/src/agent/mini-agentsam.css +54 -0
- package/packages/agentsam-workbench/src/design/DesignWorkspaceFrame.tsx +277 -82
- package/packages/agentsam-workbench/src/design/design-workspace.css +173 -109
- package/packages/agentsam-workbench/src/index.ts +1 -0
- package/packages/agentsam-workbench/src/shell/InspectorPicker.tsx +38 -0
- package/packages/agentsam-workbench/src/shell/ResizableStage.tsx +26 -5
- package/packages/agentsam-workbench/src/shell/SidePanel.tsx +3 -3
- package/packages/agentsam-workbench/src/shell/StudioCommands.tsx +32 -0
- package/packages/agentsam-workbench/src/shell/appearance.d.mts +28 -0
- package/packages/agentsam-workbench/src/shell/appearance.mjs +279 -0
- package/packages/agentsam-workbench/src/shell/index.ts +2 -0
- package/packages/agentsam-workbench/src/shell/inspector-picker.css +48 -0
- package/packages/agentsam-workbench/src/shell/studio-icons.ts +104 -0
- package/packages/agentsam-workbench/src/shell/studio-panels.ts +21 -0
- package/packages/agentsam-workbench/src/widgets/registry.ts +4 -4
- package/packages/agentsam-workbench/src/workflows/WorkflowStudio.tsx +936 -0
- package/packages/agentsam-workbench/src/workflows/index.ts +5 -0
- package/packages/agentsam-workbench/src/workflows/model.ts +207 -0
- package/packages/agentsam-workbench/src/workflows/types.ts +206 -0
- package/packages/agentsam-workbench/src/workflows/workflow-studio.css +290 -0
- package/packages/catalog/generated/packages.json +157 -45
- package/packages/connectors/cfoa/package.json +7 -2
- package/packages/connectors/cfoa/src/PERMISSION_REGISTRY.md +45 -0
- package/packages/connectors/cfoa/src/api-client.js +4 -0
- package/packages/connectors/cfoa/src/capabilities.js +123 -285
- package/packages/connectors/cfoa/src/families/media.js +16 -12
- package/packages/connectors/cfoa/src/index.js +31 -37
- package/packages/connectors/cfoa/src/oauth-persist.js +18 -2
- package/packages/connectors/cfoa/src/permission-options.js +147 -1038
- package/packages/connectors/cfoa/src/routes.js +92 -35
- package/packages/connectors/cfoa/src/scope-catalog.js +16 -351
- package/packages/connectors/cfoa/src/scope-registry.js +248 -0
- package/packages/connectors/cfoa/test/scope-registry.test.mjs +168 -0
- package/packages/connectors/cfoa/tests/capabilities.test.mjs +86 -45
- package/packages/connectors/cfoa/tests/connector.test.mjs +143 -0
- package/packages/connectors/cfoa/tests/media-discovery.test.mjs +34 -10
- package/packages/identity/.agentsam/features/oauth-login-portal/agentsam.feature.json +1 -1
- package/packages/identity/agentsam.package.json +4 -4
- package/packages/identity/migrations/apply-portable.js +11 -4
- package/packages/identity/migrations/sqlite/007_identity_session_revoke_reason.sql +3 -0
- package/packages/identity/migrations/sqlite/008_identity_accounts.sql +41 -0
- package/packages/identity/migrations/sqlite/009_identity_scope.sql +30 -0
- package/packages/identity/package.json +11 -6
- package/packages/identity/schema/agentsam.identity/manifest.json +21 -4
- package/packages/identity/src/adapters/account-security-store.js +7 -0
- package/packages/identity/src/adapters/column-support.js +39 -0
- package/packages/identity/src/adapters/iam-compat/index.js +19 -4
- package/packages/identity/src/adapters/portable-d1/index.js +3 -1
- package/packages/identity/src/adapters/portable-store.js +80 -51
- package/packages/identity/src/app/verify-app.js +27 -0
- package/packages/identity/src/contracts/identity-store.js +2 -2
- package/packages/identity/src/core/password-gate.js +116 -0
- package/packages/identity/src/frontend/auth-portal/pages/login.html +1 -1
- package/packages/identity/src/frontend/auth-portal/pages/reset.html +1 -1
- package/packages/identity/src/frontend/auth-portal/pages/signup.html +1 -1
- package/packages/identity/src/frontend/auth-portal/shared/company-branding.js +18 -7
- package/packages/identity/src/frontend/auth-portal/shared/default-auth-logo.svg +4 -0
- package/packages/identity/src/frontend/auth-portal/store-access.js +97 -0
- package/packages/identity/src/migrations/0005_session_audit_columns.sql +6 -0
- package/packages/identity/src/migrations/README.md +2 -0
- package/packages/identity/src/oauth/native-handoff.js +2 -2
- package/packages/identity/src/server/identity-service.js +1 -1
- package/packages/identity/src/server/worker-router.js +16 -5
- package/packages/identity/tests/identity-portal-e2e.test.mjs +166 -0
- package/packages/identity/tests/lane1-identity-store-parity.test.mjs +17 -6
- package/packages/identity/tests/password-gate.test.mjs +66 -0
- package/packages/identity/tests/portable-identity-scope.test.mjs +59 -0
- package/packages/identity/tests/session-audit.test.mjs +135 -0
- package/packages/identity/tests/worker-portal-assets.test.mjs +47 -0
- package/packages/primetech-procedures/README.md +46 -5
- package/packages/primetech-procedures/agentsam.package.json +6 -6
- package/packages/primetech-procedures/package.json +14 -3
- package/packages/primetech-procedures/procedures/arch.assembly.calculate/procedure.json +83 -0
- package/packages/primetech-procedures/procedures/media.asset.preflight/procedure.json +85 -0
- package/packages/primetech-procedures/procedures/media.image.optimize-asset/procedure.json +102 -0
- package/packages/primetech-procedures/procedures/repo.asset.inventory/__pycache__/run.cpython-314.pyc +0 -0
- package/packages/primetech-procedures/procedures/repo.git.status/procedure.json +58 -0
- package/packages/primetech-procedures/procedures/repo.git.status/run.sh +10 -0
- package/packages/primetech-procedures/src/index.js +140 -41
- package/packages/primetech-procedures/test/__pycache__/test_inventory.cpython-314.pyc +0 -0
- package/packages/primetech-procedures/test/runtime-kinds.test.mjs +210 -0
- package/packages/theme-scenes/package.json +1 -1
- package/packages/work-graph/package.json +1 -1
- package/protocol/README.md +18 -0
- package/protocol/capabilities/capability-manifest.schema.json +111 -19
- package/protocol/capabilities/manifest.json +12 -1
- package/protocol/contracts/source-types.v2.json +86 -1
- package/protocol/product-releases/README.md +15 -12
- package/protocol/registry/universal-catalog.v1.json +2820 -0
- package/protocol/sam/activity.v1.schema.json +111 -17
- package/protocol/sam/operation.schema.json +8 -0
- package/protocol/sam/run-receipt.v1.schema.json +411 -0
- package/protocol/sam/run-start.v1.schema.json +40 -0
- package/protocol/sam/run.v1.schema.json +243 -0
- package/protocol/theme-refinery/d1-reconciliation.md +66 -32
- package/protocol/theme-refinery/product-metadata.schema.json +1 -1
- package/python/README.md +81 -8
- package/python/agentsam_sdk/cad/__init__.py +26 -3
- package/python/agentsam_sdk/cad/adapters/__init__.py +6 -0
- package/python/agentsam_sdk/cad/adapters/freecad.py +200 -0
- package/python/agentsam_sdk/cad/building.py +42 -0
- package/python/agentsam_sdk/cad/jobs.py +174 -0
- package/python/agentsam_sdk/cad/native.py +68 -9
- package/python/agentsam_sdk/cad/service.py +570 -0
- package/python/agentsam_sdk/cli.py +31 -0
- package/python/agentsam_sdk/client.py +49 -16
- package/python/agentsam_sdk/data/d1_bloat.py +0 -1
- package/python/agentsam_sdk/media/__init__.py +8 -0
- package/python/agentsam_sdk/media/opencv.py +188 -0
- package/python/agentsam_sdk/procedures/client.py +1 -1
- package/python/agentsam_sdk/registry_cli.py +88 -0
- package/python/agentsam_sdk/runtime/native.py +1 -1
- package/python/agentsam_sdk/terminal_art.py +5 -6
- package/python/pyproject.toml +3 -0
- package/python/tests/fixtures/freecad_host_cases.json +30 -0
- package/python/tests/test_bridge_policy.py +40 -0
- package/python/tests/test_cad_building_client.py +47 -0
- package/python/tests/test_cad_jobs_client.py +102 -0
- package/python/tests/test_cad_native.py +104 -1
- package/python/tests/test_cad_service_client.py +288 -0
- package/python/tests/test_opencv_media.py +79 -0
- package/python/tests/test_procedure_client.py +6 -0
- package/python/tests/test_public_client.py +13 -0
- package/services/cad/blender/adapter.py +49 -0
- package/services/cad/ifc/__pycache__/adapter.cpython-311.pyc +0 -0
- package/services/cad/ifc/adapter.py +836 -0
- package/services/cad/server.py +435 -132
- package/skills/README.md +1 -1
- package/skills/agentsam-app-fundamentals/agentsam.skill.json +20 -0
- package/skills/agentsam-arch-bim/SKILL.md +166 -6
- package/skills/agentsam-arch-bim/agentsam.skill.json +2 -2
- package/skills/agentsam-cad/SKILL.md +122 -36
- package/skills/agentsam-cad/agentsam.skill.json +20 -0
- package/skills/agentsam-cad/evals/README.md +56 -0
- package/skills/agentsam-cad/references/engines-and-lanes.md +70 -0
- package/skills/agentsam-cad/references/projects-and-operations.md +112 -0
- package/skills/agentsam-cad/references/proof-and-triage.md +89 -0
- package/skills/agentsam-cad/references/python-service-and-jobs.md +102 -0
- package/skills/agentsam-cad/references/scene-geometry-bim.md +113 -0
- package/skills/agentsam-canvas-creation/agentsam.skill.json +20 -0
- package/skills/agentsam-cloudflare-workers/agentsam.skill.json +20 -0
- package/skills/agentsam-cms-ready-creation/agentsam.skill.json +20 -0
- package/skills/agentsam-codebaseindex/agentsam.skill.json +20 -0
- package/skills/agentsam-jr-dev/agentsam.skill.json +20 -0
- package/skills/agentsam-plan-and-goap/agentsam.skill.json +20 -0
- package/skills/agentsam-progression-guard/agentsam.skill.json +20 -0
- package/skills/agentsam-repo-recon/agentsam.skill.json +20 -0
- package/skills/agentsam-sam-operations/SKILL.md +76 -36
- package/skills/agentsam-sam-operations/agentsam.skill.json +20 -0
- package/skills/agentsam-sdk-orientation/agentsam.skill.json +20 -0
- package/skills/catalog.json +21 -6
- package/src/acp/agent-executor.js +38 -2
- package/src/acp/client.js +128 -39
- package/src/acp/dependencies.js +159 -19
- package/src/acp/http.js +14 -0
- package/src/acp/index.js +3 -0
- package/src/acp/runs.js +5 -3
- package/src/agent/capability-adapter.js +21 -23
- package/src/cli/command-catalog.js +4 -4
- package/src/cli/desktop-launch.js +2 -2
- package/src/cli/update-check.js +131 -0
- package/src/cli.js +6 -5
- package/src/commands/account-auth.js +36 -26
- package/src/commands/app-inventory.js +343 -0
- package/src/commands/app.js +162 -27
- package/src/commands/ast.js +80 -0
- package/src/commands/cad.js +2 -0
- package/src/commands/cheat-sheet.js +1 -1
- package/src/commands/cloudflare-login.js +170 -65
- package/src/commands/cloudflare-status.js +38 -0
- package/src/commands/cloudflare.js +54 -42
- package/src/commands/codebaseindex.js +34 -13
- package/src/commands/db.js +2 -2
- package/src/commands/go.js +1 -1
- package/src/commands/interactive.js +5 -0
- package/src/commands/knowledge.js +4 -2
- package/src/commands/mcp.js +5 -2
- package/src/commands/preferences.js +48 -6
- package/src/commands/product.js +4 -4
- package/src/commands/run.js +3 -4
- package/src/commands/shell.js +32 -10
- package/src/go/contract.js +1 -1
- package/src/go/official-registry.js +41 -36
- package/src/go/product-catalog.test.mjs +52 -0
- package/src/go/receipts.js +19 -6
- package/src/indexing/index.js +10 -0
- package/src/indexing/live-ast.js +200 -0
- package/src/indexing/live-cad-graph.js +107 -0
- package/src/indexing/live-resource-graph.js +95 -0
- package/src/knowledge/config.js +5 -4
- package/src/knowledge/store-discovery.js +22 -5
- package/src/knowledge/stores/d1.js +141 -0
- package/src/lib/auth.js +7 -4
- package/src/lib/cad/bim-bridge.d.ts +6 -0
- package/src/lib/cad/bim-bridge.js +96 -0
- package/src/lib/cad/d1-project-store.js +1 -1
- package/src/lib/cad/delivery-profiles.d.ts +1 -1
- package/src/lib/cad/delivery-profiles.js +82 -6
- package/src/lib/cad/format-policy.d.ts +11 -0
- package/src/lib/cad/format-policy.js +14 -0
- package/src/lib/cad/freecad-host.d.ts +19 -0
- package/src/lib/cad/freecad-host.js +171 -0
- package/src/lib/cad/freecad.js +38 -65
- package/src/lib/cad/ifc-cli.js +82 -0
- package/src/lib/cad/ifc.js +152 -0
- package/src/lib/cad/index.js +3 -0
- package/src/lib/cad/production-operations.js +2 -0
- package/src/lib/cad/project-runtime.js +2 -2
- package/src/lib/cad/project-v2.js +13 -25
- package/src/lib/cad-docker.js +35 -17
- package/src/lib/whoami-capabilities.js +8 -14
- package/src/mcp/cloudflare-bundles.js +39 -41
- package/src/models/inventory-core.d.ts +32 -1
- package/src/models/inventory-core.js +118 -36
- package/src/plugins/cloudflare.js +3 -3
- package/src/plugins/completeful.js +2 -4
- package/src/plugins/contracts.js +2 -3
- package/src/plugins/creative.js +2 -2
- package/src/plugins/registry.js +52 -33
- package/src/plugins/runtime.js +64 -13
- package/src/registry/generated/inventory.json +289 -66
- package/src/registry/universal-reconcile.js +120 -0
- package/src/registry/universal-source.js +253 -0
- package/src/sam/adapters/opencv-video.js +206 -0
- package/src/sam/adapters/workspace-media.js +15 -2
- package/src/sam/bridge/policy.mjs +50 -0
- package/src/sam/bridge/stdio.mjs +61 -38
- package/src/sam/operations/architectural-knowledge.js +1 -0
- package/src/sam/operations/artifact-render.js +2 -1
- package/src/sam/operations/cad-bim-ifc.js +89 -0
- package/src/sam/operations/decision-evaluate.js +1 -0
- package/src/sam/operations/planning-goap.js +1 -0
- package/src/sam/operations/repository-inspect.js +1 -0
- package/src/sam/operations/robotics.js +1 -1
- package/src/sam/packs/core.js +2 -0
- package/src/sam/packs/evidence/endpoint.js +39 -0
- package/src/sam/packs/evidence/media.js +3 -2
- package/src/sam/packs/evidence/store-hosted.js +5 -3
- package/src/sam/shell-host.js +26 -8
- package/src/skills/catalog.js +12 -1
- package/src/skills/registry.js +16 -17
- package/src/ui/boot.js +12 -14
- package/src/ui/brand/agentsam-mark.generated.js +49 -0
- package/src/ui/cli/prompt-box.js +151 -0
- package/src/ui/home-screen.js +49 -0
- package/apps/README.md +0 -67
- package/apps/cad-creator/README.md +0 -743
- package/packages/agentsam-brand/LICENSE +0 -110
- package/packages/agentsam-desktop-shell/LICENSE +0 -110
- package/packages/agentsam-desktop-shell/README.md +0 -73
- package/packages/agentsam-ide/LICENSE +0 -110
- package/packages/agentsam-ide/README.md +0 -147
- package/packages/agentsam-nav/LICENSE +0 -110
- package/packages/agentsam-vault/LICENSE +0 -110
- package/packages/agentsam-workbench/LICENSE +0 -110
- package/src/ui/art/geaux_boot.json +0 -25
- package/src/ui/companion-art.js +0 -40
- /package/{apps/cad-creator → packages/primetech-procedures}/LICENSE +0 -0
package/src/lib/cad/freecad.js
CHANGED
|
@@ -4,10 +4,12 @@ import path from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { runProcess } from '../../security/process.js';
|
|
6
6
|
import { discoverFreeCad, freeCadStatus } from './discovery.js';
|
|
7
|
+
import { discoverFreeCadHost, freeCadAdapterCommand, freeCadHostEnvironment } from './freecad-host.js';
|
|
7
8
|
import { probeDockerServiceHealth, executeFreeCadDocker } from './docker-executor.js';
|
|
8
9
|
|
|
9
10
|
const sdkRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
10
|
-
|
|
11
|
+
// The adapter ships inside the Python SDK package (wheel, sdist and npm alike): one home, no copies.
|
|
12
|
+
export const FREECAD_ADAPTER_PATH = path.join(sdkRoot, 'python/agentsam_sdk/cad/adapters/freecad.py');
|
|
11
13
|
export const FREECAD_RESULT_PREFIX = 'AGENTSAM_RESULT=';
|
|
12
14
|
export const FREECAD_EXPORT_FORMATS = Object.freeze(['step', 'stp', 'iges', 'brep', 'stl']);
|
|
13
15
|
|
|
@@ -20,56 +22,31 @@ function isFile(value) {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
25
|
+
* Resolves the FreeCAD host (python or FreeCADCmd). An explicit `freecadBin` narrows discovery to
|
|
26
|
+
* that install; everything else follows the same algorithm as the Python SDK (freecad-host.js).
|
|
24
27
|
*/
|
|
25
|
-
export function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
libDir: env.AGENTSAM_FREECAD_LIB || null,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 2. Discover FreeCAD base installation
|
|
39
|
-
const { binary } = discoverFreeCad({ freecadBin, env, platform });
|
|
40
|
-
if (binary) {
|
|
41
|
-
if (platform === 'darwin') {
|
|
42
|
-
const appRoot = binary.includes('.app') ? binary.split('.app')[0] + '.app' : null;
|
|
43
|
-
if (appRoot) {
|
|
44
|
-
const bundledPython = path.join(appRoot, 'Contents/Resources/bin/python');
|
|
45
|
-
const bundledLib = path.join(appRoot, 'Contents/Resources/lib');
|
|
46
|
-
if (isFile(bundledPython)) {
|
|
47
|
-
return { pythonBin: bundledPython, libDir: bundledLib };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// 3. Fallback candidates on system
|
|
54
|
-
const candidates = [
|
|
55
|
-
...(platform === 'darwin'
|
|
56
|
-
? ['/Applications/FreeCAD.app/Contents/Resources/bin/python']
|
|
57
|
-
: []),
|
|
58
|
-
...(platform === 'linux'
|
|
59
|
-
? ['/usr/lib/freecad/bin/python', '/usr/bin/python3']
|
|
60
|
-
: []),
|
|
61
|
-
...(platform === 'win32'
|
|
62
|
-
? [path.join(env.ProgramFiles || 'C:\\Program Files', 'FreeCAD', 'bin', 'python.exe')]
|
|
63
|
-
: []),
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
for (const c of candidates) {
|
|
67
|
-
if (isFile(c)) {
|
|
68
|
-
return { pythonBin: c, libDir: null };
|
|
69
|
-
}
|
|
28
|
+
export function resolveFreeCadHost({ freecadBin, env = process.env, platform = process.platform } = {}) {
|
|
29
|
+
const scoped = { ...env };
|
|
30
|
+
if (freecadBin) {
|
|
31
|
+
const bundle = String(freecadBin).match(/^(.*?\.app)[\\/]/);
|
|
32
|
+
const name = path.basename(String(freecadBin));
|
|
33
|
+
if (bundle) scoped.AGENTSAM_FREECAD_HOME = path.join(bundle[1], 'Contents', 'Resources');
|
|
34
|
+
else if (/^freecadcmd/i.test(name)) scoped.AGENTSAM_FREECAD_CMD = freecadBin;
|
|
35
|
+
else if (/^python/i.test(name)) scoped.AGENTSAM_FREECAD_PYTHON = freecadBin;
|
|
36
|
+
else scoped.AGENTSAM_FREECAD_HOME = path.dirname(path.dirname(freecadBin));
|
|
70
37
|
}
|
|
38
|
+
return discoverFreeCadHost({ env: scoped, platform });
|
|
39
|
+
}
|
|
71
40
|
|
|
72
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Compatibility view of resolveFreeCadHost for callers that only want a FreeCAD-capable interpreter.
|
|
43
|
+
* A FreeCADCmd-only install has no interpreter to hand back; use resolveFreeCadHost for that.
|
|
44
|
+
*/
|
|
45
|
+
export function discoverFreeCadPython({ freecadBin, env = process.env, platform = process.platform } = {}) {
|
|
46
|
+
const host = resolveFreeCadHost({ freecadBin, env, platform });
|
|
47
|
+
return host?.mode === 'python'
|
|
48
|
+
? { pythonBin: host.executable, libDir: host.libraryDir }
|
|
49
|
+
: { pythonBin: null, libDir: null };
|
|
73
50
|
}
|
|
74
51
|
|
|
75
52
|
export function parseFreeCadResult(stdout) {
|
|
@@ -97,8 +74,8 @@ export async function freeCadBuild({
|
|
|
97
74
|
cwd = process.cwd(),
|
|
98
75
|
runProcessImpl = runProcess,
|
|
99
76
|
} = {}) {
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
77
|
+
const host = resolveFreeCadHost({ freecadBin });
|
|
78
|
+
if (!host || !fs.existsSync(FREECAD_ADAPTER_PATH)) {
|
|
102
79
|
try {
|
|
103
80
|
const dockerHealth = await probeDockerServiceHealth();
|
|
104
81
|
if (dockerHealth.available && dockerHealth.tools?.freecad?.installed) {
|
|
@@ -138,16 +115,14 @@ export async function freeCadBuild({
|
|
|
138
115
|
|
|
139
116
|
fs.writeFileSync(requestPath, JSON.stringify(request, null, 2), { mode: 0o600 });
|
|
140
117
|
|
|
141
|
-
const env =
|
|
142
|
-
|
|
143
|
-
env.PYTHONPATH = [libDir, env.PYTHONPATH].filter(Boolean).join(path.delimiter);
|
|
144
|
-
}
|
|
118
|
+
const env = freeCadHostEnvironment(host);
|
|
119
|
+
const [command, ...commandArgs] = freeCadAdapterCommand(host, FREECAD_ADAPTER_PATH, requestPath, 'build');
|
|
145
120
|
|
|
146
121
|
const started = Date.now();
|
|
147
122
|
try {
|
|
148
123
|
const proc = await runProcessImpl(
|
|
149
|
-
|
|
150
|
-
|
|
124
|
+
command,
|
|
125
|
+
commandArgs,
|
|
151
126
|
{
|
|
152
127
|
cwd,
|
|
153
128
|
env,
|
|
@@ -193,9 +168,9 @@ export async function freeCadInspect({
|
|
|
193
168
|
cwd = process.cwd(),
|
|
194
169
|
runProcessImpl = runProcess,
|
|
195
170
|
} = {}) {
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
198
|
-
throw new Error('FreeCAD
|
|
171
|
+
const host = resolveFreeCadHost({ freecadBin });
|
|
172
|
+
if (!host) {
|
|
173
|
+
throw new Error('FreeCAD is not available; install FreeCAD or set AGENTSAM_FREECAD_PYTHON / AGENTSAM_FREECAD_CMD');
|
|
199
174
|
}
|
|
200
175
|
|
|
201
176
|
const inputPath = path.resolve(cwd, input);
|
|
@@ -213,16 +188,14 @@ export async function freeCadInspect({
|
|
|
213
188
|
|
|
214
189
|
fs.writeFileSync(requestPath, JSON.stringify(request, null, 2), { mode: 0o600 });
|
|
215
190
|
|
|
216
|
-
const env =
|
|
217
|
-
|
|
218
|
-
env.PYTHONPATH = [libDir, env.PYTHONPATH].filter(Boolean).join(path.delimiter);
|
|
219
|
-
}
|
|
191
|
+
const env = freeCadHostEnvironment(host);
|
|
192
|
+
const [command, ...commandArgs] = freeCadAdapterCommand(host, FREECAD_ADAPTER_PATH, requestPath, 'inspect');
|
|
220
193
|
|
|
221
194
|
const started = Date.now();
|
|
222
195
|
try {
|
|
223
196
|
const proc = await runProcessImpl(
|
|
224
|
-
|
|
225
|
-
|
|
197
|
+
command,
|
|
198
|
+
commandArgs,
|
|
226
199
|
{
|
|
227
200
|
cwd,
|
|
228
201
|
env,
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ifcDiff, ifcEdit, ifcInspect, ifcStatus, ifcValidate } from './ifc.js';
|
|
4
|
+
|
|
5
|
+
export function ifcUsage() {
|
|
6
|
+
return `AgentSam CAD: real IFC/BIM operations (IfcOpenShell)
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
agentsam cad ifc status [--python <path>] [--json]
|
|
10
|
+
agentsam cad ifc inspect <model.ifc> [--max-elements <n>] [--json]
|
|
11
|
+
agentsam cad ifc validate <model.ifc> [--json]
|
|
12
|
+
agentsam cad ifc diff <before.ifc> <after.ifc> [--json]
|
|
13
|
+
agentsam cad ifc edit <model.ifc> --edits <edits.json> --out <new.ifc> [--base <sha256>] [--json]
|
|
14
|
+
|
|
15
|
+
edit never overwrites the source. It writes a new .ifc only when the copy adds no validation
|
|
16
|
+
errors, keeps every GlobalId (except explicit removals) and changes nothing outside the edited
|
|
17
|
+
objects. --edits is a JSON array; supported ops: attribute.set, property.set, property.remove,
|
|
18
|
+
placement.move, solid.extrusion_depth, element.remove.
|
|
19
|
+
|
|
20
|
+
IfcOpenShell is found automatically (PATH Python, a venv, or FreeCAD's bundled Python).
|
|
21
|
+
Use --python <path> to choose one. Install with: pip install ifcopenshell`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function parse(argv) {
|
|
25
|
+
const opts = { positional: [], json: false };
|
|
26
|
+
const values = new Set(['--python', '--timeout', '--cwd', '--out', '--edits', '--base', '--max-elements']);
|
|
27
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
28
|
+
const arg = argv[i];
|
|
29
|
+
if (arg === '--json') opts.json = true;
|
|
30
|
+
else if (arg === '--help' || arg === '-h') opts.help = true;
|
|
31
|
+
else if (values.has(arg)) {
|
|
32
|
+
const value = argv[++i];
|
|
33
|
+
if (value == null || value.startsWith('--')) throw new Error(`${arg} requires a value`);
|
|
34
|
+
opts[arg.slice(2).replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = value;
|
|
35
|
+
} else if (arg.startsWith('-')) throw new Error(`unknown cad ifc option: ${arg}`);
|
|
36
|
+
else opts.positional.push(arg);
|
|
37
|
+
}
|
|
38
|
+
return opts;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const need = (value, message) => { if (!value) throw new Error(message); return value; };
|
|
42
|
+
|
|
43
|
+
function summarize(result) {
|
|
44
|
+
if (result.capability === 'cad.bim.ifc.status') {
|
|
45
|
+
return result.available
|
|
46
|
+
? `IfcOpenShell ${result.ifcopenshell} via ${result.python} (${result.source})`
|
|
47
|
+
: `IfcOpenShell not found (${(result.searched || []).join(', ')})\n${result.guidance}`;
|
|
48
|
+
}
|
|
49
|
+
if (result.capability === 'cad.bim.ifc.inspect') {
|
|
50
|
+
const m = result.model;
|
|
51
|
+
return `${m.source.ifcSchema} ${m.project.name ?? ''} - ${m.elements.length} elements, ${m.spaces.length} spaces, truncated: ${m.truncated}\nsha256 ${result.input.sha256}`;
|
|
52
|
+
}
|
|
53
|
+
if (result.capability === 'cad.bim.ifc.validate') {
|
|
54
|
+
return `${result.valid ? 'valid' : 'INVALID'} - ${JSON.stringify(result.counts)}`;
|
|
55
|
+
}
|
|
56
|
+
const c = result.diff?.counts ?? result.counts;
|
|
57
|
+
const head = `added ${c.added}, removed ${c.removed}, changed ${c.changed}, unchanged ${c.unchanged}`;
|
|
58
|
+
return result.capability === 'cad.bim.ifc.edit' ? `wrote ${result.output.path}\nsha256 ${result.output.sha256}\n${head}` : head;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function runIfcCli(argv) {
|
|
62
|
+
const action = argv[0];
|
|
63
|
+
if (!action || action === '--help' || action === '-h') { console.log(ifcUsage()); return undefined; }
|
|
64
|
+
const opts = parse(argv.slice(1));
|
|
65
|
+
if (opts.help) { console.log(ifcUsage()); return undefined; }
|
|
66
|
+
const cwd = path.resolve(opts.cwd || process.cwd());
|
|
67
|
+
const shared = { python: opts.python, cwd, timeoutSeconds: opts.timeout == null ? undefined : Number(opts.timeout) };
|
|
68
|
+
let result;
|
|
69
|
+
if (action === 'status') result = await ifcStatus(shared);
|
|
70
|
+
else if (action === 'inspect') result = await ifcInspect({ ...shared, input: need(opts.positional[0], 'inspect requires <model.ifc>'), maxElements: opts.maxElements ? Number(opts.maxElements) : undefined });
|
|
71
|
+
else if (action === 'validate') result = await ifcValidate({ ...shared, input: need(opts.positional[0], 'validate requires <model.ifc>') });
|
|
72
|
+
else if (action === 'diff') result = await ifcDiff({ ...shared, input: need(opts.positional[0], 'diff requires <before.ifc> <after.ifc>'), other: need(opts.positional[1], 'diff requires <before.ifc> <after.ifc>') });
|
|
73
|
+
else if (action === 'edit') {
|
|
74
|
+
const file = path.resolve(cwd, need(opts.edits, 'edit requires --edits <edits.json>'));
|
|
75
|
+
if (!fs.existsSync(file)) throw new Error(`edits file not found: ${file}`);
|
|
76
|
+
let edits;
|
|
77
|
+
try { edits = JSON.parse(fs.readFileSync(file, 'utf8')); } catch (error) { throw new Error(`invalid edits JSON: ${error.message}`); }
|
|
78
|
+
result = await ifcEdit({ ...shared, input: need(opts.positional[0], 'edit requires <model.ifc>'), output: need(opts.out, 'edit requires --out <new.ifc>'), edits, base: opts.base });
|
|
79
|
+
} else throw new Error(`unknown cad ifc action: ${action}`);
|
|
80
|
+
console.log(opts.json ? JSON.stringify(result, null, 2) : summarize(result));
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { runProcess } from '../../security/process.js';
|
|
7
|
+
import { discoverFreeCadPython } from './freecad.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Local IFC lane: runs the one IfcOpenShell adapter (services/cad/ifc/adapter.py)
|
|
11
|
+
* with any Python that can import it. The adapter is the single engine; the CAD
|
|
12
|
+
* service container runs the same file. Nothing here parses or writes IFC itself.
|
|
13
|
+
*/
|
|
14
|
+
const sdkRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
15
|
+
export const IFC_ADAPTER_PATH = path.join(sdkRoot, 'services/cad/ifc/adapter.py');
|
|
16
|
+
export const IFC_RESULT_PREFIX = 'AGENTSAM_RESULT=';
|
|
17
|
+
export const IFC_EDIT_OPERATIONS = Object.freeze([
|
|
18
|
+
'attribute.set', 'property.set', 'property.remove', 'placement.move',
|
|
19
|
+
'solid.extrusion_depth', 'element.remove',
|
|
20
|
+
]);
|
|
21
|
+
const PROBE = 'import json,ifcopenshell,ifcopenshell.api,ifcopenshell.validate,ifcopenshell.util.placement as p;'
|
|
22
|
+
+ 'print(json.dumps({"version":ifcopenshell.version}))';
|
|
23
|
+
const CONTAINER_VENV = '/opt/agentsam-venv/bin/python';
|
|
24
|
+
|
|
25
|
+
const isFile = value => { try { return fs.statSync(value).isFile(); } catch { return false; } };
|
|
26
|
+
export const sha256File = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
27
|
+
|
|
28
|
+
function pythonCandidates({ python, env, platform }) {
|
|
29
|
+
const list = [];
|
|
30
|
+
const add = (bin, source) => { if (bin && !list.some(c => c.bin === bin)) list.push({ bin, source }); };
|
|
31
|
+
add(python, 'option');
|
|
32
|
+
add(env.AGENTSAM_CAD_PYTHON, 'AGENTSAM_CAD_PYTHON');
|
|
33
|
+
if (platform !== 'win32') add(CONTAINER_VENV, 'container-venv');
|
|
34
|
+
add(platform === 'win32' ? 'python' : 'python3', 'path');
|
|
35
|
+
if (platform !== 'win32') add('python', 'path');
|
|
36
|
+
try { add(discoverFreeCadPython({ env, platform })?.pythonBin, 'freecad-bundled'); } catch { /* optional */ }
|
|
37
|
+
return list;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let cached = null;
|
|
41
|
+
|
|
42
|
+
/** First interpreter that really imports ifcopenshell (+ api, validate, placement). */
|
|
43
|
+
export async function discoverIfcPython({ python, env = process.env, platform = process.platform, runProcessImpl = runProcess, fresh = false } = {}) {
|
|
44
|
+
if (cached && !fresh && !python) return cached;
|
|
45
|
+
const searched = [];
|
|
46
|
+
for (const candidate of pythonCandidates({ python, env, platform })) {
|
|
47
|
+
if (candidate.bin.includes(path.sep) && !isFile(candidate.bin)) { searched.push(`${candidate.bin} (missing)`); continue; }
|
|
48
|
+
try {
|
|
49
|
+
const proc = await runProcessImpl(candidate.bin, ['-c', PROBE], { timeoutMs: 20_000, maxBytes: 64 * 1024 });
|
|
50
|
+
if (proc.code === 0) {
|
|
51
|
+
const found = { available: true, python: candidate.bin, source: candidate.source, ifcopenshell: JSON.parse(proc.stdout.trim().split('\n').pop()).version };
|
|
52
|
+
if (!python) cached = found;
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
searched.push(`${candidate.bin} (no ifcopenshell)`);
|
|
56
|
+
} catch { searched.push(`${candidate.bin} (not runnable)`); }
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
available: false, searched,
|
|
60
|
+
guidance: 'Install IfcOpenShell into any Python 3 (pip install ifcopenshell), or install FreeCAD, which bundles it. '
|
|
61
|
+
+ 'Pass python to point at a specific interpreter.',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function ifcStatus(options = {}) {
|
|
66
|
+
const found = await discoverIfcPython({ ...options, fresh: true });
|
|
67
|
+
return { capability: 'cad.bim.ifc.status', adapter: fs.existsSync(IFC_ADAPTER_PATH), ...found };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function resolveIfc(value, label, cwd, { mustExist }) {
|
|
71
|
+
if (!String(value || '').trim()) throw Object.assign(new Error(`${label} path is required`), { code: 'sam_invalid_input' });
|
|
72
|
+
const resolved = path.resolve(cwd, String(value));
|
|
73
|
+
if (path.extname(resolved).toLowerCase() !== '.ifc') throw Object.assign(new Error(`${label} must be an .ifc file`), { code: 'sam_invalid_input' });
|
|
74
|
+
if (mustExist && !isFile(resolved)) throw Object.assign(new Error(`${label} file not found: ${resolved}`), { code: 'sam_invalid_input' });
|
|
75
|
+
return resolved;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function parseIfcResult(stdout) {
|
|
79
|
+
const line = String(stdout || '').split(/\r?\n/).reverse().find(v => v.startsWith(IFC_RESULT_PREFIX));
|
|
80
|
+
if (!line) throw new Error('IFC adapter did not return an AgentSam result envelope');
|
|
81
|
+
try { return JSON.parse(line.slice(IFC_RESULT_PREFIX.length)); } catch { throw new Error('IFC adapter returned malformed JSON'); }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function runAdapter({ operation, request, python, timeoutSeconds = 120, cwd, runProcessImpl = runProcess }) {
|
|
85
|
+
const runtime = await discoverIfcPython({ python, runProcessImpl });
|
|
86
|
+
if (!runtime.available) {
|
|
87
|
+
throw Object.assign(new Error(`IfcOpenShell is not available (looked in: ${runtime.searched.join(', ') || 'no interpreters'}). ${runtime.guidance}`),
|
|
88
|
+
{ code: 'sam_ifc_runtime_unavailable' });
|
|
89
|
+
}
|
|
90
|
+
if (!fs.existsSync(IFC_ADAPTER_PATH)) throw new Error('IFC adapter is not installed with this SDK build');
|
|
91
|
+
const timeout = Number(timeoutSeconds);
|
|
92
|
+
if (!Number.isInteger(timeout) || timeout < 1 || timeout > 600) throw new Error('timeout must be an integer from 1 to 600 seconds');
|
|
93
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-ifc-'));
|
|
94
|
+
const requestPath = path.join(dir, 'request.json');
|
|
95
|
+
fs.writeFileSync(requestPath, JSON.stringify({ schema_version: 1, ...request }), { mode: 0o600 });
|
|
96
|
+
try {
|
|
97
|
+
const proc = await runProcessImpl(runtime.python, [IFC_ADAPTER_PATH, '--operation', operation, '--request', requestPath],
|
|
98
|
+
{ cwd, timeoutMs: timeout * 1000, maxBytes: 32 * 1024 * 1024 });
|
|
99
|
+
let envelope;
|
|
100
|
+
try { envelope = parseIfcResult(proc.stdout); } catch (error) {
|
|
101
|
+
throw new Error(proc.code === 0 ? error.message : `IFC ${operation} failed (exit ${proc.code}): ${(proc.stderr || proc.stdout || '').slice(-2000)}`);
|
|
102
|
+
}
|
|
103
|
+
if (proc.code !== 0 || envelope.ok === false) {
|
|
104
|
+
const message = String(envelope.error || `IFC ${operation} failed`);
|
|
105
|
+
throw Object.assign(new Error(message), { code: message.includes('ifc_edit_base_conflict') ? 'sam_revision_conflict' : 'sam_ifc_operation_failed' });
|
|
106
|
+
}
|
|
107
|
+
return { envelope, runtime, dir, requestDir: dir };
|
|
108
|
+
} catch (error) { fs.rmSync(dir, { recursive: true, force: true }); throw error; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const finish = ({ dir }) => fs.rmSync(dir, { recursive: true, force: true });
|
|
112
|
+
const receipt = (runtime, started) => ({ python: runtime.python, python_source: runtime.source, ifcopenshell: runtime.ifcopenshell, duration_ms: Date.now() - started });
|
|
113
|
+
|
|
114
|
+
export async function ifcInspect({ input, maxElements, python, timeoutSeconds, cwd = process.cwd(), runProcessImpl } = {}) {
|
|
115
|
+
const source = resolveIfc(input, 'input', cwd, { mustExist: true });
|
|
116
|
+
const started = Date.now();
|
|
117
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'agentsam-ifc-out-'));
|
|
118
|
+
try {
|
|
119
|
+
const output = path.join(dir, 'model.json');
|
|
120
|
+
const run = await runAdapter({ operation: 'inspect', request: { input: source, output, ...(maxElements ? { max_elements: maxElements } : {}) }, python, timeoutSeconds, cwd, runProcessImpl });
|
|
121
|
+
try {
|
|
122
|
+
const model = JSON.parse(fs.readFileSync(output, 'utf8'));
|
|
123
|
+
return { schema_version: 1, capability: 'cad.bim.ifc.inspect', input: { path: source, sha256: sha256File(source) }, model, metrics: run.envelope.metrics, ...receipt(run.runtime, started) };
|
|
124
|
+
} finally { finish(run); }
|
|
125
|
+
} finally { fs.rmSync(dir, { recursive: true, force: true }); }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function ifcValidate({ input, python, timeoutSeconds, cwd = process.cwd(), runProcessImpl } = {}) {
|
|
129
|
+
const source = resolveIfc(input, 'input', cwd, { mustExist: true });
|
|
130
|
+
const started = Date.now();
|
|
131
|
+
const run = await runAdapter({ operation: 'validate', request: { input: source }, python, timeoutSeconds, cwd, runProcessImpl });
|
|
132
|
+
try { return { schema_version: 1, capability: 'cad.bim.ifc.validate', input: { path: source }, ...run.envelope.data, ...receipt(run.runtime, started) }; } finally { finish(run); }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function ifcDiff({ input, other, python, timeoutSeconds, cwd = process.cwd(), runProcessImpl } = {}) {
|
|
136
|
+
const a = resolveIfc(input, 'input', cwd, { mustExist: true });
|
|
137
|
+
const b = resolveIfc(other, 'other', cwd, { mustExist: true });
|
|
138
|
+
const started = Date.now();
|
|
139
|
+
const run = await runAdapter({ operation: 'diff', request: { input: a, other: b }, python, timeoutSeconds, cwd, runProcessImpl });
|
|
140
|
+
try { return { schema_version: 1, capability: 'cad.bim.ifc.diff', ...run.envelope.data, ...receipt(run.runtime, started) }; } finally { finish(run); }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Edits a COPY. `base` (sha256 of the source you read) is the revision precondition; it defaults to the file as it is now. */
|
|
144
|
+
export async function ifcEdit({ input, output, edits, base, python, timeoutSeconds, cwd = process.cwd(), runProcessImpl } = {}) {
|
|
145
|
+
const source = resolveIfc(input, 'input', cwd, { mustExist: true });
|
|
146
|
+
const target = resolveIfc(output, 'output', cwd, { mustExist: false });
|
|
147
|
+
if (!Array.isArray(edits) || edits.length === 0) throw Object.assign(new Error('edits must be a non-empty array'), { code: 'sam_invalid_input' });
|
|
148
|
+
if (base != null && !/^[a-f0-9]{64}$/.test(String(base))) throw Object.assign(new Error('base must be a sha256 hex digest'), { code: 'sam_invalid_input' });
|
|
149
|
+
const started = Date.now();
|
|
150
|
+
const run = await runAdapter({ operation: 'edit', request: { input: source, output: target, base_sha256: base ?? sha256File(source), edits }, python, timeoutSeconds, cwd, runProcessImpl });
|
|
151
|
+
try { return { schema_version: 1, capability: 'cad.bim.ifc.edit', ...run.envelope.data, ...receipt(run.runtime, started) }; } finally { finish(run); }
|
|
152
|
+
}
|
package/src/lib/cad/index.js
CHANGED
|
@@ -38,6 +38,7 @@ export {
|
|
|
38
38
|
FREECAD_ADAPTER_PATH,
|
|
39
39
|
FREECAD_EXPORT_FORMATS,
|
|
40
40
|
discoverFreeCadPython,
|
|
41
|
+
resolveFreeCadHost,
|
|
41
42
|
freeCadBuild,
|
|
42
43
|
freeCadInspect,
|
|
43
44
|
} from './freecad.js';
|
|
@@ -55,6 +56,8 @@ export {
|
|
|
55
56
|
export * from './project-contract.js';
|
|
56
57
|
export * from './project-tools.js';
|
|
57
58
|
export * from './project-v2.js';
|
|
59
|
+
export * from './format-policy.js';
|
|
60
|
+
export * from './bim-bridge.js';
|
|
58
61
|
export * from './delivery-profiles.js';
|
|
59
62
|
export * from './production-operations.js';
|
|
60
63
|
|
|
@@ -5,6 +5,8 @@ export const CAD_PRODUCTION_CAPABILITIES = Object.freeze([
|
|
|
5
5
|
['cad.geometry.validate', 'Validate dimensional CAD entities and constraints.', 'read'],
|
|
6
6
|
['cad.bim.ifc.export', 'Export a semantic IFC building model from an approved revision.', 'write'],
|
|
7
7
|
['cad.solid.export', 'Export precision BREP solids from approved geometry.', 'write'],
|
|
8
|
+
['cad.mesh.export', 'Export fabricated triangle meshes and 3MF packages with unit and watertightness verification.', 'write'],
|
|
9
|
+
['cad.native.export', 'Export an editable native CAD project through an explicitly authorized desktop engine.', 'write'],
|
|
8
10
|
['cad.drawing.generate', 'Generate dimensioned vector and PDF engineering drawing sheets.', 'write'],
|
|
9
11
|
['cad.schedule.generate', 'Generate model-derived schedules, not invented cost figures.', 'write'],
|
|
10
12
|
['cad.quantity.takeoff', 'Calculate traceable measured material quantities.', 'write'],
|
|
@@ -58,7 +58,7 @@ export function createProjectRuntime({store,artifactRoot,native={blenderBuild,bl
|
|
|
58
58
|
return {...prior,operation:name};
|
|
59
59
|
}
|
|
60
60
|
const created=await occt.execute('design_model_build',{kind:'features',units:'mm',operations:history.operations,cursor:history.cursor,elementId:args.element_id,format},{artifactRoot:dir,projectId:row.project.id});
|
|
61
|
-
const out={...created,operation:name,project_id:row.project.id,revision:row.revision,content_hash:row.content_hash,source:'cad.project
|
|
61
|
+
const out={...created,operation:name,project_id:row.project.id,revision:row.revision,content_hash:row.content_hash,source:row.project.schema??'cad.project'};
|
|
62
62
|
fs.renameSync(out.artifact.path,final);out.artifact.path=final;
|
|
63
63
|
fs.writeFileSync(final+'.json',JSON.stringify(out,null,2));return out;
|
|
64
64
|
}
|
|
@@ -78,7 +78,7 @@ export function createProjectRuntime({store,artifactRoot,native={blenderBuild,bl
|
|
|
78
78
|
fs.renameSync(created.artifact.path,stepFile);
|
|
79
79
|
const out={...created,artifact:{...created.artifact,path:stepFile},
|
|
80
80
|
project_id:row.project.id,revision:row.revision,content_hash:row.content_hash,
|
|
81
|
-
parametric_object_id:object.id,source:'cad.project
|
|
81
|
+
parametric_object_id:object.id,source:row.project.schema??'cad.project'};
|
|
82
82
|
fs.writeFileSync(occtReceipt,JSON.stringify(out,null,2));
|
|
83
83
|
return out;
|
|
84
84
|
}
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* identity, asset store, queue or GOAP machinery.
|
|
5
5
|
*/
|
|
6
6
|
import { requireValidProject } from './project-contract.js';
|
|
7
|
+
import {
|
|
8
|
+
isAgentSourceFormatReference as isSourceFormatReference,
|
|
9
|
+
isAgentSourceKindReference as isSourceKindReference,
|
|
10
|
+
isAgentSourceIdentificationResult as isSourceIdentificationResult,
|
|
11
|
+
} from '@inneranimalmedia/agentsam-contracts/source-types/registry';
|
|
7
12
|
|
|
8
13
|
export const CAD_PROJECT_V2 = 'cad.project.v2';
|
|
9
14
|
export const CAD_DOMAINS = Object.freeze([
|
|
@@ -16,29 +21,6 @@ const isRecord = value => value !== null && typeof value === 'object' && !Array.
|
|
|
16
21
|
const isId = value => typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$/.test(value);
|
|
17
22
|
const isSha = value => typeof value === 'string' && /^[a-f0-9]{64}$/.test(value);
|
|
18
23
|
const validUri = value => typeof value === 'string' && value.length > 0 && !/^javascript:/i.test(value);
|
|
19
|
-
const SOURCE_TYPES_CATALOG = 'agentsam.source-types.v2';
|
|
20
|
-
const sourceIdentificationStatuses = new Set(['declared','identified','ambiguous','unknown','mismatch']);
|
|
21
|
-
const sourceIdentificationConfidence = new Set(['high','medium','low','none']);
|
|
22
|
-
const sourceIdentificationEvidence = new Set(['extension','media-type','signature','container','content','application-context','user-selection','provider-metadata']);
|
|
23
|
-
const isSourceFormatReference = value => isRecord(value)
|
|
24
|
-
&& value.catalog === SOURCE_TYPES_CATALOG
|
|
25
|
-
&& typeof value.id === 'string' && /^[a-z][a-z0-9.-]{1,127}$/.test(value.id)
|
|
26
|
-
&& (value.extension == null || (typeof value.extension === 'string' && /^\.[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(value.extension)))
|
|
27
|
-
&& (value.mediaType == null || (typeof value.mediaType === 'string' && value.mediaType.length >= 3))
|
|
28
|
-
&& (value.variant == null || (typeof value.variant === 'string' && value.variant.length > 0))
|
|
29
|
-
&& (value.parameters == null || (isRecord(value.parameters) && Object.values(value.parameters).every(v => ['string','number','boolean'].includes(typeof v))))
|
|
30
|
-
&& Object.keys(value).every(k => ['catalog','id','extension','mediaType','variant','parameters'].includes(k));
|
|
31
|
-
const isSourceKindReference = value => isRecord(value)
|
|
32
|
-
&& value.catalog === SOURCE_TYPES_CATALOG
|
|
33
|
-
&& typeof value.id === 'string' && /^[a-z][a-z0-9.-]{1,63}$/.test(value.id)
|
|
34
|
-
&& Object.keys(value).every(k => ['catalog','id'].includes(k));
|
|
35
|
-
const isSourceIdentificationResult = value => isRecord(value)
|
|
36
|
-
&& sourceIdentificationStatuses.has(value.status)
|
|
37
|
-
&& sourceIdentificationConfidence.has(value.confidence)
|
|
38
|
-
&& Array.isArray(value.evidence) && value.evidence.every(x => sourceIdentificationEvidence.has(x))
|
|
39
|
-
&& (value.candidates == null || (Array.isArray(value.candidates) && value.candidates.every(isSourceFormatReference)))
|
|
40
|
-
&& (value.notes == null || (Array.isArray(value.notes) && value.notes.every(x => typeof x === 'string')))
|
|
41
|
-
&& Object.keys(value).every(k => ['status','confidence','evidence','candidates','notes'].includes(k));
|
|
42
24
|
const groupsV1 = ['walls', 'rooms', 'doors', 'windows', 'furniture', 'annotations'];
|
|
43
25
|
const states = new Set(['planned', 'queued', 'running', 'generated', 'validated', 'approved', 'stale', 'failed', 'blocked']);
|
|
44
26
|
const profiles = Object.freeze({
|
|
@@ -84,8 +66,14 @@ export function validateCadProjectV2(project) {
|
|
|
84
66
|
if (requiredModule && !isRecord(project.modules?.[requiredModule])) errors.push('domain_module_required:' + requiredModule);
|
|
85
67
|
if (project.domain === 'architecture.building' && isRecord(project.modules?.architecture)) {
|
|
86
68
|
const a = project.modules.architecture;
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
const legacy = isRecord(a.site) && Array.isArray(a.spaces) && Array.isArray(a.openings)
|
|
70
|
+
&& (Array.isArray(a.walls) || Array.isArray(a.wings));
|
|
71
|
+
// The separately versioned architecture module uses sites/buildings/storeys.
|
|
72
|
+
// Preserve legacy sources without rejecting a valid strict v1 module.
|
|
73
|
+
const strict = a.schema === 'cad.module.architecture.v1' && a.version === 1
|
|
74
|
+
&& Array.isArray(a.sites) && Array.isArray(a.buildings) && Array.isArray(a.storeys)
|
|
75
|
+
&& Array.isArray(a.spaces) && Array.isArray(a.relationships);
|
|
76
|
+
if (!legacy && !strict)
|
|
89
77
|
errors.push('architecture_site_spaces_openings_and_massing_required');
|
|
90
78
|
}
|
|
91
79
|
for (const key of ['assets', 'views', 'sheets', 'scenes', 'productions', 'outputs', 'packages', 'receipts', 'revisions']) {
|
package/src/lib/cad-docker.js
CHANGED
|
@@ -5,13 +5,14 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
|
|
6
6
|
const sdkRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
7
7
|
const CAD_SERVER_FILE = 'services/cad/server.py';
|
|
8
|
+
const OCCT_NATIVE_FILES = Object.freeze(['CMakeLists.txt', 'main.cpp', 'engine.cpp', 'engine.hpp', 'sketch_solver.cpp', 'sketch_solver.hpp']);
|
|
8
9
|
|
|
9
10
|
export const CAD_TOOLS = Object.freeze(['openscad', 'freecad', 'blender', 'ifc', 'media', 'occt']);
|
|
10
11
|
|
|
11
12
|
// Pinned so every build, on any machine, gets the same toolchain. ifcopenshell 0.9.x wheels need a newer
|
|
12
13
|
// glibc than Debian 12 ships; 0.8.4.post1 is the newest that imports on bookworm. The distro Node is too
|
|
13
14
|
// old for current glTF tooling, so Node is installed from a checksum-verified tarball.
|
|
14
|
-
export const CAD_PINS = Object.freeze({ ifcopenshell: '0.8.4.post1', ezdxf: '1.4.5', pymupdf: '1.28.2', pillow: '13.0.0', gltfTransformCli: '4.5.1', node: 'v20.20.2' });
|
|
15
|
+
export const CAD_PINS = Object.freeze({ ifcopenshell: '0.8.4.post1', ezdxf: '1.4.5', pymupdf: '1.28.2', pillow: '13.0.0', gltfTransformCli: '4.5.1', node: 'v20.20.2', occt: '7.9.3', occtCommit: 'a016080bf6738d6aeae020badee4e888ad1540a5', boost: '1.84.0', boostSha256: 'cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454' });
|
|
15
16
|
|
|
16
17
|
const APT_PACKAGES = Object.freeze({
|
|
17
18
|
openscad: ['openscad', 'xvfb', 'xauth'],
|
|
@@ -19,7 +20,7 @@ const APT_PACKAGES = Object.freeze({
|
|
|
19
20
|
blender: ['blender'],
|
|
20
21
|
ifc: ['python3-venv', 'fonts-dejavu-core'],
|
|
21
22
|
media: ['ffmpeg'],
|
|
22
|
-
occt: ['
|
|
23
|
+
occt: ['libfreetype6', 'libfontconfig1', 'libx11-6', 'libxext6'],
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
export function normalizeCadTools(input) {
|
|
@@ -73,7 +74,7 @@ export function cadDefaultResources(tools) {
|
|
|
73
74
|
function runtimeDigest() {
|
|
74
75
|
const digest = createHash('sha256');
|
|
75
76
|
digest.update(CAD_SERVER_FILE).update('\0').update(fs.readFileSync(path.join(sdkRoot, CAD_SERVER_FILE))).update('\0');
|
|
76
|
-
for (const extra of ['services/cad/provision/install_node.py',
|
|
77
|
+
for (const extra of ['services/cad/provision/install_node.py', ...OCCT_NATIVE_FILES.map(file => `packages/agentsam-occt/native/${file}`)]) {
|
|
77
78
|
const file = path.join(sdkRoot, extra);
|
|
78
79
|
if (fs.existsSync(file)) digest.update(extra).update('\0').update(fs.readFileSync(file)).update('\0');
|
|
79
80
|
}
|
|
@@ -93,8 +94,8 @@ export function generateCadDocker(opts = {}) {
|
|
|
93
94
|
|
|
94
95
|
const packages = ['python3', 'ca-certificates', 'passwd', ...new Set(tools.flatMap(tool => APT_PACKAGES[tool]))];
|
|
95
96
|
const q = JSON.stringify;
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
// server.py imports agentsam_sdk.cad (the one native-host implementation, adapters included).
|
|
98
|
+
const copyLines = ['COPY server.py /srv/server.py', 'COPY agentsam_sdk/ /srv/agentsam_sdk/'];
|
|
98
99
|
if (tools.includes('blender')) copyLines.push('COPY blender/ /srv/blender/');
|
|
99
100
|
const provision = [];
|
|
100
101
|
if (tools.includes('ifc')) {
|
|
@@ -104,18 +105,36 @@ export function generateCadDocker(opts = {}) {
|
|
|
104
105
|
provision.push('COPY provision/install_node.py /tmp/install_node.py');
|
|
105
106
|
provision.push(`RUN python3 /tmp/install_node.py ${CAD_PINS.node} /opt/node \\\n && PATH=/opt/node/bin:$PATH npm install -g --no-audit --no-fund @gltf-transform/cli@${CAD_PINS.gltfTransformCli} \\\n && rm -rf /tmp/install_node.py /root/.npm`);
|
|
106
107
|
}
|
|
107
|
-
if (tools.includes('occt'))
|
|
108
|
+
if (tools.includes('occt')) {
|
|
109
|
+
provision.push('COPY --from=occt-build /opt/occt/lib /opt/occt/lib');
|
|
110
|
+
// Register the kernel libraries with the dynamic linker so the engine runs for any user and any exec path.
|
|
111
|
+
provision.push("RUN echo /opt/occt/lib > /etc/ld.so.conf.d/occt.conf && ldconfig");
|
|
112
|
+
provision.push('COPY --from=occt-build /build/agentsam-occt /usr/local/bin/agentsam-occt');
|
|
113
|
+
}
|
|
108
114
|
const extraEnv = [
|
|
109
115
|
tools.includes('media') ? 'PATH=/opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' : '',
|
|
110
116
|
tools.includes('ifc') ? 'AGENTSAM_CAD_PYTHON=/opt/agentsam-venv/bin/python' : '',
|
|
111
117
|
].filter(Boolean);
|
|
112
|
-
const occtStage = tools.includes('occt') ? `FROM debian:bookworm-slim AS occt-
|
|
118
|
+
const occtStage = tools.includes('occt') ? `FROM debian:bookworm-slim AS occt-kernel
|
|
113
119
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
114
120
|
RUN apt-get update \\
|
|
115
|
-
&& apt-get install -y --no-install-recommends ca-certificates g++ cmake ninja-build
|
|
121
|
+
&& apt-get install -y --no-install-recommends ca-certificates git curl bzip2 g++ cmake ninja-build libfreetype-dev libfontconfig-dev libgl-dev libglu1-mesa-dev libx11-dev libxext-dev libxmu-dev libxi-dev \\
|
|
116
122
|
&& rm -rf /var/lib/apt/lists/*
|
|
123
|
+
RUN git clone --depth 1 --branch V${CAD_PINS.occt.replaceAll('.', '_')} https://github.com/Open-Cascade-SAS/OCCT.git /src/occt-kernel \\
|
|
124
|
+
&& test "$(git -C /src/occt-kernel rev-parse HEAD)" = "${CAD_PINS.occtCommit}" \\
|
|
125
|
+
&& cmake -S /src/occt-kernel -B /build-kernel -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/occt -DBUILD_LIBRARY_TYPE=Shared -DBUILD_MODULE_Draw=OFF -DBUILD_DOC_Overview=OFF -DUSE_TBB=OFF -DUSE_RAPIDJSON=OFF -DUSE_DRACO=OFF -DUSE_FFMPEG=OFF -DUSE_VTK=OFF -DUSE_TK=OFF -DUSE_FREEIMAGE=OFF \\
|
|
126
|
+
&& cmake --build /build-kernel -j6 \\
|
|
127
|
+
&& cmake --install /build-kernel \\
|
|
128
|
+
&& rm -rf /src/occt-kernel /build-kernel
|
|
129
|
+
|
|
130
|
+
FROM occt-kernel AS occt-build
|
|
131
|
+
RUN curl -fsSL -o /tmp/boost.tar.bz2 https://archives.boost.io/release/${CAD_PINS.boost}/source/boost_${CAD_PINS.boost.replaceAll('.', '_')}.tar.bz2 \\
|
|
132
|
+
&& echo "${CAD_PINS.boostSha256} /tmp/boost.tar.bz2" | sha256sum -c - \\
|
|
133
|
+
&& mkdir -p /opt/boost/include \\
|
|
134
|
+
&& tar -xjf /tmp/boost.tar.bz2 -C /opt/boost/include --strip-components=1 boost_${CAD_PINS.boost.replaceAll('.', '_')}/boost \\
|
|
135
|
+
&& rm /tmp/boost.tar.bz2
|
|
117
136
|
COPY occt/ /src/occt/
|
|
118
|
-
RUN cmake -S /src/occt -B /build -G Ninja -DCMAKE_BUILD_TYPE=Release -DAGENTSAM_OCCT_PREFIX=/
|
|
137
|
+
RUN cmake -S /src/occt -B /build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/boost -DAGENTSAM_OCCT_PREFIX=/opt/occt -DAGENTSAM_OCCT_LIBDIR=/opt/occt/lib \\
|
|
119
138
|
&& cmake --build /build
|
|
120
139
|
|
|
121
140
|
` : '';
|
|
@@ -208,20 +227,19 @@ export function stageCadContext(versionDir, opts = {}) {
|
|
|
208
227
|
fs.mkdirSync(context, { recursive: true });
|
|
209
228
|
fs.copyFileSync(path.join(sdkRoot, CAD_SERVER_FILE), path.join(context, 'server.py'));
|
|
210
229
|
const tools = opts.tools ? normalizeCadTools(opts.tools) : [];
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
230
|
+
const sdkCadSource = path.join(sdkRoot, 'python/agentsam_sdk/cad');
|
|
231
|
+
if (!fs.existsSync(sdkCadSource)) throw new Error(`SDK CAD module missing from this install: ${sdkCadSource}`);
|
|
232
|
+
const sdkStage = path.join(context, 'agentsam_sdk');
|
|
233
|
+
fs.mkdirSync(sdkStage, { recursive: true });
|
|
234
|
+
fs.writeFileSync(path.join(sdkStage, '__init__.py'), '"""Minimal agentsam_sdk package staged for the CAD service; only agentsam_sdk.cad ships here."""\n');
|
|
235
|
+
fs.cpSync(sdkCadSource, path.join(sdkStage, 'cad'), { recursive: true, filter: source => path.basename(source) !== '__pycache__' });
|
|
218
236
|
if (tools.includes('media')) {
|
|
219
237
|
fs.mkdirSync(path.join(context, 'provision'), { recursive: true });
|
|
220
238
|
fs.copyFileSync(path.join(sdkRoot, 'services/cad/provision/install_node.py'), path.join(context, 'provision', 'install_node.py'));
|
|
221
239
|
}
|
|
222
240
|
if (tools.includes('occt')) {
|
|
223
241
|
fs.mkdirSync(path.join(context, 'occt'), { recursive: true });
|
|
224
|
-
for (const file of
|
|
242
|
+
for (const file of OCCT_NATIVE_FILES) fs.copyFileSync(path.join(sdkRoot, 'packages/agentsam-occt/native', file), path.join(context, 'occt', file));
|
|
225
243
|
}
|
|
226
244
|
if (tools.includes('blender')) {
|
|
227
245
|
const blenderAdapter = path.join(sdkRoot, 'services/cad/blender/adapter.py');
|