dsh-multigameassistant 2.3.0 → 2.3.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.
@@ -1,13 +1,18 @@
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
3
  convertRecord
4
- } from "./chunk-VBWSM7LF.js";
4
+ } from "./chunk-OCJFAT7J.js";
5
5
  import {
6
6
  writeFileAtomic
7
7
  } from "./chunk-RESS7WVY.js";
8
8
  import {
9
9
  BY_YOU,
10
+ DECISION_AREAS,
11
+ FORMER_AGENT_NAMES,
12
+ MAIN_AGENT_NAME,
10
13
  NOTIFY_CAPABILITY,
14
+ briefText,
15
+ isAgentNamed,
11
16
  isQuiet,
12
17
  parseRelay,
13
18
  parseTask,
@@ -20,7 +25,7 @@ import {
20
25
  threadMessage,
21
26
  threadReminder,
22
27
  threadsBetween
23
- } from "./chunk-7EFZ5KR6.js";
28
+ } from "./chunk-BB2T4JHF.js";
24
29
  import {
25
30
  external_exports
26
31
  } from "./chunk-6DSSLS7I.js";
@@ -749,12 +754,15 @@ function joined(turns, unfinished) {
749
754
 
750
755
  // packages/notify/lib/delegate.js
751
756
  var MAX_OUT = 4;
752
- var DELEGATOR = "\u52A9\u624B";
757
+ var DELEGATOR = MAIN_AGENT_NAME;
753
758
  var TIMEOUT_MS = 2 * 60 * 6e4;
754
759
  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`;
755
760
  var Args2 = external_exports.object({
756
761
  agent: external_exports.string().trim().min(1).max(40),
757
762
  task: external_exports.string().trim().min(1).max(8e3),
763
+ limits: external_exports.string().trim().max(2e3).nullish(),
764
+ allow: external_exports.array(external_exports.string().trim()).max(DECISION_AREAS.length).nullish(),
765
+ done_when: external_exports.string().trim().min(1).max(2e3),
758
766
  expecting: external_exports.string().trim().max(2e3).nullish()
759
767
  });
760
768
  function delegateTool(deps) {
@@ -771,17 +779,23 @@ function delegateTool(deps) {
771
779
  description: [
772
780
  "\u628A\u4E00\u4EF6\u4E8B\u4EA4\u7ED9\u53E6\u4E00\u4E2A agent \u53BB\u505A\u3002\u53EF\u4EE5\u4EA4\u7ED9\u8C01\u3001\u5404\u81EA\u505A\u4EC0\u4E48\uFF0C\u89C1\u7CFB\u7EDF\u63D0\u793A\u91CC\u7684\u300C\u56E2\u961F\u300D\u3002",
773
781
  "\u4EA4\u51FA\u53BB\u5C31\u8FD4\u56DE\uFF0C\u4E0D\u7B49\u5B83\u505A\u5B8C\uFF1A\u5B83\u5728\u81EA\u5DF1\u7684\u5BF9\u8BDD\u91CC\u505A\uFF0C\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",
774
- "task \u8981\u5199\u5B8C\u6574\uFF1A\u5BF9\u65B9\u770B\u4E0D\u5230\u4F60\u7684\u5BF9\u8BDD\uFF0C\u53EA\u770B\u5230 task\uFF08\u8981\u505A\u4EC0\u4E48\u3001\u5728\u54EA\u4E2A\u6E38\u620F\u6216\u811A\u672C\u3001\u505A\u5230\u54EA\u4E00\u6B65\u4E3A\u6B62\uFF09\u3002expecting \u5199\u4F60\u8981\u5B83\u4EA4\u56DE\u4EC0\u4E48\uFF08\u53EF\u9009\uFF09\u3002",
782
+ "\u5BF9\u65B9\u770B\u4E0D\u5230\u4F60\u7684\u5BF9\u8BDD\uFF0C\u53EA\u770B\u5230\u4F60\u5199\u7684\u8FD9\u51E0\u9879\uFF0C\u6240\u4EE5\u8981\u5199\u5B8C\u6574\uFF1B\u53EA\u5199\u8981\u4EC0\u4E48\u3001\u5230\u54EA\u4E3A\u6B62\uFF0C\u4E0D\u5199\u4E00\u6B65\u6B65\u600E\u4E48\u505A\u2014\u2014\u7528\u4EC0\u4E48\u5DE5\u5177\u3001\u600E\u4E48\u505A\u7531\u5BF9\u65B9\u51B3\u5B9A\uFF0C\u5B83\u6BD4\u4F60\u6E05\u695A\u81EA\u5DF1\u7684\u5DE5\u5177\u3002",
783
+ "task \u5199\u76EE\u6807\uFF1A\u8981\u505A\u6210\u4EC0\u4E48\u6837\uFF0C\u52A0\u4E0A\u4F60\u5DF2\u7ECF\u77E5\u9053\u7684\u60C5\u51B5\uFF08\u54EA\u4E2A\u6E38\u620F\u6216\u811A\u672C\u3001\u8FD0\u884C id\u3001\u7528\u6237\u7684\u539F\u8BDD\uFF09\u3002limits \u5199\u8FB9\u754C\uFF1A\u54EA\u4E9B\u4E0D\u80FD\u52A8\u3001\u505A\u5230\u54EA\u4E00\u6B65\u4E3A\u6B62\uFF08\u53EF\u9009\uFF09\u3002done_when \u5199\u5B8C\u6210\u6807\u51C6\uFF1A\u600E\u6837\u7B97\u505A\u5B8C\u3002expecting \u5199\u8981\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\uFF1A\u8FD0\u884C id\u3001\u65E5\u5FD7\u539F\u6587\u3001\u6539\u4E86\u54EA\u4E9B\u8BBE\u7F6E\u6216\u6587\u4EF6\u3001\u7ED3\u679C\u72B6\u6001\uFF08\u53EF\u9009\uFF09\u3002",
784
+ "\u60C5\u51B5\u4E0D\u660E\u3001\u6216\u8005\u8981\u505A\u6536\u4E0D\u56DE\u7684\u4E8B\uFF08\u5220\u3001\u88C5\u3001\u6539\u8BBE\u7F6E\uFF09\u65F6\uFF0C\u5148\u8BA9\u5B83\u67E5\u6E05\u695A\u4EA4\u56DE\uFF0C\u7531\u4F60\u51B3\u5B9A\u4EE5\u540E\u518D\u4EA4\u5B83\u53BB\u505A\u3002",
785
+ `\u4F1A\u7559\u4E0B\u6765\u7684\u6539\u52A8\uFF08${DECISION_AREAS.map((a) => `${a.id}\uFF1A${a.title}`).join("\uFF1B")}\uFF09\u9ED8\u8BA4\u4E0D\u76F4\u63A5\u505A\uFF1A\u505A\u8FD9\u7C7B\u6539\u52A8\u65F6\u8F6F\u4EF6\u5148\u8BB0\u6210\u5F85\u5B9A\u6539\u52A8\uFF0C\u7531\u63A5\u624B\u7684 agent \u51B3\u5B9A\uFF0C\u5B83\u62FF\u4E0D\u51C6\u65F6\u4F1A\u56DE\u5934\u95EE\u4F60\u3002\u7528\u6237\u5DF2\u7ECF\u660E\u786E\u8981\u505A\u7684\u90A3\u7C7B\uFF0C\u5199\u8FDB allow\uFF0C\u5C31\u76F4\u63A5\u505A\u3002`,
775
786
  `\u51E0\u4EF6\u4E92\u4E0D\u76F8\u5173\u7684\u4E8B\u53EF\u4EE5\u540C\u65F6\u4EA4\u51FA\u53BB\uFF0C\u4E00\u4E2A\u5BF9\u8BDD\u540C\u65F6\u6700\u591A ${MAX_OUT} \u4EF6\u3002\u5B83\u8981\u7528\u6237\u5BA1\u6279\u6216\u56DE\u7B54\u95EE\u9898\u65F6\u4F1A\u505C\u4E0B\u7B49\u7528\u6237\u3002`
776
787
  ].join(""),
777
788
  parameters: {
778
789
  type: "object",
779
790
  properties: {
780
- agent: { type: "string", description: "agent \u7684\u540D\u5B57\u6216 id\uFF0C\u4F8B\u5982\u300C\u6E38\u620F\u300D\u300C\u811A\u672C\u300D\u3002" },
781
- task: { type: "string", description: "\u8981\u5B83\u505A\u7684\u4E8B\uFF0C\u5199\u5B8C\u6574\u3002" },
782
- expecting: { type: "string", description: "\u8981\u5B83\u4EA4\u56DE\u4EC0\u4E48\uFF0C\u4F8B\u5982\u300C\u54EA\u4E9B\u6D3B\u52A8\u4ECA\u5929\u7ED3\u675F\uFF0C\u6CA1\u6709\u5C31\u8BF4\u6CA1\u6709\u300D\uFF08\u53EF\u9009\uFF09\u3002" }
791
+ 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" },
792
+ 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" },
793
+ 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" },
794
+ 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" },
795
+ done_when: { type: "string", description: "\u5B8C\u6210\u6807\u51C6\uFF1A\u600E\u6837\u7B97\u505A\u5B8C\uFF0C\u4F8B\u5982\u300C\u5217\u51FA\u4ECA\u5929\u7ED3\u675F\u7684\u6D3B\u52A8\uFF0C\u6CA1\u6709\u5C31\u8BF4\u6CA1\u6709\u300D\u3002" },
796
+ expecting: { type: "string", description: "\u8981\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\uFF1A\u8FD0\u884C id\u3001\u65E5\u5FD7\u539F\u6587\u3001\u6539\u4E86\u4EC0\u4E48\u3001\u7ED3\u679C\u72B6\u6001\uFF08\u53EF\u9009\uFF09\u3002" }
783
797
  },
784
- required: ["agent", "task"],
798
+ required: ["agent", "task", "done_when"],
785
799
  additionalProperties: false
786
800
  },
787
801
  output: { schema: {}, render: (_args, value) => [{ type: "text", text: HANDED(value.agent) }] },
@@ -790,22 +804,28 @@ function delegateTool(deps) {
790
804
  const parsed = Args2.safeParse(args ?? {});
791
805
  if (!parsed.success)
792
806
  throw new Error(`\u53C2\u6570\u65E0\u6548\uFF1A${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}`);
793
- const { agent: wanted, task, expecting } = parsed.data;
807
+ const { agent: wanted, task: goal, limits, allow, done_when: doneWhen, expecting } = parsed.data;
808
+ const unknownKinds = (allow ?? []).filter((kind) => !DECISION_AREAS.some((a) => a.id === kind));
809
+ if (unknownKinds.length > 0)
810
+ throw new Error(`allow \u91CC\u6CA1\u6709\u8FD9\u4E9B\u7C7B\u522B\uFF1A${unknownKinds.join("\u3001")}\u3002\u53EF\u4EE5\u5199\uFF1A${DECISION_AREAS.map((a) => a.id).join("\u3001")}`);
811
+ const task = briefText(goal, { limits: limits ?? void 0, doneWhen, allow: allow ?? void 0 });
794
812
  const parent = exec.agent?.session.id;
795
813
  if (parent === void 0)
796
814
  throw new Error("\u53EA\u80FD\u5728\u4F1A\u8BDD\u91CC\u4EA4\u51FA\u53BB");
797
815
  const caller = deps.agentOf?.(parent);
798
816
  const agents = deps.agents();
799
- const agent = agents.find((a) => a.name === wanted || a.id === wanted);
817
+ const agent = agents.find((a) => isAgentNamed(a, wanted));
800
818
  if (agent === void 0)
801
819
  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"}`);
