dsh-multigameassistant 2.2.3 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cordis.patch.yml CHANGED
@@ -1,4 +1,4 @@
1
- # dsh-multigameassistant 2.2.3
1
+ # dsh-multigameassistant 2.3.1
2
2
  # dsh-multigameassistant: the app's plugins (packages/bundle/cordis.patch.yml, each @adg/<plugin> as dsh-multigameassistant/<plugin>)
3
3
  # sharing the dsh with the person's other chats, and the app's agent preset (dsh's standard one with the app's
4
4
  # tools and prompts, and compaction as 设置 → 对话压缩 says). No row of dsh is restated.
@@ -51,9 +51,13 @@
51
51
  - id: adg-analyzer
52
52
  name: 'dsh-multigameassistant/analyzer'
53
53
 
54
- # M2: the agent may not change script files without the user's grant.
54
+ # M2: the agent may not change script files without the user's grant, nor the
55
+ # app's own program, data and settings at all (dsh's profiles: its plugins, this guard).
55
56
  - id: adg-guard
56
57
  name: 'dsh-multigameassistant/guard'
58
+ config:
59
+ settingsDirs:
60
+ - !!js "dshHomePath('profiles')"
57
61
 
58
62
  # M3: incidents while scripts run (error rules, failures, stalls,
59
63
  # overtime), L0 recovery from the pack, screenshots; the `monitor` capability.
@@ -182,12 +186,9 @@
182
186
  - id: skill-filesystem
183
187
  name: '@deepseek-ai/dsh-skill-filesystem'
184
188
  config:
185
- # The app's agents read their own skills only, not the folders other agents on the machine share
186
- # (~/.agents/skills, ~/.dsh/skills, a working folder's .agents/skills or .dsh/skills); dsh's bundled ones stay.
189
+ # The app's agents read the app's own skills only: not the folders other agents on the machine share
190
+ # (~/.agents/skills, ~/.dsh/skills, a working folder's .agents/skills or .dsh/skills), nor dsh's own.
187
191
  includeDefaultRoots: false
188
- bundledSkillDir: !!js "process.env.DSH_BUNDLED_SKILL_DIR || undefined"
189
- customSkillDirs:
190
- - !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
191
192
  - id: tool-skill
192
193
  name: '@deepseek-ai/dsh-tool-skill'
193
194
  - id: command-goal
@@ -339,10 +340,9 @@
339
340
  - id: skill-filesystem
340
341
  name: '@deepseek-ai/dsh-skill-filesystem'
341
342
  config:
342
- # The app's agents read their own skills only, not the folders other agents on the machine share
343
- # (~/.agents/skills, ~/.dsh/skills, a working folder's .agents/skills or .dsh/skills); dsh's bundled ones stay.
343
+ # The app's agents read the app's own skills only: not the folders other agents on the machine share
344
+ # (~/.agents/skills, ~/.dsh/skills, a working folder's .agents/skills or .dsh/skills), nor dsh's own.
344
345
  includeDefaultRoots: false
345
- bundledSkillDir: !!js "process.env.DSH_BUNDLED_SKILL_DIR || undefined"
346
346
  - id: tool-skill
347
347
  name: '@deepseek-ai/dsh-tool-skill'
348
348
  - id: command-goal
package/lib/analyzer.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  discoverMcp,
4
4
  discoverSkills,
5
5
  mcpEndpoints
6
- } from "./chunk-YTIR5JW4.js";
6
+ } from "./chunk-KW36B7DT.js";
7
7
  import {
8
8
  probeProject
9
9
  } from "./chunk-B4UT4NYH.js";
@@ -11,20 +11,24 @@ import {
11
11
  MANIFEST_FILE,
12
12
  SKILL_FILE,
13
13
  guideIssues,
14
+ isScriptLauncher,
15
+ launchCommand,
14
16
  parseJsonc,
15
17
  parseManifest,
18
+ patternIssues,
16
19
  require_dist,
20
+ strayKeys,
17
21
  stripJsonc
18
- } from "./chunk-RGEGJH6R.js";
19
- import "./chunk-A6YQRWHZ.js";
20
- import "./chunk-6NJSSOB6.js";
21
- import "./chunk-KMVQK5CI.js";
22
+ } from "./chunk-C7X2KJ5C.js";
23
+ import "./chunk-4QXRDWGS.js";
24
+ import "./chunk-QSETYM2Y.js";
25
+ import "./chunk-M7GNYL5B.js";
22
26
  import "./chunk-RESS7WVY.js";
23
27
  import {
24
28
  BUILTIN_PACK_VERSION,
25
29
  PACKS_CAPABILITY,
26
30
  ScriptId
27
- } from "./chunk-LXHF6AKU.js";
31
+ } from "./chunk-34VNH3YS.js";
28
32
  import {
29
33
  external_exports
30
34
  } from "./chunk-6DSSLS7I.js";
@@ -475,6 +479,33 @@ var AdgAnalyzer = class extends Service {
475
479
  return problem;
476
480
  }
477
481
  };
