@agent-proxy/zcode 0.18.0 → 0.19.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/index.js +6 -6
- package/dist/request.js +8 -6
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { isIP } from "node:net";
|
|
4
4
|
import { resolvePaths } from "@agent-proxy/plugin-api";
|
|
5
5
|
import { createZcodeConfigCache, readZcodeAPIKeyProviders, zcodeConfigPresent, ZcodeConfigError } from "./config.js";
|
|
6
|
-
import { clearModelsCacheEntries, invalidateModelsCache
|
|
6
|
+
import { clearModelsCacheEntries, invalidateModelsCache } from "@agent-proxy/plugin-api";
|
|
7
7
|
import { buildZcodeVendorCatalog, createZcodeCatalog, isZcodeModel, writeZcodeServedCatalog, zcodeAPIProviderIDFromModel, zcodeModelPlan, zcodeUpstreamModel, } from "./catalog.js";
|
|
8
8
|
import { translateZcodeRequest, ZcodeRequestError } from "./request.js";
|
|
9
9
|
import { createZcodeClientResponse } from "./response.js";
|
|
@@ -11,7 +11,7 @@ import { executeZcodeAnalyzeImage, matchZcodeAnalyzeImage } from "./vision.js";
|
|
|
11
11
|
import { ZcodeEndpointRouting } from "./endpoint-routing.js";
|
|
12
12
|
import { clientSigningVerifyRejection, ZcodeClientSigning } from "./client-signing.js";
|
|
13
13
|
import { isZcodeRecord } from "./wire.js";
|
|
14
|
-
import { buildZcodeModelHeaders, createZcodeContexts, decorateZcodeBody, readZcodeIdentity, zcodePlan
|
|
14
|
+
import { buildZcodeModelHeaders, createZcodeContexts, decorateZcodeBody, readZcodeIdentity, zcodePlan } from "./request-context.js";
|
|
15
15
|
import { localTime, logExchange, logGroupFromPath, requestLogDir } from "@agent-proxy/plugin-api";
|
|
16
16
|
import { logGatewayError, logRequestSummary } from "@agent-proxy/plugin-api";
|
|
17
17
|
export function validateZcodeConfig(config) {
|
|
@@ -52,10 +52,10 @@ function buildZcodeAdapter(config, dependencies = {}) {
|
|
|
52
52
|
return clearModelsCacheEntries(dependencies.codexModelsCacheFile, (slug) => isZcodeModel(slug) && !current.has(slug.toLowerCase()));
|
|
53
53
|
};
|
|
54
54
|
const publishServedCatalog = (catalog) => {
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
servedCatalog = { models: catalog.models
|
|
55
|
+
// 目录条目保持 vendor 预设基底(base_instructions 为空串、无 model_messages 模板);
|
|
56
|
+
// 官方 ZCode 提示词由请求转换层整体注入(request.ts,任何客户端协议进入均生效),
|
|
57
|
+
// catalog 不再改写提示词。
|
|
58
|
+
servedCatalog = { models: catalog.models };
|
|
59
59
|
const changed = writeZcodeServedCatalog(servedCatalogFile, servedCatalog);
|
|
60
60
|
if (!changed || !dependencies.codexModelsCacheFile)
|
|
61
61
|
return;
|
package/dist/request.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BridgeConversionError, convertRequest, normalizeResponsesToolDeclarations } from "@agent-proxy/llm-bridge";
|
|
1
|
+
import { BridgeConversionError, convertRequest, normalizeResponsesToolDeclarations, stripClientSystemPrompt } from "@agent-proxy/llm-bridge";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
+
import { ZCODE_AGENT_SYSTEM_PROMPT } from "./request-context.js";
|
|
3
4
|
import { decodeZcodeThinking, isZcodeRecord } from "./wire.js";
|
|
4
5
|
import { ANALYZE_IMAGE_SYSTEM_NOTE, ANALYZE_IMAGE_TOOL_DECLARATION, ANALYZE_IMAGE_TOOL_NAME, collectZcodeImages } from "./vision.js";
|
|
5
6
|
/**
|
|
@@ -267,6 +268,9 @@ export async function translateZcodeRequest(body, upstreamModel, to = "responses
|
|
|
267
268
|
}
|
|
268
269
|
if (body.instructions !== undefined && typeof body.instructions !== "string")
|
|
269
270
|
fail("instructions 必须是字符串");
|
|
271
|
+
// 官方 ZCode 提示词整体替换客户端系统内容(catalog 不再注入,任何客户端协议
|
|
272
|
+
// 进入都在转换层统一注入):入口先剥离 instructions 与 system/developer 内容。
|
|
273
|
+
body = stripClientSystemPrompt(to, body);
|
|
270
274
|
// 上游 token 上限按来源取参:responses 用 max_output_tokens,chat-completions /
|
|
271
275
|
// anthropic 用 max_tokens,gemini 用 generationConfig.maxOutputTokens;缺省走服务默认 16384。
|
|
272
276
|
const sourceLimit = to === "responses"
|
|
@@ -281,9 +285,9 @@ export async function translateZcodeRequest(body, upstreamModel, to = "responses
|
|
|
281
285
|
const clientModel = body.model === undefined ? upstreamModel : string(body.model, "model");
|
|
282
286
|
const identities = new Map();
|
|
283
287
|
const messages = [];
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
288
|
+
// 官方 ZCode 提示词为上游系统槽唯一基底;客户端系统内容已入口剥离,
|
|
289
|
+
// 网关旁白(dropped 工具通告、视觉适配说明)随后拼装。
|
|
290
|
+
const system = [ZCODE_AGENT_SYSTEM_PROMPT];
|
|
287
291
|
let passthroughChoice;
|
|
288
292
|
let passthroughStopSequences;
|
|
289
293
|
let passthroughTools;
|
|
@@ -301,8 +305,6 @@ export async function translateZcodeRequest(body, upstreamModel, to = "responses
|
|
|
301
305
|
identities.set(mapped, identity);
|
|
302
306
|
for (const message of anthropicMessagesOf(converted))
|
|
303
307
|
addMessage(messages, message.role, message.content);
|
|
304
|
-
if (typeof converted.body.system === "string" && converted.body.system)
|
|
305
|
-
system.push(converted.body.system);
|
|
306
308
|
passthroughTools = Array.isArray(converted.body.tools) ? converted.body.tools.filter(record) : undefined;
|
|
307
309
|
passthroughChoice = converted.body.tool_choice;
|
|
308
310
|
if (Array.isArray(converted.body.stop_sequences) && converted.body.stop_sequences.every((entry) => typeof entry === "string")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-proxy/zcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Agent Proxy zcode 插件;保留基线转换行为。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"url": "git+https://github.com/aceHubert/codex-cliproxy-gateway.git"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@agent-proxy/models": "0.
|
|
38
|
+
"@agent-proxy/models": "0.19.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@agent-proxy/llm-bridge": "0.
|
|
42
|
-
"@agent-proxy/plugin-api": "0.
|
|
41
|
+
"@agent-proxy/llm-bridge": "0.19.0",
|
|
42
|
+
"@agent-proxy/plugin-api": "0.19.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "20dff92139f68670155c173ba94849415c7ef21e"
|
|
45
45
|
}
|