ai_co_discuss 0.5.11 → 0.5.12

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.
@@ -52,6 +52,8 @@ description: "AI CoDiscuss 的通用参与技能,所有参与者(包括主
52
52
 
53
53
  用请求者使用的语言回答,结论先行;篇幅与结构由你按问题决定。正文约 300 字以上或分多段时写摘要:给只听语音播报的人,约 15 秒念完(不超过约 80 字),用能直接念出口的话、不用列表和编号。
54
54
 
55
- 需要附件时先 `attachment upload ROOM --file FILE --submission-id 上传编号`,再 `message post --attachment ID`(最多 10 个,单个 20 MiB,须在执行资格结束前上传)。
55
+ **给人看的成品默认作为附件交付**:这次新建或改出、请求者要看或要拿走的结果(文档、表格、幻灯片、PDF、图片、音视频、单文件网页,或它们的打包),上传为附件,正文用 `[文件 #n]`(图片 `[图片 #n]`)引用;改了已交付的成品就附上新版。(附件随消息保存、卡片内直接预览,分享页、其他设备和外部成员都看得到;项目文件之后会变,也只有能读这台电脑的人看得到。)同时写进了项目的,正文再用反引号写出项目路径(如 `合同.docx`),回答下方会出现该文件的卡片。项目源码与配置的修改、中间产物和日志不附(执行卡片已显示文件差异),用户说了只放项目里的也不附。
56
+
57
+ 附件先 `attachment upload ROOM --file FILE --submission-id 上传编号`,再 `message post --attachment ID`(最多 10 个,单个 20 MiB,须在执行资格结束前上传)。
56
58
 
