@mitsein-ai/cli 0.1.2 → 0.1.3
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 +267 -136
- package/package.json +4 -3
- package/src/core/proxy.ts +29 -0
- package/src/index.ts +4 -0
package/package.json
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"commander": "^13.1.0",
|
|
7
7
|
"consola": "^3.4.2",
|
|
8
|
-
"ofetch": "^1.4.1"
|
|
8
|
+
"ofetch": "^1.4.1",
|
|
9
|
+
"undici": "^8.0.2"
|
|
9
10
|
},
|
|
10
|
-
"description": "Mitsein CLI
|
|
11
|
+
"description": "Mitsein CLI — dev tooling, API helpers, and workflow automation",
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@types/bun": "latest",
|
|
13
14
|
"typescript": "^5.3.3"
|
|
@@ -45,5 +46,5 @@
|
|
|
45
46
|
"typecheck": "tsc --noEmit"
|
|
46
47
|
},
|
|
47
48
|
"type": "module",
|
|
48
|
-
"version": "0.1.
|
|
49
|
+
"version": "0.1.3"
|
|
49
50
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set up HTTP proxy support for Node.js fetch (undici).
|
|
3
|
+
* Reads https_proxy / http_proxy / HTTPS_PROXY / HTTP_PROXY env vars.
|
|
4
|
+
* Must be called before any fetch() calls.
|
|
5
|
+
*/
|
|
6
|
+
export function setupProxy(): void {
|
|
7
|
+
const proxyUrl =
|
|
8
|
+
process.env.https_proxy ??
|
|
9
|
+
process.env.HTTPS_PROXY ??
|
|
10
|
+
process.env.http_proxy ??
|
|
11
|
+
process.env.HTTP_PROXY;
|
|
12
|
+
|
|
13
|
+
if (!proxyUrl) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Dynamic import to avoid bundling issues when undici is not available
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
20
|
+
const { ProxyAgent, setGlobalDispatcher } = require('undici') as typeof import('undici');
|
|
21
|
+
const agent = new ProxyAgent(proxyUrl);
|
|
22
|
+
setGlobalDispatcher(agent);
|
|
23
|
+
} catch {
|
|
24
|
+
// undici not available — proxy won't work but CLI still runs
|
|
25
|
+
process.stderr.write(
|
|
26
|
+
`[warn] Proxy ${proxyUrl} detected but undici not available. Install undici for proxy support.\n`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import consola from 'consola';
|
|
4
|
+
import { setupProxy } from './core/proxy.js';
|
|
4
5
|
import { registerAgent } from './commands/agent.js';
|
|
5
6
|
import { registerApi } from './commands/api-auto.js';
|
|
6
7
|
import { registerAuth } from './commands/auth.js';
|
|
@@ -17,6 +18,9 @@ interface GlobalOpts {
|
|
|
17
18
|
json?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
// Set up proxy support before any fetch calls
|
|
22
|
+
setupProxy();
|
|
23
|
+
|
|
20
24
|
const program = new Command();
|
|
21
25
|
|
|
22
26
|
program
|