@get-bb/plugin-sdk 0.6.157 → 0.6.164
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/bundled-types/bb-plugin-sdk-app.d.ts +698 -72
- package/bundled-types/bb-plugin-sdk-environment-provider.d.ts +3 -0
- package/bundled-types/bb-plugin-sdk-host.d.ts +4 -1
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +3 -0
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +6 -3
- package/bundled-types/bb-plugin-sdk-internal-thread-event-gate.d.ts +1001 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp-next.d.ts +56 -6
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +56 -6
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +45 -8
- package/bundled-types/bb-plugin-sdk-testing.d.ts +14 -19
- package/bundled-types/bb-plugin-sdk.d.ts +860 -286
- package/dist/app.js +8 -0
- package/dist/host.js +27 -3
- package/dist/index.js +19 -1
- package/dist/internal/host-policy.js +24 -2
- package/dist/internal/plugin-app-collector.js +20 -0
- package/dist/internal/rpc-query-host.js +1 -0
- package/dist/internal/thread-event-gate.js +95 -0
- package/dist/process.js +7 -1
- package/dist/provider-bridge-acp-next.js +503 -144
- package/dist/provider-bridge-acp.js +503 -144
- package/dist/provider-bridge-testing.js +12 -4
- package/dist/provider-bridge.js +115 -34
- package/dist/replay-provider-child.mjs +158 -31
- package/dist/testing/app.js +627 -347
- package/dist/testing/index.js +174 -66
- package/package.json +8 -1
|
@@ -1827,6 +1827,27 @@ var interactionLifecycleSchema = z13.union([
|
|
|
1827
1827
|
pluginExtensionInteractionLifecycleSchema
|
|
1828
1828
|
]);
|
|
1829
1829
|
|
|
1830
|
+
// ../text-utils/src/utf16.ts
|
|
1831
|
+
function isHighSurrogateAt(value, index) {
|
|
1832
|
+
const code = value.charCodeAt(index);
|
|
1833
|
+
return code >= 55296 && code <= 56319;
|
|
1834
|
+
}
|
|
1835
|
+
function isLowSurrogateAt(value, index) {
|
|
1836
|
+
const code = value.charCodeAt(index);
|
|
1837
|
+
return code >= 56320 && code <= 57343;
|
|
1838
|
+
}
|
|
1839
|
+
function sliceUtf16Head(value, maxChars) {
|
|
1840
|
+
let end = Math.min(value.length, Math.max(0, maxChars));
|
|
1841
|
+
if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
|
|
1842
|
+
end -= 1;
|
|
1843
|
+
}
|
|
1844
|
+
return value.slice(0, end);
|
|
1845
|
+
}
|
|
1846
|
+
var LONE_SURROGATE = /[\uD800-\uDFFF]/gu;
|
|
1847
|
+
function toWellFormedUtf16(value) {
|
|
1848
|
+
return value.replace(LONE_SURROGATE, "\uFFFD");
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1830
1851
|
// ../domain/src/provider-event.ts
|
|
1831
1852
|
import { z as z18 } from "zod";
|
|
1832
1853
|
|
|
@@ -3179,7 +3200,8 @@ import { z as z26 } from "zod";
|
|
|
3179
3200
|
var providerMaintenanceParamsSchema = z26.object({
|
|
3180
3201
|
providerId: z26.string().min(1),
|
|
3181
3202
|
cwd: z26.string().min(1).optional(),
|
|
3182
|
-
providerOptions: z26.record(z26.string(), z26.unknown()).optional()
|
|
3203
|
+
providerOptions: z26.record(z26.string(), z26.unknown()).optional(),
|
|
3204
|
+
envVars: z26.record(z26.string(), z26.string()).optional()
|
|
3183
3205
|
}).passthrough();
|
|
3184
3206
|
var providerInstallationRequirementSchema = z26.enum(["thread_rewind"]);
|
|
3185
3207
|
var providerInstallationStatusParamsSchema = providerMaintenanceParamsSchema.extend({
|
|
@@ -3326,7 +3348,10 @@ var modelListParamsSchema = z27.object({
|
|
|
3326
3348
|
envVars: z27.record(z27.string(), z27.string()).optional(),
|
|
3327
3349
|
selectedModel: z27.string().min(1).optional()
|
|
3328
3350
|
}).passthrough();
|
|
3329
|
-
var commandListParamsSchema = z27.object({
|
|
3351
|
+
var commandListParamsSchema = z27.object({
|
|
3352
|
+
cwd: z27.string().min(1),
|
|
3353
|
+
envVars: z27.record(z27.string(), z27.string()).optional()
|
|
3354
|
+
}).passthrough();
|
|
3330
3355
|
var threadStartParamsSchema = z27.object({
|
|
3331
3356
|
...sessionConstructionFields,
|
|
3332
3357
|
input: z27.array(promptInputSchema).optional()
|
|
@@ -3413,8 +3438,12 @@ var BRIDGE_NOTIFICATION_METHODS = {
|
|
|
3413
3438
|
sessionReplaced: "session/replaced",
|
|
3414
3439
|
providerRaw: "provider/raw",
|
|
3415
3440
|
providerRecovery: "provider/recovery",
|
|
3416
|
-
error: "error"
|
|
3441
|
+
error: "error",
|
|
3442
|
+
requestCancelled: "notifications/cancelled"
|
|
3417
3443
|
};
|
|
3444
|
+
var requestCancelledNotificationSchema = z29.object({
|
|
3445
|
+
requestId: z29.union([z29.string(), z29.number().int()])
|
|
3446
|
+
}).passthrough();
|
|
3418
3447
|
var threadIdentityNotificationSchema = z29.object({
|
|
3419
3448
|
threadId: z29.string().min(1),
|
|
3420
3449
|
providerThreadId: z29.string().min(1),
|
|
@@ -3830,6 +3859,16 @@ var shellEnvironmentVariableKeySchema = z33.string().regex(/^[A-Z_][A-Z0-9_]*$/i
|
|
|
3830
3859
|
function toOptionalString(value) {
|
|
3831
3860
|
return typeof value === "string" ? value : void 0;
|
|
3832
3861
|
}
|
|
3862
|
+
function buildShellEnvOverrides(envVars) {
|
|
3863
|
+
const overrides = {};
|
|
3864
|
+
for (const [key, value] of Object.entries(envVars ?? {})) {
|
|
3865
|
+
if (!shellEnvironmentVariableKeySchema.safeParse(key).success) {
|
|
3866
|
+
continue;
|
|
3867
|
+
}
|
|
3868
|
+
overrides[key] = value;
|
|
3869
|
+
}
|
|
3870
|
+
return overrides;
|
|
3871
|
+
}
|
|
3833
3872
|
function extractResultText(content) {
|
|
3834
3873
|
if (content === null || content === void 0) return "";
|
|
3835
3874
|
if (typeof content === "string") return content;
|
|
@@ -4178,6 +4217,30 @@ function withoutBridgeRuntimeEnv(env) {
|
|
|
4178
4217
|
delete childEnv[PROVIDER_BRIDGE_RECORD_DIR_ENV];
|
|
4179
4218
|
return childEnv;
|
|
4180
4219
|
}
|
|
4220
|
+
function buildProviderCliEnv(envVars) {
|
|
4221
|
+
const inherited = withoutBridgeRuntimeEnv(process.env);
|
|
4222
|
+
const overrides = buildShellEnvOverrides(envVars);
|
|
4223
|
+
if (process.platform === "win32") {
|
|
4224
|
+
const overridden = new Set(
|
|
4225
|
+
Object.keys(overrides).map((name) => name.toUpperCase())
|
|
4226
|
+
);
|
|
4227
|
+
for (const name of Object.keys(inherited)) {
|
|
4228
|
+
if (overridden.has(name.toUpperCase())) delete inherited[name];
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
return { ...inherited, ...overrides };
|
|
4232
|
+
}
|
|
4233
|
+
var THREAD_IDENTITY_ENV_NAMES = [
|
|
4234
|
+
"BB_THREAD_ID",
|
|
4235
|
+
"BB_THREAD_STORAGE",
|
|
4236
|
+
"BB_PROJECT_ID",
|
|
4237
|
+
"BB_ENVIRONMENT_ID"
|
|
4238
|
+
];
|
|
4239
|
+
function withoutThreadIdentityEnv(envVars) {
|
|
4240
|
+
const shared2 = { ...envVars };
|
|
4241
|
+
for (const name of THREAD_IDENTITY_ENV_NAMES) delete shared2[name];
|
|
4242
|
+
return shared2;
|
|
4243
|
+
}
|
|
4181
4244
|
|
|
4182
4245
|
// ../provider-bridge-protocol/src/bridge-kit/bridge-tool-calls.ts
|
|
4183
4246
|
import { z as z34 } from "zod";
|
|
@@ -4351,23 +4414,6 @@ function mimeTypeFromExtension(filePath) {
|
|
|
4351
4414
|
}
|
|
4352
4415
|
}
|
|
4353
4416
|
|
|
4354
|
-
// ../text-utils/src/utf16.ts
|
|
4355
|
-
function isHighSurrogateAt(value, index) {
|
|
4356
|
-
const code = value.charCodeAt(index);
|
|
4357
|
-
return code >= 55296 && code <= 56319;
|
|
4358
|
-
}
|
|
4359
|
-
function isLowSurrogateAt(value, index) {
|
|
4360
|
-
const code = value.charCodeAt(index);
|
|
4361
|
-
return code >= 56320 && code <= 57343;
|
|
4362
|
-
}
|
|
4363
|
-
function sliceUtf16Head(value, maxChars) {
|
|
4364
|
-
let end = Math.min(value.length, Math.max(0, maxChars));
|
|
4365
|
-
if (isHighSurrogateAt(value, end - 1) && isLowSurrogateAt(value, end)) {
|
|
4366
|
-
end -= 1;
|
|
4367
|
-
}
|
|
4368
|
-
return value.slice(0, end);
|
|
4369
|
-
}
|
|
4370
|
-
|
|
4371
4417
|
// ../provider-bridge-protocol/src/bridge-kit/presentation.ts
|
|
4372
4418
|
var PRESENTATION_TITLE_MAX_LENGTH = 160;
|
|
4373
4419
|
function presentationTitle(text) {
|
|
@@ -5095,8 +5141,7 @@ function spawnPortableProcess(request) {
|
|
|
5095
5141
|
cwd: request.cwd,
|
|
5096
5142
|
detached: request.detached,
|
|
5097
5143
|
env: request.env,
|
|
5098
|
-
stdio: request.stdio
|
|
5099
|
-
windowsHide: true
|
|
5144
|
+
stdio: request.stdio
|
|
5100
5145
|
});
|
|
5101
5146
|
}
|
|
5102
5147
|
function assertPortablePipedProcess(child) {
|
|
@@ -5138,7 +5183,7 @@ function terminateWindowsProcessTrees(pids) {
|
|
|
5138
5183
|
"taskkill.exe"
|
|
5139
5184
|
),
|
|
5140
5185
|
[...pids.flatMap((pid) => ["/pid", String(pid)]), "/T", "/F"],
|
|
5141
|
-
{
|
|
5186
|
+
{},
|
|
5142
5187
|
(error) => finish(error === null)
|
|
5143
5188
|
);
|
|
5144
5189
|
timer = setTimeout(() => {
|
|
@@ -12413,8 +12458,8 @@ function isPathWithinDirectory(directoryPath, candidatePath) {
|
|
|
12413
12458
|
var import_compare = __toESM(require_compare(), 1);
|
|
12414
12459
|
var import_valid = __toESM(require_valid(), 1);
|
|
12415
12460
|
import { z as z36 } from "zod";
|
|
12416
|
-
async function resolveExecutablePath(command) {
|
|
12417
|
-
return hostToolchain.resolve(command);
|
|
12461
|
+
async function resolveExecutablePath(command, env) {
|
|
12462
|
+
return hostToolchain.resolve(command, env === void 0 ? {} : { env });
|
|
12418
12463
|
}
|
|
12419
12464
|
function versionFrom(value) {
|
|
12420
12465
|
const candidate = value?.match(/\bv?(\d+\.\d+\.\d+[0-9A-Za-z.+-]*)/u)?.[1];
|
|
@@ -12471,6 +12516,59 @@ function createProviderVisibilityMetadata(args) {
|
|
|
12471
12516
|
// ../provider-bridge-protocol/src/bridge-kit/runtime-json-rpc.ts
|
|
12472
12517
|
import { z as z38 } from "zod";
|
|
12473
12518
|
var ignoredJsonRpcResultSchema = z38.unknown();
|
|
12519
|
+
function wellFormedStrings(_key, value) {
|
|
12520
|
+
return typeof value === "string" ? toWellFormedUtf16(value) : value;
|
|
12521
|
+
}
|
|
12522
|
+
function serializeJsonRpcLine(message) {
|
|
12523
|
+
const line = JSON.stringify(message);
|
|
12524
|
+
return line.includes("\\ud") ? JSON.stringify(message, wellFormedStrings) : line;
|
|
12525
|
+
}
|
|
12526
|
+
|
|
12527
|
+
// ../provider-bridge-protocol/src/bridge-kit/unanswered-interaction.ts
|
|
12528
|
+
var UNANSWERED_INTERACTION_WARNING_SUMMARY = "bb answered the agent without you";
|
|
12529
|
+
function sentence(text) {
|
|
12530
|
+
return text.trim().replace(/[.\s]+$/u, "");
|
|
12531
|
+
}
|
|
12532
|
+
function causeText(cause) {
|
|
12533
|
+
switch (cause.kind) {
|
|
12534
|
+
case "unshowable-request":
|
|
12535
|
+
return `it could not show the question: ${sentence(cause.detail)}`;
|
|
12536
|
+
case "runtime-error":
|
|
12537
|
+
return `it stopped waiting for your answer: ${sentence(cause.message)}`;
|
|
12538
|
+
case "unreadable-resolution":
|
|
12539
|
+
return "it could not read the answer it received";
|
|
12540
|
+
case "unmappable-answer":
|
|
12541
|
+
return `your answer did not fit the question: ${sentence(cause.detail)}`;
|
|
12542
|
+
case "withdrawn":
|
|
12543
|
+
return `it withdrew the question: ${sentence(cause.detail)}`;
|
|
12544
|
+
}
|
|
12545
|
+
}
|
|
12546
|
+
function agentCauseText(cause) {
|
|
12547
|
+
switch (cause.kind) {
|
|
12548
|
+
case "unshowable-request":
|
|
12549
|
+
return `bb could not show the question (${sentence(cause.detail)})`;
|
|
12550
|
+
case "runtime-error":
|
|
12551
|
+
return `bb stopped waiting for the answer (${sentence(cause.message)})`;
|
|
12552
|
+
case "unreadable-resolution":
|
|
12553
|
+
return "bb could not read the answer it received";
|
|
12554
|
+
case "unmappable-answer":
|
|
12555
|
+
return `the answer did not fit the question (${sentence(cause.detail)})`;
|
|
12556
|
+
case "withdrawn":
|
|
12557
|
+
return `bb withdrew the question (${sentence(cause.detail)})`;
|
|
12558
|
+
}
|
|
12559
|
+
}
|
|
12560
|
+
function unansweredInteractionErrorMessage(cause) {
|
|
12561
|
+
return `The user did not answer: ${agentCauseText(cause)}.`;
|
|
12562
|
+
}
|
|
12563
|
+
function unansweredInteractionWarning(args) {
|
|
12564
|
+
const answer = args.answer.kind === "error" ? "an error" : JSON.stringify(args.answer.value);
|
|
12565
|
+
return {
|
|
12566
|
+
kind: "provider.warning",
|
|
12567
|
+
summary: UNANSWERED_INTERACTION_WARNING_SUMMARY,
|
|
12568
|
+
details: `bb answered the agent with ${answer} because ${causeText(args.cause)}.`,
|
|
12569
|
+
vouchedTurn: true
|
|
12570
|
+
};
|
|
12571
|
+
}
|
|
12474
12572
|
|
|
12475
12573
|
// ../provider-bridge-acp/src/bridge/bridge.ts
|
|
12476
12574
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -12555,16 +12653,19 @@ var acpToolCallLocationSchema = z39.object({
|
|
|
12555
12653
|
path: z39.string(),
|
|
12556
12654
|
line: z39.number().optional().nullable()
|
|
12557
12655
|
}).passthrough();
|
|
12558
|
-
|
|
12656
|
+
function acpNullAsAbsent(schema) {
|
|
12657
|
+
return schema.nullable().transform((value) => value ?? void 0).optional();
|
|
12658
|
+
}
|
|
12659
|
+
var acpOptionalString = acpNullAsAbsent(z39.string());
|
|
12559
12660
|
var acpToolCallFieldsSchema = z39.object({
|
|
12560
12661
|
toolCallId: z39.string(),
|
|
12561
|
-
title:
|
|
12562
|
-
name:
|
|
12662
|
+
title: acpOptionalString,
|
|
12663
|
+
name: acpOptionalString,
|
|
12563
12664
|
kind: acpToolKindSchema.optional(),
|
|
12564
12665
|
rawKind: z39.string().optional(),
|
|
12565
12666
|
status: acpToolCallStatusSchema.optional(),
|
|
12566
|
-
content: acpToolCallContentListSchema
|
|
12567
|
-
locations: z39.array(acpToolCallLocationSchema)
|
|
12667
|
+
content: acpNullAsAbsent(acpToolCallContentListSchema),
|
|
12668
|
+
locations: acpNullAsAbsent(z39.array(acpToolCallLocationSchema)),
|
|
12568
12669
|
rawInput: z39.unknown().optional(),
|
|
12569
12670
|
rawOutput: z39.unknown().optional()
|
|
12570
12671
|
});
|
|
@@ -12625,6 +12726,33 @@ var acpUsageUpdateSchema = z39.object({
|
|
|
12625
12726
|
used: z39.number().int().nonnegative(),
|
|
12626
12727
|
size: z39.number().int().nonnegative()
|
|
12627
12728
|
}).passthrough();
|
|
12729
|
+
var acpCompactionUpdateSchema = z39.object({
|
|
12730
|
+
sessionUpdate: z39.literal("compaction_update"),
|
|
12731
|
+
compactionId: z39.string().min(1),
|
|
12732
|
+
status: z39.string(),
|
|
12733
|
+
error: z39.string().nullable().optional()
|
|
12734
|
+
}).passthrough();
|
|
12735
|
+
var openCodeCompactionMarkerSchema = z39.object({
|
|
12736
|
+
_meta: z39.object({
|
|
12737
|
+
"opencode/compaction": z39.object({
|
|
12738
|
+
messageId: z39.string().min(1),
|
|
12739
|
+
status: z39.enum(["started", "completed", "failed"]),
|
|
12740
|
+
error: z39.object({ message: z39.string() }).nullish()
|
|
12741
|
+
})
|
|
12742
|
+
})
|
|
12743
|
+
});
|
|
12744
|
+
function readOpenCodeCompactionUpdate(update) {
|
|
12745
|
+
if (update.sessionUpdate !== "session_info_update") return void 0;
|
|
12746
|
+
const parsed = openCodeCompactionMarkerSchema.safeParse(update);
|
|
12747
|
+
if (!parsed.success) return void 0;
|
|
12748
|
+
const marker = parsed.data._meta["opencode/compaction"];
|
|
12749
|
+
return {
|
|
12750
|
+
sessionUpdate: "compaction_update",
|
|
12751
|
+
compactionId: marker.messageId,
|
|
12752
|
+
status: marker.status === "started" ? "in_progress" : marker.status,
|
|
12753
|
+
...marker.error ? { error: marker.error.message } : {}
|
|
12754
|
+
};
|
|
12755
|
+
}
|
|
12628
12756
|
var acpOtherSessionUpdateSchema = z39.object({
|
|
12629
12757
|
sessionUpdate: z39.string()
|
|
12630
12758
|
}).passthrough();
|
|
@@ -12640,7 +12768,6 @@ var acpSessionNotificationParamsSchema = z39.object({
|
|
|
12640
12768
|
sessionId: z39.string(),
|
|
12641
12769
|
update: acpSessionUpdateSchema
|
|
12642
12770
|
}).passthrough();
|
|
12643
|
-
var acpOptionalString = z39.union([z39.string(), z39.null()]).transform((value) => value ?? void 0).optional();
|
|
12644
12771
|
var acpConfigOptionSelectOptionSchema = z39.object({
|
|
12645
12772
|
value: z39.string(),
|
|
12646
12773
|
name: acpOptionalString
|
|
@@ -13265,11 +13392,11 @@ function healthResult(args) {
|
|
|
13265
13392
|
}
|
|
13266
13393
|
};
|
|
13267
13394
|
}
|
|
13268
|
-
async function readAcpCliVersion(command) {
|
|
13395
|
+
async function readAcpCliVersion(command, env) {
|
|
13269
13396
|
try {
|
|
13270
13397
|
const { stdout, stderr } = await execPortableFile(command, ["--version"], {
|
|
13271
13398
|
cwd: process.cwd(),
|
|
13272
|
-
env
|
|
13399
|
+
env,
|
|
13273
13400
|
maxBuffer: 1024 * 1024,
|
|
13274
13401
|
timeout: 5e3
|
|
13275
13402
|
});
|
|
@@ -13291,10 +13418,10 @@ async function getAcpProviderHealth(args) {
|
|
|
13291
13418
|
statusMessage: "The ACP provider has no launch command."
|
|
13292
13419
|
});
|
|
13293
13420
|
}
|
|
13294
|
-
if (await resolveExecutablePath(args.command) === null) {
|
|
13421
|
+
if (await resolveExecutablePath(args.command, args.env) === null) {
|
|
13295
13422
|
return healthResult({ maintenance, status: "not_installed" });
|
|
13296
13423
|
}
|
|
13297
|
-
const version = await readAcpCliVersion(args.command);
|
|
13424
|
+
const version = await readAcpCliVersion(args.command, args.env);
|
|
13298
13425
|
if (maintenance === void 0) {
|
|
13299
13426
|
return healthResult({
|
|
13300
13427
|
maintenance,
|
|
@@ -13321,9 +13448,9 @@ async function getAcpProviderHealth(args) {
|
|
|
13321
13448
|
}
|
|
13322
13449
|
async function getAcpProviderInstallationStatus(args) {
|
|
13323
13450
|
const executableName = args.command ?? "";
|
|
13324
|
-
const resolvedExecutable = args.command === null ? null : await resolveExecutablePath(args.command);
|
|
13451
|
+
const resolvedExecutable = args.command === null ? null : await resolveExecutablePath(args.command, args.env);
|
|
13325
13452
|
const installed = resolvedExecutable !== null;
|
|
13326
|
-
const currentVersion = installed && args.command !== null ? await readAcpCliVersion(args.command) : null;
|
|
13453
|
+
const currentVersion = installed && args.command !== null ? await readAcpCliVersion(args.command, args.env) : null;
|
|
13327
13454
|
const installAction = args.maintenance !== void 0 && !installed ? {
|
|
13328
13455
|
kind: "install",
|
|
13329
13456
|
label: "Install",
|
|
@@ -13435,7 +13562,7 @@ function fetchDashboard(method, accessToken) {
|
|
|
13435
13562
|
async function getAcpProviderUsage(args) {
|
|
13436
13563
|
const readUsage = args.dialectId === "opencode" ? () => readOpenCodeGoUsage(args.env) : args.maintenance?.readUsage;
|
|
13437
13564
|
if (readUsage === void 0) return { supported: false };
|
|
13438
|
-
if (args.command === null || await resolveExecutablePath(args.command) === null) {
|
|
13565
|
+
if (args.command === null || await resolveExecutablePath(args.command, args.env) === null) {
|
|
13439
13566
|
return { supported: true, usage: { status: "not_installed" } };
|
|
13440
13567
|
}
|
|
13441
13568
|
return readUsage();
|
|
@@ -13722,7 +13849,7 @@ function truncatedPayloadText(text) {
|
|
|
13722
13849
|
return text;
|
|
13723
13850
|
}
|
|
13724
13851
|
const removed = text.length - ACP_TOOL_PAYLOAD_MAX_CHARS;
|
|
13725
|
-
return `${text
|
|
13852
|
+
return `${sliceUtf16Head(text, ACP_TOOL_PAYLOAD_MAX_CHARS)}
|
|
13726
13853
|
\u2026[${removed.toLocaleString("en-US")} more characters truncated]`;
|
|
13727
13854
|
}
|
|
13728
13855
|
function boundAcpToolPayload(value) {
|
|
@@ -14736,13 +14863,15 @@ var NORMALIZED_ACP_UPDATE_KINDS = /* @__PURE__ */ new Set([
|
|
|
14736
14863
|
"tool_call_update",
|
|
14737
14864
|
"plan",
|
|
14738
14865
|
"usage_update",
|
|
14739
|
-
"session_info_update"
|
|
14866
|
+
"session_info_update",
|
|
14867
|
+
"compaction_update"
|
|
14740
14868
|
]);
|
|
14741
14869
|
var NOISE_ACP_UPDATE_KINDS = /* @__PURE__ */ new Set([
|
|
14742
14870
|
"user_message_chunk",
|
|
14743
14871
|
"available_commands_update",
|
|
14744
14872
|
"current_mode_update",
|
|
14745
|
-
"config_option_update"
|
|
14873
|
+
"config_option_update",
|
|
14874
|
+
"compaction_summary_chunk"
|
|
14746
14875
|
]);
|
|
14747
14876
|
function parseAcpRawEvent(event) {
|
|
14748
14877
|
if (event.method !== ACP_UPDATE_METHOD) {
|
|
@@ -14865,6 +14994,8 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
14865
14994
|
}
|
|
14866
14995
|
let lastUsageCost;
|
|
14867
14996
|
let lastAgentTitle;
|
|
14997
|
+
const openAgentCompactions = /* @__PURE__ */ new Set();
|
|
14998
|
+
const finishedAgentCompactions = /* @__PURE__ */ new Set();
|
|
14868
14999
|
let injectedToolsByName = /* @__PURE__ */ new Map();
|
|
14869
15000
|
const injectedToolBindings = /* @__PURE__ */ new Map();
|
|
14870
15001
|
const pendingInjectedCalls = /* @__PURE__ */ new Map();
|
|
@@ -15172,6 +15303,75 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15172
15303
|
...drainOpenToolCalls(context, status)
|
|
15173
15304
|
];
|
|
15174
15305
|
}
|
|
15306
|
+
function agentCompactionKey(compactionId) {
|
|
15307
|
+
return {
|
|
15308
|
+
channel: "compaction",
|
|
15309
|
+
providerItemId: `compaction:${compactionId}`
|
|
15310
|
+
};
|
|
15311
|
+
}
|
|
15312
|
+
function agentCompactionFailure(status, error) {
|
|
15313
|
+
switch (status) {
|
|
15314
|
+
case "failed":
|
|
15315
|
+
return {
|
|
15316
|
+
kind: "provider.error",
|
|
15317
|
+
message: "Context compaction failed",
|
|
15318
|
+
detail: error ?? "The agent reported that context compaction failed"
|
|
15319
|
+
};
|
|
15320
|
+
case "cancelled":
|
|
15321
|
+
return {
|
|
15322
|
+
kind: "provider.error",
|
|
15323
|
+
message: "Context compaction interrupted",
|
|
15324
|
+
detail: error ?? "The agent cancelled context compaction"
|
|
15325
|
+
};
|
|
15326
|
+
default:
|
|
15327
|
+
return void 0;
|
|
15328
|
+
}
|
|
15329
|
+
}
|
|
15330
|
+
function translateCompactionUpdate(update, context, rawEvent) {
|
|
15331
|
+
const parsed = acpCompactionUpdateSchema.safeParse(update);
|
|
15332
|
+
if (!parsed.success) {
|
|
15333
|
+
return suppressedUnhandled(rawEvent);
|
|
15334
|
+
}
|
|
15335
|
+
const { compactionId, status, error } = parsed.data;
|
|
15336
|
+
const compactionKey = callKey(context, compactionId);
|
|
15337
|
+
if (finishedAgentCompactions.has(compactionKey)) {
|
|
15338
|
+
return [];
|
|
15339
|
+
}
|
|
15340
|
+
const deltas = [];
|
|
15341
|
+
if (!openAgentCompactions.has(compactionKey)) {
|
|
15342
|
+
openAgentCompactions.add(compactionKey);
|
|
15343
|
+
deltas.push(closeThoughtStream(), closeAssistantStream(), {
|
|
15344
|
+
kind: "item.open",
|
|
15345
|
+
key: agentCompactionKey(compactionId),
|
|
15346
|
+
item: { type: "compaction" },
|
|
15347
|
+
presentation: COMPACTION_PRESENTATION,
|
|
15348
|
+
noTurnFallback: noTurnFallbackFor(rawEvent)
|
|
15349
|
+
});
|
|
15350
|
+
}
|
|
15351
|
+
const failure = agentCompactionFailure(status, error || void 0);
|
|
15352
|
+
if (status !== "completed" && failure === void 0) {
|
|
15353
|
+
return deltas;
|
|
15354
|
+
}
|
|
15355
|
+
openAgentCompactions.delete(compactionKey);
|
|
15356
|
+
finishedAgentCompactions.add(compactionKey);
|
|
15357
|
+
if (failure !== void 0) {
|
|
15358
|
+
return [...deltas, failure];
|
|
15359
|
+
}
|
|
15360
|
+
return [
|
|
15361
|
+
...deltas,
|
|
15362
|
+
{
|
|
15363
|
+
kind: "item.close",
|
|
15364
|
+
key: agentCompactionKey(compactionId),
|
|
15365
|
+
status: "completed",
|
|
15366
|
+
item: { type: "compaction" },
|
|
15367
|
+
presentation: COMPACTION_PRESENTATION
|
|
15368
|
+
},
|
|
15369
|
+
{
|
|
15370
|
+
kind: "context.compacted",
|
|
15371
|
+
noTurnFallback: noTurnFallbackFor(rawEvent)
|
|
15372
|
+
}
|
|
15373
|
+
];
|
|
15374
|
+
}
|
|
15175
15375
|
function translateUpdate(update, context) {
|
|
15176
15376
|
const rawEvent = updateEnvelope(context, update);
|
|
15177
15377
|
switch (update.sessionUpdate) {
|
|
@@ -15372,6 +15572,8 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15372
15572
|
}
|
|
15373
15573
|
];
|
|
15374
15574
|
}
|
|
15575
|
+
case "compaction_update":
|
|
15576
|
+
return translateCompactionUpdate(update, context, rawEvent);
|
|
15375
15577
|
case "session_info_update": {
|
|
15376
15578
|
const title = isJsonObject(update) ? update["title"] : void 0;
|
|
15377
15579
|
if (typeof title !== "string" || title.trim() === "" || title.trimStart().startsWith(SYSTEM_INSTRUCTIONS_OPEN_TAG) || title === lastAgentTitle) {
|
|
@@ -16057,7 +16259,14 @@ function planConfirmation(message) {
|
|
|
16057
16259
|
kind: "questions",
|
|
16058
16260
|
payload,
|
|
16059
16261
|
toResponse(resolution) {
|
|
16060
|
-
|
|
16262
|
+
const selected = resolution.answers[CONFIRM_QUESTION_ID]?.selected[0];
|
|
16263
|
+
if (selected === CONFIRM_ACCEPT_VALUE) {
|
|
16264
|
+
return { action: "accept", content: {} };
|
|
16265
|
+
}
|
|
16266
|
+
if (selected === CONFIRM_DECLINE_VALUE) {
|
|
16267
|
+
return { action: "decline" };
|
|
16268
|
+
}
|
|
16269
|
+
return { unmappable: "the answer was neither Accept nor Decline" };
|
|
16061
16270
|
}
|
|
16062
16271
|
};
|
|
16063
16272
|
}
|
|
@@ -16156,7 +16365,9 @@ function planAcpElicitation(params) {
|
|
|
16156
16365
|
for (const entry of planned) {
|
|
16157
16366
|
const answered = contentFor(entry, resolution.answers[entry.name]);
|
|
16158
16367
|
if (!answered) {
|
|
16159
|
-
return {
|
|
16368
|
+
return {
|
|
16369
|
+
unmappable: `the answer to "${entry.name}" does not fit that field`
|
|
16370
|
+
};
|
|
16160
16371
|
}
|
|
16161
16372
|
Object.assign(content, answered);
|
|
16162
16373
|
}
|
|
@@ -16766,10 +16977,11 @@ function buildAcpSessionInstructions(options) {
|
|
|
16766
16977
|
);
|
|
16767
16978
|
return instructions.length > 0 ? instructions.join("\n\n") : void 0;
|
|
16768
16979
|
}
|
|
16769
|
-
function launchEnvVars(launchSpec) {
|
|
16770
|
-
|
|
16980
|
+
function launchEnvVars(launchSpec, envVars) {
|
|
16981
|
+
const merged = { ...launchSpec.env, ...envVars };
|
|
16982
|
+
return Object.keys(merged).length > 0 ? { envVars: merged } : {};
|
|
16771
16983
|
}
|
|
16772
|
-
function buildAcpModelListCommand(launchSpec) {
|
|
16984
|
+
function buildAcpModelListCommand(launchSpec, envVars) {
|
|
16773
16985
|
if (!launchSpec.modelCli || launchSpec.modelCli.listArgs.length === 0) {
|
|
16774
16986
|
return void 0;
|
|
16775
16987
|
}
|
|
@@ -16777,19 +16989,19 @@ function buildAcpModelListCommand(launchSpec) {
|
|
|
16777
16989
|
command: launchSpec.command,
|
|
16778
16990
|
args: [...launchSpec.modelCli.listArgs],
|
|
16779
16991
|
...launchSpec.cwd !== void 0 ? { cwd: launchSpec.cwd } : {},
|
|
16780
|
-
...launchEnvVars(launchSpec)
|
|
16992
|
+
...launchEnvVars(launchSpec, envVars)
|
|
16781
16993
|
};
|
|
16782
16994
|
}
|
|
16783
|
-
function buildAcpAgentCommand(launchSpec) {
|
|
16995
|
+
function buildAcpAgentCommand(launchSpec, envVars) {
|
|
16784
16996
|
return {
|
|
16785
16997
|
command: launchSpec.command,
|
|
16786
16998
|
args: [...launchSpec.args],
|
|
16787
16999
|
...launchSpec.cwd !== void 0 ? { cwd: launchSpec.cwd } : {},
|
|
16788
|
-
...launchEnvVars(launchSpec)
|
|
17000
|
+
...launchEnvVars(launchSpec, envVars)
|
|
16789
17001
|
};
|
|
16790
17002
|
}
|
|
16791
|
-
function buildAcpModelDiscoveryAgentCommand(launchSpec) {
|
|
16792
|
-
return buildAcpModelListCommand(launchSpec) !== void 0 ? void 0 : buildAcpAgentCommand(launchSpec);
|
|
17003
|
+
function buildAcpModelDiscoveryAgentCommand(launchSpec, envVars) {
|
|
17004
|
+
return buildAcpModelListCommand(launchSpec, envVars) !== void 0 ? void 0 : buildAcpAgentCommand(launchSpec, envVars);
|
|
16793
17005
|
}
|
|
16794
17006
|
function buildAcpModelListParams(launchSpec, options) {
|
|
16795
17007
|
const primaryModels = [
|
|
@@ -16801,12 +17013,12 @@ function buildAcpModelListParams(launchSpec, options) {
|
|
|
16801
17013
|
parameterizedModelPicker: options.parameterizedModelPicker
|
|
16802
17014
|
};
|
|
16803
17015
|
}
|
|
16804
|
-
const listCommand = buildAcpModelListCommand(launchSpec);
|
|
16805
|
-
const agent = buildAcpModelDiscoveryAgentCommand(launchSpec);
|
|
17016
|
+
const listCommand = buildAcpModelListCommand(launchSpec, options.envVars);
|
|
17017
|
+
const agent = buildAcpModelDiscoveryAgentCommand(launchSpec, options.envVars);
|
|
16806
17018
|
return {
|
|
16807
17019
|
...listCommand !== void 0 ? { listCommand } : {},
|
|
16808
17020
|
...agent !== void 0 ? { agent } : {},
|
|
16809
|
-
optionsAgent: buildAcpAgentCommand(launchSpec),
|
|
17021
|
+
optionsAgent: buildAcpAgentCommand(launchSpec, options.envVars),
|
|
16810
17022
|
primaryModels,
|
|
16811
17023
|
parameterizedModelPicker: options.parameterizedModelPicker,
|
|
16812
17024
|
...launchSpec.reasoningCli !== void 0 ? { reasoningCli: launchSpec.reasoningCli } : {},
|
|
@@ -16827,7 +17039,10 @@ function buildAcpModelSelectionParams(launchSpec, options, parameterizedModelPic
|
|
|
16827
17039
|
}
|
|
16828
17040
|
function buildAcpModelSelection(launchSpec, options, parameterizedModelPicker, dialectId) {
|
|
16829
17041
|
const model = options.model;
|
|
16830
|
-
const listCommand = buildAcpModelListCommand(
|
|
17042
|
+
const listCommand = buildAcpModelListCommand(
|
|
17043
|
+
launchSpec,
|
|
17044
|
+
withoutThreadIdentityEnv(options.envVars ?? {})
|
|
17045
|
+
);
|
|
16831
17046
|
if (!model || model === ACP_DEFAULT_MODEL_ID) {
|
|
16832
17047
|
return void 0;
|
|
16833
17048
|
}
|
|
@@ -20381,7 +20596,7 @@ function createAcpMessageStream(options) {
|
|
|
20381
20596
|
outstandingRequestIds.add(id);
|
|
20382
20597
|
}
|
|
20383
20598
|
}
|
|
20384
|
-
options.output.write(`${
|
|
20599
|
+
options.output.write(`${serializeJsonRpcLine(message)}
|
|
20385
20600
|
`);
|
|
20386
20601
|
}
|
|
20387
20602
|
});
|
|
@@ -20389,6 +20604,7 @@ function createAcpMessageStream(options) {
|
|
|
20389
20604
|
}
|
|
20390
20605
|
|
|
20391
20606
|
// ../provider-bridge-acp/src/client/acp-client.ts
|
|
20607
|
+
var ACP_RESOURCE_NOT_FOUND_CODE = -32002;
|
|
20392
20608
|
var AcpRequestTimeoutError = class extends Error {
|
|
20393
20609
|
method;
|
|
20394
20610
|
timeoutMs;
|
|
@@ -20861,6 +21077,7 @@ function acpClientCapabilities(parameterizedModelPicker, fsAccess, elicitation)
|
|
|
20861
21077
|
fs: { readTextFile: fsAccess, writeTextFile: fsAccess },
|
|
20862
21078
|
terminal: false,
|
|
20863
21079
|
auth: { terminal: true },
|
|
21080
|
+
session: { compaction: {} },
|
|
20864
21081
|
...elicitation ? { elicitation: { form: {} } } : {},
|
|
20865
21082
|
...parameterizedModelPicker === true ? { _meta: { parameterizedModelPicker: true } } : {}
|
|
20866
21083
|
};
|
|
@@ -21907,7 +22124,7 @@ async function resolveCursorProjectRoot(args) {
|
|
|
21907
22124
|
execHostFileCallback(
|
|
21908
22125
|
"git",
|
|
21909
22126
|
["rev-parse", "--show-toplevel"],
|
|
21910
|
-
{ cwd: args.cwd, env: args.env
|
|
22127
|
+
{ cwd: args.cwd, env: args.env },
|
|
21911
22128
|
(error, stdout) => {
|
|
21912
22129
|
const root = stdout.trim();
|
|
21913
22130
|
resolveRoot(error === null && root !== "" ? root : resolve3(args.cwd));
|
|
@@ -22058,6 +22275,7 @@ var SESSION_BUSY_QUIET_MS = 2e3;
|
|
|
22058
22275
|
var SESSION_BUSY_MAX_WAITS = 300;
|
|
22059
22276
|
var SESSION_BUSY_MAX_RETRIES = 3;
|
|
22060
22277
|
var ACP_SESSION_BUSY_ERROR_CODE = -32003;
|
|
22278
|
+
var ACP_LOST_SESSION_MESSAGE = /\bsession\b(?:\s+\S+)?\s+not found|\bsession lock unavailable\b/i;
|
|
22061
22279
|
var ACP_SESSION_SETUP_TIMEOUT_MS = 3e5;
|
|
22062
22280
|
var ACP_SESSION_CONFIG_TIMEOUT_MS = 6e4;
|
|
22063
22281
|
var ACP_AUTHENTICATE_TIMEOUT_MS = 12e4;
|
|
@@ -22073,8 +22291,10 @@ function sendRuntimeRequest(method, params, signal) {
|
|
|
22073
22291
|
const responsePromise = new Promise(
|
|
22074
22292
|
(resolveResponse, rejectResponse) => {
|
|
22075
22293
|
abort = () => {
|
|
22076
|
-
pendingRuntimeRequests.delete(requestId);
|
|
22077
|
-
sendNotification(
|
|
22294
|
+
if (!pendingRuntimeRequests.delete(requestId)) return;
|
|
22295
|
+
sendNotification(BRIDGE_NOTIFICATION_METHODS.requestCancelled, {
|
|
22296
|
+
requestId
|
|
22297
|
+
});
|
|
22078
22298
|
rejectResponse(new Error("ACP dynamic tool call cancelled"));
|
|
22079
22299
|
};
|
|
22080
22300
|
signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -22456,10 +22676,7 @@ async function authenticateAcpAgent(args) {
|
|
|
22456
22676
|
async function loadAgentModelCatalog(listCommand) {
|
|
22457
22677
|
const stdout = await execPortableFile(listCommand.command, listCommand.args, {
|
|
22458
22678
|
cwd: listCommand.cwd ?? process.cwd(),
|
|
22459
|
-
env:
|
|
22460
|
-
...withoutBridgeRuntimeEnv(process.env),
|
|
22461
|
-
...listCommand.envVars ?? {}
|
|
22462
|
-
},
|
|
22679
|
+
env: buildProviderCliEnv(listCommand.envVars),
|
|
22463
22680
|
maxBuffer: 1024 * 1024,
|
|
22464
22681
|
timeout: MODEL_LIST_TIMEOUT_MS
|
|
22465
22682
|
}).then(
|
|
@@ -22578,10 +22795,7 @@ async function loadDeclaredSessionOptions(agent, parameterizedModelPicker, diale
|
|
|
22578
22795
|
if (cached !== null) {
|
|
22579
22796
|
return cached;
|
|
22580
22797
|
}
|
|
22581
|
-
const childEnv =
|
|
22582
|
-
...withoutBridgeRuntimeEnv(process.env),
|
|
22583
|
-
...agent.envVars ?? {}
|
|
22584
|
-
};
|
|
22798
|
+
const childEnv = buildProviderCliEnv(agent.envVars);
|
|
22585
22799
|
const connection = createBridgeAgentConnection({
|
|
22586
22800
|
command: agent.command,
|
|
22587
22801
|
args: agent.args,
|
|
@@ -22672,10 +22886,7 @@ async function loadSessionDiscoveredModels(agent, parameterizedModelPicker, dial
|
|
|
22672
22886
|
if (selectedModel === void 0 && cachedSessionDiscoveredModels?.key === key && Date.now() - cachedSessionDiscoveredModels.fetchedAt < SESSION_MODEL_DISCOVERY_TTL_MS) {
|
|
22673
22887
|
return cachedSessionDiscoveredModels.models;
|
|
22674
22888
|
}
|
|
22675
|
-
const childEnv =
|
|
22676
|
-
...withoutBridgeRuntimeEnv(process.env),
|
|
22677
|
-
...agent.envVars ?? {}
|
|
22678
|
-
};
|
|
22889
|
+
const childEnv = buildProviderCliEnv(agent.envVars);
|
|
22679
22890
|
const connection = createBridgeAgentConnection({
|
|
22680
22891
|
command: agent.command,
|
|
22681
22892
|
args: agent.args,
|
|
@@ -23237,65 +23448,121 @@ function pickPermissionOptionId(options, decision) {
|
|
|
23237
23448
|
return findOptionIdByKinds(options, ["reject_once", "reject_always"]);
|
|
23238
23449
|
}
|
|
23239
23450
|
}
|
|
23240
|
-
function
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23451
|
+
function answerWithoutUser(session, responder, cause) {
|
|
23452
|
+
sendThreadDeltas(session.bbThreadId, [
|
|
23453
|
+
unansweredInteractionWarning({ cause, answer: { kind: "error" } })
|
|
23454
|
+
]);
|
|
23455
|
+
responder.error(
|
|
23456
|
+
cause.kind === "unshowable-request" ? -32602 : -32603,
|
|
23457
|
+
unansweredInteractionErrorMessage(cause)
|
|
23458
|
+
);
|
|
23459
|
+
}
|
|
23460
|
+
function runtimeErrorCause(error) {
|
|
23461
|
+
return {
|
|
23462
|
+
kind: "runtime-error",
|
|
23463
|
+
message: error instanceof Error ? error.message : String(error)
|
|
23464
|
+
};
|
|
23465
|
+
}
|
|
23466
|
+
function respondPermission(session, pending, decision) {
|
|
23245
23467
|
const optionId = pickPermissionOptionId(pending.options, decision);
|
|
23246
23468
|
if (optionId === void 0) {
|
|
23247
|
-
pending.responder
|
|
23469
|
+
answerWithoutUser(session, pending.responder, {
|
|
23470
|
+
kind: "unmappable-answer",
|
|
23471
|
+
detail: `the agent offered no option for ${decision.replaceAll("_", " ")}`
|
|
23472
|
+
});
|
|
23248
23473
|
return;
|
|
23249
23474
|
}
|
|
23250
23475
|
pending.responder.result({ outcome: { outcome: "selected", optionId } });
|
|
23251
23476
|
}
|
|
23477
|
+
function withdrawPendingQuestions(session, detail) {
|
|
23478
|
+
const cause = { kind: "withdrawn", detail };
|
|
23479
|
+
const permissions = [...session.pendingPermissions];
|
|
23480
|
+
const elicitations = [...session.pendingElicitations];
|
|
23481
|
+
session.pendingPermissions.clear();
|
|
23482
|
+
session.pendingElicitations.clear();
|
|
23483
|
+
for (const pending of permissions) {
|
|
23484
|
+
answerWithoutUser(session, pending.responder, cause);
|
|
23485
|
+
pending.withdrawal.abort();
|
|
23486
|
+
}
|
|
23487
|
+
for (const [responder, withdrawal] of elicitations) {
|
|
23488
|
+
answerWithoutUser(session, responder, cause);
|
|
23489
|
+
withdrawal.abort();
|
|
23490
|
+
}
|
|
23491
|
+
}
|
|
23252
23492
|
function cancelPendingPermissions(session) {
|
|
23253
|
-
|
|
23493
|
+
const permissions = [...session.pendingPermissions];
|
|
23494
|
+
const elicitations = [...session.pendingElicitations];
|
|
23495
|
+
session.pendingPermissions.clear();
|
|
23496
|
+
session.pendingElicitations.clear();
|
|
23497
|
+
for (const pending of permissions) {
|
|
23254
23498
|
pending.responder.result({ outcome: { outcome: "cancelled" } });
|
|
23499
|
+
pending.withdrawal.abort();
|
|
23255
23500
|
}
|
|
23256
|
-
|
|
23257
|
-
for (const responder of session.pendingElicitations) {
|
|
23501
|
+
for (const [responder, withdrawal] of elicitations) {
|
|
23258
23502
|
responder.result({ action: "cancel" });
|
|
23503
|
+
withdrawal.abort();
|
|
23259
23504
|
}
|
|
23260
|
-
session.pendingElicitations.clear();
|
|
23261
23505
|
}
|
|
23506
|
+
var COMPACTION_QUESTION_CAUSE = {
|
|
23507
|
+
kind: "unshowable-request",
|
|
23508
|
+
detail: "the agent asked while bb was compacting the conversation"
|
|
23509
|
+
};
|
|
23262
23510
|
function handleElicitationRequest(session, params, responder) {
|
|
23263
|
-
if (session.stopping || session.cancelRequested
|
|
23511
|
+
if (session.stopping || session.cancelRequested) {
|
|
23264
23512
|
responder.result({ action: "cancel" });
|
|
23265
23513
|
return;
|
|
23266
23514
|
}
|
|
23515
|
+
if (session.activePromptKind === "compaction") {
|
|
23516
|
+
answerWithoutUser(session, responder, COMPACTION_QUESTION_CAUSE);
|
|
23517
|
+
return;
|
|
23518
|
+
}
|
|
23267
23519
|
const plan = planAcpElicitation(params);
|
|
23268
23520
|
if (plan.kind === "unsupported") {
|
|
23269
|
-
|
|
23270
|
-
|
|
23271
|
-
|
|
23272
|
-
details: `bb answered the agent with an error because ${plan.reason}.`
|
|
23521
|
+
answerWithoutUser(session, responder, {
|
|
23522
|
+
kind: "unshowable-request",
|
|
23523
|
+
detail: plan.reason
|
|
23273
23524
|
});
|
|
23274
|
-
responder.error(-32602, `bb cannot show this form: ${plan.reason}`);
|
|
23275
23525
|
return;
|
|
23276
23526
|
}
|
|
23277
23527
|
if (session.activePromptKind === null) {
|
|
23278
23528
|
openAgentTurn(session);
|
|
23279
23529
|
}
|
|
23280
|
-
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23530
|
+
const withdrawal = new AbortController();
|
|
23531
|
+
session.pendingElicitations.set(responder, withdrawal);
|
|
23532
|
+
void sendRuntimeRequest(
|
|
23533
|
+
BRIDGE_INBOUND_REQUEST_METHODS.interactionRequest,
|
|
23534
|
+
{
|
|
23535
|
+
providerThreadId: session.providerThreadId,
|
|
23536
|
+
threadId: session.bbThreadId,
|
|
23537
|
+
turnId: null,
|
|
23538
|
+
payload: plan.payload
|
|
23539
|
+
},
|
|
23540
|
+
withdrawal.signal
|
|
23541
|
+
).then((result) => {
|
|
23287
23542
|
if (!session.pendingElicitations.delete(responder)) {
|
|
23288
23543
|
return;
|
|
23289
23544
|
}
|
|
23290
23545
|
const resolution = userQuestionPendingInteractionResolutionSchema.safeParse(result);
|
|
23291
|
-
|
|
23292
|
-
|
|
23293
|
-
|
|
23294
|
-
|
|
23546
|
+
if (!resolution.success) {
|
|
23547
|
+
answerWithoutUser(session, responder, {
|
|
23548
|
+
kind: "unreadable-resolution"
|
|
23549
|
+
});
|
|
23550
|
+
return;
|
|
23551
|
+
}
|
|
23552
|
+
const response = plan.toResponse(resolution.data);
|
|
23553
|
+
if ("unmappable" in response) {
|
|
23554
|
+
answerWithoutUser(session, responder, {
|
|
23555
|
+
kind: "unmappable-answer",
|
|
23556
|
+
detail: response.unmappable
|
|
23557
|
+
});
|
|
23558
|
+
return;
|
|
23559
|
+
}
|
|
23560
|
+
responder.result(response);
|
|
23561
|
+
}).catch((error) => {
|
|
23295
23562
|
if (!session.pendingElicitations.delete(responder)) {
|
|
23296
23563
|
return;
|
|
23297
23564
|
}
|
|
23298
|
-
|
|
23565
|
+
answerWithoutUser(session, responder, runtimeErrorCause(error));
|
|
23299
23566
|
});
|
|
23300
23567
|
}
|
|
23301
23568
|
function handlePermissionRequest(session, params, responder) {
|
|
@@ -23304,10 +23571,14 @@ function handlePermissionRequest(session, params, responder) {
|
|
|
23304
23571
|
responder.error(-32602, "Invalid session/request_permission params");
|
|
23305
23572
|
return;
|
|
23306
23573
|
}
|
|
23307
|
-
if (session.stopping || session.cancelRequested
|
|
23574
|
+
if (session.stopping || session.cancelRequested) {
|
|
23308
23575
|
responder.result({ outcome: { outcome: "cancelled" } });
|
|
23309
23576
|
return;
|
|
23310
23577
|
}
|
|
23578
|
+
if (session.activePromptKind === "compaction") {
|
|
23579
|
+
answerWithoutUser(session, responder, COMPACTION_QUESTION_CAUSE);
|
|
23580
|
+
return;
|
|
23581
|
+
}
|
|
23311
23582
|
const toolCall = parsed.data.toolCall;
|
|
23312
23583
|
const bound = toolCall?.toolCallId !== void 0 ? session.translator.notePermissionToolCall(session.bbThreadId, {
|
|
23313
23584
|
toolCallId: toolCall.toolCallId,
|
|
@@ -23320,10 +23591,11 @@ function handlePermissionRequest(session, params, responder) {
|
|
|
23320
23591
|
}) : void 0;
|
|
23321
23592
|
const pending = {
|
|
23322
23593
|
responder,
|
|
23323
|
-
options: parsed.data.options
|
|
23594
|
+
options: parsed.data.options,
|
|
23595
|
+
withdrawal: new AbortController()
|
|
23324
23596
|
};
|
|
23325
23597
|
if (session.policy.permissionMode === "full") {
|
|
23326
|
-
respondPermission(pending, "allow_once");
|
|
23598
|
+
respondPermission(session, pending, "allow_once");
|
|
23327
23599
|
return;
|
|
23328
23600
|
}
|
|
23329
23601
|
const normalizedToolCall = toolCall?.toolCallId !== void 0 && bound !== void 0 ? {
|
|
@@ -23348,19 +23620,23 @@ function handlePermissionRequest(session, params, responder) {
|
|
|
23348
23620
|
});
|
|
23349
23621
|
const grantKey = acpSessionGrantKey(payload);
|
|
23350
23622
|
if (grantKey !== null && session.sessionGrants.has(grantKey)) {
|
|
23351
|
-
respondPermission(pending, "allow_once");
|
|
23623
|
+
respondPermission(session, pending, "allow_once");
|
|
23352
23624
|
return;
|
|
23353
23625
|
}
|
|
23354
23626
|
if (session.activePromptKind === null) {
|
|
23355
23627
|
openAgentTurn(session);
|
|
23356
23628
|
}
|
|
23357
23629
|
session.pendingPermissions.add(pending);
|
|
23358
|
-
void sendRuntimeRequest(
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
23363
|
-
|
|
23630
|
+
void sendRuntimeRequest(
|
|
23631
|
+
BRIDGE_INBOUND_REQUEST_METHODS.interactionRequest,
|
|
23632
|
+
{
|
|
23633
|
+
providerThreadId: session.providerThreadId,
|
|
23634
|
+
threadId: session.bbThreadId,
|
|
23635
|
+
turnId: null,
|
|
23636
|
+
payload
|
|
23637
|
+
},
|
|
23638
|
+
pending.withdrawal.signal
|
|
23639
|
+
).then((result) => {
|
|
23364
23640
|
if (!session.pendingPermissions.delete(pending)) {
|
|
23365
23641
|
return;
|
|
23366
23642
|
}
|
|
@@ -23369,15 +23645,21 @@ function handlePermissionRequest(session, params, responder) {
|
|
|
23369
23645
|
payload,
|
|
23370
23646
|
resolution: resolution.data
|
|
23371
23647
|
}) : null;
|
|
23372
|
-
if (response
|
|
23648
|
+
if (response === null) {
|
|
23649
|
+
answerWithoutUser(session, pending.responder, {
|
|
23650
|
+
kind: "unreadable-resolution"
|
|
23651
|
+
});
|
|
23652
|
+
return;
|
|
23653
|
+
}
|
|
23654
|
+
if (response.decision === "allow_for_session" && grantKey !== null) {
|
|
23373
23655
|
session.sessionGrants.add(grantKey);
|
|
23374
23656
|
}
|
|
23375
|
-
respondPermission(pending, response
|
|
23376
|
-
}).catch(() => {
|
|
23657
|
+
respondPermission(session, pending, response.decision);
|
|
23658
|
+
}).catch((error) => {
|
|
23377
23659
|
if (!session.pendingPermissions.delete(pending)) {
|
|
23378
23660
|
return;
|
|
23379
23661
|
}
|
|
23380
|
-
|
|
23662
|
+
answerWithoutUser(session, pending.responder, runtimeErrorCause(error));
|
|
23381
23663
|
});
|
|
23382
23664
|
}
|
|
23383
23665
|
function isPathInsideRoots(targetPath, roots) {
|
|
@@ -23559,11 +23841,10 @@ async function startAgentSession(request) {
|
|
|
23559
23841
|
}
|
|
23560
23842
|
const agentLabel = [params.agent.command, ...params.agent.args].join(" ");
|
|
23561
23843
|
let session;
|
|
23562
|
-
const childEnv = {
|
|
23563
|
-
...withoutBridgeRuntimeEnv(process.env),
|
|
23844
|
+
const childEnv = buildProviderCliEnv({
|
|
23564
23845
|
...params.envVars,
|
|
23565
23846
|
...dialectLaunchEnv(dialect.id, params.permissionMode)
|
|
23566
|
-
};
|
|
23847
|
+
});
|
|
23567
23848
|
const connection = createBridgeAgentConnection({
|
|
23568
23849
|
command: params.agent.command,
|
|
23569
23850
|
args: launch.args,
|
|
@@ -23617,11 +23898,14 @@ async function startAgentSession(request) {
|
|
|
23617
23898
|
pendingInstructions: params.instructions,
|
|
23618
23899
|
activePromptKind: null,
|
|
23619
23900
|
compactionAgentMessage: "",
|
|
23901
|
+
compactionUpdateOutcome: void 0,
|
|
23902
|
+
openAgentCompactionIds: /* @__PURE__ */ new Set(),
|
|
23903
|
+
finishedAgentCompactionIds: /* @__PURE__ */ new Set(),
|
|
23620
23904
|
queuedInputs: [],
|
|
23621
23905
|
promptRequestPending: false,
|
|
23622
23906
|
cancelRequested: false,
|
|
23623
23907
|
turnStartedAtMs: void 0,
|
|
23624
|
-
|
|
23908
|
+
rebuildBeforeNextPrompt: null,
|
|
23625
23909
|
loading: false,
|
|
23626
23910
|
loadingSessionId: void 0,
|
|
23627
23911
|
pendingLoadUsageUpdate: void 0,
|
|
@@ -23630,7 +23914,7 @@ async function startAgentSession(request) {
|
|
|
23630
23914
|
turnSettled: void 0,
|
|
23631
23915
|
pendingPermissions: /* @__PURE__ */ new Set(),
|
|
23632
23916
|
sessionGrants: /* @__PURE__ */ new Set(),
|
|
23633
|
-
pendingElicitations: /* @__PURE__ */ new
|
|
23917
|
+
pendingElicitations: /* @__PURE__ */ new Map(),
|
|
23634
23918
|
pendingToolCalls: /* @__PURE__ */ new Set(),
|
|
23635
23919
|
cursorMcpApproval: void 0,
|
|
23636
23920
|
deferStartEmit: emitStartNotification,
|
|
@@ -23930,6 +24214,7 @@ function setActivePromptKind(session, kind) {
|
|
|
23930
24214
|
}
|
|
23931
24215
|
if (kind === null) {
|
|
23932
24216
|
clearAgentTurnQuietTimer(session);
|
|
24217
|
+
session.openAgentCompactionIds.clear();
|
|
23933
24218
|
if (session.promptWorkOpen) {
|
|
23934
24219
|
session.promptWorkOpen = false;
|
|
23935
24220
|
session.model.promptSettled({ stopReason: "end_turn" });
|
|
@@ -23945,7 +24230,7 @@ function clearAgentTurnQuietTimer(session) {
|
|
|
23945
24230
|
}
|
|
23946
24231
|
}
|
|
23947
24232
|
function agentTurnHasOpenWork(session) {
|
|
23948
|
-
return session.pendingPermissions.size > 0 || session.pendingElicitations.size > 0 || session.model.hasUnfinishedToolCalls();
|
|
24233
|
+
return session.pendingPermissions.size > 0 || session.pendingElicitations.size > 0 || session.openAgentCompactionIds.size > 0 || session.model.hasUnfinishedToolCalls();
|
|
23949
24234
|
}
|
|
23950
24235
|
function armAgentTurnQuietTimer(session) {
|
|
23951
24236
|
clearAgentTurnQuietTimer(session);
|
|
@@ -24189,6 +24474,14 @@ function finishTurn(session, stopReason) {
|
|
|
24189
24474
|
stopReason
|
|
24190
24475
|
});
|
|
24191
24476
|
}
|
|
24477
|
+
function isLostSessionError(error) {
|
|
24478
|
+
return error instanceof AcpAgentResponseError && (error.code === ACP_RESOURCE_NOT_FOUND_CODE || ACP_LOST_SESSION_MESSAGE.test(error.message));
|
|
24479
|
+
}
|
|
24480
|
+
function scheduleRebuildIfSessionLost(session, error) {
|
|
24481
|
+
if (isLostSessionError(error)) {
|
|
24482
|
+
session.rebuildBeforeNextPrompt ??= "lost-session";
|
|
24483
|
+
}
|
|
24484
|
+
}
|
|
24192
24485
|
function isSessionBusyError(error) {
|
|
24193
24486
|
return error instanceof AcpAgentResponseError && error.code === ACP_SESSION_BUSY_ERROR_CODE && isJsonObject(error.data) && error.data["reason"] === "session_busy";
|
|
24194
24487
|
}
|
|
@@ -24212,7 +24505,8 @@ var TURN_OUTPUT_UPDATE_KINDS = /* @__PURE__ */ new Set([
|
|
|
24212
24505
|
"agent_thought_chunk",
|
|
24213
24506
|
"tool_call",
|
|
24214
24507
|
"tool_call_update",
|
|
24215
|
-
"plan"
|
|
24508
|
+
"plan",
|
|
24509
|
+
"compaction_update"
|
|
24216
24510
|
]);
|
|
24217
24511
|
function isTurnOutputUpdate(update) {
|
|
24218
24512
|
const kind = isJsonObject(update) ? update["sessionUpdate"] : void 0;
|
|
@@ -24287,7 +24581,8 @@ function runTurn(session, firstInput, turnAlreadyOpen = false) {
|
|
|
24287
24581
|
}
|
|
24288
24582
|
}
|
|
24289
24583
|
} catch (error) {
|
|
24290
|
-
session.
|
|
24584
|
+
session.rebuildBeforeNextPrompt = session.cancelRequested ? "cancel-error" : null;
|
|
24585
|
+
scheduleRebuildIfSessionLost(session, error);
|
|
24291
24586
|
session.promptRequestPending = false;
|
|
24292
24587
|
dropTurnInput(pending, "ACP turn failed before the prompt was sent");
|
|
24293
24588
|
dropQueuedTurnInputs(
|
|
@@ -24383,8 +24678,8 @@ function reconcileExecutionSettings(session, options) {
|
|
|
24383
24678
|
dialectLaunchEnv(session.dialect.id, session.construction.permissionMode),
|
|
24384
24679
|
dialectLaunchEnv(session.dialect.id, construction.permissionMode)
|
|
24385
24680
|
) || launchModelChanged;
|
|
24386
|
-
const restart = session.connection.exited || session.
|
|
24387
|
-
|
|
24681
|
+
const restart = session.connection.exited || session.rebuildBeforeNextPrompt !== null || launchArgsChanged || !isDeepStrictEqual2(envVars ?? {}, session.construction.envVars ?? {});
|
|
24682
|
+
withdrawPendingQuestions(session, "a new prompt started before you answered");
|
|
24388
24683
|
session.policy = {
|
|
24389
24684
|
permissionMode: options.permissionMode,
|
|
24390
24685
|
workspaceWriteRoots
|
|
@@ -24419,7 +24714,7 @@ async function applyNativeModelSelection(session, construction) {
|
|
|
24419
24714
|
}
|
|
24420
24715
|
async function rebuildAgentSession(session, construction) {
|
|
24421
24716
|
const previousProviderThreadId = session.providerThreadId;
|
|
24422
|
-
const reason = session.connection.exited ? "The ACP agent exited unexpectedly; its session was rebuilt before continuing." : session.
|
|
24717
|
+
const reason = session.connection.exited ? "The ACP agent exited unexpectedly; its session was rebuilt before continuing." : session.rebuildBeforeNextPrompt === "cancel-error" ? "The ACP agent failed during cancellation; its session was rebuilt before continuing." : session.rebuildBeforeNextPrompt === "lost-session" ? "The ACP agent lost its session; the session was rebuilt before continuing." : "Execution settings changed; the ACP session was rebuilt to apply them.";
|
|
24423
24718
|
const queuedInputs = session.queuedInputs.splice(0);
|
|
24424
24719
|
const continuingTurn = session.activePromptKind === "turn";
|
|
24425
24720
|
if (continuingTurn) {
|
|
@@ -24489,6 +24784,7 @@ function startCompaction(session, pending) {
|
|
|
24489
24784
|
setActivePromptKind(session, "compaction");
|
|
24490
24785
|
session.awaitingFirstPrompt = false;
|
|
24491
24786
|
session.compactionAgentMessage = "";
|
|
24787
|
+
session.compactionUpdateOutcome = void 0;
|
|
24492
24788
|
emitForSession(session, ACP_COMPACTION_STARTED_METHOD, {
|
|
24493
24789
|
threadId: session.bbThreadId
|
|
24494
24790
|
});
|
|
@@ -24510,7 +24806,7 @@ function startCompaction(session, pending) {
|
|
|
24510
24806
|
emitGrokContextWindow(session, grokUsage.used);
|
|
24511
24807
|
}
|
|
24512
24808
|
finish(
|
|
24513
|
-
result.stopReason === "end_turn" ? compactionOutcomeForEndTurn(
|
|
24809
|
+
result.stopReason === "end_turn" ? session.compactionUpdateOutcome ?? compactionOutcomeForEndTurn(
|
|
24514
24810
|
session.dialect,
|
|
24515
24811
|
session.compactionAgentMessage
|
|
24516
24812
|
) : result.stopReason === "cancelled" ? { status: "interrupted" } : {
|
|
@@ -24519,6 +24815,7 @@ function startCompaction(session, pending) {
|
|
|
24519
24815
|
}
|
|
24520
24816
|
);
|
|
24521
24817
|
}).catch((error) => {
|
|
24818
|
+
scheduleRebuildIfSessionLost(session, error);
|
|
24522
24819
|
finish({
|
|
24523
24820
|
status: "failed",
|
|
24524
24821
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -24536,20 +24833,24 @@ function finishCompaction(session, outcome) {
|
|
|
24536
24833
|
setActivePromptKind(session, null);
|
|
24537
24834
|
session.turnSettled = void 0;
|
|
24538
24835
|
}
|
|
24836
|
+
var ACP_QUESTION_HANDLERS = /* @__PURE__ */ new Map([
|
|
24837
|
+
["session/request_permission", handlePermissionRequest],
|
|
24838
|
+
["elicitation/create", handleElicitationRequest]
|
|
24839
|
+
]);
|
|
24840
|
+
var ACP_QUESTION_REQUEST_METHODS = [...ACP_QUESTION_HANDLERS.keys()];
|
|
24539
24841
|
function handleAgentRequest(session, method, params, responder) {
|
|
24842
|
+
const question = ACP_QUESTION_HANDLERS.get(method);
|
|
24843
|
+
if (question !== void 0) {
|
|
24844
|
+
question(session, params, responder);
|
|
24845
|
+
return;
|
|
24846
|
+
}
|
|
24540
24847
|
switch (method) {
|
|
24541
|
-
case "session/request_permission":
|
|
24542
|
-
handlePermissionRequest(session, params, responder);
|
|
24543
|
-
return;
|
|
24544
24848
|
case "fs/read_text_file":
|
|
24545
24849
|
void handleFsReadTextFile(params, responder);
|
|
24546
24850
|
return;
|
|
24547
24851
|
case "fs/write_text_file":
|
|
24548
24852
|
void handleFsWriteTextFile(session, params, responder);
|
|
24549
24853
|
return;
|
|
24550
|
-
case "elicitation/create":
|
|
24551
|
-
handleElicitationRequest(session, params, responder);
|
|
24552
|
-
return;
|
|
24553
24854
|
default:
|
|
24554
24855
|
handleDialectRequest(session, method, params, responder);
|
|
24555
24856
|
}
|
|
@@ -24618,15 +24919,56 @@ function handleAgentNotification(session, method, params) {
|
|
|
24618
24919
|
};
|
|
24619
24920
|
}
|
|
24620
24921
|
}
|
|
24922
|
+
const compactionUpdate = session.dialect.id === "opencode" ? readOpenCodeCompactionUpdate(parsed.data.update) : void 0;
|
|
24923
|
+
const update = compactionUpdate ?? parsed.data.update;
|
|
24924
|
+
const parsedCompaction = acpCompactionUpdateSchema.safeParse(update);
|
|
24621
24925
|
if (session.activePromptKind === "compaction") {
|
|
24926
|
+
if (parsedCompaction.success) {
|
|
24927
|
+
recordCompactionUpdateOutcome(session, parsedCompaction.data);
|
|
24928
|
+
return;
|
|
24929
|
+
}
|
|
24622
24930
|
const chunk = acpAgentMessageChunkUpdateSchema.safeParse(
|
|
24623
24931
|
parsed.data.update
|
|
24624
24932
|
);
|
|
24625
24933
|
if (chunk.success) {
|
|
24626
24934
|
session.compactionAgentMessage += extractAcpContentText(chunk.data.content) ?? "";
|
|
24627
24935
|
}
|
|
24936
|
+
} else if (parsedCompaction.success) {
|
|
24937
|
+
trackAgentCompaction(session, parsedCompaction.data);
|
|
24938
|
+
}
|
|
24939
|
+
emitSessionUpdate(session, update, rawUpdate);
|
|
24940
|
+
}
|
|
24941
|
+
var TERMINAL_COMPACTION_STATUSES = /* @__PURE__ */ new Set([
|
|
24942
|
+
"completed",
|
|
24943
|
+
"failed",
|
|
24944
|
+
"cancelled"
|
|
24945
|
+
]);
|
|
24946
|
+
function recordCompactionUpdateOutcome(session, update) {
|
|
24947
|
+
if (update.status === "failed") {
|
|
24948
|
+
session.compactionUpdateOutcome = {
|
|
24949
|
+
status: "failed",
|
|
24950
|
+
error: update.error || "The agent reported that compaction failed"
|
|
24951
|
+
};
|
|
24952
|
+
} else if (update.status === "cancelled") {
|
|
24953
|
+
session.compactionUpdateOutcome = { status: "interrupted" };
|
|
24954
|
+
}
|
|
24955
|
+
}
|
|
24956
|
+
function trackAgentCompaction(session, update) {
|
|
24957
|
+
if (session.awaitingFirstPrompt && session.activePromptKind === null) {
|
|
24958
|
+
return;
|
|
24959
|
+
}
|
|
24960
|
+
if (session.finishedAgentCompactionIds.has(update.compactionId)) {
|
|
24961
|
+
return;
|
|
24962
|
+
}
|
|
24963
|
+
if (TERMINAL_COMPACTION_STATUSES.has(update.status)) {
|
|
24964
|
+
session.finishedAgentCompactionIds.add(update.compactionId);
|
|
24965
|
+
session.openAgentCompactionIds.delete(update.compactionId);
|
|
24966
|
+
} else {
|
|
24967
|
+
session.openAgentCompactionIds.add(update.compactionId);
|
|
24968
|
+
}
|
|
24969
|
+
if (session.activePromptKind === null) {
|
|
24970
|
+
openAgentTurn(session);
|
|
24628
24971
|
}
|
|
24629
|
-
emitSessionUpdate(session, parsed.data.update, rawUpdate);
|
|
24630
24972
|
}
|
|
24631
24973
|
function decodeAcpBridgeJsonRpcRequest(raw) {
|
|
24632
24974
|
const envelope = bridgeRequestEnvelopeSchema.safeParse(raw);
|
|
@@ -24751,7 +25093,7 @@ function decodeAdditionalWorkspaceWriteRoots(providerOptions) {
|
|
|
24751
25093
|
function decodeDialectId(providerOptions) {
|
|
24752
25094
|
return acpProviderOptionsSchema.parse(providerOptions ?? {}).acpDialect;
|
|
24753
25095
|
}
|
|
24754
|
-
function maintenanceTarget(providerOptions) {
|
|
25096
|
+
function maintenanceTarget(providerOptions, envVars) {
|
|
24755
25097
|
const launchSpec = decodeLaunchSpec(providerOptions);
|
|
24756
25098
|
const dialect = resolveAcpDialect({
|
|
24757
25099
|
dialectId: decodeDialectId(providerOptions),
|
|
@@ -24761,7 +25103,7 @@ function maintenanceTarget(providerOptions) {
|
|
|
24761
25103
|
maintenance: dialect.maintenance,
|
|
24762
25104
|
command: launchSpec?.command ?? null,
|
|
24763
25105
|
dialectId: dialect.id,
|
|
24764
|
-
env: { ...
|
|
25106
|
+
env: buildProviderCliEnv({ ...launchSpec?.env, ...envVars })
|
|
24765
25107
|
};
|
|
24766
25108
|
}
|
|
24767
25109
|
async function handleRequest2(request) {
|
|
@@ -24794,7 +25136,7 @@ async function handleRequest2(request) {
|
|
|
24794
25136
|
inModelListWorkspace(
|
|
24795
25137
|
buildAcpModelListParams(
|
|
24796
25138
|
decodeLaunchSpec(request.params.providerOptions),
|
|
24797
|
-
modelPicker
|
|
25139
|
+
{ ...modelPicker, envVars: request.params.envVars ?? {} }
|
|
24798
25140
|
),
|
|
24799
25141
|
await resolveModelListWorkspace(request.params.cwd)
|
|
24800
25142
|
),
|
|
@@ -24807,7 +25149,10 @@ async function handleRequest2(request) {
|
|
|
24807
25149
|
sendResult(
|
|
24808
25150
|
request.id,
|
|
24809
25151
|
await getAcpProviderHealth(
|
|
24810
|
-
maintenanceTarget(
|
|
25152
|
+
maintenanceTarget(
|
|
25153
|
+
request.params.providerOptions,
|
|
25154
|
+
request.params.envVars
|
|
25155
|
+
)
|
|
24811
25156
|
)
|
|
24812
25157
|
);
|
|
24813
25158
|
return;
|
|
@@ -24815,7 +25160,10 @@ async function handleRequest2(request) {
|
|
|
24815
25160
|
sendResult(
|
|
24816
25161
|
request.id,
|
|
24817
25162
|
await getAcpProviderUsage(
|
|
24818
|
-
maintenanceTarget(
|
|
25163
|
+
maintenanceTarget(
|
|
25164
|
+
request.params.providerOptions,
|
|
25165
|
+
request.params.envVars
|
|
25166
|
+
)
|
|
24819
25167
|
)
|
|
24820
25168
|
);
|
|
24821
25169
|
return;
|
|
@@ -24823,7 +25171,10 @@ async function handleRequest2(request) {
|
|
|
24823
25171
|
sendResult(
|
|
24824
25172
|
request.id,
|
|
24825
25173
|
await getAcpProviderInstallationStatus(
|
|
24826
|
-
maintenanceTarget(
|
|
25174
|
+
maintenanceTarget(
|
|
25175
|
+
request.params.providerOptions,
|
|
25176
|
+
request.params.envVars
|
|
25177
|
+
)
|
|
24827
25178
|
)
|
|
24828
25179
|
);
|
|
24829
25180
|
return;
|
|
@@ -24831,7 +25182,10 @@ async function handleRequest2(request) {
|
|
|
24831
25182
|
sendResult(
|
|
24832
25183
|
request.id,
|
|
24833
25184
|
await getAcpProviderInstallationRun({
|
|
24834
|
-
...maintenanceTarget(
|
|
25185
|
+
...maintenanceTarget(
|
|
25186
|
+
request.params.providerOptions,
|
|
25187
|
+
request.params.envVars
|
|
25188
|
+
),
|
|
24835
25189
|
action: request.params.action
|
|
24836
25190
|
})
|
|
24837
25191
|
);
|
|
@@ -24914,10 +25268,15 @@ async function handleRequest2(request) {
|
|
|
24914
25268
|
const reconciled = reconcileExecutionSettings(session, params.options);
|
|
24915
25269
|
session = reconciled instanceof Promise ? await reconciled : reconciled;
|
|
24916
25270
|
if (params.options.sessionOptions !== void 0) {
|
|
24917
|
-
|
|
24918
|
-
|
|
24919
|
-
|
|
24920
|
-
|
|
25271
|
+
try {
|
|
25272
|
+
await applySessionOptionSelections(
|
|
25273
|
+
session,
|
|
25274
|
+
params.options.sessionOptions
|
|
25275
|
+
);
|
|
25276
|
+
} catch (error) {
|
|
25277
|
+
scheduleRebuildIfSessionLost(session, error);
|
|
25278
|
+
throw error;
|
|
25279
|
+
}
|
|
24921
25280
|
}
|
|
24922
25281
|
const pending = {
|
|
24923
25282
|
clientRequestId: params.clientRequestId,
|
|
@@ -25106,7 +25465,7 @@ async function probeAcpAgent(request) {
|
|
|
25106
25465
|
command: request.command,
|
|
25107
25466
|
args: [...request.args],
|
|
25108
25467
|
cwd: request.cwd,
|
|
25109
|
-
env:
|
|
25468
|
+
env: buildProviderCliEnv(request.env),
|
|
25110
25469
|
recordThreadId: null,
|
|
25111
25470
|
onNotification: () => {
|
|
25112
25471
|
},
|