ai_co_discuss 0.4.95 → 0.4.97

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.
@@ -1,8 +1,8 @@
1
1
  """External members: AIs that run on another computer and reach this room only through the runner's gateway.
2
2
 
3
3
  An external member is a `room_members` row with `access='external'` plus one `external_members` row holding where it
4
- runs, what it may read, until when, and its read quota. This module is the room-side authority (DESIGN D4): it decides
5
- validity, expiry and revocation, keeps the read audit and quota counts, and serves the only routes an external
4
+ runs, what it may read and until when. This module is the room-side authority (DESIGN D4): it decides validity,
5
+ expiry and revocation, keeps the read audit, and serves the only routes an external
6
6
  credential may use (`/api/external/rooms/{room}/...`). Every other route refuses an external credential or a request
7
7
  the gateway marked as external; see `guard_route`. Contract: .dev/plans/远程协作与多人房间/子Task1_B侧后端/CONTRACT.md.
8
8
  """
@@ -24,9 +24,7 @@ EXTERNAL_PREFIX = ["api", "external", "rooms"]
24
24
  SCOPES = ("discuss", "read")
25
25
  # How many ended external members the roster still lists.
26
26
  MAX_ENDED_SHOWN = 10
27
- QUOTA_KEYS = ("hourly_bytes", "total_bytes", "hourly_reads")
28
- DEFAULT_QUOTA = {"hourly_bytes": 4 * 1024 * 1024, "total_bytes": 64 * 1024 * 1024, "hourly_reads": 600}
29
- MAX_QUOTA = {"hourly_bytes": 1024 ** 3, "total_bytes": 100 * 1024 ** 3, "hourly_reads": 100000}
27
+ # Reads are no longer limited (user 2026-11-19); the old quota columns stay in the table, written as 0 and never read.
30
28
  MAX_EXTERNAL_SECONDS = 365 * 86400
31
29
  PENDING_SEAT_SECONDS = 7 * 86400
32
30
  MAX_DIRECTORIES = 20
@@ -35,7 +33,6 @@ MAX_MACHINE = 200
35
33
  MAX_MACHINE_LABEL = 80
36
34
  MAX_ADAPTER = 40
37
35
  MAX_MODEL = 120
38
- HOUR_SECONDS = 3600
39
36
  READ_OPS = ("ls", "read", "grep")
40
37
  READ_OUTCOMES = ("ok", "denied")
41
38
  MAX_READ_PATH = 1000
@@ -90,20 +87,6 @@ def guard_route(connect, headers, parts):
90
87
  raise classified(PermissionError, Text("外部成员只能使用成员范围接口"), "external_route_forbidden")
91
88
 
92
89
 
93
- def quota_of(row):
94
- """The member's three quota limits."""
95
- return {key: row[key] for key in QUOTA_KEYS}
96
-
97
-
98
- def usage_of(connection, member_id, now=None):
99
- """Read counts from the persisted audit: allowed bytes and reads in the last hour, allowed bytes in total, denials."""
100
- since = ((now or int(time.time())) - HOUR_SECONDS) * 1000
101
- row = connection.execute("""SELECT COALESCE(SUM(CASE WHEN allowed=1 AND at>? THEN bytes END),0),
102
- COALESCE(SUM(CASE WHEN allowed=1 AND at>? THEN 1 END),0),COALESCE(SUM(CASE WHEN allowed=1 THEN bytes END),0),
103
- COALESCE(SUM(CASE WHEN allowed=0 THEN 1 END),0) FROM external_reads WHERE member_id=?""", (since, since, member_id)).fetchone()
104
- return {"hour_bytes": row[0], "hour_reads": row[1], "total_bytes": row[2], "denied": row[3]}
105
-
106
-
107
90
  def directory_names(directories):
108
91
  """Directory roots by number with only their last segment, for views that must not show local paths."""
109
92
  return [{"root": index, "name": posixpath.basename(path.replace("\\", "/").rstrip("/")) or path}
@@ -111,12 +94,12 @@ def directory_names(directories):
111
94
 
112
95
 
113
96
  def owner_view(connection, row):
114
- """Describe one external member for the owner, with full directory paths and current usage."""
97
+ """Describe one external member for the owner, with full directory paths."""
115
98
  labels = free_room.member_display_names(connection, row["room_id"])
116
99
  return {"member_id": row["id"], "name": row["name"], "label": labels.get(row["name"], row["name"]), "adapter": row["adapter"],
117
100
  "status": row["status"], "machine": row["machine"], "machine_label": row["machine_label"], "platform": row["platform"],
118
- "model": row["model"], "scope": row["scope"], "directories": json.loads(row["directories"]), "expires_at": row["expires_at"], "quota": quota_of(row),
119
- "usage": usage_of(connection, row["id"]), "created_at": row["created_at"], "updated_at": row["updated_at"],
101
+ "model": row["model"], "scope": row["scope"], "directories": json.loads(row["directories"]), "expires_at": row["expires_at"],
102
+ "created_at": row["created_at"], "updated_at": row["updated_at"],
120
103
  "ended_at": row["ended_at"], "end_reason": row["end_reason"],
121
104
  "claimed_at": row["claimed_at"], "invite_version": row["invite_version"], "duration": row["invite_duration"]}
122
105
 
@@ -204,20 +187,6 @@ def checked_expiry(value, now):
204
187
  return value
205
188
 
206
189
 
207
- def checked_quota(value, current):
208
- """Merge given quota limits over `current`; each is a positive integer within its maximum."""
209
- if value is None:
210
- return dict(current)
211
- if not isinstance(value, dict) or set(value) - set(QUOTA_KEYS):
212
- raise ValueError(Text("quota 只能包含 hourly_bytes、total_bytes、hourly_reads"))
213
- merged = dict(current)
214
- for key, item in value.items():
215
- if type(item) is not int or not 0 < item <= MAX_QUOTA[key]:
216
- raise ValueError(Text("配额 {key} 须为 1–{limit} 的整数", key=key, limit=MAX_QUOTA[key]))
217
- merged[key] = item
218
- return merged
219
-
220
-
221
190
  def checked_text(value, limit, field, required=False):
222
191
  """Validate a bounded single-line text field."""
223
192
  if value is None and not required:
@@ -284,7 +253,6 @@ def create_external(connection, room_id, token, payload, now):
284
253
  label = checked_text(payload.get("machine_label"), MAX_MACHINE_LABEL, "machine_label")
285
254
  directories = checked_scope(payload.get("scope"), payload.get("directories", []))
286
255
  expires_at = now + PENDING_SEAT_SECONDS if pending else checked_expiry(payload.get("expires_at"), now)
287
- quota = checked_quota(payload.get("quota"), DEFAULT_QUOTA)
288
256
  if connection.execute("SELECT 1 FROM room_members WHERE room_id=? AND name=? AND status<>'removed'", (room_id, name)).fetchone():
289
257
  raise FileExistsError(Text("{name} 已是本房间成员", name=name))
290
258
  if connection.execute("SELECT COUNT(*) FROM room_members WHERE room_id=? AND status<>'removed'", (room_id,)).fetchone()[0] >= MAX_ROOM_AGENTS:
@@ -296,7 +264,7 @@ def create_external(connection, room_id, token, payload, now):
296
264
  connection.execute("""INSERT INTO external_members (member_id,room_id,token_hash,machine,machine_label,scope,directories,expires_at,
297
265
  hourly_bytes,total_bytes,hourly_reads,created_at,updated_at,claimed_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)""",
298
266
  (cursor.lastrowid, room_id, hashed, machine, label, payload["scope"], json.dumps(directories, ensure_ascii=False),
299
- expires_at, quota["hourly_bytes"], quota["total_bytes"], quota["hourly_reads"], now, now, 0 if pending else now))
267
+ expires_at, 0, 0, 0, now, now, 0 if pending else now))
300
268
  if pending:
