@acosmi/sdk-ts 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -1
- package/README.md +130 -25
- package/dist/browser/index.mjs +46 -6
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +46 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.cjs +11 -2
- package/dist/node/adapters/anthropic.cjs.map +1 -1
- package/dist/node/adapters/anthropic.d.cts +1 -1
- package/dist/node/adapters/anthropic.d.ts +1 -1
- package/dist/node/adapters/anthropic.mjs +11 -2
- package/dist/node/adapters/anthropic.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +3 -0
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.d.cts +2 -2
- package/dist/node/adapters/openai.d.ts +2 -2
- package/dist/node/adapters/openai.mjs +3 -0
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-nvLKgCm9.d.cts → index-Bah9A83R.d.cts} +1 -1
- package/dist/node/{index-nvLKgCm9.d.ts → index-Bah9A83R.d.ts} +1 -1
- package/dist/node/{index-DEA6LXw6.d.cts → index-C9X5Yuyk.d.cts} +10 -1
- package/dist/node/{index-DEA6LXw6.d.ts → index-C9X5Yuyk.d.ts} +10 -1
- package/dist/node/index.cjs +48 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +34 -8
- package/dist/node/index.d.ts +34 -8
- package/dist/node/index.mjs +46 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{openai-vfUUgdvL.d.ts → openai-BqKAhbSc.d.ts} +2 -2
- package/dist/node/{openai-BDodfhsG.d.cts → openai-C_UKadSX.d.cts} +2 -2
- package/dist/node/sanitize/index.d.cts +1 -1
- package/dist/node/sanitize/index.d.ts +1 -1
- package/docs/compliance.md +13 -8
- package/examples/auth-oauth-flow.ts +6 -2
- package/examples/compliance-evidence-timestamp.ts +3 -1
- package/examples/core-chat.ts +5 -2
- package/package.json +2 -2
package/dist/node/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { M as ManagedModel, Q as QuotaSummary,
|
|
4
|
-
export { B as BucketClassCommercial,
|
|
5
|
-
import { M as MinimalSanitizeConfig } from './index-
|
|
6
|
-
export {
|
|
1
|
+
import { a as AnthropicResponse } from './openai-C_UKadSX.cjs';
|
|
2
|
+
export { A as AnthropicContentBlock, b as AnthropicUsage, O as OpenAIAdapter, d as anthropicResponseTextContent, e as anthropicResponseThinkingContent, f as anthropicResponseToolUseBlocks } from './openai-C_UKadSX.cjs';
|
|
3
|
+
import { M as ManagedModel, Q as QuotaSummary, h as ModelCapabilities, e as ChatRequest, P as ProviderAdapter, f as ChatResponse, l as StreamEvent, k as SourcesEvent, m as StreamSettlement, I as InputModality } from './index-C9X5Yuyk.cjs';
|
|
4
|
+
export { B as BucketClassCommercial, a as BucketClassGeneric, b as BucketInfo, c as BucketRow, C as ChatContentBlock, d as ChatMessage, g as ChatUsage, E as EffortConfig, G as GeoLoc, O as OutputConfig, i as ProviderFormat, S as ServerTool, j as ServerToolTypeWebSearch, T as ThinkingConfig, n as ThinkingHigh, o as ThinkingHighMinMaxTokens, p as ThinkingMax, q as ThinkingMaxFallbackMaxTokens, r as ThinkingOff, W as WebSearchConfig, s as WebSearchSource, t as bucketInfoIsCommercial, u as bucketRowIsCommercial, v as getAdapter, w as getAdapterForModel, x as newThinkingConfig, y as newWebSearchTool, z as parseSettlement, A as parseSourcesEvent } from './index-C9X5Yuyk.cjs';
|
|
5
|
+
import { M as MinimalSanitizeConfig } from './index-Bah9A83R.cjs';
|
|
6
|
+
export { A as sanitize } from './index-Bah9A83R.cjs';
|
|
7
7
|
export { AnthropicAdapter } from './adapters/anthropic.cjs';
|
|
8
8
|
|
|
9
9
|
/** 权益余额 (聚合) */
|
|
@@ -289,7 +289,10 @@ interface AuthorizeResult {
|
|
|
289
289
|
* 3. 接收回调拿到 authorization code
|
|
290
290
|
* 4. 返回 code 供后续 token 交换
|
|
291
291
|
*
|
|
292
|
-
* 浏览器环境会抛错
|
|
292
|
+
* 浏览器环境会抛错 (无 loopback HTTP server)。
|
|
293
|
+
* 浏览器侧 (v1.4.0+) 请改用本文件下方的 Web OAuth 原语:
|
|
294
|
+
* createWebAuthorizationRequest + completeWebAuthorizationRequest
|
|
295
|
+
* (SDK 负责 PKCE / state 校验; popup / redirect handler 由调用方实现)
|
|
293
296
|
*/
|
|
294
297
|
declare function authorize(meta: ServerMetadata, clientID: string, scopes: string[], opts?: LoginOptions & {
|
|
295
298
|
handler?: (e: LoginEvent) => void;
|
|
@@ -1511,6 +1514,29 @@ declare function buildBetas(caps: ModelCapabilities, req: ChatRequest): string[]
|
|
|
1511
1514
|
/** 合并两个字符串数组并去重, 保留顺序 */
|
|
1512
1515
|
declare function uniqueMerge(base: string[], extra: string[]): string[];
|
|
1513
1516
|
|
|
1517
|
+
/** maxEndUserIdLength 与上游 DeepSeek 官方文档对齐。 */
|
|
1518
|
+
declare const maxEndUserIdLength = 512;
|
|
1519
|
+
/**
|
|
1520
|
+
* 检查 endUserId 是否符合规范 (字符集 + 长度)。
|
|
1521
|
+
* 空串视为合法 (表示未设置), 返回 null。
|
|
1522
|
+
*
|
|
1523
|
+
* 网关侧 sanitizer 在收到非空但校验失败的值时会 drop 并 metric, 不阻塞请求;
|
|
1524
|
+
* 但 caller 在自有业务侧拿到来源 (如 DB 内部 id) 后, 推荐先调用本函数明确语义。
|
|
1525
|
+
*
|
|
1526
|
+
* @returns 错误信息字符串, 或 null 表示合法
|
|
1527
|
+
*/
|
|
1528
|
+
declare function validateEndUserId(s: string | undefined | null): string | null;
|
|
1529
|
+
/**
|
|
1530
|
+
* 识别 SSE 协议中的注释行 (":<text>"), 如 ": keep-alive"。
|
|
1531
|
+
*
|
|
1532
|
+
* 上游 (如 DeepSeek) 在开始推理前可能持续发送 SSE 注释作为保活;
|
|
1533
|
+
* 注释行不构成事件, SDK 解析器必须显式跳过, 否则未来若 else-branch 把
|
|
1534
|
+
* 未匹配行误送 JSON.parse 会回归出 parse error。
|
|
1535
|
+
*
|
|
1536
|
+
* 严格定义: 行的首字节是 ":". 不放宽允许行首空白 (SSE 规范不允许)。
|
|
1537
|
+
*/
|
|
1538
|
+
declare function isSSECommentLine(line: string): boolean;
|
|
1539
|
+
|
|
1514
1540
|
declare module '@acosmi/sdk-ts' {
|
|
1515
1541
|
interface Client {
|
|
1516
1542
|
/** 查询当前用户的权益余额 (聚合) */
|
|
@@ -3384,4 +3410,4 @@ declare module '@acosmi/sdk-ts' {
|
|
|
3384
3410
|
}
|
|
3385
3411
|
}
|
|
3386
3412
|
|
|
3387
|
-
export { type APIResponse, type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRunOptions, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type ApiClientRef, type ApproveSealApprovalQuery, type AuthorizeResult, type BalanceDetail, type BillingPreflightResult, type BlockMeta, type BrowserRefreshMode, type BugReportResult, type BugView, BusinessError, type CancelSealApprovalQuery, type CertificationStatus, ChatRequest, ChatResponse, Client, type ClientRegistration, type ComplianceAssetType, type ComplianceBillingDisplayStatus, type ComplianceCapability, ComplianceClient, type ComplianceClientErrorCode, type ComplianceDigestSource, type ComplianceEnvelopeStatus, type ComplianceErrorInfo, type ComplianceErrorKey, type ComplianceHashAlgorithm, CompliancePollError, type CompliancePollOptions, type CompliancePrivacyLevel, type ComplianceProviderRequestStatus, type ComplianceProviderStatus, type ComplianceReport, type ComplianceScope, type ComplianceSealApprovalStatus, type ComplianceTimestampVerificationStatus, type ComplianceWriteOptions, type Config, type ConsumeRecord, type ConsumeRecordPage, type ContractTemplateField, type ContractTemplateFieldType, type ContractTemplatePageItem, type ContractTemplateResp, type ContractTemplateStatus, type ContractTemplateVersion, type CreateContractTemplateRequest, type CreateEvidenceAssetRequest, type CreateH5SigningUrlRequest, type CreateReportRequest, type CreateSigningEnvelopeRequest, type CreateWebAuthorizationRequestOptions, DefaultRetryPolicy, type DeviceRegistration, type EntitlementBalance, type EntitlementItem, type EnvelopeContractItem, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, type EvidenceAsset, type EvidenceAssetPageItem, type EvidencePackage, type EvidencePackagePageItem, type FeatureGateState, type FeatureGateStatus, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, type GateQuota, type GenerateSkillRequest, type GenerateSkillResult, HTTPError, type IdempotencyKey, IdempotencyKeyHeader, InMemoryTokenStore, InputModality, type IssueTimestampRequest, type ListContractTemplatesRequest, type ListEvidenceAssetsRequest, type ListEvidencePackagesRequest, type ListOperationsRequest, type ListReportsRequest, type ListSealApprovalsRequest, type ListSealUsesRequest, type ListSigningEnvelopesRequest, type ListTimestampsRequest, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, type ModelBucket, type ModelByQuotaResponse, ModelCapabilities, type ModelCoefficient, ModelNotFoundError, NetworkError, type Notification, type NotificationList, type NotificationPreference, type NotificationUnreadCount, type OAuthMetadataProfile, type OpenAIChatChoice, type OpenAIChatMessage, type OpenAIChatResponse, type OpenAIFunctionCall, type OpenAIStreamChoice, type OpenAIStreamChunk, type OpenAIStreamDelta, type OpenAIStreamToolCall, type OpenAIToolCall, type OpenAIUsage, type OperationDetail, type OperationId, type OperationPageItem, type OperationSource, type OperationStatus, type OptimizeSkillRequest, type OptimizeSkillResult, type Order, type OrderStatus, OrderTerminalError, type PageRequest, type PageResult, type PayPayload, type PrincipalRef, ProviderAdapter, type ProviderRequestStatus, type ProviderRequestStatusView, type PublicEvidenceVerifyResult, QuotaSummary, RETRY_ADVICE_REASONS, RateLimitError, type RegisterWebOAuthClientOptions, type RejectSealApprovalQuery, type ReportDownload, type ReportPageItem, type RetryAdvice, type RetryAdviceReason, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, type SealApproval, type SealApprovalPageItem, type SealUsePageItem, type ServerMetadata, type SignEnvelopeRequest, type SigningEnvelope, type SigningEnvelopePageItem, type SkillBrowseListResponse, type SkillBrowseResponse, type SkillStoreItem, type SkillStoreListItem, type SkillStoreQuery, type SkillSummary, type SortDirection, SourcesEvent, type StepUpStatus, StreamError, StreamEvent, StreamSettlement, type SubmitSealApprovalRequest, type TenantRef, type TimestampPageItem, type TimestampToken, type TimestampVerifyResult, type TokenPackage, type TokenResponse, type TokenSet, type TokenStore, type ToolListResponse, type ToolProvider, type ToolView, type Transaction, type TsaProvider, type TsaStats, type UpdateContractTemplateRequest, type UploadContractTemplatePdfRequest, type VerifyStatus, type VerifyTimestampRequest, type VoidEnvelopeRequest, type WSConfig, type WSEvent, type WalletStats, type WebAuthorizationCallbackParams, type WebAuthorizationPending, type WebAuthorizationRequest, type YudaoPageResult, allScopes, apiResponseBusinessError, apiResponseGetMessage, authorize, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newTokenSet, parseNotificationEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, skillScopes, tokenSetIsExpired, uniqueMerge };
|
|
3413
|
+
export { type APIResponse, type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRunOptions, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type ApiClientRef, type ApproveSealApprovalQuery, type AuthorizeResult, type BalanceDetail, type BillingPreflightResult, type BlockMeta, type BrowserRefreshMode, type BugReportResult, type BugView, BusinessError, type CancelSealApprovalQuery, type CertificationStatus, ChatRequest, ChatResponse, Client, type ClientRegistration, type ComplianceAssetType, type ComplianceBillingDisplayStatus, type ComplianceCapability, ComplianceClient, type ComplianceClientErrorCode, type ComplianceDigestSource, type ComplianceEnvelopeStatus, type ComplianceErrorInfo, type ComplianceErrorKey, type ComplianceHashAlgorithm, CompliancePollError, type CompliancePollOptions, type CompliancePrivacyLevel, type ComplianceProviderRequestStatus, type ComplianceProviderStatus, type ComplianceReport, type ComplianceScope, type ComplianceSealApprovalStatus, type ComplianceTimestampVerificationStatus, type ComplianceWriteOptions, type Config, type ConsumeRecord, type ConsumeRecordPage, type ContractTemplateField, type ContractTemplateFieldType, type ContractTemplatePageItem, type ContractTemplateResp, type ContractTemplateStatus, type ContractTemplateVersion, type CreateContractTemplateRequest, type CreateEvidenceAssetRequest, type CreateH5SigningUrlRequest, type CreateReportRequest, type CreateSigningEnvelopeRequest, type CreateWebAuthorizationRequestOptions, DefaultRetryPolicy, type DeviceRegistration, type EntitlementBalance, type EntitlementItem, type EnvelopeContractItem, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, type EvidenceAsset, type EvidenceAssetPageItem, type EvidencePackage, type EvidencePackagePageItem, type FeatureGateState, type FeatureGateStatus, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, type GateQuota, type GenerateSkillRequest, type GenerateSkillResult, HTTPError, type IdempotencyKey, IdempotencyKeyHeader, InMemoryTokenStore, InputModality, type IssueTimestampRequest, type ListContractTemplatesRequest, type ListEvidenceAssetsRequest, type ListEvidencePackagesRequest, type ListOperationsRequest, type ListReportsRequest, type ListSealApprovalsRequest, type ListSealUsesRequest, type ListSigningEnvelopesRequest, type ListTimestampsRequest, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, type ModelBucket, type ModelByQuotaResponse, ModelCapabilities, type ModelCoefficient, ModelNotFoundError, NetworkError, type Notification, type NotificationList, type NotificationPreference, type NotificationUnreadCount, type OAuthMetadataProfile, type OpenAIChatChoice, type OpenAIChatMessage, type OpenAIChatResponse, type OpenAIFunctionCall, type OpenAIStreamChoice, type OpenAIStreamChunk, type OpenAIStreamDelta, type OpenAIStreamToolCall, type OpenAIToolCall, type OpenAIUsage, type OperationDetail, type OperationId, type OperationPageItem, type OperationSource, type OperationStatus, type OptimizeSkillRequest, type OptimizeSkillResult, type Order, type OrderStatus, OrderTerminalError, type PageRequest, type PageResult, type PayPayload, type PrincipalRef, ProviderAdapter, type ProviderRequestStatus, type ProviderRequestStatusView, type PublicEvidenceVerifyResult, QuotaSummary, RETRY_ADVICE_REASONS, RateLimitError, type RegisterWebOAuthClientOptions, type RejectSealApprovalQuery, type ReportDownload, type ReportPageItem, type RetryAdvice, type RetryAdviceReason, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, type SealApproval, type SealApprovalPageItem, type SealUsePageItem, type ServerMetadata, type SignEnvelopeRequest, type SigningEnvelope, type SigningEnvelopePageItem, type SkillBrowseListResponse, type SkillBrowseResponse, type SkillStoreItem, type SkillStoreListItem, type SkillStoreQuery, type SkillSummary, type SortDirection, SourcesEvent, type StepUpStatus, StreamError, StreamEvent, StreamSettlement, type SubmitSealApprovalRequest, type TenantRef, type TimestampPageItem, type TimestampToken, type TimestampVerifyResult, type TokenPackage, type TokenResponse, type TokenSet, type TokenStore, type ToolListResponse, type ToolProvider, type ToolView, type Transaction, type TsaProvider, type TsaStats, type UpdateContractTemplateRequest, type UploadContractTemplatePdfRequest, type VerifyStatus, type VerifyTimestampRequest, type VoidEnvelopeRequest, type WSConfig, type WSEvent, type WalletStats, type WebAuthorizationCallbackParams, type WebAuthorizationPending, type WebAuthorizationRequest, type YudaoPageResult, allScopes, apiResponseBusinessError, apiResponseGetMessage, authorize, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSECommentLine, isSSLError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newTokenSet, parseNotificationEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { M as ManagedModel, Q as QuotaSummary,
|
|
4
|
-
export { B as BucketClassCommercial,
|
|
5
|
-
import { M as MinimalSanitizeConfig } from './index-
|
|
6
|
-
export {
|
|
1
|
+
import { a as AnthropicResponse } from './openai-BqKAhbSc.js';
|
|
2
|
+
export { A as AnthropicContentBlock, b as AnthropicUsage, O as OpenAIAdapter, d as anthropicResponseTextContent, e as anthropicResponseThinkingContent, f as anthropicResponseToolUseBlocks } from './openai-BqKAhbSc.js';
|
|
3
|
+
import { M as ManagedModel, Q as QuotaSummary, h as ModelCapabilities, e as ChatRequest, P as ProviderAdapter, f as ChatResponse, l as StreamEvent, k as SourcesEvent, m as StreamSettlement, I as InputModality } from './index-C9X5Yuyk.js';
|
|
4
|
+
export { B as BucketClassCommercial, a as BucketClassGeneric, b as BucketInfo, c as BucketRow, C as ChatContentBlock, d as ChatMessage, g as ChatUsage, E as EffortConfig, G as GeoLoc, O as OutputConfig, i as ProviderFormat, S as ServerTool, j as ServerToolTypeWebSearch, T as ThinkingConfig, n as ThinkingHigh, o as ThinkingHighMinMaxTokens, p as ThinkingMax, q as ThinkingMaxFallbackMaxTokens, r as ThinkingOff, W as WebSearchConfig, s as WebSearchSource, t as bucketInfoIsCommercial, u as bucketRowIsCommercial, v as getAdapter, w as getAdapterForModel, x as newThinkingConfig, y as newWebSearchTool, z as parseSettlement, A as parseSourcesEvent } from './index-C9X5Yuyk.js';
|
|
5
|
+
import { M as MinimalSanitizeConfig } from './index-Bah9A83R.js';
|
|
6
|
+
export { A as sanitize } from './index-Bah9A83R.js';
|
|
7
7
|
export { AnthropicAdapter } from './adapters/anthropic.js';
|
|
8
8
|
|
|
9
9
|
/** 权益余额 (聚合) */
|
|
@@ -289,7 +289,10 @@ interface AuthorizeResult {
|
|
|
289
289
|
* 3. 接收回调拿到 authorization code
|
|
290
290
|
* 4. 返回 code 供后续 token 交换
|
|
291
291
|
*
|
|
292
|
-
* 浏览器环境会抛错
|
|
292
|
+
* 浏览器环境会抛错 (无 loopback HTTP server)。
|
|
293
|
+
* 浏览器侧 (v1.4.0+) 请改用本文件下方的 Web OAuth 原语:
|
|
294
|
+
* createWebAuthorizationRequest + completeWebAuthorizationRequest
|
|
295
|
+
* (SDK 负责 PKCE / state 校验; popup / redirect handler 由调用方实现)
|
|
293
296
|
*/
|
|
294
297
|
declare function authorize(meta: ServerMetadata, clientID: string, scopes: string[], opts?: LoginOptions & {
|
|
295
298
|
handler?: (e: LoginEvent) => void;
|
|
@@ -1511,6 +1514,29 @@ declare function buildBetas(caps: ModelCapabilities, req: ChatRequest): string[]
|
|
|
1511
1514
|
/** 合并两个字符串数组并去重, 保留顺序 */
|
|
1512
1515
|
declare function uniqueMerge(base: string[], extra: string[]): string[];
|
|
1513
1516
|
|
|
1517
|
+
/** maxEndUserIdLength 与上游 DeepSeek 官方文档对齐。 */
|
|
1518
|
+
declare const maxEndUserIdLength = 512;
|
|
1519
|
+
/**
|
|
1520
|
+
* 检查 endUserId 是否符合规范 (字符集 + 长度)。
|
|
1521
|
+
* 空串视为合法 (表示未设置), 返回 null。
|
|
1522
|
+
*
|
|
1523
|
+
* 网关侧 sanitizer 在收到非空但校验失败的值时会 drop 并 metric, 不阻塞请求;
|
|
1524
|
+
* 但 caller 在自有业务侧拿到来源 (如 DB 内部 id) 后, 推荐先调用本函数明确语义。
|
|
1525
|
+
*
|
|
1526
|
+
* @returns 错误信息字符串, 或 null 表示合法
|
|
1527
|
+
*/
|
|
1528
|
+
declare function validateEndUserId(s: string | undefined | null): string | null;
|
|
1529
|
+
/**
|
|
1530
|
+
* 识别 SSE 协议中的注释行 (":<text>"), 如 ": keep-alive"。
|
|
1531
|
+
*
|
|
1532
|
+
* 上游 (如 DeepSeek) 在开始推理前可能持续发送 SSE 注释作为保活;
|
|
1533
|
+
* 注释行不构成事件, SDK 解析器必须显式跳过, 否则未来若 else-branch 把
|
|
1534
|
+
* 未匹配行误送 JSON.parse 会回归出 parse error。
|
|
1535
|
+
*
|
|
1536
|
+
* 严格定义: 行的首字节是 ":". 不放宽允许行首空白 (SSE 规范不允许)。
|
|
1537
|
+
*/
|
|
1538
|
+
declare function isSSECommentLine(line: string): boolean;
|
|
1539
|
+
|
|
1514
1540
|
declare module '@acosmi/sdk-ts' {
|
|
1515
1541
|
interface Client {
|
|
1516
1542
|
/** 查询当前用户的权益余额 (聚合) */
|
|
@@ -3384,4 +3410,4 @@ declare module '@acosmi/sdk-ts' {
|
|
|
3384
3410
|
}
|
|
3385
3411
|
}
|
|
3386
3412
|
|
|
3387
|
-
export { type APIResponse, type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRunOptions, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type ApiClientRef, type ApproveSealApprovalQuery, type AuthorizeResult, type BalanceDetail, type BillingPreflightResult, type BlockMeta, type BrowserRefreshMode, type BugReportResult, type BugView, BusinessError, type CancelSealApprovalQuery, type CertificationStatus, ChatRequest, ChatResponse, Client, type ClientRegistration, type ComplianceAssetType, type ComplianceBillingDisplayStatus, type ComplianceCapability, ComplianceClient, type ComplianceClientErrorCode, type ComplianceDigestSource, type ComplianceEnvelopeStatus, type ComplianceErrorInfo, type ComplianceErrorKey, type ComplianceHashAlgorithm, CompliancePollError, type CompliancePollOptions, type CompliancePrivacyLevel, type ComplianceProviderRequestStatus, type ComplianceProviderStatus, type ComplianceReport, type ComplianceScope, type ComplianceSealApprovalStatus, type ComplianceTimestampVerificationStatus, type ComplianceWriteOptions, type Config, type ConsumeRecord, type ConsumeRecordPage, type ContractTemplateField, type ContractTemplateFieldType, type ContractTemplatePageItem, type ContractTemplateResp, type ContractTemplateStatus, type ContractTemplateVersion, type CreateContractTemplateRequest, type CreateEvidenceAssetRequest, type CreateH5SigningUrlRequest, type CreateReportRequest, type CreateSigningEnvelopeRequest, type CreateWebAuthorizationRequestOptions, DefaultRetryPolicy, type DeviceRegistration, type EntitlementBalance, type EntitlementItem, type EnvelopeContractItem, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, type EvidenceAsset, type EvidenceAssetPageItem, type EvidencePackage, type EvidencePackagePageItem, type FeatureGateState, type FeatureGateStatus, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, type GateQuota, type GenerateSkillRequest, type GenerateSkillResult, HTTPError, type IdempotencyKey, IdempotencyKeyHeader, InMemoryTokenStore, InputModality, type IssueTimestampRequest, type ListContractTemplatesRequest, type ListEvidenceAssetsRequest, type ListEvidencePackagesRequest, type ListOperationsRequest, type ListReportsRequest, type ListSealApprovalsRequest, type ListSealUsesRequest, type ListSigningEnvelopesRequest, type ListTimestampsRequest, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, type ModelBucket, type ModelByQuotaResponse, ModelCapabilities, type ModelCoefficient, ModelNotFoundError, NetworkError, type Notification, type NotificationList, type NotificationPreference, type NotificationUnreadCount, type OAuthMetadataProfile, type OpenAIChatChoice, type OpenAIChatMessage, type OpenAIChatResponse, type OpenAIFunctionCall, type OpenAIStreamChoice, type OpenAIStreamChunk, type OpenAIStreamDelta, type OpenAIStreamToolCall, type OpenAIToolCall, type OpenAIUsage, type OperationDetail, type OperationId, type OperationPageItem, type OperationSource, type OperationStatus, type OptimizeSkillRequest, type OptimizeSkillResult, type Order, type OrderStatus, OrderTerminalError, type PageRequest, type PageResult, type PayPayload, type PrincipalRef, ProviderAdapter, type ProviderRequestStatus, type ProviderRequestStatusView, type PublicEvidenceVerifyResult, QuotaSummary, RETRY_ADVICE_REASONS, RateLimitError, type RegisterWebOAuthClientOptions, type RejectSealApprovalQuery, type ReportDownload, type ReportPageItem, type RetryAdvice, type RetryAdviceReason, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, type SealApproval, type SealApprovalPageItem, type SealUsePageItem, type ServerMetadata, type SignEnvelopeRequest, type SigningEnvelope, type SigningEnvelopePageItem, type SkillBrowseListResponse, type SkillBrowseResponse, type SkillStoreItem, type SkillStoreListItem, type SkillStoreQuery, type SkillSummary, type SortDirection, SourcesEvent, type StepUpStatus, StreamError, StreamEvent, StreamSettlement, type SubmitSealApprovalRequest, type TenantRef, type TimestampPageItem, type TimestampToken, type TimestampVerifyResult, type TokenPackage, type TokenResponse, type TokenSet, type TokenStore, type ToolListResponse, type ToolProvider, type ToolView, type Transaction, type TsaProvider, type TsaStats, type UpdateContractTemplateRequest, type UploadContractTemplatePdfRequest, type VerifyStatus, type VerifyTimestampRequest, type VoidEnvelopeRequest, type WSConfig, type WSEvent, type WalletStats, type WebAuthorizationCallbackParams, type WebAuthorizationPending, type WebAuthorizationRequest, type YudaoPageResult, allScopes, apiResponseBusinessError, apiResponseGetMessage, authorize, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newTokenSet, parseNotificationEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, skillScopes, tokenSetIsExpired, uniqueMerge };
|
|
3413
|
+
export { type APIResponse, type AgentRun, type AgentRunArtifact, type AgentRunArtifactList, type AgentRunArtifactPolicy, type AgentRunCreateRequest, type AgentRunCreateResponse, type AgentRunDownload, type AgentRunErrorPayload, type AgentRunLocalContextPolicy, type AgentRunLocalToolHandler, type AgentRunLocalToolHandlerContext, type AgentRunLocalToolResult, type AgentRunRunOptions, type AgentRunSettlement, type AgentRunStatus, AgentRunStreamError, type AgentRunStreamEvent, type AgentRunStreamOptions, type AgentRunUsage, type AgentRunWithLocalToolsOptions, AgentRunsClient, AnthropicResponse, type ApiClientRef, type ApproveSealApprovalQuery, type AuthorizeResult, type BalanceDetail, type BillingPreflightResult, type BlockMeta, type BrowserRefreshMode, type BugReportResult, type BugView, BusinessError, type CancelSealApprovalQuery, type CertificationStatus, ChatRequest, ChatResponse, Client, type ClientRegistration, type ComplianceAssetType, type ComplianceBillingDisplayStatus, type ComplianceCapability, ComplianceClient, type ComplianceClientErrorCode, type ComplianceDigestSource, type ComplianceEnvelopeStatus, type ComplianceErrorInfo, type ComplianceErrorKey, type ComplianceHashAlgorithm, CompliancePollError, type CompliancePollOptions, type CompliancePrivacyLevel, type ComplianceProviderRequestStatus, type ComplianceProviderStatus, type ComplianceReport, type ComplianceScope, type ComplianceSealApprovalStatus, type ComplianceTimestampVerificationStatus, type ComplianceWriteOptions, type Config, type ConsumeRecord, type ConsumeRecordPage, type ContractTemplateField, type ContractTemplateFieldType, type ContractTemplatePageItem, type ContractTemplateResp, type ContractTemplateStatus, type ContractTemplateVersion, type CreateContractTemplateRequest, type CreateEvidenceAssetRequest, type CreateH5SigningUrlRequest, type CreateReportRequest, type CreateSigningEnvelopeRequest, type CreateWebAuthorizationRequestOptions, DefaultRetryPolicy, type DeviceRegistration, type EntitlementBalance, type EntitlementItem, type EnvelopeContractItem, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, type EvidenceAsset, type EvidenceAssetPageItem, type EvidencePackage, type EvidencePackagePageItem, type FeatureGateState, type FeatureGateStatus, FileTokenStore, type FilterStatus, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, type GateQuota, type GenerateSkillRequest, type GenerateSkillResult, HTTPError, type IdempotencyKey, IdempotencyKeyHeader, InMemoryTokenStore, InputModality, type IssueTimestampRequest, type ListContractTemplatesRequest, type ListEvidenceAssetsRequest, type ListEvidencePackagesRequest, type ListOperationsRequest, type ListReportsRequest, type ListSealApprovalsRequest, type ListSealUsesRequest, type ListSigningEnvelopesRequest, type ListTimestampsRequest, LocalStorageTokenStore, type LoginErrCode, type LoginEvent, type LoginEventType, type LoginOptions, ManagedModel, type ModelBucket, type ModelByQuotaResponse, ModelCapabilities, type ModelCoefficient, ModelNotFoundError, NetworkError, type Notification, type NotificationList, type NotificationPreference, type NotificationUnreadCount, type OAuthMetadataProfile, type OpenAIChatChoice, type OpenAIChatMessage, type OpenAIChatResponse, type OpenAIFunctionCall, type OpenAIStreamChoice, type OpenAIStreamChunk, type OpenAIStreamDelta, type OpenAIStreamToolCall, type OpenAIToolCall, type OpenAIUsage, type OperationDetail, type OperationId, type OperationPageItem, type OperationSource, type OperationStatus, type OptimizeSkillRequest, type OptimizeSkillResult, type Order, type OrderStatus, OrderTerminalError, type PageRequest, type PageResult, type PayPayload, type PrincipalRef, ProviderAdapter, type ProviderRequestStatus, type ProviderRequestStatusView, type PublicEvidenceVerifyResult, QuotaSummary, RETRY_ADVICE_REASONS, RateLimitError, type RegisterWebOAuthClientOptions, type RejectSealApprovalQuery, type ReportDownload, type ReportPageItem, type RetryAdvice, type RetryAdviceReason, type RetryPolicy, type RetryRequestInfo, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, type SealApproval, type SealApprovalPageItem, type SealUsePageItem, type ServerMetadata, type SignEnvelopeRequest, type SigningEnvelope, type SigningEnvelopePageItem, type SkillBrowseListResponse, type SkillBrowseResponse, type SkillStoreItem, type SkillStoreListItem, type SkillStoreQuery, type SkillSummary, type SortDirection, SourcesEvent, type StepUpStatus, StreamError, StreamEvent, StreamSettlement, type SubmitSealApprovalRequest, type TenantRef, type TimestampPageItem, type TimestampToken, type TimestampVerifyResult, type TokenPackage, type TokenResponse, type TokenSet, type TokenStore, type ToolListResponse, type ToolProvider, type ToolView, type Transaction, type TsaProvider, type TsaStats, type UpdateContractTemplateRequest, type UploadContractTemplatePdfRequest, type VerifyStatus, type VerifyTimestampRequest, type VoidEnvelopeRequest, type WSConfig, type WSEvent, type WalletStats, type WebAuthorizationCallbackParams, type WebAuthorizationPending, type WebAuthorizationRequest, type YudaoPageResult, allScopes, apiResponseBusinessError, apiResponseGetMessage, authorize, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSECommentLine, isSSLError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newTokenSet, parseNotificationEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
package/dist/node/index.mjs
CHANGED
|
@@ -365,8 +365,17 @@ var init_anthropic = __esm({
|
|
|
365
365
|
body["effort"] = req.effort;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
if (req.metadata) {
|
|
369
|
-
|
|
368
|
+
if (req.metadata || req.endUserId && req.endUserId !== "") {
|
|
369
|
+
const meta = {};
|
|
370
|
+
if (req.metadata) {
|
|
371
|
+
for (const [k, v] of Object.entries(req.metadata)) {
|
|
372
|
+
meta[k] = v;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (req.endUserId && req.endUserId !== "" && meta["user_id"] === void 0) {
|
|
376
|
+
meta["user_id"] = req.endUserId;
|
|
377
|
+
}
|
|
378
|
+
body["metadata"] = meta;
|
|
370
379
|
}
|
|
371
380
|
const allTools = [];
|
|
372
381
|
if (req.tools != null) {
|
|
@@ -710,6 +719,9 @@ var init_openai = __esm({
|
|
|
710
719
|
body[k] = v;
|
|
711
720
|
}
|
|
712
721
|
}
|
|
722
|
+
if (req.endUserId && req.endUserId !== "") {
|
|
723
|
+
body["user_id"] = req.endUserId;
|
|
724
|
+
}
|
|
713
725
|
if (req.stream === true) {
|
|
714
726
|
body["stream_options"] = { include_usage: true };
|
|
715
727
|
}
|
|
@@ -1773,6 +1785,30 @@ function extractAnthropicBlockMeta(eventType, data, blockTypeMap) {
|
|
|
1773
1785
|
// src/core/client.ts
|
|
1774
1786
|
init_openai();
|
|
1775
1787
|
|
|
1788
|
+
// src/models/enduser.ts
|
|
1789
|
+
var maxEndUserIdLength = 512;
|
|
1790
|
+
function validateEndUserId(s) {
|
|
1791
|
+
if (!s) return null;
|
|
1792
|
+
if (s.length > maxEndUserIdLength) {
|
|
1793
|
+
return `endUserId length ${s.length} > ${maxEndUserIdLength}`;
|
|
1794
|
+
}
|
|
1795
|
+
for (let i = 0; i < s.length; i++) {
|
|
1796
|
+
const c = s.charCodeAt(i);
|
|
1797
|
+
const ok = c >= 97 && c <= 122 || // a-z
|
|
1798
|
+
c >= 65 && c <= 90 || // A-Z
|
|
1799
|
+
c >= 48 && c <= 57 || // 0-9
|
|
1800
|
+
c === 95 || // _
|
|
1801
|
+
c === 45;
|
|
1802
|
+
if (!ok) {
|
|
1803
|
+
return `endUserId contains invalid char code 0x${c.toString(16)} at offset ${i} (allowed: [a-zA-Z0-9_-])`;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
function isSSECommentLine(line) {
|
|
1809
|
+
return line.length > 0 && line.charCodeAt(0) === 58;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1776
1812
|
// src/core/http.ts
|
|
1777
1813
|
init_errors();
|
|
1778
1814
|
var maxDownloadSize = 50 * 1024 * 1024;
|
|
@@ -1963,6 +1999,7 @@ var FilterStatusUnknown = "";
|
|
|
1963
1999
|
var ErrOAuthCORSBlocked = "oauth_cors_blocked";
|
|
1964
2000
|
var ErrRefreshProxyFailed = "refresh_proxy_failed";
|
|
1965
2001
|
var ErrTokenExpired = "token_expired";
|
|
2002
|
+
var CHAT_REQUEST_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
1966
2003
|
function newDeferred() {
|
|
1967
2004
|
let resolve;
|
|
1968
2005
|
let reject;
|
|
@@ -2556,7 +2593,7 @@ var Client = class _Client {
|
|
|
2556
2593
|
*/
|
|
2557
2594
|
async chat(modelID, req, signal) {
|
|
2558
2595
|
req.stream = false;
|
|
2559
|
-
const ctl = withRequestTimeout(
|
|
2596
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2560
2597
|
try {
|
|
2561
2598
|
const { body, adapter } = await this.buildChatRequest(modelID, req, ctl.signal);
|
|
2562
2599
|
const endpoint = `/managed-models/${encodeURIComponent(modelID)}${adapter.endpointSuffix()}`;
|
|
@@ -2603,7 +2640,7 @@ var Client = class _Client {
|
|
|
2603
2640
|
}
|
|
2604
2641
|
async chatMessagesAnthropic(modelID, req, adapter, signal) {
|
|
2605
2642
|
req.stream = false;
|
|
2606
|
-
const ctl = withRequestTimeout(
|
|
2643
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2607
2644
|
try {
|
|
2608
2645
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2609
2646
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2640,7 +2677,7 @@ var Client = class _Client {
|
|
|
2640
2677
|
}
|
|
2641
2678
|
async chatMessagesOpenAI(modelID, req, adapter, signal) {
|
|
2642
2679
|
req.stream = false;
|
|
2643
|
-
const ctl = withRequestTimeout(
|
|
2680
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2644
2681
|
try {
|
|
2645
2682
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2646
2683
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2721,6 +2758,7 @@ var Client = class _Client {
|
|
|
2721
2758
|
}
|
|
2722
2759
|
let currentEvent = "";
|
|
2723
2760
|
for await (const line of iterSSELines(resp.body)) {
|
|
2761
|
+
if (isSSECommentLine(line)) continue;
|
|
2724
2762
|
if (line.startsWith("event:")) {
|
|
2725
2763
|
currentEvent = line.slice("event:".length).trim();
|
|
2726
2764
|
} else if (line.startsWith("data:")) {
|
|
@@ -2786,6 +2824,7 @@ var Client = class _Client {
|
|
|
2786
2824
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
2787
2825
|
const converter = newOpenAIStreamConverter();
|
|
2788
2826
|
for await (const line of iterSSELines(resp.body)) {
|
|
2827
|
+
if (isSSECommentLine(line)) continue;
|
|
2789
2828
|
if (line.startsWith("event:")) {
|
|
2790
2829
|
line.slice("event:".length).trim();
|
|
2791
2830
|
} else if (line.startsWith("data:")) {
|
|
@@ -2799,6 +2838,7 @@ var Client = class _Client {
|
|
|
2799
2838
|
const blockTypeMap = /* @__PURE__ */ new Map();
|
|
2800
2839
|
let currentEvent = "";
|
|
2801
2840
|
for await (const line of iterSSELines(resp.body)) {
|
|
2841
|
+
if (isSSECommentLine(line)) continue;
|
|
2802
2842
|
if (line.startsWith("event:")) {
|
|
2803
2843
|
currentEvent = line.slice("event:".length).trim();
|
|
2804
2844
|
} else if (line.startsWith("data:")) {
|
|
@@ -6086,6 +6126,6 @@ Client.prototype.getBugReport = async function(bugID, signal) {
|
|
|
6086
6126
|
return resp.data;
|
|
6087
6127
|
};
|
|
6088
6128
|
|
|
6089
|
-
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge };
|
|
6129
|
+
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSECommentLine, isSSLError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
|
6090
6130
|
//# sourceMappingURL=index.mjs.map
|
|
6091
6131
|
//# sourceMappingURL=index.mjs.map
|