@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.
@@ -1015,6 +1015,45 @@ var init_adapters = __esm({
1015
1015
 
1016
1016
  // src/index.ts
1017
1017
  init_types();
1018
+
1019
+ // src/model-helpers.ts
1020
+ function modelSupportsInputModality(model, modality) {
1021
+ if (!model) return false;
1022
+ const mods = model.inputModalities;
1023
+ if (!Array.isArray(mods)) return false;
1024
+ return mods.includes(modality);
1025
+ }
1026
+ function modelSupportsImageInput(model) {
1027
+ return modelSupportsInputModality(model, "image");
1028
+ }
1029
+ function findFirstModelByInputModality(models, modality) {
1030
+ if (!Array.isArray(models)) return null;
1031
+ for (const m of models) {
1032
+ if (!m) continue;
1033
+ if (m.isEnabled === false) continue;
1034
+ if (!modelSupportsInputModality(m, modality)) continue;
1035
+ return m;
1036
+ }
1037
+ return null;
1038
+ }
1039
+ function findDesktopVisualUnderstandingModel(models) {
1040
+ if (!Array.isArray(models)) return null;
1041
+ const candidates = [];
1042
+ for (const m of models) {
1043
+ if (!m) continue;
1044
+ if (m.isEnabled === false) continue;
1045
+ if (m.capabilities?.supports_desktop_visual_understanding !== true) continue;
1046
+ if (!modelSupportsInputModality(m, "image")) continue;
1047
+ candidates.push(m);
1048
+ }
1049
+ if (candidates.length === 0) return null;
1050
+ for (const m of candidates) {
1051
+ if (m.isDefault === true) return m;
1052
+ }
1053
+ return candidates[0];
1054
+ }
1055
+
1056
+ // src/index.ts
1018
1057
  init_adapters();
1019
1058
 
1020
1059
  // src/auth.ts
@@ -2590,14 +2629,15 @@ var Client = class _Client {
2590
2629
  null,
2591
2630
  signal
2592
2631
  );
2593
- this.modelCache = result.data;
2632
+ const normalized = normalizeInputModalities(result.data);
2633
+ this.modelCache = normalized;
2594
2634
  this.modelCacheTimeMs = Date.now();
2595
2635
  let status = "";
2596
2636
  if (headers) {
2597
2637
  const h = headers.get("X-Entitlement-Filter-Status");
2598
2638
  if (h) status = h;
2599
2639
  }
2600
- return { models: result.data, status };
2640
+ return { models: normalized, status };
2601
2641
  }
2602
2642
  /** 查询当前用户账户级权益总览 (v0.19+) */
2603
2643
  async getQuotaSummary(signal) {
@@ -3230,9 +3270,24 @@ function zeroModelCapabilities() {
3230
3270
  supports_token_efficient: false,
3231
3271
  supports_redact_thinking: false,
3232
3272
  max_input_tokens: 0,
3233
- max_output_tokens: 0
3273
+ max_output_tokens: 0,
3274
+ supports_desktop_visual_understanding: false
3234
3275
  };
3235
3276
  }
3277
+ function normalizeInputModalities(models) {
3278
+ if (!Array.isArray(models)) return models;
3279
+ for (const m of models) {
3280
+ if (!m || typeof m !== "object") continue;
3281
+ if (Array.isArray(m.inputModalities)) continue;
3282
+ const snake = m.input_modalities;
3283
+ if (Array.isArray(snake)) {
3284
+ m.inputModalities = snake.filter(
3285
+ (v) => v === "text" || v === "image"
3286
+ );
3287
+ }
3288
+ }
3289
+ return models;
3290
+ }
3236
3291
  function withRequestTimeout(ms, parent) {
3237
3292
  const ctl = new AbortController();
3238
3293
  const timer = setTimeout(() => ctl.abort(), ms);
@@ -4636,10 +4691,14 @@ exports.effectivePolicy = effectivePolicy;
4636
4691
  exports.exchangeCode = exchangeCode;
4637
4692
  exports.extractAnthropicBlockMeta = extractAnthropicBlockMeta;
4638
4693
  exports.fileLockDefaults = fileLockDefaults;
4694
+ exports.findDesktopVisualUnderstandingModel = findDesktopVisualUnderstandingModel;
4695
+ exports.findFirstModelByInputModality = findFirstModelByInputModality;
4639
4696
  exports.getAdapter = getAdapter;
4640
4697
  exports.getAdapterForModel = getAdapterForModel;
4641
4698
  exports.isSSLError = isSSLError;
4642
4699
  exports.modelScopes = modelScopes;
4700
+ exports.modelSupportsImageInput = modelSupportsImageInput;
4701
+ exports.modelSupportsInputModality = modelSupportsInputModality;
4643
4702
  exports.newFileTokenStore = newFileTokenStore;
4644
4703
  exports.newThinkingConfig = newThinkingConfig;
4645
4704
  exports.newTokenSet = newTokenSet;