@inneranimalmedia/agentsam-sdk 2.6.5 → 2.6.8
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/README.md +37 -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/REPO_FILE_MAP.txt +132 -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/migrations/d1/0018_goap_control_plane_remaster.sql +40 -0
- package/migrations/d1/0019_agentsam_agent_run_plan_todo.sql +14 -0
- package/migrations/d1/README_PORTABLE_CONTROL_PLANE.md +20 -9
- package/migrations/runtime/0002_goap_blackboard_v1.sql +15 -0
- package/migrations/runtime/0004_agent_run_plan_linkage.sql +8 -0
- package/native/agentsam-machine/Cargo.lock +426 -0
- package/native/agentsam-machine/Cargo.toml +9 -0
- package/native/agentsam-machine/cli/Cargo.toml +21 -0
- package/native/agentsam-machine/cli/README.md +21 -0
- package/native/agentsam-machine/cli/src/main.rs +77 -0
- package/native/agentsam-machine/core/Cargo.toml +22 -0
- package/native/agentsam-machine/core/README.md +14 -0
- package/native/agentsam-machine/core/build.rs +33 -0
- package/native/agentsam-machine/core/contracts/source-types.v1.json +353 -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 +1092 -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 +64 -24
- 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-errors/src/index.js +1 -0
- package/packages/agentsam-errors/src/tool.js +56 -0
- package/packages/agentsam-errors/test/tool.test.mjs +58 -0
- package/packages/agentsam-goap/README.md +52 -0
- package/packages/agentsam-goap/package.json +37 -0
- package/packages/agentsam-goap/src/adapters/d1-sqlite.js +570 -0
- package/packages/agentsam-goap/src/adapters/memory.js +199 -0
- package/packages/agentsam-goap/src/contracts.js +226 -0
- package/packages/agentsam-goap/src/control-plane.js +112 -0
- package/packages/agentsam-goap/src/errors.js +157 -0
- package/packages/agentsam-goap/src/index.js +5 -0
- package/packages/agentsam-goap/src/world.js +202 -0
- package/packages/agentsam-goap/test/goap-control-plane.test.mjs +245 -0
- package/packages/agentsam-goap/test/world.test.mjs +79 -0
- 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/dist/browser.global.js +21 -18
- package/packages/agentsam-nav/dist/browser.js +6807 -130
- package/packages/agentsam-nav/dist/index.js +6799 -122
- 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/goap.js +13 -14
- package/packages/agentsam-repository/src/source-types.js +8 -0
- package/packages/agentsam-repository/src/tickets.js +15 -22
- package/packages/agentsam-repository/test/goap-tickets-workspace-state.test.mjs +19 -8
- 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 +15 -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/python/agentsam_sdk/repository/intelligence/discovery.py +27 -2
- package/python/agentsam_sdk/repository/intelligence/git.py +4 -0
- package/python/tests/test_repository_intelligence.py +30 -0
- package/src/cli/command-catalog.js +48 -5
- package/src/cli/dispatch.js +1 -0
- package/src/cli.js +20 -1
- 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/goap-world.js +134 -0
- package/src/commands/goap.js +11 -4
- package/src/commands/knowledge.js +59 -2
- package/src/commands/machine-binary.js +109 -0
- package/src/commands/machine-runtime.js +266 -0
- package/src/commands/machine.js +208 -0
- package/src/commands/package.js +530 -0
- package/src/commands/plan-ledger.js +370 -0
- package/src/commands/plan.js +183 -0
- package/src/commands/security.js +67 -4
- package/src/commands/setup.js +33 -16
- package/src/commands/skill.js +78 -17
- 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/knowledge/source.js +1 -1
- package/src/lib/identity-scaffold.js +53 -13
- package/src/lib/setup/recipes.js +1 -1
- package/src/lib/slash-commands.js +1 -1
- package/src/local/runtime-store.js +24 -2
- package/src/local/sqlite.js +17 -0
- 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/sam/operations/package-audit.js +41 -0
- package/src/sam/seed.js +2 -0
- package/src/security/logs.js +3 -0
- package/src/ui/cli/help.js +41 -0
- package/apps/client-cms-editor/backend/src/demo-bootstrap.ts +0 -145
- package/test/account-session.test.mjs +0 -101
- package/test/agent-capabilities.test.mjs +0 -67
- package/test/app-authority-context.test.mjs +0 -32
- package/test/app-building-skills.test.mjs +0 -61
- package/test/apps-scaffold-contract.test.mjs +0 -114
- package/test/blender-cad.test.mjs +0 -146
- package/test/cad-docker.test.mjs +0 -96
- package/test/capabilities.test.mjs +0 -133
- package/test/cli/api-key-env-whoami.test.mjs +0 -129
- package/test/cli/codebaseindex-plan-ux.test.mjs +0 -37
- package/test/cli/eval-live.test.mjs +0 -219
- package/test/cli/go.test.mjs +0 -128
- package/test/cli/local-vault-and-provider-setup.test.mjs +0 -268
- package/test/cli/mcp-client.test.mjs +0 -256
- package/test/cli/preferences-runtime.test.mjs +0 -11
- package/test/cli/runtime-persist.test.mjs +0 -56
- package/test/cli/runtime-ui.test.mjs +0 -141
- package/test/cli/rust-command.test.mjs +0 -21
- package/test/cli/skill-npm-and-env.test.mjs +0 -52
- package/test/cli/status-actions.test.mjs +0 -88
- package/test/cli/wireframes-go-registry.test.mjs +0 -139
- package/test/cli-preferences.test.mjs +0 -46
- package/test/cloudflare-connector.test.mjs +0 -93
- package/test/cloudflare-runtime.test.mjs +0 -82
- package/test/context.test.mjs +0 -159
- package/test/credentials-audit.test.mjs +0 -113
- package/test/deploy-health-scan.test.mjs +0 -95
- package/test/deploy-receipt.test.mjs +0 -91
- package/test/dockerize.test.mjs +0 -93
- package/test/error-diagnostics.test.mjs +0 -124
- package/test/eval-context.test.mjs +0 -37
- package/test/execution-approvals.test.mjs +0 -27
- package/test/fixtures/cad/courtyard-house.json +0 -208
- package/test/fixtures/knowledge-rpc-worker.mjs +0 -16
- package/test/gcloud-auth.test.mjs +0 -111
- package/test/go/build-source-identity.test.mjs +0 -31
- package/test/go/cloudflare-probe.test.mjs +0 -317
- package/test/go/distribution.test.mjs +0 -28
- package/test/google-cloud-connection.test.mjs +0 -83
- package/test/google-cloud-inventory.test.mjs +0 -64
- package/test/indexing-provider.test.mjs +0 -29
- package/test/init-options.test.mjs +0 -35
- package/test/integration/ai-access-onboarding.test.mjs +0 -47
- package/test/integration/app-command.test.mjs +0 -85
- package/test/integration/cad-discovery.test.mjs +0 -158
- package/test/integration/cad-docker-executor.test.mjs +0 -249
- package/test/integration/cad-execution.test.mjs +0 -184
- package/test/integration/cad-project-app.test.mjs +0 -31
- package/test/integration/cad-project-d1.test.mjs +0 -25
- package/test/integration/cad-project-native.test.mjs +0 -24
- package/test/integration/cad-project-workflow.test.mjs +0 -9
- package/test/integration/cad-project.test.mjs +0 -85
- package/test/integration/cli-help.test.mjs +0 -41
- package/test/integration/cms-app-scaffold.test.mjs +0 -71
- package/test/integration/cms-site-tenancy-contract.test.mjs +0 -257
- package/test/integration/codebaseindex-ingest.test.mjs +0 -214
- package/test/integration/core-client.integration.test.mjs +0 -55
- package/test/integration/error-runtime-rpc.test.mjs +0 -71
- package/test/integration/features-resolve.test.mjs +0 -147
- package/test/integration/icon-registry.test.mjs +0 -67
- package/test/integration/ingest-discover-models.test.mjs +0 -30
- package/test/integration/inspect-path-cli.test.mjs +0 -46
- package/test/integration/install-script.test.mjs +0 -110
- package/test/integration/inventory-core.test.mjs +0 -53
- package/test/integration/inventory-evidence.test.mjs +0 -125
- package/test/integration/knowledge-rpc.test.mjs +0 -112
- package/test/integration/local-fs.test.mjs +0 -113
- package/test/integration/merkle-cli.test.mjs +0 -61
- package/test/integration/merkle-persistence-identity.test.mjs +0 -48
- package/test/integration/plugins-cloudflare.integration.test.mjs +0 -28
- package/test/integration/provider-env-cli.test.mjs +0 -50
- package/test/integration/provider-factory.test.mjs +0 -197
- package/test/integration/repository-company-graph.test.mjs +0 -90
- package/test/integration/runtime-migrations.test.mjs +0 -87
- package/test/integration/runtime-status.integration.test.mjs +0 -212
- package/test/integration/sam-activity-recovery.test.mjs +0 -147
- package/test/integration/sam-decision.test.mjs +0 -584
- package/test/integration/sam-kernel.test.mjs +0 -99
- package/test/integration/sam-planning-astar.test.mjs +0 -279
- package/test/integration/scaffold-cloudflare.test.mjs +0 -46
- package/test/integration/skill-runtime.test.mjs +0 -240
- package/test/integration/storage-architecture.test.mjs +0 -154
- package/test/integration/store-discovery.test.mjs +0 -44
- package/test/integration/studio-fs-pty-e2e.test.mjs +0 -294
- package/test/integration/terminal-exec.integration.test.mjs +0 -86
- package/test/integration/tool-runtime.test.mjs +0 -124
- package/test/integration/tool-schema.test.mjs +0 -59
- package/test/jr-dev-skill.test.mjs +0 -26
- package/test/knowledge-context-pack.test.mjs +0 -19
- package/test/knowledge-postgres.test.mjs +0 -40
- package/test/knowledge-service.test.mjs +0 -110
- package/test/knowledge.test.mjs +0 -206
- package/test/live/terminal-transport.live.test.mjs +0 -24
- package/test/local-sessions.test.mjs +0 -57
- package/test/local-studio-deploy.test.mjs +0 -83
- package/test/loopback-oauth.test.mjs +0 -53
- package/test/merkle-render.test.mjs +0 -31
- package/test/mini.test.mjs +0 -140
- package/test/model-catalog.test.mjs +0 -70
- package/test/models.test.mjs +0 -309
- package/test/npm10-lock.test.mjs +0 -29
- package/test/ollama.test.mjs +0 -137
- package/test/open-url.test.mjs +0 -64
- package/test/openai-responses.test.mjs +0 -155
- package/test/portable-context.test.mjs +0 -94
- package/test/project-config.test.mjs +0 -81
- package/test/project-rules.test.mjs +0 -44
- package/test/provider-credentials.test.mjs +0 -106
- package/test/rehydrate.test.mjs +0 -25
- package/test/release-hygiene.test.mjs +0 -42
- package/test/repository-snapshot-view.test.mjs +0 -112
- package/test/responses-runner.test.mjs +0 -465
- package/test/runtime-activity.test.mjs +0 -98
- package/test/sdk-worker-contract.test.mjs +0 -72
- package/test/security.test.mjs +0 -252
- package/test/setup-planner.test.mjs +0 -74
- package/test/setup-runtime.test.mjs +0 -51
- package/test/shell.test.mjs +0 -281
- package/test/skills.test.mjs +0 -22
- package/test/smoke.mjs +0 -122
- package/test/telemetry.test.mjs +0 -79
- package/test/terminal/local-pty.mock.test.mjs +0 -153
- package/test/terminal-machine-identity.test.mjs +0 -88
- package/test/theme-portability.test.mjs +0 -14
- package/test/tools-search.test.mjs +0 -73
- package/test/unit/website-assets-bindings.test.mjs +0 -60
- package/test/whoami-resume.test.mjs +0 -157
package/src/commands/autorag.js
CHANGED
|
@@ -2,10 +2,12 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { parseArgs } from 'node:util';
|
|
4
4
|
import { createInterface } from 'node:readline/promises';
|
|
5
|
-
import { repositoryRoot, readConfig, validateConfig, CONFIG_PATH } from '../knowledge/config.js';
|
|
5
|
+
import { repositoryRoot, readConfig, validateConfig, defaultConfig, scopeKey, CONFIG_PATH } from '../knowledge/config.js';
|
|
6
6
|
import { openSqliteStore } from '../knowledge/stores/sqlite.js';
|
|
7
7
|
import { openPostgresStore } from '../knowledge/stores/postgres.js';
|
|
8
8
|
import { planIndex, runIndex, retrieve } from '../knowledge/engine.js';
|
|
9
|
+
import { discoverKnowledgeRuntime } from '../knowledge/runtime-discovery.js';
|
|
10
|
+
import { getRepositoryId, portableRepositoryIdFromGit, tryReadProjectConfig } from '../lib/project-config.js';
|
|
9
11
|
import { discoverAutoRag, recommendAutoRag, safeAutoRagConfig, runAutoRagProbe, createProviderRegistry, createBackendRegistry } from '../../packages/agentsam-knowledge/src/index.js';
|
|
10
12
|
|
|
11
13
|
const show = value => console.log(JSON.stringify(value, null, 2));
|
|
@@ -16,6 +18,12 @@ const parse = argv => parseArgs({ args: argv, allowPositionals: true, options: {
|
|
|
16
18
|
kind: { type: 'string' }, scope: { type: 'string' }, provider: { type: 'string' }, backend: { type: 'string' }, model: { type: 'string' }, dimensions: { type: 'string' }, semantic: { type: 'boolean' }, 'allow-paid': { type: 'boolean' }, query: { type: 'string' },
|
|
17
19
|
} });
|
|
18
20
|
function readExisting(root) { try { return readConfig(root); } catch (error) { if (error.code === 'ENOENT') return null; throw error; } }
|
|
21
|
+
function generationConfig(root, existing) {
|
|
22
|
+
if (existing) return existing;
|
|
23
|
+
const project = tryReadProjectConfig(root);
|
|
24
|
+
const repositoryId = getRepositoryId(project) || portableRepositoryIdFromGit(root);
|
|
25
|
+
return repositoryId ? defaultConfig({ repositoryId }) : null;
|
|
26
|
+
}
|
|
19
27
|
function writeConfig(root, config) {
|
|
20
28
|
const filename = path.join(root, CONFIG_PATH); fs.mkdirSync(path.dirname(filename), { recursive: true, mode: 0o700 });
|
|
21
29
|
const safe = JSON.stringify(validateConfig(config), null, 2) + '\n';
|
|
@@ -28,10 +36,20 @@ function adapterFor(config) {
|
|
|
28
36
|
return { validate: profile => adapter.validate(profile), async embed(text, profile, context) { return context?.kind === 'query' ? adapter.embedQuery(text, profile, context) : (await adapter.embedDocuments([text], profile, context))[0]; } };
|
|
29
37
|
}
|
|
30
38
|
async function storeFor(root, config, readOnly = false) { return config.storage.driver === 'sqlite' ? openSqliteStore(localPath(root), { readOnly }) : openPostgresStore(process.env[config.storage.connection_env]); }
|
|
31
|
-
function defaults(discovery, opts, existing) {
|
|
39
|
+
function defaults(discovery, opts, existing, runtime) {
|
|
32
40
|
const purpose = opts.kind || existing?.scope?.name || 'code';
|
|
33
|
-
const
|
|
41
|
+
const declaredVectorize = (runtime?.cloudflare?.vectorize || []).filter(row => row.binding && row.index);
|
|
42
|
+
const adoptVectorize = !opts.backend && !existing?.lane?.backend && declaredVectorize.length === 1;
|
|
43
|
+
const backend = opts.backend || existing?.lane?.backend || (adoptVectorize ? 'cloudflare_vectorize' : 'local_exact');
|
|
44
|
+
const recommendation = recommendAutoRag({ discovery, purpose, include: opts.scope ? split(opts.scope) : existing?.scope?.include, provider: opts.provider || 'none', backend, semantic: Boolean(opts.semantic) });
|
|
34
45
|
const config = safeAutoRagConfig({ existing: existing || {}, recommendation, repositoryId: existing?.repository_id || discovery.repository.identity, projectKey: existing?.project_key || discovery.repository.identity });
|
|
46
|
+
if (adoptVectorize) {
|
|
47
|
+
const resource = declaredVectorize[0];
|
|
48
|
+
config.lane.id = `${purpose}-cloudflare-vectorize`;
|
|
49
|
+
config.lane.backend = 'cloudflare_vectorize';
|
|
50
|
+
config.lane.binding = resource.binding;
|
|
51
|
+
config.lane.index = resource.index;
|
|
52
|
+
}
|
|
35
53
|
if (opts.provider) {
|
|
36
54
|
const models = { fixture: 'deterministic', gemini: 'gemini-embedding-2', openai: 'text-embedding-3-small', 'workers-ai': '@cf/baai/bge-base-en-v1.5', ollama: 'nomic-embed-text' };
|
|
37
55
|
config.embedding = opts.provider === 'none' ? { provider: 'none', model: 'none', revision: '1', dimensions: 0, parameters: {} } : { provider: opts.provider, model: opts.model || models[opts.provider] || '', revision: '1', dimensions: Number(opts.dimensions || (opts.provider === 'fixture' ? 3 : 768)), parameters: { task: 'code retrieval' } };
|
|
@@ -43,7 +61,7 @@ async function interactiveOptions(discovery, opts) {
|
|
|
43
61
|
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
44
62
|
try {
|
|
45
63
|
const kind = opts.kind || await prompt.question('What kind of knowledge? code, documents, schema, media, memory, mixed [code]: ') || 'code';
|
|
46
|
-
const suggested =
|
|
64
|
+
const suggested = recommendAutoRag({ discovery, purpose: kind }).scope.join(',');
|
|
47
65
|
const scope = opts.scope || await prompt.question(`Sources (literal paths, comma separated) [${suggested || '.'}]: `) || suggested || '.';
|
|
48
66
|
const semantic = opts.semantic || (await prompt.question('Enable semantic embeddings for this setup? [no]: ')).toLowerCase() === 'yes';
|
|
49
67
|
const provider = opts.provider || (semantic ? await prompt.question('Provider: fixture, gemini, openai, workers-ai, ollama [fixture]: ') || 'fixture' : 'none');
|
|
@@ -55,18 +73,54 @@ export async function runAutoRag(argv) {
|
|
|
55
73
|
if (opts.help || !['setup', 'status', 'doctor', 'lanes', 'configure', 'probe', 'providers', 'backends', 'scope'].includes(command)) {
|
|
56
74
|
console.log('agentsam autorag setup|status|doctor|lanes|configure|probe|providers|backends|scope [--cwd PATH] [--yes] [--kind code|documents|schema|media|memory|mixed] [--scope a,b] [--provider none|fixture|gemini|openai|workers-ai|ollama] [--backend local_exact|postgres_pgvector|supabase_pgvector|cloudflare_vectorize] [--semantic]'); return;
|
|
57
75
|
}
|
|
58
|
-
const root = repositoryRoot(opts.cwd); const discovery = await discoverAutoRag({ root }); const existing = readExisting(root);
|
|
59
|
-
if (command === 'providers')
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
const root = repositoryRoot(opts.cwd); const discovery = await discoverAutoRag({ root }); const existing = readExisting(root); const runtime = discoverKnowledgeRuntime(root, { knowledgeConfig: existing });
|
|
77
|
+
if (command === 'providers') {
|
|
78
|
+
const providers = await createProviderRegistry().capabilities();
|
|
79
|
+
const workersAi = runtime.resources.workers_ai;
|
|
80
|
+
return show(providers.map(item => item.id === 'workers-ai'
|
|
81
|
+
? { ...item, runtime_configured: workersAi.configured, runtime_binding: workersAi.binding, locally_executable: workersAi.locally_executable, remotely_executable: workersAi.remotely_executable, credential_state: workersAi.credential_state }
|
|
82
|
+
: item));
|
|
83
|
+
}
|
|
84
|
+
if (command === 'backends') {
|
|
85
|
+
const backends = createBackendRegistry().capabilities();
|
|
86
|
+
const vectorize = runtime.resources.vectorize;
|
|
87
|
+
return show(backends.map(item => item.id === 'cloudflare_vectorize'
|
|
88
|
+
? { ...item, declared_resources: vectorize, locally_executable: vectorize.some(row => row.locally_executable), remotely_executable: vectorize.some(row => row.remotely_executable), conflicts: runtime.conflicts }
|
|
89
|
+
: item));
|
|
90
|
+
}
|
|
91
|
+
if (command === 'status') {
|
|
92
|
+
const generationProfile = runtime.local_index.exists ? generationConfig(root, existing) : null;
|
|
93
|
+
const generation = generationProfile ? await (async () => {
|
|
94
|
+
const store = await storeFor(root, generationProfile, true);
|
|
95
|
+
try { return await store?.active(scopeKey(generationProfile)); }
|
|
96
|
+
finally { await store?.close(); }
|
|
97
|
+
})() : null;
|
|
98
|
+
return show({ discovery, config: existing || null, project_context: runtime, runtime, generation });
|
|
99
|
+
}
|
|
62
100
|
if (command === 'doctor') {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
101
|
+
const hasRuntimeLane = runtime.lanes.some(lane => lane.configured);
|
|
102
|
+
const checks = [
|
|
103
|
+
{ check: 'knowledge_authority', ok: Boolean(existing) || hasRuntimeLane, detail: existing ? CONFIG_PATH : hasRuntimeLane ? 'Detected repository knowledge runtime.' : 'No local config or declared runtime lane found.' },
|
|
104
|
+
{ check: 'local_sqlite', ok: runtime.local_index.exists, blocking: false, detail: runtime.local_index.exists ? runtime.local_index.path : 'Not indexed yet; run agentsam index run or agentsam autorag probe.' },
|
|
105
|
+
{ check: 'git_merkle', ok: discovery.repository.merkle, blocking: false, detail: discovery.repository.merkle ? '.agentsam/merkle.json' : 'No Merkle snapshot yet; run agentsam merkle root . --json when snapshot evidence is needed.' },
|
|
106
|
+
];
|
|
107
|
+
if (existing?.embedding && existing.embedding.provider !== 'none') {
|
|
108
|
+
try { adapterFor(existing).validate(existing.embedding); checks.push({ check: 'provider:' + existing.embedding.provider, ok: true }); }
|
|
109
|
+
catch (error) { checks.push({ check: 'provider:' + existing.embedding.provider, ok: false, detail: error.message }); }
|
|
110
|
+
}
|
|
111
|
+
if (runtime.resources.vectorize.length) checks.push({ check: 'cloudflare_vectorize', ok: runtime.conflicts.length === 0 && runtime.resources.vectorize.every(row => row.configured && (row.locally_executable || row.remotely_executable)), detail: runtime.resources.vectorize });
|
|
112
|
+
if (runtime.resources.workers_ai.observed) checks.push({ check: 'workers_ai_runtime', ok: runtime.resources.workers_ai.remotely_executable || runtime.resources.workers_ai.locally_executable, detail: runtime.resources.workers_ai });
|
|
113
|
+
if (runtime.conflicts.length) checks.push({ check: 'project_context_conflicts', ok: false, detail: runtime.conflicts });
|
|
114
|
+
return show({ ok: checks.filter(check => check.blocking !== false).every(check => check.ok), checks, project_context: runtime, runtime });
|
|
115
|
+
}
|
|
116
|
+
if (command === 'lanes') {
|
|
117
|
+
const configured = existing ? [existing.lane || { id: 'legacy-local', backend: existing.storage.driver === 'sqlite' ? 'local_exact' : 'postgres_pgvector', source: CONFIG_PATH }] : [];
|
|
118
|
+
const laneKey = lane => [lane.backend, lane.binding || '', lane.index || ''].join(':');
|
|
119
|
+
const seen = new Set(configured.map(laneKey));
|
|
120
|
+
return show([...configured, ...runtime.lanes.filter(lane => !seen.has(laneKey(lane)))]);
|
|
66
121
|
}
|
|
67
|
-
if (command === 'lanes') return show(existing ? [existing.lane || { id: 'legacy-local', backend: existing.storage.driver === 'sqlite' ? 'local_exact' : 'postgres_pgvector' }] : []);
|
|
68
122
|
if (command === 'setup' || command === 'configure' || command === 'scope') {
|
|
69
|
-
const selected = opts.yes ? opts : await interactiveOptions(discovery, opts); const { recommendation, config } = defaults(discovery, selected, existing);
|
|
123
|
+
const selected = opts.yes ? opts : await interactiveOptions(discovery, opts); const { recommendation, config } = defaults(discovery, selected, existing, runtime);
|
|
70
124
|
writeConfig(root, config); return show({ action: command, config: CONFIG_PATH, recommendation, config, next: ['agentsam autorag probe', 'agentsam index plan', 'agentsam index run', 'agentsam search "symbol or phrase"'] });
|
|
71
125
|
}
|
|
72
126
|
if (!existing) throw new Error('AutoRAG is not configured. Run agentsam autorag setup first.');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Canonical Agent Sam cheat-sheet — gcloud-like command groups.
|
|
3
3
|
* Old top-level commands remain as compatibility aliases.
|
|
4
|
+
* Every row shows a copy-pasteable `agentsam …` invocation.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
const GROUPS = Object.freeze([
|
|
@@ -19,8 +20,13 @@ const GROUPS = Object.freeze([
|
|
|
19
20
|
label: 'Repository',
|
|
20
21
|
commands: [
|
|
21
22
|
['inspect', 'Bounded repository authority view'],
|
|
23
|
+
['machine', 'Deterministic local perception + asset discovery'],
|
|
24
|
+
['machine inspect', 'Inspect a path (file or directory)'],
|
|
22
25
|
['recon', 'Bounded-worker finding packets'],
|
|
23
26
|
['codebaseindex', 'AST ingest + optional embeddings'],
|
|
27
|
+
['index', 'Project inventory + knowledge index commands'],
|
|
28
|
+
['index status', 'Show knowledge index freshness'],
|
|
29
|
+
['search', 'Retrieve from the local knowledge index'],
|
|
24
30
|
['merkle', 'Integrity snapshots'],
|
|
25
31
|
['security', 'Dependency + trust-boundary scan'],
|
|
26
32
|
],
|
|
@@ -103,16 +109,30 @@ const GROUPS = Object.freeze([
|
|
|
103
109
|
['update', 'Component update preview (gcloud-like)'],
|
|
104
110
|
['billing', 'Billing account relationships (not --billing-project)'],
|
|
105
111
|
['cheat-sheet', 'This page'],
|
|
106
|
-
['version', '
|
|
112
|
+
['version', 'Print CLI version'],
|
|
107
113
|
],
|
|
108
114
|
},
|
|
109
115
|
]);
|
|
110
116
|
|
|
117
|
+
/** Expand "a / b" rows into copy-pasteable `agentsam …` invocations. */
|
|
118
|
+
export function agentsamInvocations(cmd) {
|
|
119
|
+
const raw = String(cmd || '').trim();
|
|
120
|
+
if (!raw) return [];
|
|
121
|
+
if (raw.includes(' / ')) {
|
|
122
|
+
return raw.split(' / ').map((part) => `agentsam ${part.trim()}`);
|
|
123
|
+
}
|
|
124
|
+
return [`agentsam ${raw}`];
|
|
125
|
+
}
|
|
126
|
+
|
|
111
127
|
export function listCheatSheetGroups() {
|
|
112
128
|
return GROUPS.map((group) => ({
|
|
113
129
|
id: group.id,
|
|
114
130
|
label: group.label,
|
|
115
|
-
commands: group.commands.map(([cmd, summary]) => ({
|
|
131
|
+
commands: group.commands.map(([cmd, summary]) => ({
|
|
132
|
+
cmd,
|
|
133
|
+
summary,
|
|
134
|
+
invocations: agentsamInvocations(cmd),
|
|
135
|
+
})),
|
|
116
136
|
}));
|
|
117
137
|
}
|
|
118
138
|
|
|
@@ -120,13 +140,18 @@ export function renderCheatSheet(version) {
|
|
|
120
140
|
const lines = [
|
|
121
141
|
'',
|
|
122
142
|
` Agent Sam cheat-sheet${version ? ` · v${version}` : ''}`,
|
|
123
|
-
' Organized hierarchy ·
|
|
143
|
+
' Organized hierarchy · each row shows a runnable `agentsam …` command.',
|
|
124
144
|
'',
|
|
125
145
|
];
|
|
126
146
|
for (const group of GROUPS) {
|
|
127
147
|
lines.push(` ${group.label}`);
|
|
128
148
|
for (const [cmd, summary] of group.commands) {
|
|
129
|
-
|
|
149
|
+
const invocations = agentsamInvocations(cmd);
|
|
150
|
+
const primary = invocations[0] || `agentsam ${cmd}`;
|
|
151
|
+
lines.push(` ${primary.padEnd(52)} ${summary}`);
|
|
152
|
+
for (const extra of invocations.slice(1)) {
|
|
153
|
+
lines.push(` ${extra.padEnd(52)} (same group)`);
|
|
154
|
+
}
|
|
130
155
|
}
|
|
131
156
|
lines.push('');
|
|
132
157
|
}
|
|
@@ -16,6 +16,8 @@ import { openSqliteStore } from '../knowledge/stores/sqlite.js';
|
|
|
16
16
|
import { openPostgresStore } from '../knowledge/stores/postgres.js';
|
|
17
17
|
import { planIndex, retrieve, runIndex } from '../knowledge/engine.js';
|
|
18
18
|
import { createProviderRegistry } from '../../packages/agentsam-knowledge/src/providers/index.js';
|
|
19
|
+
import { createBackendRegistry } from '../../packages/agentsam-knowledge/src/backends/index.js';
|
|
20
|
+
import { discoverProjectContext } from '../knowledge/runtime-discovery.js';
|
|
19
21
|
import { ensureProjectManifest, getRepositoryId, portableRepositoryIdFromGit, tryReadProjectConfig } from '../lib/project-config.js';
|
|
20
22
|
import { parsePastedPaths, stageMaterials } from '../indexing/ingest/materials.js';
|
|
21
23
|
import {
|
|
@@ -74,6 +76,21 @@ function writeKnowledgeConfig(root, config) {
|
|
|
74
76
|
return validated;
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
function resolveVectorLane(root, vectors, input = {}) {
|
|
80
|
+
if (vectors !== 'vectorize') return null;
|
|
81
|
+
const explicitBinding = String(input.vectorBinding || input.binding || '').trim();
|
|
82
|
+
const explicitIndex = String(input.vectorIndex || input.index || '').trim();
|
|
83
|
+
if (explicitBinding || explicitIndex) {
|
|
84
|
+
if (!explicitBinding || !explicitIndex) throw new Error('Vectorize requires both vectorBinding and vectorIndex when either is supplied.');
|
|
85
|
+
return { backend: 'cloudflare_vectorize', binding: explicitBinding, index: explicitIndex };
|
|
86
|
+
}
|
|
87
|
+
const context = discoverProjectContext(root);
|
|
88
|
+
const resources = context.resources.vectorize.filter(row => row.configured);
|
|
89
|
+
if (resources.length === 1) return { backend: 'cloudflare_vectorize', binding: resources[0].binding, index: resources[0].index };
|
|
90
|
+
if (!resources.length) throw new Error('No Cloudflare Vectorize binding is declared by this project. Configure Wrangler or pass vectorBinding/vectorIndex explicitly.');
|
|
91
|
+
throw new Error('Multiple Cloudflare Vectorize bindings are declared. Select vectorBinding/vectorIndex explicitly.');
|
|
92
|
+
}
|
|
93
|
+
|
|
77
94
|
function loadOrBuildConfig(root, preferences) {
|
|
78
95
|
const project = tryReadProjectConfig(root) || ensureProjectManifest(root, {});
|
|
79
96
|
const repositoryId = getRepositoryId(project) || portableRepositoryIdFromGit(root) || preferences.repositoryId;
|
|
@@ -103,7 +120,14 @@ function loadOrBuildConfig(root, preferences) {
|
|
|
103
120
|
storage: preferences.storage === 'postgres'
|
|
104
121
|
? { driver: 'postgres', connection_env: preferences.connectionEnv || 'AGENTSAM_DATABASE_URL' }
|
|
105
122
|
: { driver: 'sqlite' },
|
|
106
|
-
lane: {
|
|
123
|
+
lane: preferences.vectorLane ? {
|
|
124
|
+
id: `${preferences.scopeName || 'default'}-cloudflare-vectorize`,
|
|
125
|
+
backend: 'cloudflare_vectorize',
|
|
126
|
+
resource: null,
|
|
127
|
+
binding: preferences.vectorLane.binding,
|
|
128
|
+
index: preferences.vectorLane.index,
|
|
129
|
+
metric: 'cosine',
|
|
130
|
+
} : {
|
|
107
131
|
id: `${preferences.scopeName || 'default'}-ingest`,
|
|
108
132
|
backend: preferences.storage === 'postgres' ? 'postgres_pgvector' : 'local_exact',
|
|
109
133
|
resource: null,
|
|
@@ -172,11 +196,13 @@ export async function runCodebaseindexIngest(input = {}, ctx = {}) {
|
|
|
172
196
|
const vectors = input.vectors || (embedding.provider === 'none' ? 'none'
|
|
173
197
|
: storage === 'postgres' ? 'pgvector' : 'sqlite_exact');
|
|
174
198
|
|
|
199
|
+
const vectorLane = resolveVectorLane(root, vectors, input);
|
|
175
200
|
const config = loadOrBuildConfig(root, {
|
|
176
201
|
include,
|
|
177
202
|
exclude,
|
|
178
203
|
embedding,
|
|
179
204
|
storage,
|
|
205
|
+
vectorLane,
|
|
180
206
|
scopeName: input.scope || 'ingest',
|
|
181
207
|
connectionEnv: input.connectionEnv,
|
|
182
208
|
});
|
|
@@ -185,6 +211,9 @@ export async function runCodebaseindexIngest(input = {}, ctx = {}) {
|
|
|
185
211
|
jobGraph = advanceJobGraph(jobGraph, 'lane.resolve');
|
|
186
212
|
|
|
187
213
|
const embed = Boolean(input.embed) && embedding.provider !== 'none';
|
|
214
|
+
if (vectors === 'vectorize' && !embed && !input.planOnly) {
|
|
215
|
+
throw new Error('Cloudflare Vectorize execution requires an embedding provider and embed=true. Use planOnly to inspect the lane without writing vectors.');
|
|
216
|
+
}
|
|
188
217
|
const store = await openStore(root, config, false);
|
|
189
218
|
try {
|
|
190
219
|
if (input.planOnly) {
|
|
@@ -214,12 +243,26 @@ export async function runCodebaseindexIngest(input = {}, ctx = {}) {
|
|
|
214
243
|
validate: (...args) => (adapter ??= providerAdapter(config.embedding)).validate(...args),
|
|
215
244
|
embed: (...args) => (adapter ??= providerAdapter(config.embedding)).embed(...args),
|
|
216
245
|
};
|
|
246
|
+
const vectorBackend = config.lane?.backend === 'cloudflare_vectorize'
|
|
247
|
+
? createBackendRegistry().get('cloudflare_vectorize')
|
|
248
|
+
: null;
|
|
249
|
+
const vectorContext = {
|
|
250
|
+
...(ctx.cloudflare || {}),
|
|
251
|
+
...(input.vectorContext || {}),
|
|
252
|
+
env: input.env || ctx.env || process.env,
|
|
253
|
+
ownerId: input.ownerId || ctx.ownerId || ctx.owner_id || '',
|
|
254
|
+
accountId: input.accountId || ctx.accountId || '',
|
|
255
|
+
workerBinding: input.workerBinding || ctx.workerBinding,
|
|
256
|
+
apiClient: input.apiClient || ctx.apiClient,
|
|
257
|
+
};
|
|
217
258
|
const result = await runIndex({
|
|
218
259
|
root,
|
|
219
260
|
config,
|
|
220
261
|
store,
|
|
221
262
|
embed,
|
|
222
263
|
embedder,
|
|
264
|
+
vectorBackend,
|
|
265
|
+
vectorContext,
|
|
223
266
|
maxInputs: Number(input.maxInputs ?? 200),
|
|
224
267
|
maxCharacters: Number(input.maxCharacters ?? 400000),
|
|
225
268
|
});
|
|
@@ -568,7 +611,7 @@ async function runWizard(root, opts) {
|
|
|
568
611
|
}));
|
|
569
612
|
const storage = lane === 'supabase' ? 'postgres' : 'sqlite';
|
|
570
613
|
if (lane === 'vectorize') {
|
|
571
|
-
note('Vectorize
|
|
614
|
+
note('Uses this project’s declared Vectorize binding via Worker runtime or the current user’s authorized Cloudflare API transport.', 'Lane note');
|
|
572
615
|
}
|
|
573
616
|
if (lane === 'supabase') {
|
|
574
617
|
note('Uses AGENTSAM_DATABASE_URL / Hyperdrive-style postgres. Owner IAM already has node-api.', 'Lane note');
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { buildRepositoryAuditPacket } from '../agent/repository-audit.js';
|
|
2
|
+
import { repositorySnapshot } from '../capabilities/repository-snapshot.js';
|
|
3
|
+
import { getNextPlanStep, getPlan, openPlanLedger } from './plan-ledger.js';
|
|
4
|
+
import { projectGoapWorld } from '../../packages/agentsam-goap/src/world.js';
|
|
5
|
+
|
|
6
|
+
const PRIORITY_TO_TICKET = Object.freeze({
|
|
7
|
+
critical: 'P0',
|
|
8
|
+
high: 'P1',
|
|
9
|
+
medium: 'P2',
|
|
10
|
+
low: 'P3',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function stableJson(value) {
|
|
14
|
+
if (Array.isArray(value)) return '[' + value.map(stableJson).join(',') + ']';
|
|
15
|
+
if (value && typeof value === 'object') {
|
|
16
|
+
return '{' + Object.keys(value).sort().map((key) => JSON.stringify(key) + ':' + stableJson(value[key])).join(',') + '}';
|
|
17
|
+
}
|
|
18
|
+
return JSON.stringify(value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function knowledgeFreshness(snapshot = {}) {
|
|
22
|
+
const knowledge = snapshot.knowledge || {};
|
|
23
|
+
if (!knowledge.configured) return { status: 'not_configured', reason: 'knowledge_config_missing' };
|
|
24
|
+
if (!knowledge.indexed) return { status: 'not_indexed', reason: 'active_generation_missing' };
|
|
25
|
+
const receipt = knowledge.receipt || {};
|
|
26
|
+
if (receipt.scope && knowledge.scope && stableJson(receipt.scope) !== stableJson(knowledge.scope)) {
|
|
27
|
+
return { status: 'stale', reason: 'scope_policy_changed' };
|
|
28
|
+
}
|
|
29
|
+
if (receipt.merkle_root && snapshot.tree?.merkle_root && receipt.merkle_root !== snapshot.tree.merkle_root) {
|
|
30
|
+
return { status: 'stale', reason: 'repository_merkle_changed' };
|
|
31
|
+
}
|
|
32
|
+
return { status: 'current', reason: 'active_generation_matches_world' };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function buildLocalGoapState({ cwd = process.cwd(), snapshot = null } = {}) {
|
|
36
|
+
const ctx = openPlanLedger(cwd);
|
|
37
|
+
try {
|
|
38
|
+
const plan = getPlan(ctx, 'current');
|
|
39
|
+
if (!plan) return null;
|
|
40
|
+
|
|
41
|
+
const running = (plan.tasks || []).find((task) => task.status === 'running') || null;
|
|
42
|
+
const next = running ? null : getNextPlanStep(ctx, { planId: plan.id });
|
|
43
|
+
const step = running || next?.step || null;
|
|
44
|
+
const world = snapshot || await repositorySnapshot({ cwd: ctx.root });
|
|
45
|
+
const packet = buildRepositoryAuditPacket({
|
|
46
|
+
snapshot: world,
|
|
47
|
+
focus: [plan.title, step?.title].filter(Boolean),
|
|
48
|
+
requestedSections: ['repository', 'tree', 'knowledge', 'packages'],
|
|
49
|
+
evidenceBudget: 6000,
|
|
50
|
+
});
|
|
51
|
+
const freshness = knowledgeFreshness(world);
|
|
52
|
+
const projectedWorld = projectGoapWorld({
|
|
53
|
+
repository: {
|
|
54
|
+
...world.repository,
|
|
55
|
+
merkle_root: world.tree?.merkle_root || null,
|
|
56
|
+
},
|
|
57
|
+
plan,
|
|
58
|
+
activeTodo: step,
|
|
59
|
+
knowledge: {
|
|
60
|
+
...freshness,
|
|
61
|
+
generation_id: world.knowledge?.generation_id || null,
|
|
62
|
+
},
|
|
63
|
+
evidence: packet,
|
|
64
|
+
updatedAt: step?.updated_at_unix || plan.updated_at_unix || null,
|
|
65
|
+
});
|
|
66
|
+
const run = step?.agent_run_id
|
|
67
|
+
? ctx.db.prepare('SELECT * FROM agentsam_agent_run WHERE id = ? LIMIT 1').get(step.agent_run_id) || null
|
|
68
|
+
: null;
|
|
69
|
+
|
|
70
|
+
const git = {
|
|
71
|
+
root: ctx.root,
|
|
72
|
+
repoFullName: world.repository?.full_name || ctx.git?.repoFullName || null,
|
|
73
|
+
revisionSha: world.repository?.revision_sha || ctx.git?.revisionSha || null,
|
|
74
|
+
branch: world.repository?.branch || ctx.git?.branch || null,
|
|
75
|
+
dirty: world.repository?.dirty ?? ctx.git?.dirty ?? null,
|
|
76
|
+
};
|
|
77
|
+
const activeTicket = step ? {
|
|
78
|
+
id: step.id,
|
|
79
|
+
title: step.title,
|
|
80
|
+
status: step.status,
|
|
81
|
+
priority: PRIORITY_TO_TICKET[step.priority] || 'P2',
|
|
82
|
+
subsystem: step.metadata?.kind || 'work',
|
|
83
|
+
surface: 'local',
|
|
84
|
+
status_reason: 'selected_from_project_local_plan',
|
|
85
|
+
description: step.description || null,
|
|
86
|
+
agent_run_id: step.agent_run_id || null,
|
|
87
|
+
} : {
|
|
88
|
+
id: plan.id,
|
|
89
|
+
title: plan.title,
|
|
90
|
+
status: plan.tasks_done === plan.tasks_total ? 'complete' : 'active',
|
|
91
|
+
priority: 'P2',
|
|
92
|
+
subsystem: 'plan',
|
|
93
|
+
surface: 'local',
|
|
94
|
+
status_reason: 'plan_has_no_open_executable_step',
|
|
95
|
+
agent_run_id: null,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
ok: true,
|
|
100
|
+
source: 'local_world',
|
|
101
|
+
repositoryId: world.repository?.repository_id || ctx.repositoryId,
|
|
102
|
+
git,
|
|
103
|
+
workspaceState: {
|
|
104
|
+
current_task_id: step?.id || null,
|
|
105
|
+
locked_by: 'project_local_plan',
|
|
106
|
+
checkpoint_sha: plan.metadata?.revision || null,
|
|
107
|
+
last_agent_action: 'world_snapshot_projected',
|
|
108
|
+
updated_at: step?.updated_at_unix || plan.updated_at_unix || null,
|
|
109
|
+
},
|
|
110
|
+
activeTicket,
|
|
111
|
+
agentRun: run,
|
|
112
|
+
recentCommits: [],
|
|
113
|
+
checkpoint: null,
|
|
114
|
+
cursor: {},
|
|
115
|
+
steps: plan.tasks || [],
|
|
116
|
+
stepsUnavailable: false,
|
|
117
|
+
localPlan: plan,
|
|
118
|
+
localStep: step,
|
|
119
|
+
worldSnapshot: {
|
|
120
|
+
snapshot_id: world.snapshot_id,
|
|
121
|
+
content_hash: world.content_hash,
|
|
122
|
+
merkle_root: world.tree?.merkle_root || null,
|
|
123
|
+
knowledge_generation_id: world.knowledge?.generation_id || null,
|
|
124
|
+
knowledge_freshness: freshness,
|
|
125
|
+
repository: world.repository,
|
|
126
|
+
actions: projectedWorld.actions,
|
|
127
|
+
},
|
|
128
|
+
boundedEvidence: packet,
|
|
129
|
+
canonicalWorld: projectedWorld,
|
|
130
|
+
};
|
|
131
|
+
} finally {
|
|
132
|
+
ctx.close();
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/commands/goap.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
renderGoapPlan,
|
|
12
12
|
} from '../../packages/agentsam-repository/src/goap.js';
|
|
13
13
|
import { readAccountSession } from '../lib/account-session.js';
|
|
14
|
+
import { buildLocalGoapState } from './goap-world.js';
|
|
14
15
|
|
|
15
16
|
function parseArgs(args = []) {
|
|
16
17
|
const flags = { _: [] };
|
|
@@ -102,7 +103,7 @@ export async function runGoap(subcommand = 'status', options = {}) {
|
|
|
102
103
|
console.log(`Successfully created and activated GOAP goal: ${res.ticketId}`);
|
|
103
104
|
console.log(` Title: ${res.title}`);
|
|
104
105
|
console.log(` Priority: ${res.priority} [Subsystem: ${res.subsystem}]`);
|
|
105
|
-
console.log(` Agent Run: ${res.agentRunId}`);
|
|
106
|
+
if (res.agentRunId) console.log(` Agent Run: ${res.agentRunId}`);
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -147,9 +148,15 @@ export async function runGoap(subcommand = 'status', options = {}) {
|
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
let state = null;
|
|
152
|
+
try {
|
|
153
|
+
state = await buildLocalGoapState({ cwd });
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (jsonMode && options.debug) console.error(error?.stack || error);
|
|
156
|
+
}
|
|
157
|
+
if (!state && accountId) state = await readGoapState({ cwd, accountId });
|
|
158
|
+
if (!state?.ok) {
|
|
159
|
+
console.error(`Error reading GOAP state: ${state?.error || 'no local plan or remote GOAP state available'}`);
|
|
153
160
|
return;
|
|
154
161
|
}
|
|
155
162
|
|
|
@@ -169,10 +169,66 @@ export async function runSearch(argv) {
|
|
|
169
169
|
finally { await store?.close(); }
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
function compactNumber(value) {
|
|
173
|
+
const n = Number(value || 0);
|
|
174
|
+
if (!Number.isFinite(n)) return '0';
|
|
175
|
+
if (Math.abs(n) >= 1_000_000) return `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 1 : 2).replace(/\.0+$/, '')}m`;
|
|
176
|
+
if (Math.abs(n) >= 1_000) return `${(n / 1_000).toFixed(n >= 100_000 ? 0 : 1).replace(/\.0$/, '')}k`;
|
|
177
|
+
return String(n);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function renderRepositoryObservation(observation) {
|
|
181
|
+
const data = observation?.data || {};
|
|
182
|
+
const git = data.git || {};
|
|
183
|
+
const summary = data.summary || {};
|
|
184
|
+
const top = Array.isArray(data.top_level) ? data.top_level.slice(0, 5) : [];
|
|
185
|
+
const pressure = Array.isArray(data.pressure_points) ? data.pressure_points.slice(0, 6) : [];
|
|
186
|
+
const dirty = git.dirty ? `dirty · ${git.changed_paths || 0} changed` : 'clean';
|
|
187
|
+
const head = git.head_sha ? String(git.head_sha).slice(0, 10) : 'unknown';
|
|
188
|
+
|
|
189
|
+
const lines = [
|
|
190
|
+
'',
|
|
191
|
+
' Agent Sam · repository',
|
|
192
|
+
'',
|
|
193
|
+
` repo ${data.repo_name || path.basename(data.repo_root || '') || 'unknown'}`,
|
|
194
|
+
` root ${data.repo_root || 'unknown'}`,
|
|
195
|
+
` git ${git.branch || 'unknown'} @ ${head} · ${dirty}`,
|
|
196
|
+
` scale ${compactNumber(summary.file_count)} files · ${compactNumber(summary.source_file_count)} source · ${compactNumber(summary.total_lines)} lines`,
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
if (top.length) {
|
|
200
|
+
lines.push('', ' Primary areas');
|
|
201
|
+
for (const row of top) {
|
|
202
|
+
lines.push(` ${String(row.path || '.').padEnd(28)} ${compactNumber(row.files)} files · ${compactNumber(row.lines)} lines`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (pressure.length) {
|
|
207
|
+
lines.push('', ' Change pressure');
|
|
208
|
+
for (const row of pressure) {
|
|
209
|
+
lines.push(` ${String(row.path || '.').padEnd(28)} pressure ${Number(row.pressure_score || 0).toFixed(1)} · stability ${Number(row.stability_score || 0).toFixed(1)}`);
|
|
210
|
+
}
|
|
211
|
+
lines.push(' relative activity heuristics — not quality grades');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
lines.push(
|
|
215
|
+
'',
|
|
216
|
+
' More',
|
|
217
|
+
' agentsam repo --json full deterministic receipt',
|
|
218
|
+
' agentsam repo history saved observations',
|
|
219
|
+
' agentsam repo compare compare latest saved observations',
|
|
220
|
+
' agentsam inspect bounded architecture / authority view',
|
|
221
|
+
' agentsam machine inspect native deterministic perception',
|
|
222
|
+
'',
|
|
223
|
+
);
|
|
224
|
+
return lines.join('\n');
|
|
225
|
+
}
|
|
226
|
+
|
|
172
227
|
export async function runRepository(argv) {
|
|
173
228
|
const { values: opts, positionals } = flags(argv, { save: { type: 'boolean' }, 'churn-days': { type: 'string' } });
|
|
174
229
|
const command = positionals[0] || 'snapshot';
|
|
175
|
-
if (opts.help) { console.log('agentsam repo snapshot [--cwd PATH] [--churn-days 30] [--save] [--json]\nagentsam repo history|compare [--cwd PATH]\
|
|
230
|
+
if (opts.help) { console.log('agentsam repo [snapshot] [--cwd PATH] [--churn-days 30] [--save] [--json]\nagentsam repo history|compare [--cwd PATH]\nDefault output is a human summary; --json emits the full deterministic receipt.'); return; }
|
|
231
|
+
if (command === 'context') throw new Error('Repository context is `agentsam context`. Use `agentsam repo snapshot|history|compare` for repository intelligence.');
|
|
176
232
|
if (positionals.length > 1 || !['snapshot', 'history', 'compare'].includes(command)) throw new Error('Use agentsam repo snapshot|history|compare.');
|
|
177
233
|
const root = repositoryRoot(opts.cwd);
|
|
178
234
|
let store;
|
|
@@ -190,6 +246,7 @@ export async function runRepository(argv) {
|
|
|
190
246
|
});
|
|
191
247
|
const observation = { id: randomUUID(), created_at: new Date().toISOString(), kind: 'repository-intelligence', data: JSON.parse(result.stdout) };
|
|
192
248
|
if (store) await store.observe(cacheNamespace(readConfig(root)), observation);
|
|
193
|
-
show(observation);
|
|
249
|
+
if (opts.json) show(observation);
|
|
250
|
+
else console.log(renderRepositoryObservation(observation));
|
|
194
251
|
} finally { await store?.close(); }
|
|
195
252
|
}
|