802
820
  const conversations = deps.conversations();
803
821
  if (conversations === void 0)
804
822
  throw new Error("agent \u670D\u52A1\u8FD8\u6CA1\u6709\u51C6\u5907\u597D");
823
+ if (agent.id === caller?.id || caller === void 0 && agent.name === DELEGATOR) {
824
+ 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`);
825
+ }
805
826
  if ((out.get(parent) ?? 0) >= MAX_OUT)
806
827
  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`);
807
- const self = agent.id === caller?.id;
808
- const refusal = self ? void 0 : conversations.handOffRefusal?.(parent, agent.id, caller?.id ?? "", agent.name);
828
+ const refusal = conversations.handOffRefusal?.(parent, agent.id, caller?.id ?? "", agent.name);
809
829
  if (refusal !== void 0)
810
830
  throw new Error(refusal);
811
831
  out.set(parent, (out.get(parent) ?? 0) + 1);
@@ -821,7 +841,7 @@ function delegateTool(deps) {
821
841
  ...expecting ? { expecting } : {},
822
842
  signal: AbortSignal.timeout(TIMEOUT_MS),
823
843
  from: { sessionId: parent, callId, asker: by, ...caller === void 0 ? {} : { agent: caller.id } },
824
- relay: !self,
844
+ relay: true,
825
845
  ...relayed === void 0 ? {} : { relayed }
826
846
  }).catch(() => {
827
847
  }).finally(() => settle(parent));
