ai_co_discuss 0.2.87 → 0.2.88

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.
@@ -19,7 +19,8 @@ How collaboration works inside a room. For installation, see [Setup](runner.md).
19
19
 
20
20
  - **Mention** — `@member` and it works in its own original session; several members can run in parallel.
21
21
  - **Unaddressed messages** go to the host. With a single member, they go straight to it.
22
- - **Host delegation** — when the host mentions one member, that member replies to you directly; when it mentions several, the host summarizes after they finish.
22
+ - **Expert presets** — the add row lists presets after the platforms; one click adds a member with its description, prompt, project access (and optionally model and effort) set. `Codex-评审` (read-only reviewer) and `Gemini-文档` (writes docs only, via agy) are built in; the bookmark on a card's back saves it as your own preset on the computer running the local service.
23
+ - **Host delegation** — after the members the host mentioned finish, the host is woken once more to summarize or hand the work on (for example to a reviewer). One message of yours allows up to 8 dispatches and hand-backs by default; change it (1–50) under 协作设置 (Collaboration settings) on the room page.
23
24
  - **Everyone** — `@全体成员` asks all members to answer; `@全体依次` asks them one after another in speaking order.
24
25
  - **Stop and retry** — stop a member's current run from its menu; failed runs can be resent with one click.
25
26
 
package/docs/runner.md CHANGED
@@ -65,7 +65,7 @@ API 成员可以担任专家或主持人,只有房间读写工具,不访问
65
65
 
