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.
@@ -378,8 +378,11 @@ var ScriptSkillItem = external_exports.object({
378
378
  /** Its folder in the script directory. */
379
379
  path: external_exports.string(),
380
380
  problem: external_exports.string().optional(),
381
- /** Among this app's skills: under which name, whether it is the script's current version, whether it was changed here. */
382
- 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()
383
386
  });
384
387
  var ById = external_exports.object({ id: ScriptId });
385
388
  var ScriptRequests = {
@@ -955,6 +958,8 @@ var ChatNotice = external_exports.object({
955
958
  channels: external_exports.array(external_exports.string()),
956
959
  /** It came with a picture (a screenshot), sent to the chat apps only. */
957
960
  image: external_exports.boolean().optional(),
961
+ /** The agent whose conversation shows it and is told of it (the daily report: `games`); absent: 助手's (`main`). */
962
+ agent: external_exports.string().optional(),
958
963
  /** Its buttons no longer apply (dealt with, or over): what came of it. */
959
964
  done: external_exports.string().optional(),
960
965
  /** Someone picked one of its actions: who, which, what came of it. */
@@ -2016,7 +2021,7 @@ var PERMISSIONS_CAPABILITY = "permissions";
2016
2021
  var PermissionMode = external_exports.enum(["ask", "full"]);
2017
2022
  var AreaPolicy = external_exports.enum(["default", "allow", "ask", "deny"]);
2018
2023
  var AGENT_AREAS = [
2019
- { id: "pipelines-edit", title: "\u7F16\u8F91\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6", description: "\u8D77\u8349\u6D41\u6C34\u7EBF\uFF0C\u300C\u7F16\u6392\u300D\u76F4\u63A5\u4FEE\u6539\u3001\u4FDD\u5B58\u6D41\u6C34\u7EBF\uFF08pipeline_save\uFF09\uFF0C\u8BBE\u5B9A\u65F6\u95F4\uFF08schedule_set\uFF09\uFF0C\u4EE5\u53CA dsh \u81EA\u5DF1\u7684\u5B9A\u65F6\u4EFB\u52A1\u3002", tools: ["pipeline_draft", "pipeline_save", "schedule_set", "schedule_create", "schedule_edit"] },
2024
+ { id: "pipelines-edit", title: "\u7F16\u8F91\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6", description: "\u8D77\u8349\u6D41\u6C34\u7EBF\uFF0C\u300C\u7F16\u6392\u52A9\u624B\u300D\u76F4\u63A5\u4FEE\u6539\u3001\u4FDD\u5B58\u6D41\u6C34\u7EBF\uFF08pipeline_save\uFF09\uFF0C\u8BBE\u5B9A\u65F6\u95F4\uFF08schedule_set\uFF09\uFF0C\u4EE5\u53CA dsh \u81EA\u5DF1\u7684\u5B9A\u65F6\u4EFB\u52A1\u3002", tools: ["pipeline_draft", "pipeline_save", "schedule_set", "schedule_create", "schedule_edit"] },
2020
2025
  { id: "run", title: "\u8FD0\u884C\u6D41\u6C34\u7EBF\u548C\u811A\u672C", description: "\u542F\u52A8\u3001\u505C\u6B62\u6D41\u6C34\u7EBF\u548C\u811A\u672C\u4EFB\u52A1\uFF0C\u901A\u8FC7\u811A\u672C\u81EA\u5E26\u7684 MCP \u670D\u52A1\u64CD\u63A7\u811A\u672C\u3002", tools: ["pipeline_run", "script_run", "script_stop", "script_mcp_call"] },
2021
2026
  { id: "scripts-config", title: "\u6539\u811A\u672C\u914D\u7F6E", description: "\u4FEE\u6539\u811A\u672C\u7684\u914D\u7F6E\u526F\u672C\u3001\u5BFC\u5165\u914D\u7F6E\u3001\u65B0\u5EFA\u9009\u9879\u3001\u6253\u5F00\u811A\u672C\u81EA\u5DF1\u7684\u8BBE\u7F6E\u754C\u9762\u3001\u8BBE\u7F6E\u6E38\u620F\u4F4D\u7F6E\u3002", tools: ["script_config_set", "script_config_import", "script_choice_create", "script_settings", "game_path_set"] },
2022
2027
  { id: "scripts-install", title: "\u5B89\u88C5\u3001\u66F4\u65B0\u3001\u5220\u9664\u811A\u672C", description: "\u4ECE GitHub \u5B89\u88C5\u3001\u66F4\u65B0\u3001\u56DE\u6EDA\u3001\u5220\u9664\u811A\u672C\uFF0C\u8FD0\u884C\u811A\u672C\u7684\u5B89\u88C5\u7A0B\u5E8F\uFF0C\u5BFC\u5165\u672C\u5730\u811A\u672C\uFF0C\u4FEE\u590D\u8FD0\u884C\u73AF\u5883\uFF0C\u5199\u3001\u6539\u811A\u672C\u5305\uFF08pack_propose\uFF0C\u76F4\u63A5\u751F\u6548\uFF09\u3002", tools: ["script_install", "script_update", "script_rollback", "script_remove", "script_setup_run", "script_import", "script_env_fix", "pack_propose"] },
@@ -2031,6 +2036,21 @@ var AGENT_AREAS = [
2031
2036
  function areaOf(toolName) {
2032
2037
  return AGENT_AREAS.find((a) => a.tools.includes(toolName));
2033
2038
  }
2039
+ var DECISION_AREAS = [
2040
+ { 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"] },
2041
+ { 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"] },
2042
+ { id: "pipelines-edit", title: "\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6", tools: ["pipeline_save", "schedule_set"] },
2043
+ { id: "skills", title: "\u4FDD\u5B58\u6280\u80FD", tools: ["skill_save", "script_skills_import", "skill_hub_install"] },
2044
+ { 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"] }
2045
+ ];
2046
+ function decisionOf(toolName, args) {
2047
+ const area = DECISION_AREAS.find((a) => a.tools.includes(toolName));
2048
+ if (area === void 0)
2049
+ return void 0;
2050
+ if (toolName === "game_routine")
2051
+ return args?.action === "add" ? area : void 0;
2052
+ return area;
2053
+ }
2034
2054
  var PermissionsState = external_exports.object({
2035
2055
  mode: PermissionMode,
2036
2056
  /** When the mode last changed. */
@@ -2235,6 +2255,33 @@ var THREAD_LINE = /^(这件事的线索是 (\S+):做的过程中要问清楚
2235
2255
  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`;
2236
2256
  var PAST_LINE = /^(你和.{1,20}之前的来往,/;
2237
2257
  var PAST_END = "\uFF09";
2258
+ var BRIEF_LIMITS = "\u8FB9\u754C";
2259
+ var BRIEF_DONE_WHEN = "\u5B8C\u6210\u6807\u51C6";
2260
+ var BRIEF_ALLOW = "\u5141\u8BB8\u76F4\u63A5\u505A\u7684\u6539\u52A8";
2261
+ function briefText(task, parts) {
2262
+ const allowed = DECISION_AREAS.filter((area) => parts.allow?.includes(area.id) === true);
2263
+ const lines = [
2264
+ ...parts.limits?.trim() ? [`${BRIEF_LIMITS}\uFF1A${parts.limits.trim()}`] : [],
2265
+ ...allowed.length > 0 ? [`${BRIEF_ALLOW}\uFF1A${allowed.map((area) => `${area.title}\uFF08${area.id}\uFF09`).join("\u3001")}`] : [],
2266
+ ...parts.doneWhen?.trim() ? [`${BRIEF_DONE_WHEN}\uFF1A${parts.doneWhen.trim()}`] : []
2267
+ ];
2268
+ return lines.length === 0 ? task.trim() : `${task.trim()}
2269
+
2270
+ ${lines.join("\n")}`;
2271
+ }
2272
+ function grantsIn(brief) {
2273
+ if (brief.trimStart().startsWith(`\uFF08\u4F60\u5728\u8F6F\u4EF6\u91CC\u70B9\u7684\uFF1A`))
2274
+ return new Set(DECISION_AREAS.map((area) => area.id));
2275
+ const at = brief.search(new RegExp(`${BRIEF_ALLOW}[\uFF1A:]`));
2276
+ if (at === -1)
2277
+ return /* @__PURE__ */ new Set();
2278
+ const rest = brief.slice(at + BRIEF_ALLOW.length + 1).split("\n")[0];
2279
+ const stop = rest.search(new RegExp(`[\u3002\uFF1B;]|(${BRIEF_LIMITS}|${BRIEF_DONE_WHEN}|\u5E26\u56DE|\u8981\u4EA4\u56DE\u7684|\u76EE\u6807)[\uFF1A:]`));
2280
+ const named = stop === -1 ? rest : rest.slice(0, stop);
2281
+ if (/全部|所有/.test(named))
2282
+ return new Set(DECISION_AREAS.map((area) => area.id));
2283
+ return new Set(DECISION_AREAS.filter((area) => named.includes(area.id) || named.includes(area.title)).map((area) => area.id));
2284
+ }
2238
2285
  function taskMessage(by, title, body, returns = false, thread, past) {
2239
2286
  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`;
2240
2287
  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`]];
@@ -3204,6 +3251,17 @@ var Role = external_exports.object({
3204
3251
  /** Position in the list (smaller first). */
3205
3252
  order: external_exports.number()
3206
3253
  });
3254
+ var MAIN_AGENT_NAME = "MultiGameAssistant";
3255
+ var FORMER_AGENT_NAMES = {
3256
+ main: "\u52A9\u624B",
3257
+ games: "\u6E38\u620F",
3258
+ scripts: "\u811A\u672C",
3259
+ pipelines: "\u7F16\u6392",
3260
+ intervene: "\u5E72\u9884"
3261
+ };
3262
+ function isAgentNamed(agent, wanted) {
3263
+ return wanted === agent.id || wanted === agent.name || wanted === FORMER_AGENT_NAMES[agent.id];
3264
+ }
3207
3265
  var QueuedPrompt = external_exports.object({
3208
3266
  /** Queue item id (for `session/queue/update`). */
3209
3267
  id: external_exports.string(),
@@ -3887,7 +3945,8 @@ function optimizeScriptPrompt(target, why, id) {
3887
3945
  " \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",
3888
3946
  "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",
3889
3947
  "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",
3890
- "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\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\u3002"
3948
+ "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",
3949
+ "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"
3891
3950
  ].join("\n");
3892
3951
  }
3893
3952
  var COMMANDS = [
@@ -3918,7 +3977,7 @@ var COMMANDS = [
3918
3977
  expand: (arg) => [
3919
3978
  `\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`,
3920
3979
  "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",
3921
- "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",
3980
+ "2. \u6392\u597D\u540E\u4FDD\u5B58\uFF1A\u4F60\u662F\u300C\u7F16\u6392\u52A9\u624B\u300D\u5C31\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF1B\u4E0D\u662F\u5C31\u6574\u4EF6\u4E8B\u4EA4\u7ED9\u300C\u7F16\u6392\u52A9\u624B\u300D\uFF08agent_delegate\uFF09\u53BB\u6392\u548C\u4FDD\u5B58\uFF0C\u53EA\u6709\u6CA1\u6709\u300C\u7F16\u6392\u52A9\u624B\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",
3922
3981
  "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"
3923
3982
  ].join("\n")
3924
3983
  },
@@ -4088,6 +4147,8 @@ export {
4088
4147
  AreaPolicy,
4089
4148
  AGENT_AREAS,
4090
4149
  areaOf,
4150
+ DECISION_AREAS,
4151
+ decisionOf,
4091
4152
  QUESTIONS_CAPABILITY,
4092
4153
  INSTANCES_CAPABILITY,
4093
4154
  SKILLS_CAPABILITY,
@@ -4096,6 +4157,11 @@ export {
4096
4157
  SKILLHUB_CAPABILITY,
4097
4158
  BY_YOU,
4098
4159
  isQuiet,
4160
+ BRIEF_LIMITS,
4161
+ BRIEF_DONE_WHEN,
4162
+ BRIEF_ALLOW,
4163
+ briefText,
4164
+ grantsIn,
4099
4165
  taskMessage,
4100
4166
  parseTask,
4101
4167
  threadMessage,
@@ -4127,6 +4193,9 @@ export {
4127
4193
  MemoryEntry,
4128
4194
  RUNS_CAPABILITY,
4129
4195
  DEEPSEEK_API_KEY,
4196
+ MAIN_AGENT_NAME,
4197
+ FORMER_AGENT_NAMES,
4198
+ isAgentNamed,
4130
4199
  AGENTS_CAPABILITY,
4131
4200
  ProviderApi,
4132
4201
  Requests,
@@ -5,11 +5,11 @@ import {
5
5
  launchCommand,
6
6
  renderTask,
7
7
  require_dist
8
- } from "./chunk-TXW3NMBH.js";
8
+ } from "./chunk-7UJ3LK3G.js";
9
9
  import {
10
10
  RUNS_CAPABILITY,
11
11
  ScriptId
12
- } from "./chunk-7EFZ5KR6.js";
12
+ } from "./chunk-BB2T4JHF.js";
13
13
  import {
14
14
  external_exports
15
15
  } from "./chunk-6DSSLS7I.js";
@@ -243,29 +243,63 @@ var LaunchStore = class {
243
243
  return next;
244
244
  }
245
245
  };
246
+ function conditionText(condition) {
247
+ if (condition.note !== void 0)
248
+ return condition.note;
249
+ const key = condition.path.findLast((seg) => typeof seg === "string");
250
+ return `\u811A\u672C\u8BBE\u7F6E\u91CC\u6253\u5F00\u4E86 ${key ?? condition.file}`;
251
+ }
246
252
  function describeSelfLaunch(game) {
247
253
  if (game === void 0 || game.selfLaunch === "never")
248
254
  return "\u811A\u672C\u4E0D\u4F1A\u81EA\u5DF1\u542F\u52A8\u6E38\u620F";
249
255
  if (game.selfLaunch === "always")
250
256
  return "\u811A\u672C\u81EA\u5DF1\u4F1A\u542F\u52A8\u6E38\u620F";
251
- return `\u811A\u672C\u8BBE\u7F6E\u91CC\u6253\u5F00\u4E86 ${game.selfLaunch.map((c) => c.path.at(-1)).join(" / ")} \u65F6\uFF0C\u811A\u672C\u81EA\u5DF1\u4F1A\u542F\u52A8\u6E38\u620F`;
257
+ return `${[...new Set(game.selfLaunch.map(conditionText))].join("\uFF0C\u6216")}\u65F6\uFF0C\u811A\u672C\u81EA\u5DF1\u4F1A\u542F\u52A8\u6E38\u620F`;
252
258
  }
253
- async function scriptLaunchesGame(game, scriptDir) {
259
+ async function scriptLaunchesGame(game, scriptDir, params = {}) {
254
260
  if (game === void 0 || game.selfLaunch === "never")
255
- return false;
261
+ return void 0;
256
262
  if (game.selfLaunch === "always")
257
- return true;
263
+ return "\u811A\u672C\u81EA\u5DF1\u4F1A\u542F\u52A8\u6E38\u620F";
258
264
  for (const condition of game.selfLaunch) {
259
265
  try {
260
- let node = parseConfig(condition.file, await readFile2(inside(scriptDir, condition.file), "utf8"));
261
- for (const key of condition.path)
262
- node = node !== null && typeof node === "object" ? node[key] : void 0;
263
- if (node !== void 0 && String(node).toLowerCase() === String(condition.equals).toLowerCase())
264
- return true;
266
+ const node = valueAt(parseConfig(condition.file, await readFile2(inside(scriptDir, condition.file), "utf8")), condition.path, params);
267
+ if (node === void 0)
268
+ continue;
269
+ if (condition.equals !== void 0 ? same(node, condition.equals) : someMatches(node, condition.some ?? {}))
270
+ return conditionText(condition);
265
271
  } catch {
266
272
  }
267
273
  }
268
- return false;
274
+ return void 0;
275
+ }
276
+ function valueAt(data, path, params) {
277
+ let node = data;
278
+ for (const seg of path) {
279
+ if (node === null || typeof node !== "object")
280
+ return void 0;
281
+ if (typeof seg === "object") {
282
+ if (!Array.isArray(node))
283
+ return void 0;
284
+ const wanted = seg.where.equals.replace(/\{([A-Za-z][A-Za-z0-9_.]*)\}/g, (whole, name) => params[name] === void 0 ? whole : String(params[name]));
285
+ if (/\{[A-Za-z][A-Za-z0-9_.]*\}/.test(wanted))
286
+ return void 0;
287
+ node = node.find((item) => item !== null && typeof item === "object" && String(item[seg.where.field]) === wanted);
288
+ } else {
289
+ node = node[seg];
290
+ }
291
+ }
292
+ return node;
293
+ }
294
+ function same(value, expected) {
295
+ return value !== null && typeof value !== "object" && String(value).toLowerCase() === String(expected).toLowerCase();
296
+ }
297
+ function someMatches(node, fields) {
298
+ const items = Array.isArray(node) ? node : node !== null && typeof node === "object" ? [node] : [];
299
+ return items.some((item) => item !== null && typeof item === "object" && Object.entries(fields).every(([field2, want]) => {
300
+ const value = item[field2];
301
+ return typeof want === "object" ? value !== null && typeof value !== "object" && value !== void 0 && new RegExp(want.match, "i").test(String(value)) : same(value, want);
302
+ }));
269
303
  }
270
304
  var CLOSE_GRACE_MS = 15e3;
271
305
  async function closeGame(stop) {
@@ -315,10 +349,12 @@ async function ensureGame(start) {
315
349
  const sleep = start.sleep ?? delay;
316
350
  const startupMs = (game?.startupSeconds ?? 30) * 1e3;
317
351
  const name = game?.name ?? "\u6E38\u620F";
318
- if (settings.mode === "auto" && await scriptLaunchesGame(game, start.scriptDir)) {
319
- if (game !== void 0)
320
- line(`${name}\u7531\u811A\u672C\u81EA\u5DF1\u542F\u52A8`);
321
- return;
352
+ if (settings.mode === "auto") {
353
+ const why = await scriptLaunchesGame(game, start.scriptDir, start.params);
354
+ if (why !== void 0) {
355
+ line(`${name}\u7531\u811A\u672C\u81EA\u5DF1\u542F\u52A8\uFF08${why}\uFF09\uFF0C\u672C\u5E94\u7528\u4E0D\u518D\u542F\u52A8`);
356
+ return;
357
+ }
322
358
  }
323
359
  if (start.input === "adb") {
324
360
  const pkg = settings.androidPackage ?? game?.android?.package;
@@ -1511,16 +1547,7 @@ var Runner = class {
1511
1547
  */
1512
1548
  async readLog(runId, query = {}) {
1513
1549
  const dir = join6(this.#options.dataDir, "runs", runId);
1514
- let all = await readRunLog(dir);
1515
- if (all === void 0) {
1516
- const memory = this.#runs.get(runId);
1517
- if (memory !== void 0 && (memory.archived !== true || memory.lines.length > 0))
1518
- all = memory.lines;
1519
- else if (await stat4(join6(dir, "run.json")).then(() => true, () => false))
1520
- throw new Error(`${runId} \u7684\u65E5\u5FD7\u5DF2\u6309\u4FDD\u7559\u89C4\u5219\u6E05\u7406\uFF08\u6BCF\u4E2A\u811A\u672C\u53EA\u7559\u6700\u8FD1\u7EA6 ${SCRIPT_LOG_BUDGET / 1024 / 1024} MiB \u7684\u8FD0\u884C\u65E5\u5FD7\uFF09`);
1521
- else
1522
- throw new Error(`\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55 ${runId}`);
1523
- }
1550
+ const all = await this.allLines(runId);
1524
1551
  const file = await runLogFile(dir);
1525
1552
  const pattern = query.search === void 0 || query.search === "" ? void 0 : toPattern(query.search);
1526
1553
  const numbered = all.map((line, i) => ({ ...line, n: i + 1 })).filter((l) => (query.levels === void 0 || query.levels.length === 0 || l.level !== void 0 && query.levels.includes(l.level)) && (pattern === void 0 || pattern.test(l.text)));
@@ -1528,6 +1555,19 @@ var Runner = class {
1528
1555
  const lines = query.fromLine === void 0 ? numbered.slice(-limit) : numbered.filter((l) => l.n >= query.fromLine).slice(0, limit);
1529
1556
  return { file, total: all.length, matched: numbered.length, lines };
1530
1557
  }
1558
+ /** Every line of a run's log: the saved one, or what is in memory for a run not saved yet. */
1559
+ async allLines(runId) {
1560
+ const dir = join6(this.#options.dataDir, "runs", runId);
1561
+ const saved = await readRunLog(dir);
1562
+ if (saved !== void 0)
1563
+ return saved;
1564
+ const memory = this.#runs.get(runId);
1565
+ if (memory !== void 0 && (memory.archived !== true || memory.lines.length > 0))
1566
+ return memory.lines;
1567
+ if (await stat4(join6(dir, "run.json")).then(() => true, () => false))
1568
+ throw new Error(`${runId} \u7684\u65E5\u5FD7\u5DF2\u6309\u4FDD\u7559\u89C4\u5219\u6E05\u7406\uFF08\u6BCF\u4E2A\u811A\u672C\u53EA\u7559\u6700\u8FD1\u7EA6 ${SCRIPT_LOG_BUDGET / 1024 / 1024} MiB \u7684\u8FD0\u884C\u65E5\u5FD7\uFF09`);
1569
+ throw new Error(`\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55 ${runId}`);
1570
+ }
1531
1571
  /**
1532
1572
  * Runs from before a restart, from their saved records; a run cut off by
1533
1573
  * the restart is marked failed. Old run folders are removed.
@@ -1879,6 +1919,7 @@ var Runner = class {
1879
1919
  settings: await this.launch.get(scriptId),
1880
1920
  input: resources.input,
1881
1921
  scriptDir: dir,
1922
+ params: rendered.params,
1882
1923
  address: vars["adb"],
1883
1924
  android: this.#options.emulators?.(),
1884
1925
  signal: run.controller.signal,
@@ -2412,8 +2453,8 @@ async function writeConfig(library, profiles, dataDir, scriptId, file, path, val
2412
2453
  const { manifest, dir } = packFor(library, scriptId);
2413
2454
  allowed(manifest, file);
2414
2455
  const profile = await profiles.resolve(scriptId, profileRef);
2415
- const stamp = new Date(now).toISOString().replace(/[:.]/g, "-");
2416
- const historyDir = join7(dataDir, "config-history", scriptId, profile.id === DEFAULT_PROFILE ? stamp : `${stamp}-${profile.id}`);
2456
+ const stamp2 = new Date(now).toISOString().replace(/[:.]/g, "-");
2457
+ const historyDir = join7(dataDir, "config-history", scriptId, profile.id === DEFAULT_PROFILE ? stamp2 : `${stamp2}-${profile.id}`);
2417
2458
  await profiles.write(scriptId, dir, manifest, file, path, value, historyDir, profile.id);
2418
2459
  return { file, backup: join7(historyDir, file), copy: "local", profile: profile.name };
2419
2460
  }
@@ -2894,6 +2935,59 @@ function runnerTools(runner, config) {
2894
2935
  ];
2895
2936
  }
2896
2937
 
2938
+ // packages/runner/lib/export.js
2939
+ import { mkdir as mkdir5, writeFile as writeFile5 } from "node:fs/promises";
2940
+ import { join as join8 } from "node:path";
2941
+ var pad = (n) => String(n).padStart(2, "0");
2942
+ var stamp = (at) => {
2943
+ const d = new Date(at);
2944
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}_${pad(d.getHours())}-${pad(d.getMinutes())}-${pad(d.getSeconds())}`;
2945
+ };
2946
+ var full = (at) => {
2947
+ const d = new Date(at);
2948
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
2949
+ };
2950
+ var clock = (at) => {
2951
+ const d = new Date(at);
2952
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
2953
+ };
2954
+ var safe = (name) => name.replace(/[\\/:*?"<>|]/g, "_");
2955
+ function runLogsPart(runner) {
2956
+ return {
2957
+ name: "runs",
2958
+ title: "\u811A\u672C\u8FD0\u884C\u65E5\u5FD7",
2959
+ async write({ since, until }, dir, { mask, signal }) {
2960
+ const runs = runner.list().filter((r) => r.startedAt >= since && r.startedAt < until).sort((a, b) => a.startedAt - b.startedAt);
2961
+ if (runs.length === 0)
2962
+ return { files: 0, summary: "\u8FD9\u6BB5\u65F6\u95F4\u6CA1\u6709\u811A\u672C\u8FD0\u884C" };
2963
+ await mkdir5(dir, { recursive: true });
2964
+ const gone = [];
2965
+ for (const run of runs) {
2966
+ signal.throwIfAborted();
2967
+ let lines = [];
2968
+ try {
2969
+ lines = await runner.allLines(run.id);
2970
+ } catch (error) {
2971
+ gone.push(`${run.id}\uFF08${error instanceof Error ? error.message : String(error)}\uFF09`);
2972
+ }
2973
+ const head = [
2974
+ `\u8FD0\u884C ${run.id}`,
2975
+ `\u811A\u672C ${run.scriptName}\uFF08${run.scriptId}\uFF09\uFF0C${run.kind === "settings" ? "\u8BBE\u7F6E\u754C\u9762" : `\u4EFB\u52A1 ${run.taskTitle}\uFF08${run.taskId}\uFF09`}`,
2976
+ `\u5F00\u59CB ${full(run.startedAt)}${run.endedAt === void 0 ? "\uFF0C\u8FD8\u5728\u8FD0\u884C" : `\uFF0C\u7ED3\u675F ${full(run.endedAt)}`}`,
2977
+ `\u7ED3\u679C ${run.state}${run.outcome === void 0 ? "" : `\uFF1A${mask(run.outcome)}`}${run.exitCode === void 0 ? "" : `\uFF08\u9000\u51FA\u7801 ${run.exitCode}\uFF09`}`,
2978
+ `\u65E5\u5FD7 ${lines.length} \u884C`,
2979
+ ""
2980
+ ];
2981
+ const body = lines.map((l) => `${clock(l.at)} [${l.source}]${l.level === void 0 ? "" : `[${l.level}]`} ${mask(l.text)}`);
2982
+ await writeFile5(join8(dir, safe(`${stamp(run.startedAt)}-${run.scriptId}-${run.taskId}-${run.state}.log`)), `${[...head, ...body].join("\n")}
2983
+ `, "utf8");
2984
+ }
2985
+ const scripts = [...new Set(runs.map((r) => r.scriptName))];
2986
+ return { files: runs.length, summary: `${runs.length} \u6B21\u8FD0\u884C\uFF08${scripts.join("\u3001")}\uFF09${gone.length === 0 ? "" : `\uFF1B\u5176\u4E2D ${gone.length} \u6B21\u7684\u65E5\u5FD7\u62FF\u4E0D\u5230\uFF1A${gone.join("\uFF1B")}`}` };
2987
+ }
2988
+ };
2989
+ }
2990
+
2897
2991
  // packages/runner/lib/index.js
2898
2992
  var ConfigSchema = external_exports.object({
2899
2993
  /** Run records, logs and config backups: `<dataDir>/runs/<id>/`. */
@@ -2956,6 +3050,9 @@ var AdgRunner = class extends Service {
2956
3050
  dispose();
2957
3051
  };
2958
3052
  }));
3053
+ ctx.inject(["adgGateway"], (scoped) => {
3054
+ scoped.effect(() => scoped.adgGateway.exportPart(runLogsPart(runner)), "adg-runner run logs export");
3055
+ });
2959
3056
  ctx.inject(["adgGateway"], (scoped) => {
2960
3057
  scoped.adgGateway.register({
2961
3058
  id: RUNS_CAPABILITY,