@bsbofmusic/cdper-doubao 1.1.5 → 1.1.6
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 +15 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -32,6 +32,18 @@ const SESSION_OPTIONS = { json: { type: 'boolean' } };
|
|
|
32
32
|
function writeJson(value) {
|
|
33
33
|
process.stdout.write(JSON.stringify(redactValue(value), null, 2) + '\n');
|
|
34
34
|
}
|
|
35
|
+
function addQueryOk(value) {
|
|
36
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
37
|
+
return { ok: false, value };
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(value, 'ok'))
|
|
39
|
+
return value;
|
|
40
|
+
const status = String(value.status || value.wrapperStatus || value.exitReason || '').toLowerCase();
|
|
41
|
+
const ok = status === 'ok' || status === 'complete' || status === 'complete_short';
|
|
42
|
+
return { ok, ...value };
|
|
43
|
+
}
|
|
44
|
+
function writeQueryJson(value) {
|
|
45
|
+
writeJson(addQueryOk(value));
|
|
46
|
+
}
|
|
35
47
|
function camelCase(name) {
|
|
36
48
|
return name.replace(/-([a-z])/g, (_match, chr) => chr.toUpperCase());
|
|
37
49
|
}
|
|
@@ -209,6 +221,8 @@ function parseQueryOptions(argv) {
|
|
|
209
221
|
async function runQuery(text, argv) {
|
|
210
222
|
if (!text || !String(text).trim())
|
|
211
223
|
throw new Error('Query text is required');
|
|
224
|
+
if (argv.json && !argv.debug)
|
|
225
|
+
process.env.QUIET = '1';
|
|
212
226
|
if (argv.quiet)
|
|
213
227
|
process.env.QUIET = '1';
|
|
214
228
|
if (argv.debug)
|
|
@@ -226,7 +240,7 @@ async function runQuery(text, argv) {
|
|
|
226
240
|
}
|
|
227
241
|
const result = await queryDoubao(String(text), parseQueryOptions(argv));
|
|
228
242
|
if (argv.json) {
|
|
229
|
-
|
|
243
|
+
writeQueryJson(result);
|
|
230
244
|
return;
|
|
231
245
|
}
|
|
232
246
|
if (result.content && String(result.content).trim()) {
|
package/package.json
CHANGED