omniharness-cli 0.1.53 → 0.1.55
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 +27 -2
- 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();
|
|
@@ -43,15 +52,31 @@ else if (command === 'doctor') {
|
|
|
43
52
|
}
|
|
44
53
|
else if (command === 'models') {
|
|
45
54
|
void (async () => {
|
|
55
|
+
const client = new OmniRouteClient();
|
|
46
56
|
try {
|
|
47
|
-
console.log((await models(
|
|
57
|
+
console.log((await models(client)).join('\n'));
|
|
48
58
|
}
|
|
49
59
|
catch (error) {
|
|
50
|
-
|
|
60
|
+
// "fetch failed" on its own tells the user nothing they can act on.
|
|
61
|
+
// Name the endpoint that was tried and what to check, the way doctor
|
|
62
|
+
// does — a connection failure here almost always means the gateway is
|
|
63
|
+
// not running or OMNIROUTE_URL points somewhere else.
|
|
64
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
65
|
+
console.error(`omniharness models: ${reason}`);
|
|
66
|
+
console.error(` endpoint: ${client.endpoint}`);
|
|
67
|
+
console.error(' check that OmniRoute is running, and that OMNIROUTE_URL points at it');
|
|
68
|
+
console.error(" run 'omniharness doctor' for a full connection report");
|
|
51
69
|
process.exitCode = 1;
|
|
52
70
|
}
|
|
53
71
|
})();
|
|
54
72
|
}
|
|
73
|
+
else if (command !== undefined) {
|
|
74
|
+
// Anything else is a mistake, not an invitation to open the TUI: `omniharness
|
|
75
|
+
// doctr` used to start an interactive session instead of naming the typo.
|
|
76
|
+
console.error(`omniharness: unknown command '${command}'`);
|
|
77
|
+
console.error("run 'omniharness --help' for usage");
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
}
|
|
55
80
|
else {
|
|
56
81
|
void (async () => {
|
|
57
82
|
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;
|