@cloud411716/fancy-webnovel 4.30.17 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.30.17",
3
+ "version": "4.30.19",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -93,12 +93,13 @@ export async function validateTeamModels(ctx, config) {
93
93
  ['generatorB', config.generatorB],
94
94
  ['judge', config.judge],
95
95
  ];
96
- if (!ctx || !ctx.llm || typeof ctx.llm.listModels !== 'function') return '';
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 ctx.llm.listModels(route.provider);
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
- if (!ctx || !ctx.llm || typeof ctx.llm.listModels !== 'function') return [];
115
- const models = await ctx.llm.listModels(provider);
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
- if (!ctx || !ctx.workflowEngine || typeof ctx.workflowEngine.start !== 'function') {
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 = ctx.workflowEngine.start({
415
+ run = engine.start({
398
416
  script: TEAM_WORKFLOW_SCRIPT,
399
417
  meta: {
400
418
  name: 'fancy-material-team',