@openclaw/copilot 2026.8.1-beta.3 → 2026.8.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-DsIndF6T.js → attempt-DwhhWgyV.js} +49 -82
- package/dist/{harness-BJ_IcIJk.js → harness-DvYbOGRx.js} +7 -12
- package/dist/harness.js +1 -1
- package/dist/index.js +9 -4
- package/dist/{isolated-completion-D9VIGPmy.js → isolated-completion-C0DfWtVO.js} +1 -1
- package/dist/{runtime-C2t8Iz5R.js → runtime-DvZQV_8v.js} +4 -1
- package/package.json +5 -5
|
@@ -1,11 +1,12 @@
|
|
|
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-DvYbOGRx.js";
|
|
2
2
|
import { n as normalizeCopilotUsage, r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.js";
|
|
3
|
-
import { normalizeOptionalString, normalizeUniqueStringEntries, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
import { SKILL_WORKSHOP_TOOL_NAME,
|
|
3
|
+
import { asNonArrayRecord, normalizeOptionalString, normalizeUniqueStringEntries, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
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";
|
|
7
7
|
import { parseDateStringTimestampMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
8
|
import fsp from "node:fs/promises";
|
|
9
|
+
import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
9
10
|
import { convertMcpCallToolResult } from "@github/copilot-sdk";
|
|
10
11
|
import { createAgentHarnessToolSurfaceRuntime } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
11
12
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -351,7 +352,7 @@ function createResult(params, state) {
|
|
|
351
352
|
messagingToolSentTexts: [],
|
|
352
353
|
replayMetadata,
|
|
353
354
|
sessionFileUsed: readNonEmptyString(params.sessionFile),
|
|
354
|
-
sessionIdUsed:
|
|
355
|
+
sessionIdUsed: params.sessionId,
|
|
355
356
|
toolMetas,
|
|
356
357
|
yieldDetected: state.yieldDetected === true,
|
|
357
358
|
...state.yieldAcknowledgment ? { yieldAcknowledgment: state.yieldAcknowledgment } : {}
|
|
@@ -542,7 +543,7 @@ function buildAssistantMessage(params) {
|
|
|
542
543
|
type: "text"
|
|
543
544
|
});
|
|
544
545
|
for (const request of toolRequests) content.push({
|
|
545
|
-
arguments: request.arguments
|
|
546
|
+
arguments: asNonArrayRecord(request.arguments),
|
|
546
547
|
id: request.toolCallId,
|
|
547
548
|
name: request.name,
|
|
548
549
|
type: "toolCall"
|
|
@@ -1345,6 +1346,7 @@ function registerCopilotActiveRun(params) {
|
|
|
1345
1346
|
const activeRunHandle = {
|
|
1346
1347
|
kind: "embedded",
|
|
1347
1348
|
runId: params.input.runId,
|
|
1349
|
+
startedAtMs: params.startedAtMs,
|
|
1348
1350
|
toolAuthorityFingerprint: params.input.toolAuthorityFingerprint,
|
|
1349
1351
|
claimPendingUserInputAnswer,
|
|
1350
1352
|
cancelPendingUserInput,
|
|
@@ -1389,7 +1391,7 @@ async function waitForPersistenceReceipt(receipt, requestedTimeoutMs) {
|
|
|
1389
1391
|
//#endregion
|
|
1390
1392
|
//#region extensions/copilot/src/attempt-finalize.ts
|
|
1391
1393
|
async function completeCopilotAttempt(params) {
|
|
1392
|
-
const { aborted, attemptStartedAt, bridge, codeModeEngaged, downgradedFromResume, externalAbort, hookContext, hookContextWindowFields, input, lastToolError, messages, nativeSessionHistoryUnvalidated, transcriptJournal, modelRef, now, promptError, releaseError, resumeFailureRecovered, sdkSessionId, sentTurnStarted,
|
|
1394
|
+
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;
|
|
1393
1395
|
const snap = bridge?.snapshot();
|
|
1394
1396
|
const assistantTexts = bridge?.finalizeAssistantTexts() ?? [];
|
|
1395
1397
|
const lastAssistant = bridge?.buildAssistantMessage({
|
|
@@ -1425,7 +1427,6 @@ async function completeCopilotAttempt(params) {
|
|
|
1425
1427
|
promptError,
|
|
1426
1428
|
resumeFailureRecovered,
|
|
1427
1429
|
sdkSessionId,
|
|
1428
|
-
sessionIdUsed,
|
|
1429
1430
|
timedOut,
|
|
1430
1431
|
timedOutDuringCompaction,
|
|
1431
1432
|
toolMetas: snap ? [...snap.toolMetas] : [],
|
|
@@ -1522,21 +1523,12 @@ async function createCopilotToolBridge(input) {
|
|
|
1522
1523
|
disableTools: attemptParams.disableTools,
|
|
1523
1524
|
forceMessageTool: shouldForceCopilotMessageTool(attemptParams),
|
|
1524
1525
|
isRawModelRun: isRawCopilotModelRun(attemptParams),
|
|
1525
|
-
toolsAllow:
|
|
1526
|
+
toolsAllow: buildEmbeddedAttemptToolRunContext({
|
|
1527
|
+
...attemptParams,
|
|
1528
|
+
forceMessageTool: shouldForceCopilotMessageTool(attemptParams)
|
|
1529
|
+
}).runtimeToolAllowlist
|
|
1526
1530
|
});
|
|
1527
|
-
|
|
1528
|
-
...toolPlan,
|
|
1529
|
-
codingToolConstructionPlan: {
|
|
1530
|
-
includeBaseCodingTools: true,
|
|
1531
|
-
includeChannelTools: true,
|
|
1532
|
-
includeOpenClawTools: true,
|
|
1533
|
-
includePluginTools: true,
|
|
1534
|
-
includeShellTools: true
|
|
1535
|
-
},
|
|
1536
|
-
constructTools: true,
|
|
1537
|
-
includeCoreTools: true
|
|
1538
|
-
} : toolPlan;
|
|
1539
|
-
if (!effectiveToolPlan.constructTools) return {
|
|
1531
|
+
if (!toolPlan.constructTools) return {
|
|
1540
1532
|
codeModeEngaged: false,
|
|
1541
1533
|
promptToolPolicy: EMPTY_PROMPT_TOOL_POLICY,
|
|
1542
1534
|
sourceTools: []
|
|
@@ -1546,26 +1538,27 @@ async function createCopilotToolBridge(input) {
|
|
|
1546
1538
|
abortSignal: input.abortSignal,
|
|
1547
1539
|
agentId: input.agentId,
|
|
1548
1540
|
config: attemptParams.config,
|
|
1541
|
+
codeModeOverride: attemptParams.codeModeOverride,
|
|
1549
1542
|
disableTools: attemptParams.disableTools,
|
|
1550
1543
|
executeTool: (toolParams) => executeCatalogTool(input, toolParams),
|
|
1551
1544
|
forceMessageTool: shouldForceCopilotMessageTool(attemptParams),
|
|
1552
1545
|
isRawModelRun: isRawCopilotModelRun(attemptParams),
|
|
1553
1546
|
model: attemptParams.model,
|
|
1547
|
+
contextTokenBudget: attemptParams.contextTokenBudget,
|
|
1554
1548
|
modelId: input.modelId,
|
|
1555
1549
|
modelProvider: input.modelProvider,
|
|
1556
1550
|
modelToolsEnabled: true,
|
|
1557
1551
|
prompt: attemptParams.prompt,
|
|
1558
1552
|
runId: attemptParams.runId,
|
|
1559
|
-
runtimeToolAllowlist:
|
|
1553
|
+
runtimeToolAllowlist: toolPlan.runtimeToolAllowlist,
|
|
1560
1554
|
sessionId: input.sessionId,
|
|
1561
1555
|
sessionKey: attemptParams.sandboxSessionKey ?? attemptParams.sessionKey ?? input.sessionKey,
|
|
1562
1556
|
scheduledToolPolicy: attemptParams.scheduledToolPolicy,
|
|
1563
|
-
skillWorkshopProposalOnly: attemptParams.skillWorkshopProposalOnly,
|
|
1564
1557
|
sourceReplyDeliveryMode: attemptParams.sourceReplyDeliveryMode,
|
|
1565
1558
|
toolsAllow: attemptParams.toolsAllow
|
|
1566
1559
|
});
|
|
1567
1560
|
const toolOptions = buildOpenClawCodingToolsOptions(input, {
|
|
1568
|
-
...
|
|
1561
|
+
...toolPlan,
|
|
1569
1562
|
runtimeToolAllowlist: toolSurfaceRuntime.runtimeToolAllowlist
|
|
1570
1563
|
}, toolSurfaceRuntime);
|
|
1571
1564
|
let sourceTools;
|
|
@@ -1583,7 +1576,7 @@ async function createCopilotToolBridge(input) {
|
|
|
1583
1576
|
} catch (error) {
|
|
1584
1577
|
throw createError(`[copilot-tool-bridge] createOpenClawCodingTools failed: ${toStringifiedError(error).message}`, error);
|
|
1585
1578
|
}
|
|
1586
|
-
const plannedSourceTools = filterCopilotToolsForConstructionPlan(applyEmbeddedAttemptToolsAllow(sourceTools, toolSurfaceRuntime.runtimeToolAllowlist, { toolMeta: (tool) => getPluginToolMeta(tool) ?? readInlinePluginToolMeta(tool) }),
|
|
1579
|
+
const plannedSourceTools = filterCopilotToolsForConstructionPlan(applyEmbeddedAttemptToolsAllow(sourceTools, toolSurfaceRuntime.runtimeToolAllowlist, { toolMeta: (tool) => getPluginToolMeta(tool) ?? readInlinePluginToolMeta(tool) }), toolPlan.codingToolConstructionPlan, { preserveToolNames: toolSurfaceRuntime.runtimeToolAllowlist });
|
|
1587
1580
|
const compactedTools = toolSurfaceRuntime.compactTools(plannedSourceTools, { localModelLeanApplied: true });
|
|
1588
1581
|
const newlyConstructedTools = compactedTools.tools.filter((tool) => !boundSourceTools.has(tool));
|
|
1589
1582
|
const boundNewlyConstructedTools = newlyConstructedTools.length > 0 ? hostCapabilities.bindToolSurface(newlyConstructedTools, bindingOptions) : newlyConstructedTools;
|
|
@@ -1604,7 +1597,14 @@ async function createCopilotToolBridge(input) {
|
|
|
1604
1597
|
cleanup: toolSurfaceRuntime.cleanup,
|
|
1605
1598
|
codeModeEngaged: toolSurfaceRuntime.codeModeControlsEnabled,
|
|
1606
1599
|
promptToolPolicy: { apply: (params = {}) => {
|
|
1607
|
-
const result = compactedTools.promptToolPolicy.apply(
|
|
1600
|
+
const result = compactedTools.promptToolPolicy.apply({
|
|
1601
|
+
...params,
|
|
1602
|
+
toolsAllow: buildEmbeddedAttemptToolRunContext({
|
|
1603
|
+
...attemptParams,
|
|
1604
|
+
toolsAllow: params.toolsAllow,
|
|
1605
|
+
forceMessageTool: shouldForceCopilotMessageTool(attemptParams)
|
|
1606
|
+
}).runtimeToolAllowlist
|
|
1607
|
+
});
|
|
1608
1608
|
const directToolNames = new Set(result.tools.map((tool) => tool.name));
|
|
1609
1609
|
return {
|
|
1610
1610
|
tools: sdkTools.filter((tool) => directToolNames.has(tool.name)),
|
|
@@ -1615,26 +1615,9 @@ async function createCopilotToolBridge(input) {
|
|
|
1615
1615
|
};
|
|
1616
1616
|
}
|
|
1617
1617
|
/**
|
|
1618
|
-
*
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1621
|
-
* Why PI parity matters: bridged OpenClaw tools register with the SDK
|
|
1622
|
-
* as `overridesBuiltInTool: true, skipPermission: true` (see
|
|
1623
|
-
* `convertOpenClawToolToSdkTool` below). That means the wrapped-tool
|
|
1624
|
-
* enforcement layer
|
|
1625
|
-
* (`src/agents/pi-tools.before-tool-call.ts → wrapToolWithBeforeToolCallHook`)
|
|
1626
|
-
* is the single gate for permission, owner-only allowlists, loop
|
|
1627
|
-
* detection, trusted-plugin policies, and two-phase plugin approvals.
|
|
1628
|
-
* That layer reads its context from the fields forwarded here; missing
|
|
1629
|
-
* fields silently degrade policy decisions. See docs/plugins/copilot.md.
|
|
1630
|
-
*
|
|
1631
|
-
* The shared embedded-runner tool plan is forwarded so the bridge does
|
|
1632
|
-
* not construct broad tool families only to filter them later. That
|
|
1633
|
-
* preserves PI allowlist semantics such as `write` not materializing
|
|
1634
|
-
* `apply_patch`.
|
|
1635
|
-
* Sandbox is forwarded via the explicit `sandbox` field on
|
|
1636
|
-
* {@link CopilotToolBridgeInput}; callers resolve it via
|
|
1637
|
-
* `resolveSandboxContext` before constructing the bridge.
|
|
1618
|
+
* Bridged tools skip SDK permission prompts, so host wrappers need the complete
|
|
1619
|
+
* attempt context and prepared sandbox/construction policy to enforce access.
|
|
1620
|
+
* Missing fields here silently weaken or misapply the native harness contract.
|
|
1638
1621
|
*/
|
|
1639
1622
|
function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
1640
1623
|
const a = input.attemptParams;
|
|
@@ -1654,13 +1637,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1654
1637
|
const modelCompat = model && typeof model === "object" && "compat" in model && model.compat && typeof model.compat === "object" ? model.compat : void 0;
|
|
1655
1638
|
return {
|
|
1656
1639
|
agentId: input.agentId,
|
|
1657
|
-
...buildEmbeddedAttemptToolRunContext(
|
|
1658
|
-
trigger: a.trigger,
|
|
1659
|
-
jobId: a.jobId,
|
|
1660
|
-
memoryFlushWritePath: a.memoryFlushWritePath,
|
|
1661
|
-
toolsAllow: a.toolsAllow,
|
|
1662
|
-
conversationToolPolicy: a.conversationToolPolicy
|
|
1663
|
-
}),
|
|
1640
|
+
...buildEmbeddedAttemptToolRunContext(a),
|
|
1664
1641
|
exec: {
|
|
1665
1642
|
...a.execOverrides,
|
|
1666
1643
|
elevated: a.bashElevated
|
|
@@ -1708,7 +1685,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1708
1685
|
toolConstructionPlan: toolPlan.codingToolConstructionPlan,
|
|
1709
1686
|
modelCompat,
|
|
1710
1687
|
modelApi: model?.api,
|
|
1711
|
-
modelContextWindowTokens: model?.contextWindow,
|
|
1688
|
+
modelContextWindowTokens: a.contextTokenBudget ?? model?.contextWindow,
|
|
1712
1689
|
delegationCapability: a.delegationCapability,
|
|
1713
1690
|
modelAuthMode: resolveModelAuthMode(input.modelProvider, a.config, void 0, { workspaceDir }),
|
|
1714
1691
|
currentChannelId: a.currentChannelId,
|
|
@@ -1857,6 +1834,7 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1857
1834
|
} : executeOnce;
|
|
1858
1835
|
return {
|
|
1859
1836
|
description: sourceTool.description,
|
|
1837
|
+
defer: sourceTool.catalogMode === "direct-only" ? "never" : void 0,
|
|
1860
1838
|
handler,
|
|
1861
1839
|
name: sourceTool.name,
|
|
1862
1840
|
overridesBuiltInTool: true,
|
|
@@ -1977,12 +1955,6 @@ function filterCopilotToolsForConstructionPlan(tools, plan, options = {}) {
|
|
|
1977
1955
|
return true;
|
|
1978
1956
|
});
|
|
1979
1957
|
}
|
|
1980
|
-
function hasNonWildcardGlobAllowlist(toolsAllow) {
|
|
1981
|
-
return (toolsAllow ?? []).some((entry) => {
|
|
1982
|
-
const trimmed = entry.trim();
|
|
1983
|
-
return trimmed !== "*" && trimmed.includes("*");
|
|
1984
|
-
});
|
|
1985
|
-
}
|
|
1986
1958
|
function readInlinePluginToolMeta(tool) {
|
|
1987
1959
|
const pluginId = tool.pluginId;
|
|
1988
1960
|
return typeof pluginId === "string" && pluginId.trim() ? { pluginId } : void 0;
|
|
@@ -2026,7 +1998,7 @@ function prepareCopilotAttemptContext(params, deps) {
|
|
|
2026
1998
|
const modelRef = resolveModelRef(input);
|
|
2027
1999
|
const resolvedWorkspaceForSandbox = readResolvedAttemptPath(input.workspaceDir) ?? readResolvedAttemptPath(input.cwd);
|
|
2028
2000
|
const sandboxSessionKey = readNonEmptyString(input.sandboxSessionKey) ?? readNonEmptyString(input.sessionKey) ?? readNonEmptyString(input.sessionId);
|
|
2029
|
-
const { sessionAgentId } =
|
|
2001
|
+
const { sessionAgentId } = resolveSessionAgentIdsStrict({
|
|
2030
2002
|
sessionKey: readNonEmptyString(input.sessionKey),
|
|
2031
2003
|
config: input.config,
|
|
2032
2004
|
agentId: readNonEmptyString(params.agentId)
|
|
@@ -2057,6 +2029,10 @@ function prepareCopilotAttemptContext(params, deps) {
|
|
|
2057
2029
|
modelProviderId: modelRef.provider,
|
|
2058
2030
|
modelId: modelRef.id,
|
|
2059
2031
|
trigger: input.trigger,
|
|
2032
|
+
foregroundPromptContext: buildEmbeddedForegroundPromptContext({
|
|
2033
|
+
...input,
|
|
2034
|
+
agentId: sessionAgentId
|
|
2035
|
+
}, input.agentDir ?? resolveAgentDir(input.config ?? {}, sessionAgentId)),
|
|
2060
2036
|
...input.config ? { config: input.config } : {},
|
|
2061
2037
|
...hookContextWindowFields,
|
|
2062
2038
|
...buildAgentHookContextChannelFields(input)
|
|
@@ -2107,7 +2083,7 @@ function buildCopilotPromptGuidance(params) {
|
|
|
2107
2083
|
sourceReplyDeliveryMode: params.attempt.sourceReplyDeliveryMode,
|
|
2108
2084
|
messageToolAvailable: callableTools.has("message")
|
|
2109
2085
|
}),
|
|
2110
|
-
|
|
2086
|
+
buildCredentialSafetyPrompt(params.attempt.disableTools !== true && callableTools.has("secrets") ? "secrets" : void 0),
|
|
2111
2087
|
params.workspaceBootstrapInstructions?.trim(),
|
|
2112
2088
|
extraSystemPrompt ? `${isMinimal ? "## Subagent Context" : "## Conversation Context"}\n${extraSystemPrompt}` : void 0
|
|
2113
2089
|
].filter((section) => section?.trim()).join("\n\n") || void 0;
|
|
@@ -2545,7 +2521,8 @@ function createAttemptTranscriptJournal(params) {
|
|
|
2545
2521
|
const hooked = runAgentHarnessBeforeMessageWriteHook({
|
|
2546
2522
|
message: structuredClone(message),
|
|
2547
2523
|
agentId: target.agentId,
|
|
2548
|
-
sessionKey: target.sessionKey
|
|
2524
|
+
sessionKey: target.sessionKey,
|
|
2525
|
+
prepareAssistantTranscriptMessage: options.singleton && !hiddenTurn ? params.attempt.prepareAssistantTranscriptMessage : void 0
|
|
2549
2526
|
});
|
|
2550
2527
|
if (!hooked) return;
|
|
2551
2528
|
if (!isDeepStrictEqual(originalReplayPayload, projectReplayPayload(hooked))) replayInvalid = true;
|
|
@@ -3058,7 +3035,6 @@ async function runCopilotExecution(context) {
|
|
|
3058
3035
|
let timedOut = false;
|
|
3059
3036
|
let promptError;
|
|
3060
3037
|
let sdkSessionId;
|
|
3061
|
-
let sessionIdUsed = input.sessionId;
|
|
3062
3038
|
let nativeSessionCreatedFresh = false;
|
|
3063
3039
|
let nativeSessionHistoryValidated = false;
|
|
3064
3040
|
let disconnectError;
|
|
@@ -3119,15 +3095,13 @@ async function runCopilotExecution(context) {
|
|
|
3119
3095
|
messagesSnapshot: messages,
|
|
3120
3096
|
now,
|
|
3121
3097
|
promptError: void 0,
|
|
3122
|
-
sdkSessionId: void 0
|
|
3123
|
-
sessionIdUsed: input.sessionId
|
|
3098
|
+
sdkSessionId: void 0
|
|
3124
3099
|
}));
|
|
3125
3100
|
return finishAttempt(createResult(input, {
|
|
3126
3101
|
messagesSnapshot: messages,
|
|
3127
3102
|
now,
|
|
3128
3103
|
promptError: createPromptError$1("sandbox_resolution_failure", `[copilot-attempt] sandbox resolution failed: ${toCopilotError(error).message}`, error),
|
|
3129
|
-
sdkSessionId: void 0
|
|
3130
|
-
sessionIdUsed: input.sessionId
|
|
3104
|
+
sdkSessionId: void 0
|
|
3131
3105
|
}));
|
|
3132
3106
|
}
|
|
3133
3107
|
hookContext.workspaceDir = effectiveWorkspaceDir;
|
|
@@ -3139,8 +3113,7 @@ async function runCopilotExecution(context) {
|
|
|
3139
3113
|
messagesSnapshot: messages,
|
|
3140
3114
|
now,
|
|
3141
3115
|
promptError: createPromptError$1("sandbox_cwd_override_unsupported", "[copilot-attempt] cwd override is not supported for sandboxed Copilot runs; omit cwd or use the agent workspace as cwd"),
|
|
3142
|
-
sdkSessionId: void 0
|
|
3143
|
-
sessionIdUsed: input.sessionId
|
|
3116
|
+
sdkSessionId: void 0
|
|
3144
3117
|
}));
|
|
3145
3118
|
}
|
|
3146
3119
|
const effectiveCwd = sandbox?.enabled ? effectiveWorkspaceDir : requestedCwd ?? effectiveWorkspaceDir;
|
|
@@ -3168,8 +3141,7 @@ async function runCopilotExecution(context) {
|
|
|
3168
3141
|
messagesSnapshot: messages,
|
|
3169
3142
|
now,
|
|
3170
3143
|
promptError: createPromptError$1("model_not_supported", toCopilotError(error).message, error),
|
|
3171
|
-
sdkSessionId: void 0
|
|
3172
|
-
sessionIdUsed: input.sessionId
|
|
3144
|
+
sdkSessionId: void 0
|
|
3173
3145
|
}));
|
|
3174
3146
|
}
|
|
3175
3147
|
const cleanupByokProxy = byokProxy?.close;
|
|
@@ -3228,8 +3200,7 @@ async function runCopilotExecution(context) {
|
|
|
3228
3200
|
messagesSnapshot: messages,
|
|
3229
3201
|
now,
|
|
3230
3202
|
promptError: createPromptError$1("tool_bridge_failure", `[copilot-attempt] tool-bridge construction failed: ${toCopilotError(error).message}`, error),
|
|
3231
|
-
sdkSessionId: void 0
|
|
3232
|
-
sessionIdUsed: input.sessionId
|
|
3203
|
+
sdkSessionId: void 0
|
|
3233
3204
|
}));
|
|
3234
3205
|
}
|
|
3235
3206
|
handle = await deps.pool.acquire(poolAcquire.key, poolAcquire.options);
|
|
@@ -3281,7 +3252,6 @@ async function runCopilotExecution(context) {
|
|
|
3281
3252
|
sessionRef.current = session;
|
|
3282
3253
|
sdkSessionId = readNonEmptyString(session.sessionId) ?? readNonEmptyString(session.id) ?? (resumeFailureRecovered ? void 0 : resumeSessionId);
|
|
3283
3254
|
if (!sdkSessionId) throw createPromptError$1("transcript_persistence_failed", "[copilot-attempt] canonical transcript persistence requires the Copilot SDK session id");
|
|
3284
|
-
sessionIdUsed = sdkSessionId ?? input.sessionId;
|
|
3285
3255
|
if (sdkSessionId && deps.onSessionEstablished && !settledToolFinalization) try {
|
|
3286
3256
|
deps.onSessionEstablished({
|
|
3287
3257
|
compactionSessionConfig,
|
|
@@ -3343,6 +3313,7 @@ async function runCopilotExecution(context) {
|
|
|
3343
3313
|
abortActiveSession,
|
|
3344
3314
|
bridge,
|
|
3345
3315
|
canAcceptSteering: () => initialSdkUserValidated,
|
|
3316
|
+
startedAtMs: input.startedAtMs,
|
|
3346
3317
|
input,
|
|
3347
3318
|
isAborted: () => aborted,
|
|
3348
3319
|
isSettled: () => settled,
|
|
@@ -3490,7 +3461,6 @@ async function runCopilotExecution(context) {
|
|
|
3490
3461
|
resumeFailureRecovered,
|
|
3491
3462
|
sdkSessionId,
|
|
3492
3463
|
sentTurnStarted,
|
|
3493
|
-
sessionIdUsed,
|
|
3494
3464
|
settledFinalizationAssistantCompleted,
|
|
3495
3465
|
settledToolFinalization,
|
|
3496
3466
|
timedOut,
|
|
@@ -3512,8 +3482,7 @@ async function runCopilotAttempt(params, deps) {
|
|
|
3512
3482
|
messagesSnapshot: messages,
|
|
3513
3483
|
now,
|
|
3514
3484
|
promptError: void 0,
|
|
3515
|
-
sdkSessionId: void 0
|
|
3516
|
-
sessionIdUsed: input.sessionId
|
|
3485
|
+
sdkSessionId: void 0
|
|
3517
3486
|
}));
|
|
3518
3487
|
try {
|
|
3519
3488
|
resolveCopilotProvider({
|
|
@@ -3526,8 +3495,7 @@ async function runCopilotAttempt(params, deps) {
|
|
|
3526
3495
|
messagesSnapshot: messages,
|
|
3527
3496
|
now,
|
|
3528
3497
|
promptError: createPromptError$1("model_not_supported", toCopilotError(error).message, error),
|
|
3529
|
-
sdkSessionId: void 0
|
|
3530
|
-
sessionIdUsed: input.sessionId
|
|
3498
|
+
sdkSessionId: void 0
|
|
3531
3499
|
}));
|
|
3532
3500
|
}
|
|
3533
3501
|
const settledFinalizationSessionId = settledToolFinalization ? readNonEmptyString(input.initialReplayState?.sdkSessionId) : void 0;
|
|
@@ -3535,8 +3503,7 @@ async function runCopilotAttempt(params, deps) {
|
|
|
3535
3503
|
messagesSnapshot: messages,
|
|
3536
3504
|
now,
|
|
3537
3505
|
promptError: createPromptError$1("settled_finalization_session_unavailable", "[copilot-attempt] settled tool finalization requires the existing Copilot SDK session"),
|
|
3538
|
-
sdkSessionId: void 0
|
|
3539
|
-
sessionIdUsed: input.sessionId
|
|
3506
|
+
sdkSessionId: void 0
|
|
3540
3507
|
}));
|
|
3541
3508
|
return await runCopilotExecution({
|
|
3542
3509
|
params,
|
|
@@ -5,7 +5,7 @@ import { homedir } from "node:os";
|
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
6
|
import { createServer } from "node:http";
|
|
7
7
|
import { Readable } from "node:stream";
|
|
8
|
-
import {
|
|
8
|
+
import { pipeline } from "node:stream/promises";
|
|
9
9
|
import { fetchWithSsrFGuard, isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
10
10
|
import { isNonSecretApiKeyMarker } from "openclaw/plugin-sdk/provider-auth";
|
|
11
11
|
//#region extensions/copilot/src/auth-bridge.ts
|
|
@@ -281,7 +281,7 @@ async function handleProxyRequest(req, res, params) {
|
|
|
281
281
|
method: req.method,
|
|
282
282
|
headers: buildProxyRequestHeaders(req.headers, { upstreamBearerAuthorization: canInjectBearerAuthorization ? params.upstreamBearerAuthorization : void 0 }),
|
|
283
283
|
signal: upstreamAbort.signal,
|
|
284
|
-
...body ? { body
|
|
284
|
+
...body ? { body } : {}
|
|
285
285
|
},
|
|
286
286
|
auditContext: "copilot-byok-provider",
|
|
287
287
|
requireHttps: true
|
|
@@ -291,7 +291,7 @@ async function handleProxyRequest(req, res, params) {
|
|
|
291
291
|
res.end();
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
|
-
await
|
|
294
|
+
await pipeline(Readable.fromWeb(guarded.response.body), res);
|
|
295
295
|
} catch (error) {
|
|
296
296
|
if (res.destroyed || res.writableEnded) return;
|
|
297
297
|
if (res.headersSent) {
|
|
@@ -333,11 +333,6 @@ async function readBody(req) {
|
|
|
333
333
|
for await (const chunk of req) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
334
334
|
return chunks.length > 0 ? Buffer.concat(chunks) : void 0;
|
|
335
335
|
}
|
|
336
|
-
function toFetchBody(body) {
|
|
337
|
-
const copy = new Uint8Array(body.byteLength);
|
|
338
|
-
copy.set(body);
|
|
339
|
-
return copy;
|
|
340
|
-
}
|
|
341
336
|
function normalizeProxyRequestHeaders(headers) {
|
|
342
337
|
const out = {};
|
|
343
338
|
for (const [key, value] of Object.entries(headers)) {
|
|
@@ -827,7 +822,7 @@ function createCopilotAgentHarness(options) {
|
|
|
827
822
|
async function getPool() {
|
|
828
823
|
if (options?.pool) return options.pool;
|
|
829
824
|
if (!poolPromise) poolPromise = (async () => {
|
|
830
|
-
const { createCopilotClientPool } = await import("./runtime-
|
|
825
|
+
const { createCopilotClientPool } = await import("./runtime-DvZQV_8v.js");
|
|
831
826
|
createdPool = createCopilotClientPool(options?.poolOptions);
|
|
832
827
|
return createdPool;
|
|
833
828
|
})();
|
|
@@ -864,7 +859,7 @@ function createCopilotAgentHarness(options) {
|
|
|
864
859
|
async function runHarnessAttempt(params, operation) {
|
|
865
860
|
const attemptPromise = (async () => {
|
|
866
861
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
|
|
867
|
-
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-
|
|
862
|
+
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-DwhhWgyV.js");
|
|
868
863
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
869
864
|
const pool = await getPool();
|
|
870
865
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
@@ -995,7 +990,7 @@ function createCopilotAgentHarness(options) {
|
|
|
995
990
|
async function runIsolatedCompletionV2(params) {
|
|
996
991
|
const completionPromise = (async () => {
|
|
997
992
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start isolated completion");
|
|
998
|
-
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-
|
|
993
|
+
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-C0DfWtVO.js");
|
|
999
994
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
1000
995
|
return await runCopilotIsolatedCompletion(params, async () => {
|
|
1001
996
|
const pool = await getPool();
|
|
@@ -1086,7 +1081,7 @@ function createCopilotAgentHarness(options) {
|
|
|
1086
1081
|
};
|
|
1087
1082
|
const tracked = trackedSessions.get(openclawSessionId);
|
|
1088
1083
|
const currentCompactKey = computeCompactRequestKey(params);
|
|
1089
|
-
const { resolvePoolAcquire } = await import("./attempt-
|
|
1084
|
+
const { resolvePoolAcquire } = await import("./attempt-DwhhWgyV.js");
|
|
1090
1085
|
let resolvedPoolAcquire;
|
|
1091
1086
|
let currentAuth;
|
|
1092
1087
|
try {
|
package/dist/harness.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "./harness-
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./harness-DvYbOGRx.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-DvYbOGRx.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
|
|
@@ -15,16 +15,21 @@ var copilot_default = definePluginEntry({
|
|
|
15
15
|
name: "GitHub Copilot agent runtime",
|
|
16
16
|
description: "Registers the GitHub Copilot agent runtime.",
|
|
17
17
|
register(api) {
|
|
18
|
-
if (api.registrationMode !== "full") return;
|
|
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
22
|
namespace: "sdk-sessions",
|
|
22
23
|
maxEntries: 5e3,
|
|
23
24
|
defaultTtlMs: 2160 * 60 * 60 * 1e3
|
|
24
25
|
});
|
|
25
26
|
api.registerAgentHarness(createCopilotAgentHarness({
|
|
26
27
|
...poolOptions ? { poolOptions } : {},
|
|
27
|
-
sessionStore
|
|
28
|
+
sessionStore: {
|
|
29
|
+
register: (key, value, options) => getSessionStore().register(key, value, options),
|
|
30
|
+
lookup: (key) => getSessionStore().lookup(key),
|
|
31
|
+
delete: (key) => getSessionStore().delete(key)
|
|
32
|
+
}
|
|
28
33
|
}));
|
|
29
34
|
}
|
|
30
35
|
});
|
|
@@ -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-DvYbOGRx.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
|
|
@@ -4,11 +4,14 @@ import { toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
|
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
7
|
+
//#region extensions/copilot/package.json
|
|
8
|
+
var dependencies = { "@github/copilot-sdk": "1.0.11" };
|
|
9
|
+
//#endregion
|
|
7
10
|
//#region extensions/copilot/src/sdk-loader.ts
|
|
8
11
|
function resolveCopilotSdkFallbackDir(env = process.env) {
|
|
9
12
|
return path.join(resolveStateDir(env), "npm-runtime", "copilot");
|
|
10
13
|
}
|
|
11
|
-
const COPILOT_SDK_SPEC = "@github/copilot-sdk
|
|
14
|
+
const COPILOT_SDK_SPEC = `@github/copilot-sdk@${dependencies["@github/copilot-sdk"]}`;
|
|
12
15
|
let cached;
|
|
13
16
|
async function loadCopilotSdk(options = {}) {
|
|
14
17
|
const useCache = options.cache !== false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/copilot",
|
|
3
|
-
"version": "2026.8.1
|
|
3
|
+
"version": "2026.8.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",
|
|
@@ -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.11"
|
|
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.8.1
|
|
27
|
+
"pluginApi": ">=2026.8.1"
|
|
28
28
|
},
|
|
29
29
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.8.1
|
|
30
|
+
"openclawVersion": "2026.8.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.8.1
|
|
48
|
+
"openclaw": ">=2026.8.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"openclaw": {
|