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/lib/gateway.js CHANGED
@@ -23,10 +23,10 @@ import {
23
23
  pluginVersion,
24
24
  streamFacts,
25
25
  userSkills
26
- } from "./chunk-6NJSSOB6.js";
27
- import "./chunk-KMVQK5CI.js";
26
+ } from "./chunk-QSETYM2Y.js";
27
+ import "./chunk-M7GNYL5B.js";
28
28
  import "./chunk-RESS7WVY.js";
29
- import "./chunk-LXHF6AKU.js";
29
+ import "./chunk-34VNH3YS.js";
30
30
  import "./chunk-6DSSLS7I.js";
31
31
  import "./chunk-2UFLGPDY.js";
32
32
  export {
package/lib/guard.js CHANGED
@@ -1,49 +1,104 @@
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-LXHF6AKU.js";
4
+ } from "./chunk-34VNH3YS.js";
5
5
  import "./chunk-6DSSLS7I.js";
6
6
  import "./chunk-2UFLGPDY.js";
7
7
 
8
8
  // packages/guard/lib/index.js
9
9
  import { Service } from "@deepseek-ai/cordis";
10
+ import { existsSync } from "node:fs";
11
+ import { basename, dirname, isAbsolute as isAbsolute2, join, relative as relative2, resolve as resolve2 } from "node:path";
10
12
  import { fileURLToPath } from "node:url";
11
13
 
12
14
  // packages/guard/lib/policy.js
13
15
  import { isAbsolute, relative, resolve } from "node:path";
14
- var FILE_TOOLS = /* @__PURE__ */ new Set(["write", "edit", "str_replace_based_edit_tool", "apply_patch", "notebook_edit"]);
16
+ var TOOLS = "_tools";
17
+ var APP_FILES = "_app";
18
+ var APP_DATA = "_app_data";
19
+ var APP_SETTINGS = "_app_settings";
20
+ var APP_ENTRIES = /* @__PURE__ */ new Set([APP_FILES, APP_DATA, APP_SETTINGS]);
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", "history_export"]);
15
23
  var SHELL_TOOLS = /* @__PURE__ */ new Set(["pwsh", "bash", "powershell", "shell", "cmd"]);
