@qwen-code/arena-agent 0.0.10-dev.15 → 0.0.10-dev.16
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/.env.example +25 -3
- package/CHANGELOG.md +23 -1
- package/README.md +80 -26
- package/dist/agent.d.ts +5 -1
- package/dist/agent.js +99 -28
- package/dist/agent.js.map +1 -1
- package/dist/arena-history.d.ts +12 -0
- package/dist/arena-history.js +119 -0
- package/dist/arena-history.js.map +1 -0
- package/dist/brave-search.js +7 -4
- package/dist/brave-search.js.map +1 -1
- package/dist/canonical-data.d.ts +7 -0
- package/dist/canonical-data.js +10 -3
- package/dist/canonical-data.js.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/code-cli.js +0 -0
- package/dist/code-tools.js +2 -4
- package/dist/code-tools.js.map +1 -1
- package/dist/compaction.d.ts +2 -0
- package/dist/compaction.js +6 -2
- package/dist/compaction.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/connector-errors.d.ts +16 -0
- package/dist/connector-errors.js +69 -0
- package/dist/connector-errors.js.map +1 -0
- package/dist/connector-files.d.ts +31 -0
- package/dist/connector-files.js +249 -0
- package/dist/connector-files.js.map +1 -0
- package/dist/connector-input.d.ts +10 -0
- package/dist/connector-input.js +79 -0
- package/dist/connector-input.js.map +1 -0
- package/dist/connector-mcp.d.ts +15 -2
- package/dist/connector-mcp.js +201 -41
- package/dist/connector-mcp.js.map +1 -1
- package/dist/connectors.d.ts +7 -2
- package/dist/connectors.js +42 -30
- package/dist/connectors.js.map +1 -1
- package/dist/fetch-page.js +2 -2
- package/dist/fetch-page.js.map +1 -1
- package/dist/history.d.ts +4 -2
- package/dist/history.js +4 -1
- package/dist/history.js.map +1 -1
- package/dist/image-choice.d.ts +23 -0
- package/dist/image-choice.js +190 -0
- package/dist/image-choice.js.map +1 -0
- package/dist/image-model.d.ts +6 -0
- package/dist/image-model.js +32 -0
- package/dist/image-model.js.map +1 -0
- package/dist/model-router-media.js +5 -3
- package/dist/model-router-media.js.map +1 -1
- package/dist/process-manager.js +9 -9
- package/dist/process-manager.js.map +1 -1
- package/dist/prompts.d.ts +0 -1
- package/dist/prompts.js +3 -27
- package/dist/prompts.js.map +1 -1
- package/dist/repo.d.ts +1 -1
- package/dist/repo.js +26 -4
- package/dist/repo.js.map +1 -1
- package/dist/routify-web-fetch.js +2 -2
- package/dist/routify-web-fetch.js.map +1 -1
- package/dist/server.js +24 -12
- package/dist/server.js.map +1 -1
- package/dist/session-memory-prompts.d.ts +2 -1
- package/dist/session-memory-prompts.js +2 -1
- package/dist/session-memory-prompts.js.map +1 -1
- package/dist/spec.d.ts +4 -4
- package/dist/spec.js +25 -12
- package/dist/spec.js.map +1 -1
- package/dist/startup-main-config.d.ts +1 -0
- package/dist/startup-main-config.js +1 -0
- package/dist/startup-main-config.js.map +1 -1
- package/dist/startup-tool-config.js +12 -2
- package/dist/startup-tool-config.js.map +1 -1
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +133 -49
- package/dist/tools.js.map +1 -1
- package/dist/tui.js +15 -2
- package/dist/tui.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/web/app.js +8 -0
- package/dist/web/app.js.map +1 -1
- package/package.json +1 -1
- package/web/styles.css +22 -0
- package/dist/code-arena-output.d.ts +0 -15
- package/dist/code-arena-output.js +0 -41
- package/dist/code-arena-output.js.map +0 -1
- package/dist/legacy-compaction.d.ts +0 -20
- package/dist/legacy-compaction.js +0 -209
- package/dist/legacy-compaction.js.map +0 -1
- package/dist/web/app.d.ts +0 -1
package/.env.example
CHANGED
|
@@ -68,11 +68,18 @@ ARENA_HARNESS_MODE=arena
|
|
|
68
68
|
# ARENA_TOOL_CHOICE=auto
|
|
69
69
|
# JSON array of exact tool names hidden from the model and rejected if called.
|
|
70
70
|
# ARENA_DISALLOWED_TOOLS=["bash","write_file"]
|
|
71
|
-
# Agent Arena connectors through Merge MCP
|
|
71
|
+
# Agent Arena connectors through Merge MCP; opt-in, ignored by Code Arena.
|
|
72
72
|
# Enable the captured catalog in the Tool Pack; connect apps for the Registered
|
|
73
73
|
# User through Merge Link. The key and user must belong to the same environment.
|
|
74
74
|
# One configured Registered User is shared by all sessions of this process.
|
|
75
|
-
#
|
|
75
|
+
# Slugs: notion, google_calendar, google_drive, google_docs, google_sheets,
|
|
76
|
+
# google_slides, gmail, dropbox, supabase, vercel, linear.
|
|
77
|
+
# ARENA_CONNECTORS=["notion","google_drive","google_docs","google_sheets"]
|
|
78
|
+
# Optional host-provided authenticated-app snapshot, separate from conversation
|
|
79
|
+
# enablement. This does not authorize apps or query Merge. Explicit [] enables
|
|
80
|
+
# discovery with the captured no-connected-apps prompt. Omit both arrays to keep
|
|
81
|
+
# the connector-off baseline.
|
|
82
|
+
# ARENA_CONNECTED_CONNECTORS=["notion","google_drive","google_docs","google_sheets","gmail"]
|
|
76
83
|
# ARENA_MERGE_ACCESS_KEY=
|
|
77
84
|
# ARENA_MERGE_TOOL_PACK_ID=
|
|
78
85
|
# ARENA_MERGE_REGISTERED_USER_ID=
|
|
@@ -161,6 +168,12 @@ ARENA_HARNESS_MODE=arena
|
|
|
161
168
|
|
|
162
169
|
# Search, page reading, image generation, and speech through ModelRouter/Routify.
|
|
163
170
|
ROUTIFY_API_KEY=
|
|
171
|
+
# Optional per-tool keys override ROUTIFY_API_KEY; unset or blank falls back.
|
|
172
|
+
# ROUTIFY_WEB_SEARCH_API_KEY=
|
|
173
|
+
# ROUTIFY_IMAGE_SEARCH_API_KEY=
|
|
174
|
+
# ROUTIFY_GENERATE_IMAGE_API_KEY=
|
|
175
|
+
# For an image proxy, keep the real MR key in ROUTIFY_API_KEY and set only
|
|
176
|
+
# ROUTIFY_GENERATE_IMAGE_API_KEY to the proxy key, with the base URL below.
|
|
164
177
|
# ROUTIFY_WEB_SEARCH_URL=https://routify-pub.alibaba-inc.com/protocol/compatible-mode/res/v1/llm/context
|
|
165
178
|
# ROUTIFY_IMAGE_SEARCH_URL=https://routify-pub.alibaba-inc.com/protocol/brave/res/v1/images/search
|
|
166
179
|
# ROUTIFY_VERTEX_BASE_URL=https://routify-pub.alibaba-inc.com/protocol/vertex/v1beta
|
|
@@ -172,8 +185,17 @@ ROUTIFY_API_KEY=
|
|
|
172
185
|
# Code Arena web_fetch content cap (UTF-8 bytes, including truncation notice).
|
|
173
186
|
# Applies to local and Routify readers in all formats; must be a positive integer.
|
|
174
187
|
# CODE_HARNESS_WEB_FETCH_MAX_BYTES=40000
|
|
175
|
-
#
|
|
188
|
+
# Agent Arena single images randomly use Gemini or gpt-image-2 by default.
|
|
189
|
+
# Set this variable to pin a model (also overrides option one).
|
|
190
|
+
# ARENA_IMAGE_MODEL=gpt-image-2
|
|
191
|
+
# Second model for Agent Arena generate_image with offer_options=true.
|
|
192
|
+
# Defaults to gpt-image-2 (or Gemini when that is the primary).
|
|
193
|
+
# Without a user handler, save option one and continue; otherwise ask the user.
|
|
194
|
+
# ARENA_IMAGE_ALTERNATIVE_MODEL=gpt-image-2
|
|
176
195
|
# ARENA_IMAGE_SIZE=1024*1024
|
|
196
|
+
# Code Arena randomly uses Sunburst or Flare.
|
|
197
|
+
# Set this variable to pin a model; otherwise an explicit ARENA_IMAGE_MODEL
|
|
198
|
+
# also pins Code Arena. Grok and Muse are not enabled.
|
|
177
199
|
# CODE_HARNESS_IMAGE_MODEL=gpt-image-2.5-sunburst
|
|
178
200
|
# CODE_HARNESS_IMAGE_SIZE=1024*1024
|
|
179
201
|
# ARENA_SPEECH_MODEL=gemini-3.1-flash-tts-preview
|
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,27 @@
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [0.0.10-dev.16] - 2026-11-04
|
|
16
|
+
|
|
17
|
+
### Agent Arena
|
|
18
|
+
|
|
19
|
+
- Repo 会话记住目标仓库,新增同级仓库后仍可继续和恢复;目标缺失或 Git 状态异常时明确报错。
|
|
20
|
+
- 对齐近期日志中的工作区、Repo 和记忆提示词,以及已有工具的声明顺序。
|
|
21
|
+
- `read_file` 支持 `offset`、`limit` 分页;`bash` 超时返回已有输出并允许命令继续运行,主动取消仍终止进程树。
|
|
22
|
+
- 对齐工具参数的默认值、实时与恢复历史格式,以及同批工具并发执行和结果顺序。
|
|
23
|
+
- 扩展 MCP 应用至 Google Drive、Docs、Sheets、Slides、Gmail、Dropbox、Supabase、Vercel 和 Linear,并对齐 Notion 工具、工作区文件传输及重复调用保护。
|
|
24
|
+
- 新增 `ARENA_CONNECTED_CONNECTORS`,区分已连接但未开启和未连接的应用。
|
|
25
|
+
- `generate_image` 单图默认随机使用 GPT Image 2 或 Gemini 3.1 Flash,`offer_options` 并行生成双图供选择,保存未选图片并支持中断后重试;第二模型可用 `ARENA_IMAGE_ALTERNATIVE_MODEL` 配置。
|
|
26
|
+
- Headless 未配置用户 handler 时,`generate_image` 的 `offer_options=true` 默认保存第一张候选图并继续执行。
|
|
27
|
+
|
|
28
|
+
### Code Arena
|
|
29
|
+
|
|
30
|
+
- `generate_image` 默认随机使用 `gpt-image-2.5-sunburst` 或 `gpt-image-2.5-flare`。
|
|
31
|
+
|
|
32
|
+
### 通用
|
|
33
|
+
|
|
34
|
+
- 新增 `ROUTIFY_WEB_SEARCH_API_KEY`、`ROUTIFY_IMAGE_SEARCH_API_KEY`、`ROUTIFY_GENERATE_IMAGE_API_KEY`,支持搜索与生图独立密钥,未设置或留空时继续使用 `ROUTIFY_API_KEY`。
|
|
35
|
+
|
|
15
36
|
## [0.0.10-dev.15] - 2026-10-28
|
|
16
37
|
|
|
17
38
|
### Agent Arena
|
|
@@ -279,7 +300,8 @@
|
|
|
279
300
|
- `bash` 用于一次性命令,区分超时与信号终止,并清理遗留后台进程;需要持续运行
|
|
280
301
|
的任务改用进程工具。预览端口支持 E2B Host 探测及按需返回告警。
|
|
281
302
|
|
|
282
|
-
[Unreleased]: https://code.alibaba-inc.com/know-how/arena-harness/compare?from=v0.0.10-dev.
|
|
303
|
+
[Unreleased]: https://code.alibaba-inc.com/know-how/arena-harness/compare?from=v0.0.10-dev.16&to=master&mergeBase=true
|
|
304
|
+
[0.0.10-dev.16]: https://code.alibaba-inc.com/know-how/arena-harness/compare?from=v0.0.10-dev.15&to=v0.0.10-dev.16&mergeBase=true
|
|
283
305
|
[0.0.10-dev.15]: https://code.alibaba-inc.com/know-how/arena-harness/compare?from=v0.0.10-dev.14&to=v0.0.10-dev.15&mergeBase=true
|
|
284
306
|
[0.0.10-dev.14]: https://code.alibaba-inc.com/know-how/arena-harness/compare?from=v0.0.10-dev.13&to=v0.0.10-dev.14&mergeBase=true
|
|
285
307
|
[0.0.10-dev.13]: https://code.alibaba-inc.com/know-how/arena-harness/compare?from=v0.0.10-dev.12&to=v0.0.10-dev.13&mergeBase=true
|
package/README.md
CHANGED
|
@@ -263,8 +263,11 @@ arena serve --system-prompt '只使用中文回复。'
|
|
|
263
263
|
history.json、增量日志和返回的 messages 只保存对话历史(含 compaction),不保存运行时生成的开头 system;中途出现的 system 消息会保留。
|
|
264
264
|
新会话和续跑均在构建模型请求时前置运行时 system;官方以 user 开头的历史可直接续跑。
|
|
265
265
|
旧版带开头 system 的本地历史仍可读取,该旧前缀不作为本次指令,后续写入会移除它。
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
Agent Arena 在尚未选定仓库时,沿用“工作区根不是 Git 仓库,且仅有一个直接子仓库”的自动识别规则。
|
|
267
|
+
成功识别后,会话记住该子仓库的相对路径;新消息、`--continue`、TUI 和服务端恢复均沿用该目标,
|
|
268
|
+
新增同级仓库不会使会话退出 Repo 模式。普通会话后续出现首个可识别仓库时仍可自动进入 Repo 模式。
|
|
269
|
+
每次运行仍从当前 Git 状态刷新分支(包括 `arena/...`)、远端和基准提交,不复用旧 system 中的信息。
|
|
270
|
+
已绑定仓库缺失或 Git 状态无法解析时明确报错,不会静默换仓库或模式。旧历史没有绑定信息时仍按原规则识别。
|
|
268
271
|
|
|
269
272
|
如需保留当前 mode 生成的 system prompt,只在末尾追加任务或部署指令,可传入
|
|
270
273
|
`--append-system-prompt <text>`:
|
|
@@ -416,29 +419,49 @@ ARENA_DISALLOWED_TOOLS=["bash","write_file"]
|
|
|
416
419
|
被禁用的工具不会发送给模型;即使模型仍构造了该工具调用,执行层也会
|
|
417
420
|
在产生副作用前拒绝。
|
|
418
421
|
|
|
419
|
-
Agent Arena 可通过 Merge MCP 调用 Notion
|
|
422
|
+
Agent Arena 可通过 Merge MCP 调用 Notion、Google Calendar、Google Drive、Docs、
|
|
423
|
+
Sheets、Slides、Gmail、Dropbox、Supabase 和 Vercel,应用范围由
|
|
420
424
|
`ARENA_CONNECTORS` JSON 数组控制。先在 Merge 创建 Tool Pack 和 Registered User,
|
|
421
425
|
让该用户通过 Merge Link 连接目标应用,再配置同一环境的 Access Key:
|
|
422
426
|
|
|
423
427
|
```sh
|
|
424
428
|
# 写入本地 .env;三个 Merge 值从自己的 Merge 环境取得。
|
|
425
|
-
ARENA_CONNECTORS='["notion","
|
|
429
|
+
ARENA_CONNECTORS='["notion","google_drive","google_docs","google_sheets"]'
|
|
426
430
|
ARENA_MERGE_ACCESS_KEY=...
|
|
427
431
|
ARENA_MERGE_TOOL_PACK_ID=...
|
|
428
432
|
ARENA_MERGE_REGISTERED_USER_ID=...
|
|
429
433
|
```
|
|
430
434
|
|
|
431
|
-
首次可运行 `arena -p '加载 Google
|
|
432
|
-
Tool Pack
|
|
435
|
+
首次可运行 `arena -p '加载 Google Drive 工具并最多列出一个文件,不要创建或修改文件'`。
|
|
436
|
+
Tool Pack 需启用所选应用的完整捕获目录,见
|
|
433
437
|
[目录源文件](spec/connectors/catalog.json)。缺少工具时会明确报错;上游新增的工具不会自动暴露给模型。
|
|
434
438
|
|
|
435
|
-
|
|
439
|
+
| 应用 slug | 工具数 | 模型参数定义 |
|
|
440
|
+
| --- | ---: | --- |
|
|
441
|
+
| `notion` | 22 | 历史完整捕获 |
|
|
442
|
+
| `google_drive` | 49 | 历史完整捕获 |
|
|
443
|
+
| `google_docs` | 46 | 历史完整捕获 |
|
|
444
|
+
| `google_sheets` | 56 | 历史完整捕获 |
|
|
445
|
+
| `google_slides` | 50 | 历史完整捕获 |
|
|
446
|
+
| `gmail` | 29 | 历史完整捕获 |
|
|
447
|
+
| `dropbox` | 33 | 历史完整捕获 |
|
|
448
|
+
| `supabase` | 42 | 历史完整捕获 |
|
|
449
|
+
| `vercel` | 53 | 历史完整捕获 |
|
|
450
|
+
| `linear` | 41 | 历史完整捕获 |
|
|
451
|
+
| `google_calendar` | 42 | 旧捕获目录与 Merge 实时 schema |
|
|
452
|
+
|
|
453
|
+
默认不启用应用。非空 `ARENA_CONNECTORS` 在基础工具集合中注册
|
|
436
454
|
`list_connector_tools`,并在普通/Repo 系统提示词末尾加入捕获的 `Connected apps`
|
|
437
|
-
|
|
455
|
+
段落,列出数组中的应用。接受上表中的 slug;重复项去重,
|
|
438
456
|
保留输入顺序,未知名称或非法 JSON 会在启动时报错。Code Arena 忽略此配置。
|
|
439
457
|
|
|
440
|
-
|
|
441
|
-
|
|
458
|
+
可选 `ARENA_CONNECTED_CONNECTORS` JSON 数组由宿主提供已连接应用的快照,用来区分
|
|
459
|
+
“已连接但未开启”和“未连接”。它不执行 OAuth,也不自动查询账号状态。未设置时按
|
|
460
|
+
`ARENA_CONNECTORS` 提供会话应用;显式 `[]` 可启用“尚无连接应用”的提示和发现入口。
|
|
461
|
+
两项均未设置时,基础提示词和工具集合保持原样。
|
|
462
|
+
|
|
463
|
+
模型调用 `list_connector_tools` 后,harness 才连接 Merge、校验后端目录并注册业务工具。
|
|
464
|
+
每条新用户消息都需要重新发现;暂停续跑恢复目录及重复调用保护,不重放已执行的操作。
|
|
442
465
|
数组表示本次会话允许哪些应用,加载目录成功也不保证账号具有全部读写权限。
|
|
443
466
|
缺少配置、授权失败或目录不完整时返回明确错误;业务调用按历史日志包装结果。
|
|
444
467
|
`ARENA_DISALLOWED_TOOLS` 禁用发现工具时也会省略应用提示词;显式 `--system-prompt`
|
|
@@ -449,18 +472,23 @@ Tool Pack 需启用所选应用的完整捕获目录:Notion 22 个、Calendar
|
|
|
449
472
|
已经完成写入,需先查询确认。当前一个进程使用一个 Registered User,Web 会话共用该账号;
|
|
450
473
|
尚未提供各 Web 用户独立登录和账号绑定界面。
|
|
451
474
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
475
|
+
Drive、Dropbox 上传及 Gmail 草稿附件使用 `input.file_path` 读取工作区文件;下载/导出
|
|
476
|
+
通过 Merge 文件接口落盘并返回文件路径。单文件上限为 100 MiB。同一回复中已完成或正在
|
|
477
|
+
执行的相同写调用、已失败的相同业务调用会被拦截;上传限流也会阻止该回复继续上传文件。
|
|
478
|
+
|
|
479
|
+
提示词、发现入口和十家应用的 421 个完整模型工具定义(含 Linear 的 41 个工具)保存在 `spec/connectors/`,
|
|
480
|
+
由构建脚本嵌入;后端要求的 nullable 字段和文件引用只在发送给 Merge 时转换。
|
|
481
|
+
Google Calendar 本批没有完整历史 schema,继续使用实时定义。
|
|
482
|
+
配置步骤及历史与真实后端的验证边界见 [Connector 接入分析](docs/research/AGENT_ARENA_CONNECTOR_BACKEND.md)。
|
|
457
483
|
|
|
458
484
|
`ARENA_EXTRA_BODY` 会在配置加载时解析为 JSON 对象,既作为最后一层请求
|
|
459
485
|
参数覆盖,也会原样写入 `history.json` 的
|
|
460
486
|
`metadata.parameters.extra_body`。
|
|
461
487
|
|
|
462
488
|
`ROUTIFY_API_KEY` 供 `web_search`、`image_search`、`generate_image` 和
|
|
463
|
-
`generate_speech`
|
|
489
|
+
`generate_speech` 使用。前三者分别支持 `ROUTIFY_WEB_SEARCH_API_KEY`、
|
|
490
|
+
`ROUTIFY_IMAGE_SEARCH_API_KEY`、`ROUTIFY_GENERATE_IMAGE_API_KEY` 独立覆盖;
|
|
491
|
+
未设置或留空(含纯空白)时回退到 `ROUTIFY_API_KEY`,旧配置无需修改。开启
|
|
464
492
|
`CODE_HARNESS_ROUTIFY_WEB_FETCH_ENABLED` 后,Arena 的 `fetch_page` 和 Code Arena 的
|
|
465
493
|
`web_fetch` 也复用该密钥,通过 Routify 先调用 Firecrawl,失败时回退到
|
|
466
494
|
Jina Reader。
|
|
@@ -1100,7 +1128,8 @@ watcher 或任务应使用 `start_process`;随后可用 `get_process_output`
|
|
|
1100
1128
|
保持普通捕获的结果 shape 不变。
|
|
1101
1129
|
|
|
1102
1130
|
`web_search` 使用 Routify 网关提供的 Brave LLM Context,从工作区 `.env`
|
|
1103
|
-
|
|
1131
|
+
优先读取 `ROUTIFY_WEB_SEARCH_API_KEY`,未设置或留空时读取 `ROUTIFY_API_KEY`,
|
|
1132
|
+
默认通过内置的 ModelRouter 兼容接口调用
|
|
1104
1133
|
`brave.llm-context` 路由。实现按 depth 请求最多 3/5/8 条结果,并将
|
|
1105
1134
|
`grounding.generic` 的内容片段及 `sources` 的来源信息转换成 Arena 的既有工具
|
|
1106
1135
|
结果。请求固定考虑最多 20 个搜索候选,再通过 `maximum_number_of_urls` 将
|
|
@@ -1111,8 +1140,9 @@ snippets,仅在没有 grounding 内容时回退到来源摘要。三个 Code A
|
|
|
1111
1140
|
token 预算 512/1280/1536。
|
|
1112
1141
|
可用 `ROUTIFY_WEB_SEARCH_URL` 和 `ARENA_WEB_SEARCH_MODEL` 覆盖默认值。
|
|
1113
1142
|
|
|
1114
|
-
`image_search` 使用 Routify 网关提供的 Brave Images Search
|
|
1115
|
-
`
|
|
1143
|
+
`image_search` 使用 Routify 网关提供的 Brave Images Search,优先读取
|
|
1144
|
+
`ROUTIFY_IMAGE_SEARCH_API_KEY`,未设置或留空时读取 `ROUTIFY_API_KEY`,
|
|
1145
|
+
通过 `X-Subscription-Token` 发送 GET 请求。默认使用内置的
|
|
1116
1146
|
ModelRouter 兼容接口,可用 `ROUTIFY_IMAGE_SEARCH_URL` 覆盖。实现优先下载 Brave
|
|
1117
1147
|
返回的原图地址,原图不可用
|
|
1118
1148
|
时回退到 Brave 代理缩略图,并保持既有工具结果格式和工作区文件命名不变。
|
|
@@ -1123,11 +1153,25 @@ Arena 的 `fetch_page` 和 Code Arena 的 `web_fetch` 默认仍使用本地抓
|
|
|
1123
1153
|
错误。`fetch_page` 仍按 8000 字符分块并缓存同一 URL 的后续 chunk。认证复用
|
|
1124
1154
|
`ROUTIFY_API_KEY`。
|
|
1125
1155
|
|
|
1126
|
-
`generate_image`、`generate_speech` 使用 ModelRouter/Routify
|
|
1127
|
-
|
|
1156
|
+
`generate_image`、`generate_speech` 使用 ModelRouter/Routify。图片生成优先读取
|
|
1157
|
+
`ROUTIFY_GENERATE_IMAGE_API_KEY`,未设置或留空时回退到 `ROUTIFY_API_KEY`;
|
|
1158
|
+
语音仍使用 `ROUTIFY_API_KEY`。GPT Image 图片生成与编辑使用 OpenAI 图片
|
|
1128
1159
|
协议,可用 `ROUTIFY_OPENAI_BASE_URL` 覆盖 ModelRouter 根地址。显式选择 Gemini
|
|
1129
1160
|
图片模型及默认 Gemini TTS 时使用 Google 协议,可用 `ROUTIFY_VERTEX_BASE_URL`
|
|
1130
|
-
|
|
1161
|
+
覆盖对应根地址。
|
|
1162
|
+
|
|
1163
|
+
例如,搜索直连 MR、GPT Image 生图走 proxy 时,可以在 `.env` 中配置:
|
|
1164
|
+
|
|
1165
|
+
```dotenv
|
|
1166
|
+
ROUTIFY_API_KEY=your-real-mr-key
|
|
1167
|
+
ROUTIFY_GENERATE_IMAGE_API_KEY=your-proxy-key
|
|
1168
|
+
ROUTIFY_OPENAI_BASE_URL=https://your-proxy.example/v1
|
|
1169
|
+
ARENA_IMAGE_MODEL=gpt-image-2
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
Gemini 生图使用同一个生图专用 key,但 proxy 地址需配置到
|
|
1173
|
+
`ROUTIFY_VERTEX_BASE_URL`(该地址也供 Gemini TTS 使用)。新密钥配置对 Agent Arena
|
|
1174
|
+
和提供对应工具的 Code Arena 模式均生效,不改变请求协议、模型默认值或工具契约。
|
|
1131
1175
|
|
|
1132
1176
|
`fetch_page` 使用 Defuddle 将 HTML 正文转换为 Markdown,并使用
|
|
1133
1177
|
`pdf-parse` 提取 PDF 的前 30 页。响应按 Markdown 边界稳定分块,同一轮内
|
|
@@ -1142,10 +1186,20 @@ XLSX 仍可提取文字和表格内容,旧版 DOC、PPT、XLS 会先通过 Lib
|
|
|
1142
1186
|
内容继续发送给模型。所有工具结果另有 1,000,000 字符的最终兜底。当前不做
|
|
1143
1187
|
OCR,扫描版 PDF 只会返回无可提取文字的提示。
|
|
1144
1188
|
|
|
1145
|
-
Agent Arena
|
|
1146
|
-
`gemini-3.1-flash-tts-preview
|
|
1147
|
-
|
|
1148
|
-
`
|
|
1189
|
+
Agent Arena 单图生成默认在 `gemini-3.1-flash-image` 和 `gpt-image-2` 中每次等概率随机选择;
|
|
1190
|
+
设置 `ARENA_IMAGE_MODEL` 可固定模型。语音默认使用 `gemini-3.1-flash-tts-preview`,
|
|
1191
|
+
可用 `ARENA_SPEECH_MODEL` 覆盖。
|
|
1192
|
+
`generate_image` 的 `offer_options=true` 默认并行调用 Gemini 和 GPT Image 2 生成候选图,等用户选择后
|
|
1193
|
+
把选中的图保存到 `file_path`,另一张保存到工作区根目录的 `Unselected files`。
|
|
1194
|
+
选择“两张都不要”或跳过时保留已有目标文件。省略该参数或传 `false` 仍直接生成一张图。
|
|
1195
|
+
第一模型可用 `ARENA_IMAGE_MODEL` 指定,第二模型可用 `ARENA_IMAGE_ALTERNATIVE_MODEL` 指定,
|
|
1196
|
+
默认 `gpt-image-2`;第一模型已经使用它时,第二模型默认改为 `gemini-3.1-flash-image`,两者不能相同。
|
|
1197
|
+
Web UI 直接展示两张图;TUI 给出候选图片路径供查看。没有交互 handler 的 headless 模式
|
|
1198
|
+
仍生成两张候选图,默认保存第一张并继续执行;也可配置支持图片预览的远程用户 handler 供选择。未完成的候选图保存在
|
|
1199
|
+
`ARENA_HOME/image-options`,同一会话重试相同请求时可复用;选择完成后清理临时图片。
|
|
1200
|
+
Code Arena 单图生成默认在 `gpt-image-2.5-sunburst` 和 `gpt-image-2.5-flare` 中
|
|
1201
|
+
每次等概率随机选择,暂不使用 Grok 和 `muse-image`。配置时优先使用 `CODE_HARNESS_IMAGE_MODEL` 固定模型,
|
|
1202
|
+
其次使用显式设置的 `ARENA_IMAGE_MODEL`。Code Arena 不提供 `offer_options`。图片生成结果和
|
|
1149
1203
|
搜索到的图片会立即下载到工作区;每次图片搜索的结果按生产命名保存为
|
|
1150
1204
|
`image-search/<query slug>-<序号>.<扩展名>`,并作为可预览文件显示在 Web UI。
|
|
1151
1205
|
语音生成先由 `add_voice` 生成两个试听候选并让用户选择,选择结果注册为稳定的
|
package/dist/agent.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ interface AgentOptions {
|
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
clientContext?: ClientContext;
|
|
18
18
|
workspaceContext?: WorkspaceContext;
|
|
19
|
+
/** Restore the session's selected direct workspace child. */
|
|
20
|
+
repoDirectory?: string;
|
|
19
21
|
onCheckpoint?: (messages: readonly Message[], tools: readonly ToolDefinition[], sessionMemory?: StoredSessionMemory | null) => Promise<void>;
|
|
20
22
|
/** Inspect repetition, tool-call batches and pending Agent Arena compactions. */
|
|
21
23
|
midturnCheckpointHook?: MidturnCheckpointHook;
|
|
@@ -42,14 +44,16 @@ interface AgentRunOptions {
|
|
|
42
44
|
restoreSessionMemory?: boolean;
|
|
43
45
|
}
|
|
44
46
|
export declare function isContinuableHistory(messages: readonly Message[]): boolean;
|
|
45
|
-
export declare function resolveRepoContext(workspace: string, _history?: Message[], mode?: HarnessMode): RepoContext | undefined;
|
|
47
|
+
export declare function resolveRepoContext(workspace: string, _history?: Message[], mode?: HarnessMode, repoDirectory?: string): RepoContext | undefined;
|
|
46
48
|
export declare class Agent {
|
|
47
49
|
private readonly config;
|
|
48
50
|
private readonly sink;
|
|
49
51
|
private readonly options;
|
|
50
52
|
private checkpointQueue;
|
|
53
|
+
private readonly restoredToolCalls;
|
|
51
54
|
private checkpointError?;
|
|
52
55
|
private persistedMemory?;
|
|
56
|
+
private repoDirectory?;
|
|
53
57
|
private readonly memoryCache;
|
|
54
58
|
private readonly client;
|
|
55
59
|
private readonly tools;
|
package/dist/agent.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
4
|
import { supportsModelInput, } from "./config.js";
|
|
4
5
|
import { compactMessagesIfNeeded, maintainSessionMemory, contextFromHistory, sessionMemoryMatchesHistory, settleSessionMemory, storedSessionMemory } from "./compaction.js";
|
|
5
6
|
import { ANTHROPIC_INCOMPLETE_STREAM_ERROR_CODE } from "./anthropic.js";
|
|
7
|
+
import { rememberRestoredCalls, restoredArenaHistory } from "./arena-history.js";
|
|
6
8
|
import { modelCallLogPath, withoutLeadingSystemMessage } from "./history.js";
|
|
7
9
|
import { MockModelClient } from "./mock.js";
|
|
8
10
|
import { contentPartMediaTypes, JsonlModelCallDiagnostics, } from "./model-diagnostics.js";
|
|
@@ -25,7 +27,7 @@ function wrapMalformedToolArguments(argumentsText) {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
/** Keep Agent Arena history replayable without losing the model's invalid input. */
|
|
28
|
-
function normalizeToolCallHistory(message, mode) {
|
|
30
|
+
function normalizeToolCallHistory(message, mode, historyCall) {
|
|
29
31
|
if (isCodeArenaMode(mode) || message.role !== "assistant")
|
|
30
32
|
return message;
|
|
31
33
|
// A failed Responses stream can retain completed native items without the
|
|
@@ -37,7 +39,10 @@ function normalizeToolCallHistory(message, mode) {
|
|
|
37
39
|
? [{ id: item.call_id, type: "function", function: { name: item.name, arguments: item.arguments } }]
|
|
38
40
|
: []) ?? message.tool_calls;
|
|
39
41
|
let changed = Boolean(calls?.length && calls !== message.tool_calls);
|
|
40
|
-
const toolCalls = calls?.map((
|
|
42
|
+
const toolCalls = calls?.map((original) => {
|
|
43
|
+
const call = historyCall ? historyCall(original) : original;
|
|
44
|
+
if (call !== original)
|
|
45
|
+
changed = true;
|
|
41
46
|
if (typeof call.function?.arguments !== "string")
|
|
42
47
|
return call;
|
|
43
48
|
const argumentsText = wrapMalformedToolArguments(call.function.arguments);
|
|
@@ -51,7 +56,8 @@ function normalizeToolCallHistory(message, mode) {
|
|
|
51
56
|
const responseItems = message.openai_response_items?.map((item) => {
|
|
52
57
|
if (item.type !== "function_call" || typeof item.arguments !== "string")
|
|
53
58
|
return item;
|
|
54
|
-
const
|
|
59
|
+
const paired = toolCalls?.find(call => call.id === item.call_id);
|
|
60
|
+
const argumentsText = paired?.function.arguments ?? wrapMalformedToolArguments(item.arguments);
|
|
55
61
|
if (argumentsText === item.arguments)
|
|
56
62
|
return item;
|
|
57
63
|
changed = true;
|
|
@@ -73,6 +79,41 @@ function parseToolResult(content) {
|
|
|
73
79
|
return {};
|
|
74
80
|
}
|
|
75
81
|
}
|
|
82
|
+
/** Live Agent Arena results arrive in completion order. Checkpoint writes stay
|
|
83
|
+
* serialized by the consumer, and every started operation settles before exit.
|
|
84
|
+
* Code Arena retains its sequential execution path.
|
|
85
|
+
*/
|
|
86
|
+
async function* completedTools(calls, parallel, execute) {
|
|
87
|
+
if (!parallel) {
|
|
88
|
+
for (const call of calls)
|
|
89
|
+
yield { call, message: await execute(call) };
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const queue = [];
|
|
93
|
+
let wake;
|
|
94
|
+
const settled = Promise.all(calls.map(async (call) => {
|
|
95
|
+
try {
|
|
96
|
+
queue.push({ status: "fulfilled", value: { call, message: await execute(call) } });
|
|
97
|
+
}
|
|
98
|
+
catch (reason) {
|
|
99
|
+
queue.push({ status: "rejected", reason });
|
|
100
|
+
}
|
|
101
|
+
wake?.();
|
|
102
|
+
}));
|
|
103
|
+
try {
|
|
104
|
+
for (let count = 0; count < calls.length; count++) {
|
|
105
|
+
if (!queue.length)
|
|
106
|
+
await new Promise(resolve => { wake = resolve; });
|
|
107
|
+
const result = queue.shift();
|
|
108
|
+
if (result.status === "rejected")
|
|
109
|
+
throw result.reason;
|
|
110
|
+
yield result.value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
await settled;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
76
117
|
// Network faults that abort an in-flight stream (a dropped socket, a reset, a
|
|
77
118
|
// DNS blip). undici surfaces these mid-stream as `TypeError: fetch failed` or
|
|
78
119
|
// `TypeError: terminated`; some are also reachable via an errno-style code on
|
|
@@ -320,18 +361,20 @@ class CheckpointFailure extends Error {
|
|
|
320
361
|
this.cause = cause;
|
|
321
362
|
}
|
|
322
363
|
}
|
|
323
|
-
//
|
|
364
|
+
// Refresh live Git state on every run, using the saved target when available.
|
|
324
365
|
// The history argument is retained for callers; it never supplies runtime state.
|
|
325
|
-
export function resolveRepoContext(workspace, _history, mode = "arena") {
|
|
326
|
-
return isCodeArenaMode(mode) ? undefined : detectRepoContext(workspace);
|
|
366
|
+
export function resolveRepoContext(workspace, _history, mode = "arena", repoDirectory) {
|
|
367
|
+
return isCodeArenaMode(mode) ? undefined : detectRepoContext(workspace, repoDirectory);
|
|
327
368
|
}
|
|
328
369
|
export class Agent {
|
|
329
370
|
config;
|
|
330
371
|
sink;
|
|
331
372
|
options;
|
|
332
373
|
checkpointQueue = Promise.resolve();
|
|
374
|
+
restoredToolCalls = new Set();
|
|
333
375
|
checkpointError;
|
|
334
376
|
persistedMemory;
|
|
377
|
+
repoDirectory;
|
|
335
378
|
memoryCache;
|
|
336
379
|
client;
|
|
337
380
|
tools;
|
|
@@ -343,6 +386,7 @@ export class Agent {
|
|
|
343
386
|
this.sink = sink;
|
|
344
387
|
this.options = options;
|
|
345
388
|
this.memoryCache = options.sessionMemory || {};
|
|
389
|
+
this.repoDirectory = options.repoDirectory;
|
|
346
390
|
this.sessionId =
|
|
347
391
|
options.sessionId || crypto.randomUUID().replaceAll("-", "");
|
|
348
392
|
this.sessionAffinityId = options.sessionAffinityId || crypto.randomUUID();
|
|
@@ -358,15 +402,18 @@ export class Agent {
|
|
|
358
402
|
(!needsMainHttpClient && !needsFallbackHttpClient)
|
|
359
403
|
? undefined
|
|
360
404
|
: new JsonlModelCallDiagnostics(modelCallLogPath(config.stateRoot, config.tenantId, this.sessionId));
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
(
|
|
364
|
-
|
|
365
|
-
:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
405
|
+
const client = options.client ||
|
|
406
|
+
(config.model.startsWith("mock/")
|
|
407
|
+
? new MockModelClient()
|
|
408
|
+
: new HttpModelClient(config, {
|
|
409
|
+
sessionAffinityId: this.sessionAffinityId,
|
|
410
|
+
onRequest: options.onModelRequest,
|
|
411
|
+
...(diagnostics ? { diagnostics } : {}),
|
|
412
|
+
}));
|
|
413
|
+
this.client = isCodeArenaMode(config.mode) ? client : {
|
|
414
|
+
stream: request => client.stream({ ...request,
|
|
415
|
+
messages: restoredArenaHistory(request.messages, this.restoredToolCalls) }),
|
|
416
|
+
};
|
|
370
417
|
const imageInputFallbackClient = options.imageInputFallbackClient ||
|
|
371
418
|
(fallbackConnection
|
|
372
419
|
? new HttpModelClient(config, {
|
|
@@ -409,17 +456,25 @@ export class Agent {
|
|
|
409
456
|
? interruptedUserMessage(baseUserMessage, this.config.mode)
|
|
410
457
|
: structuredClone(baseUserMessage);
|
|
411
458
|
const clientContext = this.options.clientContext || defaultClientContext();
|
|
412
|
-
const repoContext = resolveRepoContext(this.config.workspace, history, this.config.mode);
|
|
459
|
+
const repoContext = resolveRepoContext(this.config.workspace, history, this.config.mode, this.repoDirectory);
|
|
460
|
+
if (repoContext) {
|
|
461
|
+
this.repoDirectory = path.relative(this.config.workspace, repoContext.checkoutPath);
|
|
462
|
+
}
|
|
413
463
|
// System instructions belong to this invocation, never to the saved dialogue.
|
|
414
464
|
// Older local histories included a system message; accept them without
|
|
415
465
|
// carrying the old runtime configuration into the next request.
|
|
416
466
|
const dialogue = withoutLeadingSystemMessage(history || []).map((message) => normalizeToolCallHistory(message, this.config.mode));
|
|
467
|
+
this.restoredToolCalls.clear();
|
|
468
|
+
if (!isCodeArenaMode(this.config.mode))
|
|
469
|
+
rememberRestoredCalls(dialogue, this.restoredToolCalls);
|
|
417
470
|
const trajectory = completeInterruptedToolCalls(this.options.reuseHistoryMessages ? [...dialogue] : structuredClone(dialogue));
|
|
418
471
|
const connectors = this.config.disallowedTools?.includes("list_connector_tools")
|
|
419
472
|
? undefined : this.config.connectors;
|
|
473
|
+
const connectedConnectors = this.config.disallowedTools?.includes("list_connector_tools")
|
|
474
|
+
? undefined : this.config.connectedConnectors;
|
|
420
475
|
const runtimeSystemMessage = repoContext
|
|
421
|
-
? repoSystemMessage(clientContext, repoContext, this.config.mode, this.workspaceContext, this.config.maxTurns, connectors)
|
|
422
|
-
: systemMessage(clientContext, this.workspaceContext, this.config.mode, this.config.maxTurns, connectors);
|
|
476
|
+
? repoSystemMessage(clientContext, repoContext, this.config.mode, this.workspaceContext, this.config.maxTurns, connectors, connectedConnectors)
|
|
477
|
+
: systemMessage(clientContext, this.workspaceContext, this.config.mode, this.config.maxTurns, connectors, connectedConnectors);
|
|
423
478
|
applySystemPromptConfig(runtimeSystemMessage, this.config);
|
|
424
479
|
if (runOptions.resumeFromHistory) {
|
|
425
480
|
if (!isContinuableHistory(dialogue)) {
|
|
@@ -467,7 +522,7 @@ export class Agent {
|
|
|
467
522
|
}
|
|
468
523
|
}
|
|
469
524
|
const recordMessage = async (message) => {
|
|
470
|
-
const normalized = normalizeToolCallHistory(message, this.config.mode);
|
|
525
|
+
const normalized = normalizeToolCallHistory(message, this.config.mode, call => this.tools.historyCall(call));
|
|
471
526
|
messages.push(normalized);
|
|
472
527
|
const recorded = structuredClone(normalized);
|
|
473
528
|
trajectory.push(recorded);
|
|
@@ -549,46 +604,62 @@ export class Agent {
|
|
|
549
604
|
return await this.finish(trajectory, "success");
|
|
550
605
|
}
|
|
551
606
|
const completedToolCallIds = [];
|
|
552
|
-
|
|
607
|
+
let needsInput = false;
|
|
608
|
+
const execute = async (call) => {
|
|
553
609
|
const toolCallId = String(call.id || "");
|
|
554
610
|
const toolName = String(call.function?.name || "tool");
|
|
555
611
|
this.sink.toolStart(this.sessionId, toolCallId, toolName);
|
|
556
|
-
|
|
612
|
+
return this.tools.execute(call, toolName === "ask_user" || toolName === "add_voice" ||
|
|
613
|
+
(!isCodeArenaMode(this.config.mode) && toolName === "generate_image")
|
|
557
614
|
? {
|
|
558
615
|
sessionId: this.sessionId,
|
|
559
616
|
messages: structuredClone(trajectory),
|
|
560
617
|
signal: this.options.signal,
|
|
561
618
|
}
|
|
562
619
|
: undefined);
|
|
620
|
+
};
|
|
621
|
+
for await (const { call, message: toolMessage } of completedTools(assistant.tool_calls, !isCodeArenaMode(this.config.mode), execute)) {
|
|
622
|
+
const toolCallId = String(call.id || "");
|
|
623
|
+
const toolName = String(call.function?.name || "tool");
|
|
563
624
|
const toolResult = parseToolResult(toolMessage.content);
|
|
564
625
|
const skippedAskUser = toolName === "ask_user" && toolResult.skipped === true;
|
|
565
626
|
if (this.options.signal?.aborted && !skippedAskUser) {
|
|
566
627
|
throw this.options.signal.reason || new Error("operation cancelled");
|
|
567
628
|
}
|
|
568
629
|
await recordMessage(toolMessage);
|
|
630
|
+
if (this.tools.takeInteractionBoundary(toolCallId)) {
|
|
631
|
+
rememberRestoredCalls(messages, this.restoredToolCalls);
|
|
632
|
+
}
|
|
569
633
|
completedToolCallIds.push(toolCallId);
|
|
570
634
|
this.sink.toolComplete(this.sessionId, toolCallId, toolName);
|
|
571
|
-
if (toolName === "ask_user" || toolName === "add_voice"
|
|
635
|
+
if (toolName === "ask_user" || toolName === "add_voice" ||
|
|
636
|
+
(!isCodeArenaMode(this.config.mode) && toolName === "generate_image")) {
|
|
572
637
|
if (toolResult.status === "needs_input") {
|
|
573
|
-
const visualMessage = this.tools.takeVisualMessage(completedToolCallIds);
|
|
574
|
-
if (visualMessage) {
|
|
575
|
-
await recordMessage(visualMessage);
|
|
576
|
-
}
|
|
577
638
|
const questions = Array.isArray(toolResult.questions)
|
|
578
639
|
? toolResult.questions
|
|
579
640
|
: [];
|
|
580
641
|
this.sink.inputRequired(this.sessionId, toolCallId, questions);
|
|
581
|
-
|
|
642
|
+
if (isCodeArenaMode(this.config.mode)) {
|
|
643
|
+
const visualMessage = this.tools.takeVisualMessage(completedToolCallIds);
|
|
644
|
+
if (visualMessage)
|
|
645
|
+
await recordMessage(visualMessage);
|
|
646
|
+
return await this.finish(trajectory, "needs_input");
|
|
647
|
+
}
|
|
648
|
+
needsInput = true;
|
|
582
649
|
}
|
|
583
650
|
}
|
|
584
651
|
if (this.options.signal?.aborted) {
|
|
585
652
|
throw this.options.signal.reason || new Error("operation cancelled");
|
|
586
653
|
}
|
|
587
654
|
}
|
|
588
|
-
|
|
655
|
+
// Image parts retain the assistant's declaration order independently
|
|
656
|
+
// of which tool result completed first.
|
|
657
|
+
const visualMessage = this.tools.takeVisualMessage(assistant.tool_calls.map(call => call.id));
|
|
589
658
|
if (visualMessage) {
|
|
590
659
|
await recordMessage(visualMessage);
|
|
591
660
|
}
|
|
661
|
+
if (needsInput)
|
|
662
|
+
return await this.finish(trajectory, "needs_input");
|
|
592
663
|
if (runOptions.singleStep) {
|
|
593
664
|
return await this.pause(trajectory, "single_step");
|
|
594
665
|
}
|