@puku-ai/sdk 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +26 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/vendor/_vendor/partial-json-parser/parser.d.ts +2 -0
- package/dist/vendor/_vendor/partial-json-parser/parser.js +223 -0
- package/dist/vendor/_vendor/partial-json-parser/parser.js.map +1 -0
- package/dist/vendor/api-promise.d.ts +2 -0
- package/dist/vendor/api-promise.js +3 -0
- package/dist/vendor/api-promise.js.map +1 -0
- package/dist/vendor/client.d.ts +399 -0
- package/dist/vendor/client.js +976 -0
- package/dist/vendor/client.js.map +1 -0
- package/dist/vendor/core/api-promise.d.ts +49 -0
- package/dist/vendor/core/api-promise.js +77 -0
- package/dist/vendor/core/api-promise.js.map +1 -0
- package/dist/vendor/core/api.d.ts +10 -0
- package/dist/vendor/core/api.js +2 -0
- package/dist/vendor/core/api.js.map +1 -0
- package/dist/vendor/core/credentials.d.ts +130 -0
- package/dist/vendor/core/credentials.js +274 -0
- package/dist/vendor/core/credentials.js.map +1 -0
- package/dist/vendor/core/error.d.ts +82 -0
- package/dist/vendor/core/error.js +140 -0
- package/dist/vendor/core/error.js.map +1 -0
- package/dist/vendor/core/middleware.d.ts +153 -0
- package/dist/vendor/core/middleware.js +168 -0
- package/dist/vendor/core/middleware.js.map +1 -0
- package/dist/vendor/core/pagination.d.ts +121 -0
- package/dist/vendor/core/pagination.js +207 -0
- package/dist/vendor/core/pagination.js.map +1 -0
- package/dist/vendor/core/resource.d.ts +5 -0
- package/dist/vendor/core/resource.js +8 -0
- package/dist/vendor/core/resource.js.map +1 -0
- package/dist/vendor/core/streaming.d.ts +41 -0
- package/dist/vendor/core/streaming.js +342 -0
- package/dist/vendor/core/streaming.js.map +1 -0
- package/dist/vendor/core/uploads.d.ts +2 -0
- package/dist/vendor/core/uploads.js +2 -0
- package/dist/vendor/core/uploads.js.map +1 -0
- package/dist/vendor/error.d.ts +2 -0
- package/dist/vendor/error.js +3 -0
- package/dist/vendor/error.js.map +1 -0
- package/dist/vendor/helpers/beta/environments.d.ts +22 -0
- package/dist/vendor/helpers/beta/environments.js +23 -0
- package/dist/vendor/helpers/beta/environments.js.map +1 -0
- package/dist/vendor/helpers/beta/json-schema.d.ts +36 -0
- package/dist/vendor/helpers/beta/json-schema.js +53 -0
- package/dist/vendor/helpers/beta/json-schema.js.map +1 -0
- package/dist/vendor/helpers/beta/mcp.d.ts +302 -0
- package/dist/vendor/helpers/beta/mcp.js +406 -0
- package/dist/vendor/helpers/beta/mcp.js.map +1 -0
- package/dist/vendor/helpers/beta/memory.d.ts +10 -0
- package/dist/vendor/helpers/beta/memory.js +15 -0
- package/dist/vendor/helpers/beta/memory.js.map +1 -0
- package/dist/vendor/helpers/beta/standard-schema.d.ts +44 -0
- package/dist/vendor/helpers/beta/standard-schema.js +54 -0
- package/dist/vendor/helpers/beta/standard-schema.js.map +1 -0
- package/dist/vendor/helpers/beta/zod.d.ts +32 -0
- package/dist/vendor/helpers/beta/zod.js +52 -0
- package/dist/vendor/helpers/beta/zod.js.map +1 -0
- package/dist/vendor/helpers/index.d.ts +2 -0
- package/dist/vendor/helpers/index.js +3 -0
- package/dist/vendor/helpers/index.js.map +1 -0
- package/dist/vendor/helpers/json-schema.d.ts +17 -0
- package/dist/vendor/helpers/json-schema.js +34 -0
- package/dist/vendor/helpers/json-schema.js.map +1 -0
- package/dist/vendor/helpers/zod.d.ts +12 -0
- package/dist/vendor/helpers/zod.js +42 -0
- package/dist/vendor/helpers/zod.js.map +1 -0
- package/dist/vendor/index.d.ts +16 -0
- package/dist/vendor/index.js +23 -0
- package/dist/vendor/index.js.map +1 -0
- package/dist/vendor/internal/builtin-types.d.ts +72 -0
- package/dist/vendor/internal/builtin-types.js +3 -0
- package/dist/vendor/internal/builtin-types.js.map +1 -0
- package/dist/vendor/internal/constants.d.ts +4 -0
- package/dist/vendor/internal/constants.js +10 -0
- package/dist/vendor/internal/constants.js.map +1 -0
- package/dist/vendor/internal/decoders/jsonl.d.ts +9 -0
- package/dist/vendor/internal/decoders/jsonl.js +37 -0
- package/dist/vendor/internal/decoders/jsonl.js.map +1 -0
- package/dist/vendor/internal/decoders/line.d.ts +16 -0
- package/dist/vendor/internal/decoders/line.js +105 -0
- package/dist/vendor/internal/decoders/line.js.map +1 -0
- package/dist/vendor/internal/detect-platform.d.ts +14 -0
- package/dist/vendor/internal/detect-platform.js +155 -0
- package/dist/vendor/internal/detect-platform.js.map +1 -0
- package/dist/vendor/internal/errors.d.ts +2 -0
- package/dist/vendor/internal/errors.js +38 -0
- package/dist/vendor/internal/errors.js.map +1 -0
- package/dist/vendor/internal/file-store.d.ts +135 -0
- package/dist/vendor/internal/file-store.js +529 -0
- package/dist/vendor/internal/file-store.js.map +1 -0
- package/dist/vendor/internal/headers.d.ts +28 -0
- package/dist/vendor/internal/headers.js +114 -0
- package/dist/vendor/internal/headers.js.map +1 -0
- package/dist/vendor/internal/message-stream-utils.d.ts +9 -0
- package/dist/vendor/internal/message-stream-utils.js +30 -0
- package/dist/vendor/internal/message-stream-utils.js.map +1 -0
- package/dist/vendor/internal/node.browser.d.ts +8 -0
- package/dist/vendor/internal/node.browser.js +19 -0
- package/dist/vendor/internal/node.browser.js.map +1 -0
- package/dist/vendor/internal/node.d.ts +13 -0
- package/dist/vendor/internal/node.js +14 -0
- package/dist/vendor/internal/node.js.map +1 -0
- package/dist/vendor/internal/parse.d.ts +17 -0
- package/dist/vendor/internal/parse.js +62 -0
- package/dist/vendor/internal/parse.js.map +1 -0
- package/dist/vendor/internal/qs/formats.d.ts +6 -0
- package/dist/vendor/internal/qs/formats.js +9 -0
- package/dist/vendor/internal/qs/formats.js.map +1 -0
- package/dist/vendor/internal/qs/index.d.ts +9 -0
- package/dist/vendor/internal/qs/index.js +10 -0
- package/dist/vendor/internal/qs/index.js.map +1 -0
- package/dist/vendor/internal/qs/stringify.d.ts +2 -0
- package/dist/vendor/internal/qs/stringify.js +274 -0
- package/dist/vendor/internal/qs/stringify.js.map +1 -0
- package/dist/vendor/internal/qs/types.d.ts +56 -0
- package/dist/vendor/internal/qs/types.js +2 -0
- package/dist/vendor/internal/qs/types.js.map +1 -0
- package/dist/vendor/internal/qs/utils.d.ts +14 -0
- package/dist/vendor/internal/qs/utils.js +217 -0
- package/dist/vendor/internal/qs/utils.js.map +1 -0
- package/dist/vendor/internal/request-options.d.ts +126 -0
- package/dist/vendor/internal/request-options.js +27 -0
- package/dist/vendor/internal/request-options.js.map +1 -0
- package/dist/vendor/internal/request-signal.d.ts +3 -0
- package/dist/vendor/internal/request-signal.js +45 -0
- package/dist/vendor/internal/request-signal.js.map +1 -0
- package/dist/vendor/internal/shim-types.d.ts +16 -0
- package/dist/vendor/internal/shim-types.js +3 -0
- package/dist/vendor/internal/shim-types.js.map +1 -0
- package/dist/vendor/internal/shims.d.ts +25 -0
- package/dist/vendor/internal/shims.js +85 -0
- package/dist/vendor/internal/shims.js.map +1 -0
- package/dist/vendor/internal/stainless-helper-header.d.ts +59 -0
- package/dist/vendor/internal/stainless-helper-header.js +83 -0
- package/dist/vendor/internal/stainless-helper-header.js.map +1 -0
- package/dist/vendor/internal/stream-utils.d.ts +7 -0
- package/dist/vendor/internal/stream-utils.js +35 -0
- package/dist/vendor/internal/stream-utils.js.map +1 -0
- package/dist/vendor/internal/to-file.d.ts +44 -0
- package/dist/vendor/internal/to-file.js +93 -0
- package/dist/vendor/internal/to-file.js.map +1 -0
- package/dist/vendor/internal/types.d.ts +62 -0
- package/dist/vendor/internal/types.js +3 -0
- package/dist/vendor/internal/types.js.map +1 -0
- package/dist/vendor/internal/uploads.d.ts +41 -0
- package/dist/vendor/internal/uploads.js +139 -0
- package/dist/vendor/internal/uploads.js.map +1 -0
- package/dist/vendor/internal/utils/abort.d.ts +11 -0
- package/dist/vendor/internal/utils/abort.js +22 -0
- package/dist/vendor/internal/utils/abort.js.map +1 -0
- package/dist/vendor/internal/utils/async-queue.d.ts +30 -0
- package/dist/vendor/internal/utils/async-queue.js +66 -0
- package/dist/vendor/internal/utils/async-queue.js.map +1 -0
- package/dist/vendor/internal/utils/backoff.d.ts +22 -0
- package/dist/vendor/internal/utils/backoff.js +36 -0
- package/dist/vendor/internal/utils/backoff.js.map +1 -0
- package/dist/vendor/internal/utils/base64.d.ts +2 -0
- package/dist/vendor/internal/utils/base64.js +33 -0
- package/dist/vendor/internal/utils/base64.js.map +1 -0
- package/dist/vendor/internal/utils/bytes.d.ts +3 -0
- package/dist/vendor/internal/utils/bytes.js +26 -0
- package/dist/vendor/internal/utils/bytes.js.map +1 -0
- package/dist/vendor/internal/utils/env.d.ts +8 -0
- package/dist/vendor/internal/utils/env.js +18 -0
- package/dist/vendor/internal/utils/env.js.map +1 -0
- package/dist/vendor/internal/utils/log.d.ts +46 -0
- package/dist/vendor/internal/utils/log.js +105 -0
- package/dist/vendor/internal/utils/log.js.map +1 -0
- package/dist/vendor/internal/utils/path.d.ts +14 -0
- package/dist/vendor/internal/utils/path.js +74 -0
- package/dist/vendor/internal/utils/path.js.map +1 -0
- package/dist/vendor/internal/utils/promise.d.ts +10 -0
- package/dist/vendor/internal/utils/promise.js +15 -0
- package/dist/vendor/internal/utils/promise.js.map +1 -0
- package/dist/vendor/internal/utils/query.d.ts +1 -0
- package/dist/vendor/internal/utils/query.js +6 -0
- package/dist/vendor/internal/utils/query.js.map +1 -0
- package/dist/vendor/internal/utils/sleep.d.ts +9 -0
- package/dist/vendor/internal/utils/sleep.js +24 -0
- package/dist/vendor/internal/utils/sleep.js.map +1 -0
- package/dist/vendor/internal/utils/time.d.ts +2 -0
- package/dist/vendor/internal/utils/time.js +5 -0
- package/dist/vendor/internal/utils/time.js.map +1 -0
- package/dist/vendor/internal/utils/uuid.d.ts +4 -0
- package/dist/vendor/internal/utils/uuid.js +15 -0
- package/dist/vendor/internal/utils/uuid.js.map +1 -0
- package/dist/vendor/internal/utils/values.d.ts +24 -0
- package/dist/vendor/internal/utils/values.js +106 -0
- package/dist/vendor/internal/utils/values.js.map +1 -0
- package/dist/vendor/internal/utils.d.ts +7 -0
- package/dist/vendor/internal/utils.js +9 -0
- package/dist/vendor/internal/utils.js.map +1 -0
- package/dist/vendor/lib/BetaMessageStream.d.ts +123 -0
- package/dist/vendor/lib/BetaMessageStream.js +662 -0
- package/dist/vendor/lib/BetaMessageStream.js.map +1 -0
- package/dist/vendor/lib/MessageStream.d.ts +122 -0
- package/dist/vendor/lib/MessageStream.js +609 -0
- package/dist/vendor/lib/MessageStream.js.map +1 -0
- package/dist/vendor/lib/beta-parser.d.ts +36 -0
- package/dist/vendor/lib/beta-parser.js +75 -0
- package/dist/vendor/lib/beta-parser.js.map +1 -0
- package/dist/vendor/lib/credentials/credential-chain.d.ts +38 -0
- package/dist/vendor/lib/credentials/credential-chain.js +208 -0
- package/dist/vendor/lib/credentials/credential-chain.js.map +1 -0
- package/dist/vendor/lib/credentials/identity-token.d.ts +10 -0
- package/dist/vendor/lib/credentials/identity-token.js +35 -0
- package/dist/vendor/lib/credentials/identity-token.js.map +1 -0
- package/dist/vendor/lib/credentials/oidc-federation.d.ts +39 -0
- package/dist/vendor/lib/credentials/oidc-federation.js +79 -0
- package/dist/vendor/lib/credentials/oidc-federation.js.map +1 -0
- package/dist/vendor/lib/credentials/token-cache.d.ts +53 -0
- package/dist/vendor/lib/credentials/token-cache.js +110 -0
- package/dist/vendor/lib/credentials/token-cache.js.map +1 -0
- package/dist/vendor/lib/credentials/types.d.ts +95 -0
- package/dist/vendor/lib/credentials/types.js +226 -0
- package/dist/vendor/lib/credentials/types.js.map +1 -0
- package/dist/vendor/lib/credentials/user-oauth.d.ts +20 -0
- package/dist/vendor/lib/credentials/user-oauth.js +94 -0
- package/dist/vendor/lib/credentials/user-oauth.js.map +1 -0
- package/dist/vendor/lib/credentials.d.ts +3 -0
- package/dist/vendor/lib/credentials.js +3 -0
- package/dist/vendor/lib/credentials.js.map +1 -0
- package/dist/vendor/lib/environments/index.d.ts +3 -0
- package/dist/vendor/lib/environments/index.js +4 -0
- package/dist/vendor/lib/environments/index.js.map +1 -0
- package/dist/vendor/lib/environments/poller.d.ts +94 -0
- package/dist/vendor/lib/environments/poller.js +218 -0
- package/dist/vendor/lib/environments/poller.js.map +1 -0
- package/dist/vendor/lib/environments/worker.d.ts +226 -0
- package/dist/vendor/lib/environments/worker.js +572 -0
- package/dist/vendor/lib/environments/worker.js.map +1 -0
- package/dist/vendor/lib/helper-client.d.ts +30 -0
- package/dist/vendor/lib/helper-client.js +55 -0
- package/dist/vendor/lib/helper-client.js.map +1 -0
- package/dist/vendor/lib/middleware.d.ts +97 -0
- package/dist/vendor/lib/middleware.js +775 -0
- package/dist/vendor/lib/middleware.js.map +1 -0
- package/dist/vendor/lib/parser.d.ts +31 -0
- package/dist/vendor/lib/parser.js +62 -0
- package/dist/vendor/lib/parser.js.map +1 -0
- package/dist/vendor/lib/sessions/accumulate.d.ts +22 -0
- package/dist/vendor/lib/sessions/accumulate.js +42 -0
- package/dist/vendor/lib/sessions/accumulate.js.map +1 -0
- package/dist/vendor/lib/standard-schema.d.ts +130 -0
- package/dist/vendor/lib/standard-schema.js +41 -0
- package/dist/vendor/lib/standard-schema.js.map +1 -0
- package/dist/vendor/lib/tools/BetaRunnableTool.d.ts +48 -0
- package/dist/vendor/lib/tools/BetaRunnableTool.js +26 -0
- package/dist/vendor/lib/tools/BetaRunnableTool.js.map +1 -0
- package/dist/vendor/lib/tools/BetaToolRunner.d.ts +160 -0
- package/dist/vendor/lib/tools/BetaToolRunner.js +497 -0
- package/dist/vendor/lib/tools/BetaToolRunner.js.map +1 -0
- package/dist/vendor/lib/tools/CompactionControl.d.ts +29 -0
- package/dist/vendor/lib/tools/CompactionControl.js +25 -0
- package/dist/vendor/lib/tools/CompactionControl.js.map +1 -0
- package/dist/vendor/lib/tools/SessionToolRunner.d.ts +178 -0
- package/dist/vendor/lib/tools/SessionToolRunner.js +737 -0
- package/dist/vendor/lib/tools/SessionToolRunner.js.map +1 -0
- package/dist/vendor/lib/tools/ToolError.d.ts +32 -0
- package/dist/vendor/lib/tools/ToolError.js +43 -0
- package/dist/vendor/lib/tools/ToolError.js.map +1 -0
- package/dist/vendor/lib/transform-json-schema.d.ts +2 -0
- package/dist/vendor/lib/transform-json-schema.js +111 -0
- package/dist/vendor/lib/transform-json-schema.js.map +1 -0
- package/dist/vendor/pagination.d.ts +2 -0
- package/dist/vendor/pagination.js +3 -0
- package/dist/vendor/pagination.js.map +1 -0
- package/dist/vendor/resource.d.ts +2 -0
- package/dist/vendor/resource.js +3 -0
- package/dist/vendor/resource.js.map +1 -0
- package/dist/vendor/resources/beta/agents/agents.d.ts +1128 -0
- package/dist/vendor/resources/beta/agents/agents.js +123 -0
- package/dist/vendor/resources/beta/agents/agents.js.map +1 -0
- package/dist/vendor/resources/beta/agents/index.d.ts +2 -0
- package/dist/vendor/resources/beta/agents/index.js +4 -0
- package/dist/vendor/resources/beta/agents/index.js.map +1 -0
- package/dist/vendor/resources/beta/agents/versions.d.ts +32 -0
- package/dist/vendor/resources/beta/agents/versions.js +32 -0
- package/dist/vendor/resources/beta/agents/versions.js.map +1 -0
- package/dist/vendor/resources/beta/agents.d.ts +1 -0
- package/dist/vendor/resources/beta/agents.js +3 -0
- package/dist/vendor/resources/beta/agents.js.map +1 -0
- package/dist/vendor/resources/beta/beta.d.ts +131 -0
- package/dist/vendor/resources/beta/beta.js +69 -0
- package/dist/vendor/resources/beta/beta.js.map +1 -0
- package/dist/vendor/resources/beta/deployment-runs.d.ts +305 -0
- package/dist/vendor/resources/beta/deployment-runs.js +51 -0
- package/dist/vendor/resources/beta/deployment-runs.js.map +1 -0
- package/dist/vendor/resources/beta/deployments.d.ts +698 -0
- package/dist/vendor/resources/beta/deployments.js +192 -0
- package/dist/vendor/resources/beta/deployments.js.map +1 -0
- package/dist/vendor/resources/beta/dreams.d.ts +335 -0
- package/dist/vendor/resources/beta/dreams.js +112 -0
- package/dist/vendor/resources/beta/dreams.js.map +1 -0
- package/dist/vendor/resources/beta/environments/environments.d.ts +432 -0
- package/dist/vendor/resources/beta/environments/environments.js +142 -0
- package/dist/vendor/resources/beta/environments/environments.js.map +1 -0
- package/dist/vendor/resources/beta/environments/index.d.ts +2 -0
- package/dist/vendor/resources/beta/environments/index.js +4 -0
- package/dist/vendor/resources/beta/environments/index.js.map +1 -0
- package/dist/vendor/resources/beta/environments/work.d.ts +500 -0
- package/dist/vendor/resources/beta/environments/work.js +251 -0
- package/dist/vendor/resources/beta/environments/work.js.map +1 -0
- package/dist/vendor/resources/beta/environments.d.ts +1 -0
- package/dist/vendor/resources/beta/environments.js +3 -0
- package/dist/vendor/resources/beta/environments.js.map +1 -0
- package/dist/vendor/resources/beta/files.d.ts +190 -0
- package/dist/vendor/resources/beta/files.js +120 -0
- package/dist/vendor/resources/beta/files.js.map +1 -0
- package/dist/vendor/resources/beta/index.d.ts +17 -0
- package/dist/vendor/resources/beta/index.js +19 -0
- package/dist/vendor/resources/beta/index.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/index.d.ts +3 -0
- package/dist/vendor/resources/beta/memory-stores/index.js +5 -0
- package/dist/vendor/resources/beta/memory-stores/index.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/memories.d.ts +346 -0
- package/dist/vendor/resources/beta/memory-stores/memories.js +126 -0
- package/dist/vendor/resources/beta/memory-stores/memories.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/memory-stores.d.ts +230 -0
- package/dist/vendor/resources/beta/memory-stores/memory-stores.js +137 -0
- package/dist/vendor/resources/beta/memory-stores/memory-stores.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores/memory-versions.d.ts +252 -0
- package/dist/vendor/resources/beta/memory-stores/memory-versions.js +77 -0
- package/dist/vendor/resources/beta/memory-stores/memory-versions.js.map +1 -0
- package/dist/vendor/resources/beta/memory-stores.d.ts +1 -0
- package/dist/vendor/resources/beta/memory-stores.js +3 -0
- package/dist/vendor/resources/beta/memory-stores.js.map +1 -0
- package/dist/vendor/resources/beta/messages/batches.d.ts +685 -0
- package/dist/vendor/resources/beta/messages/batches.js +203 -0
- package/dist/vendor/resources/beta/messages/batches.js.map +1 -0
- package/dist/vendor/resources/beta/messages/index.d.ts +3 -0
- package/dist/vendor/resources/beta/messages/index.js +5 -0
- package/dist/vendor/resources/beta/messages/index.js.map +1 -0
- package/dist/vendor/resources/beta/messages/messages.d.ts +5376 -0
- package/dist/vendor/resources/beta/messages/messages.js +158 -0
- package/dist/vendor/resources/beta/messages/messages.js.map +1 -0
- package/dist/vendor/resources/beta/messages.d.ts +1 -0
- package/dist/vendor/resources/beta/messages.js +3 -0
- package/dist/vendor/resources/beta/messages.js.map +1 -0
- package/dist/vendor/resources/beta/models.d.ts +217 -0
- package/dist/vendor/resources/beta/models.js +56 -0
- package/dist/vendor/resources/beta/models.js.map +1 -0
- package/dist/vendor/resources/beta/organization/api-keys.d.ts +176 -0
- package/dist/vendor/resources/beta/organization/api-keys.js +52 -0
- package/dist/vendor/resources/beta/organization/api-keys.js.map +1 -0
- package/dist/vendor/resources/beta/organization/compliance-settings.d.ts +73 -0
- package/dist/vendor/resources/beta/organization/compliance-settings.js +48 -0
- package/dist/vendor/resources/beta/organization/compliance-settings.js.map +1 -0
- package/dist/vendor/resources/beta/organization/external-keys.d.ts +271 -0
- package/dist/vendor/resources/beta/organization/external-keys.js +115 -0
- package/dist/vendor/resources/beta/organization/external-keys.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/federation.d.ts +13 -0
- package/dist/vendor/resources/beta/organization/federation/federation.js +13 -0
- package/dist/vendor/resources/beta/organization/federation/federation.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/index.d.ts +3 -0
- package/dist/vendor/resources/beta/organization/federation/index.js +5 -0
- package/dist/vendor/resources/beta/organization/federation/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/issuers.d.ts +352 -0
- package/dist/vendor/resources/beta/organization/federation/issuers.js +165 -0
- package/dist/vendor/resources/beta/organization/federation/issuers.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules/index.d.ts +2 -0
- package/dist/vendor/resources/beta/organization/federation/rules/index.js +4 -0
- package/dist/vendor/resources/beta/organization/federation/rules/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules/rules.d.ts +467 -0
- package/dist/vendor/resources/beta/organization/federation/rules/rules.js +190 -0
- package/dist/vendor/resources/beta/organization/federation/rules/rules.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules/workspaces.d.ts +123 -0
- package/dist/vendor/resources/beta/organization/federation/rules/workspaces.js +110 -0
- package/dist/vendor/resources/beta/organization/federation/rules/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/federation/rules.js +3 -0
- package/dist/vendor/resources/beta/organization/federation/rules.js.map +1 -0
- package/dist/vendor/resources/beta/organization/federation.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/federation.js +3 -0
- package/dist/vendor/resources/beta/organization/federation.js.map +1 -0
- package/dist/vendor/resources/beta/organization/index.d.ts +10 -0
- package/dist/vendor/resources/beta/organization/index.js +12 -0
- package/dist/vendor/resources/beta/organization/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/invites.d.ts +161 -0
- package/dist/vendor/resources/beta/organization/invites.js +72 -0
- package/dist/vendor/resources/beta/organization/invites.js.map +1 -0
- package/dist/vendor/resources/beta/organization/organization.d.ts +72 -0
- package/dist/vendor/resources/beta/organization/organization.js +54 -0
- package/dist/vendor/resources/beta/organization/organization.js.map +1 -0
- package/dist/vendor/resources/beta/organization/rate-limits.d.ts +76 -0
- package/dist/vendor/resources/beta/organization/rate-limits.js +27 -0
- package/dist/vendor/resources/beta/organization/rate-limits.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts/index.d.ts +2 -0
- package/dist/vendor/resources/beta/organization/service-accounts/index.js +4 -0
- package/dist/vendor/resources/beta/organization/service-accounts/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts/service-accounts.d.ts +257 -0
- package/dist/vendor/resources/beta/organization/service-accounts/service-accounts.js +166 -0
- package/dist/vendor/resources/beta/organization/service-accounts/service-accounts.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts/workspaces.d.ts +140 -0
- package/dist/vendor/resources/beta/organization/service-accounts/workspaces.js +121 -0
- package/dist/vendor/resources/beta/organization/service-accounts/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/service-accounts.js +3 -0
- package/dist/vendor/resources/beta/organization/service-accounts.js.map +1 -0
- package/dist/vendor/resources/beta/organization/users.d.ts +123 -0
- package/dist/vendor/resources/beta/organization/users.js +63 -0
- package/dist/vendor/resources/beta/organization/users.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/index.d.ts +4 -0
- package/dist/vendor/resources/beta/organization/workspaces/index.js +6 -0
- package/dist/vendor/resources/beta/organization/workspaces/index.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/members.d.ts +134 -0
- package/dist/vendor/resources/beta/organization/workspaces/members.js +98 -0
- package/dist/vendor/resources/beta/organization/workspaces/members.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/rate-limits.d.ts +82 -0
- package/dist/vendor/resources/beta/organization/workspaces/rate-limits.js +30 -0
- package/dist/vendor/resources/beta/organization/workspaces/rate-limits.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/service-accounts.d.ts +209 -0
- package/dist/vendor/resources/beta/organization/workspaces/service-accounts.js +185 -0
- package/dist/vendor/resources/beta/organization/workspaces/service-accounts.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces/workspaces.d.ts +302 -0
- package/dist/vendor/resources/beta/organization/workspaces/workspaces.js +104 -0
- package/dist/vendor/resources/beta/organization/workspaces/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization/workspaces.d.ts +1 -0
- package/dist/vendor/resources/beta/organization/workspaces.js +3 -0
- package/dist/vendor/resources/beta/organization/workspaces.js.map +1 -0
- package/dist/vendor/resources/beta/organization.d.ts +1 -0
- package/dist/vendor/resources/beta/organization.js +3 -0
- package/dist/vendor/resources/beta/organization.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/events.d.ts +1513 -0
- package/dist/vendor/resources/beta/sessions/events.js +115 -0
- package/dist/vendor/resources/beta/sessions/events.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/index.d.ts +4 -0
- package/dist/vendor/resources/beta/sessions/index.js +6 -0
- package/dist/vendor/resources/beta/sessions/index.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/resources.d.ts +227 -0
- package/dist/vendor/resources/beta/sessions/resources.js +128 -0
- package/dist/vendor/resources/beta/sessions/resources.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/sessions.d.ts +866 -0
- package/dist/vendor/resources/beta/sessions/sessions.js +150 -0
- package/dist/vendor/resources/beta/sessions/sessions.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads/events.d.ts +77 -0
- package/dist/vendor/resources/beta/sessions/threads/events.js +57 -0
- package/dist/vendor/resources/beta/sessions/threads/events.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads/index.d.ts +2 -0
- package/dist/vendor/resources/beta/sessions/threads/index.js +4 -0
- package/dist/vendor/resources/beta/sessions/threads/index.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads/threads.d.ts +195 -0
- package/dist/vendor/resources/beta/sessions/threads/threads.js +80 -0
- package/dist/vendor/resources/beta/sessions/threads/threads.js.map +1 -0
- package/dist/vendor/resources/beta/sessions/threads.d.ts +1 -0
- package/dist/vendor/resources/beta/sessions/threads.js +3 -0
- package/dist/vendor/resources/beta/sessions/threads.js.map +1 -0
- package/dist/vendor/resources/beta/sessions.d.ts +1 -0
- package/dist/vendor/resources/beta/sessions.js +3 -0
- package/dist/vendor/resources/beta/sessions.js.map +1 -0
- package/dist/vendor/resources/beta/skills/index.d.ts +2 -0
- package/dist/vendor/resources/beta/skills/index.js +4 -0
- package/dist/vendor/resources/beta/skills/index.js.map +1 -0
- package/dist/vendor/resources/beta/skills/skills.d.ts +178 -0
- package/dist/vendor/resources/beta/skills/skills.js +96 -0
- package/dist/vendor/resources/beta/skills/skills.js.map +1 -0
- package/dist/vendor/resources/beta/skills/versions.d.ts +181 -0
- package/dist/vendor/resources/beta/skills/versions.js +125 -0
- package/dist/vendor/resources/beta/skills/versions.js.map +1 -0
- package/dist/vendor/resources/beta/skills.d.ts +1 -0
- package/dist/vendor/resources/beta/skills.js +3 -0
- package/dist/vendor/resources/beta/skills.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels/certificates.d.ts +162 -0
- package/dist/vendor/resources/beta/tunnels/certificates.js +125 -0
- package/dist/vendor/resources/beta/tunnels/certificates.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels/index.d.ts +2 -0
- package/dist/vendor/resources/beta/tunnels/index.js +4 -0
- package/dist/vendor/resources/beta/tunnels/index.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels/tunnels.d.ts +211 -0
- package/dist/vendor/resources/beta/tunnels/tunnels.js +173 -0
- package/dist/vendor/resources/beta/tunnels/tunnels.js.map +1 -0
- package/dist/vendor/resources/beta/tunnels.d.ts +1 -0
- package/dist/vendor/resources/beta/tunnels.js +3 -0
- package/dist/vendor/resources/beta/tunnels.js.map +1 -0
- package/dist/vendor/resources/beta/user-profiles.d.ts +244 -0
- package/dist/vendor/resources/beta/user-profiles.js +114 -0
- package/dist/vendor/resources/beta/user-profiles.js.map +1 -0
- package/dist/vendor/resources/beta/vaults/credentials.d.ts +715 -0
- package/dist/vendor/resources/beta/vaults/credentials.js +173 -0
- package/dist/vendor/resources/beta/vaults/credentials.js.map +1 -0
- package/dist/vendor/resources/beta/vaults/index.d.ts +2 -0
- package/dist/vendor/resources/beta/vaults/index.js +4 -0
- package/dist/vendor/resources/beta/vaults/index.js.map +1 -0
- package/dist/vendor/resources/beta/vaults/vaults.d.ts +191 -0
- package/dist/vendor/resources/beta/vaults/vaults.js +141 -0
- package/dist/vendor/resources/beta/vaults/vaults.js.map +1 -0
- package/dist/vendor/resources/beta/vaults.d.ts +1 -0
- package/dist/vendor/resources/beta/vaults.js +3 -0
- package/dist/vendor/resources/beta/vaults.js.map +1 -0
- package/dist/vendor/resources/beta/webhooks.d.ts +464 -0
- package/dist/vendor/resources/beta/webhooks.js +29 -0
- package/dist/vendor/resources/beta/webhooks.js.map +1 -0
- package/dist/vendor/resources/beta.d.ts +1 -0
- package/dist/vendor/resources/beta.js +3 -0
- package/dist/vendor/resources/beta.js.map +1 -0
- package/dist/vendor/resources/completions.d.ts +172 -0
- package/dist/vendor/resources/completions.js +19 -0
- package/dist/vendor/resources/completions.js.map +1 -0
- package/dist/vendor/resources/files.d.ts +104 -0
- package/dist/vendor/resources/files.js +48 -0
- package/dist/vendor/resources/files.js.map +1 -0
- package/dist/vendor/resources/index.d.ts +7 -0
- package/dist/vendor/resources/index.js +9 -0
- package/dist/vendor/resources/index.js.map +1 -0
- package/dist/vendor/resources/messages/batches.d.ts +312 -0
- package/dist/vendor/resources/messages/batches.js +157 -0
- package/dist/vendor/resources/messages/batches.js.map +1 -0
- package/dist/vendor/resources/messages/index.d.ts +2 -0
- package/dist/vendor/resources/messages/index.js +4 -0
- package/dist/vendor/resources/messages/index.js.map +1 -0
- package/dist/vendor/resources/messages/messages.d.ts +3886 -0
- package/dist/vendor/resources/messages/messages.js +130 -0
- package/dist/vendor/resources/messages/messages.js.map +1 -0
- package/dist/vendor/resources/messages.d.ts +1 -0
- package/dist/vendor/resources/messages.js +3 -0
- package/dist/vendor/resources/messages.js.map +1 -0
- package/dist/vendor/resources/models.d.ts +196 -0
- package/dist/vendor/resources/models.js +41 -0
- package/dist/vendor/resources/models.js.map +1 -0
- package/dist/vendor/resources/shared.d.ts +43 -0
- package/dist/vendor/resources/shared.js +3 -0
- package/dist/vendor/resources/shared.js.map +1 -0
- package/dist/vendor/resources/skills/index.d.ts +2 -0
- package/dist/vendor/resources/skills/index.js +4 -0
- package/dist/vendor/resources/skills/index.js.map +1 -0
- package/dist/vendor/resources/skills/skills.d.ts +128 -0
- package/dist/vendor/resources/skills/skills.js +36 -0
- package/dist/vendor/resources/skills/skills.js.map +1 -0
- package/dist/vendor/resources/skills/versions.d.ts +103 -0
- package/dist/vendor/resources/skills/versions.js +37 -0
- package/dist/vendor/resources/skills/versions.js.map +1 -0
- package/dist/vendor/resources/skills.d.ts +1 -0
- package/dist/vendor/resources/skills.js +3 -0
- package/dist/vendor/resources/skills.js.map +1 -0
- package/dist/vendor/resources/top-level.d.ts +1 -0
- package/dist/vendor/resources/top-level.js +3 -0
- package/dist/vendor/resources/top-level.js.map +1 -0
- package/dist/vendor/resources.d.ts +1 -0
- package/dist/vendor/resources.js +2 -0
- package/dist/vendor/resources.js.map +1 -0
- package/dist/vendor/streaming.d.ts +2 -0
- package/dist/vendor/streaming.js +3 -0
- package/dist/vendor/streaming.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/fs-util.d.ts +74 -0
- package/dist/vendor/tools/agent-toolset/fs-util.js +184 -0
- package/dist/vendor/tools/agent-toolset/fs-util.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/memories.d.ts +172 -0
- package/dist/vendor/tools/agent-toolset/memories.js +910 -0
- package/dist/vendor/tools/agent-toolset/memories.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/node.browser.d.ts +80 -0
- package/dist/vendor/tools/agent-toolset/node.browser.js +129 -0
- package/dist/vendor/tools/agent-toolset/node.browser.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/node.d.ts +191 -0
- package/dist/vendor/tools/agent-toolset/node.js +886 -0
- package/dist/vendor/tools/agent-toolset/node.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/skills.d.ts +73 -0
- package/dist/vendor/tools/agent-toolset/skills.js +320 -0
- package/dist/vendor/tools/agent-toolset/skills.js.map +1 -0
- package/dist/vendor/tools/agent-toolset/sync-interval.d.ts +18 -0
- package/dist/vendor/tools/agent-toolset/sync-interval.js +25 -0
- package/dist/vendor/tools/agent-toolset/sync-interval.js.map +1 -0
- package/dist/vendor/tools/memory/node.browser.d.ts +26 -0
- package/dist/vendor/tools/memory/node.browser.js +44 -0
- package/dist/vendor/tools/memory/node.browser.js.map +1 -0
- package/dist/vendor/tools/memory/node.d.ts +17 -0
- package/dist/vendor/tools/memory/node.js +327 -0
- package/dist/vendor/tools/memory/node.js.map +1 -0
- package/dist/vendor/uploads.d.ts +2 -0
- package/dist/vendor/uploads.js +3 -0
- package/dist/vendor/uploads.js.map +1 -0
- package/dist/vendor/version.d.ts +1 -0
- package/dist/vendor/version.js +2 -0
- package/dist/vendor/version.js.map +1 -0
- package/package.json +7 -14
- package/sdk.cjs +2 -2
- package/sdk.cjs.map +2 -2
- package/sdk.d.ts +1 -1
- package/sdk.mjs +2 -2
- package/sdk.mjs.map +3 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { ADVISORY_REFRESH_BACKOFF_IN_SECONDS, ADVISORY_REFRESH_THRESHOLD_IN_SECONDS, MANDATORY_REFRESH_THRESHOLD_IN_SECONDS, } from './types.js';
|
|
2
|
+
import { nowAsSeconds } from '../../internal/utils/time.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps an {@link AccessTokenProvider} with two-tier proactive refresh
|
|
5
|
+
* and concurrent deduplication.
|
|
6
|
+
*
|
|
7
|
+
* Refresh policy on each {@link getToken} call:
|
|
8
|
+
*
|
|
9
|
+
* - No cached token → call provider (blocking), cache, return.
|
|
10
|
+
* - Cached with `expiresAt == null` → return cached forever.
|
|
11
|
+
* - More than 120s remaining → return cached.
|
|
12
|
+
* - 30–120s remaining (advisory window) → return stale token immediately,
|
|
13
|
+
* kick off background refresh. On failure, log and keep stale.
|
|
14
|
+
* - Less than 30s remaining or expired (mandatory) → block and refresh.
|
|
15
|
+
* On failure, throw.
|
|
16
|
+
*
|
|
17
|
+
* Concurrent mandatory callers coalesce into a single provider call.
|
|
18
|
+
*/
|
|
19
|
+
export class TokenCache {
|
|
20
|
+
provider;
|
|
21
|
+
cached = null;
|
|
22
|
+
pendingRefresh = null;
|
|
23
|
+
nextForce = false;
|
|
24
|
+
lastAdvisoryError = 0;
|
|
25
|
+
onAdvisoryRefreshError;
|
|
26
|
+
constructor(provider, onAdvisoryRefreshError) {
|
|
27
|
+
this.provider = provider;
|
|
28
|
+
this.onAdvisoryRefreshError = onAdvisoryRefreshError;
|
|
29
|
+
}
|
|
30
|
+
async getToken() {
|
|
31
|
+
const force = this.nextForce;
|
|
32
|
+
this.nextForce = false;
|
|
33
|
+
const cached = this.cached;
|
|
34
|
+
if (force || cached == null) {
|
|
35
|
+
const token = await this.refresh(force);
|
|
36
|
+
return token.token;
|
|
37
|
+
}
|
|
38
|
+
if (cached.expiresAt == null) {
|
|
39
|
+
return cached.token;
|
|
40
|
+
}
|
|
41
|
+
const remaining = cached.expiresAt - nowAsSeconds();
|
|
42
|
+
if (remaining > ADVISORY_REFRESH_THRESHOLD_IN_SECONDS) {
|
|
43
|
+
return cached.token;
|
|
44
|
+
}
|
|
45
|
+
if (remaining > MANDATORY_REFRESH_THRESHOLD_IN_SECONDS) {
|
|
46
|
+
this.backgroundRefresh();
|
|
47
|
+
return cached.token;
|
|
48
|
+
}
|
|
49
|
+
const token = await this.refresh();
|
|
50
|
+
return token.token;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Clears the cached token and marks the next {@link getToken} as a forced
|
|
54
|
+
* refresh, so the underlying provider bypasses any on-disk freshness check.
|
|
55
|
+
* Called after a 401 — the server has just told us the token is bad even
|
|
56
|
+
* if its `expires_at` still looks fresh.
|
|
57
|
+
*/
|
|
58
|
+
invalidate() {
|
|
59
|
+
this.cached = null;
|
|
60
|
+
this.nextForce = true;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Mandatory refresh. Joins any in-flight refresh unless forced — a forced
|
|
64
|
+
* refresh must not coalesce into a non-forced one that may re-serve the
|
|
65
|
+
* same stale disk token.
|
|
66
|
+
*/
|
|
67
|
+
refresh(force = false) {
|
|
68
|
+
if (this.pendingRefresh && !force) {
|
|
69
|
+
return this.pendingRefresh;
|
|
70
|
+
}
|
|
71
|
+
return this.doRefresh(force);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Advisory background refresh. Shares the same in-flight promise as
|
|
75
|
+
* mandatory refreshes for deduplication, but swallows errors so the
|
|
76
|
+
* stale cached token keeps being served. Backs off for
|
|
77
|
+
* {@link ADVISORY_REFRESH_BACKOFF_IN_SECONDS} after a failure so an
|
|
78
|
+
* outage during the advisory window doesn't hammer the token endpoint.
|
|
79
|
+
*/
|
|
80
|
+
backgroundRefresh() {
|
|
81
|
+
if (this.pendingRefresh) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (nowAsSeconds() - this.lastAdvisoryError < ADVISORY_REFRESH_BACKOFF_IN_SECONDS) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.doRefresh().catch((err) => {
|
|
88
|
+
this.lastAdvisoryError = nowAsSeconds();
|
|
89
|
+
// Advisory failure: keep serving the stale cached token, but surface
|
|
90
|
+
// the error to the caller-provided hook so it can be logged.
|
|
91
|
+
this.onAdvisoryRefreshError?.(err);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Core refresh. Sets {@link pendingRefresh} so concurrent callers
|
|
96
|
+
* (both advisory and mandatory) coalesce into a single provider call.
|
|
97
|
+
*/
|
|
98
|
+
doRefresh(force = false) {
|
|
99
|
+
this.pendingRefresh = this.provider(force ? { forceRefresh: true } : undefined).then((token) => {
|
|
100
|
+
this.cached = token;
|
|
101
|
+
this.pendingRefresh = null;
|
|
102
|
+
return token;
|
|
103
|
+
}, (err) => {
|
|
104
|
+
this.pendingRefresh = null;
|
|
105
|
+
throw err;
|
|
106
|
+
});
|
|
107
|
+
return this.pendingRefresh;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=token-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-cache.js","sourceRoot":"","sources":["../../../../src/vendor/lib/credentials/token-cache.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mCAAmC,EACnC,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,UAAU;IACb,QAAQ,CAAsB;IAC9B,MAAM,GAAuB,IAAI,CAAC;IAClC,cAAc,GAAgC,IAAI,CAAC;IACnD,SAAS,GAAG,KAAK,CAAC;IAClB,iBAAiB,GAAG,CAAC,CAAC;IACtB,sBAAsB,CAAuC;IAErE,YAAY,QAA6B,EAAE,sBAA+C;QACxF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,IAAI,KAAK,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACxC,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QAED,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,YAAY,EAAE,CAAC;QAEpD,IAAI,SAAS,GAAG,qCAAqC,EAAE,CAAC;YACtD,OAAO,MAAM,CA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,CAAC,CAAC,IAAI,CAClF,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC,EACD,CAAC,GAAG,EAAE,EAAE;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAC3B,MAAM,GAAG,CAAC;QACZ,CAAC,CACF,CAAC;QACF,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PukuError } from '../../core/error';
|
|
2
|
+
export type AccessToken = {
|
|
3
|
+
token: string;
|
|
4
|
+
/** Unix epoch seconds. `null` means no expiry (cache forever). */
|
|
5
|
+
expiresAt: number | null;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Mints or returns a cached access token.
|
|
9
|
+
*
|
|
10
|
+
* The optional `opts.forceRefresh` flag, set by {@link TokenCache.invalidate}
|
|
11
|
+
* after a 401, tells providers with on-disk caches (user_oauth, cachedExchange)
|
|
12
|
+
* to bypass their freshness short-circuit and always fetch fresh. Providers
|
|
13
|
+
* without a cache can ignore it.
|
|
14
|
+
*/
|
|
15
|
+
export type AccessTokenProvider = (opts?: {
|
|
16
|
+
forceRefresh?: boolean;
|
|
17
|
+
}) => Promise<AccessToken>;
|
|
18
|
+
export type IdentityTokenProvider = () => string | Promise<string>;
|
|
19
|
+
export type CredentialResult = {
|
|
20
|
+
provider: AccessTokenProvider;
|
|
21
|
+
extraHeaders: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* The `base_url` from the resolved config/profile, if any. The client
|
|
24
|
+
* applies this to outbound API requests when no explicit `baseURL` (constructor
|
|
25
|
+
* option or `PUKU_BASE_URL` env) was given, so a profile pointing at a
|
|
26
|
+
* non-default API host both mints its token against that host AND sends
|
|
27
|
+
* subsequent API requests there.
|
|
28
|
+
*/
|
|
29
|
+
baseURL?: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
/** Response body from `POST /v1/oauth/token`. */
|
|
32
|
+
export type TokenEndpointResponse = {
|
|
33
|
+
access_token?: string;
|
|
34
|
+
expires_in?: number;
|
|
35
|
+
refresh_token?: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const GRANT_TYPE_JWT_BEARER = "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
38
|
+
export declare const GRANT_TYPE_REFRESH_TOKEN = "refresh_token";
|
|
39
|
+
export declare const TOKEN_ENDPOINT = "/v1/oauth/token";
|
|
40
|
+
/**
|
|
41
|
+
* `puku-beta` value required on authenticated API requests using an
|
|
42
|
+
* OAuth bearer token, and on `refresh_token` grants against the token endpoint.
|
|
43
|
+
*/
|
|
44
|
+
export declare const OAUTH_API_BETA_HEADER = "oauth-2025-04-20";
|
|
45
|
+
/**
|
|
46
|
+
* `puku-beta` value required on jwt-bearer exchanges against the token
|
|
47
|
+
* endpoint. It routes the request to the federation service; it must NOT be
|
|
48
|
+
* sent on `refresh_token` grants, which are handled by a different backend.
|
|
49
|
+
*/
|
|
50
|
+
export declare const FEDERATION_BETA_HEADER = "oidc-federation-2026-04-01";
|
|
51
|
+
export declare const ADVISORY_REFRESH_THRESHOLD_IN_SECONDS = 120;
|
|
52
|
+
export declare const MANDATORY_REFRESH_THRESHOLD_IN_SECONDS = 30;
|
|
53
|
+
export declare const ADVISORY_REFRESH_BACKOFF_IN_SECONDS = 5;
|
|
54
|
+
/**
|
|
55
|
+
* Rejects base URLs that would cause a JWT assertion or refresh token to be
|
|
56
|
+
* sent over cleartext HTTP. Loopback hosts are allowed for local development.
|
|
57
|
+
*/
|
|
58
|
+
export declare function requireSecureTokenEndpoint(baseURL: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Reads the response body as text, parses it as a token-endpoint JSON
|
|
61
|
+
* response, validates `access_token` is present, and rejects a non-Bearer
|
|
62
|
+
* `token_type` when one is provided. Reads at most
|
|
63
|
+
* {@link MAX_TOKEN_RESPONSE_BYTES} from the body stream.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseTokenResponse(resp: Response, requestId: string | null): Promise<TokenEndpointResponse & {
|
|
66
|
+
access_token: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Returns a redacted copy of a token-endpoint error body for safe inclusion
|
|
70
|
+
* in an exception. Strings are truncated; objects keep only the RFC 6749
|
|
71
|
+
* §5.2 error fields.
|
|
72
|
+
*/
|
|
73
|
+
export declare function redactSensitive(body: unknown): unknown;
|
|
74
|
+
/**
|
|
75
|
+
* Best-effort safety check on a credentials file before reading it.
|
|
76
|
+
*
|
|
77
|
+
* On POSIX: resolves symlinks (so containerized deployments that mount the
|
|
78
|
+
* credential as a symlink to a tmpfs-backed file keep working), then rejects
|
|
79
|
+
* the resolved target if it is group- or world- readable or writable. A uid
|
|
80
|
+
* mismatch on the resolved target is surfaced via `onWarn` since
|
|
81
|
+
* root-written/app-read is common in init-container setups. No-op on Windows.
|
|
82
|
+
*/
|
|
83
|
+
export declare function checkCredentialsFileSafety(path: string, onWarn?: (msg: string) => void): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Atomically writes JSON to `targetPath` via a `.tmp` sibling + rename,
|
|
86
|
+
* with fsync on the file and (best-effort) on the parent directory.
|
|
87
|
+
* Creates the parent directory with mode 0700 and the file with mode 0600.
|
|
88
|
+
*/
|
|
89
|
+
export declare function writeCredentialsFileAtomic(targetPath: string, data: unknown): Promise<void>;
|
|
90
|
+
export declare class WorkloadIdentityError extends PukuError {
|
|
91
|
+
readonly statusCode: number | null;
|
|
92
|
+
readonly body: unknown;
|
|
93
|
+
readonly requestId: string | null;
|
|
94
|
+
constructor(message: string, statusCode?: number | null, body?: unknown, requestId?: string | null);
|
|
95
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { PukuError } from '../../core/error.js';
|
|
2
|
+
export const GRANT_TYPE_JWT_BEARER = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
|
|
3
|
+
export const GRANT_TYPE_REFRESH_TOKEN = 'refresh_token';
|
|
4
|
+
export const TOKEN_ENDPOINT = '/v1/oauth/token';
|
|
5
|
+
/**
|
|
6
|
+
* `puku-beta` value required on authenticated API requests using an
|
|
7
|
+
* OAuth bearer token, and on `refresh_token` grants against the token endpoint.
|
|
8
|
+
*/
|
|
9
|
+
export const OAUTH_API_BETA_HEADER = 'oauth-2025-04-20';
|
|
10
|
+
/**
|
|
11
|
+
* `puku-beta` value required on jwt-bearer exchanges against the token
|
|
12
|
+
* endpoint. It routes the request to the federation service; it must NOT be
|
|
13
|
+
* sent on `refresh_token` grants, which are handled by a different backend.
|
|
14
|
+
*/
|
|
15
|
+
export const FEDERATION_BETA_HEADER = 'oidc-federation-2026-04-01';
|
|
16
|
+
export const ADVISORY_REFRESH_THRESHOLD_IN_SECONDS = 120;
|
|
17
|
+
export const MANDATORY_REFRESH_THRESHOLD_IN_SECONDS = 30;
|
|
18
|
+
export const ADVISORY_REFRESH_BACKOFF_IN_SECONDS = 5;
|
|
19
|
+
const MAX_TOKEN_RESPONSE_BYTES = 1 << 20;
|
|
20
|
+
/**
|
|
21
|
+
* Rejects base URLs that would cause a JWT assertion or refresh token to be
|
|
22
|
+
* sent over cleartext HTTP. Loopback hosts are allowed for local development.
|
|
23
|
+
*/
|
|
24
|
+
export function requireSecureTokenEndpoint(baseURL) {
|
|
25
|
+
if (!baseURL)
|
|
26
|
+
return;
|
|
27
|
+
let u;
|
|
28
|
+
try {
|
|
29
|
+
u = new URL(baseURL);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
throw new WorkloadIdentityError(`Invalid token endpoint base URL "${baseURL}": ${err}`);
|
|
33
|
+
}
|
|
34
|
+
if (u.protocol === 'https:')
|
|
35
|
+
return;
|
|
36
|
+
// WHATWG URL.hostname returns bracketed IPv6 ("[::1]"); Go's net/url strips them.
|
|
37
|
+
const host = u.hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
38
|
+
if (u.protocol === 'http:' && (host === 'localhost' || host === '127.0.0.1' || host === '::1')) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
throw new WorkloadIdentityError(`Refusing to send credential over non-https token endpoint "${baseURL}"`);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reads the response body as text, parses it as a token-endpoint JSON
|
|
45
|
+
* response, validates `access_token` is present, and rejects a non-Bearer
|
|
46
|
+
* `token_type` when one is provided. Reads at most
|
|
47
|
+
* {@link MAX_TOKEN_RESPONSE_BYTES} from the body stream.
|
|
48
|
+
*/
|
|
49
|
+
export async function parseTokenResponse(resp, requestId) {
|
|
50
|
+
const text = await readLimitedText(resp);
|
|
51
|
+
let data;
|
|
52
|
+
try {
|
|
53
|
+
data = JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new WorkloadIdentityError(`Token endpoint returned non-JSON response (status ${resp.status})`, resp.status, redactSensitive(text), requestId);
|
|
57
|
+
}
|
|
58
|
+
if (!data.access_token) {
|
|
59
|
+
throw new WorkloadIdentityError(`Token endpoint response missing access_token: ${JSON.stringify(redactSensitive(data))}`, resp.status, redactSensitive(data), requestId);
|
|
60
|
+
}
|
|
61
|
+
if (data.token_type && data.token_type.toLowerCase() !== 'bearer') {
|
|
62
|
+
throw new WorkloadIdentityError(`Token endpoint response: unsupported token_type "${data.token_type}" (want Bearer)`, resp.status, redactSensitive(data), requestId);
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
const MAX_ERROR_BODY_CHARS = 2000;
|
|
67
|
+
// RFC 6749 §5.2 standard error-response fields. Anything else in a token
|
|
68
|
+
// endpoint error body is potentially echoed input (assertion, refresh_token,
|
|
69
|
+
// access_token, …) and is dropped rather than allowlisted-with-exceptions.
|
|
70
|
+
const SAFE_ERROR_KEYS = new Set(['error', 'error_description', 'error_uri']);
|
|
71
|
+
/**
|
|
72
|
+
* Returns a redacted copy of a token-endpoint error body for safe inclusion
|
|
73
|
+
* in an exception. Strings are truncated; objects keep only the RFC 6749
|
|
74
|
+
* §5.2 error fields.
|
|
75
|
+
*/
|
|
76
|
+
export function redactSensitive(body) {
|
|
77
|
+
if (body == null)
|
|
78
|
+
return body;
|
|
79
|
+
if (typeof body === 'string') {
|
|
80
|
+
let parsed;
|
|
81
|
+
try {
|
|
82
|
+
parsed = JSON.parse(body);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
if (body.length <= MAX_ERROR_BODY_CHARS)
|
|
86
|
+
return body;
|
|
87
|
+
return body.slice(0, MAX_ERROR_BODY_CHARS) + `... <${body.length - MAX_ERROR_BODY_CHARS} more chars>`;
|
|
88
|
+
}
|
|
89
|
+
return JSON.stringify(redactSensitive(parsed));
|
|
90
|
+
}
|
|
91
|
+
if (typeof body === 'object' && !Array.isArray(body)) {
|
|
92
|
+
const out = {};
|
|
93
|
+
for (const [k, v] of Object.entries(body)) {
|
|
94
|
+
if (SAFE_ERROR_KEYS.has(k))
|
|
95
|
+
out[k] = v;
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Best-effort safety check on a credentials file before reading it.
|
|
103
|
+
*
|
|
104
|
+
* On POSIX: resolves symlinks (so containerized deployments that mount the
|
|
105
|
+
* credential as a symlink to a tmpfs-backed file keep working), then rejects
|
|
106
|
+
* the resolved target if it is group- or world- readable or writable. A uid
|
|
107
|
+
* mismatch on the resolved target is surfaced via `onWarn` since
|
|
108
|
+
* root-written/app-read is common in init-container setups. No-op on Windows.
|
|
109
|
+
*/
|
|
110
|
+
export async function checkCredentialsFileSafety(path, onWarn = (m) => console.warn(`puku-ai/sdk: ${m}`)) {
|
|
111
|
+
if (typeof process === 'undefined' || process.platform === 'win32')
|
|
112
|
+
return;
|
|
113
|
+
const { fs } = await import('../../internal/node.js');
|
|
114
|
+
let resolved = path;
|
|
115
|
+
let st;
|
|
116
|
+
try {
|
|
117
|
+
resolved = await fs.promises.realpath(path);
|
|
118
|
+
st = await fs.promises.stat(resolved);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return; // ENOENT etc — let the subsequent read surface a precise error
|
|
122
|
+
}
|
|
123
|
+
const mode = st.mode & 0o777;
|
|
124
|
+
// 0o022 = group/world write; 0o044 = group/world read.
|
|
125
|
+
if (mode & 0o022) {
|
|
126
|
+
throw new WorkloadIdentityError(`Credentials file at ${resolved} is group/world-writable (mode 0o${mode.toString(8)}); ` +
|
|
127
|
+
`this allows other local users to plant tokens. Run \`chmod 600 ${resolved}\`.`);
|
|
128
|
+
}
|
|
129
|
+
if (mode & 0o044) {
|
|
130
|
+
throw new WorkloadIdentityError(`Credentials file at ${resolved} is group/world-readable (mode 0o${mode.toString(8)}); ` +
|
|
131
|
+
`run \`chmod 600 ${resolved}\` before retrying.`);
|
|
132
|
+
}
|
|
133
|
+
if (typeof process.getuid === 'function' && st.uid !== process.getuid()) {
|
|
134
|
+
onWarn(`credentials file at ${resolved} is owned by uid ${st.uid} (current process uid ${process.getuid()}); ` + `verify this is intentional.`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Atomically writes JSON to `targetPath` via a `.tmp` sibling + rename,
|
|
139
|
+
* with fsync on the file and (best-effort) on the parent directory.
|
|
140
|
+
* Creates the parent directory with mode 0700 and the file with mode 0600.
|
|
141
|
+
*/
|
|
142
|
+
export async function writeCredentialsFileAtomic(targetPath, data) {
|
|
143
|
+
const { fs, path } = await import('../../internal/node.js');
|
|
144
|
+
const dir = path.dirname(targetPath);
|
|
145
|
+
await fs.promises.mkdir(dir, { recursive: true, mode: 0o700 });
|
|
146
|
+
// Unique temp name avoids two concurrent writers (different processes or
|
|
147
|
+
// SDK instances) racing on the same '.tmp' sibling and corrupting each
|
|
148
|
+
// other's bytes mid-write before the rename.
|
|
149
|
+
const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
150
|
+
try {
|
|
151
|
+
const fh = await fs.promises.open(tmpPath, 'w', 0o600);
|
|
152
|
+
try {
|
|
153
|
+
await fh.writeFile(JSON.stringify(data, null, 2));
|
|
154
|
+
await fh.sync();
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
await fh.close();
|
|
158
|
+
}
|
|
159
|
+
await fs.promises.rename(tmpPath, targetPath);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
// Don't leak the temp file if anything between create and rename failed.
|
|
163
|
+
await fs.promises.unlink(tmpPath).catch(() => { });
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
// fsync the parent directory so the rename survives a crash.
|
|
167
|
+
try {
|
|
168
|
+
const dirFh = await fs.promises.open(dir, 'r');
|
|
169
|
+
try {
|
|
170
|
+
await dirFh.sync();
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
await dirFh.close();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
// Directory fsync is best-effort (unsupported on some platforms, e.g. Windows).
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function readLimitedText(resp) {
|
|
181
|
+
if (!resp.body) {
|
|
182
|
+
return '';
|
|
183
|
+
}
|
|
184
|
+
const reader = resp.body.getReader();
|
|
185
|
+
const chunks = [];
|
|
186
|
+
let received = 0;
|
|
187
|
+
for (;;) {
|
|
188
|
+
const { done, value } = await reader.read();
|
|
189
|
+
if (done)
|
|
190
|
+
break;
|
|
191
|
+
if (received + value.length > MAX_TOKEN_RESPONSE_BYTES) {
|
|
192
|
+
const remaining = MAX_TOKEN_RESPONSE_BYTES - received;
|
|
193
|
+
if (remaining > 0)
|
|
194
|
+
chunks.push(value.subarray(0, remaining));
|
|
195
|
+
await reader.cancel();
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
chunks.push(value);
|
|
199
|
+
received += value.length;
|
|
200
|
+
}
|
|
201
|
+
let merged;
|
|
202
|
+
if (chunks.length === 1) {
|
|
203
|
+
merged = chunks[0];
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
merged = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
207
|
+
let offset = 0;
|
|
208
|
+
for (const c of chunks) {
|
|
209
|
+
merged.set(c, offset);
|
|
210
|
+
offset += c.length;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return new TextDecoder('utf-8').decode(merged);
|
|
214
|
+
}
|
|
215
|
+
export class WorkloadIdentityError extends PukuError {
|
|
216
|
+
statusCode;
|
|
217
|
+
body;
|
|
218
|
+
requestId;
|
|
219
|
+
constructor(message, statusCode = null, body = null, requestId = null) {
|
|
220
|
+
super(message);
|
|
221
|
+
this.statusCode = statusCode;
|
|
222
|
+
this.body = body;
|
|
223
|
+
this.requestId = requestId;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/vendor/lib/credentials/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAwC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,6CAA6C,CAAC;AACnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAEnE,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,CAAC;AACzD,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAA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B,YAA2B,IAAI;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Fetch } from '../../internal/builtin-types';
|
|
2
|
+
import type { AccessTokenProvider } from './types';
|
|
3
|
+
export type UserOAuthConfig = {
|
|
4
|
+
credentialsPath: string;
|
|
5
|
+
clientId?: string | undefined;
|
|
6
|
+
baseURL: string;
|
|
7
|
+
fetch: Fetch;
|
|
8
|
+
userAgent?: string | undefined;
|
|
9
|
+
onSafetyWarning?: ((msg: string) => void) | undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Reads a user-oauth credential file. Returns the cached access token while
|
|
13
|
+
* fresh; on expiry performs a `refresh_token` grant and writes the new
|
|
14
|
+
* tokens back to the credentials file (atomic replace, fsync'd).
|
|
15
|
+
*
|
|
16
|
+
* If `clientId` is empty, the access token is treated as static — the
|
|
17
|
+
* credentials file is read on every call but no refresh is attempted, and
|
|
18
|
+
* an expired token without a `refresh_token` raises.
|
|
19
|
+
*/
|
|
20
|
+
export declare function userOAuthProvider(config: UserOAuthConfig): AccessTokenProvider;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CREDENTIALS_FILE_VERSION } from '../../core/credentials.js';
|
|
2
|
+
import { GRANT_TYPE_REFRESH_TOKEN, MANDATORY_REFRESH_THRESHOLD_IN_SECONDS, OAUTH_API_BETA_HEADER, TOKEN_ENDPOINT, WorkloadIdentityError, checkCredentialsFileSafety, parseTokenResponse, redactSensitive, requireSecureTokenEndpoint, writeCredentialsFileAtomic, } from './types.js';
|
|
3
|
+
import { nowAsSeconds } from '../../internal/utils/time.js';
|
|
4
|
+
import { VERSION } from '../../version.js';
|
|
5
|
+
/**
|
|
6
|
+
* Reads a user-oauth credential file. Returns the cached access token while
|
|
7
|
+
* fresh; on expiry performs a `refresh_token` grant and writes the new
|
|
8
|
+
* tokens back to the credentials file (atomic replace, fsync'd).
|
|
9
|
+
*
|
|
10
|
+
* If `clientId` is empty, the access token is treated as static — the
|
|
11
|
+
* credentials file is read on every call but no refresh is attempted, and
|
|
12
|
+
* an expired token without a `refresh_token` raises.
|
|
13
|
+
*/
|
|
14
|
+
export function userOAuthProvider(config) {
|
|
15
|
+
return async (opts) => {
|
|
16
|
+
const { fs } = await import('../../internal/node.js');
|
|
17
|
+
await checkCredentialsFileSafety(config.credentialsPath, config.onSafetyWarning);
|
|
18
|
+
let raw;
|
|
19
|
+
try {
|
|
20
|
+
raw = await fs.promises.readFile(config.credentialsPath, 'utf-8');
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new WorkloadIdentityError(`Credentials file not found at ${config.credentialsPath}: ${err}`);
|
|
24
|
+
}
|
|
25
|
+
let creds;
|
|
26
|
+
try {
|
|
27
|
+
creds = JSON.parse(raw);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
throw new WorkloadIdentityError(`Credentials file at ${config.credentialsPath} is not valid JSON: ${err}`);
|
|
31
|
+
}
|
|
32
|
+
const accessToken = creds.access_token;
|
|
33
|
+
if (!accessToken) {
|
|
34
|
+
throw new WorkloadIdentityError(`Credentials file at ${config.credentialsPath} must include 'access_token'`);
|
|
35
|
+
}
|
|
36
|
+
// Return cached token if still fresh (or no expiry info), unless the
|
|
37
|
+
// caller is forcing a refresh after a 401 — then go straight to refresh
|
|
38
|
+
// even if the file's expires_at still looks valid.
|
|
39
|
+
const expiresAt = creds.expires_at;
|
|
40
|
+
if (!opts?.forceRefresh &&
|
|
41
|
+
(expiresAt == null || nowAsSeconds() < expiresAt - MANDATORY_REFRESH_THRESHOLD_IN_SECONDS)) {
|
|
42
|
+
return { token: accessToken, expiresAt: expiresAt ?? null };
|
|
43
|
+
}
|
|
44
|
+
const refreshToken = creds.refresh_token;
|
|
45
|
+
if (!config.clientId || !refreshToken) {
|
|
46
|
+
throw new WorkloadIdentityError(`Access token at ${config.credentialsPath} has expired and no refresh is available ` +
|
|
47
|
+
`(client_id ${config.clientId ? 'set' : 'empty'}, refresh_token ${refreshToken ? 'set' : 'empty'})`);
|
|
48
|
+
}
|
|
49
|
+
requireSecureTokenEndpoint(config.baseURL);
|
|
50
|
+
const body = {
|
|
51
|
+
grant_type: GRANT_TYPE_REFRESH_TOKEN,
|
|
52
|
+
refresh_token: refreshToken,
|
|
53
|
+
client_id: config.clientId,
|
|
54
|
+
};
|
|
55
|
+
const url = `${config.baseURL}${TOKEN_ENDPOINT}`;
|
|
56
|
+
let resp;
|
|
57
|
+
try {
|
|
58
|
+
resp = await config.fetch(url, {
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
'puku-beta': OAUTH_API_BETA_HEADER,
|
|
63
|
+
'User-Agent': config.userAgent || `puku-ai-sdk-typescript/${VERSION} userOAuthProvider`,
|
|
64
|
+
},
|
|
65
|
+
body: JSON.stringify(body),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
throw new WorkloadIdentityError(`User OAuth refresh failed to reach token endpoint: ${err}`);
|
|
70
|
+
}
|
|
71
|
+
const requestId = resp.headers.get('Request-Id');
|
|
72
|
+
if (!resp.ok) {
|
|
73
|
+
const text = await resp.text().catch(() => '');
|
|
74
|
+
throw new WorkloadIdentityError(`User OAuth refresh failed (HTTP ${resp.status}): ${redactSensitive(text)}`, resp.status, redactSensitive(text), requestId);
|
|
75
|
+
}
|
|
76
|
+
const data = await parseTokenResponse(resp, requestId);
|
|
77
|
+
const expiresIn = Number(data.expires_in);
|
|
78
|
+
if (!Number.isFinite(expiresIn)) {
|
|
79
|
+
throw new WorkloadIdentityError(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(redactSensitive(data))}`, resp.status, redactSensitive(data), requestId);
|
|
80
|
+
}
|
|
81
|
+
const newExpiresAt = nowAsSeconds() + expiresIn;
|
|
82
|
+
const newRefreshToken = data.refresh_token || refreshToken;
|
|
83
|
+
await writeCredentialsFileAtomic(config.credentialsPath, {
|
|
84
|
+
...creds,
|
|
85
|
+
version: CREDENTIALS_FILE_VERSION,
|
|
86
|
+
type: 'oauth_token',
|
|
87
|
+
access_token: data.access_token,
|
|
88
|
+
expires_at: newExpiresAt,
|
|
89
|
+
refresh_token: newRefreshToken,
|
|
90
|
+
});
|
|
91
|
+
return { token: data.access_token, expiresAt: newExpiresAt };
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=user-oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-oauth.js","sourceRoot":"","sources":["../../../../src/vendor/lib/credentials/user-oauth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAwB,MAAM,wBAAwB,CAAC;AAExF,OAAO,EACL,wBAAwB,EACxB,sCAAsC,EACtC,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWxC;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACvD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAE,EAAE,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAEnD,MAAM,0BAA0B,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;QAEjF,IAAI,GAAW,CAAC;QAChB,IAAI,CAAC;YACH,GAAG,GAAG,MAAM,EAAE,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I,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACvD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,qBAAqB,CAC7B,8DAA8D,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE,EACrG,IAAI,CAAC,MAAM,EACX,eAAe,CAAC,IAAI,CAAC,EACrB,SAAS,CACV,CAAC;QACJ,CAAC;QACD,MAAM,YAAY,GAAG,YAAY,EAAE,GAAG,SAAS,CAAC;QAChD,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,IAAI,YAAY,CAAC;QAE3D,MAAM,0BAA0B,CAAC,MAAM,CAAC,eAAe,EAAE;YACvD,GAAG,KAAK;YACR,OAAO,EAAE,wBAAwB;YACjC,IAAI,EAAE,aAAa;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,YAAY;YACxB,aAAa,EAAE,eAAe;SAC/B,CAAC,CAAC;QAEH,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/vendor/lib/credentials.ts"],"names":[],"mappings":"AACA,OAAO,EAA4C,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { WorkPoller, type WorkPollerOptions, POLL_BLOCK_MS, backoff, jitter, isStatus, is4xx, isFatal4xx, } from './poller';
|
|
2
|
+
export { EnvironmentWorker, type EnvironmentWorkerOptions, type EnvironmentWorkerTools, type HandleItemOptions, } from './worker';
|
|
3
|
+
export { SessionToolRunner, type SessionToolRunnerOptions, type DispatchedToolCall, MANAGED_AGENTS_BETA, DEFAULT_MAX_IDLE_MS, } from '../tools/SessionToolRunner';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { WorkPoller, POLL_BLOCK_MS, backoff, jitter, isStatus, is4xx, isFatal4xx, } from './poller.js';
|
|
2
|
+
export { EnvironmentWorker, } from './worker.js';
|
|
3
|
+
export { SessionToolRunner, MANAGED_AGENTS_BETA, DEFAULT_MAX_IDLE_MS, } from '../tools/SessionToolRunner.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/vendor/lib/environments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,aAAa,EACb,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,UAAU,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,iBAAiB,GAIlB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,iBAAiB,EAGjB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC"}
|