301
269
  duration = payload.get("duration", "1h")
302
270
  if duration not in ("1h", "today", "3d", "7d", "30d"):
@@ -337,11 +305,9 @@ def update_external(connection, room_id, member_id, token, payload, now):
337
305
  directories = payload.get("directories", [] if scope == "discuss" and "directories" not in payload else json.loads(row["directories"]))
338
306
  directories = checked_scope(scope, directories)
339
307
  expires_at = checked_expiry(payload["expires_at"], now) if "expires_at" in payload else row["expires_at"]
340
- quota = checked_quota(payload.get("quota"), quota_of(row))
341
308
  label = checked_text(payload["machine_label"], MAX_MACHINE_LABEL, "machine_label") if "machine_label" in payload else row["machine_label"]
342
- connection.execute("""UPDATE external_members SET scope=?,directories=?,expires_at=?,hourly_bytes=?,total_bytes=?,hourly_reads=?,
343
- machine_label=?,updated_at=? WHERE member_id=?""", (scope, json.dumps(directories, ensure_ascii=False), expires_at,
344
- quota["hourly_bytes"], quota["total_bytes"], quota["hourly_reads"], label, now, member_id))
309
+ connection.execute("""UPDATE external_members SET scope=?,directories=?,expires_at=?,machine_label=?,updated_at=? WHERE member_id=?""",
310
+ (scope, json.dumps(directories, ensure_ascii=False), expires_at, label, now, member_id))
345
311
  return owner_view(connection, external_row(connection, room_id, member_id))
346
312
 
347
313
 
@@ -457,8 +423,8 @@ def checked_read(payload):
457
423
  return op, root, path, size, outcome, reason
458
424
 
459
425
 
460
- def read_decision(row, root, size, outcome, reason, usage):
461
- """Decide one read: (allowed, code, reason). Only reads the engine served count toward the quota."""
426
+ def read_decision(row, root, outcome, reason):
427
+ """Decide one read: (allowed, code, reason)."""
462
428
  if row["status"] != "active":
463
429
  return False, "member_ended", ENDED_TEXTS.get(row["end_reason"], ENDED_TEXTS["revoked"])
464
430
  if outcome == "denied":
@@ -467,17 +433,11 @@ def read_decision(row, root, size, outcome, reason, usage):
467
433
  return False, "not_readable", Text("该外部成员只讨论,未开放读取项目")
468
434
  if root >= len(json.loads(row["directories"])):
469
435
  return False, "bad_root", Text("该目录未对外部成员开放")
470
- if usage["hour_reads"] + 1 > row["hourly_reads"]:
471
- return False, "quota_hour_reads", Text("本小时读取次数已达上限")
472
- if usage["hour_bytes"] + size > row["hourly_bytes"]:
473
- return False, "quota_hour_bytes", Text("本小时读取量已达上限")
474
- if usage["total_bytes"] + size > row["total_bytes"]:
475
- return False, "quota_total_bytes", Text("读取总量已达上限")
476
436
  return True, "ok", ""
477
437
 
478
438
 
479
439
  def record_read(connection, room_id, member_id, token, payload):
480
- """Audit one read, then judge it against the persisted quota, and commit before the gateway may return content.
440
+ """Audit one read, then judge it, and commit before the gateway may return content.
481
441
 
482
442
  The audit row and the room event are written first (as not allowed), the decision updates them in the same
483
443
  transaction, and the transaction commits here: a failure anywhere raises, so the gateway returns nothing.
@@ -495,14 +455,13 @@ def record_read(connection, room_id, member_id, token, payload):
495
455
  read_id = cursor.lastrowid
496
456
  event = connection.execute("INSERT INTO room_events (room_id,at,kind,data) VALUES (?,?,'external.read',?)",
497
457
  (room_id, at, json.dumps({"member_id": member_id, "read_id": read_id}))).lastrowid
498
- allowed, code, why = read_decision(row, root, size, outcome, reason, usage_of(connection, member_id))
458
+ allowed, code, why = read_decision(row, root, outcome, reason)
499
459
  connection.execute("UPDATE external_reads SET allowed=?,code=?,reason=? WHERE id=?", (int(allowed), code, str(why), read_id))
500
460
  data = {"member_id": member_id, "member": row["name"], "read_id": read_id, "op": op, "root": root, "directory": directory,
501
461
  "path": path, "bytes": size, "allowed": allowed, "code": code, "reason": str(why)}
502
462
  connection.execute("UPDATE room_events SET data=? WHERE id=?", (json.dumps(data, ensure_ascii=False), event))
503
463
  connection.commit()
504
- return {"allowed": allowed, "code": code, "reason": why, "reason_text": text_payload(why), "read_id": read_id, "recorded": True,
505
- "usage": usage_of(connection, member_id)}
464
+ return {"allowed": allowed, "code": code, "reason": why, "reason_text": text_payload(why), "read_id": read_id, "recorded": True}
506
465
 
