@wacry/codeks-bridge 0.0.13 → 0.0.15
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/README.md +3 -2
- package/dist/catalog.js +6 -3
- package/dist/config.js +10 -8
- package/dist/inspect/capture.d.ts +3 -2
- package/dist/inspect/capture.js +4 -3
- package/dist/inspect/view.d.ts +3 -3
- package/dist/inspect/view.js +17 -8
- package/dist/server.js +11 -9
- package/dist/types.d.ts +4 -0
- package/docs/config.md +19 -3
- package/docs/design.md +7 -1
- package/docs/embedding.md +3 -3
- package/docs/image-generation.md +58 -0
- package/docs/inspect.md +9 -9
- package/docs/tools.md +1 -1
- package/examples/chatgpt-claude.json +1 -0
- package/package.json +1 -1
- package/ui/labels.js +7 -5
package/README.md
CHANGED
|
@@ -34,10 +34,11 @@ codeks-bridge config-snippet --config /absolute/path/bridge.json
|
|
|
34
34
|
- bridge 封装的 reasoning 默认只回放给原目标,原生压缩与 reasoning 的跨目标复用分别配置。无法识别的历史状态默认透传,也可配置[过滤或报错](docs/config.md#未识别的历史状态);实际兼容性由上游决定。
|
|
35
35
|
- GPT 默认使用 `compaction.mode: "native"`:先做原生加密压缩,需要文字表示时再向原来源复述并缓存。其他模型默认使用标准文字压缩,也可通过 [`compaction.model`](docs/config.md#压缩模式与执行模型) 委托常用 GPT 执行原生压缩,直接复用已有模型配置;见 [GPT+Claude 双模型示例](examples/gpt-claude.json)。
|
|
36
36
|
- 历史由 codeks 保存;按需复述的成功结果另存本地缓存。封装只是编码,文字 reasoning、摘要及复述配方可读。
|
|
37
|
-
- Lark/regex
|
|
37
|
+
- Lark/regex 转为工具描述约束。配置 `"web_search": { "upstream": "chatgpt" }` 后,所有模型可共用[订阅搜索](docs/web-search.md)。
|
|
38
|
+
- 配置 `"image_generation": { "upstream": "chatgpt" }` 后,支持图片输入的模型可共用[图片生成与编辑](docs/image-generation.md)。codeks 客户端还需已登录 ChatGPT。
|
|
38
39
|
|
|
39
40
|
## 调试
|
|
40
41
|
|
|
41
42
|
`serve` 加 `--capture` 后打开日志里的 `/inspect/` 地址,可以逐条查看 codeks 请求、发往上游的请求、上游原始响应和写回 codeks 的响应,以及 reasoning 与压缩状态的回放决定。记录只在内存中,也可以在页面上开关捕获、清空或导出。详见[调试检查器](docs/inspect.md)。
|
|
42
43
|
|
|
43
|
-
[配置与模型目录](docs/config.md) · [嵌入现有服务](docs/embedding.md) · [整体设计](docs/design.md) · [Reasoning](docs/reasoning.md) · [压缩](docs/compaction.md) · [工具](docs/tools.md) · [订阅搜索](docs/web-search.md) · [调试检查器](docs/inspect.md) · [验证](docs/testing.md) · [发布](docs/releasing.md)
|
|
44
|
+
[配置与模型目录](docs/config.md) · [嵌入现有服务](docs/embedding.md) · [整体设计](docs/design.md) · [Reasoning](docs/reasoning.md) · [压缩](docs/compaction.md) · [工具](docs/tools.md) · [订阅搜索](docs/web-search.md) · [图片生成](docs/image-generation.md) · [调试检查器](docs/inspect.md) · [验证](docs/testing.md) · [发布](docs/releasing.md)
|
package/dist/catalog.js
CHANGED
|
@@ -20,11 +20,13 @@ export function configSnippet(config, catalogPath) {
|
|
|
20
20
|
const lines = [
|
|
21
21
|
`model = ${JSON.stringify(first)}`, 'model_provider = "bridge"',
|
|
22
22
|
...(catalogPath ? [`model_catalog_json = ${JSON.stringify(catalogPath)}`] : []),
|
|
23
|
-
`web_search = "${config.web_search ? "live" : "disabled"}"`, "", "[features]",
|
|
23
|
+
`web_search = "${config.web_search ? "live" : "disabled"}"`, "", "[features]", `image_generation = ${!!config.image_generation}`, "",
|
|
24
24
|
// Outside the reserved "collaboration" namespace, codeks sends multi-agent task messages as plaintext.
|
|
25
25
|
"[features.multi_agent_v2]", 'tool_namespace = "agents"', "",
|
|
26
26
|
"[model_providers.bridge]", 'name = "Local bridge"',
|
|
27
27
|
`base_url = ${JSON.stringify(baseUrl)}`, 'wire_api = "responses"',
|
|
28
|
+
// Codex exposes the native image tool only with a local ChatGPT login.
|
|
29
|
+
`requires_openai_auth = ${!!config.image_generation}`,
|
|
28
30
|
];
|
|
29
31
|
if (!catalogPath)
|
|
30
32
|
lines.push(`model_catalog_url = ${JSON.stringify(`${baseUrl}/models`)}`);
|
|
@@ -32,8 +34,9 @@ export function configSnippet(config, catalogPath) {
|
|
|
32
34
|
lines.push("supports_standalone_web_search = true");
|
|
33
35
|
if (config.token_env)
|
|
34
36
|
lines.push(`env_key = ${JSON.stringify(config.token_env)}`);
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
+
// Keep local subscription credentials out of bridge requests; this bearer
|
|
38
|
+
// also enables API-key catalog discovery on loopback.
|
|
39
|
+
else if (!catalogPath || config.image_generation)
|
|
37
40
|
lines.push('experimental_bearer_token = "codeks-bridge-local"');
|
|
38
41
|
lines.push("", "[model_providers.bridge.capabilities]", 'remote_compaction = "v2"', "");
|
|
39
42
|
return lines.join("\n");
|
package/dist/config.js
CHANGED
|
@@ -89,14 +89,16 @@ export function validateConfig(value) {
|
|
|
89
89
|
fail(`upstream ${name}: options must be an object`);
|
|
90
90
|
validateAdapterConfig(up.adapters, `upstream ${name}`);
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
fail(
|
|
98
|
-
if (
|
|
99
|
-
fail(
|
|
92
|
+
for (const name of ["web_search", "image_generation"]) {
|
|
93
|
+
const service = value[name];
|
|
94
|
+
if (service === undefined)
|
|
95
|
+
continue;
|
|
96
|
+
if (!object(service) || typeof service.upstream !== "string" || !Object.hasOwn(value.upstreams, service.upstream))
|
|
97
|
+
fail(`${name}.upstream must name an existing connection`);
|
|
98
|
+
if (Object.keys(service).some(key => key !== "upstream"))
|
|
99
|
+
fail(`unknown ${name} option`);
|
|
100
|
+
if (value.upstreams[service.upstream].auth?.type !== "chatgpt")
|
|
101
|
+
fail(`${name} requires a ChatGPT subscription connection`);
|
|
100
102
|
}
|
|
101
103
|
for (const [slug, model] of Object.entries(value.models)) {
|
|
102
104
|
if (!slug || !object(model) || typeof model.model !== "string" || !model.model || typeof model.upstream !== "string" || !Object.hasOwn(value.upstreams, model.upstream))
|
|
@@ -2,6 +2,7 @@ import type { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders, ServerR
|
|
|
2
2
|
import type { BridgeConfig, ResolvedModel, ResponsesRequest } from "../types.ts";
|
|
3
3
|
export declare const DEFAULT_CAPTURE_MIB = 256;
|
|
4
4
|
export type EndKind = "active" | "complete" | "cancelled" | "error" | "unread";
|
|
5
|
+
export type StandaloneKind = "search" | "image_generation";
|
|
5
6
|
export type HeaderMap = Record<string, string>;
|
|
6
7
|
export interface Part {
|
|
7
8
|
t: number;
|
|
@@ -51,7 +52,7 @@ export declare class Call {
|
|
|
51
52
|
}
|
|
52
53
|
export interface RequestMeta {
|
|
53
54
|
model: string | null;
|
|
54
|
-
kind: "turn" | "compaction" |
|
|
55
|
+
kind: "turn" | "compaction" | StandaloneKind | "invalid";
|
|
55
56
|
stream: boolean | null;
|
|
56
57
|
input_items: number | null;
|
|
57
58
|
preview: string | null;
|
|
@@ -82,7 +83,7 @@ export declare class Exchange {
|
|
|
82
83
|
touch(): void;
|
|
83
84
|
account(bytes: number): void;
|
|
84
85
|
received(text: string): void;
|
|
85
|
-
parsed(request: ResponsesRequest, kind?:
|
|
86
|
+
parsed(request: ResponsesRequest, kind?: StandaloneKind): void;
|
|
86
87
|
routed(route: ResolvedModel, responsesLite: boolean): void;
|
|
87
88
|
/** Records what the bridge writes, at the same calls that write it. */
|
|
88
89
|
private tap;
|
package/dist/inspect/capture.js
CHANGED
|
@@ -210,9 +210,10 @@ export class Exchange {
|
|
|
210
210
|
this.meta = {
|
|
211
211
|
model: typeof request.model === "string" ? request.model : null,
|
|
212
212
|
kind: kind ?? (Array.isArray(input) && input.some(item => item?.type === "compaction_trigger") ? "compaction" : "turn"),
|
|
213
|
-
stream: kind
|
|
214
|
-
input_items: Array.isArray(input) ? input.length : null,
|
|
215
|
-
preview: kind === "
|
|
213
|
+
stream: kind ? false : typeof request.stream === "boolean" ? request.stream : null,
|
|
214
|
+
input_items: kind === "image_generation" ? null : Array.isArray(input) ? input.length : null,
|
|
215
|
+
preview: kind === "image_generation" ? typeof request.prompt === "string" ? request.prompt.slice(0, 200) : null
|
|
216
|
+
: kind === "search" ? JSON.stringify(request.commands ?? {}).slice(0, 200) : previewOf(request),
|
|
216
217
|
};
|
|
217
218
|
this.touch();
|
|
218
219
|
}
|
package/dist/inspect/view.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare function summary(exchange: Exchange): {
|
|
|
36
36
|
api: import("../types.ts").Api | null;
|
|
37
37
|
upstream: string | null;
|
|
38
38
|
upstream_model: string | null;
|
|
39
|
-
kind: "
|
|
39
|
+
kind: "compaction" | import("./capture.ts").StandaloneKind | "turn" | "invalid";
|
|
40
40
|
stream: boolean | null;
|
|
41
41
|
status: number | null;
|
|
42
42
|
outcome: Outcome;
|
|
@@ -153,7 +153,7 @@ export declare function detail(exchange: Exchange): {
|
|
|
153
153
|
adapter: import("../types.ts").AdapterId | null;
|
|
154
154
|
api: import("../types.ts").Api | null;
|
|
155
155
|
upstream_model: string | null;
|
|
156
|
-
kind: "
|
|
156
|
+
kind: "compaction" | import("./capture.ts").StandaloneKind | "turn" | "invalid";
|
|
157
157
|
stream: boolean | null;
|
|
158
158
|
status: number | null;
|
|
159
159
|
outcome: Outcome;
|
|
@@ -213,7 +213,7 @@ export declare function listView(inspector: Inspector, since: number): {
|
|
|
213
213
|
api: import("../types.ts").Api | null;
|
|
214
214
|
upstream: string | null;
|
|
215
215
|
upstream_model: string | null;
|
|
216
|
-
kind: "
|
|
216
|
+
kind: "compaction" | import("./capture.ts").StandaloneKind | "turn" | "invalid";
|
|
217
217
|
stream: boolean | null;
|
|
218
218
|
status: number | null;
|
|
219
219
|
outcome: Outcome;
|
package/dist/inspect/view.js
CHANGED
|
@@ -138,10 +138,17 @@ function source(inspector, origin) {
|
|
|
138
138
|
function header(exchange, name) {
|
|
139
139
|
return exchange.headers[name] ?? null;
|
|
140
140
|
}
|
|
141
|
+
function standaloneConnection(exchange) {
|
|
142
|
+
const { config } = exchange.inspector;
|
|
143
|
+
if (exchange.meta.kind === "search")
|
|
144
|
+
return config.web_search;
|
|
145
|
+
if (exchange.meta.kind === "image_generation")
|
|
146
|
+
return config.image_generation;
|
|
147
|
+
}
|
|
141
148
|
export function summary(exchange) {
|
|
142
149
|
const { outcome, error, usage } = result(exchange);
|
|
143
150
|
const route = exchange.route;
|
|
144
|
-
const
|
|
151
|
+
const standalone = standaloneConnection(exchange);
|
|
145
152
|
return {
|
|
146
153
|
id: exchange.id,
|
|
147
154
|
seq: exchange.seq,
|
|
@@ -151,9 +158,9 @@ export function summary(exchange) {
|
|
|
151
158
|
active: !exchange.closed,
|
|
152
159
|
model: exchange.meta.model,
|
|
153
160
|
adapter: route?.profile.id ?? null,
|
|
154
|
-
api: route?.profile.api ?? (
|
|
155
|
-
upstream: route?.config.upstream ??
|
|
156
|
-
upstream_model: route?.config.model ?? (
|
|
161
|
+
api: route?.profile.api ?? (standalone ? "responses" : null),
|
|
162
|
+
upstream: route?.config.upstream ?? standalone?.upstream ?? null,
|
|
163
|
+
upstream_model: route?.config.model ?? (standalone ? exchange.meta.model : null),
|
|
157
164
|
kind: exchange.meta.kind,
|
|
158
165
|
stream: exchange.meta.stream,
|
|
159
166
|
status: exchange.response.status ?? null,
|
|
@@ -271,6 +278,8 @@ function outputNote(inspector, item, target) {
|
|
|
271
278
|
return undefined;
|
|
272
279
|
}
|
|
273
280
|
function annotations(exchange, client) {
|
|
281
|
+
if (!exchange.route)
|
|
282
|
+
return [];
|
|
274
283
|
const notes = [];
|
|
275
284
|
const { inspector, route } = exchange;
|
|
276
285
|
const request = route ? parse(exchange.requestText) : undefined;
|
|
@@ -308,12 +317,12 @@ function annotations(exchange, client) {
|
|
|
308
317
|
}
|
|
309
318
|
export function detail(exchange) {
|
|
310
319
|
const client = messageView(exchange.response);
|
|
311
|
-
const
|
|
320
|
+
const standalone = standaloneConnection(exchange);
|
|
312
321
|
return {
|
|
313
322
|
...summary(exchange),
|
|
314
|
-
route: exchange.route ? routeView(exchange.inspector, exchange.route, exchange.responsesLite) :
|
|
315
|
-
alias: exchange.meta.model, api: "responses", upstream:
|
|
316
|
-
base_url: upstreamBaseUrl(exchange.inspector.config.upstreams[
|
|
323
|
+
route: exchange.route ? routeView(exchange.inspector, exchange.route, exchange.responsesLite) : standalone ? {
|
|
324
|
+
alias: exchange.meta.model, api: "responses", upstream: standalone.upstream,
|
|
325
|
+
base_url: upstreamBaseUrl(exchange.inspector.config.upstreams[standalone.upstream]), upstream_model: exchange.meta.model,
|
|
317
326
|
} : null,
|
|
318
327
|
client: {
|
|
319
328
|
request: {
|
package/dist/server.js
CHANGED
|
@@ -52,7 +52,7 @@ async function readRequest(req, maxMiB, exchange, kind) {
|
|
|
52
52
|
exchange?.parsed(request, kind);
|
|
53
53
|
if (typeof request.model !== "string")
|
|
54
54
|
throw new BridgeError("model is required");
|
|
55
|
-
if (kind
|
|
55
|
+
if (kind)
|
|
56
56
|
return request;
|
|
57
57
|
if (request.input !== undefined && typeof request.input !== "string" && !Array.isArray(request.input))
|
|
58
58
|
throw new BridgeError("input must be a string or an array");
|
|
@@ -117,16 +117,18 @@ export function createBridgeServer(value, options = {}) {
|
|
|
117
117
|
res.end(catalog);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
const standalone = path === "/alpha/search" ? "search"
|
|
121
|
+
: path === "/images/generations" || path === "/images/edits" ? "image_generation" : undefined;
|
|
122
|
+
if (req.method === "POST" && standalone) {
|
|
123
|
+
const service = standalone === "search" ? config.web_search : config.image_generation;
|
|
124
|
+
if (!service) {
|
|
125
|
+
json(res, 404, { error: { code: "invalid_prompt", message: `${standalone === "search" ? "Standalone web search" : "Image generation"} is not configured` } });
|
|
123
126
|
return;
|
|
124
127
|
}
|
|
125
|
-
const request = await readRequest(req, config.request_max_mib ?? 512, inspector.begin(req, res),
|
|
126
|
-
const upstream = config.upstreams[
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
const response = await withCaptureLabel("search", () => upstreamFetch({ upstream, profile: { api: "responses" } }, "alpha/search", request, controller.signal, incomingHeaders(req.headers), undefined, options.fetch));
|
|
128
|
+
const request = await readRequest(req, config.request_max_mib ?? 512, inspector.begin(req, res), standalone);
|
|
129
|
+
const upstream = config.upstreams[service.upstream];
|
|
130
|
+
// Standalone JSON protocols do not use inference adapters or history conversion.
|
|
131
|
+
const response = await withCaptureLabel(standalone, () => upstreamFetch({ upstream, profile: { api: "responses" } }, path, request, controller.signal, incomingHeaders(req.headers), undefined, options.fetch));
|
|
130
132
|
const body = Buffer.from(await response.arrayBuffer());
|
|
131
133
|
res.writeHead(response.status, forwardResponseHeaders(response.headers, false));
|
|
132
134
|
res.end(body);
|
package/dist/types.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ export interface BridgeConfig {
|
|
|
64
64
|
web_search?: {
|
|
65
65
|
upstream: string;
|
|
66
66
|
};
|
|
67
|
+
/** Optional subscription image connection, shared by all working models. */
|
|
68
|
+
image_generation?: {
|
|
69
|
+
upstream: string;
|
|
70
|
+
};
|
|
67
71
|
/** Debug capture for the /inspect/ page. */
|
|
68
72
|
inspect?: {
|
|
69
73
|
capture?: boolean;
|
package/docs/config.md
CHANGED
|
@@ -46,14 +46,15 @@
|
|
|
46
46
|
| `host` | 默认 `127.0.0.1` |
|
|
47
47
|
| `port` | 默认 `8787`;程序集成测试可用 `0` 分配端口 |
|
|
48
48
|
| `token_env` | 保存 bridge 入口 Bearer token 的环境变量名称 |
|
|
49
|
-
| `request_max_mib` |
|
|
49
|
+
| `request_max_mib` | 模型、独立搜索及图片 POST 请求体上限,单位 MiB,默认 `512`;必须是正整数且换算后的字节数可安全表示 |
|
|
50
50
|
| `compaction_cache_dir` | 按需复述缓存目录;默认 `$XDG_CACHE_HOME/codeks-bridge/compaction`,未设置 XDG 时为 `~/.cache/codeks-bridge/compaction` |
|
|
51
51
|
| `upstreams` | 上游连接配置表 |
|
|
52
52
|
| `models` | 模型别名表,是否进入客户端目录由各自的 `expose` 控制 |
|
|
53
53
|
| `web_search` | 可选;`{"upstream":"chatgpt"}` 让所有模型共用指定的订阅搜索连接,省略时关闭 |
|
|
54
|
+
| `image_generation` | 可选;`{"upstream":"chatgpt"}` 为支持图片输入的工作模型提供订阅图片生成与编辑,省略时关闭 |
|
|
54
55
|
| `inspect` | 可选;`capture` 决定启动时是否捕获,`max_mib` 是内存软上限,见[调试检查器](inspect.md) |
|
|
55
56
|
|
|
56
|
-
监听非 loopback 地址时必须配置 `token_env`,客户端也要设置同一个变量。它是 bridge 入口鉴权,不是上游 API key。入口没有 CORS。携带 `Origin` 的请求必须使用配置好的 bridge token,即使监听 loopback 也一样,避免网页的简单 POST 在无法读取响应时仍触发上游调用。没有 `Origin` 的 codeks 请求保持原行为。`GET /health`、`GET /v1/models`、`POST /v1/responses`
|
|
57
|
+
监听非 loopback 地址时必须配置 `token_env`,客户端也要设置同一个变量。它是 bridge 入口鉴权,不是上游 API key。入口没有 CORS。携带 `Origin` 的请求必须使用配置好的 bridge token,即使监听 loopback 也一样,避免网页的简单 POST 在无法读取响应时仍触发上游调用。没有 `Origin` 的 codeks 请求保持原行为。`GET /health`、`GET /v1/models`、`POST /v1/responses` 以及启用后的 `/v1/alpha/search`、`/v1/images/generations`、`/v1/images/edits` POST 路由使用同一鉴权。`/inspect/` 页面与接口使用[自己的规则](inspect.md#访问与鉴权)。
|
|
57
58
|
|
|
58
59
|
请求体上限按实际收到的字节计算,包含 JSON 和图片编码,不按字符数或声明的 `Content-Length` 判断。恰好达到上限的请求可接受,超限立即返回 HTTP 413 并关闭连接,不调用上游。默认 `512` MiB 为长截图历史留出空间;可按会话需要及可用内存调高或调低。保留上限是为了约束完整缓冲、JSON 解析和转换的内存开销,启用检查器时还会保留捕获副本;它不是进程总内存上限,也不等于模型 token 窗口。
|
|
59
60
|
|
|
@@ -122,6 +123,21 @@ token 临近过期时自动续期并写回原文件;HTTP 401 可触发一次
|
|
|
122
123
|
|
|
123
124
|
配置后,`config-snippet` 生成 `web_search = "live"` 和 provider 级 `supports_standalone_web_search = true`;合并片段并重载客户端即可启用。工作模型与搜索连接独立,搜索请求的 `model` 原样传递。请求、结果、引用和鉴权边界见[订阅搜索](web-search.md)。
|
|
124
125
|
|
|
126
|
+
## 订阅图片生成与编辑
|
|
127
|
+
|
|
128
|
+
指定使用 `auth.type: "chatgpt"` 的连接,与 `web_search` 分别启用:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"image_generation": { "upstream": "chatgpt" },
|
|
133
|
+
"upstreams": {
|
|
134
|
+
"chatgpt": { "auth": { "type": "chatgpt" } }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
合并到已有模型配置后,重新生成客户端片段。它开启 `features.image_generation` 和 provider 的 `requires_openai_auth`,保留 bridge token 配置。每个 codeks 客户端需要 `codex login`,且当前模型支持图片输入;只有 bridge 服务端持有登录还不足以显示工具。实际图片请求仍由 bridge 所选订阅连接鉴权,无需添加图片模型目录条目。完整用法、登录边界和协议见[图片生成与编辑](image-generation.md)。
|
|
140
|
+
|
|
125
141
|
## 模型
|
|
126
142
|
|
|
127
143
|
| 字段 | 含义 |
|
|
@@ -327,7 +343,7 @@ codeks-bridge config-snippet --config /absolute/path/bridge.json
|
|
|
327
343
|
|
|
328
344
|
配置了 `token_env` 时,片段用 `env_key` 传递 bridge 入口凭据。匿名 loopback 服务使用公开标记 `experimental_bearer_token = "codeks-bridge-local"`,让 codeks 进入 API key 目录发现流程。这个固定字符串不是密钥,也不为服务提供鉴权;需要入口鉴权时应配置 `token_env`。
|
|
329
345
|
|
|
330
|
-
provider 显示名为 `Local bridge`,并显式声明 `[model_providers.bridge.capabilities] remote_compaction = "v2"`,无需借用 Azure 或 OpenAI
|
|
346
|
+
provider 显示名为 `Local bridge`,并显式声明 `[model_providers.bridge.capabilities] remote_compaction = "v2"`,无需借用 Azure 或 OpenAI 名称触发能力。图片生成随 `image_generation` 配置启用,并同时声明 `requires_openai_auth = true`;省略配置时 `features.image_generation = false`,图片输入仍然支持。未配置订阅搜索时关闭 `web_search`;配置后启用 `web_search = "live"` 与 provider 的 `supports_standalone_web_search = true`,模型目录保持原样。
|
|
331
347
|
|
|
332
348
|
片段还设置 `[features.multi_agent_v2] tool_namespace = "agents"`。在默认的保留 namespace `collaboration` 下,`spawn_agent`、`send_message` 和 `followup_task` 的 `message` 带 `encrypted` 标记,GPT 上游会把子代理任务写成密文。GPT 父代理创建的 Claude 或 DeepSeek 子代理只能收到读不懂的密文,会话记录和请求日志里也看不到任务内容。改用其他 namespace 后,codeks 去掉这个标记并按明文投递消息(见 [codeks patch 0005](https://github.com/WAcry/codeks/blob/main/fork/patches/0005-plaintext-agent-messages.md)),任何模型的子代理都能读懂任务,日志中也能看到原始 prompt。没有这个补丁的 Codex 只会改变工具名,消息仍然加密。
|
|
333
349
|
|
package/docs/design.md
CHANGED
|
@@ -58,6 +58,12 @@ ChatGPT 订阅鉴权放在连接层,由 `auth.type: "chatgpt"` 显式启用。
|
|
|
58
58
|
|
|
59
59
|
搜索请求的 `model` 原样透传:真实订阅探测已接受 Claude、DeepSeek 和一个合成模型别名,没有依据强制替换为固定 GPT 名称。bridge 同样保留 `id`、commands、上下文、设置、结果及未知字段,只处理现有 HTTP 与鉴权边界。固定搜索连接让切换工作模型后仍可沿用服务端引用;远端状态的期限与账号切换行为由上游决定。失败保持原状,客户端决定如何处理。[配置、协议与验证范围](web-search.md)
|
|
60
60
|
|
|
61
|
+
## 图片接口复用客户端工具
|
|
62
|
+
|
|
63
|
+
用户选择纯配置启用 codeks 原生图片工具:`image_generation.upstream` 选择订阅连接,片段设置 `features.image_generation = true` 与 provider 的 `requires_openai_auth = true`,保留 bridge 入口 token。已有 `codex login` 的同机使用无需额外源码补丁;代价是每个客户端仍需本地登录,工具可用性受该账号状态和模型图片输入能力影响,即使 bridge 实际使用另一份订阅凭据。
|
|
64
|
+
|
|
65
|
+
图片生成和编辑是独立 JSON 接口,返回图片字节。bridge 只转发两条图片路由并记录 Inspector,由 codeks 负责输入文件、生成参数、保存结果和工具回传;无需图片模型目录、GPT 推理会话或独立图片状态存储。图像 `background` 与 Responses 后台任务不是同一语义,入口按独立协议处理。生成和编辑分别使用客户端路径,原样保留请求、错误及用量;图片 usage 留在本次独立记录,不并入后续推理。[配置、协议与验证](image-generation.md)
|
|
66
|
+
|
|
61
67
|
## 历史保存事实,配置决定恢复
|
|
62
68
|
|
|
63
69
|
Reasoning 载荷记录来源、格式和原始数据;压缩载荷保存文字摘要及可选原生状态,或保存原生状态与按需复述配方。它们写入 Responses item 的 `encrypted_content`,由 codeks 原样持久化。bridge 不维护完整会话或响应 ID 索引;按需复述的成功结果及独立 usage 另存本地文件缓存,避免重复付费和服务重启后重复生成。
|
|
@@ -98,7 +104,7 @@ GPT 原生 HTTP 失败保留 status、body 和诊断 header,流内失败保留
|
|
|
98
104
|
|
|
99
105
|
## 调试捕获只观察
|
|
100
106
|
|
|
101
|
-
[检查器](inspect.md)记录 bridge
|
|
107
|
+
[检查器](inspect.md)记录 bridge 真正收发的模型、独立搜索和图片请求字节,不重新构造请求。入口请求在解析前保存原文;这些上游请求都经过 `upstreamFetch`,在这里保存实际发送的 JSON 和逐块到达的响应;写回 codeks 的内容在 `writeHead`/`write`/`end` 处记录。每条请求在 AsyncLocalStorage 中持有自己的记录,上游调用按用途附加 `main`、`summary`、`native`、`handoff`、`search` 或 `image_generation` 标签,因此并发会话和子代理不会混在一起,后端代码不需要传递捕获参数。需要生成文字摘要时,`handoff` 先完成,再执行目标调用;命中摘要缓存时没有辅助上游调用。客户端响应只报告对应 main、summary 或 native 调用的 usage;handoff 用量留在缓存与独立上游记录,避免把辅助消耗当作客户端当前上下文。OAuth 刷新正文含凭据,不进入模型调用捕获;401 与其后的请求重发分别保留记录。
|
|
102
108
|
|
|
103
109
|
服务端保存完整正文,折叠、截断和格式化都在页面完成,避免字段白名单遗漏协议新增内容。状态标注调用与 `prepareHistory` 相同的回放判断函数,显示的决定不会与实际转换分叉。页面是零依赖的静态文件,和运行时一样不引入第三方包。捕获关闭时不保存任何内容,每条请求只多一个 AsyncLocalStorage 作用域。
|
|
104
110
|
|
package/docs/embedding.md
CHANGED
|
@@ -26,9 +26,9 @@ server.listen(8123, "127.0.0.1");
|
|
|
26
26
|
|
|
27
27
|
| 选项 | 调用边界 |
|
|
28
28
|
| --- | --- |
|
|
29
|
-
| `transformRequest(request, { headers })` | 仅处理 `/responses`:入口鉴权与 JSON 解析之后、模型路由和历史转换之前,主请求调用一次。可原位修改并返回 `void`,也可返回替换请求,支持 Promise。`headers` 是该请求的 HTTP headers
|
|
30
|
-
| `fetch` | 与标准 `fetch`
|
|
31
|
-
| `onResponseEvent(request, event)` | 仅观察 `/responses` 主响应实际提交的标准 Responses 事件;`request` 是变换后的请求。缓冲后因失败丢弃的工具事件、辅助请求和 keepalive 不进入观察器。非流式 Responses 请求也产生同样的语义事件,其中每个已提交输出项有一次 `response.output_item.done
|
|
29
|
+
| `transformRequest(request, { headers })` | 仅处理 `/responses`:入口鉴权与 JSON 解析之后、模型路由和历史转换之前,主请求调用一次。可原位修改并返回 `void`,也可返回替换请求,支持 Promise。`headers` 是该请求的 HTTP headers。辅助压缩和按需复述不会再次调用它;独立搜索和图片请求不调用它。 |
|
|
30
|
+
| `fetch` | 与标准 `fetch` 签名相同,承接全部模型请求,包括压缩、委托压缩及按需复述,以及已启用的独立搜索、图片请求和 ChatGPT OAuth 刷新。可接入宿主的代理、凭据和传输策略;须保留每次调用传入的取消信号并返回标准 `Response`。 |
|
|
31
|
+
| `onResponseEvent(request, event)` | 仅观察 `/responses` 主响应实际提交的标准 Responses 事件;`request` 是变换后的请求。缓冲后因失败丢弃的工具事件、辅助请求和 keepalive 不进入观察器。非流式 Responses 请求也产生同样的语义事件,其中每个已提交输出项有一次 `response.output_item.done`;独立搜索和图片请求直接返回原始 JSON,不调用此观察器。 |
|
|
32
32
|
|
|
33
33
|
观察器应只读取参数,不修改请求或事件,也不返回 Promise。它在事件写出后同步执行;抛出的异常会进入现有请求错误处理,并停止该请求的后续观察,已经写出的事件无法撤回。如果交付终止错误时观察器自身抛错,bridge 关闭当前响应连接,不再尝试发送第二个错误;其他请求仍可继续。请求结束时取消仍在进行的模型调用,普通重试由客户端或宿主决定。原始上游帧及辅助调用的调试使用[检查器](inspect.md)。
|
|
34
34
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# 订阅图片生成与编辑
|
|
2
|
+
|
|
3
|
+
`image_generation: { "upstream": "chatgpt" }` 让支持图片输入的工作模型共用指定订阅连接的图片生成、编辑能力。连接使用 `auth.type: "chatgpt"`,省略配置时关闭;它与 `web_search` 分别配置,可以共用同一连接。完整配置见 [ChatGPT+Claude 示例](../examples/chatgpt-claude.json)。
|
|
4
|
+
|
|
5
|
+
## 客户端配置与登录
|
|
6
|
+
|
|
7
|
+
重新运行 `config-snippet` 并合并到 codeks 配置,关键项为:
|
|
8
|
+
|
|
9
|
+
```toml
|
|
10
|
+
[features]
|
|
11
|
+
image_generation = true
|
|
12
|
+
|
|
13
|
+
[model_providers.bridge]
|
|
14
|
+
requires_openai_auth = true
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
每个 codeks 客户端都需要自己的有效 ChatGPT 登录,可运行 `codex login`。当前客户端根据本地登录状态决定是否显示 `image_gen.imagegen`:Free 账号和纯文本模型不会获得该工具。bridge 进程还需能读取所选订阅连接的文件登录;同机默认配置通常复用同一份 `~/.codex/auth.json`。
|
|
18
|
+
|
|
19
|
+
bridge token 与订阅凭据仍分开。片段保留 `env_key` 或 `experimental_bearer_token`,codeks 用它连接 bridge;bridge 再读取所选连接的 token 与账号 ID 调用图片接口,并复用已有续期和 HTTP 401 恢复逻辑。客户端本地登录用于工具启用判断,不要求把该凭据作为 bridge token。两端可以使用不同账号,但客户端仍受自己登录状态的门槛影响。见[订阅鉴权](backends-responses.md#订阅凭据与续期)。
|
|
20
|
+
|
|
21
|
+
用户选择这条配置路径,是因为同机自用已有 `codex login`,无需为工具启用条件增加 codeks 源码补丁。代价是仅在 bridge 服务器保存登录、客户端没有登录时,工具仍不会出现。
|
|
22
|
+
|
|
23
|
+
## 独立图片协议
|
|
24
|
+
|
|
25
|
+
工作模型调用原生 `image_gen.imagegen` 后,codeks 发出独立 JSON 请求:
|
|
26
|
+
|
|
27
|
+
| 操作 | bridge 路径 | 上游路径 |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| 生成 | `POST /v1/images/generations` | `<base_url>/images/generations` |
|
|
30
|
+
| 编辑 | `POST /v1/images/edits` | `<base_url>/images/edits` |
|
|
31
|
+
|
|
32
|
+
bridge 也接受没有 `/v1` 前缀的这两个路径。图片请求按 `image_generation.upstream` 选路,不按 `models` 查找,也不经过推理 adapter、reasoning 筛选或压缩。工作模型和连接的推理 `options` 不注入图片请求。
|
|
33
|
+
|
|
34
|
+
Codex `0.164.0` 使用固定图片模型 `gpt-image-2`,默认 `quality: "auto"`、`size: "auto"`,由工具参数决定背景是否透明。这些值来自客户端,bridge 原样转发;无需再建立图片模型目录或 GPT 推理别名。生成请求包含 prompt,编辑请求另带所选图片,不发送完整会话历史。
|
|
35
|
+
|
|
36
|
+
编辑同样使用 JSON。codeks 可读取 `referenced_image_paths` 中的本地文件,转换成 data URL;也可用 `num_last_images_to_include` 选择最近的 1–5 张会话图片,两种选择方式互斥。默认客户端附件存储使用内联图片;宿主自定义远端附件存储时,`file_id` 也会原样传递,其所属账号和有效性由上游判断。
|
|
37
|
+
|
|
38
|
+
图片协议中的 `background` 是背景选项,不是 Responses 的后台任务开关。bridge 仅检查独立请求所需的 JSON 形状,保留其他字段,以及 `x-codex-image-turn-id` 等诊断 header;传输和凭据使用现有[转发边界](responses-stream.md#header-与转发边界)。
|
|
39
|
+
|
|
40
|
+
## 结果、用量与失败
|
|
41
|
+
|
|
42
|
+
上游返回完整 JSON,其中 `data[].b64_json` 是图片内容,可另带 `generation_id`、`usage` 和未知字段。bridge 保留正文、HTTP 状态与 header。codeks 负责图片保存、UI 事件和普通工具结果;Code Mode 可通过 `generatedImage(result)` 输出结果。返回后工作模型可读取图片继续处理,不依赖 GPT 私有密文或原推理会话。
|
|
43
|
+
|
|
44
|
+
当前 codeks 保存到 `$CODEX_HOME/generated_images/<thread>/<call>.png`,使用第一张输出图片。工具结果包含图片与保存路径提示。客户端行为依据 Codex `rust-v0.164.0` 的 [ImagesClient](https://github.com/openai/codex/blob/rust-v0.164.0/codex-rs/codex-api/src/endpoint/images.rs)、[图片工具](https://github.com/openai/codex/blob/rust-v0.164.0/codex-rs/ext/image-generation/src/tool.rs)和[工具启用条件](https://github.com/openai/codex/blob/rust-v0.164.0/codex-rs/core/src/tools/spec_plan.rs);升级时应复核这些边界。
|
|
45
|
+
|
|
46
|
+
上游错误直接交回 codeks,不由 bridge 自动更换来源或重试生成。图片失败走客户端工具错误路径;凭据过期时仅复用一次 HTTP 401 恢复。请求体上限沿用 `request_max_mib`,等待时间沿用订阅连接的 `headers_timeout_ms` 与 `stream_idle_timeout_ms`。客户端断开会取消 bridge 的请求,但已开始的远端作业不保证立即停止或退还额度。
|
|
47
|
+
|
|
48
|
+
[Inspector](inspect.md) 以 `image_generation` 记录生成和编辑请求,保留 prompt、图片、实际订阅连接、诊断信息及上游报告的 usage。图片用量不累加到下一次普通推理响应。图片 JSON/base64 与其他正文一样完整捕获,受现有内存软上限管理。
|
|
49
|
+
|
|
50
|
+
## 验证范围
|
|
51
|
+
|
|
52
|
+
开发调查直接调用订阅图片端点,使用 codeks 同形状的 `gpt-image-2` 请求:生成白底蓝色圆形,再用返回图片编辑为绿色,两次均 HTTP 200,分别约 12 秒、13 秒。返回完整 PNG、`generation_id`、usage 与 `x-codex-imagegen-request-id`,没有先建立 Responses 会话。这里只验证两种接口及图片可独立使用,不评估复杂生成质量或额度。
|
|
53
|
+
|
|
54
|
+
另用真实 codeks `0.164.0` 二进制、合成登录和本地模拟上游验证工具门槛:开启 feature 但没有 provider 登录声明时工具不可见;加入 `requires_openai_auth` 与非 Free 登录后,静态目录和动态目录均可生成图片,并将图片带入下一次模型请求。动态目录覆盖仅登录、显式 bearer token 和 `env_key` 三种入口鉴权配置;纯文本模型仍不暴露图片工具。该项没有调用真实推理模型。
|
|
55
|
+
|
|
56
|
+
[客户端联动测试](../test/image-generation-e2e.test.ts)使用生成的配置片段,覆盖静态及动态目录,分别验证 Claude、DeepSeek 的 Code Mode 生成 → 保存 PNG → 读取保存路径编辑 → 新图片回到模型历史;客户端与 bridge 使用不同的合成订阅账号,并验证普通推理请求不携带本地订阅账号信息。另验证图片 HTTP 400 作为工具错误返回模型,bridge 只发出一次图片请求。这些测试使用真实 codeks,模型与图片上游均为模拟服务。
|
|
57
|
+
|
|
58
|
+
实际 bridge HTTP 转发另完成一次订阅编辑请求:发送已有蓝色圆形图片,要求改为橙色,约 13 秒返回 HTTP 200 和约 1.37 MB PNG。Inspector 记录一次图片上游调用,usage、图片正文和请求 ID 与实际响应一致。真实凭据、原始响应和图片留在仓库外;公开测试仅含合成数据。
|
package/docs/inspect.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# 调试检查器
|
|
2
2
|
|
|
3
|
-
检查器是 bridge 内置的网页,用来确认一条请求在 bridge 里实际经过了什么转换。打开捕获后,每条 `POST /v1/responses
|
|
3
|
+
检查器是 bridge 内置的网页,用来确认一条请求在 bridge 里实际经过了什么转换。打开捕获后,每条 `POST /v1/responses`,或已启用的 `/v1/alpha/search`、`/v1/images/generations`、`/v1/images/edits` POST 请求,记录为一次交换(exchange),包含四段原始内容:
|
|
4
4
|
|
|
5
5
|
1. codeks 发给 bridge 的请求;
|
|
6
6
|
2. bridge 发给上游的每个请求;
|
|
7
7
|
3. 上游返回的原始响应,含 SSE 事件和到达时间;
|
|
8
8
|
4. bridge 写回 codeks 的响应。
|
|
9
9
|
|
|
10
|
-
普通轮次使用上游调用 `main`,独立搜索使用 `search`。搜索记录保留原始 JSON
|
|
10
|
+
普通轮次使用上游调用 `main`,独立搜索使用 `search`。搜索记录保留原始 JSON 请求和响应,可核对实际订阅连接、请求模型与引用。图片生成与编辑使用 `image_generation`,记录 prompt、图片模型和所选订阅连接,具体操作可从请求路径区分。压缩请求按模式使用文字摘要调用 `summary` 或原生调用 `native`。委托压缩仍标为 `native` 或 `summary`,上游请求中的模型和连接来自实际执行别名。请求需要按需复述且缓存尚无结果时,先执行 `handoff`,成功后再执行目标调用;命中缓存时不产生这条辅助调用。路由前失败的请求(例如 JSON 无效或模型别名未知)没有上游调用,只有前后两段。
|
|
11
11
|
|
|
12
12
|
## 打开
|
|
13
13
|
|
|
@@ -41,9 +41,9 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
41
41
|
|
|
42
42
|
## 使用页面
|
|
43
43
|
|
|
44
|
-
左侧列表每行是一次交换,显示开始时间、模型别名和 adapter
|
|
44
|
+
左侧列表每行是一次交换,显示开始时间、模型别名和 adapter、类型(轮次、压缩、搜索或图片生成)、每个上游调用的状态、token 用量、子代理与父线程标记和预览。顶部可以按文字筛选(按 `/` 聚焦),或只看错误、压缩、进行中的交换;“按线程分组”把同一线程的请求放在一起。`↑`/`↓` 切换选中项。列表每 1.5 秒刷新,标签页隐藏时暂停。
|
|
45
45
|
|
|
46
|
-
右侧顶部的卡片按数据流排列:① codeks → bridge,② bridge → 上游,③ 上游 → bridge,④ bridge → codeks。每个实际上游调用各占一行,并显示 `main`、`summary`、`native`、`handoff` 或 `
|
|
46
|
+
右侧顶部的卡片按数据流排列:① codeks → bridge,② bridge → 上游,③ 上游 → bridge,④ bridge → codeks。每个实际上游调用各占一行,并显示 `main`、`summary`、`native`、`handoff`、`search` 或 `image_generation` 标签。点击卡片查看这一段的正文,Shift+点击在右侧并排打开第二段。每段正文有几种视图:
|
|
47
47
|
|
|
48
48
|
| 视图 | 内容 |
|
|
49
49
|
| --- | --- |
|
|
@@ -55,9 +55,9 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
55
55
|
|
|
56
56
|
大内容只在显示时折叠,记录本身完整。长字符串显示开头和结尾,中间注明省略的字符数,可以展开全部、复制或下载;`cxbr1:` 与 `cxbc1:` 载荷可以直接解码。很长的列表分批显示,可以继续加载。Responses Lite 的终止事件可能省略完整 `output`;结构视图会用之前的 `response.output_item.done` 还原输出,原始事件保持不变。
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
模型请求的列表和详情顶部 token 用量取自写回 codeks 的响应,只代表该次 main、summary 或 native 调用。handoff 的独立 usage 可在它的上游响应中查看:SSE 事件、结构或 JSON 视图保留原始字段,不累加进客户端用量。缓存命中不产生新的 handoff 调用,也不重复展示为本次消耗。搜索与图片请求保留上游原始响应及其 usage;图片用量只属于本次独立调用,不累加到后续推理。检查器没有跨调用的计费总额;上游没有报告的字段不能按零消耗理解。
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
“概要”给出实际执行模型的路由配置、每个调用的时间线和上游调用表;模型推理请求的客户端模型字段仍保留用户请求的工作别名;图片请求显示客户端指定的图片模型。“标注”列出全部回放决定,点击可定位到对应项。“对比”选择任意两次交换的任意一段做结构比较,常用的是和同一线程上一轮的客户端请求或上游请求比较;数组按类型和角色对齐,新增、删除的项单独标出。
|
|
61
61
|
|
|
62
62
|
概要中的“流式内容延迟”直接从已有 SSE 捕获派生,不增加请求或修改原始记录:
|
|
63
63
|
|
|
@@ -93,7 +93,7 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
93
93
|
| `cancelled` | 客户端断开;仍在进行的上游调用随之标记为 `cancelled` |
|
|
94
94
|
| `error` | 传输出错,`error` 字段给出原因 |
|
|
95
95
|
|
|
96
|
-
交换的 `outcome` 来自写回 codeks 的内容:流式响应取最后一个终止事件(`response.completed`、`response.incomplete`、`response.failed`、`error`),非流式 Responses 响应取 JSON 的 `status
|
|
96
|
+
交换的 `outcome` 来自写回 codeks 的内容:流式响应取最后一个终止事件(`response.completed`、`response.incomplete`、`response.failed`、`error`),非流式 Responses 响应取 JSON 的 `status`,独立搜索和图片等普通 JSON 响应按 HTTP 状态判断。客户端断开为 `aborted`;没有写出响应或流没有终止事件时为 `error`。
|
|
97
97
|
|
|
98
98
|
## 状态标注
|
|
99
99
|
|
|
@@ -114,7 +114,7 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
114
114
|
| compaction | `summary` / `handoff` | `source_not_allowed` | 原生检查点来源不在允许列表 |
|
|
115
115
|
| compaction | `summary` / `handoff` | `format_mismatch` | 原生检查点格式与当前 adapter 不同 |
|
|
116
116
|
|
|
117
|
-
`summary`
|
|
117
|
+
`summary` 表示直接使用载荷中已有的文字。`no_native` 的标注显示“压缩 · 使用文字摘要”:这种检查点只保存摘要,没有原生来源信息,是正常的文字压缩。无法识别的原始密文仍标为 `unrecognized_state`,按配置透传、过滤或拒绝。`handoff` 表示先取得文字交接:可以复用本地缓存,也可以向原来源生成。只有实际发起辅助请求时,上游调用列表才出现 `handoff`;这条状态标注本身不表示发生了额外 HTTP 请求。
|
|
118
118
|
|
|
119
119
|
响应侧标注 bridge 新生成的 reasoning 与压缩项(决定为 `output`)。流式响应指向 `response.output_item.done` 事件里的 `/item`,非流式响应指向 `/output/k`。只有文字摘要的压缩项没有原生部分,来源和格式为空;`native` 检查点的来源和格式取原生部分。
|
|
120
120
|
|
|
@@ -153,4 +153,4 @@ codeks-bridge serve --config /absolute/path/bridge.json --capture
|
|
|
153
153
|
|
|
154
154
|
交换 id 是不透明字符串,只用于查询。
|
|
155
155
|
|
|
156
|
-
摘要里的 `thread` 取自 codeks 的请求 header:`session-id`、`thread-id`、`x-codex-parent-thread-id`、`x-openai-subagent` 和 `x-codex-window-id`。子代理请求带父线程 id 和子代理类型,可以据此把父子请求对应起来。`preview` 取最后一条用户消息;子代理请求取最后一条 `agent_message
|
|
156
|
+
摘要里的 `thread` 取自 codeks 的请求 header:`session-id`、`thread-id`、`x-codex-parent-thread-id`、`x-openai-subagent` 和 `x-codex-window-id`。子代理请求带父线程 id 和子代理类型,可以据此把父子请求对应起来。`preview` 取最后一条用户消息;子代理请求取最后一条 `agent_message`,也就是父代理发来的任务;图片请求取 `prompt`。
|
package/docs/tools.md
CHANGED
|
@@ -23,7 +23,7 @@ Claude 的 `adapters.claude-messages.tool_updates` 有两种明确模式:
|
|
|
23
23
|
|
|
24
24
|
`supports_search_tool` 表示客户端的工具发现能力,与网页搜索不同。当前源目录的 GPT 条目显式设为 `true`,bridge 保留它。是否出现独立 `tool_search` 还取决于客户端工具模式和功能开关,不能只从目录字段推断。
|
|
25
25
|
|
|
26
|
-
当前目录采用 Code Mode Only:大多数工具通过 `exec` 中的函数调用,模型从 `ALL_TOOLS` 读取目录;外层不会因此增加一个独立搜索工具。网页搜索由客户端 `web_search` 配置和 provider 能力控制;启用[订阅搜索](web-search.md)后,`web.run`
|
|
26
|
+
当前目录采用 Code Mode Only:大多数工具通过 `exec` 中的函数调用,模型从 `ALL_TOOLS` 读取目录;外层不会因此增加一个独立搜索工具。网页搜索由客户端 `web_search` 配置和 provider 能力控制;启用[订阅搜索](web-search.md)后,`web.run` 的明文结果通过普通工具结果路径返回各模型。[图片生成与编辑](image-generation.md)使用客户端 `image_gen.imagegen` 工具及独立图片接口,同样不通过 `supports_search_tool` 控制。
|
|
27
27
|
|
|
28
28
|
## 名字
|
|
29
29
|
|
package/package.json
CHANGED
package/ui/labels.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { h, kvTable, shortId, strBlock, put } from './dom.js';
|
|
3
3
|
import { jsonTree } from './tree.js';
|
|
4
4
|
|
|
5
|
-
export const CALL_LABEL = { main: '主请求', summary: '压缩·文字摘要', native: '压缩·原生', handoff: '压缩·交接复述', search: '独立搜索' };
|
|
5
|
+
export const CALL_LABEL = { main: '主请求', summary: '压缩·文字摘要', native: '压缩·原生', handoff: '压缩·交接复述', search: '独立搜索', image_generation: '图片生成' };
|
|
6
6
|
export const callLabel = (l) => CALL_LABEL[l] ?? l;
|
|
7
7
|
|
|
8
8
|
export const INPUT_TRANSFORMATION_LABEL = {
|
|
@@ -10,14 +10,14 @@ export const INPUT_TRANSFORMATION_LABEL = {
|
|
|
10
10
|
thinking_mismatch_allowed: '允许失配,保留 thinking',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export const KIND_LABEL = { turn: '轮次', compaction: '压缩', search: '独立搜索', invalid: '无效' };
|
|
13
|
+
export const KIND_LABEL = { turn: '轮次', compaction: '压缩', search: '独立搜索', image_generation: '图片生成', invalid: '无效' };
|
|
14
14
|
export const OUTCOME_LABEL = { active: '进行中', completed: '完成', incomplete: '未完成', failed: '失败', error: '错误', aborted: '中止' };
|
|
15
15
|
export const END_LABEL = { active: '传输中', complete: '完整', cancelled: '已取消', error: '出错', unread: '终止事件后停止读取' };
|
|
16
16
|
|
|
17
17
|
const DECISION = { replay: '回放', passthrough: '原样透传', drop: '丢弃', native: '恢复原生', summary: '文字摘要', handoff: '按需文字交接', reject: '拒绝', output: '输出' };
|
|
18
18
|
const DECISION_CLASS = { replay: 'ok', passthrough: 'info', native: 'ok', drop: 'warn', summary: 'warn', handoff: 'warn', reject: 'bad', output: 'info' };
|
|
19
19
|
// Verb shown before the reason text, per decision.
|
|
20
|
-
const VERB = { replay: '回放', passthrough: '原样透传', drop: '丢弃', reject: '拒绝', summary: '
|
|
20
|
+
const VERB = { replay: '回放', passthrough: '原样透传', drop: '丢弃', reject: '拒绝', summary: '使用文字摘要', handoff: '获取文字交接', native: '恢复原生压缩' };
|
|
21
21
|
|
|
22
22
|
const REASON = {
|
|
23
23
|
reasoning: {
|
|
@@ -29,7 +29,7 @@ const REASON = {
|
|
|
29
29
|
},
|
|
30
30
|
compaction: {
|
|
31
31
|
native_restored: '',
|
|
32
|
-
no_native: '
|
|
32
|
+
no_native: '',
|
|
33
33
|
native_replay_disabled: '目标关闭了 native_replay',
|
|
34
34
|
source_not_allowed: '来源未在原生压缩白名单',
|
|
35
35
|
format_mismatch: '原生格式与目标不匹配',
|
|
@@ -57,7 +57,9 @@ export function sourceText(src) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export function annChip(a, onClick) {
|
|
60
|
-
const
|
|
60
|
+
const source = a.source ? sourceText(a.source)
|
|
61
|
+
: (a.decision === 'output' || (a.kind === 'compaction' && a.reason === 'no_native') ? null : '来源未知');
|
|
62
|
+
const parts = [KIND_TEXT[a.kind] ?? a.kind, source, reasonText(a)].filter(Boolean);
|
|
61
63
|
return h('span', {
|
|
62
64
|
class: `chip ann ${decisionClass(a.decision)}${onClick ? ' click' : ''}`,
|
|
63
65
|
title: `${a.target}${a.event != null ? ` 事件 #${a.event}` : ''} ${a.pointer ?? ''}\n原因代码:${a.reason}\n格式:${a.format ?? '–'}`,
|