@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,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform persistence for agentsamd (LaunchAgent / Windows Scheduled Task).
|
|
3
|
+
* Pure builders are exported for tests; side-effect helpers call OS tools.
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { execFile } from 'node:child_process';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import { runtimeStateDir, ensureRuntimeStateDir } from './runtime.js';
|
|
10
|
+
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
12
|
+
|
|
13
|
+
export const DARWIN_LAUNCH_LABEL = 'com.inneranimalmedia.agentsamd';
|
|
14
|
+
export const WINDOWS_TASK_NAME = 'InnerAnimalMedia\\agentsamd';
|
|
15
|
+
export const WINDOWS_TASK_FOLDER = 'InnerAnimalMedia';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {{ binary: string, listen: string, stdoutLog: string, stderrLog: string, label?: string }} opts
|
|
19
|
+
*/
|
|
20
|
+
export function buildLaunchAgentPlist(opts) {
|
|
21
|
+
const label = opts.label || DARWIN_LAUNCH_LABEL;
|
|
22
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
23
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
24
|
+
<plist version="1.0">
|
|
25
|
+
<dict>
|
|
26
|
+
<key>Label</key><string>${label}</string>
|
|
27
|
+
<key>ProgramArguments</key>
|
|
28
|
+
<array>
|
|
29
|
+
<string>${opts.binary}</string>
|
|
30
|
+
<string>--listen</string>
|
|
31
|
+
<string>${opts.listen}</string>
|
|
32
|
+
</array>
|
|
33
|
+
<key>RunAtLoad</key><true/>
|
|
34
|
+
<key>KeepAlive</key><true/>
|
|
35
|
+
<key>StandardOutPath</key><string>${opts.stdoutLog}</string>
|
|
36
|
+
<key>StandardErrorPath</key><string>${opts.stderrLog}</string>
|
|
37
|
+
<key>EnvironmentVariables</key>
|
|
38
|
+
<dict>
|
|
39
|
+
<key>AGENTSAMD_ROLE</key><string>machine</string>
|
|
40
|
+
</dict>
|
|
41
|
+
</dict>
|
|
42
|
+
</plist>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* User-level Scheduled Task XML (InteractiveToken, at logon, restart on failure).
|
|
48
|
+
* @param {{ binary: string, listen: string, workingDirectory: string, author?: string }} opts
|
|
49
|
+
*/
|
|
50
|
+
export function buildWindowsScheduledTaskXml(opts) {
|
|
51
|
+
const author = opts.author || 'Inner Animal Media';
|
|
52
|
+
const bin = String(opts.binary).replace(/&/g, '&').replace(/"/g, '"');
|
|
53
|
+
const cwd = String(opts.workingDirectory).replace(/&/g, '&').replace(/"/g, '"');
|
|
54
|
+
const listen = String(opts.listen).replace(/&/g, '&').replace(/"/g, '"');
|
|
55
|
+
// Arguments must not include the executable path — Command contains the .exe.
|
|
56
|
+
return `<?xml version="1.0" encoding="UTF-16"?>
|
|
57
|
+
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
58
|
+
<RegistrationInfo>
|
|
59
|
+
<Author>${author}</Author>
|
|
60
|
+
<Description>AgentSam machine runtime daemon (agentsamd). Protocol agentsam.runtime.v1.</Description>
|
|
61
|
+
</RegistrationInfo>
|
|
62
|
+
<Triggers>
|
|
63
|
+
<LogonTrigger>
|
|
64
|
+
<Enabled>true</Enabled>
|
|
65
|
+
</LogonTrigger>
|
|
66
|
+
</Triggers>
|
|
67
|
+
<Principals>
|
|
68
|
+
<Principal id="Author">
|
|
69
|
+
<LogonType>InteractiveToken</LogonType>
|
|
70
|
+
<RunLevel>LeastPrivilege</RunLevel>
|
|
71
|
+
</Principal>
|
|
72
|
+
</Principals>
|
|
73
|
+
<Settings>
|
|
74
|
+
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
|
|
75
|
+
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
76
|
+
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
77
|
+
<AllowHardTerminate>true</AllowHardTerminate>
|
|
78
|
+
<StartWhenAvailable>true</StartWhenAvailable>
|
|
79
|
+
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
|
|
80
|
+
<AllowStartOnDemand>true</AllowStartOnDemand>
|
|
81
|
+
<Enabled>true</Enabled>
|
|
82
|
+
<Hidden>false</Hidden>
|
|
83
|
+
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
|
84
|
+
<WakeToRun>false</WakeToRun>
|
|
85
|
+
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
|
|
86
|
+
<Priority>7</Priority>
|
|
87
|
+
<RestartOnFailure>
|
|
88
|
+
<Interval>PT1M</Interval>
|
|
89
|
+
<Count>3</Count>
|
|
90
|
+
</RestartOnFailure>
|
|
91
|
+
</Settings>
|
|
92
|
+
<Actions Context="Author">
|
|
93
|
+
<Exec>
|
|
94
|
+
<Command>${bin}</Command>
|
|
95
|
+
<Arguments>--listen ${listen}</Arguments>
|
|
96
|
+
<WorkingDirectory>${cwd}</WorkingDirectory>
|
|
97
|
+
</Exec>
|
|
98
|
+
</Actions>
|
|
99
|
+
</Task>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @returns {{ kind: 'launch_agent', label: string, plist: string } | null}
|
|
105
|
+
*/
|
|
106
|
+
export function writeLaunchAgent(home, binary, listen) {
|
|
107
|
+
if (process.platform !== 'darwin') return null;
|
|
108
|
+
const label = DARWIN_LAUNCH_LABEL;
|
|
109
|
+
const plistDir = path.join(home, 'Library', 'LaunchAgents');
|
|
110
|
+
fs.mkdirSync(plistDir, { recursive: true });
|
|
111
|
+
const plist = path.join(plistDir, `${label}.plist`);
|
|
112
|
+
const logDir = path.join(runtimeStateDir(home), 'logs');
|
|
113
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
114
|
+
const contents = buildLaunchAgentPlist({
|
|
115
|
+
binary,
|
|
116
|
+
listen,
|
|
117
|
+
label,
|
|
118
|
+
stdoutLog: path.join(logDir, 'agentsamd.stdout.log'),
|
|
119
|
+
stderrLog: path.join(logDir, 'agentsamd.stderr.log'),
|
|
120
|
+
});
|
|
121
|
+
fs.writeFileSync(plist, contents);
|
|
122
|
+
return { kind: 'launch_agent', label, plist };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Write task XML under ~/.agentsam/runtime/ and register via schtasks.
|
|
127
|
+
* @returns {Promise<{ kind: 'scheduled_task', taskName: string, xmlPath: string, registered: boolean, error?: string } | null>}
|
|
128
|
+
*/
|
|
129
|
+
export async function writeWindowsScheduledTask(home, binary, listen, options = {}) {
|
|
130
|
+
if (process.platform !== 'win32' && options.forcePlatform !== 'win32') return null;
|
|
131
|
+
ensureRuntimeStateDir(home);
|
|
132
|
+
const xmlPath = path.join(runtimeStateDir(home), 'agentsamd.scheduled-task.xml');
|
|
133
|
+
const workingDirectory = path.dirname(binary);
|
|
134
|
+
const xml = buildWindowsScheduledTaskXml({ binary, listen, workingDirectory });
|
|
135
|
+
// Node writes UTF-8; schtasks accepts UTF-8 when /XML is used on modern Windows.
|
|
136
|
+
fs.writeFileSync(xmlPath, xml, 'utf8');
|
|
137
|
+
|
|
138
|
+
const taskName = WINDOWS_TASK_NAME;
|
|
139
|
+
const execImpl = options.execFileAsync || execFileAsync;
|
|
140
|
+
if (options.skipRegister === true) {
|
|
141
|
+
return { kind: 'scheduled_task', taskName, xmlPath, registered: false };
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
await execImpl('schtasks', ['/Create', '/TN', taskName, '/XML', xmlPath, '/F'], {
|
|
145
|
+
timeout: 30000,
|
|
146
|
+
windowsHide: true,
|
|
147
|
+
});
|
|
148
|
+
return { kind: 'scheduled_task', taskName, xmlPath, registered: true };
|
|
149
|
+
} catch (err) {
|
|
150
|
+
return {
|
|
151
|
+
kind: 'scheduled_task',
|
|
152
|
+
taskName,
|
|
153
|
+
xmlPath,
|
|
154
|
+
registered: false,
|
|
155
|
+
error: String(err?.message || err),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export async function startWindowsScheduledTask(options = {}) {
|
|
161
|
+
const execImpl = options.execFileAsync || execFileAsync;
|
|
162
|
+
const taskName = options.taskName || WINDOWS_TASK_NAME;
|
|
163
|
+
await execImpl('schtasks', ['/Run', '/TN', taskName], { timeout: 15000, windowsHide: true });
|
|
164
|
+
return { ok: true, taskName };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function stopWindowsScheduledTask(options = {}) {
|
|
168
|
+
const execImpl = options.execFileAsync || execFileAsync;
|
|
169
|
+
const taskName = options.taskName || WINDOWS_TASK_NAME;
|
|
170
|
+
try {
|
|
171
|
+
await execImpl('schtasks', ['/End', '/TN', taskName], { timeout: 15000, windowsHide: true });
|
|
172
|
+
} catch {
|
|
173
|
+
/* task may not be running */
|
|
174
|
+
}
|
|
175
|
+
return { ok: true, taskName };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export async function bootstrapDarwinLaunchAgent(plist, label = DARWIN_LAUNCH_LABEL) {
|
|
179
|
+
if (process.platform !== 'darwin' || !plist) return { ok: false };
|
|
180
|
+
try {
|
|
181
|
+
await execFileAsync('launchctl', ['unload', plist], { timeout: 10000 }).catch(() => {});
|
|
182
|
+
await execFileAsync('launchctl', ['load', plist], { timeout: 10000 });
|
|
183
|
+
return { ok: true, label, plist };
|
|
184
|
+
} catch (err) {
|
|
185
|
+
return { ok: false, error: String(err?.message || err), label, plist };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export async function unloadDarwinLaunchAgent(plist) {
|
|
190
|
+
if (process.platform !== 'darwin' || !plist) return { ok: false };
|
|
191
|
+
try {
|
|
192
|
+
await execFileAsync('launchctl', ['unload', plist], { timeout: 10000 });
|
|
193
|
+
return { ok: true, plist };
|
|
194
|
+
} catch (err) {
|
|
195
|
+
return { ok: false, error: String(err?.message || err), plist };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentsam setup runtime — goal profiles → hard constraints → GOAP → utility → receipts.
|
|
3
|
+
* Physical registry remains terminal_* (Studio/IAM). This CLI owns local plan/install receipts.
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import { planGoap, GOAP_ENGINE } from '../../sam/planning/goap.js';
|
|
9
|
+
import {
|
|
10
|
+
RUNTIME_PROTOCOL_SCHEMA,
|
|
11
|
+
RUNTIME_ADAPTERS,
|
|
12
|
+
RUNTIME_TRANSPORTS,
|
|
13
|
+
capabilitiesSatisfy,
|
|
14
|
+
} from '../../../packages/runtime-protocol/src/index.js';
|
|
15
|
+
import { discoverEnvironment } from './discover.js';
|
|
16
|
+
|
|
17
|
+
export const RUNTIME_SETUP_SCHEMA = 'agentsam.runtime-setup.v1';
|
|
18
|
+
|
|
19
|
+
/** Five goal profiles (+ advanced). */
|
|
20
|
+
export const RUNTIME_PROFILES = Object.freeze([
|
|
21
|
+
{
|
|
22
|
+
id: 'my_computer',
|
|
23
|
+
label: 'My Computer',
|
|
24
|
+
description: 'This Mac/Linux host as a persistent agentsamd machine.',
|
|
25
|
+
provider: 'local',
|
|
26
|
+
substrate: 'host',
|
|
27
|
+
lifecycle: 'persistent',
|
|
28
|
+
runtime_adapter: 'agentsamd',
|
|
29
|
+
transport: 'direct_https',
|
|
30
|
+
required_capabilities: { exec: true, pty: true, filesystem: true, process: true },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'isolated_local',
|
|
34
|
+
label: 'Isolated Local',
|
|
35
|
+
description: 'Local Docker container running agentsamd.',
|
|
36
|
+
provider: 'local',
|
|
37
|
+
substrate: 'container',
|
|
38
|
+
lifecycle: 'persistent',
|
|
39
|
+
provider_product: 'docker',
|
|
40
|
+
runtime_adapter: 'agentsamd',
|
|
41
|
+
transport: 'direct_https',
|
|
42
|
+
required_capabilities: { exec: true, pty: true, filesystem: true, docker: true },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'cloud_computer',
|
|
46
|
+
label: 'Cloud Computer',
|
|
47
|
+
description: 'Persistent cloud VM (GCP today) with agentsamd.',
|
|
48
|
+
provider: 'google_cloud',
|
|
49
|
+
substrate: 'vm',
|
|
50
|
+
lifecycle: 'persistent',
|
|
51
|
+
provider_product: 'compute_engine',
|
|
52
|
+
runtime_adapter: 'agentsamd',
|
|
53
|
+
transport: 'cloudflare_tunnel',
|
|
54
|
+
required_capabilities: { exec: true, pty: true, filesystem: true, process: true },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'on_demand',
|
|
58
|
+
label: 'On-demand',
|
|
59
|
+
description: 'Scale-to-zero cloud container (CF Containers / Cloud Run).',
|
|
60
|
+
provider: 'cloudflare',
|
|
61
|
+
substrate: 'container',
|
|
62
|
+
lifecycle: 'scale_to_zero',
|
|
63
|
+
provider_product: 'containers',
|
|
64
|
+
runtime_adapter: 'agentsamd',
|
|
65
|
+
transport: 'service_binding',
|
|
66
|
+
required_capabilities: { exec: true, filesystem: true },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'safe_sandbox',
|
|
70
|
+
label: 'Safe Sandbox',
|
|
71
|
+
description: 'Ephemeral Cloudflare Sandbox adapter (no full daemon required).',
|
|
72
|
+
provider: 'cloudflare',
|
|
73
|
+
substrate: 'sandbox',
|
|
74
|
+
lifecycle: 'ephemeral',
|
|
75
|
+
provider_product: 'sandbox',
|
|
76
|
+
runtime_adapter: 'cloudflare_sandbox',
|
|
77
|
+
transport: 'service_binding',
|
|
78
|
+
required_capabilities: { exec: true },
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
function clean(value) {
|
|
83
|
+
return value == null ? '' : String(value).trim();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function runtimeStateDir(home = os.homedir()) {
|
|
87
|
+
return path.join(home, '.agentsam', 'runtime');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function ensureRuntimeStateDir(home = os.homedir()) {
|
|
91
|
+
const dir = runtimeStateDir(home);
|
|
92
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
93
|
+
return dir;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Discover facts for runtime placement (providers as adapters).
|
|
98
|
+
*/
|
|
99
|
+
export async function discoverRuntimeFacts(options = {}) {
|
|
100
|
+
const env = await discoverEnvironment(options);
|
|
101
|
+
const home = options.home || os.homedir();
|
|
102
|
+
const stateDir = runtimeStateDir(home);
|
|
103
|
+
const receiptPath = path.join(stateDir, 'latest.install-receipt.json');
|
|
104
|
+
let prior = null;
|
|
105
|
+
try {
|
|
106
|
+
if (fs.existsSync(receiptPath)) prior = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));
|
|
107
|
+
} catch {
|
|
108
|
+
prior = null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const agentsamdBin =
|
|
112
|
+
(await whichBinary('agentsamd')) ||
|
|
113
|
+
(fs.existsSync(path.join(home, '.agentsam', 'bin', 'agentsamd'))
|
|
114
|
+
? path.join(home, '.agentsam', 'bin', 'agentsamd')
|
|
115
|
+
: null);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
schema: RUNTIME_SETUP_SCHEMA,
|
|
119
|
+
discovered_at: new Date().toISOString(),
|
|
120
|
+
protocol: RUNTIME_PROTOCOL_SCHEMA,
|
|
121
|
+
host: {
|
|
122
|
+
hostname: env.hostname,
|
|
123
|
+
platform: env.platform,
|
|
124
|
+
arch: env.arch,
|
|
125
|
+
label: env.host_label,
|
|
126
|
+
},
|
|
127
|
+
tools: {
|
|
128
|
+
docker: Boolean(env.tools?.docker),
|
|
129
|
+
gcloud: Boolean(env.tools?.gcloud),
|
|
130
|
+
wrangler: Boolean(env.tools?.wrangler),
|
|
131
|
+
go: Boolean(await whichBinary('go')),
|
|
132
|
+
},
|
|
133
|
+
agentsamd: {
|
|
134
|
+
binary: agentsamdBin,
|
|
135
|
+
installed: Boolean(agentsamdBin),
|
|
136
|
+
prior_receipt: prior?.product || prior?.profile_id || null,
|
|
137
|
+
},
|
|
138
|
+
available_capabilities: {
|
|
139
|
+
exec: true,
|
|
140
|
+
pty: env.platform !== 'win32',
|
|
141
|
+
filesystem: true,
|
|
142
|
+
process: true,
|
|
143
|
+
git: Boolean(env.tools?.git),
|
|
144
|
+
docker: Boolean(env.tools?.docker),
|
|
145
|
+
gpu: false,
|
|
146
|
+
browser: false,
|
|
147
|
+
gui: env.platform === 'darwin',
|
|
148
|
+
ports: true,
|
|
149
|
+
snapshot: false,
|
|
150
|
+
persistent_filesystem: true,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function whichBinary(bin) {
|
|
156
|
+
const { execFile } = await import('node:child_process');
|
|
157
|
+
const { promisify } = await import('node:util');
|
|
158
|
+
const execFileAsync = promisify(execFile);
|
|
159
|
+
try {
|
|
160
|
+
const cmd = process.platform === 'win32' ? 'where' : 'which';
|
|
161
|
+
const { stdout } = await execFileAsync(cmd, [bin], { timeout: 4000 });
|
|
162
|
+
return String(stdout || '').trim().split(/\r?\n/)[0] || null;
|
|
163
|
+
} catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function hardConstraintsOk(profile, facts) {
|
|
169
|
+
const caps = capabilitiesSatisfy(profile.required_capabilities || {}, facts.available_capabilities || {});
|
|
170
|
+
const missingTools = [];
|
|
171
|
+
if (profile.substrate === 'container' && profile.provider === 'local' && !facts.tools.docker) {
|
|
172
|
+
missingTools.push('docker');
|
|
173
|
+
}
|
|
174
|
+
if (profile.provider === 'google_cloud' && !facts.tools.gcloud && !facts.tools.wrangler) {
|
|
175
|
+
// tunnel path can work with wrangler alone later; flag soft for now
|
|
176
|
+
}
|
|
177
|
+
if (profile.runtime_adapter === 'agentsamd' && !facts.tools.go && !facts.agentsamd.installed) {
|
|
178
|
+
missingTools.push('go_or_agentsamd_binary');
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
ok: caps.ok && missingTools.length === 0,
|
|
182
|
+
missing_capabilities: caps.missing,
|
|
183
|
+
missing_tools: missingTools,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* GOAP install actions for a profile.
|
|
189
|
+
*/
|
|
190
|
+
function goapCatalogFor(profile) {
|
|
191
|
+
return [
|
|
192
|
+
{
|
|
193
|
+
id: 'ensure_agentsamd_binary',
|
|
194
|
+
cost: 3,
|
|
195
|
+
preconditions: { need_agentsamd: true, has_agentsamd: false },
|
|
196
|
+
effects: { has_agentsamd: true },
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: 'ensure_docker',
|
|
200
|
+
cost: 2,
|
|
201
|
+
preconditions: { need_docker: true, has_docker: false },
|
|
202
|
+
effects: { has_docker: true },
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: 'create_instance_record',
|
|
206
|
+
cost: 1,
|
|
207
|
+
preconditions: { has_plan: true },
|
|
208
|
+
effects: { instance_planned: true },
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
id: 'create_connection_record',
|
|
212
|
+
cost: 1,
|
|
213
|
+
preconditions: { instance_planned: true },
|
|
214
|
+
effects: { connection_planned: true },
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: 'configure_transport',
|
|
218
|
+
cost: 2,
|
|
219
|
+
preconditions: { connection_planned: true },
|
|
220
|
+
effects: { transport_ready: true },
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: 'install_launch_agent',
|
|
224
|
+
cost: 2,
|
|
225
|
+
preconditions: { has_agentsamd: true, need_launchd: true },
|
|
226
|
+
effects: { launch_agent_installed: true },
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: 'enroll_runtime',
|
|
230
|
+
cost: 2,
|
|
231
|
+
preconditions: { transport_ready: true, has_agentsamd: true },
|
|
232
|
+
effects: { enrolled: true },
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
id: 'health_probe',
|
|
236
|
+
cost: 1,
|
|
237
|
+
preconditions: { enrolled: true },
|
|
238
|
+
effects: { healthy: true },
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function utilityScore(profile, facts, constraints) {
|
|
244
|
+
let score = 50;
|
|
245
|
+
if (constraints.ok) score += 40;
|
|
246
|
+
else score -= 30;
|
|
247
|
+
if (profile.id === 'my_computer' && facts.host.platform === 'darwin') score += 10;
|
|
248
|
+
if (profile.runtime_adapter === 'agentsamd' && facts.agentsamd.installed) score += 15;
|
|
249
|
+
if (profile.substrate === 'container' && facts.tools.docker) score += 8;
|
|
250
|
+
if (profile.provider === 'google_cloud' && facts.tools.gcloud) score += 8;
|
|
251
|
+
if (!constraints.ok) score -= constraints.missing_capabilities.length * 5;
|
|
252
|
+
return score;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Rank eligible profiles and build GOAP install plans.
|
|
257
|
+
*/
|
|
258
|
+
export async function planRuntimeSetup(options = {}) {
|
|
259
|
+
const facts = options.facts || (await discoverRuntimeFacts(options));
|
|
260
|
+
const profileId = clean(options.profileId || options.profile);
|
|
261
|
+
const profiles = profileId
|
|
262
|
+
? RUNTIME_PROFILES.filter((p) => p.id === profileId)
|
|
263
|
+
: [...RUNTIME_PROFILES];
|
|
264
|
+
|
|
265
|
+
const candidates = [];
|
|
266
|
+
for (const profile of profiles) {
|
|
267
|
+
const constraints = hardConstraintsOk(profile, facts);
|
|
268
|
+
const initialState = {
|
|
269
|
+
has_plan: true,
|
|
270
|
+
need_agentsamd: profile.runtime_adapter === 'agentsamd',
|
|
271
|
+
has_agentsamd: Boolean(facts.agentsamd.installed),
|
|
272
|
+
need_docker: profile.substrate === 'container' && profile.provider === 'local',
|
|
273
|
+
has_docker: Boolean(facts.tools.docker),
|
|
274
|
+
need_launchd: profile.substrate === 'host' && facts.host.platform === 'darwin',
|
|
275
|
+
instance_planned: false,
|
|
276
|
+
connection_planned: false,
|
|
277
|
+
transport_ready: false,
|
|
278
|
+
launch_agent_installed: facts.host.platform !== 'darwin',
|
|
279
|
+
enrolled: false,
|
|
280
|
+
healthy: false,
|
|
281
|
+
};
|
|
282
|
+
const goal = {
|
|
283
|
+
healthy: true,
|
|
284
|
+
enrolled: true,
|
|
285
|
+
...(profile.runtime_adapter === 'agentsamd' ? { has_agentsamd: true } : {}),
|
|
286
|
+
};
|
|
287
|
+
const goap = planGoap({
|
|
288
|
+
initialState,
|
|
289
|
+
goal,
|
|
290
|
+
actions: goapCatalogFor(profile),
|
|
291
|
+
maxExpansions: 200,
|
|
292
|
+
});
|
|
293
|
+
const score = utilityScore(profile, facts, constraints);
|
|
294
|
+
candidates.push({
|
|
295
|
+
profile,
|
|
296
|
+
eligible: constraints.ok,
|
|
297
|
+
constraints,
|
|
298
|
+
utility: score,
|
|
299
|
+
goap: {
|
|
300
|
+
engine: goap.engine || GOAP_ENGINE,
|
|
301
|
+
ok: goap.ok,
|
|
302
|
+
status: goap.status,
|
|
303
|
+
action_ids: goap.action_ids || [],
|
|
304
|
+
total_cost: goap.total_cost || 0,
|
|
305
|
+
error: goap.error || null,
|
|
306
|
+
},
|
|
307
|
+
target: {
|
|
308
|
+
protocol: RUNTIME_PROTOCOL_SCHEMA,
|
|
309
|
+
provider: profile.provider,
|
|
310
|
+
substrate: profile.substrate,
|
|
311
|
+
lifecycle: profile.lifecycle,
|
|
312
|
+
provider_product: profile.provider_product || null,
|
|
313
|
+
runtime_adapter: profile.runtime_adapter,
|
|
314
|
+
transport: profile.transport,
|
|
315
|
+
auth_mode: profile.runtime_adapter === 'agentsamd' ? 'connection_token' : 'service_binding',
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
candidates.sort((a, b) => {
|
|
321
|
+
if (a.eligible !== b.eligible) return a.eligible ? -1 : 1;
|
|
322
|
+
return b.utility - a.utility;
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
schema: RUNTIME_SETUP_SCHEMA,
|
|
327
|
+
protocol: RUNTIME_PROTOCOL_SCHEMA,
|
|
328
|
+
facts,
|
|
329
|
+
candidates,
|
|
330
|
+
recommended: candidates.find((c) => c.eligible) || candidates[0] || null,
|
|
331
|
+
adapters: RUNTIME_ADAPTERS,
|
|
332
|
+
transports: RUNTIME_TRANSPORTS,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function writeRuntimePlanReceipt(plan, home = os.homedir()) {
|
|
337
|
+
const dir = ensureRuntimeStateDir(home);
|
|
338
|
+
const file = path.join(dir, 'latest.plan.json');
|
|
339
|
+
const body = {
|
|
340
|
+
...plan,
|
|
341
|
+
written_at: new Date().toISOString(),
|
|
342
|
+
};
|
|
343
|
+
fs.writeFileSync(file, `${JSON.stringify(body, null, 2)}\n`);
|
|
344
|
+
return file;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export function writeRuntimeInstallReceipt(receipt, home = os.homedir()) {
|
|
348
|
+
const dir = ensureRuntimeStateDir(home);
|
|
349
|
+
const file = path.join(dir, 'latest.install-receipt.json');
|
|
350
|
+
const body = {
|
|
351
|
+
schema: 'agentsam.runtime-install-receipt.v1',
|
|
352
|
+
written_at: new Date().toISOString(),
|
|
353
|
+
...receipt,
|
|
354
|
+
};
|
|
355
|
+
fs.writeFileSync(file, `${JSON.stringify(body, null, 2)}\n`);
|
|
356
|
+
return file;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export function renderRuntimePlan(plan) {
|
|
360
|
+
const lines = [
|
|
361
|
+
'',
|
|
362
|
+
' Agent Sam · setup runtime',
|
|
363
|
+
' ────────────────────────────────────────',
|
|
364
|
+
'',
|
|
365
|
+
` Host ${plan.facts.host.label} · ${plan.facts.host.hostname} · ${plan.facts.host.platform}/${plan.facts.host.arch}`,
|
|
366
|
+
` Protocol ${plan.protocol}`,
|
|
367
|
+
` agentsamd ${plan.facts.agentsamd.installed ? `✓ ${plan.facts.agentsamd.binary}` : '○ not installed'}`,
|
|
368
|
+
'',
|
|
369
|
+
' Profiles (hard constraints → GOAP → utility)',
|
|
370
|
+
'',
|
|
371
|
+
];
|
|
372
|
+
for (const c of plan.candidates) {
|
|
373
|
+
const mark = c.eligible ? '✓' : '✕';
|
|
374
|
+
lines.push(` ${mark} ${c.profile.label.padEnd(18)} utility ${String(c.utility).padStart(3)} adapter=${c.target.runtime_adapter} ${c.target.provider}/${c.target.substrate}`);
|
|
375
|
+
if (!c.eligible) {
|
|
376
|
+
if (c.constraints.missing_capabilities.length) {
|
|
377
|
+
lines.push(` missing caps: ${c.constraints.missing_capabilities.join(', ')}`);
|
|
378
|
+
}
|
|
379
|
+
if (c.constraints.missing_tools.length) {
|
|
380
|
+
lines.push(` missing tools: ${c.constraints.missing_tools.join(', ')}`);
|
|
381
|
+
}
|
|
382
|
+
} else if (c.goap.action_ids.length) {
|
|
383
|
+
lines.push(` plan: ${c.goap.action_ids.join(' → ')}`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
lines.push('');
|
|
387
|
+
if (plan.recommended) {
|
|
388
|
+
lines.push(` Recommended ${plan.recommended.profile.label} (${plan.recommended.profile.id})`);
|
|
389
|
+
lines.push(` Next agentsam setup runtime --profile ${plan.recommended.profile.id} --yes`);
|
|
390
|
+
lines.push(` agentsam runtime install`);
|
|
391
|
+
}
|
|
392
|
+
lines.push('');
|
|
393
|
+
return `${lines.join('\n')}\n`;
|
|
394
|
+
}
|
|
@@ -13,6 +13,8 @@ export const SLASH_COMMANDS = [
|
|
|
13
13
|
{ cmd: '/status', description: 'Honest project awareness: account, models, terminal, live deploy', lane: 'local' },
|
|
14
14
|
{ cmd: '/models', description: 'Probe providers and provider-verified known models', lane: 'model' },
|
|
15
15
|
{ cmd: '/providers', description: 'Configure and verify machine provider credentials', lane: 'model' },
|
|
16
|
+
{ cmd: '/credentials', description: 'Audit credentials, drift, and remediation (never prints secrets)', lane: 'identity' },
|
|
17
|
+
{ cmd: '/cheat-sheet', description: 'Organized Agent Sam command groups', lane: 'local' },
|
|
16
18
|
{ cmd: '/login', description: 'Sign in to Inner Animal Media and save the machine-local Agent Sam session', lane: 'identity' },
|
|
17
19
|
{ cmd: '/logout', description: 'Sign out locally without deleting provider credentials', lane: 'identity' },
|
|
18
20
|
{ cmd: '/whoami', description: 'Show authenticated account identity and safe credential status', lane: 'identity' },
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host identity the CLI sends when enrolling a device.
|
|
3
|
+
* Same vocabulary as ExecOS heartbeat: macos|linux|windows and arm64|x86_64|x86.
|
|
4
|
+
*/
|
|
5
|
+
import { execFile } from 'node:child_process';
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { arch as osArch, hostname as osHostname, platform as osPlatform } from 'node:os';
|
|
8
|
+
|
|
9
|
+
function clean(value) {
|
|
10
|
+
return value == null ? '' : String(value).trim();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function normalizeTerminalPlatform(value) {
|
|
14
|
+
const raw = clean(value).toLowerCase();
|
|
15
|
+
if (raw === 'darwin' || raw === 'macos' || raw === 'mac' || raw === 'osx') return 'macos';
|
|
16
|
+
if (raw === 'win32' || raw === 'windows' || raw === 'win') return 'windows';
|
|
17
|
+
if (raw === 'linux') return 'linux';
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function normalizeTerminalArch(value) {
|
|
22
|
+
const raw = clean(value).toLowerCase().replace(/-/g, '_');
|
|
23
|
+
if (raw === 'arm64' || raw === 'aarch64') return 'arm64';
|
|
24
|
+
if (raw === 'x64' || raw === 'x86_64' || raw === 'amd64') return 'x86_64';
|
|
25
|
+
if (raw === 'ia32' || raw === 'i386' || raw === 'i686' || raw === 'x86') return 'x86';
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function normalizeHostname(value) {
|
|
30
|
+
const raw = clean(value).replace(/\.local$/i, '').replace(/[\u0000\r\n]/g, '');
|
|
31
|
+
if (!raw) return null;
|
|
32
|
+
return raw.slice(0, 255);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function normalizeHardwareModel(value) {
|
|
36
|
+
const raw = clean(value).replace(/[\u0000\r\n]/g, ' ').replace(/\s+/g, ' ');
|
|
37
|
+
if (!raw) return null;
|
|
38
|
+
const lower = raw.toLowerCase();
|
|
39
|
+
if (lower === 'unknown' || lower === 'to be filled by o.e.m.' || lower === 'system product name') return null;
|
|
40
|
+
return raw.slice(0, 128);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function runText(file, args) {
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
execFile(file, args, { timeout: 3000, encoding: 'utf8', windowsHide: true }, (error, stdout) => {
|
|
46
|
+
if (error) {
|
|
47
|
+
resolve(null);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve(String(stdout || '').trim() || null);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function readHardwareModel(platform) {
|
|
56
|
+
try {
|
|
57
|
+
if (platform === 'darwin') return runText('sysctl', ['-n', 'hw.model']);
|
|
58
|
+
if (platform === 'win32') {
|
|
59
|
+
return runText('powershell.exe', [
|
|
60
|
+
'-NoProfile',
|
|
61
|
+
'-NonInteractive',
|
|
62
|
+
'-Command',
|
|
63
|
+
'(Get-CimInstance Win32_ComputerSystem).Model',
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
if (platform === 'linux') {
|
|
67
|
+
if (existsSync('/.dockerenv') || process.env.KUBERNETES_SERVICE_HOST) return 'container';
|
|
68
|
+
try {
|
|
69
|
+
return readFileSync('/sys/class/dmi/id/product_name', 'utf8').trim() || null;
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function collectMachineIdentity() {
|
|
81
|
+
let platform = '';
|
|
82
|
+
let arch = '';
|
|
83
|
+
let hostname = '';
|
|
84
|
+
try { platform = osPlatform(); } catch { platform = ''; }
|
|
85
|
+
try { arch = osArch(); } catch { arch = ''; }
|
|
86
|
+
try { hostname = osHostname(); } catch { hostname = ''; }
|
|
87
|
+
let model = null;
|
|
88
|
+
try { model = await readHardwareModel(platform); } catch { model = null; }
|
|
89
|
+
return {
|
|
90
|
+
hostname: normalizeHostname(hostname),
|
|
91
|
+
platform: normalizeTerminalPlatform(platform),
|
|
92
|
+
arch: normalizeTerminalArch(arch),
|
|
93
|
+
model: normalizeHardwareModel(model),
|
|
94
|
+
};
|
|
95
|
+
}
|