ai_co_discuss 0.6.0 → 0.6.2
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/.agents/skills/discuss-host/SKILL.md +7 -5
- package/.agents/skills/discuss-host/references/experience.md +26 -0
- package/.agents/skills/discuss-host/references/members.md +5 -1
- package/.agents/skills/discuss-host/references/room.md +6 -2
- package/.agents/skills/discuss-host/references/rooms.md +1 -1
- package/.agents/skills/discuss-host/references/workflow.md +3 -1
- package/.agents/skills/discuss-participant/references/interactive-html.md +1 -1
- package/.agents/skills/model-generation/SKILL.md +27 -0
- package/.agents/skills/prompt-design/SKILL.md +34 -0
- package/.agents/skills/prompt-design/agents/openai.yaml +5 -0
- package/.agents/skills/screen-acceptance/SKILL.md +22 -0
- package/.agents/skills/video-generation/SKILL.md +38 -0
- package/.agents/skills/workflow-creator/SKILL.md +1 -1
- package/.agents/steward-skills/dispatch-analysis/SKILL.md +31 -8
- package/README.md +1 -15
- package/README.zh-CN.md +1 -15
- package/backend/free_room.py +8 -5
- package/backend/room_import.py +3 -0
- package/backend/schema.sql +5 -0
- package/backend/server.py +233 -20
- package/docs/en/guide/admin.md +3 -3
- package/docs/en/guide/analytics.md +9 -0
- package/docs/en/guide/cli.md +1 -0
- package/docs/en/guide/faq.md +1 -1
- package/docs/en/guide/first-run.md +1 -1
- package/docs/en/guide/members.md +12 -3
- package/docs/en/guide/rooms.md +5 -4
- package/docs/en/guide/steward.md +2 -0
- package/docs/en/guide/working.md +4 -3
- package/docs/guide/admin.md +3 -3
- package/docs/guide/analytics.md +9 -0
- package/docs/guide/cli.md +1 -0
- package/docs/guide/faq.md +1 -1
- package/docs/guide/first-run.md +1 -1
- package/docs/guide/members.md +12 -3
- package/docs/guide/rooms.md +5 -4
- package/docs/guide/steward.md +2 -0
- package/docs/guide/working.md +4 -3
- package/frontend/locales/en/admin.json +21 -5
- package/frontend/locales/en/analytics.json +5 -0
- package/frontend/locales/en/backend.json +11 -1
- package/frontend/locales/en/core.json +5 -2
- package/frontend/locales/en/discussion.json +27 -3
- package/frontend/locales/en/room.json +15 -0
- package/frontend/locales/en/settings.json +135 -1
- package/package.json +5 -1
- package/runner/account_env.mjs +15 -10
- package/runner/adapters/antigravity_cli.mjs +3 -2
- package/runner/adapters/api.mjs +24 -5
- package/runner/adapters/claude.mjs +103 -4
- package/runner/adapters/common.mjs +11 -0
- package/runner/adapters/index.mjs +70 -9
- package/runner/adapters/profiles.mjs +22 -2
- package/runner/channels.mjs +5 -1
- package/runner/discuss.py +14 -1
- package/runner/discussion_launch.mjs +433 -30
- package/runner/discussion_skills.mjs +4 -1
- package/runner/expert_prompts.mjs +2 -2
- package/runner/free_runner.mjs +52 -22
- package/runner/host_experience.mjs +447 -0
- package/runner/i18n_en.mjs +59 -0
- package/runner/model_service.mjs +19 -4
- package/runner/remote_launch.mjs +12 -4
- package/runner/share_shared.mjs +1 -1
- package/runner/steward.mjs +7 -5
- package/runner/steward_proactive.mjs +7 -3
- package/runner/wakeup_text.mjs +20 -0
- package/runner/workflows.mjs +4 -2
- package/skills/forum-browsing/SKILL.md +1 -1
- package/web/admin.css +1 -1
- package/web/admin.js +8 -8
- package/web/app.js +159 -16
- package/web/guest.js +1 -1
- package/web/i18n.js +7 -4
- package/web/icons/tripo.svg +1 -0
- package/web/modern.css +1 -1
- package/web/modern.js +89 -81
- package/workflows/human-writing/SKILL.md +68 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/LICENSE +21 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/SKILL.md +167 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/VERSION +1 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/agents/openai.yaml +4 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/dist/human-writing-lite.md +25 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/references/fiction.md +119 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/references/formats.md +99 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/references/forum-prose.md +349 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/references/reality.md +119 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/references/revision.md +206 -0
- package/workflows/human-writing/experts/writer/skills/human-writing/scripts/check_prose.py +731 -0
- package/workflows/human-writing/experts/writer/writer.md +33 -0
- package/workflows/human-writing/flow.json +156 -0
- package/workflows/story-serial/SKILL.md +2 -0
- package/workflows/story-serial/workflows/aigc-reduce/flow.json +27 -27
- package/workflows/story-serial/workflows/character-play/SKILL.md +1 -1
- package/workflows/story-serial/workflows/character-play/flow.json +35 -35
- package/workflows/story-serial/workflows/jack-sparrow/flow.json +15 -15
- package/workflows/story-serial/workflows/luke-nichols/flow.json +15 -15
- package/workflows/story-serial/workflows/revise-episodes/flow.json +27 -27
- package/workflows/story-serial/workflows/story-illust/SKILL.md +124 -0
- package/workflows/story-serial/workflows/story-illust/experts/illust_writer.md +25 -0
- package/workflows/story-serial/workflows/story-illust/experts/rev_codex.md +18 -0
- package/workflows/story-serial/workflows/story-illust/experts/rev_cont.md +27 -0
- package/workflows/story-serial/workflows/story-illust/experts/rev_gemini.md +20 -0
- package/workflows/story-serial/workflows/story-illust/flow.json +917 -0
- package/workflows/story-serial/workflows/story-illust/references//347/224/237/345/233/276/346/226/271/346/263/225.md +72 -0
- package/workflows/story-serial/workflows/story-illust/scripts/batch_check.py +338 -0
- package/workflows/story-serial/workflows/story-illust/scripts/book.py +105 -0
- package/workflows/story-serial/workflows/story-illust/scripts/check.py +463 -0
- package/workflows/story-serial/workflows/story-illust/scripts/contact.py +599 -0
- package/workflows/story-serial/workflows/story-illust/scripts/md_tables.py +298 -0
- package/workflows/story-serial/workflows/story-illust/scripts/room_verify.py +546 -0
- package/workflows/story-serial/workflows/story-illust/scripts/sheet.py +210 -0
- package/workflows/story-serial/workflows/story-illust/templates//346/211/271/346/254/241/345/267/245/344/275/234/345/215/225.md +86 -0
- package/workflows/story-serial/workflows/story-illust/templates//350/247/206/350/247/211/350/256/276/345/256/232/350/241/250.md +142 -0
- package/workflows/story-serial/workflows/tidy-docs/flow.json +39 -39
- /package/workflows/story-serial/{agents → experts}/critic.md +0 -0
- /package/workflows/story-serial/{agents → experts}/critic_people.md +0 -0
- /package/workflows/story-serial/{agents → experts}/reader.md +0 -0
- /package/workflows/story-serial/{agents → experts}/recorder.md +0 -0
- /package/workflows/story-serial/{agents → experts}/screenwriter.md +0 -0
- /package/workflows/story-serial/{agents → experts}/writer.md +0 -0
- /package/workflows/story-serial/workflows/character-play/{agents → experts}/character.md +0 -0
- /package/workflows/story-serial/workflows/jack-sparrow/{agents → experts}/jack_sparrow/jack_sparrow.md +0 -0
- /package/workflows/story-serial/workflows/jack-sparrow/{agents → experts}/jack_sparrow/skills/coastal-sailing/SKILL.md +0 -0
- /package/workflows/story-serial/workflows/jack-sparrow/{agents → experts}/jack_sparrow/skills/coastal-sailing/references/catamaran-and-crew.md +0 -0
- /package/workflows/story-serial/workflows/jack-sparrow/{agents → experts}/jack_sparrow/skills/coastal-sailing/references/emergency-and-navigation.md +0 -0
- /package/workflows/story-serial/workflows/jack-sparrow/{agents → experts}/jack_sparrow/skills/coastal-sailing/references/resources-and-systems.md +0 -0
- /package/workflows/story-serial/workflows/jack-sparrow/{agents → experts}/jack_sparrow/skills/coastal-sailing/references/weather-and-anchoring.md +0 -0
- /package/workflows/story-serial/workflows/luke-nichols/{agents → experts}/luke_nichols/luke_nichols.md +0 -0
- /package/workflows/story-serial/workflows/luke-nichols/{agents → experts}/luke_nichols/skills/cold-survival/SKILL.md +0 -0
- /package/workflows/story-serial/workflows/luke-nichols/{agents → experts}/luke_nichols/skills/cold-survival/references/fire-and-fuel.md +0 -0
- /package/workflows/story-serial/workflows/luke-nichols/{agents → experts}/luke_nichols/skills/cold-survival/references/luke-videos.md +0 -0
- /package/workflows/story-serial/workflows/luke-nichols/{agents → experts}/luke_nichols/skills/cold-survival/references/shelter-and-warmth.md +0 -0
- /package/workflows/story-serial/workflows/luke-nichols/{agents → experts}/luke_nichols/skills/cold-survival/references/travel-and-ice.md +0 -0
package/backend/server.py
CHANGED
|
@@ -50,7 +50,7 @@ from .free_room import (active_members, add_member, after_free_message, after_pr
|
|
|
50
50
|
inbox, interrupt_for_message, interrupt_member, member_action, member_capability, member_values, migrate_free_tables, reserve_execution,
|
|
51
51
|
room_failure_wakes, room_quiet_checkins, save_room_access, view_execution, recent_executions, LAST_NOTE_SQL, MAX_MESSAGE_ID)
|
|
52
52
|
from . import moss_channel_sends
|
|
53
|
-
from .free_room import answered_chain, relay_provenance
|
|
53
|
+
from .free_room import answered_chain, relay_provenance, wake_host
|
|
54
54
|
from .free_room import ROOM_FAILURE_RESET_SQL, ROOM_WAITING_SINCE_SQL, STEWARD_SESSION_TEMPLATE, convert_suggestion, message_suggestions, replace_steward_member, save_suggestions, sync_participants
|
|
55
55
|
from .free_room import account_quotas, quota_plans, quota_usage, report_quota, save_quota_plan
|
|
56
56
|
from .free_room import HOST_WITHDRAW_RESULT, INTERJECTION_PARENT_SQL, OWNER_INTERRUPT_RESULT, OWNER_REWIND_RESULT, OWNER_STOP_RESULT, QUEUE_RESTART_RESULT, observed_host_versions
|
|
@@ -317,7 +317,7 @@ ROOM_BACKUP_QUERIES = {
|
|
|
317
317
|
"session_requests": "SELECT * FROM session_requests WHERE session_id IN (SELECT id FROM discussion_sessions WHERE room_id=?) ORDER BY id",
|
|
318
318
|
"task_message_sources": "SELECT * FROM task_message_sources WHERE session_id IN (SELECT id FROM discussion_sessions WHERE room_id=?) ORDER BY message_id",
|
|
319
319
|
**{table: f"SELECT * FROM {table} WHERE message_id IN (SELECT id FROM messages WHERE room_id=?) ORDER BY message_id"
|
|
320
|
-
for table in ("message_details", "message_summaries", "message_timings", "message_dispatch_reasons")},
|
|
320
|
+
for table in ("message_details", "message_summaries", "message_timings", "message_dispatch_reasons", "message_host_experience")},
|
|
321
321
|
}
|
|
322
322
|
ROOM_BACKUP_QUERIES["room_creations"] = "SELECT submission_id,room_id FROM room_creations WHERE room_id=?"
|
|
323
323
|
# Shared membership plus free-room requests; credential hashes are never exported.
|
|
@@ -414,6 +414,7 @@ def room_backup(connection, room_id, *, include_dispatch_reasons=False):
|
|
|
414
414
|
queries = {**ROOM_BACKUP_QUERIES, **FREE_BACKUP_QUERIES}
|
|
415
415
|
if not include_dispatch_reasons:
|
|
416
416
|
del queries["message_dispatch_reasons"]
|
|
417
|
+
del queries["message_host_experience"]
|
|
417
418
|
tables = {table: [dict(row) for row in connection.execute(query, (room_id,))]
|
|
418
419
|
for table, query in queries.items()}
|
|
419
420
|
tables["stored_texts"] = [dict(row) for row in connection.execute(
|
|
@@ -1253,14 +1254,17 @@ def scheduler_decisions(connection, room_id, span=None):
|
|
|
1253
1254
|
return decisions
|
|
1254
1255
|
|
|
1255
1256
|
|
|
1256
|
-
def history_cards(connection, room_id, span):
|
|
1257
|
+
def history_cards(connection, room_id, span, owner=False):
|
|
1257
1258
|
"""The cards placed after messages in `span` (low, high]; high None runs to the end.
|
|
1258
1259
|
|
|
1259
1260
|
The room view carries only the recent executions, plans, missed turns and decisions; the transcript reads the rest
|
|
1260
1261
|
with each batch of messages, so older cards stay where they were instead of disappearing.
|
|
1261
1262
|
"""
|
|
1262
1263
|
decisions = scheduler_decisions(connection, room_id, span)
|
|
1263
|
-
|
|
1264
|
+
executions = recent_executions(connection, room_id, span)
|
|
1265
|
+
if owner:
|
|
1266
|
+
attach_stopped_reasons(connection, room_id, executions)
|
|
1267
|
+
return {"executions": executions, "scheduler_decisions": decisions,
|
|
1264
1268
|
"host_arrangements": host_arrangements(connection, room_id, decisions, span),
|
|
1265
1269
|
"cancelled_turns": cancelled_turns(connection, room_id, span),
|
|
1266
1270
|
"failure_wakes": room_failure_wakes(connection, room_id, span),
|
|
@@ -2945,7 +2949,7 @@ def redact_payload(value, texts=None, path="payload"):
|
|
|
2945
2949
|
if isinstance(value, dict):
|
|
2946
2950
|
result = {}
|
|
2947
2951
|
for key, item in value.items():
|
|
2948
|
-
if key in ("dispatch_reason", "message_dispatch_reasons"):
|
|
2952
|
+
if key in ("dispatch_reason", "message_dispatch_reasons", "experience", "message_host_experience"):
|
|
2949
2953
|
continue
|
|
2950
2954
|
field = f"{path}.{key}"
|
|
2951
2955
|
if API_LOG_SECRET.search(str(key)) or field in ("payload.edits.cover", "payload.link.card"):
|
|
@@ -3615,7 +3619,12 @@ def interjection_subset(connection, message):
|
|
|
3615
3619
|
return selected if selected and set(selected) < original else []
|
|
3616
3620
|
|
|
3617
3621
|
|
|
3618
|
-
def
|
|
3622
|
+
def experience_reader(connection, room_id, token):
|
|
3623
|
+
"""Only the authenticated owner may receive the private dispatch basis."""
|
|
3624
|
+
return getattr(connection, "private_experience_read", True) and api_actor(connection, room_id, token) == "owner"
|
|
3625
|
+
|
|
3626
|
+
|
|
3627
|
+
def message_with_attachments(connection, row, owner=False):
|
|
3619
3628
|
"""Attach the published file list to an original message."""
|
|
3620
3629
|
message = dict(row)
|
|
3621
3630
|
message.pop("no_wake_id", None)
|
|
@@ -3641,7 +3650,16 @@ def message_with_attachments(connection, row):
|
|
|
3641
3650
|
message["silent"] = True
|
|
3642
3651
|
if is_host_dispatch(connection, message["id"]):
|
|
3643
3652
|
message["host_dispatch"] = True
|
|
3653
|
+
if owner:
|
|
3654
|
+
basis = connection.execute("SELECT experience_id AS id,text FROM message_host_experience WHERE message_id=?",
|
|
3655
|
+
(message["id"],)).fetchone()
|
|
3656
|
+
if basis:
|
|
3657
|
+
message["experience"] = dict(basis)
|
|
3644
3658
|
message["dispatch_feedback"] = dispatch_feedback(connection, message["id"])
|
|
3659
|
+
if owner and (message.get("host_dispatch") or message["withdrawn"] and message["author"] == "用户"):
|
|
3660
|
+
target = {"message_id": message["id"]}
|
|
3661
|
+
if dispatch_reason_targets(connection, message["room_id"], target):
|
|
3662
|
+
message["intervention_reason"] = latest_dispatch_reason(connection, message["room_id"], target)
|
|
3645
3663
|
if message.get("interjection_parent_id") and not message.get("interjection_restarted"):
|
|
3646
3664
|
if selected := interjection_subset(connection, message):
|
|
3647
3665
|
message["interjection_targets"] = selected
|
|
@@ -5078,6 +5096,35 @@ def has_host_dispatch_targets(actor, payload):
|
|
|
5078
5096
|
and bool(payload.get("to") or payload.get("detach")))
|
|
5079
5097
|
|
|
5080
5098
|
|
|
5099
|
+
def dispatch_experience(connection, room_id, identifier):
|
|
5100
|
+
"""Resolve an enabled rule from the account which controls this registered room."""
|
|
5101
|
+
home = connection.service_home
|
|
5102
|
+
error = ValueError(Text("经验编号不存在或已停用。"))
|
|
5103
|
+
if not home or not isinstance(identifier, str):
|
|
5104
|
+
raise error
|
|
5105
|
+
try:
|
|
5106
|
+
settings = json.loads((home / "launch-settings.json").read_text(encoding="utf-8-sig"))
|
|
5107
|
+
paths = json.loads((home / "rooms.json").read_text(encoding="utf-8-sig"))["configs"]
|
|
5108
|
+
for path in paths:
|
|
5109
|
+
try:
|
|
5110
|
+
config = json.loads(Path(path).read_text(encoding="utf-8-sig"))
|
|
5111
|
+
except (OSError, ValueError):
|
|
5112
|
+
continue
|
|
5113
|
+
if config.get("room") == room_id and api_actor(connection, room_id, config.get("token", "")) == "owner":
|
|
5114
|
+
break
|
|
5115
|
+
else:
|
|
5116
|
+
raise error
|
|
5117
|
+
entries = settings.get("host_experience", {}).get("entries", [])
|
|
5118
|
+
if "host_experience" not in settings and settings.get("system_prompts", {}).get("host"):
|
|
5119
|
+
entries = [{"id": "host", "text": settings["system_prompts"]["host"], "scope": "global", "enabled": True}]
|
|
5120
|
+
for item in entries:
|
|
5121
|
+
if item["id"] == identifier and item["enabled"]:
|
|
5122
|
+
return item["text"]
|
|
5123
|
+
except (OSError, KeyError, json.JSONDecodeError):
|
|
5124
|
+
pass
|
|
5125
|
+
raise error
|
|
5126
|
+
|
|
5127
|
+
|
|
5081
5128
|
def dispatch_text_and_reason(text, payload):
|
|
5082
5129
|
"""Keep explicit metadata separate and move only an unquoted, final legacy reason line."""
|
|
5083
5130
|
if "dispatch_reason" in payload:
|
|
@@ -5157,6 +5204,7 @@ def append_free_message(connection, room, payload, actor):
|
|
|
5157
5204
|
payload["text"] = expected["text"]
|
|
5158
5205
|
previous = message_with_attachments(connection, previous)
|
|
5159
5206
|
if ((previous.get("relay_room") or None) != (payload.get("relay") or {}).get("room_id")
|
|
5207
|
+
or payload.get("experience_id") != (previous.get("experience") or {}).get("id")
|
|
5160
5208
|
or retry_reason != previous_reason
|
|
5161
5209
|
or any(previous[key] != renumbered_expected(expected, payload, previous)[key] for key in ("author", "text", "reply_to", "kind", "submitted_by", "summary", "summary_by"))
|
|
5162
5210
|
or [item["id"] for item in previous["attachments"]] != identifiers
|
|
@@ -5191,6 +5239,7 @@ def append_free_message(connection, room, payload, actor):
|
|
|
5191
5239
|
check_answer(connection, room_id, actor, payload)
|
|
5192
5240
|
review_plan = checked_review_plan(connection, room_id, actor, payload)
|
|
5193
5241
|
checked_sequence(actor, payload)
|
|
5242
|
+
experience_text = dispatch_experience(connection, room_id, payload["experience_id"]) if "experience_id" in payload else None
|
|
5194
5243
|
dispatch_reason = None
|
|
5195
5244
|
# Proactive work starts its own chain. Only a batch needs an existing chain to send its requests.
|
|
5196
5245
|
if (has_host_dispatch_targets(actor, payload)
|
|
@@ -5213,6 +5262,9 @@ def append_free_message(connection, room, payload, actor):
|
|
|
5213
5262
|
connection.execute("INSERT INTO moss_silent_answers(message_id) VALUES(?)", (cursor.lastrowid,))
|
|
5214
5263
|
connection.execute("INSERT INTO message_summaries (message_id,text,author) VALUES (?,?,?)",
|
|
5215
5264
|
(cursor.lastrowid, expected["summary"], expected["summary_by"]))
|
|
5265
|
+
if experience_text is not None:
|
|
5266
|
+
connection.execute("INSERT INTO message_host_experience VALUES (?,?,?)",
|
|
5267
|
+
(cursor.lastrowid, payload["experience_id"], experience_text))
|
|
5216
5268
|
if dispatch_reason is not None:
|
|
5217
5269
|
# An empty row distinguishes a new dispatch with no recorded reason from an old-format message.
|
|
5218
5270
|
connection.execute("INSERT INTO message_dispatch_reasons (message_id,reason) VALUES (?,?)",
|
|
@@ -5399,6 +5451,8 @@ def read_execution_proposal(connection, room_id, execution_id, member=None, *, r
|
|
|
5399
5451
|
def append_message(connection, room_id, payload, actor):
|
|
5400
5452
|
"""Atomically append an attributed message for the owner or one member, as authorized by `actor`."""
|
|
5401
5453
|
message_values(payload)
|
|
5454
|
+
if "experience_id" in payload and not has_host_dispatch_targets(actor, payload):
|
|
5455
|
+
raise ValueError(Text("只有主持人派活可以引用经验。"))
|
|
5402
5456
|
if "dispatch_reason" in payload and (not has_host_dispatch_targets(actor, payload) or not isinstance(payload["dispatch_reason"], str)):
|
|
5403
5457
|
raise ValueError(Text("dispatch_reason 须为主持人派活时提交的文本"))
|
|
5404
5458
|
begin_write(connection)
|
|
@@ -5822,6 +5876,120 @@ def request_invalidations(request, attempts, legacy_withdraw=False):
|
|
|
5822
5876
|
return [kind for kind in DISPATCH_INVALIDATIONS if kind in reasons]
|
|
5823
5877
|
|
|
5824
5878
|
|
|
5879
|
+
def dispatch_reason_targets(connection, room_id, target):
|
|
5880
|
+
"""Resolve a reason target exactly as the write endpoint does."""
|
|
5881
|
+
execution_id, message_id = target.get("execution_id"), target.get("message_id")
|
|
5882
|
+
if type(execution_id) is int and message_id is None:
|
|
5883
|
+
return connection.execute("""SELECT DISTINCT r.chain_id,r.message_id FROM member_requests r
|
|
5884
|
+
JOIN request_cancel_reasons c ON c.request_id=r.id
|
|
5885
|
+
WHERE r.room_id=? AND r.execution_id=? AND c.reason='user_stop'""", (room_id, execution_id)).fetchall()
|
|
5886
|
+
if type(message_id) is int and execution_id is None:
|
|
5887
|
+
return connection.execute("""SELECT DISTINCT r.chain_id,r.message_id FROM member_requests r
|
|
5888
|
+
WHERE r.room_id=? AND r.message_id=? AND (
|
|
5889
|
+
r.created_by='host' AND r.purpose='ask' OR EXISTS (
|
|
5890
|
+
SELECT 1 FROM message_withdrawals w JOIN messages m ON m.id=w.message_id
|
|
5891
|
+
WHERE w.message_id=r.message_id AND m.author='用户'))""", (room_id, message_id)).fetchall()
|
|
5892
|
+
return []
|
|
5893
|
+
|
|
5894
|
+
|
|
5895
|
+
def latest_dispatch_reason(connection, room_id, target):
|
|
5896
|
+
"""Read only the latest note of this exact target, not notes of its sibling executions."""
|
|
5897
|
+
execution_id, message_id = target.get("execution_id"), target.get("message_id")
|
|
5898
|
+
row = connection.execute("""SELECT json_extract(data,'$.reason') AS reason FROM room_events
|
|
5899
|
+
WHERE room_id=? AND kind='dispatch.user_reason' AND (
|
|
5900
|
+
(? IS NOT NULL AND json_extract(data,'$.execution_id')=?) OR
|
|
5901
|
+
(? IS NOT NULL AND json_extract(data,'$.message_id')=? AND json_extract(data,'$.execution_id') IS NULL)
|
|
5902
|
+
) ORDER BY id DESC LIMIT 1""", (room_id, execution_id, execution_id, message_id, message_id)).fetchone()
|
|
5903
|
+
return row["reason"] if row else ""
|
|
5904
|
+
|
|
5905
|
+
|
|
5906
|
+
def attach_stopped_reasons(connection, room_id, executions):
|
|
5907
|
+
"""Expose an empty or saved note on eligible owner-stop cards only."""
|
|
5908
|
+
for execution in executions:
|
|
5909
|
+
if execution["status"] != "cancelled" or execution["result"] not in USER_STOP_RESULTS:
|
|
5910
|
+
continue
|
|
5911
|
+
target = {"execution_id": execution["id"]}
|
|
5912
|
+
if dispatch_reason_targets(connection, room_id, target):
|
|
5913
|
+
execution["intervention_reason"] = latest_dispatch_reason(connection, room_id, target)
|
|
5914
|
+
|
|
5915
|
+
|
|
5916
|
+
def room_intervention_notes(connection, room_id):
|
|
5917
|
+
"""Read saved notes and eligible taken-back messages for the owner's cached transcript."""
|
|
5918
|
+
messages = {str(row["message_id"]): "" for row in connection.execute("""
|
|
5919
|
+
SELECT DISTINCT r.message_id FROM message_withdrawal_rooms w
|
|
5920
|
+
JOIN member_requests r ON r.message_id=w.message_id AND r.room_id=w.room_id
|
|
5921
|
+
JOIN messages m ON m.id=r.message_id
|
|
5922
|
+
WHERE w.room_id=? AND (m.author='用户' OR r.created_by='host' AND r.purpose='ask')
|
|
5923
|
+
""", (room_id,))}
|
|
5924
|
+
executions = {}
|
|
5925
|
+
for row in connection.execute("""SELECT data FROM room_events
|
|
5926
|
+
WHERE room_id=? AND kind='dispatch.user_reason' ORDER BY id""", (room_id,)):
|
|
5927
|
+
note = json.loads(row["data"])
|
|
5928
|
+
if note["execution_id"] is None:
|
|
5929
|
+
messages[str(note["message_id"])] = note["reason"]
|
|
5930
|
+
else:
|
|
5931
|
+
executions[str(note["execution_id"])] = note["reason"]
|
|
5932
|
+
return {"messages": messages, "executions": executions}
|
|
5933
|
+
|
|
5934
|
+
|
|
5935
|
+
def start_experience_intent(connection, room_id, token, payload):
|
|
5936
|
+
"""The owner agreed to a host's intent: wake the host once in the background to finish it.
|
|
5937
|
+
|
|
5938
|
+
The notice names only the intent and the execution that raised it, so the owner's preference itself stays off the
|
|
5939
|
+
shared transcript; the host proposed it and reads the rest from its own session. It costs no round of a chain.
|
|
5940
|
+
"""
|
|
5941
|
+
require_owner(connection, room_id, token)
|
|
5942
|
+
intent_id, execution_id = payload.get("intent_id"), payload.get("execution_id")
|
|
5943
|
+
if not isinstance(intent_id, str) or not re.fullmatch(r"[0-9a-fA-F-]{8,64}", intent_id):
|
|
5944
|
+
raise ValueError(Text("意图编号无效。"))
|
|
5945
|
+
chain_id = None
|
|
5946
|
+
if isinstance(execution_id, int) and not isinstance(execution_id, bool):
|
|
5947
|
+
row = connection.execute("""SELECT r.chain_id, r.message_id FROM member_requests r JOIN member_executions e ON e.id=r.execution_id
|
|
5948
|
+
JOIN room_members m ON m.id=e.member_id WHERE e.id=? AND e.room_id=? AND m.role='host' ORDER BY r.id LIMIT 1""", (execution_id, room_id)).fetchone()
|
|
5949
|
+
chain_id = row and (row["chain_id"] or row["message_id"])
|
|
5950
|
+
if not chain_id:
|
|
5951
|
+
raise ValueError(Text("找不到提出这条意图的执行。"))
|
|
5952
|
+
text = Text("用户同意你在执行 #{execution_id} 中提出的意图(编号 {intent_id})。请在后台完成,不占用主线:起草较长时派一位成员用 --detach 去写,本次执行尽快结束,等它交回再提交。经验用 experience-propose 带 intent 字段提交成品;工作流先用 workflow-creator 写出草稿并保存为未启用,再提交 kind 为 workflow 的成品。做不成就在回答里说明原因。",
|
|
5953
|
+
execution_id=execution_id, intent_id=intent_id)
|
|
5954
|
+
attempt = payload.get("attempt", 1)
|
|
5955
|
+
if not isinstance(attempt, int) or isinstance(attempt, bool) or not 1 <= attempt <= 1000:
|
|
5956
|
+
raise ValueError(Text("意图编号无效。"))
|
|
5957
|
+
# One wake per attempt: the same request sent again (a lost response) does not wake the host twice.
|
|
5958
|
+
key = f"experience:{intent_id}:{attempt}"
|
|
5959
|
+
if connection.execute("SELECT 1 FROM free_host_wakes WHERE room_id=? AND key=?", (room_id, key)).fetchone():
|
|
5960
|
+
return {"ok": True, "duplicate": True}
|
|
5961
|
+
if not wake_host(connection, room_id, chain_id, text, key):
|
|
5962
|
+
raise ValueError(Text("主持人不在房间,无法交给它去做。"))
|
|
5963
|
+
return {"ok": True}
|
|
5964
|
+
|
|
5965
|
+
|
|
5966
|
+
def save_dispatch_reason(connection, room_id, token, payload):
|
|
5967
|
+
"""Attach an owner note to a stopped execution or dispatch in this room."""
|
|
5968
|
+
require_owner(connection, room_id, token)
|
|
5969
|
+
reason = payload.get("reason")
|
|
5970
|
+
if not isinstance(reason, str) or not reason.strip() or len(reason) > 300:
|
|
5971
|
+
raise ValueError(Text("介入原因须为 1 至 300 字。"))
|
|
5972
|
+
records = dispatch_reason_targets(connection, room_id, payload)
|
|
5973
|
+
if not records:
|
|
5974
|
+
raise ValueError(Text("找不到可补充原因的派活或已停止执行。"))
|
|
5975
|
+
for record in records:
|
|
5976
|
+
connection.execute("INSERT INTO room_events(room_id,at,kind,data) VALUES (?,?,'dispatch.user_reason',?)",
|
|
5977
|
+
(room_id, int(time.time() * 1000), json.dumps({"chain_id": record["chain_id"] or record["message_id"],
|
|
5978
|
+
"message_id": record["message_id"], "execution_id": payload.get("execution_id"), "reason": reason.strip()}, ensure_ascii=False)))
|
|
5979
|
+
return {"saved": True}
|
|
5980
|
+
|
|
5981
|
+
|
|
5982
|
+
def dispatch_reasons(connection, room_id, field, identifier):
|
|
5983
|
+
"""Return the latest reason per stopped execution or dispatch."""
|
|
5984
|
+
rows = connection.execute(f"""SELECT data FROM room_events WHERE room_id=? AND kind='dispatch.user_reason'
|
|
5985
|
+
AND json_extract(data,'$.{field}')=? ORDER BY id DESC""", (room_id, identifier))
|
|
5986
|
+
result = {}
|
|
5987
|
+
for row in rows:
|
|
5988
|
+
item = json.loads(row["data"])
|
|
5989
|
+
result.setdefault((item["message_id"], item["execution_id"]), item)
|
|
5990
|
+
return list(result.values())
|
|
5991
|
+
|
|
5992
|
+
|
|
5825
5993
|
def dispatch_record(connection, message):
|
|
5826
5994
|
"""Assemble a dispatch's source and the outcomes of the requests it created."""
|
|
5827
5995
|
message_id = message["id"]
|
|
@@ -5869,7 +6037,8 @@ def dispatch_record(connection, message):
|
|
|
5869
6037
|
"members": members, "withdrawn": bool(host_withdrawal or withdrawal),
|
|
5870
6038
|
"redirect_message_id": host_withdrawal["redirect_message_id"] if host_withdrawal else None,
|
|
5871
6039
|
"invalidation_reasons": [kind for kind in DISPATCH_INVALIDATIONS if kind in reasons],
|
|
5872
|
-
"feedback": dispatch_feedback(connection, message_id)
|
|
6040
|
+
"feedback": dispatch_feedback(connection, message_id),
|
|
6041
|
+
"intervention_reasons": dispatch_reasons(connection, message["room_id"], "message_id", message_id)}
|
|
5873
6042
|
|
|
5874
6043
|
|
|
5875
6044
|
def list_dispatches(connection, after, room_id=None):
|
|
@@ -6078,6 +6247,7 @@ def dispatch_chain_record(connection, source, events):
|
|
|
6078
6247
|
"dispatch_messages": len(dispatches), "dispatch_requests": sum(len(record["members"]) for record in dispatches),
|
|
6079
6248
|
"invalidated_dispatches": {kind: {"count": len(ids), "message_ids": ids} for kind, ids in invalidated.items()},
|
|
6080
6249
|
"user_interventions": chain_user_interventions(connection, requests, events, dispatches),
|
|
6250
|
+
"intervention_reasons": dispatch_reasons(connection, room_id, "chain_id", chain_id),
|
|
6081
6251
|
"unhandled_failure": ended and any(row["request_status"] == "failed" for row in requests),
|
|
6082
6252
|
"tokens": tokens, "host_versions": chain_host_versions(connection, execution_ids)}
|
|
6083
6253
|
|
|
@@ -6231,7 +6401,7 @@ def message_filters(room_id, params, search_anchors=None):
|
|
|
6231
6401
|
return " AND ".join(clauses), values
|
|
6232
6402
|
|
|
6233
6403
|
|
|
6234
|
-
def latest_messages(connection, room_id, params, where, values, size, bounded=False):
|
|
6404
|
+
def latest_messages(connection, room_id, params, where, values, size, bounded=False, owner=False):
|
|
6235
6405
|
"""Read the room's transcript from the newest end: the `size` messages before `before` (0: the latest), oldest first.
|
|
6236
6406
|
|
|
6237
6407
|
The page shows the latest messages first and reads the earlier ones after (#8131), so a long room opens without
|
|
@@ -6250,12 +6420,12 @@ def latest_messages(connection, room_id, params, where, values, size, bounded=Fa
|
|
|
6250
6420
|
has_earlier = len(rows) > size
|
|
6251
6421
|
shown = member_display_names(connection, room_id)
|
|
6252
6422
|
messages = [{**message, "author_label": message.get("author_label") or shown.get(message["author"], message["author"])}
|
|
6253
|
-
for message in (message_with_attachments(connection, row) for row in reversed(rows[:size]))]
|
|
6423
|
+
for message in (message_with_attachments(connection, row, owner) for row in reversed(rows[:size]))]
|
|
6254
6424
|
result = {"messages": messages, "has_earlier": has_earlier}
|
|
6255
6425
|
unfiltered = not any(params.get(name) for name in ("q", "author", "mention", "kind", "host", "submission_id"))
|
|
6256
6426
|
if params.get("cards") == "1" and not bounded and unfiltered and params.get("withdrawn") == INCLUDE_WITHDRAWN and messages:
|
|
6257
6427
|
low = rows[size]["id"] if has_earlier else 0
|
|
6258
|
-
result["cards"] = history_cards(connection, room_id, (low, messages[-1]["id"] if before else None))
|
|
6428
|
+
result["cards"] = history_cards(connection, room_id, (low, messages[-1]["id"] if before else None), owner)
|
|
6259
6429
|
return result
|
|
6260
6430
|
|
|
6261
6431
|
|
|
@@ -6288,16 +6458,17 @@ def query_messages(connection, room_id, params, token="", *, search_database=Non
|
|
|
6288
6458
|
where += " AND messages.id<=?"
|
|
6289
6459
|
values.append(cutoff)
|
|
6290
6460
|
if "before" in params:
|
|
6291
|
-
return latest_messages(connection, room_id, params, where, values, size, bounded=cutoff is not None)
|
|
6461
|
+
return latest_messages(connection, room_id, params, where, values, size, bounded=cutoff is not None, owner=experience_reader(connection, room_id, token))
|
|
6292
6462
|
total = connection.execute(f"""SELECT COUNT(*) FROM messages
|
|
6293
6463
|
LEFT JOIN message_details AS details ON details.message_id=messages.id
|
|
6294
6464
|
LEFT JOIN message_withdrawals AS withdrawn ON withdrawn.message_id=messages.id
|
|
6295
6465
|
WHERE {where}""", values).fetchone()[0]
|
|
6296
6466
|
rows = connection.execute(f"{MESSAGE_QUERY} WHERE {where} ORDER BY messages.id LIMIT ? OFFSET ?",
|
|
6297
6467
|
[room_id, *values, size + 1, (page - 1) * size]).fetchall()
|
|
6468
|
+
owner = experience_reader(connection, room_id, token)
|
|
6298
6469
|
shown = member_display_names(connection, room_id)
|
|
6299
6470
|
messages = [{**message, "author_label": message.get("author_label") or shown.get(message["author"], message["author"])}
|
|
6300
|
-
for message in (message_with_attachments(connection, row) for row in rows[:size])]
|
|
6471
|
+
for message in (message_with_attachments(connection, row, owner) for row in rows[:size])]
|
|
6301
6472
|
if params.get("fold_visuals") in ("1", "en"):
|
|
6302
6473
|
messages = [fold_message_visuals(message, params["fold_visuals"] == "en") for message in messages]
|
|
6303
6474
|
has_more = len(rows) > size
|
|
@@ -6332,7 +6503,7 @@ def query_messages(connection, room_id, params, token="", *, search_database=Non
|
|
|
6332
6503
|
# The unfiltered transcript also takes the cards of its batch, for history older than the room view's recent cards.
|
|
6333
6504
|
unfiltered = not use_search and not any(params.get(name) for name in ("q", "author", "mention", "kind", "host", "submission_id"))
|
|
6334
6505
|
if params.get("cards") == "1" and cutoff is None and unfiltered and params.get("withdrawn") == INCLUDE_WITHDRAWN:
|
|
6335
|
-
result["cards"] = history_cards(connection, room_id, (int(params["after"]), result["next_after"] if result["has_more"] else None))
|
|
6506
|
+
result["cards"] = history_cards(connection, room_id, (int(params["after"]), result["next_after"] if result["has_more"] else None), owner)
|
|
6336
6507
|
return result
|
|
6337
6508
|
|
|
6338
6509
|
|
|
@@ -6444,7 +6615,7 @@ def get_message(connection, room_id, message_id, params=None, token=""):
|
|
|
6444
6615
|
row = connection.execute(f"{MESSAGE_QUERY} WHERE {where} AND messages.id=?", [room_id, *values, message_id]).fetchone()
|
|
6445
6616
|
if row is None:
|
|
6446
6617
|
raise ReadError(Text('消息不存在'), code="not_available", requested_message_id=message_id)
|
|
6447
|
-
return message_with_attachments(connection, row)
|
|
6618
|
+
return message_with_attachments(connection, row, experience_reader(connection, room_id, token))
|
|
6448
6619
|
|
|
6449
6620
|
|
|
6450
6621
|
def trace_message(connection, room_id, params, token):
|
|
@@ -7191,6 +7362,8 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
7191
7362
|
return self.respond("User-agent: *\nAllow: /\n", content_type="text/plain")
|
|
7192
7363
|
with open_database() as connection:
|
|
7193
7364
|
connection.service_home = self.server.service_home
|
|
7365
|
+
connection.private_experience_read = not (self.read_only_request() or self.headers.get(ACTING_MEMBER_HEADER)
|
|
7366
|
+
or guest_path(parts) or is_external_path(parts))
|
|
7194
7367
|
with connection:
|
|
7195
7368
|
self.guard_private_window_access(connection, parts, method)
|
|
7196
7369
|
self.guard_group_window_request(connection, parts, method)
|
|
@@ -7750,7 +7923,7 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
7750
7923
|
if method != "POST":
|
|
7751
7924
|
raise LookupError(Text('本机入口不存在'))
|
|
7752
7925
|
return self.handle_local_media_command(route[0], site)
|
|
7753
|
-
if method == "OPTIONS" and route in (["settings"], ["object-storage-settings"], ["launch"], ["wipe-histories"], ["room-models"], ["room-skills"], ["room-files"], ["share-job"], ["room-page"], ["room-media"], ["execution-details"], ["room-member"], ["room-member-access"], ["room-member-adapter"], ["room-member-model"], ["room-profiles"], ["room-restore"], ["room-fork"], ["models"], ["sessions"], ["api-key"], ["api-check"],
|
|
7926
|
+
if method == "OPTIONS" and route in (["settings"], ["object-storage-settings"], ["launch"], ["wipe-histories"], ["room-models"], ["quota-refresh"], ["room-skills"], ["room-files"], ["share-job"], ["room-page"], ["room-media"], ["execution-details"], ["room-member"], ["room-member-access"], ["room-member-adapter"], ["room-member-model"], ["room-profiles"], ["room-restore"], ["room-fork"], ["models"], ["sessions"], ["api-key"], ["api-check"],
|
|
7754
7927
|
["scheduler-check"], ["image-check"], ["image-settings"], ["tts-settings"], ["tts"], ["tts-release"], ["local-speech"], ["stt"], ["weixin"], ["notify"], ["pick-directory"], ["browse-directory"], ["projects"], ["presets"], ["templates"], ["workflows"], ["room-workflow"], ["room-settings"], ["machine-link"], ["device-pairing"], ["devices"]) or (method == "OPTIONS" and len(route) == 1 and route[0] in INVITE_COMMANDS + INVITED_COMMANDS + SITE_COMMANDS + STEWARD_COMMANDS):
|
|
7755
7928
|
return self.respond({"ok": True})
|
|
7756
7929
|
if route in (["settings"], ["object-storage-settings"]) and method in ("GET", "POST"):
|
|
@@ -7764,8 +7937,8 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
7764
7937
|
command = "start"
|
|
7765
7938
|
elif route == ["room-config"] and method == "POST" and not self.bridge_origin:
|
|
7766
7939
|
command = "room-config"
|
|
7767
|
-
elif route
|
|
7768
|
-
command =
|
|
7940
|
+
elif route in (["room-models"], ["quota-refresh"]) and method == "POST":
|
|
7941
|
+
command = route[0]
|
|
7769
7942
|
elif route == ["models"] and method == "POST":
|
|
7770
7943
|
command = "models"
|
|
7771
7944
|
elif route == ["sessions"] and method == "POST":
|
|
@@ -7820,6 +7993,13 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
7820
7993
|
if self.headers.get_content_type() != "application/json":
|
|
7821
7994
|
raise ValueError(Text('本机操作须使用 application/json'))
|
|
7822
7995
|
payload = self.read_payload(MAX_FILE_PART_BODY_BYTES if command == "room-files" else MAX_BODY_BYTES)
|
|
7996
|
+
if command in ("start", "room-settings") and "model_specialist" in payload:
|
|
7997
|
+
if ("access_file" in payload or self.read_only_request() or self.headers.get(ACTING_MEMBER_HEADER)
|
|
7998
|
+
or self.headers.get(PROPOSAL_ACTING_MEMBER_HEADER)):
|
|
7999
|
+
raise PermissionError(Text('需要管理员登录'))
|
|
8000
|
+
if self.has_explicit_room_token:
|
|
8001
|
+
with closing(connect_db(self.server.database)) as connection:
|
|
8002
|
+
require_owner(connection, payload.get("room_id", ""), self.headers.get("X-Discussion-Token", ""))
|
|
7823
8003
|
payload.pop("_local_paths", None)
|
|
7824
8004
|
payload.pop("attachment_file_name", None)
|
|
7825
8005
|
if command == "room-files" and self.can_open_local_files():
|
|
@@ -7827,10 +8007,12 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
7827
8007
|
if command == "room-media" and payload.get("page") is True and not self.can_open_local_files():
|
|
7828
8008
|
raise PermissionError(Text('仅限在本机管理员本地网页中打开本地文件'))
|
|
7829
8009
|
payload.pop("_moss_owner", None)
|
|
7830
|
-
if command in ("start", "room-config", "room-models", "room-skills", "room-files", "open-file", "share-job", "room-page", "room-media", "execution-details", "room-member", "room-member-access", "room-member-adapter", "room-member-model", "room-profiles", "room-restore", "room-fork", "room-workflow", "room-settings", "workflows") + SITE_COMMANDS:
|
|
8010
|
+
if command in ("start", "room-config", "room-models", "quota-refresh", "room-skills", "room-files", "open-file", "share-job", "room-page", "room-media", "execution-details", "room-member", "room-member-access", "room-member-adapter", "room-member-model", "room-profiles", "room-restore", "room-fork", "room-workflow", "room-settings", "workflows") + SITE_COMMANDS:
|
|
7831
8011
|
payload.pop("access_file", None)
|
|
7832
8012
|
payload.update(site=site, entry="web")
|
|
7833
|
-
if command
|
|
8013
|
+
if command == "execution-details" and payload.get("wakeup_text") is True:
|
|
8014
|
+
self.authorize_wakeup_text(payload)
|
|
8015
|
+
if command in ("quota-refresh", "room-skills", "room-files", "open-file", "share-job", "room-page", "room-media", "execution-details", "room-workflow", "room-settings", "room-member", "room-member-access", "room-member-model", "room-member-adapter") + SITE_COMMANDS and payload.get("room_id") and not payload.get("token") and not self.bridge_origin:
|
|
7834
8016
|
with closing(connect_db(self.server.database)) as connection:
|
|
7835
8017
|
if (command in ("room-member-access", "room-member-model", "room-member-adapter", "room-settings")
|
|
7836
8018
|
and not self.headers.get("X-Discussion-Token") and not self.headers.get(ACTING_MEMBER_HEADER)
|
|
@@ -7871,6 +8053,30 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
7871
8053
|
# A connected website's page is another device's entry: it gets the same limits as the relay.
|
|
7872
8054
|
return self.run_local_command(command, payload, remote=bool(self.bridge_origin) and command != "machine-link")
|
|
7873
8055
|
|
|
8056
|
+
def authorize_wakeup_text(self, payload):
|
|
8057
|
+
"""Never lift an explicit member or cross-room identity to owner when reading wakeup text."""
|
|
8058
|
+
if self.read_only_request() or any(self.headers.get(header) is not None for header in
|
|
8059
|
+
(ACTING_MEMBER_HEADER, PROPOSAL_ACTING_MEMBER_HEADER)):
|
|
8060
|
+
raise PermissionError(Text('需要本房间的控制凭据'))
|
|
8061
|
+
room_id = payload.get("room_id")
|
|
8062
|
+
token = payload.get("token")
|
|
8063
|
+
header = self.headers.get("X-Discussion-Token", "")
|
|
8064
|
+
if not isinstance(room_id, str) or not room_id or (token is not None and not isinstance(token, str)):
|
|
8065
|
+
raise PermissionError(Text('需要本房间的控制凭据'))
|
|
8066
|
+
if token and header and token != header:
|
|
8067
|
+
raise PermissionError(Text('需要本房间的控制凭据'))
|
|
8068
|
+
token = token or header
|
|
8069
|
+
if self.bridge_origin:
|
|
8070
|
+
if not token:
|
|
8071
|
+
raise PermissionError(Text('需要本房间的控制凭据'))
|
|
8072
|
+
else:
|
|
8073
|
+
with closing(connect_db(self.server.database)) as connection:
|
|
8074
|
+
if not token:
|
|
8075
|
+
self.admin_as_owner(connection, room_id)
|
|
8076
|
+
token = self.headers.get("X-Discussion-Token", "")
|
|
8077
|
+
require_owner(connection, room_id, token)
|
|
8078
|
+
payload["token"] = token
|
|
8079
|
+
|
|
7874
8080
|
def handle_local_media_command(self, command, site):
|
|
7875
8081
|
"""Pin owner-scoped media and patch commands to the authenticated origin."""
|
|
7876
8082
|
if (self.read_only_request() or self.headers.get(ACTING_MEMBER_HEADER)
|
|
@@ -9046,7 +9252,7 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
9046
9252
|
return self.respond(execution_changes_batch(connection, room_id, params.get("ids", ""), token))
|
|
9047
9253
|
if len(parts) >= 6 and parts[3] == "executions" and parts[4].isdigit() and parts[5] == "proposal":
|
|
9048
9254
|
return self.handle_proposal_api(connection, parts, params, method)
|
|
9049
|
-
if parts[3:4] in (["inbox"], ["executions"], ["members"], ["chats"], ["suggestions"], ["recommendations"], ["stop"], ["dispatches"], ["host-checkin"], ["quotas"], ["room-link"], ["room-relay-sent"], ["host-actions"]):
|
|
9255
|
+
if parts[3:4] in (["inbox"], ["executions"], ["members"], ["chats"], ["suggestions"], ["recommendations"], ["stop"], ["dispatches"], ["experience-intents"], ["host-checkin"], ["quotas"], ["room-link"], ["room-relay-sent"], ["host-actions"]):
|
|
9050
9256
|
return self.handle_free_api(connection, parts, method)
|
|
9051
9257
|
if parts[3:4] == ["attachments"]:
|
|
9052
9258
|
return self.handle_attachments(connection, parts, params, method, local_attachment=local_attachment)
|
|
@@ -9136,6 +9342,9 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
9136
9342
|
if room["system_kind"] == moss_window_messages.GROUP_KIND:
|
|
9137
9343
|
room["group_enabled"] = group_window_enabled(self.server.service_home, room)
|
|
9138
9344
|
view = room_read_view(connection, room, token)
|
|
9345
|
+
if experience_reader(connection, room_id, token):
|
|
9346
|
+
attach_stopped_reasons(connection, room_id, (view.get("free") or {}).get("executions", []))
|
|
9347
|
+
view["intervention_notes"] = room_intervention_notes(connection, room_id)
|
|
9139
9348
|
if owner:
|
|
9140
9349
|
current = runner_room_fingerprint(connection, room_id)
|
|
9141
9350
|
view["room_revision"] = current if current == previous else None
|
|
@@ -10195,6 +10404,10 @@ class DiscussionHandler(BaseHTTPRequestHandler):
|
|
|
10195
10404
|
result = report_quota(connection, room_id, token, self.read_payload())
|
|
10196
10405
|
elif parts[3:] == ["stop"] and method == "POST":
|
|
10197
10406
|
result = stop_room(connection, room_id, token)
|
|
10407
|
+
elif parts[3:] == ["dispatches", "reason"] and method == "POST":
|
|
10408
|
+
result = save_dispatch_reason(connection, room_id, token, self.read_payload())
|
|
10409
|
+
elif parts[3:] == ["experience-intents"] and method == "POST":
|
|
10410
|
+
result = start_experience_intent(connection, room_id, token, self.read_payload())
|
|
10198
10411
|
elif len(parts) == 6 and parts[3] == "dispatches" and parts[4].isdigit() and parts[5] == "withdraw" and method == "POST":
|
|
10199
10412
|
result = withdraw_dispatch(connection, room_id, token, int(parts[4]), self.read_payload().get("execution_id"))
|
|
10200
10413
|
elif parts[3:] == ["host-checkin"] and method == "POST":
|
package/docs/en/guide/admin.md
CHANGED
|
@@ -19,7 +19,7 @@ Use the local management panel or the corresponding codiscuss admin commands to
|
|
|
19
19
|
- **Settings:** View the installed version, select **Check for updates** or **Update and restart** (which also updates room skills and isolated accounts). If the installed version has a problem, select **Other versions**, pick one of the latest 10 published versions (the previous one is preselected) and select **Install and restart** to go back. An older version may not understand data written by a newer one; if anything goes wrong after going back, update to the latest version again, enable **Start when signing in to Windows** and **Hosting** (see step 1 of “Set it up” below), and change the panel language. Under “Language · 语言”, pick “Display time zone” to update the panel’s times immediately. The panel and the room site keep separate preferences because they use different addresses.
|
|
20
20
|
- **Storage:**
|
|
21
21
|
- View local `.codiscuss` data usage against the 10 GiB limit (excluding speech models), total drafts against 3 GiB (1 GiB per room), **Room records & attachments (`local/`)**, disk free space and safety reserve, per-room and per-member breakdowns, and any unreadable entries. Local TTS and STT models are listed separately and excluded from the 10 GiB cap (covering both legacy and custom model paths, including when the service home itself is a symlink or junction).
|
|
22
|
-
- When `.codiscuss` data reaches the 8 GiB warning threshold, the **Storage** tab shows a warning dot and displays a notice; exceeding a limit or dropping below the disk safety reserve pauses new runs. The total is split into five named directories and Other. **Safe cleanup** removes registered failed scratch, speech cache entries, empty orphan directories, stale launches containing only setup records, and local execution files more than 24 hours after completion. After clearing the speech cache, replaying old content with cloud speech synthesizes it again and incurs a new charge. **Deep repair** estimates space
|
|
22
|
+
- When `.codiscuss` data reaches the 8 GiB warning threshold, the **Storage** tab shows a warning dot and displays a notice; exceeding a limit or dropping below the disk safety reserve pauses new runs. The total is split into five named directories and Other. **Safe cleanup** removes registered failed scratch, speech cache entries, empty orphan directories, stale launches containing only setup records, and local execution files more than 24 hours after completion. After clearing the speech cache, replaying old content with cloud speech synthesizes it again and incurs a new charge. **Deep repair** opens a dialog that estimates the space freed and lists what is kept; confirm there to delete finished logs, including the last day.
|
|
23
23
|
- **Room attachments** lists each room's sent, not-yet-cleared attachments, largest first. Select **Manage attachments** to expand the same attachment manager as on the room page (see “Storage and limits” in [Managing rooms](rooms.md)).
|
|
24
24
|
- **Attachment cache** holds the copies of cloud space attachments downloaded to this computer when members read them. It shows usage against its own limit (20 GiB by default), is counted separately from the 10 GiB data limit, and removes the least recently used copies when over its limit. Select **Clear** and confirm to delete these copies: only the copies on this computer are removed, and the originals in the cloud space are not affected; files in use are skipped, and members download them again when they next need them. On the command line, use `codiscuss admin storage cache [clear] [--account NAME]`. Omit `--account` to use the local administrator cache.
|
|
25
25
|
- Select “Ask the platform steward to analyze storage,” or run `codiscuss admin storage analyze`, to inventory this account’s member drafts, run logs, workflow backups, room attachments, and local speech models. View the result in the [platform steward](steward.md) conversation. The inventory does not scan the whole drive or delete anything. Approve specific items before cleanup.
|
|
@@ -27,9 +27,9 @@ Use the local management panel or the corresponding codiscuss admin commands to
|
|
|
27
27
|
During active runs, the service checks free space on its own volume every two seconds. While part of the 10 GiB budget remains, a drop in free space as large as that remainder triggers an early scan. When a run ends, the service updates that member’s draft usage. A manual retry after cleanup rechecks the limit that blocked the run. If a machine-wide limit was exceeded, the service measures machine-wide usage again. If another program writes to the volume, runs continue when measured usage is within limits and the unreadable count is stable. If an early scan finds more unreadable entries, dispatch pauses and the service requests stops for stoppable runs. Dispatch resumes when a later scan finds a stable count, usage within limits and enough free disk space. The low-disk reserve applies independently. At 80% of the room draft limit, new runs without confirmed stop support are paused. Writes can continue between and during scans, and ongoing unstoppable runs can keep writing. Project files, system temporary files and third-party AI data outside the service directory are excluded. Follow the cleanup instructions on the failed run’s card, then select “Retry” on that card from the computer or a paired device.
|
|
28
28
|
- **Account:**
|
|
29
29
|
- **Local account** is listed by default. When hosting is enabled, the page also lists **Hosted accounts** and a **New account** button.
|
|
30
|
-
- Select the administrator or a hosted account to manage its **CLI sign-ins** (Claude Code, Codex, and Gemini status, sign-in method, or sign-out; Setup Token is recommended for Claude Code), **API keys**, **Skills** (select from **Skill library** or import a ZIP/folder), **bundled workflows**, and **system prompt** (editable for hosted accounts: sent to every member CoDiscuss wakes for that account, ahead of what the account’s user writes in **Settings → System prompts**; the user cannot change it on the website or with commands (it is kept in the account’s own service folder, so this is not tamper-proof); CLAUDE.md and AGENTS.md are not written. Set the administrator’s own in **Settings** on the website). Updating the program leaves installed workflows unchanged; the workflows section works like the update check on the overview page. A tag next to the title shows **Up to date** or how many workflows can be synced;
|
|
30
|
+
- Select the administrator or a hosted account to manage its **CLI sign-ins** (Claude Code, Codex, and Gemini status, sign-in method, or sign-out; Setup Token is recommended for Claude Code), **API keys**, **Skills** (select from **Skill library** or import a ZIP/folder), **bundled workflows**, and **system prompt** (editable for hosted accounts: sent to every member CoDiscuss wakes for that account, ahead of what the account’s user writes in **Settings → System prompts**; the user cannot change it on the website or with commands (it is kept in the account’s own service folder, so this is not tamper-proof); CLAUDE.md and AGENTS.md are not written. Set the administrator’s own in **Settings** on the website). Updating the program leaves installed workflows unchanged; the workflows section works like the update check on the overview page. A tag next to the title shows **Up to date** or how many workflows can be synced; workflows that differ from the bundled version are tagged **Update available**, and missing bundled workflows are listed last as **Not installed**. The refresh button in the top-right corner checks again, and **Sync to latest** is enabled once something differs. After you confirm, it installs the missing ones and replaces those that differ (each replaced copy is first backed up to `backups/workflows` in that account's service folder, and changes made there are replaced too).
|
|
31
31
|
|
|
32
|
-
In **Account → Skills**, select “Admin” or an isolated hosted account. Under **Officially bundled skills**, search by name or description for a skill such as `forum-browsing`. To remove a skill, open **Installed**. The
|
|
32
|
+
In **Account → Skills**, select “Admin” or an isolated hosted account. Under **Officially bundled skills**, search by name or description for a skill such as `forum-browsing`. To remove a skill, open **Installed**. **Installed** starts expanded, listing each skill and its source, when it holds 12 skills or fewer; a longer list starts folded with a count per source, and clicking its header row expands or folds it. After an upgrade ships newer bundled skills, the **Installed** header row shows “N updatable”; click **Update all**, or expand the list and click **Update** per skill. With nothing to update it shows “Bundled skills up to date”. Built-in CoDiscuss skills are synced with each CoDiscuss update; library and manually installed skills are not version-checked. A bundled skill you edited is tagged “Edited locally” and is not offered as an update unless a newer bundled version exists; updating or removing it asks for confirmation first, and the backup path is shown after the change. The nine built-in skills (including `prompt-design`, `model-generation`, `video-generation`, and `screen-acceptance`) and the administrator's manually installed skills cannot be removed here. Officially bundled skills and administrator imports in the **Skill library** are separate sources. Updating or replacing a copy with different contents, or removing a modified managed skill, first backs up the previous copy to `backups/skills/` in that account's service directory.
|
|
33
33
|
|
|
34
34
|
Select a group to pick its currently visible installable or updatable skills, then adjust individual checkboxes. A mixed checkbox indicates a partial selection. With one visible skill checked, click “Install selected skills (1)”. Hidden skills are excluded from the request. Use `codiscuss admin skill install owner --group research` to install the group from the CLI.
|
|
35
35
|
|
|
@@ -44,6 +44,15 @@ In "Reports", click "Share image" at the top right to preview the image, then ch
|
|
|
44
44
|
|
|
45
45
|
The image shows total AI work time, wall-clock active time, peak concurrency and its chart, tasks started, rooms worked on at once, and the share that needed no follow-up. It also counts dispatched runs, participating expert seats (each member once per room), and files delivered and sites published (posted AI attachments, files logged as delivered by runs, and sites still live). These three counts cover existing rooms, including archived rooms, but exclude deleted rooms. The image contains no member names, room titles, folder names, or message text.
|
|
46
46
|
|
|
47
|
+
## Export data
|
|
48
|
+
|
|
49
|
+
In "Reports", click "Export data" next to the share image button and choose "CSV tables (ZIP)" or "JSON". The download uses the snapshot, time range, and room scope currently shown, including the previous-period comparisons already in the report. "Any time" has no previous period. The button is disabled if there is nothing to export. Both the local page and paired devices generate the files in the browser without uploading the data.
|
|
50
|
+
|
|
51
|
+
- **CSV tables (ZIP)**: Extract the archive and open each table with Excel or pandas. Each CSV is UTF-8 with a BOM. The archive includes the range, summary, timeline, daily figures, and group tables with data. A blank previous-period value in the summary means no comparison value is available, not zero.
|
|
52
|
+
- **JSON**: Contains the main report, export time, range, and units, including nested details such as issue samples. Timestamps use ISO 8601 UTC, calendar dates use the report time zone, and durations remain numeric with documented units. Separately loaded sections such as host dispatch details, MOSS and subscription usage are not part of the main report.
|
|
53
|
+
|
|
54
|
+
Exports may contain room, folder and member names, as well as message excerpts. Use the share image for a public summary.
|
|
55
|
+
|
|
47
56
|
## Things to note
|
|
48
57
|
|
|
49
58
|
- **Deleted rooms**: when a room is deleted or auto-destroyed, its statistics are first saved as anonymous totals with no title or text, and they can no longer link back to the room. These totals are included by default; click "Existing rooms only" at the bottom of the page to leave them out. Active time, folder distribution, the member scorecard, peak concurrency and "Worth a look" cover existing rooms only. Rooms deleted before this feature shipped cannot be recovered.
|
package/docs/en/guide/cli.md
CHANGED
|
@@ -58,6 +58,7 @@ External members can use `codiscuss repo ls` to find a shared folder, then run `
|
|
|
58
58
|
| Set custom host strategy text or clear back to Balanced (owner only) | `codiscuss room host-strategy <room-ID> --text "strategy text"` / `--body-file FILE` / `--clear` |
|
|
59
59
|
| View bundled defaults / effective local host model rules | `codiscuss launch prompts list --builtin` / `codiscuss launch prompts rule-list` |
|
|
60
60
|
| Enable, disable, edit or reset one host model rule | `codiscuss launch prompts rule-enable ID` / `rule-disable ID` / `rule-set ID --file FILE` / `rule-reset ID` |
|
|
61
|
+
| Add a model rule or delete a custom rule | `codiscuss launch prompts rule-add MODEL [--file FILE]` / `rule-delete ID` (use `rule-list` to find the rule ID) |
|
|
61
62
|
| List, save, or delete personal strategies on this computer | `codiscuss launch strategies list` / `set <name> --file FILE` / `delete <name>` |
|
|
62
63
|
| List platforms available to invite and their latest local subscription quota readings (requires “Manage the member list”). Each window shows the applicable model group and reset time. Once a known reset time is reached, the window shows `reset_passed` and omits the remaining fraction until a new reading is available. Other windows show the fraction remaining when observed. Missing subscription data appears as `unknown`. | `codiscuss launch host-control invite --list` |
|
|
63
64
|
| Move an execution to the background and continue without waiting (requires execution controls). | `codiscuss launch host-control detach --execution RUN_ID` or `codiscuss launch host-control detach --member NAME` |
|
package/docs/en/guide/faq.md
CHANGED
|
@@ -74,7 +74,7 @@ To see what changed in this version, click the version number after "AI CoDiscus
|
|
|
74
74
|
| Appearance → Language · 语言 | 简体中文, English | Choose the display language. Changes take effect immediately. |
|
|
75
75
|
| Appearance → Visual effects | Full, Compact | Compact turns off background blur and layered shadows for smoother scrolling on slower devices. |
|
|
76
76
|
| Appearance → Archive button in room list | Menu only, Show on hover | Menu only is the default: hovering a room on desktop shows just “…”, and you archive from that menu. Show on hover adds the archive button next to it. Applies to this device only. |
|
|
77
|
-
| Reading → Conversation width | Narrow, Default, Wide |
|
|
77
|
+
| Reading → Conversation width | Narrow, Default, Wide | Changes the column width in Messages and Private chat immediately. On narrow screens the column uses the available width. |
|
|
78
78
|
| Reading → Card text size | Small, Medium, Large | Text size inside message cards. Medium is the default; the choice applies to this device only. |
|
|
79
79
|
| Reading → Fold answers longer than | 0.5 screens, 0.7 screens, 1.2 screens | Answers longer than the chosen number of screen heights fold. 1.2 screens is the default; the choice applies to this device only. |
|
|
80
80
|
| Reading → Lines shown when folded | Fewer, Medium, More | A folded answer keeps about 0.35, 0.6 or 0.9 of the screen, converted to lines from the screen height, so phones, tablets and computers each differ. Medium is the default; the choice applies to this device only. |
|
|
@@ -29,7 +29,7 @@ npm install --global ai_co_discuss@latest
|
|
|
29
29
|
codiscuss setup
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
Confirm the detected tools and install the
|
|
32
|
+
Confirm the detected tools and install the built-in skills, including `model-generation` for 3D models and `video-generation` for videos. Under **Install settings**, interactive setup also lets you select optional bundled skills (such as `forum-browsing`), bundled workflows, and on Windows **Create CoDiscuss shortcut** (for non-interactive runs, pass `--optional-skills` or `--workflows`). By default, setup opens `http://127.0.0.1:8765`. If only the terminal output appears, open the local address it prints. If setup reports **Configuration needs attention**, follow the instructions for the affected item and rerun `codiscuss setup`.
|
|
33
33
|
|
|
34
34
|
Later, use `codiscuss local open` to open the site, `codiscuss local status` to check it, and `codiscuss local stop` to stop the site and its managed services.
|
|
35
35
|
|