Skip to content

Commit db25292

Browse files
author
wangmingxiang
committed
chore(deps): 更新依赖版本和移除部分覆盖项
- 移除 vite、vitest 和 ws 的覆盖版本配置 - 更新 @deepseek-ai 相关包的版本缓存标识 - 新增多种依赖包,包含 @modelcontextprotocol/sdk 和其他实用库 - 更新多个包的版本与依赖关系 - 添加和升级相关的节点模块依赖及其引擎版本要求 - 调整锁文件中依赖的完整性校验和元数据
1 parent 44a7330 commit db25292

26 files changed

Lines changed: 3657 additions & 1427 deletions

‎docs/agents/telemetry-change.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
- `channel` 与 `t1` 是当前固定口径
6565
- `User-Agent` 是独立标识:`bl` 为 `bailian-cli/<version>`,`kscli` 为 `knowledge-studio-cli/<version>`
6666
- `X-Dashscope-Service: bailian-cli` 与 source-config 一起由 `trackingHeaders()` 注入;凡走该函数的百炼 / DashScope 请求(含 MCP 注册与 JSON-RPC)都会带上。OSS、结果文件下载、npm / Skill 仍不发送。
67+
- **AIGC auto MCP 例外**:AIGC 命令解析出的模型为保留值 `auto` 时,经 `withAigcMcpSession` 调用的 4 个生成类 MCP server(TextGenerateImage / VideoGenerate / TextGenerateSpeech / SpeechGenerateText)把 `X-Dashscope-Service` 覆写为 `bailian-cli-call`(常量 `MCP_CALL_SERVICE`),供网关单独归因 CLI 发起的 MCP 生成流量;此时 `source-config` 的 `channel` 仍是 `bailian-cli`,只有 Service 头变。其它 MCP 命令(`search web`、`mcp tools`、`mcp call`)与所有 REST 请求保持 `bailian-cli`。覆写经 `connectBailianMcp(serverCode, urlOverride?, serviceSource?)` → `connectBailianMcpWithFallback` → `SdkMcpAdapter` → `trackingHeaders(identity, service = CHANNEL)` 逐层透传,未传时回落默认 `CHANNEL`。
6768

6869
source-config 只用于百炼 / DashScope API 侧消费,不发送到通用网络传输:
6970

‎packages/commands/src/commands/image/edit.ts‎

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import {
2222
ASYNC_FLAG,
2323
CONCURRENT_FLAG,
2424
redactDataUri,
25+
bailianMcpPath,
26+
AIGC_MCP_SERVER,
27+
AIGC_MCP_TOOL,
28+
buildImageEditArgs,
29+
parseAigcImageResults,
2530
} from "bailian-cli-core";
2631
import { poll } from "bailian-cli-runtime";
2732
import { downloadFile } from "bailian-cli-runtime";
@@ -30,6 +35,14 @@ import { emitResult, emitBare } from "bailian-cli-runtime";
3035
import { resolveImageSize } from "bailian-cli-runtime";
3136
import { join } from "path";
3237
import { BOOL_FLAG_PROMPT_EXTEND_CLI_TRUE, BOOL_FLAG_WATERMARK } from "bailian-cli-runtime";
38+
import {
39+
isAutoModel,
40+
assertMcpCompatible,
41+
withAigcMcpSession,
42+
resolveAutoImageInput,
43+
mcpSingleImageOnlyError,
44+
type Localize,
45+
} from "../shared/aigc-mcp.ts";
3346

