@inneranimalmedia/agentsam-sdk 2.6.5 → 2.6.7
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 +29 -0
- package/apps/README.md +5 -0
- package/apps/cad-creator/README.md +4 -4
- package/apps/cad-creator/shared/cad/package.json +1 -1
- package/apps/client-cms-editor/AGENTS.md +12 -7
- package/apps/client-cms-editor/README.md +76 -48
- package/apps/client-cms-editor/agentsam.app.json +26 -9
- package/apps/client-cms-editor/backend/package.json +20 -3
- package/apps/client-cms-editor/backend/src/api/client.ts +134 -101
- package/apps/client-cms-editor/backend/src/index.ts +1 -1
- package/apps/client-cms-editor/backend/src/model.ts +11 -115
- package/apps/client-cms-editor/backend/src/preview/bridge.ts +1 -1
- package/apps/client-cms-editor/backend/tsconfig.json +6 -1
- package/apps/client-cms-editor/bin/agentsam-cms.js +262 -0
- package/apps/client-cms-editor/bin/agentsam-cms.mjs +2 -228
- package/apps/client-cms-editor/frontend/package.json +16 -7
- package/apps/client-cms-editor/frontend/src/AgentSamDrawer.tsx +9 -41
- package/apps/client-cms-editor/frontend/src/CmsAgentSurface.tsx +19 -174
- package/apps/client-cms-editor/frontend/src/adapters/heuristic.ts +29 -0
- package/apps/client-cms-editor/frontend/src/adapters/http.ts +628 -0
- package/apps/client-cms-editor/frontend/src/adapters/memory.ts +510 -0
- package/apps/client-cms-editor/frontend/src/editor/CmsEditor.tsx +213 -0
- package/apps/client-cms-editor/frontend/src/editor/CmsEditorProvider.tsx +20 -0
- package/apps/client-cms-editor/frontend/src/editor/canvas/PreviewCanvas.tsx +53 -0
- package/apps/client-cms-editor/frontend/src/{CmsEditor.tsx → editor/legacy/CmsEditorPrototype.tsx} +52 -23
- package/apps/client-cms-editor/frontend/src/editor/useCmsEditorController.ts +218 -0
- package/apps/client-cms-editor/frontend/src/index.ts +19 -5
- package/apps/client-cms-editor/frontend/src/lib/agent-host.ts +24 -0
- package/apps/client-cms-editor/frontend/src/main.tsx +82 -8
- package/apps/client-cms-editor/frontend/src/mount.tsx +92 -30
- package/apps/client-cms-editor/frontend/src/styles/agentsam-drawer.css +1 -1
- package/apps/client-cms-editor/frontend/src/styles/cmsShell.css +8 -8
- package/apps/client-cms-editor/frontend/src/styles/studio.css +55 -3
- package/apps/client-cms-editor/frontend/tsconfig.json +12 -1
- package/apps/client-cms-editor/frontend/vite.config.ts +12 -0
- package/apps/client-cms-editor/package-lock.json +973 -134
- package/apps/client-cms-editor/package.json +118 -6
- package/apps/client-cms-editor/reference/harvest/HARVEST_RECEIPT.json +201 -0
- package/apps/client-cms-editor/reference/harvest/PROVENANCE_HISTORY.txt +10 -0
- package/apps/client-cms-editor/reference/harvest/README.md +8 -0
- package/apps/client-cms-editor/reference/harvest/plans/ARCHIVE-INTAKE.md +135 -0
- package/apps/client-cms-editor/reference/harvest/plans/CHATGPT-IDENTITY-HARVEST.md +83 -0
- package/apps/client-cms-editor/reference/harvest/plans/CMS-EDITOR-HARVEST.md +166 -0
- package/apps/client-cms-editor/reference/harvest/plans/HARVEST-INDEX.md +196 -0
- package/apps/client-cms-editor/reference/harvest/plans/INNERANIMALS-CONTENT-001.md +137 -0
- package/apps/client-cms-editor/reference/harvest/plans/NO-IMPLICIT-SIDE-EFFECTS.md +87 -0
- package/apps/client-cms-editor/reference/harvest/plans/STOREFRONT-SURFACE-MAP.md +140 -0
- package/apps/client-cms-editor/reference/harvest/plans/THEME-INNERANIMALS-HARVEST.md +137 -0
- package/apps/client-cms-editor/reference/harvest/plans/TOOLING-LAB.md +63 -0
- package/apps/client-cms-editor/reference/harvest/plans/harvest-manifest.json +97 -0
- package/apps/client-cms-editor/reference/harvest/plans/local-cms-harvest-schema.sql +328 -0
- package/apps/client-cms-editor/shared/cms/package.json +17 -7
- package/apps/client-cms-editor/shared/cms/src/adapter.ts +204 -0
- package/apps/client-cms-editor/shared/cms/src/agent-context.ts +7 -5
- package/apps/client-cms-editor/shared/cms/src/editor-types.ts +32 -0
- package/apps/client-cms-editor/shared/cms/src/host.ts +82 -0
- package/apps/client-cms-editor/shared/cms/src/index.ts +4 -0
- package/apps/client-cms-editor/shared/cms/src/map.ts +115 -0
- package/apps/client-cms-editor/shared/cms/src/starter-pack.ts +158 -0
- package/contracts/source-types.v1.json +353 -0
- package/docs/CMS_CONTEXTUAL_COMPOSER.md +1 -1
- package/docs/PRODUCT_LIFECYCLE.md +566 -0
- package/docs/THEME_REFINERY.md +2 -2
- package/docs/architecture/AGENTSAM_RUNTIME_PROTOCOL.md +40 -20
- package/docs/content-studio/REVISION_GATE_2026-09-27.md +1 -1
- package/docs/plans/LOCAL_STUDIO_DESKTOP_RELEASE_2026-09-29.md +150 -0
- package/migrations/d1/0017_identity_native_oauth.sql +21 -0
- package/native/agentsam-machine/Cargo.lock +426 -0
- package/native/agentsam-machine/Cargo.toml +9 -0
- package/native/agentsam-machine/cli/Cargo.toml +14 -0
- package/native/agentsam-machine/cli/src/main.rs +77 -0
- package/native/agentsam-machine/core/Cargo.toml +15 -0
- package/native/agentsam-machine/core/src/assets.rs +790 -0
- package/native/agentsam-machine/core/src/bound.rs +298 -0
- package/native/agentsam-machine/core/src/enrich.rs +706 -0
- package/native/agentsam-machine/core/src/frontend.rs +442 -0
- package/native/agentsam-machine/core/src/lib.rs +1086 -0
- package/native/agentsam-machine/core/src/liquid.rs +528 -0
- package/native/agentsam-machine/core/src/source_types.rs +78 -0
- package/package.json +51 -21
- package/packages/agentsam-brand/README.md +1 -1
- package/packages/agentsam-brand/package.json +4 -4
- package/packages/agentsam-brand/src/index.js +1 -1
- package/packages/agentsam-contracts/package.json +13 -3
- package/packages/agentsam-contracts/src/tools.ts +22 -0
- package/packages/agentsam-errors/package.json +13 -3
- package/packages/agentsam-knowledge/package.json +18 -4
- package/packages/agentsam-knowledge/src/autorag/index.js +10 -3
- package/packages/agentsam-knowledge/src/backends/index.js +33 -1
- package/packages/agentsam-knowledge/test/autorag.test.mjs +60 -1
- package/packages/agentsam-nav/package.json +24 -6
- package/packages/agentsam-queue-control/README.md +1 -1
- package/packages/agentsam-queue-control/package.json +7 -2
- package/packages/agentsam-rapid-rust/src/main.rs +1 -1
- package/packages/agentsam-repository/package.json +13 -3
- package/packages/agentsam-repository/src/source-types.js +8 -0
- package/packages/agentsam-vault/package.json +14 -4
- package/packages/agentsam-workbench/package.json +15 -4
- package/packages/agentsam-workbench/src/agent/ToolPermissionRequest.tsx +94 -0
- package/packages/agentsam-workbench/src/agent/index.ts +2 -0
- package/packages/agentsam-workbench/src/agent/tool-permission.css +134 -0
- package/packages/connectors/cloudflare/package.json +13 -3
- package/packages/connectors/cloudflare/src/api-client.js +3 -2
- package/packages/connectors/cloudflare/src/families/vectorize.js +127 -0
- package/packages/connectors/cloudflare/src/index.js +1 -0
- package/packages/heuristic-theme/README.md +2 -2
- package/packages/heuristic-theme/package.json +8 -3
- package/packages/heuristic-theme/src/registry.js +2 -2
- package/packages/heuristic-theme/src/theme.js +1 -1
- package/packages/heuristic-theme/test/theme.test.mjs +1 -1
- package/packages/identity/.agentsam/features/oauth-login-portal/agentsam.feature.json +1 -1
- package/packages/identity/.agentsam/features/oauth-login-portal/providers.json +27 -7
- package/packages/identity/README.md +2 -2
- package/packages/identity/migrations/D1_SCHEMA_MAPPING.md +18 -15
- package/packages/identity/migrations/apply-portable.js +109 -0
- package/packages/identity/migrations/sqlite/004_identity_oauth_consent_catalog.sql +1 -1
- package/packages/identity/migrations/sqlite/005_identity_company_native.sql +52 -0
- package/packages/identity/package.json +27 -6
- package/packages/identity/schema/agentsam.identity/manifest.json +101 -0
- package/packages/identity/scripts/local-identity-bridge.mjs +13 -7
- package/packages/identity/scripts/preview-auth-portal.mjs +6 -6
- package/packages/identity/src/adapters/cloudflare-d1/index.js +8 -401
- package/packages/identity/src/adapters/iam-compat/index.js +540 -0
- package/packages/identity/src/adapters/portable-d1/index.js +18 -0
- package/packages/identity/src/adapters/portable-store.js +479 -0
- package/packages/identity/src/adapters/sqlite/index.js +13 -312
- package/packages/identity/src/contracts/auth-config.js +0 -1
- package/packages/identity/src/contracts/identity-store.js +56 -5
- package/packages/identity/src/contracts/provider.js +1 -0
- package/packages/identity/src/contracts/sign-in-options.js +104 -0
- package/packages/identity/src/core/constants.js +1 -1
- package/packages/identity/src/core/session-policy.js +31 -0
- package/packages/identity/src/frontend/auth-portal/pages/login.html +6 -6
- package/packages/identity/src/frontend/auth-portal/pages/reset.html +5 -5
- package/packages/identity/src/frontend/auth-portal/pages/signup.html +5 -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 +6 -37
- package/packages/identity/src/index.js +28 -1
- package/packages/identity/src/migrations/README.md +23 -23
- package/packages/identity/src/oauth/README.md +1 -1
- package/packages/identity/src/oauth/credentials.js +10 -11
- package/packages/identity/src/oauth/google-desktop-exchange.js +195 -27
- package/packages/identity/src/oauth/iam-platform.js +21 -9
- package/packages/identity/src/oauth/native-handoff.js +136 -0
- package/packages/identity/src/providers/chatgpt/headers.js +65 -0
- package/packages/identity/src/providers/chatgpt/index.js +86 -0
- package/packages/identity/src/providers/chatgpt/mapper.js +43 -0
- package/packages/identity/src/providers/chatgpt/paths.js +45 -0
- package/packages/identity/src/providers/github/oauth.js +1 -2
- package/packages/identity/src/providers/github/profile.js +16 -2
- package/packages/identity/src/providers/index.js +11 -3
- package/packages/identity/src/server/identity-service.js +2 -1
- package/packages/identity/src/server/worker-router.js +71 -18
- package/packages/identity/tests/chatgpt-provider.test.mjs +75 -0
- package/packages/identity/tests/google-desktop-identity-login.test.mjs +210 -0
- package/packages/identity/tests/identity-init-scaffold.test.mjs +15 -4
- package/packages/identity/tests/lane1-identity-store-parity.test.mjs +527 -0
- package/packages/identity/tests/lane1-packed-consumer.test.mjs +175 -0
- package/packages/identity/tests/native-oauth-handoff.test.mjs +292 -0
- package/packages/identity/tests/oauth-credentials.test.mjs +4 -4
- package/packages/identity/tests/preview-auth-portal.test.mjs +4 -2
- package/packages/identity/tests/session-routes-policy.test.mjs +13 -1
- package/packages/identity/tests/worker-runtime-boundary.test.mjs +11 -0
- package/packages/providers/completeful/package.json +7 -2
- package/packages/theme-church-site/package.json +17 -6
- package/packages/theme-church-site/src/harvest.json +4 -2
- package/packages/theme-church-site/src/index.js +7 -3
- package/packages/theme-church-site/test/theme.test.mjs +4 -2
- package/packages/theme-companions-site/package.json +17 -6
- package/packages/theme-companions-site/src/harvest.json +4 -2
- package/packages/theme-companions-site/src/index.js +7 -3
- package/packages/theme-companions-site/test/theme.test.mjs +4 -2
- package/packages/theme-floors-site/package.json +17 -6
- package/packages/theme-floors-site/src/harvest.json +4 -2
- package/packages/theme-floors-site/src/index.js +7 -3
- package/packages/theme-floors-site/test/theme.test.mjs +4 -2
- package/packages/theme-fuelnfree-site/package.json +17 -6
- package/packages/theme-fuelnfree-site/src/harvest.json +4 -2
- package/packages/theme-fuelnfree-site/src/index.js +7 -3
- package/packages/theme-fuelnfree-site/test/theme.test.mjs +4 -2
- package/packages/theme-handyman-site/package.json +17 -6
- package/packages/theme-handyman-site/src/harvest.json +4 -2
- package/packages/theme-handyman-site/src/index.js +7 -3
- package/packages/theme-handyman-site/test/theme.test.mjs +4 -2
- package/packages/theme-insurance-site/package.json +17 -6
- package/packages/theme-insurance-site/src/harvest.json +4 -2
- package/packages/theme-insurance-site/src/index.js +7 -3
- package/packages/theme-insurance-site/test/theme.test.mjs +4 -2
- package/packages/theme-scenes/README.md +1 -1
- package/packages/theme-scenes/package.json +4 -3
- package/packages/theme-scenes/src/registry.js +187 -0
- package/packages/theme-shinshu-site/package.json +17 -6
- package/packages/theme-shinshu-site/src/harvest.json +4 -2
- package/packages/theme-shinshu-site/src/index.js +7 -3
- package/packages/theme-shinshu-site/test/theme.test.mjs +4 -2
- package/packages/work-graph/package.json +14 -4
- package/protocol/FILEMETA_V1.md +2 -2
- package/protocol/capabilities/manifest.json +1 -1
- package/protocol/database/agentsam.schema-pack.v1.schema.json +72 -0
- package/protocol/presets/catalog.json +2 -2
- package/protocol/theme-refinery/lineage-registry.json +105 -0
- package/protocol/theme-refinery/product-metadata.schema.json +21 -1
- package/skills/grok-auth/SKILL.md +110 -0
- package/skills/grok-auth/agentsam.skill.json +25 -0
- package/skills/grok-auth/references/grok-identity.md +64 -0
- package/skills/grok-auth/references/per-user-data.md +49 -0
- package/skills/grok-auth/references/prewired-and-env.md +54 -0
- package/skills/grok-auth/references/session-ui.md +133 -0
- package/skills/grok-auth/references/sign-in-methods.md +55 -0
- package/skills/grok-auth/references/wiring.md +71 -0
- package/skills/grok-building-games/SKILL.md +213 -0
- package/skills/grok-building-games/agentsam.skill.json +25 -0
- package/skills/grok-building-games/references/3d-libs.md +64 -0
- package/skills/grok-building-games/references/ai-pathfinding.md +122 -0
- package/skills/grok-building-games/references/audio.md +129 -0
- package/skills/grok-building-games/references/babylon.md +202 -0
- package/skills/grok-building-games/references/collision-physics.md +122 -0
- package/skills/grok-building-games/references/ecs-architecture.md +111 -0
- package/skills/grok-building-games/references/game-feel-juice.md +110 -0
- package/skills/grok-building-games/references/genres/board-card-chess.md +89 -0
- package/skills/grok-building-games/references/genres/endless-runner.md +83 -0
- package/skills/grok-building-games/references/genres/fps.md +105 -0
- package/skills/grok-building-games/references/genres/platformer-2d.md +97 -0
- package/skills/grok-building-games/references/genres/puzzle-match3-tetris.md +131 -0
- package/skills/grok-building-games/references/genres/racing-kart.md +106 -0
- package/skills/grok-building-games/references/genres/topdown-twin-stick.md +97 -0
- package/skills/grok-building-games/references/genres/tower-defense.md +84 -0
- package/skills/grok-building-games/references/genres/voxel-minecraft.md +89 -0
- package/skills/grok-building-games/references/input.md +139 -0
- package/skills/grok-building-games/references/phaser.md +277 -0
- package/skills/grok-building-games/references/procedural-generation.md +141 -0
- package/skills/grok-building-games/references/save-persistence.md +108 -0
- package/skills/grok-building-games/references/threejs-foundational.md +148 -0
- package/skills/grok-controls/SKILL.md +274 -0
- package/skills/grok-controls/agentsam.skill.json +25 -0
- package/skills/grok-design-ui/SKILL.md +122 -0
- package/skills/grok-design-ui/agentsam.skill.json +25 -0
- package/skills/grok-design-ui/references/animations.md +379 -0
- package/skills/grok-design-ui/references/performance.md +88 -0
- package/skills/grok-design-ui/references/refined-ui.md +384 -0
- package/skills/grok-design-ui/references/surfaces.md +247 -0
- package/skills/grok-design-ui/references/typography.md +123 -0
- package/skills/grok-game-animation-frames/SKILL.md +84 -0
- package/skills/grok-game-animation-frames/agentsam.skill.json +25 -0
- package/skills/grok-game-asset-core/SKILL.md +69 -0
- package/skills/grok-game-asset-core/agentsam.skill.json +25 -0
- package/skills/grok-game-character-consistency/SKILL.md +69 -0
- package/skills/grok-game-character-consistency/agentsam.skill.json +25 -0
- package/skills/grok-game-tilesets/SKILL.md +65 -0
- package/skills/grok-game-tilesets/agentsam.skill.json +25 -0
- package/skills/grok-game-ui-icons/SKILL.md +56 -0
- package/skills/grok-game-ui-icons/agentsam.skill.json +25 -0
- package/skills/grok-generate2dmap/LICENSE +21 -0
- package/skills/grok-generate2dmap/SKILL.md +120 -0
- package/skills/grok-generate2dmap/SOURCE.md +6 -0
- package/skills/grok-generate2dmap/agentsam.skill.json +25 -0
- package/skills/grok-generate2dmap/references/deliverables.md +101 -0
- package/skills/grok-generate2dmap/references/layered-map-contract.md +209 -0
- package/skills/grok-generate2dmap/references/map-strategies.md +341 -0
- package/skills/grok-generate2dmap/references/object-production-gate.md +24 -0
- package/skills/grok-generate2dmap/references/pipeline.md +149 -0
- package/skills/grok-generate2dmap/references/prop-pack-contract.md +174 -0
- package/skills/grok-generate2dmap/references/side-scroll-stages.md +29 -0
- package/skills/grok-generate2dmap/scripts/compose_layered_preview.py +157 -0
- package/skills/grok-generate2dmap/scripts/extract_prop_pack.py +369 -0
- package/skills/grok-generate2dsprite/LICENSE +21 -0
- package/skills/grok-generate2dsprite/SKILL.md +313 -0
- package/skills/grok-generate2dsprite/SOURCE.md +6 -0
- package/skills/grok-generate2dsprite/agentsam.skill.json +25 -0
- package/skills/grok-generate2dsprite/references/modes.md +124 -0
- package/skills/grok-generate2dsprite/references/prompt-rules.md +315 -0
- package/skills/grok-generate2dsprite/scripts/generate2dsprite.py +1031 -0
- package/skills/grok-generate2dsprite/scripts/make_layout_guide.py +109 -0
- package/skills/grok-imagine/SKILL.md +201 -0
- package/skills/grok-imagine/agentsam.skill.json +25 -0
- package/skills/grok-multiplayer-p2p/SKILL.md +111 -0
- package/skills/grok-multiplayer-p2p/agentsam.skill.json +25 -0
- package/skills/grok-multiplayer-p2p/references/react-binding.md +144 -0
- package/skills/grok-multiplayer-p2p/references/signaling-relay.md +269 -0
- package/skills/grok-neon/SKILL.md +157 -0
- package/skills/grok-neon/agentsam.skill.json +25 -0
- package/skills/grok-og/SKILL.md +102 -0
- package/skills/grok-og/agentsam.skill.json +25 -0
- package/skills/grok-og/references/brand-pass.md +53 -0
- package/skills/grok-og/references/custom-card.md +107 -0
- package/skills/grok-og/references/favicon-and-icons.md +48 -0
- package/skills/grok-og/references/og-type-contract.md +18 -0
- package/skills/grok-og/references/placeholder-card.md +21 -0
- package/skills/grok-og/references/x-banner.md +41 -0
- package/skills/grok-threejs/SKILL.md +67 -0
- package/skills/grok-threejs/agentsam.skill.json +25 -0
- package/skills/grok-threejs/references/llms-full.txt +2780 -0
- package/skills/grok-video2dsprite/LICENSE +21 -0
- package/skills/grok-video2dsprite/SKILL.md +236 -0
- package/skills/grok-video2dsprite/SOURCE.md +6 -0
- package/skills/grok-video2dsprite/agentsam.skill.json +25 -0
- package/skills/grok-video2dsprite/references/pipeline.md +90 -0
- package/skills/grok-video2dsprite/references/prompt-rules.md +63 -0
- package/skills/grok-video2dsprite/scripts/video2dsprite.py +490 -0
- package/skills/grok-xai-api/SKILL.md +152 -0
- package/skills/grok-xai-api/agentsam.skill.json +25 -0
- package/src/cli/command-catalog.js +46 -4
- package/src/cli/dispatch.js +1 -0
- package/src/cli.js +10 -0
- package/src/cloudflare/runtime-status.js +2 -1
- package/src/commands/autorag.js +67 -13
- package/src/commands/cheat-sheet.js +29 -4
- package/src/commands/codebaseindex.js +45 -2
- package/src/commands/knowledge.js +59 -2
- package/src/commands/machine-binary.js +103 -0
- package/src/commands/machine.js +137 -0
- package/src/commands/security.js +67 -4
- package/src/commands/setup.js +33 -16
- package/src/commands/status.js +8 -1
- package/src/features/resolve.js +1 -0
- package/src/knowledge/engine.js +21 -2
- package/src/knowledge/runtime-discovery.js +127 -0
- package/src/lib/identity-scaffold.js +53 -13
- package/src/lib/setup/recipes.js +1 -1
- package/src/models/discovery.js +40 -22
- package/src/models/inventory-core.d.ts +105 -0
- package/src/models/inventory-core.js +54 -6
- package/src/security/logs.js +3 -0
- package/src/ui/cli/help.js +41 -0
- package/test/apps-scaffold-contract.test.mjs +3 -2
- package/test/cli/api-key-env-whoami.test.mjs +2 -2
- package/test/cli/catalog-authority.test.mjs +64 -0
- package/test/cli/machine-command.test.mjs +34 -0
- package/test/fixtures/project-authority/customer-app/.agentsam/app.json +5 -0
- package/test/fixtures/project-authority/customer-app/apps/my-product/index.ts +1 -0
- package/test/fixtures/project-authority/customer-app/wrangler.toml +17 -0
- package/test/integration/autorag-project-authority.integration.test.mjs +51 -0
- package/test/integration/autorag-runtime-discovery.test.mjs +107 -0
- package/test/integration/cms-app-scaffold.test.mjs +37 -31
- package/test/integration/cms-site-tenancy-contract.test.mjs +28 -17
- package/test/integration/codebaseindex-ingest.test.mjs +41 -0
- package/test/integration/database-hosted-honesty.test.mjs +49 -0
- package/test/integration/desktop-keychain-boundary.test.mjs +45 -0
- package/test/integration/hosted-work-host-authority.test.mjs +47 -0
- package/test/integration/inventory-eligibility.test.mjs +59 -0
- package/test/integration/local-provider-bridge.test.mjs +65 -0
- package/test/integration/local-studio-settings-production.test.mjs +40 -0
- package/test/integration/lockfile-sync.test.mjs +26 -0
- package/test/integration/provider-env-cli.test.mjs +13 -3
- package/test/integration/runtime-status.integration.test.mjs +16 -1
- package/test/integration/theme-package-registry.test.mjs +31 -0
- package/test/repository-snapshot-view.test.mjs +2 -2
- package/test/security.test.mjs +14 -0
- package/test/terminal-machine-identity.test.mjs +2 -2
- package/apps/client-cms-editor/backend/src/demo-bootstrap.ts +0 -145
- package/packages/agentsam-nav/dist/Nav.d.ts +0 -43
- package/packages/agentsam-nav/dist/NavCollapsible.d.ts +0 -10
- package/packages/agentsam-nav/dist/NavContent.d.ts +0 -2
- package/packages/agentsam-nav/dist/NavFooter.d.ts +0 -2
- package/packages/agentsam-nav/dist/NavGroup.d.ts +0 -3
- package/packages/agentsam-nav/dist/NavHeader.d.ts +0 -2
- package/packages/agentsam-nav/dist/NavMenu.d.ts +0 -22
- package/packages/agentsam-nav/dist/NavProvider.d.ts +0 -35
- package/packages/agentsam-nav/dist/NavTrigger.d.ts +0 -2
- package/packages/agentsam-nav/dist/Surfaces.d.ts +0 -41
- package/packages/agentsam-nav/dist/browser.d.ts +0 -11
- package/packages/agentsam-nav/dist/browser.global.js +0 -132
- package/packages/agentsam-nav/dist/browser.js +0 -613
- package/packages/agentsam-nav/dist/contracts.d.ts +0 -76
- package/packages/agentsam-nav/dist/index.d.ts +0 -11
- package/packages/agentsam-nav/dist/index.js +0 -614
- package/packages/agentsam-nav/dist/legacy.css +0 -83
- package/packages/agentsam-nav/dist/shell.css +0 -113
- package/packages/agentsam-nav/dist/theme.css +0 -113
- package/packages/agentsam-nav/dist/utils.d.ts +0 -1
- package/packages/agentsam-repository/src/goap.js.bak-20260922011251 +0 -670
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentsam machine — graduate the native Machine engine to the product CLI.
|
|
3
|
+
*
|
|
4
|
+
* Graduation rule: capability is complete when reachable through
|
|
5
|
+
* `agentsam machine …`, emits bounded deterministic receipts, and preserves evidence.
|
|
6
|
+
*
|
|
7
|
+
* Asset perception rule: discovery is read-only and network-free by default.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { resolveMachineBinary, spawnMachine } from './machine-binary.js';
|
|
12
|
+
|
|
13
|
+
function usage() {
|
|
14
|
+
return `agentsam machine — deterministic local perception (native engine)
|
|
15
|
+
|
|
16
|
+
Usage:
|
|
17
|
+
agentsam machine inspect <path> [--json] [--run-id <id>] [--include-generated]
|
|
18
|
+
agentsam machine doctor [--json]
|
|
19
|
+
agentsam machine --help
|
|
20
|
+
|
|
21
|
+
Notes:
|
|
22
|
+
Default inspect is read-only and network-free.
|
|
23
|
+
Large detail is externalized under <target>/.agentsam/machine/runs/<run_id>/.
|
|
24
|
+
Generated/cache trees are summarized unless --include-generated is set.
|
|
25
|
+
Remote fetch/probe, optimization, storage, and reference rewriting are separate explicit actions.
|
|
26
|
+
Set AGENTSAM_MACHINE_BIN to force a specific agentsam-machine binary.`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseArgs(argv = []) {
|
|
30
|
+
const out = {
|
|
31
|
+
help: false,
|
|
32
|
+
json: false,
|
|
33
|
+
includeGenerated: false,
|
|
34
|
+
runId: null,
|
|
35
|
+
subcommand: null,
|
|
36
|
+
target: null,
|
|
37
|
+
positionals: [],
|
|
38
|
+
};
|
|
39
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
40
|
+
const arg = argv[i];
|
|
41
|
+
if (arg === '--help' || arg === '-h') out.help = true;
|
|
42
|
+
else if (arg === '--json') out.json = true;
|
|
43
|
+
else if (arg === '--include-generated') out.includeGenerated = true;
|
|
44
|
+
else if (arg === '--run-id') {
|
|
45
|
+
const value = argv[++i];
|
|
46
|
+
if (value == null || value.startsWith('--')) {
|
|
47
|
+
throw new Error('--run-id requires a value');
|
|
48
|
+
}
|
|
49
|
+
out.runId = value;
|
|
50
|
+
} else if (arg.startsWith('-')) {
|
|
51
|
+
throw new Error(`unknown machine option: ${arg}`);
|
|
52
|
+
} else {
|
|
53
|
+
out.positionals.push(arg);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
out.subcommand = out.positionals[0] || null;
|
|
57
|
+
out.target = out.positionals[1] || null;
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function printTextDoctor(resolution) {
|
|
62
|
+
if (resolution.kind === 'binary') {
|
|
63
|
+
console.log(`agentsam-machine available (${resolution.source}): ${resolution.path}`);
|
|
64
|
+
console.log('capability: machine.inspect');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (resolution.kind === 'cargo') {
|
|
68
|
+
console.log(`agentsam-machine via cargo run (${resolution.source}): ${resolution.manifest}`);
|
|
69
|
+
console.log('capability: machine.inspect (dev fallback)');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
console.log('agentsam-machine unavailable');
|
|
73
|
+
console.log(`tried: ${(resolution.tried || []).join(', ')}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string[]} argv
|
|
78
|
+
*/
|
|
79
|
+
export async function runMachine(argv = []) {
|
|
80
|
+
const args = parseArgs(argv);
|
|
81
|
+
if (args.help || !args.subcommand) {
|
|
82
|
+
console.log(usage());
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const resolution = resolveMachineBinary();
|
|
87
|
+
|
|
88
|
+
if (args.subcommand === 'doctor') {
|
|
89
|
+
const payload = {
|
|
90
|
+
capability: 'machine.doctor',
|
|
91
|
+
available: resolution.kind !== 'missing',
|
|
92
|
+
resolution,
|
|
93
|
+
};
|
|
94
|
+
if (args.json) console.log(JSON.stringify(payload));
|
|
95
|
+
else printTextDoctor(resolution);
|
|
96
|
+
return resolution.kind === 'missing' ? 1 : 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (args.subcommand === 'inspect') {
|
|
100
|
+
const target = args.target || process.cwd();
|
|
101
|
+
const abs = path.resolve(target);
|
|
102
|
+
const machineArgv = ['inspect', abs];
|
|
103
|
+
if (args.runId) machineArgv.push('--run-id', args.runId);
|
|
104
|
+
if (args.includeGenerated) machineArgv.push('--include-generated');
|
|
105
|
+
if (args.json) machineArgv.push('--json');
|
|
106
|
+
|
|
107
|
+
const result = spawnMachine(resolution, machineArgv, {
|
|
108
|
+
stdio: args.json ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
109
|
+
// Large donors still emit bounded compact JSON; raise buffer for safety.
|
|
110
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (result.error) throw result.error;
|
|
114
|
+
if (args.json) {
|
|
115
|
+
const stdout = String(result.stdout || '');
|
|
116
|
+
const stderr = String(result.stderr || '');
|
|
117
|
+
if (result.status && result.status !== 0) {
|
|
118
|
+
const err = new Error(stderr.trim() || `agentsam-machine exited with code ${result.status}`);
|
|
119
|
+
err.exitCode = result.status;
|
|
120
|
+
throw err;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const parsed = JSON.parse(stdout);
|
|
124
|
+
console.log(JSON.stringify(parsed));
|
|
125
|
+
} catch {
|
|
126
|
+
process.stdout.write(stdout);
|
|
127
|
+
}
|
|
128
|
+
if (stderr.trim()) process.stderr.write(stderr);
|
|
129
|
+
}
|
|
130
|
+
return result.status ?? 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(usage());
|
|
134
|
+
const err = new Error(`Unknown machine subcommand: ${args.subcommand}`);
|
|
135
|
+
err.exitCode = 1;
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
package/src/commands/security.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
import { scanProjectSecurity, reportExitCode, repairProject, formatSecurityReport } from '../security/index.js';
|
|
3
2
|
import { runProcess } from '../security/process.js';
|
|
4
3
|
import { diagnosticFromError, renderDiagnosticError } from '../errors/index.js';
|
|
5
4
|
|
|
@@ -19,6 +18,54 @@ const help = [
|
|
|
19
18
|
'Exit: 0 clean/verified, 1 unresolved findings or command failure, 2 incomplete/error.',
|
|
20
19
|
''
|
|
21
20
|
].join('\n');
|
|
21
|
+
|
|
22
|
+
async function loadSecurityModules() {
|
|
23
|
+
// Deferred until after any pre-install child command (e.g. npm ci) so the
|
|
24
|
+
// Merkle/TypeScript trust-boundary stack is not required before dependencies exist.
|
|
25
|
+
return import('../security/index.js');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Bootstrap-safe receipt when the child install/build command fails — never import the heavy scan stack. */
|
|
29
|
+
function bootstrapSafeCommandFailureReceipt(result, childArgs) {
|
|
30
|
+
const stdout = result.stdout || '';
|
|
31
|
+
const stderr = result.stderr || '';
|
|
32
|
+
return {
|
|
33
|
+
schema_version: 1,
|
|
34
|
+
ok: false,
|
|
35
|
+
complete: true,
|
|
36
|
+
status: 'command-failed',
|
|
37
|
+
command: childArgs,
|
|
38
|
+
command_exit_code: result.code,
|
|
39
|
+
signal: result.signal || null,
|
|
40
|
+
stdout,
|
|
41
|
+
stderr,
|
|
42
|
+
log: stdout + (stdout && stderr ? '\n' : '') + stderr,
|
|
43
|
+
issues: [`Child command exited with code ${result.code}`],
|
|
44
|
+
findings: [],
|
|
45
|
+
results: [],
|
|
46
|
+
dependency_count: 0,
|
|
47
|
+
checked_count: 0,
|
|
48
|
+
dependency_complete: false,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function formatCommandFailureReport(report) {
|
|
53
|
+
const lines = [
|
|
54
|
+
'Agent Sam · security · COMMAND-FAILED',
|
|
55
|
+
'',
|
|
56
|
+
'Command: ' + (Array.isArray(report.command) ? report.command.join(' ') : String(report.command || '')),
|
|
57
|
+
'Exit code: ' + String(report.command_exit_code),
|
|
58
|
+
];
|
|
59
|
+
if (report.signal) lines.push('Signal: ' + report.signal);
|
|
60
|
+
for (const issue of report.issues || []) lines.push(' ! ' + issue);
|
|
61
|
+
if (report.stderr) {
|
|
62
|
+
lines.push('', 'stderr:', report.stderr.trimEnd());
|
|
63
|
+
} else if (report.stdout) {
|
|
64
|
+
lines.push('', 'stdout:', report.stdout.trimEnd());
|
|
65
|
+
}
|
|
66
|
+
return lines.join('\n') + '\n';
|
|
67
|
+
}
|
|
68
|
+
|
|
22
69
|
export async function runSecurity(argv) {
|
|
23
70
|
const ownArgs = argv.slice(0, argv.indexOf('--') < 0 ? argv.length : argv.indexOf('--'));
|
|
24
71
|
if (ownArgs.includes('--help') || ownArgs.includes('-h') || !argv.length) { process.stdout.write(help); return; }
|
|
@@ -52,13 +99,29 @@ export async function runSecurity(argv) {
|
|
|
52
99
|
const abort = () => controller.abort();
|
|
53
100
|
process.once('SIGINT', abort); process.once('SIGTERM', abort);
|
|
54
101
|
let report;
|
|
102
|
+
let reportExitCode;
|
|
103
|
+
let formatSecurityReport;
|
|
55
104
|
try {
|
|
56
105
|
if (command === 'run') {
|
|
57
106
|
const result = await runProcess(childArgs[0], childArgs.slice(1), { cwd: options.projectRoot || process.cwd(), signal: options.signal });
|
|
58
|
-
|
|
107
|
+
// Child failure must surface as command-failed without importing Merkle/TypeScript.
|
|
108
|
+
if (result.code !== 0) {
|
|
109
|
+
report = bootstrapSafeCommandFailureReceipt(result, childArgs);
|
|
110
|
+
process.stdout.write(options.json ? JSON.stringify(report, null, 2) + '\n' : formatCommandFailureReport(report));
|
|
111
|
+
process.exitCode = 1;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const security = await loadSecurityModules();
|
|
115
|
+
reportExitCode = security.reportExitCode;
|
|
116
|
+
formatSecurityReport = security.formatSecurityReport;
|
|
117
|
+
report = await security.scanProjectSecurity({ ...options, log: result.stdout + '\n' + result.stderr });
|
|
59
118
|
report.command_exit_code = result.code;
|
|
60
|
-
|
|
61
|
-
|
|
119
|
+
} else {
|
|
120
|
+
const security = await loadSecurityModules();
|
|
121
|
+
reportExitCode = security.reportExitCode;
|
|
122
|
+
formatSecurityReport = security.formatSecurityReport;
|
|
123
|
+
report = command === 'repair' ? await security.repairProject(options) : await security.scanProjectSecurity(options);
|
|
124
|
+
}
|
|
62
125
|
} finally {
|
|
63
126
|
process.removeListener('SIGINT', abort); process.removeListener('SIGTERM', abort);
|
|
64
127
|
}
|
package/src/commands/setup.js
CHANGED
|
@@ -18,11 +18,39 @@ import {
|
|
|
18
18
|
RUNTIME_PROFILES,
|
|
19
19
|
} from '../lib/setup/runtime.js';
|
|
20
20
|
import { runRuntime } from './runtime.js';
|
|
21
|
+
import { getCliCommand } from '../cli/command-catalog.js';
|
|
21
22
|
|
|
22
23
|
function writeLine(write, value = '') {
|
|
23
24
|
write(`${value}\n`);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
function catalogCommand(id, args = '') {
|
|
28
|
+
const entry = getCliCommand(id);
|
|
29
|
+
if (!entry) throw new Error(`setup_next_command_not_catalogued: ${id}`);
|
|
30
|
+
return `agentsam ${entry.id}${args ? ` ${args}` : ''}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function setupNextCommands(capabilityIds = []) {
|
|
34
|
+
const commands = [
|
|
35
|
+
catalogCommand('status'),
|
|
36
|
+
catalogCommand('capabilities'),
|
|
37
|
+
catalogCommand('google-cloud', 'doctor'),
|
|
38
|
+
];
|
|
39
|
+
if (capabilityIds.includes('google.cloud')) {
|
|
40
|
+
commands.push(catalogCommand('setup', 'google.cloud --inventory'));
|
|
41
|
+
}
|
|
42
|
+
if (capabilityIds.includes('image.vectorize')) {
|
|
43
|
+
commands.push(catalogCommand('capabilities', 'image.vectorize'));
|
|
44
|
+
}
|
|
45
|
+
return [...new Set(commands)];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function writeSetupNext(write, capabilityIds = []) {
|
|
49
|
+
writeLine(write, ' Next');
|
|
50
|
+
for (const command of setupNextCommands(capabilityIds)) writeLine(write, ` ${command}`);
|
|
51
|
+
writeLine(write, '');
|
|
52
|
+
}
|
|
53
|
+
|
|
26
54
|
function printHelp(write) {
|
|
27
55
|
writeLine(write, '');
|
|
28
56
|
writeLine(write, ' Agent Sam · setup');
|
|
@@ -220,9 +248,9 @@ export async function runSetup(argv = [], options = {}) {
|
|
|
220
248
|
}
|
|
221
249
|
writeLine(write, '');
|
|
222
250
|
writeLine(write, ' Next');
|
|
223
|
-
writeLine(write, '
|
|
224
|
-
writeLine(write, '
|
|
225
|
-
writeLine(write, '
|
|
251
|
+
writeLine(write, ` ${catalogCommand('google-cloud', 'auth login')}`);
|
|
252
|
+
writeLine(write, ` ${catalogCommand('google-cloud', 'connection set --identity EMAIL --project PROJECT')}`);
|
|
253
|
+
writeLine(write, ` ${catalogCommand('google-cloud', 'doctor')}`);
|
|
226
254
|
writeLine(write, '');
|
|
227
255
|
}
|
|
228
256
|
return inv.errors?.length ? 2 : 0;
|
|
@@ -243,8 +271,7 @@ export async function runSetup(argv = [], options = {}) {
|
|
|
243
271
|
if (dryRun || !plan.would_install.length) {
|
|
244
272
|
if (!plan.would_install.length) {
|
|
245
273
|
writeLine(write, ' ✓ setup complete — requested capabilities already satisfied');
|
|
246
|
-
|
|
247
|
-
writeLine(write, '');
|
|
274
|
+
writeSetupNext(write, capabilityIds);
|
|
248
275
|
}
|
|
249
276
|
if (json) write(JSON.stringify({ environment, plan, executed: false }, null, 2) + '\n');
|
|
250
277
|
return 0;
|
|
@@ -262,17 +289,7 @@ export async function runSetup(argv = [], options = {}) {
|
|
|
262
289
|
writeLine(write, receipt.ok ? ' ✓ Agent Sam setup complete' : ' ✕ Setup finished with failures');
|
|
263
290
|
writeLine(write, ` Receipt ${receipt.path}`);
|
|
264
291
|
writeLine(write, '');
|
|
265
|
-
|
|
266
|
-
writeLine(write, ' agentsam doctor');
|
|
267
|
-
writeLine(write, ' agentsam capabilities');
|
|
268
|
-
if (capabilityIds.includes('google.cloud')) {
|
|
269
|
-
writeLine(write, ' agentsam setup google.cloud --inventory');
|
|
270
|
-
writeLine(write, ' agentsam gcloud auth login');
|
|
271
|
-
}
|
|
272
|
-
if (capabilityIds.includes('image.vectorize')) {
|
|
273
|
-
writeLine(write, ' agentsam image optimize ./logo.png # when image command ships');
|
|
274
|
-
}
|
|
275
|
-
writeLine(write, '');
|
|
292
|
+
writeSetupNext(write, capabilityIds);
|
|
276
293
|
|
|
277
294
|
if (json) write(JSON.stringify({ environment, plan, receipt }, null, 2) + '\n');
|
|
278
295
|
return receipt.ok ? 0 : 2;
|
package/src/commands/status.js
CHANGED
|
@@ -4,6 +4,7 @@ import { buildStatusActionPlan } from '../status/actions.js';
|
|
|
4
4
|
import { openExternalUrl } from '../lib/open-url.js';
|
|
5
5
|
import readline from 'node:readline/promises';
|
|
6
6
|
import { stdin as input, stdout as output } from 'node:process';
|
|
7
|
+
import { renderCommandHelp } from '../ui/cli/help.js';
|
|
7
8
|
|
|
8
9
|
function parseStatusArgs(argv = []) {
|
|
9
10
|
const opts = {
|
|
@@ -11,12 +12,14 @@ function parseStatusArgs(argv = []) {
|
|
|
11
12
|
offline: false,
|
|
12
13
|
discoverModels: true,
|
|
13
14
|
interactive: false,
|
|
15
|
+
help: false,
|
|
14
16
|
};
|
|
15
17
|
for (const arg of argv) {
|
|
16
18
|
if (arg === '--json') opts.json = true;
|
|
17
19
|
else if (arg === '--offline') opts.offline = true;
|
|
18
20
|
else if (arg === '--no-discover') opts.discoverModels = false;
|
|
19
21
|
else if (arg === '--interactive' || arg === '-i') opts.interactive = true;
|
|
22
|
+
else if (arg === '--help' || arg === '-h') opts.help = true;
|
|
20
23
|
else throw new Error(`unknown status option: ${arg}`);
|
|
21
24
|
}
|
|
22
25
|
return opts;
|
|
@@ -68,13 +71,17 @@ async function runInteractiveMenu(status, write) {
|
|
|
68
71
|
|
|
69
72
|
export async function runStatus(argv = [], opts = {}) {
|
|
70
73
|
const parsed = parseStatusArgs(argv);
|
|
74
|
+
const write = opts.write || ((value) => process.stdout.write(value));
|
|
75
|
+
if (parsed.help) {
|
|
76
|
+
write(renderCommandHelp('status'));
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
71
79
|
const status = await (opts.collectRuntime || collectRuntimeStatus)({
|
|
72
80
|
...opts,
|
|
73
81
|
cwd: opts.cwd || process.cwd(),
|
|
74
82
|
offline: parsed.offline,
|
|
75
83
|
discoverModels: parsed.discoverModels,
|
|
76
84
|
});
|
|
77
|
-
const write = opts.write || ((value) => process.stdout.write(value));
|
|
78
85
|
if (parsed.json) {
|
|
79
86
|
const plan = buildStatusActionPlan(status);
|
|
80
87
|
write(`${JSON.stringify({ ...status, next: plan }, null, 2)}\n`);
|
package/src/features/resolve.js
CHANGED
|
@@ -39,6 +39,7 @@ export function normalizeProviderTemplateId(id) {
|
|
|
39
39
|
if (!key) return '';
|
|
40
40
|
if (key === 'iam') return 'inneranimalmedia';
|
|
41
41
|
if (key === 'google-desktop') return 'google_desktop';
|
|
42
|
+
if (key === 'openai' || key === 'chatgpt-hosted' || key === 'chatgpt_hosted') return 'chatgpt';
|
|
42
43
|
return key;
|
|
43
44
|
}
|
|
44
45
|
|
package/src/knowledge/engine.js
CHANGED
|
@@ -59,7 +59,7 @@ export async function planIndex({ root, config: input, store, embed = false, lim
|
|
|
59
59
|
limits: Number.isFinite(maxFiles) || Number.isFinite(maxChunks) ? { max_files: maxFiles, max_chunks: maxChunks } : null } };
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export async function runIndex({ root, config, store, embedder, embed = false, maxInputs = 100, maxCharacters = 200000, limits = null }) {
|
|
62
|
+
export async function runIndex({ root, config, store, embedder, embed = false, vectorBackend = null, vectorContext = {}, maxInputs = 100, maxCharacters = 200000, limits = null }) {
|
|
63
63
|
if (!store) throw new Error('A writable knowledge store is required.');
|
|
64
64
|
if (!Number.isInteger(maxInputs) || maxInputs < 0 || !Number.isInteger(maxCharacters) || maxCharacters < 0) throw new Error('Embedding budgets must be nonnegative integers.');
|
|
65
65
|
const plan = await planIndex({ root, config, store, embed, limits });
|
|
@@ -76,6 +76,25 @@ export async function runIndex({ root, config, store, embedder, embed = false, m
|
|
|
76
76
|
// Completed work remains reusable even if a later request or publication fails.
|
|
77
77
|
await store.cachePut(key, vector);
|
|
78
78
|
}
|
|
79
|
+
let vectorUpsert = null;
|
|
80
|
+
if (embed && plan.config.lane?.backend === 'cloudflare_vectorize') {
|
|
81
|
+
if (!vectorBackend?.upsert) throw new Error('cloudflare_vectorize_backend_required');
|
|
82
|
+
const records = [];
|
|
83
|
+
for (const chunk of plan.chunks) {
|
|
84
|
+
const vector = validateVector(await store.cacheGet(chunk.embedding_key), plan.config.embedding.dimensions);
|
|
85
|
+
records.push({
|
|
86
|
+
id: chunk.id,
|
|
87
|
+
vector,
|
|
88
|
+
metadata: { path: chunk.path, ordinal: chunk.ordinal, content_hash: chunk.content_hash },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
vectorUpsert = await vectorBackend.upsert(records, {
|
|
92
|
+
...vectorContext,
|
|
93
|
+
binding: plan.config.lane.binding,
|
|
94
|
+
index: plan.config.lane.index,
|
|
95
|
+
profile: { ...plan.config.lane, dimensions: plan.config.embedding.dimensions },
|
|
96
|
+
});
|
|
97
|
+
}
|
|
79
98
|
// A generation describes one coherent source snapshot. Never publish after a mid-run edit.
|
|
80
99
|
const check = [];
|
|
81
100
|
const checkFiles = inventory(root, plan.config.scope).slice(0, limits?.maxFiles == null ? Infinity : limits.maxFiles);
|
|
@@ -85,7 +104,7 @@ export async function runIndex({ root, config, store, embedder, embed = false, m
|
|
|
85
104
|
source_hash: receipt.source_hash, config_hash: receipt.config_hash, config: plan.config, profile_id: receipt.profile_id,
|
|
86
105
|
git: gitEvidence(root), files: plan.files, chunks: plan.chunks, symbols: plan.symbols, edges: plan.edges, receipt };
|
|
87
106
|
await store.publish(generation, plan.previous?.id || null);
|
|
88
|
-
return { ...receipt, generation_id: generation.id, published: true };
|
|
107
|
+
return { ...receipt, generation_id: generation.id, published: true, vector_upsert: vectorUpsert };
|
|
89
108
|
}
|
|
90
109
|
|
|
91
110
|
export async function retrieve({ store, config: input, text, semantic = false, embedder, topK = 8, tokenBudget = 6000, generationId, resultPolicy: requestedResultPolicy }) {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readCloudflareDeploymentContract } from '../cloudflare/runtime-status.js';
|
|
4
|
+
import { getRepositoryId, portableRepositoryIdFromGit, tryReadProjectConfig } from '../lib/project-config.js';
|
|
5
|
+
import { resolveProviderCredential } from '../lib/provider-credentials.js';
|
|
6
|
+
import { tryResolveGitContext } from '../../packages/agentsam-repository/src/git-context.js';
|
|
7
|
+
|
|
8
|
+
export const PROJECT_CONTEXT_SCHEMA = 'agentsam.project-context.v1';
|
|
9
|
+
const clean = value => value == null ? '' : String(value).trim();
|
|
10
|
+
const localIndexPath = root => path.join(root, '.agentsam', 'knowledge', 'index.sqlite');
|
|
11
|
+
function readJson(filename) { try { return JSON.parse(fs.readFileSync(filename, 'utf8')); } catch { return null; } }
|
|
12
|
+
function executionState({ observed = false, selected = false, local = false, remote = false, conflicting = false, source = null, reason = null } = {}) {
|
|
13
|
+
return { observed: Boolean(observed), explicitly_selected: Boolean(selected), locally_executable: Boolean(local), remotely_executable: Boolean(remote), missing: !observed, conflicting: Boolean(conflicting), source: source || null, reason: reason || null };
|
|
14
|
+
}
|
|
15
|
+
function cloudflareCredentialState(env) {
|
|
16
|
+
try {
|
|
17
|
+
const credential = resolveProviderCredential('cloudflare', { env });
|
|
18
|
+
const configured = Boolean(credential?.configured);
|
|
19
|
+
const accountResolved = Boolean(clean(credential?.account_id));
|
|
20
|
+
return { configured, account_resolved: accountResolved, executable: configured && accountResolved, source: credential?.source || null, error: credential?.error || (!configured ? 'cloudflare_authorization_required' : !accountResolved ? 'cloudflare_account_id_required' : null) };
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return { configured: false, account_resolved: false, executable: false, source: null, error: error?.message || String(error) };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function policyConflict(policy, vectorize) {
|
|
26
|
+
if (policy?.lane?.backend !== 'cloudflare_vectorize') return [];
|
|
27
|
+
const binding = clean(policy.lane.binding), index = clean(policy.lane.index);
|
|
28
|
+
if (vectorize.some(row => row.binding === binding && row.index === index)) return [];
|
|
29
|
+
return [{ kind: 'knowledge_deployment_drift', backend: 'cloudflare_vectorize', policy: { binding: binding || null, index: index || null }, observed: vectorize.map(row => ({ binding: row.binding, index: row.index })), detail: 'Knowledge policy selects a Vectorize binding/index that is not declared by the active Wrangler deployment contract.' }];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function discoverProjectContext(root = process.cwd(), options = {}) {
|
|
33
|
+
const resolvedRoot = fs.realpathSync(path.resolve(root));
|
|
34
|
+
const env = options.env || process.env;
|
|
35
|
+
const policy = options.knowledgeConfig || null;
|
|
36
|
+
const projectConfig = options.projectConfig || tryReadProjectConfig(resolvedRoot);
|
|
37
|
+
const git = tryResolveGitContext({ cwd: resolvedRoot });
|
|
38
|
+
const repositoryId = getRepositoryId(projectConfig) || portableRepositoryIdFromGit(resolvedRoot) || `local:${path.basename(resolvedRoot)}`;
|
|
39
|
+
const hostInstallPath = path.join(resolvedRoot, '.agentsam', 'app.json');
|
|
40
|
+
const hostInstall = fs.existsSync(hostInstallPath) ? readJson(hostInstallPath) : null;
|
|
41
|
+
const productManifestPath = path.join(resolvedRoot, 'agentsam.app.json');
|
|
42
|
+
const productManifest = fs.existsSync(productManifestPath) ? readJson(productManifestPath) : null;
|
|
43
|
+
let contract = null, contractError = null;
|
|
44
|
+
try { contract = readCloudflareDeploymentContract(resolvedRoot, projectConfig || {}); } catch (error) { contractError = error?.message || String(error); }
|
|
45
|
+
const bindings = contract?.bindings || [];
|
|
46
|
+
const ai = bindings.find(row => row.type === 'ai') || null;
|
|
47
|
+
const vectorize = bindings.filter(row => row.type === 'vectorize').map(row => ({ binding: row.name, index: row.index_name || null, source: row.source || 'wrangler_config' }));
|
|
48
|
+
const d1 = bindings.filter(row => row.type === 'd1');
|
|
49
|
+
const r2 = bindings.filter(row => row.type === 'r2_bucket');
|
|
50
|
+
const credential = cloudflareCredentialState(env);
|
|
51
|
+
const remoteConfigured = Boolean(contract?.configured);
|
|
52
|
+
const conflicts = policyConflict(policy, vectorize);
|
|
53
|
+
const indexPath = localIndexPath(resolvedRoot);
|
|
54
|
+
const localIndex = { exists: fs.existsSync(indexPath), path: path.relative(resolvedRoot, indexPath) };
|
|
55
|
+
const policyBinding = clean(policy?.lane?.binding), policyIndex = clean(policy?.lane?.index);
|
|
56
|
+
const vectorizeResources = vectorize.map(row => {
|
|
57
|
+
const selected = policy?.lane?.backend === 'cloudflare_vectorize' && row.binding === policyBinding && row.index === policyIndex;
|
|
58
|
+
return {
|
|
59
|
+
...row,
|
|
60
|
+
configured: Boolean(row.binding && row.index),
|
|
61
|
+
...executionState({
|
|
62
|
+
observed: Boolean(row.binding && row.index), selected,
|
|
63
|
+
local: Boolean(row.binding && row.index && credential.executable),
|
|
64
|
+
remote: Boolean(row.binding && row.index && remoteConfigured),
|
|
65
|
+
conflicting: conflicts.length > 0 && !selected,
|
|
66
|
+
source: row.source,
|
|
67
|
+
reason: credential.executable ? null : 'Local CLI/Desktop Vectorize execution requires the current user Cloudflare authorization and account id.',
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const workersAi = ai ? {
|
|
72
|
+
binding: ai.name, configured: true, credential_state: credential,
|
|
73
|
+
...executionState({ observed: true, selected: policy?.embedding?.provider === 'workers-ai', local: false, remote: remoteConfigured, source: ai.source || 'wrangler_config', reason: 'Workers AI binding is executable in the configured Worker runtime; a local Node process does not possess env.<AI_BINDING>.' }),
|
|
74
|
+
} : {
|
|
75
|
+
binding: null, configured: false, credential_state: credential,
|
|
76
|
+
...executionState({ observed: false, source: contract?.config || null, reason: 'No Workers AI binding declared.' }),
|
|
77
|
+
};
|
|
78
|
+
const mapBoundResource = row => ({
|
|
79
|
+
binding: row.name,
|
|
80
|
+
name: row.database_name || row.bucket_name || null,
|
|
81
|
+
id: row.database_id || null,
|
|
82
|
+
...executionState({ observed: true, local: false, remote: remoteConfigured, source: row.source || 'wrangler_config', reason: 'This receipt describes runtime binding execution; local provider API execution is a separate authorized transport.' }),
|
|
83
|
+
});
|
|
84
|
+
const lanes = [];
|
|
85
|
+
if (localIndex.exists) lanes.push({ id: 'local-index', backend: 'local_exact', source: 'local_index', configured: true, locally_executable: true, remotely_executable: false });
|
|
86
|
+
for (const row of vectorizeResources) lanes.push({ id: `cloudflare-vectorize:${row.binding}`, backend: 'cloudflare_vectorize', binding: row.binding, index: row.index, source: row.source, configured: row.configured, locally_executable: row.locally_executable, remotely_executable: row.remotely_executable, explicitly_selected: row.explicitly_selected, conflicting: row.conflicting });
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
schema: PROJECT_CONTEXT_SCHEMA,
|
|
90
|
+
version: 1,
|
|
91
|
+
repository: { root: resolvedRoot, identity: repositoryId, branch: git?.branch || null, revision: git?.revisionSha || null, dirty: git?.dirty ?? null, source: git ? 'git' : projectConfig ? '.agentsam/config.json' : 'filesystem' },
|
|
92
|
+
project: {
|
|
93
|
+
config_present: Boolean(projectConfig), config_source: projectConfig ? '.agentsam/config.json' : null,
|
|
94
|
+
product_manifest: productManifest ? { id: clean(productManifest.id) || null, source: 'agentsam.app.json' } : null,
|
|
95
|
+
host_install: hostInstall ? { app_id: clean(hostInstall.app_id || hostInstall.id) || null, name: clean(hostInstall.name) || null, role: clean(hostInstall.role) || null, mounts: hostInstall.mounts || null, schema: clean(hostInstall.schema) || null, source: '.agentsam/app.json' } : null,
|
|
96
|
+
},
|
|
97
|
+
deployment: { configured: remoteConfigured, worker_name: contract?.worker_name || null, config: contract?.config || null, error: contractError },
|
|
98
|
+
knowledge: {
|
|
99
|
+
policy_configured: Boolean(policy), policy_source: policy ? '.agentsam/knowledge.json' : null,
|
|
100
|
+
selected_backend: policy?.lane?.backend || null,
|
|
101
|
+
suggested_backend: !policy && vectorizeResources.length === 1 ? 'cloudflare_vectorize' : (!policy ? 'local_exact' : null),
|
|
102
|
+
local_index: { ...localIndex, ...executionState({ observed: localIndex.exists, selected: policy?.lane?.backend === 'local_exact', local: localIndex.exists, remote: false, source: localIndex.exists ? localIndex.path : null, reason: localIndex.exists ? null : 'No local knowledge SQLite index exists.' }) },
|
|
103
|
+
},
|
|
104
|
+
authorization: { cloudflare: credential },
|
|
105
|
+
resources: {
|
|
106
|
+
workers_ai: workersAi,
|
|
107
|
+
vectorize: vectorizeResources,
|
|
108
|
+
d1: d1.map(mapBoundResource),
|
|
109
|
+
r2: r2.map(mapBoundResource),
|
|
110
|
+
},
|
|
111
|
+
conflicts,
|
|
112
|
+
local_index: localIndex,
|
|
113
|
+
cloudflare: {
|
|
114
|
+
configured: remoteConfigured,
|
|
115
|
+
worker_name: contract?.worker_name || null,
|
|
116
|
+
config: contract?.config || null,
|
|
117
|
+
ai_binding: ai?.name || null,
|
|
118
|
+
vectorize: vectorizeResources.map(row => ({ binding: row.binding, index: row.index, source: row.source })),
|
|
119
|
+
error: contractError,
|
|
120
|
+
},
|
|
121
|
+
lanes,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function discoverKnowledgeRuntime(root = process.cwd(), options = {}) {
|
|
126
|
+
return discoverProjectContext(root, options);
|
|
127
|
+
}
|