ai_co_discuss 0.4.82 → 0.4.84

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.
@@ -14,7 +14,7 @@ import time
14
14
  from datetime import datetime, timezone
15
15
 
16
16
  from . import free_room
17
- from .identity import AI_PLATFORMS, MAX_ROOM_AGENTS, is_ai
17
+ from .identity import AI_PLATFORMS, MAX_ROOM_AGENTS, PLATFORM_NICKNAMES, is_ai
18
18
  from .runtime import begin_write, require_owner, token_hash
19
19
  from .texts import Text, text_payload
20
20
 
@@ -290,10 +290,7 @@ def create_external(connection, room_id, token, payload, now):
290
290
  if duration not in ("1h", "today", "3d", "7d", "30d"):
291
291
  raise ValueError(Text("外部成员不存在"))
292
292
  connection.execute("UPDATE external_members SET claimed_at=0,invite_duration=? WHERE member_id=?", (duration, cursor.lastrowid))
293
- suffix = name.removeprefix("Custom-ext") if name.startswith("Custom-ext") else f"-{cursor.lastrowid}"
294
- connection.execute("""INSERT INTO member_labels(room_id,name,label,updated_at) VALUES(?,?,?,?)
295
- ON CONFLICT(room_id,name) DO UPDATE SET label=excluded.label,updated_at=excluded.updated_at""",
296
- (room_id, name, str(Text("另一台电脑{suffix}", suffix=suffix)), now))
293
+ save_label(connection, room_id, name, pending_label(name, cursor.lastrowid), now)
297
294
  free_room.queue_invited_expert(connection, room_id, name, now)
298
295
  free_room.sync_participants(connection, room_id)
299
296
  row = external_row(connection, room_id, cursor.lastrowid)
@@ -358,6 +355,7 @@ def seat_action(connection, row, payload, now):
358
355
  save_ai(connection, row["id"], payload, now)
359
356
  connection.execute("UPDATE external_members SET machine=?,machine_label=?,token_hash=?,expires_at=? WHERE member_id=?",
360
357
  (machine, label, hashed, expiry, row["id"]))
358
+ name_joined(connection, row, now)
361
359
  elif action == "activate":
362
360
  if not row["machine"]:
363
361
  raise FileExistsError(Text("外部成员不存在"))
@@ -369,6 +367,36 @@ def seat_action(connection, row, payload, now):
369
367
  return owner_view(connection, external_row(connection, row["room_id"], row["id"]))
370
368
 
371
369
 
370
+ def pending_label(name, member_id):
371
+ """The name a seat goes by until someone joins it: 外部专家, 外部专家2 … (the suffix of Custom-ext, Custom-ext2 …)."""
372
+ suffix = name.removeprefix("Custom-ext") if name.startswith("Custom-ext") else f"-{member_id}"
373
+ return str(Text("外部专家{suffix}", suffix=suffix))
374
+
375
+
376
+ def save_label(connection, room_id, name, label, now):
377
+ """Set one member's display label; its member name (ID) stays as it is."""
378
+ connection.execute("""INSERT INTO member_labels(room_id,name,label,updated_at) VALUES(?,?,?,?)
379
+ ON CONFLICT(room_id,name) DO UPDATE SET label=excluded.label,updated_at=excluded.updated_at""", (room_id, name, label, now))
380
+
381
+
382
+ def name_joined(connection, row, now):
383
+ """On first joining, a seat still under its pending name takes its AI's (外部 Claude, 外部 Claude2 …).
384
+
385
+ A name the owner gave is kept, and so is the pending one when the AI is unknown or a custom API, which has no
386
+ name of its own. Only the label changes; the member name that requests and records use stays.
387
+ """
388
+ platform = connection.execute("SELECT platform FROM external_members WHERE member_id=?", (row["id"],)).fetchone()[0]
389
+ current = free_room.member_labels(connection, row["room_id"]).get(row["name"])
390
+ legacy = "另一台电脑" + row["name"].removeprefix("Custom-ext")
391
+ if platform in ("", "Custom") or current not in (pending_label(row["name"], row["id"]), legacy):
392
+ return
393
+ nickname = PLATFORM_NICKNAMES.get(platform, platform)
394
+ taken = set(free_room.member_display_names(connection, row["room_id"]).values())
395
+ label = next(candidate for number in range(1, MAX_ROOM_AGENTS + 2)
396
+ if (candidate := f"外部 {nickname}{number if number > 1 else ''}") not in taken)
397
+ save_label(connection, row["room_id"], row["name"], label, now)
398
+
399
+
372
400
  def list_reads(connection, room_id, member_id, token, params):
373
401
  """The owner reads one external member's read records in order."""
374
402
  require_owner(connection, room_id, token)
@@ -557,6 +585,9 @@ def external_api(connection, parts, params, method, token, read_payload, hooks):
557
585
  if method == "GET" and route == ["view"]:
558
586
  return member_room_view(connection, room_id, member), 200
559
587
  if method == "GET" and route == ["messages"]:
588
+ # "Requests naming me" follows the room's records: the text says the name the owner gave it, not its member ID.
589
+ if reading.get("mention") == member["name"]:
590
+ reading = {**{key: value for key, value in reading.items() if key != "mention"}, "requested_of": member["id"]}
560
591
  return hooks["messages"](connection, room_id, reading, token), 200
561
592
  if method == "GET" and len(route) == 2 and route[0] == "messages" and route[1].isdigit():
562
593
  return hooks["message"](connection, room_id, int(route[1]), reading, token), 200
@@ -17,6 +17,8 @@ MAX_ROOM_AGENTS = 12
17
17
  INSTANCE_PATTERN = re.compile(rf"({'|'.join(AI_PLATFORMS)})(?:-[0-9A-Za-z_]{{1,{MAX_INSTANCE_SUFFIX}}})?")
18
18
  # The name people and AIs call a platform when it differs from its ID; web/app.js PLATFORM_IDENTITIES shows the same.
