agent2agent-cli 0.3.7 → 0.3.8

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.
Files changed (2) hide show
  1. package/a2a.js +42 -30
  2. package/package.json +1 -1
package/a2a.js CHANGED
@@ -1032,65 +1032,77 @@ async function cmdCheckin(opts, ctx) {
1032
1032
  await api(config, 'POST', '/heartbeat', { body: { status: opts.status } });
1033
1033
  }
1034
1034
 
1035
- // 4) 输出摘要
1035
+ // 4) 输出摘要(固定工作流引导:待你回复 → 你发出的等待 → 任务建议 → 记忆)
1036
1036
  const mem = res.memory || {};
1037
1037
  const pending = res.pending || {};
1038
1038
  const inboxItems = (res.inbox && res.inbox.items) || [];
1039
- const taskItems = (res.tasks && res.tasks.items) || [];
1040
1039
  const acct = res.account || {};
1041
1040
 
1041
+ // 我的任务(全量,判滞留与来源关联)
1042
+ const myTasks = toArray(await api(config, 'GET', '/tasks', { query: { account: ctx.config.accountId } }))
1043
+ .filter((t) => t.status !== 'done');
1044
+ // 我发出的、等待对方回复的消息(发送方视角:对方还没回应 → 该跟进/该建任务)
1045
+ const outAll = toArray(await api(config, 'GET', '/messages', { query: { dir: 'out', limit: 100 } }));
1046
+ const outWaiting = outAll.filter((m) => m.needsReply && m.status !== 'resolved');
1047
+
1042
1048
  console.log('');
1043
1049
  console.log(hl('========== a2a checkin =========='));
1044
- console.log(`账号: ${acct.name || acct.id || ctx.config.accountId} 状态: ${acct.status || 'starting'}`);
1045
- console.log(`记忆版本: v${mem.version ?? 0}`);
1046
- // 记忆维护提示:空记忆 / 版本过低时提醒 agent 写回(记忆由 agent 自己维护)
1050
+ console.log(`账号: ${acct.name || acct.id || ctx.config.accountId} 状态: ${acct.status || 'starting'} 平台 v${res.platformVersion || '?'}`);
1047
1051
  const memEmpty = !mem.content || !String(mem.content || '').trim();
1048
- if (memEmpty) {
1049
- console.log(paint(C.yellow, ' ⚠ 记忆为空:本账号尚无 memory.md。请在会话中/结束时把「进展、决策、待办、协作关系」整理成记忆文件,用 a2a memory set <file> 写回(跨会话保持上下文的关键)。'));
1050
- } else if ((mem.version || 0) < 2) {
1051
- console.log(paint(C.dim, ' (提示:建议每次会话结束前用 a2a memory set 更新记忆,保持 v' + (mem.version || 0) + ' → 演进)'));
1052
- }
1053
- // 待我回复的消息(发给我的、needsReply、未 resolved)—— 别人等待我回复
1052
+ // 待我回复(别人等我) / 我发出的等待(我等别人) 双视角计数
1054
1053
  const needMyReply = inboxItems.filter((m) => m.needsReply && m.status !== 'resolved');
1055
- const unreadNow = (pending.unreadMessages ?? 0);
1056
- console.log(`未读消息: ${unreadNow} 条 待你回复: ${needMyReply.length} 待办任务: ${pending.todoTasks ?? taskItems.length} 个`);
1054
+ console.log(`待你回复: ${needMyReply.length} 条 你发出等对方回复: ${outWaiting.length} 条 进行中任务: ${myTasks.length} 个`);
1055
+ console.log(`收件箱新消息 ${inboxItems.length} 条(拉取即自动已读,读后不算未读) 记忆版本: v${mem.version ?? 0}`);
1057
1056
 
1058
1057
  console.log('');
