omniharness-cli 0.1.53 → 0.1.54
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/cli.js +16 -0
- package/dist/config/omniRoute.js +17 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -24,6 +24,15 @@ function dumpTranscript(messages) {
|
|
|
24
24
|
}
|
|
25
25
|
process.stdout.write('\n');
|
|
26
26
|
}
|
|
27
|
+
// A crash anywhere below would otherwise surface as a raw Node stack trace, or
|
|
28
|
+
// as an unhandled rejection that terminates the process without saying why.
|
|
29
|
+
// A CLI should fail with a sentence.
|
|
30
|
+
function die(error) {
|
|
31
|
+
console.error(`omniharness: ${error instanceof Error ? error.message : String(error)}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
process.on('unhandledRejection', die);
|
|
35
|
+
process.on('uncaughtException', die);
|
|
27
36
|
const command = process.argv[2];
|
|
28
37
|
if (command === 'update') {
|
|
29
38
|
process.exitCode = runUpdate();
|
|
@@ -52,6 +61,13 @@ else if (command === 'models') {
|
|
|
52
61
|
}
|
|
53
62
|
})();
|
|
54
63
|
}
|
|
64
|
+
else if (command !== undefined) {
|
|
65
|
+
// Anything else is a mistake, not an invitation to open the TUI: `omniharness
|
|
66
|
+
// doctr` used to start an interactive session instead of naming the typo.
|
|
67
|
+
console.error(`omniharness: unknown command '${command}'`);
|
|
68
|
+
console.error("run 'omniharness --help' for usage");
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
}
|
|
55
71
|
else {
|
|
56
72
|
void (async () => {
|
|
57
73
|
const saved = await readActiveCombo();
|
package/dist/config/omniRoute.js
CHANGED
|
@@ -7,6 +7,22 @@ export class OmniRouteError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
const DEFAULT_ENDPOINT = 'http://localhost:20128';
|
|
10
|
+
/**
|
|
11
|
+
* First value that is actually set, treating blank strings as unset.
|
|
12
|
+
*
|
|
13
|
+
* `??` only falls back on null/undefined, so `OMNIROUTE_URL=` — routine in a
|
|
14
|
+
* .env file, a docker-compose entry, or CI where a variable is declared but
|
|
15
|
+
* left empty — produced an empty endpoint and every request failed with
|
|
16
|
+
* "Failed to parse URL". The Go side has always treated empty as unset; this
|
|
17
|
+
* matches it.
|
|
18
|
+
*/
|
|
19
|
+
function firstSet(...values) {
|
|
20
|
+
for (const value of values) {
|
|
21
|
+
if (value !== undefined && value.trim() !== '')
|
|
22
|
+
return value.trim();
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
10
26
|
export class OmniRouteClient {
|
|
11
27
|
endpoint;
|
|
12
28
|
timeoutMs;
|
|
@@ -19,7 +35,7 @@ export class OmniRouteClient {
|
|
|
19
35
|
requestCount: 0,
|
|
20
36
|
};
|
|
21
37
|
constructor(config = {}) {
|
|
22
|
-
this.endpoint = (config.endpoint
|
|
38
|
+
this.endpoint = (firstSet(config.endpoint, process.env.OMNIROUTE_URL) ?? DEFAULT_ENDPOINT).replace(/\/$/, '');
|
|
23
39
|
this.apiKey = config.apiKey ?? process.env.OMNIROUTE_API_KEY ?? '';
|
|
24
40
|
this.mgmtToken = config.mgmtToken ?? process.env.OMNIROUTE_MGMT_TOKEN ?? '';
|
|
25
41
|
this.timeoutMs = config.timeoutMs ?? 120_000;
|