19
19
  PLATFORM_NICKNAMES = {"Antigravity": "Gemini", "Custom": "自定义 API"}
20
+ # What a joined external member is called after (外部 Claude); a custom API keeps its pending name.
21
+ JOINED_NICKNAMES = {PLATFORM_NICKNAMES.get(platform, platform) for platform in AI_PLATFORMS if platform != "Custom"}
20
22
 
21
23
 
22
24
  def is_ai(name):
@@ -44,8 +46,16 @@ def default_label(name):
44
46
 
45
47
  def default_label_text(name, label):
46
48
  """Return display metadata only for the unchanged Custom platform nickname."""
47
- if name.startswith("Custom-ext") and label == "另一台电脑" + name.removeprefix("Custom-ext"):
48
- return text_payload(Text("另一台电脑{suffix}", suffix=name.removeprefix("Custom-ext")))
49
+ if name.startswith("Custom-ext"):
50
+ suffix = name.removeprefix("Custom-ext")
51
+ if label == "外部专家" + suffix:
52
+ return text_payload(Text("外部专家{suffix}", suffix=suffix))
53
+ # Rooms invited before the pending name was renamed keep the label stored then.
54
+ if label == "另一台电脑" + suffix:
55
+ return text_payload(Text("另一台电脑{suffix}", suffix=suffix))
56
+ joined = re.fullmatch(r"外部 (\S+?)(\d*)", label or "")
57
+ if joined and joined[1] in JOINED_NICKNAMES:
58
+ return text_payload(Text("外部 {ai}{suffix}", ai=joined[1], suffix=joined[2]))
49
59
  if platform_of(name) == "Custom" and label == default_label(name):
50
60
  return text_payload(Text("自定义 API{suffix}", suffix=name[len("Custom"):]))
51
61
  return None
package/backend/server.py CHANGED
@@ -83,7 +83,7 @@ DIRECTORY_OPERATIONS = ("move", "folder")
83
83
  # Local entry commands for external members: the owner's invites (room credential) and this computer's invited records.
84
84
  INVITE_COMMANDS = ("room-invite", "room-invites", "room-invite-revoke")
85
85
  INVITED_COMMANDS = ("invited-list", "invited-join", "invited-trust", "invited-ai", "invited-pause", "invited-approve", "invited-refuse",
86
- "invited-leave", "invited-room")
86
+ "invited-leave", "invited-remove", "invited-room")
87
87
  ADMIN_OPERATIONS = ("rename", "archive", "restore", "delete")
88
88
  DIRECTORY_PICKER_TIMEOUT = 600 # the folder dialog waits for the person at the computer
89
89
  # Files are streamed to players in pieces of this size.
@@ -2002,6 +2002,10 @@ def message_filters(room_id, params):
2002
2002
  if mention:
2003
2003
  clauses.append("instr(messages.text, ?) > 0")
2004
2004
  values.append(f"@{mention}")
2005
+ if "requested_of" in params:
2006
+ # The requests the room recorded for this member, however the owner has renamed it in the text.
2007
+ clauses.append("messages.id IN (SELECT message_id FROM member_requests WHERE room_id=? AND member_id=?)")
2008
+ values.extend([room_id, int(params["requested_of"])])
2005
2009
  if "kind" in params:
2006
2010
  if params["kind"] not in ("opinion", "moderation", "receipt", "chat"):
2007
2011
  raise ValueError(Text('发言职责无效'))
package/docs/en/runner.md CHANGED
@@ -90,31 +90,30 @@ Invite an AI on another computer into your room: it reads only the project files
90
90
 
91
91
  **Invite (your computer)**:
92
92
  1. In the new-room panel or Invite members, click "External expert +" on the External row (once per expert), then on the card's back select the access and membership duration after check-in. "Can read project" opens all of the room's project folders.
93
- 2. Choose Add a seat awaiting check-in (automatic when creating the room). The seat appears immediately in the right-hand roster; share its link, QR code or pairing code. The link lasts 10 minutes and binds one member; regenerating it invalidates the previous link. Without a connected hosted site, the seat shows that it is waiting for a link and explains why; generate it from the seat menu after connecting. Before check-in, the panel shows the automatic expiry deadline and Remove seat. Usage, read logs and access adjustments appear after check-in.
93
+ 2. Choose Add a seat awaiting check-in (automatic when creating the room). The seat appears immediately in the right-hand roster; share its link or QR code. The link lasts 10 minutes and binds one member; regenerating it invalidates the previous link. Without a connected hosted site, the seat shows that it is waiting for a link and explains why; generate it from the seat menu after connecting. Before check-in, the panel shows the automatic expiry deadline and Remove seat. Usage, read logs and access adjustments appear after check-in.
94
94
  3. Redemption completes check-in and starts the membership duration, with **no extra approval step**. Pending seats receive no work and do not participate in group replies or discussions; they end automatically after 7 days. An expired link leaves the seat intact.
95
95
  4. `@` it in the room; its answers appear in the conversation as usual. "Read log and access" in the member menu lists every file it read (recorded by your computer) and lets you extend, downgrade to discussion only, or revoke; revoking takes effect immediately.
96
96
  5. After check-in, its avatar shows the vendor of the other side's AI, and "Read log and access" shows the software and model; both update when the other side switches AI. The other computer reports this itself, so treat it as identification only. A custom endpoint shows the external expert icon.
97
97
 
98
98
  **Join (the other computer)**:
99
- 1. Open the link and choose "Join with CoDiscuss on this computer" to go to the local page; or choose "+" under "Invited rooms" in the left panel and paste the link or pairing code; or run `codiscuss join <link or code> --adapter TOOL`. A pairing code also needs the inviting site's address.
100
- 2. Pick the AI, model and effort, and a trust level:
99
+ 1. Open the link and choose "Join with CoDiscuss on this computer" to go to the local page; or choose "+" under "Invited rooms" in the left panel and paste the link, scan the QR code with the camera, choose a QR code image, or paste a screenshot of it; or run `codiscuss join <link> --adapter TOOL`.
100
+ 2. Pick the AI, model and effort, and a trust level (a new computer starts at Full loan, with no further confirmation after joining):
101
101
 
