@openclaw/copilot 2026.9.3 → 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.
@@ -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>
Binary file
@@ -1,5 +1,5 @@
1
- import { a as resolveCopilotAuth, i as createCopilotByokAuth, n as resolveCopilotProvider, r as createCopilotByokProxy } from "./harness-qA-Kb-ZC.js";
2
- import { n as normalizeCopilotUsage, r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.js";
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
- params.finalizeNativeSubagents?.();
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$1(candidate.content) === userText$1(prepared.content);
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
- const constructedTools = await createOpenClawCodingTools(toolOptions);
1581
- if (!Array.isArray(constructedTools)) throw new Error("createOpenClawCodingTools must return an array of tools");
1582
- const boundTools = hostCapabilities.bindToolSurface(constructedTools, bindingOptions);
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,
@@ -2019,6 +2067,7 @@ function prepareCopilotAttemptContext(params, deps) {
2019
2067
  modelProviderId: modelRef.provider,
2020
2068
  modelId: modelRef.id,
2021
2069
  trigger: input.trigger,
2070
+ inputProvenance: input.inputProvenance,
2022
2071
  foregroundPromptContext: buildEmbeddedForegroundPromptContext({
2023
2072
  ...input,
2024
2073
  agentId: sessionAgentId
@@ -2075,7 +2124,7 @@ function buildCopilotPromptGuidance(params) {
2075
2124
  messageToolAvailable: callableTools.has("message"),
2076
2125
  requireExplicitMessageTarget: params.requireExplicitMessageTarget
2077
2126
  }),
2078
- buildCredentialSafetyPrompt(params.attempt.disableTools !== true && callableTools.has("secrets") ? "secrets" : void 0),
2127
+ buildCredentialSafetyPrompt({ controlToolsAvailable: params.attempt.disableTools !== true && (callableTools.has("openclaw") || callableTools.has("gateway")) }),
2079
2128
  params.workspaceBootstrapInstructions?.trim(),
2080
2129
  extraSystemPrompt ? `${isMinimal ? "## Subagent Context" : "## Conversation Context"}\n${extraSystemPrompt}` : void 0
2081
2130
  ].filter((section) => section?.trim()).join("\n\n") || void 0;
@@ -2420,41 +2469,6 @@ async function createCopilotSessionSetup(params) {
2420
2469
  };
2421
2470
  }
2422
2471
  //#endregion
2423
- //#region extensions/copilot/src/attempt-transcript-replay.ts
2424
- function readAssistantToolCallIds(message) {
2425
- return message.role === "assistant" ? message.content.flatMap((part) => part.type === "toolCall" ? [part.id] : []) : [];
2426
- }
2427
- function isCompatibleSingletonRewrite(original, prepared) {
2428
- return original.role === prepared.role && (original.role !== "assistant" || JSON.stringify(readAssistantToolCallIds(original)) === JSON.stringify(readAssistantToolCallIds(prepared)));
2429
- }
2430
- function projectReplayPayload(message) {
2431
- switch (message.role) {
2432
- case "user": return {
2433
- role: message.role,
2434
- content: message.content
2435
- };
2436
- case "assistant": return {
2437
- role: message.role,
2438
- content: message.content,
2439
- api: message.api,
2440
- model: message.model,
2441
- provider: message.provider,
2442
- stopReason: message.stopReason
2443
- };
2444
- case "toolResult": return {
2445
- role: message.role,
2446
- content: message.content,
2447
- isError: message.isError,
2448
- toolCallId: message.toolCallId,
2449
- toolName: message.toolName
2450
- };
2451
- }
2452
- }
2453
- function isCompleteToolGroup(messages, order) {
2454
- const [assistant, ...results] = messages;
2455
- 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]);
2456
- }
2457
- //#endregion
2458
2472
  //#region extensions/copilot/src/attempt-transcript-journal.ts
2459
2473
  function readTurnTaintMetadata(message) {
2460
2474
  const metadata = message["__openclaw"];
@@ -2885,14 +2899,6 @@ function isSameUserTurn(candidate, current, currentRunUserKey) {
2885
2899
  }
2886
2900
  return candidate.timestamp === current.timestamp && userText(candidate.content) === userText(current.content);
2887
2901
  }
