@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,320 @@
|
|
|
1
|
+
import type { AgentRunStatus } from './agent';
|
|
2
|
+
|
|
3
|
+
export type AgentRunSuspensionReason =
|
|
4
|
+
| 'external'
|
|
5
|
+
| 'child_run'
|
|
6
|
+
| 'approval'
|
|
7
|
+
| 'input'
|
|
8
|
+
| 'retry'
|
|
9
|
+
| 'scheduled'
|
|
10
|
+
| 'rate_limit';
|
|
11
|
+
|
|
12
|
+
export interface AgentRunSuspension {
|
|
13
|
+
runId: string;
|
|
14
|
+
state:
|
|
15
|
+
| 'waiting_external'
|
|
16
|
+
| 'waiting_child'
|
|
17
|
+
| 'awaiting_input'
|
|
18
|
+
| 'awaiting_approval'
|
|
19
|
+
| 'sleeping'
|
|
20
|
+
| 'retry_scheduled';
|
|
21
|
+
reason: AgentRunSuspensionReason;
|
|
22
|
+
wakeAt?: number;
|
|
23
|
+
wakeEvent?: string;
|
|
24
|
+
dependencyRunIds?: string[];
|
|
25
|
+
attempt?: number;
|
|
26
|
+
resumeStepId?: string;
|
|
27
|
+
checkpointRef?: string;
|
|
28
|
+
expiresAt?: number;
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type AgentRunWakeKind = 'event' | 'dependency' | 'scheduled' | 'manual';
|
|
33
|
+
|
|
34
|
+
export interface AgentRunWakeSignal {
|
|
35
|
+
id: string;
|
|
36
|
+
runId: string;
|
|
37
|
+
kind: AgentRunWakeKind;
|
|
38
|
+
occurredAt: number;
|
|
39
|
+
dedupeKey: string;
|
|
40
|
+
eventKey?: string;
|
|
41
|
+
dependencyRunId?: string;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type AgentRunRetryClass = 'transient' | 'wait' | 'replan' | 'terminal';
|
|
46
|
+
|
|
47
|
+
export interface AgentRunRetryClassificationInput {
|
|
48
|
+
code?: string | null;
|
|
49
|
+
statusCode?: number | null;
|
|
50
|
+
retryable?: boolean | null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface AgentRunRetryClassification {
|
|
54
|
+
class: AgentRunRetryClass;
|
|
55
|
+
automaticRetry: boolean;
|
|
56
|
+
reason: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const WAIT_CODES = new Set([
|
|
60
|
+
'approval_required',
|
|
61
|
+
'input_required',
|
|
62
|
+
'external_pending',
|
|
63
|
+
'dependency_pending',
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
const REPLAN_CODES = new Set([
|
|
67
|
+
'precondition_failed',
|
|
68
|
+
'repository_changed',
|
|
69
|
+
'capability_unavailable',
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const TRANSIENT_CODES = new Set([
|
|
73
|
+
'timeout',
|
|
74
|
+
'request_timeout',
|
|
75
|
+
'rate_limited',
|
|
76
|
+
'provider_unavailable',
|
|
77
|
+
'runtime_unavailable',
|
|
78
|
+
'econnreset',
|
|
79
|
+
'econnrefused',
|
|
80
|
+
'etimedout',
|
|
81
|
+
'eai_again',
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
export function classifyAgentRunRetry(input: AgentRunRetryClassificationInput = {}): AgentRunRetryClassification {
|
|
85
|
+
const code = String(input.code || '').trim().toLowerCase();
|
|
86
|
+
const statusCode = Number(input.statusCode);
|
|
87
|
+
|
|
88
|
+
if (input.retryable === true) {
|
|
89
|
+
return { class: 'transient', automaticRetry: true, reason: code || 'explicit_retryable' };
|
|
90
|
+
}
|
|
91
|
+
if (input.retryable === false) {
|
|
92
|
+
return { class: 'terminal', automaticRetry: false, reason: code || 'explicit_non_retryable' };
|
|
93
|
+
}
|
|
94
|
+
if (WAIT_CODES.has(code)) {
|
|
95
|
+
return { class: 'wait', automaticRetry: false, reason: code };
|
|
96
|
+
}
|
|
97
|
+
if (REPLAN_CODES.has(code)) {
|
|
98
|
+
return { class: 'replan', automaticRetry: false, reason: code };
|
|
99
|
+
}
|
|
100
|
+
if (TRANSIENT_CODES.has(code) || [408, 425, 429, 500, 502, 503, 504].includes(statusCode)) {
|
|
101
|
+
return { class: 'transient', automaticRetry: true, reason: code || `http_${statusCode}` };
|
|
102
|
+
}
|
|
103
|
+
return { class: 'terminal', automaticRetry: false, reason: code || 'unclassified_failure' };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type AgentRunWakeDecisionReason =
|
|
107
|
+
| 'accepted'
|
|
108
|
+
| 'duplicate'
|
|
109
|
+
| 'run_mismatch'
|
|
110
|
+
| 'expired'
|
|
111
|
+
| 'condition_not_met';
|
|
112
|
+
|
|
113
|
+
export interface AgentRunWakeDecision {
|
|
114
|
+
accepted: boolean;
|
|
115
|
+
reason: AgentRunWakeDecisionReason;
|
|
116
|
+
nextStatus?: 'queued';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function evaluateAgentRunWake(
|
|
120
|
+
suspension: AgentRunSuspension,
|
|
121
|
+
wake: AgentRunWakeSignal,
|
|
122
|
+
options: { consumedDedupeKeys?: Iterable<string>; now?: number } = {},
|
|
123
|
+
): AgentRunWakeDecision {
|
|
124
|
+
const consumed = new Set(options.consumedDedupeKeys || []);
|
|
125
|
+
if (consumed.has(wake.dedupeKey)) return { accepted: false, reason: 'duplicate' };
|
|
126
|
+
if (suspension.runId !== wake.runId) return { accepted: false, reason: 'run_mismatch' };
|
|
127
|
+
|
|
128
|
+
const now = options.now ?? wake.occurredAt;
|
|
129
|
+
if (suspension.expiresAt != null && now > suspension.expiresAt) {
|
|
130
|
+
return { accepted: false, reason: 'expired' };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const matched = wake.kind === 'manual'
|
|
134
|
+
|| Boolean(suspension.wakeEvent && wake.eventKey === suspension.wakeEvent)
|
|
135
|
+
|| Boolean(
|
|
136
|
+
wake.kind === 'dependency'
|
|
137
|
+
&& wake.dependencyRunId
|
|
138
|
+
&& (suspension.dependencyRunIds || []).includes(wake.dependencyRunId),
|
|
139
|
+
)
|
|
140
|
+
|| Boolean(wake.kind === 'scheduled' && suspension.wakeAt != null && now >= suspension.wakeAt);
|
|
141
|
+
|
|
142
|
+
return matched
|
|
143
|
+
? { accepted: true, reason: 'accepted', nextStatus: 'queued' }
|
|
144
|
+
: { accepted: false, reason: 'condition_not_met' };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function wakeMatchesSuspension(
|
|
148
|
+
suspension: AgentRunSuspension,
|
|
149
|
+
wake: AgentRunWakeSignal,
|
|
150
|
+
now = wake.occurredAt,
|
|
151
|
+
): boolean {
|
|
152
|
+
return evaluateAgentRunWake(suspension, wake, { now }).accepted;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type AgentRunLifecycleAction =
|
|
156
|
+
| { type: 'start' }
|
|
157
|
+
| { type: 'suspend'; status: AgentRunSuspension['state'] }
|
|
158
|
+
| { type: 'wake' }
|
|
159
|
+
| { type: 'complete' }
|
|
160
|
+
| { type: 'fail' }
|
|
161
|
+
| { type: 'cancel' }
|
|
162
|
+
| { type: 'timeout' };
|
|
163
|
+
|
|
164
|
+
export function transitionAgentRunStatus(status: AgentRunStatus, action: AgentRunLifecycleAction): AgentRunStatus {
|
|
165
|
+
if (status === 'completed' || status === 'failed' || status === 'cancelled' || status === 'timed_out') {
|
|
166
|
+
return status;
|
|
167
|
+
}
|
|
168
|
+
if (action.type === 'cancel') return 'cancelled';
|
|
169
|
+
if (action.type === 'timeout') return 'timed_out';
|
|
170
|
+
if (action.type === 'complete') return 'completed';
|
|
171
|
+
if (action.type === 'fail') return 'failed';
|
|
172
|
+
if (action.type === 'suspend') return action.status;
|
|
173
|
+
if (action.type === 'wake') return 'queued';
|
|
174
|
+
if (action.type === 'start') return 'running';
|
|
175
|
+
return status;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type AgentRunEventType =
|
|
179
|
+
| 'run.created'
|
|
180
|
+
| 'run.queued'
|
|
181
|
+
| 'run.started'
|
|
182
|
+
| 'run.status'
|
|
183
|
+
| 'run.suspended'
|
|
184
|
+
| 'run.woken'
|
|
185
|
+
| 'run.cancel_requested'
|
|
186
|
+
| 'run.cancelled'
|
|
187
|
+
| 'run.timed_out'
|
|
188
|
+
| 'run.failed'
|
|
189
|
+
| 'run.completed'
|
|
190
|
+
| 'step.started'
|
|
191
|
+
| 'step.progress'
|
|
192
|
+
| 'step.completed'
|
|
193
|
+
| 'decision.made'
|
|
194
|
+
| 'tool.started'
|
|
195
|
+
| 'tool.completed'
|
|
196
|
+
| 'artifact.created'
|
|
197
|
+
| 'file.changed'
|
|
198
|
+
| 'approval.required'
|
|
199
|
+
| 'input.required'
|
|
200
|
+
| 'verification.completed'
|
|
201
|
+
| (string & {});
|
|
202
|
+
|
|
203
|
+
export type AgentActivityPhase =
|
|
204
|
+
| 'boot'
|
|
205
|
+
| 'observe'
|
|
206
|
+
| 'context'
|
|
207
|
+
| 'plan'
|
|
208
|
+
| 'execute'
|
|
209
|
+
| 'verify'
|
|
210
|
+
| 'compact'
|
|
211
|
+
| 'waiting'
|
|
212
|
+
| 'recover'
|
|
213
|
+
| 'complete';
|
|
214
|
+
|
|
215
|
+
export type AgentActivityEventType =
|
|
216
|
+
| 'run.started'
|
|
217
|
+
| 'phase.changed'
|
|
218
|
+
| 'step.started'
|
|
219
|
+
| 'step.progress'
|
|
220
|
+
| 'step.completed'
|
|
221
|
+
| 'decision.made'
|
|
222
|
+
| 'tool.started'
|
|
223
|
+
| 'tool.completed'
|
|
224
|
+
| 'artifact.created'
|
|
225
|
+
| 'file.changed'
|
|
226
|
+
| 'approval.required'
|
|
227
|
+
| 'input.required'
|
|
228
|
+
| 'verification.completed'
|
|
229
|
+
| 'run.failed'
|
|
230
|
+
| 'run.completed';
|
|
231
|
+
|
|
232
|
+
export interface AgentRunEvent {
|
|
233
|
+
id: string;
|
|
234
|
+
runId: string;
|
|
235
|
+
parentRunId?: string;
|
|
236
|
+
seq: number;
|
|
237
|
+
eventType: AgentRunEventType;
|
|
238
|
+
status?: AgentRunStatus;
|
|
239
|
+
phase?: AgentActivityPhase;
|
|
240
|
+
stepId?: string;
|
|
241
|
+
label?: string;
|
|
242
|
+
detail?: string | null;
|
|
243
|
+
progress?: { current: number; total: number } | null;
|
|
244
|
+
source?: { kind?: string; name?: string | null } | null;
|
|
245
|
+
evidence?: Record<string, unknown> | null;
|
|
246
|
+
createdAt: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface AgentActivityEventV1 {
|
|
250
|
+
schema: 'agentsam.activity.v1';
|
|
251
|
+
run_id: string;
|
|
252
|
+
seq: number;
|
|
253
|
+
timestamp: string;
|
|
254
|
+
phase: AgentActivityPhase;
|
|
255
|
+
event: AgentActivityEventType;
|
|
256
|
+
step_id: string | null;
|
|
257
|
+
parent_id: string | null;
|
|
258
|
+
label: string;
|
|
259
|
+
detail: string | null;
|
|
260
|
+
progress: { current: number; total: number } | null;
|
|
261
|
+
source: { kind: string; name: string | null };
|
|
262
|
+
evidence: Record<string, unknown> | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function phaseForRunEvent(event: AgentRunEvent): AgentActivityPhase {
|
|
266
|
+
if (event.phase) return event.phase;
|
|
267
|
+
if (event.eventType === 'run.created' || event.eventType === 'run.queued' || event.eventType === 'run.started') return 'boot';
|
|
268
|
+
if (event.eventType === 'run.suspended') return 'waiting';
|
|
269
|
+
if (event.eventType === 'run.woken' || event.eventType === 'run.cancel_requested') return 'recover';
|
|
270
|
+
if (event.eventType === 'verification.completed') return 'verify';
|
|
271
|
+
if (event.eventType === 'run.completed' || event.eventType === 'run.cancelled' || event.eventType === 'run.timed_out') return 'complete';
|
|
272
|
+
if (event.eventType === 'run.failed') return 'complete';
|
|
273
|
+
return 'execute';
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function activityTypeForRunEvent(event: AgentRunEvent): AgentActivityEventType {
|
|
277
|
+
if (event.eventType === 'run.started') return 'run.started';
|
|
278
|
+
if (event.eventType === 'run.completed') return 'run.completed';
|
|
279
|
+
if (event.eventType === 'run.failed' || event.eventType === 'run.timed_out') return 'run.failed';
|
|
280
|
+
if (event.eventType === 'run.cancelled' || event.eventType === 'run.suspended' || event.eventType === 'run.woken' || event.eventType === 'run.status' || event.eventType === 'run.cancel_requested' || event.eventType === 'run.created' || event.eventType === 'run.queued') return 'phase.changed';
|
|
281
|
+
if (event.eventType === 'step.started') return 'step.started';
|
|
282
|
+
if (event.eventType === 'step.completed') return 'step.completed';
|
|
283
|
+
if (event.eventType === 'decision.made') return 'decision.made';
|
|
284
|
+
if (event.eventType === 'tool.started') return 'tool.started';
|
|
285
|
+
if (event.eventType === 'tool.completed') return 'tool.completed';
|
|
286
|
+
if (event.eventType === 'artifact.created') return 'artifact.created';
|
|
287
|
+
if (event.eventType === 'file.changed') return 'file.changed';
|
|
288
|
+
if (event.eventType === 'approval.required') return 'approval.required';
|
|
289
|
+
if (event.eventType === 'input.required') return 'input.required';
|
|
290
|
+
if (event.eventType === 'verification.completed') return 'verification.completed';
|
|
291
|
+
return 'step.progress';
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export function projectRunEventToActivity(event: AgentRunEvent): AgentActivityEventV1 {
|
|
295
|
+
const evidence = {
|
|
296
|
+
...(event.evidence || {}),
|
|
297
|
+
run_event_id: event.id,
|
|
298
|
+
run_event_type: event.eventType,
|
|
299
|
+
...(event.status ? { run_status: event.status } : {}),
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
schema: 'agentsam.activity.v1',
|
|
304
|
+
run_id: event.runId,
|
|
305
|
+
seq: event.seq,
|
|
306
|
+
timestamp: new Date(event.createdAt).toISOString(),
|
|
307
|
+
phase: phaseForRunEvent(event),
|
|
308
|
+
event: activityTypeForRunEvent(event),
|
|
309
|
+
step_id: event.stepId ?? null,
|
|
310
|
+
parent_id: event.parentRunId ?? null,
|
|
311
|
+
label: event.label || '',
|
|
312
|
+
detail: event.detail ?? null,
|
|
313
|
+
progress: event.progress ?? null,
|
|
314
|
+
source: {
|
|
315
|
+
kind: event.source?.kind || 'sam',
|
|
316
|
+
name: event.source?.name ?? null,
|
|
317
|
+
},
|
|
318
|
+
evidence,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AgentSamErrorEnvelope } from './errors';
|
|
2
|
+
|
|
3
|
+
export type AgentSamWidgetSize = 'small' | 'medium' | 'large';
|
|
4
|
+
|
|
5
|
+
export type AgentSamWidgetKind =
|
|
6
|
+
| 'countdown'
|
|
7
|
+
| 'clock'
|
|
8
|
+
| 'metric'
|
|
9
|
+
| 'list'
|
|
10
|
+
| 'launcher'
|
|
11
|
+
| 'brand'
|
|
12
|
+
| (string & {});
|
|
13
|
+
|
|
14
|
+
export interface AgentSamWidgetDataSource {
|
|
15
|
+
/** Existing route key, tool operation id, or host-owned projection id. */
|
|
16
|
+
source: string;
|
|
17
|
+
/** Host-defined refresh class, such as realtime, short, medium, or manual. */
|
|
18
|
+
refresh?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AgentSamWidgetDefinition {
|
|
22
|
+
id: string;
|
|
23
|
+
kind: AgentSamWidgetKind;
|
|
24
|
+
title: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
icon?: string;
|
|
27
|
+
sizes: readonly AgentSamWidgetSize[];
|
|
28
|
+
data?: AgentSamWidgetDataSource;
|
|
29
|
+
/** Route key or host-resolved deep link. Do not put credentials or raw provider secrets here. */
|
|
30
|
+
deeplink?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface AgentSamWidgetReadyState {
|
|
34
|
+
status: 'ready';
|
|
35
|
+
updated_at?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface AgentSamWidgetStaleState {
|
|
39
|
+
status: 'stale';
|
|
40
|
+
updated_at: string;
|
|
41
|
+
error: AgentSamErrorEnvelope;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AgentSamWidgetEmptyState {
|
|
45
|
+
status: 'empty';
|
|
46
|
+
updated_at?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AgentSamWidgetErrorState {
|
|
50
|
+
status: 'error';
|
|
51
|
+
error: AgentSamErrorEnvelope;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type AgentSamWidgetState =
|
|
55
|
+
| AgentSamWidgetReadyState
|
|
56
|
+
| AgentSamWidgetStaleState
|
|
57
|
+
| AgentSamWidgetEmptyState
|
|
58
|
+
| AgentSamWidgetErrorState;
|
|
@@ -10,7 +10,7 @@ test('contracts package stays framework neutral', async () => {
|
|
|
10
10
|
|
|
11
11
|
test('execution-plane contracts are exported as first-class package surfaces', async () => {
|
|
12
12
|
const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
13
|
-
for (const key of ['./tools', './authority', './execution', './providers', './events', './hooks']) {
|
|
13
|
+
for (const key of ['./tools', './authority', './execution', './providers', './events', './run', './hooks', './widgets']) {
|
|
14
14
|
const entry = pkg.exports[key];
|
|
15
15
|
assert.equal(typeof entry, 'object', `missing typed contract export: ${key}`);
|
|
16
16
|
assert.match(entry.types, /^\.\/dist\/.+\.d\.ts$/);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
classifyAgentRunRetry,
|
|
6
|
+
evaluateAgentRunWake,
|
|
7
|
+
isAgentRunModelActiveStatus,
|
|
8
|
+
isAgentRunTerminalStatus,
|
|
9
|
+
isAgentRunWaitingStatus,
|
|
10
|
+
projectRunEventToActivity,
|
|
11
|
+
transitionAgentRunStatus,
|
|
12
|
+
} from '../dist/index.js';
|
|
13
|
+
|
|
14
|
+
test('run lifecycle distinguishes model-active, waiting, and terminal states', () => {
|
|
15
|
+
assert.equal(isAgentRunModelActiveStatus('running'), true);
|
|
16
|
+
assert.equal(isAgentRunModelActiveStatus('waiting_external'), false);
|
|
17
|
+
assert.equal(isAgentRunWaitingStatus('waiting_child'), true);
|
|
18
|
+
assert.equal(isAgentRunTerminalStatus('timed_out'), true);
|
|
19
|
+
assert.equal(isAgentRunTerminalStatus('partial'), false);
|
|
20
|
+
|
|
21
|
+
assert.equal(transitionAgentRunStatus('queued', { type: 'start' }), 'running');
|
|
22
|
+
assert.equal(transitionAgentRunStatus('running', { type: 'suspend', status: 'waiting_external' }), 'waiting_external');
|
|
23
|
+
assert.equal(transitionAgentRunStatus('waiting_external', { type: 'wake' }), 'queued');
|
|
24
|
+
assert.equal(transitionAgentRunStatus('running', { type: 'cancel' }), 'cancelled');
|
|
25
|
+
assert.equal(transitionAgentRunStatus('running', { type: 'timeout' }), 'timed_out');
|
|
26
|
+
assert.equal(transitionAgentRunStatus('completed', { type: 'wake' }), 'completed');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('wake evaluation is deterministic and rejects duplicate wake signals', () => {
|
|
30
|
+
const suspension = {
|
|
31
|
+
runId: 'run_parent',
|
|
32
|
+
state: 'waiting_child',
|
|
33
|
+
reason: 'child_run',
|
|
34
|
+
dependencyRunIds: ['run_child'],
|
|
35
|
+
expiresAt: 2_000,
|
|
36
|
+
};
|
|
37
|
+
const wake = {
|
|
38
|
+
id: 'wake_1',
|
|
39
|
+
runId: 'run_parent',
|
|
40
|
+
kind: 'dependency',
|
|
41
|
+
dependencyRunId: 'run_child',
|
|
42
|
+
occurredAt: 1_000,
|
|
43
|
+
dedupeKey: 'child:run_child:complete',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
assert.deepEqual(evaluateAgentRunWake(suspension, wake), {
|
|
47
|
+
accepted: true,
|
|
48
|
+
reason: 'accepted',
|
|
49
|
+
nextStatus: 'queued',
|
|
50
|
+
});
|
|
51
|
+
assert.deepEqual(evaluateAgentRunWake(suspension, wake, {
|
|
52
|
+
consumedDedupeKeys: [wake.dedupeKey],
|
|
53
|
+
}), {
|
|
54
|
+
accepted: false,
|
|
55
|
+
reason: 'duplicate',
|
|
56
|
+
});
|
|
57
|
+
assert.equal(evaluateAgentRunWake(suspension, { ...wake, dependencyRunId: 'other' }).accepted, false);
|
|
58
|
+
assert.equal(evaluateAgentRunWake(suspension, { ...wake, occurredAt: 2_001 }, { now: 2_001 }).reason, 'expired');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('retry classification only auto-retries transient failures', () => {
|
|
62
|
+
assert.deepEqual(classifyAgentRunRetry({ statusCode: 429 }), {
|
|
63
|
+
class: 'transient',
|
|
64
|
+
automaticRetry: true,
|
|
65
|
+
reason: 'http_429',
|
|
66
|
+
});
|
|
67
|
+
assert.equal(classifyAgentRunRetry({ code: 'approval_required' }).class, 'wait');
|
|
68
|
+
assert.equal(classifyAgentRunRetry({ code: 'repository_changed' }).class, 'replan');
|
|
69
|
+
assert.equal(classifyAgentRunRetry({ code: 'permission_denied' }).automaticRetry, false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('append-only run events project to agentsam.activity.v1 without losing provenance', () => {
|
|
73
|
+
const projected = projectRunEventToActivity({
|
|
74
|
+
id: 'evt_42',
|
|
75
|
+
runId: 'run_parent',
|
|
76
|
+
parentRunId: 'run_root',
|
|
77
|
+
seq: 42,
|
|
78
|
+
eventType: 'run.suspended',
|
|
79
|
+
status: 'waiting_external',
|
|
80
|
+
label: 'Waiting for deployment',
|
|
81
|
+
detail: 'Provider job is still pending',
|
|
82
|
+
createdAt: Date.parse('2026-10-03T07:00:00.000Z'),
|
|
83
|
+
source: { kind: 'queue', name: 'deployments' },
|
|
84
|
+
evidence: { provider_job_id: 'dep_123' },
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
assert.equal(projected.schema, 'agentsam.activity.v1');
|
|
88
|
+
assert.equal(projected.phase, 'waiting');
|
|
89
|
+
assert.equal(projected.event, 'phase.changed');
|
|
90
|
+
assert.equal(projected.parent_id, 'run_root');
|
|
91
|
+
assert.equal(projected.evidence.run_event_id, 'evt_42');
|
|
92
|
+
assert.equal(projected.evidence.run_event_type, 'run.suspended');
|
|
93
|
+
assert.equal(projected.evidence.run_status, 'waiting_external');
|
|
94
|
+
});
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inneranimalmedia/agentsam-errors",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.11",
|
|
4
4
|
"description": "Canonical AgentSam runtime error normalization, classification, transport, remediation and rendering.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
|
+
"types": "./types/index.d.ts",
|
|
7
8
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./types/index.d.ts",
|
|
11
|
+
"import": "./src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./catalog": "./protocol/error-catalog.json",
|
|
14
|
+
"./schema": "./protocol/agentsam.error.v2.schema.json"
|
|
9
15
|
},
|
|
10
16
|
"scripts": {
|
|
11
17
|
"test": "node --test test/*.test.mjs"
|
|
@@ -22,7 +28,9 @@
|
|
|
22
28
|
"directory": "packages/agentsam-errors"
|
|
23
29
|
},
|
|
24
30
|
"files": [
|
|
25
|
-
"src"
|
|
31
|
+
"src",
|
|
32
|
+
"types",
|
|
33
|
+
"protocol"
|
|
26
34
|
],
|
|
27
35
|
"license": "MIT"
|
|
28
36
|
}
|