@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,718 @@
|
|
|
1
|
+
use anyhow::{bail, Context, Result};
|
|
2
|
+
use clap::{Parser, Subcommand, ValueEnum};
|
|
3
|
+
use serde_json::{json, Value};
|
|
4
|
+
use std::fs;
|
|
5
|
+
use std::path::{Path, PathBuf};
|
|
6
|
+
use std::process::{Command, Stdio};
|
|
7
|
+
use std::time::{SystemTime, UNIX_EPOCH};
|
|
8
|
+
|
|
9
|
+
const WORKER_VERSION: &str = "0.8.7";
|
|
10
|
+
const WORKER_BUILD_VERSION: &str = "0.8.7";
|
|
11
|
+
const WRANGLER_VERSION: &str = "4.141.0";
|
|
12
|
+
const COMPATIBILITY_DATE: &str = "2026-09-27";
|
|
13
|
+
|
|
14
|
+
#[derive(Parser, Debug)]
|
|
15
|
+
#[command(
|
|
16
|
+
name = "agentsam-rapid-rust",
|
|
17
|
+
version,
|
|
18
|
+
about = "Scaffold, teach, verify, build, and explicitly deploy Cloudflare Rust/Wasm Workers"
|
|
19
|
+
)]
|
|
20
|
+
struct Cli {
|
|
21
|
+
#[command(subcommand)]
|
|
22
|
+
command: Commands,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
|
|
26
|
+
enum Template {
|
|
27
|
+
Api,
|
|
28
|
+
SharedCore,
|
|
29
|
+
CryptoAuth,
|
|
30
|
+
DataProcessor,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
impl Template {
|
|
34
|
+
fn key(self) -> &'static str {
|
|
35
|
+
match self {
|
|
36
|
+
Self::Api => "api",
|
|
37
|
+
Self::SharedCore => "shared-core",
|
|
38
|
+
Self::CryptoAuth => "crypto-auth",
|
|
39
|
+
Self::DataProcessor => "data-processor",
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#[derive(Subcommand, Debug)]
|
|
45
|
+
enum Commands {
|
|
46
|
+
/// Scaffold a Rust/Wasm Worker without deploying it.
|
|
47
|
+
New {
|
|
48
|
+
name: String,
|
|
49
|
+
#[arg(short, long, value_enum, default_value_t = Template::Api)]
|
|
50
|
+
template: Template,
|
|
51
|
+
#[arg(long, default_value = ".")]
|
|
52
|
+
out: PathBuf,
|
|
53
|
+
#[arg(long)]
|
|
54
|
+
explain: bool,
|
|
55
|
+
/// Explicitly install local project prerequisites after scaffolding.
|
|
56
|
+
#[arg(long)]
|
|
57
|
+
bootstrap: bool,
|
|
58
|
+
/// Initialize a new Git repository in the generated project.
|
|
59
|
+
#[arg(long)]
|
|
60
|
+
git: bool,
|
|
61
|
+
},
|
|
62
|
+
/// Inspect (and optionally install) the Rust/Wasm toolchain.
|
|
63
|
+
Doctor {
|
|
64
|
+
#[arg(long)]
|
|
65
|
+
bootstrap: bool,
|
|
66
|
+
#[arg(long)]
|
|
67
|
+
json: bool,
|
|
68
|
+
},
|
|
69
|
+
/// List packaged project templates.
|
|
70
|
+
Templates {
|
|
71
|
+
#[arg(long)]
|
|
72
|
+
json: bool,
|
|
73
|
+
},
|
|
74
|
+
/// Explain one template and the Rust/Wasm runtime boundaries.
|
|
75
|
+
Explain {
|
|
76
|
+
#[arg(value_enum, default_value_t = Template::Api)]
|
|
77
|
+
template: Template,
|
|
78
|
+
},
|
|
79
|
+
/// Compile-check a generated Worker for wasm32-unknown-unknown.
|
|
80
|
+
Check {
|
|
81
|
+
#[arg(long, default_value = ".")]
|
|
82
|
+
cwd: PathBuf,
|
|
83
|
+
#[arg(long)]
|
|
84
|
+
json: bool,
|
|
85
|
+
},
|
|
86
|
+
/// Build a generated Worker locally with worker-build.
|
|
87
|
+
Build {
|
|
88
|
+
#[arg(long, default_value = ".")]
|
|
89
|
+
cwd: PathBuf,
|
|
90
|
+
#[arg(long)]
|
|
91
|
+
json: bool,
|
|
92
|
+
},
|
|
93
|
+
/// Run local Wrangler development. No remote deploy.
|
|
94
|
+
Dev {
|
|
95
|
+
#[arg(long, default_value = ".")]
|
|
96
|
+
cwd: PathBuf,
|
|
97
|
+
},
|
|
98
|
+
/// Deploy only when explicitly confirmed. --dry-run never publishes.
|
|
99
|
+
Deploy {
|
|
100
|
+
#[arg(long, default_value = ".")]
|
|
101
|
+
cwd: PathBuf,
|
|
102
|
+
#[arg(long)]
|
|
103
|
+
dry_run: bool,
|
|
104
|
+
#[arg(long)]
|
|
105
|
+
yes: bool,
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
fn main() -> Result<()> {
|
|
110
|
+
let cli = Cli::parse();
|
|
111
|
+
match cli.command {
|
|
112
|
+
Commands::New {
|
|
113
|
+
name,
|
|
114
|
+
template,
|
|
115
|
+
out,
|
|
116
|
+
explain,
|
|
117
|
+
bootstrap,
|
|
118
|
+
git,
|
|
119
|
+
} => create_project(&name, template, &out, explain, bootstrap, git),
|
|
120
|
+
Commands::Doctor { bootstrap, json } => doctor(bootstrap, json),
|
|
121
|
+
Commands::Templates { json } => list_templates(json),
|
|
122
|
+
Commands::Explain { template } => {
|
|
123
|
+
print_explanation(template);
|
|
124
|
+
Ok(())
|
|
125
|
+
}
|
|
126
|
+
Commands::Check { cwd, json } => check_project(&cwd, json),
|
|
127
|
+
Commands::Build { cwd, json } => build_project(&cwd, json),
|
|
128
|
+
Commands::Dev { cwd } => run_wrangler(&cwd, &["dev"]),
|
|
129
|
+
Commands::Deploy { cwd, dry_run, yes } => deploy_project(&cwd, dry_run, yes),
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
fn validate_name(name: &str) -> Result<()> {
|
|
134
|
+
if name.is_empty() || name.len() > 80 {
|
|
135
|
+
bail!("project name must be 1..80 characters");
|
|
136
|
+
}
|
|
137
|
+
let valid = name
|
|
138
|
+
.bytes()
|
|
139
|
+
.all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-');
|
|
140
|
+
if !valid || name.starts_with('-') || name.ends_with('-') || name.contains("--") {
|
|
141
|
+
bail!("project name must use lowercase letters, digits, and single hyphens");
|
|
142
|
+
}
|
|
143
|
+
Ok(())
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
fn render(source: &str, name: &str) -> String {
|
|
147
|
+
source
|
|
148
|
+
.replace("{{PROJECT_NAME}}", name)
|
|
149
|
+
.replace("{{CRATE_NAME}}", &name.replace('-', "_"))
|
|
150
|
+
.replace("{{WORKER_VERSION}}", WORKER_VERSION)
|
|
151
|
+
.replace("{{WRANGLER_VERSION}}", WRANGLER_VERSION)
|
|
152
|
+
.replace("{{COMPATIBILITY_DATE}}", COMPATIBILITY_DATE)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
fn write_file(root: &Path, rel: &str, body: &str) -> Result<()> {
|
|
156
|
+
let path = root.join(rel);
|
|
157
|
+
if let Some(parent) = path.parent() {
|
|
158
|
+
fs::create_dir_all(parent).with_context(|| format!("create {}", parent.display()))?;
|
|
159
|
+
}
|
|
160
|
+
fs::write(&path, body).with_context(|| format!("write {}", path.display()))?;
|
|
161
|
+
Ok(())
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fn create_project(
|
|
165
|
+
name: &str,
|
|
166
|
+
template: Template,
|
|
167
|
+
out: &Path,
|
|
168
|
+
explain: bool,
|
|
169
|
+
bootstrap: bool,
|
|
170
|
+
init_git: bool,
|
|
171
|
+
) -> Result<()> {
|
|
172
|
+
validate_name(name)?;
|
|
173
|
+
let root = out.join(name);
|
|
174
|
+
if root.exists() {
|
|
175
|
+
bail!("refusing to overwrite existing path: {}", root.display());
|
|
176
|
+
}
|
|
177
|
+
fs::create_dir_all(&root)?;
|
|
178
|
+
|
|
179
|
+
let common_gitignore =
|
|
180
|
+
"/target\n/build\n/worker/target\n/worker/build\n/node_modules\n/.wrangler\n.DS_Store\n";
|
|
181
|
+
write_file(&root, ".gitignore", common_gitignore)?;
|
|
182
|
+
|
|
183
|
+
match template {
|
|
184
|
+
Template::Api => write_single_crate(
|
|
185
|
+
&root,
|
|
186
|
+
name,
|
|
187
|
+
include_str!("../templates/api/Cargo.toml.tmpl"),
|
|
188
|
+
include_str!("../templates/api/src/lib.rs.tmpl"),
|
|
189
|
+
)?,
|
|
190
|
+
Template::CryptoAuth => write_single_crate(
|
|
191
|
+
&root,
|
|
192
|
+
name,
|
|
193
|
+
include_str!("../templates/crypto-auth/Cargo.toml.tmpl"),
|
|
194
|
+
include_str!("../templates/crypto-auth/src/lib.rs.tmpl"),
|
|
195
|
+
)?,
|
|
196
|
+
Template::DataProcessor => write_single_crate(
|
|
197
|
+
&root,
|
|
198
|
+
name,
|
|
199
|
+
include_str!("../templates/data-processor/Cargo.toml.tmpl"),
|
|
200
|
+
include_str!("../templates/data-processor/src/lib.rs.tmpl"),
|
|
201
|
+
)?,
|
|
202
|
+
Template::SharedCore => write_shared_core(&root, name)?,
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
write_file(
|
|
206
|
+
&root,
|
|
207
|
+
"package.json",
|
|
208
|
+
&render(include_str!("../templates/common/package.json.tmpl"), name),
|
|
209
|
+
)?;
|
|
210
|
+
write_file(
|
|
211
|
+
&root,
|
|
212
|
+
"README.md",
|
|
213
|
+
&render(include_str!("../templates/common/README.md.tmpl"), name)
|
|
214
|
+
.replace("{{TEMPLATE}}", template.key()),
|
|
215
|
+
)?;
|
|
216
|
+
|
|
217
|
+
let worker_dir = if template == Template::SharedCore {
|
|
218
|
+
"worker"
|
|
219
|
+
} else {
|
|
220
|
+
"."
|
|
221
|
+
};
|
|
222
|
+
let metadata = json!({
|
|
223
|
+
"schema": "agentsam.rapid-rust.v1",
|
|
224
|
+
"template": template.key(),
|
|
225
|
+
"project_name": name,
|
|
226
|
+
"worker_dir": worker_dir,
|
|
227
|
+
"worker_version": WORKER_VERSION,
|
|
228
|
+
"worker_build_version": WORKER_BUILD_VERSION,
|
|
229
|
+
"wrangler_version": WRANGLER_VERSION,
|
|
230
|
+
"compatibility_date": COMPATIBILITY_DATE,
|
|
231
|
+
"deploy_is_explicit": true
|
|
232
|
+
});
|
|
233
|
+
write_file(
|
|
234
|
+
&root,
|
|
235
|
+
".agentsam/rapid-rust.json",
|
|
236
|
+
&(serde_json::to_string_pretty(&metadata)? + "\n"),
|
|
237
|
+
)?;
|
|
238
|
+
|
|
239
|
+
if init_git {
|
|
240
|
+
run_status(
|
|
241
|
+
Command::new("git").arg("init").current_dir(&root),
|
|
242
|
+
"git init",
|
|
243
|
+
)?;
|
|
244
|
+
}
|
|
245
|
+
if bootstrap {
|
|
246
|
+
bootstrap_tools()?;
|
|
247
|
+
run_status(
|
|
248
|
+
Command::new("npm").arg("install").current_dir(&root),
|
|
249
|
+
"npm install",
|
|
250
|
+
)?;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
println!("✓ scaffolded {} [{}]", root.display(), template.key());
|
|
254
|
+
println!(" next: cd {}", root.display());
|
|
255
|
+
println!(" agentsam rust check");
|
|
256
|
+
println!(" agentsam rust dev");
|
|
257
|
+
println!(" deploy stays explicit: agentsam rust deploy --dry-run");
|
|
258
|
+
if explain {
|
|
259
|
+
print_explanation(template);
|
|
260
|
+
}
|
|
261
|
+
Ok(())
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fn write_single_crate(root: &Path, name: &str, cargo: &str, lib: &str) -> Result<()> {
|
|
265
|
+
write_file(root, "Cargo.toml", &render(cargo, name))?;
|
|
266
|
+
write_file(root, "src/lib.rs", &render(lib, name))?;
|
|
267
|
+
write_file(
|
|
268
|
+
root,
|
|
269
|
+
"wrangler.toml",
|
|
270
|
+
&render(include_str!("../templates/common/wrangler.toml.tmpl"), name),
|
|
271
|
+
)?;
|
|
272
|
+
Ok(())
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
fn write_shared_core(root: &Path, name: &str) -> Result<()> {
|
|
276
|
+
write_file(
|
|
277
|
+
root,
|
|
278
|
+
"Cargo.toml",
|
|
279
|
+
&render(
|
|
280
|
+
include_str!("../templates/shared-core/Cargo.toml.tmpl"),
|
|
281
|
+
name,
|
|
282
|
+
),
|
|
283
|
+
)?;
|
|
284
|
+
write_file(
|
|
285
|
+
root,
|
|
286
|
+
"core/Cargo.toml",
|
|
287
|
+
&render(
|
|
288
|
+
include_str!("../templates/shared-core/core/Cargo.toml.tmpl"),
|
|
289
|
+
name,
|
|
290
|
+
),
|
|
291
|
+
)?;
|
|
292
|
+
write_file(
|
|
293
|
+
root,
|
|
294
|
+
"core/src/lib.rs",
|
|
295
|
+
&render(
|
|
296
|
+
include_str!("../templates/shared-core/core/src/lib.rs.tmpl"),
|
|
297
|
+
name,
|
|
298
|
+
),
|
|
299
|
+
)?;
|
|
300
|
+
write_file(
|
|
301
|
+
root,
|
|
302
|
+
"worker/Cargo.toml",
|
|
303
|
+
&render(
|
|
304
|
+
include_str!("../templates/shared-core/worker/Cargo.toml.tmpl"),
|
|
305
|
+
name,
|
|
306
|
+
),
|
|
307
|
+
)?;
|
|
308
|
+
write_file(
|
|
309
|
+
root,
|
|
310
|
+
"worker/src/lib.rs",
|
|
311
|
+
&render(
|
|
312
|
+
include_str!("../templates/shared-core/worker/src/lib.rs.tmpl"),
|
|
313
|
+
name,
|
|
314
|
+
),
|
|
315
|
+
)?;
|
|
316
|
+
write_file(
|
|
317
|
+
root,
|
|
318
|
+
"wrangler.toml",
|
|
319
|
+
&render(
|
|
320
|
+
include_str!("../templates/shared-core/wrangler.toml.tmpl"),
|
|
321
|
+
name,
|
|
322
|
+
),
|
|
323
|
+
)?;
|
|
324
|
+
Ok(())
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
fn command_output(program: &str, args: &[&str]) -> Value {
|
|
328
|
+
match Command::new(program).args(args).output() {
|
|
329
|
+
Ok(out) => json!({
|
|
330
|
+
"ok": out.status.success(),
|
|
331
|
+
"version": String::from_utf8_lossy(&out.stdout).trim(),
|
|
332
|
+
"stderr": String::from_utf8_lossy(&out.stderr).trim()
|
|
333
|
+
}),
|
|
334
|
+
Err(error) => json!({"ok": false, "error": error.to_string()}),
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
fn wasm_target_installed() -> bool {
|
|
339
|
+
Command::new("rustup")
|
|
340
|
+
.args(["target", "list", "--installed"])
|
|
341
|
+
.output()
|
|
342
|
+
.map(|out| {
|
|
343
|
+
String::from_utf8_lossy(&out.stdout)
|
|
344
|
+
.lines()
|
|
345
|
+
.any(|x| x.trim() == "wasm32-unknown-unknown")
|
|
346
|
+
})
|
|
347
|
+
.unwrap_or(false)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
fn doctor(bootstrap: bool, as_json: bool) -> Result<()> {
|
|
351
|
+
if bootstrap {
|
|
352
|
+
bootstrap_tools()?;
|
|
353
|
+
}
|
|
354
|
+
let rustc = command_output("rustc", &["--version"]);
|
|
355
|
+
let cargo = command_output("cargo", &["--version"]);
|
|
356
|
+
let rustup = command_output("rustup", &["--version"]);
|
|
357
|
+
let node = command_output("node", &["--version"]);
|
|
358
|
+
let npm = command_output("npm", &["--version"]);
|
|
359
|
+
let wrangler = command_output("npx", &["wrangler", "--version"]);
|
|
360
|
+
let worker_build = command_output("worker-build", &["--version"]);
|
|
361
|
+
let wasm_target = wasm_target_installed();
|
|
362
|
+
let base_ok = [&rustc, &cargo, &rustup, &node, &npm, &wrangler]
|
|
363
|
+
.iter()
|
|
364
|
+
.all(|value| value["ok"].as_bool().unwrap_or(false));
|
|
365
|
+
let build_ready = base_ok && wasm_target && worker_build["ok"].as_bool().unwrap_or(false);
|
|
366
|
+
let payload = json!({
|
|
367
|
+
"ok": base_ok,
|
|
368
|
+
"build_ready": build_ready,
|
|
369
|
+
"rustc": rustc,
|
|
370
|
+
"cargo": cargo,
|
|
371
|
+
"rustup": rustup,
|
|
372
|
+
"node": node,
|
|
373
|
+
"npm": npm,
|
|
374
|
+
"wrangler": wrangler,
|
|
375
|
+
"worker_build": worker_build,
|
|
376
|
+
"wasm32_unknown_unknown": wasm_target,
|
|
377
|
+
"expected": {
|
|
378
|
+
"worker": WORKER_VERSION,
|
|
379
|
+
"worker_build": WORKER_BUILD_VERSION,
|
|
380
|
+
"wrangler": WRANGLER_VERSION
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
if as_json {
|
|
384
|
+
println!("{}", serde_json::to_string_pretty(&payload)?);
|
|
385
|
+
} else {
|
|
386
|
+
println!("AgentSam Rapid Rust doctor");
|
|
387
|
+
println!(" rustc {}", display_check(&payload["rustc"]));
|
|
388
|
+
println!(" cargo {}", display_check(&payload["cargo"]));
|
|
389
|
+
println!(" rustup {}", display_check(&payload["rustup"]));
|
|
390
|
+
println!(" node {}", display_check(&payload["node"]));
|
|
391
|
+
println!(" npm {}", display_check(&payload["npm"]));
|
|
392
|
+
println!(" wrangler {}", display_check(&payload["wrangler"]));
|
|
393
|
+
println!(" worker-build {}", display_check(&payload["worker_build"]));
|
|
394
|
+
println!(
|
|
395
|
+
" wasm target {}",
|
|
396
|
+
if wasm_target {
|
|
397
|
+
"✓ wasm32-unknown-unknown"
|
|
398
|
+
} else {
|
|
399
|
+
"✗ missing"
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
println!(
|
|
403
|
+
" build ready {}",
|
|
404
|
+
if build_ready { "✓ yes" } else { "✗ no" }
|
|
405
|
+
);
|
|
406
|
+
if !build_ready {
|
|
407
|
+
println!("\n bootstrap explicitly with: agentsam rust doctor --bootstrap");
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
Ok(())
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
fn display_check(value: &Value) -> String {
|
|
414
|
+
if value["ok"].as_bool().unwrap_or(false) {
|
|
415
|
+
let version = value["version"].as_str().unwrap_or("");
|
|
416
|
+
format!("✓ {}", version.lines().next().unwrap_or(version))
|
|
417
|
+
} else {
|
|
418
|
+
format!(
|
|
419
|
+
"✗ {}",
|
|
420
|
+
value["error"]
|
|
421
|
+
.as_str()
|
|
422
|
+
.or(value["stderr"].as_str())
|
|
423
|
+
.unwrap_or("missing")
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
fn bootstrap_tools() -> Result<()> {
|
|
429
|
+
if !wasm_target_installed() {
|
|
430
|
+
run_status(
|
|
431
|
+
Command::new("rustup").args(["target", "add", "wasm32-unknown-unknown"]),
|
|
432
|
+
"rustup target add wasm32-unknown-unknown",
|
|
433
|
+
)?;
|
|
434
|
+
}
|
|
435
|
+
let worker_ok = Command::new("worker-build")
|
|
436
|
+
.arg("--version")
|
|
437
|
+
.stdout(Stdio::null())
|
|
438
|
+
.stderr(Stdio::null())
|
|
439
|
+
.status()
|
|
440
|
+
.map(|x| x.success())
|
|
441
|
+
.unwrap_or(false);
|
|
442
|
+
if !worker_ok {
|
|
443
|
+
run_status(
|
|
444
|
+
Command::new("cargo").args([
|
|
445
|
+
"install",
|
|
446
|
+
"worker-build",
|
|
447
|
+
"--version",
|
|
448
|
+
WORKER_BUILD_VERSION,
|
|
449
|
+
"--locked",
|
|
450
|
+
]),
|
|
451
|
+
"cargo install worker-build",
|
|
452
|
+
)?;
|
|
453
|
+
}
|
|
454
|
+
Ok(())
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
fn project_root(input: &Path) -> Result<PathBuf> {
|
|
458
|
+
let root = fs::canonicalize(input).with_context(|| format!("resolve {}", input.display()))?;
|
|
459
|
+
if !root.join(".agentsam/rapid-rust.json").is_file() {
|
|
460
|
+
bail!(
|
|
461
|
+
"{} is not an AgentSam Rapid Rust project (.agentsam/rapid-rust.json missing)",
|
|
462
|
+
root.display()
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
Ok(root)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
fn metadata(root: &Path) -> Result<Value> {
|
|
469
|
+
let raw = fs::read_to_string(root.join(".agentsam/rapid-rust.json"))?;
|
|
470
|
+
Ok(serde_json::from_str(&raw)?)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
fn worker_dir(root: &Path) -> Result<PathBuf> {
|
|
474
|
+
let meta = metadata(root)?;
|
|
475
|
+
let rel = meta["worker_dir"].as_str().unwrap_or(".");
|
|
476
|
+
Ok(root.join(rel))
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
fn check_project(cwd: &Path, as_json: bool) -> Result<()> {
|
|
480
|
+
let root = project_root(cwd)?;
|
|
481
|
+
if !wasm_target_installed() {
|
|
482
|
+
bail!("wasm32-unknown-unknown is missing; run agentsam rust doctor --bootstrap");
|
|
483
|
+
}
|
|
484
|
+
let started = unix_ms();
|
|
485
|
+
let status = Command::new("cargo")
|
|
486
|
+
.args(["check", "--target", "wasm32-unknown-unknown"])
|
|
487
|
+
.current_dir(&root)
|
|
488
|
+
.status()?;
|
|
489
|
+
let receipt = write_receipt(
|
|
490
|
+
&root,
|
|
491
|
+
"check",
|
|
492
|
+
started,
|
|
493
|
+
status.code().unwrap_or(1),
|
|
494
|
+
json!({}),
|
|
495
|
+
)?;
|
|
496
|
+
if as_json {
|
|
497
|
+
println!("{}", serde_json::to_string_pretty(&receipt)?);
|
|
498
|
+
}
|
|
499
|
+
if !status.success() {
|
|
500
|
+
bail!("cargo check failed");
|
|
501
|
+
}
|
|
502
|
+
Ok(())
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
fn build_project(cwd: &Path, as_json: bool) -> Result<()> {
|
|
506
|
+
let root = project_root(cwd)?;
|
|
507
|
+
if !wasm_target_installed() {
|
|
508
|
+
bail!("wasm32-unknown-unknown is missing; run agentsam rust doctor --bootstrap");
|
|
509
|
+
}
|
|
510
|
+
if Command::new("worker-build")
|
|
511
|
+
.arg("--version")
|
|
512
|
+
.stdout(Stdio::null())
|
|
513
|
+
.stderr(Stdio::null())
|
|
514
|
+
.status()
|
|
515
|
+
.map(|x| x.success())
|
|
516
|
+
.unwrap_or(false)
|
|
517
|
+
== false
|
|
518
|
+
{
|
|
519
|
+
bail!("worker-build is missing; run agentsam rust doctor --bootstrap");
|
|
520
|
+
}
|
|
521
|
+
let work = worker_dir(&root)?;
|
|
522
|
+
let started = unix_ms();
|
|
523
|
+
let status = Command::new("worker-build")
|
|
524
|
+
.arg("--release")
|
|
525
|
+
.current_dir(&work)
|
|
526
|
+
.status()?;
|
|
527
|
+
let artifacts = artifact_summary(&work);
|
|
528
|
+
let receipt = write_receipt(
|
|
529
|
+
&root,
|
|
530
|
+
"build",
|
|
531
|
+
started,
|
|
532
|
+
status.code().unwrap_or(1),
|
|
533
|
+
artifacts,
|
|
534
|
+
)?;
|
|
535
|
+
if as_json {
|
|
536
|
+
println!("{}", serde_json::to_string_pretty(&receipt)?);
|
|
537
|
+
} else {
|
|
538
|
+
println!(
|
|
539
|
+
"build receipt: {}",
|
|
540
|
+
receipt["receipt_path"].as_str().unwrap_or("")
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
if !status.success() {
|
|
544
|
+
bail!("worker-build failed");
|
|
545
|
+
}
|
|
546
|
+
Ok(())
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
fn artifact_summary(work: &Path) -> Value {
|
|
550
|
+
let build = work.join("build");
|
|
551
|
+
let mut rows = Vec::new();
|
|
552
|
+
if let Ok(entries) = fs::read_dir(&build) {
|
|
553
|
+
for entry in entries.flatten() {
|
|
554
|
+
let path = entry.path();
|
|
555
|
+
if path.is_file() {
|
|
556
|
+
let bytes = path.metadata().map(|m| m.len()).unwrap_or(0);
|
|
557
|
+
rows.push(json!({"path": path.display().to_string(), "bytes": bytes}));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
json!({"artifacts": rows})
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
fn write_receipt(
|
|
565
|
+
root: &Path,
|
|
566
|
+
action: &str,
|
|
567
|
+
started_ms: u128,
|
|
568
|
+
exit_code: i32,
|
|
569
|
+
extra: Value,
|
|
570
|
+
) -> Result<Value> {
|
|
571
|
+
let dir = root.join(".agentsam/rapid-rust/receipts");
|
|
572
|
+
fs::create_dir_all(&dir)?;
|
|
573
|
+
let finished_ms = unix_ms();
|
|
574
|
+
let path = dir.join(format!("{}-{}.json", action, finished_ms));
|
|
575
|
+
let mut receipt = json!({
|
|
576
|
+
"schema": "agentsam.rapid-rust.receipt.v1",
|
|
577
|
+
"action": action,
|
|
578
|
+
"started_ms": started_ms,
|
|
579
|
+
"finished_ms": finished_ms,
|
|
580
|
+
"exit_code": exit_code,
|
|
581
|
+
"ok": exit_code == 0,
|
|
582
|
+
"project": root.display().to_string(),
|
|
583
|
+
"remote_mutation": false
|
|
584
|
+
});
|
|
585
|
+
if let (Some(dst), Some(src)) = (receipt.as_object_mut(), extra.as_object()) {
|
|
586
|
+
for (key, value) in src {
|
|
587
|
+
dst.insert(key.clone(), value.clone());
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
receipt["receipt_path"] = json!(path.display().to_string());
|
|
591
|
+
fs::write(&path, serde_json::to_string_pretty(&receipt)? + "\n")?;
|
|
592
|
+
Ok(receipt)
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
fn run_wrangler(cwd: &Path, args: &[&str]) -> Result<()> {
|
|
596
|
+
let root = project_root(cwd)?;
|
|
597
|
+
let status = Command::new("npx")
|
|
598
|
+
.args(["wrangler"])
|
|
599
|
+
.args(args)
|
|
600
|
+
.current_dir(root)
|
|
601
|
+
.status()?;
|
|
602
|
+
if !status.success() {
|
|
603
|
+
bail!("wrangler {} failed", args.join(" "));
|
|
604
|
+
}
|
|
605
|
+
Ok(())
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
fn deploy_project(cwd: &Path, dry_run: bool, yes: bool) -> Result<()> {
|
|
609
|
+
if !dry_run && !yes {
|
|
610
|
+
bail!("live deploy requires --yes; inspect first with: agentsam rust deploy --dry-run");
|
|
611
|
+
}
|
|
612
|
+
if dry_run {
|
|
613
|
+
run_wrangler(cwd, &["deploy", "--dry-run"])
|
|
614
|
+
} else {
|
|
615
|
+
println!("explicit live deploy approved (--yes)");
|
|
616
|
+
run_wrangler(cwd, &["deploy"])
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
fn run_status(command: &mut Command, label: &str) -> Result<()> {
|
|
621
|
+
println!("→ {}", label);
|
|
622
|
+
let status = command.status().with_context(|| label.to_string())?;
|
|
623
|
+
if !status.success() {
|
|
624
|
+
bail!("{} failed with {}", label, status);
|
|
625
|
+
}
|
|
626
|
+
Ok(())
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
fn list_templates(as_json: bool) -> Result<()> {
|
|
630
|
+
let rows = json!([
|
|
631
|
+
{"id":"api","purpose":"small HTTP/JSON Worker"},
|
|
632
|
+
{"id":"shared-core","purpose":"pure Rust core shared with Tauri; Swift needs an FFI layer"},
|
|
633
|
+
{"id":"crypto-auth","purpose":"HMAC-SHA256 webhook/request verification"},
|
|
634
|
+
{"id":"data-processor","purpose":"typed JSON batch transformations"}
|
|
635
|
+
]);
|
|
636
|
+
if as_json {
|
|
637
|
+
println!("{}", serde_json::to_string_pretty(&rows)?);
|
|
638
|
+
} else {
|
|
639
|
+
println!("api small HTTP/JSON Worker");
|
|
640
|
+
println!("shared-core reusable pure Rust crate + Worker adapter");
|
|
641
|
+
println!("crypto-auth constant-time HMAC-SHA256 verification");
|
|
642
|
+
println!("data-processor typed JSON batch transformations");
|
|
643
|
+
}
|
|
644
|
+
Ok(())
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
fn print_explanation(template: Template) {
|
|
648
|
+
println!("\nAgentSam Rapid Rust · {}", template.key());
|
|
649
|
+
println!(" target: wasm32-unknown-unknown via workers-rs/worker-build");
|
|
650
|
+
println!(" local: cargo check + worker-build + wrangler dev");
|
|
651
|
+
println!(" cloud: deploy is never implicit; use deploy --dry-run, then deploy --yes");
|
|
652
|
+
println!(" runtime boundary: Workers Rust is Wasm; normal Tokio/async-std runtimes are not available");
|
|
653
|
+
println!(" size: release uses LTO + debuginfo stripping + one codegen unit; full symbol stripping is avoided for wasm-bindgen externref compatibility");
|
|
654
|
+
match template {
|
|
655
|
+
Template::Api => println!(" api: use Rust when shared logic, binary parsing, or predictable memory justifies it; basic routing may be simpler in TypeScript"),
|
|
656
|
+
Template::SharedCore => println!(" shared-core: core/ has no Cloudflare dependency and can be reused directly by Tauri; Swift integration still requires an explicit C/UniFFI-style bridge"),
|
|
657
|
+
Template::CryptoAuth => println!(" crypto-auth: verifies HMAC bytes with constant-time MAC verification; secrets come from Worker bindings, never source"),
|
|
658
|
+
Template::DataProcessor => println!(" data-processor: demonstrates typed bounded JSON transforms; large/long-running jobs may belong in a Container instead of an isolate"),
|
|
659
|
+
}
|
|
660
|
+
println!();
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
fn unix_ms() -> u128 {
|
|
664
|
+
SystemTime::now()
|
|
665
|
+
.duration_since(UNIX_EPOCH)
|
|
666
|
+
.unwrap_or_default()
|
|
667
|
+
.as_millis()
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
#[cfg(test)]
|
|
671
|
+
mod tests {
|
|
672
|
+
use super::*;
|
|
673
|
+
use tempfile::tempdir;
|
|
674
|
+
|
|
675
|
+
#[test]
|
|
676
|
+
fn project_name_validation_is_strict() {
|
|
677
|
+
assert!(validate_name("my-edge-worker").is_ok());
|
|
678
|
+
assert!(validate_name("Bad Name").is_err());
|
|
679
|
+
assert!(validate_name("../oops").is_err());
|
|
680
|
+
assert!(validate_name("two--dashes").is_err());
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
#[test]
|
|
684
|
+
fn scaffolds_api_without_side_effects() {
|
|
685
|
+
let dir = tempdir().unwrap();
|
|
686
|
+
create_project(
|
|
687
|
+
"fixture-worker",
|
|
688
|
+
Template::Api,
|
|
689
|
+
dir.path(),
|
|
690
|
+
false,
|
|
691
|
+
false,
|
|
692
|
+
false,
|
|
693
|
+
)
|
|
694
|
+
.unwrap();
|
|
695
|
+
let root = dir.path().join("fixture-worker");
|
|
696
|
+
assert!(root.join("Cargo.toml").is_file());
|
|
697
|
+
assert!(root.join("src/lib.rs").is_file());
|
|
698
|
+
assert!(root.join("wrangler.toml").is_file());
|
|
699
|
+
assert!(root.join(".agentsam/rapid-rust.json").is_file());
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
#[test]
|
|
703
|
+
fn shared_core_is_a_real_workspace() {
|
|
704
|
+
let dir = tempdir().unwrap();
|
|
705
|
+
create_project(
|
|
706
|
+
"shared-fixture",
|
|
707
|
+
Template::SharedCore,
|
|
708
|
+
dir.path(),
|
|
709
|
+
false,
|
|
710
|
+
false,
|
|
711
|
+
false,
|
|
712
|
+
)
|
|
713
|
+
.unwrap();
|
|
714
|
+
let root = dir.path().join("shared-fixture");
|
|
715
|
+
assert!(root.join("core/src/lib.rs").is_file());
|
|
716
|
+
assert!(root.join("worker/src/lib.rs").is_file());
|
|
717
|
+
}
|
|
718
|
+
}
|