@evident-ai/cli 3.0.1-dev.f10ab0f → 3.0.1-dev.f1d0273
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 +48 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -490,6 +490,29 @@ var TelemetryEventTypes = {
|
|
|
490
490
|
var MAX_FRAME_BYTES = 256 * 1024;
|
|
491
491
|
var TUNNEL_DRAIN_PING_PATH = "/__evident/drain";
|
|
492
492
|
|
|
493
|
+
// ../../packages/types/src/logging/index.ts
|
|
494
|
+
var CORRELATION_ID_HEADER = "x-evident-correlation-id";
|
|
495
|
+
function log(level, event, fields) {
|
|
496
|
+
const method = level === "debug" ? "log" : level;
|
|
497
|
+
try {
|
|
498
|
+
console[method]("[evident]", JSON.stringify({ level, event, ...fields }));
|
|
499
|
+
} catch (err) {
|
|
500
|
+
console.error(
|
|
501
|
+
"[evident] log_serialize_failed",
|
|
502
|
+
event,
|
|
503
|
+
err instanceof Error ? err.message : String(err)
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function stripQuery(url) {
|
|
508
|
+
try {
|
|
509
|
+
return new URL(url).pathname;
|
|
510
|
+
} catch {
|
|
511
|
+
const q = url.indexOf("?");
|
|
512
|
+
return q === -1 ? url : url.slice(0, q);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
493
516
|
// src/lib/telemetry.ts
|
|
494
517
|
var CLI_VERSION = process.env.npm_package_version || "unknown";
|
|
495
518
|
var eventBuffer = [];
|
|
@@ -1192,12 +1215,20 @@ var StreamForwarder = class {
|
|
|
1192
1215
|
}
|
|
1193
1216
|
async handleOpen(frame) {
|
|
1194
1217
|
const { sid, method, path, headers, has_body } = frame;
|
|
1218
|
+
const correlationId = headers?.[CORRELATION_ID_HEADER];
|
|
1219
|
+
const startedAt = Date.now();
|
|
1195
1220
|
if (path === TUNNEL_DRAIN_PING_PATH) {
|
|
1196
1221
|
this.callbacks.onDrainPing?.();
|
|
1197
1222
|
this.send({ type: "head", sid, status: 204, headers: {} });
|
|
1198
1223
|
this.send({ type: "res_end", sid });
|
|
1199
1224
|
return;
|
|
1200
1225
|
}
|
|
1226
|
+
log("info", "agent_request", {
|
|
1227
|
+
correlation_id: correlationId,
|
|
1228
|
+
sid,
|
|
1229
|
+
method,
|
|
1230
|
+
path: stripQuery(path)
|
|
1231
|
+
});
|
|
1201
1232
|
const ac = new AbortController();
|
|
1202
1233
|
let bodyPromise;
|
|
1203
1234
|
let pushBody;
|
|
@@ -1244,6 +1275,12 @@ var StreamForwarder = class {
|
|
|
1244
1275
|
if (!STRIP_RES.has(key.toLowerCase())) resHeaders[key] = value;
|
|
1245
1276
|
});
|
|
1246
1277
|
this.send({ type: "head", sid, status: upstream.status, headers: resHeaders });
|
|
1278
|
+
log("info", "agent_response", {
|
|
1279
|
+
correlation_id: correlationId,
|
|
1280
|
+
sid,
|
|
1281
|
+
status: upstream.status,
|
|
1282
|
+
duration_ms: Date.now() - startedAt
|
|
1283
|
+
});
|
|
1247
1284
|
this.callbacks.onHead?.(sid, upstream.status);
|
|
1248
1285
|
try {
|
|
1249
1286
|
if (upstream.body) {
|
|
@@ -2535,7 +2572,7 @@ async function getAgentInfo(agentId, authHeader) {
|
|
|
2535
2572
|
// src/commands/run.ts
|
|
2536
2573
|
var MAX_ACTIVITY_LOG_ENTRIES = 10;
|
|
2537
2574
|
var CHANNEL_POLL_INTERVAL_MS = Number(process.env.EVIDENT_CHANNEL_POLL_INTERVAL_MS) || 2e3;
|
|
2538
|
-
function
|
|
2575
|
+
function log2(state, message, isError = false) {
|
|
2539
2576
|
if (state.json) {
|
|
2540
2577
|
console.log(
|
|
2541
2578
|
JSON.stringify({
|
|
@@ -2560,9 +2597,9 @@ function logActivity(state, entry) {
|
|
|
2560
2597
|
}
|
|
2561
2598
|
if (!state.interactive) {
|
|
2562
2599
|
if (entry.type === "error") {
|
|
2563
|
-
|
|
2600
|
+
log2(state, entry.error ?? "Unknown error", true);
|
|
2564
2601
|
} else if (entry.type === "info" && entry.message) {
|
|
2565
|
-
|
|
2602
|
+
log2(state, entry.message);
|
|
2566
2603
|
}
|
|
2567
2604
|
}
|
|
2568
2605
|
}
|
|
@@ -2709,7 +2746,7 @@ async function cleanup(state) {
|
|
|
2709
2746
|
logActivity(state, { type: "info", message: "Stopped OpenCode process" });
|
|
2710
2747
|
displayStatus(state);
|
|
2711
2748
|
} else {
|
|
2712
|
-
|
|
2749
|
+
log2(state, "Stopped OpenCode process");
|
|
2713
2750
|
}
|
|
2714
2751
|
state.opencodeProcess = null;
|
|
2715
2752
|
}
|
|
@@ -2735,7 +2772,7 @@ async function run(options) {
|
|
|
2735
2772
|
authHeader: ""
|
|
2736
2773
|
};
|
|
2737
2774
|
if (state.idleTimeout === null && (process.env.GITHUB_ACTIONS || process.env.CI)) {
|
|
2738
|
-
|
|
2775
|
+
log2(
|
|
2739
2776
|
state,
|
|
2740
2777
|
"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.",
|
|
2741
2778
|
false
|
|
@@ -2746,7 +2783,7 @@ async function run(options) {
|
|
|
2746
2783
|
logActivity(state, { type: "info", message: "Shutting down..." });
|
|
2747
2784
|
displayStatus(state);
|
|
2748
2785
|
} else {
|
|
2749
|
-
|
|
2786
|
+
log2(state, "Shutting down...");
|
|
2750
2787
|
}
|
|
2751
2788
|
await cleanup(state);
|
|
2752
2789
|
await shutdownTelemetry();
|
|
@@ -2779,7 +2816,7 @@ async function run(options) {
|
|
|
2779
2816
|
const resolved = await resolveAgentIdFromKey(state.authHeader);
|
|
2780
2817
|
if (resolved.agent_id) {
|
|
2781
2818
|
state.agentId = resolved.agent_id;
|
|
2782
|
-
|
|
2819
|
+
log2(state, `Resolved agent ID from key: ${state.agentId}`);
|
|
2783
2820
|
if (state.interactive && !state.json) {
|
|
2784
2821
|
logActivity(state, {
|
|
2785
2822
|
type: "info",
|
|
@@ -2842,7 +2879,7 @@ async function run(options) {
|
|
|
2842
2879
|
port: state.port,
|
|
2843
2880
|
interactive: state.interactive,
|
|
2844
2881
|
agentId: state.agentId,
|
|
2845
|
-
log: (message) =>
|
|
2882
|
+
log: (message) => log2(state, message)
|
|
2846
2883
|
});
|
|
2847
2884
|
state.port = oc.port;
|
|
2848
2885
|
state.opencodeProcess = oc.process;
|
|
@@ -2852,7 +2889,7 @@ async function run(options) {
|
|
|
2852
2889
|
ocSpinner?.succeed(`OpenCode running on port ${state.port}${version}`);
|
|
2853
2890
|
const versionWarning = buildOpenCodeVersionWarning(state.opencodeVersion);
|
|
2854
2891
|
if (versionWarning) {
|
|
2855
|
-
|
|
2892
|
+
log2(state, versionWarning, false);
|
|
2856
2893
|
if (state.interactive && !state.json) {
|
|
2857
2894
|
logActivity(state, { type: "info", message: versionWarning });
|
|
2858
2895
|
}
|
|
@@ -2962,7 +2999,7 @@ async function run(options) {
|
|
|
2962
2999
|
throw error2;
|
|
2963
3000
|
}
|
|
2964
3001
|
if (!interactive || state.json) {
|
|
2965
|
-
|
|
3002
|
+
log2(state, "Driving channel messages...");
|
|
2966
3003
|
}
|
|
2967
3004
|
await driveChannels(state, channelDriver);
|
|
2968
3005
|
await cleanup(state);
|
|
@@ -2974,7 +3011,7 @@ async function run(options) {
|
|
|
2974
3011
|
})
|
|
2975
3012
|
);
|
|
2976
3013
|
} else if (!interactive) {
|
|
2977
|
-
|
|
3014
|
+
log2(state, `Completed. Processed ${state.messageCount} message(s).`);
|
|
2978
3015
|
}
|
|
2979
3016
|
await shutdownTelemetry();
|
|
2980
3017
|
process.exit(0);
|