@get-bb/plugin-sdk 0.6.54 → 0.6.59
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 +96 -3
- package/bundled-types/bb-plugin-sdk-environment-provider.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk-host.d.ts +11 -2
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp-next.d.ts +71 -11
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +26 -7
- package/bundled-types/bb-plugin-sdk-provider-bridge-testing.d.ts +21 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge.d.ts +33 -1
- package/bundled-types/bb-plugin-sdk-testing.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk.d.ts +102 -5
- package/dist/host.js +150 -5
- package/dist/provider-bridge-acp-next.js +290 -69
- package/dist/provider-bridge-acp.js +6709 -620
- package/dist/provider-bridge-testing.js +74 -32
- package/dist/provider-bridge-worker-entry.mjs +136 -5
- package/dist/provider-bridge.js +194 -8
- package/dist/testing/index.js +1 -0
- package/package.json +1 -2
|
@@ -1745,6 +1745,7 @@ var systemMessageKindValues = [
|
|
|
1745
1745
|
"child-interrupted",
|
|
1746
1746
|
"child-outcome-batch",
|
|
1747
1747
|
"tool-result-delivered",
|
|
1748
|
+
"environment-directory-updated",
|
|
1748
1749
|
"unlabeled"
|
|
1749
1750
|
];
|
|
1750
1751
|
var systemMessageKindSchema = z12.enum(systemMessageKindValues);
|
|
@@ -1778,6 +1779,10 @@ var systemMessageSubjectSchema = z12.discriminatedUnion("kind", [
|
|
|
1778
1779
|
kind: z12.literal("tool-call"),
|
|
1779
1780
|
toolName: z12.string(),
|
|
1780
1781
|
suppress: z12.boolean()
|
|
1782
|
+
}),
|
|
1783
|
+
z12.object({
|
|
1784
|
+
kind: z12.literal("directory"),
|
|
1785
|
+
path: z12.string()
|
|
1781
1786
|
})
|
|
1782
1787
|
]);
|
|
1783
1788
|
|
|
@@ -2021,6 +2026,7 @@ var threadEventScopeDefinitionByType = {
|
|
|
2021
2026
|
},
|
|
2022
2027
|
"turn/plan/updated": { policy: "turn" },
|
|
2023
2028
|
"turn/diff/updated": { policy: "turn" },
|
|
2029
|
+
"turn/mainRun/updated": { policy: "turn" },
|
|
2024
2030
|
"provider/error": {
|
|
2025
2031
|
policy: "thread-or-turn",
|
|
2026
2032
|
rationale: "Provider diagnostics use thread scope for provider setup/session failures; in-turn failures use turn scope."
|
|
@@ -2440,6 +2446,7 @@ var threadEventItemSchema = z16.discriminatedUnion("type", [
|
|
|
2440
2446
|
changes: z16.array(threadEventFileChangeSchema),
|
|
2441
2447
|
status: threadEventItemStatusSchema,
|
|
2442
2448
|
approvalStatus: threadEventItemApprovalStatusSchema,
|
|
2449
|
+
error: z16.string().optional(),
|
|
2443
2450
|
...itemPresentationField,
|
|
2444
2451
|
parentToolCallId: z16.string().optional()
|
|
2445
2452
|
}),
|
|
@@ -2640,6 +2647,12 @@ var unscopedProviderEventSchema = z16.discriminatedUnion("type", [
|
|
|
2640
2647
|
plan: z16.array(threadEventPlanStepSchema),
|
|
2641
2648
|
explanation: z16.string().optional()
|
|
2642
2649
|
}),
|
|
2650
|
+
z16.object({
|
|
2651
|
+
type: z16.literal("turn/mainRun/updated"),
|
|
2652
|
+
threadId: z16.string(),
|
|
2653
|
+
providerThreadId: z16.string(),
|
|
2654
|
+
state: z16.enum(["idle", "running"])
|
|
2655
|
+
}),
|
|
2643
2656
|
z16.object({
|
|
2644
2657
|
type: z16.literal("turn/diff/updated"),
|
|
2645
2658
|
threadId: z16.string(),
|
|
@@ -3038,7 +3051,7 @@ function reasoningEffortsForLevels(levels) {
|
|
|
3038
3051
|
);
|
|
3039
3052
|
}
|
|
3040
3053
|
|
|
3041
|
-
// ../provider-bridge-acp
|
|
3054
|
+
// ../provider-bridge-acp/src/launch-spec.ts
|
|
3042
3055
|
import { z as z20 } from "zod";
|
|
3043
3056
|
var acpNativeSkillRootsSchema = z20.object({
|
|
3044
3057
|
user: z20.array(providerNativeRootInputSchema).default([]),
|
|
@@ -3099,7 +3112,8 @@ var bridgeCapabilitiesSchema = z21.object({
|
|
|
3099
3112
|
PROVIDER_BRIDGE_PROTOCOL_VERSION
|
|
3100
3113
|
]),
|
|
3101
3114
|
steerMode: bridgeSteerModeSchema.default("queue"),
|
|
3102
|
-
skills: z21.object({ configure: z21.boolean().default(false) }).default({ configure: false })
|
|
3115
|
+
skills: z21.object({ configure: z21.boolean().default(false) }).default({ configure: false }),
|
|
3116
|
+
commands: z21.object({ list: z21.boolean().default(false) }).default({ list: false })
|
|
3103
3117
|
}).passthrough();
|
|
3104
3118
|
var initializeParamsSchema = z21.object({
|
|
3105
3119
|
protocolVersion: z21.number().int().positive(),
|
|
@@ -3276,7 +3290,11 @@ var sessionConstructionFields = {
|
|
|
3276
3290
|
disallowedTools: z24.array(z24.string().min(1)).optional(),
|
|
3277
3291
|
instructionMode: instructionModeSchema
|
|
3278
3292
|
};
|
|
3279
|
-
var modelListParamsSchema = z24.object({
|
|
3293
|
+
var modelListParamsSchema = z24.object({
|
|
3294
|
+
cwd: z24.string().min(1).optional(),
|
|
3295
|
+
envVars: z24.record(z24.string(), z24.string()).optional()
|
|
3296
|
+
}).passthrough();
|
|
3297
|
+
var commandListParamsSchema = z24.object({ cwd: z24.string().min(1) }).passthrough();
|
|
3280
3298
|
var threadStartParamsSchema = z24.object({
|
|
3281
3299
|
...sessionConstructionFields,
|
|
3282
3300
|
input: z24.array(promptInputSchema).optional()
|
|
@@ -3587,6 +3605,10 @@ var threadDeltaSchema = z28.discriminatedUnion("kind", [
|
|
|
3587
3605
|
providerTurnId: providerTurnIdSchema.optional(),
|
|
3588
3606
|
parentRef: deltaKeyPartSchema.optional()
|
|
3589
3607
|
}),
|
|
3608
|
+
z28.object({
|
|
3609
|
+
kind: z28.literal("turn.mainRun"),
|
|
3610
|
+
state: z28.enum(["idle", "running"])
|
|
3611
|
+
}),
|
|
3590
3612
|
z28.object({
|
|
3591
3613
|
kind: z28.literal("turn.boundary"),
|
|
3592
3614
|
status: threadEventTurnStatusSchema,
|
|
@@ -11405,8 +11427,157 @@ var {
|
|
|
11405
11427
|
getCancelSignal: getCancelSignal2
|
|
11406
11428
|
} = getIpcExport();
|
|
11407
11429
|
|
|
11430
|
+
// ../process-utils/src/vcs-process-scheduler.ts
|
|
11431
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11432
|
+
import { availableParallelism } from "node:os";
|
|
11433
|
+
var ranks = { interactive: 0, status: 1, background: 2 };
|
|
11434
|
+
function localProcessCapacities(parallelism) {
|
|
11435
|
+
const total = Math.min(6, Math.max(4, parallelism - 2));
|
|
11436
|
+
return [total, total - 1, total - 2];
|
|
11437
|
+
}
|
|
11438
|
+
var capacities = {
|
|
11439
|
+
local: localProcessCapacities(availableParallelism()),
|
|
11440
|
+
network: [4, 3, 2]
|
|
11441
|
+
};
|
|
11442
|
+
var githubCapacity = 2;
|
|
11443
|
+
var agingMs = 15e3;
|
|
11444
|
+
var networkGitSubcommands = /* @__PURE__ */ new Set([
|
|
11445
|
+
"fetch",
|
|
11446
|
+
"pull",
|
|
11447
|
+
"push",
|
|
11448
|
+
"clone",
|
|
11449
|
+
"ls-remote"
|
|
11450
|
+
]);
|
|
11451
|
+
var gitGlobalOptionsWithValue = /* @__PURE__ */ new Set([
|
|
11452
|
+
"-C",
|
|
11453
|
+
"-c",
|
|
11454
|
+
"--git-dir",
|
|
11455
|
+
"--work-tree",
|
|
11456
|
+
"--namespace",
|
|
11457
|
+
"--config-env"
|
|
11458
|
+
]);
|
|
11459
|
+
function isNetworkGitCommand(args) {
|
|
11460
|
+
let index = 0;
|
|
11461
|
+
while (index < args.length && args[index].startsWith("-")) {
|
|
11462
|
+
index += gitGlobalOptionsWithValue.has(args[index]) ? 2 : 1;
|
|
11463
|
+
}
|
|
11464
|
+
const subcommand = args[index];
|
|
11465
|
+
if (subcommand === void 0) return false;
|
|
11466
|
+
if (networkGitSubcommands.has(subcommand)) return true;
|
|
11467
|
+
const action = args.slice(index + 1).find((arg) => !arg.startsWith("-"));
|
|
11468
|
+
return (subcommand === "submodule" || subcommand === "remote") && action === "update";
|
|
11469
|
+
}
|
|
11470
|
+
var VcsProcessScheduler = class {
|
|
11471
|
+
priority = new AsyncLocalStorage();
|
|
11472
|
+
admitted = new AsyncLocalStorage();
|
|
11473
|
+
active = { local: 0, network: 0 };
|
|
11474
|
+
githubActive = 0;
|
|
11475
|
+
queue = [];
|
|
11476
|
+
timer;
|
|
11477
|
+
acquire(command, args, options) {
|
|
11478
|
+
const pool = command === "gh" || isNetworkGitCommand(args) ? "network" : "local";
|
|
11479
|
+
const slots = options.slots ?? 1;
|
|
11480
|
+
if (!Number.isInteger(slots) || slots < 1 || slots > capacities[pool][ranks.background]) {
|
|
11481
|
+
return Promise.reject(new Error("Invalid VCS process slot count"));
|
|
11482
|
+
}
|
|
11483
|
+
if (options.signal?.aborted) {
|
|
11484
|
+
return Promise.reject(this.abortError(options.signal));
|
|
11485
|
+
}
|
|
11486
|
+
return new Promise((grant, reject) => {
|
|
11487
|
+
const waiter = {
|
|
11488
|
+
command,
|
|
11489
|
+
pool,
|
|
11490
|
+
priority: options.priority ?? this.priority.getStore() ?? "status",
|
|
11491
|
+
slots,
|
|
11492
|
+
queuedAt: performance.now(),
|
|
11493
|
+
signal: options.signal,
|
|
11494
|
+
grant,
|
|
11495
|
+
onAbort: () => {
|
|
11496
|
+
const index = this.queue.indexOf(waiter);
|
|
11497
|
+
if (index === -1) return;
|
|
11498
|
+
this.queue.splice(index, 1);
|
|
11499
|
+
reject(this.abortError(options.signal));
|
|
11500
|
+
this.drain();
|
|
11501
|
+
}
|
|
11502
|
+
};
|
|
11503
|
+
this.queue.push(waiter);
|
|
11504
|
+
options.signal?.addEventListener("abort", waiter.onAbort, { once: true });
|
|
11505
|
+
this.drain();
|
|
11506
|
+
});
|
|
11507
|
+
}
|
|
11508
|
+
abortError(signal) {
|
|
11509
|
+
return Object.assign(
|
|
11510
|
+
new Error("The operation was aborted", { cause: signal?.reason }),
|
|
11511
|
+
{
|
|
11512
|
+
name: "AbortError",
|
|
11513
|
+
code: "ABORT_ERR"
|
|
11514
|
+
}
|
|
11515
|
+
);
|
|
11516
|
+
}
|
|
11517
|
+
rank(waiter) {
|
|
11518
|
+
return Math.max(
|
|
11519
|
+
0,
|
|
11520
|
+
ranks[waiter.priority] - Math.floor((performance.now() - waiter.queuedAt) / agingMs)
|
|
11521
|
+
);
|
|
11522
|
+
}
|
|
11523
|
+
drain() {
|
|
11524
|
+
clearTimeout(this.timer);
|
|
11525
|
+
this.queue.sort(
|
|
11526
|
+
(a2, b) => this.rank(a2) - this.rank(b) || a2.queuedAt - b.queuedAt
|
|
11527
|
+
);
|
|
11528
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
11529
|
+
for (let index = 0; index < this.queue.length; ) {
|
|
11530
|
+
const waiter = this.queue[index];
|
|
11531
|
+
if (blocked.has(waiter.pool) || waiter.command === "gh" && this.githubActive + waiter.slots > githubCapacity) {
|
|
11532
|
+
index += 1;
|
|
11533
|
+
continue;
|
|
11534
|
+
}
|
|
11535
|
+
if (this.active[waiter.pool] + waiter.slots > capacities[waiter.pool][this.rank(waiter)]) {
|
|
11536
|
+
blocked.add(waiter.pool);
|
|
11537
|
+
index += 1;
|
|
11538
|
+
continue;
|
|
11539
|
+
}
|
|
11540
|
+
this.queue.splice(index, 1);
|
|
11541
|
+
waiter.signal?.removeEventListener("abort", waiter.onAbort);
|
|
11542
|
+
this.active[waiter.pool] += waiter.slots;
|
|
11543
|
+
if (waiter.command === "gh") this.githubActive += waiter.slots;
|
|
11544
|
+
let released = false;
|
|
11545
|
+
waiter.grant(() => {
|
|
11546
|
+
if (released) return;
|
|
11547
|
+
released = true;
|
|
11548
|
+
this.active[waiter.pool] -= waiter.slots;
|
|
11549
|
+
if (waiter.command === "gh") this.githubActive -= waiter.slots;
|
|
11550
|
+
this.drain();
|
|
11551
|
+
});
|
|
11552
|
+
}
|
|
11553
|
+
if (this.queue.length > 0) {
|
|
11554
|
+
const delay = Math.min(
|
|
11555
|
+
...this.queue.map(
|
|
11556
|
+
(waiter) => agingMs - (performance.now() - waiter.queuedAt) % agingMs
|
|
11557
|
+
)
|
|
11558
|
+
);
|
|
11559
|
+
this.timer = setTimeout(() => this.drain(), delay);
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
};
|
|
11563
|
+
var registry = globalThis;
|
|
11564
|
+
var scheduler3 = registry.__bbVcsProcessScheduler ??= new VcsProcessScheduler();
|
|
11565
|
+
async function runVcsProcess(command, args, operation, options = {}) {
|
|
11566
|
+
if (scheduler3.admitted.getStore()) {
|
|
11567
|
+
options.signal?.throwIfAborted();
|
|
11568
|
+
return operation();
|
|
11569
|
+
}
|
|
11570
|
+
const release = await scheduler3.acquire(command, args, options);
|
|
11571
|
+
try {
|
|
11572
|
+
options.signal?.throwIfAborted();
|
|
11573
|
+
return await scheduler3.admitted.run(true, operation);
|
|
11574
|
+
} finally {
|
|
11575
|
+
release();
|
|
11576
|
+
}
|
|
11577
|
+
}
|
|
11578
|
+
|
|
11408
11579
|
// ../process-utils/src/exec-portable-file.ts
|
|
11409
|
-
import { extname as extname2 } from "node:path";
|
|
11580
|
+
import { basename, extname as extname2 } from "node:path";
|
|
11410
11581
|
|
|
11411
11582
|
// ../../node_modules/.pnpm/which-command@0.1.0/node_modules/which-command/index.js
|
|
11412
11583
|
import fs from "node:fs";
|
|
@@ -11493,6 +11664,21 @@ function whichCommandSync(command, options = {}) {
|
|
|
11493
11664
|
|
|
11494
11665
|
// ../process-utils/src/exec-portable-file.ts
|
|
11495
11666
|
async function execPortableFile(command, args, options) {
|
|
11667
|
+
const executable = basename(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
|
|
11668
|
+
if (executable === "git" || executable === "gh") {
|
|
11669
|
+
return runVcsProcess(
|
|
11670
|
+
executable,
|
|
11671
|
+
args,
|
|
11672
|
+
() => execPortableFileUnbounded(command, args, options),
|
|
11673
|
+
{
|
|
11674
|
+
priority: options.priority,
|
|
11675
|
+
signal: options.signal
|
|
11676
|
+
}
|
|
11677
|
+
);
|
|
11678
|
+
}
|
|
11679
|
+
return execPortableFileUnbounded(command, args, options);
|
|
11680
|
+
}
|
|
11681
|
+
async function execPortableFileUnbounded(command, args, options) {
|
|
11496
11682
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
11497
11683
|
if (process.platform === "win32") {
|
|
11498
11684
|
const envKeys = Object.keys(options.env).sort();
|
|
@@ -11606,11 +11792,6 @@ import { execFile as execFile2 } from "node:child_process";
|
|
|
11606
11792
|
import { promisify as promisify3 } from "node:util";
|
|
11607
11793
|
var execFileAsync = promisify3(execFile2);
|
|
11608
11794
|
|
|
11609
|
-
// ../process-utils/src/performance-diagnostics.ts
|
|
11610
|
-
import { Session } from "node:inspector/promises";
|
|
11611
|
-
var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
|
|
11612
|
-
var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
|
|
11613
|
-
|
|
11614
11795
|
// ../provider-bridge-protocol/src/bridge-kit/provider-maintenance-kit.ts
|
|
11615
11796
|
var import_compare = __toESM(require_compare(), 1);
|
|
11616
11797
|
var import_valid = __toESM(require_valid(), 1);
|
|
@@ -11726,19 +11907,19 @@ function createProviderVisibilityMetadata(args) {
|
|
|
11726
11907
|
import { z as z35 } from "zod";
|
|
11727
11908
|
var ignoredJsonRpcResultSchema = z35.unknown();
|
|
11728
11909
|
|
|
11729
|
-
// ../provider-bridge-acp
|
|
11910
|
+
// ../provider-bridge-acp/src/bridge/bridge.ts
|
|
11730
11911
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
11731
11912
|
import { promises as fs4, readFileSync as readFileSync3 } from "node:fs";
|
|
11732
11913
|
import { createServer } from "node:net";
|
|
11733
|
-
import { dirname as dirname2, isAbsolute as isAbsolute2, basename as
|
|
11914
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, basename as basename4, relative as relative2, resolve as resolve4 } from "node:path";
|
|
11734
11915
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
11735
11916
|
import { isDeepStrictEqual } from "node:util";
|
|
11736
11917
|
import { z as z48 } from "zod";
|
|
11737
11918
|
|
|
11738
|
-
// ../provider-bridge-acp
|
|
11919
|
+
// ../provider-bridge-acp/src/bridge-protocol.ts
|
|
11739
11920
|
import { z as z37 } from "zod";
|
|
11740
11921
|
|
|
11741
|
-
// ../provider-bridge-acp
|
|
11922
|
+
// ../provider-bridge-acp/src/wire.ts
|
|
11742
11923
|
import { z as z36 } from "zod";
|
|
11743
11924
|
var acpTextContentBlockSchema = z36.object({
|
|
11744
11925
|
type: z36.literal("text"),
|
|
@@ -12034,7 +12215,7 @@ var acpWriteTextFileParamsSchema = z36.object({
|
|
|
12034
12215
|
content: z36.string()
|
|
12035
12216
|
}).passthrough();
|
|
12036
12217
|
|
|
12037
|
-
// ../provider-bridge-acp
|
|
12218
|
+
// ../provider-bridge-acp/src/bridge-protocol.ts
|
|
12038
12219
|
var ACP_DEFAULT_MODEL_ID = "acp-default";
|
|
12039
12220
|
var acpModelListParamsSchema = modelListParamsSchema.extend({
|
|
12040
12221
|
providerOptions: z37.record(z37.string(), z37.unknown()).optional()
|
|
@@ -12151,11 +12332,11 @@ var acpWarningNotificationParamsSchema = z37.object({
|
|
|
12151
12332
|
details: z37.string().optional()
|
|
12152
12333
|
}).passthrough();
|
|
12153
12334
|
|
|
12154
|
-
// ../provider-bridge-acp
|
|
12155
|
-
import { basename } from "node:path";
|
|
12335
|
+
// ../provider-bridge-acp/src/dialect.ts
|
|
12336
|
+
import { basename as basename2 } from "node:path";
|
|
12156
12337
|
import { z as z42 } from "zod";
|
|
12157
12338
|
|
|
12158
|
-
// ../provider-bridge-acp
|
|
12339
|
+
// ../provider-bridge-acp/src/bridge/provider-maintenance.ts
|
|
12159
12340
|
import { execFile as execFile4 } from "node:child_process";
|
|
12160
12341
|
import { existsSync } from "node:fs";
|
|
12161
12342
|
import fs3 from "node:fs/promises";
|
|
@@ -12165,7 +12346,7 @@ import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
|
12165
12346
|
import { promisify as promisify5 } from "node:util";
|
|
12166
12347
|
import { z as z39 } from "zod";
|
|
12167
12348
|
|
|
12168
|
-
// ../provider-bridge-acp
|
|
12349
|
+
// ../provider-bridge-acp/src/bridge/opencode-usage.ts
|
|
12169
12350
|
import fs2 from "node:fs/promises";
|
|
12170
12351
|
import os from "node:os";
|
|
12171
12352
|
import path9 from "node:path";
|
|
@@ -12399,7 +12580,7 @@ async function readOpenCodeGoUsage(env) {
|
|
|
12399
12580
|
}
|
|
12400
12581
|
}
|
|
12401
12582
|
|
|
12402
|
-
// ../provider-bridge-acp
|
|
12583
|
+
// ../provider-bridge-acp/src/bridge/provider-maintenance.ts
|
|
12403
12584
|
var execFileAsync3 = promisify5(execFile4);
|
|
12404
12585
|
var USAGE_FETCH_TIMEOUT_MS = 15e3;
|
|
12405
12586
|
var CURSOR_DASHBOARD_URL = "https://api2.cursor.sh/aiserver.v1.DashboardService";
|
|
@@ -12722,7 +12903,7 @@ async function readCursorUsage() {
|
|
|
12722
12903
|
}
|
|
12723
12904
|
}
|
|
12724
12905
|
|
|
12725
|
-
// ../provider-bridge-acp
|
|
12906
|
+
// ../provider-bridge-acp/src/presentation.ts
|
|
12726
12907
|
function stripCodeTicks(text) {
|
|
12727
12908
|
const trimmed = text.trim();
|
|
12728
12909
|
return trimmed.length >= 2 && trimmed.startsWith("`") && trimmed.endsWith("`") ? trimmed.slice(1, -1) : trimmed;
|
|
@@ -12818,10 +12999,10 @@ function toolKindPresentation(args) {
|
|
|
12818
12999
|
);
|
|
12819
13000
|
}
|
|
12820
13001
|
|
|
12821
|
-
// ../provider-bridge-acp
|
|
13002
|
+
// ../provider-bridge-acp/src/tool-classification.ts
|
|
12822
13003
|
import { z as z41 } from "zod";
|
|
12823
13004
|
|
|
12824
|
-
// ../provider-bridge-acp
|
|
13005
|
+
// ../provider-bridge-acp/src/tool-call-operation.ts
|
|
12825
13006
|
import path11 from "node:path";
|
|
12826
13007
|
import { z as z40 } from "zod";
|
|
12827
13008
|
var acpRawInputCommandSchema = z40.object({ command: z40.string() }).passthrough();
|
|
@@ -12915,7 +13096,7 @@ function resolveAcpFileChangeWriteScope(paths) {
|
|
|
12915
13096
|
return candidate;
|
|
12916
13097
|
}
|
|
12917
13098
|
|
|
12918
|
-
// ../provider-bridge-acp
|
|
13099
|
+
// ../provider-bridge-acp/src/tool-classification.ts
|
|
12919
13100
|
var BB_TOOL_SERVER = "bb";
|
|
12920
13101
|
function isInjectedToolCandidate(event) {
|
|
12921
13102
|
if (event.kind !== void 0 && event.kind !== "other") {
|
|
@@ -13285,7 +13466,7 @@ function classifyAcpToolCall2(event, injected, options) {
|
|
|
13285
13466
|
}
|
|
13286
13467
|
}
|
|
13287
13468
|
|
|
13288
|
-
// ../provider-bridge-acp
|
|
13469
|
+
// ../provider-bridge-acp/src/dialect.ts
|
|
13289
13470
|
var GENERIC_ACP_DIALECT = { id: "acp" };
|
|
13290
13471
|
var grokToolMetaSchema = z42.object({
|
|
13291
13472
|
"x.ai/tool": z42.object({
|
|
@@ -13586,11 +13767,11 @@ function resolveAcpDialect(launch) {
|
|
|
13586
13767
|
if (launch.dialectId !== void 0) {
|
|
13587
13768
|
return DIALECTS_BY_ID.get(launch.dialectId) ?? GENERIC_ACP_DIALECT;
|
|
13588
13769
|
}
|
|
13589
|
-
const byCommand = DIALECT_IDS_BY_COMMAND[
|
|
13770
|
+
const byCommand = DIALECT_IDS_BY_COMMAND[basename2(launch.command)];
|
|
13590
13771
|
return byCommand === void 0 ? GENERIC_ACP_DIALECT : DIALECTS_BY_ID.get(byCommand) ?? GENERIC_ACP_DIALECT;
|
|
13591
13772
|
}
|
|
13592
13773
|
|
|
13593
|
-
// ../provider-bridge-acp
|
|
13774
|
+
// ../provider-bridge-acp/src/session/decode.ts
|
|
13594
13775
|
var ACP_LEGACY_MODE_CONFIG_ID = "_bb/legacy-mode";
|
|
13595
13776
|
var ACP_LEGACY_MODEL_CONFIG_ID = "_bb/legacy-model";
|
|
13596
13777
|
function isJsonObject(value) {
|
|
@@ -13923,7 +14104,7 @@ function decodeWorkError(value) {
|
|
|
13923
14104
|
return "data" in value ? { code, message, data: value["data"] } : { code, message };
|
|
13924
14105
|
}
|
|
13925
14106
|
|
|
13926
|
-
// ../provider-bridge-acp
|
|
14107
|
+
// ../provider-bridge-acp/src/visibility.ts
|
|
13927
14108
|
var NORMALIZED_ACP_METHODS = /* @__PURE__ */ new Set([
|
|
13928
14109
|
"thread/identity",
|
|
13929
14110
|
"error",
|
|
@@ -13988,7 +14169,7 @@ var acpVisibilityMetadata = createProviderVisibilityMetadata({
|
|
|
13988
14169
|
describeParsedRawEvent: describeParsedAcpRawEvent
|
|
13989
14170
|
});
|
|
13990
14171
|
|
|
13991
|
-
// ../provider-bridge-acp
|
|
14172
|
+
// ../provider-bridge-acp/src/delta-translation.ts
|
|
13992
14173
|
var ASSISTANT_STREAM_KEY = "assistant";
|
|
13993
14174
|
var THOUGHT_STREAM_KEY = "thought";
|
|
13994
14175
|
var ACP_PLAN_STEP_STATUS_BY_ENTRY_STATUS = {
|
|
@@ -14815,7 +14996,7 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
14815
14996
|
};
|
|
14816
14997
|
}
|
|
14817
14998
|
|
|
14818
|
-
// ../provider-bridge-acp
|
|
14999
|
+
// ../provider-bridge-acp/src/auth-guidance.ts
|
|
14819
15000
|
var SHELL_SAFE_WORD = /^[A-Za-z0-9_@%+=:,./-]+$/u;
|
|
14820
15001
|
var WINDOWS_SAFE_WORD = /^[A-Za-z0-9_@%+=:,./\\-]+$/u;
|
|
14821
15002
|
var MAX_LISTED_METHODS = 4;
|
|
@@ -14874,7 +15055,7 @@ function describeAcpSignIn(args) {
|
|
|
14874
15055
|
return `The agent offers these ways to sign in: ${listed}${more}. Sign in with the agent's own command on the machine that hosts the thread, then try again.`;
|
|
14875
15056
|
}
|
|
14876
15057
|
|
|
14877
|
-
// ../provider-bridge-acp
|
|
15058
|
+
// ../provider-bridge-acp/src/elicitation.ts
|
|
14878
15059
|
var CONFIRM_QUESTION_ID = "confirm";
|
|
14879
15060
|
var CONFIRM_ACCEPT_VALUE = "accept";
|
|
14880
15061
|
var CONFIRM_DECLINE_VALUE = "decline";
|
|
@@ -15118,7 +15299,7 @@ function planAcpElicitation(params) {
|
|
|
15118
15299
|
};
|
|
15119
15300
|
}
|
|
15120
15301
|
|
|
15121
|
-
// ../provider-bridge-acp
|
|
15302
|
+
// ../provider-bridge-acp/src/interactions.ts
|
|
15122
15303
|
function classifyAcpPermission(toolCall, options) {
|
|
15123
15304
|
const own = classifyAcpToolCall(toolCall, options);
|
|
15124
15305
|
if (own.kind !== "generic" || !toolCall.startedToolCall) {
|
|
@@ -15235,10 +15416,10 @@ function resolveAcpPermissionDecision(args) {
|
|
|
15235
15416
|
return { decision: args.resolution.decision };
|
|
15236
15417
|
}
|
|
15237
15418
|
|
|
15238
|
-
// ../provider-bridge-acp
|
|
15419
|
+
// ../provider-bridge-acp/src/session-params.ts
|
|
15239
15420
|
import path12 from "node:path";
|
|
15240
15421
|
|
|
15241
|
-
// ../provider-bridge-acp
|
|
15422
|
+
// ../provider-bridge-acp/src/bridge/model-catalog.ts
|
|
15242
15423
|
var ACP_NATIVE_REASONING_EFFORTS = [
|
|
15243
15424
|
{
|
|
15244
15425
|
reasoningEffort: "medium",
|
|
@@ -15572,7 +15753,7 @@ function splitPrimaryModels(catalogModels, primaryModels) {
|
|
|
15572
15753
|
};
|
|
15573
15754
|
}
|
|
15574
15755
|
|
|
15575
|
-
// ../provider-bridge-acp
|
|
15756
|
+
// ../provider-bridge-acp/src/cursor-model-selection.ts
|
|
15576
15757
|
var CURSOR_LEGACY_FAMILY_SELECTIONS = {
|
|
15577
15758
|
"claude-4-sonnet": { modelId: "claude-sonnet-4" },
|
|
15578
15759
|
"claude-4.5-opus": { modelId: "claude-opus-4-5" },
|
|
@@ -15675,7 +15856,7 @@ function buildCursorParameterizedModelCatalog(models) {
|
|
|
15675
15856
|
return [...normalized.values()].map((entry) => entry.model);
|
|
15676
15857
|
}
|
|
15677
15858
|
|
|
15678
|
-
// ../provider-bridge-acp
|
|
15859
|
+
// ../provider-bridge-acp/src/session-params.ts
|
|
15679
15860
|
function sanitizeAcpSkillDescription(description) {
|
|
15680
15861
|
const sanitized = description.replace(/[\r\n]+/gu, " ").replace(/\s+/gu, " ").replace(/[<>]/gu, "").trim();
|
|
15681
15862
|
return sanitized.length > 0 ? sanitized : "(description unavailable)";
|
|
@@ -19512,10 +19693,10 @@ var legacyClientNotificationMethods = /* @__PURE__ */ new Set([
|
|
|
19512
19693
|
CLIENT_METHODS.elicitation_complete
|
|
19513
19694
|
]);
|
|
19514
19695
|
|
|
19515
|
-
// ../provider-bridge-acp
|
|
19696
|
+
// ../provider-bridge-acp/src/bridge/agent-connection.ts
|
|
19516
19697
|
import { createInterface as createInterface2 } from "node:readline";
|
|
19517
19698
|
|
|
19518
|
-
// ../provider-bridge-acp
|
|
19699
|
+
// ../provider-bridge-acp/src/client/message-stream.ts
|
|
19519
19700
|
import { createInterface } from "node:readline";
|
|
19520
19701
|
var SESSION_UPDATE_METHOD = "session/update";
|
|
19521
19702
|
function readId(message) {
|
|
@@ -19612,7 +19793,7 @@ function createAcpMessageStream(options) {
|
|
|
19612
19793
|
return { readable: readable2, writable: writable2 };
|
|
19613
19794
|
}
|
|
19614
19795
|
|
|
19615
|
-
// ../provider-bridge-acp
|
|
19796
|
+
// ../provider-bridge-acp/src/client/acp-client.ts
|
|
19616
19797
|
var AcpRequestTimeoutError = class extends Error {
|
|
19617
19798
|
method;
|
|
19618
19799
|
timeoutMs;
|
|
@@ -19716,7 +19897,7 @@ function connectAcpClient(options) {
|
|
|
19716
19897
|
};
|
|
19717
19898
|
}
|
|
19718
19899
|
|
|
19719
|
-
// ../provider-bridge-acp
|
|
19900
|
+
// ../provider-bridge-acp/src/client/capabilities.ts
|
|
19720
19901
|
var ACP_CLIENT_PROTOCOL_VERSION = 1;
|
|
19721
19902
|
var AcpUnsupportedProtocolVersionError = class extends Error {
|
|
19722
19903
|
agentProtocolVersion;
|
|
@@ -19828,7 +20009,7 @@ function readAcpAgentCapabilities(initializeResult) {
|
|
|
19828
20009
|
};
|
|
19829
20010
|
}
|
|
19830
20011
|
|
|
19831
|
-
// ../provider-bridge-acp
|
|
20012
|
+
// ../provider-bridge-acp/src/bridge/agent-connection.ts
|
|
19832
20013
|
import { z as z46 } from "zod";
|
|
19833
20014
|
var STDERR_TAIL_MAX_CHUNKS = 40;
|
|
19834
20015
|
var ACP_CORE_CLIENT_REQUEST_METHODS = [
|
|
@@ -20112,7 +20293,7 @@ async function requestAcpInitialize(connection, {
|
|
|
20112
20293
|
return readAcpAgentCapabilities(result);
|
|
20113
20294
|
}
|
|
20114
20295
|
|
|
20115
|
-
// ../provider-bridge-acp
|
|
20296
|
+
// ../provider-bridge-acp/src/session/session-model.ts
|
|
20116
20297
|
var DEFAULT_PLAN_ID = "default";
|
|
20117
20298
|
var TERMINAL_TOOL_CALL_STATUSES = /* @__PURE__ */ new Set([
|
|
20118
20299
|
"completed",
|
|
@@ -20697,7 +20878,7 @@ function createAcpSessionModel(options) {
|
|
|
20697
20878
|
};
|
|
20698
20879
|
}
|
|
20699
20880
|
|
|
20700
|
-
// ../provider-bridge-acp
|
|
20881
|
+
// ../provider-bridge-acp/src/session/thread-state.ts
|
|
20701
20882
|
var MAX_COMMANDS = 500;
|
|
20702
20883
|
var MAX_OPTIONS = 64;
|
|
20703
20884
|
var MAX_OPTION_VALUES = 1e3;
|
|
@@ -20756,14 +20937,14 @@ function toThreadSessionOptionsState(options) {
|
|
|
20756
20937
|
return { options: sessionOptions.slice(0, MAX_OPTIONS) };
|
|
20757
20938
|
}
|
|
20758
20939
|
|
|
20759
|
-
// ../provider-bridge-acp
|
|
20940
|
+
// ../provider-bridge-acp/src/bridge/cursor-mcp-approval.ts
|
|
20760
20941
|
import { execFile as execFile5 } from "node:child_process";
|
|
20761
20942
|
import { createHash, randomBytes } from "node:crypto";
|
|
20762
20943
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
20763
20944
|
import { homedir } from "node:os";
|
|
20764
|
-
import { basename as
|
|
20945
|
+
import { basename as basename3, dirname, join as join2, resolve as resolve3 } from "node:path";
|
|
20765
20946
|
|
|
20766
|
-
// ../provider-bridge-acp
|
|
20947
|
+
// ../provider-bridge-acp/src/bridge/tool-proxy-mcp.ts
|
|
20767
20948
|
import { createConnection } from "node:net";
|
|
20768
20949
|
import { createInterface as createInterface3 } from "node:readline";
|
|
20769
20950
|
import { z as z47 } from "zod";
|
|
@@ -21062,7 +21243,7 @@ function runAcpDynamicToolMcpServer() {
|
|
|
21062
21243
|
});
|
|
21063
21244
|
}
|
|
21064
21245
|
|
|
21065
|
-
// ../provider-bridge-acp
|
|
21246
|
+
// ../provider-bridge-acp/src/bridge/cursor-mcp-approval.ts
|
|
21066
21247
|
var CURSOR_MCP_APPROVAL_FILE = "mcp-approvals.json";
|
|
21067
21248
|
var CURSOR_APPROVAL_LOCK_STALE_MS = 3e4;
|
|
21068
21249
|
var CURSOR_APPROVAL_LOCK_TIMEOUT_MS = 5e3;
|
|
@@ -21070,7 +21251,7 @@ function errorCode(error) {
|
|
|
21070
21251
|
return error instanceof Error && "code" in error ? error.code : void 0;
|
|
21071
21252
|
}
|
|
21072
21253
|
function cursorAgentCommand(command) {
|
|
21073
|
-
return
|
|
21254
|
+
return basename3(command).toLowerCase().replace(/\.(?:bat|cmd|exe)$/u, "") === "cursor-agent";
|
|
21074
21255
|
}
|
|
21075
21256
|
function cursorProjectSlug(projectRoot) {
|
|
21076
21257
|
return projectRoot.replace(/[^a-zA-Z0-9]/gu, "-").replace(/-+/gu, "-").replace(/^-+|-+$/gu, "");
|
|
@@ -21225,8 +21406,24 @@ async function revokeCursorSessionMcpServer(approval) {
|
|
|
21225
21406
|
);
|
|
21226
21407
|
}
|
|
21227
21408
|
|
|
21228
|
-
// ../provider-bridge-acp
|
|
21409
|
+
// ../provider-bridge-acp/src/bridge/bridge.ts
|
|
21229
21410
|
var sessionsByBbThreadId = /* @__PURE__ */ new Map();
|
|
21411
|
+
var agentConnections = /* @__PURE__ */ new Set();
|
|
21412
|
+
var shuttingDown = false;
|
|
21413
|
+
function createBridgeAgentConnection(options) {
|
|
21414
|
+
if (shuttingDown) {
|
|
21415
|
+
throw new Error("ACP bridge is shutting down");
|
|
21416
|
+
}
|
|
21417
|
+
const connection = createAcpAgentConnection({
|
|
21418
|
+
...options,
|
|
21419
|
+
onExit: (info) => {
|
|
21420
|
+
agentConnections.delete(connection);
|
|
21421
|
+
options.onExit(info);
|
|
21422
|
+
}
|
|
21423
|
+
});
|
|
21424
|
+
agentConnections.add(connection);
|
|
21425
|
+
return connection;
|
|
21426
|
+
}
|
|
21230
21427
|
var bbThreadIdByProviderThreadId = /* @__PURE__ */ new Map();
|
|
21231
21428
|
var pendingRuntimeRequests = /* @__PURE__ */ new Map();
|
|
21232
21429
|
var runtimeRequestIdCounter = 0;
|
|
@@ -21758,7 +21955,7 @@ async function loadDeclaredSessionOptions(agent, parameterizedModelPicker, diale
|
|
|
21758
21955
|
...withoutBridgeRuntimeEnv(process.env),
|
|
21759
21956
|
...agent.envVars ?? {}
|
|
21760
21957
|
};
|
|
21761
|
-
const connection =
|
|
21958
|
+
const connection = createBridgeAgentConnection({
|
|
21762
21959
|
command: agent.command,
|
|
21763
21960
|
args: agent.args,
|
|
21764
21961
|
cwd: agent.cwd ?? process.cwd(),
|
|
@@ -21853,7 +22050,7 @@ async function loadSessionDiscoveredModels(agent, reasoningProbePriorityModelIds
|
|
|
21853
22050
|
...withoutBridgeRuntimeEnv(process.env),
|
|
21854
22051
|
...agent.envVars ?? {}
|
|
21855
22052
|
};
|
|
21856
|
-
const connection =
|
|
22053
|
+
const connection = createBridgeAgentConnection({
|
|
21857
22054
|
command: agent.command,
|
|
21858
22055
|
args: agent.args,
|
|
21859
22056
|
cwd: agent.cwd ?? process.cwd(),
|
|
@@ -22353,7 +22550,7 @@ ${instructions}
|
|
|
22353
22550
|
blocks.push({
|
|
22354
22551
|
type: "resource_link",
|
|
22355
22552
|
uri: `file://${item.path}`,
|
|
22356
|
-
name: item.name ??
|
|
22553
|
+
name: item.name ?? basename4(item.path)
|
|
22357
22554
|
});
|
|
22358
22555
|
break;
|
|
22359
22556
|
}
|
|
@@ -22664,7 +22861,7 @@ async function startAgentSession(request) {
|
|
|
22664
22861
|
...params.envVars,
|
|
22665
22862
|
...dialect.id === "opencode" ? { OPENCODE_CLIENT: "acp", OPENCODE_ENABLE_QUESTION_TOOL: "false" } : {}
|
|
22666
22863
|
};
|
|
22667
|
-
const connection =
|
|
22864
|
+
const connection = createBridgeAgentConnection({
|
|
22668
22865
|
command: params.agent.command,
|
|
22669
22866
|
args: launch.args,
|
|
22670
22867
|
cwd: params.cwd,
|
|
@@ -23781,7 +23978,8 @@ async function handleRequest2(request) {
|
|
|
23781
23978
|
approvalEnforcedBy: "runtime",
|
|
23782
23979
|
grammarVersions: [THREAD_DELTA_GRAMMAR_V3, THREAD_DELTA_GRAMMAR_V3],
|
|
23783
23980
|
steerMode: "queue",
|
|
23784
|
-
skills: { configure: true }
|
|
23981
|
+
skills: { configure: true },
|
|
23982
|
+
commands: { list: false }
|
|
23785
23983
|
}
|
|
23786
23984
|
};
|
|
23787
23985
|
sendResult(request.id, result);
|
|
@@ -24037,11 +24235,21 @@ function handleParsedMessage(parsed) {
|
|
|
24037
24235
|
}
|
|
24038
24236
|
var handleLine = createBridgeLineHandler({ handleParsedMessage });
|
|
24039
24237
|
async function stopAllSessions() {
|
|
24040
|
-
await Promise.
|
|
24041
|
-
Array.from(
|
|
24042
|
-
(
|
|
24043
|
-
|
|
24044
|
-
|
|
24238
|
+
const results = await Promise.allSettled([
|
|
24239
|
+
...Array.from(
|
|
24240
|
+
sessionsByBbThreadId.values(),
|
|
24241
|
+
(session) => releaseSession(session)
|
|
24242
|
+
),
|
|
24243
|
+
...Array.from(agentConnections, (connection) => connection.kill())
|
|
24244
|
+
]);
|
|
24245
|
+
for (const result of results) {
|
|
24246
|
+
if (result.status === "rejected") {
|
|
24247
|
+
process.stderr.write(
|
|
24248
|
+
`acp bridge: shutdown cleanup failed: ${String(result.reason)}
|
|
24249
|
+
`
|
|
24250
|
+
);
|
|
24251
|
+
}
|
|
24252
|
+
}
|
|
24045
24253
|
const dynamicToolBridge = dynamicToolBridgePromise ? await dynamicToolBridgePromise.catch(() => null) : null;
|
|
24046
24254
|
await new Promise((resolveClose) => {
|
|
24047
24255
|
if (!dynamicToolBridge) {
|
|
@@ -24051,19 +24259,25 @@ async function stopAllSessions() {
|
|
|
24051
24259
|
dynamicToolBridge.server.close(() => resolveClose());
|
|
24052
24260
|
});
|
|
24053
24261
|
}
|
|
24262
|
+
function shutdownBridge() {
|
|
24263
|
+
if (shuttingDown) return;
|
|
24264
|
+
shuttingDown = true;
|
|
24265
|
+
void stopAllSessions().catch((error) => {
|
|
24266
|
+
process.stderr.write(`acp bridge: shutdown failed: ${String(error)}
|
|
24267
|
+
`);
|
|
24268
|
+
}).finally(() => process.exit(0));
|
|
24269
|
+
}
|
|
24054
24270
|
if (process.argv.includes("--mcp-stdio")) {
|
|
24055
24271
|
runAcpDynamicToolMcpServer();
|
|
24056
24272
|
}
|
|
24057
24273
|
var experimental_providerBridge = experimental_defineProviderBridge({
|
|
24058
24274
|
handleLine,
|
|
24059
|
-
onClose:
|
|
24060
|
-
|
|
24061
|
-
|
|
24062
|
-
});
|
|
24063
|
-
}
|
|
24275
|
+
onClose: shutdownBridge,
|
|
24276
|
+
onSigterm: shutdownBridge,
|
|
24277
|
+
onSigint: shutdownBridge
|
|
24064
24278
|
});
|
|
24065
24279
|
|
|
24066
|
-
// ../provider-bridge-acp
|
|
24280
|
+
// ../provider-bridge-acp/src/probe.ts
|
|
24067
24281
|
import { z as z49 } from "zod";
|
|
24068
24282
|
var PROBE_TIMEOUT_MS = 1e4;
|
|
24069
24283
|
function describe(error) {
|
|
@@ -24126,10 +24340,17 @@ var acpAgentProbeSchema = z49.union([
|
|
|
24126
24340
|
z49.object({ reachable: z49.literal(true), fork: z49.boolean() }),
|
|
24127
24341
|
z49.object({ reachable: z49.literal(false), reason: z49.string() })
|
|
24128
24342
|
]);
|
|
24343
|
+
|
|
24344
|
+
// src/provider-bridge-acp-next.ts
|
|
24345
|
+
var experimental_acpAgentProbeSchema = acpAgentProbeSchema;
|
|
24346
|
+
var experimental_acpLaunchSpecSchema = acpLaunchSpecSchema;
|
|
24347
|
+
var experimental_acpProviderBridge = experimental_providerBridge;
|
|
24348
|
+
var experimental_probeAcpAgent = probeAcpAgent;
|
|
24349
|
+
var experimental_registerAcpDialect = registerAcpDialect;
|
|
24129
24350
|
export {
|
|
24130
|
-
|
|
24131
|
-
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24351
|
+
experimental_acpAgentProbeSchema,
|
|
24352
|
+
experimental_acpLaunchSpecSchema,
|
|
24353
|
+
experimental_acpProviderBridge,
|
|
24354
|
+
experimental_probeAcpAgent,
|
|
24355
|
+
experimental_registerAcpDialect
|
|
24135
24356
|
};
|