@acosmi/sdk-ts 1.1.0 → 1.2.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 +24 -0
- package/README.md +36 -4
- package/dist/browser/index.mjs +59 -4
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +59 -4
- package/dist/index.mjs.map +1 -1
- 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.map +1 -1
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.d.cts +1 -1
- package/dist/node/adapters/openai.d.ts +1 -1
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-BI8EgBXu.d.cts → index-B2Uuh21R.d.cts} +36 -1
- package/dist/node/{index-BI8EgBXu.d.ts → index-B2Uuh21R.d.ts} +36 -1
- package/dist/node/index.cjs +62 -3
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +46 -3
- package/dist/node/index.d.ts +46 -3
- package/dist/node/index.mjs +59 -4
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1013,6 +1013,45 @@ var init_adapters = __esm({
|
|
|
1013
1013
|
|
|
1014
1014
|
// src/index.ts
|
|
1015
1015
|
init_types();
|
|
1016
|
+
|
|
1017
|
+
// src/model-helpers.ts
|
|
1018
|
+
function modelSupportsInputModality(model, modality) {
|
|
1019
|
+
if (!model) return false;
|
|
1020
|
+
const mods = model.inputModalities;
|
|
1021
|
+
if (!Array.isArray(mods)) return false;
|
|
1022
|
+
return mods.includes(modality);
|
|
1023
|
+
}
|
|
1024
|
+
function modelSupportsImageInput(model) {
|
|
1025
|
+
return modelSupportsInputModality(model, "image");
|
|
1026
|
+
}
|
|
1027
|
+
function findFirstModelByInputModality(models, modality) {
|
|
1028
|
+
if (!Array.isArray(models)) return null;
|
|
1029
|
+
for (const m of models) {
|
|
1030
|
+
if (!m) continue;
|
|
1031
|
+
if (m.isEnabled === false) continue;
|
|
1032
|
+
if (!modelSupportsInputModality(m, modality)) continue;
|
|
1033
|
+
return m;
|
|
1034
|
+
}
|
|
1035
|
+
return null;
|
|
1036
|
+
}
|
|
1037
|
+
function findDesktopVisualUnderstandingModel(models) {
|
|
1038
|
+
if (!Array.isArray(models)) return null;
|
|
1039
|
+
const candidates = [];
|
|
1040
|
+
for (const m of models) {
|
|
1041
|
+
if (!m) continue;
|
|
1042
|
+
if (m.isEnabled === false) continue;
|
|
1043
|
+
if (m.capabilities?.supports_desktop_visual_understanding !== true) continue;
|
|
1044
|
+
if (!modelSupportsInputModality(m, "image")) continue;
|
|
1045
|
+
candidates.push(m);
|
|
1046
|
+
}
|
|
1047
|
+
if (candidates.length === 0) return null;
|
|
1048
|
+
for (const m of candidates) {
|
|
1049
|
+
if (m.isDefault === true) return m;
|
|
1050
|
+
}
|
|
1051
|
+
return candidates[0];
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// src/index.ts
|
|
1016
1055
|
init_adapters();
|
|
1017
1056
|
|
|
1018
1057
|
// src/auth.ts
|
|
@@ -2588,14 +2627,15 @@ var Client = class _Client {
|
|
|
2588
2627
|
null,
|
|
2589
2628
|
signal
|
|
2590
2629
|
);
|
|
2591
|
-
|
|
2630
|
+
const normalized = normalizeInputModalities(result.data);
|
|
2631
|
+
this.modelCache = normalized;
|
|
2592
2632
|
this.modelCacheTimeMs = Date.now();
|
|
2593
2633
|
let status = "";
|
|
2594
2634
|
if (headers) {
|
|
2595
2635
|
const h = headers.get("X-Entitlement-Filter-Status");
|
|
2596
2636
|
if (h) status = h;
|
|
2597
2637
|
}
|
|
2598
|
-
return { models:
|
|
2638
|
+
return { models: normalized, status };
|
|
2599
2639
|
}
|
|
2600
2640
|
/** 查询当前用户账户级权益总览 (v0.19+) */
|
|
2601
2641
|
async getQuotaSummary(signal) {
|
|
@@ -3228,9 +3268,24 @@ function zeroModelCapabilities() {
|
|
|
3228
3268
|
supports_token_efficient: false,
|
|
3229
3269
|
supports_redact_thinking: false,
|
|
3230
3270
|
max_input_tokens: 0,
|
|
3231
|
-
max_output_tokens: 0
|
|
3271
|
+
max_output_tokens: 0,
|
|
3272
|
+
supports_desktop_visual_understanding: false
|
|
3232
3273
|
};
|
|
3233
3274
|
}
|
|
3275
|
+
function normalizeInputModalities(models) {
|
|
3276
|
+
if (!Array.isArray(models)) return models;
|
|
3277
|
+
for (const m of models) {
|
|
3278
|
+
if (!m || typeof m !== "object") continue;
|
|
3279
|
+
if (Array.isArray(m.inputModalities)) continue;
|
|
3280
|
+
const snake = m.input_modalities;
|
|
3281
|
+
if (Array.isArray(snake)) {
|
|
3282
|
+
m.inputModalities = snake.filter(
|
|
3283
|
+
(v) => v === "text" || v === "image"
|
|
3284
|
+
);
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
return models;
|
|
3288
|
+
}
|
|
3234
3289
|
function withRequestTimeout(ms, parent) {
|
|
3235
3290
|
const ctl = new AbortController();
|
|
3236
3291
|
const timer = setTimeout(() => ctl.abort(), ms);
|
|
@@ -4576,6 +4631,6 @@ Client.prototype.getBugReport = async function(bugID, signal) {
|
|
|
4576
4631
|
return resp.data;
|
|
4577
4632
|
};
|
|
4578
4633
|
|
|
4579
|
-
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, DefaultRetryPolicy, ErrAuthDenied, ErrBrowserOpen, ErrDiscovery, ErrRegistration, ErrSSLProxy, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RateLimitError, ScopeAI, ScopeAccount, 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, commerceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, getAdapter, getAdapterForModel, isSSLError, modelScopes, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge };
|
|
4634
|
+
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, DefaultRetryPolicy, ErrAuthDenied, ErrBrowserOpen, ErrDiscovery, ErrRegistration, ErrSSLProxy, ErrTimeout, ErrTokenExchange, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProviderFormat, RateLimitError, ScopeAI, ScopeAccount, 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, commerceScopes, computeBackoff, defaultRetryable, defaultSafeToRetry, discover, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, getAdapter, getAdapterForModel, isSSLError, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge };
|
|
4580
4635
|
//# sourceMappingURL=index.mjs.map
|
|
4581
4636
|
//# sourceMappingURL=index.mjs.map
|