dsh-multigameassistant 2.2.1 → 2.2.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 +1 -1
- package/lib/analyzer.js +6 -6
- package/lib/browser.js +5 -1
- package/lib/{chunk-YSTZL6HE.js → chunk-6YPSKAQ5.js} +161 -123
- package/lib/{chunk-NOZCFSQP.js → chunk-CCYE6H2F.js} +32 -18
- package/lib/{chunk-OFVGRKTD.js → chunk-DSWWQWQH.js} +137 -23
- 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/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-CCYE6H2F.js.LEGAL.txt} +0 -0
|
@@ -35,13 +35,13 @@ import {
|
|
|
35
35
|
parseJsonc,
|
|
36
36
|
parseManifest,
|
|
37
37
|
versionOfTag
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-RGEGJH6R.js";
|
|
39
39
|
import {
|
|
40
40
|
sessionConversations
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-6YPSKAQ5.js";
|
|
42
42
|
import {
|
|
43
43
|
pluginVersion
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-DSWWQWQH.js";
|
|
45
45
|
import {
|
|
46
46
|
ExeIcons,
|
|
47
47
|
writeFileAtomic
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
optimizeScriptPrompt,
|
|
65
65
|
parseGitHubLink,
|
|
66
66
|
taskMessage
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-LXHF6AKU.js";
|
|
68
68
|
import {
|
|
69
69
|
NEVER,
|
|
70
70
|
ZodIssueCode,
|
|
@@ -2976,7 +2976,8 @@ function packReview(ctx, library, log) {
|
|
|
2976
2976
|
throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
|
|
2977
2977
|
const gateway = ctx.get("adgGateway");
|
|
2978
2978
|
const conversations = sessionConversations(sessions, () => gateway?.workspaceDir(), (sessionId2, focus) => gateway?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => gateway);
|
|
2979
|
-
const
|
|
2979
|
+
const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u68C0\u67E5\u811A\u672C\u5305\uFF1A${script.name}`, { scripts: [id] });
|
|
2980
|
+
const sessionId = work.owner;
|
|
2980
2981
|
const from = script.packReview?.from ?? "\u65E7\u7248\u672C";
|
|
2981
2982
|
const to = script.packReview?.to ?? script.localVersion?.version ?? script.current ?? "\u65B0\u7248\u672C";
|
|
2982
2983
|
const prompt = [
|
|
@@ -2987,8 +2988,11 @@ function packReview(ctx, library, log) {
|
|
|
2987
2988
|
"3. \u8981\u6539\u5C31\u7528\u539F\u6765\u7684\u811A\u672C\u5305 id \u8C03\u7528 pack_propose \u4FDD\u5B58\uFF08\u76F4\u63A5\u751F\u6548\uFF1Bsummary \u5199\u660E\u4F9D\u636E\u66F4\u65B0\u65E5\u5FD7\u6539\u4E86\u4EC0\u4E48\uFF09\uFF1B\u4E0D\u7528\u6539\u5C31\u8C03\u7528 pack_reviewed \u8BF4\u660E\u7406\u7531\uFF1B",
|
|
2988
2989
|
"4. \u6700\u540E\u7528\u4E24\u4E09\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u7ED3\u8BBA\u3002"
|
|
2989
2990
|
].join("\n");
|
|
2990
|
-
|
|
2991
|
-
|
|
2991
|
+
close("\u811A\u672C agent \u6B63\u5728\u68C0\u67E5");
|
|
2992
|
+
void work.run(taskMessage("\u4F60", `\u68C0\u67E5\u811A\u672C\u5305\uFF1A${script.name}`, prompt), AbortSignal.timeout(REVIEW_TIMEOUT_MS)).then((answer) => close(`\u68C0\u67E5\u7ED3\u679C\uFF1A${answer.slice(0, 400)}`), (error) => {
|
|
2993
|
+
close(`\u68C0\u67E5\u672A\u5B8C\u6210\uFF1A${String(error)}`);
|
|
2994
|
+
log.warn(`pack review for ${id}: ${String(error)}`);
|
|
2995
|
+
});
|
|
2992
2996
|
return { sessionId };
|
|
2993
2997
|
};
|
|
2994
2998
|
ctx.inject(["adgNotify"], (scoped) => {
|
|
@@ -2996,6 +3000,8 @@ function packReview(ctx, library, log) {
|
|
|
2996
3000
|
const id = noticeId.split(":")[1];
|
|
2997
3001
|
if (id === void 0 || actionId !== "check" && actionId !== "keep")
|
|
2998
3002
|
throw new Error(`\u672A\u77E5\u64CD\u4F5C ${actionId}`);
|
|
3003
|
+
if (noticeId !== noticeIdOf(id, library().get(id).packReview?.to ?? ""))
|
|
3004
|
+
throw new Error("\u8BE5\u7248\u672C\u7684\u68C0\u67E5\u5DF2\u7ED3\u675F\uFF0C\u8BF7\u67E5\u770B\u6700\u65B0\u7248\u672C");
|
|
2999
3005
|
const { sessionId } = await decide(id, actionId);
|
|
3000
3006
|
return sessionId === void 0 ? "\u597D\u7684\uFF0C\u811A\u672C\u5305\u4FDD\u6301\u4E0D\u53D8" : "\u597D\u7684\uFF0Cagent \u5148\u8BFB\u66F4\u65B0\u65E5\u5FD7\uFF0C\u518D\u68C0\u67E5\u811A\u672C\u5305\uFF1B\u8981\u6539\u7684\u5B83\u4F1A\u76F4\u63A5\u6539\u597D\uFF0C\u7ED3\u679C\u4F1A\u544A\u8BC9\u4F60";
|
|
3001
3007
|
}), "adg-scripts pack review actions");
|
|
@@ -3008,6 +3014,11 @@ function packReview(ctx, library, log) {
|
|
|
3008
3014
|
const notify = ctx.get("adgNotify");
|
|
3009
3015
|
if (notify === void 0)
|
|
3010
3016
|
return;
|
|
3017
|
+
for (const old of notify.notify.notices()) {
|
|
3018
|
+
if (old.id.startsWith(`${PACK_REVIEW_SCOPE}:${script.id}:`) && old.id !== noticeIdOf(script.id, review.to) && !old.done) {
|
|
3019
|
+
void notify.update(old.id, { done: `\u5DF2\u6709\u66F4\u65B0\u7684\u5F85\u68C0\u67E5\u7248\u672C ${review.to}` }).catch((error) => log.warn(String(error)));
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3011
3022
|
void notify.send({
|
|
3012
3023
|
id: noticeIdOf(script.id, review.to),
|
|
3013
3024
|
scope: PACK_REVIEW_SCOPE,
|
|
@@ -3038,7 +3049,7 @@ function optimizer(ctx, library, log) {
|
|
|
3038
3049
|
void ctx.get("adgNotify")?.update(noticeId, { done }).catch(() => {
|
|
3039
3050
|
});
|
|
3040
3051
|
};
|
|
3041
|
-
const why = (script) => script.optimize?.due === "updated" ? `\u66F4\u65B0\u5230 ${script.current ?? script.localVersion?.version ?? "\
|
|
3052
|
+
const why = (script) => script.optimize?.due === "updated" ? `\u66F4\u65B0\u5230 ${(script.current === "local" ? script.localVersion?.version : script.current ?? script.localVersion?.version) ?? "\u672A\u77E5\u7248\u672C"} \u540E\u5DF2\u7ECF\u8DD1\u901A\u4E86\uFF0C\u5148\u8BFB\u66F4\u65B0\u65E5\u5FD7` : script.optimize === void 0 ? void 0 : `${script.optimize.at === void 0 ? "\u88C5\u597D\u4EE5\u6765" : "\u4E0A\u6B21\u4F18\u5316\u4EE5\u6765"}\u5DF2\u7ECF\u8DD1\u6210\u529F ${script.optimize.runs} \u6B21`;
|
|
3042
3053
|
const decide = async (id, decision, by) => {
|
|
3043
3054
|
const lib = library();
|
|
3044
3055
|
const script = lib.get(id);
|
|
@@ -3052,10 +3063,11 @@ function optimizer(ctx, library, log) {
|
|
|
3052
3063
|
throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
|
|
3053
3064
|
const gateway = ctx.get("adgGateway");
|
|
3054
3065
|
const conversations = sessionConversations(sessions, () => gateway?.workspaceDir(), (sessionId2, focus) => gateway?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => gateway);
|
|
3055
|
-
const
|
|
3066
|
+
const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u4F18\u5316\u811A\u672C\uFF1A${script.name}`, { scripts: [id] });
|
|
3067
|
+
const sessionId = work.owner;
|
|
3056
3068
|
const prompt = optimizeScriptPrompt(script.name, why(script), id);
|
|
3057
3069
|
await lib.optimizeDone(id, "run");
|
|
3058
|
-
void
|
|
3070
|
+
void work.run(taskMessage(by, `\u4F18\u5316\u811A\u672C\uFF1A${script.name}`, prompt), AbortSignal.timeout(OPTIMIZE_TIMEOUT_MS)).catch((error) => log.warn(`optimizing ${id}: ${error instanceof Error ? error.message : String(error)}`));
|
|
3059
3071
|
close(id, "\u5DF2\u4EA4\u7ED9\u300C\u811A\u672C\u300D\u4F18\u5316\uFF0C\u811A\u672C\u5305\u7684\u6539\u52A8\u4F1A\u5728\u300C\u811A\u672C\u300D\u9875\u7B49\u4F60\u786E\u8BA4");
|
|
3060
3072
|
return { sessionId };
|
|
3061
3073
|
};
|
|
@@ -3987,7 +3999,8 @@ function scriptSummaries(ctx, library, log) {
|
|
|
3987
3999
|
const material = await library.summaryMaterial(id);
|
|
3988
4000
|
const name = library.get(id).name;
|
|
3989
4001
|
const conversations = sessionConversations(sessions, () => ctx.get("adgGateway")?.workspaceDir(), (sessionId2, focus) => ctx.get("adgGateway")?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => ctx.get("adgGateway"));
|
|
3990
|
-
const
|
|
4002
|
+
const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u811A\u672C\u4ECB\u7ECD\uFF1A${name}`, { scripts: [id] });
|
|
4003
|
+
const sessionId = work.owner;
|
|
3991
4004
|
running.add(id);
|
|
3992
4005
|
await library.setSummary(id, { state: "running", at: Date.now(), sessionId, ...previous?.text === void 0 || previous.state !== "done" ? {} : { text: previous.text } });
|
|
3993
4006
|
const prompt = [
|
|
@@ -4001,7 +4014,7 @@ function scriptSummaries(ctx, library, log) {
|
|
|
4001
4014
|
"\u6750\u6599\uFF1A",
|
|
4002
4015
|
material
|
|
4003
4016
|
].join("\n");
|
|
4004
|
-
void
|
|
4017
|
+
void work.run(taskMessage("\u4F60", `\u811A\u672C\u4ECB\u7ECD\uFF1A${name}`, prompt), AbortSignal.timeout(SUMMARY_TIMEOUT_MS)).then(
|
|
4005
4018
|
// A turn that did not finish (no model set up, cut off) comes back as a note, not a summary.
|
|
4006
4019
|
(answer) => library.setSummary(id, answer.startsWith("\uFF08\u8FD9\u4E00\u8F6E\u6CA1\u6709\u5B8C\u6210") || answer.startsWith("\uFF08agent \u6CA1\u6709\u56DE\u590D\u6587\u5B57") ? { state: "failed", at: Date.now(), sessionId, text: answer.replace(/^(这一轮没有完成:?|)$/g, "") } : { state: "done", at: Date.now(), sessionId, text: tidy(answer) }),
|
|
4007
4020
|
(error) => {
|
|
@@ -4367,14 +4380,15 @@ function setupHandOff(ctx, library, log) {
|
|
|
4367
4380
|
if (sessions === void 0)
|
|
4368
4381
|
throw new Error("agent \u73B0\u5728\u4E0D\u53EF\u7528\uFF08\u4F1A\u8BDD\u670D\u52A1\u6CA1\u6709\u52A0\u8F7D\uFF09");
|
|
4369
4382
|
const conversations = sessionConversations(sessions, () => ctx.get("adgGateway")?.workspaceDir(), (sessionId2, focus) => ctx.get("adgGateway")?.skillScope.setFocus(sessionId2, focus) ?? Promise.resolve(), () => ctx.get("adgGateway"));
|
|
4370
|
-
const
|
|
4383
|
+
const work = await conversations.prepareTask(SCRIPT_ROLE.id, `\u5B89\u88C5\u811A\u672C\uFF1A${setup.name}`, { scripts: [setup.scriptId] });
|
|
4384
|
+
const sessionId = work.owner;
|
|
4371
4385
|
log.info(`${setup.scriptId}: setup program handed to session ${sessionId}`);
|
|
4372
|
-
await library().setSetupAgent(setup.scriptId, { sessionId, state: "running" });
|
|
4386
|
+
await library().setSetupAgent(setup.scriptId, { sessionId, taskId: work.id, state: "running" });
|
|
4373
4387
|
const failed = async (reason) => {
|
|
4374
|
-
if (library().pendingSetup(setup.scriptId)?.agent?.
|
|
4388
|
+
if (library().pendingSetup(setup.scriptId)?.agent?.taskId !== work.id)
|
|
4375
4389
|
return;
|
|
4376
4390
|
log.warn(`${setup.scriptId}: setup session ${sessionId}: ${reason}`);
|
|
4377
|
-
await library().setSetupAgent(setup.scriptId, { sessionId, state: "failed", reason });
|
|
4391
|
+
await library().setSetupAgent(setup.scriptId, { sessionId, taskId: work.id, state: "failed", reason });
|
|
4378
4392
|
};
|
|
4379
4393
|
void (async () => {
|
|
4380
4394
|
const prompt = [
|
|
@@ -4385,7 +4399,7 @@ function setupHandOff(ctx, library, log) {
|
|
|
4385
4399
|
"4. \u6700\u540E\u7528\u4E00\u4E24\u53E5\u8BDD\u544A\u8BC9\u7528\u6237\u7ED3\u679C\uFF08\u88C5\u5728\u54EA\u3001\u662F\u5426\u6210\u529F\uFF09\u3002",
|
|
4386
4400
|
"\u4E0D\u8981\u8FD0\u884C\u88C5\u597D\u7684\u7A0B\u5E8F\uFF0C\u4E0D\u8981\u6539\u5B83\u7684\u6587\u4EF6\uFF0C\u4E0D\u8981\u5411\u7528\u6237\u63D0\u95EE\uFF1B\u505A\u4E0D\u5230\u65F6\u8BF4\u660E\u5361\u5728\u54EA\u4E00\u6B65\u3002"
|
|
4387
4401
|
].join("\n");
|
|
4388
|
-
const answer = await
|
|
4402
|
+
const answer = await work.run(taskMessage("\u4F60", `\u5B89\u88C5\u811A\u672C\uFF1A${setup.name}`, prompt), AbortSignal.timeout(SETUP_TIMEOUT_MS));
|
|
4389
4403
|
const cut = /^(这一轮没有完成:(.*))$/s.exec(answer.trim());
|
|
4390
4404
|
await failed(cut !== null ? cut[1] : "agent \u505C\u4E0B\u4E86\uFF0C\u4F46\u6CA1\u6709\u5BFC\u5165\u88C5\u597D\u7684\u76EE\u5F55");
|
|
4391
4405
|
})().catch((error) => failed(error instanceof Error ? error.message : String(error)));
|
|
@@ -22941,4 +22955,4 @@ export {
|
|
|
22941
22955
|
AdgScripts,
|
|
22942
22956
|
lib_default
|
|
22943
22957
|
};
|
|
22944
|
-
/*! For license information please see chunk-
|
|
22958
|
+
/*! For license information please see chunk-CCYE6H2F.js.LEGAL.txt */
|
|
@@ -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)
|
|
@@ -7482,7 +7483,7 @@ var HandOffs = class {
|
|
|
7482
7483
|
}
|
|
7483
7484
|
/** Those from or to this conversation, oldest first. */
|
|
7484
7485
|
of(sessionId) {
|
|
7485
|
-
return [...this.#items.values()].filter((h) => h.fromSession === sessionId || h.toSession === sessionId);
|
|
7486
|
+
return [...this.#items.values()].filter((h) => h.fromSession === sessionId || h.toSession === sessionId || h.ownerSession === sessionId);
|
|
7486
7487
|
}
|
|
7487
7488
|
get(id) {
|
|
7488
7489
|
return this.#items.get(id);
|
|
@@ -7701,7 +7702,7 @@ function keeps(tools, name) {
|
|
|
7701
7702
|
function matches(patterns, name) {
|
|
7702
7703
|
return patterns.some((pattern) => pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern);
|
|
7703
7704
|
}
|
|
7704
|
-
var NOBODY = ["subagent_fork"];
|
|
7705
|
+
var NOBODY = ["subagent_fork", "wait_agent"];
|
|
7705
7706
|
var TOGETHER = ["agent_delegate", "agent_message", "agent_threads"];
|
|
7706
7707
|
var MEMORY_TOOLS = ["memory_save", "memory_forget", "memory_search", "history_search", "history_read"];
|
|
7707
7708
|
var ALWAYS = [...TOGETHER, ...MEMORY_TOOLS];
|
|
@@ -7755,7 +7756,7 @@ function teamPrompt(self, main, leads, options = {}) {
|
|
|
7755
7756
|
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
7757
|
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
7758
|
${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\
|
|
7759
|
+
"\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
7760
|
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
7761
|
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
7762
|
"\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 +8009,8 @@ function fallbackReason(failure) {
|
|
|
8008
8009
|
return "\u6A21\u578B\u4E0D\u53EF\u7528";
|
|
8009
8010
|
if (LIMIT_CODES.has(code))
|
|
8010
8011
|
return "\u8BF7\u6C42\u592A\u9891\u7E41\uFF0C\u91CD\u8BD5\u540E\u4ECD\u88AB\u9650\u6D41";
|
|
8012
|
+
if (code === "TIMEOUT")
|
|
8013
|
+
return "\u6A21\u578B\u8BF7\u6C42\u8D85\u65F6\uFF0C\u91CD\u8BD5\u540E\u4ECD\u65E0\u54CD\u5E94";
|
|
8011
8014
|
if (code === "SERVER" || /^HTTP_5\d\d$/.test(code))
|
|
8012
8015
|
return "\u6A21\u578B\u670D\u52A1\u51FA\u9519\uFF0C\u91CD\u8BD5\u540E\u4ECD\u7136\u5931\u8D25";
|
|
8013
8016
|
return void 0;
|
|
@@ -9034,6 +9037,7 @@ function ownerInfo(owner) {
|
|
|
9034
9037
|
return { owner: { ...owner.scripts === void 0 ? {} : { scripts: [...owner.scripts] }, ...owner.games === void 0 ? {} : { games: [...owner.games] } } };
|
|
9035
9038
|
}
|
|
9036
9039
|
var ROLE_CLOSING = [
|
|
9040
|
+
"\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
9041
|
"\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
9042
|
"\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
9043
|
"\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 +9155,8 @@ var AdgGateway = class extends Service {
|
|
|
9151
9155
|
/** Live agents by session, and what narrows each to its role (`narrow`). */
|
|
9152
9156
|
agents = /* @__PURE__ */ new Map();
|
|
9153
9157
|
narrowed = /* @__PURE__ */ new Map();
|
|
9158
|
+
appChildren = /* @__PURE__ */ new Set();
|
|
9159
|
+
assignedSpecs = /* @__PURE__ */ new WeakMap();
|
|
9154
9160
|
subAgentSpecs = /* @__PURE__ */ new WeakMap();
|
|
9155
9161
|
persona;
|
|
9156
9162
|
/**
|
|
@@ -9344,6 +9350,18 @@ var AdgGateway = class extends Service {
|
|
|
9344
9350
|
await this.routeSubAgent(payload.agent);
|
|
9345
9351
|
}));
|
|
9346
9352
|
ctx.on("tools/execute", ((exec, next) => {
|
|
9353
|
+
if ((exec.name === "subagent" || exec.name === "list_subagent_models") && exec.agent !== void 0) {
|
|
9354
|
+
const parent = this.specOf(exec.agent.session.id);
|
|
9355
|
+
if (parent !== void 0) {
|
|
9356
|
+
const pinned = exec.name === "subagent" && this.subAgentModel(memoryOwnerOf(parent)) !== void 0;
|
|
9357
|
+
const args = { ...exec.arguments };
|
|
9358
|
+
for (const field of ["provider", "model", "reasoning_effort"]) {
|
|
9359
|
+
if (pinned || args[field] === "")
|
|
9360
|
+
delete args[field];
|
|
9361
|
+
}
|
|
9362
|
+
exec.arguments = args;
|
|
9363
|
+
}
|
|
9364
|
+
}
|
|
9347
9365
|
if (exec.name === "schedule_create" && exec.agent !== void 0 && typeof exec.arguments.prompt === "string") {
|
|
9348
9366
|
const desk = this.handOffDesk;
|
|
9349
9367
|
const noted = desk?.reminderNote?.(exec.agent.session.id, exec.arguments.prompt);
|
|
@@ -10164,8 +10182,13 @@ Content-Length: 0
|
|
|
10164
10182
|
refused.add(name);
|
|
10165
10183
|
}
|
|
10166
10184
|
}
|
|
10167
|
-
|
|
10168
|
-
|
|
10185
|
+
disposers.push(tools.guard((exec) => {
|
|
10186
|
+
if (exec.name === "wait_agent")
|
|
10187
|
+
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";
|
|
10188
|
+
if (refused.has(exec.name))
|
|
10189
|
+
return home && handsOn(exec.name) ? HANDS_ON_REFUSAL(exec.name) : `${spec.name}\u4E0D\u80FD\u7528 ${exec.name}`;
|
|
10190
|
+
return void 0;
|
|
10191
|
+
}));
|
|
10169
10192
|
if (spec.subAgentOf === void 0) {
|
|
10170
10193
|
disposers.push(tools.guard((exec) => exec.name === "ask_user_question" ? this.handOffDesk?.askRefusal?.(agent.session.id) : void 0));
|
|
10171
10194
|
}
|
|
@@ -10275,7 +10298,8 @@ Content-Length: 0
|
|
|
10275
10298
|
}
|
|
10276
10299
|
/** The agent working in a session, as other agents address it. A sub-agent is nobody to them. */
|
|
10277
10300
|
agentOfSession(sessionId) {
|
|
10278
|
-
const
|
|
10301
|
+
const owner = this.appChildren.has(sessionId) ? this.parentSession(sessionId) : void 0;
|
|
10302
|
+
const spec = this.specOf(owner ?? sessionId);
|
|
10279
10303
|
return spec === void 0 || spec.subAgentOf !== void 0 ? void 0 : { id: spec.id, name: spec.name };
|
|
10280
10304
|
}
|
|
10281
10305
|
/**
|
|
@@ -10323,6 +10347,20 @@ Content-Length: 0
|
|
|
10323
10347
|
return void 0;
|
|
10324
10348
|
if (parent.subAgentOf !== void 0)
|
|
10325
10349
|
return parent;
|
|
10350
|
+
if (this.appChildren.has(sessionId)) {
|
|
10351
|
+
let assigned = this.assignedSpecs.get(parent);
|
|
10352
|
+
if (!assigned) {
|
|
10353
|
+
const child2 = subAgentSpec(parent);
|
|
10354
|
+
const tools = /* @__PURE__ */ new Set(["agent_message", "ask_user_question", ...parent.id === "intervene" ? ["intervention_done"] : []]);
|
|
10355
|
+
assigned = {
|
|
10356
|
+
...child2,
|
|
10357
|
+
hide: (child2.hide ?? []).filter((name) => !tools.has(name)),
|
|
10358
|
+
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") ?? ""
|
|
10359
|
+
};
|
|
10360
|
+
this.assignedSpecs.set(parent, assigned);
|
|
10361
|
+
}
|
|
10362
|
+
return assigned;
|
|
10363
|
+
}
|
|
10326
10364
|
let child = this.subAgentSpecs.get(parent);
|
|
10327
10365
|
if (child === void 0)
|
|
10328
10366
|
this.subAgentSpecs.set(parent, child = subAgentSpec(parent));
|
|
@@ -10362,7 +10400,76 @@ Content-Length: 0
|
|
|
10362
10400
|
return;
|
|
10363
10401
|
}
|
|
10364
10402
|
}
|
|
10365
|
-
/**
|
|
10403
|
+
/** App actions are addressed to an agent's home. dsh owns child membership, model selection, settlement and parent delivery. */
|
|
10404
|
+
async runChild(owner, childId, title, instruction, signal, images = []) {
|
|
10405
|
+
if (!this.homes.agentOf(owner))
|
|
10406
|
+
throw new Error("\u4EFB\u52A1\u5FC5\u987B\u4ECE\u52A9\u624B\u7684\u4E3B\u5BF9\u8BDD\u6D3E\u53D1");
|
|
10407
|
+
const service = this.ctx.get("subagents");
|
|
10408
|
+
if (!service)
|
|
10409
|
+
throw new Error("\u539F\u751F\u5B50\u4EE3\u7406\u670D\u52A1\u672A\u52A0\u8F7D");
|
|
10410
|
+
const resolved = await this.ctx.sessionController.resolveAgent(owner);
|
|
10411
|
+
if (!("agent" in resolved))
|
|
10412
|
+
throw new Error("\u65E0\u6CD5\u6062\u590D\u8D1F\u8D23\u8FD9\u9879\u4EFB\u52A1\u7684\u4E3B\u52A9\u624B");
|
|
10413
|
+
const parent = resolved.agent;
|
|
10414
|
+
signal.throwIfAborted();
|
|
10415
|
+
const ptc = this.compaction?.state().settings.ptcSubagents ?? true;
|
|
10416
|
+
this.appChildren.add(childId);
|
|
10417
|
+
try {
|
|
10418
|
+
const activation = await service.startActivation({
|
|
10419
|
+
provider: "spawn",
|
|
10420
|
+
parent,
|
|
10421
|
+
childId,
|
|
10422
|
+
label: title,
|
|
10423
|
+
...ptc ? { agentPreset: this.shared ? "mga-ptc" : "ptc" } : {},
|
|
10424
|
+
prompt: [{ type: "text", text: instruction }, ...images.map((png) => ({ type: "image", mediaType: "image/png", data: png.toString("base64") }))],
|
|
10425
|
+
delivery: "parent",
|
|
10426
|
+
signal
|
|
10427
|
+
});
|
|
10428
|
+
let stopping;
|
|
10429
|
+
const cancel = () => {
|
|
10430
|
+
stopping ??= activation.dispose();
|
|
10431
|
+
void stopping.catch(() => {
|
|
10432
|
+
});
|
|
10433
|
+
};
|
|
10434
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
10435
|
+
try {
|
|
10436
|
+
if (signal.aborted) {
|
|
10437
|
+
cancel();
|
|
10438
|
+
signal.throwIfAborted();
|
|
10439
|
+
}
|
|
10440
|
+
await parent.send({
|
|
10441
|
+
id: randomUUID5(),
|
|
10442
|
+
role: "user",
|
|
10443
|
+
content: [{ type: "text", text: `\uFF08\u4F60\u8D1F\u8D23\u7684\u5B50\u4EFB\u52A1\uFF1A${title}\uFF09
|
|
10444
|
+
\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
|
|
10445
|
+
|
|
10446
|
+
${instruction}` }],
|
|
10447
|
+
source: { kind: "adg-task-dispatched", form: "notice", summary: title, childId }
|
|
10448
|
+
}, "next-step", false);
|
|
10449
|
+
const result = await activation.result;
|
|
10450
|
+
signal.throwIfAborted();
|
|
10451
|
+
if (result.stopReason === "aborted" || result.stopReason === "interrupted")
|
|
10452
|
+
throw new DOMException(result.diagnostic || "\u5B50\u4EFB\u52A1\u5DF2\u505C\u6B62", "AbortError");
|
|
10453
|
+
if (result.stopReason !== "completed")
|
|
10454
|
+
throw new Error(result.diagnostic || `\u5B50\u4EFB\u52A1\u4E2D\u65AD\uFF08${result.stopReason}\uFF09`);
|
|
10455
|
+
const answer = result.output.filter((p) => p.type === "text").map((p) => p.text ?? "").join("\n").trim();
|
|
10456
|
+
if (!answer)
|
|
10457
|
+
throw new Error("\u5B50\u4EE3\u7406\u7ED3\u675F\u65F6\u6CA1\u6709\u4EA4\u56DE\u7ED3\u8BBA");
|
|
10458
|
+
return answer;
|
|
10459
|
+
} catch (error) {
|
|
10460
|
+
cancel();
|
|
10461
|
+
throw error;
|
|
10462
|
+
} finally {
|
|
10463
|
+
signal.removeEventListener("abort", cancel);
|
|
10464
|
+
await stopping;
|
|
10465
|
+
}
|
|
10466
|
+
} finally {
|
|
10467
|
+
this.appChildren.delete(childId);
|
|
10468
|
+
const child = this.agents.get(childId);
|
|
10469
|
+
if (child)
|
|
10470
|
+
this.narrow(child);
|
|
10471
|
+
}
|
|
10472
|
+
}
|
|
10366
10473
|
stopSubAgent(sessionId) {
|
|
10367
10474
|
const parent = this.agents.get(sessionId)?.session.header?.parentSession;
|
|
10368
10475
|
if (parent === void 0)
|
|
@@ -10372,7 +10479,7 @@ Content-Length: 0
|
|
|
10372
10479
|
/** Stop the sub-agents working under this session's agent (a hand-off called off stops them with it). */
|
|
10373
10480
|
stopSubAgents(sessionId) {
|
|
10374
10481
|
for (const agent of this.agents.values()) {
|
|
10375
|
-
if (agent.session.header?.parentSession !== sessionId || agent.session.header.origin !== "subagent")
|
|
10482
|
+
if (this.appChildren.has(agent.session.id) || agent.session.header?.parentSession !== sessionId || agent.session.header.origin !== "subagent")
|
|
10376
10483
|
continue;
|
|
10377
10484
|
try {
|
|
10378
10485
|
this.stopSubAgent(agent.session.id);
|
|
@@ -10473,8 +10580,7 @@ Content-Length: 0
|
|
|
10473
10580
|
* (agent-models.ts); else dsh gives it its parent's. The choice is made as
|
|
10474
10581
|
* the sub-agent is created (agent.model, as dsh's own model choice is), so its
|
|
10475
10582
|
* 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.
|
|
10583
|
+
* that cannot be resolved is tried against the configured child fallback list.
|
|
10478
10584
|
*/
|
|
10479
10585
|
async routeSubAgent(agent) {
|
|
10480
10586
|
if (agent.session.header?.origin !== "subagent" || !this.isOwn(agent.session.id))
|
|
@@ -10483,18 +10589,26 @@ Content-Length: 0
|
|
|
10483
10589
|
if (spec?.subAgentOf === void 0)
|
|
10484
10590
|
return;
|
|
10485
10591
|
const model = this.subAgentModel(memoryOwnerOf(spec));
|
|
10486
|
-
if (model === void 0
|
|
10592
|
+
if (model === void 0)
|
|
10487
10593
|
return;
|
|
10488
|
-
const route = { provider: model.provider, model: model.model, ...model.reasoningEffort === void 0 ? {} : { reasoningEffort: model.reasoningEffort } };
|
|
10489
10594
|
const llm = this.ctx.get("llm");
|
|
10490
|
-
if (llm === void 0)
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10595
|
+
if (llm === void 0 || agent.model === void 0)
|
|
10596
|
+
throw new Error("\u5B50\u4EE3\u7406\u6A21\u578B\u670D\u52A1\u5C1A\u672A\u5C31\u7EEA");
|
|
10597
|
+
const tried = /* @__PURE__ */ new Set();
|
|
10598
|
+
for (const route of [model, ...this.agentModels.fallbacksOf(true)]) {
|
|
10599
|
+
const key = `${route.provider}/${route.model}`;
|
|
10600
|
+
if (tried.has(key))
|
|
10601
|
+
continue;
|
|
10602
|
+
tried.add(key);
|
|
10603
|
+
try {
|
|
10604
|
+
await llm.resolveCallConfig(route, AbortSignal.timeout(1e4));
|
|
10605
|
+
agent.model.select({ provider: route.provider, model: route.model, ...route.reasoningEffort === void 0 ? {} : { reasoningEffort: route.reasoningEffort } });
|
|
10606
|
+
return;
|
|
10607
|
+
} catch (error) {
|
|
10608
|
+
this.log.warn(`\u5B50\u4EE3\u7406\u6A21\u578B ${key} \u65E0\u6CD5\u4F7F\u7528\uFF1A${String(error)}`);
|
|
10609
|
+
}
|
|
10497
10610
|
}
|
|
10611
|
+
throw new Error(`\u5B50\u4EE3\u7406\u6A21\u578B\u5747\u4E0D\u53EF\u7528\uFF1A${[...tried].join("\u3001")}`);
|
|
10498
10612
|
}
|
|
10499
10613
|
/** Why a model chosen for this layer will not do: it cannot see images and the work there looks at screenshots. */
|
|
10500
10614
|
async visionWarning(model, target) {
|
|
@@ -290,7 +290,7 @@ var ReleaseInfo = external_exports.object({
|
|
|
290
290
|
notes: external_exports.string().optional()
|
|
291
291
|
});
|
|
292
292
|
var ScriptJobPhase = external_exports.enum(["queued", "resolving", "downloading", "verifying", "extracting", "checking", "running", "done", "failed", "cancelled"]);
|
|
293
|
-
var SetupAgent = external_exports.object({ sessionId: external_exports.string(), state: external_exports.enum(["running", "failed"]), reason: external_exports.string().optional() });
|
|
293
|
+
var SetupAgent = external_exports.object({ sessionId: external_exports.string(), taskId: external_exports.string().optional(), state: external_exports.enum(["running", "failed"]), reason: external_exports.string().optional() });
|
|
294
294
|
var PendingSetupInfo = external_exports.object({
|
|
295
295
|
scriptId: external_exports.string(),
|
|
296
296
|
name: external_exports.string(),
|
|
@@ -1206,6 +1206,8 @@ var NodeRun = external_exports.object({
|
|
|
1206
1206
|
state: NodeRunState,
|
|
1207
1207
|
/** For people: what it waits for, how it ended. */
|
|
1208
1208
|
detail: external_exports.string().optional(),
|
|
1209
|
+
/** The outcome of an explicitly linked repair after the pipeline ended. */
|
|
1210
|
+
repair: external_exports.object({ runId: external_exports.string(), state: external_exports.enum(["succeeded", "failed", "cancelled"]), at: external_exports.number() }).optional(),
|
|
1209
1211
|
/** Script runs started for this node (retries add more). */
|
|
1210
1212
|
runIds: external_exports.array(external_exports.string()),
|
|
1211
1213
|
attempts: external_exports.number().int().min(0),
|
|
@@ -1512,6 +1514,11 @@ var GameNotice = external_exports.object({
|
|
|
1512
1514
|
/** When it was read. */
|
|
1513
1515
|
at: external_exports.number()
|
|
1514
1516
|
});
|
|
1517
|
+
var NoticeArticle = external_exports.array(external_exports.discriminatedUnion("type", [
|
|
1518
|
+
external_exports.object({ type: external_exports.literal("text"), text: external_exports.string() }),
|
|
1519
|
+
external_exports.object({ type: external_exports.literal("image"), url: external_exports.url({ protocol: /^https$/ }) })
|
|
1520
|
+
]));
|
|
1521
|
+
var GameNoticeDetail = GameNotice.extend({ article: NoticeArticle.optional() });
|
|
1515
1522
|
var Activity = external_exports.object({
|
|
1516
1523
|
/** `<game>/<key>`; the key is the normalised name, so a site and the screen meet on it. */
|
|
1517
1524
|
id: external_exports.string(),
|
|
@@ -1540,6 +1547,7 @@ var Activity = external_exports.object({
|
|
|
1540
1547
|
name: external_exports.string(),
|
|
1541
1548
|
at: external_exports.number(),
|
|
1542
1549
|
web: external_exports.boolean(),
|
|
1550
|
+
url: external_exports.string().optional(),
|
|
1543
1551
|
startsAt: external_exports.number().optional(),
|
|
1544
1552
|
endsAt: external_exports.number().optional(),
|
|
1545
1553
|
shopEndsAt: external_exports.number().optional(),
|
|
@@ -1607,6 +1615,15 @@ var GameSourceInfo = external_exports.object({
|
|
|
1607
1615
|
/** A page the user added on the game page (`games/source/add`); it can be removed there. */
|
|
1608
1616
|
added: external_exports.boolean().optional()
|
|
1609
1617
|
});
|
|
1618
|
+
var GameReading = external_exports.object({
|
|
1619
|
+
state: external_exports.enum(["queued", "running", "done", "partial", "failed", "cancelled"]),
|
|
1620
|
+
at: external_exports.number(),
|
|
1621
|
+
sessionId: external_exports.string().optional(),
|
|
1622
|
+
taskId: external_exports.string().optional(),
|
|
1623
|
+
scope: external_exports.string().optional(),
|
|
1624
|
+
remainingUrls: external_exports.array(external_exports.string()).optional(),
|
|
1625
|
+
summary: external_exports.string().optional()
|
|
1626
|
+
});
|
|
1610
1627
|
var GameInfo = external_exports.object({
|
|
1611
1628
|
id: external_exports.string(),
|
|
1612
1629
|
name: external_exports.string(),
|
|
@@ -1652,19 +1669,9 @@ var GameInfo = external_exports.object({
|
|
|
1652
1669
|
/** The last data-site refresh. */
|
|
1653
1670
|
refreshed: external_exports.object({ at: external_exports.number(), ok: external_exports.boolean(), count: external_exports.number(), detail: external_exports.string().optional() }).optional(),
|
|
1654
1671
|
/** The last time the agent read the game screen. */
|
|
1655
|
-
reading:
|
|
1656
|
-
state: external_exports.enum(["running", "done", "failed"]),
|
|
1657
|
-
at: external_exports.number(),
|
|
1658
|
-
sessionId: external_exports.string().optional(),
|
|
1659
|
-
summary: external_exports.string().optional()
|
|
1660
|
-
}).optional(),
|
|
1672
|
+
reading: GameReading.optional(),
|
|
1661
1673
|
/** The last time the agent read the web for it (official news, wikis — the sources the plugin cannot read itself). */
|
|
1662
|
-
webReading:
|
|
1663
|
-
state: external_exports.enum(["running", "done", "failed"]),
|
|
1664
|
-
at: external_exports.number(),
|
|
1665
|
-
sessionId: external_exports.string().optional(),
|
|
1666
|
-
summary: external_exports.string().optional()
|
|
1667
|
-
}).optional()
|
|
1674
|
+
webReading: GameReading.optional()
|
|
1668
1675
|
});
|
|
1669
1676
|
var GamesSettings = external_exports.object({
|
|
1670
1677
|
report: external_exports.object({
|
|
@@ -1701,6 +1708,11 @@ var GamesRequests = {
|
|
|
1701
1708
|
params: external_exports.object({}),
|
|
1702
1709
|
result: external_exports.object({ games: external_exports.array(GameInfo), activities: external_exports.array(Activity), notices: external_exports.array(GameNotice).default([]), settings: GamesSettings, report: ReportInfo })
|
|
1703
1710
|
},
|
|
1711
|
+
"games/notice/detail": {
|
|
1712
|
+
capability: GAMES_CAPABILITY,
|
|
1713
|
+
params: external_exports.object({ game: external_exports.string(), noticeId: external_exports.string() }),
|
|
1714
|
+
result: GameNoticeDetail
|
|
1715
|
+
},
|
|
1704
1716
|
/** Read the data sites now (one game, or all). */
|
|
1705
1717
|
"games/refresh": {
|
|
1706
1718
|
capability: GAMES_CAPABILITY,
|
|
@@ -1718,6 +1730,11 @@ var GamesRequests = {
|
|
|
1718
1730
|
params: external_exports.object({ game: external_exports.string(), how: external_exports.enum(["screen", "web"]).optional(), source: external_exports.string().optional() }),
|
|
1719
1731
|
result: external_exports.object({ sessionId: external_exports.string() })
|
|
1720
1732
|
},
|
|
1733
|
+
"games/read/cancel": {
|
|
1734
|
+
capability: GAMES_CAPABILITY,
|
|
1735
|
+
params: external_exports.object({ taskId: external_exports.string() }),
|
|
1736
|
+
result: external_exports.object({ cancelled: external_exports.boolean() })
|
|
1737
|
+
},
|
|
1721
1738
|
"games/report/preview": {
|
|
1722
1739
|
capability: GAMES_CAPABILITY,
|
|
1723
1740
|
params: external_exports.object({}),
|
|
@@ -2773,7 +2790,8 @@ var MessageOrigin = external_exports.object({
|
|
|
2773
2790
|
/** One-line account for `notice`-form injected context. */
|
|
2774
2791
|
summary: external_exports.string().optional(),
|
|
2775
2792
|
/** A model failed and the agent went on with the next of its fallback list (kind MODEL_FALLBACK_SOURCE). */
|
|
2776
|
-
fallback: ModelFallbackNotice.optional()
|
|
2793
|
+
fallback: ModelFallbackNotice.optional(),
|
|
2794
|
+
childId: external_exports.string().optional()
|
|
2777
2795
|
});
|
|
2778
2796
|
var base = { seq: external_exports.number(), time: external_exports.number() };
|
|
2779
2797
|
var SessionEvent = external_exports.discriminatedUnion("type", [
|
|
@@ -2815,6 +2833,7 @@ var SessionEvent = external_exports.discriminatedUnion("type", [
|
|
|
2815
2833
|
external_exports.object({
|
|
2816
2834
|
...base,
|
|
2817
2835
|
type: external_exports.literal("assistant/attempt"),
|
|
2836
|
+
usage: TokenUsage.optional(),
|
|
2818
2837
|
turn: external_exports.number(),
|
|
2819
2838
|
step: external_exports.number(),
|
|
2820
2839
|
timing: StreamTiming,
|
|
@@ -3165,6 +3184,8 @@ var HandOff = external_exports.object({
|
|
|
3165
3184
|
/** The agent it went to (role id) and its conversation. */
|
|
3166
3185
|
to: external_exports.string(),
|
|
3167
3186
|
toSession: external_exports.string(),
|
|
3187
|
+
isolated: external_exports.boolean().optional(),
|
|
3188
|
+
ownerSession: external_exports.string().optional(),
|
|
3168
3189
|
title: external_exports.string(),
|
|
3169
3190
|
task: external_exports.string(),
|
|
3170
3191
|
expecting: external_exports.string().optional(),
|
|
@@ -3963,11 +3984,13 @@ export {
|
|
|
3963
3984
|
AgentTaskRun,
|
|
3964
3985
|
INTERVENE_CAPABILITY,
|
|
3965
3986
|
GAMES_CAPABILITY,
|
|
3966
|
-
|
|
3987
|
+
NoticeArticle,
|
|
3988
|
+
GameNoticeDetail,
|
|
3967
3989
|
OWN_SOURCE,
|
|
3968
3990
|
SCREEN_SOURCE,
|
|
3969
3991
|
OWN_IMAGE,
|
|
3970
3992
|
SHOT_IMAGE,
|
|
3993
|
+
GameReading,
|
|
3971
3994
|
GamesSettings,
|
|
3972
3995
|
PERMISSIONS_CAPABILITY,
|
|
3973
3996
|
AreaPolicy,
|