@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,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
collectCredentialsAudit,
|
|
3
|
+
renderCredentialsAudit,
|
|
4
|
+
} from '../lib/credentials-audit.js';
|
|
5
|
+
import {
|
|
6
|
+
remediateProviderFailure,
|
|
7
|
+
renderRemediationCard,
|
|
8
|
+
recommendedCommand,
|
|
9
|
+
} from '../lib/provider-command-remediation.js';
|
|
10
|
+
|
|
11
|
+
function writeLine(write, value = '') {
|
|
12
|
+
write(`${value}\n`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function parseArgs(argv = []) {
|
|
16
|
+
const out = {
|
|
17
|
+
action: 'audit',
|
|
18
|
+
json: false,
|
|
19
|
+
verify: false,
|
|
20
|
+
drift: true,
|
|
21
|
+
namesOnly: false,
|
|
22
|
+
noNetwork: false,
|
|
23
|
+
help: false,
|
|
24
|
+
remediateArgv: [],
|
|
25
|
+
};
|
|
26
|
+
const args = [...argv];
|
|
27
|
+
if (!args.length || args[0] === 'audit') {
|
|
28
|
+
if (args[0] === 'audit') args.shift();
|
|
29
|
+
out.action = 'audit';
|
|
30
|
+
} else if (args[0] === 'remediate') {
|
|
31
|
+
out.action = 'remediate';
|
|
32
|
+
args.shift();
|
|
33
|
+
} else if (args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
|
|
34
|
+
out.help = true;
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
39
|
+
const arg = args[i];
|
|
40
|
+
if (arg === '--json') out.json = true;
|
|
41
|
+
else if (arg === '--verify') out.verify = true;
|
|
42
|
+
else if (arg === '--drift') out.drift = true;
|
|
43
|
+
else if (arg === '--no-drift') out.drift = false;
|
|
44
|
+
else if (arg === '--names-only') out.namesOnly = true;
|
|
45
|
+
else if (arg === '--no-network') out.noNetwork = true;
|
|
46
|
+
else if (arg === '--help' || arg === '-h') out.help = true;
|
|
47
|
+
else if (arg === '--') continue;
|
|
48
|
+
else if (out.action === 'remediate') out.remediateArgv.push(arg);
|
|
49
|
+
else throw new Error(`unknown credentials option: ${arg}`);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function printHelp(write = (s) => process.stdout.write(s)) {
|
|
55
|
+
writeLine(write, '');
|
|
56
|
+
writeLine(write, ' agentsam credentials audit [--verify] [--drift] [--names-only] [--no-network] [--json]');
|
|
57
|
+
writeLine(write, ' agentsam credentials remediate -- <provider argv…>');
|
|
58
|
+
writeLine(write, '');
|
|
59
|
+
writeLine(write, ' Never prints secret values. Prefer --names-only for shareable receipts.');
|
|
60
|
+
writeLine(write, ' Example remediation fixture:');
|
|
61
|
+
writeLine(write, ' agentsam credentials remediate -- gcloud edge-cloud service-accounts keys create');
|
|
62
|
+
writeLine(write, '');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function runCredentials(argv = [], options = {}) {
|
|
66
|
+
const write = options.write || ((s) => process.stdout.write(s));
|
|
67
|
+
const parsed = parseArgs(argv);
|
|
68
|
+
if (parsed.help) {
|
|
69
|
+
printHelp(write);
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (parsed.action === 'remediate') {
|
|
74
|
+
const card = remediateProviderFailure({
|
|
75
|
+
argv: parsed.remediateArgv,
|
|
76
|
+
env: options.env || process.env,
|
|
77
|
+
projectId: options.projectId,
|
|
78
|
+
});
|
|
79
|
+
if (!card) {
|
|
80
|
+
writeLine(write, '');
|
|
81
|
+
writeLine(write, ' No deterministic remediation matched that failure yet.');
|
|
82
|
+
writeLine(write, ' Tip: agentsam cheat-sheet · agentsam credentials audit --verify --drift');
|
|
83
|
+
writeLine(write, '');
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
if (parsed.json) {
|
|
87
|
+
write(JSON.stringify({ ...card, recommended_command: recommendedCommand(card) }, null, 2) + '\n');
|
|
88
|
+
} else {
|
|
89
|
+
write(renderRemediationCard(card));
|
|
90
|
+
const cmd = recommendedCommand(card);
|
|
91
|
+
if (cmd) writeLine(write, ` Recommended copy:\n ${cmd}\n`);
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const report = await collectCredentialsAudit({
|
|
97
|
+
env: options.env || process.env,
|
|
98
|
+
home: options.home,
|
|
99
|
+
verify: parsed.verify,
|
|
100
|
+
drift: parsed.drift,
|
|
101
|
+
namesOnly: parsed.namesOnly,
|
|
102
|
+
noNetwork: parsed.noNetwork || !parsed.verify,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (parsed.json) {
|
|
106
|
+
write(JSON.stringify(report, null, 2) + '\n');
|
|
107
|
+
} else {
|
|
108
|
+
write(renderCredentialsAudit(report));
|
|
109
|
+
for (const card of report.remediations || []) {
|
|
110
|
+
write(renderRemediationCard(card));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const high = (report.drift || []).some((row) => row.severity === 'high');
|
|
115
|
+
return high ? 2 : 0;
|
|
116
|
+
}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Sam Google auth for CLI.
|
|
3
|
+
*
|
|
4
|
+
* Default: Local Studio Web OAuth broker (GOOGLE_CLIENT_ID + Worker secret).
|
|
5
|
+
* Optional: --desktop native Desktop PKCE · --web identity login · --sdk gcloud ADC.
|
|
6
|
+
*/
|
|
7
|
+
import { spawn, execFile } from 'node:child_process';
|
|
8
|
+
import { promisify } from 'node:util';
|
|
9
|
+
import readline from 'node:readline/promises';
|
|
10
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
11
|
+
import { promptToOpenUrl, openExternalUrl } from '../lib/open-url.js';
|
|
12
|
+
import { resolveIamIssuer } from '../../packages/identity/src/contracts/auth-config.js';
|
|
13
|
+
import {
|
|
14
|
+
googleCloudPermissionChecklist,
|
|
15
|
+
runGoogleDesktopCloudLogin,
|
|
16
|
+
} from '../lib/google-desktop-oauth.js';
|
|
17
|
+
import { runGoogleStudioBrokeredCloudLogin } from '../lib/google-studio-brokered-oauth.js';
|
|
18
|
+
|
|
19
|
+
const execFileAsync = promisify(execFile);
|
|
20
|
+
|
|
21
|
+
function clean(value) {
|
|
22
|
+
return value == null ? '' : String(value).trim();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Hosted Google identity start URL — IAM issuer + /api/oauth/google/start.
|
|
27
|
+
* Requires GOOGLE_CLIENT_ID (or GOOGLE_DESKTOP_CLIENT_ID) in env; server holds secrets.
|
|
28
|
+
* No AGENTSAM_GOOGLE_OAUTH_START / hardcoded product host.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveGoogleOauthStartUrl(env = process.env, explicit = '') {
|
|
31
|
+
const fromExplicit = clean(explicit);
|
|
32
|
+
if (fromExplicit) return fromExplicit;
|
|
33
|
+
const googleId = clean(env.GOOGLE_CLIENT_ID) || clean(env.GOOGLE_DESKTOP_CLIENT_ID);
|
|
34
|
+
if (!googleId) {
|
|
35
|
+
const err = new Error(
|
|
36
|
+
'GOOGLE_CLIENT_ID (web) or GOOGLE_DESKTOP_CLIENT_ID (desktop) is not configured.',
|
|
37
|
+
);
|
|
38
|
+
err.code = 'google_oauth_not_configured';
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
const issuer = resolveIamIssuer(env);
|
|
42
|
+
return new URL('/api/oauth/google/start', `${issuer}/`).toString();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function writeLine(write, value = '') {
|
|
46
|
+
write(`${value}\n`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function terminalWidth(stream = output) {
|
|
50
|
+
const cols = Number(stream?.columns) || 80;
|
|
51
|
+
return Math.max(40, Math.min(cols, 120));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function wrapText(text, width) {
|
|
55
|
+
const words = String(text || '').split(/\s+/).filter(Boolean);
|
|
56
|
+
if (!words.length) return [];
|
|
57
|
+
const lines = [];
|
|
58
|
+
let current = '';
|
|
59
|
+
for (const word of words) {
|
|
60
|
+
const next = current ? `${current} ${word}` : word;
|
|
61
|
+
if (next.length > width && current) {
|
|
62
|
+
lines.push(current);
|
|
63
|
+
current = word;
|
|
64
|
+
} else {
|
|
65
|
+
current = next;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (current) lines.push(current);
|
|
69
|
+
return lines;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function printBanner(write, title, detailLines = []) {
|
|
73
|
+
const width = terminalWidth();
|
|
74
|
+
const rule = '─'.repeat(Math.min(width - 2, 56));
|
|
75
|
+
writeLine(write, '');
|
|
76
|
+
writeLine(write, ` ${title}`);
|
|
77
|
+
writeLine(write, ` ${rule}`);
|
|
78
|
+
for (const line of detailLines) {
|
|
79
|
+
for (const wrapped of wrapText(line, width - 4)) {
|
|
80
|
+
writeLine(write, ` ${wrapped}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
writeLine(write, '');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function printAuthHelp(write) {
|
|
87
|
+
printBanner(write, 'Agent Sam · Google auth', [
|
|
88
|
+
'Default: Local Studio Web OAuth broker (Worker holds GOOGLE_CLIENT_SECRET).',
|
|
89
|
+
'Use --desktop for native Desktop PKCE (no secret; requires a true Desktop client Google accepts).',
|
|
90
|
+
'Use --web for hosted identity login, --sdk for native gcloud ADC.',
|
|
91
|
+
]);
|
|
92
|
+
writeLine(write, ' agentsam gcloud auth login');
|
|
93
|
+
writeLine(write, ' agentsam gcloud auth login --desktop');
|
|
94
|
+
writeLine(write, ' agentsam gcloud auth login --web');
|
|
95
|
+
writeLine(write, ' agentsam gcloud auth login --sdk');
|
|
96
|
+
writeLine(write, ' agentsam gcloud auth login --permissions');
|
|
97
|
+
writeLine(write, ' agentsam gcloud auth login --no-launch-browser');
|
|
98
|
+
writeLine(write, ' agentsam gcloud auth list');
|
|
99
|
+
writeLine(write, ' agentsam gcloud auth revoke [--all]');
|
|
100
|
+
writeLine(write, ' agentsam gcloud auth application-default login');
|
|
101
|
+
writeLine(write, '');
|
|
102
|
+
writeLine(write, ` Hosted identity URL ( --web )`);
|
|
103
|
+
writeLine(write, ` \${IAM_OAUTH_ISSUER}/api/oauth/google/start`);
|
|
104
|
+
writeLine(write, ` requires GOOGLE_CLIENT_ID or GOOGLE_DESKTOP_CLIENT_ID`);
|
|
105
|
+
writeLine(write, '');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function printPermissions(write) {
|
|
109
|
+
const checklist = googleCloudPermissionChecklist();
|
|
110
|
+
printBanner(write, 'Agent Sam · Google Cloud permissions', checklist.notes);
|
|
111
|
+
writeLine(write, ' OAuth scopes this CLI requests');
|
|
112
|
+
for (const s of checklist.oauth_scopes_requested) writeLine(write, ` • ${s}`);
|
|
113
|
+
writeLine(write, '');
|
|
114
|
+
writeLine(write, ' Google Auth Platform (Console)');
|
|
115
|
+
for (const row of checklist.oauth_consent_screen) writeLine(write, ` • ${row}`);
|
|
116
|
+
writeLine(write, '');
|
|
117
|
+
writeLine(write, ' GCP project IAM (on the project you operate)');
|
|
118
|
+
for (const row of checklist.project_iam_roles) writeLine(write, ` • ${row}`);
|
|
119
|
+
writeLine(write, '');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function spawnGcloudInteractive(args, env) {
|
|
123
|
+
return new Promise((resolve) => {
|
|
124
|
+
const child = spawn('gcloud', args, {
|
|
125
|
+
env,
|
|
126
|
+
stdio: 'inherit',
|
|
127
|
+
shell: false,
|
|
128
|
+
});
|
|
129
|
+
child.on('error', (error) => {
|
|
130
|
+
resolve({ ok: false, code: 1, error: error.message });
|
|
131
|
+
});
|
|
132
|
+
child.on('close', (code) => {
|
|
133
|
+
resolve({ ok: code === 0, code: code ?? 1 });
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function runGcloudCapture(args, env, timeoutMs = 30000) {
|
|
139
|
+
try {
|
|
140
|
+
const { stdout, stderr } = await execFileAsync('gcloud', args, {
|
|
141
|
+
timeout: timeoutMs,
|
|
142
|
+
env,
|
|
143
|
+
maxBuffer: 2 * 1024 * 1024,
|
|
144
|
+
});
|
|
145
|
+
return { ok: true, code: 0, stdout: String(stdout || ''), stderr: String(stderr || '') };
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return {
|
|
148
|
+
ok: false,
|
|
149
|
+
code: Number(error?.code) || 1,
|
|
150
|
+
stdout: String(error?.stdout || ''),
|
|
151
|
+
stderr: String(error?.stderr || error?.message || ''),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function waitForEnter(message, { inputStream = input, outputStream = output } = {}) {
|
|
157
|
+
if (!inputStream?.isTTY || !outputStream?.isTTY) {
|
|
158
|
+
outputStream.write(`${message}\n`);
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
const rl = readline.createInterface({ input: inputStream, output: outputStream });
|
|
162
|
+
try {
|
|
163
|
+
await rl.question(`\n ${message}\n `);
|
|
164
|
+
return true;
|
|
165
|
+
} finally {
|
|
166
|
+
rl.close();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Hosted Google OAuth identity — uses IAM_OAUTH_ISSUER + GOOGLE_CLIENT_ID lane.
|
|
172
|
+
*/
|
|
173
|
+
export async function runAgentsamGoogleOauthLogin(options = {}) {
|
|
174
|
+
const write = options.write || ((s) => process.stdout.write(s));
|
|
175
|
+
const env = options.env || process.env;
|
|
176
|
+
const startUrl = resolveGoogleOauthStartUrl(env, options.startUrl);
|
|
177
|
+
const noLaunch = Boolean(options.noLaunchBrowser);
|
|
178
|
+
const json = Boolean(options.json);
|
|
179
|
+
|
|
180
|
+
printBanner(write, 'Agent Sam · Continue with Google (web identity)', [
|
|
181
|
+
'Hosted Local Studio identity — openid/email/profile only (not Google Cloud scopes).',
|
|
182
|
+
'CLI cannot auto-detect browser completion on this path; prefer default Desktop login for Cloud.',
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
writeLine(write, ' Authorization URL');
|
|
186
|
+
writeLine(write, ` ${startUrl}`);
|
|
187
|
+
writeLine(write, '');
|
|
188
|
+
|
|
189
|
+
if (json) {
|
|
190
|
+
write(JSON.stringify({
|
|
191
|
+
schema_version: 'agentsam-google-oauth-login-v1',
|
|
192
|
+
mode: 'hosted_identity',
|
|
193
|
+
start_url: startUrl,
|
|
194
|
+
scopes: ['openid', 'email', 'profile'],
|
|
195
|
+
note: 'Identity only. Use agentsam gcloud auth login (default) for Google Cloud scopes + auto callback.',
|
|
196
|
+
}, null, 2) + '\n');
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
writeLine(write, ' [enter] open browser');
|
|
201
|
+
writeLine(write, ' [c] cancel');
|
|
202
|
+
writeLine(write, '');
|
|
203
|
+
|
|
204
|
+
const interactive =
|
|
205
|
+
Boolean(options.forceInteractive)
|
|
206
|
+
|| Boolean(options.choice)
|
|
207
|
+
|| Boolean(options.promptToOpenUrlImpl)
|
|
208
|
+
|| (input.isTTY && output.isTTY && !options.nonInteractive);
|
|
209
|
+
|
|
210
|
+
if (!interactive) {
|
|
211
|
+
writeLine(write, ' Non-interactive shell — open this URL in a browser:');
|
|
212
|
+
writeLine(write, ` ${startUrl}`);
|
|
213
|
+
writeLine(write, '');
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
let choice = options.choice || 'enter';
|
|
218
|
+
if (!options.choice) {
|
|
219
|
+
const rl = readline.createInterface({ input, output });
|
|
220
|
+
try {
|
|
221
|
+
const answer = String(await rl.question(' Choice [enter/c]: ')).trim().toLowerCase();
|
|
222
|
+
if (answer === 'c' || answer === 'cancel' || answer === 'q') choice = 'cancel';
|
|
223
|
+
else choice = 'enter';
|
|
224
|
+
} finally {
|
|
225
|
+
rl.close();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (choice === 'cancel') {
|
|
230
|
+
writeLine(write, ' Cancelled.');
|
|
231
|
+
return 1;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (noLaunch) {
|
|
235
|
+
writeLine(write, '');
|
|
236
|
+
writeLine(write, ' Open the URL above manually, then return here.');
|
|
237
|
+
} else {
|
|
238
|
+
const promptImpl = options.promptToOpenUrlImpl || promptToOpenUrl;
|
|
239
|
+
await promptImpl(startUrl, {
|
|
240
|
+
heading: ' Continue to Agent Sam at:',
|
|
241
|
+
prompt: 'Press ENTER to open Google sign-in in your browser.',
|
|
242
|
+
input: options.input || input,
|
|
243
|
+
output: options.output || output,
|
|
244
|
+
openImpl: options.openImpl || openExternalUrl,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (!options.skipCompletionPrompt) {
|
|
249
|
+
await waitForEnter('After you finish in the browser, press ENTER to continue…', {
|
|
250
|
+
inputStream: options.input || input,
|
|
251
|
+
outputStream: options.output || output,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
writeLine(write, '');
|
|
255
|
+
writeLine(write, ' ✓ Hosted identity step acknowledged.');
|
|
256
|
+
writeLine(write, ' For Google Cloud scopes + automatic completion, run:');
|
|
257
|
+
writeLine(write, ' agentsam gcloud auth login');
|
|
258
|
+
writeLine(write, '');
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function runSdkGcloudLogin({ write, env, pass = [], noLaunch = false }) {
|
|
263
|
+
printBanner(write, 'Agent Sam · Google Cloud SDK login', [
|
|
264
|
+
'This opens Google Cloud SDK OAuth (Continue to Google Cloud SDK).',
|
|
265
|
+
'Redirect stays on localhost — expected for the gcloud client.',
|
|
266
|
+
]);
|
|
267
|
+
const args = ['auth', 'login', ...pass];
|
|
268
|
+
if (noLaunch && !pass.includes('--no-launch-browser')) {
|
|
269
|
+
args.push('--no-launch-browser');
|
|
270
|
+
}
|
|
271
|
+
const result = await spawnGcloudInteractive(args, env);
|
|
272
|
+
if (!result.ok) {
|
|
273
|
+
writeLine(write, '');
|
|
274
|
+
writeLine(write, ' ✕ gcloud auth login failed.');
|
|
275
|
+
writeLine(write, ' Tip: agentsam gcloud auth login --sdk --no-launch-browser');
|
|
276
|
+
writeLine(write, '');
|
|
277
|
+
return result.code || 1;
|
|
278
|
+
}
|
|
279
|
+
writeLine(write, '');
|
|
280
|
+
writeLine(write, ' ✓ Google Cloud SDK login complete.');
|
|
281
|
+
writeLine(write, ' Next: agentsam google-cloud doctor');
|
|
282
|
+
writeLine(write, '');
|
|
283
|
+
return 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @param {string[]} argv args after `auth`
|
|
288
|
+
*/
|
|
289
|
+
export async function runGcloudAuth(argv = [], options = {}) {
|
|
290
|
+
const write = options.write || ((s) => process.stdout.write(s));
|
|
291
|
+
const env = options.env || process.env;
|
|
292
|
+
const json = argv.includes('--json') || Boolean(options.json);
|
|
293
|
+
const args = argv.filter((a) => a !== '--json');
|
|
294
|
+
|
|
295
|
+
if (!args.length || args[0] === 'help' || args[0] === '--help' || args[0] === '-h') {
|
|
296
|
+
printAuthHelp(write);
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (args[0] === 'list') {
|
|
301
|
+
const result = await runGcloudCapture(
|
|
302
|
+
['auth', 'list', '--format=table(account,status)'],
|
|
303
|
+
env,
|
|
304
|
+
);
|
|
305
|
+
if (json) {
|
|
306
|
+
const parsed = await runGcloudCapture(['auth', 'list', '--format=json'], env);
|
|
307
|
+
write((parsed.stdout || '[]') + (parsed.stdout?.endsWith('\n') ? '' : '\n'));
|
|
308
|
+
return parsed.ok ? 0 : 1;
|
|
309
|
+
}
|
|
310
|
+
if (!result.ok) {
|
|
311
|
+
write(result.stderr || result.stdout);
|
|
312
|
+
return 1;
|
|
313
|
+
}
|
|
314
|
+
writeLine(write, '');
|
|
315
|
+
writeLine(write, ' Agent Sam · gcloud auth list');
|
|
316
|
+
writeLine(write, '');
|
|
317
|
+
write(result.stdout.endsWith('\n') ? result.stdout : `${result.stdout}\n`);
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (args[0] === 'login') {
|
|
322
|
+
const pass = args.slice(1);
|
|
323
|
+
if (pass.includes('--permissions') || pass.includes('--scopes')) {
|
|
324
|
+
if (json) write(JSON.stringify(googleCloudPermissionChecklist(), null, 2) + '\n');
|
|
325
|
+
else printPermissions(write);
|
|
326
|
+
return 0;
|
|
327
|
+
}
|
|
328
|
+
const useSdk = pass.includes('--sdk') || pass.includes('--gcloud-sdk');
|
|
329
|
+
const useWeb = pass.includes('--web') || pass.includes('--hosted');
|
|
330
|
+
const useDesktop = pass.includes('--desktop') || pass.includes('--pkce');
|
|
331
|
+
const noLaunch = pass.includes('--no-launch-browser');
|
|
332
|
+
const cleanPass = pass.filter(
|
|
333
|
+
(a) =>
|
|
334
|
+
a !== '--sdk'
|
|
335
|
+
&& a !== '--gcloud-sdk'
|
|
336
|
+
&& a !== '--web'
|
|
337
|
+
&& a !== '--hosted'
|
|
338
|
+
&& a !== '--desktop'
|
|
339
|
+
&& a !== '--pkce'
|
|
340
|
+
&& a !== '--no-launch-browser'
|
|
341
|
+
&& a !== '--permissions'
|
|
342
|
+
&& a !== '--scopes',
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
if (useSdk) {
|
|
346
|
+
return runSdkGcloudLogin({ write, env, pass: cleanPass, noLaunch });
|
|
347
|
+
}
|
|
348
|
+
if (useWeb) {
|
|
349
|
+
return runAgentsamGoogleOauthLogin({
|
|
350
|
+
write,
|
|
351
|
+
env,
|
|
352
|
+
json,
|
|
353
|
+
noLaunchBrowser: noLaunch,
|
|
354
|
+
nonInteractive: options.nonInteractive,
|
|
355
|
+
promptToOpenUrlImpl: options.promptToOpenUrlImpl,
|
|
356
|
+
openImpl: options.openImpl,
|
|
357
|
+
input: options.input,
|
|
358
|
+
output: options.output,
|
|
359
|
+
startUrl: options.startUrl,
|
|
360
|
+
choice: options.choice,
|
|
361
|
+
skipCompletionPrompt: options.skipCompletionPrompt,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
try {
|
|
366
|
+
if (useDesktop) {
|
|
367
|
+
await runGoogleDesktopCloudLogin({
|
|
368
|
+
write,
|
|
369
|
+
env,
|
|
370
|
+
json,
|
|
371
|
+
noLaunchBrowser: noLaunch,
|
|
372
|
+
home: options.home,
|
|
373
|
+
promptToOpenUrlImpl: options.promptToOpenUrlImpl,
|
|
374
|
+
openImpl: options.openImpl,
|
|
375
|
+
input: options.input,
|
|
376
|
+
output: options.output,
|
|
377
|
+
fetchImpl: options.fetchImpl,
|
|
378
|
+
createServerImpl: options.createServerImpl,
|
|
379
|
+
disableOsStore: options.disableOsStore,
|
|
380
|
+
storeCredential: options.storeCredential,
|
|
381
|
+
writeConnection: options.writeConnection,
|
|
382
|
+
});
|
|
383
|
+
} else {
|
|
384
|
+
await runGoogleStudioBrokeredCloudLogin({
|
|
385
|
+
write,
|
|
386
|
+
env,
|
|
387
|
+
json,
|
|
388
|
+
noLaunchBrowser: noLaunch,
|
|
389
|
+
home: options.home,
|
|
390
|
+
promptToOpenUrlImpl: options.promptToOpenUrlImpl,
|
|
391
|
+
openImpl: options.openImpl,
|
|
392
|
+
input: options.input,
|
|
393
|
+
output: options.output,
|
|
394
|
+
fetchImpl: options.fetchImpl,
|
|
395
|
+
createServerImpl: options.createServerImpl,
|
|
396
|
+
disableOsStore: options.disableOsStore,
|
|
397
|
+
storeCredential: options.storeCredential,
|
|
398
|
+
writeConnection: options.writeConnection,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
return 0;
|
|
402
|
+
} catch (error) {
|
|
403
|
+
writeLine(write, '');
|
|
404
|
+
writeLine(write, ` ✕ ${error?.message || error}`);
|
|
405
|
+
writeLine(write, ' Tip: agentsam gcloud auth login --permissions');
|
|
406
|
+
writeLine(write, '');
|
|
407
|
+
return 1;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (args[0] === 'application-default' && args[1] === 'login') {
|
|
412
|
+
writeLine(write, '');
|
|
413
|
+
writeLine(write, ' Agent Sam · application-default credentials');
|
|
414
|
+
writeLine(write, ' Used by libraries/ADC — separate from Agent Sam Desktop Google OAuth.');
|
|
415
|
+
writeLine(write, '');
|
|
416
|
+
const result = await spawnGcloudInteractive(['auth', 'application-default', 'login', ...args.slice(2)], env);
|
|
417
|
+
return result.ok ? 0 : result.code || 1;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (args[0] === 'revoke') {
|
|
421
|
+
const result = await spawnGcloudInteractive(['auth', 'revoke', ...args.slice(1)], env);
|
|
422
|
+
return result.ok ? 0 : result.code || 1;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const result = await spawnGcloudInteractive(['auth', ...args], env);
|
|
426
|
+
return result.ok ? 0 : result.code || 1;
|
|
427
|
+
}
|