507
466
 
508
467
  def require_external(connection, room_id, token):
@@ -529,15 +488,18 @@ def member_room_view(connection, room_id, member):
529
488
  room = connection.execute("SELECT r.id,r.title,r.goal,d.archived FROM rooms r JOIN room_directory d ON d.room_id=r.id WHERE r.id=?",
530
489
  (room_id,)).fetchone()
531
490
  labels = free_room.member_display_names(connection, room_id)
491
+ # An external member carries the vendor its computer reported (`platform`, display only), so the other computer's page
492
+ # can show it as this room does; local members are known by their platform names.
532
493
  members = [{"name": row["name"], "label": labels.get(row["name"], row["name"]), "role": row["role"], "status": row["status"],
533
- "external": row["access"] == "external"}
534
- for row in connection.execute(f"SELECT name,role,status,access FROM room_members WHERE room_id=? AND status<>'removed' AND {free_room.REGISTERED_MEMBER} ORDER BY id",
494
+ "external": row["access"] == "external", **({"platform": row["platform"] or ""} if row["access"] == "external" else {})}
495
+ for row in connection.execute(f"""SELECT room_members.name,room_members.role,room_members.status,room_members.access,ext.platform
496
+ FROM room_members LEFT JOIN external_members ext ON ext.member_id=room_members.id
497
+ WHERE room_members.room_id=? AND room_members.status<>'removed' AND {free_room.REGISTERED_MEMBER} ORDER BY room_members.id""",
535
498
  (room_id,))]
536
499
  latest = connection.execute("""SELECT COALESCE(MAX(id),0) FROM messages m WHERE room_id=?
537
500
  AND NOT EXISTS (SELECT 1 FROM internal_task_messages t WHERE t.message_id=m.id)""", (room_id,)).fetchone()[0]
538
501
  me = {"member_id": member["id"], "name": member["name"], "label": labels.get(member["name"], member["name"]), "scope": member["scope"],
539
- "expires_at": member["expires_at"], "directories": directory_names(json.loads(member["directories"])),
540
- "quota": quota_of(member), "usage": usage_of(connection, member["id"])}
502
+ "expires_at": member["expires_at"], "directories": directory_names(json.loads(member["directories"]))}
541
503
  return {"room": {"id": room["id"], "title": room["title"], "goal": room["goal"], "archived": bool(room["archived"])},
542
504
  "me": me, "members": members, "latest_message_id": latest}
543
505
 
@@ -594,11 +556,35 @@ def report_ai(connection, member, payload):
594
556
  return {"reported": True}
595
557
 
596
558
 
597
- def lend_until(connection, member, payload):
598
- """The member's computer sets how long it lends its AI; only its own end changes, never what it may read (red line 1 exception)."""
599
- expires_at = checked_expiry(payload.get("expires_at"), int(time.time()))
600
- connection.execute("UPDATE external_members SET expires_at=?,updated_at=? WHERE member_id=?", (expires_at, int(time.time()), member["id"]))
601
- return {"expires_at": expires_at}
559
+ def lend_until(connection, room_id, token, payload):
560
+ """The member's computer sets how long it lends its AI; only its own end changes, never what it may read (red line 1 exception).
561
+
562
+ A member whose time ran out comes back at once with the new end (user 2026-11-19): how long it is lent was its own
563
+ choice, so letting it lapse is not a decision of the owner's. One the owner revoked, or that left, stays ended.
564
+ """
565
+ begin_write(connection)
566
+ now = int(time.time())
567
+ expires_at = checked_expiry(payload.get("expires_at"), now)
568
+ hashed = token_hash(token)
569
+ row = connection.execute(f"{EXTERNAL_SQL} WHERE x.room_id=? AND x.token_hash=?", (room_id, hashed)).fetchone() if hashed else None
570
+ if not row or not row["claimed_at"]:
571
+ raise classified(PermissionError, Text("需要本房间外部成员的凭证"), "external_credential_required")
572
+ revived = row["status"] != "active"
573
+ if revived:
574
+ if row["end_reason"] != "expired":
575
+ raise classified(PermissionError, ENDED_TEXTS.get(row["end_reason"], ENDED_TEXTS["revoked"]), "external_ended",
576
+ reason=row["end_reason"] or "revoked")
577
+ if connection.execute("SELECT 1 FROM room_members WHERE room_id=? AND name=? AND status<>'removed' AND id<>?",
578
+ (room_id, row["name"], row["id"])).fetchone():
579
+ raise FileExistsError(Text("{name} 已是本房间成员", name=row["name"]))
580
+ if connection.execute("SELECT COUNT(*) FROM room_members WHERE room_id=? AND status<>'removed'", (room_id,)).fetchone()[0] >= MAX_ROOM_AGENTS:
581
+ raise FileExistsError(Text("房间成员已满"))
582
+ connection.execute("UPDATE room_members SET status='active' WHERE id=?", (row["id"],))
583
+ connection.execute("UPDATE external_members SET ended_at=0,end_reason='' WHERE member_id=?", (row["id"],))
584
+ connection.execute("UPDATE external_members SET expires_at=?,updated_at=? WHERE member_id=?", (expires_at, now, row["id"]))
585
+ if revived:
586
+ free_room.sync_participants(connection, room_id)
587
+ return {"expires_at": expires_at, "revived": revived}
602
588
 
603
589
 
604
590
  def leave_room(connection, member):
@@ -620,6 +606,9 @@ def external_api(connection, parts, params, method, token, read_payload, hooks):
620
606
  (body, status)
