@anthropic-ai/sdk 0.125.0 → 0.127.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 +88 -0
- package/client.d.mts +12 -11
- package/client.d.mts.map +1 -1
- package/client.d.ts +12 -11
- package/client.d.ts.map +1 -1
- package/client.js +865 -845
- package/client.js.map +1 -1
- package/client.mjs +866 -840
- package/client.mjs.map +1 -1
- package/core/api-promise.js +71 -68
- package/core/api-promise.js.map +1 -1
- package/core/api-promise.mjs +71 -64
- package/core/api-promise.mjs.map +1 -1
- package/core/error.js +5 -2
- package/core/error.js.map +1 -1
- package/core/error.mjs +5 -2
- package/core/error.mjs.map +1 -1
- package/core/pagination.js +56 -50
- package/core/pagination.js.map +1 -1
- package/core/pagination.mjs +56 -41
- package/core/pagination.mjs.map +1 -1
- package/core/streaming.js +212 -209
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +212 -209
- package/core/streaming.mjs.map +1 -1
- package/helpers/beta/mcp.js +14 -19
- package/helpers/beta/mcp.js.map +1 -1
- package/helpers/beta/mcp.mjs +14 -13
- package/helpers/beta/mcp.mjs.map +1 -1
- package/internal/constants.js +1 -1
- package/internal/constants.js.map +1 -1
- package/internal/decoders/jsonl.js +27 -24
- package/internal/decoders/jsonl.js.map +1 -1
- package/internal/decoders/jsonl.mjs +27 -24
- package/internal/decoders/jsonl.mjs.map +1 -1
- package/internal/decoders/line.js +52 -49
- package/internal/decoders/line.js.map +1 -1
- package/internal/decoders/line.mjs +52 -43
- package/internal/decoders/line.mjs.map +1 -1
- package/internal/file-store.js +256 -258
- package/internal/file-store.js.map +1 -1
- package/internal/file-store.mjs +256 -243
- package/internal/file-store.mjs.map +1 -1
- package/internal/node.browser.d.mts.map +1 -1
- package/internal/node.browser.d.ts.map +1 -1
- package/internal/node.browser.js.map +1 -1
- package/internal/node.browser.mjs +7 -7
- package/internal/node.browser.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +2 -2
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +3 -3
- package/internal/parse.mjs.map +1 -1
- package/internal/shim-types.js +0 -6
- package/internal/shim-types.js.map +1 -1
- package/internal/shim-types.mjs +0 -6
- package/internal/shim-types.mjs.map +1 -1
- package/internal/shims.d.mts +3 -3
- package/internal/shims.d.mts.map +1 -1
- package/internal/shims.d.ts +3 -3
- package/internal/shims.d.ts.map +1 -1
- package/internal/shims.js +0 -6
- package/internal/shims.js.map +1 -1
- package/internal/shims.mjs +0 -6
- package/internal/shims.mjs.map +1 -1
- package/internal/stainless-helper-header.js +6 -6
- package/internal/stainless-helper-header.js.map +1 -1
- package/internal/utils/async-queue.js +66 -63
- package/internal/utils/async-queue.js.map +1 -1
- package/internal/utils/async-queue.mjs +66 -56
- package/internal/utils/async-queue.mjs.map +1 -1
- package/internal/utils/bytes.d.mts +1 -1
- package/internal/utils/bytes.d.mts.map +1 -1
- package/internal/utils/bytes.d.ts +1 -1
- package/internal/utils/bytes.d.ts.map +1 -1
- package/internal/utils/log.d.mts +7 -12
- package/internal/utils/log.d.mts.map +1 -1
- package/internal/utils/log.d.ts +7 -12
- package/internal/utils/log.d.ts.map +1 -1
- package/internal/utils/log.js +12 -0
- package/internal/utils/log.js.map +1 -1
- package/internal/utils/log.mjs +11 -0
- package/internal/utils/log.mjs.map +1 -1
- package/lib/BetaMessageStream.d.mts.map +1 -1
- package/lib/BetaMessageStream.d.ts.map +1 -1
- package/lib/BetaMessageStream.js +595 -590
- package/lib/BetaMessageStream.js.map +1 -1
- package/lib/BetaMessageStream.mjs +595 -590
- package/lib/BetaMessageStream.mjs.map +1 -1
- package/lib/MessageStream.js +544 -541
- package/lib/MessageStream.js.map +1 -1
- package/lib/MessageStream.mjs +544 -541
- package/lib/MessageStream.mjs.map +1 -1
- package/lib/beta-parser.d.mts +1 -3
- package/lib/beta-parser.d.mts.map +1 -1
- package/lib/beta-parser.d.ts +1 -3
- package/lib/beta-parser.d.ts.map +1 -1
- package/lib/beta-parser.js.map +1 -1
- package/lib/beta-parser.mjs.map +1 -1
- package/lib/environments/poller.js +180 -174
- package/lib/environments/poller.js.map +1 -1
- package/lib/environments/poller.mjs +180 -153
- package/lib/environments/poller.mjs.map +1 -1
- package/lib/environments/worker.js +375 -369
- package/lib/environments/worker.js.map +1 -1
- package/lib/environments/worker.mjs +374 -329
- package/lib/environments/worker.mjs.map +1 -1
- package/lib/internal/stub.d.mts +2 -0
- package/lib/internal/stub.d.mts.map +1 -0
- package/lib/internal/stub.d.ts +2 -0
- package/lib/internal/stub.d.ts.map +1 -0
- package/lib/internal/stub.js +6 -0
- package/lib/internal/stub.js.map +1 -0
- package/lib/internal/stub.mjs +3 -0
- package/lib/internal/stub.mjs.map +1 -0
- package/lib/internal/types.d.mts +5 -0
- package/lib/internal/types.d.mts.map +1 -0
- package/lib/internal/types.d.ts +5 -0
- package/lib/internal/types.d.ts.map +1 -0
- package/lib/internal/types.js +3 -0
- package/lib/internal/types.js.map +1 -0
- package/lib/internal/types.mjs +2 -0
- package/lib/internal/types.mjs.map +1 -0
- package/lib/middleware.js +6 -1
- package/lib/middleware.js.map +1 -1
- package/lib/middleware.mjs +6 -1
- package/lib/middleware.mjs.map +1 -1
- package/lib/parser.d.mts +1 -3
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts +1 -3
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs.map +1 -1
- package/lib/tools/BetaToolRunner.d.mts +21 -6
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts +21 -6
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +415 -310
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +414 -303
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/lib/tools/SessionToolRunner.js +241 -235
- package/lib/tools/SessionToolRunner.js.map +1 -1
- package/lib/tools/SessionToolRunner.mjs +241 -192
- package/lib/tools/SessionToolRunner.mjs.map +1 -1
- package/lib/tools/ToolError.js +39 -36
- package/lib/tools/ToolError.js.map +1 -1
- package/lib/tools/ToolError.mjs +39 -13
- package/lib/tools/ToolError.mjs.map +1 -1
- package/lib/transform-json-schema.js +7 -5
- package/lib/transform-json-schema.js.map +1 -1
- package/lib/transform-json-schema.mjs +7 -5
- package/lib/transform-json-schema.mjs.map +1 -1
- package/package.json +4 -3
- package/resources/beta/agents/agents.js +135 -132
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs +135 -132
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/beta.d.mts +5 -5
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +5 -5
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +39 -36
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +39 -36
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/deployment-runs.d.mts +4 -0
- package/resources/beta/deployment-runs.d.mts.map +1 -1
- package/resources/beta/deployment-runs.d.ts +4 -0
- package/resources/beta/deployment-runs.d.ts.map +1 -1
- package/resources/beta/deployments.d.mts +5 -0
- package/resources/beta/deployments.d.mts.map +1 -1
- package/resources/beta/deployments.d.ts +5 -0
- package/resources/beta/deployments.d.ts.map +1 -1
- package/resources/beta/dreams.d.mts +19 -28
- package/resources/beta/dreams.d.mts.map +1 -1
- package/resources/beta/dreams.d.ts +19 -28
- package/resources/beta/dreams.d.ts.map +1 -1
- package/resources/beta/environments/environments.js +157 -154
- package/resources/beta/environments/environments.js.map +1 -1
- package/resources/beta/environments/environments.mjs +157 -154
- package/resources/beta/environments/environments.mjs.map +1 -1
- package/resources/beta/environments/work.js +255 -252
- package/resources/beta/environments/work.js.map +1 -1
- package/resources/beta/environments/work.mjs +255 -252
- package/resources/beta/environments/work.mjs.map +1 -1
- package/resources/beta/index.d.mts +2 -2
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +2 -2
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/memory-stores/memories.d.mts +6 -0
- package/resources/beta/memory-stores/memories.d.mts.map +1 -1
- package/resources/beta/memory-stores/memories.d.ts +6 -0
- package/resources/beta/memory-stores/memories.d.ts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.js +150 -147
- package/resources/beta/memory-stores/memory-stores.js.map +1 -1
- package/resources/beta/memory-stores/memory-stores.mjs +150 -147
- package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.mts +7 -0
- package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.ts +7 -0
- package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
- package/resources/beta/messages/batches.d.mts +12 -1
- package/resources/beta/messages/batches.d.mts.map +1 -1
- package/resources/beta/messages/batches.d.ts +12 -1
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +239 -101
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +239 -101
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +113 -110
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +113 -110
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/models.d.mts +22 -1
- package/resources/beta/models.d.mts.map +1 -1
- package/resources/beta/models.d.ts +22 -1
- package/resources/beta/models.d.ts.map +1 -1
- package/resources/beta/organization/federation/federation.js +11 -8
- package/resources/beta/organization/federation/federation.js.map +1 -1
- package/resources/beta/organization/federation/federation.mjs +11 -8
- package/resources/beta/organization/federation/federation.mjs.map +1 -1
- package/resources/beta/organization/federation/rules/rules.js +187 -184
- package/resources/beta/organization/federation/rules/rules.js.map +1 -1
- package/resources/beta/organization/federation/rules/rules.mjs +187 -184
- package/resources/beta/organization/federation/rules/rules.mjs.map +1 -1
- package/resources/beta/organization/index.d.mts +1 -1
- package/resources/beta/organization/index.d.mts.map +1 -1
- package/resources/beta/organization/index.d.ts +1 -1
- package/resources/beta/organization/index.d.ts.map +1 -1
- package/resources/beta/organization/index.js.map +1 -1
- package/resources/beta/organization/index.mjs.map +1 -1
- package/resources/beta/organization/organization.d.mts +2 -2
- package/resources/beta/organization/organization.d.mts.map +1 -1
- package/resources/beta/organization/organization.d.ts +2 -2
- package/resources/beta/organization/organization.d.ts.map +1 -1
- package/resources/beta/organization/organization.js +38 -35
- package/resources/beta/organization/organization.js.map +1 -1
- package/resources/beta/organization/organization.mjs +38 -35
- package/resources/beta/organization/organization.mjs.map +1 -1
- package/resources/beta/organization/rate-limits.d.mts +87 -5
- package/resources/beta/organization/rate-limits.d.mts.map +1 -1
- package/resources/beta/organization/rate-limits.d.ts +87 -5
- package/resources/beta/organization/rate-limits.d.ts.map +1 -1
- package/resources/beta/organization/service-accounts/service-accounts.js +163 -160
- package/resources/beta/organization/service-accounts/service-accounts.js.map +1 -1
- package/resources/beta/organization/service-accounts/service-accounts.mjs +163 -160
- package/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.d.mts +9 -4
- package/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.d.ts +9 -4
- package/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.js.map +1 -1
- package/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.d.mts +3 -3
- package/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.d.ts +3 -3
- package/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.js +97 -94
- package/resources/beta/organization/workspaces/workspaces.js.map +1 -1
- package/resources/beta/organization/workspaces/workspaces.mjs +97 -94
- package/resources/beta/organization/workspaces/workspaces.mjs.map +1 -1
- package/resources/beta/sessions/events.d.mts +12 -21
- package/resources/beta/sessions/events.d.mts.map +1 -1
- package/resources/beta/sessions/events.d.ts +12 -21
- package/resources/beta/sessions/events.d.ts.map +1 -1
- package/resources/beta/sessions/events.js +118 -115
- package/resources/beta/sessions/events.js.map +1 -1
- package/resources/beta/sessions/events.mjs +118 -115
- package/resources/beta/sessions/events.mjs.map +1 -1
- package/resources/beta/sessions/resources.d.mts +0 -3
- package/resources/beta/sessions/resources.d.mts.map +1 -1
- package/resources/beta/sessions/resources.d.ts +0 -3
- package/resources/beta/sessions/resources.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.d.mts +8 -2
- package/resources/beta/sessions/sessions.d.mts.map +1 -1
- package/resources/beta/sessions/sessions.d.ts +8 -2
- package/resources/beta/sessions/sessions.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.js +161 -158
- package/resources/beta/sessions/sessions.js.map +1 -1
- package/resources/beta/sessions/sessions.mjs +161 -158
- package/resources/beta/sessions/sessions.mjs.map +1 -1
- package/resources/beta/sessions/threads/threads.js +86 -83
- package/resources/beta/sessions/threads/threads.js.map +1 -1
- package/resources/beta/sessions/threads/threads.mjs +86 -83
- package/resources/beta/sessions/threads/threads.mjs.map +1 -1
- package/resources/beta/skills/skills.js +104 -101
- package/resources/beta/skills/skills.js.map +1 -1
- package/resources/beta/skills/skills.mjs +104 -101
- package/resources/beta/skills/skills.mjs.map +1 -1
- package/resources/beta/tunnels/certificates.d.mts +2 -2
- package/resources/beta/tunnels/certificates.d.ts +2 -2
- package/resources/beta/tunnels/tunnels.js +188 -185
- package/resources/beta/tunnels/tunnels.js.map +1 -1
- package/resources/beta/tunnels/tunnels.mjs +188 -185
- package/resources/beta/tunnels/tunnels.mjs.map +1 -1
- package/resources/beta/user-profiles.d.mts +45 -0
- package/resources/beta/user-profiles.d.mts.map +1 -1
- package/resources/beta/user-profiles.d.ts +45 -0
- package/resources/beta/user-profiles.d.ts.map +1 -1
- package/resources/beta/user-profiles.js +25 -10
- package/resources/beta/user-profiles.js.map +1 -1
- package/resources/beta/user-profiles.mjs +25 -10
- package/resources/beta/user-profiles.mjs.map +1 -1
- package/resources/beta/vaults/credentials.d.mts +19 -19
- package/resources/beta/vaults/credentials.d.mts.map +1 -1
- package/resources/beta/vaults/credentials.d.ts +19 -19
- package/resources/beta/vaults/credentials.d.ts.map +1 -1
- package/resources/beta/vaults/vaults.js +156 -153
- package/resources/beta/vaults/vaults.js.map +1 -1
- package/resources/beta/vaults/vaults.mjs +156 -153
- package/resources/beta/vaults/vaults.mjs.map +1 -1
- package/resources/completions.d.mts +1 -1
- package/resources/completions.d.ts +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- 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/messages/index.d.mts +1 -1
- package/resources/messages/index.d.mts.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.mts +100 -63
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +100 -63
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +115 -112
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +115 -112
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/skills/skills.js +88 -85
- package/resources/skills/skills.js.map +1 -1
- package/resources/skills/skills.mjs +88 -85
- package/resources/skills/skills.mjs.map +1 -1
- package/resources/top-level.js +0 -1
- package/resources/top-level.js.map +1 -1
- package/resources/top-level.mjs +0 -1
- package/resources/top-level.mjs.map +1 -1
- package/src/client.ts +95 -72
- package/src/internal/node.browser.ts +7 -7
- package/src/internal/parse.ts +8 -11
- package/src/internal/shims.ts +4 -3
- package/src/internal/utils/bytes.ts +1 -1
- package/src/internal/utils/log.ts +16 -2
- package/src/lib/BetaMessageStream.ts +7 -5
- package/src/lib/beta-parser.ts +1 -3
- package/src/lib/internal/stub.ts +2 -0
- package/src/lib/internal/types.ts +2 -0
- package/src/lib/middleware.ts +6 -1
- package/src/lib/parser.ts +1 -3
- package/src/lib/tools/BetaToolRunner.ts +157 -24
- package/src/lib/transform-json-schema.ts +8 -6
- package/src/resources/beta/beta.ts +24 -1
- package/src/resources/beta/deployment-runs.ts +4 -0
- package/src/resources/beta/deployments.ts +5 -0
- package/src/resources/beta/dreams.ts +19 -28
- package/src/resources/beta/index.ts +11 -0
- package/src/resources/beta/memory-stores/memories.ts +6 -0
- package/src/resources/beta/memory-stores/memory-versions.ts +7 -0
- package/src/resources/beta/messages/batches.ts +13 -1
- package/src/resources/beta/messages/index.ts +10 -0
- package/src/resources/beta/messages/messages.ts +289 -100
- package/src/resources/beta/models.ts +25 -0
- package/src/resources/beta/organization/index.ts +6 -0
- package/src/resources/beta/organization/organization.ts +12 -0
- package/src/resources/beta/organization/rate-limits.ts +112 -4
- package/src/resources/beta/organization/workspaces/rate-limits.ts +16 -4
- package/src/resources/beta/organization/workspaces/workspaces.ts +3 -3
- package/src/resources/beta/sessions/events.ts +12 -21
- package/src/resources/beta/sessions/resources.ts +0 -3
- package/src/resources/beta/sessions/sessions.ts +8 -2
- package/src/resources/beta/tunnels/certificates.ts +2 -2
- package/src/resources/beta/user-profiles.ts +75 -10
- package/src/resources/beta/vaults/credentials.ts +19 -19
- package/src/resources/completions.ts +1 -1
- package/src/resources/index.ts +6 -0
- package/src/resources/messages/index.ts +6 -0
- package/src/resources/messages/messages.ts +128 -62
- package/src/tsconfig.json +13 -3
- package/src/version.ts +1 -1
- package/tools/agent-toolset/fs-util.js +0 -6
- package/tools/agent-toolset/fs-util.js.map +1 -1
- package/tools/agent-toolset/fs-util.mjs +0 -6
- package/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/tools/agent-toolset/memories.js +4 -4
- package/tools/agent-toolset/memories.js.map +1 -1
- package/tools/agent-toolset/memories.mjs +2 -2
- package/tools/agent-toolset/memories.mjs.map +1 -1
- package/tools/agent-toolset/node.browser.js +12 -12
- package/tools/agent-toolset/node.browser.js.map +1 -1
- package/tools/agent-toolset/node.js +142 -139
- package/tools/agent-toolset/node.js.map +1 -1
- package/tools/agent-toolset/node.mjs +132 -125
- package/tools/agent-toolset/node.mjs.map +1 -1
- package/tools/agent-toolset/skills.js +5 -5
- package/tools/agent-toolset/skills.js.map +1 -1
- package/tools/agent-toolset/sync-interval.js +3 -3
- package/tools/agent-toolset/sync-interval.js.map +1 -1
- package/tools/memory/node.browser.js +2 -2
- package/tools/memory/node.browser.js.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/helpers/beta/mcp.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.mjs","sourceRoot":"","sources":["../../src/helpers/beta/mcp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp.mjs","sourceRoot":"","sources":["../../src/helpers/beta/mcp.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,sCAAkC;AAUtD,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,mDAA+C;AAChD,OAAO,EAAE,UAAU,EAAE,wCAAoC;AAEzD,OAAO,EAAE,iBAAiB,EAAE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AAC,wDAAwD,CAAC,CAAC;IAC/F,CAAC;IACD,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;IAChF,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC;IACvC,MAAM,IAAI,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAChE,IAAY,CAAC,iBAAiB,CAAC,GAAG,mBAAmB,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/internal/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// File containing shared constants
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.MODEL_NONSTREAMING_TOKENS = void 0;
|
|
4
|
+
// File containing shared constants
|
|
5
5
|
/**
|
|
6
6
|
* Model-specific timeout constraints for non-streaming requests
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/internal/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/internal/constants.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC;;GAEG;AACU,QAAA,yBAAyB,GAA2B;IAC/D,wBAAwB,EAAE,IAAI;IAC9B,yCAAyC,EAAE,IAAI;IAC/C,0BAA0B,EAAE,IAAI;CACjC,CAAC"}
|
|
@@ -4,36 +4,39 @@ exports.JSONLDecoder = void 0;
|
|
|
4
4
|
const error_1 = require("../../core/error.js");
|
|
5
5
|
const shims_1 = require("../shims.js");
|
|
6
6
|
const line_1 = require("./line.js");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for (const
|
|
7
|
+
var JSONLDecoder = /* @__PURE__ */ (() => {
|
|
8
|
+
class JSONLDecoder {
|
|
9
|
+
constructor(iterator, controller) {
|
|
10
|
+
this.iterator = iterator;
|
|
11
|
+
this.controller = controller;
|
|
12
|
+
}
|
|
13
|
+
async *decoder() {
|
|
14
|
+
const lineDecoder = new line_1.LineDecoder();
|
|
15
|
+
for await (const chunk of this.iterator) {
|
|
16
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
17
|
+
yield JSON.parse(line);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const line of lineDecoder.flush()) {
|
|
16
21
|
yield JSON.parse(line);
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
[Symbol.asyncIterator]() {
|
|
25
|
+
return this.decoder();
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
globalThis.navigator.product === 'ReactNative') {
|
|
31
|
-
throw new error_1.AnthropicError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
27
|
+
static fromResponse(response, controller) {
|
|
28
|
+
if (!response.body) {
|
|
29
|
+
controller.abort();
|
|
30
|
+
if (typeof globalThis.navigator !== 'undefined' &&
|
|
31
|
+
globalThis.navigator.product === 'ReactNative') {
|
|
32
|
+
throw new error_1.AnthropicError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
33
|
+
}
|
|
34
|
+
throw new error_1.AnthropicError(`Attempted to iterate over a response with no body`);
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
return new JSONLDecoder((0, shims_1.ReadableStreamToAsyncIterable)(response.body), controller);
|
|
34
37
|
}
|
|
35
|
-
return new JSONLDecoder((0, shims_1.ReadableStreamToAsyncIterable)(response.body), controller);
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
return JSONLDecoder;
|
|
40
|
+
})();
|
|
38
41
|
exports.JSONLDecoder = JSONLDecoder;
|
|
39
42
|
//# sourceMappingURL=jsonl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../src/internal/decoders/jsonl.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,uCAAyD;AACzD,oCAAiD
|
|
1
|
+
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../src/internal/decoders/jsonl.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,uCAAyD;AACzD,oCAAiD;;IAEjD,MAAa,YAAY;QAGvB,YACU,QAAsC,EAC9C,UAA2B;YADnB,aAAQ,GAAR,QAAQ,CAA8B;YAG9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;QAEO,KAAK,CAAC,CAAC,OAAO;YACpB,MAAM,WAAW,GAAG,IAAI,kBAAW,EAAE,CAAC;YACtC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACxC,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC7C,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;gBAC9B,CAAC;YACH,CAAC;YAED,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC;gBACvC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;QAED,MAAM,CAAC,YAAY,CAAI,QAAkB,EAAE,UAA2B;YACpE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnB,UAAU,CAAC,KAAK,EAAE,CAAC;gBACnB,IACE,OAAQ,UAAkB,CAAC,SAAS,KAAK,WAAW;oBACnD,UAAkB,CAAC,SAAS,CAAC,OAAO,KAAK,aAAa,EACvD,CAAC;oBACD,MAAM,IAAI,sBAAc,CACtB,gKAAgK,CACjK,CAAC;gBACJ,CAAC;gBACD,MAAM,IAAI,sBAAc,CAAC,mDAAmD,CAAC,CAAC;YAChF,CAAC;YAED,OAAO,IAAI,YAAY,CAAC,IAAA,qCAA6B,EAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;QAC3F,CAAC;KACF;;;AA3CD,oCA2CC"}
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
import { AnthropicError } from "../../core/error.mjs";
|
|
2
2
|
import { ReadableStreamToAsyncIterable } from "../shims.mjs";
|
|
3
3
|
import { LineDecoder } from "./line.mjs";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (const
|
|
4
|
+
export var JSONLDecoder = /* @__PURE__ */ (() => {
|
|
5
|
+
class JSONLDecoder {
|
|
6
|
+
constructor(iterator, controller) {
|
|
7
|
+
this.iterator = iterator;
|
|
8
|
+
this.controller = controller;
|
|
9
|
+
}
|
|
10
|
+
async *decoder() {
|
|
11
|
+
const lineDecoder = new LineDecoder();
|
|
12
|
+
for await (const chunk of this.iterator) {
|
|
13
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
14
|
+
yield JSON.parse(line);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
for (const line of lineDecoder.flush()) {
|
|
13
18
|
yield JSON.parse(line);
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
[Symbol.asyncIterator]() {
|
|
22
|
+
return this.decoder();
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
globalThis.navigator.product === 'ReactNative') {
|
|
28
|
-
throw new AnthropicError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
24
|
+
static fromResponse(response, controller) {
|
|
25
|
+
if (!response.body) {
|
|
26
|
+
controller.abort();
|
|
27
|
+
if (typeof globalThis.navigator !== 'undefined' &&
|
|
28
|
+
globalThis.navigator.product === 'ReactNative') {
|
|
29
|
+
throw new AnthropicError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
30
|
+
}
|
|
31
|
+
throw new AnthropicError(`Attempted to iterate over a response with no body`);
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
return new JSONLDecoder(ReadableStreamToAsyncIterable(response.body), controller);
|
|
31
34
|
}
|
|
32
|
-
return new JSONLDecoder(ReadableStreamToAsyncIterable(response.body), controller);
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
return JSONLDecoder;
|
|
37
|
+
})();
|
|
35
38
|
//# sourceMappingURL=jsonl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.mjs","sourceRoot":"","sources":["../../src/internal/decoders/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAyB;AAClD,OAAO,EAAE,6BAA6B,EAAE,qBAAiB;AACzD,OAAO,EAAE,WAAW,EAAc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J,CAAC;gBACD,MAAM,IAAI,cAAc,CAAC,mDAAmD,CAAC,CAAC;YAChF,CAAC;YAED,OAAO,IAAI,YAAY,CAAC,6BAA6B,CAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;QAC3F,CAAC;KACF"}
|
|
@@ -5,63 +5,66 @@ exports.LineDecoder = void 0;
|
|
|
5
5
|
exports.findDoubleNewlineIndex = findDoubleNewlineIndex;
|
|
6
6
|
const tslib_1 = require("../tslib.js");
|
|
7
7
|
const bytes_1 = require("../utils/bytes.js");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
decode(chunk) {
|
|
22
|
-
if (chunk == null) {
|
|
23
|
-
return [];
|
|
8
|
+
var LineDecoder = /* @__PURE__ */ (() => {
|
|
9
|
+
/**
|
|
10
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
11
|
+
* reading lines from text.
|
|
12
|
+
*
|
|
13
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
14
|
+
*/
|
|
15
|
+
class LineDecoder {
|
|
16
|
+
constructor() {
|
|
17
|
+
_LineDecoder_buffer.set(this, void 0);
|
|
18
|
+
_LineDecoder_carriageReturnIndex.set(this, void 0);
|
|
19
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_buffer, new Uint8Array(), "f");
|
|
20
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
tslib_1.__classPrivateFieldSet(this, _LineDecoder_buffer, (0, bytes_1.concatBytes)([tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), binaryChunk]), "f");
|
|
29
|
-
const lines = [];
|
|
30
|
-
let patternIndex;
|
|
31
|
-
while ((patternIndex = findNewlineIndex(tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"))) != null) {
|
|
32
|
-
if (patternIndex.carriage && tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") == null) {
|
|
33
|
-
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
34
|
-
tslib_1.__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, patternIndex.index, "f");
|
|
35
|
-
continue;
|
|
22
|
+
decode(chunk) {
|
|
23
|
+
if (chunk == null) {
|
|
24
|
+
return [];
|
|
36
25
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
27
|
+
: typeof chunk === 'string' ? (0, bytes_1.encodeUTF8)(chunk)
|
|
28
|
+
: chunk;
|
|
29
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_buffer, (0, bytes_1.concatBytes)([tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), binaryChunk]), "f");
|
|
30
|
+
const lines = [];
|
|
31
|
+
let patternIndex;
|
|
32
|
+
while ((patternIndex = findNewlineIndex(tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"))) != null) {
|
|
33
|
+
if (patternIndex.carriage && tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") == null) {
|
|
34
|
+
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
35
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, patternIndex.index, "f");
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// we got double \r or \rtext\n
|
|
39
|
+
if (tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") != null &&
|
|
40
|
+
(patternIndex.index !== tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") + 1 || patternIndex.carriage)) {
|
|
41
|
+
lines.push((0, bytes_1.decodeUTF8)(tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(0, tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") - 1)));
|
|
42
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_buffer, tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f")), "f");
|
|
43
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const endIndex = tslib_1.__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
47
|
+
const line = (0, bytes_1.decodeUTF8)(tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(0, endIndex));
|
|
48
|
+
lines.push(line);
|
|
49
|
+
tslib_1.__classPrivateFieldSet(this, _LineDecoder_buffer, tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(patternIndex.index), "f");
|
|
42
50
|
tslib_1.__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
43
|
-
continue;
|
|
44
51
|
}
|
|
45
|
-
|
|
46
|
-
const line = (0, bytes_1.decodeUTF8)(tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(0, endIndex));
|
|
47
|
-
lines.push(line);
|
|
48
|
-
tslib_1.__classPrivateFieldSet(this, _LineDecoder_buffer, tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(patternIndex.index), "f");
|
|
49
|
-
tslib_1.__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
52
|
+
return lines;
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return
|
|
54
|
+
flush() {
|
|
55
|
+
if (!tslib_1.__classPrivateFieldGet(this, _LineDecoder_buffer, "f").length) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
return this.decode('\n');
|
|
56
59
|
}
|
|
57
|
-
return this.decode('\n');
|
|
58
60
|
}
|
|
59
|
-
|
|
61
|
+
_LineDecoder_buffer = new WeakMap(), _LineDecoder_carriageReturnIndex = new WeakMap();
|
|
62
|
+
// prettier-ignore
|
|
63
|
+
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
64
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
65
|
+
return LineDecoder;
|
|
66
|
+
})();
|
|
60
67
|
exports.LineDecoder = LineDecoder;
|
|
61
|
-
_LineDecoder_buffer = new WeakMap(), _LineDecoder_carriageReturnIndex = new WeakMap();
|
|
62
|
-
// prettier-ignore
|
|
63
|
-
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
64
|
-
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
65
68
|
/**
|
|
66
69
|
* This function searches the buffer for the end patterns, (\r or \n)
|
|
67
70
|
* and returns an object with the index preceding the matched newline and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";;;;AAyGA,wDA6BC;;AAtID,6CAAqE
|
|
1
|
+
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";;;;AAyGA,wDA6BC;;AAtID,6CAAqE;;IAIrE;;;;;OAKG;IACH,MAAa,WAAW;QAQtB;YAHA,sCAAoB;YACpB,mD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AC,CAAC,GAAG,CAAC,CAAC,KAAK,OAAO;YACzB,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM;YACrB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,QAAQ;YAC1B,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,OAAO,EACzB,CAAC;YACD,WAAW;YACX,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
|
|
@@ -7,56 +7,65 @@ import { concatBytes, decodeUTF8, encodeUTF8 } from "../utils/bytes.mjs";
|
|
|
7
7
|
*
|
|
8
8
|
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
export var LineDecoder = /* @__PURE__ */ (() => {
|
|
11
|
+
/**
|
|
12
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
13
|
+
* reading lines from text.
|
|
14
|
+
*
|
|
15
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
16
|
+
*/
|
|
17
|
+
class LineDecoder {
|
|
18
|
+
constructor() {
|
|
19
|
+
_LineDecoder_buffer.set(this, void 0);
|
|
20
|
+
_LineDecoder_carriageReturnIndex.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, new Uint8Array(), "f");
|
|
22
|
+
__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
__classPrivateFieldSet(this, _LineDecoder_buffer, concatBytes([__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), binaryChunk]), "f");
|
|
25
|
-
const lines = [];
|
|
26
|
-
let patternIndex;
|
|
27
|
-
while ((patternIndex = findNewlineIndex(__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"))) != null) {
|
|
28
|
-
if (patternIndex.carriage && __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") == null) {
|
|
29
|
-
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
30
|
-
__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, patternIndex.index, "f");
|
|
31
|
-
continue;
|
|
24
|
+
decode(chunk) {
|
|
25
|
+
if (chunk == null) {
|
|
26
|
+
return [];
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
29
|
+
: typeof chunk === 'string' ? encodeUTF8(chunk)
|
|
30
|
+
: chunk;
|
|
31
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, concatBytes([__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), binaryChunk]), "f");
|
|
32
|
+
const lines = [];
|
|
33
|
+
let patternIndex;
|
|
34
|
+
while ((patternIndex = findNewlineIndex(__classPrivateFieldGet(this, _LineDecoder_buffer, "f"), __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f"))) != null) {
|
|
35
|
+
if (patternIndex.carriage && __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") == null) {
|
|
36
|
+
// skip until we either get a corresponding `\n`, a new `\r` or nothing
|
|
37
|
+
__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, patternIndex.index, "f");
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// we got double \r or \rtext\n
|
|
41
|
+
if (__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") != null &&
|
|
42
|
+
(patternIndex.index !== __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") + 1 || patternIndex.carriage)) {
|
|
43
|
+
lines.push(decodeUTF8(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(0, __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") - 1)));
|
|
44
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, __classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(__classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f")), "f");
|
|
45
|
+
__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const endIndex = __classPrivateFieldGet(this, _LineDecoder_carriageReturnIndex, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
49
|
+
const line = decodeUTF8(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(0, endIndex));
|
|
50
|
+
lines.push(line);
|
|
51
|
+
__classPrivateFieldSet(this, _LineDecoder_buffer, __classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(patternIndex.index), "f");
|
|
38
52
|
__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
39
|
-
continue;
|
|
40
53
|
}
|
|
41
|
-
|
|
42
|
-
const line = decodeUTF8(__classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(0, endIndex));
|
|
43
|
-
lines.push(line);
|
|
44
|
-
__classPrivateFieldSet(this, _LineDecoder_buffer, __classPrivateFieldGet(this, _LineDecoder_buffer, "f").subarray(patternIndex.index), "f");
|
|
45
|
-
__classPrivateFieldSet(this, _LineDecoder_carriageReturnIndex, null, "f");
|
|
54
|
+
return lines;
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return
|
|
56
|
+
flush() {
|
|
57
|
+
if (!__classPrivateFieldGet(this, _LineDecoder_buffer, "f").length) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
return this.decode('\n');
|
|
52
61
|
}
|
|
53
|
-
return this.decode('\n');
|
|
54
62
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
LineDecoder.
|
|
59
|
-
LineDecoder
|
|
63
|
+
_LineDecoder_buffer = new WeakMap(), _LineDecoder_carriageReturnIndex = new WeakMap();
|
|
64
|
+
// prettier-ignore
|
|
65
|
+
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r']);
|
|
66
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
67
|
+
return LineDecoder;
|
|
68
|
+
})();
|
|
60
69
|
/**
|
|
61
70
|
* This function searches the buffer for the end patterns, (\r or \n)
|
|
62
71
|
* and returns an object with the index preceding the matched newline and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.mjs","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,2BAAuB;AAIrE;;;;;GAKG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"line.mjs","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,2BAAuB;AAIrE;;;;;GAKG;AACH,MAAM;IANN;;;;;OAKG;IACH,MAAa,WAAW;QAQtB;YAHA,sCAAoB;YACpB,mDAAoC;YAGlC,uBAAA,IAAI,uBAAW,IAAI,UAAU,EAAE,MAAA,CAAC;YAChC,uBAAA,IAAI,oCAAwB,IAAI,MAAA,CAAC;QACnC,CAAC;QAED,MAAM,CAAC,KAAY;YACjB,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,MAAM,WAAW,GACf,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,IAAI,UAAU,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