@cloud411716/fancy-webnovel 4.30.18 → 4.30.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/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { apply as applyMaterial } from './plugins/fancy-material/index.js';
|
|
|
12
12
|
import { apply as applyDouyin } from './plugins/fancy-douyin/index.js';
|
|
13
13
|
|
|
14
14
|
export const name = 'fancy-webnovel';
|
|
15
|
-
export const inject = ['commands', 'userQuestions', 'tools'
|
|
15
|
+
export const inject = ['commands', 'userQuestions', 'tools'];
|
|
16
16
|
|
|
17
17
|
export async function apply(ctx) {
|
|
18
18
|
await applyBootstrap(ctx);
|
package/package.json
CHANGED
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
validationFailedText,
|
|
90
90
|
} from './templates.js';
|
|
91
91
|
|
|
92
|
-
export const inject = ['commands', 'userQuestions'
|
|
92
|
+
export const inject = ['commands', 'userQuestions'];
|
|
93
93
|
|
|
94
94
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
95
95
|
const DOCS_DIR = path.resolve(__dirname, '..', '..', 'docs', 'material-library');
|
|
@@ -93,12 +93,13 @@ export async function validateTeamModels(ctx, config) {
|
|
|
93
93
|
['generatorB', config.generatorB],
|
|
94
94
|
['judge', config.judge],
|
|
95
95
|
];
|
|
96
|
-
|
|
96
|
+
const llm = service(ctx, 'llm');
|
|
97
|
+
if (!llm || typeof llm.listModels !== 'function') return '';
|
|
97
98
|
for (const [label, route] of routes) {
|
|
98
99
|
if (!route) continue;
|
|
99
100
|
let models;
|
|
100
101
|
try {
|
|
101
|
-
models = await
|
|
102
|
+
models = await llm.listModels(route.provider);
|
|
102
103
|
} catch (err) {
|
|
103
104
|
return `${label} 的 provider "${route.provider}" 不可用:${err && err.message ? err.message : String(err)}`;
|
|
104
105
|
}
|
|
@@ -111,11 +112,27 @@ export async function validateTeamModels(ctx, config) {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
export async function listTeamModels(ctx, provider = 'opencode-go') {
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
const llm = service(ctx, 'llm');
|
|
116
|
+
if (!llm || typeof llm.listModels !== 'function') return [];
|
|
117
|
+
const models = await llm.listModels(provider);
|
|
116
118
|
return Array.isArray(models) ? models : [];
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
function service(ctx, name) {
|
|
122
|
+
if (!ctx) return undefined;
|
|
123
|
+
if (typeof ctx.get === 'function') {
|
|
124
|
+
try {
|
|
125
|
+
const value = ctx.get(name, false);
|
|
126
|
+
if (value !== undefined) return value;
|
|
127
|
+
} catch { /* optional service */ }
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
return ctx[name];
|
|
131
|
+
} catch {
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
119
136
|
function retargetPrompt(prompt, from, to) {
|
|
120
137
|
return String(prompt || '').split(`目标文件(**绝对路径**):\`${from}\``).join(`目标文件(**绝对路径**):\`${to}\``);
|
|
121
138
|
}
|
|
@@ -373,7 +390,8 @@ export async function runTeamBatch({
|
|
|
373
390
|
batchId = '',
|
|
374
391
|
batchNo = 1,
|
|
375
392
|
}) {
|
|
376
|
-
|
|
393
|
+
const engine = service(ctx, 'workflowEngine');
|
|
394
|
+
if (!engine || typeof engine.start !== 'function') {
|
|
377
395
|
return { ok: false, error: 'team 模式需要 workflowEngine,但当前 profile 没有加载 workflow。' };
|
|
378
396
|
}
|
|
379
397
|
const problem = teamConfigProblem(team);
|
|
@@ -394,7 +412,7 @@ export async function runTeamBatch({
|
|
|
394
412
|
|
|
395
413
|
let run;
|
|
396
414
|
try {
|
|
397
|
-
run =
|
|
415
|
+
run = engine.start({
|
|
398
416
|
script: TEAM_WORKFLOW_SCRIPT,
|
|
399
417
|
meta: {
|
|
400
418
|
name: 'fancy-material-team',
|