@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
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { createAgentControlClient } from '../acp/client.js';
|
|
2
|
+
|
|
3
|
+
function clean(value) { return value == null ? '' : String(value).trim(); }
|
|
4
|
+
function number(value, fallback) {
|
|
5
|
+
const n = Number(value);
|
|
6
|
+
return Number.isFinite(n) ? n : fallback;
|
|
7
|
+
}
|
|
8
|
+
function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
|
9
|
+
|
|
10
|
+
function parse(argv = []) {
|
|
11
|
+
const out = {
|
|
12
|
+
command: clean(argv[0]) || 'help',
|
|
13
|
+
id: null,
|
|
14
|
+
json: false,
|
|
15
|
+
local: false,
|
|
16
|
+
url: '',
|
|
17
|
+
once: false,
|
|
18
|
+
after: -1,
|
|
19
|
+
limit: 200,
|
|
20
|
+
intervalMs: 1000,
|
|
21
|
+
objective: '',
|
|
22
|
+
role: '',
|
|
23
|
+
workItemId: '',
|
|
24
|
+
stepId: '',
|
|
25
|
+
modelKey: '',
|
|
26
|
+
runtimeRequirements: {},
|
|
27
|
+
};
|
|
28
|
+
let i = 1;
|
|
29
|
+
if (!['help', 'start'].includes(out.command) && argv[i] && !String(argv[i]).startsWith('-')) out.id = String(argv[i++]);
|
|
30
|
+
for (; i < argv.length; i += 1) {
|
|
31
|
+
const arg = String(argv[i]);
|
|
32
|
+
if (arg === '--json') out.json = true;
|
|
33
|
+
else if (arg === '--local') out.local = true;
|
|
34
|
+
else if (arg === '--once') out.once = true;
|
|
35
|
+
else if (arg === '--url') out.url = String(argv[++i] || '');
|
|
36
|
+
else if (arg.startsWith('--url=')) out.url = arg.slice(6);
|
|
37
|
+
else if (arg === '--after') out.after = number(argv[++i], -1);
|
|
38
|
+
else if (arg.startsWith('--after=')) out.after = number(arg.slice(8), -1);
|
|
39
|
+
else if (arg === '--limit') out.limit = number(argv[++i], 200);
|
|
40
|
+
else if (arg.startsWith('--limit=')) out.limit = number(arg.slice(8), 200);
|
|
41
|
+
else if (arg === '--interval-ms') out.intervalMs = number(argv[++i], 1000);
|
|
42
|
+
else if (arg.startsWith('--interval-ms=')) out.intervalMs = number(arg.slice(14), 1000);
|
|
43
|
+
else if (arg === '--objective') out.objective = String(argv[++i] || '');
|
|
44
|
+
else if (arg.startsWith('--objective=')) out.objective = arg.slice(12);
|
|
45
|
+
else if (arg === '--role') out.role = String(argv[++i] || '');
|
|
46
|
+
else if (arg.startsWith('--role=')) out.role = arg.slice(7);
|
|
47
|
+
else if (arg === '--work-item') out.workItemId = String(argv[++i] || '');
|
|
48
|
+
else if (arg.startsWith('--work-item=')) out.workItemId = arg.slice(12);
|
|
49
|
+
else if (arg === '--step') out.stepId = String(argv[++i] || '');
|
|
50
|
+
else if (arg.startsWith('--step=')) out.stepId = arg.slice(7);
|
|
51
|
+
else if (arg === '--model') out.modelKey = String(argv[++i] || '');
|
|
52
|
+
else if (arg.startsWith('--model=')) out.modelKey = arg.slice(8);
|
|
53
|
+
else if (arg === '--runtime-json') out.runtimeRequirements = JSON.parse(String(argv[++i] || '{}'));
|
|
54
|
+
else if (arg.startsWith('--runtime-json=')) out.runtimeRequirements = JSON.parse(arg.slice(15) || '{}');
|
|
55
|
+
else throw new Error(`unknown_run_option:${arg}`);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function help() {
|
|
61
|
+
return [
|
|
62
|
+
'Agent Sam · run',
|
|
63
|
+
'Provider-neutral Agent Control Plane inspection and control.',
|
|
64
|
+
'',
|
|
65
|
+
'Usage:',
|
|
66
|
+
' agentsam run start --objective <text> [--role <slug>] [--model <key>] [--runtime-json <json>] [--json]',
|
|
67
|
+
' agentsam run get <run_id> [--json] [--local | --url <base-url>]',
|
|
68
|
+
' agentsam run tree <run_id> [--json]',
|
|
69
|
+
' agentsam run events <run_id> [--after <seq>] [--limit <n>] [--json]',
|
|
70
|
+
' agentsam run watch <run_id> [--after <seq>] [--interval-ms <ms>] [--once] [--json]',
|
|
71
|
+
' agentsam run spawn <parent_run_id> --objective <text> [--role <slug>] [--runtime-json <json>] [--json]',
|
|
72
|
+
' agentsam run cancel <run_id> [--json]',
|
|
73
|
+
' agentsam run receipt <run_id> [--json]',
|
|
74
|
+
'',
|
|
75
|
+
'Host selection:',
|
|
76
|
+
' local SQLite is the default.',
|
|
77
|
+
' AGENTSAM_CONTROL_PLANE_URL or --url selects any HTTP ACP host.',
|
|
78
|
+
' AGENTSAM_CONTROL_PLANE_TOKEN supplies hosted bearer auth without putting secrets in shell history.',
|
|
79
|
+
' --local forces the project-local SQLite control plane.',
|
|
80
|
+
].join('\n');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function formatRun(run, clientKind) {
|
|
84
|
+
if (!run) return 'run not found';
|
|
85
|
+
return [
|
|
86
|
+
'Agent Sam · run',
|
|
87
|
+
`source ${clientKind}`,
|
|
88
|
+
`id ${run.id}`,
|
|
89
|
+
`status ${run.status}${run.cancelRequested ? ' · cancel requested' : ''}`,
|
|
90
|
+
`mode ${run.mode || 'unknown'}`,
|
|
91
|
+
`parent ${run.parentRunId || '—'}`,
|
|
92
|
+
`model ${run.modelKey || '—'}`,
|
|
93
|
+
`calls model ${run.modelCallCount || 0} · tool ${run.toolCallCount || 0}`,
|
|
94
|
+
`cost $${Number(run.costUsd || 0).toFixed(6)}`,
|
|
95
|
+
run.suspension ? `wait ${run.suspension.state} · ${run.suspension.reason}` : null,
|
|
96
|
+
].filter(Boolean).join('\n');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function treeLines(node, depth = 0, rows = []) {
|
|
100
|
+
if (!node) return rows;
|
|
101
|
+
const indent = ' '.repeat(depth);
|
|
102
|
+
rows.push(`${indent}${depth ? '└─ ' : ''}${node.id} · ${node.status} · ${node.mode || 'agent'}`);
|
|
103
|
+
for (const child of node.children || []) treeLines(child, depth + 1, rows);
|
|
104
|
+
return rows;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function eventLine(event) {
|
|
108
|
+
const at = event.createdAt ? new Date(event.createdAt).toISOString() : '';
|
|
109
|
+
return `#${event.seq} ${event.eventType}${event.phase ? ` · ${event.phase}` : ''}${event.label ? ` · ${event.label}` : ''}${at ? ` · ${at}` : ''}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function requireId(args) {
|
|
113
|
+
if (!clean(args.id)) {
|
|
114
|
+
const error = new Error(`run_id_required:${args.command}`);
|
|
115
|
+
error.hint = `Usage: agentsam run ${args.command} <run_id>`;
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function runRun(argv = [], options = {}) {
|
|
121
|
+
const args = parse(argv);
|
|
122
|
+
const write = options.write || ((value) => process.stdout.write(String(value)));
|
|
123
|
+
if (args.command === 'help' || args.command === '--help' || args.command === '-h') {
|
|
124
|
+
write(help() + '\n');
|
|
125
|
+
return { ok: true, command: 'help' };
|
|
126
|
+
}
|
|
127
|
+
if (!['start', 'get', 'tree', 'events', 'watch', 'spawn', 'cancel', 'receipt'].includes(args.command)) {
|
|
128
|
+
throw new Error(`unknown_run_command:${args.command}`);
|
|
129
|
+
}
|
|
130
|
+
if (args.command !== 'start') requireId(args);
|
|
131
|
+
|
|
132
|
+
const client = options.client || createAgentControlClient({
|
|
133
|
+
cwd: options.cwd || process.cwd(),
|
|
134
|
+
url: args.url || options.url,
|
|
135
|
+
token: options.token,
|
|
136
|
+
local: args.local,
|
|
137
|
+
fetchImpl: options.fetchImpl,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (args.command === 'start') {
|
|
141
|
+
if (!clean(args.objective)) {
|
|
142
|
+
const error = new Error('run_objective_required');
|
|
143
|
+
error.hint = 'Usage: agentsam run start --objective <text>';
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
const started = await client.start({
|
|
147
|
+
objective: args.objective,
|
|
148
|
+
role: clean(args.role) || 'lead',
|
|
149
|
+
model_key: clean(args.modelKey) || null,
|
|
150
|
+
runtime_requirements: args.runtimeRequirements,
|
|
151
|
+
});
|
|
152
|
+
if (args.json) write(JSON.stringify(started, null, 2) + '\n');
|
|
153
|
+
else {
|
|
154
|
+
write([
|
|
155
|
+
'Agent Sam · run started',
|
|
156
|
+
`run ${started.run_id}`,
|
|
157
|
+
`queue ${started.queue || 'host-managed'}`,
|
|
158
|
+
`status ${started.status || 'queued'}`,
|
|
159
|
+
].join('\n') + '\n');
|
|
160
|
+
}
|
|
161
|
+
return started;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (args.command === 'get') {
|
|
165
|
+
const run = await client.getRun(args.id);
|
|
166
|
+
if (!run) throw new Error(`run_not_found:${args.id}`);
|
|
167
|
+
write(args.json ? JSON.stringify(run, null, 2) + '\n' : formatRun(run, client.kind) + '\n');
|
|
168
|
+
return run;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (args.command === 'tree') {
|
|
172
|
+
const tree = await client.tree(args.id);
|
|
173
|
+
if (!tree) throw new Error(`run_not_found:${args.id}`);
|
|
174
|
+
write(args.json ? JSON.stringify(tree, null, 2) + '\n' : treeLines(tree).join('\n') + '\n');
|
|
175
|
+
return tree;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (args.command === 'events') {
|
|
179
|
+
const events = await client.events(args.id, { after: args.after, limit: args.limit });
|
|
180
|
+
write(args.json ? JSON.stringify(events, null, 2) + '\n' : (events.map(eventLine).join('\n') || 'no events') + '\n');
|
|
181
|
+
return events;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (args.command === 'spawn') {
|
|
185
|
+
if (!clean(args.objective)) {
|
|
186
|
+
const error = new Error('child_run_objective_required');
|
|
187
|
+
error.hint = 'Usage: agentsam run spawn <parent_run_id> --objective <text>';
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
const spawned = await client.spawn(args.id, {
|
|
191
|
+
objective: args.objective,
|
|
192
|
+
role: clean(args.role) || null,
|
|
193
|
+
work_item_id: clean(args.workItemId) || null,
|
|
194
|
+
step_id: clean(args.stepId) || null,
|
|
195
|
+
model_key: clean(args.modelKey) || null,
|
|
196
|
+
runtime_requirements: args.runtimeRequirements,
|
|
197
|
+
});
|
|
198
|
+
if (args.json) write(JSON.stringify(spawned, null, 2) + '\n');
|
|
199
|
+
else {
|
|
200
|
+
write([
|
|
201
|
+
'Agent Sam · child run',
|
|
202
|
+
`parent ${spawned.parent_run_id || args.id}`,
|
|
203
|
+
`child ${spawned.child_run_id || '—'}`,
|
|
204
|
+
`queue ${spawned.queue || 'host-managed'}`,
|
|
205
|
+
`status ${spawned.dependency_status || 'pending'}`,
|
|
206
|
+
].join('\n') + '\n');
|
|
207
|
+
}
|
|
208
|
+
return spawned;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (args.command === 'cancel') {
|
|
212
|
+
const run = await client.cancel(args.id);
|
|
213
|
+
if (!run) throw new Error(`run_not_found:${args.id}`);
|
|
214
|
+
write(args.json ? JSON.stringify(run, null, 2) + '\n' : formatRun(run, client.kind) + '\n');
|
|
215
|
+
return run;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (args.command === 'receipt') {
|
|
219
|
+
const receipt = await client.receipt(args.id);
|
|
220
|
+
if (!receipt) throw new Error(`run_not_found:${args.id}`);
|
|
221
|
+
if (args.json) write(JSON.stringify(receipt, null, 2) + '\n');
|
|
222
|
+
else {
|
|
223
|
+
write([
|
|
224
|
+
'Agent Sam · run receipt',
|
|
225
|
+
`id ${receipt.runId}`,
|
|
226
|
+
`status ${receipt.status}`,
|
|
227
|
+
`terminal ${receipt.terminal ? 'yes' : 'no'}`,
|
|
228
|
+
`events ${receipt.eventCount}`,
|
|
229
|
+
`children ${receipt.childRunCount}`,
|
|
230
|
+
`cost $${Number(receipt.usage?.costUsd || 0).toFixed(6)}`,
|
|
231
|
+
].join('\n') + '\n');
|
|
232
|
+
}
|
|
233
|
+
return receipt;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
let after = args.after;
|
|
237
|
+
const seen = [];
|
|
238
|
+
const wait = options.sleep || sleep;
|
|
239
|
+
do {
|
|
240
|
+
const events = await client.events(args.id, { after, limit: args.limit });
|
|
241
|
+
for (const event of events) {
|
|
242
|
+
seen.push(event);
|
|
243
|
+
after = Math.max(after, Number(event.seq));
|
|
244
|
+
write(args.json ? JSON.stringify(event) + '\n' : eventLine(event) + '\n');
|
|
245
|
+
}
|
|
246
|
+
const run = await client.getRun(args.id);
|
|
247
|
+
if (!run) throw new Error(`run_not_found:${args.id}`);
|
|
248
|
+
if (args.once || ['completed', 'failed', 'cancelled', 'timed_out'].includes(run.status)) {
|
|
249
|
+
return { run, events: seen, after };
|
|
250
|
+
}
|
|
251
|
+
await wait(Math.max(100, args.intervalMs));
|
|
252
|
+
} while (true);
|
|
253
|
+
}
|
package/src/commands/shell.js
CHANGED
|
@@ -33,6 +33,7 @@ import { grantExecutionApproval, isExecutionApproved, toolApprovalKey } from '..
|
|
|
33
33
|
import { runWhoami } from './whoami.js';
|
|
34
34
|
import { runCredentials } from './credentials.js';
|
|
35
35
|
import { runCheatSheet } from './cheat-sheet.js';
|
|
36
|
+
import { createProjectHookRuntime, runHooks } from './hooks.js';
|
|
36
37
|
import pkg from '../../package.json' with { type: 'json' };
|
|
37
38
|
import { runLogin, runLogout } from './account-auth.js';
|
|
38
39
|
import { runHelp } from '../ui/cli/help.js';
|
|
@@ -262,21 +263,48 @@ function spawnGit(cwd, args) {
|
|
|
262
263
|
if (result.status !== 0) throw new Error(`git exited ${result.status}`);
|
|
263
264
|
}
|
|
264
265
|
|
|
265
|
-
function selectedModel(cwd) {
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
|
|
266
|
+
function selectedModel(cwd, state = null) {
|
|
267
|
+
const saved = readCliPreferences(cwd) || {};
|
|
268
|
+
const sessionConfig = state?.hookEffectiveConfig || {};
|
|
269
|
+
const preferences = {
|
|
270
|
+
...saved,
|
|
271
|
+
...(sessionConfig.model_key ? { modelPreference: sessionConfig.model_key } : {}),
|
|
272
|
+
...(sessionConfig.reasoning_effort ? { reasoningEffort: sessionConfig.reasoning_effort } : {}),
|
|
273
|
+
...(sessionConfig.requested_service_tier ? { serviceTier: sessionConfig.requested_service_tier } : {}),
|
|
274
|
+
};
|
|
275
|
+
const snapshot = saved.modelSnapshot?.model_key === preferences.modelPreference
|
|
276
|
+
? mergeModelReference(saved.modelSnapshot)
|
|
269
277
|
: null;
|
|
270
278
|
let model = snapshot || getModelRecord(preferences.modelPreference);
|
|
279
|
+
if (!model && sessionConfig.model_key && sessionConfig.model_key.includes(':')) {
|
|
280
|
+
const [provider, ...modelParts] = sessionConfig.model_key.split(':');
|
|
281
|
+
const providerModelId = modelParts.join(':');
|
|
282
|
+
if (provider && providerModelId) {
|
|
283
|
+
model = {
|
|
284
|
+
model_key: sessionConfig.model_key,
|
|
285
|
+
provider,
|
|
286
|
+
provider_model_id: providerModelId,
|
|
287
|
+
label: providerModelId,
|
|
288
|
+
context_window: null,
|
|
289
|
+
context_window_source: 'unknown',
|
|
290
|
+
max_output_tokens: null,
|
|
291
|
+
max_output_tokens_source: 'unknown',
|
|
292
|
+
reasoning_efforts: ['auto'],
|
|
293
|
+
default_reasoning_effort: null,
|
|
294
|
+
service_tiers: ['default'],
|
|
295
|
+
capabilities: {},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
271
299
|
if (!model && (preferences.modelPreference === 'auto' || !preferences.modelPreference)) {
|
|
272
|
-
model = mergeModelReference(
|
|
300
|
+
model = mergeModelReference(saved.modelSnapshot) || listModelCatalog()[0];
|
|
273
301
|
}
|
|
274
302
|
if (!model) throw new Error('Select an exact provider-verified model with /model first so Agent Sam can verify supported runtime controls.');
|
|
275
303
|
return { preferences, model };
|
|
276
304
|
}
|
|
277
305
|
|
|
278
306
|
async function resolveModelForTurn(cwd, state) {
|
|
279
|
-
const selected = selectedModel(cwd);
|
|
307
|
+
const selected = selectedModel(cwd, state);
|
|
280
308
|
const { preferences } = selected;
|
|
281
309
|
let model = selected.model;
|
|
282
310
|
|
|
@@ -291,7 +319,7 @@ async function resolveModelForTurn(cwd, state) {
|
|
|
291
319
|
capabilities: { ...(model.capabilities || {}), local_runtime: true, ...(Object.fromEntries((probe.capabilities || []).map((name) => [name, true]))) },
|
|
292
320
|
};
|
|
293
321
|
updateCliPreferences(cwd, { modelPreference: model.model_key, modelSnapshot: model });
|
|
294
|
-
return { preferences: readCliPreferences(cwd) || preferences, model, credential: null, verification: 'local_runtime' };
|
|
322
|
+
return { preferences: { ...(readCliPreferences(cwd) || preferences), reasoningEffort: preferences.reasoningEffort, serviceTier: preferences.serviceTier }, model, credential: null, verification: 'local_runtime' };
|
|
295
323
|
}
|
|
296
324
|
|
|
297
325
|
const credential = resolveProviderCredential(model.provider, { home: state.home });
|
|
@@ -305,7 +333,7 @@ async function resolveModelForTurn(cwd, state) {
|
|
|
305
333
|
if (!live) throw new Error(`selected_model_not_available_for_credential:${model.provider}:${model.provider_model_id}`);
|
|
306
334
|
model = live;
|
|
307
335
|
updateCliPreferences(cwd, { modelPreference: live.model_key, modelSnapshot: live });
|
|
308
|
-
return { preferences: readCliPreferences(cwd) || preferences, model, credential, verification: 'provider_api' };
|
|
336
|
+
return { preferences: { ...(readCliPreferences(cwd) || preferences), reasoningEffort: preferences.reasoningEffort, serviceTier: preferences.serviceTier }, model, credential, verification: 'provider_api' };
|
|
309
337
|
}
|
|
310
338
|
|
|
311
339
|
if (preferences.modelSnapshot?.availability === 'available') {
|
|
@@ -595,7 +623,47 @@ function checkpointCompaction(state, model, result) {
|
|
|
595
623
|
return receipt;
|
|
596
624
|
}
|
|
597
625
|
|
|
626
|
+
async function ensureShellHookExperience(state) {
|
|
627
|
+
if (state.hookExperience) return state.hookExperience;
|
|
628
|
+
const experience = await createProjectHookRuntime({
|
|
629
|
+
cwd: state.cwd,
|
|
630
|
+
projectRoot: state.projectRoot,
|
|
631
|
+
home: state.home,
|
|
632
|
+
sessionId: state.session?.id,
|
|
633
|
+
conversationId: state.session?.conversation_id,
|
|
634
|
+
hooks: state.codeHooks,
|
|
635
|
+
});
|
|
636
|
+
state.hookExperience = experience;
|
|
637
|
+
if (!state.hookSessionStarted) {
|
|
638
|
+
const config = {
|
|
639
|
+
model_key: state.session?.model_key || null,
|
|
640
|
+
reasoning_effort: state.session?.reasoning_effort || null,
|
|
641
|
+
requested_service_tier: state.session?.requested_service_tier || 'default',
|
|
642
|
+
auto_compact: state.session?.auto_compact !== false,
|
|
643
|
+
};
|
|
644
|
+
const started = await experience.runtime.dispatch('session_start', {
|
|
645
|
+
config,
|
|
646
|
+
project_root: state.projectRoot,
|
|
647
|
+
cwd: state.cwd,
|
|
648
|
+
}, {
|
|
649
|
+
session_id: state.session?.id,
|
|
650
|
+
source: 'agentsam-cli',
|
|
651
|
+
}, { cwd: state.cwd });
|
|
652
|
+
const modified = started.input.config || config;
|
|
653
|
+
const allowed = {};
|
|
654
|
+
for (const key of ['model_key', 'reasoning_effort', 'requested_service_tier', 'auto_compact']) {
|
|
655
|
+
if (modified[key] !== undefined) allowed[key] = modified[key];
|
|
656
|
+
}
|
|
657
|
+
state.hookEffectiveConfig = { ...config, ...allowed };
|
|
658
|
+
if (state.session && Object.keys(allowed).length) persistSession(state, allowed);
|
|
659
|
+
state.hookSessionContext = started.output.additional_context || null;
|
|
660
|
+
state.hookSessionStarted = true;
|
|
661
|
+
}
|
|
662
|
+
return experience;
|
|
663
|
+
}
|
|
664
|
+
|
|
598
665
|
async function runInteractiveModelTurn(prompt, state) {
|
|
666
|
+
const hookExperience = await ensureShellHookExperience(state);
|
|
599
667
|
const resolved = await resolveModelForTurn(state.cwd, state);
|
|
600
668
|
const { preferences, model, credential } = resolved;
|
|
601
669
|
const provider = createProviderAdapter({
|
|
@@ -660,7 +728,13 @@ async function runInteractiveModelTurn(prompt, state) {
|
|
|
660
728
|
autoCompact: state.session?.auto_compact !== false,
|
|
661
729
|
onCompaction: result => { if (state.session) checkpointCompaction(state, model, result); },
|
|
662
730
|
promptCacheKey: state.session?.id || undefined,
|
|
731
|
+
hookRuntime: hookExperience.runtime,
|
|
732
|
+
sessionId: state.session?.id || undefined,
|
|
663
733
|
runId: runtimeRunId || state.session?.id || undefined,
|
|
734
|
+
source: 'agentsam-cli',
|
|
735
|
+
...(state.hookSessionContext ? {
|
|
736
|
+
contextItems: [{ kind: 'hook', ref: 'hook://session-start/context', priority: 96, content: state.hookSessionContext }],
|
|
737
|
+
} : {}),
|
|
664
738
|
beforeRequest: (preflight) => approveModelRequest(preflight, state),
|
|
665
739
|
beforeTool: (request) => approveToolExecution(request, state),
|
|
666
740
|
emit(event) {
|
|
@@ -793,7 +867,7 @@ export async function dispatchShellLine(line, state = {}) {
|
|
|
793
867
|
'help', 'exit', 'quit', 'clear', 'status', 'models', 'model',
|
|
794
868
|
'whoami', 'cf', 'cloudflare', 'db', 'tunnel', 'connections',
|
|
795
869
|
'connect', 'usage', 'session', 'providers', 'credentials', 'cheatsheet',
|
|
796
|
-
'settings', 'logs',
|
|
870
|
+
'settings', 'logs', 'hooks', 'hook',
|
|
797
871
|
'git', 'diff', 'pwd', 'cd', 'fast', 'flex', 'standard', 'reasoning',
|
|
798
872
|
];
|
|
799
873
|
if (commonVerbs.includes(bare)) {
|
|
@@ -862,6 +936,22 @@ export async function dispatchShellLine(line, state = {}) {
|
|
|
862
936
|
state.rl?.resume?.();
|
|
863
937
|
}
|
|
864
938
|
break;
|
|
939
|
+
case '/hooks':
|
|
940
|
+
case '/hook': {
|
|
941
|
+
const hookCommand = args[0] || 'status';
|
|
942
|
+
await runHooks(args.length ? args : ['status'], { cwd: state.cwd, write, home: state.home, hooks: state.codeHooks });
|
|
943
|
+
if (['init', 'enable', 'disable'].includes(hookCommand)) {
|
|
944
|
+
if (state.hookExperience && state.hookSessionStarted) {
|
|
945
|
+
await state.hookExperience.runtime.dispatch('session_end', {
|
|
946
|
+
status: 'reloading_hooks',
|
|
947
|
+
elapsed_ms: state.session ? localSessionElapsedMs(state.session) : 0,
|
|
948
|
+
}, { session_id: state.session?.id, source: 'agentsam-cli' }, { cwd: state.cwd });
|
|
949
|
+
}
|
|
950
|
+
state.hookExperience = null;
|
|
951
|
+
state.hookSessionStarted = false;
|
|
952
|
+
}
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
865
955
|
case '/providers':
|
|
866
956
|
state.rl?.pause?.();
|
|
867
957
|
try {
|
|
@@ -1113,6 +1203,7 @@ export async function runShell(argv = [], options = {}) {
|
|
|
1113
1203
|
session: options.session || null,
|
|
1114
1204
|
home: options.home,
|
|
1115
1205
|
providerFetchImpl: options.providerFetchImpl,
|
|
1206
|
+
codeHooks: options.hooks || null,
|
|
1116
1207
|
persistFooter: options.persistFooter === true,
|
|
1117
1208
|
};
|
|
1118
1209
|
const sub = argv[0] || '';
|
|
@@ -1201,6 +1292,20 @@ export async function runShell(argv = [], options = {}) {
|
|
|
1201
1292
|
restorePaste();
|
|
1202
1293
|
state.rl = null;
|
|
1203
1294
|
}
|
|
1295
|
+
if (state.hookExperience && state.hookSessionStarted) {
|
|
1296
|
+
try {
|
|
1297
|
+
await state.hookExperience.runtime.dispatch('session_end', {
|
|
1298
|
+
status: interrupted ? 'interrupted' : 'paused',
|
|
1299
|
+
elapsed_ms: state.session ? localSessionElapsedMs(state.session) : 0,
|
|
1300
|
+
cumulative_usage: state.session?.cumulative_usage || {},
|
|
1301
|
+
}, {
|
|
1302
|
+
session_id: state.session?.id,
|
|
1303
|
+
source: 'agentsam-cli',
|
|
1304
|
+
}, { cwd: state.cwd });
|
|
1305
|
+
} catch (error) {
|
|
1306
|
+
writeLine(write, ` Hook cleanup warning: ${error?.message || error}`);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1204
1309
|
if (state.session) {
|
|
1205
1310
|
const activeElapsedMs = localSessionElapsedMs(state.session);
|
|
1206
1311
|
persistSession(state, {
|
package/src/errors/diagnostic.js
CHANGED
|
@@ -181,16 +181,16 @@ export function diagnosticFromError(error, fallback = {}) {
|
|
|
181
181
|
if (error?.diagnostic) return error.diagnostic;
|
|
182
182
|
const envelope = error?.envelope || (error?.ok === false && error?.schema_version ? error : null);
|
|
183
183
|
if (envelope) return legacyDiagnosticFromEnvelope(envelope, fallback);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
retry_strategy: fallback.retry_strategy || 'inspect_error',
|
|
184
|
+
const canonical = normalizeError(error, {
|
|
185
|
+
reason: fallback.reason,
|
|
186
|
+
domain: fallback.domain || 'runtime',
|
|
187
|
+
stage: fallback.stage,
|
|
188
|
+
feature: fallback.feature,
|
|
189
|
+
failure_behavior: fallback.failure_behavior,
|
|
190
|
+
side_effect_state: fallback.side_effect_state,
|
|
191
|
+
source: { kind: 'runtime', name: fallback.source || 'agentsam-sdk' },
|
|
193
192
|
});
|
|
193
|
+
return legacyDiagnosticFromEnvelope(canonical, fallback);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
export function renderDiagnosticError(error) {
|
package/src/go/container.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { probeGoDeploymentWithRetry } from './
|
|
2
|
+
import { probeGoDeploymentWithRetry } from './probe.js';
|
|
3
3
|
|
|
4
4
|
function runDocker(args, { productRoot, spawn = spawnSync } = {}) {
|
|
5
5
|
const res = spawn('docker', args, {
|
package/src/go/contract.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import { DEFAULT_PRODUCT } from './discover.js';
|
|
5
6
|
|
|
6
7
|
const PACKAGE_TEMPLATE = {
|
|
@@ -90,12 +91,16 @@ function rel(root, file) {
|
|
|
90
91
|
return path.relative(root, file).split(path.sep).join('/');
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
export function preflightToolchain({
|
|
94
|
+
export function preflightToolchain({
|
|
95
|
+
requireDocker = false,
|
|
96
|
+
productRoot = null,
|
|
97
|
+
spawn = spawnSync,
|
|
98
|
+
} = {}) {
|
|
94
99
|
const checks = [];
|
|
95
100
|
const push = (id, ok, detail = '') => checks.push({ id, ok, detail });
|
|
96
101
|
|
|
97
102
|
try {
|
|
98
|
-
const v =
|
|
103
|
+
const v = spawn('go', ['version'], { encoding: 'utf8' });
|
|
99
104
|
push('go', v.status === 0, (v.stdout || v.stderr || '').trim());
|
|
100
105
|
} catch (e) {
|
|
101
106
|
push('go', false, e.message);
|
|
@@ -103,7 +108,7 @@ export function preflightToolchain({ requireDocker = false, productRoot = null }
|
|
|
103
108
|
|
|
104
109
|
const wranglerBin = resolveWranglerBin(productRoot);
|
|
105
110
|
try {
|
|
106
|
-
const v =
|
|
111
|
+
const v = spawn(wranglerBin.command, wranglerBin.args.concat(['--version']), {
|
|
107
112
|
encoding: 'utf8',
|
|
108
113
|
cwd: productRoot || process.cwd(),
|
|
109
114
|
});
|
|
@@ -112,33 +117,71 @@ export function preflightToolchain({ requireDocker = false, productRoot = null }
|
|
|
112
117
|
push('wrangler', false, e.message);
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
// Docker is capability-gated.
|
|
121
|
+
//
|
|
122
|
+
// A caller that does not require a container must not execute
|
|
123
|
+
// `docker info` merely to discover that Docker is optional.
|
|
124
|
+
//
|
|
125
|
+
// Besides wasting work, Docker Desktop may be installed while its
|
|
126
|
+
// daemon is stopped/unhealthy, and `docker info` can block for a
|
|
127
|
+
// significant period.
|
|
128
|
+
if (requireDocker) {
|
|
129
|
+
try {
|
|
130
|
+
const v = spawn('docker', ['info'], {
|
|
131
|
+
encoding: 'utf8',
|
|
132
|
+
timeout: 8000,
|
|
133
|
+
});
|
|
134
|
+
push(
|
|
135
|
+
'docker',
|
|
136
|
+
v.status === 0,
|
|
137
|
+
v.status === 0
|
|
138
|
+
? 'available'
|
|
139
|
+
: (v.stderr || 'unavailable').trim().slice(0, 200),
|
|
140
|
+
);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
push('docker', false, e.message);
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
push('docker', true, 'skipped:not-required');
|
|
120
146
|
}
|
|
121
147
|
|
|
122
|
-
const failed = checks.filter((c) =>
|
|
123
|
-
if (c.ok) return false;
|
|
124
|
-
if (c.id === 'docker' && !requireDocker) return false;
|
|
125
|
-
return true;
|
|
126
|
-
});
|
|
148
|
+
const failed = checks.filter((c) => !c.ok);
|
|
127
149
|
return { ok: failed.length === 0, checks, failed, wrangler: wranglerBin };
|
|
128
150
|
}
|
|
129
151
|
|
|
130
|
-
function resolveWranglerBin(productRoot) {
|
|
152
|
+
export function resolveWranglerBin(productRoot) {
|
|
153
|
+
if (productRoot) {
|
|
154
|
+
try {
|
|
155
|
+
const req = createRequire(path.join(productRoot, 'package.json'));
|
|
156
|
+
const resolved = req.resolve('wrangler');
|
|
157
|
+
if (resolved) {
|
|
158
|
+
return { command: process.execPath, args: [resolved], source: 'package_dependency' };
|
|
159
|
+
}
|
|
160
|
+
} catch {
|
|
161
|
+
// Fall through to explicit paths / pinned npx fallback.
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
131
165
|
const candidates = [];
|
|
132
166
|
if (productRoot) {
|
|
133
|
-
candidates.push(path.join(productRoot, 'node_modules', 'wrangler', 'bin', 'wrangler.js'));
|
|
134
167
|
candidates.push(path.join(productRoot, 'node_modules', '.bin', 'wrangler'));
|
|
135
168
|
}
|
|
136
169
|
candidates.push(path.join(process.cwd(), 'node_modules', '.bin', 'wrangler'));
|
|
137
170
|
for (const candidate of candidates) {
|
|
138
171
|
if (fs.existsSync(candidate)) {
|
|
139
|
-
|
|
140
|
-
|
|
172
|
+
return { command: candidate, args: [], source: 'local_bin' };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let requested = 'wrangler';
|
|
177
|
+
if (productRoot) {
|
|
178
|
+
try {
|
|
179
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(productRoot, 'package.json'), 'utf8'));
|
|
180
|
+
const version = pkg.dependencies?.wrangler || pkg.devDependencies?.wrangler || '';
|
|
181
|
+
if (version) requested = 'wrangler@' + version;
|
|
182
|
+
} catch {
|
|
183
|
+
// Keep generic fallback only when package metadata is unavailable.
|
|
141
184
|
}
|
|
142
185
|
}
|
|
143
|
-
return { command: 'npx', args: ['--yes', '
|
|
186
|
+
return { command: 'npx', args: ['--yes', requested], source: 'npx_fallback' };
|
|
144
187
|
}
|
package/src/go/discover.js
CHANGED
|
@@ -180,10 +180,6 @@ export function probeGoToolchain() {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export function resolveGoStateRoot(discovery, cwd = process.cwd()) {
|
|
183
|
-
const origin = discovery?.runtime?.origin || null;
|
|
184
|
-
if (origin === 'repository' || origin === 'sdk_development_tree') {
|
|
185
|
-
return discovery.runtime.productRoot;
|
|
186
|
-
}
|
|
187
183
|
return repositoryRoot(cwd);
|
|
188
184
|
}
|
|
189
185
|
|
package/src/go/index.js
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
export { discoverGoRuntime, resolveProductRoot, resolveGoStateRoot, probeGoToolchain, DEFAULT_PRODUCT, SDK_ROOT } from './discover.js';
|
|
2
2
|
export { ensureProductContract, readProductManifest, preflightToolchain } from './contract.js';
|
|
3
3
|
export { buildGoProduct, runGoBuild, runGoTests, runGoVet } from './build.js';
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
deployGoCloudflare,
|
|
6
|
+
resolveConfiguredDeploymentUrl,
|
|
7
|
+
resolveWranglerIdentity,
|
|
8
|
+
readLatestWranglerDeployment,
|
|
9
|
+
extractWorkersDevUrl,
|
|
10
|
+
guessWorkersDevUrl,
|
|
11
|
+
} from './providers/cloudflare.js';
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
probeGoDeployment,
|
|
15
|
+
probeGoDeploymentWithRetry,
|
|
16
|
+
} from './probe.js';
|
|
5
17
|
export { verifyGoContainer } from './container.js';
|
|
6
18
|
export { verifyGoProduct } from './verify.js';
|
|
7
19
|
export {
|