@openclaw/copilot 2026.9.5 → 2026.9.7
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/icon.png +0 -0
- package/dist/.setup/{attempt-BZXPuTyZ.mjs → attempt-CRiSJYXq.mjs} +193 -525
- package/dist/.setup/{harness-Dj0L75Tk.mjs → harness-BAWs53-w.mjs} +58 -146
- package/dist/.setup/{isolated-completion-54FP0qmC.mjs → isolated-completion-ClBsnNg8.mjs} +1 -1
- package/dist/.setup/{runtime-D6DFeSZX.mjs → runtime-CWI9o_Vc.mjs} +28 -47
- package/dist/harness.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +5 -5
|
@@ -10,49 +10,6 @@ import { pipeline } from "node:stream/promises";
|
|
|
10
10
|
import { fetchWithSsrFGuard, isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
11
11
|
import { isNonSecretApiKeyMarker } from "openclaw/plugin-sdk/provider-auth";
|
|
12
12
|
//#region extensions/copilot/src/auth-bridge.ts
|
|
13
|
-
/**
|
|
14
|
-
* Pure functional auth resolver for the copilot agent runtime.
|
|
15
|
-
*
|
|
16
|
-
* Scope:
|
|
17
|
-
*
|
|
18
|
-
* - Consumes the resolved auth signals that core's harness contract
|
|
19
|
-
* already carries on `EmbeddedRunAttemptParams` (=
|
|
20
|
-
* `AgentHarnessAttemptParams`): `resolvedApiKey`, `authProfileId`,
|
|
21
|
-
* `authProfileIdSource`. Core resolves these from the agent's
|
|
22
|
-
* `AuthProfileStore` via `provider-usage.auth.ts:resolveProviderAuths`
|
|
23
|
-
* before invoking the harness, so the harness does not re-perform
|
|
24
|
-
* the lookup (and could not, due to the package boundary in
|
|
25
|
-
* `tsconfig.package-boundary.base.json`).
|
|
26
|
-
* - Reads optional explicit overrides from the harness attempt params
|
|
27
|
-
* (`auth.useLoggedInUser`, `auth.gitHubToken`) for direct CLI / test
|
|
28
|
-
* use cases.
|
|
29
|
-
* - Falls back to OPENCLAW_GITHUB_TOKEN, COPILOT_GITHUB_TOKEN,
|
|
30
|
-
* GH_TOKEN, or GITHUB_TOKEN env vars (in that precedence) when
|
|
31
|
-
* no contract-resolved token is given; synthesises a stable,
|
|
32
|
-
* non-reversible pool fingerprint so token rotation busts the
|
|
33
|
-
* client pool cleanly.
|
|
34
|
-
* - Computes a per-agent `copilotHome` default
|
|
35
|
-
* (`<openClawHome>/.openclaw/agents/<agentId>/copilot`, or
|
|
36
|
-
* `<agentDir>/copilot` when an agent directory is supplied) that
|
|
37
|
-
* respects `OPENCLAW_HOME` for the home directory root.
|
|
38
|
-
* - Defaults to `useLoggedInUser` when no token signal is available.
|
|
39
|
-
*
|
|
40
|
-
* Precedence (highest to lowest):
|
|
41
|
-
* 1. `auth.useLoggedInUser === true` (explicit user opt-in)
|
|
42
|
-
* 2. `auth.gitHubToken` (explicit override; requires
|
|
43
|
-
* `profileId` + `profileVersion`)
|
|
44
|
-
* 3. `resolvedApiKey` + `authProfileId` from the contract (core's
|
|
45
|
-
* AuthProfileStore-resolved token — the production main path for
|
|
46
|
-
* a configured `github-copilot` auth profile)
|
|
47
|
-
* 4. OPENCLAW_GITHUB_TOKEN, then COPILOT_GITHUB_TOKEN, then
|
|
48
|
-
* GH_TOKEN, then GITHUB_TOKEN env vars (mirrors the
|
|
49
|
-
* shipped `github-copilot` provider precedence so headless
|
|
50
|
-
* users who already follow the documented
|
|
51
|
-
* COPILOT_GITHUB_TOKEN / GH_TOKEN setup get the token they
|
|
52
|
-
* configured rather than silently falling through to the
|
|
53
|
-
* logged-in CLI user.)
|
|
54
|
-
* 5. `useLoggedInUser` (default)
|
|
55
|
-
*/
|
|
56
13
|
const COPILOT_TOKEN_PROFILE_ERROR = "[copilot-attempt] gitHubToken auth requires profileId+profileVersion (pool keying safety; per Q5/Q1 decisions)";
|
|
57
14
|
const COPILOT_DEFAULT_AGENT_ID = "copilot";
|
|
58
15
|
function createCopilotByokAuth(input) {
|
|
@@ -71,16 +28,6 @@ function createCopilotByokAuth(input) {
|
|
|
71
28
|
authProfileVersion: input.authProfileVersion?.trim() || "byok:unfingerprinted"
|
|
72
29
|
};
|
|
73
30
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Resolve copilot auth + copilotHome.
|
|
76
|
-
*
|
|
77
|
-
* Synchronous because we intentionally do not perform any I/O or
|
|
78
|
-
* cross-package credential lookups here (see file header for rationale).
|
|
79
|
-
*
|
|
80
|
-
* Throws if `gitHubToken` is supplied via `params.auth.gitHubToken`
|
|
81
|
-
* WITHOUT both `profileId` and `profileVersion` (the existing invariant
|
|
82
|
-
* from attempt.ts; preserves pool-key safety per Q5/Q1).
|
|
83
|
-
*/
|
|
84
31
|
function resolveCopilotAuth(input) {
|
|
85
32
|
const env = input.env ?? process.env;
|
|
86
33
|
const homeDir = input.homeDir ?? homedir;
|
|
@@ -88,7 +35,6 @@ function resolveCopilotAuth(input) {
|
|
|
88
35
|
const copilotHome = resolveCopilotHome({
|
|
89
36
|
explicit: readNonEmptyStringPreservingWhitespace(input.copilotHome),
|
|
90
37
|
agentDir: readNonEmptyStringPreservingWhitespace(input.agentDir),
|
|
91
|
-
workspaceDir: readNonEmptyStringPreservingWhitespace(input.workspaceDir),
|
|
92
38
|
agentId,
|
|
93
39
|
env,
|
|
94
40
|
homeDir
|
|
@@ -136,23 +82,9 @@ function resolveCopilotAuth(input) {
|
|
|
136
82
|
agentId
|
|
137
83
|
};
|
|
138
84
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Validate + sanitise an agent id for use in filesystem paths and pool
|
|
141
|
-
* keys.
|
|
142
|
-
*
|
|
143
|
-
* Mirrors the shape constraints documented by core's `normalizeAgentId`
|
|
144
|
-
* / `isValidAgentId` in `src/routing/session-key.ts` (alnum + `-_`,
|
|
145
|
-
* starts with alnum, lowercase, <=64 chars). We re-implement here
|
|
146
|
-
* because the package boundary prevents importing from `src/`. Any
|
|
147
|
-
* caller that passes an invalid id falls back to the shared default
|
|
148
|
-
* (`COPILOT_DEFAULT_AGENT_ID`) rather than throwing - the harness's
|
|
149
|
-
* job is to keep running with a safe default, not to validate config.
|
|
150
|
-
*/
|
|
151
85
|
function sanitizeAgentId(value) {
|
|
152
86
|
const trimmed = (value ?? "").trim().toLowerCase();
|
|
153
|
-
|
|
154
|
-
if (!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(trimmed)) return COPILOT_DEFAULT_AGENT_ID;
|
|
155
|
-
return trimmed;
|
|
87
|
+
return /^[a-z0-9][a-z0-9_-]{0,63}$/.test(trimmed) ? trimmed : COPILOT_DEFAULT_AGENT_ID;
|
|
156
88
|
}
|
|
157
89
|
function resolveCopilotHome(args) {
|
|
158
90
|
if (args.explicit) return resolve(args.explicit);
|
|
@@ -193,14 +125,7 @@ function readEnvTokenFallback(env) {
|
|
|
193
125
|
profileVersion: tokenFingerprint(value)
|
|
194
126
|
};
|
|
195
127
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Non-reversible 12-hex-char fingerprint of a token, prefixed with
|
|
198
|
-
* `sha256:` for forward-compat. Used as the pool-key profileVersion when
|
|
199
|
-
* a token comes from env: rotation -> different fingerprint -> pool
|
|
200
|
-
* entry invalidated cleanly. 48 bits of entropy is sufficient
|
|
201
|
-
* collision resistance for a per-agent client pool; never log the
|
|
202
|
-
* fingerprint alongside an account id.
|
|
203
|
-
*/
|
|
128
|
+
/** Pool invalidation fingerprint; never log it alongside an account id. */
|
|
204
129
|
function tokenFingerprint(token) {
|
|
205
130
|
return `sha256:${createHash("sha256").update(token).digest("hex").slice(0, 12)}`;
|
|
206
131
|
}
|
|
@@ -252,7 +177,10 @@ async function createCopilotByokProxy(resolvedProvider) {
|
|
|
252
177
|
provider: {
|
|
253
178
|
...providerConfig,
|
|
254
179
|
baseUrl: sdkBaseUrl,
|
|
255
|
-
...proxyCredentialHeader ? { headers:
|
|
180
|
+
...proxyCredentialHeader ? { headers: {
|
|
181
|
+
...providerConfig.headers,
|
|
182
|
+
[proxyCredentialHeader]: nonce
|
|
183
|
+
} } : {}
|
|
256
184
|
}
|
|
257
185
|
},
|
|
258
186
|
close: async () => {
|
|
@@ -360,12 +288,6 @@ function normalizeProxyRequestHeaders(headers, proxyCredentialHeader) {
|
|
|
360
288
|
out["accept-encoding"] = "identity";
|
|
361
289
|
return out;
|
|
362
290
|
}
|
|
363
|
-
function buildSdkProviderHeaders(headers, proxyCredentialHeader, proxyCredential) {
|
|
364
|
-
return {
|
|
365
|
-
...headers,
|
|
366
|
-
[proxyCredentialHeader]: proxyCredential
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
291
|
function createProxyCredentialHeaderName(headers) {
|
|
370
292
|
for (;;) {
|
|
371
293
|
const name = `${PROXY_CREDENTIAL_HEADER_PREFIX}${randomBytes(12).toString("hex")}`;
|
|
@@ -417,8 +339,34 @@ function isContentEncodingHeader(key) {
|
|
|
417
339
|
}
|
|
418
340
|
}
|
|
419
341
|
function trimTrailingSlash(pathname) {
|
|
420
|
-
|
|
421
|
-
|
|
342
|
+
return pathname.replace(/\/+$/, "");
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region extensions/copilot/src/history-compaction.ts
|
|
346
|
+
function throwIfAborted(signal) {
|
|
347
|
+
if (!signal?.aborted) return;
|
|
348
|
+
const reason = "reason" in signal ? signal.reason : void 0;
|
|
349
|
+
if (reason instanceof Error) throw reason;
|
|
350
|
+
const error = reason ? new Error("aborted", { cause: reason }) : /* @__PURE__ */ new Error("aborted");
|
|
351
|
+
error.name = "AbortError";
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
function isStaleSdkSessionError(error) {
|
|
355
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
356
|
+
return /\b(404|not found|no such session|unknown session|stale|deleted|does not exist)\b/i.test(message);
|
|
357
|
+
}
|
|
358
|
+
function buildCopilotCompactionHookContext(params) {
|
|
359
|
+
return {
|
|
360
|
+
...params.runId ? { runId: params.runId } : {},
|
|
361
|
+
agentId: params.agentId,
|
|
362
|
+
sessionKey: params.sessionKey,
|
|
363
|
+
sessionId: params.sessionId,
|
|
364
|
+
workspaceDir: params.workspaceDir,
|
|
365
|
+
modelProviderId: params.provider,
|
|
366
|
+
modelId: params.model,
|
|
367
|
+
trigger: params.trigger,
|
|
368
|
+
...buildAgentHookContextChannelFields(params)
|
|
369
|
+
};
|
|
422
370
|
}
|
|
423
371
|
//#endregion
|
|
424
372
|
//#region extensions/copilot/src/provider-bridge.ts
|
|
@@ -465,7 +413,7 @@ function resolveCopilotProvider(params) {
|
|
|
465
413
|
if (params.model.provider.trim().toLowerCase() === "github-copilot") return { mode: "github-copilot" };
|
|
466
414
|
const baseUrl = normalizeOptionalString(params.model.baseUrl);
|
|
467
415
|
if (!baseUrl) throw new Error(COPILOT_BYOK_PROVIDER_ERROR);
|
|
468
|
-
|
|
416
|
+
assertByokEndpointHostAllowed(baseUrl);
|
|
469
417
|
if (hasUnsupportedTransportPolicy(params.model)) throw new Error(COPILOT_BYOK_TRANSPORT_POLICY_ERROR);
|
|
470
418
|
const api = normalizeOptionalString(params.model.api)?.toLowerCase() ?? "openai-responses";
|
|
471
419
|
const provider = resolveProviderType(api, baseUrl, params.model.azureApiVersion);
|
|
@@ -506,10 +454,11 @@ function isCopilotByokUnsupportedProviderError(error) {
|
|
|
506
454
|
return error instanceof Error && (error.message === COPILOT_BYOK_PROVIDER_ERROR || error.message === COPILOT_BYOK_TRANSPORT_POLICY_ERROR || error.message === COPILOT_BYOK_ENDPOINT_POLICY_ERROR);
|
|
507
455
|
}
|
|
508
456
|
function supportsCopilotByokProviderShape(model) {
|
|
509
|
-
|
|
457
|
+
const baseUrl = normalizeOptionalString(model.baseUrl);
|
|
458
|
+
if (!baseUrl || hasUnsupportedTransportPolicy(model)) return false;
|
|
510
459
|
try {
|
|
511
|
-
resolveProviderType(normalizeOptionalString(model.api)?.toLowerCase() ?? "openai-responses",
|
|
512
|
-
assertByokEndpointHostAllowed(
|
|
460
|
+
resolveProviderType(normalizeOptionalString(model.api)?.toLowerCase() ?? "openai-responses", baseUrl, void 0);
|
|
461
|
+
assertByokEndpointHostAllowed(baseUrl);
|
|
513
462
|
return true;
|
|
514
463
|
} catch {
|
|
515
464
|
return false;
|
|
@@ -539,9 +488,6 @@ function normalizeCredentialQueryParamName(name) {
|
|
|
539
488
|
return stripped.toLowerCase().replace(/[-_]/g, "");
|
|
540
489
|
}
|
|
541
490
|
}
|
|
542
|
-
function assertByokEndpointAllowed(baseUrl) {
|
|
543
|
-
assertByokEndpointHostAllowed(baseUrl);
|
|
544
|
-
}
|
|
545
491
|
function resolveProviderType(api, baseUrl, azureApiVersion) {
|
|
546
492
|
switch (api) {
|
|
547
493
|
case "anthropic-messages": return {
|
|
@@ -619,7 +565,7 @@ function sessionAuthFields(auth) {
|
|
|
619
565
|
function sessionAuthMatches(stored, current) {
|
|
620
566
|
if (stored.authMode !== current.authMode) return false;
|
|
621
567
|
if (stored.authMode === "useLoggedInUser") return true;
|
|
622
|
-
return
|
|
568
|
+
return stored.authProfileId === current.authProfileId && stored.authProfileVersion === current.authProfileVersion;
|
|
623
569
|
}
|
|
624
570
|
function normalizeBinding(value) {
|
|
625
571
|
if (!value || value.schemaVersion !== 2 || typeof value.sdkSessionId !== "string" || value.sdkSessionId.trim() === "" || typeof value.compatKey !== "string" || value.compatKey.trim() === "" || typeof value.compactKey !== "string" || value.compactKey.trim() === "" || value.journalVersion !== void 0 && value.journalVersion !== 1 || value.authMode !== "gitHubToken" && value.authMode !== "byok" && value.authMode !== "useLoggedInUser" || (value.authMode === "gitHubToken" || value.authMode === "byok") && (typeof value.authProfileId !== "string" || value.authProfileId.trim() === "" || typeof value.authProfileVersion !== "string" || value.authProfileVersion.trim() === "") || typeof value.updatedAt !== "number" || !Number.isFinite(value.updatedAt)) return;
|
|
@@ -676,19 +622,8 @@ async function deleteStoredBinding(store, key) {
|
|
|
676
622
|
return false;
|
|
677
623
|
}
|
|
678
624
|
}
|
|
679
|
-
function throwIfAborted(signal) {
|
|
680
|
-
if (!signal?.aborted) return;
|
|
681
|
-
const reason = "reason" in signal ? signal.reason : void 0;
|
|
682
|
-
if (reason instanceof Error) throw reason;
|
|
683
|
-
const error = reason ? new Error("aborted", { cause: reason }) : /* @__PURE__ */ new Error("aborted");
|
|
684
|
-
error.name = "AbortError";
|
|
685
|
-
throw error;
|
|
686
|
-
}
|
|
687
|
-
function isStaleSdkSessionError(error) {
|
|
688
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
689
|
-
return /\b(404|not found|no such session|unknown session|stale|deleted|does not exist)\b/i.test(message);
|
|
690
|
-
}
|
|
691
625
|
async function compactTrackedSdkSession(params) {
|
|
626
|
+
params.assertCurrent();
|
|
692
627
|
throwIfAborted(params.abortSignal);
|
|
693
628
|
const session = await params.client.resumeSession(params.sdkSessionId, {
|
|
694
629
|
...params.sessionConfig,
|
|
@@ -699,6 +634,7 @@ async function compactTrackedSdkSession(params) {
|
|
|
699
634
|
params.onSession?.(session);
|
|
700
635
|
const request = params.customInstructions?.trim() ? { customInstructions: params.customInstructions } : void 0;
|
|
701
636
|
try {
|
|
637
|
+
params.assertCurrent();
|
|
702
638
|
throwIfAborted(params.abortSignal);
|
|
703
639
|
return await session.rpc.history.compact(request);
|
|
704
640
|
} finally {
|
|
@@ -827,19 +763,6 @@ function computeCompactRequestKey(params) {
|
|
|
827
763
|
includeAuth: false
|
|
828
764
|
});
|
|
829
765
|
}
|
|
830
|
-
function buildCopilotCompactionHookContext(params) {
|
|
831
|
-
return {
|
|
832
|
-
...params.runId ? { runId: params.runId } : {},
|
|
833
|
-
agentId: params.agentId,
|
|
834
|
-
sessionKey: params.sessionKey,
|
|
835
|
-
sessionId: params.sessionId,
|
|
836
|
-
workspaceDir: params.workspaceDir,
|
|
837
|
-
modelProviderId: params.provider,
|
|
838
|
-
modelId: params.model,
|
|
839
|
-
trigger: params.trigger,
|
|
840
|
-
...buildAgentHookContextChannelFields(params)
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
766
|
function createCopilotAgentHarness(options) {
|
|
844
767
|
let poolPromise;
|
|
845
768
|
let createdPool;
|
|
@@ -862,7 +785,7 @@ function createCopilotAgentHarness(options) {
|
|
|
862
785
|
async function getPool() {
|
|
863
786
|
if (options?.pool) return options.pool;
|
|
864
787
|
if (!poolPromise) poolPromise = (async () => {
|
|
865
|
-
const { createCopilotClientPool } = await import("./runtime-
|
|
788
|
+
const { createCopilotClientPool } = await import("./runtime-CWI9o_Vc.mjs");
|
|
866
789
|
createdPool = createCopilotClientPool(options?.poolOptions);
|
|
867
790
|
return createdPool;
|
|
868
791
|
})();
|
|
@@ -897,9 +820,9 @@ function createCopilotAgentHarness(options) {
|
|
|
897
820
|
await Promise.allSettled(pending.map(([cleanup]) => cleanup));
|
|
898
821
|
}
|
|
899
822
|
async function runHarnessAttempt(params, operation) {
|
|
900
|
-
|
|
823
|
+
return trackOperation(async () => {
|
|
901
824
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
|
|
902
|
-
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-
|
|
825
|
+
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-CRiSJYXq.mjs");
|
|
903
826
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
904
827
|
const pool = await getPool();
|
|
905
828
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
@@ -939,11 +862,8 @@ function createCopilotAgentHarness(options) {
|
|
|
939
862
|
onToolResult: void 0,
|
|
940
863
|
onToolStreamBoundary: void 0
|
|
941
864
|
} : {},
|
|
942
|
-
initialReplayState:
|
|
943
|
-
...
|
|
944
|
-
sdkSessionId: resumableSessionId
|
|
945
|
-
} : {
|
|
946
|
-
...params.initialReplayState,
|
|
865
|
+
initialReplayState: {
|
|
866
|
+
...operation === "attempt" ? params.initialReplayState : void 0,
|
|
947
867
|
...resumableBinding?.journalVersion === 1 ? { journalValidated: true } : {},
|
|
948
868
|
sdkSessionId: resumableSessionId
|
|
949
869
|
}
|
|
@@ -1025,31 +945,19 @@ function createCopilotAgentHarness(options) {
|
|
|
1025
945
|
});
|
|
1026
946
|
}
|
|
1027
947
|
return result;
|
|
1028
|
-
})
|
|
1029
|
-
inFlight.add(attemptPromise);
|
|
1030
|
-
try {
|
|
1031
|
-
return await attemptPromise;
|
|
1032
|
-
} finally {
|
|
1033
|
-
inFlight.delete(attemptPromise);
|
|
1034
|
-
}
|
|
948
|
+
});
|
|
1035
949
|
}
|
|
1036
950
|
async function runIsolatedCompletionV2(params) {
|
|
1037
|
-
|
|
951
|
+
return trackOperation(async () => {
|
|
1038
952
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start isolated completion");
|
|
1039
|
-
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-
|
|
953
|
+
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-ClBsnNg8.mjs");
|
|
1040
954
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
1041
955
|
return await runCopilotIsolatedCompletion(params, async () => {
|
|
1042
956
|
const pool = await getPool();
|
|
1043
957
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
1044
958
|
return pool;
|
|
1045
959
|
});
|
|
1046
|
-
})
|
|
1047
|
-
inFlight.add(completionPromise);
|
|
1048
|
-
try {
|
|
1049
|
-
return await completionPromise;
|
|
1050
|
-
} finally {
|
|
1051
|
-
inFlight.delete(completionPromise);
|
|
1052
|
-
}
|
|
960
|
+
});
|
|
1053
961
|
}
|
|
1054
962
|
return {
|
|
1055
963
|
id: options?.id ?? "copilot",
|
|
@@ -1123,6 +1031,9 @@ function createCopilotAgentHarness(options) {
|
|
|
1123
1031
|
}),
|
|
1124
1032
|
compact: (params) => trackOperation(async () => {
|
|
1125
1033
|
if (disposed) return;
|
|
1034
|
+
const hostCapabilities = params.hostCapabilities;
|
|
1035
|
+
if (hostCapabilities?.kind !== "agent-harness-host-capability" || hostCapabilities.version !== 1 || typeof hostCapabilities.assertActive !== "function" || typeof hostCapabilities.retainSourceAuthority !== "function") throw new Error("This host did not provide compaction source authority. Update OpenClaw before compacting this session.");
|
|
1036
|
+
hostCapabilities.assertActive();
|
|
1126
1037
|
const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
|
|
1127
1038
|
if (!openclawSessionId) return {
|
|
1128
1039
|
ok: false,
|
|
@@ -1137,9 +1048,8 @@ function createCopilotAgentHarness(options) {
|
|
|
1137
1048
|
};
|
|
1138
1049
|
const tracked = trackedSessions.get(openclawSessionId);
|
|
1139
1050
|
const currentCompactKey = computeCompactRequestKey(params);
|
|
1140
|
-
const { resolvePoolAcquire } = await import("./attempt-
|
|
1051
|
+
const { resolvePoolAcquire } = await import("./attempt-CRiSJYXq.mjs");
|
|
1141
1052
|
let resolvedPoolAcquire;
|
|
1142
|
-
let currentAuth;
|
|
1143
1053
|
try {
|
|
1144
1054
|
resolvedPoolAcquire = resolvePoolAcquire(params);
|
|
1145
1055
|
} catch (error) {
|
|
@@ -1151,7 +1061,7 @@ function createCopilotAgentHarness(options) {
|
|
|
1151
1061
|
};
|
|
1152
1062
|
throw error;
|
|
1153
1063
|
}
|
|
1154
|
-
|
|
1064
|
+
const currentAuth = sessionAuthFields(resolvedPoolAcquire.auth);
|
|
1155
1065
|
const compatibleTracked = tracked?.compactKey === currentCompactKey && sessionAuthMatches(tracked, currentAuth) ? tracked : void 0;
|
|
1156
1066
|
if (!compatibleTracked) return {
|
|
1157
1067
|
ok: false,
|
|
@@ -1187,8 +1097,10 @@ function createCopilotAgentHarness(options) {
|
|
|
1187
1097
|
sessionFile: params.sessionFile,
|
|
1188
1098
|
ctx: hookContext
|
|
1189
1099
|
});
|
|
1100
|
+
hostCapabilities.assertActive();
|
|
1190
1101
|
compactResult = await compactWithSafetyTimeout((abortSignal) => compactTrackedSdkSession({
|
|
1191
1102
|
abortSignal,
|
|
1103
|
+
assertCurrent: hostCapabilities.assertActive,
|
|
1192
1104
|
client,
|
|
1193
1105
|
customInstructions: params.customInstructions,
|
|
1194
1106
|
gitHubToken: compatibleTracked?.clientOptions.gitHubToken ?? (resolvedPoolAcquire?.auth.authMode === "gitHubToken" ? resolvedPoolAcquire.auth.gitHubToken : void 0),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveCopilotProvider, o as tokenFingerprint, r as createCopilotByokProxy } from "./harness-
|
|
1
|
+
import { n as resolveCopilotProvider, o as tokenFingerprint, r as createCopilotByokProxy } from "./harness-BAWs53-w.mjs";
|
|
2
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,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.14" };
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region extensions/copilot/src/sdk-loader.ts
|
|
11
11
|
function resolveCopilotSdkFallbackDir(env = process.env) {
|
|
@@ -90,7 +90,6 @@ function createCopilotClientPool(options = {}) {
|
|
|
90
90
|
return new (await (loadCopilotSdk())).CopilotClient(clientOptions);
|
|
91
91
|
});
|
|
92
92
|
const idleTtlMs = options.idleTtlMs ?? DEFAULT_IDLE_TTL_MS;
|
|
93
|
-
const now = options.now ?? Date.now;
|
|
94
93
|
const entries = /* @__PURE__ */ new Map();
|
|
95
94
|
const releasedHandles = /* @__PURE__ */ new WeakSet();
|
|
96
95
|
let disposed = false;
|
|
@@ -102,11 +101,6 @@ function createCopilotClientPool(options = {}) {
|
|
|
102
101
|
};
|
|
103
102
|
const stopReadyOrIdleEntry = (entry, client, idleTimer) => {
|
|
104
103
|
if (idleTimer) clearTimeout(idleTimer);
|
|
105
|
-
if (entry.stopRan) {
|
|
106
|
-
if (entry.state.kind === "stopping") return entry.state.promise;
|
|
107
|
-
if (entry.state.kind === "stopped") return Promise.resolve([]);
|
|
108
|
-
}
|
|
109
|
-
entry.stopRan = true;
|
|
110
104
|
const stopPromise = (async () => {
|
|
111
105
|
try {
|
|
112
106
|
return await client.stop();
|
|
@@ -147,22 +141,11 @@ function createCopilotClientPool(options = {}) {
|
|
|
147
141
|
client,
|
|
148
142
|
idleTimer: setTimeout(() => {
|
|
149
143
|
stopEntry(entry);
|
|
150
|
-
}, idleTtlMs)
|
|
151
|
-
idleSinceMs: now()
|
|
144
|
+
}, idleTtlMs)
|
|
152
145
|
};
|
|
153
146
|
};
|
|
154
147
|
const createEntry = (key, cacheKey, clientOptions) => {
|
|
155
|
-
const
|
|
156
|
-
key,
|
|
157
|
-
cacheKey,
|
|
158
|
-
refCount: 1,
|
|
159
|
-
stopRan: false,
|
|
160
|
-
state: {
|
|
161
|
-
kind: "creating",
|
|
162
|
-
promise: Promise.resolve(void 0)
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
const createPromise = (async () => {
|
|
148
|
+
const createPromise = Promise.resolve().then(async () => {
|
|
166
149
|
try {
|
|
167
150
|
const client = await sdkFactory(clientOptions);
|
|
168
151
|
entry.state = {
|
|
@@ -175,10 +158,15 @@ function createCopilotClientPool(options = {}) {
|
|
|
175
158
|
maybeDeleteEntry(entry);
|
|
176
159
|
throw toStringifiedError(error);
|
|
177
160
|
}
|
|
178
|
-
})
|
|
179
|
-
entry
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
});
|
|
162
|
+
const entry = {
|
|
163
|
+
key,
|
|
164
|
+
cacheKey,
|
|
165
|
+
refCount: 1,
|
|
166
|
+
state: {
|
|
167
|
+
kind: "creating",
|
|
168
|
+
promise: createPromise
|
|
169
|
+
}
|
|
182
170
|
};
|
|
183
171
|
entries.set(cacheKey, entry);
|
|
184
172
|
return {
|
|
@@ -195,36 +183,29 @@ function createCopilotClientPool(options = {}) {
|
|
|
195
183
|
const existing = entries.get(cacheKey);
|
|
196
184
|
if (!existing) {
|
|
197
185
|
const created = createEntry(key, cacheKey, clientOptions);
|
|
198
|
-
|
|
199
|
-
|
|
186
|
+
const client = await created.createPromise;
|
|
187
|
+
if (disposed) {
|
|
188
|
+
await stopEntry(created.entry);
|
|
189
|
+
throw createDisposedError();
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
key: created.entry.key,
|
|
193
|
+
client
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
switch (existing.state.kind) {
|
|
197
|
+
case "creating": {
|
|
198
|
+
existing.refCount += 1;
|
|
199
|
+
const client = await existing.state.promise;
|
|
200
200
|
if (disposed) {
|
|
201
|
-
await stopEntry(
|
|
201
|
+
await stopEntry(existing);
|
|
202
202
|
throw createDisposedError();
|
|
203
203
|
}
|
|
204
204
|
return {
|
|
205
|
-
key:
|
|
205
|
+
key: existing.key,
|
|
206
206
|
client
|
|
207
207
|
};
|
|
208
|
-
} catch (error) {
|
|
209
|
-
throw toStringifiedError(error);
|
|
210
208
|
}
|
|
211
|
-
}
|
|
212
|
-
switch (existing.state.kind) {
|
|
213
|
-
case "creating":
|
|
214
|
-
existing.refCount += 1;
|
|
215
|
-
try {
|
|
216
|
-
const client = await existing.state.promise;
|
|
217
|
-
if (disposed) {
|
|
218
|
-
await stopEntry(existing);
|
|
219
|
-
throw createDisposedError();
|
|
220
|
-
}
|
|
221
|
-
return {
|
|
222
|
-
key: existing.key,
|
|
223
|
-
client
|
|
224
|
-
};
|
|
225
|
-
} catch (error) {
|
|
226
|
-
throw toStringifiedError(error);
|
|
227
|
-
}
|
|
228
209
|
case "ready":
|
|
229
210
|
existing.refCount += 1;
|
|
230
211
|
return {
|
package/dist/harness.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "./.setup/harness-
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./.setup/harness-BAWs53-w.mjs";
|
|
2
2
|
export { createCopilotAgentHarness };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "./.setup/harness-
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./.setup/harness-BAWs53-w.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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/copilot",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.7",
|
|
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.14"
|
|
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.7"
|
|
28
28
|
},
|
|
29
29
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.9.
|
|
30
|
+
"openclawVersion": "2026.9.7",
|
|
31
31
|
"bundledDist": false
|
|
32
32
|
},
|
|
33
33
|
"release": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"assets/activity.svg"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"openclaw": ">=2026.9.
|
|
50
|
+
"openclaw": ">=2026.9.7"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"openclaw": {
|