@inneranimalmedia/agentsam-sdk 2.6.4 → 2.6.5
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 +11 -0
- package/README.md +15 -9
- package/apps/client-cms-editor/AGENTS.md +12 -0
- package/apps/client-cms-editor/IMPORT_PROVENANCE.json +8 -0
- package/apps/client-cms-editor/README.md +72 -0
- package/apps/client-cms-editor/agentsam.app.json +57 -0
- package/apps/client-cms-editor/backend/README.md +5 -0
- package/apps/client-cms-editor/backend/package.json +22 -0
- package/apps/client-cms-editor/backend/src/api/client.ts +200 -0
- package/apps/client-cms-editor/backend/src/demo-bootstrap.ts +145 -0
- package/apps/client-cms-editor/backend/src/index.ts +6 -0
- package/apps/client-cms-editor/backend/src/model.ts +115 -0
- package/apps/client-cms-editor/backend/src/preview/bridge.ts +79 -0
- package/apps/client-cms-editor/backend/src/preview/urls.ts +55 -0
- package/apps/client-cms-editor/backend/src/routing/cms-route.js +293 -0
- package/apps/client-cms-editor/backend/src/routing/index.js +10 -0
- package/apps/client-cms-editor/backend/src/storefront.ts +52 -0
- package/apps/client-cms-editor/backend/tsconfig.json +15 -0
- package/apps/client-cms-editor/backend/worker/index.js +34 -0
- package/apps/client-cms-editor/backend/wrangler.jsonc +11 -0
- package/apps/client-cms-editor/bin/agentsam-cms.mjs +229 -0
- package/apps/client-cms-editor/frontend/index.html +12 -0
- package/apps/client-cms-editor/frontend/package.json +33 -0
- package/apps/client-cms-editor/frontend/src/AgentSamDrawer.tsx +188 -0
- package/apps/client-cms-editor/frontend/src/CmsAgentSurface.tsx +191 -0
- package/apps/client-cms-editor/frontend/src/CmsEditor.tsx +1345 -0
- package/apps/client-cms-editor/frontend/src/env.d.ts +14 -0
- package/apps/client-cms-editor/frontend/src/index.ts +8 -0
- package/apps/client-cms-editor/frontend/src/lib/content-safety.ts +63 -0
- package/apps/client-cms-editor/frontend/src/main.tsx +17 -0
- package/apps/client-cms-editor/frontend/src/mount.tsx +51 -0
- package/apps/client-cms-editor/frontend/src/styles/agentsam-drawer.css +214 -0
- package/apps/client-cms-editor/frontend/src/styles/cmsShell.css +1739 -0
- package/apps/client-cms-editor/frontend/src/styles/studio.css +106 -0
- package/apps/client-cms-editor/frontend/src/surfaces/CmsDashboard.tsx +313 -0
- package/apps/client-cms-editor/frontend/src/surfaces/CmsGuidedChatHero.tsx +121 -0
- package/apps/client-cms-editor/frontend/src/surfaces/CmsHubPage.tsx +132 -0
- package/apps/client-cms-editor/frontend/src/surfaces/CmsSiteSwitcher.tsx +176 -0
- package/apps/client-cms-editor/frontend/src/surfaces/index.ts +5 -0
- package/apps/client-cms-editor/frontend/src/surfaces/types.ts +48 -0
- package/apps/client-cms-editor/frontend/tsconfig.json +25 -0
- package/apps/client-cms-editor/frontend/vite.config.ts +13 -0
- package/apps/client-cms-editor/package-lock.json +3832 -0
- package/apps/client-cms-editor/package.json +23 -0
- package/apps/client-cms-editor/reference/DONOR_README.md +52 -0
- package/apps/client-cms-editor/reference/DONOR_package-lock.json +1253 -0
- package/apps/client-cms-editor/reference/DONOR_tsconfig.json +15 -0
- package/apps/client-cms-editor/shared/cms/package.json +21 -0
- package/apps/client-cms-editor/shared/cms/src/agent-context.ts +35 -0
- package/apps/client-cms-editor/shared/cms/src/cloudflare-bindings.ts +51 -0
- package/apps/client-cms-editor/shared/cms/src/editor-types.ts +58 -0
- package/apps/client-cms-editor/shared/cms/src/index.ts +5 -0
- package/apps/client-cms-editor/shared/cms/src/publication.ts +24 -0
- package/apps/client-cms-editor/shared/cms/src/routes.ts +11 -0
- package/apps/client-cms-editor/shared/cms/tsconfig.json +12 -0
- package/bin/agentsam-rapid-rust +36 -0
- package/docs/AUTH_IDENTITY_CONTRACT.md +2 -0
- package/docs/MACHINE_INTELLIGENCE.md +120 -0
- package/docs/WINDOWS_RUNTIME_INSTALL.md +30 -0
- package/docs/architecture/AGENTSAM_APPLICATION_CONTRACT.md +188 -0
- package/docs/architecture/AGENTSAM_RUNTIME_PROTOCOL.md +151 -0
- package/docs/architecture/LOCAL_STUDIO_CLOUDFLARE_OAUTH.md +12 -4
- package/docs/architecture/R2_SLUG_NAMESPACE.md +20 -0
- package/docs/architecture/WORK_PRODUCT_EXTRACTION.md +97 -0
- package/docs/brand/AGENT_SAM_ICON_GRAMMAR.md +70 -0
- package/docs/content-studio/HOST_MOUNT_CHECKLIST.md +71 -0
- package/docs/content-studio/REVISION_GATE_2026-09-27.md +501 -0
- package/docs/contracts/capability-install-planner.md +67 -0
- package/docs/contracts/environment-vocabulary.md +195 -0
- package/docs/contracts/google-cloud-oauth-setup.md +199 -0
- package/docs/local-studio/WORKMODE_DONOR_NOTES.md +1 -1
- package/docs/plans/LOCAL-STUDIO-GRADUATION-2026-09-26.md +290 -0
- package/docs/plans/LOCAL-STUDIO-REAL-APP-CONTRACT-ADDENDUM-2026-09-27.md +394 -0
- package/docs/plans/MACHINE-FIRST-APPS-TUI-2026-09-24.md +227 -0
- package/docs/plans/TOMORROW-EXTENSIVE-TODO-2026-09-26.md +221 -0
- package/docs/plans/TOMORROW-MACHINE-FIRST-BRIEFING.md +145 -0
- package/docs/plans/UNIVERSAL-INGEST-MACHINE-FIRST-2026-09-24.md +215 -0
- package/docs/plugins.md +2 -2
- package/docs/product/AGENTSAM_PRODUCT_EXPERIENCE_STANDARD.md +280 -0
- package/docs/product/LOCAL_STUDIO_DESKTOP_EXPERIENCE.md +139 -0
- package/docs/product/README.md +8 -0
- package/docs/rapid-rust-wasm.md +35 -0
- package/migrations/d1/0016_cloudflare_oauth_user_oauth_tokens_ssot.sql +14 -0
- package/package.json +73 -14
- package/packages/agentsam-brand/README.md +106 -11
- package/packages/agentsam-brand/bin/agentsam-brand.mjs +9 -0
- package/packages/agentsam-brand/package.json +39 -7
- package/packages/agentsam-brand/src/adapters/cloudflare-images.js +453 -0
- package/packages/agentsam-brand/src/adapters/cloudflare-r2.js +74 -0
- package/packages/agentsam-brand/src/adapters/d1-registry.js +26 -0
- package/packages/agentsam-brand/src/adapters/filesystem.js +59 -0
- package/packages/agentsam-brand/src/adapters/memory.js +31 -0
- package/packages/agentsam-brand/src/cli/controller.js +503 -0
- package/packages/agentsam-brand/src/cli/wizard.js +526 -0
- package/packages/agentsam-brand/src/core/capabilities.js +201 -0
- package/packages/agentsam-brand/src/core/derivatives.js +211 -0
- package/packages/agentsam-brand/src/core/errors.js +12 -0
- package/packages/agentsam-brand/src/core/ingest.js +195 -0
- package/packages/agentsam-brand/src/core/inspect.js +109 -0
- package/packages/agentsam-brand/src/core/keys.js +83 -0
- package/packages/agentsam-brand/src/core/naming.js +142 -0
- package/packages/agentsam-brand/src/core/optimize.js +316 -0
- package/packages/agentsam-brand/src/core/pack.js +305 -0
- package/packages/agentsam-brand/src/core/plan.js +276 -0
- package/packages/agentsam-brand/src/core/preview.js +159 -0
- package/packages/agentsam-brand/src/core/processors/cloudflare.js +68 -0
- package/packages/agentsam-brand/src/core/processors/contract.js +203 -0
- package/packages/agentsam-brand/src/core/processors/index.js +148 -0
- package/packages/agentsam-brand/src/core/processors/native.js +82 -0
- package/packages/agentsam-brand/src/core/processors/sharp.js +113 -0
- package/packages/agentsam-brand/src/core/processors/squoosh-binary.js +195 -0
- package/packages/agentsam-brand/src/core/promote.js +288 -0
- package/packages/agentsam-brand/src/core/receipts.js +155 -0
- package/packages/agentsam-brand/src/core/v2/compile.js +280 -0
- package/packages/agentsam-brand/src/core/v2/derivatives-semantic.js +207 -0
- package/packages/agentsam-brand/src/core/v2/ingest-graph.js +387 -0
- package/packages/agentsam-brand/src/core/v2/roles.js +180 -0
- package/packages/agentsam-brand/src/core/v2/schema.js +209 -0
- package/packages/agentsam-brand/src/core/v2/templates.js +114 -0
- package/packages/agentsam-brand/src/index.js +193 -36
- package/packages/agentsam-brand/src/presets/app-icon.json +16 -0
- package/packages/agentsam-brand/src/presets/favicon.json +17 -0
- package/packages/agentsam-brand/src/presets/hero.json +12 -0
- package/packages/agentsam-brand/src/presets/index.js +40 -0
- package/packages/agentsam-brand/src/presets/logo.json +12 -0
- package/packages/agentsam-brand/src/presets/model.json +8 -0
- package/packages/agentsam-brand/src/presets/og-image.json +10 -0
- package/packages/agentsam-brand/src/presets/product-shot.json +11 -0
- package/packages/agentsam-brand/src/presets/social-image.json +10 -0
- package/packages/agentsam-brand/src/presets/web-image.json +10 -0
- package/packages/agentsam-contracts/src/artifacts.ts +41 -0
- package/packages/agentsam-knowledge/src/autorag/index.js +1 -1
- package/packages/agentsam-knowledge/src/providers/index.js +6 -4
- package/packages/agentsam-knowledge/src/providers/ollama-endpoint.js +31 -0
- package/packages/agentsam-knowledge/test/autorag.test.mjs +22 -1
- package/packages/agentsam-nav/package.json +2 -2
- package/packages/agentsam-rapid-rust/Cargo.lock +344 -0
- package/packages/agentsam-rapid-rust/Cargo.toml +18 -0
- package/packages/agentsam-rapid-rust/README.md +5 -0
- package/packages/agentsam-rapid-rust/src/main.rs +718 -0
- package/packages/agentsam-rapid-rust/templates/api/Cargo.toml.tmpl +18 -0
- package/packages/agentsam-rapid-rust/templates/api/src/lib.rs.tmpl +17 -0
- package/packages/agentsam-rapid-rust/templates/common/README.md.tmpl +22 -0
- package/packages/agentsam-rapid-rust/templates/common/package.json.tmpl +12 -0
- package/packages/agentsam-rapid-rust/templates/common/wrangler.toml.tmpl +6 -0
- package/packages/agentsam-rapid-rust/templates/crypto-auth/Cargo.toml.tmpl +21 -0
- package/packages/agentsam-rapid-rust/templates/crypto-auth/src/lib.rs.tmpl +32 -0
- package/packages/agentsam-rapid-rust/templates/data-processor/Cargo.toml.tmpl +18 -0
- package/packages/agentsam-rapid-rust/templates/data-processor/src/lib.rs.tmpl +41 -0
- package/packages/agentsam-rapid-rust/templates/shared-core/Cargo.toml.tmpl +9 -0
- package/packages/agentsam-rapid-rust/templates/shared-core/core/Cargo.toml.tmpl +7 -0
- package/packages/agentsam-rapid-rust/templates/shared-core/core/src/lib.rs.tmpl +23 -0
- package/packages/agentsam-rapid-rust/templates/shared-core/worker/Cargo.toml.tmpl +12 -0
- package/packages/agentsam-rapid-rust/templates/shared-core/worker/src/lib.rs.tmpl +16 -0
- package/packages/agentsam-rapid-rust/templates/shared-core/wrangler.toml.tmpl +6 -0
- package/packages/agentsam-repository/src/index.js +1 -0
- package/packages/agentsam-repository/src/merkle/semantic.js +3 -10
- package/packages/agentsam-repository/src/source-types.js +85 -0
- package/packages/agentsam-vault/README.md +96 -0
- package/packages/agentsam-vault/package.json +32 -0
- package/packages/agentsam-vault/src/contracts/credential.d.ts +78 -0
- package/packages/agentsam-vault/src/contracts/credential.js +132 -0
- package/packages/agentsam-vault/src/crypto/aes-gcm.d.ts +30 -0
- package/packages/agentsam-vault/src/crypto/aes-gcm.js +107 -0
- package/packages/agentsam-vault/src/crypto/oauth-envelope.js +150 -0
- package/packages/agentsam-vault/src/index.d.ts +9 -0
- package/packages/agentsam-vault/src/index.js +27 -0
- package/packages/agentsam-vault/src/providers/registry.js +90 -0
- package/packages/agentsam-vault/src/runtime/resolver.js +77 -0
- package/packages/agentsam-workbench/README.md +24 -0
- package/packages/agentsam-workbench/package.json +38 -0
- package/packages/agentsam-workbench/src/agent/AgentPanel.tsx +41 -0
- package/packages/agentsam-workbench/src/agent/ArtifactCard.tsx +9 -0
- package/packages/agentsam-workbench/src/agent/Composer.tsx +102 -0
- package/packages/agentsam-workbench/src/agent/ConnectedAgentPanel.tsx +194 -0
- package/packages/agentsam-workbench/src/agent/ContextualComposer.tsx +788 -0
- package/packages/agentsam-workbench/src/agent/GoalStatusStrip.tsx +38 -0
- package/packages/agentsam-workbench/src/agent/MiniAgentSam.tsx +86 -0
- package/packages/agentsam-workbench/src/agent/ModelSelect.tsx +19 -0
- package/packages/agentsam-workbench/src/agent/Thread.tsx +56 -0
- package/packages/agentsam-workbench/src/agent/ToolReceipt.tsx +11 -0
- package/packages/agentsam-workbench/src/agent/contextual-composer.css +611 -0
- package/packages/agentsam-workbench/src/agent/index.ts +10 -0
- package/packages/agentsam-workbench/src/agent/mini-agentsam.css +12 -0
- package/packages/agentsam-workbench/src/browser/BrowserFrame.tsx +37 -0
- package/packages/agentsam-workbench/src/browser/index.ts +1 -0
- package/packages/agentsam-workbench/src/index.ts +6 -0
- package/packages/agentsam-workbench/src/project-control.css +160 -0
- package/packages/agentsam-workbench/src/projects/ProjectsSurface.tsx +131 -0
- package/packages/agentsam-workbench/src/projects/index.ts +1 -0
- package/packages/agentsam-workbench/src/shell/Breadcrumb.tsx +35 -0
- package/packages/agentsam-workbench/src/shell/ResizableStage.tsx +99 -0
- package/packages/agentsam-workbench/src/shell/SidePanel.tsx +5 -0
- package/packages/agentsam-workbench/src/shell/index.ts +4 -0
- package/packages/agentsam-workbench/src/shell/surfaceRegistry.ts +29 -0
- package/packages/agentsam-workbench/src/terminal/TerminalSurface.tsx +5 -0
- package/packages/agentsam-workbench/src/terminal/index.ts +1 -0
- package/packages/agentsam-workbench/src/timeline/GanttBoard.tsx +258 -0
- package/packages/agentsam-workbench/src/timeline/index.ts +1 -0
- package/packages/agentsam-workbench/tsconfig.json +13 -0
- package/packages/connectors/cloudflare/OAUTH_STORAGE_AUDIT.md +53 -0
- package/packages/connectors/cloudflare/package.json +3 -1
- package/packages/connectors/cloudflare/src/api-client.js +279 -0
- package/packages/connectors/cloudflare/src/capabilities.js +585 -0
- package/packages/connectors/cloudflare/src/credential.js +318 -0
- package/packages/connectors/cloudflare/src/families/brand-protection.js +123 -0
- package/packages/connectors/cloudflare/src/families/keyless.js +114 -0
- package/packages/connectors/cloudflare/src/families/pages.js +151 -0
- package/packages/connectors/cloudflare/src/families/scanner.js +123 -0
- package/packages/connectors/cloudflare/src/families/snippets.js +207 -0
- package/packages/connectors/cloudflare/src/families/tag-gateway.js +46 -0
- package/packages/connectors/cloudflare/src/families/tags.js +124 -0
- package/packages/connectors/cloudflare/src/families/token-validation.js +95 -0
- package/packages/connectors/cloudflare/src/families/workflows.js +156 -0
- package/packages/connectors/cloudflare/src/index.js +102 -265
- package/packages/connectors/cloudflare/src/oauth-persist.js +336 -0
- package/packages/connectors/cloudflare/src/owner.js +42 -12
- package/packages/connectors/cloudflare/src/permission-options.js +1064 -0
- package/packages/connectors/cloudflare/src/routes.js +309 -144
- package/packages/connectors/cloudflare/src/scope-catalog.js +345 -0
- package/packages/connectors/cloudflare/src/vault.js +2 -2
- package/packages/connectors/cloudflare/tests/capabilities.test.mjs +276 -0
- package/packages/connectors/cloudflare/tests/connector.test.mjs +26 -30
- package/packages/connectors/cloudflare/tests/oauth-persist.test.mjs +125 -0
- package/packages/identity/.agentsam/features/oauth-login-portal/providers.json +22 -2
- package/packages/identity/.agentsam/features/oauth-login-portal/resources.json +10 -4
- package/packages/identity/.agentsam/features/oauth-login-portal/routes.json +20 -0
- package/packages/identity/README.md +1 -1
- package/packages/identity/backend/README.md +1 -1
- package/packages/identity/migrations/D1_SCHEMA_MAPPING.md +3 -2
- package/packages/identity/migrations/sqlite/004_identity_oauth_consent_catalog.sql +48 -0
- package/packages/identity/package.json +4 -3
- package/packages/identity/scripts/local-identity-bridge.mjs +184 -0
- package/packages/identity/scripts/preview-auth-portal.mjs +7 -7
- package/packages/identity/src/adapters/cloudflare-d1/index.js +31 -2
- package/packages/identity/src/adapters/sqlite/index.js +4 -1
- package/packages/identity/src/contracts/auth-config.js +28 -8
- package/packages/identity/src/contracts/external-identity.js +1 -1
- package/packages/identity/src/contracts/provider.js +1 -0
- package/packages/identity/src/frontend/auth-portal/README.md +2 -1
- package/packages/identity/src/frontend/auth-portal/pages/login.html +6 -5
- package/packages/identity/src/frontend/auth-portal/pages/reset.html +6 -5
- package/packages/identity/src/frontend/auth-portal/pages/signup.html +6 -5
- package/packages/identity/src/frontend/auth-portal/shared/company-branding.js +1 -1
- package/packages/identity/src/frontend/auth-portal/shared/desktop-identity-bridge.js +207 -0
- package/packages/identity/src/index.js +16 -0
- package/packages/identity/src/migrations/0001_identity_core.sql +19 -2
- package/packages/identity/src/migrations/0003_accounts_ssot.sql +20 -0
- package/packages/identity/src/migrations/README.md +5 -2
- package/packages/identity/src/oauth/README.md +10 -5
- package/packages/identity/src/oauth/consent-view.js +388 -0
- package/packages/identity/src/oauth/credentials.js +31 -11
- package/packages/identity/src/oauth/google-desktop-exchange.js +173 -0
- package/packages/identity/src/providers/cloudflare/oauth.js +3 -4
- package/packages/identity/src/providers/cloudflare/profile.js +49 -14
- package/packages/identity/src/providers/iam/index.js +27 -5
- package/packages/identity/src/server/identity-service.js +31 -2
- package/packages/identity/src/server/worker-router.js +111 -81
- package/packages/identity/tests/auth-config.test.mjs +3 -2
- package/packages/identity/tests/identity-init-scaffold.test.mjs +3 -0
- package/packages/identity/tests/identity-service.test.mjs +16 -0
- package/packages/identity/tests/native-session-worker.test.mjs +64 -0
- package/packages/identity/tests/oauth-consent-view.test.mjs +106 -0
- package/packages/identity/tests/oauth-credentials.test.mjs +17 -4
- package/packages/identity/tests/oauth-presets-accounts-ssot.test.mjs +58 -0
- package/packages/identity/tests/preview-auth-portal.test.mjs +3 -3
- package/packages/runtime-protocol/src/index.js +154 -0
- package/packages/theme-scenes/README.md +164 -0
- package/packages/theme-scenes/package.json +53 -0
- package/packages/theme-scenes/src/blocks/index.js +30 -0
- package/packages/theme-scenes/src/contracts/index.js +286 -0
- package/packages/theme-scenes/src/demos/index.js +65 -0
- package/packages/theme-scenes/src/index.js +75 -0
- package/packages/theme-scenes/src/presets/index.js +263 -0
- package/packages/theme-scenes/src/runtime/compile.js +119 -0
- package/packages/theme-scenes/src/scenes/index.js +146 -0
- package/packages/theme-scenes/src/shell/index.js +47 -0
- package/packages/theme-scenes/src/themes/index.js +129 -0
- package/packages/theme-scenes/src/visuals/index.js +41 -0
- package/packages/theme-scenes/test/theme-scenes.test.mjs +179 -0
- package/packages/work-graph/src/index.js +34 -1
- package/packages/work-graph/src/renderers/gantt-model.js +24 -0
- package/packages/work-graph/test/work-graph.test.mjs +27 -7
- package/protocol/README.md +15 -7
- package/protocol/apps/agentsam.app.v1.schema.json +89 -7
- package/protocol/apps/agentsam.host-install.v1.schema.json +36 -0
- package/protocol/assets/README.md +9 -0
- package/protocol/assets/asset-record.v1.schema.json +64 -0
- package/protocol/runtime/agentsam.runtime.v1.schema.json +75 -0
- package/protocol/scoring/README.md +10 -0
- package/protocol/scoring/scorecard.v1.schema.json +65 -0
- package/protocol/ui/icon-registry.mjs +1 -0
- package/registry/cms-rust-machine-20260928/installable-products.json +31 -0
- package/registry/cms-rust-machine-20260928/manifest.json +22 -0
- package/registry/cms-rust-machine-20260928/migration.sql +237 -0
- package/registry/cms-rust-machine-20260928/receipt.json +21 -0
- package/registry/cms-rust-machine-20260928/receipt.sql +27 -0
- package/scripts/build_rapid_rust_cli.py +83 -0
- package/src/attachments/index.js +6 -0
- package/src/attachments/intake.js +235 -0
- package/src/capabilities/repository-snapshot.js +19 -2
- package/src/cli/command-catalog.js +8 -0
- package/src/cli.js +182 -26
- package/src/commands/account-auth.js +94 -8
- package/src/commands/app.js +307 -3
- package/src/commands/billing.js +127 -0
- package/src/commands/brand.js +74 -60
- package/src/commands/cheat-sheet.js +154 -0
- package/src/commands/cloudflare-login.js +222 -0
- package/src/commands/cloudflare.js +453 -23
- package/src/commands/codebaseindex.js +6 -1
- package/src/commands/compute.js +4 -0
- package/src/commands/connections.js +11 -5
- package/src/commands/credentials.js +116 -0
- package/src/commands/gcloud-auth.js +427 -0
- package/src/commands/google-cloud.js +375 -0
- package/src/commands/identity-init.js +2 -2
- package/src/commands/mcp.js +226 -33
- package/src/commands/ollama.js +3 -2
- package/src/commands/plugins.js +7 -2
- package/src/commands/product.js +36 -0
- package/src/commands/runtime-status.js +28 -9
- package/src/commands/runtime.js +313 -0
- package/src/commands/rust.js +24 -0
- package/src/commands/setup.js +279 -0
- package/src/commands/shell.js +16 -3
- package/src/commands/start-local.js +2 -2
- package/src/commands/terminal.js +171 -0
- package/src/commands/update.js +140 -0
- package/src/commands/whoami.js +329 -65
- package/src/features/resolve.js +1 -0
- package/src/index.js +4 -0
- package/src/indexing/ingest/inventory.js +254 -19
- package/src/indexing/ingest/materials.js +3 -9
- package/src/indexing/ingest/style-evidence.js +181 -0
- package/src/knowledge/source.js +3 -3
- package/src/lib/account-session.js +11 -4
- package/src/lib/app-authority.js +172 -0
- package/src/lib/auth.js +94 -21
- package/src/lib/core-client.js +5 -6
- package/src/lib/credentials-audit.js +451 -0
- package/src/lib/deploy/health.js +24 -6
- package/src/lib/detect-context.js +7 -1
- package/src/lib/google-cloud-connection.js +270 -0
- package/src/lib/google-cloud-inventory.js +385 -0
- package/src/lib/google-desktop-oauth.js +372 -0
- package/src/lib/google-studio-brokered-oauth.js +158 -0
- package/src/lib/identity-scaffold.js +24 -6
- package/src/lib/init-options.js +192 -0
- package/src/lib/local-scaffold.js +48 -16
- package/src/lib/provider-command-remediation.js +308 -0
- package/src/lib/provider-credentials.js +8 -0
- package/src/lib/scaffold/index.js +8 -2
- package/src/lib/scaffold/mcp-server.js +43 -0
- package/src/lib/scaffold/templates/mcp-server/index.js +397 -0
- package/src/lib/scaffold/templates/mcp-server/presets.js +39 -0
- package/src/lib/scaffold/wizards/cms.js +93 -0
- package/src/lib/scaffold/wizards/mcp-server.js +61 -0
- package/src/lib/setup/contract.js +26 -0
- package/src/lib/setup/discover.js +116 -0
- package/src/lib/setup/execute.js +205 -0
- package/src/lib/setup/planner.js +134 -0
- package/src/lib/setup/recipes.js +235 -0
- package/src/lib/setup/runtime-persist.js +197 -0
- package/src/lib/setup/runtime.js +394 -0
- package/src/lib/slash-commands.js +2 -0
- package/src/lib/terminal/machine-identity.js +95 -0
- package/src/lib/terminal-local.js +164 -0
- package/src/lib/terminal-scopes.js +52 -0
- package/src/lib/whoami-capabilities.js +184 -0
- package/src/local-pty/server.js +34 -5
- package/src/mcp/authority.js +58 -108
- package/src/mcp/client-adapters.js +68 -144
- package/src/mcp/client.js +142 -122
- package/src/mcp/cloudflare-bundles.js +225 -0
- package/src/mcp/index.js +12 -0
- package/src/plugins/cloudflare.js +1 -1
- package/src/providers/ollama-chat.js +2 -1
- package/src/sam/types.js +27 -2
- package/src/security/inventory.js +12 -2
- package/src/security/local-vault.js +2 -0
- package/src/security/scan.js +1 -1
- package/test/account-session.test.mjs +3 -3
- package/test/app-authority-context.test.mjs +32 -0
- package/test/cli/codebaseindex-plan-ux.test.mjs +1 -1
- package/test/cli/mcp-client.test.mjs +21 -10
- package/test/cli/runtime-persist.test.mjs +56 -0
- package/test/cli/rust-command.test.mjs +21 -0
- package/test/credentials-audit.test.mjs +113 -0
- package/test/deploy-health-scan.test.mjs +29 -1
- package/test/gcloud-auth.test.mjs +111 -0
- package/test/google-cloud-connection.test.mjs +83 -0
- package/test/google-cloud-inventory.test.mjs +64 -0
- package/test/init-options.test.mjs +35 -0
- package/test/integration/app-command.test.mjs +30 -0
- package/test/integration/cad-project.test.mjs +4 -1
- package/test/integration/cms-app-scaffold.test.mjs +71 -0
- package/test/integration/cms-site-tenancy-contract.test.mjs +3 -2
- package/test/integration/codebaseindex-ingest.test.mjs +48 -0
- package/test/integration/features-resolve.test.mjs +30 -11
- package/test/integration/inspect-path-cli.test.mjs +46 -0
- package/test/integration/inventory-evidence.test.mjs +125 -0
- package/test/integration/runtime-status.integration.test.mjs +2 -1
- package/test/knowledge.test.mjs +35 -1
- package/test/loopback-oauth.test.mjs +53 -0
- package/test/ollama.test.mjs +22 -0
- package/test/security.test.mjs +23 -0
- package/test/setup-planner.test.mjs +74 -0
- package/test/setup-runtime.test.mjs +51 -0
- package/test/terminal/local-pty.mock.test.mjs +3 -1
- package/test/terminal-machine-identity.test.mjs +88 -0
- package/test/whoami-resume.test.mjs +27 -6
- package/packages/agentsam-brand/test/brand-scan.test.mjs +0 -106
- package/packages/work-graph/prototype/README.md +0 -32
- package/packages/work-graph/prototype/data/demo-workgraph.js +0 -47
- package/packages/work-graph/prototype/renderers/timeline-model.js +0 -21
- package/packages/work-graph/prototype/renderers/workgraph-runtime.js +0 -38
- package/packages/work-graph/prototype-gnantt.html +0 -655
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { inspectBrandAsset } from '../inspect.js';
|
|
5
|
+
import { BrandAssetError } from '../errors.js';
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
function tryLoadSharp() {
|
|
10
|
+
try {
|
|
11
|
+
return require('sharp');
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const sharpProcessor = {
|
|
18
|
+
id: 'sharp',
|
|
19
|
+
label: 'Sharp',
|
|
20
|
+
|
|
21
|
+
available() {
|
|
22
|
+
return Boolean(tryLoadSharp());
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
async inspect(input) {
|
|
26
|
+
const meta = inspectBrandAsset(input);
|
|
27
|
+
const sharp = tryLoadSharp();
|
|
28
|
+
if (sharp) {
|
|
29
|
+
try {
|
|
30
|
+
const info = await sharp(input, { failOn: 'none' }).metadata();
|
|
31
|
+
meta.width = info.width ?? meta.width;
|
|
32
|
+
meta.height = info.height ?? meta.height;
|
|
33
|
+
meta.alpha = info.hasAlpha ?? meta.alpha;
|
|
34
|
+
} catch {
|
|
35
|
+
/* keep sniff */
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
meta.processor = 'sharp';
|
|
39
|
+
return meta;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
async resize(input, { width, height, fit = 'contain', outPath }) {
|
|
43
|
+
const sharp = tryLoadSharp();
|
|
44
|
+
if (!sharp) throw new BrandAssetError('processor_unavailable', 'sharp not installed');
|
|
45
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
46
|
+
let pipeline = sharp(input, { failOn: 'none' }).rotate();
|
|
47
|
+
if (width || height) {
|
|
48
|
+
pipeline = pipeline.resize(width || null, height || null, {
|
|
49
|
+
fit,
|
|
50
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
await pipeline.toFile(outPath);
|
|
54
|
+
const inspected = inspectBrandAsset(outPath);
|
|
55
|
+
return {
|
|
56
|
+
path: outPath,
|
|
57
|
+
format: path.extname(outPath).slice(1).toLowerCase(),
|
|
58
|
+
bytes: inspected.bytes,
|
|
59
|
+
width: inspected.width,
|
|
60
|
+
height: inspected.height,
|
|
61
|
+
sha256: inspected.sha256,
|
|
62
|
+
content_type: inspected.content_type,
|
|
63
|
+
processor: 'sharp',
|
|
64
|
+
options: { width, height, fit },
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
async encode(input, {
|
|
69
|
+
format,
|
|
70
|
+
quality,
|
|
71
|
+
lossless,
|
|
72
|
+
cqLevel,
|
|
73
|
+
outPath,
|
|
74
|
+
}) {
|
|
75
|
+
const sharp = tryLoadSharp();
|
|
76
|
+
if (!sharp) throw new BrandAssetError('processor_unavailable', 'sharp not installed');
|
|
77
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
78
|
+
const fmt = String(format || 'webp').toLowerCase();
|
|
79
|
+
let pipeline = sharp(input, { failOn: 'none' }).rotate();
|
|
80
|
+
if (fmt === 'png') pipeline = pipeline.png(lossless ? {} : { compressionLevel: 9 });
|
|
81
|
+
else if (fmt === 'jpeg' || fmt === 'jpg') pipeline = pipeline.jpeg({ quality: quality ?? 90 });
|
|
82
|
+
else if (fmt === 'webp') {
|
|
83
|
+
pipeline = pipeline.webp({
|
|
84
|
+
quality: quality ?? 80,
|
|
85
|
+
lossless: Boolean(lossless),
|
|
86
|
+
});
|
|
87
|
+
} else if (fmt === 'avif') {
|
|
88
|
+
pipeline = pipeline.avif({
|
|
89
|
+
quality: quality ?? (cqLevel != null ? Math.max(1, 100 - cqLevel * 1.5) : 80),
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
throw new BrandAssetError('unsupported_format', `sharp cannot encode ${fmt}`);
|
|
93
|
+
}
|
|
94
|
+
await pipeline.toFile(outPath);
|
|
95
|
+
const inspected = inspectBrandAsset(outPath);
|
|
96
|
+
return {
|
|
97
|
+
path: outPath,
|
|
98
|
+
format: fmt === 'jpg' ? 'jpeg' : fmt,
|
|
99
|
+
bytes: inspected.bytes,
|
|
100
|
+
width: inspected.width,
|
|
101
|
+
height: inspected.height,
|
|
102
|
+
sha256: inspected.sha256,
|
|
103
|
+
content_type: inspected.content_type,
|
|
104
|
+
processor: 'sharp',
|
|
105
|
+
options: { format: fmt, quality, lossless, cqLevel },
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
async optimize(input, options = {}) {
|
|
110
|
+
const format = options.format || 'webp';
|
|
111
|
+
return this.encode(input, { ...options, format });
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squoosh backend — maintained community BINARY only.
|
|
3
|
+
* Never invoke @squoosh/cli via npx/npm.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { spawnSync } from 'node:child_process';
|
|
9
|
+
import { inspectBrandAsset } from '../inspect.js';
|
|
10
|
+
import { BrandAssetError } from '../errors.js';
|
|
11
|
+
|
|
12
|
+
const SQUOOSH_BIN = process.env.AGENTSAM_SQUOOSH_PATH || 'squoosh';
|
|
13
|
+
|
|
14
|
+
export function hasSquooshBinary() {
|
|
15
|
+
const r = spawnSync(SQUOOSH_BIN, ['--help'], { encoding: 'utf8' });
|
|
16
|
+
if (r.error?.code === 'ENOENT') return false;
|
|
17
|
+
return r.status === 0 || (r.stdout || r.stderr || '').includes('Usage: squoosh');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function squooshVersion() {
|
|
21
|
+
const r = spawnSync(SQUOOSH_BIN, ['--version'], { encoding: 'utf8' });
|
|
22
|
+
const text = `${r.stdout || ''}${r.stderr || ''}`.trim();
|
|
23
|
+
return text.split('\n')[0] || 'unknown';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function encoderFlag(format) {
|
|
27
|
+
const f = String(format || '').toLowerCase();
|
|
28
|
+
if (f === 'webp') return '--webp';
|
|
29
|
+
if (f === 'avif') return '--avif';
|
|
30
|
+
if (f === 'jxl') return '--jxl';
|
|
31
|
+
if (f === 'wp2') return '--wp2';
|
|
32
|
+
if (f === 'png' || f === 'oxipng') return '--oxipng';
|
|
33
|
+
if (f === 'jpeg' || f === 'jpg' || f === 'mozjpeg') return '--mozjpeg';
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function encodeConfig(format, options = {}) {
|
|
38
|
+
if (options.auto === true || options.auto === 'auto') return 'auto';
|
|
39
|
+
const f = String(format || '').toLowerCase();
|
|
40
|
+
if (f === 'webp' || f === 'mozjpeg' || f === 'jpeg' || f === 'jpg' || f === 'jxl' || f === 'wp2') {
|
|
41
|
+
return JSON.stringify({ quality: options.quality ?? 80 });
|
|
42
|
+
}
|
|
43
|
+
if (f === 'avif') {
|
|
44
|
+
return JSON.stringify({ cqLevel: options.cqLevel ?? 28 });
|
|
45
|
+
}
|
|
46
|
+
if (f === 'png' || f === 'oxipng') {
|
|
47
|
+
return JSON.stringify({ level: options.level ?? 3 });
|
|
48
|
+
}
|
|
49
|
+
return 'auto';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function expectedExt(format) {
|
|
53
|
+
const f = String(format || '').toLowerCase();
|
|
54
|
+
if (f === 'jpeg' || f === 'jpg' || f === 'mozjpeg') return '.jpg';
|
|
55
|
+
if (f === 'oxipng' || f === 'png') return '.png';
|
|
56
|
+
if (f === 'webp') return '.webp';
|
|
57
|
+
if (f === 'avif') return '.avif';
|
|
58
|
+
if (f === 'jxl') return '.jxl';
|
|
59
|
+
if (f === 'wp2') return '.wp2';
|
|
60
|
+
return `.${f}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function findProduced(dir, ext) {
|
|
64
|
+
if (!fs.existsSync(dir)) return null;
|
|
65
|
+
const walk = (d) => {
|
|
66
|
+
for (const name of fs.readdirSync(d)) {
|
|
67
|
+
const p = path.join(d, name);
|
|
68
|
+
const st = fs.statSync(p);
|
|
69
|
+
if (st.isDirectory()) {
|
|
70
|
+
const hit = walk(p);
|
|
71
|
+
if (hit) return hit;
|
|
72
|
+
} else if (!ext || name.toLowerCase().endsWith(ext)) {
|
|
73
|
+
return p;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
};
|
|
78
|
+
return walk(dir);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const squooshProcessor = {
|
|
82
|
+
id: 'squoosh',
|
|
83
|
+
label: 'Squoosh (maintained binary)',
|
|
84
|
+
|
|
85
|
+
available() {
|
|
86
|
+
return hasSquooshBinary();
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
async inspect(input) {
|
|
90
|
+
const meta = inspectBrandAsset(input);
|
|
91
|
+
meta.processor = 'squoosh';
|
|
92
|
+
meta.processor_version = squooshVersion();
|
|
93
|
+
return meta;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
async resize(input, { width, height, method = 'lanczos3', outPath }) {
|
|
97
|
+
if (!hasSquooshBinary()) {
|
|
98
|
+
throw new BrandAssetError('processor_unavailable', 'squoosh binary not found (brew install squoosh)');
|
|
99
|
+
}
|
|
100
|
+
const outDir = path.dirname(outPath);
|
|
101
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
102
|
+
const tmpBase = path.join(outDir, `.squoosh-resize-${Date.now()}`);
|
|
103
|
+
const cfg = JSON.stringify({
|
|
104
|
+
width: width || undefined,
|
|
105
|
+
height: height || undefined,
|
|
106
|
+
method,
|
|
107
|
+
});
|
|
108
|
+
const r = spawnSync(
|
|
109
|
+
SQUOOSH_BIN,
|
|
110
|
+
['--resize', cfg, '--oxipng', '{"level":2}', '-d', tmpBase, path.resolve(input)],
|
|
111
|
+
{ encoding: 'utf8' },
|
|
112
|
+
);
|
|
113
|
+
if (r.status !== 0) {
|
|
114
|
+
throw new BrandAssetError('derive_failed', r.stderr || r.stdout || 'squoosh resize failed');
|
|
115
|
+
}
|
|
116
|
+
const produced = findProduced(tmpBase, '.png') || findProduced(tmpBase, null);
|
|
117
|
+
if (!produced) {
|
|
118
|
+
throw new BrandAssetError('derive_failed', 'squoosh resize produced no file');
|
|
119
|
+
}
|
|
120
|
+
fs.renameSync(produced, outPath);
|
|
121
|
+
try {
|
|
122
|
+
fs.rmSync(tmpBase, { recursive: true, force: true });
|
|
123
|
+
} catch {
|
|
124
|
+
/* ignore */
|
|
125
|
+
}
|
|
126
|
+
const inspected = inspectBrandAsset(outPath);
|
|
127
|
+
return {
|
|
128
|
+
path: outPath,
|
|
129
|
+
format: 'png',
|
|
130
|
+
bytes: inspected.bytes,
|
|
131
|
+
width: inspected.width,
|
|
132
|
+
height: inspected.height,
|
|
133
|
+
sha256: inspected.sha256,
|
|
134
|
+
content_type: inspected.content_type,
|
|
135
|
+
processor: 'squoosh',
|
|
136
|
+
processor_version: squooshVersion(),
|
|
137
|
+
options: { width, height, method },
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
async encode(input, { format, quality, cqLevel, level, auto, outPath }) {
|
|
142
|
+
if (!hasSquooshBinary()) {
|
|
143
|
+
throw new BrandAssetError('processor_unavailable', 'squoosh binary not found');
|
|
144
|
+
}
|
|
145
|
+
const flag = encoderFlag(format);
|
|
146
|
+
if (!flag) {
|
|
147
|
+
throw new BrandAssetError('unsupported_format', `squoosh cannot encode ${format}`);
|
|
148
|
+
}
|
|
149
|
+
const outDir = path.dirname(outPath);
|
|
150
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
151
|
+
const tmpBase = path.join(outDir, `.squoosh-enc-${Date.now()}`);
|
|
152
|
+
const cfg = encodeConfig(format, { quality, cqLevel, level, auto });
|
|
153
|
+
const r = spawnSync(
|
|
154
|
+
SQUOOSH_BIN,
|
|
155
|
+
[flag, cfg, '-d', tmpBase, path.resolve(input)],
|
|
156
|
+
{ encoding: 'utf8' },
|
|
157
|
+
);
|
|
158
|
+
if (r.status !== 0) {
|
|
159
|
+
throw new BrandAssetError('derive_failed', r.stderr || r.stdout || 'squoosh encode failed');
|
|
160
|
+
}
|
|
161
|
+
const ext = expectedExt(format);
|
|
162
|
+
const produced = findProduced(tmpBase, ext) || findProduced(tmpBase, null);
|
|
163
|
+
if (!produced) {
|
|
164
|
+
throw new BrandAssetError('derive_failed', 'squoosh encode produced no file');
|
|
165
|
+
}
|
|
166
|
+
fs.renameSync(produced, outPath);
|
|
167
|
+
try {
|
|
168
|
+
fs.rmSync(tmpBase, { recursive: true, force: true });
|
|
169
|
+
} catch {
|
|
170
|
+
/* ignore */
|
|
171
|
+
}
|
|
172
|
+
const inspected = inspectBrandAsset(outPath);
|
|
173
|
+
return {
|
|
174
|
+
path: outPath,
|
|
175
|
+
format: String(format).toLowerCase().replace('mozjpeg', 'jpeg').replace('oxipng', 'png'),
|
|
176
|
+
bytes: inspected.bytes,
|
|
177
|
+
width: inspected.width,
|
|
178
|
+
height: inspected.height,
|
|
179
|
+
sha256: inspected.sha256,
|
|
180
|
+
content_type: inspected.content_type,
|
|
181
|
+
processor: 'squoosh',
|
|
182
|
+
processor_version: squooshVersion(),
|
|
183
|
+
options: { format, quality, cqLevel, level, auto },
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
async optimize(input, options = {}) {
|
|
188
|
+
const format = options.format || 'webp';
|
|
189
|
+
return this.encode(input, {
|
|
190
|
+
...options,
|
|
191
|
+
format,
|
|
192
|
+
auto: options.auto !== false ? (options.auto || 'auto') : undefined,
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import { planBrandAssetPromotion, normalizePromotionSpec, createBrandAssetManifest } from './plan.js';
|
|
5
|
+
import { deriveBrandAssets } from './derivatives.js';
|
|
6
|
+
import { inspectBrandAsset, sha256Buffer } from './inspect.js';
|
|
7
|
+
import { receiptDir, writePromotionReceipt, requireReceipt } from './receipts.js';
|
|
8
|
+
import { MemoryStorageAdapter } from '../adapters/memory.js';
|
|
9
|
+
import { assert } from './errors.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Promote = plan + optional derive + write receipt (publish is separate).
|
|
13
|
+
*/
|
|
14
|
+
export async function promoteBrandAssets(input = {}, options = {}) {
|
|
15
|
+
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
16
|
+
const dryRun = options.dryRun !== false && !options.publish && !options.yes
|
|
17
|
+
? true
|
|
18
|
+
: Boolean(options.dryRun);
|
|
19
|
+
|
|
20
|
+
let spec = normalizePromotionSpec(input);
|
|
21
|
+
let derivedArtifacts = [];
|
|
22
|
+
|
|
23
|
+
// Derive if requested and source exists
|
|
24
|
+
const source = (spec.inputs || []).find((i) => i.role === 'source' || i.id === 'source');
|
|
25
|
+
if (source?.path && spec.derivatives?.length && options.derive !== false) {
|
|
26
|
+
const outDir = options.deriveDir
|
|
27
|
+
|| path.join(cwd, '.agentsam', 'brand', 'work', `${spec.brand}-${spec.asset}-${spec.version}`);
|
|
28
|
+
const result = deriveBrandAssets({
|
|
29
|
+
sourcePath: source.path,
|
|
30
|
+
outDir,
|
|
31
|
+
derivatives: spec.derivatives,
|
|
32
|
+
asset: spec.asset,
|
|
33
|
+
});
|
|
34
|
+
derivedArtifacts = result.artifacts.filter((a) => a.status === 'generated');
|
|
35
|
+
// Append generated artifacts as inputs for planning keys
|
|
36
|
+
for (const art of derivedArtifacts) {
|
|
37
|
+
spec.inputs.push({
|
|
38
|
+
id: art.id,
|
|
39
|
+
role: art.role === 'web' ? `web.${art.format}` : 'raster',
|
|
40
|
+
path: art.path,
|
|
41
|
+
filename: path.basename(art.path),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const plan = await planBrandAssetPromotion(spec, {
|
|
47
|
+
deliveryAdapter: options.deliveryAdapter || null,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const dir = receiptDir(cwd, plan);
|
|
51
|
+
const receipt = {
|
|
52
|
+
...plan,
|
|
53
|
+
dry_run: dryRun,
|
|
54
|
+
derived: derivedArtifacts,
|
|
55
|
+
created_at: new Date().toISOString(),
|
|
56
|
+
};
|
|
57
|
+
const receiptPath = writePromotionReceipt(dir, receipt);
|
|
58
|
+
receipt.receipt_path = receiptPath;
|
|
59
|
+
|
|
60
|
+
if (options.publish || options.yes) {
|
|
61
|
+
const published = await publishBrandAssets({
|
|
62
|
+
brand: plan.brand,
|
|
63
|
+
asset: plan.asset,
|
|
64
|
+
version: plan.version,
|
|
65
|
+
cwd,
|
|
66
|
+
dryRun: Boolean(options.dryRun) && !options.forcePublish,
|
|
67
|
+
storageAdapter: options.storageAdapter,
|
|
68
|
+
deliveryAdapter: options.deliveryAdapter,
|
|
69
|
+
registryAdapter: options.registryAdapter,
|
|
70
|
+
force: options.force,
|
|
71
|
+
});
|
|
72
|
+
return { ...receipt, publish: published, published: !published.dry_run };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return receipt;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function publishBrandAssets(options = {}) {
|
|
79
|
+
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
80
|
+
const brand = options.brand;
|
|
81
|
+
const asset = options.asset;
|
|
82
|
+
const version = options.version || 'v1';
|
|
83
|
+
assert(brand && asset, 'brand_and_asset_required', 'brand and asset required');
|
|
84
|
+
|
|
85
|
+
const dir = receiptDir(cwd, { brand, asset, version });
|
|
86
|
+
const receipt = options.receipt || requireReceipt(dir);
|
|
87
|
+
const dryRun = Boolean(options.dryRun);
|
|
88
|
+
const storage = options.storageAdapter || new MemoryStorageAdapter();
|
|
89
|
+
|
|
90
|
+
const uploaded = [];
|
|
91
|
+
const skipped = [];
|
|
92
|
+
const conflicts = [];
|
|
93
|
+
|
|
94
|
+
for (const obj of receipt.objects || []) {
|
|
95
|
+
if (!obj.local_path || !fs.existsSync(obj.local_path)) continue;
|
|
96
|
+
const buf = fs.readFileSync(obj.local_path);
|
|
97
|
+
const localSha = obj.sha256 || sha256Buffer(buf);
|
|
98
|
+
|
|
99
|
+
if (!dryRun && typeof storage.head === 'function') {
|
|
100
|
+
const remote = await storage.head(obj.key);
|
|
101
|
+
if (remote?.exists && remote.buffer) {
|
|
102
|
+
const remoteSha = sha256Buffer(remote.buffer);
|
|
103
|
+
if (remoteSha === localSha) {
|
|
104
|
+
skipped.push({ key: obj.key, reason: 'same_sha256' });
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
conflicts.push({ key: obj.key, local_sha256: localSha, remote_sha256: remoteSha });
|
|
108
|
+
if (!options.force) {
|
|
109
|
+
const err = new Error(`r2_sha_conflict:${obj.key}`);
|
|
110
|
+
err.code = 'sha_conflict';
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!dryRun) {
|
|
117
|
+
await storage.put(obj.key, buf, {
|
|
118
|
+
contentType: obj.content_type,
|
|
119
|
+
sha256: localSha,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
uploaded.push({ key: obj.key, sha256: localSha, content_type: obj.content_type, dry_run: dryRun });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let storageResult = {
|
|
126
|
+
provider: storage.kind || storage.provider || 'unknown',
|
|
127
|
+
status: dryRun ? 'planned' : 'published',
|
|
128
|
+
objects: uploaded,
|
|
129
|
+
skipped,
|
|
130
|
+
conflicts,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
let deliveryResult = null;
|
|
134
|
+
const delivery = options.deliveryAdapter;
|
|
135
|
+
const primary = (receipt.objects || []).find((o) => o.delivery_eligible)
|
|
136
|
+
|| (receipt.objects || []).find((o) => o.role === 'raster.primary')
|
|
137
|
+
|| (receipt.objects || []).find((o) => o.role === 'source' && String(o.content_type || '').startsWith('image/'));
|
|
138
|
+
|
|
139
|
+
if (delivery && primary && typeof delivery.upload === 'function') {
|
|
140
|
+
const supported = typeof delivery.supports === 'function'
|
|
141
|
+
? await delivery.supports({ contentType: primary.content_type, role: primary.role })
|
|
142
|
+
: true;
|
|
143
|
+
if (!supported) {
|
|
144
|
+
deliveryResult = {
|
|
145
|
+
ok: true,
|
|
146
|
+
provider: delivery.provider || 'unknown',
|
|
147
|
+
status: 'skipped',
|
|
148
|
+
reason: 'unsupported_content_type',
|
|
149
|
+
content_type: primary.content_type,
|
|
150
|
+
};
|
|
151
|
+
} else {
|
|
152
|
+
deliveryResult = await delivery.upload({
|
|
153
|
+
filePath: primary.local_path,
|
|
154
|
+
fileName: path.basename(primary.local_path || primary.key || 'image.png'),
|
|
155
|
+
contentType: primary.content_type,
|
|
156
|
+
sourceSha256: primary.sha256,
|
|
157
|
+
sourceStorage: {
|
|
158
|
+
provider: storage.kind || storage.provider || null,
|
|
159
|
+
bucket: storage.bucket || null,
|
|
160
|
+
key: primary.key,
|
|
161
|
+
},
|
|
162
|
+
metadata: { brand, asset, version, role: primary.role },
|
|
163
|
+
dryRun,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const storageStatus = storageResult.status;
|
|
169
|
+
const deliveryStatus = deliveryResult?.status || null;
|
|
170
|
+
let overall = 'success';
|
|
171
|
+
if (conflicts.length) overall = 'failed';
|
|
172
|
+
else if (deliveryStatus === 'failed' && storageStatus === 'published') overall = 'partial_success';
|
|
173
|
+
else if (deliveryStatus === 'failed' && dryRun) overall = 'failed';
|
|
174
|
+
else if (dryRun) overall = 'planned';
|
|
175
|
+
|
|
176
|
+
const manifest = createBrandAssetManifest({
|
|
177
|
+
spec: receipt,
|
|
178
|
+
keys: receipt.keys,
|
|
179
|
+
objects: receipt.objects,
|
|
180
|
+
derivatives: receipt.derivatives,
|
|
181
|
+
storage: {
|
|
182
|
+
provider: storageResult.provider,
|
|
183
|
+
status: storageStatus,
|
|
184
|
+
bucket: storage.bucket || null,
|
|
185
|
+
binding: storage.binding || null,
|
|
186
|
+
},
|
|
187
|
+
delivery: deliveryResult,
|
|
188
|
+
});
|
|
189
|
+
const manifestKey = receipt.keys?.manifest || `brands/${brand}/${asset}/${version}/manifest.json`;
|
|
190
|
+
const manifestBuf = Buffer.from(`${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
|
|
191
|
+
if (!dryRun) {
|
|
192
|
+
await storage.put(manifestKey, manifestBuf, { contentType: 'application/json' });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (options.registryAdapter && typeof options.registryAdapter.register === 'function' && !dryRun) {
|
|
196
|
+
for (const obj of receipt.objects || []) {
|
|
197
|
+
await options.registryAdapter.register({
|
|
198
|
+
brand,
|
|
199
|
+
asset,
|
|
200
|
+
version,
|
|
201
|
+
// Explicit storage vs delivery columns — never collapse
|
|
202
|
+
storage_provider: storageResult.provider,
|
|
203
|
+
storage_bucket: storage.bucket || null,
|
|
204
|
+
storage_key: obj.key,
|
|
205
|
+
delivery_provider: deliveryResult?.status === 'published' ? deliveryResult.provider : null,
|
|
206
|
+
delivery_asset_id: deliveryResult?.status === 'published'
|
|
207
|
+
? (deliveryResult.provider_receipt?.provider_asset_id || deliveryResult.provider_receipt?.image_id)
|
|
208
|
+
: null,
|
|
209
|
+
delivery_variants_json: deliveryResult?.status === 'published'
|
|
210
|
+
? JSON.stringify(deliveryResult.provider_receipt?.variants || [])
|
|
211
|
+
: null,
|
|
212
|
+
content_type: obj.content_type,
|
|
213
|
+
bytes: obj.bytes,
|
|
214
|
+
sha256: obj.sha256,
|
|
215
|
+
width: obj.width,
|
|
216
|
+
height: obj.height,
|
|
217
|
+
role: obj.role,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const result = {
|
|
223
|
+
capability: 'brand.publish',
|
|
224
|
+
ok: overall === 'success' || overall === 'planned' || overall === 'partial_success',
|
|
225
|
+
overall,
|
|
226
|
+
dry_run: dryRun,
|
|
227
|
+
brand,
|
|
228
|
+
asset,
|
|
229
|
+
version,
|
|
230
|
+
storage: storageResult,
|
|
231
|
+
delivery: deliveryResult,
|
|
232
|
+
registry: options.registryAdapter ? { status: dryRun ? 'planned' : 'published' } : { status: 'skipped' },
|
|
233
|
+
uploaded,
|
|
234
|
+
skipped,
|
|
235
|
+
conflicts,
|
|
236
|
+
manifest_key: manifestKey,
|
|
237
|
+
manifest,
|
|
238
|
+
};
|
|
239
|
+
writePromotionReceipt(dir, { ...receipt, publish: result, updated_at: new Date().toISOString() });
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export async function verifyBrandAssets(options = {}) {
|
|
244
|
+
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
245
|
+
const brand = options.brand;
|
|
246
|
+
const asset = options.asset;
|
|
247
|
+
const version = options.version || 'v1';
|
|
248
|
+
assert(brand && asset, 'brand_and_asset_required', 'brand and asset required');
|
|
249
|
+
|
|
250
|
+
const dir = receiptDir(cwd, { brand, asset, version });
|
|
251
|
+
const receipt = options.receipt || requireReceipt(dir);
|
|
252
|
+
const storage = options.storageAdapter || new MemoryStorageAdapter();
|
|
253
|
+
|
|
254
|
+
const checks = [];
|
|
255
|
+
for (const obj of receipt.objects || []) {
|
|
256
|
+
const remote = await storage.head(obj.key);
|
|
257
|
+
if (!remote?.exists) {
|
|
258
|
+
checks.push({ key: obj.key, ok: false, error: 'missing' });
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (remote.buffer && obj.sha256) {
|
|
262
|
+
const remoteSha = sha256Buffer(remote.buffer);
|
|
263
|
+
checks.push({
|
|
264
|
+
key: obj.key,
|
|
265
|
+
ok: remoteSha === obj.sha256,
|
|
266
|
+
local_sha256: obj.sha256,
|
|
267
|
+
remote_sha256: remoteSha,
|
|
268
|
+
error: remoteSha === obj.sha256 ? null : 'sha_mismatch',
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
checks.push({ key: obj.key, ok: true });
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const ok = checks.every((c) => c.ok !== false);
|
|
276
|
+
return {
|
|
277
|
+
capability: 'brand.verify',
|
|
278
|
+
ok,
|
|
279
|
+
brand,
|
|
280
|
+
asset,
|
|
281
|
+
version,
|
|
282
|
+
checks,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// avoid top-level require for crypto in publish loop - already used sha256Buffer
|
|
287
|
+
void os;
|
|
288
|
+
void inspectBrandAsset;
|