ai_co_discuss 0.4.96 → 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.
- package/backend/external_members.py +47 -64
- package/docs/en/runner.md +4 -4
- package/docs/runner.md +4 -4
- package/frontend/locales/en/admin.json +5 -2
- package/frontend/locales/en/backend.json +0 -5
- package/frontend/locales/en/external.json +4 -5
- package/package.json +1 -1
- package/runner/external_client.mjs +15 -14
- package/runner/external_gateway.mjs +6 -2
- package/runner/i18n_en.mjs +1 -1
- package/web/admin.css +1 -1
- package/web/admin.js +2 -2
- package/web/i18n.js +2 -2
- package/web/modern.css +1 -1
- package/web/modern.js +39 -39
|
@@ -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
|
|
5
|
-
|
|
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
|
-
|
|
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
|
|
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"],
|
|
119
|
-
"
|
|
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,
|
|
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=?,
|
|
343
|
-
|
|
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,
|
|
461
|
-
"""Decide one read: (allowed, code, reason).
|
|
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
|
|
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,
|
|
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):
|
|
@@ -540,8 +499,7 @@ def member_room_view(connection, room_id, member):
|
|
|
540
499
|
latest = connection.execute("""SELECT COALESCE(MAX(id),0) FROM messages m WHERE room_id=?
|
|
541
500
|
AND NOT EXISTS (SELECT 1 FROM internal_task_messages t WHERE t.message_id=m.id)""", (room_id,)).fetchone()[0]
|
|
542
501
|
me = {"member_id": member["id"], "name": member["name"], "label": labels.get(member["name"], member["name"]), "scope": member["scope"],
|
|
543
|
-
"expires_at": member["expires_at"], "directories": directory_names(json.loads(member["directories"]))
|
|
544
|
-
"quota": quota_of(member), "usage": usage_of(connection, member["id"])}
|
|
502
|
+
"expires_at": member["expires_at"], "directories": directory_names(json.loads(member["directories"]))}
|
|
545
503
|
return {"room": {"id": room["id"], "title": room["title"], "goal": room["goal"], "archived": bool(room["archived"])},
|
|
546
504
|
"me": me, "members": members, "latest_message_id": latest}
|
|
547
505
|
|
|
@@ -598,11 +556,35 @@ def report_ai(connection, member, payload):
|
|
|
598
556
|
return {"reported": True}
|
|
599
557
|
|
|
600
558
|
|
|
601
|
-
def lend_until(connection,
|
|
602
|
-
"""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).
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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}
|
|
606
588
|
|
|
607
589
|
|
|
608
590
|
def leave_room(connection, member):
|
|
@@ -624,6 +606,9 @@ def external_api(connection, parts, params, method, token, read_payload, hooks):
|
|
|
624
606
|
(body, status)
|
|
625
607
|
"""
|
|
626
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
|
|
627
612
|
member = require_external(connection, room_id, token)
|
|
628
613
|
reading = {key: params[key] for key in MESSAGE_PARAMS if key in params}
|
|
629
614
|
if method == "GET" and route == ["view"]:
|
|
@@ -652,8 +637,6 @@ def external_api(connection, parts, params, method, token, read_payload, hooks):
|
|
|
652
637
|
return hooks["answer"](connection, room_id, answer_payload(member, payload), member), 201
|
|
653
638
|
if route == ["ai"]:
|
|
654
639
|
return report_ai(connection, member, payload), 200
|
|
655
|
-
if route == ["expiry"]:
|
|
656
|
-
return lend_until(connection, member, payload), 200
|
|
657
640
|
if route == ["leave"]:
|
|
658
641
|
return leave_room(connection, member), 200
|
|
659
642
|
raise LookupError(Text("地址不存在"))
|
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.
|
|
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
|
|
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;
|
|
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
|
|
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
|
|
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",
|
|
@@ -234,11 +232,12 @@
|
|
|
234
232
|
"绑定了多个线上网站,生成链接时选择": "Several hosted sites connected; choose one when making the link",
|
|
235
233
|
"未绑定线上网站,无法生成链接": "No hosted site connected; a link cannot be made",
|
|
236
234
|
"目录": "Folders",
|
|
237
|
-
"读取": "Reads",
|
|
238
|
-
"只读 · 每小时 {hourly} · 共 {total}": "Read only · {hourly} per hour · {total} in all",
|
|
239
235
|
"中转": "Relay",
|
|
240
236
|
"调整「{room}」的设置": "Settings for “{room}”",
|
|
241
237
|
"只影响你这台电脑上的 AI,对方房间的开放范围由对方决定。": "Only affects your AI on this computer; what the other room opens is up to its owner.",
|
|
242
238
|
"当前借出到 {time}": "Currently lent until {time}",
|
|
243
|
-
"正在添加席位…": "Adding the seat…"
|
|
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."
|
|
244
243
|
}
|
package/package.json
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
|
|
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
|
-
//
|
|
509
|
-
//
|
|
510
|
-
const
|
|
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
|
-
|
|
521
|
-
|
|
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.
|
|
@@ -304,8 +304,12 @@ export function external_entries(home, site) {
|
|
|
304
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 }));
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
/**
|
|
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
|
+
*/
|
|
308
311
|
async function drop_external(home, ctx, external_id, reason) {
|
|
312
|
+
if (reason === 'expired') return;
|
|
309
313
|
const dropped = with_registry(home, registry => {
|
|
310
314
|
const existed = Boolean(registry.externals[external_id]);
|
|
311
315
|
delete registry.externals[external_id];
|
|
@@ -501,7 +505,7 @@ async function external_repo(home, ctx, external_id, entry, room, payload) {
|
|
|
501
505
|
if (!result.ok) return { status: 403, body: { ...text_of('读取被拒绝({reason})', { reason: result.reason }), code: 'engine_denied', reason: result.reason } };
|
|
502
506
|
if (record.status !== 200 || record.body?.allowed !== true || record.body?.recorded !== true) {
|
|
503
507
|
return { status: record.status === 200 ? 403 : record.status >= 500 ? 503 : record.status,
|
|
504
|
-
body: { ...(record.body?.allowed === false ? text_of('
|
|
508
|
+
body: { ...(record.body?.allowed === false ? text_of('读取不被允许({reason})', { reason: record.body.code || '' }) : text_of('读取记录写入失败,未返回内容')),
|
|
505
509
|
code: record.body?.code || 'audit_failed',
|
|
506
510
|
reason: record.body?.code || 'audit_failed' } };
|
|
507
511
|
}
|
package/runner/i18n_en.mjs
CHANGED
|
@@ -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
|
-
"
|
|
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",
|