57
59
  提交后核对回执(消息编号、作者、执行或请求关联;正文只给 `text_chars` 字数),足够就不再读一遍。提交成功后在当前会话只回一句(如“已提交 #编号”),不复述正文。执行结束不等于房间的工作结束。
@@ -10,7 +10,7 @@
10
10
  | 未引用的附件 | 篇幅大、不必打断阅读的页面 | 回答下方的文件卡片,点“在消息内展开”或点开预览窗口才运行 |
11
11
  | 项目文件 | 要随项目保留、反复修改的页面 | 用户在“项目文件”里打开;按相对路径引用的样式、脚本、图片由电脑内联后一起显示 |
12
12
 
13
- 附件:`attachment upload ROOM --file 页面.html` 后 `message post --attachment ID`,见主技能“回答”。项目文件:写在任务 `cwd` 的项目里,正文写明路径,项目只读时改用附件。
13
+ 附件:`attachment upload ROOM --file 页面.html` 后 `message post --attachment ID`,见主技能“回答”;演示是给人看的成品,默认作为附件交付。项目文件:用户要它留在项目里时写在任务 `cwd` 的项目里,正文用反引号写明路径,同时仍附上附件。
14
14
 
15
15
  `[文件 #n]` 的 n 从 1 起,按本条消息 `--attachment` 的先后顺序数;提交后程序换成房间内的统一编号。
16
16
 
@@ -15,9 +15,9 @@ In the sidebar, select “New room”. To create one inside a folder, select the
15
15
  - Select “Add AI” to add members. Select the crown on a member card to make it the host.
16
16
  - Optionally configure “Smart scheduling”, “Image generation” (add an OpenAI Images card and enter an endpoint, API key, and image model; the lightning button on the back of the card checks the endpoint, key, and model without generating an image or incurring charges), and “Web search” (enter a DeepSeek API key shared across rooms).
17
17
  3. **“How to work (optional)”**
18
- - Optionally enable “Full host control”. This lets the host manage members, retry or interrupt work, start discussions and Goals, and save workflows. To allow only part of it, expand “Items” and tick just the ones you need.
19
18
  - Under “After creation”, choose “Off”, “Start discussion”, or “Start Goal”.
20
- 4. **“Advanced settings”** lets you set the “Assignment round limit” (10 by default, from 1 to 100 or unlimited) and “API request limit”.
19
+ - Optionally set “Auto-destroy” (see below).
20
+ 4. **“Advanced settings”**: optionally enable “Full host control”, which lets the host manage members, retry or interrupt work, start discussions and Goals, and save workflows (to allow only part of it, expand “Items” and tick just the ones you need); set the “Assignment round limit” (10 by default, from 1 to 100 or unlimited) and “API request limit”.
21
21
  5. Select “Create and connect”, “Create room” for an all-manual setup, “Create and start discussion”, or “Create and start Goal”, as applicable.
22
22
 
23
23
  Room name, project directory, and members are chosen for each room. Smart scheduling, collaboration settings, discussion and Goal limits, and continuous host-turn limits remember the last selection, even if you cancel room creation. If startup fails, a failed item remains in the sidebar. Select “Retry” in its menu to continue the same request without creating a duplicate room.
@@ -29,9 +29,9 @@ You can also send a message from the blank home page to create a room and send i
29
29
  - **Sort rooms.** Open the directory options in the top-right corner. Choose “Manual order” (drag items or use the arrow keys) or “Recent activity”.
30
30
  - **Folders.** Select “New folder” to group rooms by project. A folder can have a default project directory, which is used for new rooms created inside it. Its menu offers “Edit”, “Move up”, “Move down”, “Archive folder”, and “Remove folder”. You can remove just the folder or delete its rooms as well.
31
31
  - **Room actions.** Open a room’s menu to “Rename”, “Edit topic”, “Move to folder”, “Copy reading link”, “Refresh messages”, “Archive room”, or “Destroy room”. “Edit topic” and “Refresh messages” apply to the currently open room.
32
- - **Destroy a room.** Select “Destroy room” in the room’s menu. The dialog lists what is deleted and what is kept. You can first select “Export package” to download a copy with messages, private chats, attachments, a “讨论记录.html” page that opens with a double click, and the files members wrote in their draft folders (in “草稿”; beyond 50 MB only their names are listed). After “Destroy now” and then “Destroy” in “Confirm destroying again” (every way of destroying asks twice), the room’s records, attachments, the AI sessions its members started in this room, and its run files and drafts are deleted from this computer: the dialog closes, a notice says the room is being destroyed and it dims in the sidebar. Once every item is checked, the room dissolves into particles and a notice shows what was removed. The draft folder made when the room was created (under “Drafts” in “Project”) is deleted with its files too; the package keeps them in “草稿空间”. A project folder you chose is not deleted. Sessions taken over from your own windows or shared with other rooms are kept. Content already sent to model providers stays under their policies and cannot be deleted from here. A published share page is taken down first. If an item cannot be removed yet, the room stays dimmed in the sidebar and you can select “Retry” in the dialog. Files in members’ draft folders are deleted with the room; export the package first if you need them.
32
+ - **Destroy a room.** Select “Destroy room” in the room’s menu. The dialog lists what is deleted and what is kept. You can first select “Export package” to download a copy with messages, private chats, attachments, a “讨论记录.html” page that opens with a double click, and the files members wrote in their draft folders (in “草稿”; beyond 50 MB only their names are listed). After “Destroy now” and then “Destroy” in “Confirm destroying again” (every way of destroying asks twice), the room’s records, attachments, the AI sessions its members started in this room, and its run files and drafts are deleted from this computer: the room dissolves into particles at once (its sidebar row, and the middle pane when it is open) while deletion and checks go on in the background; a notice shows what was removed when they finish. The draft folder made when the room was created (under “Drafts” in “Project”) is deleted with its files too; the package keeps them in “草稿空间”. A project folder you chose is not deleted. Sessions taken over from your own windows or shared with other rooms are kept. Content already sent to model providers stays under their policies and cannot be deleted from here. A published share page is taken down first. If an item cannot be removed yet, a notice says so and you can follow and retry it in “Destruction records”. Files in members’ draft folders are deleted with the room; export the package first if you need them.
33
33
  - **Destruction records and destroying all rooms.** Open “…” at the top right of the room list and select “Destruction records” to see what each destruction deleted and kept (the room name is cleared once it finishes). Select “Retry” on an unfinished one. “Destroy all rooms” at the bottom asks you to type a confirmation word, then destroys every room, archived ones included, one by one; project files are kept. A hosted account running as its own Windows user then also deletes every conversation in its AI software and the preferences the AI remembered, keeping logins. “Export all rooms” leaves drafts out; export rooms one at a time to include them.
34
- - **Auto-destroy.** Choose it under “Advanced settings” when creating a room, or later in the “Room” tab at the top of the room, set “Auto-destroy” to destroy the room after 1, 7, or 30 days without activity; the time left is shown beside it. The count starts when you set it and restarts with each new message or private chat. Archived rooms, rooms with members at work or queued work, an open question for you, or a published share page are not destroyed automatically. The page warns once when less than a day is left, and again after a room is destroyed. The default is “Keep”.
34
+ - **Auto-destroy.** Choose it under “How to work (optional)” when creating a room, or later in the “Room” tab at the top of the room, set “Auto-destroy” to destroy the room after 1, 7, or 30 days without activity; the time left is shown beside it. The count starts when you set it and restarts with each new message or private chat. Archived rooms, rooms with members at work or queued work, an open question for you, or a published share page are not destroyed automatically. The page warns once when less than a day is left, and again after a room is destroyed. The default is “Keep”.
35
35
  - **Restore or clear archived rooms.** Open “Archived”. Filter by keyword or whether rooms contain messages. Select “Restore” to return a room to the active list. To delete one permanently, select “Delete for good” and confirm. “Delete all” applies to the current filtered results.
36
36
 
37
37
  ### 3. Set project directories and browse project files
@@ -15,9 +15,9 @@
15
15
  - 点“添加 AI”加入成员,点卡片上的皇冠指定主持人。
16
16
  - 按需配置下方的“智能调度”、“生图”(添加“OpenAI Images”卡片并填地址、API Key 和图片模型;点卡片背面的闪电按钮可检查地址、密钥与模型,不生成图片、不计费)以及“联网搜索”(填 DeepSeek API Key,所有房间共用)。
17
17
  3. **“协作方式(可选)”**
18
- - 按需勾选“主持人完整权限”,允许主持人自行管理成员、重试或打断执行、开启讨论与 Goal 及保存工作流。不想全部放开时,展开“具体权限”只勾选需要的几项。
19
18
  - 在“创建后”选择“不开启”、“开启讨论”或“开启 Goal”。
20
- 4. **展开“高级设置”**:调整“连续派活上限”(默认 10 轮,可设 1–100 轮或不限)和“API 请求上限”。
19
+ - 按需设置“自动销毁”(见下文)。
20
+ 4. **展开“高级设置”**:按需勾选“主持人完整权限”,允许主持人自行管理成员、重试或打断执行、开启讨论与 Goal 及保存工作流,不想全部放开时展开“具体权限”只勾选需要的几项;调整“连续派活上限”(默认 10 轮,可设 1–100 轮或不限)和“API 请求上限”。
21
21
  5. 按所选方式点“创建并连接”“创建协作房间”“创建并开启讨论”或“创建并开启 Goal”,进入新房间。
22
22
 
23
23
  话题名称、项目目录和本次成员每次重新填写;智能调度、协作方式、讨论与 Goal 上限、连续派活轮数会自动记住上一次选择(取消建房也保留)。如果启动失败,左栏会留一条失败记录,点菜单里的“重试”可沿用原请求继续,不会重复建房。
@@ -29,9 +29,9 @@
29
29
  - **排序**:点目录右上角选项,在“手动排序”(拖动或用上下方向键调序)和“最近发言”之间切换。
30
30
  - **文件夹**:点“新建文件夹”按项目归集房间,可为文件夹设置默认项目目录,之后在该文件夹里建房会自动带入。点文件夹菜单可“编辑”、“上移”、“下移”、“存档文件夹”或“移除文件夹”(可选择仅移除文件夹,或连同其中房间一并删除)。
31
31
  - **房间操作**:点房间右侧菜单,可以“重命名”、“编辑议题”、“移至文件夹”、“复制阅读入口”、“刷新消息”、“存档房间”或“销毁房间”。“编辑议题”和“刷新消息”用于当前打开的房间。
32
- - **销毁房间**:在房间菜单点“销毁房间”。确认框列出会删除和保留的内容,可先点“导出资料包”下载一份:含消息、私聊、附件、可双击打开的“讨论记录.html”,以及成员写在草稿目录里的文件(“草稿”文件夹,超过 50 MB 的部分只列出文件名)。点“立即销毁”,再在“再次确认销毁”里点“确认销毁”后(所有销毁入口都要这样确认两次),这台电脑上的房间记录、附件、成员在本房间新建的 AI 会话记录、运行文件和草稿会被删除:确认框随即关闭,右下角提示正在销毁,房间在左栏变暗;全部核验通过后,房间化成粒子消散,右下角显示删除了多少。建房时自动创建的草稿文件夹(左侧“项目”里的“草稿”)连同其中文件也会删除,资料包里放在“草稿空间”文件夹;你选的项目文件夹不会删除;沿用你原有窗口的会话、与其他房间共用的会话会保留;已发给模型服务商的内容按其政策保留,无法从这里删除。房间发布过分享网页时,销毁前会先撤销它。某项暂时没删掉时,房间会变暗留在左栏,可在确认框点“重试”。成员草稿目录里的文件会随房间删除,需要的先导出资料包。
32
+ - **销毁房间**:在房间菜单点“销毁房间”。确认框列出会删除和保留的内容,可先点“导出资料包”下载一份:含消息、私聊、附件、可双击打开的“讨论记录.html”,以及成员写在草稿目录里的文件(“草稿”文件夹,超过 50 MB 的部分只列出文件名)。点“立即销毁”,再在“再次确认销毁”里点“确认销毁”后(所有销毁入口都要这样确认两次),这台电脑上的房间记录、附件、成员在本房间新建的 AI 会话记录、运行文件和草稿会被删除:房间立即化成粒子消散(左栏那一行和打开着的中间区域一起),删除与核验在后台继续,全部完成后右下角显示删除了多少。建房时自动创建的草稿文件夹(左侧“项目”里的“草稿”)连同其中文件也会删除,资料包里放在“草稿空间”文件夹;你选的项目文件夹不会删除;沿用你原有窗口的会话、与其他房间共用的会话会保留;已发给模型服务商的内容按其政策保留,无法从这里删除。房间发布过分享网页时,销毁前会先撤销它。某项暂时没删掉时,右下角会提示,可在“销毁记录”里查看并重试。成员草稿目录里的文件会随房间删除,需要的先导出资料包。
33
33
  - **销毁记录与销毁全部房间**:点左栏房间目录右上角“…”里的“销毁记录”,查看每次销毁删除了什么、保留了什么(房间名在完成后清除),未完成的可点“重试”。底部“销毁全部房间”须输入“销毁全部”确认,会逐个销毁全部房间(含已存档),项目文件保留;以独立 Windows 用户运行的托管账号随后还会删除各 AI 软件里的全部会话记录和 AI 记住的偏好,登录信息保留。“导出全部房间”不含草稿,需要草稿请逐个房间导出。
34
- - **自动销毁**:新建房间时在“高级设置”里选,或之后在房间顶部的“房间”页,把“自动销毁”设为无活动 1 天、7 天或 30 天后销毁,旁边显示还剩多久;从设定时起算,房间里有新消息或私聊会重新计时;已存档、有成员在工作或排队、有待你回答的提问、发布着分享网页的房间不会自动销毁。剩余不足一天时网页会提示一次,销毁后也会提示。默认“长期保留”。
34
+ - **自动销毁**:新建房间时在“协作方式(可选)”里选,或之后在房间顶部的“房间”页,把“自动销毁”设为无活动 1 天、7 天或 30 天后销毁,旁边显示还剩多久;从设定时起算,房间里有新消息或私聊会重新计时;已存档、有成员在工作或排队、有待你回答的提问、发布着分享网页的房间不会自动销毁。剩余不足一天时网页会提示一次,销毁后也会提示。默认“长期保留”。
35
35
  - **恢复与清理存档**:打开“已存档”,按关键词或有无消息筛选,对选中房间点“恢复”放回活跃列表,单个房间点“彻底删除”并确认;“全部删除”针对当前筛选结果。
36
36
 
37
37
  ### 3. 设置多个项目目录并浏览项目文件
@@ -534,6 +534,5 @@
534
534
  "房间已建好,但自动销毁没有设置成功,可在“房间”页重新设置:{value1}": "The room was created, but auto-destroy could not be set; set it again in the “Room” tab: {value1}",
535
535
  "这个文件夹有 {count} 个文件、共 {size},超过一次下载的上限({files} 个文件、{limit});请下载其中的子文件夹。": "This folder has {count} files, {size} in all, more than one download takes ({files} files, {limit}); download its subfolders instead.",
536
536
  "已读取 {done} / {count} 个文件": "Read {done} of {count} files",
537
- "正在销毁「{name}」:记录与附件已删除,其余各项核验完成后房间会消散。": "Destroying “{name}”: records and attachments are deleted; the room dissolves once the remaining items are checked.",
538
537
  "「{name}」还在清理,可在房间目录“…”里的“销毁记录”查看进度或重试。": "“{name}” is still being cleaned up; follow it or retry under “Destruction records” in the room list's “…” menu."
539
538
  }
