@puku-ai/sdk 4.0.0 → 4.0.2
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/README.md +29 -10
- package/dist/index.d.ts +26 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/vendor/_vendor/partial-json-parser/parser.d.ts +2 -0
- package/dist/vendor/_vendor/partial-json-parser/parser.js +223 -0
- package/dist/vendor/_vendor/partial-json-parser/parser.js.map +1 -0
- package/dist/vendor/api-promise.d.ts +2 -0
- package/dist/vendor/api-promise.js +3 -0
- package/dist/vendor/api-promise.js.map +1 -0
- package/dist/vendor/client.d.ts +399 -0
- package/dist/vendor/client.js +976 -0
- package/dist/vendor/client.js.map +1 -0
- package/dist/vendor/core/api-promise.d.ts +49 -0
- package/dist/vendor/core/api-promise.js +77 -0
- package/dist/vendor/core/api-promise.js.map +1 -0
- package/dist/vendor/core/api.d.ts +10 -0
- package/dist/vendor/core/api.js +2 -0
- package/dist/vendor/core/api.js.map +1 -0
- package/dist/vendor/core/credentials.d.ts +130 -0
- package/dist/vendor/core/credentials.js +274 -0
- package/dist/vendor/core/credentials.js.map +1 -0
- package/dist/vendor/core/error.d.ts +82 -0
- package/dist/vendor/core/error.js +140 -0
- package/dist/vendor/core/error.js.map +1 -0
- package/dist/vendor/core/middleware.d.ts +153 -0
- package/dist/vendor/core/middleware.js +168 -0
- package/dist/vendor/core/middleware.js.map +1 -0
- package/dist/vendor/core/pagination.d.ts +121 -0
- package/dist/vendor/core/pagination.js +207 -0
- package/dist/vendor/core/pagination.js.map +1 -0
- package/dist/vendor/core/resource.d.ts +5 -0
- package/dist/vendor/core/resource.js +8 -0
- package/dist/vendor/core/resource.js.map +1 -0
- package/dist/vendor/core/streaming.d.ts +41 -0
- package/dist/vendor/core/streaming.js +342 -0
- package/dist/vendor/core/streaming.js.map +1 -0
- package/dist/vendor/core/uploads.d.ts +2 -0
- package/dist/vendor/core/uploads.js +2 -0
- package/dist/vendor/core/uploads.js.map +1 -0
- package/dist/vendor/error.d.ts +2 -0
- package/dist/vendor/error.js +3 -0
- package/dist/vendor/error.js.map +1 -0
- package/dist/vendor/helpers/beta/environments.d.ts +22 -0
- package/dist/vendor/helpers/beta/environments.js +23 -0
- package/dist/vendor/helpers/beta/environments.js.map +1 -0
- package/dist/vendor/helpers/beta/json-schema.d.ts +36 -0
- package/dist/vendor/helpers/beta/json-schema.js +53 -0
- package/dist/vendor/helpers/beta/json-schema.js.map +1 -0
- package/dist/vendor/helpers/beta/mcp.d.ts +302 -0
- package/dist/vendor/helpers/beta/mcp.js +406 -0
- package/dist/vendor/helpers/beta/mcp.js.map +1 -0
- package/dist/vendor/helpers/beta/memory.d.ts +10 -0
- package/dist/vendor/helpers/beta/memory.js +15 -0
- package/dist/vendor/helpers/beta/memory.js.map +1 -0
- package/dist/vendor/helpers/beta/standard-schema.d.ts +44 -0
- package/dist/vendor/helpers/beta/standard-schema.js +54 -0
- package/dist/vendor/helpers/beta/standard-schema.js.map +1 -0
- package/dist/vendor/helpers/beta/zod.d.ts +32 -0
- package/dist/vendor/helpers/beta/zod.js +52 -0
- package/dist/vendor/helpers/beta/zod.js.map +1 -0
- package/dist/vendor/helpers/index.d.ts +2 -0
- package/dist/vendor/helpers/index.js +3 -0
- package/dist/vendor/helpers/index.js.map +1 -0
- package/dist/vendor/helpers/json-schema.d.ts +17 -0
- package/dist/vendor/helpers/json-schema.js +34 -0
- package/dist/vendor/helpers/json-schema.js.map +1 -0
- package/dist/vendor/helpers/zod.d.ts +12 -0
- package/dist/vendor/helpers/zod.js +42 -0
- package/dist/vendor/helpers/zod.js.map +1 -0
- package/dist/vendor/index.d.ts +16 -0
- package/dist/vendor/index.js +23 -0
- package/dist/vendor/index.js.map +1 -0
- package/dist/vendor/internal/builtin-types.d.ts +72 -0
- package/dist/vendor/internal/builtin-types.js +3 -0
- package/dist/vendor/internal/builtin-types.js.map +1 -0
- package/dist/vendor/internal/constants.d.ts +4 -0
- package/dist/vendor/internal/constants.js +10 -0
- package/dist/vendor/internal/constants.js.map +1 -0
- package/dist/vendor/internal/decoders/jsonl.d.ts +9 -0
- package/dist/vendor/internal/decoders/jsonl.js +37 -0
- package/dist/vendor/internal/decoders/jsonl.js.map +1 -0
- package/dist/vendor/internal/decoders/line.d.ts +16 -0
- package/dist/vendor/internal/decoders/line.js +105 -0
- package/dist/vendor/internal/decoders/line.js.map +1 -0
- package/dist/vendor/internal/detect-platform.d.ts +14 -0
- package/dist/vendor/internal/detect-platform.js +155 -0
- package/dist/vendor/internal/detect-platform.js.map +1 -0
- package/dist/vendor/internal/errors.d.ts +2 -0
- package/dist/vendor/internal/errors.js +38 -0
- package/dist/vendor/internal/errors.js.map +1 -0
- package/dist/vendor/internal/file-store.d.ts +135 -0
- package/dist/vendor/internal/file-store.js +529 -0
- package/dist/vendor/internal/file-store.js.map +1 -0
- package/dist/vendor/internal/headers.d.ts +28 -0
- package/dist/vendor/internal/headers.js +114 -0
- package/dist/vendor/internal/headers.js.map +1 -0
- package/dist/vendor/internal/message-stream-utils.d.ts +9 -0
- package/dist/vendor/internal/message-stream-utils.js +30 -0
- package/dist/vendor/internal/message-stream-utils.js.map +1 -0
- package/dist/vendor/internal/node.browser.d.ts +8 -0
- package/dist/vendor/internal/node.browser.js +19 -0
- package/dist/vendor/internal/node.browser.js.map +1 -0
- package/dist/vendor/internal/node.d.ts +13 -0
- package/dist/vendor/internal/node.js +14 -0
- package/dist/vendor/internal/node.js.map +1 -0
- package/dist/vendor/internal/parse.d.ts +17 -0
- package/dist/vendor/internal/parse.js +62 -0
- package/dist/vendor/internal/parse.js.map +1 -0
- package/dist/vendor/internal/qs/formats.d.ts +6 -0
- package/dist/vendor/internal/qs/formats.js +9 -0
- package/dist/vendor/internal/qs/formats.js.map +1 -0
- package/dist/vendor/internal/qs/index.d.ts +9 -0
- package/dist/vendor/internal/qs/index.js +10 -0
- package/dist/vendor/internal/qs/index.js.map +1 -0
- package/dist/vendor/internal/qs/stringify.d.ts +2 -0
- package/dist/vendor/internal/qs/stringify.js +274 -0
- package/dist/vendor/internal/qs/stringify.js.map +1 -0
- package/dist/vendor/internal/qs/types.d.ts +56 -0
- package/dist/vendor/internal/qs/types.js +2 -0
- package/dist/vendor/internal/qs/types.js.map +1 -0
- package/dist/vendor/internal/qs/utils.d.ts +14 -0
- package/dist/vendor/internal/qs/utils.js +217 -0
- package/dist/vendor/internal/qs/utils.js.map +1 -0
- package/dist/vendor/internal/request-options.d.ts +126 -0
- package/dist/vendor/internal/request-options.js +27 -0
- package/dist/vendor/internal/request-options.js.map +1 -0
- package/dist/vendor/internal/request-signal.d.ts +3 -0
- package/dist/vendor/internal/request-signal.js +45 -0
- package/dist/vendor/internal/request-signal.js.map +1 -0
- package/dist/vendor/internal/shim-types.d.ts +16 -0
- package/dist/vendor/internal/shim-types.js +3 -0
- package/dist/vendor/internal/shim-types.js.map +1 -0
- package/dist/vendor/internal/shims.d.ts +25 -0
- package/dist/vendor/internal/shims.js +85 -0
- package/dist/vendor/internal/shims.js.map +1 -0
- package/dist/vendor/internal/stainless-helper-header.d.ts +59 -0
- package/dist/vendor/internal/stainless-helper-header.js +83 -0
- package/dist/vendor/internal/stainless-helper-header.js.map +1 -0
- package/dist/vendor/internal/stream-utils.d.ts +7 -0
- package/dist/vendor/internal/stream-utils.js +35 -0
- package/dist/vendor/internal/stream-utils.js.map +1 -0
- package/dist/vendor/internal/to-file.d.ts +44 -0
- package/dist/vendor/internal/to-file.js +93 -0
- package/dist/vendor/internal/to-file.js.map +1 -0
- package/dist/vendor/internal/types.d.ts +62 -0
- package/dist/vendor/internal/types.js +3 -0
- package/dist/vendor/internal/types.js.map +1 -0
- package/dist/vendor/internal/uploads.d.ts +41 -0
- package/dist/vendor/internal/uploads.js +139 -0
- package/dist/vendor/internal/uploads.js.map +1 -0
- package/dist/vendor/internal/utils/abort.d.ts +11 -0
- package/dist/vendor/internal/utils/abort.js +22 -0
- package/dist/vendor/internal/utils/abort.js.map +1 -0
- package/dist/vendor/internal/utils/async-queue.d.ts +30 -0
- package/dist/vendor/internal/utils/async-queue.js +66 -0
- package/dist/vendor/internal/utils/async-queue.js.map +1 -0
- package/dist/vendor/internal/utils/backoff.d.ts +22 -0
- package/dist/vendor/internal/utils/backoff.js +36 -0
- package/dist/vendor/internal/utils/backoff.js.map +1 -0
- package/dist/vendor/internal/utils/base64.d.ts +2 -0
- package/dist/vendor/internal/utils/base64.js +33 -0
- package/dist/vendor/internal/utils/base64.js.map +1 -0
- package/dist/vendor/internal/utils/bytes.d.ts +3 -0
- package/dist/vendor/internal/utils/bytes.js +26 -0
- package/dist/vendor/internal/utils/bytes.js.map +1 -0
- package/dist/vendor/internal/utils/env.d.ts +8 -0
- package/dist/vendor/internal/utils/env.js +18 -0
- package/dist/vendor/internal/utils/env.js.map +1 -0
- package/dist/vendor/internal/utils/log.d.ts +46 -0
- package/dist/vendor/internal/utils/log.js +105 -0
- package/dist/vendor/internal/utils/log.js.map +1 -0
- package/dist/vendor/internal/utils/path.d.ts +14 -0
- package/dist/vendor/internal/utils/path.js +74 -0
- package/dist/vendor/internal/utils/path.js.map +1 -0
- package/dist/vendor/internal/utils/promise.d.ts +10 -0
- package/dist/vendor/internal/utils/promise.js +15 -0
- package/dist/vendor/internal/utils/promise.js.map +1 -0
- package/dist/vendor/internal/utils/query.d.ts +1 -0
- package/dist/vendor/internal/utils/query.js +6 -0
- package/dist/vendor/internal/utils/query.js.map +1 -0
- package/dist/vendor/internal/utils/sleep.d.ts +9 -0
- package/dist/vendor/internal/utils/sleep.js +24 -0
- package/dist/vendor/internal/utils/sleep.js.map +1 -0
- package/dist/vendor/internal/utils/time.d.ts +2 -0
- package/dist/vendor/internal/utils/time.js +5 -0
- package/dist/vendor/internal/utils/time.js.map +1 -0
- package/dist/vendor/internal/utils/uuid.d.ts +4 -0
- package/dist/vendor/internal/utils/uuid.js +15 -0
- package/dist/vendor/internal/utils/uuid.js.map +1 -0
- package/dist/vendor/internal/utils/values.d.ts +24 -0
- package/dist/vendor/internal/utils/values.js +106 -0
- package/dist/vendor/internal/utils/values.js.map +1 -0
- package/dist/vendor/internal/utils.d.ts +7 -0
- package/dist/vendor/internal/utils.js +9 -0
- package/dist/vendor/internal/utils.js.map +1 -0
- package/dist/vendor/lib/BetaMessageStream.d.ts +123 -0
- package/dist/vendor/lib/BetaMessageStream.js +662 -0
- package/dist/vendor/lib/BetaMessageStream.js.map +1 -0
- package/dist/vendor/lib/MessageStream.d.ts +122 -0
- package/dist/vendor/lib/MessageStream.js +609 -0
- package/dist/vendor/lib/MessageStream.js.map +1 -0
- package/dist/vendor/lib/beta-parser.d.ts +36 -0
- package/dist/vendor/lib/beta-parser.js +75 -0
- package/dist/vendor/lib/beta-parser.js.map +1 -0
- package/dist/vendor/lib/credentials/credential-chain.d.ts +38 -0
- package/dist/vendor/lib/credentials/credential-chain.js +208 -0
- package/dist/vendor/lib/credentials/credential-chain.js.map +1 -0
- package/dist/vendor/lib/credentials/identity-token.d.ts +10 -0
- package/dist/vendor/lib/credentials/identity-token.js +35 -0
- package/dist/vendor/lib/credentials/identity-token.js.map +1 -0
- package/dist/vendor/lib/credentials/oidc-federation.d.ts +39 -0
- package/dist/vendor/lib/credentials/oidc-federation.js +79 -0
- package/dist/vendor/lib/credentials/oidc-federation.js.map +1 -0
- package/dist/vendor/lib/credentials/token-cache.d.ts +53 -0
- package/dist/vendor/lib/credentials/token-cache.js +110 -0
- package/dist/vendor/lib/credentials/token-cache.js.map +1 -0
- package/dist/vendor/lib/credentials/types.d.ts +95 -0
- package/dist/vendor/lib/credentials/types.js +226 -0
- package/dist/vendor/lib/credentials/types.js.map +1 -0
- package/dist/vendor/lib/credentials/user-oauth.d.ts +20 -0
- package/dist/vendor/lib/credentials/user-oauth.js +94 -0
- package/dist/vendor/lib/credentials/user-oauth.js.map +1 -0
- package/dist/vendor/lib/credentials.d.ts +3 -0
- package/dist/vendor/lib/credentials.js +3 -0
- package/dist/vendor/lib/credentials.js.map +1 -0
- package/dist/vendor/lib/environments/index.d.ts +3 -0
- package/dist/vendor/lib/environments/index.js +4 -0
- package/dist/vendor/lib/environments/index.js.map +1 -0
- package/dist/vendor/lib/environments/poller.d.ts +94 -0
- package/dist/vendor/lib/environments/poller.js +218 -0
- package/dist/vendor/lib/environments/poller.js.map +1 -0
- package/dist/vendor/lib/environments/worker.d.ts +226 -0
- package/dist/vendor/lib/environments/worker.js +572 -0
- package/dist/vendor/lib/environments/worker.js.map +1 -0
- package/dist/vendor/lib/helper-client.d.ts +30 -0
- package/dist/vendor/lib/helper-client.js +55 -0
- package/dist/vendor/lib/helper-client.js.map +1 -0
- package/dist/vendor/lib/middleware.d.ts +97 -0
- package/dist/vendor/lib/middleware.js +775 -0
- package/dist/vendor/lib/middleware.js.map +1 -0
- package/dist/vendor/lib/parser.d.ts +31 -0
- package/dist/vendor/lib/parser.js +62 -0
- package/dist/vendor/lib/parser.js.map +1 -0
- package/dist/vendor/lib/sessions/accumulate.d.ts +22 -0
- package/dist/vendor/lib/sessions/accumulate.js +42 -0
- package/dist/vendor/lib/sessions/accumulate.js.map +1 -0
- package/dist/vendor/lib/standard-schema.d.ts +130 -0
- package/dist/vendor/lib/standard-schema.js +41 -0
- package/dist/vendor/lib/standard-schema.js.map +1 -0
- package/dist/vendor/lib/tools/BetaRunnableTool.d.ts +48 -0
- package/dist/vendor/lib/tools/BetaRunnableTool.js +26 -0
- package/dist/vendor/lib/tools/BetaRunnableTool.js.map +1 -0
- package/dist/vendor/lib/tools/BetaToolRunner.d.ts +160 -0
- package/dist/vendor/lib/tools/BetaToolRunner.js +497 -0
- package/dist/vendor/lib/tools/BetaToolRunner.js.map +1 -0
- package/dist/vendor/lib/tools/CompactionControl.d.ts +29 -0
- package/dist/vendor/lib/tools/CompactionControl.js +25 -0
- package/dist/vendor/lib/tools/CompactionControl.js.map +1 -0
- package/dist/vendor/lib/tools/SessionToolRunner.d.ts +178 -0
- package/dist/vendor/lib/tools/SessionToolRunner.js +737 -0
- package/dist/vendor/lib/tools/SessionToolRunner.js.map +1 -0
- package/dist/vendor/lib/tools/ToolError.d.ts +32 -0
- package/dist/vendor/lib/tools/ToolError.js +43 -0
- package/dist/vendor/lib/tools/ToolError.js.map +1 -0
- package/dist/vendor/lib/transform-json-schema.d.ts +2 -0
- package/dist/vendor/lib/transform-json-schema.js +111 -0
- package/dist/vendor/lib/transform-json-schema.js.map +1 -0
- package/dist/vendor/pagination.d.ts +2 -0
- package/dist/vendor/pagination.js +3 -0
- package/dist/vendor/pagination.js.map +1 -0
- package/dist/vendor/resource.d.ts +2 -0
- package/dist/vendor/resource.js +3 -0
- package/dist/vendor/resource.js.map +1 -0
- package/dist/vendor/resources/beta/agents/agents.d.ts +1128 -0
- package/dist/vendor/resources/beta/agents/agents.js +123 -0
- package/dist/vendor/resources/beta/agents/agents.js.map +1 -0
- package/dist/vendor/resources/beta/agents/index.d.ts +2 -0
- package/dist/vendor/resources/beta/agents/index.js +4 -0
- package/dist/vendor/resources/beta/agents/index.js.map +1 -0
- package/dist/vendor/resources/beta/agents/versions.d.ts +32 -0
- package/dist/vendor/resources/beta/agents/versions.js +32 -0
- package/dist/vendor/resources/beta/agents/versions.js.map +1 -0
- package/dist/vendor/resources/beta/agents.d.ts +1 -0
- package/dist/vendor/resources/beta/agents.js +3 -0
- package/dist/vendor/resources/beta/agents.js.map +1 -0
- package/dist/vendor/resources/beta/beta.d.ts +131 -0
- package/dist/vendor/resources/beta/beta.js +69 -0
- package/dist/vendor/resources/beta/beta.js.map +1 -0
- package/dist/vendor/resources/beta/deployment-runs.d.ts +305 -0
- package/dist/vendor/resources/beta/deployment-runs.js +51 -0
- package/dist/vendor/resources/beta/deployment-runs.js.map +1 -0
- package/dist/vendor/resources/beta/deployments.d.ts +698 -0
- package/dist/vendor/resources/beta/deployments.js +192 -0
- package/dist/vendor/resources/beta/deployments.js.map +1 -0
- package/dist/vendor/resources/beta/dreams.d.ts +335 -0
- package/dist/vendor/resources/beta/dreams.js +112 -0
- package/dist/vendor/resources/beta/dreams.js.map +1 -0
- package/dist/vendor/resources/beta/environments/environments.d.ts +432 -0
- package/dist/vendor/resources/beta/environments/environments.js +142 -0
- package/dist/vendor/resources/beta/environments/environments.js.map +1 -0
- package/dist/vendor/resources/beta/environments/index.d.ts +2 -0
- package/dist/vendor/resources/beta/environments/index.js +4 -0
- package/dist/vendor/resources/beta/environments/index.js.map +1 -0
- package/dist/vendor/resources/beta/environments/work.d.ts +500 -0
- package/dist/vendor/resources/beta/environments/work.js +251 -0
- package/dist/vendor/resources/beta/environments/work.js.map +1 -0
- package/dist/vendor/resources/beta/environments.d.ts +1 -0
- package/dist/vendor/resources/beta/environments.js +3 -0
- package/dist/vendor/resources/beta/environments.js.map +1 -0
- package/dist/vendor/resources/beta/files.d.ts +190 -0
- package/dist/vendor/resources/beta/files.js +120 -0
- package/dist/vendor/resources/beta/files.js.map +1 -0
- package/dist/vendor/resources/beta/index.d.ts +17 -0
- package/dist/vendor/resources/beta/index.js +19 -0
- package/dist/vendor/resources/beta/index.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/index.d.ts +3 -0
- package/dist/vendor/resources/beta/memory-stores/index.js +5 -0
- package/dist/vendor/resources/beta/memory-stores/index.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/memories.d.ts +346 -0
- package/dist/vendor/resources/beta/memory-stores/memories.js +126 -0
- package/dist/vendor/resources/beta/memory-stores/memories.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/memory-stores.d.ts +230 -0
- package/dist/vendor/resources/beta/memory-stores/memory-stores.js +137 -0
- package/dist/vendor/resources/beta/memory-stores/memory-stores.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/memory-versions.d.ts +252 -0
- package/dist/vendor/resources/beta/memory-stores/memory-versions.js +77 -0
- package/dist/vendor/resources/beta/memory-stores/memory-versions.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores.d.ts +1 -0
- package/dist/vendor/resources/beta/memory-stores.js +3 -0
- package/dist/vendor/resources/beta/memory-stores.js.map +1 -0
- package/dist/vendor/resources/beta/messages/batches.d.ts +685 -0
- package/dist/vendor/resources/beta/messages/batches.js +203 -0
- package/dist/vendor/resources/beta/messages/batches.js.map +1 -0
- package/dist/vendor/resources/beta/messages/index.d.ts +3 -0
- package/dist/vendor/resources/beta/messages/index.js +5 -0
- package/dist/vendor/resources/beta/messages/index.js.map +1 -0
- package/dist/vendor/resources/beta/messages/messages.d.ts +5376 -0
- package/dist/vendor/resources/beta/messages/messages.js +158 -0
- package/dist/vendor/resources/beta/messages/messages.js.map +1 -0
- package/dist/vendor/resources/beta/messages.d.ts +1 -0
- package/dist/vendor/resources/beta/messages.js +3 -0
- package/dist/vendor/resources/beta/messages.js.map +1 -0
- package/dist/vendor/resources/beta/models.d.ts +217 -0
- package/dist/vendor/resources/beta/models.js +56 -0
- package/dist/vendor/resources/beta/models.js.map +1 -0
- package/dist/vendor/resources/beta/organization/api-keys.d.ts +176 -0
- package/dist/vendor/resources/beta/organization/api-keys.js +52 -0
- package/dist/vendor/resources/beta/organization/api-keys.js.map +1 -0
- package/dist/vendor/resources/beta/organization/compliance-settings.d.ts +73 -0
- package/dist/vendor/resources/beta/organization/compliance-settings.js +48 -0
- package/dist/vendor/resources/beta/organization/compliance-settings.js.map +1 -0
- package/dist/vendor/resources/beta/organization/external-keys.d.ts +271 -0
- package/dist/vendor/resources/beta/organization/external-keys.js +115 -0
- package/dist/vendor/resources/beta/organization/external-keys.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/federation.d.ts +13 -0
- package/dist/vendor/resources/beta/organization/federation/federation.js +13 -0
- package/dist/vendor/resources/beta/organization/federation/federation.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/index.d.ts +3 -0
- package/dist/vendor/resources/beta/organization/federation/index.js +5 -0
- package/dist/vendor/resources/beta/organization/federation/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/issuers.d.ts +352 -0
- package/dist/vendor/resources/beta/organization/federation/issuers.js +165 -0
- package/dist/vendor/resources/beta/organization/federation/issuers.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules/index.d.ts +2 -0
- package/dist/vendor/resources/beta/organization/federation/rules/index.js +4 -0
- package/dist/vendor/resources/beta/organization/federation/rules/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules/rules.d.ts +467 -0
- package/dist/vendor/resources/beta/organization/federation/rules/rules.js +190 -0
- package/dist/vendor/resources/beta/organization/federation/rules/rules.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules/workspaces.d.ts +123 -0
- package/dist/vendor/resources/beta/organization/federation/rules/workspaces.js +110 -0
- package/dist/vendor/resources/beta/organization/federation/rules/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules.js +3 -0
- package/dist/vendor/resources/beta/organization/federation/rules.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/federation.js +3 -0
- package/dist/vendor/resources/beta/organization/federation.js.map +1 -0
- package/dist/vendor/resources/beta/organization/index.d.ts +10 -0
- package/dist/vendor/resources/beta/organization/index.js +12 -0
- package/dist/vendor/resources/beta/organization/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/invites.d.ts +161 -0
- package/dist/vendor/resources/beta/organization/invites.js +72 -0
- package/dist/vendor/resources/beta/organization/invites.js.map +1 -0
- package/dist/vendor/resources/beta/organization/organization.d.ts +72 -0
- package/dist/vendor/resources/beta/organization/organization.js +54 -0
- package/dist/vendor/resources/beta/organization/organization.js.map +1 -0
- package/dist/vendor/resources/beta/organization/rate-limits.d.ts +76 -0
- package/dist/vendor/resources/beta/organization/rate-limits.js +27 -0
- package/dist/vendor/resources/beta/organization/rate-limits.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts/index.d.ts +2 -0
- package/dist/vendor/resources/beta/organization/service-accounts/index.js +4 -0
- package/dist/vendor/resources/beta/organization/service-accounts/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts/service-accounts.d.ts +257 -0
- package/dist/vendor/resources/beta/organization/service-accounts/service-accounts.js +166 -0
- package/dist/vendor/resources/beta/organization/service-accounts/service-accounts.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts/workspaces.d.ts +140 -0
- package/dist/vendor/resources/beta/organization/service-accounts/workspaces.js +121 -0
- package/dist/vendor/resources/beta/organization/service-accounts/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts.js +3 -0
- package/dist/vendor/resources/beta/organization/service-accounts.js.map +1 -0
- package/dist/vendor/resources/beta/organization/users.d.ts +123 -0
- package/dist/vendor/resources/beta/organization/users.js +63 -0
- package/dist/vendor/resources/beta/organization/users.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/index.d.ts +4 -0
- package/dist/vendor/resources/beta/organization/workspaces/index.js +6 -0
- package/dist/vendor/resources/beta/organization/workspaces/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/members.d.ts +134 -0
- package/dist/vendor/resources/beta/organization/workspaces/members.js +98 -0
- package/dist/vendor/resources/beta/organization/workspaces/members.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/rate-limits.d.ts +82 -0
- package/dist/vendor/resources/beta/organization/workspaces/rate-limits.js +30 -0
- package/dist/vendor/resources/beta/organization/workspaces/rate-limits.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/service-accounts.d.ts +209 -0
- package/dist/vendor/resources/beta/organization/workspaces/service-accounts.js +185 -0
- package/dist/vendor/resources/beta/organization/workspaces/service-accounts.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/workspaces.d.ts +302 -0
- package/dist/vendor/resources/beta/organization/workspaces/workspaces.js +104 -0
- package/dist/vendor/resources/beta/organization/workspaces/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/workspaces.js +3 -0
- package/dist/vendor/resources/beta/organization/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization.d.ts +1 -0
- package/dist/vendor/resources/beta/organization.js +3 -0
- package/dist/vendor/resources/beta/organization.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/events.d.ts +1513 -0
- package/dist/vendor/resources/beta/sessions/events.js +115 -0
- package/dist/vendor/resources/beta/sessions/events.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/index.d.ts +4 -0
- package/dist/vendor/resources/beta/sessions/index.js +6 -0
- package/dist/vendor/resources/beta/sessions/index.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/resources.d.ts +227 -0
- package/dist/vendor/resources/beta/sessions/resources.js +128 -0
- package/dist/vendor/resources/beta/sessions/resources.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/sessions.d.ts +866 -0
- package/dist/vendor/resources/beta/sessions/sessions.js +150 -0
- package/dist/vendor/resources/beta/sessions/sessions.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads/events.d.ts +77 -0
- package/dist/vendor/resources/beta/sessions/threads/events.js +57 -0
- package/dist/vendor/resources/beta/sessions/threads/events.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads/index.d.ts +2 -0
- package/dist/vendor/resources/beta/sessions/threads/index.js +4 -0
- package/dist/vendor/resources/beta/sessions/threads/index.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads/threads.d.ts +195 -0
- package/dist/vendor/resources/beta/sessions/threads/threads.js +80 -0
- package/dist/vendor/resources/beta/sessions/threads/threads.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads.d.ts +1 -0
- package/dist/vendor/resources/beta/sessions/threads.js +3 -0
- package/dist/vendor/resources/beta/sessions/threads.js.map +1 -0
- package/dist/vendor/resources/beta/sessions.d.ts +1 -0
- package/dist/vendor/resources/beta/sessions.js +3 -0
- package/dist/vendor/resources/beta/sessions.js.map +1 -0
- package/dist/vendor/resources/beta/skills/index.d.ts +2 -0
- package/dist/vendor/resources/beta/skills/index.js +4 -0
- package/dist/vendor/resources/beta/skills/index.js.map +1 -0
- package/dist/vendor/resources/beta/skills/skills.d.ts +178 -0
- package/dist/vendor/resources/beta/skills/skills.js +96 -0
- package/dist/vendor/resources/beta/skills/skills.js.map +1 -0
- package/dist/vendor/resources/beta/skills/versions.d.ts +181 -0
- package/dist/vendor/resources/beta/skills/versions.js +125 -0
- package/dist/vendor/resources/beta/skills/versions.js.map +1 -0
- package/dist/vendor/resources/beta/skills.d.ts +1 -0
- package/dist/vendor/resources/beta/skills.js +3 -0
- package/dist/vendor/resources/beta/skills.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels/certificates.d.ts +162 -0
- package/dist/vendor/resources/beta/tunnels/certificates.js +125 -0
- package/dist/vendor/resources/beta/tunnels/certificates.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels/index.d.ts +2 -0
- package/dist/vendor/resources/beta/tunnels/index.js +4 -0
- package/dist/vendor/resources/beta/tunnels/index.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels/tunnels.d.ts +211 -0
- package/dist/vendor/resources/beta/tunnels/tunnels.js +173 -0
- package/dist/vendor/resources/beta/tunnels/tunnels.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels.d.ts +1 -0
- package/dist/vendor/resources/beta/tunnels.js +3 -0
- package/dist/vendor/resources/beta/tunnels.js.map +1 -0
- package/dist/vendor/resources/beta/user-profiles.d.ts +244 -0
- package/dist/vendor/resources/beta/user-profiles.js +114 -0
- package/dist/vendor/resources/beta/user-profiles.js.map +1 -0
- package/dist/vendor/resources/beta/vaults/credentials.d.ts +715 -0
- package/dist/vendor/resources/beta/vaults/credentials.js +173 -0
- package/dist/vendor/resources/beta/vaults/credentials.js.map +1 -0
- package/dist/vendor/resources/beta/vaults/index.d.ts +2 -0
- package/dist/vendor/resources/beta/vaults/index.js +4 -0
- package/dist/vendor/resources/beta/vaults/index.js.map +1 -0
- package/dist/vendor/resources/beta/vaults/vaults.d.ts +191 -0
- package/dist/vendor/resources/beta/vaults/vaults.js +141 -0
- package/dist/vendor/resources/beta/vaults/vaults.js.map +1 -0
- package/dist/vendor/resources/beta/vaults.d.ts +1 -0
- package/dist/vendor/resources/beta/vaults.js +3 -0
- package/dist/vendor/resources/beta/vaults.js.map +1 -0
- package/dist/vendor/resources/beta/webhooks.d.ts +464 -0
- package/dist/vendor/resources/beta/webhooks.js +29 -0
- package/dist/vendor/resources/beta/webhooks.js.map +1 -0
- package/dist/vendor/resources/beta.d.ts +1 -0
- package/dist/vendor/resources/beta.js +3 -0
- package/dist/vendor/resources/beta.js.map +1 -0
- package/dist/vendor/resources/completions.d.ts +172 -0
- package/dist/vendor/resources/completions.js +19 -0
- package/dist/vendor/resources/completions.js.map +1 -0
- package/dist/vendor/resources/files.d.ts +104 -0
- package/dist/vendor/resources/files.js +48 -0
- package/dist/vendor/resources/files.js.map +1 -0
- package/dist/vendor/resources/index.d.ts +7 -0
- package/dist/vendor/resources/index.js +9 -0
- package/dist/vendor/resources/index.js.map +1 -0
- package/dist/vendor/resources/messages/batches.d.ts +312 -0
- package/dist/vendor/resources/messages/batches.js +157 -0
- package/dist/vendor/resources/messages/batches.js.map +1 -0
- package/dist/vendor/resources/messages/index.d.ts +2 -0
- package/dist/vendor/resources/messages/index.js +4 -0
- package/dist/vendor/resources/messages/index.js.map +1 -0
- package/dist/vendor/resources/messages/messages.d.ts +3886 -0
- package/dist/vendor/resources/messages/messages.js +130 -0
- package/dist/vendor/resources/messages/messages.js.map +1 -0
- package/dist/vendor/resources/messages.d.ts +1 -0
- package/dist/vendor/resources/messages.js +3 -0
- package/dist/vendor/resources/messages.js.map +1 -0
- package/dist/vendor/resources/models.d.ts +196 -0
- package/dist/vendor/resources/models.js +41 -0
- package/dist/vendor/resources/models.js.map +1 -0
- package/dist/vendor/resources/shared.d.ts +43 -0
- package/dist/vendor/resources/shared.js +3 -0
- package/dist/vendor/resources/shared.js.map +1 -0
- package/dist/vendor/resources/skills/index.d.ts +2 -0
- package/dist/vendor/resources/skills/index.js +4 -0
- package/dist/vendor/resources/skills/index.js.map +1 -0
- package/dist/vendor/resources/skills/skills.d.ts +128 -0
- package/dist/vendor/resources/skills/skills.js +36 -0
- package/dist/vendor/resources/skills/skills.js.map +1 -0
- package/dist/vendor/resources/skills/versions.d.ts +103 -0
- package/dist/vendor/resources/skills/versions.js +37 -0
- package/dist/vendor/resources/skills/versions.js.map +1 -0
- package/dist/vendor/resources/skills.d.ts +1 -0
- package/dist/vendor/resources/skills.js +3 -0
- package/dist/vendor/resources/skills.js.map +1 -0
- package/dist/vendor/resources/top-level.d.ts +1 -0
- package/dist/vendor/resources/top-level.js +3 -0
- package/dist/vendor/resources/top-level.js.map +1 -0
- package/dist/vendor/resources.d.ts +1 -0
- package/dist/vendor/resources.js +2 -0
- package/dist/vendor/resources.js.map +1 -0
- package/dist/vendor/streaming.d.ts +2 -0
- package/dist/vendor/streaming.js +3 -0
- package/dist/vendor/streaming.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/fs-util.d.ts +74 -0
- package/dist/vendor/tools/agent-toolset/fs-util.js +184 -0
- package/dist/vendor/tools/agent-toolset/fs-util.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/memories.d.ts +172 -0
- package/dist/vendor/tools/agent-toolset/memories.js +910 -0
- package/dist/vendor/tools/agent-toolset/memories.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/node.browser.d.ts +80 -0
- package/dist/vendor/tools/agent-toolset/node.browser.js +129 -0
- package/dist/vendor/tools/agent-toolset/node.browser.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/node.d.ts +191 -0
- package/dist/vendor/tools/agent-toolset/node.js +886 -0
- package/dist/vendor/tools/agent-toolset/node.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/skills.d.ts +73 -0
- package/dist/vendor/tools/agent-toolset/skills.js +320 -0
- package/dist/vendor/tools/agent-toolset/skills.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/sync-interval.d.ts +18 -0
- package/dist/vendor/tools/agent-toolset/sync-interval.js +25 -0
- package/dist/vendor/tools/agent-toolset/sync-interval.js.map +1 -0
- package/dist/vendor/tools/memory/node.browser.d.ts +26 -0
- package/dist/vendor/tools/memory/node.browser.js +44 -0
- package/dist/vendor/tools/memory/node.browser.js.map +1 -0
- package/dist/vendor/tools/memory/node.d.ts +17 -0
- package/dist/vendor/tools/memory/node.js +327 -0
- package/dist/vendor/tools/memory/node.js.map +1 -0
- package/dist/vendor/uploads.d.ts +2 -0
- package/dist/vendor/uploads.js +3 -0
- package/dist/vendor/uploads.js.map +1 -0
- package/dist/vendor/version.d.ts +1 -0
- package/dist/vendor/version.js +2 -0
- package/dist/vendor/version.js.map +1 -0
- package/package.json +7 -14
- package/sdk.cjs +6 -6
- package/sdk.cjs.map +18 -18
- package/sdk.d.ts +10 -10
- package/sdk.mjs +21 -21
- package/sdk.mjs.map +18 -18
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { PukuError } from './error.js';
|
|
2
|
+
import { makeReadableStream } from '../internal/shims.js';
|
|
3
|
+
import { findDoubleNewlineIndex, LineDecoder } from '../internal/decoders/line.js';
|
|
4
|
+
import { ReadableStreamToAsyncIterable } from '../internal/shims.js';
|
|
5
|
+
import { isAbortError } from '../internal/errors.js';
|
|
6
|
+
import { safeJSON } from '../internal/utils/values.js';
|
|
7
|
+
import { encodeUTF8 } from '../internal/utils/bytes.js';
|
|
8
|
+
import { loggerFor } from '../internal/utils/log.js';
|
|
9
|
+
import { APIError } from './error.js';
|
|
10
|
+
import { releaseRequestSignal } from '../internal/request-signal.js';
|
|
11
|
+
export class Stream {
|
|
12
|
+
iterator;
|
|
13
|
+
controller;
|
|
14
|
+
#client;
|
|
15
|
+
constructor(iterator, controller, client) {
|
|
16
|
+
this.iterator = iterator;
|
|
17
|
+
this.controller = controller;
|
|
18
|
+
this.#client = client;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Iterate the raw Server-Sent Events from `response` — `{event, data, raw}`
|
|
22
|
+
* objects, before any JSON parsing or event-name filtering.
|
|
23
|
+
*
|
|
24
|
+
* This reads `response.body` directly (not a clone), so the response is
|
|
25
|
+
* consumed. Use this in middleware that fully replaces the stream body; for
|
|
26
|
+
* read-only observation of parsed events, use `ctx.parse()` instead.
|
|
27
|
+
*/
|
|
28
|
+
static rawEvents(response, controller = new AbortController()) {
|
|
29
|
+
return _iterSSEMessages(response, controller);
|
|
30
|
+
}
|
|
31
|
+
static fromSSEResponse(response, controller, client) {
|
|
32
|
+
let consumed = false;
|
|
33
|
+
const logger = client ? loggerFor(client) : console;
|
|
34
|
+
async function* iterator() {
|
|
35
|
+
if (consumed) {
|
|
36
|
+
throw new PukuError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
37
|
+
}
|
|
38
|
+
consumed = true;
|
|
39
|
+
let done = false;
|
|
40
|
+
try {
|
|
41
|
+
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
42
|
+
if (sse.event === 'completion') {
|
|
43
|
+
try {
|
|
44
|
+
yield JSON.parse(sse.data);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
48
|
+
logger.error(`From chunk:`, sse.raw);
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (sse.event === 'message_start' ||
|
|
53
|
+
sse.event === 'message_delta' ||
|
|
54
|
+
sse.event === 'message_stop' ||
|
|
55
|
+
sse.event === 'content_block_start' ||
|
|
56
|
+
sse.event === 'content_block_delta' ||
|
|
57
|
+
sse.event === 'content_block_stop' ||
|
|
58
|
+
sse.event === 'message' ||
|
|
59
|
+
sse.event === 'user.message' ||
|
|
60
|
+
sse.event === 'user.interrupt' ||
|
|
61
|
+
sse.event === 'user.tool_confirmation' ||
|
|
62
|
+
sse.event === 'user.custom_tool_result' ||
|
|
63
|
+
sse.event === 'user.tool_result' ||
|
|
64
|
+
sse.event === 'agent.message' ||
|
|
65
|
+
sse.event === 'agent.thinking' ||
|
|
66
|
+
sse.event === 'agent.tool_use' ||
|
|
67
|
+
sse.event === 'agent.tool_result' ||
|
|
68
|
+
sse.event === 'agent.mcp_tool_use' ||
|
|
69
|
+
sse.event === 'agent.mcp_tool_result' ||
|
|
70
|
+
sse.event === 'agent.custom_tool_use' ||
|
|
71
|
+
sse.event === 'agent.thread_context_compacted' ||
|
|
72
|
+
sse.event === 'session.status_running' ||
|
|
73
|
+
sse.event === 'session.status_idle' ||
|
|
74
|
+
sse.event === 'session.status_rescheduled' ||
|
|
75
|
+
sse.event === 'session.status_terminated' ||
|
|
76
|
+
sse.event === 'session.error' ||
|
|
77
|
+
sse.event === 'session.deleted' ||
|
|
78
|
+
sse.event === 'session.updated' ||
|
|
79
|
+
sse.event === 'span.model_request_start' ||
|
|
80
|
+
sse.event === 'span.model_request_end' ||
|
|
81
|
+
sse.event === 'span.outcome_evaluation_start' ||
|
|
82
|
+
sse.event === 'span.outcome_evaluation_ongoing' ||
|
|
83
|
+
sse.event === 'span.outcome_evaluation_end' ||
|
|
84
|
+
sse.event === 'user.define_outcome' ||
|
|
85
|
+
sse.event === 'agent.thread_message_received' ||
|
|
86
|
+
sse.event === 'agent.thread_message_sent' ||
|
|
87
|
+
sse.event === 'agent.session_thread_message_received' ||
|
|
88
|
+
sse.event === 'agent.session_thread_message_sent' ||
|
|
89
|
+
sse.event === 'session.thread_created' ||
|
|
90
|
+
sse.event === 'session.thread_status_created' ||
|
|
91
|
+
sse.event === 'session.thread_status_running' ||
|
|
92
|
+
sse.event === 'session.thread_status_idle' ||
|
|
93
|
+
sse.event === 'session.thread_status_rescheduled' ||
|
|
94
|
+
sse.event === 'session.thread_status_terminated' ||
|
|
95
|
+
sse.event === 'event_start' ||
|
|
96
|
+
sse.event === 'event_delta' ||
|
|
97
|
+
sse.event === 'system.message') {
|
|
98
|
+
try {
|
|
99
|
+
yield JSON.parse(sse.data);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
103
|
+
logger.error(`From chunk:`, sse.raw);
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (sse.event === 'ping') {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (sse.event === 'error') {
|
|
111
|
+
const body = safeJSON(sse.data) ?? sse.data;
|
|
112
|
+
const type = body?.error?.type;
|
|
113
|
+
throw new APIError(undefined, body, undefined, response.headers, type);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
done = true;
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
120
|
+
if (isAbortError(e))
|
|
121
|
+
return;
|
|
122
|
+
throw e;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
// If the user `break`s, abort the ongoing request.
|
|
126
|
+
if (!done)
|
|
127
|
+
controller.abort();
|
|
128
|
+
releaseRequestSignal(controller);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return new Stream(iterator, controller, client);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
135
|
+
* where each item is a JSON value.
|
|
136
|
+
*/
|
|
137
|
+
static fromReadableStream(readableStream, controller, client) {
|
|
138
|
+
let consumed = false;
|
|
139
|
+
async function* iterLines() {
|
|
140
|
+
const lineDecoder = new LineDecoder();
|
|
141
|
+
const iter = ReadableStreamToAsyncIterable(readableStream);
|
|
142
|
+
for await (const chunk of iter) {
|
|
143
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
144
|
+
yield line;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const line of lineDecoder.flush()) {
|
|
148
|
+
yield line;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function* iterator() {
|
|
152
|
+
if (consumed) {
|
|
153
|
+
throw new PukuError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
154
|
+
}
|
|
155
|
+
consumed = true;
|
|
156
|
+
let done = false;
|
|
157
|
+
try {
|
|
158
|
+
for await (const line of iterLines()) {
|
|
159
|
+
if (done)
|
|
160
|
+
continue;
|
|
161
|
+
if (line)
|
|
162
|
+
yield JSON.parse(line);
|
|
163
|
+
}
|
|
164
|
+
done = true;
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
168
|
+
if (isAbortError(e))
|
|
169
|
+
return;
|
|
170
|
+
throw e;
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
// If the user `break`s, abort the ongoing request.
|
|
174
|
+
if (!done)
|
|
175
|
+
controller.abort();
|
|
176
|
+
releaseRequestSignal(controller);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return new Stream(iterator, controller, client);
|
|
180
|
+
}
|
|
181
|
+
[Symbol.asyncIterator]() {
|
|
182
|
+
return this.iterator();
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Splits the stream into two streams which can be
|
|
186
|
+
* independently read from at different speeds.
|
|
187
|
+
*/
|
|
188
|
+
tee() {
|
|
189
|
+
const left = [];
|
|
190
|
+
const right = [];
|
|
191
|
+
const iterator = this.iterator();
|
|
192
|
+
const teeIterator = (queue) => {
|
|
193
|
+
return {
|
|
194
|
+
next: () => {
|
|
195
|
+
if (queue.length === 0) {
|
|
196
|
+
const result = iterator.next();
|
|
197
|
+
left.push(result);
|
|
198
|
+
right.push(result);
|
|
199
|
+
}
|
|
200
|
+
return queue.shift();
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
return [
|
|
205
|
+
new Stream(() => teeIterator(left), this.controller, this.#client),
|
|
206
|
+
new Stream(() => teeIterator(right), this.controller, this.#client),
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
211
|
+
* JSON stringified values in the stream
|
|
212
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
213
|
+
*/
|
|
214
|
+
toReadableStream() {
|
|
215
|
+
const self = this;
|
|
216
|
+
let iter;
|
|
217
|
+
return makeReadableStream({
|
|
218
|
+
async start() {
|
|
219
|
+
iter = self[Symbol.asyncIterator]();
|
|
220
|
+
},
|
|
221
|
+
async pull(ctrl) {
|
|
222
|
+
try {
|
|
223
|
+
const { value, done } = await iter.next();
|
|
224
|
+
if (done)
|
|
225
|
+
return ctrl.close();
|
|
226
|
+
const bytes = encodeUTF8(JSON.stringify(value) + '\n');
|
|
227
|
+
ctrl.enqueue(bytes);
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
ctrl.error(err);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
async cancel() {
|
|
234
|
+
await iter.return?.();
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export async function* _iterSSEMessages(response, controller) {
|
|
240
|
+
if (!response.body) {
|
|
241
|
+
controller.abort();
|
|
242
|
+
if (typeof globalThis.navigator !== 'undefined' &&
|
|
243
|
+
globalThis.navigator.product === 'ReactNative') {
|
|
244
|
+
throw new PukuError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
245
|
+
}
|
|
246
|
+
throw new PukuError(`Attempted to iterate over a response with no body`);
|
|
247
|
+
}
|
|
248
|
+
const sseDecoder = new SSEDecoder();
|
|
249
|
+
const lineDecoder = new LineDecoder();
|
|
250
|
+
const iter = ReadableStreamToAsyncIterable(response.body);
|
|
251
|
+
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
252
|
+
for (const line of lineDecoder.decode(sseChunk)) {
|
|
253
|
+
const sse = sseDecoder.decode(line);
|
|
254
|
+
if (sse)
|
|
255
|
+
yield sse;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
for (const line of lineDecoder.flush()) {
|
|
259
|
+
const sse = sseDecoder.decode(line);
|
|
260
|
+
if (sse)
|
|
261
|
+
yield sse;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Given an async iterable iterator, iterates over it and yields full
|
|
266
|
+
* SSE chunks, i.e. yields when a double new-line is encountered.
|
|
267
|
+
*/
|
|
268
|
+
async function* iterSSEChunks(iterator) {
|
|
269
|
+
let data = new Uint8Array();
|
|
270
|
+
for await (const chunk of iterator) {
|
|
271
|
+
if (chunk == null) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
275
|
+
: typeof chunk === 'string' ? encodeUTF8(chunk)
|
|
276
|
+
: chunk;
|
|
277
|
+
let newData = new Uint8Array(data.length + binaryChunk.length);
|
|
278
|
+
newData.set(data);
|
|
279
|
+
newData.set(binaryChunk, data.length);
|
|
280
|
+
data = newData;
|
|
281
|
+
let patternIndex;
|
|
282
|
+
while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
|
|
283
|
+
yield data.slice(0, patternIndex);
|
|
284
|
+
data = data.slice(patternIndex);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (data.length > 0) {
|
|
288
|
+
yield data;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
class SSEDecoder {
|
|
292
|
+
data;
|
|
293
|
+
event;
|
|
294
|
+
chunks;
|
|
295
|
+
constructor() {
|
|
296
|
+
this.event = null;
|
|
297
|
+
this.data = [];
|
|
298
|
+
this.chunks = [];
|
|
299
|
+
}
|
|
300
|
+
decode(line) {
|
|
301
|
+
if (line.endsWith('\r')) {
|
|
302
|
+
line = line.substring(0, line.length - 1);
|
|
303
|
+
}
|
|
304
|
+
if (!line) {
|
|
305
|
+
// empty line and we didn't previously encounter any messages
|
|
306
|
+
if (!this.event && !this.data.length)
|
|
307
|
+
return null;
|
|
308
|
+
const sse = {
|
|
309
|
+
event: this.event,
|
|
310
|
+
data: this.data.join('\n'),
|
|
311
|
+
raw: this.chunks,
|
|
312
|
+
};
|
|
313
|
+
this.event = null;
|
|
314
|
+
this.data = [];
|
|
315
|
+
this.chunks = [];
|
|
316
|
+
return sse;
|
|
317
|
+
}
|
|
318
|
+
this.chunks.push(line);
|
|
319
|
+
if (line.startsWith(':')) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
323
|
+
if (value.startsWith(' ')) {
|
|
324
|
+
value = value.substring(1);
|
|
325
|
+
}
|
|
326
|
+
if (fieldname === 'event') {
|
|
327
|
+
this.event = value;
|
|
328
|
+
}
|
|
329
|
+
else if (fieldname === 'data') {
|
|
330
|
+
this.data.push(value);
|
|
331
|
+
}
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function partition(str, delimiter) {
|
|
336
|
+
const index = str.indexOf(delimiter);
|
|
337
|
+
if (index !== -1) {
|
|
338
|
+
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
339
|
+
}
|
|
340
|
+
return [str, '', ''];
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../../../src/vendor/core/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;A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AAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;aAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,SAAiB;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploads.js","sourceRoot":"","sources":["../../../src/vendor/core/uploads.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/vendor/error.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-hosted environment runner helpers.
|
|
3
|
+
*
|
|
4
|
+
* - {@link WorkPoller} (`client.beta.environments.work.poller`) — control-plane
|
|
5
|
+
* only: claims work items and yields each one.
|
|
6
|
+
* - {@link SessionToolRunner} (`client.beta.sessions.events.toolRunner`) — the
|
|
7
|
+
* sessions-side counterpart to `client.beta.messages.toolRunner`: dispatches
|
|
8
|
+
* local tools against a session's `agent.tool_use` events.
|
|
9
|
+
* - {@link EnvironmentWorker} (`client.beta.environments.work.worker`) — the full
|
|
10
|
+
* composition: poll → set up the workdir + skills → run a
|
|
11
|
+
* {@link SessionToolRunner} while heartbeating the work-item lease →
|
|
12
|
+
* force-stop on exit (unless the lease was lost to another holder) → loop.
|
|
13
|
+
* Use `handleItem()` for the per-item flow when you already hold a claimed
|
|
14
|
+
* work item — with no arguments it reads the `PUKU_*` env vars that
|
|
15
|
+
* `ant worker poll --on-work` sets. The class is also exported here if you
|
|
16
|
+
* prefer `new EnvironmentWorker({ client, ... })`.
|
|
17
|
+
*
|
|
18
|
+
* The tool implementations themselves (`betaAgentToolset` and the
|
|
19
|
+
* per-tool factories) live in their own Node-only module — import them directly
|
|
20
|
+
* from `@puku-ai/sdk/tools/agent-toolset/node`.
|
|
21
|
+
*/
|
|
22
|
+
export { WorkPoller, EnvironmentWorker, SessionToolRunner, MANAGED_AGENTS_BETA, DEFAULT_MAX_IDLE_MS, type DispatchedToolCall, type WorkPollerOptions, type EnvironmentWorkerOptions, type EnvironmentWorkerTools, type HandleItemOptions, type SessionToolRunnerOptions, } from '../../lib/environments/index';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-hosted environment runner helpers.
|
|
3
|
+
*
|
|
4
|
+
* - {@link WorkPoller} (`client.beta.environments.work.poller`) — control-plane
|
|
5
|
+
* only: claims work items and yields each one.
|
|
6
|
+
* - {@link SessionToolRunner} (`client.beta.sessions.events.toolRunner`) — the
|
|
7
|
+
* sessions-side counterpart to `client.beta.messages.toolRunner`: dispatches
|
|
8
|
+
* local tools against a session's `agent.tool_use` events.
|
|
9
|
+
* - {@link EnvironmentWorker} (`client.beta.environments.work.worker`) — the full
|
|
10
|
+
* composition: poll → set up the workdir + skills → run a
|
|
11
|
+
* {@link SessionToolRunner} while heartbeating the work-item lease →
|
|
12
|
+
* force-stop on exit (unless the lease was lost to another holder) → loop.
|
|
13
|
+
* Use `handleItem()` for the per-item flow when you already hold a claimed
|
|
14
|
+
* work item — with no arguments it reads the `PUKU_*` env vars that
|
|
15
|
+
* `ant worker poll --on-work` sets. The class is also exported here if you
|
|
16
|
+
* prefer `new EnvironmentWorker({ client, ... })`.
|
|
17
|
+
*
|
|
18
|
+
* The tool implementations themselves (`betaAgentToolset` and the
|
|
19
|
+
* per-tool factories) live in their own Node-only module — import them directly
|
|
20
|
+
* from `@puku-ai/sdk/tools/agent-toolset/node`.
|
|
21
|
+
*/
|
|
22
|
+
export { WorkPoller, EnvironmentWorker, SessionToolRunner, MANAGED_AGENTS_BETA, DEFAULT_MAX_IDLE_MS, } from '../../lib/environments/index.js';
|
|
23
|
+
//# sourceMappingURL=environments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../../src/vendor/helpers/beta/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,GAOpB,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
2
|
+
import { Promisable, BetaRunnableTool, BetaToolRunContext } from '../../lib/tools/BetaRunnableTool';
|
|
3
|
+
import { BetaToolResultContentBlockParam } from '../../resources/beta';
|
|
4
|
+
import { AutoParseableBetaOutputFormat } from '../../lib/beta-parser';
|
|
5
|
+
type NoInfer<T> = T extends infer R ? R : never;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Tool with a provided JSON schema that can be passed
|
|
8
|
+
* to the `.toolRunner()` method. The schema is used to automatically validate
|
|
9
|
+
* the input arguments for the tool.
|
|
10
|
+
*/
|
|
11
|
+
export declare function betaTool<const Schema extends Exclude<JSONSchema, boolean> & {
|
|
12
|
+
type: 'object';
|
|
13
|
+
}>(options: {
|
|
14
|
+
name: string;
|
|
15
|
+
inputSchema: Schema;
|
|
16
|
+
description: string;
|
|
17
|
+
run: (args: NoInfer<FromSchema<Schema>>, context?: BetaToolRunContext) => Promisable<string | Array<BetaToolResultContentBlockParam>>;
|
|
18
|
+
/**
|
|
19
|
+
* Optional cleanup hook for tools that hold process-level resources (e.g. a
|
|
20
|
+
* persistent shell). `client.beta.sessions.events.toolRunner` calls it once
|
|
21
|
+
* when iteration ends.
|
|
22
|
+
*/
|
|
23
|
+
close?: () => void | Promise<void>;
|
|
24
|
+
}): BetaRunnableTool<NoInfer<FromSchema<Schema>>>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a JSON schema output format object from the given JSON schema.
|
|
27
|
+
* If this is passed to the `.parse()` method then the response message will contain a
|
|
28
|
+
* `.parsed_output` property that is the result of parsing the content with the given JSON schema.
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export declare function betaJSONSchemaOutputFormat<const Schema extends Exclude<JSONSchema, boolean> & {
|
|
32
|
+
type: 'object';
|
|
33
|
+
}>(jsonSchema: Schema, options?: {
|
|
34
|
+
transform?: boolean;
|
|
35
|
+
}): AutoParseableBetaOutputFormat<NoInfer<FromSchema<Schema>>>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PukuError } from '../../index.js';
|
|
2
|
+
import { transformJSONSchema } from '../../lib/transform-json-schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Tool with a provided JSON schema that can be passed
|
|
5
|
+
* to the `.toolRunner()` method. The schema is used to automatically validate
|
|
6
|
+
* the input arguments for the tool.
|
|
7
|
+
*/
|
|
8
|
+
export function betaTool(options) {
|
|
9
|
+
if (options.inputSchema.type !== 'object') {
|
|
10
|
+
throw new Error(`JSON schema for tool "${options.name}" must be an object, but got ${options.inputSchema.type}`);
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
type: 'custom',
|
|
14
|
+
name: options.name,
|
|
15
|
+
input_schema: options.inputSchema,
|
|
16
|
+
description: options.description,
|
|
17
|
+
run: options.run,
|
|
18
|
+
parse: (content) => content,
|
|
19
|
+
...(options.close ? { close: options.close } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a JSON schema output format object from the given JSON schema.
|
|
24
|
+
* If this is passed to the `.parse()` method then the response message will contain a
|
|
25
|
+
* `.parsed_output` property that is the result of parsing the content with the given JSON schema.
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export function betaJSONSchemaOutputFormat(jsonSchema, options) {
|
|
29
|
+
if (jsonSchema.type !== 'object') {
|
|
30
|
+
throw new Error(`JSON schema for tool must be an object, but got ${jsonSchema.type}`);
|
|
31
|
+
}
|
|
32
|
+
const transform = options?.transform ?? true;
|
|
33
|
+
if (transform) {
|
|
34
|
+
// todo: doing this is arguably necessary, but it does change the schema the user passed in
|
|
35
|
+
// so I'm not sure how we should handle that
|
|
36
|
+
jsonSchema = transformJSONSchema(jsonSchema);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
type: 'json_schema',
|
|
40
|
+
schema: {
|
|
41
|
+
...jsonSchema,
|
|
42
|
+
},
|
|
43
|
+
parse: (content) => {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(content);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new PukuError(`Failed to parse structured output: ${error}`);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAItE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,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