102
102
  | Trust level | When named | Local AI |
103
103
  | --- | --- | --- |
104
- | Default | Woken only after you approve in the right panel each time; declining, or 15 minutes without an answer, shows "Not accepted by the other side" in the room | Limited to CoDiscuss commands, running in an empty temporary folder |
104
+ | Ask each time | Woken only after you approve in the right panel each time; declining, or 15 minutes without an answer, shows "Not accepted by the other side" in the room | Limited to CoDiscuss commands, running in an empty temporary folder |
105
105
  | Full loan | Woken directly, within a wake count and time limit (20 wakes and 1 day by default); once used up it goes back to asking each time | Same as above |
106
106
  | Trusted computer | Woken directly, no limits; later invites from that computer are accepted at this level | Unrestricted: local files and network tools available |
107
107
 
108
- You can change the level and limits later in the invited room's right panel, or pause or leave; `codiscuss invited` offers the same commands. Trusted computer can be set only on the other computer itself; a paired phone or tablet can choose only Default or Full loan. The local service does the waking, so keep codiscuss running.
108
+ You can change the level and limits later in the invited room's right panel, or pause or leave. Once the room has ended, you can delete its record from this computer. `codiscuss invited` offers the same commands. Trusted computer can be set only on the other computer itself; a paired phone or tablet can choose only Ask each time or Full loan. The local service does the waking, so keep codiscuss running.
109
109
 
110
- **Supported tools**: Default and Full loan need a tool that can be limited to CoDiscuss commands. Claude Code (background runs) supports it, tested on version 2.1.325 (other versions not individually checked), and so do model APIs, backed by unit tests; Codex and Antigravity do not support it and can serve only at the Trusted computer level; desktop apps cannot join as external members.
110
+ **Supported tools**: Ask each time and Full loan need a tool that can be limited to CoDiscuss commands. Claude Code (background runs) supports it, tested on version 2.1.325 (other versions not individually checked), and so do model APIs, backed by unit tests; Codex and Antigravity do not support it and can serve only at the Trusted computer level; desktop apps cannot join as external members.
111
111
 
112
112
  **What it can read**: files Git tracks in the opened folders (including uncommitted changes, skipping files in `.gitignore`); in a folder without Git, every file except generated folders such as `node_modules`. `.env`-style files, private keys and certificates, credential files, `.git`, and `data/` at the root of an opened folder are never opened; links pointing outside the folder are refused. It can only read: no writing files or running commands, and no private chats, other rooms or local paths. Each read returns at most 128 KiB; by default 4 MiB per hour, 64 MiB in total and 600 reads per hour.
113
113
 
114
114
  **Keep in mind**:
115
115
  - What it reads cannot be taken back: it stays in the other AI's session and reaches the other side's model provider; revoking only stops later reads.
116
116
  - If someone else uses an invite first within its 10 minutes, they become a member, and only revoking after the notice fixes it. Send invites only to people you trust.
117
- - A pairing code carries no key fingerprint for your computer, so the other side cannot check it reached you; prefer the link or QR code.
118
117
  - At Trusted computer the other AI is unrestricted, and content in your room may lead it to read files on that computer; use it only between your own computers.
119
118
 
120
119
  ## API Access
@@ -131,6 +130,20 @@ API members can act as experts or hosts. When the room has a project folder, rea
131
130
 
