@evident-ai/cli 3.0.1-dev.892519e → 3.0.1-dev.96d8de4

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
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { createRequire } from "module";
5
4
  import { Command } from "commander";
6
5
 
7
6
  // src/commands/login.ts
@@ -491,29 +490,6 @@ var TelemetryEventTypes = {
491
490
  var MAX_FRAME_BYTES = 256 * 1024;
492
491
  var TUNNEL_DRAIN_PING_PATH = "/__evident/drain";
493
492
 
494
- // ../../packages/types/src/logging/index.ts
495
- var CORRELATION_ID_HEADER = "x-evident-correlation-id";
496
- function log(level, event, fields) {
497
- const method = level === "debug" ? "log" : level;
498
- try {
499
- console[method]("[evident]", JSON.stringify({ level, event, ...fields }));
500
- } catch (err) {
501
- console.error(
502
- "[evident] log_serialize_failed",
503
- event,
504
- err instanceof Error ? err.message : String(err)
505
- );
506
- }
507
- }
508
- function stripQuery(url) {
509
- try {
510
- return new URL(url).pathname;
511
- } catch {
512
- const q = url.indexOf("?");
513
- return q === -1 ? url : url.slice(0, q);
514
- }
515
- }
516
-
517
493
  // src/lib/telemetry.ts
518
494
  var CLI_VERSION = process.env.npm_package_version || "unknown";
519
495
  var eventBuffer = [];
@@ -716,13 +692,13 @@ async function waitForOpenCodeHealth(port, timeoutMs = 3e4) {
716
692
 
717
693
  // src/lib/opencode/opencode-version-gate.ts
718
694
  var QUEUE_VALIDATED_OPENCODE_VERSIONS = ["1.17.11"];
719
- function isQueueValidatedVersion(version2) {
720
- if (!version2) return false;
721
- return QUEUE_VALIDATED_OPENCODE_VERSIONS.includes(version2);
695
+ function isQueueValidatedVersion(version) {
696
+ if (!version) return false;
697
+ return QUEUE_VALIDATED_OPENCODE_VERSIONS.includes(version);
722
698
  }
723
- function buildOpenCodeVersionWarning(version2) {
724
- if (isQueueValidatedVersion(version2)) return null;
725
- const detected = version2 ? `v${version2}` : "unknown";
699
+ function buildOpenCodeVersionWarning(version) {
700
+ if (isQueueValidatedVersion(version)) return null;
701
+ const detected = version ? `v${version}` : "unknown";
726
702
  const validated = QUEUE_VALIDATED_OPENCODE_VERSIONS.map((v) => `v${v}`).join(", ");
727
703
  return `Warning: opencode ${detected} is not a queue-validated version (validated: ${validated}). Native message queuing \u2014 which channel (Slack/WhatsApp) message handling relies on \u2014 is unverified on this version; queued/follow-up messages may behave unexpectedly. Continuing anyway. Bumping the validated set requires re-running the queue validation.`;
728
704
  }
@@ -1216,20 +1192,12 @@ var StreamForwarder = class {
1216
1192
  }
1217
1193
  async handleOpen(frame) {
1218
1194
  const { sid, method, path, headers, has_body } = frame;
1219
- const correlationId = headers?.[CORRELATION_ID_HEADER];
1220
- const startedAt = Date.now();
1221
1195
  if (path === TUNNEL_DRAIN_PING_PATH) {
1222
1196
  this.callbacks.onDrainPing?.();
1223
1197
  this.send({ type: "head", sid, status: 204, headers: {} });
1224
1198
  this.send({ type: "res_end", sid });
1225
1199
  return;
1226
1200
  }
1227
- log("info", "agent_request", {
1228
- correlation_id: correlationId,
1229
- sid,
1230
- method,
1231
- path: stripQuery(path)
1232
- });
1233
1201
  const ac = new AbortController();
1234
1202
  let bodyPromise;
1235
1203
  let pushBody;
@@ -1276,12 +1244,6 @@ var StreamForwarder = class {
1276
1244
  if (!STRIP_RES.has(key.toLowerCase())) resHeaders[key] = value;
1277
1245
  });
1278
1246
  this.send({ type: "head", sid, status: upstream.status, headers: resHeaders });
1279
- log("info", "agent_response", {
1280
- correlation_id: correlationId,
1281
- sid,
1282
- status: upstream.status,
1283
- duration_ms: Date.now() - startedAt
1284
- });
1285
1247
  this.callbacks.onHead?.(sid, upstream.status);
1286
1248
  try {
1287
1249
  if (upstream.body) {
@@ -2573,7 +2535,7 @@ async function getAgentInfo(agentId, authHeader) {
2573
2535
  // src/commands/run.ts
2574
2536
  var MAX_ACTIVITY_LOG_ENTRIES = 10;
2575
2537
  var CHANNEL_POLL_INTERVAL_MS = Number(process.env.EVIDENT_CHANNEL_POLL_INTERVAL_MS) || 2e3;
2576
- function log2(state, message, isError = false) {
2538
+ function log(state, message, isError = false) {
2577
2539
  if (state.json) {
2578
2540
  console.log(
2579
2541
  JSON.stringify({
@@ -2598,9 +2560,9 @@ function logActivity(state, entry) {
2598
2560
  }
2599
2561
  if (!state.interactive) {
2600
2562
  if (entry.type === "error") {
2601
- log2(state, entry.error ?? "Unknown error", true);
2563
+ log(state, entry.error ?? "Unknown error", true);
2602
2564
  } else if (entry.type === "info" && entry.message) {
2603
- log2(state, entry.message);
2565
+ log(state, entry.message);
2604
2566
  }
2605
2567
  }
2606
2568
  }
@@ -2686,7 +2648,6 @@ async function handleAuthError(state, error2) {
2686
2648
  }
2687
2649
  async function driveChannels(state, driver) {
2688
2650
  let idlePolls = 0;
2689
- let lastSeenProxiedActivityAt = state.lastProxiedActivityAt;
2690
2651
  while (state.running) {
2691
2652
  if (state.connection?.reconnecting && state.connection.reconnectPromise) {
2692
2653
  logActivity(state, { type: "info", message: "Waiting for tunnel reconnection..." });
@@ -2696,9 +2657,7 @@ async function driveChannels(state, driver) {
2696
2657
  try {
2697
2658
  const processed = await driver.drainPending();
2698
2659
  state.messageCount += processed;
2699
- const proxiedActivity = state.lastProxiedActivityAt !== lastSeenProxiedActivityAt;
2700
- lastSeenProxiedActivityAt = state.lastProxiedActivityAt;
2701
- if (processed > 0 || driver.hasInFlightWatchers() || proxiedActivity) {
2660
+ if (processed > 0 || driver.hasInFlightWatchers()) {
2702
2661
  idlePolls = 0;
2703
2662
  if (processed > 0 && state.interactive) displayStatus(state);
2704
2663
  } else if (state.idleTimeout !== null) {
@@ -2750,7 +2709,7 @@ async function cleanup(state) {
2750
2709
  logActivity(state, { type: "info", message: "Stopped OpenCode process" });
2751
2710
  displayStatus(state);
2752
2711
  } else {
2753
- log2(state, "Stopped OpenCode process");
2712
+ log(state, "Stopped OpenCode process");
2754
2713
  }
2755
2714
  state.opencodeProcess = null;
2756
2715
  }
@@ -2773,11 +2732,10 @@ async function run(options) {
2773
2732
  running: true,
2774
2733
  activityLog: [],
2775
2734
  messageCount: 0,
2776
- lastProxiedActivityAt: null,
2777
2735
  authHeader: ""
2778
2736
  };
2779
2737
  if (state.idleTimeout === null && (process.env.GITHUB_ACTIONS || process.env.CI)) {
2780
- log2(
2738
+ log(
2781
2739
  state,
2782
2740
  "Warning: No --idle-timeout set in CI environment. The runner will poll indefinitely until the job times out. Consider adding --idle-timeout 30 to avoid wasting runner minutes.",
2783
2741
  false
@@ -2788,7 +2746,7 @@ async function run(options) {
2788
2746
  logActivity(state, { type: "info", message: "Shutting down..." });
2789
2747
  displayStatus(state);
2790
2748
  } else {
2791
- log2(state, "Shutting down...");
2749
+ log(state, "Shutting down...");
2792
2750
  }
2793
2751
  await cleanup(state);
2794
2752
  await shutdownTelemetry();
@@ -2821,7 +2779,7 @@ async function run(options) {
2821
2779
  const resolved = await resolveAgentIdFromKey(state.authHeader);
2822
2780
  if (resolved.agent_id) {
2823
2781
  state.agentId = resolved.agent_id;
2824
- log2(state, `Resolved agent ID from key: ${state.agentId}`);
2782
+ log(state, `Resolved agent ID from key: ${state.agentId}`);
2825
2783
  if (state.interactive && !state.json) {
2826
2784
  logActivity(state, {
2827
2785
  type: "info",
@@ -2884,17 +2842,17 @@ async function run(options) {
2884
2842
  port: state.port,
2885
2843
  interactive: state.interactive,
2886
2844
  agentId: state.agentId,
2887
- log: (message) => log2(state, message)
2845
+ log: (message) => log(state, message)
2888
2846
  });
2889
2847
  state.port = oc.port;
2890
2848
  state.opencodeProcess = oc.process;
2891
2849
  state.opencodeVersion = oc.version;
2892
2850
  state.opencodeConnected = oc.process !== null || oc.version !== null;
2893
- const version2 = state.opencodeVersion ? ` (v${state.opencodeVersion})` : "";
2894
- ocSpinner?.succeed(`OpenCode running on port ${state.port}${version2}`);
2851
+ const version = state.opencodeVersion ? ` (v${state.opencodeVersion})` : "";
2852
+ ocSpinner?.succeed(`OpenCode running on port ${state.port}${version}`);
2895
2853
  const versionWarning = buildOpenCodeVersionWarning(state.opencodeVersion);
2896
2854
  if (versionWarning) {
2897
- log2(state, versionWarning, false);
2855
+ log(state, versionWarning, false);
2898
2856
  if (state.interactive && !state.json) {
2899
2857
  logActivity(state, { type: "info", message: versionWarning });
2900
2858
  }
@@ -2963,14 +2921,9 @@ async function run(options) {
2963
2921
  logActivity(state, { type: "error", error: error2 });
2964
2922
  if (state.interactive) displayStatus(state);
2965
2923
  },
2966
- // Web traffic is proxied transparently; note opencode is live and stamp
2967
- // proxied activity so the idle loop treats interactive proxy use as work.
2968
- // Fires per forwarded response head (incl. every SSE open) and excludes
2969
- // the internal drain-ping, so an actively-used proxy keeps the timer
2970
- // fresh while a lone idle SSE with no follow-up requests still ages out.
2924
+ // Web traffic is proxied transparently; only note opencode is live.
2971
2925
  onResponse: () => {
2972
2926
  state.opencodeConnected = true;
2973
- state.lastProxiedActivityAt = Date.now();
2974
2927
  },
2975
2928
  // A channel message was queued and the api-worker pinged us over the
2976
2929
  // tunnel to drain immediately instead of waiting for the next poll tick.
@@ -3009,7 +2962,7 @@ async function run(options) {
3009
2962
  throw error2;
3010
2963
  }
3011
2964
  if (!interactive || state.json) {
3012
- log2(state, "Driving channel messages...");
2965
+ log(state, "Driving channel messages...");
3013
2966
  }
3014
2967
  await driveChannels(state, channelDriver);
3015
2968
  await cleanup(state);
@@ -3021,7 +2974,7 @@ async function run(options) {
3021
2974
  })
3022
2975
  );
3023
2976
  } else if (!interactive) {
3024
- log2(state, `Completed. Processed ${state.messageCount} message(s).`);
2977
+ log(state, `Completed. Processed ${state.messageCount} message(s).`);
3025
2978
  }
3026
2979
  await shutdownTelemetry();
3027
2980
  process.exit(0);
@@ -3043,9 +2996,8 @@ async function run(options) {
3043
2996
  }
3044
2997
 
3045
2998
  // src/index.ts
3046
- var { version } = createRequire(import.meta.url)("../package.json");
3047
2999
  var program = new Command();
3048
- program.name("evident").description("Run OpenCode locally and connect it to Evident").version(version).option(
3000
+ program.name("evident").description("Run OpenCode locally and connect it to Evident").version("0.1.0").option(
3049
3001
  "--endpoint <url>",
3050
3002
  "Evident API base URL (default: production; e.g. http://localhost:3001)"
3051
3003
  ).option("--tunnel <url>", "Tunnel WebSocket URL (default: production; e.g. ws://localhost:8787)").hook("preAction", (thisCommand) => {