dsh-multigameassistant 2.0.5 → 2.1.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 +178 -4
- package/lib/analyzer.js +6 -4
- package/lib/browser.js +279 -0
- package/lib/{chunk-KHO3SRUJ.js → chunk-5PDYWE24.js} +4 -2
- package/lib/{chunk-YG4B5G7F.js → chunk-B4UT4NYH.js} +1 -0
- package/lib/{chunk-IOBYH4RN.js → chunk-FBDVN6Q2.js} +76 -1
- package/lib/{chunk-TD4YFQWE.js → chunk-MQG5FLOG.js} +629 -167
- package/lib/chunk-NM6H6WCQ.js +3753 -0
- package/lib/chunk-RESS7WVY.js +157 -0
- package/lib/{chunk-BTT2GBTQ.js → chunk-SHTX4AGU.js} +1 -3670
- package/lib/{chunk-4Q4EH73S.js → chunk-UQLHGLMP.js} +13 -9
- package/lib/{chunk-PAJOD6LV.js → chunk-VOTN4IHB.js} +384 -54
- package/lib/emulator.js +6 -4
- package/lib/feishu.js +8 -6
- package/lib/game-intel.js +90 -9
- package/lib/gateway.js +11 -6
- package/lib/guard.js +5 -3
- package/lib/intervene.js +62 -18
- package/lib/low-context.js +13 -2
- package/lib/monitor.js +90 -10
- package/lib/notify.js +6 -5
- package/lib/orchestrator.js +14 -10
- package/lib/qqbot.js +8 -6
- package/lib/runner.js +18 -5
- package/lib/scheduler.js +4 -2
- package/lib/script-registry.js +345 -216
- package/package.json +5 -4
- package/skills/pipeline-planning.md +1 -1
- package/skills/web-reading.md +2 -0
- package/web/assets/index-CL3SeTW9.css +1 -0
- package/web/assets/index-GYwpGP3f.js +244 -0
- package/web/assets/index-GYwpGP3f.js.map +1 -0
- package/web/index.html +2 -2
- package/lib/chunk-CCAB6XXZ.js +0 -34
- package/web/assets/index-BuStplKb.js +0 -242
- package/web/assets/index-BuStplKb.js.map +0 -1
- package/web/assets/index-CSB3B28L.css +0 -1
package/lib/emulator.js
CHANGED
|
@@ -2,15 +2,17 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
download,
|
|
4
4
|
runElevated
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-B4UT4NYH.js";
|
|
6
6
|
import {
|
|
7
7
|
writeFileAtomic
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RESS7WVY.js";
|
|
9
9
|
import {
|
|
10
10
|
EMULATORS_CAPABILITY,
|
|
11
|
-
EmulatorSettings
|
|
11
|
+
EmulatorSettings
|
|
12
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
13
|
+
import {
|
|
12
14
|
external_exports
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-SHTX4AGU.js";
|
|
14
16
|
import "./chunk-2UFLGPDY.js";
|
|
15
17
|
|
|
16
18
|
// packages/emulator/lib/index.js
|
package/lib/feishu.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
replyMarkdown,
|
|
4
4
|
replyPlain
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UQLHGLMP.js";
|
|
6
6
|
import {
|
|
7
7
|
require_extension,
|
|
8
8
|
require_permessage_deflate,
|
|
@@ -12,18 +12,20 @@ import {
|
|
|
12
12
|
require_subprotocol,
|
|
13
13
|
require_websocket,
|
|
14
14
|
require_websocket_server
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-MQG5FLOG.js";
|
|
16
|
+
import "./chunk-FBDVN6Q2.js";
|
|
17
17
|
import {
|
|
18
18
|
writeFileAtomic
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RESS7WVY.js";
|
|
20
20
|
import {
|
|
21
21
|
FEISHU_CAPABILITY,
|
|
22
22
|
FEISHU_SECRET_REF,
|
|
23
23
|
FeishuPending,
|
|
24
|
-
FeishuSettings
|
|
24
|
+
FeishuSettings
|
|
25
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
26
|
+
import {
|
|
25
27
|
external_exports
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-SHTX4AGU.js";
|
|
27
29
|
import {
|
|
28
30
|
__commonJS,
|
|
29
31
|
__require,
|
package/lib/game-intel.js
CHANGED
|
@@ -7,15 +7,16 @@ import {
|
|
|
7
7
|
GAME_MANIFEST_FILE,
|
|
8
8
|
GameManifest,
|
|
9
9
|
parseGameManifest
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-5PDYWE24.js";
|
|
11
11
|
import {
|
|
12
12
|
sessionConversations
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-UQLHGLMP.js";
|
|
14
|
+
import "./chunk-MQG5FLOG.js";
|
|
15
|
+
import "./chunk-FBDVN6Q2.js";
|
|
16
16
|
import {
|
|
17
|
+
ExeIcons,
|
|
17
18
|
writeFileAtomic
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RESS7WVY.js";
|
|
19
20
|
import {
|
|
20
21
|
GAMES_CAPABILITY,
|
|
21
22
|
GamesSettings,
|
|
@@ -23,13 +24,16 @@ import {
|
|
|
23
24
|
OWN_SOURCE,
|
|
24
25
|
SCREEN_SOURCE,
|
|
25
26
|
SHOT_IMAGE,
|
|
26
|
-
external_exports,
|
|
27
27
|
taskMessage
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
29
|
+
import {
|
|
30
|
+
external_exports
|
|
31
|
+
} from "./chunk-SHTX4AGU.js";
|
|
29
32
|
import "./chunk-2UFLGPDY.js";
|
|
30
33
|
|
|
31
34
|
// packages/game-intel/lib/index.js
|
|
32
35
|
import { createHash } from "node:crypto";
|
|
36
|
+
import { existsSync } from "node:fs";
|
|
33
37
|
import { mkdir as mkdir2, readdir, readFile as readFile2, rm, writeFile } from "node:fs/promises";
|
|
34
38
|
import { isAbsolute, join as join2, resolve } from "node:path";
|
|
35
39
|
import { Service } from "@deepseek-ai/cordis";
|
|
@@ -1624,7 +1628,8 @@ var GAME_ROLE = {
|
|
|
1624
1628
|
titles: ["\u6E38\u620F\u4FE1\u606F", "\u6E38\u620F\u8D44\u8BAF", "\u6DFB\u52A0\u6E38\u620F", "\u65E5\u62A5"],
|
|
1625
1629
|
// Games and their screens, and what scripts ran (for the daily report); no installing, runs or pipelines.
|
|
1626
1630
|
// skill_hub_list: its reading prompt and game_list send it there when a game's skill is missing.
|
|
1627
|
-
|
|
1631
|
+
// browser_*: official sites and wikis that need clicking through (the built-in browser).
|
|
1632
|
+
tools: ["game_*", "screen_*", "window_*", "browser_*", "emulator_status", "emulator_start", "script_list", "script_tasks", "script_runs", "skill_hub_list", "system_info", "skill_focus", "skill_save"],
|
|
1628
1633
|
duty: [
|
|
1629
1634
|
"# \u4F60\u7684\u89D2\u8272\uFF1A\u6E38\u620F",
|
|
1630
1635
|
"\u4F60\u662F MultiGameAssistant \u7684\u300C\u6E38\u620F\u300Dagent\uFF1A\u8BFB\u6E38\u620F\u7684\u6D3B\u52A8\u3001\u8D44\u8BAF\u548C\u8FDB\u5EA6\u5E76\u8BB0\u4E0B\u6765\uFF08game_record\uFF09\uFF0C\u5199\u65E5\u62A5\uFF0C\u6DFB\u52A0\u6E38\u620F\u3002",
|
|
@@ -1647,6 +1652,10 @@ var AdgGameIntel = class extends Service {
|
|
|
1647
1652
|
games = [];
|
|
1648
1653
|
daily;
|
|
1649
1654
|
dir;
|
|
1655
|
+
/** Game programs' icons (exe-icon.ts). */
|
|
1656
|
+
icons;
|
|
1657
|
+
/** Each game's PC program as found this run (undefined: none). */
|
|
1658
|
+
programs = /* @__PURE__ */ new Map();
|
|
1650
1659
|
builtinDir;
|
|
1651
1660
|
log;
|
|
1652
1661
|
constructor(ctx, config) {
|
|
@@ -1657,6 +1666,7 @@ var AdgGameIntel = class extends Service {
|
|
|
1657
1666
|
this.dir = join2(spec.dataDir, "games");
|
|
1658
1667
|
this.builtinDir = spec.gamesDir ?? GAMES_DIR;
|
|
1659
1668
|
this.calendar = new Calendar(this.dir);
|
|
1669
|
+
this.icons = new ExeIcons(join2(this.dir, "icons"));
|
|
1660
1670
|
const calendar = this.calendar;
|
|
1661
1671
|
const changed = (game) => ctx.get("adgGateway")?.broadcast("games/changed", game === void 0 ? {} : { game });
|
|
1662
1672
|
const daily = new DailyReport({
|
|
@@ -1816,6 +1826,11 @@ var AdgGameIntel = class extends Service {
|
|
|
1816
1826
|
return this.picture(screen.image);
|
|
1817
1827
|
return { mediaType: "image/png", data: (await readFile2(this.evidenceFile(id))).toString("base64") };
|
|
1818
1828
|
},
|
|
1829
|
+
"games/icon": async (params, call) => {
|
|
1830
|
+
await this.ready;
|
|
1831
|
+
const icon = await this.icon(params.game, call.signal);
|
|
1832
|
+
return icon === null ? {} : { icon };
|
|
1833
|
+
},
|
|
1819
1834
|
"games/image": async (params) => {
|
|
1820
1835
|
await this.ready;
|
|
1821
1836
|
return this.picture(params.url);
|
|
@@ -2152,6 +2167,72 @@ var AdgGameIntel = class extends Service {
|
|
|
2152
2167
|
const mine = new Set([...byName, ...byDescription].filter(([, ids]) => ids.includes(gameId)).map(([rid]) => rid));
|
|
2153
2168
|
return { items: items.filter((i) => mine.has(i.rid)), from };
|
|
2154
2169
|
}
|
|
2170
|
+
/** A game's program icon, for its avatar; null when it has no PC program this app knows of. */
|
|
2171
|
+
async icon(gameId, signal) {
|
|
2172
|
+
const program = await this.program(gameId);
|
|
2173
|
+
if (program === void 0)
|
|
2174
|
+
return null;
|
|
2175
|
+
try {
|
|
2176
|
+
return { mediaType: "image/png", data: (await this.icons.png(program, signal)).toString("base64") };
|
|
2177
|
+
} catch (e) {
|
|
2178
|
+
this.log.warn(`games: no icon for ${gameId} (${program}): ${e instanceof Error ? e.message : String(e)}`);
|
|
2179
|
+
return null;
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* Where a game's PC program is: the one a script that plays it starts (its
|
|
2184
|
+
* saved 游戏位置), else where 自动查找 finds the program the packs that play
|
|
2185
|
+
* it name (installed or not), looked for once a run.
|
|
2186
|
+
*/
|
|
2187
|
+
async program(gameId) {
|
|
2188
|
+
const runner = this.ctx.get("adgRunner")?.runner;
|
|
2189
|
+
if (runner === void 0 || process.platform !== "win32")
|
|
2190
|
+
return void 0;
|
|
2191
|
+
const scripts = this.scriptsOf(gameId);
|
|
2192
|
+
for (const id of scripts) {
|
|
2193
|
+
const exe = (await runner.launch.get(id).catch(() => void 0))?.pcExe;
|
|
2194
|
+
if (exe !== void 0 && existsSync(exe))
|
|
2195
|
+
return exe;
|
|
2196
|
+
}
|
|
2197
|
+
let search = this.programs.get(gameId);
|
|
2198
|
+
if (search === void 0) {
|
|
2199
|
+
search = this.searchProgram(gameId, scripts);
|
|
2200
|
+
this.programs.set(gameId, search);
|
|
2201
|
+
void search.then((path2) => {
|
|
2202
|
+
if (path2 === void 0)
|
|
2203
|
+
setTimeout(() => this.programs.delete(gameId), 2 * 6e4).unref?.();
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
const path = await search;
|
|
2207
|
+
if (path !== void 0 && !existsSync(path)) {
|
|
2208
|
+
this.programs.delete(gameId);
|
|
2209
|
+
return void 0;
|
|
2210
|
+
}
|
|
2211
|
+
return path;
|
|
2212
|
+
}
|
|
2213
|
+
/** Where 自动查找 finds the program the packs that play a game name (installed or not), with the game's names to look for. */
|
|
2214
|
+
async searchProgram(gameId, scripts) {
|
|
2215
|
+
const runner = this.ctx.get("adgRunner")?.runner;
|
|
2216
|
+
if (runner === void 0)
|
|
2217
|
+
return void 0;
|
|
2218
|
+
const { manifest } = this.game(gameId);
|
|
2219
|
+
const library = this.ctx.get("adgScripts")?.library;
|
|
2220
|
+
for (const id of scripts) {
|
|
2221
|
+
let pack;
|
|
2222
|
+
try {
|
|
2223
|
+
pack = library?.packOf(id);
|
|
2224
|
+
} catch {
|
|
2225
|
+
pack = void 0;
|
|
2226
|
+
}
|
|
2227
|
+
const game = (pack ?? library?.pack(id))?.manifest.game;
|
|
2228
|
+
if (game?.pc?.process === void 0)
|
|
2229
|
+
continue;
|
|
2230
|
+
const found = await runner.findGameProgram(game, [manifest.name, ...manifest.aliases]).catch(() => void 0);
|
|
2231
|
+
if (found !== void 0)
|
|
2232
|
+
return found;
|
|
2233
|
+
}
|
|
2234
|
+
return void 0;
|
|
2235
|
+
}
|
|
2155
2236
|
scriptsOf(gameId) {
|
|
2156
2237
|
return this.scriptsByGame().get(gameId) ?? [];
|
|
2157
2238
|
}
|
|
@@ -2196,7 +2277,7 @@ var AdgGameIntel = class extends Service {
|
|
|
2196
2277
|
for (const { manifest } of games) {
|
|
2197
2278
|
const sources = manifest.sources.filter((s) => s.smw !== void 0 || s.sra !== void 0);
|
|
2198
2279
|
if (sources.length === 0) {
|
|
2199
|
-
results.push({ game: manifest.id, ok: false, count: 0, detail: `\u6CA1\u6709\u80FD\u76F4\u63A5\u8BFB\u7684\u6570\u636E\u7AD9\uFF1A\u7528 web_fetch
|
|
2280
|
+
results.push({ game: manifest.id, ok: false, count: 0, detail: `\u6CA1\u6709\u80FD\u76F4\u63A5\u8BFB\u7684\u6570\u636E\u7AD9\uFF1A\u7528 web_fetch\uFF08\u53EA\u62FF\u5230\u7A7A\u58F3\u65F6\u7528\u5185\u7F6E\u6D4F\u89C8\u5668\uFF09\u770B ${manifest.sources.map((s) => s.homepage).filter(Boolean).join(" \u6216 ") || "\u5B98\u7F51\u516C\u544A"}\uFF0C\u518D\u7528 game_record\uFF08source=site\uFF09\u8BB0\u4E0B` });
|
|
2200
2281
|
continue;
|
|
2201
2282
|
}
|
|
2202
2283
|
const failures = [];
|
package/lib/gateway.js
CHANGED
|
@@ -2,11 +2,12 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
AGENT_PRESET,
|
|
4
4
|
AdgGateway,
|
|
5
|
+
AgentModels,
|
|
5
6
|
INSTANCES_DIR,
|
|
6
7
|
Instances,
|
|
8
|
+
NEW_INPUT,
|
|
7
9
|
PRESET,
|
|
8
10
|
Permissions,
|
|
9
|
-
RoleModel,
|
|
10
11
|
SessionRoles,
|
|
11
12
|
SkillScope,
|
|
12
13
|
clashes,
|
|
@@ -16,20 +17,23 @@ import {
|
|
|
16
17
|
convertRecords,
|
|
17
18
|
copyLabel,
|
|
18
19
|
lib_default,
|
|
20
|
+
pluginVersion,
|
|
19
21
|
streamFacts
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-MQG5FLOG.js";
|
|
23
|
+
import "./chunk-FBDVN6Q2.js";
|
|
24
|
+
import "./chunk-RESS7WVY.js";
|
|
25
|
+
import "./chunk-NM6H6WCQ.js";
|
|
26
|
+
import "./chunk-SHTX4AGU.js";
|
|
24
27
|
import "./chunk-2UFLGPDY.js";
|
|
25
28
|
export {
|
|
26
29
|
AGENT_PRESET,
|
|
27
30
|
AdgGateway,
|
|
31
|
+
AgentModels,
|
|
28
32
|
INSTANCES_DIR,
|
|
29
33
|
Instances,
|
|
34
|
+
NEW_INPUT,
|
|
30
35
|
PRESET,
|
|
31
36
|
Permissions,
|
|
32
|
-
RoleModel,
|
|
33
37
|
SessionRoles,
|
|
34
38
|
SkillScope,
|
|
35
39
|
clashes,
|
|
@@ -39,5 +43,6 @@ export {
|
|
|
39
43
|
convertRecords,
|
|
40
44
|
copyLabel,
|
|
41
45
|
lib_default as default,
|
|
46
|
+
pluginVersion,
|
|
42
47
|
streamFacts
|
|
43
48
|
};
|
package/lib/guard.js
CHANGED
|
@@ -1,7 +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
|
GUARD_CAPABILITY
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
5
|
+
import "./chunk-SHTX4AGU.js";
|
|
5
6
|
import "./chunk-2UFLGPDY.js";
|
|
6
7
|
|
|
7
8
|
// packages/guard/lib/index.js
|
|
@@ -66,7 +67,7 @@ function denialReason(verdict, scriptName) {
|
|
|
66
67
|
if (verdict.scriptId === APP_FILES) {
|
|
67
68
|
return [
|
|
68
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`,
|
|
69
|
-
"\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\
|
|
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"
|
|
70
71
|
].join("");
|
|
71
72
|
}
|
|
72
73
|
return [
|
|
@@ -97,7 +98,8 @@ var AdgGuard = class extends Service {
|
|
|
97
98
|
for (const version of script.versions)
|
|
98
99
|
protectedDirs.push({ scriptId: script.id, dir: version.dir });
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
+
for (const dir of [scripts.library.toolsDir, ...scripts.library.formerToolsDirs])
|
|
102
|
+
protectedDirs.push({ scriptId: TOOLS, dir });
|
|
101
103
|
protectedDirs.push({ scriptId: APP_FILES, dir: APP_FILES_DIR });
|
|
102
104
|
return { protectedDirs, allowed: [...open.values()].flatMap((g) => g.dirs) };
|
|
103
105
|
};
|
package/lib/intervene.js
CHANGED
|
@@ -2,17 +2,19 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
finalText,
|
|
4
4
|
sessionConversations
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-UQLHGLMP.js";
|
|
6
|
+
import "./chunk-MQG5FLOG.js";
|
|
7
|
+
import "./chunk-FBDVN6Q2.js";
|
|
8
8
|
import {
|
|
9
9
|
writeFileAtomic
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RESS7WVY.js";
|
|
11
11
|
import {
|
|
12
12
|
INTERVENE_CAPABILITY,
|
|
13
|
-
UPDATE_RULE
|
|
13
|
+
UPDATE_RULE
|
|
14
|
+
} from "./chunk-NM6H6WCQ.js";
|
|
15
|
+
import {
|
|
14
16
|
external_exports
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-SHTX4AGU.js";
|
|
16
18
|
import "./chunk-2UFLGPDY.js";
|
|
17
19
|
|
|
18
20
|
// packages/intervene/lib/index.js
|
|
@@ -28,6 +30,7 @@ var INTERVENE_ROLE = {
|
|
|
28
30
|
description: "\u811A\u672C\u51FA\u9519\u3001\u5361\u4F4F\u65F6\u5904\u7406",
|
|
29
31
|
order: 10,
|
|
30
32
|
titles: ["\u5E72\u9884"],
|
|
33
|
+
handedImages: true,
|
|
31
34
|
// The screen, the script's run and its settings; no installing, games or pipelines.
|
|
32
35
|
tools: [
|
|
33
36
|
"screen_*",
|
|
@@ -74,11 +77,41 @@ var Interventions = class {
|
|
|
74
77
|
#bySession = /* @__PURE__ */ new Map();
|
|
75
78
|
/** The latest screenshot of each recent session, for whoever wants to keep it as evidence. */
|
|
76
79
|
#shots = /* @__PURE__ */ new Map();
|
|
80
|
+
/** How long each run has been held paused: past pauses' `total`, and `since` while one is going on. */
|
|
81
|
+
#held = /* @__PURE__ */ new Map();
|
|
77
82
|
#seq = 0;
|
|
78
83
|
constructor(deps) {
|
|
79
84
|
this.#deps = deps;
|
|
80
85
|
this.#now = deps.now ?? Date.now;
|
|
81
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* How long interventions have held the run paused so far (the stretch going on included), and whether one is
|
|
89
|
+
* now: the monitor counts neither as the script's quiet time nor its running time.
|
|
90
|
+
*/
|
|
91
|
+
heldPaused(runId) {
|
|
92
|
+
const held = this.#held.get(runId);
|
|
93
|
+
if (held === void 0)
|
|
94
|
+
return { ms: 0, now: false };
|
|
95
|
+
return { ms: held.total + (held.since === void 0 ? 0 : this.#now() - held.since), now: held.since !== void 0 };
|
|
96
|
+
}
|
|
97
|
+
/** Every change to whether an intervention holds its run paused goes through here, so `heldPaused` keeps time. */
|
|
98
|
+
#setPaused(item, paused) {
|
|
99
|
+
item.paused = paused;
|
|
100
|
+
if (item.runId === void 0)
|
|
101
|
+
return;
|
|
102
|
+
const held = this.#held.get(item.runId) ?? { total: 0 };
|
|
103
|
+
const now = this.#now();
|
|
104
|
+
if (paused)
|
|
105
|
+
held.since ??= now;
|
|
106
|
+
else if (held.since !== void 0) {
|
|
107
|
+
held.total += now - held.since;
|
|
108
|
+
held.since = void 0;
|
|
109
|
+
}
|
|
110
|
+
this.#held.delete(item.runId);
|
|
111
|
+
this.#held.set(item.runId, held);
|
|
112
|
+
while (this.#held.size > KEEP)
|
|
113
|
+
this.#held.delete(this.#held.keys().next().value);
|
|
114
|
+
}
|
|
82
115
|
async load() {
|
|
83
116
|
try {
|
|
84
117
|
const saved = JSON.parse(await readFile(this.#file(), "utf8"));
|
|
@@ -149,14 +182,15 @@ var Interventions = class {
|
|
|
149
182
|
if (result === "retry") {
|
|
150
183
|
if (!await settle("retry"))
|
|
151
184
|
await this.#deps.runner.restart(item.runId, `agent \u5904\u7406\u540E\u91CD\u65B0\u8FD0\u884C\uFF1A${summary}`);
|
|
152
|
-
|
|
185
|
+
item.state = "retried";
|
|
186
|
+
this.#setPaused(item, false);
|
|
153
187
|
this.#changed(item);
|
|
154
188
|
return "\u5DF2\u7ECF\u91CD\u65B0\u8FD0\u884C\u8FD9\u4E2A\u4EFB\u52A1\uFF08\u5F02\u5E38\u4E5F\u6807\u4E3A\u5DF2\u5904\u7406\uFF09\u3002\u73B0\u5728\u7ED3\u675F\u8FD9\u4E00\u8F6E\u56DE\u590D\u3002";
|
|
155
189
|
}
|
|
156
190
|
if (item.paused) {
|
|
157
191
|
if (!await settle("resume"))
|
|
158
192
|
await this.#resume(item);
|
|
159
|
-
item
|
|
193
|
+
this.#setPaused(item, false);
|
|
160
194
|
} else {
|
|
161
195
|
await settle("resolve");
|
|
162
196
|
}
|
|
@@ -225,7 +259,7 @@ var Interventions = class {
|
|
|
225
259
|
this.#deps.log.warn(`pausing ${incident.runId} failed: ${String(error)}`);
|
|
226
260
|
return 0;
|
|
227
261
|
});
|
|
228
|
-
item
|
|
262
|
+
this.#setPaused(item, changed > 0);
|
|
229
263
|
if (item.paused)
|
|
230
264
|
this.#deps.runner.note(incident.runId, "agent \u6B63\u5728\u5904\u7406\u5F02\u5E38\uFF0C\u811A\u672C\u5DF2\u6682\u505C");
|
|
231
265
|
}
|
|
@@ -287,7 +321,7 @@ var Interventions = class {
|
|
|
287
321
|
if (done.result === "retry") {
|
|
288
322
|
try {
|
|
289
323
|
await this.#deps.runner.restart(incident.runId, `agent \u5904\u7406\u540E\u91CD\u65B0\u8FD0\u884C\uFF1A${done.summary}`);
|
|
290
|
-
item
|
|
324
|
+
this.#setPaused(item, false);
|
|
291
325
|
return finish("retried", done.summary);
|
|
292
326
|
} catch (error) {
|
|
293
327
|
return finish("gave-up", `${done.summary}\uFF08\u91CD\u65B0\u8FD0\u884C\u6CA1\u6709\u6210\u529F\uFF1A${error instanceof Error ? error.message : String(error)}\uFF09`, imageOf(active, screenshot));
|
|
@@ -330,10 +364,10 @@ var Interventions = class {
|
|
|
330
364
|
await this.#resume(item);
|
|
331
365
|
else if (then === "restart") {
|
|
332
366
|
await this.#deps.runner.restart(item.runId, "\u5904\u7406\u5B8C\u540E\u91CD\u65B0\u8FD0\u884C", { byUser: true });
|
|
333
|
-
item
|
|
367
|
+
this.#setPaused(item, false);
|
|
334
368
|
} else {
|
|
335
369
|
await this.#deps.runner.stop(item.runId, "\u5904\u7406\u5F02\u5E38\u540E\u505C\u6B62");
|
|
336
|
-
item
|
|
370
|
+
this.#setPaused(item, false);
|
|
337
371
|
}
|
|
338
372
|
this.#changed(item);
|
|
339
373
|
return item;
|
|
@@ -353,7 +387,7 @@ var Interventions = class {
|
|
|
353
387
|
const pid = this.#deps.runner.processId(item.runId);
|
|
354
388
|
if (pid !== void 0)
|
|
355
389
|
await this.#deps.suspend(pid, true);
|
|
356
|
-
item
|
|
390
|
+
this.#setPaused(item, false);
|
|
357
391
|
try {
|
|
358
392
|
this.#deps.runner.note(item.runId, "\u5F02\u5E38\u5DF2\u5904\u7406\uFF0C\u811A\u672C\u7EE7\u7EED\u8FD0\u884C");
|
|
359
393
|
} catch {
|
|
@@ -1518,12 +1552,18 @@ var AdgIntervene = class extends Service {
|
|
|
1518
1552
|
return sessions === void 0 ? void 0 : sessionConversations(sessions, () => ctx.get("adgGateway")?.workspaceDir(), (id, f) => ctx.get("adgGateway")?.skillScope.setFocus(id, f) ?? Promise.resolve(), () => ctx.get("adgGateway"));
|
|
1519
1553
|
},
|
|
1520
1554
|
visionProblem: async () => {
|
|
1521
|
-
const
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1555
|
+
const gateway = ctx.get("adgGateway");
|
|
1556
|
+
const own = gateway?.agentModel(INTERVENE_ROLE.id);
|
|
1557
|
+
const lead = own ?? ctx.get("agentDefaultModel")?.currentSelection();
|
|
1558
|
+
if (lead === void 0)
|
|
1524
1559
|
return void 0;
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1560
|
+
const fix = "\u5728\u300C\u8BBE\u7F6E \u2192 \u6A21\u578B\u300D\u6362\u6210\u80FD\u770B\u56FE\u7684\uFF08\u4F8B\u5982 Claude\u3001GPT-4o\u3001Gemini\u3001\u901A\u4E49 VL\uFF09";
|
|
1561
|
+
if (!await sees(lead.provider, lead.model))
|
|
1562
|
+
return `${own === void 0 ? "\u9ED8\u8BA4\u6A21\u578B" : "\u300C\u5E72\u9884\u300D\u7684\u6A21\u578B"} ${lead.model} \u4E0D\u80FD\u770B\u56FE\u7247\uFF0Cagent \u6CA1\u6CD5\u67E5\u770B\u622A\u56FE\uFF1B${fix}`;
|
|
1563
|
+
const sub = gateway?.subAgentModel(INTERVENE_ROLE.id);
|
|
1564
|
+
if (sub !== void 0 && !await sees(sub.provider, sub.model))
|
|
1565
|
+
return `\u300C\u5E72\u9884\u300D\u7684\u5B50 agent \u7528\u7684 ${sub.model} \u4E0D\u80FD\u770B\u56FE\u7247\uFF0C\u6CA1\u6CD5\u622A\u56FE\u770B\u753B\u9762\uFF1B${fix}`;
|
|
1566
|
+
return void 0;
|
|
1527
1567
|
},
|
|
1528
1568
|
revealWindows: async (runId) => process.platform === "win32" ? (await screens.reveal(await ownerOf(runId))).windows : [],
|
|
1529
1569
|
describeTargets: (run) => {
|
|
@@ -1649,6 +1689,10 @@ var AdgIntervene = class extends Service {
|
|
|
1649
1689
|
resumeRun(runId) {
|
|
1650
1690
|
return this.interventions.resumeRun(runId);
|
|
1651
1691
|
}
|
|
1692
|
+
/** How long interventions have held the run paused, for the monitor's stall and overtime clocks. */
|
|
1693
|
+
heldPaused(runId) {
|
|
1694
|
+
return this.interventions.heldPaused(runId);
|
|
1695
|
+
}
|
|
1652
1696
|
};
|
|
1653
1697
|
var lib_default = AdgIntervene;
|
|
1654
1698
|
export {
|
package/lib/low-context.js
CHANGED
|
@@ -1,6 +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
|
ARCHIVE_BATCH_MS,
|
|
4
|
+
IDLE_COMPACT_MS,
|
|
5
|
+
MIN_PRUNE_CHARS,
|
|
4
6
|
MIN_SPAN_TOKENS,
|
|
5
7
|
Refusals,
|
|
6
8
|
SUMMARIES_FILE,
|
|
@@ -10,6 +12,7 @@ import {
|
|
|
10
12
|
assemble,
|
|
11
13
|
coverOf,
|
|
12
14
|
eventText,
|
|
15
|
+
idleRange,
|
|
13
16
|
inject,
|
|
14
17
|
isMessage,
|
|
15
18
|
isPointer,
|
|
@@ -22,6 +25,8 @@ import {
|
|
|
22
25
|
parseLowContext,
|
|
23
26
|
pointerStep,
|
|
24
27
|
pointerText,
|
|
28
|
+
prunableChars,
|
|
29
|
+
pruneStale,
|
|
25
30
|
refusedForSize,
|
|
26
31
|
settingsReader,
|
|
27
32
|
spanChars,
|
|
@@ -33,11 +38,14 @@ import {
|
|
|
33
38
|
summaryTarget,
|
|
34
39
|
summaryText,
|
|
35
40
|
taskOver
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-
|
|
41
|
+
} from "./chunk-FBDVN6Q2.js";
|
|
42
|
+
import "./chunk-NM6H6WCQ.js";
|
|
43
|
+
import "./chunk-SHTX4AGU.js";
|
|
38
44
|
import "./chunk-2UFLGPDY.js";
|
|
39
45
|
export {
|
|
40
46
|
ARCHIVE_BATCH_MS,
|
|
47
|
+
IDLE_COMPACT_MS,
|
|
48
|
+
MIN_PRUNE_CHARS,
|
|
41
49
|
MIN_SPAN_TOKENS,
|
|
42
50
|
Refusals,
|
|
43
51
|
SUMMARIES_FILE,
|
|
@@ -47,6 +55,7 @@ export {
|
|
|
47
55
|
assemble,
|
|
48
56
|
coverOf,
|
|
49
57
|
eventText,
|
|
58
|
+
idleRange,
|
|
50
59
|
inject,
|
|
51
60
|
isMessage,
|
|
52
61
|
isPointer,
|
|
@@ -59,6 +68,8 @@ export {
|
|
|
59
68
|
parseLowContext,
|
|
60
69
|
pointerStep,
|
|
61
70
|
pointerText,
|
|
71
|
+
prunableChars,
|
|
72
|
+
pruneStale,
|
|
62
73
|
refusedForSize,
|
|
63
74
|
settingsReader,
|
|
64
75
|
spanChars,
|