@@ -899,7 +919,8 @@ function threadsTool(deps) {
899
919
  const all = deps.list();
900
920
  if (parsed.data.id == null) {
901
921
  const who = parsed.data.with;
902
- const about = who == null ? all : all.filter((h) => h.by === who || h.to === who || h.by === deps.name(who) || deps.name(h.to) === who);
922
+ const agentId = (x) => Object.keys(FORMER_AGENT_NAMES).find((id) => isAgentNamed({ id, name: deps.name(id) }, x)) ?? x;
923
+ const about = who == null ? all : all.filter((h) => agentId(h.by) === agentId(who) || agentId(h.to) === agentId(who));
903
924
  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`);
904
925
  }
905
926
  const found = all.find((h) => h.id === parsed.data.id);
@@ -975,17 +996,17 @@ var Notify = class {
975
996
  notices() {
976
997
  return this.#history.map(shown);
977
998
  }
978
- /** Notices of the last day 助手 has not been told about yet (the latest few), oldest first. */
979
- untold() {
999
+ /** Notices of the last day an agent (助手: `main`) has not been told about yet (the latest few), oldest first. */
1000
+ untold(agent = "main") {
980
1001
  const since = this.#now() - REPLY_WINDOW_MS;
981
- return this.#history.filter((n) => n.told !== true && n.at >= since).slice(-TELL_AT_MOST).map(shown);
1002
+ return this.#history.filter((n) => n.told !== true && n.at >= since && (n.agent ?? "main") === agent).slice(-TELL_AT_MOST).map(shown);
982
1003
  }
983
- /** 助手 has been told about these (and so no longer needs the older ones). */
984
- markTold(ids) {
1004
+ /** The agent has been told about these (and so no longer needs its older ones). */
1005
+ markTold(ids, agent = "main") {
985
1006
  const last = Math.max(-1, ...ids.map((id) => this.#history.findIndex((n) => n.id === id)));
986
1007
  if (last < 0)
987
1008
  return;
988
- this.#history = this.#history.map((n, i) => i <= last && n.told !== true ? { ...n, told: true } : n);
1009
+ this.#history = this.#history.map((n, i) => i <= last && n.told !== true && (n.agent ?? "main") === agent ? { ...n, told: true } : n);
989
1010
  this.#saveHistory();
990
1011
  }
991
1012
  #changeNotice(id, change) {
@@ -1037,7 +1058,8 @@ var Notify = class {
1037
1058
  at: this.#now(),
1038
1059
  actions: (notice.actions ?? []).map((a) => ({ id: a.id, label: a.label, ...a.style === void 0 ? {} : { style: a.style } })),
1039
1060
  channels: reached,
1040
- ...notice.image === void 0 ? {} : { image: true }
1061
+ ...notice.image === void 0 ? {} : { image: true },
1062
+ ...notice.agent === void 0 ? {} : { agent: notice.agent }
1041
1063
  };
1042
1064
  this.#history = [...this.#history.filter((n) => n.id !== notice.id), item].slice(-KEEP_HISTORY);
1043
1065
  this.#saveHistory();
@@ -1080,7 +1102,7 @@ var Notify = class {
1080
1102
  /** Who picked an action, for people: 你(软件), 你(QQ), 助手. */
1081
1103
  #actorName(actor) {
1082
1104
  if (actor.channel === "agent")
1083
- return actor.name ?? "\u52A9\u624B";
1105
+ return actor.name ?? MAIN_AGENT_NAME;
1084
1106
  if (actor.channel === "app")
1085
1107
  return "\u4F60\uFF08\u8F6F\u4EF6\uFF09";
1086
1108
  return `${actor.name ?? "\u4F60"}\uFF08${this.channelName(actor.channel)}\uFF09`;
@@ -1365,7 +1387,7 @@ function approvalText(request) {
1365
1387
  function questionText(request) {
1366
1388
  const first = request.questions[0];
1367
1389
  const more = request.questions.length > 1 ? `\uFF08\u5171 ${request.questions.length} \u4E2A\u95EE\u9898\uFF0C\u7B54\u5B8C\u4E00\u4E2A\u53D1\u4E0B\u4E00\u4E2A\uFF09` : "";
1368
- 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");
1390
+ 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");
1369
1391
  }
1370
1392
  function describeQuestion(item) {
1371
1393
  const options = item.options ?? [];
@@ -1373,7 +1395,7 @@ function describeQuestion(item) {
1373
1395
  }
1374
1396
 
1375
1397
  // packages/notify/lib/mirror.js
1376
- var MAIN_NAME = "\u52A9\u624B";
1398
+ var MAIN_NAME = MAIN_AGENT_NAME;
1377
1399
  var KEEP_SEEN = 200;
1378
1400
  var HomeMirror = class {
1379
1401
  #deps;
@@ -1564,21 +1586,24 @@ var AdgNotify = class extends Service {
1564
1586
  resolved: (id, outcome) => notify.approvalResolved(id, outcome)
1565
1587
  });
1566
1588
  const agentOf = (sessionId) => scoped.adgGateway.agentOfSession(sessionId);
1567
- const agentName = (id) => id === MAIN ? "\u52A9\u624B" : scoped.adgGateway.roles.list().find((r) => r.id === id)?.name ?? id;
1568
- scoped.adgGateway.agentPart("adg-notify agent_delegate", (agent) => agent.tools.register(delegateTool({ agents: () => [{ id: MAIN, name: "\u52A9\u624B" }, ...scoped.adgGateway.roles.list()], conversations, agentOf })));
1589
+ const agentName = (id) => id === MAIN ? MAIN_AGENT_NAME : scoped.adgGateway.roles.list().find((r) => r.id === id)?.name ?? id;
1590
+ 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 })));
1569
1591
  scoped.adgGateway.agentPart("adg-notify agent_message", (agent) => agent.tools.register(messageTool({ desk: () => conversations()?.desk, agentOf })));
1570
1592
  scoped.adgGateway.agentPart("adg-notify agent_threads", (agent) => agent.tools.register(threadsTool({ list: () => scoped.adgGateway.handOffs.all(), name: agentName })));
1571
- scoped.adgGateway.agentPart("adg-notify notice_act", (agent) => agent.tools.register(noticeActTool(notify, gateway.roles.list().find((r) => r.id === MAIN)?.name ?? "\u52A9\u624B")));
1593
+ 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)));
1572
1594
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1573
1595
  scoped.adgGateway.agentPart("adg-notify notices note", (agent) => agent.on("agent/pre-step", (async (payload, next) => {
1574
1596
  const decision = await next();
1575
1597
  if (decision.kind !== "enter" || payload.step !== 1 || payload.signal.aborted)
1576
1598
  return decision;
1577
1599
  try {
1578
- const items = notify.untold();
1579
- if (items.length === 0 || payload.agent.session.id !== await gateway.home(MAIN))
1600
+ const home = gateway.homes.agentOf(payload.agent.session.id);
1601
+ if (home === void 0)
1602
+ return decision;
1603
+ const items = notify.untold(home);
1604
+ if (items.length === 0)
1580
1605
  return decision;
1581
- notify.markTold(items.map((n) => n.id));
1606
+ notify.markTold(items.map((n) => n.id), home);
1582
1607
  return { ...decision, messages: [...decision.messages, noticesMessage(noticesNote(items, timeZone))] };
1583
1608
  } catch (error) {
1584
1609
  log.warn(`notices note for ${payload.agent.session.id}: ${error instanceof Error ? error.message : String(error)}`);
package/lib/emulator.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  EMULATORS_CAPABILITY,
11
11
  EmulatorSettings
12
- } from "./chunk-7EFZ5KR6.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-VG32XPZH.js";
5
+ } from "./chunk-SMXJWLAZ.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-VBWSM7LF.js";
16
- import "./chunk-Y3ZZBBLV.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-7EFZ5KR6.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-TXW3NMBH.js";
9
+ } from "./chunk-7UJ3LK3G.js";
10
10
  import {
11
11
  finalText,
12
12
  sessionConversations
13
- } from "./chunk-VG32XPZH.js";
14
- import "./chunk-VBWSM7LF.js";
15
- import "./chunk-Y3ZZBBLV.js";
13
+ } from "./chunk-SMXJWLAZ.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-7EFZ5KR6.js";
31
+ } from "./chunk-BB2T4JHF.js";
32
32
  import {
33
33
  external_exports
34
34
  } from "./chunk-6DSSLS7I.js";
@@ -5953,25 +5953,30 @@ function gameTools(deps) {
5953
5953
  description: [
5954
5954
  "\u6E38\u620F\u9875\u300C\u65E5\u5E38 \xB7 \u5468\u5E38\u300D\u7684\u6E05\u5355\uFF1Aaction=list \u770B\u6BCF\u4E00\u9879\u8FD9\u4E00\u671F\uFF08\u4ECA\u5929\u3001\u8FD9\u5468\u3001\u8FD9\u4E00\u671F\u5468\u671F\u73A9\u6CD5\uFF09\u505A\u6CA1\u505A\u5B8C\u3001\u8C01\u52FE\u7684\u3001\u9760\u4EC0\u4E48\u81EA\u52A8\u52FE\u3001\u4EC0\u4E48\u65F6\u5019\u91CD\u7F6E\uFF1Baction=set \u52FE\u4E0A\u6216\u53D6\u6D88\u4E00\u9879\u3002",
5955
5955
  "\u811A\u672C\u65E5\u5FD7\u6216\u4EFB\u52A1\u6210\u529F\u80FD\u8BC1\u660E\u7684\u9879\u76EE\u63D2\u4EF6\u4F1A\u81EA\u5DF1\u52FE\uFF0C\u4E5F\u4F1A\u56DE\u5934\u8BFB\u8FD9\u4E00\u671F\u65E9\u4E9B\u65F6\u5019\u7684\u8FD0\u884C\u8BB0\u5F55\u8865\u4E0A\uFF08list \u4E4B\u524D\u5DF2\u7ECF\u8BFB\u8FC7\u4E00\u904D\uFF09\u2014\u2014\u6240\u4EE5\u5148 list\uFF0C\u6CA1\u52FE\u4E0A\u7684\u518D\u67E5\u539F\u56E0\uFF1A\u811A\u672C\u5305\u6CA1\u5199 routines\u3001log \u5199\u7684\u4E0D\u662F\u65E5\u5FD7\u91CC\u771F\u5B9E\u7684\u539F\u6587\u3001\u6216\u8005\u786E\u5B9E\u6CA1\u505A\u3002",
5956
- "set \u53EA\u5728\u4F60\u4EB2\u773C\u770B\u5230\u5B8C\u6210\u8BC1\u636E\u65F6\u7528\uFF08\u8FD0\u884C\u65E5\u5FD7\u91CC\u7684\u539F\u6587\u3001\u6E38\u620F\u753B\u9762\u4E0A\u7684\u5B8C\u6210\u6587\u5B57\uFF09\uFF0Cevidence \u5199\u539F\u6587\u548C\u51FA\u5904\uFF1B\u9875\u9762\u4E0A\u4F1A\u663E\u793A\u6210\u300Cagent \u8BB0\u7684\u300D\uFF0C\u548C\u7528\u6237\u81EA\u5DF1\u52FE\u7684\u5206\u5F00\u3002\u4E0D\u8981\u7528\u6D4F\u89C8\u5668\u70B9\u6E38\u620F\u9875\u3001\u6216\u8C03\u7528\u63A5\u53E3\u53BB\u52FE\uFF0C\u90A3\u6837\u4F1A\u88AB\u5F53\u6210\u7528\u6237\u52FE\u7684\u3002"
5956
+ "set \u53EA\u5728\u4F60\u4EB2\u773C\u770B\u5230\u5B8C\u6210\u8BC1\u636E\u65F6\u7528\uFF08\u8FD0\u884C\u65E5\u5FD7\u91CC\u7684\u539F\u6587\u3001\u6E38\u620F\u753B\u9762\u4E0A\u7684\u5B8C\u6210\u6587\u5B57\uFF09\uFF0Cevidence \u5199\u539F\u6587\u548C\u51FA\u5904\uFF1B\u9875\u9762\u4E0A\u4F1A\u663E\u793A\u6210\u300Cagent \u8BB0\u7684\u300D\uFF0C\u548C\u7528\u6237\u81EA\u5DF1\u52FE\u7684\u5206\u5F00\u3002\u4E0D\u8981\u7528\u6D4F\u89C8\u5668\u70B9\u6E38\u620F\u9875\u3001\u6216\u8C03\u7528\u63A5\u53E3\u53BB\u52FE\uFF0C\u90A3\u6837\u4F1A\u88AB\u5F53\u6210\u7528\u6237\u52FE\u7684\u3002",
5957
+ "\u7528\u6237\u4E0D\u80FD\u5728\u9875\u9762\u4E0A\u81EA\u5DF1\u52A0\u65E5\u5E38\u5468\u5E38\uFF0C\u8981\u52A0\u90FD\u7531 agent \u52A0\uFF1A\u811A\u672C\u505A\u7684\u5199\u8FDB\u90A3\u4E2A\u811A\u672C\u7684\u811A\u672C\u5305 routines\uFF08pack_propose\uFF0Clog \u5199\u65E5\u5FD7\u91CC\u505A\u5B8C\u65F6\u7684\u539F\u6587\uFF09\uFF0C\u8DD1\u5B8C\u4F1A\u81EA\u52A8\u52FE\uFF1Baction=add \u53EA\u52A0\u6CA1\u6709\u811A\u672C\u505A\u3001\u53EA\u80FD\u624B\u52A8\u52FE\u7684\uFF08name\u3001period\uFF09\uFF0C\u540C\u540D\u7684\u4E0D\u4F1A\u91CD\u590D\u52A0\u3002"
5957
5958
  ].join(""),
5958
5959
  properties: {
5959
5960
  game: GAME,
5960
- action: { type: "string", enum: ["list", "set"], description: "list\uFF1A\u770B\u6E05\u5355\uFF1Bset\uFF1A\u52FE\u4E0A\u6216\u53D6\u6D88\u4E00\u9879\u3002" },
5961
+ action: { type: "string", enum: ["list", "set", "add"], description: "list\uFF1A\u770B\u6E05\u5355\uFF1Bset\uFF1A\u52FE\u4E0A\u6216\u53D6\u6D88\u4E00\u9879\uFF1Badd\uFF1A\u52A0\u4E00\u9879\u53EA\u80FD\u624B\u52A8\u52FE\u7684\u3002" },
5961
5962
  routine: { type: "string", description: "action=set\uFF1A\u65E5\u5E38\u7684 id \u6216\u540D\u79F0\uFF08\u7167 list \u91CC\u7684\u5199\uFF09\u3002" },
5962
5963
  done: { type: "boolean", description: "action=set\uFF1Atrue \u52FE\u4E0A\uFF08\u9ED8\u8BA4\uFF09\uFF0Cfalse \u53D6\u6D88\u3002" },
5963
- evidence: { type: "string", description: "action=set \u4E14 done=true\uFF1A\u770B\u5230\u7684\u5B8C\u6210\u8BC1\u636E\u539F\u6587\u548C\u51FA\u5904\uFF0C\u4F8B\u5982\u300CMAA \u8FD0\u884C run-\u2026 \u65E5\u5FD7\uFF1A\u5B8C\u6210\u4EFB\u52A1: \u57FA\u5EFA\u6362\u73ED\u300D\u6216\u300C\u6E38\u620F\u753B\u9762\uFF1A\u6BCF\u65E5\u5B9E\u8BAD 500/500\u300D\u3002" }
5964
+ evidence: { type: "string", description: "action=set \u4E14 done=true\uFF1A\u770B\u5230\u7684\u5B8C\u6210\u8BC1\u636E\u539F\u6587\u548C\u51FA\u5904\uFF0C\u4F8B\u5982\u300CMAA \u8FD0\u884C run-\u2026 \u65E5\u5FD7\uFF1A\u5B8C\u6210\u4EFB\u52A1: \u57FA\u5EFA\u6362\u73ED\u300D\u6216\u300C\u6E38\u620F\u753B\u9762\uFF1A\u6BCF\u65E5\u5B9E\u8BAD 500/500\u300D\u3002" },
5965
+ name: { type: "string", description: "action=add\uFF1A\u6E38\u620F\u91CC\u7684\u53EB\u6CD5\uFF0C\u4F8B\u5982\u300C\u6BCF\u65E5\u59D4\u6258\u300D\u300C\u5468\u672C\u300D\uFF0C40 \u5B57\u4EE5\u5185\u3002" },
5966
+ period: { type: "string", enum: ["daily", "weekly"], description: "action=add\uFF1Adaily \u65E5\u5E38\uFF08\u6BCF\u5929\u91CD\u7F6E\uFF09\uFF0Cweekly \u5468\u5E38\uFF08\u6BCF\u5468\u91CD\u7F6E\uFF09\u3002" }
5964
5967
  },
5965
5968
  required: ["game", "action"],
5966
5969
  kind: "other",
5967
- title: (a) => `${a["action"] === "set" ? "\u52FE\u9009\u65E5\u5E38" : "\u65E5\u5E38\u6E05\u5355"}\uFF1A${String(a["game"] ?? "")}`,
5970
+ title: (a) => `${a["action"] === "set" ? "\u52FE\u9009\u65E5\u5E38" : a["action"] === "add" ? "\u6DFB\u52A0\u65E5\u5E38" : "\u65E5\u5E38\u6E05\u5355"}\uFF1A${String(a["game"] ?? "")}`,
5968
5971
  execute: async (args) => {
5969
5972
  const a = parse(external_exports.object({
5970
5973
  game: external_exports.string(),
5971
- action: external_exports.enum(["list", "set"]),
5974
+ action: external_exports.enum(["list", "set", "add"]),
5972
5975
  routine: external_exports.string().trim().min(1).max(80).nullish(),
5973
5976
  done: external_exports.boolean().nullish(),
5974
- evidence: external_exports.string().trim().max(300).nullish()
5977
+ evidence: external_exports.string().trim().max(300).nullish(),
5978
+ name: external_exports.string().trim().min(1).max(40).nullish(),
5979
+ period: external_exports.enum(["daily", "weekly"]).nullish()
5975
5980
  }), args);
5976
5981
  const game = known(a.game);
5977
5982
  const PERIOD = { daily: "\u65E5\u5E38", weekly: "\u5468\u5E38", event: "\u5468\u671F\u73A9\u6CD5" };
@@ -5991,6 +5996,12 @@ function gameTools(deps) {
5991
5996
  next: status.routines.length === 0 ? "\u8FD9\u4E2A\u6E38\u620F\u8FD8\u6CA1\u6709\u65E5\u5E38\u5468\u5E38\uFF1A\u6E38\u620F\u5305\u6216\u73A9\u5B83\u7684\u811A\u672C\u5305\u91CC\u5199 routines \u624D\u4F1A\u5217\u51FA\u6765\u3002" : "\u6CA1\u52FE\u4E0A\u7684\u9879\u76EE\uFF1A\u5148\u770B auto \u91CC\u7684\u65E5\u5FD7\u539F\u6587\u5728\u8FD9\u4E00\u671F\u7684\u8FD0\u884C\u65E5\u5FD7\u91CC\u6709\u6CA1\u6709\uFF08script_run_log \u641C\u7D22\uFF09\uFF0C\u6709\u5C31\u662F\u63D2\u4EF6\u6CA1\u8BFB\u5230\uFF0C\u544A\u8BC9\u7528\u6237\uFF1B\u6CA1\u6709\u5C31\u662F\u8FD8\u6CA1\u505A\u6216\u811A\u672C\u5305\u7684 log \u5199\u5F97\u4E0D\u5BF9\u3002"
5992
5997
  };
5993
5998
  }
5999
+ if (a.action === "add") {
6000
+ if (a.name == null || a.period == null)
6001
+ throw new Error("action=add \u8981\u5199 name\uFF08\u6E38\u620F\u91CC\u7684\u53EB\u6CD5\uFF09\u548C period\uFF08daily \u6216 weekly\uFF09");
6002
+ const routine2 = await deps.addRoutine(game.id, a.name, a.period);
6003
+ return { routine: view(routine2), next: `\u52A0\u4E0A\u4E86\uFF0C\u6E38\u620F\u9875\u7684\u300C${PERIOD[a.period]}\u300D\u91CC\u80FD\u770B\u5230\uFF1B\u5B83\u53EA\u80FD\u624B\u52A8\u52FE\uFF08\u4F60\u770B\u5230\u5B8C\u6210\u8BC1\u636E\u65F6\u7528 set \u52FE\uFF09\u3002` };
6004
+ }
5994
6005
  if (a.routine == null)
5995
6006
  throw new Error("action=set \u8981\u5199 routine\uFF08\u7167 list \u91CC\u7684 id \u6216\u540D\u79F0\uFF09");
5996
6007
  const done = a.done ?? true;
@@ -6227,8 +6238,9 @@ var ConfigSchema = external_exports.object({
6227
6238
  });
6228
6239
  var GAME_ROLE = {
6229
6240
  id: "games",
6230
- name: "\u6E38\u620F",
6241
+ name: "\u6E38\u620F\u52A9\u624B",
6231
6242
  description: "\u8BFB\u6E38\u620F\u6D3B\u52A8\u548C\u8D44\u8BAF\u3001\u5199\u65E5\u62A5\u3001\u6DFB\u52A0\u6E38\u620F",
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",
6232
6244
  order: 20,
6233
6245
  titles: ["\u6E38\u620F\u4FE1\u606F", "\u6E38\u620F\u8D44\u8BAF", "\u6DFB\u52A0\u6E38\u620F", "\u65E5\u62A5"],
6234
6246
  // Games and their screens, and what scripts ran (for the daily report); no installing, runs or pipelines.
@@ -6238,7 +6250,7 @@ var GAME_ROLE = {
6238
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"],
6239
6251
  duty: [
6240
6252
  "# \u4F60\u7684\u89D2\u8272\uFF1A\u6E38\u620F",
6241
- "\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",
6242
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"
6243
6255
  ].join("\n")
6244
6256
  };
@@ -6308,6 +6320,12 @@ var AdgGameIntel = class extends Service {
6308
6320
  daily.start();
6309
6321
  })();
6310
6322
  ctx.effect(() => () => this.daily.stop(), "adg-game-intel daily report");
6323
+ ctx.inject(["adgGateway"], (scoped) => {
6324
+ scoped.effect(() => {
6325
+ scoped.adgGateway.skillScope.resolveGames(this.gameIdOf);
6326
+ return () => scoped.adgGateway.skillScope.resolveGames(() => void 0);
6327
+ }, "adg-game-intel game names for skills");
6328
+ });
6311
6329
  ctx.inject(["skills", "adgGateway"], (scoped) => {
6312
6330
  const disposers = [];
6313
6331
  void (async () => {
@@ -6354,6 +6372,10 @@ var AdgGameIntel = class extends Service {
6354
6372
  await this.ready;
6355
6373
  return this.setRoutine(game, routine, done, "agent", evidence);
6356
6374
  },
6375
+ addRoutine: async (game, name, period) => {
6376
+ await this.ready;
6377
+ return this.addRoutine(game, name, period);
6378
+ },
6357
6379
  recordPools: async (game, pools) => {
6358
6380
  await this.ready;
6359
6381
  this.game(game);
@@ -6707,7 +6729,16 @@ var AdgGameIntel = class extends Service {
6707
6729
  const links = this.calendar.links(g.manifest.id);
6708
6730
  return links.length === 0 ? g : { ...g, manifest: { ...g.manifest, sources: [...g.manifest.sources, ...links.map((l) => ({ id: l.id, name: l.name, homepage: l.url }))] } };
6709
6731
  });
6732
+ this.ctx.get("adgGateway")?.skillScope.resolveGames(this.gameIdOf);
6710
6733
  }
6734
+ /** The game a key names, by its id, name or an alias (any case); undefined when no game is known by it. */
6735
+ gameIdOf = (key) => {
6736
+ const k = key.trim().toLowerCase();
6737
+ if (k === "")
6738
+ return void 0;
6739
+ const named = (g) => [g.manifest.id, g.manifest.name, ...g.manifest.aliases].some((n) => n.toLowerCase() === k);
6740
+ return (this.games.find(named) ?? this.allGames.find(named))?.manifest.id;
6741
+ };
6711
6742
  /** Keep a page about a game as a source and have the agent read it now. @returns its id and the reading session. */
6712
6743
  async addLink(gameId, url, name) {
6713
6744
  this.game(gameId);
@@ -7153,6 +7184,16 @@ var AdgGameIntel = class extends Service {
7153
7184
  * the game page (`user`), or an agent that saw it done (`agent`, with what it
7154
7185
  * saw). Found by id or by name.
7155
7186
  */
7187
+ /** A hand-ticked 日常 / 周常 of the game's own, added by an agent (game_routine add; the page has no way to add one by hand). */
7188
+ async addRoutine(gameId, name, period) {
7189
+ const { manifest } = this.game(gameId);
7190
+ const same = this.routineDefs(manifest, this.scriptsOf(gameId)).find((r) => r.name === name.trim());
7191
+ if (same !== void 0)
7192
+ throw new Error(`\u5DF2\u7ECF\u6709\u300C${same.name}\u300D\uFF08${same.id}\uFF09\u4E86\uFF0C\u4E0D\u7528\u518D\u52A0`);
7193
+ const own = await this.routines.addOwn(gameId, name.trim(), period, this.clock.now());
7194
+ this.changed(gameId);
7195
+ return this.routineInfo(manifest, this.scriptsOf(gameId)).routines.find((r) => r.id === own.id);
7196
+ }
7156
7197
  async setRoutine(gameId, routine, done, by = "user", detail) {
7157
7198
  const { manifest } = this.game(gameId);
7158
7199
  const defs = this.routineDefs(manifest, this.scriptsOf(gameId));
@@ -7844,30 +7885,29 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
7844
7885
  }));
7845
7886
  }
7846
7887
  /**
7847
- * The agent's summary of the recent events (just started, ending soon,
7848
- * starting soon), in a session of its own. @returns undefined when the
7849
- * 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).
7850
7894
  */
7851
7895
  async summarize() {
7852
7896
  const settings = this.calendar.settings.report;
7853
- const sessions = this.ctx.get("sessionController");
7854
- if (!settings.ai || sessions === void 0)
7897
+ const gateway = this.ctx.get("adgGateway");
7898
+ if (!settings.ai || gateway === void 0)
7855
7899
  return void 0;
7856
- const now = this.clock.now();
7857
- const digest = recentDigest(this.reportGames(), this.calendar.list(), settings, now);
7900
+ const digest = recentDigest(this.reportGames(), this.calendar.list(), settings, this.clock.now());
7858
7901
  if (digest === void 0)
7859
7902
  return void 0;
7860
- const local = wallClock(now, Intl.DateTimeFormat().resolvedOptions().timeZone);
7861
- 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");
7862
7909
  try {
7863
- const work = await conversations.prepareTask(GAME_ROLE.id, `\u65E5\u62A5\uFF1A${local.month}\u6708${local.day}\u65E5`);
7864
- const prompt = [
7865
- "\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",
7866
- "\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",
7867
- "",
7868
- digest
7869
- ].join("\n");
7870
- 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));
7871
7911
  return answer.length === 0 ? void 0 : answer;
7872
7912
  } catch (error) {
7873
7913
  this.log.warn(`daily report: the agent summary failed, sending the plain list: ${error instanceof Error ? error.message : String(error)}`);
@@ -7882,7 +7922,7 @@ ${JSON.stringify({ id, name: wanted, sources: [] }, null, 2)}
7882
7922
  let channels = [];
7883
7923
  let result;
7884
7924
  try {
7885
- 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" });
7886
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")}`;
7887
7927
  } catch (error) {
7888
7928
  result = `\u53D1\u9001\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`;
package/lib/gateway.js CHANGED
@@ -23,10 +23,10 @@ import {
23
23
  pluginVersion,
24
24
  streamFacts,
25
25
  userSkills
26
- } from "./chunk-VBWSM7LF.js";
27
- import "./chunk-Y3ZZBBLV.js";
26
+ } from "./chunk-OCJFAT7J.js";
27
+ import "./chunk-4NR36PKL.js";
28
28
  import "./chunk-RESS7WVY.js";
29
- import "./chunk-7EFZ5KR6.js";
29
+ import "./chunk-BB2T4JHF.js";
30
30
  import "./chunk-6DSSLS7I.js";
31
31
  import "./chunk-2UFLGPDY.js";
32
32
  export {
package/lib/guard.js CHANGED
@@ -1,7 +1,7 @@
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
3
  GUARD_CAPABILITY
4
- } from "./chunk-7EFZ5KR6.js";
4
+ } from "./chunk-BB2T4JHF.js";
5
5
  import "./chunk-6DSSLS7I.js";
6
6
  import "./chunk-2UFLGPDY.js";
7
7
 
@@ -19,7 +19,7 @@ var APP_DATA = "_app_data";
19
19
  var APP_SETTINGS = "_app_settings";
20
20
  var APP_ENTRIES = /* @__PURE__ */ new Set([APP_FILES, APP_DATA, APP_SETTINGS]);
21
21
  var isAppEntry = (scriptId) => APP_ENTRIES.has(scriptId);
22
- var FILE_TOOLS = /* @__PURE__ */ new Set(["write", "edit", "multi_edit", "str_replace_editor", "str_replace_based_edit_tool", "apply_patch", "notebook_edit"]);
22
+ var FILE_TOOLS = /* @__PURE__ */ new Set(["write", "edit", "multi_edit", "str_replace_editor", "str_replace_based_edit_tool", "apply_patch", "notebook_edit", "history_export"]);
23
23
  var SHELL_TOOLS = /* @__PURE__ */ new Set(["pwsh", "bash", "powershell", "shell", "cmd"]);
24
24
  var CODE_TOOLS = /* @__PURE__ */ new Set(["run_code"]);
25
25
  var AGENT_TOOLS = /* @__PURE__ */ new Set(["subagent"]);