dsh-multigameassistant 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,19 @@
1
1
  import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
2
2
  import {
3
+ convertLiveFrame,
3
4
  convertRecord
4
- } from "./chunk-QSETYM2Y.js";
5
+ } from "./chunk-OCJFAT7J.js";
5
6
  import {
6
7
  writeFileAtomic
7
8
  } from "./chunk-RESS7WVY.js";
8
9
  import {
9
10
  BY_YOU,
10
11
  DECISION_AREAS,
12
+ FORMER_AGENT_NAMES,
13
+ MAIN_AGENT_NAME,
11
14
  NOTIFY_CAPABILITY,
12
15
  briefText,
16
+ isAgentNamed,
13
17
  isQuiet,
14
18
  parseRelay,
15
19
  parseTask,
@@ -22,7 +26,7 @@ import {
22
26
  threadMessage,
23
27
  threadReminder,
24
28
  threadsBetween
25
- } from "./chunk-34VNH3YS.js";
29
+ } from "./chunk-BB2T4JHF.js";
26
30
  import {
27
31
  external_exports
28
32
  } from "./chunk-6DSSLS7I.js";
@@ -95,6 +99,20 @@ import { randomUUID as randomUUID2 } from "node:crypto";
95
99
  function textReply(text) {
96
100
  return { blocks: [{ kind: "text", text }] };
97
101
  }
