@openclaw/copilot 2026.8.1-beta.2 → 2026.9.1-beta.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-BNDq00ZS.js → attempt-NJAPbYd4.js} +152 -93
- package/dist/{harness-EyKssDe5.js → harness-hh25oAuF.js} +58 -39
- package/dist/harness.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{isolated-completion-CM4w2GCk.js → isolated-completion-GNSNtOHz.js} +1 -1
- package/dist/{runtime-C2t8Iz5R.js → runtime-DvZQV_8v.js} +4 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
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-hh25oAuF.js";
|
|
2
2
|
import { n as normalizeCopilotUsage, r as createCopilotIsolatedSessionRestrictions, t as buildCopilotAssistantUsage } from "./usage-bridge-Cpa-ZYwL.js";
|
|
3
|
-
import { normalizeOptionalString, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
import { TRANSCRIPT_CREDENTIAL_SAFETY_PROMPT, applyEmbeddedAttemptToolsAllow, awaitAgentEndSideEffects, buildAgentHookContextChannelFields, buildEmbeddedAttemptToolRunContext, callGatewayTool, cancelPendingAgentQuestionForSession, claimPendingAgentQuestionAnswer, clearActiveEmbeddedRun, detectAndLoadAgentHarnessPromptImages, embeddedAgentLog, extractToolErrorMessage, getModelProviderRequestTransport, getPluginToolMeta, isHostScopedAgentToolActive, isSubagentSessionKey, isToolResultError, projectAgentHarnessTranscriptMessageForDisplay, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptFsWorkspaceOnly, resolveAttemptSpawnWorkspaceDir, resolveBootstrapContextForRun, resolveCompactionTimeoutMs, resolveEmbeddedAttemptToolConstructionPlan, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, resolveUserPath, runAgentEndSideEffects, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessGatewayQuestion, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, sanitizeToolResult, setActiveEmbeddedRun } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
3
|
+
import { asNonArrayRecord, normalizeOptionalString, normalizeUniqueStringEntries, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { SKILL_WORKSHOP_TOOL_NAME, TRANSCRIPT_CREDENTIAL_SAFETY_PROMPT, applyEmbeddedAttemptToolsAllow, awaitAgentEndSideEffects, buildAgentHookContextChannelFields, 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, resolveSessionAgentIds, 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";
|
|
@@ -304,7 +304,7 @@ function createResult(params, state) {
|
|
|
304
304
|
const toolMetas = state.toolMetas ?? [];
|
|
305
305
|
const replayMetadata = params.operation === "settled-tool-finalization" ? {
|
|
306
306
|
hadPotentialSideEffects: false,
|
|
307
|
-
replaySafe:
|
|
307
|
+
replaySafe: !transcriptPersistenceFailed
|
|
308
308
|
} : computeReplayMetadata({
|
|
309
309
|
priorReplayInvalid: params.initialReplayState?.replayInvalid === true || state.nativeReplayInvalid === true || transcriptPersistenceFailed,
|
|
310
310
|
priorHadPotentialSideEffects: params.initialReplayState?.hadPotentialSideEffects,
|
|
@@ -353,7 +353,8 @@ function createResult(params, state) {
|
|
|
353
353
|
sessionFileUsed: readNonEmptyString(params.sessionFile),
|
|
354
354
|
sessionIdUsed: state.sessionIdUsed ?? readNonEmptyString(params.sessionId) ?? "copilot-session",
|
|
355
355
|
toolMetas,
|
|
356
|
-
yieldDetected: state.yieldDetected === true
|
|
356
|
+
yieldDetected: state.yieldDetected === true,
|
|
357
|
+
...state.yieldAcknowledgment ? { yieldAcknowledgment: state.yieldAcknowledgment } : {}
|
|
357
358
|
};
|
|
358
359
|
}
|
|
359
360
|
function createPromptError$1(code, message, cause) {
|
|
@@ -441,21 +442,6 @@ function resolveImageCapabilityModel(params) {
|
|
|
441
442
|
if (model && typeof model === "object" && Array.isArray(model.input)) return { input: model.input };
|
|
442
443
|
return { input: ["image"] };
|
|
443
444
|
}
|
|
444
|
-
function createSystemMessageContent(params, workspaceBootstrapInstructions) {
|
|
445
|
-
if (isRawCopilotModelRun(params)) return;
|
|
446
|
-
const sections = [TRANSCRIPT_CREDENTIAL_SAFETY_PROMPT];
|
|
447
|
-
const bootstrap = workspaceBootstrapInstructions?.trim();
|
|
448
|
-
if (bootstrap) sections.push(bootstrap);
|
|
449
|
-
const extraSystemPrompt = readNonEmptyString(params.extraSystemPrompt)?.trim();
|
|
450
|
-
if (extraSystemPrompt) {
|
|
451
|
-
const contextHeader = params.promptMode === "minimal" ? "## Subagent Context" : "## Conversation Context";
|
|
452
|
-
sections.push(`${contextHeader}\n${extraSystemPrompt}`);
|
|
453
|
-
}
|
|
454
|
-
return sections.length > 0 ? sections.join("\n\n") : void 0;
|
|
455
|
-
}
|
|
456
|
-
function isRawCopilotModelRun(params) {
|
|
457
|
-
return params.modelRun === true || params.promptMode === "none";
|
|
458
|
-
}
|
|
459
445
|
function readResolvedAttemptPath(value) {
|
|
460
446
|
const raw = readNonEmptyString(value)?.trim();
|
|
461
447
|
if (!raw) return;
|
|
@@ -556,7 +542,7 @@ function buildAssistantMessage(params) {
|
|
|
556
542
|
type: "text"
|
|
557
543
|
});
|
|
558
544
|
for (const request of toolRequests) content.push({
|
|
559
|
-
arguments: request.arguments
|
|
545
|
+
arguments: asNonArrayRecord(request.arguments),
|
|
560
546
|
id: request.toolCallId,
|
|
561
547
|
name: request.name,
|
|
562
548
|
type: "toolCall"
|
|
@@ -1403,7 +1389,7 @@ async function waitForPersistenceReceipt(receipt, requestedTimeoutMs) {
|
|
|
1403
1389
|
//#endregion
|
|
1404
1390
|
//#region extensions/copilot/src/attempt-finalize.ts
|
|
1405
1391
|
async function completeCopilotAttempt(params) {
|
|
1406
|
-
const { aborted, attemptStartedAt, bridge, codeModeEngaged, downgradedFromResume, externalAbort, hookContext, hookContextWindowFields, input, lastToolError, messages, nativeSessionHistoryUnvalidated, transcriptJournal, modelRef, now, promptError, releaseError, resumeFailureRecovered, sdkSessionId, sentTurnStarted, sessionIdUsed, settledFinalizationAssistantCompleted, settledToolFinalization, timedOut, timedOutDuringCompaction, yieldDetected } = params;
|
|
1392
|
+
const { aborted, attemptStartedAt, bridge, codeModeEngaged, downgradedFromResume, externalAbort, hookContext, hookContextWindowFields, input, lastToolError, messages, nativeSessionHistoryUnvalidated, transcriptJournal, modelRef, now, promptError, releaseError, resumeFailureRecovered, sdkSessionId, sentTurnStarted, sessionIdUsed, settledFinalizationAssistantCompleted, settledToolFinalization, timedOut, timedOutDuringCompaction, yieldDetected, yieldAcknowledgment } = params;
|
|
1407
1393
|
const snap = bridge?.snapshot();
|
|
1408
1394
|
const assistantTexts = bridge?.finalizeAssistantTexts() ?? [];
|
|
1409
1395
|
const lastAssistant = bridge?.buildAssistantMessage({
|
|
@@ -1444,7 +1430,8 @@ async function completeCopilotAttempt(params) {
|
|
|
1444
1430
|
timedOutDuringCompaction,
|
|
1445
1431
|
toolMetas: snap ? [...snap.toolMetas] : [],
|
|
1446
1432
|
usage: snap?.usage,
|
|
1447
|
-
yieldDetected
|
|
1433
|
+
yieldDetected,
|
|
1434
|
+
yieldAcknowledgment
|
|
1448
1435
|
});
|
|
1449
1436
|
if (sentTurnStarted && !settledToolFinalization && !transcriptJournal?.hasFailed()) runAgentHarnessLlmOutputHook({
|
|
1450
1437
|
event: {
|
|
@@ -1503,7 +1490,16 @@ function userText$1(content) {
|
|
|
1503
1490
|
return JSON.stringify(content) ?? "";
|
|
1504
1491
|
}
|
|
1505
1492
|
//#endregion
|
|
1493
|
+
//#region extensions/copilot/src/attempt-mode.ts
|
|
1494
|
+
function isRawCopilotModelRun(params) {
|
|
1495
|
+
return params.modelRun === true || params.promptMode === "none";
|
|
1496
|
+
}
|
|
1497
|
+
//#endregion
|
|
1506
1498
|
//#region extensions/copilot/src/tool-bridge.ts
|
|
1499
|
+
const EMPTY_PROMPT_TOOL_POLICY = { apply: () => ({
|
|
1500
|
+
tools: [],
|
|
1501
|
+
callableToolNames: []
|
|
1502
|
+
}) };
|
|
1507
1503
|
const SUPPORTED_TOOL_PROVIDERS = /* @__PURE__ */ new Set(["github-copilot"]);
|
|
1508
1504
|
const BASE_COPILOT_CODING_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1509
1505
|
"edit",
|
|
@@ -1515,20 +1511,17 @@ const SHELL_COPILOT_CODING_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
1515
1511
|
"exec",
|
|
1516
1512
|
"process"
|
|
1517
1513
|
]);
|
|
1518
|
-
function supportsModelTools(modelProvider) {
|
|
1519
|
-
return SUPPORTED_TOOL_PROVIDERS.has(modelProvider);
|
|
1520
|
-
}
|
|
1521
1514
|
async function createCopilotToolBridge(input) {
|
|
1522
|
-
if (!input.allowModelTools && !
|
|
1515
|
+
if (!input.allowModelTools && !SUPPORTED_TOOL_PROVIDERS.has(input.modelProvider)) return {
|
|
1523
1516
|
codeModeEngaged: false,
|
|
1524
|
-
|
|
1517
|
+
promptToolPolicy: EMPTY_PROMPT_TOOL_POLICY,
|
|
1525
1518
|
sourceTools: []
|
|
1526
1519
|
};
|
|
1527
1520
|
const attemptParams = input.attemptParams;
|
|
1528
1521
|
const toolPlan = resolveEmbeddedAttemptToolConstructionPlan({
|
|
1529
1522
|
disableTools: attemptParams.disableTools,
|
|
1530
1523
|
forceMessageTool: shouldForceCopilotMessageTool(attemptParams),
|
|
1531
|
-
isRawModelRun:
|
|
1524
|
+
isRawModelRun: isRawCopilotModelRun(attemptParams),
|
|
1532
1525
|
toolsAllow: attemptParams.toolsAllow
|
|
1533
1526
|
});
|
|
1534
1527
|
const effectiveToolPlan = hasNonWildcardGlobAllowlist(toolPlan.runtimeToolAllowlist) ? {
|
|
@@ -1545,7 +1538,7 @@ async function createCopilotToolBridge(input) {
|
|
|
1545
1538
|
} : toolPlan;
|
|
1546
1539
|
if (!effectiveToolPlan.constructTools) return {
|
|
1547
1540
|
codeModeEngaged: false,
|
|
1548
|
-
|
|
1541
|
+
promptToolPolicy: EMPTY_PROMPT_TOOL_POLICY,
|
|
1549
1542
|
sourceTools: []
|
|
1550
1543
|
};
|
|
1551
1544
|
const createOpenClawCodingTools = input.createOpenClawCodingTools ?? (await import("openclaw/plugin-sdk/agent-harness")).createOpenClawCodingTools;
|
|
@@ -1556,7 +1549,7 @@ async function createCopilotToolBridge(input) {
|
|
|
1556
1549
|
disableTools: attemptParams.disableTools,
|
|
1557
1550
|
executeTool: (toolParams) => executeCatalogTool(input, toolParams),
|
|
1558
1551
|
forceMessageTool: shouldForceCopilotMessageTool(attemptParams),
|
|
1559
|
-
isRawModelRun:
|
|
1552
|
+
isRawModelRun: isRawCopilotModelRun(attemptParams),
|
|
1560
1553
|
model: attemptParams.model,
|
|
1561
1554
|
modelId: input.modelId,
|
|
1562
1555
|
modelProvider: input.modelProvider,
|
|
@@ -1567,7 +1560,6 @@ async function createCopilotToolBridge(input) {
|
|
|
1567
1560
|
sessionId: input.sessionId,
|
|
1568
1561
|
sessionKey: attemptParams.sandboxSessionKey ?? attemptParams.sessionKey ?? input.sessionKey,
|
|
1569
1562
|
scheduledToolPolicy: attemptParams.scheduledToolPolicy,
|
|
1570
|
-
skillWorkshopProposalOnly: attemptParams.skillWorkshopProposalOnly,
|
|
1571
1563
|
sourceReplyDeliveryMode: attemptParams.sourceReplyDeliveryMode,
|
|
1572
1564
|
toolsAllow: attemptParams.toolsAllow
|
|
1573
1565
|
});
|
|
@@ -1590,26 +1582,34 @@ async function createCopilotToolBridge(input) {
|
|
|
1590
1582
|
} catch (error) {
|
|
1591
1583
|
throw createError(`[copilot-tool-bridge] createOpenClawCodingTools failed: ${toStringifiedError(error).message}`, error);
|
|
1592
1584
|
}
|
|
1593
|
-
const
|
|
1594
|
-
const
|
|
1595
|
-
const newlyConstructedTools =
|
|
1585
|
+
const plannedSourceTools = filterCopilotToolsForConstructionPlan(applyEmbeddedAttemptToolsAllow(sourceTools, toolSurfaceRuntime.runtimeToolAllowlist, { toolMeta: (tool) => getPluginToolMeta(tool) ?? readInlinePluginToolMeta(tool) }), effectiveToolPlan.codingToolConstructionPlan, { preserveToolNames: toolSurfaceRuntime.runtimeToolAllowlist });
|
|
1586
|
+
const compactedTools = toolSurfaceRuntime.compactTools(plannedSourceTools, { localModelLeanApplied: true });
|
|
1587
|
+
const newlyConstructedTools = compactedTools.tools.filter((tool) => !boundSourceTools.has(tool));
|
|
1596
1588
|
const boundNewlyConstructedTools = newlyConstructedTools.length > 0 ? hostCapabilities.bindToolSurface(newlyConstructedTools, bindingOptions) : newlyConstructedTools;
|
|
1597
1589
|
if (boundNewlyConstructedTools.length !== newlyConstructedTools.length) throw new Error("Copilot host capability changed the tool surface length.");
|
|
1598
1590
|
const newlyBoundTools = /* @__PURE__ */ new Map();
|
|
1599
1591
|
for (let index = 0; index < newlyConstructedTools.length; index += 1) newlyBoundTools.set(newlyConstructedTools[index], boundNewlyConstructedTools[index]);
|
|
1600
|
-
const exposedTools =
|
|
1592
|
+
const exposedTools = compactedTools.tools.map((tool) => newlyBoundTools.get(tool) ?? tool);
|
|
1601
1593
|
const duplicateNames = findDuplicateToolNames(exposedTools);
|
|
1602
1594
|
if (duplicateNames.length > 0) throw new Error(`[copilot-tool-bridge] duplicate tool names: ${duplicateNames.join(", ")}`);
|
|
1595
|
+
const sdkTools = exposedTools.map((sourceTool) => convertOpenClawToolToSdkTool(sourceTool, {
|
|
1596
|
+
abortSignal: input.abortSignal,
|
|
1597
|
+
beforeExecute: input.beforeExecute,
|
|
1598
|
+
onAgentToolResult: input.attemptParams?.onAgentToolResult,
|
|
1599
|
+
onToolCompleted: input.onToolCompleted,
|
|
1600
|
+
observeToolTerminal: input.attemptParams?.observeToolTerminal
|
|
1601
|
+
}));
|
|
1603
1602
|
return {
|
|
1604
1603
|
cleanup: toolSurfaceRuntime.cleanup,
|
|
1605
1604
|
codeModeEngaged: toolSurfaceRuntime.codeModeControlsEnabled,
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1605
|
+
promptToolPolicy: { apply: (params = {}) => {
|
|
1606
|
+
const result = compactedTools.promptToolPolicy.apply(params);
|
|
1607
|
+
const directToolNames = new Set(result.tools.map((tool) => tool.name));
|
|
1608
|
+
return {
|
|
1609
|
+
tools: sdkTools.filter((tool) => directToolNames.has(tool.name)),
|
|
1610
|
+
callableToolNames: result.callableToolNames
|
|
1611
|
+
};
|
|
1612
|
+
} },
|
|
1613
1613
|
sourceTools: exposedTools
|
|
1614
1614
|
};
|
|
1615
1615
|
}
|
|
@@ -1665,6 +1665,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1665
1665
|
elevated: a.bashElevated
|
|
1666
1666
|
},
|
|
1667
1667
|
messageProvider: a.messageProvider ?? a.messageChannel,
|
|
1668
|
+
messageChannel: a.messageChannel,
|
|
1668
1669
|
toolBindings: a.toolBindings,
|
|
1669
1670
|
chatType: a.chatType,
|
|
1670
1671
|
agentAccountId: a.agentAccountId,
|
|
@@ -1689,6 +1690,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1689
1690
|
sessionId: input.sessionId,
|
|
1690
1691
|
runId: a.runId,
|
|
1691
1692
|
agentDir,
|
|
1693
|
+
preparedModelRuntime: a.preparedModelRuntime,
|
|
1692
1694
|
workspaceDir,
|
|
1693
1695
|
cwd,
|
|
1694
1696
|
sandbox,
|
|
@@ -1725,9 +1727,9 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1725
1727
|
computerContextEpoch: input.computerContextEpoch,
|
|
1726
1728
|
onToolOutcome: a.onToolOutcome,
|
|
1727
1729
|
isTurnTainted: a.isTurnTainted,
|
|
1728
|
-
onYield: (message) => {
|
|
1730
|
+
onYield: (message, acknowledgment) => {
|
|
1729
1731
|
try {
|
|
1730
|
-
input.onYieldDetected?.(message);
|
|
1732
|
+
input.onYieldDetected?.(message, acknowledgment);
|
|
1731
1733
|
} catch (error) {
|
|
1732
1734
|
console.warn("[copilot-tool-bridge] onYieldDetected handler threw; continuing", error);
|
|
1733
1735
|
}
|
|
@@ -1738,6 +1740,8 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1738
1740
|
function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
1739
1741
|
if (typeof sourceTool.name !== "string" || sourceTool.name.trim().length === 0) throw new Error("[copilot-tool-bridge] tool name must be a non-empty string");
|
|
1740
1742
|
if (typeof sourceTool.execute !== "function") throw new Error(`[copilot-tool-bridge] tool '${sourceTool.name}' must define an execute function`);
|
|
1743
|
+
const ownerKey = getPluginToolSideEffectOwnerKey(sourceTool);
|
|
1744
|
+
const ownerMutation = ownerKey ? { ownerKey } : void 0;
|
|
1741
1745
|
let sequentialLock = Promise.resolve();
|
|
1742
1746
|
const notifyToolResult = (result, isError) => {
|
|
1743
1747
|
try {
|
|
@@ -1767,7 +1771,8 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1767
1771
|
arguments: executedArgs,
|
|
1768
1772
|
executionStarted,
|
|
1769
1773
|
outcome: "failure",
|
|
1770
|
-
failure: { error: errorMessage }
|
|
1774
|
+
failure: { error: errorMessage },
|
|
1775
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1771
1776
|
});
|
|
1772
1777
|
notifyToolResult(sanitizeToolResult({
|
|
1773
1778
|
content: [{
|
|
@@ -1830,7 +1835,8 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1830
1835
|
arguments: preparedArgs,
|
|
1831
1836
|
executionStarted: true,
|
|
1832
1837
|
outcome: resultIsError ? "failure" : "success",
|
|
1833
|
-
...resultIsError ? { failure: { error: resultError ?? "tool returned an error" } } : {}
|
|
1838
|
+
...resultIsError ? { failure: { error: resultError ?? "tool returned an error" } } : {},
|
|
1839
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1834
1840
|
});
|
|
1835
1841
|
notifyToolResult(sanitizedResult, resultIsError);
|
|
1836
1842
|
notifyToolCompleted({
|
|
@@ -1859,6 +1865,8 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1859
1865
|
}
|
|
1860
1866
|
async function executeCatalogTool(input, params) {
|
|
1861
1867
|
const sourceTool = params.tool;
|
|
1868
|
+
const ownerKey = getPluginToolSideEffectOwnerKey(sourceTool);
|
|
1869
|
+
const ownerMutation = ownerKey ? { ownerKey } : void 0;
|
|
1862
1870
|
const startedAt = Date.now();
|
|
1863
1871
|
let preparedArgs = params.input;
|
|
1864
1872
|
let executionStarted = false;
|
|
@@ -1877,7 +1885,8 @@ async function executeCatalogTool(input, params) {
|
|
|
1877
1885
|
arguments: preparedArgs,
|
|
1878
1886
|
executionStarted,
|
|
1879
1887
|
outcome: isError ? "failure" : "success",
|
|
1880
|
-
...error ? { failure: { error } } : {}
|
|
1888
|
+
...error ? { failure: { error } } : {},
|
|
1889
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1881
1890
|
});
|
|
1882
1891
|
input.attemptParams?.onAgentToolResult?.({
|
|
1883
1892
|
toolName: params.toolName,
|
|
@@ -1901,7 +1910,8 @@ async function executeCatalogTool(input, params) {
|
|
|
1901
1910
|
arguments: preparedArgs,
|
|
1902
1911
|
executionStarted,
|
|
1903
1912
|
outcome: "failure",
|
|
1904
|
-
failure: { error: message }
|
|
1913
|
+
failure: { error: message },
|
|
1914
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1905
1915
|
});
|
|
1906
1916
|
const failure = sanitizeToolResult({
|
|
1907
1917
|
content: [{
|
|
@@ -1944,17 +1954,6 @@ function createError(message, cause) {
|
|
|
1944
1954
|
return error;
|
|
1945
1955
|
}
|
|
1946
1956
|
/**
|
|
1947
|
-
* Returns true when the attempt was launched as a raw-model run, which
|
|
1948
|
-
* suppresses tool construction in PI
|
|
1949
|
-
* (`src/agents/pi-embedded-runner/run/attempt.ts:1305-1310` and
|
|
1950
|
-
* `attempt-tool-construction-plan.ts:165-184`). A run is raw when the
|
|
1951
|
-
* caller explicitly sets `modelRun: true` or asks for no system prompt
|
|
1952
|
-
* via `promptMode: "none"`.
|
|
1953
|
-
*/
|
|
1954
|
-
function isCopilotRawModelRun(params) {
|
|
1955
|
-
return params.modelRun === true || params.promptMode === "none";
|
|
1956
|
-
}
|
|
1957
|
-
/**
|
|
1958
1957
|
* Mirrors PI's `shouldForceMessageTool` semantics: a message tool is
|
|
1959
1958
|
* forced when the caller asked for it explicitly or when the source
|
|
1960
1959
|
* reply delivery mode is `message_tool_only`, but never when
|
|
@@ -1967,18 +1966,6 @@ function shouldForceCopilotMessageTool(params) {
|
|
|
1967
1966
|
if (params.disableMessageTool === true) return false;
|
|
1968
1967
|
return params.forceMessageTool === true || params.sourceReplyDeliveryMode === "message_tool_only";
|
|
1969
1968
|
}
|
|
1970
|
-
/**
|
|
1971
|
-
* Mirrors PI's `applyEmbeddedAttemptToolsAllow`
|
|
1972
|
-
* (`src/agents/embedded-agent-runner/run/attempt-tool-construction-plan.ts`)
|
|
1973
|
-
* so final filtering keeps aliases, groups, plugin policies, and glob
|
|
1974
|
-
* semantics identical to the in-tree embedded runner.
|
|
1975
|
-
*/
|
|
1976
|
-
function filterCopilotToolsForAllowlist(tools, toolsAllow, options) {
|
|
1977
|
-
const filtered = applyEmbeddedAttemptToolsAllow(tools, toolsAllow, { toolMeta: (tool) => getPluginToolMeta(tool) ?? readInlinePluginToolMeta(tool) });
|
|
1978
|
-
if (!options?.forceToolNames?.length) return filtered;
|
|
1979
|
-
const allowedNames = /* @__PURE__ */ new Set([...filtered.map((tool) => tool.name), ...options.forceToolNames]);
|
|
1980
|
-
return tools.filter((tool) => allowedNames.has(tool.name));
|
|
1981
|
-
}
|
|
1982
1969
|
function filterCopilotToolsForConstructionPlan(tools, plan, options = {}) {
|
|
1983
1970
|
if (plan.includeBaseCodingTools && plan.includeShellTools) return tools;
|
|
1984
1971
|
const preserveToolNames = new Set(options.preserveToolNames);
|
|
@@ -2069,6 +2056,10 @@ function prepareCopilotAttemptContext(params, deps) {
|
|
|
2069
2056
|
modelProviderId: modelRef.provider,
|
|
2070
2057
|
modelId: modelRef.id,
|
|
2071
2058
|
trigger: input.trigger,
|
|
2059
|
+
foregroundPromptContext: buildEmbeddedForegroundPromptContext({
|
|
2060
|
+
...input,
|
|
2061
|
+
agentId: sessionAgentId
|
|
2062
|
+
}, input.agentDir ?? resolveAgentDir(input.config ?? {}, sessionAgentId)),
|
|
2072
2063
|
...input.config ? { config: input.config } : {},
|
|
2073
2064
|
...hookContextWindowFields,
|
|
2074
2065
|
...buildAgentHookContextChannelFields(input)
|
|
@@ -2090,6 +2081,41 @@ async function resolveCopilotAttemptSandbox(params) {
|
|
|
2090
2081
|
};
|
|
2091
2082
|
}
|
|
2092
2083
|
//#endregion
|
|
2084
|
+
//#region extensions/copilot/src/prompt-guidance.ts
|
|
2085
|
+
const COPILOT_HARNESS_IDENTITY = "You are a personal agent running inside OpenClaw. Your available OpenClaw capabilities are policy-filtered for this turn; use only the exact tools exposed to you.";
|
|
2086
|
+
function buildCopilotPromptGuidance(params) {
|
|
2087
|
+
if (isRawCopilotModelRun(params.attempt)) return;
|
|
2088
|
+
const callableTools = new Set(normalizeUniqueStringEntries(params.callableToolNames));
|
|
2089
|
+
const hasSessionsSpawn = callableTools.has("sessions_spawn");
|
|
2090
|
+
const isMinimal = params.attempt.promptMode === "minimal";
|
|
2091
|
+
const extraSystemPrompt = readNonEmptyStringPreservingWhitespace(params.attempt.extraSystemPrompt)?.trim();
|
|
2092
|
+
const delegationGuidance = params.attempt.disableTools !== true && params.attempt.delegationCapability !== "report_only" ? buildDelegationGuidanceSection({
|
|
2093
|
+
mode: resolveMainSessionDelegationMode({
|
|
2094
|
+
config: params.attempt.config,
|
|
2095
|
+
agentId: params.attempt.agentId,
|
|
2096
|
+
sessionKey: params.attempt.sessionKey
|
|
2097
|
+
}),
|
|
2098
|
+
isMinimal,
|
|
2099
|
+
hiddenDelegationTool: hasSessionsSpawn ? "`sessions_spawn`" : "",
|
|
2100
|
+
hasVisibleSessionSpawn: hasSessionsSpawn,
|
|
2101
|
+
hasSessionsYield: callableTools.has("sessions_yield"),
|
|
2102
|
+
hasSubagentsList: callableTools.has("subagents"),
|
|
2103
|
+
hasSessionsSend: callableTools.has("sessions_send")
|
|
2104
|
+
}).join("\n") : void 0;
|
|
2105
|
+
return [
|
|
2106
|
+
COPILOT_HARNESS_IDENTITY,
|
|
2107
|
+
callableTools.has(SKILL_WORKSHOP_TOOL_NAME) ? buildSkillWorkshopPromptSection().join("\n") : void 0,
|
|
2108
|
+
delegationGuidance,
|
|
2109
|
+
buildHarnessVisibleReplyGuidance({
|
|
2110
|
+
sourceReplyDeliveryMode: params.attempt.sourceReplyDeliveryMode,
|
|
2111
|
+
messageToolAvailable: callableTools.has("message")
|
|
2112
|
+
}),
|
|
2113
|
+
TRANSCRIPT_CREDENTIAL_SAFETY_PROMPT,
|
|
2114
|
+
params.workspaceBootstrapInstructions?.trim(),
|
|
2115
|
+
extraSystemPrompt ? `${isMinimal ? "## Subagent Context" : "## Conversation Context"}\n${extraSystemPrompt}` : void 0
|
|
2116
|
+
].filter((section) => section?.trim()).join("\n\n") || void 0;
|
|
2117
|
+
}
|
|
2118
|
+
//#endregion
|
|
2093
2119
|
//#region extensions/copilot/src/user-input-bridge.ts
|
|
2094
2120
|
const COPILOT_USER_INPUT_QUESTION_ID = "answer";
|
|
2095
2121
|
const DEFAULT_USER_INPUT_TIMEOUT_MS = 15 * 6e4;
|
|
@@ -2325,7 +2351,7 @@ function readResolvedWorkspacePath(value) {
|
|
|
2325
2351
|
//#endregion
|
|
2326
2352
|
//#region extensions/copilot/src/attempt-session-setup.ts
|
|
2327
2353
|
async function createCopilotSessionSetup(params) {
|
|
2328
|
-
const { attempt: input, byokProxy, effectiveCwd, effectiveWorkspaceDir, hookContext, modelRef, messages, operation, poolAcquire, ringZeroSystemAgentRun,
|
|
2354
|
+
const { attempt: input, byokProxy, effectiveCwd, effectiveWorkspaceDir, hookContext, modelRef, messages, operation, poolAcquire, ringZeroSystemAgentRun, promptToolPolicy, sessionProvider, settledToolFinalization, signal } = params;
|
|
2329
2355
|
const ordinaryAttemptInput = settledToolFinalization ? void 0 : (() => {
|
|
2330
2356
|
assertCopilotAttemptHostCapabilities(input);
|
|
2331
2357
|
return input;
|
|
@@ -2335,22 +2361,51 @@ async function createCopilotSessionSetup(params) {
|
|
|
2335
2361
|
effectiveWorkspaceDir,
|
|
2336
2362
|
warn: (message) => console.warn(message)
|
|
2337
2363
|
}) : { instructions: void 0 };
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2364
|
+
const forceToolNames = ordinaryAttemptInput && shouldForceCopilotMessageTool(ordinaryAttemptInput) ? ["message"] : void 0;
|
|
2365
|
+
let promptPolicyResult;
|
|
2366
|
+
let promptBuild;
|
|
2367
|
+
if (settledToolFinalization) promptBuild = {
|
|
2340
2368
|
prompt: input.prompt,
|
|
2341
|
-
developerInstructions:
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2369
|
+
developerInstructions: ""
|
|
2370
|
+
};
|
|
2371
|
+
else if (isRawCopilotModelRun(input)) {
|
|
2372
|
+
promptPolicyResult = promptToolPolicy?.apply();
|
|
2373
|
+
promptBuild = {
|
|
2374
|
+
prompt: input.prompt,
|
|
2375
|
+
developerInstructions: ""
|
|
2376
|
+
};
|
|
2377
|
+
} else {
|
|
2378
|
+
if (!ordinaryAttemptInput) throw new Error("Copilot ordinary attempt authority is unavailable.");
|
|
2379
|
+
if (!promptToolPolicy) throw new Error("Copilot ordinary attempts require a prompt tool policy.");
|
|
2380
|
+
promptBuild = await resolveAgentHarnessBeforePromptBuildResult({
|
|
2381
|
+
prompt: input.prompt,
|
|
2382
|
+
developerInstructions: { build: ({ toolsAllow }) => {
|
|
2383
|
+
promptPolicyResult = promptToolPolicy.apply({
|
|
2384
|
+
toolsAllow,
|
|
2385
|
+
forceToolNames
|
|
2386
|
+
});
|
|
2387
|
+
return buildCopilotPromptGuidance({
|
|
2388
|
+
attempt: input,
|
|
2389
|
+
callableToolNames: promptPolicyResult.callableToolNames,
|
|
2390
|
+
workspaceBootstrapInstructions: workspaceBootstrap.instructions
|
|
2391
|
+
});
|
|
2392
|
+
} },
|
|
2393
|
+
messages,
|
|
2394
|
+
ctx: hookContext,
|
|
2395
|
+
bootstrapContextRunKind: input.bootstrapContextRunKind,
|
|
2396
|
+
toolAuthority: {
|
|
2397
|
+
fingerprint: input.toolAuthorityFingerprint,
|
|
2398
|
+
activeToolNames: () => promptPolicyResult?.callableToolNames ?? [],
|
|
2399
|
+
assertActive: ordinaryAttemptInput.hostCapabilities.assertActive
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2349
2403
|
const attemptInput = promptBuild.prompt === input.prompt ? input : {
|
|
2350
2404
|
...input,
|
|
2351
2405
|
prompt: promptBuild.prompt
|
|
2352
2406
|
};
|
|
2353
|
-
const promptTools =
|
|
2407
|
+
const promptTools = promptPolicyResult?.tools ?? [];
|
|
2408
|
+
const finalDeveloperInstructions = promptBuild.developerInstructions;
|
|
2354
2409
|
const includeAskUser = !ringZeroSystemAgentRun && (attemptInput.pluginHarnessToolPolicyRestricted !== true || promptTools.some((tool) => tool.name === "ask_user"));
|
|
2355
2410
|
let promptImagesCount = 0;
|
|
2356
2411
|
const emitLlmInput = (prompt, additionalContext) => {
|
|
@@ -2361,7 +2416,7 @@ async function createCopilotSessionSetup(params) {
|
|
|
2361
2416
|
sessionId: input.sessionId,
|
|
2362
2417
|
provider: modelRef.provider,
|
|
2363
2418
|
model: modelRef.id,
|
|
2364
|
-
...
|
|
2419
|
+
...finalDeveloperInstructions ? { systemPrompt: finalDeveloperInstructions } : {},
|
|
2365
2420
|
prompt: additionalContext ? `${prompt}\n\n${additionalContext}` : prompt,
|
|
2366
2421
|
historyMessages: [],
|
|
2367
2422
|
imagesCount: promptImagesCount,
|
|
@@ -2378,14 +2433,14 @@ async function createCopilotSessionSetup(params) {
|
|
|
2378
2433
|
signal
|
|
2379
2434
|
});
|
|
2380
2435
|
})();
|
|
2381
|
-
const sessionConfig = createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, sessionProvider,
|
|
2436
|
+
const sessionConfig = createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, sessionProvider, finalDeveloperInstructions || void 0, effectiveWorkspaceDir, effectiveCwd, userInputBridge?.onUserInputRequest, {
|
|
2382
2437
|
hooksBridgeOptions: hasNativePromptHook ? { onUserPromptSubmitted: ({ additionalContext, prompt }) => emitLlmInput(prompt, additionalContext) } : void 0,
|
|
2383
2438
|
includeAskUser,
|
|
2384
2439
|
operation: operation ?? "attempt"
|
|
2385
2440
|
});
|
|
2386
2441
|
return {
|
|
2387
2442
|
attemptInput,
|
|
2388
|
-
compactionSessionConfig: byokProxy ? createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, poolAcquire.provider,
|
|
2443
|
+
compactionSessionConfig: byokProxy ? createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, poolAcquire.provider, finalDeveloperInstructions || void 0, effectiveWorkspaceDir, effectiveCwd, userInputBridge?.onUserInputRequest, {
|
|
2389
2444
|
hooksBridgeOptions: hasNativePromptHook ? { onUserPromptSubmitted: ({ additionalContext, prompt }) => emitLlmInput(prompt, additionalContext) } : void 0,
|
|
2390
2445
|
includeAskUser,
|
|
2391
2446
|
operation: operation ?? "attempt"
|
|
@@ -3027,6 +3082,7 @@ async function runCopilotExecution(context) {
|
|
|
3027
3082
|
let downgradedFromResume = false;
|
|
3028
3083
|
let resumeFailureRecovered = false;
|
|
3029
3084
|
let yieldDetected = false;
|
|
3085
|
+
let yieldAcknowledgment;
|
|
3030
3086
|
let lastToolError;
|
|
3031
3087
|
const hostObserveToolTerminal = input.observeToolTerminal;
|
|
3032
3088
|
const observeToolTerminal = hostObserveToolTerminal ? (observation) => {
|
|
@@ -3124,8 +3180,8 @@ async function runCopilotExecution(context) {
|
|
|
3124
3180
|
const sessionRef = { current: void 0 };
|
|
3125
3181
|
const computerContextEpoch = { value: 0 };
|
|
3126
3182
|
let codeModeEngaged;
|
|
3183
|
+
let promptToolPolicy;
|
|
3127
3184
|
try {
|
|
3128
|
-
let sdkTools = [];
|
|
3129
3185
|
let resultContentSourceByToolName = /* @__PURE__ */ new Map();
|
|
3130
3186
|
if (!settledToolFinalization) try {
|
|
3131
3187
|
assertCopilotAttemptHostCapabilities(input);
|
|
@@ -3148,8 +3204,9 @@ async function runCopilotExecution(context) {
|
|
|
3148
3204
|
} : input,
|
|
3149
3205
|
computerContextEpoch,
|
|
3150
3206
|
sessionRef,
|
|
3151
|
-
onYieldDetected: () => {
|
|
3207
|
+
onYieldDetected: (_message, acknowledgment) => {
|
|
3152
3208
|
yieldDetected = true;
|
|
3209
|
+
yieldAcknowledgment = acknowledgment;
|
|
3153
3210
|
},
|
|
3154
3211
|
onToolCompleted: ({ args, error, result, startedAt, toolCallId, toolName }) => runAgentHarnessAfterToolCallHook({
|
|
3155
3212
|
toolName,
|
|
@@ -3167,7 +3224,7 @@ async function runCopilotExecution(context) {
|
|
|
3167
3224
|
});
|
|
3168
3225
|
cleanupToolBridge = toolBridge.cleanup;
|
|
3169
3226
|
codeModeEngaged = toolBridge.codeModeEngaged;
|
|
3170
|
-
|
|
3227
|
+
promptToolPolicy = toolBridge.promptToolPolicy;
|
|
3171
3228
|
resultContentSourceByToolName = new Map(toolBridge.sourceTools.flatMap((tool) => tool.resultContentSource ? [[tool.name, tool.resultContentSource]] : []));
|
|
3172
3229
|
} catch (error) {
|
|
3173
3230
|
return finishAttempt(createResult(input, {
|
|
@@ -3191,7 +3248,7 @@ async function runCopilotExecution(context) {
|
|
|
3191
3248
|
operation: deps.operation,
|
|
3192
3249
|
poolAcquire,
|
|
3193
3250
|
ringZeroSystemAgentRun,
|
|
3194
|
-
|
|
3251
|
+
promptToolPolicy,
|
|
3195
3252
|
sessionProvider,
|
|
3196
3253
|
settledToolFinalization,
|
|
3197
3254
|
signal: params.abortSignal
|
|
@@ -3207,7 +3264,8 @@ async function runCopilotExecution(context) {
|
|
|
3207
3264
|
if (resumeSessionId) try {
|
|
3208
3265
|
session = await client.resumeSession(resumeSessionId, {
|
|
3209
3266
|
...sessionConfig,
|
|
3210
|
-
continuePendingWork: false
|
|
3267
|
+
continuePendingWork: false,
|
|
3268
|
+
...settledToolFinalization ? { suppressResumeEvent: true } : {}
|
|
3211
3269
|
});
|
|
3212
3270
|
nativeSessionHistoryValidated = input.initialReplayState?.journalValidated === true;
|
|
3213
3271
|
} catch (error) {
|
|
@@ -3440,7 +3498,8 @@ async function runCopilotExecution(context) {
|
|
|
3440
3498
|
settledToolFinalization,
|
|
3441
3499
|
timedOut,
|
|
3442
3500
|
timedOutDuringCompaction,
|
|
3443
|
-
yieldDetected
|
|
3501
|
+
yieldDetected,
|
|
3502
|
+
yieldAcknowledgment
|
|
3444
3503
|
});
|
|
3445
3504
|
}
|
|
3446
3505
|
//#endregion
|
|
@@ -687,12 +687,16 @@ function readAgentIdFromSessionKey(sessionKey) {
|
|
|
687
687
|
const parts = sessionKey.trim().split(":");
|
|
688
688
|
return parts[0] === "agent" && parts[1]?.trim() ? parts[1].trim() : void 0;
|
|
689
689
|
}
|
|
690
|
-
function computeSessionKey(
|
|
691
|
-
const
|
|
692
|
-
const
|
|
693
|
-
const
|
|
694
|
-
const
|
|
695
|
-
const
|
|
690
|
+
function computeSessionKey(input, options) {
|
|
691
|
+
const attempt = input.kind === "attempt" ? input.params : void 0;
|
|
692
|
+
const compact = input.kind === "compact" ? input.params : void 0;
|
|
693
|
+
const attemptModel = attempt?.model;
|
|
694
|
+
const compactModel = compact?.model;
|
|
695
|
+
const rawModel = attemptModel ?? compactModel;
|
|
696
|
+
const modelObj = rawModel && typeof rawModel === "object" ? rawModel : compact?.runtimeModel ?? { id: typeof rawModel === "string" ? rawModel : void 0 };
|
|
697
|
+
const provider = normalizeOptionalString(modelObj.provider) ?? attempt?.provider ?? compact?.provider ?? "";
|
|
698
|
+
const modelId = normalizeOptionalString(modelObj.id) ?? attempt?.modelId ?? compact?.modelId ?? (typeof compactModel === "string" ? compactModel : "");
|
|
699
|
+
const requestTransport = rawModel && typeof rawModel === "object" ? getModelProviderRequestTransport(rawModel) : void 0;
|
|
696
700
|
const requestAuthMode = normalizeOptionalString(requestTransport?.auth?.mode ?? modelObj.request?.auth?.mode);
|
|
697
701
|
const azureApiVersion = normalizeOptionalString(modelObj.azureApiVersion ?? modelObj.params?.azureApiVersion);
|
|
698
702
|
let authParts;
|
|
@@ -700,18 +704,18 @@ function computeSessionKey(params, options) {
|
|
|
700
704
|
let resolvedCopilotHome = "";
|
|
701
705
|
try {
|
|
702
706
|
const resolved = !options.includeAuth ? resolveCopilotAuth({
|
|
703
|
-
agentId:
|
|
704
|
-
agentDir:
|
|
705
|
-
workspaceDir:
|
|
706
|
-
copilotHome:
|
|
707
|
+
agentId: input.params.agentId ?? readAgentIdFromSessionKey(input.params.sessionKey),
|
|
708
|
+
agentDir: input.params.agentDir,
|
|
709
|
+
workspaceDir: input.params.workspaceDir,
|
|
710
|
+
copilotHome: input.params.copilotHome,
|
|
707
711
|
auth: { useLoggedInUser: true }
|
|
708
712
|
}) : (() => {
|
|
709
713
|
const modelProvider = resolveCopilotProvider({
|
|
710
714
|
model: {
|
|
711
|
-
api: modelObj.api,
|
|
715
|
+
api: normalizeOptionalString(modelObj.api),
|
|
712
716
|
id: modelId,
|
|
713
717
|
provider,
|
|
714
|
-
baseUrl: modelObj.baseUrl,
|
|
718
|
+
baseUrl: normalizeOptionalString(modelObj.baseUrl),
|
|
715
719
|
azureApiVersion,
|
|
716
720
|
headers: modelObj.headers,
|
|
717
721
|
authHeader: modelObj.authHeader,
|
|
@@ -723,25 +727,25 @@ function computeSessionKey(params, options) {
|
|
|
723
727
|
contextWindow: modelObj.contextWindow,
|
|
724
728
|
maxTokens: modelObj.maxTokens
|
|
725
729
|
},
|
|
726
|
-
resolvedApiKey:
|
|
727
|
-
authProfileId:
|
|
730
|
+
resolvedApiKey: input.params.resolvedApiKey,
|
|
731
|
+
authProfileId: input.params.authProfileId
|
|
728
732
|
});
|
|
729
733
|
return modelProvider.mode === "byok" ? createCopilotByokAuth({
|
|
730
|
-
agentId:
|
|
731
|
-
agentDir:
|
|
732
|
-
workspaceDir:
|
|
733
|
-
copilotHome:
|
|
734
|
+
agentId: input.params.agentId ?? readAgentIdFromSessionKey(input.params.sessionKey),
|
|
735
|
+
agentDir: input.params.agentDir,
|
|
736
|
+
workspaceDir: input.params.workspaceDir,
|
|
737
|
+
copilotHome: input.params.copilotHome,
|
|
734
738
|
authProfileId: modelProvider.authProfileId,
|
|
735
739
|
authProfileVersion: modelProvider.authProfileVersion
|
|
736
740
|
}) : resolveCopilotAuth({
|
|
737
|
-
agentId:
|
|
738
|
-
agentDir:
|
|
739
|
-
workspaceDir:
|
|
740
|
-
copilotHome:
|
|
741
|
-
auth:
|
|
742
|
-
resolvedApiKey:
|
|
743
|
-
authProfileId:
|
|
744
|
-
profileVersion:
|
|
741
|
+
agentId: input.params.agentId ?? readAgentIdFromSessionKey(input.params.sessionKey),
|
|
742
|
+
agentDir: input.params.agentDir,
|
|
743
|
+
workspaceDir: input.params.workspaceDir,
|
|
744
|
+
copilotHome: input.params.copilotHome,
|
|
745
|
+
auth: input.params.auth,
|
|
746
|
+
resolvedApiKey: input.params.resolvedApiKey,
|
|
747
|
+
authProfileId: input.params.authProfileId,
|
|
748
|
+
profileVersion: input.params.profileVersion
|
|
745
749
|
});
|
|
746
750
|
})();
|
|
747
751
|
resolvedAgentId = resolved.agentId;
|
|
@@ -758,12 +762,12 @@ function computeSessionKey(params, options) {
|
|
|
758
762
|
return [
|
|
759
763
|
`provider=${provider}`,
|
|
760
764
|
`model=${modelId}`,
|
|
761
|
-
...options.includeApi ? [`api=${modelObj.api ?? ""}`] : [],
|
|
765
|
+
...options.includeApi ? [`api=${normalizeOptionalString(modelObj.api) ?? ""}`] : [],
|
|
762
766
|
...options.includeApi ? [`baseUrlFingerprint=${fingerprintSessionValue(modelObj.baseUrl)}`] : [],
|
|
763
|
-
`cwd=${
|
|
767
|
+
`cwd=${input.params.cwd ?? input.params.workspaceDir ?? ""}`,
|
|
764
768
|
`agentId=${resolvedAgentId}`,
|
|
765
|
-
`agentDir=${
|
|
766
|
-
`copilotHome=${
|
|
769
|
+
`agentDir=${input.params.agentDir ?? ""}`,
|
|
770
|
+
`copilotHome=${input.params.copilotHome ?? ""}`,
|
|
767
771
|
`resolvedCopilotHome=${resolvedCopilotHome}`,
|
|
768
772
|
...options.includeAuth ? authParts : []
|
|
769
773
|
].join("|");
|
|
@@ -772,13 +776,28 @@ function fingerprintSessionValue(value) {
|
|
|
772
776
|
return typeof value === "string" && value ? tokenFingerprint(value) : "";
|
|
773
777
|
}
|
|
774
778
|
function computeSessionCompatKey(params) {
|
|
775
|
-
return computeSessionKey(
|
|
779
|
+
return computeSessionKey({
|
|
780
|
+
kind: "attempt",
|
|
781
|
+
params
|
|
782
|
+
}, {
|
|
776
783
|
includeApi: true,
|
|
777
784
|
includeAuth: true
|
|
778
785
|
});
|
|
779
786
|
}
|
|
780
|
-
function
|
|
781
|
-
return computeSessionKey(
|
|
787
|
+
function computeAttemptCompactKey(params) {
|
|
788
|
+
return computeSessionKey({
|
|
789
|
+
kind: "attempt",
|
|
790
|
+
params
|
|
791
|
+
}, {
|
|
792
|
+
includeApi: false,
|
|
793
|
+
includeAuth: false
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function computeCompactRequestKey(params) {
|
|
797
|
+
return computeSessionKey({
|
|
798
|
+
kind: "compact",
|
|
799
|
+
params
|
|
800
|
+
}, {
|
|
782
801
|
includeApi: false,
|
|
783
802
|
includeAuth: false
|
|
784
803
|
});
|
|
@@ -808,7 +827,7 @@ function createCopilotAgentHarness(options) {
|
|
|
808
827
|
async function getPool() {
|
|
809
828
|
if (options?.pool) return options.pool;
|
|
810
829
|
if (!poolPromise) poolPromise = (async () => {
|
|
811
|
-
const { createCopilotClientPool } = await import("./runtime-
|
|
830
|
+
const { createCopilotClientPool } = await import("./runtime-DvZQV_8v.js");
|
|
812
831
|
createdPool = createCopilotClientPool(options?.poolOptions);
|
|
813
832
|
return createdPool;
|
|
814
833
|
})();
|
|
@@ -845,7 +864,7 @@ function createCopilotAgentHarness(options) {
|
|
|
845
864
|
async function runHarnessAttempt(params, operation) {
|
|
846
865
|
const attemptPromise = (async () => {
|
|
847
866
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
|
|
848
|
-
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-
|
|
867
|
+
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-NJAPbYd4.js");
|
|
849
868
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
850
869
|
const pool = await getPool();
|
|
851
870
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
@@ -858,7 +877,7 @@ function createCopilotAgentHarness(options) {
|
|
|
858
877
|
}
|
|
859
878
|
const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
|
|
860
879
|
const currentCompatKey = computeSessionCompatKey(params);
|
|
861
|
-
const currentCompactKey =
|
|
880
|
+
const currentCompactKey = computeAttemptCompactKey(params);
|
|
862
881
|
const compactionCleanupPending = openclawSessionId !== void 0 && hasPendingDeferredCompactionCleanup(openclawSessionId);
|
|
863
882
|
const replayBlocked = openclawSessionId !== void 0 && (compactionCleanupPending || resetBlockedStoredSessions.has(openclawSessionId));
|
|
864
883
|
const tracked = openclawSessionId && !replayBlocked ? trackedSessions.get(openclawSessionId) : void 0;
|
|
@@ -976,7 +995,7 @@ function createCopilotAgentHarness(options) {
|
|
|
976
995
|
async function runIsolatedCompletionV2(params) {
|
|
977
996
|
const completionPromise = (async () => {
|
|
978
997
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start isolated completion");
|
|
979
|
-
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-
|
|
998
|
+
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-GNSNtOHz.js");
|
|
980
999
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
981
1000
|
return await runCopilotIsolatedCompletion(params, async () => {
|
|
982
1001
|
const pool = await getPool();
|
|
@@ -1066,8 +1085,8 @@ function createCopilotAgentHarness(options) {
|
|
|
1066
1085
|
failure: { reason: "background-compaction-pending" }
|
|
1067
1086
|
};
|
|
1068
1087
|
const tracked = trackedSessions.get(openclawSessionId);
|
|
1069
|
-
const currentCompactKey =
|
|
1070
|
-
const { resolvePoolAcquire } = await import("./attempt-
|
|
1088
|
+
const currentCompactKey = computeCompactRequestKey(params);
|
|
1089
|
+
const { resolvePoolAcquire } = await import("./attempt-NJAPbYd4.js");
|
|
1071
1090
|
let resolvedPoolAcquire;
|
|
1072
1091
|
let currentAuth;
|
|
1073
1092
|
try {
|
package/dist/harness.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createCopilotAgentHarness } from "./harness-
|
|
1
|
+
import { t as createCopilotAgentHarness } from "./harness-hh25oAuF.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-hh25oAuF.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-hh25oAuF.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.
|
|
3
|
+
"version": "2026.9.1-beta.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.
|
|
27
|
+
"pluginApi": ">=2026.9.1-beta.1"
|
|
28
28
|
},
|
|
29
29
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.
|
|
30
|
+
"openclawVersion": "2026.9.1-beta.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-beta.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"openclaw": {
|