@openclaw/copilot 2026.8.2 → 2026.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{attempt-5q0X0LCu.js → attempt-Ls_qYja7.js} +30 -16
- package/dist/{harness-Bmmbz3QS.js → harness-V2lGlWa5.js} +38 -11
- package/dist/harness.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{isolated-completion-BYHkro0M.js → isolated-completion-DxQ0E51R.js} +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as resolveCopilotAuth, i as createCopilotByokAuth, n as resolveCopilotProvider, r as createCopilotByokProxy } from "./harness-
|
|
1
|
+
import { a as resolveCopilotAuth, i as createCopilotByokAuth, n as resolveCopilotProvider, r as createCopilotByokProxy } from "./harness-V2lGlWa5.js";
|
|
2
2
|
import { n as normalizeCopilotUsage, r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.js";
|
|
3
|
-
import { asNonArrayRecord, normalizeOptionalString, normalizeUniqueStringEntries, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
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, callGatewayTool, cancelPendingAgentQuestionForSession, claimPendingAgentQuestionAnswer, clearActiveEmbeddedRun, detectAndLoadAgentHarnessPromptImages, embeddedAgentLog, extractToolErrorMessage, getModelProviderRequestTransport, getPluginToolMeta, getPluginToolSideEffectOwnerKey, isHostScopedAgentToolActive, isSubagentSessionKey, isToolResultError, projectAgentHarnessTranscriptMessageForDisplay, resolveAgentDir, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptFsWorkspaceOnly, resolveAttemptSpawnWorkspaceDir, resolveBootstrapContextForRun, resolveCompactionTimeoutMs, resolveEmbeddedAttemptToolConstructionPlan, resolveMainSessionDelegationMode, resolveModelAuthMode, resolveSandboxContext, resolveUserPath, runAgentEndSideEffects, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessGatewayQuestion, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, sanitizeToolResult, setActiveEmbeddedRun } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { formatErrorMessage, toErrorObject, toStringifiedError, toStringifiedError as toCopilotError } from "openclaw/plugin-sdk/error-runtime";
|
|
@@ -326,6 +326,7 @@ function createResult(params, state) {
|
|
|
326
326
|
} : { kind: "ok" };
|
|
327
327
|
return {
|
|
328
328
|
terminal: promptError !== void 0 ? withPromptFailure(interruption, promptError) : interruption,
|
|
329
|
+
...state.acceptedSessionSpawns?.length ? { acceptedSessionSpawns: state.acceptedSessionSpawns } : {},
|
|
329
330
|
...state.assistantTranscriptOwned ? {
|
|
330
331
|
assistantTranscriptOwned: true,
|
|
331
332
|
...state.assistantTranscriptIdempotencyKey ? { assistantTranscriptIdempotencyKey: state.assistantTranscriptIdempotencyKey } : {}
|
|
@@ -1393,7 +1394,7 @@ async function waitForPersistenceReceipt(receipt, requestedTimeoutMs) {
|
|
|
1393
1394
|
//#endregion
|
|
1394
1395
|
//#region extensions/copilot/src/attempt-finalize.ts
|
|
1395
1396
|
async function completeCopilotAttempt(params) {
|
|
1396
|
-
const { 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;
|
|
1397
|
+
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;
|
|
1397
1398
|
const snap = bridge?.snapshot();
|
|
1398
1399
|
const assistantTexts = bridge?.finalizeAssistantTexts() ?? [];
|
|
1399
1400
|
const lastAssistant = bridge?.buildAssistantMessage({
|
|
@@ -1405,6 +1406,7 @@ async function completeCopilotAttempt(params) {
|
|
|
1405
1406
|
const currentRunUserKey = `${input.runId}:user`;
|
|
1406
1407
|
const messagesSnapshot = transcript?.messagesSnapshot ?? (recorder?.isBlocked() ? removePreparedUser(messages, recorder.message, currentRunUserKey) : includePreparedUser(messages, recorder?.message, input.trigger === "memory", currentRunUserKey));
|
|
1407
1408
|
const result = createResult(input, {
|
|
1409
|
+
acceptedSessionSpawns,
|
|
1408
1410
|
aborted,
|
|
1409
1411
|
assistantTexts,
|
|
1410
1412
|
codeModeEngaged,
|
|
@@ -3061,6 +3063,7 @@ async function runCopilotExecution(context) {
|
|
|
3061
3063
|
let resumeFailureRecovered = false;
|
|
3062
3064
|
let yieldDetected = false;
|
|
3063
3065
|
let yieldAcknowledgment;
|
|
3066
|
+
const acceptedSessionSpawns = [];
|
|
3064
3067
|
let lastToolError;
|
|
3065
3068
|
const hostObserveToolTerminal = input.observeToolTerminal;
|
|
3066
3069
|
const observeToolTerminal = hostObserveToolTerminal ? (observation) => {
|
|
@@ -3182,19 +3185,29 @@ async function runCopilotExecution(context) {
|
|
|
3182
3185
|
yieldDetected = true;
|
|
3183
3186
|
yieldAcknowledgment = acknowledgment;
|
|
3184
3187
|
},
|
|
3185
|
-
onToolCompleted: ({ args, error, result, startedAt, toolCallId, toolName }) =>
|
|
3186
|
-
toolName
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3188
|
+
onToolCompleted: async ({ args, error, result, startedAt, toolCallId, toolName }) => {
|
|
3189
|
+
const acceptedSessionSpawnDetails = toolName === "sessions_spawn" && !error ? asOptionalRecord(asOptionalRecord(result)?.details) : void 0;
|
|
3190
|
+
const runId = normalizeOptionalString(acceptedSessionSpawnDetails?.runId);
|
|
3191
|
+
const childSessionKey = normalizeOptionalString(acceptedSessionSpawnDetails?.childSessionKey);
|
|
3192
|
+
if (acceptedSessionSpawnDetails?.status === "accepted" && runId && childSessionKey) acceptedSessionSpawns.push({
|
|
3193
|
+
runId,
|
|
3194
|
+
childSessionKey,
|
|
3195
|
+
expectsCompletionMessage: acceptedSessionSpawnDetails.expectsCompletionMessage === true
|
|
3196
|
+
});
|
|
3197
|
+
await runAgentHarnessAfterToolCallHook({
|
|
3198
|
+
toolName,
|
|
3199
|
+
toolCallId,
|
|
3200
|
+
runId: input.runId,
|
|
3201
|
+
agentId: sessionAgentId,
|
|
3202
|
+
sessionId: input.sessionId,
|
|
3203
|
+
sessionKey: hookContext.sessionKey,
|
|
3204
|
+
channelId: hookContext.channelId,
|
|
3205
|
+
startArgs: args,
|
|
3206
|
+
...result !== void 0 ? { result } : {},
|
|
3207
|
+
...error ? { error } : {},
|
|
3208
|
+
startedAt
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
3198
3211
|
});
|
|
3199
3212
|
cleanupToolBridge = toolBridge.cleanup;
|
|
3200
3213
|
codeModeEngaged = toolBridge.codeModeEngaged;
|
|
@@ -3448,6 +3461,7 @@ async function runCopilotExecution(context) {
|
|
|
3448
3461
|
}
|
|
3449
3462
|
}
|
|
3450
3463
|
return await completeCopilotAttempt({
|
|
3464
|
+
acceptedSessionSpawns,
|
|
3451
3465
|
aborted,
|
|
3452
3466
|
attemptStartedAt,
|
|
3453
3467
|
bridge,
|
|
@@ -1,6 +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 { createHash, randomBytes } from "node:crypto";
|
|
3
|
+
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
6
|
import { createServer } from "node:http";
|
|
@@ -206,6 +206,7 @@ function tokenFingerprint(token) {
|
|
|
206
206
|
//#endregion
|
|
207
207
|
//#region extensions/copilot/src/byok-proxy.ts
|
|
208
208
|
const LOOPBACK_HOST = "127.0.0.1";
|
|
209
|
+
const PROXY_CREDENTIAL_HEADER_PREFIX = "x-openclaw-copilot-byok-";
|
|
209
210
|
async function createCopilotByokProxy(resolvedProvider) {
|
|
210
211
|
if (resolvedProvider.mode !== "byok") return;
|
|
211
212
|
const providerConfig = resolvedProvider.provider;
|
|
@@ -215,6 +216,7 @@ async function createCopilotByokProxy(resolvedProvider) {
|
|
|
215
216
|
const targetPathPrefix = trimTrailingSlash(targetBaseUrl.pathname);
|
|
216
217
|
const proxyPathPrefix = `/${nonce}${targetPathPrefix}`;
|
|
217
218
|
const acceptsAzureSdkPaths = providerConfig.type === "azure";
|
|
219
|
+
const proxyCredentialHeader = acceptsAzureSdkPaths ? createProxyCredentialHeaderName(providerConfig.headers) : void 0;
|
|
218
220
|
const upstreamBearerAuthorization = resolveUpstreamBearerAuthorization(providerConfig);
|
|
219
221
|
const activeFetches = /* @__PURE__ */ new Set();
|
|
220
222
|
const server = createServer((req, res) => {
|
|
@@ -222,6 +224,8 @@ async function createCopilotByokProxy(resolvedProvider) {
|
|
|
222
224
|
acceptsAzureSdkPaths,
|
|
223
225
|
activeFetches,
|
|
224
226
|
proxyPathPrefix,
|
|
227
|
+
proxyCredential: nonce,
|
|
228
|
+
proxyCredentialHeader,
|
|
225
229
|
targetBaseUrl,
|
|
226
230
|
targetPathPrefix,
|
|
227
231
|
upstreamBearerAuthorization
|
|
@@ -246,7 +250,8 @@ async function createCopilotByokProxy(resolvedProvider) {
|
|
|
246
250
|
...resolvedProvider,
|
|
247
251
|
provider: {
|
|
248
252
|
...providerConfig,
|
|
249
|
-
baseUrl: sdkBaseUrl
|
|
253
|
+
baseUrl: sdkBaseUrl,
|
|
254
|
+
...proxyCredentialHeader ? { headers: buildSdkProviderHeaders(providerConfig.headers, proxyCredentialHeader, nonce) } : {}
|
|
250
255
|
}
|
|
251
256
|
},
|
|
252
257
|
close: async () => {
|
|
@@ -268,9 +273,9 @@ async function handleProxyRequest(req, res, params) {
|
|
|
268
273
|
if (!res.writableEnded) abortUpstream();
|
|
269
274
|
});
|
|
270
275
|
try {
|
|
271
|
-
const
|
|
276
|
+
const isNonceProtected = isNonceProtectedProxyRequest(req, params.proxyPathPrefix);
|
|
272
277
|
const url = resolveTargetUrl(req, params);
|
|
273
|
-
if (!url) {
|
|
278
|
+
if (!url || !isNonceProtected && (!params.proxyCredentialHeader || !hasValidProxyCredential(req, params.proxyCredentialHeader, params.proxyCredential))) {
|
|
274
279
|
res.writeHead(404);
|
|
275
280
|
res.end("Not found");
|
|
276
281
|
return;
|
|
@@ -280,7 +285,10 @@ async function handleProxyRequest(req, res, params) {
|
|
|
280
285
|
url: url.toString(),
|
|
281
286
|
init: {
|
|
282
287
|
method: req.method,
|
|
283
|
-
headers: buildProxyRequestHeaders(req.headers, {
|
|
288
|
+
headers: buildProxyRequestHeaders(req.headers, {
|
|
289
|
+
upstreamBearerAuthorization: isNonceProtected ? params.upstreamBearerAuthorization : void 0,
|
|
290
|
+
proxyCredentialHeader: params.proxyCredentialHeader
|
|
291
|
+
}),
|
|
284
292
|
signal: upstreamAbort.signal,
|
|
285
293
|
...body ? { body } : {}
|
|
286
294
|
},
|
|
@@ -329,23 +337,42 @@ function isNonceProtectedProxyRequest(req, proxyPathPrefix) {
|
|
|
329
337
|
const incomingUrl = new URL(req.url ?? "/", `http://${LOOPBACK_HOST}`);
|
|
330
338
|
return incomingUrl.pathname === proxyPathPrefix || incomingUrl.pathname.startsWith(`${proxyPathPrefix}/`);
|
|
331
339
|
}
|
|
340
|
+
function hasValidProxyCredential(req, headerName, expected) {
|
|
341
|
+
const received = req.headers[headerName];
|
|
342
|
+
if (typeof received !== "string") return false;
|
|
343
|
+
const receivedBytes = Buffer.from(received);
|
|
344
|
+
const expectedBytes = Buffer.from(expected);
|
|
345
|
+
return receivedBytes.length === expectedBytes.length && timingSafeEqual(receivedBytes, expectedBytes);
|
|
346
|
+
}
|
|
332
347
|
async function readBody(req) {
|
|
333
348
|
const chunks = [];
|
|
334
349
|
for await (const chunk of req) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
335
350
|
return chunks.length > 0 ? Buffer.concat(chunks) : void 0;
|
|
336
351
|
}
|
|
337
|
-
function normalizeProxyRequestHeaders(headers) {
|
|
352
|
+
function normalizeProxyRequestHeaders(headers, proxyCredentialHeader) {
|
|
338
353
|
const out = {};
|
|
339
354
|
for (const [key, value] of Object.entries(headers)) {
|
|
340
|
-
if (isHopByHopHeader(key) || key.toLowerCase() === "accept-encoding") continue;
|
|
355
|
+
if (isHopByHopHeader(key) || key.toLowerCase() === "accept-encoding" || key.toLowerCase() === proxyCredentialHeader) continue;
|
|
341
356
|
const normalized = normalizeHeaderValue(value);
|
|
342
357
|
if (normalized !== void 0) out[key] = normalized;
|
|
343
358
|
}
|
|
344
359
|
out["accept-encoding"] = "identity";
|
|
345
360
|
return out;
|
|
346
361
|
}
|
|
362
|
+
function buildSdkProviderHeaders(headers, proxyCredentialHeader, proxyCredential) {
|
|
363
|
+
return {
|
|
364
|
+
...headers,
|
|
365
|
+
[proxyCredentialHeader]: proxyCredential
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function createProxyCredentialHeaderName(headers) {
|
|
369
|
+
for (;;) {
|
|
370
|
+
const name = `${PROXY_CREDENTIAL_HEADER_PREFIX}${randomBytes(12).toString("hex")}`;
|
|
371
|
+
if (!headers || !hasHeader(headers, name)) return name;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
347
374
|
function buildProxyRequestHeaders(headers, params) {
|
|
348
|
-
const out = normalizeProxyRequestHeaders(headers);
|
|
375
|
+
const out = normalizeProxyRequestHeaders(headers, params.proxyCredentialHeader);
|
|
349
376
|
if (params.upstreamBearerAuthorization && !hasHeader(out, "authorization")) out["authorization"] = params.upstreamBearerAuthorization;
|
|
350
377
|
return out;
|
|
351
378
|
}
|
|
@@ -861,7 +888,7 @@ function createCopilotAgentHarness(options) {
|
|
|
861
888
|
async function runHarnessAttempt(params, operation) {
|
|
862
889
|
const attemptPromise = (async () => {
|
|
863
890
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
|
|
864
|
-
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-
|
|
891
|
+
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-Ls_qYja7.js");
|
|
865
892
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
866
893
|
const pool = await getPool();
|
|
867
894
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
@@ -992,7 +1019,7 @@ function createCopilotAgentHarness(options) {
|
|
|
992
1019
|
async function runIsolatedCompletionV2(params) {
|
|
993
1020
|
const completionPromise = (async () => {
|
|
994
1021
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start isolated completion");
|
|
995
|
-
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-
|
|
1022
|
+
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-DxQ0E51R.js");
|
|
996
1023
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
997
1024
|
return await runCopilotIsolatedCompletion(params, async () => {
|
|
998
1025
|
const pool = await getPool();
|
|
@@ -1084,7 +1111,7 @@ function createCopilotAgentHarness(options) {
|
|
|
1084
1111
|
};
|
|
1085
1112
|
const tracked = trackedSessions.get(openclawSessionId);
|
|
1086
1113
|
const currentCompactKey = computeCompactRequestKey(params);
|
|
1087
|
-
const { resolvePoolAcquire } = await import("./attempt-
|
|
1114
|
+
const { resolvePoolAcquire } = await import("./attempt-Ls_qYja7.js");
|
|
1088
1115
|
let resolvedPoolAcquire;
|
|
1089
1116
|
let currentAuth;
|
|
1090
1117
|
try {
|
package/dist/harness.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "./harness-
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./harness-V2lGlWa5.js";
|
|
2
2
|
export { createCopilotAgentHarness };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "./harness-
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./harness-V2lGlWa5.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
|
|
@@ -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-V2lGlWa5.js";
|
|
2
2
|
import { r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.js";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
//#region extensions/copilot/src/isolated-completion.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/copilot",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.9.1",
|
|
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",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"minHostVersion": ">=2026.5.28"
|
|
25
25
|
},
|
|
26
26
|
"compat": {
|
|
27
|
-
"pluginApi": ">=2026.
|
|
27
|
+
"pluginApi": ">=2026.9.1"
|
|
28
28
|
},
|
|
29
29
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.
|
|
30
|
+
"openclawVersion": "2026.9.1",
|
|
31
31
|
"bundledDist": false
|
|
32
32
|
},
|
|
33
33
|
"release": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"README.md"
|
|
46
46
|
],
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"openclaw": ">=2026.
|
|
48
|
+
"openclaw": ">=2026.9.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"openclaw": {
|