102
+ function saidKey(seq, text) {
103
+ return `${seq}:${text}`;
104
+ }
105
+ function finalKey(reply) {
106
+ for (let i = reply.blocks.length - 1; i >= 0; i--) {
107
+ const block = reply.blocks[i];
108
+ if (block.kind === "text" && block.text.trim() !== "")
109
+ return block.seq === void 0 ? void 0 : saidKey(block.seq, block.text);
110
+ }
111
+ return void 0;
112
+ }
113
+ function replyRest(reply) {
114
+ return [reply.note, reply.ended].filter((p) => p !== void 0 && p !== "").join("\n\n");
115
+ }
98
116
  function finalText(reply) {
99
117
  for (let i = reply.blocks.length - 1; i >= 0; i--) {
100
118
  const block = reply.blocks[i];
@@ -502,7 +520,8 @@ function sessionConversations(sessions, _cwd = () => void 0, focus, app) {
502
520
  signal.throwIfAborted();
503
521
  options.onAccepted?.();
504
522
  const settled = app?.()?.settled;
505
- return await workReply(iterator, requestId, text, turn, settled === void 0 ? void 0 : () => settled.call(app(), sessionId, observing), options.onWorkerReport);
523
+ return await workReply(iterator, requestId, text, turn, settled === void 0 ? void 0 : () => settled.call(app(), sessionId, observing), options.onWorkerReport, options.onSay === void 0 && options.onTyping === void 0 ? void 0 : { say: options.onSay ?? (() => {
524
+ }), ...options.onTyping === void 0 ? {} : { typing: options.onTyping } });
506
525
  } finally {
507
526
  controller.abort();
508
527
  if (signal.aborted && iterator !== void 0)
@@ -616,7 +635,7 @@ var TurnReply = class {
616
635
  if (event.type === "assistant/message") {
617
636
  const said = event.content.map((p) => p.type === "text" ? p.text : "").join("").trim();
618
637
  if (said !== "")
619
- blocks.push({ kind: "text", text: said });
638
+ blocks.push({ kind: "text", text: said, seq: event.seq });
620
639
  } else if (event.type === "tool/call") {
621
640
  if (blocks.at(-1)?.kind !== "steps")
622
641
  blocks.push({ kind: "steps", steps: [] });
@@ -644,7 +663,83 @@ var TurnReply = class {
644
663
  return { blocks: [...this.#blocks], ...this.#outcome === void 0 ? {} : { outcome: this.#outcome }, ...this.#ended === void 0 ? {} : { ended: this.#ended } };
645
664
  }
646
665
  };
647
- async function workReply(iterator, requestId, text, turn, settled, onWorkerReport) {
666
+ var KEEP_TYPED = 32;
667
+ var LiveWords = class {
668
+ #sink;
669
+ #held;
670
+ /** Text typed per attempt, by content block. */
671
+ #typed = /* @__PURE__ */ new Map();
672
+ /** Attempts committed before their event was seen: event seq → attempt. */
673
+ #committed = /* @__PURE__ */ new Map();
674
+ /** Events seen before their attempt's end: seq → the words' key (null: no words to show). */
675
+ #events = /* @__PURE__ */ new Map();
676
+ constructor(sink) {
677
+ this.#sink = typeof sink === "function" ? { say: sink } : sink;
678
+ }
679
+ add(event) {
680
+ if (event.type !== "assistant/message" && event.type !== "tool/call")
681
+ return;
682
+ if (this.#held !== void 0)
683
+ this.#sink.say(this.#held);
684
+ this.#held = void 0;
685
+ if (event.type !== "assistant/message")
686
+ return;
687
+ const text = event.content.map((p) => p.type === "text" ? p.text : "").join("").trim();
688
+ const shown2 = text !== "" && !isQuiet(text);
689
+ if (shown2)
690
+ this.#held = { text, key: saidKey(event.seq, text) };
691
+ if (this.#sink.typing === void 0)
692
+ return;
693
+ const key = shown2 ? saidKey(event.seq, text) : null;
694
+ const attempt = this.#committed.get(event.seq);
695
+ if (attempt === void 0)
696
+ keep(this.#events, event.seq, key);
697
+ else {
698
+ this.#committed.delete(event.seq);
699
+ this.#settle(attempt, key);
700
+ }
701
+ }
702
+ /** A frame of dsh's assistant stream (the step being typed). */
703
+ frame(frame) {
704
+ const typing = this.#sink.typing;
705
+ if (typing === void 0)
706
+ return;
707
+ if (frame.type === "start")
708
+ this.#typed.set(frame.attemptId, []);
709
+ else if (frame.type === "delta") {
710
+ if (frame.kind !== "text")
711
+ return;
712
+ let parts = this.#typed.get(frame.attemptId);
713
+ if (parts === void 0)
714
+ this.#typed.set(frame.attemptId, parts = []);
715
+ parts[frame.index] = (parts[frame.index] ?? "") + frame.text;
716
+ const text = parts.join("").trim();
717
+ if (text !== "")
718
+ typing({ kind: "typing", id: frame.attemptId, text });
719
+ } else {
720
+ this.#typed.delete(frame.attemptId);
721
+ if (frame.outcome !== "committed" || frame.seq === void 0)
722
+ return typing({ kind: "dropped", id: frame.attemptId });
723
+ const key = this.#events.get(frame.seq);
724
+ if (key === void 0)
725
+ keep(this.#committed, frame.seq, frame.attemptId);
726
+ else {
727
+ this.#events.delete(frame.seq);
728
+ this.#settle(frame.attemptId, key);
729
+ }
730
+ }
731
+ }
732
+ #settle(attempt, key) {
733
+ this.#sink.typing?.(key === null ? { kind: "dropped", id: attempt } : { kind: "committed", id: attempt, key });
734
+ }
735
+ };
736
+ function keep(map, seq, value) {
737
+ map.set(seq, value);
738
+ while (map.size > KEEP_TYPED)
739
+ map.delete(map.keys().next().value);
740
+ }
741
+ async function workReply(iterator, requestId, text, turn, settled, onWorkerReport, words) {
742
+ const live = words === void 0 ? void 0 : new LiveWords(words);
648
743
  const inbox = {};
649
744
  let cancelled = false;
650
745
  let mine = false;
@@ -655,6 +750,12 @@ async function workReply(iterator, requestId, text, turn, settled, onWorkerRepor
655
750
  let reply = new TurnReply();
656
751
  let switched = false;
657
752
  const take = (frame) => {
753
+ if (frame.type === "assistant-stream") {
754
+ const typed = mine && !other && live !== void 0 ? convertLiveFrame(frame.frame) : null;
755
+ if (typed !== null)
756
+ live.frame(typed);
757
+ return false;
758
+ }
658
759
  if (frame.type !== "event")
659
760
  return false;
660
761
  if (!mine) {
@@ -696,6 +797,7 @@ async function workReply(iterator, requestId, text, turn, settled, onWorkerRepor
696
797
  other = false;
697
798
  return false;
698
799
  }
800
+ live?.add(event);
699
801
  if (event.type === "tool/call" && SUB_AGENT_TOOLS.has(event.name))
700
802
  opened = true;
701
803
  if (event.type === "turn/end" && event.reason.kind === "error" && afterSwitch) {
@@ -751,7 +853,7 @@ function joined(turns, unfinished) {
751
853
 
752
854
  // packages/notify/lib/delegate.js
753
855
  var MAX_OUT = 4;
754
- var DELEGATOR = "\u52A9\u624B";
856
+ var DELEGATOR = MAIN_AGENT_NAME;
755
857
  var TIMEOUT_MS = 2 * 60 * 6e4;
756
858
  var HANDED = (agent) => `\u5DF2\u4EA4\u7ED9\u300C${agent}\u300D\u3002\u5B83\u5728\u81EA\u5DF1\u7684\u5BF9\u8BDD\u91CC\u505A\uFF0C\u5B83\u505A\u7684\u8FC7\u7A0B\u4E2D\u8BF4\u7684\u8BDD\u548C\u6700\u540E\u7684\u7ED3\u8BBA\u90FD\u4F1A\u4F5C\u4E3A\u65B0\u6D88\u606F\u53D1\u5230\u8FD9\u4E2A\u5BF9\u8BDD\u91CC\u3002\u73B0\u5728\u7528\u4E00\u53E5\u8BDD\u8BF4\u4F60\u4EA4\u7ED9\u4E86\u8C01\u3001\u505A\u4EC0\u4E48\uFF0C\u7136\u540E\u7ED3\u675F\u8FD9\u4E00\u8F6E\uFF1A\u4E0D\u8981\u7B49\u5B83\uFF0C\u4E5F\u4E0D\u8981\u66FF\u5B83\u56DE\u7B54\u3002`;
757
859
  var Args2 = external_exports.object({
@@ -785,7 +887,7 @@ function delegateTool(deps) {
785
887
  parameters: {
786
888
  type: "object",
787
889
  properties: {
788
- agent: { type: "string", description: "agent \u7684\u540D\u5B57\u6216 id\uFF0C\u4F8B\u5982\u300C\u6E38\u620F\u300D\u300C\u811A\u672C\u300D\u3002" },
890
+ agent: { type: "string", description: "agent \u7684\u540D\u5B57\u6216 id\uFF0C\u4F8B\u5982\u300C\u6E38\u620F\u52A9\u624B\u300D\u300C\u811A\u672C\u52A9\u624B\u300D\u3002" },
789
891
  task: { type: "string", description: "\u76EE\u6807\uFF1A\u8981\u505A\u6210\u4EC0\u4E48\u6837\uFF0C\u52A0\u4E0A\u5DF2\u7ECF\u77E5\u9053\u7684\u60C5\u51B5\u3002\u4E0D\u5199\u6B65\u9AA4\u3002" },
790
892
  limits: { type: "string", description: "\u8FB9\u754C\uFF1A\u54EA\u4E9B\u4E0D\u80FD\u52A8\u3001\u505A\u5230\u54EA\u4E00\u6B65\u4E3A\u6B62\uFF0C\u4F8B\u5982\u300C\u53EA\u67E5\u4E0D\u6539\u300D\u300C\u4E0D\u8981\u91CD\u8DD1\u300D\uFF08\u53EF\u9009\uFF09\u3002" },
791
893
  allow: { type: "array", items: { type: "string", enum: DECISION_AREAS.map((a) => a.id) }, description: "\u7528\u6237\u5DF2\u7ECF\u660E\u786E\u8981\u505A\u3001\u53EF\u4EE5\u8BA9\u5BF9\u65B9\u76F4\u63A5\u505A\u7684\u6539\u52A8\u7C7B\u522B\uFF08\u53EF\u9009\uFF1B\u4E0D\u5199\u5C31\u90FD\u4EA4\u56DE\u7ED9\u4F60\u51B3\u5B9A\uFF09\u3002" },
@@ -811,16 +913,18 @@ function delegateTool(deps) {
811
913
  throw new Error("\u53EA\u80FD\u5728\u4F1A\u8BDD\u91CC\u4EA4\u51FA\u53BB");
812
914
  const caller = deps.agentOf?.(parent);
813
915
  const agents = deps.agents();
814
- const agent = agents.find((a) => a.name === wanted || a.id === wanted);
916
+ const agent = agents.find((a) => isAgentNamed(a, wanted));
815
917
  if (agent === void 0)
816
918
  throw new Error(`\u6CA1\u6709\u53EB\u300C${wanted}\u300D\u7684 agent\u3002\u53EF\u4EE5\u4EA4\u7ED9\uFF1A${agents.map((a) => a.name).join("\u3001") || "\uFF08\u6CA1\u6709\uFF09"}`);
817
919
  const conversations = deps.conversations();
818
920
  if (conversations === void 0)
819
921
  throw new Error("agent \u670D\u52A1\u8FD8\u6CA1\u6709\u51C6\u5907\u597D");
922
+ if (agent.id === caller?.id || caller === void 0 && agent.name === DELEGATOR) {
923
+ throw new Error(`\u4E0D\u80FD\u4EA4\u7ED9\u81EA\u5DF1\uFF08\u4F60\u5C31\u662F\u300C${agent.name}\u300D\uFF09\uFF1A\u81EA\u5DF1\u8FD9\u5757\u7684\u4E8B\u81EA\u5DF1\u505A\uFF0C\u8981\u5206\u51FA\u53BB\u5E76\u884C\u505A\u5C31\u5F00\u5B50 agent\uFF08subagent\uFF09\uFF1Bagent_delegate \u53EA\u7528\u6765\u4EA4\u7ED9\u522B\u7684\u89D2\u8272`);
924
+ }
820
925
  if ((out.get(parent) ?? 0) >= MAX_OUT)
821
926
  throw new Error(`\u8FD9\u4E2A\u5BF9\u8BDD\u5DF2\u7ECF\u6709 ${MAX_OUT} \u4EF6\u4E8B\u5728\u522B\u7684 agent \u90A3\u91CC\uFF0C\u7B49\u5176\u4E2D\u4E00\u4EF6\u56DE\u6765\u518D\u4EA4`);
822
- const self = agent.id === caller?.id;
823
- const refusal = self ? void 0 : conversations.handOffRefusal?.(parent, agent.id, caller?.id ?? "", agent.name);
927
+ const refusal = conversations.handOffRefusal?.(parent, agent.id, caller?.id ?? "", agent.name);
824
928
  if (refusal !== void 0)
825
929
  throw new Error(refusal);
826
930
  out.set(parent, (out.get(parent) ?? 0) + 1);
@@ -836,7 +940,7 @@ function delegateTool(deps) {
836
940
  ...expecting ? { expecting } : {},
837
941
  signal: AbortSignal.timeout(TIMEOUT_MS),
838
942
  from: { sessionId: parent, callId, asker: by, ...caller === void 0 ? {} : { agent: caller.id } },
839
- relay: !self,
943
+ relay: true,
840
944
  ...relayed === void 0 ? {} : { relayed }
841
945
  }).catch(() => {
842
946
  }).finally(() => settle(parent));
@@ -914,7 +1018,8 @@ function threadsTool(deps) {
914
1018
  const all = deps.list();
915
1019
  if (parsed.data.id == null) {
916
1020
  const who = parsed.data.with;
917
- const about = who == null ? all : all.filter((h) => h.by === who || h.to === who || h.by === deps.name(who) || deps.name(h.to) === who);
1021
+ const agentId = (x) => Object.keys(FORMER_AGENT_NAMES).find((id) => isAgentNamed({ id, name: deps.name(id) }, x)) ?? x;
1022
+ const about = who == null ? all : all.filter((h) => agentId(h.by) === agentId(who) || agentId(h.to) === agentId(who));
918
1023
  return about.slice(-20).reverse().map(line).join("\n") || (who == null ? "\uFF08\u8FD8\u6CA1\u6709\u7EBF\u7D22\uFF09" : `\uFF08\u548C\u300C${who}\u300D\u8FD8\u6CA1\u6709\u7EBF\u7D22\uFF09`);
919
1024
  }
920
1025
  const found = all.find((h) => h.id === parsed.data.id);
@@ -990,17 +1095,17 @@ var Notify = class {
990
1095
  notices() {
991
1096
  return this.#history.map(shown);
992
1097
  }
993
- /** Notices of the last day 助手 has not been told about yet (the latest few), oldest first. */
994
- untold() {
1098
+ /** Notices of the last day an agent (助手: `main`) has not been told about yet (the latest few), oldest first. */
1099
+ untold(agent = "main") {
995
1100
  const since = this.#now() - REPLY_WINDOW_MS;
996
- return this.#history.filter((n) => n.told !== true && n.at >= since).slice(-TELL_AT_MOST).map(shown);
1101
+ return this.#history.filter((n) => n.told !== true && n.at >= since && (n.agent ?? "main") === agent).slice(-TELL_AT_MOST).map(shown);
997
1102
  }
998
- /** 助手 has been told about these (and so no longer needs the older ones). */
999
- markTold(ids) {
1103
+ /** The agent has been told about these (and so no longer needs its older ones). */
1104
+ markTold(ids, agent = "main") {
1000
1105
  const last = Math.max(-1, ...ids.map((id) => this.#history.findIndex((n) => n.id === id)));
1001
1106
  if (last < 0)
1002
1107
  return;
1003
- this.#history = this.#history.map((n, i) => i <= last && n.told !== true ? { ...n, told: true } : n);
1108
+ this.#history = this.#history.map((n, i) => i <= last && n.told !== true && (n.agent ?? "main") === agent ? { ...n, told: true } : n);
1004
1109
  this.#saveHistory();
1005
1110
  }
1006
1111
  #changeNotice(id, change) {
@@ -1052,7 +1157,8 @@ var Notify = class {
1052
1157
  at: this.#now(),
1053
1158
  actions: (notice.actions ?? []).map((a) => ({ id: a.id, label: a.label, ...a.style === void 0 ? {} : { style: a.style } })),
1054
1159
  channels: reached,
1055
- ...notice.image === void 0 ? {} : { image: true }
1160
+ ...notice.image === void 0 ? {} : { image: true },
1161
+ ...notice.agent === void 0 ? {} : { agent: notice.agent }
1056
1162
  };
1057
1163
  this.#history = [...this.#history.filter((n) => n.id !== notice.id), item].slice(-KEEP_HISTORY);
1058
1164
  this.#saveHistory();
@@ -1095,7 +1201,7 @@ var Notify = class {
1095
1201
  /** Who picked an action, for people: 你(软件), 你(QQ), 助手. */
1096
1202
  #actorName(actor) {
1097
1203
  if (actor.channel === "agent")
1098
- return actor.name ?? "\u52A9\u624B";
1204
+ return actor.name ?? MAIN_AGENT_NAME;
1099
1205
  if (actor.channel === "app")
1100
1206
  return "\u4F60\uFF08\u8F6F\u4EF6\uFF09";
1101
1207
  return `${actor.name ?? "\u4F60"}\uFF08${this.channelName(actor.channel)}\uFF09`;
@@ -1106,6 +1212,10 @@ var Notify = class {
1106
1212
  * anything else is a conversation with the agent.
1107
1213
  * @returns the reply to send back, for the channel to render.
1108
1214
  */
1215
+ /**
1216
+ * @param message_.onSay - each thing the agent says while it works, as it says it; the reply then ends with its last words.
1217
+ * @param message_.onTyping - the agent's words while it types them (all of them, the last words too).
1218
+ */
1109
1219
  async inbound(message_) {
1110
1220
  const text = message_.text.trim();
1111
1221
  const key = `${message_.actor.channel}:${message_.actor.userId}`;
@@ -1142,12 +1252,13 @@ var Notify = class {
1142
1252
  ${text}`;
1143
1253
  }
1144
1254
  const signal = message_.signal ?? AbortSignal.timeout(20 * 6e4);
1145
- prompt = `${channelNote(message_.actor.channel)}
1255
+ const live = message_.onSay !== void 0 && conversations.converse !== void 0;
1256
+ prompt = `${channelNote(message_.actor.channel, live)}
1146
1257
  ${prompt}`;
1147
1258
  this.#origins.set(prompt.trim(), message_.actor);
1148
1259
  while (this.#origins.size > KEEP_ORIGINS)
1149
1260
  this.#origins.delete(this.#origins.keys().next().value);
1150
- return conversations.converse !== void 0 ? await conversations.converse(sessionId, prompt, signal, [], { insert: true }) : textReply(await conversations.ask(sessionId, prompt, signal));
1261
+ return conversations.converse !== void 0 ? await conversations.converse(sessionId, prompt, signal, [], { insert: true, ...live ? { onSay: message_.onSay } : {}, ...live && message_.onTyping !== void 0 ? { onTyping: message_.onTyping } : {} }) : textReply(await conversations.ask(sessionId, prompt, signal));
1151
1262
  }
1152
1263
  /** The agent waits for this person's answer (a question, an approval): their next message is it, not one to queue. */
1153
1264
  waiting(actor) {
@@ -1366,7 +1477,9 @@ ${text}
1366
1477
  "\u4E3B\u4EBA\u7684\u8BDD\u662F\u5728\u56DE\u5E94\u67D0\u6761\u8FD8\u5728\u7B49\u9009\u62E9\u7684\u901A\u77E5\u65F6\uFF08\u4F8B\u5982\u300C\u6539\u5427\u300D\u300C\u597D\u300D\u300C\u4E0D\u7528\u4E86\u300D\u300C\u505C\u300D\uFF09\uFF0C\u7528 notice_act \u66FF\u4ED6\u9009\u5BF9\u5E94\u7684\u64CD\u4F5C\uFF0C\u518D\u544A\u8BC9\u4ED6\u7ED3\u679C\uFF1B\u62FF\u4E0D\u51C6\u6307\u54EA\u6761\u5C31\u95EE\u3002\u8DDF\u901A\u77E5\u65E0\u5173\u5C31\u7167\u5E38\u56DE\u7B54\uFF0C\u4E0D\u7528\u63D0\u8FD9\u4E9B\u901A\u77E5\u3002"
1367
1478
  ].join("\n");
1368
1479
  }
1369
- function channelNote(channel) {
1480
+ function channelNote(channel, live = false) {
1481
+ if (live)
1482
+ return `\uFF08\u8FD9\u6761\u6D88\u606F\u6765\u81EA${CHANNEL_NAMES[channel] ?? channel}\u3002\u4F60\u8BF4\u7684\u6BCF\u6BB5\u8BDD\u90FD\u4F1A\u9A6C\u4E0A\u53D1\u7ED9\u5BF9\u65B9\uFF0C\u6B65\u9AA4\u4E0D\u4F1A\uFF1A\u8981\u505A\u4E00\u9635\u7684\u4E8B\u5148\u8BF4\u4E00\u53E5\u5728\u505A\u4EC0\u4E48\uFF1B\u6700\u540E\u7528\u51E0\u53E5\u8BDD\u603B\u7ED3\u8FD9\u4E00\u8F6E\u2014\u2014\u7ED3\u8BBA\u3001\u505A\u4E86\u4EC0\u4E48\u3001\u9700\u8981\u5BF9\u65B9\u505A\u4EC0\u4E48\u3002\uFF09`;
1370
1483
  return `\uFF08\u8FD9\u6761\u6D88\u606F\u6765\u81EA${CHANNEL_NAMES[channel] ?? channel}\u3002\u53EA\u6709\u4F60\u8FD9\u4E00\u8F6E\u7684\u6700\u540E\u4E00\u6761\u6D88\u606F\u4F1A\u53D1\u7ED9\u5BF9\u65B9\uFF0C\u4E2D\u95F4\u7684\u8BDD\u548C\u6B65\u9AA4\u5BF9\u65B9\u770B\u4E0D\u5230\uFF1A\u6700\u540E\u7528\u51E0\u53E5\u8BDD\u603B\u7ED3\u8FD9\u4E00\u8F6E\u2014\u2014\u7ED3\u8BBA\u3001\u505A\u4E86\u4EC0\u4E48\u3001\u9700\u8981\u5BF9\u65B9\u505A\u4EC0\u4E48\u3002\uFF09`;
1371
1484
  }
1372
1485
  var CHANNEL_NAMES = { feishu: "\u98DE\u4E66", qq: "QQ" };
@@ -1380,7 +1493,7 @@ function approvalText(request) {
1380
1493
  function questionText(request) {
1381
1494
  const first = request.questions[0];
1382
1495
  const more = request.questions.length > 1 ? `\uFF08\u5171 ${request.questions.length} \u4E2A\u95EE\u9898\uFF0C\u7B54\u5B8C\u4E00\u4E2A\u53D1\u4E0B\u4E00\u4E2A\uFF09` : "";
1383
- return ["\u3010\u52A9\u624B\u95EE\u4F60\u3011" + more, first === void 0 ? "" : describeQuestion(first), "\u56DE\u590D\u9009\u9879\u7684\u6570\u5B57\u6216\u6587\u5B57\uFF0C\u6216\u76F4\u63A5\u5199\u4F60\u7684\u56DE\u7B54\u3002"].join("\n");
1496
+ return [`\u3010${MAIN_AGENT_NAME} \u95EE\u4F60\u3011` + more, first === void 0 ? "" : describeQuestion(first), "\u56DE\u590D\u9009\u9879\u7684\u6570\u5B57\u6216\u6587\u5B57\uFF0C\u6216\u76F4\u63A5\u5199\u4F60\u7684\u56DE\u7B54\u3002"].join("\n");
1384
1497
  }
1385
1498
  function describeQuestion(item) {
1386
1499
  const options = item.options ?? [];
@@ -1388,7 +1501,7 @@ function describeQuestion(item) {
1388
1501
  }
1389
1502
 
1390
1503
  // packages/notify/lib/mirror.js
1391
- var MAIN_NAME = "\u52A9\u624B";
1504
+ var MAIN_NAME = MAIN_AGENT_NAME;
1392
1505
  var KEEP_SEEN = 200;
1393
1506
  var HomeMirror = class {
1394
1507
  #deps;
@@ -1440,20 +1553,28 @@ var HomeMirror = class {
1440
1553
  event(event) {
1441
1554
  if (event.type === "user/message") {
1442
1555
  const text = event.content.map((p) => p.type === "text" ? p.text : "").join("");
1443
- const origin2 = event.origin.human ? this.#message(text) : void 0;
1556
+ const { origin, person } = event.origin.human ? this.#message(text) : { origin: void 0, person: false };
1444
1557
  const reminder = event.origin.human ? void 0 : reminderPrompts(text);
1445
1558
  if (reminder !== void 0)
1446
1559
  this.#deps.post({ text: reminderLine(reminder) });
1447
- this.#turn ??= { origin: void 0, reply: new TurnReply() };
1448
- this.#turn.origin ??= origin2;
1560
+ const turn2 = this.#turn ??= this.#newTurn();
1561
+ turn2.origin ??= origin;
1562
+ if (person && turn2.live === void 0)
1563
+ turn2.live = new LiveWords((said) => {
1564
+ turn2.said.add(said.key);
1565
+ this.#deps.post({ text: said.text, markdown: true, key: said.key }, turn2.origin);
1566
+ });
1449
1567
  return;
1450
1568
  }
1451
- this.#turn ??= { origin: void 0, reply: new TurnReply() };
1452
- if (!this.#turn.reply.add(event))
1569
+ const turn = this.#turn ??= this.#newTurn();
1570
+ turn.live?.add(event);
1571
+ if (!turn.reply.add(event))
1453
1572
  return;
1454
- const { origin, reply } = this.#turn;
1455
1573
  this.#turn = void 0;
1456
- this.#reply(reply.reply, origin);
1574
+ this.#reply(turn.reply.reply, turn.origin, turn.said);
1575
+ }
1576
+ #newTurn() {
1577
+ return { origin: void 0, reply: new TurnReply(), live: void 0, said: /* @__PURE__ */ new Set() };
1457
1578
  }
1458
1579
  /** A hand-off (the gateway's); 助手's (from its conversation) become lines. */
1459
1580
  handOff(item) {
@@ -1467,36 +1588,45 @@ var HomeMirror = class {
1467
1588
  const to = this.#deps.agentName(item.to);
1468
1589
  this.#deps.post({ text: item.state === "running" ? `${item.by} \u2192 ${to}\uFF1A${item.title}` : `${to} \u2192 ${item.by}\uFF1A${item.title}\uFF08${item.state === "done" ? "\u4EA4\u56DE\u4E86" : "\u6CA1\u6709\u505A\u5B8C"}\uFF09` });
1469
1590
  }
1470
- /** @returns who wrote it from a chat app, if someone did. */
1591
+ /** @returns who wrote it from a chat app, if someone did; `person`: someone wrote it (not an agent, a task or a reminder). */
1471
1592
  #message(text) {
1593
+ const none = { origin: void 0, person: false };
1472
1594
  if (parseRelay(text) !== void 0)
1473
- return void 0;
1595
+ return none;
1474
1596
  const said = parseThreadNote(text);
1475
1597
  if (said !== void 0) {
1476
1598
  this.#deps.post({ text: `${said.from} \u2192 ${MAIN_NAME}\uFF1A${{ question: "\u95EE", answer: "\u7B54", update: "\u8BF4" }[said.kind]}\uFF1A${said.text}` });
1477
- return void 0;
1599
+ return none;
1478
1600
  }
1479
1601
  const task = parseTask(text);
1480
1602
  if (task !== void 0) {
1481
1603
  this.#deps.post({ text: task.by === BY_YOU ? `\u4F60\uFF08\u8F6F\u4EF6\uFF09\u70B9\u4E86\uFF1A${task.title}` : `${task.by} \u2192 ${MAIN_NAME}\uFF1A${task.title}` });
1482
- return void 0;
1604
+ return none;
1483
1605
  }
1484
1606
  const origin = this.#deps.originOf(text);
1485
1607
  const words = personWords(text);
1486
1608
  if (words === "")
1487
- return origin;
1609
+ return { origin, person: false };
1488
1610
  if (origin === void 0)
1489
1611
  this.#deps.post({ text: `\u4F60\uFF08\u8F6F\u4EF6\uFF09\uFF1A${words}` });
1490
1612
  else
1491
1613
  this.#deps.post({ text: `${origin.name ?? "\u5BF9\u65B9"}\uFF08${this.#deps.channelName(origin.channel)}\uFF09\uFF1A${words}` }, origin);
1492
- return origin;
1614
+ return { origin, person: true };
1493
1615
  }
1494
- #reply(reply, origin) {
1616
+ /** @param said - what of it already went out as it was said. */
1617
+ #reply(reply, origin, said) {
1495
1618
  const words = finalText(reply).trim();
1496
1619
  const stepped = reply.blocks.some((b) => b.kind === "steps");
1497
1620
  if (words === "" && !stepped || isQuiet(words))
1498
1621
  return;
1499
- this.#deps.post({ text: replyMarkdown(reply), markdown: true }, origin);
1622
+ const key = finalKey(reply);
1623
+ if (key !== void 0 && said.has(key)) {
1624
+ const rest = replyRest(reply);
1625
+ if (rest !== "")
1626
+ this.#deps.post({ text: rest }, origin);
1627
+ return;
1628
+ }
1629
+ this.#deps.post({ text: replyMarkdown(reply), markdown: true, ...key === void 0 ? {} : { key } }, origin);
1500
1630
  }
1501
1631
  };
1502
1632
 
@@ -1579,21 +1709,24 @@ var AdgNotify = class extends Service {
1579
1709
  resolved: (id, outcome) => notify.approvalResolved(id, outcome)
1580
1710
  });
1581
1711
  const agentOf = (sessionId) => scoped.adgGateway.agentOfSession(sessionId);
1582
- const agentName = (id) => id === MAIN ? "\u52A9\u624B" : scoped.adgGateway.roles.list().find((r) => r.id === id)?.name ?? id;
1583
- scoped.adgGateway.agentPart("adg-notify agent_delegate", (agent) => agent.tools.register(delegateTool({ agents: () => [{ id: MAIN, name: "\u52A9\u624B" }, ...scoped.adgGateway.roles.list()], conversations, agentOf })));
1712
+ const agentName = (id) => id === MAIN ? MAIN_AGENT_NAME : scoped.adgGateway.roles.list().find((r) => r.id === id)?.name ?? id;
1713
+ scoped.adgGateway.agentPart("adg-notify agent_delegate", (agent) => agent.tools.register(delegateTool({ agents: () => [{ id: MAIN, name: MAIN_AGENT_NAME }, ...scoped.adgGateway.roles.list()], conversations, agentOf })));
1584
1714
  scoped.adgGateway.agentPart("adg-notify agent_message", (agent) => agent.tools.register(messageTool({ desk: () => conversations()?.desk, agentOf })));
1585
1715
  scoped.adgGateway.agentPart("adg-notify agent_threads", (agent) => agent.tools.register(threadsTool({ list: () => scoped.adgGateway.handOffs.all(), name: agentName })));
1586
- scoped.adgGateway.agentPart("adg-notify notice_act", (agent) => agent.tools.register(noticeActTool(notify, gateway.roles.list().find((r) => r.id === MAIN)?.name ?? "\u52A9\u624B")));
1716
+ scoped.adgGateway.agentPart("adg-notify notice_act", (agent) => agent.tools.register(noticeActTool(notify, gateway.roles.list().find((r) => r.id === MAIN)?.name ?? MAIN_AGENT_NAME)));
1587
1717
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1588
1718
  scoped.adgGateway.agentPart("adg-notify notices note", (agent) => agent.on("agent/pre-step", (async (payload, next) => {
1589
1719
  const decision = await next();
1590
1720
  if (decision.kind !== "enter" || payload.step !== 1 || payload.signal.aborted)
1591
1721
  return decision;
1592
1722
  try {
1593
- const items = notify.untold();
1594
- if (items.length === 0 || payload.agent.session.id !== await gateway.home(MAIN))
1723
+ const home = gateway.homes.agentOf(payload.agent.session.id);
1724
+ if (home === void 0)
1725
+ return decision;
1726
+ const items = notify.untold(home);
1727
+ if (items.length === 0)
1595
1728
  return decision;
1596
- notify.markTold(items.map((n) => n.id));
1729
+ notify.markTold(items.map((n) => n.id), home);
1597
1730
  return { ...decision, messages: [...decision.messages, noticesMessage(noticesNote(items, timeZone))] };
1598
1731
  } catch (error) {
1599
1732
  log.warn(`notices note for ${payload.agent.session.id}: ${error instanceof Error ? error.message : String(error)}`);
@@ -1669,6 +1802,8 @@ export {
1669
1802
  NOTICES_SOURCE,
1670
1803
  noticeActTool,
1671
1804
  textReply,
1805
+ finalKey,
1806
+ replyRest,
1672
1807
  finalText,
1673
1808
  replyMarkdown,
1674
1809
  replyPlain,
package/lib/emulator.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  EMULATORS_CAPABILITY,
11
11
  EmulatorSettings
12
- } from "./chunk-34VNH3YS.js";
12
+ } from "./chunk-BB2T4JHF.js";
13
13
  import {
14
14
  external_exports
15
15
  } from "./chunk-6DSSLS7I.js";
@@ -999,6 +999,7 @@ var AdgEmulators = class extends Service {
999
999
  async prepare(options) {
1000
1000
  await this.ready;
1001
1001
  if (this.settings.manualAddress !== void 0 && options.index === void 0) {
1002
+ await this.connectQuietly(this.settings.manualAddress, options.onStatus);
1002
1003
  return { address: this.settings.manualAddress, label: "\u624B\u52A8\u914D\u7F6E\u7684 ADB \u5730\u5740", managed: false };
1003
1004
  }
1004
1005
  const mumu = await this.manager();
@@ -1010,7 +1011,17 @@ var AdgEmulators = class extends Service {
1010
1011
  throw new Error(`MuMu \u5B9E\u4F8B ${index} \u6CA1\u6709\u8FD0\u884C\uFF0C\u4E14\u5DF2\u5173\u95ED\u300C\u4EFB\u52A1\u9700\u8981\u65F6\u81EA\u52A8\u542F\u52A8\u300D`);
1011
1012
  }
1012
1013
  const ready = await mumu.ensureReady(index, { timeoutMs: this.settings.bootTimeoutSeconds * 1e3, signal: options.signal, onStatus: options.onStatus });
1013
- return { address: await mumu.adbAddress(index), label: `MuMu ${ready.index}\uFF08${ready.name}\uFF09`, managed: true };
1014
+ const address = await mumu.adbAddress(index);
1015
+ await this.connectQuietly(address, options.onStatus);
1016
+ return { address, label: `MuMu ${ready.index}\uFF08${ready.name}\uFF09`, managed: true };
1017
+ }
1018
+ /** `connect`, saying so instead of failing: the script may still connect by itself. */
1019
+ async connectQuietly(address, onStatus) {
1020
+ try {
1021
+ await this.connect(await this.adb(), address);
1022
+ } catch (error) {
1023
+ onStatus(`\u672C\u5E94\u7528\u7684 adb \u6CA1\u6709\u8FDE\u4E0A ${address}\uFF08${error instanceof Error ? error.message : String(error)}\uFF09\uFF0C\u811A\u672C\u53EF\u80FD\u4F1A\u81EA\u5DF1\u8FDE\u63A5`);
1024
+ }
1014
1025
  }
1015
1026
  /** The address `prepare` would return, without starting anything (the runner locks it first). */
1016
1027
  async expectedAddress() {
@@ -1072,10 +1083,15 @@ var AdgEmulators = class extends Service {
1072
1083
  */
1073
1084
  async launchApp(address, pkg) {
1074
1085
  await this.ready;
1075
- const result = await this.exec(await this.adb(), ["-s", address, "shell", "monkey", "-p", pkg, "-c", "android.intent.category.LAUNCHER", "1"], { timeoutMs: 3e4 });
1086
+ const adb = await this.adb();
1087
+ await this.connect(adb, address);
1088
+ const result = await this.exec(adb, ["-s", address, "shell", "monkey", "-p", pkg, "-c", "android.intent.category.LAUNCHER", "1"], { timeoutMs: 3e4 });
1076
1089
  if (result === void 0)
1077
1090
  throw new Error("\u627E\u4E0D\u5230 adb\uFF0C\u65E0\u6CD5\u542F\u52A8\u6E38\u620F");
1078
1091
  const output = `${result.stdout}${result.stderr}`;
1092
+ const last = output.trim().split("\n").pop() ?? "";
1093
+ if (/device .*not found|device offline|no devices|unauthorized/i.test(output))
1094
+ throw new Error(`\u542F\u52A8 ${pkg} \u5931\u8D25\uFF1A\u8FDE\u4E0D\u4E0A\u6A21\u62DF\u5668 ${address}\uFF08${last}\uFF09`);
1079
1095
  if (/No activities found|monkey aborted|not found/i.test(output) || !/Events injected/i.test(output)) {
1080
1096
  throw new Error(`\u542F\u52A8 ${pkg} \u5931\u8D25\uFF1A\u6A21\u62DF\u5668\u91CC\u53EF\u80FD\u6CA1\u6709\u88C5\u8FD9\u4E2A\u6E38\u620F\uFF08${output.trim().split("\n").pop() ?? ""}\uFF09`);
1081
1097
  }
package/lib/feishu.js CHANGED
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
2
2
  import {
3
3
  replyMarkdown,
4
4
  replyPlain
5
- } from "./chunk-4QXRDWGS.js";
5
+ } from "./chunk-RREVLKRY.js";
6
6
  import {
7
7
  require_extension,
8
8
  require_permessage_deflate,
@@ -12,8 +12,8 @@ import {
12
12
  require_subprotocol,
13
13
  require_websocket,
14
14
  require_websocket_server
15
- } from "./chunk-QSETYM2Y.js";
16
- import "./chunk-M7GNYL5B.js";
15
+ } from "./chunk-OCJFAT7J.js";
16
+ import "./chunk-4NR36PKL.js";
17
17
  import {
18
18
  writeFileAtomic
19
19
  } from "./chunk-RESS7WVY.js";
@@ -22,7 +22,7 @@ import {
22
22
  FEISHU_SECRET_REF,
23
23
  FeishuPending,
24
24
  FeishuSettings
25
- } from "./chunk-34VNH3YS.js";
25
+ } from "./chunk-BB2T4JHF.js";
26
26
  import {
27
27
  external_exports
28
28
  } from "./chunk-6DSSLS7I.js";
package/lib/game-intel.js CHANGED
@@ -6,13 +6,13 @@ import {
6
6
  GameSource,
7
7
  parseGameManifest,
8
8
  routineLogs
9
- } from "./chunk-C7X2KJ5C.js";
9
+ } from "./chunk-7UJ3LK3G.js";
10
10
  import {
11
11
  finalText,
12
12
  sessionConversations
13
- } from "./chunk-4QXRDWGS.js";
14
- import "./chunk-QSETYM2Y.js";
15
- import "./chunk-M7GNYL5B.js";
13
+ } from "./chunk-RREVLKRY.js";
14
+ import "./chunk-OCJFAT7J.js";
15
+ import "./chunk-4NR36PKL.js";
16
16
  import {
17
17
  ExeIcons,
18
18
  writeFileAtomic
@@ -28,7 +28,7 @@ import {
28
28
  SCREEN_SOURCE,
29
29
  SHOT_IMAGE,
30
30
  taskMessage
31
- } from "./chunk-34VNH3YS.js";
31
+ } from "./chunk-BB2T4JHF.js";
32
32
  import {
33
33
  external_exports
34
34
  } from "./chunk-6DSSLS7I.js";
@@ -6238,7 +6238,7 @@ var ConfigSchema = external_exports.object({
6238
6238
  });
6239
6239
  var GAME_ROLE = {
6240
6240
  id: "games",
6241
- name: "\u6E38\u620F",
6241
+ name: "\u6E38\u620F\u52A9\u624B",
6242
6242
  description: "\u8BFB\u6E38\u620F\u6D3B\u52A8\u548C\u8D44\u8BAF\u3001\u5199\u65E5\u62A5\u3001\u6DFB\u52A0\u6E38\u620F",
6243
6243
  handles: "\u6E38\u620F\u672C\u8EAB\u7684\u4E8B\u4EA4\u7ED9\u5B83\uFF1A\u67E5\u6E38\u620F\u7684\u6D3B\u52A8\u3001\u8D44\u8BAF\u3001\u5361\u6C60\u548C\u8FDB\u5EA6\uFF08\u5B98\u7F51\u3001\u516C\u544A\uFF0C\u5FC5\u8981\u65F6\u8FDB\u6E38\u620F\u770B\u753B\u9762\uFF09\u5E76\u8BB0\u8FDB\u65E5\u5386\uFF0C\u5199\u65E5\u62A5\uFF0C\u6DFB\u52A0\u6E38\u620F\u3001\u627E\u6E38\u620F\u7684\u5B89\u88C5\u8DEF\u5F84\u3002\u4E0D\u8FD0\u884C\u3001\u4E0D\u5B89\u88C5\u811A\u672C\u3002",
6244
6244
  order: 20,
@@ -6250,7 +6250,7 @@ var GAME_ROLE = {
6250
6250
  tools: ["game_*", "screen_*", "window_*", "browser_*", "emulator_status", "emulator_start", "script_list", "script_tasks", "script_runs", "script_run_log", "skill_hub_list", "system_info", "skill_focus", "skill_save"],
6251
6251
  duty: [
6252
6252
  "# \u4F60\u7684\u89D2\u8272\uFF1A\u6E38\u620F",
6253
- "\u4F60\u662F MultiGameAssistant \u7684\u300C\u6E38\u620F\u300Dagent\uFF1A\u8BFB\u6E38\u620F\u7684\u6D3B\u52A8\u3001\u8D44\u8BAF\u548C\u8FDB\u5EA6\u5E76\u8BB0\u4E0B\u6765\uFF08game_record\uFF09\uFF0C\u5199\u65E5\u62A5\uFF0C\u6DFB\u52A0\u6E38\u620F\u3002",
6253
+ "\u4F60\u662F MultiGameAssistant \u7684\u300C\u6E38\u620F\u52A9\u624B\u300Dagent\uFF1A\u8BFB\u6E38\u620F\u7684\u6D3B\u52A8\u3001\u8D44\u8BAF\u548C\u8FDB\u5EA6\u5E76\u8BB0\u4E0B\u6765\uFF08game_record\uFF09\uFF0C\u5199\u65E5\u62A5\uFF0C\u6DFB\u52A0\u6E38\u620F\u3002",
6254
6254
  "\u4E0D\u5B89\u88C5\u3001\u8FD0\u884C\u6216\u4FEE\u811A\u672C\uFF0C\u4E0D\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\uFF1B\u9700\u8981\u8FD9\u4E9B\u65F6\u4EA4\u7ED9\u5BF9\u5E94\u7684\u540C\u4E8B\uFF08agent_delegate\uFF09\uFF0C\u6216\u8005\u5728\u56DE\u590D\u91CC\u8BF4\u6E05\u695A\u3002"
6255
6255
  ].join("\n")
6256
6256
  };
@@ -7885,30 +7885,29 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
7885
7885
  }));
7886
7886
  }
7887
7887
  /**
7888
- * The agent's summary of the recent events (just started, ending soon,
7889
- * starting soon), in a session of its own. @returns undefined when the
7890
- * setting is off, nothing is recent, or the agent cannot (the plain list goes out).
7888
+ * 游戏助手's summary of the recent events (just started, ending soon,
7889
+ * starting soon): one model call as 游戏助手 — its role, memory, reply
7890
+ * style and model — outside any conversation, so no session is left and
7891
+ * nothing comes back into 游戏助手's conversation to be summarized again
7892
+ * (gateway writeAs). @returns undefined when the setting is off, nothing
7893
+ * is recent, or it cannot be written (the plain list goes out).
7891
7894
  */
7892
7895
  async summarize() {
7893
7896
  const settings = this.calendar.settings.report;
7894
- const sessions = this.ctx.get("sessionController");
7895
- if (!settings.ai || sessions === void 0)
7897
+ const gateway = this.ctx.get("adgGateway");
7898
+ if (!settings.ai || gateway === void 0)
7896
7899
  return void 0;
7897
- const now = this.clock.now();
7898
- const digest = recentDigest(this.reportGames(), this.calendar.list(), settings, now);
7900
+ const digest = recentDigest(this.reportGames(), this.calendar.list(), settings, this.clock.now());
7899
7901
  if (digest === void 0)
7900
7902
  return void 0;
7901
- const local = wallClock(now, Intl.DateTimeFormat().resolvedOptions().timeZone);
7902
- const conversations = sessionConversations(sessions, () => this.ctx.get("adgGateway")?.workspaceDir(), void 0, () => this.ctx.get("adgGateway"));
7903
+ const prompt = [
7904
+ "\u628A\u4E0B\u9762\u8FD9\u4E9B\u8FD1\u671F\u7684\u6E38\u620F\u6D3B\u52A8\u5199\u6210\u4ECA\u5929\u53D1\u5230\u98DE\u4E66\u7684\u65E5\u62A5\u6B63\u6587\u3002\u53EA\u6839\u636E\u7ED9\u51FA\u7684\u5185\u5BB9\u5199\u3002",
7905
+ "\u8981\u6C42\uFF1A\u4E2D\u6587\uFF0C\u6309\u6E38\u620F\u5206\u6BB5\uFF08\u6BB5\u9996\u7528\u3010\u6E38\u620F\u540D\u3011\uFF09\uFF0C\u6BCF\u4E2A\u6E38\u620F\u4E00\u4E24\u53E5\uFF1B\u5148\u8BF4\u65E5\u5E38\u3001\u5468\u5E38\u8FD8\u5DEE\u54EA\u51E0\u9879\u3001\u4EC0\u4E48\u65F6\u5019\u91CD\u7F6E\uFF08\u90FD\u505A\u5B8C\u4E86\u4E00\u53E5\u5E26\u8FC7\uFF1B\u5468\u5E38\u5FEB\u91CD\u7F6E\u8FD8\u6CA1\u505A\u5B8C\u8981\u63D0\u9192\uFF09\uFF0C\u518D\u8BF4\u5FEB\u7ED3\u675F\u4E14\u6CA1\u505A\u5B8C\u7684\u6D3B\u52A8\uFF08\u5199\u6E05\u5269\u51E0\u5929\u3001\u8FD8\u5DEE\u4EC0\u4E48\uFF09\uFF0C\u6700\u540E\u8BF4\u521A\u5F00\u59CB\u548C\u5373\u5C06\u5F00\u59CB\u7684\uFF1B\u7528\u6237\u5DF2\u505A\u5B8C\u7684\u4E0D\u7528\u63D0\u9192\uFF1B\u4E0D\u7528 Markdown \u6807\u9898\u3001\u52A0\u7C97\u6216\u8868\u683C\uFF1B\u6574\u7BC7\u4E0D\u8D85\u8FC7 12 \u884C\u3002\u8BED\u6C14\u3001\u79F0\u547C\u548C\u81EA\u79F0\u6309\u4F60\u7684\u300C\u56DE\u590D\u98CE\u683C\u300D\u6765\uFF08\u6CA1\u6709\u8BBE\u5B9A\u5C31\u5E73\u5B9E\u5730\u5199\uFF09\uFF1A\u53EF\u4EE5\u7528\u4E00\u53E5\u7B26\u5408\u98CE\u683C\u7684\u8BDD\u5F00\u5934\uFF0C\u5185\u5BB9\u7167\u4E0A\u9762\u7684\u8981\u6C42\uFF0C\u4E0D\u8981\u5BA2\u5957\u7684\u7ED3\u675F\u8BED\u3002",
7906
+ "",
7907
+ digest
7908
+ ].join("\n");
7903
7909
  try {
7904
- const work = await conversations.prepareTask(GAME_ROLE.id, `\u65E5\u62A5\uFF1A${local.month}\u6708${local.day}\u65E5`);
7905
- const prompt = [
7906
- "\u628A\u4E0B\u9762\u8FD9\u4E9B\u8FD1\u671F\u7684\u6E38\u620F\u6D3B\u52A8\u5199\u6210\u4ECA\u5929\u53D1\u5230\u98DE\u4E66\u7684\u65E5\u62A5\u6B63\u6587\u3002\u53EA\u6839\u636E\u7ED9\u51FA\u7684\u5185\u5BB9\u5199\uFF0C\u4E0D\u8C03\u7528\u5DE5\u5177\uFF0C\u4E0D\u63D0\u95EE\u3002",
7907
- "\u8981\u6C42\uFF1A\u4E2D\u6587\uFF0C\u6309\u6E38\u620F\u5206\u6BB5\uFF08\u6BB5\u9996\u7528\u3010\u6E38\u620F\u540D\u3011\uFF09\uFF0C\u6BCF\u4E2A\u6E38\u620F\u4E00\u4E24\u53E5\uFF1B\u5148\u8BF4\u65E5\u5E38\u3001\u5468\u5E38\u8FD8\u5DEE\u54EA\u51E0\u9879\u3001\u4EC0\u4E48\u65F6\u5019\u91CD\u7F6E\uFF08\u90FD\u505A\u5B8C\u4E86\u4E00\u53E5\u5E26\u8FC7\uFF1B\u5468\u5E38\u5FEB\u91CD\u7F6E\u8FD8\u6CA1\u505A\u5B8C\u8981\u63D0\u9192\uFF09\uFF0C\u518D\u8BF4\u5FEB\u7ED3\u675F\u4E14\u6CA1\u505A\u5B8C\u7684\u6D3B\u52A8\uFF08\u5199\u6E05\u5269\u51E0\u5929\u3001\u8FD8\u5DEE\u4EC0\u4E48\uFF09\uFF0C\u6700\u540E\u8BF4\u521A\u5F00\u59CB\u548C\u5373\u5C06\u5F00\u59CB\u7684\uFF1B\u7528\u6237\u5DF2\u505A\u5B8C\u7684\u4E0D\u7528\u63D0\u9192\uFF1B\u4E0D\u7528 Markdown \u6807\u9898\u3001\u52A0\u7C97\u6216\u8868\u683C\uFF1B\u6574\u7BC7\u4E0D\u8D85\u8FC7 12 \u884C\u3002\u8BED\u6C14\u3001\u79F0\u547C\u548C\u81EA\u79F0\u6309\u4F60\u7684\u300C\u56DE\u590D\u98CE\u683C\u300D\u6765\uFF08\u6CA1\u6709\u8BBE\u5B9A\u5C31\u5E73\u5B9E\u5730\u5199\uFF09\uFF1A\u53EF\u4EE5\u7528\u4E00\u53E5\u7B26\u5408\u98CE\u683C\u7684\u8BDD\u5F00\u5934\uFF0C\u5185\u5BB9\u7167\u4E0A\u9762\u7684\u8981\u6C42\uFF0C\u4E0D\u8981\u5BA2\u5957\u7684\u7ED3\u675F\u8BED\u3002",
7908
- "",
7909
- digest
7910
- ].join("\n");
7911
- const answer = (await work.run(taskMessage("\u5B9A\u65F6", `\u65E5\u62A5\uFF1A${local.month}\u6708${local.day}\u65E5`, prompt), AbortSignal.timeout(SUMMARY_TIMEOUT_MS))).trim();
7910
+ const answer = await gateway.writeAs(GAME_ROLE.id, prompt, AbortSignal.timeout(SUMMARY_TIMEOUT_MS));
7912
7911
  return answer.length === 0 ? void 0 : answer;
7913
7912
  } catch (error) {
7914
7913
  this.log.warn(`daily report: the agent summary failed, sending the plain list: ${error instanceof Error ? error.message : String(error)}`);
@@ -7923,7 +7922,7 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
7923
7922
  let channels = [];
7924
7923
  let result;
7925
7924
  try {
7926
- channels = await this.ctx.adgNotify.notify.send({ id: `games-report:${day}:${this.clock.now()}`, scope: "games", title, text, severity: "info" });
7925
+ channels = await this.ctx.adgNotify.notify.send({ id: `games-report:${day}:${this.clock.now()}`, scope: "games", agent: GAME_ROLE.id, title, text, severity: "info" });
7927
7926
  result = channels.length === 0 ? "\u6CA1\u6709\u53D1\u51FA\u53BB\uFF1A\u8FD8\u6CA1\u6709\u8BBE\u7F6E\u597D\u7684\u804A\u5929\u6E20\u9053" : `\u5DF2\u53D1\u5230${channels.join("\u3001")}`;
7928
7927
  } catch (error) {
7929
7928
  result = `\u53D1\u9001\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`;