16
- var WRITING = /(\bset-content\b|\badd-content\b|\bout-file\b|\bnew-item\b|\bremove-item\b|\bmove-item\b|\bcopy-item\b|\brename-item\b|\bclear-content\b|\bexpand-archive\b|\bcompress-archive\b|\bdel\b|\berase\b|\brd\b|\brmdir\b|\bren\b|\bmove\b|\bcopy\b|\bxcopy\b|\brobocopy\b|\brm\b|\bmv\b|\bcp\b|\btouch\b|\btee\b|\bsed\s+-i\b|\btruncate\b|\bgit\s+(apply|checkout|reset|restore|clean|stash|am|merge|pull)\b|\[io\.file\]::write|\bwritealltext\b|\bwriteallbytes\b|>{1,2})/i;
24
+ var CODE_TOOLS = /* @__PURE__ */ new Set(["run_code"]);
25
+ var AGENT_TOOLS = /* @__PURE__ */ new Set(["subagent"]);
26
+ var WRITING = /(\bset-content\b|\badd-content\b|\bout-file\b|\bnew-item\b|\bremove-item\b|\bmove-item\b|\bcopy-item\b|\brename-item\b|\bclear-content\b|\bexpand-archive\b|\bcompress-archive\b|\bdel\b|\berase\b|\brd\b|\brmdir\b|\bren\b|\bmove\b|\bcopy\b|\bxcopy\b|\brobocopy\b|\brm\b|\bmv\b|\bcp\b|\btouch\b|\btee\b|\bsed\s+-i\b|\btruncate\b|\bgit\b[^;&|\n]*?\s(apply|checkout|reset|restore|clean|stash|am|merge|pull|switch|rebase|cherry-pick|revert|commit)\b|\b(pnpm|npm|yarn|npx|pip3?|uv|poetry|tsc|vite|esbuild|cargo|msbuild|dotnet)\b|\[io\.file\]::write|\bwritealltext\b|\bwriteallbytes\b|>{1,2})/i;
27
+ var CODE_WRITING = /\b(writeFile|appendFile|rm|rmdir|unlink|rename|mkdir|mkdtemp|copyFile|cp|truncate|symlink|chmod|utimes|createWriteStream|execSync|execFile|execFileSync|spawn|spawnSync|fork)(Sync)?\s*\(|\bopen(Sync)?\s*\([^)]*['"`][wa]|\bchild_process\b[\s\S]*\bexec\s*\(/;
28
+ function guardDirs(state) {
29
+ const protectedDirs = [];
30
+ const opened = new Set(state.grants.map((g) => g.scriptId));
31
+ if (!state.fullAccess) {
32
+ for (const script of state.scripts)
33
+ if (!opened.has(script.id))
34
+ for (const dir of script.dirs)
35
+ protectedDirs.push({ scriptId: script.id, dir });
36
+ for (const dir of state.toolsDirs)
37
+ protectedDirs.push({ scriptId: TOOLS, dir });
38
+ }
39
+ protectedDirs.push(...state.app);
40
+ const workspace = state.workspace;
41
+ const allowed = [
42
+ ...workspace !== void 0 && owner(resolve(workspace), state.app) !== void 0 ? [workspace] : [],
43
+ ...state.fullAccess ? [] : state.grants.flatMap((g) => g.dirs)
44
+ ];
45
+ return { protectedDirs, allowed };
46
+ }
17
47
  function judgeCall(call, protectedDirs, allowedDirs = []) {
18
48
  const args = call.args ?? {};
19
49
  const allowed = allowedDirs.map((dir) => ({ scriptId: "", dir }));
50
+ const inside = (path) => owner(path, allowed) === void 0 ? owner(path, protectedDirs) : void 0;
20
51
  if (FILE_TOOLS.has(call.toolName)) {
21
- const path = [args["file_path"], args["path"]].find((v) => typeof v === "string");
22
- if (path === void 0)
23
- return void 0;
24
- const absolute = resolvePath(path, call.cwd);
25
- if (owner(absolute, allowed) !== void 0)
52
+ if (call.toolName === "str_replace_editor" && args["command"] === "view")
26
53
  return void 0;
27
- const hit = owner(absolute, protectedDirs);
28
- return hit === void 0 ? void 0 : { blocked: true, scriptId: hit.scriptId, target: path };
54
+ for (const path of filePaths(call.toolName, args)) {
55
+ const hit = inside(resolvePath(path, call.cwd));
56
+ if (hit !== void 0)
57
+ return { blocked: true, scriptId: hit.scriptId, target: path };
58
+ }
59
+ return void 0;
29
60
  }
30
61
  if (SHELL_TOOLS.has(call.toolName)) {
31
62
  const command = typeof args["command"] === "string" ? args["command"] : "";
32
63
  if (!WRITING.test(stripReadonlyRedirects(command)))
33
64
  return void 0;
34
- const workdir = typeof args["workdir"] === "string" ? resolvePath(args["workdir"], call.cwd) : void 0;
35
- if (workdir !== void 0 && owner(workdir, allowed) === void 0) {
36
- const inWorkdir = owner(workdir, protectedDirs);
37
- if (inWorkdir !== void 0)
38
- return { blocked: true, scriptId: inWorkdir.scriptId, target: workdir };
39
- }
40
- let text = normalize(command);
41
- for (const dir of allowedDirs)
42
- text = text.split(normalize(dir)).join("");
43
- for (const entry of protectedDirs) {
44
- if (text.includes(normalize(entry.dir)))
45
- return { blocked: true, scriptId: entry.scriptId, target: entry.dir };
46
- }
65
+ const workdir = typeof args["workdir"] === "string" ? resolvePath(args["workdir"], call.cwd) : call.cwd === void 0 ? void 0 : resolve(call.cwd);
66
+ const here = workdir === void 0 ? void 0 : inside(workdir);
67
+ if (here !== void 0)
68
+ return { blocked: true, scriptId: here.scriptId, target: workdir };
69
+ return named(command, protectedDirs, allowedDirs);
70
+ }
71
+ if (CODE_TOOLS.has(call.toolName)) {
72
+ const code = typeof args["code"] === "string" ? args["code"] : "";
73
+ if (!CODE_WRITING.test(code))
74
+ return void 0;
75
+ const here = call.cwd === void 0 ? void 0 : inside(resolve(call.cwd));
76
+ if (here !== void 0)
77
+ return { blocked: true, scriptId: here.scriptId, target: call.cwd };
78
+ return named(code, protectedDirs, allowedDirs);
79
+ }
80
+ if (AGENT_TOOLS.has(call.toolName) && typeof args["cwd"] === "string") {
81
+ const dir = resolvePath(args["cwd"], call.cwd);
82
+ const hit = inside(dir);
83
+ if (hit !== void 0 && isAppEntry(hit.scriptId))
84
+ return { blocked: true, scriptId: hit.scriptId, target: args["cwd"] };
85
+ }
86
+ return void 0;
87
+ }
88
+ function filePaths(toolName, args) {
89
+ if (toolName === "apply_patch") {
90
+ const patch = [args["input"], args["patch"]].find((v) => typeof v === "string") ?? "";
91
+ return [...patch.matchAll(/^\*\*\* (?:(?:Add|Update|Delete) File|Move to): *(.+?) *$/gm)].map((m) => m[1]);
92
+ }
93
+ return [args["file_path"], args["path"], args["notebook_path"]].filter((v) => typeof v === "string");
94
+ }
95
+ function named(text, protectedDirs, allowedDirs) {
96
+ let normalized = normalize(text);
97
+ for (const dir of allowedDirs)
98
+ normalized = normalized.split(normalize(dir)).join("");
99
+ for (const entry of protectedDirs) {
100
+ if (normalized.includes(normalize(entry.dir)))
101
+ return { blocked: true, scriptId: entry.scriptId, target: entry.dir };
47
102
  }
48
103
  return void 0;
49
104
  }
@@ -62,14 +117,25 @@ function resolvePath(path, cwd) {
62
117
  function normalize(text) {
63
118
  return text.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/\/$/, "").toLowerCase();
64
119
  }
65
- var APP_FILES = "_app";
66
120
  function denialReason(verdict, scriptName) {
121
+ const always = "\u8FD9\u4E00\u6761\u4E0D\u80FD\u7531 agent \u89E3\u9664\uFF0C\u5B8C\u5168\u8BBF\u95EE\u4E5F\u4E00\u6837\u3002";
67
122
  if (verdict.scriptId === APP_FILES) {
68
123
  return [
69
- `\u5DF2\u62E6\u622A\uFF1A\u8FD9\u662F MultiGameAssistant \u81EA\u5E26\u7684\u6587\u4EF6\uFF08\u5185\u7F6E\u6280\u80FD\u3001\u811A\u672C\u5305\u3001\u6E38\u620F\u5305\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539\uFF08${verdict.target}\uFF09\u3002`,
70
- "\u8F6F\u4EF6\u66F4\u65B0\u65F6\u4F1A\u6574\u4F53\u66FF\u6362\u5B83\u4EEC\u3002\u8981\u8865\u5145\u505A\u6CD5\uFF0C\u7528 skill_save \u53E6\u5B58\u4E00\u4E2A\u81EA\u5DF1\u7684\u6280\u80FD\uFF08\u6280\u80FD\u5E93\u4E0B\u8F7D\u7684\u6280\u80FD\u4E5F\u4E00\u6837\uFF1A\u5B83\u8DDF\u7740\u6280\u80FD\u5E93\u66F4\u65B0\uFF0C\u5728\u672C\u5730\u6539\u4E86\u4F1A\u88AB\u65B0\u7248\u672C\u6362\u6389\uFF09\u3002"
124
+ `\u5DF2\u62E6\u622A\uFF1A\u8FD9\u662F MultiGameAssistant \u81EA\u5DF1\u7684\u7A0B\u5E8F\u6587\u4EF6\uFF08\u6E90\u7801\u3001\u5B89\u88C5\u76EE\u5F55\u3001\u5185\u7F6E\u6280\u80FD\u548C\u5305\uFF09\uFF0Cagent \u4E0D\u80FD\u4FEE\u6539\uFF0C\u4E5F\u4E0D\u8981\u5728\u8FD9\u91CC\u5F00\u5B50 agent \u53BB\u6539\uFF08${verdict.target}\uFF09\u3002`,
125
+ "\u53D1\u73B0\u8F6F\u4EF6\u672C\u8EAB\u7684\u95EE\u9898\u6216\u7F3A\u7684\u529F\u80FD\uFF0C\u544A\u8BC9\u7528\u6237\u73B0\u8C61\u548C\u4F60\u7684\u5224\u65AD\uFF0C\u7531\u7528\u6237\u51B3\u5B9A\u600E\u4E48\u6539\u3002\u8981\u8865\u5145\u505A\u6CD5\uFF0C\u7528 skill_save \u53E6\u5B58\u4E00\u4E2A\u81EA\u5DF1\u7684\u6280\u80FD\u3002",
126
+ always
71
127
  ].join("");
72
128
  }
129
+ if (verdict.scriptId === APP_DATA) {
130
+ return [
131
+ `\u5DF2\u62E6\u622A\uFF1A\u8FD9\u662F MultiGameAssistant \u7684\u6570\u636E\u548C\u8BBE\u7F6E\uFF0C\u4E0D\u80FD\u76F4\u63A5\u6539\u6587\u4EF6\uFF08${verdict.target}\uFF09\u3002`,
132
+ "\u7528\u5BF9\u5E94\u7684\u5DE5\u5177\uFF1A\u811A\u672C\u5305\u7528 pack_propose\uFF0C\u6280\u80FD\u7528 skill_save\uFF0C\u65E5\u5E38\u5468\u5E38\u7528 game_routine\uFF0C\u811A\u672C\u8BBE\u7F6E\u7528 script_config_set\uFF1B\u6743\u9650\u3001\u6A21\u578B\u8FD9\u4E9B\u8BBE\u7F6E\u8BF7\u7528\u6237\u5728\u8F6F\u4EF6\u91CC\u6539\u3002",
133
+ always
134
+ ].join("");
135
+ }
136
+ if (verdict.scriptId === APP_SETTINGS) {
137
+ return `\u5DF2\u62E6\u622A\uFF1A\u8FD9\u662F\u8F6F\u4EF6\u8FD0\u884C\u7528\u7684 dsh \u914D\u7F6E\uFF08\u63D2\u4EF6\u3001\u6743\u9650\u3001\u9884\u8BBE\uFF09\uFF0Cagent \u4E0D\u80FD\u4FEE\u6539\uFF08${verdict.target}\uFF09\u3002\u9700\u8981\u6539\u65F6\u544A\u8BC9\u7528\u6237\u3002${always}`;
138
+ }
73
139
  return [
74
140
  `\u5DF2\u62E6\u622A\uFF1A${scriptName} \u7684\u811A\u672C\u76EE\u5F55\u53D7\u4FDD\u62A4\uFF08${verdict.target}\uFF09\u3002`,
75
141
  "\u6CA1\u6709\u7528\u6237\u7684\u660E\u786E\u6388\u6743\u65F6\uFF0C\u4E0D\u80FD\u4FEE\u6539\u811A\u672C\u81EA\u5DF1\u7684\u6587\u4EF6\u3002",
@@ -80,34 +146,75 @@ function denialReason(verdict, scriptName) {
80
146
 
81
147
  // packages/guard/lib/index.js
82
148
  var APP_FILES_DIR = fileURLToPath(new URL("../../", import.meta.url));
83
- var TOOLS = "_tools";
149
+ function appRoot(moduleDir, exists = existsSync) {
150
+ let pkg = resolve2(moduleDir);
151
+ while (!exists(join(pkg, "package.json"))) {
152
+ const up = dirname(pkg);
153
+ if (up === pkg)
154
+ return resolve2(moduleDir);
155
+ pkg = up;
156
+ }
157
+ const parent = dirname(pkg);
158
+ if (basename(parent) === "packages" && exists(join(dirname(parent), "pnpm-workspace.yaml")))
159
+ return dirname(parent);
160
+ if (basename(parent) === "@adg" && basename(dirname(parent)) === "node_modules") {
161
+ const app = dirname(dirname(parent));
162
+ return basename(app).toLowerCase() === "app" && basename(dirname(app)).toLowerCase() === "resources" ? dirname(dirname(app)) : app;
163
+ }
164
+ return pkg;
165
+ }
166
+ var APP_ROOT = appRoot(fileURLToPath(new URL(".", import.meta.url)));
167
+ var within = (path, dir) => {
168
+ const rel = relative2(resolve2(dir), resolve2(path));
169
+ return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
170
+ };
84
171
  var AdgGuard = class extends Service {
85
172
  static inject = ["adgScripts"];
86
173
  grantMap = /* @__PURE__ */ new Map();
87
174
  blocked = 0;
88
- constructor(ctx) {
175
+ constructor(ctx, config = {}) {
89
176
  super(ctx, "adgGuard");
90
177
  const log = ctx.logger("adg-guard");
91
178
  const scripts = ctx.adgScripts;
179
+ const appEdits = process.env["ADG_GUARD_ALLOW_APP_EDITS"] === "1";
180
+ if (appEdits)
181
+ log.warn("ADG_GUARD_ALLOW_APP_EDITS=1: agents may change the app's own program, data and settings");
182
+ const appDirs = () => {
183
+ if (appEdits)
184
+ return [];
185
+ const dirs2 = [{ scriptId: APP_DATA, dir: scripts.library.dataDir }];
186
+ if (ctx.get("adgGateway")?.shared !== true)
187
+ for (const dir of config.settingsDirs ?? [])
188
+ dirs2.push({ scriptId: APP_SETTINGS, dir });
189
+ dirs2.push({ scriptId: APP_FILES, dir: APP_ROOT });
190
+ return dirs2;
191
+ };
92
192
  const dirs = () => {
93
- const open = new Map(this.grants().map((g) => [g.scriptId, g]));
94
- const protectedDirs = [];
95
- for (const script of scripts.library.list().scripts) {
96
- if (open.has(script.id))
97
- continue;
98
- for (const version of script.versions)
99
- protectedDirs.push({ scriptId: script.id, dir: version.dir });
193
+ const gateway = ctx.get("adgGateway");
194
+ return guardDirs({
195
+ fullAccess: gateway?.fullAccess() === true,
196
+ scripts: scripts.library.list().scripts.map((s) => ({ id: s.id, dirs: s.versions.map((v) => v.dir) })),
197
+ toolsDirs: [scripts.library.toolsDir, ...scripts.library.formerToolsDirs],
198
+ grants: this.grants(),
199
+ app: appDirs(),
200
+ workspace: gateway?.workspaceDir()
201
+ });
202
+ };
203
+ const cwdOf = (agent) => {
204
+ if (agent === void 0)
205
+ return void 0;
206
+ try {
207
+ const service = ctx.get("workingDirectory");
208
+ return service?.get(agent.session);
209
+ } catch {
210
+ return void 0;
100
211
  }
101
- for (const dir of [scripts.library.toolsDir, ...scripts.library.formerToolsDirs])
102
- protectedDirs.push({ scriptId: TOOLS, dir });
103
- protectedDirs.push({ scriptId: APP_FILES, dir: APP_FILES_DIR });
104
- return { protectedDirs, allowed: [...open.values()].flatMap((g) => g.dirs) };
105
212
  };
106
213
  ctx.on("tools/pre-execute", async (exec, next) => {
107
- if (ctx.get("adgGateway")?.fullAccess() === true)
108
- return next();
109
214
  const { protectedDirs, allowed } = dirs();
110
- const verdict = judgeCall({ toolName: exec.name, args: exec.arguments }, protectedDirs, allowed);
215
+ if (protectedDirs.length === 0)
216
+ return next();
217
+ const verdict = judgeCall({ toolName: exec.name, args: exec.arguments, cwd: cwdOf(exec.agent) }, protectedDirs, allowed);
111
218
  if (verdict === void 0)
112
219
  return next();
113
220
  this.blocked += 1;
@@ -132,6 +239,9 @@ var AdgGuard = class extends Service {
132
239
  "guard/grant": (params) => {
133
240
  const p = params;
134
241
  const script = scripts.library.get(p.scriptId);
242
+ const app = appDirs().find((entry) => script.versions.some((v) => within(v.dir, entry.dir)));
243
+ if (app !== void 0)
244
+ throw new Error(`${script.name} \u5728\u8F6F\u4EF6\u81EA\u5DF1\u7684\u6587\u4EF6\u5939\u91CC\uFF08${app.dir}\uFF09\uFF0C\u4E0D\u80FD\u5F00\u542F\u4FEE\u6539\u6388\u6743`);
135
245
  const now = Date.now();
136
246
  const grant = { scriptId: p.scriptId, dir: script.dir ?? "", grantedAt: now, expiresAt: now + p.minutes * 6e4, dirs: script.versions.map((v) => v.dir) };
137
247
  this.grantMap.set(p.scriptId, grant);
@@ -160,10 +270,17 @@ var AdgGuard = class extends Service {
160
270
  };
161
271
  var lib_default = AdgGuard;
162
272
  export {
273
+ APP_DATA,
163
274
  APP_FILES,
164
275
  APP_FILES_DIR,
276
+ APP_ROOT,
277
+ APP_SETTINGS,
165
278
  AdgGuard,
279
+ TOOLS,
280
+ appRoot,
166
281
  lib_default as default,
167
282
  denialReason,
283
+ guardDirs,
284
+ isAppEntry,
168
285
  judgeCall
169
286
  };
package/lib/intervene.js CHANGED
@@ -2,16 +2,16 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
2
2
  import {
3
3
  finalText,
4
4
  sessionConversations
5
- } from "./chunk-A6YQRWHZ.js";
6
- import "./chunk-6NJSSOB6.js";
7
- import "./chunk-KMVQK5CI.js";
5
+ } from "./chunk-4QXRDWGS.js";
6
+ import "./chunk-QSETYM2Y.js";
7
+ import "./chunk-M7GNYL5B.js";
8
8
  import {
9
9
  writeFileAtomic
10
10
  } from "./chunk-RESS7WVY.js";
11
11
  import {
12
12
  INTERVENE_CAPABILITY,
13
13
  UPDATE_RULE
14
- } from "./chunk-LXHF6AKU.js";
14
+ } from "./chunk-34VNH3YS.js";
15
15
  import {
16
16
  external_exports
17
17
  } from "./chunk-6DSSLS7I.js";
@@ -28,6 +28,7 @@ var INTERVENE_ROLE = {
28
28
  id: "intervene",
29
29
  name: "\u5E72\u9884",
30
30
  description: "\u811A\u672C\u51FA\u9519\u3001\u5361\u4F4F\u65F6\u5904\u7406",
31
+ handles: "\u811A\u672C\u8FD0\u884C\u4E2D\u51FA\u9519\u3001\u5361\u4F4F\u3001\u8D85\u65F6\u65F6\u63A5\u624B\uFF08\u901A\u5E38\u662F\u76D1\u63A7\u81EA\u52A8\u4EA4\u7ED9\u5B83\uFF09\uFF1A\u770B\u65E5\u5FD7\u548C\u753B\u9762\uFF0C\u91CD\u8DD1\u3001\u6539\u914D\u7F6E\u3001\u7ED3\u675F\u5361\u4F4F\u7684\u8FDB\u7A0B\uFF0C\u53EA\u5904\u7406\u8FD9\u4E00\u6B21\u4E8B\u6545\u3002\u5E73\u65F6\u8FD0\u884C\u811A\u672C\u3001\u88C5\u811A\u672C\u627E\u300C\u811A\u672C\u300D\u3002",
31
32
  order: 10,
32
33
  titles: ["\u5E72\u9884"],
33
34
  handedImages: true,
@@ -38,8 +38,8 @@ import {
38
38
  summaryTarget,
39
39
  summaryText,
40
40
  taskOver
41
- } from "./chunk-KMVQK5CI.js";
42
- import "./chunk-LXHF6AKU.js";
41
+ } from "./chunk-M7GNYL5B.js";
42
+ import "./chunk-34VNH3YS.js";
43
43
  import "./chunk-6DSSLS7I.js";
44
44
  import "./chunk-2UFLGPDY.js";
45
45
  export {
package/lib/monitor.js CHANGED
@@ -1,8 +1,8 @@
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
  parseDuration
4
- } from "./chunk-TELJUUBZ.js";
5
- import "./chunk-RGEGJH6R.js";
4
+ } from "./chunk-76UHR2GO.js";
5
+ import "./chunk-C7X2KJ5C.js";
6
6
  import {
7
7
  writeFileAtomic
8
8
  } from "./chunk-RESS7WVY.js";
@@ -10,7 +10,7 @@ import {
10
10
  Incident,
11
11
  MONITOR_CAPABILITY,
12
12
  MonitorSettings
13
- } from "./chunk-LXHF6AKU.js";
13
+ } from "./chunk-34VNH3YS.js";
14
14
  import {
15
15
  external_exports
16
16
  } from "./chunk-6DSSLS7I.js";
package/lib/notify.js CHANGED
@@ -16,11 +16,11 @@ import {
16
16
  replyPlain,
17
17
  sessionConversations,
18
18
  textReply
19
- } from "./chunk-A6YQRWHZ.js";
20
- import "./chunk-6NJSSOB6.js";
21
- import "./chunk-KMVQK5CI.js";
19
+ } from "./chunk-4QXRDWGS.js";
20
+ import "./chunk-QSETYM2Y.js";
21
+ import "./chunk-M7GNYL5B.js";
22
22
  import "./chunk-RESS7WVY.js";
23
- import "./chunk-LXHF6AKU.js";
23
+ import "./chunk-34VNH3YS.js";
24
24
  import "./chunk-6DSSLS7I.js";
25
25
  import "./chunk-2UFLGPDY.js";
26
26
  export {
@@ -4,18 +4,18 @@ import {
4
4
  PARAMS_SCHEMA,
5
5
  parseDuration,
6
6
  taskParams
7
- } from "./chunk-TELJUUBZ.js";
7
+ } from "./chunk-76UHR2GO.js";
8
8
  import {
9
9
  TaskInputError,
10
10
  renderTask
11
- } from "./chunk-RGEGJH6R.js";
11
+ } from "./chunk-C7X2KJ5C.js";
12
12
  import {
13
13
  MAIN,
14
14
  finalText,
15
15
  sessionConversations
16
- } from "./chunk-A6YQRWHZ.js";
17
- import "./chunk-6NJSSOB6.js";
18
- import "./chunk-KMVQK5CI.js";
16
+ } from "./chunk-4QXRDWGS.js";
17
+ import "./chunk-QSETYM2Y.js";
18
+ import "./chunk-M7GNYL5B.js";
19
19
  import {
20
20
  writeFileAtomic
21
21
  } from "./chunk-RESS7WVY.js";
@@ -33,7 +33,7 @@ import {
33
33
  isMarker,
34
34
  taskMessage,
35
35
  withStartEnd
36
- } from "./chunk-LXHF6AKU.js";
36
+ } from "./chunk-34VNH3YS.js";
37
37
  import {
38
38
  external_exports
39
39
  } from "./chunk-6DSSLS7I.js";
@@ -229,9 +229,10 @@ var PIPELINE_ROLE = {
229
229
  id: "pipelines",
230
230
  name: "\u7F16\u6392",
231
231
  description: "\u65B0\u5EFA\u3001\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B83\u4EEC\u7684\u5B9A\u65F6\uFF08\u76F4\u63A5\u4FDD\u5B58\u751F\u6548\uFF09\uFF0C\u8FD0\u884C\u6D41\u6C34\u7EBF\uFF1B\u4E5F\u505A\u6D41\u6C34\u7EBF\u91CC\u4EA4\u7ED9 agent \u7684\u6B65\u9AA4",
232
+ handles: "\u6D41\u6C34\u7EBF\u7684\u4E8B\u4EA4\u7ED9\u5B83\uFF1A\u628A\u51E0\u4E2A\u811A\u672C\u6392\u6210\u6BCF\u5929\u81EA\u52A8\u8DD1\u7684\u6D41\u7A0B\uFF0C\u65B0\u5EFA\u3001\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B83\u4EEC\u7684\u5B9A\u65F6\uFF08\u76F4\u63A5\u4FDD\u5B58\u751F\u6548\uFF09\uFF0C\u8FD0\u884C\u6D41\u6C34\u7EBF\u3001\u67E5\u8FD0\u884C\u72B6\u6001\u3002\u53EA\u662F\u5230\u70B9\u8BA9\u67D0\u4E2A agent \u505A\u4E00\u4EF6\u4E8B\u7684\uFF0C\u7528\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u4E0D\u7528\u6D41\u6C34\u7EBF\u3002",
232
233
  order: 40,
233
234
  titles: ["\u7F16\u6392"],
234
- // Its own tool for pipelines is pipeline_save; drafting (pipeline_draft) is for the agents that cannot save.
235
+ // Its own tool for pipelines is pipeline_save. The app's other agents hand pipeline work to it; drafting (pipeline_draft) is left to chats without it (a shared dsh's).
235
236
  tools: [
236
237
  "script_*",
237
238
  "game_*",
@@ -254,7 +255,7 @@ var PIPELINE_ROLE = {
254
255
  duty: [
255
256
  "# \u4F60\u7684\u89D2\u8272\uFF1A\u7F16\u6392",
256
257
  "\u6D41\u6C34\u7EBF\u5F52\u4F60\u7BA1\uFF1A\u65B0\u5EFA\u3001\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B83\u4EEC\u7684\u5B9A\u65F6\uFF0C\u8FD0\u884C\u6D41\u6C34\u7EBF\uFF0C\u4E5F\u505A\u6D41\u6C34\u7EBF\u91CC\u4EA4\u7ED9 agent \u7684\u6B65\u9AA4\u3002",
257
- "\u6539\u6D41\u6C34\u7EBF\u4E0D\u7528\u7B49\u7528\u6237\u5BA1\u6279\u6216\u5728\u300C\u7F16\u6392\u300D\u9875\u786E\u8BA4\uFF1A\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF0C\u65B0\u5EFA\u7684\u3001\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u90FD\u53EF\u4EE5\uFF0C\u4FDD\u5B58\u540E\u5C31\u751F\u6548\uFF1B\u4F60\u5F00\u7684\u5B50 agent \u4E5F\u53EF\u4EE5\u8FD9\u6837\u4FDD\u5B58\u3002\u4E0D\u8981\u53BB\u6539\u6570\u636E\u76EE\u5F55\u91CC\u7684\u6D41\u6C34\u7EBF\u6587\u4EF6\uFF0C\u4E5F\u4E0D\u8981\u56E0\u4E3A\u300C\u662F\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u300D\u5C31\u9000\u56DE\u53BB\u8BA9\u7528\u6237\u81EA\u5DF1\u5728\u754C\u9762\u4E0A\u6539\u3002",
258
+ "\u6539\u6D41\u6C34\u7EBF\u4E0D\u7528\u7B49\u7528\u6237\u5BA1\u6279\u6216\u5728\u300C\u7F16\u6392\u300D\u9875\u786E\u8BA4\uFF1A\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF0C\u65B0\u5EFA\u7684\u3001\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u90FD\u53EF\u4EE5\uFF0C\u4FDD\u5B58\u540E\u5C31\u751F\u6548\uFF1B\u4F60\u5F00\u7684\u5B50 agent \u8981\u76F4\u63A5\u4FDD\u5B58\uFF0C\u5C31\u5728\u7ED9\u5B83\u7684 prompt \u91CC\u52A0\u4E00\u884C\u300C\u5141\u8BB8\u76F4\u63A5\u505A\u7684\u6539\u52A8\uFF1A\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\u300D\uFF1B\u6CA1\u5199\u7684\u8BDD\uFF0C\u5B83\u4FDD\u5B58\u65F6\u8F6F\u4EF6\u5148\u8BB0\u6210\u5F85\u5B9A\u6539\u52A8\u4EA4\u56DE\u7ED9\u4F60\uFF0C\u4F60\u7528 pending_changes \u51B3\u5B9A\u3002\u4E0D\u8981\u53BB\u6539\u6570\u636E\u76EE\u5F55\u91CC\u7684\u6D41\u6C34\u7EBF\u6587\u4EF6\uFF0C\u4E5F\u4E0D\u8981\u56E0\u4E3A\u300C\u662F\u7528\u6237\u4FDD\u5B58\u8FC7\u7684\u300D\u5C31\u9000\u56DE\u53BB\u8BA9\u7528\u6237\u81EA\u5DF1\u5728\u754C\u9762\u4E0A\u6539\u3002",
258
259
  "\u6539\u5DF2\u6709\u7684\u6D41\u6C34\u7EBF\uFF1A\u5148 pipeline_get \u8BFB\u51FA\u73B0\u5728\u7684\u5B9A\u4E49\uFF0C\u53EA\u52A8\u8981\u6539\u7684\u5730\u65B9\uFF0C\u5176\u4F59\u7167\u539F\u6837\u5199\u56DE\uFF1B\u4FDD\u5B58\u540E\u770B\u8FD4\u56DE\u7684 check \u548C\u5B9A\u4E49\uFF0C\u786E\u8BA4\u6539\u52A8\u5728\u3001\u6CA1\u6709 error\uFF0C\u518D\u8BF4\u6539\u597D\u4E86\u3002\u5B9A\u65F6\u7528 schedule_set\u3002",
259
260
  "\u6539\u4EC0\u4E48\u3001\u8981\u4E0D\u8981\u8FD0\u884C\uFF0C\u6309\u4EA4\u7ED9\u4F60\u8FD9\u4EF6\u4E8B\u7684\u4EBA\u8BF4\u7684\u6765\uFF1A\u8BA9\u6539\u5C31\u6539\uFF0C\u6CA1\u8BA9\u8FD0\u884C\u5C31\u4E0D\u8FD0\u884C\u3002\u5220\u6389\u8282\u70B9\u3001\u6362\u6389\u4EFB\u52A1\u8FD9\u7C7B\u4F1A\u6539\u53D8\u6BCF\u5929\u8DD1\u4EC0\u4E48\u7684\u6539\u52A8\uFF0C\u56DE\u590D\u91CC\u5199\u6E05\u695A\u6539\u4E86\u54EA\u91CC\u3002",
260
261
  "\u6D88\u606F\u662F\u6D41\u6C34\u7EBF\u4EA4\u7ED9\u4F60\u7684\u4E00\u4E2A\u6B65\u9AA4\u65F6\uFF1A\u53EA\u505A\u8FD9\u4E00\u6B65\u8BF4\u7684\u4E8B\uFF0C\u505A\u5B8C\u5C31\u505C\uFF1B\u8FD9\u4E00\u6B65\u6CA1\u8BA9\u4F60\u6539\u7684\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\u4E0D\u8981\u52A8\u3002"
package/lib/qqbot.js CHANGED
@@ -4,9 +4,9 @@ import {
4
4
  questionText,
5
5
  replyMarkdown,
6
6
  replyPlain
7
- } from "./chunk-A6YQRWHZ.js";
8
- import "./chunk-6NJSSOB6.js";
9
- import "./chunk-KMVQK5CI.js";
7
+ } from "./chunk-4QXRDWGS.js";
8
+ import "./chunk-QSETYM2Y.js";
9
+ import "./chunk-M7GNYL5B.js";
10
10
  import {
11
11
  writeFileAtomic
12
12
  } from "./chunk-RESS7WVY.js";
@@ -15,7 +15,7 @@ import {
15
15
  QQBOT_SECRET_REF,
16
16
  QQPending,
17
17
  QQSettings
18
- } from "./chunk-LXHF6AKU.js";
18
+ } from "./chunk-34VNH3YS.js";
19
19
  import {
20
20
  external_exports
21
21
  } from "./chunk-6DSSLS7I.js";
package/lib/runner.js CHANGED
@@ -25,9 +25,9 @@ import {
25
25
  setIn,
26
26
  taskParams,
27
27
  tidyRuns
28
- } from "./chunk-TELJUUBZ.js";
29
- import "./chunk-RGEGJH6R.js";
30
- import "./chunk-LXHF6AKU.js";
28
+ } from "./chunk-76UHR2GO.js";
29
+ import "./chunk-C7X2KJ5C.js";
30
+ import "./chunk-34VNH3YS.js";
31
31
  import "./chunk-6DSSLS7I.js";
32
32
  import "./chunk-2UFLGPDY.js";
33
33
  export {
package/lib/scheduler.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
  SCHEDULE_CAPABILITY
4
- } from "./chunk-LXHF6AKU.js";
4
+ } from "./chunk-34VNH3YS.js";
5
5
  import {
6
6
  external_exports
7
7
  } from "./chunk-6DSSLS7I.js";
@@ -17,14 +17,14 @@ import {
17
17
  packForRepo,
18
18
  parseMcpConfig,
19
19
  readSkills
20
- } from "./chunk-YTIR5JW4.js";
20
+ } from "./chunk-KW36B7DT.js";
21
21
  import "./chunk-B4UT4NYH.js";
22
- import "./chunk-RGEGJH6R.js";
23
- import "./chunk-A6YQRWHZ.js";
24
- import "./chunk-6NJSSOB6.js";
25
- import "./chunk-KMVQK5CI.js";
22
+ import "./chunk-C7X2KJ5C.js";
23
+ import "./chunk-4QXRDWGS.js";
24
+ import "./chunk-QSETYM2Y.js";
25
+ import "./chunk-M7GNYL5B.js";
26
26
  import "./chunk-RESS7WVY.js";
27
- import "./chunk-LXHF6AKU.js";
27
+ import "./chunk-34VNH3YS.js";
28
28
  import "./chunk-6DSSLS7I.js";
29
29
  import "./chunk-2UFLGPDY.js";
30
30
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multigameassistant",
3
- "version": "2.2.3",
3
+ "version": "2.3.1",
4
4
  "description": "多游戏助手 MultiGameAssistant 的 dsh 插件版:让 agent 管好各个游戏的日常脚本(安装、编排定时流水线、看护运行、查活动),界面在自己的网页里。",
5
5
  "keywords": [
6
6
  "dsh",
@@ -14,6 +14,18 @@ description: 游戏活动信息:查有什么活动、还剩几天、商店换
14
14
  用户想看更多游戏(原神、绝区零、鸣潮等没有游戏包的):告诉他在「游戏 → 全部活动 → 更多游戏」里勾上,活动来自 SRA 公共 API,每天自动刷新。
15
15
  3. 游戏包里没有可直接读的数据站(`game_list` 里 auto 都是 false):按技能 web-reading 的顺序查(先公开 API,如 SRA 公共 API,再 Wiki 接口,最后官网公告页),找到活动名和起止时间后 `game_record`(source=site,带上 `url`,有配图把图片地址写进 `cover`)。
16
16
 
17
+ ## 卡池、日常和周常
18
+
19
+ - `game_list` 里每个游戏带着 `pools`(卡池)。明日方舟、原神、终末地的卡池插件每天自己读;其他游戏(星穹铁道、绝区零、鸣潮等)没有能直接读的卡池数据:读官方公告、游戏内公告时看到卡池(祈愿、跃迁、调频、唤取、寻访),用 `game_pool` 记下名称、UP 的角色或武器、起止时间(游戏服务器时间)。
20
+ - 游戏页的「日常 · 周常」由游戏包和脚本包的 routines 列出,脚本日志或任务成功时自动勾上,到游戏的每日 / 每周重置时间清空;用户也可以自己勾、自己加。混沌回忆、卫戍协议这类周期玩法列在「活动日程」的「周期玩法」里,做完一期就是那个活动 `finished`。
21
+ - 看日常周常用 `game_routine`(action=list):每一项这一期做没做完、谁勾的(脚本日志 / 脚本任务成功 / agent 记的 / 用户自己勾的)、靠哪条日志或哪个任务自动勾、什么时候重置。list 之前插件已经把这一期早些时候的运行记录读过一遍,脚本包后来才加的 routines 也会补上,**不用**为此重跑脚本,也不用自己去勾。
22
+ - 用户问「日常周常为什么没显示完成」:先 `game_routine` list,对没勾上的一项看它的 auto:
23
+ - 「没有:只能手动勾」→ 脚本包没写这一项的 routines:交给「脚本」(agent_delegate)在脚本包里补,log 用运行日志里的原文;
24
+ - 有日志规则却没勾 → `script_run_log` 在这一期的运行里搜那段原文:搜不到说明日志里的写法不一样(交给「脚本」改 log)或者这一项确实没做(例如剿灭被跳过、实训失败);
25
+ - 结论用一两句话告诉用户:哪几项已经自动勾上、哪几项缺规则正在补、哪几项今天确实没做。
26
+ - 只有亲眼看到完成证据(运行日志原文、游戏画面上的完成文字)才用 `game_routine` action=set 勾,evidence 写原文和出处;页面会显示成「agent 记的」。**不要**用浏览器点游戏页的勾选框,也不要自己调接口——那样会被记成用户勾的。跳过、失败、只开始了的不算完成。
27
+ - 日报里每个游戏先写日常周常还差哪几项、什么时候重置,插件发日报前也会先读一遍运行记录。
28
+
17
29
  ## 公告和版本更新(单机游戏主要看这个)
18
30
 
19
31
  不是限时活动的消息记在游戏的「公告」里:版本更新、补丁说明、长期有效的公告、其他资讯。`game_activities` 每个游戏带着最近的 `notices`(`single_player` 为 true 的是单机游戏)。
@@ -7,7 +7,7 @@ description: 把几个游戏脚本编成一条流水线(每天自动跑、一
7
7
 
8
8
  目标:做出一条用户看得懂、电脑带得动、一个游戏出错不拖累其他游戏的流水线。
9
9
 
10
- 谁来保存:「编排」和它的子 agent 用 `pipeline_save`,直接保存生效,新建和修改已有的(用户保存过的也可以)都行,不用用户审批;其他 agent 没有这个工具,用 `pipeline_draft` 存成草稿等用户在「编排」页确认,要改已经保存的流水线就用 `agent_delegate` 交给「编排」。下面写「保存」的地方,按你有的那个工具来。
10
+ 谁来保存:「编排」用 `pipeline_save`(它的子 agent 要任务里写了「允许直接做的改动:改流水线和定时」才直接保存,否则保存会记成待定改动交回给「编排」决定),直接保存生效,新建和修改已有的(用户保存过的也可以)都行,不用用户审批;软件里的其他 agent 没有这个工具,把整件事用 `agent_delegate` 交给「编排」;只有没有「编排」的对话(比如共享 dsh 里的别的对话)才用 `pipeline_draft` 存成草稿,等用户在「编排」页确认。下面写「保存」的地方,按你有的那个工具来。
11
11
 
12
12
  ## 规则
13
13
 
@@ -30,7 +30,7 @@ description: 把几个游戏脚本编成一条流水线(每天自动跑、一
30
30
  - 先跑耗时短、容易失败的(例如需要登录的),把长任务放后面;用户有偏好就按用户的。
31
31
  4. 连线:串行时每一步到下一步用 **`when: always`(上一步结束后,不管成败)**,这样一个游戏失败不会让后面的游戏都不跑;只有用户明确要求「失败就停」时才用 `success` 或 `then: stop`。最后一个任务连到一个 `notify` 节点发汇总。不需要自己加「开始」「结束」节点,系统会加。
32
32
  5. 失败处理:默认不重试(游戏脚本自己多数会重试);用户在意成功率可以 `retries: 1`。
33
- 6. `pipeline_save`(其他 agent 用 `pipeline_draft`)提交(id 用小写短横线,如 `daily-games`);看返回的 `check`:有 error 就改正重交;有「会自动排队」的 info 说明画了不必要的并行,可以改成串行。
33
+ 6. `pipeline_save`(没有「编排」的对话用 `pipeline_draft`)提交(id 用小写短横线,如 `daily-games`);看返回的 `check`:有 error 就改正重交;有「会自动排队」的 info 说明画了不必要的并行,可以改成串行。
34
34
  7. 回复用户:顺序(A → B → C → D)、为什么这样排、预计时长(`check.estimateMinutes`)、没确认的事项;问要不要现在运行一次(`pipeline_run`)或设定每天的时间(`schedule_set`;草稿要先保存)。
35
35
 
36
36
  ## 例子