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.
Files changed (40) hide show
  1. package/cordis.patch.yml +178 -4
  2. package/lib/analyzer.js +135 -26
  3. package/lib/browser.js +279 -0
  4. package/lib/{chunk-XHP3SLMO.js → chunk-77ZYHRN7.js} +292 -6
  5. package/lib/{chunk-UOVFYP7C.js → chunk-EOWM56PA.js} +398 -58
  6. package/lib/chunk-FH64SAZU.js +605 -0
  7. package/lib/{chunk-IZENRXQ6.js → chunk-MEKSHT6V.js} +1797 -575
  8. package/lib/chunk-RESS7WVY.js +157 -0
  9. package/lib/{chunk-SA72K6M2.js → chunk-SHTX4AGU.js} +1 -3572
  10. package/lib/{chunk-4PNYIZVU.js → chunk-TWUATN5X.js} +13 -9
  11. package/lib/chunk-V2X4PLF5.js +3730 -0
  12. package/lib/emulator.js +5 -3
  13. package/lib/feishu.js +8 -5
  14. package/lib/game-intel.js +91 -8
  15. package/lib/gateway.js +9 -5
  16. package/lib/guard.js +5 -3
  17. package/lib/intervene.js +62 -17
  18. package/lib/low-context.js +71 -87
  19. package/lib/monitor.js +90 -10
  20. package/lib/notify.js +6 -4
  21. package/lib/orchestrator.js +97 -27
  22. package/lib/packs/maa/adg.script.yaml +119 -1
  23. package/lib/packs/maaend/adg.script.yaml +74 -4
  24. package/lib/packs/march7th/adg.script.yaml +116 -0
  25. package/lib/qqbot.js +8 -5
  26. package/lib/runner.js +18 -5
  27. package/lib/scheduler.js +4 -2
  28. package/lib/script-registry.js +203 -214
  29. package/package.json +5 -4
  30. package/skills/pipeline-planning.md +8 -5
  31. package/skills/script-analysis.md +70 -10
  32. package/skills/web-reading.md +2 -0
  33. package/web/assets/index-C-csjWiw.js +244 -0
  34. package/web/assets/index-C-csjWiw.js.map +1 -0
  35. package/web/assets/index-CjtVfcDS.css +1 -0
  36. package/web/index.html +2 -2
  37. package/lib/chunk-CCAB6XXZ.js +0 -34
  38. package/web/assets/index-BqeCz6LB.css +0 -1
  39. package/web/assets/index-CCaVm9ks.js +0 -242
  40. package/web/assets/index-CCaVm9ks.js.map +0 -1