@@ -174,8 +174,6 @@
174
174
  "请至少添加一位成员。同一平台可添加多位,各自独立会话。": "Add at least one member. The same platform can be added several times, each with its own session.",
175
175
  "协作方式(可选)": "How to work (optional)",
176
176
  "创建后": "After creation",
177
- "派活 {value}": "Assign {value}",
178
- "API {value}": "API {value}",
179
177
  "{count} 次": "{count} requests",
180
178
  "建房后可在房间页修改。": "Can be changed on the room page later.",
181
179
  "还差:{reason}": "Still needed: {reason}",
@@ -59,7 +59,7 @@
59
59
  "主持人完整权限": "Full host control",
60
60
  "主持人权限": "Host permissions",
61
61
  "主持人部分权限": "Partial host control",
62
- "主持人可自行处理问题、持续推进;可只勾选下面的一部分。成员项目权限最高可写。": "The host handles problems and keeps work moving by itself; you can tick only some of the items below. Members get write access to the project at most.",
62
+ "主持人自行处理问题、持续推进;给成员的项目权限最高可写。": "The host handles problems and keeps work moving; it can give members write access at most.",
63
63
  "具体权限(已选 {count} / {total})": "Items ({count} of {total} selected)",
64
64
  "处理执行问题": "Handle execution problems",