1059
- console.log(paint(C.bold, '收件箱消息:'));
1060
- if (inboxItems.length === 0) {
1061
- console.log(' (无新消息)');
1058
+ console.log(paint(C.bold, '① 待你回复(别人等待你——最高优先,回复后原消息自动 resolved,无需再手动 mark):'));
1059
+ if (needMyReply.length === 0) {
1060
+ console.log(' (无)');
1062
1061
  } else {
1063
- inboxItems.forEach((m, i) => {
1064
- const needReply = m.needsReply && m.status !== 'resolved' ? ' ' + paint(C.yellow, '[需你回复]') : '';
1065
- console.log(` [${i + 1}] ${m.subject || '(无主题)'} — 来自 ${m.from || '?'}${needReply}`);
1062
+ needMyReply.forEach((m, i) => {
1063
+ const age = m.createdAt ? Math.floor((Date.now() - m.createdAt) / 3600000) : 0;
1064
+ console.log(` [${i + 1}] ${m.subject || '(无主题)'} — 来自 ${m.from || '?'}(${age}h 前)`);
1065
+ console.log(` → a2a reply --msg ${m.id} --body "..."`);
1066
1066
  });
1067
1067
  }
1068
1068
 
1069
1069
  console.log('');
1070
- console.log(paint(C.bold, '我的任务(todo / doing / blocked):'));
1071
- const myTasks = toArray(await api(config, 'GET', '/tasks', { query: { account: ctx.config.accountId } }))
1072
- .filter((t) => t.status !== 'done');
1073
- if (myTasks.length === 0) {
1070
+ console.log(paint(C.bold, ' 你发出、等待对方回复(若对方长期未回应可跟进):'));
1071
+ if (outWaiting.length === 0) {
1074
1072
  console.log(' (无)');
1073
+ } else {
1074
+ const taskSrcIds = new Set(myTasks.map((t) => t.sourceMessageId).filter(Boolean));
1075
+ outWaiting.forEach((m, i) => {
1076
+ const age = m.createdAt ? Math.floor((Date.now() - m.createdAt) / 3600000) : 0;
1077
+ const linked = taskSrcIds.has(m.id);
1078
+ console.log(` [${i + 1}] ${m.subject || '(无主题)'} → ${m.to || '?'}(${age}h 前)${linked ? '(已建任务)' : paint(C.yellow, '(未关联任务)')}`);
1079
+ const hint = linked
1080
+ ? '→ 对方回应后自动结束;如需催办 a2a send 跟进'
1081
+ : '→ 若是一项需跟踪的工作,请建任务:a2a task new --title "..." --source-msg ' + m.id;
1082
+ console.log(' ' + hint);
1083
+ });
1084
+ }
1085
+
1086
+ console.log('');
1087
+ console.log(paint(C.bold, '③ 我的任务(todo / doing / blocked):'));
1088
+ if (myTasks.length === 0) {
1089
+ console.log(' (无——收到需求类消息时请用 ②/① 中的命令建任务,任务是你自己的工作表)');
1075
1090
  } else {
1076
1091
  myTasks.forEach((t, i) => {
1077
1092
  const stayH = t.updatedAt ? Math.floor((Date.now() - t.updatedAt) / 3600000) : 0;
1078
1093
  const stay = stayH > 24
1079
- ? ' ' + paint(C.yellow, `(滞留 ${Math.floor(stayH / 24)}d${stayH % 24}h:若等待他人/人类介入请 a2a task update blocked 并说明原因)`)
1094
+ ? ' ' + paint(C.yellow, `(滞留 ${Math.floor(stayH / 24)}d${stayH % 24}h:若等待他人/人类介入请 a2a task update --id ${t.id} --status blocked --note 原因)`)
1080
1095
  : (stayH > 4 ? `(已 ${stayH}h)` : '');
1081
1096
  console.log(` [${i + 1}] ${t.title || '(无标题)'}(${t.status || '?'})${t.assigneeId ? '→ ' + t.assigneeId : ''}${stay}`);
1097
+ console.log(` → 推进: a2a task update --id ${t.id} --status done|doing|blocked --note 说明`);
1082
1098
  });
1083
1099
  }
1084
1100
 
1085
1101
  console.log('');
1086
- if (needMyReply.length > 0) {
1087
- console.log(paint(C.yellow, `→ ${needMyReply.length} 条消息等待你回复:用 a2a inbox 查看后 a2a reply --msg ID --body "...",处理完 a2a mark --msg ID --status resolved`));
1088
- }
1089
- if ((pending.todoTasks ?? 0) > 0 || myTasks.length > 0) {
1090
- console.log(paint(C.yellow, '→ 推进任务:a2a task list 查看 → 完成 a2a task update --id ID --status done --note 说明'));
1102
+ if (memEmpty) {
1103
+ console.log(paint(C.yellow, '→ 会话结束前固定动作:把「进展、决策、待办、协作关系」写回记忆 a2a memory set <file>'));
1091
1104
  }
1092
1105
  console.log(hl('======================================='));
1093
-
1094
1106
  // 更新检查(≤24h 一次;网络不可达静默跳过;有更新才提示)
1095
1107
  const lastCheck = state.lastUpdateCheckAt || 0;
1096
1108
  if (Date.now() - lastCheck > 24 * 3600 * 1000) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent2agent-cli",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Agent2Agent 统一 CLI(命令名 a2a):跨 AI 编程代理协作平台的命令行客户端 — 异步消息、任务看板、文档双向同步、持久记忆",
5
5
  "bin": {
6
6
  "a2a": "a2a.js"