Skip to content

GAL v1.10.0

Choose a tag to compare

@zmysysz zmysysz released this 02 Dec 09:13

GAL v1.10.0

Highlights

  • serve can continue a CLI session, in the project directory it belongs to. An endpoint may now share the session library (workdir, workdir_fixed, session_shared — all off unless you ask), and every front end takes the same cross-process lease, so a conversation created over HTTP opens with gal chat --resume in the same directory, and the other way round.
  • Breaking: gal chat --pipe speaks JSON-RPC (a reduced ACP) by default. One JSON message per line, a stopReason that tells finished from cancelled from out-of-rounds, and tool calls with structured arguments. A script that needs the old plain text adds --format raw.
  • A command that leaves a background process no longer wedges the turn. WaitDelay bounds the read after the shell exits, so Stop actually ends the turn and the session stops claiming it is running.

serve: an endpoint can continue the CLI session, in its own directory

  • An API session's id and working directory used to be derived and unconfigurable: the id always carried an api_<endpoint>_<session> prefix and the directory was always "endpoint directory + session id". gal chat --resume matches sessions by directory, so together they kept API and CLI conversations in two worlds: in one project directory the API and the terminal saw two conversations that knew nothing of each other, and neither could continue the other.
  • api.endpoints.<name> gains three optional fields, all of which default to the old behaviour: workdir (the endpoint's working directory, relative to serve.yaml's workdir, absolute paths accepted), workdir_fixed (this directory is the session directory, with no session id appended; needs workdir, validated at startup), and session_shared (store whatever session id the caller supplies, with no prefix, so API, CLI and GUI name the same conversation).
  • A shared session keeps the directory it was created in: --resume matches on the directory, so a different one would not connect. Taking over therefore does not recompute the working directory.
  • A shared endpoint can address the entire session library, so reuse is guarded, each guard with its own reason: sessions from the Management centre, ids starting with api_ (whether or not they exist — the test runs before the file is opened), and sessions created by another agent. A session.json that cannot be read is now refused and left exactly as it is: it is the only copy of that conversation, and it used to be treated as absent, so the next save overwrote it.
  • One writer per session: internal/session.Lease is the cross-process advisory lock every front end takes (session-<id>, plus a best-effort lock on the CLI's older cli-session-<id> so machines still running the old binary stay mutually exclusive). The CLI holds it until the process exits, serve holds it per turn — which is exactly why a handoff needs neither side restarted. A turn that finds the file changed on disk re-reads it instead of appending to history only this process remembers.
  • Startup refuses two endpoints whose names differ by one underscore (a_b and a): their storage ids would collide into one session, one directory and one engine, letting an endpoint without a key read the history of an endpoint with one. That is privilege escalation, not a naming quirk, and failing at startup costs a rename.
  • Tests: internal/config/serve_sessions_test.go, internal/session/lease_test.go, cmd/serve_session_scope_test.go (TestAPISessionID/TestAPISessionDir/TestLoadSessionForReuse/TestTakeTurnLease/TestPrepareEndpointWorkDirs); verified against real processes: create a session over the API, continue it with gal chat --resume in the same directory under the same session id, then the reverse.

A handoff keeps the session's choices, and says when a turn degrades

  • serve used to carry only Messages when it took over an existing session: model, capability overrides (what /caps had done), title, profile, focus, reasoning effort and the archived flag stayed in the file and took no effect. Two consequences: the conversation continued on serve's default model while the CLI had always used another, and capability changes made on either side during the handoff were overwritten wholesale by serve's stale snapshot at the end of the turn, erasing what the other front end had just set.
  • serve now takes the same construction path as the CLI (read agent config, apply the session's /caps delta, build the engine), in the order buildSessionEngine in the CLI and refreshEngine in the GUI already use. An empty delta returns the config untouched, keeping the prompt cache byte-identical.
  • When the file changed on disk it is re-read, adopting title, profile, focus, reasoning, overrides and archived. A changed capability delta does not rebuild the engine — swapping the toolset mid-turn would break that turn — it only logs a line saying the change takes effect next time.
  • A model that has disappeared from the agent's model list used to be swapped silently: it is now logged at the decision point, logged again as "saved model unavailable", and the engine's OnModelFallback is wired up — in serve it had never been connected at all.

Keeping existing deployments working

  • Two of the guards above were narrowed so they cannot break a deployment that is already running. Agent validation applies only to shared endpoints: an isolated endpoint's sessions are all its own, and a session whose agent line changed must still work — one log line, not a 500 for every session.
  • Not being able to take the lock does not mean someone else is using it: takeTurnLease separates the two answers. Refuse the turn when the other side holds it; when the lock store is simply unusable (a normal write fails) say so once and keep serving. The request path, clear and timers all make the same decision.

Hooks: a pre_tool exec script is a veto, now documented as one

  • The capability was always there; the documentation was wrong. The rule table showed only Deny, confirm for pre_tool, every action: exec example hung off a notify-class event, and nothing tested whether a script could stop the call. So the question that gets asked most — can a pre-tool script veto a tool that is about to run? — could only be answered by reading execSync.
  • The contract now appears in gal agent help, both READMEs and .gal/design.md: a non-zero exit code is a veto (the tool does not run, the model receives [hook denied] hook script error: ..., and the turn continues); deny <reason> with exit 0 is a veto with a reason; when both appear the reason is lost (exit code wins); a missing or non-executable script is a veto (fail closed, not allow); a hook has no timeout of its own — the turn's overall timeout is the upper bound.
  • The same text says what it is not: hook scripts run as the GAL user and outside the safe-mode sandbox, so they are a policy and audit gate, not an isolation boundary.
  • Tests: internal/hook/hook_exec_verdict_test.go (six exit shapes, fail closed, allow does not stop later rules, the script sees the call it is judging) and internal/tool/hook_exec_veto_test.go (after a veto the tool really did not run, with a no-rules control group).

GUI: pictures produced by tools

  • A picture published by a tool was drawn inside .tool-body, and a tool card collapses the moment it ends — so the one part of the result worth seeing at a glance was hidden behind a click nobody knew to make. That click was open_url carrying the whole data: URL, which the system handler either ignores or answers with a browser tab, so "let me look at it properly" showed nothing. Images now hang in a .tool-shots strip after the body, outside the fold's control, and clicking one opens the same lightbox as an inline image in the text (a data: URL is not a file, so the lightbox shows no "open file").
  • The fold still governs it: .tool-block.collapsed .tool-shots collapse together ("the image image_read displayed is not in the box, so it cannot be collapsed"), and a card carrying pictures no longer auto-collapses — otherwise the picture is hidden behind a click again.
  • Pictures survive a restart. A tool carried its images as data: URLs inside that tool_done frame, history.db had no column for them and they existed in no file, so a card rebuilt from history came back with its text, status and duration but no picture. They are now written to <session>/shots/ with the path in a new history.shots column, replay and live view sharing one source and one rendering path. The bytes stay out of the database: a few hundred KB of base64 per row would be read by every history page, search and export, while only tool cards draw it.
  • image_read no longer treats "not a picture" as a picture: pointed at an HTML file it did not fail, it published those bytes as an image — the result line claimed a picture was attached, the model could not decode it, the output area drew a broken element, and the bytes were written into shot storage as shot-....png (an unknown header fell back to png), so the broken image came back on every restart. It now accepts PNG / JPEG / GIF / WebP only and names the file; non-image rows written by older versions read back as "no picture" and draw a card without one instead of a broken element.
  • A file no browser displays (.log, .docx, source code) used to take the wrong branch: assetResolveWithHome refused anything outside mediaTypes, so the path the model wrote as "the log is at xxx" stayed dead text. It now takes the directory route (real path, kind file, no token) and becomes a clickable chip.
  • Tests: frontend_output_chips_test.go, server_tool_shots_test.go, session_edit_shot_test.go, media_browser_e2e_test.go (each folding rule verified on its own: remove it and the test goes red for its own reason).

GUI: session management and the sidebar

  • Deleting a session that had never been opened: Management → Sessions lists what is on disk, while the delete handler required the session to be open in this process, so every row except the one being read failed silently. Deleting is a disk operation; the in-memory map only decides who to close first. The refusals left are "this turn is running" and "a web principal reaching for someone else's id", and both refusals and disk failures now tell the user instead of leaving the row inert.
  • A toggleable session-name filter sits next to the sidebar's Search: case-insensitive substring, ordered-subsequence fuzzy match, and space-separated terms ANDed together, applied to both name and id. Empty groups are hidden, a collapsed group expands temporarily on a hit without touching the persisted collapsed_groups, and the strings are translated for all nine locales.
  • Custom agent cards get an enable/disable switch: the enabled flag and handleSetAgentEnabled were already there, the card just hard-coded selected: true, canToggle: false. Disabling hides "set as default" and keeps delete and card editing, and cancelling the confirmation redraws the card so the checkbox does not sit in the wrong state.
  • Locales: German and Spanish lost their leftover English (purpose_*, agent_name.coder, field_prompt_cache), Russian uses пространство throughout, and field_base_url in de/es/fr/ja/ru matches the localised "Base URL".

CLI, engine and provider

  • gal provider edit (aliases update / modify / set): change an existing provider with --type, --base-url, --key, --key-env or --clear-key without touching its models, model_confs, fallback_models or any other setting. With no flags it prompts field by field against the current values, and Enter keeps them.
  • TruncatePreview truncated lines but not characters when both maxChars and maxLines were exceeded: twenty-odd lines of log or JSON at a thousand characters each could dump several thousand characters into the terminal at once. It now truncates by line first and applies maxChars to the result, so both budgets always hold.
  • Provider chat presets and endpoint branding aligned: compatible product endpoints are recommended without rewriting an existing config, chat paths are normalised, icon matching is unified, and the per-cloud resource-level notes are filled in.

Breaking change: --pipe emits JSON-RPC (a reduced ACP) by default

  • gal chat --pipe output changes from plain text with a ---END--- delimiter to one JSON-RPC message per line: stdin accepts initialize / session/new / session/prompt / session/cancel, stdout emits only session/update notifications (agent_message_chunk, agent_thought_chunk, tool_call, tool_call_update). Method and field names follow ACP, which makes this a reduced ACP: session/list, session/resume, fs/*, terminal/*, session/request_permission and the rest are not implemented and are declared false in the capabilities.
  • Migration: a script that needs the old behaviour adds --format raw (gal chat --pipe --format raw); everything else is unchanged. No code in the repository consumed ---END--- — only documentation and agent prompts mentioned it — so the breakage is in external scripts.
  • The problem with a plain-text stream is that it cannot tell "the turn ended" from "the process died", cannot express a tool call's structured arguments, and cannot separate "failed", "timed out" and "cancelled" (all three used to be one ⚠ error: ... line on stderr). A JSON stream separates them into stopReason: end_turn|cancelled|max_turn_requests and JSON-RPC errors carrying data.reason.
  • gal chat -m "..." --format json emits JSON frames too, but since a command-line message has no request to answer, it closes with a GAL extension notification, gal/turn_end, instead of faking a response.
  • The stdin line limit rises from 1 MiB to 16 MiB: in JSON mode one prompt is one line, and the old limit made the scanner stop silently when a large block of text was pasted, so the process looked as though it had exited by itself.
  • The engine gains an OnToolCallFull callback handing the caller the tool name and structured arguments (the old ToolCallCallback gave an 80-character display summary), and agentic loop exceeded becomes the testable engine.ErrMaxRounds.
  • Protocol fixes, for people writing a client: a prompt accepts resource_link besides text — ACP lists it as a baseline requirement and it is not gated by promptCapabilities — and the link reaches the model as a reference line which it fetches with file_read; session/new answers once, and a second call returns -32601 naming the session this process serves, so a client cannot believe it holds two independent sessions that in fact share one context; initialize and session/new sent as notifications are not answered (otherwise a response frame with id: null lands in the stream); and the overlong-line error now names the 16 MiB limit it broke.

Interop fixes for ACP clients (from testing a third-party integration)

  • Every frame of pipe mode was validated against the official schema/v1/schema.json (ACP v1.35.0), and the three places that are not schema violations but that a real client still trips over were fixed:
  • A failed tool now reports status: "failed": the engine used to flatten errors into an "error: ..." string and the pipe reported status: "completed" for everything, so a client put a green tick on a failed call. ToolResultFullCallback therefore takes an extra failed argument (an internal callback whose only caller is the pipe itself), executeTool returns a toolOutcome carrying failed, and a call whose panic was recovered counts as failed too. A tool whose own output happens to begin with error: is no longer misjudged either.
  • mcpServers / additionalDirectories no longer reject the whole session: mcpServers is a required field of NewSessionRequest, so a client cannot "just not send it", and any user with a single configured MCP server got -32602 from session/new — the session could not start at all. The session now opens, and the result reports the servers that were not attached and the directories that were not activated in _meta.gal.ignored (ACP's extension point) while a line goes to stderr: neither a silent downgrade nor a lost session over one field. cwd is still refused: the engine's tool sandbox root is fixed when the process starts, and accepting another cwd would resolve every relative path in the wrong place.
  • session/prompt sent as a notification no longer writes an id: null response frame: JSON-RPC 2.0 forbids answering a notification and strict client libraries treat that frame as malformed. It is ignored and logged the way initialize / session/new / session/load already were, and the turn does not run — its reply has nowhere to go.

--pipe supports session/load (ACP session switching)

  • With session/load a client can switch to another existing session on the same pipe stream: session id, session lock, session.json, engine, context store (memory.db) and SessionDir all switch together, and the session's model, capability overrides (/caps) and recorded working directory are restored after the switch.
  • The replay is emitted as session/update notifications before the response, as ACP requires — the response is itself the signal that the history is complete. Only user and model text is replayed; tool calls and results are not (they are the path to a reply, not the conversation, and are often several times larger). Above 8 MiB the beginning is kept and _meta.gal.replay carries {replayed, total, truncated} rather than silently starting in the middle.
  • The loadSession capability is derived from whether a loader is actually wired up; with none (-m mode) it is declared false instead of "declared but uncallable".
  • Refusals are explicit, each with its reason: the session does not exist (-32002), another CLI instance holds it, the agent was deleted or disabled, and the session's recorded working directory does not match this process (one process has one tool sandbox root). cwd goes through the same logic as session/new (mcpServers / additionalDirectories are accepted and reported, as in the previous section). Switching while a turn is running is refused too: afterwards session/cancel would name a session that no longer exists and that turn could never be cancelled.
  • The TUI's engine-swap logic is factored into a reusable adoptEngine(dst, cfg, newEng) shared by pipe mode and the TUI, so a new engine field cannot be copied in one place and missed in the other.

A bash call that leaves a background process no longer wedges the turn

  • Root cause: when a command left a process in the background (Start-Process, nohup, setsid, any daemonising script), that process inherited the call's output pipe. cmd.Wait() only returns after it reads EOF, and the pipe stays open until the background process exits, so "start the service and return" never returned. By then the shell had already exited and the Stop button's taskkill /T (a process-group kill on Unix) had nothing left to kill: the context was cancelled, the interface said stopped, and the turn never ended — the session stayed "running", switching away and back showed it still running, and every other action was refused with session is running.
  • Fix: the direct-execution path sets WaitDelay on the exec.Cmd (a new tool.BackgroundIOWait, 2s). After the command process ends, at most two more seconds of output are read and then the pipe is closed and the call returns. The background process is not killed — outliving the call is a legitimate need — the result is marked [exit 0] with a line saying the command finished, the process it left behind is still running and holds the output, and anything printed after this point is not in this result.
  • The sandbox agent (gal sandbox-agent) gets the same bound: it used to block on Run forever, the host timed out waiting for the answer and discarded the whole sandbox, killing every other background process in the namespace with it. On the agent side ErrWaitDelay counts as "the command finished" instead of being reported as a failure.
  • Tests: TestACallReturnsWhenTheCommandLeavesAProcessRunning, TestStopEndsACallWhoseShellIsAlreadyGone, TestTheAgentDoesNotWaitForABackgroundProcess (each goes red without WaitDelay: the call waits out the background process's entire lifetime).

Install

Download the archive for your platform below, verify it against checksums.txt, then run the binary (or install.sh on macOS CLI).


GAL v1.10.0 中文说明

重点更新

  • serve 可以接着 CLI 的会话,在它原本所属的项目目录里干活。 endpoint 现在可以共享会话库(workdir、workdir_fixed、session_shared,不配置就是旧行为),所有前端取同一把跨进程锁,于是 HTTP 建出来的对话能在同一目录下用 gal chat --resume 接上,反过来也成立。
  • 破坏性变更:gal chat --pipe 默认输出 JSON-RPC(精简版 ACP)。 每行一条 JSON,stopReason 区分「正常结束」「被取消」「轮次用尽」,工具调用带结构化参数。需要旧格式的脚本加 --format raw。
  • 命令留下后台进程不再卡死这一轮。 WaitDelay 给 shell 退出后的读取加上界,于是「停止」真的能结束这一轮,会话也不再自称「运行中」。

serve:一个 endpoint 可以接着 CLI 的会话,在原有目录里干活

  • 此前 API 会话的 id 和工作目录都是推导出来的、都不可配置:id 固定加 api_<endpoint>_<session> 前缀,目录固定是「endpoint 目录 + 会话 id 子目录」。而 gal chat --resume 按目录匹配会话 —— 两条一起把 API 会话和 CLI 会话永久分成了两个世界:同一个项目目录里,API 和终端看到的是两份互不知情的对话,谁也无法接着对方往下说
  • api.endpoints.<name> 新增三个可选字段,全部默认等于旧行为:workdir(该 endpoint 的工作目录,相对 serve.yaml 的 workdir,绝对路径照用)、workdir_fixed(这个目录就是会话目录,不再往下拼会话 id;需要 workdir,启动时校验)、session_shared(调用方给什么 session id 就存什么,不加前缀,于是 API、CLI、GUI 指向同一段对话)
  • 共享会话保留它被创建时的目录:--resume 匹配的就是目录,换了目录就接不上,所以接管时不重算工作目录
  • 共享 endpoint 能寻址整个会话库,因此复用加了守卫,各自给理由:Management 中心的会话、以 api_ 开头的 id(不论是否已存在 —— 判定在打开文件之前)、以及由另一个 agent 创建的会话。另外,读不出来的 session.json 现在直接拒绝并保持原样:它是这段对话唯一的副本,而此前它被当成「不存在」,下一次保存就把它覆盖了
  • 一个会话只有一个写者:internal/session.Lease 是所有前端共取的跨进程建议锁(session-<id>,并对 CLI 旧的 cli-session-<id> 做一次尽力而为的加锁,让仍在跑旧二进制的机器依然互斥)。CLI 持有到进程退出,serve 每轮持有 —— 这正是交接不需要重启任何一方的原因;一轮开始时发现文件在磁盘上变了就重新读取,而不是往只有本进程记得的历史后面追加
  • 启动时拒绝两个名字互为「加一个下划线」的 endpoint(a_b 与 a):它们的存储 id 会撞成同一段会话、同一个目录、同一个引擎,无 key 的 endpoint 于是能读到有 key 的 endpoint 的历史 —— 这是越权,不是命名怪癖,在启动时报错只需要改个名字
  • 测试:internal/config/serve_sessions_test.go、internal/session/lease_test.go、cmd/serve_session_scope_test.go(TestAPISessionID/TestAPISessionDir/TestLoadSessionForReuse/TestTakeTurnLease/TestPrepareEndpointWorkDirs);真实进程验证:API 建一个会话 → gal chat --resume 在同一个目录接上同一个 session id → 反过来也成立

交接时接住会话的选择,并说明降级

  • serve 接手一个已存在的会话时只搬了 Messages:模型、能力覆盖(/caps 做过什么)、标题、profile、focus、推理强度、归档标记全都留在文件里没有生效。两个后果:会话在 serve 里用默认模型继续,而 CLI 里它一直用的是另一个;以及交接期间对能力的改动会在本轮结束时被 serve 的旧快照整体写回,把另一端刚做的修改抹掉
  • serve 现在走和 CLI 同一条构建路径(读 agent 配置 → 应用会话的 /caps 增量 → 建引擎),顺序与 CLI 的 buildSessionEngine、GUI 的 refreshEngine 一致;增量为空时原样返回配置,保证提示词缓存逐字节不变
  • 磁盘上的文件变了就重新读取,采用 title / profile / focus / reasoning / overrides / archived;但能力增量变了不重建引擎(一轮跑到一半换工具集会破坏这一轮),只记一行日志说明下一次才生效
  • 模型在 agent 的模型清单里消失时,此前是静默换一个:现在在决策点就记一行、另记「保存的模型不可用」,并把引擎的 OnModelFallback 接上 —— 它在 serve 里此前根本没有接

保留既有部署的行为

  • 上述守卫里有两处是为了「不打断已经跑着的部署」而收窄的:agent 校验只对共享 endpoint 生效 —— 隔离 endpoint 的会话都是它自己建的,agent 行改了也必须能继续,记一行日志即可,而不是对每个会话回 500
  • 锁本身取不到不等于「别人在用」:takeTurnLease 把两种答案分开 —— 另一端持有时拒绝这一轮;锁存储根本不可用(正常写不进去)时只提示一次并继续服务。请求路径、clear 与定时器都走同一个判断

钩子:pre_tool 的 exec 脚本写清楚就是「否决」

  • 能力一直在,文档是错的:规则表里 pre_tool 只写了 Deny, confirm,所有 action: exec 的例子都挂在 notify 类事件下,也没有一处测试覆盖「脚本能不能拦住这个调用」。于是最该被问到的那个问题 —— pre-tool 脚本能否否决待执行的工具 —— 只能靠读 execSync 才能回答
  • 契约现在写进了 gal agent help、两份 README 与 .gal/design.md:退出码非 0 = 否决(工具不执行,模型收到 [hook denied] hook script error: ...,这一轮继续);deny <理由> + 退出 0 = 带理由否决;两者同时出现时理由丢失(退出码优先);脚本不存在或不可执行 = 否决(fail closed,不是放行);hook 没有单独的 timeout,上界是这一轮的总超时
  • 同时说明它不是什么:hook 脚本以 GAL 用户的身份、在安全模式的沙箱之外执行,所以它是策略与审计的闸门,不是隔离边界
  • 测试:internal/hook/hook_exec_verdict_test.go(六种退出方式、fail closed、allow 不终止后续规则、脚本能看到待执行的调用)与 internal/tool/hook_exec_veto_test.go(否决后工具确实没有执行,含无规则的对照组)

GUI:工具产出的图片

  • 工具发布出来的图片画在 .tool-body 里,而工具卡片一结束就折叠 —— 于是整段结果里唯一值得一眼看到的部位,恰好藏在一次没人知道要点的点击后面。那个点击还是 open_url 带整个 data: URL,系统处理器要么忽略要么开一个浏览器标签,「放大看看」于是什么也看不到。图片现在挂在正文后面的 .tool-shots 条里,不受折叠管辖,点击开的是与正文内联图片同一个 lightbox(data: URL 不是文件,lightbox 就不显示「打开文件」)
  • 折叠仍然管得着它:.tool-block.collapsed .tool-shots 一起收起(「image_read 显示的图没有放在框里,无法收起」),同时带图的卡片不再自动折叠 —— 否则又回到「图藏在一次点击后面」那个毛病
  • 重启后图片还在:工具把图片作为 data: URL 塞在那一帧 tool_done 里,history.db 没有列、它也不存在于任何文件,所以从历史重建的卡片回来时文字、状态、耗时都在,图没有。现在写到 <session>/shots/、路径存进新的 history.shots 列,重放与实时走同一份数据、同一个渲染路径;字节不进数据库 —— 每行几百 KB base64 会被每一次历史分页、检索和导出读到,而只有工具卡片会画它
  • image_read 不再把「不是图片」当图片:对着一份 HTML 调用它不会报错,而是把这页的字节当图片发布出去 —— 结果行说附了一张图、模型拿到它解码不了、输出区画出一个坏元素,那份字节还被以 shot-....png 写进 shot 存储(未知头回退到 png),于是坏图每次重启都回来。现在只接受 PNG / JPEG / GIF / WebP 并报出文件名;旧版本写下的非图片行按「没有图」读回,画一张没有图的卡片而不是坏元素
  • 一个浏览器根本不显示的文件(.log、.docx、源码)此前落在错误分支上:assetResolveWithHome 拒绝 mediaTypes 之外的任何东西,于是模型写着「日志在 xxx」的那条路径只是一行死文字。现在它走目录的那条路(真实路径、kind file、不带 token),变成一个可点的 chip
  • 测试:frontend_output_chips_test.go、server_tool_shots_test.go、session_edit_shot_test.go、media_browser_e2e_test.go(每条折叠规则都单独验证过:去掉它,测试就以自己的理由变红)

GUI:会话管理与侧边栏

  • 删除一个从没打开过的会话:Management → Sessions 列的是磁盘上的会话,而删除处理要求它在本进程里打开着,于是除当前正在读的那一行之外,每一行的删除都静默无效。删除是磁盘操作,内存里的 map 只决定先关掉谁;拒绝现在只剩「这一轮正在跑」和「web 主体要动别人的 id」,而且拒绝与磁盘失败都会告诉用户,而不是让那一行毫无反应
  • 侧边栏 Search 旁新增可切换的会话名过滤条:大小写不敏感的子串、有序子序列模糊匹配、空格分隔的多条件 AND,作用在会话名与 id 上;空分组隐藏,折叠的分组在命中时临时展开且不改动持久化的 collapsed_groups,9 种语言的文案一并补齐
  • 自定义 agent 卡片也有了启用/停用开关:enabled 标志与 handleSetAgentEnabled 本来就在,只是卡片硬编码了 selected: true, canToggle: false。停用后隐藏「设为默认」、保留删除与卡片编辑,取消确认后重绘卡片,以免复选框停在错误状态
  • 语言文案:德语与西班牙语补齐残留英文(purpose_*、agent_name.coder、field_prompt_cache),俄语的 Space 统一为 пространство,de/es/fr/ja/ru 的 field_base_url 对齐到已本地化的「Base URL」

CLI、引擎与 provider

  • gal provider edit(别名 update / modify / set):用 --type、--base-url、--key、--key-env、--clear-key 改一个已存在的 provider,不碰它的 models、model_confs、fallback_models 与其它设置;不给参数就按当前值逐项交互,回车保持原值
  • TruncatePreview 在同时超出 maxChars 与 maxLines 时只截行、不截字符:二十几行日志或 JSON、每行上千字符,能在终端里一次倾泻几千字符。现在先按行截,再对结果执行 maxChars,两个预算始终同时成立
  • provider 聊天预设与 endpoint 品牌对齐:推荐兼容的产品端点而不改写已有配置,归一化聊天路径、统一图标匹配,并补上各家云服务的资源级配置说明

破坏性变更:--pipe 默认输出改为 JSON-RPC(精简版 ACP)

  • gal chat --pipe 的默认输出从纯文本 + ---END--- 分隔符改为每行一条 JSON-RPC 消息:stdin 接受 initialize / session/new / session/prompt / session/cancel,stdout 只输出 session/update 通知(agent_message_chunk、agent_thought_chunk、tool_call、tool_call_update)。方法名与字段名沿用 ACP,因此这就是一个精简版 ACP:session/list、session/resume、fs/*、terminal/*、session/request_permission 等一律不实现,并通过 capability 如实声明为 false
  • 迁移:需要旧行为的脚本加 --format raw(gal chat --pipe --format raw),其余语义不变。仓库内没有任何代码消费 ---END---,只有文档和 agent 提示词提到它,所以破坏面在外部脚本
  • 纯文本流的问题在于它无法区分「本轮结束」和「进程崩溃」、无法表达工具调用的结构化参数、无法把「失败」「超时」「被取消」分开(原来三者都是 stderr 上一行 ⚠ error: ...)。JSON 流把三者分成 stopReason: end_turn|cancelled|max_turn_requests 和带 data.reason 的 JSON-RPC error
  • gal chat -m "..." --format json 同样输出 JSON 帧,但因为命令行消息没有对应请求可回答,结尾用 GAL 扩展通知 gal/turn_end 收尾,而不是伪造一个响应
  • stdin 单行上限从 1 MiB 提升到 16 MiB:JSON 模式下一条 prompt 是一整行,此前的上限会让粘贴大段文本时 scanner 静默结束、进程看起来像是自己退出了
  • 引擎新增 OnToolCallFull 回调,把工具名和结构化参数交给调用方(原来的 ToolCallCallback 只给 80 字符的展示摘要);顺带把 agentic loop exceeded 改为可判定的 engine.ErrMaxRounds
  • 协议合规修正(面向写客户端的人):prompt 除 text 外接受 resource_link —— ACP 把它列为基线要求、且不受 promptCapabilities 门控,链接会作为引用行交给模型,由它自己用 file_read 取;session/new 只应答一次,第二次回 -32601 并指出本进程服务的 session,避免客户端以为拿到了两个独立会话(实际共用同一份上下文);initialize / session/new 若被当作通知发送则不应答(否则会在流里写出 id 为 null 的响应帧);超长行错误现在会说明是 16 MiB 上限被突破

面向 ACP 客户端的互操作修正(第三方接入实测)

  • 用官方 schema/v1/schema.json(ACP v1.35.0)逐帧校验了 pipe 模式的全部帧,并把三处「不是 schema 违规、但真客户端会踩」的地方修掉:
  • 工具失败现在上报 status: "failed":此前引擎把错误压成 "error: ..." 字符串,管道一律报 status: "completed",客户端会给一次失败的调用打绿勾。ToolResultFullCallback 因此多一个 failed 参数(内部回调,调用方只有管道本身),executeTool 改为返回带 failed 的 toolOutcome;panic 被兜住的那次调用同样算失败。顺带修正:工具自己的输出恰好以 error: 开头不会再被误判
  • mcpServers / additionalDirectories 不再拒绝整条会话:mcpServers 在 NewSessionRequest 里是必填字段,客户端没法「不发送」,此前只要用户配过一个 MCP 服务器,session/new 就直接 -32602、会话根本起不来。现在照常开会话,并在结果里用 _meta.gal.ignored(ACP 的扩展点)如实报告未接入的服务器/未激活的目录,stderr 同时记一行——既不静默降级,也不为一个字段丢掉整个会话。cwd 仍然拒绝:引擎的工具沙箱根目录在进程启动时就定了,接受别的 cwd 会让所有相对路径解析到错误的位置
  • session/prompt 被当作通知发送时不再写出 id: null 的响应帧:JSON-RPC 2.0 禁止响应通知,严格的客户端库会把这帧当格式错误;现在按 initialize/session/new/session/load 的同样方式忽略并记日志,这一轮不执行(它的回复无处可去)

--pipe 支持 session/load(ACP 会话切换)

  • 有了 session/load,客户端可以在同一条管道流里切换到另一个已有会话:会话 ID、会话锁、session.json、引擎、上下文库(memory.db)与 SessionDir 一并切换,切换后该会话的模型、能力覆盖(/caps)与工作目录记录都会被恢复
  • 重放按 ACP 要求在响应之前以 session/update 通知发出——响应本身就是「历史已经完了」的信号。只重放用户与模型文本,工具调用/结果不重放(那是到达回复的路径,不是对话本身,且体积往往大出数倍);超过 8 MiB 时保留开头并在 _meta.gal.replay 里给出 {replayed, total, truncated},不静默从中间开始
  • loadSession 能力由是否真的接了装载器推导,没有装载器(-m 模式)就声明为 false,不做「声明了但调不动」
  • 明确拒绝并各自说明原因:会话不存在(-32002)、被另一个 CLI 实例占用、agent 已删除或被禁用、会话记录的工作目录与当前进程不一致(一个进程只有一个工具沙箱根目录)。cwd 与 session/new 走同一套拒绝逻辑(mcpServers/additionalDirectories 按上一节改为接受并报告)。正在跑 turn 时也拒绝:否则切换后 session/cancel 指定的会话已经不存在,那一轮变成无法取消
  • 顺带把 TUI 的引擎替换逻辑 adoptEngine 抽成可复用的 adoptEngine(dst, cfg, newEng),管道模式与 TUI 共用一份字段搬运,避免新增引擎字段时两边漏掉一处

修复 bash 卡死导致「停止」停不下来、会话永远「运行中」

  • 根因:命令在后台留下一个进程(Start-Process、nohup、setsid、任何 daemon 化的脚本)时,该进程继承了本次调用的输出管道。cmd.Wait() 必须读到管道 EOF 才返回,而管道会一直开到那个后台进程退出为止,于是「启动服务然后返回」这类命令永远不返回。此时 shell 早已退出,停止按钮的 taskkill /T(Unix 上是进程组 kill)已经没有目标可杀:取消上下文、界面显示已停止,但 turn 永远结束不了——会话一直是「运行中」,切走再切回依旧在跑,其它操作全被 session is running 拒绝
  • 修复:直接执行路径给 exec.Cmd 设 WaitDelay(新增 tool.BackgroundIOWait,2s)。命令进程结束后最多再读 2s 输出,然后关掉管道返回。后台进程不会被杀掉——「让它活过这次调用」本身就是合法需求——结果标记为 [exit 0] 并附一行说明:命令已结束、它留下的进程仍在运行并持有输出,之后打印的内容不在这份结果里
  • 沙箱 agent(gal sandbox-agent)加同一个上界:此前它会在 Run 上永久阻塞,宿主等不到回复就按连接超时把整个沙箱丢弃,连同命名空间里其它后台进程一起被杀;ErrWaitDelay 在 agent 侧按「命令已完成」处理,不再被当成失败上报
  • 测试:TestACallReturnsWhenTheCommandLeavesAProcessRunning、TestStopEndsACallWhoseShellIsAlreadyGone、TestTheAgentDoesNotWaitForABackgroundProcess(去掉 WaitDelay 后各自变红:调用会等满后台进程的整个生命周期)

安装

下载对应平台的压缩包,用 checksums.txt 校验后运行(macOS CLI 可执行 install.sh)。