@x1a0f3n9/dsh-llm 0.1.5-rc.2 → 0.1.5-rc.4

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/lib/index.js CHANGED
@@ -155,6 +155,12 @@ const STRUCTURED_CONTEXT_OVERFLOW = new RegExp(String.raw`(?:^|[^a-z0-9])context
155
155
  const TOO_LARGE_FOR_CONTEXT = new RegExp(String.raw`\b(?:request|prompt|input|messages?)\s+(?:is\s+|are\s+)?` + String.raw`too\s+(?:large|long)\s+for\s+(?:(?:this|the)\s+)?` + String.raw`(?:model(?:'s)?\s+)?context(?:\s+window)?\b`, "i");
156
156
  /** "Exceeds" wording is safe only when its object is explicitly the model context. */
157
157
  const EXCEEDS_MODEL_CONTEXT = new RegExp(String.raw`\b(?:input|prompt|request|messages?)\b.{0,40}` + String.raw`\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}` + String.raw`\b(?:the\s+)?(?:model(?:'s)?\s+)?context(?:\s+(?:length|window))?\b`, "i");
158
+ /** xAI Grok and similar OpenAI-compatible gateways name the bound as prompt length. */
159
+ const MAXIMUM_PROMPT_LENGTH = /\bmaximum prompt length\b|\bprompt is too long\b/i;
160
+ /** Groq and similar gateways ask the caller to shorten the message list. */
161
+ const REDUCE_MESSAGE_LENGTH = /\breduce the length of the messages\b/i;
162
+ /** Chinese OpenAI-compatible gateways often return localized overflow copy. */
163
+ const CHINESE_CONTEXT_OVERFLOW = /上下文(?:窗口|长度)|(?:提示词|输入|请求).{0,8}过长/;
158
164
  /**
159
165
  * Recognize the context-overflow wording used by OpenAI-compatible providers
160
166
  * and library adapters. Adapters pass all available provider code, type, and
@@ -163,7 +169,7 @@ const EXCEEDS_MODEL_CONTEXT = new RegExp(String.raw`\b(?:input|prompt|request|me
163
169
  * @returns true when the detail identifies a request exceeding the model context window.
164
170
  */
165
171
  function isContextWindowExceededError(detail) {
166
- return STRUCTURED_CONTEXT_OVERFLOW.test(detail) || /\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(detail) || TOO_LARGE_FOR_CONTEXT.test(detail) || /\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(detail) || EXCEEDS_MODEL_CONTEXT.test(detail);
172
+ return STRUCTURED_CONTEXT_OVERFLOW.test(detail) || /\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(detail) || TOO_LARGE_FOR_CONTEXT.test(detail) || /\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(detail) || /\btoo long for (?:this|the) model\b/i.test(detail) || EXCEEDS_MODEL_CONTEXT.test(detail) || MAXIMUM_PROMPT_LENGTH.test(detail) || REDUCE_MESSAGE_LENGTH.test(detail) || CHINESE_CONTEXT_OVERFLOW.test(detail);
167
173
  }
168
174
  /**
169
175
  * Recognize provider wording that identifies an exhausted account quota rather
@@ -172,7 +178,7 @@ function isContextWindowExceededError(detail) {
172
178
  * @returns true only for terminal quota, balance, credit, budget, or usage-limit wording.
173
179
  */
174
180
  function isQuotaExceededError(detail) {
175
- return /\binsufficient[\s_-]+(?:quota|balance|credits?)\b/i.test(detail) || /\b(?:quota|usage[\s_-]+limit)[\s_-]+(?:exceeded|exhausted|reached)\b/i.test(detail) || /\bexceed(?:ed|s)?[\s_-]+(?:(?:your|the)[\s_-]+)?(?:current[\s_-]+)?quota\b/i.test(detail) || /\b(?:balance|credits?)[\s_-]+(?:exhausted|depleted)\b/i.test(detail) || /\bout[\s_-]+of[\s_-]+(?:credits?|budget)\b/i.test(detail);
181
+ return /\binsufficient[\s_-]+(?:quota|balance|credits?)\b/i.test(detail) || /\b(?:quota|usage[\s_-]+limit)[\s_-]+(?:exceeded|exhausted|reached)\b/i.test(detail) || /\bexceed(?:ed|s)?[\s_-]+(?:(?:your|the)[\s_-]+)?(?:current[\s_-]+)?quota\b/i.test(detail) || /\b(?:balance|credits?)[\s_-]+(?:exhausted|depleted)\b/i.test(detail) || /\bout[\s_-]+of[\s_-]+(?:credits?|budget)\b/i.test(detail) || /\bexceeded the .{0,24}usage[\s_-]+quota\b/i.test(detail) || /\breached your usage limit\b/i.test(detail) || /\busage[\s_-]+limit\b.{0,48}\bbilling cycle\b/i.test(detail);
176
182
  }
177
183
  /**
178
184
  * Render a thrown value with its full `cause` chain and AggregateError
@@ -1953,7 +1959,8 @@ let LlmRuntime = (() => {
1953
1959
  id: model.id,
1954
1960
  ...model.name === void 0 ? {} : { name: model.name },
1955
1961
  ...model.contextWindow === void 0 ? {} : { contextWindow: model.contextWindow },
1956
- ...model.maxTokens === void 0 ? {} : { maxTokens: model.maxTokens }
1962
+ ...model.maxTokens === void 0 ? {} : { maxTokens: model.maxTokens },
1963
+ ...model.inputModalities === void 0 ? {} : { inputModalities: model.inputModalities }
1957
1964
  });
1958
1965
  }
1959
1966
  return models;
@@ -13,6 +13,7 @@ const _x1a0f3n9_dsh_llm_llm_discoverModels_result$schema = z.array(z.object({
13
13
  'name': z.string().optional(),
14
14
  'contextWindow': z.number().optional(),
15
15
  'maxTokens': z.number().optional(),
16
+ 'inputModalities': z.array(z.union([z.literal("text"), z.literal("image")])).optional(),
16
17
  }))
17
18
  const _x1a0f3n9_dsh_llm_llm_listConfigurableProviders_result$schema = z.array(z.object({
18
19
  'provider': z.string(),
@@ -68,7 +69,7 @@ export const TYPERT = {
68
69
  typeSymbol: '@x1a0f3n9/dsh-llm#llm/discoverModels:result',
69
70
  schema: _x1a0f3n9_dsh_llm_llm_discoverModels_result$schema,
70
71
  },
71
- sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":628,"column":9},
72
+ sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":629,"column":9},
72
73
  },
73
74
  {
74
75
  id: '@x1a0f3n9/dsh-llm#llm/listConfigurableProviders',
@@ -324,7 +325,7 @@ export const TYPERT = {
324
325
  },
325
326
  {
326
327
  "name": "LlmDiscoveredModel",
327
- "declaration": "export interface LlmDiscoveredModel {\n id: string;\n name?: string;\n contextWindow?: number;\n maxTokens?: number;\n}"
328
+ "declaration": "export interface LlmDiscoveredModel {\n id: string;\n name?: string;\n contextWindow?: number;\n maxTokens?: number;\n inputModalities?: readonly ModelModality[];\n}"
328
329
  },
329
330
  {
330
331
  "name": "LlmFailure",
@@ -13,6 +13,7 @@ const _x1a0f3n9_dsh_llm_llm_discoverModels_result$schema = z.array(z.object({
13
13
  'name': z.string().optional(),
14
14
  'contextWindow': z.number().optional(),
15
15
  'maxTokens': z.number().optional(),
16
+ 'inputModalities': z.array(z.union([z.literal("text"), z.literal("image")])).optional(),
16
17
  }))
17
18
  const _x1a0f3n9_dsh_llm_llm_listConfigurableProviders_result$schema = z.array(z.object({
18
19
  'provider': z.string(),
@@ -65,7 +66,7 @@ export const TYPERT_REMOTE = {
65
66
  typeSymbol: '@x1a0f3n9/dsh-llm#llm/discoverModels:result',
66
67
  schema: _x1a0f3n9_dsh_llm_llm_discoverModels_result$schema,
67
68
  },
68
- sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":628,"column":9},
69
+ sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":629,"column":9},
69
70
  },
70
71
  {
71
72
  id: '@x1a0f3n9/dsh-llm#llm/listConfigurableProviders',
@@ -51,6 +51,12 @@ const TOO_LARGE_FOR_CONTEXT = new RegExp(String.raw `\b(?:request|prompt|input|m
51
51
  const EXCEEDS_MODEL_CONTEXT = new RegExp(String.raw `\b(?:input|prompt|request|messages?)\b.{0,40}`
52
52
  + String.raw `\b(?:exceed(?:s|ed)?|overflows?|is\s+larger\s+than)\b.{0,40}`
53
53
  + String.raw `\b(?:the\s+)?(?:model(?:'s)?\s+)?context(?:\s+(?:length|window))?\b`, 'i');
54
+ /** xAI Grok and similar OpenAI-compatible gateways name the bound as prompt length. */
55
+ const MAXIMUM_PROMPT_LENGTH = /\bmaximum prompt length\b|\bprompt is too long\b/i;
56
+ /** Groq and similar gateways ask the caller to shorten the message list. */
57
+ const REDUCE_MESSAGE_LENGTH = /\breduce the length of the messages\b/i;
58
+ /** Chinese OpenAI-compatible gateways often return localized overflow copy. */
59
+ const CHINESE_CONTEXT_OVERFLOW = /上下文(?:窗口|长度)|(?:提示词|输入|请求).{0,8}过长/;
54
60
  /**
55
61
  * Recognize the context-overflow wording used by OpenAI-compatible providers
56
62
  * and library adapters. Adapters pass all available provider code, type, and
@@ -63,7 +69,11 @@ export function isContextWindowExceededError(detail) {
63
69
  || /\b(?:maximum|max)(?:\s+(?:allowed|supported))?\s+context\s+(?:length|window)\b/i.test(detail)
64
70
  || TOO_LARGE_FOR_CONTEXT.test(detail)
65
71
  || /\b(?:input|prompt|request)\s+(?:is\s+)?too\s+(?:long|large)\s+for\s+(?:this|the)\s+model\b/i.test(detail)
66
- || EXCEEDS_MODEL_CONTEXT.test(detail);
72
+ || /\btoo long for (?:this|the) model\b/i.test(detail)
73
+ || EXCEEDS_MODEL_CONTEXT.test(detail)
74
+ || MAXIMUM_PROMPT_LENGTH.test(detail)
75
+ || REDUCE_MESSAGE_LENGTH.test(detail)
76
+ || CHINESE_CONTEXT_OVERFLOW.test(detail);
67
77
  }
68
78
  /**
69
79
  * Recognize provider wording that identifies an exhausted account quota rather
@@ -76,7 +86,10 @@ export function isQuotaExceededError(detail) {
76
86
  || /\b(?:quota|usage[\s_-]+limit)[\s_-]+(?:exceeded|exhausted|reached)\b/i.test(detail)
77
87
  || /\bexceed(?:ed|s)?[\s_-]+(?:(?:your|the)[\s_-]+)?(?:current[\s_-]+)?quota\b/i.test(detail)
78
88
  || /\b(?:balance|credits?)[\s_-]+(?:exhausted|depleted)\b/i.test(detail)
79
- || /\bout[\s_-]+of[\s_-]+(?:credits?|budget)\b/i.test(detail);
89
+ || /\bout[\s_-]+of[\s_-]+(?:credits?|budget)\b/i.test(detail)
90
+ || /\bexceeded the .{0,24}usage[\s_-]+quota\b/i.test(detail)
91
+ || /\breached your usage limit\b/i.test(detail)
92
+ || /\busage[\s_-]+limit\b.{0,48}\bbilling cycle\b/i.test(detail);
80
93
  }
81
94
  /**
82
95
  * Render a thrown value with its full `cause` chain and AggregateError
@@ -487,6 +487,7 @@ let LlmRuntime = (() => {
487
487
  ...model.name === undefined ? {} : { name: model.name },
488
488
  ...model.contextWindow === undefined ? {} : { contextWindow: model.contextWindow },
489
489
  ...model.maxTokens === undefined ? {} : { maxTokens: model.maxTokens },
490
+ ...model.inputModalities === undefined ? {} : { inputModalities: model.inputModalities },
490
491
  });
491
492
  }
492
493
  return models;
@@ -272,6 +272,11 @@ export interface LlmDiscoveredModel {
272
272
  contextWindow?: number;
273
273
  /** Maximum output tokens, when disclosed. */
274
274
  maxTokens?: number;
275
+ /**
276
+ * Accepted request modalities when the listing or an installed catalog
277
+ * discloses them. Absent means unknown, not text-only.
278
+ */
279
+ inputModalities?: readonly ModelModality[];
275
280
  }
276
281
  /** One adapter-discovered model; catalog membership is advisory, not request validation. */
277
282
  export interface LlmModelInfo {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@x1a0f3n9/dsh-llm",
3
3
  "description": "Provider-neutral LLM service interface for the DeepSeek Harness",
4
- "version": "0.1.5-rc.2",
4
+ "version": "0.1.5-rc.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -65,16 +65,16 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "zod": "^4.4.3",
68
- "@x1a0f3n9/dsh-util-crypto": "^0.1.5-rc.2",
68
+ "@x1a0f3n9/dsh-util-crypto": "^0.1.5-rc.4",
69
69
  "@deepseek-ai/schemastery": "^3.18.2",
70
- "@x1a0f3n9/dsh-timeout": "^0.1.5-rc.2",
71
- "@x1a0f3n9/dsh-brand": "^0.1.5-rc.2",
72
- "@x1a0f3n9/dsh-util-values": "^0.1.5-rc.2",
73
- "@x1a0f3n9/dsh-typert-protocol": "^0.1.5-rc.2"
70
+ "@x1a0f3n9/dsh-timeout": "^0.1.5-rc.4",
71
+ "@x1a0f3n9/dsh-brand": "^0.1.5-rc.4",
72
+ "@x1a0f3n9/dsh-util-values": "^0.1.5-rc.4",
73
+ "@x1a0f3n9/dsh-typert-protocol": "^0.1.5-rc.4"
74
74
  },
75
75
  "devDependencies": {
76
- "@x1a0f3n9/dsh-attachment": "^0.1.5-rc.2",
77
- "@x1a0f3n9/dsh-invariants": "^0.1.5-rc.2",
76
+ "@x1a0f3n9/dsh-attachment": "^0.1.5-rc.4",
77
+ "@x1a0f3n9/dsh-invariants": "^0.1.5-rc.4",
78
78
  "@deepseek-ai/cordis": "^4.0.2"
79
79
  }
80
80
  }