@askalf/dario 3.31.18 → 3.31.19
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.d.ts +24 -0
- package/dist/cli.js +39 -8
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -48,3 +48,27 @@ export declare function parseBooleanEnv(value: string | undefined): boolean | un
|
|
|
48
48
|
* Set(['thinking','env']) — value "thinking,env" → preserve listed
|
|
49
49
|
*/
|
|
50
50
|
export declare function resolvePreserveOrchestrationTags(args: string[], env: string | undefined): Set<string> | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Decide whether this module is being invoked as the CLI entry point or
|
|
53
|
+
* imported as a library. Pure, exported for tests; the file-bottom uses
|
|
54
|
+
* it with `process.argv[1]` + `import.meta.url` + `fs.realpathSync`.
|
|
55
|
+
*
|
|
56
|
+
* The pre-v3.31.19 implementation was a strict string compare —
|
|
57
|
+
* import.meta.url === pathToFileURL(process.argv[1]).href
|
|
58
|
+
* — which silently failed on every npm-global install because the bin
|
|
59
|
+
* shim path (e.g. `/usr/local/bin/dario`) is a symlink to `dist/cli.js`.
|
|
60
|
+
* `argv[1]` arrived as the *symlink* path while `import.meta.url`
|
|
61
|
+
* resolved through the symlink to the real file. They never matched,
|
|
62
|
+
* the guard returned false, and the entire CLI body was gated out —
|
|
63
|
+
* `dario doctor`, `dario proxy`, every command produced zero output and
|
|
64
|
+
* exited 0. Reported as dario#143 by @tetsuco.
|
|
65
|
+
*
|
|
66
|
+
* The fix: also check the symlink-resolved path. `realpathSync`
|
|
67
|
+
* canonicalizes the argv[1] symlink into the same on-disk path that
|
|
68
|
+
* `import.meta.url` already represents, so a global-install bin-shim
|
|
69
|
+
* invocation matches. Direct invocation (`node dist/cli.js`) still
|
|
70
|
+
* matches via the first leg. Test-side imports of named exports still
|
|
71
|
+
* don't match either leg, which preserves the original purpose of the
|
|
72
|
+
* guard from #137 (v3.31.15).
|
|
73
|
+
*/
|
|
74
|
+
export declare function isMainEntry(argv1: string | undefined | null, moduleHref: string, realpath?: (p: string) => string): boolean;
|
package/dist/cli.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
// just want `parsePositiveIntEnv`) doesn't trigger a Bun relaunch or any
|
|
18
18
|
// other startup side effect.
|
|
19
19
|
import { unlink } from 'node:fs/promises';
|
|
20
|
+
import { realpathSync } from 'node:fs';
|
|
20
21
|
import { join } from 'node:path';
|
|
21
22
|
import { homedir } from 'node:os';
|
|
22
23
|
import { pathToFileURL } from 'node:url';
|
|
@@ -1154,14 +1155,44 @@ const commands = {
|
|
|
1154
1155
|
'--version': version,
|
|
1155
1156
|
'-V': version,
|
|
1156
1157
|
};
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1158
|
+
/**
|
|
1159
|
+
* Decide whether this module is being invoked as the CLI entry point or
|
|
1160
|
+
* imported as a library. Pure, exported for tests; the file-bottom uses
|
|
1161
|
+
* it with `process.argv[1]` + `import.meta.url` + `fs.realpathSync`.
|
|
1162
|
+
*
|
|
1163
|
+
* The pre-v3.31.19 implementation was a strict string compare —
|
|
1164
|
+
* import.meta.url === pathToFileURL(process.argv[1]).href
|
|
1165
|
+
* — which silently failed on every npm-global install because the bin
|
|
1166
|
+
* shim path (e.g. `/usr/local/bin/dario`) is a symlink to `dist/cli.js`.
|
|
1167
|
+
* `argv[1]` arrived as the *symlink* path while `import.meta.url`
|
|
1168
|
+
* resolved through the symlink to the real file. They never matched,
|
|
1169
|
+
* the guard returned false, and the entire CLI body was gated out —
|
|
1170
|
+
* `dario doctor`, `dario proxy`, every command produced zero output and
|
|
1171
|
+
* exited 0. Reported as dario#143 by @tetsuco.
|
|
1172
|
+
*
|
|
1173
|
+
* The fix: also check the symlink-resolved path. `realpathSync`
|
|
1174
|
+
* canonicalizes the argv[1] symlink into the same on-disk path that
|
|
1175
|
+
* `import.meta.url` already represents, so a global-install bin-shim
|
|
1176
|
+
* invocation matches. Direct invocation (`node dist/cli.js`) still
|
|
1177
|
+
* matches via the first leg. Test-side imports of named exports still
|
|
1178
|
+
* don't match either leg, which preserves the original purpose of the
|
|
1179
|
+
* guard from #137 (v3.31.15).
|
|
1180
|
+
*/
|
|
1181
|
+
export function isMainEntry(argv1, moduleHref, realpath = realpathSync) {
|
|
1182
|
+
if (typeof argv1 !== 'string' || argv1.length === 0)
|
|
1183
|
+
return false;
|
|
1184
|
+
if (moduleHref === pathToFileURL(argv1).href)
|
|
1185
|
+
return true;
|
|
1186
|
+
try {
|
|
1187
|
+
return moduleHref === pathToFileURL(realpath(argv1)).href;
|
|
1188
|
+
}
|
|
1189
|
+
catch {
|
|
1190
|
+
return false;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
// Main-entry guard. Only run the Bun auto-relaunch and handler dispatch
|
|
1194
|
+
// when this module is the direct CLI entry point.
|
|
1195
|
+
const isDirectEntry = isMainEntry(process.argv[1], import.meta.url);
|
|
1165
1196
|
if (isDirectEntry) {
|
|
1166
1197
|
// Bun auto-relaunch for TLS fingerprint fidelity. Only meaningful when
|
|
1167
1198
|
// dario is the direct entry — if we're imported, whoever imported us
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askalf/dario",
|
|
3
|
-
"version": "3.31.
|
|
3
|
+
"version": "3.31.19",
|
|
4
4
|
"description": "A local LLM router. One endpoint, every provider — Claude subscriptions, OpenAI, OpenRouter, Groq, local LiteLLM, any OpenAI-compat endpoint — your tools don't need to change.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|