@lorikeetai/node-sdk 1.8.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -782
- package/README.md +114 -44
- 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/bin/cli +53 -0
- package/bin/migration-config.json +50 -0
- package/client.d.mts +197 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +197 -0
- package/client.d.ts.map +1 -0
- package/client.js +504 -0
- package/client.js.map +1 -0
- package/client.mjs +500 -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 +1 -46
- package/error.d.ts.map +1 -1
- package/error.js +3 -110
- package/error.js.map +1 -1
- package/error.mjs +1 -96
- package/error.mjs.map +1 -1
- package/index.d.mts +7 -131
- package/index.d.mts.map +1 -0
- package/index.d.ts +6 -130
- package/index.d.ts.map +1 -1
- package/index.js +14 -142
- package/index.js.map +1 -1
- package/index.mjs +6 -114
- package/index.mjs.map +1 -1
- 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/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 +92 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +89 -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 +86 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +80 -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/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 +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/lib/generate-signature.d.mts +7 -0
- package/lib/generate-signature.d.mts.map +1 -0
- package/lib/generate-signature.d.ts +1 -1
- package/lib/generate-signature.d.ts.map +1 -1
- package/lib/generate-signature.js +3 -3
- package/lib/generate-signature.js.map +1 -1
- package/lib/generate-signature.mjs +1 -1
- package/lib/generate-signature.mjs.map +1 -1
- package/lib/poll-until.d.mts +20 -0
- package/lib/poll-until.d.mts.map +1 -0
- package/lib/poll-until.d.ts.map +1 -1
- package/lib/promise.d.mts +55 -0
- package/lib/promise.d.mts.map +1 -0
- package/package.json +123 -73
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +1 -5
- package/resource.d.ts.map +1 -1
- package/resource.js +3 -8
- package/resource.js.map +1 -1
- package/resource.mjs +1 -6
- package/resource.mjs.map +1 -1
- package/resources/api-keys.d.mts +130 -0
- package/resources/api-keys.d.mts.map +1 -0
- package/resources/api-keys.d.ts +7 -6
- package/resources/api-keys.d.ts.map +1 -1
- package/resources/api-keys.js +6 -4
- package/resources/api-keys.js.map +1 -1
- package/resources/api-keys.mjs +6 -4
- package/resources/api-keys.mjs.map +1 -1
- package/resources/conversation/chat.d.mts +312 -0
- package/resources/conversation/chat.d.mts.map +1 -0
- package/resources/conversation/chat.d.ts +45 -77
- package/resources/conversation/chat.d.ts.map +1 -1
- package/resources/conversation/chat.js +14 -48
- package/resources/conversation/chat.js.map +1 -1
- package/resources/conversation/chat.mjs +14 -48
- package/resources/conversation/chat.mjs.map +1 -1
- package/resources/conversation/conversation.d.mts +77 -0
- package/resources/conversation/conversation.d.mts.map +1 -0
- package/resources/conversation/conversation.d.ts +1 -1
- package/resources/conversation/conversation.d.ts.map +1 -1
- package/resources/conversation/conversation.js +5 -27
- package/resources/conversation/conversation.js.map +1 -1
- package/resources/conversation/conversation.mjs +1 -1
- package/resources/conversation/email.d.mts +257 -0
- package/resources/conversation/email.d.mts.map +1 -0
- package/resources/conversation/email.d.ts +10 -8
- package/resources/conversation/email.d.ts.map +1 -1
- package/resources/conversation/email.js +6 -6
- package/resources/conversation/email.js.map +1 -1
- package/resources/conversation/email.mjs +6 -6
- package/resources/conversation/email.mjs.map +1 -1
- package/resources/conversation/index.d.mts +5 -0
- package/resources/conversation/index.d.mts.map +1 -0
- package/resources/conversation/index.d.ts +1 -1
- package/resources/conversation/index.d.ts.map +1 -1
- package/resources/conversation/index.js.map +1 -1
- package/resources/conversation/index.mjs.map +1 -1
- package/resources/conversation/voice.d.mts +45 -0
- package/resources/conversation/voice.d.mts.map +1 -0
- package/resources/conversation/voice.d.ts +4 -3
- package/resources/conversation/voice.d.ts.map +1 -1
- package/resources/conversation/voice.js +3 -2
- package/resources/conversation/voice.js.map +1 -1
- package/resources/conversation/voice.mjs +3 -2
- package/resources/conversation/voice.mjs.map +1 -1
- package/resources/conversation.d.mts +2 -0
- package/resources/conversation.d.mts.map +1 -0
- package/resources/conversation.d.ts.map +1 -1
- package/resources/conversation.js +2 -15
- package/resources/conversation.js.map +1 -1
- package/resources/customer/customer.d.mts +333 -0
- package/resources/customer/customer.d.mts.map +1 -0
- package/resources/customer/customer.d.ts +7 -7
- package/resources/customer/customer.d.ts.map +1 -1
- package/resources/customer/customer.js +12 -31
- package/resources/customer/customer.js.map +1 -1
- package/resources/customer/customer.mjs +9 -6
- package/resources/customer/customer.mjs.map +1 -1
- package/resources/customer/index.d.mts +4 -0
- package/resources/customer/index.d.mts.map +1 -0
- package/resources/customer/index.d.ts.map +1 -1
- package/resources/customer/profile.d.mts +30 -0
- package/resources/customer/profile.d.mts.map +1 -0
- package/resources/customer/profile.d.ts +4 -3
- package/resources/customer/profile.d.ts.map +1 -1
- package/resources/customer/profile.js +3 -2
- package/resources/customer/profile.js.map +1 -1
- package/resources/customer/profile.mjs +3 -2
- package/resources/customer/profile.mjs.map +1 -1
- package/resources/customer/remote.d.mts +164 -0
- package/resources/customer/remote.d.mts.map +1 -0
- package/resources/customer/remote.d.ts +5 -4
- package/resources/customer/remote.d.ts.map +1 -1
- package/resources/customer/remote.js +6 -5
- package/resources/customer/remote.js.map +1 -1
- package/resources/customer/remote.mjs +6 -5
- package/resources/customer/remote.mjs.map +1 -1
- package/resources/customer.d.mts +2 -0
- package/resources/customer.d.mts.map +1 -0
- package/resources/customer.d.ts.map +1 -1
- package/resources/customer.js +2 -15
- package/resources/customer.js.map +1 -1
- package/resources/index.d.mts +5 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/ingest.d.mts +27 -0
- package/resources/ingest.d.mts.map +1 -0
- package/resources/ingest.d.ts +12 -6
- package/resources/ingest.d.ts.map +1 -1
- package/resources/ingest.js +11 -8
- package/resources/ingest.js.map +1 -1
- package/resources/ingest.mjs +11 -8
- package/resources/ingest.mjs.map +1 -1
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts.map +1 -1
- package/resources.js +2 -15
- package/resources.js.map +1 -1
- package/src/api-promise.ts +2 -0
- package/src/client.ts +835 -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 -130
- package/src/index.ts +6 -275
- 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/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 +156 -0
- package/src/internal/types.ts +95 -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 +127 -0
- package/src/internal/utils/path.ts +88 -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 +8 -0
- package/src/lib/generate-signature.ts +2 -2
- package/src/resource.ts +2 -11
- package/src/resources/api-keys.ts +12 -9
- package/src/resources/conversation/chat.ts +60 -95
- package/src/resources/conversation/conversation.ts +1 -1
- package/src/resources/conversation/email.ts +13 -12
- package/src/resources/conversation/index.ts +5 -0
- package/src/resources/conversation/voice.ts +6 -4
- package/src/resources/customer/customer.ts +12 -16
- package/src/resources/customer/profile.ts +6 -8
- package/src/resources/customer/remote.ts +10 -8
- package/src/resources/index.ts +1 -1
- package/src/resources/ingest.ts +23 -17
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +2 -256
- package/src/version.ts +1 -1
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +1 -74
- package/uploads.d.ts.map +1 -1
- package/uploads.js +3 -167
- package/uploads.js.map +1 -1
- package/uploads.mjs +1 -156
- package/uploads.mjs.map +1 -1
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/_shims/MultipartBody.d.ts +0 -9
- package/_shims/MultipartBody.d.ts.map +0 -1
- package/_shims/MultipartBody.js +0 -16
- package/_shims/MultipartBody.js.map +0 -1
- package/_shims/MultipartBody.mjs +0 -12
- package/_shims/MultipartBody.mjs.map +0 -1
- package/_shims/README.md +0 -46
- package/_shims/auto/runtime-bun.d.ts +0 -5
- package/_shims/auto/runtime-bun.d.ts.map +0 -1
- package/_shims/auto/runtime-bun.js +0 -21
- package/_shims/auto/runtime-bun.js.map +0 -1
- package/_shims/auto/runtime-bun.mjs +0 -2
- package/_shims/auto/runtime-bun.mjs.map +0 -1
- package/_shims/auto/runtime-node.d.ts +0 -5
- package/_shims/auto/runtime-node.d.ts.map +0 -1
- package/_shims/auto/runtime-node.js +0 -21
- package/_shims/auto/runtime-node.js.map +0 -1
- package/_shims/auto/runtime-node.mjs +0 -2
- package/_shims/auto/runtime-node.mjs.map +0 -1
- package/_shims/auto/runtime.d.ts +0 -5
- package/_shims/auto/runtime.d.ts.map +0 -1
- package/_shims/auto/runtime.js +0 -21
- package/_shims/auto/runtime.js.map +0 -1
- package/_shims/auto/runtime.mjs +0 -2
- package/_shims/auto/runtime.mjs.map +0 -1
- package/_shims/auto/types-node.d.ts +0 -5
- package/_shims/auto/types-node.d.ts.map +0 -1
- package/_shims/auto/types-node.js +0 -21
- package/_shims/auto/types-node.js.map +0 -1
- package/_shims/auto/types-node.mjs +0 -2
- package/_shims/auto/types-node.mjs.map +0 -1
- package/_shims/auto/types.d.ts +0 -101
- package/_shims/auto/types.js +0 -3
- package/_shims/auto/types.mjs +0 -3
- package/_shims/bun-runtime.d.ts +0 -6
- package/_shims/bun-runtime.d.ts.map +0 -1
- package/_shims/bun-runtime.js +0 -13
- package/_shims/bun-runtime.js.map +0 -1
- package/_shims/bun-runtime.mjs +0 -10
- package/_shims/bun-runtime.mjs.map +0 -1
- package/_shims/index.d.ts +0 -83
- package/_shims/index.js +0 -17
- package/_shims/index.mjs +0 -11
- package/_shims/manual-types.d.ts +0 -12
- package/_shims/manual-types.js +0 -3
- package/_shims/manual-types.mjs +0 -3
- package/_shims/node-runtime.d.ts +0 -3
- package/_shims/node-runtime.d.ts.map +0 -1
- package/_shims/node-runtime.js +0 -88
- package/_shims/node-runtime.js.map +0 -1
- package/_shims/node-runtime.mjs +0 -56
- package/_shims/node-runtime.mjs.map +0 -1
- package/_shims/node-types.d.ts +0 -42
- package/_shims/node-types.js +0 -3
- package/_shims/node-types.mjs +0 -3
- package/_shims/registry.d.ts +0 -37
- package/_shims/registry.d.ts.map +0 -1
- package/_shims/registry.js +0 -41
- package/_shims/registry.js.map +0 -1
- package/_shims/registry.mjs +0 -37
- package/_shims/registry.mjs.map +0 -1
- package/_shims/web-runtime.d.ts +0 -5
- package/_shims/web-runtime.d.ts.map +0 -1
- package/_shims/web-runtime.js +0 -77
- package/_shims/web-runtime.js.map +0 -1
- package/_shims/web-runtime.mjs +0 -71
- package/_shims/web-runtime.mjs.map +0 -1
- package/_shims/web-types.d.ts +0 -83
- package/_shims/web-types.js +0 -3
- package/_shims/web-types.mjs +0 -3
- package/core.d.ts +0 -253
- package/core.d.ts.map +0 -1
- package/core.js +0 -929
- package/core.js.map +0 -1
- package/core.mjs +0 -897
- package/core.mjs.map +0 -1
- package/internal/qs/formats.d.ts +0 -6
- package/internal/qs/formats.d.ts.map +0 -1
- package/internal/qs/formats.js +0 -11
- package/internal/qs/formats.js.map +0 -1
- package/internal/qs/formats.mjs +0 -8
- package/internal/qs/formats.mjs.map +0 -1
- package/internal/qs/index.d.ts +0 -10
- package/internal/qs/index.d.ts.map +0 -1
- package/internal/qs/index.js +0 -14
- package/internal/qs/index.js.map +0 -1
- package/internal/qs/index.mjs +0 -10
- package/internal/qs/index.mjs.map +0 -1
- package/internal/qs/stringify.d.ts +0 -3
- package/internal/qs/stringify.d.ts.map +0 -1
- package/internal/qs/stringify.js +0 -279
- package/internal/qs/stringify.js.map +0 -1
- package/internal/qs/stringify.mjs +0 -276
- package/internal/qs/stringify.mjs.map +0 -1
- package/internal/qs/types.d.ts +0 -57
- package/internal/qs/types.d.ts.map +0 -1
- package/internal/qs/types.js +0 -3
- package/internal/qs/types.js.map +0 -1
- package/internal/qs/types.mjs +0 -2
- package/internal/qs/types.mjs.map +0 -1
- package/internal/qs/utils.d.ts +0 -14
- package/internal/qs/utils.d.ts.map +0 -1
- package/internal/qs/utils.js +0 -229
- package/internal/qs/utils.js.map +0 -1
- package/internal/qs/utils.mjs +0 -217
- package/internal/qs/utils.mjs.map +0 -1
- package/resources/ticket.d.ts +0 -14
- package/resources/ticket.d.ts.map +0 -1
- package/resources/ticket.js +0 -16
- package/resources/ticket.js.map +0 -1
- package/resources/ticket.mjs +0 -12
- package/resources/ticket.mjs.map +0 -1
- package/shims/node.d.ts +0 -26
- package/shims/node.d.ts.map +0 -1
- package/shims/node.js +0 -6
- package/shims/node.js.map +0 -1
- package/shims/node.mjs +0 -4
- package/shims/node.mjs.map +0 -1
- package/shims/web.d.ts +0 -26
- package/shims/web.d.ts.map +0 -1
- package/shims/web.js +0 -6
- package/shims/web.js.map +0 -1
- package/shims/web.mjs +0 -4
- package/shims/web.mjs.map +0 -1
- package/src/_shims/MultipartBody.ts +0 -9
- package/src/_shims/README.md +0 -46
- package/src/_shims/auto/runtime-bun.ts +0 -4
- package/src/_shims/auto/runtime-node.ts +0 -4
- package/src/_shims/auto/runtime.ts +0 -4
- package/src/_shims/auto/types-node.ts +0 -4
- package/src/_shims/auto/types.d.ts +0 -101
- package/src/_shims/auto/types.js +0 -3
- package/src/_shims/auto/types.mjs +0 -3
- package/src/_shims/bun-runtime.ts +0 -14
- package/src/_shims/index.d.ts +0 -83
- package/src/_shims/index.js +0 -17
- package/src/_shims/index.mjs +0 -11
- package/src/_shims/manual-types.d.ts +0 -12
- package/src/_shims/manual-types.js +0 -3
- package/src/_shims/manual-types.mjs +0 -3
- package/src/_shims/node-runtime.ts +0 -81
- package/src/_shims/node-types.d.ts +0 -42
- package/src/_shims/node-types.js +0 -3
- package/src/_shims/node-types.mjs +0 -3
- package/src/_shims/registry.ts +0 -67
- package/src/_shims/web-runtime.ts +0 -103
- package/src/_shims/web-types.d.ts +0 -83
- package/src/_shims/web-types.js +0 -3
- package/src/_shims/web-types.mjs +0 -3
- package/src/core.ts +0 -1242
- package/src/internal/qs/LICENSE.md +0 -13
- package/src/internal/qs/README.md +0 -3
- package/src/internal/qs/formats.ts +0 -9
- package/src/internal/qs/index.ts +0 -13
- package/src/internal/qs/stringify.ts +0 -388
- package/src/internal/qs/types.ts +0 -71
- package/src/internal/qs/utils.ts +0 -265
- package/src/resources/ticket.ts +0 -30
- package/src/shims/node.ts +0 -50
- package/src/shims/web.ts +0 -50
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { APIResource } from "../../core/resource.mjs";
|
|
2
|
+
import * as ConversationAPI from "./conversation.mjs";
|
|
3
|
+
import { APIPromise } from "../../core/api-promise.mjs";
|
|
4
|
+
import { RequestOptions } from "../../internal/request-options.mjs";
|
|
5
|
+
export declare class Chat extends APIResource {
|
|
6
|
+
/**
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const response = await client.conversation.chat.generate({
|
|
10
|
+
* attachments: [
|
|
11
|
+
* {
|
|
12
|
+
* name: 'example.jpg',
|
|
13
|
+
* type: 'image/jpeg',
|
|
14
|
+
* url: 'https://example.com/example.jpg',
|
|
15
|
+
* },
|
|
16
|
+
* ],
|
|
17
|
+
* conversationId: 'conversationId',
|
|
18
|
+
* message: 'message',
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
generate(body: ChatGenerateParams, options?: RequestOptions): APIPromise<ChatGenerateResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const chat = await client.conversation.chat.get({
|
|
27
|
+
* conversationId: 'conversationId',
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
get(query: ChatGetParams, options?: RequestOptions): APIPromise<ChatGetResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const response = await client.conversation.chat.start({
|
|
36
|
+
* customerId: 'customerId',
|
|
37
|
+
* publicKey: 'publicKey',
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
start(body: ChatStartParams, options?: RequestOptions): APIPromise<ChatStartResponse>;
|
|
42
|
+
/**
|
|
43
|
+
* Send a message and poll until a response is ready.
|
|
44
|
+
*
|
|
45
|
+
* This is a convenience wrapper that calls {@link Chat.generate} then {@link Chat.poll}.
|
|
46
|
+
*/
|
|
47
|
+
message(body: ChatGenerateParams, options?: RequestOptions): APIPromise<ChatGetResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Poll until the conversation has a bot response ready.
|
|
50
|
+
*
|
|
51
|
+
* Stops when `latestMessageType` is `BOT_RESPONSE` or `PENDING_RESPONSE`,
|
|
52
|
+
* or when `status` is `Escalated` or `Error`.
|
|
53
|
+
*/
|
|
54
|
+
poll(query: ChatGetParams, options?: RequestOptions): APIPromise<ChatGetResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Create a persistent stream of updates for a conversation.
|
|
57
|
+
*
|
|
58
|
+
* Responses from the bot will arrive as events. Consuming clients must aggregate
|
|
59
|
+
* multiple chunks into a single message based on the `messageId` field.
|
|
60
|
+
*
|
|
61
|
+
* This stream is open indefinitely and does not automatically close — avoid
|
|
62
|
+
* blocking other operations while listening to events from this generator.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* for await (const evt of client.conversation.chat.streamUpdates({ conversationId: 'abc123' })) {
|
|
67
|
+
* console.log(evt);
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
streamUpdates(params: ChatStreamParams): AsyncIterable<ChatStreamEvent>;
|
|
72
|
+
}
|
|
73
|
+
export interface ChatGenerateResponse {
|
|
74
|
+
/**
|
|
75
|
+
* The ID of the conversation
|
|
76
|
+
*/
|
|
77
|
+
conversationId: string;
|
|
78
|
+
/**
|
|
79
|
+
* The timestamp of the when the conversation was created in our system.
|
|
80
|
+
*/
|
|
81
|
+
createdAt: string;
|
|
82
|
+
/**
|
|
83
|
+
* The events that have occurred in the conversation. Can be used for deriving more
|
|
84
|
+
* information about the conversation.
|
|
85
|
+
*/
|
|
86
|
+
events: Array<ConversationAPI.TicketEvent>;
|
|
87
|
+
/**
|
|
88
|
+
* The latest message type - useful for polling
|
|
89
|
+
*/
|
|
90
|
+
latestMessageType: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | null;
|
|
91
|
+
/**
|
|
92
|
+
* The url of the conversation in the Lorikeet dashboard
|
|
93
|
+
*/
|
|
94
|
+
link: string;
|
|
95
|
+
/**
|
|
96
|
+
* The full list of messages. This endpoint supports markdown.
|
|
97
|
+
*/
|
|
98
|
+
messages: Array<ConversationAPI.TicketMessageDto>;
|
|
99
|
+
/**
|
|
100
|
+
* The status of the conversation
|
|
101
|
+
*/
|
|
102
|
+
status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
|
|
103
|
+
/**
|
|
104
|
+
* The tags of the conversation
|
|
105
|
+
*/
|
|
106
|
+
tags: Array<string>;
|
|
107
|
+
/**
|
|
108
|
+
* The timestamp of when the ticket was last updated in our system.
|
|
109
|
+
*/
|
|
110
|
+
updatedAt: string;
|
|
111
|
+
}
|
|
112
|
+
export interface ChatGetResponse {
|
|
113
|
+
/**
|
|
114
|
+
* The ID of the conversation
|
|
115
|
+
*/
|
|
116
|
+
conversationId: string;
|
|
117
|
+
/**
|
|
118
|
+
* The timestamp of the when the conversation was created in our system.
|
|
119
|
+
*/
|
|
120
|
+
createdAt: string;
|
|
121
|
+
/**
|
|
122
|
+
* The events that have occurred in the conversation. Can be used for deriving more
|
|
123
|
+
* information about the conversation.
|
|
124
|
+
*/
|
|
125
|
+
events: Array<ConversationAPI.TicketEvent>;
|
|
126
|
+
/**
|
|
127
|
+
* The latest message type - useful for polling
|
|
128
|
+
*/
|
|
129
|
+
latestMessageType: 'CUSTOMER' | 'BOT_RESPONSE' | 'PENDING_RESPONSE' | 'DRAFT_RESPONSE' | null;
|
|
130
|
+
/**
|
|
131
|
+
* The url of the conversation in the Lorikeet dashboard
|
|
132
|
+
*/
|
|
133
|
+
link: string;
|
|
134
|
+
/**
|
|
135
|
+
* The full list of messages. This endpoint supports markdown.
|
|
136
|
+
*/
|
|
137
|
+
messages: Array<ConversationAPI.TicketMessageDto>;
|
|
138
|
+
/**
|
|
139
|
+
* The status of the conversation
|
|
140
|
+
*/
|
|
141
|
+
status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
|
|
142
|
+
/**
|
|
143
|
+
* The tags of the conversation
|
|
144
|
+
*/
|
|
145
|
+
tags: Array<string>;
|
|
146
|
+
/**
|
|
147
|
+
* The timestamp of when the ticket was last updated in our system.
|
|
148
|
+
*/
|
|
149
|
+
updatedAt: string;
|
|
150
|
+
}
|
|
151
|
+
export interface ChatStartResponse {
|
|
152
|
+
/**
|
|
153
|
+
* The ID of the conversation
|
|
154
|
+
*/
|
|
155
|
+
conversationId: string;
|
|
156
|
+
/**
|
|
157
|
+
* The timestamp of the when the conversation was created in our system.
|
|
158
|
+
*/
|
|
159
|
+
createdAt: string;
|
|
160
|
+
/**
|
|
161
|
+
* The events that have occurred in the conversation. Can be used for deriving more
|
|
162
|
+
* information about the conversation.
|
|
163
|
+
*/
|
|
164
|
+
events: Array<ConversationAPI.TicketEvent>;
|
|
165
|
+
/**
|
|
166
|
+
* The url of the conversation in the Lorikeet dashboard
|
|
167
|
+
*/
|
|
168
|
+
link: string;
|
|
169
|
+
/**
|
|
170
|
+
* The status of the conversation
|
|
171
|
+
*/
|
|
172
|
+
status: 'Unprocessed' | 'Processing' | 'Unhandled' | 'Responded' | 'Error' | 'Escalated' | 'Processed';
|
|
173
|
+
/**
|
|
174
|
+
* The tags of the conversation
|
|
175
|
+
*/
|
|
176
|
+
tags: Array<string>;
|
|
177
|
+
}
|
|
178
|
+
export interface ChatGenerateParams {
|
|
179
|
+
/**
|
|
180
|
+
* Attachments to be sent with the message
|
|
181
|
+
*/
|
|
182
|
+
attachments: Array<ConversationAPI.AttachmentDto>;
|
|
183
|
+
/**
|
|
184
|
+
* The ID of the conversation
|
|
185
|
+
*/
|
|
186
|
+
conversationId: string;
|
|
187
|
+
/**
|
|
188
|
+
* The message to be sent to the user (customer or agent). This endpoint supports
|
|
189
|
+
* markdown.
|
|
190
|
+
*/
|
|
191
|
+
message: string;
|
|
192
|
+
/**
|
|
193
|
+
* Any additional customer information, that has changed in the course of the
|
|
194
|
+
* conversation. Required if the message is sent by the customer to the agent. Must
|
|
195
|
+
* be omitted if the message is sent by the agent to the customer.
|
|
196
|
+
*/
|
|
197
|
+
customer?: ChatGenerateParams.Customer;
|
|
198
|
+
/**
|
|
199
|
+
* The variables to be passed to the conversation - this can be used by workflows
|
|
200
|
+
*/
|
|
201
|
+
variables?: {
|
|
202
|
+
[key: string]: unknown;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
export declare namespace ChatGenerateParams {
|
|
206
|
+
/**
|
|
207
|
+
* Any additional customer information, that has changed in the course of the
|
|
208
|
+
* conversation. Required if the message is sent by the customer to the agent. Must
|
|
209
|
+
* be omitted if the message is sent by the agent to the customer.
|
|
210
|
+
*/
|
|
211
|
+
interface Customer {
|
|
212
|
+
/**
|
|
213
|
+
* The URL of the customer avatar
|
|
214
|
+
*/
|
|
215
|
+
avatarUrl?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The display name of the customer
|
|
218
|
+
*/
|
|
219
|
+
displayName?: string;
|
|
220
|
+
/**
|
|
221
|
+
* The email of the customer
|
|
222
|
+
*/
|
|
223
|
+
email?: string;
|
|
224
|
+
/**
|
|
225
|
+
* The first name of the customer
|
|
226
|
+
*/
|
|
227
|
+
firstName?: string;
|
|
228
|
+
/**
|
|
229
|
+
* The last name of the customer
|
|
230
|
+
*/
|
|
231
|
+
lastName?: string;
|
|
232
|
+
/**
|
|
233
|
+
* The phone number of the customer (in international / E.164 format)
|
|
234
|
+
*/
|
|
235
|
+
phoneNumber?: string;
|
|
236
|
+
/**
|
|
237
|
+
* The id of the customer in the ticketing system. For the SDK this needs to be
|
|
238
|
+
* stable and unique
|
|
239
|
+
*/
|
|
240
|
+
remoteId?: string;
|
|
241
|
+
/**
|
|
242
|
+
* The id of the customer in your own primary database or a unique identifier, for
|
|
243
|
+
* example a cookie
|
|
244
|
+
*/
|
|
245
|
+
subscriberCustomerId?: string;
|
|
246
|
+
/**
|
|
247
|
+
* A token that can be used to authenticate the customer in the your system, like a
|
|
248
|
+
* JWT
|
|
249
|
+
*/
|
|
250
|
+
subscriberToken?: string;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
export interface ChatGetParams {
|
|
254
|
+
/**
|
|
255
|
+
* The ID of the conversation you need to poll.
|
|
256
|
+
*/
|
|
257
|
+
conversationId: string;
|
|
258
|
+
}
|
|
259
|
+
export interface ChatStartParams {
|
|
260
|
+
/**
|
|
261
|
+
* The ID of the customer. If omitted, a new customer will be created.
|
|
262
|
+
*/
|
|
263
|
+
customerId: string;
|
|
264
|
+
/**
|
|
265
|
+
* The public key associated with this agent
|
|
266
|
+
*/
|
|
267
|
+
publicKey: string;
|
|
268
|
+
/**
|
|
269
|
+
* The subject of the conversation.
|
|
270
|
+
*/
|
|
271
|
+
subject?: string;
|
|
272
|
+
/**
|
|
273
|
+
* The UUID of the workflow to trigger.
|
|
274
|
+
*/
|
|
275
|
+
workflowId?: string;
|
|
276
|
+
}
|
|
277
|
+
export interface ChatStreamParams {
|
|
278
|
+
/**
|
|
279
|
+
* The ID of the conversation you need to stream.
|
|
280
|
+
*/
|
|
281
|
+
conversationId: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Signal that a new response message has been created and new chunks
|
|
285
|
+
* for this response for the messageId will follow.
|
|
286
|
+
*/
|
|
287
|
+
export interface ChatStreamNewMessageEvent {
|
|
288
|
+
type: 'new-message';
|
|
289
|
+
createdAt: string;
|
|
290
|
+
messageId: string;
|
|
291
|
+
content: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* A chunk of text response for the message with the given messageId.
|
|
295
|
+
*/
|
|
296
|
+
export interface ChatStreamMessageChunkEvent {
|
|
297
|
+
type: 'message-chunk';
|
|
298
|
+
contentDelta: string;
|
|
299
|
+
messageId: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* All chunks for a message have been received and no more chunks will follow for this message.
|
|
303
|
+
*/
|
|
304
|
+
export interface ChatStreamMessageCompleteEvent {
|
|
305
|
+
type: 'message-complete';
|
|
306
|
+
messageId: string;
|
|
307
|
+
}
|
|
308
|
+
export type ChatStreamEvent = ChatStreamNewMessageEvent | ChatStreamMessageChunkEvent | ChatStreamMessageCompleteEvent;
|
|
309
|
+
export declare namespace Chat {
|
|
310
|
+
export { type ChatGenerateResponse as ChatGenerateResponse, type ChatGetResponse as ChatGetResponse, type ChatStartResponse as ChatStartResponse, type ChatGenerateParams as ChatGenerateParams, type ChatGetParams as ChatGetParams, type ChatStartParams as ChatStartParams, type ChatStreamParams as ChatStreamParams, type ChatStreamEvent as ChatStreamEvent, type ChatStreamNewMessageEvent as ChatStreamNewMessageEvent, type ChatStreamMessageChunkEvent as ChatStreamMessageChunkEvent, type ChatStreamMessageCompleteEvent as ChatStreamMessageCompleteEvent, };
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=chat.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,eAAe,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GACvB,yBAAyB,GACzB,2BAA2B,GAC3B,8BAA8B,CAAC;AAEnC,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,8BAA8B,IAAI,8BAA8B,GACtE,CAAC;CACH"}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { APIResource } from "../../resource.js";
|
|
2
|
-
import * as Core from "../../core.js";
|
|
1
|
+
import { APIResource } from "../../core/resource.js";
|
|
3
2
|
import * as ConversationAPI from "./conversation.js";
|
|
3
|
+
import { APIPromise } from "../../core/api-promise.js";
|
|
4
|
+
import { RequestOptions } from "../../internal/request-options.js";
|
|
4
5
|
export declare class Chat extends APIResource {
|
|
5
|
-
/**
|
|
6
|
-
* __chat.generate__
|
|
7
|
-
*
|
|
8
|
-
* Generate a chat message for a conversation. This endpoint will return immediately, polling will be required to get the response.
|
|
9
|
-
*
|
|
10
|
-
* The `latestMessageType` field in the response can be used to determine if the response is ready.
|
|
11
|
-
*
|
|
12
|
-
* If the `latestMessageType` is `BOT_RESPONSE`, the response is ready.
|
|
13
|
-
* For a more ergonomic way to poll, use the `message` method.
|
|
14
|
-
*
|
|
15
|
-
* ** WARNING ** This endpoint is not idempotent. If you call it multiple times, you will generate multiple messages.
|
|
16
|
-
*
|
|
17
|
-
* @see {@link Chat.message}
|
|
18
|
-
*/
|
|
19
6
|
/**
|
|
20
7
|
* @example
|
|
21
8
|
* ```ts
|
|
@@ -32,12 +19,7 @@ export declare class Chat extends APIResource {
|
|
|
32
19
|
* });
|
|
33
20
|
* ```
|
|
34
21
|
*/
|
|
35
|
-
generate(body: ChatGenerateParams, options?:
|
|
36
|
-
/**
|
|
37
|
-
* __chat.get__
|
|
38
|
-
*
|
|
39
|
-
* Returns a chat message for a conversation. This endpoint will return the latest state of the conversation.
|
|
40
|
-
*/
|
|
22
|
+
generate(body: ChatGenerateParams, options?: RequestOptions): APIPromise<ChatGenerateResponse>;
|
|
41
23
|
/**
|
|
42
24
|
* @example
|
|
43
25
|
* ```ts
|
|
@@ -46,16 +28,7 @@ export declare class Chat extends APIResource {
|
|
|
46
28
|
* });
|
|
47
29
|
* ```
|
|
48
30
|
*/
|
|
49
|
-
get(query: ChatGetParams, options?:
|
|
50
|
-
/**
|
|
51
|
-
* __chat.start__
|
|
52
|
-
*
|
|
53
|
-
* Start a chat conversation. This endpoint will return immediately.
|
|
54
|
-
*
|
|
55
|
-
* The `conversationId` field in the response can be used to generate messages.
|
|
56
|
-
*
|
|
57
|
-
* ** WARNING ** This endpoint is not idempotent. If you call it multiple times, you will generate multiple conversations.
|
|
58
|
-
*/
|
|
31
|
+
get(query: ChatGetParams, options?: RequestOptions): APIPromise<ChatGetResponse>;
|
|
59
32
|
/**
|
|
60
33
|
* @example
|
|
61
34
|
* ```ts
|
|
@@ -65,34 +38,29 @@ export declare class Chat extends APIResource {
|
|
|
65
38
|
* });
|
|
66
39
|
* ```
|
|
67
40
|
*/
|
|
68
|
-
start(body: ChatStartParams, options?:
|
|
41
|
+
start(body: ChatStartParams, options?: RequestOptions): APIPromise<ChatStartResponse>;
|
|
69
42
|
/**
|
|
70
|
-
*
|
|
43
|
+
* Send a message and poll until a response is ready.
|
|
71
44
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @see {@link Chat.poll}
|
|
45
|
+
* This is a convenience wrapper that calls {@link Chat.generate} then {@link Chat.poll}.
|
|
75
46
|
*/
|
|
76
|
-
message(body: ChatGenerateParams, options?:
|
|
47
|
+
message(body: ChatGenerateParams, options?: RequestOptions): APIPromise<ChatGetResponse>;
|
|
77
48
|
/**
|
|
78
|
-
*
|
|
49
|
+
* Poll until the conversation has a bot response ready.
|
|
79
50
|
*
|
|
80
|
-
*
|
|
51
|
+
* Stops when `latestMessageType` is `BOT_RESPONSE` or `PENDING_RESPONSE`,
|
|
52
|
+
* or when `status` is `Escalated` or `Error`.
|
|
81
53
|
*/
|
|
82
|
-
poll(query: ChatGetParams, options?:
|
|
54
|
+
poll(query: ChatGetParams, options?: RequestOptions): APIPromise<ChatGetResponse>;
|
|
83
55
|
/**
|
|
84
|
-
* __chat.streamUpdates__
|
|
85
|
-
*
|
|
86
56
|
* Create a persistent stream of updates for a conversation.
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
57
|
+
*
|
|
58
|
+
* Responses from the bot will arrive as events. Consuming clients must aggregate
|
|
59
|
+
* multiple chunks into a single message based on the `messageId` field.
|
|
60
|
+
*
|
|
61
|
+
* This stream is open indefinitely and does not automatically close — avoid
|
|
90
62
|
* blocking other operations while listening to events from this generator.
|
|
91
63
|
*
|
|
92
|
-
* @param params.conversationId - Conversation/ticket ID to subscribe to.
|
|
93
|
-
* @returns AsyncGenerator<ChatStreamEvent> a generator that emits response events as they arrive.
|
|
94
|
-
*/
|
|
95
|
-
/**
|
|
96
64
|
* @example
|
|
97
65
|
* ```ts
|
|
98
66
|
* for await (const evt of client.conversation.chat.streamUpdates({ conversationId: 'abc123' })) {
|
|
@@ -102,32 +70,6 @@ export declare class Chat extends APIResource {
|
|
|
102
70
|
*/
|
|
103
71
|
streamUpdates(params: ChatStreamParams): AsyncIterable<ChatStreamEvent>;
|
|
104
72
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Signal that a new response message has been created and new chunks
|
|
107
|
-
* for this response for the messageId will follow.
|
|
108
|
-
*/
|
|
109
|
-
export interface ChatStreamNewMessageEvent {
|
|
110
|
-
type: 'new-message';
|
|
111
|
-
createdAt: string;
|
|
112
|
-
messageId: string;
|
|
113
|
-
content: string;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* A chunk of text response for the message with the given messageId.
|
|
117
|
-
*/
|
|
118
|
-
export interface ChatStreamMessageChunkEvent {
|
|
119
|
-
type: 'message-chunk';
|
|
120
|
-
contentDelta: string;
|
|
121
|
-
messageId: string;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* All chunks for a message have been received and no more chunks will follow for this message.
|
|
125
|
-
*/
|
|
126
|
-
export interface ChatStreamMessageCompleteEvent {
|
|
127
|
-
type: 'message-complete';
|
|
128
|
-
messageId: string;
|
|
129
|
-
}
|
|
130
|
-
export type ChatStreamEvent = ChatStreamNewMessageEvent | ChatStreamMessageChunkEvent | ChatStreamMessageCompleteEvent;
|
|
131
73
|
export interface ChatGenerateResponse {
|
|
132
74
|
/**
|
|
133
75
|
* The ID of the conversation
|
|
@@ -338,7 +280,33 @@ export interface ChatStreamParams {
|
|
|
338
280
|
*/
|
|
339
281
|
conversationId: string;
|
|
340
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Signal that a new response message has been created and new chunks
|
|
285
|
+
* for this response for the messageId will follow.
|
|
286
|
+
*/
|
|
287
|
+
export interface ChatStreamNewMessageEvent {
|
|
288
|
+
type: 'new-message';
|
|
289
|
+
createdAt: string;
|
|
290
|
+
messageId: string;
|
|
291
|
+
content: string;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* A chunk of text response for the message with the given messageId.
|
|
295
|
+
*/
|
|
296
|
+
export interface ChatStreamMessageChunkEvent {
|
|
297
|
+
type: 'message-chunk';
|
|
298
|
+
contentDelta: string;
|
|
299
|
+
messageId: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* All chunks for a message have been received and no more chunks will follow for this message.
|
|
303
|
+
*/
|
|
304
|
+
export interface ChatStreamMessageCompleteEvent {
|
|
305
|
+
type: 'message-complete';
|
|
306
|
+
messageId: string;
|
|
307
|
+
}
|
|
308
|
+
export type ChatStreamEvent = ChatStreamNewMessageEvent | ChatStreamMessageChunkEvent | ChatStreamMessageCompleteEvent;
|
|
341
309
|
export declare namespace Chat {
|
|
342
|
-
export { type ChatGenerateResponse as ChatGenerateResponse, type ChatGetResponse as ChatGetResponse, type ChatStartResponse as ChatStartResponse, type ChatGenerateParams as ChatGenerateParams, type ChatGetParams as ChatGetParams, type ChatStartParams as ChatStartParams, type ChatStreamParams as ChatStreamParams, };
|
|
310
|
+
export { type ChatGenerateResponse as ChatGenerateResponse, type ChatGetResponse as ChatGetResponse, type ChatStartResponse as ChatStartResponse, type ChatGenerateParams as ChatGenerateParams, type ChatGetParams as ChatGetParams, type ChatStartParams as ChatStartParams, type ChatStreamParams as ChatStreamParams, type ChatStreamEvent as ChatStreamEvent, type ChatStreamNewMessageEvent as ChatStreamNewMessageEvent, type ChatStreamMessageChunkEvent as ChatStreamMessageChunkEvent, type ChatStreamMessageCompleteEvent as ChatStreamMessageCompleteEvent, };
|
|
343
311
|
}
|
|
344
312
|
//# sourceMappingURL=chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/resources/conversation/chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/resources/conversation/chat.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,eAAe;OACpB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAKzB,qBAAa,IAAK,SAAQ,WAAW;IACnC;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;IAI9F;;;;;;;OAOG;IACH,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;IAIhF;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAIrF;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;IAMxF;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC;IAwBjF;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAAC,eAAe,CAAC;CA2CxE;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,EAAE,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAE3C;;OAEG;IACH,iBAAiB,EAAE,UAAU,GAAG,cAAc,GAAG,kBAAkB,GAAG,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AElB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,eAAe,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GACvB,yBAAyB,GACzB,2BAA2B,GAC3B,8BAA8B,CAAC;AAEnC,MAAM,CAAC,OAAO,WAAW,IAAI,CAAC;IAC5B,OAAO,EACL,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,aAAa,IAAI,aAAa,EACnC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,8BAA8B,IAAI,8BAA8B,GACtE,CAAC;CACH"}
|
|
@@ -2,25 +2,11 @@
|
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Chat = void 0;
|
|
5
|
-
const resource_1 = require("../../resource.js");
|
|
6
|
-
const poll_until_1 = require("
|
|
5
|
+
const resource_1 = require("../../core/resource.js");
|
|
6
|
+
const poll_until_1 = require("../../lib/poll-until.js");
|
|
7
|
+
const promise_1 = require("../../lib/promise.js");
|
|
7
8
|
const eventsource_1 = require("eventsource");
|
|
8
|
-
const promise_1 = require("@lorikeetai/node-sdk/lib/promise");
|
|
9
9
|
class Chat extends resource_1.APIResource {
|
|
10
|
-
/**
|
|
11
|
-
* __chat.generate__
|
|
12
|
-
*
|
|
13
|
-
* Generate a chat message for a conversation. This endpoint will return immediately, polling will be required to get the response.
|
|
14
|
-
*
|
|
15
|
-
* The `latestMessageType` field in the response can be used to determine if the response is ready.
|
|
16
|
-
*
|
|
17
|
-
* If the `latestMessageType` is `BOT_RESPONSE`, the response is ready.
|
|
18
|
-
* For a more ergonomic way to poll, use the `message` method.
|
|
19
|
-
*
|
|
20
|
-
* ** WARNING ** This endpoint is not idempotent. If you call it multiple times, you will generate multiple messages.
|
|
21
|
-
*
|
|
22
|
-
* @see {@link Chat.message}
|
|
23
|
-
*/
|
|
24
10
|
/**
|
|
25
11
|
* @example
|
|
26
12
|
* ```ts
|
|
@@ -40,11 +26,6 @@ class Chat extends resource_1.APIResource {
|
|
|
40
26
|
generate(body, options) {
|
|
41
27
|
return this._client.post('/v1/conversation/chat/message', { body, ...options });
|
|
42
28
|
}
|
|
43
|
-
/**
|
|
44
|
-
* __chat.get__
|
|
45
|
-
*
|
|
46
|
-
* Returns a chat message for a conversation. This endpoint will return the latest state of the conversation.
|
|
47
|
-
*/
|
|
48
29
|
/**
|
|
49
30
|
* @example
|
|
50
31
|
* ```ts
|
|
@@ -56,15 +37,6 @@ class Chat extends resource_1.APIResource {
|
|
|
56
37
|
get(query, options) {
|
|
57
38
|
return this._client.get('/v1/conversation/chat/message', { query, ...options });
|
|
58
39
|
}
|
|
59
|
-
/**
|
|
60
|
-
* __chat.start__
|
|
61
|
-
*
|
|
62
|
-
* Start a chat conversation. This endpoint will return immediately.
|
|
63
|
-
*
|
|
64
|
-
* The `conversationId` field in the response can be used to generate messages.
|
|
65
|
-
*
|
|
66
|
-
* ** WARNING ** This endpoint is not idempotent. If you call it multiple times, you will generate multiple conversations.
|
|
67
|
-
*/
|
|
68
40
|
/**
|
|
69
41
|
* @example
|
|
70
42
|
* ```ts
|
|
@@ -78,26 +50,24 @@ class Chat extends resource_1.APIResource {
|
|
|
78
50
|
return this._client.post('/v1/conversation/chat/create', { body, ...options });
|
|
79
51
|
}
|
|
80
52
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* When it return the response is the latest message type that is of type `BOT_RESPONSE`.
|
|
53
|
+
* Send a message and poll until a response is ready.
|
|
84
54
|
*
|
|
85
|
-
* @
|
|
55
|
+
* This is a convenience wrapper that calls {@link Chat.generate} then {@link Chat.poll}.
|
|
86
56
|
*/
|
|
87
57
|
message(body, options) {
|
|
88
58
|
return this.generate(body, options).then((response) => this.poll({ conversationId: response.conversationId }, options));
|
|
89
59
|
}
|
|
90
60
|
/**
|
|
91
|
-
*
|
|
61
|
+
* Poll until the conversation has a bot response ready.
|
|
92
62
|
*
|
|
93
|
-
*
|
|
63
|
+
* Stops when `latestMessageType` is `BOT_RESPONSE` or `PENDING_RESPONSE`,
|
|
64
|
+
* or when `status` is `Escalated` or `Error`.
|
|
94
65
|
*/
|
|
95
66
|
poll(query, options) {
|
|
96
67
|
return (0, poll_until_1.pollUntil)(() => this._client.get('/v1/conversation/chat/message', { query, ...options }), {
|
|
97
68
|
timeout: options?.timeout || 180000,
|
|
98
69
|
interval: 2000,
|
|
99
70
|
condition: (conversation) => {
|
|
100
|
-
// Don't poll if the conversation is escalated or in error
|
|
101
71
|
if (conversation.status === 'Escalated' || conversation.status === 'Error') {
|
|
102
72
|
return true;
|
|
103
73
|
}
|
|
@@ -110,18 +80,14 @@ class Chat extends resource_1.APIResource {
|
|
|
110
80
|
});
|
|
111
81
|
}
|
|
112
82
|
/**
|
|
113
|
-
* __chat.streamUpdates__
|
|
114
|
-
*
|
|
115
83
|
* Create a persistent stream of updates for a conversation.
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
84
|
+
*
|
|
85
|
+
* Responses from the bot will arrive as events. Consuming clients must aggregate
|
|
86
|
+
* multiple chunks into a single message based on the `messageId` field.
|
|
87
|
+
*
|
|
88
|
+
* This stream is open indefinitely and does not automatically close — avoid
|
|
119
89
|
* blocking other operations while listening to events from this generator.
|
|
120
90
|
*
|
|
121
|
-
* @param params.conversationId - Conversation/ticket ID to subscribe to.
|
|
122
|
-
* @returns AsyncGenerator<ChatStreamEvent> a generator that emits response events as they arrive.
|
|
123
|
-
*/
|
|
124
|
-
/**
|
|
125
91
|
* @example
|
|
126
92
|
* ```ts
|
|
127
93
|
* for await (const evt of client.conversation.chat.streamUpdates({ conversationId: 'abc123' })) {
|
|
@@ -133,7 +99,7 @@ class Chat extends resource_1.APIResource {
|
|
|
133
99
|
const queries = new URLSearchParams();
|
|
134
100
|
queries.set('sseMessageTypes', 'new-message,message-chunk,message-complete');
|
|
135
101
|
queries.set('ticketMessageTypes', 'BOT_RESPONSE');
|
|
136
|
-
const url =
|
|
102
|
+
const url = `${this._client.baseURL}/v1/ticket/sse/${params.conversationId}?${queries.toString()}`;
|
|
137
103
|
const eventSource = new eventsource_1.EventSource(url);
|
|
138
104
|
const output = new promise_1.DeferredAsyncIterable();
|
|
139
105
|
eventSource.addEventListener('error', (evt) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/resources/conversation/chat.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/resources/conversation/chat.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,qDAAkD;AAIlD,wDAAiD;AACjD,kDAA0D;AAC1D,6CAA0C;AAE1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