dsh-multigameassistant 2.2.1 → 2.2.3
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 +1 -1
- package/lib/analyzer.js +6 -6
- package/lib/browser.js +5 -1
- package/lib/{chunk-OFVGRKTD.js → chunk-6NJSSOB6.js} +157 -27
- package/lib/{chunk-YSTZL6HE.js → chunk-A6YQRWHZ.js} +235 -158
- package/lib/{chunk-52LYI7WP.js → chunk-KMVQK5CI.js} +1 -1
- package/lib/{chunk-F7ZQE7BT.js → chunk-LXHF6AKU.js} +38 -15
- package/lib/{chunk-IBPJC6DX.js → chunk-RGEGJH6R.js} +1 -1
- package/lib/{chunk-EOZKHLHK.js → chunk-TELJUUBZ.js} +28 -5
- package/lib/{chunk-NOZCFSQP.js → chunk-YTIR5JW4.js} +32 -18
- package/lib/emulator.js +1 -1
- package/lib/feishu.js +4 -4
- package/lib/game-intel.js +4279 -348
- package/lib/gateway.js +3 -3
- package/lib/guard.js +1 -1
- package/lib/intervene.js +19 -9
- package/lib/low-context.js +2 -2
- package/lib/monitor.js +20 -3
- package/lib/notify.js +4 -4
- package/lib/orchestrator.js +67 -12
- package/lib/qqbot.js +4 -4
- 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/web-reading.md +2 -2
- package/web/assets/index-DwItOcWq.css +1 -0
- package/web/assets/index-YiJ--jV1.js +255 -0
- package/web/assets/index-YiJ--jV1.js.map +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-BBPTH2CM.css +0 -1
- package/web/assets/index-DRxvDcu6.js +0 -245
- package/web/assets/index-DRxvDcu6.js.map +0 -1
- /package/lib/{chunk-NOZCFSQP.js.LEGAL.txt → chunk-YTIR5JW4.js.LEGAL.txt} +0 -0
package/cordis.patch.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-multigameassistant 2.2.
|
|
1
|
+
# dsh-multigameassistant 2.2.3
|
|
2
2
|
# dsh-multigameassistant: the app's plugins (packages/bundle/cordis.patch.yml, each @adg/<plugin> as dsh-multigameassistant/<plugin>)
|
|
3
3
|
# sharing the dsh with the person's other chats, and the app's agent preset (dsh's standard one with the app's
|
|
4
4
|
# tools and prompts, and compaction as 设置 → 对话压缩 says). No row of dsh is restated.
|
package/lib/analyzer.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
discoverMcp,
|
|
4
4
|
discoverSkills,
|
|
5
5
|
mcpEndpoints
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YTIR5JW4.js";
|
|
7
7
|
import {
|
|
8
8
|
probeProject
|
|
9
9
|
} from "./chunk-B4UT4NYH.js";
|
|
@@ -15,16 +15,16 @@ import {
|
|
|
15
15
|
parseManifest,
|
|
16
16
|
require_dist,
|
|
17
17
|
stripJsonc
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-RGEGJH6R.js";
|
|
19
|
+
import "./chunk-A6YQRWHZ.js";
|
|
20
|
+
import "./chunk-6NJSSOB6.js";
|
|
21
|
+
import "./chunk-KMVQK5CI.js";
|
|
22
22
|
import "./chunk-RESS7WVY.js";
|
|
23
23
|
import {
|
|
24
24
|
BUILTIN_PACK_VERSION,
|
|
25
25
|
PACKS_CAPABILITY,
|
|
26
26
|
ScriptId
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-LXHF6AKU.js";
|
|
28
28
|
import {
|
|
29
29
|
external_exports
|
|
30
30
|
} from "./chunk-6DSSLS7I.js";
|
package/lib/browser.js
CHANGED
|
@@ -189,11 +189,15 @@ ${v.url}
|
|
|
189
189
|
},
|
|
190
190
|
render: (_args, value) => {
|
|
191
191
|
const v = value;
|
|
192
|
+
const media = v.images?.length ? `
|
|
193
|
+
|
|
194
|
+
\u9875\u9762\u914D\u56FE\u5019\u9009\uFF08\u4F9D\u6B21\u4E3A\u5206\u4EAB\u56FE\u3001\u6B63\u6587\u56FE\uFF09\uFF1A
|
|
195
|
+
${v.images.join("\n")}` : "";
|
|
192
196
|
return [{ type: "text", text: `\u6807\u7B7E\u9875 ${v.tab}\uFF1A${v.title}
|
|
193
197
|
${v.url}
|
|
194
198
|
|
|
195
199
|
${v.text}${v.truncated === void 0 ? "" : `
|
|
196
|
-
\u2026\uFF08\u8FD8\u6709 ${v.truncated} \u5B57\uFF0C\u52A0\u5927 max_chars \u770B\u66F4\u591A\uFF09`}` }];
|
|
200
|
+
\u2026\uFF08\u8FD8\u6709 ${v.truncated} \u5B57\uFF0C\u52A0\u5927 max_chars \u770B\u66F4\u591A\uFF09`}${media}` }];
|
|
197
201
|
}
|
|
198
202
|
}),
|
|
199
203
|
tool({
|
|
@@ -2,7 +2,7 @@ import { createRequire as __adgCreateRequire } from 'node:module'; import { dirn
|
|
|
2
2
|
import {
|
|
3
3
|
SUMMARIES_FILE,
|
|
4
4
|
summariesReader
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KMVQK5CI.js";
|
|
6
6
|
import {
|
|
7
7
|
writeFileAtomic
|
|
8
8
|
} from "./chunk-RESS7WVY.js";
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
personaPrompt,
|
|
44
44
|
threadsBetween,
|
|
45
45
|
timetableText
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-LXHF6AKU.js";
|
|
47
47
|
import {
|
|
48
48
|
external_exports
|
|
49
49
|
} from "./chunk-6DSSLS7I.js";
|
|
@@ -3725,7 +3725,7 @@ var require_websocket_server = __commonJS({
|
|
|
3725
3725
|
|
|
3726
3726
|
// packages/gateway/lib/index.js
|
|
3727
3727
|
import { execFile as execFile2 } from "node:child_process";
|
|
3728
|
-
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
3728
|
+
import { randomBytes as randomBytes2, randomUUID as randomUUID5 } from "node:crypto";
|
|
3729
3729
|
import { existsSync, mkdirSync as mkdirSync6, readFileSync as readFileSync3, writeFileSync } from "node:fs";
|
|
3730
3730
|
import { dirname as dirname7, join as join8 } from "node:path";
|
|
3731
3731
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -6649,6 +6649,7 @@ function convertEvent(event) {
|
|
|
6649
6649
|
kind,
|
|
6650
6650
|
human: HUMAN_SOURCES.has(kind),
|
|
6651
6651
|
...opt("summary", source.form === "notice" ? str2(source.summary) : void 0),
|
|
6652
|
+
...opt("childId", kind === "adg-task-dispatched" ? str2(source.childId) : void 0),
|
|
6652
6653
|
...opt("fallback", kind === MODEL_FALLBACK_SOURCE ? fallbackOf(source.fallback) : void 0)
|
|
6653
6654
|
},
|
|
6654
6655
|
...opt("requestId", str2(source.rpcId)),
|
|
@@ -6687,7 +6688,7 @@ function convertEvent(event) {
|
|
|
6687
6688
|
if (turn === void 0 || step === void 0)
|
|
6688
6689
|
return unknown();
|
|
6689
6690
|
const facts = streamFacts(d.stream);
|
|
6690
|
-
return { type: "assistant/attempt", seq, time, turn, step, timing: facts.timing, ...opt("error", facts.failure) };
|
|
6691
|
+
return { type: "assistant/attempt", seq, time, turn, step, timing: facts.timing, ...opt("usage", convertUsage(d.usage)), ...opt("error", facts.failure) };
|
|
6691
6692
|
}
|
|
6692
6693
|
case "tool/call":
|
|
6693
6694
|
if (turn === void 0 || step === void 0)
|
|
@@ -7475,14 +7476,16 @@ var HandOffs = class {
|
|
|
7475
7476
|
#listeners = /* @__PURE__ */ new Set();
|
|
7476
7477
|
loaded;
|
|
7477
7478
|
constructor(file, changed = () => {
|
|
7478
|
-
}) {
|
|
7479
|
+
}, log = console) {
|
|
7479
7480
|
this.#file = file;
|
|
7480
7481
|
this.#changed = changed;
|
|
7481
|
-
this.loaded = this.#load()
|
|
7482
|
+
this.loaded = this.#load().catch((error) => {
|
|
7483
|
+
log.warn(`\u5199\u56DE\u4E2D\u65AD\u4EFB\u52A1\u72B6\u6001\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`);
|
|
7484
|
+
});
|
|
7482
7485
|
}
|
|
7483
7486
|
/** Those from or to this conversation, oldest first. */
|
|
7484
7487
|
of(sessionId) {
|
|
7485
|
-
return [...this.#items.values()].filter((h) => h.fromSession === sessionId || h.toSession === sessionId);
|
|
7488
|
+
return [...this.#items.values()].filter((h) => h.fromSession === sessionId || h.toSession === sessionId || h.ownerSession === sessionId);
|
|
7486
7489
|
}
|
|
7487
7490
|
get(id) {
|
|
7488
7491
|
return this.#items.get(id);
|
|
@@ -7523,6 +7526,7 @@ var HandOffs = class {
|
|
|
7523
7526
|
async #load() {
|
|
7524
7527
|
if (this.#file === void 0)
|
|
7525
7528
|
return;
|
|
7529
|
+
let recovered = false;
|
|
7526
7530
|
try {
|
|
7527
7531
|
const saved = JSON.parse(await readFile7(this.#file, "utf8"));
|
|
7528
7532
|
if (!Array.isArray(saved))
|
|
@@ -7530,10 +7534,17 @@ var HandOffs = class {
|
|
|
7530
7534
|
for (const item of saved) {
|
|
7531
7535
|
if (typeof item?.id !== "string")
|
|
7532
7536
|
continue;
|
|
7533
|
-
|
|
7537
|
+
if (item.state === "running" || item.state === "waiting") {
|
|
7538
|
+
this.#items.set(item.id, { ...item, state: "failed", reply: "\u8F6F\u4EF6\u5173\u95ED\u65F6\u5B83\u8FD8\u6CA1\u505A\u5B8C\uFF0C\u8FD9\u4E00\u8F6E\u4E2D\u65AD\u4E86", endedAt: Date.now() });
|
|
7539
|
+
recovered = true;
|
|
7540
|
+
} else
|
|
7541
|
+
this.#items.set(item.id, item);
|
|
7534
7542
|
}
|
|
7535
7543
|
} catch {
|
|
7544
|
+
return;
|
|
7536
7545
|
}
|
|
7546
|
+
if (recovered)
|
|
7547
|
+
await this.#save();
|
|
7537
7548
|
}
|
|
7538
7549
|
};
|
|
7539
7550
|
|
|
@@ -7701,7 +7712,7 @@ function keeps(tools, name) {
|
|
|
7701
7712
|
function matches(patterns, name) {
|
|
7702
7713
|
return patterns.some((pattern) => pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern);
|
|
7703
7714
|
}
|
|
7704
|
-
var NOBODY = ["subagent_fork"];
|
|
7715
|
+
var NOBODY = ["subagent_fork", "wait_agent"];
|
|
7705
7716
|
var TOGETHER = ["agent_delegate", "agent_message", "agent_threads"];
|
|
7706
7717
|
var MEMORY_TOOLS = ["memory_save", "memory_forget", "memory_search", "history_search", "history_read"];
|
|
7707
7718
|
var ALWAYS = [...TOGETHER, ...MEMORY_TOOLS];
|
|
@@ -7755,7 +7766,7 @@ function teamPrompt(self, main, leads, options = {}) {
|
|
|
7755
7766
|
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`,
|
|
7756
7767
|
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
|
|
7757
7768
|
${colleagues.map(line2).join("\n")}`,
|
|
7758
|
-
"\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\u8FD0\u884C\u548C\u5B89\u88C5\u811A\u672C\u3001\u542F\u52A8\u6E38\u620F\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\uFF0C\u628A\u4EFB\u52A1\u5199\u5B8C\u6574\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\u3002\u51E0\u4EF6\u4E92\u4E0D\u76F8\u5173\u7684\u4E8B\u53EF\u4EE5\u540C\u65F6\u5F00\u3002\
|
|
7769
|
+
"\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\u8FD0\u884C\u548C\u5B89\u88C5\u811A\u672C\u3001\u542F\u52A8\u6E38\u620F\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\uFF0C\u628A\u4EFB\u52A1\u5199\u5B8C\u6574\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\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",
|
|
7759
7770
|
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" : "",
|
|
7760
7771
|
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`,
|
|
7761
7772
|
"\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",
|
|
@@ -8008,6 +8019,8 @@ function fallbackReason(failure) {
|
|
|
8008
8019
|
return "\u6A21\u578B\u4E0D\u53EF\u7528";
|
|
8009
8020
|
if (LIMIT_CODES.has(code))
|
|
8010
8021
|
return "\u8BF7\u6C42\u592A\u9891\u7E41\uFF0C\u91CD\u8BD5\u540E\u4ECD\u88AB\u9650\u6D41";
|
|
8022
|
+
if (code === "TIMEOUT")
|
|
8023
|
+
return "\u6A21\u578B\u8BF7\u6C42\u8D85\u65F6\uFF0C\u91CD\u8BD5\u540E\u4ECD\u65E0\u54CD\u5E94";
|
|
8011
8024
|
if (code === "SERVER" || /^HTTP_5\d\d$/.test(code))
|
|
8012
8025
|
return "\u6A21\u578B\u670D\u52A1\u51FA\u9519\uFF0C\u91CD\u8BD5\u540E\u4ECD\u7136\u5931\u8D25";
|
|
8013
8026
|
return void 0;
|
|
@@ -9034,6 +9047,7 @@ function ownerInfo(owner) {
|
|
|
9034
9047
|
return { owner: { ...owner.scripts === void 0 ? {} : { scripts: [...owner.scripts] }, ...owner.games === void 0 ? {} : { games: [...owner.games] } } };
|
|
9035
9048
|
}
|
|
9036
9049
|
var ROLE_CLOSING = [
|
|
9050
|
+
"\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\u76F4\u63A5\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",
|
|
9037
9051
|
"\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",
|
|
9038
9052
|
"\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",
|
|
9039
9053
|
"\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"
|
|
@@ -9151,6 +9165,8 @@ var AdgGateway = class extends Service {
|
|
|
9151
9165
|
/** Live agents by session, and what narrows each to its role (`narrow`). */
|
|
9152
9166
|
agents = /* @__PURE__ */ new Map();
|
|
9153
9167
|
narrowed = /* @__PURE__ */ new Map();
|
|
9168
|
+
appChildren = /* @__PURE__ */ new Set();
|
|
9169
|
+
assignedSpecs = /* @__PURE__ */ new WeakMap();
|
|
9154
9170
|
subAgentSpecs = /* @__PURE__ */ new WeakMap();
|
|
9155
9171
|
persona;
|
|
9156
9172
|
/**
|
|
@@ -9176,7 +9192,7 @@ var AdgGateway = class extends Service {
|
|
|
9176
9192
|
this.agentModels = new AgentModels(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "agent-models.json"), config.dataDir === void 0 ? void 0 : join8(config.dataDir, "role-model.json"));
|
|
9177
9193
|
this.roles = new SessionRoles(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "session-roles.json"), () => this.broadcast("roles/changed", { items: this.roles.list() }));
|
|
9178
9194
|
this.homes = new AgentHomes(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "agent-homes.json"));
|
|
9179
|
-
this.handOffs = new HandOffs(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "handoffs.json"), (item) => this.broadcast("handoffs/changed", { item }));
|
|
9195
|
+
this.handOffs = new HandOffs(config.dataDir === void 0 ? void 0 : join8(config.dataDir, "handoffs.json"), (item) => this.broadcast("handoffs/changed", { item }), log);
|
|
9180
9196
|
if (!this.shared)
|
|
9181
9197
|
ctx.inject(["tools", "systemPrompt"], (scoped) => {
|
|
9182
9198
|
scoped.effect(() => this.parts.attach(scoped), "adg-gateway agent parts");
|
|
@@ -9344,6 +9360,18 @@ var AdgGateway = class extends Service {
|
|
|
9344
9360
|
await this.routeSubAgent(payload.agent);
|
|
9345
9361
|
}));
|
|
9346
9362
|
ctx.on("tools/execute", ((exec, next) => {
|
|
9363
|
+
if ((exec.name === "subagent" || exec.name === "list_subagent_models") && exec.agent !== void 0) {
|
|
9364
|
+
const parent = this.specOf(exec.agent.session.id);
|
|
9365
|
+
if (parent !== void 0) {
|
|
9366
|
+
const pinned = exec.name === "subagent" && this.subAgentModel(memoryOwnerOf(parent)) !== void 0;
|
|
9367
|
+
const args = { ...exec.arguments };
|
|
9368
|
+
for (const field of ["provider", "model", "reasoning_effort"]) {
|
|
9369
|
+
if (pinned || args[field] === "")
|
|
9370
|
+
delete args[field];
|
|
9371
|
+
}
|
|
9372
|
+
exec.arguments = args;
|
|
9373
|
+
}
|
|
9374
|
+
}
|
|
9347
9375
|
if (exec.name === "schedule_create" && exec.agent !== void 0 && typeof exec.arguments.prompt === "string") {
|
|
9348
9376
|
const desk = this.handOffDesk;
|
|
9349
9377
|
const noted = desk?.reminderNote?.(exec.agent.session.id, exec.arguments.prompt);
|
|
@@ -10164,8 +10192,13 @@ Content-Length: 0
|
|
|
10164
10192
|
refused.add(name);
|
|
10165
10193
|
}
|
|
10166
10194
|
}
|
|
10167
|
-
|
|
10168
|
-
|
|
10195
|
+
disposers.push(tools.guard((exec) => {
|
|
10196
|
+
if (exec.name === "wait_agent")
|
|
10197
|
+
return "\u5B50\u4EFB\u52A1\u7684\u7EC8\u6001\u4F1A\u81EA\u52A8\u9001\u8FBE\u3002\u5DF2\u6536\u5230\u4EA4\u4ED8\u901A\u77E5\u5C31\u76F4\u63A5\u5904\u7406\u7ED3\u679C\uFF1B\u53EA\u5269\u672A\u4EA4\u4ED8\u7684\u4EFB\u52A1\u65F6\u7ED3\u675F\u672C\u8F6E\u3002";
|
|
10198
|
+
if (refused.has(exec.name))
|
|
10199
|
+
return home && handsOn(exec.name) ? HANDS_ON_REFUSAL(exec.name) : `${spec.name}\u4E0D\u80FD\u7528 ${exec.name}`;
|
|
10200
|
+
return void 0;
|
|
10201
|
+
}));
|
|
10169
10202
|
if (spec.subAgentOf === void 0) {
|
|
10170
10203
|
disposers.push(tools.guard((exec) => exec.name === "ask_user_question" ? this.handOffDesk?.askRefusal?.(agent.session.id) : void 0));
|
|
10171
10204
|
}
|
|
@@ -10275,7 +10308,8 @@ Content-Length: 0
|
|
|
10275
10308
|
}
|
|
10276
10309
|
/** The agent working in a session, as other agents address it. A sub-agent is nobody to them. */
|
|
10277
10310
|
agentOfSession(sessionId) {
|
|
10278
|
-
const
|
|
10311
|
+
const owner = this.appChildren.has(sessionId) ? this.parentSession(sessionId) : void 0;
|
|
10312
|
+
const spec = this.specOf(owner ?? sessionId);
|
|
10279
10313
|
return spec === void 0 || spec.subAgentOf !== void 0 ? void 0 : { id: spec.id, name: spec.name };
|
|
10280
10314
|
}
|
|
10281
10315
|
/**
|
|
@@ -10323,6 +10357,20 @@ Content-Length: 0
|
|
|
10323
10357
|
return void 0;
|
|
10324
10358
|
if (parent.subAgentOf !== void 0)
|
|
10325
10359
|
return parent;
|
|
10360
|
+
if (this.appChildren.has(sessionId)) {
|
|
10361
|
+
let assigned = this.assignedSpecs.get(parent);
|
|
10362
|
+
if (!assigned) {
|
|
10363
|
+
const child2 = subAgentSpec(parent);
|
|
10364
|
+
const tools = /* @__PURE__ */ new Set(["agent_message", "ask_user_question", ...parent.id === "intervene" ? ["intervention_done"] : []]);
|
|
10365
|
+
assigned = {
|
|
10366
|
+
...child2,
|
|
10367
|
+
hide: (child2.hide ?? []).filter((name) => !tools.has(name)),
|
|
10368
|
+
duty: child2.duty?.replace("\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" + parent.name + "\u300D\u53BB\u95EE\u3002", "\u9700\u8981\u8865\u5145\u4FE1\u606F\u65F6\u901A\u8FC7\u5F53\u524D\u59D4\u6D3E\u7EBF\u7D22\u8054\u7CFB\u53D1\u8D77\u65B9\uFF1B\u76F4\u63A5\u7531\u8F6F\u4EF6\u53D1\u8D77\u7684\u4EFB\u52A1\u53EF\u4EE5\u8BE2\u95EE\u7528\u6237\u3002") ?? ""
|
|
10369
|
+
};
|
|
10370
|
+
this.assignedSpecs.set(parent, assigned);
|
|
10371
|
+
}
|
|
10372
|
+
return assigned;
|
|
10373
|
+
}
|
|
10326
10374
|
let child = this.subAgentSpecs.get(parent);
|
|
10327
10375
|
if (child === void 0)
|
|
10328
10376
|
this.subAgentSpecs.set(parent, child = subAgentSpec(parent));
|
|
@@ -10362,7 +10410,82 @@ Content-Length: 0
|
|
|
10362
10410
|
return;
|
|
10363
10411
|
}
|
|
10364
10412
|
}
|
|
10365
|
-
|
|
10413
|
+
promptChild(request, signal) {
|
|
10414
|
+
const service = this.ctx.get("subagents");
|
|
10415
|
+
if (!service)
|
|
10416
|
+
throw new Error("\u539F\u751F\u5B50\u4EE3\u7406\u670D\u52A1\u672A\u52A0\u8F7D");
|
|
10417
|
+
return service.prompt(request, signal);
|
|
10418
|
+
}
|
|
10419
|
+
/** App actions are addressed to an agent's home. dsh owns child membership, model selection, settlement and parent delivery. */
|
|
10420
|
+
async runChild(owner, childId, title, instruction, signal, images = []) {
|
|
10421
|
+
if (!this.homes.agentOf(owner))
|
|
10422
|
+
throw new Error("\u4EFB\u52A1\u5FC5\u987B\u4ECE\u52A9\u624B\u7684\u4E3B\u5BF9\u8BDD\u6D3E\u53D1");
|
|
10423
|
+
const service = this.ctx.get("subagents");
|
|
10424
|
+
if (!service)
|
|
10425
|
+
throw new Error("\u539F\u751F\u5B50\u4EE3\u7406\u670D\u52A1\u672A\u52A0\u8F7D");
|
|
10426
|
+
const resolved = await this.ctx.sessionController.resolveAgent(owner);
|
|
10427
|
+
if (!("agent" in resolved))
|
|
10428
|
+
throw new Error("\u65E0\u6CD5\u6062\u590D\u8D1F\u8D23\u8FD9\u9879\u4EFB\u52A1\u7684\u4E3B\u52A9\u624B");
|
|
10429
|
+
const parent = resolved.agent;
|
|
10430
|
+
signal.throwIfAborted();
|
|
10431
|
+
const ptc = this.compaction?.state().settings.ptcSubagents ?? true;
|
|
10432
|
+
this.appChildren.add(childId);
|
|
10433
|
+
try {
|
|
10434
|
+
const activation = await service.startActivation({
|
|
10435
|
+
provider: "spawn",
|
|
10436
|
+
parent,
|
|
10437
|
+
childId,
|
|
10438
|
+
label: title,
|
|
10439
|
+
...ptc ? { agentPreset: this.shared ? "mga-ptc" : "ptc" } : {},
|
|
10440
|
+
prompt: [{ type: "text", text: instruction }, ...images.map((png) => ({ type: "image", mediaType: "image/png", data: png.toString("base64") }))],
|
|
10441
|
+
delivery: "parent",
|
|
10442
|
+
signal
|
|
10443
|
+
});
|
|
10444
|
+
let stopping;
|
|
10445
|
+
const cancel = () => {
|
|
10446
|
+
stopping ??= activation.dispose();
|
|
10447
|
+
void stopping.catch(() => {
|
|
10448
|
+
});
|
|
10449
|
+
};
|
|
10450
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
10451
|
+
try {
|
|
10452
|
+
if (signal.aborted) {
|
|
10453
|
+
cancel();
|
|
10454
|
+
signal.throwIfAborted();
|
|
10455
|
+
}
|
|
10456
|
+
await parent.send({
|
|
10457
|
+
id: randomUUID5(),
|
|
10458
|
+
role: "user",
|
|
10459
|
+
content: [{ type: "text", text: `\uFF08\u4F60\u8D1F\u8D23\u7684\u5B50\u4EFB\u52A1\uFF1A${title}\uFF09
|
|
10460
|
+
\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\uFF0C\u6536\u5230\u540E\u5411\u7528\u6237\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
|
|
10461
|
+
|
|
10462
|
+
${instruction}` }],
|
|
10463
|
+
source: { kind: "adg-task-dispatched", form: "notice", summary: title, childId }
|
|
10464
|
+
}, "next-step", false);
|
|
10465
|
+
const result = await activation.result;
|
|
10466
|
+
signal.throwIfAborted();
|
|
10467
|
+
if (result.stopReason === "aborted" || result.stopReason === "interrupted")
|
|
10468
|
+
throw new DOMException(result.diagnostic || "\u5B50\u4EFB\u52A1\u5DF2\u505C\u6B62", "AbortError");
|
|
10469
|
+
if (result.stopReason !== "completed")
|
|
10470
|
+
throw new Error(result.diagnostic || `\u5B50\u4EFB\u52A1\u4E2D\u65AD\uFF08${result.stopReason}\uFF09`);
|
|
10471
|
+
const answer = result.output.filter((p) => p.type === "text").map((p) => p.text ?? "").join("\n").trim();
|
|
10472
|
+
if (!answer)
|
|
10473
|
+
throw new Error("\u5B50\u4EE3\u7406\u7ED3\u675F\u65F6\u6CA1\u6709\u4EA4\u56DE\u7ED3\u8BBA");
|
|
10474
|
+
return answer;
|
|
10475
|
+
} catch (error) {
|
|
10476
|
+
cancel();
|
|
10477
|
+
throw error;
|
|
10478
|
+
} finally {
|
|
10479
|
+
signal.removeEventListener("abort", cancel);
|
|
10480
|
+
await stopping;
|
|
10481
|
+
}
|
|
10482
|
+
} finally {
|
|
10483
|
+
this.appChildren.delete(childId);
|
|
10484
|
+
const child = this.agents.get(childId);
|
|
10485
|
+
if (child)
|
|
10486
|
+
this.narrow(child);
|
|
10487
|
+
}
|
|
10488
|
+
}
|
|
10366
10489
|
stopSubAgent(sessionId) {
|
|
10367
10490
|
const parent = this.agents.get(sessionId)?.session.header?.parentSession;
|
|
10368
10491
|
if (parent === void 0)
|
|
@@ -10372,7 +10495,7 @@ Content-Length: 0
|
|
|
10372
10495
|
/** Stop the sub-agents working under this session's agent (a hand-off called off stops them with it). */
|
|
10373
10496
|
stopSubAgents(sessionId) {
|
|
10374
10497
|
for (const agent of this.agents.values()) {
|
|
10375
|
-
if (agent.session.header?.parentSession !== sessionId || agent.session.header.origin !== "subagent")
|
|
10498
|
+
if (this.appChildren.has(agent.session.id) || agent.session.header?.parentSession !== sessionId || agent.session.header.origin !== "subagent")
|
|
10376
10499
|
continue;
|
|
10377
10500
|
try {
|
|
10378
10501
|
this.stopSubAgent(agent.session.id);
|
|
@@ -10473,8 +10596,7 @@ Content-Length: 0
|
|
|
10473
10596
|
* (agent-models.ts); else dsh gives it its parent's. The choice is made as
|
|
10474
10597
|
* the sub-agent is created (agent.model, as dsh's own model choice is), so its
|
|
10475
10598
|
* steps use that model from the first and its system prompt names it. A model
|
|
10476
|
-
* that cannot be
|
|
10477
|
-
* than failing the work. Never throws: a throw would fail the sub-agent.
|
|
10599
|
+
* that cannot be resolved is tried against the configured child fallback list.
|
|
10478
10600
|
*/
|
|
10479
10601
|
async routeSubAgent(agent) {
|
|
10480
10602
|
if (agent.session.header?.origin !== "subagent" || !this.isOwn(agent.session.id))
|
|
@@ -10483,18 +10605,26 @@ Content-Length: 0
|
|
|
10483
10605
|
if (spec?.subAgentOf === void 0)
|
|
10484
10606
|
return;
|
|
10485
10607
|
const model = this.subAgentModel(memoryOwnerOf(spec));
|
|
10486
|
-
if (model === void 0
|
|
10608
|
+
if (model === void 0)
|
|
10487
10609
|
return;
|
|
10488
|
-
const route = { provider: model.provider, model: model.model, ...model.reasoningEffort === void 0 ? {} : { reasoningEffort: model.reasoningEffort } };
|
|
10489
10610
|
const llm = this.ctx.get("llm");
|
|
10490
|
-
if (llm === void 0)
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10611
|
+
if (llm === void 0 || agent.model === void 0)
|
|
10612
|
+
throw new Error("\u5B50\u4EE3\u7406\u6A21\u578B\u670D\u52A1\u5C1A\u672A\u5C31\u7EEA");
|
|
10613
|
+
const tried = /* @__PURE__ */ new Set();
|
|
10614
|
+
for (const route of [model, ...this.agentModels.fallbacksOf(true)]) {
|
|
10615
|
+
const key = `${route.provider}/${route.model}`;
|
|
10616
|
+
if (tried.has(key))
|
|
10617
|
+
continue;
|
|
10618
|
+
tried.add(key);
|
|
10619
|
+
try {
|
|
10620
|
+
await llm.resolveCallConfig(route, AbortSignal.timeout(1e4));
|
|
10621
|
+
agent.model.select({ provider: route.provider, model: route.model, ...route.reasoningEffort === void 0 ? {} : { reasoningEffort: route.reasoningEffort } });
|
|
10622
|
+
return;
|
|
10623
|
+
} catch (error) {
|
|
10624
|
+
this.log.warn(`\u5B50\u4EE3\u7406\u6A21\u578B ${key} \u65E0\u6CD5\u4F7F\u7528\uFF1A${String(error)}`);
|
|
10625
|
+
}
|
|
10497
10626
|
}
|
|
10627
|
+
throw new Error(`\u5B50\u4EE3\u7406\u6A21\u578B\u5747\u4E0D\u53EF\u7528\uFF1A${[...tried].join("\u3001")}`);
|
|
10498
10628
|
}
|
|
10499
10629
|
/** Why a model chosen for this layer will not do: it cannot see images and the work there looks at screenshots. */
|
|
10500
10630
|
async visionWarning(model, target) {
|