621
607
  """
622
608
  room_id, route = parts[3], parts[4:]
609
+ # Renewing is the one route a member whose time ran out may still use: it brings the member back.
610
+ if method == "POST" and route == ["expiry"]:
611
+ return lend_until(connection, room_id, token, read_payload()), 200
623
612
  member = require_external(connection, room_id, token)
624
613
  reading = {key: params[key] for key in MESSAGE_PARAMS if key in params}
625
614
  if method == "GET" and route == ["view"]:
@@ -648,8 +637,6 @@ def external_api(connection, parts, params, method, token, read_payload, hooks):
648
637
  return hooks["answer"](connection, room_id, answer_payload(member, payload), member), 201
649
638
  if route == ["ai"]:
650
639
  return report_ai(connection, member, payload), 200
651
- if route == ["expiry"]:
652
- return lend_until(connection, member, payload), 200
653
640
  if route == ["leave"]:
654
641
  return leave_room(connection, member), 200
655
642
  raise LookupError(Text("地址不存在"))
package/backend/server.py CHANGED
@@ -3202,6 +3202,9 @@ class DiscussionHandler(BaseHTTPRequestHandler):
3202
3202
  connection.commit()
3203
3203
  if parts[3:4] == ["external-members"]:
3204
3204
  result, status = external_owner_api(connection, room_id, parts[4:], params, method, token, self.read_payload)
3205
+ # Revoking (or finding expired) the member that held the room frees it: messages queued behind it go now.
3206
+ if method == "POST":
3207
+ drain_room_queue(connection, room_id)
3205
3208
  connection.commit()
3206
3209
  return self.respond(result, status)
3207
3210
  if parts[3:] == ["discussion"]:
package/docs/en/runner.md CHANGED
@@ -90,9 +90,9 @@ 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 what they can see (Room messages / Messages and project). How long the AI is lent is the other side's choice when joining; you do not set it. "Messages and project" opens all of the room's project folders.
93
- 2. Choose Invite (automatic when creating the room). The seat appears immediately in the right-hand roster. When added from the invite dialog, the dialog stays on an "added" step where you can choose Copy invitation link right away. Above the message box, "<name> awaiting check-in: send the invitation link to the invitee" offers Copy invitation link (also in the member menu), or Invitation details for the QR code; share either. The link lasts 10 minutes and binds one member; regenerating it invalidates the previous link. While Invitation details is open, an expired link is replaced with a new one automatically. 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 Invite (automatic when creating the room). The seat appears immediately in the right-hand roster. When added from the invite dialog, the dialog stays on an "added" step where you can choose Copy invitation link right away. Above the message box, "<name> awaiting check-in: send the invitation link to the invitee" offers Copy invitation link (also in the member menu), or Invitation details for the QR code; share either. The link lasts 10 minutes and binds one member; regenerating it invalidates the previous link. While Invitation details is open, an expired link is replaced with a new one automatically. 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. Read logs and access adjustments appear after check-in.
94
94
  3. Redemption completes check-in and starts the loan time, 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
- 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 switch to messages only, or revoke; revoking takes effect immediately. The time left is set by the other side and only shown here. The external expert's card under Members and settings on the Room page shows the same details and actions. Once a member has ended (expired, left or revoked) it stays dimmed below the roster with the reason; Invite back makes a new link that brings the same member back, keeping its name and history in the room. If the other side still keeps its invited-room record, that record and its settings carry on; if it was deleted, a new one starts.
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 switch to messages only, or revoke; revoking takes effect immediately. The time left is set by the other side and only shown here. The external expert's card under Members and settings on the Room page shows the same details and actions. Once a member has ended (expired, left or revoked) it stays dimmed below the roster with the reason. An expired member can be renewed by the other side, which brings it back at once; for one that was revoked or left, Invite back makes a new link that brings the same member back, keeping its name and history in the room.
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)**:
@@ -105,11 +105,11 @@ Invite an AI on another computer into your room: it reads only the project files
105
105
  | Local access | Room only: limited to CoDiscuss commands, running in an empty temporary folder · Unrestricted: can read local files and use the network |
106
106
  | Lent for | 1 hour · Today · 3 days (3 days at most). The membership ends when it runs out; renew before then to continue |
107
107
 
108
- The external room page shows the other room's chat like a room's messages, read only (scroll up for earlier messages); the requests to your AI carry how they went on this computer. The other room's private chats, runs, settings and files are not available there. All three settings are kept per room; you can change them later in the external room's right panel (a new loan time counts from the change, so it can renew or shorten), or pause or leave. Once the room has ended, you can delete its record from this computer. `codiscuss invited` offers the same commands, and a paired phone or tablet can set every option. The local service does the waking, so keep codiscuss running. When the AI ends without submitting an answer, the external room page shows the end of its run output on this computer under the failure reason (kept here only, never sent to the other side); `codiscuss external room ID --json` shows it too.
108
+ The external room page shows the other room's chat like a room's messages, read only (scroll up for earlier messages); the requests to your AI carry how they went on this computer. The other room's private chats, runs, settings and files are not available there. All three settings are kept per room; you can change them later in the external room's right panel (a new loan time counts from the change, so it can renew or shorten; a record whose time ran out comes back at once with Renew, unless the other side revoked it), or pause or leave. Once the room has ended, you can delete its record from this computer. `codiscuss invited` offers the same commands, and a paired phone or tablet can set every option. The local service does the waking, so keep codiscuss running. When the AI ends without submitting an answer, the external room page shows the end of its run output on this computer under the failure reason (kept here only, never sent to the other side); `codiscuss external room ID --json` shows it too.
109
109
 
110
110
  **Supported tools**: Room only needs 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), so does the Antigravity CLI, tested on version 1.5.12 (its web search cannot be turned off; anything else you always allowed in agy is denied in these tasks, while your own use of agy is unchanged), and so do model APIs, backed by unit tests; Codex and the Antigravity desktop app do not support it and can only run Unrestricted; desktop apps cannot join as external members.
111
111
 
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.
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; the total amount and number of reads are not limited.
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.
package/docs/runner.md CHANGED
@@ -121,9 +121,9 @@ codiscuss local connect https://你的站点
121
121
 
122
122
  **邀请(你的电脑)**:
123
123
  1. 建房面板或右栏“邀请成员”里点“外部”一行的“外部专家 +”(可加多位),翻到卡片背面设置“对方能看到”(房间消息 / 消息和项目)。借出多久由对方加入时决定,你不用设。选“消息和项目”时开放本房间的全部项目目录。
124
- 2. 点“邀请”(建房时自动添加),右栏名单立即显示待签到成员。从邀请弹窗添加时,弹窗会停在“已加入”一步,可直接点“复制邀请链接”。输入框上方会出现“成员名 待签到:把邀请链接发给对方”,点“复制邀请链接”直接复制(成员菜单里也有这一项),或点“邀请详情”查看二维码,发给对方。链接 10 分钟有效,只能绑定一位成员;重新生成会立即作废旧链接。“邀请详情”开着时,链接到期会自动换成新的。未绑定线上站点时显示“待生成链接”及原因,绑定站点后从席位菜单生成。待签到面板显示自动结束期限,可“移除席位”;签到后才显示用量、读取记录和授权调整。
124
+ 2. 点“邀请”(建房时自动添加),右栏名单立即显示待签到成员。从邀请弹窗添加时,弹窗会停在“已加入”一步,可直接点“复制邀请链接”。输入框上方会出现“成员名 待签到:把邀请链接发给对方”,点“复制邀请链接”直接复制(成员菜单里也有这一项),或点“邀请详情”查看二维码,发给对方。链接 10 分钟有效,只能绑定一位成员;重新生成会立即作废旧链接。“邀请详情”开着时,链接到期会自动换成新的。未绑定线上站点时显示“待生成链接”及原因,绑定站点后从席位菜单生成。待签到面板显示自动结束期限,可“移除席位”;签到后才显示读取记录和授权调整。
125
125
  3. 对方兑换即完成签到,借出时间从兑换时开始,**没有额外批准步骤**。未签到不收任务、不参与全体回应或讨论,7 天后自动结束;链接过期不会删除席位。
126
- 4. 在房间里 `@` 它,回答照常出现在对话中。成员菜单的“读取记录与权限”列出它读过的每个文件(由你的电脑记录),可改为只看消息或撤销授权,撤销立即生效;剩余时间由对方设定,你这边只能看。房间页“成员与设置”里的外部专家卡片显示同样的信息与操作。成员结束后(到期、对方退出或撤销)仍灰显在名单下方并写明原因,点“重新邀请”可生成新链接把原成员请回:名字和房间里的历史不变;对方若还保留那条被邀请记录,记录与设置也接着用,删了则新建。
126
+ 4. 在房间里 `@` 它,回答照常出现在对话中。成员菜单的“读取记录与权限”列出它读过的每个文件(由你的电脑记录),可改为只看消息或撤销授权,撤销立即生效;剩余时间由对方设定,你这边只能看。房间页“成员与设置”里的外部专家卡片显示同样的信息与操作。成员结束后(到期、对方退出或撤销)仍灰显在名单下方并写明原因。到期的成员可由对方自己续期,立即回到房间;被撤销或退出的,点“重新邀请”生成新链接把原成员请回,名字和房间里的历史不变。
127
127
  5. 签到后头像显示对方 AI 的厂家,“读取记录与权限”里可看到软件和模型;对方换 AI 后自动更新。这些信息由对方电脑自报,仅供辨认。自定义接口显示外部专家图标。
128
128
 
129
129
  **加入(对方电脑)**:
@@ -136,11 +136,11 @@ codiscuss local connect https://你的站点
136
136
  | 本机权限 | 只在房间里发言:只能用共议命令,在空的临时目录运行 · 不受限:可读本机文件、联网 |
137
137
  | 借出时间 | 1 小时 · 今天 · 3 天(最长 3 天)。到期后成员资格结束,要继续须在到期前续期 |
138
138
 
139
- 外部房间的页面像房间消息页一样显示对方房间的聊天记录(只读,往上滚动可看更早的消息),点名你 AI 的请求标有在这台电脑上的处理结果;对方房间的私聊、执行、房间设置与文件都不开放。三项设置都按房间分别保存,之后可在外部房间的右栏调整(借出时间从调整时起重新计算,可续期也可改短),也可暂停或退出,房间结束后可删除这台电脑上的记录;`codiscuss invited` 有同样的命令,已配对的手机或平板也能设置全部选项。唤醒由本机服务完成,请保持 codiscuss 运行。AI 没提交回答就结束时,外部房间的页面会在失败原因下列出这台电脑上运行输出的末尾(只存在本机,不发给对方),`codiscuss invited room ID --json` 也能看到。
139
+ 外部房间的页面像房间消息页一样显示对方房间的聊天记录(只读,往上滚动可看更早的消息),点名你 AI 的请求标有在这台电脑上的处理结果;对方房间的私聊、执行、房间设置与文件都不开放。三项设置都按房间分别保存,之后可在外部房间的右栏调整(借出时间从调整时起重新计算,可续期也可改短;已经到期的记录点“续期”即可立即回到对方房间,被对方撤销的不行),也可暂停或退出,房间结束后可删除这台电脑上的记录;`codiscuss invited` 有同样的命令,已配对的手机或平板也能设置全部选项。唤醒由本机服务完成,请保持 codiscuss 运行。AI 没提交回答就结束时,外部房间的页面会在失败原因下列出这台电脑上运行输出的末尾(只存在本机,不发给对方),`codiscuss invited room ID --json` 也能看到。
140
140
 
141
141
  **支持的软件**:“只在房间里发言”要求软件能限制为只用共议命令,目前支持 Claude Code(后台运行,已在 2.1.325 版实测,其他版本未逐一验证)、Antigravity CLI(已在 1.5.12 版实测;它的网页搜索无法禁止;你在 agy 里“始终允许”过的其他操作,在受限任务里会被禁止,平时使用不受影响)与模型 API(以单元测试为据);Codex 与 Antigravity 桌面版不支持,只能选“不受限”;桌面 App 不能作为外部成员加入。
142
142
 
143
- **能读到什么**:开放目录中 Git 管理的文件(含未提交的改动,忽略 `.gitignore` 里的文件),非 Git 目录则是除 `node_modules` 等生成目录外的文件。`.env` 一类文件、私钥与证书、凭据文件、`.git`、开放目录根下的 `data/` 永不开放;指向目录外的链接被拒绝。它只能读,不能写文件或执行命令,也看不到私聊、其他房间和本机路径。每次最多读 128 KiB,默认每小时 4 MiB、总量 64 MiB、每小时 600 次。
143
+ **能读到什么**:开放目录中 Git 管理的文件(含未提交的改动,忽略 `.gitignore` 里的文件),非 Git 目录则是除 `node_modules` 等生成目录外的文件。`.env` 一类文件、私钥与证书、凭据文件、`.git`、开放目录根下的 `data/` 永不开放;指向目录外的链接被拒绝。它只能读,不能写文件或执行命令,也看不到私聊、其他房间和本机路径。每次最多读 128 KiB,读取总量与次数不设上限。
144
144
 
145
145
  **须知**:
146
146
  - 读出去的内容收不回:它会留在对方 AI 的会话里,并发送给对方的模型服务商;撤销只阻止以后的读取。
@@ -379,11 +379,14 @@
379
379
  "不需要域名:经共议线上网站中转到这台电脑,手机和外地的电脑都能打开。需要先把这台电脑绑定到线上网站。": "No domain needed: relayed through the CoDiscuss online site to this computer, so phones and computers elsewhere can open it. Bind this computer to the online site first.",
380
380
  "已开启经线上网站中转": "Relay through the online site turned on",
381
381
  "已关闭经线上网站中转": "Relay through the online site turned off",
382
- "其他设备远程使用、邀请外部专家、托管账号经线上网站登录都需要": "Needed for using this computer from other devices, inviting external experts, and hosted accounts signing in through the online site",
383
382
  "在部署线上网站的电脑上,为其他电脑生成绑定用的接入码": "On the computer that deployed the online site, make an access code for binding another computer",
384
383
  "绑定共议线上网站(形如 https://xxx.pages.dev),不是你的自有域名": "Bind the CoDiscuss online site (like https://xxx.pages.dev), not your own domain",
385
384
  "在部署线上网站的电脑上生成(它的管理面板“本机 → 线上网站 → 生成接入码”,或运行 codiscuss admin entry code),只能用一次。就在那台电脑上绑定时,只填站点地址即可。": "Generate it on the computer that deployed the online site (its management panel: This computer → Online site → Generate access code, or run codiscuss admin entry code); each code works once. On that computer itself, the site address alone is enough.",
386
385
  "发给要绑定的电脑,在它的管理面板“本机 → 线上网站 → 绑定”里粘贴。只能用一次;再生成一个会让之前没用过的作废。": "Send it to the computer to bind and paste it in its management panel under This computer → Online site → Bind. It works once; generating another voids any unused earlier one.",
387
386
  "不需要域名:经共议线上网站中转到这台电脑,手机和外地的电脑都能打开。": "No domain needed: relayed through the CoDiscuss online site to this computer, so phones and computers elsewhere can open it.",
388
- "密码仅在重设时显示一次": "The password is shown only when it is reset"
387
+ "密码仅在重设时显示一次": "The password is shown only when it is reset",
388
+ "在外面用其他设备使用这台电脑、邀请外部专家时需要": "Needed to use this computer from other devices while away, and to invite external experts",
389
+ "只供你自己在外面使用这台电脑、邀请外部专家;托管账号走自有域名,不经过它": "Only for you, to use this computer while away and to invite external experts; hosted accounts go through your own domain, not this",
390
+ "你在外面使用这台电脑,以及托管账号的登录和邀请外部专家,都经过它": "You using this computer while away, and hosted accounts signing in and inviting external experts, all go through this",
391
+ "你在外面使用这台电脑、邀请外部专家时经过它;托管账号默认走自有域名,也可以经它登录": "You use this when away from this computer and when inviting external experts; hosted accounts use your own domain by default but can also sign in through it"
389
392
  }
@@ -791,7 +791,6 @@
791
791
  "expires_at 须为晚于现在、不超过 {days} 天的秒级时间": "expires_at must be a time in seconds later than now and within {days} days",
792
792
  "op 须为 ls、read 或 grep,outcome 须为 ok 或 denied": "op must be ls, read or grep, and outcome must be ok or denied",
793
793
  "outcome 须为 declined 或 timeout": "outcome must be declined or timeout",
794
- "quota 只能包含 hourly_bytes、total_bytes、hourly_reads": "quota may only contain hourly_bytes, total_bytes and hourly_reads",
795
794
  "reason 不超过 {limit} 字,outcome 为 denied 时必填": "reason must be at most {limit} characters and is required when outcome is denied",
796
795
  "request_ids 须为 1–{limit} 个不重复的请求编号": "request_ids must be 1 to {limit} distinct request IDs",
797
796
  "root 须为非负整数,path 不超过 {limit} 字": "root must be a non-negative integer and path at most {limit} characters",
@@ -814,12 +813,8 @@
814
813
  "开放目录不能重复": "Opened directories cannot repeat",
815
814
  "房间成员已变化,请重新读取外部成员名单后再提交": "The room's members have changed; read the external member list again before submitting",
816
815
  "房间成员已满": "The room is full",
817
- "本小时读取次数已达上限": "The hourly read count limit has been reached",
818
- "本小时读取量已达上限": "The hourly read volume limit has been reached",
819
816
  "该外部成员只讨论,未开放读取项目": "This external member is discussion-only and cannot read the project",
820
817
  "该目录未对外部成员开放": "This directory is not open to the external member",
821
- "读取总量已达上限": "The total read volume limit has been reached",
822
- "配额 {key} 须为 1–{limit} 的整数": "Quota {key} must be an integer from 1 to {limit}",
823
818
  "需要本房间外部成员的凭证": "This room's external member credential is required",
824
819
  "diffs 须为最多 {max_changed_files} 项的列表": "diffs must be a list of at most {max_changed_files} items",
825
820
  "这台电脑未绑定线上网站,请在管理面板“本机 → 线上网站”处绑定": "This computer is not bound to an online site. Bind it under This computer → Online site in the management panel.",
@@ -183,7 +183,6 @@
183
183
  "无法读取这个邀请链接": "This invitation link can't be read",
184
184
  "链接可能被截断或改动过。请让对方重新复制完整链接发给你。": "The link may have been cut off or changed. Ask them to copy the complete link and send it again.",
185
185
  "对方电脑上的 AI,只读本房间开放的内容": "An AI on their computer; reads only what this room opens",
186
- "用量": "Usage",
187
186
  "正在读取读取记录": "Loading the read log",
188
187
  "对方电脑在时限内没有确认唤醒": "Their computer did not confirm the run in time",
189
188
  "对方电脑拒绝了这次唤醒": "Their computer declined this run",
@@ -192,7 +191,6 @@
192
191
  "剩 {count} 天": "{count}d",
193
192
  "剩 {count} 小时": "{count}h",
194
193
  "剩 {count} 分": "{count}m",
195
- "{used} / {limit} · 本小时 {hour} / {hour_limit} · 被拒 {denied} 次": "{used} / {limit} · this hour {hour} / {hour_limit} · {denied} refused",
196
194
  "外部专家 · 待签到": "External expert · Awaiting check-in",
197
195
  "待签到": "Awaiting check-in",
198
196
  "重新生成链接": "Regenerate link",
@@ -221,8 +219,6 @@
221
219
  "借出时间": "Lent for",
222
220
  "借出多久由你决定,最长 3 天;加入后可在外部房间里续期或改短。": "You decide how long to lend it, up to 3 days; after joining you can renew or shorten it in the external room.",
223
221
  "借出时间已更新": "Loan time updated",
224
- "由对方决定": "Set by the invitee",
225
- "借出多久由对方加入时决定,你可随时撤销。": "The invitee decides how long to lend its AI when joining; you can revoke at any time.",
226
222
  "对方设定": "set by the invitee",
227
223
  "借出到": "Lent until",
228
224
  "对方未说明": "Not stated",
@@ -232,5 +228,16 @@
232
228
  "借出多久由对方决定,你可随时撤销": "The invitee decides how long it is lent; you can revoke at any time",
233
229
  "由对方加入时决定": "Set by the invitee when joining",
234
230
  "不变": "Unchanged",
235
- "从现在起重新计算,最长 3 天": "Counted again from now, 3 days at most"
231
+ "从现在起重新计算,最长 3 天": "Counted again from now, 3 days at most",
232
+ "绑定了多个线上网站,生成链接时选择": "Several hosted sites connected; choose one when making the link",
233
+ "未绑定线上网站,无法生成链接": "No hosted site connected; a link cannot be made",
234
+ "目录": "Folders",
235
+ "中转": "Relay",
236
+ "调整「{room}」的设置": "Settings for “{room}”",
237
+ "只影响你这台电脑上的 AI,对方房间的开放范围由对方决定。": "Only affects your AI on this computer; what the other room opens is up to its owner.",
238
+ "当前借出到 {time}": "Currently lent until {time}",
239
+ "正在添加席位…": "Adding the seat…",
240
+ "借出时间已到;点“续期”即可回到对方房间。": "The loan time is up; choose Renew to go back to the other room.",
241
+ "续期": "Renew",
242
+ "借出时间已到,保存后立即回到对方房间。": "The loan time is up; saving takes you back to the other room at once."
236
243
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.4.95",
3
+ "version": "0.4.97",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -2399,6 +2399,8 @@ export async function launch_main(args = process.argv.slice(2), input_text) {
2399
2399
  let result;
2400
2400
  if (positionals[0] === 'settings') result = { ...(input ? save_launch_settings(home, input) : launch_settings(home)), api_providers: API_PROVIDERS,
2401
2401
  scheduler_providers: SCHEDULER_PROVIDERS, scheduler_modes: SCHEDULER_MODES, scheduler_default_mode: DEFAULT_SCHEDULER_MODE, api_keys: saved_api_keys(home), managed_api_keys: restricted ? managed_api_keys(home) : [], projects: launch_projects(home).projects, projects_restricted: restricted, full_access_only: ADAPTER_IDS.filter(id => adapter_capabilities(id).no_sandbox), workspace: space.workspace, user_home: restricted ? homedir() : '', ...expert_presets(home), ...workflow_library(home) };
2402
+ // The online site an invitation would use, so an external expert's card says before the room exists whether a link can be made.
2403
+ if (positionals[0] === 'settings') result.invite_site = await (await import('./external_gateway.mjs')).invite_site_state(home);
2402
2404
  else if (positionals[0] === 'projects') result = input ? save_launch_projects(home, input) : launch_projects(home);
2403
2405
  else if (positionals[0] === 'presets') result = input ? save_expert_presets(home, input) : expert_presets(home);
2404
2406
  else if (positionals[0] === 'workflows') result = await workflows_command(home, input || {});
@@ -459,14 +459,22 @@ export function lend_until(duration, now = Date.now()) {
459
459
  return Math.floor((now + HOUR_MS) / 1000);
460
460
  }
461
461
 
462
- /** Change how long this record's AI stays lent; the inviting room confirms the new end, which the record then keeps. */
462
+ /**
463
+ * Change how long this record's AI stays lent; the inviting room confirms the new end, which the record then keeps. A
464
+ * record whose time ran out renews the same way and is active again at once; one revoked there, or left here, cannot.
465
+ */
463
466
  export async function lend(home, { id, duration }, deps = {}) {
464
467
  const expires_at = lend_until(duration, deps.now?.() ?? Date.now());
465
468
  const record = find_record(read_store(home), id);
466
- if (record.status !== 'active') throw failure('record_ended', '这条被邀请记录已结束,不能再改借出时间');
469
+ const lapsed = record.status === 'ended' && record.end_reason === 'expired';
470
+ if (record.status !== 'active' && !lapsed) throw failure('record_ended', '这条被邀请记录已结束,不能再改借出时间');
467
471
  const answer = await member_api(home, id, 'POST', MEMBER_API.expiry(record.room), { expires_at }, deps);
468
472
  return change_record(home, id, (current, now, store) => {
469
473
  current.expires_at = Number(answer?.expires_at || expires_at) * 1000;
474
+ if (lapsed) {
475
+ current.status = 'active';
476
+ delete current.end_reason;
477
+ }
470
478
  return { record: record_view(current, store) };
471
479
  });
472
480
  }
@@ -505,11 +513,9 @@ export async function join_invite(home, input, deps = {}) {
505
513
  const name = joined.machine?.name || keys.name || invite.machine_name;
506
514
  const machine = store.machines[keys.fingerprint] ||= {};
507
515
  Object.assign(machine, { machine: keys.id, site: invite.site, machine_name: name, updated_at: now });
508
- // Invited back as the same member of the same room: the record this computer still keeps carries on, with its
509
- // history and settings; once deleted, a new record starts.
510
- const previous = Object.values(store.records).find(record => record.id !== attempt.id && record.machine_fingerprint === keys.fingerprint
511
- && record.room === joined.room.id && record.member === joined.member.name && (record.member_id ?? null) === (joined.member.id ?? null));
512
- const id = previous?.id || attempt.id;
516
+ // Every join starts a record of its own with the AI and settings picked for it, even when invited back as a member
517
+ // this computer already has a record of (user 2026-11-19): the earlier record stays as it ended.
518
+ const id = attempt.id;
513
519
  const fresh = { id, site: invite.site, machine: keys.id, machine_name: name, machine_fingerprint: keys.fingerprint,
514
520
  machine_key: keys.public_key, fingerprint_checked: Boolean(invite.fingerprint), room: joined.room.id, room_title: String(joined.room.name || invite.room_name),
515
521
  member: joined.member.name, member_id: joined.member.id ?? null, key_id, open_level: joined.level || invite.level || 'read',
@@ -517,13 +523,8 @@ export async function join_invite(home, input, deps = {}) {
517
523
  expires_at: Number(joined.expires_at) ? Number(joined.expires_at) * 1000 : null, ai, ai_reported: JSON.stringify(identity),
518
524
  limits: null, paused: false, status: 'active', contact: { at: now, state: 'online', error: '' }, approvals: [], running: null,
519
525
  ...(session_id ? { session_id } : {}) };
520
- if (previous) {
521
- const { end_reason, leave_pending, ...kept } = previous;
522
- store.records[id] = { ...kept, ...fresh, rejoined_at: now };
523
- } else {
524
- // Accepting the invitation is the consent: a new record answers at once, confined.
525
- store.records[id] = { ...fresh, wake: 'auto', confined: true, wakes: 0, last_wake_at: null, history: [], joined_at: now };
526
- }
526
+ // Accepting the invitation is the consent: a new record answers at once, confined.
527
+ store.records[id] = { ...fresh, wake: 'auto', confined: true, wakes: 0, last_wake_at: null, history: [], joined_at: now };
527
528
  const values = secrets.get();
528
529
  values[id] = { private_key: pair.private_key, token: joined.token };
529
530
  // A retry of this join finds the record it ended up in.
@@ -869,7 +870,10 @@ async function start_run(home, record, execution, { lockdown, software, end, res
869
870
  role: 'member', cwd: null, project_access: 'read', draft_directory: drafts, open_level: record.open_level, directories,
870
871
  skills: ['discuss-participant/SKILL.md', 'discuss-participant/references/room.md'].map(file => join(skills_directory, file)),
871
872
  cli, subcommands: TASK_SUBCOMMANDS, access_file: access_path, tool_lockdown: lockdown, instructions });
872
- const profile = { adapter: record.ai.adapter, ...software, model: record.ai.model || software.model || '', effort: record.ai.effort, cwd: workdir, project_access: 'read',
873
+ // 不受限 means the AI works on this computer as usual (全放开): a sandbox would run its commands as another Windows
874
+ // account, which cannot open the record's credential (DPAPI, current user), so its `codiscuss` calls would all fail.
875
+ // A locked-down run is confined by the tool rules instead and keeps read-only.
876
+ const profile = { adapter: record.ai.adapter, ...software, model: record.ai.model || software.model || '', effort: record.ai.effort, cwd: workdir, project_access: lockdown ? 'read' : 'full',
873
877
  ...(Object.hasOwn(record.ai, 'system_prompt') ? { system_prompt: record.ai.system_prompt } : {}) };
874
878
  const log_path = join(base, `external-${execution.id}.log`);
875
879
  const deliver = deps.deliver || (await import('./adapters/index.mjs')).deliver_task;
@@ -198,6 +198,12 @@ async function invite_site(home, site_url) {
198
198
  return { site: found[0], link: found[1] };
199
199
  }
200
200
 
201
+ /** The site an invite would name now: `{ site }`, or `{ problem }` (`site_missing` / `site_required`) when none can be picked. */
202
+ export async function invite_site_state(home) {
203
+ try { return { site: (await invite_site(home)).site }; }
204
+ catch (error) { return { problem: error.code || 'site_missing' }; }
205
+ }
206
+
201
207
  /**
202
208
  * Issue an invite for one room: a 12-character code valid ten minutes, kept here only as its hash, and the link that
203
209
  * carries it with this computer's key fingerprint. The code and link are returned this once.
@@ -298,8 +304,12 @@ export function external_entries(home, site) {
298
304
  .map(([id, entry]) => ({ id, x: entry.public_key.x, y: entry.public_key.y, kind: 'external', room: entry.room_id, expires_at: entry.key_expires_at }));
299
305
  }
300
306
 
301
- /** Forget an external member's key, so the website stops letting it through. */
307
+ /**
308
+ * Forget an external member's key, so the website stops letting it through. A member whose time ran out keeps its key: it
309
+ * may renew itself back (the room backend's `/expiry`), and the key still lapses on its own after KEY_DAYS unused.
310
+ */
302
311
  async function drop_external(home, ctx, external_id, reason) {
312
+ if (reason === 'expired') return;
303
313
  const dropped = with_registry(home, registry => {
304
314
  const existed = Boolean(registry.externals[external_id]);
305
315
  delete registry.externals[external_id];
@@ -495,7 +505,7 @@ async function external_repo(home, ctx, external_id, entry, room, payload) {
495
505
  if (!result.ok) return { status: 403, body: { ...text_of('读取被拒绝({reason})', { reason: result.reason }), code: 'engine_denied', reason: result.reason } };
496
506
  if (record.status !== 200 || record.body?.allowed !== true || record.body?.recorded !== true) {
497
507
  return { status: record.status === 200 ? 403 : record.status >= 500 ? 503 : record.status,
498
- body: { ...(record.body?.allowed === false ? text_of('读取超出配额或不被允许({reason})', { reason: record.body.code || '' }) : text_of('读取记录写入失败,未返回内容')),
508
+ body: { ...(record.body?.allowed === false ? text_of('读取不被允许({reason})', { reason: record.body.code || '' }) : text_of('读取记录写入失败,未返回内容')),
499
509
  code: record.body?.code || 'audit_failed',
500
510
  reason: record.body?.code || 'audit_failed' } };
501
511
  }
@@ -507,7 +507,7 @@ export default {
507
507
  "读取操作须为 ls、read 或 grep": "The read operation must be ls, read or grep",
508
508
  "读取被拒绝({reason})": "Read refused ({reason})",
509
509
  "读取记录写入失败,未返回内容": "The read could not be recorded, so no content was returned",
510
- "读取超出配额或不被允许({reason})": "The read exceeds the quota or is not allowed ({reason})",
510
+ "读取不被允许({reason})": "The read is not allowed ({reason})",
511
511
  "这个目录没有对你开放": "This folder is not open to you",
512
512
  "这位外部成员只能讨论,不能读取项目": "This external member can discuss but cannot read the project",
513
513
  "这位外部成员未登记或已移除": "This external member is not registered or has been removed",