@pauly4010/evalai-sdk 1.7.0 → 1.8.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/CHANGELOG.md +70 -0
- package/README.md +42 -1
- package/dist/cli/check.js +15 -0
- package/dist/cli/doctor.d.ts +80 -3
- package/dist/cli/doctor.js +576 -43
- package/dist/cli/explain.d.ts +58 -0
- package/dist/cli/explain.js +429 -0
- package/dist/cli/formatters/github.js +5 -0
- package/dist/cli/formatters/types.d.ts +3 -0
- package/dist/cli/formatters/types.js +3 -0
- package/dist/cli/index.js +41 -4
- package/dist/cli/init.js +16 -4
- package/dist/cli/print-config.d.ts +29 -0
- package/dist/cli/print-config.js +251 -0
- package/dist/cli/report/build-check-report.d.ts +1 -1
- package/dist/cli/report/build-check-report.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* evalai print-config — Show resolved configuration with source-of-truth annotations.
|
|
4
|
+
*
|
|
5
|
+
* Prints every config field, where it came from (file, env, default, CLI arg),
|
|
6
|
+
* and redacts secrets. Useful for debugging "why is it using this baseUrl?"
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* evalai print-config
|
|
10
|
+
* evalai print-config --format json
|
|
11
|
+
*
|
|
12
|
+
* Exit codes:
|
|
13
|
+
* 0 — Always (informational only)
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.runPrintConfig = runPrintConfig;
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
51
|
+
const version_1 = require("../version");
|
|
52
|
+
const config_1 = require("./config");
|
|
53
|
+
const profiles_1 = require("./profiles");
|
|
54
|
+
function parseFlags(argv) {
|
|
55
|
+
const raw = {};
|
|
56
|
+
for (let i = 0; i < argv.length; i++) {
|
|
57
|
+
const arg = argv[i];
|
|
58
|
+
if (arg.startsWith("--")) {
|
|
59
|
+
const key = arg.slice(2);
|
|
60
|
+
const next = argv[i + 1];
|
|
61
|
+
if (next !== undefined && !next.startsWith("--")) {
|
|
62
|
+
raw[key] = next;
|
|
63
|
+
i++;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
raw[key] = "true";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
format: raw.format === "json" ? "json" : "human",
|
|
72
|
+
evaluationId: raw.evaluationId,
|
|
73
|
+
baseUrl: raw.baseUrl,
|
|
74
|
+
apiKey: raw.apiKey,
|
|
75
|
+
baseline: raw.baseline,
|
|
76
|
+
profile: raw.profile,
|
|
77
|
+
minScore: raw.minScore,
|
|
78
|
+
maxDrop: raw.maxDrop,
|
|
79
|
+
warnDrop: raw.warnDrop,
|
|
80
|
+
minN: raw.minN,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// ── Helpers ──
|
|
84
|
+
function redact(value) {
|
|
85
|
+
if (!value)
|
|
86
|
+
return null;
|
|
87
|
+
if (value.length > 8)
|
|
88
|
+
return `${value.slice(0, 4)}...${value.slice(-4)}`;
|
|
89
|
+
return "****";
|
|
90
|
+
}
|
|
91
|
+
// ── Build resolved config ──
|
|
92
|
+
function buildResolvedConfig(cwd, flags) {
|
|
93
|
+
const configPath = (0, config_1.findConfigPath)(cwd);
|
|
94
|
+
const fileConfig = (0, config_1.loadConfig)(cwd);
|
|
95
|
+
// Build CLI args object (only what was explicitly passed)
|
|
96
|
+
const cliArgs = {};
|
|
97
|
+
if (flags.evaluationId)
|
|
98
|
+
cliArgs.evaluationId = flags.evaluationId;
|
|
99
|
+
if (flags.baseUrl)
|
|
100
|
+
cliArgs.baseUrl = flags.baseUrl;
|
|
101
|
+
if (flags.baseline)
|
|
102
|
+
cliArgs.baseline = flags.baseline;
|
|
103
|
+
if (flags.profile)
|
|
104
|
+
cliArgs.profile = flags.profile;
|
|
105
|
+
if (flags.minScore)
|
|
106
|
+
cliArgs.minScore = flags.minScore;
|
|
107
|
+
if (flags.maxDrop)
|
|
108
|
+
cliArgs.maxDrop = flags.maxDrop;
|
|
109
|
+
if (flags.warnDrop)
|
|
110
|
+
cliArgs.warnDrop = flags.warnDrop;
|
|
111
|
+
if (flags.minN)
|
|
112
|
+
cliArgs.minN = flags.minN;
|
|
113
|
+
const merged = (0, config_1.mergeConfigWithArgs)(fileConfig, cliArgs);
|
|
114
|
+
// Determine source of each field
|
|
115
|
+
const fields = [];
|
|
116
|
+
// evaluationId
|
|
117
|
+
const evalIdSource = flags.evaluationId ? "arg"
|
|
118
|
+
: fileConfig?.evaluationId ? "file"
|
|
119
|
+
: "default";
|
|
120
|
+
fields.push({
|
|
121
|
+
key: "evaluationId",
|
|
122
|
+
value: merged.evaluationId ?? null,
|
|
123
|
+
source: evalIdSource,
|
|
124
|
+
});
|
|
125
|
+
// baseUrl
|
|
126
|
+
const envBaseUrl = process.env.EVALAI_BASE_URL;
|
|
127
|
+
const baseUrlSource = flags.baseUrl ? "arg"
|
|
128
|
+
: envBaseUrl ? "env"
|
|
129
|
+
: fileConfig?.baseUrl ? "file"
|
|
130
|
+
: "default";
|
|
131
|
+
fields.push({
|
|
132
|
+
key: "baseUrl",
|
|
133
|
+
value: flags.baseUrl || envBaseUrl || fileConfig?.baseUrl || "http://localhost:3000",
|
|
134
|
+
source: baseUrlSource,
|
|
135
|
+
});
|
|
136
|
+
// apiKey (always redacted)
|
|
137
|
+
const envApiKey = process.env.EVALAI_API_KEY;
|
|
138
|
+
const rawApiKey = flags.apiKey || envApiKey || "";
|
|
139
|
+
const apiKeySource = flags.apiKey ? "arg"
|
|
140
|
+
: envApiKey ? "env"
|
|
141
|
+
: "default";
|
|
142
|
+
fields.push({
|
|
143
|
+
key: "apiKey",
|
|
144
|
+
value: redact(rawApiKey) ?? "(not set)",
|
|
145
|
+
source: apiKeySource,
|
|
146
|
+
raw: rawApiKey ? "(redacted)" : undefined,
|
|
147
|
+
});
|
|
148
|
+
// profile
|
|
149
|
+
const profileName = (flags.profile || fileConfig?.profile);
|
|
150
|
+
const profileSource = flags.profile ? "arg" : fileConfig?.profile ? "file" : "default";
|
|
151
|
+
fields.push({
|
|
152
|
+
key: "profile",
|
|
153
|
+
value: profileName ?? null,
|
|
154
|
+
source: profileSource,
|
|
155
|
+
});
|
|
156
|
+
// Numeric gate fields: minScore, maxDrop, warnDrop, minN, allowWeakEvidence
|
|
157
|
+
const numericFields = [
|
|
158
|
+
{ key: "minScore" },
|
|
159
|
+
{ key: "maxDrop" },
|
|
160
|
+
{ key: "warnDrop" },
|
|
161
|
+
{ key: "minN" },
|
|
162
|
+
{ key: "allowWeakEvidence" },
|
|
163
|
+
];
|
|
164
|
+
for (const { key } of numericFields) {
|
|
165
|
+
const argVal = cliArgs[key];
|
|
166
|
+
const fileVal = fileConfig?.[key];
|
|
167
|
+
const profileVal = profileName && profileName in profiles_1.PROFILES
|
|
168
|
+
? profiles_1.PROFILES[profileName][key]
|
|
169
|
+
: undefined;
|
|
170
|
+
const source = argVal !== undefined ? "arg"
|
|
171
|
+
: fileVal !== undefined ? "file"
|
|
172
|
+
: profileVal !== undefined ? "profile"
|
|
173
|
+
: "default";
|
|
174
|
+
fields.push({
|
|
175
|
+
key,
|
|
176
|
+
value: merged[key] ?? null,
|
|
177
|
+
source,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
// baseline
|
|
181
|
+
const baselineSource = flags.baseline ? "arg"
|
|
182
|
+
: fileConfig?.baseline ? "file"
|
|
183
|
+
: "default";
|
|
184
|
+
fields.push({
|
|
185
|
+
key: "baseline",
|
|
186
|
+
value: merged.baseline ?? "published",
|
|
187
|
+
source: baselineSource,
|
|
188
|
+
});
|
|
189
|
+
// Environment variables summary
|
|
190
|
+
const envVars = {
|
|
191
|
+
EVALAI_API_KEY: redact(envApiKey),
|
|
192
|
+
EVALAI_BASE_URL: envBaseUrl ?? null,
|
|
193
|
+
OPENAI_API_KEY: redact(process.env.OPENAI_API_KEY),
|
|
194
|
+
ANTHROPIC_API_KEY: redact(process.env.ANTHROPIC_API_KEY),
|
|
195
|
+
AZURE_OPENAI_API_KEY: redact(process.env.AZURE_OPENAI_API_KEY),
|
|
196
|
+
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS ?? null,
|
|
197
|
+
CI: process.env.CI ?? null,
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
cliVersion: version_1.SDK_VERSION,
|
|
201
|
+
configFile: configPath ? path.relative(cwd, configPath) : null,
|
|
202
|
+
cwd,
|
|
203
|
+
resolved: fields,
|
|
204
|
+
env: envVars,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
// ── Output formatting ──
|
|
208
|
+
function printHuman(output) {
|
|
209
|
+
console.log("\n evalai print-config\n");
|
|
210
|
+
console.log(` CLI version: ${output.cliVersion}`);
|
|
211
|
+
console.log(` Config file: ${output.configFile ?? "(none found)"}`);
|
|
212
|
+
console.log(` Working dir: ${output.cwd}`);
|
|
213
|
+
console.log("");
|
|
214
|
+
console.log(" Resolved configuration:");
|
|
215
|
+
console.log("");
|
|
216
|
+
const maxKeyLen = Math.max(...output.resolved.map((f) => f.key.length));
|
|
217
|
+
for (const field of output.resolved) {
|
|
218
|
+
const val = field.value === null ? "(not set)" : String(field.value);
|
|
219
|
+
const pad = " ".repeat(maxKeyLen - field.key.length);
|
|
220
|
+
const sourceTag = `[${field.source}]`;
|
|
221
|
+
console.log(` ${field.key}${pad} ${val} ${sourceTag}`);
|
|
222
|
+
}
|
|
223
|
+
console.log("");
|
|
224
|
+
console.log(" Environment variables:");
|
|
225
|
+
console.log("");
|
|
226
|
+
for (const [key, val] of Object.entries(output.env)) {
|
|
227
|
+
if (val !== null) {
|
|
228
|
+
console.log(` ${key} = ${val}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const unsetEnv = Object.entries(output.env)
|
|
232
|
+
.filter(([, v]) => v === null)
|
|
233
|
+
.map(([k]) => k);
|
|
234
|
+
if (unsetEnv.length > 0) {
|
|
235
|
+
console.log(` (not set: ${unsetEnv.join(", ")})`);
|
|
236
|
+
}
|
|
237
|
+
console.log("");
|
|
238
|
+
}
|
|
239
|
+
// ── Main ──
|
|
240
|
+
function runPrintConfig(argv) {
|
|
241
|
+
const flags = parseFlags(argv);
|
|
242
|
+
const cwd = process.cwd();
|
|
243
|
+
const output = buildResolvedConfig(cwd, flags);
|
|
244
|
+
if (flags.format === "json") {
|
|
245
|
+
console.log(JSON.stringify(output, null, 2));
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
printHuman(output);
|
|
249
|
+
}
|
|
250
|
+
return 0;
|
|
251
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { QualityLatestData, RunDetailsData } from "../api";
|
|
6
6
|
import type { CheckArgs } from "../check";
|
|
7
|
-
import type
|
|
7
|
+
import { type CheckReport } from "../formatters/types";
|
|
8
8
|
import type { GateResult } from "../gate";
|
|
9
9
|
export type BuildReportInput = {
|
|
10
10
|
args: CheckArgs;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.buildCheckReport = buildCheckReport;
|
|
8
|
+
const types_1 = require("../formatters/types");
|
|
8
9
|
const snippet_1 = require("../render/snippet");
|
|
9
10
|
const sort_1 = require("../render/sort");
|
|
10
11
|
const TOP_N = 3;
|
|
@@ -69,6 +70,7 @@ function buildCheckReport(input) {
|
|
|
69
70
|
: (gateResult.reasonMessage ?? undefined);
|
|
70
71
|
const verdict = gateResult.reasonCode === "WARN_REGRESSION" ? "warn" : gateResult.passed ? "pass" : "fail";
|
|
71
72
|
const report = {
|
|
73
|
+
schemaVersion: types_1.CHECK_REPORT_SCHEMA_VERSION,
|
|
72
74
|
evaluationId: args.evaluationId,
|
|
73
75
|
runId: evaluationRunId,
|
|
74
76
|
verdict,
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -6,5 +6,5 @@ exports.SPEC_VERSION = exports.SDK_VERSION = void 0;
|
|
|
6
6
|
* X-EvalAI-SDK-Version: SDK package version
|
|
7
7
|
* X-EvalAI-Spec-Version: OpenAPI spec version (docs/openapi.json info.version)
|
|
8
8
|
*/
|
|
9
|
-
exports.SDK_VERSION = "1.
|
|
9
|
+
exports.SDK_VERSION = "1.8.0";
|
|
10
10
|
exports.SPEC_VERSION = "1.0.0";
|