65
65
  "停止、插话、重试成员,撤回自己派出的活": "Stop, steer or retry members, and withdraw work it dispatched",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -712,15 +712,28 @@ export function sweep_legacy_agy_projects(service_home, user_home = homedir()) {
712
712
  // Signed out or the account switched (room #3203: "Eligibility check failed: UNAUTHENTICATED (401)"; the sign-in prompt
713
713
  // timing out headless, "authentication failed or timed out"): only signing agy in again on this computer helps.
714
714
  const AGY_SIGNED_OUT = /\bUNAUTHENTICATED\b|\bauthentication (?:failed|required|timed out)\b/i;
715
+ // agy also asks to sign in when it failed to load a stored sign-in on a flaky network, while the account still works
716
+ // (room 拾光咖啡App, execution #5258). No one signs in headless, so the prompt is not waited out (60 s): the process is
717
+ // stopped at once and started again before it is reported as `auth`.
718
+ const AGY_SIGN_IN_PROMPT = /\bAuthentication required\b/;
719
+ const AGY_SIGN_IN_STOPPED = 'Antigravity CLI ERROR:authentication required (sign-in prompt in a headless run, not waited for)';
720
+ const AGY_SIGN_IN_TIMED_OUT = /\bauthentication (?:required \(sign-in prompt|(?:failed or )?timed out\b)/i;
721
+
722
+ /** Stop agy as soon as it asks to sign in; see AGY_SIGN_IN_PROMPT. */
723
+ function abandon_sign_in(state, text) {
724
+ if (AGY_SIGN_IN_PROMPT.test(text)) state.abandon = AGY_SIGN_IN_STOPPED;
725
+ }
715
726
 
716
727
  /**
717
728
  * How a failed agy turn is classified for the room (adapter contract `on_failure(reason, {failure_class, resets,
718
- * reset_at})`, as Claude's): a signed-out account is `auth`, an exhausted account quota `quota`. agy says when it resets as a duration from now
729
+ * reset_at})`, as Claude's): a signed-out account is `auth` (`restartable` when it may be a sign-in that failed to
730
+ * load, so the CLI framework starts it again at once first), an exhausted account quota `quota`. agy says when it resets as a duration from now
719
731
  * ("Individual quota reached. … Resets in 141h35m10s.", 1.5.x, room #3327): `reset_at` is now plus that duration in
720
732
  * Unix seconds, and `resets` the same moment as a local time, since the failure is shown long after. Anything else
721
733
  * stays unclassified.
722
734
  */
723
735
  export function agy_failure_class(reason, now = new Date()) {
736
+ if (AGY_SIGN_IN_TIMED_OUT.test(String(reason))) return { failure_class: 'auth', restartable: true };
724
737
  if (AGY_SIGNED_OUT.test(String(reason))) return { failure_class: 'auth' };
725
738
  if (!/\bquota reached\b/i.test(String(reason))) return {};
726
739
  const match = /\bResets in\s+(?:(\d+)h)?\s*(?:(\d+)m)?\s*(?:(\d+)s)?/i.exec(reason);
@@ -744,7 +757,7 @@ export const antigravity_cli = {
744
757
  // A deleted room's session records and any legacy private agy projects are removed with it.
745
758
  cleanup: remove_agy_projects, sweep: sweep_legacy_agy_projects,
746
759
  deliver,
747
- invocation, lifecycle, events, failure_class: reason => agy_failure_class(reason),
760
+ invocation, lifecycle, events, failure_class: reason => agy_failure_class(reason), on_stderr: abandon_sign_in,
748
761
  session: { path: session_path, exists: session_exists, owns: session_exists, branch, settings: session_settings,
749
762
  list: list_sessions, preview: preview_session,
750
763
  remove: (id, { home = homedir() } = {}) => remove_conversation(join(home, '.gemini', 'antigravity-cli'), id),
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * One headless CLI turn, shared by the CLI adapters (Codex CLI, agy CLI). The adapter supplies what differs:
3
3
  * `invocation(config, binding, task, user_home)` → `{args, input?, check?, on_session?, executable?, steer?}`, `lifecycle(state, event, task, bind)`
4
- * for its documented events, `events` for progress (and optionally `events.edits(event)` for files edited with the agent's own tools), and optionally `on_stderr(state, text)` and `exit_error(state)`.
4
+ * for its documented events, `events` for progress (and optionally `events.edits(event)` for files edited with the agent's own tools), and optionally `on_stderr(state, text)` (setting `state.abandon` to a reason stops a CLI that waits before any turn, as not started) and `exit_error(state)`.
5
5
  * `executable` runs another program in place of the software (a bridge to it); `steer(text)` → the stdin line that passes
6
6
  * an interjection into the running turn, and with it stdin stays open after `input` and the delivery can be steered.
7
7
  */
@@ -56,8 +56,16 @@ function monitor_cli(adapter, child, binding, task, restart) {
56
56
  state.limit_timer = setTimeout(() => { state.error = cli_timeout_reason(max_run_ms); child.kill(); }, max_run_ms);
57
57
  child.stdout.on('data', chunk => task.on_output(log_path, chunk));
58
58
  child.stderr.setEncoding('utf8');
59
+ // Stops the process without marking it stopped by the runner, so a restart is still allowed.
60
+ const own_kill = child.kill.bind(child);
61
+ // Plain text output (stderr, and stdout lines that are not JSON) goes to the adapter's `on_stderr`.
62
+ const watch_text = text => {
63
+ adapter.on_stderr?.(state, text);
64
+ // `abandon`: the adapter saw the CLI wait before any turn for something no one does headless (a sign-in prompt).
65
+ if (state.abandon && !state.error) { state.error = state.abandon; state.not_started = true; own_kill(); }
66
+ };
59
67
  child.stderr.on('data', chunk => {
60
- adapter.on_stderr?.(state, state.diagnostic + chunk);
68
+ watch_text(state.diagnostic + chunk);
61
69
  state.diagnostic = (state.diagnostic + chunk).slice(-CLI_DIAGNOSTIC_CHARS).trim();
62
70
  task.on_output(log_path, chunk);
63
71
  });
@@ -65,7 +73,7 @@ function monitor_cli(adapter, child, binding, task, restart) {
65
73
  if (!line.trim()) return;
66
74
  let event;
67
75
  try { event = JSON.parse(line); }
68
- catch { state.diagnostic = 'CLI 输出中存在无效 JSON,详情见本机日志'; return; }
76
+ catch { state.diagnostic = 'CLI 输出中存在无效 JSON,详情见本机日志'; watch_text(line); return; }
69
77
  trace_cli_event(event, task);
70
78
  const phase = adapter.events.phase(event);
71
79
  if (phase) task.on_activity?.(phase, adapter.events.tool(event), adapter.events.call?.(event));
@@ -82,9 +90,10 @@ function monitor_cli(adapter, child, binding, task, restart) {
82
90
  if (!state.spawned) return;
83
91
  if (state.denials.length) task.on_denials?.(state.denials);
84
92
  const error = cli_exit_error(adapter, state, code, signal);
85
- // The adapter's classification of the failure (`quota` with when it resets); a lasting one is never started again.
86
- const failure = error ? adapter.failure_class?.(error, state) || {} : {};
87
- if (error && state.not_started && !state.stopped && !failure.failure_class && restart?.()) return;
93
+ // The adapter's classification of the failure (`quota` with when it resets); a lasting one is never started again,
94
+ // unless the adapter marks it `restartable` (it may be passing), and is reported once the restarts are used up.
95
+ const { restartable, ...failure } = error ? adapter.failure_class?.(error, state) || {} : {};
96
+ if (error && state.not_started && !state.stopped && (!failure.failure_class || restartable) && restart?.()) return;
88
97
  // `not_started`: the adapter saw the CLI fail before any turn ran, so the runner may deliver the same task again.
89
98
  if (error) task.on_failure(error, { not_started: Boolean(state.not_started) && !failure.failure_class,
90
99
  ...(failure.failure_class ? { retryable: false, ...failure } : {}) });
package/web/app.js CHANGED
@@ -72,9 +72,8 @@ const RESUME_LOADING_MAX_MS = 15000;
72
72
  const TOAST_DURATION_MS = 3500;
73
73
  // How long an archived room can be taken back before the archive is saved.
74
74
  const ARCHIVE_UNDO_MS = 4000;
75
- // The destroy effect: how long the confirmation takes to close, the wave across the element, each particle's random start and fade,
75
+ // The destroy effect: the wave across the element, each particle's random start and fade,
76
76
  // the grain size in CSS pixels, about how many grains it keeps at most, and how many elements and text lines it draws at most.
77
- const DESTROY_DIALOG_CLOSE_MS = 250;
78
77
  // After this long still cleaning, a destroy says where to follow it.
79
78
  const DESTROY_SLOW_MS = 20_000;
80
79
  const DUST_WAVE_MS = 650;
@@ -926,29 +925,45 @@ async function reorder_channel(id, before_id) {
926
925
  async function delete_channel(id) {
927
926
  const room = state.rooms.find(item => item.id === id);
928
927
  if (!room || state.destroying.has(id)) return;
929
- const key = `delete:${id}`;
930
- state.directory_pending.set(key, {});
931
- publish_view();
928
+ const index = state.rooms.indexOf(room);
929
+ // The room dissolves at once (UI first); its deletion and checks go on behind, and a refusal brings it back.
930
+ state.destroying.set(id, { room, index });
931
+ const dissolving = dissolve_room(id);
932
932
  try {
933
933
  if (share_link(id)) await take_down_share(id);
934
934
  const result = await request_json(`/api/rooms/${id}/delete`, { actor: "用户" });
935
- state.destroying.set(id, { room, index: state.rooms.indexOf(room) });
936
935
  if (result.destruction) merge_destruction(result.destruction);
937
- notify("info", t('正在销毁「{name}」:记录与附件已删除,其余各项核验完成后房间会消散。', { name: room.title }));
938
936
  // A cleanup that takes long says where to follow it, once.
939
937
  setTimeout(() => {
940
938
  if (state.destroying.has(id)) notify("warning", t('「{name}」还在清理,可在房间目录“…”里的“销毁记录”查看进度或重试。', { name: room.title }));
941
939
  }, DESTROY_SLOW_MS);
942
940
  } catch (error) {
941
+ await dissolving;
942
+ state.destroying.delete(id);
943
+ if (!state.rooms.some(item => item.id === id)) state.rooms.splice(Math.min(index, state.rooms.length), 0, room);
944
+ render_rooms();
945
+ publish_view();
943
946
  notify_failure(error, t('「{value1}」销毁失败,房间未改变:{value2}', { value1: room.title, value2: management_error_message(id, error) }));
944
947
  throw error;
945
- } finally {
946
- state.directory_pending.delete(key);
947
- publish_view();
948
948
  }
949
+ await dissolving;
949
950
  settle_destructions();
950
951
  }
951
952
 
953
+ /** Play the destroy effect on the room's row, and on the middle pane when it is open, then take it off the page. */
954
+ async function dissolve_room(id) {
955
+ // Wait one frame so the confirmation has begun to close; the effect draws the page itself, not what covers it.
956
+ await new Promise(resolve => requestAnimationFrame(resolve));
957
+ const row = document.querySelector(`[data-drag-room="${CSS.escape(id)}"]`);
958
+ const targets = [row, state.room?.id === id ? document.querySelector(".channel-main") : null].filter(Boolean);
959
+ await Promise.all(targets.map(dust_away));
960
+ state.rooms = state.rooms.filter(item => item.id !== id);
961
+ if (state.room?.id === id) await select_room(visible_rooms()[0]?.id);
962
+ for (const target of targets) target.style.visibility = "";
963
+ render_rooms();
964
+ publish_view();
965
+ }
966
+
952
967
  /** Set how many days without a message a room may stay before it destroys itself; 0 keeps it. */
953
968
  async function set_auto_destroy(id, days) {
954
969
  await request_json(`/api/rooms/${id}/auto-destroy`, { actor: "用户", days });
@@ -998,13 +1013,9 @@ function merge_destruction(record) {
998
1013
  state.destructions = [record, ...state.destructions.filter(item => item.room_id !== record.room_id)];
999
1014
  }
1000
1015
 
1001
- /** Keep rooms still being destroyed in the list the website no longer has them in, where they were. */
1016
+ /** Leave out rooms being destroyed: they dissolved already, though a read begun before may still list them. */
1002
1017
  function with_destroying(rooms) {
1003
- const result = [...rooms];
1004
- for (const [id, { room, index }] of state.destroying) {
1005
- if (!result.some(item => item.id === id)) result.splice(Math.min(index, result.length), 0, room);
1006
- }
1007
- return result;
1018
+ return rooms.filter(room => !state.destroying.has(room.id));
1008
1019
  }
1009
1020
 
1010
1021
  /** Retry the website's part of an unfinished destruction (a held attachment file, a busy log). */
@@ -1013,30 +1024,19 @@ async function retry_destruction(id) {
1013
1024
  settle_destructions();
1014
1025
  }
1015
1026
 
1016
- /** Dissolve each room whose receipt is complete and tell what was removed. */
1027
+ /** Tell what was removed for each room whose receipt is complete. */
1017
1028
  function settle_destructions() {
1018
1029
  for (const [id, { room }] of state.destroying) {
1019
1030
  const record = state.destructions.find(item => item.room_id === id);
1020
1031
  if (record?.status !== "done") continue;
1021
1032
  state.destroying.delete(id);
1022
- finish_destroyed_room(id, room, record).catch(error => notify("error", error.message));
1033
+ announce_receipt(room, record);
1023
1034
  }
1024
1035
  publish_view();
1025
1036
  }
1026
1037
 
1027
- /** Play the destroy effect on what shows the room (its open conversation, else its list row), then drop it. */
1028
- async function finish_destroyed_room(id, room, record) {
1029
- // Let the confirmation dialog close first, so the effect plays on the page itself.
1030
- await new Promise(resolve => setTimeout(resolve, DESTROY_DIALOG_CLOSE_MS));
1031
- // The room's row always dissolves; an open room's middle pane dissolves with it.
1032
- const row = document.querySelector(`[data-drag-room="${CSS.escape(id)}"]`);
1033
- const targets = [row, state.room?.id === id ? document.querySelector(".channel-main") : null].filter(Boolean);
1034
- await Promise.all(targets.map(dust_away));
1035
- state.rooms = state.rooms.filter(item => item.id !== id);
1036
- if (state.room?.id === id) await select_room(visible_rooms()[0]?.id);
1037
- for (const target of targets) target.style.visibility = "";
1038
- render_rooms();
1039
- publish_view();
1038
+ /** One notice of what a finished destruction removed and kept. */
1039
+ function announce_receipt(room, record) {
1040
1040
  const count = kind => record.items.filter(item => item.kind === kind).reduce((total, item) => total + (item.count || 0), 0);
1041
1041
  const removed = t('已销毁「{name}」:删除 {messages} 条消息、{files} 个附件、{sessions} 个 AI 会话记录。',
1042
1042
  { name: room.title, messages: count("messages"), files: count("attachments"), sessions: count("sessions") });