@acosmi/sdk-ts 2.19.1 → 2.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/browser/index.mjs +23 -8
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.cjs +2 -0
- 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 +2 -0
- package/dist/node/adapters/anthropic.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +13 -5
- 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 +13 -5
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-C2oh157O.d.cts → index-CqxPqbsl.d.cts} +2 -1
- package/dist/node/{index-C2oh157O.d.ts → index-CqxPqbsl.d.ts} +2 -1
- package/dist/node/index.cjs +22 -7
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +10 -5
- package/dist/node/index.d.ts +10 -5
- package/dist/node/index.mjs +23 -8
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{openai-CMrvATF_.d.cts → openai-Ce85qh14.d.cts} +2 -2
- package/dist/node/{openai-BbCQOMNY.d.ts → openai-mkTSir6E.d.ts} +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 2.19.3
|
|
2
|
+
|
|
3
|
+
- Surface gateway stream failures on the OpenAI line instead of crashing on them. The gateway emits its structured error frame with `event: failed`, but the OpenAI branch of `chatMessagesStream` captured the SSE event name and never read it, so the error frame reached the OpenAI chunk converter and died on `chunk.choices.length` - replacing the real upstream cause with an unrelated TypeError. That branch now routes `failed` and `error` frames through the existing `parseStreamError`, exactly as `chatStreamWithUsage` already did.
|
|
4
|
+
- Guard the OpenAI stream converter against data frames that carry no `choices` (gateway error frames, usage-only tail frames from some compatible implementations), and mark `OpenAIStreamChunk.choices` optional - the type declared it required while the wire genuinely omits it, which is where the TypeError came from.
|
|
5
|
+
- No behavior change on the Anthropic line, and no change to request building.
|
|
6
|
+
|
|
7
|
+
## 2.19.2
|
|
8
|
+
|
|
9
|
+
- Preserve catalog-supported low, medium, xhigh, and max thinking levels through both chat adapters.
|
|
10
|
+
- Deliver explicit thinking-off requests to compatible OpenAI gateways.
|
|
11
|
+
- Keep the credential and request-ID behavior shipped in 2.19.1.
|
|
12
|
+
|
|
1
13
|
# Changelog
|
|
2
14
|
|
|
3
15
|
All notable changes to `@acosmi/sdk-ts` will be documented in this file.
|
package/dist/browser/index.mjs
CHANGED
|
@@ -132,12 +132,13 @@ function parseSettlement(ev) {
|
|
|
132
132
|
callRemaining: s.callRemaining ?? -1
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
var BucketClassCommercial, BucketClassGeneric, ThinkingOff, ThinkingHigh, ThinkingMax, ThinkingHighMinMaxTokens, ThinkingMaxFallbackMaxTokens, ServerToolTypeWebSearch;
|
|
135
|
+
var BucketClassCommercial, BucketClassGeneric, ThinkingOff, ThinkingLow, ThinkingHigh, ThinkingMax, ThinkingHighMinMaxTokens, ThinkingMaxFallbackMaxTokens, ServerToolTypeWebSearch;
|
|
136
136
|
var init_types = __esm({
|
|
137
137
|
"src/models/types.ts"() {
|
|
138
138
|
BucketClassCommercial = "COMMERCIAL";
|
|
139
139
|
BucketClassGeneric = "GENERIC";
|
|
140
140
|
ThinkingOff = "off";
|
|
141
|
+
ThinkingLow = "low";
|
|
141
142
|
ThinkingHigh = "high";
|
|
142
143
|
ThinkingMax = "max";
|
|
143
144
|
ThinkingHighMinMaxTokens = 32e3;
|
|
@@ -504,6 +505,8 @@ function resolveThinkingLevel(body, req, caps) {
|
|
|
504
505
|
}
|
|
505
506
|
if (caps.supports_effort) {
|
|
506
507
|
let effortLevel = "high";
|
|
508
|
+
if (level === "low") effortLevel = "low";
|
|
509
|
+
if (level === "medium" || level === "xhigh") effortLevel = level;
|
|
507
510
|
if (level === ThinkingMax && caps.supports_max_effort) {
|
|
508
511
|
effortLevel = "max";
|
|
509
512
|
}
|
|
@@ -681,23 +684,28 @@ __export(openai_exports, {
|
|
|
681
684
|
resolveOpenAIReasoningEffort: () => resolveOpenAIReasoningEffort,
|
|
682
685
|
resolveOpenAIResponseFormat: () => resolveOpenAIResponseFormat
|
|
683
686
|
});
|
|
684
|
-
function resolveOpenAIReasoningEffort(req) {
|
|
687
|
+
function resolveOpenAIReasoningEffort(req, supportsMax = false) {
|
|
685
688
|
if (req.effort && req.effort.level !== "") {
|
|
686
689
|
switch (req.effort.level) {
|
|
687
690
|
case "low":
|
|
688
691
|
case "medium":
|
|
689
692
|
case "high":
|
|
693
|
+
case "xhigh":
|
|
690
694
|
return req.effort.level;
|
|
691
695
|
case "max":
|
|
692
|
-
return "high";
|
|
696
|
+
return supportsMax ? "max" : "high";
|
|
693
697
|
}
|
|
694
698
|
}
|
|
695
699
|
if (req.thinking) {
|
|
696
700
|
switch (req.thinking.level) {
|
|
701
|
+
case "low":
|
|
702
|
+
case "medium":
|
|
703
|
+
case "xhigh":
|
|
704
|
+
return req.thinking.level;
|
|
697
705
|
case ThinkingHigh:
|
|
698
706
|
return "high";
|
|
699
707
|
case ThinkingMax:
|
|
700
|
-
return "high";
|
|
708
|
+
return supportsMax ? "max" : "high";
|
|
701
709
|
case ThinkingOff:
|
|
702
710
|
return "";
|
|
703
711
|
}
|
|
@@ -901,10 +909,13 @@ var init_openai = __esm({
|
|
|
901
909
|
if (req.tools != null) {
|
|
902
910
|
body["tools"] = req.tools;
|
|
903
911
|
}
|
|
904
|
-
const eff = resolveOpenAIReasoningEffort(req);
|
|
912
|
+
const eff = resolveOpenAIReasoningEffort(req, _caps.supports_max_effort);
|
|
905
913
|
if (eff !== "") {
|
|
906
914
|
body["reasoning_effort"] = eff;
|
|
907
915
|
}
|
|
916
|
+
if (_caps.supports_thinking && req.thinking?.level === ThinkingOff) {
|
|
917
|
+
body["thinking"] = { type: "disabled" };
|
|
918
|
+
}
|
|
908
919
|
if (req.speed && req.speed !== "") {
|
|
909
920
|
body["speed"] = req.speed;
|
|
910
921
|
}
|
|
@@ -1073,7 +1084,7 @@ var init_openai = __esm({
|
|
|
1073
1084
|
throw new Error(`parse openai stream chunk: ${e instanceof Error ? e.message : String(e)}`);
|
|
1074
1085
|
}
|
|
1075
1086
|
const events = [];
|
|
1076
|
-
if (chunk.choices.length === 0) {
|
|
1087
|
+
if (!Array.isArray(chunk.choices) || chunk.choices.length === 0) {
|
|
1077
1088
|
return { events, done: false };
|
|
1078
1089
|
}
|
|
1079
1090
|
const choice = chunk.choices[0];
|
|
@@ -4344,13 +4355,17 @@ var Client = class _Client {
|
|
|
4344
4355
|
}
|
|
4345
4356
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
4346
4357
|
const converter = newOpenAIStreamConverter();
|
|
4358
|
+
let currentEvent = "";
|
|
4347
4359
|
for await (const line of iterSSELines(resp.body)) {
|
|
4348
4360
|
notifyUpstreamActivity(onUpstreamActivity);
|
|
4349
4361
|
if (isSSECommentLine(line)) continue;
|
|
4350
4362
|
if (line.startsWith("event:")) {
|
|
4351
|
-
line.slice("event:".length).trim();
|
|
4363
|
+
currentEvent = line.slice("event:".length).trim();
|
|
4352
4364
|
} else if (line.startsWith("data:")) {
|
|
4353
4365
|
const data = line.slice("data:".length).trim();
|
|
4366
|
+
if (currentEvent === "failed" || currentEvent === "error") {
|
|
4367
|
+
throw parseStreamError(data);
|
|
4368
|
+
}
|
|
4354
4369
|
const { events, done } = converter.convert(data);
|
|
4355
4370
|
for (const ev of events) yield ev;
|
|
4356
4371
|
if (done) return;
|
|
@@ -8869,6 +8884,6 @@ function brandCredential(c) {
|
|
|
8869
8884
|
return c;
|
|
8870
8885
|
}
|
|
8871
8886
|
|
|
8872
|
-
export { AGENT_RUN_META_TITLE, AGENT_RUN_META_WORKSPACE, ALL_INTEGRATION_STATUS, ALL_PLATFORMS, ALL_REGIONS, AgentRunStreamError, AgentRunsClient, AnthropicAdapter, AudienceEnum, BillingModeEnum, BucketClassCommercial, BucketClassGeneric, BusinessError, CHAT_REQUEST_TIMEOUT_MS, ChatBridgeClient, Client, ComplianceClient, CompliancePollError, CrabCodeByokClient, DEFAULT_API_TIMEOUT_MS, DEFAULT_GATEWAY_BASE_URL, LocalStorageTokenStore as DefaultBrowserTokenStore, 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, GATEWAY_REQUEST_ID_HEADER, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OAuthTokenEndpointError, OpenAIAdapter, OrderTerminalError, ProductFamilyEnum, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, RegionScopeEnum, ScopeAI, ScopeAccount, ScopeAgentAccessManage, ScopeChatBridge, ScopeChatBridgeRead, ScopeChatBridgeRotate, ScopeChatBridgeWrite, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeRemoteControl, ScopeRemoteControlAgentRun, ScopeRemoteControlPermissionResponse, ScopeRemoteControlSessionControl, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, agentAccessScopes, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, asCredentialRef, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, chatBridgeScopes, classifyComplianceError, classifySourcesEvent, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, getWindowLimitStreamDetails, isBillingConfirmable, isChannelInboundEvent, isComplianceBusinessError, isComplianceTerminalError, isContinuableWindowLimitError, isIntegrationStatus, isInvalidGrantError, isPlatform, isRegion, isSSECommentLine, isSSLError, isTerminalRemoteEvent, isUserAccessTokenRejected, isValidTokenSet, isWindowLimitError, isWindowLimitStreamError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, normalizeGatewayBaseURL, normalizeOverrideBaseURL, parseNotificationEvent, parseRemoteControlEvent, parseSettlement, parseSourcesEvent, readGatewayErrorContract, refreshToken, register, registerWebOAuthClient, remoteControlScopes, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
|
8887
|
+
export { AGENT_RUN_META_TITLE, AGENT_RUN_META_WORKSPACE, ALL_INTEGRATION_STATUS, ALL_PLATFORMS, ALL_REGIONS, AgentRunStreamError, AgentRunsClient, AnthropicAdapter, AudienceEnum, BillingModeEnum, BucketClassCommercial, BucketClassGeneric, BusinessError, CHAT_REQUEST_TIMEOUT_MS, ChatBridgeClient, Client, ComplianceClient, CompliancePollError, CrabCodeByokClient, DEFAULT_API_TIMEOUT_MS, DEFAULT_GATEWAY_BASE_URL, LocalStorageTokenStore as DefaultBrowserTokenStore, 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, GATEWAY_REQUEST_ID_HEADER, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OAuthTokenEndpointError, OpenAIAdapter, OrderTerminalError, ProductFamilyEnum, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, RegionScopeEnum, ScopeAI, ScopeAccount, ScopeAgentAccessManage, ScopeChatBridge, ScopeChatBridgeRead, ScopeChatBridgeRotate, ScopeChatBridgeWrite, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeRemoteControl, ScopeRemoteControlAgentRun, ScopeRemoteControlPermissionResponse, ScopeRemoteControlSessionControl, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingLow, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, agentAccessScopes, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, asCredentialRef, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, chatBridgeScopes, classifyComplianceError, classifySourcesEvent, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, getWindowLimitStreamDetails, isBillingConfirmable, isChannelInboundEvent, isComplianceBusinessError, isComplianceTerminalError, isContinuableWindowLimitError, isIntegrationStatus, isInvalidGrantError, isPlatform, isRegion, isSSECommentLine, isSSLError, isTerminalRemoteEvent, isUserAccessTokenRejected, isValidTokenSet, isWindowLimitError, isWindowLimitStreamError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, normalizeGatewayBaseURL, normalizeOverrideBaseURL, parseNotificationEvent, parseRemoteControlEvent, parseSettlement, parseSourcesEvent, readGatewayErrorContract, refreshToken, register, registerWebOAuthClient, remoteControlScopes, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
|
8873
8888
|
//# sourceMappingURL=index.mjs.map
|
|
8874
8889
|
//# sourceMappingURL=index.mjs.map
|