@inneranimalmedia/agentsam-sdk 2.6.9 → 2.6.11
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/README.md +21 -0
- package/TRADEMARKS.md +22 -0
- package/apps/README.md +3 -0
- package/apps/cad-creator/LICENSE +21 -0
- package/apps/cad-creator/README.md +4 -1
- package/apps/cad-creator/shared/cad/package.json +1 -1
- package/apps/client-cms-editor/LICENSE +21 -0
- package/apps/client-cms-editor/README.md +3 -0
- package/apps/client-cms-editor/backend/package.json +3 -3
- package/apps/client-cms-editor/frontend/package.json +4 -4
- package/apps/client-cms-editor/package-lock.json +43 -43
- package/apps/client-cms-editor/package.json +3 -3
- package/apps/client-cms-editor/reference/harvest/HARVEST_RECEIPT.json +1 -1
- package/apps/client-cms-editor/reference/harvest/README.md +1 -1
- package/apps/client-cms-editor/reference/harvest/plans/ARCHIVE-INTAKE.md +1 -1
- package/apps/client-cms-editor/reference/harvest/plans/HARVEST-INDEX.md +1 -1
- package/apps/client-cms-editor/reference/harvest/plans/TOOLING-LAB.md +1 -1
- package/apps/client-cms-editor/shared/cms/package.json +2 -2
- package/docs/MINI.md +4 -2
- package/docs/REPO_FILE_MAP.txt +0 -1
- package/docs/SOURCE_ARCHITECTURE.md +1 -1
- package/docs/architecture/DUAL_ANALYTICS_PRODUCT.md +140 -0
- package/docs/architecture/HOOKS-MODELS-SELF-HOSTING-PLAN.md +199 -0
- package/docs/content-studio/REVISION_GATE_2026-09-27.md +1 -1
- package/docs/engineering/go-portability/01-product-project-deployment-authority.md +69 -0
- package/docs/engineering/provider-internal-renames/01-lane-initialization.md +20 -0
- package/docs/engineering/provider-internal-renames/01a-runtime-environment-contract.md +115 -0
- package/docs/engineering/provider-internal-renames/02-cfoa.md +57 -0
- package/docs/engineering/provider-internal-renames/03-gclioa.md +32 -0
- package/docs/engineering/provider-internal-renames/04-goaude.md +50 -0
- package/docs/engineering/provider-internal-renames/05-gdrv.md +33 -0
- package/docs/engineering/provider-internal-renames/06-verification.md +103 -0
- package/docs/engineering/provider-internal-renames/README.md +77 -0
- package/docs/engineering/provider-internal-renames/runtime-environment-contract.json +220 -0
- package/docs/engineering/test-diagnostics/go-cli-test-hang-20261003.md +49 -0
- package/docs/engineering/test-diagnostics/go-skip-deploy-docker-fix.md +90 -0
- package/docs/knowledge-service-verification.md +3 -3
- package/docs/plans/AGENTSAM-SUSPEND-QUEUE-KNOWLEDGE-RDP-2026-10-03.md +870 -0
- package/docs/plans/LOCAL-STUDIO-GRADUATION-2026-09-26.md +9 -9
- package/docs/plans/MACHINE-FIRST-APPS-TUI-2026-09-24.md +11 -11
- package/docs/plans/RECONCILIATION-2026-09-19.md +6 -6
- package/docs/plans/SAM_WORK_PROTOCOL.md +667 -0
- package/docs/plans/TOMORROW-EXTENSIVE-TODO-2026-09-26.md +2 -2
- package/docs/plans/UNIVERSAL-INGEST-MACHINE-FIRST-2026-09-24.md +3 -3
- package/examples/hyperspace-demo/index.html +16 -0
- package/examples/hyperspace-demo/package.json +21 -0
- package/examples/hyperspace-demo/src/main.tsx +277 -0
- package/examples/hyperspace-demo/tsconfig.json +9 -0
- package/examples/hyperspace-demo/vite.config.ts +24 -0
- package/migrations/d1/0020_agentsam_receipt_catalog.sql +35 -0
- package/migrations/runtime/0005_agentsam_hooks.sql +87 -0
- package/migrations/runtime/0006_agent_run_suspend_activity.sql +53 -0
- package/migrations/runtime/0007_queue_control.sql +40 -0
- package/migrations/runtime/0008_agent_run_dependencies.sql +24 -0
- package/migrations/runtime/0008_analytics_legacy_bootstrap.sql +43 -0
- package/migrations/runtime/0009_analytics_authority.sql +108 -0
- package/package.json +45 -14
- package/packages/agentsam-brand/README.md +3 -0
- package/packages/agentsam-brand/package.json +2 -2
- package/packages/agentsam-brand/src/core/v2/compile.js +1 -1
- package/packages/agentsam-brand/src/core/v2/schema.js +1 -1
- package/packages/agentsam-contracts/dist/adapter.d.ts +22 -0
- package/packages/agentsam-contracts/dist/adapter.js +0 -0
- package/packages/agentsam-contracts/dist/agent.d.ts +66 -0
- package/packages/agentsam-contracts/dist/agent.js +15 -0
- package/packages/agentsam-contracts/dist/artifacts.d.ts +70 -0
- package/packages/agentsam-contracts/dist/artifacts.js +0 -0
- package/packages/agentsam-contracts/dist/authority.d.ts +21 -0
- package/packages/agentsam-contracts/dist/authority.js +0 -0
- package/packages/agentsam-contracts/dist/context.d.ts +14 -0
- package/packages/agentsam-contracts/dist/context.js +0 -0
- package/packages/agentsam-contracts/dist/errors.d.ts +121 -0
- package/packages/agentsam-contracts/dist/errors.js +5 -0
- package/packages/agentsam-contracts/dist/events.d.ts +53 -0
- package/packages/agentsam-contracts/dist/events.js +0 -0
- package/packages/agentsam-contracts/dist/execution.d.ts +38 -0
- package/packages/agentsam-contracts/dist/execution.js +0 -0
- package/packages/agentsam-contracts/dist/hooks.d.ts +31 -0
- package/packages/agentsam-contracts/dist/hooks.js +0 -0
- package/packages/agentsam-contracts/dist/identity.d.ts +15 -0
- package/packages/agentsam-contracts/dist/identity.js +0 -0
- package/packages/agentsam-contracts/dist/index.d.ts +16 -0
- package/packages/agentsam-contracts/dist/index.js +164 -0
- package/packages/agentsam-contracts/dist/models.d.ts +9 -0
- package/packages/agentsam-contracts/dist/models.js +0 -0
- package/packages/agentsam-contracts/dist/providers.d.ts +27 -0
- package/packages/agentsam-contracts/dist/providers.js +0 -0
- package/packages/agentsam-contracts/dist/repository.d.ts +56 -0
- package/packages/agentsam-contracts/dist/repository.js +15 -0
- package/packages/agentsam-contracts/dist/run.d.ts +113 -0
- package/packages/agentsam-contracts/dist/run.js +132 -0
- package/packages/agentsam-contracts/dist/tools.d.ts +82 -0
- package/packages/agentsam-contracts/dist/tools.js +0 -0
- package/packages/agentsam-contracts/dist/widgets.d.ts +38 -0
- package/packages/agentsam-contracts/dist/widgets.js +0 -0
- package/packages/agentsam-contracts/package.json +9 -1
- package/packages/agentsam-contracts/scripts/build.mjs +1 -1
- package/packages/agentsam-contracts/src/agent.ts +78 -3
- package/packages/agentsam-contracts/src/errors.ts +19 -10
- package/packages/agentsam-contracts/src/index.ts +2 -0
- package/packages/agentsam-contracts/src/run.ts +320 -0
- package/packages/agentsam-contracts/src/widgets.ts +58 -0
- package/packages/agentsam-contracts/test/contracts.test.mjs +1 -1
- package/packages/agentsam-contracts/test/run-contract.test.mjs +94 -0
- package/packages/agentsam-errors/package.json +11 -3
- package/packages/agentsam-errors/protocol/agentsam.error.v2.schema.json +821 -0
- package/packages/agentsam-errors/protocol/error-catalog.json +3512 -0
- package/packages/agentsam-errors/src/envelope.js +63 -11
- package/packages/agentsam-errors/src/error.js +6 -0
- package/packages/agentsam-errors/src/fingerprint.js +9 -1
- package/packages/agentsam-errors/src/normalize.js +51 -6
- package/packages/agentsam-errors/src/recovery.js +9 -35
- package/packages/agentsam-errors/src/transport.js +6 -1
- package/packages/agentsam-errors/src/vocabulary.js +515 -126
- package/packages/agentsam-errors/test/catalog-v2.test.mjs +106 -0
- package/packages/agentsam-errors/types/index.d.ts +157 -0
- package/packages/agentsam-goap/README.md +3 -0
- package/packages/agentsam-goap/package.json +2 -2
- package/packages/agentsam-hooks/README.md +206 -0
- package/packages/agentsam-hooks/bin/agentsam-hooks.mjs +64 -0
- package/packages/agentsam-hooks/bindings/go/command.go +55 -0
- package/packages/agentsam-hooks/bindings/go/errors_generated.go +402 -0
- package/packages/agentsam-hooks/bindings/go/go.mod +3 -0
- package/packages/agentsam-hooks/bindings/go/hooks.go +285 -0
- package/packages/agentsam-hooks/bindings/go/hooks_test.go +48 -0
- package/packages/agentsam-hooks/bindings/rust/Cargo.toml +11 -0
- package/packages/agentsam-hooks/bindings/rust/src/errors_generated.rs +396 -0
- package/packages/agentsam-hooks/bindings/rust/src/lib.rs +397 -0
- package/packages/agentsam-hooks/package.json +69 -0
- package/packages/agentsam-hooks/schema/manifest.json +54 -0
- package/packages/agentsam-hooks/scripts/clean-protocol.mjs +17 -0
- package/packages/agentsam-hooks/scripts/sync-protocol.mjs +27 -0
- package/packages/agentsam-hooks/src/adapters/agents.js +108 -0
- package/packages/agentsam-hooks/src/adapters/callback.js +4 -0
- package/packages/agentsam-hooks/src/adapters/capability.js +122 -0
- package/packages/agentsam-hooks/src/adapters/command.js +104 -0
- package/packages/agentsam-hooks/src/adapters/composite.js +31 -0
- package/packages/agentsam-hooks/src/adapters/http.js +58 -0
- package/packages/agentsam-hooks/src/adapters/lsp.js +116 -0
- package/packages/agentsam-hooks/src/adapters/mcp.js +76 -0
- package/packages/agentsam-hooks/src/adapters/provider.js +129 -0
- package/packages/agentsam-hooks/src/config.js +143 -0
- package/packages/agentsam-hooks/src/contracts.js +284 -0
- package/packages/agentsam-hooks/src/errors-generated.js +2732 -0
- package/packages/agentsam-hooks/src/index.d.ts +209 -0
- package/packages/agentsam-hooks/src/index.js +14 -0
- package/packages/agentsam-hooks/src/policy.js +34 -0
- package/packages/agentsam-hooks/src/runtime.js +312 -0
- package/packages/agentsam-hooks/src/store.js +264 -0
- package/packages/agentsam-hooks/test/adapters.test.mjs +216 -0
- package/packages/agentsam-hooks/test/runtime.test.mjs +258 -0
- package/packages/agentsam-knowledge/package.json +1 -1
- package/packages/agentsam-knowledge/src/backends/index.js +1 -1
- package/packages/agentsam-merch/README.md +62 -0
- package/packages/agentsam-merch/bin/agentsam-merch.mjs +16 -0
- package/packages/agentsam-merch/package.json +65 -0
- package/packages/agentsam-merch/profiles/completeful/dtg-back-large.json +42 -0
- package/packages/agentsam-merch/profiles/completeful/laser-engraving.json +39 -0
- package/packages/agentsam-merch/profiles/generic/embroidery-digitization.json +22 -0
- package/packages/agentsam-merch/schemas/collection-candidate.schema.json +66 -0
- package/packages/agentsam-merch/schemas/manufacturing-profile.schema.json +221 -0
- package/packages/agentsam-merch/src/adapters-completeful.js +50 -0
- package/packages/agentsam-merch/src/cli.js +93 -0
- package/packages/agentsam-merch/src/collection-lab.js +60 -0
- package/packages/agentsam-merch/src/compatibility.js +501 -0
- package/packages/agentsam-merch/src/derivatives.js +112 -0
- package/packages/agentsam-merch/src/index.d.ts +316 -0
- package/packages/agentsam-merch/src/index.js +46 -0
- package/packages/agentsam-merch/src/node/index.d.ts +58 -0
- package/packages/agentsam-merch/src/node/index.js +6 -0
- package/packages/agentsam-merch/src/node/raster.js +142 -0
- package/packages/agentsam-merch/src/node/vector.js +239 -0
- package/packages/agentsam-merch/src/product-concepts.js +118 -0
- package/packages/agentsam-merch/src/profile-registry.js +104 -0
- package/packages/agentsam-merch/src/profile.js +158 -0
- package/packages/agentsam-merch/src/transforms.js +215 -0
- package/packages/agentsam-merch/test/merch.test.mjs +332 -0
- package/packages/agentsam-merch/test/node-transforms.test.mjs +149 -0
- package/packages/agentsam-nav/dist/Nav.d.ts +43 -0
- package/packages/agentsam-nav/dist/NavCollapsible.d.ts +10 -0
- package/packages/agentsam-nav/dist/NavContent.d.ts +2 -0
- package/packages/agentsam-nav/dist/NavFooter.d.ts +2 -0
- package/packages/agentsam-nav/dist/NavGroup.d.ts +3 -0
- package/packages/agentsam-nav/dist/NavHeader.d.ts +2 -0
- package/packages/agentsam-nav/dist/NavMenu.d.ts +22 -0
- package/packages/agentsam-nav/dist/NavProvider.d.ts +35 -0
- package/packages/agentsam-nav/dist/NavTrigger.d.ts +2 -0
- package/packages/agentsam-nav/dist/Surfaces.d.ts +41 -0
- package/packages/agentsam-nav/dist/browser.d.ts +11 -0
- package/packages/agentsam-nav/dist/browser.global.js +172 -0
- package/packages/agentsam-nav/dist/browser.js +9688 -0
- package/packages/agentsam-nav/dist/contracts.d.ts +76 -0
- package/packages/agentsam-nav/dist/index.d.ts +11 -0
- package/packages/agentsam-nav/dist/index.js +9689 -0
- package/packages/agentsam-nav/dist/legacy.css +83 -0
- package/packages/agentsam-nav/dist/shell.css +113 -0
- package/packages/agentsam-nav/dist/theme.css +113 -0
- package/packages/agentsam-nav/dist/utils.d.ts +1 -0
- package/packages/agentsam-nav/package.json +1 -1
- package/packages/agentsam-queue-control/README.md +4 -1
- package/packages/agentsam-queue-control/package.json +4 -3
- package/packages/agentsam-queue-control/schemas/job-envelope.schema.json +111 -11
- package/packages/agentsam-queue-control/src/adapters/cloudflare.js +34 -6
- package/packages/agentsam-queue-control/src/adapters/memory.js +11 -2
- package/packages/agentsam-queue-control/src/adapters/sqlite.js +259 -0
- package/packages/agentsam-queue-control/src/contracts.js +207 -3
- package/packages/agentsam-queue-control/src/control-plane.js +62 -2
- package/packages/agentsam-queue-control/src/index.js +1 -0
- package/packages/agentsam-queue-control/test/queue-control.test.mjs +310 -0
- package/packages/agentsam-queue-control/test/sqlite-adapter.test.mjs +91 -0
- package/packages/agentsam-rapid-rust/README.md +3 -0
- package/packages/agentsam-repository/README.md +3 -0
- package/packages/agentsam-repository/package.json +1 -1
- package/packages/agentsam-vault/package.json +1 -1
- package/packages/agentsam-workbench/README.md +43 -0
- package/packages/agentsam-workbench/package.json +14 -4
- package/packages/agentsam-workbench/src/agent/AgentConversationSurface.tsx +108 -0
- package/packages/agentsam-workbench/src/agent/AgentPanel.tsx +25 -8
- package/packages/agentsam-workbench/src/agent/AgentRuntimeField.tsx +152 -0
- package/packages/agentsam-workbench/src/agent/Composer.tsx +10 -1
- package/packages/agentsam-workbench/src/agent/RunMode.ts +26 -0
- package/packages/agentsam-workbench/src/agent/Thread.tsx +18 -3
- package/packages/agentsam-workbench/src/agent/index.ts +3 -0
- package/packages/agentsam-workbench/src/index.ts +4 -0
- package/packages/agentsam-workbench/src/manufacturing/PreflightIndicator.tsx +203 -0
- package/packages/agentsam-workbench/src/manufacturing/index.ts +2 -0
- package/packages/agentsam-workbench/src/manufacturing/loading.ts +147 -0
- package/packages/agentsam-workbench/src/widgets/BuiltinWidget.tsx +22 -0
- package/packages/agentsam-workbench/src/widgets/CountdownWidget.tsx +68 -0
- package/packages/agentsam-workbench/src/widgets/WidgetFrame.tsx +56 -0
- package/packages/agentsam-workbench/src/widgets/countdown.ts +25 -0
- package/packages/agentsam-workbench/src/widgets/index.ts +6 -0
- package/packages/agentsam-workbench/src/widgets/registry.ts +13 -0
- package/packages/agentsam-workbench/src/widgets/useCountdown.ts +128 -0
- package/packages/agentsam-workbench/src/widgets/widgets.css +102 -0
- package/packages/connectors/{cloudflare → cfoa}/package.json +3 -3
- package/packages/heuristic-theme/package.json +1 -1
- package/packages/identity/README.md +3 -0
- package/packages/identity/backend/README.md +3 -0
- package/packages/identity/package.json +2 -2
- package/packages/identity/src/frontend/auth-portal/README.md +3 -0
- package/packages/identity/src/index.js +1 -1
- package/packages/identity/src/oauth/README.md +4 -1
- package/packages/identity/src/oauth/credentials.js +1 -1
- package/packages/identity/src/server/worker-router.js +1 -1
- package/packages/identity/tests/google-desktop-identity-login.test.mjs +1 -1
- package/packages/identity/tests/lane1-packed-consumer.test.mjs +1 -1
- package/packages/identity/tests/oauth-presets-accounts-ssot.test.mjs +1 -1
- package/packages/providers/completeful/package.json +1 -1
- package/packages/theme-church-site/package.json +2 -2
- package/packages/theme-companions-site/package.json +2 -2
- package/packages/theme-floors-site/package.json +2 -2
- package/packages/theme-fuelnfree-site/package.json +2 -2
- package/packages/theme-handyman-site/package.json +2 -2
- package/packages/theme-insurance-site/package.json +2 -2
- package/packages/theme-scenes/package.json +1 -1
- package/packages/theme-shinshu-site/package.json +2 -2
- package/packages/work-graph/package.json +1 -1
- package/protocol/apps/agentsam.app.v1.schema.json +1 -1
- package/protocol/apps/agentsam.host-install.v1.schema.json +1 -1
- package/protocol/assets/asset-record.v1.schema.json +1 -1
- package/protocol/brand/brandpack.v1.schema.json +1 -1
- package/protocol/capabilities/capability-manifest.schema.json +1 -1
- package/protocol/capabilities/knowledge-search-input.schema.json +1 -0
- package/protocol/credentials/issue.v1.schema.json +1 -1
- package/protocol/database/agentsam.schema-pack.v1.schema.json +1 -1
- package/protocol/database/connection.v1.schema.json +1 -1
- package/protocol/embeddings/embedding-profile.v1.schema.json +1 -1
- package/protocol/errors/README.md +36 -0
- package/protocol/errors/agentsam.error.v2.schema.json +821 -0
- package/protocol/errors/error-catalog.json +3506 -158
- package/protocol/errors/error-envelope.schema.json +195 -52
- package/protocol/errors/recovery.v1.schema.json +1 -1
- package/protocol/features/agentsam.feature.v1.schema.json +1 -1
- package/protocol/hooks/README.md +18 -0
- package/protocol/hooks/agentsam.hook.output.v1.schema.json +27 -0
- package/protocol/hooks/agentsam.hook.receipt.v1.schema.json +61 -0
- package/protocol/hooks/agentsam.hook.v1.schema.json +35 -0
- package/protocol/hooks/agentsam.hooks.config.v1.schema.json +78 -0
- package/protocol/local-engine/benchmark.v1.schema.json +1 -1
- package/protocol/local-engine/engine.v1.schema.json +1 -1
- package/protocol/models/README.md +3 -0
- package/protocol/models/model-inventory-v2.schema.json +1 -1
- package/protocol/models/provider-model-snapshot.v1.schema.json +22 -0
- package/protocol/receipts/agentsam.receipt.v1.json +95 -0
- package/protocol/rpc/v1/errors.proto +1 -0
- package/protocol/runtime/agentsam.runtime.v1.schema.json +1 -1
- package/protocol/runtime/workspace-fs.v1.schema.json +1 -1
- package/protocol/sam/activity.v1.schema.json +1 -1
- package/protocol/sam/answer.v1.schema.json +1 -1
- package/protocol/sam/calibration.v1.schema.json +1 -1
- package/protocol/sam/decision-receipt.v1.schema.json +1 -1
- package/protocol/sam/evaluation.v1.schema.json +1 -1
- package/protocol/sam/operation.schema.json +1 -1
- package/protocol/sam/outcome.v1.schema.json +1 -1
- package/protocol/sam/question.v1.schema.json +1 -1
- package/protocol/sam/result.schema.json +1 -1
- package/protocol/sam/state.v1.schema.json +1 -1
- package/protocol/scoring/scorecard.v1.schema.json +1 -1
- package/protocol/skills/agentsam.interaction.v1.schema.json +1 -1
- package/protocol/skills/agentsam.skill.v1.schema.json +1 -1
- package/protocol/theme-refinery/product-metadata.schema.json +1 -1
- package/protocol/theme-refinery/receipts/products-registry-batch-20260924.json +6 -6
- package/protocol/theme-refinery/receipts/theme-harvest-20260924.json +6 -6
- package/protocol/theme-refinery/reconciliation-receipt.schema.json +1 -1
- package/protocol/ui/icon.v1.schema.json +1 -1
- package/python/README.md +20 -0
- package/python/agentsam_sdk/errors/__init__.py +4 -0
- package/python/agentsam_sdk/errors/vocabulary.py +2730 -0
- package/python/agentsam_sdk/hooks/__init__.py +32 -0
- package/python/agentsam_sdk/hooks/adapters.py +132 -0
- package/python/agentsam_sdk/hooks/contracts.py +121 -0
- package/python/agentsam_sdk/hooks/runtime.py +253 -0
- package/python/tests/test_hooks.py +115 -0
- package/skills/README.md +3 -0
- package/src/acp/agent-executor.js +106 -0
- package/src/acp/client.js +316 -0
- package/src/acp/dependencies.js +426 -0
- package/src/acp/http.js +207 -0
- package/src/acp/index.js +22 -0
- package/src/acp/runs.js +125 -0
- package/src/acp/runtime-selection.js +180 -0
- package/src/agent/responses-runner.js +145 -1
- package/src/cli/command-catalog.js +4 -0
- package/src/cli.js +33 -0
- package/src/commands/cheat-sheet.js +1 -0
- package/src/commands/cloudflare-login.js +1 -1
- package/src/commands/cloudflare.js +2 -2
- package/src/commands/connections.js +1 -1
- package/src/commands/go.js +76 -6
- package/src/commands/hooks.js +260 -0
- package/src/commands/merch.js +5 -0
- package/src/commands/mini.js +1 -1
- package/src/commands/models.js +1 -1
- package/src/commands/receipts.js +140 -0
- package/src/commands/run.js +253 -0
- package/src/commands/shell.js +114 -9
- package/src/errors/diagnostic.js +9 -9
- package/src/go/container.js +1 -1
- package/src/go/contract.js +61 -18
- package/src/go/discover.js +0 -4
- package/src/go/index.js +13 -1
- package/src/go/probe.js +109 -0
- package/src/go/{cloudflare.js → providers/cloudflare.js} +36 -136
- package/src/go/verify.js +1 -1
- package/src/index.js +32 -0
- package/src/indexing/ingest/inventory.js +1 -1
- package/src/knowledge/service/grpc-codec.js +2 -0
- package/src/lib/deploy/local-studio.js +2 -2
- package/src/lib/mini/scaffold.js +1 -1
- package/src/lib/slash-commands.js +1 -0
- package/src/lib/whoami-capabilities.js +1 -1
- package/src/local/runtime-store.js +54 -0
- package/src/mcp/cloudflare-bundles.js +1 -1
- package/src/models/catalog.js +0 -49
- package/src/models/inventory-core.js +69 -0
- package/src/plugins/index.js +9 -1
- package/src/plugins/registry.js +115 -6
- package/src/receipts/contract.js +68 -0
- package/src/receipts/index.js +20 -0
- package/src/receipts/prune.js +64 -0
- package/src/receipts/sinks.js +285 -0
- package/src/rpc/generated/errors_pb.js +49 -1
- package/src/tools/runtime.js +13 -5
- package/templates/mini/gadget/app.js +15 -40
- package/templates/mini/gadget/index.html +7 -7
- package/templates/mini/shared/style.css +1 -1
- /package/packages/connectors/{cloudflare → cfoa}/OAUTH_STORAGE_AUDIT.md +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/api-client.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/capabilities.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/credential.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/brand-protection.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/keyless.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/pages.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/scanner.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/snippets.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/tag-gateway.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/tags.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/token-validation.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/vectorize.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/families/workflows.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/index.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/oauth-persist.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/owner.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/permission-options.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/routes.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/scope-catalog.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/src/vault.js +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/tests/capabilities.test.mjs +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/tests/connector.test.mjs +0 -0
- /package/packages/connectors/{cloudflare → cfoa}/tests/oauth-persist.test.mjs +0 -0
- /package/packages/identity/src/oauth/{google-desktop-exchange.js → goaude.js} +0 -0
package/src/commands/go.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { cancel, confirm, intro, isCancel, outro, select } from '@clack/prompts';
|
|
2
|
+
import { cancel, confirm, intro, isCancel, outro, select, text } from '@clack/prompts';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_PRODUCT,
|
|
@@ -32,6 +32,7 @@ function parse(argv = []) {
|
|
|
32
32
|
skipDeploy: false,
|
|
33
33
|
skipRegistry: false,
|
|
34
34
|
accountId: null,
|
|
35
|
+
receiptRoot: null,
|
|
35
36
|
officialRelease: false,
|
|
36
37
|
yes: false,
|
|
37
38
|
help: false,
|
|
@@ -48,6 +49,7 @@ function parse(argv = []) {
|
|
|
48
49
|
else if (arg === '--official-release') out.officialRelease = true;
|
|
49
50
|
else if (arg === '--yes' || arg === '-y') out.yes = true;
|
|
50
51
|
else if (arg === '--account') out.accountId = String(argv[++i] || '').trim() || null;
|
|
52
|
+
else if (arg === '--receipt-root') out.receiptRoot = String(argv[++i] || '').trim() || null;
|
|
51
53
|
else if (arg === '--cwd') out.cwd = path.resolve(argv[++i] || out.cwd);
|
|
52
54
|
else if (arg === '--cloudflare') {
|
|
53
55
|
out.cloudflare = true;
|
|
@@ -106,6 +108,7 @@ const HELP = `Agent Sam · Go
|
|
|
106
108
|
|
|
107
109
|
Flags:
|
|
108
110
|
--account <id> Explicit Cloudflare account target
|
|
111
|
+
--receipt-root <path> Base directory for AgentSam Go receipts/state
|
|
109
112
|
--yes, -y Confirm a live non-interactive deployment
|
|
110
113
|
--json Machine-readable output
|
|
111
114
|
--dry-run Build/probe + Wrangler dry-run; no live deploy or InnerAnimalMedia registry write
|
|
@@ -180,9 +183,13 @@ export async function runGo(argv = [], options = {}) {
|
|
|
180
183
|
|
|
181
184
|
const discovery = discoverGoRuntime(args.cwd);
|
|
182
185
|
const productRoot = resolveProductRoot(discovery, args.product);
|
|
183
|
-
|
|
186
|
+
|
|
187
|
+
let stateRoot = options.stateRoot
|
|
184
188
|
? path.resolve(options.stateRoot)
|
|
185
|
-
:
|
|
189
|
+
: args.receiptRoot
|
|
190
|
+
? path.resolve(args.cwd, args.receiptRoot)
|
|
191
|
+
: resolveGoStateRoot(discovery, args.cwd);
|
|
192
|
+
|
|
186
193
|
const runtimeRoot = discovery.runtime?.runtimeRoot || path.join(productRoot, 'runtime');
|
|
187
194
|
|
|
188
195
|
if (args.subcommand === 'menu' && process.stdout.isTTY && !args.json) {
|
|
@@ -485,7 +492,7 @@ async function shipCloudflare({ discovery, productRoot, stateRoot, runtimeRoot,
|
|
|
485
492
|
}
|
|
486
493
|
|
|
487
494
|
const preflight = preflightToolchain({
|
|
488
|
-
requireDocker: !args.skipDeploy,
|
|
495
|
+
requireDocker: !args.skipDeploy && !args.dryRun,
|
|
489
496
|
productRoot,
|
|
490
497
|
});
|
|
491
498
|
for (const check of preflight.checks) {
|
|
@@ -519,7 +526,7 @@ async function shipCloudflare({ discovery, productRoot, stateRoot, runtimeRoot,
|
|
|
519
526
|
note('✓ native runtime boot/probe/shutdown');
|
|
520
527
|
|
|
521
528
|
let container = null;
|
|
522
|
-
if (!args.skipDeploy) {
|
|
529
|
+
if (!args.skipDeploy && !args.dryRun) {
|
|
523
530
|
if (!args.json) write('\n Container\n');
|
|
524
531
|
container = await verifyGoContainer({
|
|
525
532
|
productRoot,
|
|
@@ -634,6 +641,62 @@ async function shipCloudflare({ discovery, productRoot, stateRoot, runtimeRoot,
|
|
|
634
641
|
|
|
635
642
|
async function runInteractiveMenu({ discovery, productRoot, stateRoot, runtimeRoot, args, write }) {
|
|
636
643
|
intro(pc.bgCyan(pc.black(' Agent Sam · Go ')));
|
|
644
|
+
|
|
645
|
+
const receiptChoice = await select({
|
|
646
|
+
message: 'Where should AgentSam Go store run receipts?',
|
|
647
|
+
options: [
|
|
648
|
+
{
|
|
649
|
+
value: 'project',
|
|
650
|
+
label: 'This project',
|
|
651
|
+
hint: path.join(stateRoot, '.agentsam', 'go'),
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
value: 'home',
|
|
655
|
+
label: 'Central AgentSam receipts folder',
|
|
656
|
+
hint: '~/.agentsam/receipts',
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
value: 'custom',
|
|
660
|
+
label: 'Choose another folder',
|
|
661
|
+
},
|
|
662
|
+
],
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
if (isCancel(receiptChoice)) {
|
|
666
|
+
cancel('Cancelled.');
|
|
667
|
+
return { ok: false, cancelled: true };
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (receiptChoice === 'home') {
|
|
671
|
+
stateRoot = path.join(
|
|
672
|
+
process.env.HOME || process.env.USERPROFILE || stateRoot,
|
|
673
|
+
'.agentsam',
|
|
674
|
+
'receipts',
|
|
675
|
+
path.basename(path.resolve(args.cwd)),
|
|
676
|
+
);
|
|
677
|
+
} else if (receiptChoice === 'custom') {
|
|
678
|
+
const customRoot = await text({
|
|
679
|
+
message: 'Receipt/state base directory',
|
|
680
|
+
placeholder: '/path/to/agentsam-receipts',
|
|
681
|
+
validate(value) {
|
|
682
|
+
return String(value || '').trim()
|
|
683
|
+
? undefined
|
|
684
|
+
: 'Enter a directory.';
|
|
685
|
+
},
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
if (isCancel(customRoot)) {
|
|
689
|
+
cancel('Cancelled.');
|
|
690
|
+
return { ok: false, cancelled: true };
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
stateRoot = path.resolve(
|
|
694
|
+
String(customRoot).replace(/^~(?=\/|$)/, process.env.HOME || '~'),
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
write(`\n Receipts\n ${path.join(stateRoot, '.agentsam', 'go')}\n`);
|
|
699
|
+
|
|
637
700
|
const status = readLatestStatus(stateRoot);
|
|
638
701
|
write(`\n Runtime\n`);
|
|
639
702
|
write(` ${discovery.go?.ok ? '✓' : '✗'} Go ${discovery.go?.goversion || ''}\n`);
|
|
@@ -671,7 +734,14 @@ async function runInteractiveMenu({ discovery, productRoot, stateRoot, runtimeRo
|
|
|
671
734
|
return { ok: false, cancelled: true };
|
|
672
735
|
}
|
|
673
736
|
outro(`Running ${action}`);
|
|
674
|
-
const forwarded = [
|
|
737
|
+
const forwarded = [
|
|
738
|
+
action,
|
|
739
|
+
args.product,
|
|
740
|
+
'--cwd',
|
|
741
|
+
args.cwd,
|
|
742
|
+
'--receipt-root',
|
|
743
|
+
stateRoot,
|
|
744
|
+
];
|
|
675
745
|
if (action === 'deploy') forwarded.push('--cloudflare');
|
|
676
746
|
if (args.json) forwarded.push('--json');
|
|
677
747
|
return runGo(forwarded, { write });
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
HOOK_CONFIG_SCHEMA,
|
|
5
|
+
createHookRuntime,
|
|
6
|
+
createHookRuntimeFromConfig,
|
|
7
|
+
findHookConfig,
|
|
8
|
+
loadHookConfig,
|
|
9
|
+
registerStoredHooks,
|
|
10
|
+
} from '../../packages/agentsam-hooks/src/index.js';
|
|
11
|
+
import { findCliProjectRoot } from '../lib/cli-preferences.js';
|
|
12
|
+
import { readAccountSession } from '../lib/account-session.js';
|
|
13
|
+
import {
|
|
14
|
+
listRuntimeHooks,
|
|
15
|
+
listRuntimeHookExecutions,
|
|
16
|
+
recordRuntimeHookReceipt,
|
|
17
|
+
setRuntimeHookActive,
|
|
18
|
+
} from '../local/runtime-store.js';
|
|
19
|
+
|
|
20
|
+
function clean(value) { return value == null ? '' : String(value).trim(); }
|
|
21
|
+
function writeLine(write, value = '') { write(`${value}\n`); }
|
|
22
|
+
function countConfigured(config) {
|
|
23
|
+
return Object.values(config?.hooks || {}).reduce((sum, rows) => sum + rows.length, 0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function registerCodeHooks(runtime, hooks = {}) {
|
|
27
|
+
for (const [event, definitions] of Object.entries(hooks || {})) {
|
|
28
|
+
for (const definition of Array.isArray(definitions) ? definitions : [definitions]) {
|
|
29
|
+
if (typeof definition === 'function') {
|
|
30
|
+
runtime.register(event, { handler: definition, metadata: { hook_source: 'code' } });
|
|
31
|
+
} else {
|
|
32
|
+
runtime.register(event, {
|
|
33
|
+
...definition,
|
|
34
|
+
metadata: { ...(definition?.metadata || {}), hook_source: 'code' },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Resolve code, project config, and stored definitions into one ordered runtime.
|
|
43
|
+
* The source changes authoring/ownership only; dispatch semantics stay identical.
|
|
44
|
+
*/
|
|
45
|
+
export async function createProjectHookRuntime(options = {}) {
|
|
46
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
47
|
+
const projectRoot = path.resolve(options.projectRoot || findCliProjectRoot(cwd));
|
|
48
|
+
const accountId = clean(options.ownerId || readAccountSession({ home: options.home })?.account_id) || 'local';
|
|
49
|
+
const sourceByHook = new Map();
|
|
50
|
+
const persistReceipts = options.persistReceipts !== false;
|
|
51
|
+
const runtime = createHookRuntime({
|
|
52
|
+
clock: options.clock,
|
|
53
|
+
async onReceipt(receipt) {
|
|
54
|
+
const definition = sourceByHook.get(`${receipt.hook}:${receipt.hook_id}`) || { source: 'code', stored_hook_id: null };
|
|
55
|
+
if (persistReceipts) {
|
|
56
|
+
await recordRuntimeHookReceipt({
|
|
57
|
+
projectRoot,
|
|
58
|
+
owner_id: accountId,
|
|
59
|
+
receipt,
|
|
60
|
+
source_kind: definition.source,
|
|
61
|
+
hook_id: definition.stored_hook_id,
|
|
62
|
+
session_id: options.sessionId,
|
|
63
|
+
conversation_id: options.conversationId,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (typeof options.onReceipt === 'function') await options.onReceipt(receipt);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
registerCodeHooks(runtime, options.hooks);
|
|
71
|
+
const configFile = options.configFile || findHookConfig(cwd, { stopAt: projectRoot });
|
|
72
|
+
let config = null;
|
|
73
|
+
if (configFile) {
|
|
74
|
+
({ config } = createHookRuntimeFromConfig(configFile, {
|
|
75
|
+
runtime,
|
|
76
|
+
cwd,
|
|
77
|
+
env: options.env,
|
|
78
|
+
fetchImpl: options.fetchImpl,
|
|
79
|
+
restrictCommandCwd: options.restrictCommandCwd,
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const stored = await registerStoredHooks(runtime, {
|
|
84
|
+
listHooks: (query) => listRuntimeHooks({
|
|
85
|
+
projectRoot,
|
|
86
|
+
owner_id: accountId,
|
|
87
|
+
...query,
|
|
88
|
+
}),
|
|
89
|
+
}, {
|
|
90
|
+
cwd: projectRoot,
|
|
91
|
+
env: options.env,
|
|
92
|
+
fetchImpl: options.fetchImpl,
|
|
93
|
+
restrictCommandCwd: options.restrictCommandCwd,
|
|
94
|
+
resolveHandler: options.resolveHandler,
|
|
95
|
+
context: {
|
|
96
|
+
owner_id: accountId,
|
|
97
|
+
account_id: accountId,
|
|
98
|
+
project_id: options.projectId,
|
|
99
|
+
project_root: projectRoot,
|
|
100
|
+
repository_id: options.repositoryId,
|
|
101
|
+
session_id: options.sessionId,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
for (const definition of runtime.list()) {
|
|
106
|
+
sourceByHook.set(`${definition.hook}:${definition.id}`, {
|
|
107
|
+
source: clean(definition.metadata?.hook_source) || (definition.metadata?.stored_hook_id ? 'stored' : definition.metadata?.config_source ? 'config' : 'code'),
|
|
108
|
+
stored_hook_id: clean(definition.metadata?.stored_hook_id) || null,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return Object.freeze({
|
|
112
|
+
runtime,
|
|
113
|
+
owner_id: accountId,
|
|
114
|
+
project_root: projectRoot,
|
|
115
|
+
config,
|
|
116
|
+
config_file: configFile || null,
|
|
117
|
+
stored,
|
|
118
|
+
definitions: runtime.list(),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function hookTemplate() {
|
|
123
|
+
return {
|
|
124
|
+
schema: HOOK_CONFIG_SCHEMA,
|
|
125
|
+
adapters: {},
|
|
126
|
+
hooks: {},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function parseLimit(argv, fallback = 30) {
|
|
131
|
+
const index = argv.indexOf('--limit');
|
|
132
|
+
if (index === -1) return fallback;
|
|
133
|
+
const value = Number(argv[index + 1]);
|
|
134
|
+
if (!Number.isInteger(value) || value < 1 || value > 500) throw new Error('hooks_limit_must_be_between_1_and_500');
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function renderHookRows(rows, write) {
|
|
139
|
+
if (!rows.length) {
|
|
140
|
+
writeLine(write, ' No hooks configured. Run `agentsam hooks init` or add a stored hook.');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
for (const row of rows) {
|
|
144
|
+
const source = clean(row.metadata?.hook_source || row.source_kind) || 'code';
|
|
145
|
+
const state = row.enabled === false || row.is_active === false ? 'disabled' : 'active';
|
|
146
|
+
const handler = clean(row.handler_type || row.metadata?.adapter) || 'callback';
|
|
147
|
+
writeLine(write, ` ${String(row.hook || row.event_type).padEnd(25)} ${String(row.id || row.hook_key).padEnd(28)} ${source.padEnd(7)} ${handler.padEnd(10)} ${state} · p${row.priority ?? 100}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export async function runHooks(argv = [], options = {}) {
|
|
152
|
+
const write = options.write || ((text) => process.stdout.write(text));
|
|
153
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
154
|
+
const projectRoot = findCliProjectRoot(cwd);
|
|
155
|
+
const jsonOutput = argv.includes('--json');
|
|
156
|
+
const command = argv.find((arg) => !arg.startsWith('-')) || 'status';
|
|
157
|
+
if (argv.includes('--help') || argv.includes('-h') || command === 'help') {
|
|
158
|
+
write([
|
|
159
|
+
'agentsam hooks [status|list|executions|validate|init|enable|disable] [--json]',
|
|
160
|
+
'',
|
|
161
|
+
'One hook concept, three authoring sources: code, project config, and stored rows.',
|
|
162
|
+
' status Show active sources and execution evidence',
|
|
163
|
+
' list Show the merged dispatch order with source badges',
|
|
164
|
+
' executions [--limit N] Show recent value-free receipts',
|
|
165
|
+
' validate [config] Validate a portable hook config',
|
|
166
|
+
' init Create .agentsam/hooks.json (idempotent)',
|
|
167
|
+
' enable|disable <key> Toggle a stored hook without editing code/config',
|
|
168
|
+
'',
|
|
169
|
+
].join('\n'));
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (command === 'init') {
|
|
174
|
+
const filename = path.join(projectRoot, '.agentsam', 'hooks.json');
|
|
175
|
+
fs.mkdirSync(path.dirname(filename), { recursive: true });
|
|
176
|
+
const created = !fs.existsSync(filename);
|
|
177
|
+
if (created) fs.writeFileSync(filename, `${JSON.stringify(hookTemplate(), null, 2)}\n`, { mode: 0o600 });
|
|
178
|
+
const loaded = loadHookConfig(filename);
|
|
179
|
+
const result = { ok: true, created, source: filename, schema: loaded.schema };
|
|
180
|
+
if (jsonOutput) writeLine(write, JSON.stringify(result, null, 2));
|
|
181
|
+
else writeLine(write, ` Hooks config ready · ${filename}`);
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (command === 'validate') {
|
|
186
|
+
const commandIndex = argv.indexOf(command);
|
|
187
|
+
const candidate = argv.slice(commandIndex + 1).find((arg) => !arg.startsWith('-'));
|
|
188
|
+
const filename = candidate || findHookConfig(cwd, { stopAt: projectRoot });
|
|
189
|
+
if (!filename) throw new Error('agentsam_hook_config_not_found');
|
|
190
|
+
const config = loadHookConfig(filename);
|
|
191
|
+
const result = { ok: true, schema: config.schema, source: config.source, adapters: Object.keys(config.adapters).length, hooks: countConfigured(config) };
|
|
192
|
+
if (jsonOutput) writeLine(write, JSON.stringify(result, null, 2));
|
|
193
|
+
else writeLine(write, ` Valid · ${result.hooks} hooks · ${result.adapters} adapters · ${result.source}`);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const ownerId = clean(options.ownerId || readAccountSession({ home: options.home })?.account_id) || 'local';
|
|
198
|
+
if (command === 'enable' || command === 'disable') {
|
|
199
|
+
const key = argv[argv.indexOf(command) + 1];
|
|
200
|
+
if (!key || key.startsWith('-')) throw new Error(`hooks_${command}_requires_key`);
|
|
201
|
+
const changed = await setRuntimeHookActive({ projectRoot, owner_id: ownerId, hook_key: key, active: command === 'enable' });
|
|
202
|
+
if (!changed) throw new Error(`stored_hook_not_found:${key}`);
|
|
203
|
+
const result = { ok: true, hook_key: key, active: command === 'enable' };
|
|
204
|
+
if (jsonOutput) writeLine(write, JSON.stringify(result, null, 2));
|
|
205
|
+
else writeLine(write, ` ${key} → ${result.active ? 'enabled' : 'disabled'}`);
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (command === 'executions') {
|
|
210
|
+
const executions = await listRuntimeHookExecutions({ projectRoot, owner_id: ownerId, limit: parseLimit(argv) });
|
|
211
|
+
if (jsonOutput) writeLine(write, JSON.stringify({ schema: 'agentsam.hook.executions.v1', executions }, null, 2));
|
|
212
|
+
else {
|
|
213
|
+
writeLine(write, '\n Recent hook executions');
|
|
214
|
+
if (!executions.length) writeLine(write, ' No hook receipts recorded yet.');
|
|
215
|
+
for (const row of executions) {
|
|
216
|
+
const at = new Date(Number(row.ran_at_unix) * 1000).toISOString();
|
|
217
|
+
writeLine(write, ` ${at} ${String(row.status).padEnd(9)} ${String(row.event_type).padEnd(24)} ${row.hook_key} · ${row.duration_ms}ms`);
|
|
218
|
+
}
|
|
219
|
+
writeLine(write);
|
|
220
|
+
}
|
|
221
|
+
return executions;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (!['status', 'list'].includes(command)) throw new Error(`unknown_hooks_command:${command}`);
|
|
225
|
+
const resolved = await createProjectHookRuntime({
|
|
226
|
+
cwd,
|
|
227
|
+
projectRoot,
|
|
228
|
+
ownerId,
|
|
229
|
+
home: options.home,
|
|
230
|
+
hooks: options.hooks,
|
|
231
|
+
persistReceipts: false,
|
|
232
|
+
});
|
|
233
|
+
const storedAll = await listRuntimeHooks({ projectRoot, owner_id: ownerId, activeOnly: false });
|
|
234
|
+
const result = {
|
|
235
|
+
schema: 'agentsam.hooks.status.v1',
|
|
236
|
+
project_root: projectRoot,
|
|
237
|
+
owner_id: ownerId,
|
|
238
|
+
config: resolved.config ? { source: resolved.config_file, hooks: countConfigured(resolved.config), adapters: Object.keys(resolved.config.adapters).length } : null,
|
|
239
|
+
sources: {
|
|
240
|
+
code: resolved.definitions.filter((row) => row.metadata?.hook_source === 'code').length,
|
|
241
|
+
config: resolved.definitions.filter((row) => row.metadata?.hook_source === 'config').length,
|
|
242
|
+
stored_active: resolved.definitions.filter((row) => row.metadata?.hook_source === 'stored').length,
|
|
243
|
+
stored_total: storedAll.length,
|
|
244
|
+
},
|
|
245
|
+
hooks: resolved.definitions,
|
|
246
|
+
};
|
|
247
|
+
if (jsonOutput) writeLine(write, JSON.stringify(result, null, 2));
|
|
248
|
+
else {
|
|
249
|
+
writeLine(write, '\n Agent Sam · hooks');
|
|
250
|
+
writeLine(write, ' One ordered lifecycle contract · code is read-only · config/stored hooks are portable.');
|
|
251
|
+
writeLine(write, ` project ${projectRoot}`);
|
|
252
|
+
writeLine(write, ` config ${result.config ? `${result.config.hooks} hooks · ${result.config.source}` : 'not configured'}`);
|
|
253
|
+
writeLine(write, ` stored ${result.sources.stored_active} active · ${result.sources.stored_total} total`);
|
|
254
|
+
writeLine(write, '');
|
|
255
|
+
if (command === 'list') renderHookRows([...resolved.definitions, ...storedAll.filter((row) => !row.is_active)], write);
|
|
256
|
+
else writeLine(write, ' Use `agentsam hooks list` for dispatch order and `agentsam hooks executions` for receipts.');
|
|
257
|
+
writeLine(write);
|
|
258
|
+
}
|
|
259
|
+
return result;
|
|
260
|
+
}
|
package/src/commands/mini.js
CHANGED
|
@@ -7,7 +7,7 @@ export function printMiniHelp() {
|
|
|
7
7
|
console.log(`
|
|
8
8
|
agentsam mini — small local gadgets and prototypes
|
|
9
9
|
|
|
10
|
-
agentsam mini <name> Create and preview a
|
|
10
|
+
agentsam mini <name> Create and preview a small interactive prototype
|
|
11
11
|
agentsam mini <name> --template page Create and preview a simple page
|
|
12
12
|
agentsam mini <name> --template data Create and preview a JSON viewer
|
|
13
13
|
agentsam mini <name> --write-only Create files without starting anything
|
package/src/commands/models.js
CHANGED
|
@@ -17,7 +17,7 @@ export const API_PROVIDERS = Object.freeze([
|
|
|
17
17
|
{ id: 'openai', label: 'OpenAI', credential: 'OPENAI_API_KEY' },
|
|
18
18
|
{ id: 'anthropic', label: 'Anthropic', credential: 'ANTHROPIC_API_KEY' },
|
|
19
19
|
{ id: 'gemini', label: 'Gemini', credential: 'GEMINI_API_KEY' },
|
|
20
|
-
{ id: '
|
|
20
|
+
{ id: 'xai', label: 'Grok / xAI', credential: 'XAI_API_KEY' },
|
|
21
21
|
{ id: 'cursor', label: 'Cursor', credential: 'CURSOR_API_KEY' },
|
|
22
22
|
{ id: 'cloudflare', label: 'Cloudflare', credential: 'CLOUDFLARE_API_TOKEN' },
|
|
23
23
|
]);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
pruneLocalWorkspaces,
|
|
5
|
+
validateReceiptEnvelope,
|
|
6
|
+
} from "../receipts/index.js";
|
|
7
|
+
|
|
8
|
+
function intFlag(args, flag, fallback) {
|
|
9
|
+
const index = args.indexOf(flag);
|
|
10
|
+
const value = index >= 0 ? Number.parseInt(args[index + 1], 10) : NaN;
|
|
11
|
+
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function numberFlag(args, flag, fallback) {
|
|
15
|
+
const index = args.indexOf(flag);
|
|
16
|
+
const value = index >= 0 ? Number(args[index + 1]) : NaN;
|
|
17
|
+
return Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function stringFlag(args, flag) {
|
|
21
|
+
const index = args.indexOf(flag);
|
|
22
|
+
return index >= 0 && args[index + 1] ? args[index + 1] : null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function readLocalReceipts(directory) {
|
|
26
|
+
const entries = await readdir(directory, { withFileTypes: true }).catch(() => []);
|
|
27
|
+
const receipts = [];
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
30
|
+
try {
|
|
31
|
+
const value = JSON.parse(
|
|
32
|
+
await readFile(path.join(directory, entry.name), "utf8"),
|
|
33
|
+
);
|
|
34
|
+
if (validateReceiptEnvelope(value).ok) receipts.push(value);
|
|
35
|
+
} catch {}
|
|
36
|
+
}
|
|
37
|
+
receipts.sort(
|
|
38
|
+
(a, b) =>
|
|
39
|
+
Number(b.metrics?.created_at_unix || 0) -
|
|
40
|
+
Number(a.metrics?.created_at_unix || 0),
|
|
41
|
+
);
|
|
42
|
+
return receipts;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function writeSummary(receipt) {
|
|
46
|
+
const date = new Date(
|
|
47
|
+
Number(receipt.metrics?.created_at_unix || 0) * 1000,
|
|
48
|
+
).toISOString();
|
|
49
|
+
process.stdout.write(
|
|
50
|
+
[
|
|
51
|
+
receipt.receipt_id,
|
|
52
|
+
receipt.status,
|
|
53
|
+
receipt.kind,
|
|
54
|
+
date,
|
|
55
|
+
receipt.identity?.repository_id || "-",
|
|
56
|
+
].join("\t") + "\n",
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function runReceipts(args = [], options = {}) {
|
|
61
|
+
const [command = "list", ...rest] = args;
|
|
62
|
+
const localDir =
|
|
63
|
+
options.localDir ||
|
|
64
|
+
stringFlag(rest, "--dir") ||
|
|
65
|
+
path.join(process.cwd(), ".agentsam", "receipts");
|
|
66
|
+
|
|
67
|
+
if (command === "prune") {
|
|
68
|
+
const result = await pruneLocalWorkspaces({
|
|
69
|
+
maxTmpGb: numberFlag(rest, "--max-tmp-gb", 1),
|
|
70
|
+
dryRun: rest.includes("--dry-run"),
|
|
71
|
+
});
|
|
72
|
+
if (rest.includes("--json")) {
|
|
73
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
74
|
+
} else {
|
|
75
|
+
process.stdout.write(
|
|
76
|
+
"Scanned " +
|
|
77
|
+
result.scannedCount +
|
|
78
|
+
" AgentSam workdirs; purged " +
|
|
79
|
+
result.purgedCount +
|
|
80
|
+
"; " +
|
|
81
|
+
result.remainingBytes +
|
|
82
|
+
" bytes remain.\n",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const receipts = options.catalog
|
|
89
|
+
? await options.catalog.list({
|
|
90
|
+
limit: intFlag(rest, "--limit", 20),
|
|
91
|
+
repositoryId: stringFlag(rest, "--repo"),
|
|
92
|
+
status: command === "failures" ? "failed" : undefined,
|
|
93
|
+
})
|
|
94
|
+
: await readLocalReceipts(localDir);
|
|
95
|
+
|
|
96
|
+
if (command === "show") {
|
|
97
|
+
const id = rest.find((arg) => !arg.startsWith("--"));
|
|
98
|
+
if (!id) throw new Error("agentsam receipts show requires a receipt id");
|
|
99
|
+
const receipt = options.catalog
|
|
100
|
+
? await options.catalog.get(id)
|
|
101
|
+
: receipts.find((item) => item.receipt_id === id);
|
|
102
|
+
if (!receipt) {
|
|
103
|
+
const error = new Error("Receipt not found: " + id);
|
|
104
|
+
error.code = "AGENTSAM_RECEIPT_NOT_FOUND";
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
process.stdout.write(JSON.stringify(receipt, null, 2) + "\n");
|
|
108
|
+
return receipt;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!["list", "failures"].includes(command)) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
"Usage: agentsam receipts list [--limit 20] [--repo <id>]\n" +
|
|
114
|
+
" agentsam receipts show <receipt-id>\n" +
|
|
115
|
+
" agentsam receipts failures [--repo <id>]\n" +
|
|
116
|
+
" agentsam receipts prune [--max-tmp-gb 1.0] [--dry-run]",
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const repo = stringFlag(rest, "--repo");
|
|
121
|
+
const limit = intFlag(rest, "--limit", 20);
|
|
122
|
+
const filtered = receipts
|
|
123
|
+
.filter((receipt) => !repo || receipt.identity?.repository_id === repo)
|
|
124
|
+
.filter((receipt) => command !== "failures" || receipt.status === "failed")
|
|
125
|
+
.slice(0, limit);
|
|
126
|
+
|
|
127
|
+
if (rest.includes("--json")) {
|
|
128
|
+
process.stdout.write(JSON.stringify(filtered, null, 2) + "\n");
|
|
129
|
+
} else {
|
|
130
|
+
if (!options.catalog) {
|
|
131
|
+
process.stderr.write(
|
|
132
|
+
" source: local receipt cache (" +
|
|
133
|
+
localDir +
|
|
134
|
+
"); durable D1 catalog requires a host catalog adapter\n",
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
for (const receipt of filtered) writeSummary(receipt);
|
|
138
|
+
}
|
|
139
|
+
return filtered;
|
|
140
|
+
}
|