@model-go/cli 0.1.2 → 0.1.4
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/README.md +15 -4
- package/package.json +5 -3
- package/scripts/install.js +48 -13
- package/checksums.txt +0 -6
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The official CLI for modelgo. Pairs with AI agent skills (Claude Code, Codex, Gemini CLI, etc.) so AI agents can operate modelgo on your behalf.
|
|
4
4
|
|
|
5
|
-
> **v0 framework stage.**
|
|
5
|
+
> **v0 framework stage.** Device-flow `auth` commands are available. `modelgo pay request` supports anonymous x402 pay-per-call calls to model gateway APIs; API key management is not wired up yet.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -17,9 +17,9 @@ This runs an interactive wizard that:
|
|
|
17
17
|
|
|
18
18
|
After install, restart your AI agent (open a new chat / session) and try:
|
|
19
19
|
|
|
20
|
-
> "
|
|
20
|
+
> "Check my modelgo login status."
|
|
21
21
|
|
|
22
|
-
Your AI should find the `modelgo-
|
|
22
|
+
Your AI should find the `modelgo-shared` skill and run `modelgo auth status`.
|
|
23
23
|
|
|
24
24
|
## Direct commands
|
|
25
25
|
|
|
@@ -28,7 +28,8 @@ modelgo --version
|
|
|
28
28
|
modelgo auth login
|
|
29
29
|
modelgo auth status
|
|
30
30
|
modelgo auth logout
|
|
31
|
-
modelgo
|
|
31
|
+
modelgo pay methods
|
|
32
|
+
modelgo pay request --env cn --path /v1/chat/completions --method POST --data '{"model":"gpt-4o","messages":[]}' --json
|
|
32
33
|
modelgo --help
|
|
33
34
|
```
|
|
34
35
|
|
|
@@ -87,6 +88,16 @@ seeing the URL before the agent starts waiting.
|
|
|
87
88
|
> `JSON.parse` the whole stream. With `--no-wait`, only the device-code object
|
|
88
89
|
> is printed.
|
|
89
90
|
|
|
91
|
+
### x402 pay-per-call model APIs
|
|
92
|
+
|
|
93
|
+
Use `modelgo pay request` when the user wants to call a model API without logging in to ModelGo first. The CLI opts into the gateway x402 path with `X-Payment-Protocol: x402`.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
modelgo pay request --env cn --path /v1/chat/completions --method POST --data '{"model":"gpt-4o","messages":[{"role":"user","content":"hello"}]}' --intent "调用 gpt-4o 完成聊天补全" --json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
In the `cn` environment, if the gateway returns a 402 that advertises `alipay:*`, the CLI writes the `PAYMENT-REQUIRED` payload to a local file and returns a structured handoff for `alipay-payment-skill`. In `intl`, the CLI does not route to Alipay; it returns the advertised x402 options for a future non-Alipay rail.
|
|
100
|
+
|
|
90
101
|
## Upgrade
|
|
91
102
|
|
|
92
103
|
Re-run the installer; it detects an out-of-date install and upgrades in place:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@model-go/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The official CLI for modelgo. Pairs with AI agent skills so AI agents can operate modelgo on your behalf.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"modelgo": "scripts/run.js"
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"postinstall": "node scripts/install.js",
|
|
10
10
|
"test": "node --test scripts/__tests__/*.test.mjs",
|
|
11
|
-
"lint:skills": "node scripts/lint-skills.mjs"
|
|
11
|
+
"lint:skills": "node scripts/lint-skills.mjs",
|
|
12
|
+
"sync:skills": "node scripts/sync-skill-version.mjs",
|
|
13
|
+
"generate:reference": "node scripts/generate-reference.mjs",
|
|
14
|
+
"sync:skill-assets": "node scripts/generate-reference.mjs && node scripts/sync-skill-version.mjs"
|
|
12
15
|
},
|
|
13
16
|
"files": [
|
|
14
17
|
"scripts/install.js",
|
|
15
18
|
"scripts/install-wizard.js",
|
|
16
19
|
"scripts/run.js",
|
|
17
|
-
"checksums.txt",
|
|
18
20
|
"LICENSE",
|
|
19
21
|
"README.md"
|
|
20
22
|
],
|
package/scripts/install.js
CHANGED
|
@@ -31,6 +31,13 @@ const ext = isWindows ? ".zip" : ".tar.gz";
|
|
|
31
31
|
const archiveName = `${NAME}-${VERSION}-${platform}-${arch}${ext}`;
|
|
32
32
|
const GITHUB_URL = `https://github.com/${REPO}/releases/download/v${VERSION}/${archiveName}`;
|
|
33
33
|
|
|
34
|
+
// checksums.txt is published by goreleaser alongside the release artifacts.
|
|
35
|
+
// We fetch it from the release at install time rather than bundling it in the
|
|
36
|
+
// npm package: a bundled copy generated locally (goreleaser --snapshot) can
|
|
37
|
+
// never match the CI-built release artifacts' names or SHAs.
|
|
38
|
+
const CHECKSUMS_NAME = "checksums.txt";
|
|
39
|
+
const GITHUB_CHECKSUMS_URL = `https://github.com/${REPO}/releases/download/v${VERSION}/${CHECKSUMS_NAME}`;
|
|
40
|
+
|
|
34
41
|
const binDir = path.join(__dirname, "..", "bin");
|
|
35
42
|
const dest = path.join(binDir, NAME + (isWindows ? ".exe" : ""));
|
|
36
43
|
|
|
@@ -184,6 +191,21 @@ function download(url, destPath) {
|
|
|
184
191
|
execFileSync("curl", args, { stdio: ["ignore", "ignore", "pipe"] });
|
|
185
192
|
}
|
|
186
193
|
|
|
194
|
+
// Try each URL in order, returning once one succeeds. Throws the last error if
|
|
195
|
+
// all fail.
|
|
196
|
+
function downloadFirst(urls, destPath) {
|
|
197
|
+
let lastErr;
|
|
198
|
+
for (const url of urls) {
|
|
199
|
+
try {
|
|
200
|
+
download(url, destPath);
|
|
201
|
+
return;
|
|
202
|
+
} catch (e) {
|
|
203
|
+
lastErr = e;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
throw lastErr;
|
|
207
|
+
}
|
|
208
|
+
|
|
187
209
|
function extractZipWindows(archivePath, destDir) {
|
|
188
210
|
const psOpts = ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"];
|
|
189
211
|
const psStdio = ["ignore", "inherit", "inherit"];
|
|
@@ -228,20 +250,33 @@ function install() {
|
|
|
228
250
|
const archivePath = path.join(tmpDir, archiveName);
|
|
229
251
|
|
|
230
252
|
try {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
253
|
+
downloadFirst(downloadUrls, archivePath);
|
|
254
|
+
|
|
255
|
+
// Fetch the authoritative checksums.txt from the same release (GitHub
|
|
256
|
+
// first, then mirrors). If it can't be fetched (restricted network),
|
|
257
|
+
// skip verification rather than block the install — the binary itself
|
|
258
|
+
// came from an allowlisted host over HTTPS.
|
|
259
|
+
const checksumsUrls = [
|
|
260
|
+
GITHUB_CHECKSUMS_URL,
|
|
261
|
+
...resolveMirrorUrls(process.env, CHECKSUMS_NAME, VERSION),
|
|
262
|
+
];
|
|
263
|
+
for (const u of checksumsUrls) ALLOWED_HOSTS.add(new URL(u).hostname);
|
|
264
|
+
const checksumsPath = path.join(tmpDir, CHECKSUMS_NAME);
|
|
265
|
+
let checksumsFetched = true;
|
|
266
|
+
try {
|
|
267
|
+
downloadFirst(checksumsUrls, checksumsPath);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
checksumsFetched = false;
|
|
270
|
+
console.error(
|
|
271
|
+
`[WARN] could not fetch ${CHECKSUMS_NAME} from release ` +
|
|
272
|
+
`(${e.message}); skipping checksum verification`
|
|
273
|
+
);
|
|
241
274
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
const expectedHash =
|
|
275
|
+
// A fetched-but-incomplete checksums.txt is a real integrity problem and
|
|
276
|
+
// must fail loudly, so parse outside the network try/catch above.
|
|
277
|
+
const expectedHash = checksumsFetched
|
|
278
|
+
? getExpectedChecksum(archiveName, tmpDir)
|
|
279
|
+
: null;
|
|
245
280
|
verifyChecksum(archivePath, expectedHash);
|
|
246
281
|
|
|
247
282
|
if (isWindows) {
|
package/checksums.txt
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
818fc80cdbb471fe9abd2373c30795f4a138f4be4c812cdb3d25148b71a131ed modelgo-0.1.2-darwin-amd64.tar.gz
|
|
2
|
-
cb981e35d3652d2b0e3d50c0f0eadfd8ee1497887d1e529f7630581c8cfb29e5 modelgo-0.1.2-darwin-arm64.tar.gz
|
|
3
|
-
974822455dd0b423e91a096b00fb6d28750f42ceb982185a434d14d6396974dd modelgo-0.1.2-linux-amd64.tar.gz
|
|
4
|
-
f388c0e1d23df86a24650b7bcbd2424b5a232b81a0a3f7bb426ad31781fa1217 modelgo-0.1.2-linux-arm64.tar.gz
|
|
5
|
-
5d96a2409132650dd4a98dcc8d1d0f44d519fde5de816550e53db7aba6ae629a modelgo-0.1.2-windows-amd64.zip
|
|
6
|
-
ea37a1341c87afd2f3cddfe5027a3e8203532cf5432b329c6caa8b4ce506cc05 modelgo-0.1.2-windows-arm64.zip
|