@evident-ai/cli 3.6.1-dev.391e5fd → 3.6.1-dev.409b23d

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
@@ -1442,7 +1442,7 @@ import ora4 from "ora";
1442
1442
  import { select as select4 } from "@inquirer/prompts";
1443
1443
 
1444
1444
  // src/lib/telemetry.ts
1445
- var CLI_VERSION = (true ? "3.6.1-dev.391e5fd" : void 0) ?? process.env.npm_package_version ?? "unknown";
1445
+ var CLI_VERSION = (true ? "3.6.1-dev.409b23d" : void 0) ?? process.env.npm_package_version ?? "unknown";
1446
1446
  function getCliVersion() {
1447
1447
  return CLI_VERSION;
1448
1448
  }
@@ -3209,6 +3209,52 @@ async function getModelAttachmentCapability(port, model, client) {
3209
3209
  return null;
3210
3210
  }
3211
3211
  }
3212
+ async function isPinnedProviderLoaded(port, model, client) {
3213
+ if (client?.version === "v2") return null;
3214
+ const { model: baseModel } = splitModelVariant(model);
3215
+ if (!baseModel) return null;
3216
+ const slash = baseModel.indexOf("/");
3217
+ if (slash <= 0) return null;
3218
+ const providerId = baseModel.slice(0, slash);
3219
+ try {
3220
+ const res = await requestWithClient(port, client, "/config/providers");
3221
+ if (!res.ok) {
3222
+ console.error(
3223
+ `[isPinnedProviderLoaded] GET /config/providers returned HTTP ${res.status} (port ${port})`
3224
+ );
3225
+ return null;
3226
+ }
3227
+ const body = await res.json();
3228
+ if (body === null || typeof body !== "object" || Array.isArray(body)) {
3229
+ console.error(
3230
+ `[isPinnedProviderLoaded] GET /config/providers body was not a plain object (port ${port})`
3231
+ );
3232
+ return null;
3233
+ }
3234
+ const providers = body.providers;
3235
+ if (!Array.isArray(providers)) {
3236
+ console.error(
3237
+ `[isPinnedProviderLoaded] GET /config/providers body had no providers array (port ${port})`
3238
+ );
3239
+ return null;
3240
+ }
3241
+ const providerIds = providers.filter(
3242
+ (provider) => provider !== null && typeof provider === "object" && typeof provider.id === "string"
3243
+ ).map((provider) => provider.id);
3244
+ if (providerIds.length === 0) {
3245
+ console.error(
3246
+ `[isPinnedProviderLoaded] GET /config/providers had no provider entries with string ids (port ${port})`
3247
+ );
3248
+ return null;
3249
+ }
3250
+ return providerIds.includes(providerId);
3251
+ } catch (err) {
3252
+ console.error(
3253
+ `[isPinnedProviderLoaded] GET /config/providers failed (port ${port}): ${err instanceof Error ? err.message : String(err)}`
3254
+ );
3255
+ return null;
3256
+ }
3257
+ }
3212
3258
  async function buildFileParts(attachments, capable) {
3213
3259
  const outcomes = [];
3214
3260
  const parts = [];
@@ -8722,6 +8768,47 @@ var ChannelDriver = class _ChannelDriver {
8722
8768
  agent: message.opencode_agent ?? void 0,
8723
8769
  model: message.opencode_model ?? void 0
8724
8770
  };
8771
+ const pinnedProviderLoaded = await isPinnedProviderLoaded(
8772
+ this.port,
8773
+ options.model,
8774
+ this.openCodeClient
8775
+ );
8776
+ if (pinnedProviderLoaded === false) {
8777
+ const dispatchedModel = message.opencode_model;
8778
+ const separator = dispatchedModel?.indexOf("/") ?? -1;
8779
+ const hasProviderAndModel = dispatchedModel !== null && separator > 0 && separator < dispatchedModel.length - 1;
8780
+ const providerId = hasProviderAndModel ? dispatchedModel.slice(0, separator) : null;
8781
+ const modelId = hasProviderAndModel ? dispatchedModel.slice(separator + 1) : null;
8782
+ const errorMessage3 = `Provider namespace not loaded on this runner: ${message.opencode_model}. Refused before dispatch; no turn was started.`;
8783
+ this.log({
8784
+ level: "error",
8785
+ message: `Refusing message ${message.id.slice(0, 8)} in conversation ${conv.id.slice(0, 8)}: provider namespace ${providerId ?? "(unknown)"} is not loaded; no turn was started`,
8786
+ conversation_id: conv.id,
8787
+ message_id: message.id
8788
+ });
8789
+ try {
8790
+ await this.markFailed(conv.id, message.id, sessionId, errorMessage3, void 0, {
8791
+ classification: {
8792
+ kind: "model_auth",
8793
+ providerId,
8794
+ modelId,
8795
+ reason: "missing"
8796
+ },
8797
+ errorShape: { name: null, statusCode: null }
8798
+ });
8799
+ this.signalDispatchNotStarted(conv, message, "model_provider_absent");
8800
+ } catch (markErr) {
8801
+ this.log({
8802
+ level: "warn",
8803
+ message: `markFailed PATCH for refused message ${message.id.slice(0, 8)} (conversation ${conv.id.slice(0, 8)}) failed: ${markErr instanceof Error ? markErr.message : String(markErr)}`,
8804
+ conversation_id: conv.id,
8805
+ message_id: message.id
8806
+ });
8807
+ this.signalDispatchNotStarted(conv, message, "failure_unreported");
8808
+ }
8809
+ await this.repairProviderRegistry(conv.id, message.id);
8810
+ break;
8811
+ }
8725
8812
  let opencodeMessageId;
8726
8813
  let preDispatchUserIds = null;
8727
8814
  try {
@@ -14388,8 +14475,18 @@ function readSetup(value) {
14388
14475
  }
14389
14476
  function clearLocalSetup(options) {
14390
14477
  const env = options.env ?? process.env;
14391
- (options.store ?? defaultStore).clear(options.agentId);
14392
- delete env.EVIDENT_PROXY_TOKEN;
14478
+ const store = options.store ?? defaultStore;
14479
+ const stored = store.get(options.agentId);
14480
+ store.clear(options.agentId);
14481
+ const token = env.EVIDENT_PROXY_TOKEN;
14482
+ if (token !== void 0 && token === stored?.token) {
14483
+ delete env.EVIDENT_PROXY_TOKEN;
14484
+ } else if (token !== void 0) {
14485
+ options.log(
14486
+ `MANAGED-INFERENCE-CLEANUP-PRESERVED-EXTERNAL-TOKEN: runner=${options.agentId}`,
14487
+ "debug"
14488
+ );
14489
+ }
14393
14490
  }
14394
14491
  async function discoverManagedInferenceSetup(options) {
14395
14492
  const headers = requestHeaders(options);