3447
const EDIT_FLAGS = {
3548
image: {
@@ -181,6 +194,14 @@ export default defineCommand({
181194
"zh-CN": '--image ./photo.png --prompt "将背景替换为海滩" --watermark false',
182195
},
183196
],
197+
notes: [
198+
{
199+
"en-US":
200+
'Model "auto" (via --model auto or a config default model of "auto") routes to the official Bailian MCP with a reduced parameter set; MCP-incompatible flags fail fast with a usage error instead of falling back to REST. Auto edit accepts a single --image only.',
201+
"zh-CN":
202+
'模型 "auto"(通过 --model auto 或将配置默认模型设为 "auto")改走百炼官方 MCP,参数面更小;MCP 不支持的参数会直接报用法错误,而不回退 REST。auto 编辑仅支持单个 --image。',
203+
},
204+
],
184205
async run(ctx) {
185206
const { settings, flags } = ctx;
186207
// Normalize --image to string array (supports both single and repeated flags)
@@ -192,7 +213,20 @@ export default defineCommand({
192213
}
193214
const prompt = flags.prompt;
194215

195-
const model = flags.model || settings.defaultImageModel || "qwen-image-3.0";
216+
const resolvedModel = flags.model || settings.defaultImageModel;
217+
if (isAutoModel(resolvedModel)) {
218+
await handleAutoMcpMode(
219+
ctx.client,
220+
ctx.localize,
221+
settings,
222+
flags,
223+
rawImages,
224+
detectOutputFormat(settings.output),
225+
);
226+
return;
227+
}
228+
229+
const model = resolvedModel || "qwen-image-3.0";
196230
const route = resolveImageEditApi(model);
197231

198232
// Auto-upload local files (resolve all images in parallel)
@@ -329,6 +363,69 @@ export default defineCommand({
329363
},
330364
});
331365

366+
async function handleAutoMcpMode(
367+
client: Client,
368+
localize: Localize,
369+
settings: Settings,
370+
flags: EditFlags,
371+
rawImages: string[],
372+
format: OutputFormat,
373+
): Promise<void> {
374+
assertMcpCompatible("imageEdit", flags, localize);
375+
376+
// bailian_image_edit takes a single source image; bailian_image_fusion is out
377+
// of scope, so multi-image merge is rejected in auto mode.
378+
if (rawImages.length > 1) {
379+
throw mcpSingleImageOnlyError(localize);
380+
}
381+
const source = rawImages[0];
382+
if (!source) {
383+
throw new BailianError("Provide one --image to edit.", ExitCode.USAGE);
384+
}
385+
386+
const imageUrl = resolveAutoImageInput(source, localize);
387+
const concurrent = getConcurrency(flags);
388+
const args = buildImageEditArgs({
389+
imageUrl,
390+
prompt: flags.prompt,
391+
negativePrompt: flags.negativePrompt || undefined,
392+
});
393+
394+
if (settings.dryRun) {
395+
emitResult(
396+
{
397+
server: AIGC_MCP_SERVER.image,
398+
url: client.url(bailianMcpPath(AIGC_MCP_SERVER.image)),
399+
tool: AIGC_MCP_TOOL.imageEdit,
400+
arguments: { ...args, image_url: redactDataUri(imageUrl) },
401+
mode: "mcp",
402+
concurrent,
403+
},
404+
format,
405+
);
406+
return;
407+
}
408+
409+
if (!settings.quiet) {
410+
process.stderr.write("[Model: auto] [Mode: mcp] [Images: 1]\n");
411+
}
412+
413+
// One shared MCP session; --concurrent fans out parallel tools/call on it.
414+
await withAigcMcpSession(client, AIGC_MCP_SERVER.image, localize, async (callTool) => {
415+
const perRequest = await runConcurrent(concurrent, settings, async () => {
416+
const inner = await callTool(AIGC_MCP_TOOL.imageEdit, args);
417+
return parseAigcImageResults(inner);
418+
});
419+
420+
const imageUrls = perRequest.flat();
421+
if (imageUrls.length === 0) {
422+
throw new BailianError("Edit completed but no images returned.", ExitCode.GENERAL);
423+
}
424+
425+
await saveImages(imageUrls, flags, settings, format);
426+
});
427+
}
428+
332429
async function handleSyncMode(
333430
client: Client,
334431
settings: Settings,

‎packages/commands/src/commands/image/generate.ts‎

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@ import {
2020
resolveImageGenerateApi,
2121
ASYNC_FLAG,
2222
CONCURRENT_FLAG,
23+
bailianMcpPath,
24+
AIGC_MCP_SERVER,
25+
AIGC_MCP_TOOL,
26+
buildImageGenArgs,
27+
parseAigcImageResults,
2328
} from "bailian-cli-core";
2429
import { poll } from "bailian-cli-runtime";
2530
import { downloadFile } from "bailian-cli-runtime";
2631
import { runConcurrent, downloadParallel, getConcurrency } from "bailian-cli-runtime";
2732
import { emitResult, emitBare } from "bailian-cli-runtime";
2833
import { resolveImageSize } from "bailian-cli-runtime";
2934
import { BOOL_FLAG_PROMPT_EXTEND_IMAGE_GENERATE, BOOL_FLAG_WATERMARK } from "bailian-cli-runtime";
35+
import {
36+
isAutoModel,
37+
assertMcpCompatible,
38+
withAigcMcpSession,
39+
type Localize,
40+
} from "../shared/aigc-mcp.ts";
3041

3142
import { join } from "path";
3243

@@ -167,11 +178,31 @@ export default defineCommand({
167178
"zh-CN": '--prompt "产品摄影" --n 2 --concurrent 3 # 并行生成 6 张图片',
168179
},
169180
],
181+
notes: [
182+
{
183+
"en-US":
184+
'Model "auto" (via --model auto or a config default model of "auto") routes to the official Bailian MCP with a reduced parameter set; MCP-incompatible flags fail fast with a usage error instead of falling back to REST.',
185+
"zh-CN":
186+
'模型 "auto"(通过 --model auto 或将配置默认模型设为 "auto")改走百炼官方 MCP,参数面更小;MCP 不支持的参数会直接报用法错误,而不回退 REST。',
187+
},
188+
],
170189
async run(ctx) {
171190
const { settings, flags } = ctx;
172191
const prompt = flags.prompt;
173192

174-
const model = flags.model || settings.defaultImageModel || "qwen-image-3.0";
193+
const resolvedModel = flags.model || settings.defaultImageModel;
194+
if (isAutoModel(resolvedModel)) {
195+
await handleAutoMcpMode(
196+
ctx.client,
197+
ctx.localize,
198+
settings,
199+
flags,
200+
detectOutputFormat(settings.output),
201+
);
202+
return;
203+
}
204+
205+
const model = resolvedModel || "qwen-image-3.0";
175206
const route = resolveImageGenerateApi(model);
176207
const defaultSize = "1:1";
177208
const sizeInput = flags.size || defaultSize;
@@ -238,6 +269,61 @@ export default defineCommand({
238269
},
239270
});
240271

272+
// ---- Auto mode: Bailian AIGC MCP (bailian_image_gen) ----
273+
274+
async function handleAutoMcpMode(
275+
client: Client,
276+
localize: Localize,
277+
settings: Settings,
278+
flags: GenerateFlags,
279+
format: string,
280+
): Promise<void> {
281+
assertMcpCompatible("imageGen", flags, localize);
282+
283+
const concurrent = getConcurrency(flags);
284+
const args = buildImageGenArgs({
285+
prompt: flags.prompt,
286+
size: flags.size || undefined,
287+
n: flags.n,
288+
negativePrompt: flags.negativePrompt || undefined,
289+
promptExtend: flags.promptExtend,
290+
});
291+
292+
if (settings.dryRun) {
293+
emitResult(
294+
{
295+
server: AIGC_MCP_SERVER.image,
296+
url: client.url(bailianMcpPath(AIGC_MCP_SERVER.image)),
297+
tool: AIGC_MCP_TOOL.imageGen,
298+
arguments: args,
299+
mode: "mcp",
300+
concurrent,
301+
},
302+
format as OutputFormat,
303+
);
304+
return;
305+
}
306+
307+
if (!settings.quiet) {
308+
process.stderr.write("[Model: auto] [Mode: mcp]\n");
309+
}
310+
311+
// One shared MCP session; --concurrent fans out parallel tools/call on it.
312+
await withAigcMcpSession(client, AIGC_MCP_SERVER.image, localize, async (callTool) => {
313+
const perRequest = await runConcurrent(concurrent, settings, async () => {
314+
const inner = await callTool(AIGC_MCP_TOOL.imageGen, args);
315+
return parseAigcImageResults(inner);
316+
});
317+
318+
const imageUrls = perRequest.flat();
319+
if (imageUrls.length === 0) {
320+
throw new BailianError("Generation completed but no images returned.", ExitCode.GENERAL);
321+
}
322+
323+
await saveImages(imageUrls, flags, settings, format);
324+
});
325+
}
326+
241327
// ---- Sync mode: qwen-image / wan2.7-image / z-image ----
242328

243329
async function handleSyncMode(

0 commit comments

Comments
 (0)