@vibe-lark/larkpal 0.1.85 → 0.1.86
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/dist/account-id-BM1T6029-DYjVxojW.mjs +46 -0
- package/dist/activation-context--5yu1dPF-Bwsn3moT.mjs +172 -0
- package/dist/anthropic-TH8ERTXK.mjs +5962 -0
- package/dist/assistant-visible-text-DuFWokAt-CsbII5KS.mjs +596 -0
- package/dist/azure-openai-responses-Bt_Ag9Er.mjs +166 -0
- package/dist/boundary-file-read-BSd9MXPy--KThL5e6.mjs +594 -0
- package/dist/browser-lifecycle-cleanup-BdNsMhMD-O3tnAM4i.mjs +60 -0
- package/dist/build-DgTrEpge.mjs +3333 -0
- package/dist/bundled-compat-BpaDaAAu-D7oazKjD.mjs +5216 -0
- package/dist/bundled-dir-U738ay4K-DXK0q_TV.mjs +258 -0
- package/dist/call-DimWbpgJ-ColD4W-y.mjs +9993 -0
- package/dist/channel-bootstrap.runtime-BVclcGv1-DJv_Z-Kr.mjs +2 -0
- package/dist/channel-bootstrap.runtime-Cwcr38m2-VRfVCR-i.mjs +33 -0
- package/dist/chunk-D6SyT4dJ.mjs +36 -0
- package/dist/cli.mjs +6 -6
- package/dist/command-format-LSnUCVVF-BQ2SMKka.mjs +685 -0
- package/dist/config-Bim2pi8a-BQUdfiEi.mjs +9 -0
- package/dist/delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs +72 -0
- package/dist/diagnostic-ClMwNnUA-D6nUtLnb.mjs +140 -0
- package/dist/dist-CEGw8-2W.mjs +429 -0
- package/dist/dist-DD2aJ2UL.mjs +125135 -0
- package/dist/env-api-keys-BVvSg7T2.mjs +68 -0
- package/dist/event-stream-xaQWmyas.mjs +15226 -0
- package/dist/facade-loader-DFzIYYt_-CIr4HKtE.mjs +194 -0
- package/dist/from-DF7cl2wz.mjs +3842 -0
- package/dist/gateway-method-policy-C7rf0SeV-CJQMEYIE.mjs +28 -0
- package/dist/github-copilot-headers-DjqWtUoP.mjs +22 -0
- package/dist/google-C2pVrgBZ.mjs +336 -0
- package/dist/google-gemini-cli-BBxgS5Ho.mjs +623 -0
- package/dist/google-shared-BsWgwEk1.mjs +22791 -0
- package/dist/google-vertex-BsVLJrrC.mjs +358 -0
- package/dist/hash-DAFtW_W7.mjs +16 -0
- package/dist/headers-R3HdCbAE.mjs +8 -0
- package/dist/home-dir-C44RaPME-CBRS4HLP.mjs +93 -0
- package/dist/ids-BPsM98Uu-CwuxvUai.mjs +77 -0
- package/dist/image-2w3cApg7-CxpHvoB5.mjs +207 -0
- package/dist/io-CH2g3vsv-BOGlLlB8.mjs +26218 -0
- package/dist/jiti-loader-cache-Bat69wam-D6hCxboy.mjs +5049 -0
- package/dist/json-file-BQRNuxmK-DhJM5NsG.mjs +108 -0
- package/dist/json-parse-v_HIJjjI.mjs +381 -0
- package/dist/jws-GFcTvvVT.mjs +2291 -0
- package/dist/{lark-cli-provider-7LvtOIF_.mjs → lark-cli-provider-BARgbbmo.mjs} +1 -1
- package/dist/{live-smoke-nvTUPtrv.mjs → live-smoke-BhkBOcH9.mjs} +3 -3
- package/dist/load-context-mb7uvLSn-B10MAi3I.mjs +29 -0
- package/dist/loader-708jrx4Y-BOswuvpe.mjs +5053 -0
- package/dist/main.mjs +56550 -205
- package/dist/manifest-registry-_hxKCS2K-CZdeyN0f.mjs +3512 -0
- package/dist/mcp-server.mjs +1 -1
- package/dist/message-channel-Bk_YHfQg-AeNrPPpp.mjs +50 -0
- package/dist/message-channel-core-DTA--Gjh-CY4Tkb7N.mjs +29 -0
- package/dist/message.config.runtime-K-k4XOyq-DZTmXomP.mjs +2 -0
- package/dist/message.gateway.runtime-DqHOHRTQ-DH4ml0YF.mjs +2 -0
- package/dist/mistral-CaR4DiLu.mjs +28657 -0
- package/dist/model-auth-env-oyg2Hexc-DU_rOUU5.mjs +1306 -0
- package/dist/models-config-BmpSQJQF-Gfvh1n3A.mjs +1282 -0
- package/dist/models-config.runtime-BsU_22xk.mjs +2 -0
- package/dist/multipart-parser-DedmaB5g.mjs +294 -0
- package/dist/oauth-DOJeGfcE.mjs +6392 -0
- package/dist/openai-BDtIh3Ja.mjs +6693 -0
- package/dist/openai-codex-responses-C5EORu31.mjs +664 -0
- package/dist/openai-completions-CR_cS6gX.mjs +669 -0
- package/dist/openai-responses-oGxwZyuC.mjs +184 -0
- package/dist/openai-responses-shared-BixMSDZE.mjs +398 -0
- package/dist/paths-D6msg0S1-C2lYuisN.mjs +189 -0
- package/dist/paths-D92DjaZ--CTOESW2b.mjs +192 -0
- package/dist/pi-model-discovery-Bd0TWzo8-BFsJmeMb.mjs +227 -0
- package/dist/pi-model-discovery-runtime-CCCZxkd8.mjs +2 -0
- package/dist/pi-tools.before-tool-call.runtime-Bn7uqKie-C5ewk8kK.mjs +399 -0
- package/dist/plugin-auto-enable-DdH3n9V8-DsA1isaF.mjs +1456 -0
- package/dist/process-scoped-map-B2cWkYET-CXwUZ8CZ.mjs +61 -0
- package/dist/provider-discovery.runtime-BPzz1PFj.mjs +58 -0
- package/dist/provider-model-compat-CFqcq0it-BDDuBI3A.mjs +118 -0
- package/dist/provider-runtime-C8rljsNs-CIT93zoy.mjs +2 -0
- package/dist/provider-runtime-CT50mNIX-BwEV6GyO.mjs +573 -0
- package/dist/provider-stream-COLujAAo-CbJPDngm.mjs +35449 -0
- package/dist/providers.runtime-Ba7tOlq7-CXkhkzU9.mjs +219 -0
- package/dist/public-surface-loader-BVl0NQAE-C0piXtsT.mjs +117 -0
- package/dist/resolve-C33B7eeu-BNvYTl6k.mjs +1041 -0
- package/dist/runtime-Cym-fqI8-DaSDMH-a.mjs +120 -0
- package/dist/runtime-channel-state-CohMybAh-hXR6y5Gx.mjs +19 -0
- package/dist/runtime-snapshot-C54O1-gI-40cbyi7P.mjs +677 -0
- package/dist/runtime-state-IBOIXKOx-Bf9tcLvc.mjs +10 -0
- package/dist/runtime-web-tools-fallback.runtime-Ca-qn1mj-BCVImm7a.mjs +39 -0
- package/dist/runtime-web-tools-manifest.runtime-BgxQTjmq-Cb4nJkRT.mjs +2 -0
- package/dist/runtime-web-tools-public-artifacts.runtime-D9qcoWIX-BrQdXzOQ.mjs +2 -0
- package/dist/session-archive.runtime-B52_5vs4-BG-_IwNJ.mjs +2 -0
- package/dist/session-key-Cn2QoOyX-CuHbJMgR.mjs +82 -0
- package/dist/session-transcript-files.fs-DEeFXruQ-B1PF6nLy.mjs +147 -0
- package/dist/src-BgCX0MLG.mjs +813 -0
- package/dist/src-DYbqlAqf.mjs +1177 -0
- package/dist/subagent-announce-L5WsQatW-CQWI9GMd.mjs +344 -0
- package/dist/subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs +28 -0
- package/dist/subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs +211 -0
- package/dist/subagent-system-prompt-C1qnN--K-DpnTFP47.mjs +3061 -0
- package/dist/target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs +1002 -0
- package/dist/task-registry-delivery-runtime-Dd1CUkZF-C8U40a3O.mjs +2950 -0
- package/dist/task-registry-delivery-runtime-ragbeVx5-CNbFAkjD.mjs +2 -0
- package/dist/thinking-Bh-7MqXz-D3woGbO7.mjs +2 -0
- package/dist/transcript-E_-ISOkD-DWCfZP2p.mjs +2019 -0
- package/dist/transcript.runtime-BqhvZZdl-BPy42vBP.mjs +2 -0
- package/dist/transform-messages-DbhIzTxq.mjs +207 -0
- package/dist/web-provider-public-artifacts-BlpRwIUS-CGPSV4W2.mjs +295 -0
- package/dist/web-search-providers.runtime--0aUtC3b-DyuhC95V.mjs +200 -0
- package/package.json +3 -3
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- /package/dist/{interactive-init-B6j8j_Ap.mjs → interactive-init-BXQBalNr.mjs} +0 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { c as normalizeOptionalString } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
+
import { C as SILENT_REPLY_TOKEN, D as stripLeadingSilentToken, E as startsWithSilentToken, O as stripSilentToken, T as isSilentReplyText, n as getSubagentDepthFromSessionStore } from "./target-parsing-loaded-DKkb6jJY-BMD4CkpS.mjs";
|
|
3
|
+
import { n as loadConfig } from "./io-CH2g3vsv-BOGlLlB8.mjs";
|
|
4
|
+
import { C as isEmbeddedPiRunActive, T as formatAgentInternalEventsForPrompt, _ as isAnnounceSkip, a as loadRequesterSessionEntry, b as waitForSubagentRunOutcome, c as resolveSubagentAnnounceTimeoutMs, d as applySubagentWaitOutcome, f as buildChildCompletionFindings, g as filterCurrentDirectChildCompletionRows, h as dedupeLatestChildCompletionRows, i as deliverSubagentAnnouncement, l as resolveSubagentCompletionOrigin, m as captureSubagentCompletionReply, n as buildAnnounceIdFromChildRun, o as loadSessionEntryByKey, p as buildCompactAnnounceStatsLine, r as buildAnnounceIdempotencyKey, s as resolveAnnounceOrigin, t as buildSubagentSystemPrompt, u as runAnnounceDeliveryWithRetry, v as readLatestSubagentOutputWithRetry, w as waitForEmbeddedPiRunEnd, y as readSubagentOutput } from "./subagent-system-prompt-C1qnN--K-DpnTFP47.mjs";
|
|
5
|
+
import { t as INTERNAL_MESSAGE_CHANNEL } from "./message-channel-core-DTA--Gjh-CY4Tkb7N.mjs";
|
|
6
|
+
import "./message-channel-Bk_YHfQg-AeNrPPpp.mjs";
|
|
7
|
+
import { P as defaultRuntime } from "./manifest-registry-_hxKCS2K-CZdeyN0f.mjs";
|
|
8
|
+
import { r as isCronSessionKey } from "./session-key-Cn2QoOyX-CuHbJMgR.mjs";
|
|
9
|
+
import { r as normalizeDeliveryContext } from "./delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs";
|
|
10
|
+
import { t as callGateway } from "./call-DimWbpgJ-ColD4W-y.mjs";
|
|
11
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/subagent-announce-L5WsQatW.js
|
|
12
|
+
const defaultSubagentAnnounceDeps = {
|
|
13
|
+
callGateway,
|
|
14
|
+
loadConfig,
|
|
15
|
+
loadSubagentRegistryRuntime
|
|
16
|
+
};
|
|
17
|
+
let subagentAnnounceDeps = defaultSubagentAnnounceDeps;
|
|
18
|
+
let subagentRegistryRuntimePromise = null;
|
|
19
|
+
function loadSubagentRegistryRuntime() {
|
|
20
|
+
subagentRegistryRuntimePromise ??= import("./subagent-announce.registry.runtime-DiqZyeTs-BKuniyi3.mjs");
|
|
21
|
+
return subagentRegistryRuntimePromise;
|
|
22
|
+
}
|
|
23
|
+
function buildAnnounceReplyInstruction(params) {
|
|
24
|
+
if (params.requesterIsSubagent) return `Convert this completion into a concise internal orchestration update for your parent agent in your own words. Keep this internal context private (don't mention system/log/stats/session details or announce type). If this result is duplicate or no update is needed, reply ONLY: ${SILENT_REPLY_TOKEN}.`;
|
|
25
|
+
if (params.expectsCompletionMessage) return `A completed ${params.announceType} is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now. Keep this internal context private (don't mention system/log/stats/session details or announce type).`;
|
|
26
|
+
return `A completed ${params.announceType} is ready for user delivery. Convert the result above into your normal assistant voice and send that user-facing update now. Keep this internal context private (don't mention system/log/stats/session details or announce type), and do not copy the internal event text verbatim. Reply ONLY: ${SILENT_REPLY_TOKEN} if this exact result was already delivered to the user in this same turn.`;
|
|
27
|
+
}
|
|
28
|
+
function buildAnnounceSteerMessage(events) {
|
|
29
|
+
return formatAgentInternalEventsForPrompt(events) || "A background task finished. Process the completion update now.";
|
|
30
|
+
}
|
|
31
|
+
function hasUsableSessionEntry(entry) {
|
|
32
|
+
if (!entry || typeof entry !== "object") return false;
|
|
33
|
+
const sessionId = entry.sessionId;
|
|
34
|
+
return typeof sessionId !== "string" || sessionId.trim() !== "";
|
|
35
|
+
}
|
|
36
|
+
function buildDescendantWakeMessage(params) {
|
|
37
|
+
return [
|
|
38
|
+
"[Subagent Context] Your prior run ended while waiting for descendant subagent completions.",
|
|
39
|
+
"[Subagent Context] All pending descendants for that run have now settled.",
|
|
40
|
+
"[Subagent Context] Continue your workflow using these results. Spawn more subagents if needed, otherwise send your final answer.",
|
|
41
|
+
"",
|
|
42
|
+
`Task: ${params.taskLabel}`,
|
|
43
|
+
"",
|
|
44
|
+
params.findings
|
|
45
|
+
].join("\n");
|
|
46
|
+
}
|
|
47
|
+
const WAKE_RUN_SUFFIX = ":wake";
|
|
48
|
+
function stripWakeRunSuffixes(runId) {
|
|
49
|
+
let next = runId.trim();
|
|
50
|
+
while (next.endsWith(WAKE_RUN_SUFFIX)) next = next.slice(0, -5);
|
|
51
|
+
return next || runId.trim();
|
|
52
|
+
}
|
|
53
|
+
function isWakeContinuationRun(runId) {
|
|
54
|
+
const trimmed = runId.trim();
|
|
55
|
+
if (!trimmed) return false;
|
|
56
|
+
return stripWakeRunSuffixes(trimmed) !== trimmed;
|
|
57
|
+
}
|
|
58
|
+
function stripAndClassifyReply(text) {
|
|
59
|
+
let result = text;
|
|
60
|
+
let didStrip = false;
|
|
61
|
+
const hasLeadingSilentToken = startsWithSilentToken(result, SILENT_REPLY_TOKEN);
|
|
62
|
+
if (hasLeadingSilentToken) {
|
|
63
|
+
result = stripLeadingSilentToken(result, SILENT_REPLY_TOKEN);
|
|
64
|
+
didStrip = true;
|
|
65
|
+
}
|
|
66
|
+
if (hasLeadingSilentToken || result.toLowerCase().includes("NO_REPLY".toLowerCase())) {
|
|
67
|
+
result = stripSilentToken(result, SILENT_REPLY_TOKEN);
|
|
68
|
+
didStrip = true;
|
|
69
|
+
}
|
|
70
|
+
if (didStrip && (!result.trim() || isSilentReplyText(result, "NO_REPLY") || isAnnounceSkip(result))) return null;
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
async function wakeSubagentRunAfterDescendants(params) {
|
|
74
|
+
if (params.signal?.aborted) return false;
|
|
75
|
+
if (!hasUsableSessionEntry(loadSessionEntryByKey(params.childSessionKey))) return false;
|
|
76
|
+
const announceTimeoutMs = resolveSubagentAnnounceTimeoutMs(subagentAnnounceDeps.loadConfig());
|
|
77
|
+
const wakeMessage = buildDescendantWakeMessage({
|
|
78
|
+
findings: params.findings,
|
|
79
|
+
taskLabel: params.taskLabel
|
|
80
|
+
});
|
|
81
|
+
let wakeRunId = "";
|
|
82
|
+
try {
|
|
83
|
+
wakeRunId = normalizeOptionalString((await runAnnounceDeliveryWithRetry({
|
|
84
|
+
operation: "descendant wake agent call",
|
|
85
|
+
signal: params.signal,
|
|
86
|
+
run: async () => await subagentAnnounceDeps.callGateway({
|
|
87
|
+
method: "agent",
|
|
88
|
+
params: {
|
|
89
|
+
sessionKey: params.childSessionKey,
|
|
90
|
+
message: wakeMessage,
|
|
91
|
+
deliver: false,
|
|
92
|
+
inputProvenance: {
|
|
93
|
+
kind: "inter_session",
|
|
94
|
+
sourceSessionKey: params.childSessionKey,
|
|
95
|
+
sourceChannel: "webchat",
|
|
96
|
+
sourceTool: "subagent_announce"
|
|
97
|
+
},
|
|
98
|
+
idempotencyKey: buildAnnounceIdempotencyKey(`${params.announceId}:wake`)
|
|
99
|
+
},
|
|
100
|
+
timeoutMs: announceTimeoutMs
|
|
101
|
+
})
|
|
102
|
+
}))?.runId) ?? "";
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (!wakeRunId) return false;
|
|
107
|
+
const { replaceSubagentRunAfterSteer } = await loadSubagentRegistryRuntime();
|
|
108
|
+
return replaceSubagentRunAfterSteer({
|
|
109
|
+
previousRunId: params.runId,
|
|
110
|
+
nextRunId: wakeRunId,
|
|
111
|
+
preserveFrozenResultFallback: true
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async function runSubagentAnnounceFlow(params) {
|
|
115
|
+
let didAnnounce = false;
|
|
116
|
+
const expectsCompletionMessage = params.expectsCompletionMessage === true;
|
|
117
|
+
const announceType = params.announceType ?? "subagent task";
|
|
118
|
+
let shouldDeleteChildSession = params.cleanup === "delete";
|
|
119
|
+
try {
|
|
120
|
+
let targetRequesterSessionKey = params.requesterSessionKey;
|
|
121
|
+
let targetRequesterOrigin = normalizeDeliveryContext(params.requesterOrigin);
|
|
122
|
+
const childSessionId = (() => {
|
|
123
|
+
const entry = loadSessionEntryByKey(params.childSessionKey);
|
|
124
|
+
return typeof entry?.sessionId === "string" && entry.sessionId.trim() ? entry.sessionId.trim() : void 0;
|
|
125
|
+
})();
|
|
126
|
+
const settleTimeoutMs = Math.min(Math.max(params.timeoutMs, 1), 12e4);
|
|
127
|
+
let reply = params.roundOneReply;
|
|
128
|
+
let outcome = params.outcome;
|
|
129
|
+
if (childSessionId && isEmbeddedPiRunActive(childSessionId)) {
|
|
130
|
+
if (!await waitForEmbeddedPiRunEnd(childSessionId, settleTimeoutMs) && isEmbeddedPiRunActive(childSessionId)) {
|
|
131
|
+
shouldDeleteChildSession = false;
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!reply && params.waitForCompletion !== false) {
|
|
136
|
+
const applied = applySubagentWaitOutcome({
|
|
137
|
+
wait: await waitForSubagentRunOutcome(params.childRunId, settleTimeoutMs),
|
|
138
|
+
outcome,
|
|
139
|
+
startedAt: params.startedAt,
|
|
140
|
+
endedAt: params.endedAt
|
|
141
|
+
});
|
|
142
|
+
outcome = applied.outcome;
|
|
143
|
+
params.startedAt = applied.startedAt;
|
|
144
|
+
params.endedAt = applied.endedAt;
|
|
145
|
+
}
|
|
146
|
+
if (!outcome) outcome = { status: "unknown" };
|
|
147
|
+
const failedTerminalOutcome = outcome.status === "error";
|
|
148
|
+
if (failedTerminalOutcome) reply = void 0;
|
|
149
|
+
let requesterDepth = getSubagentDepthFromSessionStore(targetRequesterSessionKey);
|
|
150
|
+
const requesterIsInternalSession = () => requesterDepth >= 1 || isCronSessionKey(targetRequesterSessionKey);
|
|
151
|
+
let childCompletionFindings;
|
|
152
|
+
let subagentRegistryRuntime;
|
|
153
|
+
try {
|
|
154
|
+
subagentRegistryRuntime = await subagentAnnounceDeps.loadSubagentRegistryRuntime();
|
|
155
|
+
if (requesterDepth >= 1 && subagentRegistryRuntime.shouldIgnorePostCompletionAnnounceForSession(targetRequesterSessionKey)) return true;
|
|
156
|
+
if (Math.max(0, subagentRegistryRuntime.countPendingDescendantRuns(params.childSessionKey)) > 0 && announceType !== "cron job") {
|
|
157
|
+
shouldDeleteChildSession = false;
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
if (typeof subagentRegistryRuntime.listSubagentRunsForRequester === "function") {
|
|
161
|
+
const directChildren = subagentRegistryRuntime.listSubagentRunsForRequester(params.childSessionKey, { requesterRunId: params.childRunId });
|
|
162
|
+
if (Array.isArray(directChildren) && directChildren.length > 0) childCompletionFindings = buildChildCompletionFindings(dedupeLatestChildCompletionRows(filterCurrentDirectChildCompletionRows(directChildren, {
|
|
163
|
+
requesterSessionKey: params.childSessionKey,
|
|
164
|
+
getLatestSubagentRunByChildSessionKey: subagentRegistryRuntime.getLatestSubagentRunByChildSessionKey
|
|
165
|
+
})));
|
|
166
|
+
}
|
|
167
|
+
} catch {}
|
|
168
|
+
const announceId = buildAnnounceIdFromChildRun({
|
|
169
|
+
childSessionKey: params.childSessionKey,
|
|
170
|
+
childRunId: params.childRunId
|
|
171
|
+
});
|
|
172
|
+
const childRunAlreadyWoken = isWakeContinuationRun(params.childRunId);
|
|
173
|
+
if (params.wakeOnDescendantSettle === true && childCompletionFindings?.trim() && !childRunAlreadyWoken) {
|
|
174
|
+
const wakeAnnounceId = buildAnnounceIdFromChildRun({
|
|
175
|
+
childSessionKey: params.childSessionKey,
|
|
176
|
+
childRunId: stripWakeRunSuffixes(params.childRunId)
|
|
177
|
+
});
|
|
178
|
+
if (await wakeSubagentRunAfterDescendants({
|
|
179
|
+
runId: params.childRunId,
|
|
180
|
+
childSessionKey: params.childSessionKey,
|
|
181
|
+
taskLabel: params.label || params.task || "task",
|
|
182
|
+
findings: childCompletionFindings,
|
|
183
|
+
announceId: wakeAnnounceId,
|
|
184
|
+
signal: params.signal
|
|
185
|
+
})) {
|
|
186
|
+
shouldDeleteChildSession = false;
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!childCompletionFindings && !failedTerminalOutcome) {
|
|
191
|
+
const fallbackReply = normalizeOptionalString(params.fallbackReply);
|
|
192
|
+
const fallbackIsSilent = Boolean(fallbackReply) && (isAnnounceSkip(fallbackReply) || isSilentReplyText(fallbackReply, "NO_REPLY"));
|
|
193
|
+
if (!reply) reply = await readSubagentOutput(params.childSessionKey, outcome);
|
|
194
|
+
if (!reply?.trim()) reply = await readLatestSubagentOutputWithRetry({
|
|
195
|
+
sessionKey: params.childSessionKey,
|
|
196
|
+
maxWaitMs: params.timeoutMs,
|
|
197
|
+
outcome
|
|
198
|
+
});
|
|
199
|
+
if (!reply?.trim() && fallbackReply && !fallbackIsSilent) reply = fallbackReply;
|
|
200
|
+
if (outcome?.status === "timeout" && reply?.trim() && params.waitForCompletion !== false) try {
|
|
201
|
+
const applied = applySubagentWaitOutcome({
|
|
202
|
+
wait: await waitForSubagentRunOutcome(params.childRunId, 0),
|
|
203
|
+
outcome,
|
|
204
|
+
startedAt: params.startedAt,
|
|
205
|
+
endedAt: params.endedAt
|
|
206
|
+
});
|
|
207
|
+
outcome = applied.outcome;
|
|
208
|
+
params.startedAt = applied.startedAt;
|
|
209
|
+
params.endedAt = applied.endedAt;
|
|
210
|
+
} catch {}
|
|
211
|
+
if (isAnnounceSkip(reply) || isSilentReplyText(reply, "NO_REPLY")) if (fallbackReply && !fallbackIsSilent) {
|
|
212
|
+
const cleaned = stripAndClassifyReply(fallbackReply);
|
|
213
|
+
if (cleaned === null) return true;
|
|
214
|
+
reply = cleaned;
|
|
215
|
+
} else return true;
|
|
216
|
+
else if (reply) {
|
|
217
|
+
const cleaned = stripAndClassifyReply(reply);
|
|
218
|
+
if (cleaned === null) if (fallbackReply && !fallbackIsSilent) {
|
|
219
|
+
const cleanedFallback = stripAndClassifyReply(fallbackReply);
|
|
220
|
+
if (cleanedFallback === null) return true;
|
|
221
|
+
reply = cleanedFallback;
|
|
222
|
+
} else return true;
|
|
223
|
+
else reply = cleaned;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (!outcome) outcome = { status: "unknown" };
|
|
227
|
+
const statusLabel = outcome.status === "ok" ? "completed successfully" : outcome.status === "timeout" ? "timed out" : outcome.status === "error" ? `failed: ${outcome.error || "unknown error"}` : "finished with unknown status";
|
|
228
|
+
const taskLabel = params.label || params.task || "task";
|
|
229
|
+
const announceSessionId = childSessionId || "unknown";
|
|
230
|
+
const findings = childCompletionFindings || reply || "(no output)";
|
|
231
|
+
let requesterIsSubagent = requesterIsInternalSession();
|
|
232
|
+
if (requesterIsSubagent) {
|
|
233
|
+
const { isSubagentSessionRunActive, resolveRequesterForChildSession, shouldIgnorePostCompletionAnnounceForSession } = subagentRegistryRuntime ?? await loadSubagentRegistryRuntime();
|
|
234
|
+
if (!isSubagentSessionRunActive(targetRequesterSessionKey)) {
|
|
235
|
+
if (shouldIgnorePostCompletionAnnounceForSession(targetRequesterSessionKey)) return true;
|
|
236
|
+
if (!hasUsableSessionEntry(loadSessionEntryByKey(targetRequesterSessionKey))) {
|
|
237
|
+
const fallback = resolveRequesterForChildSession(targetRequesterSessionKey);
|
|
238
|
+
if (!fallback?.requesterSessionKey) {
|
|
239
|
+
shouldDeleteChildSession = false;
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
targetRequesterSessionKey = fallback.requesterSessionKey;
|
|
243
|
+
targetRequesterOrigin = normalizeDeliveryContext(fallback.requesterOrigin) ?? targetRequesterOrigin;
|
|
244
|
+
requesterDepth = getSubagentDepthFromSessionStore(targetRequesterSessionKey);
|
|
245
|
+
requesterIsSubagent = requesterIsInternalSession();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const replyInstruction = buildAnnounceReplyInstruction({
|
|
250
|
+
requesterIsSubagent,
|
|
251
|
+
announceType,
|
|
252
|
+
expectsCompletionMessage
|
|
253
|
+
});
|
|
254
|
+
const statsLine = await buildCompactAnnounceStatsLine({
|
|
255
|
+
sessionKey: params.childSessionKey,
|
|
256
|
+
startedAt: params.startedAt,
|
|
257
|
+
endedAt: params.endedAt
|
|
258
|
+
});
|
|
259
|
+
const internalEvents = [{
|
|
260
|
+
type: "task_completion",
|
|
261
|
+
source: announceType === "cron job" ? "cron" : "subagent",
|
|
262
|
+
childSessionKey: params.childSessionKey,
|
|
263
|
+
childSessionId: announceSessionId,
|
|
264
|
+
announceType,
|
|
265
|
+
taskLabel,
|
|
266
|
+
status: outcome.status,
|
|
267
|
+
statusLabel,
|
|
268
|
+
result: findings,
|
|
269
|
+
statsLine,
|
|
270
|
+
replyInstruction
|
|
271
|
+
}];
|
|
272
|
+
const triggerMessage = buildAnnounceSteerMessage(internalEvents);
|
|
273
|
+
let directOrigin = targetRequesterOrigin;
|
|
274
|
+
if (!requesterIsSubagent) {
|
|
275
|
+
const { entry } = loadRequesterSessionEntry(targetRequesterSessionKey);
|
|
276
|
+
directOrigin = resolveAnnounceOrigin(entry, targetRequesterOrigin);
|
|
277
|
+
}
|
|
278
|
+
const completionDirectOrigin = expectsCompletionMessage && !requesterIsSubagent ? await resolveSubagentCompletionOrigin({
|
|
279
|
+
childSessionKey: params.childSessionKey,
|
|
280
|
+
requesterSessionKey: targetRequesterSessionKey,
|
|
281
|
+
requesterOrigin: directOrigin,
|
|
282
|
+
childRunId: params.childRunId,
|
|
283
|
+
spawnMode: params.spawnMode,
|
|
284
|
+
expectsCompletionMessage
|
|
285
|
+
}) : targetRequesterOrigin;
|
|
286
|
+
const directIdempotencyKey = buildAnnounceIdempotencyKey(announceId);
|
|
287
|
+
const delivery = await deliverSubagentAnnouncement({
|
|
288
|
+
requesterSessionKey: targetRequesterSessionKey,
|
|
289
|
+
announceId,
|
|
290
|
+
triggerMessage,
|
|
291
|
+
steerMessage: triggerMessage,
|
|
292
|
+
internalEvents,
|
|
293
|
+
summaryLine: taskLabel,
|
|
294
|
+
requesterSessionOrigin: targetRequesterOrigin,
|
|
295
|
+
requesterOrigin: expectsCompletionMessage && !requesterIsSubagent ? completionDirectOrigin : targetRequesterOrigin,
|
|
296
|
+
completionDirectOrigin,
|
|
297
|
+
directOrigin,
|
|
298
|
+
sourceSessionKey: params.childSessionKey,
|
|
299
|
+
sourceChannel: INTERNAL_MESSAGE_CHANNEL,
|
|
300
|
+
sourceTool: "subagent_announce",
|
|
301
|
+
targetRequesterSessionKey,
|
|
302
|
+
requesterIsSubagent,
|
|
303
|
+
expectsCompletionMessage,
|
|
304
|
+
bestEffortDeliver: params.bestEffortDeliver,
|
|
305
|
+
directIdempotencyKey,
|
|
306
|
+
signal: params.signal
|
|
307
|
+
});
|
|
308
|
+
didAnnounce = delivery.delivered;
|
|
309
|
+
if (!delivery.delivered && delivery.path === "direct" && delivery.error) defaultRuntime.error?.(`Subagent completion direct announce failed for run ${params.childRunId}: ${delivery.error}`);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
defaultRuntime.error?.(`Subagent announce failed: ${String(err)}`);
|
|
312
|
+
} finally {
|
|
313
|
+
if (params.label) try {
|
|
314
|
+
await subagentAnnounceDeps.callGateway({
|
|
315
|
+
method: "sessions.patch",
|
|
316
|
+
params: {
|
|
317
|
+
key: params.childSessionKey,
|
|
318
|
+
label: params.label
|
|
319
|
+
},
|
|
320
|
+
timeoutMs: 1e4
|
|
321
|
+
});
|
|
322
|
+
} catch {}
|
|
323
|
+
if (shouldDeleteChildSession) try {
|
|
324
|
+
await subagentAnnounceDeps.callGateway({
|
|
325
|
+
method: "sessions.delete",
|
|
326
|
+
params: {
|
|
327
|
+
key: params.childSessionKey,
|
|
328
|
+
deleteTranscript: true,
|
|
329
|
+
emitLifecycleHooks: params.spawnMode === "session"
|
|
330
|
+
},
|
|
331
|
+
timeoutMs: 1e4
|
|
332
|
+
});
|
|
333
|
+
} catch {}
|
|
334
|
+
}
|
|
335
|
+
return didAnnounce;
|
|
336
|
+
}
|
|
337
|
+
const __testing = { setDepsForTest(overrides) {
|
|
338
|
+
subagentAnnounceDeps = overrides ? {
|
|
339
|
+
...defaultSubagentAnnounceDeps,
|
|
340
|
+
...overrides
|
|
341
|
+
} : defaultSubagentAnnounceDeps;
|
|
342
|
+
} };
|
|
343
|
+
//#endregion
|
|
344
|
+
export { __testing, buildSubagentSystemPrompt, captureSubagentCompletionReply, runSubagentAnnounceFlow };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { r as normalizeDeliveryContext } from "./delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs";
|
|
2
|
+
import { a as countPendingDescendantRunsExcludingRunFromRuns, c as isSubagentSessionRunActiveFromRuns, d as resolveRequesterForChildSessionFromRuns, i as getLatestSubagentRunByChildSessionKey, l as listRunsForRequesterFromRuns, m as subagentRuns, n as replaceSubagentRunAfterSteer, o as countPendingDescendantRunsFromRuns, p as shouldIgnorePostCompletionAnnounceForSessionFromRuns, r as countActiveDescendantRuns, s as getSubagentRunsSnapshotForRead } from "./subagent-registry-steer-runtime-DFgZFC0j-BhBz0roy.mjs";
|
|
3
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/subagent-announce.registry.runtime-DiqZyeTs.js
|
|
4
|
+
function resolveRequesterForChildSession(childSessionKey) {
|
|
5
|
+
const resolved = resolveRequesterForChildSessionFromRuns(getSubagentRunsSnapshotForRead(subagentRuns), childSessionKey);
|
|
6
|
+
if (!resolved) return null;
|
|
7
|
+
return {
|
|
8
|
+
requesterSessionKey: resolved.requesterSessionKey,
|
|
9
|
+
requesterOrigin: normalizeDeliveryContext(resolved.requesterOrigin)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function isSubagentSessionRunActive(childSessionKey) {
|
|
13
|
+
return isSubagentSessionRunActiveFromRuns(subagentRuns, childSessionKey);
|
|
14
|
+
}
|
|
15
|
+
function shouldIgnorePostCompletionAnnounceForSession(childSessionKey) {
|
|
16
|
+
return shouldIgnorePostCompletionAnnounceForSessionFromRuns(getSubagentRunsSnapshotForRead(subagentRuns), childSessionKey);
|
|
17
|
+
}
|
|
18
|
+
function listSubagentRunsForRequester(requesterSessionKey, options) {
|
|
19
|
+
return listRunsForRequesterFromRuns(subagentRuns, requesterSessionKey, options);
|
|
20
|
+
}
|
|
21
|
+
function countPendingDescendantRuns(rootSessionKey) {
|
|
22
|
+
return countPendingDescendantRunsFromRuns(getSubagentRunsSnapshotForRead(subagentRuns), rootSessionKey);
|
|
23
|
+
}
|
|
24
|
+
function countPendingDescendantRunsExcludingRun(rootSessionKey, excludeRunId) {
|
|
25
|
+
return countPendingDescendantRunsExcludingRunFromRuns(getSubagentRunsSnapshotForRead(subagentRuns), rootSessionKey, excludeRunId);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { countActiveDescendantRuns, countPendingDescendantRuns, countPendingDescendantRunsExcludingRun, getLatestSubagentRunByChildSessionKey, isSubagentSessionRunActive, listSubagentRunsForRequester, replaceSubagentRunAfterSteer, resolveRequesterForChildSession, shouldIgnorePostCompletionAnnounceForSession };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { d as readStringValue } from "./home-dir-C44RaPME-CBRS4HLP.mjs";
|
|
2
|
+
import { o as resolveStateDir } from "./paths-D92DjaZ--CTOESW2b.mjs";
|
|
3
|
+
import { r as normalizeDeliveryContext } from "./delivery-context.shared-j5hC5qb1-CI83RXXZ.mjs";
|
|
4
|
+
import { n as saveJsonFile, t as loadJsonFile } from "./json-file-BQRNuxmK-DhJM5NsG.mjs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import os from "node:os";
|
|
7
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/subagent-registry-state-ByShCGTk.js
|
|
8
|
+
const subagentRuns = /* @__PURE__ */ new Map();
|
|
9
|
+
function listRunsForRequesterFromRuns(runs, requesterSessionKey, options) {
|
|
10
|
+
const key = requesterSessionKey.trim();
|
|
11
|
+
if (!key) return [];
|
|
12
|
+
const requesterRunId = options?.requesterRunId?.trim();
|
|
13
|
+
const requesterRun = requesterRunId ? runs.get(requesterRunId) : void 0;
|
|
14
|
+
const requesterRunMatchesScope = requesterRun && requesterRun.childSessionKey === key ? requesterRun : void 0;
|
|
15
|
+
const lowerBound = requesterRunMatchesScope?.startedAt ?? requesterRunMatchesScope?.createdAt;
|
|
16
|
+
const upperBound = requesterRunMatchesScope?.endedAt;
|
|
17
|
+
return [...runs.values()].filter((entry) => {
|
|
18
|
+
if (entry.requesterSessionKey !== key) return false;
|
|
19
|
+
if (typeof lowerBound === "number" && entry.createdAt < lowerBound) return false;
|
|
20
|
+
if (typeof upperBound === "number" && entry.createdAt > upperBound) return false;
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function findLatestRunForChildSession(runs, childSessionKey) {
|
|
25
|
+
const key = childSessionKey.trim();
|
|
26
|
+
if (!key) return;
|
|
27
|
+
let latest;
|
|
28
|
+
for (const entry of runs.values()) {
|
|
29
|
+
if (entry.childSessionKey !== key) continue;
|
|
30
|
+
if (!latest || entry.createdAt > latest.createdAt) latest = entry;
|
|
31
|
+
}
|
|
32
|
+
return latest;
|
|
33
|
+
}
|
|
34
|
+
function isSubagentSessionRunActiveFromRuns(runs, childSessionKey) {
|
|
35
|
+
const latest = findLatestRunForChildSession(runs, childSessionKey);
|
|
36
|
+
return Boolean(latest && typeof latest.endedAt !== "number");
|
|
37
|
+
}
|
|
38
|
+
function resolveRequesterForChildSessionFromRuns(runs, childSessionKey) {
|
|
39
|
+
const latest = findLatestRunForChildSession(runs, childSessionKey);
|
|
40
|
+
if (!latest) return null;
|
|
41
|
+
return {
|
|
42
|
+
requesterSessionKey: latest.requesterSessionKey,
|
|
43
|
+
requesterOrigin: latest.requesterOrigin
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function shouldIgnorePostCompletionAnnounceForSessionFromRuns(runs, childSessionKey) {
|
|
47
|
+
const latest = findLatestRunForChildSession(runs, childSessionKey);
|
|
48
|
+
return Boolean(latest && latest.spawnMode !== "session" && typeof latest.endedAt === "number" && typeof latest.cleanupCompletedAt === "number" && latest.cleanupCompletedAt >= latest.endedAt);
|
|
49
|
+
}
|
|
50
|
+
function forEachDescendantRun(runs, rootSessionKey, visitor) {
|
|
51
|
+
const root = rootSessionKey.trim();
|
|
52
|
+
if (!root) return false;
|
|
53
|
+
const pending = [root];
|
|
54
|
+
const visited = new Set([root]);
|
|
55
|
+
for (let index = 0; index < pending.length; index += 1) {
|
|
56
|
+
const requester = pending[index];
|
|
57
|
+
if (!requester) continue;
|
|
58
|
+
const latestByChildSessionKey = /* @__PURE__ */ new Map();
|
|
59
|
+
for (const [runId, entry] of runs.entries()) {
|
|
60
|
+
if (entry.requesterSessionKey !== requester) continue;
|
|
61
|
+
const childKey = entry.childSessionKey.trim();
|
|
62
|
+
const existing = latestByChildSessionKey.get(childKey);
|
|
63
|
+
if (!existing || entry.createdAt > existing[1].createdAt) latestByChildSessionKey.set(childKey, [runId, entry]);
|
|
64
|
+
}
|
|
65
|
+
for (const [runId, entry] of latestByChildSessionKey.values()) {
|
|
66
|
+
const latestForChildSession = findLatestRunForChildSession(runs, entry.childSessionKey);
|
|
67
|
+
if (!latestForChildSession || latestForChildSession.runId !== runId || latestForChildSession.requesterSessionKey !== requester) continue;
|
|
68
|
+
visitor(runId, entry);
|
|
69
|
+
const childKey = entry.childSessionKey.trim();
|
|
70
|
+
if (!childKey || visited.has(childKey)) continue;
|
|
71
|
+
visited.add(childKey);
|
|
72
|
+
pending.push(childKey);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
function countActiveDescendantRunsFromRuns(runs, rootSessionKey) {
|
|
78
|
+
let count = 0;
|
|
79
|
+
if (!forEachDescendantRun(runs, rootSessionKey, (_runId, entry) => {
|
|
80
|
+
if (typeof entry.endedAt !== "number") count += 1;
|
|
81
|
+
})) return 0;
|
|
82
|
+
return count;
|
|
83
|
+
}
|
|
84
|
+
function countPendingDescendantRunsInternal(runs, rootSessionKey, excludeRunId) {
|
|
85
|
+
const excludedRunId = excludeRunId?.trim();
|
|
86
|
+
let count = 0;
|
|
87
|
+
if (!forEachDescendantRun(runs, rootSessionKey, (runId, entry) => {
|
|
88
|
+
const runEnded = typeof entry.endedAt === "number";
|
|
89
|
+
const cleanupCompleted = typeof entry.cleanupCompletedAt === "number";
|
|
90
|
+
if ((!runEnded || !cleanupCompleted) && runId !== excludedRunId) count += 1;
|
|
91
|
+
})) return 0;
|
|
92
|
+
return count;
|
|
93
|
+
}
|
|
94
|
+
function countPendingDescendantRunsFromRuns(runs, rootSessionKey) {
|
|
95
|
+
return countPendingDescendantRunsInternal(runs, rootSessionKey);
|
|
96
|
+
}
|
|
97
|
+
function countPendingDescendantRunsExcludingRunFromRuns(runs, rootSessionKey, excludeRunId) {
|
|
98
|
+
return countPendingDescendantRunsInternal(runs, rootSessionKey, excludeRunId);
|
|
99
|
+
}
|
|
100
|
+
const REGISTRY_VERSION = 2;
|
|
101
|
+
function resolveSubagentStateDir(env = process.env) {
|
|
102
|
+
if (env.OPENCLAW_STATE_DIR?.trim()) return resolveStateDir(env);
|
|
103
|
+
if (env.VITEST || env.NODE_ENV === "test") return path.join(os.tmpdir(), "openclaw-test-state", String(process.pid));
|
|
104
|
+
return resolveStateDir(env);
|
|
105
|
+
}
|
|
106
|
+
function resolveSubagentRegistryPath() {
|
|
107
|
+
return path.join(resolveSubagentStateDir(process.env), "subagents", "runs.json");
|
|
108
|
+
}
|
|
109
|
+
function loadSubagentRegistryFromDisk() {
|
|
110
|
+
const raw = loadJsonFile(resolveSubagentRegistryPath());
|
|
111
|
+
if (!raw || typeof raw !== "object") return /* @__PURE__ */ new Map();
|
|
112
|
+
const record = raw;
|
|
113
|
+
if (record.version !== 1 && record.version !== 2) return /* @__PURE__ */ new Map();
|
|
114
|
+
const runsRaw = record.runs;
|
|
115
|
+
if (!runsRaw || typeof runsRaw !== "object") return /* @__PURE__ */ new Map();
|
|
116
|
+
const out = /* @__PURE__ */ new Map();
|
|
117
|
+
const isLegacy = record.version === 1;
|
|
118
|
+
let migrated = false;
|
|
119
|
+
for (const [runId, entry] of Object.entries(runsRaw)) {
|
|
120
|
+
if (!entry || typeof entry !== "object") continue;
|
|
121
|
+
const typed = entry;
|
|
122
|
+
if (!typed.runId || typeof typed.runId !== "string") continue;
|
|
123
|
+
const legacyCompletedAt = isLegacy && typeof typed.announceCompletedAt === "number" ? typed.announceCompletedAt : void 0;
|
|
124
|
+
const cleanupCompletedAt = typeof typed.cleanupCompletedAt === "number" ? typed.cleanupCompletedAt : legacyCompletedAt;
|
|
125
|
+
const cleanupHandled = typeof typed.cleanupHandled === "boolean" ? typed.cleanupHandled : isLegacy ? Boolean(typed.announceHandled ?? cleanupCompletedAt) : void 0;
|
|
126
|
+
const requesterOrigin = normalizeDeliveryContext(typed.requesterOrigin ?? {
|
|
127
|
+
channel: readStringValue(typed.requesterChannel),
|
|
128
|
+
accountId: readStringValue(typed.requesterAccountId)
|
|
129
|
+
});
|
|
130
|
+
const childSessionKey = readStringValue(typed.childSessionKey)?.trim() ?? "";
|
|
131
|
+
const requesterSessionKey = readStringValue(typed.requesterSessionKey)?.trim() ?? "";
|
|
132
|
+
const controllerSessionKey = readStringValue(typed.controllerSessionKey)?.trim() || requesterSessionKey;
|
|
133
|
+
if (!childSessionKey || !requesterSessionKey) continue;
|
|
134
|
+
const { announceCompletedAt: _announceCompletedAt, announceHandled: _announceHandled, requesterChannel: _channel, requesterAccountId: _accountId, ...rest } = typed;
|
|
135
|
+
out.set(runId, {
|
|
136
|
+
...rest,
|
|
137
|
+
childSessionKey,
|
|
138
|
+
requesterSessionKey,
|
|
139
|
+
controllerSessionKey,
|
|
140
|
+
requesterOrigin,
|
|
141
|
+
cleanupCompletedAt,
|
|
142
|
+
cleanupHandled,
|
|
143
|
+
spawnMode: typed.spawnMode === "session" ? "session" : "run"
|
|
144
|
+
});
|
|
145
|
+
if (isLegacy) migrated = true;
|
|
146
|
+
}
|
|
147
|
+
if (migrated) try {
|
|
148
|
+
saveSubagentRegistryToDisk(out);
|
|
149
|
+
} catch {}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
function saveSubagentRegistryToDisk(runs) {
|
|
153
|
+
const pathname = resolveSubagentRegistryPath();
|
|
154
|
+
const serialized = {};
|
|
155
|
+
for (const [runId, entry] of runs.entries()) serialized[runId] = entry;
|
|
156
|
+
saveJsonFile(pathname, {
|
|
157
|
+
version: REGISTRY_VERSION,
|
|
158
|
+
runs: serialized
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function persistSubagentRunsToDisk(runs) {
|
|
162
|
+
try {
|
|
163
|
+
saveSubagentRegistryToDisk(runs);
|
|
164
|
+
} catch {}
|
|
165
|
+
}
|
|
166
|
+
function restoreSubagentRunsFromDisk(params) {
|
|
167
|
+
const restored = loadSubagentRegistryFromDisk();
|
|
168
|
+
if (restored.size === 0) return 0;
|
|
169
|
+
let added = 0;
|
|
170
|
+
for (const [runId, entry] of restored.entries()) {
|
|
171
|
+
if (!runId || !entry) continue;
|
|
172
|
+
if (params.mergeOnly && params.runs.has(runId)) continue;
|
|
173
|
+
params.runs.set(runId, entry);
|
|
174
|
+
added += 1;
|
|
175
|
+
}
|
|
176
|
+
return added;
|
|
177
|
+
}
|
|
178
|
+
function getSubagentRunsSnapshotForRead(inMemoryRuns) {
|
|
179
|
+
const merged = /* @__PURE__ */ new Map();
|
|
180
|
+
if (process.env.OPENCLAW_TEST_READ_SUBAGENT_RUNS_FROM_DISK === "1" || !(process.env.VITEST || false)) try {
|
|
181
|
+
for (const [runId, entry] of loadSubagentRegistryFromDisk().entries()) merged.set(runId, entry);
|
|
182
|
+
} catch {}
|
|
183
|
+
for (const [runId, entry] of inMemoryRuns.entries()) merged.set(runId, entry);
|
|
184
|
+
return merged;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/subagent-registry-read-D7OQcNDJ.js
|
|
188
|
+
function countActiveDescendantRuns(rootSessionKey) {
|
|
189
|
+
return countActiveDescendantRunsFromRuns(getSubagentRunsSnapshotForRead(subagentRuns), rootSessionKey);
|
|
190
|
+
}
|
|
191
|
+
function getLatestSubagentRunByChildSessionKey(childSessionKey) {
|
|
192
|
+
const key = childSessionKey.trim();
|
|
193
|
+
if (!key) return null;
|
|
194
|
+
let latest = null;
|
|
195
|
+
for (const entry of getSubagentRunsSnapshotForRead(subagentRuns).values()) {
|
|
196
|
+
if (entry.childSessionKey !== key) continue;
|
|
197
|
+
if (!latest || entry.createdAt > latest.createdAt) latest = entry;
|
|
198
|
+
}
|
|
199
|
+
return latest;
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region node_modules/.pnpm/openclaw@2026.4.22_@napi-rs+canvas@0.1.99/node_modules/openclaw/dist/subagent-registry-steer-runtime-DFgZFC0j.js
|
|
203
|
+
let replaceSubagentRunAfterSteerImpl = null;
|
|
204
|
+
function configureSubagentRegistrySteerRuntime(params) {
|
|
205
|
+
replaceSubagentRunAfterSteerImpl = params.replaceSubagentRunAfterSteer;
|
|
206
|
+
}
|
|
207
|
+
function replaceSubagentRunAfterSteer(params) {
|
|
208
|
+
return replaceSubagentRunAfterSteerImpl?.(params) ?? false;
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
export { countPendingDescendantRunsExcludingRunFromRuns as a, isSubagentSessionRunActiveFromRuns as c, resolveRequesterForChildSessionFromRuns as d, restoreSubagentRunsFromDisk as f, getLatestSubagentRunByChildSessionKey as i, listRunsForRequesterFromRuns as l, subagentRuns as m, replaceSubagentRunAfterSteer as n, countPendingDescendantRunsFromRuns as o, shouldIgnorePostCompletionAnnounceForSessionFromRuns as p, countActiveDescendantRuns as r, getSubagentRunsSnapshotForRead as s, configureSubagentRegistrySteerRuntime as t, persistSubagentRunsToDisk as u };
|