@oobe-protocol-labs/sap-mcp-server 0.9.2 → 0.9.3
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 +8 -7
- package/CHANGELOG.md +731 -0
- package/README.md +9 -3
- package/USER_DOCS/00_START_HERE.md +51 -4
- package/USER_DOCS/01_HOSTED_REMOTE_MCP.md +1 -1
- package/USER_DOCS/03_PAYMENTS_X402_PAYSH.md +32 -3
- package/USER_DOCS/04_CLIENT_CONFIGS.md +14 -7
- package/USER_DOCS/05_SKILLS_AND_TOOLS.md +68 -8
- package/USER_DOCS/06_DESKTOP_GUI_WIZARD.md +20 -14
- package/USER_DOCS/07_SMITHERY_AND_MARKETPLACES.md +7 -0
- package/config.example.json +5 -4
- package/config.schema.json +9 -4
- package/config.secure-example.json +5 -4
- package/dist/adapters/index.d.ts +7 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +7 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/mcp/errors.d.ts +13 -1
- package/dist/adapters/mcp/errors.d.ts.map +1 -1
- package/dist/adapters/mcp/errors.js +13 -1
- package/dist/adapters/mcp/errors.js.map +1 -1
- package/dist/adapters/mcp/index.d.ts +7 -1
- package/dist/adapters/mcp/index.d.ts.map +1 -1
- package/dist/adapters/mcp/index.js +7 -1
- package/dist/adapters/mcp/index.js.map +1 -1
- package/dist/adapters/mcp/prompt-response.d.ts +13 -1
- package/dist/adapters/mcp/prompt-response.d.ts.map +1 -1
- package/dist/adapters/mcp/prompt-response.js +13 -1
- package/dist/adapters/mcp/prompt-response.js.map +1 -1
- package/dist/adapters/mcp/resource-response.d.ts +14 -1
- package/dist/adapters/mcp/resource-response.d.ts.map +1 -1
- package/dist/adapters/mcp/resource-response.js +14 -1
- package/dist/adapters/mcp/resource-response.js.map +1 -1
- package/dist/adapters/mcp/sdk-compat.d.ts +11 -3
- package/dist/adapters/mcp/sdk-compat.d.ts.map +1 -1
- package/dist/adapters/mcp/sdk-compat.js +232 -25
- package/dist/adapters/mcp/sdk-compat.js.map +1 -1
- package/dist/adapters/mcp/tool-response.d.ts +51 -3
- package/dist/adapters/mcp/tool-response.d.ts.map +1 -1
- package/dist/adapters/mcp/tool-response.js +48 -3
- package/dist/adapters/mcp/tool-response.js.map +1 -1
- package/dist/adapters/solana/commitment.d.ts +14 -2
- package/dist/adapters/solana/commitment.d.ts.map +1 -1
- package/dist/adapters/solana/commitment.js +14 -2
- package/dist/adapters/solana/commitment.js.map +1 -1
- package/dist/adapters/solana/connection.d.ts +11 -2
- package/dist/adapters/solana/connection.d.ts.map +1 -1
- package/dist/adapters/solana/connection.js +11 -2
- package/dist/adapters/solana/connection.js.map +1 -1
- package/dist/adapters/solana/index.d.ts +7 -1
- package/dist/adapters/solana/index.d.ts.map +1 -1
- package/dist/adapters/solana/index.js +7 -1
- package/dist/adapters/solana/index.js.map +1 -1
- package/dist/adapters/solana/public-key.d.ts +11 -2
- package/dist/adapters/solana/public-key.d.ts.map +1 -1
- package/dist/adapters/solana/public-key.js +11 -2
- package/dist/adapters/solana/public-key.js.map +1 -1
- package/dist/config/defaults.d.ts +5 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +5 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/env.d.ts +4 -0
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +15 -10
- package/dist/config/env.js.map +1 -1
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/mcp-client-injection.d.ts.map +1 -1
- package/dist/config/mcp-client-injection.js +136 -33
- package/dist/config/mcp-client-injection.js.map +1 -1
- package/dist/config/paths.d.ts +14 -1
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +20 -1
- package/dist/config/paths.js.map +1 -1
- package/dist/config/profiles.d.ts +3 -10
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +5 -0
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/schema.d.ts +5 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +5 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/secure-config.d.ts +5 -0
- package/dist/config/secure-config.d.ts.map +1 -1
- package/dist/config/secure-config.js +5 -0
- package/dist/config/secure-config.js.map +1 -1
- package/dist/config/setup.d.ts +5 -0
- package/dist/config/setup.d.ts.map +1 -1
- package/dist/config/setup.js +5 -0
- package/dist/config/setup.js.map +1 -1
- package/dist/config/wizard.d.ts +6 -0
- package/dist/config/wizard.d.ts.map +1 -1
- package/dist/config/wizard.js +102 -18
- package/dist/config/wizard.js.map +1 -1
- package/dist/config-cli.d.ts +3 -13
- package/dist/config-cli.d.ts.map +1 -1
- package/dist/config-cli.js +14 -1
- package/dist/config-cli.js.map +1 -1
- package/dist/core/constants.d.ts +33 -6
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +38 -8
- package/dist/core/constants.js.map +1 -1
- package/dist/core/errors.d.ts +5 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +5 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/guards.d.ts +5 -0
- package/dist/core/guards.d.ts.map +1 -1
- package/dist/core/guards.js +3 -1
- package/dist/core/guards.js.map +1 -1
- package/dist/core/index.d.ts +7 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.js +1 -1
- package/dist/core/result.d.ts +77 -9
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/result.js +68 -9
- package/dist/core/result.js.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +3 -4
- package/dist/core/types.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/async-processor.d.ts +107 -0
- package/dist/memory/async-processor.d.ts.map +1 -0
- package/dist/memory/async-processor.js +204 -0
- package/dist/memory/async-processor.js.map +1 -0
- package/dist/memory/auto-record.d.ts +47 -0
- package/dist/memory/auto-record.d.ts.map +1 -0
- package/dist/memory/auto-record.js +133 -0
- package/dist/memory/auto-record.js.map +1 -0
- package/dist/memory/database.d.ts +103 -0
- package/dist/memory/database.d.ts.map +1 -0
- package/dist/memory/database.js +337 -0
- package/dist/memory/database.js.map +1 -0
- package/dist/memory/hermes-bridge.d.ts +70 -0
- package/dist/memory/hermes-bridge.d.ts.map +1 -0
- package/dist/memory/hermes-bridge.js +155 -0
- package/dist/memory/hermes-bridge.js.map +1 -0
- package/dist/memory/index.d.ts +23 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +22 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory-store.d.ts +76 -0
- package/dist/memory/memory-store.d.ts.map +1 -0
- package/dist/memory/memory-store.js +231 -0
- package/dist/memory/memory-store.js.map +1 -0
- package/dist/memory/stream-buffer-store.d.ts +69 -0
- package/dist/memory/stream-buffer-store.d.ts.map +1 -0
- package/dist/memory/stream-buffer-store.js +182 -0
- package/dist/memory/stream-buffer-store.js.map +1 -0
- package/dist/memory/tool-call-store.d.ts +68 -0
- package/dist/memory/tool-call-store.d.ts.map +1 -0
- package/dist/memory/tool-call-store.js +189 -0
- package/dist/memory/tool-call-store.js.map +1 -0
- package/dist/memory/types.d.ts +197 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +15 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/memory/utils.d.ts +30 -0
- package/dist/memory/utils.d.ts.map +1 -0
- package/dist/memory/utils.js +47 -0
- package/dist/memory/utils.js.map +1 -0
- package/dist/payments/facilitator-rpc-fallback.d.ts.map +1 -1
- package/dist/payments/facilitator-rpc-fallback.js +95 -0
- package/dist/payments/facilitator-rpc-fallback.js.map +1 -1
- package/dist/payments/hosted-tool-eligibility.d.ts +22 -0
- package/dist/payments/hosted-tool-eligibility.d.ts.map +1 -0
- package/dist/payments/hosted-tool-eligibility.js +173 -0
- package/dist/payments/hosted-tool-eligibility.js.map +1 -0
- package/dist/payments/index.d.ts +2 -2
- package/dist/payments/index.d.ts.map +1 -1
- package/dist/payments/index.js +1 -1
- package/dist/payments/index.js.map +1 -1
- package/dist/payments/mcp-session-cache.d.ts +35 -0
- package/dist/payments/mcp-session-cache.d.ts.map +1 -0
- package/dist/payments/mcp-session-cache.js +83 -0
- package/dist/payments/mcp-session-cache.js.map +1 -0
- package/dist/payments/monetization-gate.d.ts +33 -0
- package/dist/payments/monetization-gate.d.ts.map +1 -1
- package/dist/payments/monetization-gate.js +124 -12
- package/dist/payments/monetization-gate.js.map +1 -1
- package/dist/payments/pricing.d.ts +31 -0
- package/dist/payments/pricing.d.ts.map +1 -1
- package/dist/payments/pricing.js +317 -19
- package/dist/payments/pricing.js.map +1 -1
- package/dist/payments/usage-ledger.d.ts +36 -2
- package/dist/payments/usage-ledger.d.ts.map +1 -1
- package/dist/payments/usage-ledger.js +121 -4
- package/dist/payments/usage-ledger.js.map +1 -1
- package/dist/payments/x402-paid-call.d.ts +121 -0
- package/dist/payments/x402-paid-call.d.ts.map +1 -1
- package/dist/payments/x402-paid-call.js +428 -1
- package/dist/payments/x402-paid-call.js.map +1 -1
- package/dist/policy/default-policies.d.ts +18 -2
- package/dist/policy/default-policies.d.ts.map +1 -1
- package/dist/policy/default-policies.js +18 -2
- package/dist/policy/default-policies.js.map +1 -1
- package/dist/policy/index.d.ts +6 -3
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +6 -3
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/local-policy-engine.d.ts +71 -13
- package/dist/policy/local-policy-engine.d.ts.map +1 -1
- package/dist/policy/local-policy-engine.js +33 -11
- package/dist/policy/local-policy-engine.js.map +1 -1
- package/dist/policy/permission-checks.d.ts +29 -3
- package/dist/policy/permission-checks.d.ts.map +1 -1
- package/dist/policy/permission-checks.js +29 -3
- package/dist/policy/permission-checks.js.map +1 -1
- package/dist/policy/policy-engine.d.ts +22 -2
- package/dist/policy/policy-engine.d.ts.map +1 -1
- package/dist/policy/policy-engine.js +22 -2
- package/dist/policy/policy-engine.js.map +1 -1
- package/dist/policy/policy-types.d.ts +55 -5
- package/dist/policy/policy-types.d.ts.map +1 -1
- package/dist/policy/policy-types.js +8 -1
- package/dist/policy/policy-types.js.map +1 -1
- package/dist/policy/risk-level.d.ts +32 -3
- package/dist/policy/risk-level.d.ts.map +1 -1
- package/dist/policy/risk-level.js +32 -3
- package/dist/policy/risk-level.js.map +1 -1
- package/dist/policy/spending-limits.d.ts +29 -3
- package/dist/policy/spending-limits.d.ts.map +1 -1
- package/dist/policy/spending-limits.js +29 -3
- package/dist/policy/spending-limits.js.map +1 -1
- package/dist/premium/activation-manager.d.ts +43 -0
- package/dist/premium/activation-manager.d.ts.map +1 -0
- package/dist/premium/activation-manager.js +131 -0
- package/dist/premium/activation-manager.js.map +1 -0
- package/dist/premium/builtin-plugins.d.ts +165 -0
- package/dist/premium/builtin-plugins.d.ts.map +1 -0
- package/dist/premium/builtin-plugins.js +422 -0
- package/dist/premium/builtin-plugins.js.map +1 -0
- package/dist/premium/event-store.d.ts +61 -0
- package/dist/premium/event-store.d.ts.map +1 -0
- package/dist/premium/event-store.js +130 -0
- package/dist/premium/event-store.js.map +1 -0
- package/dist/premium/index.d.ts +54 -0
- package/dist/premium/index.d.ts.map +1 -0
- package/dist/premium/index.js +54 -0
- package/dist/premium/index.js.map +1 -0
- package/dist/premium/manifest-builder.d.ts +65 -0
- package/dist/premium/manifest-builder.d.ts.map +1 -0
- package/dist/premium/manifest-builder.js +182 -0
- package/dist/premium/manifest-builder.js.map +1 -0
- package/dist/premium/meme-radar-capabilities.d.ts +38 -0
- package/dist/premium/meme-radar-capabilities.d.ts.map +1 -0
- package/dist/premium/meme-radar-capabilities.js +306 -0
- package/dist/premium/meme-radar-capabilities.js.map +1 -0
- package/dist/premium/metrics.d.ts +27 -0
- package/dist/premium/metrics.d.ts.map +1 -0
- package/dist/premium/metrics.js +65 -0
- package/dist/premium/metrics.js.map +1 -0
- package/dist/premium/plugin-validator.d.ts +39 -0
- package/dist/premium/plugin-validator.d.ts.map +1 -0
- package/dist/premium/plugin-validator.js +325 -0
- package/dist/premium/plugin-validator.js.map +1 -0
- package/dist/premium/private-manifest-loader.d.ts +111 -0
- package/dist/premium/private-manifest-loader.d.ts.map +1 -0
- package/dist/premium/private-manifest-loader.js +285 -0
- package/dist/premium/private-manifest-loader.js.map +1 -0
- package/dist/premium/provider-bridge.d.ts +133 -0
- package/dist/premium/provider-bridge.d.ts.map +1 -0
- package/dist/premium/provider-bridge.js +349 -0
- package/dist/premium/provider-bridge.js.map +1 -0
- package/dist/premium/session-manager.d.ts +125 -0
- package/dist/premium/session-manager.d.ts.map +1 -0
- package/dist/premium/session-manager.js +337 -0
- package/dist/premium/session-manager.js.map +1 -0
- package/dist/premium/stream-broker.d.ts +98 -0
- package/dist/premium/stream-broker.d.ts.map +1 -0
- package/dist/premium/stream-broker.js +199 -0
- package/dist/premium/stream-broker.js.map +1 -0
- package/dist/premium/tech-fundamentals-capabilities.d.ts +37 -0
- package/dist/premium/tech-fundamentals-capabilities.d.ts.map +1 -0
- package/dist/premium/tech-fundamentals-capabilities.js +283 -0
- package/dist/premium/tech-fundamentals-capabilities.js.map +1 -0
- package/dist/premium/trading-capabilities.d.ts +36 -0
- package/dist/premium/trading-capabilities.d.ts.map +1 -0
- package/dist/premium/trading-capabilities.js +205 -0
- package/dist/premium/trading-capabilities.js.map +1 -0
- package/dist/premium/types.d.ts +518 -0
- package/dist/premium/types.d.ts.map +1 -0
- package/dist/premium/types.js +23 -0
- package/dist/premium/types.js.map +1 -0
- package/dist/premium/webhook-engine.d.ts +138 -0
- package/dist/premium/webhook-engine.d.ts.map +1 -0
- package/dist/premium/webhook-engine.js +516 -0
- package/dist/premium/webhook-engine.js.map +1 -0
- package/dist/prompts/context/sap-agent-context.prompt.d.ts +5 -0
- package/dist/prompts/context/sap-agent-context.prompt.d.ts.map +1 -1
- package/dist/prompts/context/sap-agent-context.prompt.js +20 -16
- package/dist/prompts/context/sap-agent-context.prompt.js.map +1 -1
- package/dist/prompts/context/sap-agent-intent-router.prompt.d.ts +14 -0
- package/dist/prompts/context/sap-agent-intent-router.prompt.d.ts.map +1 -0
- package/dist/prompts/context/sap-agent-intent-router.prompt.js +155 -0
- package/dist/prompts/context/sap-agent-intent-router.prompt.js.map +1 -0
- package/dist/prompts/context/sap-agent-start.prompt.js +7 -0
- package/dist/prompts/context/sap-agent-start.prompt.js.map +1 -1
- package/dist/prompts/developer/debug-sap-error.prompt.d.ts +5 -0
- package/dist/prompts/developer/debug-sap-error.prompt.d.ts.map +1 -1
- package/dist/prompts/developer/debug-sap-error.prompt.js +3 -4
- package/dist/prompts/developer/debug-sap-error.prompt.js.map +1 -1
- package/dist/prompts/developer/generate-sap-integration.prompt.d.ts +5 -0
- package/dist/prompts/developer/generate-sap-integration.prompt.d.ts.map +1 -1
- package/dist/prompts/developer/generate-sap-integration.prompt.js +3 -4
- package/dist/prompts/developer/generate-sap-integration.prompt.js.map +1 -1
- package/dist/prompts/developer/index.d.ts +4 -1
- package/dist/prompts/developer/index.d.ts.map +1 -1
- package/dist/prompts/developer/index.js +4 -1
- package/dist/prompts/developer/index.js.map +1 -1
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.d.ts +5 -0
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.d.ts.map +1 -1
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.js +3 -4
- package/dist/prompts/execution-proof/explain-proof-of-execution.prompt.js.map +1 -1
- package/dist/prompts/execution-proof/index.d.ts +4 -1
- package/dist/prompts/execution-proof/index.d.ts.map +1 -1
- package/dist/prompts/execution-proof/index.js +4 -1
- package/dist/prompts/execution-proof/index.js.map +1 -1
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.d.ts +5 -0
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.d.ts.map +1 -1
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.js +3 -4
- package/dist/prompts/execution-proof/verify-execution-proof.prompt.js.map +1 -1
- package/dist/prompts/index.d.ts +4 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +4 -1
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/payments/create-paid-api.prompt.d.ts +5 -0
- package/dist/prompts/payments/create-paid-api.prompt.d.ts.map +1 -1
- package/dist/prompts/payments/create-paid-api.prompt.js +3 -4
- package/dist/prompts/payments/create-paid-api.prompt.js.map +1 -1
- package/dist/prompts/payments/explain-x402-settlement.prompt.d.ts +5 -0
- package/dist/prompts/payments/explain-x402-settlement.prompt.d.ts.map +1 -1
- package/dist/prompts/payments/explain-x402-settlement.prompt.js +4 -5
- package/dist/prompts/payments/explain-x402-settlement.prompt.js.map +1 -1
- package/dist/prompts/payments/index.d.ts +4 -1
- package/dist/prompts/payments/index.d.ts.map +1 -1
- package/dist/prompts/payments/index.js +4 -1
- package/dist/prompts/payments/index.js.map +1 -1
- package/dist/prompts/register-prompts.d.ts +18 -2
- package/dist/prompts/register-prompts.d.ts.map +1 -1
- package/dist/prompts/register-prompts.js +21 -3
- package/dist/prompts/register-prompts.js.map +1 -1
- package/dist/prompts/registry/analyze-sap-agent.prompt.d.ts +5 -0
- package/dist/prompts/registry/analyze-sap-agent.prompt.d.ts.map +1 -1
- package/dist/prompts/registry/analyze-sap-agent.prompt.js +3 -4
- package/dist/prompts/registry/analyze-sap-agent.prompt.js.map +1 -1
- package/dist/prompts/registry/index.d.ts +4 -1
- package/dist/prompts/registry/index.d.ts.map +1 -1
- package/dist/prompts/registry/index.js +4 -1
- package/dist/prompts/registry/index.js.map +1 -1
- package/dist/prompts/registry/register-sap-agent.prompt.d.ts +5 -0
- package/dist/prompts/registry/register-sap-agent.prompt.d.ts.map +1 -1
- package/dist/prompts/registry/register-sap-agent.prompt.js +22 -23
- package/dist/prompts/registry/register-sap-agent.prompt.js.map +1 -1
- package/dist/remote/premium-memory.d.ts +90 -0
- package/dist/remote/premium-memory.d.ts.map +1 -0
- package/dist/remote/premium-memory.js +161 -0
- package/dist/remote/premium-memory.js.map +1 -0
- package/dist/remote/premium-routes.d.ts +99 -0
- package/dist/remote/premium-routes.d.ts.map +1 -0
- package/dist/remote/premium-routes.js +347 -0
- package/dist/remote/premium-routes.js.map +1 -0
- package/dist/remote/public-home/sections.d.ts.map +1 -1
- package/dist/remote/public-home/sections.js +23 -4
- package/dist/remote/public-home/sections.js.map +1 -1
- package/dist/remote/public-home/types.d.ts +9 -0
- package/dist/remote/public-home/types.d.ts.map +1 -1
- package/dist/remote/server.d.ts +20 -0
- package/dist/remote/server.d.ts.map +1 -1
- package/dist/remote/server.js +369 -8
- package/dist/remote/server.js.map +1 -1
- package/dist/remote/tx-relay.d.ts +42 -0
- package/dist/remote/tx-relay.d.ts.map +1 -0
- package/dist/remote/tx-relay.js +118 -0
- package/dist/remote/tx-relay.js.map +1 -0
- package/dist/resources/current/sap-current-config.resource.d.ts +5 -0
- package/dist/resources/current/sap-current-config.resource.d.ts.map +1 -1
- package/dist/resources/current/sap-current-config.resource.js +2 -5
- package/dist/resources/current/sap-current-config.resource.js.map +1 -1
- package/dist/resources/execution-proof/index.d.ts +5 -0
- package/dist/resources/execution-proof/index.d.ts.map +1 -1
- package/dist/resources/execution-proof/index.js +5 -0
- package/dist/resources/execution-proof/index.js.map +1 -1
- package/dist/resources/execution-proof/sap-execution-record.resource.d.ts +5 -0
- package/dist/resources/execution-proof/sap-execution-record.resource.d.ts.map +1 -1
- package/dist/resources/execution-proof/sap-execution-record.resource.js +3 -4
- package/dist/resources/execution-proof/sap-execution-record.resource.js.map +1 -1
- package/dist/resources/index.d.ts +5 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +5 -0
- package/dist/resources/index.js.map +1 -1
- package/dist/resources/memory/index.d.ts +5 -0
- package/dist/resources/memory/index.d.ts.map +1 -1
- package/dist/resources/memory/index.js +5 -0
- package/dist/resources/memory/index.js.map +1 -1
- package/dist/resources/memory/sap-memory.resource.d.ts +5 -0
- package/dist/resources/memory/sap-memory.resource.d.ts.map +1 -1
- package/dist/resources/memory/sap-memory.resource.js +3 -4
- package/dist/resources/memory/sap-memory.resource.js.map +1 -1
- package/dist/resources/profile/sap-active-profile.resource.d.ts +5 -0
- package/dist/resources/profile/sap-active-profile.resource.d.ts.map +1 -1
- package/dist/resources/profile/sap-active-profile.resource.js +2 -5
- package/dist/resources/profile/sap-active-profile.resource.js.map +1 -1
- package/dist/resources/register-resources.d.ts +5 -0
- package/dist/resources/register-resources.d.ts.map +1 -1
- package/dist/resources/register-resources.js +3 -1
- package/dist/resources/register-resources.js.map +1 -1
- package/dist/resources/registry/index.d.ts +5 -0
- package/dist/resources/registry/index.d.ts.map +1 -1
- package/dist/resources/registry/index.js +5 -0
- package/dist/resources/registry/index.js.map +1 -1
- package/dist/resources/registry/sap-agent.resource.d.ts +5 -0
- package/dist/resources/registry/sap-agent.resource.d.ts.map +1 -1
- package/dist/resources/registry/sap-agent.resource.js +3 -4
- package/dist/resources/registry/sap-agent.resource.js.map +1 -1
- package/dist/resources/registry/sap-global-registry.resource.d.ts +18 -4
- package/dist/resources/registry/sap-global-registry.resource.d.ts.map +1 -1
- package/dist/resources/registry/sap-global-registry.resource.js +18 -4
- package/dist/resources/registry/sap-global-registry.resource.js.map +1 -1
- package/dist/resources/reputation/index.d.ts +4 -1
- package/dist/resources/reputation/index.d.ts.map +1 -1
- package/dist/resources/reputation/index.js +4 -1
- package/dist/resources/reputation/index.js.map +1 -1
- package/dist/resources/reputation/sap-reputation.resource.d.ts +18 -4
- package/dist/resources/reputation/sap-reputation.resource.d.ts.map +1 -1
- package/dist/resources/reputation/sap-reputation.resource.js +18 -4
- package/dist/resources/reputation/sap-reputation.resource.js.map +1 -1
- package/dist/resources/tool-schema/index.d.ts +4 -1
- package/dist/resources/tool-schema/index.d.ts.map +1 -1
- package/dist/resources/tool-schema/index.js +4 -1
- package/dist/resources/tool-schema/index.js.map +1 -1
- package/dist/resources/tool-schema/sap-tool-schema.resource.d.ts +18 -4
- package/dist/resources/tool-schema/sap-tool-schema.resource.d.ts.map +1 -1
- package/dist/resources/tool-schema/sap-tool-schema.resource.js +18 -4
- package/dist/resources/tool-schema/sap-tool-schema.resource.js.map +1 -1
- package/dist/sap/index.d.ts +7 -1
- package/dist/sap/index.d.ts.map +1 -1
- package/dist/sap/index.js +7 -1
- package/dist/sap/index.js.map +1 -1
- package/dist/sap/sap-client-manager.d.ts +80 -13
- package/dist/sap/sap-client-manager.d.ts.map +1 -1
- package/dist/sap/sap-client-manager.js +80 -13
- package/dist/sap/sap-client-manager.js.map +1 -1
- package/dist/sap/sap-errors.d.ts +22 -3
- package/dist/sap/sap-errors.d.ts.map +1 -1
- package/dist/sap/sap-errors.js +22 -3
- package/dist/sap/sap-errors.js.map +1 -1
- package/dist/sap/sap-types.d.ts +75 -6
- package/dist/sap/sap-types.d.ts.map +1 -1
- package/dist/sap/sap-types.js +11 -1
- package/dist/sap/sap-types.js.map +1 -1
- package/dist/schemas/common.schema.d.ts +45 -8
- package/dist/schemas/common.schema.d.ts.map +1 -1
- package/dist/schemas/common.schema.js +45 -8
- package/dist/schemas/common.schema.js.map +1 -1
- package/dist/schemas/developer.schema.d.ts +22 -3
- package/dist/schemas/developer.schema.d.ts.map +1 -1
- package/dist/schemas/developer.schema.js +22 -3
- package/dist/schemas/developer.schema.js.map +1 -1
- package/dist/schemas/execution-proof.schema.d.ts +29 -4
- package/dist/schemas/execution-proof.schema.d.ts.map +1 -1
- package/dist/schemas/execution-proof.schema.js +29 -4
- package/dist/schemas/execution-proof.schema.js.map +1 -1
- package/dist/schemas/identity.schema.d.ts +23 -3
- package/dist/schemas/identity.schema.d.ts.map +1 -1
- package/dist/schemas/identity.schema.js +23 -3
- package/dist/schemas/identity.schema.js.map +1 -1
- package/dist/schemas/index.d.ts +11 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +11 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/memory.schema.d.ts +23 -3
- package/dist/schemas/memory.schema.d.ts.map +1 -1
- package/dist/schemas/memory.schema.js +23 -3
- package/dist/schemas/memory.schema.js.map +1 -1
- package/dist/schemas/payments.schema.d.ts +24 -3
- package/dist/schemas/payments.schema.d.ts.map +1 -1
- package/dist/schemas/payments.schema.js +24 -3
- package/dist/schemas/payments.schema.js.map +1 -1
- package/dist/schemas/registry.schema.d.ts +38 -6
- package/dist/schemas/registry.schema.d.ts.map +1 -1
- package/dist/schemas/registry.schema.js +36 -4
- package/dist/schemas/registry.schema.js.map +1 -1
- package/dist/schemas/reputation.schema.d.ts +22 -3
- package/dist/schemas/reputation.schema.d.ts.map +1 -1
- package/dist/schemas/reputation.schema.js +22 -3
- package/dist/schemas/reputation.schema.js.map +1 -1
- package/dist/schemas/settlement.schema.d.ts +31 -4
- package/dist/schemas/settlement.schema.d.ts.map +1 -1
- package/dist/schemas/settlement.schema.js +31 -4
- package/dist/schemas/settlement.schema.js.map +1 -1
- package/dist/schemas/tool-schema.schema.d.ts +29 -3
- package/dist/schemas/tool-schema.schema.d.ts.map +1 -1
- package/dist/schemas/tool-schema.schema.js +29 -3
- package/dist/schemas/tool-schema.schema.js.map +1 -1
- package/dist/schemas/transaction.schema.d.ts +23 -3
- package/dist/schemas/transaction.schema.d.ts.map +1 -1
- package/dist/schemas/transaction.schema.js +23 -3
- package/dist/schemas/transaction.schema.js.map +1 -1
- package/dist/security/approval-required.d.ts +19 -2
- package/dist/security/approval-required.d.ts.map +1 -1
- package/dist/security/approval-required.js +19 -2
- package/dist/security/approval-required.js.map +1 -1
- package/dist/security/index.d.ts +7 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +7 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/private-key-guard.d.ts +18 -2
- package/dist/security/private-key-guard.d.ts.map +1 -1
- package/dist/security/private-key-guard.js +19 -2
- package/dist/security/private-key-guard.js.map +1 -1
- package/dist/security/prompt-injection-notes.d.ts +10 -1
- package/dist/security/prompt-injection-notes.d.ts.map +1 -1
- package/dist/security/prompt-injection-notes.js +10 -1
- package/dist/security/prompt-injection-notes.js.map +1 -1
- package/dist/security/tool-permissions.d.ts.map +1 -1
- package/dist/security/tool-permissions.js +12 -0
- package/dist/security/tool-permissions.js.map +1 -1
- package/dist/security/unsafe-action-guard.d.ts +36 -10
- package/dist/security/unsafe-action-guard.d.ts.map +1 -1
- package/dist/security/unsafe-action-guard.js +67 -15
- package/dist/security/unsafe-action-guard.js.map +1 -1
- package/dist/server/create-server.d.ts +18 -3
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +18 -3
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/index.d.ts +6 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/register-capabilities.d.ts +17 -2
- package/dist/server/register-capabilities.d.ts.map +1 -1
- package/dist/server/register-capabilities.js +17 -2
- package/dist/server/register-capabilities.js.map +1 -1
- package/dist/server/server-metadata.d.ts +35 -1
- package/dist/server/server-metadata.d.ts.map +1 -1
- package/dist/server/server-metadata.js +36 -2
- package/dist/server/server-metadata.js.map +1 -1
- package/dist/session/agent-session.d.ts +35 -4
- package/dist/session/agent-session.d.ts.map +1 -1
- package/dist/session/agent-session.js +35 -4
- package/dist/session/agent-session.js.map +1 -1
- package/dist/session/delegated-session.d.ts +31 -3
- package/dist/session/delegated-session.d.ts.map +1 -1
- package/dist/session/delegated-session.js +31 -3
- package/dist/session/delegated-session.js.map +1 -1
- package/dist/session/index.d.ts +7 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +7 -1
- package/dist/session/index.js.map +1 -1
- package/dist/session/redis-session-store.d.ts +94 -21
- package/dist/session/redis-session-store.d.ts.map +1 -1
- package/dist/session/redis-session-store.js +87 -20
- package/dist/session/redis-session-store.js.map +1 -1
- package/dist/session/session-limits.d.ts +34 -4
- package/dist/session/session-limits.d.ts.map +1 -1
- package/dist/session/session-limits.js +34 -4
- package/dist/session/session-limits.js.map +1 -1
- package/dist/session/session-permissions.d.ts +57 -7
- package/dist/session/session-permissions.d.ts.map +1 -1
- package/dist/session/session-permissions.js +57 -7
- package/dist/session/session-permissions.js.map +1 -1
- package/dist/session/session-store.d.ts +9 -1
- package/dist/session/session-store.d.ts.map +1 -1
- package/dist/session/session-store.js +18 -3
- package/dist/session/session-store.js.map +1 -1
- package/dist/session/session-types.d.ts +33 -4
- package/dist/session/session-types.d.ts.map +1 -1
- package/dist/session/session-types.js +9 -1
- package/dist/session/session-types.js.map +1 -1
- package/dist/signer/index.d.ts +7 -1
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +7 -1
- package/dist/signer/index.js.map +1 -1
- package/dist/signer/load-keypair.d.ts +25 -4
- package/dist/signer/load-keypair.d.ts.map +1 -1
- package/dist/signer/load-keypair.js +25 -4
- package/dist/signer/load-keypair.js.map +1 -1
- package/dist/signer/local-keypair-signer.d.ts +19 -3
- package/dist/signer/local-keypair-signer.d.ts.map +1 -1
- package/dist/signer/local-keypair-signer.js +24 -4
- package/dist/signer/local-keypair-signer.js.map +1 -1
- package/dist/signer/signer-resolver.d.ts +19 -2
- package/dist/signer/signer-resolver.d.ts.map +1 -1
- package/dist/signer/signer-resolver.js +26 -3
- package/dist/signer/signer-resolver.js.map +1 -1
- package/dist/signer/signer-types.d.ts +47 -5
- package/dist/signer/signer-types.d.ts.map +1 -1
- package/dist/signer/signer-types.js +13 -1
- package/dist/signer/signer-types.js.map +1 -1
- package/dist/strategies/strategy-store.d.ts +82 -0
- package/dist/strategies/strategy-store.d.ts.map +1 -0
- package/dist/strategies/strategy-store.js +165 -0
- package/dist/strategies/strategy-store.js.map +1 -0
- package/dist/tools/agent-start-tool.d.ts.map +1 -1
- package/dist/tools/agent-start-tool.js +481 -5
- package/dist/tools/agent-start-tool.js.map +1 -1
- package/dist/tools/client-sdk-tools.d.ts.map +1 -1
- package/dist/tools/client-sdk-tools.js +32 -7
- package/dist/tools/client-sdk-tools.js.map +1 -1
- package/dist/tools/estimate-tool-cost.d.ts +13 -0
- package/dist/tools/estimate-tool-cost.d.ts.map +1 -0
- package/dist/tools/estimate-tool-cost.js +139 -0
- package/dist/tools/estimate-tool-cost.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +11 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/magicblock-tools.d.ts +31 -6
- package/dist/tools/magicblock-tools.d.ts.map +1 -1
- package/dist/tools/magicblock-tools.js +178 -53
- package/dist/tools/magicblock-tools.js.map +1 -1
- package/dist/tools/memory-tools.d.ts +26 -0
- package/dist/tools/memory-tools.d.ts.map +1 -0
- package/dist/tools/memory-tools.js +533 -0
- package/dist/tools/memory-tools.js.map +1 -0
- package/dist/tools/perp-tools.d.ts +39 -0
- package/dist/tools/perp-tools.d.ts.map +1 -0
- package/dist/tools/perp-tools.js +1110 -0
- package/dist/tools/perp-tools.js.map +1 -0
- package/dist/tools/premium-tools.d.ts +8 -0
- package/dist/tools/premium-tools.d.ts.map +1 -0
- package/dist/tools/premium-tools.js +1102 -0
- package/dist/tools/premium-tools.js.map +1 -0
- package/dist/tools/profile-tools.d.ts.map +1 -1
- package/dist/tools/profile-tools.js +18 -1
- package/dist/tools/profile-tools.js.map +1 -1
- package/dist/tools/quick-context-tool.d.ts +16 -0
- package/dist/tools/quick-context-tool.d.ts.map +1 -0
- package/dist/tools/quick-context-tool.js +304 -0
- package/dist/tools/quick-context-tool.js.map +1 -0
- package/dist/tools/register-tools.d.ts.map +1 -1
- package/dist/tools/register-tools.js +17 -0
- package/dist/tools/register-tools.js.map +1 -1
- package/dist/tools/sap-sdk-tools.d.ts +419 -0
- package/dist/tools/sap-sdk-tools.d.ts.map +1 -1
- package/dist/tools/sap-sdk-tools.js +1547 -126
- package/dist/tools/sap-sdk-tools.js.map +1 -1
- package/dist/tools/sap-sns-tools.d.ts +2 -2
- package/dist/tools/sap-sns-tools.d.ts.map +1 -1
- package/dist/tools/sap-sns-tools.js +12 -8
- package/dist/tools/sap-sns-tools.js.map +1 -1
- package/dist/tools/skills-tools.d.ts +16 -0
- package/dist/tools/skills-tools.d.ts.map +1 -1
- package/dist/tools/skills-tools.js +282 -5
- package/dist/tools/skills-tools.js.map +1 -1
- package/dist/tools/tool-aliases.d.ts.map +1 -1
- package/dist/tools/tool-aliases.js +7 -0
- package/dist/tools/tool-aliases.js.map +1 -1
- package/dist/tools/transaction-tools.d.ts +135 -0
- package/dist/tools/transaction-tools.d.ts.map +1 -1
- package/dist/tools/transaction-tools.js +515 -16
- package/dist/tools/transaction-tools.js.map +1 -1
- package/dist/tools/x402-paid-call-tool.d.ts.map +1 -1
- package/dist/tools/x402-paid-call-tool.js +756 -23
- package/dist/tools/x402-paid-call-tool.js.map +1 -1
- package/dist/transports/index.d.ts +6 -1
- package/dist/transports/index.d.ts.map +1 -1
- package/dist/transports/index.js +6 -1
- package/dist/transports/index.js.map +1 -1
- package/dist/transports/stdio.d.ts +17 -5
- package/dist/transports/stdio.d.ts.map +1 -1
- package/dist/transports/stdio.js +17 -5
- package/dist/transports/stdio.js.map +1 -1
- package/dist/tui/wizard-save.d.ts +88 -8
- package/dist/tui/wizard-save.d.ts.map +1 -1
- package/dist/tui/wizard-save.js +77 -8
- package/dist/tui/wizard-save.js.map +1 -1
- package/dist/wizard-core/desktop-flow.d.ts.map +1 -1
- package/dist/wizard-core/desktop-flow.js +4 -2
- package/dist/wizard-core/desktop-flow.js.map +1 -1
- package/docs/03_CONFIGURATION_AND_WIZARD.md +5 -3
- package/docs/06_PAYMENTS_X402_AND_PAYSH.md +82 -4
- package/docs/07_ENDPOINTS_AND_CLIENTS.md +7 -3
- package/docs/09_TOOLS_SKILLS_AND_AGENT_GUIDE.md +21 -3
- package/docs/14_DESKTOP_WIZARD_RELEASE.md +8 -6
- package/docs/16_SAP_AGENT_IDENTITY_PIPELINE.md +304 -0
- package/docs/18_PREMIUM_PLUGIN_RUNTIME.md +108 -0
- package/docs/BRANCH_AND_CI.md +67 -0
- package/docs/README.md +19 -2
- package/docs/magicblock-tools.md +70 -29
- package/package.json +10 -6
- package/server.json +3 -3
- package/skills/README.md +12 -2
- package/skills/sap-agent-registry/SKILL.md +99 -4
- package/skills/sap-defi/SKILL.md +8 -4
- package/skills/sap-discovery-indexing/SKILL.md +26 -4
- package/skills/sap-escrow-settlement/SKILL.md +22 -4
- package/skills/sap-mcp/SKILL.md +140 -22
- package/skills/sap-mcp/TOOL_REFERENCE.md +47 -7
- package/skills/sap-nft-metaplex/SKILL.md +22 -0
- package/skills/sap-operations/SKILL.md +32 -3
- package/skills/sap-payments-x402/SKILL.md +85 -8
- package/skills/sap-sns/SKILL.md +32 -10
- package/smithery.config.schema.json +7 -0
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
import { registerTool } from '../adapters/mcp/sdk-compat.js';
|
|
6
6
|
import { createTextResponse } from '../adapters/mcp/tool-response.js';
|
|
7
7
|
import { getActiveProfile, getProfileConfigPath } from '../config/profiles.js';
|
|
8
|
-
import { executeX402PaidCall, getX402PaymentReadiness, inspectX402Receipt, probeX402PaymentChallenge, signX402PaymentChallenge, } from '../payments/x402-paid-call.js';
|
|
8
|
+
import { executeX402PaidCall, executeExternalX402Call, getX402PaymentReadiness, inspectX402Receipt, probeX402PaymentChallenge, signX402PaymentChallenge, } from '../payments/x402-paid-call.js';
|
|
9
|
+
import { finalizeTransactionWithLocalSigner } from './transaction-tools.js';
|
|
10
|
+
import { SAP_AGENT_REGISTER_INPUT_SCHEMA, SAP_AGENT_UPDATE_INPUT_SCHEMA, parseRegisterAgentArgs, parseUpdateAgentArgs, } from './sap-sdk-tools.js';
|
|
11
|
+
import { SAP_PROTOCOL_TREASURY, SAP_REGISTRATION_FEE_LAMPORTS } from '../core/constants.js';
|
|
9
12
|
const paidCallInputSchema = {
|
|
10
13
|
endpoint: {
|
|
11
14
|
type: 'string',
|
|
@@ -29,7 +32,7 @@ const paidCallInputSchema = {
|
|
|
29
32
|
},
|
|
30
33
|
maxPriceUsd: {
|
|
31
34
|
type: 'number',
|
|
32
|
-
description: '
|
|
35
|
+
description: 'Per-call safety cap in USD for the x402 payment. The call aborts before signing if the challenge exceeds this cap. Estimate first with sap_estimate_tool_cost.',
|
|
33
36
|
},
|
|
34
37
|
maxAttempts: {
|
|
35
38
|
type: 'number',
|
|
@@ -93,12 +96,588 @@ export function registerX402PaidCallTool(server, _context) {
|
|
|
93
96
|
registerPaymentsProfileCurrentTool(server, _context);
|
|
94
97
|
registerPaymentsReadinessTool(server);
|
|
95
98
|
registerPaymentsCallPaidTool(server, 'sap_payments_call_paid_tool');
|
|
99
|
+
registerPaymentsCallExternalX402Tool(server);
|
|
100
|
+
registerPaymentsRegisterAgentTool(server, _context);
|
|
101
|
+
registerPaymentsUpdateAgentTool(server, _context);
|
|
102
|
+
registerPaymentsFinalizeTransactionTool(server, _context);
|
|
96
103
|
registerPaymentsPrepareChallengeTool(server);
|
|
97
104
|
registerPaymentsSignChallengeTool(server);
|
|
98
105
|
registerPaymentsVerifyReceiptTool(server);
|
|
99
106
|
// Backward-compatible alias used by existing Codex/Hermes/Claude client snippets.
|
|
100
107
|
registerPaymentsCallPaidTool(server, 'sap_x402_paid_call');
|
|
101
108
|
}
|
|
109
|
+
function registerPaymentsRegisterAgentTool(server, context) {
|
|
110
|
+
registerTool(server, 'sap_payments_register_agent', {
|
|
111
|
+
title: 'Register SAP Agent With Local Signer',
|
|
112
|
+
description: 'Canonical local non-custodial SAP registry write for hosted and local users. Use this after hosted sap_register_agent returns hosted_local_signer_required, or directly instead of raw sap_register_agent. It registers the active local SAP MCP profile wallet as an on-chain SAP agent with the local signer; OOBE never receives keypair bytes. This tool does not pay a hosted x402 fee because it runs locally through sap_payments. After confirmation it enforces the source-level expected 0.1 SOL SAP protocol registration fee against the protocol treasury. success is true only when the agent account exists and the protocol fee invariant is verified. Requires confirm: true.',
|
|
113
|
+
inputSchema: {
|
|
114
|
+
...SAP_AGENT_REGISTER_INPUT_SCHEMA,
|
|
115
|
+
confirmationTimeoutMs: {
|
|
116
|
+
type: 'number',
|
|
117
|
+
description: 'Optional local confirmation wait in milliseconds. Defaults to 90000 so the tool can distinguish confirmed registration from an expired/not-landed transaction.',
|
|
118
|
+
},
|
|
119
|
+
confirm: { type: 'boolean', description: 'Must be true. Confirms the user wants the local signer to submit this SAP registry transaction.' },
|
|
120
|
+
},
|
|
121
|
+
outputSchema: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
success: { type: 'boolean', description: 'Whether the full SAP registration lifecycle completed: agent account confirmed and protocol fee invariant verified.' },
|
|
125
|
+
signature: { type: 'string', description: 'Solana transaction signature returned by the SAP SDK.' },
|
|
126
|
+
confirmationStatus: { type: 'string', description: 'Final local confirmation result: confirmed, finalized, processed, expired, missing, or failed.' },
|
|
127
|
+
signerPublicKey: { type: 'string', description: 'Public key of the local SAP MCP signer that registered the agent.' },
|
|
128
|
+
profile: { type: 'string', description: 'Active local SAP MCP profile used for registration when available.' },
|
|
129
|
+
agentRegistered: { type: 'boolean', description: 'Whether the SAP agent account was found on-chain, even if protocolComplete is false.' },
|
|
130
|
+
agent: { type: 'object', description: 'Agent registration fields submitted on-chain.' },
|
|
131
|
+
protocolFee: { type: 'object', description: 'Verification of the SAP protocol registration fee credited to the protocol treasury in the landed transaction.' },
|
|
132
|
+
protocolComplete: { type: 'boolean', description: 'True only when the agent account is confirmed and the expected protocol fee invariant is verified from transaction metadata.' },
|
|
133
|
+
audit: { type: 'object', description: 'Agent-readable proof that the write was local, non-custodial, and did not use hosted x402.' },
|
|
134
|
+
},
|
|
135
|
+
required: ['success', 'signature', 'confirmationStatus', 'signerPublicKey', 'agentRegistered', 'agent', 'protocolFee', 'protocolComplete', 'audit'],
|
|
136
|
+
},
|
|
137
|
+
annotations: {
|
|
138
|
+
readOnlyHint: false,
|
|
139
|
+
destructiveHint: false,
|
|
140
|
+
idempotentHint: false,
|
|
141
|
+
openWorldHint: false,
|
|
142
|
+
},
|
|
143
|
+
}, async (input) => {
|
|
144
|
+
try {
|
|
145
|
+
const parsed = parseRegisterAgentInput(input);
|
|
146
|
+
const activeProfile = getActiveProfile();
|
|
147
|
+
const signerPublicKey = context.signer?.publicKey.toBase58();
|
|
148
|
+
if (!signerPublicKey) {
|
|
149
|
+
throw new Error('No local signer configured. Run the SAP MCP wizard full setup or repair the local sap_payments bridge, then restart the agent runtime.');
|
|
150
|
+
}
|
|
151
|
+
const args = parseRegisterAgentArgs(parsed);
|
|
152
|
+
const signature = await context.sapClient.agent.register(args);
|
|
153
|
+
const confirmation = await waitForLocalAgentRegistration(context, signature, parsed.confirmationTimeoutMs);
|
|
154
|
+
if (!confirmation.confirmed) {
|
|
155
|
+
return createTextResponse(JSON.stringify({
|
|
156
|
+
success: false,
|
|
157
|
+
signature,
|
|
158
|
+
confirmationStatus: confirmation.status,
|
|
159
|
+
signerPublicKey,
|
|
160
|
+
profile: activeProfile,
|
|
161
|
+
agentPda: confirmation.agentPda,
|
|
162
|
+
agentRegistered: false,
|
|
163
|
+
agent: {
|
|
164
|
+
name: args.name,
|
|
165
|
+
description: args.description,
|
|
166
|
+
agentId: args.agentId,
|
|
167
|
+
agentUri: args.agentUri,
|
|
168
|
+
x402Endpoint: args.x402Endpoint,
|
|
169
|
+
protocols: args.protocols,
|
|
170
|
+
capabilityCount: args.capabilities.length,
|
|
171
|
+
pricingTierCount: args.pricing.length,
|
|
172
|
+
},
|
|
173
|
+
protocolFee: buildUnconfirmedProtocolFeeStatus(signature),
|
|
174
|
+
protocolComplete: false,
|
|
175
|
+
audit: {
|
|
176
|
+
action: 'sap_payments_register_agent',
|
|
177
|
+
registeredLocally: true,
|
|
178
|
+
hostedX402Charged: false,
|
|
179
|
+
signerBoundary: 'local-sap-payments-bridge',
|
|
180
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
181
|
+
transactionLanded: false,
|
|
182
|
+
retrySafe: confirmation.retrySafe,
|
|
183
|
+
rule: 'The local signer submitted the SAP registry transaction, but the transaction did not confirm or the agent account was not found inside the local confirmation window.',
|
|
184
|
+
nextAction: confirmation.retrySafe
|
|
185
|
+
? 'Ask the user for confirmation, then retry sap_payments_register_agent once with the same fields and confirm: true. Do not call hosted sap_register_agent.'
|
|
186
|
+
: 'Do not retry automatically. Inspect the signature and local RPC health first.',
|
|
187
|
+
},
|
|
188
|
+
}, null, 2), { isError: true });
|
|
189
|
+
}
|
|
190
|
+
const protocolFee = await verifyProtocolRegistrationFee(context, signature);
|
|
191
|
+
if (protocolFee.status === 'missing_or_underpaid') {
|
|
192
|
+
return createTextResponse(JSON.stringify({
|
|
193
|
+
success: false,
|
|
194
|
+
signature,
|
|
195
|
+
confirmationStatus: confirmation.status,
|
|
196
|
+
signerPublicKey,
|
|
197
|
+
profile: activeProfile,
|
|
198
|
+
agentPda: confirmation.agentPda,
|
|
199
|
+
agentRegistered: true,
|
|
200
|
+
protocolComplete: false,
|
|
201
|
+
agent: {
|
|
202
|
+
name: args.name,
|
|
203
|
+
description: args.description,
|
|
204
|
+
agentId: args.agentId,
|
|
205
|
+
agentUri: args.agentUri,
|
|
206
|
+
x402Endpoint: args.x402Endpoint,
|
|
207
|
+
protocols: args.protocols,
|
|
208
|
+
capabilityCount: args.capabilities.length,
|
|
209
|
+
pricingTierCount: args.pricing.length,
|
|
210
|
+
},
|
|
211
|
+
protocolFee,
|
|
212
|
+
audit: {
|
|
213
|
+
action: 'sap_payments_register_agent',
|
|
214
|
+
registeredLocally: true,
|
|
215
|
+
hostedX402Charged: false,
|
|
216
|
+
signerBoundary: 'local-sap-payments-bridge',
|
|
217
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
218
|
+
transactionLanded: true,
|
|
219
|
+
protocolIntegrity: 'failed',
|
|
220
|
+
rule: 'The SAP agent account was found after registration, but the source-level expected protocol treasury registration fee was not visible in the landed transaction. The account exists, but the SAP registration lifecycle is not complete and must not be marketed as protocol-complete.',
|
|
221
|
+
nextAction: 'Do not retry registration automatically. Inspect the signature, deployed SAP program version, and treasury account balance delta before changing fee policy or redeploying the program.',
|
|
222
|
+
},
|
|
223
|
+
}, null, 2), { isError: true });
|
|
224
|
+
}
|
|
225
|
+
if (protocolFee.status !== 'verified') {
|
|
226
|
+
return createTextResponse(JSON.stringify({
|
|
227
|
+
success: false,
|
|
228
|
+
signature,
|
|
229
|
+
confirmationStatus: confirmation.status,
|
|
230
|
+
signerPublicKey,
|
|
231
|
+
profile: activeProfile,
|
|
232
|
+
agentPda: confirmation.agentPda,
|
|
233
|
+
agentRegistered: true,
|
|
234
|
+
protocolComplete: false,
|
|
235
|
+
agent: {
|
|
236
|
+
name: args.name,
|
|
237
|
+
description: args.description,
|
|
238
|
+
agentId: args.agentId,
|
|
239
|
+
agentUri: args.agentUri,
|
|
240
|
+
x402Endpoint: args.x402Endpoint,
|
|
241
|
+
protocols: args.protocols,
|
|
242
|
+
capabilityCount: args.capabilities.length,
|
|
243
|
+
pricingTierCount: args.pricing.length,
|
|
244
|
+
},
|
|
245
|
+
protocolFee,
|
|
246
|
+
audit: {
|
|
247
|
+
action: 'sap_payments_register_agent',
|
|
248
|
+
registeredLocally: true,
|
|
249
|
+
hostedX402Charged: false,
|
|
250
|
+
signerBoundary: 'local-sap-payments-bridge',
|
|
251
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
252
|
+
transactionLanded: true,
|
|
253
|
+
protocolIntegrity: 'fee-verification-unavailable',
|
|
254
|
+
rule: 'The SAP agent account was found, but transaction metadata did not prove the protocol treasury fee. The lifecycle is intentionally failed closed until another RPC or explorer verifies the fee delta.',
|
|
255
|
+
nextAction: 'Fetch transaction metadata from a reliable RPC or explorer. Do not announce registration complete until protocolFee.status is verified.',
|
|
256
|
+
},
|
|
257
|
+
}, null, 2), { isError: true });
|
|
258
|
+
}
|
|
259
|
+
return createTextResponse(JSON.stringify({
|
|
260
|
+
success: true,
|
|
261
|
+
signature,
|
|
262
|
+
confirmationStatus: confirmation.status,
|
|
263
|
+
signerPublicKey,
|
|
264
|
+
profile: activeProfile,
|
|
265
|
+
agentPda: confirmation.agentPda,
|
|
266
|
+
agentRegistered: true,
|
|
267
|
+
agent: {
|
|
268
|
+
name: args.name,
|
|
269
|
+
description: args.description,
|
|
270
|
+
agentId: args.agentId,
|
|
271
|
+
agentUri: args.agentUri,
|
|
272
|
+
x402Endpoint: args.x402Endpoint,
|
|
273
|
+
protocols: args.protocols,
|
|
274
|
+
capabilityCount: args.capabilities.length,
|
|
275
|
+
pricingTierCount: args.pricing.length,
|
|
276
|
+
},
|
|
277
|
+
protocolFee,
|
|
278
|
+
protocolComplete: protocolFee.status === 'verified',
|
|
279
|
+
audit: {
|
|
280
|
+
action: 'sap_payments_register_agent',
|
|
281
|
+
registeredLocally: true,
|
|
282
|
+
hostedX402Charged: false,
|
|
283
|
+
signerBoundary: 'local-sap-payments-bridge',
|
|
284
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
285
|
+
transactionLanded: true,
|
|
286
|
+
protocolIntegrity: 'verified',
|
|
287
|
+
rule: 'Hosted sap_register_agent is accountless and cannot sign user-owned registry writes. This local bridge submitted the SAP registry transaction with the user-controlled profile signer.',
|
|
288
|
+
nextAction: 'Registration is complete. Fetch the agent by owner wallet and continue with optional Metaplex or SNS identity links.',
|
|
289
|
+
},
|
|
290
|
+
}, null, 2));
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
return createTextResponse(formatLocalRegistryError(error), { isError: true });
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function buildUnconfirmedProtocolFeeStatus(signature) {
|
|
298
|
+
return {
|
|
299
|
+
status: 'not_checked',
|
|
300
|
+
signature,
|
|
301
|
+
expectedTreasury: SAP_PROTOCOL_TREASURY,
|
|
302
|
+
expectedLamports: SAP_REGISTRATION_FEE_LAMPORTS.toString(10),
|
|
303
|
+
reason: 'Registration transaction was not confirmed, so protocol fee verification was skipped.',
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
async function verifyProtocolRegistrationFee(context, signature) {
|
|
307
|
+
try {
|
|
308
|
+
const tx = await context.connection.getParsedTransaction(signature, {
|
|
309
|
+
commitment: 'confirmed',
|
|
310
|
+
maxSupportedTransactionVersion: 0,
|
|
311
|
+
});
|
|
312
|
+
if (!tx?.meta) {
|
|
313
|
+
return {
|
|
314
|
+
status: 'unavailable',
|
|
315
|
+
signature,
|
|
316
|
+
expectedTreasury: SAP_PROTOCOL_TREASURY,
|
|
317
|
+
expectedLamports: SAP_REGISTRATION_FEE_LAMPORTS.toString(10),
|
|
318
|
+
reason: 'Transaction metadata was unavailable from the configured RPC.',
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const accountKeys = tx.transaction.message.accountKeys.map((account) => account.pubkey.toBase58());
|
|
322
|
+
const treasuryIndex = accountKeys.indexOf(SAP_PROTOCOL_TREASURY);
|
|
323
|
+
if (treasuryIndex < 0) {
|
|
324
|
+
return {
|
|
325
|
+
status: 'missing_or_underpaid',
|
|
326
|
+
signature,
|
|
327
|
+
expectedTreasury: SAP_PROTOCOL_TREASURY,
|
|
328
|
+
expectedLamports: SAP_REGISTRATION_FEE_LAMPORTS.toString(10),
|
|
329
|
+
observedLamportsDelta: '0',
|
|
330
|
+
reason: 'Protocol treasury account was not present in the transaction account list.',
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
const preBalance = BigInt(tx.meta.preBalances[treasuryIndex] ?? 0);
|
|
334
|
+
const postBalance = BigInt(tx.meta.postBalances[treasuryIndex] ?? 0);
|
|
335
|
+
const delta = postBalance - preBalance;
|
|
336
|
+
const verified = delta >= SAP_REGISTRATION_FEE_LAMPORTS;
|
|
337
|
+
return {
|
|
338
|
+
status: verified ? 'verified' : 'missing_or_underpaid',
|
|
339
|
+
signature,
|
|
340
|
+
expectedTreasury: SAP_PROTOCOL_TREASURY,
|
|
341
|
+
expectedLamports: SAP_REGISTRATION_FEE_LAMPORTS.toString(10),
|
|
342
|
+
observedLamportsDelta: delta.toString(10),
|
|
343
|
+
reason: verified
|
|
344
|
+
? 'Protocol treasury balance delta satisfies the expected SAP registration fee.'
|
|
345
|
+
: 'Protocol treasury balance delta is below the expected SAP registration fee.',
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
return {
|
|
350
|
+
status: 'unavailable',
|
|
351
|
+
signature,
|
|
352
|
+
expectedTreasury: SAP_PROTOCOL_TREASURY,
|
|
353
|
+
expectedLamports: SAP_REGISTRATION_FEE_LAMPORTS.toString(10),
|
|
354
|
+
reason: error instanceof Error ? error.message : 'Unable to fetch transaction metadata from RPC.',
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function registerPaymentsUpdateAgentTool(server, context) {
|
|
359
|
+
registerTool(server, 'sap_payments_update_agent', {
|
|
360
|
+
title: 'Update SAP Agent With Local Signer',
|
|
361
|
+
description: 'Local non-custodial SAP registry update for hosted users. Use this when hosted sap_update_agent returns hosted_local_signer_required. It updates the active local SAP MCP profile wallet agent with the local signer, including name, description, capabilities, protocols, pricing, agentUri/metadataUri, or x402Endpoint. Use it for agent picture/profile metadata updates after uploading image or metadata to a public URL such as IPFS, Arweave, Kommodo, or a HTTPS metadata endpoint. OOBE never receives keypair bytes and no hosted x402 fee is charged. Requires confirm: true.',
|
|
362
|
+
inputSchema: {
|
|
363
|
+
...SAP_AGENT_UPDATE_INPUT_SCHEMA,
|
|
364
|
+
confirmationTimeoutMs: {
|
|
365
|
+
type: 'number',
|
|
366
|
+
description: 'Optional local confirmation wait in milliseconds. Defaults to 90000 so the tool can distinguish confirmed update from an expired/not-landed transaction.',
|
|
367
|
+
},
|
|
368
|
+
confirm: { type: 'boolean', description: 'Must be true. Confirms the user wants the local signer to submit this SAP registry update transaction.' },
|
|
369
|
+
},
|
|
370
|
+
outputSchema: {
|
|
371
|
+
type: 'object',
|
|
372
|
+
properties: {
|
|
373
|
+
success: { type: 'boolean', description: 'Whether the local SAP agent update transaction was confirmed on-chain.' },
|
|
374
|
+
signature: { type: 'string', description: 'Solana transaction signature returned by the SAP SDK.' },
|
|
375
|
+
confirmationStatus: { type: 'string', description: 'Final local confirmation result: confirmed, finalized, processed, expired, missing, or failed.' },
|
|
376
|
+
signerPublicKey: { type: 'string', description: 'Public key of the local SAP MCP signer that updated the agent.' },
|
|
377
|
+
profile: { type: 'string', description: 'Active local SAP MCP profile used for update when available.' },
|
|
378
|
+
agentPda: { type: 'string', description: 'SAP agent PDA derived from the active local signer wallet.' },
|
|
379
|
+
update: { type: 'object', description: 'Update fields submitted on-chain. Omitted fields were intentionally left unchanged.' },
|
|
380
|
+
audit: { type: 'object', description: 'Agent-readable proof that the write was local, non-custodial, and did not use hosted x402.' },
|
|
381
|
+
},
|
|
382
|
+
required: ['success', 'signature', 'confirmationStatus', 'signerPublicKey', 'agentPda', 'update', 'audit'],
|
|
383
|
+
},
|
|
384
|
+
annotations: {
|
|
385
|
+
readOnlyHint: false,
|
|
386
|
+
destructiveHint: false,
|
|
387
|
+
idempotentHint: false,
|
|
388
|
+
openWorldHint: false,
|
|
389
|
+
},
|
|
390
|
+
}, async (input) => {
|
|
391
|
+
try {
|
|
392
|
+
const parsed = parseUpdateAgentInput(input);
|
|
393
|
+
const activeProfile = getActiveProfile();
|
|
394
|
+
const signerPublicKey = context.signer?.publicKey.toBase58();
|
|
395
|
+
if (!signerPublicKey) {
|
|
396
|
+
throw new Error('No local signer configured. Run the SAP MCP wizard full setup or repair the local sap_payments bridge, then restart the agent runtime.');
|
|
397
|
+
}
|
|
398
|
+
const args = parseUpdateAgentArgs(parsed);
|
|
399
|
+
const signature = await context.sapClient.agent.update(args);
|
|
400
|
+
const confirmation = await waitForLocalAgentUpdate(context, signature, parsed.confirmationTimeoutMs);
|
|
401
|
+
const update = summarizeAgentUpdate(args);
|
|
402
|
+
if (!confirmation.confirmed) {
|
|
403
|
+
return createTextResponse(JSON.stringify({
|
|
404
|
+
success: false,
|
|
405
|
+
signature,
|
|
406
|
+
confirmationStatus: confirmation.status,
|
|
407
|
+
signerPublicKey,
|
|
408
|
+
profile: activeProfile,
|
|
409
|
+
agentPda: confirmation.agentPda,
|
|
410
|
+
update,
|
|
411
|
+
audit: {
|
|
412
|
+
action: 'sap_payments_update_agent',
|
|
413
|
+
updatedLocally: true,
|
|
414
|
+
hostedX402Charged: false,
|
|
415
|
+
signerBoundary: 'local-sap-payments-bridge',
|
|
416
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
417
|
+
transactionLanded: false,
|
|
418
|
+
retrySafe: confirmation.retrySafe,
|
|
419
|
+
rule: 'The local signer submitted the SAP registry update transaction, but the transaction did not confirm or the agent account was not found inside the local confirmation window.',
|
|
420
|
+
nextAction: confirmation.retrySafe
|
|
421
|
+
? 'Ask the user for confirmation, then retry sap_payments_update_agent once with the same fields and confirm: true. Do not call hosted sap_update_agent.'
|
|
422
|
+
: 'Do not retry automatically. Inspect the signature and local RPC health first.',
|
|
423
|
+
},
|
|
424
|
+
}, null, 2), { isError: true });
|
|
425
|
+
}
|
|
426
|
+
return createTextResponse(JSON.stringify({
|
|
427
|
+
success: true,
|
|
428
|
+
signature,
|
|
429
|
+
confirmationStatus: confirmation.status,
|
|
430
|
+
signerPublicKey,
|
|
431
|
+
profile: activeProfile,
|
|
432
|
+
agentPda: confirmation.agentPda,
|
|
433
|
+
update,
|
|
434
|
+
audit: {
|
|
435
|
+
action: 'sap_payments_update_agent',
|
|
436
|
+
updatedLocally: true,
|
|
437
|
+
hostedX402Charged: false,
|
|
438
|
+
signerBoundary: 'local-sap-payments-bridge',
|
|
439
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
440
|
+
transactionLanded: true,
|
|
441
|
+
rule: 'Hosted sap_update_agent is accountless and cannot sign user-owned registry writes. This local bridge submitted the SAP registry update with the user-controlled profile signer.',
|
|
442
|
+
},
|
|
443
|
+
}, null, 2));
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
return createTextResponse(formatLocalRegistryError(error), { isError: true });
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
async function waitForLocalAgentRegistration(context, signature, timeoutMs = 90_000) {
|
|
451
|
+
return waitForLocalAgentWrite(context, signature, timeoutMs);
|
|
452
|
+
}
|
|
453
|
+
async function waitForLocalAgentWrite(context, signature, timeoutMs = 90_000) {
|
|
454
|
+
const boundedTimeoutMs = Math.max(15_000, Math.min(timeoutMs, 180_000));
|
|
455
|
+
const startedAt = Date.now();
|
|
456
|
+
const [agentPda] = context.sapClient.agent.deriveAgent();
|
|
457
|
+
let lastStatus = 'missing';
|
|
458
|
+
while (Date.now() - startedAt < boundedTimeoutMs) {
|
|
459
|
+
const statuses = await context.connection.getSignatureStatuses([signature], { searchTransactionHistory: true });
|
|
460
|
+
const status = statuses.value[0];
|
|
461
|
+
if (status?.err) {
|
|
462
|
+
return {
|
|
463
|
+
confirmed: false,
|
|
464
|
+
retrySafe: true,
|
|
465
|
+
status: 'failed',
|
|
466
|
+
agentPda: agentPda.toBase58(),
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
lastStatus = status?.confirmationStatus ?? lastStatus;
|
|
470
|
+
const agent = await context.sapClient.agent.fetchNullable();
|
|
471
|
+
if (agent) {
|
|
472
|
+
return {
|
|
473
|
+
confirmed: true,
|
|
474
|
+
retrySafe: false,
|
|
475
|
+
status: status?.confirmationStatus ?? 'confirmed',
|
|
476
|
+
agentPda: agentPda.toBase58(),
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
await sleep(2_000);
|
|
480
|
+
}
|
|
481
|
+
return {
|
|
482
|
+
confirmed: false,
|
|
483
|
+
retrySafe: lastStatus === 'missing',
|
|
484
|
+
status: lastStatus === 'missing' ? 'expired_or_not_landed' : lastStatus,
|
|
485
|
+
agentPda: agentPda.toBase58(),
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
async function waitForLocalAgentUpdate(context, signature, timeoutMs = 90_000) {
|
|
489
|
+
const boundedTimeoutMs = Math.max(15_000, Math.min(timeoutMs, 180_000));
|
|
490
|
+
const startedAt = Date.now();
|
|
491
|
+
const [agentPda] = context.sapClient.agent.deriveAgent();
|
|
492
|
+
let lastStatus = 'missing';
|
|
493
|
+
while (Date.now() - startedAt < boundedTimeoutMs) {
|
|
494
|
+
const statuses = await context.connection.getSignatureStatuses([signature], { searchTransactionHistory: true });
|
|
495
|
+
const status = statuses.value[0];
|
|
496
|
+
if (status?.err) {
|
|
497
|
+
return {
|
|
498
|
+
confirmed: false,
|
|
499
|
+
retrySafe: true,
|
|
500
|
+
status: 'failed',
|
|
501
|
+
agentPda: agentPda.toBase58(),
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
lastStatus = status?.confirmationStatus ?? lastStatus;
|
|
505
|
+
if (lastStatus === 'processed' || lastStatus === 'confirmed' || lastStatus === 'finalized') {
|
|
506
|
+
return {
|
|
507
|
+
confirmed: true,
|
|
508
|
+
retrySafe: false,
|
|
509
|
+
status: lastStatus,
|
|
510
|
+
agentPda: agentPda.toBase58(),
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
await sleep(2_000);
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
confirmed: false,
|
|
517
|
+
retrySafe: lastStatus === 'missing',
|
|
518
|
+
status: lastStatus === 'missing' ? 'expired_or_not_landed' : lastStatus,
|
|
519
|
+
agentPda: agentPda.toBase58(),
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
async function sleep(ms) {
|
|
523
|
+
await new Promise(resolve => setTimeout(resolve, ms));
|
|
524
|
+
}
|
|
525
|
+
function registerPaymentsCallExternalX402Tool(server) {
|
|
526
|
+
registerTool(server, 'sap_payments_call_external_x402', {
|
|
527
|
+
title: 'Pay And Call External x402 Endpoint',
|
|
528
|
+
description: 'High-level local payment bridge for generic HTTP x402 endpoints outside hosted SAP MCP, such as another SAP agent endpoint discovered from the registry. It sends the request once to obtain the 402 payment challenge, signs with the user-controlled local SAP MCP profile wallet, retries the same HTTP request with PAYMENT-SIGNATURE, and returns the response plus receipt. Use sap_payments_call_paid_tool for hosted SAP MCP tools; use this only for external HTTP x402 providers. Requires confirm: true and maxPriceUsd.',
|
|
529
|
+
inputSchema: {
|
|
530
|
+
url: {
|
|
531
|
+
type: 'string',
|
|
532
|
+
description: 'External HTTP or HTTPS x402 endpoint URL to call, for example an agent endpoint discovered from SAP registry metadata.',
|
|
533
|
+
},
|
|
534
|
+
method: {
|
|
535
|
+
type: 'string',
|
|
536
|
+
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
537
|
+
description: 'HTTP method for the external request. Defaults to POST.',
|
|
538
|
+
},
|
|
539
|
+
headers: {
|
|
540
|
+
type: 'object',
|
|
541
|
+
description: 'Optional non-sensitive headers for the external request. Do not include PAYMENT-SIGNATURE, X-PAYMENT, Authorization, or cookies.',
|
|
542
|
+
},
|
|
543
|
+
body: {
|
|
544
|
+
type: 'object',
|
|
545
|
+
description: 'Optional JSON request body for POST, PUT, PATCH, or DELETE calls. Strings are sent as-is; objects are JSON-encoded.',
|
|
546
|
+
},
|
|
547
|
+
profileName: paidCallInputSchema.profileName,
|
|
548
|
+
maxPriceUsd: paidCallInputSchema.maxPriceUsd,
|
|
549
|
+
maxAttempts: paidCallInputSchema.maxAttempts,
|
|
550
|
+
confirm: paidCallInputSchema.confirm,
|
|
551
|
+
},
|
|
552
|
+
outputSchema: {
|
|
553
|
+
type: 'object',
|
|
554
|
+
properties: {
|
|
555
|
+
success: { type: 'boolean', description: 'Whether the external x402 call completed successfully.' },
|
|
556
|
+
url: { type: 'string', description: 'External endpoint URL called.' },
|
|
557
|
+
method: { type: 'string', description: 'HTTP method used.' },
|
|
558
|
+
signerAddress: { type: 'string', description: 'Public address of the local SAP MCP signer. Secret bytes are never returned.' },
|
|
559
|
+
payment: { type: 'object', description: 'Selected payment requirements, including amountUsd, network, asset, and payTo, when a 402 challenge was paid.' },
|
|
560
|
+
settlement: { type: 'object', description: 'x402 settlement response returned by the provider/facilitator when available.' },
|
|
561
|
+
response: { type: 'object', description: 'External HTTP response status, safe headers, and parsed body.' },
|
|
562
|
+
attempts: { type: 'number', description: 'Number of attempts used.' },
|
|
563
|
+
transientRetries: { type: 'array', items: { type: 'string' }, description: 'Retryable errors encountered before success.' },
|
|
564
|
+
audit: { type: 'object', description: 'Agent-readable proof object with intent id, profile, payment receipt, attempts, and secret-material guarantee.' },
|
|
565
|
+
},
|
|
566
|
+
required: ['success', 'url', 'method', 'signerAddress', 'response', 'attempts', 'transientRetries', 'audit'],
|
|
567
|
+
},
|
|
568
|
+
annotations: {
|
|
569
|
+
readOnlyHint: false,
|
|
570
|
+
destructiveHint: false,
|
|
571
|
+
idempotentHint: false,
|
|
572
|
+
openWorldHint: true,
|
|
573
|
+
},
|
|
574
|
+
}, async (input) => {
|
|
575
|
+
try {
|
|
576
|
+
const parsed = parseExternalInput(input);
|
|
577
|
+
const result = await executeExternalX402Call(parsed);
|
|
578
|
+
return createTextResponse(JSON.stringify(result, null, 2));
|
|
579
|
+
}
|
|
580
|
+
catch (error) {
|
|
581
|
+
return createTextResponse(formatPaidCallError(error), { isError: true });
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function registerPaymentsFinalizeTransactionTool(server, context) {
|
|
586
|
+
registerTool(server, 'sap_payments_finalize_transaction', {
|
|
587
|
+
title: 'Finalize Transaction With Local Signer',
|
|
588
|
+
description: 'Local non-custodial transaction finalizer for hosted SAP MCP builders. Use this when a hosted tool returns transactionBase64, transaction, or an unsigned Solana transaction. It previews, signs with the active local SAP MCP profile signer, and optionally submits through the OOBE hosted submit relay for reliable confirmation. The relay only broadcasts already-signed bytes and never receives keypair material. Never create temporary signing scripts, read keypair JSON, or call hosted sap_sign_transaction for user-owned signatures. Requires confirm: true.',
|
|
589
|
+
inputSchema: {
|
|
590
|
+
transaction: {
|
|
591
|
+
type: 'string',
|
|
592
|
+
description: 'Serialized unsigned or partially signed Solana transaction. Accepts base64 by default.',
|
|
593
|
+
},
|
|
594
|
+
transactionBase64: {
|
|
595
|
+
type: 'string',
|
|
596
|
+
description: 'Alias for transaction when the builder returns transactionBase64.',
|
|
597
|
+
},
|
|
598
|
+
encoding: {
|
|
599
|
+
type: 'string',
|
|
600
|
+
enum: ['base64', 'base58'],
|
|
601
|
+
description: 'Encoding for transaction or transactionBase64. Defaults to base64.',
|
|
602
|
+
},
|
|
603
|
+
submit: {
|
|
604
|
+
type: 'boolean',
|
|
605
|
+
description: 'When true, submit the signed transaction after preview and signing. When false or omitted, return the signed transaction for inspection.',
|
|
606
|
+
},
|
|
607
|
+
skipPreflight: {
|
|
608
|
+
type: 'boolean',
|
|
609
|
+
description: 'Optional Solana RPC sendRawTransaction skipPreflight flag, used only when submit is true.',
|
|
610
|
+
},
|
|
611
|
+
maxRetries: {
|
|
612
|
+
type: 'number',
|
|
613
|
+
description: 'Optional Solana RPC sendRawTransaction maxRetries value, used only when submit is true.',
|
|
614
|
+
},
|
|
615
|
+
confirmationTimeoutMs: {
|
|
616
|
+
type: 'number',
|
|
617
|
+
description: 'Optional bounded confirmation wait in milliseconds. Defaults to 90000; maximum 180000.',
|
|
618
|
+
},
|
|
619
|
+
commitment: {
|
|
620
|
+
type: 'string',
|
|
621
|
+
enum: ['processed', 'confirmed', 'finalized'],
|
|
622
|
+
description: 'Desired confirmation status before returning success. Defaults to confirmed.',
|
|
623
|
+
},
|
|
624
|
+
submitViaRelay: {
|
|
625
|
+
type: 'boolean',
|
|
626
|
+
description: 'When submit is true, defaults to true. Set false only when the user explicitly wants local RPC submission instead of the OOBE hosted submit relay.',
|
|
627
|
+
},
|
|
628
|
+
submitRelayUrl: {
|
|
629
|
+
type: 'string',
|
|
630
|
+
description: 'Optional submit relay URL. Must be HTTPS, localhost, or 127.0.0.1. Defaults to https://mcp.sap.oobeprotocol.ai/tx/submit.',
|
|
631
|
+
},
|
|
632
|
+
confirm: {
|
|
633
|
+
type: 'boolean',
|
|
634
|
+
description: 'Must be true. Confirms the user allows the local SAP MCP signer to sign this transaction.',
|
|
635
|
+
},
|
|
636
|
+
signerProfile: {
|
|
637
|
+
type: 'string',
|
|
638
|
+
description: 'Optional profile name to use for signing instead of the global active profile. When provided, the bridge loads config-<signerProfile>.json and uses its keypair. This eliminates the need to switch .active-profile manually — multiple profiles can coexist in the same session. Falls back to the active profile if omitted.',
|
|
639
|
+
},
|
|
640
|
+
intentId: {
|
|
641
|
+
type: 'string',
|
|
642
|
+
description: 'Optional caller-provided id used to bind preview, signature, submission, and audit output.',
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
outputSchema: {
|
|
646
|
+
type: 'object',
|
|
647
|
+
properties: {
|
|
648
|
+
success: { type: 'boolean', description: 'Whether finalization succeeded.' },
|
|
649
|
+
action: { type: 'string', description: 'preview-sign or preview-sign-submit.' },
|
|
650
|
+
submitted: { type: 'boolean', description: 'Whether the signed transaction was submitted to RPC.' },
|
|
651
|
+
signature: { type: 'string', description: 'Solana transaction signature when submit is true.' },
|
|
652
|
+
confirmationStatus: { type: 'string', description: 'Confirmed/finalized/failed/expired_or_not_landed status when submit is true.' },
|
|
653
|
+
retrySafe: { type: 'boolean', description: 'Whether the agent may ask the user to retry without risking a known landed duplicate.' },
|
|
654
|
+
explorerUrl: { type: 'string', description: 'Solana explorer URL for the submitted signature.' },
|
|
655
|
+
signerPublicKey: { type: 'string', description: 'Public key of the local signer that signed the transaction.' },
|
|
656
|
+
nativeTransferSol: { type: 'number', description: 'Estimated native SOL transferred by the transaction.' },
|
|
657
|
+
preview: { type: 'object', description: 'Decoded transaction preview and policy result.' },
|
|
658
|
+
signedTransaction: { type: 'string', description: 'Base64 signed transaction when submit is false or for audit.' },
|
|
659
|
+
encoding: { type: 'string', description: 'Encoding of signedTransaction.' },
|
|
660
|
+
audit: { type: 'object', description: 'Proof object binding intent, local signer, preview, signing, submission, and secret-material guarantee.' },
|
|
661
|
+
},
|
|
662
|
+
required: ['success', 'action', 'submitted', 'signerPublicKey', 'nativeTransferSol', 'preview', 'audit'],
|
|
663
|
+
},
|
|
664
|
+
annotations: {
|
|
665
|
+
readOnlyHint: false,
|
|
666
|
+
destructiveHint: false,
|
|
667
|
+
idempotentHint: false,
|
|
668
|
+
openWorldHint: false,
|
|
669
|
+
},
|
|
670
|
+
}, async (input) => {
|
|
671
|
+
try {
|
|
672
|
+
const parsed = parseFinalizeTransactionInput(input);
|
|
673
|
+
const result = await finalizeTransactionWithLocalSigner(context, parsed);
|
|
674
|
+
return createTextResponse(JSON.stringify(result, null, 2));
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
return createTextResponse(formatFinalizeTransactionError(error), { isError: true });
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}
|
|
102
681
|
function registerPaymentsProfileCurrentTool(server, context) {
|
|
103
682
|
registerTool(server, 'sap_payments_profile_current', {
|
|
104
683
|
title: 'Show Local SAP Payments Profile',
|
|
@@ -129,26 +708,55 @@ function registerPaymentsProfileCurrentTool(server, context) {
|
|
|
129
708
|
idempotentHint: true,
|
|
130
709
|
openWorldHint: false,
|
|
131
710
|
},
|
|
132
|
-
}, async () =>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
711
|
+
}, async () => {
|
|
712
|
+
// Re-read the active profile on every call to avoid stale cache.
|
|
713
|
+
// The context.signer was resolved at startup from the then-active profile;
|
|
714
|
+
// if the user switched .active-profile manually, the cached signer is stale.
|
|
715
|
+
// We re-read .active-profile and resolve the current signer on demand.
|
|
716
|
+
const currentProfile = getActiveProfile();
|
|
717
|
+
const currentConfigPath = getProfileConfigPath(currentProfile);
|
|
718
|
+
let currentSignerPubkey = context.signer?.publicKey.toBase58();
|
|
719
|
+
let currentWalletPath = context.config.walletPath;
|
|
720
|
+
// Always try to re-resolve the signer from the active profile to avoid
|
|
721
|
+
// stale cache. If .active-profile was switched manually after startup,
|
|
722
|
+
// the context.signer reflects the OLD profile. We re-read and re-resolve.
|
|
723
|
+
try {
|
|
724
|
+
const { loadProfileConfig } = await import('../config/profiles.js');
|
|
725
|
+
const { resolveSigner } = await import('../signer/signer-resolver.js');
|
|
726
|
+
const profileConfig = loadProfileConfig(currentProfile);
|
|
727
|
+
if (profileConfig) {
|
|
728
|
+
const signerResult = await resolveSigner({ ...context.config, ...profileConfig });
|
|
729
|
+
if (signerResult.signer) {
|
|
730
|
+
currentSignerPubkey = signerResult.signer.publicKey.toBase58();
|
|
731
|
+
}
|
|
732
|
+
currentWalletPath = profileConfig.walletPath;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
catch {
|
|
736
|
+
// If we can't resolve the signer for the current profile, fall back
|
|
737
|
+
// to the cached signer — better than crashing.
|
|
738
|
+
}
|
|
739
|
+
return createTextResponse(JSON.stringify({
|
|
740
|
+
serverRole: 'local-sap-payments-bridge',
|
|
741
|
+
activeProfile: currentProfile,
|
|
742
|
+
configPath: currentConfigPath,
|
|
743
|
+
mode: context.config.mode,
|
|
744
|
+
network: networkFromRpcUrl(context.config.rpcUrl),
|
|
745
|
+
rpcUrl: redactUrl(context.config.rpcUrl),
|
|
746
|
+
programId: context.config.programId,
|
|
747
|
+
agentPubkey: context.config.agentPubkey,
|
|
748
|
+
walletPath: currentWalletPath,
|
|
749
|
+
walletPathConfigured: Boolean(currentWalletPath),
|
|
750
|
+
signerConfigured: Boolean(currentSignerPubkey),
|
|
751
|
+
signerPublicKey: currentSignerPubkey,
|
|
752
|
+
localProfileVisibility: 'visible-to-local-sap-payments-bridge',
|
|
753
|
+
hostedRemoteVisibility: 'not-visible-to-hosted-accountless-server',
|
|
754
|
+
secretMaterial: 'keypair-bytes-never-returned',
|
|
755
|
+
recommendedPaidTool: 'sap_payments_call_paid_tool',
|
|
756
|
+
recommendedReadinessTool: 'sap_payments_readiness',
|
|
757
|
+
agentInstruction: 'For wallet/profile questions, trust this local sap_payments profile result over the remote hosted sap_profile_current result. For paid/write workflows call sap_payments_readiness first. The hosted SAP MCP server is intentionally accountless. If you need to sign with a specific profile, use signerProfile param on sap_payments_finalize_transaction instead of switching .active-profile.',
|
|
758
|
+
}, null, 2));
|
|
759
|
+
});
|
|
152
760
|
}
|
|
153
761
|
function registerPaymentsReadinessTool(server) {
|
|
154
762
|
registerTool(server, 'sap_payments_readiness', {
|
|
@@ -227,7 +835,7 @@ function registerPaymentsPrepareChallengeTool(server) {
|
|
|
227
835
|
body: paidCallInputSchema.body,
|
|
228
836
|
maxPriceUsd: {
|
|
229
837
|
type: 'number',
|
|
230
|
-
description: '
|
|
838
|
+
description: 'Maximum accepted x402 payment amount in USD. The call aborts if the challenge exceeds this cap. Common tool costs: read-premium ~$0.001, builder ~$0.008, standard value-action ~$0.09, heavy value-action ~$0.05. Set to at least the expected tier price — e.g. maxPriceUsd: 0.12 for standard swaps, 0.06 for heavy private execution, 0.01 for reads. If omitted, defaults to a very low cap that may abort value-action calls silently.',
|
|
231
839
|
},
|
|
232
840
|
},
|
|
233
841
|
outputSchema: {
|
|
@@ -365,6 +973,74 @@ function parseInput(input) {
|
|
|
365
973
|
confirm: record.confirm === true,
|
|
366
974
|
};
|
|
367
975
|
}
|
|
976
|
+
function parseExternalInput(input) {
|
|
977
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
978
|
+
throw new Error('sap_payments_call_external_x402 requires an input object.');
|
|
979
|
+
}
|
|
980
|
+
const record = input;
|
|
981
|
+
if (!record.url) {
|
|
982
|
+
throw new Error('url is required.');
|
|
983
|
+
}
|
|
984
|
+
if (record.maxPriceUsd === undefined) {
|
|
985
|
+
throw new Error('maxPriceUsd is required.');
|
|
986
|
+
}
|
|
987
|
+
return {
|
|
988
|
+
url: record.url,
|
|
989
|
+
method: record.method,
|
|
990
|
+
headers: record.headers,
|
|
991
|
+
body: record.body,
|
|
992
|
+
profileName: record.profileName,
|
|
993
|
+
maxPriceUsd: record.maxPriceUsd,
|
|
994
|
+
maxAttempts: record.maxAttempts,
|
|
995
|
+
confirm: record.confirm === true,
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
function parseRegisterAgentInput(input) {
|
|
999
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
1000
|
+
throw new Error('sap_payments_register_agent requires an input object.');
|
|
1001
|
+
}
|
|
1002
|
+
const record = input;
|
|
1003
|
+
if (record.confirm !== true) {
|
|
1004
|
+
throw new Error('confirm: true is required to submit a local SAP registry transaction.');
|
|
1005
|
+
}
|
|
1006
|
+
return record;
|
|
1007
|
+
}
|
|
1008
|
+
function parseUpdateAgentInput(input) {
|
|
1009
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
1010
|
+
throw new Error('sap_payments_update_agent requires an input object.');
|
|
1011
|
+
}
|
|
1012
|
+
const record = input;
|
|
1013
|
+
if (record.confirm !== true) {
|
|
1014
|
+
throw new Error('confirm: true is required to submit a local SAP registry update transaction.');
|
|
1015
|
+
}
|
|
1016
|
+
const hasUpdate = [
|
|
1017
|
+
'name',
|
|
1018
|
+
'description',
|
|
1019
|
+
'capabilities',
|
|
1020
|
+
'pricing',
|
|
1021
|
+
'protocols',
|
|
1022
|
+
'agentId',
|
|
1023
|
+
'agentUri',
|
|
1024
|
+
'metadataUri',
|
|
1025
|
+
'x402Endpoint',
|
|
1026
|
+
].some((key) => Object.prototype.hasOwnProperty.call(record, key));
|
|
1027
|
+
if (!hasUpdate) {
|
|
1028
|
+
throw new Error('At least one update field is required: name, description, capabilities, pricing, protocols, agentId, agentUri/metadataUri, or x402Endpoint.');
|
|
1029
|
+
}
|
|
1030
|
+
return record;
|
|
1031
|
+
}
|
|
1032
|
+
function summarizeAgentUpdate(args) {
|
|
1033
|
+
return {
|
|
1034
|
+
name: args.name,
|
|
1035
|
+
description: args.description,
|
|
1036
|
+
agentId: args.agentId,
|
|
1037
|
+
agentUri: args.agentUri,
|
|
1038
|
+
x402Endpoint: args.x402Endpoint,
|
|
1039
|
+
protocols: args.protocols,
|
|
1040
|
+
capabilityCount: args.capabilities?.length ?? null,
|
|
1041
|
+
pricingTierCount: args.pricing?.length ?? null,
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
368
1044
|
function parseProbeInput(input) {
|
|
369
1045
|
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
370
1046
|
throw new Error('sap_payments_prepare_challenge requires an input object.');
|
|
@@ -409,6 +1085,30 @@ function parseReceiptInput(input) {
|
|
|
409
1085
|
}
|
|
410
1086
|
return header;
|
|
411
1087
|
}
|
|
1088
|
+
function parseFinalizeTransactionInput(input) {
|
|
1089
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
1090
|
+
throw new Error('sap_payments_finalize_transaction requires an input object.');
|
|
1091
|
+
}
|
|
1092
|
+
const record = input;
|
|
1093
|
+
if (!record.transaction && !record.transactionBase64) {
|
|
1094
|
+
throw new Error('transaction or transactionBase64 is required.');
|
|
1095
|
+
}
|
|
1096
|
+
return {
|
|
1097
|
+
transaction: record.transaction,
|
|
1098
|
+
transactionBase64: record.transactionBase64,
|
|
1099
|
+
encoding: record.encoding,
|
|
1100
|
+
submit: record.submit === true,
|
|
1101
|
+
skipPreflight: record.skipPreflight,
|
|
1102
|
+
maxRetries: record.maxRetries,
|
|
1103
|
+
confirmationTimeoutMs: record.confirmationTimeoutMs,
|
|
1104
|
+
commitment: record.commitment,
|
|
1105
|
+
submitViaRelay: record.submitViaRelay !== false,
|
|
1106
|
+
submitRelayUrl: record.submitRelayUrl,
|
|
1107
|
+
confirm: record.confirm === true,
|
|
1108
|
+
signerProfile: typeof record.signerProfile === 'string' ? record.signerProfile : undefined,
|
|
1109
|
+
intentId: record.intentId,
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
412
1112
|
function formatPaidCallError(error) {
|
|
413
1113
|
const message = error instanceof Error ? error.message : String(error);
|
|
414
1114
|
const retryable = isRetryablePaymentError(message);
|
|
@@ -426,6 +1126,39 @@ function formatPaidCallError(error) {
|
|
|
426
1126
|
};
|
|
427
1127
|
return JSON.stringify(payload, null, 2);
|
|
428
1128
|
}
|
|
1129
|
+
function formatLocalRegistryError(error) {
|
|
1130
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1131
|
+
const normalized = message.toLowerCase();
|
|
1132
|
+
const signerMissing = normalized.includes('no local signer') || normalized.includes('no signer configured');
|
|
1133
|
+
const retryable = isRetryablePaymentError(message);
|
|
1134
|
+
const category = signerMissing
|
|
1135
|
+
? 'local_signer_missing'
|
|
1136
|
+
: 'local_registry_write_failed';
|
|
1137
|
+
return JSON.stringify({
|
|
1138
|
+
success: false,
|
|
1139
|
+
error: message,
|
|
1140
|
+
retryable,
|
|
1141
|
+
category,
|
|
1142
|
+
hostedX402Charged: false,
|
|
1143
|
+
agentInstruction: 'For SAP agent registration or profile updates from hosted-user setups, call sap_payments_register_agent or sap_payments_update_agent from the local sap_payments bridge. Do not retry hosted sap_register_agent/sap_update_agent after hosted_local_signer_required, and do not create temporary signing scripts or read keypair JSON.',
|
|
1144
|
+
nextAction: signerMissing
|
|
1145
|
+
? 'Call sap_payments_readiness. If signerConfigured is false, run the SAP MCP wizard full setup or repair flow and restart the agent runtime.'
|
|
1146
|
+
: 'Check the registry fields, local profile, SOL fee balance, and SAP program/RPC status. Retry the matching sap_payments registry tool only after explicit user confirmation.',
|
|
1147
|
+
}, null, 2);
|
|
1148
|
+
}
|
|
1149
|
+
function formatFinalizeTransactionError(error) {
|
|
1150
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1151
|
+
return JSON.stringify({
|
|
1152
|
+
success: false,
|
|
1153
|
+
error: message,
|
|
1154
|
+
retryable: isRetryablePaymentError(message),
|
|
1155
|
+
category: message.toLowerCase().includes('no local signer') || message.toLowerCase().includes('no signer')
|
|
1156
|
+
? 'local_signer_missing'
|
|
1157
|
+
: 'local_transaction_finalization_failed',
|
|
1158
|
+
agentInstruction: 'Do not create temporary signing scripts, do not read keypair JSON, and do not call hosted sap_sign_transaction for user-owned signatures. Use sap_payments_finalize_transaction from the local sap_payments bridge. For submit:true, prefer the default hosted submit relay unless the user explicitly requests local RPC submission.',
|
|
1159
|
+
nextAction: 'Call sap_payments_readiness. If the local signer is ready, retry sap_payments_finalize_transaction with confirm: true, submit: true, and the same transaction only when retrySafe is true or the prior attempt never submitted. If readiness says missing bridge or signer, run the wizard repair flow.',
|
|
1160
|
+
}, null, 2);
|
|
1161
|
+
}
|
|
429
1162
|
function isRetryablePaymentError(message) {
|
|
430
1163
|
const normalized = message.toLowerCase();
|
|
431
1164
|
const retryablePatterns = [
|