@openclaw/copilot 2026.9.4 → 2026.9.5
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/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/{attempt-EPgLnjoV.js → .setup/attempt-BZXPuTyZ.mjs} +98 -80
- package/dist/{harness-C_65tSNm.js → .setup/harness-Dj0L75Tk.mjs} +105 -75
- package/dist/{isolated-completion-YG0Z8FkF.js → .setup/isolated-completion-54FP0qmC.mjs} +2 -2
- package/dist/{runtime-LtZ5NAjV.js → .setup/runtime-D6DFeSZX.mjs} +2 -2
- package/dist/harness.js +1 -1
- package/dist/index.js +2 -2
- package/openclaw.plugin.json +9 -1
- package/package.json +8 -6
- /package/dist/{usage-bridge-Cpa-ZYwL.js → .setup/usage-bridge-Cpa-ZYwL.mjs} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
|
2
|
+
<!--
|
|
3
|
+
Adapted from OpenClaw ui/public/provider-icons/ProviderIcon-copilot.svg.
|
|
4
|
+
Source: https://github.com/steipete/CodexBar/blob/215efbd39ad58acb4b0cd637c407d63e6183bc8d/Sources/CodexBar/Resources/ProviderIcon-copilot.svg
|
|
5
|
+
|
|
6
|
+
MIT License
|
|
7
|
+
Copyright (c) 2026 Peter Steinberger
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Names and marks remain the property of their respective owners.
|
|
28
|
+
-->
|
|
29
|
+
<path fill="currentColor" stroke="none" d="M79.7057 21.6044C85.0857 27.2967 87.3915 35.1429 88.3522 46.0659C90.8885 46.0659 93.2711 46.6428 94.8851 48.8352L97.8826 52.9121C98.728 54.0659 99.1892 55.4505 99.1892 56.9121V67.9505C99.1833 68.6605 99.0137 69.3596 98.6938 69.9934C98.3739 70.6271 97.9122 71.1784 97.3446 71.6044C83.7791 81.5275 67.0241 89.5275 50 89.5275C31.1698 89.5275 12.2627 78.6428 2.65542 71.6044C2.08785 71.1784 1.62614 70.6271 1.30621 69.9934C0.986278 69.3596 0.816752 68.6605 0.810822 67.9505L0.810822 56.9121C0.810822 55.4505 1.27197 54.0659 2.11741 52.8736L5.11488 48.8352C6.7289 46.6428 9.1115 46.0659 11.6478 46.0659C12.6085 35.1429 14.8759 27.2967 20.2944 21.6044C30.5165 10.7582 44.0819 9.52747 49.8463 9.52747H50C55.6491 9.52747 69.3683 10.6429 79.7057 21.6044ZM50 39.7967C48.8471 39.7967 47.5021 39.8736 46.0418 40.0275C45.678 41.7486 44.8848 43.3496 43.7361 44.6813C42.1163 46.2842 40.1962 47.5511 38.0858 48.4092C35.9755 49.2672 33.7165 49.6995 31.4388 49.6813C28.8256 49.6813 26.0971 49.1044 23.8683 47.6813C21.7547 48.4121 19.7179 49.4121 19.5642 51.9121C19.3721 56.6044 19.3336 61.3352 19.3336 66.0659C19.3336 68.4121 19.3336 70.7967 19.2568 73.1813C19.2568 74.5659 20.1022 75.8352 21.3704 76.4121C31.5156 81.0275 41.1613 83.3736 50 83.3736C58.8387 83.3736 68.446 81.0659 78.6297 76.4121C79.2511 76.1286 79.7794 75.6746 80.1535 75.1028C80.5276 74.531 80.7321 73.8647 80.7432 73.1813C80.8585 66.1044 80.7432 58.9505 80.4358 51.9121C80.2821 49.3736 78.2454 48.4121 76.1318 47.6813C73.9029 49.1044 71.136 49.6429 68.5612 49.6429C66.2861 49.6662 64.0288 49.2399 61.9186 48.3885C59.8084 47.5371 57.8868 46.2773 56.2639 44.6813C55.1153 43.3496 54.322 41.7486 53.9582 40.0275C52.6516 39.8736 51.3066 39.8352 50 39.7967ZM39.6242 56.7198C41.853 56.7198 43.6592 58.489 43.6592 60.7198V68.1044C43.6592 69.1653 43.2381 70.1827 42.4886 70.9328C41.7391 71.683 40.7226 72.1044 39.6626 72.1044C38.6026 72.1044 37.5861 71.683 36.8366 70.9328C36.087 70.1827 35.666 69.1653 35.666 68.1044V60.6813C35.666 58.4505 37.4337 56.6813 39.6626 56.6813L39.6242 56.7198ZM60.1453 56.7198C62.3742 56.7198 64.1419 58.489 64.1419 60.7198V68.1044C64.1419 69.1653 63.7208 70.1827 62.9713 70.9328C62.2218 71.683 61.2052 72.1044 60.1453 72.1044C59.0853 72.1044 58.0688 71.683 57.3192 70.9328C56.5697 70.1827 56.1487 69.1653 56.1487 68.1044V60.6813C56.1487 58.4505 57.9548 56.6813 60.1453 56.6813V56.7198ZM32.0921 20.4121C27.788 20.8352 24.1757 22.2582 22.3311 24.2582C18.3345 28.6044 19.1799 39.6813 21.4857 42.0275C23.7655 43.9275 26.6682 44.9142 29.6326 44.7967C32.2458 44.7967 37.1647 44.2198 41.1998 40.1044C43.0059 38.3736 44.0819 34.0659 43.9666 29.7198C43.8514 26.2198 42.8522 23.2967 41.3919 22.0659C39.7779 20.6813 36.1655 20.0659 32.0921 20.4121ZM58.6081 22.0659C57.1478 23.2967 56.1487 26.2198 56.0334 29.7198C55.9181 34.0659 56.9941 38.3736 58.8003 40.1044C60.3121 41.6165 62.111 42.8106 64.0909 43.6164C66.0708 44.4223 68.1918 44.8236 70.329 44.7967C73.7492 44.7967 76.8619 43.6813 78.5144 42.0275C80.8201 39.6813 81.6655 28.6044 77.6689 24.2198C75.8243 22.2967 72.212 20.8352 67.9079 20.4121C63.8345 20.0275 60.2221 20.6813 58.6081 22.0659ZM50 31.0659C49.0009 31.0659 47.848 31.1429 46.5414 31.2582C46.6951 31.9121 46.7335 32.6813 46.8104 33.4505C46.8104 34.0275 46.8104 34.6044 46.7335 35.1813C47.9633 35.0659 49.0393 35.0659 50 35.0659C50.9992 35.0659 52.0367 35.0659 53.2665 35.1813C53.1896 34.5659 53.1896 34.0275 53.1896 33.4505C53.2665 32.6813 53.3049 31.9121 53.4586 31.2582C52.152 31.1429 50.9992 31.0659 50 31.0659Z" />
|
|
30
|
+
</svg>
|
package/assets/icon.png
ADDED
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as resolveCopilotAuth, i as createCopilotByokAuth, n as resolveCopilotProvider, r as createCopilotByokProxy } from "./harness-
|
|
2
|
-
import { n as normalizeCopilotUsage, r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.
|
|
1
|
+
import { a as resolveCopilotAuth, i as createCopilotByokAuth, n as resolveCopilotProvider, r as createCopilotByokProxy } from "./harness-Dj0L75Tk.mjs";
|
|
2
|
+
import { n as normalizeCopilotUsage, r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.mjs";
|
|
3
3
|
import { asNonArrayRecord, asOptionalRecord, normalizeOptionalString, normalizeUniqueStringEntries, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { SKILL_WORKSHOP_TOOL_NAME, applyEmbeddedAttemptToolsAllow, awaitAgentEndSideEffects, buildAgentHookContextChannelFields, buildCredentialSafetyPrompt, buildDelegationGuidanceSection, buildEmbeddedAttemptToolRunContext, buildEmbeddedForegroundPromptContext, buildHarnessVisibleReplyGuidance, buildSkillWorkshopPromptSection, cancelPendingAgentQuestionForSession, claimPendingAgentQuestionAnswer, clearActiveEmbeddedRun, detectAndLoadAgentHarnessPromptImages, embeddedAgentLog, extractToolErrorMessage, getModelProviderRequestTransport, getPluginToolMeta, getPluginToolSideEffectOwnerKey, isHostScopedAgentToolActive, isSubagentSessionKey, isToolResultError, projectAgentHarnessTranscriptMessageForDisplay, resolveAgentDir, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptFsWorkspaceOnly, resolveAttemptSpawnWorkspaceDir, resolveBootstrapContextForRun, resolveCompactionTimeoutMs, resolveEmbeddedAttemptToolConstructionPlan, resolveMainSessionDelegationMode, resolveModelAuthMode, resolveSandboxContext, resolveUserPath, restorePreparedUserTurnOperationalMetaForRuntime, runAgentEndSideEffects, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessGatewayQuestion, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, sanitizeToolResult, setActiveEmbeddedRun } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
5
5
|
import path from "node:path";
|
|
@@ -1224,6 +1224,7 @@ async function finalizeCopilotAttempt(params, result, ctx, attemptStartedAt, now
|
|
|
1224
1224
|
function deferBackgroundCompactionCleanup(params) {
|
|
1225
1225
|
return (async () => {
|
|
1226
1226
|
let outcome = "deadline";
|
|
1227
|
+
let finalizationError;
|
|
1227
1228
|
try {
|
|
1228
1229
|
outcome = await awaitDeferredCleanupBeforeDeadline({
|
|
1229
1230
|
abortSignal: params.abortSignal,
|
|
@@ -1236,7 +1237,11 @@ function deferBackgroundCompactionCleanup(params) {
|
|
|
1236
1237
|
await cancelBackgroundCompactionBeforeTeardown(params.session);
|
|
1237
1238
|
params.bridge.settleCompactionWait();
|
|
1238
1239
|
}
|
|
1239
|
-
|
|
1240
|
+
try {
|
|
1241
|
+
params.finalizeNativeSubagents?.();
|
|
1242
|
+
} catch (error) {
|
|
1243
|
+
finalizationError = toCopilotError(error);
|
|
1244
|
+
}
|
|
1240
1245
|
params.bridge.detach();
|
|
1241
1246
|
try {
|
|
1242
1247
|
await params.session.disconnect();
|
|
@@ -1250,6 +1255,7 @@ function deferBackgroundCompactionCleanup(params) {
|
|
|
1250
1255
|
await params.pool.release(params.handle);
|
|
1251
1256
|
} catch {}
|
|
1252
1257
|
}
|
|
1258
|
+
if (finalizationError) throw finalizationError;
|
|
1253
1259
|
return outcome;
|
|
1254
1260
|
})();
|
|
1255
1261
|
}
|
|
@@ -1397,6 +1403,49 @@ async function waitForPersistenceReceipt(receipt, requestedTimeoutMs) {
|
|
|
1397
1403
|
}
|
|
1398
1404
|
}
|
|
1399
1405
|
//#endregion
|
|
1406
|
+
//#region extensions/copilot/src/attempt-transcript-replay.ts
|
|
1407
|
+
function userText(content) {
|
|
1408
|
+
if (typeof content === "string") return content;
|
|
1409
|
+
if (Array.isArray(content) && content.length === 1) {
|
|
1410
|
+
const part = content[0];
|
|
1411
|
+
if (part?.type === "text" && typeof part.text === "string") return part.text;
|
|
1412
|
+
}
|
|
1413
|
+
return JSON.stringify(content) ?? "";
|
|
1414
|
+
}
|
|
1415
|
+
function readAssistantToolCallIds(message) {
|
|
1416
|
+
return message.role === "assistant" ? message.content.flatMap((part) => part.type === "toolCall" ? [part.id] : []) : [];
|
|
1417
|
+
}
|
|
1418
|
+
function isCompatibleSingletonRewrite(original, prepared) {
|
|
1419
|
+
return original.role === prepared.role && (original.role !== "assistant" || JSON.stringify(readAssistantToolCallIds(original)) === JSON.stringify(readAssistantToolCallIds(prepared)));
|
|
1420
|
+
}
|
|
1421
|
+
function projectReplayPayload(message) {
|
|
1422
|
+
switch (message.role) {
|
|
1423
|
+
case "user": return {
|
|
1424
|
+
role: message.role,
|
|
1425
|
+
content: message.content
|
|
1426
|
+
};
|
|
1427
|
+
case "assistant": return {
|
|
1428
|
+
role: message.role,
|
|
1429
|
+
content: message.content,
|
|
1430
|
+
api: message.api,
|
|
1431
|
+
model: message.model,
|
|
1432
|
+
provider: message.provider,
|
|
1433
|
+
stopReason: message.stopReason
|
|
1434
|
+
};
|
|
1435
|
+
case "toolResult": return {
|
|
1436
|
+
role: message.role,
|
|
1437
|
+
content: message.content,
|
|
1438
|
+
isError: message.isError,
|
|
1439
|
+
toolCallId: message.toolCallId,
|
|
1440
|
+
toolName: message.toolName
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function isCompleteToolGroup(messages, order) {
|
|
1445
|
+
const [assistant, ...results] = messages;
|
|
1446
|
+
return assistant?.role === "assistant" && JSON.stringify(readAssistantToolCallIds(assistant)) === JSON.stringify(order) && results.length === order.length && results.every((message, index) => message.role === "toolResult" && message.toolCallId === order[index]);
|
|
1447
|
+
}
|
|
1448
|
+
//#endregion
|
|
1400
1449
|
//#region extensions/copilot/src/attempt-finalize.ts
|
|
1401
1450
|
async function completeCopilotAttempt(params) {
|
|
1402
1451
|
const { acceptedSessionSpawns, aborted, attemptStartedAt, bridge, codeModeEngaged, downgradedFromResume, externalAbort, hookContext, hookContextWindowFields, input, lastToolError, messages, nativeSessionHistoryUnvalidated, transcriptJournal, modelRef, now, promptError, releaseError, resumeFailureRecovered, sdkSessionId, sentTurnStarted, settledFinalizationAssistantCompleted, settledToolFinalization, timedOut, timedOutDuringCompaction, yieldDetected, yieldAcknowledgment } = params;
|
|
@@ -1489,15 +1538,7 @@ function isSamePreparedUser(candidate, prepared, currentRunUserKey) {
|
|
|
1489
1538
|
if (typeof candidateKey === "string" && typeof preparedKey === "string") return candidateKey === preparedKey;
|
|
1490
1539
|
if (typeof candidateKey !== "string" || typeof preparedKey === "string" || !candidateKey.startsWith("copilot:") && candidateKey !== currentRunUserKey) return false;
|
|
1491
1540
|
}
|
|
1492
|
-
return candidate.timestamp === prepared.timestamp && userText
|
|
1493
|
-
}
|
|
1494
|
-
function userText$1(content) {
|
|
1495
|
-
if (typeof content === "string") return content;
|
|
1496
|
-
if (Array.isArray(content) && content.length === 1) {
|
|
1497
|
-
const part = content[0];
|
|
1498
|
-
if (part?.type === "text" && typeof part.text === "string") return part.text;
|
|
1499
|
-
}
|
|
1500
|
-
return JSON.stringify(content) ?? "";
|
|
1541
|
+
return candidate.timestamp === prepared.timestamp && userText(candidate.content) === userText(prepared.content);
|
|
1501
1542
|
}
|
|
1502
1543
|
//#endregion
|
|
1503
1544
|
//#region extensions/copilot/src/attempt-mode.ts
|
|
@@ -1542,7 +1583,6 @@ async function createCopilotToolBridge(input) {
|
|
|
1542
1583
|
promptToolPolicy: EMPTY_PROMPT_TOOL_POLICY,
|
|
1543
1584
|
sourceTools: []
|
|
1544
1585
|
};
|
|
1545
|
-
const createOpenClawCodingTools = input.createOpenClawCodingTools ?? (await import("openclaw/plugin-sdk/agent-harness")).createOpenClawCodingTools;
|
|
1546
1586
|
const toolSurfaceRuntime = createAgentHarnessToolSurfaceRuntime({
|
|
1547
1587
|
abortSignal: input.abortSignal,
|
|
1548
1588
|
agentId: attemptParams.sandboxAgentId ?? input.agentId,
|
|
@@ -1577,9 +1617,16 @@ async function createCopilotToolBridge(input) {
|
|
|
1577
1617
|
const bindingCwd = toolOptions.cwd ?? toolOptions.workspaceDir;
|
|
1578
1618
|
const bindingOptions = bindingCwd ? { cwd: bindingCwd } : void 0;
|
|
1579
1619
|
try {
|
|
1580
|
-
|
|
1581
|
-
if (
|
|
1582
|
-
|
|
1620
|
+
let boundTools;
|
|
1621
|
+
if (input.createOpenClawCodingTools) {
|
|
1622
|
+
const constructedTools = await input.createOpenClawCodingTools(toolOptions);
|
|
1623
|
+
if (!Array.isArray(constructedTools)) throw new Error("createOpenClawCodingTools must return an array of tools");
|
|
1624
|
+
boundTools = hostCapabilities.bindToolSurface(constructedTools, bindingOptions);
|
|
1625
|
+
} else {
|
|
1626
|
+
const createToolSurface = hostCapabilities.createToolSurface;
|
|
1627
|
+
if (!createToolSurface) throw new Error("Copilot tool construction requires a current host capability");
|
|
1628
|
+
boundTools = createToolSurface(toolOptions, bindingOptions);
|
|
1629
|
+
}
|
|
1583
1630
|
sourceTools = boundTools;
|
|
1584
1631
|
for (const tool of boundTools) boundSourceTools.add(tool);
|
|
1585
1632
|
} catch (error) {
|
|
@@ -1673,6 +1720,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1673
1720
|
sandbox,
|
|
1674
1721
|
spawnWorkspaceDir: input.spawnWorkspaceDir,
|
|
1675
1722
|
config: toolSurfaceRuntime?.config ?? a.config,
|
|
1723
|
+
skillsSnapshot: a.skillsSnapshot,
|
|
1676
1724
|
abortSignal: input.abortSignal,
|
|
1677
1725
|
modelProvider: input.modelProvider,
|
|
1678
1726
|
modelId: input.modelId,
|
|
@@ -2421,41 +2469,6 @@ async function createCopilotSessionSetup(params) {
|
|
|
2421
2469
|
};
|
|
2422
2470
|
}
|
|
2423
2471
|
//#endregion
|
|
2424
|
-
//#region extensions/copilot/src/attempt-transcript-replay.ts
|
|
2425
|
-
function readAssistantToolCallIds(message) {
|
|
2426
|
-
return message.role === "assistant" ? message.content.flatMap((part) => part.type === "toolCall" ? [part.id] : []) : [];
|
|
2427
|
-
}
|
|
2428
|
-
function isCompatibleSingletonRewrite(original, prepared) {
|
|
2429
|
-
return original.role === prepared.role && (original.role !== "assistant" || JSON.stringify(readAssistantToolCallIds(original)) === JSON.stringify(readAssistantToolCallIds(prepared)));
|
|
2430
|
-
}
|
|
2431
|
-
function projectReplayPayload(message) {
|
|
2432
|
-
switch (message.role) {
|
|
2433
|
-
case "user": return {
|
|
2434
|
-
role: message.role,
|
|
2435
|
-
content: message.content
|
|
2436
|
-
};
|
|
2437
|
-
case "assistant": return {
|
|
2438
|
-
role: message.role,
|
|
2439
|
-
content: message.content,
|
|
2440
|
-
api: message.api,
|
|
2441
|
-
model: message.model,
|
|
2442
|
-
provider: message.provider,
|
|
2443
|
-
stopReason: message.stopReason
|
|
2444
|
-
};
|
|
2445
|
-
case "toolResult": return {
|
|
2446
|
-
role: message.role,
|
|
2447
|
-
content: message.content,
|
|
2448
|
-
isError: message.isError,
|
|
2449
|
-
toolCallId: message.toolCallId,
|
|
2450
|
-
toolName: message.toolName
|
|
2451
|
-
};
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
function isCompleteToolGroup(messages, order) {
|
|
2455
|
-
const [assistant, ...results] = messages;
|
|
2456
|
-
return assistant?.role === "assistant" && JSON.stringify(readAssistantToolCallIds(assistant)) === JSON.stringify(order) && results.length === order.length && results.every((message, index) => message.role === "toolResult" && message.toolCallId === order[index]);
|
|
2457
|
-
}
|
|
2458
|
-
//#endregion
|
|
2459
2472
|
//#region extensions/copilot/src/attempt-transcript-journal.ts
|
|
2460
2473
|
function readTurnTaintMetadata(message) {
|
|
2461
2474
|
const metadata = message["__openclaw"];
|
|
@@ -2886,14 +2899,6 @@ function isSameUserTurn(candidate, current, currentRunUserKey) {
|
|
|
2886
2899
|
}
|
|
2887
2900
|
return candidate.timestamp === current.timestamp && userText(candidate.content) === userText(current.content);
|
|
2888
2901
|
}
|
|
2889
|
-
function userText(content) {
|
|
2890
|
-
if (typeof content === "string") return content;
|
|
2891
|
-
if (Array.isArray(content) && content.length === 1) {
|
|
2892
|
-
const part = content[0];
|
|
2893
|
-
if (part?.type === "text" && typeof part.text === "string") return part.text;
|
|
2894
|
-
}
|
|
2895
|
-
return JSON.stringify(content) ?? "";
|
|
2896
|
-
}
|
|
2897
2902
|
//#endregion
|
|
2898
2903
|
//#region extensions/copilot/src/native-subagent-task-mirror.ts
|
|
2899
2904
|
const COPILOT_NATIVE_SUBAGENT_TASK_KIND = "copilot-native";
|
|
@@ -2916,8 +2921,7 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
2916
2921
|
this.runtime = runtime;
|
|
2917
2922
|
this.runIdByAgentId = /* @__PURE__ */ new Map();
|
|
2918
2923
|
this.runIdByToolCallId = /* @__PURE__ */ new Map();
|
|
2919
|
-
this.
|
|
2920
|
-
this.activeRunIds = /* @__PURE__ */ new Set();
|
|
2924
|
+
this.activeRuns = /* @__PURE__ */ new Map();
|
|
2921
2925
|
this.now = params.now ?? Date.now;
|
|
2922
2926
|
}
|
|
2923
2927
|
handleEvent(event) {
|
|
@@ -2936,9 +2940,9 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
2936
2940
|
}
|
|
2937
2941
|
finalizeActiveRuns() {
|
|
2938
2942
|
const eventAt = this.now();
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
this.
|
|
2943
|
+
let failure;
|
|
2944
|
+
for (const runId of this.activeRuns.keys()) try {
|
|
2945
|
+
this.finalizeRun({
|
|
2942
2946
|
runId,
|
|
2943
2947
|
status: "cancelled",
|
|
2944
2948
|
endedAt: eventAt,
|
|
@@ -2947,8 +2951,10 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
2947
2951
|
progressSummary: "Subagent cancelled with its parent attempt.",
|
|
2948
2952
|
terminalSummary: "Subagent cancelled."
|
|
2949
2953
|
});
|
|
2954
|
+
} catch (error) {
|
|
2955
|
+
failure ??= { error };
|
|
2950
2956
|
}
|
|
2951
|
-
|
|
2957
|
+
if (failure) throw failure.error;
|
|
2952
2958
|
}
|
|
2953
2959
|
handleStarted(event, runId, toolCallId) {
|
|
2954
2960
|
const agentId = event.agentId?.trim();
|
|
@@ -2956,7 +2962,7 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
2956
2962
|
const eventAt = this.now();
|
|
2957
2963
|
const label = event.data.agentDisplayName.trim() || event.data.agentName.trim();
|
|
2958
2964
|
const task = event.data.agentDescription.trim() || `Subagent ${label}`;
|
|
2959
|
-
|
|
2965
|
+
const taskRecord = this.runtime.tryCreateRunningTaskRun({
|
|
2960
2966
|
sourceId: toolCallId,
|
|
2961
2967
|
agentId: this.params.agentId,
|
|
2962
2968
|
runId,
|
|
@@ -2968,18 +2974,15 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
2968
2974
|
startedAt: eventAt,
|
|
2969
2975
|
lastEventAt: eventAt,
|
|
2970
2976
|
progressSummary: "Subagent started."
|
|
2971
|
-
})
|
|
2977
|
+
});
|
|
2978
|
+
if (!taskRecord) return;
|
|
2972
2979
|
if (agentId) this.runIdByAgentId.set(agentId, runId);
|
|
2973
2980
|
else this.runIdByToolCallId.set(toolCallId, runId);
|
|
2974
|
-
this.
|
|
2975
|
-
this.activeRunIds.add(runId);
|
|
2981
|
+
this.activeRuns.set(runId, { taskId: taskRecord.taskId });
|
|
2976
2982
|
}
|
|
2977
2983
|
handleCompleted(event, runId) {
|
|
2978
|
-
if (this.terminalRunIds.has(runId)) return;
|
|
2979
2984
|
const eventAt = this.now();
|
|
2980
|
-
this.
|
|
2981
|
-
this.activeRunIds.delete(runId);
|
|
2982
|
-
this.runtime.finalizeTaskRunByRunId({
|
|
2985
|
+
this.finalizeRun({
|
|
2983
2986
|
runId,
|
|
2984
2987
|
status: "succeeded",
|
|
2985
2988
|
endedAt: eventAt,
|
|
@@ -2989,11 +2992,8 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
2989
2992
|
});
|
|
2990
2993
|
}
|
|
2991
2994
|
handleFailed(event, runId) {
|
|
2992
|
-
if (this.terminalRunIds.has(runId)) return;
|
|
2993
2995
|
const eventAt = this.now();
|
|
2994
|
-
this.
|
|
2995
|
-
this.activeRunIds.delete(runId);
|
|
2996
|
-
this.runtime.finalizeTaskRunByRunId({
|
|
2996
|
+
this.finalizeRun({
|
|
2997
2997
|
runId,
|
|
2998
2998
|
status: "failed",
|
|
2999
2999
|
endedAt: eventAt,
|
|
@@ -3003,6 +3003,20 @@ var CopilotNativeSubagentTaskMirror = class {
|
|
|
3003
3003
|
terminalSummary: "Subagent failed."
|
|
3004
3004
|
});
|
|
3005
3005
|
}
|
|
3006
|
+
finalizeRun(params) {
|
|
3007
|
+
const run = this.activeRuns.get(params.runId);
|
|
3008
|
+
if (!run) return;
|
|
3009
|
+
run.terminal ??= params;
|
|
3010
|
+
const matchesRun = (task) => task.taskId === run.taskId && task.runId === params.runId;
|
|
3011
|
+
const before = this.runtime.listTaskRecords().find(matchesRun);
|
|
3012
|
+
if (!before || before.status !== "queued" && before.status !== "running") {
|
|
3013
|
+
this.activeRuns.delete(params.runId);
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3016
|
+
const current = this.runtime.finalizeTaskRunByRunId(run.terminal).find(matchesRun) ?? this.runtime.listTaskRecords().find(matchesRun);
|
|
3017
|
+
if (current?.status === "queued" || current?.status === "running") throw new Error(`Native subagent task finalization did not persist: ${params.runId}`);
|
|
3018
|
+
this.activeRuns.delete(params.runId);
|
|
3019
|
+
}
|
|
3006
3020
|
resolveRunId(event) {
|
|
3007
3021
|
const agentId = event.agentId?.trim();
|
|
3008
3022
|
if (agentId) {
|
|
@@ -3262,7 +3276,7 @@ async function runCopilotExecution(context) {
|
|
|
3262
3276
|
sdkSessionId = readNonEmptyString(session.sessionId) ?? readNonEmptyString(session.id) ?? (resumeFailureRecovered ? void 0 : resumeSessionId);
|
|
3263
3277
|
if (!sdkSessionId) throw createPromptError$1("transcript_persistence_failed", "[copilot-attempt] canonical transcript persistence requires the Copilot SDK session id");
|
|
3264
3278
|
if (sdkSessionId && deps.onSessionEstablished && !settledToolFinalization) try {
|
|
3265
|
-
deps.onSessionEstablished({
|
|
3279
|
+
await deps.onSessionEstablished({
|
|
3266
3280
|
compactionSessionConfig,
|
|
3267
3281
|
sdkSessionId,
|
|
3268
3282
|
pooledClient: handle,
|
|
@@ -3422,7 +3436,7 @@ async function runCopilotExecution(context) {
|
|
|
3422
3436
|
params.abortSignal?.removeEventListener("abort", abortCleanup);
|
|
3423
3437
|
}).catch(() => void 0);
|
|
3424
3438
|
if (sdkSessionId && !settledToolFinalization) try {
|
|
3425
|
-
deps.onDeferredCompaction?.({
|
|
3439
|
+
await deps.onDeferredCompaction?.({
|
|
3426
3440
|
abort: () => cleanupAbort.abort(),
|
|
3427
3441
|
cleanup,
|
|
3428
3442
|
sdkSessionId
|
|
@@ -3432,7 +3446,11 @@ async function runCopilotExecution(context) {
|
|
|
3432
3446
|
} else {
|
|
3433
3447
|
await bridge?.awaitCompactionChain();
|
|
3434
3448
|
await bridge?.awaitAgentEventChain();
|
|
3435
|
-
|
|
3449
|
+
try {
|
|
3450
|
+
nativeSubagentTaskMirror?.finalizeActiveRuns();
|
|
3451
|
+
} catch (error) {
|
|
3452
|
+
promptError ??= toCopilotError(error);
|
|
3453
|
+
}
|
|
3436
3454
|
cleanupToolBridge?.();
|
|
3437
3455
|
await cleanupByokProxy?.();
|
|
3438
3456
|
bridge?.detach();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { filterStringRecord, normalizeOptionalString, readNonEmptyStringPreservingWhitespace } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
2
|
import { buildAgentHookContextChannelFields, compactWithSafetyTimeout, getModelProviderRequestTransport, projectSettledTurnFinalizationAttemptResult, resolveCompactionTimeoutMs, runAgentHarnessAfterCompactionHook, runAgentHarnessBeforeCompactionHook } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
3
|
+
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
3
4
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
4
5
|
import { homedir } from "node:os";
|
|
5
6
|
import { join, resolve } from "node:path";
|
|
@@ -646,30 +647,30 @@ function normalizeAttemptBinding(value) {
|
|
|
646
647
|
compatKey: legacy.compatKey
|
|
647
648
|
};
|
|
648
649
|
}
|
|
649
|
-
function lookupStoredBinding(store, key) {
|
|
650
|
+
async function lookupStoredBinding(store, key) {
|
|
650
651
|
try {
|
|
651
|
-
return normalizeAttemptBinding(store?.lookup(key));
|
|
652
|
+
return normalizeAttemptBinding(await store?.lookup(key));
|
|
652
653
|
} catch {
|
|
653
654
|
try {
|
|
654
|
-
store?.delete(key);
|
|
655
|
+
await store?.delete(key);
|
|
655
656
|
} catch {}
|
|
656
657
|
return;
|
|
657
658
|
}
|
|
658
659
|
}
|
|
659
|
-
function registerStoredBinding(store, key, binding) {
|
|
660
|
+
async function registerStoredBinding(store, key, binding) {
|
|
660
661
|
try {
|
|
661
|
-
store?.register(key, binding);
|
|
662
|
+
await store?.register(key, binding);
|
|
662
663
|
return true;
|
|
663
664
|
} catch {
|
|
664
665
|
try {
|
|
665
|
-
store?.delete(key);
|
|
666
|
+
await store?.delete(key);
|
|
666
667
|
} catch {}
|
|
667
668
|
return false;
|
|
668
669
|
}
|
|
669
670
|
}
|
|
670
|
-
function deleteStoredBinding(store, key) {
|
|
671
|
+
async function deleteStoredBinding(store, key) {
|
|
671
672
|
try {
|
|
672
|
-
store?.delete(key);
|
|
673
|
+
await store?.delete(key);
|
|
673
674
|
return true;
|
|
674
675
|
} catch {
|
|
675
676
|
return false;
|
|
@@ -845,13 +846,23 @@ function createCopilotAgentHarness(options) {
|
|
|
845
846
|
let disposed = false;
|
|
846
847
|
let disposePromise;
|
|
847
848
|
const inFlight = /* @__PURE__ */ new Set();
|
|
849
|
+
const bindingQueue = new KeyedAsyncQueue();
|
|
848
850
|
const deferredCompactionCleanups = /* @__PURE__ */ new Map();
|
|
849
851
|
const trackedSessions = /* @__PURE__ */ new Map();
|
|
850
852
|
const resetBlockedStoredSessions = /* @__PURE__ */ new Set();
|
|
853
|
+
async function trackOperation(operation) {
|
|
854
|
+
const pending = operation();
|
|
855
|
+
inFlight.add(pending);
|
|
856
|
+
try {
|
|
857
|
+
return await pending;
|
|
858
|
+
} finally {
|
|
859
|
+
inFlight.delete(pending);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
851
862
|
async function getPool() {
|
|
852
863
|
if (options?.pool) return options.pool;
|
|
853
864
|
if (!poolPromise) poolPromise = (async () => {
|
|
854
|
-
const { createCopilotClientPool } = await import("./runtime-
|
|
865
|
+
const { createCopilotClientPool } = await import("./runtime-D6DFeSZX.mjs");
|
|
855
866
|
createdPool = createCopilotClientPool(options?.poolOptions);
|
|
856
867
|
return createdPool;
|
|
857
868
|
})();
|
|
@@ -872,10 +883,10 @@ function createCopilotAgentHarness(options) {
|
|
|
872
883
|
cleanups.delete(cleanup);
|
|
873
884
|
if (cleanups.size === 0) deferredCompactionCleanups.delete(sessionId);
|
|
874
885
|
}
|
|
875
|
-
function hasPendingDeferredCompactionCleanup(sessionId) {
|
|
886
|
+
async function hasPendingDeferredCompactionCleanup(sessionId) {
|
|
876
887
|
const cleanups = deferredCompactionCleanups.get(sessionId);
|
|
877
888
|
if (!cleanups) return false;
|
|
878
|
-
const currentSdkSessionId = trackedSessions.get(sessionId)?.sdkSessionId ?? lookupStoredBinding(options?.sessionStore, sessionId)?.sdkSessionId;
|
|
889
|
+
const currentSdkSessionId = trackedSessions.get(sessionId)?.sdkSessionId ?? (await lookupStoredBinding(options?.sessionStore, sessionId))?.sdkSessionId;
|
|
879
890
|
return currentSdkSessionId !== void 0 && [...cleanups.values()].some((cleanup) => cleanup.sdkSessionId === currentSdkSessionId);
|
|
880
891
|
}
|
|
881
892
|
async function abortDeferredCompactionCleanups(sessionId) {
|
|
@@ -888,7 +899,7 @@ function createCopilotAgentHarness(options) {
|
|
|
888
899
|
async function runHarnessAttempt(params, operation) {
|
|
889
900
|
const attemptPromise = (async () => {
|
|
890
901
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
|
|
891
|
-
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-
|
|
902
|
+
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-BZXPuTyZ.mjs");
|
|
892
903
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
893
904
|
const pool = await getPool();
|
|
894
905
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
@@ -902,11 +913,14 @@ function createCopilotAgentHarness(options) {
|
|
|
902
913
|
const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
|
|
903
914
|
const currentCompatKey = computeSessionCompatKey(params);
|
|
904
915
|
const currentCompactKey = computeAttemptCompactKey(params);
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
916
|
+
const resumableBinding = openclawSessionId ? await bindingQueue.enqueue(openclawSessionId, async () => {
|
|
917
|
+
if (await hasPendingDeferredCompactionCleanup(openclawSessionId) || resetBlockedStoredSessions.has(openclawSessionId)) return;
|
|
918
|
+
const tracked = trackedSessions.get(openclawSessionId);
|
|
919
|
+
const stored = tracked ? void 0 : await lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
920
|
+
const binding = tracked ?? stored;
|
|
921
|
+
return binding?.compatKey === currentCompatKey ? binding : void 0;
|
|
922
|
+
}) : void 0;
|
|
923
|
+
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
910
924
|
const resumableSessionId = resumableBinding?.sdkSessionId;
|
|
911
925
|
if (operation === "settled-tool-finalization" && !resumableSessionId) throw new Error("[copilot] cannot safely finalize a settled tool turn without its compatible SDK session");
|
|
912
926
|
const result = await runCopilotAttempt(resumableSessionId ? {
|
|
@@ -936,8 +950,8 @@ function createCopilotAgentHarness(options) {
|
|
|
936
950
|
} : params, {
|
|
937
951
|
pool,
|
|
938
952
|
...operation === "settled-tool-finalization" ? { operation } : {},
|
|
939
|
-
onSessionEstablished: operation === "attempt" && openclawSessionId ? ({ compactionSessionConfig, sdkSessionId, pooledClient, sessionConfig }) => {
|
|
940
|
-
|
|
953
|
+
onSessionEstablished: operation === "attempt" && openclawSessionId ? ({ compactionSessionConfig, sdkSessionId, pooledClient, sessionConfig }) => bindingQueue.enqueue(openclawSessionId, async () => {
|
|
954
|
+
const tracked = {
|
|
941
955
|
sdkSessionId,
|
|
942
956
|
client: pooledClient.client,
|
|
943
957
|
clientOptions: poolAcquire.options,
|
|
@@ -946,8 +960,8 @@ function createCopilotAgentHarness(options) {
|
|
|
946
960
|
poolKey: pooledClient.key,
|
|
947
961
|
sessionConfig: compactionSessionConfig ?? sessionConfig,
|
|
948
962
|
...sessionAuthFields(poolAcquire.auth)
|
|
949
|
-
}
|
|
950
|
-
registerStoredBinding(options?.sessionStore, openclawSessionId, {
|
|
963
|
+
};
|
|
964
|
+
await registerStoredBinding(options?.sessionStore, openclawSessionId, {
|
|
951
965
|
schemaVersion: 2,
|
|
952
966
|
sdkSessionId,
|
|
953
967
|
compatKey: currentCompatKey,
|
|
@@ -955,57 +969,60 @@ function createCopilotAgentHarness(options) {
|
|
|
955
969
|
...sessionAuthFields(poolAcquire.auth),
|
|
956
970
|
updatedAt: Date.now()
|
|
957
971
|
});
|
|
972
|
+
trackedSessions.set(openclawSessionId, tracked);
|
|
958
973
|
resetBlockedStoredSessions.delete(openclawSessionId);
|
|
959
|
-
} : void 0,
|
|
960
|
-
onDeferredCompaction: openclawSessionId ? ({ abort, cleanup, sdkSessionId }) => {
|
|
974
|
+
}) : void 0,
|
|
975
|
+
onDeferredCompaction: openclawSessionId ? ({ abort, cleanup, sdkSessionId }) => bindingQueue.enqueue(openclawSessionId, async () => {
|
|
961
976
|
const trackedBinding = trackedSessions.get(openclawSessionId);
|
|
962
|
-
const storedBinding = lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
977
|
+
const storedBinding = await lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
963
978
|
const ownsTrackedSession = trackedBinding?.sdkSessionId === sdkSessionId;
|
|
964
979
|
const ownsStoredSession = storedBinding?.sdkSessionId === sdkSessionId;
|
|
965
980
|
if (!ownsTrackedSession && !ownsStoredSession) return;
|
|
981
|
+
resetBlockedStoredSessions.add(openclawSessionId);
|
|
966
982
|
trackDeferredCompactionCleanup({
|
|
967
983
|
abort,
|
|
968
|
-
cleanup,
|
|
984
|
+
cleanup: cleanup.then((outcome) => bindingQueue.enqueue(openclawSessionId, async () => {
|
|
985
|
+
const currentTracked = trackedSessions.get(openclawSessionId);
|
|
986
|
+
const currentStored = await lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
987
|
+
const stillOwnsTrackedSession = currentTracked?.sdkSessionId === sdkSessionId;
|
|
988
|
+
const stillOwnsStoredSession = currentStored?.sdkSessionId === sdkSessionId;
|
|
989
|
+
if (outcome === "completed") {
|
|
990
|
+
if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.delete(openclawSessionId);
|
|
991
|
+
return outcome;
|
|
992
|
+
}
|
|
993
|
+
if (stillOwnsTrackedSession) trackedSessions.delete(openclawSessionId);
|
|
994
|
+
if (stillOwnsStoredSession) await deleteStoredBinding(options?.sessionStore, openclawSessionId);
|
|
995
|
+
if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.add(openclawSessionId);
|
|
996
|
+
return outcome;
|
|
997
|
+
})),
|
|
969
998
|
sessionId: openclawSessionId,
|
|
970
999
|
sdkSessionId
|
|
971
1000
|
});
|
|
972
|
-
|
|
973
|
-
cleanup.then((outcome) => {
|
|
974
|
-
const currentTracked = trackedSessions.get(openclawSessionId);
|
|
975
|
-
const currentStored = lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
976
|
-
const stillOwnsTrackedSession = currentTracked?.sdkSessionId === sdkSessionId;
|
|
977
|
-
const stillOwnsStoredSession = currentStored?.sdkSessionId === sdkSessionId;
|
|
978
|
-
if (outcome === "completed") {
|
|
979
|
-
if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.delete(openclawSessionId);
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
if (stillOwnsTrackedSession) trackedSessions.delete(openclawSessionId);
|
|
983
|
-
if (stillOwnsStoredSession) deleteStoredBinding(options?.sessionStore, openclawSessionId);
|
|
984
|
-
if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.add(openclawSessionId);
|
|
985
|
-
});
|
|
986
|
-
} : void 0
|
|
1001
|
+
}) : void 0
|
|
987
1002
|
});
|
|
988
1003
|
if (operation === "attempt" && openclawSessionId) {
|
|
989
1004
|
const attemptResult = result;
|
|
990
1005
|
const sdkSessionId = attemptResult.sdkSessionId;
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1006
|
+
await bindingQueue.enqueue(openclawSessionId, async () => {
|
|
1007
|
+
const trackedSession = trackedSessions.get(openclawSessionId);
|
|
1008
|
+
if (sdkSessionId && trackedSession?.sdkSessionId === sdkSessionId) {
|
|
1009
|
+
const { journalVersion: _journalVersion, ...baseTracked } = trackedSession;
|
|
1010
|
+
const nextTracked = {
|
|
1011
|
+
...baseTracked,
|
|
1012
|
+
...attemptResult.journalValidated ? { journalVersion: 1 } : {}
|
|
1013
|
+
};
|
|
1014
|
+
await registerStoredBinding(options?.sessionStore, openclawSessionId, {
|
|
1015
|
+
schemaVersion: 2,
|
|
1016
|
+
...attemptResult.journalValidated ? { journalVersion: 1 } : {},
|
|
1017
|
+
sdkSessionId,
|
|
1018
|
+
compatKey: nextTracked.compatKey,
|
|
1019
|
+
compactKey: nextTracked.compactKey,
|
|
1020
|
+
...sessionAuthFields(nextTracked),
|
|
1021
|
+
updatedAt: Date.now()
|
|
1022
|
+
});
|
|
1023
|
+
trackedSessions.set(openclawSessionId, nextTracked);
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1009
1026
|
}
|
|
1010
1027
|
return result;
|
|
1011
1028
|
})();
|
|
@@ -1019,7 +1036,7 @@ function createCopilotAgentHarness(options) {
|
|
|
1019
1036
|
async function runIsolatedCompletionV2(params) {
|
|
1020
1037
|
const completionPromise = (async () => {
|
|
1021
1038
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start isolated completion");
|
|
1022
|
-
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-
|
|
1039
|
+
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-54FP0qmC.mjs");
|
|
1023
1040
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
1024
1041
|
return await runCopilotIsolatedCompletion(params, async () => {
|
|
1025
1042
|
const pool = await getPool();
|
|
@@ -1079,31 +1096,40 @@ function createCopilotAgentHarness(options) {
|
|
|
1079
1096
|
const result = await runHarnessAttempt(attempt, "settled-tool-finalization");
|
|
1080
1097
|
return projectSettledTurnFinalizationAttemptResult(result);
|
|
1081
1098
|
},
|
|
1082
|
-
|
|
1099
|
+
reset: (params) => trackOperation(async () => {
|
|
1100
|
+
if (disposed) return;
|
|
1083
1101
|
const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
|
|
1084
1102
|
if (!openclawSessionId) return;
|
|
1085
|
-
const tracked =
|
|
1086
|
-
|
|
1087
|
-
|
|
1103
|
+
const { tracked, stored } = await bindingQueue.enqueue(openclawSessionId, async () => {
|
|
1104
|
+
const binding = await lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
1105
|
+
resetBlockedStoredSessions.add(openclawSessionId);
|
|
1106
|
+
return {
|
|
1107
|
+
tracked: trackedSessions.get(openclawSessionId),
|
|
1108
|
+
stored: binding
|
|
1109
|
+
};
|
|
1110
|
+
});
|
|
1088
1111
|
await abortDeferredCompactionCleanups(openclawSessionId);
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
if (
|
|
1092
|
-
|
|
1112
|
+
await bindingQueue.enqueue(openclawSessionId, async () => {
|
|
1113
|
+
const currentStored = await lookupStoredBinding(options?.sessionStore, openclawSessionId);
|
|
1114
|
+
if (stored !== void 0 && currentStored?.sdkSessionId === stored.sdkSessionId) {
|
|
1115
|
+
if (await deleteStoredBinding(options?.sessionStore, openclawSessionId)) resetBlockedStoredSessions.delete(openclawSessionId);
|
|
1116
|
+
} else resetBlockedStoredSessions.delete(openclawSessionId);
|
|
1117
|
+
if (tracked && trackedSessions.get(openclawSessionId)?.sdkSessionId === tracked.sdkSessionId) trackedSessions.delete(openclawSessionId);
|
|
1118
|
+
});
|
|
1093
1119
|
if (!tracked) return;
|
|
1094
|
-
if (trackedSessions.get(openclawSessionId)?.sdkSessionId === tracked.sdkSessionId) trackedSessions.delete(openclawSessionId);
|
|
1095
1120
|
try {
|
|
1096
1121
|
await tracked.client.deleteSession(tracked.sdkSessionId);
|
|
1097
1122
|
} catch {}
|
|
1098
|
-
},
|
|
1099
|
-
|
|
1123
|
+
}),
|
|
1124
|
+
compact: (params) => trackOperation(async () => {
|
|
1125
|
+
if (disposed) return;
|
|
1100
1126
|
const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
|
|
1101
1127
|
if (!openclawSessionId) return {
|
|
1102
1128
|
ok: false,
|
|
1103
1129
|
compacted: false,
|
|
1104
1130
|
reason: "missing-required-params"
|
|
1105
1131
|
};
|
|
1106
|
-
if (hasPendingDeferredCompactionCleanup(openclawSessionId)) return {
|
|
1132
|
+
if (await bindingQueue.enqueue(openclawSessionId, () => hasPendingDeferredCompactionCleanup(openclawSessionId))) return {
|
|
1107
1133
|
ok: false,
|
|
1108
1134
|
compacted: false,
|
|
1109
1135
|
reason: "background-compaction-pending",
|
|
@@ -1111,7 +1137,7 @@ function createCopilotAgentHarness(options) {
|
|
|
1111
1137
|
};
|
|
1112
1138
|
const tracked = trackedSessions.get(openclawSessionId);
|
|
1113
1139
|
const currentCompactKey = computeCompactRequestKey(params);
|
|
1114
|
-
const { resolvePoolAcquire } = await import("./attempt-
|
|
1140
|
+
const { resolvePoolAcquire } = await import("./attempt-BZXPuTyZ.mjs");
|
|
1115
1141
|
let resolvedPoolAcquire;
|
|
1116
1142
|
let currentAuth;
|
|
1117
1143
|
try {
|
|
@@ -1178,8 +1204,12 @@ function createCopilotAgentHarness(options) {
|
|
|
1178
1204
|
} catch (err) {
|
|
1179
1205
|
const rawError = err instanceof Error ? err.message : String(err);
|
|
1180
1206
|
if (isStaleSdkSessionError(err)) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1207
|
+
await bindingQueue.enqueue(openclawSessionId, async () => {
|
|
1208
|
+
if (trackedSessions.get(openclawSessionId)?.sdkSessionId === compatibleTracked.sdkSessionId) {
|
|
1209
|
+
await deleteStoredBinding(options?.sessionStore, openclawSessionId);
|
|
1210
|
+
trackedSessions.delete(openclawSessionId);
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1183
1213
|
return {
|
|
1184
1214
|
ok: false,
|
|
1185
1215
|
compacted: false,
|
|
@@ -1231,7 +1261,7 @@ function createCopilotAgentHarness(options) {
|
|
|
1231
1261
|
sessionFile: params.sessionFile
|
|
1232
1262
|
} } : {}
|
|
1233
1263
|
};
|
|
1234
|
-
},
|
|
1264
|
+
}),
|
|
1235
1265
|
async dispose() {
|
|
1236
1266
|
if (disposePromise) return disposePromise;
|
|
1237
1267
|
disposed = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as resolveCopilotProvider, o as tokenFingerprint, r as createCopilotByokProxy } from "./harness-
|
|
2
|
-
import { r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.
|
|
1
|
+
import { n as resolveCopilotProvider, o as tokenFingerprint, r as createCopilotByokProxy } from "./harness-Dj0L75Tk.mjs";
|
|
2
|
+
import { r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.mjs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
//#region extensions/copilot/src/isolated-completion.ts
|
|
5
5
|
function startBestEffortCleanup(cleanup) {
|
|
@@ -5,7 +5,7 @@ import { existsSync } from "node:fs";
|
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
7
7
|
//#region extensions/copilot/package.json
|
|
8
|
-
var dependencies = { "@github/copilot-sdk": "1.0.
|
|
8
|
+
var dependencies = { "@github/copilot-sdk": "1.0.13" };
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region extensions/copilot/src/sdk-loader.ts
|
|
11
11
|
function resolveCopilotSdkFallbackDir(env = process.env) {
|
|
@@ -52,7 +52,7 @@ function createMissingSdkError(primaryErr, fallbackErr, fallbackPath) {
|
|
|
52
52
|
"[copilot] @github/copilot-sdk is not installed.",
|
|
53
53
|
"",
|
|
54
54
|
"The external @openclaw/copilot plugin depends on @github/copilot-sdk",
|
|
55
|
-
"
|
|
55
|
+
"including its platform-specific Copilot runtime package.",
|
|
56
56
|
"Reinstall the plugin once with:",
|
|
57
57
|
"",
|
|
58
58
|
" openclaw plugins install @openclaw/copilot",
|
package/dist/harness.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./.setup/harness-Dj0L75Tk.mjs";
|
|
2
2
|
export { createCopilotAgentHarness };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./.setup/harness-Dj0L75Tk.mjs";
|
|
2
2
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
3
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
//#region extensions/copilot/index.ts
|
|
@@ -18,7 +18,7 @@ var copilot_default = definePluginEntry({
|
|
|
18
18
|
if (api.registrationMode !== "full" && api.registrationMode !== "discovery" && api.registrationMode !== "tool-discovery") return;
|
|
19
19
|
const poolOptions = readPoolOptions(api.pluginConfig);
|
|
20
20
|
let sessionStore;
|
|
21
|
-
const getSessionStore = () => sessionStore ??= api.runtime.state.
|
|
21
|
+
const getSessionStore = () => sessionStore ??= api.runtime.state.openKeyedStore({
|
|
22
22
|
namespace: "sdk-sessions",
|
|
23
23
|
maxEntries: 5e3,
|
|
24
24
|
defaultTtlMs: 7776e6
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "copilot",
|
|
3
|
-
"categories": ["
|
|
3
|
+
"categories": ["agent-runtimes"],
|
|
4
4
|
"doctorContract": {
|
|
5
5
|
"configRepair": true
|
|
6
6
|
},
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
"onStartup": false,
|
|
22
22
|
"onAgentHarnesses": ["copilot"]
|
|
23
23
|
},
|
|
24
|
+
"configGroups": [
|
|
25
|
+
{
|
|
26
|
+
"id": "client-pool",
|
|
27
|
+
"title": "Client pool",
|
|
28
|
+
"order": 10,
|
|
29
|
+
"properties": ["pool"]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
24
32
|
"configSchema": {
|
|
25
33
|
"type": "object",
|
|
26
34
|
"additionalProperties": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/copilot",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.5",
|
|
4
4
|
"description": "OpenClaw GitHub Copilot agent runtime plugin (registers a `github-copilot` AgentHarness backed by @github/copilot-sdk over JSON-RPC to the GitHub Copilot CLI)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@github/copilot-sdk": "1.0.
|
|
11
|
+
"@github/copilot-sdk": "1.0.13"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@openclaw/plugin-sdk": "workspace:*"
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"minHostVersion": ">=2026.5.28"
|
|
25
25
|
},
|
|
26
26
|
"compat": {
|
|
27
|
-
"pluginApi": ">=2026.9.
|
|
27
|
+
"pluginApi": ">=2026.9.5"
|
|
28
28
|
},
|
|
29
29
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.9.
|
|
30
|
+
"openclawVersion": "2026.9.5",
|
|
31
31
|
"bundledDist": false
|
|
32
32
|
},
|
|
33
33
|
"release": {
|
|
@@ -42,10 +42,12 @@
|
|
|
42
42
|
"files": [
|
|
43
43
|
"dist/**",
|
|
44
44
|
"openclaw.plugin.json",
|
|
45
|
-
"README.md"
|
|
45
|
+
"README.md",
|
|
46
|
+
"assets/icon.png",
|
|
47
|
+
"assets/activity.svg"
|
|
46
48
|
],
|
|
47
49
|
"peerDependencies": {
|
|
48
|
-
"openclaw": ">=2026.9.
|
|
50
|
+
"openclaw": ">=2026.9.5"
|
|
49
51
|
},
|
|
50
52
|
"peerDependenciesMeta": {
|
|
51
53
|
"openclaw": {
|
|
File without changes
|