@@ -0,0 +1,3730 @@
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
+
6
+ // packages/protocol/lib/emulators.js
7
+ var EMULATORS_CAPABILITY = "emulators";
8
+ var EmulatorInstance = external_exports.object({
9
+ index: external_exports.number().int().min(0),
10
+ name: external_exports.string(),
11
+ /** The emulator process is up. */
12
+ running: external_exports.boolean(),
13
+ /** Android has finished booting. */
14
+ ready: external_exports.boolean(),
15
+ adb: external_exports.string().optional()
16
+ });
17
+ var EmulatorProvider = external_exports.object({
18
+ kind: external_exports.enum(["mumu"]),
19
+ name: external_exports.string(),
20
+ /** The manager program used for control, e.g. MuMuManager.exe. */
21
+ manager: external_exports.string(),
22
+ version: external_exports.string().optional(),
23
+ instances: external_exports.array(EmulatorInstance),
24
+ error: external_exports.string().optional()
25
+ });
26
+ var EmulatorSettings = external_exports.object({
27
+ /** MuMuManager.exe chosen by the user; otherwise found automatically. */
28
+ mumuManager: external_exports.string().optional(),
29
+ /** Instance tasks use. */
30
+ instance: external_exports.number().int().min(0).max(63),
31
+ /**
32
+ * Use this ADB address instead of managing an emulator (any emulator or
33
+ * device the user starts themselves).
34
+ */
35
+ manualAddress: external_exports.string().regex(/^[\w.-]+:\d{1,5}$/).optional(),
36
+ /** adb.exe for reconnecting and screenshots; otherwise the one next to MuMuManager.exe, else `adb` on PATH. */
37
+ adbPath: external_exports.string().optional(),
38
+ /** Start the instance when a task needs it. */
39
+ autoStart: external_exports.boolean(),
40
+ /** Seconds to wait for Android to finish booting. */
41
+ bootTimeoutSeconds: external_exports.number().int().min(30).max(900)
42
+ });
43
+ var Status = external_exports.object({
44
+ providers: external_exports.array(EmulatorProvider),
45
+ settings: EmulatorSettings,
46
+ /** What a task would use right now, or why it cannot. */
47
+ selection: external_exports.object({ label: external_exports.string(), address: external_exports.string().optional(), problem: external_exports.string().optional() })
48
+ });
49
+ var EmulatorRequests = {
50
+ "emulators/status": {
51
+ capability: EMULATORS_CAPABILITY,
52
+ params: external_exports.object({ refresh: external_exports.boolean().optional() }),
53
+ result: Status
54
+ },
55
+ "emulators/start": {
56
+ capability: EMULATORS_CAPABILITY,
57
+ params: external_exports.object({ index: external_exports.number().int().min(0).optional() }),
58
+ result: external_exports.object({ address: external_exports.string(), label: external_exports.string() })
59
+ },
60
+ "emulators/stop": {
61
+ capability: EMULATORS_CAPABILITY,
62
+ params: external_exports.object({ index: external_exports.number().int().min(0).optional() }),
63
+ result: external_exports.object({})
64
+ },
65
+ "emulators/settings/set": {
66
+ capability: EMULATORS_CAPABILITY,
67
+ params: EmulatorSettings.partial().extend({ mumuManager: external_exports.string().nullable().optional(), manualAddress: external_exports.string().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(), adbPath: external_exports.string().nullable().optional() }),
68
+ result: EmulatorSettings
69
+ }
70
+ };
71
+ var EmulatorNotifications = {
72
+ "emulators/changed": external_exports.object({})
73
+ };
74
+
75
+ // packages/protocol/lib/scripts.js
76
+ var SCRIPTS_CAPABILITY = "scripts";
77
+ var ScriptFamily = external_exports.enum(["maafw-pi", "cli", "gui-config", "generic-process", "visual"]);
78
+ var ScriptId = external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/, "use lowercase letters, digits, dot, dash or underscore (max 64)");
79
+ var GitHubRepo = external_exports.string().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/, "use owner/repo");
80
+ var MirrorRid = external_exports.string().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/, "use the resource id, e.g. MAA or BGI");
81
+ var ScriptSource = external_exports.discriminatedUnion("kind", [
82
+ /** Installed by MultiGameAssistant into the tools directory. */
83
+ external_exports.object({ kind: external_exports.literal("github"), repo: external_exports.string() }),
84
+ /** Installed into the tools directory from Mirror酱 (`platform`: asked with os and arch; `os` / `arch` each on its own). */
85
+ external_exports.object({ kind: external_exports.literal("mirrorchyan"), rid: external_exports.string(), platform: external_exports.boolean(), os: external_exports.boolean().optional(), arch: external_exports.boolean().optional() }),
86
+ /** A directory the user already had; used in place, never moved or deleted. */
87
+ external_exports.object({ kind: external_exports.literal("local"), path: external_exports.string() })
88
+ ]);
89
+ var ScriptVersion = external_exports.object({
90
+ version: external_exports.string(),
91
+ dir: external_exports.string(),
92
+ installedAt: external_exports.number(),
93
+ asset: external_exports.object({ name: external_exports.string(), size: external_exports.number() }).optional(),
94
+ current: external_exports.boolean()
95
+ });
96
+ var EnvStatus = external_exports.enum(["ok", "missing", "outdated", "unknown", "unsupported"]);
97
+ var EnvItem = external_exports.object({
98
+ /** Requirement kind, e.g. `dotnet-desktop-runtime`, `vcredist`, `adb`, `python`. */
99
+ kind: external_exports.string(),
100
+ label: external_exports.string(),
101
+ /** Version range asked for, e.g. `>=8`. */
102
+ required: external_exports.string().optional(),
103
+ status: EnvStatus,
104
+ /** What was found (version or path). */
105
+ found: external_exports.string().optional(),
106
+ detail: external_exports.string().optional(),
107
+ /** How it can be fixed, when it is not `ok`. */
108
+ fix: external_exports.object({
109
+ /** `auto`: downloaded and set up without prompts; `installer`: runs an official installer (UAC); `manual`: instructions only. */
110
+ kind: external_exports.enum(["auto", "installer", "manual"]),
111
+ description: external_exports.string(),
112
+ needsAdmin: external_exports.boolean()
113
+ }).optional()
114
+ });
115
+ var EnvReport = external_exports.object({
116
+ checkedAt: external_exports.number(),
117
+ /** True when every item is `ok` (unsupported items do not count against it). */
118
+ ok: external_exports.boolean(),
119
+ items: external_exports.array(EnvItem)
120
+ });
121
+ var ProjectProbe = external_exports.object({
122
+ /** Executables and launch scripts near the top of the tree, relative paths. */
123
+ executables: external_exports.array(external_exports.string()),
124
+ /** Marker files found, e.g. `interface.json`, `pyproject.toml`, `README.md`. */
125
+ markers: external_exports.array(external_exports.string()),
126
+ /** Best guess at the adapter family from the markers alone. */
127
+ family: ScriptFamily.optional()
128
+ });
129
+ var ChannelFrom = external_exports.enum(["install", "pack", "known", "user"]);
130
+ var UpdateChannels = external_exports.object({
131
+ github: external_exports.object({ repo: external_exports.string(), from: ChannelFrom }).optional(),
132
+ mirrorchyan: external_exports.object({ rid: external_exports.string(), from: ChannelFrom }).optional()
133
+ });
134
+ var LocalVersion = external_exports.object({ version: external_exports.string(), from: external_exports.string() });
135
+ var ScriptSummary = external_exports.object({
136
+ state: external_exports.enum(["running", "done", "failed"]),
137
+ at: external_exports.number(),
138
+ /** The summary; on failure, why. */
139
+ text: external_exports.string().optional(),
140
+ /** The agent session that wrote it. */
141
+ sessionId: external_exports.string().optional()
142
+ });
143
+ var ScriptInfo = external_exports.object({
144
+ id: external_exports.string(),
145
+ name: external_exports.string(),
146
+ source: ScriptSource,
147
+ /** Script Pack describing it, when one matches. */
148
+ packId: external_exports.string().optional(),
149
+ family: ScriptFamily.optional(),
150
+ /** Current version and its directory; local imports use `local`. */
151
+ current: external_exports.string().optional(),
152
+ dir: external_exports.string().optional(),
153
+ versions: external_exports.array(ScriptVersion),
154
+ env: EnvReport.optional(),
155
+ probe: ProjectProbe.optional(),
156
+ update: external_exports.object({ latest: external_exports.string(), available: external_exports.boolean(), checkedAt: external_exports.number() }).optional(),
157
+ /** Where its updates come from. */
158
+ channels: UpdateChannels,
159
+ /** The entry of the known-project list it was recognized as (no pack describes it). */
160
+ known: external_exports.string().optional(),
161
+ /** The version found in a local import's directory; absent when it could not be read. */
162
+ localVersion: LocalVersion.optional(),
163
+ /** The last in-place update of a local import, which can be undone. */
164
+ undo: external_exports.object({ from: external_exports.string().optional(), to: external_exports.string(), at: external_exports.number() }).optional(),
165
+ /** Job currently working on this script. */
166
+ jobId: external_exports.string().optional(),
167
+ addedAt: external_exports.number(),
168
+ summary: ScriptSummary.optional(),
169
+ /**
170
+ * The script was updated after its (non-built-in) pack was written or last
171
+ * checked: `from` the version the pack is for, `to` the version now. The
172
+ * user is asked whether the agent should read the changelog and check it.
173
+ */
174
+ packReview: external_exports.object({ from: external_exports.string().optional(), to: external_exports.string() }).optional(),
175
+ /**
176
+ * 优化脚本: clean runs since it was last optimized (or the offer turned down),
177
+ * when that was, and `due` when the app offers it: `runs` enough of them to
178
+ * learn from, `updated` it went through on a new version.
179
+ */
180
+ optimize: external_exports.object({ runs: external_exports.number(), at: external_exports.number().optional(), due: external_exports.enum(["runs", "updated"]).optional() }).optional()
181
+ });
182
+ var PackSummary = external_exports.object({
183
+ id: external_exports.string(),
184
+ name: external_exports.string(),
185
+ description: external_exports.string().optional(),
186
+ repo: external_exports.string().optional(),
187
+ /** Its resource id on Mirror酱, when it is published there. */
188
+ mirrorchyan: external_exports.string().optional(),
189
+ family: ScriptFamily.optional(),
190
+ /** Shipped with MultiGameAssistant (false: in the user's pack directory). */
191
+ builtin: external_exports.boolean(),
192
+ /** A script with this pack is in the library. */
193
+ installed: external_exports.boolean(),
194
+ /** Problems loading the pack, if any; the pack is skipped. */
195
+ error: external_exports.string().optional()
196
+ });
197
+ var PackGuide = external_exports.object({
198
+ packId: external_exports.string(),
199
+ name: external_exports.string(),
200
+ builtin: external_exports.boolean(),
201
+ /** The pack has a written guide; without one only its tasks and run changes are known. */
202
+ written: external_exports.boolean(),
203
+ overview: external_exports.string().optional(),
204
+ tasks: external_exports.array(external_exports.object({
205
+ id: external_exports.string(),
206
+ title: external_exports.string(),
207
+ description: external_exports.string().optional(),
208
+ utterances: external_exports.array(external_exports.string()),
209
+ /** `desktop` takes the mouse and keyboard; `adb` an emulator; `window` the game's window in the background. */
210
+ input: external_exports.enum(["desktop", "window", "adb", "none"]),
211
+ expectedDuration: external_exports.string().optional(),
212
+ params: external_exports.array(external_exports.object({
213
+ name: external_exports.string(),
214
+ type: external_exports.enum(["string", "integer", "number", "boolean"]),
215
+ description: external_exports.string().optional(),
216
+ default: external_exports.string().optional(),
217
+ /** Its allowed values: listed, or where they come from. */
218
+ values: external_exports.string().optional()
219
+ }))
220
+ })),
221
+ setup: external_exports.array(external_exports.string()),
222
+ checks: external_exports.array(external_exports.string()),
223
+ features: external_exports.array(external_exports.object({
224
+ title: external_exports.string(),
225
+ description: external_exports.string().optional(),
226
+ enable: external_exports.string(),
227
+ config: external_exports.array(external_exports.object({ file: external_exports.string(), key: external_exports.string(), value: external_exports.string() })),
228
+ /** Titles of the tasks that do it. */
229
+ tasks: external_exports.array(external_exports.string())
230
+ })),
231
+ config: external_exports.array(external_exports.object({
232
+ file: external_exports.string(),
233
+ about: external_exports.string().optional(),
234
+ keys: external_exports.array(external_exports.object({ key: external_exports.string(), meaning: external_exports.string(), values: external_exports.string().optional(), default: external_exports.string().optional(), advice: external_exports.string().optional() })),
235
+ /** What runs set in it for themselves; the file is put back after each run. */
236
+ changes: external_exports.array(external_exports.object({
237
+ key: external_exports.string(),
238
+ value: external_exports.string(),
239
+ note: external_exports.string().optional(),
240
+ /** Only then (e.g. 本应用启动了模拟器时). */
241
+ when: external_exports.string().optional(),
242
+ /** Titles of the tasks that make it. */
243
+ tasks: external_exports.array(external_exports.string())
244
+ }))
245
+ })),
246
+ troubleshooting: external_exports.array(external_exports.object({ problem: external_exports.string(), cause: external_exports.string().optional(), fix: external_exports.string() }))
247
+ });
248
+ var MirrorLookup = external_exports.object({
249
+ rid: external_exports.string(),
250
+ version: external_exports.string(),
251
+ platform: external_exports.boolean(),
252
+ os: external_exports.boolean().optional(),
253
+ arch: external_exports.boolean().optional(),
254
+ name: external_exports.string().optional(),
255
+ description: external_exports.string().optional(),
256
+ repo: external_exports.string().optional()
257
+ });
258
+ var MirrorSearchItem = external_exports.object({
259
+ rid: external_exports.string(),
260
+ name: external_exports.string(),
261
+ description: external_exports.string(),
262
+ repo: external_exports.string().optional(),
263
+ url: external_exports.string().optional(),
264
+ /** A script with this resource is in the library. */
265
+ installed: external_exports.boolean(),
266
+ /** A pack or MultiGameAssistant's list knows it (curated). */
267
+ known: external_exports.boolean()
268
+ });
269
+ var KnownProjectSummary = external_exports.object({
270
+ id: external_exports.string(),
271
+ name: external_exports.string(),
272
+ repo: external_exports.string().optional(),
273
+ mirrorchyan: external_exports.string().optional(),
274
+ /** A script with this project is in the library. */
275
+ installed: external_exports.boolean()
276
+ });
277
+ var ReleaseAsset = external_exports.object({ name: external_exports.string(), size: external_exports.number(), downloadUrl: external_exports.string(), digest: external_exports.string().optional() });
278
+ var ReleaseInfo = external_exports.object({
279
+ tag: external_exports.string(),
280
+ name: external_exports.string(),
281
+ prerelease: external_exports.boolean(),
282
+ publishedAt: external_exports.string().optional(),
283
+ url: external_exports.string().optional(),
284
+ assets: external_exports.array(ReleaseAsset),
285
+ /** Asset MultiGameAssistant would pick for this machine. */
286
+ suggestedAsset: external_exports.string().optional(),
287
+ /** Its release notes (markdown), as published. */
288
+ notes: external_exports.string().optional()
289
+ });
290
+ var ScriptJobPhase = external_exports.enum(["queued", "resolving", "downloading", "verifying", "extracting", "checking", "running", "done", "failed", "cancelled"]);
291
+ var SetupAgent = external_exports.object({ sessionId: external_exports.string(), state: external_exports.enum(["running", "failed"]), reason: external_exports.string().optional() });
292
+ var PendingSetupInfo = external_exports.object({
293
+ scriptId: external_exports.string(),
294
+ name: external_exports.string(),
295
+ kind: external_exports.enum(["nsis", "inno", "kachina"]),
296
+ version: external_exports.string(),
297
+ /** Where it installs (prefilled in its window): a new version folder, or a local import's own. */
298
+ dir: external_exports.string(),
299
+ /** Updating a script already in the library. */
300
+ update: external_exports.boolean(),
301
+ at: external_exports.number(),
302
+ agent: SetupAgent.optional()
303
+ });
304
+ var ScriptJob = external_exports.object({
305
+ id: external_exports.string(),
306
+ kind: external_exports.enum(["install", "update", "env-fix"]),
307
+ scriptId: external_exports.string(),
308
+ phase: ScriptJobPhase,
309
+ message: external_exports.string().optional(),
310
+ received: external_exports.number().optional(),
311
+ total: external_exports.number().optional(),
312
+ version: external_exports.string().optional(),
313
+ error: external_exports.string().optional(),
314
+ /** The release was a setup program (not an archive), left for the agent to run into `dir`; in that conversation when the app started one. */
315
+ setup: external_exports.object({ kind: external_exports.enum(["nsis", "inno", "kachina"]), dir: external_exports.string(), sessionId: external_exports.string().optional() }).optional(),
316
+ startedAt: external_exports.number(),
317
+ endedAt: external_exports.number().optional()
318
+ });
319
+ var ScriptUpdatePolicy = external_exports.enum(["auto", "ask", "off"]);
320
+ var InstallSettings = external_exports.object({
321
+ /** GitHub REST API base. */
322
+ apiBase: external_exports.url({ protocol: /^https?$/ }),
323
+ /**
324
+ * Prefix put before release download URLs (ghproxy style, e.g.
325
+ * `https://ghfast.top/`); empty downloads directly.
326
+ */
327
+ downloadMirror: external_exports.string().trim().max(300),
328
+ /** Retry directly when the mirror fails. */
329
+ mirrorFallback: external_exports.boolean(),
330
+ /** Credential holding an optional GitHub token (raises the API rate limit). */
331
+ tokenRef: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),
332
+ /** Installed versions kept per script for rollback, including the current one. */
333
+ keepVersions: external_exports.number().int().min(1).max(10),
334
+ /** Offer pre-releases when no stable release exists. */
335
+ includePrereleases: external_exports.boolean(),
336
+ /** Credential holding the user's Mirror酱 CDK: scripts published there update from it (incremental when possible). */
337
+ cdkRef: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),
338
+ /** What happens when a script has a newer version. */
339
+ autoUpdate: ScriptUpdatePolicy
340
+ });
341
+ var Empty = external_exports.object({});
342
+ var ById = external_exports.object({ id: ScriptId });
343
+ var ScriptRequests = {
344
+ /** Library, plus the packs that could be installed. */
345
+ "scripts/list": {
346
+ capability: SCRIPTS_CAPABILITY,
347
+ params: Empty,
348
+ result: external_exports.object({ scripts: external_exports.array(ScriptInfo), packs: external_exports.array(PackSummary), known: external_exports.array(KnownProjectSummary), setups: external_exports.array(PendingSetupInfo).default([]), toolsDir: external_exports.string() })
349
+ },
350
+ "scripts/get": {
351
+ capability: SCRIPTS_CAPABILITY,
352
+ params: ById,
353
+ result: ScriptInfo
354
+ },
355
+ /** The script's user guide, from its pack; null without a pack. */
356
+ "scripts/guide": {
357
+ capability: SCRIPTS_CAPABILITY,
358
+ params: ById,
359
+ result: external_exports.object({ guide: PackGuide.nullable() })
360
+ },
361
+ /**
362
+ * An installed script's program icon (the program its pack opens for its settings, else the one it runs),
363
+ * for its avatar on the 脚本 page. No `icon`: not installed, no pack, or not on Windows.
364
+ */
365
+ "scripts/icon": {
366
+ capability: SCRIPTS_CAPABILITY,
367
+ params: ById,
368
+ result: external_exports.object({ icon: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() }).optional() })
369
+ },
370
+ /** Search GitHub repositories; packs whose repo matches are marked. */
371
+ "scripts/search": {
372
+ capability: SCRIPTS_CAPABILITY,
373
+ params: external_exports.object({ query: external_exports.string().trim().min(1).max(200) }),
374
+ result: external_exports.object({ items: external_exports.array(external_exports.object({ repo: external_exports.string(), description: external_exports.string().optional(), stars: external_exports.number(), packId: external_exports.string().optional() })) })
375
+ },
376
+ /** Recent releases of a repository, newest first, with the suggested asset. */
377
+ "scripts/releases": {
378
+ capability: SCRIPTS_CAPABILITY,
379
+ params: external_exports.object({ repo: GitHubRepo, limit: external_exports.number().int().min(1).max(30).optional() }),
380
+ result: external_exports.object({ repo: external_exports.string(), packId: external_exports.string().optional(), releases: external_exports.array(ReleaseInfo) })
381
+ },
382
+ /**
383
+ * Start installing a release from GitHub (`repo`) or Mirror酱
384
+ * (`mirrorchyan`, needs a CDK); progress arrives as `scripts/job`.
385
+ */
386
+ "scripts/install": {
387
+ capability: SCRIPTS_CAPABILITY,
388
+ params: external_exports.object({
389
+ repo: GitHubRepo.optional(),
390
+ /** A Mirror酱 resource id, instead of `repo`; tag and asset do not apply. */
391
+ mirrorchyan: MirrorRid.optional(),
392
+ /** Release tag; omitted takes the latest stable (or pre-release, if allowed and none is stable). */
393
+ tag: external_exports.string().min(1).max(200).optional(),
394
+ /** Asset name; omitted takes the suggested one. */
395
+ asset: external_exports.string().min(1).max(300).optional(),
396
+ /** Install this branch's source instead of a release (a repository without releases gets its default branch anyway). */
397
+ branch: external_exports.string().min(1).max(200).optional(),
398
+ /** Script id; omitted uses the matching pack's id, else the repo name. */
399
+ id: ScriptId.optional()
400
+ }).refine((p) => p.repo === void 0 !== (p.mirrorchyan === void 0), "give either repo or mirrorchyan"),
401
+ result: external_exports.object({ jobId: external_exports.string(), scriptId: external_exports.string() })
402
+ },
403
+ /**
404
+ * Compare the current version with the latest release (Mirror酱 with a CDK,
405
+ * else GitHub). A local import is compared by the version found in its
406
+ * directory, against its update source.
407
+ */
408
+ "scripts/checkUpdate": {
409
+ capability: SCRIPTS_CAPABILITY,
410
+ params: ById,
411
+ result: external_exports.object({ current: external_exports.string().optional(), latest: external_exports.string(), available: external_exports.boolean() })
412
+ },
413
+ /**
414
+ * Install the latest release next to the current one, carrying the pack's
415
+ * config files over. A local import is updated in its own directory: the
416
+ * files it replaces or removes are backed up first (`scripts/restore`
417
+ * puts them back) and the pack's existing config files are left alone.
418
+ */
419
+ "scripts/update": {
420
+ capability: SCRIPTS_CAPABILITY,
421
+ params: ById,
422
+ result: external_exports.object({ jobId: external_exports.string().optional(), upToDate: external_exports.boolean() })
423
+ },
424
+ /**
425
+ * Set a script's update channels: a value sets it, `null` turns it off,
426
+ * omitted leaves it, `reset` goes back to the automatic one (its pack's,
427
+ * or the known project's). A script installed from GitHub keeps its
428
+ * repository; one installed from Mirror酱 keeps its resource.
429
+ */
430
+ "scripts/source/set": {
431
+ capability: SCRIPTS_CAPABILITY,
432
+ params: external_exports.object({
433
+ id: ScriptId,
434
+ repo: GitHubRepo.nullable().optional(),
435
+ mirrorchyan: MirrorRid.nullable().optional(),
436
+ reset: external_exports.array(external_exports.enum(["repo", "mirrorchyan"])).optional()
437
+ }),
438
+ result: ScriptInfo
439
+ },
440
+ /**
441
+ * Whether a library script is on Mirror酱 (no CDK needed): the projects
442
+ * whose GitHub repository is its repository, else whose name matches.
443
+ */
444
+ "scripts/mirrorchyan/match": {
445
+ capability: SCRIPTS_CAPABILITY,
446
+ params: ById,
447
+ result: external_exports.object({ items: external_exports.array(MirrorSearchItem.extend({ by: external_exports.enum(["repo", "name"]) })), from: external_exports.enum(["mirrorchyan", "builtin"]) })
448
+ },
449
+ /** Whether Mirror酱 has a resource, and its latest version (no CDK needed). */
450
+ "scripts/mirrorchyan/lookup": {
451
+ capability: SCRIPTS_CAPABILITY,
452
+ params: external_exports.object({ rid: MirrorRid }),
453
+ result: MirrorLookup
454
+ },
455
+ /**
456
+ * Search Mirror酱's projects by name, game or id (its project list, read
457
+ * at most once a day; MultiGameAssistant's own list when it cannot be read).
458
+ * Only tools with a Windows build Mirror酱 hands out.
459
+ */
460
+ "scripts/mirrorchyan/search": {
461
+ capability: SCRIPTS_CAPABILITY,
462
+ params: external_exports.object({ query: external_exports.string().trim().max(100) }),
463
+ result: external_exports.object({
464
+ items: external_exports.array(MirrorSearchItem),
465
+ /** `mirrorchyan`: its list, fresh or from today's cache; `builtin`: it could not be read. */
466
+ from: external_exports.enum(["mirrorchyan", "builtin"]),
467
+ fetchedAt: external_exports.number().optional()
468
+ })
469
+ },
470
+ /**
471
+ * The script updated past its pack's version (ScriptInfo.packReview): `check`
472
+ * starts the agent on it (changelog first; a changed pack comes back as a
473
+ * draft), `keep` leaves the pack as it is.
474
+ */
475
+ "scripts/packReview": {
476
+ capability: SCRIPTS_CAPABILITY,
477
+ params: external_exports.object({ id: external_exports.string(), decision: external_exports.enum(["check", "keep"]) }),
478
+ result: external_exports.object({ sessionId: external_exports.string().optional() })
479
+ },
480
+ /** Undo a local import's last in-place update: the old files back, the new ones removed. */
481
+ "scripts/restore": {
482
+ capability: SCRIPTS_CAPABILITY,
483
+ params: ById,
484
+ result: ScriptInfo
485
+ },
486
+ /** Make another installed version current; default: the one before the current. */
487
+ "scripts/rollback": {
488
+ capability: SCRIPTS_CAPABILITY,
489
+ params: external_exports.object({ id: ScriptId, version: external_exports.string().optional() }),
490
+ result: ScriptInfo
491
+ },
492
+ /** Register an existing directory in place. */
493
+ /** Open a waiting setup program's own window (its folder prefilled), for the user to install it; then `scripts/import` its folder. */
494
+ "scripts/setup/open": {
495
+ capability: SCRIPTS_CAPABILITY,
496
+ params: ById,
497
+ result: external_exports.object({ dir: external_exports.string() })
498
+ },
499
+ /** Hand a waiting setup program to the agent (again). */
500
+ "scripts/setup/agent": {
501
+ capability: SCRIPTS_CAPABILITY,
502
+ params: ById,
503
+ result: external_exports.object({ sessionId: external_exports.string() })
504
+ },
505
+ /** Give up a waiting setup program: it is deleted, nothing is installed. */
506
+ "scripts/setup/discard": {
507
+ capability: SCRIPTS_CAPABILITY,
508
+ params: ById,
509
+ result: Empty
510
+ },
511
+ "scripts/import": {
512
+ capability: SCRIPTS_CAPABILITY,
513
+ params: external_exports.object({
514
+ path: external_exports.string().trim().min(1).max(1e3),
515
+ id: ScriptId.optional(),
516
+ name: external_exports.string().trim().min(1).max(100).optional(),
517
+ /** Pack to describe it with; omitted matches by directory contents. */
518
+ packId: ScriptId.optional()
519
+ }),
520
+ result: ScriptInfo
521
+ },
522
+ /**
523
+ * Remove from the library. Installed versions are deleted only with
524
+ * `deleteFiles`; an imported directory is never deleted.
525
+ */
526
+ /**
527
+ * 优化脚本 (ScriptInfo.optimize): `run` starts the 脚本 agent on it (pack summed
528
+ * up again, stall time, skills of its own); `keep` turns this offer down.
529
+ */
530
+ "scripts/optimize": {
531
+ capability: SCRIPTS_CAPABILITY,
532
+ params: external_exports.object({ id: ScriptId, decision: external_exports.enum(["run", "keep"]) }),
533
+ result: external_exports.object({ sessionId: external_exports.string().optional() })
534
+ },
535
+ /** Have the agent sum up what the script is (its README, files, pack); the summary lands in `summary`. */
536
+ "scripts/summarize": {
537
+ capability: SCRIPTS_CAPABILITY,
538
+ params: external_exports.object({ id: ScriptId }),
539
+ result: external_exports.object({ sessionId: external_exports.string() })
540
+ },
541
+ "scripts/remove": {
542
+ capability: SCRIPTS_CAPABILITY,
543
+ params: external_exports.object({ id: ScriptId, deleteFiles: external_exports.boolean().optional() }),
544
+ result: Empty
545
+ },
546
+ /** Check the script's runtime requirements on this machine. */
547
+ "scripts/envCheck": {
548
+ capability: SCRIPTS_CAPABILITY,
549
+ params: ById,
550
+ result: EnvReport
551
+ },
552
+ /** Fix one requirement; an `installer` fix shows the system UAC prompt. */
553
+ "scripts/envFix": {
554
+ capability: SCRIPTS_CAPABILITY,
555
+ params: external_exports.object({ id: ScriptId, kind: external_exports.string().min(1).max(64) }),
556
+ result: external_exports.object({ jobId: external_exports.string() })
557
+ },
558
+ "scripts/jobs": {
559
+ capability: SCRIPTS_CAPABILITY,
560
+ params: Empty,
561
+ result: external_exports.object({ items: external_exports.array(ScriptJob) })
562
+ },
563
+ "scripts/jobs/cancel": {
564
+ capability: SCRIPTS_CAPABILITY,
565
+ params: external_exports.object({ jobId: external_exports.string() }),
566
+ result: Empty
567
+ },
568
+ "scripts/settings": {
569
+ capability: SCRIPTS_CAPABILITY,
570
+ params: Empty,
571
+ result: InstallSettings.extend({ tokenConfigured: external_exports.boolean(), cdkConfigured: external_exports.boolean() })
572
+ },
573
+ /** Try the Mirror酱 CDK: whether it works, and until when. */
574
+ "scripts/mirrorchyan/check": {
575
+ capability: SCRIPTS_CAPABILITY,
576
+ params: Empty,
577
+ result: external_exports.object({ ok: external_exports.boolean(), message: external_exports.string(), expiresAt: external_exports.number().optional() })
578
+ },
579
+ "scripts/settings/set": {
580
+ capability: SCRIPTS_CAPABILITY,
581
+ params: InstallSettings.partial(),
582
+ result: InstallSettings
583
+ }
584
+ };
585
+ var ScriptNotifications = {
586
+ /** The library or a script changed; re-read `scripts/list` (or `scripts/get` for `id`). */
587
+ "scripts/changed": external_exports.object({ id: external_exports.string().optional() }),
588
+ /** A job's progress or outcome. */
589
+ "scripts/job": ScriptJob
590
+ };
591
+
592
+ // packages/protocol/lib/packs.js
593
+ var PACKS_CAPABILITY = "packs";
594
+ var PackDraft = external_exports.object({
595
+ packId: external_exports.string(),
596
+ /** Library script it was written for. */
597
+ scriptId: external_exports.string(),
598
+ proposedAt: external_exports.number(),
599
+ sessionId: external_exports.string().optional(),
600
+ /** What the agent says it changed or found. */
601
+ summary: external_exports.string(),
602
+ /** The project's documents it was written from (paths in the script's folder, or URLs), and what each told. */
603
+ docs: external_exports.array(external_exports.object({ source: external_exports.string(), used: external_exports.string() })).optional(),
604
+ /** Why it was written from the code alone: no documentation was found. */
605
+ noDocs: external_exports.string().optional(),
606
+ manifest: external_exports.string(),
607
+ skill: external_exports.string(),
608
+ /** The pack in use now, for comparison. */
609
+ current: external_exports.object({ manifest: external_exports.string(), skill: external_exports.string().optional(), builtin: external_exports.boolean() }).optional(),
610
+ /** Tasks the draft declares. */
611
+ tasks: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
612
+ });
613
+ var PackVersion = external_exports.object({
614
+ /** What `packs/restore` takes; `builtin` for the built-in pack. */
615
+ id: external_exports.string(),
616
+ /** When it was replaced (absent for the built-in pack). */
617
+ at: external_exports.number().optional(),
618
+ builtin: external_exports.boolean().optional(),
619
+ /** Tasks it declares. */
620
+ tasks: external_exports.array(external_exports.object({ id: external_exports.string(), title: external_exports.string() }))
621
+ });
622
+ var BUILTIN_PACK_VERSION = "builtin";
623
+ var PackRequests = {
624
+ /** What a pack can go back to, the last replaced first, the built-in pack (if a user pack is used instead of it) last. */
625
+ "packs/history": {
626
+ capability: PACKS_CAPABILITY,
627
+ params: external_exports.object({ packId: ScriptId }),
628
+ result: external_exports.object({ items: external_exports.array(PackVersion) })
629
+ },
630
+ /** Put that version back in use. The pack in use now goes into the history, so this can be undone. */
631
+ "packs/restore": {
632
+ capability: PACKS_CAPABILITY,
633
+ params: external_exports.object({ packId: ScriptId, version: external_exports.string().min(1).max(64) }),
634
+ result: external_exports.object({})
635
+ },
636
+ "packs/drafts": {
637
+ capability: PACKS_CAPABILITY,
638
+ params: external_exports.object({ scriptId: ScriptId.optional() }),
639
+ result: external_exports.object({ items: external_exports.array(PackDraft) })
640
+ },
641
+ /** Install the draft as the user's pack for this id (replacing a built-in one by id) and attach it to the script. */
642
+ "packs/accept": {
643
+ capability: PACKS_CAPABILITY,
644
+ params: external_exports.object({ packId: ScriptId }),
645
+ result: external_exports.object({ packId: external_exports.string(), dir: external_exports.string() })
646
+ },
647
+ "packs/reject": {
648
+ capability: PACKS_CAPABILITY,
649
+ params: external_exports.object({ packId: ScriptId }),
650
+ result: external_exports.object({})
651
+ }
652
+ };
653
+ var PackNotifications = {
654
+ "packs/changed": external_exports.object({ packId: external_exports.string().optional() })
655
+ };
656
+
657
+ // packages/protocol/lib/guard.js
658
+ var GUARD_CAPABILITY = "guard";
659
+ var GuardGrant = external_exports.object({
660
+ scriptId: external_exports.string(),
661
+ /** Directory the grant opens. */
662
+ dir: external_exports.string(),
663
+ grantedAt: external_exports.number(),
664
+ expiresAt: external_exports.number()
665
+ });
666
+ var GuardRequests = {
667
+ "guard/grants": {
668
+ capability: GUARD_CAPABILITY,
669
+ params: external_exports.object({}),
670
+ result: external_exports.object({ items: external_exports.array(GuardGrant), blocked: external_exports.number() })
671
+ },
672
+ /** Let the agent change this script's files for `minutes`. */
673
+ "guard/grant": {
674
+ capability: GUARD_CAPABILITY,
675
+ params: external_exports.object({ scriptId: ScriptId, minutes: external_exports.number().int().min(1).max(240) }),
676
+ result: GuardGrant
677
+ },
678
+ "guard/revoke": {
679
+ capability: GUARD_CAPABILITY,
680
+ params: external_exports.object({ scriptId: ScriptId }),
681
+ result: external_exports.object({})
682
+ }
683
+ };
684
+ var GuardNotifications = {
685
+ "guard/changed": external_exports.object({}),
686
+ /** The guard refused an agent tool call. */
687
+ "guard/blocked": external_exports.object({ toolName: external_exports.string(), target: external_exports.string(), sessionId: external_exports.string().optional(), at: external_exports.number() })
688
+ };
689
+
690
+ // packages/protocol/lib/monitor.js
691
+ var MONITOR_CAPABILITY = "monitor";
692
+ var IncidentKind = external_exports.enum([
693
+ /** An `error` log rule matched. */
694
+ "error",
695
+ /** A `warning` log rule matched (recorded; pushed only when the settings say so). */
696
+ "warning",
697
+ /** The run ended failed without an earlier error incident. */
698
+ "failed",
699
+ /** No new script log line for longer than the stall threshold. */
700
+ "stalled",
701
+ /** Running for more than twice the task's expected duration. */
702
+ "overtime"
703
+ ]);
704
+ var IncidentStep = external_exports.object({
705
+ at: external_exports.number(),
706
+ action: external_exports.enum(["reconnect-adb", "restart", "stop", "screenshot", "notify", "resolve", "intervene"]),
707
+ /** `rule`: L0 recovery from the pack; `user`: the UI or a chat channel. */
708
+ by: external_exports.enum(["rule", "user", "agent"]),
709
+ ok: external_exports.boolean(),
710
+ detail: external_exports.string()
711
+ });
712
+ var Incident = external_exports.object({
713
+ id: external_exports.string(),
714
+ runId: external_exports.string(),
715
+ scriptId: external_exports.string(),
716
+ scriptName: external_exports.string(),
717
+ taskId: external_exports.string(),
718
+ taskTitle: external_exports.string(),
719
+ kind: IncidentKind,
720
+ severity: external_exports.enum(["warning", "error"]),
721
+ /** Log rule tag, or the kind. */
722
+ tag: external_exports.string(),
723
+ /** One line for people, e.g. "MAA · 日常:重连失败,连接断开!". */
724
+ title: external_exports.string(),
725
+ /** The matching log line or the run's outcome. */
726
+ detail: external_exports.string(),
727
+ /** The run's last log lines when the incident was raised. */
728
+ lines: external_exports.array(external_exports.string()),
729
+ status: external_exports.enum(["open", "resolved"]),
730
+ resolution: external_exports.string().optional(),
731
+ createdAt: external_exports.number(),
732
+ updatedAt: external_exports.number(),
733
+ steps: external_exports.array(IncidentStep),
734
+ /** A screenshot was taken (`monitor/screenshot`). */
735
+ screenshot: external_exports.boolean()
736
+ });
737
+ var ScriptStall = external_exports.object({
738
+ seconds: external_exports.number().int().min(5).max(24 * 3600),
739
+ by: external_exports.enum(["learned", "agent", "user"]),
740
+ /** Why (the agent's words), for people. */
741
+ note: external_exports.string().max(300).optional(),
742
+ /** The longest quiet stretch (seconds) of each of the last runs that went through cleanly, newest last. */
743
+ samples: external_exports.array(external_exports.number().min(0)).max(10).default([]),
744
+ at: external_exports.number()
745
+ });
746
+ var MonitorSettings = external_exports.object({
747
+ /**
748
+ * Seconds without a new script log line before a run counts as stalled and goes to the agent, for a script
749
+ * with nothing of its own in `scriptStall` (nor `logs.stallAfter` in its pack); 0 turns it off. Applies only
750
+ * once the run has written at least one log line.
751
+ */
752
+ defaultStallSeconds: external_exports.number().int().min(0).max(24 * 3600),
753
+ /** Script id → its own stall time (learned from its normal runs, or set by the agent or the user). */
754
+ scriptStall: external_exports.record(external_exports.string(), ScriptStall),
755
+ /** Also push `warning` incidents to chat channels. */
756
+ notifyWarnings: external_exports.boolean(),
757
+ /** Take a screenshot (emulator or desktop) when an incident is raised. */
758
+ screenshot: external_exports.boolean(),
759
+ /**
760
+ * What L0 does not settle goes to the agent first: `off`, `diagnose` (it
761
+ * looks and explains, then you decide), or `act` (it may also click and type
762
+ * to fix it, with the script paused). Needs an image-capable model.
763
+ */
764
+ intervene: external_exports.enum(["off", "diagnose", "act"]),
765
+ /** At most this many agent interventions a day (model cost). */
766
+ interventionsPerDay: external_exports.number().int().min(0).max(200)
767
+ });
768
+ var MonitorRequests = {
769
+ "monitor/incidents": {
770
+ capability: MONITOR_CAPABILITY,
771
+ params: external_exports.object({ status: external_exports.enum(["open", "all"]).optional(), runId: external_exports.string().optional(), limit: external_exports.number().int().min(1).max(500).optional() }),
772
+ result: external_exports.object({ items: external_exports.array(Incident) })
773
+ },
774
+ /** Stop the incident's run, run its task again, mark the incident handled, or let the paused script carry on. */
775
+ "monitor/act": {
776
+ capability: MONITOR_CAPABILITY,
777
+ params: external_exports.object({ incidentId: external_exports.string(), action: external_exports.enum(["stop", "retry", "resolve", "resume"]) }),
778
+ result: Incident
779
+ },
780
+ "monitor/screenshot": {
781
+ capability: MONITOR_CAPABILITY,
782
+ params: external_exports.object({ incidentId: external_exports.string() }),
783
+ result: external_exports.object({ mime: external_exports.literal("image/png"), data: external_exports.string() })
784
+ },
785
+ "monitor/settings": {
786
+ capability: MONITOR_CAPABILITY,
787
+ params: external_exports.object({}),
788
+ result: MonitorSettings
789
+ },
790
+ "monitor/settings/set": {
791
+ capability: MONITOR_CAPABILITY,
792
+ params: MonitorSettings.partial(),
793
+ result: MonitorSettings
794
+ }
795
+ };
796
+ var MonitorNotifications = {
797
+ /** An incident was raised or changed. */
798
+ "monitor/incident": Incident
799
+ };
800
+
801
+ // packages/protocol/lib/notify.js
802
+ var NOTIFY_CAPABILITY = "notify";
803
+ var FEISHU_CAPABILITY = "feishu";
804
+ var QQBOT_CAPABILITY = "qqbot";
805
+ var FEISHU_SECRET_REF = "ADG_FEISHU_APP_SECRET";
806
+ var QQBOT_SECRET_REF = "ADG_QQBOT_APP_SECRET";
807
+ var ChannelCheck = external_exports.object({
808
+ id: external_exports.string(),
809
+ label: external_exports.string(),
810
+ /** `null`: not checked yet. */
811
+ ok: external_exports.boolean().nullable(),
812
+ detail: external_exports.string().optional()
813
+ });
814
+ var ChannelStatus = external_exports.object({
815
+ id: external_exports.string(),
816
+ name: external_exports.string(),
817
+ state: external_exports.enum(["off", "connecting", "ready", "error"]),
818
+ detail: external_exports.string().optional(),
819
+ /** People notices go to. */
820
+ recipients: external_exports.number().int().min(0),
821
+ checks: external_exports.array(ChannelCheck)
822
+ });
823
+ var FeishuUser = external_exports.object({
824
+ openId: external_exports.string().min(1),
825
+ name: external_exports.string().optional(),
826
+ addedAt: external_exports.number()
827
+ });
828
+ var FeishuSettings = external_exports.object({
829
+ enabled: external_exports.boolean(),
830
+ appId: external_exports.string().optional(),
831
+ /** `feishu` (open.feishu.cn) or `lark` (open.larksuite.com). */
832
+ domain: external_exports.enum(["feishu", "lark"]),
833
+ /** Only these people may talk to the agent; notices go to them. */
834
+ allowedUsers: external_exports.array(FeishuUser),
835
+ /** Also post notices to this group chat (`oc_…`). */
836
+ chatId: external_exports.string().optional(),
837
+ /**
838
+ * Also send approvals from sessions not started in Feishu (the UI, schedules,
839
+ * game reading) as cards to everyone above. A Feishu conversation's own
840
+ * approvals always go to its person only, whatever this says.
841
+ */
842
+ otherApprovals: external_exports.boolean()
843
+ });
844
+ var FeishuPending = external_exports.object({ openId: external_exports.string(), at: external_exports.number(), text: external_exports.string() });
845
+ var FeishuView = external_exports.object({ settings: FeishuSettings, secretConfigured: external_exports.boolean(), pending: external_exports.array(FeishuPending) });
846
+ var QQUser = external_exports.object({
847
+ openId: external_exports.string().min(1),
848
+ name: external_exports.string().optional(),
849
+ addedAt: external_exports.number()
850
+ });
851
+ var QQSettings = external_exports.object({
852
+ enabled: external_exports.boolean(),
853
+ /** 机器人 AppID, from the QQ open platform. */
854
+ appId: external_exports.string().optional(),
855
+ /** Only these people may talk to the agent; notices and 助手's conversation go to them. */
856
+ allowedUsers: external_exports.array(QQUser)
857
+ });
858
+ var QQPending = external_exports.object({ openId: external_exports.string(), at: external_exports.number(), text: external_exports.string() });
859
+ var QQView = external_exports.object({ settings: QQSettings, secretConfigured: external_exports.boolean(), pending: external_exports.array(QQPending) });
860
+ var ChatNotice = external_exports.object({
861
+ id: external_exports.string(),
862
+ title: external_exports.string(),
863
+ text: external_exports.string(),
864
+ severity: external_exports.enum(["info", "success", "warning", "error"]),
865
+ at: external_exports.number(),
866
+ actions: external_exports.array(external_exports.object({ id: external_exports.string(), label: external_exports.string(), style: external_exports.enum(["primary", "danger", "default"]).optional() })),
867
+ /** The chat apps it reached (飞书, QQ); empty: shown in the app only. */
868
+ channels: external_exports.array(external_exports.string()),
869
+ /** It came with a picture (a screenshot), sent to the chat apps only. */
870
+ image: external_exports.boolean().optional(),
871
+ /** Its buttons no longer apply (dealt with, or over): what came of it. */
872
+ done: external_exports.string().optional(),
873
+ /** Someone picked one of its actions: who, which, what came of it. */
874
+ acted: external_exports.object({ by: external_exports.string(), label: external_exports.string(), result: external_exports.string(), at: external_exports.number() }).optional()
875
+ });
876
+ var NotifyRequests = {
877
+ "notify/status": {
878
+ capability: NOTIFY_CAPABILITY,
879
+ params: external_exports.object({}),
880
+ result: external_exports.object({ channels: external_exports.array(ChannelStatus) })
881
+ },
882
+ /** Conversations people have with the agent through a chat channel (Feishu): which session is whose. */
883
+ "notify/conversations": {
884
+ capability: NOTIFY_CAPABILITY,
885
+ params: external_exports.object({}),
886
+ result: external_exports.object({ items: external_exports.array(external_exports.object({ sessionId: external_exports.string(), channel: external_exports.string(), user: external_exports.string() })) })
887
+ },
888
+ /** What the app told the person through the chat apps lately, oldest first (助手's conversation shows them). */
889
+ "notify/notices": {
890
+ capability: NOTIFY_CAPABILITY,
891
+ params: external_exports.object({}),
892
+ result: external_exports.object({ items: external_exports.array(ChatNotice) })
893
+ },
894
+ /** Pick one of a notice's actions in the app, as its button in a chat app would. */
895
+ "notify/act": {
896
+ capability: NOTIFY_CAPABILITY,
897
+ params: external_exports.object({ noticeId: external_exports.string(), actionId: external_exports.string() }),
898
+ result: external_exports.object({ result: external_exports.string() })
899
+ },
900
+ /** Send a test notice through one channel, or all. */
901
+ "notify/test": {
902
+ capability: NOTIFY_CAPABILITY,
903
+ params: external_exports.object({ channel: external_exports.string().optional() }),
904
+ result: external_exports.object({ sent: external_exports.array(external_exports.string()), failed: external_exports.array(external_exports.object({ channel: external_exports.string(), error: external_exports.string() })) })
905
+ },
906
+ "feishu/settings": {
907
+ capability: FEISHU_CAPABILITY,
908
+ params: external_exports.object({}),
909
+ result: FeishuView
910
+ },
911
+ "feishu/settings/set": {
912
+ capability: FEISHU_CAPABILITY,
913
+ params: external_exports.object({
914
+ enabled: external_exports.boolean().optional(),
915
+ appId: external_exports.string().trim().regex(/^cli_[0-9a-fA-F]{16}$/, "App ID \u662F cli_ \u52A0 16 \u4F4D\u5B57\u6BCD\u6570\u5B57\uFF0C\u5728\u300C\u51ED\u8BC1\u4E0E\u57FA\u7840\u4FE1\u606F\u300D\u91CC\u590D\u5236").nullable().optional(),
916
+ domain: external_exports.enum(["feishu", "lark"]).optional(),
917
+ chatId: external_exports.string().trim().regex(/^oc_[A-Za-z0-9]+$/, "\u7FA4 ID \u4EE5 oc_ \u5F00\u5934").nullable().optional(),
918
+ otherApprovals: external_exports.boolean().optional()
919
+ }),
920
+ result: FeishuView
921
+ },
922
+ "feishu/users/allow": {
923
+ capability: FEISHU_CAPABILITY,
924
+ params: external_exports.object({ openId: external_exports.string().trim().regex(/^ou_[A-Za-z0-9]+$/, "open_id \u4EE5 ou_ \u5F00\u5934"), name: external_exports.string().max(40).optional() }),
925
+ result: FeishuView
926
+ },
927
+ /** Take someone off the allowed list, or dismiss a pending one. */
928
+ "feishu/users/remove": {
929
+ capability: FEISHU_CAPABILITY,
930
+ params: external_exports.object({ openId: external_exports.string() }),
931
+ result: FeishuView
932
+ },
933
+ /** Run the self-check again (credentials, bot, long connection). */
934
+ "feishu/check": {
935
+ capability: FEISHU_CAPABILITY,
936
+ params: external_exports.object({}),
937
+ result: external_exports.object({ checks: external_exports.array(ChannelCheck) })
938
+ },
939
+ "qqbot/settings": {
940
+ capability: QQBOT_CAPABILITY,
941
+ params: external_exports.object({}),
942
+ result: QQView
943
+ },
944
+ "qqbot/settings/set": {
945
+ capability: QQBOT_CAPABILITY,
946
+ params: external_exports.object({
947
+ enabled: external_exports.boolean().optional(),
948
+ appId: external_exports.string().trim().regex(/^\d{6,20}$/, "AppID \u662F\u4E00\u4E32\u6570\u5B57\uFF0C\u5728 QQ \u5F00\u653E\u5E73\u53F0\u300C\u5F00\u53D1\u8BBE\u7F6E\u300D\u91CC\u590D\u5236").nullable().optional()
949
+ }),
950
+ result: QQView
951
+ },
952
+ "qqbot/users/allow": {
953
+ capability: QQBOT_CAPABILITY,
954
+ params: external_exports.object({ openId: external_exports.string().trim().regex(/^[0-9A-Za-z_-]{8,64}$/, "user_openid \u662F\u4E00\u4E32\u5B57\u6BCD\u6570\u5B57\uFF08\u673A\u5668\u4EBA\u56DE\u590D\u4F60\u7684\u90A3\u6761\u6D88\u606F\u91CC\u6709\uFF09"), name: external_exports.string().max(40).optional() }),
955
+ result: QQView
956
+ },
957
+ /** Take someone off the allowed list, or dismiss a pending one. */
958
+ "qqbot/users/remove": {
959
+ capability: QQBOT_CAPABILITY,
960
+ params: external_exports.object({ openId: external_exports.string() }),
961
+ result: QQView
962
+ },
963
+ /** Run the self-check again (AppID / AppSecret, the WebSocket gateway). */
964
+ "qqbot/check": {
965
+ capability: QQBOT_CAPABILITY,
966
+ params: external_exports.object({}),
967
+ result: external_exports.object({ checks: external_exports.array(ChannelCheck) })
968
+ }
969
+ };
970
+ var NotifyNotifications = {
971
+ /** A channel's state or its settings changed. */
972
+ "notify/changed": external_exports.object({}),
973
+ /** A notice was sent, or what came of it changed. */
974
+ "notify/notice": external_exports.object({ item: ChatNotice })
975
+ };
976
+
977
+ // packages/protocol/lib/pipelines.js
978
+ var PIPELINES_CAPABILITY = "pipelines";
979
+ var SCHEDULE_CAPABILITY = "schedule";
980
+ var PipelineId = external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u77ED\u6A2A\u7EBF").max(64);
981
+ var NodeId = external_exports.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
982
+ var ClockTime = external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "\u65F6\u95F4\u5199\u6210 HH:MM\uFF0C\u4F8B\u5982 04:30");
983
+ var FailurePolicy = external_exports.object({
984
+ retries: external_exports.number().int().min(0).max(5).default(0),
985
+ then: external_exports.enum(["continue", "stop"]).default("continue")
986
+ });
987
+ var NodeBase = {
988
+ id: NodeId,
989
+ title: external_exports.string().max(60).optional(),
990
+ /** Canvas position. */
991
+ position: external_exports.object({ x: external_exports.number(), y: external_exports.number() }).optional(),
992
+ onFailure: FailurePolicy.optional(),
993
+ /**
994
+ * Start only once every node not after this one has finished (succeeded,
995
+ * failed or skipped), not just the ones whose edges lead here — a barrier
996
+ * for parallel branches. Its own edges still decide whether it runs.
997
+ */
998
+ waitForAll: external_exports.boolean().optional()
999
+ };
1000
+ var PipelineNode = external_exports.discriminatedUnion("kind", [
1001
+ /** A script's task with parameters (from its pack), run with one of the script's config profiles (default: its current one). */
1002
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("script-task"), scriptId: ScriptId, taskId: external_exports.string().min(1).max(64), params: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])).default({}), profile: external_exports.string().min(1).max(64).optional() }),
1003
+ /** A step in plain words for the agent, e.g. "检查活动还剩几天,快结束的发飞书提醒我". */
1004
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("agent"), prompt: external_exports.string().min(1).max(4e3) }),
1005
+ /** Wait some minutes, or until a time of day. */
1006
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("wait"), minutes: external_exports.number().int().min(1).max(1440).optional(), until: ClockTime.optional() }).refine((n) => n.minutes === void 0 !== (n.until === void 0), "\u7B49\u5F85\u8282\u70B9\u5199\u5206\u949F\u6570\u6216\u65F6\u95F4\u5176\u4E2D\u4E00\u4E2A"),
1007
+ /** Send a message to the chat channels (Feishu). */
1008
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("notify"), text: external_exports.string().min(1).max(2e3) }),
1009
+ /** Ask the user to continue or stop (UI or a Feishu card). */
1010
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("gate"), text: external_exports.string().min(1).max(2e3) }),
1011
+ /** Where the pipeline begins: done at once. */
1012
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("start") }),
1013
+ /** Where it ends: reached once every other node has finished, whatever the edges into it say. */
1014
+ external_exports.object({ ...NodeBase, kind: external_exports.literal("end") })
1015
+ ]);
1016
+ function isMarker(node) {
1017
+ return node.kind === "start" || node.kind === "end";
1018
+ }
1019
+ function withStartEnd(pipeline) {
1020
+ const hasStart = pipeline.nodes.some((n) => n.kind === "start");
1021
+ const hasEnd = pipeline.nodes.some((n) => n.kind === "end");
1022
+ if (hasStart && hasEnd)
1023
+ return pipeline;
1024
+ const steps = pipeline.nodes.filter((n) => !isMarker(n));
1025
+ const ids = new Set(pipeline.nodes.map((n) => n.id));
1026
+ const fresh = (base2) => {
1027
+ let id = base2;
1028
+ for (let i = 2; ids.has(id); i++)
1029
+ id = `${base2}${i}`;
1030
+ ids.add(id);
1031
+ return id;
1032
+ };
1033
+ const placed = steps.filter((n) => n.position !== void 0).map((n) => n.position);
1034
+ const minX = Math.min(...placed.map((p) => p.x));
1035
+ const maxX = Math.max(...placed.map((p) => p.x));
1036
+ const midY = placed.length === 0 ? 40 : Math.round(placed.reduce((sum, p) => sum + p.y, 0) / placed.length);
1037
+ const nodes = [...pipeline.nodes];
1038
+ const edges = [...pipeline.edges];
1039
+ if (!hasStart) {
1040
+ const id = fresh("start");
1041
+ nodes.unshift({ id, kind: "start", ...placed.length === 0 ? {} : { position: { x: minX - 240, y: midY } } });
1042
+ for (const step of steps)
1043
+ if (!pipeline.edges.some((e) => e.to === step.id))
1044
+ edges.push({ from: id, to: step.id, when: "success" });
1045
+ }
1046
+ if (!hasEnd) {
1047
+ const id = fresh("end");
1048
+ nodes.push({ id, kind: "end", ...placed.length === 0 ? {} : { position: { x: maxX + 300, y: midY } } });
1049
+ for (const step of steps)
1050
+ if (!pipeline.edges.some((e) => e.from === step.id))
1051
+ edges.push({ from: step.id, to: id, when: "always" });
1052
+ }
1053
+ return { ...pipeline, nodes, edges };
1054
+ }
1055
+ var PipelineEdge = external_exports.object({
1056
+ from: NodeId,
1057
+ to: NodeId,
1058
+ /** Run `to` when `from` succeeded (default), failed, or either. */
1059
+ when: external_exports.enum(["success", "failure", "always"]).default("success")
1060
+ });
1061
+ var PipelineSchedule = external_exports.object({
1062
+ enabled: external_exports.boolean().default(false),
1063
+ times: external_exports.array(ClockTime).max(12).default([]),
1064
+ /** 0 = Sunday … 6 = Saturday; empty = every day. */
1065
+ days: external_exports.array(external_exports.number().int().min(0).max(6)).max(7).default([]),
1066
+ /** A time missed by at most this many minutes (sleep, the computer was off) still runs. */
1067
+ catchUpMinutes: external_exports.number().int().min(0).max(720).default(10),
1068
+ /** Also run when this other pipeline finishes successfully. */
1069
+ after: PipelineId.optional()
1070
+ });
1071
+ var PowerAction = external_exports.enum(["none", "sleep", "hibernate", "shutdown"]);
1072
+ var Pipeline = external_exports.object({
1073
+ id: PipelineId,
1074
+ name: external_exports.string().min(1).max(60),
1075
+ description: external_exports.string().max(500).optional(),
1076
+ nodes: external_exports.array(PipelineNode).max(60),
1077
+ edges: external_exports.array(PipelineEdge).max(200).default([]),
1078
+ /** Node default when a node sets none. */
1079
+ onFailure: FailurePolicy.default({ retries: 0, then: "continue" }),
1080
+ schedule: PipelineSchedule.default({ enabled: false, times: [], days: [], catchUpMinutes: 10 }),
1081
+ /** Shut the emulator down when the pipeline ends (if it used one). */
1082
+ stopEmulatorAfter: external_exports.boolean().default(false),
1083
+ /** Close the games its script tasks played when the pipeline ends (PC programs, apps in the emulator). */
1084
+ closeGameAfter: external_exports.boolean().default(false),
1085
+ /** Then sleep, hibernate or shut down (see PowerAction). */
1086
+ powerAfter: PowerAction.default("none"),
1087
+ /** Written by the agent and not yet saved by the user: never runs on a schedule. */
1088
+ draft: external_exports.boolean().optional(),
1089
+ createdAt: external_exports.number().optional(),
1090
+ updatedAt: external_exports.number().optional()
1091
+ });
1092
+ var PipelineIssue = external_exports.object({
1093
+ level: external_exports.enum(["error", "warning", "info"]),
1094
+ /** The node it is about, if any. */
1095
+ nodeId: external_exports.string().optional(),
1096
+ message: external_exports.string()
1097
+ });
1098
+ var PipelineCheck = external_exports.object({
1099
+ ok: external_exports.boolean(),
1100
+ issues: external_exports.array(PipelineIssue),
1101
+ /** Branches drawn in parallel that will take turns, and why. */
1102
+ serialized: external_exports.array(external_exports.object({ a: external_exports.string(), b: external_exports.string(), resource: external_exports.string() })),
1103
+ /** Rough duration from the tasks' expected durations, when they say. */
1104
+ estimateMinutes: external_exports.number().optional()
1105
+ });
1106
+ var NodeRunState = external_exports.enum(["pending", "waiting", "running", "succeeded", "failed", "skipped", "cancelled"]);
1107
+ var NodeRun = external_exports.object({
1108
+ state: NodeRunState,
1109
+ /** For people: what it waits for, how it ended. */
1110
+ detail: external_exports.string().optional(),
1111
+ /** Script runs started for this node (retries add more). */
1112
+ runIds: external_exports.array(external_exports.string()),
1113
+ attempts: external_exports.number().int().min(0),
1114
+ startedAt: external_exports.number().optional(),
1115
+ endedAt: external_exports.number().optional()
1116
+ });
1117
+ var PipelineTrigger = external_exports.object({
1118
+ kind: external_exports.enum(["manual", "schedule", "autostart", "agent", "after"]),
1119
+ detail: external_exports.string().optional()
1120
+ });
1121
+ var PipelineRun = external_exports.object({
1122
+ id: external_exports.string(),
1123
+ pipelineId: external_exports.string(),
1124
+ pipelineName: external_exports.string(),
1125
+ trigger: PipelineTrigger,
1126
+ /** Started from this node: it and what follows ran, the rest was passed over. */
1127
+ from: external_exports.string().optional(),
1128
+ state: external_exports.enum(["running", "succeeded", "failed", "cancelled"]),
1129
+ /** Being called off, while it closes what it started: what is being closed now, for people (正在结束「MAA · 日常」…). */
1130
+ stopping: external_exports.string().optional(),
1131
+ nodes: external_exports.record(external_exports.string(), NodeRun),
1132
+ startedAt: external_exports.number(),
1133
+ endedAt: external_exports.number().optional(),
1134
+ outcome: external_exports.string().optional()
1135
+ });
1136
+ var PipelineSummary = external_exports.object({
1137
+ id: external_exports.string(),
1138
+ name: external_exports.string(),
1139
+ description: external_exports.string().optional(),
1140
+ nodes: external_exports.number(),
1141
+ draft: external_exports.boolean(),
1142
+ schedule: PipelineSchedule,
1143
+ updatedAt: external_exports.number().optional(),
1144
+ lastRun: PipelineRun.pick({ id: true, state: true, startedAt: true, endedAt: true }).optional()
1145
+ });
1146
+ var AgentTaskId = external_exports.string().regex(/^task-[a-z0-9]{4,24}$/);
1147
+ var AgentTask = external_exports.object({
1148
+ id: AgentTaskId,
1149
+ /** The agent that does it: `main` (助手), a role agent, or one the person made. */
1150
+ agent: external_exports.string().min(1).max(64),
1151
+ title: external_exports.string().trim().min(1).max(60),
1152
+ prompt: external_exports.string().trim().min(1).max(4e3),
1153
+ schedule: PipelineSchedule,
1154
+ createdAt: external_exports.number().optional(),
1155
+ updatedAt: external_exports.number().optional()
1156
+ });
1157
+ var AgentTaskRun = external_exports.object({
1158
+ id: external_exports.string(),
1159
+ taskId: external_exports.string(),
1160
+ trigger: PipelineTrigger,
1161
+ state: external_exports.enum(["running", "done", "failed"]),
1162
+ /** The start of the agent's reply, or why it did not finish. */
1163
+ outcome: external_exports.string().optional(),
1164
+ startedAt: external_exports.number(),
1165
+ endedAt: external_exports.number().optional()
1166
+ });
1167
+ var ScheduleSettings = external_exports.object({
1168
+ /** Start MultiGameAssistant when the user logs on to Windows (a Task Scheduler task). */
1169
+ autostart: external_exports.boolean(),
1170
+ /** Pipelines run when the app starts (by hand or at logon). */
1171
+ autostartPipelines: external_exports.array(PipelineId),
1172
+ /** Seconds to wait after a start at logon (network, desktop, drivers); a start by hand waits 10 s. */
1173
+ autostartDelaySeconds: external_exports.number().int().min(0).max(1800),
1174
+ /** Skip an on-start pipeline that already ran today (a day starts at 4:00). */
1175
+ skipIfRanToday: external_exports.boolean(),
1176
+ /** Run the on-start pipelines only on the app's first start of the day (a day starts at 4:00, as in the games). */
1177
+ firstStartOnly: external_exports.boolean().default(false),
1178
+ /** Wake the computer from sleep (or hibernation) just before scheduled times (a Task Scheduler task). */
1179
+ wakeToRun: external_exports.boolean().default(false),
1180
+ /** Seconds between announcing a sleep / hibernate / shutdown and doing it. */
1181
+ powerCountdownSeconds: external_exports.number().int().min(10).max(600).default(60)
1182
+ });
1183
+ var OnAgent = { agent: external_exports.string().optional() };
1184
+ var ScheduleEntry = external_exports.object({
1185
+ /** A pipeline's id, or `task:<id>` for a timed task. */
1186
+ pipelineId: external_exports.string(),
1187
+ pipelineName: external_exports.string(),
1188
+ ...OnAgent,
1189
+ /** The planned local slot, `YYYY-MM-DD HH:MM`. */
1190
+ slot: external_exports.string(),
1191
+ at: external_exports.number(),
1192
+ outcome: external_exports.enum(["fired", "missed", "skipped", "failed"]),
1193
+ detail: external_exports.string().optional()
1194
+ });
1195
+ var PowerStatus = external_exports.object({
1196
+ /** Sleep is held off while pipelines or scripts run. */
1197
+ awake: external_exports.boolean(),
1198
+ /** A sleep / hibernate / shutdown on its way: `at` once counting down, absent while other tasks still run. */
1199
+ pending: external_exports.object({ action: PowerAction.exclude(["none"]), pipelineName: external_exports.string(), at: external_exports.number().optional() }).optional()
1200
+ });
1201
+ var ScheduleStatus = external_exports.object({
1202
+ settings: ScheduleSettings,
1203
+ autostart: external_exports.object({
1204
+ /** Only the desktop app can start itself at logon. */
1205
+ available: external_exports.boolean(),
1206
+ registered: external_exports.boolean(),
1207
+ detail: external_exports.string().optional()
1208
+ }),
1209
+ /** This start was an automatic one (at logon). */
1210
+ autostarted: external_exports.boolean(),
1211
+ wake: external_exports.object({
1212
+ /** Only the desktop app can register it (it is what the task starts). */
1213
+ available: external_exports.boolean(),
1214
+ registered: external_exports.boolean(),
1215
+ /** The next wake-up registered. */
1216
+ next: external_exports.number().optional(),
1217
+ detail: external_exports.string().optional()
1218
+ }),
1219
+ power: PowerStatus,
1220
+ upcoming: external_exports.array(external_exports.object({ pipelineId: external_exports.string(), pipelineName: external_exports.string(), at: external_exports.number(), ...OnAgent })),
1221
+ history: external_exports.array(ScheduleEntry)
1222
+ });
1223
+ var PipelineRequests = {
1224
+ "pipelines/list": {
1225
+ capability: PIPELINES_CAPABILITY,
1226
+ params: external_exports.object({}),
1227
+ result: external_exports.object({ items: external_exports.array(PipelineSummary) })
1228
+ },
1229
+ "pipelines/get": {
1230
+ capability: PIPELINES_CAPABILITY,
1231
+ params: external_exports.object({ id: PipelineId }),
1232
+ result: Pipeline
1233
+ },
1234
+ /** Create or replace; saving clears `draft`. */
1235
+ "pipelines/save": {
1236
+ capability: PIPELINES_CAPABILITY,
1237
+ params: external_exports.object({ pipeline: Pipeline }),
1238
+ result: external_exports.object({ pipeline: Pipeline, check: PipelineCheck })
1239
+ },
1240
+ "pipelines/remove": {
1241
+ capability: PIPELINES_CAPABILITY,
1242
+ params: external_exports.object({ id: PipelineId }),
1243
+ result: external_exports.object({})
1244
+ },
1245
+ /** Check without saving. */
1246
+ "pipelines/check": {
1247
+ capability: PIPELINES_CAPABILITY,
1248
+ params: external_exports.object({ pipeline: Pipeline }),
1249
+ result: PipelineCheck
1250
+ },
1251
+ "pipelines/run": {
1252
+ capability: PIPELINES_CAPABILITY,
1253
+ /** `from`: start at this node (it and what follows run; the rest is passed over). */
1254
+ params: external_exports.object({ id: PipelineId, from: NodeId.optional() }),
1255
+ result: PipelineRun
1256
+ },
1257
+ "pipelines/cancel": {
1258
+ capability: PIPELINES_CAPABILITY,
1259
+ params: external_exports.object({ runId: external_exports.string() }),
1260
+ result: external_exports.object({})
1261
+ },
1262
+ "pipelines/runs": {
1263
+ capability: PIPELINES_CAPABILITY,
1264
+ params: external_exports.object({ pipelineId: PipelineId.optional(), limit: external_exports.number().int().min(1).max(100).optional() }),
1265
+ result: external_exports.object({ items: external_exports.array(PipelineRun) })
1266
+ },
1267
+ /** Answer a gate node. */
1268
+ "pipelines/gate": {
1269
+ capability: PIPELINES_CAPABILITY,
1270
+ params: external_exports.object({ runId: external_exports.string(), nodeId: NodeId, decision: external_exports.enum(["continue", "stop"]) }),
1271
+ result: external_exports.object({})
1272
+ },
1273
+ "schedule/status": {
1274
+ capability: SCHEDULE_CAPABILITY,
1275
+ params: external_exports.object({}),
1276
+ result: ScheduleStatus
1277
+ },
1278
+ "schedule/settings/set": {
1279
+ capability: SCHEDULE_CAPABILITY,
1280
+ params: ScheduleSettings.partial(),
1281
+ result: ScheduleStatus
1282
+ },
1283
+ "schedule/power": {
1284
+ capability: SCHEDULE_CAPABILITY,
1285
+ params: external_exports.object({}),
1286
+ result: PowerStatus
1287
+ },
1288
+ /** Call off the sleep / hibernate / shutdown on its way. */
1289
+ "schedule/power/cancel": {
1290
+ capability: SCHEDULE_CAPABILITY,
1291
+ params: external_exports.object({}),
1292
+ result: PowerStatus
1293
+ },
1294
+ /** Timed tasks, each with its last run; `agent`: only that agent's. */
1295
+ "tasks/list": {
1296
+ capability: PIPELINES_CAPABILITY,
1297
+ params: external_exports.object({ agent: external_exports.string().optional() }),
1298
+ result: external_exports.object({ items: external_exports.array(AgentTask.extend({ lastRun: AgentTaskRun.optional() })) })
1299
+ },
1300
+ /** Create (no `id`) or replace. */
1301
+ "tasks/save": {
1302
+ capability: PIPELINES_CAPABILITY,
1303
+ params: external_exports.object({ task: AgentTask.extend({ id: AgentTaskId.optional() }) }),
1304
+ result: AgentTask
1305
+ },
1306
+ "tasks/remove": {
1307
+ capability: PIPELINES_CAPABILITY,
1308
+ params: external_exports.object({ id: AgentTaskId }),
1309
+ result: external_exports.object({})
1310
+ },
1311
+ /** Hand it to its agent now (not waiting for the reply). */
1312
+ "tasks/run": {
1313
+ capability: PIPELINES_CAPABILITY,
1314
+ params: external_exports.object({ id: AgentTaskId }),
1315
+ result: AgentTaskRun
1316
+ },
1317
+ "tasks/runs": {
1318
+ capability: PIPELINES_CAPABILITY,
1319
+ params: external_exports.object({ id: AgentTaskId }),
1320
+ result: external_exports.object({ items: external_exports.array(AgentTaskRun) })
1321
+ }
1322
+ };
1323
+ var PipelineNotifications = {
1324
+ /** A pipeline was saved or removed. */
1325
+ "pipelines/changed": external_exports.object({}),
1326
+ /** A pipeline run started or changed. */
1327
+ "pipelines/run": PipelineRun,
1328
+ "schedule/changed": external_exports.object({}),
1329
+ /** A timed task was saved, removed, or one of its runs started or ended. */
1330
+ "tasks/changed": external_exports.object({}),
1331
+ /** Keeping awake started or stopped; a sleep / shutdown was asked for, began counting down, was cancelled or done. */
1332
+ "schedule/power": PowerStatus
1333
+ };
1334
+
1335
+ // packages/protocol/lib/intervene.js
1336
+ var INTERVENE_CAPABILITY = "intervene";
1337
+ var InterventionState = external_exports.enum([
1338
+ /** The agent is working on it. */
1339
+ "running",
1340
+ /** Fixed; the script was resumed. */
1341
+ "resolved",
1342
+ /** Fixed; the script was run again. */
1343
+ "retried",
1344
+ /** The agent could not handle it; passed on to the user. */
1345
+ "gave-up",
1346
+ /** The user took over. */
1347
+ "taken-over",
1348
+ /** Took too long. */
1349
+ "timeout",
1350
+ /** Could not start (no image-capable model, the run had ended …). */
1351
+ "failed"
1352
+ ]);
1353
+ var Intervention = external_exports.object({
1354
+ id: external_exports.string(),
1355
+ incidentId: external_exports.string().optional(),
1356
+ runId: external_exports.string().optional(),
1357
+ title: external_exports.string(),
1358
+ /** `diagnose`: look and explain only; `act`: may also click and type. */
1359
+ mode: external_exports.enum(["diagnose", "act"]),
1360
+ state: InterventionState,
1361
+ /** The agent session doing it (open it to watch). */
1362
+ sessionId: external_exports.string().optional(),
1363
+ /** The script is suspended while the agent works. */
1364
+ paused: external_exports.boolean(),
1365
+ /** The agent's own account of what happened and what it did. */
1366
+ summary: external_exports.string().optional(),
1367
+ startedAt: external_exports.number(),
1368
+ endedAt: external_exports.number().optional()
1369
+ });
1370
+ var InterveneRequests = {
1371
+ "intervene/list": {
1372
+ capability: INTERVENE_CAPABILITY,
1373
+ params: external_exports.object({ limit: external_exports.number().int().min(1).max(100).optional() }),
1374
+ result: external_exports.object({ items: external_exports.array(Intervention) })
1375
+ },
1376
+ /** Stop the agent; the script stays paused until `intervene/release`. */
1377
+ "intervene/takeover": {
1378
+ capability: INTERVENE_CAPABILITY,
1379
+ params: external_exports.object({ id: external_exports.string() }),
1380
+ result: Intervention
1381
+ },
1382
+ /** Done by hand: carry on, run the task again, or stop it. */
1383
+ "intervene/release": {
1384
+ capability: INTERVENE_CAPABILITY,
1385
+ params: external_exports.object({ id: external_exports.string(), then: external_exports.enum(["resume", "restart", "stop"]) }),
1386
+ result: Intervention
1387
+ }
1388
+ };
1389
+ var InterveneNotifications = {
1390
+ "intervene/changed": Intervention
1391
+ };
1392
+
1393
+ // packages/protocol/lib/games.js
1394
+ var GAMES_CAPABILITY = "games";
1395
+ var Activity = external_exports.object({
1396
+ /** `<game>/<key>`; the key is the normalised name, so a site and the screen meet on it. */
1397
+ id: external_exports.string(),
1398
+ game: external_exports.string(),
1399
+ name: external_exports.string(),
1400
+ startsAt: external_exports.number().optional(),
1401
+ endsAt: external_exports.number().optional(),
1402
+ /** The event's shop stays open until then (Arknights: 兑换结束). */
1403
+ shopEndsAt: external_exports.number().optional(),
1404
+ url: external_exports.string().optional(),
1405
+ /** What kind of event, as the data site says ("SideStory", "挑战活动"). */
1406
+ kind: external_exports.string().optional(),
1407
+ /** What it is about, from the data site. */
1408
+ description: external_exports.string().optional(),
1409
+ /**
1410
+ * Its picture (fetch it with `games/image`). Unless the user chose a source
1411
+ * (`chosen`), by rank: what the user set, then what a source gives (data
1412
+ * sites, then web pages), then the screenshot the agent read it from.
1413
+ */
1414
+ cover: external_exports.string().optional(),
1415
+ /** The source whose dates are shown: a data site, else the newest web page the agent read. */
1416
+ site: external_exports.object({ source: external_exports.string(), name: external_exports.string(), at: external_exports.number() }).optional(),
1417
+ /** Every source that lists it (data sites, web pages the agent read), with what each says. */
1418
+ sources: external_exports.array(external_exports.object({
1419
+ id: external_exports.string(),
1420
+ name: external_exports.string(),
1421
+ at: external_exports.number(),
1422
+ web: external_exports.boolean(),
1423
+ startsAt: external_exports.number().optional(),
1424
+ endsAt: external_exports.number().optional(),
1425
+ shopEndsAt: external_exports.number().optional(),
1426
+ cover: external_exports.string().optional()
1427
+ })).optional(),
1428
+ /**
1429
+ * The source the user picked for the picture and the dates (`games/activity/source`):
1430
+ * a source's id, `OWN_SOURCE` or `SCREEN_SOURCE`. Absent: the default order.
1431
+ */
1432
+ chosen: external_exports.string().optional(),
1433
+ /** Which source each shown value comes from, in the same ids as `chosen`. */
1434
+ shown: external_exports.object({ cover: external_exports.string().optional(), startsAt: external_exports.string().optional(), endsAt: external_exports.string().optional() }).optional(),
1435
+ /** Read from the game screen by the agent. */
1436
+ screen: external_exports.object({
1437
+ at: external_exports.number(),
1438
+ /** The remaining time as the game wrote it. */
1439
+ remaining: external_exports.string().optional(),
1440
+ endsAt: external_exports.number().optional(),
1441
+ /** A screenshot was kept (`games/evidence`). */
1442
+ evidence: external_exports.boolean(),
1443
+ /**
1444
+ * The screenshot it was read from (`shot:…`, fetch it with `games/image`),
1445
+ * also the activity's `cover` when no source and not the user gives one.
1446
+ * Kept from an earlier reading when the last one saved none.
1447
+ */
1448
+ image: external_exports.string().optional(),
1449
+ sessionId: external_exports.string().optional()
1450
+ }).optional(),
1451
+ /** Still to do, as read from the game ("活动商店还剩 3 项没换"). */
1452
+ todo: external_exports.array(external_exports.string()),
1453
+ done: external_exports.array(external_exports.string()),
1454
+ progress: external_exports.string().optional(),
1455
+ /** The user said they are done with it (or took it back): their word beats the lists. */
1456
+ finished: external_exports.object({ at: external_exports.number() }).optional(),
1457
+ /** The game and the data site disagree on when it ends. */
1458
+ mismatch: external_exports.string().optional(),
1459
+ /**
1460
+ * What the user (or the agent for them) wrote themselves (`games/activity/save`):
1461
+ * those fields beat every source, and a refresh never changes or drops them.
1462
+ * An activity with no `sources` and no `screen` is one the user added.
1463
+ */
1464
+ own: external_exports.object({
1465
+ at: external_exports.number(),
1466
+ fields: external_exports.array(external_exports.enum(["name", "startsAt", "endsAt", "kind", "description", "url", "cover"])),
1467
+ startsAt: external_exports.number().optional(),
1468
+ endsAt: external_exports.number().optional(),
1469
+ cover: external_exports.string().optional()
1470
+ }).optional()
1471
+ });
1472
+ var OWN_SOURCE = "@own";
1473
+ var SCREEN_SOURCE = "@screen";
1474
+ var MAX_ACTIVITY_IMAGE_BASE64 = 112e5;
1475
+ var ActivityImage = external_exports.object({
1476
+ mediaType: external_exports.enum(["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif"]),
1477
+ data: external_exports.string().min(1).max(MAX_ACTIVITY_IMAGE_BASE64).regex(/^[A-Za-z0-9+/]+={0,2}$/, "base64 without a data: prefix")
1478
+ });
1479
+ var OWN_IMAGE = /^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/;
1480
+ var SHOT_IMAGE = /^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/;
1481
+ var GameSourceInfo = external_exports.object({
1482
+ id: external_exports.string(),
1483
+ name: external_exports.string(),
1484
+ homepage: external_exports.string().optional(),
1485
+ /** Read by the plugin itself (no model); otherwise only the agent reads it. */
1486
+ auto: external_exports.boolean(),
1487
+ /** A page the user added on the game page (`games/source/add`); it can be removed there. */
1488
+ added: external_exports.boolean().optional()
1489
+ });
1490
+ var GameInfo = external_exports.object({
1491
+ id: external_exports.string(),
1492
+ name: external_exports.string(),
1493
+ aliases: external_exports.array(external_exports.string()),
1494
+ /** Script Packs that play it. */
1495
+ scripts: external_exports.array(external_exports.string()),
1496
+ timezone: external_exports.string(),
1497
+ screen: external_exports.object({ target: external_exports.enum(["emulator", "window"]), window: external_exports.string().optional() }).optional(),
1498
+ sources: external_exports.array(GameSourceInfo),
1499
+ builtin: external_exports.boolean(),
1500
+ /** The game pack's own picture (https; fetch it with `games/image`). */
1501
+ art: external_exports.string().optional(),
1502
+ /** Followed from the SRA public API without a Game Pack (no scripts, no screen reading): can be unfollowed. */
1503
+ followed: external_exports.boolean().optional(),
1504
+ /** The game's current version, from a data site that knows it. */
1505
+ version: external_exports.object({
1506
+ name: external_exports.string(),
1507
+ title: external_exports.string().optional(),
1508
+ startsAt: external_exports.number().optional(),
1509
+ endsAt: external_exports.number().optional(),
1510
+ /** The version's key art (fetch it with `games/image`). */
1511
+ cover: external_exports.string().optional(),
1512
+ source: external_exports.string(),
1513
+ at: external_exports.number()
1514
+ }).optional(),
1515
+ /** Banners (卡池) open now or soon, from a data site that lists them. */
1516
+ pools: external_exports.array(external_exports.object({
1517
+ name: external_exports.string(),
1518
+ type: external_exports.string().optional(),
1519
+ startsAt: external_exports.number().optional(),
1520
+ endsAt: external_exports.number(),
1521
+ cover: external_exports.string().optional(),
1522
+ up: external_exports.array(external_exports.string())
1523
+ })).optional(),
1524
+ /** The last data-site refresh. */
1525
+ refreshed: external_exports.object({ at: external_exports.number(), ok: external_exports.boolean(), count: external_exports.number(), detail: external_exports.string().optional() }).optional(),
1526
+ /** The last time the agent read the game screen. */
1527
+ reading: external_exports.object({
1528
+ state: external_exports.enum(["running", "done", "failed"]),
1529
+ at: external_exports.number(),
1530
+ sessionId: external_exports.string().optional(),
1531
+ summary: external_exports.string().optional()
1532
+ }).optional(),
1533
+ /** The last time the agent read the web for it (official news, wikis — the sources the plugin cannot read itself). */
1534
+ webReading: external_exports.object({
1535
+ state: external_exports.enum(["running", "done", "failed"]),
1536
+ at: external_exports.number(),
1537
+ sessionId: external_exports.string().optional(),
1538
+ summary: external_exports.string().optional()
1539
+ }).optional()
1540
+ });
1541
+ var GamesSettings = external_exports.object({
1542
+ report: external_exports.object({
1543
+ /** Send the daily report to the chat channels (Feishu). */
1544
+ enabled: external_exports.boolean(),
1545
+ /** Local time it is sent; data sites are read just before. */
1546
+ at: ClockTime,
1547
+ /** Games in the report; empty: every game with events. */
1548
+ games: external_exports.array(external_exports.string()),
1549
+ /** An event ending within this many days is called out. */
1550
+ soonDays: external_exports.number().int().min(1).max(30),
1551
+ /** The agent writes the report from the recent events (just started, ending soon, starting soon); off, or when it cannot: the plain list. */
1552
+ ai: external_exports.boolean()
1553
+ }),
1554
+ /** SRA game ids followed besides the Game Packs (`ys`, `zzz`…), see `games/catalog`. */
1555
+ followed: external_exports.array(external_exports.string())
1556
+ });
1557
+ var ReportInfo = external_exports.object({
1558
+ /** When today's (or the last) report went out. */
1559
+ lastSentAt: external_exports.number().optional(),
1560
+ /** The day (YYYY-MM-DD, local) it was for. */
1561
+ lastDay: external_exports.string().optional(),
1562
+ lastResult: external_exports.string().optional(),
1563
+ /** What went out last time (the agent's summary, or the plain list). */
1564
+ lastText: external_exports.string().optional(),
1565
+ /** The next time it will go out. */
1566
+ next: external_exports.number().optional()
1567
+ });
1568
+ var GamesRequests = {
1569
+ "games/list": {
1570
+ capability: GAMES_CAPABILITY,
1571
+ params: external_exports.object({}),
1572
+ result: external_exports.object({ games: external_exports.array(GameInfo), activities: external_exports.array(Activity), settings: GamesSettings, report: ReportInfo })
1573
+ },
1574
+ /** Read the data sites now (one game, or all). */
1575
+ "games/refresh": {
1576
+ capability: GAMES_CAPABILITY,
1577
+ params: external_exports.object({ game: external_exports.string().optional() }),
1578
+ result: external_exports.object({ results: external_exports.array(external_exports.object({ game: external_exports.string(), ok: external_exports.boolean(), count: external_exports.number(), detail: external_exports.string().optional() })) })
1579
+ },
1580
+ /** Ask the agent to read the game screen; it works in a session of its own. */
1581
+ /**
1582
+ * Ask the agent to read the game (`screen`, the default: its activity pages
1583
+ * in the game) or the web (`web`: official news, wikis; one `source` of the
1584
+ * game pack, or all it cannot read itself). It works in a session of its own.
1585
+ */
1586
+ "games/read": {
1587
+ capability: GAMES_CAPABILITY,
1588
+ params: external_exports.object({ game: external_exports.string(), how: external_exports.enum(["screen", "web"]).optional(), source: external_exports.string().optional() }),
1589
+ result: external_exports.object({ sessionId: external_exports.string() })
1590
+ },
1591
+ "games/report/preview": {
1592
+ capability: GAMES_CAPABILITY,
1593
+ params: external_exports.object({}),
1594
+ result: external_exports.object({ title: external_exports.string(), text: external_exports.string() })
1595
+ },
1596
+ "games/report/send": {
1597
+ capability: GAMES_CAPABILITY,
1598
+ params: external_exports.object({}),
1599
+ result: external_exports.object({ channels: external_exports.array(external_exports.string()), text: external_exports.string() })
1600
+ },
1601
+ "games/settings/set": {
1602
+ capability: GAMES_CAPABILITY,
1603
+ params: external_exports.object({ report: GamesSettings.shape.report.partial().optional() }),
1604
+ result: GamesSettings
1605
+ },
1606
+ /** The screenshot kept when an event was read from the game. */
1607
+ "games/evidence": {
1608
+ capability: GAMES_CAPABILITY,
1609
+ params: external_exports.object({ activityId: external_exports.string() }),
1610
+ result: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() })
1611
+ },
1612
+ /**
1613
+ * A picture a data site gave (a version's art, an event's or a banner's
1614
+ * cover), fetched and kept by the host: the UI loads no outside addresses.
1615
+ * Only addresses that came from a data site are fetched.
1616
+ */
1617
+ "games/image": {
1618
+ capability: GAMES_CAPABILITY,
1619
+ /** A data site's https address, a picture the user added (`own:…`), or a kept screenshot (`shot:…`). */
1620
+ params: external_exports.object({ url: external_exports.string().refine((u) => OWN_IMAGE.test(u) || SHOT_IMAGE.test(u) || /^https?:\/\/\S+$/.test(u), "\u4E0D\u662F\u56FE\u7247\u5730\u5740") }),
1621
+ result: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() })
1622
+ },
1623
+ /**
1624
+ * The game program's own icon (its .exe, as Explorer shows it), for the game's avatar: the program a script that plays
1625
+ * it starts (启动游戏), else where 自动查找 finds it. No `icon`: no PC program known (a phone game), or not on Windows.
1626
+ */
1627
+ "games/icon": {
1628
+ capability: GAMES_CAPABILITY,
1629
+ params: external_exports.object({ game: external_exports.string().min(1) }),
1630
+ result: external_exports.object({ icon: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() }).optional() })
1631
+ },
1632
+ /** Ask the agent to find where a game's events can be read and add it (a game pack of the user's own). */
1633
+ "games/discover": {
1634
+ capability: GAMES_CAPABILITY,
1635
+ params: external_exports.object({ name: external_exports.string().min(1).max(60) }),
1636
+ result: external_exports.object({ sessionId: external_exports.string() })
1637
+ },
1638
+ /**
1639
+ * A page about the game the user wants read (official news, a wiki page, a
1640
+ * forum post): kept with the game as a source only the agent reads, and
1641
+ * read by the agent at once. @returns the reading session.
1642
+ */
1643
+ /** Mirror酱 tools that play a game, matched like scripts (no CDK needed); `builtin` when Mirror酱's list could not be read. */
1644
+ "games/mirrorchyan": {
1645
+ capability: GAMES_CAPABILITY,
1646
+ params: external_exports.object({ game: external_exports.string() }),
1647
+ result: external_exports.object({ items: external_exports.array(MirrorSearchItem), from: external_exports.enum(["mirrorchyan", "builtin"]) })
1648
+ },
1649
+ "games/source/add": {
1650
+ capability: GAMES_CAPABILITY,
1651
+ params: external_exports.object({ game: external_exports.string(), url: external_exports.string().url().refine((u) => /^https?:\/\//.test(u), "\u53EA\u80FD\u662F http \u6216 https \u7F51\u5740"), name: external_exports.string().max(30).optional() }),
1652
+ result: external_exports.object({ source: external_exports.string(), sessionId: external_exports.string() })
1653
+ },
1654
+ /** Remove a page the user added. */
1655
+ "games/source/remove": {
1656
+ capability: GAMES_CAPABILITY,
1657
+ params: external_exports.object({ game: external_exports.string(), source: external_exports.string() }),
1658
+ result: external_exports.object({})
1659
+ },
1660
+ /** Every game the SRA public API knows, and whether it is shown (a Game Pack reads it, or it is followed). */
1661
+ "games/catalog": {
1662
+ capability: GAMES_CAPABILITY,
1663
+ params: external_exports.object({}),
1664
+ result: external_exports.object({ games: external_exports.array(external_exports.object({ sra: external_exports.string(), name: external_exports.string(), followed: external_exports.boolean(), pack: external_exports.string().optional() })) })
1665
+ },
1666
+ /** Follow (or stop following) an SRA game that has no Game Pack: its events come in with the daily refresh. */
1667
+ "games/follow": {
1668
+ capability: GAMES_CAPABILITY,
1669
+ params: external_exports.object({ sra: external_exports.string(), follow: external_exports.boolean() }),
1670
+ result: external_exports.object({})
1671
+ },
1672
+ /** The user's own progress on an event: its checklist, or done as a whole. */
1673
+ "games/activity/progress": {
1674
+ capability: GAMES_CAPABILITY,
1675
+ params: external_exports.object({
1676
+ activityId: external_exports.string(),
1677
+ todo: external_exports.array(external_exports.string().min(1).max(80)).max(30).optional(),
1678
+ done: external_exports.array(external_exports.string().min(1).max(80)).max(30).optional(),
1679
+ finished: external_exports.boolean().optional()
1680
+ }),
1681
+ result: Activity
1682
+ },
1683
+ /**
1684
+ * Add an event of the user's own, or write the user's word on one
1685
+ * (`activityId`): each field set beats what the sources say, `null` takes
1686
+ * the user's value back (the sources' shows again), absent leaves it. A
1687
+ * field equal to what the sources say is not kept. `image`: a new picture
1688
+ * (kept by the host, it becomes `cover`). A new one needs a `name`; one
1689
+ * with the same name already in the calendar is that one.
1690
+ */
1691
+ "games/activity/save": {
1692
+ capability: GAMES_CAPABILITY,
1693
+ params: external_exports.object({
1694
+ game: external_exports.string(),
1695
+ activityId: external_exports.string().optional(),
1696
+ name: external_exports.string().trim().min(1).max(60).nullable().optional(),
1697
+ startsAt: external_exports.number().nullable().optional(),
1698
+ endsAt: external_exports.number().nullable().optional(),
1699
+ kind: external_exports.string().trim().max(20).nullable().optional(),
1700
+ description: external_exports.string().trim().max(500).nullable().optional(),
1701
+ url: external_exports.string().trim().refine((u) => u === "" || /^https?:\/\/\S+$/.test(u), "\u53EA\u80FD\u662F http \u6216 https \u7F51\u5740").nullable().optional(),
1702
+ /** null: drop the user's picture (the sources' shows again). */
1703
+ cover: external_exports.null().optional(),
1704
+ image: ActivityImage.optional(),
1705
+ todo: external_exports.array(external_exports.string().min(1).max(80)).max(30).optional()
1706
+ }),
1707
+ result: Activity
1708
+ },
1709
+ /**
1710
+ * Which source an event's picture and dates come from: a source's id,
1711
+ * `OWN_SOURCE` or `SCREEN_SOURCE`; `null` goes back to the default order.
1712
+ * What that source does not say still comes from the default order.
1713
+ */
1714
+ "games/activity/source": {
1715
+ capability: GAMES_CAPABILITY,
1716
+ params: external_exports.object({ activityId: external_exports.string(), source: external_exports.string().nullable() }),
1717
+ result: Activity
1718
+ },
1719
+ /** Take back everything the user wrote on an event: the sources' word shows again; one only the user added goes. */
1720
+ "games/activity/reset": {
1721
+ capability: GAMES_CAPABILITY,
1722
+ params: external_exports.object({ activityId: external_exports.string() }),
1723
+ result: external_exports.object({ activity: Activity.optional() })
1724
+ },
1725
+ /** Forget an event (wrongly read, or no longer wanted). */
1726
+ "games/activity/remove": {
1727
+ capability: GAMES_CAPABILITY,
1728
+ params: external_exports.object({ activityId: external_exports.string() }),
1729
+ result: external_exports.object({})
1730
+ }
1731
+ };
1732
+ var GamesNotifications = {
1733
+ /** Something changed; re-read `games/list`. */
1734
+ "games/changed": external_exports.object({ game: external_exports.string().optional() })
1735
+ };
1736
+
1737
+ // packages/protocol/lib/permissions.js
1738
+ var PERMISSIONS_CAPABILITY = "permissions";
1739
+ var PermissionMode = external_exports.enum(["ask", "full"]);
1740
+ var AreaPolicy = external_exports.enum(["default", "allow", "ask", "deny"]);
1741
+ var AGENT_AREAS = [
1742
+ { id: "pipelines-edit", title: "\u7F16\u8F91\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6", description: "\u8D77\u8349\u6D41\u6C34\u7EBF\uFF0C\u300C\u7F16\u6392\u300D\u76F4\u63A5\u4FEE\u6539\u3001\u4FDD\u5B58\u6D41\u6C34\u7EBF\uFF08pipeline_save\uFF09\uFF0C\u8BBE\u5B9A\u65F6\u95F4\uFF08schedule_set\uFF09\uFF0C\u4EE5\u53CA dsh \u81EA\u5DF1\u7684\u5B9A\u65F6\u4EFB\u52A1\u3002", tools: ["pipeline_draft", "pipeline_save", "schedule_set", "schedule_create", "schedule_edit"] },
1743
+ { id: "run", title: "\u8FD0\u884C\u6D41\u6C34\u7EBF\u548C\u811A\u672C", description: "\u542F\u52A8\u3001\u505C\u6B62\u6D41\u6C34\u7EBF\u548C\u811A\u672C\u4EFB\u52A1\u3002", tools: ["pipeline_run", "script_run", "script_stop"] },
1744
+ { id: "scripts-config", title: "\u6539\u811A\u672C\u914D\u7F6E", description: "\u4FEE\u6539\u811A\u672C\u7684\u914D\u7F6E\u526F\u672C\u3001\u5BFC\u5165\u914D\u7F6E\u3001\u65B0\u5EFA\u9009\u9879\u3001\u6253\u5F00\u811A\u672C\u81EA\u5DF1\u7684\u8BBE\u7F6E\u754C\u9762\u3001\u8BBE\u7F6E\u6E38\u620F\u4F4D\u7F6E\u3002", tools: ["script_config_set", "script_config_import", "script_choice_create", "script_settings", "game_path_set"] },
1745
+ { id: "scripts-install", title: "\u5B89\u88C5\u3001\u66F4\u65B0\u3001\u5220\u9664\u811A\u672C", description: "\u4ECE GitHub \u5B89\u88C5\u3001\u66F4\u65B0\u3001\u56DE\u6EDA\u3001\u5220\u9664\u811A\u672C\uFF0C\u8FD0\u884C\u811A\u672C\u7684\u5B89\u88C5\u7A0B\u5E8F\uFF0C\u5BFC\u5165\u672C\u5730\u811A\u672C\uFF0C\u4FEE\u590D\u8FD0\u884C\u73AF\u5883\uFF0C\u5199\u3001\u6539\u811A\u672C\u5305\uFF08pack_propose\uFF0C\u76F4\u63A5\u751F\u6548\uFF09\u3002", tools: ["script_install", "script_update", "script_rollback", "script_remove", "script_setup_run", "script_import", "script_env_fix", "pack_propose"] },
1746
+ { id: "screen", title: "\u64CD\u4F5C\u5C4F\u5E55\u548C\u6A21\u62DF\u5668", description: "\u5728\u6E38\u620F\u7A97\u53E3\u6216\u6A21\u62DF\u5668\u91CC\u70B9\u51FB\u3001\u8F93\u5165\u3001\u6309\u952E\u3001\u6ED1\u52A8\u3001\u5207\u6362\u7A97\u53E3\uFF08\u622A\u56FE\u4E0D\u7B97\uFF09\u3002", tools: ["screen_tap", "screen_type", "screen_key", "screen_scroll", "screen_swipe", "window_focus"] },
1747
+ { id: "games", title: "\u542F\u52A8\u3001\u5173\u95ED\u6E38\u620F\u548C\u6A21\u62DF\u5668", description: "\u6253\u5F00\u3001\u5173\u6389\u6E38\u620F\uFF0C\u542F\u52A8\u3001\u5173\u95ED\u3001\u5B89\u88C5\u3001\u8BBE\u7F6E\u6A21\u62DF\u5668\u3002", tools: ["game_launch", "game_close", "emulator_start", "emulator_stop", "emulator_install", "emulator_configure"] },
1748
+ { id: "game-records", title: "\u8BB0\u5F55\u6D3B\u52A8\u3001\u6DFB\u52A0\u6E38\u620F", description: "\u628A\u8BFB\u5230\u7684\u6D3B\u52A8\u5199\u8FDB\u65E5\u5386\uFF0C\u66FF\u4F60\u6DFB\u52A0\u3001\u4FEE\u6539\u6216\u53BB\u6389\u6D3B\u52A8\uFF0C\u7ED9\u65B0\u6E38\u620F\u5EFA\u6E38\u620F\u5305\u3002", tools: ["game_record", "game_activity_save", "game_activity_remove", "game_add"] },
1749
+ { id: "skills", title: "\u4FDD\u5B58\u6280\u80FD", description: "\u628A\u505A\u6CD5\u5B58\u6210\u6280\u80FD\uFF0C\u4EE5\u540E\u7684\u5BF9\u8BDD\u90FD\u4F1A\u7528\u5230\u3002", tools: ["skill_save"] },
1750
+ { id: "web", title: "\u4E0A\u7F51\u67E5\u8D44\u6599", description: "\u8BFB\u7F51\u9875\u3001\u641C\u7D22\u3002", tools: ["web_fetch", "web_search"] },
1751
+ { id: "browser", title: "\u64CD\u4F5C\u5185\u7F6E\u6D4F\u89C8\u5668", description: "\u5728\u5185\u7F6E\u6D4F\u89C8\u5668\u91CC\u6253\u5F00\u7F51\u9875\u3001\u70B9\u51FB\u3001\u8F93\u5165\u3001\u6309\u952E\u3001\u6EDA\u52A8\u3001\u5207\u6362\u6807\u7B7E\u9875\uFF08\u8BFB\u9875\u9762\u548C\u622A\u56FE\u4E0D\u7B97\uFF09\u3002", tools: ["browser_navigate", "browser_click", "browser_type", "browser_press", "browser_scroll", "browser_tabs"] },
1752
+ { id: "shell", title: "\u8FD0\u884C\u547D\u4EE4\u3001\u6539\u6587\u4EF6", description: "dsh \u81EA\u5E26\u7684\u547D\u4EE4\u884C\u548C\u6587\u4EF6\u7F16\u8F91\u3002\u53EA\u5728\u5B83\u8BF7\u6C42\u786E\u8BA4\u65F6\u6309\u8FD9\u91CC\u7684\u8BBE\u7F6E\u5904\u7406\uFF08\u6C99\u7BB1\u91CC\u7684\u666E\u901A\u547D\u4EE4\u4E0D\u4F1A\u8BF7\u6C42\uFF09\u3002", tools: ["pwsh", "bash", "edit", "write"], approvalOnly: true }
1753
+ ];
1754
+ function areaOf(toolName) {
1755
+ return AGENT_AREAS.find((a) => a.tools.includes(toolName));
1756
+ }
1757
+ var PermissionsState = external_exports.object({
1758
+ mode: PermissionMode,
1759
+ /** When the mode last changed. */
1760
+ since: external_exports.number().optional(),
1761
+ /** Area id → policy; areas not listed are `default`. */
1762
+ areas: external_exports.record(external_exports.string(), AreaPolicy).default({}),
1763
+ /** Approvals answered "allow" by full access or an area set to allow, newest first (since the host started). */
1764
+ recent: external_exports.array(external_exports.object({
1765
+ at: external_exports.number(),
1766
+ sessionId: external_exports.string(),
1767
+ toolName: external_exports.string(),
1768
+ reason: external_exports.string().optional()
1769
+ }))
1770
+ });
1771
+ var PermissionsRequests = {
1772
+ "permissions/get": {
1773
+ capability: PERMISSIONS_CAPABILITY,
1774
+ params: external_exports.object({}),
1775
+ result: PermissionsState
1776
+ },
1777
+ "permissions/set": {
1778
+ capability: PERMISSIONS_CAPABILITY,
1779
+ params: external_exports.object({ mode: PermissionMode }),
1780
+ result: PermissionsState
1781
+ },
1782
+ /** One area's policy. */
1783
+ "permissions/area/set": {
1784
+ capability: PERMISSIONS_CAPABILITY,
1785
+ params: external_exports.object({ area: external_exports.string(), policy: AreaPolicy }),
1786
+ result: PermissionsState
1787
+ }
1788
+ };
1789
+ var PermissionsNotifications = {
1790
+ /** The mode or an area changed, or something was allowed without asking. */
1791
+ "permissions/changed": PermissionsState
1792
+ };
1793
+
1794
+ // packages/protocol/lib/questions.js
1795
+ var QUESTIONS_CAPABILITY = "questions";
1796
+ var QuestionOption = external_exports.object({
1797
+ label: external_exports.string(),
1798
+ description: external_exports.string().optional()
1799
+ });
1800
+ var QuestionItem = external_exports.object({
1801
+ /** Stable id within the request, echoed in the answer. */
1802
+ id: external_exports.string(),
1803
+ question: external_exports.string(),
1804
+ /** Supporting detail (markdown). */
1805
+ detail: external_exports.string().optional(),
1806
+ /** Short heading. */
1807
+ header: external_exports.string().optional(),
1808
+ options: external_exports.array(QuestionOption).optional(),
1809
+ multiSelect: external_exports.boolean().optional()
1810
+ });
1811
+ var QuestionRequested = external_exports.object({
1812
+ questionId: external_exports.string(),
1813
+ sessionId: external_exports.string(),
1814
+ /** The `ask_user_question` tool call, when known. */
1815
+ callId: external_exports.string().optional(),
1816
+ questions: external_exports.array(QuestionItem)
1817
+ });
1818
+ var QuestionAnswerItem = external_exports.object({
1819
+ id: external_exports.string(),
1820
+ selected: external_exports.array(external_exports.string()),
1821
+ custom: external_exports.string().optional()
1822
+ });
1823
+ var QuestionOutcome = external_exports.enum(["answered", "cancelled", "unavailable"]);
1824
+ var QuestionsRequests = {
1825
+ /** Answer a question; items left out count as skipped. */
1826
+ "question/respond": {
1827
+ capability: QUESTIONS_CAPABILITY,
1828
+ params: external_exports.object({ questionId: external_exports.string(), answers: external_exports.array(QuestionAnswerItem) }),
1829
+ result: external_exports.object({})
1830
+ }
1831
+ };
1832
+ var QuestionsNotifications = {
1833
+ "question/requested": QuestionRequested,
1834
+ "question/resolved": external_exports.object({ questionId: external_exports.string(), outcome: QuestionOutcome, answers: external_exports.array(QuestionAnswerItem).optional() })
1835
+ };
1836
+
1837
+ // packages/protocol/lib/instances.js
1838
+ var INSTANCES_CAPABILITY = "instances";
1839
+ var OtherCopy = external_exports.object({
1840
+ pid: external_exports.number().int(),
1841
+ /** What it is, in words: 「桌面版」, 「dsh 插件版」 … */
1842
+ label: external_exports.string(),
1843
+ /** Where its data lives. */
1844
+ dataDir: external_exports.string().optional(),
1845
+ startedAt: external_exports.number(),
1846
+ /** What clashes with this copy, one sentence each; the first is the general one. */
1847
+ warnings: external_exports.array(external_exports.string())
1848
+ });
1849
+ var OtherCopies = external_exports.object({ others: external_exports.array(OtherCopy) });
1850
+ var InstancesRequests = {
1851
+ "instances/others": {
1852
+ capability: INSTANCES_CAPABILITY,
1853
+ params: external_exports.object({}),
1854
+ result: OtherCopies
1855
+ }
1856
+ };
1857
+ var InstancesNotifications = {
1858
+ /** Another copy started or stopped, or what it uses changed. */
1859
+ "instances/changed": OtherCopies
1860
+ };
1861
+
1862
+ // packages/protocol/lib/skills.js
1863
+ var SKILLS_CAPABILITY = "skills";
1864
+ var SkillOwner = external_exports.object({ scripts: external_exports.array(external_exports.string()).optional(), games: external_exports.array(external_exports.string()).optional() });
1865
+ var SkillInfo = external_exports.object({
1866
+ /** `/name` in a message invokes it. */
1867
+ name: external_exports.string(),
1868
+ description: external_exports.string(),
1869
+ whenToUse: external_exports.string().optional(),
1870
+ /**
1871
+ * Where it comes from: `bundled` (shipped with the app or a plugin), `custom`
1872
+ * (packs and game packs the user added), `user-dsh` / `user-agents` (the
1873
+ * user's own skill folders), `project-*` (a working folder), `runtime`.
1874
+ */
1875
+ source: external_exports.string(),
1876
+ /** The plugin or provider that serves it. */
1877
+ provider: external_exports.string(),
1878
+ /** Its SKILL.md, when it is a file. */
1879
+ path: external_exports.string().optional(),
1880
+ /** The agent finds and loads it by itself. */
1881
+ modelInvocable: external_exports.boolean(),
1882
+ /** People can call it with `/name`. */
1883
+ userInvocable: external_exports.boolean(),
1884
+ /**
1885
+ * What it belongs to (技能隔离): a session sees it only while it works on one
1886
+ * of these scripts or games. Absent: a general skill, seen everywhere.
1887
+ */
1888
+ owner: SkillOwner.optional(),
1889
+ /** Kept in this app's skills folder (saved by the agent or made on the 技能 page): it can be changed and deleted. */
1890
+ removable: external_exports.boolean().optional()
1891
+ });
1892
+ var SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
1893
+ var MAX_SKILL_NAME = 48;
1894
+ var SkillsRequests = {
1895
+ "skills/list": {
1896
+ capability: SKILLS_CAPABILITY,
1897
+ params: external_exports.object({}),
1898
+ result: external_exports.object({ skills: external_exports.array(SkillInfo) })
1899
+ },
1900
+ /** One skill with its instructions (markdown). */
1901
+ "skills/get": {
1902
+ capability: SKILLS_CAPABILITY,
1903
+ params: external_exports.object({ name: external_exports.string() }),
1904
+ result: SkillInfo.extend({ content: external_exports.string() })
1905
+ },
1906
+ /** Write a skill into this app's skills folder; `replace` to change one already there. Seen by the agents at once. */
1907
+ "skills/save": {
1908
+ capability: SKILLS_CAPABILITY,
1909
+ params: external_exports.object({
1910
+ name: external_exports.string().regex(SKILL_NAME).max(MAX_SKILL_NAME),
1911
+ description: external_exports.string().trim().min(10).max(400),
1912
+ content: external_exports.string().trim().min(20).max(2e4),
1913
+ /** Only these scripts (ids) see it; none: every session. */
1914
+ scripts: external_exports.array(external_exports.string().min(1).max(64)).max(20).optional(),
1915
+ games: external_exports.array(external_exports.string().min(1).max(64)).max(20).optional(),
1916
+ replace: external_exports.boolean().optional()
1917
+ }),
1918
+ result: external_exports.object({ name: external_exports.string(), replaced: external_exports.boolean() })
1919
+ },
1920
+ /** Delete one of this app's skills folder (`removable`). */
1921
+ "skills/remove": {
1922
+ capability: SKILLS_CAPABILITY,
1923
+ params: external_exports.object({ name: external_exports.string() }),
1924
+ result: external_exports.object({})
1925
+ }
1926
+ };
1927
+ var SkillsNotifications = {
1928
+ /** A skill was saved or deleted; re-read `skills/list`. */
1929
+ "skills/changed": external_exports.object({})
1930
+ };
1931
+
1932
+ // packages/protocol/lib/handoff-notes.js
1933
+ var BY_YOU = "\u4F60";
1934
+ var QUIET = "\uFF08\u4E0D\u7528\u544A\u8BC9\u7528\u6237\uFF09";
1935
+ var wordsOf = (text) => text.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu, "");
1936
+ function isQuiet(text) {
1937
+ return wordsOf(text) === wordsOf(QUIET);
1938
+ }
1939
+ var RETURNS = "\uFF08\u4F60\u8FD9\u4E00\u8F6E\u7684\u6700\u540E\u4E00\u6BB5\u56DE\u590D\u4F1A\u4F5C\u4E3A\u7ED3\u8BBA\u4EA4\u56DE\u53BB\u3002\u5728\u90A3\u4E4B\u524D\u8981\u8BA9\u5BF9\u65B9\u77E5\u9053\u7684\uFF0C\u7528 agent_message \u7684 update \u8BF4\uFF0C\u9A6C\u4E0A\u9001\u5230\uFF0C\u8BF4\u51E0\u6B21\u90FD\u884C\uFF1B\u4EA4\u56DE\u7ED3\u8BBA\u4EE5\u540E\u8FD8\u6709\u8BDD\uFF0C\u540C\u6837\u53D1\u5230\u8FD9\u6761\u7EBF\u7D22\uFF1A\u4F60\u7684\u666E\u901A\u56DE\u590D\u5BF9\u65B9\u770B\u4E0D\u5230\u3002\uFF09";
1940
+ var RETURNS_BEFORE = "\uFF08\u505A\u5B8C\u540E\u4F60\u8FD9\u4E00\u8F6E\u7684\u6700\u540E\u4E00\u6BB5\u56DE\u590D\u4F1A\u539F\u6837\u4EA4\u56DE\u53BB\uFF1A\u628A\u7ED3\u8BBA\u5199\u5728\u90A3\u91CC\u3002\uFF09";
1941
+ var THREAD_LINE = /^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/;
1942
+ var PAST_HEAD = (who) => `\uFF08\u4F60\u548C${who}\u4E4B\u524D\u7684\u6765\u5F80\uFF0C\u4ECE\u65E7\u5230\u65B0\u3002\u53EF\u80FD\u5DF2\u7ECF\u8FC7\u65F6\uFF1B\u8981\u770B\u5B8C\u6574\u7684\uFF0C\u7528 agent_threads \u5E26 id\uFF1A`;
1943
+ var PAST_LINE = /^(你和.{1,20}之前的来往,/;
1944
+ var PAST_END = "\uFF09";
1945
+ function taskMessage(by, title, body, returns = false, thread, past) {
1946
+ const head = by === BY_YOU ? `\uFF08\u4F60\u5728\u8F6F\u4EF6\u91CC\u70B9\u7684\uFF1A${oneLine(title)}\uFF09` : `\uFF08${by}\u4EA4\u7ED9\u4F60\u7684\u4E8B\uFF1A${oneLine(title)}\uFF09`;
1947
+ const notes = [...returns ? [RETURNS] : [], ...thread === void 0 ? [] : [`\uFF08\u8FD9\u4EF6\u4E8B\u7684\u7EBF\u7D22\u662F ${thread}\uFF1A\u505A\u7684\u8FC7\u7A0B\u4E2D\u8981\u95EE\u6E05\u695A\u4EC0\u4E48\uFF0C\u7528 agent_message \u95EE\uFF0Cthread \u586B\u5B83\uFF1B\u4E0D\u8981\u731C\u3002\uFF09`]];
1948
+ if (past !== void 0 && past.lines.length > 0)
1949
+ notes.push([PAST_HEAD(past.who), ...past.lines, PAST_END].join("\n"));
1950
+ return `${head}
1951
+ ${notes.map((n) => `${n}
1952
+ `).join("")}
1953
+ ${body}`;
1954
+ }
1955
+ function parseTask(text) {
1956
+ const [first = "", ...rest] = text.split("\n");
1957
+ const mine = /^(你在软件里点的:(.*))$/.exec(first);
1958
+ const theirs = mine === null ? /^(([^():]{1,20})交给你的事:(.*))$/.exec(first) : null;
1959
+ if (mine === null && theirs === null)
1960
+ return void 0;
1961
+ const returns = rest[0] === RETURNS || rest[0] === RETURNS_BEFORE;
1962
+ const after = returns ? rest.slice(1) : rest;
1963
+ const thread = THREAD_LINE.exec(after[0] ?? "")?.[1];
1964
+ const next = thread === void 0 ? after : after.slice(1);
1965
+ const pastEnd = PAST_LINE.test(next[0] ?? "") ? next.indexOf(PAST_END) : -1;
1966
+ return {
1967
+ by: mine !== null ? BY_YOU : theirs[1],
1968
+ title: mine !== null ? mine[1] : theirs[2],
1969
+ returns,
1970
+ ...thread === void 0 ? {} : { thread },
1971
+ body: next.slice(pastEnd + 1).join("\n").trim()
1972
+ };
1973
+ }
1974
+ var THREAD_WORDS = { question: "\u95EE\u4F60", answer: "\u56DE\u7B54\u4E86\u4F60", update: "\u544A\u8BC9\u4F60" };
1975
+ function threadTail(kind, thread, reader, closed) {
1976
+ const person = `\u770B\u60C5\u51B5\u544A\u8BC9\u7528\u6237\uFF1A\u6709\u7528\u6237\u8BE5\u77E5\u9053\u7684\uFF0C\u4E00\u4E24\u53E5\u8BDD\u8BF4\u8981\u70B9\uFF1B\u6CA1\u6709\u7684\u8BDD\u6574\u6BB5\u56DE\u590D\u53EA\u5199\u300C${QUIET}\u300D\u3002`;
1977
+ if (closed) {
1978
+ if (kind === "question")
1979
+ return `\uFF08\u8FD9\u4EF6\u4E8B\u5DF2\u7ECF\u4EA4\u56DE\u4E86\uFF0C\u8FD9\u662F\u540E\u9762\u7684\u8BDD\u3002\u8981\u56DE\u7B54\u7684\u8BDD\u7528 agent_message\uFF1Athread \u586B ${thread}\uFF0Ckind \u586B answer\uFF0C\u4F60\u7684\u666E\u901A\u56DE\u590D\u5BF9\u65B9\u770B\u4E0D\u5230\u3002\uFF09`;
1980
+ return reader === "main" ? `\uFF08\u8FD9\u4EF6\u4E8B\u5DF2\u7ECF\u4EA4\u56DE\u4E86\uFF0C\u8FD9\u662F\u540E\u9762\u8865\u7684\u8BDD\uFF0C\u4E0D\u7528\u56DE\u5B83\u3002${person}\uFF09` : "\uFF08\u8FD9\u4EF6\u4E8B\u5DF2\u7ECF\u4EA4\u56DE\u4E86\uFF0C\u8FD9\u662F\u540E\u9762\u8865\u7684\u8BDD\uFF0C\u4E0D\u7528\u56DE\u5B83\u3002\uFF09";
1981
+ }
1982
+ if (kind === "question")
1983
+ return `\uFF08\u5BF9\u65B9\u5728\u7B49\uFF1A\u5148\u56DE\u7B54\u5B83\uFF0C\u518D\u63A5\u7740\u505A\u624B\u4E0A\u7684\u4E8B\u3002\u7528 agent_message \u56DE\u7B54\uFF1Athread \u586B ${thread}\uFF0Ckind \u586B answer\u3002\u4F60\u8FD9\u4E00\u8F6E\u7684\u6700\u540E\u4E00\u6BB5\u56DE\u590D\u4E5F\u7B97\u56DE\u7B54\u3002\u8981\u7B49\u7528\u6237\u51B3\u5B9A\u7684\u8BDD\uFF0C\u5148\u7528 kind: update \u8BF4\u4E00\u58F0\uFF0C\u7B49\u6709\u4E86\u7ED3\u679C\u518D\u56DE\u7B54\u3002\uFF09`;
1984
+ if (kind === "answer" || reader === "worker")
1985
+ return "\uFF08\u63A5\u7740\u505A\u8FD9\u4EF6\u4E8B\u3002\uFF09";
1986
+ return reader === "main" ? `\uFF08\u5B83\u8FD8\u5728\u505A\uFF0C\u8FD9\u662F\u8FC7\u7A0B\u4E2D\u544A\u8BC9\u4F60\u7684\uFF0C\u4E0D\u7528\u56DE\u5B83\u3002${person}\uFF09` : "\uFF08\u5B83\u8FD8\u5728\u505A\uFF0C\u8FD9\u662F\u8FC7\u7A0B\u4E2D\u544A\u8BC9\u4F60\u7684\uFF0C\u4E0D\u7528\u56DE\u5B83\uFF1A\u63A5\u7740\u505A\u4F60\u624B\u4E0A\u7684\u4E8B\u3002\uFF09";
1987
+ }
1988
+ function threadMessage(input) {
1989
+ const head = `\uFF08\u300C${input.from}\u300D\u5728\u7EBF\u7D22 ${input.thread} \u91CC${THREAD_WORDS[input.kind]}\uFF1A${oneLine(input.title)}\uFF09`;
1990
+ return `${head}
1991
+
1992
+ ${input.text.trim()}
1993
+
1994
+ ${threadTail(input.kind, input.thread, input.reader ?? "worker", input.closed === true)}`;
1995
+ }
1996
+ function parseThreadNote(text) {
1997
+ const [first = "", ...rest] = text.split("\n");
1998
+ const head = /^(「([^」]+)」在线索 (\S+) 里(问你|回答了你|告诉你):(.*))$/.exec(first);
1999
+ if (head === null)
2000
+ return void 0;
2001
+ const body = rest.join("\n").trim();
2002
+ const end = body.lastIndexOf("\n\n\uFF08");
2003
+ return { from: head[1], thread: head[2], kind: head[3] === "\u95EE\u4F60" ? "question" : head[3] === "\u544A\u8BC9\u4F60" ? "update" : "answer", title: head[4], text: (end === -1 ? body : body.slice(0, end)).trim() };
2004
+ }
2005
+ function relayMessage(input) {
2006
+ const head = `\uFF08\u300C${input.agent}\u300D${input.ok ? "\u4EA4\u56DE\u4E86" : "\u6CA1\u6709\u505A\u5B8C"}${input.asker}\u4EA4\u7ED9\u5B83\u7684\u4E8B\uFF1A${oneLine(input.title)}\uFF09`;
2007
+ const tail = input.toLead === true ? input.ok ? "\uFF08\u8FD9\u662F\u4F60\u95EE\u5B83\u7684\u7ED3\u679C\uFF1A\u63A5\u7740\u505A\u4F60\u624B\u4E0A\u7684\u4E8B\uFF0C\u628A\u5B83\u7528\u5230\u4F60\u7684\u7ED3\u8BBA\u91CC\u3002\uFF09" : "\uFF08\u5B83\u6CA1\u505A\u6210\uFF1A\u63A5\u7740\u505A\u4F60\u624B\u4E0A\u7684\u4E8B\uFF0C\u80FD\u7ED5\u8FC7\u53BB\u5C31\u7ED5\u8FC7\u53BB\uFF0C\u7ED5\u4E0D\u8FC7\u53BB\u5C31\u5728\u4F60\u7684\u7ED3\u8BBA\u91CC\u8BF4\u6E05\u695A\u3002\uFF09" : input.ok ? `\uFF08\u770B\u60C5\u51B5\u544A\u8BC9\u7528\u6237\uFF1A\u6709\u7528\u6237\u8BE5\u77E5\u9053\u6216\u8981\u505A\u7684\uFF0C\u7528\u4E00\u4E24\u53E5\u8BDD\u8BF4\u8981\u70B9\uFF0C\u5B8C\u6574\u8FC7\u7A0B\u5728\u300C${input.agent}\u300D\u7684\u5BF9\u8BDD\u91CC\uFF1B\u6CA1\u6709\u7684\u8BDD\u6574\u6BB5\u56DE\u590D\u53EA\u5199\u300C${QUIET}\u300D\u3002\u8FD8\u8981\u522B\u7684 agent \u63A5\u7740\u505A\u7684\uFF0C\u53EF\u4EE5\u518D\u4EA4\u3002\uFF09` : `\uFF08\u544A\u8BC9\u7528\u6237\u54EA\u91CC\u6CA1\u505A\u6210\u3001\u4E3A\u4EC0\u4E48\uFF1B\u9700\u8981\u7684\u8BDD\u6362\u4E2A\u8BF4\u6CD5\u518D\u4EA4\u4E00\u6B21\uFF0C\u6216\u8005\u95EE\u7528\u6237\u3002\uFF09`;
2008
+ const asked = input.consulted !== void 0 && input.consulted.length > 0 ? `
2009
+
2010
+ \uFF08\u505A\u8FD9\u4EF6\u4E8B\u65F6\u5B83\u8FD8\u95EE\u4E86\uFF1A${input.consulted.join("\u3001")}\u3002\uFF09` : "";
2011
+ return `${head}
2012
+
2013
+ ${input.reply.trim()}${asked}
2014
+
2015
+ ${tail}`;
2016
+ }
2017
+ function threadsBetween(all, a, b) {
2018
+ return all.filter((h) => {
2019
+ const from = h.chain?.at(-2);
2020
+ const to = h.chain?.at(-1);
2021
+ return from === a && to === b || from === b && to === a;
2022
+ });
2023
+ }
2024
+ function parseRelay(text) {
2025
+ const [first = "", ...rest] = text.split("\n");
2026
+ const head = /^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(first);
2027
+ if (head === null)
2028
+ return void 0;
2029
+ const body = rest.join("\n").trim();
2030
+ const end = body.lastIndexOf("\n\n\uFF08");
2031
+ return { agent: head[1], ok: head[2] === "\u4EA4\u56DE\u4E86", asker: head[3], title: head[4], reply: (end === -1 ? body : body.slice(0, end)).trim() };
2032
+ }
2033
+ function oneLine(text) {
2034
+ return text.replace(/\s+/g, " ").replace(/[()]/g, (m) => m === "\uFF08" ? "(" : ")").trim();
2035
+ }
2036
+ var REMINDER_NOTE = /\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;
2037
+ function threadReminder(prompt, thread, by) {
2038
+ return `${prompt}
2039
+
2040
+ \uFF08\u8FD9\u662F\u4F60\u5728\u7EBF\u7D22 ${thread} \u4E0A\u5B9A\u7684\u63D0\u9192\uFF1A\u8981\u8BA9${by}\u77E5\u9053\u7684\uFF0C\u5230\u70B9\u540E\u7528 agent_message \u53D1\u7ED9\u5B83\uFF0Cthread \u586B ${thread}\uFF0Ckind \u586B update\uFF1B\u4F60\u7684\u666E\u901A\u56DE\u590D\u5B83\u770B\u4E0D\u5230\u3002\uFF09`;
2041
+ }
2042
+ function reminderPrompts(text) {
2043
+ const single = /^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(text);
2044
+ if (single !== null)
2045
+ return [jsonString(single[1]).replace(REMINDER_NOTE, "")];
2046
+ const batch = /^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(text);
2047
+ if (batch === null)
2048
+ return void 0;
2049
+ try {
2050
+ const items = JSON.parse(batch[1]);
2051
+ return items.map((item) => String(item.reminder_prompt ?? "").replace(REMINDER_NOTE, "")).filter((p) => p !== "");
2052
+ } catch {
2053
+ return [];
2054
+ }
2055
+ }
2056
+ function reminderLine(prompts) {
2057
+ return prompts.length === 0 ? "\u5B9A\u65F6\u63D0\u9192" : `\u5B9A\u65F6\u63D0\u9192\uFF1A${prompts.map((p) => oneLine(p)).join("\uFF1B")}`;
2058
+ }
2059
+ function jsonString(json) {
2060
+ try {
2061
+ const value = JSON.parse(json);
2062
+ return typeof value === "string" ? value : json;
2063
+ } catch {
2064
+ return json;
2065
+ }
2066
+ }
2067
+
2068
+ // packages/protocol/lib/persona.js
2069
+ var PERSONA_CAPABILITY = "persona";
2070
+ var PersonaStyle = external_exports.enum(["default", "concise", "patient", "lively", "buddy", "butler"]);
2071
+ var PeerStyle = external_exports.enum(["plain", "same"]);
2072
+ var Persona = external_exports.object({
2073
+ style: PersonaStyle,
2074
+ /** How it addresses the user ("主人", "指挥官"…). */
2075
+ callUser: external_exports.string().max(20).optional(),
2076
+ /** Anything else, in the user's words. */
2077
+ custom: external_exports.string().optional(),
2078
+ peerStyle: PeerStyle.optional()
2079
+ });
2080
+ var PersonaOverride = Persona.partial().extend({
2081
+ /** What the agent calls itself. */
2082
+ name: external_exports.string().max(20).optional()
2083
+ });
2084
+ var PersonaSettings = external_exports.object({
2085
+ persona: Persona,
2086
+ agents: external_exports.record(external_exports.string(), PersonaOverride)
2087
+ });
2088
+ var PersonaAnswer = PersonaSettings.extend({
2089
+ /** The text added to the system prompt with nothing of an agent's own, for the settings page to show. */
2090
+ prompt: external_exports.string(),
2091
+ /** The same, as it is for each agent, by id. */
2092
+ prompts: external_exports.record(external_exports.string(), external_exports.string())
2093
+ });
2094
+ var STYLE_TEXT = {
2095
+ default: "",
2096
+ concise: "\u56DE\u7B54\u7B80\u77ED\u76F4\u63A5\uFF1A\u5148\u7ED9\u7ED3\u8BBA\uFF0C\u518D\u7ED9\u5FC5\u8981\u7684\u7EC6\u8282\uFF1B\u5C11\u5BD2\u6684\uFF0C\u4E0D\u7528\u8868\u60C5\u3002",
2097
+ patient: "\u8010\u5FC3\u3001\u8BB2\u6E05\u695A\uFF1A\u6BCF\u4E00\u6B65\u8BF4\u660E\u4E3A\u4EC0\u4E48\u8FD9\u4E48\u505A\uFF0C\u7528\u5BF9\u65B9\u542C\u5F97\u61C2\u7684\u8BDD\uFF0C\u50CF\u6559\u4E00\u4E2A\u521A\u63A5\u89E6\u7684\u4EBA\u3002",
2098
+ lively: "\u8BED\u6C14\u8F7B\u677E\u6D3B\u6CFC\uFF0C\u53EF\u4EE5\u7528\u4E00\u70B9\u8BED\u6C14\u8BCD\u548C\u8868\u60C5\uFF0C\u4F46\u4FE1\u606F\u8981\u51C6\u786E\u3001\u4E0D\u5570\u55E6\u3002",
2099
+ buddy: "\u50CF\u4E00\u8D77\u73A9\u6E38\u620F\u7684\u8001\u670B\u53CB\u90A3\u6837\u8BF4\u8BDD\uFF1A\u719F\u6089\u6E38\u620F\u91CC\u7684\u8BF4\u6CD5\uFF0C\u53EF\u4EE5\u9002\u5F53\u5410\u69FD\u548C\u9F13\u52B1\uFF0C\u4F46\u4E0D\u5938\u5F20\u3001\u4E0D\u6CB9\u817B\u3002",
2100
+ butler: "\u50CF\u4E00\u4F4D\u7A33\u91CD\u5468\u5230\u7684\u7BA1\u5BB6\uFF1A\u793C\u8C8C\u3001\u6761\u7406\u6E05\u695A\uFF0C\u4E3B\u52A8\u6C47\u62A5\u8FDB\u5EA6\u548C\u9700\u8981\u5BF9\u65B9\u51B3\u5B9A\u7684\u4E8B\u3002"
2101
+ };
2102
+ function personaOf(settings, agentId) {
2103
+ const own = Object.entries(settings.agents[agentId] ?? {}).filter(([, value]) => value !== void 0);
2104
+ return { ...settings.persona, ...Object.fromEntries(own) };
2105
+ }
2106
+ function personaPrompt(p) {
2107
+ const lines = [];
2108
+ if (p.name !== void 0 && p.name.trim() !== "")
2109
+ lines.push(`\u4F60\u7684\u540D\u5B57\u662F\u300C${p.name.trim()}\u300D\uFF0C\u81EA\u79F0\u65F6\u7528\u8FD9\u4E2A\u540D\u5B57\u3002`);
2110
+ if (p.callUser !== void 0 && p.callUser.trim() !== "")
2111
+ lines.push(`\u79F0\u547C\u7528\u6237\u4E3A\u300C${p.callUser.trim()}\u300D\u3002`);
2112
+ if (STYLE_TEXT[p.style] !== "")
2113
+ lines.push(STYLE_TEXT[p.style]);
2114
+ if (p.custom !== void 0 && p.custom.trim() !== "")
2115
+ lines.push(`\u7528\u6237\u5BF9\u4F60\u8BF4\u8BDD\u65B9\u5F0F\u7684\u8981\u6C42\uFF1A${p.custom.trim()}`);
2116
+ if (lines.length === 0)
2117
+ return "";
2118
+ lines.push(p.peerStyle === "same" ? "\u548C\u5176\u4ED6 agent \u8BF4\u8BDD\u65F6\u4E5F\u7528\u8FD9\u4E2A\u65B9\u5F0F\u3002" : "\u4E0A\u9762\u662F\u5BF9\u7528\u6237\u8BF4\u8BDD\u7684\u65B9\u5F0F\u3002\u548C\u5176\u4ED6 agent \u8BF4\u8BDD\uFF08agent_delegate\u3001agent_message\u3001\u4EA4\u56DE\u53BB\u7684\u7ED3\u8BBA\uFF09\u7528\u5E73\u5B9E\u7684\u8BDD\uFF0C\u76F4\u63A5\u8BF4\u4E8B\uFF0C\u4E0D\u7528\u4EBA\u8BBE\u548C\u79F0\u547C\uFF1A\u5B83\u4EEC\u8981\u8BFB\u7684\u662F\u5185\u5BB9\u3002");
2119
+ lines.push(`\u8F6F\u4EF6\u7EA6\u5B9A\u7684\u56FA\u5B9A\u5199\u6CD5\uFF08\u6BD4\u5982\u300C${QUIET}\u300D\u8FD9\u4E00\u53E5\u3001\u7EBF\u7D22\u7F16\u53F7\u3001\u5DE5\u5177\u7684\u53C2\u6570\uFF09\u4E00\u5B57\u4E0D\u5DEE\u7167\u5199\uFF0C\u4E0D\u52A0\u8BED\u6C14\u8BCD\u548C\u8868\u60C5\u3002`);
2120
+ return ["# \u56DE\u590D\u98CE\u683C", ...lines, "\u8FD9\u4E9B\u53EA\u5F71\u54CD\u4F60\u8BF4\u8BDD\u7684\u65B9\u5F0F\uFF0C\u4E0D\u6539\u53D8\u505A\u4E8B\u7684\u89C4\u5219\uFF1A\u786E\u8BA4\u3001\u5B89\u5168\u9650\u5236\u548C\u4E0D\u80FD\u505A\u7684\u4E8B\u90FD\u7167\u65E7\uFF1B\u5728\u98DE\u4E66\u91CC\u56DE\u590D\u4E5F\u4E00\u6837\u3002"].join("\n");
2121
+ }
2122
+ var PersonaRequests = {
2123
+ "persona/get": {
2124
+ capability: PERSONA_CAPABILITY,
2125
+ params: external_exports.object({}),
2126
+ result: PersonaAnswer
2127
+ },
2128
+ "persona/set": {
2129
+ capability: PERSONA_CAPABILITY,
2130
+ params: PersonaSettings,
2131
+ result: PersonaAnswer
2132
+ }
2133
+ };
2134
+
2135
+ // packages/protocol/lib/compaction.js
2136
+ var COMPACTION_CAPABILITY = "compaction";
2137
+ var DEFAULT_COMPACTION_THRESHOLD = 80;
2138
+ var MIN_COMPACTION_THRESHOLD = 5;
2139
+ var MAX_COMPACTION_THRESHOLD = 100;
2140
+ var LOW_CONTEXT_WINDOW_MS = 12 * 60 * 6e4;
2141
+ var MIN_ARCHIVE_DAYS = 1;
2142
+ var MAX_ARCHIVE_DAYS = 365;
2143
+ var ARCHIVE_MARK = "\uFF08\u5DF2\u5F52\u6863\uFF09";
2144
+ var CompactionSettings = external_exports.object({
2145
+ /** Compact by itself when the conversation is long; off: a too-long conversation fails until compacted by hand. */
2146
+ auto: external_exports.boolean(),
2147
+ /** How full the context window gets before compacting, in percent. */
2148
+ threshold: external_exports.number().int().min(MIN_COMPACTION_THRESHOLD).max(MAX_COMPACTION_THRESHOLD),
2149
+ /** Low-context mode: keep only the last 12 hours and the summary in the context. */
2150
+ lowContext: external_exports.boolean(),
2151
+ /** With low-context mode: summaries of conversation older than this many days leave the context too; null: they stay. */
2152
+ archiveDays: external_exports.number().int().min(MIN_ARCHIVE_DAYS).max(MAX_ARCHIVE_DAYS).nullable().default(null),
2153
+ /**
2154
+ * Sub-agents call their tools from a program (dsh's ptc preset, run_code): only what the program returns or
2155
+ * prints enters their conversation, so polling a run or reading a long log costs a few lines, not every result
2156
+ * at every step. Off: they run the standard preset, one tool call per step. Read when the agent service starts.
2157
+ */
2158
+ ptcSubagents: external_exports.boolean().default(true)
2159
+ });
2160
+ var State = external_exports.object({ settings: CompactionSettings, applied: CompactionSettings });
2161
+ var CompactionRequests = {
2162
+ "compaction/get": {
2163
+ capability: COMPACTION_CAPABILITY,
2164
+ params: external_exports.object({}),
2165
+ result: State
2166
+ },
2167
+ "compaction/set": {
2168
+ capability: COMPACTION_CAPABILITY,
2169
+ params: external_exports.object({ settings: CompactionSettings }),
2170
+ result: State
2171
+ }
2172
+ };
2173
+
2174
+ // packages/protocol/lib/memory.js
2175
+ var MEMORY_CAPABILITY = "memory";
2176
+ var SHARED_MEMORY = "shared";
2177
+ var MemoryKind = external_exports.enum(["profile", "journal", "core"]);
2178
+ var MAX_CORE_CHARS = 2e3;
2179
+ var MemorySource = external_exports.object({
2180
+ /** The lead agent whose conversation it is (only that agent reads it back). */
2181
+ agent: external_exports.string(),
2182
+ sessionId: external_exports.string(),
2183
+ seq: external_exports.number().int().min(0)
2184
+ });
2185
+ var MAX_MEMORY_TEXT = 600;
2186
+ var MemoryEntry = external_exports.object({
2187
+ id: external_exports.string(),
2188
+ kind: MemoryKind,
2189
+ /** `shared`, or the id of the agent whose own it is. */
2190
+ scope: external_exports.string(),
2191
+ text: external_exports.string(),
2192
+ /** ISO time it was written, and last changed. */
2193
+ createdAt: external_exports.string(),
2194
+ updatedAt: external_exports.string(),
2195
+ /** Who wrote it: an agent id, `user` (设置 → 记忆), or `auto` (read back from a conversation). */
2196
+ by: external_exports.string(),
2197
+ /** Where it was learned; absent for what the user wrote on 设置 → 记忆, and for entries from before this was kept. */
2198
+ source: MemorySource.optional()
2199
+ });
2200
+ var MemoryAutoSettings = external_exports.object({
2201
+ auto: external_exports.boolean(),
2202
+ /** Same shape as ModelSelection (methods.ts), which imports this file. */
2203
+ model: external_exports.object({ provider: external_exports.string(), model: external_exports.string(), reasoningEffort: external_exports.string().optional() }).nullable()
2204
+ });
2205
+ var MemoryText = external_exports.string().trim().min(1).max(MAX_MEMORY_TEXT);
2206
+ var MemoryRequests = {
2207
+ "memory/list": {
2208
+ capability: MEMORY_CAPABILITY,
2209
+ params: external_exports.object({}),
2210
+ /** Newest first. */
2211
+ result: external_exports.object({ items: external_exports.array(MemoryEntry) })
2212
+ },
2213
+ "memory/add": {
2214
+ capability: MEMORY_CAPABILITY,
2215
+ params: external_exports.object({ kind: MemoryKind, scope: external_exports.string().min(1).max(64), text: MemoryText }),
2216
+ result: external_exports.object({ item: MemoryEntry })
2217
+ },
2218
+ "memory/update": {
2219
+ capability: MEMORY_CAPABILITY,
2220
+ params: external_exports.object({ id: external_exports.string(), text: MemoryText, kind: MemoryKind.optional(), scope: external_exports.string().min(1).max(64).optional() }),
2221
+ result: external_exports.object({ item: MemoryEntry })
2222
+ },
2223
+ "memory/auto/get": {
2224
+ capability: MEMORY_CAPABILITY,
2225
+ params: external_exports.object({}),
2226
+ /** `forced`: on whatever `auto` says, because low-context mode is on (compaction.ts). */
2227
+ result: MemoryAutoSettings.extend({ forced: external_exports.boolean().optional() })
2228
+ },
2229
+ "memory/auto/set": {
2230
+ capability: MEMORY_CAPABILITY,
2231
+ params: MemoryAutoSettings,
2232
+ result: MemoryAutoSettings
2233
+ },
2234
+ "memory/remove": {
2235
+ capability: MEMORY_CAPABILITY,
2236
+ params: external_exports.object({ id: external_exports.string() }),
2237
+ result: external_exports.object({ removed: external_exports.boolean() })
2238
+ }
2239
+ };
2240
+ var MemoryNotifications = {
2241
+ /** An entry was written, changed or forgotten; re-read `memory/list`. */
2242
+ "memory/changed": external_exports.object({})
2243
+ };
2244
+
2245
+ // packages/protocol/lib/runs.js
2246
+ var RUNS_CAPABILITY = "runs";
2247
+ var RunState = external_exports.enum(["starting", "running", "stopping", "succeeded", "failed", "cancelled"]);
2248
+ var TaskParamInfo = external_exports.object({
2249
+ type: external_exports.enum(["string", "integer", "number", "boolean"]),
2250
+ default: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional(),
2251
+ enum: external_exports.array(external_exports.union([external_exports.string(), external_exports.number()])).optional(),
2252
+ description: external_exports.string().optional(),
2253
+ /** Values read from the script's local config (e.g. MXU instances). */
2254
+ choices: external_exports.array(external_exports.object({ value: external_exports.string(), label: external_exports.string(), detail: external_exports.string().optional() })).optional(),
2255
+ /** A new choice can be made with `runs/choices/create`. */
2256
+ canCreate: external_exports.boolean().optional()
2257
+ });
2258
+ var LaunchSettings = external_exports.object({
2259
+ /** `auto`: only when the script will not and the game is not running; `platform`: always unless running; `off`: never. */
2260
+ mode: external_exports.enum(["auto", "platform", "off"]),
2261
+ /** PC launch implementation; MaaEnd uses its standalone LaunchGamePC pretask. */
2262
+ pcLaunch: external_exports.enum(["program", "maaend"]).optional(),
2263
+ /** MaaEnd launcher region; defaults to CN. */
2264
+ pcRegion: external_exports.enum(["CN", "Global", "Bilibili", "TapTap", "Steam", "Epic"]).optional(),
2265
+ /** PC game program, or the official Launcher.exe for MaaEnd. */
2266
+ pcExe: external_exports.string().optional(),
2267
+ /** Its process name, when it differs from the program's file name. */
2268
+ pcProcess: external_exports.string().optional(),
2269
+ /** Android package started in the emulator (for emulator tasks). */
2270
+ androidPackage: external_exports.string().optional()
2271
+ });
2272
+ var LaunchView = external_exports.object({
2273
+ settings: LaunchSettings,
2274
+ /** What the script pack says. */
2275
+ game: external_exports.object({
2276
+ name: external_exports.string().optional(),
2277
+ androidPackage: external_exports.string().optional(),
2278
+ pcProcess: external_exports.string().optional(),
2279
+ /** How the script starts the game itself, for people. */
2280
+ selfLaunch: external_exports.string()
2281
+ }),
2282
+ /** The script has tasks that use the emulator / the desktop. */
2283
+ uses: external_exports.object({ adb: external_exports.boolean(), desktop: external_exports.boolean() })
2284
+ });
2285
+ var TaskInfo = external_exports.object({
2286
+ id: external_exports.string(),
2287
+ title: external_exports.string(),
2288
+ description: external_exports.string().optional(),
2289
+ utterances: external_exports.array(external_exports.string()),
2290
+ params: external_exports.record(external_exports.string(), TaskParamInfo),
2291
+ /** What the task occupies: `desktop` takes the mouse and keyboard; `adb` an emulator. */
2292
+ input: external_exports.enum(["desktop", "window", "adb", "none"]),
2293
+ account: external_exports.string().optional(),
2294
+ expectedDuration: external_exports.string().optional()
2295
+ });
2296
+ var ProfileRef = external_exports.string().trim().min(1).max(64);
2297
+ var ProfileEntry = external_exports.object({ id: external_exports.string(), name: external_exports.string(), createdAt: external_exports.number().optional() });
2298
+ var ProfileList = external_exports.object({
2299
+ /** What runs use when they name no profile. */
2300
+ current: external_exports.string(),
2301
+ items: external_exports.array(ProfileEntry)
2302
+ });
2303
+ var RunInfo = external_exports.object({
2304
+ id: external_exports.string(),
2305
+ scriptId: external_exports.string(),
2306
+ scriptName: external_exports.string(),
2307
+ taskId: external_exports.string(),
2308
+ taskTitle: external_exports.string(),
2309
+ params: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])),
2310
+ state: RunState,
2311
+ /** Why it ended the way it did, for people. */
2312
+ outcome: external_exports.string().optional(),
2313
+ startedAt: external_exports.number(),
2314
+ endedAt: external_exports.number().optional(),
2315
+ exitCode: external_exports.number().optional(),
2316
+ /** Program and arguments as started. */
2317
+ command: external_exports.array(external_exports.string()),
2318
+ /** Locks held while running, e.g. `desktop`, `adb:127.0.0.1:16384`, `account:main`. */
2319
+ resources: external_exports.array(external_exports.string()),
2320
+ /** Tags of the log rules that matched. */
2321
+ tags: external_exports.array(external_exports.string()),
2322
+ warnings: external_exports.array(external_exports.string()),
2323
+ /** A task run, or a settings session (the script's own window opened to change the local config). */
2324
+ kind: external_exports.enum(["task", "settings"]),
2325
+ /** This run restarts that one (L0 recovery or the user's retry). */
2326
+ retryOf: external_exports.string().optional(),
2327
+ /**
2328
+ * Stopped on purpose (the user, a pipeline being stopped, the agent), not
2329
+ * restarted: nothing runs it again by itself, and its incidents are closed.
2330
+ */
2331
+ halted: external_exports.boolean().optional(),
2332
+ /** The config profile it ran with (absent in runs from before profiles). */
2333
+ profile: external_exports.string().optional(),
2334
+ profileName: external_exports.string().optional()
2335
+ });
2336
+ var RunLogLine = external_exports.object({
2337
+ at: external_exports.number(),
2338
+ /** `stdout`, `stderr`, or the log file's relative path. */
2339
+ source: external_exports.string(),
2340
+ text: external_exports.string(),
2341
+ /** Level of the log rule that matched this line, if any. */
2342
+ level: external_exports.enum(["info", "progress", "done", "warning", "error"]).optional(),
2343
+ /** Tag of that rule (its level when it has none). */
2344
+ tag: external_exports.string().optional()
2345
+ });
2346
+ var RunRequests = {
2347
+ /** Tasks a library script can run, from its Script Pack. */
2348
+ "runs/tasks": {
2349
+ capability: RUNS_CAPABILITY,
2350
+ /** `profile`: read parameter choices from that config profile (default: the current one). */
2351
+ params: external_exports.object({ scriptId: ScriptId, profile: ProfileRef.optional() }),
2352
+ result: external_exports.object({ tasks: external_exports.array(TaskInfo), runnable: external_exports.boolean(), problem: external_exports.string().optional() })
2353
+ },
2354
+ "runs/start": {
2355
+ capability: RUNS_CAPABILITY,
2356
+ params: external_exports.object({
2357
+ scriptId: ScriptId,
2358
+ taskId: external_exports.string().min(1).max(64),
2359
+ params: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])).optional(),
2360
+ /** Config profile (id or name); default: the script's current one. */
2361
+ profile: ProfileRef.optional()
2362
+ }),
2363
+ result: RunInfo
2364
+ },
2365
+ "runs/stop": {
2366
+ capability: RUNS_CAPABILITY,
2367
+ params: external_exports.object({ runId: external_exports.string() }),
2368
+ result: external_exports.object({})
2369
+ },
2370
+ /** Recent runs, newest first. */
2371
+ "runs/list": {
2372
+ capability: RUNS_CAPABILITY,
2373
+ params: external_exports.object({ scriptId: ScriptId.optional() }),
2374
+ result: external_exports.object({ items: external_exports.array(RunInfo) })
2375
+ },
2376
+ /** The last lines of a run's log. */
2377
+ "runs/logs": {
2378
+ capability: RUNS_CAPABILITY,
2379
+ params: external_exports.object({ runId: external_exports.string(), limit: external_exports.number().int().min(1).max(2e3).optional() }),
2380
+ result: external_exports.object({ lines: external_exports.array(RunLogLine) })
2381
+ },
2382
+ /** The script's local config copy and whether the original changed since it was imported. */
2383
+ /** A script's config profiles and which one runs use when they name none. */
2384
+ "configs/profiles": {
2385
+ capability: RUNS_CAPABILITY,
2386
+ params: external_exports.object({ scriptId: ScriptId }),
2387
+ result: ProfileList
2388
+ },
2389
+ /** Save a new profile: a copy of one, the original project's current config, or config files from another folder. */
2390
+ "configs/profiles/create": {
2391
+ capability: RUNS_CAPABILITY,
2392
+ params: external_exports.object({
2393
+ scriptId: ScriptId,
2394
+ name: external_exports.string().trim().min(1).max(30),
2395
+ from: external_exports.discriminatedUnion("kind", [
2396
+ external_exports.object({ kind: external_exports.literal("copy"), profile: ProfileRef }),
2397
+ external_exports.object({ kind: external_exports.literal("original") }),
2398
+ external_exports.object({ kind: external_exports.literal("folder"), dir: external_exports.string().trim().min(1).max(500) })
2399
+ ])
2400
+ }),
2401
+ result: external_exports.object({ profile: ProfileEntry, files: external_exports.array(external_exports.string()), list: ProfileList })
2402
+ },
2403
+ "configs/profiles/update": {
2404
+ capability: RUNS_CAPABILITY,
2405
+ params: external_exports.object({ scriptId: ScriptId, profile: ProfileRef, name: external_exports.string().trim().min(1).max(30).optional(), current: external_exports.literal(true).optional() }),
2406
+ result: ProfileList
2407
+ },
2408
+ "configs/profiles/remove": {
2409
+ capability: RUNS_CAPABILITY,
2410
+ params: external_exports.object({ scriptId: ScriptId, profile: ProfileRef }),
2411
+ result: ProfileList
2412
+ },
2413
+ "configs/status": {
2414
+ capability: RUNS_CAPABILITY,
2415
+ params: external_exports.object({ scriptId: ScriptId, profile: ProfileRef.optional() }),
2416
+ result: external_exports.object({
2417
+ importedAt: external_exports.number().optional(),
2418
+ /** Where the local copy lives. */
2419
+ dir: external_exports.string(),
2420
+ /** The profile this is. */
2421
+ profile: ProfileEntry,
2422
+ files: external_exports.array(external_exports.object({ file: external_exports.string(), local: external_exports.boolean(), original: external_exports.boolean(), changed: external_exports.boolean() })),
2423
+ drift: external_exports.array(external_exports.string())
2424
+ })
2425
+ },
2426
+ /** One declared config file of the local copy, as text (to look at). */
2427
+ "configs/read": {
2428
+ capability: RUNS_CAPABILITY,
2429
+ params: external_exports.object({ scriptId: ScriptId, file: external_exports.string().min(1), profile: ProfileRef.optional() }),
2430
+ result: external_exports.object({ file: external_exports.string(), content: external_exports.string(), truncated: external_exports.boolean() })
2431
+ },
2432
+ /** Replace the local copy with the original project's current config (the user's call). */
2433
+ "configs/import": {
2434
+ capability: RUNS_CAPABILITY,
2435
+ params: external_exports.object({ scriptId: ScriptId, profile: ProfileRef.optional() }),
2436
+ result: external_exports.object({ imported: external_exports.array(external_exports.string()) })
2437
+ },
2438
+ /** Open the script's own settings window on the local copy; saved back when the user closes it. */
2439
+ "configs/open": {
2440
+ capability: RUNS_CAPABILITY,
2441
+ params: external_exports.object({ scriptId: ScriptId, profile: ProfileRef.optional() }),
2442
+ result: RunInfo
2443
+ },
2444
+ /**
2445
+ * Done changing settings in the script's window opened by `configs/open`
2446
+ * (「我已手动改好」): the window closes and what the script wrote is saved
2447
+ * to the local copy. Stopping the run instead (`runs/stop`) discards it.
2448
+ */
2449
+ "configs/done": {
2450
+ capability: RUNS_CAPABILITY,
2451
+ params: external_exports.object({ runId: external_exports.string() }),
2452
+ result: external_exports.object({})
2453
+ },
2454
+ /** Make a new choice for a parameter (e.g. an MXU instance copied from an existing one) in the local config. */
2455
+ "runs/choices/create": {
2456
+ capability: RUNS_CAPABILITY,
2457
+ params: external_exports.object({ scriptId: ScriptId, taskId: external_exports.string().min(1), param: external_exports.string().min(1), name: external_exports.string().trim().min(1).max(40), profile: ProfileRef.optional() }),
2458
+ result: external_exports.object({ value: external_exports.string() })
2459
+ },
2460
+ "configs/launch": {
2461
+ capability: RUNS_CAPABILITY,
2462
+ params: external_exports.object({ scriptId: ScriptId }),
2463
+ result: LaunchView
2464
+ },
2465
+ "configs/launch/set": {
2466
+ capability: RUNS_CAPABILITY,
2467
+ params: external_exports.object({
2468
+ scriptId: ScriptId,
2469
+ mode: external_exports.enum(["auto", "platform", "off"]).optional(),
2470
+ pcLaunch: external_exports.enum(["program", "maaend"]).nullable().optional(),
2471
+ pcRegion: external_exports.enum(["CN", "Global", "Bilibili", "TapTap", "Steam", "Epic"]).nullable().optional(),
2472
+ pcExe: external_exports.string().trim().nullable().optional(),
2473
+ pcProcess: external_exports.string().trim().nullable().optional(),
2474
+ androidPackage: external_exports.string().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/, "\u5B89\u5353\u5305\u540D\u50CF com.example.game").nullable().optional()
2475
+ }),
2476
+ result: LaunchView
2477
+ },
2478
+ /** Look for the PC game's program (running process, installed programs, shortcuts, the usual folders). */
2479
+ "configs/launch/locate": {
2480
+ capability: RUNS_CAPABILITY,
2481
+ params: external_exports.object({ scriptId: ScriptId }),
2482
+ result: external_exports.object({
2483
+ /** The program looked for, e.g. Endfield.exe; absent when the pack does not name one. */
2484
+ exe: external_exports.string().optional(),
2485
+ candidates: external_exports.array(external_exports.object({ path: external_exports.string(), source: external_exports.string() }))
2486
+ })
2487
+ }
2488
+ };
2489
+ var RunNotifications = {
2490
+ "runs/state": RunInfo,
2491
+ /** A script's config profiles changed (saved, renamed, removed, another made current). */
2492
+ "configs/profiles/changed": external_exports.object({ scriptId: external_exports.string(), list: ProfileList }),
2493
+ "runs/log": external_exports.object({ runId: external_exports.string(), lines: external_exports.array(RunLogLine) })
2494
+ };
2495
+
2496
+ // packages/protocol/lib/events.js
2497
+ var ContentPart = external_exports.discriminatedUnion("type", [
2498
+ external_exports.object({ type: external_exports.literal("text"), text: external_exports.string() }),
2499
+ external_exports.object({ type: external_exports.literal("reasoning"), text: external_exports.string() }),
2500
+ external_exports.object({
2501
+ type: external_exports.literal("image"),
2502
+ name: external_exports.string().optional(),
2503
+ mediaType: external_exports.string().optional(),
2504
+ width: external_exports.number().optional(),
2505
+ height: external_exports.number().optional(),
2506
+ /** Stored image (with `bytes`): fetch it with `attachments/image`. */
2507
+ attachmentId: external_exports.string().optional(),
2508
+ bytes: external_exports.number().optional()
2509
+ }),
2510
+ external_exports.object({
2511
+ type: external_exports.literal("file"),
2512
+ name: external_exports.string().optional(),
2513
+ size: external_exports.number().optional(),
2514
+ mediaType: external_exports.string().optional()
2515
+ }),
2516
+ external_exports.object({
2517
+ type: external_exports.literal("tool-call"),
2518
+ callId: external_exports.string(),
2519
+ name: external_exports.string(),
2520
+ arguments: external_exports.string()
2521
+ }),
2522
+ /** A block kind the gateway does not translate (tool additions, future kinds). */
2523
+ external_exports.object({ type: external_exports.literal("other"), kind: external_exports.string() })
2524
+ ]);
2525
+ var TokenUsage = external_exports.object({
2526
+ inputTokens: external_exports.number(),
2527
+ outputTokens: external_exports.number(),
2528
+ totalTokens: external_exports.number().optional(),
2529
+ cacheReadTokens: external_exports.number().optional(),
2530
+ cacheWriteTokens: external_exports.number().optional(),
2531
+ reasoningTokens: external_exports.number().optional()
2532
+ });
2533
+ var StreamTiming = external_exports.object({
2534
+ /** First chunk of any kind. */
2535
+ firstChunkAt: external_exports.number().optional(),
2536
+ /** First chunk carrying an output token (text, reasoning, or tool-call fragment). */
2537
+ firstTokenAt: external_exports.number().optional(),
2538
+ /** Last chunk of any kind. */
2539
+ lastChunkAt: external_exports.number().optional(),
2540
+ /** Number of token-bearing chunks. */
2541
+ tokenChunks: external_exports.number()
2542
+ });
2543
+ var Failure = external_exports.object({
2544
+ message: external_exports.string(),
2545
+ code: external_exports.string().optional()
2546
+ });
2547
+ var TurnEndReason = external_exports.object({
2548
+ kind: external_exports.string(),
2549
+ message: external_exports.string().optional()
2550
+ });
2551
+ var MessageOrigin = external_exports.object({
2552
+ /** Upstream source kind: `user`, `user-rpc`, injected-context producers, goal rounds, ... */
2553
+ kind: external_exports.string(),
2554
+ /** True for a direct human prompt; false for injected context. */
2555
+ human: external_exports.boolean(),
2556
+ /** One-line account for `notice`-form injected context. */
2557
+ summary: external_exports.string().optional()
2558
+ });
2559
+ var base = { seq: external_exports.number(), time: external_exports.number() };
2560
+ var SessionEvent = external_exports.discriminatedUnion("type", [
2561
+ external_exports.object({ ...base, type: external_exports.literal("turn/start"), turn: external_exports.number() }),
2562
+ external_exports.object({ ...base, type: external_exports.literal("turn/end"), turn: external_exports.number(), reason: TurnEndReason }),
2563
+ external_exports.object({ ...base, type: external_exports.literal("step/start"), turn: external_exports.number(), step: external_exports.number() }),
2564
+ external_exports.object({ ...base, type: external_exports.literal("step/end"), turn: external_exports.number(), step: external_exports.number() }),
2565
+ external_exports.object({
2566
+ ...base,
2567
+ type: external_exports.literal("user/message"),
2568
+ messageId: external_exports.string(),
2569
+ content: external_exports.array(ContentPart),
2570
+ origin: MessageOrigin,
2571
+ /** Client correlation id when the prompt came through a request id. */
2572
+ requestId: external_exports.string().optional(),
2573
+ /** True when this message replaced earlier history (compaction summary). */
2574
+ replacesHistory: external_exports.boolean().optional()
2575
+ }),
2576
+ external_exports.object({
2577
+ ...base,
2578
+ type: external_exports.literal("system/message"),
2579
+ turn: external_exports.number(),
2580
+ step: external_exports.number(),
2581
+ text: external_exports.string()
2582
+ }),
2583
+ external_exports.object({
2584
+ ...base,
2585
+ type: external_exports.literal("assistant/message"),
2586
+ turn: external_exports.number(),
2587
+ step: external_exports.number(),
2588
+ messageId: external_exports.string(),
2589
+ content: external_exports.array(ContentPart),
2590
+ timing: StreamTiming,
2591
+ usage: TokenUsage.optional(),
2592
+ interrupted: external_exports.boolean().optional(),
2593
+ provider: external_exports.string().optional(),
2594
+ model: external_exports.string().optional()
2595
+ }),
2596
+ external_exports.object({
2597
+ ...base,
2598
+ type: external_exports.literal("assistant/attempt"),
2599
+ turn: external_exports.number(),
2600
+ step: external_exports.number(),
2601
+ timing: StreamTiming,
2602
+ error: Failure.optional()
2603
+ }),
2604
+ external_exports.object({
2605
+ ...base,
2606
+ type: external_exports.literal("tool/call"),
2607
+ turn: external_exports.number(),
2608
+ step: external_exports.number(),
2609
+ callId: external_exports.string(),
2610
+ name: external_exports.string(),
2611
+ arguments: external_exports.string()
2612
+ }),
2613
+ external_exports.object({
2614
+ ...base,
2615
+ type: external_exports.literal("tool/result"),
2616
+ turn: external_exports.number(),
2617
+ step: external_exports.number(),
2618
+ callId: external_exports.string(),
2619
+ isError: external_exports.boolean(),
2620
+ content: external_exports.array(ContentPart),
2621
+ error: Failure.optional()
2622
+ }),
2623
+ external_exports.object({
2624
+ ...base,
2625
+ type: external_exports.literal("request/header"),
2626
+ provider: external_exports.string().optional(),
2627
+ model: external_exports.string().optional(),
2628
+ reasoningEffort: external_exports.string().optional(),
2629
+ toolNames: external_exports.array(external_exports.string()),
2630
+ reason: external_exports.string()
2631
+ }),
2632
+ external_exports.object({
2633
+ ...base,
2634
+ type: external_exports.literal("compaction/start"),
2635
+ compactionId: external_exports.string(),
2636
+ turn: external_exports.number().nullable()
2637
+ }),
2638
+ external_exports.object({
2639
+ ...base,
2640
+ type: external_exports.literal("compaction/summary"),
2641
+ compactionId: external_exports.string(),
2642
+ shadowedTokenCount: external_exports.number(),
2643
+ provider: external_exports.string().optional(),
2644
+ model: external_exports.string().optional(),
2645
+ usage: TokenUsage.optional()
2646
+ }),
2647
+ external_exports.object({
2648
+ ...base,
2649
+ type: external_exports.literal("compaction/end"),
2650
+ compactionId: external_exports.string(),
2651
+ turn: external_exports.number().nullable(),
2652
+ error: external_exports.string().optional()
2653
+ }),
2654
+ external_exports.object({
2655
+ ...base,
2656
+ type: external_exports.literal("approval/asked"),
2657
+ approvalId: external_exports.string(),
2658
+ toolName: external_exports.string(),
2659
+ callId: external_exports.string().optional(),
2660
+ reason: external_exports.string().optional()
2661
+ }),
2662
+ external_exports.object({
2663
+ ...base,
2664
+ type: external_exports.literal("approval/decided"),
2665
+ approvalId: external_exports.string(),
2666
+ outcome: external_exports.string()
2667
+ }),
2668
+ external_exports.object({ ...base, type: external_exports.literal("session/title"), title: external_exports.string() }),
2669
+ /** Any upstream event the gateway does not translate. */
2670
+ external_exports.object({
2671
+ ...base,
2672
+ type: external_exports.literal("unknown"),
2673
+ upstreamType: external_exports.string(),
2674
+ data: external_exports.unknown()
2675
+ })
2676
+ ]);
2677
+ var LiveFrame = external_exports.discriminatedUnion("type", [
2678
+ external_exports.object({
2679
+ type: external_exports.literal("start"),
2680
+ attemptId: external_exports.string(),
2681
+ turn: external_exports.number(),
2682
+ step: external_exports.number(),
2683
+ /** Last durable seq observed when the attempt started. */
2684
+ afterSeq: external_exports.number()
2685
+ }),
2686
+ external_exports.object({
2687
+ type: external_exports.literal("delta"),
2688
+ attemptId: external_exports.string(),
2689
+ time: external_exports.number(),
2690
+ kind: external_exports.enum(["text", "reasoning", "tool-args"]),
2691
+ /** Content block position inside the assistant message. */
2692
+ index: external_exports.number(),
2693
+ text: external_exports.string(),
2694
+ callId: external_exports.string().optional(),
2695
+ toolName: external_exports.string().optional()
2696
+ }),
2697
+ external_exports.object({
2698
+ type: external_exports.literal("end"),
2699
+ attemptId: external_exports.string(),
2700
+ outcome: external_exports.enum(["committed", "abandoned"]),
2701
+ seq: external_exports.number().optional()
2702
+ })
2703
+ ]);
2704
+ var LiveAttempt = external_exports.object({
2705
+ attemptId: external_exports.string(),
2706
+ turn: external_exports.number(),
2707
+ step: external_exports.number(),
2708
+ afterSeq: external_exports.number(),
2709
+ deltas: external_exports.array(LiveFrame.options[1])
2710
+ });
2711
+
2712
+ // packages/protocol/lib/skillhub.js
2713
+ var SKILLHUB_CAPABILITY = "skillhub";
2714
+ var HubRepo = external_exports.object({ repo: GitHubRepo, branch: external_exports.string().trim().min(1).max(100).regex(/^[\w./-]+$/) });
2715
+ var HubItem = external_exports.object({
2716
+ name: external_exports.string(),
2717
+ description: external_exports.string(),
2718
+ title: external_exports.string().optional(),
2719
+ kind: external_exports.enum(["game", "script", "general"]),
2720
+ /** Game ids and script / pack ids it is for: the page suggests it for the ones the user has. */
2721
+ games: external_exports.array(external_exports.string()),
2722
+ scripts: external_exports.array(external_exports.string()),
2723
+ repo: external_exports.string(),
2724
+ path: external_exports.string(),
2725
+ hash: external_exports.string(),
2726
+ installed: external_exports.object({
2727
+ at: external_exports.number(),
2728
+ /** The repository has a newer version. */
2729
+ update: external_exports.boolean()
2730
+ }).optional(),
2731
+ /** Why it cannot be downloaded (a core or the user's own skill has the name). */
2732
+ blocked: external_exports.string().optional()
2733
+ });
2734
+ var ByName = external_exports.object({ name: external_exports.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/) });
2735
+ var SkillHubRequests = {
2736
+ /** What the repositories have and how each stands here; `refresh` reads them now (otherwise at most daily). */
2737
+ "skillhub/list": {
2738
+ capability: SKILLHUB_CAPABILITY,
2739
+ params: external_exports.object({ refresh: external_exports.boolean().optional() }),
2740
+ result: external_exports.object({ items: external_exports.array(HubItem), repos: external_exports.array(HubRepo), errors: external_exports.array(external_exports.string()), fetchedAt: external_exports.number().optional() })
2741
+ },
2742
+ "skillhub/install": {
2743
+ capability: SKILLHUB_CAPABILITY,
2744
+ params: ByName.extend({ repo: GitHubRepo.optional() }),
2745
+ result: HubItem
2746
+ },
2747
+ /** Take the newer version in place of the downloaded one, changed here or not. */
2748
+ "skillhub/update": {
2749
+ capability: SKILLHUB_CAPABILITY,
2750
+ params: ByName,
2751
+ result: external_exports.object({ state: external_exports.enum(["current", "updated"]), item: HubItem })
2752
+ },
2753
+ "skillhub/remove": {
2754
+ capability: SKILLHUB_CAPABILITY,
2755
+ params: ByName,
2756
+ result: external_exports.object({})
2757
+ },
2758
+ /**
2759
+ * Put a downloaded skill under other games and scripts than the repository
2760
+ * says (it was picked for the wrong one); empty lists make it general, `null`
2761
+ * goes back to the repository's. Kept across its updates.
2762
+ */
2763
+ "skillhub/owner": {
2764
+ capability: SKILLHUB_CAPABILITY,
2765
+ params: ByName.extend({ owner: SkillOwner.nullable() }),
2766
+ result: external_exports.object({})
2767
+ },
2768
+ /** Which repositories to read, in order (the first with a name wins). */
2769
+ "skillhub/repos/set": {
2770
+ capability: SKILLHUB_CAPABILITY,
2771
+ params: external_exports.object({ repos: external_exports.array(HubRepo).min(1).max(10) }),
2772
+ result: external_exports.object({ repos: external_exports.array(HubRepo) })
2773
+ }
2774
+ };
2775
+ var SkillHubNotifications = {
2776
+ /** A downloaded skill or the list changed; read `skillhub/list` again. */
2777
+ "skillhub/changed": external_exports.object({})
2778
+ };
2779
+
2780
+ // packages/protocol/lib/methods.js
2781
+ var CredentialRef = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/, "credential names use letters, digits and underscores");
2782
+ var CredentialInfo = external_exports.object({
2783
+ configured: external_exports.boolean(),
2784
+ /** Layer supplying the value, e.g. the launch environment or the stored file. */
2785
+ source: external_exports.string().optional(),
2786
+ /** False when a read-only layer (the launch environment) shadows the reference. */
2787
+ writable: external_exports.boolean()
2788
+ });
2789
+ var DEEPSEEK_API_KEY = "DEEPSEEK_API_KEY";
2790
+ var Capability = external_exports.object({
2791
+ id: external_exports.string(),
2792
+ version: external_exports.number().int().positive()
2793
+ });
2794
+ var SessionItem = external_exports.object({
2795
+ id: external_exports.string(),
2796
+ title: external_exports.string().nullable(),
2797
+ updatedAt: external_exports.number(),
2798
+ running: external_exports.boolean(),
2799
+ /** True when the session has no turn yet. */
2800
+ blank: external_exports.boolean(),
2801
+ /** Whether a live agent currently owns the session. */
2802
+ live: external_exports.boolean(),
2803
+ cwd: external_exports.string().optional(),
2804
+ parentId: external_exports.string().optional(),
2805
+ origin: external_exports.enum(["subagent"]).optional(),
2806
+ /** The role agent the session belongs to (`roles/list`); absent: the main agent's (the person's own chats, chat channels). */
2807
+ role: external_exports.string().optional(),
2808
+ /** Who asked for a role agent's work, in words: 监控, 定时, 你, 流水线「…」. */
2809
+ requestedBy: external_exports.string().optional(),
2810
+ /** The agent whose one conversation this is (`main` for 助手, else its role id); absent: an earlier conversation. */
2811
+ home: external_exports.string().optional()
2812
+ });
2813
+ var Role = external_exports.object({
2814
+ id: external_exports.string(),
2815
+ /** Its name in the session list, e.g. 干预. */
2816
+ name: external_exports.string(),
2817
+ /** What it does, in a sentence. */
2818
+ description: external_exports.string(),
2819
+ /** Position in the list (smaller first). */
2820
+ order: external_exports.number()
2821
+ });
2822
+ var QueuedPrompt = external_exports.object({
2823
+ /** Queue item id (for `session/queue/update`). */
2824
+ id: external_exports.string(),
2825
+ /** The `requestId` it was sent with, when it came from a client. */
2826
+ requestId: external_exports.string().optional(),
2827
+ text: external_exports.string(),
2828
+ images: external_exports.number().int().optional(),
2829
+ placement: external_exports.enum(["next-turn", "next-step"])
2830
+ });
2831
+ var SessionContext = external_exports.object({
2832
+ contextWindow: external_exports.number().int().positive(),
2833
+ usedTokens: external_exports.number().int().nonnegative(),
2834
+ breakdown: external_exports.object({
2835
+ systemTokens: external_exports.number().int().nonnegative(),
2836
+ toolsTokens: external_exports.number().int().nonnegative(),
2837
+ messageTokens: external_exports.number().int().nonnegative()
2838
+ }).optional()
2839
+ });
2840
+ var SessionHeader = external_exports.object({
2841
+ id: external_exports.string(),
2842
+ createdAt: external_exports.number(),
2843
+ cwd: external_exports.string().optional(),
2844
+ parentId: external_exports.string().optional(),
2845
+ agentPreset: external_exports.string().optional()
2846
+ });
2847
+ var ModelSelection = external_exports.object({
2848
+ provider: external_exports.string(),
2849
+ model: external_exports.string(),
2850
+ reasoningEffort: external_exports.string().optional()
2851
+ });
2852
+ var AgentModels = external_exports.object({
2853
+ /** Role agents' own models, by agent id. */
2854
+ agents: external_exports.record(external_exports.string(), ModelSelection),
2855
+ /** Every agent's sub-agents. */
2856
+ subAgents: ModelSelection.nullable(),
2857
+ /** One agent's sub-agents, by agent id (`main`: 助手's). */
2858
+ subAgentsOf: external_exports.record(external_exports.string(), ModelSelection)
2859
+ });
2860
+ var AGENTS_CAPABILITY = "agents";
2861
+ var ThreadMessage = external_exports.object({
2862
+ /** Who said it, by name. */
2863
+ from: external_exports.string(),
2864
+ /** `question` waits for an answer; `update` only informs, and reaches the other side at once; `done` is the conclusion. */
2865
+ kind: external_exports.enum(["question", "answer", "update", "done"]),
2866
+ text: external_exports.string(),
2867
+ at: external_exports.number()
2868
+ });
2869
+ var HandOff = external_exports.object({
2870
+ id: external_exports.string(),
2871
+ /** What the two have said since the work was handed over (docs/design/agent-roles.md §14.3). */
2872
+ messages: external_exports.array(ThreadMessage).optional(),
2873
+ /** The agents the work has passed through, first asker first (ids); a chain does not come back on itself. */
2874
+ chain: external_exports.array(external_exports.string()).optional(),
2875
+ /** The hand-off this one was opened from inside of. */
2876
+ parent: external_exports.string().optional(),
2877
+ /** The conversation that asked, where the reply goes back. */
2878
+ fromSession: external_exports.string(),
2879
+ /** 助手's `agent_delegate` call that asked; absent: the app asked (`by`). */
2880
+ callId: external_exports.string().optional(),
2881
+ /** Who asked, in words: 助手, 监控. */
2882
+ by: external_exports.string(),
2883
+ /** The agent it went to (role id) and its conversation. */
2884
+ to: external_exports.string(),
2885
+ toSession: external_exports.string(),
2886
+ title: external_exports.string(),
2887
+ task: external_exports.string(),
2888
+ expecting: external_exports.string().optional(),
2889
+ /** `waiting`: the agent doing it asked something and waits for the answer. */
2890
+ state: external_exports.enum(["running", "waiting", "done", "failed"]),
2891
+ /** Its reply; for a failure, why. */
2892
+ reply: external_exports.string().optional(),
2893
+ startedAt: external_exports.number(),
2894
+ endedAt: external_exports.number().optional()
2895
+ });
2896
+ var AgentReminder = external_exports.object({
2897
+ id: external_exports.string(),
2898
+ /** The agent whose conversation it is in (role id; `main`: 助手). */
2899
+ agent: external_exports.string(),
2900
+ sessionId: external_exports.string(),
2901
+ title: external_exports.string(),
2902
+ /** What the agent is to do when it comes. */
2903
+ prompt: external_exports.string(),
2904
+ /** When, in words: 一次 / 每天 09:00 / 每周一、三 09:00 / 每 2 小时 / cron …. */
2905
+ rule: external_exports.string(),
2906
+ repeats: external_exports.boolean(),
2907
+ /** Next time it comes (epoch ms). */
2908
+ next: external_exports.number()
2909
+ });
2910
+ var ModelCatalog = external_exports.object({
2911
+ default: ModelSelection,
2912
+ groups: external_exports.array(external_exports.object({
2913
+ id: external_exports.string(),
2914
+ name: external_exports.string(),
2915
+ models: external_exports.array(external_exports.object({
2916
+ id: external_exports.string(),
2917
+ name: external_exports.string(),
2918
+ description: external_exports.string().optional(),
2919
+ efforts: external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string() })),
2920
+ defaultEffort: external_exports.string().optional()
2921
+ }))
2922
+ })),
2923
+ failures: external_exports.array(external_exports.object({ id: external_exports.string(), name: external_exports.string(), message: external_exports.string() }))
2924
+ });
2925
+ var SessionModel = external_exports.object({
2926
+ lastUsed: ModelSelection.nullable(),
2927
+ next: ModelSelection.nullable()
2928
+ });
2929
+ var ProviderApi = external_exports.enum(["openai-completions", "openai-responses", "anthropic-messages"]);
2930
+ var ProviderId = external_exports.string().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, "use lowercase letters, digits and single hyphens, starting with a letter");
2931
+ var ProviderModel = external_exports.object({
2932
+ id: external_exports.string().min(1),
2933
+ name: external_exports.string().optional(),
2934
+ contextWindow: external_exports.number().int().positive().optional(),
2935
+ maxTokens: external_exports.number().int().positive().optional(),
2936
+ input: external_exports.array(external_exports.enum(["text", "image"])).optional(),
2937
+ /** Selectable thinking levels (e.g. off, low, medium, high); absent = not declared. */
2938
+ efforts: external_exports.array(external_exports.string().min(1)).optional()
2939
+ });
2940
+ var ProviderProfile = external_exports.object({
2941
+ id: external_exports.string(),
2942
+ displayName: external_exports.string(),
2943
+ /** Wire protocol; a catalog route may leave it to the catalog. */
2944
+ api: external_exports.string().optional(),
2945
+ baseURL: external_exports.string().optional(),
2946
+ models: external_exports.array(ProviderModel),
2947
+ /** Credential reference the route reads its key from. */
2948
+ apiKeyRef: external_exports.string().optional(),
2949
+ credential: CredentialInfo.optional(),
2950
+ /** False when the route narrows a provider dsh ships a catalog for. */
2951
+ declared: external_exports.boolean(),
2952
+ /** Whether the route is currently registered and serving requests. */
2953
+ active: external_exports.boolean(),
2954
+ /** Configuration diagnostic reported by the adapter. */
2955
+ error: external_exports.string().optional()
2956
+ });
2957
+ var ProviderBalance = external_exports.object({
2958
+ /** False when the balance is too low for API calls. */
2959
+ available: external_exports.boolean(),
2960
+ balances: external_exports.array(external_exports.object({
2961
+ currency: external_exports.string(),
2962
+ total: external_exports.string(),
2963
+ granted: external_exports.string(),
2964
+ toppedUp: external_exports.string()
2965
+ }))
2966
+ });
2967
+ var MAX_IMAGE_BASE64 = 35e5;
2968
+ var PromptImage = external_exports.object({
2969
+ mediaType: external_exports.enum(["image/png", "image/jpeg", "image/gif", "image/webp"]),
2970
+ data: external_exports.string().min(1).max(MAX_IMAGE_BASE64).regex(/^[A-Za-z0-9+/]+={0,2}$/, "base64 without a data: prefix"),
2971
+ name: external_exports.string().max(200).optional()
2972
+ });
2973
+ var ReleaseNote = external_exports.object({
2974
+ version: external_exports.string(),
2975
+ /** The release's own title, when it has one. */
2976
+ title: external_exports.string().optional(),
2977
+ publishedAt: external_exports.string().optional(),
2978
+ /** Its page on GitHub. */
2979
+ url: external_exports.string(),
2980
+ /** Markdown. */
2981
+ body: external_exports.string()
2982
+ });
2983
+ var Empty2 = external_exports.object({});
2984
+ var Accepted = external_exports.object({ accepted: external_exports.literal(true) });
2985
+ var Requests = {
2986
+ "initialize": {
2987
+ capability: null,
2988
+ params: external_exports.object({
2989
+ protocolVersion: external_exports.number().int(),
2990
+ client: external_exports.object({ name: external_exports.string(), version: external_exports.string() })
2991
+ }),
2992
+ result: external_exports.object({
2993
+ protocolVersion: external_exports.number().int(),
2994
+ server: external_exports.object({ name: external_exports.string(), version: external_exports.string(), dsh: external_exports.string().optional() }),
2995
+ capabilities: external_exports.array(Capability)
2996
+ })
2997
+ },
2998
+ "sessions/list": {
2999
+ capability: "sessions",
3000
+ params: Empty2,
3001
+ result: external_exports.object({ items: external_exports.array(SessionItem) })
3002
+ },
3003
+ "sessions/create": {
3004
+ capability: "sessions",
3005
+ /**
3006
+ * `focus`: the scripts and games the conversation is about; it sees their skills (技能隔离).
3007
+ * `role`: a role agent's session (`roles/list`), listed under it and created with the role agents' model.
3008
+ */
3009
+ params: external_exports.object({ cwd: external_exports.string().optional(), focus: external_exports.object({ scripts: external_exports.array(external_exports.string()).optional(), games: external_exports.array(external_exports.string()).optional() }).optional(), role: external_exports.string().optional() }),
3010
+ result: external_exports.object({ sessionId: external_exports.string() })
3011
+ },
3012
+ /** What each session last said: the agent's last reply as one shortened line (null: none yet), for the agent roster and task cards. */
3013
+ "sessions/lastReplies": {
3014
+ capability: "sessions",
3015
+ params: external_exports.object({ sessionIds: external_exports.array(external_exports.string()).max(60) }),
3016
+ result: external_exports.object({ items: external_exports.array(external_exports.object({ sessionId: external_exports.string(), text: external_exports.string().nullable() })) })
3017
+ },
3018
+ /** The role agents (their sessions carry `role`). */
3019
+ "roles/list": {
3020
+ capability: "sessions",
3021
+ params: Empty2,
3022
+ result: external_exports.object({ items: external_exports.array(Role) })
3023
+ },
3024
+ /** The agent's one conversation (`main`: 助手's), made the first time it is asked for, or again when it was deleted. */
3025
+ "agents/home": {
3026
+ capability: AGENTS_CAPABILITY,
3027
+ params: external_exports.object({ agentId: external_exports.string() }),
3028
+ result: external_exports.object({ sessionId: external_exports.string() })
3029
+ },
3030
+ /** Work handed from or to this conversation, newest last. */
3031
+ "handoffs/list": {
3032
+ capability: AGENTS_CAPABILITY,
3033
+ params: external_exports.object({ sessionId: external_exports.string() }),
3034
+ result: external_exports.object({ items: external_exports.array(HandOff) })
3035
+ },
3036
+ /** Stop a sub-agent's current work (the parent's own turn goes on). */
3037
+ "subagents/stop": {
3038
+ capability: AGENTS_CAPABILITY,
3039
+ params: external_exports.object({ sessionId: external_exports.string() }),
3040
+ result: Accepted
3041
+ },
3042
+ /** One hand-off, for the page that shows what the two agents said. */
3043
+ /** All that two agents have said to each other, oldest first: one conversation, whatever each thread was about. */
3044
+ "handoffs/between": {
3045
+ capability: AGENTS_CAPABILITY,
3046
+ params: external_exports.object({ a: external_exports.string(), b: external_exports.string() }),
3047
+ result: external_exports.object({ items: external_exports.array(HandOff) })
3048
+ },
3049
+ "handoffs/get": {
3050
+ capability: AGENTS_CAPABILITY,
3051
+ params: external_exports.object({ id: external_exports.string() }),
3052
+ result: HandOff
3053
+ },
3054
+ /** Reminders the agents set for themselves, soonest first; `agent`: one agent's. */
3055
+ "reminders/list": {
3056
+ capability: AGENTS_CAPABILITY,
3057
+ params: external_exports.object({ agent: external_exports.string().optional() }),
3058
+ result: external_exports.object({ items: external_exports.array(AgentReminder) })
3059
+ },
3060
+ "reminders/remove": {
3061
+ capability: AGENTS_CAPABILITY,
3062
+ params: external_exports.object({ id: external_exports.string() }),
3063
+ result: external_exports.object({})
3064
+ },
3065
+ "sessions/rename": {
3066
+ capability: "sessions",
3067
+ params: external_exports.object({ sessionId: external_exports.string(), title: external_exports.string().min(1) }),
3068
+ result: external_exports.object({ title: external_exports.string() })
3069
+ },
3070
+ "session/open": {
3071
+ capability: "sessions",
3072
+ params: external_exports.object({
3073
+ sessionId: external_exports.string(),
3074
+ /** Upper bound on user/assistant messages in the opening window. */
3075
+ maxMessages: external_exports.number().int().positive().optional()
3076
+ }),
3077
+ result: external_exports.object({
3078
+ subscriptionId: external_exports.string(),
3079
+ header: SessionHeader,
3080
+ /** Inclusive durable cut of the opening window; pass as `throughSeq` to history. */
3081
+ cursor: external_exports.number(),
3082
+ events: external_exports.array(SessionEvent),
3083
+ hasMore: external_exports.boolean(),
3084
+ title: external_exports.string().nullable(),
3085
+ live: LiveAttempt.nullable(),
3086
+ /** Messages still waiting in the queue. */
3087
+ queue: external_exports.array(QueuedPrompt).optional(),
3088
+ /** How full the model's context is; absent until a request reported its usage. */
3089
+ context: SessionContext.optional()
3090
+ })
3091
+ },
3092
+ "session/close": {
3093
+ capability: "sessions",
3094
+ params: external_exports.object({ subscriptionId: external_exports.string() }),
3095
+ result: Empty2
3096
+ },
3097
+ "session/history": {
3098
+ capability: "sessions",
3099
+ params: external_exports.object({
3100
+ sessionId: external_exports.string(),
3101
+ throughSeq: external_exports.number(),
3102
+ beforeSeq: external_exports.number(),
3103
+ maxMessages: external_exports.number().int().positive().optional()
3104
+ }),
3105
+ result: external_exports.object({ events: external_exports.array(SessionEvent), hasMore: external_exports.boolean() })
3106
+ },
3107
+ "session/prompt": {
3108
+ capability: "chat",
3109
+ params: external_exports.object({
3110
+ sessionId: external_exports.string(),
3111
+ /** Client-minted id; retrying with the same id never enqueues twice. */
3112
+ requestId: external_exports.string(),
3113
+ text: external_exports.string(),
3114
+ mode: external_exports.enum(["queue", "steer"]),
3115
+ /** Images with the text (the model must accept images). */
3116
+ images: external_exports.array(PromptImage).max(4).optional()
3117
+ }).refine((p) => p.text.trim() !== "" || (p.images?.length ?? 0) > 0, "\u6D88\u606F\u662F\u7A7A\u7684"),
3118
+ result: Accepted
3119
+ },
3120
+ "session/cancel": {
3121
+ capability: "chat",
3122
+ params: external_exports.object({ sessionId: external_exports.string() }),
3123
+ result: Accepted
3124
+ },
3125
+ /**
3126
+ * Replace the older part of the conversation with a summary (dsh's `/compact`).
3127
+ * The agent loses the details in it: ask the person first. Only while the agent is idle.
3128
+ */
3129
+ "session/compact": {
3130
+ capability: "chat",
3131
+ params: external_exports.object({ sessionId: external_exports.string() }),
3132
+ result: external_exports.object({ compacted: external_exports.boolean(), message: external_exports.string() })
3133
+ },
3134
+ /** A waiting message: put it into the running turn now (`steer`), or take it back (`remove`). */
3135
+ "session/queue/update": {
3136
+ capability: "chat",
3137
+ params: external_exports.object({ sessionId: external_exports.string(), itemId: external_exports.string(), action: external_exports.enum(["steer", "remove"]) }),
3138
+ result: Accepted
3139
+ },
3140
+ /** The bytes of an image in a session (a screenshot a tool took, an image the user sent). */
3141
+ "attachments/image": {
3142
+ capability: "attachments",
3143
+ params: external_exports.object({ attachmentId: external_exports.string(), mediaType: external_exports.string(), bytes: external_exports.number(), width: external_exports.number(), height: external_exports.number() }),
3144
+ result: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string() })
3145
+ },
3146
+ /**
3147
+ * The bytes of an image file on the gateway's computer that a reply shows
3148
+ * (`![…](C:\…\shot.png)`) or links to; a relative path is in the agents'
3149
+ * workspace. Image files only (png, jpg, gif, webp, bmp), up to 25 MB.
3150
+ */
3151
+ "attachments/file": {
3152
+ capability: "attachments",
3153
+ params: external_exports.object({ path: external_exports.string().min(1) }),
3154
+ result: external_exports.object({ mediaType: external_exports.string(), data: external_exports.string(), path: external_exports.string() })
3155
+ },
3156
+ /**
3157
+ * Open a file or folder dialog on the gateway's computer (Windows), for
3158
+ * pages without the desktop app's: a game's program, a script folder.
3159
+ * `path` is absent when the dialog was closed.
3160
+ */
3161
+ "files/pick": {
3162
+ capability: "files",
3163
+ params: external_exports.object({
3164
+ kind: external_exports.enum(["file", "folder"]),
3165
+ title: external_exports.string().max(200).optional(),
3166
+ defaultPath: external_exports.string().max(1e3).optional(),
3167
+ filterName: external_exports.string().max(60).optional(),
3168
+ extensions: external_exports.array(external_exports.string().regex(/^\w+$/)).max(20).optional()
3169
+ }),
3170
+ result: external_exports.object({ path: external_exports.string().optional() })
3171
+ },
3172
+ /** Archived sessions: hidden from the session list, kept, restorable. */
3173
+ "sessions/archived": {
3174
+ capability: "archive",
3175
+ params: Empty2,
3176
+ result: external_exports.object({ sessionIds: external_exports.array(external_exports.string()) })
3177
+ },
3178
+ "sessions/archive": {
3179
+ capability: "archive",
3180
+ params: external_exports.object({ sessionId: external_exports.string() }),
3181
+ result: external_exports.object({ sessionIds: external_exports.array(external_exports.string()) })
3182
+ },
3183
+ "sessions/unarchive": {
3184
+ capability: "archive",
3185
+ params: external_exports.object({ sessionId: external_exports.string() }),
3186
+ result: external_exports.object({ sessionIds: external_exports.array(external_exports.string()) })
3187
+ },
3188
+ /** Model for new sessions (and new chat-channel conversations). */
3189
+ "models/setDefault": {
3190
+ capability: "model-default",
3191
+ params: ModelSelection,
3192
+ result: Empty2
3193
+ },
3194
+ /** Which model each agent and its sub-agents use; what is not set follows the layer above (AgentModels). */
3195
+ "models/agentModels": {
3196
+ capability: "agent-models",
3197
+ params: Empty2,
3198
+ result: AgentModels
3199
+ },
3200
+ /**
3201
+ * Set one layer (null: follow the one above again): an agent's own model (`agentId`; 助手's is the default
3202
+ * model, set with models/setDefault), its sub-agents' (`agentId` and `sub`), or every sub-agent's (`sub` alone).
3203
+ * The agent's own conversation switches at its next request. `warning`: the model cannot see images, and the
3204
+ * agent's work looks at screenshots.
3205
+ */
3206
+ "models/setAgentModel": {
3207
+ capability: "agent-models",
3208
+ params: external_exports.object({ agentId: external_exports.string().optional(), sub: external_exports.boolean().optional(), model: ModelSelection.nullable() }),
3209
+ result: external_exports.object({ warning: external_exports.string().optional() })
3210
+ },
3211
+ "models/catalog": {
3212
+ capability: "models",
3213
+ params: Empty2,
3214
+ result: ModelCatalog
3215
+ },
3216
+ "session/selectModel": {
3217
+ capability: "models",
3218
+ params: ModelSelection.extend({ sessionId: external_exports.string() }),
3219
+ result: external_exports.object({ selected: ModelSelection })
3220
+ },
3221
+ "session/model": {
3222
+ capability: "models",
3223
+ params: external_exports.object({ sessionId: external_exports.string() }),
3224
+ result: SessionModel
3225
+ },
3226
+ "approval/respond": {
3227
+ capability: "approval",
3228
+ params: external_exports.object({
3229
+ approvalId: external_exports.string(),
3230
+ decision: external_exports.enum(["allow-once", "reject"])
3231
+ }),
3232
+ result: Empty2
3233
+ },
3234
+ "credentials/describe": {
3235
+ capability: "credentials",
3236
+ params: external_exports.object({ refs: external_exports.array(CredentialRef).min(1).max(64) }),
3237
+ result: external_exports.object({ items: external_exports.record(external_exports.string(), CredentialInfo) })
3238
+ },
3239
+ "credentials/set": {
3240
+ capability: "credentials",
3241
+ /** The value travels client → host only; no method ever returns it. */
3242
+ params: external_exports.object({ ref: CredentialRef, value: external_exports.string().min(1).max(4096) }),
3243
+ result: Empty2
3244
+ },
3245
+ "credentials/unset": {
3246
+ capability: "credentials",
3247
+ params: external_exports.object({ ref: CredentialRef }),
3248
+ result: Empty2
3249
+ },
3250
+ /**
3251
+ * Which build serves this host, for 设置 → 关于: `plugin` is the dsh plugin package (dsh-multigameassistant),
3252
+ * with its version; anything else (the desktop app, a checkout) says so through its own means.
3253
+ */
3254
+ "about/info": {
3255
+ capability: "about",
3256
+ params: Empty2,
3257
+ result: external_exports.object({ edition: external_exports.enum(["plugin", "other"]), version: external_exports.string().optional() })
3258
+ },
3259
+ /**
3260
+ * The plugin package's newest release on GitHub, if newer than this one (a pre-release only for a
3261
+ * pre-release). `onNpm`: npm already serves it under the plugin's name (a release is live there only
3262
+ * once approved); undefined when npm could not be asked. `notes`: what each release from this one up
3263
+ * to it brings (its GitHub Release text), newest first. Only the plugin package checks here.
3264
+ */
3265
+ "about/checkUpdate": {
3266
+ capability: "about",
3267
+ params: Empty2,
3268
+ result: external_exports.object({
3269
+ current: external_exports.string(),
3270
+ latest: external_exports.object({ version: external_exports.string(), prerelease: external_exports.boolean(), notesUrl: external_exports.string(), onNpm: external_exports.boolean().optional(), notes: external_exports.array(ReleaseNote).optional() }).optional(),
3271
+ checkedAt: external_exports.number()
3272
+ })
3273
+ },
3274
+ "providers/list": {
3275
+ capability: "providers",
3276
+ params: Empty2,
3277
+ result: external_exports.object({
3278
+ providers: external_exports.array(ProviderProfile),
3279
+ /** Pass back as `expectedRevision` so a concurrent edit is refused rather than overwritten. */
3280
+ revision: external_exports.number(),
3281
+ writable: external_exports.boolean(),
3282
+ protocols: external_exports.array(ProviderApi),
3283
+ /** Every route id already in use, custom or shipped. */
3284
+ taken: external_exports.array(external_exports.string())
3285
+ })
3286
+ },
3287
+ "providers/discover": {
3288
+ capability: "providers",
3289
+ params: external_exports.object({
3290
+ /** Existing route being edited; lets the host use its stored key and headers. */
3291
+ provider: external_exports.string().optional(),
3292
+ baseURL: external_exports.url({ protocol: /^https?$/ }).optional(),
3293
+ api: ProviderApi.optional(),
3294
+ /** Used for this one request only; never stored. */
3295
+ apiKey: external_exports.string().min(1).max(4096).optional()
3296
+ }),
3297
+ result: external_exports.object({ models: external_exports.array(ProviderModel) })
3298
+ },
3299
+ "providers/balance": {
3300
+ capability: "providers",
3301
+ params: external_exports.object({ provider: external_exports.string().min(1) }),
3302
+ /** Null when the route is not served by DeepSeek's own API or has no key; a failed query is an error, never a zero. */
3303
+ result: external_exports.object({ balance: ProviderBalance.nullable() })
3304
+ },
3305
+ "providers/save": {
3306
+ capability: "providers",
3307
+ params: external_exports.object({
3308
+ id: ProviderId,
3309
+ /** True for a new route: refused when the id is taken. */
3310
+ create: external_exports.boolean(),
3311
+ displayName: external_exports.string().max(80).optional(),
3312
+ api: ProviderApi,
3313
+ baseURL: external_exports.url({ protocol: /^https?$/ }),
3314
+ models: external_exports.array(ProviderModel).min(1),
3315
+ /** Stored under the route's credential reference; omitted keeps the current key. */
3316
+ apiKey: external_exports.string().min(1).max(4096).optional(),
3317
+ expectedRevision: external_exports.number().optional()
3318
+ }),
3319
+ result: external_exports.object({ revision: external_exports.number(), apiKeyRef: external_exports.string().optional() })
3320
+ },
3321
+ "providers/remove": {
3322
+ capability: "providers",
3323
+ params: external_exports.object({
3324
+ id: external_exports.string().min(1),
3325
+ /** Also delete the stored key the route referenced. */
3326
+ removeKey: external_exports.boolean().optional(),
3327
+ expectedRevision: external_exports.number().optional()
3328
+ }),
3329
+ result: external_exports.object({
3330
+ revision: external_exports.number(),
3331
+ /** True when the route was the default for new sessions and the default fell back to the profile's own. */
3332
+ defaultReset: external_exports.boolean()
3333
+ })
3334
+ },
3335
+ ...ScriptRequests,
3336
+ ...RunRequests,
3337
+ ...GuardRequests,
3338
+ ...EmulatorRequests,
3339
+ ...PackRequests,
3340
+ ...MonitorRequests,
3341
+ ...NotifyRequests,
3342
+ ...PipelineRequests,
3343
+ ...InterveneRequests,
3344
+ ...GamesRequests,
3345
+ ...PermissionsRequests,
3346
+ ...QuestionsRequests,
3347
+ ...InstancesRequests,
3348
+ ...SkillsRequests,
3349
+ ...SkillHubRequests,
3350
+ ...PersonaRequests,
3351
+ ...CompactionRequests,
3352
+ ...MemoryRequests
3353
+ };
3354
+ var SessionsChanged = external_exports.discriminatedUnion("kind", [
3355
+ external_exports.object({ kind: external_exports.literal("upsert"), item: SessionItem.partial().extend({ id: external_exports.string() }) }),
3356
+ external_exports.object({ kind: external_exports.literal("removed"), sessionId: external_exports.string() })
3357
+ ]);
3358
+ var ApprovalRequested = external_exports.object({
3359
+ approvalId: external_exports.string(),
3360
+ sessionId: external_exports.string(),
3361
+ toolName: external_exports.string(),
3362
+ callId: external_exports.string().optional(),
3363
+ reason: external_exports.string().optional(),
3364
+ /** Localized presentation text keyed by locale (always has `en`). */
3365
+ displayReason: external_exports.record(external_exports.string(), external_exports.string()).optional()
3366
+ });
3367
+ var Notifications = {
3368
+ "sessions/changed": SessionsChanged,
3369
+ "session/event": external_exports.object({ subscriptionId: external_exports.string(), event: SessionEvent }),
3370
+ "session/live": external_exports.object({ subscriptionId: external_exports.string(), frame: LiveFrame }),
3371
+ "session/closed": external_exports.object({ subscriptionId: external_exports.string(), reason: external_exports.string() }),
3372
+ "session/title": external_exports.object({ sessionId: external_exports.string(), title: external_exports.string().nullable() }),
3373
+ "session/error": external_exports.object({ sessionId: external_exports.string(), message: external_exports.string() }),
3374
+ /** A session's waiting messages changed (sent, inserted, taken back, or admitted). */
3375
+ "session/queue": external_exports.object({ sessionId: external_exports.string(), items: external_exports.array(QueuedPrompt) }),
3376
+ /** How full a session's context is changed (a request reported its usage, or the conversation was compacted). */
3377
+ "session/context": external_exports.object({ sessionId: external_exports.string(), context: SessionContext.nullable() }),
3378
+ "approval/requested": ApprovalRequested,
3379
+ "approval/resolved": external_exports.object({ approvalId: external_exports.string(), outcome: external_exports.string() }),
3380
+ /** A stored credential changed (set, unset, or edited on disk). Never carries the value. */
3381
+ "credentials/changed": external_exports.object({ ref: external_exports.string() }),
3382
+ /** The archived set changed (here or in dsh's own page). */
3383
+ "sessions/archived": external_exports.object({ sessionIds: external_exports.array(external_exports.string()) }),
3384
+ /** The role agents changed (a plugin loaded or unloaded); the whole list. */
3385
+ "roles/changed": external_exports.object({ items: external_exports.array(Role) }),
3386
+ /** A hand-off started or ended. */
3387
+ "handoffs/changed": external_exports.object({ item: HandOff }),
3388
+ /** A reminder was set, came, or was removed. */
3389
+ "reminders/changed": external_exports.object({}),
3390
+ /** Provider routes or their models changed; re-read `providers/list` and `models/catalog`. */
3391
+ "providers/changed": external_exports.object({}),
3392
+ /** Someone set an agent's or sub-agents' model. */
3393
+ "models/agentModelsChanged": AgentModels,
3394
+ /** A session's model selection changed. */
3395
+ "session/model": SessionModel.extend({ sessionId: external_exports.string() }),
3396
+ ...ScriptNotifications,
3397
+ ...SkillHubNotifications,
3398
+ ...SkillsNotifications,
3399
+ ...RunNotifications,
3400
+ ...GuardNotifications,
3401
+ ...EmulatorNotifications,
3402
+ ...PackNotifications,
3403
+ ...MonitorNotifications,
3404
+ ...NotifyNotifications,
3405
+ ...PipelineNotifications,
3406
+ ...InterveneNotifications,
3407
+ ...GamesNotifications,
3408
+ ...PermissionsNotifications,
3409
+ ...QuestionsNotifications,
3410
+ ...InstancesNotifications,
3411
+ ...MemoryNotifications
3412
+ };
3413
+ var ErrorCode = {
3414
+ ParseError: -32700,
3415
+ InvalidRequest: -32600,
3416
+ MethodNotFound: -32601,
3417
+ InvalidParams: -32602,
3418
+ InternalError: -32603,
3419
+ /** `initialize` has not completed on this connection. */
3420
+ NotInitialized: -32002,
3421
+ /** The upstream host rejected the operation; `data.code` carries its code. */
3422
+ HostError: -32010,
3423
+ /** The referenced subscription, approval, or session does not exist. */
3424
+ NotFound: -32011
3425
+ };
3426
+
3427
+ // packages/protocol/lib/jsonrpc.js
3428
+ var RpcError = class extends Error {
3429
+ code;
3430
+ data;
3431
+ constructor(code, message, data) {
3432
+ super(message);
3433
+ this.name = "RpcError";
3434
+ this.code = code;
3435
+ this.data = data;
3436
+ }
3437
+ toJSON() {
3438
+ return this.data === void 0 ? { code: this.code, message: this.message } : { code: this.code, message: this.message, data: this.data };
3439
+ }
3440
+ };
3441
+ function classify(value) {
3442
+ if (typeof value !== "object" || value === null || value.jsonrpc !== "2.0")
3443
+ return "invalid";
3444
+ const frame = value;
3445
+ if (typeof frame.method === "string")
3446
+ return "id" in frame ? "request" : "notification";
3447
+ if ("result" in frame || "error" in frame)
3448
+ return "response";
3449
+ return "invalid";
3450
+ }
3451
+
3452
+ // packages/protocol/lib/tools.js
3453
+ function summarizeToolArgs(args) {
3454
+ try {
3455
+ const value = JSON.parse(args);
3456
+ for (const key of ["command", "cmd", "path", "file_path", "pattern", "query", "url", "description", "prompt"]) {
3457
+ const v = value[key];
3458
+ if (typeof v === "string" && v !== "")
3459
+ return v.split("\n")[0].slice(0, 160);
3460
+ }
3461
+ const first = Object.values(value).find((v) => typeof v === "string");
3462
+ return typeof first === "string" ? first.slice(0, 160) : "";
3463
+ } catch {
3464
+ return args.slice(0, 160);
3465
+ }
3466
+ }
3467
+
3468
+ // packages/protocol/lib/commands.js
3469
+ var SAVE_SKILL_PROMPT = [
3470
+ "\u628A\u8FD9\u6B21\u8D70\u901A\u7684\u505A\u6CD5\u4FDD\u5B58\u6210\u6280\u80FD\uFF08\u7528 skill_save\uFF09\uFF0C\u8BA9\u4E0B\u6B21\u540C\u6837\u7684\u4E8B\u53EF\u4EE5\u76F4\u63A5\u7167\u7740\u505A\u3001\u5C11\u8C03\u7528\u6A21\u578B\u3002\u8981\u6C42\uFF1A",
3471
+ "- \u53EA\u5199\u6700\u540E\u6210\u529F\u7684\u8DEF\u5F84\uFF0C\u4E0D\u5199\u5931\u8D25\u7684\u5C1D\u8BD5\u548C\u95F2\u804A\uFF1B",
3472
+ "- \u5199\u6E05\u695A\u9002\u7528\u573A\u666F\uFF08\u7528\u6237\u4F1A\u600E\u4E48\u8BF4\uFF09\u3001\u4E00\u6B65\u4E00\u6B65\u7684\u64CD\u4F5C\uFF08\u7528\u5230\u7684\u5DE5\u5177\u3001\u547D\u4EE4\u3001\u8DEF\u5F84\u3001\u53C2\u6570\u7167\u5B9E\u5199\uFF0C\u4F1A\u53D8\u7684\u5199\u6210\u300C\u628A X \u6362\u6210\u2026\u300D\uFF09\u3001\u600E\u6837\u7B97\u6210\u529F\u3001\u6CE8\u610F\u4E8B\u9879\u548C\u8E29\u8FC7\u7684\u5751\uFF1B",
3473
+ "- \u540D\u5B57\u7528\u7B80\u77ED\u7684\u82F1\u6587\u5C0F\u5199\u52A0\u77ED\u6A2A\u7EBF\uFF0Cdescription \u4E00\u4E24\u53E5\u8BDD\u8BF4\u6E05\u695A\u505A\u4EC0\u4E48\u3001\u4EC0\u4E48\u65F6\u5019\u7528\uFF1B",
3474
+ "- \u5206\u5230\u5BF9\u5E94\u7684\u6E38\u620F\u548C\u811A\u672C\uFF1A\u53EA\u6709\u7528\u67D0\u4E2A\u811A\u672C\u65F6\u624D\u7528\u5F97\u4E0A\u7684\uFF08\u5B83\u7684\u914D\u7F6E\u3001\u62A5\u9519\u3001\u65E5\u5FD7\uFF09\uFF0Cscripts \u586B\u811A\u672C id\uFF1B\u548C\u6E38\u620F\u672C\u8EAB\u6709\u5173\u3001\u6362\u4E2A\u811A\u672C\u4E5F\u7528\u5F97\u4E0A\u7684\uFF08\u6E38\u620F\u91CC\u7684\u64CD\u4F5C\u3001\u754C\u9762\u3001\u6D3B\u52A8\u3001\u673A\u5236\uFF09\uFF0Cgames \u586B\u6E38\u620F id\uFF08\u7528 game_list \u67E5\uFF09\uFF1B\u548C\u54EA\u4E2A\u6E38\u620F\u90FD\u65E0\u5173\u624D\u5F53\u901A\u7528\u6280\u80FD\uFF1B",
3475
+ "- \u4FDD\u5B58\u540E\u544A\u8BC9\u6211\u6280\u80FD\u540D\uFF0C\u4EE5\u53CA\u4EE5\u540E\u6211\u8BF4\u4EC0\u4E48\u65F6\u4F1A\u7528\u5230\u5B83\u3002"
3476
+ ].join("\n");
3477
+ function optimizeScriptPrompt(target, why, id) {
3478
+ return [
3479
+ `\u4F18\u5316\u811A\u672C${target === "" ? "\uFF1A\u6700\u8FD1\u8FD0\u884C\u8FC7\u7684\u811A\u672C\uFF08script_runs \u770B\u6700\u8FD1\u4E00\u5468\u8DD1\u8FC7\u54EA\u4E9B\uFF0C\u4E00\u4E2A\u4E00\u4E2A\u6765\uFF09" : `\u300C${target}\u300D${id === void 0 ? "" : `\uFF08\u811A\u672C id ${id}\uFF09`}`}${why === void 0 ? "" : `\uFF08${why}\uFF09`}\u3002\u628A\u8FD9\u6BB5\u65F6\u95F4\u8FD0\u884C\u6512\u4E0B\u7684\u4FE1\u606F\u7528\u8D77\u6765\uFF0C\u4E00\u6B21\u505A\u5B8C\u4E0B\u9762\u51E0\u4EF6\u4E8B\uFF1A`,
3480
+ "1. \u91CD\u65B0\u603B\u7ED3\u811A\u672C\u5305\uFF1Ascript_tasks\u3001script_help \u770B\u5B83\u73B0\u5728\u6709\u54EA\u4E9B\u4EFB\u52A1\u548C\u53C2\u6570\uFF0Cscript_runs\u3001script_run_log \u770B\u6700\u8FD1\u7684\u8FD0\u884C\uFF08\u6210\u529F\u7684\u770B\u6B63\u5E38\u6D41\u7A0B\u548C\u7528\u65F6\uFF0C\u5931\u8D25\u7684\u770B\u539F\u56E0\uFF09\uFF1B\u66F4\u65B0\u8FC7\u7248\u672C\u5C31\u5148\u7528 script_changelog \u8BFB\u66F4\u65B0\u65E5\u5FD7\u3002\u5BF9\u7167\u5B83\u7684\u811A\u672C\u5305\uFF0C\u4EFB\u52A1\u3001\u53C2\u6570\u3001\u914D\u7F6E\u6587\u4EF6\u3001\u5B8C\u6210\u548C\u51FA\u9519\u7684\u65E5\u5FD7\u6587\u5B57\u3001\u9884\u8BA1\u7528\u65F6\u6709\u4E0D\u5BF9\u6216\u7F3A\u7684\uFF0C\u6216\u8005\u4F7F\u7528\u8BF4\u660E\uFF08guide\uFF1A\u529F\u80FD\u600E\u4E48\u5F00\u542F\u3001\u914D\u7F6E\u600E\u4E48\u8BBE\u3001\u8FD0\u884C\u524D\u68C0\u67E5\u3001\u5E38\u89C1\u95EE\u9898\uFF09\u7F3A\u4E86\u3001\u8FC7\u65F6\u4E86\u3001\u80FD\u7528\u8FD0\u884C\u91CC\u9047\u5230\u7684\u62A5\u9519\u8865\u4E0A\u7684\uFF0C\u7528\u539F\u6765\u7684\u811A\u672C\u5305 id \u8C03\u7528 pack_propose \u4FDD\u5B58\uFF08\u76F4\u63A5\u751F\u6548\uFF1Bsummary \u5199\u660E\u4F9D\u636E\uFF09\uFF1B\u90FD\u5BF9\u5C31\u4E0D\u6539\uFF1B",
3481
+ "2. \u6539\u5584\u76D1\u63A7\u65F6\u95F4\uFF1Amonitor_stall_check \u770B\u5B83\u6B63\u5E38\u8FD0\u884C\u65F6\u65E5\u5FD7\u7684\u8282\u594F\uFF0C\u6309\u5EFA\u8BAE\u503C\u548C\u4F60\u770B\u65E5\u5FD7\u7684\u5224\u65AD\u7528 monitor_stall_set \u8BBE\u5B83\u591A\u4E45\u6CA1\u65B0\u65E5\u5FD7\u7B97\u5361\u4F4F\uFF0Cnote \u5199\u660E\u4F9D\u636E\uFF08\u4F8B\u5982\u300C\u6218\u6597\u4E2D\u6700\u957F 70 \u79D2\u4E0D\u8F93\u51FA\u300D\uFF09\uFF1B",
3482
+ "3. \u628A\u505A\u8FC7\u7684\u6B65\u9AA4\u603B\u7ED3\u6210\u6280\u80FD\uFF0C\u5206\u5230\u5BF9\u5E94\u7684\u6E38\u620F\u548C\u811A\u672C\uFF1A\u8FD0\u884C\u548C\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u65F6\u53CD\u590D\u7528\u5230\u3001\u5DF2\u7ECF\u8D70\u901A\u7684\u505A\u6CD5\uFF08\u5E38\u89C1\u62A5\u9519\u600E\u4E48\u5904\u7406\u3001\u600E\u4E48\u786E\u8BA4\u8DD1\u5B8C\u3001\u914D\u7F6E\u600E\u4E48\u6539\uFF09\u7528 skill_save \u5B58\u6210\u6280\u80FD\uFF0Cscripts \u586B\u8FD9\u4E2A\u811A\u672C\u7684 id\uFF0C\u53EA\u7ED9\u5B83\u7528\uFF1B\u5176\u4E2D\u548C\u6E38\u620F\u672C\u8EAB\u6709\u5173\u3001\u522B\u7684\u811A\u672C\u4E5F\u7528\u5F97\u4E0A\u7684\uFF08\u6E38\u620F\u91CC\u7684\u64CD\u4F5C\u3001\u754C\u9762\u3001\u6D3B\u52A8\u3001\u673A\u5236\uFF09\u5355\u72EC\u5B58\uFF0Cgames \u586B\u5B83\u73A9\u7684\u6E38\u620F id\uFF08game_list \u67E5\uFF09\uFF0C\u4E0D\u586B scripts\uFF1B\u5DF2\u6709\u7684\u6280\u80FD\u5C31\u5408\u5E76\u66F4\u65B0\uFF08replace\uFF09\uFF0C\u4E0D\u8981\u91CD\u590D\u5B58\uFF0C\u6CA1\u6709\u503C\u5F97\u5B58\u7684\u5C31\u4E0D\u5B58\uFF1B",
3483
+ "4. \u4E0D\u8981\u8FD0\u884C\u811A\u672C\u3001\u4E0D\u8981\u6539\u5B83\u7684\u914D\u7F6E\uFF1B\u6700\u540E\u7528\u51E0\u53E5\u8BDD\u544A\u8BC9\u6211\uFF1A\u811A\u672C\u5305\u6539\u4E86\u4EC0\u4E48\uFF08\u5DF2\u7ECF\u76F4\u63A5\u751F\u6548\uFF09\u3001\u5361\u4F4F\u65F6\u95F4\u8BBE\u6210\u591A\u5C11\u3001\u5B58\u4E86\u6216\u66F4\u65B0\u4E86\u54EA\u4E9B\u6280\u80FD\u3002"
3484
+ ].join("\n");
3485
+ }
3486
+ var COMMANDS = [
3487
+ {
3488
+ name: "\u6280\u80FD",
3489
+ aliases: ["skill"],
3490
+ title: "\u628A\u521A\u624D\u8D70\u901A\u7684\u505A\u6CD5\u5B58\u6210\u6280\u80FD\uFF0C\u4E0B\u6B21\u5C11\u8C03\u7528\u6A21\u578B",
3491
+ expand: () => SAVE_SKILL_PROMPT
3492
+ },
3493
+ {
3494
+ name: "\u8D44\u8BAF",
3495
+ aliases: ["news"],
3496
+ title: "\u4E0A\u7F51\u67E5\u6E38\u620F\u8D44\u8BAF\uFF1A\u6D3B\u52A8\u3001\u7248\u672C\u3001\u7EF4\u62A4\u516C\u544A",
3497
+ arg: "\u6E38\u620F\u540D\uFF08\u53EF\u9009\uFF0C\u4E0D\u5199\u5C31\u67E5\u6E38\u620F\u9875\u4E0A\u7684\u6E38\u620F\uFF09",
3498
+ expand: (arg) => [
3499
+ `\u4E0A\u7F51\u67E5${arg === "" ? "\u6211\u6E38\u620F\u9875\u4E0A\u7684\u6E38\u620F" : `\u300C${arg}\u300D`}\u6700\u8FD1\u7684\u8D44\u8BAF\uFF0C\u6309\u6280\u80FD web-reading\uFF1A`,
3500
+ "1. \u5148 game_list\u3001game_activities \u770B\u65E5\u5386\u91CC\u5DF2\u7ECF\u6709\u4EC0\u4E48\uFF0C\u4E0D\u91CD\u590D\u67E5\uFF1B",
3501
+ "2. \u5148\u7528\u516C\u5F00 API\uFF08SRA \u516C\u5171 API\u3001Wiki \u7684 api.php\uFF09\uFF0C\u6CA1\u6709\u518D\u8BFB\u5B98\u7F51\u516C\u544A\u5217\u8868\u9875\uFF0C\u53EA\u6253\u5F00\u6700\u8FD1\u7684\u6D3B\u52A8\u3001\u7248\u672C\u548C\u7EF4\u62A4\u516C\u544A\uFF1B",
3502
+ "3. \u67E5\u5230\u8D77\u6B62\u65F6\u95F4\u7684\u6D3B\u52A8\u7528 game_record\uFF08source=site\uFF0C\u5199\u4E0A url\uFF09\u8BB0\u8FDB\u65E5\u5386\uFF1B",
3503
+ "4. \u6700\u540E\u6309\u6E38\u620F\u5217\u4E00\u4E0B\uFF1A\u6B63\u5728\u8FDB\u884C\u3001\u5FEB\u7ED3\u675F\u3001\u5373\u5C06\u5F00\u59CB\u7684\u6D3B\u52A8\uFF0C\u548C\u5176\u4ED6\u503C\u5F97\u77E5\u9053\u7684\u6D88\u606F\uFF08\u65B0\u7248\u672C\u3001\u7EF4\u62A4\u3001\u798F\u5229\u3001\u5151\u6362\u7801\uFF09\u3002"
3504
+ ].join("\n")
3505
+ },
3506
+ {
3507
+ name: "\u7F16\u6392",
3508
+ aliases: ["plan", "pipeline"],
3509
+ title: "\u628A\u811A\u672C\u7F16\u6210\u6D41\u6C34\u7EBF",
3510
+ arg: "\u60F3\u505A\u4EC0\u4E48\uFF08\u53EF\u9009\uFF0C\u4F8B\u5982\u300C\u6BCF\u5929\u65E9\u4E0A\u8DD1\u5B8C\u4E09\u4E2A\u6E38\u620F\u7684\u65E5\u5E38\u300D\uFF09",
3511
+ expand: (arg) => [
3512
+ `\u5E2E\u6211\u628A\u811A\u672C\u7F16\u6392\u6210\u6D41\u6C34\u7EBF\uFF1A${arg === "" ? "\u628A\u6211\u88C5\u597D\u7684\u5404\u4E2A\u811A\u672C\u7684\u65E5\u5E38\u4EFB\u52A1\u6392\u6210\u6BCF\u5929\u80FD\u81EA\u52A8\u8DD1\u7684\u6D41\u7A0B" : arg}\u3002\u6309\u6280\u80FD pipeline-planning\uFF1A`,
3513
+ "1. \u5148 system_info \u770B\u7535\u8111\u914D\u7F6E\uFF08\u80FD\u4E0D\u80FD\u540C\u65F6\u8DD1\u51E0\u4E2A\u6E38\u620F\uFF09\uFF0Cpipeline_list \u770B\u5DF2\u6709\u7684\u6D41\u6C34\u7EBF\uFF0Cscript_tasks \u770B\u5404\u811A\u672C\u6709\u54EA\u4E9B\u4EFB\u52A1\uFF1B",
3514
+ "2. \u6392\u597D\u540E\u4FDD\u5B58\uFF1A\u4F60\u662F\u300C\u7F16\u6392\u300D\u5C31\u7528 pipeline_save \u76F4\u63A5\u4FDD\u5B58\uFF1B\u4E0D\u662F\u5C31\u7528 pipeline_draft \u8D77\u8349\uFF08\u8349\u7A3F\uFF0C\u6211\u5728\u300C\u7F16\u6392\u300D\u9875\u4FDD\u5B58\u540E\u624D\u4F1A\u6309\u5B9A\u65F6\u8FD0\u884C\uFF09\uFF0C\u6216\u8005\u4EA4\u7ED9\u300C\u7F16\u6392\u300D\u3002\u6A21\u62DF\u5668\u548C\u524D\u53F0\u811A\u672C\u80FD\u5E76\u884C\u7684\u5E76\u884C\uFF0C\u5931\u8D25\u4E0D\u8981\u6321\u4F4F\u522B\u7684\uFF1B",
3515
+ "3. \u8BF4\u6E05\u695A\u4E3A\u4EC0\u4E48\u8FD9\u6837\u6392\u3001\u54EA\u4E9B\u6B65\u9AA4\u5E76\u884C\u3001\u4F30\u8BA1\u591A\u4E45\u3001\u5EFA\u8BAE\u5B9A\u5728\u51E0\u70B9\u8DD1\u3002"
3516
+ ].join("\n")
3517
+ },
3518
+ {
3519
+ name: "\u8BCA\u65AD",
3520
+ aliases: ["diagnose", "why"],
3521
+ title: "\u5206\u6790\u811A\u672C\u4E3A\u4EC0\u4E48\u5931\u8D25\uFF0C\u7ED9\u51FA\u600E\u4E48\u6539\u7684\u5EFA\u8BAE",
3522
+ arg: "\u811A\u672C\u540D\u6216\u8FD0\u884C id\uFF08\u53EF\u9009\uFF0C\u4E0D\u5199\u5C31\u770B\u6700\u8FD1\u5931\u8D25\u7684\uFF09",
3523
+ expand: (arg) => [
3524
+ `\u5206\u6790${arg === "" ? "\u6700\u8FD1\u5931\u8D25\u7684\u811A\u672C\u8FD0\u884C" : `\u300C${arg}\u300D`}\u4E3A\u4EC0\u4E48\u5931\u8D25\uFF1A`,
3525
+ "1. \u7528 script_runs \u627E\u5230\u5931\u8D25\u7684\u90A3\u6B21\u8FD0\u884C\uFF0Cscript_run_log \u770B\u65E5\u5FD7\uFF08\u5148\u6309\u9519\u8BEF\u7EA7\u522B\u7B5B\uFF0C\u518D\u770B\u51FA\u9519\u524D\u540E\uFF09\uFF1B",
3526
+ "2. \u5BF9\u7167\u8FD9\u4E2A\u811A\u672C\u5305\u7684\u6280\u80FD\u8BF4\u660E\u539F\u56E0\uFF1A\u662F\u811A\u672C\u672C\u8EAB\u3001\u914D\u7F6E\u3001\u6E38\u620F\u72B6\u6001\uFF08\u66F4\u65B0\u3001\u516C\u544A\u3001\u6389\u7EBF\uFF09\u3001\u6A21\u62DF\u5668 / ADB\uFF0C\u8FD8\u662F\u7535\u8111\u73AF\u5883\uFF1B",
3527
+ "3. \u7ED9\u51FA\u600E\u4E48\u6539\uFF1A\u6539\u54EA\u9879\u914D\u7F6E\u3001\u6E38\u620F\u91CC\u8981\u505A\u4EC0\u4E48\u3001\u8981\u4E0D\u8981\u91CD\u8DD1\u3002\u5148\u4E0D\u8981\u6539\u4EFB\u4F55\u4E1C\u897F\u3001\u4E0D\u8981\u91CD\u8DD1\uFF0C\u7B49\u6211\u51B3\u5B9A\u3002"
3528
+ ].join("\n")
3529
+ },
3530
+ {
3531
+ name: "\u4F18\u5316\u811A\u672C",
3532
+ aliases: ["optimize"],
3533
+ title: "\u7528\u8FD0\u884C\u6512\u4E0B\u7684\u4FE1\u606F\u4F18\u5316\u811A\u672C\uFF1A\u91CD\u65B0\u603B\u7ED3\u811A\u672C\u5305\u3001\u8C03\u76D1\u63A7\u65F6\u95F4\u3001\u628A\u505A\u8FC7\u7684\u6B65\u9AA4\u5B58\u6210\u6280\u80FD",
3534
+ arg: "\u811A\u672C\u540D\uFF08\u53EF\u9009\uFF0C\u4E0D\u5199\u5C31\u770B\u6700\u8FD1\u8FD0\u884C\u8FC7\u7684\uFF09",
3535
+ expand: (arg) => optimizeScriptPrompt(arg)
3536
+ },
3537
+ {
3538
+ name: "\u538B\u7F29",
3539
+ aliases: ["compact"],
3540
+ title: "\u538B\u7F29\u8FD9\u4E2A\u5BF9\u8BDD\uFF1A\u8F83\u65E9\u7684\u90E8\u5206\u6362\u6210\u6458\u8981\uFF0Cagent \u4F1A\u5FD8\u6389\u5176\u4E2D\u7684\u7EC6\u8282",
3541
+ expand: () => "",
3542
+ local: "compact"
3543
+ }
3544
+ ];
3545
+ function skillInstruction(name, request) {
3546
+ return `\u4F7F\u7528\u6280\u80FD\u300C${name}\u300D\uFF1A\u5148\u7528 skill \u5DE5\u5177\u52A0\u8F7D\u5B83\uFF0C\u518D\u6309\u5B83\u7684\u8BF4\u660E\u505A${request === "" ? "\u3002" : `\uFF1A${request}`}`;
3547
+ }
3548
+ function expandSlash(text, skills) {
3549
+ const typed = text.trim();
3550
+ const match = /^\/(\S+)(?:\s+([\s\S]*))?$/.exec(typed);
3551
+ if (match === null)
3552
+ return typed;
3553
+ const word = match[1];
3554
+ const arg = (match[2] ?? "").trim();
3555
+ const command = COMMANDS.find((c) => c.name === word.toLowerCase() || c.aliases.includes(word.toLowerCase()));
3556
+ if (command?.local !== void 0)
3557
+ return typed;
3558
+ if (command !== void 0)
3559
+ return `${typed}
3560
+
3561
+ ${command.expand(arg)}`;
3562
+ const skill = skills.find((s) => s.name === word);
3563
+ return skill === void 0 ? typed : `${typed}
3564
+
3565
+ ${skillInstruction(skill.name, arg)}`;
3566
+ }
3567
+
3568
+ // packages/protocol/lib/github-link.js
3569
+ var REPO_PAGES = /* @__PURE__ */ new Set(["issues", "pulls", "wiki", "actions", "discussions", "blob", "commits", "commit", "compare", "security", "pulse", "graphs", "network", "settings", "projects", "stargazers", "forks", "watchers", "tags", "branches"]);
3570
+ function parseGitHubLink(text) {
3571
+ const value = text.trim().replace(/^<|>$/g, "");
3572
+ const plain = /^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(value);
3573
+ if (plain !== null && !value.includes(":"))
3574
+ return { repo: `${plain[1]}/${plain[2]}` };
3575
+ const ssh = /git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/i.exec(value);
3576
+ if (ssh !== null)
3577
+ return { repo: `${ssh[1]}/${ssh[2]}` };
3578
+ const decode = (s) => {
3579
+ try {
3580
+ return decodeURIComponent(s);
3581
+ } catch {
3582
+ return s;
3583
+ }
3584
+ };
3585
+ const raw = /raw\.githubusercontent\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/([^/?#]+)/i.exec(value);
3586
+ if (raw !== null)
3587
+ return { repo: `${raw[1]}/${raw[2]}`, branch: decode(raw[3]) };
3588
+ const apiRepo = /api\.github\.com\/repos\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/i.exec(value);
3589
+ if (apiRepo !== null)
3590
+ return { repo: `${apiRepo[1]}/${apiRepo[2]}` };
3591
+ const at = value.toLowerCase().lastIndexOf("github.com/");
3592
+ if (at === -1)
3593
+ return void 0;
3594
+ const path = value.slice(at + "github.com/".length).split(/[?#]/)[0].replace(/\/+$/, "");
3595
+ const parts = path.split("/");
3596
+ if (parts.length < 2 || !/^[A-Za-z0-9_.-]+$/.test(parts[0]))
3597
+ return void 0;
3598
+ const name = parts[1].replace(/\.git$/i, "");
3599
+ if (!/^[A-Za-z0-9_.-]+$/.test(name))
3600
+ return void 0;
3601
+ const repo = `${parts[0]}/${name}`;
3602
+ const [section, ...rest] = parts.slice(2);
3603
+ if (section === "releases") {
3604
+ if (rest[0] === "tag" && rest[1] !== void 0)
3605
+ return { repo, tag: decode(rest.slice(1).join("/")) };
3606
+ if (rest[0] === "download" && rest.length >= 3)
3607
+ return { repo, tag: decode(rest.slice(1, -1).join("/")), asset: decode(rest.at(-1)) };
3608
+ return { repo };
3609
+ }
3610
+ if (section === "tree" && rest.length > 0)
3611
+ return { repo, branch: decode(rest[0]) };
3612
+ if (section === "archive") {
3613
+ const ref = rest.join("/").replace(/\.(zip|tar\.gz)$/i, "");
3614
+ const tag = /^refs\/tags\/(.+)$/.exec(ref)?.[1];
3615
+ if (tag !== void 0)
3616
+ return { repo, tag: decode(tag) };
3617
+ const head = /^refs\/heads\/(.+)$/.exec(ref)?.[1];
3618
+ return head !== void 0 ? { repo, branch: decode(head) } : { repo, tag: decode(ref) };
3619
+ }
3620
+ if (section === void 0 || REPO_PAGES.has(section))
3621
+ return { repo };
3622
+ return { repo };
3623
+ }
3624
+
3625
+ // packages/protocol/lib/update-rule.js
3626
+ var UPDATE_RULE = "\u66F4\u65B0\u811A\u672C\u53EA\u8D70\u5B98\u65B9\u6E20\u9053\uFF1A\u5148\u7528 script_update\uFF08Mirror\u9171 \u6216\u5B98\u65B9\u53D1\u5E03\u5305\uFF0C\u914D\u7F6E\u4F1A\u63A5\u4E0A\uFF09\uFF1B\u5B83\u6CA1\u6709\u66F4\u65B0\u6765\u6E90\u6216\u5931\u8D25\u65F6\uFF0C\u7528\u811A\u672C\u81EA\u5DF1\u7684\u66F4\u65B0\u529F\u80FD\uFF08\u5B83\u7684\u66F4\u65B0\u7A0B\u5E8F\u3001\u542F\u52A8\u5668\u6216\u8BBE\u7F6E\u91CC\u7684\u300C\u68C0\u67E5\u66F4\u65B0\u300D\uFF09\u3002\u4E0D\u8981\u7528 git clone / pull / checkout \u62C9\u4EE3\u7801\uFF0C\u4E0D\u8981\u81EA\u5DF1\u4E0B\u8F7D\u6E90\u7801\u6216\u624B\u52A8\u89E3\u538B\u8986\u76D6\u6587\u4EF6\u2014\u2014\u9664\u975E\u6CA1\u6709\u4EFB\u4F55\u5B98\u65B9\u6E20\u9053\uFF0C\u5E76\u4E14\u7528\u6237\u540C\u610F\u3002";
3627
+
3628
+ export {
3629
+ EMULATORS_CAPABILITY,
3630
+ EmulatorSettings,
3631
+ SCRIPTS_CAPABILITY,
3632
+ ScriptFamily,
3633
+ ScriptId,
3634
+ GitHubRepo,
3635
+ MirrorRid,
3636
+ ScriptSource,
3637
+ EnvReport,
3638
+ ProjectProbe,
3639
+ LocalVersion,
3640
+ ScriptSummary,
3641
+ SetupAgent,
3642
+ InstallSettings,
3643
+ PACKS_CAPABILITY,
3644
+ BUILTIN_PACK_VERSION,
3645
+ GUARD_CAPABILITY,
3646
+ MONITOR_CAPABILITY,
3647
+ Incident,
3648
+ MonitorSettings,
3649
+ NOTIFY_CAPABILITY,
3650
+ FEISHU_CAPABILITY,
3651
+ QQBOT_CAPABILITY,
3652
+ FEISHU_SECRET_REF,
3653
+ QQBOT_SECRET_REF,
3654
+ FeishuSettings,
3655
+ FeishuPending,
3656
+ QQSettings,
3657
+ QQPending,
3658
+ PIPELINES_CAPABILITY,
3659
+ SCHEDULE_CAPABILITY,
3660
+ PipelineId,
3661
+ ClockTime,
3662
+ isMarker,
3663
+ withStartEnd,
3664
+ PowerAction,
3665
+ Pipeline,
3666
+ PipelineRun,
3667
+ AgentTaskId,
3668
+ AgentTask,
3669
+ AgentTaskRun,
3670
+ INTERVENE_CAPABILITY,
3671
+ GAMES_CAPABILITY,
3672
+ OWN_SOURCE,
3673
+ SCREEN_SOURCE,
3674
+ OWN_IMAGE,
3675
+ SHOT_IMAGE,
3676
+ GamesSettings,
3677
+ PERMISSIONS_CAPABILITY,
3678
+ AreaPolicy,
3679
+ AGENT_AREAS,
3680
+ areaOf,
3681
+ QUESTIONS_CAPABILITY,
3682
+ INSTANCES_CAPABILITY,
3683
+ SKILLS_CAPABILITY,
3684
+ SKILL_NAME,
3685
+ MAX_SKILL_NAME,
3686
+ SKILLHUB_CAPABILITY,
3687
+ BY_YOU,
3688
+ isQuiet,
3689
+ taskMessage,
3690
+ parseTask,
3691
+ threadMessage,
3692
+ parseThreadNote,
3693
+ relayMessage,
3694
+ threadsBetween,
3695
+ parseRelay,
3696
+ threadReminder,
3697
+ reminderPrompts,
3698
+ reminderLine,
3699
+ PERSONA_CAPABILITY,
3700
+ Persona,
3701
+ PersonaSettings,
3702
+ personaOf,
3703
+ personaPrompt,
3704
+ COMPACTION_CAPABILITY,
3705
+ DEFAULT_COMPACTION_THRESHOLD,
3706
+ LOW_CONTEXT_WINDOW_MS,
3707
+ MIN_ARCHIVE_DAYS,
3708
+ MAX_ARCHIVE_DAYS,
3709
+ ARCHIVE_MARK,
3710
+ CompactionSettings,
3711
+ MEMORY_CAPABILITY,
3712
+ SHARED_MEMORY,
3713
+ MemoryKind,
3714
+ MAX_CORE_CHARS,
3715
+ MAX_MEMORY_TEXT,
3716
+ MemoryEntry,
3717
+ RUNS_CAPABILITY,
3718
+ DEEPSEEK_API_KEY,
3719
+ AGENTS_CAPABILITY,
3720
+ ProviderApi,
3721
+ Requests,
3722
+ ErrorCode,
3723
+ RpcError,
3724
+ classify,
3725
+ summarizeToolArgs,
3726
+ optimizeScriptPrompt,
3727
+ expandSlash,
3728
+ parseGitHubLink,
3729
+ UPDATE_RULE
3730
+ };