dsh-multigameassistant 2.0.4 → 2.1.0
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 +135 -26
- package/lib/browser.js +279 -0
- package/lib/{chunk-XHP3SLMO.js → chunk-77ZYHRN7.js} +292 -6
- package/lib/{chunk-UOVFYP7C.js → chunk-EOWM56PA.js} +398 -58
- package/lib/chunk-FH64SAZU.js +605 -0
- package/lib/{chunk-IZENRXQ6.js → chunk-MEKSHT6V.js} +1797 -575
- package/lib/chunk-RESS7WVY.js +157 -0
- package/lib/{chunk-SA72K6M2.js → chunk-SHTX4AGU.js} +1 -3572
- package/lib/{chunk-4PNYIZVU.js → chunk-TWUATN5X.js} +13 -9
- package/lib/chunk-V2X4PLF5.js +3730 -0
- package/lib/emulator.js +5 -3
- package/lib/feishu.js +8 -5
- package/lib/game-intel.js +91 -8
- package/lib/gateway.js +9 -5
- package/lib/guard.js +5 -3
- package/lib/intervene.js +62 -17
- package/lib/low-context.js +71 -87
- package/lib/monitor.js +90 -10
- package/lib/notify.js +6 -4
- package/lib/orchestrator.js +97 -27
- package/lib/packs/maa/adg.script.yaml +119 -1
- package/lib/packs/maaend/adg.script.yaml +74 -4
- package/lib/packs/march7th/adg.script.yaml +116 -0
- package/lib/qqbot.js +8 -5
- package/lib/runner.js +18 -5
- package/lib/scheduler.js +4 -2
- package/lib/script-registry.js +203 -214
- package/package.json +5 -4
- package/skills/pipeline-planning.md +8 -5
- package/skills/script-analysis.md +70 -10
- package/skills/web-reading.md +2 -0
- package/web/assets/index-C-csjWiw.js +244 -0
- package/web/assets/index-C-csjWiw.js.map +1 -0
- package/web/assets/index-CjtVfcDS.css +1 -0
- package/web/index.html +2 -2
- package/lib/chunk-CCAB6XXZ.js +0 -34
- package/web/assets/index-BqeCz6LB.css +0 -1
- package/web/assets/index-CCaVm9ks.js +0 -242
- package/web/assets/index-CCaVm9ks.js.map +0 -1
package/lib/browser.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
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
|
+
external_exports
|
|
4
|
+
} from "./chunk-SHTX4AGU.js";
|
|
5
|
+
import "./chunk-2UFLGPDY.js";
|
|
6
|
+
|
|
7
|
+
// packages/browser/lib/client.js
|
|
8
|
+
var CALL_TIMEOUT_MS = 6e4;
|
|
9
|
+
function browserClient(endpoint, fetchImpl = fetch) {
|
|
10
|
+
return async (method, params, signal) => {
|
|
11
|
+
let response;
|
|
12
|
+
try {
|
|
13
|
+
response = await fetchImpl(`${endpoint.url}/call`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: { authorization: `Bearer ${endpoint.token}`, "content-type": "application/json" },
|
|
16
|
+
body: JSON.stringify({ method, params }),
|
|
17
|
+
signal: signal === void 0 ? AbortSignal.timeout(CALL_TIMEOUT_MS) : AbortSignal.any([signal, AbortSignal.timeout(CALL_TIMEOUT_MS)])
|
|
18
|
+
});
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (signal?.aborted === true)
|
|
21
|
+
throw error;
|
|
22
|
+
throw new Error(`\u8FDE\u4E0D\u4E0A\u5185\u7F6E\u6D4F\u89C8\u5668\uFF08\u591A\u6E38\u620F\u52A9\u624B\u7684\u684C\u9762\u7A0B\u5E8F\uFF09\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
23
|
+
}
|
|
24
|
+
const body = await response.json().catch(() => void 0);
|
|
25
|
+
if (body?.ok === true)
|
|
26
|
+
return body.result;
|
|
27
|
+
throw new Error(body?.error ?? `\u5185\u7F6E\u6D4F\u89C8\u5668\u6CA1\u6709\u56DE\u7B54\uFF08HTTP ${response.status}\uFF09`);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// packages/browser/lib/tools.js
|
|
32
|
+
var BROWSER_TOOLS = {
|
|
33
|
+
navigate: "browser_navigate",
|
|
34
|
+
snapshot: "browser_snapshot",
|
|
35
|
+
click: "browser_click",
|
|
36
|
+
type: "browser_type",
|
|
37
|
+
press: "browser_press",
|
|
38
|
+
scroll: "browser_scroll",
|
|
39
|
+
screenshot: "browser_screenshot",
|
|
40
|
+
text: "browser_text",
|
|
41
|
+
tabs: "browser_tabs"
|
|
42
|
+
};
|
|
43
|
+
function parse(schema, args) {
|
|
44
|
+
const parsed = schema.safeParse(args);
|
|
45
|
+
if (!parsed.success)
|
|
46
|
+
throw new Error(`\u53C2\u6570\u65E0\u6548\uFF1A${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}`);
|
|
47
|
+
return parsed.data;
|
|
48
|
+
}
|
|
49
|
+
function renderPage(view) {
|
|
50
|
+
return `\u6807\u7B7E\u9875 ${view.tab}\uFF1A${view.title === "" ? "\uFF08\u65E0\u6807\u9898\uFF09" : view.title}
|
|
51
|
+
${view.url}${view.loading === true ? "\n\uFF08\u8FD8\u5728\u52A0\u8F7D\uFF09" : ""}
|
|
52
|
+
|
|
53
|
+
${view.snapshot}`;
|
|
54
|
+
}
|
|
55
|
+
var REF = { type: "string", description: "\u9875\u9762\u5185\u5BB9\u91CC\u7684 [ref=\u2026]\uFF08\u5982 e12\uFF09\u3002\u53EA\u5728\u6700\u8FD1\u4E00\u6B21\u8FD4\u56DE\u7684\u9875\u9762\u5185\u5BB9\u91CC\u6709\u6548\u3002" };
|
|
56
|
+
function browserTools(deps) {
|
|
57
|
+
const sessionOf = (exec) => exec.agent?.session.id;
|
|
58
|
+
const call = (exec, method, params) => {
|
|
59
|
+
const session = sessionOf(exec);
|
|
60
|
+
return deps.call(method, { ...params, ...session === void 0 ? {} : { session } }, exec.signal);
|
|
61
|
+
};
|
|
62
|
+
const given = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0 && v !== null));
|
|
63
|
+
const tool = (spec) => ({
|
|
64
|
+
name: spec.name,
|
|
65
|
+
description: spec.description,
|
|
66
|
+
parameters: { type: "object", properties: spec.properties, ...spec.required === void 0 ? {} : { required: spec.required }, additionalProperties: false },
|
|
67
|
+
output: { schema: {}, render: spec.render ?? ((_args, value) => [{ type: "text", text: renderPage(value) }]) },
|
|
68
|
+
timeoutMs: 9e4,
|
|
69
|
+
// One page, one cursor: the agent's actions on it go one after another.
|
|
70
|
+
isConcurrencySafe: () => false,
|
|
71
|
+
execute: async (args, exec) => JSON.parse(JSON.stringify(await spec.execute(args, exec) ?? null)),
|
|
72
|
+
presentCall: (args) => ({ card: "generic", title: spec.title(args ?? {}), kind: spec.readOnly === true ? "read" : "other" })
|
|
73
|
+
});
|
|
74
|
+
return [
|
|
75
|
+
tool({
|
|
76
|
+
name: BROWSER_TOOLS.navigate,
|
|
77
|
+
description: "\u5728\u5185\u7F6E\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u7F51\u9875\uFF08\u7528\u6237\u80FD\u5728\u591A\u6E38\u620F\u52A9\u624B\u7684\u6D4F\u89C8\u5668\u9762\u677F\u91CC\u770B\u5230\uFF0C\u4E5F\u80FD\u63A5\u624B\uFF09\uFF0C\u6216\u8005\u540E\u9000\u3001\u524D\u8FDB\u3001\u5237\u65B0\u3002\u9002\u5408 web_fetch \u53EA\u62FF\u5230\u6807\u9898\u6216\u7A7A\u58F3\u7684\u7F51\u9875\uFF08\u524D\u7AEF\u6E32\u67D3\u7684\u5B98\u7F51\u3001\u516C\u544A\u9875\u3001\u6D3B\u52A8\u9875\uFF09\uFF0C\u8981\u70B9\u51FB\u3001\u7FFB\u9875\u3001\u5C55\u5F00\u624D\u770B\u5F97\u5230\u7684\u5185\u5BB9\uFF0C\u6216\u8005\u7528\u6237\u8BA9\u4F60\u5728\u6D4F\u89C8\u5668\u91CC\u64CD\u4F5C\uFF1B\u666E\u901A\u7684\u9759\u6001\u9875\u9762\u548C JSON \u63A5\u53E3\u7528 web_fetch \u66F4\u7701\u3002\u8BFB\u6587\u5B57\u7528 browser_text\u3002\u6BCF\u4E2A\u5BF9\u8BDD\u6709\u81EA\u5DF1\u7684\u6807\u7B7E\u9875\uFF1B\u8FD4\u56DE\u9875\u9762\u5185\u5BB9\uFF1A\u89D2\u8272\u548C\u6587\u5B57\u6309\u5C42\u7EA7\u5217\u51FA\uFF0C\u80FD\u64CD\u4F5C\u7684\u5143\u7D20\u5E26 [ref=\u2026]\uFF0C\u63A5\u7740\u7528 browser_click / browser_type \u64CD\u4F5C\u5B83\u4EEC\u3002\u5185\u7F6E\u6D4F\u89C8\u5668\u662F\u9694\u79BB\u7684\uFF1A\u4E0D\u4FDD\u5B58\u767B\u5F55\u3001\u4E0D\u80FD\u4E0B\u8F7D\u6587\u4EF6\uFF0C\u53EA\u5F00 http / https \u7F51\u9875\u3002",
|
|
78
|
+
properties: {
|
|
79
|
+
url: { type: "string", description: "\u8981\u6253\u5F00\u7684\u7F51\u5740\uFF08\u4E0D\u5199 https:// \u4E5F\u884C\uFF09\u3002" },
|
|
80
|
+
action: { type: "string", enum: ["back", "forward", "reload"], description: "\u4E0D\u7ED9 url \u65F6\uFF1A\u540E\u9000\u3001\u524D\u8FDB\u6216\u5237\u65B0\u3002" },
|
|
81
|
+
new_tab: { type: "boolean", description: "\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00\uFF08\u539F\u6765\u7684\u7559\u7740\uFF09\u3002" }
|
|
82
|
+
},
|
|
83
|
+
title: (a) => typeof a["url"] === "string" ? `\u6253\u5F00\u7F51\u9875\uFF1A${a["url"]}` : `\u6D4F\u89C8\u5668\uFF1A${String(a["action"] ?? "")}`,
|
|
84
|
+
execute: async (args, exec) => {
|
|
85
|
+
const a = parse(external_exports.object({ url: external_exports.string().trim().min(1).nullish(), action: external_exports.enum(["back", "forward", "reload"]).nullish(), new_tab: external_exports.boolean().nullish() }), args);
|
|
86
|
+
if ((a.url ?? void 0) === void 0 && (a.action ?? void 0) === void 0)
|
|
87
|
+
throw new Error("\u8981\u7ED9 url\uFF0C\u6216 action\uFF08back / forward / reload\uFF09");
|
|
88
|
+
return call(exec, "navigate", given({ url: a.url, action: a.url === void 0 || a.url === null ? a.action : void 0, newTab: a.new_tab === true ? true : void 0 }));
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
tool({
|
|
92
|
+
name: BROWSER_TOOLS.snapshot,
|
|
93
|
+
description: "\u91CD\u65B0\u8BFB\u4E00\u904D\u5F53\u524D\u9875\u9762\u7684\u5185\u5BB9\uFF08\u5E26 [ref=\u2026]\uFF09\u3002\u6BCF\u6B21\u64CD\u4F5C\u90FD\u5DF2\u7ECF\u8FD4\u56DE\u4E86\u9875\u9762\u5185\u5BB9\uFF0C\u4E00\u822C\u4E0D\u7528\u5355\u72EC\u8C03\u7528\uFF1B\u9875\u9762\u81EA\u5DF1\u53D8\u4E86\uFF08\u7B49\u52A0\u8F7D\u3001\u5B9A\u65F6\u5237\u65B0\uFF09\u6216\u5185\u5BB9\u88AB\u622A\u65AD\u60F3\u770B\u66F4\u591A\u65F6\u518D\u7528\u3002",
|
|
94
|
+
properties: { max_chars: { type: "integer", description: "\u6700\u591A\u8FD4\u56DE\u591A\u5C11\u5B57\uFF0C\u9ED8\u8BA4 20000\uFF0C\u6700\u591A 60000\u3002" } },
|
|
95
|
+
readOnly: true,
|
|
96
|
+
title: () => "\u8BFB\u53D6\u9875\u9762",
|
|
97
|
+
execute: async (args, exec) => {
|
|
98
|
+
const a = parse(external_exports.object({ max_chars: external_exports.number().int().min(2e3).max(6e4).nullish() }), args);
|
|
99
|
+
return call(exec, "snapshot", given({ maxChars: a.max_chars }));
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
tool({
|
|
103
|
+
name: BROWSER_TOOLS.click,
|
|
104
|
+
description: "\u70B9\u51FB\u9875\u9762\u4E0A\u7684\u5143\u7D20\uFF1A\u7ED9 ref\uFF1B\u753B\u9762\u4E0A\u624D\u770B\u5F97\u5230\u7684\u4F4D\u7F6E\uFF08\u753B\u5E03\u3001\u5730\u56FE\uFF09\u53EF\u4EE5\u7ED9 browser_screenshot \u622A\u56FE\u4E0A\u7684 x\u3001y\u3002\u8FD4\u56DE\u70B9\u51FB\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002",
|
|
105
|
+
properties: {
|
|
106
|
+
ref: REF,
|
|
107
|
+
x: { type: "number", description: "\u6CA1\u6709 ref \u65F6\uFF1A\u622A\u56FE\u4E0A\u7684\u6A2A\u5750\u6807\u3002" },
|
|
108
|
+
y: { type: "number", description: "\u6CA1\u6709 ref \u65F6\uFF1A\u622A\u56FE\u4E0A\u7684\u7EB5\u5750\u6807\u3002" },
|
|
109
|
+
double: { type: "boolean", description: "\u53CC\u51FB\u3002" }
|
|
110
|
+
},
|
|
111
|
+
title: (a) => `\u70B9\u51FB\uFF1A${String(a["ref"] ?? `${String(a["x"])},${String(a["y"])}`)}`,
|
|
112
|
+
execute: async (args, exec) => {
|
|
113
|
+
const a = parse(external_exports.object({ ref: external_exports.string().nullish(), x: external_exports.number().nullish(), y: external_exports.number().nullish(), double: external_exports.boolean().nullish() }), args);
|
|
114
|
+
return call(exec, "click", given({ ref: a.ref, x: a.x, y: a.y, double: a.double }));
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
tool({
|
|
118
|
+
name: BROWSER_TOOLS.type,
|
|
119
|
+
description: "\u5728\u8F93\u5165\u6846\u91CC\u8F93\u5165\u6587\u5B57\uFF08\u9ED8\u8BA4\u5148\u6E05\u7A7A\u539F\u6765\u7684\u5185\u5BB9\uFF09\uFF1Bsubmit=true \u8F93\u5165\u540E\u6309\u56DE\u8F66\uFF08\u63D0\u4EA4\u641C\u7D22\u3001\u8868\u5355\uFF09\u3002\u8FD4\u56DE\u4E4B\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002\u4E0D\u8981\u8F93\u5165\u7528\u6237\u7684\u5BC6\u7801\u3001\u652F\u4ED8\u4FE1\u606F\u6216\u8BC1\u4EF6\u53F7\uFF1A\u9700\u8981\u767B\u5F55\u6216\u4ED8\u6B3E\u65F6\u8BF7\u7528\u6237\u5728\u6D4F\u89C8\u5668\u9762\u677F\u91CC\u81EA\u5DF1\u64CD\u4F5C\u3002",
|
|
120
|
+
properties: {
|
|
121
|
+
ref: REF,
|
|
122
|
+
text: { type: "string", description: "\u8981\u8F93\u5165\u7684\u6587\u5B57\u3002" },
|
|
123
|
+
clear: { type: "boolean", description: "\u5148\u6E05\u7A7A\u539F\u6765\u7684\u5185\u5BB9\uFF0C\u9ED8\u8BA4 true\u3002" },
|
|
124
|
+
submit: { type: "boolean", description: "\u8F93\u5165\u540E\u6309\u56DE\u8F66\u3002" }
|
|
125
|
+
},
|
|
126
|
+
required: ["ref", "text"],
|
|
127
|
+
title: (a) => `\u8F93\u5165\uFF1A${String(a["ref"] ?? "")}`,
|
|
128
|
+
execute: async (args, exec) => {
|
|
129
|
+
const a = parse(external_exports.object({ ref: external_exports.string().min(1), text: external_exports.string().max(1e4), clear: external_exports.boolean().nullish(), submit: external_exports.boolean().nullish() }), args);
|
|
130
|
+
return call(exec, "type", given({ ref: a.ref, text: a.text, clear: a.clear, submit: a.submit }));
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
tool({
|
|
134
|
+
name: BROWSER_TOOLS.press,
|
|
135
|
+
description: "\u6309\u952E\uFF1AEnter\u3001Escape\u3001Tab\u3001ArrowDown\u3001PageDown \u7B49\uFF0C\u6216\u7EC4\u5408\u952E\u5982 Control+A\u3001Shift+Tab\u3002\u6309\u5728\u5F53\u524D\u83B7\u5F97\u7126\u70B9\u7684\u5143\u7D20\u4E0A\u3002\u8FD4\u56DE\u4E4B\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002",
|
|
136
|
+
properties: { key: { type: "string", description: "\u6309\u952E\u540D\uFF0C\u6216\u7528 + \u8FDE\u8D77\u6765\u7684\u7EC4\u5408\u952E\u3002" } },
|
|
137
|
+
required: ["key"],
|
|
138
|
+
title: (a) => `\u6309\u952E\uFF1A${String(a["key"] ?? "")}`,
|
|
139
|
+
execute: async (args, exec) => {
|
|
140
|
+
const a = parse(external_exports.object({ key: external_exports.string().min(1).max(40) }), args);
|
|
141
|
+
return call(exec, "press", { key: a.key });
|
|
142
|
+
}
|
|
143
|
+
}),
|
|
144
|
+
tool({
|
|
145
|
+
name: BROWSER_TOOLS.scroll,
|
|
146
|
+
description: "\u6EDA\u52A8\u9875\u9762\uFF1Adirection \u548C amount\uFF08\u50CF\u7D20\uFF0C\u9ED8\u8BA4 600\uFF09\uFF1B\u7ED9 ref \u4E0D\u7ED9 direction \u5C31\u628A\u90A3\u4E2A\u5143\u7D20\u6EDA\u5230\u770B\u5F97\u89C1\u7684\u5730\u65B9\uFF1B\u4E24\u4E2A\u90FD\u7ED9\u5C31\u5728\u90A3\u4E2A\u5143\u7D20\uFF08\u4F8B\u5982\u4E00\u4E2A\u53EF\u4EE5\u6EDA\u52A8\u7684\u5217\u8868\uFF09\u91CC\u6EDA\u3002\u8FD4\u56DE\u4E4B\u540E\u7684\u9875\u9762\u5185\u5BB9\u3002",
|
|
147
|
+
properties: {
|
|
148
|
+
direction: { type: "string", enum: ["up", "down", "left", "right"] },
|
|
149
|
+
amount: { type: "integer", description: "\u6EDA\u591A\u5C11\u50CF\u7D20\uFF0C\u9ED8\u8BA4 600\u3002" },
|
|
150
|
+
ref: REF
|
|
151
|
+
},
|
|
152
|
+
title: (a) => `\u6EDA\u52A8\uFF1A${String(a["direction"] ?? a["ref"] ?? "down")}`,
|
|
153
|
+
execute: async (args, exec) => {
|
|
154
|
+
const a = parse(external_exports.object({ direction: external_exports.enum(["up", "down", "left", "right"]).nullish(), amount: external_exports.number().int().min(50).max(5e3).nullish(), ref: external_exports.string().nullish() }), args);
|
|
155
|
+
return call(exec, "scroll", given({ direction: a.direction, amount: a.amount, ref: a.ref }));
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
tool({
|
|
159
|
+
name: BROWSER_TOOLS.screenshot,
|
|
160
|
+
description: "\u7ED9\u5F53\u524D\u6807\u7B7E\u9875\u622A\u56FE\uFF08\u6A21\u578B\u8981\u80FD\u770B\u56FE\uFF09\u3002\u9875\u9762\u5185\u5BB9\u662F\u6587\u5B57\u65F6\u4E0D\u7528\u622A\u56FE\uFF1B\u753B\u9762\u3001\u56FE\u8868\u3001\u753B\u5E03\u3001\u9A8C\u8BC1\u6548\u679C\u65F6\u518D\u7528\u3002\u622A\u56FE\u7684\u5750\u6807\u53EF\u4EE5\u7ED9 browser_click \u7528\u3002",
|
|
161
|
+
properties: {},
|
|
162
|
+
readOnly: true,
|
|
163
|
+
title: () => "\u6D4F\u89C8\u5668\u622A\u56FE",
|
|
164
|
+
execute: async (_args, exec) => {
|
|
165
|
+
await deps.checkVision(exec);
|
|
166
|
+
const shot = await call(exec, "screenshot", {});
|
|
167
|
+
const image = await deps.saveImage(Buffer.from(shot.png, "base64"));
|
|
168
|
+
return { tab: shot.tab, url: shot.url, title: shot.title, width: shot.width, height: shot.height, image };
|
|
169
|
+
},
|
|
170
|
+
render: (_args, value) => {
|
|
171
|
+
const v = value;
|
|
172
|
+
return [
|
|
173
|
+
{ type: "text", text: `\u6807\u7B7E\u9875 ${v.tab}\uFF1A${v.title}
|
|
174
|
+
${v.url}
|
|
175
|
+
\u622A\u56FE ${v.width}\xD7${v.height}\uFF08\u5DE6\u4E0A\u89D2\u662F 0,0\uFF0Cbrowser_click \u7684 x\u3001y \u6309\u8FD9\u5F20\u56FE\uFF09` },
|
|
176
|
+
{ type: "image", attachment: v.image }
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
tool({
|
|
181
|
+
name: BROWSER_TOOLS.text,
|
|
182
|
+
description: "\u53D6\u5F53\u524D\u9875\u9762\u7684\u5168\u90E8\u53EF\u89C1\u6587\u5B57\uFF08\u4E0D\u5E26\u7ED3\u6784\u548C ref\uFF09\uFF0C\u9002\u5408\u8BFB\u957F\u6587\u7AE0\u3001\u516C\u544A\u3001\u8868\u683C\u5185\u5BB9\u3002",
|
|
183
|
+
properties: { max_chars: { type: "integer", description: "\u6700\u591A\u8FD4\u56DE\u591A\u5C11\u5B57\uFF0C\u9ED8\u8BA4 20000\uFF0C\u6700\u591A 100000\u3002" } },
|
|
184
|
+
readOnly: true,
|
|
185
|
+
title: () => "\u8BFB\u53D6\u9875\u9762\u6587\u5B57",
|
|
186
|
+
execute: async (args, exec) => {
|
|
187
|
+
const a = parse(external_exports.object({ max_chars: external_exports.number().int().min(1e3).max(1e5).nullish() }), args);
|
|
188
|
+
return call(exec, "text", given({ maxChars: a.max_chars }));
|
|
189
|
+
},
|
|
190
|
+
render: (_args, value) => {
|
|
191
|
+
const v = value;
|
|
192
|
+
return [{ type: "text", text: `\u6807\u7B7E\u9875 ${v.tab}\uFF1A${v.title}
|
|
193
|
+
${v.url}
|
|
194
|
+
|
|
195
|
+
${v.text}${v.truncated === void 0 ? "" : `
|
|
196
|
+
\u2026\uFF08\u8FD8\u6709 ${v.truncated} \u5B57\uFF0C\u52A0\u5927 max_chars \u770B\u66F4\u591A\uFF09`}` }];
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
tool({
|
|
200
|
+
name: BROWSER_TOOLS.tabs,
|
|
201
|
+
description: "\u5185\u7F6E\u6D4F\u89C8\u5668\u7684\u6807\u7B7E\u9875\uFF1Alist \u5217\u51FA\u5168\u90E8\uFF08\u6807\u51FA\u4F60\u5728\u7528\u7684\u90A3\u4E2A\uFF09\uFF1Bselect \u6362\u5230\u67D0\u4E2A\u6807\u7B7E\u9875\uFF08\u4E4B\u540E\u7684\u64CD\u4F5C\u90FD\u5728\u5B83\u4E0A\u9762\uFF0C\u4F8B\u5982\u7528\u6237\u6253\u5F00\u7684\u9875\u9762\uFF09\uFF1Bclose \u5173\u6389\u4E00\u4E2A\u3002",
|
|
202
|
+
properties: {
|
|
203
|
+
action: { type: "string", enum: ["list", "select", "close"] },
|
|
204
|
+
tab: { type: "string", description: "select / close\uFF1A\u6807\u7B7E\u9875 id\uFF08list \u53EF\u67E5\uFF09\u3002" }
|
|
205
|
+
},
|
|
206
|
+
required: ["action"],
|
|
207
|
+
title: (a) => `\u6D4F\u89C8\u5668\u6807\u7B7E\u9875\uFF1A${String(a["action"] ?? "")}`,
|
|
208
|
+
execute: async (args, exec) => {
|
|
209
|
+
const a = parse(external_exports.object({ action: external_exports.enum(["list", "select", "close"]), tab: external_exports.string().nullish() }), args);
|
|
210
|
+
if (a.action !== "list" && (a.tab ?? void 0) === void 0)
|
|
211
|
+
throw new Error(`${a.action} \u8981\u7ED9 tab`);
|
|
212
|
+
return call(exec, "tabs", given({ action: a.action, tab: a.tab }));
|
|
213
|
+
},
|
|
214
|
+
render: (_args, value) => {
|
|
215
|
+
const v = value;
|
|
216
|
+
if ("snapshot" in v)
|
|
217
|
+
return [{ type: "text", text: renderPage(v) }];
|
|
218
|
+
return [{ type: "text", text: v.tabs.length === 0 ? "\u6CA1\u6709\u6253\u5F00\u7684\u6807\u7B7E\u9875" : v.tabs.map((t) => `${t.id}${t.yours === true ? "\uFF08\u4F60\u5728\u7528\uFF09" : ""}\uFF1A${t.title === "" ? "\uFF08\u65E0\u6807\u9898\uFF09" : t.title} ${t.url}`).join("\n") }];
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// packages/browser/lib/index.js
|
|
225
|
+
var name = "adg-browser";
|
|
226
|
+
var ConfigSchema = external_exports.object({
|
|
227
|
+
/** The bridge's address (`http://127.0.0.1:<port>`); none: no browser here. */
|
|
228
|
+
endpoint: external_exports.string().url().optional(),
|
|
229
|
+
token: external_exports.string().min(1).optional()
|
|
230
|
+
});
|
|
231
|
+
function apply(ctx, config = {}, call) {
|
|
232
|
+
const spec = ConfigSchema.parse(config);
|
|
233
|
+
if (call === void 0 && (spec.endpoint === void 0 || spec.token === void 0))
|
|
234
|
+
return;
|
|
235
|
+
const browser = call ?? browserClient({ url: spec.endpoint, token: spec.token });
|
|
236
|
+
const sees = async (provider, model, signal) => {
|
|
237
|
+
const llm = ctx.get("llm");
|
|
238
|
+
if (llm === void 0)
|
|
239
|
+
return true;
|
|
240
|
+
const info = await llm.resolveModelInfo(provider, model, signal);
|
|
241
|
+
return info.inputModalities?.includes("image") === true;
|
|
242
|
+
};
|
|
243
|
+
ctx.inject(["adgGateway"], (gateway) => gateway.adgGateway.agentPart("adg-browser tools", (agent) => {
|
|
244
|
+
const tools = browserTools({
|
|
245
|
+
call: browser,
|
|
246
|
+
saveImage: async (png) => {
|
|
247
|
+
const attachments = ctx.get("attachments");
|
|
248
|
+
if (attachments === void 0)
|
|
249
|
+
throw new Error("\u6CA1\u6709\u56FE\u7247\u5B58\u50A8\u670D\u52A1\uFF0C\u65E0\u6CD5\u628A\u622A\u56FE\u4EA4\u7ED9\u6A21\u578B");
|
|
250
|
+
return { ...await attachments.saveImage({ data: png, mediaType: "image/png", name: "browser.png" }) };
|
|
251
|
+
},
|
|
252
|
+
checkVision: async (exec) => {
|
|
253
|
+
const routed = exec.agent?.session.requestHeader()?.config;
|
|
254
|
+
const provider = routed?.provider ?? exec.agent?.options.provider;
|
|
255
|
+
const model = routed?.model ?? exec.agent?.options.model;
|
|
256
|
+
if (provider === void 0 || model === void 0)
|
|
257
|
+
return;
|
|
258
|
+
if (!await sees(provider, model, exec.signal))
|
|
259
|
+
throw new Error(`\u5F53\u524D\u6A21\u578B ${model} \u4E0D\u80FD\u770B\u56FE\u7247\uFF1A\u7528 browser_snapshot \u8BFB\u9875\u9762\u5185\u5BB9\uFF0C\u6216\u6362\u4E00\u4E2A\u80FD\u770B\u56FE\u7684\u6A21\u578B`);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
const registered = tools.map((tool) => agent.tools.register({ ...tool, execute: async (args, exec) => {
|
|
263
|
+
await ctx.get("adgGateway")?.guardTool(exec);
|
|
264
|
+
return tool.execute(args, exec);
|
|
265
|
+
} }));
|
|
266
|
+
return () => {
|
|
267
|
+
for (const dispose of registered)
|
|
268
|
+
dispose();
|
|
269
|
+
};
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
BROWSER_TOOLS,
|
|
274
|
+
apply,
|
|
275
|
+
browserClient,
|
|
276
|
+
browserTools,
|
|
277
|
+
name,
|
|
278
|
+
renderPage
|
|
279
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
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
|
ScriptFamily,
|
|
4
|
-
ScriptId
|
|
4
|
+
ScriptId
|
|
5
|
+
} from "./chunk-V2X4PLF5.js";
|
|
6
|
+
import {
|
|
5
7
|
external_exports
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SHTX4AGU.js";
|
|
7
9
|
import {
|
|
8
10
|
__commonJS,
|
|
9
11
|
__require,
|
|
@@ -7340,9 +7342,6 @@ var require_dist = __commonJS({
|
|
|
7340
7342
|
}
|
|
7341
7343
|
});
|
|
7342
7344
|
|
|
7343
|
-
// packages/pack-schema/lib/parse.js
|
|
7344
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
7345
|
-
|
|
7346
7345
|
// packages/pack-schema/lib/manifest.js
|
|
7347
7346
|
var Requirement = external_exports.object({
|
|
7348
7347
|
/** e.g. `dotnet-desktop-runtime`, `vcredist`, `adb`, `python`, `node`, `emulator`. */
|
|
@@ -7420,7 +7419,9 @@ var ConfigPatch = external_exports.object({
|
|
|
7420
7419
|
when: external_exports.enum(["emulator-managed"]).optional(),
|
|
7421
7420
|
set: external_exports.array(external_exports.object({
|
|
7422
7421
|
path: external_exports.array(PathSegment).min(1),
|
|
7423
|
-
value: external_exports.unknown()
|
|
7422
|
+
value: external_exports.unknown(),
|
|
7423
|
+
/** What this change does, for people: shown in the script's guide (e.g. 「启动 MAA 后直接开始任务」). */
|
|
7424
|
+
note: external_exports.string().optional()
|
|
7424
7425
|
})).min(1)
|
|
7425
7426
|
});
|
|
7426
7427
|
var Resources = external_exports.object({
|
|
@@ -7538,6 +7539,65 @@ var Recovery = external_exports.object({
|
|
|
7538
7539
|
do: external_exports.enum(["reconnect-adb", "restart", "stop"]),
|
|
7539
7540
|
max: external_exports.number().int().min(1).max(10).default(1)
|
|
7540
7541
|
});
|
|
7542
|
+
var Text = external_exports.string().trim().min(1);
|
|
7543
|
+
var KeyRef = external_exports.object({
|
|
7544
|
+
/** One of `config.files` (a path it lists, or a file its `*` matches). */
|
|
7545
|
+
file: external_exports.string().min(1),
|
|
7546
|
+
path: external_exports.array(PathSegment).min(1)
|
|
7547
|
+
});
|
|
7548
|
+
var Guide = external_exports.object({
|
|
7549
|
+
/** What the script does and how (on an emulator, or holding the mouse), in a few sentences. */
|
|
7550
|
+
overview: Text,
|
|
7551
|
+
/** One-time setup before the first run, in order: what to set in the script's own window. */
|
|
7552
|
+
setup: external_exports.array(Text).default([]),
|
|
7553
|
+
/** What to check before each run. */
|
|
7554
|
+
checks: external_exports.array(Text).default([]),
|
|
7555
|
+
/** The script's features and how each is turned on. */
|
|
7556
|
+
features: external_exports.array(external_exports.object({
|
|
7557
|
+
title: Text,
|
|
7558
|
+
description: Text.optional(),
|
|
7559
|
+
/** How to turn it on in the script's own window: where it is and what to pick. */
|
|
7560
|
+
enable: Text,
|
|
7561
|
+
/** The config keys behind that setting and the value that turns it on. */
|
|
7562
|
+
config: external_exports.array(KeyRef.extend({ value: external_exports.unknown() })).default([]),
|
|
7563
|
+
/** Tasks that do it, by id. */
|
|
7564
|
+
tasks: external_exports.array(external_exports.string()).default([])
|
|
7565
|
+
})).default([]),
|
|
7566
|
+
/** The config files: what each holds and the keys that matter. */
|
|
7567
|
+
config: external_exports.array(external_exports.object({
|
|
7568
|
+
file: external_exports.string().min(1),
|
|
7569
|
+
/** What the file holds and when the script reads it. */
|
|
7570
|
+
about: Text,
|
|
7571
|
+
keys: external_exports.array(external_exports.object({
|
|
7572
|
+
path: external_exports.array(PathSegment).min(1),
|
|
7573
|
+
/** What the key does. */
|
|
7574
|
+
meaning: Text,
|
|
7575
|
+
/** Its values and what each means, e.g. 「True 开,False 关」. */
|
|
7576
|
+
values: Text.optional(),
|
|
7577
|
+
/** Its default, as the script writes it. */
|
|
7578
|
+
default: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional(),
|
|
7579
|
+
/** What to set it to for use with MultiGameAssistant, and why. */
|
|
7580
|
+
advice: Text.optional()
|
|
7581
|
+
})).default([])
|
|
7582
|
+
})).default([]),
|
|
7583
|
+
/** Common problems: what is seen (a log message in the script's own words, or a symptom), what it means, what to do. */
|
|
7584
|
+
troubleshooting: external_exports.array(external_exports.object({
|
|
7585
|
+
problem: Text,
|
|
7586
|
+
cause: Text.optional(),
|
|
7587
|
+
fix: Text,
|
|
7588
|
+
/** The log rule it comes from (a rule's tag). */
|
|
7589
|
+
tag: external_exports.string().optional()
|
|
7590
|
+
})).default([])
|
|
7591
|
+
});
|
|
7592
|
+
function declaresFile(files, file) {
|
|
7593
|
+
const norm = (p) => p.replace(/\\/g, "/").toLowerCase();
|
|
7594
|
+
return files.some((f) => {
|
|
7595
|
+
if (!f.path.includes("*"))
|
|
7596
|
+
return norm(f.path) === norm(file);
|
|
7597
|
+
const pattern = norm(f.path).split("*").map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/]*");
|
|
7598
|
+
return new RegExp(`^${pattern}$`).test(norm(file));
|
|
7599
|
+
});
|
|
7600
|
+
}
|
|
7541
7601
|
var ScriptManifest = external_exports.object({
|
|
7542
7602
|
id: ScriptId,
|
|
7543
7603
|
name: external_exports.string().min(1),
|
|
@@ -7589,6 +7649,8 @@ var ScriptManifest = external_exports.object({
|
|
|
7589
7649
|
logs: Logs.default({ sources: [{ stdout: true, encoding: "auto" }], rules: [] }),
|
|
7590
7650
|
recovery: external_exports.array(Recovery).default([]),
|
|
7591
7651
|
game: Game.optional(),
|
|
7652
|
+
/** The user guide shown on the 脚本 page. */
|
|
7653
|
+
guide: Guide.optional(),
|
|
7592
7654
|
intervention: open.optional(),
|
|
7593
7655
|
update: open.optional()
|
|
7594
7656
|
}).superRefine((manifest, issues) => {
|
|
@@ -7605,9 +7667,231 @@ var ScriptManifest = external_exports.object({
|
|
|
7605
7667
|
if (!tags.has(entry.on))
|
|
7606
7668
|
issues.addIssue({ code: "custom", path: ["recovery", index, "on"], message: `no log rule has tag ${entry.on} (use a rule tag, stalled or failed)` });
|
|
7607
7669
|
});
|
|
7670
|
+
const guide = manifest.guide;
|
|
7671
|
+
if (guide === void 0)
|
|
7672
|
+
return;
|
|
7673
|
+
const file = (name, path) => {
|
|
7674
|
+
if (!declaresFile(manifest.config.files, name))
|
|
7675
|
+
issues.addIssue({ code: "custom", path, message: `${name} is not one of config.files` });
|
|
7676
|
+
};
|
|
7677
|
+
guide.features.forEach((feature, index) => {
|
|
7678
|
+
feature.config.forEach((key, k) => file(key.file, ["guide", "features", index, "config", k, "file"]));
|
|
7679
|
+
feature.tasks.forEach((task, t) => {
|
|
7680
|
+
if (!ids.has(task))
|
|
7681
|
+
issues.addIssue({ code: "custom", path: ["guide", "features", index, "tasks", t], message: `no task ${task}` });
|
|
7682
|
+
});
|
|
7683
|
+
});
|
|
7684
|
+
guide.config.forEach((entry, index) => file(entry.file, ["guide", "config", index, "file"]));
|
|
7685
|
+
guide.troubleshooting.forEach((entry, index) => {
|
|
7686
|
+
if (entry.tag !== void 0 && !tags.has(entry.tag))
|
|
7687
|
+
issues.addIssue({ code: "custom", path: ["guide", "troubleshooting", index, "tag"], message: `no log rule has tag ${entry.tag}` });
|
|
7688
|
+
});
|
|
7608
7689
|
});
|
|
7609
7690
|
|
|
7691
|
+
// packages/pack-schema/lib/guide.js
|
|
7692
|
+
var FACTS = { adb: "\u6A21\u62DF\u5668\u7684 ADB \u5730\u5740", dir: "\u811A\u672C\u76EE\u5F55" };
|
|
7693
|
+
var WHEN = { "emulator-managed": "\u672C\u5E94\u7528\u542F\u52A8\u4E86\u6A21\u62DF\u5668\u65F6\uFF08\u586B\u4E86\u624B\u52A8 ADB \u5730\u5740\u65F6\u4E0D\u6539\uFF09" };
|
|
7694
|
+
function keyText(path, params = {}) {
|
|
7695
|
+
return path.map((seg) => typeof seg === "string" ? seg : typeof seg === "number" ? `[${seg}]` : `[${seg.where.field} = ${templateText(seg.where.equals, params)}]`).join(" \u203A ");
|
|
7696
|
+
}
|
|
7697
|
+
function valueText(value, params = {}) {
|
|
7698
|
+
if (typeof value === "string")
|
|
7699
|
+
return templateText(value, params);
|
|
7700
|
+
if (value === void 0)
|
|
7701
|
+
return "";
|
|
7702
|
+
return JSON.stringify(value);
|
|
7703
|
+
}
|
|
7704
|
+
function templateText(template, params) {
|
|
7705
|
+
const name = (key) => FACTS[key] ?? (params[key] === void 0 ? `{${key}}` : `\u53C2\u6570 ${key}${params[key].description === void 0 ? "" : `\uFF08${params[key].description}\uFF09`}`);
|
|
7706
|
+
const whole = /^\{([A-Za-z][A-Za-z0-9_.]*)\}$/.exec(template);
|
|
7707
|
+
if (whole !== null)
|
|
7708
|
+
return `\u300C${name(whole[1])}\u300D`;
|
|
7709
|
+
return template.replace(/\{([A-Za-z][A-Za-z0-9_.]*)\}/g, (_, key) => `\u300C${name(key)}\u300D`);
|
|
7710
|
+
}
|
|
7711
|
+
function paramValues(spec) {
|
|
7712
|
+
if (spec.enum !== void 0)
|
|
7713
|
+
return spec.enum.join("\u3001");
|
|
7714
|
+
if (spec.choices !== void 0)
|
|
7715
|
+
return `\u4ECE\u811A\u672C\u914D\u7F6E\uFF08${spec.choices.file}\uFF09\u91CC\u5DF2\u6709\u7684\u9879\u4E2D\u9009${spec.choices.create === void 0 ? "" : "\uFF0C\u4E5F\u53EF\u4EE5\u65B0\u5EFA\u4E00\u4E2A"}`;
|
|
7716
|
+
if (spec.type === "boolean")
|
|
7717
|
+
return "true\uFF08\u662F\uFF09/ false\uFF08\u5426\uFF09";
|
|
7718
|
+
return void 0;
|
|
7719
|
+
}
|
|
7720
|
+
function guideView(manifest, options) {
|
|
7721
|
+
const guide = manifest.guide;
|
|
7722
|
+
const titleOf = (id) => manifest.tasks.find((t) => t.id === id)?.title ?? id;
|
|
7723
|
+
const files = (guide?.config ?? []).map((entry) => ({
|
|
7724
|
+
file: entry.file,
|
|
7725
|
+
about: entry.about,
|
|
7726
|
+
keys: entry.keys.map((k) => ({
|
|
7727
|
+
key: keyText(k.path),
|
|
7728
|
+
meaning: k.meaning,
|
|
7729
|
+
...k.values === void 0 ? {} : { values: k.values },
|
|
7730
|
+
...k.default === void 0 ? {} : { default: String(k.default) },
|
|
7731
|
+
...k.advice === void 0 ? {} : { advice: k.advice }
|
|
7732
|
+
})),
|
|
7733
|
+
changes: []
|
|
7734
|
+
}));
|
|
7735
|
+
for (const task of manifest.tasks) {
|
|
7736
|
+
for (const patch of task.patches) {
|
|
7737
|
+
let entry = files.find((f) => f.file === patch.file) ?? files.find((f) => declaresFile([{ path: f.file }], patch.file));
|
|
7738
|
+
if (entry === void 0) {
|
|
7739
|
+
entry = { file: patch.file, keys: [], changes: [] };
|
|
7740
|
+
files.push(entry);
|
|
7741
|
+
}
|
|
7742
|
+
for (const op of patch.set) {
|
|
7743
|
+
const key = keyText(op.path, task.params);
|
|
7744
|
+
const value = valueText(op.value, task.params);
|
|
7745
|
+
const when = patch.when === void 0 ? void 0 : WHEN[patch.when] ?? patch.when;
|
|
7746
|
+
const same = entry.changes.find((c) => c.key === key && c.value === value && c.when === when);
|
|
7747
|
+
if (same !== void 0) {
|
|
7748
|
+
if (!same.tasks.includes(task.title))
|
|
7749
|
+
same.tasks.push(task.title);
|
|
7750
|
+
if (same.note === void 0 && op.note !== void 0)
|
|
7751
|
+
same.note = op.note;
|
|
7752
|
+
continue;
|
|
7753
|
+
}
|
|
7754
|
+
entry.changes.push({ key, value, ...op.note === void 0 ? {} : { note: op.note }, ...when === void 0 ? {} : { when }, tasks: [task.title] });
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7757
|
+
}
|
|
7758
|
+
const overview = guide?.overview ?? manifest.description;
|
|
7759
|
+
return {
|
|
7760
|
+
packId: manifest.id,
|
|
7761
|
+
name: manifest.name,
|
|
7762
|
+
builtin: options.builtin,
|
|
7763
|
+
written: guide !== void 0,
|
|
7764
|
+
...overview === void 0 ? {} : { overview },
|
|
7765
|
+
tasks: manifest.tasks.map((task) => ({
|
|
7766
|
+
id: task.id,
|
|
7767
|
+
title: task.title,
|
|
7768
|
+
...task.description === void 0 ? {} : { description: task.description },
|
|
7769
|
+
utterances: [...task.utterances],
|
|
7770
|
+
input: task.resources.input,
|
|
7771
|
+
...task.expectedDuration === void 0 ? {} : { expectedDuration: task.expectedDuration },
|
|
7772
|
+
params: Object.entries(task.params).map(([name, spec]) => {
|
|
7773
|
+
const values = paramValues(spec);
|
|
7774
|
+
return {
|
|
7775
|
+
name,
|
|
7776
|
+
type: spec.type,
|
|
7777
|
+
...spec.description === void 0 ? {} : { description: spec.description },
|
|
7778
|
+
...spec.default === void 0 ? {} : { default: String(spec.default) },
|
|
7779
|
+
...values === void 0 ? {} : { values }
|
|
7780
|
+
};
|
|
7781
|
+
})
|
|
7782
|
+
})),
|
|
7783
|
+
setup: [...guide?.setup ?? []],
|
|
7784
|
+
checks: [...guide?.checks ?? []],
|
|
7785
|
+
features: (guide?.features ?? []).map((f) => ({
|
|
7786
|
+
title: f.title,
|
|
7787
|
+
...f.description === void 0 ? {} : { description: f.description },
|
|
7788
|
+
enable: f.enable,
|
|
7789
|
+
config: f.config.map((k) => ({ file: k.file, key: keyText(k.path), value: valueText(k.value) })),
|
|
7790
|
+
tasks: f.tasks.map(titleOf)
|
|
7791
|
+
})),
|
|
7792
|
+
config: files,
|
|
7793
|
+
troubleshooting: (guide?.troubleshooting ?? []).map((p) => ({ problem: p.problem, ...p.cause === void 0 ? {} : { cause: p.cause }, fix: p.fix }))
|
|
7794
|
+
};
|
|
7795
|
+
}
|
|
7796
|
+
var TOOLS = [
|
|
7797
|
+
"script_analyze",
|
|
7798
|
+
"script_changelog",
|
|
7799
|
+
"script_choice_create",
|
|
7800
|
+
"script_config_get",
|
|
7801
|
+
"script_config_import",
|
|
7802
|
+
"script_config_set",
|
|
7803
|
+
"script_config_status",
|
|
7804
|
+
"script_env_check",
|
|
7805
|
+
"script_env_fix",
|
|
7806
|
+
"script_help",
|
|
7807
|
+
"script_import",
|
|
7808
|
+
"script_install",
|
|
7809
|
+
"script_list",
|
|
7810
|
+
"script_profiles",
|
|
7811
|
+
"script_releases",
|
|
7812
|
+
"script_remove",
|
|
7813
|
+
"script_rollback",
|
|
7814
|
+
"script_run",
|
|
7815
|
+
"script_run_log",
|
|
7816
|
+
"script_runs",
|
|
7817
|
+
"script_search",
|
|
7818
|
+
"script_settings",
|
|
7819
|
+
"script_setup_run",
|
|
7820
|
+
"script_stop",
|
|
7821
|
+
"script_tasks",
|
|
7822
|
+
"script_update",
|
|
7823
|
+
"pack_propose",
|
|
7824
|
+
"pack_reviewed",
|
|
7825
|
+
"skill_focus",
|
|
7826
|
+
"skill_save",
|
|
7827
|
+
"skill_hub_install",
|
|
7828
|
+
"skill_hub_list",
|
|
7829
|
+
"emulator_configure",
|
|
7830
|
+
"emulator_install",
|
|
7831
|
+
"emulator_start",
|
|
7832
|
+
"emulator_status",
|
|
7833
|
+
"emulator_stop",
|
|
7834
|
+
"game_launch",
|
|
7835
|
+
"game_locate",
|
|
7836
|
+
"game_path_set",
|
|
7837
|
+
"intervention_done",
|
|
7838
|
+
"monitor_incidents",
|
|
7839
|
+
"monitor_stall_check",
|
|
7840
|
+
"monitor_stall_set"
|
|
7841
|
+
];
|
|
7842
|
+
var AGENT_NOTES = [
|
|
7843
|
+
[new RegExp(`\\b(?:${TOOLS.join("|")})\\b`), "\u5DE5\u5177\u540D", "anywhere"],
|
|
7844
|
+
// A bare word: `resource/manifest.json` in a script's log is the script's own file.
|
|
7845
|
+
[/(?<![\w./\\-])manifest(?![\w./\\-])|adg\.script\.yaml|SKILL\.md/i, "\u811A\u672C\u5305\u7684\u6587\u4EF6", "unquoted"],
|
|
7846
|
+
[/\bpatch(?:es)?\b|\bdone-log\b|\bexit-code\b|\bstopAfterDone\b|\bselfLaunch\b|\brestore\b|\bsuccess:/i, "\u811A\u672C\u5305\u7684\u5B57\u6BB5", "unquoted"],
|
|
7847
|
+
[/\{[A-Za-z][A-Za-z0-9_.]*\}/, "\u5360\u4F4D\u7B26", "unquoted"],
|
|
7848
|
+
[/渲染器|占位符|待确认|待核验|待校准|尚未验证|未经验证|核验依据|本草稿|草稿/, "\u7ED9 agent \u7684\u5907\u6CE8", "unquoted"]
|
|
7849
|
+
];
|
|
7850
|
+
var unquoted = (text) => text.replace(/「[^」]*」/g, "\u300C\u300D");
|
|
7851
|
+
function guideIssues(manifest) {
|
|
7852
|
+
const issues = [];
|
|
7853
|
+
if (manifest.guide === void 0)
|
|
7854
|
+
issues.push("\u7F3A\u5C11 guide\uFF08\u7ED9\u7528\u6237\u770B\u7684\u4F7F\u7528\u8BF4\u660E\uFF09\uFF1A\u81F3\u5C11\u5199 overview\uFF0C\u518D\u6309\u811A\u672C\u7684\u5B9E\u9645\u60C5\u51B5\u5199 setup\u3001checks\u3001features\u3001config\u3001troubleshooting");
|
|
7855
|
+
const texts = [];
|
|
7856
|
+
for (const task of manifest.tasks) {
|
|
7857
|
+
if (task.description === void 0)
|
|
7858
|
+
issues.push(`\u4EFB\u52A1 ${task.id} \u7F3A\u5C11 description\uFF1A\u7528\u4E00\u4E24\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u8FD9\u4E2A\u4EFB\u52A1\u505A\u4EC0\u4E48`);
|
|
7859
|
+
texts.push([`tasks.${task.id}.title`, task.title], [`tasks.${task.id}.description`, task.description]);
|
|
7860
|
+
for (const [name, spec] of Object.entries(task.params)) {
|
|
7861
|
+
if (spec.description === void 0)
|
|
7862
|
+
issues.push(`\u4EFB\u52A1 ${task.id} \u7684\u53C2\u6570 ${name} \u7F3A\u5C11 description\uFF1A\u5199\u5B83\u7684\u542B\u4E49`);
|
|
7863
|
+
texts.push([`tasks.${task.id}.params.${name}.description`, spec.description]);
|
|
7864
|
+
}
|
|
7865
|
+
task.patches.forEach((patch, p) => patch.set.forEach((op, s) => texts.push([`tasks.${task.id}.patches.${p}.set.${s}.note`, op.note])));
|
|
7866
|
+
}
|
|
7867
|
+
const guide = manifest.guide;
|
|
7868
|
+
if (guide !== void 0) {
|
|
7869
|
+
texts.push(["guide.overview", guide.overview]);
|
|
7870
|
+
guide.setup.forEach((t, i) => texts.push([`guide.setup.${i}`, t]));
|
|
7871
|
+
guide.checks.forEach((t, i) => texts.push([`guide.checks.${i}`, t]));
|
|
7872
|
+
guide.features.forEach((f, i) => texts.push([`guide.features.${i}.title`, f.title], [`guide.features.${i}.description`, f.description], [`guide.features.${i}.enable`, f.enable]));
|
|
7873
|
+
guide.config.forEach((c, i) => {
|
|
7874
|
+
texts.push([`guide.config.${i}.about`, c.about]);
|
|
7875
|
+
c.keys.forEach((k, j) => texts.push([`guide.config.${i}.keys.${j}.meaning`, k.meaning], [`guide.config.${i}.keys.${j}.values`, k.values], [`guide.config.${i}.keys.${j}.advice`, k.advice]));
|
|
7876
|
+
});
|
|
7877
|
+
guide.troubleshooting.forEach((t, i) => texts.push([`guide.troubleshooting.${i}.problem`, t.problem], [`guide.troubleshooting.${i}.cause`, t.cause], [`guide.troubleshooting.${i}.fix`, t.fix]));
|
|
7878
|
+
}
|
|
7879
|
+
for (const [where, text] of texts) {
|
|
7880
|
+
if (text === void 0)
|
|
7881
|
+
continue;
|
|
7882
|
+
for (const [pattern, what, scope] of AGENT_NOTES) {
|
|
7883
|
+
const found = pattern.exec(scope === "anywhere" ? text : unquoted(text));
|
|
7884
|
+
if (found === null)
|
|
7885
|
+
continue;
|
|
7886
|
+
issues.push(`${where} \u91CC\u6709${what}\u300C${found[0]}\u300D\uFF1A\u4F7F\u7528\u8BF4\u660E\u53EA\u5199\u7528\u6237\u8981\u77E5\u9053\u7684\uFF08\u80FD\u505A\u4EC0\u4E48\u3001\u600E\u4E48\u8BBE\u7F6E\u3001\u51FA\u9519\u600E\u4E48\u529E\uFF09\uFF1B\u5DE5\u5177\u7528\u6CD5\u3001\u811A\u672C\u5305\u5185\u90E8\u3001\u6838\u9A8C\u4F9D\u636E\u548C\u5F85\u786E\u8BA4\u5199\u8FDB SKILL.md${scope === "unquoted" ? "\u3002\u5982\u679C\u8FD9\u662F\u811A\u672C\u81EA\u5DF1\u7684\u65E5\u5FD7\u539F\u6587\u6216\u754C\u9762\u6587\u5B57\uFF0C\u7528\u300C\u300D\u62EC\u8D77\u6765\u3001\u539F\u6837\u4FDD\u7559\uFF0C\u4E0D\u8981\u6539\u5199" : ""}`);
|
|
7887
|
+
break;
|
|
7888
|
+
}
|
|
7889
|
+
}
|
|
7890
|
+
return issues;
|
|
7891
|
+
}
|
|
7892
|
+
|
|
7610
7893
|
// packages/pack-schema/lib/parse.js
|
|
7894
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
7611
7895
|
var PackError = class extends Error {
|
|
7612
7896
|
file;
|
|
7613
7897
|
issues;
|
|
@@ -7893,6 +8177,8 @@ var MANIFEST_FILE = "adg.script.yaml";
|
|
|
7893
8177
|
var SKILL_FILE = "SKILL.md";
|
|
7894
8178
|
|
|
7895
8179
|
export {
|
|
8180
|
+
guideView,
|
|
8181
|
+
guideIssues,
|
|
7896
8182
|
TaskInputError,
|
|
7897
8183
|
renderTask,
|
|
7898
8184
|
require_dist,
|