@oobe-protocol-labs/sap-mcp-server 0.1.0
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/.env.example +159 -0
- package/CHANGELOG.md +55 -0
- package/LICENSE +21 -0
- package/README.md +223 -0
- package/config.example.json +64 -0
- package/config.schema.json +370 -0
- package/config.secure-example.json +100 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +6 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/mcp/errors.d.ts +7 -0
- package/dist/adapters/mcp/errors.d.ts.map +1 -0
- package/dist/adapters/mcp/errors.js +10 -0
- package/dist/adapters/mcp/errors.js.map +1 -0
- package/dist/adapters/mcp/index.d.ts +8 -0
- package/dist/adapters/mcp/index.d.ts.map +1 -0
- package/dist/adapters/mcp/index.js +8 -0
- package/dist/adapters/mcp/index.js.map +1 -0
- package/dist/adapters/mcp/prompt-response.d.ts +13 -0
- package/dist/adapters/mcp/prompt-response.d.ts.map +1 -0
- package/dist/adapters/mcp/prompt-response.js +7 -0
- package/dist/adapters/mcp/prompt-response.js.map +1 -0
- package/dist/adapters/mcp/resource-response.d.ts +8 -0
- package/dist/adapters/mcp/resource-response.d.ts.map +1 -0
- package/dist/adapters/mcp/resource-response.js +7 -0
- package/dist/adapters/mcp/resource-response.js.map +1 -0
- package/dist/adapters/mcp/sdk-compat.d.ts +191 -0
- package/dist/adapters/mcp/sdk-compat.d.ts.map +1 -0
- package/dist/adapters/mcp/sdk-compat.js +606 -0
- package/dist/adapters/mcp/sdk-compat.js.map +1 -0
- package/dist/adapters/mcp/tool-response.d.ts +32 -0
- package/dist/adapters/mcp/tool-response.d.ts.map +1 -0
- package/dist/adapters/mcp/tool-response.js +27 -0
- package/dist/adapters/mcp/tool-response.js.map +1 -0
- package/dist/adapters/solana/commitment.d.ts +9 -0
- package/dist/adapters/solana/commitment.d.ts.map +1 -0
- package/dist/adapters/solana/commitment.js +14 -0
- package/dist/adapters/solana/commitment.js.map +1 -0
- package/dist/adapters/solana/connection.d.ts +10 -0
- package/dist/adapters/solana/connection.d.ts.map +1 -0
- package/dist/adapters/solana/connection.js +13 -0
- package/dist/adapters/solana/connection.js.map +1 -0
- package/dist/adapters/solana/index.d.ts +7 -0
- package/dist/adapters/solana/index.d.ts.map +1 -0
- package/dist/adapters/solana/index.js +7 -0
- package/dist/adapters/solana/index.js.map +1 -0
- package/dist/adapters/solana/public-key.d.ts +9 -0
- package/dist/adapters/solana/public-key.d.ts.map +1 -0
- package/dist/adapters/solana/public-key.js +11 -0
- package/dist/adapters/solana/public-key.js.map +1 -0
- package/dist/cli.d.ts +29 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +269 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/defaults.d.ts +28 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +28 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/env.d.ts +297 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +563 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/mcp-client-injection.d.ts +113 -0
- package/dist/config/mcp-client-injection.d.ts.map +1 -0
- package/dist/config/mcp-client-injection.js +453 -0
- package/dist/config/mcp-client-injection.js.map +1 -0
- package/dist/config/paths.d.ts +37 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +93 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/profiles.d.ts +85 -0
- package/dist/config/profiles.d.ts.map +1 -0
- package/dist/config/profiles.js +346 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/schema.d.ts +9 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +8 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/secure-config.d.ts +607 -0
- package/dist/config/secure-config.d.ts.map +1 -0
- package/dist/config/secure-config.js +526 -0
- package/dist/config/secure-config.js.map +1 -0
- package/dist/config/setup.d.ts +42 -0
- package/dist/config/setup.d.ts.map +1 -0
- package/dist/config/setup.js +173 -0
- package/dist/config/setup.js.map +1 -0
- package/dist/config/wizard.d.ts +15 -0
- package/dist/config/wizard.d.ts.map +1 -0
- package/dist/config/wizard.js +1176 -0
- package/dist/config/wizard.js.map +1 -0
- package/dist/config-cli.d.ts +21 -0
- package/dist/config-cli.d.ts.map +1 -0
- package/dist/config-cli.js +679 -0
- package/dist/config-cli.js.map +1 -0
- package/dist/core/constants.d.ts +78 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +78 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/errors.d.ts +188 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +337 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/guards.d.ts +41 -0
- package/dist/core/guards.d.ts.map +1 -0
- package/dist/core/guards.js +93 -0
- package/dist/core/guards.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +64 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +159 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/result.d.ts +49 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/result.js +61 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/types.d.ts +147 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/payments/http-adapter.d.ts +76 -0
- package/dist/payments/http-adapter.d.ts.map +1 -0
- package/dist/payments/http-adapter.js +126 -0
- package/dist/payments/http-adapter.js.map +1 -0
- package/dist/payments/index.d.ts +12 -0
- package/dist/payments/index.d.ts.map +1 -0
- package/dist/payments/index.js +9 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/payments/json-rpc.d.ts +49 -0
- package/dist/payments/json-rpc.d.ts.map +1 -0
- package/dist/payments/json-rpc.js +53 -0
- package/dist/payments/json-rpc.js.map +1 -0
- package/dist/payments/monetization-gate.d.ts +49 -0
- package/dist/payments/monetization-gate.d.ts.map +1 -0
- package/dist/payments/monetization-gate.js +398 -0
- package/dist/payments/monetization-gate.js.map +1 -0
- package/dist/payments/oobe-facilitator-server.d.ts +71 -0
- package/dist/payments/oobe-facilitator-server.d.ts.map +1 -0
- package/dist/payments/oobe-facilitator-server.js +409 -0
- package/dist/payments/oobe-facilitator-server.js.map +1 -0
- package/dist/payments/pay-sh-spec.d.ts +44 -0
- package/dist/payments/pay-sh-spec.d.ts.map +1 -0
- package/dist/payments/pay-sh-spec.js +218 -0
- package/dist/payments/pay-sh-spec.js.map +1 -0
- package/dist/payments/pricing.d.ts +60 -0
- package/dist/payments/pricing.d.ts.map +1 -0
- package/dist/payments/pricing.js +272 -0
- package/dist/payments/pricing.js.map +1 -0
- package/dist/payments/usage-ledger.d.ts +84 -0
- package/dist/payments/usage-ledger.d.ts.map +1 -0
- package/dist/payments/usage-ledger.js +126 -0
- package/dist/payments/usage-ledger.js.map +1 -0
- package/dist/policy/bento-policy-engine.d.ts +71 -0
- package/dist/policy/bento-policy-engine.d.ts.map +1 -0
- package/dist/policy/bento-policy-engine.js +218 -0
- package/dist/policy/bento-policy-engine.js.map +1 -0
- package/dist/policy/default-policies.d.ts +9 -0
- package/dist/policy/default-policies.d.ts.map +1 -0
- package/dist/policy/default-policies.js +69 -0
- package/dist/policy/default-policies.js.map +1 -0
- package/dist/policy/hybrid-policy-engine.d.ts +95 -0
- package/dist/policy/hybrid-policy-engine.d.ts.map +1 -0
- package/dist/policy/hybrid-policy-engine.js +297 -0
- package/dist/policy/hybrid-policy-engine.js.map +1 -0
- package/dist/policy/index.d.ts +10 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +10 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/local-policy-engine.d.ts +119 -0
- package/dist/policy/local-policy-engine.d.ts.map +1 -0
- package/dist/policy/local-policy-engine.js +318 -0
- package/dist/policy/local-policy-engine.js.map +1 -0
- package/dist/policy/permission-checks.d.ts +19 -0
- package/dist/policy/permission-checks.d.ts.map +1 -0
- package/dist/policy/permission-checks.js +60 -0
- package/dist/policy/permission-checks.js.map +1 -0
- package/dist/policy/policy-engine.d.ts +57 -0
- package/dist/policy/policy-engine.d.ts.map +1 -0
- package/dist/policy/policy-engine.js +162 -0
- package/dist/policy/policy-engine.js.map +1 -0
- package/dist/policy/policy-types.d.ts +46 -0
- package/dist/policy/policy-types.d.ts.map +1 -0
- package/dist/policy/policy-types.js +5 -0
- package/dist/policy/policy-types.js.map +1 -0
- package/dist/policy/risk-level.d.ts +18 -0
- package/dist/policy/risk-level.d.ts.map +1 -0
- package/dist/policy/risk-level.js +46 -0
- package/dist/policy/risk-level.js.map +1 -0
- package/dist/policy/spending-limits.d.ts +17 -0
- package/dist/policy/spending-limits.d.ts.map +1 -0
- package/dist/policy/spending-limits.js +40 -0
- package/dist/policy/spending-limits.js.map +1 -0
- package/dist/prompts/context/sap-agent-context.prompt.d.ts +64 -0
- package/dist/prompts/context/sap-agent-context.prompt.d.ts.map +1 -0
- package/dist/prompts/context/sap-agent-context.prompt.js +336 -0
- package/dist/prompts/context/sap-agent-context.prompt.js.map +1 -0
- package/dist/prompts/developer/debug-sap-error.prompt.d.ts +13 -0
- package/dist/prompts/developer/debug-sap-error.prompt.d.ts.map +1 -0
- package/dist/prompts/developer/debug-sap-error.prompt.js +78 -0
- package/dist/prompts/developer/debug-sap-error.prompt.js.map +1 -0
- package/dist/prompts/developer/generate-sap-integration.prompt.d.ts +13 -0
- package/dist/prompts/developer/generate-sap-integration.prompt.d.ts.map +1 -0
- package/dist/prompts/developer/generate-sap-integration.prompt.js +132 -0
- package/dist/prompts/developer/generate-sap-integration.prompt.js.map +1 -0
- package/dist/prompts/developer/index.d.ts +6 -0
- package/dist/prompts/developer/index.d.ts.map +1 -0
- package/dist/prompts/developer/index.js +6 -0
- package/dist/prompts/developer/index.js.map +1 -0
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.d.ts +13 -0
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.d.ts.map +1 -0
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.js +97 -0
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.js.map +1 -0
- package/dist/prompts/execution-proof/index.d.ts +6 -0
- package/dist/prompts/execution-proof/index.d.ts.map +1 -0
- package/dist/prompts/execution-proof/index.js +6 -0
- package/dist/prompts/execution-proof/index.js.map +1 -0
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.d.ts +13 -0
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.d.ts.map +1 -0
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.js +95 -0
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.js.map +1 -0
- package/dist/prompts/index.d.ts +5 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/payments/create-paid-api.prompt.d.ts +13 -0
- package/dist/prompts/payments/create-paid-api.prompt.d.ts.map +1 -0
- package/dist/prompts/payments/create-paid-api.prompt.js +142 -0
- package/dist/prompts/payments/create-paid-api.prompt.js.map +1 -0
- package/dist/prompts/payments/explain-x402-settlement.prompt.d.ts +13 -0
- package/dist/prompts/payments/explain-x402-settlement.prompt.d.ts.map +1 -0
- package/dist/prompts/payments/explain-x402-settlement.prompt.js +83 -0
- package/dist/prompts/payments/explain-x402-settlement.prompt.js.map +1 -0
- package/dist/prompts/payments/index.d.ts +6 -0
- package/dist/prompts/payments/index.d.ts.map +1 -0
- package/dist/prompts/payments/index.js +6 -0
- package/dist/prompts/payments/index.js.map +1 -0
- package/dist/prompts/register-prompts.d.ts +10 -0
- package/dist/prompts/register-prompts.d.ts.map +1 -0
- package/dist/prompts/register-prompts.js +40 -0
- package/dist/prompts/register-prompts.js.map +1 -0
- package/dist/prompts/registry/analyze-sap-agent.prompt.d.ts +13 -0
- package/dist/prompts/registry/analyze-sap-agent.prompt.d.ts.map +1 -0
- package/dist/prompts/registry/analyze-sap-agent.prompt.js +85 -0
- package/dist/prompts/registry/analyze-sap-agent.prompt.js.map +1 -0
- package/dist/prompts/registry/index.d.ts +6 -0
- package/dist/prompts/registry/index.d.ts.map +1 -0
- package/dist/prompts/registry/index.js +6 -0
- package/dist/prompts/registry/index.js.map +1 -0
- package/dist/prompts/registry/register-sap-agent.prompt.d.ts +13 -0
- package/dist/prompts/registry/register-sap-agent.prompt.d.ts.map +1 -0
- package/dist/prompts/registry/register-sap-agent.prompt.js +152 -0
- package/dist/prompts/registry/register-sap-agent.prompt.js.map +1 -0
- package/dist/remote/auth/index.d.ts +86 -0
- package/dist/remote/auth/index.d.ts.map +1 -0
- package/dist/remote/auth/index.js +152 -0
- package/dist/remote/auth/index.js.map +1 -0
- package/dist/remote/server.d.ts +140 -0
- package/dist/remote/server.d.ts.map +1 -0
- package/dist/remote/server.js +412 -0
- package/dist/remote/server.js.map +1 -0
- package/dist/resources/current/sap-current-config.resource.d.ts +30 -0
- package/dist/resources/current/sap-current-config.resource.d.ts.map +1 -0
- package/dist/resources/current/sap-current-config.resource.js +142 -0
- package/dist/resources/current/sap-current-config.resource.js.map +1 -0
- package/dist/resources/execution-proof/index.d.ts +5 -0
- package/dist/resources/execution-proof/index.d.ts.map +1 -0
- package/dist/resources/execution-proof/index.js +5 -0
- package/dist/resources/execution-proof/index.js.map +1 -0
- package/dist/resources/execution-proof/sap-execution-record.resource.d.ts +13 -0
- package/dist/resources/execution-proof/sap-execution-record.resource.d.ts.map +1 -0
- package/dist/resources/execution-proof/sap-execution-record.resource.js +75 -0
- package/dist/resources/execution-proof/sap-execution-record.resource.js.map +1 -0
- package/dist/resources/index.d.ts +5 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +5 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/memory/index.d.ts +5 -0
- package/dist/resources/memory/index.d.ts.map +1 -0
- package/dist/resources/memory/index.js +5 -0
- package/dist/resources/memory/index.js.map +1 -0
- package/dist/resources/memory/sap-memory.resource.d.ts +13 -0
- package/dist/resources/memory/sap-memory.resource.d.ts.map +1 -0
- package/dist/resources/memory/sap-memory.resource.js +77 -0
- package/dist/resources/memory/sap-memory.resource.js.map +1 -0
- package/dist/resources/profile/sap-active-profile.resource.d.ts +51 -0
- package/dist/resources/profile/sap-active-profile.resource.d.ts.map +1 -0
- package/dist/resources/profile/sap-active-profile.resource.js +119 -0
- package/dist/resources/profile/sap-active-profile.resource.js.map +1 -0
- package/dist/resources/register-resources.d.ts +10 -0
- package/dist/resources/register-resources.d.ts.map +1 -0
- package/dist/resources/register-resources.js +33 -0
- package/dist/resources/register-resources.js.map +1 -0
- package/dist/resources/registry/index.d.ts +6 -0
- package/dist/resources/registry/index.d.ts.map +1 -0
- package/dist/resources/registry/index.js +6 -0
- package/dist/resources/registry/index.js.map +1 -0
- package/dist/resources/registry/sap-agent.resource.d.ts +13 -0
- package/dist/resources/registry/sap-agent.resource.d.ts.map +1 -0
- package/dist/resources/registry/sap-agent.resource.js +75 -0
- package/dist/resources/registry/sap-agent.resource.js.map +1 -0
- package/dist/resources/registry/sap-global-registry.resource.d.ts +13 -0
- package/dist/resources/registry/sap-global-registry.resource.d.ts.map +1 -0
- package/dist/resources/registry/sap-global-registry.resource.js +71 -0
- package/dist/resources/registry/sap-global-registry.resource.js.map +1 -0
- package/dist/resources/reputation/index.d.ts +5 -0
- package/dist/resources/reputation/index.d.ts.map +1 -0
- package/dist/resources/reputation/index.js +5 -0
- package/dist/resources/reputation/index.js.map +1 -0
- package/dist/resources/reputation/sap-reputation.resource.d.ts +13 -0
- package/dist/resources/reputation/sap-reputation.resource.d.ts.map +1 -0
- package/dist/resources/reputation/sap-reputation.resource.js +75 -0
- package/dist/resources/reputation/sap-reputation.resource.js.map +1 -0
- package/dist/resources/stats/sap-network-stats.resource.d.ts +14 -0
- package/dist/resources/stats/sap-network-stats.resource.d.ts.map +1 -0
- package/dist/resources/stats/sap-network-stats.resource.js +86 -0
- package/dist/resources/stats/sap-network-stats.resource.js.map +1 -0
- package/dist/resources/tool-schema/index.d.ts +5 -0
- package/dist/resources/tool-schema/index.d.ts.map +1 -0
- package/dist/resources/tool-schema/index.js +5 -0
- package/dist/resources/tool-schema/index.js.map +1 -0
- package/dist/resources/tool-schema/sap-tool-schema.resource.d.ts +13 -0
- package/dist/resources/tool-schema/sap-tool-schema.resource.d.ts.map +1 -0
- package/dist/resources/tool-schema/sap-tool-schema.resource.js +75 -0
- package/dist/resources/tool-schema/sap-tool-schema.resource.js.map +1 -0
- package/dist/sap/index.d.ts +7 -0
- package/dist/sap/index.d.ts.map +1 -0
- package/dist/sap/index.js +6 -0
- package/dist/sap/index.js.map +1 -0
- package/dist/sap/sap-client-manager.d.ts +54 -0
- package/dist/sap/sap-client-manager.d.ts.map +1 -0
- package/dist/sap/sap-client-manager.js +129 -0
- package/dist/sap/sap-client-manager.js.map +1 -0
- package/dist/sap/sap-errors.d.ts +13 -0
- package/dist/sap/sap-errors.d.ts.map +1 -0
- package/dist/sap/sap-errors.js +23 -0
- package/dist/sap/sap-errors.js.map +1 -0
- package/dist/sap/sap-types.d.ts +69 -0
- package/dist/sap/sap-types.d.ts.map +1 -0
- package/dist/sap/sap-types.js +5 -0
- package/dist/sap/sap-types.js.map +1 -0
- package/dist/schemas/common.schema.d.ts +42 -0
- package/dist/schemas/common.schema.d.ts.map +1 -0
- package/dist/schemas/common.schema.js +36 -0
- package/dist/schemas/common.schema.js.map +1 -0
- package/dist/schemas/developer.schema.d.ts +31 -0
- package/dist/schemas/developer.schema.d.ts.map +1 -0
- package/dist/schemas/developer.schema.js +19 -0
- package/dist/schemas/developer.schema.js.map +1 -0
- package/dist/schemas/execution-proof.schema.d.ts +44 -0
- package/dist/schemas/execution-proof.schema.d.ts.map +1 -0
- package/dist/schemas/execution-proof.schema.js +26 -0
- package/dist/schemas/execution-proof.schema.js.map +1 -0
- package/dist/schemas/identity.schema.d.ts +34 -0
- package/dist/schemas/identity.schema.d.ts.map +1 -0
- package/dist/schemas/identity.schema.js +21 -0
- package/dist/schemas/identity.schema.js.map +1 -0
- package/dist/schemas/index.d.ts +15 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +15 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/memory.schema.d.ts +34 -0
- package/dist/schemas/memory.schema.d.ts.map +1 -0
- package/dist/schemas/memory.schema.js +21 -0
- package/dist/schemas/memory.schema.js.map +1 -0
- package/dist/schemas/payments.schema.d.ts +37 -0
- package/dist/schemas/payments.schema.d.ts.map +1 -0
- package/dist/schemas/payments.schema.js +22 -0
- package/dist/schemas/payments.schema.js.map +1 -0
- package/dist/schemas/registry.schema.d.ts +65 -0
- package/dist/schemas/registry.schema.d.ts.map +1 -0
- package/dist/schemas/registry.schema.js +34 -0
- package/dist/schemas/registry.schema.js.map +1 -0
- package/dist/schemas/reputation.schema.d.ts +31 -0
- package/dist/schemas/reputation.schema.d.ts.map +1 -0
- package/dist/schemas/reputation.schema.js +20 -0
- package/dist/schemas/reputation.schema.js.map +1 -0
- package/dist/schemas/settlement.schema.d.ts +50 -0
- package/dist/schemas/settlement.schema.d.ts.map +1 -0
- package/dist/schemas/settlement.schema.js +29 -0
- package/dist/schemas/settlement.schema.js.map +1 -0
- package/dist/schemas/tool-schema.schema.d.ts +56 -0
- package/dist/schemas/tool-schema.schema.d.ts.map +1 -0
- package/dist/schemas/tool-schema.schema.js +26 -0
- package/dist/schemas/tool-schema.schema.js.map +1 -0
- package/dist/schemas/transaction.schema.d.ts +34 -0
- package/dist/schemas/transaction.schema.d.ts.map +1 -0
- package/dist/schemas/transaction.schema.js +20 -0
- package/dist/schemas/transaction.schema.js.map +1 -0
- package/dist/security/approval-required.d.ts +9 -0
- package/dist/security/approval-required.d.ts.map +1 -0
- package/dist/security/approval-required.js +10 -0
- package/dist/security/approval-required.js.map +1 -0
- package/dist/security/index.d.ts +9 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +9 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/private-key-guard.d.ts +11 -0
- package/dist/security/private-key-guard.d.ts.map +1 -0
- package/dist/security/private-key-guard.js +22 -0
- package/dist/security/private-key-guard.js.map +1 -0
- package/dist/security/prompt-injection-notes.d.ts +13 -0
- package/dist/security/prompt-injection-notes.d.ts.map +1 -0
- package/dist/security/prompt-injection-notes.js +23 -0
- package/dist/security/prompt-injection-notes.js.map +1 -0
- package/dist/security/tool-permissions.d.ts +30 -0
- package/dist/security/tool-permissions.d.ts.map +1 -0
- package/dist/security/tool-permissions.js +270 -0
- package/dist/security/tool-permissions.js.map +1 -0
- package/dist/security/unsafe-action-guard.d.ts +28 -0
- package/dist/security/unsafe-action-guard.d.ts.map +1 -0
- package/dist/security/unsafe-action-guard.js +175 -0
- package/dist/security/unsafe-action-guard.js.map +1 -0
- package/dist/server/create-server.d.ts +12 -0
- package/dist/server/create-server.d.ts.map +1 -0
- package/dist/server/create-server.js +57 -0
- package/dist/server/create-server.js.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +7 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/register-capabilities.d.ts +10 -0
- package/dist/server/register-capabilities.d.ts.map +1 -0
- package/dist/server/register-capabilities.js +23 -0
- package/dist/server/register-capabilities.js.map +1 -0
- package/dist/server/server-metadata.d.ts +32 -0
- package/dist/server/server-metadata.d.ts.map +1 -0
- package/dist/server/server-metadata.js +32 -0
- package/dist/server/server-metadata.js.map +1 -0
- package/dist/session/agent-session.d.ts +25 -0
- package/dist/session/agent-session.d.ts.map +1 -0
- package/dist/session/agent-session.js +35 -0
- package/dist/session/agent-session.js.map +1 -0
- package/dist/session/delegated-session.d.ts +20 -0
- package/dist/session/delegated-session.d.ts.map +1 -0
- package/dist/session/delegated-session.js +47 -0
- package/dist/session/delegated-session.js.map +1 -0
- package/dist/session/index.d.ts +10 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +9 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/redis-session-store.d.ts +89 -0
- package/dist/session/redis-session-store.d.ts.map +1 -0
- package/dist/session/redis-session-store.js +219 -0
- package/dist/session/redis-session-store.js.map +1 -0
- package/dist/session/session-limits.d.ts +20 -0
- package/dist/session/session-limits.d.ts.map +1 -0
- package/dist/session/session-limits.js +55 -0
- package/dist/session/session-limits.js.map +1 -0
- package/dist/session/session-permissions.d.ts +37 -0
- package/dist/session/session-permissions.d.ts.map +1 -0
- package/dist/session/session-permissions.js +58 -0
- package/dist/session/session-permissions.js.map +1 -0
- package/dist/session/session-store.d.ts +38 -0
- package/dist/session/session-store.d.ts.map +1 -0
- package/dist/session/session-store.js +62 -0
- package/dist/session/session-store.js.map +1 -0
- package/dist/session/session-types.d.ts +33 -0
- package/dist/session/session-types.d.ts.map +1 -0
- package/dist/session/session-types.js +5 -0
- package/dist/session/session-types.js.map +1 -0
- package/dist/signer/external-signer.d.ts +16 -0
- package/dist/signer/external-signer.d.ts.map +1 -0
- package/dist/signer/external-signer.js +128 -0
- package/dist/signer/external-signer.js.map +1 -0
- package/dist/signer/index.d.ts +9 -0
- package/dist/signer/index.d.ts.map +1 -0
- package/dist/signer/index.js +8 -0
- package/dist/signer/index.js.map +1 -0
- package/dist/signer/load-keypair.d.ts +15 -0
- package/dist/signer/load-keypair.d.ts.map +1 -0
- package/dist/signer/load-keypair.js +39 -0
- package/dist/signer/load-keypair.js.map +1 -0
- package/dist/signer/local-keypair-signer.d.ts +11 -0
- package/dist/signer/local-keypair-signer.d.ts.map +1 -0
- package/dist/signer/local-keypair-signer.js +46 -0
- package/dist/signer/local-keypair-signer.js.map +1 -0
- package/dist/signer/signer-resolver.d.ts +10 -0
- package/dist/signer/signer-resolver.d.ts.map +1 -0
- package/dist/signer/signer-resolver.js +63 -0
- package/dist/signer/signer-resolver.js.map +1 -0
- package/dist/signer/signer-types.d.ts +35 -0
- package/dist/signer/signer-types.d.ts.map +1 -0
- package/dist/signer/signer-types.js +5 -0
- package/dist/signer/signer-types.js.map +1 -0
- package/dist/signer/signing-proxy.d.ts +45 -0
- package/dist/signer/signing-proxy.d.ts.map +1 -0
- package/dist/signer/signing-proxy.js +300 -0
- package/dist/signer/signing-proxy.js.map +1 -0
- package/dist/tools/client-sdk-tools.d.ts +22 -0
- package/dist/tools/client-sdk-tools.d.ts.map +1 -0
- package/dist/tools/client-sdk-tools.js +220 -0
- package/dist/tools/client-sdk-tools.js.map +1 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/profile-tools.d.ts +12 -0
- package/dist/tools/profile-tools.d.ts.map +1 -0
- package/dist/tools/profile-tools.js +250 -0
- package/dist/tools/profile-tools.js.map +1 -0
- package/dist/tools/register-tools.d.ts +12 -0
- package/dist/tools/register-tools.d.ts.map +1 -0
- package/dist/tools/register-tools.js +36 -0
- package/dist/tools/register-tools.js.map +1 -0
- package/dist/tools/sap-network-stats.tool.d.ts +14 -0
- package/dist/tools/sap-network-stats.tool.d.ts.map +1 -0
- package/dist/tools/sap-network-stats.tool.js +101 -0
- package/dist/tools/sap-network-stats.tool.js.map +1 -0
- package/dist/tools/sap-sdk-tools.d.ts +15 -0
- package/dist/tools/sap-sdk-tools.d.ts.map +1 -0
- package/dist/tools/sap-sdk-tools.js +1515 -0
- package/dist/tools/sap-sdk-tools.js.map +1 -0
- package/dist/tools/sap-sns-tools.d.ts +35 -0
- package/dist/tools/sap-sns-tools.d.ts.map +1 -0
- package/dist/tools/sap-sns-tools.js +626 -0
- package/dist/tools/sap-sns-tools.js.map +1 -0
- package/dist/tools/skills-tools.d.ts +12 -0
- package/dist/tools/skills-tools.d.ts.map +1 -0
- package/dist/tools/skills-tools.js +273 -0
- package/dist/tools/skills-tools.js.map +1 -0
- package/dist/tools/transaction-tools.d.ts +14 -0
- package/dist/tools/transaction-tools.d.ts.map +1 -0
- package/dist/tools/transaction-tools.js +297 -0
- package/dist/tools/transaction-tools.js.map +1 -0
- package/dist/transports/http.d.ts +40 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +212 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/index.d.ts +6 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +6 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/transports/stdio.d.ts +14 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +32 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/tui/components.d.ts +59 -0
- package/dist/tui/components.d.ts.map +1 -0
- package/dist/tui/components.js +82 -0
- package/dist/tui/components.js.map +1 -0
- package/dist/tui/config-wizard.d.ts +12 -0
- package/dist/tui/config-wizard.d.ts.map +1 -0
- package/dist/tui/config-wizard.js +348 -0
- package/dist/tui/config-wizard.js.map +1 -0
- package/dist/tui/wizard-save.d.ts +51 -0
- package/dist/tui/wizard-save.d.ts.map +1 -0
- package/dist/tui/wizard-save.js +148 -0
- package/dist/tui/wizard-save.js.map +1 -0
- package/docs/00_README.md +45 -0
- package/docs/01_PRODUCT_OVERVIEW.md +69 -0
- package/docs/02_ARCHITECTURE_AND_REQUEST_FLOW.md +120 -0
- package/docs/03_CONFIGURATION_AND_WIZARD.md +143 -0
- package/docs/04_LOCAL_STDIO_USAGE.md +118 -0
- package/docs/05_REMOTE_VPS_DEPLOYMENT.md +136 -0
- package/docs/06_PAYMENTS_X402_AND_PAYSH.md +162 -0
- package/docs/07_ENDPOINTS_AND_CLIENTS.md +114 -0
- package/docs/08_SECURITY_POLICY_AND_SIGNING.md +134 -0
- package/docs/09_TOOLS_SKILLS_AND_AGENT_GUIDE.md +72 -0
- package/docs/10_OPERATIONS_RELEASE_AND_PM2.md +90 -0
- package/docs/11_CODE_QUALITY_AUDIT.md +49 -0
- package/ecosystem.config.example.cjs +55 -0
- package/package.json +132 -0
- package/skills/README.md +146 -0
- package/skills/sap-agent-registry/SKILL.md +39 -0
- package/skills/sap-agentkit/SKILL.md +40 -0
- package/skills/sap-defi/SKILL.md +51 -0
- package/skills/sap-discovery-indexing/SKILL.md +33 -0
- package/skills/sap-escrow-settlement/SKILL.md +37 -0
- package/skills/sap-ledger-session/SKILL.md +24 -0
- package/skills/sap-market-data/SKILL.md +36 -0
- package/skills/sap-mcp/SKILL.md +202 -0
- package/skills/sap-mcp/TOOL_REFERENCE.md +184 -0
- package/skills/sap-memory-vault/SKILL.md +29 -0
- package/skills/sap-nft-metaplex/SKILL.md +38 -0
- package/skills/sap-operations/SKILL.md +97 -0
- package/skills/sap-payments-x402/SKILL.md +47 -0
- package/skills/sap-reputation-attestation/SKILL.md +30 -0
- package/skills/sap-sns/SKILL.md +51 -0
- package/skills/sap-social-gaming/SKILL.md +30 -0
- package/skills/sap-solana-token/SKILL.md +32 -0
- package/skills/sap-staking/SKILL.md +24 -0
- package/skills/sap-tool-registry/SKILL.md +29 -0
|
@@ -0,0 +1,1515 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SAP SDK MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* This module intentionally wraps only methods that exist on
|
|
5
|
+
* `@oobe-protocol-labs/synapse-sap-sdk@0.21.x`. It does not create local
|
|
6
|
+
* facades for missing SDK namespaces and it does not fabricate network data.
|
|
7
|
+
*/
|
|
8
|
+
import { PublicKey } from '@solana/web3.js';
|
|
9
|
+
import BN from 'bn.js';
|
|
10
|
+
import { TOOL_CATEGORY_VALUES } from '@oobe-protocol-labs/synapse-sap-sdk';
|
|
11
|
+
import { SettlementMode, TokenType, } from '@oobe-protocol-labs/synapse-sap-sdk/types';
|
|
12
|
+
import { createTextResponse } from '../adapters/mcp/tool-response.js';
|
|
13
|
+
import { registerTool } from '../adapters/mcp/sdk-compat.js';
|
|
14
|
+
import { getSapClient, isSapClientInitialized } from '../sap/sap-client-manager.js';
|
|
15
|
+
import { logger } from '../core/logger.js';
|
|
16
|
+
/**
|
|
17
|
+
* @name jsonReplacer
|
|
18
|
+
* @description Serializes SDK values such as PublicKey, BN, bigint, Buffer, and Uint8Array into JSON-safe output.
|
|
19
|
+
*/
|
|
20
|
+
function jsonReplacer(_key, value) {
|
|
21
|
+
if (value instanceof PublicKey) {
|
|
22
|
+
return value.toBase58();
|
|
23
|
+
}
|
|
24
|
+
if (BN.isBN(value)) {
|
|
25
|
+
return value.toString(10);
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'bigint') {
|
|
28
|
+
return value.toString();
|
|
29
|
+
}
|
|
30
|
+
if (value instanceof Uint8Array) {
|
|
31
|
+
return Array.from(value);
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @name ok
|
|
37
|
+
* @description Wraps a successful tool result in the MCP text response shape.
|
|
38
|
+
*/
|
|
39
|
+
function ok(payload) {
|
|
40
|
+
return createTextResponse(JSON.stringify({ success: true, ...asObjectPayload(payload) }, jsonReplacer, 2));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @name asObjectPayload
|
|
44
|
+
* @description Preserves object payloads and wraps scalar payloads under `result`.
|
|
45
|
+
*/
|
|
46
|
+
function asObjectPayload(payload) {
|
|
47
|
+
return payload && typeof payload === 'object' && !Array.isArray(payload)
|
|
48
|
+
? payload
|
|
49
|
+
: { result: payload };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @name getSapAnchorAccounts
|
|
53
|
+
* @description Narrows the SDK Anchor program account namespace used for global read-only enumeration.
|
|
54
|
+
*/
|
|
55
|
+
function getSapAnchorAccounts(client) {
|
|
56
|
+
return client.program.account;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @name bnString
|
|
60
|
+
* @description Converts BN-like SDK counters into stable decimal strings.
|
|
61
|
+
*/
|
|
62
|
+
function bnString(value) {
|
|
63
|
+
return BN.isBN(value) ? value.toString(10) : String(value);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @name buildProtocolMembership
|
|
67
|
+
* @description Builds an agent PDA to protocol ID lookup from protocol index accounts.
|
|
68
|
+
*/
|
|
69
|
+
function buildProtocolMembership(protocolIndexes) {
|
|
70
|
+
const membership = new Map();
|
|
71
|
+
for (const { account } of protocolIndexes) {
|
|
72
|
+
for (const agent of account.agents) {
|
|
73
|
+
const agentPda = agent.toBase58();
|
|
74
|
+
const protocols = membership.get(agentPda) ?? [];
|
|
75
|
+
protocols.push(account.protocolId);
|
|
76
|
+
membership.set(agentPda, protocols);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return membership;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @name summarizeProtocolIndexes
|
|
83
|
+
* @description Converts protocol index accounts into compact MCP-safe summaries.
|
|
84
|
+
*/
|
|
85
|
+
function summarizeProtocolIndexes(protocolIndexes) {
|
|
86
|
+
return protocolIndexes
|
|
87
|
+
.map(({ publicKey, account }) => ({
|
|
88
|
+
pda: publicKey.toBase58(),
|
|
89
|
+
protocolId: account.protocolId,
|
|
90
|
+
agentCount: account.agents.length,
|
|
91
|
+
lastUpdated: bnString(account.lastUpdated),
|
|
92
|
+
}))
|
|
93
|
+
.sort((left, right) => left.protocolId.localeCompare(right.protocolId));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @name buildAgentDirectoryEntry
|
|
97
|
+
* @description Converts an AgentAccount into a compact directory row with optional stats and protocol-index membership.
|
|
98
|
+
*/
|
|
99
|
+
function buildAgentDirectoryEntry(accountResult, statsByAgent, indexedProtocolsByAgent) {
|
|
100
|
+
const agentPda = accountResult.publicKey.toBase58();
|
|
101
|
+
const account = accountResult.account;
|
|
102
|
+
const stats = statsByAgent.get(agentPda);
|
|
103
|
+
return {
|
|
104
|
+
agentPda,
|
|
105
|
+
wallet: account.wallet.toBase58(),
|
|
106
|
+
name: account.name,
|
|
107
|
+
description: account.description,
|
|
108
|
+
agentId: account.agentId,
|
|
109
|
+
agentUri: account.agentUri,
|
|
110
|
+
x402Endpoint: account.x402Endpoint,
|
|
111
|
+
isActive: account.isActive,
|
|
112
|
+
createdAt: bnString(account.createdAt),
|
|
113
|
+
updatedAt: bnString(account.updatedAt),
|
|
114
|
+
reputationScore: account.reputationScore,
|
|
115
|
+
totalFeedbacks: account.totalFeedbacks,
|
|
116
|
+
totalCallsServed: stats ? bnString(stats.totalCallsServed) : bnString(account.totalCallsServed),
|
|
117
|
+
avgLatencyMs: account.avgLatencyMs,
|
|
118
|
+
uptimePercent: account.uptimePercent,
|
|
119
|
+
protocols: account.protocols,
|
|
120
|
+
indexedProtocols: indexedProtocolsByAgent.get(agentPda) ?? [],
|
|
121
|
+
capabilities: account.capabilities.map((capability) => capability.id),
|
|
122
|
+
activePlugins: account.activePlugins.map((plugin) => `${plugin.pluginType}:${plugin.pda.toBase58()}`),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @name matchesAgentDirectoryFilters
|
|
127
|
+
* @description Applies optional directory filters to an already hydrated agent row.
|
|
128
|
+
*/
|
|
129
|
+
function matchesAgentDirectoryFilters(entry, filters) {
|
|
130
|
+
if (!filters.includeInactive && !entry.isActive) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (filters.protocol && !entry.protocols.includes(filters.protocol) && !entry.indexedProtocols.includes(filters.protocol)) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (filters.capability && !entry.capabilities.includes(filters.capability)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @name asRecord
|
|
143
|
+
* @description Normalizes MCP tool input into an object.
|
|
144
|
+
*/
|
|
145
|
+
function asRecord(input) {
|
|
146
|
+
return input && typeof input === 'object' && !Array.isArray(input) ? input : {};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @name requiredString
|
|
150
|
+
* @description Reads a required string field from tool input.
|
|
151
|
+
*/
|
|
152
|
+
function requiredString(input, field) {
|
|
153
|
+
const value = input[field];
|
|
154
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
155
|
+
throw new Error(`${field} is required`);
|
|
156
|
+
}
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @name optionalString
|
|
161
|
+
* @description Reads an optional string field from tool input.
|
|
162
|
+
*/
|
|
163
|
+
function optionalString(input, field) {
|
|
164
|
+
const value = input[field];
|
|
165
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @name requiredNumber
|
|
169
|
+
* @description Reads a required finite number field from tool input.
|
|
170
|
+
*/
|
|
171
|
+
function requiredNumber(input, field) {
|
|
172
|
+
const value = input[field];
|
|
173
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value))) {
|
|
177
|
+
return Number(value);
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`${field} must be a finite number`);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* @name optionalNumber
|
|
183
|
+
* @description Reads an optional finite number field from tool input.
|
|
184
|
+
*/
|
|
185
|
+
function optionalNumber(input, field) {
|
|
186
|
+
const value = input[field];
|
|
187
|
+
if (value === undefined || value === null || value === '') {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
return requiredNumber(input, field);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @name requiredBn
|
|
194
|
+
* @description Reads a numeric field and converts it to BN for SAP SDK calls.
|
|
195
|
+
*/
|
|
196
|
+
function requiredBn(input, field) {
|
|
197
|
+
const value = input[field];
|
|
198
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
199
|
+
return new BN(Math.trunc(value));
|
|
200
|
+
}
|
|
201
|
+
if (typeof value === 'string' && /^-?\d+$/.test(value)) {
|
|
202
|
+
return new BN(value, 10);
|
|
203
|
+
}
|
|
204
|
+
throw new Error(`${field} must be an integer number or decimal string`);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* @name optionalBn
|
|
208
|
+
* @description Reads an optional numeric field and converts it to BN.
|
|
209
|
+
*/
|
|
210
|
+
function optionalBn(input, field, fallback) {
|
|
211
|
+
const value = input[field];
|
|
212
|
+
return value === undefined || value === null || value === '' ? fallback : requiredBn(input, field);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* @name optionalBoolean
|
|
216
|
+
* @description Reads an optional boolean field from tool input.
|
|
217
|
+
*/
|
|
218
|
+
function optionalBoolean(input, field) {
|
|
219
|
+
const value = input[field];
|
|
220
|
+
if (value === undefined || value === null || value === '') {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
if (typeof value === 'boolean') {
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
if (typeof value === 'string' && (value === 'true' || value === 'false')) {
|
|
227
|
+
return value === 'true';
|
|
228
|
+
}
|
|
229
|
+
throw new Error(`${field} must be a boolean`);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @name requiredPublicKey
|
|
233
|
+
* @description Reads a required base58 public key field from tool input.
|
|
234
|
+
*/
|
|
235
|
+
function requiredPublicKey(input, field) {
|
|
236
|
+
return new PublicKey(requiredString(input, field));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @name optionalPublicKey
|
|
240
|
+
* @description Reads an optional base58 public key field from tool input.
|
|
241
|
+
*/
|
|
242
|
+
function optionalPublicKey(input, field) {
|
|
243
|
+
const value = optionalString(input, field);
|
|
244
|
+
return value ? new PublicKey(value) : undefined;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* @name parseVolumeCurve
|
|
248
|
+
* @description Converts MCP JSON input into SDK volume-curve breakpoints.
|
|
249
|
+
*/
|
|
250
|
+
function parseVolumeCurve(value) {
|
|
251
|
+
if (value === undefined || value === null) {
|
|
252
|
+
return [];
|
|
253
|
+
}
|
|
254
|
+
if (!Array.isArray(value)) {
|
|
255
|
+
throw new Error('volumeCurve must be an array');
|
|
256
|
+
}
|
|
257
|
+
return value.map((item) => {
|
|
258
|
+
const record = asRecord(item);
|
|
259
|
+
return {
|
|
260
|
+
afterCalls: requiredNumber(record, 'afterCalls'),
|
|
261
|
+
pricePerCall: requiredBn(record, 'pricePerCall'),
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @name requiredBytes
|
|
267
|
+
* @description Reads byte-array fields used for hashes, nonces, and encrypted payloads.
|
|
268
|
+
*/
|
|
269
|
+
function requiredBytes(input, field, expectedLength) {
|
|
270
|
+
const value = input[field];
|
|
271
|
+
let bytes;
|
|
272
|
+
if (Array.isArray(value)) {
|
|
273
|
+
bytes = value.map((item) => {
|
|
274
|
+
if (typeof item !== 'number' || item < 0 || item > 255 || !Number.isInteger(item)) {
|
|
275
|
+
throw new Error(`${field} must contain byte values between 0 and 255`);
|
|
276
|
+
}
|
|
277
|
+
return item;
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else if (typeof value === 'string') {
|
|
281
|
+
const normalized = value.startsWith('0x') ? value.slice(2) : value;
|
|
282
|
+
if (/^[0-9a-fA-F]+$/.test(normalized) && normalized.length % 2 === 0) {
|
|
283
|
+
bytes = Array.from(Buffer.from(normalized, 'hex'));
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
bytes = Array.from(Buffer.from(value, 'base64'));
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
throw new Error(`${field} must be a byte array, hex string, or base64 string`);
|
|
291
|
+
}
|
|
292
|
+
if (expectedLength !== undefined && bytes.length !== expectedLength) {
|
|
293
|
+
throw new Error(`${field} must be ${expectedLength} bytes`);
|
|
294
|
+
}
|
|
295
|
+
return bytes;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* @name optionalBytes
|
|
299
|
+
* @description Reads an optional byte-array field.
|
|
300
|
+
*/
|
|
301
|
+
function optionalBytes(input, field, fallback = []) {
|
|
302
|
+
return input[field] === undefined || input[field] === null ? fallback : requiredBytes(input, field);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* @name optionalFairScaleTask
|
|
306
|
+
* @description Reads an optional FairScale task value supported by the SDK.
|
|
307
|
+
*/
|
|
308
|
+
function optionalFairScaleTask(input, field) {
|
|
309
|
+
const value = optionalString(input, field);
|
|
310
|
+
if (!value) {
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
if (value === 'defi_execution' || value === 'trust_focused' || value === 'work_focused' || value === 'hiring') {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
throw new Error(`${field} must be one of defi_execution, trust_focused, work_focused, hiring`);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @name requiredToolCategory
|
|
320
|
+
* @description Reads a tool category compatible with SDK DiscoveryRegistry.findToolsByCategory.
|
|
321
|
+
*/
|
|
322
|
+
function requiredToolCategory(input) {
|
|
323
|
+
const rawCategory = input.category;
|
|
324
|
+
if (typeof rawCategory === 'number') {
|
|
325
|
+
return rawCategory;
|
|
326
|
+
}
|
|
327
|
+
const category = requiredString(input, 'category');
|
|
328
|
+
if (category in TOOL_CATEGORY_VALUES) {
|
|
329
|
+
return category;
|
|
330
|
+
}
|
|
331
|
+
throw new Error(`category must be a numeric category or one of ${Object.keys(TOOL_CATEGORY_VALUES).join(', ')}`);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* @name parseCapabilities
|
|
335
|
+
* @description Converts user input into SDK `Capability[]` values.
|
|
336
|
+
*/
|
|
337
|
+
function parseCapabilities(value) {
|
|
338
|
+
if (value === undefined || value === null) {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
if (!Array.isArray(value)) {
|
|
342
|
+
throw new Error('capabilities must be an array');
|
|
343
|
+
}
|
|
344
|
+
return value.map((item) => {
|
|
345
|
+
if (typeof item === 'string') {
|
|
346
|
+
return { id: item, description: null, protocolId: null, version: null };
|
|
347
|
+
}
|
|
348
|
+
const record = asRecord(item);
|
|
349
|
+
return {
|
|
350
|
+
id: requiredString(record, 'id'),
|
|
351
|
+
description: optionalString(record, 'description') ?? null,
|
|
352
|
+
protocolId: optionalString(record, 'protocolId') ?? null,
|
|
353
|
+
version: optionalString(record, 'version') ?? null,
|
|
354
|
+
};
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* @name parsePricingTiers
|
|
359
|
+
* @description Converts user input into SDK `PricingTier[]` values.
|
|
360
|
+
*/
|
|
361
|
+
function parsePricingTiers(value) {
|
|
362
|
+
if (value === undefined || value === null) {
|
|
363
|
+
return [];
|
|
364
|
+
}
|
|
365
|
+
if (!Array.isArray(value)) {
|
|
366
|
+
throw new Error('pricing must be an array');
|
|
367
|
+
}
|
|
368
|
+
return value.map((item) => {
|
|
369
|
+
const record = asRecord(item);
|
|
370
|
+
const pricePerCall = optionalBn(record, 'pricePerCall', new BN(0));
|
|
371
|
+
return {
|
|
372
|
+
tierId: optionalString(record, 'tierId') ?? 'default',
|
|
373
|
+
pricePerCall,
|
|
374
|
+
minPricePerCall: record.minPricePerCall === undefined ? null : requiredBn(record, 'minPricePerCall'),
|
|
375
|
+
maxPricePerCall: record.maxPricePerCall === undefined ? null : requiredBn(record, 'maxPricePerCall'),
|
|
376
|
+
rateLimit: optionalNumber(record, 'rateLimit') ?? 60,
|
|
377
|
+
maxCallsPerSession: optionalNumber(record, 'maxCallsPerSession') ?? 1_000,
|
|
378
|
+
burstLimit: optionalNumber(record, 'burstLimit') ?? null,
|
|
379
|
+
tokenType: TokenType.Sol,
|
|
380
|
+
tokenMint: optionalPublicKey(record, 'tokenMint') ?? null,
|
|
381
|
+
tokenDecimals: optionalNumber(record, 'tokenDecimals') ?? null,
|
|
382
|
+
settlementMode: SettlementMode.Escrow,
|
|
383
|
+
minEscrowDeposit: record.minEscrowDeposit === undefined ? null : requiredBn(record, 'minEscrowDeposit'),
|
|
384
|
+
batchIntervalSec: optionalNumber(record, 'batchIntervalSec') ?? null,
|
|
385
|
+
volumeCurve: null,
|
|
386
|
+
};
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @name parseProtocols
|
|
391
|
+
* @description Converts user input into SDK protocol identifiers.
|
|
392
|
+
*/
|
|
393
|
+
function parseProtocols(value) {
|
|
394
|
+
if (value === undefined || value === null) {
|
|
395
|
+
return [];
|
|
396
|
+
}
|
|
397
|
+
if (!Array.isArray(value)) {
|
|
398
|
+
throw new Error('protocols must be an array');
|
|
399
|
+
}
|
|
400
|
+
return value.map((item) => {
|
|
401
|
+
if (typeof item !== 'string' || item.length === 0) {
|
|
402
|
+
throw new Error('protocols must contain non-empty strings');
|
|
403
|
+
}
|
|
404
|
+
return item;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* @name parseRegisterAgentArgs
|
|
409
|
+
* @description Builds strongly typed `RegisterAgentArgs` from MCP JSON input.
|
|
410
|
+
*/
|
|
411
|
+
function parseRegisterAgentArgs(input) {
|
|
412
|
+
return {
|
|
413
|
+
name: requiredString(input, 'name'),
|
|
414
|
+
description: requiredString(input, 'description'),
|
|
415
|
+
capabilities: parseCapabilities(input.capabilities),
|
|
416
|
+
pricing: parsePricingTiers(input.pricing),
|
|
417
|
+
protocols: parseProtocols(input.protocols),
|
|
418
|
+
agentId: optionalString(input, 'agentId') ?? null,
|
|
419
|
+
agentUri: optionalString(input, 'agentUri') ?? optionalString(input, 'metadataUri') ?? null,
|
|
420
|
+
x402Endpoint: optionalString(input, 'x402Endpoint') ?? null,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* @name parseUpdateAgentArgs
|
|
425
|
+
* @description Builds strongly typed `UpdateAgentArgs` from MCP JSON input.
|
|
426
|
+
*/
|
|
427
|
+
function parseUpdateAgentArgs(input) {
|
|
428
|
+
return {
|
|
429
|
+
name: optionalString(input, 'name') ?? null,
|
|
430
|
+
description: optionalString(input, 'description') ?? null,
|
|
431
|
+
capabilities: input.capabilities === undefined ? null : parseCapabilities(input.capabilities),
|
|
432
|
+
pricing: input.pricing === undefined ? null : parsePricingTiers(input.pricing),
|
|
433
|
+
protocols: input.protocols === undefined ? null : parseProtocols(input.protocols),
|
|
434
|
+
agentId: optionalString(input, 'agentId') ?? null,
|
|
435
|
+
agentUri: optionalString(input, 'agentUri') ?? optionalString(input, 'metadataUri') ?? null,
|
|
436
|
+
x402Endpoint: optionalString(input, 'x402Endpoint') ?? null,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @name parseEscrowArgs
|
|
441
|
+
* @description Builds typed V1 escrow creation args from MCP JSON input.
|
|
442
|
+
*/
|
|
443
|
+
function parseEscrowArgs(input) {
|
|
444
|
+
return {
|
|
445
|
+
pricePerCall: requiredBn(input, 'pricePerCall'),
|
|
446
|
+
maxCalls: requiredBn(input, 'maxCalls'),
|
|
447
|
+
initialDeposit: requiredBn(input, 'initialDeposit'),
|
|
448
|
+
expiresAt: optionalBn(input, 'expiresAt', new BN(0)),
|
|
449
|
+
volumeCurve: [],
|
|
450
|
+
tokenMint: optionalPublicKey(input, 'tokenMint') ?? null,
|
|
451
|
+
tokenDecimals: optionalNumber(input, 'tokenDecimals') ?? 9,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* @name parseX402PreparePaymentOptions
|
|
456
|
+
* @description Builds typed V1 x402 payment preparation options from MCP JSON input.
|
|
457
|
+
*/
|
|
458
|
+
function parseX402PreparePaymentOptions(input) {
|
|
459
|
+
return {
|
|
460
|
+
pricePerCall: requiredString(input, 'pricePerCall'),
|
|
461
|
+
deposit: requiredString(input, 'deposit'),
|
|
462
|
+
maxCalls: optionalString(input, 'maxCalls'),
|
|
463
|
+
expiresAt: optionalString(input, 'expiresAt'),
|
|
464
|
+
volumeCurve: parseVolumeCurve(input.volumeCurve).map(point => ({
|
|
465
|
+
afterCalls: point.afterCalls,
|
|
466
|
+
pricePerCall: point.pricePerCall,
|
|
467
|
+
})),
|
|
468
|
+
tokenMint: optionalPublicKey(input, 'tokenMint') ?? null,
|
|
469
|
+
tokenDecimals: optionalNumber(input, 'tokenDecimals'),
|
|
470
|
+
networkIdentifier: optionalString(input, 'networkIdentifier'),
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* @name parsePaymentContext
|
|
475
|
+
* @description Reconstructs a safe x402 payment context from public MCP fields.
|
|
476
|
+
*/
|
|
477
|
+
function parsePaymentContext(input) {
|
|
478
|
+
return {
|
|
479
|
+
escrowPda: requiredPublicKey(input, 'escrowPda'),
|
|
480
|
+
agentPda: requiredPublicKey(input, 'agentPda'),
|
|
481
|
+
agentWallet: requiredPublicKey(input, 'agentWallet'),
|
|
482
|
+
depositorWallet: requiredPublicKey(input, 'depositorWallet'),
|
|
483
|
+
pricePerCall: requiredBn(input, 'pricePerCall'),
|
|
484
|
+
maxCalls: requiredBn(input, 'maxCalls'),
|
|
485
|
+
txSignature: requiredString(input, 'txSignature'),
|
|
486
|
+
networkIdentifier: requiredString(input, 'networkIdentifier'),
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* @name parseSettleOptions
|
|
491
|
+
* @description Builds optional SDK settlement tuning options from MCP JSON input.
|
|
492
|
+
*/
|
|
493
|
+
function parseSettleOptions(input) {
|
|
494
|
+
const priorityFeeMicroLamports = optionalNumber(input, 'priorityFeeMicroLamports');
|
|
495
|
+
const computeUnits = optionalNumber(input, 'computeUnits');
|
|
496
|
+
const skipPreflight = optionalBoolean(input, 'skipPreflight');
|
|
497
|
+
const commitment = optionalString(input, 'commitment');
|
|
498
|
+
const maxRetries = optionalNumber(input, 'maxRetries');
|
|
499
|
+
if (priorityFeeMicroLamports === undefined
|
|
500
|
+
&& computeUnits === undefined
|
|
501
|
+
&& skipPreflight === undefined
|
|
502
|
+
&& commitment === undefined
|
|
503
|
+
&& maxRetries === undefined) {
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
if (commitment !== undefined && commitment !== 'processed' && commitment !== 'confirmed' && commitment !== 'finalized') {
|
|
507
|
+
throw new Error('commitment must be processed, confirmed, or finalized');
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
...(priorityFeeMicroLamports !== undefined ? { priorityFeeMicroLamports } : {}),
|
|
511
|
+
...(computeUnits !== undefined ? { computeUnits } : {}),
|
|
512
|
+
...(skipPreflight !== undefined ? { skipPreflight } : {}),
|
|
513
|
+
...(commitment !== undefined ? { commitment } : {}),
|
|
514
|
+
...(maxRetries !== undefined ? { maxRetries } : {}),
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* @name parseX402BatchSettlementEntries
|
|
519
|
+
* @description Converts MCP JSON input into SDK x402 batch-settlement entries.
|
|
520
|
+
*/
|
|
521
|
+
function parseX402BatchSettlementEntries(value) {
|
|
522
|
+
if (!Array.isArray(value)) {
|
|
523
|
+
throw new Error('entries must be an array');
|
|
524
|
+
}
|
|
525
|
+
return value.map((item) => {
|
|
526
|
+
const record = asRecord(item);
|
|
527
|
+
return {
|
|
528
|
+
calls: requiredNumber(record, 'calls'),
|
|
529
|
+
serviceData: requiredString(record, 'serviceData'),
|
|
530
|
+
};
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* @name parseEscrowV2Args
|
|
535
|
+
* @description Builds typed V2 escrow creation args from MCP JSON input.
|
|
536
|
+
*/
|
|
537
|
+
function parseEscrowV2Args(input) {
|
|
538
|
+
return {
|
|
539
|
+
escrowNonce: optionalBn(input, 'nonce', new BN(0)),
|
|
540
|
+
pricePerCall: requiredBn(input, 'pricePerCall'),
|
|
541
|
+
maxCalls: requiredBn(input, 'maxCalls'),
|
|
542
|
+
initialDeposit: requiredBn(input, 'initialDeposit'),
|
|
543
|
+
expiresAt: optionalBn(input, 'expiresAt', new BN(0)),
|
|
544
|
+
volumeCurve: [],
|
|
545
|
+
tokenMint: optionalPublicKey(input, 'tokenMint') ?? null,
|
|
546
|
+
tokenDecimals: optionalNumber(input, 'tokenDecimals') ?? 9,
|
|
547
|
+
settlementSecurity: optionalNumber(input, 'settlementSecurity') ?? 0,
|
|
548
|
+
disputeWindowSlots: optionalBn(input, 'disputeWindowSlots', new BN(0)),
|
|
549
|
+
coSigner: optionalPublicKey(input, 'coSigner') ?? null,
|
|
550
|
+
arbiter: optionalPublicKey(input, 'arbiter') ?? null,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* @name parseSettlement
|
|
555
|
+
* @description Builds typed V1 batch-settlement entries from MCP JSON input.
|
|
556
|
+
*/
|
|
557
|
+
function parseSettlement(item) {
|
|
558
|
+
const record = asRecord(item);
|
|
559
|
+
return {
|
|
560
|
+
callsToSettle: requiredBn(record, 'callsToSettle'),
|
|
561
|
+
serviceHash: requiredBytes(record, 'serviceHash', 32),
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* @name parseFeedbackArgs
|
|
566
|
+
* @description Builds typed feedback args from MCP JSON input.
|
|
567
|
+
*/
|
|
568
|
+
function parseFeedbackArgs(input) {
|
|
569
|
+
return {
|
|
570
|
+
score: requiredNumber(input, 'score'),
|
|
571
|
+
tag: optionalString(input, 'tag') ?? 'general',
|
|
572
|
+
commentHash: input.commentHash === undefined ? null : requiredBytes(input, 'commentHash', 32),
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* @name parseUpdateFeedbackArgs
|
|
577
|
+
* @description Builds typed feedback update args from MCP JSON input.
|
|
578
|
+
*/
|
|
579
|
+
function parseUpdateFeedbackArgs(input) {
|
|
580
|
+
return {
|
|
581
|
+
newScore: requiredNumber(input, 'score'),
|
|
582
|
+
newTag: optionalString(input, 'tag') ?? null,
|
|
583
|
+
commentHash: input.commentHash === undefined ? null : requiredBytes(input, 'commentHash', 32),
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* @name parseAttestationArgs
|
|
588
|
+
* @description Builds typed attestation creation args from MCP JSON input.
|
|
589
|
+
*/
|
|
590
|
+
function parseAttestationArgs(input) {
|
|
591
|
+
return {
|
|
592
|
+
attestationType: optionalString(input, 'attestationType') ?? 'generic',
|
|
593
|
+
metadataHash: requiredBytes(input, 'metadataHash', 32),
|
|
594
|
+
expiresAt: optionalBn(input, 'expiresAt', new BN(0)),
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* @name parseSubscriptionArgs
|
|
599
|
+
* @description Builds typed subscription creation args from MCP JSON input.
|
|
600
|
+
*/
|
|
601
|
+
function parseSubscriptionArgs(input) {
|
|
602
|
+
return {
|
|
603
|
+
subId: optionalBn(input, 'subId', new BN(0)),
|
|
604
|
+
pricePerInterval: requiredBn(input, 'pricePerInterval'),
|
|
605
|
+
billingInterval: requiredNumber(input, 'billingInterval'),
|
|
606
|
+
initialFund: requiredBn(input, 'initialFund'),
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* @name parseMemoryArgs
|
|
611
|
+
* @description Builds typed memory inscription args from MCP JSON input.
|
|
612
|
+
*/
|
|
613
|
+
function parseMemoryArgs(input) {
|
|
614
|
+
return {
|
|
615
|
+
sequence: requiredNumber(input, 'sequence'),
|
|
616
|
+
encryptedData: Buffer.from(requiredBytes(input, 'encryptedData')),
|
|
617
|
+
nonce: requiredBytes(input, 'nonce'),
|
|
618
|
+
contentHash: requiredBytes(input, 'contentHash', 32),
|
|
619
|
+
totalFragments: optionalNumber(input, 'totalFragments') ?? 1,
|
|
620
|
+
fragmentIndex: optionalNumber(input, 'fragmentIndex') ?? 0,
|
|
621
|
+
compression: optionalNumber(input, 'compression') ?? 0,
|
|
622
|
+
epochIndex: optionalNumber(input, 'epochIndex') ?? 0,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* @name parseCompactMemoryArgs
|
|
627
|
+
* @description Builds typed compact inscription args from MCP JSON input.
|
|
628
|
+
*/
|
|
629
|
+
function parseCompactMemoryArgs(input) {
|
|
630
|
+
return {
|
|
631
|
+
sequence: requiredNumber(input, 'sequence'),
|
|
632
|
+
encryptedData: Buffer.from(requiredBytes(input, 'encryptedData')),
|
|
633
|
+
nonce: requiredBytes(input, 'nonce'),
|
|
634
|
+
contentHash: requiredBytes(input, 'contentHash', 32),
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* @name parseUpdateToolArgs
|
|
639
|
+
* @description Builds typed tool update args from MCP JSON input.
|
|
640
|
+
*/
|
|
641
|
+
function parseUpdateToolArgs(input) {
|
|
642
|
+
return {
|
|
643
|
+
descriptionHash: input.descriptionHash === undefined ? null : requiredBytes(input, 'descriptionHash', 32),
|
|
644
|
+
inputSchemaHash: input.inputSchemaHash === undefined ? null : requiredBytes(input, 'inputSchemaHash', 32),
|
|
645
|
+
outputSchemaHash: input.outputSchemaHash === undefined ? null : requiredBytes(input, 'outputSchemaHash', 32),
|
|
646
|
+
httpMethod: optionalNumber(input, 'httpMethod') ?? null,
|
|
647
|
+
category: optionalNumber(input, 'category') ?? null,
|
|
648
|
+
paramsCount: optionalNumber(input, 'paramsCount') ?? null,
|
|
649
|
+
requiredParams: optionalNumber(input, 'requiredParams') ?? null,
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* @name registerSapTool
|
|
654
|
+
* @description Registers one SAP SDK-backed MCP tool with common error handling.
|
|
655
|
+
*/
|
|
656
|
+
function registerSapTool(server, client, definition) {
|
|
657
|
+
registerTool(server, definition.name, {
|
|
658
|
+
title: definition.title,
|
|
659
|
+
description: definition.description,
|
|
660
|
+
inputSchema: definition.inputSchema,
|
|
661
|
+
}, async (rawInput) => {
|
|
662
|
+
try {
|
|
663
|
+
return ok(await definition.handler(asRecord(rawInput), client));
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
logger.error(`SAP SDK tool failed: ${definition.name}`, { error });
|
|
667
|
+
return createTextResponse(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`, { isError: true });
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
const agentTools = [
|
|
672
|
+
{
|
|
673
|
+
name: 'sap_register_agent',
|
|
674
|
+
title: 'Register SAP Agent',
|
|
675
|
+
description: 'Register the connected wallet as a SAP agent using SDK AgentModule.register.',
|
|
676
|
+
inputSchema: {
|
|
677
|
+
name: { type: 'string', description: 'Human-readable name for the SAP agent' },
|
|
678
|
+
description: { type: 'string', description: 'Detailed description of the agent\'s purpose and capabilities' },
|
|
679
|
+
capabilities: { type: 'array', description: 'Array of capability objects or strings identifying what the agent can do (e.g. "jupiter:swap")' },
|
|
680
|
+
pricing: { type: 'array', description: 'Array of pricing tier objects defining per-call costs, rate limits, and settlement terms' },
|
|
681
|
+
protocols: { type: 'array', items: { type: 'string' }, description: 'Array of protocol identifiers the agent supports (e.g. "jupiter", "drift")' },
|
|
682
|
+
agentId: { type: 'string', description: 'Optional unique agent identifier string' },
|
|
683
|
+
agentUri: { type: 'string', description: 'Optional URI to the agent\'s off-chain metadata or service endpoint' },
|
|
684
|
+
metadataUri: { type: 'string', description: 'Alias for agentUri — URI to off-chain agent metadata JSON' },
|
|
685
|
+
x402Endpoint: { type: 'string', description: 'Optional x402 payment endpoint URL for HTTP-based agent payments' },
|
|
686
|
+
},
|
|
687
|
+
handler: async (input, client) => ({ signature: await client.agent.register(parseRegisterAgentArgs(input)) }),
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: 'sap_update_agent',
|
|
691
|
+
title: 'Update SAP Agent',
|
|
692
|
+
description: 'Update the connected wallet SAP agent using SDK AgentModule.update.',
|
|
693
|
+
inputSchema: { type: 'object', additionalProperties: true, description: 'Object containing any combination of agent fields to update (name, description, capabilities, pricing, protocols, agentId, agentUri, x402Endpoint)' },
|
|
694
|
+
handler: async (input, client) => ({ signature: await client.agent.update(parseUpdateAgentArgs(input)) }),
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
name: 'sap_deactivate_agent',
|
|
698
|
+
title: 'Deactivate SAP Agent',
|
|
699
|
+
description: 'Deactivate the connected wallet SAP agent.',
|
|
700
|
+
inputSchema: {},
|
|
701
|
+
handler: async (_input, client) => ({ signature: await client.agent.deactivate() }),
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
name: 'sap_reactivate_agent',
|
|
705
|
+
title: 'Reactivate SAP Agent',
|
|
706
|
+
description: 'Reactivate the connected wallet SAP agent.',
|
|
707
|
+
inputSchema: {},
|
|
708
|
+
handler: async (_input, client) => ({ signature: await client.agent.reactivate() }),
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
name: 'sap_close_agent',
|
|
712
|
+
title: 'Close SAP Agent',
|
|
713
|
+
description: 'Close the connected wallet SAP agent and reclaim rent.',
|
|
714
|
+
inputSchema: {},
|
|
715
|
+
handler: async (_input, client) => ({ signature: await client.agent.close() }),
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
name: 'sap_report_calls',
|
|
719
|
+
title: 'Report Agent Calls',
|
|
720
|
+
description: 'Report served call count for the connected wallet SAP agent.',
|
|
721
|
+
inputSchema: { callsServed: { type: 'number', description: 'Number of calls served to report for the agent' } },
|
|
722
|
+
handler: async (input, client) => ({ signature: await client.agent.reportCalls(requiredNumber(input, 'callsServed')) }),
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
name: 'sap_update_reputation_metrics',
|
|
726
|
+
title: 'Update Reputation Metrics',
|
|
727
|
+
description: 'Update self-reported latency and uptime metrics for the connected wallet SAP agent.',
|
|
728
|
+
inputSchema: { avgLatencyMs: { type: 'number', description: 'Average response latency in milliseconds to report' }, uptimePercent: { type: 'number', description: 'Uptime percentage (0–100) to report for the agent' } },
|
|
729
|
+
handler: async (input, client) => ({
|
|
730
|
+
signature: await client.agent.updateReputation(requiredNumber(input, 'avgLatencyMs'), requiredNumber(input, 'uptimePercent')),
|
|
731
|
+
}),
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
name: 'sap_get_agent',
|
|
735
|
+
title: 'Get SAP Agent',
|
|
736
|
+
description: 'Fetch agent identity by owner wallet. If omitted, fetches the connected wallet agent.',
|
|
737
|
+
inputSchema: { wallet: { type: 'string', description: 'Solana public key of the agent owner wallet (base58). If omitted, uses the connected wallet.' } },
|
|
738
|
+
handler: async (input, client) => {
|
|
739
|
+
const wallet = optionalPublicKey(input, 'wallet');
|
|
740
|
+
const pda = client.agent.deriveAgent(wallet)[0];
|
|
741
|
+
const agent = await client.agent.fetchNullable(wallet);
|
|
742
|
+
return { agentPda: pda, agent };
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
name: 'sap_get_agent_stats',
|
|
747
|
+
title: 'Get SAP Agent Stats',
|
|
748
|
+
description: 'Fetch agent stats by agent PDA.',
|
|
749
|
+
inputSchema: { agentPda: { type: 'string', description: 'Agent PDA (base58) to fetch stats for' } },
|
|
750
|
+
handler: async (input, client) => ({
|
|
751
|
+
stats: await client.agent.fetchStatsNullable(requiredPublicKey(input, 'agentPda')),
|
|
752
|
+
}),
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: 'sap_get_global_state',
|
|
756
|
+
title: 'Get SAP Global State',
|
|
757
|
+
description: 'Fetch the on-chain global registry through SDK AgentModule.fetchGlobalRegistry.',
|
|
758
|
+
inputSchema: {},
|
|
759
|
+
handler: async (_input, client) => ({ state: await client.agent.fetchGlobalRegistry() }),
|
|
760
|
+
},
|
|
761
|
+
];
|
|
762
|
+
const discoveryTools = [
|
|
763
|
+
{
|
|
764
|
+
name: 'sap_get_network_overview',
|
|
765
|
+
title: 'Get SAP Network Overview',
|
|
766
|
+
description: 'Fetch real network counters from SDK DiscoveryRegistry.getNetworkOverview.',
|
|
767
|
+
inputSchema: {},
|
|
768
|
+
handler: async (_input, client) => ({ overview: await client.discovery.getNetworkOverview() }),
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
name: 'sap_get_agent_profile',
|
|
772
|
+
title: 'Get SAP Agent Profile',
|
|
773
|
+
description: 'Fetch a hydrated SAP agent profile by owner wallet.',
|
|
774
|
+
inputSchema: { wallet: { type: 'string', description: 'Solana public key of the agent owner wallet (base58)' } },
|
|
775
|
+
handler: async (input, client) => ({ profile: await client.discovery.getAgentProfile(requiredPublicKey(input, 'wallet')) }),
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
name: 'sap_is_agent_active',
|
|
779
|
+
title: 'Check SAP Agent Active',
|
|
780
|
+
description: 'Check if a wallet owns an active SAP agent.',
|
|
781
|
+
inputSchema: { wallet: { type: 'string', description: 'Solana public key of the wallet to check for an active SAP agent (base58)' } },
|
|
782
|
+
handler: async (input, client) => ({ active: await client.discovery.isAgentActive(requiredPublicKey(input, 'wallet')) }),
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
name: 'sap_discover_agents',
|
|
786
|
+
title: 'Discover SAP Agents',
|
|
787
|
+
description: 'Discover agents by protocol, capability, or capability list. Unfiltered global listing is not exposed by SDK v0.20.',
|
|
788
|
+
inputSchema: {
|
|
789
|
+
protocol: { type: 'string', description: 'Protocol identifier to filter agents by (e.g. "jupiter", "drift")' },
|
|
790
|
+
capability: { type: 'string', description: 'Single capability ID to filter agents by (e.g. "jupiter:swap")' },
|
|
791
|
+
capabilities: { type: 'array', items: { type: 'string' }, description: 'Array of capability IDs to filter agents by (requires at least one)' },
|
|
792
|
+
hydrate: { type: 'boolean', description: 'Whether to include full hydrated agent profiles in results (default: true)' },
|
|
793
|
+
limit: { type: 'number', description: 'Maximum number of agents to return (default: 50)' },
|
|
794
|
+
},
|
|
795
|
+
handler: async (input, client) => {
|
|
796
|
+
const hydrate = input.hydrate !== false;
|
|
797
|
+
const limit = optionalNumber(input, 'limit') ?? 50;
|
|
798
|
+
const capabilities = Array.isArray(input.capabilities)
|
|
799
|
+
? input.capabilities.filter((item) => typeof item === 'string' && item.length > 0)
|
|
800
|
+
: [];
|
|
801
|
+
const protocol = optionalString(input, 'protocol');
|
|
802
|
+
const capability = optionalString(input, 'capability');
|
|
803
|
+
if (protocol) {
|
|
804
|
+
const agents = await client.discovery.findAgentsByProtocol(protocol, { hydrate });
|
|
805
|
+
return { count: Math.min(agents.length, limit), agents: agents.slice(0, limit) };
|
|
806
|
+
}
|
|
807
|
+
if (capability) {
|
|
808
|
+
const agents = await client.discovery.findAgentsByCapability(capability, { hydrate });
|
|
809
|
+
return { count: Math.min(agents.length, limit), agents: agents.slice(0, limit) };
|
|
810
|
+
}
|
|
811
|
+
if (capabilities.length > 0) {
|
|
812
|
+
const agents = await client.discovery.findAgentsByCapabilities(capabilities, { hydrate });
|
|
813
|
+
return { count: Math.min(agents.length, limit), agents: agents.slice(0, limit) };
|
|
814
|
+
}
|
|
815
|
+
return {
|
|
816
|
+
count: 0,
|
|
817
|
+
agents: [],
|
|
818
|
+
overview: await client.discovery.getNetworkOverview(),
|
|
819
|
+
note: 'SDK v0.20 exposes filtered discovery, not unfiltered global agent enumeration. Provide protocol or capability.',
|
|
820
|
+
};
|
|
821
|
+
},
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
name: 'sap_list_agents',
|
|
825
|
+
title: 'List SAP Agents',
|
|
826
|
+
description: 'Compatibility alias for filtered SAP agent discovery. Requires protocol or capability. Use sap_list_all_agents for a global on-chain directory snapshot.',
|
|
827
|
+
inputSchema: {
|
|
828
|
+
protocol: { type: 'string', description: 'Protocol identifier to filter agents by (e.g. "jupiter", "drift")' },
|
|
829
|
+
capability: { type: 'string', description: 'Single capability ID to filter agents by (e.g. "jupiter:swap")' },
|
|
830
|
+
capabilities: { type: 'array', items: { type: 'string' }, description: 'Array of capability IDs to filter agents by (requires at least one)' },
|
|
831
|
+
hydrate: { type: 'boolean', description: 'Whether to include full hydrated agent profiles in results (default: true)' },
|
|
832
|
+
limit: { type: 'number', description: 'Maximum number of agents to return (default: 50)' },
|
|
833
|
+
},
|
|
834
|
+
handler: async (input, client) => discoveryTools[3].handler(input, client),
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
name: 'sap_list_all_agents',
|
|
838
|
+
title: 'List All SAP Agents',
|
|
839
|
+
description: 'Enumerate SAP AgentAccount PDAs directly from the on-chain program account set. Use this for current global directory requests such as "list all agents in the SAP ecosystem rn".',
|
|
840
|
+
inputSchema: {
|
|
841
|
+
limit: { type: 'number', description: 'Maximum rows to return. Defaults to 100; hard-capped at 500.' },
|
|
842
|
+
offset: { type: 'number', description: 'Zero-based pagination offset. Defaults to 0.' },
|
|
843
|
+
includeInactive: { type: 'boolean', description: 'Include inactive agents. Defaults to false.' },
|
|
844
|
+
protocol: { type: 'string', description: 'Optional protocol filter matched against agent profile protocols and protocol-index membership.' },
|
|
845
|
+
capability: { type: 'string', description: 'Optional capability ID filter such as jupiter:swap.' },
|
|
846
|
+
includeProtocolIndexes: { type: 'boolean', description: 'Include compact protocol index summaries. Defaults to true.' },
|
|
847
|
+
},
|
|
848
|
+
handler: async (input, client) => {
|
|
849
|
+
const limit = Math.max(1, Math.min(optionalNumber(input, 'limit') ?? 100, 500));
|
|
850
|
+
const offset = Math.max(0, optionalNumber(input, 'offset') ?? 0);
|
|
851
|
+
const includeInactive = input.includeInactive === true;
|
|
852
|
+
const includeProtocolIndexes = input.includeProtocolIndexes !== false;
|
|
853
|
+
const protocol = optionalString(input, 'protocol');
|
|
854
|
+
const capability = optionalString(input, 'capability');
|
|
855
|
+
const accounts = getSapAnchorAccounts(client);
|
|
856
|
+
const [agentAccounts, statsAccounts, protocolIndexes, overview] = await Promise.all([
|
|
857
|
+
accounts.agentAccount.all(),
|
|
858
|
+
accounts.agentStats.all(),
|
|
859
|
+
accounts.protocolIndex.all(),
|
|
860
|
+
client.discovery.getNetworkOverview(),
|
|
861
|
+
]);
|
|
862
|
+
const statsByAgent = new Map(statsAccounts.map(({ account }) => [account.agent.toBase58(), account]));
|
|
863
|
+
const indexedProtocolsByAgent = buildProtocolMembership(protocolIndexes);
|
|
864
|
+
const filteredAgents = agentAccounts
|
|
865
|
+
.map((account) => buildAgentDirectoryEntry(account, statsByAgent, indexedProtocolsByAgent))
|
|
866
|
+
.filter((entry) => matchesAgentDirectoryFilters(entry, { includeInactive, protocol, capability }))
|
|
867
|
+
.sort((left, right) => Number(right.createdAt) - Number(left.createdAt));
|
|
868
|
+
const page = filteredAgents.slice(offset, offset + limit);
|
|
869
|
+
return {
|
|
870
|
+
source: 'program.account.agentAccount.all + program.account.protocolIndex.all',
|
|
871
|
+
overview,
|
|
872
|
+
filters: {
|
|
873
|
+
includeInactive,
|
|
874
|
+
protocol: protocol ?? null,
|
|
875
|
+
capability: capability ?? null,
|
|
876
|
+
},
|
|
877
|
+
totalEnumerated: filteredAgents.length,
|
|
878
|
+
totalAgentAccounts: agentAccounts.length,
|
|
879
|
+
activeAgentAccounts: agentAccounts.filter(({ account }) => account.isActive).length,
|
|
880
|
+
returned: page.length,
|
|
881
|
+
offset,
|
|
882
|
+
limit,
|
|
883
|
+
truncated: offset + page.length < filteredAgents.length,
|
|
884
|
+
protocolIndexes: includeProtocolIndexes ? summarizeProtocolIndexes(protocolIndexes) : undefined,
|
|
885
|
+
agents: page,
|
|
886
|
+
note: 'This is global account enumeration, not filtered DiscoveryRegistry lookup. Use sap_discover_agents for protocol/capability search and sap_fetch_protocol_index when you already know a protocol ID.',
|
|
887
|
+
};
|
|
888
|
+
},
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
name: 'sap_find_tools_by_category',
|
|
892
|
+
title: 'Find SAP Tools By Category',
|
|
893
|
+
description: 'Find on-chain tool descriptors by SDK tool category name or numeric category.',
|
|
894
|
+
inputSchema: { category: { type: ['string', 'number'], description: 'Tool category name (e.g. "defi", "infrastructure") or numeric category ID' }, hydrate: { type: 'boolean', description: 'Whether to include full hydrated tool descriptors in results (default: true)' }, limit: { type: 'number', description: 'Maximum number of tools to return (default: 50)' } },
|
|
895
|
+
handler: async (input, client) => {
|
|
896
|
+
const tools = await client.discovery.findToolsByCategory(requiredToolCategory(input), { hydrate: input.hydrate !== false });
|
|
897
|
+
const limit = optionalNumber(input, 'limit') ?? 50;
|
|
898
|
+
return { count: Math.min(tools.length, limit), tools: tools.slice(0, limit) };
|
|
899
|
+
},
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
name: 'sap_get_tool_category_summary',
|
|
903
|
+
title: 'Get SAP Tool Category Summary',
|
|
904
|
+
description: 'Fetch SDK discovery summary across SAP tool categories.',
|
|
905
|
+
inputSchema: {},
|
|
906
|
+
handler: async (_input, client) => ({ categories: await client.discovery.getToolCategorySummary() }),
|
|
907
|
+
},
|
|
908
|
+
];
|
|
909
|
+
const indexAndFetchTools = [
|
|
910
|
+
{
|
|
911
|
+
name: 'sap_fetch_capability_index',
|
|
912
|
+
title: 'Fetch Capability Index',
|
|
913
|
+
description: 'Fetch a SAP capability index by capability ID.',
|
|
914
|
+
inputSchema: { capabilityId: { type: 'string', description: 'Capability ID to fetch the index for (e.g. "jupiter:swap")' } },
|
|
915
|
+
handler: async (input, client) => ({ index: await client.indexing.fetchCapabilityIndexNullable(requiredString(input, 'capabilityId')) }),
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
name: 'sap_fetch_protocol_index',
|
|
919
|
+
title: 'Fetch Protocol Index',
|
|
920
|
+
description: 'Fetch a SAP protocol index by protocol ID.',
|
|
921
|
+
inputSchema: { protocolId: { type: 'string', description: 'Protocol ID to fetch the index for (e.g. "jupiter", "drift")' } },
|
|
922
|
+
handler: async (input, client) => ({ index: await client.indexing.fetchProtocolIndexNullable(requiredString(input, 'protocolId')) }),
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
name: 'sap_fetch_tool_category_index',
|
|
926
|
+
title: 'Fetch Tool Category Index',
|
|
927
|
+
description: 'Fetch a SAP tool category index by numeric category.',
|
|
928
|
+
inputSchema: { category: { type: 'number', description: 'Numeric tool category ID to fetch the index for' } },
|
|
929
|
+
handler: async (input, client) => ({ index: await client.indexing.fetchToolCategoryIndexNullable(requiredNumber(input, 'category')) }),
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
name: 'sap_fetch_tool',
|
|
933
|
+
title: 'Fetch SAP Tool Descriptor',
|
|
934
|
+
description: 'Fetch a tool descriptor by agent PDA and tool name.',
|
|
935
|
+
inputSchema: { agentPda: { type: 'string', description: 'Agent PDA (base58) that owns the tool descriptor' }, toolName: { type: 'string', description: 'Name of the tool descriptor to fetch' } },
|
|
936
|
+
handler: async (input, client) => ({
|
|
937
|
+
tool: await client.tools.fetchNullable(requiredPublicKey(input, 'agentPda'), requiredString(input, 'toolName')),
|
|
938
|
+
}),
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
name: 'sap_fetch_feedback',
|
|
942
|
+
title: 'Fetch SAP Feedback',
|
|
943
|
+
description: 'Fetch a feedback PDA by agent PDA and optional reviewer wallet.',
|
|
944
|
+
inputSchema: { agentPda: { type: 'string', description: 'Agent PDA (base58) to fetch feedback for' }, reviewer: { type: 'string', description: 'Optional reviewer wallet (base58) to filter feedback by' } },
|
|
945
|
+
handler: async (input, client) => ({
|
|
946
|
+
feedback: await client.feedback.fetchNullable(requiredPublicKey(input, 'agentPda'), optionalPublicKey(input, 'reviewer')),
|
|
947
|
+
}),
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
name: 'sap_fetch_attestation',
|
|
951
|
+
title: 'Fetch SAP Attestation',
|
|
952
|
+
description: 'Fetch an attestation PDA by agent PDA and optional attester wallet.',
|
|
953
|
+
inputSchema: { agentPda: { type: 'string', description: 'Agent PDA (base58) to fetch attestation for' }, attester: { type: 'string', description: 'Optional attester wallet (base58) to filter attestation by' } },
|
|
954
|
+
handler: async (input, client) => ({
|
|
955
|
+
attestation: await client.attestation.fetchNullable(requiredPublicKey(input, 'agentPda'), optionalPublicKey(input, 'attester')),
|
|
956
|
+
}),
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
name: 'sap_fetch_escrow',
|
|
960
|
+
title: 'Fetch SAP Escrow V1',
|
|
961
|
+
description: 'Fetch a V1 escrow by escrow PDA, or by agent PDA and optional depositor.',
|
|
962
|
+
inputSchema: { escrowPda: { type: 'string', description: 'Escrow PDA (base58) to fetch directly' }, agentPda: { type: 'string', description: 'Agent PDA (base58) — used when escrowPda is omitted' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58) to filter by' } },
|
|
963
|
+
handler: async (input, client) => ({
|
|
964
|
+
escrow: optionalString(input, 'escrowPda')
|
|
965
|
+
? await client.escrow.fetchByPda(requiredPublicKey(input, 'escrowPda'))
|
|
966
|
+
: await client.escrow.fetchNullable(requiredPublicKey(input, 'agentPda'), optionalPublicKey(input, 'depositor')),
|
|
967
|
+
}),
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
name: 'sap_fetch_escrow_v2',
|
|
971
|
+
title: 'Fetch SAP Escrow V2',
|
|
972
|
+
description: 'Fetch a V2 escrow by escrow PDA, or by agent PDA, depositor, and nonce.',
|
|
973
|
+
inputSchema: { escrowPda: { type: 'string', description: 'Escrow V2 PDA (base58) to fetch directly' }, agentPda: { type: 'string', description: 'Agent PDA (base58) — used when escrowPda is omitted' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58) to filter by' }, nonce: { type: 'number', description: 'Escrow nonce (default: 0) — used with agentPda and depositor' } },
|
|
974
|
+
handler: async (input, client) => ({
|
|
975
|
+
escrow: optionalString(input, 'escrowPda')
|
|
976
|
+
? await client.escrowV2.fetchByPda(requiredPublicKey(input, 'escrowPda'))
|
|
977
|
+
: await client.escrowV2.fetchNullable(requiredPublicKey(input, 'agentPda'), optionalPublicKey(input, 'depositor'), optionalBn(input, 'nonce', new BN(0))),
|
|
978
|
+
}),
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
name: 'sap_fetch_pending_settlement',
|
|
982
|
+
title: 'Fetch Pending Settlement',
|
|
983
|
+
description: 'Fetch a V2 pending settlement PDA.',
|
|
984
|
+
inputSchema: { pendingPda: { type: 'string', description: 'Pending settlement PDA (base58) to fetch' } },
|
|
985
|
+
handler: async (input, client) => ({ pendingSettlement: await client.escrowV2.fetchPendingSettlementNullable(requiredPublicKey(input, 'pendingPda')) }),
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
name: 'sap_fetch_dispute',
|
|
989
|
+
title: 'Fetch SAP Dispute',
|
|
990
|
+
description: 'Fetch a V2 dispute PDA.',
|
|
991
|
+
inputSchema: { disputePda: { type: 'string', description: 'Dispute PDA (base58) to fetch' } },
|
|
992
|
+
handler: async (input, client) => ({ dispute: await client.escrowV2.fetchDisputeNullable(requiredPublicKey(input, 'disputePda')) }),
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
name: 'sap_fetch_vault',
|
|
996
|
+
title: 'Fetch SAP Vault',
|
|
997
|
+
description: 'Fetch a memory vault by agent PDA.',
|
|
998
|
+
inputSchema: { agentPda: { type: 'string', description: 'Agent PDA (base58) to fetch the memory vault for' } },
|
|
999
|
+
handler: async (input, client) => ({ vault: await client.vault.fetchVaultNullable(requiredPublicKey(input, 'agentPda')) }),
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
name: 'sap_fetch_session',
|
|
1003
|
+
title: 'Fetch SAP Session',
|
|
1004
|
+
description: 'Fetch a session ledger by session PDA.',
|
|
1005
|
+
inputSchema: { sessionPda: { type: 'string', description: 'Session PDA (base58) to fetch the ledger for' } },
|
|
1006
|
+
handler: async (input, client) => ({ session: await client.vault.fetchSessionByPda(requiredPublicKey(input, 'sessionPda')) }),
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
name: 'sap_fetch_epoch_page',
|
|
1010
|
+
title: 'Fetch SAP Epoch Page',
|
|
1011
|
+
description: 'Fetch an epoch page by session PDA and epoch index.',
|
|
1012
|
+
inputSchema: { sessionPda: { type: 'string', description: 'Session PDA (base58) to fetch epoch page for' }, epochIndex: { type: 'number', description: 'Zero-based epoch index to fetch' } },
|
|
1013
|
+
handler: async (input, client) => ({
|
|
1014
|
+
epochPage: await client.vault.fetchEpochPage(requiredPublicKey(input, 'sessionPda'), requiredNumber(input, 'epochIndex')),
|
|
1015
|
+
}),
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
name: 'sap_fetch_stake',
|
|
1019
|
+
title: 'Fetch SAP Stake',
|
|
1020
|
+
description: 'Fetch agent stake by stake PDA or agent PDA.',
|
|
1021
|
+
inputSchema: { stakePda: { type: 'string', description: 'Stake PDA (base58) to fetch directly' }, agentPda: { type: 'string', description: 'Agent PDA (base58) — used when stakePda is omitted' } },
|
|
1022
|
+
handler: async (input, client) => ({
|
|
1023
|
+
stake: optionalString(input, 'stakePda')
|
|
1024
|
+
? await client.staking.fetchByPda(requiredPublicKey(input, 'stakePda'))
|
|
1025
|
+
: await client.staking.fetchNullable(requiredPublicKey(input, 'agentPda')),
|
|
1026
|
+
}),
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
name: 'sap_fetch_subscription',
|
|
1030
|
+
title: 'Fetch SAP Subscription',
|
|
1031
|
+
description: 'Fetch a subscription by PDA or by agent PDA/subscriber/subId.',
|
|
1032
|
+
inputSchema: { subscriptionPda: { type: 'string', description: 'Subscription PDA (base58) to fetch directly' }, agentPda: { type: 'string', description: 'Agent PDA (base58) — used when subscriptionPda is omitted' }, subscriber: { type: 'string', description: 'Optional subscriber wallet (base58) to filter by' }, subId: { type: 'number', description: 'Subscription ID (default: 0) — used with agentPda and subscriber' } },
|
|
1033
|
+
handler: async (input, client) => ({
|
|
1034
|
+
subscription: optionalString(input, 'subscriptionPda')
|
|
1035
|
+
? await client.subscription.fetchByPda(requiredPublicKey(input, 'subscriptionPda'))
|
|
1036
|
+
: await client.subscription.fetchNullable(requiredPublicKey(input, 'agentPda'), optionalPublicKey(input, 'subscriber'), optionalBn(input, 'subId', new BN(0))),
|
|
1037
|
+
}),
|
|
1038
|
+
},
|
|
1039
|
+
];
|
|
1040
|
+
const paymentAndEscrowTools = [
|
|
1041
|
+
{
|
|
1042
|
+
name: 'sap_create_escrow',
|
|
1043
|
+
title: 'Create SAP Escrow V1',
|
|
1044
|
+
description: 'Create a V1 escrow using SDK EscrowModule.create.',
|
|
1045
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in lamports (as a decimal string)' }, maxCalls: { type: 'string', description: 'Maximum number of calls the escrow covers (as a decimal string)' }, initialDeposit: { type: 'string', description: 'Initial deposit amount in lamports (as a decimal string)' } },
|
|
1046
|
+
handler: async (input, client) => ({ signature: await client.escrow.create(requiredPublicKey(input, 'agentWallet'), parseEscrowArgs(input)) }),
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
name: 'sap_deposit_escrow',
|
|
1050
|
+
title: 'Deposit SAP Escrow V1',
|
|
1051
|
+
description: 'Deposit funds into a V1 escrow.',
|
|
1052
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, amount: { type: 'string', description: 'Deposit amount in lamports (as a decimal string)' } },
|
|
1053
|
+
handler: async (input, client) => ({ signature: await client.escrow.deposit(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'amount')) }),
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
name: 'sap_settle_escrow',
|
|
1057
|
+
title: 'Settle SAP Escrow V1',
|
|
1058
|
+
description: 'Settle calls against a V1 escrow.',
|
|
1059
|
+
inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, callsToSettle: { type: 'string', description: 'Number of calls to settle (as a decimal string)' }, serviceHash: { type: 'array', description: '32-byte service hash as a byte array, hex string, or base64 string' } },
|
|
1060
|
+
handler: async (input, client) => ({
|
|
1061
|
+
signature: await client.escrow.settle(requiredPublicKey(input, 'depositorWallet'), requiredBn(input, 'callsToSettle'), requiredBytes(input, 'serviceHash', 32)),
|
|
1062
|
+
}),
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
name: 'sap_settle_escrow_batch',
|
|
1066
|
+
title: 'Batch Settle SAP Escrow V1',
|
|
1067
|
+
description: 'Batch settle V1 escrow entries using SDK EscrowModule.settleBatch.',
|
|
1068
|
+
inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, settlements: { type: 'array', description: 'Array of settlement objects, each containing callsToSettle (string) and serviceHash (32-byte array)' }, batchRoot: { type: 'array', description: 'Optional 32-byte Merkle root for batch verification' } },
|
|
1069
|
+
handler: async (input, client) => {
|
|
1070
|
+
if (!Array.isArray(input.settlements)) {
|
|
1071
|
+
throw new Error('settlements must be an array');
|
|
1072
|
+
}
|
|
1073
|
+
return {
|
|
1074
|
+
signature: await client.escrow.settleBatch(requiredPublicKey(input, 'depositorWallet'), input.settlements.map(parseSettlement), input.batchRoot === undefined ? null : requiredBytes(input, 'batchRoot', 32)),
|
|
1075
|
+
};
|
|
1076
|
+
},
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
name: 'sap_withdraw_escrow',
|
|
1080
|
+
title: 'Withdraw SAP Escrow V1',
|
|
1081
|
+
description: 'Withdraw funds from a V1 escrow.',
|
|
1082
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, amount: { type: 'string', description: 'Withdrawal amount in lamports (as a decimal string)' } },
|
|
1083
|
+
handler: async (input, client) => ({ signature: await client.escrow.withdraw(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'amount')) }),
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
name: 'sap_close_escrow',
|
|
1087
|
+
title: 'Close SAP Escrow V1',
|
|
1088
|
+
description: 'Close an empty V1 escrow.',
|
|
1089
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' } },
|
|
1090
|
+
handler: async (input, client) => ({ signature: await client.escrow.close(requiredPublicKey(input, 'agentWallet')) }),
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
name: 'sap_x402_estimate_cost',
|
|
1094
|
+
title: 'Estimate SAP x402 Cost',
|
|
1095
|
+
description: 'Estimate cost for a number of calls using SDK X402Registry.estimateCost. Reads escrow/pricing when available and supports optional volume curve overrides.',
|
|
1096
|
+
inputSchema: {
|
|
1097
|
+
agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' },
|
|
1098
|
+
calls: { type: 'number', description: 'Number of calls to estimate' },
|
|
1099
|
+
pricePerCall: { type: 'string', description: 'Optional base price per call override in token base units' },
|
|
1100
|
+
totalCallsBefore: { type: 'number', description: 'Optional cumulative settled calls before this estimate' },
|
|
1101
|
+
volumeCurve: { type: 'array', description: 'Optional array of { afterCalls, pricePerCall } pricing breakpoints' },
|
|
1102
|
+
},
|
|
1103
|
+
handler: async (input, client) => ({
|
|
1104
|
+
estimate: await client.x402.estimateCost(requiredPublicKey(input, 'agentWallet'), requiredNumber(input, 'calls'), {
|
|
1105
|
+
pricePerCall: input.pricePerCall === undefined ? undefined : requiredBn(input, 'pricePerCall'),
|
|
1106
|
+
volumeCurve: input.volumeCurve === undefined ? undefined : parseVolumeCurve(input.volumeCurve),
|
|
1107
|
+
totalCallsBefore: optionalNumber(input, 'totalCallsBefore'),
|
|
1108
|
+
}),
|
|
1109
|
+
}),
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
name: 'sap_x402_calculate_cost',
|
|
1113
|
+
title: 'Calculate SAP x402 Cost',
|
|
1114
|
+
description: 'Pure local cost calculation using SDK X402Registry.calculateCost; does not read chain state.',
|
|
1115
|
+
inputSchema: {
|
|
1116
|
+
basePrice: { type: 'string', description: 'Base price per call in token base units' },
|
|
1117
|
+
calls: { type: 'number', description: 'Number of calls to calculate' },
|
|
1118
|
+
totalCallsBefore: { type: 'number', description: 'Cumulative settled calls before this calculation (default: 0)' },
|
|
1119
|
+
volumeCurve: { type: 'array', description: 'Array of { afterCalls, pricePerCall } pricing breakpoints' },
|
|
1120
|
+
},
|
|
1121
|
+
handler: async (input, client) => ({
|
|
1122
|
+
estimate: client.x402.calculateCost(requiredBn(input, 'basePrice'), parseVolumeCurve(input.volumeCurve), optionalNumber(input, 'totalCallsBefore') ?? 0, requiredNumber(input, 'calls')),
|
|
1123
|
+
}),
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
name: 'sap_x402_prepare_payment',
|
|
1127
|
+
title: 'Prepare SAP x402 Payment V1 Deprecated',
|
|
1128
|
+
description: 'Prepare a V1 x402 payment context using SDK X402Registry.preparePayment. Deprecated by the SDK for production escrow creation; prefer Escrow V2 tools for new flows.',
|
|
1129
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call as a decimal string' }, deposit: { type: 'string', description: 'Initial deposit amount as a decimal string' }, maxCalls: { type: 'string', description: 'Optional maximum number of calls covered' }, expiresAt: { type: 'string', description: 'Optional expiry timestamp in unix seconds' }, volumeCurve: { type: 'array', description: 'Optional array of { afterCalls, pricePerCall } pricing breakpoints' }, tokenMint: { type: 'string', description: 'Optional SPL token mint; omit/null for SOL' }, tokenDecimals: { type: 'number', description: 'Optional token decimals' }, networkIdentifier: { type: 'string', description: 'Optional x402 network identifier written into headers' } },
|
|
1130
|
+
handler: async (input, client) => ({
|
|
1131
|
+
payment: await client.x402.preparePayment(requiredPublicKey(input, 'agentWallet'), parseX402PreparePaymentOptions(input)),
|
|
1132
|
+
}),
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
name: 'sap_x402_build_payment_headers',
|
|
1136
|
+
title: 'Build SAP x402 Payment Headers',
|
|
1137
|
+
description: 'Build SAP x402 HTTP headers from a public PaymentContext returned by sap_x402_prepare_payment.',
|
|
1138
|
+
inputSchema: { escrowPda: { type: 'string', description: 'Escrow PDA (base58)' }, agentPda: { type: 'string', description: 'Agent PDA (base58)' }, agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in token base units' }, maxCalls: { type: 'string', description: 'Max calls as a decimal string' }, txSignature: { type: 'string', description: 'Escrow creation transaction signature' }, networkIdentifier: { type: 'string', description: 'x402 network identifier stored in the payment context' }, network: { type: 'string', description: 'Optional override for X-Payment-Network' } },
|
|
1139
|
+
handler: async (input, client) => ({
|
|
1140
|
+
headers: client.x402.buildPaymentHeaders(parsePaymentContext(input), { network: optionalString(input, 'network') }),
|
|
1141
|
+
}),
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
name: 'sap_x402_build_headers_from_escrow',
|
|
1145
|
+
title: 'Build SAP x402 Headers From Escrow',
|
|
1146
|
+
description: 'Build SAP x402 HTTP headers by fetching escrow data for an agent wallet with SDK X402Registry.buildPaymentHeadersFromEscrow.',
|
|
1147
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, network: { type: 'string', description: 'Optional network identifier for X-Payment-Network' } },
|
|
1148
|
+
handler: async (input, client) => ({
|
|
1149
|
+
headers: await client.x402.buildPaymentHeadersFromEscrow(requiredPublicKey(input, 'agentWallet'), {
|
|
1150
|
+
network: optionalString(input, 'network'),
|
|
1151
|
+
}),
|
|
1152
|
+
}),
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
name: 'sap_x402_has_escrow',
|
|
1156
|
+
title: 'Check SAP x402 Escrow',
|
|
1157
|
+
description: 'Check whether an x402 escrow exists for an agent/depositor pair.',
|
|
1158
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58); defaults to caller in SDK' } },
|
|
1159
|
+
handler: async (input, client) => ({ exists: await client.x402.hasEscrow(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor')) }),
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
name: 'sap_x402_fetch_escrow',
|
|
1163
|
+
title: 'Fetch SAP x402 Escrow',
|
|
1164
|
+
description: 'Fetch raw x402 escrow account data using SDK X402Registry.fetchEscrow. Resolves V2 first, then V1 fallback.',
|
|
1165
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58); defaults to caller in SDK' } },
|
|
1166
|
+
handler: async (input, client) => ({ escrow: await client.x402.fetchEscrow(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor')) }),
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
name: 'sap_x402_get_balance',
|
|
1170
|
+
title: 'Get SAP x402 Balance',
|
|
1171
|
+
description: 'Fetch x402 escrow balance using SDK X402Registry.getBalance.',
|
|
1172
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositor: { type: 'string', description: 'Optional depositor wallet (base58) to filter balance by' } },
|
|
1173
|
+
handler: async (input, client) => ({ balance: await client.x402.getBalance(requiredPublicKey(input, 'agentWallet'), optionalPublicKey(input, 'depositor')) }),
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
name: 'sap_x402_settle',
|
|
1177
|
+
title: 'Settle SAP x402 Calls',
|
|
1178
|
+
description: 'Settle served x402 calls through SDK X402Registry.settle. Must be called by the agent owner wallet.',
|
|
1179
|
+
inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, callsToSettle: { type: 'number', description: 'Number of calls to settle' }, serviceData: { type: 'string', description: 'Service data to hash into the settlement proof' }, priorityFeeMicroLamports: { type: 'number', description: 'Optional priority fee in microlamports per compute unit' }, computeUnits: { type: 'number', description: 'Optional compute-unit limit' }, skipPreflight: { type: 'boolean', description: 'Optional skip preflight flag' }, commitment: { type: 'string', description: 'Optional processed|confirmed|finalized commitment' }, maxRetries: { type: 'number', description: 'Optional RPC retry limit' } },
|
|
1180
|
+
handler: async (input, client) => ({
|
|
1181
|
+
settlement: await client.x402.settle(requiredPublicKey(input, 'depositorWallet'), requiredNumber(input, 'callsToSettle'), requiredString(input, 'serviceData'), parseSettleOptions(input)),
|
|
1182
|
+
}),
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
name: 'sap_x402_settle_batch',
|
|
1186
|
+
title: 'Batch Settle SAP x402 Calls',
|
|
1187
|
+
description: 'Batch-settle served x402 calls through SDK X402Registry.settleBatch. Must be called by the agent owner wallet.',
|
|
1188
|
+
inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, entries: { type: 'array', description: 'Array of { calls, serviceData } settlement entries' }, priorityFeeMicroLamports: { type: 'number', description: 'Optional priority fee in microlamports per compute unit' }, computeUnits: { type: 'number', description: 'Optional compute-unit limit' }, skipPreflight: { type: 'boolean', description: 'Optional skip preflight flag' }, commitment: { type: 'string', description: 'Optional processed|confirmed|finalized commitment' }, maxRetries: { type: 'number', description: 'Optional RPC retry limit' } },
|
|
1189
|
+
handler: async (input, client) => ({
|
|
1190
|
+
settlement: await client.x402.settleBatch(requiredPublicKey(input, 'depositorWallet'), parseX402BatchSettlementEntries(input.entries), parseSettleOptions(input)),
|
|
1191
|
+
}),
|
|
1192
|
+
},
|
|
1193
|
+
];
|
|
1194
|
+
const escrowV2Tools = [
|
|
1195
|
+
{
|
|
1196
|
+
name: 'sap_create_escrow_v2',
|
|
1197
|
+
title: 'Create SAP Escrow V2',
|
|
1198
|
+
description: 'Create a V2 escrow using SDK EscrowV2Module.create.',
|
|
1199
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, pricePerCall: { type: 'string', description: 'Price per call in lamports (as a decimal string)' }, maxCalls: { type: 'string', description: 'Maximum number of calls the escrow covers (as a decimal string)' }, initialDeposit: { type: 'string', description: 'Initial deposit amount in lamports (as a decimal string)' } },
|
|
1200
|
+
handler: async (input, client) => ({ signature: await client.escrowV2.create(requiredPublicKey(input, 'agentWallet'), parseEscrowV2Args(input)) }),
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
name: 'sap_deposit_escrow_v2',
|
|
1204
|
+
title: 'Deposit SAP Escrow V2',
|
|
1205
|
+
description: 'Deposit funds into a V2 escrow.',
|
|
1206
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, amount: { type: 'string', description: 'Deposit amount in lamports (as a decimal string)' } },
|
|
1207
|
+
handler: async (input, client) => ({ signature: await client.escrowV2.deposit(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'amount')) }),
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
name: 'sap_settle_escrow_v2',
|
|
1211
|
+
title: 'Settle SAP Escrow V2',
|
|
1212
|
+
description: 'Settle calls against a V2 escrow.',
|
|
1213
|
+
inputSchema: { depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, callsToSettle: { type: 'string', description: 'Number of calls to settle (as a decimal string)' }, serviceHash: { type: 'array', description: '32-byte service hash as a byte array, hex string, or base64 string' } },
|
|
1214
|
+
handler: async (input, client) => ({
|
|
1215
|
+
signature: await client.escrowV2.settle(requiredPublicKey(input, 'depositorWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'callsToSettle'), requiredBytes(input, 'serviceHash', 32)),
|
|
1216
|
+
}),
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
name: 'sap_next_settlement_index',
|
|
1220
|
+
title: 'Get Next Settlement Index',
|
|
1221
|
+
description: 'Read the next V2 settlement index.',
|
|
1222
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' } },
|
|
1223
|
+
handler: async (input, client) => ({
|
|
1224
|
+
settlementIndex: await client.escrowV2.nextSettlementIndex(requiredPublicKey(input, 'agentWallet'), requiredPublicKey(input, 'depositorWallet'), optionalBn(input, 'nonce', new BN(0))),
|
|
1225
|
+
}),
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
name: 'sap_finalize_settlement_v2',
|
|
1229
|
+
title: 'Finalize SAP Escrow V2 Settlement',
|
|
1230
|
+
description: 'Finalize a V2 pending settlement.',
|
|
1231
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, depositorWallet: { type: 'string', description: 'Depositor wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, settlementIndex: { type: 'string', description: 'Settlement index to finalize (as a decimal string)' } },
|
|
1232
|
+
handler: async (input, client) => ({
|
|
1233
|
+
signature: await client.escrowV2.finalizeSettlement(requiredPublicKey(input, 'agentWallet'), requiredPublicKey(input, 'depositorWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'settlementIndex')),
|
|
1234
|
+
}),
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
name: 'sap_file_dispute_v2',
|
|
1238
|
+
title: 'File SAP Escrow V2 Dispute',
|
|
1239
|
+
description: 'File a dispute for a V2 pending settlement.',
|
|
1240
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, settlementIndex: { type: 'string', description: 'Settlement index to dispute (as a decimal string)' }, evidenceHash: { type: 'array', description: '32-byte evidence hash as a byte array, hex string, or base64 string' }, disputeType: { type: 'number', description: 'Optional dispute type identifier (numeric)' } },
|
|
1241
|
+
handler: async (input, client) => ({
|
|
1242
|
+
signature: await client.escrowV2.fileDispute(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'settlementIndex'), requiredBytes(input, 'evidenceHash', 32), optionalNumber(input, 'disputeType')),
|
|
1243
|
+
}),
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: 'sap_withdraw_escrow_v2',
|
|
1247
|
+
title: 'Withdraw SAP Escrow V2',
|
|
1248
|
+
description: 'Withdraw funds from a V2 escrow.',
|
|
1249
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' }, amount: { type: 'string', description: 'Withdrawal amount in lamports (as a decimal string)' } },
|
|
1250
|
+
handler: async (input, client) => ({ signature: await client.escrowV2.withdraw(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0)), requiredBn(input, 'amount')) }),
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
name: 'sap_close_escrow_v2',
|
|
1254
|
+
title: 'Close SAP Escrow V2',
|
|
1255
|
+
description: 'Close a V2 escrow.',
|
|
1256
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, nonce: { type: 'string', description: 'Escrow nonce (as a decimal string, default: 0)' } },
|
|
1257
|
+
handler: async (input, client) => ({ signature: await client.escrowV2.close(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'nonce', new BN(0))) }),
|
|
1258
|
+
},
|
|
1259
|
+
];
|
|
1260
|
+
const reputationAndTrustTools = [
|
|
1261
|
+
{
|
|
1262
|
+
name: 'sap_give_feedback',
|
|
1263
|
+
title: 'Give SAP Feedback',
|
|
1264
|
+
description: 'Create on-chain feedback for an agent wallet.',
|
|
1265
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to give feedback for' }, score: { type: 'number', description: 'Feedback score (numeric, e.g. 1–5)' }, tag: { type: 'string', description: 'Optional feedback tag/category (default: "general")' }, commentHash: { type: 'array', description: 'Optional 32-byte comment hash as a byte array, hex string, or base64 string' } },
|
|
1266
|
+
handler: async (input, client) => ({ signature: await client.feedback.give(requiredPublicKey(input, 'agentWallet'), parseFeedbackArgs(input)) }),
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
name: 'sap_update_feedback',
|
|
1270
|
+
title: 'Update SAP Feedback',
|
|
1271
|
+
description: 'Update existing on-chain feedback for an agent wallet.',
|
|
1272
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to update feedback for' }, score: { type: 'number', description: 'New feedback score (numeric, e.g. 1–5)' }, tag: { type: 'string', description: 'Optional new feedback tag/category' }, commentHash: { type: 'array', description: 'Optional 32-byte comment hash as a byte array, hex string, or base64 string' } },
|
|
1273
|
+
handler: async (input, client) => ({ signature: await client.feedback.update(requiredPublicKey(input, 'agentWallet'), parseUpdateFeedbackArgs(input)) }),
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
name: 'sap_revoke_feedback',
|
|
1277
|
+
title: 'Revoke SAP Feedback',
|
|
1278
|
+
description: 'Revoke feedback for an agent wallet.',
|
|
1279
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to revoke feedback for' } },
|
|
1280
|
+
handler: async (input, client) => ({ signature: await client.feedback.revoke(requiredPublicKey(input, 'agentWallet')) }),
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
name: 'sap_create_attestation',
|
|
1284
|
+
title: 'Create SAP Attestation',
|
|
1285
|
+
description: 'Create an on-chain attestation for an agent wallet.',
|
|
1286
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to create attestation for' }, attestationType: { type: 'string', description: 'Optional attestation type string (default: "generic")' }, metadataHash: { type: 'array', description: '32-byte metadata hash as a byte array, hex string, or base64 string' }, expiresAt: { type: 'string', description: 'Optional expiry timestamp (as a decimal string, 0 = no expiry)' } },
|
|
1287
|
+
handler: async (input, client) => ({ signature: await client.attestation.create(requiredPublicKey(input, 'agentWallet'), parseAttestationArgs(input)) }),
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
name: 'sap_revoke_attestation',
|
|
1291
|
+
title: 'Revoke SAP Attestation',
|
|
1292
|
+
description: 'Revoke attestation for an agent wallet.',
|
|
1293
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to revoke attestation for' } },
|
|
1294
|
+
handler: async (input, client) => ({ signature: await client.attestation.revoke(requiredPublicKey(input, 'agentWallet')) }),
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
name: 'sap_fairscale_score',
|
|
1298
|
+
title: 'Get FairScale Score',
|
|
1299
|
+
description: 'Score an agent with SDK FairScaleRegistry.score.',
|
|
1300
|
+
inputSchema: { agent: { type: 'string', description: 'Agent PDA or wallet (base58) to score' }, task: { type: 'string', description: 'Optional FairScale task type: one of "defi_execution", "trust_focused", "work_focused", "hiring"' } },
|
|
1301
|
+
handler: async (input, client) => ({ score: await client.fairscale.score(requiredString(input, 'agent'), { task: optionalFairScaleTask(input, 'task') }) }),
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
name: 'sap_fairscale_trust_gate',
|
|
1305
|
+
title: 'FairScale Trust Gate',
|
|
1306
|
+
description: 'Evaluate an agent with SDK FairScaleRegistry.trustGate.',
|
|
1307
|
+
inputSchema: { agent: { type: 'string', description: 'Agent PDA or wallet (base58) to evaluate' }, minScore: { type: 'number', description: 'Optional minimum trust score threshold' }, requireVerification: { type: 'boolean', description: 'Whether verified status is required to pass the gate (default: false)' } },
|
|
1308
|
+
handler: async (input, client) => ({
|
|
1309
|
+
result: await client.fairscale.trustGate(requiredString(input, 'agent'), {
|
|
1310
|
+
minScore: optionalNumber(input, 'minScore'),
|
|
1311
|
+
requireVerification: input.requireVerification === true,
|
|
1312
|
+
}),
|
|
1313
|
+
}),
|
|
1314
|
+
},
|
|
1315
|
+
];
|
|
1316
|
+
const vaultSessionTools = [
|
|
1317
|
+
{
|
|
1318
|
+
name: 'sap_init_vault',
|
|
1319
|
+
title: 'Initialize SAP Vault',
|
|
1320
|
+
description: 'Initialize a memory vault for the connected agent.',
|
|
1321
|
+
inputSchema: { vaultNonce: { type: 'array', description: 'Vault nonce as a byte array, hex string, or base64 string' } },
|
|
1322
|
+
handler: async (input, client) => ({ signature: await client.vault.initVault(requiredBytes(input, 'vaultNonce')) }),
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
name: 'sap_open_vault_session',
|
|
1326
|
+
title: 'Open SAP Vault Session',
|
|
1327
|
+
description: 'Open a vault session by 32-byte session hash.',
|
|
1328
|
+
inputSchema: { sessionHash: { type: 'array', description: '32-byte session hash as a byte array, hex string, or base64 string' } },
|
|
1329
|
+
handler: async (input, client) => ({ signature: await client.vault.openSession(requiredBytes(input, 'sessionHash', 32)) }),
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
name: 'sap_inscribe_memory',
|
|
1333
|
+
title: 'Inscribe SAP Memory',
|
|
1334
|
+
description: 'Inscribe encrypted memory using SDK VaultModule.inscribe.',
|
|
1335
|
+
inputSchema: { type: 'object', additionalProperties: true, description: 'Object containing memory inscription fields: sequence (number), encryptedData (byte array), nonce (byte array), contentHash (32-byte array), and optional totalFragments, fragmentIndex, compression, epochIndex' },
|
|
1336
|
+
handler: async (input, client) => ({ signature: await client.vault.inscribe(parseMemoryArgs(input)) }),
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
name: 'sap_compact_inscribe_memory',
|
|
1340
|
+
title: 'Compact Inscribe SAP Memory',
|
|
1341
|
+
description: 'Compact memory inscription with explicit vault/session PDAs.',
|
|
1342
|
+
inputSchema: { sessionPda: { type: 'string', description: 'Session PDA (base58) for the memory inscription' }, vaultPda: { type: 'string', description: 'Vault PDA (base58) for the memory inscription' }, encryptedData: { type: 'array', description: 'Encrypted memory data as a byte array, hex string, or base64 string' }, nonce: { type: 'array', description: 'Encryption nonce as a byte array, hex string, or base64 string' }, contentHash: { type: 'array', description: '32-byte content hash as a byte array, hex string, or base64 string' } },
|
|
1343
|
+
handler: async (input, client) => ({
|
|
1344
|
+
signature: await client.vault.compactInscribe(requiredPublicKey(input, 'sessionPda'), requiredPublicKey(input, 'vaultPda'), parseCompactMemoryArgs(input)),
|
|
1345
|
+
}),
|
|
1346
|
+
},
|
|
1347
|
+
{
|
|
1348
|
+
name: 'sap_session_start',
|
|
1349
|
+
title: 'Start SAP Memory Session',
|
|
1350
|
+
description: 'Start a high-level SDK session by session ID.',
|
|
1351
|
+
inputSchema: { sessionId: { type: 'string', description: 'High-level session identifier string' }, vaultNonce: { type: 'array', description: 'Optional vault nonce as a byte array, hex string, or base64 string' } },
|
|
1352
|
+
handler: async (input, client) => ({
|
|
1353
|
+
session: await client.session.start(requiredString(input, 'sessionId'), optionalBytes(input, 'vaultNonce', [])),
|
|
1354
|
+
}),
|
|
1355
|
+
},
|
|
1356
|
+
{
|
|
1357
|
+
name: 'sap_session_read_latest',
|
|
1358
|
+
title: 'Read Latest SAP Session Entries',
|
|
1359
|
+
description: 'Read latest entries from a high-level SDK session ID.',
|
|
1360
|
+
inputSchema: { sessionId: { type: 'string', description: 'High-level session identifier string to read latest entries from' } },
|
|
1361
|
+
handler: async (input, client) => {
|
|
1362
|
+
const ctx = client.session.deriveContext(requiredString(input, 'sessionId'));
|
|
1363
|
+
return { entries: await client.session.readLatest(ctx) };
|
|
1364
|
+
},
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
name: 'sap_session_status',
|
|
1368
|
+
title: 'Get SAP Session Status',
|
|
1369
|
+
description: 'Fetch high-level SDK session status by session ID.',
|
|
1370
|
+
inputSchema: { sessionId: { type: 'string', description: 'High-level session identifier string to get status for' } },
|
|
1371
|
+
handler: async (input, client) => {
|
|
1372
|
+
const ctx = client.session.deriveContext(requiredString(input, 'sessionId'));
|
|
1373
|
+
return { status: await client.session.getStatus(ctx) };
|
|
1374
|
+
},
|
|
1375
|
+
},
|
|
1376
|
+
];
|
|
1377
|
+
const toolRegistryTools = [
|
|
1378
|
+
{
|
|
1379
|
+
name: 'sap_publish_tool_by_name',
|
|
1380
|
+
title: 'Publish SAP Tool By Name',
|
|
1381
|
+
description: 'Publish a tool descriptor using SDK ToolsModule.publishByName.',
|
|
1382
|
+
inputSchema: {
|
|
1383
|
+
toolName: { type: 'string', description: 'Name of the tool to publish' },
|
|
1384
|
+
protocolId: { type: 'string', description: 'Protocol ID the tool belongs to (e.g. "jupiter")' },
|
|
1385
|
+
description: { type: 'string', description: 'Human-readable description of the tool' },
|
|
1386
|
+
inputSchemaJson: { type: 'string', description: 'JSON string of the tool input schema' },
|
|
1387
|
+
outputSchemaJson: { type: 'string', description: 'JSON string of the tool output schema' },
|
|
1388
|
+
httpMethod: { type: 'number', description: 'HTTP method code (e.g. 0=GET, 1=POST)' },
|
|
1389
|
+
category: { type: 'number', description: 'Numeric tool category ID' },
|
|
1390
|
+
paramsCount: { type: 'number', description: 'Total number of parameters the tool accepts' },
|
|
1391
|
+
requiredParams: { type: 'number', description: 'Number of required parameters' },
|
|
1392
|
+
isCompound: { type: 'boolean', description: 'Whether the tool is a compound tool (default: false)' },
|
|
1393
|
+
},
|
|
1394
|
+
handler: async (input, client) => ({
|
|
1395
|
+
signature: await client.tools.publishByName(requiredString(input, 'toolName'), requiredString(input, 'protocolId'), requiredString(input, 'description'), requiredString(input, 'inputSchemaJson'), requiredString(input, 'outputSchemaJson'), requiredNumber(input, 'httpMethod'), requiredNumber(input, 'category'), requiredNumber(input, 'paramsCount'), requiredNumber(input, 'requiredParams'), input.isCompound === true),
|
|
1396
|
+
}),
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
name: 'sap_update_tool',
|
|
1400
|
+
title: 'Update SAP Tool',
|
|
1401
|
+
description: 'Update tool descriptor hashes using SDK ToolsModule.update.',
|
|
1402
|
+
inputSchema: { toolName: { type: 'string', description: 'Name of the tool to update' }, type: 'object', additionalProperties: true, description: 'Object containing optional update fields: descriptionHash, inputSchemaHash, outputSchemaHash (32-byte arrays), httpMethod, category, paramsCount, requiredParams (numbers)' },
|
|
1403
|
+
handler: async (input, client) => ({ signature: await client.tools.update(requiredString(input, 'toolName'), parseUpdateToolArgs(input)) }),
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
name: 'sap_deactivate_tool',
|
|
1407
|
+
title: 'Deactivate SAP Tool',
|
|
1408
|
+
description: 'Deactivate a SAP tool descriptor by name.',
|
|
1409
|
+
inputSchema: { toolName: { type: 'string', description: 'Name of the tool descriptor to deactivate' } },
|
|
1410
|
+
handler: async (input, client) => ({ signature: await client.tools.deactivate(requiredString(input, 'toolName')) }),
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
name: 'sap_reactivate_tool',
|
|
1414
|
+
title: 'Reactivate SAP Tool',
|
|
1415
|
+
description: 'Reactivate a SAP tool descriptor by name.',
|
|
1416
|
+
inputSchema: { toolName: { type: 'string', description: 'Name of the tool descriptor to reactivate' } },
|
|
1417
|
+
handler: async (input, client) => ({ signature: await client.tools.reactivate(requiredString(input, 'toolName')) }),
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
name: 'sap_report_tool_invocations',
|
|
1421
|
+
title: 'Report SAP Tool Invocations',
|
|
1422
|
+
description: 'Report invocation count for a SAP tool descriptor.',
|
|
1423
|
+
inputSchema: { toolName: { type: 'string', description: 'Name of the tool descriptor to report invocations for' }, invocations: { type: 'number', description: 'Number of invocations to report' } },
|
|
1424
|
+
handler: async (input, client) => ({
|
|
1425
|
+
signature: await client.tools.reportInvocations(requiredString(input, 'toolName'), requiredNumber(input, 'invocations')),
|
|
1426
|
+
}),
|
|
1427
|
+
},
|
|
1428
|
+
];
|
|
1429
|
+
const stakingAndSubscriptionTools = [
|
|
1430
|
+
{
|
|
1431
|
+
name: 'sap_init_stake',
|
|
1432
|
+
title: 'Initialize SAP Stake',
|
|
1433
|
+
description: 'Initialize stake for an agent wallet.',
|
|
1434
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to initialize stake for' }, initialDeposit: { type: 'string', description: 'Initial stake deposit amount in lamports (as a decimal string)' } },
|
|
1435
|
+
handler: async (input, client) => ({ signature: await client.staking.initStake(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'initialDeposit')) }),
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
name: 'sap_deposit_stake',
|
|
1439
|
+
title: 'Deposit SAP Stake',
|
|
1440
|
+
description: 'Deposit additional stake for an agent wallet.',
|
|
1441
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, amount: { type: 'string', description: 'Additional stake deposit amount in lamports (as a decimal string)' } },
|
|
1442
|
+
handler: async (input, client) => ({ signature: await client.staking.deposit(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'amount')) }),
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
name: 'sap_request_unstake',
|
|
1446
|
+
title: 'Request SAP Unstake',
|
|
1447
|
+
description: 'Request unstake for an agent wallet.',
|
|
1448
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, amount: { type: 'string', description: 'Unstake request amount in lamports (as a decimal string)' } },
|
|
1449
|
+
handler: async (input, client) => ({ signature: await client.staking.requestUnstake(requiredPublicKey(input, 'agentWallet'), requiredBn(input, 'amount')) }),
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
name: 'sap_complete_unstake',
|
|
1453
|
+
title: 'Complete SAP Unstake',
|
|
1454
|
+
description: 'Complete unstake for an agent wallet.',
|
|
1455
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to complete unstaking for' } },
|
|
1456
|
+
handler: async (input, client) => ({ signature: await client.staking.completeUnstake(requiredPublicKey(input, 'agentWallet')) }),
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
name: 'sap_create_subscription',
|
|
1460
|
+
title: 'Create SAP Subscription',
|
|
1461
|
+
description: 'Create a recurring subscription for an agent wallet.',
|
|
1462
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58) to create subscription for' }, subId: { type: 'string', description: 'Subscription ID (as a decimal string, default: 0)' }, pricePerInterval: { type: 'string', description: 'Price per billing interval in lamports (as a decimal string)' }, billingInterval: { type: 'number', description: 'Billing interval in seconds between charges' }, initialFund: { type: 'string', description: 'Initial fund amount in lamports (as a decimal string)' } },
|
|
1463
|
+
handler: async (input, client) => ({ signature: await client.subscription.create(requiredPublicKey(input, 'agentWallet'), parseSubscriptionArgs(input)) }),
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
name: 'sap_fund_subscription',
|
|
1467
|
+
title: 'Fund SAP Subscription',
|
|
1468
|
+
description: 'Fund a recurring subscription.',
|
|
1469
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, subId: { type: 'string', description: 'Subscription ID (as a decimal string, default: 0)' }, amount: { type: 'string', description: 'Funding amount in lamports (as a decimal string)' } },
|
|
1470
|
+
handler: async (input, client) => ({
|
|
1471
|
+
signature: await client.subscription.fund(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'subId', new BN(0)), requiredBn(input, 'amount')),
|
|
1472
|
+
}),
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
name: 'sap_cancel_subscription',
|
|
1476
|
+
title: 'Cancel SAP Subscription',
|
|
1477
|
+
description: 'Cancel a recurring subscription.',
|
|
1478
|
+
inputSchema: { agentWallet: { type: 'string', description: 'Agent wallet public key (base58)' }, subId: { type: 'string', description: 'Subscription ID (as a decimal string, default: 0)' } },
|
|
1479
|
+
handler: async (input, client) => ({
|
|
1480
|
+
signature: await client.subscription.cancel(requiredPublicKey(input, 'agentWallet'), optionalBn(input, 'subId', new BN(0))),
|
|
1481
|
+
}),
|
|
1482
|
+
},
|
|
1483
|
+
];
|
|
1484
|
+
const sapToolGroups = [
|
|
1485
|
+
agentTools,
|
|
1486
|
+
discoveryTools,
|
|
1487
|
+
indexAndFetchTools,
|
|
1488
|
+
paymentAndEscrowTools,
|
|
1489
|
+
escrowV2Tools,
|
|
1490
|
+
reputationAndTrustTools,
|
|
1491
|
+
vaultSessionTools,
|
|
1492
|
+
toolRegistryTools,
|
|
1493
|
+
stakingAndSubscriptionTools,
|
|
1494
|
+
];
|
|
1495
|
+
/**
|
|
1496
|
+
* @name registerSapSdkTools
|
|
1497
|
+
* @description Registers production SAP SDK-backed tools using the public SDK v0.20 client surface.
|
|
1498
|
+
*/
|
|
1499
|
+
export function registerSapSdkTools(server, _context) {
|
|
1500
|
+
logger.info('Registering SAP SDK tools');
|
|
1501
|
+
if (!isSapClientInitialized()) {
|
|
1502
|
+
logger.warn('SAP client not initialized - skipping SDK tools');
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
const client = getSapClient();
|
|
1506
|
+
let count = 0;
|
|
1507
|
+
for (const group of sapToolGroups) {
|
|
1508
|
+
for (const tool of group) {
|
|
1509
|
+
registerSapTool(server, client, tool);
|
|
1510
|
+
count++;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
logger.info('SAP SDK tools registered', { count });
|
|
1514
|
+
}
|
|
1515
|
+
//# sourceMappingURL=sap-sdk-tools.js.map
|