132
131
  Choose a provider and enter a key under **Smart Scheduling** (智能调度) when creating a room; the local service must be connected. See the [User Guide](workflow.md#smart-scheduling).
133
132
 
133
+ ## Workflows (Optional)
134
+
135
+ A workflow saves one way of working together so other rooms can reuse it: a SKILL.md for the host to read, plus a set of agent cards (each card is one expert preset). Workflows are managed in the **Workflows** list below **Channel tools** in the left sidebar; click one to open it in the middle of the page, with or without a room open. To use one in a room, ask the host to start it (typing `/` in the input box and picking a workflow writes the request for you; see the permission below). The host then organises the work as the SKILL.md says. A workflow only brings a method and members; when no flow is drawn it does not guarantee the order of steps, and the host decides the details. You can @ any member at any time.
136
+
137
+ - **Bundled workflows**: the package ships three. "Serial fiction" (`story-serial`: a screenwriter, a writer, two critics and a recorder take turns episode by episode, with a reader who reads the text on request; it comes with project templates and a state-check script that needs Python's PyYAML). "Decision council" (`decision-council`: a contrarian, an outsider, an alternatives role and an executor each answer on their own, then argue over the real disagreements, and the host sums up a recommendation). "Classic tabletop RPG" (`trpg-classic`: a dungeon master and three AI players, with an optional seat for you; it comes with a rules summary, an original adventure and a dice script that needs Python). None is installed by default. When you run `codiscuss setup` in a terminal, an **Install settings** step follows the tool selection: it opens with an overview, → expands a group, Space ticks the workflows to install, and Enter continues; nothing ticked means nothing installed. You can also add `--workflows` to install all of them (`install` accepts it too, and non-interactive runs only honour this option). An existing workflow with the same name is replaced by the packaged version, and the old copy is first backed up to `backups/workflows/` in the service folder. The choice applies to this run only and is not remembered.
138
+ - **Saving**: click **+** to the right of the **Workflows** heading in the left sidebar (on a phone, open the sidebar from the top-left corner first) and choose **New**, or import a zip or folder someone shared. Imported content is previewed on the canvas and is written only when you click **Save**. Copying the folder path and deleting are under **…** on each list item. The edit page can import cards from the current room's members, keeping their prompts as written. To have the host draft one, turn on **Full host control** (below).
139
+ - **Flow canvas**: clicking a workflow shows its canvas in the middle and its SKILL.md on the right; on phones and upright tablets, switch between the two at the top. Each member is an expert card: drag its title bar to move it, click it to flip and edit, × to delete. **Members** at the top left adds cards and **Host** adds a host node; you can also drag from the dot on a card's right side to empty space to add a member already connected. Lines show who hands over to whom: a line back to an earlier card is drawn as a gold dashed loop, and a host node means the work returns to the host. Select a line or a host node to add a short note. Save with the **Save** button or Ctrl+S; undo and redo with Ctrl+Z and Ctrl+Shift+Z. **…** on a list item renames, disables, copies the folder path or deletes; a disabled workflow stays in the library but rooms cannot enable it. The lines only help you read the workflow: the program does not execute them and the host does not see them. The host assigns work by the SKILL.md, so order, parallel steps, hand-backs and rework all belong there.
140
+ - **Letting the host build one**: tick **Full host control** when creating a room or under **Members and settings → Collaboration settings**, then tell the host what division of work you want (or "save how this room works as a workflow"). It saves the workflow, enables it in the room, invites its members and starts assigning work; you do not need to import anything or add members. With the switch on, typing `/` and picking a saved workflow writes the request to enable it; add what you want done and send it. Members the host brings in get at most writable project access. Only a host running in a local tool can do this; an API host cannot.
141
+ - **What else Full host control covers**: the host handles problems in the room and keeps the work moving on its own: it interjects when a member drifts, interrupts or retries a stuck member (including its own failed run), switches models, and replaces members that cannot recover. You can also just say "stop the writer", "stop everything", "let the critic speak next", "invite a read-only Codex reviewer", "start a Goal to finish the remaining episodes" or "pause the discussion". It only invites tools configured on this computer, read-only by default and writable at most. When a member produces no new output for 10 minutes, the system reminds the host to check; the host can also set itself a recurring check every 5–120 minutes during long tasks. These stay with you: other actions on the host itself (interrupting it, changing its project access, setting it away, removing it) or replacing the host, approving rounds beyond the limit, access above writable or allowing tools, changing the project folder, withdrawing your messages, and private chats.
142
+ - **Sharing**: workflows live in the `workflows` folder of the local service folder, one folder per workflow. Copy the path from the edit page and send the whole folder (or a zip of it). An import lists each card's prompt and project access; cards that ask to write files are imported as read-only until you tick them one by one.
143
+ - **Sub-workflows**: a method used only when needed, outside the main line, can be a sub-workflow with its own SKILL.md, cards and canvas, stored under `workflows/<sub-workflow ID>/` inside the workflow folder. Switch, create or delete them in the **Main workflow and sub-workflows** list at the top left of the canvas; they are saved together with the main workflow. While a workflow is running, typing `/` also lists its sub-workflows, and the host may use them on its own. The host invites the members a sub-workflow needs and sets them away afterwards; their sessions are kept for next time. The whole folder is still a standard skill, so other AI tools can read it as one.
144
+ - **Commands for API members**: read-only API members have no command line (writable ones use Pi's own). Put a `commands.json` in the workflow folder (see the `workflow-creator` skill) to register commands they may run, such as a check script kept in the same folder. Once enabled, API members can only run these commands by name and cannot change the command line; read-only members can only run commands marked read-only. Commands run on this computer as you, so when you import someone else's workflow the edit page lists every full command and brings them along only if you tick **Allow these commands to run on this computer**. The host cannot add or remove commands when drafting or changing a workflow.
145
+ - **Changing and ending**: changes to a workflow apply to every room that has it enabled, from each member's next run. New cards do not enter a room automatically; the host adds them when needed, or click the refresh icon on the workflow row in the right column. Card prompts are read-only in the room and are edited on the workflow's canvas. While a workflow is running, the host uses it only for requests that match its purpose (or when you say to follow the workflow) and handles other requests as usual. To end it, click the dismiss-members icon on the workflow row under **Members and settings → Collaboration settings**: the members it brought leave (the host stays), their work in progress stops and the workflow ends. Their sessions are kept, so picking the workflow again with `/` brings the same members back with their earlier context. To switch workflows, just pick another one; the previous members stay as ordinary members.
146
+
134
147
  ## Permissions
135
148
 
136
149
  Permissions are set per automatically started CLI member and default to read-only. The four levels are read-only, writable, automatic approval, and unrestricted; unsupported levels are disabled (`agy` does not support automatic approval in the background). Read-only pre-approves room-related `codiscuss` commands and answer drafts; writable allows project edits and commands. Automatic approval delegates decisions to the tool, while unrestricted skips permission prompts. Hover over a level for its exact scope. Codex uses its native sandbox, `agy` uses per-session permission rules, and existing Claude Code grants still apply. Manually started members keep their session's own permissions. When the owner turns on full host control for a room, the host can invite members using software already configured on this computer: project access defaults to read-only and is at most writable, and inviting a member who is away brings it back under its original name.
package/docs/runner.md CHANGED
@@ -121,31 +121,30 @@ codiscuss local connect https://你的站点
121
121
 
122
122
  **邀请(你的电脑)**:
123
123
  1. 建房面板或右栏“邀请成员”里点“外部”一行的“外部专家 +”(可加多位),翻到卡片背面设置开放内容和签到后的有效期。选“可读项目”时开放本房间的全部项目目录。
124
- 2. 点“添加待签到席位”(建房时自动添加),右栏名单立即显示待签到成员;把席位的链接、二维码或配对码发给对方。链接 10 分钟有效,只能绑定一位成员;重新生成会立即作废旧链接。未绑定线上站点时显示“待生成链接”及原因,绑定站点后从席位菜单生成。待签到面板显示自动结束期限,可“移除席位”;签到后才显示用量、读取记录和授权调整。
124
+ 2. 点“添加待签到席位”(建房时自动添加),右栏名单立即显示待签到成员;把席位的链接或二维码发给对方。链接 10 分钟有效,只能绑定一位成员;重新生成会立即作废旧链接。未绑定线上站点时显示“待生成链接”及原因,绑定站点后从席位菜单生成。待签到面板显示自动结束期限,可“移除席位”;签到后才显示用量、读取记录和授权调整。
125
125
  3. 对方兑换即完成签到,成员有效期从兑换时开始,**没有额外批准步骤**。未签到不收任务、不参与全体回应或讨论,7 天后自动结束;链接过期不会删除席位。
126
126
  4. 在房间里 `@` 它,回答照常出现在对话中。成员菜单的“读取记录与权限”列出它读过的每个文件(由你的电脑记录),可延长、降为只讨论或撤销授权,撤销立即生效。
127
127
  5. 签到后头像显示对方 AI 的厂家,“读取记录与权限”里可看到软件和模型;对方换 AI 后自动更新。这些信息由对方电脑自报,仅供辨认。自定义接口显示外部专家图标。
128
128
 
129
129
  **加入(对方电脑)**:
130
- 1. 打开链接,点“用本机共议加入”跳到本机网页;或在左栏“被邀请的房间”点“+”粘贴链接或配对码;命令行为 `codiscuss join <链接或配对码> --adapter 软件`。配对码另需填你的线上站点地址。
131
- 2. 选派哪个 AI、模型与强度,以及信任等级:
130
+ 1. 打开链接,点“用本机共议加入”跳到本机网页;或在左栏“被邀请的房间”点“+”粘贴链接,也可以用相机扫码、选择二维码图片或粘贴二维码截图;命令行为 `codiscuss join <链接> --adapter 软件`。
131
+ 2. 选派哪个 AI、模型与强度,以及信任等级(新电脑默认“完全借用”,加入后无需再确认):
132
132
 
133
133
  | 信任等级 | 被点名后 | 本机 AI |
134
134
  | --- | --- | --- |
135
- | 默认 | 每次须你在右栏同意才唤醒;拒绝或 15 分钟未处理,对方看到“对方未同意” | 只能用共议命令,在空的临时目录运行 |
135
+ | 每次询问 | 每次须你在右栏同意才唤醒;拒绝或 15 分钟未处理,对方看到“对方未同意” | 只能用共议命令,在空的临时目录运行 |
136
136
  | 完全借用 | 直接唤醒,受次数与期限上限(默认 20 次、1 天),用完退回每次询问 | 同上 |
137
137
  | 信任设备 | 直接唤醒,不设上限;之后这台电脑发来的邀请按此等级直接接受 | 不受限,可用本机文件与联网工具 |
138
138
 
139
- 等级与上限之后可在被邀请房间的右栏调整,也可暂停或退出;`codiscuss invited` 有同样的命令。“信任设备”只能在对方电脑本机设置,从已配对的手机或平板只能选“默认”或“完全借用”。唤醒由本机服务完成,请保持 codiscuss 运行。
139
+ 等级与上限之后可在被邀请房间的右栏调整,也可暂停或退出,房间结束后可删除这台电脑上的记录;`codiscuss invited` 有同样的命令。“信任设备”只能在对方电脑本机设置,从已配对的手机或平板只能选“每次询问”或“完全借用”。唤醒由本机服务完成,请保持 codiscuss 运行。
140
140
 
141
- **支持的软件**:默认与完全借用要求软件能限制为只用共议命令,目前支持 Claude Code(后台运行,已在 2.1.325 版实测,其他版本未逐一验证)与模型 API(以单元测试为据);Codex、Antigravity 不支持收窄,只能在“信任设备”等级下服务;桌面 App 不能作为外部成员加入。
141
+ **支持的软件**:每次询问与完全借用要求软件能限制为只用共议命令,目前支持 Claude Code(后台运行,已在 2.1.325 版实测,其他版本未逐一验证)与模型 API(以单元测试为据);Codex、Antigravity 不支持收窄,只能在“信任设备”等级下服务;桌面 App 不能作为外部成员加入。
142
142
 
143
143
  **能读到什么**:开放目录中 Git 管理的文件(含未提交的改动,忽略 `.gitignore` 里的文件),非 Git 目录则是除 `node_modules` 等生成目录外的文件。`.env` 一类文件、私钥与证书、凭据文件、`.git`、开放目录根下的 `data/` 永不开放;指向目录外的链接被拒绝。它只能读,不能写文件或执行命令,也看不到私聊、其他房间和本机路径。每次最多读 128 KiB,默认每小时 4 MiB、总量 64 MiB、每小时 600 次。
144
144
 
145
145
  **须知**:
146
146
  - 读出去的内容收不回:它会留在对方 AI 的会话里,并发送给对方的模型服务商;撤销只阻止以后的读取。
147
147
  - 邀请若在 10 分钟内被别人抢先使用,对方即成为成员,只能靠你看到提示后撤销。只把邀请发给信任的人。
148
- - 配对码不含你电脑的密钥指纹,对方核对不了连到的是不是你;能用链接或二维码时优先用。
149
148
  - “信任设备”等级下对方的 AI 不受限,你房间里的内容可能诱导它读对方电脑上的文件,只在自己的电脑之间使用。
150
149
 
151
150
  ## API 接入
@@ -377,7 +377,6 @@
377
377
  "文件夹名称": "Folder name",
378
378
  "项目路径(可选)": "Project path (optional)",
379
379
  "在此文件夹中新建房间时自动带入,已有房间不受影响。": "Filled in automatically for new rooms in this folder; existing ones are not affected.",
380
- "主目录的完整路径,或选择项目": "Full path of the main folder, or choose a project",
381
380
  "房间名称": "Room name",
382
381
  "这次想讨论什么?": "What do you want to discuss?",
383
382
  "希望通过讨论解决的问题": "The question this discussion should resolve",
@@ -47,9 +47,7 @@
47
47
  "消息会发给对方模型服务商": "Messages go to their model provider",
48
48
  "生成邀请需要本机服务,请在这台电脑打开本机网站。": "Creating an invitation needs the local service; open the local website on this computer.",
49
49
  "邀请二维码": "Invitation QR code",
50
- "把链接或二维码发给对方;对方也可以在自己的共议里输入配对码:": "Send the link or QR code to the other person; they can also enter the pairing code in their own CoDiscuss:",
51
- "复制配对码": "Copy pairing code",
52
- "配对码不含这台电脑的公钥指纹,优先发链接或二维码。": "The pairing code does not carry this computer's key fingerprint; prefer sending the link or QR code.",
50
+ "把链接或二维码发给对方。": "Send the link or QR code to the other person.",
53
51
  "立即生效:之后的请求与读取一律被拒,未完成的执行作废。": "Takes effect at once: later requests and reads are refused, and unfinished runs are voided.",
54
52
  "已经读出去的内容收不回,会留在对方 AI 的会话里。": "What was already read cannot be taken back; it stays in the other AI's session.",
55
53
  "外部成员 · {name}": "External member · {name}",
@@ -117,7 +115,7 @@
117
115
  "暂停期间不领取也不唤醒;已在等你确认的请求到时照常算作未同意": "While paused nothing is taken or started; requests already awaiting you still count as declined when they time out",
118
116
  "退出房间": "Leave room",
119
117
  "退出「{room}」": "Leave \"{room}\"",
120
- "用链接或配对码加入": "Join with a link or pairing code",
118
+ "用邀请链接加入": "Join with an invitation link",
121
119
  "被邀请的房间列表": "Invited room list",
122
120
  "{computer} · {trust}": "{computer} · {trust}",
123
121
  "未命名房间": "Untitled room",
@@ -127,14 +125,15 @@
127
125
  "可读项目:另可读对方开放的目录,不能写入或执行": "Can read project: can also read the opened directories; cannot write or run anything",
128
126
  "加入共议房间 · AI CoDiscuss": "Join a CoDiscuss room · AI CoDiscuss",
129
127
  "没有邀请内容": "No invitation here",
130
- "请打开对方发来的完整链接,或在自己的共议里输入配对码。": "Open the complete link you were sent, or enter the pairing code in your own CoDiscuss.",
128
+ "请打开对方发来的完整链接。": "Open the complete link you were sent.",
131
129
  "邀请人的电脑": "Inviting computer",
132
130
  "开放": "Opens",
133
131
  "链接须在此前兑换": "Redeem the link before",
134
132
  "复制邀请链接": "Copy invitation link",
135
133
  "复制失败,请手动复制地址栏": "Copy failed; copy the address bar manually",
136
134
  "你被邀请让自己的 AI 加入一个共议房间": "You are invited to bring your own AI into a CoDiscuss room",
137
- "你的 AI 在你自己的电脑上运行,用你自己的账号与额度;对方点名后,默认先问你同意才唤醒。": "Your AI runs on your own computer with your own account and quota; by default you are asked before it starts each time it is named.",
135
+ "你的 AI 在你自己的电脑上运行,用你自己的账号与额度;加入后对方点名即唤醒,受次数与期限上限约束。": "Your AI runs on your own computer with your own account and quota; once you join, it starts when named, within a wake count and time limit.",
136
+ "每次询问": "Ask each time",
138
137
  "对方开放的项目内容会经你的 AI 发送给它的模型服务商。": "Project content they open reaches your AI's model provider.",
139
138
  "用本机共议加入": "Join with CoDiscuss on this computer",
140
139
  "按钮打开这台电脑上的共议(需已安装并运行 codiscuss)。也可以复制链接,在共议左栏“被邀请的房间”里粘贴,或运行 codiscuss join。": "The button opens CoDiscuss on this computer (codiscuss must be installed and running). You can also copy the link and paste it under \"Invited rooms\" in the left sidebar, or run codiscuss join.",
@@ -143,10 +142,12 @@
143
142
  "已加入「{room}」": "Joined \"{room}\"",
144
143
  "加入另一台电脑的房间": "Join a room on another computer",
145
144
  "你的 AI 在这台电脑上运行,只读对方开放的目录,在对方房间里回答。": "Your AI runs on this computer, reads only the directories they open, and answers in their room.",
146
- "邀请链接或配对码": "Invitation link or pairing code",
147
- "粘贴对方发来的链接,或输入配对码": "Paste the link you were sent, or enter the pairing code",
148
- "对方的线上站点": "Their online site",
149
- "配对码不含对方电脑的公钥指纹,无法核对连到的是不是对方;能用链接或扫码时优先用。": "A pairing code carries no key fingerprint of their computer, so it cannot be checked; use the link or QR code when you can.",
145
+ "邀请链接": "Invitation link",
146
+ "粘贴邀请链接或二维码截图": "Paste the invitation link or a screenshot of its QR code",
147
+ "选择二维码图片": "Choose a QR code image",
148
+ "加入中…": "Joining…",
149
+ "这张图片里没有识别到邀请二维码": "No invitation QR code was found in this image",
150
+ "这不是邀请链接,请粘贴对方发来的完整链接。": "This isn't an invitation link. Paste the complete link you were sent.",
150
151
  "派哪个 AI": "Which AI to send",
151
152
  "加入需要本机服务,请在运行 AI 的电脑打开本机网站。": "Joining needs the local service; open the local website on the computer that runs the AI.",
152
153
  "加入": "Join",
@@ -165,6 +166,12 @@
165
166
  "这个软件不能限制为只用共议命令({reason}),只能在“信任设备”等级下服务;其他等级下被点名时不会启动。": "This software cannot be limited to CoDiscuss commands ({reason}), so it can serve only at the \"Trusted computer\" level; at other levels it will not start when named.",
166
167
  "被对方撤销": "revoked by the other side",
167
168
  "你已退出": "you left",
169
+ "删除记录": "Delete record",
170
+ "删除「{room}」的记录": "Delete the record of \"{room}\"",
171
+ "记录已删除": "Record deleted",
172
+ "这台电脑上这个房间的记录、历史和运行文件会被删除,无法恢复。": "This room's record, history and run files on this computer will be deleted. This can't be undone.",
173
+ "对方房间不受影响,你的 AI 自己的会话也会保留。": "Their room isn't affected, and your AI's own session is kept.",
174
+ "退出通知还没送达对方电脑,送达后才能删除记录": "The other computer hasn't received your leave notice yet. You can delete the record once it arrives",
168
175
  "已结束:{reason}": "Ended: {reason}",
169
176
  "撤销授权": "Revoke",
170
177
  "已结束,未回答": "Ended without an answer",
@@ -179,7 +186,6 @@
179
186
  "这个链接已过期,请让对方重新生成邀请。": "This link has expired. Ask them to create a new invitation.",
180
187
  "无法读取这个邀请链接": "This invitation link can't be read",
181
188
  "链接可能被截断或改动过。请让对方重新复制完整链接发给你。": "The link may have been cut off or changed. Ask them to copy the complete link and send it again.",
182
- "也可以在自己共议左栏“被邀请的房间”里输入对方给的配对码。": "You can also enter the pairing code they gave you under \"Invited rooms\" in your own CoDiscuss sidebar.",
183
189
  "对方电脑上的 AI,只读本房间开放的内容": "An AI on their computer; reads only what this room opens",
184
190
  "用量": "Usage",
185
191
  "这位外部成员已结束,不能再调整;需要时重新邀请。": "This external member has ended and can no longer be changed; invite again if needed.",
@@ -201,6 +207,8 @@
201
207
  "邀请链接": "Invitation link",
202
208
  "{time} 前兑换有效,只能用一次。对方兑换后完成签到,你会收到提示,可随时撤销。": "Redeem before {time}, for one member only. Check-in completes on redemption; you will be notified and can revoke access anytime.",
203
209
  "另一台电脑{suffix}": "Another computer{suffix}",
210
+ "外部专家{suffix}": "External expert{suffix}",
211
+ "外部 {ai}{suffix}": "External {ai}{suffix}",
204
212
  "链接只在生成时显示;请重新生成。未绑定线上网站时,需先在设置中绑定。": "Links are shown only when generated. Generate a new one; if no online site is bound, bind one in Settings first.",
205
213
  "{count} 位外部专家待签到": "{count} external expert(s) awaiting check-in",
206
214
  "{count} 天内未签到自动结束": "Ends automatically if not checked in within {count} days",
@@ -35,6 +35,8 @@
35
35
  "重试": "Retry",
36
36
  "收起": "Collapse",
37
37
  "正在启动": "Starting",
38
+ "正在创建": "Creating",
39
+ "正在创建房间…": "Creating the room…",
38
40
  "显示更多": "Show more",
39
41
  "继续 Goal": "Continue Goal",
40
42
  "展开或收起详情": "Expand or collapse details",
@@ -318,6 +318,10 @@
318
318
  "从常用项目中选择": "Choose from saved projects",
319
319
  "选择常用项目": "Select a saved project",
320
320
  "添加常用项目": "Add saved project",
321
+ "移除后不再出现在列表里,文件夹和文件都会保留,正在使用它的房间不受影响。以后新建同名项目即可恢复。": "Removed projects leave this list, but their folders and files are kept and rooms using them are not affected. Create a project with the same name to bring one back.",
322
+ "临时路径": "One-off path",
323
+ "加入常用项目": "Add to saved projects",
324
+ "粘贴或输入临时路径": "Paste or type a one-off path",
321
325
  "保存常用项目,之后一键选择;其他设备也能用": "Save projects for one-click selection, including from other devices",
322
326
  "项目目录完整路径": "Full project folder path",
323
327
  "在本机选择项目目录": "Choose a project folder on this computer",
@@ -655,7 +659,7 @@
655
659
  "新建工作流": "New workflow",
656
660
  "调整 SKILL.md 面板宽度": "Resize SKILL.md panel",
657
661
  "拖动调整宽度,双击还原": "Drag to resize; double-click to reset",
658
- "主线与子工作流": "Main workflow and sub-workflows",
662
+ "主线与子工作流": "Main and sub-workflows",
659
663
  "回到主线": "Back to main workflow",
660
664
  "{value1} 个子工作流": "{value1} sub-workflows",
661
665
  "{value1} 位": "{value1} members",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.4.82",
3
+ "version": "0.4.84",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -10,7 +10,10 @@ import { createHash } from 'node:crypto';
10
10
  import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
11
11
  import { isAbsolute, join, relative, resolve } from 'node:path';
12
12
 
13
+ import { atomic_json } from './files.mjs';
14
+
13
15
  const SETTINGS_FILE = 'local-settings.json';
16
+ const HIDDEN_PROJECTS_FILE = 'hidden-projects.json';
14
17
  // A hosted account's instance writes the failures its runner judged here, one JSON line each; the owner's panel relays them.
15
18
  export const OPERATOR_EVENTS_FILE = 'operator-events.jsonl';
16
19
  const PROJECT_NAME_LIMIT = 80;
@@ -59,6 +62,44 @@ export function account_projects(root) {
59
62
  .map(entry => ({ id: createHash('sha256').update(entry.name).digest('hex').slice(0, 16), name: entry.name, path: join(root, entry.name) }));
60
63
  }
61
64
 
65
+ /** Names the account removed from its list; their folders stay on disk, so rooms using them keep working. */
66
+ function hidden_project_names(home) {
67
+ const path = join(home, HIDDEN_PROJECTS_FILE);
68
+ const names = existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : [];
69
+ return Array.isArray(names) ? names.filter(name => typeof name === 'string') : [];
70
+ }
71
+
72
+ /** The projects an ordinary account sees in its list: its folders, without the ones it removed. */
73
+ export function listed_account_projects(home, root) {
74
+ const hidden = new Set(hidden_project_names(home));
75
+ return account_projects(root).filter(project => !hidden.has(project.name));
76
+ }
77
+
78
+ /**
79
+ * Take projects off an ordinary account's list without touching their folders; repeating a removal changes nothing.
80
+ *
81
+ * Args:
82
+ * home: The instance's service directory, which keeps the hidden names.
83
+ * root: The account's projects root.
84
+ * ids: The ids of the projects to remove, as `account_projects` reports them.
85
+ */
86
+ export function hide_account_projects(home, root, ids) {
87
+ const projects = new Map(account_projects(root).map(project => [project.id, project.name]));
88
+ const names = ids.map(id => projects.get(id));
89
+ if (names.includes(undefined)) throw new Error('项目不存在,请刷新后重试');
90
+ atomic_json(join(home, HIDDEN_PROJECTS_FILE), [...new Set([...hidden_project_names(home), ...names])]);
91
+ }
92
+
93
+ /** Create a project, or bring back the removed project of that name with its files. */
94
+ export function create_or_restore_account_project(home, root, name) {
95
+ const wanted = typeof name === 'string' ? name.trim() : '';
96
+ const hidden = hidden_project_names(home);
97
+ if (!hidden.includes(wanted)) return create_account_project(root, name);
98
+ atomic_json(join(home, HIDDEN_PROJECTS_FILE), hidden.filter(item => item !== wanted));
99
+ const folder = join(root, wanted);
100
+ return existsSync(folder) ? { name: wanted, path: folder } : create_account_project(root, name);
101
+ }
102
+
62
103
  /** Create one project folder directly under the projects root; a name that would nest or escape is refused. */
63
104
  export function create_account_project(root, name) {
64
105
  const wanted = typeof name === 'string' ? name.trim() : '';
@@ -9,7 +9,7 @@ import { setTimeout as sleep } from 'node:timers/promises';
9
9
  import { pathToFileURL } from 'node:url';
10
10
  import { parseArgs } from 'node:util';
11
11
 
12
- import { account_projects, account_space, create_account_project, draft_folder } from './account_space.mjs';
12
+ import { account_projects, account_space, create_or_restore_account_project, draft_folder, hide_account_projects, listed_account_projects } from './account_space.mjs';
13
13
  import { atomic_json } from './files.mjs';
14
14
  import { bundle_project_markdown, bundle_project_page, outside_directory, project_media, read_only_enforced, read_project_files, read_project_folders, room_directories, search_project_roots } from './project_files.mjs';
15
15
  import { guard_remote_request, list_remote_directories, remote_allows, remote_roots } from './remote_policy.mjs';
@@ -677,7 +677,7 @@ const PROJECT_ID_PATTERN = /^[0-9a-f]{8,32}$/;
677
677
  export function launch_projects(home) {
678
678
  // An ordinary account's projects are the folders under its projects root; it keeps no list of its own.
679
679
  const { projects_root } = account_space(home);
680
- if (projects_root) return { projects: account_projects(projects_root), restricted: true };
680
+ if (projects_root) return { projects: listed_account_projects(home, projects_root), restricted: true };
681
681
  const path = join(home, 'launch-projects.json');
682
682
  return existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : { projects: [] };
683
683
  }
@@ -687,8 +687,12 @@ export function launch_projects(home) {
687
687
  export function save_launch_projects(home, input) {
688
688
  const { projects_root } = account_space(home);
689
689
  if (projects_root) {
690
- if (typeof input.create !== 'string') throw new Error('此账号的项目只能在自己的项目文件夹内新建:请提供 create(项目名称)');
691
- const created = create_account_project(projects_root, input.create);
690
+ if (Array.isArray(input.remove)) {
691
+ hide_account_projects(home, projects_root, input.remove);
692
+ return launch_projects(home);
693
+ }
694
+ if (typeof input.create !== 'string') throw new Error('此账号的项目只能在自己的项目文件夹内新建或移除:请提供 create(项目名称)或 remove(项目编号列表)');
695
+ const created = create_or_restore_account_project(home, projects_root, input.create);
692
696
  return { ...launch_projects(home), created };
693
697
  }
694
698
  if (!Array.isArray(input.projects)) throw new Error('projects 必须为列表');
@@ -2298,6 +2302,7 @@ function granted_projects(home) {
2298
2302
  const { projects_root, workspace } = account_space(home);
2299
2303
  if (!projects_root) return launch_projects(home).projects;
2300
2304
  mkdirSync(workspace, { recursive: true });
2305
+ // Removed projects stay granted: removing only shortens the list, and rooms working there must keep running.
2301
2306
  return [...account_projects(projects_root), { name: '草稿空间', path: workspace }];
2302
2307
  }
2303
2308
 
@@ -97,7 +97,7 @@ export function external_task_text({ name, messages, requests = [], cli, access_
97
97
  const instructions = `你作为外部成员参加另一台电脑上的房间,只读对方开放的项目,不修改任何文件。命令只用 subcommands 列出的 ${cli} 子命令。${limits}${reading}`;
98
98
  const prompt = `${wake_opening(requests, name)}(来自另一台电脑上的房间),对应消息 ${messages}。${instructions}`
99
99
  + `用 ${cli} message view 消息编号${access} 看原文,${cli} room read${access} 看房间概况。`
100
- + `做完用 ${cli} message post --body-file 草稿${access} 提交一次回答(简短回答可用 --body "回答")。先读任务文件 ${task_path} 与其中列出的技能。`;
100
+ + `做完用 ${cli} message post --body-file 草稿${access} 提交一次回答(简短回答可用 --body "回答")。房间按 Markdown 显示回答,内容较多时用分段、标题或列表排版。先读任务文件 ${task_path} 与其中列出的技能。`;
101
101
  return { instructions, prompt };
102
102
  }
103
103