66
66
  建房时在“智能调度”下选择供应商并填写密钥,需要连接本机服务。作用见 [使用指南](workflow.md#智能调度)。
67
67
 
68
- 翻开成员卡片,“提示”一行可以给这位专家单独写几句要求,例如“回答先给结论”。它只发给这位专家,不改变权限;部分软件带有预设,可随时恢复。
68
+ 翻开成员卡片,“提示”一行可以给这位专家单独写几句要求,例如“回答先给结论”。它只发给这位专家,不改变权限;部分软件带有预设,可随时恢复。卡片背面的书签图标把这张卡片的描述、提示词、项目权限、模型与强度存为专家预设,之后在“添加”行一键加入,见 [使用指南](workflow.md#成员管理)。
69
69
 
70
70
  ## 权限
71
71
 
package/docs/workflow.md CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  - **点名**:`@成员` 后,它在自己的原会话中处理并回复,多位可并行。
19
19
  - **未点名的消息**:交给主持人分派;只有一位成员时直接交给它。
20
- - **主持人派活**:主持人点名一位成员时,该成员直接回复你;点名多位时,都完成后主持人再汇总。
20
+ - **主持人派活**:主持人点名的成员都完成后,主持人再被唤醒一次,汇总或安排下一步(如请评审)。你的一条消息引出的派活与回交默认最多 8 次,可在房间页的“协作设置”里调整(1–50)。
21
21
  - **全体回答**:`@全体成员` 请所有成员各自回答,`@全体依次` 按发言顺序逐个回答。
22
22
  - **停止与重发**:成员菜单可停止当前执行;失败的执行可一键重发。
23
23
 
@@ -57,13 +57,14 @@
57
57
 
58
58
  决策模型只在把握足够时执行,否则交回主持人。每次判断都会显示在对话中,可以评价。开启后,房间标题与最近消息会发送给所选供应商。
59
59
 
60
- 给成员写一段描述能让分派更准,例如“Claude:审美好,UI 写得好”“Codex:代码写得好,能生成图片”。建房或邀请时点成员卡片右上角的描述按钮填写,可存为该软件的默认描述;房间里可在右栏成员菜单“编辑描述”随时修改。决策模型和 AI 主持人都会参考它,房间里所有成员也都能看到。
60
+ 给成员写一段描述能让分派更准,例如“Claude:审美好,UI 写得好”“Codex:代码写得好,能生成图片”。建房或邀请时点成员卡片右上角的描述按钮填写,可存为该软件的默认描述(连接本机服务时存在这台电脑上,所有浏览器共用);房间里可在右栏成员菜单“编辑描述”随时修改。决策模型和 AI 主持人都会参考它,房间里所有成员也都能看到。
61
61
 
62
62
  ## 成员管理
63
63
 
64
64
  在右侧成员栏可以:
65
65
 
66
66
  - **邀请**成员。Codex 与 Claude 可以填写已有会话 ID,带着原会话的上下文加入;讨论中新邀请的专家排在本轮队尾。
67
+ - **专家预设**:建房与邀请的“添加”行在各平台之后列出预设,点一下就加入一位已设好描述、专属提示词、项目权限(以及可选的模型与强度)的成员。内置 `Codex-评审`(只读,只提问题不改代码)与 `Gemini-文档`(经 agy,可写,只改文档);翻开任意卡片点背面的书签图标可把它存为你自己的预设,同名时替换内置预设。预设存在本机服务所在的电脑上,需要连接本机服务。
67
68
  - **暂离、请回或移除**成员,讨论不会因此暂停。
68
69
  - **更换主持人**:点成员卡片上的皇冠。讨论中更换会暂停讨论。
69
70
  - **调整发言顺序**:拖动右栏“发言顺序”中待发言的成员。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.2.87",
3
+ "version": "0.2.88",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
@@ -203,7 +203,7 @@ async function run_participant(profile, key, context) {
203
203
  const results = [];
204
204
  for (const call of calls) {
205
205
  context.signal.throwIfAborted();
206
- context.on_activity?.('tool');
206
+ context.on_activity?.('tool', String(call.name || ''));
207
207
  const outcome = await execute_tool(context, call, definitions);
208
208
  if (outcome.terminal) return;
209
209
  results.push({ ...call, result: outcome.result });
@@ -297,6 +297,97 @@ export function activity_phase(adapter, event) {
297
297
  return step.tool_name === 'run_command' ? 'command' : EDIT_TOOLS.test(step.tool_name || '') ? 'editing' : 'tool';
298
298
  }
299
299
 
300
+ /** The tool an event starts, by name only: never its arguments or command text. Returns '' for any other event. */
301
+ export function activity_tool(adapter, event) {
302
+ if (adapter === 'claude') {
303
+ const block = event.type === 'assistant' ? event.message?.content?.at(-1) : null;
304
+ return block?.type === 'tool_use' ? String(block.name || '') : '';
305
+ }
306
+ if (adapter === 'codex_cli') {
307
+ if (event.type !== 'item.started') return '';
308
+ return event.item?.type === 'mcp_tool_call' ? String(event.item.tool || '') : event.item?.type === 'web_search' ? 'web_search' : '';
309
+ }
310
+ const step = event.step_update;
311
+ return step?.step_type === 'tool' && !['DONE', 'ERROR'].includes(step.state) ? String(step.tool_name || '') : '';
312
+ }
313
+
314
+ /** Segments one execution may record, how many one report carries, and a tool name's length; the website enforces the same. */
315
+ export const MAX_EXECUTION_SEGMENTS = 400;
316
+ export const MAX_SEGMENTS_PER_REPORT = 40;
317
+ export const MAX_SEGMENT_TOOL = 60;
318
+
319
+ /**
320
+ * The phases each execution's software went through, as millisecond offsets from its delivery on this machine's clock.
321
+ * Consecutive events of the same phase and tool extend one segment. The open segment is reported as far as it has run
322
+ * and again later with a later end; numbering makes a resent report harmless.
323
+ */
324
+ export class SegmentLog {
325
+ constructor(now = Date.now) {
326
+ this.now = now;
327
+ this.executions = new Map();
328
+ }
329
+ /** Begin timing one execution at its delivery; a repeated start keeps the first origin. */
330
+ start(id) {
331
+ if (!this.executions.has(id)) this.executions.set(id, { origin: this.now(), last: 0, open: null, closed: [], next_seq: 0, reported: 0 });
332
+ }
333
+ /** The software produced output now; a phase, when the output names one, starts a new segment unless it continues the open one. */
334
+ mark(id, phase = '', tool = '') {
335
+ const log = this.executions.get(id);
336
+ if (!log) return;
337
+ log.last = this.now() - log.origin;
338
+ if (log.open) log.open.end_ms = log.last;
339
+ if (!phase) return;
340
+ tool = tool.slice(0, MAX_SEGMENT_TOOL).replace(/[\uD800-\uDBFF]$/, '');
341
+ if (log.open?.phase === phase && log.open.tool === tool) return;
342
+ if (log.open) log.closed.push(log.open);
343
+ log.open = null;
344
+ if (log.next_seq >= MAX_EXECUTION_SEGMENTS) return;
345
+ log.next_seq += 1;
346
+ log.open = { seq: log.next_seq, phase, tool, start_ms: log.last, end_ms: log.last };
347
+ }
348
+ /** Whether unreported segments are waiting and the last report is at least `interval_ms` old. */
349
+ due(id, interval_ms) {
350
+ const log = this.executions.get(id);
351
+ return Boolean(log && (log.closed.length || log.open) && this.now() - log.reported >= interval_ms);
352
+ }
353
+ /** The next report: closed segments first, then the open one as it stands. `final` closes the open segment first. */
354
+ batch(id, final = false) {
355
+ const log = this.executions.get(id);
356
+ if (!log) return [];
357
+ if (final && log.open) { log.closed.push(log.open); log.open = null; }
358
+ const batch = log.closed.slice(0, MAX_SEGMENTS_PER_REPORT);
359
+ if (log.open && batch.length < MAX_SEGMENTS_PER_REPORT) batch.push({ ...log.open });
360
+ return batch;
361
+ }
362
+ /** Forget the closed segments a successful report carried in full; a segment that ran on since it was sent stays. */
363
+ sent(id, batch) {
364
+ const log = this.executions.get(id);
365
+ if (!log) return;
366
+ const ends = new Map(batch.map(segment => [segment.seq, segment.end_ms]));
367
+ log.closed = log.closed.filter(segment => !(ends.has(segment.seq) && segment.end_ms <= ends.get(segment.seq)));
368
+ log.reported = this.now();
369
+ }
370
+ /**
371
+ * Send the execution's segments with `send(segments)`. `final` closes the open one, sends everything left and forgets
372
+ * the execution. A refused report drops them and any other failure keeps them for the next try; it never throws,
373
+ * so a timeline report cannot fail the execution it describes.
374
+ */
375
+ async report(id, final, send) {
376
+ do {
377
+ const batch = this.batch(id, final);
378
+ if (!batch.length) break;
379
+ try { await send(batch); }
380
+ catch (error) {
381
+ if (/HTTP 4\d\d/.test(error.message)) this.drop(id);
382
+ return;
383
+ }
384
+ this.sent(id, batch);
385
+ } while (final && this.executions.get(id)?.closed.length);
386
+ if (final) this.drop(id);
387
+ }
388
+ drop(id) { this.executions.delete(id); }
389
+ }
390
+
300
391
  /**
301
392
  * Text the agent wrote to the user in one streamed event, such as a progress remark between tool calls.
302
393
  * agy streams a response in deltas, so its text is collected per step in `responses` and returned when the step ends.
@@ -323,7 +414,7 @@ function watch_activity(adapter, stream, task) {
323
414
  let event;
324
415
  try { event = JSON.parse(line); } catch { return; }
325
416
  const phase = activity_phase(adapter, event);
326
- if (phase) task.on_activity?.(phase);
417
+ if (phase) task.on_activity?.(phase, activity_tool(adapter, event));
327
418
  const note = progress_note(adapter, event);
328
419
  if (note) task.on_note?.(note);
329
420
  });
@@ -533,7 +624,7 @@ function monitor_cli(child, config, binding, task) {
533
624
  catch { state.diagnostic = 'CLI 输出中存在无效 JSON,详情见本机日志'; return; }
534
625
  trace_cli_event(event, task);
535
626
  const phase = activity_phase(config.adapter, event);
536
- if (phase) task.on_activity?.(phase);
627
+ if (phase) task.on_activity?.(phase, activity_tool(config.adapter, event));
537
628
  const note = progress_note(config.adapter, event, state.responses);
538
629
  if (note) task.on_note?.(note);
539
630
  try { cli_event(config.adapter, state, event, task); }