482
+ const android = async (scriptId, manifest) => {
483
+ if (!manifest.tasks.some((t) => t.resources.input === "adb"))
484
+ return void 0;
485
+ const runner = ctx.get("adgRunner")?.runner;
486
+ const emulators = ctx.get("adgEmulators");
487
+ if (runner === void 0 || emulators?.findApps === void 0)
488
+ return void 0;
489
+ const game = manifest.game;
490
+ const names = game?.name === void 0 ? [] : [game.name];
491
+ const packages = game?.android?.package === void 0 ? [] : [{ package: game.android.package, source: "\u811A\u672C\u5305\u5199\u7684\u5305\u540D" }];
492
+ if (names.length === 0 && packages.length === 0)
493
+ return { note: "\u811A\u672C\u5305\u6CA1\u5199 game.name\uFF0C\u67E5\u4E0D\u4E86\u6A21\u62DF\u5668\u91CC\u88C5\u7684\u662F\u54EA\u4E2A\u6E38\u620F" };
494
+ let found;
495
+ try {
496
+ found = await emulators.findApps({ packages, names }, AbortSignal.timeout(12e4), void 0, { start: false });
497
+ } catch (error) {
498
+ return { note: `\u6CA1\u67E5\u6A21\u62DF\u5668\u91CC\u7684\u6E38\u620F\uFF08${error instanceof Error ? error.message : String(error)}\uFF09\uFF1B\u6A21\u62DF\u5668\u5F00\u7740\u65F6\u7528 emulator_apps \u67E5` };
499
+ }
500
+ const candidates = found.candidates.map((c) => ({ package: c.package, ...c.label === void 0 ? {} : { label: c.label }, ...c.client === void 0 ? {} : { client: c.client }, reason: c.reason }));
501
+ const saved = (await runner.launch.get(scriptId)).androidPackage;
502
+ const only = found.candidates.length === 1 && found.candidates[0].score >= 80 ? found.candidates[0] : void 0;
503
+ if (saved === void 0 && only !== void 0 && only.package !== game?.android?.package) {
504
+ await runner.launch.set(scriptId, { androidPackage: only.package });
505
+ return { device: found.device, candidates, saved_for_script: only.package };
506
+ }
507
+ return { device: found.device, candidates, ...saved === void 0 ? {} : { script_has: saved } };
508
+ };
478
509
  ctx.inject(["skills", "adgGateway"], (scoped) => {
479
510
  let disposers = [];
480
511
  const register = async () => {
@@ -521,7 +552,7 @@ var AdgAnalyzer = class extends Service {
521
552
  };
522
553
  ctx.inject(["adgGateway"], (gateway) => gateway.adgGateway.agentPart("adg-analyzer tools", (agent) => {
523
554
  const registered = [];
524
- for (const tool of analyzerTools({ library, drafts, approve, ready: scripts.ready, changed, use }))
555
+ for (const tool of analyzerTools({ library, drafts, approve, ready: scripts.ready, changed, use, android }))
525
556
  registered.push(agent.tools.register({ ...tool, execute: async (args, exec) => {
526
557
  await ctx.get("adgGateway")?.guardTool(exec);
527
558
  return tool.execute(args, exec);
@@ -616,6 +647,21 @@ var AdgAnalyzer = class extends Service {
616
647
  };
617
648
  }
618
649
  };
650
+ function androidNext(manifest, check) {
651
+ if (check === void 0)
652
+ return "";
653
+ const own = manifest.game?.android?.package;
654
+ const list = (check.candidates ?? []).map((c) => `${c.label ?? c.package}${c.client === void 0 ? "" : `\uFF08${c.client}\uFF09`} ${c.package}`).join("\u3001");
655
+ const parts = [];
656
+ if (own === void 0) {
657
+ parts.push(list === "" ? `\u8FD9\u4E2A\u811A\u672C\u6709\u6A21\u62DF\u5668\u4EFB\u52A1\uFF0C\u4F46 game.android.package \u6CA1\u5199\uFF1A${check.note ?? "\u6A21\u62DF\u5668\u91CC\u6CA1\u627E\u5230\u8FD9\u4E2A\u6E38\u620F"}\u3002\u67E5\u5230\u5305\u540D\u540E\u5199\u8FDB game.android.package\uFF08\u5199\u5B98\u670D\u7684\uFF09\uFF0C\u518D pack_propose \u4E00\u6B21` : `\u8FD9\u4E2A\u811A\u672C\u6709\u6A21\u62DF\u5668\u4EFB\u52A1\uFF0C\u4F46 game.android.package \u6CA1\u5199\uFF1A\u6A21\u62DF\u5668\u91CC\u88C5\u7684\u662F ${list}\u3002\u628A\u5B98\u670D\u7684\u5305\u540D\u5199\u8FDB game.android.package\uFF08\u53EA\u88C5\u4E86\u6E20\u9053\u670D\u65F6\u5199\u5B83\u672C\u8EAB\uFF09\uFF0C\u518D pack_propose \u4E00\u6B21`);
658
+ }
659
+ if (check.saved_for_script !== void 0)
660
+ parts.push(`\u5DF2\u628A\u6A21\u62DF\u5668\u91CC\u88C5\u7684 ${check.saved_for_script} \u5B58\u4E3A\u8FD9\u4E2A\u811A\u672C\u7684\u6E38\u620F\u5305\u540D\uFF08\u811A\u672C\u9875\u300C\u542F\u52A8\u6E38\u620F\u300D\u91CC\u80FD\u770B\u5230\uFF09\uFF0C\u544A\u8BC9\u7528\u6237`);
661
+ else if ((check.candidates?.length ?? 0) > 1 && check.script_has === void 0)
662
+ parts.push(`\u6A21\u62DF\u5668\u91CC\u88C5\u4E86\u597D\u51E0\u4E2A\u7248\u672C\uFF08${list}\uFF09\uFF1A\u95EE\u7528\u6237\u73A9\u54EA\u4E2A\uFF0C\u7528 game_path_set \u7684 android_package \u5B58\u7ED9\u8FD9\u4E2A\u811A\u672C`);
663
+ return parts.length === 0 ? "" : `${parts.join("\uFF1B")}\u3002`;
664
+ }
619
665
  function analyzerTools(deps) {
620
666
  const json = (value) => JSON.parse(JSON.stringify(value ?? null));
621
667
  const parse = (schema, args) => {
@@ -669,7 +715,7 @@ function analyzerTools(deps) {
669
715
  },
670
716
  skills: skills.length === 0 ? null : {
671
717
  items: skills.map((k) => ({ name: k.name, description: k.description, path: k.path, ...k.problem === void 0 ? {} : { problem: k.problem } })),
672
- todo: "\u8FD9\u4E2A\u811A\u672C\u81EA\u5E26\u6280\u80FD\uFF1A\u8BFB\u4E00\u8BFB\u5B83\u4EEC\uFF0CSKILL.md \u91CC\u63D0\u4E00\u53E5\uFF1B\u7528\u6237\u60F3\u7528\u65F6\u7528 script_skills_import \u653E\u8FDB\u6280\u80FD\u5E93"
718
+ todo: "\u8FD9\u4E2A\u811A\u672C\u81EA\u5E26\u6280\u80FD\uFF1A\u8F6F\u4EF6\u627E\u5230\u5C31\u81EA\u52A8\u653E\u8FDB\u6280\u80FD\u5E93\uFF08\u5F52\u5230\u8FD9\u4E2A\u811A\u672C\uFF09\uFF0C\u8BFB\u4E00\u8BFB\u5B83\u4EEC\uFF0CSKILL.md \u91CC\u63D0\u4E00\u53E5\uFF0C\u4E0D\u8981\u91CD\u5199\u6210\u53E6\u4E00\u4E2A\u6280\u80FD\uFF1Bscript_skills \u91CC\u8FD8\u6CA1\u653E\u8FDB\u53BB\u7684\u7528 script_skills_import \u653E"
673
719
  },
674
720
  readFirst: "\u5148\u8BFB\u6587\u6863\uFF08docs \u91CC\u7684\u6587\u4EF6\u3001readme\u3001docLinks \u91CC\u7684\u7F51\u9875\uFF09\uFF0C\u518D\u7ED3\u5408\u4EE3\u7801\u548C\u914D\u7F6E\u6838\u5BF9\u3001\u8865\u5168\uFF1B\u53EA\u6709\u5B8C\u5168\u627E\u4E0D\u5230\u6587\u6863\u65F6\u624D\u76F4\u63A5\u4ECE\u4EE3\u7801\u5206\u6790\u3002",
675
721
  currentPack: pack === void 0 ? null : { id: pack.manifest.id, builtin: pack.builtin, manifest, skill: pack.skill }
@@ -678,11 +724,11 @@ function analyzerTools(deps) {
678
724
  }),
679
725
  tool({
680
726
  name: "script_help",
681
- description: "\u8FD0\u884C\u811A\u672C\u7A0B\u5E8F\u7684\u5E2E\u52A9\u53C2\u6570\uFF08\u9ED8\u8BA4 --help\uFF09\uFF0C\u62FF\u5230\u5B83\u81EA\u5DF1\u8BF4\u660E\u7684\u547D\u4EE4\u548C\u4EFB\u52A1\u3002\u6700\u591A\u8FD0\u884C 20 \u79D2\u540E\u7ED3\u675F\u3002\u6CA1\u6709\u5B98\u65B9\u811A\u672C\u5305\uFF08\u6280\u80FD\u5E93\u4E0B\u8F7D\u7684\uFF09\u7684\u811A\u672C\u4F1A\u5148\u8BF7\u7528\u6237\u786E\u8BA4\uFF0C\u56E0\u4E3A\u8FD9\u4F1A\u542F\u52A8\u5B83\u7684\u7A0B\u5E8F\u3002",
727
+ description: "\u8FD0\u884C\u811A\u672C\u7A0B\u5E8F\u7684\u5E2E\u52A9\u53C2\u6570\uFF08\u9ED8\u8BA4 --help\uFF09\uFF0C\u62FF\u5230\u5B83\u81EA\u5DF1\u8BF4\u660E\u7684\u547D\u4EE4\u548C\u4EFB\u52A1\u3002\u6700\u591A\u8FD0\u884C 20 \u79D2\u540E\u7ED3\u675F\u3002\u8FD8\u6CA1\u6709\u811A\u672C\u5305\u7684\u811A\u672C\u4F1A\u5148\u8BF7\u7528\u6237\u786E\u8BA4\uFF0C\u56E0\u4E3A\u8FD9\u4F1A\u542F\u52A8\u4E00\u4E2A\u6CA1\u89C1\u8FC7\u7684\u7A0B\u5E8F\uFF1B\u5DF2\u7ECF\u6709\u811A\u672C\u5305\uFF08\u7528\u6237\u5728\u7528\u5B83\u8DD1\u4EFB\u52A1\uFF09\u7684\u76F4\u63A5\u8FD0\u884C\u3002.bat / .cmd / .ps1 \u542F\u52A8\u5668\u591A\u534A\u4E0D\u8BA4 --help\u3001\u4F1A\u76F4\u63A5\u5F00\u59CB\u8DD1\u4EFB\u52A1\uFF1A\u5148\u7528\u8BFB\u6587\u4EF6\u5DE5\u5177\u770B\u5B83\u91CC\u9762\u8C03\u7528\u7684\u771F\u6B63\u7A0B\u5E8F\u548C\u53C2\u6570\uFF08\u4F8B\u5982 runtime\\python.exe main.py\uFF09\uFF0C\u518D\u7528 exe \u548C args \u76F4\u63A5\u95EE\u90A3\u4E2A\u7A0B\u5E8F\u3002",
682
728
  properties: {
683
729
  id,
684
- exe: { type: "string", description: "\u8981\u8FD0\u884C\u7684\u7A0B\u5E8F\uFF08\u76F8\u5BF9\u811A\u672C\u76EE\u5F55\uFF09\uFF1B\u7701\u7565\u65F6\u7528\u811A\u672C\u5305\u7684\u542F\u52A8\u7A0B\u5E8F\u6216\u627E\u5230\u7684\u7B2C\u4E00\u4E2A\u53EF\u6267\u884C\u6587\u4EF6\u3002" },
685
- args: { type: "array", items: { type: "string" }, description: '\u53C2\u6570\uFF0C\u9ED8\u8BA4 ["--help"]\uFF1B\u4E5F\u53EF\u4EE5\u662F ["-h"]\u3001["-l"]\u3001["--list-workflows"]\u3002' }
730
+ exe: { type: "string", description: "\u8981\u8FD0\u884C\u7684\u7A0B\u5E8F\uFF08\u76F8\u5BF9\u811A\u672C\u76EE\u5F55\uFF09\uFF0C\u4F8B\u5982 runtime\\node.exe \u6216 python\\python.exe\uFF1B\u7701\u7565\u65F6\u7528\u811A\u672C\u5305\u7684\u542F\u52A8\u7A0B\u5E8F\uFF0C\u6216\u627E\u5230\u7684\u7B2C\u4E00\u4E2A\u7A0B\u5E8F\uFF08.exe \u4F18\u5148\u4E8E .bat\uFF09\u3002" },
731
+ args: { type: "array", items: { type: "string" }, description: '\u53C2\u6570\uFF0C\u9ED8\u8BA4 ["--help"]\uFF1B\u4E5F\u53EF\u4EE5\u662F ["-h"]\u3001["-l"]\u3001["--list-workflows"]\uFF1Bexe \u662F\u89E3\u91CA\u5668\u65F6\u5148\u5199\u5165\u53E3\u6587\u4EF6\uFF0C\u4F8B\u5982 ["main.py", "--help"]\u3002' }
686
732
  },
687
733
  required: ["id"],
688
734
  kind: "execute",
@@ -694,14 +740,16 @@ function analyzerTools(deps) {
694
740
  if (script.dir === void 0)
695
741
  throw new Error(`${script.name} \u8FD8\u6CA1\u6709\u5B89\u88C5`);
696
742
  const pack = deps.library.packOf(a.id);
697
- const exe = a.exe ?? pack?.manifest.launch?.exe ?? script.probe?.executables[0];
743
+ const found = script.probe?.executables ?? [];
744
+ const exe = a.exe ?? pack?.manifest.launch?.exe ?? found.find((e) => !isScriptLauncher(e)) ?? found[0];
698
745
  if (exe === void 0)
699
746
  throw new Error("\u6CA1\u6709\u627E\u5230\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u8BF7\u7528 exe \u53C2\u6570\u6307\u5B9A");
700
747
  if (exe.split(/[\\/]/).includes("..") || /^([A-Za-z]:|[\\/])/.test(exe))
701
748
  throw new Error("exe \u5FC5\u987B\u662F\u811A\u672C\u76EE\u5F55\u91CC\u7684\u76F8\u5BF9\u8DEF\u5F84");
702
749
  const helpArgs = a.args ?? ["--help"];
703
- if (pack?.builtin !== true)
704
- await deps.approve(exec, `\u4E3A\u4E86\u5206\u6790 ${script.name}\uFF0C\u8FD0\u884C ${exe} ${helpArgs.join(" ")}\uFF08\u6700\u591A 20 \u79D2\uFF0C\u53EA\u770B\u5B83\u7684\u5E2E\u52A9\u8F93\u51FA\uFF09`);
750
+ const launcher = isScriptLauncher(exe) ? `\uFF1B${exe} \u662F\u6279\u5904\u7406\u542F\u52A8\u5668\uFF0C\u5B83\u53EF\u80FD\u4E0D\u8BA4\u8FD9\u4E9B\u53C2\u6570\u3001\u76F4\u63A5\u5F00\u59CB\u8DD1\u4EFB\u52A1` : "";
751
+ if (pack === void 0)
752
+ await deps.approve(exec, `\u4E3A\u4E86\u5206\u6790 ${script.name}\uFF0C\u8FD0\u884C ${exe} ${helpArgs.join(" ")}\uFF08\u6700\u591A 20 \u79D2\uFF0C\u53EA\u770B\u5B83\u7684\u5E2E\u52A9\u8F93\u51FA${launcher}\uFF09`);
705
753
  return runHelp(join4(script.dir, exe), helpArgs, script.dir);
706
754
  }
707
755
  }),
@@ -773,12 +821,25 @@ function analyzerTools(deps) {
773
821
  deps.library.get(a.script_id);
774
822
  const manifest = parseManifest(a.manifest, `${a.pack_id}/${MANIFEST_FILE}`);
775
823
  const issues = guideIssues(manifest);
824
+ const strays = strayKeys(a.manifest);
825
+ if (strays.length > 0)
826
+ issues.push(`\u8FD9\u4E9B\u4E0D\u662F\u811A\u672C\u5305\u7684\u5B57\u6BB5\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u88AB\u4E22\u6389\uFF1A${strays.join("\u3001")}\uFF08\u5E38\u89C1\u95EE\u9898\u5199\u5728 guide.troubleshooting \u4E0B\uFF1B\u65E5\u5E38\u5468\u5E38\u7684\u65E5\u5FD7\u5199 routines[].log\uFF09`);
827
+ issues.push(...patternIssues(manifest));
828
+ let previous;
829
+ try {
830
+ previous = deps.library.pack(a.pack_id)?.manifest;
831
+ } catch {
832
+ previous = void 0;
833
+ }
834
+ const lost = (previous?.routines ?? []).filter((r) => !manifest.routines.some((n) => n.id === r.id));
835
+ if (lost.length > 0)
836
+ issues.push(`\u539F\u6765\u7684\u811A\u672C\u5305\u6709\u65E5\u5E38\u5468\u5E38\uFF08routines\uFF09\uFF1A${lost.map((r) => `${r.name}\uFF08${r.id}\uFF09`).join("\u3001")}\uFF0C\u65B0\u7684\u91CC\u6CA1\u6709\u3002\u6E38\u620F\u9875\u9760\u5B83\u4EEC\u81EA\u52A8\u52FE\u9009\uFF0C\u7167\u539F\u6837\u4FDD\u7559\uFF08log \u6362\u6210\u8FD0\u884C\u65E5\u5FD7\u91CC\u771F\u5B9E\u7684\u539F\u6587\u66F4\u597D\uFF09`);
776
837
  const dir = deps.library.get(a.script_id).dir;
777
838
  if (manifest.mcp === void 0 && dir !== void 0 && (await discoverMcp(dir)).some((e) => e.disabled !== true)) {
778
839
  issues.push("\u8FD9\u4E2A\u811A\u672C\u76EE\u5F55\u91CC\u6709 MCP \u914D\u7F6E\uFF1Amanifest \u8981\u5199 mcp \u4E00\u8282\u2014\u2014servers\uFF08\u7528 from \u6307\u5411\u811A\u672C\u7684\u914D\u7F6E\u6587\u4EF6\uFF09\u3001usage\uFF08\u4EC0\u4E48\u65F6\u5019\u7528 MCP\u3001\u600E\u4E48\u7528\uFF09\u548C tools\uFF08\u4E3B\u8981\u5DE5\u5177\u7684\u7528\u9014\uFF09\uFF1B\u786E\u5B9E\u7528\u4E0D\u4E86\u5C31\u5199 mcp: { servers: [], note: \u4E3A\u4EC0\u4E48 }\u3002SKILL.md \u91CC\u4E5F\u5199\u4E00\u8282\u300CMCP\u300D");
779
840
  }
780
841
  if (issues.length > 0)
781
- throw new Error(`\u4F7F\u7528\u8BF4\u660E\u8FD8\u8981\u6539\uFF08\u6309 script-analysis \u6280\u80FD\u300C\u4F7F\u7528\u8BF4\u660E\u300D\u4E00\u8282\uFF09\uFF1A
842
+ throw new Error(`\u811A\u672C\u5305\u8FD8\u8981\u6539\uFF08\u4F7F\u7528\u8BF4\u660E\u6309 script-analysis \u6280\u80FD\u300C\u4F7F\u7528\u8BF4\u660E\u300D\u4E00\u8282\uFF09\uFF1A
782
843
  - ${issues.join("\n- ")}`);
783
844
  const saved = await deps.drafts.save({
784
845
  packId: a.pack_id,
@@ -791,6 +852,7 @@ function analyzerTools(deps) {
791
852
  }, a.manifest, a.skill);
792
853
  const problem = await deps.use(a.pack_id, a.script_id);
793
854
  deps.changed(a.pack_id);
855
+ const android = problem === void 0 ? await deps.android?.(a.script_id, manifest).catch(() => void 0) : void 0;
794
856
  return {
795
857
  ok: true,
796
858
  pack_id: a.pack_id,
@@ -798,7 +860,8 @@ function analyzerTools(deps) {
798
860
  in_use: problem === void 0,
799
861
  replaced: saved.replaced,
800
862
  ...problem === void 0 ? {} : { problem },
801
- next: problem === void 0 ? `\u811A\u672C\u5305\u5DF2\u7ECF\u4FDD\u5B58\u5E76\u751F\u6548${saved.replaced ? "\uFF08\u4E4B\u524D\u7684\u7248\u672C\u7559\u5728\u5386\u53F2\u91CC\uFF09" : ""}\uFF0C\u4E0D\u7528\u7528\u6237\u786E\u8BA4\u3002\u56DE\u590D\u91CC\u544A\u8BC9\u7528\u6237\u6539\u4E86\u4EC0\u4E48\u3001\u4F9D\u636E\u4E86\u54EA\u4E9B\u6587\u6863\u3001\u54EA\u4E9B\u8FD8\u5F85\u786E\u8BA4\u3002` : `\u811A\u672C\u5305\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4F46\u6CA1\u80FD\u63A5\u5230\u811A\u672C ${a.script_id} \u4E0A\uFF1A${problem}\u3002\u628A\u8FD9\u4E2A\u539F\u56E0\u544A\u8BC9\u7528\u6237\u3002`
863
+ ...android === void 0 ? {} : { android },
864
+ next: problem === void 0 ? `\u811A\u672C\u5305\u5DF2\u7ECF\u4FDD\u5B58\u5E76\u751F\u6548${saved.replaced ? "\uFF08\u4E4B\u524D\u7684\u7248\u672C\u7559\u5728\u5386\u53F2\u91CC\uFF09" : ""}\uFF0C\u4E0D\u7528\u7528\u6237\u786E\u8BA4\u3002${androidNext(manifest, android)}\u56DE\u590D\u91CC\u544A\u8BC9\u7528\u6237\u6539\u4E86\u4EC0\u4E48\u3001\u4F9D\u636E\u4E86\u54EA\u4E9B\u6587\u6863\u3001\u54EA\u4E9B\u8FD8\u5F85\u786E\u8BA4\u3002` : `\u811A\u672C\u5305\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4F46\u6CA1\u80FD\u63A5\u5230\u811A\u672C ${a.script_id} \u4E0A\uFF1A${problem}\u3002\u628A\u8FD9\u4E2A\u539F\u56E0\u544A\u8BC9\u7528\u6237\u3002`
802
865
  };
803
866
  }
804
867
  })
@@ -806,7 +869,8 @@ function analyzerTools(deps) {
806
869
  }
807
870
  function runHelp(file, args, cwd) {
808
871
  return new Promise((resolve) => {
809
- execFile(file, [...args], { cwd, windowsHide: true, timeout: 2e4, maxBuffer: 4 * 1024 * 1024, encoding: "buffer" }, (error, stdout, stderr) => {
872
+ const command = launchCommand(file, args, process.platform, process.env["ComSpec"]);
873
+ execFile(command.file, [...command.args], { cwd, windowsHide: true, timeout: 2e4, maxBuffer: 4 * 1024 * 1024, encoding: "buffer", windowsVerbatimArguments: command.verbatim }, (error, stdout, stderr) => {
810
874
  const raw = Buffer.concat([stdout, stderr]);
811
875
  let output = new TextDecoder("utf-8").decode(raw);
812
876
  if ((output.match(/�/g)?.length ?? 0) > 5)
@@ -822,6 +886,7 @@ export {
822
886
  AdgAnalyzer,
823
887
  DraftStore,
824
888
  analyzeDir,
889
+ androidNext,
825
890
  lib_default as default,
826
891
  parseJsonc,
827
892
  parseSkill,
@@ -23,6 +23,19 @@ var EmulatorProvider = external_exports.object({
23
23
  instances: external_exports.array(EmulatorInstance),
24
24
  error: external_exports.string().optional()
25
25
  });
26
+ var AndroidAppCandidate = external_exports.object({
27
+ package: external_exports.string(),
28
+ /** The app's own name, from its APK. */
29
+ label: external_exports.string().optional(),
30
+ /** Which build: 官服, B服, 国际服… when known. */
31
+ client: external_exports.string().optional(),
32
+ /** Why it is taken for the game, for people. */
33
+ reason: external_exports.string(),
34
+ /** 100: a package the game is known by; 85/80: another build of one; 90/70: by the app's name. */
35
+ score: external_exports.number(),
36
+ /** The app's launcher icon (PNG, WebP, or an SVG of an adaptive icon's layers). */
37
+ icon: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() }).optional()
38
+ });
26
39
  var EmulatorSettings = external_exports.object({
27
40
  /** MuMuManager.exe chosen by the user; otherwise found automatically. */
28
41
  mumuManager: external_exports.string().optional(),
@@ -365,8 +378,11 @@ var ScriptSkillItem = external_exports.object({
365
378
  /** Its folder in the script directory. */
366
379
  path: external_exports.string(),
367
380
  problem: external_exports.string().optional(),
368
- /** Among this app's skills: under which name, whether it is the script's current version, whether it was changed here. */
369
- imported: external_exports.object({ name: external_exports.string(), current: external_exports.boolean(), changed: external_exports.boolean() }).optional()
381
+ /**
382
+ * Among this app's skills: under which name, whether it is the script's current version, whether it was
383
+ * changed here, and whether the app put it there by itself (as soon as it was found).
384
+ */
385
+ imported: external_exports.object({ name: external_exports.string(), current: external_exports.boolean(), changed: external_exports.boolean(), auto: external_exports.boolean().optional() }).optional()
370
386
  });
371
387
  var ById = external_exports.object({ id: ScriptId });
372
388
  var ScriptRequests = {
@@ -1624,6 +1640,34 @@ var GameReading = external_exports.object({
1624
1640
  remainingUrls: external_exports.array(external_exports.string()).optional(),
1625
1641
  summary: external_exports.string().optional()
1626
1642
  });
1643
+ var GameRoutine = external_exports.object({
1644
+ id: external_exports.string(),
1645
+ name: external_exports.string(),
1646
+ period: external_exports.enum(["daily", "weekly", "event"]),
1647
+ description: external_exports.string().optional(),
1648
+ /** Where it comes from: `game` the game pack, `script:<id>` a script pack, `own` the user. */
1649
+ from: external_exports.string(),
1650
+ /** How it gets ticked off by itself, for people ("MAA 日志「完成任务: 基建换班」"); none: only by hand. */
1651
+ links: external_exports.array(external_exports.string()),
1652
+ /** Done in the current period: when, and what showed it. */
1653
+ done: external_exports.object({
1654
+ at: external_exports.number(),
1655
+ /**
1656
+ * `log` a script's log line, `task` a task that succeeded (both also found
1657
+ * afterwards in the period's saved runs), `agent` an agent with what it saw
1658
+ * (game_routine), `user` the person on the game page.
1659
+ */
1660
+ by: external_exports.enum(["log", "task", "agent", "user"]),
1661
+ /** The log line, the task's title, or what the agent saw. */
1662
+ detail: external_exports.string().optional(),
1663
+ script: external_exports.string().optional(),
1664
+ runId: external_exports.string().optional()
1665
+ }).optional(),
1666
+ /** When the current period ends (the next reset, or the event's end). */
1667
+ resetsAt: external_exports.number().optional(),
1668
+ /** period=event: its events on the calendar now (activity ids), the running one first. */
1669
+ activities: external_exports.array(external_exports.string()).optional()
1670
+ });
1627
1671
  var GameInfo = external_exports.object({
1628
1672
  id: external_exports.string(),
1629
1673
  name: external_exports.string(),
@@ -1666,6 +1710,12 @@ var GameInfo = external_exports.object({
1666
1710
  cover: external_exports.string().optional(),
1667
1711
  up: external_exports.array(external_exports.string())
1668
1712
  })).optional(),
1713
+ /** Its 日常 / 周常 and recurring events, with what is done in the current period. */
1714
+ routines: external_exports.array(GameRoutine).optional(),
1715
+ /** Routines from packs the user took off the page. */
1716
+ hiddenRoutines: external_exports.number().optional(),
1717
+ /** When its day and week start over (epoch ms of the next reset). */
1718
+ resets: external_exports.object({ daily: external_exports.number(), weekly: external_exports.number() }).optional(),
1669
1719
  /** The last data-site refresh. */
1670
1720
  refreshed: external_exports.object({ at: external_exports.number(), ok: external_exports.boolean(), count: external_exports.number(), detail: external_exports.string().optional() }).optional(),
1671
1721
  /** The last time the agent read the game screen. */
@@ -1769,13 +1819,38 @@ var GamesRequests = {
1769
1819
  },
1770
1820
  /**
1771
1821
  * The game program's own icon (its .exe, as Explorer shows it), for the game's avatar: the program a script that plays
1772
- * it starts (启动游戏), else where 自动查找 finds it. No `icon`: no PC program known (a phone game), or not on Windows.
1822
+ * it starts (启动游戏), else where 自动查找 finds it; else (first, for a game played in the emulator) its app's icon in the
1823
+ * emulator, as read from the APK there (games/android/locate, or now when the emulator is up). No `icon`: neither is known.
1773
1824
  */
1774
1825
  "games/icon": {
1775
1826
  capability: GAMES_CAPABILITY,
1776
1827
  params: external_exports.object({ game: external_exports.string().min(1) }),
1777
1828
  result: external_exports.object({ icon: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() }).optional() })
1778
1829
  },
1830
+ /**
1831
+ * Which app in the emulator is the game a script plays (启动游戏 on the script
1832
+ * page): its installed apps matched against the game's known packages (one
1833
+ * per client, like MAA's 客户端类型), other builds of them, and the apps' own
1834
+ * names. Starts the emulator the script's tasks use when it is not running.
1835
+ * The icons found are kept for the game's avatar.
1836
+ */
1837
+ "games/android/locate": {
1838
+ capability: GAMES_CAPABILITY,
1839
+ params: external_exports.object({ scriptId: external_exports.string().min(1) }),
1840
+ result: external_exports.object({
1841
+ /** The emulator looked in, for people. */
1842
+ device: external_exports.string(),
1843
+ /** Third-party apps installed there. */
1844
+ installed: external_exports.number().int(),
1845
+ candidates: external_exports.array(AndroidAppCandidate)
1846
+ })
1847
+ },
1848
+ /** A saved Android package's name and icon (as last read from the emulator), for the script page; none when never read. */
1849
+ "games/android/app": {
1850
+ capability: GAMES_CAPABILITY,
1851
+ params: external_exports.object({ package: external_exports.string().min(1) }),
1852
+ result: external_exports.object({ label: external_exports.string().optional(), icon: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() }).optional() })
1853
+ },
1779
1854
  /**
1780
1855
  * Put a game on the game page by its name, whatever is known about it: one
1781
1856
  * already there (or taken off it) is shown; one the SRA public API knows is
@@ -1841,6 +1916,24 @@ var GamesRequests = {
1841
1916
  params: external_exports.object({ sra: external_exports.string(), follow: external_exports.boolean() }),
1842
1917
  result: external_exports.object({})
1843
1918
  },
1919
+ /** Tick a 日常 / 周常 off for the current period, or take it back. */
1920
+ "games/routine/set": {
1921
+ capability: GAMES_CAPABILITY,
1922
+ params: external_exports.object({ game: external_exports.string(), routine: external_exports.string(), done: external_exports.boolean() }),
1923
+ result: external_exports.object({})
1924
+ },
1925
+ /** A 日常 / 周常 of the user's own, ticked by hand. */
1926
+ "games/routine/add": {
1927
+ capability: GAMES_CAPABILITY,
1928
+ params: external_exports.object({ game: external_exports.string(), name: external_exports.string().trim().min(1).max(40), period: external_exports.enum(["daily", "weekly"]) }),
1929
+ result: external_exports.object({ routine: GameRoutine })
1930
+ },
1931
+ /** Delete one of the user's own; one from a pack is hidden from the game page instead (`restore` shows the hidden ones again). */
1932
+ "games/routine/remove": {
1933
+ capability: GAMES_CAPABILITY,
1934
+ params: external_exports.object({ game: external_exports.string(), routine: external_exports.string().optional(), restore: external_exports.boolean().optional() }),
1935
+ result: external_exports.object({})
1936
+ },
1844
1937
  /** The user's own progress on an event: its checklist, or done as a whole. */
1845
1938
  "games/activity/progress": {
1846
1939
  capability: GAMES_CAPABILITY,
@@ -1941,6 +2034,21 @@ var AGENT_AREAS = [
1941
2034
  function areaOf(toolName) {
1942
2035
  return AGENT_AREAS.find((a) => a.tools.includes(toolName));
1943
2036
  }
2037
+ var DECISION_AREAS = [
2038
+ { id: "scripts-install", title: "\u5B89\u88C5\u3001\u66F4\u65B0\u3001\u5220\u9664\u811A\u672C\uFF0C\u5199\u811A\u672C\u5305", tools: ["script_install", "script_update", "script_rollback", "script_remove", "script_setup_run", "script_import", "script_env_fix", "pack_propose"] },
2039
+ { id: "scripts-config", title: "\u6539\u811A\u672C\u914D\u7F6E", tools: ["script_config_set", "script_config_import", "script_choice_create", "game_path_set", "monitor_stall_set"] },
2040
+ { id: "pipelines-edit", title: "\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6", tools: ["pipeline_save", "schedule_set"] },
2041
+ { id: "skills", title: "\u4FDD\u5B58\u6280\u80FD", tools: ["skill_save", "script_skills_import", "skill_hub_install"] },
2042
+ { id: "games-setup", title: "\u6DFB\u52A0\u6E38\u620F\u3001\u52A0\u65E5\u5E38\u5468\u5E38\u3001\u5220\u6D3B\u52A8", tools: ["game_add", "game_routine", "game_activity_remove"] }
2043
+ ];
2044
+ function decisionOf(toolName, args) {
2045
+ const area = DECISION_AREAS.find((a) => a.tools.includes(toolName));
2046
+ if (area === void 0)
2047
+ return void 0;
2048
+ if (toolName === "game_routine")
2049
+ return args?.action === "add" ? area : void 0;
2050
+ return area;
2051
+ }
1944
2052
  var PermissionsState = external_exports.object({
1945
2053
  mode: PermissionMode,
1946
2054
  /** When the mode last changed. */
@@ -2145,6 +2253,33 @@ var THREAD_LINE = /^(这件事的线索是 (\S+):做的过程中要问清楚
2145
2253
  var PAST_HEAD = (who) => `\uFF08\u4F60\u548C${who}\u4E4B\u524D\u7684\u6765\u5F80\uFF0C\u4ECE\u65E7\u5230\u65B0\u3002\u53EF\u80FD\u5DF2\u7ECF\u8FC7\u65F6\uFF1B\u8981\u770B\u5B8C\u6574\u7684\uFF0C\u7528 agent_threads \u5E26 id\uFF1A`;
2146
2254
  var PAST_LINE = /^(你和.{1,20}之前的来往,/;
2147
2255
  var PAST_END = "\uFF09";
2256
+ var BRIEF_LIMITS = "\u8FB9\u754C";
2257
+ var BRIEF_DONE_WHEN = "\u5B8C\u6210\u6807\u51C6";
2258
+ var BRIEF_ALLOW = "\u5141\u8BB8\u76F4\u63A5\u505A\u7684\u6539\u52A8";
2259
+ function briefText(task, parts) {
2260
+ const allowed = DECISION_AREAS.filter((area) => parts.allow?.includes(area.id) === true);
2261
+ const lines = [
2262
+ ...parts.limits?.trim() ? [`${BRIEF_LIMITS}\uFF1A${parts.limits.trim()}`] : [],
2263
+ ...allowed.length > 0 ? [`${BRIEF_ALLOW}\uFF1A${allowed.map((area) => `${area.title}\uFF08${area.id}\uFF09`).join("\u3001")}`] : [],
2264
+ ...parts.doneWhen?.trim() ? [`${BRIEF_DONE_WHEN}\uFF1A${parts.doneWhen.trim()}`] : []
2265
+ ];
2266
+ return lines.length === 0 ? task.trim() : `${task.trim()}
2267
+
2268
+ ${lines.join("\n")}`;
2269
+ }
2270
+ function grantsIn(brief) {
2271
+ if (brief.trimStart().startsWith(`\uFF08\u4F60\u5728\u8F6F\u4EF6\u91CC\u70B9\u7684\uFF1A`))
2272
+ return new Set(DECISION_AREAS.map((area) => area.id));
2273
+ const at = brief.search(new RegExp(`${BRIEF_ALLOW}[\uFF1A:]`));
2274
+ if (at === -1)
2275
+ return /* @__PURE__ */ new Set();
2276
+ const rest = brief.slice(at + BRIEF_ALLOW.length + 1).split("\n")[0];
2277
+ const stop = rest.search(new RegExp(`[\u3002\uFF1B;]|(${BRIEF_LIMITS}|${BRIEF_DONE_WHEN}|\u5E26\u56DE|\u8981\u4EA4\u56DE\u7684|\u76EE\u6807)[\uFF1A:]`));
2278
+ const named = stop === -1 ? rest : rest.slice(0, stop);
2279
+ if (/全部|所有/.test(named))
2280
+ return new Set(DECISION_AREAS.map((area) => area.id));
2281
+ return new Set(DECISION_AREAS.filter((area) => named.includes(area.id) || named.includes(area.title)).map((area) => area.id));
2282
+ }
2148
2283
  function taskMessage(by, title, body, returns = false, thread, past) {
2149
2284
  const head = by === BY_YOU ? `\uFF08\u4F60\u5728\u8F6F\u4EF6\u91CC\u70B9\u7684\uFF1A${oneLine(title)}\uFF09` : `\uFF08${by}\u4EA4\u7ED9\u4F60\u7684\u4E8B\uFF1A${oneLine(title)}\uFF09`;
2150
2285
  const notes = [...returns ? [RETURNS] : [], ...thread === void 0 ? [] : [`\uFF08\u8FD9\u4EF6\u4E8B\u7684\u7EBF\u7D22\u662F ${thread}\uFF1A\u505A\u7684\u8FC7\u7A0B\u4E2D\u8981\u95EE\u6E05\u695A\u4EC0\u4E48\uFF0C\u7528 agent_message \u95EE\uFF0Cthread \u586B\u5B83\uFF1B\u4E0D\u8981\u731C\u3002\uFF09`]];
@@ -3761,6 +3896,10 @@ function classify(value) {
3761
3896
  return "invalid";
3762
3897
  }
3763
3898
 
3899
+ // packages/protocol/lib/update-rule.js
3900
+ var UPDATE_RULE = "\u66F4\u65B0\u811A\u672C\u53EA\u8D70\u5B98\u65B9\u6E20\u9053\uFF1A\u5148\u7528 script_update\uFF08Mirror\u9171 \u6216\u5B98\u65B9\u53D1\u5E03\u5305\uFF0C\u914D\u7F6E\u4F1A\u63A5\u4E0A\uFF09\uFF1B\u5B83\u6CA1\u6709\u66F4\u65B0\u6765\u6E90\u6216\u5931\u8D25\u65F6\uFF0C\u7528\u811A\u672C\u81EA\u5DF1\u7684\u66F4\u65B0\u529F\u80FD\uFF08\u5B83\u7684\u66F4\u65B0\u7A0B\u5E8F\u3001\u542F\u52A8\u5668\u6216\u8BBE\u7F6E\u91CC\u7684\u300C\u68C0\u67E5\u66F4\u65B0\u300D\uFF09\u3002\u4E0D\u8981\u7528 git clone / pull / checkout \u62C9\u4EE3\u7801\uFF0C\u4E0D\u8981\u81EA\u5DF1\u4E0B\u8F7D\u6E90\u7801\u6216\u624B\u52A8\u89E3\u538B\u8986\u76D6\u6587\u4EF6\u2014\u2014\u9664\u975E\u6CA1\u6709\u4EFB\u4F55\u5B98\u65B9\u6E20\u9053\uFF0C\u5E76\u4E14\u7528\u6237\u540C\u610F\u3002";
3901
+ var APP_FILES_RULE = "\u4E0D\u8981\u6539 MultiGameAssistant \u81EA\u5DF1\uFF1A\u5B83\u7684\u7A0B\u5E8F\u548C\u6E90\u7801\uFF08\u5B89\u88C5\u76EE\u5F55\u3001\u6E90\u7801\u76EE\u5F55\uFF09\u3001\u6570\u636E\u548C\u8BBE\u7F6E\u90FD\u4E0D\u5F52\u4F60\u6539\uFF0C\u4E5F\u4E0D\u8981\u5728\u8FD9\u4E9B\u76EE\u5F55\u91CC\u5F00\u5B50 agent \u53BB\u6539\u3002\u8F6F\u4EF6\u7684\u6570\u636E\u6709\u4E13\u95E8\u7684\u5DE5\u5177\uFF08\u811A\u672C\u5305 pack_propose\u3001\u6280\u80FD skill_save\u3001\u65E5\u5E38 game_routine\u3001\u811A\u672C\u8BBE\u7F6E script_config_set\uFF09\u3002\u7528\u6237\u8BF4\u8F6F\u4EF6\u54EA\u91CC\u4E0D\u5BF9\u3001\u5C11\u4E86\u4EC0\u4E48\uFF0C\u6216\u8005\u4F60\u53D1\u73B0\u4E86\u8F6F\u4EF6\u672C\u8EAB\u7684\u95EE\u9898\uFF1A\u8BF4\u6E05\u695A\u73B0\u8C61\u548C\u4F60\u7684\u5224\u65AD\uFF0C\u7531\u7528\u6237\u51B3\u5B9A\u600E\u4E48\u6539\uFF0C\u4E0D\u8981\u81EA\u5DF1\u52A8\u624B\u4FEE\u3002";
3902
+
3764
3903
  // packages/protocol/lib/tools.js
3765
3904
  function summarizeToolArgs(args) {
3766
3905
  try {
@@ -3790,9 +3929,11 @@ function optimizeScriptPrompt(target, why, id) {
3790
3929
  return [
3791
3930
  `\u4F18\u5316\u811A\u672C${target === "" ? "\uFF1A\u6700\u8FD1\u8FD0\u884C\u8FC7\u7684\u811A\u672C\uFF08script_runs \u770B\u6700\u8FD1\u4E00\u5468\u8DD1\u8FC7\u54EA\u4E9B\uFF0C\u4E00\u4E2A\u4E00\u4E2A\u6765\uFF09" : `\u300C${target}\u300D${id === void 0 ? "" : `\uFF08\u811A\u672C id ${id}\uFF09`}`}${why === void 0 ? "" : `\uFF08${why}\uFF09`}\u3002\u628A\u8FD9\u6BB5\u65F6\u95F4\u8FD0\u884C\u6512\u4E0B\u7684\u4FE1\u606F\u7528\u8D77\u6765\uFF0C\u4E00\u6B21\u505A\u5B8C\u4E0B\u9762\u51E0\u4EF6\u4E8B\uFF1A`,
3792
3931
  "1. \u91CD\u65B0\u603B\u7ED3\u811A\u672C\u5305\uFF1Ascript_tasks\u3001script_help \u770B\u5B83\u73B0\u5728\u6709\u54EA\u4E9B\u4EFB\u52A1\u548C\u53C2\u6570\uFF0Cscript_runs\u3001script_run_log \u770B\u6700\u8FD1\u7684\u8FD0\u884C\uFF08\u6210\u529F\u7684\u770B\u6B63\u5E38\u6D41\u7A0B\u548C\u7528\u65F6\uFF0C\u5931\u8D25\u7684\u770B\u539F\u56E0\uFF09\uFF1B\u66F4\u65B0\u8FC7\u7248\u672C\u5C31\u5148\u7528 script_changelog \u8BFB\u66F4\u65B0\u65E5\u5FD7\u3002\u5BF9\u7167\u5B83\u7684\u811A\u672C\u5305\uFF0C\u4EFB\u52A1\u3001\u53C2\u6570\u3001\u914D\u7F6E\u6587\u4EF6\u3001\u5B8C\u6210\u548C\u51FA\u9519\u7684\u65E5\u5FD7\u6587\u5B57\u3001\u9884\u8BA1\u7528\u65F6\u6709\u4E0D\u5BF9\u6216\u7F3A\u7684\uFF0C\u6216\u8005\u4F7F\u7528\u8BF4\u660E\uFF08guide\uFF1A\u529F\u80FD\u600E\u4E48\u5F00\u542F\u3001\u914D\u7F6E\u600E\u4E48\u8BBE\u3001\u8FD0\u884C\u524D\u68C0\u67E5\u3001\u5E38\u89C1\u95EE\u9898\uFF09\u7F3A\u4E86\u3001\u8FC7\u65F6\u4E86\u3001\u80FD\u7528\u8FD0\u884C\u91CC\u9047\u5230\u7684\u62A5\u9519\u8865\u4E0A\u7684\uFF0C\u7528\u539F\u6765\u7684\u811A\u672C\u5305 id \u8C03\u7528 pack_propose \u4FDD\u5B58\uFF08\u76F4\u63A5\u751F\u6548\uFF1Bsummary \u5199\u660E\u4F9D\u636E\uFF09\uFF1B\u90FD\u5BF9\u5C31\u4E0D\u6539\uFF1B",
3932
+ " \u65E5\u5E38\u5468\u5E38\uFF08routines\uFF0C\u6E38\u620F\u9875\u300C\u65E5\u5E38 \xB7 \u5468\u5E38\u300D\u9760\u5B83\u4EEC\u81EA\u52A8\u52FE\u9009\uFF09\uFF1A\u539F\u6765\u6709\u7684\u7167\u539F\u6837\u4FDD\u7559\uFF1B\u6BCF\u4E00\u9879\u7684 log \u7528\u8FD0\u884C\u65E5\u5FD7\u91CC\u5B83\u771F\u6B63\u505A\u5B8C\u65F6\u7684\u539F\u6587\u5199\uFF08\u4F8B\u5982\u300C\u5B8C\u6210\u4EFB\u52A1: \u57FA\u5EFA\u6362\u73ED\u300D\u300C\u6BCF\u65E5\u5B9E\u8BAD\u5DF2\u5B8C\u6210\u300D\u300C\u672C\u5468\u527F\u706D\u5DF2\u5B8C\u6210\uFF0C\u8DF3\u8FC7\u527F\u706D\u300D\uFF09\uFF0C\u770B\u4E0D\u51FA\u5355\u9879\u3001\u53EA\u6709\u4EFB\u52A1\u6210\u529F\u80FD\u8BC1\u660E\u7684\u5199 tasks\uFF1B\u5F00\u59CB\u3001\u8DF3\u8FC7\u4E0D\u4E86\u3001\u5931\u8D25\u7684\u884C\u4E0D\u8981\u5199\u6210\u5B8C\u6210\u3002\u5E38\u89C1\u95EE\u9898\u5199\u5728 guide.troubleshooting \u4E0B\uFF0C\u5199\u5728\u522B\u5904\u4F1A\u88AB\u4E22\u6389\uFF1B",
3793
3933
  "2. \u6539\u5584\u76D1\u63A7\u65F6\u95F4\uFF1Amonitor_stall_check \u770B\u5B83\u6B63\u5E38\u8FD0\u884C\u65F6\u65E5\u5FD7\u7684\u8282\u594F\uFF0C\u6309\u5EFA\u8BAE\u503C\u548C\u4F60\u770B\u65E5\u5FD7\u7684\u5224\u65AD\u7528 monitor_stall_set \u8BBE\u5B83\u591A\u4E45\u6CA1\u65B0\u65E5\u5FD7\u7B97\u5361\u4F4F\uFF0Cnote \u5199\u660E\u4F9D\u636E\uFF08\u4F8B\u5982\u300C\u6218\u6597\u4E2D\u6700\u957F 70 \u79D2\u4E0D\u8F93\u51FA\u300D\uFF09\uFF1B",
3794
3934
  "3. \u628A\u505A\u8FC7\u7684\u6B65\u9AA4\u603B\u7ED3\u6210\u6280\u80FD\uFF0C\u5206\u5230\u5BF9\u5E94\u7684\u6E38\u620F\u548C\u811A\u672C\uFF1A\u8FD0\u884C\u548C\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u65F6\u53CD\u590D\u7528\u5230\u3001\u5DF2\u7ECF\u8D70\u901A\u7684\u505A\u6CD5\uFF08\u5E38\u89C1\u62A5\u9519\u600E\u4E48\u5904\u7406\u3001\u600E\u4E48\u786E\u8BA4\u8DD1\u5B8C\u3001\u914D\u7F6E\u600E\u4E48\u6539\uFF09\u7528 skill_save \u5B58\u6210\u6280\u80FD\uFF0Cscripts \u586B\u8FD9\u4E2A\u811A\u672C\u7684 id\uFF0C\u53EA\u7ED9\u5B83\u7528\uFF1B\u5176\u4E2D\u548C\u6E38\u620F\u672C\u8EAB\u6709\u5173\u3001\u522B\u7684\u811A\u672C\u4E5F\u7528\u5F97\u4E0A\u7684\uFF08\u6E38\u620F\u91CC\u7684\u64CD\u4F5C\u3001\u754C\u9762\u3001\u6D3B\u52A8\u3001\u673A\u5236\uFF09\u5355\u72EC\u5B58\uFF0Cgames \u586B\u5B83\u73A9\u7684\u6E38\u620F id\uFF08game_list \u67E5\uFF09\uFF0C\u4E0D\u586B scripts\uFF1B\u5DF2\u6709\u7684\u6280\u80FD\u5C31\u5408\u5E76\u66F4\u65B0\uFF08replace\uFF09\uFF0C\u4E0D\u8981\u91CD\u590D\u5B58\uFF0C\u6CA1\u6709\u503C\u5F97\u5B58\u7684\u5C31\u4E0D\u5B58\uFF1B",
3795
- "4. \u4E0D\u8981\u8FD0\u884C\u811A\u672C\u3001\u4E0D\u8981\u6539\u5B83\u7684\u914D\u7F6E\uFF1B\u6700\u540E\u7528\u51E0\u53E5\u8BDD\u544A\u8BC9\u6211\uFF1A\u811A\u672C\u5305\u6539\u4E86\u4EC0\u4E48\uFF08\u5DF2\u7ECF\u76F4\u63A5\u751F\u6548\uFF09\u3001\u5361\u4F4F\u65F6\u95F4\u8BBE\u6210\u591A\u5C11\u3001\u5B58\u4E86\u6216\u66F4\u65B0\u4E86\u54EA\u4E9B\u6280\u80FD\u3002"
3935
+ "4. \u505A\u4E0A\u9762\u51E0\u6B65\u65F6\uFF0C\u6587\u6863\u548C\u65E5\u5FD7\u8BF4\u4E0D\u6E05\u7684\uFF08\u67D0\u4E2A\u529F\u80FD\u5728\u754C\u9762\u54EA\u91CC\u5F00\u3001\u9009\u9879\u53EB\u4EC0\u4E48\u3001\u65B0\u7248\u672C\u754C\u9762\u53D8\u4E86\u6CA1\u6709\uFF09\uFF0C\u53EF\u4EE5\u81EA\u5DF1\u6253\u5F00\u811A\u672C\u7A0B\u5E8F\u770B\uFF1Ascript_settings \u6253\u5F00\u5B83\u7684\u8BBE\u7F6E\u754C\u9762\uFF08\u547D\u4EE4\u884C\u811A\u672C\u7528 script_help \u770B\u5E2E\u52A9\uFF09\uFF0Cwindow_list \u627E\u5230\u5B83\u7684\u7A97\u53E3\uFF0Cscreen_capture\uFF08target=window\uFF09\u622A\u56FE\u5BF9\u7167\uFF0C\u770B\u5B8C\u7528 script_stop \u5173\u6389\uFF08run_id \u662F script_settings \u8FD4\u56DE\u7684\uFF09\u3002\u4E0D\u8981\u8DD1\u4F1A\u64CD\u4F5C\u6E38\u620F\u7684\u4EFB\u52A1\uFF08\u4F1A\u5360\u7528\u6E38\u620F\u548C\u8D26\u53F7\uFF09\uFF0C\u4E5F\u4E0D\u8981\u6539\u5B83\u7684\u914D\u7F6E\uFF1B",
3936
+ "5. \u6700\u540E\u7528\u51E0\u53E5\u8BDD\u544A\u8BC9\u6211\uFF1A\u811A\u672C\u5305\u6539\u4E86\u4EC0\u4E48\uFF08\u5DF2\u7ECF\u76F4\u63A5\u751F\u6548\uFF09\u3001\u54EA\u4E9B\u65E5\u5E38\u5468\u5E38\u80FD\u81EA\u52A8\u52FE\u9009\u3001\u5361\u4F4F\u65F6\u95F4\u8BBE\u6210\u591A\u5C11\u3001\u5B58\u4E86\u6216\u66F4\u65B0\u4E86\u54EA\u4E9B\u6280\u80FD\uFF1B\u6253\u5F00\u8FC7\u811A\u672C\u754C\u9762\u7684\uFF0C\u8BF4\u4E00\u53E5\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
3796
3937
  ].join("\n");
3797
3938
  }
3798
3939
  var COMMANDS = [
@@ -3823,7 +3964,7 @@ var COMMANDS = [
3823
3964
  expand: (arg) => [
3824
3965
  `\u5E2E\u6211\u628A\u811A\u672C\u7F16\u6392\u6210\u6D41\u6C34\u7EBF\uFF1A${arg === "" ? "\u628A\u6211\u88C5\u597D\u7684\u5404\u4E2A\u811A\u672C\u7684\u65E5\u5E38\u4EFB\u52A1\u6392\u6210\u6BCF\u5929\u80FD\u81EA\u52A8\u8DD1\u7684\u6D41\u7A0B" : arg}\u3002\u6309\u6280\u80FD pipeline-planning\uFF1A`,
3825
3966
  "1. \u5148 system_info \u770B\u7535\u8111\u914D\u7F6E\uFF08\u80FD\u4E0D\u80FD\u540C\u65F6\u8DD1\u51E0\u4E2A\u6E38\u620F\uFF09\uFF0Cpipeline_list \u770B\u5DF2\u6709\u7684\u6D41\u6C34\u7EBF\uFF0Cscript_tasks \u770B\u5404\u811A\u672C\u6709\u54EA\u4E9B\u4EFB\u52A1\uFF1B",
3826
- "2. \u6392\u597D\u540E\u4FDD\u5B58\uFF1A\u4F60\u662F\u300C\u7F16\u6392\u300D\u5C31\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF1B\u4E0D\u662F\u5C31\u7528 pipeline_draft \u8D77\u8349\uFF08\u8349\u7A3F\uFF0C\u6211\u5728\u300C\u7F16\u6392\u300D\u9875\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\uFF09\uFF0C\u6216\u8005\u4EA4\u7ED9\u300C\u7F16\u6392\u300D\u3002\u6A21\u62DF\u5668\u548C\u524D\u53F0\u811A\u672C\u80FD\u5E76\u884C\u7684\u5E76\u884C\uFF0C\u5931\u8D25\u4E0D\u8981\u6321\u4F4F\u522B\u7684\uFF1B",
3967
+ "2. \u6392\u597D\u540E\u4FDD\u5B58\uFF1A\u4F60\u662F\u300C\u7F16\u6392\u300D\u5C31\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF1B\u4E0D\u662F\u5C31\u6574\u4EF6\u4E8B\u4EA4\u7ED9\u300C\u7F16\u6392\u300D\uFF08agent_delegate\uFF09\u53BB\u6392\u548C\u4FDD\u5B58\uFF0C\u53EA\u6709\u6CA1\u6709\u300C\u7F16\u6392\u300D\u65F6\u624D\u7528 pipeline_draft \u8D77\u8349\uFF08\u8349\u7A3F\uFF0C\u6211\u5728\u300C\u7F16\u6392\u300D\u9875\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\uFF09\u3002\u6A21\u62DF\u5668\u548C\u524D\u53F0\u811A\u672C\u80FD\u5E76\u884C\u7684\u5E76\u884C\uFF0C\u5931\u8D25\u4E0D\u8981\u6321\u4F4F\u522B\u7684\uFF1B",
3827
3968
  "3. \u8BF4\u6E05\u695A\u4E3A\u4EC0\u4E48\u8FD9\u6837\u6392\u3001\u54EA\u4E9B\u6B65\u9AA4\u5E76\u884C\u3001\u4F30\u8BA1\u591A\u4E45\u3001\u5EFA\u8BAE\u5B9A\u5728\u51E0\u70B9\u8DD1\u3002"
3828
3969
  ].join("\n")
3829
3970
  },
@@ -3934,9 +4075,6 @@ function parseGitHubLink(text) {
3934
4075
  return { repo };
3935
4076
  }
3936
4077
 
3937
- // packages/protocol/lib/update-rule.js
3938
- var UPDATE_RULE = "\u66F4\u65B0\u811A\u672C\u53EA\u8D70\u5B98\u65B9\u6E20\u9053\uFF1A\u5148\u7528 script_update\uFF08Mirror\u9171 \u6216\u5B98\u65B9\u53D1\u5E03\u5305\uFF0C\u914D\u7F6E\u4F1A\u63A5\u4E0A\uFF09\uFF1B\u5B83\u6CA1\u6709\u66F4\u65B0\u6765\u6E90\u6216\u5931\u8D25\u65F6\uFF0C\u7528\u811A\u672C\u81EA\u5DF1\u7684\u66F4\u65B0\u529F\u80FD\uFF08\u5B83\u7684\u66F4\u65B0\u7A0B\u5E8F\u3001\u542F\u52A8\u5668\u6216\u8BBE\u7F6E\u91CC\u7684\u300C\u68C0\u67E5\u66F4\u65B0\u300D\uFF09\u3002\u4E0D\u8981\u7528 git clone / pull / checkout \u62C9\u4EE3\u7801\uFF0C\u4E0D\u8981\u81EA\u5DF1\u4E0B\u8F7D\u6E90\u7801\u6216\u624B\u52A8\u89E3\u538B\u8986\u76D6\u6587\u4EF6\u2014\u2014\u9664\u975E\u6CA1\u6709\u4EFB\u4F55\u5B98\u65B9\u6E20\u9053\uFF0C\u5E76\u4E14\u7528\u6237\u540C\u610F\u3002";
3939
-
3940
4078
  export {
3941
4079
  ModelFallbackNotice,
3942
4080
  MODEL_FALLBACK_SOURCE,
@@ -3996,6 +4134,8 @@ export {
3996
4134
  AreaPolicy,
3997
4135
  AGENT_AREAS,
3998
4136
  areaOf,
4137
+ DECISION_AREAS,
4138
+ decisionOf,
3999
4139
  QUESTIONS_CAPABILITY,
4000
4140
  INSTANCES_CAPABILITY,
4001
4141
  SKILLS_CAPABILITY,
@@ -4004,6 +4144,11 @@ export {
4004
4144
  SKILLHUB_CAPABILITY,
4005
4145
  BY_YOU,
4006
4146
  isQuiet,
4147
+ BRIEF_LIMITS,
4148
+ BRIEF_DONE_WHEN,
4149
+ BRIEF_ALLOW,
4150
+ briefText,
4151
+ grantsIn,
4007
4152
  taskMessage,
4008
4153
  parseTask,
4009
4154
  threadMessage,
@@ -4045,5 +4190,6 @@ export {
4045
4190
  optimizeScriptPrompt,
4046
4191
  expandSlash,
4047
4192
  parseGitHubLink,
4048
- UPDATE_RULE
4193
+ UPDATE_RULE,
4194
+ APP_FILES_RULE
4049
4195
  };
@@ -1,13 +1,15 @@
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-6NJSSOB6.js";
4
+ } from "./chunk-QSETYM2Y.js";
5
5
  import {
6
6
  writeFileAtomic
7
7
  } from "./chunk-RESS7WVY.js";
8
8
  import {
9
9
  BY_YOU,
10
+ DECISION_AREAS,
10
11
  NOTIFY_CAPABILITY,
12
+ briefText,
11
13
  isQuiet,
12
14
  parseRelay,
13
15
  parseTask,
@@ -20,7 +22,7 @@ import {
20
22
  threadMessage,
21
23
  threadReminder,
22
24
  threadsBetween
23
- } from "./chunk-LXHF6AKU.js";
25
+ } from "./chunk-34VNH3YS.js";
24
26
  import {
25
27
  external_exports
26
28
  } from "./chunk-6DSSLS7I.js";
@@ -755,6 +757,9 @@ var HANDED = (agent) => `\u5DF2\u4EA4\u7ED9\u300C${agent}\u300D\u3002\u5B83\u572
755
757
  var Args2 = external_exports.object({
756
758
  agent: external_exports.string().trim().min(1).max(40),
757
759
  task: external_exports.string().trim().min(1).max(8e3),
760
+ limits: external_exports.string().trim().max(2e3).nullish(),
761
+ allow: external_exports.array(external_exports.string().trim()).max(DECISION_AREAS.length).nullish(),
762
+ done_when: external_exports.string().trim().min(1).max(2e3),
758
763
  expecting: external_exports.string().trim().max(2e3).nullish()
759
764
  });
760
765
  function delegateTool(deps) {
@@ -771,17 +776,23 @@ function delegateTool(deps) {
771
776
  description: [
772
777
  "\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
778
  "\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",
779
+ "\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",
780
+ "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",
781
+ "\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",
782
+ `\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
783
  `\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
784
  ].join(""),
777
785
  parameters: {
778
786
  type: "object",
779
787
  properties: {
780
788
  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" }
789
+ 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
+ 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
+ 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" },
792
+ 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" },
793
+ 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
794
  },
784
- required: ["agent", "task"],
795
+ required: ["agent", "task", "done_when"],
785
796
  additionalProperties: false
786
797
  },
787
798
  output: { schema: {}, render: (_args, value) => [{ type: "text", text: HANDED(value.agent) }] },
@@ -790,7 +801,11 @@ function delegateTool(deps) {
790
801
  const parsed = Args2.safeParse(args ?? {});
791
802
  if (!parsed.success)
792
803
  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;
804
+ const { agent: wanted, task: goal, limits, allow, done_when: doneWhen, expecting } = parsed.data;
805
+ const unknownKinds = (allow ?? []).filter((kind) => !DECISION_AREAS.some((a) => a.id === kind));
806
+ if (unknownKinds.length > 0)
807
+ 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")}`);
808
+ const task = briefText(goal, { limits: limits ?? void 0, doneWhen, allow: allow ?? void 0 });
794
809
  const parent = exec.agent?.session.id;
795
810
  if (parent === void 0)
796
811
  throw new Error("\u53EA\u80FD\u5728\u4F1A\u8BDD\u91CC\u4EA4\u51FA\u53BB");