@chosengeneration/light-code 0.184.0 → 0.185.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/dist/server.cjs CHANGED
@@ -43175,6 +43175,8 @@ function extractModelIds(payload) {
43175
43175
  continue;
43176
43176
  }
43177
43177
  const record2 = entry;
43178
+ if (Array.isArray(record2?.supportedGenerationMethods) && !record2.supportedGenerationMethods.includes("generateContent"))
43179
+ continue;
43178
43180
  const id = typeof record2?.id === "string" ? record2.id : typeof record2?.name === "string" ? record2.name : void 0;
43179
43181
  if (id !== void 0)
43180
43182
  ids.push(id.replace(/^models\//, ""));
@@ -43191,25 +43193,36 @@ async function listModels(http, profile, auth2, signal) {
43191
43193
  }
43192
43194
  try {
43193
43195
  const tls2 = await auth2.tls?.();
43194
- const response = await http.request(url2, {
43195
- method: "GET",
43196
- headers: { ...authHeaders, ...profile.headers },
43197
- ...signal !== void 0 ? { signal } : {},
43198
- ...tls2 !== void 0 ? { tls: tls2 } : {}
43199
- });
43200
- if (response.status === 404) {
43201
- return { ids: [], warning: `${url2} returned 404. This gateway does not publish a model list \u2014 type the model id.` };
43202
- }
43203
- if (response.status < 200 || response.status >= 300) {
43204
- return { ids: [], warning: `${url2} returned HTTP ${response.status}. Type the model id instead.` };
43196
+ const gemini = profile.wireFormat === "gemini";
43197
+ const ids = [];
43198
+ const windows = {};
43199
+ let pageToken;
43200
+ for (let page = 0; page < 10; page += 1) {
43201
+ const query = gemini ? `?pageSize=1000${pageToken !== void 0 ? `&pageToken=${encodeURIComponent(pageToken)}` : ""}` : "";
43202
+ const response = await http.request(`${url2}${query}`, {
43203
+ method: "GET",
43204
+ headers: { ...authHeaders, ...profile.headers },
43205
+ ...signal !== void 0 ? { signal } : {},
43206
+ ...tls2 !== void 0 ? { tls: tls2 } : {}
43207
+ });
43208
+ if (response.status === 404) {
43209
+ return { ids: [], warning: `${url2} returned 404. This gateway does not publish a model list \u2014 type the model id.` };
43210
+ }
43211
+ if (response.status < 200 || response.status >= 300) {
43212
+ return { ids: [], warning: `${url2} returned HTTP ${response.status}. Type the model id instead.` };
43213
+ }
43214
+ const payload = await response.json();
43215
+ ids.push(...extractModelIds(payload));
43216
+ Object.assign(windows, extractContextWindows(payload));
43217
+ const next = payload?.nextPageToken;
43218
+ if (!gemini || typeof next !== "string" || next.length === 0 || next === pageToken)
43219
+ break;
43220
+ pageToken = next;
43205
43221
  }
43206
- const payload = await response.json();
43207
- const ids = extractModelIds(payload);
43208
43222
  if (ids.length === 0) {
43209
43223
  return { ids: [], warning: `${url2} returned no models. Type the model id instead.` };
43210
43224
  }
43211
- const windows = extractContextWindows(payload);
43212
- return { ids, ...Object.keys(windows).length > 0 ? { windows } : {} };
43225
+ return { ids: [...new Set(ids)].sort(), ...Object.keys(windows).length > 0 ? { windows } : {} };
43213
43226
  } catch (error51) {
43214
43227
  return { ids: [], warning: `Could not reach ${url2}: ${describeTlsError(error51)}` };
43215
43228
  }
@@ -43307,33 +43320,16 @@ async function testConnection(profile, context, http, signal) {
43307
43320
  }
43308
43321
 
43309
43322
  // ../../packages/core/dist/providers/schema.js
43310
- var GEMINI_UNSUPPORTED = /* @__PURE__ */ new Set([
43311
- "$schema",
43312
- "$ref",
43313
- "$defs",
43314
- "definitions",
43315
- "additionalProperties",
43316
- "oneOf",
43317
- "anyOf",
43318
- "allOf",
43319
- "not",
43320
- "const",
43321
- "default",
43322
- "examples",
43323
- "patternProperties",
43324
- "minLength",
43325
- "maxLength",
43326
- "pattern",
43327
- "minimum",
43328
- "maximum",
43329
- "exclusiveMinimum",
43330
- "exclusiveMaximum",
43331
- "multipleOf",
43332
- "minItems",
43333
- "maxItems",
43334
- "uniqueItems",
43335
- "format"
43323
+ var PORTABLE_KEYWORDS = /* @__PURE__ */ new Set([
43324
+ "type",
43325
+ "description",
43326
+ "properties",
43327
+ "required",
43328
+ "items",
43329
+ "enum",
43330
+ "nullable"
43336
43331
  ]);
43332
+ var keepForGemini = (key3) => PORTABLE_KEYWORDS.has(key3);
43337
43333
  function isRecord(value) {
43338
43334
  return typeof value === "object" && value !== null && !Array.isArray(value);
43339
43335
  }
@@ -43381,7 +43377,7 @@ function toGeminiTools(tools) {
43381
43377
  functionDeclarations: tools.map((tool) => ({
43382
43378
  name: tool.name,
43383
43379
  description: tool.description,
43384
- parameters: pruneSchema(normalizeObjectSchema(tool.parameters), (key3) => !GEMINI_UNSUPPORTED.has(key3))
43380
+ parameters: pruneSchema(normalizeObjectSchema(tool.parameters), keepForGemini)
43385
43381
  }))
43386
43382
  }
43387
43383
  ];
@@ -64114,7 +64110,7 @@ async function truncateToolResult(content, store, maxChars = DEFAULT_MAX_CHARS,
64114
64110
  var TRANSIENT_STATUS = /HTTP (408|409|425|429|500|502|503|504|520|521|522|523|524|529)\b/;
64115
64111
  var TRANSIENT_TRANSPORT = /ECONNRESET|ECONNREFUSED|ETIMEDOUT|ECONNABORTED|EPIPE|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|socket hang up|other side closed|terminated|fetch failed|network error|UND_ERR_(SOCKET|CONNECT_TIMEOUT|HEADERS_TIMEOUT|BODY_TIMEOUT|CLOSED)|No reply from .* within/i;
64116
64112
  var TRANSIENT_PROVIDER = /overloaded|rate.?limit|too many requests|temporarily unavailable|service unavailable|RESOURCE_EXHAUSTED|UNAVAILABLE|try again later|server_error|internal server error/i;
64117
- var PERMANENT = /HTTP (400|401|403|404|405|413|422)\b|certificate|self[- ]signed|unable to verify|CERT_|key (does not|doesn't) match|passphrase|credential missing|context.{0,20}(length|window|limit)|too many tokens|prompt is too long/i;
64113
+ var PERMANENT = /HTTP (400|401|402|403|404|405|413|422)\b|credits? (are |is )?depleted|insufficient (credit|balance|funds)|billing|certificate|self[- ]signed|unable to verify|CERT_|key (does not|doesn't) match|passphrase|credential missing|context.{0,20}(length|window|limit)|too many tokens|prompt is too long/i;
64118
64114
  function isTransientError(message5) {
64119
64115
  if (PERMANENT.test(message5))
64120
64116
  return false;
@@ -88590,31 +88586,25 @@ ${direction}` : attachMentions(text2, mentions);
88590
88586
  }
88591
88587
  async function profileFromForm(input) {
88592
88588
  const fieldErrors = validateProviderForm({
88593
- label: input.label,
88589
+ label: typeof input.label === "string" && input.label.trim().length > 0 ? input.label : "Untitled",
88594
88590
  wireFormat: input.wireFormat,
88595
88591
  baseUrl: input.baseUrl,
88596
- model: input.model
88592
+ model: typeof input.model === "string" && input.model.trim().length > 0 ? input.model : "unset"
88597
88593
  });
88598
88594
  if (fieldErrors.length > 0) {
88599
- post({
88600
- type: "error",
88601
- message: fieldErrors.map((issue2) => `${issue2.path}: ${issue2.message}`).join("; ")
88602
- });
88603
- return void 0;
88595
+ return { problem: fieldErrors.map((issue2) => `${issue2.path}: ${issue2.message}`).join("; ") };
88604
88596
  }
88605
88597
  const baseUrl = input.baseUrl.trim();
88606
- if (baseUrl.length === 0) {
88607
- post({ type: "error", message: "Enter a base URL first." });
88608
- return void 0;
88609
- }
88598
+ if (baseUrl.length === 0)
88599
+ return { problem: "Enter a base URL first." };
88610
88600
  const id = input.id ?? "__unsaved__";
88611
88601
  const auth2 = await buildAuthFromInput(input, id);
88612
88602
  const profile = {
88613
88603
  id,
88614
- label: input.label.trim().length > 0 ? input.label.trim() : "Untitled",
88604
+ label: typeof input.label === "string" && input.label.trim().length > 0 ? input.label.trim() : "Untitled",
88615
88605
  wireFormat: input.wireFormat,
88616
88606
  baseUrl,
88617
- model: input.model.trim().length > 0 ? input.model.trim() : "unset",
88607
+ model: typeof input.model === "string" && input.model.trim().length > 0 ? input.model.trim() : "unset",
88618
88608
  auth: auth2,
88619
88609
  ...input.connectionTls !== void 0 ? { tls: stripEmpty(input.connectionTls) } : {}
88620
88610
  };
@@ -93763,8 +93753,10 @@ ${last}` : ""}`);
93763
93753
  async function handleRequestModels(input) {
93764
93754
  try {
93765
93755
  const built = await profileFromForm(input);
93766
- if (built === void 0)
93756
+ if ("problem" in built) {
93757
+ post({ type: "models", models: [], warning: built.problem });
93767
93758
  return;
93759
+ }
93768
93760
  const { config: config2 } = await configManager.load();
93769
93761
  const result = await listModelsFor(config2, built.profile);
93770
93762
  rememberWindows(built.profile.baseUrl, result.windows);
@@ -93784,8 +93776,10 @@ ${last}` : ""}`);
93784
93776
  async function handleTestConnection(input) {
93785
93777
  try {
93786
93778
  const built = await profileFromForm(input);
93787
- if (built === void 0)
93779
+ if ("problem" in built) {
93780
+ post({ type: "testConnectionResult", ok: false, steps: [{ step: "certificates", status: "failed", detail: built.problem }] });
93788
93781
  return;
93782
+ }
93789
93783
  const { config: config2 } = await configManager.load();
93790
93784
  const result = built.profile.wireFormat === "vscode-lm" ? await testHostModels(services.languageModels, built.profile.model) : await testConnection(built.profile, buildAuthContext(config2, built.profile), httpClient);
93791
93785
  post({ type: "testConnectionResult", ok: result.ok, steps: result.steps });
@@ -97286,8 +97280,12 @@ only \u2014 a repository must never be able to repoint where your prompts and yo
97286
97280
 
97287
97281
  **The model dropdown is never a hard dependency.** It is filled from the provider's models
97288
97282
  endpoint, which gateways frequently answer with their own catalogue or a 404, so free-text entry
97289
- is always available. Context window, vision and tool support come from a local table and can be
97290
- overridden per profile; an unknown id defaults conservatively.
97283
+ is always available. The list loads once a URL and a key are entered - no model needs choosing
97284
+ first - and if it cannot load, the reason is shown under the dropdown. For **Google Gemini** every
97285
+ page of Google's catalogue is read and only chat models are listed (embedding, image and video
97286
+ models are left out), so pick a new model such as Gemini 4 from the list rather than typing a guess:
97287
+ Google answers a retired or mistyped id with a 404. Context window, vision and tool support come
97288
+ from a local table and can be overridden per profile; an unknown id defaults conservatively.
97291
97289
 
97292
97290
  **Auth is a separate axis from wire format**, so any strategy composes with any adapter:
97293
97291
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.184.0",
3
+ "version": "0.185.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",