dsh-multigameassistant 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cordis.patch.yml +5 -9
- package/lib/analyzer.js +22 -12
- package/lib/{chunk-Y3ZZBBLV.js → chunk-4NR36PKL.js} +1 -1
- package/lib/{chunk-TXW3NMBH.js → chunk-7UJ3LK3G.js} +77 -67
- package/lib/{chunk-7EFZ5KR6.js → chunk-BB2T4JHF.js} +74 -5
- package/lib/{chunk-X5YYRNYA.js → chunk-DBOGZLXA.js} +125 -28
- package/lib/{chunk-AJMAUHPI.js → chunk-HRP7ALS6.js} +131 -18
- package/lib/{chunk-VBWSM7LF.js → chunk-OCJFAT7J.js} +668 -115
- package/lib/{chunk-VG32XPZH.js → chunk-SMXJWLAZ.js} +55 -30
- package/lib/emulator.js +19 -3
- package/lib/feishu.js +4 -4
- package/lib/game-intel.js +71 -31
- package/lib/gateway.js +3 -3
- package/lib/guard.js +2 -2
- package/lib/intervene.js +10 -9
- package/lib/low-context.js +2 -2
- package/lib/monitor.js +4 -4
- package/lib/notify.js +4 -4
- package/lib/orchestrator.js +60 -23
- package/lib/qqbot.js +6 -6
- package/lib/runner.js +3 -3
- package/lib/scheduler.js +1 -1
- package/lib/script-registry.js +6 -6
- package/package.json +1 -1
- package/skills/game-intel.md +2 -2
- package/skills/pipeline-planning.md +2 -2
- package/skills/script-analysis.md +11 -7
- package/web/assets/index-7Lrqcs5W.js +257 -0
- package/web/assets/index-7Lrqcs5W.js.map +1 -0
- package/web/assets/index-CCqwfXjF.css +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-CNGPsX3a.css +0 -1
- package/web/assets/index-mX8hPa2E.js +0 -256
- package/web/assets/index-mX8hPa2E.js.map +0 -1
- /package/lib/{chunk-AJMAUHPI.js.LEGAL.txt → chunk-HRP7ALS6.js.LEGAL.txt} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createRequire as __adgCreateRequire } from 'node:module'; import { dirname as __adgDirname } from 'node:path'; import { fileURLToPath as __adgFileURLToPath } from 'node:url'; const require = __adgCreateRequire(import.meta.url); const __filename = __adgFileURLToPath(import.meta.url); const __dirname = __adgDirname(__filename);
|
|
2
2
|
import {
|
|
3
3
|
SUMMARIES_FILE,
|
|
4
|
+
eventText,
|
|
4
5
|
summariesReader
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4NR36PKL.js";
|
|
6
7
|
import {
|
|
7
8
|
writeFileAtomic
|
|
8
9
|
} from "./chunk-RESS7WVY.js";
|
|
@@ -12,12 +13,17 @@ import {
|
|
|
12
13
|
APP_FILES_RULE,
|
|
13
14
|
ARCHIVE_MARK,
|
|
14
15
|
AreaPolicy,
|
|
16
|
+
BRIEF_ALLOW,
|
|
17
|
+
BRIEF_DONE_WHEN,
|
|
18
|
+
BRIEF_LIMITS,
|
|
15
19
|
COMPACTION_CAPABILITY,
|
|
16
20
|
CompactionSettings,
|
|
21
|
+
DECISION_AREAS,
|
|
17
22
|
DEEPSEEK_API_KEY,
|
|
18
23
|
DEFAULT_COMPACTION_THRESHOLD,
|
|
19
24
|
ErrorCode,
|
|
20
25
|
INSTANCES_CAPABILITY,
|
|
26
|
+
MAIN_AGENT_NAME,
|
|
21
27
|
MAX_CORE_CHARS,
|
|
22
28
|
MAX_MEMORY_TEXT,
|
|
23
29
|
MAX_SKILL_NAME,
|
|
@@ -40,11 +46,13 @@ import {
|
|
|
40
46
|
SUMMARY_MAX_TOKENS,
|
|
41
47
|
areaOf,
|
|
42
48
|
classify,
|
|
49
|
+
decisionOf,
|
|
50
|
+
grantsIn,
|
|
43
51
|
personaOf,
|
|
44
52
|
personaPrompt,
|
|
45
53
|
threadsBetween,
|
|
46
54
|
timetableText
|
|
47
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-BB2T4JHF.js";
|
|
48
56
|
import {
|
|
49
57
|
external_exports
|
|
50
58
|
} from "./chunk-6DSSLS7I.js";
|
|
@@ -3726,9 +3734,9 @@ var require_websocket_server = __commonJS({
|
|
|
3726
3734
|
|
|
3727
3735
|
// packages/gateway/lib/index.js
|
|
3728
3736
|
import { execFile as execFile2 } from "node:child_process";
|
|
3729
|
-
import { randomBytes as randomBytes2, randomUUID as
|
|
3730
|
-
import { existsSync, mkdirSync as
|
|
3731
|
-
import { dirname as
|
|
3737
|
+
import { randomBytes as randomBytes2, randomUUID as randomUUID6 } from "node:crypto";
|
|
3738
|
+
import { existsSync, mkdirSync as mkdirSync7, readFileSync as readFileSync4, writeFileSync } from "node:fs";
|
|
3739
|
+
import { dirname as dirname8, join as join9 } from "node:path";
|
|
3732
3740
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
3733
3741
|
import { Service } from "@deepseek-ai/cordis";
|
|
3734
3742
|
|
|
@@ -4272,13 +4280,13 @@ var ApprovalBroker = class {
|
|
|
4272
4280
|
...ask.reason === void 0 ? {} : { reason: ask.reason },
|
|
4273
4281
|
...ask.displayReason === void 0 ? {} : { displayReason: { ...ask.displayReason } }
|
|
4274
4282
|
};
|
|
4275
|
-
return new Promise((
|
|
4283
|
+
return new Promise((resolve5) => {
|
|
4276
4284
|
const onAbort = () => this.settle(approvalId, "cancelled");
|
|
4277
4285
|
this.pending.set(approvalId, {
|
|
4278
4286
|
request,
|
|
4279
4287
|
settle: (outcome) => {
|
|
4280
4288
|
ask.signal?.removeEventListener("abort", onAbort);
|
|
4281
|
-
|
|
4289
|
+
resolve5(outcome);
|
|
4282
4290
|
}
|
|
4283
4291
|
});
|
|
4284
4292
|
ask.signal?.addEventListener("abort", onAbort, { once: true });
|
|
@@ -4430,10 +4438,10 @@ async function importUnchanged(dir, item) {
|
|
|
4430
4438
|
}
|
|
4431
4439
|
async function copyHash(folder) {
|
|
4432
4440
|
const { createHash } = await import("node:crypto");
|
|
4433
|
-
const { readdir:
|
|
4441
|
+
const { readdir: readdir3 } = await import("node:fs/promises");
|
|
4434
4442
|
const files = [];
|
|
4435
4443
|
const walk = async (sub) => {
|
|
4436
|
-
for (const entry of await
|
|
4444
|
+
for (const entry of await readdir3(join(folder, sub), { withFileTypes: true })) {
|
|
4437
4445
|
const rel = sub === "" ? entry.name : `${sub}/${entry.name}`;
|
|
4438
4446
|
if (entry.isDirectory()) {
|
|
4439
4447
|
if (!SKIPPED.test(entry.name))
|
|
@@ -4465,7 +4473,7 @@ function skillSaveTool(deps) {
|
|
|
4465
4473
|
"content \u5199\u6D53\u7F29\u540E\u7684\u505A\u6CD5\uFF1A\u4EC0\u4E48\u65F6\u5019\u7528\uFF1B\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\uFF09\uFF1B\u5224\u65AD\u6210\u529F\u7684\u65B9\u6CD5\uFF1B\u8E29\u8FC7\u7684\u5751\u548C\u6CE8\u610F\u4E8B\u9879\u3002\u4E0D\u5199\u8FD9\u6B21\u5BF9\u8BDD\u7684\u95F2\u804A\u548C\u5931\u8D25\u7684\u5C1D\u8BD5\u8FC7\u7A0B\uFF0C\u53EA\u5199\u6700\u540E\u8D70\u901A\u7684\u8DEF\u3002",
|
|
4466
4474
|
"description \u4E00\u4E24\u53E5\u8BDD\u5199\u6E05\u695A\u300C\u505A\u4EC0\u4E48\u3001\u7528\u6237\u8BF4\u4EC0\u4E48\u65F6\u7528\u300D\uFF0Cagent \u9760\u5B83\u51B3\u5B9A\u4EC0\u4E48\u65F6\u5019\u8C03\u7528\u3002\u5DF2\u6709\u540C\u540D\u6280\u80FD\u65F6\u5148\u7528 replace=true \u624D\u4F1A\u8986\u76D6\u3002",
|
|
4467
4475
|
"\u6280\u80FD\u53EA\u5199\u300C\u600E\u4E48\u505A\u300D\uFF1A\u7528\u6237\u7684\u504F\u597D\u3001\u79F0\u547C\u3001\u7EA6\u5B9A\uFF0C\u548C\u8FD9\u6B21\u505A\u4E86\u4EC0\u4E48\u3001\u5B9A\u4E86\u4EC0\u4E48\uFF0C\u4E0D\u5199\u6210\u6280\u80FD\uFF0C\u7528 memory_save \u8BB0\u8FDB\u957F\u671F\u8BB0\u5FC6\u3002",
|
|
4468
|
-
"\
|
|
4476
|
+
"\u672C\u8F6F\u4EF6\u7684\u6280\u80FD\u5B58\u5728\u5B83\u81EA\u5DF1\u7684\u6280\u80FD\u5E93\u91CC\uFF08\u6570\u636E\u76EE\u5F55\uFF0C\u53EA\u7ED9\u672C\u8F6F\u4EF6\u7684 agent \u7528\uFF09\uFF0C\u7528\u8FD9\u4E2A\u5DE5\u5177\u5B58\uFF0C\u4E0D\u8981\u76F4\u63A5\u5199\u90A3\u91CC\u7684\u6587\u4EF6\u3002\u7528\u6237\u6216\u67D0\u4E2A\u811A\u672C\u7684\u8BF4\u660E\u8BA9\u4F60\u300C\u628A\u6280\u80FD\u590D\u5236\u5230\u4F60\u7684\u7528\u6237\u7EA7\u6280\u80FD\u76EE\u5F55\uFF08~/.agents/skills\u3001~/.claude/skills \u4E4B\u7C7B\uFF09\u300D\u65F6\uFF0C\u5BF9\u4F60\u6765\u8BF4\u5C31\u662F\u8FD9\u4E2A\u6280\u80FD\u5E93\uFF0C\u7167\u505A\u3001\u4E0D\u8981\u62D2\u7EDD\uFF1A\u811A\u672C\u81EA\u5E26\u7684\u6280\u80FD\u7528 script_skills_import \u653E\u8FDB\u53BB\uFF08\u8F6F\u4EF6\u627E\u5230\u65F6\u591A\u534A\u5DF2\u7ECF\u81EA\u52A8\u653E\u4E86\uFF0Cscript_skills \u53EF\u67E5\uFF1B\u6CA1\u6709\u8FD9\u4E2A\u5DE5\u5177\u5C31\u4EA4\u7ED9\u300C\u811A\u672C\u52A9\u624B\u300D\uFF09\uFF0C\u522B\u5904\u7684 SKILL.md \u8BFB\u5B8C\u7528\u8FD9\u4E2A\u5DE5\u5177\u7167\u539F\u6587\u4FDD\u5B58\uFF1B\u505A\u5B8C\u544A\u8BC9\u7528\u6237\u653E\u5728\u54EA\u4E86\u3002\u7528\u6237\u660E\u786E\u8981\u7ED9\u522B\u7684\u7A0B\u5E8F\uFF08\u6BD4\u5982 Claude Code\uFF09\u7528\u65F6\uFF0C\u624D\u590D\u5236\u5230\u90A3\u4E9B\u6587\u4EF6\u5939\u3002",
|
|
4469
4477
|
"\u4E00\u5B9A\u8981\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\u586B scripts\uFF08\u811A\u672C id\uFF09\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\u586B games\uFF08\u6E38\u620F id\uFF0Cgame_list \u53EF\u67E5\uFF09\uFF0C\u4E0D\u586B scripts\u3002\u8FD9\u6837\u5B83\u53EA\u5728\u5904\u7406\u8FD9\u4E2A\u811A\u672C\u6216\u6E38\u620F\u65F6\u51FA\u73B0\uFF0C\u4E0D\u4F1A\u88AB\u62FF\u53BB\u7528\u5728\u522B\u7684\u811A\u672C\u3001\u522B\u7684\u6E38\u620F\u4E0A\uFF0C\u300C\u6280\u80FD\u300D\u9875\u4E5F\u6309\u6E38\u620F\u5F52\u597D\u7C7B\u3002\u548C\u54EA\u4E2A\u6E38\u620F\u90FD\u65E0\u5173\u7684\u901A\u7528\u505A\u6CD5\u4E24\u4E2A\u90FD\u4E0D\u586B\u3002"
|
|
4470
4478
|
].join(""),
|
|
4471
4479
|
parameters: {
|
|
@@ -4492,8 +4500,8 @@ function skillSaveTool(deps) {
|
|
|
4492
4500
|
};
|
|
4493
4501
|
}
|
|
4494
4502
|
async function userSkills(dir) {
|
|
4495
|
-
const { readdir:
|
|
4496
|
-
const entries = await
|
|
4503
|
+
const { readdir: readdir3 } = await import("node:fs/promises");
|
|
4504
|
+
const entries = await readdir3(dir, { withFileTypes: true }).catch(() => []);
|
|
4497
4505
|
const out = [];
|
|
4498
4506
|
for (const entry of entries) {
|
|
4499
4507
|
if (!entry.isDirectory())
|
|
@@ -4541,6 +4549,8 @@ var PROVIDER = "adg";
|
|
|
4541
4549
|
var RANK = 250;
|
|
4542
4550
|
var MAX_SESSIONS = 1e3;
|
|
4543
4551
|
var INVOCABLE = { modelInvocable: true, userInvocable: true };
|
|
4552
|
+
var SHADOWED_SKILLS = ["diagnose-windows-sandbox-acl", "office", "office-docx", "office-pptx", "office-xlsx"];
|
|
4553
|
+
var OFF = { modelInvocable: false, userInvocable: false };
|
|
4544
4554
|
var norm = (value) => value.trim().toLowerCase();
|
|
4545
4555
|
var SkillScope = class {
|
|
4546
4556
|
#skills = /* @__PURE__ */ new Map();
|
|
@@ -4552,6 +4562,7 @@ var SkillScope = class {
|
|
|
4552
4562
|
#invalidate = () => {
|
|
4553
4563
|
};
|
|
4554
4564
|
#relations = () => ({ aliases: [], games: [] });
|
|
4565
|
+
#gameOf = () => void 0;
|
|
4555
4566
|
#loaded;
|
|
4556
4567
|
#saving = Promise.resolve();
|
|
4557
4568
|
log;
|
|
@@ -4571,9 +4582,10 @@ var SkillScope = class {
|
|
|
4571
4582
|
if (session !== void 0 && this.#only?.(session) === false)
|
|
4572
4583
|
return [];
|
|
4573
4584
|
const focus = this.focusOf(session);
|
|
4574
|
-
|
|
4585
|
+
const own2 = [...this.#skills.values()].filter((skill) => focus === void 0 || this.visible(skill.owner, focus)).map(candidate);
|
|
4586
|
+
return [...own2, ...SHADOWED_SKILLS.filter((name) => !this.#skills.has(name)).map(shadow)];
|
|
4575
4587
|
},
|
|
4576
|
-
get: async ({ locator }) => definition(locator)
|
|
4588
|
+
get: async ({ locator }) => typeof locator === "string" ? void 0 : definition(locator)
|
|
4577
4589
|
};
|
|
4578
4590
|
}
|
|
4579
4591
|
/** A sub-agent works on what its parent is working on, until it says otherwise. */
|
|
@@ -4589,8 +4601,17 @@ var SkillScope = class {
|
|
|
4589
4601
|
* What else a script in a focus stands for: its pack's id (the pack's skill
|
|
4590
4602
|
* names that), and the games it plays, whose skills it sees too.
|
|
4591
4603
|
*/
|
|
4592
|
-
resolveScripts(
|
|
4593
|
-
this.#relations =
|
|
4604
|
+
resolveScripts(resolve5) {
|
|
4605
|
+
this.#relations = resolve5;
|
|
4606
|
+
this.#invalidate();
|
|
4607
|
+
}
|
|
4608
|
+
/**
|
|
4609
|
+
* Which game a key names (its id, name or an alias): its id; undefined when no game is known by it.
|
|
4610
|
+
* A skill saved for `starrail` then shows where the focus says 星铁, or 崩坏:星穹铁道 (as a script's
|
|
4611
|
+
* pack names the game it plays). Called again when the games change.
|
|
4612
|
+
*/
|
|
4613
|
+
resolveGames(gameOf) {
|
|
4614
|
+
this.#gameOf = gameOf;
|
|
4594
4615
|
this.#invalidate();
|
|
4595
4616
|
}
|
|
4596
4617
|
/**
|
|
@@ -4671,8 +4692,9 @@ var SkillScope = class {
|
|
|
4671
4692
|
const focusScripts = new Set([...focus.scripts, ...related.flatMap((r) => r.aliases)].map(norm));
|
|
4672
4693
|
if (scripts.some((s) => focusScripts.has(norm(s))))
|
|
4673
4694
|
return true;
|
|
4674
|
-
const
|
|
4675
|
-
|
|
4695
|
+
const game = (key) => norm(this.#gameOf(key) ?? key);
|
|
4696
|
+
const focusGames = new Set([...focus.games, ...related.flatMap((r) => r.games)].map(game));
|
|
4697
|
+
return games.some((g) => focusGames.has(game(g)));
|
|
4676
4698
|
}
|
|
4677
4699
|
async #load() {
|
|
4678
4700
|
if (this.#file === void 0)
|
|
@@ -4711,6 +4733,9 @@ function candidate(skill) {
|
|
|
4711
4733
|
locator: skill
|
|
4712
4734
|
};
|
|
4713
4735
|
}
|
|
4736
|
+
function shadow(name) {
|
|
4737
|
+
return { name, description: "\uFF08\u8FD9\u4E2A\u8F6F\u4EF6\u4E0D\u7528\u8FD9\u4E2A\u6280\u80FD\uFF09", invocation: OFF, source: "adg", provider: PROVIDER, rank: RANK, locator: name };
|
|
4738
|
+
}
|
|
4714
4739
|
function definition(skill) {
|
|
4715
4740
|
return {
|
|
4716
4741
|
name: skill.name,
|
|
@@ -4816,7 +4841,7 @@ var IDENTITY_PROMPT = [
|
|
|
4816
4841
|
"# \u5148\u7528\u811A\u672C\uFF0C\u518D\u7528\u81EA\u5DF1\u7684\u80FD\u529B",
|
|
4817
4842
|
"\u7528\u6237\u8981\u5728\u6E38\u620F\u91CC\u505A\u4E00\u4EF6\u4E8B\uFF08\u5237\u5173\u5361\u3001\u6E05\u4F53\u529B\u3001\u9886\u5956\u52B1\u548C\u90AE\u4EF6\u3001\u505A\u65E5\u5E38\u5468\u5E38\u3001\u6536\u57FA\u5EFA\u3001\u5151\u6362\u5546\u5E97\u3001\u6253\u6D3B\u52A8\u2026\u2026\uFF09\u65F6\uFF0C\u6309\u8FD9\u4E2A\u987A\u5E8F\uFF1A",
|
|
4818
4843
|
"1. \u5148\u770B\u8FD9\u4E2A\u6E38\u620F\u4E0B\u88C5\u4E86\u54EA\u4E9B\u811A\u672C\uFF08script_list\uFF09\uFF0C\u518D\u770B\u5B83\u4EEC\u6709\u6CA1\u6709\u505A\u8FD9\u4EF6\u4E8B\u7684\u4EFB\u52A1\u6216\u9009\u9879\uFF08script_tasks\uFF1B\u8BF4\u4E0D\u6E05\u65F6\u770B\u811A\u672C\u7684\u6280\u80FD\u3001script_help\uFF09\u3002",
|
|
4819
|
-
"2. \u811A\u672C\u80FD\u505A\uFF0C\u5C31\u7528\u811A\u672C\u505A\uFF1A\u8FD0\u884C\u5B83\u5BF9\u5E94\u7684\u4EFB\u52A1\uFF08script_run\uFF0C\u9700\u8981\u65F6\u5148\u6539\u8FD9\u6B21\u8981\u7528\u7684\u914D\u7F6E\uFF09\u3002\u4E0D\u8981\u81EA\u5DF1\u622A\u56FE\u3001\u70B9\u5C4F\u5E55\u53BB\u505A\u811A\u672C\u80FD\u505A\u7684\u4E8B\u3002\u4F60\u81EA\u5DF1\u4E0D\u80FD\u8FD0\u884C\u811A\u672C\u7684\uFF0C\u4EA4\u7ED9\u80FD\u8FD0\u884C\u7684\u540C\u4E8B\uFF08\u300C\u811A\u672C\
|
|
4844
|
+
"2. \u811A\u672C\u80FD\u505A\uFF0C\u5C31\u7528\u811A\u672C\u505A\uFF1A\u8FD0\u884C\u5B83\u5BF9\u5E94\u7684\u4EFB\u52A1\uFF08script_run\uFF0C\u9700\u8981\u65F6\u5148\u6539\u8FD9\u6B21\u8981\u7528\u7684\u914D\u7F6E\uFF09\u3002\u4E0D\u8981\u81EA\u5DF1\u622A\u56FE\u3001\u70B9\u5C4F\u5E55\u53BB\u505A\u811A\u672C\u80FD\u505A\u7684\u4E8B\u3002\u4F60\u81EA\u5DF1\u4E0D\u80FD\u8FD0\u884C\u811A\u672C\u7684\uFF0C\u4EA4\u7ED9\u80FD\u8FD0\u884C\u7684\u540C\u4E8B\uFF08\u300C\u811A\u672C\u52A9\u624B\u300D\uFF09\uFF0C\u628A\u8981\u8DD1\u54EA\u4E2A\u811A\u672C\u7684\u54EA\u4E2A\u4EFB\u52A1\u5199\u6E05\u695A\u3002",
|
|
4820
4845
|
"3. \u53EA\u6709\u786E\u8BA4\u811A\u672C\u505A\u4E0D\u4E86\uFF0C\u624D\u7528\u4F60\u81EA\u5DF1\u7684\u80FD\u529B\uFF08\u622A\u56FE\u70B9\u51FB\u3001\u547D\u4EE4\u884C\uFF09\u53BB\u505A\uFF1A\u88C5\u7740\u7684\u811A\u672C\u90FD\u6CA1\u6709\u8FD9\u4E2A\u529F\u80FD\uFF1B\u6216\u8005\u811A\u672C\u8DD1\u4E86\u5931\u8D25\u3001\u4FEE\u4E0D\u597D\u3002\u52A8\u624B\u524D\u7528\u4E00\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u4E3A\u4EC0\u4E48\u4E0D\u7528\u811A\u672C\u3002",
|
|
4821
4846
|
"4. \u6709\u80FD\u505A\u8FD9\u4EF6\u4E8B\u7684\u811A\u672C\u4F46\u8FD8\u6CA1\u88C5\uFF1A\u5148\u544A\u8BC9\u7528\u6237\u662F\u54EA\u4E2A\u811A\u672C\u3001\u95EE\u8981\u4E0D\u8981\u88C5\uFF0C\u4E0D\u8981\u4E0D\u95EE\u5C31\u81EA\u5DF1\u70B9\u3002"
|
|
4822
4847
|
].join("\n");
|
|
@@ -4872,6 +4897,10 @@ var PersonaStore = class {
|
|
|
4872
4897
|
return next;
|
|
4873
4898
|
}
|
|
4874
4899
|
};
|
|
4900
|
+
function voicedPrompt(persona) {
|
|
4901
|
+
return persona === "" ? "" : `${persona}
|
|
4902
|
+
\u8FD9\u4E00\u8F6E\u7684\u56DE\u590D\u4F1A\u539F\u6837\u53D1\u7ED9\u7528\u6237\uFF08\u4E0D\u662F\u4EA4\u56DE\u7ED9 agent \u7684\u7ED3\u8BBA\uFF09\uFF1A\u6574\u7BC7\u6309\u4E0A\u9762\u5BF9\u7528\u6237\u8BF4\u8BDD\u7684\u65B9\u5F0F\u5199\u3002`;
|
|
4903
|
+
}
|
|
4875
4904
|
|
|
4876
4905
|
// packages/gateway/lib/time-context.js
|
|
4877
4906
|
import { randomUUID } from "node:crypto";
|
|
@@ -5150,6 +5179,9 @@ function looksSecret(text) {
|
|
|
5150
5179
|
}
|
|
5151
5180
|
return false;
|
|
5152
5181
|
}
|
|
5182
|
+
function maskSecrets(text) {
|
|
5183
|
+
return text.replace(/((?:密码|口令|验证码|动态码|password|passwd|passcode|pwd|token|api[\s_-]?key|secret|私钥|cookie)\s*(?:是|为|[::=])\s*)[^\s,。;、!?,;!?))」'"]{4,}/gi, "$1***").replace(/\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|AKIA[0-9A-Z]{16}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}(?:\.[A-Za-z0-9_-]+)?)/g, "***").replace(/[A-Za-z0-9+/_=-]{32,}/g, (blob) => !/^[0-9a-f]+$/i.test(blob) && /[a-z]/.test(blob) && /[A-Z]/.test(blob) && /[0-9]/.test(blob) ? "***" : blob);
|
|
5184
|
+
}
|
|
5153
5185
|
var SECRET_REFUSAL = "\u8FD9\u6761\u50CF\u662F\u5BC6\u7801\u3001\u9A8C\u8BC1\u7801\u6216\u5BC6\u94A5\uFF1A\u8FD9\u7C7B\u4E1C\u897F\u4E0D\u5199\u8FDB\u8BB0\u5FC6\uFF08\u7528\u6237\u8BA9\u8BB0\u4E5F\u4E0D\u8BB0\uFF09\u3002\u628A\u5B83\u53BB\u6389\u518D\u8BB0\uFF0C\u6216\u8005\u544A\u8BC9\u7528\u6237\u4E3A\u4EC0\u4E48\u4E0D\u8BB0\u3002";
|
|
5154
5186
|
var MemoryStore = class {
|
|
5155
5187
|
#file;
|
|
@@ -5711,6 +5743,10 @@ var MemoryViews = class {
|
|
|
5711
5743
|
const known = this.#known(view);
|
|
5712
5744
|
return new Set([...known].flatMap(([id, line2]) => line2 === null ? [] : [id]));
|
|
5713
5745
|
}
|
|
5746
|
+
/** An agent's memory section as it is now, for something it writes outside any conversation (nothing pinned). */
|
|
5747
|
+
current(owner) {
|
|
5748
|
+
return this.#render(owner, void 0, this.#now());
|
|
5749
|
+
}
|
|
5714
5750
|
#render(owner, lead, now) {
|
|
5715
5751
|
return memoryPrompt(this.#store.visibleTo(owner), owner, { now: new Date(now), ...this.#timeZone === void 0 ? {} : { timeZone: this.#timeZone }, ...lead === void 0 ? {} : { lead } });
|
|
5716
5752
|
}
|
|
@@ -6407,8 +6443,344 @@ var AutoMemory = class {
|
|
|
6407
6443
|
}
|
|
6408
6444
|
};
|
|
6409
6445
|
|
|
6410
|
-
// packages/gateway/lib/
|
|
6446
|
+
// packages/gateway/lib/history-export.js
|
|
6447
|
+
import { mkdir as mkdir5, readdir, writeFile as writeFile4 } from "node:fs/promises";
|
|
6448
|
+
import { isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "node:path";
|
|
6449
|
+
var EXPORT_DEPTH = 2e4;
|
|
6450
|
+
var Args3 = external_exports.object({
|
|
6451
|
+
path: external_exports.string().trim().min(1),
|
|
6452
|
+
since: external_exports.string().trim().min(1),
|
|
6453
|
+
until: external_exports.string().trim().min(1).nullish(),
|
|
6454
|
+
session_id: external_exports.string().nullish(),
|
|
6455
|
+
with_agents: external_exports.boolean().nullish(),
|
|
6456
|
+
parts: external_exports.array(external_exports.string()).nullish()
|
|
6457
|
+
});
|
|
6458
|
+
function parseWhen(text, now) {
|
|
6459
|
+
const t = text.trim().replace(/\//g, "-");
|
|
6460
|
+
if (/(z|[+-]\d{2}:?\d{2})$/i.test(t)) {
|
|
6461
|
+
const at = Date.parse(t);
|
|
6462
|
+
if (!Number.isNaN(at))
|
|
6463
|
+
return at;
|
|
6464
|
+
}
|
|
6465
|
+
const full = /^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T](\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(t);
|
|
6466
|
+
if (full !== null) {
|
|
6467
|
+
const [, y, mo, d, h = "0", mi = "0", s = "0"] = full;
|
|
6468
|
+
return new Date(Number(y), Number(mo) - 1, Number(d), Number(h), Number(mi), Number(s)).getTime();
|
|
6469
|
+
}
|
|
6470
|
+
const time = /^(?:(今天|今日|today|昨天|昨日|yesterday)\s*的?\s*)?(\d{1,2})[::](\d{2})(?:[::](\d{2}))?$/i.exec(t);
|
|
6471
|
+
if (time !== null) {
|
|
6472
|
+
const day2 = new Date(now);
|
|
6473
|
+
const back = /^(昨|yesterday)/i.test(time[1] ?? "") ? 1 : 0;
|
|
6474
|
+
return new Date(day2.getFullYear(), day2.getMonth(), day2.getDate() - back, Number(time[2]), Number(time[3]), Number(time[4] ?? 0)).getTime();
|
|
6475
|
+
}
|
|
6476
|
+
throw new Error(`\u770B\u4E0D\u61C2\u8FD9\u4E2A\u65F6\u95F4\uFF1A${text}\uFF08\u5199\u6210 2026-11-29 15:00\uFF1B\u4ECA\u5929\u7684\u53EF\u4EE5\u53EA\u5199 15:00\uFF09`);
|
|
6477
|
+
}
|
|
6478
|
+
function clock2(time, timeZone, seconds = false) {
|
|
6479
|
+
const parts = new Intl.DateTimeFormat("en-CA", { timeZone, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", ...seconds ? { second: "2-digit" } : {}, hourCycle: "h23" }).formatToParts(new Date(time));
|
|
6480
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
|
|
6481
|
+
return `${get("year")}-${get("month")}-${get("day")} ${get("hour")}:${get("minute")}${seconds ? `:${get("second")}` : ""}`;
|
|
6482
|
+
}
|
|
6483
|
+
async function freshFolder(path) {
|
|
6484
|
+
for (let n = 1; n < 1e3; n++) {
|
|
6485
|
+
const candidate2 = n === 1 ? path : `${path}-${n}`;
|
|
6486
|
+
const entries = await readdir(candidate2).catch((error) => error.code === "ENOENT" ? null : Promise.reject(error));
|
|
6487
|
+
if (entries === null || entries.length === 0) {
|
|
6488
|
+
await mkdir5(candidate2, { recursive: true });
|
|
6489
|
+
return candidate2;
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
throw new Error(`${path} \u65C1\u8FB9\u5DF2\u7ECF\u6709\u592A\u591A\u5BFC\u51FA\u4E86\uFF0C\u6362\u4E2A\u6587\u4EF6\u5939`);
|
|
6493
|
+
}
|
|
6494
|
+
function chatMarkdown(said, names, timeZone, mask) {
|
|
6495
|
+
return said.map((s) => `### ${s.from === "user" ? names.user : s.from === "agent" ? names.agent : names.app} \xB7 ${clock2(s.time, timeZone, true)}
|
|
6496
|
+
|
|
6497
|
+
${mask(s.text)}
|
|
6498
|
+
`).join("\n");
|
|
6499
|
+
}
|
|
6500
|
+
function historyExportTool(deps) {
|
|
6501
|
+
const render4 = (_args, value) => [{ type: "text", text: JSON.stringify(value, null, 1) }];
|
|
6502
|
+
return {
|
|
6503
|
+
name: "history_export",
|
|
6504
|
+
description: [
|
|
6505
|
+
"\u628A\u4E00\u6BB5\u65F6\u95F4\u91CC\u7684\u804A\u5929\u8BB0\u5F55\u548C\u76F8\u5173\u65E5\u5FD7\u5BFC\u51FA\u5230\u7528\u6237\u6307\u5B9A\u7684\u6587\u4EF6\u5939\uFF1A\u7528\u6237\u8BF4\u300C\u628A\u4ECA\u5929\u4E0B\u5348\u4E09\u70B9\u4E4B\u540E\u7684\u65E5\u5FD7\u548C\u804A\u5929\u8BB0\u5F55\u653E\u5230\u67D0\u4E2A\u6587\u4EF6\u5939\u300D\u65F6\u7528\u5B83\uFF0C\u4E00\u6B21\u8C03\u7528\u5C31\u505A\u5B8C\uFF0C\u4E0D\u8981\u81EA\u5DF1\u53BB\u7FFB\u8F6F\u4EF6\u7684\u6570\u636E\u76EE\u5F55\u548C\u4F1A\u8BDD\u6587\u4EF6\u3002",
|
|
6506
|
+
"\u804A\u5929\u8BB0\u5F55\u662F\u8FD9\u4E2A\u5BF9\u8BDD\u91CC\u7528\u6237\u548C\u4F60\u8BF4\u7684\u8BDD\uFF08with_agents \u4E3A true \u65F6\u4E5F\u5E26\u4E0A\u8F6F\u4EF6\u548C\u5176\u4ED6 agent \u53D1\u6765\u7684\u6D88\u606F\uFF09\uFF0C\u4E0D\u542B\u7CFB\u7EDF\u63D0\u793A\u3001\u6280\u80FD\u76EE\u5F55\u3001\u5DE5\u5177\u8C03\u7528\u548C\u538B\u7F29\u6458\u8981\uFF1B",
|
|
6507
|
+
"\u518D\u52A0\u4E0A\u8F6F\u4EF6\u5176\u4ED6\u90E8\u5206\u5728\u8FD9\u6BB5\u65F6\u95F4\u7684\u8BB0\u5F55\uFF08parts\uFF0C\u9ED8\u8BA4\u5168\u90E8\uFF0C\u4F8B\u5982 runs\uFF1A\u811A\u672C\u8FD0\u884C\u65E5\u5FD7\uFF09\u3002\u5BC6\u7801\u3001\u9A8C\u8BC1\u7801\u3001\u5BC6\u94A5\u4F1A\u906E\u76D6\u3002",
|
|
6508
|
+
"path \u5199\u7528\u6237\u6307\u5B9A\u7684\u6587\u4EF6\u5939\uFF08\u5B8C\u6574\u8DEF\u5F84\uFF09\uFF1A\u5DF2\u7ECF\u6709\u4E1C\u897F\u65F6\u4F1A\u53E6\u5EFA <\u6587\u4EF6\u5939>-2\uFF0C\u4E0D\u4F1A\u8986\u76D6\uFF1B\u4E0D\u80FD\u5199\u8FDB\u811A\u672C\u76EE\u5F55\u6216\u672C\u8F6F\u4EF6\u81EA\u5DF1\u7684\u76EE\u5F55\u3002\u7528\u6237\u6CA1\u8BF4\u653E\u54EA\u5C31\u5148\u95EE\u3002"
|
|
6509
|
+
].join(""),
|
|
6510
|
+
parameters: {
|
|
6511
|
+
type: "object",
|
|
6512
|
+
properties: {
|
|
6513
|
+
path: { type: "string", description: "\u5BFC\u51FA\u5230\u54EA\u4E2A\u6587\u4EF6\u5939\uFF08\u5B8C\u6574\u8DEF\u5F84\uFF09\u3002" },
|
|
6514
|
+
since: { type: "string", description: "\u4ECE\u4EC0\u4E48\u65F6\u5019\u8D77\uFF08\u672C\u673A\u65F6\u95F4\uFF09\uFF1A\u5199\u6210 2026-11-29 15:00\uFF1B\u4ECA\u5929\u7684\u53EF\u4EE5\u53EA\u5199 15:00\u3002" },
|
|
6515
|
+
until: { type: "string", description: "\u5230\u4EC0\u4E48\u65F6\u5019\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u73B0\u5728\uFF09\u3002" },
|
|
6516
|
+
session_id: { type: "string", description: "\u54EA\u4E2A\u5BF9\u8BDD\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u8FD9\u4E2A\u5BF9\u8BDD\uFF1B\u53EA\u80FD\u662F\u4F60\u81EA\u5DF1\u7684\u5BF9\u8BDD\uFF09\u3002" },
|
|
6517
|
+
with_agents: { type: "boolean", description: "\u4E5F\u5BFC\u51FA\u8F6F\u4EF6\u548C\u5176\u4ED6 agent \u53D1\u6765\u7684\u6D88\u606F\uFF08\u4EA4\u56DE\u7684\u7ED3\u679C\u3001\u901A\u77E5\uFF09\uFF0C\u9ED8\u8BA4\u53EA\u5BFC\u51FA\u7528\u6237\u548C\u4F60\u8BF4\u7684\u8BDD\u3002" },
|
|
6518
|
+
parts: { type: "array", items: { type: "string" }, description: "\u8FD8\u5BFC\u51FA\u54EA\u4E9B\u8BB0\u5F55\uFF08\u9ED8\u8BA4\u5168\u90E8\uFF1B[] \u53EA\u5BFC\u51FA\u804A\u5929\u8BB0\u5F55\uFF09\u3002" }
|
|
6519
|
+
},
|
|
6520
|
+
required: ["path", "since"],
|
|
6521
|
+
additionalProperties: false
|
|
6522
|
+
},
|
|
6523
|
+
output: { schema: {}, render: render4 },
|
|
6524
|
+
timeoutMs: 12e4,
|
|
6525
|
+
isConcurrencySafe: () => false,
|
|
6526
|
+
execute: async (args, exec) => {
|
|
6527
|
+
const parsed = Args3.safeParse(args ?? {});
|
|
6528
|
+
if (!parsed.success)
|
|
6529
|
+
throw new Error(`\u53C2\u6570\u65E0\u6548\uFF1A${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}`);
|
|
6530
|
+
const a = parsed.data;
|
|
6531
|
+
const session = exec.agent?.session.id;
|
|
6532
|
+
const agent = session === void 0 ? void 0 : deps.agentOf(session);
|
|
6533
|
+
if (session === void 0 || agent === void 0)
|
|
6534
|
+
throw new Error("\u53EA\u6709\u672C\u8F6F\u4EF6\u7684 agent \u80FD\u5BFC\u51FA\u5BF9\u8BDD\u8BB0\u5F55");
|
|
6535
|
+
const signal = exec.signal ?? new AbortController().signal;
|
|
6536
|
+
const now = deps.now?.() ?? Date.now();
|
|
6537
|
+
const since = parseWhen(a.since, now);
|
|
6538
|
+
const until = a.until == null ? now : parseWhen(a.until, now);
|
|
6539
|
+
if (until <= since)
|
|
6540
|
+
throw new Error("\u7ED3\u675F\u65F6\u95F4\u8981\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4");
|
|
6541
|
+
if (!isAbsolute2(a.path))
|
|
6542
|
+
throw new Error("path \u8981\u5199\u5B8C\u6574\u8DEF\u5F84\uFF08\u4F8B\u5982 D:\\\u5BFC\u51FA\\\u804A\u5929\u8BB0\u5F55\uFF09");
|
|
6543
|
+
const target = a.session_id ?? session;
|
|
6544
|
+
if (target !== session && !(await deps.sessions(agent, signal)).some((s) => s.id === target))
|
|
6545
|
+
throw new Error(`\u6CA1\u6709\u8FD9\u4E2A\u5BF9\u8BDD\uFF1A${target}\uFF08\u53EA\u80FD\u5BFC\u51FA\u4F60\u81EA\u5DF1\u7684\u5BF9\u8BDD\uFF09`);
|
|
6546
|
+
const known = deps.parts();
|
|
6547
|
+
const wanted = a.parts == null ? known : known.filter((p) => a.parts.includes(p.name));
|
|
6548
|
+
const unknown = (a.parts ?? []).filter((n) => !known.some((p) => p.name === n));
|
|
6549
|
+
if (unknown.length > 0)
|
|
6550
|
+
throw new Error(`\u6CA1\u6709\u8FD9\u4E9B\u8BB0\u5F55\uFF1A${unknown.join("\u3001")}\uFF08\u6709\uFF1A${known.map((p) => `${p.name}\uFF08${p.title}\uFF09`).join("\u3001") || "\u6CA1\u6709"}\uFF09`);
|
|
6551
|
+
const said = saidIn(await deps.read(target, EXPORT_DEPTH, signal)).filter((s) => s.time >= since && s.time < until && s.summary !== true && (a.with_agents === true || s.from !== "app"));
|
|
6552
|
+
const folder = await freshFolder(resolve2(a.path));
|
|
6553
|
+
const files = [];
|
|
6554
|
+
const put = async (name, text) => {
|
|
6555
|
+
await writeFile4(join6(folder, name), text, "utf8");
|
|
6556
|
+
files.push({ path: name, bytes: Buffer.byteLength(text) });
|
|
6557
|
+
};
|
|
6558
|
+
const range = `${clock2(since, deps.timeZone)} \uFF5E ${clock2(until, deps.timeZone)}`;
|
|
6559
|
+
const agentName = deps.nameOf(agent);
|
|
6560
|
+
await put("\u804A\u5929\u8BB0\u5F55.md", `# \u804A\u5929\u8BB0\u5F55\uFF08${range}\uFF09
|
|
6561
|
+
|
|
6562
|
+
${said.length === 0 ? "\u8FD9\u6BB5\u65F6\u95F4\u8FD9\u4E2A\u5BF9\u8BDD\u91CC\u6CA1\u6709\u6D88\u606F\u3002\n" : chatMarkdown(said, { user: "\u7528\u6237", agent: agentName, app: "\u8F6F\u4EF6/\u5176\u4ED6 agent" }, deps.timeZone, maskSecrets)}`);
|
|
6563
|
+
const done = [];
|
|
6564
|
+
for (const part of wanted) {
|
|
6565
|
+
signal.throwIfAborted();
|
|
6566
|
+
try {
|
|
6567
|
+
const r = await part.write({ since, until }, join6(folder, part.name), { mask: maskSecrets, signal });
|
|
6568
|
+
done.push({ name: part.name, title: part.title, ...r });
|
|
6569
|
+
} catch (error) {
|
|
6570
|
+
done.push({ name: part.name, title: part.title, files: 0, summary: `\u6CA1\u5BFC\u51FA\uFF1A${error instanceof Error ? error.message : String(error)}` });
|
|
6571
|
+
}
|
|
6572
|
+
}
|
|
6573
|
+
const count = (from) => said.filter((s) => s.from === from).length;
|
|
6574
|
+
await put("README.md", [
|
|
6575
|
+
`# \u5BFC\u51FA\uFF1A${range}`,
|
|
6576
|
+
"",
|
|
6577
|
+
`- \u65F6\u95F4\u8303\u56F4\uFF1A${range}\uFF08${deps.timeZone ?? "\u672C\u673A\u65F6\u533A"}\uFF09`,
|
|
6578
|
+
`- \u5BF9\u8BDD\uFF1A${agentName}${target === session ? "\uFF08\u5BFC\u51FA\u65F6\u6240\u5728\u7684\u5BF9\u8BDD\uFF09" : `\uFF08${target}\uFF09`}`,
|
|
6579
|
+
`- \u804A\u5929\u8BB0\u5F55\uFF1A\u7528\u6237 ${count("user")} \u6761\uFF0C${agentName} ${count("agent")} \u6761${a.with_agents === true ? `\uFF0C\u8F6F\u4EF6/\u5176\u4ED6 agent ${count("app")} \u6761` : ""}\uFF08\u804A\u5929\u8BB0\u5F55.md\uFF09`,
|
|
6580
|
+
...done.map((p) => `- ${p.title}\uFF1A${p.summary}${p.files > 0 ? `\uFF08${p.name}/\uFF0C${p.files} \u4E2A\u6587\u4EF6\uFF09` : ""}`),
|
|
6581
|
+
"- \u4E0D\u542B\uFF1A\u7CFB\u7EDF\u63D0\u793A\u3001\u6280\u80FD\u76EE\u5F55\u3001\u65F6\u95F4\u548C\u8BB0\u5FC6\u7684\u6CE8\u5165\u3001\u5DE5\u5177\u8C03\u7528\u548C\u7ED3\u679C\u3001\u9690\u85CF\u7684\u601D\u8003\u3001\u4E0A\u4E0B\u6587\u538B\u7F29\u6458\u8981\u3002",
|
|
6582
|
+
"- \u5BC6\u7801\u3001\u9A8C\u8BC1\u7801\u3001\u5BC6\u94A5\u4E4B\u7C7B\u5DF2\u906E\u76D6\u4E3A ***\u3002",
|
|
6583
|
+
""
|
|
6584
|
+
].join("\n"));
|
|
6585
|
+
return {
|
|
6586
|
+
folder,
|
|
6587
|
+
chat: { user: count("user"), agent: count("agent"), ...a.with_agents === true ? { app: count("app") } : {} },
|
|
6588
|
+
parts: done,
|
|
6589
|
+
files: files.map((f) => f.path),
|
|
6590
|
+
note: folder === resolve2(a.path) ? "\u5BFC\u51FA\u597D\u4E86\uFF1A\u544A\u8BC9\u7528\u6237\u653E\u5728\u54EA\u3001\u6709\u54EA\u4E9B\u6587\u4EF6\u3002" : `${a.path} \u91CC\u5DF2\u7ECF\u6709\u4E1C\u897F\uFF0C\u5BFC\u51FA\u653E\u5728\u4E86 ${folder}\uFF0C\u6CA1\u6709\u8986\u76D6\u539F\u6765\u7684\uFF1A\u544A\u8BC9\u7528\u6237\u3002`
|
|
6591
|
+
};
|
|
6592
|
+
},
|
|
6593
|
+
presentCall: (args) => ({ card: "generic", title: `\u5BFC\u51FA\u804A\u5929\u8BB0\u5F55\u548C\u65E5\u5FD7\uFF1A${String(args?.path ?? "")}`, kind: "execute" })
|
|
6594
|
+
};
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
// packages/gateway/lib/changes.js
|
|
6598
|
+
import { mkdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
6599
|
+
import { dirname as dirname2 } from "node:path";
|
|
6411
6600
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
6601
|
+
var HELD_FOR_MS = 7 * 24 * 60 * 6e4;
|
|
6602
|
+
var MAX_KEPT = 300;
|
|
6603
|
+
var HeldChanges = class {
|
|
6604
|
+
#items = /* @__PURE__ */ new Map();
|
|
6605
|
+
#file;
|
|
6606
|
+
#now;
|
|
6607
|
+
#saving = Promise.resolve();
|
|
6608
|
+
constructor(file, now = Date.now) {
|
|
6609
|
+
this.#file = file;
|
|
6610
|
+
this.#now = now;
|
|
6611
|
+
if (file === void 0)
|
|
6612
|
+
return;
|
|
6613
|
+
try {
|
|
6614
|
+
const saved = JSON.parse(readFileSync3(file, "utf8"));
|
|
6615
|
+
if (Array.isArray(saved)) {
|
|
6616
|
+
for (const item of saved)
|
|
6617
|
+
if (typeof item?.id === "string" && item.state === "held")
|
|
6618
|
+
this.#items.set(item.id, item);
|
|
6619
|
+
}
|
|
6620
|
+
} catch {
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
hold(input) {
|
|
6624
|
+
const change = {
|
|
6625
|
+
id: `c-${randomUUID3().slice(0, 6)}`,
|
|
6626
|
+
tool: input.tool,
|
|
6627
|
+
args: input.args,
|
|
6628
|
+
area: input.area.id,
|
|
6629
|
+
areaTitle: input.area.title,
|
|
6630
|
+
summary: summarize(input.args),
|
|
6631
|
+
from: input.from,
|
|
6632
|
+
lead: input.lead,
|
|
6633
|
+
at: this.#now(),
|
|
6634
|
+
state: "held"
|
|
6635
|
+
};
|
|
6636
|
+
this.#items.set(change.id, change);
|
|
6637
|
+
while (this.#items.size > MAX_KEPT)
|
|
6638
|
+
this.#items.delete(this.#items.keys().next().value);
|
|
6639
|
+
this.#save();
|
|
6640
|
+
return change;
|
|
6641
|
+
}
|
|
6642
|
+
/** The undecided changes a lead's conversation (or another of the same agent's, `sameAgent`) holds, oldest first. */
|
|
6643
|
+
waiting(lead, sameAgent = (a, b) => a === b) {
|
|
6644
|
+
const since = this.#now() - HELD_FOR_MS;
|
|
6645
|
+
return [...this.#items.values()].filter((c) => c.state === "held" && c.at >= since && sameAgent(c.lead, lead));
|
|
6646
|
+
}
|
|
6647
|
+
get(id) {
|
|
6648
|
+
return this.#items.get(id);
|
|
6649
|
+
}
|
|
6650
|
+
/** Resolves once what was held or decided so far is on disk. */
|
|
6651
|
+
saved() {
|
|
6652
|
+
return this.#saving;
|
|
6653
|
+
}
|
|
6654
|
+
settle(id, state, outcome) {
|
|
6655
|
+
const change = this.#items.get(id);
|
|
6656
|
+
if (change === void 0)
|
|
6657
|
+
return;
|
|
6658
|
+
this.#items.set(id, { ...change, state, outcome });
|
|
6659
|
+
this.#save();
|
|
6660
|
+
}
|
|
6661
|
+
#save() {
|
|
6662
|
+
const file = this.#file;
|
|
6663
|
+
if (file === void 0)
|
|
6664
|
+
return;
|
|
6665
|
+
const items = [...this.#items.values()].filter((c) => c.state === "held");
|
|
6666
|
+
this.#saving = this.#saving.then(async () => {
|
|
6667
|
+
mkdirSync(dirname2(file), { recursive: true });
|
|
6668
|
+
await writeFileAtomic(file, `${JSON.stringify(items)}
|
|
6669
|
+
`);
|
|
6670
|
+
}).catch(() => {
|
|
6671
|
+
});
|
|
6672
|
+
}
|
|
6673
|
+
};
|
|
6674
|
+
function summarize(args) {
|
|
6675
|
+
const short = (value) => {
|
|
6676
|
+
if (typeof value === "string")
|
|
6677
|
+
return value.length > 80 ? `\u300C${value.slice(0, 60).replace(/\s+/g, " ")}\u2026\u300D\uFF08${value.length} \u5B57\uFF09` : value;
|
|
6678
|
+
const json = JSON.stringify(value) ?? String(value);
|
|
6679
|
+
return json.length > 120 ? `${json.slice(0, 100)}\u2026\uFF08${json.length} \u5B57\uFF09` : json;
|
|
6680
|
+
};
|
|
6681
|
+
const text = Object.entries(args).filter(([, v]) => v !== void 0 && v !== null && v !== "").map(([k, v]) => `${k}=${short(v)}`).join("\uFF0C");
|
|
6682
|
+
return text.length > 300 ? `${text.slice(0, 299)}\u2026` : text;
|
|
6683
|
+
}
|
|
6684
|
+
function heldNote(change) {
|
|
6685
|
+
return [
|
|
6686
|
+
`\u6CA1\u6709\u6267\u884C\uFF1A\u8FD9\u662F\u8981\u4E0A\u7EA7\u51B3\u5B9A\u7684\u6539\u52A8\uFF08${change.areaTitle}\uFF09\uFF0C\u8F6F\u4EF6\u5DF2\u7ECF\u8BB0\u6210\u5F85\u5B9A\u6539\u52A8 ${change.id}\u3002`,
|
|
6687
|
+
"\u4E0D\u4F9D\u8D56\u5B83\u7684\u90E8\u5206\u63A5\u7740\u505A\uFF1B\u4F9D\u8D56\u5B83\u7684\u540E\u7EED\u6B65\u9AA4\u5148\u4E0D\u505A\u3002\u4EA4\u56DE\u65F6\u5728\u300C\u9700\u8981\u51B3\u5B9A\u7684\u300D\u91CC\u5199\u4E0A\u8FD9\u4E2A\u7F16\u53F7\u3001\u6539\u4EC0\u4E48\u3001\u4E3A\u4EC0\u4E48\u3002",
|
|
6688
|
+
"\u4E0D\u8981\u6362\u522B\u7684\u529E\u6CD5\u53BB\u505A\uFF08\u6539\u6587\u4EF6\u3001\u547D\u4EE4\u884C\u3001\u518D\u8C03\u4E00\u6B21\uFF09\uFF1A\u4E0A\u7EA7\u51B3\u5B9A\u4EE5\u540E\u4F1A\u66FF\u4F60\u6267\u884C\u3002"
|
|
6689
|
+
].join("");
|
|
6690
|
+
}
|
|
6691
|
+
var Args4 = external_exports.object({
|
|
6692
|
+
action: external_exports.enum(["list", "apply", "discard"]),
|
|
6693
|
+
ids: external_exports.array(external_exports.string().trim().min(1)).max(20).nullish(),
|
|
6694
|
+
id: external_exports.string().trim().min(1).nullish(),
|
|
6695
|
+
reason: external_exports.string().trim().max(500).nullish()
|
|
6696
|
+
});
|
|
6697
|
+
var MAX_FULL = 2e4;
|
|
6698
|
+
var MAX_OUTCOME = 600;
|
|
6699
|
+
var render3 = (_args, value) => [{ type: "text", text: typeof value === "string" ? value : JSON.stringify(value, null, 1) }];
|
|
6700
|
+
var clip2 = (text, max) => text.length > max ? `${text.slice(0, max - 1)}\u2026` : text;
|
|
6701
|
+
var show = (value) => clip2(typeof value === "string" ? value : JSON.stringify(value) ?? String(value), MAX_OUTCOME);
|
|
6702
|
+
function pendingChangesTool(deps) {
|
|
6703
|
+
const sameAgent = deps.sameAgent ?? ((a, b) => a === b);
|
|
6704
|
+
return {
|
|
6705
|
+
name: "pending_changes",
|
|
6706
|
+
description: [
|
|
6707
|
+
"\u5F85\u5B9A\u6539\u52A8\uFF1A\u4F60\u7684\u5B50 agent \u8981\u505A\u3001\u4F46\u8981\u4F60\u51B3\u5B9A\u7684\u6539\u52A8\uFF08\u5B89\u88C5\u3001\u66F4\u65B0\u3001\u5220\u9664\u811A\u672C\uFF0C\u5199\u811A\u672C\u5305\uFF0C\u6539\u811A\u672C\u914D\u7F6E\uFF0C\u6539\u6D41\u6C34\u7EBF\u548C\u5B9A\u65F6\uFF0C\u5B58\u6280\u80FD\uFF0C\u52A0\u6E38\u620F\u6216\u65E5\u5E38\u5468\u5E38\uFF09\uFF0C\u8F6F\u4EF6\u66FF\u5B83\u8BB0\u4E0B\u3001\u6CA1\u6709\u6267\u884C\uFF1B\u5B50 agent \u4EA4\u56DE\u65F6\u4F1A\u5728\u300C\u9700\u8981\u51B3\u5B9A\u7684\u300D\u91CC\u5199\u4E0A\u7F16\u53F7\u3002",
|
|
6708
|
+
"action=list \u5217\u51FA\u8FD8\u6CA1\u51B3\u5B9A\u7684\uFF08\u5E26 id \u770B\u8FD9\u4E00\u6761\u7684\u5B8C\u6574\u53C2\u6570\uFF09\uFF1Bapply \u6309 ids \u7684\u987A\u5E8F\u6267\u884C\uFF0C\u7ED3\u679C\u9010\u6761\u8FD4\u56DE\uFF1Bdiscard \u653E\u5F03\uFF0Creason \u5199\u4E3A\u4EC0\u4E48\u3002",
|
|
6709
|
+
"\u7528\u6237\u5DF2\u7ECF\u660E\u786E\u8981\u8FD9\u6837\u6539\u7684\uFF08\u4EA4\u7ED9\u4F60\u7684\u4E8B\u5C31\u662F\u8FD9\u4E2A\uFF09\uFF0C\u76F4\u63A5 apply\uFF1B\u7528\u6237\u6CA1\u8BF4\u8FC7\u7684\u3001\u6536\u4E0D\u56DE\u7684\uFF08\u5220\u811A\u672C\u3001\u5220\u8BB0\u5F55\uFF09\uFF0C\u5148\u95EE\u7528\u6237\uFF1B\u6CA1\u4EBA\u53EF\u95EE\uFF08\u8F6F\u4EF6\u81EA\u52A8\u4EA4\u7ED9\u4F60\u7684\u4E8B\uFF09\u65F6\u6309\u4F60\u7684\u5224\u65AD\uFF0C\u5728\u7ED3\u8BBA\u91CC\u8BF4\u660E\u3002"
|
|
6710
|
+
].join(""),
|
|
6711
|
+
parameters: {
|
|
6712
|
+
type: "object",
|
|
6713
|
+
properties: {
|
|
6714
|
+
action: { type: "string", enum: ["list", "apply", "discard"], description: "list \u770B\uFF1Bapply \u6267\u884C\uFF1Bdiscard \u653E\u5F03\u3002" },
|
|
6715
|
+
ids: { type: "array", items: { type: "string" }, description: "apply\u3001discard\uFF1A\u5F85\u5B9A\u6539\u52A8\u7684\u7F16\u53F7\uFF08c-\u2026\uFF09\u3002" },
|
|
6716
|
+
id: { type: "string", description: "list\uFF1A\u770B\u8FD9\u4E00\u6761\u7684\u5B8C\u6574\u53C2\u6570\uFF08\u53EF\u9009\uFF09\u3002" },
|
|
6717
|
+
reason: { type: "string", description: "discard\uFF1A\u4E3A\u4EC0\u4E48\u4E0D\u505A\u3002" }
|
|
6718
|
+
},
|
|
6719
|
+
required: ["action"],
|
|
6720
|
+
additionalProperties: false
|
|
6721
|
+
},
|
|
6722
|
+
output: { schema: {}, render: render3 },
|
|
6723
|
+
// Applying runs other tools one after another, in the order given.
|
|
6724
|
+
isConcurrencySafe: () => false,
|
|
6725
|
+
execute: async (args, exec) => {
|
|
6726
|
+
const parsed = Args4.safeParse(args ?? {});
|
|
6727
|
+
if (!parsed.success)
|
|
6728
|
+
throw new Error(`\u53C2\u6570\u65E0\u6548\uFF1A${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}`);
|
|
6729
|
+
const { action, ids, id, reason } = parsed.data;
|
|
6730
|
+
const lead = exec.agent?.session?.id;
|
|
6731
|
+
if (lead === void 0)
|
|
6732
|
+
throw new Error("\u53EA\u80FD\u5728\u4F1A\u8BDD\u91CC\u7528");
|
|
6733
|
+
const mine = (change) => change !== void 0 && sameAgent(change.lead, lead);
|
|
6734
|
+
if (action === "list") {
|
|
6735
|
+
if (id) {
|
|
6736
|
+
const change = deps.store.get(id);
|
|
6737
|
+
if (!mine(change))
|
|
6738
|
+
throw new Error(`\u6CA1\u6709\u8FD9\u4E00\u6761\u5F85\u5B9A\u6539\u52A8\uFF1A${id}`);
|
|
6739
|
+
return { id: change.id, state: change.state, tool: change.tool, kind: change.areaTitle, args: clip2(JSON.stringify(change.args, null, 1), MAX_FULL) };
|
|
6740
|
+
}
|
|
6741
|
+
const waiting = deps.store.waiting(lead, sameAgent);
|
|
6742
|
+
if (waiting.length === 0)
|
|
6743
|
+
return { waiting: [], note: "\u6CA1\u6709\u5F85\u5B9A\u6539\u52A8\u3002" };
|
|
6744
|
+
return { waiting: waiting.map((c) => ({ id: c.id, kind: c.areaTitle, tool: c.tool, summary: c.summary })) };
|
|
6745
|
+
}
|
|
6746
|
+
if (!ids || ids.length === 0)
|
|
6747
|
+
throw new Error(`${action} \u8981\u5199 ids`);
|
|
6748
|
+
const changes = ids.map((want) => deps.store.get(want));
|
|
6749
|
+
const unknown = ids.filter((_, i) => !mine(changes[i]));
|
|
6750
|
+
if (unknown.length > 0)
|
|
6751
|
+
throw new Error(`\u6CA1\u6709\u8FD9\u4E9B\u5F85\u5B9A\u6539\u52A8\uFF1A${unknown.join("\u3001")}`);
|
|
6752
|
+
const decided = changes.filter((c) => c.state !== "held");
|
|
6753
|
+
if (decided.length > 0)
|
|
6754
|
+
throw new Error(`\u8FD9\u4E9B\u5DF2\u7ECF\u51B3\u5B9A\u8FC7\u4E86\uFF1A${decided.map((c) => `${c.id}\uFF08${c.state}\uFF09`).join("\u3001")}`);
|
|
6755
|
+
if (action === "discard") {
|
|
6756
|
+
for (const change of changes)
|
|
6757
|
+
deps.store.settle(change.id, "discarded", reason ?? "");
|
|
6758
|
+
return { discarded: ids };
|
|
6759
|
+
}
|
|
6760
|
+
const results = [];
|
|
6761
|
+
for (const change of changes) {
|
|
6762
|
+
try {
|
|
6763
|
+
const value = await deps.run(change.tool, change.args, exec);
|
|
6764
|
+
deps.store.settle(change.id, "applied", show(value));
|
|
6765
|
+
results.push({ id: change.id, tool: change.tool, ok: true, result: show(value) });
|
|
6766
|
+
} catch (error) {
|
|
6767
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
6768
|
+
deps.store.settle(change.id, "failed", why);
|
|
6769
|
+
results.push({ id: change.id, tool: change.tool, ok: false, result: clip2(why, MAX_OUTCOME) });
|
|
6770
|
+
}
|
|
6771
|
+
}
|
|
6772
|
+
return { applied: results };
|
|
6773
|
+
},
|
|
6774
|
+
presentCall: (args) => {
|
|
6775
|
+
const a = args ?? {};
|
|
6776
|
+
const ids = Array.isArray(a.ids) ? a.ids.join("\u3001") : "";
|
|
6777
|
+
return { card: "generic", title: a.action === "apply" ? `\u6267\u884C\u5F85\u5B9A\u6539\u52A8\uFF1A${ids}` : a.action === "discard" ? `\u653E\u5F03\u5F85\u5B9A\u6539\u52A8\uFF1A${ids}` : "\u770B\u5F85\u5B9A\u6539\u52A8", kind: a.action === "list" ? "other" : "execute" };
|
|
6778
|
+
}
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6781
|
+
|
|
6782
|
+
// packages/gateway/lib/recall.js
|
|
6783
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
6412
6784
|
var RECALL_SOURCE = "adg-recall";
|
|
6413
6785
|
var MAX_RECALLED = 5;
|
|
6414
6786
|
var MAX_RECALL_CHARS = 1500;
|
|
@@ -6461,7 +6833,7 @@ function recallText(entries, agentId, timeZone) {
|
|
|
6461
6833
|
}
|
|
6462
6834
|
function recallMessage(text, ids) {
|
|
6463
6835
|
return Object.freeze({
|
|
6464
|
-
id:
|
|
6836
|
+
id: randomUUID4(),
|
|
6465
6837
|
role: "user",
|
|
6466
6838
|
content: Object.freeze([Object.freeze({ type: "text", text })]),
|
|
6467
6839
|
source: Object.freeze({ kind: RECALL_SOURCE, form: "snapshot", ids: Object.freeze([...ids]), sections: Object.freeze([Object.freeze({ name: RECALL_SOURCE, text })]) })
|
|
@@ -6944,14 +7316,14 @@ var QuestionBroker = class {
|
|
|
6944
7316
|
...q.multiSelect === void 0 ? {} : { multiSelect: q.multiSelect }
|
|
6945
7317
|
}))
|
|
6946
7318
|
};
|
|
6947
|
-
return new Promise((
|
|
7319
|
+
return new Promise((resolve5, reject) => {
|
|
6948
7320
|
const onAbort = () => this.settle(questionId, "cancelled");
|
|
6949
7321
|
this.pending.set(questionId, {
|
|
6950
7322
|
request,
|
|
6951
7323
|
settle: (outcome, answer) => {
|
|
6952
7324
|
ask.signal?.removeEventListener("abort", onAbort);
|
|
6953
7325
|
if (outcome === "answered" && answer !== void 0)
|
|
6954
|
-
|
|
7326
|
+
resolve5(answer);
|
|
6955
7327
|
else
|
|
6956
7328
|
reject(new QuestionClosed(outcome === "answered" ? "unavailable" : outcome));
|
|
6957
7329
|
}
|
|
@@ -7418,8 +7790,8 @@ function builtinCapabilities(deps) {
|
|
|
7418
7790
|
|
|
7419
7791
|
// packages/gateway/lib/homes.js
|
|
7420
7792
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
7421
|
-
import { mkdirSync } from "node:fs";
|
|
7422
|
-
import { dirname as
|
|
7793
|
+
import { mkdirSync as mkdirSync2 } from "node:fs";
|
|
7794
|
+
import { dirname as dirname3 } from "node:path";
|
|
7423
7795
|
var AgentHomes = class {
|
|
7424
7796
|
#file;
|
|
7425
7797
|
#homes = /* @__PURE__ */ new Map();
|
|
@@ -7451,7 +7823,7 @@ var AgentHomes = class {
|
|
|
7451
7823
|
async #save() {
|
|
7452
7824
|
if (this.#file === void 0)
|
|
7453
7825
|
return;
|
|
7454
|
-
|
|
7826
|
+
mkdirSync2(dirname3(this.#file), { recursive: true });
|
|
7455
7827
|
await writeFileAtomic(this.#file, `${JSON.stringify(Object.fromEntries(this.#homes), null, 2)}
|
|
7456
7828
|
`);
|
|
7457
7829
|
}
|
|
@@ -7469,7 +7841,7 @@ var AgentHomes = class {
|
|
|
7469
7841
|
}
|
|
7470
7842
|
}
|
|
7471
7843
|
};
|
|
7472
|
-
var
|
|
7844
|
+
var MAX_KEPT2 = 500;
|
|
7473
7845
|
var HandOffs = class {
|
|
7474
7846
|
#file;
|
|
7475
7847
|
#items = /* @__PURE__ */ new Map();
|
|
@@ -7506,7 +7878,7 @@ var HandOffs = class {
|
|
|
7506
7878
|
await this.loaded;
|
|
7507
7879
|
this.#items.delete(item.id);
|
|
7508
7880
|
this.#items.set(item.id, item);
|
|
7509
|
-
while (this.#items.size >
|
|
7881
|
+
while (this.#items.size > MAX_KEPT2)
|
|
7510
7882
|
this.#items.delete(this.#items.keys().next().value);
|
|
7511
7883
|
this.#changed(item);
|
|
7512
7884
|
for (const listener of this.#listeners) {
|
|
@@ -7520,7 +7892,7 @@ var HandOffs = class {
|
|
|
7520
7892
|
async #save() {
|
|
7521
7893
|
if (this.#file === void 0)
|
|
7522
7894
|
return;
|
|
7523
|
-
|
|
7895
|
+
mkdirSync2(dirname3(this.#file), { recursive: true });
|
|
7524
7896
|
await writeFileAtomic(this.#file, `${JSON.stringify([...this.#items.values()])}
|
|
7525
7897
|
`);
|
|
7526
7898
|
}
|
|
@@ -7705,21 +8077,45 @@ function plain(markdown) {
|
|
|
7705
8077
|
|
|
7706
8078
|
// packages/gateway/lib/roles.js
|
|
7707
8079
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
7708
|
-
import { mkdirSync as
|
|
7709
|
-
import { dirname as
|
|
8080
|
+
import { mkdirSync as mkdirSync3 } from "node:fs";
|
|
8081
|
+
import { dirname as dirname4 } from "node:path";
|
|
7710
8082
|
function keeps(tools, name) {
|
|
7711
8083
|
return tools === void 0 || matches(tools, name);
|
|
7712
8084
|
}
|
|
7713
8085
|
function matches(patterns, name) {
|
|
7714
8086
|
return patterns.some((pattern) => pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern);
|
|
7715
8087
|
}
|
|
7716
|
-
var NOBODY = ["subagent_fork", "wait_agent"];
|
|
8088
|
+
var NOBODY = ["subagent_fork", "wait_agent", "plugin_manager", "present", "create_goal", "update_goal", "get_goal", "list_subagent_models"];
|
|
7717
8089
|
var TOGETHER = ["agent_delegate", "agent_message", "agent_threads"];
|
|
7718
8090
|
var MEMORY_TOOLS = ["memory_save", "memory_forget", "memory_search", "history_search", "history_read"];
|
|
7719
|
-
var
|
|
7720
|
-
var
|
|
8091
|
+
var DECIDING = ["pending_changes"];
|
|
8092
|
+
var ALWAYS = [...TOGETHER, ...MEMORY_TOOLS, ...DECIDING];
|
|
8093
|
+
var COORDINATION = [
|
|
8094
|
+
"agent_delegate",
|
|
8095
|
+
"agent_message",
|
|
8096
|
+
"agent_threads",
|
|
8097
|
+
"notice_act",
|
|
8098
|
+
"ask_user_question",
|
|
8099
|
+
"exit_plan_mode",
|
|
8100
|
+
"subagent",
|
|
8101
|
+
"list_agents",
|
|
8102
|
+
"interrupt_agent",
|
|
8103
|
+
"schedule_create",
|
|
8104
|
+
"schedule_list",
|
|
8105
|
+
"schedule_view",
|
|
8106
|
+
"schedule_edit",
|
|
8107
|
+
"schedule_task_*",
|
|
8108
|
+
"intervention_done",
|
|
8109
|
+
"memory_save",
|
|
8110
|
+
"memory_forget",
|
|
8111
|
+
// Its conversation is its parent's task: what it would export is not the user's chat.
|
|
8112
|
+
"history_export",
|
|
8113
|
+
// Its lasting changes are decided above it.
|
|
8114
|
+
"pending_changes"
|
|
8115
|
+
];
|
|
8116
|
+
var LIGHT = ["pipeline_run", "script_run", "script_stop", "game_launch", "game_close", "emulator_start", "emulator_stop"];
|
|
7721
8117
|
var HANDS_ON = [
|
|
7722
|
-
...AGENT_AREAS.filter((area) => ["run", "scripts-config", "scripts-install", "screen", "games", "shell"].includes(area.id)).flatMap((area) => area.tools).filter((tool) => tool
|
|
8118
|
+
...AGENT_AREAS.filter((area) => ["run", "scripts-config", "scripts-install", "screen", "games", "shell"].includes(area.id)).flatMap((area) => area.tools).filter((tool) => !LIGHT.includes(tool)),
|
|
7723
8119
|
// Screenshots are not in an area (they change nothing), and they weigh the most.
|
|
7724
8120
|
"screen_*",
|
|
7725
8121
|
// The built-in browser: every step answers with the whole page.
|
|
@@ -7727,14 +8123,26 @@ var HANDS_ON = [
|
|
|
7727
8123
|
// Runs a program that calls the tools: the same work, by another door.
|
|
7728
8124
|
"workflow"
|
|
7729
8125
|
];
|
|
8126
|
+
var AT_HOME = ["job_*", "todo_write"];
|
|
7730
8127
|
var HANDS_ON_REFUSAL = (tool) => `${tool} \u8FD9\u7C7B\u5177\u4F53\u64CD\u4F5C\u4E0D\u5728\u4F60\u7684\u5BF9\u8BDD\u91CC\u505A\uFF1A\u7528 subagent \u5F00\u4E00\u4E2A\u5B50 agent \u53BB\u505A\uFF0C\u628A\u4EFB\u52A1\u5199\u5B8C\u6574\uFF08\u5B83\u770B\u4E0D\u5230\u4F60\u7684\u5BF9\u8BDD\uFF09\uFF0C\u5B83\u53EA\u628A\u7ED3\u679C\u4EA4\u56DE\u6765\u3002\u8981\u7528\u6237\u6279\u51C6\u7684\u64CD\u4F5C\uFF0C\u5B83\u505A\u7684\u65F6\u5019\u540C\u6837\u4F1A\u8BF7\u7528\u6237\u6279\u51C6\u3002`;
|
|
7731
8128
|
function handsOn(tool) {
|
|
7732
8129
|
return matches(HANDS_ON, tool);
|
|
7733
8130
|
}
|
|
7734
8131
|
function hiddenTools(spec, appTools, visible, home = false) {
|
|
7735
|
-
const hide = [...NOBODY, ...spec.hide ?? [], ...home ? HANDS_ON : []];
|
|
8132
|
+
const hide = [...NOBODY, ...spec.hide ?? [], ...home ? [...HANDS_ON, ...AT_HOME] : []];
|
|
7736
8133
|
return [...visible].filter((name) => matches(hide, name) || appTools.has(name) && !keeps(spec.tools, name) && !ALWAYS.includes(name));
|
|
7737
8134
|
}
|
|
8135
|
+
var REPORT_SHAPE = [
|
|
8136
|
+
"\u7ED3\u8BBA\uFF1A\u505A\u6210\u4E86\u6CA1\u6709\uFF0C\u4E00\u4E24\u53E5\u3002",
|
|
8137
|
+
"\u8BC1\u636E\uFF1A\u80FD\u6838\u5BF9\u7684\u4E1C\u897F\u2014\u2014\u8FD0\u884C id\u3001\u65E5\u5FD7\u539F\u6587\u3001\u6539\u4E86\u54EA\u4E9B\u8BBE\u7F6E\u6216\u6587\u4EF6\u3001\u7ED3\u679C\u72B6\u6001\u3001\u51FA\u5904\u3002",
|
|
8138
|
+
"\u6CA1\u505A\u6210\u7684\u548C\u539F\u56E0\uFF1A",
|
|
8139
|
+
"\u9700\u8981\u51B3\u5B9A\u7684\uFF1A\u8981\u4E0A\u7EA7\u6216\u7528\u6237\u51B3\u5B9A\u7684\u4E8B\uFF08\u8D8A\u8FC7\u8FB9\u754C\u7684\u3001\u6536\u4E0D\u56DE\u7684\u3001\u60C5\u51B5\u4E0D\u660E\u7684\uFF09\uFF0C\u8F6F\u4EF6\u8BB0\u4E0B\u7684\u5F85\u5B9A\u6539\u52A8\u5199\u4E0A\u7F16\u53F7\uFF08c-\u2026\uFF09\u3001\u6539\u4EC0\u4E48\u3001\u4E3A\u4EC0\u4E48\u3002"
|
|
8140
|
+
].join("\n");
|
|
8141
|
+
var BRIEFING = [
|
|
8142
|
+
`\u5F00\u5B50 agent \u65F6\uFF0Cprompt \u5199\u8FD9\u51E0\u9879\uFF1A\u76EE\u6807\uFF08\u8981\u505A\u6210\u4EC0\u4E48\u6837\uFF0C\u52A0\u4E0A\u4F60\u5DF2\u7ECF\u77E5\u9053\u7684\u60C5\u51B5\uFF1A\u54EA\u4E2A\u6E38\u620F\u6216\u811A\u672C\u3001\u8FD0\u884C id\u3001\u7528\u6237\u539F\u8BDD\uFF09\u3001${BRIEF_LIMITS}\uFF08\u54EA\u4E9B\u4E0D\u80FD\u52A8\u3001\u505A\u5230\u54EA\u4E00\u6B65\u4E3A\u6B62\uFF09\u3001${BRIEF_DONE_WHEN}\uFF08\u600E\u6837\u7B97\u505A\u5B8C\uFF09\u3001\u5E26\u56DE\uFF08\u8981\u5B83\u4EA4\u56DE\u7684\u8BC1\u636E\uFF1A\u8FD0\u884C id\u3001\u65E5\u5FD7\u539F\u6587\u3001\u6539\u4E86\u4EC0\u4E48\uFF09\u3002\u4E0D\u5199\u4E00\u6B65\u6B65\u600E\u4E48\u505A\uFF1A\u7528\u4EC0\u4E48\u5DE5\u5177\u3001\u600E\u4E48\u505A\u7531\u5B83\u51B3\u5B9A\uFF0C\u5B83\u770B\u5F97\u5230\u81EA\u5DF1\u5168\u90E8\u5DE5\u5177\u7684\u8BF4\u660E\u3002`,
|
|
8143
|
+
`\u5B50 agent \u505A\u4F1A\u7559\u4E0B\u6765\u3001\u6536\u4E0D\u56DE\u7684\u6539\u52A8\uFF08${DECISION_AREAS.map((a) => a.title).join("\uFF1B")}\uFF09\u65F6\uFF0C\u8F6F\u4EF6\u4E0D\u66FF\u5B83\u6267\u884C\uFF0C\u5148\u8BB0\u6210\u5F85\u5B9A\u6539\u52A8\u4EA4\u56DE\u7ED9\u4F60\uFF0C\u4F60\u7528 pending_changes \u51B3\u5B9A\uFF1A\u7528\u6237\u5DF2\u7ECF\u660E\u786E\u8981\u8FD9\u6837\u6539\u7684\u76F4\u63A5 apply\uFF0C\u7528\u6237\u6CA1\u8BF4\u8FC7\u7684\u3001\u6536\u4E0D\u56DE\u7684\u5148\u95EE\u7528\u6237\uFF0C\u6CA1\u4EBA\u53EF\u95EE\u65F6\u6309\u4F60\u7684\u5224\u65AD\u5E76\u5728\u7ED3\u8BBA\u91CC\u8BF4\u660E\u3002\u7528\u6237\u5DF2\u7ECF\u660E\u786E\u8981\u5B83\u505A\u7684\u90A3\u7C7B\u6539\u52A8\uFF0C\u5728 prompt \u91CC\u52A0\u4E00\u884C\u300C${BRIEF_ALLOW}\uFF1A\u2026\u300D\u5199\u4E0A\u7C7B\u522B\uFF08\u4E0A\u9762\u5206\u53F7\u9694\u5F00\u7684\u90A3\u51E0\u7C7B\uFF09\uFF0C\u5B83\u5C31\u76F4\u63A5\u505A\uFF0C\u4E0D\u7528\u518D\u4EA4\u56DE\u6765\u3002`,
|
|
8144
|
+
`\u5B83\u4EA4\u56DE\u540E\uFF0C\u6309${BRIEF_DONE_WHEN}\u6838\u5BF9\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\uFF1A\u7528\u770B\u7684\u5DE5\u5177\u770B\u4E00\u773C\uFF08\u8FD0\u884C id \u7528 script_run_log\uFF0C\u6587\u4EF6\u7528 read\uFF09\uFF0C\u4E0D\u8981\u81EA\u5DF1\u91CD\u505A\u4E00\u904D\uFF1B\u5BF9\u4E0D\u4E0A\u5C31\u7528 send_message \u8BA9\u5B83\u8865\uFF0C\u6216\u8005\u7167\u5B9E\u8BF4\u6CA1\u505A\u6210\u3002\u60C5\u51B5\u4E0D\u660E\u3001\u6216\u8005\u8981\u505A\u6536\u4E0D\u56DE\u7684\u4E8B\uFF08\u5220\u3001\u88C5\u3001\u6539\u8BBE\u7F6E\uFF09\u65F6\uFF0C\u5148\u8BA9\u5B83\u67E5\u6E05\u695A\u4EA4\u56DE\uFF0C\u4F60\u51B3\u5B9A\u4EE5\u540E\u518D\u8BA9\u5B83\u505A\u3002`
|
|
8145
|
+
].join("\n");
|
|
7738
8146
|
function subAgentSpec(parent) {
|
|
7739
8147
|
const name = parent.name;
|
|
7740
8148
|
return {
|
|
@@ -7748,7 +8156,10 @@ function subAgentSpec(parent) {
|
|
|
7748
8156
|
duty: [
|
|
7749
8157
|
`# \u4F60\u7684\u89D2\u8272\uFF1A\u300C${name}\u300D\u7684\u5B50 agent`,
|
|
7750
8158
|
`\u4F60\u662F\u300C${name}\u300D\u5F00\u7684\u5B50 agent\uFF0C\u53EA\u505A\u5B83\u4EA4\u7ED9\u4F60\u7684\u8FD9\u4E00\u4EF6\u4E8B\u3002\u5B83\u7684\u4EFB\u52A1\u5C31\u662F\u4F60\u6536\u5230\u7684\u7B2C\u4E00\u6761\u6D88\u606F\uFF1B\u4F60\u770B\u4E0D\u5230\u5B83\u548C\u522B\u4EBA\u7684\u5BF9\u8BDD\u3002`,
|
|
7751
|
-
`\
|
|
8159
|
+
`\u4EFB\u52A1\u5199\u4E86\u300C${BRIEF_LIMITS}\u300D\u300C${BRIEF_DONE_WHEN}\u300D\u7684\uFF0C\u7167\u7740\u505A\uFF1A\u8D8A\u8FC7\u8FB9\u754C\u7684\u4E8B\u4E0D\u505A\uFF0C\u5199\u8FDB\u300C\u9700\u8981\u51B3\u5B9A\u7684\u300D\uFF1B\u505A\u5230\u5B8C\u6210\u6807\u51C6\u5C31\u505C\uFF0C\u4E0D\u591A\u505A\u3002\u600E\u4E48\u505A\u3001\u7528\u4EC0\u4E48\u5DE5\u5177\u7531\u4F60\u51B3\u5B9A\u3002`,
|
|
8160
|
+
`\u4F1A\u7559\u4E0B\u6765\u3001\u6536\u4E0D\u56DE\u7684\u6539\u52A8\uFF08${DECISION_AREAS.map((a) => a.title).join("\uFF1B")}\uFF09\u7531\u300C${name}\u300D\u51B3\u5B9A\uFF1A\u4EFB\u52A1\u91CC\u300C${BRIEF_ALLOW}\u300D\u6CA1\u5199\u5230\u7684\u90A3\u7C7B\uFF08\u7528\u6237\u5728\u8F6F\u4EF6\u91CC\u70B9\u7684\u4E8B\u4E0D\u7B97\uFF0C\u90FD\u53EF\u4EE5\u76F4\u63A5\u505A\uFF09\uFF0C\u4F60\u8C03\u7528\u65F6\u8F6F\u4EF6\u53EA\u8BB0\u6210\u5F85\u5B9A\u6539\u52A8\u3001\u4E0D\u6267\u884C\uFF0C\u4F60\u628A\u7F16\u53F7\u5199\u8FDB\u4EA4\u56DE\u5C31\u884C\uFF1B\u8981\u5148\u6709\u5B83\u624D\u80FD\u505A\u7684\u540E\u7EED\u6B65\u9AA4\uFF0C\u7559\u5230\u51B3\u5B9A\u4EE5\u540E\u3002`,
|
|
8161
|
+
`\u4F60\u7684\u56DE\u590D\u53EA\u6709\u300C${name}\u300D\u8BFB\uFF0C\u7528\u6237\u770B\u4E0D\u5230\uFF1A\u7528\u5DE5\u5177\u628A\u4E8B\u505A\u5B8C\uFF0C\u6700\u540E\u4E00\u6BB5\u56DE\u590D\u6309\u4E0B\u9762\u51E0\u9879\u5199\uFF08\u6CA1\u6709\u7684\u5199\u300C\u65E0\u300D\uFF09\uFF0C\u4E0D\u5BD2\u6684\uFF1A`,
|
|
8162
|
+
REPORT_SHAPE,
|
|
7752
8163
|
`\u4F60\u95EE\u4E0D\u4E86\u7528\u6237\uFF0C\u4E5F\u4E0D\u80FD\u4EA4\u7ED9\u522B\u7684 agent\uFF1A\u7F3A\u4EC0\u4E48\u5C31\u5199\u8FDB\u56DE\u590D\uFF0C\u7531\u300C${name}\u300D\u53BB\u95EE\u3002\u9700\u8981\u7528\u6237\u6279\u51C6\u7684\u64CD\u4F5C\u4F1A\u8BF7\u7528\u6237\u6279\u51C6\uFF0C\u7B49\u7ED3\u679C\u5C31\u662F\uFF1B\u88AB\u62D2\u7EDD\u4E86\u4E0D\u8981\u6362\u4E2A\u529E\u6CD5\u7ED5\u8FC7\u53BB\uFF0C\u628A\u6CA1\u505A\u6210\u7684\u548C\u539F\u56E0\u5199\u8FDB\u56DE\u590D\u3002`,
|
|
7753
8164
|
"\u80FD\u7528\u5DE5\u5177\u3001\u547D\u4EE4\u884C\u3001\u8BFB\u6587\u4EF6\uFF08\u914D\u7F6E\u3001\u65E5\u5FD7\u3001\u7248\u672C\u53F7\uFF09\u6216\u811A\u672C\u81EA\u5DF1\u7684\u547D\u4EE4\u548C\u8BBE\u7F6E\u505A\u5230\u3001\u786E\u8BA4\u5230\u7684\uFF0C\u5C31\u8FD9\u6837\u505A\uFF1B\u622A\u56FE\u3001\u770B\u753B\u9762\u3001\u70B9\u5C4F\u5E55\u662F\u6700\u540E\u7684\u529E\u6CD5\u3002",
|
|
7754
8165
|
// Only where the parent's tools take the browser in (and it may be missing: dsh's own app has none).
|
|
@@ -7767,7 +8178,8 @@ function teamPrompt(self, main, leads, options = {}) {
|
|
|
7767
8178
|
isMain ? `\u4F60\u662F\u300C${self.name}\u300D\uFF08${self.id}\uFF09\uFF0C\u662F\u6700\u4E0A\u7EA7\u7684 agent\uFF1A\u548C\u7528\u6237\u5BF9\u8BDD\uFF0C\u628A\u4E8B\u5206\u7ED9\u4E0B\u9762\u7684\u4E3B agent\uFF0C\u6C47\u603B\u7ED3\u679C\u5E76\u505A\u51B3\u5B9A\u3002` : `\u4F60\u662F\u300C${self.name}\u300D\uFF08${self.id}\uFF09\uFF0C\u662F\u4E00\u4E2A\u4E3B agent\uFF1A\u8D1F\u8D23\u81EA\u5DF1\u8FD9\u5757\u4E8B\uFF0C\u505A\u51B3\u5B9A\u3001\u6C47\u603B\u7ED3\u679C\u3002\u4E0A\u7EA7\u662F${who(main)}\uFF1A\u5B83\u548C\u7528\u6237\u5BF9\u8BDD\u3001\u5206\u53D1\u4EFB\u52A1\u3001\u505A\u51B3\u5B9A\u3002`,
|
|
7768
8179
|
colleagues.length === 0 ? isMain ? "\u73B0\u5728\u6CA1\u6709\u5176\u4ED6\u4E3B agent\u3002" : "\u73B0\u5728\u6CA1\u6709\u5176\u4ED6\u540C\u4E8B\u3002" : `${isMain ? "\u4E0B\u9762\u7684\u4E3B agent" : "\u540C\u4E8B"}\uFF1A
|
|
7769
8180
|
${colleagues.map(line2).join("\n")}`,
|
|
7770
|
-
"\u5177\u4F53\u7684\u6D3B\u90FD\u7531\u5B50 agent \u505A\uFF08subagent\uFF09\uFF1A\u8FD0\u884C\u547D\u4EE4\u3001\u6539\u6587\u4EF6\u3001\u622A\u56FE\u70B9\u51FB\u3001\
|
|
8181
|
+
"\u5177\u4F53\u7684\u6D3B\u90FD\u7531\u5B50 agent \u505A\uFF08subagent\uFF09\uFF1A\u8FD0\u884C\u547D\u4EE4\u3001\u6539\u6587\u4EF6\u3001\u622A\u56FE\u70B9\u51FB\u3001\u5B89\u88C5\u811A\u672C\u3001\u6539\u8BBE\u7F6E\uFF0C\u8FD9\u4E9B\u5DE5\u5177\u4E0D\u5728\u4F60\u7684\u5BF9\u8BDD\u91CC\uFF0C\u53EA\u6709\u5B50 agent \u6709\uFF1B\u522B\u5904\u63D0\u5230\u8FD9\u4E9B\u5DE5\u5177\uFF0C\u4E5F\u662F\u8BA9\u5B50 agent \u53BB\u7528\u3002\u4F60\u7684\u5BF9\u8BDD\u7559\u7ED9\u5224\u65AD\u548C\u6C47\u603B\uFF1A\u8981\u505A\u4EC0\u4E48\u5C31\u5F00\u4E00\u4E2A\u5B50 agent\uFF08\u5B83\u770B\u4E0D\u5230\u4F60\u7684\u5BF9\u8BDD\uFF09\uFF0C\u7ED3\u679C\u4EA4\u56DE\u540E\u7531\u4F60\u5224\u65AD\u3001\u6C47\u603B\u3002\u67E5\u72B6\u6001\u3001\u8BFB\u4E00\u4E0B\u6587\u4EF6\u8FD9\u79CD\u770B\u4E00\u773C\u7684\u4E8B\u53EF\u4EE5\u81EA\u5DF1\u6765\uFF1B\u4E00\u6B21\u8C03\u7528\u5C31\u505A\u5B8C\u3001\u5728\u522B\u5904\u8FD0\u884C\u7684\u5C0F\u4E8B\u4E5F\u81EA\u5DF1\u505A\uFF0C\u4E0D\u7528\u5F00\u5B50 agent\uFF1A\u542F\u52A8\u6216\u505C\u6B62\u4E00\u4E2A\u811A\u672C\u4EFB\u52A1\uFF08script_run\u3001script_stop\uFF09\u3001\u8FD0\u884C\u6D41\u6C34\u7EBF\u3001\u6253\u5F00\u6216\u5173\u6389\u6E38\u620F\u548C\u6A21\u62DF\u5668\u2014\u2014\u4F60\u7684\u5DE5\u5177\u91CC\u6709\u7684\u8BDD\u3002\u51E0\u4EF6\u4E92\u4E0D\u76F8\u5173\u7684\u4E8B\u53EF\u4EE5\u540C\u65F6\u5F00\u3002\u6D3E\u53D1\u540E\u53EF\u4EE5\u7EE7\u7EED\u5176\u4ED6\u5DE5\u4F5C\uFF1B\u53EA\u5269\u5B50\u4EFB\u52A1\u672A\u4EA4\u4ED8\u65F6\u5C31\u7ED3\u675F\u5F53\u524D\u8F6E\u6B21\u3002\u5B50\u4EFB\u52A1\u5B8C\u6210\u3001\u5931\u8D25\u6216\u88AB\u505C\u6B62\u65F6\uFF0C\u7CFB\u7EDF\u4F1A\u81EA\u52A8\u628A\u5E26\u6709\u5B50\u4EFB\u52A1\u8EAB\u4EFD\u7684\u7EC8\u6001\u548C\u7ED3\u679C\u9001\u5230\u4F60\u7684\u5BF9\u8BDD\u3002\u6536\u5230\u56DE\u6267\u5C31\u76F4\u63A5\u7528\u5B83\u7EE7\u7EED\u5DE5\u4F5C\uFF1B\u591A\u4E2A\u5B50\u4EFB\u52A1\u5206\u522B\u4EA4\u4ED8\uFF0C\u6309\u5404\u81EA\u7684\u56DE\u6267\u5904\u7406\u3002\u8981\u7B49\u4E00\u6B21\u811A\u672C\u8FD0\u884C\u7ED3\u675F\uFF0C\u7528 script_runs \u5E26\u4E0A run_id \u548C wait_seconds\uFF0C\u5B83\u7B49\u5230\u7ED3\u675F\uFF08\u91CD\u65B0\u8FD0\u884C\u7684\u8BDD\u8DDF\u5230\u6700\u540E\u90A3\u6B21\uFF09\u624D\u8FD4\u56DE\u3002\u4E0D\u8981\u7528 glob\u3001list_agents\u3001script_runs\u3001window_list \u4E00\u904D\u904D\u67E5\u505A\u5230\u54EA\u4E86\uFF1A\u4F60\u5BF9\u8BDD\u91CC\u7684\u6BCF\u4E00\u6B65\u90FD\u8981\u628A\u6574\u4E2A\u5BF9\u8BDD\u91CD\u65B0\u53D1\u7ED9\u6A21\u578B\u4E00\u6B21\uFF0C\u8FD9\u6837\u7B49\u6700\u8D39\u3002\u5B50 agent \u53EA\u5BF9\u4F60\u8D1F\u8D23\uFF0C\u53EA\u628A\u7ED3\u679C\u4EA4\u56DE\u7ED9\u4F60\uFF1B\u5B83\u8981\u7528\u6237\u6279\u51C6\u7684\u64CD\u4F5C\uFF0C\u4F1A\u5728\u4F60\u7684\u5BF9\u8BDD\u91CC\u8BF7\u7528\u6237\u6279\u51C6\u3002",
|
|
8182
|
+
BRIEFING,
|
|
7771
8183
|
options.browser === true && keeps(self.tools, "browser_navigate") ? "\u7F51\u9875\u4E5F\u4E00\u6837\uFF1Aweb_fetch \u53EA\u62FF\u5230\u7A7A\u58F3\uFF08\u524D\u7AEF\u6E32\u67D3\u7684\u5B98\u7F51\u3001\u516C\u544A\u9875\u5E38\u8FD9\u6837\uFF09\u6216\u8981\u70B9\u5F00\u3001\u7FFB\u9875\u624D\u770B\u5F97\u5230\u65F6\uFF0C\u5F00\u5B50 agent \u7528\u5185\u7F6E\u6D4F\u89C8\u5668\u53BB\u8BFB\uFF0C\u4EFB\u52A1\u91CC\u5199\u660E\u300C\u7528\u5185\u7F6E\u6D4F\u89C8\u5668\uFF08browser_navigate \u6253\u5F00\uFF0Cbrowser_text \u8BFB\u6E32\u67D3\u540E\u7684\u6587\u5B57\uFF09\u300D\u3002\u5B83\u6253\u5F00\u7684\u9875\u9762\u7528\u6237\u5728\u6D4F\u89C8\u5668\u9762\u677F\u91CC\u770B\u5F97\u5230\u3002" : "",
|
|
7772
8184
|
isMain ? "" : `\u9700\u8981\u540C\u4E8B\u7684\u90A3\u90E8\u5206\uFF0C\u7528 agent_delegate \u76F4\u63A5\u4EA4\u7ED9\u5B83\uFF0C\u4E0D\u7528\u7ED5\u8FC7\u300C${main.name}\u300D\u3002\u4EA4\u7ED9\u4F60\u7684\u4E8B\u6CA1\u8BF4\u6E05\u695A\u65F6\uFF0C\u7528 agent_message \u95EE\u4EA4\u7ED9\u4F60\u7684\u4E00\u65B9\uFF0C\u4E0D\u8981\u81EA\u5DF1\u53BB\u95EE\u7528\u6237\uFF08\u8981\u4E0D\u8981\u95EE\u7528\u6237\u7531\u5BF9\u65B9\u51B3\u5B9A\uFF09\uFF0C\u95EE\u6E05\u695A\u518D\u505A\uFF1B\u505A\u5B8C\u7528 agent_message \u7684 done \u4EA4\u56DE\u7ED3\u8BBA\uFF0C\u6216\u8005\u628A\u7ED3\u8BBA\u5199\u5728\u8FD9\u4E00\u8F6E\u6700\u540E\u4E00\u6BB5\u56DE\u590D\u91CC\u3002`,
|
|
7773
8185
|
"\u548C\u5176\u4ED6 agent \u8BF4\u8BDD\u4E0D\u662F\u4E00\u95EE\u4E00\u7B54\uFF1A\u505A\u7684\u8FC7\u7A0B\u4E2D\u8981\u8BA9\u5BF9\u65B9\u77E5\u9053\u7684\uFF0C\u7528 agent_message \u7684 update\uFF0C\u9A6C\u4E0A\u9001\u5230\u5B83\u7684\u5BF9\u8BDD\u91CC\uFF0C\u8BF4\u51E0\u6B21\u90FD\u884C\uFF1B\u4E00\u4EF6\u4E8B\u4EA4\u56DE\u7ED3\u8BBA\u4EE5\u540E\u8FD8\u6709\u8BDD\uFF08\u6BD4\u5982\u5B9A\u65F6\u63D0\u9192\u5230\u4E86\uFF09\uFF0C\u540C\u6837\u7528 agent_message \u53D1\u5230\u90A3\u6761\u7EBF\u7D22\uFF0C\u4F60\u7684\u666E\u901A\u56DE\u590D\u5BF9\u65B9\u770B\u4E0D\u5230\u3002",
|
|
@@ -7785,7 +8197,7 @@ ${colleagues.map(line2).join("\n")}`,
|
|
|
7785
8197
|
].join("\n")
|
|
7786
8198
|
].filter((part) => part !== "").join("\n\n");
|
|
7787
8199
|
}
|
|
7788
|
-
var
|
|
8200
|
+
var MAX_KEPT3 = 5e3;
|
|
7789
8201
|
var SessionRoles = class {
|
|
7790
8202
|
#file;
|
|
7791
8203
|
#roles = /* @__PURE__ */ new Map();
|
|
@@ -7820,7 +8232,14 @@ var SessionRoles = class {
|
|
|
7820
8232
|
return role !== void 0 && this.#roles.has(role) ? role : void 0;
|
|
7821
8233
|
}
|
|
7822
8234
|
list() {
|
|
7823
|
-
return
|
|
8235
|
+
return this.#sorted().map(({ id, name, description, order }) => ({ id, name, description, order }));
|
|
8236
|
+
}
|
|
8237
|
+
/** The roles as the agents know them: what to hand each (`handles`), for their team list. */
|
|
8238
|
+
members() {
|
|
8239
|
+
return this.#sorted().map(({ id, name, description, handles }) => ({ id, name, description: handles ?? description }));
|
|
8240
|
+
}
|
|
8241
|
+
#sorted() {
|
|
8242
|
+
return [...this.#roles.values()].sort((a, b) => a.order - b.order || a.name.localeCompare(b.name));
|
|
7824
8243
|
}
|
|
7825
8244
|
/**
|
|
7826
8245
|
* The role a session belongs to: the one it was opened with, else the one
|
|
@@ -7851,11 +8270,11 @@ var SessionRoles = class {
|
|
|
7851
8270
|
return;
|
|
7852
8271
|
this.#tags.delete(sessionId);
|
|
7853
8272
|
this.#tags.set(sessionId, { role, ...by === void 0 ? {} : { by } });
|
|
7854
|
-
while (this.#tags.size >
|
|
8273
|
+
while (this.#tags.size > MAX_KEPT3)
|
|
7855
8274
|
this.#tags.delete(this.#tags.keys().next().value);
|
|
7856
8275
|
if (this.#file === void 0)
|
|
7857
8276
|
return;
|
|
7858
|
-
|
|
8277
|
+
mkdirSync3(dirname4(this.#file), { recursive: true });
|
|
7859
8278
|
const saved = Object.fromEntries([...this.#tags].map(([id, tag]) => [id, tag.by === void 0 ? tag.role : tag]));
|
|
7860
8279
|
await writeFileAtomic(this.#file, `${JSON.stringify(saved)}
|
|
7861
8280
|
`);
|
|
@@ -7882,8 +8301,8 @@ var SessionRoles = class {
|
|
|
7882
8301
|
|
|
7883
8302
|
// packages/gateway/lib/agent-models.js
|
|
7884
8303
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
7885
|
-
import { mkdirSync as
|
|
7886
|
-
import { dirname as
|
|
8304
|
+
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
8305
|
+
import { dirname as dirname5 } from "node:path";
|
|
7887
8306
|
var LEGACY_ROLES = ["intervene", "games", "scripts", "pipelines"];
|
|
7888
8307
|
var EMPTY = { agents: {}, subAgents: null, subAgentsOf: {}, fallbacks: { agents: [], subAgents: [] } };
|
|
7889
8308
|
var AgentModels = class {
|
|
@@ -7934,7 +8353,7 @@ var AgentModels = class {
|
|
|
7934
8353
|
async #save() {
|
|
7935
8354
|
if (this.#file === void 0)
|
|
7936
8355
|
return;
|
|
7937
|
-
|
|
8356
|
+
mkdirSync4(dirname5(this.#file), { recursive: true });
|
|
7938
8357
|
await writeFileAtomic(this.#file, `${JSON.stringify(this.#state)}
|
|
7939
8358
|
`);
|
|
7940
8359
|
}
|
|
@@ -7993,7 +8412,7 @@ function distinct(list) {
|
|
|
7993
8412
|
}
|
|
7994
8413
|
|
|
7995
8414
|
// packages/gateway/lib/model-fallback.js
|
|
7996
|
-
import { randomUUID as
|
|
8415
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
7997
8416
|
function failureOf(error) {
|
|
7998
8417
|
if (error === null || typeof error !== "object")
|
|
7999
8418
|
return void 0;
|
|
@@ -8046,7 +8465,7 @@ function fallbackSummary(notice) {
|
|
|
8046
8465
|
}
|
|
8047
8466
|
function fallbackMessage(notice) {
|
|
8048
8467
|
return Object.freeze({
|
|
8049
|
-
id:
|
|
8468
|
+
id: randomUUID5(),
|
|
8050
8469
|
role: "user",
|
|
8051
8470
|
content: Object.freeze([Object.freeze({ type: "text", text: fallbackText(notice) })]),
|
|
8052
8471
|
source: Object.freeze({ kind: MODEL_FALLBACK_SOURCE, form: "notice", summary: fallbackSummary(notice), fallback: notice })
|
|
@@ -8323,7 +8742,7 @@ function toRpcError(error) {
|
|
|
8323
8742
|
|
|
8324
8743
|
// packages/gateway/lib/pick.js
|
|
8325
8744
|
import { execFile } from "node:child_process";
|
|
8326
|
-
import { isAbsolute as
|
|
8745
|
+
import { isAbsolute as isAbsolute3, normalize } from "node:path";
|
|
8327
8746
|
var SCRIPT = String.raw`
|
|
8328
8747
|
$ErrorActionPreference = 'Stop'
|
|
8329
8748
|
$ProgressPreference = 'SilentlyContinue'
|
|
@@ -8387,7 +8806,7 @@ function pickPath(options, signal) {
|
|
|
8387
8806
|
return Promise.reject(new Error("\u5DF2\u7ECF\u6253\u5F00\u4E86\u4E00\u4E2A\u9009\u62E9\u7A97\u53E3\uFF0C\u5148\u628A\u5B83\u5173\u6389"));
|
|
8388
8807
|
const extensions = (options.extensions ?? []).filter((e) => /^\w+$/.test(e));
|
|
8389
8808
|
const filter = extensions.length === 0 ? "" : `${(options.filterName ?? "\u6587\u4EF6").replace(/\|/g, "")}|${extensions.map((e) => `*.${e}`).join(";")}|\u6240\u6709\u6587\u4EF6|*.*`;
|
|
8390
|
-
const pending = new Promise((
|
|
8809
|
+
const pending = new Promise((resolve5, reject) => {
|
|
8391
8810
|
execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-STA", "-ExecutionPolicy", "Bypass", "-EncodedCommand", Buffer.from(SCRIPT, "utf16le").toString("base64")], {
|
|
8392
8811
|
windowsHide: true,
|
|
8393
8812
|
signal,
|
|
@@ -8396,7 +8815,7 @@ function pickPath(options, signal) {
|
|
|
8396
8815
|
...process.env,
|
|
8397
8816
|
ADG_PICK_KIND: options.kind,
|
|
8398
8817
|
ADG_PICK_TITLE: options.title ?? (options.kind === "folder" ? "\u9009\u62E9\u6587\u4EF6\u5939" : "\u9009\u62E9\u6587\u4EF6"),
|
|
8399
|
-
ADG_PICK_PATH: options.defaultPath !== void 0 &&
|
|
8818
|
+
ADG_PICK_PATH: options.defaultPath !== void 0 && isAbsolute3(options.defaultPath) ? normalize(options.defaultPath) : "",
|
|
8400
8819
|
ADG_PICK_FILTER: filter
|
|
8401
8820
|
}
|
|
8402
8821
|
}, (error, stdout, stderr) => {
|
|
@@ -8405,7 +8824,7 @@ function pickPath(options, signal) {
|
|
|
8405
8824
|
return;
|
|
8406
8825
|
}
|
|
8407
8826
|
const out = String(stdout).trim();
|
|
8408
|
-
|
|
8827
|
+
resolve5(out === "" ? void 0 : Buffer.from(out, "base64").toString("utf8"));
|
|
8409
8828
|
});
|
|
8410
8829
|
});
|
|
8411
8830
|
open = pending;
|
|
@@ -8419,8 +8838,8 @@ function pickPath(options, signal) {
|
|
|
8419
8838
|
|
|
8420
8839
|
// packages/gateway/lib/permissions.js
|
|
8421
8840
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
8422
|
-
import { mkdirSync as
|
|
8423
|
-
import { dirname as
|
|
8841
|
+
import { mkdirSync as mkdirSync5 } from "node:fs";
|
|
8842
|
+
import { dirname as dirname6 } from "node:path";
|
|
8424
8843
|
var PRESET = { ask: "workspace-write", full: "full-access" };
|
|
8425
8844
|
var KEEP_RECENT = 50;
|
|
8426
8845
|
var Permissions = class {
|
|
@@ -8476,7 +8895,7 @@ var Permissions = class {
|
|
|
8476
8895
|
async #save() {
|
|
8477
8896
|
if (this.#file === void 0)
|
|
8478
8897
|
return;
|
|
8479
|
-
|
|
8898
|
+
mkdirSync5(dirname6(this.#file), { recursive: true });
|
|
8480
8899
|
await writeFileAtomic(this.#file, `${JSON.stringify({ mode: this.#mode, since: this.#since, areas: this.#areas }, null, 2)}
|
|
8481
8900
|
`);
|
|
8482
8901
|
}
|
|
@@ -8530,7 +8949,7 @@ var CapabilityRegistry = class {
|
|
|
8530
8949
|
// packages/gateway/lib/server.js
|
|
8531
8950
|
import { createReadStream, statSync } from "node:fs";
|
|
8532
8951
|
import { createServer } from "node:http";
|
|
8533
|
-
import { extname, join as
|
|
8952
|
+
import { extname, join as join7, normalize as normalize2, resolve as resolve3, sep } from "node:path";
|
|
8534
8953
|
import { timingSafeEqual } from "node:crypto";
|
|
8535
8954
|
|
|
8536
8955
|
// node_modules/.pnpm/ws@8.21.3/node_modules/ws/wrapper.mjs
|
|
@@ -8607,19 +9026,19 @@ function serveMounted(root, req, res) {
|
|
|
8607
9026
|
res.writeHead(404, { "content-type": "text/plain; charset=utf-8" }).end("\u8FD9\u4E2A\u5B89\u88C5\u6CA1\u6709\u5E26\u754C\u9762");
|
|
8608
9027
|
return;
|
|
8609
9028
|
}
|
|
8610
|
-
serveStatic(
|
|
9029
|
+
serveStatic(resolve3(root), req, res, pathname.slice(MOUNT.length));
|
|
8611
9030
|
}
|
|
8612
9031
|
function serveStatic(root, req, res, path) {
|
|
8613
9032
|
const pathname = decodeURIComponent(path ?? new URL(req.url ?? "/", "http://local").pathname);
|
|
8614
|
-
const target = normalize2(
|
|
9033
|
+
const target = normalize2(join7(root, pathname));
|
|
8615
9034
|
const inside = target === root || target.startsWith(root.endsWith(sep) ? root : root + sep);
|
|
8616
|
-
let file = inside ? target :
|
|
9035
|
+
let file = inside ? target : join7(root, "index.html");
|
|
8617
9036
|
try {
|
|
8618
9037
|
if (statSync(file).isDirectory())
|
|
8619
|
-
file =
|
|
9038
|
+
file = join7(file, "index.html");
|
|
8620
9039
|
statSync(file);
|
|
8621
9040
|
} catch {
|
|
8622
|
-
file =
|
|
9041
|
+
file = join7(root, "index.html");
|
|
8623
9042
|
}
|
|
8624
9043
|
try {
|
|
8625
9044
|
const size = statSync(file).size;
|
|
@@ -8635,7 +9054,7 @@ function serveStatic(root, req, res, path) {
|
|
|
8635
9054
|
}
|
|
8636
9055
|
}
|
|
8637
9056
|
async function startServer(options) {
|
|
8638
|
-
const staticRoot = options.staticDir === void 0 ? void 0 :
|
|
9057
|
+
const staticRoot = options.staticDir === void 0 ? void 0 : resolve3(options.staticDir);
|
|
8639
9058
|
const server = createServer((req, res) => {
|
|
8640
9059
|
if (!authorityAllowed(req.headers.host, options.trustedHosts)) {
|
|
8641
9060
|
res.writeHead(403).end("forbidden host");
|
|
@@ -8704,10 +9123,10 @@ Content-Length: 0\r
|
|
|
8704
9123
|
}
|
|
8705
9124
|
|
|
8706
9125
|
// packages/gateway/lib/instances.js
|
|
8707
|
-
import { mkdir as
|
|
9126
|
+
import { mkdir as mkdir6, readdir as readdir2, readFile as readFile11, rm as rm2 } from "node:fs/promises";
|
|
8708
9127
|
import { tmpdir } from "node:os";
|
|
8709
|
-
import { join as
|
|
8710
|
-
var INSTANCES_DIR =
|
|
9128
|
+
import { join as join8, resolve as resolve4 } from "node:path";
|
|
9129
|
+
var INSTANCES_DIR = join8(tmpdir(), "MultiGameAssistant", "instances");
|
|
8711
9130
|
var STALE_MS = 3 * 6e4;
|
|
8712
9131
|
var FORGET_MS = 24 * 60 * 6e4;
|
|
8713
9132
|
function copyLabel(shared, env = process.env) {
|
|
@@ -8720,7 +9139,7 @@ function copyLabel(shared, env = process.env) {
|
|
|
8720
9139
|
function sameDir(a, b) {
|
|
8721
9140
|
if (a === void 0 || b === void 0)
|
|
8722
9141
|
return false;
|
|
8723
|
-
const norm2 = (dir) => process.platform === "win32" ?
|
|
9142
|
+
const norm2 = (dir) => process.platform === "win32" ? resolve4(dir).toLowerCase() : resolve4(dir);
|
|
8724
9143
|
return norm2(a) === norm2(b);
|
|
8725
9144
|
}
|
|
8726
9145
|
function clashes(self, other) {
|
|
@@ -8817,22 +9236,22 @@ var Instances = class {
|
|
|
8817
9236
|
const self = this.#record();
|
|
8818
9237
|
const others = [];
|
|
8819
9238
|
try {
|
|
8820
|
-
await
|
|
9239
|
+
await mkdir6(this.#dir, { recursive: true });
|
|
8821
9240
|
await writeFileAtomic(this.#file(this.#pid), JSON.stringify(self));
|
|
8822
9241
|
const alive = this.#options.alive ?? processAlive;
|
|
8823
|
-
for (const name of await
|
|
9242
|
+
for (const name of await readdir2(this.#dir)) {
|
|
8824
9243
|
const match = /^(\d+)\.json$/.exec(name);
|
|
8825
9244
|
if (match === null || Number(match[1]) === this.#pid)
|
|
8826
9245
|
continue;
|
|
8827
9246
|
let other;
|
|
8828
9247
|
try {
|
|
8829
|
-
other = JSON.parse(await readFile11(
|
|
9248
|
+
other = JSON.parse(await readFile11(join8(this.#dir, name), "utf8"));
|
|
8830
9249
|
} catch {
|
|
8831
9250
|
continue;
|
|
8832
9251
|
}
|
|
8833
9252
|
const age = self.updatedAt - other.updatedAt;
|
|
8834
9253
|
if (!alive(other.pid) || age > FORGET_MS) {
|
|
8835
|
-
await rm2(
|
|
9254
|
+
await rm2(join8(this.#dir, name), { force: true }).catch(() => {
|
|
8836
9255
|
});
|
|
8837
9256
|
continue;
|
|
8838
9257
|
}
|
|
@@ -8850,7 +9269,7 @@ var Instances = class {
|
|
|
8850
9269
|
return changed;
|
|
8851
9270
|
}
|
|
8852
9271
|
#file(pid) {
|
|
8853
|
-
return
|
|
9272
|
+
return join8(this.#dir, `${pid}.json`);
|
|
8854
9273
|
}
|
|
8855
9274
|
#now() {
|
|
8856
9275
|
return (this.#options.now ?? Date.now)();
|
|
@@ -8859,10 +9278,10 @@ var Instances = class {
|
|
|
8859
9278
|
|
|
8860
9279
|
// packages/gateway/lib/shared.js
|
|
8861
9280
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
8862
|
-
import { mkdirSync as
|
|
8863
|
-
import { dirname as
|
|
9281
|
+
import { mkdirSync as mkdirSync6 } from "node:fs";
|
|
9282
|
+
import { dirname as dirname7 } from "node:path";
|
|
8864
9283
|
var AGENT_PRESET = "mga";
|
|
8865
|
-
var
|
|
9284
|
+
var MAX_KEPT4 = 5e3;
|
|
8866
9285
|
var OwnSessions = class {
|
|
8867
9286
|
#file;
|
|
8868
9287
|
#ids = /* @__PURE__ */ new Set();
|
|
@@ -8879,11 +9298,11 @@ var OwnSessions = class {
|
|
|
8879
9298
|
if (this.#ids.has(sessionId))
|
|
8880
9299
|
return;
|
|
8881
9300
|
this.#ids.add(sessionId);
|
|
8882
|
-
while (this.#ids.size >
|
|
9301
|
+
while (this.#ids.size > MAX_KEPT4)
|
|
8883
9302
|
this.#ids.delete(this.#ids.values().next().value);
|
|
8884
9303
|
if (this.#file === void 0)
|
|
8885
9304
|
return;
|
|
8886
|
-
|
|
9305
|
+
mkdirSync6(dirname7(this.#file), { recursive: true });
|
|
8887
9306
|
await writeFileAtomic(this.#file, `${JSON.stringify([...this.#ids])}
|
|
8888
9307
|
`);
|
|
8889
9308
|
}
|
|
@@ -8905,6 +9324,7 @@ var AgentParts = class {
|
|
|
8905
9324
|
/** Tools the parts registered: the app's own, as opposed to dsh's (role agents are narrowed among these). */
|
|
8906
9325
|
tools = /* @__PURE__ */ new Set();
|
|
8907
9326
|
#parts = /* @__PURE__ */ new Map();
|
|
9327
|
+
#definitions = /* @__PURE__ */ new Map();
|
|
8908
9328
|
#scopes = /* @__PURE__ */ new Map();
|
|
8909
9329
|
#next = 0;
|
|
8910
9330
|
#log;
|
|
@@ -8939,6 +9359,10 @@ var AgentParts = class {
|
|
|
8939
9359
|
held.clear();
|
|
8940
9360
|
};
|
|
8941
9361
|
}
|
|
9362
|
+
/** An app tool as a part registered it, to run a call held for a lead (changes.ts). */
|
|
9363
|
+
definition(name) {
|
|
9364
|
+
return this.#definitions.get(name);
|
|
9365
|
+
}
|
|
8942
9366
|
#apply(scope, held, id, label, part) {
|
|
8943
9367
|
try {
|
|
8944
9368
|
const before = toolNames(scope);
|
|
@@ -8946,11 +9370,24 @@ var AgentParts = class {
|
|
|
8946
9370
|
for (const name of toolNames(scope))
|
|
8947
9371
|
if (!before.has(name))
|
|
8948
9372
|
this.tools.add(name);
|
|
9373
|
+
for (const definition2 of toolDefinitions(scope))
|
|
9374
|
+
if (!before.has(definition2.name))
|
|
9375
|
+
this.#definitions.set(definition2.name, definition2);
|
|
8949
9376
|
} catch (error) {
|
|
8950
9377
|
this.#log.warn(`${label} not registered for the app's agents: ${error instanceof Error ? error.message : String(error)}`);
|
|
8951
9378
|
}
|
|
8952
9379
|
}
|
|
8953
9380
|
};
|
|
9381
|
+
function toolDefinitions(scope) {
|
|
9382
|
+
const found = [];
|
|
9383
|
+
for (const key of [void 0, scope]) {
|
|
9384
|
+
try {
|
|
9385
|
+
found.push(...scope.tools.definitions(key));
|
|
9386
|
+
} catch {
|
|
9387
|
+
}
|
|
9388
|
+
}
|
|
9389
|
+
return found;
|
|
9390
|
+
}
|
|
8954
9391
|
function toolNames(scope) {
|
|
8955
9392
|
const names = /* @__PURE__ */ new Set();
|
|
8956
9393
|
for (const key of [void 0, scope]) {
|
|
@@ -9025,16 +9462,16 @@ function keptToken(dataDir, log) {
|
|
|
9025
9462
|
const fresh = () => randomBytes2(18).toString("base64url");
|
|
9026
9463
|
if (dataDir === void 0)
|
|
9027
9464
|
return fresh();
|
|
9028
|
-
const file =
|
|
9465
|
+
const file = join9(dataDir, "gateway-token");
|
|
9029
9466
|
try {
|
|
9030
|
-
const saved =
|
|
9467
|
+
const saved = readFileSync4(file, "utf8").trim();
|
|
9031
9468
|
if (/^[\w-]{16,}$/.test(saved))
|
|
9032
9469
|
return saved;
|
|
9033
9470
|
} catch {
|
|
9034
9471
|
}
|
|
9035
9472
|
const token = fresh();
|
|
9036
9473
|
try {
|
|
9037
|
-
|
|
9474
|
+
mkdirSync7(dataDir, { recursive: true });
|
|
9038
9475
|
writeFileSync(file, `${token}
|
|
9039
9476
|
`);
|
|
9040
9477
|
} catch (error) {
|
|
@@ -9048,14 +9485,14 @@ function ownerInfo(owner) {
|
|
|
9048
9485
|
return { owner: { ...owner.scripts === void 0 ? {} : { scripts: [...owner.scripts] }, ...owner.games === void 0 ? {} : { games: [...owner.games] } } };
|
|
9049
9486
|
}
|
|
9050
9487
|
var ROLE_CLOSING = [
|
|
9051
|
-
"\u8F6F\u4EF6\u6D3E\u53D1\u7684\u4EFB\u52A1\u7531\u4F60\u7684\u539F\u751F\u5B50 agent \u6267\u884C\u3002\u53EA\u6536\u5230\u6D3E\u53D1\u901A\u77E5\u65F6\u53EF\u4EE5\u7ED3\u675F\u672C\u8F6E\uFF0C\u6536\u5230\u5B50\u4EFB\u52A1\u7684\u4EA4\u4ED8\u901A\u77E5\u540E\
|
|
9488
|
+
"\u8F6F\u4EF6\u6D3E\u53D1\u7684\u4EFB\u52A1\u7531\u4F60\u7684\u539F\u751F\u5B50 agent \u6267\u884C\u3002\u53EA\u6536\u5230\u6D3E\u53D1\u901A\u77E5\u65F6\u53EF\u4EE5\u7ED3\u675F\u672C\u8F6E\uFF0C\u6536\u5230\u5B50\u4EFB\u52A1\u7684\u4EA4\u4ED8\u901A\u77E5\u540E\uFF0C\u6309\u4EFB\u52A1\u91CC\u7684\u5B8C\u6210\u6807\u51C6\u6838\u5BF9\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\uFF0C\u518D\u5904\u7406\u7ED3\u679C\u5E76\u6C47\u62A5\u3002\u81EA\u884C\u5B89\u6392\u672C\u89D2\u8272\u5DE5\u4F5C\u65F6\u7528 subagent\uFF1Bagent_delegate \u7528\u4E8E\u4E0D\u540C\u89D2\u8272\u4E4B\u95F4\u7684\u534F\u4F5C\u3002",
|
|
9052
9489
|
"\u8FD9\u662F\u4F60\u552F\u4E00\u7684\u5BF9\u8BDD\uFF1A\u7528\u6237\u76F4\u63A5\u627E\u4F60\u8BF4\u7684\u8BDD\u3001\u522B\u7684 agent \u548C\u8F6F\u4EF6\u4EA4\u7ED9\u4F60\u7684\u4E8B\uFF08\u6D88\u606F\u5F00\u5934\u5199\u7740\u300C\uFF08\u2026\u4EA4\u7ED9\u4F60\u7684\u4E8B\uFF1A\u2026\uFF09\u300D\uFF09\u90FD\u5728\u8FD9\u91CC\uFF0C\u4E00\u4EF6\u63A5\u4E00\u4EF6\u3002",
|
|
9053
9490
|
"\u80FD\u7528\u5DE5\u5177\u3001\u547D\u4EE4\u884C\u3001\u8BFB\u6587\u4EF6\uFF08\u914D\u7F6E\u3001\u65E5\u5FD7\u3001\u7248\u672C\u53F7\uFF09\u6216\u811A\u672C\u81EA\u5DF1\u7684\u547D\u4EE4\u548C\u8BBE\u7F6E\u505A\u5230\u3001\u786E\u8BA4\u5230\u7684\uFF0C\u5C31\u8FD9\u6837\u505A\uFF1B\u622A\u56FE\u3001\u770B\u753B\u9762\u3001\u70B9\u5C4F\u5E55\u662F\u6700\u540E\u7684\u529E\u6CD5\u2014\u2014\u53EA\u6709\u753B\u9762\u4E0A\u624D\u770B\u5F97\u5230\u3001\u522B\u7684\u529E\u6CD5\u90FD\u786E\u8BA4\u4E0D\u4E86\u65F6\u624D\u7528\uFF0C\u7528\u4E4B\u524D\u5148\u8BF4\u4E3A\u4EC0\u4E48\u3002",
|
|
9054
9491
|
"\u4F60\u6BCF\u4E00\u8F6E\u6700\u540E\u4E00\u6BB5\u56DE\u590D\u5C31\u662F\u8FD9\u4EF6\u4E8B\u7684\u7ED3\u8BBA\uFF1A\u5199\u6E05\u695A\u7ED3\u679C\uFF0C\u4EE5\u53CA\u9700\u8981\u7528\u6237\u505A\u7684\u4E8B\uFF08\u6CA1\u6709\u5C31\u4E0D\u5199\uFF09\u3002\u522B\u4EBA\u4EA4\u7ED9\u4F60\u7684\u4E8B\uFF0C\u8FD9\u6BB5\u56DE\u590D\u4F1A\u4F5C\u4E3A\u7ED3\u8BBA\u4EA4\u56DE\u7ED9\u5B83\uFF1B\u5728\u90A3\u4E4B\u524D\u3001\u5728\u90A3\u4E4B\u540E\u8981\u8BA9\u5B83\u77E5\u9053\u7684\uFF0C\u7528 agent_message \u53D1\u5230\u90A3\u6761\u7EBF\u7D22\u3002"
|
|
9055
9492
|
].join("\n");
|
|
9056
9493
|
var MAIN_AGENT = {
|
|
9057
9494
|
id: "main",
|
|
9058
|
-
name:
|
|
9495
|
+
name: MAIN_AGENT_NAME,
|
|
9059
9496
|
description: "",
|
|
9060
9497
|
order: 0,
|
|
9061
9498
|
tools: [
|
|
@@ -9075,17 +9512,25 @@ var MAIN_AGENT = {
|
|
|
9075
9512
|
"game_list",
|
|
9076
9513
|
"game_activities",
|
|
9077
9514
|
"game_report",
|
|
9078
|
-
|
|
9079
|
-
"
|
|
9515
|
+
// Where pipelines stand, and starting one; making and timing them is 编排's (no draft tool here either).
|
|
9516
|
+
"pipeline_list",
|
|
9517
|
+
"pipeline_get",
|
|
9518
|
+
"pipeline_status",
|
|
9519
|
+
"pipeline_run",
|
|
9520
|
+
// A task the user named, started or stopped in one call (roles.ts LIGHT); choosing, settings and failures are 脚本's.
|
|
9521
|
+
"script_run",
|
|
9522
|
+
"script_stop",
|
|
9523
|
+
// Timed tasks: at a time, an agent does one thing. dsh's reminders (schedule_create…) stay besides.
|
|
9524
|
+
"schedule_task_*",
|
|
9080
9525
|
"monitor_incidents",
|
|
9081
9526
|
"monitor_stall_check",
|
|
9082
9527
|
"emulator_status",
|
|
9083
9528
|
"window_list",
|
|
9529
|
+
// The user's chat and the runs' logs to a folder, in one call (history-export.ts).
|
|
9530
|
+
"history_export",
|
|
9084
9531
|
// The built-in browser, for its sub-agents (its own conversation hands it out: roles.ts HANDS_ON).
|
|
9085
9532
|
"browser_*"
|
|
9086
|
-
]
|
|
9087
|
-
// Saving a pipeline outright is 编排's: 助手 drafts one for the user, or hands the change to 编排.
|
|
9088
|
-
hide: ["pipeline_save"]
|
|
9533
|
+
]
|
|
9089
9534
|
};
|
|
9090
9535
|
function memoryOwnerOf(spec) {
|
|
9091
9536
|
return spec.subAgentOf === void 0 ? spec.id : spec.id.replace(/:sub$/, "");
|
|
@@ -9096,15 +9541,16 @@ function sameRoute(a, b) {
|
|
|
9096
9541
|
var MAIN_AGENT_MEMBER = { id: MAIN_AGENT.id, name: MAIN_AGENT.name, description: "\u548C\u7528\u6237\u5BF9\u8BDD\uFF0C\u5206\u53D1\u4EFB\u52A1\uFF0C\u505A\u51B3\u5B9A" };
|
|
9097
9542
|
function mainDuty(roles) {
|
|
9098
9543
|
return [
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
"\u7528\u6237\u8981\u5728\u6E38\u620F\u91CC\u505A\u4E00\u4EF6\u4E8B\u65F6\uFF0C\u4EA4\u51FA\u53BB\u4E4B\u524D\u5148\u7528 script_list\u3001script_tasks \u770B\u8FD9\u4E2A\u6E38\u620F\u4E0B\u7684\u811A\u672C\u6709\u6CA1\u6709\u8FD9\u4E2A\u529F\u80FD\uFF1A\u6709\uFF0C\u5C31\u4EA4\u7ED9\u300C\u811A\u672C\
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
"\
|
|
9105
|
-
"\
|
|
9544
|
+
`# \u4F60\u7684\u89D2\u8272\uFF1A${MAIN_AGENT_NAME}`,
|
|
9545
|
+
`\u4F60\u662F\u300C${MAIN_AGENT_NAME}\u300D\uFF0C\u7528\u6237\u7684\u4E3B agent\uFF1A\u548C\u7528\u6237\u5BF9\u8BDD\uFF0C\u5F04\u6E05\u8981\u505A\u4EC0\u4E48\uFF0C\u5B89\u6392\u8C01\u6765\u505A\u3002\u622A\u56FE\u70B9\u51FB\u3001\u5B89\u88C5\u811A\u672C\u3001\u6539\u811A\u672C\u8BBE\u7F6E\u3001\u5206\u6790\u811A\u672C\u548C\u5199\u811A\u672C\u5305\u3001\u8BFB\u6E38\u620F\u3001\u6392\u6D41\u6C34\u7EBF\u8FD9\u4E9B\u5177\u4F53\u7684\u4E8B\u4EA4\u7ED9\u5BF9\u5E94\u7684 agent\uFF08agent_delegate\uFF09\uFF0C\u4F60\u81EA\u5DF1\u4E0D\u505A\u3002\u5206\u6790\u811A\u672C\u3001\u5199\u6216\u6539\u811A\u672C\u5305\u4EA4\u7ED9\u300C\u811A\u672C\u52A9\u624B\u300D\uFF1A\u4FDD\u5B58\u811A\u672C\u5305\u7684 pack_propose \u53EA\u6709\u5B83\u6709\uFF0C\u4F60\u7684\u5B50 agent \u6CA1\u6709\u3002\u65B0\u5EFA\u3001\u4FEE\u6539\u6D41\u6C34\u7EBF\u548C\u5B83\u4EEC\u7684\u5B9A\u65F6\u4EA4\u7ED9\u300C\u7F16\u6392\u52A9\u624B\u300D\uFF1A\u4FDD\u5B58\u6D41\u6C34\u7EBF\u53EA\u6709\u5B83\u80FD\u505A\u3002`,
|
|
9546
|
+
"\u7528\u6237\u8981\u5728\u6E38\u620F\u91CC\u505A\u4E00\u4EF6\u4E8B\u65F6\uFF0C\u4EA4\u51FA\u53BB\u4E4B\u524D\u5148\u7528 script_list\u3001script_tasks \u770B\u8FD9\u4E2A\u6E38\u620F\u4E0B\u7684\u811A\u672C\u6709\u6CA1\u6709\u8FD9\u4E2A\u529F\u80FD\uFF1A\u6709\uFF0C\u800C\u4E14\u5C31\u662F\u7528\u6237\u8BF4\u7684\u90A3\u4E2A\u4EFB\u52A1\u3001\u4E0D\u7528\u6539\u8BBE\u7F6E\uFF0C\u4F60\u81EA\u5DF1\u7528 script_run \u542F\u52A8\u5B83\uFF08\u8981\u7B49\u7ED3\u679C\uFF0C\u7528 script_runs \u5E26\u4E0A run_id \u548C wait_seconds\uFF09\uFF0C\u8981\u505C\u7528 script_stop\uFF1B\u8981\u5728\u51E0\u4E2A\u811A\u672C\u91CC\u6311\u3001\u8981\u6539\u8BBE\u7F6E\u3001\u8DD1\u5931\u8D25\u4E86\u8981\u5904\u7406\uFF0C\u4EA4\u7ED9\u300C\u811A\u672C\u52A9\u624B\u300D\uFF0C\u5199\u660E\u7528\u54EA\u4E2A\u811A\u672C\u7684\u54EA\u4E2A\u4EFB\u52A1\uFF1B\u811A\u672C\u81EA\u5E26 MCP \u670D\u52A1\u65F6\uFF08script_mcp_list\uFF09\uFF0C\u300C\u811A\u672C\u52A9\u624B\u300D \u8FD8\u80FD\u76F4\u63A5\u8C03\u7528\u5B83\u7684\u5DE5\u5177\uFF0C\u505A\u5230\u6574\u4E2A\u4EFB\u52A1\u4E4B\u5916\u7684\u7EC6\u7C92\u5EA6\u64CD\u4F5C\uFF08\u67E5\u72B6\u6001\u3001\u53EA\u8DD1\u67D0\u4E00\u9879\u3001\u6539\u8BBE\u7F6E\uFF09\uFF0C\u4E5F\u4EA4\u7ED9\u5B83\uFF1B\u786E\u8BA4\u811A\u672C\u90FD\u505A\u4E0D\u4E86\uFF0C\u624D\u4EA4\u7ED9\u80FD\u622A\u56FE\u70B9\u51FB\u7684 agent \u81EA\u5DF1\u52A8\u624B\uFF0C\u5E76\u5728\u4EFB\u52A1\u91CC\u5199\u4E0A\u811A\u672C\u4E3A\u4EC0\u4E48\u505A\u4E0D\u4E86\u3002",
|
|
9547
|
+
// Who they are and what each takes is the team section's list (teamPrompt): not twice in the prompt.
|
|
9548
|
+
roles.length === 0 ? "\u73B0\u5728\u6CA1\u6709\u53EF\u4EE5\u4EA4\u7ED9\u7684 agent\uFF0C\u80FD\u505A\u7684\u4F60\u81EA\u5DF1\u505A\u3002" : "\u53EF\u4EE5\u4EA4\u7ED9\u8C01\u3001\u5404\u81EA\u505A\u4EC0\u4E48\uFF0C\u89C1\u300C\u56E2\u961F\u300D\u91CC\u7684\u4E3B agent \u5217\u8868\uFF1A\u6309\u90A3\u91CC\u5199\u7684\u4EA4\uFF0C\u4EA4\u9519\u4E86\uFF0C\u5BF9\u65B9\u6CA1\u6709\u505A\u8FD9\u4EF6\u4E8B\u7684\u5DE5\u5177\u3002",
|
|
9549
|
+
"\u8FD9\u4E9B\u4F60\u81EA\u5DF1\u505A\uFF0C\u4E0D\u4EA4\u51FA\u53BB\uFF0C\u4E5F\u4E0D\u5F00\u5B50 agent\uFF1A\u5BFC\u51FA\u804A\u5929\u8BB0\u5F55\u548C\u811A\u672C\u8FD0\u884C\u65E5\u5FD7\u7528 history_export\uFF0C\u4E00\u6B21\u8C03\u7528\u5C31\u628A\u6574\u4E2A\u6587\u4EF6\u5939\u5199\u597D\uFF0C\u4E0D\u8981\u53BB\u7FFB\u8F6F\u4EF6\u7684\u6570\u636E\u76EE\u5F55\u6216\u6E90\u7801\uFF1B\u63D0\u9192\uFF08schedule_create\uFF09\u548C\u5230\u70B9\u8BA9\u67D0\u4E2A agent \u505A\u4E00\u4EF6\u4E8B\u7684\u5B9A\u65F6\u4EFB\u52A1\uFF08schedule_task_save\uFF09\u4F60\u81EA\u5DF1\u8BBE\uFF1B\u67E5\u811A\u672C\u3001\u8FD0\u884C\u8BB0\u5F55\u548C\u65E5\u5FD7\u3001\u6E38\u620F\u6D3B\u52A8\u3001\u6D41\u6C34\u7EBF\u72B6\u6001\u8FD9\u4E9B\u770B\u4E00\u773C\u7684\u4E8B\uFF0C\u7528\u4F60\u81EA\u5DF1\u7684\u5DE5\u5177\u3002",
|
|
9550
|
+
"\u8FD0\u884C\u547D\u4EE4\u3001\u6539\u6587\u4EF6\u8FD9\u4E9B\u5DE5\u5177\u4E0D\u5728\u4F60\u7684\u5BF9\u8BDD\u91CC\uFF1A\u7528\u6237\u8981\u7684\u8FD9\u7C7B\u4E8B\uFF08\u6574\u7406\u6587\u4EF6\u3001\u67E5\u7CFB\u7EDF\uFF09\uFF0C\u8FD8\u6709\u67E5\u8D44\u6599\u3001\u6BD4\u8F83\u51E0\u4E2A\u65B9\u6848\uFF0C\u5F00\u81EA\u5DF1\u7684\u5B50 agent\uFF08subagent\uFF09\u53BB\u505A\uFF0C\u5B83\u628A\u7ED3\u679C\u4EA4\u56DE\u6765\uFF0C\u4F60\u544A\u8BC9\u7528\u6237\u3002",
|
|
9551
|
+
"\u4EA4\u51FA\u53BB\u7684\u4E8B\u5728\u90A3\u4E2A agent \u81EA\u5DF1\u7684\u5BF9\u8BDD\u91CC\u505A\uFF0C\u5B83\u770B\u4E0D\u5230\u4F60\u548C\u7528\u6237\u7684\u5BF9\u8BDD\u3002agent_delegate \u7684 task \u5199\u76EE\u6807\u548C\u4F60\u5DF2\u7ECF\u77E5\u9053\u7684\u60C5\u51B5\uFF0Climits \u5199\u8FB9\u754C\uFF0Cdone_when \u5199\u5B8C\u6210\u6807\u51C6\uFF0Cexpecting \u5199\u8981\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\uFF1B\u7528\u6237\u5DF2\u7ECF\u660E\u786E\u8981\u505A\u7684\u6539\u52A8\uFF08\u88C5\u3001\u5220\u3001\u6539\u8BBE\u7F6E\u3001\u5B58\u6280\u80FD\uFF09\uFF0C\u90A3\u4E00\u7C7B\u5199\u8FDB allow\uFF0C\u5B83\u5C31\u76F4\u63A5\u505A\uFF0C\u4E0D\u7136\u5B83\u4F1A\u5148\u4EA4\u56DE\u53BB\u51B3\u5B9A\u3002\u4E0D\u5199\u4E00\u6B65\u6B65\u600E\u4E48\u505A\uFF0C\u7528\u4EC0\u4E48\u5DE5\u5177\u7531\u5B83\u51B3\u5B9A\u3002\u4EA4\u51FA\u53BB\u4EE5\u540E\u7528\u4E00\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u4EA4\u7ED9\u4E86\u8C01\u3001\u505A\u4EC0\u4E48\uFF0C\u7136\u540E\u7ED3\u675F\u8FD9\u4E00\u8F6E\uFF1A\u4E0D\u8981\u7B49\u5B83\uFF0C\u4E5F\u4E0D\u8981\u66FF\u5B83\u56DE\u7B54\u3002",
|
|
9106
9552
|
"\u5B83\u505A\u7684\u8FC7\u7A0B\u4E2D\u53EF\u80FD\u56DE\u5934\u95EE\u4F60\uFF08\u6D88\u606F\u5F00\u5934\u662F\u300C\uFF08\u300C\u67D0 agent\u300D\u5728\u7EBF\u7D22 \u2026 \u91CC\u95EE\u4F60\uFF1A\u2026\uFF09\u300D\uFF09\uFF0C\u8FD9\u79CD\u6D88\u606F\u4F1A\u63D2\u8FDB\u4F60\u6B63\u5728\u505A\u7684\u4E8B\uFF1A\u5B83\u5728\u7B49\uFF0C\u5148\u56DE\u7B54\u5B83\u3002\u80FD\u7B54\u5C31\u7528 agent_message \u56DE\u7B54\uFF1B\u8981\u7528\u6237\u51B3\u5B9A\u7684\uFF0C\u5148\u7528 kind: update \u8BF4\u4E00\u58F0\u3001\u53BB\u95EE\u7528\u6237\uFF0C\u6709\u4E86\u7ED3\u679C\u518D\u56DE\u7B54\u3002\u5B83\u4E5F\u53EF\u80FD\u53EA\u662F\u544A\u8BC9\u4F60\u4E00\u4EF6\u4E8B\uFF08\u300C\u2026 \u91CC\u544A\u8BC9\u4F60\uFF1A\u2026\u300D\uFF09\uFF0C\u4E0D\u7528\u56DE\u5B83\u3002\u4F60\u8981\u8865\u5145\u6216\u6539\u4E3B\u610F\uFF0C\u540C\u6837\u7528 agent_message \u53D1\u5230\u90A3\u6761\u7EBF\u7D22\uFF0C\u9A6C\u4E0A\u9001\u5230\u5B83\u90A3\u91CC\u3002",
|
|
9107
|
-
"\u5B83\u505A\u5B8C\u540E\uFF0C\u56DE\u590D\u4F1A\u4F5C\u4E3A\u4E00\u6761\u65B0\u6D88\u606F\u53D1\u5230\u8FD9\u91CC\uFF0C\u5F00\u5934\u662F\u300C\uFF08\u300C\u67D0 agent\u300D\u4EA4\u56DE\u4E86\u2026\uFF09\u300D\u6216\u300C\uFF08\u300C\u67D0 agent\u300D\u6CA1\u6709\u505A\u5B8C\u2026\uFF09\u300D\u3002\u6536\u5230\u540E\u7528\u4E00\u4E24\u53E5\u8BDD\u628A\u8981\u70B9\u544A\u8BC9\u7528\u6237\uFF1A\u7ED3\u8BBA\u3001\u8981\u7528\u6237\u505A\u7684\u4E8B\u3002\u6CA1\u505A\u6210\u5C31\u76F4\u8BF4\uFF1A\u6CA1\u505A\u6210\u3001\u5F53\u65F6\u8BF7\u5B83\u505A\u4EC0\u4E48\u3001\u4F60\u63A5\u4E0B\u6765\u80FD\u505A\u4EC0\u4E48\u3002",
|
|
9553
|
+
"\u5B83\u505A\u5B8C\u540E\uFF0C\u56DE\u590D\u4F1A\u4F5C\u4E3A\u4E00\u6761\u65B0\u6D88\u606F\u53D1\u5230\u8FD9\u91CC\uFF0C\u5F00\u5934\u662F\u300C\uFF08\u300C\u67D0 agent\u300D\u4EA4\u56DE\u4E86\u2026\uFF09\u300D\u6216\u300C\uFF08\u300C\u67D0 agent\u300D\u6CA1\u6709\u505A\u5B8C\u2026\uFF09\u300D\u3002\u6536\u5230\u540E\u5148\u770B\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\u5BF9\u4E0D\u5BF9\u5F97\u4E0A\u5B8C\u6210\u6807\u51C6\uFF08\u770B\u5F97\u5230\u7684\u7528\u4F60\u7684\u5DE5\u5177\u770B\u4E00\u773C\uFF0C\u4E0D\u8981\u91CD\u505A\uFF09\uFF0C\u5BF9\u4E0D\u4E0A\u5C31\u7528 agent_message \u8BA9\u5B83\u8865\uFF0C\u6216\u8005\u7167\u5B9E\u544A\u8BC9\u7528\u6237\u6CA1\u505A\u6210\uFF1B\u5BF9\u5F97\u4E0A\u5C31\u7528\u4E00\u4E24\u53E5\u8BDD\u628A\u8981\u70B9\u544A\u8BC9\u7528\u6237\uFF1A\u7ED3\u8BBA\u3001\u8981\u7528\u6237\u505A\u7684\u4E8B\u3002\u6CA1\u505A\u6210\u5C31\u76F4\u8BF4\uFF1A\u6CA1\u505A\u6210\u3001\u5F53\u65F6\u8BF7\u5B83\u505A\u4EC0\u4E48\u3001\u4F60\u63A5\u4E0B\u6765\u80FD\u505A\u4EC0\u4E48\u3002",
|
|
9108
9554
|
"\u8F6F\u4EF6\u81EA\u5DF1\u4E5F\u4F1A\u628A\u4E8B\u4EA4\u7ED9 agent\uFF08\u6BD4\u5982\u76D1\u63A7\u53D1\u73B0\u811A\u672C\u51FA\u4E86\u95EE\u9898\uFF0C\u4EA4\u7ED9\u5E72\u9884\u5904\u7406\uFF09\uFF0C\u7ED3\u679C\u540C\u6837\u53D1\u5230\u8FD9\u91CC\uFF0C\u4F60\u7167\u6837\u628A\u8981\u70B9\u544A\u8BC9\u7528\u6237\u3002\u4E3B agent \u4E4B\u95F4\u53EF\u4EE5\u76F4\u63A5\u4EA4\u6D41\uFF0C\u4E0D\u4F1A\u53EB\u9192\u4F60\uFF1B\u8981\u77E5\u9053\u5B83\u4EEC\u8BF4\u4E86\u4EC0\u4E48\uFF0C\u7528 agent_threads \u770B\u3002\u7528\u6237\u4E5F\u53EF\u4EE5\u76F4\u63A5\u53BB\u67D0\u4E2A agent \u7684\u5BF9\u8BDD\u91CC\u627E\u5B83\uFF0C\u90A3\u4E9B\u4F60\u770B\u4E0D\u5230\u3002"
|
|
9109
9555
|
].join("\n\n");
|
|
9110
9556
|
}
|
|
@@ -9113,6 +9559,8 @@ var AdgGateway = class extends Service {
|
|
|
9113
9559
|
registry = new CapabilityRegistry();
|
|
9114
9560
|
workspace;
|
|
9115
9561
|
archived = /* @__PURE__ */ new Set();
|
|
9562
|
+
/** What other parts of the app add to history_export (the runner's run logs). */
|
|
9563
|
+
exportParts = /* @__PURE__ */ new Set();
|
|
9116
9564
|
/** The latest context projections per session (a control frame carries only the keys its event changed). */
|
|
9117
9565
|
contexts = /* @__PURE__ */ new Map();
|
|
9118
9566
|
/** The latest non-empty inbox projection per session, so the queue can be sent again when only the taken messages change. */
|
|
@@ -9167,6 +9615,10 @@ var AdgGateway = class extends Service {
|
|
|
9167
9615
|
agents = /* @__PURE__ */ new Map();
|
|
9168
9616
|
narrowed = /* @__PURE__ */ new Map();
|
|
9169
9617
|
appChildren = /* @__PURE__ */ new Set();
|
|
9618
|
+
/** Lasting changes sub-agents asked for, held for their leads (changes.ts). */
|
|
9619
|
+
held;
|
|
9620
|
+
/** What each sub-agent's brief lets it change itself (grantsIn), read once. */
|
|
9621
|
+
grants = /* @__PURE__ */ new Map();
|
|
9170
9622
|
assignedSpecs = /* @__PURE__ */ new WeakMap();
|
|
9171
9623
|
subAgentSpecs = /* @__PURE__ */ new WeakMap();
|
|
9172
9624
|
persona;
|
|
@@ -9187,13 +9639,14 @@ var AdgGateway = class extends Service {
|
|
|
9187
9639
|
this.log = log;
|
|
9188
9640
|
this.workspace = config.workspaceDir;
|
|
9189
9641
|
this.shared = config.shared === true;
|
|
9190
|
-
this.own = new OwnSessions(this.shared && config.dataDir !== void 0 ?
|
|
9642
|
+
this.own = new OwnSessions(this.shared && config.dataDir !== void 0 ? join9(config.dataDir, "own-sessions.json") : void 0);
|
|
9191
9643
|
this.parts = new AgentParts(log);
|
|
9192
9644
|
this.newInput = new NewInput(ctx);
|
|
9193
|
-
this.agentModels = new AgentModels(config.dataDir === void 0 ? void 0 :
|
|
9194
|
-
this.roles = new SessionRoles(config.dataDir === void 0 ? void 0 :
|
|
9195
|
-
this.
|
|
9196
|
-
this.
|
|
9645
|
+
this.agentModels = new AgentModels(config.dataDir === void 0 ? void 0 : join9(config.dataDir, "agent-models.json"), config.dataDir === void 0 ? void 0 : join9(config.dataDir, "role-model.json"));
|
|
9646
|
+
this.roles = new SessionRoles(config.dataDir === void 0 ? void 0 : join9(config.dataDir, "session-roles.json"), () => this.broadcast("roles/changed", { items: this.roles.list() }));
|
|
9647
|
+
this.held = new HeldChanges(config.dataDir === void 0 ? void 0 : join9(config.dataDir, "held-changes.json"));
|
|
9648
|
+
this.homes = new AgentHomes(config.dataDir === void 0 ? void 0 : join9(config.dataDir, "agent-homes.json"));
|
|
9649
|
+
this.handOffs = new HandOffs(config.dataDir === void 0 ? void 0 : join9(config.dataDir, "handoffs.json"), (item) => this.broadcast("handoffs/changed", { item }), log);
|
|
9197
9650
|
if (!this.shared)
|
|
9198
9651
|
ctx.inject(["tools", "systemPrompt"], (scoped) => {
|
|
9199
9652
|
scoped.effect(() => this.parts.attach(scoped), "adg-gateway agent parts");
|
|
@@ -9232,7 +9685,7 @@ var AdgGateway = class extends Service {
|
|
|
9232
9685
|
});
|
|
9233
9686
|
if (config.workspaceDir !== void 0) {
|
|
9234
9687
|
try {
|
|
9235
|
-
|
|
9688
|
+
mkdirSync7(config.workspaceDir, { recursive: true });
|
|
9236
9689
|
} catch (error) {
|
|
9237
9690
|
log.warn(`cannot create the workspace ${config.workspaceDir}: ${String(error)}`);
|
|
9238
9691
|
}
|
|
@@ -9321,7 +9774,7 @@ var AdgGateway = class extends Service {
|
|
|
9321
9774
|
}
|
|
9322
9775
|
}
|
|
9323
9776
|
}), "adg-gateway capability questions");
|
|
9324
|
-
this.permissions = new Permissions(config.dataDir === void 0 ? void 0 :
|
|
9777
|
+
this.permissions = new Permissions(config.dataDir === void 0 ? void 0 : join9(config.dataDir, "permissions.json"));
|
|
9325
9778
|
const presetFor = (session) => {
|
|
9326
9779
|
const presets = ctx.get("permissionPresets");
|
|
9327
9780
|
if (presets === void 0 || !this.isOwn(session.id))
|
|
@@ -9379,6 +9832,9 @@ var AdgGateway = class extends Service {
|
|
|
9379
9832
|
if (noted !== void 0)
|
|
9380
9833
|
exec.arguments = { ...exec.arguments, prompt: noted };
|
|
9381
9834
|
}
|
|
9835
|
+
const held = this.holdForLead(exec);
|
|
9836
|
+
if (held !== void 0)
|
|
9837
|
+
return held;
|
|
9382
9838
|
return next();
|
|
9383
9839
|
}));
|
|
9384
9840
|
ctx.on("tools/result", ((exec, result) => {
|
|
@@ -9595,7 +10051,7 @@ var AdgGateway = class extends Service {
|
|
|
9595
10051
|
}
|
|
9596
10052
|
} catch {
|
|
9597
10053
|
}
|
|
9598
|
-
await new Promise((
|
|
10054
|
+
await new Promise((resolve5) => setTimeout(resolve5, Math.min(3e4, 1e3 * 2 ** attempt)));
|
|
9599
10055
|
}
|
|
9600
10056
|
})();
|
|
9601
10057
|
return () => controller.abort();
|
|
@@ -9671,7 +10127,8 @@ var AdgGateway = class extends Service {
|
|
|
9671
10127
|
id: SKILLS_CAPABILITY,
|
|
9672
10128
|
version: 1,
|
|
9673
10129
|
methods: {
|
|
9674
|
-
|
|
10130
|
+
// Not the names taken over so nobody sees dsh's skill of that name (skill-scope.ts SHADOWED_SKILLS).
|
|
10131
|
+
"skills/list": async (_params, call) => ({ skills: (await scoped.skills.list(options(call.signal))).filter((s) => s.invocation?.modelInvocable !== false || s.invocation?.userInvocable !== false).map(info) }),
|
|
9675
10132
|
"skills/get": async (params, call) => {
|
|
9676
10133
|
const { name } = params;
|
|
9677
10134
|
const skill = await scoped.skills.get(name, options(call.signal));
|
|
@@ -9834,12 +10291,12 @@ var AdgGateway = class extends Service {
|
|
|
9834
10291
|
this.persona = persona;
|
|
9835
10292
|
}
|
|
9836
10293
|
if (config.dataDir !== void 0) {
|
|
9837
|
-
const memory = new MemoryStore(
|
|
10294
|
+
const memory = new MemoryStore(join9(config.dataDir, "memory.json"), () => this.broadcast("memory/changed", {}));
|
|
9838
10295
|
const views = new MemoryViews(memory, { timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone });
|
|
9839
10296
|
this.memoryViews = views;
|
|
9840
10297
|
const auto = new AutoMemory({
|
|
9841
10298
|
store: memory,
|
|
9842
|
-
file:
|
|
10299
|
+
file: join9(config.dataDir, "memory-auto.json"),
|
|
9843
10300
|
// Back to where it stopped (oldest unread first): nothing between is passed over.
|
|
9844
10301
|
read: (sessionId, since, signal) => this.sessionEvents(sessionId, since.maxMessages, signal, since.after),
|
|
9845
10302
|
agentOf: (sessionId) => {
|
|
@@ -9916,11 +10373,31 @@ var AdgGateway = class extends Service {
|
|
|
9916
10373
|
sessions: (agent, signal) => this.sessionsOf(agent, signal),
|
|
9917
10374
|
read: (sessionId, maxMessages, signal) => this.sessionEvents(sessionId, maxMessages, signal),
|
|
9918
10375
|
memory: (id) => memory.get(id),
|
|
9919
|
-
archived: summariesReader(
|
|
10376
|
+
archived: summariesReader(join9(config.dataDir, SUMMARIES_FILE)),
|
|
9920
10377
|
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
9921
10378
|
});
|
|
9922
10379
|
for (const tool of history)
|
|
9923
10380
|
this.agentPart(`adg-gateway ${tool.name}`, (agent) => agent.tools.register(tool));
|
|
10381
|
+
const exporter = historyExportTool({
|
|
10382
|
+
agentOf: (sessionId) => this.memoryOwner(sessionId),
|
|
10383
|
+
nameOf: (agent) => agent === MAIN_AGENT.id ? MAIN_AGENT.name : this.roles.spec(agent)?.name ?? agent,
|
|
10384
|
+
sessions: (agent, signal) => this.sessionsOf(agent, signal),
|
|
10385
|
+
read: (sessionId, maxMessages, signal) => this.sessionEvents(sessionId, maxMessages, signal),
|
|
10386
|
+
parts: () => [...this.exportParts],
|
|
10387
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
10388
|
+
});
|
|
10389
|
+
this.agentPart(`adg-gateway ${exporter.name}`, (agent) => agent.tools.register(exporter));
|
|
10390
|
+
const pending = pendingChangesTool({
|
|
10391
|
+
store: this.held,
|
|
10392
|
+
run: async (tool, args, exec) => {
|
|
10393
|
+
const definition2 = this.parts.definition(tool);
|
|
10394
|
+
if (definition2 === void 0)
|
|
10395
|
+
throw new Error(`${tool} \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u63D0\u4F9B\u5B83\u7684\u63D2\u4EF6\u6CA1\u6709\u52A0\u8F7D\uFF09`);
|
|
10396
|
+
return definition2.execute(args, { ...exec, name: tool, arguments: args });
|
|
10397
|
+
},
|
|
10398
|
+
sameAgent: (a, b) => a === b || this.memoryOwner(a) !== void 0 && this.memoryOwner(a) === this.memoryOwner(b)
|
|
10399
|
+
});
|
|
10400
|
+
this.agentPart(`adg-gateway ${pending.name}`, (agent) => agent.tools.register(pending));
|
|
9924
10401
|
const recalled = new RecallLog();
|
|
9925
10402
|
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
9926
10403
|
this.agentPart("adg-gateway recall hook", (agent) => agent.on("agent/pre-step", (async (payload, next) => {
|
|
@@ -9977,7 +10454,7 @@ var AdgGateway = class extends Service {
|
|
|
9977
10454
|
continue;
|
|
9978
10455
|
registered.get(skill.name)?.();
|
|
9979
10456
|
try {
|
|
9980
|
-
registered.set(skill.name, this.skillScope.register({ name: skill.name, description: skill.description, content: skill.content, source: "custom", path: skill.path, resourceBase: { kind: "directory", path:
|
|
10457
|
+
registered.set(skill.name, this.skillScope.register({ name: skill.name, description: skill.description, content: skill.content, source: "custom", path: skill.path, resourceBase: { kind: "directory", path: dirname8(skill.path) }, ...skill.owner === void 0 ? {} : { owner: skill.owner } }));
|
|
9981
10458
|
} catch (error) {
|
|
9982
10459
|
log.warn(`saved skill ${skill.name} not registered: ${error instanceof Error ? error.message : String(error)}`);
|
|
9983
10460
|
}
|
|
@@ -10037,7 +10514,7 @@ var AdgGateway = class extends Service {
|
|
|
10037
10514
|
void this.followTitles(controller.signal, log);
|
|
10038
10515
|
return () => controller.abort();
|
|
10039
10516
|
}, "adg-gateway title feed");
|
|
10040
|
-
const staticDir = config.staticDir ?? (existsSync(
|
|
10517
|
+
const staticDir = config.staticDir ?? (existsSync(join9(BUNDLED_UI, "index.html")) ? BUNDLED_UI : void 0);
|
|
10041
10518
|
ctx.inject(["webServer", "connection"], (scoped) => {
|
|
10042
10519
|
const web = scoped.get("webServer");
|
|
10043
10520
|
const connection = scoped.get("connection");
|
|
@@ -10208,7 +10685,7 @@ Content-Length: 0
|
|
|
10208
10685
|
}
|
|
10209
10686
|
try {
|
|
10210
10687
|
const duty = [spec.duty, APP_FILES_RULE, spec.subAgentOf === void 0 ? ROLE_CLOSING : void 0].filter((text2) => text2 !== void 0 && text2 !== "").join("\n\n");
|
|
10211
|
-
const text = spec === MAIN_AGENT ? () => `${mainDuty(this.roles.
|
|
10688
|
+
const text = spec === MAIN_AGENT ? () => `${mainDuty(this.roles.members())}
|
|
10212
10689
|
|
|
10213
10690
|
${APP_FILES_RULE}` : () => duty;
|
|
10214
10691
|
disposers.push(agent.ctx.systemPrompt.section({ name: "adg:role", order: 10095, interpolate: false, text }));
|
|
@@ -10220,7 +10697,7 @@ ${APP_FILES_RULE}` : () => duty;
|
|
|
10220
10697
|
if (spec.subAgentOf === void 0) {
|
|
10221
10698
|
const persona = this.persona;
|
|
10222
10699
|
const known = (member) => ({ ...member, alias: persona?.of(member.id).name });
|
|
10223
|
-
disposers.push(agent.ctx.systemPrompt.section({ name: "adg:team", order: 10096, interpolate: false, text: () => teamPrompt(spec, known(MAIN_AGENT_MEMBER), this.roles.
|
|
10700
|
+
disposers.push(agent.ctx.systemPrompt.section({ name: "adg:team", order: 10096, interpolate: false, text: () => teamPrompt(spec, known(MAIN_AGENT_MEMBER), this.roles.members().map(known), { browser: this.parts.tools.has("browser_navigate") }) }));
|
|
10224
10701
|
if (persona !== void 0)
|
|
10225
10702
|
disposers.push(agent.ctx.systemPrompt.section({ name: "adg:persona", order: 10100, interpolate: false, text: () => personaPrompt(persona.of(spec.id)) }));
|
|
10226
10703
|
}
|
|
@@ -10268,6 +10745,28 @@ ${APP_FILES_RULE}` : () => duty;
|
|
|
10268
10745
|
}
|
|
10269
10746
|
}
|
|
10270
10747
|
/** One model call outside any conversation, for its text (dsh's llm service). */
|
|
10748
|
+
/**
|
|
10749
|
+
* Something an agent writes for the user in one model call, outside any
|
|
10750
|
+
* conversation (the daily report): who it is, what it remembers, its reply
|
|
10751
|
+
* style and its model, no tools. No session is made, so none is left
|
|
10752
|
+
* behind and nothing is handed back to its own conversation to summarize again.
|
|
10753
|
+
* @throws Error when the agent is unknown or no model is set.
|
|
10754
|
+
*/
|
|
10755
|
+
async writeAs(agentId, prompt, signal) {
|
|
10756
|
+
const spec = agentId === MAIN_AGENT.id ? MAIN_AGENT : this.roles.spec(agentId);
|
|
10757
|
+
if (spec === void 0)
|
|
10758
|
+
throw new Error(`\u6CA1\u6709\u8FD9\u4E2A agent\uFF1A${agentId}`);
|
|
10759
|
+
const selection = this.agentModel(agentId) ?? this.ctx.get("agentDefaultModel")?.currentSelection();
|
|
10760
|
+
if (selection === void 0)
|
|
10761
|
+
throw new Error("\u8FD8\u6CA1\u6709\u8BBE\u7F6E\u6A21\u578B");
|
|
10762
|
+
const system = [
|
|
10763
|
+
`\u4F60\u662F MultiGameAssistant\uFF08\u591A\u6E38\u620F\u52A9\u624B\uFF09\u7684\u300C${spec.name}\u300Dagent\u3002\u8FD9\u4E00\u6B21\u53EA\u5199\u4E00\u6BB5\u7ED9\u7528\u6237\u770B\u7684\u6587\u5B57\uFF1A\u4E0D\u8C03\u7528\u5DE5\u5177\uFF0C\u4E0D\u63D0\u95EE\uFF0C\u76F4\u63A5\u7ED9\u51FA\u6B63\u6587\u3002`,
|
|
10764
|
+
spec === MAIN_AGENT ? "" : spec.duty ?? "",
|
|
10765
|
+
this.memoryViews?.current(agentId) ?? "",
|
|
10766
|
+
this.persona === void 0 ? "" : voicedPrompt(personaPrompt(this.persona.of(agentId)))
|
|
10767
|
+
].filter((part) => part !== "").join("\n\n");
|
|
10768
|
+
return (await this.completeOnce({ selection, system, prompt, signal })).trim();
|
|
10769
|
+
}
|
|
10271
10770
|
async completeOnce(request) {
|
|
10272
10771
|
const llm = this.ctx.get("llm");
|
|
10273
10772
|
if (llm === void 0)
|
|
@@ -10352,6 +10851,53 @@ ${APP_FILES_RULE}` : () => duty;
|
|
|
10352
10851
|
* sessions, and for a sub-agent, its parent's made into a sub-agent's.
|
|
10353
10852
|
* A shared dsh's other chats, and their sub-agents, are nothing of ours.
|
|
10354
10853
|
*/
|
|
10854
|
+
/**
|
|
10855
|
+
* A sub-agent's call that makes a lasting change (DECISION_AREAS) its brief does not allow: held
|
|
10856
|
+
* for its lead instead of made, and the sub-agent told so in place of the result (changes.ts).
|
|
10857
|
+
* @returns the result to give, or undefined to make the call.
|
|
10858
|
+
*/
|
|
10859
|
+
holdForLead(exec) {
|
|
10860
|
+
const sessionId = exec.agent?.session.id;
|
|
10861
|
+
if (sessionId === void 0)
|
|
10862
|
+
return void 0;
|
|
10863
|
+
const area = decisionOf(exec.name, exec.arguments);
|
|
10864
|
+
if (area === void 0 || this.specOf(sessionId)?.subAgentOf === void 0)
|
|
10865
|
+
return void 0;
|
|
10866
|
+
if (this.grantsOf(sessionId).has(area.id))
|
|
10867
|
+
return void 0;
|
|
10868
|
+
const lead = this.parentSession(sessionId);
|
|
10869
|
+
if (lead === void 0)
|
|
10870
|
+
return void 0;
|
|
10871
|
+
const change = this.held.hold({ tool: exec.name, args: exec.arguments, area, from: sessionId, lead });
|
|
10872
|
+
this.log.info(`held ${change.id} for ${lead}: ${exec.name} from ${sessionId}`);
|
|
10873
|
+
const text = heldNote(change);
|
|
10874
|
+
return { isError: false, value: { held: change.id, kind: area.title, summary: change.summary, note: text }, content: [{ type: "text", text }] };
|
|
10875
|
+
}
|
|
10876
|
+
/**
|
|
10877
|
+
* What a sub-agent's brief lets it change itself: its first message from its parent (source
|
|
10878
|
+
* `user`), not dsh's notes before it (the working directory it starts in, the runtime context…).
|
|
10879
|
+
*/
|
|
10880
|
+
grantsOf(sessionId) {
|
|
10881
|
+
const known = this.grants.get(sessionId);
|
|
10882
|
+
if (known !== void 0)
|
|
10883
|
+
return known;
|
|
10884
|
+
const session = this.agents.get(sessionId)?.session;
|
|
10885
|
+
let granted = /* @__PURE__ */ new Set();
|
|
10886
|
+
for (let seq = 0; session?.eventAt !== void 0 && seq <= (session.seq ?? 0) && seq <= 200; seq++) {
|
|
10887
|
+
const event = session.eventAt(seq);
|
|
10888
|
+
if (event?.type !== "user/message")
|
|
10889
|
+
continue;
|
|
10890
|
+
const kind = event.data?.source?.kind;
|
|
10891
|
+
if (kind !== void 0 && kind !== "user")
|
|
10892
|
+
continue;
|
|
10893
|
+
granted = grantsIn(eventText(event));
|
|
10894
|
+
break;
|
|
10895
|
+
}
|
|
10896
|
+
this.grants.set(sessionId, granted);
|
|
10897
|
+
while (this.grants.size > 500)
|
|
10898
|
+
this.grants.delete(this.grants.keys().next().value);
|
|
10899
|
+
return granted;
|
|
10900
|
+
}
|
|
10355
10901
|
specOf(sessionId) {
|
|
10356
10902
|
const header = this.agents.get(sessionId)?.session.header;
|
|
10357
10903
|
if (header?.origin === "subagent" && header.parentSession !== void 0) {
|
|
@@ -10391,11 +10937,11 @@ ${APP_FILES_RULE}` : () => duty;
|
|
|
10391
10937
|
*/
|
|
10392
10938
|
async settled(sessionId, signal) {
|
|
10393
10939
|
const subagents = this.ctx.get("subagents");
|
|
10394
|
-
const stopped = new Promise((
|
|
10940
|
+
const stopped = new Promise((resolve5) => {
|
|
10395
10941
|
if (signal.aborted)
|
|
10396
|
-
|
|
10942
|
+
resolve5();
|
|
10397
10943
|
else
|
|
10398
|
-
signal.addEventListener("abort", () =>
|
|
10944
|
+
signal.addEventListener("abort", () => resolve5(), { once: true });
|
|
10399
10945
|
});
|
|
10400
10946
|
for (; ; ) {
|
|
10401
10947
|
if (signal.aborted)
|
|
@@ -10457,10 +11003,10 @@ ${APP_FILES_RULE}` : () => duty;
|
|
|
10457
11003
|
signal.throwIfAborted();
|
|
10458
11004
|
}
|
|
10459
11005
|
await parent.send({
|
|
10460
|
-
id:
|
|
11006
|
+
id: randomUUID6(),
|
|
10461
11007
|
role: "user",
|
|
10462
11008
|
content: [{ type: "text", text: `\uFF08\u4F60\u8D1F\u8D23\u7684\u5B50\u4EFB\u52A1\uFF1A${title}\uFF09
|
|
10463
|
-
\u5DF2\u5C06\u4E0B\u5217\u6307\u4EE4\u6D3E\u7ED9\u4F60\u7684\u5B50 agent\u300C${activation.name}\u300D\u3002\u5B83\u4F1A\u76F4\u63A5\u5411\u4F60\u4EA4\u4ED8\u7ED3\u679C\u3002\u7ED3\u8BBA\u4F1A\u81EA\u52A8\u9001\u8FBE\
|
|
11009
|
+
\u5DF2\u5C06\u4E0B\u5217\u6307\u4EE4\u6D3E\u7ED9\u4F60\u7684\u5B50 agent\u300C${activation.name}\u300D\u3002\u5B83\u4F1A\u76F4\u63A5\u5411\u4F60\u4EA4\u4ED8\u7ED3\u679C\u3002\u7ED3\u8BBA\u4F1A\u81EA\u52A8\u9001\u8FBE\uFF1A\u6536\u5230\u540E\u6309\u4E0B\u9762\u7684\u5B8C\u6210\u6807\u51C6\u6838\u5BF9\u5B83\u5E26\u56DE\u7684\u8BC1\u636E\uFF0C\u518D\u6C47\u62A5\u3002\u7B49\u5F85\u671F\u95F4\u53EF\u4EE5\u5904\u7406\u5176\u4ED6\u6D88\u606F\uFF0C\u65E0\u9700\u8F6E\u8BE2\u6216\u91CD\u590D\u6D3E\u53D1\u3002
|
|
10464
11010
|
|
|
10465
11011
|
${instruction}` }],
|
|
10466
11012
|
source: { kind: "adg-task-dispatched", form: "notice", summary: title, childId }
|
|
@@ -10737,6 +11283,13 @@ ${instruction}` }],
|
|
|
10737
11283
|
agentPart(label, part) {
|
|
10738
11284
|
this.ctx.effect(() => this.parts.add(label, part), label);
|
|
10739
11285
|
}
|
|
11286
|
+
/** Add what a part of the app holds for a stretch of time to history_export (the runner's run logs). @returns the disposer. */
|
|
11287
|
+
exportPart(part) {
|
|
11288
|
+
this.exportParts.add(part);
|
|
11289
|
+
return () => {
|
|
11290
|
+
this.exportParts.delete(part);
|
|
11291
|
+
};
|
|
11292
|
+
}
|
|
10740
11293
|
/**
|
|
10741
11294
|
* One of the app's general skills (a core skill every one of its sessions
|
|
10742
11295
|
* sees). Shared, it goes through the skill scope, which shows it to the
|
|
@@ -10894,7 +11447,7 @@ ${instruction}` }],
|
|
|
10894
11447
|
return;
|
|
10895
11448
|
log.warn(`title feed interrupted: ${error instanceof Error ? error.message : String(error)}`);
|
|
10896
11449
|
}
|
|
10897
|
-
await new Promise((
|
|
11450
|
+
await new Promise((resolve5) => setTimeout(resolve5, 1e3));
|
|
10898
11451
|
}
|
|
10899
11452
|
}
|
|
10900
11453
|
};
|