@naturalpay/sdk 0.1.4 → 0.2.1
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/CHANGELOG.md +119 -0
- package/LICENSE +7 -0
- package/README.md +340 -26
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +255 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +255 -0
- package/client.d.ts.map +1 -0
- package/client.js +548 -0
- package/client.js.map +1 -0
- package/client.mjs +544 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +2 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +2 -0
- package/error.d.ts.map +1 -0
- package/error.js +6 -0
- package/error.js.map +1 -0
- package/error.mjs +2 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +6 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +30 -0
- package/index.js.map +1 -0
- package/index.mjs +7 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +20 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +20 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +40 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +37 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/internal/request-options.d.mts +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +87 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +81 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/query.d.mts +2 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +10 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +6 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +8 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +8 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +12 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +9 -0
- package/internal/utils.mjs.map +1 -0
- package/lib/envelope.d.mts +4 -0
- package/lib/envelope.d.mts.map +1 -0
- package/lib/envelope.d.ts +4 -0
- package/lib/envelope.d.ts.map +1 -0
- package/lib/envelope.js +43 -0
- package/lib/envelope.js.map +1 -0
- package/lib/envelope.mjs +39 -0
- package/lib/envelope.mjs.map +1 -0
- package/package.json +142 -76
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +6 -0
- package/resource.js.map +1 -0
- package/resource.mjs +2 -0
- package/resource.mjs.map +1 -0
- package/resources/agents.d.mts +1392 -0
- package/resources/agents.d.mts.map +1 -0
- package/resources/agents.d.ts +1392 -0
- package/resources/agents.d.ts.map +1 -0
- package/resources/agents.js +192 -0
- package/resources/agents.js.map +1 -0
- package/resources/agents.mjs +188 -0
- package/resources/agents.mjs.map +1 -0
- package/resources/api-keys.d.mts +539 -0
- package/resources/api-keys.d.mts.map +1 -0
- package/resources/api-keys.d.ts +539 -0
- package/resources/api-keys.d.ts.map +1 -0
- package/resources/api-keys.js +100 -0
- package/resources/api-keys.js.map +1 -0
- package/resources/api-keys.mjs +96 -0
- package/resources/api-keys.mjs.map +1 -0
- package/resources/counterparties.d.mts +139 -0
- package/resources/counterparties.d.mts.map +1 -0
- package/resources/counterparties.d.ts +139 -0
- package/resources/counterparties.d.ts.map +1 -0
- package/resources/counterparties.js +32 -0
- package/resources/counterparties.js.map +1 -0
- package/resources/counterparties.mjs +28 -0
- package/resources/counterparties.mjs.map +1 -0
- package/resources/customers.d.mts +272 -0
- package/resources/customers.d.mts.map +1 -0
- package/resources/customers.d.ts +272 -0
- package/resources/customers.d.ts.map +1 -0
- package/resources/customers.js +48 -0
- package/resources/customers.js.map +1 -0
- package/resources/customers.mjs +44 -0
- package/resources/customers.mjs.map +1 -0
- package/resources/delegations.d.mts +458 -0
- package/resources/delegations.d.mts.map +1 -0
- package/resources/delegations.d.ts +458 -0
- package/resources/delegations.d.ts.map +1 -0
- package/resources/delegations.js +47 -0
- package/resources/delegations.js.map +1 -0
- package/resources/delegations.mjs +43 -0
- package/resources/delegations.mjs.map +1 -0
- package/resources/index.d.mts +12 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +12 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +27 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +13 -0
- package/resources/index.mjs.map +1 -0
- package/resources/invitations.d.mts +304 -0
- package/resources/invitations.d.mts.map +1 -0
- package/resources/invitations.d.ts +304 -0
- package/resources/invitations.d.ts.map +1 -0
- package/resources/invitations.js +85 -0
- package/resources/invitations.js.map +1 -0
- package/resources/invitations.mjs +81 -0
- package/resources/invitations.mjs.map +1 -0
- package/resources/parties.d.mts +364 -0
- package/resources/parties.d.mts.map +1 -0
- package/resources/parties.d.ts +364 -0
- package/resources/parties.d.ts.map +1 -0
- package/resources/parties.js +78 -0
- package/resources/parties.js.map +1 -0
- package/resources/parties.mjs +74 -0
- package/resources/parties.mjs.map +1 -0
- package/resources/payment-requests.d.mts +442 -0
- package/resources/payment-requests.d.mts.map +1 -0
- package/resources/payment-requests.d.ts +442 -0
- package/resources/payment-requests.d.ts.map +1 -0
- package/resources/payment-requests.js +87 -0
- package/resources/payment-requests.js.map +1 -0
- package/resources/payment-requests.mjs +83 -0
- package/resources/payment-requests.mjs.map +1 -0
- package/resources/payments.d.mts +174 -0
- package/resources/payments.d.mts.map +1 -0
- package/resources/payments.d.ts +174 -0
- package/resources/payments.d.ts.map +1 -0
- package/resources/payments.js +40 -0
- package/resources/payments.js.map +1 -0
- package/resources/payments.mjs +36 -0
- package/resources/payments.mjs.map +1 -0
- package/resources/transactions.d.mts +478 -0
- package/resources/transactions.d.mts.map +1 -0
- package/resources/transactions.d.ts +478 -0
- package/resources/transactions.d.ts.map +1 -0
- package/resources/transactions.js +48 -0
- package/resources/transactions.js.map +1 -0
- package/resources/transactions.mjs +44 -0
- package/resources/transactions.mjs.map +1 -0
- package/resources/wallet.d.mts +628 -0
- package/resources/wallet.d.mts.map +1 -0
- package/resources/wallet.d.ts +628 -0
- package/resources/wallet.d.ts.map +1 -0
- package/resources/wallet.js +161 -0
- package/resources/wallet.js.map +1 -0
- package/resources/wallet.mjs +157 -0
- package/resources/wallet.mjs.map +1 -0
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +1020 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +22 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +56 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/internal/request-options.ts +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +93 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +128 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/query.ts +7 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +9 -0
- package/src/lib/.keep +4 -0
- package/src/lib/envelope.ts +32 -0
- package/src/resource.ts +2 -0
- package/src/resources/agents.ts +1785 -0
- package/src/resources/api-keys.ts +743 -0
- package/src/resources/counterparties.ts +187 -0
- package/src/resources/customers.ts +365 -0
- package/src/resources/delegations.ts +580 -0
- package/src/resources/index.ts +95 -0
- package/src/resources/invitations.ts +414 -0
- package/src/resources/parties.ts +493 -0
- package/src/resources/payment-requests.ts +601 -0
- package/src/resources/payments.ts +228 -0
- package/src/resources/transactions.ts +610 -0
- package/src/resources/wallet.ts +864 -0
- package/src/resources.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +2 -0
- package/src/version.ts +1 -0
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +2 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +6 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +2 -0
- package/uploads.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
- package/dist/index.cjs +0 -1688
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -879
- package/dist/index.d.ts +0 -879
- package/dist/index.js +0 -1657
- package/dist/index.js.map +0 -1
- package/dist/mcp/cli.cjs +0 -166
- package/dist/mcp/cli.cjs.map +0 -1
- package/dist/mcp/cli.d.cts +0 -1
- package/dist/mcp/cli.d.ts +0 -1
- package/dist/mcp/cli.js +0 -164
- package/dist/mcp/cli.js.map +0 -1
- package/dist/mcp/index.cjs +0 -8
- package/dist/mcp/index.cjs.map +0 -1
- package/dist/mcp/index.d.cts +0 -9
- package/dist/mcp/index.d.ts +0 -9
- package/dist/mcp/index.js +0 -6
- package/dist/mcp/index.js.map +0 -1
package/dist/index.d.ts
DELETED
|
@@ -1,879 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent config and model usage for LLM observability.
|
|
3
|
-
*
|
|
4
|
-
* Tracks static agent configuration (system prompt, tools) and per-request
|
|
5
|
-
* model usage so the observability service can attribute API calls to
|
|
6
|
-
* specific LLM sessions.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Static agent configuration — set once per client, sent to observability.
|
|
10
|
-
*
|
|
11
|
-
* Describes the agent's identity (system prompt and available tools).
|
|
12
|
-
* Model/provider are per-request and belong in ModelUsage.
|
|
13
|
-
*/
|
|
14
|
-
interface AgentConfig {
|
|
15
|
-
systemPrompt: string;
|
|
16
|
-
toolsAvailable: string[];
|
|
17
|
-
}
|
|
18
|
-
interface ModelUsage {
|
|
19
|
-
model?: string;
|
|
20
|
-
provider?: string;
|
|
21
|
-
inputTokens?: number;
|
|
22
|
-
outputTokens?: number;
|
|
23
|
-
toolsCalled?: string[];
|
|
24
|
-
}
|
|
25
|
-
interface AgentConfigDict {
|
|
26
|
-
system_prompt: string;
|
|
27
|
-
tools_available: string[];
|
|
28
|
-
}
|
|
29
|
-
interface ModelUsageDict {
|
|
30
|
-
model?: string;
|
|
31
|
-
provider?: string;
|
|
32
|
-
input_tokens?: number;
|
|
33
|
-
output_tokens?: number;
|
|
34
|
-
tools_called?: string[];
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* SHA-256 hash for change detection.
|
|
38
|
-
*
|
|
39
|
-
* Covers only {system_prompt, tools_available} — model/provider
|
|
40
|
-
* are dynamic per-request and excluded from the config hash.
|
|
41
|
-
*/
|
|
42
|
-
declare function configHash(cfg: AgentConfig): string;
|
|
43
|
-
declare function agentConfigToDict(cfg: AgentConfig): AgentConfigDict;
|
|
44
|
-
declare function modelUsageToDict(usage: ModelUsage): ModelUsageDict;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* HTTP client for Natural Server API with JWT caching.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Parse an API key and return its environment label.
|
|
52
|
-
*
|
|
53
|
-
* Accepts keys matching `sk_ntl_(dev|sandbox|prod)_*`. Throws
|
|
54
|
-
* `InvalidRequestError` for anything else. The return type is a narrowed
|
|
55
|
-
* literal union so callers can discriminate on the env without a second
|
|
56
|
-
* parse.
|
|
57
|
-
*/
|
|
58
|
-
declare function parseApiKeyEnv(key: string): 'dev' | 'sandbox' | 'prod';
|
|
59
|
-
/**
|
|
60
|
-
* Validate that a base URL uses HTTPS, with a localhost auto-allow and an
|
|
61
|
-
* `NATURAL_ALLOW_HTTP=1` escape hatch for non-localhost plaintext hosts.
|
|
62
|
-
*
|
|
63
|
-
* Throws `InvalidRequestError` if the URL is not HTTPS and neither escape
|
|
64
|
-
* hatch applies. Runs at client construction, not per-request.
|
|
65
|
-
*/
|
|
66
|
-
declare function validateBaseUrl(baseUrl: string): void;
|
|
67
|
-
interface HTTPClientOptions {
|
|
68
|
-
apiKey?: string;
|
|
69
|
-
baseUrl?: string;
|
|
70
|
-
timeout?: number;
|
|
71
|
-
agentConfig?: AgentConfig;
|
|
72
|
-
/** Default model/provider sent with every request as X-Model-Usage. */
|
|
73
|
-
defaultModelUsage?: Pick<ModelUsage, 'model' | 'provider'>;
|
|
74
|
-
maxRetries?: number;
|
|
75
|
-
}
|
|
76
|
-
interface RequestOptions {
|
|
77
|
-
body?: Record<string, unknown>;
|
|
78
|
-
params?: Record<string, unknown>;
|
|
79
|
-
headers?: Record<string, string>;
|
|
80
|
-
modelUsage?: ModelUsage;
|
|
81
|
-
}
|
|
82
|
-
declare class HTTPClient {
|
|
83
|
-
private readonly apiKey;
|
|
84
|
-
private readonly baseUrl;
|
|
85
|
-
private readonly timeout;
|
|
86
|
-
private readonly maxRetries;
|
|
87
|
-
private readonly jwtCache;
|
|
88
|
-
private readonly agentConfig?;
|
|
89
|
-
private readonly _defaultModelUsage?;
|
|
90
|
-
private _configResolved;
|
|
91
|
-
private _configAttempted;
|
|
92
|
-
private _registerConfigPromise;
|
|
93
|
-
private _nextRetryAt;
|
|
94
|
-
private _retryBackoffMs;
|
|
95
|
-
private static readonly MAX_RETRY_BACKOFF_MS;
|
|
96
|
-
constructor(options?: HTTPClientOptions);
|
|
97
|
-
/**
|
|
98
|
-
* Get a cached JWT or exchange API key for a new one.
|
|
99
|
-
* Retries on transient failures (5xx, network) but not on 401.
|
|
100
|
-
*/
|
|
101
|
-
private getJwt;
|
|
102
|
-
/**
|
|
103
|
-
* Build URL with query parameters.
|
|
104
|
-
*/
|
|
105
|
-
private buildUrl;
|
|
106
|
-
/**
|
|
107
|
-
* Handle API response and throw appropriate errors.
|
|
108
|
-
*/
|
|
109
|
-
private handleResponse;
|
|
110
|
-
/**
|
|
111
|
-
* Register agent config with the observability service.
|
|
112
|
-
*
|
|
113
|
-
* Called lazily before the first request. Errors are caught and logged,
|
|
114
|
-
* never thrown.
|
|
115
|
-
*/
|
|
116
|
-
private registerConfig;
|
|
117
|
-
/**
|
|
118
|
-
* Add agent config hash and model usage headers if configured.
|
|
119
|
-
*/
|
|
120
|
-
private injectModelContextHeaders;
|
|
121
|
-
/**
|
|
122
|
-
* Make an authenticated request with automatic retries.
|
|
123
|
-
*/
|
|
124
|
-
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
125
|
-
get<T>(path: string, options?: Omit<RequestOptions, 'body'>): Promise<T>;
|
|
126
|
-
post<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
127
|
-
put<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
128
|
-
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Base resource class.
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
declare abstract class BaseResource {
|
|
136
|
-
protected readonly http: HTTPClient;
|
|
137
|
-
constructor(http: HTTPClient);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Payment types.
|
|
142
|
-
*/
|
|
143
|
-
interface PaymentCreateParams {
|
|
144
|
-
/** Agent ID (agt_xxx) for agent-initiated payments. */
|
|
145
|
-
agentId?: string;
|
|
146
|
-
/** Payment amount in minor units (cents). 5000 = $50.00. */
|
|
147
|
-
amount: number;
|
|
148
|
-
customerPartyId: string;
|
|
149
|
-
/** Recipient email, phone number, or party ID (pty_xxx). */
|
|
150
|
-
recipient: string;
|
|
151
|
-
/** Payment memo/description. */
|
|
152
|
-
memo: string;
|
|
153
|
-
/** Currency code (default: USD). */
|
|
154
|
-
currency?: string;
|
|
155
|
-
idempotencyKey: string;
|
|
156
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
157
|
-
instanceId?: string;
|
|
158
|
-
/** Trace ID for distributed tracing correlation. */
|
|
159
|
-
traceId?: string;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Transaction types.
|
|
164
|
-
*/
|
|
165
|
-
/**
|
|
166
|
-
* Filter for transaction types in list operations.
|
|
167
|
-
*/
|
|
168
|
-
declare enum TransactionTypeFilter {
|
|
169
|
-
PAYMENT = "payment",
|
|
170
|
-
TRANSFER = "transfer",
|
|
171
|
-
ALL = "all"
|
|
172
|
-
}
|
|
173
|
-
interface Transaction {
|
|
174
|
-
transactionId: string;
|
|
175
|
-
amount: number;
|
|
176
|
-
currency: string;
|
|
177
|
-
status: string;
|
|
178
|
-
description?: string;
|
|
179
|
-
memo?: string;
|
|
180
|
-
createdAt: string;
|
|
181
|
-
updatedAt?: string;
|
|
182
|
-
isDelegated: boolean;
|
|
183
|
-
customerName?: string;
|
|
184
|
-
customerAgentId?: string;
|
|
185
|
-
senderName?: string;
|
|
186
|
-
recipientName?: string;
|
|
187
|
-
transactionType: string;
|
|
188
|
-
category: string;
|
|
189
|
-
direction: string;
|
|
190
|
-
sourcePartyId?: string;
|
|
191
|
-
destinationPartyId?: string;
|
|
192
|
-
sourceWalletId?: string;
|
|
193
|
-
destinationWalletId?: string;
|
|
194
|
-
/** Internal instance ID (ins_xxx) assigned by server. */
|
|
195
|
-
instanceId?: string;
|
|
196
|
-
/** Claim link URL for unclaimed payments. */
|
|
197
|
-
claimLink?: string;
|
|
198
|
-
}
|
|
199
|
-
interface TransactionGetParams {
|
|
200
|
-
/** Customer party ID (pty_xxx) for delegated transaction lookup. */
|
|
201
|
-
customerPartyId?: string;
|
|
202
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
203
|
-
agentId?: string;
|
|
204
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
205
|
-
instanceId?: string;
|
|
206
|
-
/** Trace ID for distributed tracing correlation. */
|
|
207
|
-
traceId?: string;
|
|
208
|
-
}
|
|
209
|
-
interface TransactionListParams {
|
|
210
|
-
limit?: number;
|
|
211
|
-
cursor?: string;
|
|
212
|
-
agentId?: string;
|
|
213
|
-
/** Filter by transaction type (payment, transfer, or all) */
|
|
214
|
-
type?: TransactionTypeFilter;
|
|
215
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
216
|
-
instanceId?: string;
|
|
217
|
-
/** Trace ID for distributed tracing correlation. */
|
|
218
|
-
traceId?: string;
|
|
219
|
-
}
|
|
220
|
-
interface TransactionListResponse {
|
|
221
|
-
transactions: Transaction[];
|
|
222
|
-
hasMore: boolean;
|
|
223
|
-
nextCursor?: string | null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Payments resource.
|
|
228
|
-
*/
|
|
229
|
-
|
|
230
|
-
declare class PaymentsResource extends BaseResource {
|
|
231
|
-
/**
|
|
232
|
-
* Create a payment.
|
|
233
|
-
*
|
|
234
|
-
* @param params - Payment creation parameters
|
|
235
|
-
* @returns Transaction object with transaction_id (txn_*), status, etc.
|
|
236
|
-
*/
|
|
237
|
-
create(params: PaymentCreateParams): Promise<Transaction>;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Wallet types.
|
|
242
|
-
*/
|
|
243
|
-
interface AmountInfo {
|
|
244
|
-
amountMinor: number;
|
|
245
|
-
}
|
|
246
|
-
interface BalanceBreakdown {
|
|
247
|
-
operatingFunded: AmountInfo;
|
|
248
|
-
operatingAdvanced: AmountInfo;
|
|
249
|
-
escrowFundedSettled: AmountInfo;
|
|
250
|
-
escrowAdvanced: AmountInfo;
|
|
251
|
-
holdsOutbound: AmountInfo;
|
|
252
|
-
}
|
|
253
|
-
interface AccountBalance {
|
|
254
|
-
walletId: string;
|
|
255
|
-
breakdown: BalanceBreakdown;
|
|
256
|
-
available: AmountInfo;
|
|
257
|
-
pendingClaimAmountMinor?: number;
|
|
258
|
-
pendingClaimCount?: number;
|
|
259
|
-
}
|
|
260
|
-
interface BalanceOptions {
|
|
261
|
-
/** Customer party ID (pty_xxx) when acting on behalf of customer. */
|
|
262
|
-
customerPartyId?: string;
|
|
263
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
264
|
-
agentId?: string;
|
|
265
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
266
|
-
instanceId?: string;
|
|
267
|
-
/** Trace ID for distributed tracing correlation. */
|
|
268
|
-
traceId?: string;
|
|
269
|
-
}
|
|
270
|
-
interface WithdrawParams {
|
|
271
|
-
/** Withdrawal amount in minor units (cents). 5000 = $50.00. */
|
|
272
|
-
amount: number;
|
|
273
|
-
/** ID of the linked bank account (efs_xxx). */
|
|
274
|
-
externalFundingSourceId: string;
|
|
275
|
-
currency?: string;
|
|
276
|
-
description?: string;
|
|
277
|
-
idempotencyKey: string;
|
|
278
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
279
|
-
agentId?: string;
|
|
280
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
281
|
-
instanceId?: string;
|
|
282
|
-
/** Trace ID for distributed tracing correlation. */
|
|
283
|
-
traceId?: string;
|
|
284
|
-
}
|
|
285
|
-
interface WithdrawResponse {
|
|
286
|
-
transferId?: string;
|
|
287
|
-
instructionId?: string;
|
|
288
|
-
status: string;
|
|
289
|
-
amount: number;
|
|
290
|
-
currency: string;
|
|
291
|
-
estimatedSettlement?: string;
|
|
292
|
-
kycRequired: boolean;
|
|
293
|
-
kycStatus?: string;
|
|
294
|
-
kycSessionUrl?: string;
|
|
295
|
-
mfaRequired: boolean;
|
|
296
|
-
mfaChallengeId?: string;
|
|
297
|
-
mfaExpiresAt?: string;
|
|
298
|
-
error?: string;
|
|
299
|
-
errorDetails?: string;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Wallet resource.
|
|
304
|
-
*/
|
|
305
|
-
|
|
306
|
-
declare class WalletResource extends BaseResource {
|
|
307
|
-
/**
|
|
308
|
-
* Get current wallet balance.
|
|
309
|
-
*
|
|
310
|
-
* @returns AccountBalance with available, current, pending amounts
|
|
311
|
-
*/
|
|
312
|
-
balance(options?: BalanceOptions): Promise<AccountBalance>;
|
|
313
|
-
/**
|
|
314
|
-
* Initiate a withdrawal to a linked bank account.
|
|
315
|
-
*
|
|
316
|
-
* @param params - Withdrawal parameters
|
|
317
|
-
* @returns WithdrawResponse with transfer status (may require KYC/MFA)
|
|
318
|
-
*/
|
|
319
|
-
withdraw(params: WithdrawParams): Promise<WithdrawResponse>;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Transactions resource.
|
|
324
|
-
*/
|
|
325
|
-
|
|
326
|
-
declare class TransactionsResource extends BaseResource {
|
|
327
|
-
/**
|
|
328
|
-
* Get a transaction by ID.
|
|
329
|
-
*
|
|
330
|
-
* @param transactionId - Transaction ID (txn_xxx)
|
|
331
|
-
* @param params - Optional parameters for observability
|
|
332
|
-
* @returns Transaction details
|
|
333
|
-
*/
|
|
334
|
-
get(transactionId: string, params?: TransactionGetParams): Promise<Transaction>;
|
|
335
|
-
/**
|
|
336
|
-
* List recent transactions.
|
|
337
|
-
*
|
|
338
|
-
* @param params - List parameters including agent context
|
|
339
|
-
* @returns TransactionListResponse with transactions and pagination info
|
|
340
|
-
*/
|
|
341
|
-
list(params?: TransactionListParams): Promise<TransactionListResponse>;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Agent types.
|
|
346
|
-
*/
|
|
347
|
-
type AgentStatus = 'ACTIVE' | 'REVOKED';
|
|
348
|
-
interface TransactionLimits {
|
|
349
|
-
perTransaction?: number;
|
|
350
|
-
}
|
|
351
|
-
interface Agent {
|
|
352
|
-
id: string;
|
|
353
|
-
name: string;
|
|
354
|
-
description?: string;
|
|
355
|
-
status: AgentStatus;
|
|
356
|
-
partyId: string;
|
|
357
|
-
createdAt?: string;
|
|
358
|
-
createdBy?: string;
|
|
359
|
-
updatedAt?: string;
|
|
360
|
-
updatedBy?: string;
|
|
361
|
-
}
|
|
362
|
-
interface AgentCreateParams {
|
|
363
|
-
name: string;
|
|
364
|
-
description?: string;
|
|
365
|
-
limits?: TransactionLimits;
|
|
366
|
-
idempotencyKey?: string;
|
|
367
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
368
|
-
agentId?: string;
|
|
369
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
370
|
-
instanceId?: string;
|
|
371
|
-
/** Trace ID for distributed tracing correlation. */
|
|
372
|
-
traceId?: string;
|
|
373
|
-
}
|
|
374
|
-
/** @deprecated Use Agent instead — server returns full resource for all operations. */
|
|
375
|
-
type AgentCreateResponse = Agent;
|
|
376
|
-
interface AgentUpdateParams {
|
|
377
|
-
name?: string;
|
|
378
|
-
description?: string;
|
|
379
|
-
status?: AgentStatus;
|
|
380
|
-
idempotencyKey?: string;
|
|
381
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
382
|
-
agentId?: string;
|
|
383
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
384
|
-
instanceId?: string;
|
|
385
|
-
/** Trace ID for distributed tracing correlation. */
|
|
386
|
-
traceId?: string;
|
|
387
|
-
}
|
|
388
|
-
/** @deprecated Use Agent instead — server returns full resource for all operations. */
|
|
389
|
-
type AgentUpdateResponse = Agent;
|
|
390
|
-
interface AgentListParams {
|
|
391
|
-
status?: AgentStatus;
|
|
392
|
-
limit?: number;
|
|
393
|
-
cursor?: string;
|
|
394
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
395
|
-
agentId?: string;
|
|
396
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
397
|
-
instanceId?: string;
|
|
398
|
-
/** Trace ID for distributed tracing correlation. */
|
|
399
|
-
traceId?: string;
|
|
400
|
-
}
|
|
401
|
-
interface AgentGetOptions {
|
|
402
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
403
|
-
agentId?: string;
|
|
404
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
405
|
-
instanceId?: string;
|
|
406
|
-
/** Trace ID for distributed tracing correlation. */
|
|
407
|
-
traceId?: string;
|
|
408
|
-
}
|
|
409
|
-
interface AgentDeleteOptions {
|
|
410
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
411
|
-
agentId?: string;
|
|
412
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
413
|
-
instanceId?: string;
|
|
414
|
-
/** Trace ID for distributed tracing correlation. */
|
|
415
|
-
traceId?: string;
|
|
416
|
-
}
|
|
417
|
-
interface AgentListResponse {
|
|
418
|
-
agents: Agent[];
|
|
419
|
-
hasMore: boolean;
|
|
420
|
-
nextCursor?: string | null;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Agents resource.
|
|
425
|
-
*/
|
|
426
|
-
|
|
427
|
-
declare class AgentsResource extends BaseResource {
|
|
428
|
-
/**
|
|
429
|
-
* List agents for the partner.
|
|
430
|
-
*
|
|
431
|
-
* @param params - Filter and pagination parameters
|
|
432
|
-
* @returns AgentListResponse with list of agents
|
|
433
|
-
*/
|
|
434
|
-
list(params?: AgentListParams): Promise<AgentListResponse>;
|
|
435
|
-
/**
|
|
436
|
-
* Get agent by ID.
|
|
437
|
-
*
|
|
438
|
-
* @param agentId - The agent ID to retrieve (agt_xxx)
|
|
439
|
-
* @returns Agent details
|
|
440
|
-
*/
|
|
441
|
-
get(agentId: string, options?: AgentGetOptions): Promise<Agent>;
|
|
442
|
-
/**
|
|
443
|
-
* Create a new agent.
|
|
444
|
-
*
|
|
445
|
-
* @param params - Agent creation parameters
|
|
446
|
-
* @returns AgentCreateResponse with created agent details
|
|
447
|
-
*/
|
|
448
|
-
create(params: AgentCreateParams): Promise<AgentCreateResponse>;
|
|
449
|
-
/**
|
|
450
|
-
* Update an existing agent.
|
|
451
|
-
*
|
|
452
|
-
* @param agentId - The agent ID to update (agt_xxx)
|
|
453
|
-
* @param params - Update parameters
|
|
454
|
-
* @returns AgentUpdateResponse with updated agent details
|
|
455
|
-
*/
|
|
456
|
-
update(agentId: string, params: AgentUpdateParams): Promise<AgentUpdateResponse>;
|
|
457
|
-
/**
|
|
458
|
-
* Delete an agent.
|
|
459
|
-
*
|
|
460
|
-
* @param agentId - The agent ID to delete (agt_xxx)
|
|
461
|
-
* @param options - Optional observability parameters
|
|
462
|
-
*/
|
|
463
|
-
delete(agentId: string, options?: AgentDeleteOptions): Promise<void>;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Agent delegation types.
|
|
468
|
-
*/
|
|
469
|
-
interface AgentDelegation {
|
|
470
|
-
id: string;
|
|
471
|
-
agentName?: string;
|
|
472
|
-
agentId: string;
|
|
473
|
-
delegationId: string;
|
|
474
|
-
delegatorPartyId?: string;
|
|
475
|
-
delegateePartyId?: string;
|
|
476
|
-
delegatorPartyName?: string;
|
|
477
|
-
delegateePartyName?: string;
|
|
478
|
-
permissions: string[];
|
|
479
|
-
limits?: Record<string, number>;
|
|
480
|
-
expiresAt?: string;
|
|
481
|
-
createdAt: string;
|
|
482
|
-
createdBy?: string;
|
|
483
|
-
updatedAt: string;
|
|
484
|
-
}
|
|
485
|
-
interface AgentDelegationListParams {
|
|
486
|
-
delegationId?: string;
|
|
487
|
-
agentId?: string;
|
|
488
|
-
delegatorPartyId?: string;
|
|
489
|
-
delegateePartyId?: string;
|
|
490
|
-
includeRevoked?: boolean;
|
|
491
|
-
limit?: number;
|
|
492
|
-
cursor?: string;
|
|
493
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
494
|
-
instanceId?: string;
|
|
495
|
-
/** Trace ID for distributed tracing correlation. */
|
|
496
|
-
traceId?: string;
|
|
497
|
-
}
|
|
498
|
-
interface AgentDelegationListResponse {
|
|
499
|
-
agentDelegations: AgentDelegation[];
|
|
500
|
-
hasMore: boolean;
|
|
501
|
-
nextCursor?: string | null;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Agent delegations resource.
|
|
506
|
-
*/
|
|
507
|
-
|
|
508
|
-
declare class DelegationsResource extends BaseResource {
|
|
509
|
-
/**
|
|
510
|
-
* List agent delegations with optional filters.
|
|
511
|
-
*
|
|
512
|
-
* @param params - Filter parameters
|
|
513
|
-
* @returns AgentDelegationListResponse with list of agent delegations
|
|
514
|
-
*/
|
|
515
|
-
list(params?: AgentDelegationListParams): Promise<AgentDelegationListResponse>;
|
|
516
|
-
/**
|
|
517
|
-
* Get agent delegation by ID.
|
|
518
|
-
*
|
|
519
|
-
* @param agentDelegationId - The agent delegation handle (adl_xxx)
|
|
520
|
-
* @returns AgentDelegation details
|
|
521
|
-
*/
|
|
522
|
-
get(agentDelegationId: string): Promise<AgentDelegation>;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Customer types.
|
|
527
|
-
*/
|
|
528
|
-
interface CustomerPartyInfo {
|
|
529
|
-
id: string;
|
|
530
|
-
name: string;
|
|
531
|
-
email?: string;
|
|
532
|
-
}
|
|
533
|
-
interface Customer {
|
|
534
|
-
id: string;
|
|
535
|
-
type: 'party' | 'delegationInvitation';
|
|
536
|
-
party?: CustomerPartyInfo;
|
|
537
|
-
email?: string;
|
|
538
|
-
status: string;
|
|
539
|
-
permissions: string[];
|
|
540
|
-
createdAt: string;
|
|
541
|
-
walletAvailableMinor?: number;
|
|
542
|
-
walletAvailableDollars?: string;
|
|
543
|
-
walletAccess: 'granted' | 'denied' | 'noWallet';
|
|
544
|
-
}
|
|
545
|
-
interface CustomerListParams {
|
|
546
|
-
limit?: number;
|
|
547
|
-
cursor?: string;
|
|
548
|
-
/** Agent ID (agt_xxx) for observability attribution. */
|
|
549
|
-
agentId?: string;
|
|
550
|
-
/** Developer's session/conversation ID for observability grouping. */
|
|
551
|
-
instanceId?: string;
|
|
552
|
-
/** Trace ID for distributed tracing correlation. */
|
|
553
|
-
traceId?: string;
|
|
554
|
-
}
|
|
555
|
-
interface CustomerListResponse {
|
|
556
|
-
items: Customer[];
|
|
557
|
-
hasMore: boolean;
|
|
558
|
-
nextCursor?: string | null;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Customers resource.
|
|
563
|
-
*/
|
|
564
|
-
|
|
565
|
-
declare class CustomersResource extends BaseResource {
|
|
566
|
-
/**
|
|
567
|
-
* List customers who have delegated access to the partner.
|
|
568
|
-
*
|
|
569
|
-
* @param params - Pagination parameters
|
|
570
|
-
* @returns CustomerListResponse with items, hasMore, nextCursor
|
|
571
|
-
*/
|
|
572
|
-
list(params?: CustomerListParams): Promise<CustomerListResponse>;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Natural Payments SDK client.
|
|
577
|
-
*/
|
|
578
|
-
|
|
579
|
-
interface NaturalClientOptions extends HTTPClientOptions {
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Natural Payments SDK client.
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
* ```typescript
|
|
586
|
-
* import { NaturalClient } from '@naturalpay/sdk';
|
|
587
|
-
*
|
|
588
|
-
* const client = new NaturalClient({ apiKey: process.env['NATURAL_API_KEY'] });
|
|
589
|
-
*
|
|
590
|
-
* // Create a payment
|
|
591
|
-
* const payment = await client.payments.create({
|
|
592
|
-
* agentId: 'agt_xxx',
|
|
593
|
-
* amount: 5000,
|
|
594
|
-
* customerPartyId: 'pty_xxx',
|
|
595
|
-
* recipient: 'alice@example.com',
|
|
596
|
-
* memo: 'For consulting',
|
|
597
|
-
* idempotencyKey: 'unique-key-for-this-payment',
|
|
598
|
-
* });
|
|
599
|
-
*
|
|
600
|
-
* // Check balance
|
|
601
|
-
* const balance = await client.wallet.balance();
|
|
602
|
-
* ```
|
|
603
|
-
*/
|
|
604
|
-
declare class NaturalClient {
|
|
605
|
-
private readonly http;
|
|
606
|
-
/** Payments API resource. */
|
|
607
|
-
readonly payments: PaymentsResource;
|
|
608
|
-
/** Wallet API resource for balance and withdrawals. */
|
|
609
|
-
readonly wallet: WalletResource;
|
|
610
|
-
/** Transactions API resource. */
|
|
611
|
-
readonly transactions: TransactionsResource;
|
|
612
|
-
/** Agents API resource for managing agents. */
|
|
613
|
-
readonly agents: AgentsResource;
|
|
614
|
-
/** Agent delegations API resource. */
|
|
615
|
-
readonly delegations: DelegationsResource;
|
|
616
|
-
/** Customers API resource for listing parties who delegated access. */
|
|
617
|
-
readonly customers: CustomersResource;
|
|
618
|
-
/**
|
|
619
|
-
* Initialize the Natural client.
|
|
620
|
-
*
|
|
621
|
-
* @param options - Client configuration options
|
|
622
|
-
* @param options.apiKey - API key (defaults to NATURAL_API_KEY env var)
|
|
623
|
-
* @param options.baseUrl - API base URL (defaults to https://api.natural.co)
|
|
624
|
-
* @param options.timeout - Request timeout in milliseconds (default: 30000)
|
|
625
|
-
*/
|
|
626
|
-
constructor(options?: NaturalClientOptions);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/** Branded string types for observability IDs */
|
|
630
|
-
type InstanceId = string & {
|
|
631
|
-
readonly __brand: 'InstanceId';
|
|
632
|
-
};
|
|
633
|
-
type TraceId = string & {
|
|
634
|
-
readonly __brand: 'TraceId';
|
|
635
|
-
};
|
|
636
|
-
type ToolCallId = string & {
|
|
637
|
-
readonly __brand: 'ToolCallId';
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Tool call context for MCP server -> HTTP layer communication.
|
|
642
|
-
*
|
|
643
|
-
* The MCP server sets tool call data (id + name + arguments) before invoking
|
|
644
|
-
* SDK methods. The HTTP layer reads it and sends the X-Tool-Call header to the
|
|
645
|
-
* BFF for audit/observability. Direct SDK users never interact with this module.
|
|
646
|
-
*/
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Generate a unique tool call ID with the `tc_` prefix.
|
|
650
|
-
*/
|
|
651
|
-
declare function generateToolCallId(): ToolCallId;
|
|
652
|
-
/**
|
|
653
|
-
* Get the base64-encoded X-Tool-Call header value, or undefined if not in
|
|
654
|
-
* a tool call context.
|
|
655
|
-
*
|
|
656
|
-
* If the full header (with arguments) exceeds 16 KB, the arguments are
|
|
657
|
-
* omitted and a warning is logged.
|
|
658
|
-
*/
|
|
659
|
-
declare function getToolCallHeader(): string | undefined;
|
|
660
|
-
/**
|
|
661
|
-
* Run a function within a tool call context. The HTTP layer will automatically
|
|
662
|
-
* pick up the tool call data and send it as the X-Tool-Call header.
|
|
663
|
-
*
|
|
664
|
-
* @param toolCallId - Unique ID for this invocation (tc_<uuid>).
|
|
665
|
-
* @param name - Tool name (e.g. "create_payment").
|
|
666
|
-
* @param args - Raw tool arguments.
|
|
667
|
-
* @param fn - The function to execute within the context.
|
|
668
|
-
*/
|
|
669
|
-
declare function runWithToolCall<T>(toolCallId: ToolCallId, name: string, args: Record<string, unknown>, fn: () => T): T;
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Structured logging for Natural Payments SDK.
|
|
673
|
-
*
|
|
674
|
-
* Supports two modes:
|
|
675
|
-
* 1. Plain text logging (default, for local development)
|
|
676
|
-
* 2. JSON logging with Datadog correlation (when NATURAL_LOG_FORMAT=json)
|
|
677
|
-
*
|
|
678
|
-
* Features:
|
|
679
|
-
* - Source info: file, line, function on every log (for error grouping)
|
|
680
|
-
* - Context binding for request_id, agent_id, instance_id
|
|
681
|
-
* - Datadog trace correlation fields
|
|
682
|
-
* - AsyncLocalStorage for proper async context isolation
|
|
683
|
-
*/
|
|
684
|
-
type LogLevel = 'debug' | 'info' | 'warning' | 'error';
|
|
685
|
-
/**
|
|
686
|
-
* Get the current logging context.
|
|
687
|
-
* Uses AsyncLocalStorage if available, falls back to global context.
|
|
688
|
-
*/
|
|
689
|
-
declare function getContext(): Record<string, unknown>;
|
|
690
|
-
/**
|
|
691
|
-
* Bind additional context to current scope (e.g., request_id, agent_id).
|
|
692
|
-
*
|
|
693
|
-
* Values are sanitized to prevent log injection attacks.
|
|
694
|
-
* Updates both AsyncLocalStorage (if active) and global context.
|
|
695
|
-
*
|
|
696
|
-
* @example
|
|
697
|
-
* bindContext({ requestId: 'req_123', agentId: 'agt_456' });
|
|
698
|
-
* logger.info('Processing payment'); // Will include requestId and agentId
|
|
699
|
-
*/
|
|
700
|
-
declare function bindContext(context: Record<string, unknown>): void;
|
|
701
|
-
/**
|
|
702
|
-
* Clear all bound context.
|
|
703
|
-
*/
|
|
704
|
-
declare function clearContext(): void;
|
|
705
|
-
/**
|
|
706
|
-
* Run a function with isolated logging context.
|
|
707
|
-
*
|
|
708
|
-
* Context bound within the callback is isolated from other async operations.
|
|
709
|
-
* This is the recommended way to set context for request handling.
|
|
710
|
-
*
|
|
711
|
-
* @example
|
|
712
|
-
* await runWithContext({ requestId: 'req_123' }, async () => {
|
|
713
|
-
* logger.info('Processing request'); // Includes requestId
|
|
714
|
-
* await doAsyncWork();
|
|
715
|
-
* logger.info('Request complete'); // Still includes requestId
|
|
716
|
-
* });
|
|
717
|
-
*/
|
|
718
|
-
declare function runWithContext<T>(context: Record<string, unknown>, fn: () => T | Promise<T>): T | Promise<T>;
|
|
719
|
-
/**
|
|
720
|
-
* Configure logging for the Natural SDK.
|
|
721
|
-
*
|
|
722
|
-
* @param options - Logging configuration options
|
|
723
|
-
* @param options.level - Log level (debug, info, warning, error)
|
|
724
|
-
* @param options.jsonFormat - Use JSON format (default: auto-detect from NATURAL_LOG_FORMAT env var)
|
|
725
|
-
* @param options.serviceName - Service name for structured logs
|
|
726
|
-
*
|
|
727
|
-
* Environment variables:
|
|
728
|
-
* - NATURAL_LOG_LEVEL: Override log level (DEBUG, INFO, WARNING, ERROR)
|
|
729
|
-
* - NATURAL_LOG_FORMAT: Set to "json" for JSON output, "text" for plain text
|
|
730
|
-
*/
|
|
731
|
-
declare function configureLogging(options?: {
|
|
732
|
-
level?: LogLevel;
|
|
733
|
-
jsonFormat?: boolean;
|
|
734
|
-
serviceName?: string;
|
|
735
|
-
}): void;
|
|
736
|
-
/**
|
|
737
|
-
* Logger instance for a specific module/context.
|
|
738
|
-
*/
|
|
739
|
-
declare class Logger {
|
|
740
|
-
private readonly name;
|
|
741
|
-
constructor(name: string);
|
|
742
|
-
private log;
|
|
743
|
-
debug(message: string, extra?: Record<string, unknown>): void;
|
|
744
|
-
info(message: string, extra?: Record<string, unknown>): void;
|
|
745
|
-
warning(message: string, extra?: Record<string, unknown>): void;
|
|
746
|
-
warn(message: string, extra?: Record<string, unknown>): void;
|
|
747
|
-
error(message: string, extra?: Record<string, unknown>): void;
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Get a logger for the given module name.
|
|
751
|
-
*
|
|
752
|
-
* @param name - Module name (e.g., 'naturalpay.http')
|
|
753
|
-
* @returns Logger instance
|
|
754
|
-
*
|
|
755
|
-
* @example
|
|
756
|
-
* const logger = getLogger('naturalpay.payments');
|
|
757
|
-
* logger.info('Payment initiated', { amount: 10000 });
|
|
758
|
-
*/
|
|
759
|
-
declare function getLogger(name: string): Logger;
|
|
760
|
-
/**
|
|
761
|
-
* Log an error with full context and exception info.
|
|
762
|
-
*/
|
|
763
|
-
declare function logError(logger: Logger, message: string, options?: {
|
|
764
|
-
error?: Error;
|
|
765
|
-
statusCode?: number;
|
|
766
|
-
code?: string;
|
|
767
|
-
[key: string]: unknown;
|
|
768
|
-
}): void;
|
|
769
|
-
/**
|
|
770
|
-
* Log an API call with standard fields.
|
|
771
|
-
*/
|
|
772
|
-
declare function logApiCall(logger: Logger, method: string, path: string, options?: {
|
|
773
|
-
statusCode?: number;
|
|
774
|
-
durationMs?: number;
|
|
775
|
-
error?: Error;
|
|
776
|
-
[key: string]: unknown;
|
|
777
|
-
}): void;
|
|
778
|
-
/**
|
|
779
|
-
* Log an MCP tool invocation.
|
|
780
|
-
*/
|
|
781
|
-
declare function logToolCall(logger: Logger, toolName: string, options?: {
|
|
782
|
-
success?: boolean;
|
|
783
|
-
durationMs?: number;
|
|
784
|
-
error?: Error;
|
|
785
|
-
[key: string]: unknown;
|
|
786
|
-
}): void;
|
|
787
|
-
|
|
788
|
-
/**
|
|
789
|
-
* Natural Payments SDK error classes.
|
|
790
|
-
*/
|
|
791
|
-
/**
|
|
792
|
-
* Base error for all Natural SDK errors.
|
|
793
|
-
*/
|
|
794
|
-
declare class NaturalError extends Error {
|
|
795
|
-
readonly statusCode?: number;
|
|
796
|
-
readonly code?: string;
|
|
797
|
-
constructor(message: string, options?: {
|
|
798
|
-
statusCode?: number;
|
|
799
|
-
code?: string;
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Invalid or missing API key.
|
|
804
|
-
*/
|
|
805
|
-
declare class AuthenticationError extends NaturalError {
|
|
806
|
-
constructor(message?: string);
|
|
807
|
-
}
|
|
808
|
-
/**
|
|
809
|
-
* Malformed request parameters.
|
|
810
|
-
*/
|
|
811
|
-
declare class InvalidRequestError extends NaturalError {
|
|
812
|
-
constructor(message: string, code?: string);
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Payment-specific failure.
|
|
816
|
-
*/
|
|
817
|
-
declare class PaymentError extends NaturalError {
|
|
818
|
-
constructor(message: string, code?: string);
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Not enough balance for payment.
|
|
822
|
-
*/
|
|
823
|
-
declare class InsufficientFundsError extends PaymentError {
|
|
824
|
-
constructor(message?: string);
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Invalid recipient.
|
|
828
|
-
*/
|
|
829
|
-
declare class RecipientNotFoundError extends PaymentError {
|
|
830
|
-
constructor(message?: string);
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* Too many requests.
|
|
834
|
-
*/
|
|
835
|
-
declare class RateLimitError extends NaturalError {
|
|
836
|
-
readonly retryAfter?: number;
|
|
837
|
-
constructor(message?: string, retryAfter?: number);
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Internal server error.
|
|
841
|
-
*/
|
|
842
|
-
declare class ServerError extends NaturalError {
|
|
843
|
-
constructor(message?: string);
|
|
844
|
-
}
|
|
845
|
-
/**
|
|
846
|
-
* Webhook signature verification failed.
|
|
847
|
-
*/
|
|
848
|
-
declare class WebhookVerificationError extends NaturalError {
|
|
849
|
-
constructor(message: string);
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* Webhook signature verification using Standard Webhooks HMAC-SHA256.
|
|
854
|
-
*/
|
|
855
|
-
interface VerifyWebhookOptions {
|
|
856
|
-
toleranceInSeconds?: number;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* Verify a webhook signature using Standard Webhooks HMAC-SHA256.
|
|
860
|
-
*
|
|
861
|
-
* The body must be the raw request body — not a parsed and re-serialized
|
|
862
|
-
* JSON object, as whitespace or key ordering differences would produce a
|
|
863
|
-
* different signature.
|
|
864
|
-
*
|
|
865
|
-
* @param body - Raw request body (string, Buffer, or Uint8Array)
|
|
866
|
-
* @param headers - Request headers containing webhook-id, webhook-timestamp, webhook-signature
|
|
867
|
-
* @param secret - Signing secret (with or without whsec_ prefix)
|
|
868
|
-
* @param options - Optional configuration (toleranceInSeconds)
|
|
869
|
-
* @returns Parsed JSON payload
|
|
870
|
-
* @throws WebhookVerificationError on any verification failure
|
|
871
|
-
*/
|
|
872
|
-
declare function verifyWebhookSignature(body: string | Buffer | Uint8Array, headers: Record<string, string> | Headers, secret: string, options?: VerifyWebhookOptions): unknown;
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Single source of truth for the SDK version string.
|
|
876
|
-
*/
|
|
877
|
-
declare const VERSION = "0.1.4";
|
|
878
|
-
|
|
879
|
-
export { type AccountBalance, type Agent, type AgentConfig, type AgentConfigDict, type AgentCreateParams, type AgentCreateResponse, type AgentDelegation, type AgentDelegationListParams, type AgentDelegationListResponse, type AgentDeleteOptions, type AgentGetOptions, type AgentListParams, type AgentListResponse, type AgentStatus, type AgentUpdateParams, type AgentUpdateResponse, type AmountInfo, AuthenticationError, type BalanceBreakdown, type Customer, type CustomerListParams, type CustomerListResponse, type CustomerPartyInfo, type InstanceId, InsufficientFundsError, InvalidRequestError, type LogLevel, Logger, type ModelUsage, type ModelUsageDict, NaturalClient, type NaturalClientOptions, NaturalError, type PaymentCreateParams, PaymentError, RateLimitError, RecipientNotFoundError, ServerError, type ToolCallId, type TraceId, type Transaction, type TransactionGetParams, type TransactionListParams, type TransactionListResponse, TransactionTypeFilter, VERSION, type VerifyWebhookOptions, WebhookVerificationError, type WithdrawParams, type WithdrawResponse, agentConfigToDict, bindContext, clearContext, configHash, configureLogging, generateToolCallId, getContext, getLogger, getToolCallHeader, logApiCall, logError, logToolCall, modelUsageToDict, parseApiKeyEnv, runWithContext, runWithToolCall, validateBaseUrl, verifyWebhookSignature };
|