deepcode-ai 1.1.33 → 1.1.35

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/index.js CHANGED
@@ -3359,6 +3359,7 @@ function isSimpleDirectCommand(input) {
3359
3359
  }
3360
3360
  function resolveExecutionTarget(config, session, mode, explicitProvider) {
3361
3361
  const modeOverride = config.modeDefaults?.[mode];
3362
+ const hasPinnedProvider = Boolean(explicitProvider ?? modeOverride?.provider) || session.metadata.providerPinned === true;
3362
3363
  const provider = explicitProvider ?? modeOverride?.provider ?? session.provider ?? config.defaultProvider ?? resolveUsableProviderTarget(config, []).provider;
3363
3364
  const modeModel = modeOverride?.provider && modeOverride.provider !== provider ? void 0 : modeOverride?.model;
3364
3365
  const model = modeModel ?? (provider === session.provider ? session.model : void 0) ?? resolveConfiguredModelForProvider(config, provider);
@@ -3368,6 +3369,9 @@ function resolveExecutionTarget(config, session, mode, explicitProvider) {
3368
3369
  if (hasProviderCredentials(config.providers[provider], provider) && model) {
3369
3370
  return { provider, model };
3370
3371
  }
3372
+ if (hasPinnedProvider) {
3373
+ return { provider, model };
3374
+ }
3371
3375
  const fallback = resolveUsableProviderTarget(config, [
3372
3376
  explicitProvider,
3373
3377
  modeOverride?.provider,
@@ -6302,6 +6306,7 @@ function toOpenAICompatibleToolChoice(toolChoice) {
6302
6306
  return toolChoice;
6303
6307
  }
6304
6308
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 502, 503, 504]);
6309
+ var MODEL_CATALOG_GRACE_MS = 250;
6305
6310
  function isRetryableError(error) {
6306
6311
  if (error instanceof ProviderError && error.statusCode !== void 0) {
6307
6312
  return RETRYABLE_STATUS_CODES.has(error.statusCode);
@@ -6459,30 +6464,49 @@ var ProviderManager = class {
6459
6464
  validateModelForProvider(providerId, model);
6460
6465
  const started = Date.now();
6461
6466
  const controller = new AbortController();
6467
+ const modelCatalogController = new AbortController();
6462
6468
  const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? 15e3);
6463
6469
  try {
6464
- const [models, responseText] = await Promise.all([
6465
- provider.listModels({ signal: controller.signal }).catch(() => []),
6466
- provider.complete("Reply exactly with: OK", {
6467
- model,
6468
- maxTokens: 16,
6469
- temperature: 0,
6470
- signal: controller.signal
6471
- })
6472
- ]);
6470
+ let modelCatalogStatus = "skipped";
6471
+ const modelCatalogSignal = AbortSignal.any([controller.signal, modelCatalogController.signal]);
6472
+ const modelCatalogPromise = provider.listModels({ signal: modelCatalogSignal }).then((models2) => {
6473
+ modelCatalogStatus = "checked";
6474
+ return models2;
6475
+ }).catch(() => {
6476
+ modelCatalogStatus = modelCatalogController.signal.aborted ? "skipped" : "unavailable";
6477
+ return [];
6478
+ });
6479
+ const responseText = await provider.complete("Reply exactly with: OK", {
6480
+ model,
6481
+ maxTokens: 16,
6482
+ temperature: 0,
6483
+ signal: controller.signal
6484
+ });
6485
+ const latencyMs = Date.now() - started;
6473
6486
  if (!responseText.trim()) {
6474
6487
  throw new ProviderError(`${provider.name} returned an empty validation response`, providerId);
6475
6488
  }
6489
+ const catalogResult = await Promise.race([
6490
+ modelCatalogPromise.then((models2) => ({ completed: true, models: models2 })),
6491
+ delay2(MODEL_CATALOG_GRACE_MS, controller.signal).then(() => ({ completed: false }))
6492
+ ]);
6493
+ const models = catalogResult.completed ? catalogResult.models : [];
6494
+ if (!catalogResult.completed) {
6495
+ modelCatalogStatus = "skipped";
6496
+ modelCatalogController.abort();
6497
+ }
6476
6498
  const modelFound = models.length === 0 || models.some((item) => item.id === model || item.id === configuredModel);
6477
6499
  return {
6478
6500
  provider: providerId,
6479
6501
  model,
6480
6502
  modelFound,
6481
6503
  modelCount: models.length,
6504
+ modelCatalogStatus,
6482
6505
  responseText,
6483
- latencyMs: Date.now() - started
6506
+ latencyMs
6484
6507
  };
6485
6508
  } finally {
6509
+ modelCatalogController.abort();
6486
6510
  clearTimeout(timeout);
6487
6511
  }
6488
6512
  }
@@ -10268,6 +10292,21 @@ function isIndexable(value) {
10268
10292
  function isPlainObject2(value) {
10269
10293
  return typeof value === "object" && value !== null && !Array.isArray(value);
10270
10294
  }
10295
+ function formatModelCatalogSummary(result) {
10296
+ if (result.modelCatalogStatus === "checked") {
10297
+ return `${result.modelCount} models visible`;
10298
+ }
10299
+ if (result.modelCatalogStatus === "skipped") {
10300
+ return "model catalog skipped";
10301
+ }
10302
+ return "model catalog unavailable";
10303
+ }
10304
+ function formatModelCheckDetail(result) {
10305
+ if (result.modelCatalogStatus === "checked") {
10306
+ return result.modelFound ? result.model : `${result.model} (not present in provider model catalog)`;
10307
+ }
10308
+ return `${result.model} (model catalog ${result.modelCatalogStatus})`;
10309
+ }
10271
10310
  async function doctorCommand(options) {
10272
10311
  const runtime = await createRuntime({
10273
10312
  cwd: options.cwd,
@@ -10352,12 +10391,12 @@ async function providerChecks(runtime) {
10352
10391
  {
10353
10392
  name: "provider",
10354
10393
  ok: true,
10355
- detail: `${target.provider} authenticated; ${result.modelCount} models visible; model call ok (${result.latencyMs}ms)`
10394
+ detail: `${target.provider} authenticated; ${formatModelCatalogSummary(result)}; model call ok (${result.latencyMs}ms)`
10356
10395
  },
10357
10396
  {
10358
10397
  name: "model",
10359
10398
  ok: result.modelFound,
10360
- detail: result.modelFound ? result.model : `${result.model} (not present in provider model catalog)`
10399
+ detail: formatModelCheckDetail(result)
10361
10400
  }
10362
10401
  ];
10363
10402
  } catch (error) {
@@ -10544,7 +10583,7 @@ function resolveSessionTarget(config, overrides = {}) {
10544
10583
  requestedProvider,
10545
10584
  config.defaultProvider
10546
10585
  ]);
10547
- const parsedSelection = overrides.model ? parseModelSelection(overrides.model, requestedProvider ?? fallback.provider) : null;
10586
+ const parsedSelection = overrides.model ? requestedProvider ? { provider: requestedProvider, model: overrides.model.trim() } : parseModelSelection(overrides.model, fallback.provider) : null;
10548
10587
  if (overrides.model && !parsedSelection) {
10549
10588
  throw new Error(
10550
10589
  `Invalid model selection: ${overrides.model}. Use "<model>" or "<provider>/<model>".`
@@ -25828,7 +25867,7 @@ function useCommandCompletion(buffer, cwd, slashCommands, commandContext, revers
25828
25867
  const handleAutocomplete = useCallback12(
25829
25868
  (indexToUse) => {
25830
25869
  if (indexToUse < 0 || indexToUse >= suggestions.length) {
25831
- return;
25870
+ return null;
25832
25871
  }
25833
25872
  const suggestion = suggestions[indexToUse].value;
25834
25873
  let start = completionStart;
@@ -25839,7 +25878,7 @@ function useCommandCompletion(buffer, cwd, slashCommands, commandContext, revers
25839
25878
  end = lineOffset + slashCompletionRange.completionEnd;
25840
25879
  }
25841
25880
  if (start === -1 || end === -1) {
25842
- return;
25881
+ return null;
25843
25882
  }
25844
25883
  let suggestionText = suggestion;
25845
25884
  if (completionMode === "SLASH") {
@@ -25852,11 +25891,20 @@ function useCommandCompletion(buffer, cwd, slashCommands, commandContext, revers
25852
25891
  if (charAfterCompletion !== " ") {
25853
25892
  suggestionText += " ";
25854
25893
  }
25894
+ const startOffset = logicalPosToOffset(buffer.lines, cursorRow, start);
25895
+ const endOffset = logicalPosToOffset(buffer.lines, cursorRow, end);
25896
+ const currentText = toCodePoints(buffer.text);
25897
+ const nextText = [
25898
+ ...currentText.slice(0, startOffset),
25899
+ suggestionText,
25900
+ ...currentText.slice(endOffset)
25901
+ ].join("");
25855
25902
  buffer.replaceRangeByOffset(
25856
- logicalPosToOffset(buffer.lines, cursorRow, start),
25857
- logicalPosToOffset(buffer.lines, cursorRow, end),
25903
+ startOffset,
25904
+ endOffset,
25858
25905
  suggestionText
25859
25906
  );
25907
+ return nextText;
25860
25908
  },
25861
25909
  [
25862
25910
  cursorRow,
@@ -27069,22 +27117,22 @@ ${currentText}`);
27069
27117
  }
27070
27118
  const acceptActiveCompletionSuggestion = () => {
27071
27119
  if (completion.suggestions.length === 0) {
27072
- return false;
27120
+ return null;
27073
27121
  }
27074
27122
  const targetIndex = completion.activeSuggestionIndex === -1 ? 0 : completion.activeSuggestionIndex;
27075
27123
  if (targetIndex >= completion.suggestions.length) {
27076
- return false;
27124
+ return null;
27077
27125
  }
27078
- completion.handleAutocomplete(targetIndex);
27126
+ const completedText = completion.handleAutocomplete(targetIndex);
27079
27127
  exportCompletion.navigatedRef.current = false;
27080
27128
  setExpandedSuggestionIndex(-1);
27081
- return true;
27129
+ return completedText;
27082
27130
  };
27083
27131
  if (completion.isPerfectMatch && keyMatchers[
27084
27132
  "return"
27085
27133
  /* RETURN */
27086
27134
  ](key)) {
27087
- if (completion.showSuggestions && exportCompletion.navigatedRef.current && exportCompletion.navigatedTextRef.current === buffer.text && acceptActiveCompletionSuggestion()) {
27135
+ if (completion.showSuggestions && exportCompletion.navigatedRef.current && exportCompletion.navigatedTextRef.current === buffer.text && acceptActiveCompletionSuggestion() !== null) {
27088
27136
  return true;
27089
27137
  }
27090
27138
  handleSubmitAndClear(buffer.text);
@@ -27127,9 +27175,9 @@ ${currentText}`);
27127
27175
  "acceptSuggestion"
27128
27176
  /* ACCEPT_SUGGESTION */
27129
27177
  ](key) && !key.paste) {
27130
- const accepted = acceptActiveCompletionSuggestion();
27131
- if (accepted && key.name === "return" && isExactRunnableSlashCommand(buffer.text.trim(), slashCommands)) {
27132
- handleSubmitAndClear(buffer.text);
27178
+ const completedText = acceptActiveCompletionSuggestion();
27179
+ if (completedText !== null && key.name === "return" && isExactRunnableSlashCommand(completedText.trim(), slashCommands)) {
27180
+ handleSubmitAndClear(completedText);
27133
27181
  }
27134
27182
  return true;
27135
27183
  }
@@ -28293,7 +28341,7 @@ function parseVersion2(version) {
28293
28341
  if (!match) return null;
28294
28342
  return [Number(match[1]), Number(match[2]), Number(match[3])];
28295
28343
  }
28296
- var VERSION = "1.1.33".length > 0 ? "1.1.33" : "0.0.0-dev";
28344
+ var VERSION = "1.1.35".length > 0 ? "1.1.35" : "0.0.0-dev";
28297
28345
  var updateCommand = {
28298
28346
  name: "update",
28299
28347
  description: "Check published DeepCode versions",
@@ -29872,6 +29920,15 @@ Follow-up suggestion:`;
29872
29920
  return null;
29873
29921
  }
29874
29922
  }
29923
+ function formatModelCatalogSummary2(result) {
29924
+ if (result.modelCatalogStatus === "checked") {
29925
+ return `${result.modelCount} models visible`;
29926
+ }
29927
+ if (result.modelCatalogStatus === "skipped") {
29928
+ return "model catalog skipped";
29929
+ }
29930
+ return "model catalog unavailable";
29931
+ }
29875
29932
  var APPROVAL_ENTER_ARM_DELAY_MS = 350;
29876
29933
  var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
29877
29934
  const historyManager = useHistory();
@@ -30041,6 +30098,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30041
30098
  if (!runtime || !session) return;
30042
30099
  session.provider = provider2;
30043
30100
  session.model = resolveConfiguredModelForProvider(runtime.config, provider2);
30101
+ session.metadata = { ...session.metadata, providerPinned: true };
30044
30102
  runtime.sessions.save(session);
30045
30103
  setTargetSource("session");
30046
30104
  setCurrentModel(session.model ?? "(unconfigured)");
@@ -30061,6 +30119,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30061
30119
  if (!runtime || !session) return;
30062
30120
  const normalized2 = model2.trim();
30063
30121
  session.model = normalized2.length > 0 ? normalized2 : void 0;
30122
+ session.metadata = { ...session.metadata, providerPinned: true };
30064
30123
  runtime.sessions.save(session);
30065
30124
  setTargetSource("session");
30066
30125
  setCurrentModel(session.model ?? "(unconfigured)");
@@ -30252,10 +30311,17 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30252
30311
  session = existing;
30253
30312
  if (provider) session.provider = target.provider;
30254
30313
  if (model) session.model = target.model;
30314
+ if (provider || model) {
30315
+ session.metadata = { ...session.metadata, providerPinned: true };
30316
+ }
30255
30317
  runtime.sessions.save(session);
30256
30318
  resumed = true;
30257
30319
  } else {
30258
30320
  session = runtime.sessions.create(target);
30321
+ if (provider || model) {
30322
+ session.metadata = { ...session.metadata, providerPinned: true };
30323
+ runtime.sessions.save(session);
30324
+ }
30259
30325
  addHistoryItem(
30260
30326
  { type: "warning", text: `Session ${resumeSessionId} not found; starting new session.` },
30261
30327
  Date.now()
@@ -30263,6 +30329,10 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
30263
30329
  }
30264
30330
  } else {
30265
30331
  session = runtime.sessions.create(target);
30332
+ if (provider || model) {
30333
+ session.metadata = { ...session.metadata, providerPinned: true };
30334
+ runtime.sessions.save(session);
30335
+ }
30266
30336
  }
30267
30337
  runtimeRef.current = runtime;
30268
30338
  sessionRef.current = session;
@@ -31026,6 +31096,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31026
31096
  if (session) {
31027
31097
  session.provider = provider2;
31028
31098
  session.model = configuredModel;
31099
+ session.metadata = { ...session.metadata, providerPinned: true };
31029
31100
  runtime?.sessions.save(session);
31030
31101
  setProviderLabel(formatProviderLabel(session.provider, session.model));
31031
31102
  setCurrentModel(session.model ?? "(unconfigured)");
@@ -31066,7 +31137,7 @@ var AppContainer = ({ cwd, config, provider, model, resumeSessionId }) => {
31066
31137
  return {
31067
31138
  ok: true,
31068
31139
  latencyMs: result.latencyMs,
31069
- detail: `${result.modelCount} models visible; model call ok (${result.model})`
31140
+ detail: `${formatModelCatalogSummary2(result)}; model call ok (${result.model})`
31070
31141
  };
31071
31142
  } catch (error) {
31072
31143
  return {