2888
- function userText(content) {
2889
- if (typeof content === "string") return content;
2890
- if (Array.isArray(content) && content.length === 1) {
2891
- const part = content[0];
2892
- if (part?.type === "text" && typeof part.text === "string") return part.text;
2893
- }
2894
- return JSON.stringify(content) ?? "";
2895
- }
2896
2902
  //#endregion
2897
2903
  //#region extensions/copilot/src/native-subagent-task-mirror.ts
2898
2904
  const COPILOT_NATIVE_SUBAGENT_TASK_KIND = "copilot-native";
@@ -2915,8 +2921,7 @@ var CopilotNativeSubagentTaskMirror = class {
2915
2921
  this.runtime = runtime;
2916
2922
  this.runIdByAgentId = /* @__PURE__ */ new Map();
2917
2923
  this.runIdByToolCallId = /* @__PURE__ */ new Map();
2918
- this.terminalRunIds = /* @__PURE__ */ new Set();
2919
- this.activeRunIds = /* @__PURE__ */ new Set();
2924
+ this.activeRuns = /* @__PURE__ */ new Map();
2920
2925
  this.now = params.now ?? Date.now;
2921
2926
  }
2922
2927
  handleEvent(event) {
@@ -2935,73 +2940,83 @@ var CopilotNativeSubagentTaskMirror = class {
2935
2940
  }
2936
2941
  finalizeActiveRuns() {
2937
2942
  const eventAt = this.now();
2938
- for (const runId of this.activeRunIds) {
2939
- this.terminalRunIds.add(runId);
2940
- this.runtime.finalizeTaskRunByRunId({
2943
+ let failure;
2944
+ for (const runId of this.activeRuns.keys()) try {
2945
+ this.finalizeRun({
2941
2946
  runId,
2942
2947
  status: "cancelled",
2943
2948
  endedAt: eventAt,
2944
2949
  lastEventAt: eventAt,
2945
- error: "Copilot native subagent ended with its parent attempt.",
2946
- progressSummary: "Copilot native subagent cancelled with its parent attempt.",
2947
- terminalSummary: "Copilot native subagent cancelled."
2950
+ error: "Subagent ended with its parent attempt.",
2951
+ progressSummary: "Subagent cancelled with its parent attempt.",
2952
+ terminalSummary: "Subagent cancelled."
2948
2953
  });
2954
+ } catch (error) {
2955
+ failure ??= { error };
2949
2956
  }
2950
- this.activeRunIds.clear();
2957
+ if (failure) throw failure.error;
2951
2958
  }
2952
2959
  handleStarted(event, runId, toolCallId) {
2953
2960
  const agentId = event.agentId?.trim();
2954
2961
  if (agentId ? this.runIdByAgentId.get(agentId) : this.runIdByToolCallId.get(toolCallId)) return;
2955
2962
  const eventAt = this.now();
2956
2963
  const label = event.data.agentDisplayName.trim() || event.data.agentName.trim();
2957
- const task = event.data.agentDescription.trim() || `Copilot native subagent ${label}`;
2958
- if (!this.runtime.tryCreateRunningTaskRun({
2964
+ const task = event.data.agentDescription.trim() || `Subagent ${label}`;
2965
+ const taskRecord = this.runtime.tryCreateRunningTaskRun({
2959
2966
  sourceId: toolCallId,
2960
2967
  agentId: this.params.agentId,
2961
2968
  runId,
2962
- label: label || "Copilot subagent",
2969
+ label: label || "Subagent",
2963
2970
  task,
2964
2971
  notifyPolicy: "silent",
2965
2972
  deliveryStatus: "not_applicable",
2966
2973
  preferMetadata: true,
2967
2974
  startedAt: eventAt,
2968
2975
  lastEventAt: eventAt,
2969
- progressSummary: "Copilot native subagent started."
2970
- })) return;
2976
+ progressSummary: "Subagent started."
2977
+ });
2978
+ if (!taskRecord) return;
2971
2979
  if (agentId) this.runIdByAgentId.set(agentId, runId);
2972
2980
  else this.runIdByToolCallId.set(toolCallId, runId);
2973
- this.terminalRunIds.delete(runId);
2974
- this.activeRunIds.add(runId);
2981
+ this.activeRuns.set(runId, { taskId: taskRecord.taskId });
2975
2982
  }
2976
2983
  handleCompleted(event, runId) {
2977
- if (this.terminalRunIds.has(runId)) return;
2978
2984
  const eventAt = this.now();
2979
- this.terminalRunIds.add(runId);
2980
- this.activeRunIds.delete(runId);
2981
- this.runtime.finalizeTaskRunByRunId({
2985
+ this.finalizeRun({
2982
2986
  runId,
2983
2987
  status: "succeeded",
2984
2988
  endedAt: eventAt,
2985
2989
  lastEventAt: eventAt,
2986
- progressSummary: "Copilot native subagent completed.",
2990
+ progressSummary: "Subagent completed.",
2987
2991
  terminalSummary: buildCompletionSummary(event)
2988
2992
  });
2989
2993
  }
2990
2994
  handleFailed(event, runId) {
2991
- if (this.terminalRunIds.has(runId)) return;
2992
2995
  const eventAt = this.now();
2993
- this.terminalRunIds.add(runId);
2994
- this.activeRunIds.delete(runId);
2995
- this.runtime.finalizeTaskRunByRunId({
2996
+ this.finalizeRun({
2996
2997
  runId,
2997
2998
  status: "failed",
2998
2999
  endedAt: eventAt,
2999
3000
  lastEventAt: eventAt,
3000
3001
  error: event.data.error,
3001
- progressSummary: "Copilot native subagent failed.",
3002
- terminalSummary: "Copilot native subagent failed."
3002
+ progressSummary: "Subagent failed.",
3003
+ terminalSummary: "Subagent failed."
3003
3004
  });
3004
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
+ }
3005
3020
  resolveRunId(event) {
3006
3021
  const agentId = event.agentId?.trim();
3007
3022
  if (agentId) {
@@ -3016,7 +3031,7 @@ var CopilotNativeSubagentTaskMirror = class {
3016
3031
  };
3017
3032
  function buildCompletionSummary(event) {
3018
3033
  const details = [event.data.totalToolCalls !== void 0 ? `${event.data.totalToolCalls} tool calls` : void 0, event.data.totalTokens !== void 0 ? `${event.data.totalTokens} tokens` : void 0].filter((value) => value !== void 0);
3019
- return details.length > 0 ? `Copilot native subagent completed (${details.join(", ")}).` : "Copilot native subagent completed.";
3034
+ return details.length > 0 ? `Subagent completed (${details.join(", ")}).` : "Subagent completed.";
3020
3035
  }
3021
3036
  //#endregion
3022
3037
  //#region extensions/copilot/src/attempt-execution.ts
@@ -3261,7 +3276,7 @@ async function runCopilotExecution(context) {
3261
3276
  sdkSessionId = readNonEmptyString(session.sessionId) ?? readNonEmptyString(session.id) ?? (resumeFailureRecovered ? void 0 : resumeSessionId);
3262
3277
  if (!sdkSessionId) throw createPromptError$1("transcript_persistence_failed", "[copilot-attempt] canonical transcript persistence requires the Copilot SDK session id");
3263
3278
  if (sdkSessionId && deps.onSessionEstablished && !settledToolFinalization) try {
3264
- deps.onSessionEstablished({
3279
+ await deps.onSessionEstablished({
3265
3280
  compactionSessionConfig,
3266
3281
  sdkSessionId,
3267
3282
  pooledClient: handle,
@@ -3421,7 +3436,7 @@ async function runCopilotExecution(context) {
3421
3436
  params.abortSignal?.removeEventListener("abort", abortCleanup);
3422
3437
  }).catch(() => void 0);
3423
3438
  if (sdkSessionId && !settledToolFinalization) try {
3424
- deps.onDeferredCompaction?.({
3439
+ await deps.onDeferredCompaction?.({
3425
3440
  abort: () => cleanupAbort.abort(),
3426
3441
  cleanup,
3427
3442
  sdkSessionId
@@ -3431,7 +3446,11 @@ async function runCopilotExecution(context) {
3431
3446
  } else {
3432
3447
  await bridge?.awaitCompactionChain();
3433
3448
  await bridge?.awaitAgentEventChain();
3434
- nativeSubagentTaskMirror?.finalizeActiveRuns();
3449
+ try {
3450
+ nativeSubagentTaskMirror?.finalizeActiveRuns();
3451
+ } catch (error) {
3452
+ promptError ??= toCopilotError(error);
3453
+ }
3435
3454
  cleanupToolBridge?.();
3436
3455
  await cleanupByokProxy?.();
3437
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-LtZ5NAjV.js");
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-e3wCSh8h.js");
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 compactionCleanupPending = openclawSessionId !== void 0 && hasPendingDeferredCompactionCleanup(openclawSessionId);
906
- const replayBlocked = openclawSessionId !== void 0 && (compactionCleanupPending || resetBlockedStoredSessions.has(openclawSessionId));
907
- const tracked = openclawSessionId && !replayBlocked ? trackedSessions.get(openclawSessionId) : void 0;
908
- const stored = openclawSessionId ? replayBlocked ? void 0 : lookupStoredBinding(options?.sessionStore, openclawSessionId) : void 0;
909
- const resumableBinding = tracked && tracked.compatKey === currentCompatKey ? tracked : !tracked && stored && stored.compatKey === currentCompatKey ? stored : void 0;
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
- trackedSessions.set(openclawSessionId, {
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
- resetBlockedStoredSessions.add(openclawSessionId);
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
- const trackedSession = trackedSessions.get(openclawSessionId);
992
- if (sdkSessionId && trackedSession?.sdkSessionId === sdkSessionId) {
993
- const { journalVersion: _journalVersion, ...baseTracked } = trackedSession;
994
- const nextTracked = {
995
- ...baseTracked,
996
- ...attemptResult.journalValidated ? { journalVersion: 1 } : {}
997
- };
998
- trackedSessions.set(openclawSessionId, nextTracked);
999
- registerStoredBinding(options?.sessionStore, openclawSessionId, {
1000
- schemaVersion: 2,
1001
- ...attemptResult.journalValidated ? { journalVersion: 1 } : {},
1002
- sdkSessionId,
1003
- compatKey: nextTracked.compatKey,
1004
- compactKey: nextTracked.compactKey,
1005
- ...sessionAuthFields(nextTracked),
1006
- updatedAt: Date.now()
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-D01XCEU3.js");
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
- async reset(params) {
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 = trackedSessions.get(openclawSessionId);
1086
- const stored = lookupStoredBinding(options?.sessionStore, openclawSessionId);
1087
- resetBlockedStoredSessions.add(openclawSessionId);
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
- const currentStored = lookupStoredBinding(options?.sessionStore, openclawSessionId);
1090
- if (stored !== void 0 && currentStored?.sdkSessionId === stored.sdkSessionId) {
1091
- if (deleteStoredBinding(options?.sessionStore, openclawSessionId)) resetBlockedStoredSessions.delete(openclawSessionId);
1092
- } else resetBlockedStoredSessions.delete(openclawSessionId);
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
- async compact(params) {
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-e3wCSh8h.js");
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
- trackedSessions.delete(openclawSessionId);
1182
- deleteStoredBinding(options?.sessionStore, openclawSessionId);
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-qA-Kb-ZC.js";
2
- import { r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.js";
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.11" };
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
- "(~260 MB after pulling its platform-specific @github/copilot CLI binary).",
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 "./harness-qA-Kb-ZC.js";
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 "./harness-qA-Kb-ZC.js";
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.openSyncKeyedStore({
21
+ const getSessionStore = () => sessionStore ??= api.runtime.state.openKeyedStore({
22
22
  namespace: "sdk-sessions",
23
23
  maxEntries: 5e3,
24
24
  defaultTtlMs: 7776e6
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "id": "copilot",
3
+ "categories": ["agent-runtimes"],
3
4
  "doctorContract": {
4
5
  "configRepair": true
5
6
  },
@@ -20,6 +21,14 @@
20
21
  "onStartup": false,
21
22
  "onAgentHarnesses": ["copilot"]
22
23
  },
24
+ "configGroups": [
25
+ {
26
+ "id": "client-pool",
27
+ "title": "Client pool",
28
+ "order": 10,
29
+ "properties": ["pool"]
30
+ }
31
+ ],
23
32
  "configSchema": {
24
33
  "type": "object",
25
34
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/copilot",
3
- "version": "2026.9.3",
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"
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.3"
27
+ "pluginApi": ">=2026.9.5"
28
28
  },
29
29
  "build": {
30
- "openclawVersion": "2026.9.3",
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.3"
50
+ "openclaw": ">=2026.9.5"
49
51
  },
50
52
  "peerDependenciesMeta": {
51
53
  "openclaw": {