@agent-proxy/agy 0.18.0 → 0.20.0

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/dist/catalog.js CHANGED
@@ -2,9 +2,9 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { createHash } from "node:crypto";
4
4
  import { getCodexBaselineEntry } from "./resources/models.js";
5
- import { invalidateModelsCache, withAgentSystemPrompt } from "@agent-proxy/plugin-api";
5
+ import { invalidateModelsCache } from "@agent-proxy/plugin-api";
6
6
  import { atomicWrite } from "@agent-proxy/plugin-api";
7
- import { AGY_AGENT_SYSTEM_PROMPT, AGY_ENDPOINT } from "./transport.js";
7
+ import { AGY_ENDPOINT } from "./transport.js";
8
8
  import { THINKING_LEVELS } from "./request.js";
9
9
  /**
10
10
  * Antigravity 模型目录:`POST /v1internal:fetchAvailableModels` 拉取,以 `models`
@@ -238,7 +238,7 @@ export function buildAgyCatalog(data) {
238
238
  delete model.max_context_window;
239
239
  delete model.effective_context_window_percent;
240
240
  }
241
- return withAgentSystemPrompt(model, AGY_AGENT_SYSTEM_PROMPT);
241
+ return model;
242
242
  };
243
243
  const emitted = new Set();
244
244
  const models = [];
package/dist/index.js CHANGED
@@ -112,7 +112,7 @@ function buildAgyAdapter(config, dependencies = {}) {
112
112
  async catalog() {
113
113
  if (closed)
114
114
  return { models: [] };
115
- // 系统提示词已在 buildAgyCatalog 合成时替换(含 model_messages 模板),缓存即成品。
115
+ // 目录缓存即成品(官方提示词由请求转换层整体注入,任何客户端协议进入均生效)。
116
116
  return { models: (await loadCatalogMeta()) ?? [] };
117
117
  },
118
118
  /** 显式刷新不吞错;无 last-good 时由命令报告失败。 */
