diff --git a/CHANGELOG.md b/CHANGELOG.md index b4419d4d1..2d9377e36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and [中文版](CHANGELOG.zh.md) · [README](README.md) · [Contributing](CONTRIBUTING.md) +## [2.15.0] - 2026-12-01 + +### Added + +- Find workspace connector tools and authorized accounts with `bl connector tools --query`. Use `bl connector schema` to inspect the selected tool’s inputs and `bl connector call` to run it on the selected account. + ## [2.14.1] - 2026-12-01 ### Added diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index 316e7a674..89b91262d 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -6,6 +6,12 @@ [English](CHANGELOG.md) · [README](README.zh.md) · [参与贡献](CONTRIBUTING.zh.md) +## [2.15.0] - 2026-12-01 + +### 新增 + +- 使用 `bl connector tools --query` 查找工作空间中的连接器工具和已授权账号。用 `bl connector schema` 查看所选工具的入参,再用 `bl connector call` 在所选账号上执行该工具。 + ## [2.14.1] - 2026-12-01 ### 新增 diff --git a/README.md b/README.md index b4b37860c..e134db63a 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ _Built for AI Agents. Every command works as a structured tool call._ - **Model generation** — Full-modality generation across text, image, video, and speech, with editing and reference-based generation - **Asset understanding** — Parse and ask questions about images, documents, audio, and long videos - **App orchestration** — Call Managed Agents, agents, and workflows published on Aliyun Model Studio, wired to knowledge bases, memory, web search, and MCP tools; create, update, publish, copy, and delete agents/workflows, and edit workflow canvases from the CLI +- **Workspace connectors** — Discover tools with `bl connector tools --query`, inspect a selected account's schema with `bl connector schema`, and execute a tool with `bl connector call`. - **Native MCP setup** — Register Bailian MCP servers in Codex, Claude Code, Cursor, Qoder, Qoder Work, QwenWork (千问办公), Qwen Code, Gemini CLI, or Pi - **Training & deployment** — Prepare decision training data (local split, teacher-model generation, or fully async offline Batch), validate and upload datasets, fine-tune models (SFT/DPO/CPT), run reinforcement-learning jobs in an isolated sandbox (macOS/Linux), submit OPD distillation jobs via OpenAPI, deploy dedicated models as endpoints - **Batch inference** — Prepare CSV/JSONL, create and follow asynchronous Chat/Embedding tasks, download original results/errors with optional CSV, or send one synchronous Batch Chat request diff --git a/README.zh.md b/README.zh.md index 7fdad45c0..cb702d5e2 100644 --- a/README.zh.md +++ b/README.zh.md @@ -25,6 +25,7 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_ - **模型生成** — 文本、图像、视频、语音全模态生成,支持编辑与参考生成 - **素材理解** — 图像、文档、音频、长视频的解析与问答 - **应用编排** — 调用百炼已发布的 Managed Agent、智能体和工作流,接入知识库、记忆库、联网搜索与 MCP 工具;并可在命令行创建/更新/发布/复制/删除智能体与工作流、编辑工作流画布 +- **工作空间连接器** — 用 `bl connector tools --query` 查找工具,用 `bl connector schema` 查看所选账号下的入参,再用 `bl connector call` 执行。 - **原生 MCP 接入** — 将百炼 MCP 服务注册到 Codex、Claude Code、Cursor、Qoder、Qoder Work、千问办公(QwenWork)、Qwen Code、Gemini CLI 或 Pi - **模型训推** — 决策训练数据准备(本地切分 / teacher 模型生成 / 全异步离线 Batch)、数据集校验上传、模型精调(SFT/DPO/CPT)、在隔离沙箱内执行强化学习(RL)训练(macOS/Linux)、通过 OpenAPI 提交 OPD 蒸馏训练、专属模型部署上线 - **批量推理** — CSV/JSONL 构造、异步 Chat/Embedding 任务创建与跟踪、原始结果/错误下载及可选 CSV,或同步单请求 Batch Chat diff --git a/packages/bailian-kb-dsh/package.json b/packages/bailian-kb-dsh/package.json index 7c650aae8..d3827496c 100644 --- a/packages/bailian-kb-dsh/package.json +++ b/packages/bailian-kb-dsh/package.json @@ -1,6 +1,6 @@ { "name": "bailian-kb-dsh", - "version": "2.14.1", + "version": "2.15.0", "description": "Bailian knowledge-base tools for DeepSeek Harness: kb_search and kb_chat over the DashScope RAG API, plus the bl CLI management skill.", "keywords": [ "alibaba-cloud", diff --git a/packages/bailian-memo-dsh/package.json b/packages/bailian-memo-dsh/package.json index e5ad839c7..302efebab 100644 --- a/packages/bailian-memo-dsh/package.json +++ b/packages/bailian-memo-dsh/package.json @@ -1,6 +1,6 @@ { "name": "bailian-memo-dsh", - "version": "2.14.1", + "version": "2.15.0", "description": "Bailian personal memory for DeepSeek Harness: automatic recall, silent curation, and user-controlled remember/forget.", "keywords": [ "alibaba-cloud", diff --git a/packages/cli/README.md b/packages/cli/README.md index b4b37860c..e134db63a 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -26,6 +26,7 @@ _Built for AI Agents. Every command works as a structured tool call._ - **Model generation** — Full-modality generation across text, image, video, and speech, with editing and reference-based generation - **Asset understanding** — Parse and ask questions about images, documents, audio, and long videos - **App orchestration** — Call Managed Agents, agents, and workflows published on Aliyun Model Studio, wired to knowledge bases, memory, web search, and MCP tools; create, update, publish, copy, and delete agents/workflows, and edit workflow canvases from the CLI +- **Workspace connectors** — Discover tools with `bl connector tools --query`, inspect a selected account's schema with `bl connector schema`, and execute a tool with `bl connector call`. - **Native MCP setup** — Register Bailian MCP servers in Codex, Claude Code, Cursor, Qoder, Qoder Work, QwenWork (千问办公), Qwen Code, Gemini CLI, or Pi - **Training & deployment** — Prepare decision training data (local split, teacher-model generation, or fully async offline Batch), validate and upload datasets, fine-tune models (SFT/DPO/CPT), run reinforcement-learning jobs in an isolated sandbox (macOS/Linux), submit OPD distillation jobs via OpenAPI, deploy dedicated models as endpoints - **Batch inference** — Prepare CSV/JSONL, create and follow asynchronous Chat/Embedding tasks, download original results/errors with optional CSV, or send one synchronous Batch Chat request diff --git a/packages/cli/README.zh.md b/packages/cli/README.zh.md index 7fdad45c0..cb702d5e2 100644 --- a/packages/cli/README.zh.md +++ b/packages/cli/README.zh.md @@ -25,6 +25,7 @@ _专为 AI Agent 打造,每个命令均可作为结构化工具调用。_ - **模型生成** — 文本、图像、视频、语音全模态生成,支持编辑与参考生成 - **素材理解** — 图像、文档、音频、长视频的解析与问答 - **应用编排** — 调用百炼已发布的 Managed Agent、智能体和工作流,接入知识库、记忆库、联网搜索与 MCP 工具;并可在命令行创建/更新/发布/复制/删除智能体与工作流、编辑工作流画布 +- **工作空间连接器** — 用 `bl connector tools --query` 查找工具,用 `bl connector schema` 查看所选账号下的入参,再用 `bl connector call` 执行。 - **原生 MCP 接入** — 将百炼 MCP 服务注册到 Codex、Claude Code、Cursor、Qoder、Qoder Work、千问办公(QwenWork)、Qwen Code、Gemini CLI 或 Pi - **模型训推** — 决策训练数据准备(本地切分 / teacher 模型生成 / 全异步离线 Batch)、数据集校验上传、模型精调(SFT/DPO/CPT)、在隔离沙箱内执行强化学习(RL)训练(macOS/Linux)、通过 OpenAPI 提交 OPD 蒸馏训练、专属模型部署上线 - **批量推理** — CSV/JSONL 构造、异步 Chat/Embedding 任务创建与跟踪、原始结果/错误下载及可选 CSV,或同步单请求 Batch Chat diff --git a/packages/cli/package.json b/packages/cli/package.json index 724de7322..158dc6666 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "bailian-cli", - "version": "2.14.1", + "version": "2.15.0", "description": "CLI for Aliyun Model Studio (DashScope) AI Platform.", "keywords": [ "agent", diff --git a/packages/cli/src/commands.ts b/packages/cli/src/commands.ts index a7bd65436..e252584a3 100644 --- a/packages/cli/src/commands.ts +++ b/packages/cli/src/commands.ts @@ -114,6 +114,9 @@ import { mcpToolList, mcpToolSearch, mcpUpdate, + connectorTools, + connectorSchema, + connectorCall, searchWeb, speechSynthesize, speechRecognize, @@ -530,6 +533,9 @@ export const commands: Record = { "mcp tool list": mcpToolList, "mcp tool search": mcpToolSearch, "mcp update": mcpUpdate, + "connector tools": connectorTools, + "connector schema": connectorSchema, + "connector call": connectorCall, "search web": searchWeb, "speech synthesize": speechSynthesize, "speech recognize": speechRecognize, diff --git a/packages/commands/package.json b/packages/commands/package.json index 5475a4c18..039c731c1 100644 --- a/packages/commands/package.json +++ b/packages/commands/package.json @@ -1,6 +1,6 @@ { "name": "bailian-cli-commands", - "version": "2.14.1", + "version": "2.15.0", "description": "Command library for bailian-cli products (knowledge, memory, media, …). See https://www.npmjs.com/package/bailian-cli for usage.", "homepage": "https://bailian.console.aliyun.com/cli", "bugs": { @@ -41,6 +41,7 @@ }, "dependencies": { "@openagentpack/sdk": "0.9.0", + "ajv": "catalog:", "bailian-cli-core": "workspace:*", "bailian-cli-runtime": "workspace:*", "boxen": "catalog:", diff --git a/packages/commands/src/commands/connector/call.ts b/packages/commands/src/commands/connector/call.ts new file mode 100644 index 000000000..575be1e65 --- /dev/null +++ b/packages/commands/src/commands/connector/call.ts @@ -0,0 +1,67 @@ +import { Ajv } from "ajv"; +import { Ajv2020 } from "ajv/dist/2020.js"; +import { BailianError, defineCommand, UsageError } from "bailian-cli-core"; +import { isObject, invoke, runConnector, schemaRequest, selectionFlags } from "./shared.ts"; + +export default defineCommand({ + description: { + "en-US": "Validate arguments and execute one connector tool on the selected account", + "zh-CN": "校验入参并在所选账号执行一个连接器工具", + }, + auth: "apiKey", + usageArgs: "--tool --instance --json '' [--trace-id ]", + flags: { + ...selectionFlags, + json: { + type: "string", + required: true, + valueHint: "", + description: { + "en-US": "JSON object matching the selected tool schema", + "zh-CN": "与所选工具入参定义匹配的 JSON 对象", + }, + }, + }, + exampleArgs: ["--tool --instance --json '{}' --dry-run"], + async run(ctx) { + const { tool, instance, traceId } = ctx.flags; + const lookup = schemaRequest(ctx.flags); + let args: unknown; + try { + args = JSON.parse(ctx.flags.json); + } catch { + throw new UsageError("--json must contain valid JSON."); + } + if (!isObject(args)) throw new UsageError("--json must be an object."); + const payload = { + executions: [{ toolRef: tool, instanceId: instance, arguments: args }], + ...(traceId ? { traceId } : {}), + }; + const name = "CONNECTOR_MULTI_EXECUTE_TOOL"; + await runConnector(ctx, { tool: name, arguments: payload }, async (client) => { + const data = await invoke(client, "CONNECTOR_GET_TOOL_SCHEMAS", lookup); + const entries = Array.isArray(data.schemas) + ? data.schemas.filter((row) => isObject(row) && row.toolRef === tool) + : []; + const schema = entries[0]?.inputSchema; + if (data.instanceId !== instance || entries.length !== 1 || !isObject(schema)) + throw new BailianError( + "Missing matching input schema for the selected connector tool and instance.", + ); + const options = { ownProperties: true, strict: false }; + const validator = + schema.$schema === "https://json-schema.org/draft/2020-12/schema" + ? new Ajv2020(options) + : new Ajv(options); + const validate = validator.compile(schema); + if ("$async" in validate) throw new BailianError("Unsupported async connector input schema."); + if (!validate(args)) throw new UsageError(validator.errorsText(validate.errors)); + const result = await invoke(client, name, payload); + if (Array.isArray(result.errors) && result.errors.length) + throw new BailianError(JSON.stringify(result.errors)); + if (!Array.isArray(result.results) || result.results.length !== 1) + throw new BailianError("Expected one connector execution result."); + return result; + }); + }, +}); diff --git a/packages/commands/src/commands/connector/schema.ts b/packages/commands/src/commands/connector/schema.ts new file mode 100644 index 000000000..0aa4a89c8 --- /dev/null +++ b/packages/commands/src/commands/connector/schema.ts @@ -0,0 +1,20 @@ +import { defineCommand } from "bailian-cli-core"; +import { invoke, runConnector, schemaRequest, selectionFlags } from "./shared.ts"; + +export default defineCommand({ + description: { + "en-US": "Inspect a connector tool's input schema for the selected account", + "zh-CN": "查看所选账号下连接器工具的入参定义", + }, + auth: "apiKey", + usageArgs: "--tool --instance [--trace-id ]", + flags: selectionFlags, + exampleArgs: ["--tool --instance --output json"], + async run(ctx) { + const name = "CONNECTOR_GET_TOOL_SCHEMAS"; + const args = schemaRequest(ctx.flags); + await runConnector(ctx, { tool: name, arguments: args }, (client) => + invoke(client, name, args), + ); + }, +}); diff --git a/packages/commands/src/commands/connector/shared.ts b/packages/commands/src/commands/connector/shared.ts new file mode 100644 index 000000000..2568524aa --- /dev/null +++ b/packages/commands/src/commands/connector/shared.ts @@ -0,0 +1,96 @@ +import { + BailianError, + UsageError, + ragEndpoint, + type CommandContext, + type FlagsDef, + type McpConnectedClient, +} from "bailian-cli-core"; +import { resolveWorkspaceId, WORKSPACE_FLAG } from "../shared/workspace.ts"; + +export const selectionFlags = { + ...WORKSPACE_FLAG, + tool: { + type: "string", + required: true, + valueHint: "", + description: { + "en-US": "Tool reference returned by discovery", + "zh-CN": "工具发现返回的 toolRef", + }, + }, + instance: { + type: "string", + required: true, + valueHint: "", + description: { + "en-US": "Selected authorized connector instance", + "zh-CN": "选定的已授权连接器实例 ID", + }, + }, + traceId: { + type: "string", + valueHint: "", + description: { + "en-US": "Trace ID from connector discovery", + "zh-CN": "工具发现返回的 traceId", + }, + }, +} satisfies FlagsDef; + +export function schemaRequest(flags: { tool: string; instance: string; traceId?: string }) { + if (!flags.tool.trim() || !flags.instance.trim()) + throw new UsageError("--tool and --instance must be non-empty."); + return { + toolRefs: [flags.tool], + instanceId: flags.instance, + ...(flags.traceId ? { traceId: flags.traceId } : {}), + }; +} + +export function isObject(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} + +export async function invoke( + client: McpConnectedClient, + name: string, + args: Record, +) { + const result = await client.callTool(name, args); + const text = result.content + .filter((item) => item.type === "text") + .map((item) => item.text) + .join("\n"); + if (result.isError) throw new BailianError(text || name + " failed"); + let data: unknown = result.structuredContent; + if (data === undefined) { + try { + data = JSON.parse(text); + } catch { + throw new BailianError(name + " returned invalid JSON"); + } + } + if (!isObject(data)) throw new BailianError(name + " returned an invalid result"); + return data; +} + +export async function runConnector( + ctx: Pick & { + flags: { workspaceId?: string }; + }, + preview: Record, + run: (client: McpConnectedClient) => Promise>, +) { + const url = ragEndpoint(resolveWorkspaceId(ctx), "/api/v2/connector/mcp"); + if (ctx.settings.dryRun) { + ctx.output.result({ url, ...preview }); + return; + } + const { client } = await ctx.client.connectBailianMcp("connector", url); + try { + ctx.output.result(await run(client)); + } finally { + client.close?.(); + } +} diff --git a/packages/commands/src/commands/connector/tools.ts b/packages/commands/src/commands/connector/tools.ts new file mode 100644 index 000000000..a7f98aaae --- /dev/null +++ b/packages/commands/src/commands/connector/tools.ts @@ -0,0 +1,35 @@ +import { defineCommand, UsageError } from "bailian-cli-core"; +import { WORKSPACE_FLAG } from "../shared/workspace.ts"; +import { invoke, runConnector } from "./shared.ts"; + +export default defineCommand({ + description: { + "en-US": "Discover connector tools and authorized accounts by intent", + "zh-CN": "按意图查找连接器工具与已授权账号", + }, + auth: "apiKey", + usageArgs: "--query [--workspace-id ]", + flags: { + ...WORKSPACE_FLAG, + query: { + type: "string", + required: true, + valueHint: "", + description: { + "en-US": "Describe the task and any preferred app or account", + "zh-CN": "描述任务和指定的应用或账号", + }, + }, + }, + exampleArgs: [ + { "en-US": '--query "Find tomorrow\'s meetings"', "zh-CN": '--query "查明天的会议"' }, + ], + async run(ctx) { + const { query } = ctx.flags; + if (!query.trim()) throw new UsageError("--query must be non-empty."); + const name = "CONNECTOR_SEARCH_TOOL"; + await runConnector(ctx, { tool: name, arguments: { query } }, (client) => + invoke(client, name, { query }), + ); + }, +}); diff --git a/packages/commands/src/index.ts b/packages/commands/src/index.ts index c0c9351b2..4968da6f4 100644 --- a/packages/commands/src/index.ts +++ b/packages/commands/src/index.ts @@ -114,6 +114,9 @@ export { default as mcpToolCall } from "./commands/mcp/tool-call.ts"; export { default as mcpToolList } from "./commands/mcp/tool-list.ts"; export { default as mcpToolSearch } from "./commands/mcp/tool-search.ts"; export { default as mcpUpdate } from "./commands/mcp/update.ts"; +export { default as connectorTools } from "./commands/connector/tools.ts"; +export { default as connectorSchema } from "./commands/connector/schema.ts"; +export { default as connectorCall } from "./commands/connector/call.ts"; export { default as searchWeb } from "./commands/search/web.ts"; export { default as speechSynthesize } from "./commands/speech/synthesize.ts"; export { default as speechRecognize } from "./commands/speech/recognize.ts"; diff --git a/packages/commands/tests/connector.test.ts b/packages/commands/tests/connector.test.ts new file mode 100644 index 000000000..1df7f702f --- /dev/null +++ b/packages/commands/tests/connector.test.ts @@ -0,0 +1,85 @@ +import { expect, test, vi } from "vite-plus/test"; +import command from "../src/commands/connector/call.ts"; +import search from "../src/commands/connector/tools.ts"; +import schema from "../src/commands/connector/schema.ts"; + +const selection = { tool: "calendar.list", instance: "account", traceId: "trace" }; +const lookup = { instanceId: "account", toolRefs: ["calendar.list"], traceId: "trace" }; +const schemaResponse = { + instanceId: "account", + schemas: [ + { + toolRef: "calendar.list", + inputSchema: { + type: "object", + properties: { limit: { type: "integer" } }, + required: ["limit"], + }, + }, + ], +}; + +function fixture(response: unknown = schemaResponse, json = '{"limit":2}') { + const callTool = vi + .fn() + .mockResolvedValueOnce({ content: [{ type: "text", text: JSON.stringify(response) }] }) + .mockResolvedValueOnce({ structuredContent: { results: [{ meetings: [] }] }, content: [] }); + const close = vi.fn(); + const output = vi.fn(); + const ctx = { + settings: { workspaceId: "ws-test" }, + flags: { ...selection, json, query: "find meetings" }, + identity: { binName: "bl" }, + client: { connectBailianMcp: vi.fn().mockResolvedValue({ client: { callTool, close } }) }, + output: { result: output }, + }; + return { + ctx: ctx as unknown as Parameters[0] & Parameters[0], + callTool, + close, + output, + }; +} + +test("discovery only sends query, retaining account selection and trace", async () => { + const data = { traceId: "t", status: "MATCH", items: [{ requiresAccountSelection: true }] }; + const f = fixture(data); + await search.run(f.ctx); + expect(f.callTool.mock.calls).toEqual([["CONNECTOR_SEARCH_TOOL", { query: "find meetings" }]]); + expect(f.output).toHaveBeenCalledWith(data); +}); + +test("schema returns decoded schema for the requested instance", async () => { + const f = fixture(); + await schema.run(f.ctx); + expect(f.callTool.mock.calls).toEqual([["CONNECTOR_GET_TOOL_SCHEMAS", lookup]]); + expect(f.output).toHaveBeenCalledWith(schemaResponse); +}); + +test("call validates and reuses the selected tool, instance and trace", async () => { + const f = fixture(); + await command.run(f.ctx); + expect(f.callTool.mock.calls).toEqual([ + ["CONNECTOR_GET_TOOL_SCHEMAS", lookup], + [ + "CONNECTOR_MULTI_EXECUTE_TOOL", + { + traceId: "trace", + executions: [{ instanceId: "account", toolRef: "calendar.list", arguments: { limit: 2 } }], + }, + ], + ]); + expect(f.output).toHaveBeenCalledWith({ results: [{ meetings: [] }] }); + expect(f.close).toHaveBeenCalledTimes(1); +}); + +test.each([ + [schemaResponse, '{"limit":"wrong"}'], + [{ ...schemaResponse, instanceId: "different" }, "{}"], + [{ ...schemaResponse, schemas: [] }, "{}"], +] as const)("schema or argument mismatch stops before execution", async (response, json) => { + const f = fixture(response, json); + await expect(command.run(f.ctx)).rejects.toThrow(); + expect(f.callTool).toHaveBeenCalledTimes(1); + expect(f.close).toHaveBeenCalledTimes(1); +}); diff --git a/packages/commands/tests/e2e/connector.e2e.test.ts b/packages/commands/tests/e2e/connector.e2e.test.ts new file mode 100644 index 000000000..9161cc765 --- /dev/null +++ b/packages/commands/tests/e2e/connector.e2e.test.ts @@ -0,0 +1,53 @@ +import { expect, test } from "vite-plus/test"; +import { CONNECTOR_ROUTES } from "./topic-routes.ts"; +import { runCommandHelp, runCommandInProcess } from "./helpers.ts"; + +test.each(["tools", "schema", "call"])("connector %s exposes workspace scope", async (action) => { + const result = await runCommandHelp(CONNECTOR_ROUTES, ["connector", action, "--help"]); + expect(result.exitCode, result.stderr).toBe(0); + expect(result.stderr).toContain("--workspace-id"); +}); + +test("connector call reaches argument validation without confirmation", async () => { + const result = await runCommandInProcess(CONNECTOR_ROUTES, [ + "connector", + "call", + "--tool", + "calendar.list", + "--instance", + "account", + "--json", + "[]", + "--workspace-id", + "ws-test", + "--api-key", + "sk-test", + "--output", + "json", + ]); + expect(result.exitCode, result.stderr).toBe(2); + expect(JSON.parse(result.stderr).error.message).toContain("--json"); +}); + +test("connector call previews the selected account and one execution offline", async () => { + const result = await runCommandInProcess(CONNECTOR_ROUTES, [ + "connector", + "call", + "--tool", + "calendar.list", + "--instance", + "account", + "--trace-id", + "trace", + "--json", + '{"limit":3}', + "--workspace-id", + "ws-test", + "--output", + "json", + "--dry-run", + ]); + expect(result.exitCode, result.stderr).toBe(0); + expect(result.stdout).toContain("CONNECTOR_MULTI_EXECUTE_TOOL"); + expect(result.stdout).toContain("ws-test.cn-beijing.maas.aliyuncs.com"); +}); diff --git a/packages/commands/tests/e2e/topic-routes.ts b/packages/commands/tests/e2e/topic-routes.ts index f8ac7f293..451a4f7a0 100644 --- a/packages/commands/tests/e2e/topic-routes.ts +++ b/packages/commands/tests/e2e/topic-routes.ts @@ -3,6 +3,11 @@ * 仅包含该 topic 测试会调用的 path,不维护全量产品 map。 */ export type E2eRouteExports = Record; +export const CONNECTOR_ROUTES: E2eRouteExports = { + "connector tools": "connectorTools", + "connector schema": "connectorSchema", + "connector call": "connectorCall", +}; export const AUTH_ROUTES: E2eRouteExports = { "auth login": "authLogin", diff --git a/packages/core/package.json b/packages/core/package.json index fb8a53196..6253a38dc 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "bailian-cli-core", - "version": "2.14.1", + "version": "2.15.0", "description": "Core SDK for bailian-cli. See https://www.npmjs.com/package/bailian-cli for usage.", "homepage": "https://bailian.console.aliyun.com/cli", "bugs": { diff --git a/packages/kscli/package.json b/packages/kscli/package.json index 1426f968e..20dd76d08 100644 --- a/packages/kscli/package.json +++ b/packages/kscli/package.json @@ -1,6 +1,6 @@ { "name": "knowledge-studio-cli", - "version": "2.14.1", + "version": "2.15.0", "description": "Lightweight RAG CLI for Aliyun Model Studio — focused on knowledge-base retrieval.", "keywords": [ "alibaba-cloud", diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 820beb839..5b514ee00 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "bailian-cli-runtime", - "version": "2.14.1", + "version": "2.15.0", "description": "Runtime framework for bailian-cli (createCli, registry, args, output, pipeline). See https://www.npmjs.com/package/bailian-cli for usage.", "homepage": "https://bailian.console.aliyun.com/cli", "bugs": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bfa16d400..f07efddd2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -304,6 +304,9 @@ importers: '@openagentpack/sdk': specifier: 0.9.0 version: 0.9.0 + ajv: + specifier: 'catalog:' + version: 8.20.0 bailian-cli-core: specifier: workspace:* version: link:../core diff --git a/skills/bailian-cli/SKILL.md b/skills/bailian-cli/SKILL.md index a3659a0a9..42b5d127b 100644 --- a/skills/bailian-cli/SKILL.md +++ b/skills/bailian-cli/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-cli metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- @@ -91,6 +91,7 @@ Use this table only after the decision table in [`bailian-protocol`](../bailian- | SDK sample code for calling a model | `bl model code` | `--sdk openai\|dashscope`, `--lang`; text output is the snippet alone, safe to redirect | | Install / list / update / remove registry skills | `bl skill add` / `list` / `update` / `remove` | OSS `--name`, cloud `--code`. `add --all` installs the registry. `update --all` updates installed OSS skills. Filter by `--agent` / `--scope`. [Reference](reference/skill.md) | | Find cloud skills or inspect local installation paths | `bl skill search` / `bl skill get` | Search the cloud with a Bailian API key. Pass the returned `skill_code` to `get --code`. Use `get --name` for an OSS skill. | +| Find and run a workspace connector tool | `bl connector tools --query` → `schema` → `call` | Use the discovered toolRef and authorized instanceId. Pass the returned traceId to both subsequent commands. | | Inspect activated MCP servers, details or tools | `bl mcp list` / `get` / `tools` / `call` | — | | Find MCP tools by task or inspect a server's tools | `bl mcp tool search` / `bl mcp tool list` | Search with `--query` or list with `--server`. Both operations may trigger OneKey activation. Preview with `--dry-run`. | | Call a tool by server code and tool name | `bl mcp tool call` / `bl mcp call` | Use `--server` and `--tool` for OpenAPI, or `--target ` for an MCP session. | diff --git a/skills/bailian-cli/reference/connector.md b/skills/bailian-cli/reference/connector.md new file mode 100644 index 000000000..76cee08e2 --- /dev/null +++ b/skills/bailian-cli/reference/connector.md @@ -0,0 +1,93 @@ +# `bl connector` commands + +> Auto-generated from `packages/cli/src/commands.ts`. Do not edit by hand. +> Regenerate: `pnpm --filter bailian-cli run generate:reference`. + +Index: [index.md](index.md) + +## Commands in this group + +| Command | Authentication | Description | +| --------------------- | -------------- | ------------------------------------------------------------------------- | +| `bl connector call` | API Key | Validate arguments and execute one connector tool on the selected account | +| `bl connector schema` | API Key | Inspect a connector tool's input schema for the selected account | +| `bl connector tools` | API Key | Discover connector tools and authorized accounts by intent | + +## Command details + +### `bl connector call` + +| Field | Value | +| ------------------ | ------------------------------------------------------------------------------------------------ | +| **Name** | `connector call` | +| **Description** | Validate arguments and execute one connector tool on the selected account | +| **Authentication** | API Key | +| **Usage** | `bl connector call --tool --instance --json '' [--trace-id ]` | + +#### Flags + +| Flag | Type | Required | Description | +| ------------------------- | ------ | -------- | --------------------------------------------------------------- | +| `--workspace-id ` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) | +| `--tool ` | string | yes | Tool reference returned by discovery | +| `--instance ` | string | yes | Selected authorized connector instance | +| `--trace-id ` | string | no | Trace ID from connector discovery | +| `--json ` | string | yes | JSON object matching the selected tool schema | +| `--api-key ` | string | no | API key | +| `--base-url ` | string | no | API base URL | + +#### Examples + +```bash +bl connector call --tool --instance --json '{}' --dry-run +``` + +### `bl connector schema` + +| Field | Value | +| ------------------ | -------------------------------------------------------------------------------- | +| **Name** | `connector schema` | +| **Description** | Inspect a connector tool's input schema for the selected account | +| **Authentication** | API Key | +| **Usage** | `bl connector schema --tool --instance [--trace-id ]` | + +#### Flags + +| Flag | Type | Required | Description | +| ------------------------- | ------ | -------- | --------------------------------------------------------------- | +| `--workspace-id ` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) | +| `--tool ` | string | yes | Tool reference returned by discovery | +| `--instance ` | string | yes | Selected authorized connector instance | +| `--trace-id ` | string | no | Trace ID from connector discovery | +| `--api-key ` | string | no | API key | +| `--base-url ` | string | no | API base URL | + +#### Examples + +```bash +bl connector schema --tool --instance --output json +``` + +### `bl connector tools` + +| Field | Value | +| ------------------ | ---------------------------------------------------------- | +| **Name** | `connector tools` | +| **Description** | Discover connector tools and authorized accounts by intent | +| **Authentication** | API Key | +| **Usage** | `bl connector tools --query [--workspace-id ]` | + +#### Flags + +| Flag | Type | Required | Description | +| --------------------- | ------ | -------- | --------------------------------------------------------------- | +| `--workspace-id ` | string | no | Workspace ID for API endpoint URL (or set BAILIAN_WORKSPACE_ID) | +| `--query ` | string | yes | Describe the task and any preferred app or account | +| `--api-key ` | string | no | API key | +| `--base-url ` | string | no | API base URL | + +#### Examples + +```bash +bl connector tools --query "Find tomorrow's meetings" +``` diff --git a/skills/bailian-cli/reference/index.md b/skills/bailian-cli/reference/index.md index 91d318023..bfe6bcd59 100644 --- a/skills/bailian-cli/reference/index.md +++ b/skills/bailian-cli/reference/index.md @@ -50,6 +50,9 @@ Use this index for the skill-scoped quick index and global flags. | `bl config show` | No Auth | Display current configuration | [config.md](config.md) | | `bl config ui` | No Auth | Open a local web UI to manage config profiles | [config.md](config.md) | | `bl config use` | No Auth | Set the active config profile | [config.md](config.md) | +| `bl connector call` | API Key | Validate arguments and execute one connector tool on the selected account | [connector.md](connector.md) | +| `bl connector schema` | API Key | Inspect a connector tool's input schema for the selected account | [connector.md](connector.md) | +| `bl connector tools` | API Key | Discover connector tools and authorized accounts by intent | [connector.md](connector.md) | | `bl console call` | Console | Call a Bailian console API via the CLI gateway | [console.md](console.md) | | `bl decision` | API Key | Run the decision model: typed choice / noul / score answers with probabilities | [decision.md](decision.md) | | `bl file upload` | API Key | Upload a local file to DashScope temporary storage (48h) | [file.md](file.md) | @@ -160,6 +163,7 @@ Use this index for the skill-scoped quick index and global flags. | `batch` | `cancel`, `convert`, `create`, `download`, `get`, `list` | [batch.md](batch.md) | | `cmodel` | `base-models`, `delete`, `get`, `import`, `list`, `watch` | [cmodel.md](cmodel.md) | | `config` | `agent`, `list`, `set`, `show`, `ui`, `use` | [config.md](config.md) | +| `connector` | `call`, `schema`, `tools` | [connector.md](connector.md) | | `console` | `call` | [console.md](console.md) | | `decision` | `(root)` | [decision.md](decision.md) | | `file` | `upload`, `url` | [file.md](file.md) | diff --git a/skills/bailian-finetune/SKILL.md b/skills/bailian-finetune/SKILL.md index af23b3a9f..7c5044785 100644 --- a/skills/bailian-finetune/SKILL.md +++ b/skills/bailian-finetune/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-finetune metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-gen/SKILL.md b/skills/bailian-gen/SKILL.md index b0163b7a1..7e19e1a9e 100644 --- a/skills/bailian-gen/SKILL.md +++ b/skills/bailian-gen/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-gen metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-knowledge/SKILL.md b/skills/bailian-knowledge/SKILL.md index d646060fc..06f781d5a 100644 --- a/skills/bailian-knowledge/SKILL.md +++ b/skills/bailian-knowledge/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-knowledge metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-managed-agent/SKILL.md b/skills/bailian-managed-agent/SKILL.md index c9edb0010..0eef5fd1d 100644 --- a/skills/bailian-managed-agent/SKILL.md +++ b/skills/bailian-managed-agent/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-managed-agent metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-memory/SKILL.md b/skills/bailian-memory/SKILL.md index 6314a7175..794d9d8c0 100644 --- a/skills/bailian-memory/SKILL.md +++ b/skills/bailian-memory/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-memory metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-opd/SKILL.md b/skills/bailian-opd/SKILL.md index a30ad2d4e..ed289a63e 100644 --- a/skills/bailian-opd/SKILL.md +++ b/skills/bailian-opd/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-opd metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl", "node"] description: >- diff --git a/skills/bailian-protocol/SKILL.md b/skills/bailian-protocol/SKILL.md index 24ef2f2d4..b591e10f5 100644 --- a/skills/bailian-protocol/SKILL.md +++ b/skills/bailian-protocol/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-protocol metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-sandbox/SKILL.md b/skills/bailian-sandbox/SKILL.md index a55aa6ae5..c0554c00c 100644 --- a/skills/bailian-sandbox/SKILL.md +++ b/skills/bailian-sandbox/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-sandbox metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >- diff --git a/skills/bailian-web-search/SKILL.md b/skills/bailian-web-search/SKILL.md index 22af90fa4..5f48a29cf 100644 --- a/skills/bailian-web-search/SKILL.md +++ b/skills/bailian-web-search/SKILL.md @@ -1,7 +1,7 @@ --- name: bailian-web-search metadata: - version: "2.14.1" + version: "2.15.0" requires: bins: ["bl"] description: >-