@tvbs-ai/news-rd 0.1.0 → 0.1.2
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 +5 -1
- package/dist/cli.js +64 -3
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ news-rd prompt compile 2026-03-10 0600
|
|
|
52
52
|
|
|
53
53
|
| Option | Description | Default |
|
|
54
54
|
|--------|-------------|---------|
|
|
55
|
-
| `--base-url URL` | API base URL | `
|
|
55
|
+
| `--base-url URL` | API base URL | `https://news-rundown.tvbs.ai` |
|
|
56
56
|
| `--token TOKEN` | JWT token (or `RD_TOKEN` env) | — |
|
|
57
57
|
| `--json` | Raw JSON output | — |
|
|
58
58
|
| `--help` | Show help | — |
|
|
@@ -69,6 +69,10 @@ news-rd prompt compile 2026-03-10 0600
|
|
|
69
69
|
- Node.js >= 18 (uses built-in fetch)
|
|
70
70
|
- A running TVBS News Rundown AI server
|
|
71
71
|
|
|
72
|
+
## Publishing
|
|
73
|
+
|
|
74
|
+
See [CLI 發佈指南](../../docs/cli-publishing.md) for version bumping and npm publishing workflow.
|
|
75
|
+
|
|
72
76
|
## License
|
|
73
77
|
|
|
74
78
|
UNLICENSED
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var args = process.argv.slice(2);
|
|
5
5
|
function parseArgs() {
|
|
6
6
|
const options = {
|
|
7
|
-
baseUrl: process.env.RD_BASE_URL || "
|
|
7
|
+
baseUrl: process.env.RD_BASE_URL || "https://news-rundown.tvbs.ai",
|
|
8
8
|
token: process.env.RD_TOKEN || "",
|
|
9
9
|
json: false
|
|
10
10
|
};
|
|
@@ -73,7 +73,7 @@ Groups:
|
|
|
73
73
|
token JWT Token \u7BA1\u7406
|
|
74
74
|
|
|
75
75
|
Global Options:
|
|
76
|
-
--base-url URL API base URL (default:
|
|
76
|
+
--base-url URL API base URL (default: https://news-rundown.tvbs.ai)
|
|
77
77
|
--token TOKEN JWT token (or RD_TOKEN env)
|
|
78
78
|
--json Raw JSON output
|
|
79
79
|
--help, -h Show help
|
|
@@ -167,10 +167,71 @@ async function apiCall(path, options, method = "GET") {
|
|
|
167
167
|
if (options.token) {
|
|
168
168
|
headers["Authorization"] = `Bearer ${options.token}`;
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
let response;
|
|
171
|
+
try {
|
|
172
|
+
response = await fetch(url, { method, headers });
|
|
173
|
+
} catch (err) {
|
|
174
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
175
|
+
if (msg.includes("ECONNREFUSED") || msg.includes("fetch failed")) {
|
|
176
|
+
console.error(`
|
|
177
|
+
Cannot connect to ${options.baseUrl}`);
|
|
178
|
+
console.error(` Make sure the server is running, or set a different URL:
|
|
179
|
+
`);
|
|
180
|
+
console.error(` news-rd --base-url https://your-server ${path.replace(/^\//, "")}`);
|
|
181
|
+
console.error(` # or`);
|
|
182
|
+
console.error(` export RD_BASE_URL=https://your-server
|
|
183
|
+
`);
|
|
184
|
+
} else {
|
|
185
|
+
console.error(`
|
|
186
|
+
Connection error: ${msg}
|
|
187
|
+
`);
|
|
188
|
+
}
|
|
189
|
+
process.exit(1);
|
|
190
|
+
}
|
|
191
|
+
const contentType = response.headers.get("content-type") || "";
|
|
192
|
+
if (!contentType.includes("application/json")) {
|
|
193
|
+
if (response.status === 404) {
|
|
194
|
+
console.error(`
|
|
195
|
+
Endpoint not found: ${url}`);
|
|
196
|
+
console.error(` The server may not have the Admin API deployed yet.
|
|
197
|
+
`);
|
|
198
|
+
} else if (response.status >= 500) {
|
|
199
|
+
console.error(`
|
|
200
|
+
Server error (${response.status}) from ${options.baseUrl}`);
|
|
201
|
+
console.error(` The server may be starting up or experiencing issues.
|
|
202
|
+
`);
|
|
203
|
+
} else {
|
|
204
|
+
console.error(`
|
|
205
|
+
Unexpected response from ${options.baseUrl} (HTTP ${response.status})`);
|
|
206
|
+
console.error(` Expected JSON but received ${contentType || "unknown content type"}.`);
|
|
207
|
+
console.error(` Make sure the URL points to a News Rundown AI server.
|
|
208
|
+
`);
|
|
209
|
+
}
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
171
212
|
const data = await response.json();
|
|
172
213
|
if (!response.ok) {
|
|
214
|
+
const errorCode = data?.error?.code;
|
|
173
215
|
const errorMsg = data?.error?.message || `HTTP ${response.status}`;
|
|
216
|
+
if (response.status === 401) {
|
|
217
|
+
console.error(`
|
|
218
|
+
Authentication required.`);
|
|
219
|
+
if (errorCode === "UNAUTHORIZED") {
|
|
220
|
+
console.error(` Set your token to access the API:
|
|
221
|
+
`);
|
|
222
|
+
console.error(` news-rd --token YOUR_TOKEN ${path.replace(/^\//, "")}`);
|
|
223
|
+
console.error(` # or`);
|
|
224
|
+
console.error(` export RD_TOKEN=YOUR_TOKEN
|
|
225
|
+
`);
|
|
226
|
+
console.error(` To generate a token, log in to the web UI and click "API Token",`);
|
|
227
|
+
console.error(` or run: news-rd token generate (requires Clerk session).
|
|
228
|
+
`);
|
|
229
|
+
} else {
|
|
230
|
+
console.error(` ${errorMsg}
|
|
231
|
+
`);
|
|
232
|
+
}
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
174
235
|
throw new Error(`API Error: ${errorMsg}`);
|
|
175
236
|
}
|
|
176
237
|
return data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tvbs-ai/news-rd",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "TVBS News Rundown AI CLI — query rundowns, candidates, trends, and prompts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,13 @@
|
|
|
16
16
|
"lint": "tsc --noEmit",
|
|
17
17
|
"prepublishOnly": "pnpm build"
|
|
18
18
|
},
|
|
19
|
-
"keywords": [
|
|
19
|
+
"keywords": [
|
|
20
|
+
"tvbs",
|
|
21
|
+
"news",
|
|
22
|
+
"rundown",
|
|
23
|
+
"ai",
|
|
24
|
+
"cli"
|
|
25
|
+
],
|
|
20
26
|
"license": "UNLICENSED",
|
|
21
27
|
"engines": {
|
|
22
28
|
"node": ">=18.0.0"
|