package/dist/request.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { AGY_DEFAULT_PROJECT } from "./transport.js";
2
+ import { AGY_AGENT_SYSTEM_PROMPT, AGY_DEFAULT_PROJECT } from "./transport.js";
3
3
  /**
4
4
  * Codex Responses → Antigravity v1internal generateContent 请求转换。
5
5
  *
@@ -90,24 +90,6 @@ function safeToolName(name) {
90
90
  function textPart(value, field) {
91
91
  return { text: string(value.text, `${field}.text`) };
92
92
  }
93
- function systemText(value, field) {
94
- if (typeof value === "string")
95
- return value;
96
- if (!Array.isArray(value))
97
- fail(`${field} 必须是字符串或内容数组`);
98
- const parts = [];
99
- for (const raw of value) {
100
- if (!record(raw))
101
- fail(`${field} 包含无效内容块`);
102
- if (raw.type === "input_text" || raw.type === "output_text" || raw.type === "text") {
103
- parts.push(string(raw.text, `${field}.text`));
104
- }
105
- else {
106
- fail(`${field} 的 system 内容不支持图片等非文本块`);
107
- }
108
- }
109
- return parts.join("\n\n");
110
- }
111
93
  function toolIdentity(rawName, rawNamespace) {
112
94
  const original = string(rawName, "工具 name");
113
95
  if (!original)
@@ -604,8 +586,9 @@ export function translateAgyRequest(body, upstreamModel, to = "responses") {
604
586
  }
605
587
  if (item.type === "message" || item.type === undefined) {
606
588
  if (item.role === "system" || item.role === "developer") {
589
+ // 客户端系统级内容整体替换为官方 AGY 提示词(catalog 不再注入,任何
590
+ // 客户端协议进入都在转换层统一注入),不再收集进 system。
607
591
  pendingAssistant = undefined;
608
- system.push(systemText(item.content, `${item.role} 消息`));
609
592
  continue;
610
593
  }
611
594
  if (item.role !== "user" && item.role !== "assistant")
@@ -646,6 +629,46 @@ export function translateAgyRequest(body, upstreamModel, to = "responses") {
646
629
  (item.role === "assistant" ? assistantContent() : userContent()).parts.push(...parts);
647
630
  continue;
648
631
  }
632
+ if (item.type === "agent_message") {
633
+ // Codex 多智能体历史:agent 产出的消息(author/recipient 为内部路由元数据)
634
+ // 按 assistant 回放文本与图片;encrypted_content 是上游私有加密载荷,跨厂商
635
+ // 不可解,直接剥离。
636
+ const parts = [];
637
+ const content = item.content;
638
+ if (typeof content === "string")
639
+ parts.push({ text: content });
640
+ else if (Array.isArray(content)) {
641
+ for (const raw of content) {
642
+ if (!record(raw))
643
+ fail("agent_message 包含无效内容块");
644
+ if (raw.type === "encrypted_content")
645
+ continue;
646
+ if (raw.type === "input_text" || raw.type === "output_text" || raw.type === "text")
647
+ parts.push(textPart(raw, "agent_message"));
648
+ else if (raw.type === "input_image" || raw.type === "image") {
649
+ const source = raw.image_url ?? raw.url;
650
+ const url = typeof source === "string" ? source : record(source) ? source.url : undefined;
651
+ if (typeof url !== "string" || !url)
652
+ fail("agent_message 的 input_image 缺少 image_url");
653
+ if (url.startsWith("data:")) {
654
+ const match = /^data:([^;,]*)(?:;charset=[^;,]*)?;base64,(.*)$/s.exec(url);
655
+ if (!match)
656
+ fail("agent_message 的 data URI 必须是 base64 编码");
657
+ parts.push({ inlineData: { mimeType: match[1] || "image/png", data: match[2] } });
658
+ }
659
+ else {
660
+ parts.push({ fileData: { fileUri: url } });
661
+ }
662
+ }
663
+ else
664
+ fail(`agent_message 包含不支持的内容块类型 ${String(raw.type)}`);
665
+ }
666
+ }
667
+ else
668
+ fail("agent_message 的 content 必须是字符串或数组");
669
+ assistantContent().parts.push(...parts);
670
+ continue;
671
+ }
649
672
  if (item.type === "function_call" || item.type === "custom_tool_call") {
650
673
  const identity = toolIdentity(item.name, item.namespace);
651
674
  const custom = item.type === "custom_tool_call";
@@ -736,9 +759,9 @@ export function translateAgyRequest(body, upstreamModel, to = "responses") {
736
759
  }
737
760
  const inner = {
738
761
  contents,
739
- ...(system.length || body.instructions !== undefined ? {
740
- systemInstruction: { role: "user", parts: [...(body.instructions !== undefined ? [{ text: body.instructions }] : []), ...system.map((text) => ({ text }))] },
741
- } : {}),
762
+ // 官方 AGY 提示词为 systemInstruction 唯一基底;客户端 instructions 与
763
+ // system/developer 内容已剥离,网关旁白(dropped 工具通告)接在其后。
764
+ systemInstruction: { role: "user", parts: [{ text: AGY_AGENT_SYSTEM_PROMPT }, ...system.map((text) => ({ text }))] },
742
765
  ...(convertedTools.tools.length ? { tools: [{ functionDeclarations: convertedTools.tools }] } : {}),
743
766
  generationConfig,
744
767
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-proxy/agy",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Agent Proxy agy 插件;保留基线转换行为。",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,10 +35,10 @@
35
35
  "url": "git+https://github.com/aceHubert/codex-cliproxy-gateway.git"
36
36
  },
37
37
  "devDependencies": {
38
- "@agent-proxy/models": "0.18.0"
38
+ "@agent-proxy/models": "0.20.0"
39
39
  },
40
40
  "dependencies": {
41
- "@agent-proxy/plugin-api": "0.18.0"
41
+ "@agent-proxy/plugin-api": "0.20.0"
42
42
  },
43
- "gitHead": "952c260940541ec72d0859d3d66bb39738e1c40f"
43
+ "gitHead": "52d36d18816a077ef2861bf3b5479a7dbd95108c"
44
44
  }