@get-bb/plugin-sdk 0.6.54 → 0.6.60

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.
@@ -809,6 +809,7 @@ var systemMessageKindValues = [
809
809
  "child-interrupted",
810
810
  "child-outcome-batch",
811
811
  "tool-result-delivered",
812
+ "environment-directory-updated",
812
813
  "unlabeled"
813
814
  ];
814
815
  var systemMessageKindSchema = z10.enum(systemMessageKindValues);
@@ -842,6 +843,10 @@ var systemMessageSubjectSchema = z10.discriminatedUnion("kind", [
842
843
  kind: z10.literal("tool-call"),
843
844
  toolName: z10.string(),
844
845
  suppress: z10.boolean()
846
+ }),
847
+ z10.object({
848
+ kind: z10.literal("directory"),
849
+ path: z10.string()
845
850
  })
846
851
  ]);
847
852
 
@@ -1085,6 +1090,7 @@ var threadEventScopeDefinitionByType = {
1085
1090
  },
1086
1091
  "turn/plan/updated": { policy: "turn" },
1087
1092
  "turn/diff/updated": { policy: "turn" },
1093
+ "turn/mainRun/updated": { policy: "turn" },
1088
1094
  "provider/error": {
1089
1095
  policy: "thread-or-turn",
1090
1096
  rationale: "Provider diagnostics use thread scope for provider setup/session failures; in-turn failures use turn scope."
@@ -1513,6 +1519,7 @@ var threadEventItemSchema = z14.discriminatedUnion("type", [
1513
1519
  changes: z14.array(threadEventFileChangeSchema),
1514
1520
  status: threadEventItemStatusSchema,
1515
1521
  approvalStatus: threadEventItemApprovalStatusSchema,
1522
+ error: z14.string().optional(),
1516
1523
  ...itemPresentationField,
1517
1524
  parentToolCallId: z14.string().optional()
1518
1525
  }),
@@ -1713,6 +1720,12 @@ var unscopedProviderEventSchema = z14.discriminatedUnion("type", [
1713
1720
  plan: z14.array(threadEventPlanStepSchema),
1714
1721
  explanation: z14.string().optional()
1715
1722
  }),
1723
+ z14.object({
1724
+ type: z14.literal("turn/mainRun/updated"),
1725
+ threadId: z14.string(),
1726
+ providerThreadId: z14.string(),
1727
+ state: z14.enum(["idle", "running"])
1728
+ }),
1716
1729
  z14.object({
1717
1730
  type: z14.literal("turn/diff/updated"),
1718
1731
  threadId: z14.string(),
@@ -2257,6 +2270,10 @@ var threadDeltaSchema = z18.discriminatedUnion("kind", [
2257
2270
  providerTurnId: providerTurnIdSchema.optional(),
2258
2271
  parentRef: deltaKeyPartSchema.optional()
2259
2272
  }),
2273
+ z18.object({
2274
+ kind: z18.literal("turn.mainRun"),
2275
+ state: z18.enum(["idle", "running"])
2276
+ }),
2260
2277
  z18.object({
2261
2278
  kind: z18.literal("turn.boundary"),
2262
2279
  status: threadEventTurnStatusSchema,
@@ -3192,6 +3209,9 @@ function createDeltaAssembler(options) {
3192
3209
  );
3193
3210
  }
3194
3211
  }
3212
+ function fileChangeErrorField(close) {
3213
+ return close.status === "failed" && close.resultText?.trim() ? { error: close.resultText } : {};
3214
+ }
3195
3215
  function completeStartedItem(started, close, parentToolCallId) {
3196
3216
  const parent = parentToolCallId ?? started.parentToolCallId;
3197
3217
  switch (started.type) {
@@ -3216,7 +3236,8 @@ function createDeltaAssembler(options) {
3216
3236
  id: started.id,
3217
3237
  changes: started.changes,
3218
3238
  status: close.status,
3219
- approvalStatus: started.approvalStatus
3239
+ approvalStatus: started.approvalStatus,
3240
+ ...fileChangeErrorField(close)
3220
3241
  },
3221
3242
  parent
3222
3243
  );
@@ -3304,7 +3325,8 @@ function createDeltaAssembler(options) {
3304
3325
  id: bbItemId,
3305
3326
  changes: buildFileChanges(shape),
3306
3327
  status: close.status,
3307
- approvalStatus: close.approvalStatus ?? null
3328
+ approvalStatus: close.approvalStatus ?? null,
3329
+ ...fileChangeErrorField(close)
3308
3330
  },
3309
3331
  parentToolCallId
3310
3332
  );
@@ -4101,6 +4123,19 @@ function createDeltaAssembler(options) {
4101
4123
  });
4102
4124
  return;
4103
4125
  }
4126
+ case "turn.mainRun": {
4127
+ if (state.currentTurnId === void 0) {
4128
+ return;
4129
+ }
4130
+ events.push({
4131
+ type: "turn/mainRun/updated",
4132
+ threadId: UNSTAMPED_THREAD_ID,
4133
+ providerThreadId: "",
4134
+ scope: turnScope(state.currentTurnId),
4135
+ state: delta.state
4136
+ });
4137
+ return;
4138
+ }
4104
4139
  case "turn.diff": {
4105
4140
  const turnId = delta.providerTurnId !== void 0 ? resolveVouchedTurnId(state, delta.providerTurnId) : state.currentTurnId;
4106
4141
  if (turnId === void 0) {
@@ -4441,7 +4476,8 @@ var bridgeCapabilitiesSchema = z22.object({
4441
4476
  PROVIDER_BRIDGE_PROTOCOL_VERSION
4442
4477
  ]),
4443
4478
  steerMode: bridgeSteerModeSchema.default("queue"),
4444
- skills: z22.object({ configure: z22.boolean().default(false) }).default({ configure: false })
4479
+ skills: z22.object({ configure: z22.boolean().default(false) }).default({ configure: false }),
4480
+ commands: z22.object({ list: z22.boolean().default(false) }).default({ list: false })
4445
4481
  }).passthrough();
4446
4482
  var initializeParamsSchema = z22.object({
4447
4483
  protocolVersion: z22.number().int().positive(),
@@ -4613,6 +4649,7 @@ import { z as z25 } from "zod";
4613
4649
  var BRIDGE_REQUEST_METHODS = {
4614
4650
  initialize: "initialize",
4615
4651
  modelList: "model/list",
4652
+ commandList: "commands/list",
4616
4653
  providerHealth: "provider/health",
4617
4654
  providerUsage: "provider/usage",
4618
4655
  providerInstallationStatus: "provider/installation/status",
@@ -4638,7 +4675,11 @@ var sessionConstructionFields = {
4638
4675
  disallowedTools: z25.array(z25.string().min(1)).optional(),
4639
4676
  instructionMode: instructionModeSchema
4640
4677
  };
4641
- var modelListParamsSchema = z25.object({ cwd: z25.string().min(1).optional() }).passthrough();
4678
+ var modelListParamsSchema = z25.object({
4679
+ cwd: z25.string().min(1).optional(),
4680
+ envVars: z25.record(z25.string(), z25.string()).optional()
4681
+ }).passthrough();
4682
+ var commandListParamsSchema = z25.object({ cwd: z25.string().min(1) }).passthrough();
4642
4683
  var threadStartParamsSchema = z25.object({
4643
4684
  ...sessionConstructionFields,
4644
4685
  input: z25.array(promptInputSchema).optional()
@@ -5154,7 +5195,7 @@ async function runRpcHygieneScenarios(client) {
5154
5195
  }
5155
5196
  return results;
5156
5197
  }
5157
- async function runHandshakeScenario(client) {
5198
+ async function runHandshakeScenario(client, fixture) {
5158
5199
  const id = client.request(BRIDGE_REQUEST_METHODS.initialize, {
5159
5200
  protocolVersion: PROVIDER_BRIDGE_PROTOCOL_VERSION,
5160
5201
  client: { name: "bb-conformance", version: "0.0.1" },
@@ -5195,44 +5236,45 @@ async function runHandshakeScenario(client) {
5195
5236
  return {
5196
5237
  results: [
5197
5238
  pass("handshake/initialize", title),
5198
- ...await runSkillsConfigureDeclaredScenario(
5199
- client,
5200
- parsed.data.capabilities.skills.configure
5201
- )
5239
+ ...await runDeclaredRequestScenario(client, {
5240
+ id: "skills/configure-declared",
5241
+ method: BRIDGE_REQUEST_METHODS.skillsConfigure,
5242
+ params: { roots: [] },
5243
+ capability: "skills.configure",
5244
+ declared: parsed.data.capabilities.skills.configure
5245
+ }),
5246
+ ...await runDeclaredRequestScenario(client, {
5247
+ id: "commands/list-declared",
5248
+ method: BRIDGE_REQUEST_METHODS.commandList,
5249
+ params: { cwd: fixture.cwd },
5250
+ capability: "commands.list",
5251
+ declared: parsed.data.capabilities.commands.list
5252
+ })
5202
5253
  ],
5203
5254
  capabilities: parsed.data.capabilities
5204
5255
  };
5205
5256
  }
5206
- var SKILLS_CONFIGURE_DECLARED_ID = "skills/configure-declared";
5207
- var SKILLS_CONFIGURE_DECLARED_TITLE = "skills/configure is handled iff the handshake declares skills.configure";
5208
- async function runSkillsConfigureDeclaredScenario(client, declared) {
5209
- const id = client.request(BRIDGE_REQUEST_METHODS.skillsConfigure, {
5210
- roots: []
5211
- });
5257
+ async function runDeclaredRequestScenario(client, args) {
5258
+ const title = `${args.method} is handled iff the handshake declares ${args.capability}`;
5259
+ const id = client.request(args.method, args.params);
5212
5260
  const response = await client.waitForResponse(id);
5213
5261
  if (response === null) {
5214
- return [
5215
- fail(
5216
- SKILLS_CONFIGURE_DECLARED_ID,
5217
- SKILLS_CONFIGURE_DECLARED_TITLE,
5218
- "skills/configure was not answered"
5219
- )
5220
- ];
5262
+ return [fail(args.id, title, `${args.method} was not answered`)];
5221
5263
  }
5222
- if (declared) {
5223
- return response.error === void 0 ? [pass(SKILLS_CONFIGURE_DECLARED_ID, SKILLS_CONFIGURE_DECLARED_TITLE)] : [
5264
+ if (args.declared) {
5265
+ return response.error === void 0 ? [pass(args.id, title)] : [
5224
5266
  fail(
5225
- SKILLS_CONFIGURE_DECLARED_ID,
5226
- SKILLS_CONFIGURE_DECLARED_TITLE,
5227
- `the handshake declares skills.configure but the request failed: ${JSON.stringify(response.error)}`
5267
+ args.id,
5268
+ title,
5269
+ `the handshake declares ${args.capability} but the request failed: ${JSON.stringify(response.error)}`
5228
5270
  )
5229
5271
  ];
5230
5272
  }
5231
- return errorCode(response) === BRIDGE_JSON_RPC_ERRORS.METHOD_NOT_FOUND ? [pass(SKILLS_CONFIGURE_DECLARED_ID, SKILLS_CONFIGURE_DECLARED_TITLE)] : [
5273
+ return errorCode(response) === BRIDGE_JSON_RPC_ERRORS.METHOD_NOT_FOUND ? [pass(args.id, title)] : [
5232
5274
  fail(
5233
- SKILLS_CONFIGURE_DECLARED_ID,
5234
- SKILLS_CONFIGURE_DECLARED_TITLE,
5235
- `the handshake does not declare skills.configure, yet the bridge answered the request with ${JSON.stringify(response.error ?? response.result)}; declare it (the runtime never sends an undeclared request)`
5275
+ args.id,
5276
+ title,
5277
+ `the handshake does not declare ${args.capability}, yet the bridge answered the request with ${JSON.stringify(response.error ?? response.result)}; declare it (the runtime never sends an undeclared request)`
5236
5278
  )
5237
5279
  ];
5238
5280
  }
@@ -6082,7 +6124,7 @@ async function runBridgeConformance(options) {
6082
6124
  );
6083
6125
  const results = [];
6084
6126
  results.push(...await runRpcHygieneScenarios(client));
6085
- const handshake = await runHandshakeScenario(client);
6127
+ const handshake = await runHandshakeScenario(client, options.session);
6086
6128
  results.push(...handshake.results);
6087
6129
  results.push(
6088
6130
  ...await runSessionLifecycleScenarios({
@@ -545,6 +545,142 @@ import { pathToFileURL } from "node:url";
545
545
  // ../process-utils/src/spawn.ts
546
546
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
547
547
 
548
+ // ../process-utils/src/vcs-process-scheduler.ts
549
+ import { AsyncLocalStorage } from "node:async_hooks";
550
+ import { availableParallelism } from "node:os";
551
+ var ranks = { interactive: 0, status: 1, background: 2 };
552
+ function localProcessCapacities(parallelism) {
553
+ const total = Math.min(6, Math.max(4, parallelism - 2));
554
+ return [total, total - 1, total - 2];
555
+ }
556
+ var capacities = {
557
+ local: localProcessCapacities(availableParallelism()),
558
+ network: [4, 3, 2]
559
+ };
560
+ var githubCapacity = 2;
561
+ var agingMs = 15e3;
562
+ var networkGitSubcommands = /* @__PURE__ */ new Set([
563
+ "fetch",
564
+ "pull",
565
+ "push",
566
+ "clone",
567
+ "ls-remote"
568
+ ]);
569
+ var gitGlobalOptionsWithValue = /* @__PURE__ */ new Set([
570
+ "-C",
571
+ "-c",
572
+ "--git-dir",
573
+ "--work-tree",
574
+ "--namespace",
575
+ "--config-env"
576
+ ]);
577
+ function isNetworkGitCommand(args) {
578
+ let index = 0;
579
+ while (index < args.length && args[index].startsWith("-")) {
580
+ index += gitGlobalOptionsWithValue.has(args[index]) ? 2 : 1;
581
+ }
582
+ const subcommand = args[index];
583
+ if (subcommand === void 0) return false;
584
+ if (networkGitSubcommands.has(subcommand)) return true;
585
+ const action = args.slice(index + 1).find((arg) => !arg.startsWith("-"));
586
+ return (subcommand === "submodule" || subcommand === "remote") && action === "update";
587
+ }
588
+ var VcsProcessScheduler = class {
589
+ priority = new AsyncLocalStorage();
590
+ admitted = new AsyncLocalStorage();
591
+ active = { local: 0, network: 0 };
592
+ githubActive = 0;
593
+ queue = [];
594
+ timer;
595
+ acquire(command, args, options) {
596
+ const pool = command === "gh" || isNetworkGitCommand(args) ? "network" : "local";
597
+ const slots = options.slots ?? 1;
598
+ if (!Number.isInteger(slots) || slots < 1 || slots > capacities[pool][ranks.background]) {
599
+ return Promise.reject(new Error("Invalid VCS process slot count"));
600
+ }
601
+ if (options.signal?.aborted) {
602
+ return Promise.reject(this.abortError(options.signal));
603
+ }
604
+ return new Promise((grant, reject) => {
605
+ const waiter = {
606
+ command,
607
+ pool,
608
+ priority: options.priority ?? this.priority.getStore() ?? "status",
609
+ slots,
610
+ queuedAt: performance.now(),
611
+ signal: options.signal,
612
+ grant,
613
+ onAbort: () => {
614
+ const index = this.queue.indexOf(waiter);
615
+ if (index === -1) return;
616
+ this.queue.splice(index, 1);
617
+ reject(this.abortError(options.signal));
618
+ this.drain();
619
+ }
620
+ };
621
+ this.queue.push(waiter);
622
+ options.signal?.addEventListener("abort", waiter.onAbort, { once: true });
623
+ this.drain();
624
+ });
625
+ }
626
+ abortError(signal) {
627
+ return Object.assign(
628
+ new Error("The operation was aborted", { cause: signal?.reason }),
629
+ {
630
+ name: "AbortError",
631
+ code: "ABORT_ERR"
632
+ }
633
+ );
634
+ }
635
+ rank(waiter) {
636
+ return Math.max(
637
+ 0,
638
+ ranks[waiter.priority] - Math.floor((performance.now() - waiter.queuedAt) / agingMs)
639
+ );
640
+ }
641
+ drain() {
642
+ clearTimeout(this.timer);
643
+ this.queue.sort(
644
+ (a, b) => this.rank(a) - this.rank(b) || a.queuedAt - b.queuedAt
645
+ );
646
+ const blocked = /* @__PURE__ */ new Set();
647
+ for (let index = 0; index < this.queue.length; ) {
648
+ const waiter = this.queue[index];
649
+ if (blocked.has(waiter.pool) || waiter.command === "gh" && this.githubActive + waiter.slots > githubCapacity) {
650
+ index += 1;
651
+ continue;
652
+ }
653
+ if (this.active[waiter.pool] + waiter.slots > capacities[waiter.pool][this.rank(waiter)]) {
654
+ blocked.add(waiter.pool);
655
+ index += 1;
656
+ continue;
657
+ }
658
+ this.queue.splice(index, 1);
659
+ waiter.signal?.removeEventListener("abort", waiter.onAbort);
660
+ this.active[waiter.pool] += waiter.slots;
661
+ if (waiter.command === "gh") this.githubActive += waiter.slots;
662
+ let released = false;
663
+ waiter.grant(() => {
664
+ if (released) return;
665
+ released = true;
666
+ this.active[waiter.pool] -= waiter.slots;
667
+ if (waiter.command === "gh") this.githubActive -= waiter.slots;
668
+ this.drain();
669
+ });
670
+ }
671
+ if (this.queue.length > 0) {
672
+ const delay = Math.min(
673
+ ...this.queue.map(
674
+ (waiter) => agingMs - (performance.now() - waiter.queuedAt) % agingMs
675
+ )
676
+ );
677
+ this.timer = setTimeout(() => this.drain(), delay);
678
+ }
679
+ }
680
+ };
681
+ var registry = globalThis;
682
+ var scheduler = registry.__bbVcsProcessScheduler ??= new VcsProcessScheduler();
683
+
548
684
  // ../process-utils/src/plugin-process-paths.ts
549
685
  import { mkdir, mkdtemp } from "node:fs/promises";
550
686
  import { tmpdir } from "node:os";
@@ -563,11 +699,6 @@ import { execFile } from "node:child_process";
563
699
  import { promisify } from "node:util";
564
700
  var execFileAsync = promisify(execFile);
565
701
 
566
- // ../process-utils/src/performance-diagnostics.ts
567
- import { Session } from "node:inspector/promises";
568
- var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
569
- var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
570
-
571
702
  // ../provider-bridge-protocol/src/bridge-kit/bounded-line-reader.ts
572
703
  import { StringDecoder } from "node:string_decoder";
573
704
  var MAX_JSON_RPC_LINE_BYTES = 64 * 1024 * 1024;
@@ -2260,6 +2260,7 @@ var systemMessageKindValues = [
2260
2260
  "child-interrupted",
2261
2261
  "child-outcome-batch",
2262
2262
  "tool-result-delivered",
2263
+ "environment-directory-updated",
2263
2264
  "unlabeled"
2264
2265
  ];
2265
2266
  var systemMessageKindSchema = z14.enum(systemMessageKindValues);
@@ -2293,6 +2294,10 @@ var systemMessageSubjectSchema = z14.discriminatedUnion("kind", [
2293
2294
  kind: z14.literal("tool-call"),
2294
2295
  toolName: z14.string(),
2295
2296
  suppress: z14.boolean()
2297
+ }),
2298
+ z14.object({
2299
+ kind: z14.literal("directory"),
2300
+ path: z14.string()
2296
2301
  })
2297
2302
  ]);
2298
2303
 
@@ -2536,6 +2541,7 @@ var threadEventScopeDefinitionByType = {
2536
2541
  },
2537
2542
  "turn/plan/updated": { policy: "turn" },
2538
2543
  "turn/diff/updated": { policy: "turn" },
2544
+ "turn/mainRun/updated": { policy: "turn" },
2539
2545
  "provider/error": {
2540
2546
  policy: "thread-or-turn",
2541
2547
  rationale: "Provider diagnostics use thread scope for provider setup/session failures; in-turn failures use turn scope."
@@ -2955,6 +2961,7 @@ var threadEventItemSchema = z18.discriminatedUnion("type", [
2955
2961
  changes: z18.array(threadEventFileChangeSchema),
2956
2962
  status: threadEventItemStatusSchema,
2957
2963
  approvalStatus: threadEventItemApprovalStatusSchema,
2964
+ error: z18.string().optional(),
2958
2965
  ...itemPresentationField,
2959
2966
  parentToolCallId: z18.string().optional()
2960
2967
  }),
@@ -3155,6 +3162,12 @@ var unscopedProviderEventSchema = z18.discriminatedUnion("type", [
3155
3162
  plan: z18.array(threadEventPlanStepSchema),
3156
3163
  explanation: z18.string().optional()
3157
3164
  }),
3165
+ z18.object({
3166
+ type: z18.literal("turn/mainRun/updated"),
3167
+ threadId: z18.string(),
3168
+ providerThreadId: z18.string(),
3169
+ state: z18.enum(["idle", "running"])
3170
+ }),
3158
3171
  z18.object({
3159
3172
  type: z18.literal("turn/diff/updated"),
3160
3173
  threadId: z18.string(),
@@ -10934,8 +10947,157 @@ var {
10934
10947
  getCancelSignal: getCancelSignal2
10935
10948
  } = getIpcExport();
10936
10949
 
10950
+ // ../process-utils/src/vcs-process-scheduler.ts
10951
+ import { AsyncLocalStorage } from "node:async_hooks";
10952
+ import { availableParallelism } from "node:os";
10953
+ var ranks = { interactive: 0, status: 1, background: 2 };
10954
+ function localProcessCapacities(parallelism) {
10955
+ const total = Math.min(6, Math.max(4, parallelism - 2));
10956
+ return [total, total - 1, total - 2];
10957
+ }
10958
+ var capacities = {
10959
+ local: localProcessCapacities(availableParallelism()),
10960
+ network: [4, 3, 2]
10961
+ };
10962
+ var githubCapacity = 2;
10963
+ var agingMs = 15e3;
10964
+ var networkGitSubcommands = /* @__PURE__ */ new Set([
10965
+ "fetch",
10966
+ "pull",
10967
+ "push",
10968
+ "clone",
10969
+ "ls-remote"
10970
+ ]);
10971
+ var gitGlobalOptionsWithValue = /* @__PURE__ */ new Set([
10972
+ "-C",
10973
+ "-c",
10974
+ "--git-dir",
10975
+ "--work-tree",
10976
+ "--namespace",
10977
+ "--config-env"
10978
+ ]);
10979
+ function isNetworkGitCommand(args) {
10980
+ let index = 0;
10981
+ while (index < args.length && args[index].startsWith("-")) {
10982
+ index += gitGlobalOptionsWithValue.has(args[index]) ? 2 : 1;
10983
+ }
10984
+ const subcommand = args[index];
10985
+ if (subcommand === void 0) return false;
10986
+ if (networkGitSubcommands.has(subcommand)) return true;
10987
+ const action = args.slice(index + 1).find((arg) => !arg.startsWith("-"));
10988
+ return (subcommand === "submodule" || subcommand === "remote") && action === "update";
10989
+ }
10990
+ var VcsProcessScheduler = class {
10991
+ priority = new AsyncLocalStorage();
10992
+ admitted = new AsyncLocalStorage();
10993
+ active = { local: 0, network: 0 };
10994
+ githubActive = 0;
10995
+ queue = [];
10996
+ timer;
10997
+ acquire(command, args, options) {
10998
+ const pool = command === "gh" || isNetworkGitCommand(args) ? "network" : "local";
10999
+ const slots = options.slots ?? 1;
11000
+ if (!Number.isInteger(slots) || slots < 1 || slots > capacities[pool][ranks.background]) {
11001
+ return Promise.reject(new Error("Invalid VCS process slot count"));
11002
+ }
11003
+ if (options.signal?.aborted) {
11004
+ return Promise.reject(this.abortError(options.signal));
11005
+ }
11006
+ return new Promise((grant, reject) => {
11007
+ const waiter = {
11008
+ command,
11009
+ pool,
11010
+ priority: options.priority ?? this.priority.getStore() ?? "status",
11011
+ slots,
11012
+ queuedAt: performance.now(),
11013
+ signal: options.signal,
11014
+ grant,
11015
+ onAbort: () => {
11016
+ const index = this.queue.indexOf(waiter);
11017
+ if (index === -1) return;
11018
+ this.queue.splice(index, 1);
11019
+ reject(this.abortError(options.signal));
11020
+ this.drain();
11021
+ }
11022
+ };
11023
+ this.queue.push(waiter);
11024
+ options.signal?.addEventListener("abort", waiter.onAbort, { once: true });
11025
+ this.drain();
11026
+ });
11027
+ }
11028
+ abortError(signal) {
11029
+ return Object.assign(
11030
+ new Error("The operation was aborted", { cause: signal?.reason }),
11031
+ {
11032
+ name: "AbortError",
11033
+ code: "ABORT_ERR"
11034
+ }
11035
+ );
11036
+ }
11037
+ rank(waiter) {
11038
+ return Math.max(
11039
+ 0,
11040
+ ranks[waiter.priority] - Math.floor((performance.now() - waiter.queuedAt) / agingMs)
11041
+ );
11042
+ }
11043
+ drain() {
11044
+ clearTimeout(this.timer);
11045
+ this.queue.sort(
11046
+ (a2, b) => this.rank(a2) - this.rank(b) || a2.queuedAt - b.queuedAt
11047
+ );
11048
+ const blocked = /* @__PURE__ */ new Set();
11049
+ for (let index = 0; index < this.queue.length; ) {
11050
+ const waiter = this.queue[index];
11051
+ if (blocked.has(waiter.pool) || waiter.command === "gh" && this.githubActive + waiter.slots > githubCapacity) {
11052
+ index += 1;
11053
+ continue;
11054
+ }
11055
+ if (this.active[waiter.pool] + waiter.slots > capacities[waiter.pool][this.rank(waiter)]) {
11056
+ blocked.add(waiter.pool);
11057
+ index += 1;
11058
+ continue;
11059
+ }
11060
+ this.queue.splice(index, 1);
11061
+ waiter.signal?.removeEventListener("abort", waiter.onAbort);
11062
+ this.active[waiter.pool] += waiter.slots;
11063
+ if (waiter.command === "gh") this.githubActive += waiter.slots;
11064
+ let released = false;
11065
+ waiter.grant(() => {
11066
+ if (released) return;
11067
+ released = true;
11068
+ this.active[waiter.pool] -= waiter.slots;
11069
+ if (waiter.command === "gh") this.githubActive -= waiter.slots;
11070
+ this.drain();
11071
+ });
11072
+ }
11073
+ if (this.queue.length > 0) {
11074
+ const delay = Math.min(
11075
+ ...this.queue.map(
11076
+ (waiter) => agingMs - (performance.now() - waiter.queuedAt) % agingMs
11077
+ )
11078
+ );
11079
+ this.timer = setTimeout(() => this.drain(), delay);
11080
+ }
11081
+ }
11082
+ };
11083
+ var registry = globalThis;
11084
+ var scheduler3 = registry.__bbVcsProcessScheduler ??= new VcsProcessScheduler();
11085
+ async function runVcsProcess(command, args, operation, options = {}) {
11086
+ if (scheduler3.admitted.getStore()) {
11087
+ options.signal?.throwIfAborted();
11088
+ return operation();
11089
+ }
11090
+ const release = await scheduler3.acquire(command, args, options);
11091
+ try {
11092
+ options.signal?.throwIfAborted();
11093
+ return await scheduler3.admitted.run(true, operation);
11094
+ } finally {
11095
+ release();
11096
+ }
11097
+ }
11098
+
10937
11099
  // ../process-utils/src/exec-portable-file.ts
10938
- import { extname as extname2 } from "node:path";
11100
+ import { basename, extname as extname2 } from "node:path";
10939
11101
 
10940
11102
  // ../../node_modules/.pnpm/which-command@0.1.0/node_modules/which-command/index.js
10941
11103
  import fs from "node:fs";
@@ -11022,6 +11184,21 @@ function whichCommandSync(command, options = {}) {
11022
11184
 
11023
11185
  // ../process-utils/src/exec-portable-file.ts
11024
11186
  async function execPortableFile(command, args, options) {
11187
+ const executable = basename(command).toLowerCase().replace(/\.(exe|cmd|bat)$/u, "");
11188
+ if (executable === "git" || executable === "gh") {
11189
+ return runVcsProcess(
11190
+ executable,
11191
+ args,
11192
+ () => execPortableFileUnbounded(command, args, options),
11193
+ {
11194
+ priority: options.priority,
11195
+ signal: options.signal
11196
+ }
11197
+ );
11198
+ }
11199
+ return execPortableFileUnbounded(command, args, options);
11200
+ }
11201
+ async function execPortableFileUnbounded(command, args, options) {
11025
11202
  if (options.signal?.aborted) throw options.signal.reason;
11026
11203
  if (process.platform === "win32") {
11027
11204
  const envKeys = Object.keys(options.env).sort();
@@ -11147,11 +11324,6 @@ import { execFile as execFile2 } from "node:child_process";
11147
11324
  import { promisify as promisify3 } from "node:util";
11148
11325
  var execFileAsync = promisify3(execFile2);
11149
11326
 
11150
- // ../process-utils/src/performance-diagnostics.ts
11151
- import { Session } from "node:inspector/promises";
11152
- var PROFILE_RETENTION_MS = 12 * 60 * 60 * 1e3;
11153
- var MAX_PROFILE_BYTES = 12 * 1024 * 1024;
11154
-
11155
11327
  // ../provider-bridge-protocol/src/bridge-kit/provider-maintenance-kit.ts
11156
11328
  var import_compare = __toESM(require_compare(), 1);
11157
11329
  var import_valid = __toESM(require_valid(), 1);
@@ -11399,7 +11571,8 @@ var bridgeCapabilitiesSchema = z29.object({
11399
11571
  PROVIDER_BRIDGE_PROTOCOL_VERSION
11400
11572
  ]),
11401
11573
  steerMode: bridgeSteerModeSchema.default("queue"),
11402
- skills: z29.object({ configure: z29.boolean().default(false) }).default({ configure: false })
11574
+ skills: z29.object({ configure: z29.boolean().default(false) }).default({ configure: false }),
11575
+ commands: z29.object({ list: z29.boolean().default(false) }).default({ list: false })
11403
11576
  }).passthrough();
11404
11577
  var initializeParamsSchema = z29.object({
11405
11578
  protocolVersion: z29.number().int().positive(),
@@ -11571,6 +11744,7 @@ import { z as z32 } from "zod";
11571
11744
  var BRIDGE_REQUEST_METHODS = {
11572
11745
  initialize: "initialize",
11573
11746
  modelList: "model/list",
11747
+ commandList: "commands/list",
11574
11748
  providerHealth: "provider/health",
11575
11749
  providerUsage: "provider/usage",
11576
11750
  providerInstallationStatus: "provider/installation/status",
@@ -11596,7 +11770,12 @@ var sessionConstructionFields = {
11596
11770
  disallowedTools: z32.array(z32.string().min(1)).optional(),
11597
11771
  instructionMode: instructionModeSchema
11598
11772
  };
11599
- var modelListParamsSchema = z32.object({ cwd: z32.string().min(1).optional() }).passthrough();
11773
+ var modelListParamsSchema = z32.object({
11774
+ cwd: z32.string().min(1).optional(),
11775
+ envVars: z32.record(z32.string(), z32.string()).optional()
11776
+ }).passthrough();
11777
+ var commandListParamsSchema = z32.object({ cwd: z32.string().min(1) }).passthrough();
11778
+ var commandListResultSchema = threadProviderCommandsStateSchema;
11600
11779
  var threadStartParamsSchema = z32.object({
11601
11780
  ...sessionConstructionFields,
11602
11781
  input: z32.array(promptInputSchema).optional()
@@ -11855,6 +12034,10 @@ var threadDeltaSchema = z34.discriminatedUnion("kind", [
11855
12034
  providerTurnId: providerTurnIdSchema.optional(),
11856
12035
  parentRef: deltaKeyPartSchema.optional()
11857
12036
  }),
12037
+ z34.object({
12038
+ kind: z34.literal("turn.mainRun"),
12039
+ state: z34.enum(["idle", "running"])
12040
+ }),
11858
12041
  z34.object({
11859
12042
  kind: z34.literal("turn.boundary"),
11860
12043
  status: threadEventTurnStatusSchema,
@@ -12126,6 +12309,7 @@ export {
12126
12309
  LOW_REASONING_EFFORT,
12127
12310
  MAX_REASONING_EFFORT,
12128
12311
  MEDIUM_REASONING_EFFORT,
12312
+ PLUGIN_INTERACTION_MAX_TITLE_LENGTH,
12129
12313
  PROVIDER_BRIDGE_EXPORT_NAME,
12130
12314
  PROVIDER_BRIDGE_PROTOCOL_VERSION,
12131
12315
  ProviderRequestDecodeError,
@@ -12153,6 +12337,8 @@ export {
12153
12337
  buildShellEnvOverrides,
12154
12338
  claudeTaskToolNameSchema,
12155
12339
  claudeTaskToolOutputSchema,
12340
+ commandListParamsSchema,
12341
+ commandListResultSchema,
12156
12342
  contextSnapshotSchema,
12157
12343
  createBridgeIo,
12158
12344
  createBridgeLineHandler,
@@ -1550,9 +1550,9 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
1550
1550
  );
1551
1551
  }
1552
1552
  const extensions = rawExtensions.map((extension) => {
1553
- if (typeof extension !== "string" || !/^[a-z0-9]+$/.test(extension)) {
1553
+ if (typeof extension !== "string" || !/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(extension)) {
1554
1554
  throw new Error(
1555
- `${kind}: extensions must be lowercase alphanumerics without the dot, got ${JSON.stringify(extension)}`
1555
+ `${kind}: extensions must be lowercase alphanumerics with single underscores or hyphens between segments, without the dot, got ${JSON.stringify(extension)}`
1556
1556
  );
1557
1557
  }
1558
1558
  return extension;