@openclaw/copilot 2026.7.2-beta.2 → 2026.7.2-beta.4

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.
@@ -1,4 +1,4 @@
1
- import { buildAgentHookContextChannelFields, compactWithSafetyTimeout, getModelProviderRequestTransport, resolveCompactionTimeoutMs, runAgentHarnessAfterCompactionHook, runAgentHarnessBeforeCompactionHook } from "openclaw/plugin-sdk/agent-harness-runtime";
1
+ import { buildAgentHookContextChannelFields, compactWithSafetyTimeout, getModelProviderRequestTransport, projectSettledTurnFinalizationAttemptResult, resolveCompactionTimeoutMs, runAgentHarnessAfterCompactionHook, runAgentHarnessBeforeCompactionHook } from "openclaw/plugin-sdk/agent-harness-runtime";
2
2
  import { createHash, randomBytes } from "node:crypto";
3
3
  import { homedir } from "node:os";
4
4
  import { join, resolve } from "node:path";
@@ -820,7 +820,7 @@ function createCopilotAgentHarness(options) {
820
820
  async function getPool() {
821
821
  if (options?.pool) return options.pool;
822
822
  if (!poolPromise) poolPromise = (async () => {
823
- const { createCopilotClientPool } = await import("./runtime-C__LHHs3.js");
823
+ const { createCopilotClientPool } = await import("./runtime-BY2Yi3Dg.js");
824
824
  createdPool = createCopilotClientPool(options?.poolOptions);
825
825
  return createdPool;
826
826
  })();
@@ -854,9 +854,113 @@ function createCopilotAgentHarness(options) {
854
854
  for (const [, cleanup] of pending) cleanup.abort();
855
855
  await Promise.allSettled(pending.map(([cleanup]) => cleanup));
856
856
  }
857
+ async function runHarnessAttempt(params, operation) {
858
+ const attemptPromise = (async () => {
859
+ if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
860
+ const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-DYiC3PqS.js");
861
+ if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
862
+ const pool = await getPool();
863
+ if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
864
+ let poolAcquire;
865
+ try {
866
+ poolAcquire = resolvePoolAcquire(params);
867
+ } catch (error) {
868
+ if (operation === "attempt" && isCopilotByokUnsupportedProviderError(error)) return runCopilotAttempt(params, { pool });
869
+ throw error;
870
+ }
871
+ const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
872
+ const currentCompatKey = computeSessionCompatKey(params);
873
+ const currentCompactKey = computeSessionCompactKey(params);
874
+ const compactionCleanupPending = openclawSessionId !== void 0 && hasPendingDeferredCompactionCleanup(openclawSessionId);
875
+ const replayBlocked = openclawSessionId !== void 0 && (compactionCleanupPending || resetBlockedStoredSessions.has(openclawSessionId));
876
+ const tracked = openclawSessionId && !replayBlocked ? trackedSessions.get(openclawSessionId) : void 0;
877
+ const stored = openclawSessionId ? replayBlocked ? void 0 : lookupStoredBinding(options?.sessionStore, openclawSessionId) : void 0;
878
+ const resumableSessionId = tracked && tracked.compatKey === currentCompatKey ? tracked.sdkSessionId : !tracked && stored && stored.compatKey === currentCompatKey ? stored.sdkSessionId : void 0;
879
+ if (operation === "settled-tool-finalization" && !resumableSessionId) throw new Error("[copilot] cannot safely finalize a settled tool turn without its compatible SDK session");
880
+ return runCopilotAttempt(resumableSessionId ? {
881
+ ...params,
882
+ ...operation === "settled-tool-finalization" ? {
883
+ disableTools: true,
884
+ onAgentEvent: void 0,
885
+ onAgentToolResult: void 0,
886
+ onAssistantDelta: void 0,
887
+ onAssistantMessageStart: void 0,
888
+ onBlockReply: void 0,
889
+ onBlockReplyFlush: void 0,
890
+ onPartialReply: void 0,
891
+ onReasoningEnd: void 0,
892
+ onReasoningStream: void 0,
893
+ onToolResult: void 0,
894
+ onToolStreamBoundary: void 0
895
+ } : {},
896
+ initialReplayState: operation === "settled-tool-finalization" ? { sdkSessionId: resumableSessionId } : {
897
+ ...params.initialReplayState,
898
+ sdkSessionId: resumableSessionId
899
+ }
900
+ } : params, {
901
+ pool,
902
+ ...operation === "settled-tool-finalization" ? { operation } : {},
903
+ onSessionEstablished: operation === "attempt" && openclawSessionId ? ({ compactionSessionConfig, sdkSessionId, pooledClient, sessionConfig }) => {
904
+ trackedSessions.set(openclawSessionId, {
905
+ sdkSessionId,
906
+ client: pooledClient.client,
907
+ clientOptions: poolAcquire.options,
908
+ compatKey: currentCompatKey,
909
+ compactKey: currentCompactKey,
910
+ poolKey: pooledClient.key,
911
+ sessionConfig: compactionSessionConfig ?? sessionConfig,
912
+ ...sessionAuthFields(poolAcquire.auth)
913
+ });
914
+ registerStoredBinding(options?.sessionStore, openclawSessionId, {
915
+ schemaVersion: 2,
916
+ sdkSessionId,
917
+ compatKey: currentCompatKey,
918
+ compactKey: currentCompactKey,
919
+ ...sessionAuthFields(poolAcquire.auth),
920
+ updatedAt: Date.now()
921
+ });
922
+ resetBlockedStoredSessions.delete(openclawSessionId);
923
+ } : void 0,
924
+ onDeferredCompaction: openclawSessionId ? ({ abort, cleanup, sdkSessionId }) => {
925
+ const trackedBinding = trackedSessions.get(openclawSessionId);
926
+ const storedBinding = lookupStoredBinding(options?.sessionStore, openclawSessionId);
927
+ const ownsTrackedSession = trackedBinding?.sdkSessionId === sdkSessionId;
928
+ const ownsStoredSession = storedBinding?.sdkSessionId === sdkSessionId;
929
+ if (!ownsTrackedSession && !ownsStoredSession) return;
930
+ trackDeferredCompactionCleanup({
931
+ abort,
932
+ cleanup,
933
+ sessionId: openclawSessionId,
934
+ sdkSessionId
935
+ });
936
+ resetBlockedStoredSessions.add(openclawSessionId);
937
+ cleanup.then((outcome) => {
938
+ const currentTracked = trackedSessions.get(openclawSessionId);
939
+ const currentStored = lookupStoredBinding(options?.sessionStore, openclawSessionId);
940
+ const stillOwnsTrackedSession = currentTracked?.sdkSessionId === sdkSessionId;
941
+ const stillOwnsStoredSession = currentStored?.sdkSessionId === sdkSessionId;
942
+ if (outcome === "completed") {
943
+ if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.delete(openclawSessionId);
944
+ return;
945
+ }
946
+ if (stillOwnsTrackedSession) trackedSessions.delete(openclawSessionId);
947
+ if (stillOwnsStoredSession) deleteStoredBinding(options?.sessionStore, openclawSessionId);
948
+ if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.add(openclawSessionId);
949
+ });
950
+ } : void 0
951
+ });
952
+ })();
953
+ inFlight.add(attemptPromise);
954
+ try {
955
+ return await attemptPromise;
956
+ } finally {
957
+ inFlight.delete(attemptPromise);
958
+ }
959
+ }
857
960
  return {
858
961
  id: options?.id ?? "copilot",
859
962
  label: options?.label ?? "GitHub Copilot agent runtime",
963
+ autoSelection: { providerIds: [] },
860
964
  supports(ctx) {
861
965
  if (String(ctx.requestedRuntime ?? "").trim().toLowerCase() !== "copilot") return {
862
966
  supported: false,
@@ -891,92 +995,9 @@ function createCopilotAgentHarness(options) {
891
995
  priority: 100
892
996
  };
893
997
  },
894
- async runAttempt(params) {
895
- const attemptPromise = (async () => {
896
- if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
897
- const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-Bwgye68K.js");
898
- if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
899
- const pool = await getPool();
900
- if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
901
- let poolAcquire;
902
- try {
903
- poolAcquire = resolvePoolAcquire(params);
904
- } catch (error) {
905
- if (isCopilotByokUnsupportedProviderError(error)) return runCopilotAttempt(params, { pool });
906
- throw error;
907
- }
908
- const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
909
- const currentCompatKey = computeSessionCompatKey(params);
910
- const currentCompactKey = computeSessionCompactKey(params);
911
- const compactionCleanupPending = openclawSessionId !== void 0 && hasPendingDeferredCompactionCleanup(openclawSessionId);
912
- const replayBlocked = openclawSessionId !== void 0 && (compactionCleanupPending || resetBlockedStoredSessions.has(openclawSessionId));
913
- const tracked = openclawSessionId && !replayBlocked ? trackedSessions.get(openclawSessionId) : void 0;
914
- const stored = openclawSessionId ? replayBlocked ? void 0 : lookupStoredBinding(options?.sessionStore, openclawSessionId) : void 0;
915
- const resumableSessionId = tracked && tracked.compatKey === currentCompatKey ? tracked.sdkSessionId : !tracked && stored && stored.compatKey === currentCompatKey ? stored.sdkSessionId : void 0;
916
- return runCopilotAttempt(resumableSessionId ? {
917
- ...params,
918
- initialReplayState: {
919
- ...params.initialReplayState,
920
- sdkSessionId: resumableSessionId
921
- }
922
- } : params, {
923
- pool,
924
- onSessionEstablished: openclawSessionId ? ({ compactionSessionConfig, sdkSessionId, pooledClient, sessionConfig }) => {
925
- trackedSessions.set(openclawSessionId, {
926
- sdkSessionId,
927
- client: pooledClient.client,
928
- clientOptions: poolAcquire.options,
929
- compatKey: currentCompatKey,
930
- compactKey: currentCompactKey,
931
- poolKey: pooledClient.key,
932
- sessionConfig: compactionSessionConfig ?? sessionConfig,
933
- ...sessionAuthFields(poolAcquire.auth)
934
- });
935
- registerStoredBinding(options?.sessionStore, openclawSessionId, {
936
- schemaVersion: 2,
937
- sdkSessionId,
938
- compatKey: currentCompatKey,
939
- compactKey: currentCompactKey,
940
- ...sessionAuthFields(poolAcquire.auth),
941
- updatedAt: Date.now()
942
- });
943
- resetBlockedStoredSessions.delete(openclawSessionId);
944
- } : void 0,
945
- onDeferredCompaction: openclawSessionId ? ({ abort, cleanup, sdkSessionId }) => {
946
- const trackedBinding = trackedSessions.get(openclawSessionId);
947
- const storedBinding = lookupStoredBinding(options?.sessionStore, openclawSessionId);
948
- const ownsTrackedSession = trackedBinding?.sdkSessionId === sdkSessionId;
949
- const ownsStoredSession = storedBinding?.sdkSessionId === sdkSessionId;
950
- if (!ownsTrackedSession && !ownsStoredSession) return;
951
- trackDeferredCompactionCleanup({
952
- abort,
953
- cleanup,
954
- sessionId: openclawSessionId,
955
- sdkSessionId
956
- });
957
- resetBlockedStoredSessions.add(openclawSessionId);
958
- cleanup.then((outcome) => {
959
- const currentTracked = trackedSessions.get(openclawSessionId);
960
- const currentStored = lookupStoredBinding(options?.sessionStore, openclawSessionId);
961
- const stillOwnsTrackedSession = currentTracked?.sdkSessionId === sdkSessionId;
962
- const stillOwnsStoredSession = currentStored?.sdkSessionId === sdkSessionId;
963
- if (outcome === "completed") {
964
- if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.delete(openclawSessionId);
965
- return;
966
- }
967
- if (stillOwnsTrackedSession) trackedSessions.delete(openclawSessionId);
968
- if (stillOwnsStoredSession) deleteStoredBinding(options?.sessionStore, openclawSessionId);
969
- if (stillOwnsTrackedSession || stillOwnsStoredSession) resetBlockedStoredSessions.add(openclawSessionId);
970
- });
971
- } : void 0
972
- });
973
- })();
974
- inFlight.add(attemptPromise);
975
- try {
976
- return await attemptPromise;
977
- } finally {
978
- inFlight.delete(attemptPromise);
979
- }
998
+ runAttempt: (params) => runHarnessAttempt(params, "attempt"),
999
+ finalizeSettledTurn: async ({ attempt }) => {
1000
+ return projectSettledTurnFinalizationAttemptResult(await runHarnessAttempt(attempt, "settled-tool-finalization"));
980
1001
  },
981
1002
  async reset(params) {
982
1003
  const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
@@ -1010,7 +1031,7 @@ function createCopilotAgentHarness(options) {
1010
1031
  };
1011
1032
  const tracked = trackedSessions.get(openclawSessionId);
1012
1033
  const currentCompactKey = computeSessionCompactKey(params);
1013
- const { resolvePoolAcquire } = await import("./attempt-Bwgye68K.js");
1034
+ const { resolvePoolAcquire } = await import("./attempt-DYiC3PqS.js");
1014
1035
  let resolvedPoolAcquire;
1015
1036
  let currentAuth;
1016
1037
  try {
package/dist/harness.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createCopilotAgentHarness } from "./harness-DeWR8_cC.js";
1
+ import { t as createCopilotAgentHarness } from "./harness-BUP4to1-.js";
2
2
  export { createCopilotAgentHarness };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createCopilotAgentHarness } from "./harness-DeWR8_cC.js";
1
+ import { t as createCopilotAgentHarness } from "./harness-BUP4to1-.js";
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
@@ -182,7 +182,7 @@ function createCopilotClientPool(options = {}) {
182
182
  };
183
183
  };
184
184
  const acquire = async (inputKey, optionsForCreate) => {
185
- const key = normalizePoolKey(inputKey, optionsForCreate.copilotHome);
185
+ const key = normalizePoolKey(inputKey, optionsForCreate.copilotHome, optionsForCreate.mode);
186
186
  const cacheKey = JSON.stringify(key);
187
187
  const clientOptions = normalizeClientCreateOptions(optionsForCreate, key.copilotHome);
188
188
  while (true) {
@@ -310,13 +310,14 @@ function createCopilotClientPool(options = {}) {
310
310
  size: () => entries.size
311
311
  };
312
312
  }
313
- function normalizePoolKey(key, rawCopilotHome) {
313
+ function normalizePoolKey(key, rawCopilotHome, clientMode) {
314
314
  return {
315
315
  agentId: key.agentId,
316
316
  copilotHome: normalizeCopilotHome(rawCopilotHome),
317
317
  authMode: key.authMode,
318
318
  authProfileId: key.authProfileId,
319
- authProfileVersion: key.authProfileVersion
319
+ authProfileVersion: key.authProfileVersion,
320
+ ...clientMode === "empty" ? { clientMode } : {}
320
321
  };
321
322
  }
322
323
  function normalizeClientCreateOptions(options, normalizedCopilotHome) {