@openclaw/copilot 2026.8.1-beta.2 → 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-BNDq00ZS.js → attempt-DwhhWgyV.js} +189 -166
- package/dist/{harness-EyKssDe5.js → harness-DvYbOGRx.js} +61 -47
- package/dist/harness.js +1 -1
- package/dist/index.js +9 -4
- package/dist/{isolated-completion-CM4w2GCk.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, readNonBlankString, readNonEmptyStringPreservingWhitespace, readNonEmptyStringPreservingWhitespace as readNonEmptyString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
-
import {
|
|
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";
|
|
@@ -304,7 +305,7 @@ function createResult(params, state) {
|
|
|
304
305
|
const toolMetas = state.toolMetas ?? [];
|
|
305
306
|
const replayMetadata = params.operation === "settled-tool-finalization" ? {
|
|
306
307
|
hadPotentialSideEffects: false,
|
|
307
|
-
replaySafe:
|
|
308
|
+
replaySafe: !transcriptPersistenceFailed
|
|
308
309
|
} : computeReplayMetadata({
|
|
309
310
|
priorReplayInvalid: params.initialReplayState?.replayInvalid === true || state.nativeReplayInvalid === true || transcriptPersistenceFailed,
|
|
310
311
|
priorHadPotentialSideEffects: params.initialReplayState?.hadPotentialSideEffects,
|
|
@@ -351,9 +352,10 @@ 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
|
-
yieldDetected: state.yieldDetected === true
|
|
357
|
+
yieldDetected: state.yieldDetected === true,
|
|
358
|
+
...state.yieldAcknowledgment ? { yieldAcknowledgment: state.yieldAcknowledgment } : {}
|
|
357
359
|
};
|
|
358
360
|
}
|
|
359
361
|
function createPromptError$1(code, message, cause) {
|
|
@@ -441,21 +443,6 @@ function resolveImageCapabilityModel(params) {
|
|
|
441
443
|
if (model && typeof model === "object" && Array.isArray(model.input)) return { input: model.input };
|
|
442
444
|
return { input: ["image"] };
|
|
443
445
|
}
|
|
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
446
|
function readResolvedAttemptPath(value) {
|
|
460
447
|
const raw = readNonEmptyString(value)?.trim();
|
|
461
448
|
if (!raw) return;
|
|
@@ -556,7 +543,7 @@ function buildAssistantMessage(params) {
|
|
|
556
543
|
type: "text"
|
|
557
544
|
});
|
|
558
545
|
for (const request of toolRequests) content.push({
|
|
559
|
-
arguments: request.arguments
|
|
546
|
+
arguments: asNonArrayRecord(request.arguments),
|
|
560
547
|
id: request.toolCallId,
|
|
561
548
|
name: request.name,
|
|
562
549
|
type: "toolCall"
|
|
@@ -1359,6 +1346,7 @@ function registerCopilotActiveRun(params) {
|
|
|
1359
1346
|
const activeRunHandle = {
|
|
1360
1347
|
kind: "embedded",
|
|
1361
1348
|
runId: params.input.runId,
|
|
1349
|
+
startedAtMs: params.startedAtMs,
|
|
1362
1350
|
toolAuthorityFingerprint: params.input.toolAuthorityFingerprint,
|
|
1363
1351
|
claimPendingUserInputAnswer,
|
|
1364
1352
|
cancelPendingUserInput,
|
|
@@ -1403,7 +1391,7 @@ async function waitForPersistenceReceipt(receipt, requestedTimeoutMs) {
|
|
|
1403
1391
|
//#endregion
|
|
1404
1392
|
//#region extensions/copilot/src/attempt-finalize.ts
|
|
1405
1393
|
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,
|
|
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;
|
|
1407
1395
|
const snap = bridge?.snapshot();
|
|
1408
1396
|
const assistantTexts = bridge?.finalizeAssistantTexts() ?? [];
|
|
1409
1397
|
const lastAssistant = bridge?.buildAssistantMessage({
|
|
@@ -1439,12 +1427,12 @@ async function completeCopilotAttempt(params) {
|
|
|
1439
1427
|
promptError,
|
|
1440
1428
|
resumeFailureRecovered,
|
|
1441
1429
|
sdkSessionId,
|
|
1442
|
-
sessionIdUsed,
|
|
1443
1430
|
timedOut,
|
|
1444
1431
|
timedOutDuringCompaction,
|
|
1445
1432
|
toolMetas: snap ? [...snap.toolMetas] : [],
|
|
1446
1433
|
usage: snap?.usage,
|
|
1447
|
-
yieldDetected
|
|
1434
|
+
yieldDetected,
|
|
1435
|
+
yieldAcknowledgment
|
|
1448
1436
|
});
|
|
1449
1437
|
if (sentTurnStarted && !settledToolFinalization && !transcriptJournal?.hasFailed()) runAgentHarnessLlmOutputHook({
|
|
1450
1438
|
event: {
|
|
@@ -1503,7 +1491,16 @@ function userText$1(content) {
|
|
|
1503
1491
|
return JSON.stringify(content) ?? "";
|
|
1504
1492
|
}
|
|
1505
1493
|
//#endregion
|
|
1494
|
+
//#region extensions/copilot/src/attempt-mode.ts
|
|
1495
|
+
function isRawCopilotModelRun(params) {
|
|
1496
|
+
return params.modelRun === true || params.promptMode === "none";
|
|
1497
|
+
}
|
|
1498
|
+
//#endregion
|
|
1506
1499
|
//#region extensions/copilot/src/tool-bridge.ts
|
|
1500
|
+
const EMPTY_PROMPT_TOOL_POLICY = { apply: () => ({
|
|
1501
|
+
tools: [],
|
|
1502
|
+
callableToolNames: []
|
|
1503
|
+
}) };
|
|
1507
1504
|
const SUPPORTED_TOOL_PROVIDERS = /* @__PURE__ */ new Set(["github-copilot"]);
|
|
1508
1505
|
const BASE_COPILOT_CODING_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1509
1506
|
"edit",
|
|
@@ -1515,37 +1512,25 @@ const SHELL_COPILOT_CODING_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
1515
1512
|
"exec",
|
|
1516
1513
|
"process"
|
|
1517
1514
|
]);
|
|
1518
|
-
function supportsModelTools(modelProvider) {
|
|
1519
|
-
return SUPPORTED_TOOL_PROVIDERS.has(modelProvider);
|
|
1520
|
-
}
|
|
1521
1515
|
async function createCopilotToolBridge(input) {
|
|
1522
|
-
if (!input.allowModelTools && !
|
|
1516
|
+
if (!input.allowModelTools && !SUPPORTED_TOOL_PROVIDERS.has(input.modelProvider)) return {
|
|
1523
1517
|
codeModeEngaged: false,
|
|
1524
|
-
|
|
1518
|
+
promptToolPolicy: EMPTY_PROMPT_TOOL_POLICY,
|
|
1525
1519
|
sourceTools: []
|
|
1526
1520
|
};
|
|
1527
1521
|
const attemptParams = input.attemptParams;
|
|
1528
1522
|
const toolPlan = resolveEmbeddedAttemptToolConstructionPlan({
|
|
1529
1523
|
disableTools: attemptParams.disableTools,
|
|
1530
1524
|
forceMessageTool: shouldForceCopilotMessageTool(attemptParams),
|
|
1531
|
-
isRawModelRun:
|
|
1532
|
-
toolsAllow:
|
|
1525
|
+
isRawModelRun: isRawCopilotModelRun(attemptParams),
|
|
1526
|
+
toolsAllow: buildEmbeddedAttemptToolRunContext({
|
|
1527
|
+
...attemptParams,
|
|
1528
|
+
forceMessageTool: shouldForceCopilotMessageTool(attemptParams)
|
|
1529
|
+
}).runtimeToolAllowlist
|
|
1533
1530
|
});
|
|
1534
|
-
|
|
1535
|
-
...toolPlan,
|
|
1536
|
-
codingToolConstructionPlan: {
|
|
1537
|
-
includeBaseCodingTools: true,
|
|
1538
|
-
includeChannelTools: true,
|
|
1539
|
-
includeOpenClawTools: true,
|
|
1540
|
-
includePluginTools: true,
|
|
1541
|
-
includeShellTools: true
|
|
1542
|
-
},
|
|
1543
|
-
constructTools: true,
|
|
1544
|
-
includeCoreTools: true
|
|
1545
|
-
} : toolPlan;
|
|
1546
|
-
if (!effectiveToolPlan.constructTools) return {
|
|
1531
|
+
if (!toolPlan.constructTools) return {
|
|
1547
1532
|
codeModeEngaged: false,
|
|
1548
|
-
|
|
1533
|
+
promptToolPolicy: EMPTY_PROMPT_TOOL_POLICY,
|
|
1549
1534
|
sourceTools: []
|
|
1550
1535
|
};
|
|
1551
1536
|
const createOpenClawCodingTools = input.createOpenClawCodingTools ?? (await import("openclaw/plugin-sdk/agent-harness")).createOpenClawCodingTools;
|
|
@@ -1553,26 +1538,27 @@ async function createCopilotToolBridge(input) {
|
|
|
1553
1538
|
abortSignal: input.abortSignal,
|
|
1554
1539
|
agentId: input.agentId,
|
|
1555
1540
|
config: attemptParams.config,
|
|
1541
|
+
codeModeOverride: attemptParams.codeModeOverride,
|
|
1556
1542
|
disableTools: attemptParams.disableTools,
|
|
1557
1543
|
executeTool: (toolParams) => executeCatalogTool(input, toolParams),
|
|
1558
1544
|
forceMessageTool: shouldForceCopilotMessageTool(attemptParams),
|
|
1559
|
-
isRawModelRun:
|
|
1545
|
+
isRawModelRun: isRawCopilotModelRun(attemptParams),
|
|
1560
1546
|
model: attemptParams.model,
|
|
1547
|
+
contextTokenBudget: attemptParams.contextTokenBudget,
|
|
1561
1548
|
modelId: input.modelId,
|
|
1562
1549
|
modelProvider: input.modelProvider,
|
|
1563
1550
|
modelToolsEnabled: true,
|
|
1564
1551
|
prompt: attemptParams.prompt,
|
|
1565
1552
|
runId: attemptParams.runId,
|
|
1566
|
-
runtimeToolAllowlist:
|
|
1553
|
+
runtimeToolAllowlist: toolPlan.runtimeToolAllowlist,
|
|
1567
1554
|
sessionId: input.sessionId,
|
|
1568
1555
|
sessionKey: attemptParams.sandboxSessionKey ?? attemptParams.sessionKey ?? input.sessionKey,
|
|
1569
1556
|
scheduledToolPolicy: attemptParams.scheduledToolPolicy,
|
|
1570
|
-
skillWorkshopProposalOnly: attemptParams.skillWorkshopProposalOnly,
|
|
1571
1557
|
sourceReplyDeliveryMode: attemptParams.sourceReplyDeliveryMode,
|
|
1572
1558
|
toolsAllow: attemptParams.toolsAllow
|
|
1573
1559
|
});
|
|
1574
1560
|
const toolOptions = buildOpenClawCodingToolsOptions(input, {
|
|
1575
|
-
...
|
|
1561
|
+
...toolPlan,
|
|
1576
1562
|
runtimeToolAllowlist: toolSurfaceRuntime.runtimeToolAllowlist
|
|
1577
1563
|
}, toolSurfaceRuntime);
|
|
1578
1564
|
let sourceTools;
|
|
@@ -1590,50 +1576,48 @@ async function createCopilotToolBridge(input) {
|
|
|
1590
1576
|
} catch (error) {
|
|
1591
1577
|
throw createError(`[copilot-tool-bridge] createOpenClawCodingTools failed: ${toStringifiedError(error).message}`, error);
|
|
1592
1578
|
}
|
|
1593
|
-
const
|
|
1594
|
-
const
|
|
1595
|
-
const newlyConstructedTools =
|
|
1579
|
+
const plannedSourceTools = filterCopilotToolsForConstructionPlan(applyEmbeddedAttemptToolsAllow(sourceTools, toolSurfaceRuntime.runtimeToolAllowlist, { toolMeta: (tool) => getPluginToolMeta(tool) ?? readInlinePluginToolMeta(tool) }), toolPlan.codingToolConstructionPlan, { preserveToolNames: toolSurfaceRuntime.runtimeToolAllowlist });
|
|
1580
|
+
const compactedTools = toolSurfaceRuntime.compactTools(plannedSourceTools, { localModelLeanApplied: true });
|
|
1581
|
+
const newlyConstructedTools = compactedTools.tools.filter((tool) => !boundSourceTools.has(tool));
|
|
1596
1582
|
const boundNewlyConstructedTools = newlyConstructedTools.length > 0 ? hostCapabilities.bindToolSurface(newlyConstructedTools, bindingOptions) : newlyConstructedTools;
|
|
1597
1583
|
if (boundNewlyConstructedTools.length !== newlyConstructedTools.length) throw new Error("Copilot host capability changed the tool surface length.");
|
|
1598
1584
|
const newlyBoundTools = /* @__PURE__ */ new Map();
|
|
1599
1585
|
for (let index = 0; index < newlyConstructedTools.length; index += 1) newlyBoundTools.set(newlyConstructedTools[index], boundNewlyConstructedTools[index]);
|
|
1600
|
-
const exposedTools =
|
|
1586
|
+
const exposedTools = compactedTools.tools.map((tool) => newlyBoundTools.get(tool) ?? tool);
|
|
1601
1587
|
const duplicateNames = findDuplicateToolNames(exposedTools);
|
|
1602
1588
|
if (duplicateNames.length > 0) throw new Error(`[copilot-tool-bridge] duplicate tool names: ${duplicateNames.join(", ")}`);
|
|
1589
|
+
const sdkTools = exposedTools.map((sourceTool) => convertOpenClawToolToSdkTool(sourceTool, {
|
|
1590
|
+
abortSignal: input.abortSignal,
|
|
1591
|
+
beforeExecute: input.beforeExecute,
|
|
1592
|
+
onAgentToolResult: input.attemptParams?.onAgentToolResult,
|
|
1593
|
+
onToolCompleted: input.onToolCompleted,
|
|
1594
|
+
observeToolTerminal: input.attemptParams?.observeToolTerminal
|
|
1595
|
+
}));
|
|
1603
1596
|
return {
|
|
1604
1597
|
cleanup: toolSurfaceRuntime.cleanup,
|
|
1605
1598
|
codeModeEngaged: toolSurfaceRuntime.codeModeControlsEnabled,
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1599
|
+
promptToolPolicy: { apply: (params = {}) => {
|
|
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
|
+
const directToolNames = new Set(result.tools.map((tool) => tool.name));
|
|
1609
|
+
return {
|
|
1610
|
+
tools: sdkTools.filter((tool) => directToolNames.has(tool.name)),
|
|
1611
|
+
callableToolNames: result.callableToolNames
|
|
1612
|
+
};
|
|
1613
|
+
} },
|
|
1613
1614
|
sourceTools: exposedTools
|
|
1614
1615
|
};
|
|
1615
1616
|
}
|
|
1616
1617
|
/**
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1619
|
-
*
|
|
1620
|
-
* Why PI parity matters: bridged OpenClaw tools register with the SDK
|
|
1621
|
-
* as `overridesBuiltInTool: true, skipPermission: true` (see
|
|
1622
|
-
* `convertOpenClawToolToSdkTool` below). That means the wrapped-tool
|
|
1623
|
-
* enforcement layer
|
|
1624
|
-
* (`src/agents/pi-tools.before-tool-call.ts → wrapToolWithBeforeToolCallHook`)
|
|
1625
|
-
* is the single gate for permission, owner-only allowlists, loop
|
|
1626
|
-
* detection, trusted-plugin policies, and two-phase plugin approvals.
|
|
1627
|
-
* That layer reads its context from the fields forwarded here; missing
|
|
1628
|
-
* fields silently degrade policy decisions. See docs/plugins/copilot.md.
|
|
1629
|
-
*
|
|
1630
|
-
* The shared embedded-runner tool plan is forwarded so the bridge does
|
|
1631
|
-
* not construct broad tool families only to filter them later. That
|
|
1632
|
-
* preserves PI allowlist semantics such as `write` not materializing
|
|
1633
|
-
* `apply_patch`.
|
|
1634
|
-
* Sandbox is forwarded via the explicit `sandbox` field on
|
|
1635
|
-
* {@link CopilotToolBridgeInput}; callers resolve it via
|
|
1636
|
-
* `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.
|
|
1637
1621
|
*/
|
|
1638
1622
|
function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
1639
1623
|
const a = input.attemptParams;
|
|
@@ -1653,18 +1637,13 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1653
1637
|
const modelCompat = model && typeof model === "object" && "compat" in model && model.compat && typeof model.compat === "object" ? model.compat : void 0;
|
|
1654
1638
|
return {
|
|
1655
1639
|
agentId: input.agentId,
|
|
1656
|
-
...buildEmbeddedAttemptToolRunContext(
|
|
1657
|
-
trigger: a.trigger,
|
|
1658
|
-
jobId: a.jobId,
|
|
1659
|
-
memoryFlushWritePath: a.memoryFlushWritePath,
|
|
1660
|
-
toolsAllow: a.toolsAllow,
|
|
1661
|
-
conversationToolPolicy: a.conversationToolPolicy
|
|
1662
|
-
}),
|
|
1640
|
+
...buildEmbeddedAttemptToolRunContext(a),
|
|
1663
1641
|
exec: {
|
|
1664
1642
|
...a.execOverrides,
|
|
1665
1643
|
elevated: a.bashElevated
|
|
1666
1644
|
},
|
|
1667
1645
|
messageProvider: a.messageProvider ?? a.messageChannel,
|
|
1646
|
+
messageChannel: a.messageChannel,
|
|
1668
1647
|
toolBindings: a.toolBindings,
|
|
1669
1648
|
chatType: a.chatType,
|
|
1670
1649
|
agentAccountId: a.agentAccountId,
|
|
@@ -1689,6 +1668,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1689
1668
|
sessionId: input.sessionId,
|
|
1690
1669
|
runId: a.runId,
|
|
1691
1670
|
agentDir,
|
|
1671
|
+
preparedModelRuntime: a.preparedModelRuntime,
|
|
1692
1672
|
workspaceDir,
|
|
1693
1673
|
cwd,
|
|
1694
1674
|
sandbox,
|
|
@@ -1705,7 +1685,7 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1705
1685
|
toolConstructionPlan: toolPlan.codingToolConstructionPlan,
|
|
1706
1686
|
modelCompat,
|
|
1707
1687
|
modelApi: model?.api,
|
|
1708
|
-
modelContextWindowTokens: model?.contextWindow,
|
|
1688
|
+
modelContextWindowTokens: a.contextTokenBudget ?? model?.contextWindow,
|
|
1709
1689
|
delegationCapability: a.delegationCapability,
|
|
1710
1690
|
modelAuthMode: resolveModelAuthMode(input.modelProvider, a.config, void 0, { workspaceDir }),
|
|
1711
1691
|
currentChannelId: a.currentChannelId,
|
|
@@ -1725,9 +1705,9 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1725
1705
|
computerContextEpoch: input.computerContextEpoch,
|
|
1726
1706
|
onToolOutcome: a.onToolOutcome,
|
|
1727
1707
|
isTurnTainted: a.isTurnTainted,
|
|
1728
|
-
onYield: (message) => {
|
|
1708
|
+
onYield: (message, acknowledgment) => {
|
|
1729
1709
|
try {
|
|
1730
|
-
input.onYieldDetected?.(message);
|
|
1710
|
+
input.onYieldDetected?.(message, acknowledgment);
|
|
1731
1711
|
} catch (error) {
|
|
1732
1712
|
console.warn("[copilot-tool-bridge] onYieldDetected handler threw; continuing", error);
|
|
1733
1713
|
}
|
|
@@ -1738,6 +1718,8 @@ function buildOpenClawCodingToolsOptions(input, toolPlan, toolSurfaceRuntime) {
|
|
|
1738
1718
|
function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
1739
1719
|
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
1720
|
if (typeof sourceTool.execute !== "function") throw new Error(`[copilot-tool-bridge] tool '${sourceTool.name}' must define an execute function`);
|
|
1721
|
+
const ownerKey = getPluginToolSideEffectOwnerKey(sourceTool);
|
|
1722
|
+
const ownerMutation = ownerKey ? { ownerKey } : void 0;
|
|
1741
1723
|
let sequentialLock = Promise.resolve();
|
|
1742
1724
|
const notifyToolResult = (result, isError) => {
|
|
1743
1725
|
try {
|
|
@@ -1767,7 +1749,8 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1767
1749
|
arguments: executedArgs,
|
|
1768
1750
|
executionStarted,
|
|
1769
1751
|
outcome: "failure",
|
|
1770
|
-
failure: { error: errorMessage }
|
|
1752
|
+
failure: { error: errorMessage },
|
|
1753
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1771
1754
|
});
|
|
1772
1755
|
notifyToolResult(sanitizeToolResult({
|
|
1773
1756
|
content: [{
|
|
@@ -1830,7 +1813,8 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1830
1813
|
arguments: preparedArgs,
|
|
1831
1814
|
executionStarted: true,
|
|
1832
1815
|
outcome: resultIsError ? "failure" : "success",
|
|
1833
|
-
...resultIsError ? { failure: { error: resultError ?? "tool returned an error" } } : {}
|
|
1816
|
+
...resultIsError ? { failure: { error: resultError ?? "tool returned an error" } } : {},
|
|
1817
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1834
1818
|
});
|
|
1835
1819
|
notifyToolResult(sanitizedResult, resultIsError);
|
|
1836
1820
|
notifyToolCompleted({
|
|
@@ -1850,6 +1834,7 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1850
1834
|
} : executeOnce;
|
|
1851
1835
|
return {
|
|
1852
1836
|
description: sourceTool.description,
|
|
1837
|
+
defer: sourceTool.catalogMode === "direct-only" ? "never" : void 0,
|
|
1853
1838
|
handler,
|
|
1854
1839
|
name: sourceTool.name,
|
|
1855
1840
|
overridesBuiltInTool: true,
|
|
@@ -1859,6 +1844,8 @@ function convertOpenClawToolToSdkTool(sourceTool, ctx) {
|
|
|
1859
1844
|
}
|
|
1860
1845
|
async function executeCatalogTool(input, params) {
|
|
1861
1846
|
const sourceTool = params.tool;
|
|
1847
|
+
const ownerKey = getPluginToolSideEffectOwnerKey(sourceTool);
|
|
1848
|
+
const ownerMutation = ownerKey ? { ownerKey } : void 0;
|
|
1862
1849
|
const startedAt = Date.now();
|
|
1863
1850
|
let preparedArgs = params.input;
|
|
1864
1851
|
let executionStarted = false;
|
|
@@ -1877,7 +1864,8 @@ async function executeCatalogTool(input, params) {
|
|
|
1877
1864
|
arguments: preparedArgs,
|
|
1878
1865
|
executionStarted,
|
|
1879
1866
|
outcome: isError ? "failure" : "success",
|
|
1880
|
-
...error ? { failure: { error } } : {}
|
|
1867
|
+
...error ? { failure: { error } } : {},
|
|
1868
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1881
1869
|
});
|
|
1882
1870
|
input.attemptParams?.onAgentToolResult?.({
|
|
1883
1871
|
toolName: params.toolName,
|
|
@@ -1901,7 +1889,8 @@ async function executeCatalogTool(input, params) {
|
|
|
1901
1889
|
arguments: preparedArgs,
|
|
1902
1890
|
executionStarted,
|
|
1903
1891
|
outcome: "failure",
|
|
1904
|
-
failure: { error: message }
|
|
1892
|
+
failure: { error: message },
|
|
1893
|
+
...ownerMutation ? { ownerMutation } : {}
|
|
1905
1894
|
});
|
|
1906
1895
|
const failure = sanitizeToolResult({
|
|
1907
1896
|
content: [{
|
|
@@ -1944,17 +1933,6 @@ function createError(message, cause) {
|
|
|
1944
1933
|
return error;
|
|
1945
1934
|
}
|
|
1946
1935
|
/**
|
|
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
1936
|
* Mirrors PI's `shouldForceMessageTool` semantics: a message tool is
|
|
1959
1937
|
* forced when the caller asked for it explicitly or when the source
|
|
1960
1938
|
* reply delivery mode is `message_tool_only`, but never when
|
|
@@ -1967,18 +1945,6 @@ function shouldForceCopilotMessageTool(params) {
|
|
|
1967
1945
|
if (params.disableMessageTool === true) return false;
|
|
1968
1946
|
return params.forceMessageTool === true || params.sourceReplyDeliveryMode === "message_tool_only";
|
|
1969
1947
|
}
|
|
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
1948
|
function filterCopilotToolsForConstructionPlan(tools, plan, options = {}) {
|
|
1983
1949
|
if (plan.includeBaseCodingTools && plan.includeShellTools) return tools;
|
|
1984
1950
|
const preserveToolNames = new Set(options.preserveToolNames);
|
|
@@ -1989,12 +1955,6 @@ function filterCopilotToolsForConstructionPlan(tools, plan, options = {}) {
|
|
|
1989
1955
|
return true;
|
|
1990
1956
|
});
|
|
1991
1957
|
}
|
|
1992
|
-
function hasNonWildcardGlobAllowlist(toolsAllow) {
|
|
1993
|
-
return (toolsAllow ?? []).some((entry) => {
|
|
1994
|
-
const trimmed = entry.trim();
|
|
1995
|
-
return trimmed !== "*" && trimmed.includes("*");
|
|
1996
|
-
});
|
|
1997
|
-
}
|
|
1998
1958
|
function readInlinePluginToolMeta(tool) {
|
|
1999
1959
|
const pluginId = tool.pluginId;
|
|
2000
1960
|
return typeof pluginId === "string" && pluginId.trim() ? { pluginId } : void 0;
|
|
@@ -2038,7 +1998,7 @@ function prepareCopilotAttemptContext(params, deps) {
|
|
|
2038
1998
|
const modelRef = resolveModelRef(input);
|
|
2039
1999
|
const resolvedWorkspaceForSandbox = readResolvedAttemptPath(input.workspaceDir) ?? readResolvedAttemptPath(input.cwd);
|
|
2040
2000
|
const sandboxSessionKey = readNonEmptyString(input.sandboxSessionKey) ?? readNonEmptyString(input.sessionKey) ?? readNonEmptyString(input.sessionId);
|
|
2041
|
-
const { sessionAgentId } =
|
|
2001
|
+
const { sessionAgentId } = resolveSessionAgentIdsStrict({
|
|
2042
2002
|
sessionKey: readNonEmptyString(input.sessionKey),
|
|
2043
2003
|
config: input.config,
|
|
2044
2004
|
agentId: readNonEmptyString(params.agentId)
|
|
@@ -2069,6 +2029,10 @@ function prepareCopilotAttemptContext(params, deps) {
|
|
|
2069
2029
|
modelProviderId: modelRef.provider,
|
|
2070
2030
|
modelId: modelRef.id,
|
|
2071
2031
|
trigger: input.trigger,
|
|
2032
|
+
foregroundPromptContext: buildEmbeddedForegroundPromptContext({
|
|
2033
|
+
...input,
|
|
2034
|
+
agentId: sessionAgentId
|
|
2035
|
+
}, input.agentDir ?? resolveAgentDir(input.config ?? {}, sessionAgentId)),
|
|
2072
2036
|
...input.config ? { config: input.config } : {},
|
|
2073
2037
|
...hookContextWindowFields,
|
|
2074
2038
|
...buildAgentHookContextChannelFields(input)
|
|
@@ -2090,6 +2054,41 @@ async function resolveCopilotAttemptSandbox(params) {
|
|
|
2090
2054
|
};
|
|
2091
2055
|
}
|
|
2092
2056
|
//#endregion
|
|
2057
|
+
//#region extensions/copilot/src/prompt-guidance.ts
|
|
2058
|
+
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.";
|
|
2059
|
+
function buildCopilotPromptGuidance(params) {
|
|
2060
|
+
if (isRawCopilotModelRun(params.attempt)) return;
|
|
2061
|
+
const callableTools = new Set(normalizeUniqueStringEntries(params.callableToolNames));
|
|
2062
|
+
const hasSessionsSpawn = callableTools.has("sessions_spawn");
|
|
2063
|
+
const isMinimal = params.attempt.promptMode === "minimal";
|
|
2064
|
+
const extraSystemPrompt = readNonEmptyStringPreservingWhitespace(params.attempt.extraSystemPrompt)?.trim();
|
|
2065
|
+
const delegationGuidance = params.attempt.disableTools !== true && params.attempt.delegationCapability !== "report_only" ? buildDelegationGuidanceSection({
|
|
2066
|
+
mode: resolveMainSessionDelegationMode({
|
|
2067
|
+
config: params.attempt.config,
|
|
2068
|
+
agentId: params.attempt.agentId,
|
|
2069
|
+
sessionKey: params.attempt.sessionKey
|
|
2070
|
+
}),
|
|
2071
|
+
isMinimal,
|
|
2072
|
+
hiddenDelegationTool: hasSessionsSpawn ? "`sessions_spawn`" : "",
|
|
2073
|
+
hasVisibleSessionSpawn: hasSessionsSpawn,
|
|
2074
|
+
hasSessionsYield: callableTools.has("sessions_yield"),
|
|
2075
|
+
hasSubagentsList: callableTools.has("subagents"),
|
|
2076
|
+
hasSessionsSend: callableTools.has("sessions_send")
|
|
2077
|
+
}).join("\n") : void 0;
|
|
2078
|
+
return [
|
|
2079
|
+
COPILOT_HARNESS_IDENTITY,
|
|
2080
|
+
callableTools.has(SKILL_WORKSHOP_TOOL_NAME) ? buildSkillWorkshopPromptSection().join("\n") : void 0,
|
|
2081
|
+
delegationGuidance,
|
|
2082
|
+
buildHarnessVisibleReplyGuidance({
|
|
2083
|
+
sourceReplyDeliveryMode: params.attempt.sourceReplyDeliveryMode,
|
|
2084
|
+
messageToolAvailable: callableTools.has("message")
|
|
2085
|
+
}),
|
|
2086
|
+
buildCredentialSafetyPrompt(params.attempt.disableTools !== true && callableTools.has("secrets") ? "secrets" : void 0),
|
|
2087
|
+
params.workspaceBootstrapInstructions?.trim(),
|
|
2088
|
+
extraSystemPrompt ? `${isMinimal ? "## Subagent Context" : "## Conversation Context"}\n${extraSystemPrompt}` : void 0
|
|
2089
|
+
].filter((section) => section?.trim()).join("\n\n") || void 0;
|
|
2090
|
+
}
|
|
2091
|
+
//#endregion
|
|
2093
2092
|
//#region extensions/copilot/src/user-input-bridge.ts
|
|
2094
2093
|
const COPILOT_USER_INPUT_QUESTION_ID = "answer";
|
|
2095
2094
|
const DEFAULT_USER_INPUT_TIMEOUT_MS = 15 * 6e4;
|
|
@@ -2325,7 +2324,7 @@ function readResolvedWorkspacePath(value) {
|
|
|
2325
2324
|
//#endregion
|
|
2326
2325
|
//#region extensions/copilot/src/attempt-session-setup.ts
|
|
2327
2326
|
async function createCopilotSessionSetup(params) {
|
|
2328
|
-
const { attempt: input, byokProxy, effectiveCwd, effectiveWorkspaceDir, hookContext, modelRef, messages, operation, poolAcquire, ringZeroSystemAgentRun,
|
|
2327
|
+
const { attempt: input, byokProxy, effectiveCwd, effectiveWorkspaceDir, hookContext, modelRef, messages, operation, poolAcquire, ringZeroSystemAgentRun, promptToolPolicy, sessionProvider, settledToolFinalization, signal } = params;
|
|
2329
2328
|
const ordinaryAttemptInput = settledToolFinalization ? void 0 : (() => {
|
|
2330
2329
|
assertCopilotAttemptHostCapabilities(input);
|
|
2331
2330
|
return input;
|
|
@@ -2335,22 +2334,51 @@ async function createCopilotSessionSetup(params) {
|
|
|
2335
2334
|
effectiveWorkspaceDir,
|
|
2336
2335
|
warn: (message) => console.warn(message)
|
|
2337
2336
|
}) : { instructions: void 0 };
|
|
2338
|
-
const
|
|
2339
|
-
|
|
2337
|
+
const forceToolNames = ordinaryAttemptInput && shouldForceCopilotMessageTool(ordinaryAttemptInput) ? ["message"] : void 0;
|
|
2338
|
+
let promptPolicyResult;
|
|
2339
|
+
let promptBuild;
|
|
2340
|
+
if (settledToolFinalization) promptBuild = {
|
|
2340
2341
|
prompt: input.prompt,
|
|
2341
|
-
developerInstructions:
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2342
|
+
developerInstructions: ""
|
|
2343
|
+
};
|
|
2344
|
+
else if (isRawCopilotModelRun(input)) {
|
|
2345
|
+
promptPolicyResult = promptToolPolicy?.apply();
|
|
2346
|
+
promptBuild = {
|
|
2347
|
+
prompt: input.prompt,
|
|
2348
|
+
developerInstructions: ""
|
|
2349
|
+
};
|
|
2350
|
+
} else {
|
|
2351
|
+
if (!ordinaryAttemptInput) throw new Error("Copilot ordinary attempt authority is unavailable.");
|
|
2352
|
+
if (!promptToolPolicy) throw new Error("Copilot ordinary attempts require a prompt tool policy.");
|
|
2353
|
+
promptBuild = await resolveAgentHarnessBeforePromptBuildResult({
|
|
2354
|
+
prompt: input.prompt,
|
|
2355
|
+
developerInstructions: { build: ({ toolsAllow }) => {
|
|
2356
|
+
promptPolicyResult = promptToolPolicy.apply({
|
|
2357
|
+
toolsAllow,
|
|
2358
|
+
forceToolNames
|
|
2359
|
+
});
|
|
2360
|
+
return buildCopilotPromptGuidance({
|
|
2361
|
+
attempt: input,
|
|
2362
|
+
callableToolNames: promptPolicyResult.callableToolNames,
|
|
2363
|
+
workspaceBootstrapInstructions: workspaceBootstrap.instructions
|
|
2364
|
+
});
|
|
2365
|
+
} },
|
|
2366
|
+
messages,
|
|
2367
|
+
ctx: hookContext,
|
|
2368
|
+
bootstrapContextRunKind: input.bootstrapContextRunKind,
|
|
2369
|
+
toolAuthority: {
|
|
2370
|
+
fingerprint: input.toolAuthorityFingerprint,
|
|
2371
|
+
activeToolNames: () => promptPolicyResult?.callableToolNames ?? [],
|
|
2372
|
+
assertActive: ordinaryAttemptInput.hostCapabilities.assertActive
|
|
2373
|
+
}
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2349
2376
|
const attemptInput = promptBuild.prompt === input.prompt ? input : {
|
|
2350
2377
|
...input,
|
|
2351
2378
|
prompt: promptBuild.prompt
|
|
2352
2379
|
};
|
|
2353
|
-
const promptTools =
|
|
2380
|
+
const promptTools = promptPolicyResult?.tools ?? [];
|
|
2381
|
+
const finalDeveloperInstructions = promptBuild.developerInstructions;
|
|
2354
2382
|
const includeAskUser = !ringZeroSystemAgentRun && (attemptInput.pluginHarnessToolPolicyRestricted !== true || promptTools.some((tool) => tool.name === "ask_user"));
|
|
2355
2383
|
let promptImagesCount = 0;
|
|
2356
2384
|
const emitLlmInput = (prompt, additionalContext) => {
|
|
@@ -2361,7 +2389,7 @@ async function createCopilotSessionSetup(params) {
|
|
|
2361
2389
|
sessionId: input.sessionId,
|
|
2362
2390
|
provider: modelRef.provider,
|
|
2363
2391
|
model: modelRef.id,
|
|
2364
|
-
...
|
|
2392
|
+
...finalDeveloperInstructions ? { systemPrompt: finalDeveloperInstructions } : {},
|
|
2365
2393
|
prompt: additionalContext ? `${prompt}\n\n${additionalContext}` : prompt,
|
|
2366
2394
|
historyMessages: [],
|
|
2367
2395
|
imagesCount: promptImagesCount,
|
|
@@ -2378,14 +2406,14 @@ async function createCopilotSessionSetup(params) {
|
|
|
2378
2406
|
signal
|
|
2379
2407
|
});
|
|
2380
2408
|
})();
|
|
2381
|
-
const sessionConfig = createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, sessionProvider,
|
|
2409
|
+
const sessionConfig = createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, sessionProvider, finalDeveloperInstructions || void 0, effectiveWorkspaceDir, effectiveCwd, userInputBridge?.onUserInputRequest, {
|
|
2382
2410
|
hooksBridgeOptions: hasNativePromptHook ? { onUserPromptSubmitted: ({ additionalContext, prompt }) => emitLlmInput(prompt, additionalContext) } : void 0,
|
|
2383
2411
|
includeAskUser,
|
|
2384
2412
|
operation: operation ?? "attempt"
|
|
2385
2413
|
});
|
|
2386
2414
|
return {
|
|
2387
2415
|
attemptInput,
|
|
2388
|
-
compactionSessionConfig: byokProxy ? createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, poolAcquire.provider,
|
|
2416
|
+
compactionSessionConfig: byokProxy ? createSessionConfig(attemptInput, modelRef.id, promptTools, poolAcquire.auth, poolAcquire.provider, finalDeveloperInstructions || void 0, effectiveWorkspaceDir, effectiveCwd, userInputBridge?.onUserInputRequest, {
|
|
2389
2417
|
hooksBridgeOptions: hasNativePromptHook ? { onUserPromptSubmitted: ({ additionalContext, prompt }) => emitLlmInput(prompt, additionalContext) } : void 0,
|
|
2390
2418
|
includeAskUser,
|
|
2391
2419
|
operation: operation ?? "attempt"
|
|
@@ -2493,7 +2521,8 @@ function createAttemptTranscriptJournal(params) {
|
|
|
2493
2521
|
const hooked = runAgentHarnessBeforeMessageWriteHook({
|
|
2494
2522
|
message: structuredClone(message),
|
|
2495
2523
|
agentId: target.agentId,
|
|
2496
|
-
sessionKey: target.sessionKey
|
|
2524
|
+
sessionKey: target.sessionKey,
|
|
2525
|
+
prepareAssistantTranscriptMessage: options.singleton && !hiddenTurn ? params.attempt.prepareAssistantTranscriptMessage : void 0
|
|
2497
2526
|
});
|
|
2498
2527
|
if (!hooked) return;
|
|
2499
2528
|
if (!isDeepStrictEqual(originalReplayPayload, projectReplayPayload(hooked))) replayInvalid = true;
|
|
@@ -3006,7 +3035,6 @@ async function runCopilotExecution(context) {
|
|
|
3006
3035
|
let timedOut = false;
|
|
3007
3036
|
let promptError;
|
|
3008
3037
|
let sdkSessionId;
|
|
3009
|
-
let sessionIdUsed = input.sessionId;
|
|
3010
3038
|
let nativeSessionCreatedFresh = false;
|
|
3011
3039
|
let nativeSessionHistoryValidated = false;
|
|
3012
3040
|
let disconnectError;
|
|
@@ -3027,6 +3055,7 @@ async function runCopilotExecution(context) {
|
|
|
3027
3055
|
let downgradedFromResume = false;
|
|
3028
3056
|
let resumeFailureRecovered = false;
|
|
3029
3057
|
let yieldDetected = false;
|
|
3058
|
+
let yieldAcknowledgment;
|
|
3030
3059
|
let lastToolError;
|
|
3031
3060
|
const hostObserveToolTerminal = input.observeToolTerminal;
|
|
3032
3061
|
const observeToolTerminal = hostObserveToolTerminal ? (observation) => {
|
|
@@ -3066,15 +3095,13 @@ async function runCopilotExecution(context) {
|
|
|
3066
3095
|
messagesSnapshot: messages,
|
|
3067
3096
|
now,
|
|
3068
3097
|
promptError: void 0,
|
|
3069
|
-
sdkSessionId: void 0
|
|
3070
|
-
sessionIdUsed: input.sessionId
|
|
3098
|
+
sdkSessionId: void 0
|
|
3071
3099
|
}));
|
|
3072
3100
|
return finishAttempt(createResult(input, {
|
|
3073
3101
|
messagesSnapshot: messages,
|
|
3074
3102
|
now,
|
|
3075
3103
|
promptError: createPromptError$1("sandbox_resolution_failure", `[copilot-attempt] sandbox resolution failed: ${toCopilotError(error).message}`, error),
|
|
3076
|
-
sdkSessionId: void 0
|
|
3077
|
-
sessionIdUsed: input.sessionId
|
|
3104
|
+
sdkSessionId: void 0
|
|
3078
3105
|
}));
|
|
3079
3106
|
}
|
|
3080
3107
|
hookContext.workspaceDir = effectiveWorkspaceDir;
|
|
@@ -3086,8 +3113,7 @@ async function runCopilotExecution(context) {
|
|
|
3086
3113
|
messagesSnapshot: messages,
|
|
3087
3114
|
now,
|
|
3088
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"),
|
|
3089
|
-
sdkSessionId: void 0
|
|
3090
|
-
sessionIdUsed: input.sessionId
|
|
3116
|
+
sdkSessionId: void 0
|
|
3091
3117
|
}));
|
|
3092
3118
|
}
|
|
3093
3119
|
const effectiveCwd = sandbox?.enabled ? effectiveWorkspaceDir : requestedCwd ?? effectiveWorkspaceDir;
|
|
@@ -3115,8 +3141,7 @@ async function runCopilotExecution(context) {
|
|
|
3115
3141
|
messagesSnapshot: messages,
|
|
3116
3142
|
now,
|
|
3117
3143
|
promptError: createPromptError$1("model_not_supported", toCopilotError(error).message, error),
|
|
3118
|
-
sdkSessionId: void 0
|
|
3119
|
-
sessionIdUsed: input.sessionId
|
|
3144
|
+
sdkSessionId: void 0
|
|
3120
3145
|
}));
|
|
3121
3146
|
}
|
|
3122
3147
|
const cleanupByokProxy = byokProxy?.close;
|
|
@@ -3124,8 +3149,8 @@ async function runCopilotExecution(context) {
|
|
|
3124
3149
|
const sessionRef = { current: void 0 };
|
|
3125
3150
|
const computerContextEpoch = { value: 0 };
|
|
3126
3151
|
let codeModeEngaged;
|
|
3152
|
+
let promptToolPolicy;
|
|
3127
3153
|
try {
|
|
3128
|
-
let sdkTools = [];
|
|
3129
3154
|
let resultContentSourceByToolName = /* @__PURE__ */ new Map();
|
|
3130
3155
|
if (!settledToolFinalization) try {
|
|
3131
3156
|
assertCopilotAttemptHostCapabilities(input);
|
|
@@ -3148,8 +3173,9 @@ async function runCopilotExecution(context) {
|
|
|
3148
3173
|
} : input,
|
|
3149
3174
|
computerContextEpoch,
|
|
3150
3175
|
sessionRef,
|
|
3151
|
-
onYieldDetected: () => {
|
|
3176
|
+
onYieldDetected: (_message, acknowledgment) => {
|
|
3152
3177
|
yieldDetected = true;
|
|
3178
|
+
yieldAcknowledgment = acknowledgment;
|
|
3153
3179
|
},
|
|
3154
3180
|
onToolCompleted: ({ args, error, result, startedAt, toolCallId, toolName }) => runAgentHarnessAfterToolCallHook({
|
|
3155
3181
|
toolName,
|
|
@@ -3167,15 +3193,14 @@ async function runCopilotExecution(context) {
|
|
|
3167
3193
|
});
|
|
3168
3194
|
cleanupToolBridge = toolBridge.cleanup;
|
|
3169
3195
|
codeModeEngaged = toolBridge.codeModeEngaged;
|
|
3170
|
-
|
|
3196
|
+
promptToolPolicy = toolBridge.promptToolPolicy;
|
|
3171
3197
|
resultContentSourceByToolName = new Map(toolBridge.sourceTools.flatMap((tool) => tool.resultContentSource ? [[tool.name, tool.resultContentSource]] : []));
|
|
3172
3198
|
} catch (error) {
|
|
3173
3199
|
return finishAttempt(createResult(input, {
|
|
3174
3200
|
messagesSnapshot: messages,
|
|
3175
3201
|
now,
|
|
3176
3202
|
promptError: createPromptError$1("tool_bridge_failure", `[copilot-attempt] tool-bridge construction failed: ${toCopilotError(error).message}`, error),
|
|
3177
|
-
sdkSessionId: void 0
|
|
3178
|
-
sessionIdUsed: input.sessionId
|
|
3203
|
+
sdkSessionId: void 0
|
|
3179
3204
|
}));
|
|
3180
3205
|
}
|
|
3181
3206
|
handle = await deps.pool.acquire(poolAcquire.key, poolAcquire.options);
|
|
@@ -3191,7 +3216,7 @@ async function runCopilotExecution(context) {
|
|
|
3191
3216
|
operation: deps.operation,
|
|
3192
3217
|
poolAcquire,
|
|
3193
3218
|
ringZeroSystemAgentRun,
|
|
3194
|
-
|
|
3219
|
+
promptToolPolicy,
|
|
3195
3220
|
sessionProvider,
|
|
3196
3221
|
settledToolFinalization,
|
|
3197
3222
|
signal: params.abortSignal
|
|
@@ -3207,7 +3232,8 @@ async function runCopilotExecution(context) {
|
|
|
3207
3232
|
if (resumeSessionId) try {
|
|
3208
3233
|
session = await client.resumeSession(resumeSessionId, {
|
|
3209
3234
|
...sessionConfig,
|
|
3210
|
-
continuePendingWork: false
|
|
3235
|
+
continuePendingWork: false,
|
|
3236
|
+
...settledToolFinalization ? { suppressResumeEvent: true } : {}
|
|
3211
3237
|
});
|
|
3212
3238
|
nativeSessionHistoryValidated = input.initialReplayState?.journalValidated === true;
|
|
3213
3239
|
} catch (error) {
|
|
@@ -3226,7 +3252,6 @@ async function runCopilotExecution(context) {
|
|
|
3226
3252
|
sessionRef.current = session;
|
|
3227
3253
|
sdkSessionId = readNonEmptyString(session.sessionId) ?? readNonEmptyString(session.id) ?? (resumeFailureRecovered ? void 0 : resumeSessionId);
|
|
3228
3254
|
if (!sdkSessionId) throw createPromptError$1("transcript_persistence_failed", "[copilot-attempt] canonical transcript persistence requires the Copilot SDK session id");
|
|
3229
|
-
sessionIdUsed = sdkSessionId ?? input.sessionId;
|
|
3230
3255
|
if (sdkSessionId && deps.onSessionEstablished && !settledToolFinalization) try {
|
|
3231
3256
|
deps.onSessionEstablished({
|
|
3232
3257
|
compactionSessionConfig,
|
|
@@ -3288,6 +3313,7 @@ async function runCopilotExecution(context) {
|
|
|
3288
3313
|
abortActiveSession,
|
|
3289
3314
|
bridge,
|
|
3290
3315
|
canAcceptSteering: () => initialSdkUserValidated,
|
|
3316
|
+
startedAtMs: input.startedAtMs,
|
|
3291
3317
|
input,
|
|
3292
3318
|
isAborted: () => aborted,
|
|
3293
3319
|
isSettled: () => settled,
|
|
@@ -3435,12 +3461,12 @@ async function runCopilotExecution(context) {
|
|
|
3435
3461
|
resumeFailureRecovered,
|
|
3436
3462
|
sdkSessionId,
|
|
3437
3463
|
sentTurnStarted,
|
|
3438
|
-
sessionIdUsed,
|
|
3439
3464
|
settledFinalizationAssistantCompleted,
|
|
3440
3465
|
settledToolFinalization,
|
|
3441
3466
|
timedOut,
|
|
3442
3467
|
timedOutDuringCompaction,
|
|
3443
|
-
yieldDetected
|
|
3468
|
+
yieldDetected,
|
|
3469
|
+
yieldAcknowledgment
|
|
3444
3470
|
});
|
|
3445
3471
|
}
|
|
3446
3472
|
//#endregion
|
|
@@ -3456,8 +3482,7 @@ async function runCopilotAttempt(params, deps) {
|
|
|
3456
3482
|
messagesSnapshot: messages,
|
|
3457
3483
|
now,
|
|
3458
3484
|
promptError: void 0,
|
|
3459
|
-
sdkSessionId: void 0
|
|
3460
|
-
sessionIdUsed: input.sessionId
|
|
3485
|
+
sdkSessionId: void 0
|
|
3461
3486
|
}));
|
|
3462
3487
|
try {
|
|
3463
3488
|
resolveCopilotProvider({
|
|
@@ -3470,8 +3495,7 @@ async function runCopilotAttempt(params, deps) {
|
|
|
3470
3495
|
messagesSnapshot: messages,
|
|
3471
3496
|
now,
|
|
3472
3497
|
promptError: createPromptError$1("model_not_supported", toCopilotError(error).message, error),
|
|
3473
|
-
sdkSessionId: void 0
|
|
3474
|
-
sessionIdUsed: input.sessionId
|
|
3498
|
+
sdkSessionId: void 0
|
|
3475
3499
|
}));
|
|
3476
3500
|
}
|
|
3477
3501
|
const settledFinalizationSessionId = settledToolFinalization ? readNonEmptyString(input.initialReplayState?.sdkSessionId) : void 0;
|
|
@@ -3479,8 +3503,7 @@ async function runCopilotAttempt(params, deps) {
|
|
|
3479
3503
|
messagesSnapshot: messages,
|
|
3480
3504
|
now,
|
|
3481
3505
|
promptError: createPromptError$1("settled_finalization_session_unavailable", "[copilot-attempt] settled tool finalization requires the existing Copilot SDK session"),
|
|
3482
|
-
sdkSessionId: void 0
|
|
3483
|
-
sessionIdUsed: input.sessionId
|
|
3506
|
+
sdkSessionId: void 0
|
|
3484
3507
|
}));
|
|
3485
3508
|
return await runCopilotExecution({
|
|
3486
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)) {
|
|
@@ -687,12 +682,16 @@ function readAgentIdFromSessionKey(sessionKey) {
|
|
|
687
682
|
const parts = sessionKey.trim().split(":");
|
|
688
683
|
return parts[0] === "agent" && parts[1]?.trim() ? parts[1].trim() : void 0;
|
|
689
684
|
}
|
|
690
|
-
function computeSessionKey(
|
|
691
|
-
const
|
|
692
|
-
const
|
|
693
|
-
const
|
|
694
|
-
const
|
|
695
|
-
const
|
|
685
|
+
function computeSessionKey(input, options) {
|
|
686
|
+
const attempt = input.kind === "attempt" ? input.params : void 0;
|
|
687
|
+
const compact = input.kind === "compact" ? input.params : void 0;
|
|
688
|
+
const attemptModel = attempt?.model;
|
|
689
|
+
const compactModel = compact?.model;
|
|
690
|
+
const rawModel = attemptModel ?? compactModel;
|
|
691
|
+
const modelObj = rawModel && typeof rawModel === "object" ? rawModel : compact?.runtimeModel ?? { id: typeof rawModel === "string" ? rawModel : void 0 };
|
|
692
|
+
const provider = normalizeOptionalString(modelObj.provider) ?? attempt?.provider ?? compact?.provider ?? "";
|
|
693
|
+
const modelId = normalizeOptionalString(modelObj.id) ?? attempt?.modelId ?? compact?.modelId ?? (typeof compactModel === "string" ? compactModel : "");
|
|
694
|
+
const requestTransport = rawModel && typeof rawModel === "object" ? getModelProviderRequestTransport(rawModel) : void 0;
|
|
696
695
|
const requestAuthMode = normalizeOptionalString(requestTransport?.auth?.mode ?? modelObj.request?.auth?.mode);
|
|
697
696
|
const azureApiVersion = normalizeOptionalString(modelObj.azureApiVersion ?? modelObj.params?.azureApiVersion);
|
|
698
697
|
let authParts;
|
|
@@ -700,18 +699,18 @@ function computeSessionKey(params, options) {
|
|
|
700
699
|
let resolvedCopilotHome = "";
|
|
701
700
|
try {
|
|
702
701
|
const resolved = !options.includeAuth ? resolveCopilotAuth({
|
|
703
|
-
agentId:
|
|
704
|
-
agentDir:
|
|
705
|
-
workspaceDir:
|
|
706
|
-
copilotHome:
|
|
702
|
+
agentId: input.params.agentId ?? readAgentIdFromSessionKey(input.params.sessionKey),
|
|
703
|
+
agentDir: input.params.agentDir,
|
|
704
|
+
workspaceDir: input.params.workspaceDir,
|
|
705
|
+
copilotHome: input.params.copilotHome,
|
|
707
706
|
auth: { useLoggedInUser: true }
|
|
708
707
|
}) : (() => {
|
|
709
708
|
const modelProvider = resolveCopilotProvider({
|
|
710
709
|
model: {
|
|
711
|
-
api: modelObj.api,
|
|
710
|
+
api: normalizeOptionalString(modelObj.api),
|
|
712
711
|
id: modelId,
|
|
713
712
|
provider,
|
|
714
|
-
baseUrl: modelObj.baseUrl,
|
|
713
|
+
baseUrl: normalizeOptionalString(modelObj.baseUrl),
|
|
715
714
|
azureApiVersion,
|
|
716
715
|
headers: modelObj.headers,
|
|
717
716
|
authHeader: modelObj.authHeader,
|
|
@@ -723,25 +722,25 @@ function computeSessionKey(params, options) {
|
|
|
723
722
|
contextWindow: modelObj.contextWindow,
|
|
724
723
|
maxTokens: modelObj.maxTokens
|
|
725
724
|
},
|
|
726
|
-
resolvedApiKey:
|
|
727
|
-
authProfileId:
|
|
725
|
+
resolvedApiKey: input.params.resolvedApiKey,
|
|
726
|
+
authProfileId: input.params.authProfileId
|
|
728
727
|
});
|
|
729
728
|
return modelProvider.mode === "byok" ? createCopilotByokAuth({
|
|
730
|
-
agentId:
|
|
731
|
-
agentDir:
|
|
732
|
-
workspaceDir:
|
|
733
|
-
copilotHome:
|
|
729
|
+
agentId: input.params.agentId ?? readAgentIdFromSessionKey(input.params.sessionKey),
|
|
730
|
+
agentDir: input.params.agentDir,
|
|
731
|
+
workspaceDir: input.params.workspaceDir,
|
|
732
|
+
copilotHome: input.params.copilotHome,
|
|
734
733
|
authProfileId: modelProvider.authProfileId,
|
|
735
734
|
authProfileVersion: modelProvider.authProfileVersion
|
|
736
735
|
}) : resolveCopilotAuth({
|
|
737
|
-
agentId:
|
|
738
|
-
agentDir:
|
|
739
|
-
workspaceDir:
|
|
740
|
-
copilotHome:
|
|
741
|
-
auth:
|
|
742
|
-
resolvedApiKey:
|
|
743
|
-
authProfileId:
|
|
744
|
-
profileVersion:
|
|
736
|
+
agentId: input.params.agentId ?? readAgentIdFromSessionKey(input.params.sessionKey),
|
|
737
|
+
agentDir: input.params.agentDir,
|
|
738
|
+
workspaceDir: input.params.workspaceDir,
|
|
739
|
+
copilotHome: input.params.copilotHome,
|
|
740
|
+
auth: input.params.auth,
|
|
741
|
+
resolvedApiKey: input.params.resolvedApiKey,
|
|
742
|
+
authProfileId: input.params.authProfileId,
|
|
743
|
+
profileVersion: input.params.profileVersion
|
|
745
744
|
});
|
|
746
745
|
})();
|
|
747
746
|
resolvedAgentId = resolved.agentId;
|
|
@@ -758,12 +757,12 @@ function computeSessionKey(params, options) {
|
|
|
758
757
|
return [
|
|
759
758
|
`provider=${provider}`,
|
|
760
759
|
`model=${modelId}`,
|
|
761
|
-
...options.includeApi ? [`api=${modelObj.api ?? ""}`] : [],
|
|
760
|
+
...options.includeApi ? [`api=${normalizeOptionalString(modelObj.api) ?? ""}`] : [],
|
|
762
761
|
...options.includeApi ? [`baseUrlFingerprint=${fingerprintSessionValue(modelObj.baseUrl)}`] : [],
|
|
763
|
-
`cwd=${
|
|
762
|
+
`cwd=${input.params.cwd ?? input.params.workspaceDir ?? ""}`,
|
|
764
763
|
`agentId=${resolvedAgentId}`,
|
|
765
|
-
`agentDir=${
|
|
766
|
-
`copilotHome=${
|
|
764
|
+
`agentDir=${input.params.agentDir ?? ""}`,
|
|
765
|
+
`copilotHome=${input.params.copilotHome ?? ""}`,
|
|
767
766
|
`resolvedCopilotHome=${resolvedCopilotHome}`,
|
|
768
767
|
...options.includeAuth ? authParts : []
|
|
769
768
|
].join("|");
|
|
@@ -772,13 +771,28 @@ function fingerprintSessionValue(value) {
|
|
|
772
771
|
return typeof value === "string" && value ? tokenFingerprint(value) : "";
|
|
773
772
|
}
|
|
774
773
|
function computeSessionCompatKey(params) {
|
|
775
|
-
return computeSessionKey(
|
|
774
|
+
return computeSessionKey({
|
|
775
|
+
kind: "attempt",
|
|
776
|
+
params
|
|
777
|
+
}, {
|
|
776
778
|
includeApi: true,
|
|
777
779
|
includeAuth: true
|
|
778
780
|
});
|
|
779
781
|
}
|
|
780
|
-
function
|
|
781
|
-
return computeSessionKey(
|
|
782
|
+
function computeAttemptCompactKey(params) {
|
|
783
|
+
return computeSessionKey({
|
|
784
|
+
kind: "attempt",
|
|
785
|
+
params
|
|
786
|
+
}, {
|
|
787
|
+
includeApi: false,
|
|
788
|
+
includeAuth: false
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
function computeCompactRequestKey(params) {
|
|
792
|
+
return computeSessionKey({
|
|
793
|
+
kind: "compact",
|
|
794
|
+
params
|
|
795
|
+
}, {
|
|
782
796
|
includeApi: false,
|
|
783
797
|
includeAuth: false
|
|
784
798
|
});
|
|
@@ -808,7 +822,7 @@ function createCopilotAgentHarness(options) {
|
|
|
808
822
|
async function getPool() {
|
|
809
823
|
if (options?.pool) return options.pool;
|
|
810
824
|
if (!poolPromise) poolPromise = (async () => {
|
|
811
|
-
const { createCopilotClientPool } = await import("./runtime-
|
|
825
|
+
const { createCopilotClientPool } = await import("./runtime-DvZQV_8v.js");
|
|
812
826
|
createdPool = createCopilotClientPool(options?.poolOptions);
|
|
813
827
|
return createdPool;
|
|
814
828
|
})();
|
|
@@ -845,7 +859,7 @@ function createCopilotAgentHarness(options) {
|
|
|
845
859
|
async function runHarnessAttempt(params, operation) {
|
|
846
860
|
const attemptPromise = (async () => {
|
|
847
861
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start new attempts");
|
|
848
|
-
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-
|
|
862
|
+
const { resolvePoolAcquire, runCopilotAttempt } = await import("./attempt-DwhhWgyV.js");
|
|
849
863
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
850
864
|
const pool = await getPool();
|
|
851
865
|
if (disposed) throw new Error("[copilot] harness was disposed while starting an attempt");
|
|
@@ -858,7 +872,7 @@ function createCopilotAgentHarness(options) {
|
|
|
858
872
|
}
|
|
859
873
|
const openclawSessionId = typeof params.sessionId === "string" ? params.sessionId : void 0;
|
|
860
874
|
const currentCompatKey = computeSessionCompatKey(params);
|
|
861
|
-
const currentCompactKey =
|
|
875
|
+
const currentCompactKey = computeAttemptCompactKey(params);
|
|
862
876
|
const compactionCleanupPending = openclawSessionId !== void 0 && hasPendingDeferredCompactionCleanup(openclawSessionId);
|
|
863
877
|
const replayBlocked = openclawSessionId !== void 0 && (compactionCleanupPending || resetBlockedStoredSessions.has(openclawSessionId));
|
|
864
878
|
const tracked = openclawSessionId && !replayBlocked ? trackedSessions.get(openclawSessionId) : void 0;
|
|
@@ -976,7 +990,7 @@ function createCopilotAgentHarness(options) {
|
|
|
976
990
|
async function runIsolatedCompletionV2(params) {
|
|
977
991
|
const completionPromise = (async () => {
|
|
978
992
|
if (disposed) throw new Error("[copilot] harness has been disposed; cannot start isolated completion");
|
|
979
|
-
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-
|
|
993
|
+
const { runCopilotIsolatedCompletion } = await import("./isolated-completion-C0DfWtVO.js");
|
|
980
994
|
if (disposed) throw new Error("[copilot] harness was disposed while starting isolated completion");
|
|
981
995
|
return await runCopilotIsolatedCompletion(params, async () => {
|
|
982
996
|
const pool = await getPool();
|
|
@@ -1066,8 +1080,8 @@ function createCopilotAgentHarness(options) {
|
|
|
1066
1080
|
failure: { reason: "background-compaction-pending" }
|
|
1067
1081
|
};
|
|
1068
1082
|
const tracked = trackedSessions.get(openclawSessionId);
|
|
1069
|
-
const currentCompactKey =
|
|
1070
|
-
const { resolvePoolAcquire } = await import("./attempt-
|
|
1083
|
+
const currentCompactKey = computeCompactRequestKey(params);
|
|
1084
|
+
const { resolvePoolAcquire } = await import("./attempt-DwhhWgyV.js");
|
|
1071
1085
|
let resolvedPoolAcquire;
|
|
1072
1086
|
let currentAuth;
|
|
1073
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": {
|