mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-16 17:09:09 +00:00
The legacy agent card language matches the current card.
Boarded on release/v3.8.52 at 788cd78d05. Focused tests: 260 passed. File-size kept only the inherited executeTargetAttempt.ts overage (1288 > 1284). codex.ts is 1516 lines, under the frozen 1526. This pull request does not touch the inherited overage.
⚠️ base-red inherited: #15306
Fixes #16188.
This commit is contained in:
committed by
GitHub
parent
d22dd35e08
commit
5b16041b73
1
changelog.d/fixes/16188-agent-card-language.md
Normal file
1
changelog.d/fixes/16188-agent-card-language.md
Normal file
@@ -0,0 +1 @@
|
||||
- **A2A discovery:** Align the legacy Agent Card’s static names, descriptions, and examples with the English v1 card, and remove the outdated fixed skill count while preserving legacy protocol fields and dynamic fleet entries. Fixes #16188.
|
||||
@@ -27,11 +27,11 @@ export async function GET(request?: NextRequest) {
|
||||
const fleetSkills = await getFleetSkills();
|
||||
const baseUrl = getBaseUrl(request);
|
||||
const agentCard = {
|
||||
name: "OmniRoute AI 网关",
|
||||
name: "OmniRoute AI Gateway",
|
||||
description:
|
||||
"智能 AI 路由网关,支持 36+ 个提供者、智能回退、配额跟踪、" +
|
||||
"格式转换和自动管理组合。根据成本、延迟、配额可用性" +
|
||||
"和任务要求将 AI 请求路由到最优提供者。",
|
||||
"Intelligent AI routing gateway with 36+ providers, smart fallback, quota tracking, " +
|
||||
"format translation, and auto-managed combos. Routes AI requests to the optimal " +
|
||||
"provider based on cost, latency, quota availability, and task requirements.",
|
||||
url: `${baseUrl}/a2a`,
|
||||
version: APP_CONFIG.version,
|
||||
capabilities: {
|
||||
@@ -41,65 +41,56 @@ export async function GET(request?: NextRequest) {
|
||||
skills: [
|
||||
{
|
||||
id: "smart-routing",
|
||||
name: "智能请求路由",
|
||||
name: "Smart Request Routing",
|
||||
description:
|
||||
"基于配额、成本、延迟和可靠性将 AI 请求路由到最优提供者。" +
|
||||
"支持基于组合的路由,包含多种策略:优先级、加权、轮询、成本优化。",
|
||||
"Routes AI requests to the optimal provider based on quota, cost, latency, and reliability.",
|
||||
tags: ["routing", "llm", "optimization", "fallback"],
|
||||
examples: [
|
||||
"将此编码任务路由到最快的可用模型",
|
||||
"将此次审查发送给预算 $0.50 以下的分析模型",
|
||||
"查找有可用配额的最便宜提供者",
|
||||
"Route this coding task to the fastest available model",
|
||||
"Send this review to an analytical model under a $0.50 budget",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "quota-management",
|
||||
name: "配额与成本管理",
|
||||
name: "Quota & Cost Management",
|
||||
description:
|
||||
"跨 36+ 个提供者跟踪和管理 API 配额," +
|
||||
"配额耗尽时自动回退。提供实时成本跟踪和预算执行。",
|
||||
"Tracks and manages API quotas across providers with auto-fallback when quotas are exhausted.",
|
||||
tags: ["quota", "cost", "monitoring", "budget"],
|
||||
examples: ["检查所有提供者的剩余配额", "哪个提供者有最多可用配额?", "生成今天的成本报告"],
|
||||
examples: ["Check remaining quota for all providers", "Generate a cost report for today"],
|
||||
},
|
||||
{
|
||||
id: "provider-discovery",
|
||||
name: "提供者发现",
|
||||
name: "Provider Discovery",
|
||||
description:
|
||||
"发现能够处理请求能力的提供者," +
|
||||
"如聊天、图像、音频、搜索、嵌入、重排序或视频。" +
|
||||
"报告可用性、健康状态、配置状态和推荐提供者。",
|
||||
"Discovers providers that can handle a requested capability (chat, images, audio, search, embeddings, rerank, video).",
|
||||
tags: ["providers", "discovery", "capabilities", "health"],
|
||||
examples: [
|
||||
"哪些提供者可以处理图像生成?",
|
||||
"查找健康的嵌入提供者",
|
||||
"哪些本地提供者已配置?",
|
||||
"Which providers can handle image generation?",
|
||||
"Find healthy providers for embeddings",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "cost-analysis",
|
||||
name: "成本分析",
|
||||
name: "Cost Analysis",
|
||||
description:
|
||||
"按提供者和模型分析使用成本,比较最近时段," + "并返回可供代理执行的成本节省机会。",
|
||||
"Analyzes usage costs by provider and model and returns cost-saving opportunities.",
|
||||
tags: ["cost", "usage", "analytics", "optimization"],
|
||||
examples: ["这周花了多少钱?", "哪个提供者花费最多?", "建议过去 30 天的成本节省机会"],
|
||||
examples: ["How much did we spend this week?", "Which provider costs the most?"],
|
||||
},
|
||||
{
|
||||
id: "health-report",
|
||||
name: "健康报告",
|
||||
name: "Health Report",
|
||||
description:
|
||||
"将提供者健康状态、断路器状态、速率限制队列、" +
|
||||
"锁定和遥测汇总为结构化报告,供编排使用。",
|
||||
"Summarizes provider health, circuit-breaker state, rate-limit queues, and telemetry into a structured report.",
|
||||
tags: ["health", "monitoring", "resilience", "telemetry"],
|
||||
examples: ["一切都健康吗?", "报告降级的提供者和重试时机", "汇总活跃的速率限制和锁定"],
|
||||
examples: ["Is everything healthy?", "Report degraded providers and retry timing"],
|
||||
},
|
||||
{
|
||||
id: "list-capabilities",
|
||||
name: "列出能力",
|
||||
description:
|
||||
"返回 42 个 OmniRoute 代理技能的完整目录(22 API + 20 CLI)" +
|
||||
"以及 SKILL.md 文档的原始 URL。",
|
||||
name: "List Capabilities",
|
||||
description: "Returns the full catalog of OmniRoute agent skills.",
|
||||
tags: ["discovery", "capabilities"],
|
||||
examples: ["你能做什么?", "列出你的技能", "展示能力"],
|
||||
examples: ["What can you do?", "List your skills"],
|
||||
},
|
||||
...fleetSkills,
|
||||
],
|
||||
|
||||
166
tests/unit/agent-card-language-16188.test.ts
Normal file
166
tests/unit/agent-card-language-16188.test.ts
Normal file
@@ -0,0 +1,166 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { NextRequest } from "next/server";
|
||||
|
||||
import { GET as getLegacyCard } from "../../src/app/.well-known/agent.json/route.ts";
|
||||
import { GET as getCurrentCard } from "../../src/app/.well-known/agent-card.json/route.ts";
|
||||
import { clearFleetSkillsCache, getFleetSkills } from "../../src/lib/conductor/fleetSkills.ts";
|
||||
import { APP_CONFIG } from "../../src/shared/constants/appConfig.ts";
|
||||
|
||||
const STATIC_IDS = [
|
||||
"smart-routing",
|
||||
"quota-management",
|
||||
"provider-discovery",
|
||||
"cost-analysis",
|
||||
"health-report",
|
||||
"list-capabilities",
|
||||
];
|
||||
const ENV_KEYS = [
|
||||
"CONDUCTOR_HUB_URL",
|
||||
"CONDUCTOR_HUB_TOKEN",
|
||||
"OMNIROUTE_BASE_URL",
|
||||
"PORT",
|
||||
"DASHBOARD_PORT",
|
||||
];
|
||||
const originalEnv = new Map(ENV_KEYS.map((key) => [key, process.env[key]]));
|
||||
|
||||
function request(language?: string) {
|
||||
return new NextRequest("https://gateway.example.test/.well-known/agent.json", {
|
||||
headers: language ? { "accept-language": language } : {},
|
||||
});
|
||||
}
|
||||
|
||||
async function cards(language?: string) {
|
||||
const legacy = await (await getLegacyCard(request(language))).json();
|
||||
const current = await (await getCurrentCard(request(language))).json();
|
||||
return { legacy, current };
|
||||
}
|
||||
|
||||
test.beforeEach(() => {
|
||||
clearFleetSkillsCache();
|
||||
for (const key of ENV_KEYS) delete process.env[key];
|
||||
});
|
||||
|
||||
test.after(() => {
|
||||
clearFleetSkillsCache();
|
||||
for (const [key, value] of originalEnv) {
|
||||
if (value === undefined) delete process.env[key];
|
||||
else process.env[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
test("legacy discovery name and description use the same English as the current card", async () => {
|
||||
const { legacy, current } = await cards();
|
||||
assert.equal(legacy.name, "OmniRoute AI Gateway");
|
||||
assert.equal(legacy.name, current.name);
|
||||
assert.equal(legacy.description, current.description);
|
||||
});
|
||||
|
||||
test("all six static skill descriptions and examples agree across card versions", async () => {
|
||||
const { legacy, current } = await cards();
|
||||
assert.deepEqual(
|
||||
legacy.skills.map((skill: { id: string }) => skill.id),
|
||||
STATIC_IDS
|
||||
);
|
||||
assert.deepEqual(legacy.skills, current.skills);
|
||||
assert.equal(legacy.skills[0].name, "Smart Request Routing");
|
||||
});
|
||||
|
||||
test("list-capabilities describes the full catalog without an obsolete fixed count", async () => {
|
||||
const { legacy } = await cards();
|
||||
const entry = legacy.skills.find((skill: { id: string }) => skill.id === "list-capabilities");
|
||||
assert.equal(entry.name, "List Capabilities");
|
||||
assert.equal(entry.description, "Returns the full catalog of OmniRoute agent skills.");
|
||||
assert.deepEqual(entry.examples, ["What can you do?", "List your skills"]);
|
||||
});
|
||||
|
||||
test("text alignment preserves the legacy protocol envelope and response headers", async () => {
|
||||
const response = await getLegacyCard(request());
|
||||
const card = await response.json();
|
||||
assert.equal(response.status, 200);
|
||||
assert.equal(response.headers.get("cache-control"), "public, max-age=3600");
|
||||
assert.match(response.headers.get("content-type") ?? "", /^application\/json/);
|
||||
assert.equal(card.version, APP_CONFIG.version);
|
||||
assert.equal(card.url, "https://gateway.example.test/a2a");
|
||||
assert.deepEqual(card.capabilities, { streaming: true, pushNotifications: false });
|
||||
assert.deepEqual(card.authentication, {
|
||||
schemes: ["api-key"],
|
||||
apiKeyHeader: "Authorization",
|
||||
});
|
||||
assert.deepEqual(Object.keys(card).sort(), [
|
||||
"authentication",
|
||||
"capabilities",
|
||||
"description",
|
||||
"name",
|
||||
"skills",
|
||||
"url",
|
||||
"version",
|
||||
]);
|
||||
});
|
||||
|
||||
test("the admin URL override and direct-call fallback still use the existing origin rules", async () => {
|
||||
process.env.OMNIROUTE_BASE_URL = "https://public.example.test";
|
||||
const override = await (await getLegacyCard(request())).json();
|
||||
assert.equal(override.url, "https://public.example.test/a2a");
|
||||
delete process.env.OMNIROUTE_BASE_URL;
|
||||
process.env.PORT = "24688";
|
||||
const direct = await (await getLegacyCard()).json();
|
||||
assert.equal(direct.url, "http://localhost:24688/a2a");
|
||||
delete process.env.PORT;
|
||||
process.env.DASHBOARD_PORT = "24689";
|
||||
const dashboard = await (await getLegacyCard()).json();
|
||||
assert.equal(dashboard.url, "http://localhost:24689/a2a");
|
||||
});
|
||||
|
||||
test("Accept-Language does not localize the owned discovery metadata", async () => {
|
||||
for (const language of ["zh-CN", "ja-JP"]) {
|
||||
const { legacy, current } = await cards(language);
|
||||
assert.equal(legacy.name, "OmniRoute AI Gateway");
|
||||
assert.deepEqual(legacy.skills, current.skills);
|
||||
}
|
||||
});
|
||||
|
||||
test("both cards append real fleet-derived entries without translating external metadata", async () => {
|
||||
process.env.CONDUCTOR_HUB_URL = "https://synthetic-hub.example.test";
|
||||
process.env.CONDUCTOR_HUB_TOKEN = "synthetic-hub-token";
|
||||
let fetches = 0;
|
||||
const fleet = await getFleetSkills({
|
||||
fetchImpl: async (input, init) => {
|
||||
fetches++;
|
||||
assert.equal(String(input), "https://synthetic-hub.example.test/v1/runners");
|
||||
assert.equal(new Headers(init?.headers).get("authorization"), "Bearer synthetic-hub-token");
|
||||
return Response.json([
|
||||
{
|
||||
online: true,
|
||||
capabilities: { clis: [{ profile: "分析", models: [{ id: "模型" }] }], skills: ["計画"] },
|
||||
},
|
||||
]);
|
||||
},
|
||||
});
|
||||
const { legacy, current } = await cards();
|
||||
assert.equal(fetches, 1);
|
||||
assert.equal(fleet.length, 2);
|
||||
assert.deepEqual(
|
||||
legacy.skills.slice(0, 6).map((skill: { id: string }) => skill.id),
|
||||
STATIC_IDS
|
||||
);
|
||||
assert.deepEqual(legacy.skills.slice(6), fleet);
|
||||
assert.deepEqual(current.skills.slice(6), fleet);
|
||||
assert.equal(legacy.skills[6].name, "Conductor fleet: 分析 CLI");
|
||||
assert.equal(legacy.skills[7].id, "conductor-skill-計画");
|
||||
});
|
||||
|
||||
test("an unavailable fleet hub leaves all static discovery entries available", async () => {
|
||||
process.env.CONDUCTOR_HUB_URL = "https://synthetic-hub.example.test";
|
||||
const fleet = await getFleetSkills({
|
||||
fetchImpl: async () => {
|
||||
throw new Error("synthetic hub unavailable");
|
||||
},
|
||||
});
|
||||
assert.deepEqual(fleet, []);
|
||||
const { legacy } = await cards();
|
||||
assert.deepEqual(
|
||||
legacy.skills.map((skill: { id: string }) => skill.id),
|
||||
STATIC_IDS
|
||||
);
|
||||
});
|
||||
@@ -154,15 +154,13 @@ test("Agent Card v1.0 (/.well-known/agent-card.json): same skill ids, both proto
|
||||
);
|
||||
});
|
||||
|
||||
test("characterization: the v0.3 Agent Card currently serves zh-CN name/descriptions (v1.0 card is English)", async () => {
|
||||
test("the v0.3 Agent Card serves the same English metadata as the v1.0 card", async () => {
|
||||
const v03 = await (await agentCardV03.GET()).json();
|
||||
// Hardcoded by the zh-CN localization commit (#9038); the v1.0 card kept English.
|
||||
assert.equal(v03.name, "OmniRoute AI 网关");
|
||||
assert.match(v03.description, /智能 AI 路由网关/);
|
||||
assert.equal(
|
||||
v03.skills.find((s: { id: string }) => s.id === "smart-routing").name,
|
||||
"智能请求路由"
|
||||
);
|
||||
const v10 = await (await agentCardV10.GET()).json();
|
||||
assert.equal(v03.name, "OmniRoute AI Gateway");
|
||||
assert.equal(v03.name, v10.name);
|
||||
assert.equal(v03.description, v10.description);
|
||||
assert.deepEqual(v03.skills, v10.skills);
|
||||
});
|
||||
|
||||
// ─── (b) Skill handler via A2A_SKILL_HANDLERS ────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user