@puku-ai/sdk 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +151 -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 +123 -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 +4 -26
- package/sdk.cjs.map +12 -12
- package/sdk.d.ts +6 -6
- package/sdk.mjs +4 -4
- package/sdk.mjs.map +12 -12
package/sdk.d.ts
CHANGED
|
@@ -1569,7 +1569,7 @@ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
|
|
|
1569
1569
|
* const betaMessage = await client.beta.messages.create({
|
|
1570
1570
|
* max_tokens: 1024,
|
|
1571
1571
|
* messages: [{ content: 'Hello, world', role: 'user' }],
|
|
1572
|
-
* model: 'puku-
|
|
1572
|
+
* model: 'puku-ai-2.8',
|
|
1573
1573
|
* });
|
|
1574
1574
|
* ```
|
|
1575
1575
|
*/
|
|
@@ -1583,7 +1583,7 @@ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
|
|
|
1583
1583
|
* @example
|
|
1584
1584
|
* ```ts
|
|
1585
1585
|
* const message = await client.beta.messages.parse({
|
|
1586
|
-
* model: 'puku-
|
|
1586
|
+
* model: 'puku-ai-2.8',
|
|
1587
1587
|
* max_tokens: 1024,
|
|
1588
1588
|
* messages: [{ role: 'user', content: 'What is 2+2?' }],
|
|
1589
1589
|
* output_format: zodOutputFormat(z.object({ answer: z.number() }), 'math'),
|
|
@@ -6809,7 +6809,7 @@ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
|
|
|
6809
6809
|
*/
|
|
6810
6810
|
system?: string | Array<BetaTextBlockParam>;
|
|
6811
6811
|
/**
|
|
6812
|
-
* @deprecated Deprecated. Models released after Puku
|
|
6812
|
+
* @deprecated Deprecated. Models released after Puku AI 2.8 do not support
|
|
6813
6813
|
* setting temperature. A value of 1.0 of will be accepted for backwards
|
|
6814
6814
|
* compatibility, all other values will be rejected with a 400 error.
|
|
6815
6815
|
*/
|
|
@@ -6912,12 +6912,12 @@ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
|
|
|
6912
6912
|
*/
|
|
6913
6913
|
tools?: Array<BetaToolUnion>;
|
|
6914
6914
|
/**
|
|
6915
|
-
* @deprecated Deprecated. Models released after Puku
|
|
6915
|
+
* @deprecated Deprecated. Models released after Puku AI 2.8 do not accept
|
|
6916
6916
|
* top_k; any value will be rejected with a 400 error.
|
|
6917
6917
|
*/
|
|
6918
6918
|
top_k?: number;
|
|
6919
6919
|
/**
|
|
6920
|
-
* @deprecated Deprecated. Models released after Puku
|
|
6920
|
+
* @deprecated Deprecated. Models released after Puku AI 2.8 do not support
|
|
6921
6921
|
* setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all
|
|
6922
6922
|
* other values will be rejected with a 400 error.
|
|
6923
6923
|
*/
|
|
@@ -10833,7 +10833,7 @@ type AutoParseableOutputConfig = Omit<OutputConfig, 'format'> & {
|
|
|
10833
10833
|
declare function betaGlobTool(ctx: AgentToolContext): BetaRunnableTool;
|
|
10834
10834
|
|
|
10835
10835
|
declare function betaGrepTool(ctx: AgentToolContext): BetaRunnableTool;
|
|
10836
|
-
declare const VERSION = "0.
|
|
10836
|
+
declare const VERSION = "4.0.2";
|
|
10837
10837
|
|
|
10838
10838
|
export { default, PukuAI, BasePuku, PukuAIType, BasePukuType, VERSION, Uploadable, toFile };
|
|
10839
10839
|
|
package/sdk.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var C9=Object.create;var{getPrototypeOf:U9,defineProperty:a1,getOwnPropertyNames:N9}=Object;var F9=Object.prototype.hasOwnProperty;function q9(J){return this[J]}var M9,T9,w9=(J,$,Z)=>{var X=J!=null&&typeof J==="object";if(X){var G=$?M9??=new WeakMap:T9??=new WeakMap,Q=G.get(J);if(Q)return Q}Z=J!=null?C9(U9(J)):{};let Y=$||!J||!J.__esModule?a1(Z,"default",{value:J,enumerable:!0}):Z;for(let z of N9(J))if(!F9.call(Y,z))a1(Y,z,{get:q9.bind(J,z),enumerable:!0});if(X)G.set(J,Y);return Y};var r8=(J,$)=>()=>($||J(($={exports:{}}).exports,$),$.exports);var O9=(J)=>J;function R9(J,$){this[J]=O9.bind(null,$)}var R4=(J,$)=>{for(var Z in $)a1(J,Z,{get:$[Z],enumerable:!0,configurable:!0,set:R9.bind($,Z)})};var M=(J,$)=>()=>(J&&($=J(J=0)),$);var U2=function(){let{crypto:J}=globalThis;if(J?.randomUUID)return U2=J.randomUUID.bind(J),J.randomUUID();let $=new Uint8Array(1),Z=J?()=>J.getRandomValues($)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(X)=>(+X^Z()&15>>+X/4).toString(16))};function U0(J){return typeof J==="object"&&J!==null&&(("name"in J)&&J.name==="AbortError"||("message"in J)&&String(J.message).includes("FetchRequestCanceledException"))}var a0=(J)=>{if(J instanceof Error)return J;if(typeof J==="object"&&J!==null){try{let $=Object.prototype.toString.call(J);if($==="[object Error]"||$==="[object DOMException]"){let Z=Error(J.message,J.cause?{cause:J.cause}:{});if(J.stack)Z.stack=J.stack;if(J.cause&&!Z.cause)Z.cause=J.cause;if(J.name)Z.name=J.name;return Z}}catch{}try{return Error(JSON.stringify(J))}catch{}}return Error(J)};var T,l,Z0,S0,g2,t8,h2,m2,u2,d2,c2,p2,l2,i2;var c=M(()=>{T=class T extends Error{name="PukuError";constructor(J){super(J);this.name="PukuError"}};l=class l extends T{status;headers;error;requestID;workspaceID;type;constructor(J,$,Z,X,G){super(`${l.makeMessage(J,$,Z)}`);this.status=J,this.headers=X,this.requestID=X?.get("request-id"),this.workspaceID=X?.get("puku-workspace-id"),this.error=$,this.type=G??null}static makeMessage(J,$,Z){let X=$?.message?typeof $.message==="string"?$.message:JSON.stringify($.message):$?JSON.stringify($):Z;if(J&&X)return`${J} ${X}`;if(J)return`${J} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate(J,$,Z,X){if(!J||!X)return new S0({message:Z,cause:a0($)});let G=$,Q=G?.error?.type;if(J===400)return new h2(J,G,Z,X,Q);if(J===401)return new m2(J,G,Z,X,Q);if(J===403)return new u2(J,G,Z,X,Q);if(J===404)return new d2(J,G,Z,X,Q);if(J===409)return new c2(J,G,Z,X,Q);if(J===422)return new p2(J,G,Z,X,Q);if(J===429)return new l2(J,G,Z,X,Q);if(J>=500)return new i2(J,G,Z,X,Q);return new l(J,G,Z,X,Q)}};Z0=class Z0 extends l{constructor({message:J}={}){super(void 0,void 0,J||"Request was aborted.",void 0)}};S0=class S0 extends l{constructor({message:J,cause:$}){super(void 0,void 0,J||"Connection error.",void 0);if($)this.cause=$}};g2=class g2 extends S0{constructor({message:J}={}){super({message:J??"Request timed out."})}};t8=class t8 extends T{constructor(J,{cause:$}={}){super(J??"Retryable error.");if($!==void 0)this.cause=$}};h2=class h2 extends l{};m2=class m2 extends l{};u2=class u2 extends l{};d2=class d2 extends l{};c2=class c2 extends l{};p2=class p2 extends l{};l2=class l2 extends l{};i2=class i2 extends l{}});function n2(J){if(typeof J!=="object")return{};return J??{}}function r1(J){if(!J)return!0;for(let $ in J)return!1;return!0}function H4(J,$){return Object.prototype.hasOwnProperty.call(J,$)}function t1(J){return J!=null&&typeof J==="object"&&!Array.isArray(J)}function x0(J){}var H9,A4=(J)=>{return H9.test(J)},X0=(J)=>(X0=Array.isArray,X0(J)),o1,L4=(J,$)=>{if(typeof $!=="number"||!Number.isInteger($))throw new T(`${J} must be an integer`);if($<0)throw new T(`${J} must be a positive integer`);return $},o0=(J)=>{try{return JSON.parse(J)}catch($){return}},G0=(J,$)=>{let Z=J[$];return delete J[$],Z};var Q0=M(()=>{c();H9=/^[a-z][a-z0-9+.-]*:/i,o1=X0});var T0=(J,$)=>new Promise((Z)=>{if($?.aborted)return Z();let X=()=>{clearTimeout(G),Z()},G=setTimeout(()=>{$?.removeEventListener("abort",X),Z()},J);$?.addEventListener("abort",X,{once:!0})});var B0="0.123.0";function L9(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function j9(){if(typeof navigator>"u"||!navigator)return null;let J=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:$,pattern:Z}of J){let X=Z.exec(navigator.userAgent);if(X){let G=X[1]||0,Q=X[2]||0,Y=X[3]||0;return{browser:$,version:`${G}.${Q}.${Y}`}}}return null}var P4=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},D9=()=>{let J=L9();if(J==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":j4(Deno.build.os),"X-Stainless-Arch":D4(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process?.version??"unknown"};if(J==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":j4(globalThis.process.platform??"unknown"),"X-Stainless-Arch":D4(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let $=j9();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},D4=(J)=>{if(J==="x32")return"x32";if(J==="x86_64"||J==="x64")return"x64";if(J==="arm")return"arm";if(J==="aarch64"||J==="arm64")return"arm64";if(J)return`other:${J}`;return"unknown"},j4=(J)=>{if(J=J.toLowerCase(),J.includes("ios"))return"iOS";if(J==="android")return"Android";if(J==="darwin")return"MacOS";if(J==="win32")return"Windows";if(J==="freebsd")return"FreeBSD";if(J==="openbsd")return"OpenBSD";if(J==="linux")return"Linux";if(J)return`Other:${J}`;return"Unknown"},P9,a2=()=>{return P9??=D9()};var s8=()=>{};function S9(J,$){return()=>J.removeEventListener("abort",$)}function _4(J,$,Z){e8.set(J,S9($,Z))}function E4(J,$){if(e8.has($))S4?.register(J,$,$)}function H0(J){let $=e8.get(J);if($)e8.delete(J),S4?.unregister(J),$()}var e8,S4;var J1=M(()=>{e8=new WeakMap,S4=typeof globalThis.FinalizationRegistry==="function"?new globalThis.FinalizationRegistry((J)=>H0(J)):null});function I4(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new PukuAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function s1(...J){let $=globalThis.ReadableStream;if(typeof $>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new $(...J)}function $1(J){let $=Symbol.asyncIterator in J?J[Symbol.asyncIterator]():J[Symbol.iterator]();return s1({start(){},async pull(Z){let{done:X,value:G}=await $.next();if(X)Z.close();else Z.enqueue(G)},async cancel(){await $.return?.()}})}function o2(J){if(J[Symbol.asyncIterator])return J;let $=J.getReader();return{async next(){try{let Z=await $.read();if(Z?.done)$.releaseLock();return Z}catch(Z){throw $.releaseLock(),Z}},async return(){let Z=$.cancel();return $.releaseLock(),await Z,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function y4(J){if(J===null||typeof J!=="object")return;if(J[Symbol.asyncIterator]){await J[Symbol.asyncIterator]().return?.();return}let $=J.getReader(),Z=$.cancel();$.releaseLock(),await Z}class e1{index}var x4=({headers:J,body:$})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify($)}};var J6="RFC3986",$6=(J)=>String(J),Z6,k4="RFC1738";var X6=M(()=>{Z6={RFC1738:(J)=>String(J).replace(/%20/g,"+"),RFC3986:$6}});function v4(J){if(!J||typeof J!=="object")return!1;return!!(J.constructor&&J.constructor.isBuffer&&J.constructor.isBuffer(J))}function Q6(J,$){if(X0(J)){let Z=[];for(let X=0;X<J.length;X+=1)Z.push($(J[X]));return Z}return $(J)}var Z1=(J,$)=>(Z1=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Z1(J,$)),L0,G6=1024,f4=(J,$,Z,X,G)=>{if(J.length===0)return J;let Q=J;if(typeof J==="symbol")Q=Symbol.prototype.toString.call(J);else if(typeof J!=="string")Q=String(J);if(Z==="iso-8859-1")return escape(Q).replace(/%u[0-9a-f]{4}/gi,function(z){return"%26%23"+parseInt(z.slice(2),16)+"%3B"});let Y="";for(let z=0;z<Q.length;z+=G6){let B=Q.length>=G6?Q.slice(z,z+G6):Q,K=[];for(let W=0;W<B.length;++W){let C=B.charCodeAt(W);if(C===45||C===46||C===95||C===126||C>=48&&C<=57||C>=65&&C<=90||C>=97&&C<=122||G===k4&&(C===40||C===41)){K[K.length]=B.charAt(W);continue}if(C<128){K[K.length]=L0[C];continue}if(C<2048){K[K.length]=L0[192|C>>6]+L0[128|C&63];continue}if(C<55296||C>=57344){K[K.length]=L0[224|C>>12]+L0[128|C>>6&63]+L0[128|C&63];continue}W+=1,C=65536+((C&1023)<<10|B.charCodeAt(W)&1023),K[K.length]=L0[240|C>>18]+L0[128|C>>12&63]+L0[128|C>>6&63]+L0[128|C&63]}Y+=K.join("")}return Y};var b4=M(()=>{X6();Q0();L0=(()=>{let J=[];for(let $=0;$<256;++$)J.push("%"+(($<16?"0":"")+$.toString(16)).toUpperCase());return J})()});function y9(J){return typeof J==="string"||typeof J==="number"||typeof J==="boolean"||typeof J==="symbol"||typeof J==="bigint"}function m4(J,$,Z,X,G,Q,Y,z,B,K,W,C,V,F,q,A,R,H){let O=J,D=H,S=0,y=!1;while((D=D.get(Y6))!==void 0&&!y){let b=D.get(J);if(S+=1,typeof b<"u")if(b===S)throw RangeError("Cyclic object value");else y=!0;if(typeof D.get(Y6)>"u")S=0}if(typeof K==="function")O=K($,O);else if(O instanceof Date)O=V?.(O);else if(Z==="comma"&&X0(O))O=Q6(O,function(b){if(b instanceof Date)return V?.(b);return b});if(O===null){if(Q)return B&&!A?B($,a.encoder,R,"key",F):$;O=""}if(y9(O)||v4(O)){if(B){let b=A?$:B($,a.encoder,R,"key",F);return[q?.(b)+"="+q?.(B(O,a.encoder,R,"value",F))]}return[q?.($)+"="+q?.(String(O))]}let f=[];if(typeof O>"u")return f;let v;if(Z==="comma"&&X0(O)){if(A&&B)O=Q6(O,B);v=[{value:O.length>0?O.join(",")||null:void 0}]}else if(X0(K))v=K;else{let b=Object.keys(O);v=W?b.sort(W):b}let g=z?String($).replace(/\./g,"%2E"):String($),d=X&&X0(O)&&O.length===1?g+"[]":g;if(G&&X0(O)&&O.length===0)return d+"[]";for(let b=0;b<v.length;++b){let t=v[b],A0=typeof t==="object"&&typeof t.value<"u"?t.value:O[t];if(Y&&A0===null)continue;let n0=C&&z?t.replace(/\./g,"%2E"):t,C2=X0(O)?typeof Z==="function"?Z(d,n0):d:d+(C?"."+n0:"["+n0+"]");H.set(J,S);let O4=new WeakMap;O4.set(Y6,H),h4(f,m4(A0,C2,Z,X,G,Q,Y,z,Z==="comma"&&A&&X0(O)?null:B,K,W,C,V,F,q,A,R,O4))}return f}function x9(J=a){if(typeof J.allowEmptyArrays<"u"&&typeof J.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof J.encodeDotInKeys<"u"&&typeof J.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(J.encoder!==null&&typeof J.encoder<"u"&&typeof J.encoder!=="function")throw TypeError("Encoder has to be a function.");let $=J.charset||a.charset;if(typeof J.charset<"u"&&J.charset!=="utf-8"&&J.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Z=J6;if(typeof J.format<"u"){if(!Z1(Z6,J.format))throw TypeError("Unknown format option provided.");Z=J.format}let X=Z6[Z],G=a.filter;if(typeof J.filter==="function"||X0(J.filter))G=J.filter;let Q;if(J.arrayFormat&&J.arrayFormat in g4)Q=J.arrayFormat;else if("indices"in J)Q=J.indices?"indices":"repeat";else Q=a.arrayFormat;if("commaRoundTrip"in J&&typeof J.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let Y=typeof J.allowDots>"u"?!!J.encodeDotInKeys===!0?!0:a.allowDots:!!J.allowDots;return{addQueryPrefix:typeof J.addQueryPrefix==="boolean"?J.addQueryPrefix:a.addQueryPrefix,allowDots:Y,allowEmptyArrays:typeof J.allowEmptyArrays==="boolean"?!!J.allowEmptyArrays:a.allowEmptyArrays,arrayFormat:Q,charset:$,charsetSentinel:typeof J.charsetSentinel==="boolean"?J.charsetSentinel:a.charsetSentinel,commaRoundTrip:!!J.commaRoundTrip,delimiter:typeof J.delimiter>"u"?a.delimiter:J.delimiter,encode:typeof J.encode==="boolean"?J.encode:a.encode,encodeDotInKeys:typeof J.encodeDotInKeys==="boolean"?J.encodeDotInKeys:a.encodeDotInKeys,encoder:typeof J.encoder==="function"?J.encoder:a.encoder,encodeValuesOnly:typeof J.encodeValuesOnly==="boolean"?J.encodeValuesOnly:a.encodeValuesOnly,filter:G,format:Z,formatter:X,serializeDate:typeof J.serializeDate==="function"?J.serializeDate:a.serializeDate,skipNulls:typeof J.skipNulls==="boolean"?J.skipNulls:a.skipNulls,sort:typeof J.sort==="function"?J.sort:null,strictNullHandling:typeof J.strictNullHandling==="boolean"?J.strictNullHandling:a.strictNullHandling}}function u4(J,$={}){let Z=J,X=x9($),G,Q;if(typeof X.filter==="function")Q=X.filter,Z=Q("",Z);else if(X0(X.filter))Q=X.filter,G=Q;let Y=[];if(typeof Z!=="object"||Z===null)return"";let z=g4[X.arrayFormat],B=z==="comma"&&X.commaRoundTrip;if(!G)G=Object.keys(Z);if(X.sort)G.sort(X.sort);let K=new WeakMap;for(let V=0;V<G.length;++V){let F=G[V];if(X.skipNulls&&Z[F]===null)continue;h4(Y,m4(Z[F],F,z,B,X.allowEmptyArrays,X.strictNullHandling,X.skipNulls,X.encodeDotInKeys,X.encode?X.encoder:null,X.filter,X.sort,X.allowDots,X.serializeDate,X.format,X.formatter,X.encodeValuesOnly,X.charset,K))}let W=Y.join(X.delimiter),C=X.addQueryPrefix===!0?"?":"";if(X.charsetSentinel)if(X.charset==="iso-8859-1")C+="utf8=%26%2310003%3B&";else C+="utf8=%E2%9C%93&";return W.length>0?C+W:""}var g4,h4=function(J,$){Array.prototype.push.apply(J,X0($)?$:[$])},I9,a,Y6;var d4=M(()=>{b4();X6();Q0();g4={brackets(J){return String(J)+"[]"},comma:"comma",indices(J,$){return String(J)+"["+$+"]"},repeat(J){return String(J)}},a={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:f4,encodeValuesOnly:!1,format:J6,formatter:$6,indices:!1,serializeDate(J){return(I9??=Function.prototype.call.bind(Date.prototype.toISOString))(J)},skipNulls:!1,strictNullHandling:!1};Y6={}});function c4(J){return u4(J,{arrayFormat:"brackets"})}var z6=M(()=>{d4()});var D0={};R4(D0,{util:()=>K6,stream:()=>X1,path:()=>j,os:()=>f9,fs:()=>_0,crypto:()=>k0,child_process:()=>B6});import*as B6 from"node:child_process";import*as k0 from"node:crypto";import*as _0 from"node:fs";import*as f9 from"node:os";import*as j from"node:path";import*as X1 from"node:stream";import*as K6 from"node:util";var K0=()=>{};function Q1(J){if(!J)return;let $;try{$=new URL(J)}catch(X){throw new m(`Invalid token endpoint base URL "${J}": ${X}`)}if($.protocol==="https:")return;let Z=$.hostname.toLowerCase().replace(/^\[|\]$/g,"");if($.protocol==="http:"&&(Z==="localhost"||Z==="127.0.0.1"||Z==="::1"))return;throw new m(`Refusing to send credential over non-https token endpoint "${J}"`)}async function Y1(J,$){let Z=await b9(J),X;try{X=JSON.parse(Z)}catch{throw new m(`Token endpoint returned non-JSON response (status ${J.status})`,J.status,W0(Z),$)}if(!X.access_token)throw new m(`Token endpoint response missing access_token: ${JSON.stringify(W0(X))}`,J.status,W0(X),$);if(X.token_type&&X.token_type.toLowerCase()!=="bearer")throw new m(`Token endpoint response: unsupported token_type "${X.token_type}" (want Bearer)`,J.status,W0(X),$);return X}function W0(J){if(J==null)return J;if(typeof J==="string"){let $;try{$=JSON.parse(J)}catch{if(J.length<=W6)return J;return J.slice(0,W6)+`... <${J.length-W6} more chars>`}return JSON.stringify(W0($))}if(typeof J==="object"&&!Array.isArray(J)){let $={};for(let[Z,X]of Object.entries(J))if(v9.has(Z))$[Z]=X;return $}return null}async function z1(J,$=(Z)=>console.warn(`puku-ai/sdk: ${Z}`)){if(typeof process>"u"||process.platform==="win32")return;let{fs:Z}=await Promise.resolve().then(() => (K0(),D0)),X=J,G;try{X=await Z.promises.realpath(J),G=await Z.promises.stat(X)}catch{return}let Q=G.mode&511;if(Q&18)throw new m(`Credentials file at ${X} is group/world-writable (mode 0o${Q.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${X}\`.`);if(Q&36)throw new m(`Credentials file at ${X} is group/world-readable (mode 0o${Q.toString(8)}); run \`chmod 600 ${X}\` before retrying.`);if(typeof process.getuid==="function"&&G.uid!==process.getuid())$(`credentials file at ${X} is owned by uid ${G.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function B1(J,$){let{fs:Z,path:X}=await Promise.resolve().then(() => (K0(),D0)),G=X.dirname(J);await Z.promises.mkdir(G,{recursive:!0,mode:448});let Q=`${J}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let Y=await Z.promises.open(Q,"w",384);try{await Y.writeFile(JSON.stringify($,null,2)),await Y.sync()}finally{await Y.close()}await Z.promises.rename(Q,J)}catch(Y){throw await Z.promises.unlink(Q).catch(()=>{}),Y}try{let Y=await Z.promises.open(G,"r");try{await Y.sync()}finally{await Y.close()}}catch{}}async function b9(J){if(!J.body)return"";let $=J.body.getReader(),Z=[],X=0;for(;;){let{done:Q,value:Y}=await $.read();if(Q)break;if(X+Y.length>p4){let z=p4-X;if(z>0)Z.push(Y.subarray(0,z));await $.cancel();break}Z.push(Y),X+=Y.length}let G;if(Z.length===1)G=Z[0];else{G=new Uint8Array(Z.reduce((Y,z)=>Y+z.length,0));let Q=0;for(let Y of Z)G.set(Y,Q),Q+=Y.length}return new TextDecoder("utf-8").decode(G)}var l4="urn:ietf:params:oauth:grant-type:jwt-bearer",i4="refresh_token",G1="/v1/oauth/token",f0="oauth-2025-04-20",V6="oidc-federation-2026-04-01",n4=120,N2=30,a4=5,p4=1048576,W6=2000,v9,m;var r0=M(()=>{c();v9=new Set(["error","error_description","error_uri"]);m=class m extends T{statusCode;body;requestId;constructor(J,$=null,Z=null,X=null){super(J);this.statusCode=$,this.body=Z,this.requestId=X}}});function w0(){return Math.floor(Date.now()/1000)}class C6{provider;cached=null;pendingRefresh=null;nextForce=!1;lastAdvisoryError=0;onAdvisoryRefreshError;constructor(J,$){this.provider=J,this.onAdvisoryRefreshError=$}async getToken(){let J=this.nextForce;this.nextForce=!1;let $=this.cached;if(J||$==null)return(await this.refresh(J)).token;if($.expiresAt==null)return $.token;let Z=$.expiresAt-w0();if(Z>n4)return $.token;if(Z>N2)return this.backgroundRefresh(),$.token;return(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(J=!1){if(this.pendingRefresh&&!J)return this.pendingRefresh;return this.doRefresh(J)}backgroundRefresh(){if(this.pendingRefresh)return;if(w0()-this.lastAdvisoryError<a4)return;this.doRefresh().catch((J)=>{this.lastAdvisoryError=w0(),this.onAdvisoryRefreshError?.(J)})}doRefresh(J=!1){return this.pendingRefresh=this.provider(J?{forceRefresh:!0}:void 0).then(($)=>{return this.cached=$,this.pendingRefresh=null,$},($)=>{throw this.pendingRefresh=null,$}),this.pendingRefresh}}var o4=M(()=>{r0()});var x=(J)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[J]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(J)?.trim()||void 0;return};function s4(J){let $=0;for(let G of J)$+=G.length;let Z=new Uint8Array($),X=0;for(let G of J)Z.set(G,X),X+=G.length;return Z}function v0(J){let $;return(r4??($=new globalThis.TextEncoder,r4=$.encode.bind($)))(J)}function t0(J){let $;return(t4??($=new globalThis.TextDecoder,t4=$.decode.bind($)))(J)}var r4,t4;var r2=(J)=>{if(typeof globalThis.Buffer<"u"){let $=globalThis.Buffer.from(J,"base64");return new Uint8Array($.buffer,$.byteOffset,$.byteLength)}if(typeof atob<"u"){let $=atob(J),Z=new Uint8Array($.length);for(let X=0;X<$.length;X++)Z[X]=$.charCodeAt(X);return Z}throw new T("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var K1=M(()=>{c()});function t2(){}function W1(J,$,Z){if(!$||V1[J]>V1[Z])return t2;else return $[J].bind($)}function N6(J,$){let Z=e4.get(J);if(Z&&Z[0]===$)return Z[1];let X={error:W1("error",J,$),warn:W1("warn",J,$),info:W1("info",J,$),debug:W1("debug",J,$)};return e4.set(J,[$,X]),X}function k(J){let $=J.logger,Z=J.logLevel??"off";if(!$)return g9;return N6($,Z)}function $$(){let J=x("PUKU_LOG");if(!U6||J!==J$)J$=J,U6=N6(console,C1(J,"process.env['PUKU_LOG']",N6(console,s2))??s2);return U6}var s2="warn",V1,C1=(J,$,Z)=>{if(!J)return;if(H4(V1,J))return J;Z.warn(`${$} was set to ${JSON.stringify(J)}, expected one of ${JSON.stringify(Object.keys(V1))}`);return},g9,e4,J$,U6,j0=(J)=>{if(J.options)J.options={...J.options},delete J.options.headers;if(J.headers)J.headers=Object.fromEntries((J.headers instanceof Headers?[...J.headers]:Object.entries(J.headers)).map(([$,Z])=>[$,$.toLowerCase()==="authorization"||$.toLowerCase()==="api-key"||$.toLowerCase()==="x-api-key"||$.toLowerCase()==="cookie"||$.toLowerCase()==="set-cookie"?"***":Z]));if("retryOfRequestLogID"in J){if(J.retryOfRequestLogID)J.retryOf=J.retryOfRequestLogID;delete J.retryOfRequestLogID}return J};var O0=M(()=>{Q0();V1={off:0,error:200,warn:300,info:400,debug:500};g9={error:t2,warn:t2,info:t2,debug:t2},e4=new WeakMap});var F6=M(()=>{Q0();K1();O0();z6()});function Z$(J){if(!J)throw Error("profile name is empty");if(J==="."||J==="..")throw Error(`profile name "${J}" is not allowed`);if(J.includes("/")||J.includes("\\"))throw Error(`profile name "${J}" must not contain path separators`);if(!h9.test(J))throw Error(`profile name "${J}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var U1="1.0",h9,X$=async(J)=>{let $=await q6();if($===null)return null;let Z=J??await Q$();if(Z===null)return null;Z$(Z);let{fs:X,path:G}=await Promise.resolve().then(() => (K0(),D0)),Q=G.join($,"configs",`${Z}.json`),Y;try{Y=await X.promises.readFile(Q,"utf-8")}catch(K){if(K?.code!=="ENOENT")throw Error(`failed to read config file ${Q}: ${K}`);Y=null}if(Y===null){let K=x("PUKU_ORGANIZATION_ID"),W=x("PUKU_IDENTITY_TOKEN_FILE"),C=x("PUKU_FEDERATION_RULE_ID");if(C&&K)return{fromFile:!1,config:{organization_id:K,workspace_id:x("PUKU_WORKSPACE_ID"),base_url:x("PUKU_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:C,service_account_id:x("PUKU_SERVICE_ACCOUNT_ID"),identity_token:W?{source:"file",path:W}:void 0,scope:x("PUKU_SCOPE")}}};return null}let z;try{z=JSON.parse(Y)}catch(K){throw Error(`failed to parse config file ${Q}: ${K}`)}if(!z.authentication)throw Error(`config file ${Q} is missing "authentication"`);let B=z.authentication.type;if(B!=="oidc_federation"&&B!=="user_oauth")throw Error(`authentication.type "${B}" is not a known authentication type`);if(z.organization_id??=x("PUKU_ORGANIZATION_ID"),z.workspace_id??=x("PUKU_WORKSPACE_ID"),z.base_url??=x("PUKU_BASE_URL"),z.authentication.scope??=x("PUKU_SCOPE"),z.authentication.type==="oidc_federation"){if(!z.authentication.identity_token){let K=x("PUKU_IDENTITY_TOKEN_FILE");if(K)z.authentication.identity_token={source:"file",path:K}}if(!z.authentication.federation_rule_id)z.authentication.federation_rule_id=x("PUKU_FEDERATION_RULE_ID")??"";z.authentication.service_account_id??=x("PUKU_SERVICE_ACCOUNT_ID")}return{config:z,fromFile:!0}},G$=async(J,$)=>{if(J?.authentication.credentials_path)return J.authentication.credentials_path;let Z=await q6();if(!Z)return null;let X=$??await Q$();if(!X)return null;Z$(X);let{path:G}=await Promise.resolve().then(() => (K0(),D0));return G.join(Z,"credentials",`${X}.json`)},q6=async()=>{if(!m9())return null;let{path:J}=await Promise.resolve().then(() => (K0(),D0)),$=x("PUKU_CONFIG_DIR");if($)return $;if(a2()["X-Stainless-OS"]==="Windows"){let Q=x("APPDATA");if(Q)return J.join(Q,"PukuAI");let Y=x("USERPROFILE");if(Y)return J.join(Y,"AppData","Roaming","PukuAI");return null}let X=x("XDG_CONFIG_HOME");if(X)return J.join(X,"puku");let G=x("HOME");if(G)return J.join(G,".config","puku");return null},m9=()=>{let J=a2()["X-Stainless-Runtime"];return J==="node"||J==="deno"},Q$=async()=>{let J=await q6();if(!J)return null;let $=x("PUKU_PROFILE");if($)return $;let{fs:Z,path:X}=await Promise.resolve().then(() => (K0(),D0)),G=X.join(J,"active_config");try{return(await Z.promises.readFile(G,"utf-8")).trim()||"default"}catch(Q){if(Q?.code!=="ENOENT")throw Error(`failed to read ${G}: ${Q}`);return"default"}};var M6=M(()=>{s8();F6();h9=/^[A-Za-z0-9_.-]+$/});function T6(J){if(!J)throw new T("Identity token file path is empty");return async()=>{let{fs:$}=await Promise.resolve().then(() => (K0(),D0)),Z;try{Z=await $.promises.readFile(J,"utf-8")}catch(G){throw new T(`Failed to read identity token file at ${J}: ${G}`)}let X=Z.trim();if(!X)throw new T(`Identity token file at ${J} is empty`);return X}}function Y$(J){if(!J)throw new T("Identity token value is empty");return()=>J}var z$=M(()=>{c()});function B$(J){return async()=>{Q1(J.baseURL);let $=await J.identityTokenProvider();if($.length>16384)throw new m(`Identity token is ${Math.ceil($.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let Z={grant_type:l4,assertion:$,federation_rule_id:J.federationRuleId,organization_id:J.organizationId};if(J.serviceAccountId)Z.service_account_id=J.serviceAccountId;if(J.workspaceId)Z.workspace_id=J.workspaceId;let X=`${J.baseURL}${G1}`,G;try{G=await J.fetch(X,{method:"POST",headers:{"Content-Type":"application/json","puku-beta":`${f0},${V6}`,"User-Agent":J.userAgent||`puku-ai-sdk-typescript/${B0} oidcFederationProvider`},body:JSON.stringify(Z)})}catch(B){throw new m(`Failed to reach token endpoint ${X}: ${B}`)}let Q=G.headers.get("Request-Id");if(!G.ok){let B=await G.text().catch(()=>""),K=W0(B),W="";if(G.status===401)W=` Ensure your federation rule matches your identity token. ${J.workspaceId?"":"If your federation rule is scoped to multiple workspaces, set the PUKU_WORKSPACE_ID environment variable, the 'workspace_id' config key, or the `workspaceId` option. "}View your authentication events in the Workload identity page of Puku Console for more details.`;throw new m(`Token exchange failed with status ${G.status}${Q?` (request-id ${Q})`:""}: ${K}${W}`,G.status,K,Q)}let Y=await Y1(G,Q),z=Number(Y.expires_in);if(!Number.isFinite(z))throw new m(`Token endpoint response missing required fields: ${JSON.stringify(W0(Y))}`,G.status,W0(Y),Q);return{token:Y.access_token,expiresAt:w0()+z}}}var K$=M(()=>{r0()});function W$(J){return async($)=>{let{fs:Z}=await Promise.resolve().then(() => (K0(),D0));await z1(J.credentialsPath,J.onSafetyWarning);let X;try{X=await Z.promises.readFile(J.credentialsPath,"utf-8")}catch(R){throw new m(`Credentials file not found at ${J.credentialsPath}: ${R}`)}let G;try{G=JSON.parse(X)}catch(R){throw new m(`Credentials file at ${J.credentialsPath} is not valid JSON: ${R}`)}let Q=G.access_token;if(!Q)throw new m(`Credentials file at ${J.credentialsPath} must include 'access_token'`);let Y=G.expires_at;if(!$?.forceRefresh&&(Y==null||w0()<Y-N2))return{token:Q,expiresAt:Y??null};let z=G.refresh_token;if(!J.clientId||!z)throw new m(`Access token at ${J.credentialsPath} has expired and no refresh is available (client_id ${J.clientId?"set":"empty"}, refresh_token ${z?"set":"empty"})`);Q1(J.baseURL);let B={grant_type:i4,refresh_token:z,client_id:J.clientId},K=`${J.baseURL}${G1}`,W;try{W=await J.fetch(K,{method:"POST",headers:{"Content-Type":"application/json","puku-beta":f0,"User-Agent":J.userAgent||`puku-ai-sdk-typescript/${B0} userOAuthProvider`},body:JSON.stringify(B)})}catch(R){throw new m(`User OAuth refresh failed to reach token endpoint: ${R}`)}let C=W.headers.get("Request-Id");if(!W.ok){let R=await W.text().catch(()=>"");throw new m(`User OAuth refresh failed (HTTP ${W.status}): ${W0(R)}`,W.status,W0(R),C)}let V=await Y1(W,C),F=Number(V.expires_in);if(!Number.isFinite(F))throw new m(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(W0(V))}`,W.status,W0(V),C);let q=w0()+F,A=V.refresh_token||z;return await B1(J.credentialsPath,{...G,version:U1,type:"oauth_token",access_token:V.access_token,expires_at:q,refresh_token:A}),{token:V.access_token,expiresAt:q}}}var V$=M(()=>{M6();r0()});function w6(J,$){let Z=J.authentication.credentials_path??null,X=(J.base_url||$.baseURL).replace(/\/+$/,""),G=u9(J,Z,X,$),Q={};if(J.workspace_id&&J.authentication.type==="user_oauth")Q["puku-workspace-id"]=J.workspace_id;return{provider:G,extraHeaders:Q,baseURL:J.base_url||void 0}}async function C$(J,$){let Z=await X$($);if(!Z)return null;let{config:X,fromFile:G}=Z,Q=X.authentication.credentials_path||!G?X:{...X,authentication:{...X.authentication,credentials_path:await G$(X,$)??void 0}};return w6(Q,J)}function u9(J,$,Z,X){switch(J.authentication.type){case"oidc_federation":{let G=J.authentication,Q=d9(G);if(!Q)throw new m("oidc_federation config requires an identity token (set authentication.identity_token, PUKU_IDENTITY_TOKEN_FILE, or PUKU_IDENTITY_TOKEN)");if(!G.federation_rule_id)throw new m("oidc_federation config requires 'federation_rule_id'. Set it in authentication.federation_rule_id in your profile, or via PUKU_FEDERATION_RULE_ID (profile takes precedence).");if(!J.organization_id)throw new m("oidc_federation config requires organization_id (set PUKU_ORGANIZATION_ID or config.organization_id)");let Y=B$({identityTokenProvider:Q,federationRuleId:G.federation_rule_id,organizationId:J.organization_id,serviceAccountId:G.service_account_id,workspaceId:J.workspace_id,baseURL:Z,fetch:X.fetch,userAgent:X.userAgent});if($)return c9(Y,$,X.onCacheWriteError,X.onSafetyWarning);return Y}case"user_oauth":{if(!$)throw new m("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return W$({credentialsPath:$,clientId:J.authentication.client_id,baseURL:Z,fetch:X.fetch,userAgent:X.userAgent,onSafetyWarning:X.onSafetyWarning})}default:{let G=J.authentication.type;throw new m(`authentication.type "${G}" is not a known authentication type`)}}}function d9(J){if(J.identity_token){let X=J.identity_token.source;if(X!=="file")throw new m(`identity_token.source "${X}" is not supported by this SDK version (only "file")`);if(!J.identity_token.path)throw new m('identity_token.source "file" requires a non-empty path');return T6(J.identity_token.path)}let $=x("PUKU_IDENTITY_TOKEN_FILE");if($)return T6($);let Z=x("PUKU_IDENTITY_TOKEN");if(Z)return Y$(Z);return null}function c9(J,$,Z,X){return async(G)=>{let{fs:Q}=await Promise.resolve().then(() => (K0(),D0));await z1($,X);let Y;try{let B=await Q.promises.readFile($,"utf-8");Y=JSON.parse(B);let K=Y?.access_token;if(K&&!G?.forceRefresh){let W=Y?.expires_at;if(W==null||w0()<W-N2)return{token:K,expiresAt:W??null}}}catch(B){if(B?.code!=="ENOENT"&&!(B instanceof SyntaxError))Z?.(B)}let z=await J(G);try{await B1($,{...Y??{},version:U1,type:"oauth_token",access_token:z.token,expires_at:z.expiresAt})}catch(B){Z?.(B)}return z}}var U$=M(()=>{M6();r0();z$();K$();V$()});function p9(J,$){for(let G=$??0;G<J.length;G++){if(J[G]===10)return{preceding:G,index:G+1,carriage:!1};if(J[G]===13)return{preceding:G,index:G+1,carriage:!0}}return null}function N$(J){for(let X=0;X<J.length-1;X++){if(J[X]===10&&J[X+1]===10)return X+2;if(J[X]===13&&J[X+1]===13)return X+2;if(J[X]===13&&J[X+1]===10&&X+3<J.length&&J[X+2]===13&&J[X+3]===10)return X+4}return-1}var F2;var O6=M(()=>{F2=class F2{static NEWLINE_CHARS=new Set([`
|
|
1
|
+
var C9=Object.create;var{getPrototypeOf:U9,defineProperty:a1,getOwnPropertyNames:N9}=Object;var F9=Object.prototype.hasOwnProperty;function q9(J){return this[J]}var M9,T9,w9=(J,$,Z)=>{var X=J!=null&&typeof J==="object";if(X){var G=$?M9??=new WeakMap:T9??=new WeakMap,Q=G.get(J);if(Q)return Q}Z=J!=null?C9(U9(J)):{};let Y=$||!J||!J.__esModule?a1(Z,"default",{value:J,enumerable:!0}):Z;for(let z of N9(J))if(!F9.call(Y,z))a1(Y,z,{get:q9.bind(J,z),enumerable:!0});if(X)G.set(J,Y);return Y};var r8=(J,$)=>()=>($||J(($={exports:{}}).exports,$),$.exports);var O9=(J)=>J;function R9(J,$){this[J]=O9.bind(null,$)}var R4=(J,$)=>{for(var Z in $)a1(J,Z,{get:$[Z],enumerable:!0,configurable:!0,set:R9.bind($,Z)})};var M=(J,$)=>()=>(J&&($=J(J=0)),$);var U2=function(){let{crypto:J}=globalThis;if(J?.randomUUID)return U2=J.randomUUID.bind(J),J.randomUUID();let $=new Uint8Array(1),Z=J?()=>J.getRandomValues($)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(X)=>(+X^Z()&15>>+X/4).toString(16))};function U0(J){return typeof J==="object"&&J!==null&&(("name"in J)&&J.name==="AbortError"||("message"in J)&&String(J.message).includes("FetchRequestCanceledException"))}var a0=(J)=>{if(J instanceof Error)return J;if(typeof J==="object"&&J!==null){try{let $=Object.prototype.toString.call(J);if($==="[object Error]"||$==="[object DOMException]"){let Z=Error(J.message,J.cause?{cause:J.cause}:{});if(J.stack)Z.stack=J.stack;if(J.cause&&!Z.cause)Z.cause=J.cause;if(J.name)Z.name=J.name;return Z}}catch{}try{return Error(JSON.stringify(J))}catch{}}return Error(J)};var T,l,Z0,S0,g2,t8,h2,m2,u2,d2,c2,p2,l2,i2;var c=M(()=>{T=class T extends Error{name="PukuError";constructor(J){super(J);this.name="PukuError"}};l=class l extends T{status;headers;error;requestID;workspaceID;type;constructor(J,$,Z,X,G){super(`${l.makeMessage(J,$,Z)}`);this.status=J,this.headers=X,this.requestID=X?.get("request-id"),this.workspaceID=X?.get("puku-workspace-id"),this.error=$,this.type=G??null}static makeMessage(J,$,Z){let X=$?.message?typeof $.message==="string"?$.message:JSON.stringify($.message):$?JSON.stringify($):Z;if(J&&X)return`${J} ${X}`;if(J)return`${J} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate(J,$,Z,X){if(!J||!X)return new S0({message:Z,cause:a0($)});let G=$,Q=G?.error?.type;if(J===400)return new h2(J,G,Z,X,Q);if(J===401)return new m2(J,G,Z,X,Q);if(J===403)return new u2(J,G,Z,X,Q);if(J===404)return new d2(J,G,Z,X,Q);if(J===409)return new c2(J,G,Z,X,Q);if(J===422)return new p2(J,G,Z,X,Q);if(J===429)return new l2(J,G,Z,X,Q);if(J>=500)return new i2(J,G,Z,X,Q);return new l(J,G,Z,X,Q)}};Z0=class Z0 extends l{constructor({message:J}={}){super(void 0,void 0,J||"Request was aborted.",void 0)}};S0=class S0 extends l{constructor({message:J,cause:$}){super(void 0,void 0,J||"Connection error.",void 0);if($)this.cause=$}};g2=class g2 extends S0{constructor({message:J}={}){super({message:J??"Request timed out."})}};t8=class t8 extends T{constructor(J,{cause:$}={}){super(J??"Retryable error.");if($!==void 0)this.cause=$}};h2=class h2 extends l{};m2=class m2 extends l{};u2=class u2 extends l{};d2=class d2 extends l{};c2=class c2 extends l{};p2=class p2 extends l{};l2=class l2 extends l{};i2=class i2 extends l{}});function n2(J){if(typeof J!=="object")return{};return J??{}}function r1(J){if(!J)return!0;for(let $ in J)return!1;return!0}function H4(J,$){return Object.prototype.hasOwnProperty.call(J,$)}function t1(J){return J!=null&&typeof J==="object"&&!Array.isArray(J)}function x0(J){}var H9,A4=(J)=>{return H9.test(J)},X0=(J)=>(X0=Array.isArray,X0(J)),o1,L4=(J,$)=>{if(typeof $!=="number"||!Number.isInteger($))throw new T(`${J} must be an integer`);if($<0)throw new T(`${J} must be a positive integer`);return $},o0=(J)=>{try{return JSON.parse(J)}catch($){return}},G0=(J,$)=>{let Z=J[$];return delete J[$],Z};var Q0=M(()=>{c();H9=/^[a-z][a-z0-9+.-]*:/i,o1=X0});var T0=(J,$)=>new Promise((Z)=>{if($?.aborted)return Z();let X=()=>{clearTimeout(G),Z()},G=setTimeout(()=>{$?.removeEventListener("abort",X),Z()},J);$?.addEventListener("abort",X,{once:!0})});var B0="4.0.2";function L9(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function j9(){if(typeof navigator>"u"||!navigator)return null;let J=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:$,pattern:Z}of J){let X=Z.exec(navigator.userAgent);if(X){let G=X[1]||0,Q=X[2]||0,Y=X[3]||0;return{browser:$,version:`${G}.${Q}.${Y}`}}}return null}var P4=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},D9=()=>{let J=L9();if(J==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":j4(Deno.build.os),"X-Stainless-Arch":D4(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process?.version??"unknown"};if(J==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":j4(globalThis.process.platform??"unknown"),"X-Stainless-Arch":D4(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let $=j9();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":B0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},D4=(J)=>{if(J==="x32")return"x32";if(J==="x86_64"||J==="x64")return"x64";if(J==="arm")return"arm";if(J==="aarch64"||J==="arm64")return"arm64";if(J)return`other:${J}`;return"unknown"},j4=(J)=>{if(J=J.toLowerCase(),J.includes("ios"))return"iOS";if(J==="android")return"Android";if(J==="darwin")return"MacOS";if(J==="win32")return"Windows";if(J==="freebsd")return"FreeBSD";if(J==="openbsd")return"OpenBSD";if(J==="linux")return"Linux";if(J)return`Other:${J}`;return"Unknown"},P9,a2=()=>{return P9??=D9()};var s8=()=>{};function S9(J,$){return()=>J.removeEventListener("abort",$)}function _4(J,$,Z){e8.set(J,S9($,Z))}function E4(J,$){if(e8.has($))S4?.register(J,$,$)}function H0(J){let $=e8.get(J);if($)e8.delete(J),S4?.unregister(J),$()}var e8,S4;var J1=M(()=>{e8=new WeakMap,S4=typeof globalThis.FinalizationRegistry==="function"?new globalThis.FinalizationRegistry((J)=>H0(J)):null});function I4(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new PukuAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function s1(...J){let $=globalThis.ReadableStream;if(typeof $>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new $(...J)}function $1(J){let $=Symbol.asyncIterator in J?J[Symbol.asyncIterator]():J[Symbol.iterator]();return s1({start(){},async pull(Z){let{done:X,value:G}=await $.next();if(X)Z.close();else Z.enqueue(G)},async cancel(){await $.return?.()}})}function o2(J){if(J[Symbol.asyncIterator])return J;let $=J.getReader();return{async next(){try{let Z=await $.read();if(Z?.done)$.releaseLock();return Z}catch(Z){throw $.releaseLock(),Z}},async return(){let Z=$.cancel();return $.releaseLock(),await Z,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function y4(J){if(J===null||typeof J!=="object")return;if(J[Symbol.asyncIterator]){await J[Symbol.asyncIterator]().return?.();return}let $=J.getReader(),Z=$.cancel();$.releaseLock(),await Z}class e1{index}var x4=({headers:J,body:$})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify($)}};var J6="RFC3986",$6=(J)=>String(J),Z6,k4="RFC1738";var X6=M(()=>{Z6={RFC1738:(J)=>String(J).replace(/%20/g,"+"),RFC3986:$6}});function v4(J){if(!J||typeof J!=="object")return!1;return!!(J.constructor&&J.constructor.isBuffer&&J.constructor.isBuffer(J))}function Q6(J,$){if(X0(J)){let Z=[];for(let X=0;X<J.length;X+=1)Z.push($(J[X]));return Z}return $(J)}var Z1=(J,$)=>(Z1=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Z1(J,$)),L0,G6=1024,f4=(J,$,Z,X,G)=>{if(J.length===0)return J;let Q=J;if(typeof J==="symbol")Q=Symbol.prototype.toString.call(J);else if(typeof J!=="string")Q=String(J);if(Z==="iso-8859-1")return escape(Q).replace(/%u[0-9a-f]{4}/gi,function(z){return"%26%23"+parseInt(z.slice(2),16)+"%3B"});let Y="";for(let z=0;z<Q.length;z+=G6){let B=Q.length>=G6?Q.slice(z,z+G6):Q,K=[];for(let W=0;W<B.length;++W){let C=B.charCodeAt(W);if(C===45||C===46||C===95||C===126||C>=48&&C<=57||C>=65&&C<=90||C>=97&&C<=122||G===k4&&(C===40||C===41)){K[K.length]=B.charAt(W);continue}if(C<128){K[K.length]=L0[C];continue}if(C<2048){K[K.length]=L0[192|C>>6]+L0[128|C&63];continue}if(C<55296||C>=57344){K[K.length]=L0[224|C>>12]+L0[128|C>>6&63]+L0[128|C&63];continue}W+=1,C=65536+((C&1023)<<10|B.charCodeAt(W)&1023),K[K.length]=L0[240|C>>18]+L0[128|C>>12&63]+L0[128|C>>6&63]+L0[128|C&63]}Y+=K.join("")}return Y};var b4=M(()=>{X6();Q0();L0=(()=>{let J=[];for(let $=0;$<256;++$)J.push("%"+(($<16?"0":"")+$.toString(16)).toUpperCase());return J})()});function y9(J){return typeof J==="string"||typeof J==="number"||typeof J==="boolean"||typeof J==="symbol"||typeof J==="bigint"}function m4(J,$,Z,X,G,Q,Y,z,B,K,W,C,V,F,q,A,R,H){let O=J,D=H,S=0,y=!1;while((D=D.get(Y6))!==void 0&&!y){let b=D.get(J);if(S+=1,typeof b<"u")if(b===S)throw RangeError("Cyclic object value");else y=!0;if(typeof D.get(Y6)>"u")S=0}if(typeof K==="function")O=K($,O);else if(O instanceof Date)O=V?.(O);else if(Z==="comma"&&X0(O))O=Q6(O,function(b){if(b instanceof Date)return V?.(b);return b});if(O===null){if(Q)return B&&!A?B($,a.encoder,R,"key",F):$;O=""}if(y9(O)||v4(O)){if(B){let b=A?$:B($,a.encoder,R,"key",F);return[q?.(b)+"="+q?.(B(O,a.encoder,R,"value",F))]}return[q?.($)+"="+q?.(String(O))]}let f=[];if(typeof O>"u")return f;let v;if(Z==="comma"&&X0(O)){if(A&&B)O=Q6(O,B);v=[{value:O.length>0?O.join(",")||null:void 0}]}else if(X0(K))v=K;else{let b=Object.keys(O);v=W?b.sort(W):b}let g=z?String($).replace(/\./g,"%2E"):String($),d=X&&X0(O)&&O.length===1?g+"[]":g;if(G&&X0(O)&&O.length===0)return d+"[]";for(let b=0;b<v.length;++b){let t=v[b],A0=typeof t==="object"&&typeof t.value<"u"?t.value:O[t];if(Y&&A0===null)continue;let n0=C&&z?t.replace(/\./g,"%2E"):t,C2=X0(O)?typeof Z==="function"?Z(d,n0):d:d+(C?"."+n0:"["+n0+"]");H.set(J,S);let O4=new WeakMap;O4.set(Y6,H),h4(f,m4(A0,C2,Z,X,G,Q,Y,z,Z==="comma"&&A&&X0(O)?null:B,K,W,C,V,F,q,A,R,O4))}return f}function x9(J=a){if(typeof J.allowEmptyArrays<"u"&&typeof J.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof J.encodeDotInKeys<"u"&&typeof J.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(J.encoder!==null&&typeof J.encoder<"u"&&typeof J.encoder!=="function")throw TypeError("Encoder has to be a function.");let $=J.charset||a.charset;if(typeof J.charset<"u"&&J.charset!=="utf-8"&&J.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Z=J6;if(typeof J.format<"u"){if(!Z1(Z6,J.format))throw TypeError("Unknown format option provided.");Z=J.format}let X=Z6[Z],G=a.filter;if(typeof J.filter==="function"||X0(J.filter))G=J.filter;let Q;if(J.arrayFormat&&J.arrayFormat in g4)Q=J.arrayFormat;else if("indices"in J)Q=J.indices?"indices":"repeat";else Q=a.arrayFormat;if("commaRoundTrip"in J&&typeof J.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let Y=typeof J.allowDots>"u"?!!J.encodeDotInKeys===!0?!0:a.allowDots:!!J.allowDots;return{addQueryPrefix:typeof J.addQueryPrefix==="boolean"?J.addQueryPrefix:a.addQueryPrefix,allowDots:Y,allowEmptyArrays:typeof J.allowEmptyArrays==="boolean"?!!J.allowEmptyArrays:a.allowEmptyArrays,arrayFormat:Q,charset:$,charsetSentinel:typeof J.charsetSentinel==="boolean"?J.charsetSentinel:a.charsetSentinel,commaRoundTrip:!!J.commaRoundTrip,delimiter:typeof J.delimiter>"u"?a.delimiter:J.delimiter,encode:typeof J.encode==="boolean"?J.encode:a.encode,encodeDotInKeys:typeof J.encodeDotInKeys==="boolean"?J.encodeDotInKeys:a.encodeDotInKeys,encoder:typeof J.encoder==="function"?J.encoder:a.encoder,encodeValuesOnly:typeof J.encodeValuesOnly==="boolean"?J.encodeValuesOnly:a.encodeValuesOnly,filter:G,format:Z,formatter:X,serializeDate:typeof J.serializeDate==="function"?J.serializeDate:a.serializeDate,skipNulls:typeof J.skipNulls==="boolean"?J.skipNulls:a.skipNulls,sort:typeof J.sort==="function"?J.sort:null,strictNullHandling:typeof J.strictNullHandling==="boolean"?J.strictNullHandling:a.strictNullHandling}}function u4(J,$={}){let Z=J,X=x9($),G,Q;if(typeof X.filter==="function")Q=X.filter,Z=Q("",Z);else if(X0(X.filter))Q=X.filter,G=Q;let Y=[];if(typeof Z!=="object"||Z===null)return"";let z=g4[X.arrayFormat],B=z==="comma"&&X.commaRoundTrip;if(!G)G=Object.keys(Z);if(X.sort)G.sort(X.sort);let K=new WeakMap;for(let V=0;V<G.length;++V){let F=G[V];if(X.skipNulls&&Z[F]===null)continue;h4(Y,m4(Z[F],F,z,B,X.allowEmptyArrays,X.strictNullHandling,X.skipNulls,X.encodeDotInKeys,X.encode?X.encoder:null,X.filter,X.sort,X.allowDots,X.serializeDate,X.format,X.formatter,X.encodeValuesOnly,X.charset,K))}let W=Y.join(X.delimiter),C=X.addQueryPrefix===!0?"?":"";if(X.charsetSentinel)if(X.charset==="iso-8859-1")C+="utf8=%26%2310003%3B&";else C+="utf8=%E2%9C%93&";return W.length>0?C+W:""}var g4,h4=function(J,$){Array.prototype.push.apply(J,X0($)?$:[$])},I9,a,Y6;var d4=M(()=>{b4();X6();Q0();g4={brackets(J){return String(J)+"[]"},comma:"comma",indices(J,$){return String(J)+"["+$+"]"},repeat(J){return String(J)}},a={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:f4,encodeValuesOnly:!1,format:J6,formatter:$6,indices:!1,serializeDate(J){return(I9??=Function.prototype.call.bind(Date.prototype.toISOString))(J)},skipNulls:!1,strictNullHandling:!1};Y6={}});function c4(J){return u4(J,{arrayFormat:"brackets"})}var z6=M(()=>{d4()});var D0={};R4(D0,{util:()=>K6,stream:()=>X1,path:()=>j,os:()=>f9,fs:()=>_0,crypto:()=>k0,child_process:()=>B6});import*as B6 from"node:child_process";import*as k0 from"node:crypto";import*as _0 from"node:fs";import*as f9 from"node:os";import*as j from"node:path";import*as X1 from"node:stream";import*as K6 from"node:util";var K0=()=>{};function Q1(J){if(!J)return;let $;try{$=new URL(J)}catch(X){throw new m(`Invalid token endpoint base URL "${J}": ${X}`)}if($.protocol==="https:")return;let Z=$.hostname.toLowerCase().replace(/^\[|\]$/g,"");if($.protocol==="http:"&&(Z==="localhost"||Z==="127.0.0.1"||Z==="::1"))return;throw new m(`Refusing to send credential over non-https token endpoint "${J}"`)}async function Y1(J,$){let Z=await b9(J),X;try{X=JSON.parse(Z)}catch{throw new m(`Token endpoint returned non-JSON response (status ${J.status})`,J.status,W0(Z),$)}if(!X.access_token)throw new m(`Token endpoint response missing access_token: ${JSON.stringify(W0(X))}`,J.status,W0(X),$);if(X.token_type&&X.token_type.toLowerCase()!=="bearer")throw new m(`Token endpoint response: unsupported token_type "${X.token_type}" (want Bearer)`,J.status,W0(X),$);return X}function W0(J){if(J==null)return J;if(typeof J==="string"){let $;try{$=JSON.parse(J)}catch{if(J.length<=W6)return J;return J.slice(0,W6)+`... <${J.length-W6} more chars>`}return JSON.stringify(W0($))}if(typeof J==="object"&&!Array.isArray(J)){let $={};for(let[Z,X]of Object.entries(J))if(v9.has(Z))$[Z]=X;return $}return null}async function z1(J,$=(Z)=>console.warn(`puku-ai/sdk: ${Z}`)){if(typeof process>"u"||process.platform==="win32")return;let{fs:Z}=await Promise.resolve().then(() => (K0(),D0)),X=J,G;try{X=await Z.promises.realpath(J),G=await Z.promises.stat(X)}catch{return}let Q=G.mode&511;if(Q&18)throw new m(`Credentials file at ${X} is group/world-writable (mode 0o${Q.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${X}\`.`);if(Q&36)throw new m(`Credentials file at ${X} is group/world-readable (mode 0o${Q.toString(8)}); run \`chmod 600 ${X}\` before retrying.`);if(typeof process.getuid==="function"&&G.uid!==process.getuid())$(`credentials file at ${X} is owned by uid ${G.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function B1(J,$){let{fs:Z,path:X}=await Promise.resolve().then(() => (K0(),D0)),G=X.dirname(J);await Z.promises.mkdir(G,{recursive:!0,mode:448});let Q=`${J}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let Y=await Z.promises.open(Q,"w",384);try{await Y.writeFile(JSON.stringify($,null,2)),await Y.sync()}finally{await Y.close()}await Z.promises.rename(Q,J)}catch(Y){throw await Z.promises.unlink(Q).catch(()=>{}),Y}try{let Y=await Z.promises.open(G,"r");try{await Y.sync()}finally{await Y.close()}}catch{}}async function b9(J){if(!J.body)return"";let $=J.body.getReader(),Z=[],X=0;for(;;){let{done:Q,value:Y}=await $.read();if(Q)break;if(X+Y.length>p4){let z=p4-X;if(z>0)Z.push(Y.subarray(0,z));await $.cancel();break}Z.push(Y),X+=Y.length}let G;if(Z.length===1)G=Z[0];else{G=new Uint8Array(Z.reduce((Y,z)=>Y+z.length,0));let Q=0;for(let Y of Z)G.set(Y,Q),Q+=Y.length}return new TextDecoder("utf-8").decode(G)}var l4="urn:ietf:params:oauth:grant-type:jwt-bearer",i4="refresh_token",G1="/v1/oauth/token",f0="oauth-2025-04-20",V6="oidc-federation-2026-04-01",n4=120,N2=30,a4=5,p4=1048576,W6=2000,v9,m;var r0=M(()=>{c();v9=new Set(["error","error_description","error_uri"]);m=class m extends T{statusCode;body;requestId;constructor(J,$=null,Z=null,X=null){super(J);this.statusCode=$,this.body=Z,this.requestId=X}}});function w0(){return Math.floor(Date.now()/1000)}class C6{provider;cached=null;pendingRefresh=null;nextForce=!1;lastAdvisoryError=0;onAdvisoryRefreshError;constructor(J,$){this.provider=J,this.onAdvisoryRefreshError=$}async getToken(){let J=this.nextForce;this.nextForce=!1;let $=this.cached;if(J||$==null)return(await this.refresh(J)).token;if($.expiresAt==null)return $.token;let Z=$.expiresAt-w0();if(Z>n4)return $.token;if(Z>N2)return this.backgroundRefresh(),$.token;return(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(J=!1){if(this.pendingRefresh&&!J)return this.pendingRefresh;return this.doRefresh(J)}backgroundRefresh(){if(this.pendingRefresh)return;if(w0()-this.lastAdvisoryError<a4)return;this.doRefresh().catch((J)=>{this.lastAdvisoryError=w0(),this.onAdvisoryRefreshError?.(J)})}doRefresh(J=!1){return this.pendingRefresh=this.provider(J?{forceRefresh:!0}:void 0).then(($)=>{return this.cached=$,this.pendingRefresh=null,$},($)=>{throw this.pendingRefresh=null,$}),this.pendingRefresh}}var o4=M(()=>{r0()});var x=(J)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[J]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(J)?.trim()||void 0;return};function s4(J){let $=0;for(let G of J)$+=G.length;let Z=new Uint8Array($),X=0;for(let G of J)Z.set(G,X),X+=G.length;return Z}function v0(J){let $;return(r4??($=new globalThis.TextEncoder,r4=$.encode.bind($)))(J)}function t0(J){let $;return(t4??($=new globalThis.TextDecoder,t4=$.decode.bind($)))(J)}var r4,t4;var r2=(J)=>{if(typeof globalThis.Buffer<"u"){let $=globalThis.Buffer.from(J,"base64");return new Uint8Array($.buffer,$.byteOffset,$.byteLength)}if(typeof atob<"u"){let $=atob(J),Z=new Uint8Array($.length);for(let X=0;X<$.length;X++)Z[X]=$.charCodeAt(X);return Z}throw new T("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var K1=M(()=>{c()});function t2(){}function W1(J,$,Z){if(!$||V1[J]>V1[Z])return t2;else return $[J].bind($)}function N6(J,$){let Z=e4.get(J);if(Z&&Z[0]===$)return Z[1];let X={error:W1("error",J,$),warn:W1("warn",J,$),info:W1("info",J,$),debug:W1("debug",J,$)};return e4.set(J,[$,X]),X}function k(J){let $=J.logger,Z=J.logLevel??"off";if(!$)return g9;return N6($,Z)}function $$(){let J=x("PUKU_LOG");if(!U6||J!==J$)J$=J,U6=N6(console,C1(J,"process.env['PUKU_LOG']",N6(console,s2))??s2);return U6}var s2="warn",V1,C1=(J,$,Z)=>{if(!J)return;if(H4(V1,J))return J;Z.warn(`${$} was set to ${JSON.stringify(J)}, expected one of ${JSON.stringify(Object.keys(V1))}`);return},g9,e4,J$,U6,j0=(J)=>{if(J.options)J.options={...J.options},delete J.options.headers;if(J.headers)J.headers=Object.fromEntries((J.headers instanceof Headers?[...J.headers]:Object.entries(J.headers)).map(([$,Z])=>[$,$.toLowerCase()==="authorization"||$.toLowerCase()==="api-key"||$.toLowerCase()==="x-api-key"||$.toLowerCase()==="cookie"||$.toLowerCase()==="set-cookie"?"***":Z]));if("retryOfRequestLogID"in J){if(J.retryOfRequestLogID)J.retryOf=J.retryOfRequestLogID;delete J.retryOfRequestLogID}return J};var O0=M(()=>{Q0();V1={off:0,error:200,warn:300,info:400,debug:500};g9={error:t2,warn:t2,info:t2,debug:t2},e4=new WeakMap});var F6=M(()=>{Q0();K1();O0();z6()});function Z$(J){if(!J)throw Error("profile name is empty");if(J==="."||J==="..")throw Error(`profile name "${J}" is not allowed`);if(J.includes("/")||J.includes("\\"))throw Error(`profile name "${J}" must not contain path separators`);if(!h9.test(J))throw Error(`profile name "${J}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var U1="1.0",h9,X$=async(J)=>{let $=await q6();if($===null)return null;let Z=J??await Q$();if(Z===null)return null;Z$(Z);let{fs:X,path:G}=await Promise.resolve().then(() => (K0(),D0)),Q=G.join($,"configs",`${Z}.json`),Y;try{Y=await X.promises.readFile(Q,"utf-8")}catch(K){if(K?.code!=="ENOENT")throw Error(`failed to read config file ${Q}: ${K}`);Y=null}if(Y===null){let K=x("PUKU_ORGANIZATION_ID"),W=x("PUKU_IDENTITY_TOKEN_FILE"),C=x("PUKU_FEDERATION_RULE_ID");if(C&&K)return{fromFile:!1,config:{organization_id:K,workspace_id:x("PUKU_WORKSPACE_ID"),base_url:x("PUKU_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:C,service_account_id:x("PUKU_SERVICE_ACCOUNT_ID"),identity_token:W?{source:"file",path:W}:void 0,scope:x("PUKU_SCOPE")}}};return null}let z;try{z=JSON.parse(Y)}catch(K){throw Error(`failed to parse config file ${Q}: ${K}`)}if(!z.authentication)throw Error(`config file ${Q} is missing "authentication"`);let B=z.authentication.type;if(B!=="oidc_federation"&&B!=="user_oauth")throw Error(`authentication.type "${B}" is not a known authentication type`);if(z.organization_id??=x("PUKU_ORGANIZATION_ID"),z.workspace_id??=x("PUKU_WORKSPACE_ID"),z.base_url??=x("PUKU_BASE_URL"),z.authentication.scope??=x("PUKU_SCOPE"),z.authentication.type==="oidc_federation"){if(!z.authentication.identity_token){let K=x("PUKU_IDENTITY_TOKEN_FILE");if(K)z.authentication.identity_token={source:"file",path:K}}if(!z.authentication.federation_rule_id)z.authentication.federation_rule_id=x("PUKU_FEDERATION_RULE_ID")??"";z.authentication.service_account_id??=x("PUKU_SERVICE_ACCOUNT_ID")}return{config:z,fromFile:!0}},G$=async(J,$)=>{if(J?.authentication.credentials_path)return J.authentication.credentials_path;let Z=await q6();if(!Z)return null;let X=$??await Q$();if(!X)return null;Z$(X);let{path:G}=await Promise.resolve().then(() => (K0(),D0));return G.join(Z,"credentials",`${X}.json`)},q6=async()=>{if(!m9())return null;let{path:J}=await Promise.resolve().then(() => (K0(),D0)),$=x("PUKU_CONFIG_DIR");if($)return $;if(a2()["X-Stainless-OS"]==="Windows"){let Q=x("APPDATA");if(Q)return J.join(Q,"PukuAI");let Y=x("USERPROFILE");if(Y)return J.join(Y,"AppData","Roaming","PukuAI");return null}let X=x("XDG_CONFIG_HOME");if(X)return J.join(X,"puku");let G=x("HOME");if(G)return J.join(G,".config","puku");return null},m9=()=>{let J=a2()["X-Stainless-Runtime"];return J==="node"||J==="deno"},Q$=async()=>{let J=await q6();if(!J)return null;let $=x("PUKU_PROFILE");if($)return $;let{fs:Z,path:X}=await Promise.resolve().then(() => (K0(),D0)),G=X.join(J,"active_config");try{return(await Z.promises.readFile(G,"utf-8")).trim()||"default"}catch(Q){if(Q?.code!=="ENOENT")throw Error(`failed to read ${G}: ${Q}`);return"default"}};var M6=M(()=>{s8();F6();h9=/^[A-Za-z0-9_.-]+$/});function T6(J){if(!J)throw new T("Identity token file path is empty");return async()=>{let{fs:$}=await Promise.resolve().then(() => (K0(),D0)),Z;try{Z=await $.promises.readFile(J,"utf-8")}catch(G){throw new T(`Failed to read identity token file at ${J}: ${G}`)}let X=Z.trim();if(!X)throw new T(`Identity token file at ${J} is empty`);return X}}function Y$(J){if(!J)throw new T("Identity token value is empty");return()=>J}var z$=M(()=>{c()});function B$(J){return async()=>{Q1(J.baseURL);let $=await J.identityTokenProvider();if($.length>16384)throw new m(`Identity token is ${Math.ceil($.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let Z={grant_type:l4,assertion:$,federation_rule_id:J.federationRuleId,organization_id:J.organizationId};if(J.serviceAccountId)Z.service_account_id=J.serviceAccountId;if(J.workspaceId)Z.workspace_id=J.workspaceId;let X=`${J.baseURL}${G1}`,G;try{G=await J.fetch(X,{method:"POST",headers:{"Content-Type":"application/json","puku-beta":`${f0},${V6}`,"User-Agent":J.userAgent||`puku-ai-sdk-typescript/${B0} oidcFederationProvider`},body:JSON.stringify(Z)})}catch(B){throw new m(`Failed to reach token endpoint ${X}: ${B}`)}let Q=G.headers.get("Request-Id");if(!G.ok){let B=await G.text().catch(()=>""),K=W0(B),W="";if(G.status===401)W=` Ensure your federation rule matches your identity token. ${J.workspaceId?"":"If your federation rule is scoped to multiple workspaces, set the PUKU_WORKSPACE_ID environment variable, the 'workspace_id' config key, or the `workspaceId` option. "}View your authentication events in the Workload identity page of Puku Console for more details.`;throw new m(`Token exchange failed with status ${G.status}${Q?` (request-id ${Q})`:""}: ${K}${W}`,G.status,K,Q)}let Y=await Y1(G,Q),z=Number(Y.expires_in);if(!Number.isFinite(z))throw new m(`Token endpoint response missing required fields: ${JSON.stringify(W0(Y))}`,G.status,W0(Y),Q);return{token:Y.access_token,expiresAt:w0()+z}}}var K$=M(()=>{r0()});function W$(J){return async($)=>{let{fs:Z}=await Promise.resolve().then(() => (K0(),D0));await z1(J.credentialsPath,J.onSafetyWarning);let X;try{X=await Z.promises.readFile(J.credentialsPath,"utf-8")}catch(R){throw new m(`Credentials file not found at ${J.credentialsPath}: ${R}`)}let G;try{G=JSON.parse(X)}catch(R){throw new m(`Credentials file at ${J.credentialsPath} is not valid JSON: ${R}`)}let Q=G.access_token;if(!Q)throw new m(`Credentials file at ${J.credentialsPath} must include 'access_token'`);let Y=G.expires_at;if(!$?.forceRefresh&&(Y==null||w0()<Y-N2))return{token:Q,expiresAt:Y??null};let z=G.refresh_token;if(!J.clientId||!z)throw new m(`Access token at ${J.credentialsPath} has expired and no refresh is available (client_id ${J.clientId?"set":"empty"}, refresh_token ${z?"set":"empty"})`);Q1(J.baseURL);let B={grant_type:i4,refresh_token:z,client_id:J.clientId},K=`${J.baseURL}${G1}`,W;try{W=await J.fetch(K,{method:"POST",headers:{"Content-Type":"application/json","puku-beta":f0,"User-Agent":J.userAgent||`puku-ai-sdk-typescript/${B0} userOAuthProvider`},body:JSON.stringify(B)})}catch(R){throw new m(`User OAuth refresh failed to reach token endpoint: ${R}`)}let C=W.headers.get("Request-Id");if(!W.ok){let R=await W.text().catch(()=>"");throw new m(`User OAuth refresh failed (HTTP ${W.status}): ${W0(R)}`,W.status,W0(R),C)}let V=await Y1(W,C),F=Number(V.expires_in);if(!Number.isFinite(F))throw new m(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(W0(V))}`,W.status,W0(V),C);let q=w0()+F,A=V.refresh_token||z;return await B1(J.credentialsPath,{...G,version:U1,type:"oauth_token",access_token:V.access_token,expires_at:q,refresh_token:A}),{token:V.access_token,expiresAt:q}}}var V$=M(()=>{M6();r0()});function w6(J,$){let Z=J.authentication.credentials_path??null,X=(J.base_url||$.baseURL).replace(/\/+$/,""),G=u9(J,Z,X,$),Q={};if(J.workspace_id&&J.authentication.type==="user_oauth")Q["puku-workspace-id"]=J.workspace_id;return{provider:G,extraHeaders:Q,baseURL:J.base_url||void 0}}async function C$(J,$){let Z=await X$($);if(!Z)return null;let{config:X,fromFile:G}=Z,Q=X.authentication.credentials_path||!G?X:{...X,authentication:{...X.authentication,credentials_path:await G$(X,$)??void 0}};return w6(Q,J)}function u9(J,$,Z,X){switch(J.authentication.type){case"oidc_federation":{let G=J.authentication,Q=d9(G);if(!Q)throw new m("oidc_federation config requires an identity token (set authentication.identity_token, PUKU_IDENTITY_TOKEN_FILE, or PUKU_IDENTITY_TOKEN)");if(!G.federation_rule_id)throw new m("oidc_federation config requires 'federation_rule_id'. Set it in authentication.federation_rule_id in your profile, or via PUKU_FEDERATION_RULE_ID (profile takes precedence).");if(!J.organization_id)throw new m("oidc_federation config requires organization_id (set PUKU_ORGANIZATION_ID or config.organization_id)");let Y=B$({identityTokenProvider:Q,federationRuleId:G.federation_rule_id,organizationId:J.organization_id,serviceAccountId:G.service_account_id,workspaceId:J.workspace_id,baseURL:Z,fetch:X.fetch,userAgent:X.userAgent});if($)return c9(Y,$,X.onCacheWriteError,X.onSafetyWarning);return Y}case"user_oauth":{if(!$)throw new m("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return W$({credentialsPath:$,clientId:J.authentication.client_id,baseURL:Z,fetch:X.fetch,userAgent:X.userAgent,onSafetyWarning:X.onSafetyWarning})}default:{let G=J.authentication.type;throw new m(`authentication.type "${G}" is not a known authentication type`)}}}function d9(J){if(J.identity_token){let X=J.identity_token.source;if(X!=="file")throw new m(`identity_token.source "${X}" is not supported by this SDK version (only "file")`);if(!J.identity_token.path)throw new m('identity_token.source "file" requires a non-empty path');return T6(J.identity_token.path)}let $=x("PUKU_IDENTITY_TOKEN_FILE");if($)return T6($);let Z=x("PUKU_IDENTITY_TOKEN");if(Z)return Y$(Z);return null}function c9(J,$,Z,X){return async(G)=>{let{fs:Q}=await Promise.resolve().then(() => (K0(),D0));await z1($,X);let Y;try{let B=await Q.promises.readFile($,"utf-8");Y=JSON.parse(B);let K=Y?.access_token;if(K&&!G?.forceRefresh){let W=Y?.expires_at;if(W==null||w0()<W-N2)return{token:K,expiresAt:W??null}}}catch(B){if(B?.code!=="ENOENT"&&!(B instanceof SyntaxError))Z?.(B)}let z=await J(G);try{await B1($,{...Y??{},version:U1,type:"oauth_token",access_token:z.token,expires_at:z.expiresAt})}catch(B){Z?.(B)}return z}}var U$=M(()=>{M6();r0();z$();K$();V$()});function p9(J,$){for(let G=$??0;G<J.length;G++){if(J[G]===10)return{preceding:G,index:G+1,carriage:!1};if(J[G]===13)return{preceding:G,index:G+1,carriage:!0}}return null}function N$(J){for(let X=0;X<J.length-1;X++){if(J[X]===10&&J[X+1]===10)return X+2;if(J[X]===13&&J[X+1]===13)return X+2;if(J[X]===13&&J[X+1]===10&&X+3<J.length&&J[X+2]===13&&J[X+3]===10)return X+4}return-1}var F2;var O6=M(()=>{F2=class F2{static NEWLINE_CHARS=new Set([`
|
|
2
2
|
`,"\r"]);static NEWLINE_REGEXP=/\r\n|[\n\r]/g;#J;#$;constructor(){this.#J=new Uint8Array,this.#$=null}decode(J){if(J==null)return[];let $=J instanceof ArrayBuffer?new Uint8Array(J):typeof J==="string"?v0(J):J;this.#J=s4([this.#J,$]);let Z=[],X;while((X=p9(this.#J,this.#$))!=null){if(X.carriage&&this.#$==null){this.#$=X.index;continue}if(this.#$!=null&&(X.index!==this.#$+1||X.carriage)){Z.push(t0(this.#J.subarray(0,this.#$-1))),this.#J=this.#J.subarray(this.#$),this.#$=null;continue}let G=this.#$!==null?X.preceding-1:X.preceding,Q=t0(this.#J.subarray(0,G));Z.push(Q),this.#J=this.#J.subarray(X.index),this.#$=null}return Z}flush(){if(!this.#J.length)return[];return this.decode(`
|
|
3
3
|
`)}}});async function*F$(J,$){if(!J.body){if($.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new T("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new T("Attempted to iterate over a response with no body")}let Z=new q$,X=new F2,G=o2(J.body);for await(let Q of l9(G))for(let Y of X.decode(Q)){let z=Z.decode(Y);if(z)yield z}for(let Q of X.flush()){let Y=Z.decode(Q);if(Y)yield Y}}async function*l9(J){let $=new Uint8Array;for await(let Z of J){if(Z==null)continue;let X=Z instanceof ArrayBuffer?new Uint8Array(Z):typeof Z==="string"?v0(Z):Z,G=new Uint8Array($.length+X.length);G.set($),G.set(X,$.length),$=G;let Q;while((Q=N$($))!==-1)yield $.slice(0,Q),$=$.slice(Q)}if($.length>0)yield $}class q${data;event;chunks;constructor(){this.event=null,this.data=[],this.chunks=[]}decode(J){if(J.endsWith("\r"))J=J.substring(0,J.length-1);if(!J){if(!this.event&&!this.data.length)return null;let G={event:this.event,data:this.data.join(`
|
|
4
4
|
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],G}if(this.chunks.push(J),J.startsWith(":"))return null;let[$,Z,X]=i9(J,":");if(X.startsWith(" "))X=X.substring(1);if($==="event")this.event=X;else if($==="data")this.data.push(X);return null}}function i9(J,$){let Z=J.indexOf($);if(Z!==-1)return[J.substring(0,Z),$,J.substring(Z+$.length)];return[J,"",""]}var s;var q2=M(()=>{c();O6();Q0();O0();c();J1();s=class s{iterator;controller;#J;constructor(J,$,Z){this.iterator=J;this.controller=$,this.#J=Z}static rawEvents(J,$=new AbortController){return F$(J,$)}static fromSSEResponse(J,$,Z){let X=!1,G=Z?k(Z):console;async function*Q(){if(X)throw new T("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let Y=!1;try{for await(let z of F$(J,$)){if(z.event==="completion")try{yield JSON.parse(z.data)}catch(B){throw G.error("Could not parse message into JSON:",z.data),G.error("From chunk:",z.raw),B}if(z.event==="message_start"||z.event==="message_delta"||z.event==="message_stop"||z.event==="content_block_start"||z.event==="content_block_delta"||z.event==="content_block_stop"||z.event==="message"||z.event==="user.message"||z.event==="user.interrupt"||z.event==="user.tool_confirmation"||z.event==="user.custom_tool_result"||z.event==="user.tool_result"||z.event==="agent.message"||z.event==="agent.thinking"||z.event==="agent.tool_use"||z.event==="agent.tool_result"||z.event==="agent.mcp_tool_use"||z.event==="agent.mcp_tool_result"||z.event==="agent.custom_tool_use"||z.event==="agent.thread_context_compacted"||z.event==="session.status_running"||z.event==="session.status_idle"||z.event==="session.status_rescheduled"||z.event==="session.status_terminated"||z.event==="session.error"||z.event==="session.deleted"||z.event==="session.updated"||z.event==="span.model_request_start"||z.event==="span.model_request_end"||z.event==="span.outcome_evaluation_start"||z.event==="span.outcome_evaluation_ongoing"||z.event==="span.outcome_evaluation_end"||z.event==="user.define_outcome"||z.event==="agent.thread_message_received"||z.event==="agent.thread_message_sent"||z.event==="agent.session_thread_message_received"||z.event==="agent.session_thread_message_sent"||z.event==="session.thread_created"||z.event==="session.thread_status_created"||z.event==="session.thread_status_running"||z.event==="session.thread_status_idle"||z.event==="session.thread_status_rescheduled"||z.event==="session.thread_status_terminated"||z.event==="event_start"||z.event==="event_delta"||z.event==="system.message")try{yield JSON.parse(z.data)}catch(B){throw G.error("Could not parse message into JSON:",z.data),G.error("From chunk:",z.raw),B}if(z.event==="ping")continue;if(z.event==="error"){let B=o0(z.data)??z.data,K=B?.error?.type;throw new l(void 0,B,void 0,J.headers,K)}}Y=!0}catch(z){if(U0(z))return;throw z}finally{if(!Y)$.abort();H0($)}}return new s(Q,$,Z)}static fromReadableStream(J,$,Z){let X=!1;async function*G(){let Y=new F2,z=o2(J);for await(let B of z)for(let K of Y.decode(B))yield K;for(let B of Y.flush())yield B}async function*Q(){if(X)throw new T("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let Y=!1;try{for await(let z of G()){if(Y)continue;if(z)yield JSON.parse(z)}Y=!0}catch(z){if(U0(z))return;throw z}finally{if(!Y)$.abort();H0($)}}return new s(Q,$,Z)}[Symbol.asyncIterator](){return this.iterator()}tee(){let J=[],$=[],Z=this.iterator(),X=(G)=>{return{next:()=>{if(G.length===0){let Q=Z.next();J.push(Q),$.push(Q)}return G.shift()}}};return[new s(()=>X(J),this.controller,this.#J),new s(()=>X($),this.controller,this.#J)]}toReadableStream(){let J=this,$;return s1({async start(){$=J[Symbol.asyncIterator]()},async pull(Z){try{let{value:X,done:G}=await $.next();if(G)return Z.close();let Q=v0(JSON.stringify(X)+`
|
|
@@ -44,9 +44,9 @@ User preferences or style requirements
|
|
|
44
44
|
Domain-specific details that aren't obvious
|
|
45
45
|
Any promises made to the user
|
|
46
46
|
Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
|
|
47
|
-
Wrap your summary in <summary></summary> tags.`;async function rX(J,$=J.messages.at(-1),Z){if(!$||$.role!=="assistant"||!$.content||typeof $.content==="string")return null;let X=$.content.filter((Y)=>Y.type==="tool_use");if(X.length===0)return null;let G=sX(J);return{role:"user",content:await Promise.all(X.map(async(Y)=>{let z=J.tools.find((B)=>("name"in B?B.name:("mcp_server_name"in B)?B.mcp_server_name:B.type)===Y.name);if(!z||!("run"in z)||!G.has(Y.name))return tX(Y);try{let B=Y.input;if("parse"in z&&z.parse)B=z.parse(B);let K=await z.run(B,{toolUse:Y,toolUseBlock:Y,signal:Z?.signal});return{type:"tool_result",tool_use_id:Y.id,content:K}}catch(B){return{type:"tool_result",tool_use_id:Y.id,content:B instanceof P?B.content:`Error: ${B instanceof Error?B.message:String(B)}`,is_error:!0}}}))}}function tX(J){return{type:"tool_result",tool_use_id:J.id,content:`Error: Tool '${J.name}' not found`,is_error:!0}}function sX(J){let $=new Set;for(let Z of J.tools)if("run"in Z)$.add(Z.name);for(let Z of J.messages){if(Z.role!=="system"||typeof Z.content==="string")continue;for(let X of Z.content)eX(X,$)}return $}function eX(J,$){switch(J.type){case"tool_removal":case"tool_addition":JG(J,$);break}}function JG(J,$){let Z=$G(J.tool);if(Z===void 0)return;if(J.type==="tool_removal")$.delete(Z);else $.add(Z)}function $G(J){switch(J.type){case"tool_reference":return J.name;default:return}}function ZG(J){if(J===null)return"stop";switch(J){case"tool_use":return"run_tools";case"pause_turn":case"compaction":return"resume";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return x0(J),"stop"}}var P8;var LJ=M(()=>{I0();c();E();Q0();q0();P8=class P8{client;#J=!1;#$=!1;#X;#G;#Z;#Q;#B;#Y=0;constructor(J,$,Z){this.client=J;this.#X={params:{...$,messages:structuredClone($.messages)}};let X=H1($.tools,$.messages);if(this.#G={...Z,headers:U([G8("BetaToolRunner"),X.length?{[J2]:X.join(", ")}:void 0,Z?.headers])},this.#B=w2(),$.compactionControl?.enabled)console.warn('Puku: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://puku.sh/docs/')}async#z(){let J=this.#X.params.compactionControl;if(!J||!J.enabled)return!1;let $=0;if(this.#Z!==void 0)try{let z=await this.#Z;$=z.usage.input_tokens+(z.usage.cache_creation_input_tokens??0)+(z.usage.cache_read_input_tokens??0)+z.usage.output_tokens}catch{return!1}let Z=J.contextTokenThreshold??EZ;if($<Z)return!1;let X=J.model??this.#X.params.model,G=J.summaryPrompt??IZ,Q=this.#X.params.messages;if(Q[Q.length-1].role==="assistant"){let z=Q[Q.length-1];if(Array.isArray(z.content)){let B=z.content.filter((K)=>K.type!=="tool_use");if(B.length===0)Q.pop();else z.content=B}}let Y=await this.client.beta.messages.create({model:X,messages:[...Q,{role:"user",content:[{type:"text",text:G}]}],max_tokens:this.#X.params.max_tokens},{signal:this.#G.signal,headers:U([this.#G.headers,G8("compaction")])});if(Y.content[0]?.type!=="text")throw new T("Expected text response for compaction");return this.#X.params.messages=[{role:"user",content:Y.content}],!0}async*[Symbol.asyncIterator](){if(this.#J)throw new T("Cannot iterate over a consumed stream");this.#J=!0,this.#$=!0,this.#Q=void 0;try{while(!0){let J;try{if(this.#X.params.max_iterations&&this.#Y>=this.#X.params.max_iterations)break;this.#$=!1,this.#Q=void 0,this.#Y++,this.#Z=void 0;let{max_iterations:$,compactionControl:Z,...X}=this.#X.params;if(X.stream)J=this.client.beta.messages.stream({...X},this.#G),this.#Z=J.finalMessage(),this.#Z.catch(()=>{}),yield J;else this.#Z=this.client.beta.messages.create({...X,stream:!1},this.#G),yield this.#Z;if(!await this.#z()){if(!this.#$){let Y=await this.#Z,z=ZG(Y.stop_reason);this.#X.params.messages.push({role:Y.role,content:Y.content});let{container:B}=this.#X.params;if(Y.container){if(B==null)this.#X.params.container=Y.container.id;else if(typeof B==="object"&&B.id==null)this.#X.params.container={...B,id:Y.container.id}}if(z==="stop")break;if(z==="resume")continue}let Q=await this.#K(this.#X.params.messages.at(-1));if(Q)this.#X.params.messages.push(Q);else if(!this.#$)break}}finally{if(J)J.abort()}}if(!this.#Z)throw new T("ToolRunner concluded without a message from the server");this.#B.resolve(await this.#Z)}catch(J){throw this.#J=!1,this.#B.promise.catch(()=>{}),this.#B.reject(J),this.#B=w2(),J}}setMessagesParams(J){if(typeof J==="function")this.#X.params=J(this.#X.params);else this.#X.params=J;this.#$=!0,this.#Q=void 0}setRequestOptions(J){if(typeof J==="function")this.#G=J(this.#G);else this.#G={...this.#G,...J}}async generateToolResponse(J=this.#G.signal){let $=await this.#Z??this.params.messages.at(-1);if(!$)return null;return this.#K($,J)}async#K(J,$=this.#G.signal){if(this.#Q!==void 0)return this.#Q;return this.#Q=rX(this.#X.params,J,{...this.#G,signal:$}),this.#Q}done(){return this.#B.promise}async runUntilDone(){if(!this.#J)for await(let J of this);return this.done()}get params(){return this.#X.params}pushMessages(...J){this.setMessagesParams(($)=>({...$,messages:[...$.messages,...J]}))}then(J,$){return this.runUntilDone().then(J,$)}}});function xZ(J){if(!J.output_format)return J;if(J.output_config?.format)throw new T("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:$,...Z}=J;return{...Z,output_config:{...J.output_config,format:$}}}var yZ,XG,c0;var DJ=M(()=>{D2();MJ();m1();E();q0();OJ();_Z();LJ();I0();MJ();LJ();I0();yZ={
|
|
47
|
+
Wrap your summary in <summary></summary> tags.`;async function rX(J,$=J.messages.at(-1),Z){if(!$||$.role!=="assistant"||!$.content||typeof $.content==="string")return null;let X=$.content.filter((Y)=>Y.type==="tool_use");if(X.length===0)return null;let G=sX(J);return{role:"user",content:await Promise.all(X.map(async(Y)=>{let z=J.tools.find((B)=>("name"in B?B.name:("mcp_server_name"in B)?B.mcp_server_name:B.type)===Y.name);if(!z||!("run"in z)||!G.has(Y.name))return tX(Y);try{let B=Y.input;if("parse"in z&&z.parse)B=z.parse(B);let K=await z.run(B,{toolUse:Y,toolUseBlock:Y,signal:Z?.signal});return{type:"tool_result",tool_use_id:Y.id,content:K}}catch(B){return{type:"tool_result",tool_use_id:Y.id,content:B instanceof P?B.content:`Error: ${B instanceof Error?B.message:String(B)}`,is_error:!0}}}))}}function tX(J){return{type:"tool_result",tool_use_id:J.id,content:`Error: Tool '${J.name}' not found`,is_error:!0}}function sX(J){let $=new Set;for(let Z of J.tools)if("run"in Z)$.add(Z.name);for(let Z of J.messages){if(Z.role!=="system"||typeof Z.content==="string")continue;for(let X of Z.content)eX(X,$)}return $}function eX(J,$){switch(J.type){case"tool_removal":case"tool_addition":JG(J,$);break}}function JG(J,$){let Z=$G(J.tool);if(Z===void 0)return;if(J.type==="tool_removal")$.delete(Z);else $.add(Z)}function $G(J){switch(J.type){case"tool_reference":return J.name;default:return}}function ZG(J){if(J===null)return"stop";switch(J){case"tool_use":return"run_tools";case"pause_turn":case"compaction":return"resume";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return x0(J),"stop"}}var P8;var LJ=M(()=>{I0();c();E();Q0();q0();P8=class P8{client;#J=!1;#$=!1;#X;#G;#Z;#Q;#B;#Y=0;constructor(J,$,Z){this.client=J;this.#X={params:{...$,messages:structuredClone($.messages)}};let X=H1($.tools,$.messages);if(this.#G={...Z,headers:U([G8("BetaToolRunner"),X.length?{[J2]:X.join(", ")}:void 0,Z?.headers])},this.#B=w2(),$.compactionControl?.enabled)console.warn('Puku: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://puku.sh/docs/')}async#z(){let J=this.#X.params.compactionControl;if(!J||!J.enabled)return!1;let $=0;if(this.#Z!==void 0)try{let z=await this.#Z;$=z.usage.input_tokens+(z.usage.cache_creation_input_tokens??0)+(z.usage.cache_read_input_tokens??0)+z.usage.output_tokens}catch{return!1}let Z=J.contextTokenThreshold??EZ;if($<Z)return!1;let X=J.model??this.#X.params.model,G=J.summaryPrompt??IZ,Q=this.#X.params.messages;if(Q[Q.length-1].role==="assistant"){let z=Q[Q.length-1];if(Array.isArray(z.content)){let B=z.content.filter((K)=>K.type!=="tool_use");if(B.length===0)Q.pop();else z.content=B}}let Y=await this.client.beta.messages.create({model:X,messages:[...Q,{role:"user",content:[{type:"text",text:G}]}],max_tokens:this.#X.params.max_tokens},{signal:this.#G.signal,headers:U([this.#G.headers,G8("compaction")])});if(Y.content[0]?.type!=="text")throw new T("Expected text response for compaction");return this.#X.params.messages=[{role:"user",content:Y.content}],!0}async*[Symbol.asyncIterator](){if(this.#J)throw new T("Cannot iterate over a consumed stream");this.#J=!0,this.#$=!0,this.#Q=void 0;try{while(!0){let J;try{if(this.#X.params.max_iterations&&this.#Y>=this.#X.params.max_iterations)break;this.#$=!1,this.#Q=void 0,this.#Y++,this.#Z=void 0;let{max_iterations:$,compactionControl:Z,...X}=this.#X.params;if(X.stream)J=this.client.beta.messages.stream({...X},this.#G),this.#Z=J.finalMessage(),this.#Z.catch(()=>{}),yield J;else this.#Z=this.client.beta.messages.create({...X,stream:!1},this.#G),yield this.#Z;if(!await this.#z()){if(!this.#$){let Y=await this.#Z,z=ZG(Y.stop_reason);this.#X.params.messages.push({role:Y.role,content:Y.content});let{container:B}=this.#X.params;if(Y.container){if(B==null)this.#X.params.container=Y.container.id;else if(typeof B==="object"&&B.id==null)this.#X.params.container={...B,id:Y.container.id}}if(z==="stop")break;if(z==="resume")continue}let Q=await this.#K(this.#X.params.messages.at(-1));if(Q)this.#X.params.messages.push(Q);else if(!this.#$)break}}finally{if(J)J.abort()}}if(!this.#Z)throw new T("ToolRunner concluded without a message from the server");this.#B.resolve(await this.#Z)}catch(J){throw this.#J=!1,this.#B.promise.catch(()=>{}),this.#B.reject(J),this.#B=w2(),J}}setMessagesParams(J){if(typeof J==="function")this.#X.params=J(this.#X.params);else this.#X.params=J;this.#$=!0,this.#Q=void 0}setRequestOptions(J){if(typeof J==="function")this.#G=J(this.#G);else this.#G={...this.#G,...J}}async generateToolResponse(J=this.#G.signal){let $=await this.#Z??this.params.messages.at(-1);if(!$)return null;return this.#K($,J)}async#K(J,$=this.#G.signal){if(this.#Q!==void 0)return this.#Q;return this.#Q=rX(this.#X.params,J,{...this.#G,signal:$}),this.#Q}done(){return this.#B.promise}async runUntilDone(){if(!this.#J)for await(let J of this);return this.done()}get params(){return this.#X.params}pushMessages(...J){this.setMessagesParams(($)=>({...$,messages:[...$.messages,...J]}))}then(J,$){return this.runUntilDone().then(J,$)}}});function xZ(J){if(!J.output_format)return J;if(J.output_config?.format)throw new T("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:$,...Z}=J;return{...Z,output_config:{...J.output_config,format:$}}}var yZ,XG,c0;var DJ=M(()=>{D2();MJ();m1();E();q0();OJ();_Z();LJ();I0();MJ();LJ();I0();yZ={},XG=[];c0=class c0 extends w{batches=new L8(this._client);create(J,$){let Z=xZ(J),{betas:X,user_profile_id:G,...Q}=Z;if(Q.model in yZ)console.warn(`The Puku SDK model '${Q.model}' is deprecated and will reach end-of-life on ${yZ[Q.model]}
|
|
48
48
|
Please migrate to a newer model. Visit https://puku.ai/docs/resources/model-deprecations for more information.`);if(XG.includes(Q.model)&&Q.thinking&&Q.thinking.type==="enabled")console.warn(`Using Puku with ${Q.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://puku.ai/docs/en/build-with-puku/adaptive-thinking`);let Y=$?.timeout??this._client._options.timeout;if(!Q.stream&&Y==null){let B=D8[Q.model]??void 0;Y=this._client.calculateNonstreamingTimeout(Q.max_tokens,B)}let z=Q8(Q.tools,Q.messages);return this._client.post("/v1/messages?beta=true",{body:Q,timeout:Y??600000,...$,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0,...G!=null?{"puku-user-profile-id":G}:void 0},z,$?.headers]),stream:Z.stream??!1})}parse(J,$){return $={...$,headers:U([{"puku-beta":[...J.betas??[],"structured-outputs-2025-12-15"].toString()},$?.headers])},this.create(J,$).then((Z)=>wJ(Z,J,{logger:this._client.logger??console}))}stream(J,$){return j8.createMessage(this,J,$)}countTokens(J,$){let Z=xZ(J),{betas:X,user_profile_id:G,...Q}=Z;return this._client.post("/v1/messages/count_tokens?beta=true",{body:Q,...$,headers:U([{"puku-beta":[...X??[],"token-counting-2024-11-01"].toString(),...G!=null?{"puku-user-profile-id":G}:void 0},$?.headers])})}toolRunner(J,$){return new P8(this._client,J,$)}};c0.Batches=L8;c0.BetaToolRunner=P8;c0.ToolError=P});var S8;var jJ=M(()=>{_();I();S8=class S8 extends w{retrieve(J,$){return this._client.get(N`/v1/organizations/api_keys/${J}?beta=true`,$)}update(J,$,Z){return this._client.post(N`/v1/organizations/api_keys/${J}?beta=true`,{body:$,...Z})}list(J={},$){return this._client.getAPIList("/v1/organizations/api_keys?beta=true",o,{query:J,...$})}}});var _8;var PJ=M(()=>{_8=class _8 extends w{retrieve(J){return this._client.get("/v1/organizations/compliance_settings?beta=true",J)}update(J,$){return this._client.post("/v1/organizations/compliance_settings?beta=true",{body:J,...$})}}});var E8;var SJ=M(()=>{_();I();E8=class E8 extends w{create(J,$){return this._client.post("/v1/organizations/external_keys?beta=true",{body:J,...$})}retrieve(J,$){return this._client.get(N`/v1/organizations/external_keys/${J}?beta=true`,$)}update(J,$,Z){return this._client.post(N`/v1/organizations/external_keys/${J}?beta=true`,{body:$,...Z})}list(J={},$){return this._client.getAPIList("/v1/organizations/external_keys?beta=true",L,{query:J,...$})}delete(J,$){return this._client.delete(N`/v1/organizations/external_keys/${J}?beta=true`,$)}validate(J,$){return this._client.post(N`/v1/organizations/external_keys/${J}/validate?beta=true`,$)}}});var I8;var _J=M(()=>{_();I();I8=class I8 extends w{create(J,$){return this._client.post("/v1/organizations/invites?beta=true",{body:J,...$})}retrieve(J,$){return this._client.get(N`/v1/organizations/invites/${J}?beta=true`,$)}list(J={},$){return this._client.getAPIList("/v1/organizations/invites?beta=true",o,{query:J,...$})}delete(J,$){return this._client.delete(N`/v1/organizations/invites/${J}?beta=true`,$)}}});var y8;var EJ=M(()=>{_();y8=class y8 extends w{list(J={},$){return this._client.getAPIList("/v1/organizations/rate_limits?beta=true",L,{query:J,...$})}}});var x8;var IJ=M(()=>{_();I();x8=class x8 extends w{retrieve(J,$){return this._client.get(N`/v1/organizations/users/${J}?beta=true`,$)}update(J,$,Z){return this._client.post(N`/v1/organizations/users/${J}?beta=true`,{body:$,...Z})}list(J={},$){return this._client.getAPIList("/v1/organizations/users?beta=true",o,{query:J,...$})}remove(J,$){return this._client.delete(N`/v1/organizations/users/${J}?beta=true`,$)}}});var k8;var yJ=M(()=>{_();E();I();k8=class k8 extends w{create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/organizations/federation_issuers?beta=true",{body:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/organizations/federation_issuers/${J}?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}update(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/organizations/federation_issuers/${J}?beta=true`,{body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/organizations/federation_issuers?beta=true",L,{query:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}archive(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/organizations/federation_issuers/${J}/archive?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}}});var f8;var xJ=M(()=>{_();E();I();f8=class f8 extends w{list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/organizations/federation_rules/${J}/workspaces?beta=true`,L,{query:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}add(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/organizations/federation_rules/${J}/workspaces?beta=true`,{body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}remove(J,$,Z){let{federation_rule_id:X,betas:G}=$;return this._client.delete(N`/v1/organizations/federation_rules/${X}/workspaces/${J}?beta=true`,{...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}}});var S2;var kJ=M(()=>{xJ();xJ();_();E();I();S2=class S2 extends w{workspaces=new f8(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/organizations/federation_rules?beta=true",{body:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/organizations/federation_rules/${J}?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}update(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/organizations/federation_rules/${J}?beta=true`,{body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/organizations/federation_rules?beta=true",L,{query:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}archive(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/organizations/federation_rules/${J}/archive?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}};S2.Workspaces=f8});var K2;var fJ=M(()=>{yJ();yJ();kJ();kJ();K2=class K2 extends w{issuers=new k8(this._client);rules=new S2(this._client)};K2.Issuers=k8;K2.Rules=S2});var v8;var vJ=M(()=>{_();E();I();v8=class v8 extends w{list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/organizations/service_accounts/${J}/workspaces?beta=true`,L,{query:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}add(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/organizations/service_accounts/${J}/workspaces?beta=true`,{body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}remove(J,$,Z){let{service_account_id:X,betas:G}=$;return this._client.delete(N`/v1/organizations/service_accounts/${X}/workspaces/${J}?beta=true`,{...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}}});var _2;var bJ=M(()=>{vJ();vJ();_();E();I();_2=class _2 extends w{workspaces=new v8(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/organizations/service_accounts?beta=true",{body:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/organizations/service_accounts/${J}?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}update(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/organizations/service_accounts/${J}?beta=true`,{body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/organizations/service_accounts?beta=true",L,{query:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}archive(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/organizations/service_accounts/${J}/archive?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}};_2.Workspaces=v8});var b8;var gJ=M(()=>{_();I();b8=class b8 extends w{retrieve(J,$,Z){let{workspace_id:X}=$;return this._client.get(N`/v1/organizations/workspaces/${X}/members/${J}?beta=true`,Z)}update(J,$,Z){let{workspace_id:X,...G}=$;return this._client.post(N`/v1/organizations/workspaces/${X}/members/${J}?beta=true`,{body:G,...Z})}list(J,$={},Z){return this._client.getAPIList(N`/v1/organizations/workspaces/${J}/members?beta=true`,o,{query:$,...Z})}add(J,$,Z){return this._client.post(N`/v1/organizations/workspaces/${J}/members?beta=true`,{body:$,...Z})}remove(J,$,Z){let{workspace_id:X}=$;return this._client.delete(N`/v1/organizations/workspaces/${X}/members/${J}?beta=true`,Z)}}});var g8;var hJ=M(()=>{_();I();g8=class g8 extends w{list(J,$={},Z){return this._client.getAPIList(N`/v1/organizations/workspaces/${J}/rate_limits?beta=true`,L,{query:$,...Z})}}});var h8;var mJ=M(()=>{_();E();I();h8=class h8 extends w{retrieve(J,$,Z){let{workspace_id:X,betas:G}=$;return this._client.get(N`/v1/organizations/workspaces/${X}/service_accounts/${J}?beta=true`,{...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}update(J,$,Z){let{workspace_id:X,betas:G,...Q}=$;return this._client.post(N`/v1/organizations/workspaces/${X}/service_accounts/${J}?beta=true`,{body:Q,...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/organizations/workspaces/${J}/service_accounts?beta=true`,L,{query:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}add(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/organizations/workspaces/${J}/service_accounts?beta=true`,{body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}remove(J,$,Z){let{workspace_id:X,betas:G}=$;return this._client.delete(N`/v1/organizations/workspaces/${X}/service_accounts/${J}?beta=true`,{...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}}});var p0;var uJ=M(()=>{gJ();gJ();hJ();hJ();mJ();mJ();_();E();I();p0=class p0 extends w{rateLimits=new g8(this._client);members=new b8(this._client);serviceAccounts=new h8(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/organizations/workspaces?beta=true",{body:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}retrieve(J,$){return this._client.get(N`/v1/organizations/workspaces/${J}?beta=true`,$)}update(J,$,Z){return this._client.post(N`/v1/organizations/workspaces/${J}?beta=true`,{body:$,...Z})}list(J={},$){return this._client.getAPIList("/v1/organizations/workspaces?beta=true",o,{query:J,...$})}archive(J,$){return this._client.post(N`/v1/organizations/workspaces/${J}/archive?beta=true`,$)}};p0.RateLimits=g8;p0.Members=b8;p0.ServiceAccounts=h8});var C0;var dJ=M(()=>{jJ();jJ();PJ();PJ();SJ();SJ();_J();_J();EJ();EJ();IJ();IJ();fJ();fJ();bJ();bJ();uJ();uJ();C0=class C0 extends w{apiKeys=new S8(this._client);externalKeys=new E8(this._client);federation=new K2(this._client);invites=new I8(this._client);serviceAccounts=new _2(this._client);users=new x8(this._client);workspaces=new p0(this._client);rateLimits=new y8(this._client);complianceSettings=new _8(this._client);retrieve(J){return this._client.get("/v1/organizations/me?beta=true",J)}};C0.APIKeys=S8;C0.ExternalKeys=E8;C0.Federation=K2;C0.Invites=I8;C0.ServiceAccounts=_2;C0.Users=x8;C0.Workspaces=p0;C0.RateLimits=y8;C0.ComplianceSettings=_8});var E2;var cJ=M(()=>{_();E();I();E1();E1();E2=class E2 extends w{list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/sessions/${J}/events?beta=true`,L,{query:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}send(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/sessions/${J}/events?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}stream(J,$={},Z){let{betas:X,...G}=$??{};return this._client.get(N`/v1/sessions/${J}/events/stream?beta=true`,{query:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers]),stream:!0})}toolRunner(J,$){return new Z2(J,{...$,client:this._client})}};E2.SessionToolRunner=Z2});var m8;var pJ=M(()=>{_();E();I();m8=class m8 extends w{retrieve(J,$,Z){let{session_id:X,betas:G}=$;return this._client.get(N`/v1/sessions/${X}/resources/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}update(J,$,Z){let{session_id:X,betas:G,...Q}=$;return this._client.post(N`/v1/sessions/${X}/resources/${J}?beta=true`,{body:Q,...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/sessions/${J}/resources?beta=true`,L,{query:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete(J,$,Z){let{session_id:X,betas:G}=$;return this._client.delete(N`/v1/sessions/${X}/resources/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}add(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/sessions/${J}/resources?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}}});var u8;var lJ=M(()=>{_();E();I();u8=class u8 extends w{list(J,$,Z){let{session_id:X,betas:G,...Q}=$;return this._client.getAPIList(N`/v1/sessions/${X}/threads/${J}/events?beta=true`,L,{query:Q,...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}stream(J,$,Z){let{session_id:X,betas:G,...Q}=$;return this._client.get(N`/v1/sessions/${X}/threads/${J}/stream?beta=true`,{query:Q,...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers]),stream:!0})}}});var I2;var iJ=M(()=>{lJ();lJ();_();E();I();I2=class I2 extends w{events=new u8(this._client);retrieve(J,$,Z){let{session_id:X,betas:G}=$;return this._client.get(N`/v1/sessions/${X}/threads/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/sessions/${J}/threads?beta=true`,L,{query:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}archive(J,$,Z){let{session_id:X,betas:G}=$;return this._client.post(N`/v1/sessions/${X}/threads/${J}/archive?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}};I2.Events=u8});var l0;var nJ=M(()=>{cJ();cJ();pJ();pJ();iJ();iJ();_();E();I();l0=class l0 extends w{events=new E2(this._client);resources=new m8(this._client);threads=new I2(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/sessions?beta=true",{body:X,...$,headers:U([{"puku-beta":[...Z??[],"managed-agents-2026-04-01"].toString()},$?.headers])})}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/sessions/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}update(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/sessions/${J}?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/sessions?beta=true",H6,{query:X,...$,headers:U([{"puku-beta":[...Z??[],"managed-agents-2026-04-01"].toString()},$?.headers])})}delete(J,$={},Z){let{betas:X}=$??{};return this._client.delete(N`/v1/sessions/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}archive(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/sessions/${J}/archive?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}};l0.Events=E2;l0.Resources=m8;l0.Threads=I2});var d8;var aJ=M(()=>{_();E();E0();I();d8=class d8 extends w{create(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/skills/${J}/versions?beta=true`,F0({body:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])},this._client,!1))}retrieve(J,$,Z){let{skill_id:X,betas:G}=$;return this._client.get(N`/v1/skills/${X}/versions/${J}?beta=true`,{...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/skills/${J}/versions?beta=true`,L,{query:G,...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}delete(J,$,Z){let{skill_id:X,betas:G}=$;return this._client.delete(N`/v1/skills/${X}/versions/${J}?beta=true`,{...Z,headers:U([{...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers])})}download(J,$,Z){let{skill_id:X,betas:G}=$;return this._client.get(N`/v1/skills/${X}/versions/${J}/content?beta=true`,{...Z,headers:U([{Accept:"application/binary",...G?.toString()!=null?{"puku-beta":G?.toString()}:void 0},Z?.headers]),__binaryResponse:!0})}}});var y2;var oJ=M(()=>{aJ();aJ();_();E();E0();I();y2=class y2 extends w{versions=new d8(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/skills?beta=true",F0({body:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])},this._client,!1))}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/skills/${J}?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/skills?beta=true",L,{query:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}delete(J,$={},Z){let{betas:X}=$??{};return this._client.delete(N`/v1/skills/${J}?beta=true`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}};y2.Versions=d8});var c8;var rJ=M(()=>{_();E();I();c8=class c8 extends w{create(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/tunnels/${J}/certificates?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}retrieve(J,$,Z){let{tunnel_id:X,betas:G}=$;return this._client.get(N`/v1/tunnels/${X}/certificates/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/tunnels/${J}/certificates?beta=true`,L,{query:G,...Z,headers:U([{"puku-beta":[...X??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}archive(J,$,Z){let{tunnel_id:X,betas:G}=$;return this._client.post(N`/v1/tunnels/${X}/certificates/${J}/archive?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}}});var x2;var tJ=M(()=>{rJ();rJ();_();E();I();x2=class x2 extends w{certificates=new c8(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/tunnels?beta=true",{body:X,...$,headers:U([{"puku-beta":[...Z??[],"mcp-tunnels-2026-06-22"].toString()},$?.headers])})}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/tunnels/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/tunnels?beta=true",L,{query:X,...$,headers:U([{"puku-beta":[...Z??[],"mcp-tunnels-2026-06-22"].toString()},$?.headers])})}archive(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/tunnels/${J}/archive?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}revealToken(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/tunnels/${J}/reveal_token?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}rotateToken(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/tunnels/${J}/rotate_token?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"mcp-tunnels-2026-06-22"].toString()},Z?.headers])})}};x2.Certificates=c8});var p8;var sJ=M(()=>{_();E();I();p8=class p8 extends w{create(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/vaults/${J}/credentials?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve(J,$,Z){let{vault_id:X,betas:G}=$;return this._client.get(N`/v1/vaults/${X}/credentials/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}update(J,$,Z){let{vault_id:X,betas:G,...Q}=$;return this._client.post(N`/v1/vaults/${X}/credentials/${J}?beta=true`,{body:Q,...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}list(J,$={},Z){let{betas:X,...G}=$??{};return this._client.getAPIList(N`/v1/vaults/${J}/credentials?beta=true`,L,{query:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete(J,$,Z){let{vault_id:X,betas:G}=$;return this._client.delete(N`/v1/vaults/${X}/credentials/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}archive(J,$,Z){let{vault_id:X,betas:G}=$;return this._client.post(N`/v1/vaults/${X}/credentials/${J}/archive?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}mcpOAuthValidate(J,$,Z){let{vault_id:X,betas:G}=$;return this._client.post(N`/v1/vaults/${X}/credentials/${J}/mcp_oauth_validate?beta=true`,{...Z,headers:U([{"puku-beta":[...G??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}}});var k2;var eJ=M(()=>{sJ();sJ();_();E();I();k2=class k2 extends w{credentials=new p8(this._client);create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/vaults?beta=true",{body:X,...$,headers:U([{"puku-beta":[...Z??[],"managed-agents-2026-04-01"].toString()},$?.headers])})}retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/vaults/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}update(J,$,Z){let{betas:X,...G}=$;return this._client.post(N`/v1/vaults/${J}?beta=true`,{body:G,...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/vaults?beta=true",L,{query:X,...$,headers:U([{"puku-beta":[...Z??[],"managed-agents-2026-04-01"].toString()},$?.headers])})}delete(J,$={},Z){let{betas:X}=$??{};return this._client.delete(N`/v1/vaults/${J}?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}archive(J,$={},Z){let{betas:X}=$??{};return this._client.post(N`/v1/vaults/${J}/archive?beta=true`,{...Z,headers:U([{"puku-beta":[...X??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}};k2.Credentials=p8});var i;var J4=M(()=>{E6();E6();I6();I6();y6();y6();x6();x6();k6();k6();f6();f6();g6();g6();m6();m6();CJ();CJ();FJ();FJ();DJ();DJ();dJ();dJ();nJ();nJ();oJ();oJ();tJ();tJ();eJ();eJ();i=class i extends w{models=new z8(this._client);messages=new c0(this._client);agents=new M2(this._client);environments=new L2(this._client);sessions=new l0(this._client);deployments=new Z8(this._client);deploymentRuns=new $8(this._client);vaults=new k2(this._client);memoryStores=new B2(this._client);files=new Y8(this._client);skills=new y2(this._client);webhooks=new V8(this._client);userProfiles=new B8(this._client);dreams=new X8(this._client);tunnels=new x2(this._client);organization=new C0(this._client)};i.Models=z8;i.Messages=c0;i.Agents=M2;i.Environments=L2;i.Sessions=l0;i.Deployments=Z8;i.DeploymentRuns=$8;i.Vaults=k2;i.MemoryStores=B2;i.Files=Y8;i.Skills=y2;i.Webhooks=V8;i.UserProfiles=B8;i.Dreams=X8;i.Tunnels=x2;i.Organization=C0});var f2;var $4=M(()=>{E();f2=class f2 extends w{create(J,$){let{betas:Z,...X}=J;return this._client.post("/v1/complete",{body:X,timeout:this._client._options.timeout??600000,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers]),stream:J.stream??!1})}}});var v2;var Z4=M(()=>{_();E();q0();E0();I();v2=class v2 extends w{list(J={},$){return this._client.getAPIList("/v1/files",L,{query:J,...$})}delete(J,$){return this._client.delete(N`/v1/files/${J}`,$)}download(J,$){return this._client.get(N`/v1/files/${J}/content`,{...$,headers:U([{Accept:"application/binary"},$?.headers]),__binaryResponse:!0})}retrieveMetadata(J,$){return this._client.get(N`/v1/files/${J}`,$)}upload(J,$){return this._client.post("/v1/files",F0({body:J,...$,headers:U([L1(J.file),$?.headers])},this._client))}}});function kZ(J){return J?.output_config?.format}function X4(J,$,Z){let X=kZ($);if(!$||!("parse"in(X??{})))return{...J,content:J.content.map((G)=>{if(G.type==="text")return Object.defineProperty({...G},"parsed_output",{value:null,enumerable:!1});return G}),parsed_output:null};return G4(J,$,Z)}function G4(J,$,Z){let X=null,G=J.content.map((Q)=>{if(Q.type==="text"){let Y=xG($,Q.text);if(X===null)X=Y;return Object.defineProperty({...Q},"parsed_output",{value:Y,enumerable:!1})}return Q});return{...J,content:G,parsed_output:X}}function xG(J,$){let Z=kZ(J);if(Z?.type!=="json_schema")return null;try{if("parse"in Z)return Z.parse($);return JSON.parse($)}catch(X){throw new T(`Failed to parse structured output: ${X}`)}}var Q4=M(()=>{c()});function Y4(J){return J.type==="tool_use"||J.type==="server_tool_use"}var l8;var fZ=M(()=>{q0();Q0();D2();RJ();Q4();AJ();l8=class l8{messages=[];receivedMessages=[];#J;#$=null;controller=new AbortController;#X;#G=()=>{};#Z=()=>{};#Q;#B=()=>{};#Y=()=>{};#z={};#K=!1;#C=!1;#U=!1;#V=!1;#F;#W;#M;#q;constructor(J,$){this.#X=new Promise((Z,X)=>{this.#G=Z,this.#Z=X}),this.#Q=new Promise((Z,X)=>{this.#B=Z,this.#Y=X}),this.#X.catch(()=>{}),this.#Q.catch(()=>{}),this.#$=J,this.#q=$?.logger??console}get response(){return this.#F}get request_id(){return this.#W}get workspace_id(){return this.#M}async withResponse(){this.#V=!0;let J=await this.#X;if(!J)throw Error("Could not resolve a `Response` object");return{data:this,response:J,request_id:J.headers.get("request-id"),workspace_id:J.headers.get("puku-workspace-id")}}static fromReadableStream(J){let $=new l8(null);return $._run(()=>$._fromReadableStream(J)),$}static createMessage(J,$,Z,{logger:X}={}){let G=new l8($,{logger:X});for(let Q of $.messages)G._addMessageParam(Q);return G.#$={...$,stream:!0},G._run(()=>G._createMessage(J,{...$,stream:!0},{...Z,headers:{...Z?.headers,[A1]:"stream"}})),G}_run(J){J().then(()=>{this._emitFinal(),this._emit("end")},this.#T)}_addMessageParam(J){this.messages.push(J)}_addMessage(J,$=!0){if(this.receivedMessages.push(J),$)this._emit("message",J)}async _createMessage(J,$,Z){let X=Z?.signal,G;if(X){if(X.aborted)this.controller.abort();G=this.controller.abort.bind(this.controller),X.addEventListener("abort",G)}try{this.#N();let{response:Q,data:Y}=await J.create({...$,stream:!0},{...Z,signal:this.controller.signal}).withResponse();this._connected(Q);for await(let z of Y)this.#R(z);if(Y.controller.signal?.aborted)throw new Z0;this.#w()}finally{if(X&&G)X.removeEventListener("abort",G)}}_connected(J){if(this.ended)return;this.#F=J,this.#W=J?.headers.get("request-id"),this.#M=J?.headers.get("puku-workspace-id"),this.#G(J),this._emit("connect")}get ended(){return this.#K}get errored(){return this.#C}get aborted(){return this.#U}abort(){this.controller.abort()}on(J,$){return(this.#z[J]||(this.#z[J]=[])).push({listener:$}),this}off(J,$){let Z=this.#z[J];if(!Z)return this;let X=Z.findIndex((G)=>G.listener===$);if(X>=0)Z.splice(X,1);return this}once(J,$){return(this.#z[J]||(this.#z[J]=[])).push({listener:$,once:!0}),this}emitted(J){return new Promise(($,Z)=>{if(this.#V=!0,J!=="error")this.once("error",Z);this.once(J,$)})}async done(){this.#V=!0,await this.#Q}get currentMessage(){return this.#J}#O(){if(this.receivedMessages.length===0)throw new T("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)}async finalMessage(){return await this.done(),this.#O()}#A(){if(this.receivedMessages.length===0)throw new T("stream ended without producing a Message with role=assistant");let J=this.receivedMessages.at(-1).content.filter(($)=>$.type==="text").map(($)=>$.text);if(J.length===0)throw new T("stream ended without producing a content block with type=text");return J.join(" ")}async finalText(){return await this.done(),this.#A()}#T=(J)=>{if(this.#C=!0,U0(J))J=new Z0;if(J instanceof Z0)return this.#U=!0,this._emit("abort",J);if(J instanceof T)return this._emit("error",J);if(J instanceof Error){let $=new T(J.message);return $.cause=J,this._emit("error",$)}return this._emit("error",new T(String(J)))};_emit(J,...$){if(this.#K)return;if(J==="end")this.#K=!0,this.#B();let Z=this.#z[J];if(Z)this.#z[J]=Z.filter((X)=>!X.once),Z.forEach(({listener:X})=>X(...$));if(J==="abort"){let X=$[0];if(!this.#V&&!Z?.length)Promise.reject(X);this.#Z(X),this.#Y(X),this._emit("end");return}if(J==="error"){let X=$[0];if(!this.#V&&!Z?.length)Promise.reject(X);this.#Z(X),this.#Y(X),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",this.#O())}#N(){if(this.ended)return;this.#J=void 0}#R(J){if(this.ended)return;let $=this.#H(J);switch(this._emit("streamEvent",J,$),J.type){case"content_block_delta":{let Z=$.content.at(-1);switch(J.delta.type){case"text_delta":{if(Z.type==="text")this._emit("text",J.delta.text,Z.text||"");break}case"citations_delta":{if(Z.type==="text")this._emit("citation",J.delta.citation,Z.citations??[]);break}case"input_json_delta":{if(Y4(Z)&&this.#z.inputJson?.length)this._emit("inputJson",J.delta.partial_json,Z.input);break}case"thinking_delta":{if(Z.type==="thinking")this._emit("thinking",J.delta.thinking,Z.thinking);break}case"signature_delta":{if(Z.type==="thinking")this._emit("signature",Z.signature);break}default:x0(J.delta)}break}case"message_stop":{this._addMessageParam($),this._addMessage(X4($,this.#$,{logger:this.#q}),!0);break}case"content_block_stop":{this._emit("contentBlock",$.content.at(-1));break}case"message_start":{this.#J=$;break}case"content_block_start":case"message_delta":break}}#w(){if(this.ended)throw new T("stream has ended, this shouldn't happen");let J=this.#J;if(!J)throw new T("request ended without sending any chunks");return this.#J=void 0,X4(J,this.#$,{logger:this.#q})}async _fromReadableStream(J,$){let Z=$?.signal,X;if(Z){if(Z.aborted)this.controller.abort();X=this.controller.abort.bind(this.controller),Z.addEventListener("abort",X)}try{this.#N(),this._connected(null);let G=s.fromReadableStream(J,this.controller);for await(let Q of G)this.#R(Q);if(G.controller.signal?.aborted)throw new Z0;this.#w()}finally{if(Z&&X)Z.removeEventListener("abort",X)}}#H(J){let $=this.#J;if(J.type==="message_start"){if($)throw new T(`Unexpected event order, got ${J.type} before receiving "message_stop"`);return J.message}if(!$)throw new T(`Unexpected event order, got ${J.type} before "message_start"`);switch(J.type){case"message_stop":return $;case"message_delta":if($.stop_reason=J.delta.stop_reason,$.stop_sequence=J.delta.stop_sequence,$.stop_details=J.delta.stop_details,$.usage.output_tokens=J.usage.output_tokens,J.delta.container!=null)$.container=J.delta.container;if(J.usage.input_tokens!=null)$.usage.input_tokens=J.usage.input_tokens;if(J.usage.cache_creation_input_tokens!=null)$.usage.cache_creation_input_tokens=J.usage.cache_creation_input_tokens;if(J.usage.cache_read_input_tokens!=null)$.usage.cache_read_input_tokens=J.usage.cache_read_input_tokens;if(J.usage.server_tool_use!=null)$.usage.server_tool_use=J.usage.server_tool_use;if(J.usage.output_tokens_details!=null)$.usage.output_tokens_details=J.usage.output_tokens_details;return $;case"content_block_start":return $.content.push({...J.content_block}),$;case"content_block_delta":{let Z=$.content.at(J.index);switch(J.delta.type){case"text_delta":{if(Z?.type==="text")$.content[J.index]={...Z,text:(Z.text||"")+J.delta.text};break}case"citations_delta":{if(Z?.type==="text")$.content[J.index]={...Z,citations:[...Z.citations??[],J.delta.citation]};break}case"input_json_delta":{if(Z&&Y4(Z)){let X=(Z[d0]||"")+J.delta.partial_json;$.content[J.index]=u1(Z,X)}break}case"thinking_delta":{if(Z?.type==="thinking")$.content[J.index]={...Z,thinking:Z.thinking+J.delta.thinking};break}case"signature_delta":{if(Z?.type==="thinking")$.content[J.index]={...Z,signature:J.delta.signature};break}default:x0(J.delta)}return $}case"content_block_stop":{let Z=$.content.at(J.index);if(Z&&Y4(Z)&&d0 in Z)Object.defineProperty(Z,"input",{value:Z.input,enumerable:!0,configurable:!0,writable:!0});return $}}}[Symbol.asyncIterator](){let J=[],$=[],Z=!1;return this.on("streamEvent",(X)=>{let G=$.shift();if(G)G.resolve(X);else J.push(X)}),this.on("end",()=>{Z=!0;for(let X of $)X.resolve(void 0);$.length=0}),this.on("abort",(X)=>{Z=!0;for(let G of $)G.reject(X);$.length=0}),this.on("error",(X)=>{Z=!0;for(let G of $)G.reject(X);$.length=0}),{next:async()=>{if(!J.length){if(Z)return{value:void 0,done:!0};return new Promise((G,Q)=>$.push({resolve:G,reject:Q})).then((G)=>G?{value:G,done:!1}:{value:void 0,done:!0})}return{value:J.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new s(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var i8;var z4=M(()=>{_();E();qJ();D2();I();i8=class i8 extends w{create(J,$){let{user_profile_id:Z,...X}=J;return this._client.post("/v1/messages/batches",{body:X,...$,headers:U([{...Z!=null?{"puku-user-profile-id":Z}:void 0},$?.headers])})}retrieve(J,$){return this._client.get(N`/v1/messages/batches/${J}`,$)}list(J={},$){return this._client.getAPIList("/v1/messages/batches",o,{query:J,...$})}delete(J,$){return this._client.delete(N`/v1/messages/batches/${J}`,$)}cancel(J,$){return this._client.post(N`/v1/messages/batches/${J}/cancel`,$)}async results(J,$){let Z=await this.retrieve(J);if(!Z.results_url)throw new T(`No batch \`results_url\`; Has it finished processing? ${Z.processing_status} - ${Z.id}`);return this._client.get(Z.results_url,{...$,headers:U([{Accept:"application/binary"},$?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((X,G)=>j2.fromResponse(G.response,G.controller))}}});var W2,vZ,fG;var B4=M(()=>{E();q0();fZ();Q4();z4();z4();m1();W2=class W2 extends w{batches=new i8(this._client);create(J,$){let{user_profile_id:Z,...X}=J;if(X.model in vZ)console.warn(`The Puku SDK model '${X.model}' is deprecated and will reach end-of-life on ${vZ[X.model]}
|
|
49
|
-
Please migrate to a newer model. Visit https://puku.ai/docs/resources/model-deprecations for more information.`);if(fG.includes(X.model)&&X.thinking&&X.thinking.type==="enabled")console.warn(`Using Puku with ${X.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://puku.ai/docs/en/build-with-puku/adaptive-thinking`);let G=$?.timeout??this._client._options.timeout;if(!X.stream&&G==null){let Y=D8[X.model]??void 0;G=this._client.calculateNonstreamingTimeout(X.max_tokens,Y)}let Q=Q8(X.tools,X.messages);return this._client.post("/v1/messages",{body:X,timeout:G??600000,...$,headers:U([{...Z!=null?{"puku-user-profile-id":Z}:void 0},Q,$?.headers]),stream:J.stream??!1})}parse(J,$){return this.create(J,$).then((Z)=>G4(Z,J,{logger:this._client.logger??console}))}stream(J,$){return l8.createMessage(this,J,$,{logger:this._client.logger??console})}countTokens(J,$){let{user_profile_id:Z,...X}=J;return this._client.post("/v1/messages/count_tokens",{body:X,...$,headers:U([{...Z!=null?{"puku-user-profile-id":Z}:void 0},$?.headers])})}};vZ={
|
|
49
|
+
Please migrate to a newer model. Visit https://puku.ai/docs/resources/model-deprecations for more information.`);if(fG.includes(X.model)&&X.thinking&&X.thinking.type==="enabled")console.warn(`Using Puku with ${X.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://puku.ai/docs/en/build-with-puku/adaptive-thinking`);let G=$?.timeout??this._client._options.timeout;if(!X.stream&&G==null){let Y=D8[X.model]??void 0;G=this._client.calculateNonstreamingTimeout(X.max_tokens,Y)}let Q=Q8(X.tools,X.messages);return this._client.post("/v1/messages",{body:X,timeout:G??600000,...$,headers:U([{...Z!=null?{"puku-user-profile-id":Z}:void 0},Q,$?.headers]),stream:J.stream??!1})}parse(J,$){return this.create(J,$).then((Z)=>G4(Z,J,{logger:this._client.logger??console}))}stream(J,$){return l8.createMessage(this,J,$,{logger:this._client.logger??console})}countTokens(J,$){let{user_profile_id:Z,...X}=J;return this._client.post("/v1/messages/count_tokens",{body:X,...$,headers:U([{...Z!=null?{"puku-user-profile-id":Z}:void 0},$?.headers])})}};vZ={},fG=[];W2.Batches=i8});var b2;var K4=M(()=>{_();E();I();b2=class b2 extends w{retrieve(J,$={},Z){let{betas:X}=$??{};return this._client.get(N`/v1/models/${J}`,{...Z,headers:U([{...X?.toString()!=null?{"puku-beta":X?.toString()}:void 0},Z?.headers])})}list(J={},$){let{betas:Z,...X}=J??{};return this._client.getAPIList("/v1/models",o,{query:X,...$,headers:U([{...Z?.toString()!=null?{"puku-beta":Z?.toString()}:void 0},$?.headers])})}}});var n8;var W4=M(()=>{_();E0();I();n8=class n8 extends w{create(J,$,Z){return this._client.post(N`/v1/skills/${J}/versions`,F0({body:$,...Z},this._client,!1))}retrieve(J,$,Z){let{skill_id:X}=$;return this._client.get(N`/v1/skills/${X}/versions/${J}`,Z)}list(J,$={},Z){return this._client.getAPIList(N`/v1/skills/${J}/versions`,L,{query:$,...Z})}delete(J,$,Z){let{skill_id:X}=$;return this._client.delete(N`/v1/skills/${X}/versions/${J}`,Z)}}});var V2;var V4=M(()=>{W4();W4();_();E0();I();V2=class V2 extends w{versions=new n8(this._client);create(J,$){return this._client.post("/v1/skills",F0({body:J,...$},this._client,!1))}retrieve(J,$){return this._client.get(N`/v1/skills/${J}`,$)}list(J={},$){return this._client.getAPIList("/v1/skills",L,{query:J,...$})}delete(J,$){return this._client.delete(N`/v1/skills/${J}`,$)}};V2.Versions=n8});var bZ=M(()=>{J4();$4();Z4();B4();K4();V4()});var gZ="\\n\\nHuman:",hZ="\\n\\nAssistant:",d1,P0;var C4=M(()=>{Q0();s8();J1();z6();c();r0();o4();U$();O$();_();S6();bZ();q1();$4();Z4();K4();J4();B4();V4();s8();E();O0();Q0();d1=class d1{apiKey;authToken;webhookKey;get credentials(){return this._authState.provider}_authState;_baseURLIsExplicit;_requestAuthFlags=new WeakMap;baseURL;maxRetries;timeout;logger;logLevel;fetchOptions;middleware;fetch;#J;idempotencyHeader;_options;constructor({baseURL:J=x("PUKU_BASE_URL"),apiKey:$,authToken:Z,webhookKey:X=x("PUKU_WEBHOOK_SIGNING_KEY")??null,...G}={}){if($===void 0)$=G.profile!=null?null:x("PUKU_API_KEY")??null;if(Z===void 0)Z=G.profile!=null?null:x("PUKU_AUTH_TOKEN")??null;if(G.profile!=null&&(G.credentials!=null||G.config!=null))throw TypeError("Pass at most one of `profile`, `credentials`, or `config`.");let Q={apiKey:$,authToken:Z,webhookKey:X,...G,baseURL:J||""};if(!Q.baseURL)throw new T("Missing baseURL: pass `baseURL` to the constructor or set the PUKU_BASE_URL environment variable.");if(!Q.dangerouslyAllowBrowser&&P4())throw new T(`It looks like you're running in a browser-like environment.
|
|
50
50
|
|
|
51
51
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
52
52
|
If you understand the risks and have appropriate mitigations in place,
|
|
@@ -65,4 +65,4 @@ new PukuAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
65
65
|
|
|
66
66
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let Y of J.seen.entries()){let z=Y[1];if($===Y[0]){Q(Y);continue}if(J.external){let K=J.external.registry.get(Y[0])?.id;if($!==Y[0]&&K){Q(Y);continue}}if(J.metadataRegistry.get(Y[0])?.id){Q(Y);continue}if(z.cycle){Q(Y);continue}if(z.count>1){if(J.reused==="ref"){Q(Y);continue}}}if(J.external)J.sharedDefsExtractedFor=J.external}function Q9(J){let $=J.anyOf;if(!Array.isArray($)||$.length===0||J.type!==void 0)return;let Z=[];for(let X of $){if(!X||typeof X!=="object")return;Q9(X);let G=Object.keys(X);if(G.length!==1||G[0]!=="type")return;let Q=X.type;for(let Y of Array.isArray(Q)?Q:[Q]){if(typeof Y!=="string")return;if(!Z.includes(Y))Z.push(Y)}}delete J.anyOf,J.type=Z.length===1?Z[0]:Z}var Y9=new Set(["type","properties","required","additionalProperties"]),Z9=["oneOf","anyOf"];function X9(J){let $=J.additionalProperties;if($===void 0||$===!1||typeof $!=="object"||$===null)return null;return Object.keys($).length?$:null}function F4(J){let $=[];for(let Q of J){if(typeof Q!=="object"||Q.type!=="object")return null;for(let Y in Q)if(!Y9.has(Y))return null;$.push(Q)}let Z={},X=new Set;for(let Q of $){for(let Y in Q.properties){if(Object.prototype.hasOwnProperty.call(Z,Y))continue;let z=[];for(let K of $){let W=K.properties?.[Y]??X9(K);if(W===null||W===void 0)continue;if(!z.some((C)=>JSON.stringify(C)===JSON.stringify(W)))z.push(W)}let B=z.length===1?z[0]:F4(z)??{allOf:z};i0(Z,Y,B)}for(let Y of Q.required??[])X.add(Y)}let G={type:"object",properties:Z};if(X.size)G.required=[...X];if($.every((Q)=>Q.additionalProperties===!1))G.additionalProperties=!1;else{let Q=[];for(let Y of $){let z=X9(Y);if(z&&!Q.some((B)=>JSON.stringify(B)===JSON.stringify(z)))Q.push(z)}if(Q.length===1)G.additionalProperties=Q[0];else if(Q.length>1)G.additionalProperties={allOf:Q}}return G}function rG(J){let $=J.allOf;if(!Array.isArray($)||$.length<2)return;for(let G of Y9)if(G in J)return;let Z=$.filter((G)=>Z9.some((Q)=>Array.isArray(G[Q]))),X=null;if(!Z.length)X=F4($);else{let G=Z[0],Q=Z9.find((B)=>Array.isArray(G[B]));if(Object.keys(G).length!==1)return;let Y=$.filter((B)=>B!==G),z=G[Q].map((B)=>F4([...Y,B]));if(z.some((B)=>!B))return;X={[Q]:z}}if(!X)return;delete J.allOf,a8(J,X)}function l1(J,$){let Z=J.seen.get($);if(!Z)throw Error("Unprocessed schema. This is a bug in Zod.");let X=(z)=>{let B=J.seen.get(z);if(B.ref===null)return;let K=B.def??B.schema,W={...K},C=B.ref;if(B.ref=null,C){X(C);let F=J.seen.get(C),q=F.schema;if(q.$ref&&(J.target==="draft-07"||J.target==="draft-04"||J.target==="openapi-3.0"))K.allOf=K.allOf??[],K.allOf.push(q);else a8(K,q);if(a8(K,W),z._zod.parent===C)for(let R in K){if(R==="$ref"||R==="allOf")continue;if(!(R in W))delete K[R]}if(q.$ref&&F.def)for(let R in K){if(R==="$ref"||R==="allOf")continue;if(R in F.def&&JSON.stringify(K[R])===JSON.stringify(F.def[R]))delete K[R]}}let V=z._zod.parent;if(V&&V!==C){X(V);let F=J.seen.get(V);if(F?.schema.$ref){if(K.$ref=F.schema.$ref,F.def)for(let q in K){if(q==="$ref"||q==="allOf")continue;if(q in F.def&&JSON.stringify(K[q])===JSON.stringify(F.def[q]))delete K[q]}}}J.override({zodSchema:z,jsonSchema:K,path:B.path??[]})};if(!J.external||J.sharedEmitDoneFor!==J.external){for(let z of[...J.seen.entries()].reverse())X(z[0]);if(J.target!=="openapi-3.0")for(let z of J.seen.entries())Q9(z[1].def??z[1].schema);for(let z of J.deferred)z();if(J.intersections.length){let z=new Map;for(let B of J.seen.values())for(let K of[B.schema,B.def]){let W=K?.allOf;if(!Array.isArray(W))continue;let C=z.get(W);if(C)C.push(K);else z.set(W,[K])}for(let B of J.intersections)for(let K of z.get(B)??[])rG(K)}}let G={};if(J.target==="draft-2020-12")G.$schema="https://json-schema.org/draft/2020-12/schema";else if(J.target==="draft-07")G.$schema="http://json-schema.org/draft-07/schema#";else if(J.target==="draft-04")G.$schema="http://json-schema.org/draft-04/schema#";else if(J.target==="openapi-3.0");if(J.external?.uri){let z=J.external.registry.get($)?.id;if(!z)throw Error("Schema is missing an `id` property");G.$id=J.external.uri(z)}a8(G,Z.defId?Z.schema:Z.def??Z.schema);let Q=J.metadataRegistry.get($)?.id;if(Q!==void 0&&G.id===Q)delete G.id;let Y=J.external?.defs??{};if(!J.external||J.sharedEmitDoneFor!==J.external)for(let z of J.seen.entries()){let B=z[1];if(B.def&&B.defId){if(B.def.id===B.defId)delete B.def.id;i0(Y,B.defId,B.def)}}if(J.external)J.sharedEmitDoneFor=J.external;if(J.external);else if(Object.keys(Y).length>0)if(J.target==="draft-2020-12")G.$defs=Y;else G.definitions=Y;try{let z=JSON.parse(JSON.stringify(G));return Object.defineProperty(z,"~standard",{value:{...$["~standard"],jsonSchema:{input:G9($,"input",J.processors),output:G9($,"output",J.processors)}},enumerable:!1,writable:!1}),z}catch(z){throw Error("Error converting schema to JSON.")}}function z0(J,$){let Z=$??{seen:new Set};if(Z.seen.has(J))return!1;Z.seen.add(J);let X=J._zod.def;if(X.type==="transform")return!0;if(X.type==="array")return z0(X.element,Z);if(X.type==="set")return z0(X.valueType,Z);if(X.type==="lazy")return z0(X.getter(),Z);if(X.type==="promise"||X.type==="optional"||X.type==="nonoptional"||X.type==="nullable"||X.type==="readonly"||X.type==="default"||X.type==="prefault"||X.type==="catch")return z0(X.innerType,Z);if(X.type==="intersection")return z0(X.left,Z)||z0(X.right,Z);if(X.type==="record"||X.type==="map")return z0(X.keyType,Z)||z0(X.valueType,Z);if(X.type==="pipe"){if(J._zod.traits.has("$ZodCodec"))return!0;return z0(X.in,Z)||z0(X.out,Z)}if(X.type==="object"){for(let G in X.shape)if(z0(X.shape[G],Z))return!0;return!1}if(X.type==="union"){for(let G of X.options)if(z0(G,Z))return!0;return!1}if(X.type==="tuple"){for(let G of X.items)if(z0(G,Z))return!0;if(X.rest&&z0(X.rest,Z))return!0;return!1}return!1}var G9=(J,$,Z={})=>(X)=>{let{libraryOptions:G,target:Q}=X??{},Y=c1({...G??{},target:Q,io:$,processors:Z});return p(J,Y),p1(Y,J),l1(Y,J)};var tG={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sG=(J,$,Z,X)=>{let G=Z;G.type="string";let{minimum:Q,maximum:Y,format:z,patterns:B,contentEncoding:K,laxFormat:W}=J._zod.bag;if(typeof Q==="number")G.minLength=Q;if(typeof Y==="number")G.maxLength=Y;if(z){if(G.format=tG[z]??z,G.format==="")delete G.format;if(z==="time"||W)delete G.format}if(K)G.contentEncoding=K;if(B&&B.size>0){let C=[...B];if(C.length===1)G.pattern=C[0].source;else if(C.length>1)G.allOf=[...C.map((V)=>({...$.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"?{type:"string"}:{},pattern:V.source}))]}},eG=(J,$,Z,X)=>{let G=Z,{minimum:Q,maximum:Y,format:z,multipleOf:B,exclusiveMaximum:K,exclusiveMinimum:W}=J._zod.bag;if(typeof z==="string"&&z.includes("int"))G.type="integer";else G.type="number";let C=typeof W==="number"&&W>=(Q??Number.NEGATIVE_INFINITY),V=typeof K==="number"&&K<=(Y??Number.POSITIVE_INFINITY),F=$.target==="draft-04"||$.target==="openapi-3.0";if(C)if(F)G.minimum=W,G.exclusiveMinimum=!0;else G.exclusiveMinimum=W;else if(typeof Q==="number")G.minimum=Q;if(V)if(F)G.maximum=K,G.exclusiveMaximum=!0;else G.exclusiveMaximum=K;else if(typeof Y==="number")G.maximum=Y;if(typeof B==="number")if(Number.isFinite(B)&&B!==0)G.multipleOf=Math.abs(B);else $0(J,$,G,X,`A multipleOf divisor of ${B} cannot be represented in JSON Schema`)},J5=(J,$,Z,X)=>{Z.type="boolean"},$5=(J,$,Z,X)=>{$0(J,$,Z,X,"BigInt cannot be represented in JSON Schema")},Z5=(J,$,Z,X)=>{$0(J,$,Z,X,"Symbols cannot be represented in JSON Schema")},X5=(J,$,Z,X)=>{if($.target==="openapi-3.0")Z.type="string",Z.nullable=!0,Z.enum=[null];else Z.type="null"},G5=(J,$,Z,X)=>{$0(J,$,Z,X,"Undefined cannot be represented in JSON Schema")},Q5=(J,$,Z,X)=>{$0(J,$,Z,X,"Void cannot be represented in JSON Schema")},Y5=(J,$,Z,X)=>{Z.not={}},z5=(J,$,Z,X)=>{},B5=(J,$,Z,X)=>{},K5=(J,$,Z,X)=>{$0(J,$,Z,X,"Date cannot be represented in JSON Schema")},W5=(J,$,Z,X)=>{let G=J._zod.def,Q=oZ(G.entries);if(Q.length===0){Z.not={};return}if(Q.every((Y)=>typeof Y==="number"))Z.type="number";if(Q.every((Y)=>typeof Y==="string"))Z.type="string";Z.enum=Q},V5=(J,$,Z,X)=>{let G=J._zod.def;if(G.values.length===0){Z.not={};return}let Q=[];for(let Y of G.values)if(Y===void 0){if($0(J,$,Z,X,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof Y==="bigint"){if($0(J,$,Z,X,"BigInt literals cannot be represented in JSON Schema"))return;Q.push(Number(Y))}else Q.push(Y);if(Q.length===0);else if(Q.length===1){let Y=Q[0];if(Z.type=Y===null?"null":typeof Y,$.target==="draft-04"||$.target==="openapi-3.0")Z.enum=[Y];else Z.const=Y}else{if(Q.every((Y)=>typeof Y==="number"))Z.type="number";if(Q.every((Y)=>typeof Y==="string"))Z.type="string";if(Q.every((Y)=>typeof Y==="boolean"))Z.type="boolean";if(Q.every((Y)=>Y===null))Z.type="null";Z.enum=Q}},C5=(J,$,Z,X)=>{$0(J,$,Z,X,"NaN cannot be represented in JSON Schema")},U5=(J,$,Z,X)=>{let G=Z,Q=J._zod.pattern;if(!Q)throw Error("Pattern not found in template literal");G.type="string",G.pattern=Q.source},N5=(J,$,Z,X)=>{let G=Z,Q={type:"string",format:"binary",contentEncoding:"binary"},{minimum:Y,maximum:z,mime:B}=J._zod.bag;if(Y!==void 0)Q.minLength=Y;if(z!==void 0)Q.maxLength=z;if(B)if(B.length===1)Q.contentMediaType=B[0],Object.assign(G,Q);else Object.assign(G,Q),G.anyOf=B.map((K)=>({contentMediaType:K}));else Object.assign(G,Q)},F5=(J,$,Z,X)=>{Z.type="boolean"},q5=(J,$,Z,X)=>{$0(J,$,Z,X,"Custom types cannot be represented in JSON Schema")},M5=(J,$,Z,X)=>{$0(J,$,Z,X,"Function types cannot be represented in JSON Schema")},T5=(J,$,Z,X)=>{$0(J,$,Z,X,"Transforms cannot be represented in JSON Schema")},w5=(J,$,Z,X)=>{$0(J,$,Z,X,"Map cannot be represented in JSON Schema")},O5=(J,$,Z,X)=>{$0(J,$,Z,X,"Set cannot be represented in JSON Schema")},R5=(J,$,Z,X)=>{let G=Z,Q=J._zod.def,{minimum:Y,maximum:z}=J._zod.bag;if(typeof Y==="number")G.minItems=Y;if(typeof z==="number")G.maxItems=z;G.type="array",G.items=p(Q.element,$,{...X,path:[...X.path,"items"]})};function o8(J){let $=J._zod.def;if($.type==="pipe"&&$.in._zod.traits.has("$ZodTransform"))return o8($.out);if($.type==="catch")return o8($.innerType);return J._zod.optin}var A5=(J,$,Z,X)=>{let G=Z,Q=J._zod.def,Y=Q.shape;if(Object.getOwnPropertySymbols(Y).length&&$0(J,$,G,X,"Symbol keys cannot be represented in JSON Schema"))return;G.type="object",G.properties={};for(let W in Y)i0(G.properties,W,p(Y[W],$,{...X,path:[...X.path,"properties",W]}));let B=new Set(Object.keys(Y)),K=new Set([...B].filter((W)=>{let C=Q.shape[W];if($.io==="input")return o8(C)===void 0;else return C._zod.optout===void 0}));if(K.size>0)G.required=Array.from(K);if(Q.catchall?._zod.def.type==="never")G.additionalProperties=!1;else if(!Q.catchall){if($.io==="output")G.additionalProperties=!1}else if(Q.catchall)G.additionalProperties=p(Q.catchall,$,{...X,path:[...X.path,"additionalProperties"]})},H5=(J,$,Z,X)=>{let G=J._zod.def,Q=G.inclusive===!1,Y=G.options.map((z,B)=>p(z,$,{...X,path:[...X.path,Q?"oneOf":"anyOf",B]}));if(Q)Z.oneOf=Y;else Z.anyOf=Y},L5=(J,$,Z,X)=>{let G=J._zod.def,Q=p(G.left,$,{...X,path:[...X.path,"allOf",0]}),Y=p(G.right,$,{...X,path:[...X.path,"allOf",1]}),z=(K)=>("allOf"in K)&&Object.keys(K).length===1,B=[...z(Q)?Q.allOf:[Q],...z(Y)?Y.allOf:[Y]];Z.allOf=B,$.intersections.push(B)},D5=(J,$,Z,X)=>{let G=Z,Q=J._zod.def;G.type="array";let Y=$.target==="draft-2020-12"?"prefixItems":"items",z=$.target==="draft-2020-12"?"items":$.target==="openapi-3.0"?"items":"additionalItems",B=Q.items.map((A,R)=>p(A,$,{...X,path:[...X.path,Y,R]})),K=Q.rest?p(Q.rest,$,{...X,path:[...X.path,z,...$.target==="openapi-3.0"?[Q.items.length]:[]]}):null,W=Q.items.length;while(W>0){let A=Q.items[W-1];if(!($.io==="input"?o8(A)!==void 0:A._zod.optout==="optional"))break;W--}let C=Q.items.length,V=!Q.rest;if($.target==="draft-2020-12"){if(G.prefixItems=B,V)G.items=!1;else if(K)G.items=K;if(W>0)G.minItems=W;if(V)G.maxItems=C}else if($.target==="openapi-3.0"){if(G.items={anyOf:B},K)G.items.anyOf.push(K);if(W>0)G.minItems=W;if(V)G.maxItems=C}else{if(G.items=B,V)G.additionalItems=!1;else if(K)G.additionalItems=K;if(W>0)G.minItems=W;if(V)G.maxItems=C}let{minimum:F,maximum:q}=J._zod.bag;if(typeof F==="number")G.minItems=F;if(typeof q==="number")G.maxItems=q};function q4(J,$,Z){if($.$ref){if(Z.has($))return $;Z.add($);let q=J.get($)?.def;if(!q)return $;let A=q4(J,q,Z);return A===q?$:A}for(let q of["anyOf","oneOf"]){let A=$[q];if(!Array.isArray(A))continue;let R=A.map((H)=>q4(J,H,Z));if(R.some((H,O)=>H!==A[O]))$={...$,[q]:R}}let X=Array.isArray($.type)?$.type:[$.type],G=!X.includes("string")&&X.some((q)=>q==="number"||q==="integer"),Q=$.enum??($.const!==void 0?[$.const]:void 0);if(!G&&!Q?.some((q)=>typeof q==="number"))return $;let{minimum:Y,maximum:z,exclusiveMinimum:B,exclusiveMaximum:K,multipleOf:W,format:C,id:V,...F}=$;if(F.enum)F.enum=F.enum.map((q)=>typeof q==="number"?String(q):q);else if(typeof F.const==="number")F.const=String(F.const);if(!G)return F;if(F.type="string",!Q)F.pattern=(X.includes("number")?tZ:rZ).source;return F}var M4=new WeakMap;function j5(J){let $=new Map;for(let X of J.seen.values())if(X.def&&!$.has(X.schema))$.set(X.schema,X);let Z=new Map;for(let X of M4.get(J)??[]){let G=J.seen.get(X),Q=(G?.def??G?.schema)?.propertyNames;if(!Q||Q===!0||Z.has(Q))continue;let Y=q4($,Q,new Set);if(Y!==Q)Z.set(Q,Y)}if(!Z.size)return;for(let X of J.seen.values())for(let G of[X.schema,X.def]){let Q=G&&Z.get(G.propertyNames);if(Q)G.propertyNames=Q}}var P5=(J,$,Z,X)=>{let G=Z,Q=J._zod.def;G.type="object";let Y=Q.keyType,B=Y._zod.bag?.patterns;if(Q.mode==="loose"&&B&&B.size>0){let C=p(Q.valueType,$,{...X,path:[...X.path,"patternProperties","*"]});G.patternProperties={};for(let V of B)i0(G.patternProperties,V.source,C)}else{if($.target==="draft-07"||$.target==="draft-2020-12"){G.propertyNames=p(Q.keyType,$,{...X,path:[...X.path,"propertyNames"]});let C=M4.get($);if(!C)C=[],M4.set($,C),$.deferred.push(()=>j5($));C.push(J)}G.additionalProperties=p(Q.valueType,$,{...X,path:[...X.path,"additionalProperties"]})}let K=Y._zod.values,W=$.io==="input"&&o8(Q.valueType)!==void 0;if(K&&!Q.partial&&!W){let C=[...K].filter((V)=>typeof V==="string"||typeof V==="number");if(C.length>0)G.required=C.map(String)}},S5=(J,$,Z,X)=>{let G=J._zod.def,Q=p(G.innerType,$,X),Y=$.seen.get(J);if($.target==="openapi-3.0")Y.ref=G.innerType,Z.nullable=!0;else Z.anyOf=[Q,{type:"null"}]},_5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);Q.ref=G.innerType},T4=Symbol();function B9(J,$,Z,X,G){let Q=!1,Y=JSON.stringify(J,(z,B)=>{if(typeof B!=="bigint")return B;return Q=!0,null});if(!Q)return JSON.parse(Y);return $0($,Z,X,G,"BigInt defaults cannot be represented in JSON Schema"),T4}var E5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);Q.ref=G.innerType;let Y=B9(G.defaultValue,J,$,Z,X);if(Y!==T4)Z.default=Y},I5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);if(Q.ref=G.innerType,$.io!=="input")return;let Y=B9(G.defaultValue,J,$,Z,X);if(Y!==T4)Z._prefault=Y},y5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);Q.ref=G.innerType;let Y;try{Y=G.catchValue(void 0)}catch{$0(J,$,Z,X,"Dynamic catch values are not supported in JSON Schema");return}Z.default=Y},x5=(J,$,Z,X)=>{let G=J._zod.def,Q=G.in._zod.traits.has("$ZodTransform"),Y=$.io==="input"?Q?G.out:G.in:G.out;p(Y,$,X);let z=$.seen.get(J);z.ref=Y},k5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);Q.ref=G.innerType,Z.readOnly=!0},f5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);Q.ref=G.innerType},v5=(J,$,Z,X)=>{let G=J._zod.def;p(G.innerType,$,X);let Q=$.seen.get(J);Q.ref=G.innerType},b5=(J,$,Z,X)=>{let G=J._zod.innerType;p(G,$,X);let Q=$.seen.get(J);Q.ref=G},z9={string:sG,number:eG,boolean:J5,bigint:$5,symbol:Z5,null:X5,undefined:G5,void:Q5,never:Y5,any:z5,unknown:B5,date:K5,enum:W5,literal:V5,nan:C5,template_literal:U5,file:N5,success:F5,custom:q5,function:M5,transform:T5,map:w5,set:O5,array:R5,object:A5,union:H5,intersection:L5,tuple:D5,record:P5,nullable:S5,nonoptional:_5,default:E5,prefault:I5,catch:y5,pipe:x5,readonly:k5,promise:f5,optional:v5,lazy:b5};function i1(J,$){if("_idmap"in J){let X=J,G=c1({...$,processors:z9}),Q={};for(let B of X._idmap.entries()){let[K,W]=B;p(W,G)}let Y={},z={registry:X,uri:$?.uri,defs:Q};G.external=z;for(let B of X._idmap.entries()){let[K,W]=B;p1(G,W),i0(Y,K,l1(G,W))}if(Object.keys(Q).length>0){let B=G.target==="draft-2020-12"?"$defs":"definitions";Y.__shared={[B]:Q}}return{schemas:Y}}let Z=c1({...$,processors:z9});return p(J,Z),p1(Z,J),l1(Z,J)}c();function g5(J){return{type:"json_schema",schema:{...x1(i1(J,{reused:"ref"}))},parse:(Z)=>{let X=J.safeParse(JSON.parse(Z));if(!X.success)throw new T(`Failed to parse structured output: ${X.error.message} cause: ${X.error.issues}`);return X.data}}}function h5(J){let $=i1(J.inputSchema,{reused:"ref"});if($.type!=="object")throw Error(`Zod schema for tool "${J.name}" must be an object, but got ${$.type}`);let Z=$;return{type:"custom",name:J.name,input_schema:Z,description:J.description,run:J.run,parse:(X)=>J.inputSchema.parse(X),...J.close?{close:J.close}:{}}}function m5(J){return{type:"memory_20250818",name:"memory",parse:($)=>$,run:($)=>{let Z=J[$.command];if(!Z)throw Error(`${$.command} not implemented`);return Z.bind(J)($)}}}I0();q0();K1();var u5=["image/jpeg","image/png","image/gif","image/webp"];function w4(J){return u5.includes(J)}function d5(J){return!J||J.startsWith("text/")||J==="application/pdf"||w4(J)}class R0 extends Error{constructor(J){super(J);this.name="UnsupportedMCPValueError"}}function K9(J,$,Z){let X={...J.inputSchema,type:"object",properties:J.inputSchema.properties??null,required:J.inputSchema.required??null};return{...{name:J.name,input_schema:X,...J.description!==void 0?{description:J.description}:{},...Z},run:async(Y)=>{let z=await $.callTool({name:J.name,arguments:Y});if(z.isError){let B=z.content.map((K)=>n1(K));throw new P(B)}if(z.content.length===0&&typeof z.structuredContent==="object"&&z.structuredContent!==null)return JSON.stringify(z.structuredContent);return z.content.map((B)=>n1(B))},parse:(Y)=>Y,[V0]:"mcpTool"}}function c5(J,$,Z){return J.map((X)=>K9(X,$,Z))}function W9(J,$){return{role:J.role,content:[n1(J.content,$)],[V0]:"mcpMessage"}}function p5(J,$){return J.map((Z)=>W9(Z,$))}function n1(J,$){switch(J.type){case"text":return{type:"text",text:J.text,...$,[V0]:"mcpContent"};case"image":{if(!w4(J.mimeType))throw new R0(`Unsupported image MIME type: ${J.mimeType}`);return{type:"image",source:{type:"base64",data:J.data,media_type:J.mimeType},...$,[V0]:"mcpContent"}}case"resource":return V9(J.resource,$,"mcpContent");case"resource_link":case"audio":throw new R0(`Unsupported MCP content type: ${J.type}`);default:throw new R0(`Unsupported MCP content type: ${J.type}`)}}function V9(J,$,Z="mcpResourceToContent"){let X=J.mimeType;if(X&&w4(X)){if(!("blob"in J))throw new R0(`Image resource must have blob data, not text. URI: ${J.uri}`);return{type:"image",source:{type:"base64",data:J.blob,media_type:X},...$,[V0]:Z}}if(X==="application/pdf"){if(!("blob"in J))throw new R0(`PDF resource must have blob data, not text. URI: ${J.uri}`);return{type:"document",source:{type:"base64",data:J.blob,media_type:"application/pdf"},...$,[V0]:Z}}if(!X||X.startsWith("text/"))return{type:"document",source:n5(J),...$,[V0]:Z};throw new R0(`Unsupported MIME type "${X}" for resource: ${J.uri}`)}function l5(J,$){if(J.contents.length===0)throw new R0("Resource contents array must contain at least one item");let Z=J.contents.find((X)=>d5(X.mimeType));if(!Z){let X=J.contents.map((G)=>G.mimeType).filter((G)=>G!==void 0);throw new R0(`No supported MIME type found in resource contents. Available: ${X.join(", ")}`)}return V9(Z,$)}function i5(J){if("blob"in J)return r2(J.blob);return new TextEncoder().encode(J.text)}function n5(J){return{type:"text",data:"text"in J?J.text:new TextDecoder().decode(r2(J.blob)),media_type:"text/plain"}}function a5(J){if(J.contents.length===0)throw new R0("Resource contents array must contain at least one item");let $=J.contents[0],Z=new URL($.uri).pathname.split("/").at(-1)||"file",X=$.mimeType,G=i5($),Q=new File([G],Z,X?{type:X}:void 0);return Q[V0]="mcpResourceToFile",Q}I0();KJ();export{w1 as toFile,t6 as setupSkills,Y2 as resolvePath,c5 as mcpTools,K9 as mcpTool,a5 as mcpResourceToFile,l5 as mcpResourceToContent,p5 as mcpMessages,W9 as mcpMessage,n1 as mcpContent,v1 as extractSkillArchive,P0 as default,h5 as betaZodTool,g5 as betaZodOutputFormat,QJ as betaWriteTool,m0 as betaTool,mG as betaRefusalFallbackMiddleware,GJ as betaReadTool,m5 as betaMemoryTool,d3 as betaJSONSchemaOutputFormat,BJ as betaGrepTool,zJ as betaGlobTool,YJ as betaEditTool,XJ as betaBashTool,TZ as betaAgentToolset20260401,B0 as VERSION,R0 as UnsupportedMCPValueError,p2 as UnprocessableEntityError,P as ToolError,s as Stream,t8 as RetryableError,l2 as RateLimitError,T as PukuError,P0 as PukuAI,u2 as PermissionDeniedError,T1 as PagePromise,f0 as OAUTH_API_BETA_HEADER,d2 as NotFoundError,D8 as MODEL_NONSTREAMING_TOKENS,i2 as InternalServerError,gZ as HUMAN_PROMPT,V6 as FEDERATION_BETA_HEADER,c2 as ConflictError,e1 as BetaFallbackState,g1 as BashTimeoutError,h1 as BashSession,d1 as BasePuku,h2 as BadRequestError,m2 as AuthenticationError,Z0 as APIUserAbortError,s0 as APIPromise,l as APIError,g2 as APIConnectionTimeoutError,S0 as APIConnectionError,hZ as AI_PROMPT};
|
|
67
67
|
|
|
68
|
-
//# debugId=
|
|
68
|
+
//# debugId=E0FD8884C5C47CBB64756E2164756E21
|