dsh-multigameassistant 2.0.2 → 2.0.4
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 +7 -2
- package/lib/analyzer.js +2 -2
- package/lib/{chunk-I5AFAEXG.js → chunk-4PNYIZVU.js} +5 -2
- package/lib/{chunk-OPV336S5.js → chunk-IZENRXQ6.js} +1205 -174
- package/lib/{chunk-QAP7IYBS.js → chunk-SA72K6M2.js} +294 -155
- package/lib/{chunk-ZR74PFWR.js → chunk-UOVFYP7C.js} +5 -3
- package/lib/{chunk-NWM5ZN7E.js → chunk-XHP3SLMO.js} +1 -1
- package/lib/emulator.js +1 -1
- package/lib/feishu.js +3 -3
- package/lib/game-intel.js +5 -5
- package/lib/gateway.js +2 -2
- package/lib/guard.js +1 -1
- package/lib/intervene.js +3 -3
- package/lib/low-context.js +100 -0
- package/lib/monitor.js +3 -3
- package/lib/notify.js +3 -3
- package/lib/orchestrator.js +5 -5
- package/lib/qqbot.js +3 -3
- package/lib/runner.js +3 -3
- package/lib/scheduler.js +1 -1
- package/lib/script-registry.js +73 -15
- package/package.json +2 -1
- package/web/assets/index-BqeCz6LB.css +1 -0
- package/web/assets/index-CCaVm9ks.js +242 -0
- package/web/assets/index-CCaVm9ks.js.map +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-9SCfW_a1.js +0 -241
- package/web/assets/index-9SCfW_a1.js.map +0 -1
- package/web/assets/index-BodAAefM.css +0 -1
package/lib/gateway.js
CHANGED
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
copyLabel,
|
|
18
18
|
lib_default,
|
|
19
19
|
streamFacts
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IZENRXQ6.js";
|
|
21
21
|
import "./chunk-CCAB6XXZ.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-SA72K6M2.js";
|
|
23
23
|
import "./chunk-2UFLGPDY.js";
|
|
24
24
|
export {
|
|
25
25
|
AGENT_PRESET,
|
package/lib/guard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
|
|
2
2
|
import {
|
|
3
3
|
GUARD_CAPABILITY
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SA72K6M2.js";
|
|
5
5
|
import "./chunk-2UFLGPDY.js";
|
|
6
6
|
|
|
7
7
|
// packages/guard/lib/index.js
|
package/lib/intervene.js
CHANGED
|
@@ -2,8 +2,8 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
finalText,
|
|
4
4
|
sessionConversations
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-4PNYIZVU.js";
|
|
6
|
+
import "./chunk-IZENRXQ6.js";
|
|
7
7
|
import {
|
|
8
8
|
writeFileAtomic
|
|
9
9
|
} from "./chunk-CCAB6XXZ.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
INTERVENE_CAPABILITY,
|
|
12
12
|
UPDATE_RULE,
|
|
13
13
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-SA72K6M2.js";
|
|
15
15
|
import "./chunk-2UFLGPDY.js";
|
|
16
16
|
|
|
17
17
|
// packages/intervene/lib/index.js
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
import {
|
|
3
|
+
LOW_CONTEXT_WINDOW_MS
|
|
4
|
+
} from "./chunk-SA72K6M2.js";
|
|
5
|
+
import "./chunk-2UFLGPDY.js";
|
|
6
|
+
|
|
7
|
+
// packages/gateway/lib/low-context.js
|
|
8
|
+
import { readFileSync, statSync } from "node:fs";
|
|
9
|
+
var name = "adg-low-context";
|
|
10
|
+
var inject = ["compaction"];
|
|
11
|
+
var isReplace = (event) => typeof event.surfaceOp === "object" && event.surfaceOp !== null;
|
|
12
|
+
var sourceOf = (data) => data?.source ?? {};
|
|
13
|
+
var TYPED = /* @__PURE__ */ new Set(["user", "user-rpc"]);
|
|
14
|
+
var SENT = /* @__PURE__ */ new Set(["notice", "relay"]);
|
|
15
|
+
function isMessage(event) {
|
|
16
|
+
if (event.type !== "user/message" || isReplace(event))
|
|
17
|
+
return false;
|
|
18
|
+
const { kind, form } = sourceOf(event.data);
|
|
19
|
+
return TYPED.has(String(kind)) || SENT.has(String(form));
|
|
20
|
+
}
|
|
21
|
+
function lowContextRange(session, options) {
|
|
22
|
+
const nodes = session.surface.nodes;
|
|
23
|
+
const events = nodes.map((seq) => session.eventAt(seq));
|
|
24
|
+
const first = events[0]?.type === "system/message" ? 1 : 0;
|
|
25
|
+
const messages = [];
|
|
26
|
+
for (let i = first; i < events.length; i++)
|
|
27
|
+
if (events[i] !== void 0 && isMessage(events[i]))
|
|
28
|
+
messages.push(i);
|
|
29
|
+
if (messages.length === 0)
|
|
30
|
+
return null;
|
|
31
|
+
const cutoff = options.now - (options.windowMs ?? LOW_CONTEXT_WINDOW_MS);
|
|
32
|
+
const keepFrom = messages.find((i) => events[i].time >= cutoff) ?? messages[messages.length - 1];
|
|
33
|
+
if (keepFrom <= first)
|
|
34
|
+
return null;
|
|
35
|
+
if (events.slice(first, keepFrom).every((event) => event === void 0 || isReplace(event) || event.type === "system/message"))
|
|
36
|
+
return null;
|
|
37
|
+
return { start: nodes[first], end: nodes[keepFrom - 1] };
|
|
38
|
+
}
|
|
39
|
+
function parseLowContext(raw) {
|
|
40
|
+
return raw?.lowContext === true;
|
|
41
|
+
}
|
|
42
|
+
function settingsReader(file) {
|
|
43
|
+
let stamp = "";
|
|
44
|
+
let on = false;
|
|
45
|
+
return () => {
|
|
46
|
+
if (file === void 0)
|
|
47
|
+
return on;
|
|
48
|
+
try {
|
|
49
|
+
const stat = statSync(file);
|
|
50
|
+
const now = `${stat.mtimeMs}:${stat.size}`;
|
|
51
|
+
if (now !== stamp) {
|
|
52
|
+
stamp = now;
|
|
53
|
+
on = parseLowContext(JSON.parse(readFileSync(file, "utf8")));
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
stamp = "";
|
|
57
|
+
on = false;
|
|
58
|
+
}
|
|
59
|
+
return on;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function taskOver(agent, work) {
|
|
63
|
+
if ((agent.inbox?.nextTurn?.length ?? 0) > 0 || (agent.inbox?.nextStep?.length ?? 0) > 0)
|
|
64
|
+
return false;
|
|
65
|
+
return work?.workPending?.(agent.session.id) !== true;
|
|
66
|
+
}
|
|
67
|
+
function apply(ctx, config = {}) {
|
|
68
|
+
const log = ctx.logger("adg-low-context");
|
|
69
|
+
const enabled = settingsReader(config.file);
|
|
70
|
+
const engine = ctx.compaction;
|
|
71
|
+
if (typeof engine?.compactRegion !== "function") {
|
|
72
|
+
log.warn("this dsh compaction has no compactRegion: low-context mode is off");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
ctx.on("agent/turn-stopping", (async ({ agent, signal }) => {
|
|
76
|
+
if (!enabled() || signal.aborted)
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
if (!taskOver(agent, ctx.get("adgGateway")))
|
|
80
|
+
return;
|
|
81
|
+
const range = lowContextRange(agent.session, { now: Date.now() });
|
|
82
|
+
if (range === null)
|
|
83
|
+
return;
|
|
84
|
+
const result = await engine.compactRegion(range.start, range.end, agent, signal);
|
|
85
|
+
log.info(`low-context: compacted ${result.shadowedSeqs.length} records (seqs ${range.start}-${range.end}) of ${agent.session.id}`);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
log.warn(`low-context compaction of ${agent.session.id} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
apply,
|
|
93
|
+
inject,
|
|
94
|
+
isMessage,
|
|
95
|
+
lowContextRange,
|
|
96
|
+
name,
|
|
97
|
+
parseLowContext,
|
|
98
|
+
settingsReader,
|
|
99
|
+
taskOver
|
|
100
|
+
};
|
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-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-UOVFYP7C.js";
|
|
5
|
+
import "./chunk-XHP3SLMO.js";
|
|
6
6
|
import {
|
|
7
7
|
writeFileAtomic
|
|
8
8
|
} from "./chunk-CCAB6XXZ.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
MONITOR_CAPABILITY,
|
|
12
12
|
MonitorSettings,
|
|
13
13
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-SA72K6M2.js";
|
|
15
15
|
import "./chunk-2UFLGPDY.js";
|
|
16
16
|
|
|
17
17
|
// packages/monitor/lib/index.js
|
package/lib/notify.js
CHANGED
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
replyPlain,
|
|
17
17
|
sessionConversations,
|
|
18
18
|
textReply
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-4PNYIZVU.js";
|
|
20
|
+
import "./chunk-IZENRXQ6.js";
|
|
21
21
|
import "./chunk-CCAB6XXZ.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-SA72K6M2.js";
|
|
23
23
|
import "./chunk-2UFLGPDY.js";
|
|
24
24
|
export {
|
|
25
25
|
AdgNotify,
|
package/lib/orchestrator.js
CHANGED
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
PARAMS_SCHEMA,
|
|
5
5
|
parseDuration,
|
|
6
6
|
taskParams
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UOVFYP7C.js";
|
|
8
8
|
import {
|
|
9
9
|
TaskInputError,
|
|
10
10
|
renderTask
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XHP3SLMO.js";
|
|
12
12
|
import {
|
|
13
13
|
MAIN,
|
|
14
14
|
finalText,
|
|
15
15
|
sessionConversations
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-4PNYIZVU.js";
|
|
17
|
+
import "./chunk-IZENRXQ6.js";
|
|
18
18
|
import {
|
|
19
19
|
writeFileAtomic
|
|
20
20
|
} from "./chunk-CCAB6XXZ.js";
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
isMarker,
|
|
34
34
|
taskMessage,
|
|
35
35
|
withStartEnd
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-SA72K6M2.js";
|
|
37
37
|
import "./chunk-2UFLGPDY.js";
|
|
38
38
|
|
|
39
39
|
// packages/orchestrator/lib/index.js
|
package/lib/qqbot.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
questionText,
|
|
5
5
|
replyMarkdown,
|
|
6
6
|
replyPlain
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-4PNYIZVU.js";
|
|
8
|
+
import "./chunk-IZENRXQ6.js";
|
|
9
9
|
import {
|
|
10
10
|
writeFileAtomic
|
|
11
11
|
} from "./chunk-CCAB6XXZ.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
QQPending,
|
|
16
16
|
QQSettings,
|
|
17
17
|
external_exports
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SA72K6M2.js";
|
|
19
19
|
import "./chunk-2UFLGPDY.js";
|
|
20
20
|
|
|
21
21
|
// packages/qqbot/lib/index.js
|
package/lib/runner.js
CHANGED
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
runnerTools,
|
|
20
20
|
setIn,
|
|
21
21
|
taskParams
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-UOVFYP7C.js";
|
|
23
|
+
import "./chunk-XHP3SLMO.js";
|
|
24
|
+
import "./chunk-SA72K6M2.js";
|
|
25
25
|
import "./chunk-2UFLGPDY.js";
|
|
26
26
|
export {
|
|
27
27
|
AdgRunner,
|
package/lib/scheduler.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
SCHEDULE_CAPABILITY,
|
|
4
4
|
external_exports
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SA72K6M2.js";
|
|
6
6
|
import "./chunk-2UFLGPDY.js";
|
|
7
7
|
|
|
8
8
|
// packages/scheduler/lib/index.js
|
package/lib/script-registry.js
CHANGED
|
@@ -32,11 +32,11 @@ import {
|
|
|
32
32
|
globToRegExp,
|
|
33
33
|
parseManifest,
|
|
34
34
|
versionOfTag
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XHP3SLMO.js";
|
|
36
36
|
import {
|
|
37
37
|
sessionConversations
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-
|
|
38
|
+
} from "./chunk-4PNYIZVU.js";
|
|
39
|
+
import "./chunk-IZENRXQ6.js";
|
|
40
40
|
import {
|
|
41
41
|
writeFileAtomic
|
|
42
42
|
} from "./chunk-CCAB6XXZ.js";
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
optimizeScriptPrompt,
|
|
60
60
|
parseGitHubLink,
|
|
61
61
|
taskMessage
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-SA72K6M2.js";
|
|
63
63
|
import "./chunk-2UFLGPDY.js";
|
|
64
64
|
|
|
65
65
|
// packages/script-registry/lib/index.js
|
|
@@ -91,7 +91,7 @@ var SCRIPT_ROLE = {
|
|
|
91
91
|
],
|
|
92
92
|
duty: [
|
|
93
93
|
"# \u4F60\u7684\u89D2\u8272\uFF1A\u811A\u672C",
|
|
94
|
-
"\u4F60\u662F MultiGameAssistant \u7684\u300C\u811A\u672C\u300Dagent\uFF1A\u5B89\u88C5\u3001\u66F4\u65B0\u548C\u4ECB\u7ECD\u811A\u672C\uFF0C\u68C0\u67E5\u548C\u4FEE\u597D\u8FD0\u884C\u73AF\u5883\uFF0C\u68C0\u67E5\u811A\u672C\u5305\uFF0C\u5B89\u88C5\u548C\u5408\u5E76\u6280\u80FD\u3002",
|
|
94
|
+
"\u4F60\u662F MultiGameAssistant \u7684\u300C\u811A\u672C\u300Dagent\uFF1A\u5B89\u88C5\u3001\u66F4\u65B0\u548C\u4ECB\u7ECD\u811A\u672C\uFF0C\u68C0\u67E5\u548C\u4FEE\u597D\u8FD0\u884C\u73AF\u5883\uFF0C\u68C0\u67E5\u811A\u672C\u5305\uFF0C\u5B89\u88C5\u548C\u5408\u5E76\u6280\u80FD\u3002\u7528\u6237\u6216\u540C\u4E8B\u8981\u5728\u6E38\u620F\u91CC\u505A\u4E00\u4EF6\u4E8B\u3001\u800C\u67D0\u4E2A\u811A\u672C\u6709\u8FD9\u4E2A\u4EFB\u52A1\u65F6\uFF0C\u4E5F\u7531\u4F60\u7528 script_run \u8FD0\u884C\u90A3\u4E2A\u4EFB\u52A1\u53BB\u505A\u3002",
|
|
95
95
|
UPDATE_RULE,
|
|
96
96
|
"script_update \u4ECE Mirror\u9171\uFF08\u8F6F\u4EF6\u91CC\u7684 CDK\uFF0C\u6216\u811A\u672C\u81EA\u5DF1\u8BBE\u7F6E\u91CC\u586B\u7684 CDK\uFF09\u6216 GitHub \u7684\u53D1\u5E03\u5305\u4E0B\u8F7D\uFF0C\u5E76\u63A5\u4E0A\u539F\u6765\u7684\u914D\u7F6E\u3002\u8FD0\u884C\u4EFB\u52A1\u524D\u8F6F\u4EF6\u4E5F\u4F1A\u5148\u8FD9\u6837\u66F4\u65B0\u4E00\u6B21\uFF08\u8DDF\u7740\u5206\u652F\u6E90\u7801\u7684\u811A\u672C\u4E0D\u4F1A\u81EA\u52A8\u66F4\u65B0\uFF09\uFF0C\u66F4\u65B0\u5931\u8D25\u5C31\u7167\u65E7\u7528\u73B0\u6709\u7248\u672C\u8FD0\u884C\u3002",
|
|
97
97
|
"\u4E0D\u8BFB\u6E38\u620F\u6D3B\u52A8\u3001\u4E0D\u5199\u65E5\u62A5\u3001\u4E0D\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\uFF1B\u9700\u8981\u8FD9\u4E9B\u65F6\u4EA4\u7ED9\u5BF9\u5E94\u7684\u540C\u4E8B\uFF08agent_delegate\uFF09\uFF0C\u6216\u8005\u5728\u56DE\u590D\u91CC\u8BF4\u6E05\u695A\u3002"
|
|
@@ -429,7 +429,8 @@ var DEFAULT_SETTINGS = {
|
|
|
429
429
|
tokenRef: "GITHUB_TOKEN",
|
|
430
430
|
keepVersions: 3,
|
|
431
431
|
includePrereleases: false,
|
|
432
|
-
cdkRef: "MIRRORCHYAN_CDK"
|
|
432
|
+
cdkRef: "MIRRORCHYAN_CDK",
|
|
433
|
+
autoUpdate: "ask"
|
|
433
434
|
};
|
|
434
435
|
var StateFile = external_exports.object({
|
|
435
436
|
version: external_exports.literal(1),
|
|
@@ -911,18 +912,24 @@ var ScriptLibrary = class {
|
|
|
911
912
|
return { upToDate: false, ...this.#jobs.start("update", id, (ctl) => this.#installJob(id, source, { byAgent: options.byAgent }, channels, this.#packOf(script), ctl)) };
|
|
912
913
|
}
|
|
913
914
|
/**
|
|
914
|
-
* Before a task runs: update when a newer version is out
|
|
915
|
-
*
|
|
915
|
+
* Before a task runs: update when a newer version is out and the settings
|
|
916
|
+
* say `auto`; otherwise only check, and leave the update to the user. Never
|
|
917
|
+
* throws — the run goes on with what it has. Left alone: a script without an update
|
|
916
918
|
* channel, one following a branch's source (official releases only), or one another job is installing. A release that is a setup
|
|
917
919
|
* program is left waiting for the agent and counts as not updated.
|
|
918
920
|
*/
|
|
919
921
|
async updateBeforeRun(id, signal) {
|
|
920
|
-
|
|
921
|
-
const channels = this.#channels(script);
|
|
922
|
-
if (channels.github === void 0 && channels.mirror === void 0 || this.#jobs.active(id) !== void 0)
|
|
923
|
-
return { state: "skipped" };
|
|
924
|
-
if (script.sourceBranch !== void 0)
|
|
922
|
+
if (!this.#checkable(id))
|
|
925
923
|
return { state: "skipped" };
|
|
924
|
+
const policy = this.#state.settings.autoUpdate;
|
|
925
|
+
if (policy !== "auto") {
|
|
926
|
+
try {
|
|
927
|
+
const check = await this.checkUpdate(id, AbortSignal.any([signal, AbortSignal.timeout(PRE_RUN_CHECK_MS)]));
|
|
928
|
+
return check.available ? { state: "available", version: check.latest, policy } : { state: "current" };
|
|
929
|
+
} catch {
|
|
930
|
+
return { state: "skipped" };
|
|
931
|
+
}
|
|
932
|
+
}
|
|
926
933
|
try {
|
|
927
934
|
const started = await this.update(id, AbortSignal.any([signal, AbortSignal.timeout(PRE_RUN_CHECK_MS)]), { byAgent: true });
|
|
928
935
|
if (started.upToDate)
|
|
@@ -941,6 +948,31 @@ var ScriptLibrary = class {
|
|
|
941
948
|
return { state: "failed", error: signal.aborted ? "\u5DF2\u505C\u6B62" : errorText(error) };
|
|
942
949
|
}
|
|
943
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Check every script that can update on its own (see {@link updateBeforeRun}) for a newer version,
|
|
953
|
+
* one after another; what it finds is on each script (`update`). Never throws.
|
|
954
|
+
*/
|
|
955
|
+
async checkUpdates(signal) {
|
|
956
|
+
for (const { id } of [...this.#state.scripts]) {
|
|
957
|
+
if (signal?.aborted === true)
|
|
958
|
+
return;
|
|
959
|
+
if (!this.#checkable(id))
|
|
960
|
+
continue;
|
|
961
|
+
try {
|
|
962
|
+
await this.checkUpdate(id, signal);
|
|
963
|
+
} catch (error) {
|
|
964
|
+
this.#options.log.info(`update check for ${id} failed: ${errorText(error)}`);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
/** It has an update channel, follows releases (not a branch's source), and nothing is installing it. */
|
|
969
|
+
#checkable(id) {
|
|
970
|
+
const script = this.#script(id);
|
|
971
|
+
const channels = this.#channels(script);
|
|
972
|
+
if (channels.github === void 0 && channels.mirror === void 0)
|
|
973
|
+
return false;
|
|
974
|
+
return script.sourceBranch === void 0 && this.#jobs.active(id) === void 0;
|
|
975
|
+
}
|
|
944
976
|
/**
|
|
945
977
|
* Set a script's update channels: a value sets it, `null` turns it off,
|
|
946
978
|
* `reset` goes back to the automatic one. How it was installed stays its
|
|
@@ -989,9 +1021,10 @@ var ScriptLibrary = class {
|
|
|
989
1021
|
const { version, archive } = fetched;
|
|
990
1022
|
if (archive === void 0 && script !== void 0) {
|
|
991
1023
|
script.current = version;
|
|
1024
|
+
delete script.update;
|
|
992
1025
|
await this.#save();
|
|
993
1026
|
this.#options.onChanged(scriptId);
|
|
994
|
-
ctl.phase("done", { message: `${version} \u5DF2\u5B89\u88C5\uFF0C\u5DF2\u5207\u6362\u4E3A\u5F53\u524D\u7248\u672C
|
|
1027
|
+
ctl.phase("done", { message: `${version} \u5DF2\u5B89\u88C5\uFF0C\u5DF2\u5207\u6362\u4E3A\u5F53\u524D\u7248\u672C`, version });
|
|
995
1028
|
return version;
|
|
996
1029
|
}
|
|
997
1030
|
const versionDir = join2(this.toolsDir, scriptId, dirName(version));
|
|
@@ -3119,6 +3152,11 @@ var describeJob = (job) => job.phase === "done" ? { ok: true, script: job.script
|
|
|
3119
3152
|
function scriptTools(library, approve) {
|
|
3120
3153
|
const repo = { type: "string", description: "GitHub \u4ED3\u5E93\uFF0C\u683C\u5F0F owner/repo\uFF0C\u4F8B\u5982 MaaAssistantArknights/MaaAssistantArknights\u3002" };
|
|
3121
3154
|
const id = { type: "string", description: "\u811A\u672C\u5E93\u91CC\u7684\u811A\u672C id\uFF08script_list \u53EF\u67E5\uFF09\u3002" };
|
|
3155
|
+
const AUTO_UPDATE_NOTE = {
|
|
3156
|
+
auto: "\u7528\u6237\u8BBE\u7F6E\u4E3A\u81EA\u52A8\u66F4\u65B0\uFF1A\u6709\u65B0\u7248\u672C\u65F6\u8FD0\u884C\u524D\u4F1A\u81EA\u52A8\u66F4\u65B0\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u81EA\u5DF1\u51B3\u5B9A\u66F4\u65B0",
|
|
3157
|
+
ask: "\u7528\u6237\u8BBE\u7F6E\u4E3A\u5148\u95EE\u518D\u66F4\u65B0\uFF1A\u6709\u65B0\u7248\u672C\u65F6\u8F6F\u4EF6\u4F1A\u5F39\u51FA\u63D0\u793A\u8BA9\u7528\u6237\u51B3\u5B9A\uFF1B\u53EA\u5728\u7528\u6237\u8981\u6C42\u65F6\u66F4\u65B0",
|
|
3158
|
+
off: "\u7528\u6237\u8BBE\u7F6E\u4E3A\u4E0D\u81EA\u52A8\u66F4\u65B0\uFF1A\u53EA\u5728\u7528\u6237\u8981\u6C42\u65F6\u66F4\u65B0"
|
|
3159
|
+
};
|
|
3122
3160
|
return [
|
|
3123
3161
|
tool({
|
|
3124
3162
|
name: TOOL_NAMES.list,
|
|
@@ -3129,8 +3167,10 @@ function scriptTools(library, approve) {
|
|
|
3129
3167
|
title: () => "\u67E5\u770B\u811A\u672C\u5E93",
|
|
3130
3168
|
execute: async () => {
|
|
3131
3169
|
const { scripts, packs, toolsDir } = library.list();
|
|
3170
|
+
const { autoUpdate } = await library.settings();
|
|
3132
3171
|
return {
|
|
3133
3172
|
toolsDir,
|
|
3173
|
+
autoUpdate: AUTO_UPDATE_NOTE[autoUpdate],
|
|
3134
3174
|
scripts: scripts.map((s) => ({ id: s.id, name: s.name, source: s.source, version: s.source.kind === "local" ? s.localVersion?.version ?? "\uFF08\u8BA4\u4E0D\u51FA\uFF09" : s.current, channels: s.channels, dir: s.dir, family: s.family, versions: s.versions.map((v) => v.version), env: s.env === void 0 ? void 0 : { ok: s.env.ok, problems: s.env.items.filter((i) => i.status !== "ok" && i.status !== "unsupported").map((i) => `${i.label}: ${i.status}`) }, update: s.update })),
|
|
3135
3175
|
availablePacks: packs.filter((p) => !p.installed && p.error === void 0).map((p) => ({ id: p.id, name: p.name, repo: p.repo, description: p.description }))
|
|
3136
3176
|
};
|
|
@@ -3229,7 +3269,7 @@ function scriptTools(library, approve) {
|
|
|
3229
3269
|
}),
|
|
3230
3270
|
tool({
|
|
3231
3271
|
name: TOOL_NAMES.update,
|
|
3232
|
-
description: "\u68C0\u67E5\u5E76\u66F4\u65B0\u811A\u672C\u5230\u6700\u65B0\u53D1\u5E03\u7248\u672C\uFF08\u586B\u4E86 Mirror\u9171 CDK \u4E14\u811A\u672C\u5728 Mirror\u9171 \u53D1\u5E03\u65F6\u4ECE\u90A3\u91CC\u4E0B\u8F7D\uFF0C\u5426\u5219\u4ECE GitHub\uFF09\u3002\u5B89\u88C5\u7684\u811A\u672C\uFF1A\u65B0\u7248\u672C\u88C5\u5728\u65E7\u7248\u672C\u65C1\u8FB9\uFF0C\u914D\u7F6E\u6587\u4EF6\u5E26\u8FC7\u53BB\uFF0C\u65E7\u7248\u672C\u4FDD\u7559\u7528\u4E8E\u56DE\u6EDA\u3002\u672C\u5730\u5BFC\u5165\u7684\u811A\u672C\uFF1A\u5728\u5B83\u81EA\u5DF1\u7684\u76EE\u5F55\u91CC\u66F4\u65B0\uFF08\u4F1A\u5148\u8BF7\u7528\u6237\u786E\u8BA4\uFF09\uFF0C\u88AB\u66FF\u6362\u7684\u6587\u4EF6\u5148\u5907\u4EFD\uFF0C\u5DF2\u6709\u7684\u914D\u7F6E\u6587\u4EF6\u4E0D\u52A8\uFF0C\u53EF\u7528 script_rollback \u64A4\u9500\uFF1B\u6CA1\u6709\u66F4\u65B0\u6765\u6E90\u65F6\u7528 repo \u6307\u5B9A\u5B83\u7684 GitHub \u4ED3\u5E93\u3002\u53EA\u66F4\u65B0\u5B98\u65B9\u53D1\u5E03\uFF0C\u4E0D\u4FEE\u6539\u811A\u672C\u4EE3\u7801\u3002",
|
|
3272
|
+
description: "\u68C0\u67E5\u5E76\u66F4\u65B0\u811A\u672C\u5230\u6700\u65B0\u53D1\u5E03\u7248\u672C\uFF08\u586B\u4E86 Mirror\u9171 CDK \u4E14\u811A\u672C\u5728 Mirror\u9171 \u53D1\u5E03\u65F6\u4ECE\u90A3\u91CC\u4E0B\u8F7D\uFF0C\u5426\u5219\u4ECE GitHub\uFF09\u3002\u5B89\u88C5\u7684\u811A\u672C\uFF1A\u65B0\u7248\u672C\u88C5\u5728\u65E7\u7248\u672C\u65C1\u8FB9\uFF0C\u914D\u7F6E\u6587\u4EF6\u5E26\u8FC7\u53BB\uFF0C\u65E7\u7248\u672C\u4FDD\u7559\u7528\u4E8E\u56DE\u6EDA\u3002\u672C\u5730\u5BFC\u5165\u7684\u811A\u672C\uFF1A\u5728\u5B83\u81EA\u5DF1\u7684\u76EE\u5F55\u91CC\u66F4\u65B0\uFF08\u4F1A\u5148\u8BF7\u7528\u6237\u786E\u8BA4\uFF09\uFF0C\u88AB\u66FF\u6362\u7684\u6587\u4EF6\u5148\u5907\u4EFD\uFF0C\u5DF2\u6709\u7684\u914D\u7F6E\u6587\u4EF6\u4E0D\u52A8\uFF0C\u53EF\u7528 script_rollback \u64A4\u9500\uFF1B\u6CA1\u6709\u66F4\u65B0\u6765\u6E90\u65F6\u7528 repo \u6307\u5B9A\u5B83\u7684 GitHub \u4ED3\u5E93\u3002\u53EA\u66F4\u65B0\u5B98\u65B9\u53D1\u5E03\uFF0C\u4E0D\u4FEE\u6539\u811A\u672C\u4EE3\u7801\u3002\u7528\u6237\u5728\u300C\u8BBE\u7F6E \u2192 \u6743\u9650\u300D\u628A\u300C\u811A\u672C\u6709\u65B0\u7248\u672C\u65F6\u300D\u8BBE\u4E3A\u300C\u81EA\u52A8\u66F4\u65B0\u300D\u65F6\u53EF\u4EE5\u81EA\u5DF1\u51B3\u5B9A\u66F4\u65B0\uFF1B\u8BBE\u4E3A\u300C\u5148\u95EE\u6211\u300D\u6216\u300C\u4E0D\u81EA\u52A8\u66F4\u65B0\u300D\u65F6\uFF0C\u53EA\u5728\u7528\u6237\u8981\u6C42\u65F6\u66F4\u65B0\u3002",
|
|
3233
3273
|
properties: {
|
|
3234
3274
|
id,
|
|
3235
3275
|
repo: { ...repo, description: "\u8BBE\u7F6E\u5B83\u7684 GitHub \u66F4\u65B0\u6E20\u9053\uFF08owner/repo\uFF09\uFF1B\u7701\u7565\u5219\u7528\u5DF2\u6709\u7684\u3002\u4ECE GitHub \u5B89\u88C5\u7684\u811A\u672C\u4E0D\u80FD\u6539\u3002" },
|
|
@@ -3407,6 +3447,8 @@ function setupHandOff(ctx, library, log) {
|
|
|
3407
3447
|
}
|
|
3408
3448
|
|
|
3409
3449
|
// packages/script-registry/lib/index.js
|
|
3450
|
+
var UPDATE_CHECK_FIRST_MS = 2 * 6e4;
|
|
3451
|
+
var UPDATE_CHECK_EVERY_MS = 6 * 60 * 6e4;
|
|
3410
3452
|
var ConfigSchema = external_exports.object({
|
|
3411
3453
|
/** Where installed scripts live: `<toolsDir>/<id>/<version>/`. */
|
|
3412
3454
|
toolsDir: external_exports.string().min(1),
|
|
@@ -3455,6 +3497,22 @@ var AdgScripts = class extends Service {
|
|
|
3455
3497
|
this.ready = library.start();
|
|
3456
3498
|
this.ready.then(() => log.info(`script library ready: ${library.list().scripts.length} script(s), tools in ${library.toolsDir}`), (error) => log.error(`script library failed to load: ${error instanceof Error ? error.message : String(error)}`));
|
|
3457
3499
|
ctx.effect(() => () => library.dispose(), "adg-scripts jobs");
|
|
3500
|
+
ctx.effect(() => {
|
|
3501
|
+
const stop = new AbortController();
|
|
3502
|
+
const check = () => {
|
|
3503
|
+
void this.ready.then(() => library.checkUpdates(stop.signal), () => {
|
|
3504
|
+
});
|
|
3505
|
+
};
|
|
3506
|
+
const first = setTimeout(check, UPDATE_CHECK_FIRST_MS);
|
|
3507
|
+
const every = setInterval(check, UPDATE_CHECK_EVERY_MS);
|
|
3508
|
+
first.unref();
|
|
3509
|
+
every.unref();
|
|
3510
|
+
return () => {
|
|
3511
|
+
stop.abort();
|
|
3512
|
+
clearTimeout(first);
|
|
3513
|
+
clearInterval(every);
|
|
3514
|
+
};
|
|
3515
|
+
}, "adg-scripts update checks");
|
|
3458
3516
|
const approve = async (exec, reason) => {
|
|
3459
3517
|
const approval = ctx.get("approval");
|
|
3460
3518
|
if (approval === void 0 || exec.agent === void 0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-multigameassistant",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "多游戏助手 MultiGameAssistant 的 dsh 插件版:让 agent 管好各个游戏的日常脚本(安装、编排定时流水线、看护运行、查活动),界面在自己的网页里。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"./scheduler": "./lib/scheduler.js",
|
|
41
41
|
"./game-intel": "./lib/game-intel.js",
|
|
42
42
|
"./agent": "./lib/agent.js",
|
|
43
|
+
"./low-context": "./lib/low-context.js",
|
|
43
44
|
"./client": "./lib/client.js",
|
|
44
45
|
"./package.json": "./package.json"
|
|
45
46
|
},
|