@get-bb/plugin-sdk 0.4.87 → 0.4.94

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.
@@ -1751,6 +1751,8 @@ var threadEventTokenUsageBreakdownSchema = z15.object({
1751
1751
  totalTokens: z15.number(),
1752
1752
  inputTokens: z15.number(),
1753
1753
  cachedInputTokens: z15.number(),
1754
+ cacheReadInputTokens: z15.number().nonnegative().optional(),
1755
+ cacheWriteInputTokens: z15.number().nonnegative().optional(),
1754
1756
  outputTokens: z15.number(),
1755
1757
  reasoningOutputTokens: z15.number()
1756
1758
  });
@@ -3760,9 +3762,11 @@ async function resolveExecutablePath(command) {
3760
3762
  }
3761
3763
  async function readCliVersion(command) {
3762
3764
  try {
3763
- const { stdout, stderr } = await execFileAsync(command, ["--version"], {
3765
+ const probe = execFileAsync(command, ["--version"], {
3764
3766
  timeout: CLI_PROBE_TIMEOUT_MS
3765
3767
  });
3768
+ probe.child.stdin?.end();
3769
+ const { stdout, stderr } = await probe;
3766
3770
  return `${stdout}
3767
3771
  ${stderr}`.match(/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?/u)?.[0] ?? null;
3768
3772
  } catch {
@@ -3785,6 +3789,13 @@ function clampPercent(value) {
3785
3789
  );
3786
3790
  }
3787
3791
 
3792
+ // ../provider-bridge-protocol/src/bridge-kit/provider-tool-call-contract.ts
3793
+ import { z as z32 } from "zod";
3794
+ var providerToolCallCancellationSchema = z32.object({
3795
+ requestId: z32.union([z32.string(), z32.number().int()])
3796
+ });
3797
+ var PROVIDER_TOOL_CALL_CANCELLED_METHOD = "notifications/cancelled";
3798
+
3788
3799
  // ../provider-bridge-protocol/src/bridge-kit/provider-visibility.ts
3789
3800
  function createProviderVisibilityMetadata(args) {
3790
3801
  return {
@@ -3797,8 +3808,8 @@ function createProviderVisibilityMetadata(args) {
3797
3808
  }
3798
3809
 
3799
3810
  // ../provider-bridge-protocol/src/bridge-kit/runtime-json-rpc.ts
3800
- import { z as z32 } from "zod";
3801
- var ignoredJsonRpcResultSchema = z32.unknown();
3811
+ import { z as z33 } from "zod";
3812
+ var ignoredJsonRpcResultSchema = z33.unknown();
3802
3813
 
3803
3814
  // ../provider-bridge-acp/src/bridge/bridge.ts
3804
3815
  import { execFile as execFile4 } from "node:child_process";
@@ -3808,21 +3819,21 @@ import { createServer } from "node:net";
3808
3819
  import { dirname as dirname2, isAbsolute, basename as basename3, relative, resolve as resolve3 } from "node:path";
3809
3820
  import { fileURLToPath } from "node:url";
3810
3821
  import { isDeepStrictEqual } from "node:util";
3811
- import { z as z40 } from "zod";
3822
+ import { z as z41 } from "zod";
3812
3823
 
3813
3824
  // ../provider-bridge-acp/src/bridge-protocol.ts
3814
- import { z as z34 } from "zod";
3825
+ import { z as z35 } from "zod";
3815
3826
 
3816
3827
  // ../provider-bridge-acp/src/wire.ts
3817
- import { z as z33 } from "zod";
3818
- var acpTextContentBlockSchema = z33.object({
3819
- type: z33.literal("text"),
3820
- text: z33.string()
3828
+ import { z as z34 } from "zod";
3829
+ var acpTextContentBlockSchema = z34.object({
3830
+ type: z34.literal("text"),
3831
+ text: z34.string()
3821
3832
  }).passthrough();
3822
- var acpOtherContentBlockSchema = z33.object({
3823
- type: z33.string()
3833
+ var acpOtherContentBlockSchema = z34.object({
3834
+ type: z34.string()
3824
3835
  }).passthrough();
3825
- var acpContentBlockSchema = z33.union([
3836
+ var acpContentBlockSchema = z34.union([
3826
3837
  acpTextContentBlockSchema,
3827
3838
  acpOtherContentBlockSchema
3828
3839
  ]);
@@ -3845,7 +3856,7 @@ var ACP_TOOL_KINDS = [
3845
3856
  "switch_mode",
3846
3857
  "other"
3847
3858
  ];
3848
- var acpToolKindSchema = z33.enum(ACP_TOOL_KINDS);
3859
+ var acpToolKindSchema = z34.enum(ACP_TOOL_KINDS);
3849
3860
  var ACP_TOOL_KIND_SET = new Set(ACP_TOOL_KINDS);
3850
3861
  var ACP_TOOL_CALL_STATUSES = [
3851
3862
  "pending",
@@ -3854,48 +3865,48 @@ var ACP_TOOL_CALL_STATUSES = [
3854
3865
  "failed",
3855
3866
  "cancelled"
3856
3867
  ];
3857
- var acpToolCallStatusSchema = z33.enum(ACP_TOOL_CALL_STATUSES);
3868
+ var acpToolCallStatusSchema = z34.enum(ACP_TOOL_CALL_STATUSES);
3858
3869
  var ACP_TOOL_CALL_STATUS_SET = new Set(
3859
3870
  ACP_TOOL_CALL_STATUSES
3860
3871
  );
3861
- var acpToolCallContentSchema = z33.union([
3862
- z33.object({
3863
- type: z33.literal("content"),
3872
+ var acpToolCallContentSchema = z34.union([
3873
+ z34.object({
3874
+ type: z34.literal("content"),
3864
3875
  content: acpContentBlockSchema
3865
3876
  }).passthrough(),
3866
- z33.object({
3867
- type: z33.literal("diff"),
3868
- path: z33.string(),
3869
- oldText: z33.string().nullable().optional(),
3870
- newText: z33.string()
3877
+ z34.object({
3878
+ type: z34.literal("diff"),
3879
+ path: z34.string(),
3880
+ oldText: z34.string().nullable().optional(),
3881
+ newText: z34.string()
3871
3882
  }).passthrough(),
3872
- z33.object({
3873
- type: z33.literal("terminal"),
3874
- terminalId: z33.string()
3883
+ z34.object({
3884
+ type: z34.literal("terminal"),
3885
+ terminalId: z34.string()
3875
3886
  }).passthrough()
3876
3887
  ]);
3877
- var acpToolCallContentListSchema = z33.array(z33.unknown()).transform(
3888
+ var acpToolCallContentListSchema = z34.array(z34.unknown()).transform(
3878
3889
  (entries) => entries.flatMap((entry) => {
3879
3890
  const parsed = acpToolCallContentSchema.safeParse(entry);
3880
3891
  return parsed.success ? [parsed.data] : [];
3881
3892
  })
3882
3893
  );
3883
- var acpToolCallLocationSchema = z33.object({
3884
- path: z33.string(),
3885
- line: z33.number().optional().nullable()
3894
+ var acpToolCallLocationSchema = z34.object({
3895
+ path: z34.string(),
3896
+ line: z34.number().optional().nullable()
3886
3897
  }).passthrough();
3887
- var acpToolCallNameSchema = z33.union([z33.string(), z33.null()]).transform((value) => value ?? void 0).optional();
3888
- var acpToolCallFieldsSchema = z33.object({
3889
- toolCallId: z33.string(),
3890
- title: z33.string().optional(),
3898
+ var acpToolCallNameSchema = z34.union([z34.string(), z34.null()]).transform((value) => value ?? void 0).optional();
3899
+ var acpToolCallFieldsSchema = z34.object({
3900
+ toolCallId: z34.string(),
3901
+ title: z34.string().optional(),
3891
3902
  name: acpToolCallNameSchema,
3892
3903
  kind: acpToolKindSchema.optional(),
3893
- rawKind: z33.string().optional(),
3904
+ rawKind: z34.string().optional(),
3894
3905
  status: acpToolCallStatusSchema.optional(),
3895
3906
  content: acpToolCallContentListSchema.optional(),
3896
- locations: z33.array(acpToolCallLocationSchema).optional(),
3897
- rawInput: z33.unknown().optional(),
3898
- rawOutput: z33.unknown().optional()
3907
+ locations: z34.array(acpToolCallLocationSchema).optional(),
3908
+ rawInput: z34.unknown().optional(),
3909
+ rawOutput: z34.unknown().optional()
3899
3910
  });
3900
3911
  function openAcpToolCallEnums(value) {
3901
3912
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -3921,43 +3932,43 @@ function openAcpToolCallEnums(value) {
3921
3932
  }
3922
3933
  return next;
3923
3934
  }
3924
- var acpAgentMessageChunkUpdateSchema = z33.object({
3925
- sessionUpdate: z33.literal("agent_message_chunk"),
3935
+ var acpAgentMessageChunkUpdateSchema = z34.object({
3936
+ sessionUpdate: z34.literal("agent_message_chunk"),
3926
3937
  content: acpContentBlockSchema
3927
3938
  }).passthrough();
3928
- var acpAgentThoughtChunkUpdateSchema = z33.object({
3929
- sessionUpdate: z33.literal("agent_thought_chunk"),
3939
+ var acpAgentThoughtChunkUpdateSchema = z34.object({
3940
+ sessionUpdate: z34.literal("agent_thought_chunk"),
3930
3941
  content: acpContentBlockSchema
3931
3942
  }).passthrough();
3932
- var acpToolCallUpdateEventSchema = z33.preprocess(
3943
+ var acpToolCallUpdateEventSchema = z34.preprocess(
3933
3944
  openAcpToolCallEnums,
3934
3945
  acpToolCallFieldsSchema.extend({
3935
- sessionUpdate: z33.enum(["tool_call", "tool_call_update"])
3946
+ sessionUpdate: z34.enum(["tool_call", "tool_call_update"])
3936
3947
  }).passthrough()
3937
3948
  );
3938
- var acpPlanEntryStatusSchema = z33.enum([
3949
+ var acpPlanEntryStatusSchema = z34.enum([
3939
3950
  "pending",
3940
3951
  "in_progress",
3941
3952
  "completed"
3942
3953
  ]);
3943
- var acpPlanUpdateSchema = z33.object({
3944
- sessionUpdate: z33.literal("plan"),
3945
- entries: z33.array(
3946
- z33.object({
3947
- content: z33.string(),
3954
+ var acpPlanUpdateSchema = z34.object({
3955
+ sessionUpdate: z34.literal("plan"),
3956
+ entries: z34.array(
3957
+ z34.object({
3958
+ content: z34.string(),
3948
3959
  status: acpPlanEntryStatusSchema.optional()
3949
3960
  }).passthrough()
3950
3961
  )
3951
3962
  }).passthrough();
3952
- var acpUsageUpdateSchema = z33.object({
3953
- sessionUpdate: z33.literal("usage_update"),
3954
- used: z33.number().int().nonnegative(),
3955
- size: z33.number().int().nonnegative()
3963
+ var acpUsageUpdateSchema = z34.object({
3964
+ sessionUpdate: z34.literal("usage_update"),
3965
+ used: z34.number().int().nonnegative(),
3966
+ size: z34.number().int().nonnegative()
3956
3967
  }).passthrough();
3957
- var acpOtherSessionUpdateSchema = z33.object({
3958
- sessionUpdate: z33.string()
3968
+ var acpOtherSessionUpdateSchema = z34.object({
3969
+ sessionUpdate: z34.string()
3959
3970
  }).passthrough();
3960
- var acpSessionUpdateSchema = z33.union([
3971
+ var acpSessionUpdateSchema = z34.union([
3961
3972
  acpAgentMessageChunkUpdateSchema,
3962
3973
  acpAgentThoughtChunkUpdateSchema,
3963
3974
  acpToolCallUpdateEventSchema,
@@ -3965,55 +3976,55 @@ var acpSessionUpdateSchema = z33.union([
3965
3976
  acpUsageUpdateSchema,
3966
3977
  acpOtherSessionUpdateSchema
3967
3978
  ]);
3968
- var acpSessionNotificationParamsSchema = z33.object({
3969
- sessionId: z33.string(),
3979
+ var acpSessionNotificationParamsSchema = z34.object({
3980
+ sessionId: z34.string(),
3970
3981
  update: acpSessionUpdateSchema
3971
3982
  }).passthrough();
3972
3983
  var ACP_PROTOCOL_VERSION = 1;
3973
- var acpInitializeResultSchema = z33.object({
3974
- protocolVersion: z33.number(),
3975
- agentCapabilities: z33.object({
3976
- loadSession: z33.boolean().optional(),
3977
- sessionCapabilities: z33.object({
3978
- fork: z33.object({}).passthrough().nullable().optional()
3984
+ var acpInitializeResultSchema = z34.object({
3985
+ protocolVersion: z34.number(),
3986
+ agentCapabilities: z34.object({
3987
+ loadSession: z34.boolean().optional(),
3988
+ sessionCapabilities: z34.object({
3989
+ fork: z34.object({}).passthrough().nullable().optional()
3979
3990
  }).passthrough().optional(),
3980
- promptCapabilities: z33.object({
3981
- image: z33.boolean().optional(),
3982
- audio: z33.boolean().optional(),
3983
- embeddedContext: z33.boolean().optional()
3991
+ promptCapabilities: z34.object({
3992
+ image: z34.boolean().optional(),
3993
+ audio: z34.boolean().optional(),
3994
+ embeddedContext: z34.boolean().optional()
3984
3995
  }).passthrough().optional()
3985
3996
  }).passthrough().optional(),
3986
- authMethods: z33.array(z33.object({ id: z33.string() }).passthrough()).optional()
3997
+ authMethods: z34.array(z34.object({ id: z34.string() }).passthrough()).optional()
3987
3998
  }).passthrough();
3988
- var acpOptionalString = z33.union([z33.string(), z33.null()]).transform((value) => value ?? void 0).optional();
3989
- var acpConfigOptionSelectOptionSchema = z33.object({
3990
- value: z33.string(),
3999
+ var acpOptionalString = z34.union([z34.string(), z34.null()]).transform((value) => value ?? void 0).optional();
4000
+ var acpConfigOptionSelectOptionSchema = z34.object({
4001
+ value: z34.string(),
3991
4002
  name: acpOptionalString
3992
4003
  }).passthrough();
3993
- var acpConfigOptionSchema = z33.object({
3994
- id: z33.string(),
4004
+ var acpConfigOptionSchema = z34.object({
4005
+ id: z34.string(),
3995
4006
  name: acpOptionalString,
3996
4007
  category: acpOptionalString,
3997
- type: z33.string(),
4008
+ type: z34.string(),
3998
4009
  currentValue: acpOptionalString,
3999
- options: z33.array(acpConfigOptionSelectOptionSchema).optional()
4010
+ options: z34.array(acpConfigOptionSelectOptionSchema).optional()
4000
4011
  }).passthrough();
4001
- var acpSessionModelSchema = z33.object({
4002
- modelId: z33.string(),
4012
+ var acpSessionModelSchema = z34.object({
4013
+ modelId: z34.string(),
4003
4014
  name: acpOptionalString,
4004
4015
  description: acpOptionalString
4005
4016
  }).passthrough();
4006
- var acpSessionModelsSchema = z33.object({
4017
+ var acpSessionModelsSchema = z34.object({
4007
4018
  currentModelId: acpOptionalString,
4008
- availableModels: z33.array(acpSessionModelSchema).optional()
4019
+ availableModels: z34.array(acpSessionModelSchema).optional()
4009
4020
  }).passthrough();
4010
- var acpLooseConfigOptionSchema = z33.object({
4011
- id: z33.string().optional(),
4012
- name: z33.unknown().optional(),
4021
+ var acpLooseConfigOptionSchema = z34.object({
4022
+ id: z34.string().optional(),
4023
+ name: z34.unknown().optional(),
4013
4024
  category: acpOptionalString,
4014
- type: z33.unknown().optional(),
4015
- currentValue: z33.unknown().optional(),
4016
- options: z33.unknown().optional()
4025
+ type: z34.unknown().optional(),
4026
+ currentValue: z34.unknown().optional(),
4027
+ options: z34.unknown().optional()
4017
4028
  }).passthrough();
4018
4029
  function parseAcpConfigOptions(options, ctx) {
4019
4030
  if (options == null) {
@@ -4057,119 +4068,119 @@ function parseAcpConfigOptions(options, ctx) {
4057
4068
  }
4058
4069
  return parsedOptions;
4059
4070
  }
4060
- var acpSessionNewResultSchema = z33.object({
4061
- sessionId: z33.string(),
4071
+ var acpSessionNewResultSchema = z34.object({
4072
+ sessionId: z34.string(),
4062
4073
  models: acpSessionModelsSchema.optional(),
4063
- configOptions: z33.array(z33.unknown()).nullable().optional().transform((options, ctx) => parseAcpConfigOptions(options, ctx))
4074
+ configOptions: z34.array(z34.unknown()).nullable().optional().transform((options, ctx) => parseAcpConfigOptions(options, ctx))
4064
4075
  }).passthrough();
4065
- var acpConfigStateResultSchema = z33.object({
4076
+ var acpConfigStateResultSchema = z34.object({
4066
4077
  models: acpSessionModelsSchema.optional(),
4067
- configOptions: z33.array(z33.unknown()).nullable().optional().transform((options, ctx) => parseAcpConfigOptions(options, ctx))
4078
+ configOptions: z34.array(z34.unknown()).nullable().optional().transform((options, ctx) => parseAcpConfigOptions(options, ctx))
4068
4079
  }).passthrough();
4069
4080
  var acpSessionForkResultSchema = acpConfigStateResultSchema.extend({
4070
- sessionId: z33.string()
4081
+ sessionId: z34.string()
4071
4082
  });
4072
- var acpStopReasonSchema = z33.enum([
4083
+ var acpStopReasonSchema = z34.enum([
4073
4084
  "end_turn",
4074
4085
  "max_tokens",
4075
4086
  "max_turn_requests",
4076
4087
  "refusal",
4077
4088
  "cancelled"
4078
4089
  ]);
4079
- var acpPromptResultSchema = z33.object({
4090
+ var acpPromptResultSchema = z34.object({
4080
4091
  stopReason: acpStopReasonSchema
4081
4092
  }).passthrough();
4082
- var acpPermissionOptionKindSchema = z33.enum([
4093
+ var acpPermissionOptionKindSchema = z34.enum([
4083
4094
  "allow_once",
4084
4095
  "allow_always",
4085
4096
  "reject_once",
4086
4097
  "reject_always"
4087
4098
  ]);
4088
- var acpPermissionOptionSchema = z33.object({
4089
- optionId: z33.string(),
4090
- name: z33.string(),
4099
+ var acpPermissionOptionSchema = z34.object({
4100
+ optionId: z34.string(),
4101
+ name: z34.string(),
4091
4102
  kind: acpPermissionOptionKindSchema
4092
4103
  }).passthrough();
4093
- var acpRequestPermissionParamsSchema = z33.object({
4094
- sessionId: z33.string(),
4095
- toolCall: z33.preprocess(
4104
+ var acpRequestPermissionParamsSchema = z34.object({
4105
+ sessionId: z34.string(),
4106
+ toolCall: z34.preprocess(
4096
4107
  openAcpToolCallEnums,
4097
4108
  acpToolCallFieldsSchema.partial().passthrough()
4098
4109
  ).optional(),
4099
- options: z33.array(acpPermissionOptionSchema).min(1)
4110
+ options: z34.array(acpPermissionOptionSchema).min(1)
4100
4111
  }).passthrough();
4101
- var acpReadTextFileParamsSchema = z33.object({
4102
- sessionId: z33.string(),
4103
- path: z33.string(),
4104
- line: z33.number().nullable().optional(),
4105
- limit: z33.number().nullable().optional()
4112
+ var acpReadTextFileParamsSchema = z34.object({
4113
+ sessionId: z34.string(),
4114
+ path: z34.string(),
4115
+ line: z34.number().nullable().optional(),
4116
+ limit: z34.number().nullable().optional()
4106
4117
  }).passthrough();
4107
- var acpWriteTextFileParamsSchema = z33.object({
4108
- sessionId: z33.string(),
4109
- path: z33.string(),
4110
- content: z33.string()
4118
+ var acpWriteTextFileParamsSchema = z34.object({
4119
+ sessionId: z34.string(),
4120
+ path: z34.string(),
4121
+ content: z34.string()
4111
4122
  }).passthrough();
4112
4123
 
4113
4124
  // ../provider-bridge-acp/src/bridge-protocol.ts
4114
4125
  var ACP_DEFAULT_MODEL_ID = "acp-default";
4115
4126
  var acpModelListParamsSchema = modelListParamsSchema.extend({
4116
- providerOptions: z34.record(z34.string(), z34.unknown()).optional()
4127
+ providerOptions: z35.record(z35.string(), z35.unknown()).optional()
4117
4128
  });
4118
- var acpBridgeCommandSchema = z34.discriminatedUnion("method", [
4119
- z34.object({
4120
- method: z34.literal("initialize"),
4129
+ var acpBridgeCommandSchema = z35.discriminatedUnion("method", [
4130
+ z35.object({
4131
+ method: z35.literal("initialize"),
4121
4132
  params: initializeParamsSchema
4122
4133
  }),
4123
- z34.object({
4124
- method: z34.literal("model/list"),
4134
+ z35.object({
4135
+ method: z35.literal("model/list"),
4125
4136
  params: acpModelListParamsSchema
4126
4137
  }),
4127
- z34.object({
4128
- method: z34.literal("provider/health"),
4138
+ z35.object({
4139
+ method: z35.literal("provider/health"),
4129
4140
  params: providerMaintenanceParamsSchema
4130
4141
  }),
4131
- z34.object({
4132
- method: z34.literal("provider/usage"),
4142
+ z35.object({
4143
+ method: z35.literal("provider/usage"),
4133
4144
  params: providerMaintenanceParamsSchema
4134
4145
  }),
4135
- z34.object({
4136
- method: z34.literal("provider/installation/status"),
4146
+ z35.object({
4147
+ method: z35.literal("provider/installation/status"),
4137
4148
  params: providerInstallationStatusParamsSchema
4138
4149
  }),
4139
- z34.object({
4140
- method: z34.literal("provider/installation/run"),
4150
+ z35.object({
4151
+ method: z35.literal("provider/installation/run"),
4141
4152
  params: providerInstallationRunParamsSchema
4142
4153
  }),
4143
- z34.object({
4144
- method: z34.literal("thread/start"),
4154
+ z35.object({
4155
+ method: z35.literal("thread/start"),
4145
4156
  params: threadStartParamsSchema
4146
4157
  }),
4147
- z34.object({
4148
- method: z34.literal("thread/resume"),
4158
+ z35.object({
4159
+ method: z35.literal("thread/resume"),
4149
4160
  params: threadResumeParamsSchema
4150
4161
  }),
4151
- z34.object({
4152
- method: z34.literal("thread/fork"),
4162
+ z35.object({
4163
+ method: z35.literal("thread/fork"),
4153
4164
  params: threadForkParamsSchema
4154
4165
  }),
4155
- z34.object({
4156
- method: z34.literal("turn/start"),
4166
+ z35.object({
4167
+ method: z35.literal("turn/start"),
4157
4168
  params: turnStartParamsSchema
4158
4169
  }),
4159
- z34.object({
4160
- method: z34.literal("turn/steer"),
4170
+ z35.object({
4171
+ method: z35.literal("turn/steer"),
4161
4172
  params: turnSteerParamsSchema
4162
4173
  }),
4163
- z34.object({
4164
- method: z34.literal("thread/stop"),
4174
+ z35.object({
4175
+ method: z35.literal("thread/stop"),
4165
4176
  params: threadStopParamsSchema
4166
4177
  }),
4167
- z34.object({
4168
- method: z34.literal("thread/discard"),
4178
+ z35.object({
4179
+ method: z35.literal("thread/discard"),
4169
4180
  params: threadDiscardParamsSchema
4170
4181
  }),
4171
- z34.object({
4172
- method: z34.literal("skills/configure"),
4182
+ z35.object({
4183
+ method: z35.literal("skills/configure"),
4173
4184
  params: skillsConfigureParamsSchema
4174
4185
  })
4175
4186
  ]);
@@ -4184,53 +4195,53 @@ var ACP_UPDATE_METHOD = "acp/update";
4184
4195
  var ACP_FS_WRITE_METHOD = "acp/fs/write";
4185
4196
  var ACP_WARNING_METHOD = "acp/warning";
4186
4197
  var ACP_BRIDGE_NO_ACTIVE_TURN_ERROR_CODE = -32001;
4187
- var acpTurnStartedNotificationParamsSchema = z34.object({
4188
- threadId: z34.string().min(1)
4198
+ var acpTurnStartedNotificationParamsSchema = z35.object({
4199
+ threadId: z35.string().min(1)
4189
4200
  }).passthrough();
4190
- var acpTurnCompletedNotificationParamsSchema = z34.object({
4191
- threadId: z34.string().min(1),
4201
+ var acpTurnCompletedNotificationParamsSchema = z35.object({
4202
+ threadId: z35.string().min(1),
4192
4203
  stopReason: acpStopReasonSchema
4193
4204
  }).passthrough();
4194
- var acpCompactionCompletedNotificationParamsSchema = z34.discriminatedUnion("status", [
4195
- z34.object({
4196
- threadId: z34.string().min(1),
4197
- status: z34.literal("completed")
4205
+ var acpCompactionCompletedNotificationParamsSchema = z35.discriminatedUnion("status", [
4206
+ z35.object({
4207
+ threadId: z35.string().min(1),
4208
+ status: z35.literal("completed")
4198
4209
  }).passthrough(),
4199
- z34.object({
4200
- threadId: z34.string().min(1),
4201
- status: z34.literal("interrupted")
4210
+ z35.object({
4211
+ threadId: z35.string().min(1),
4212
+ status: z35.literal("interrupted")
4202
4213
  }).passthrough(),
4203
- z34.object({
4204
- threadId: z34.string().min(1),
4205
- status: z34.literal("skipped"),
4206
- detail: z34.string().min(1)
4214
+ z35.object({
4215
+ threadId: z35.string().min(1),
4216
+ status: z35.literal("skipped"),
4217
+ detail: z35.string().min(1)
4207
4218
  }).passthrough(),
4208
- z34.object({
4209
- threadId: z34.string().min(1),
4210
- status: z34.literal("failed"),
4211
- error: z34.string().min(1)
4219
+ z35.object({
4220
+ threadId: z35.string().min(1),
4221
+ status: z35.literal("failed"),
4222
+ error: z35.string().min(1)
4212
4223
  }).passthrough()
4213
4224
  ]);
4214
- var acpUpdateNotificationParamsSchema = z34.object({
4215
- threadId: z34.string().min(1),
4225
+ var acpUpdateNotificationParamsSchema = z35.object({
4226
+ threadId: z35.string().min(1),
4216
4227
  update: acpSessionUpdateSchema
4217
4228
  }).passthrough();
4218
- var acpFsWriteNotificationParamsSchema = z34.object({
4219
- threadId: z34.string().min(1),
4220
- path: z34.string().min(1),
4221
- kind: z34.enum(["add", "update"]),
4222
- oldText: z34.string().optional(),
4223
- content: z34.string()
4229
+ var acpFsWriteNotificationParamsSchema = z35.object({
4230
+ threadId: z35.string().min(1),
4231
+ path: z35.string().min(1),
4232
+ kind: z35.enum(["add", "update"]),
4233
+ oldText: z35.string().optional(),
4234
+ content: z35.string()
4224
4235
  }).passthrough();
4225
- var acpWarningNotificationParamsSchema = z34.object({
4226
- threadId: z34.string().min(1),
4227
- summary: z34.string().min(1),
4228
- details: z34.string().optional()
4236
+ var acpWarningNotificationParamsSchema = z35.object({
4237
+ threadId: z35.string().min(1),
4238
+ summary: z35.string().min(1),
4239
+ details: z35.string().optional()
4229
4240
  }).passthrough();
4230
4241
 
4231
4242
  // ../provider-bridge-acp/src/dialect.ts
4232
4243
  import { basename } from "node:path";
4233
- import { z as z38 } from "zod";
4244
+ import { z as z39 } from "zod";
4234
4245
 
4235
4246
  // ../provider-bridge-acp/src/bridge/provider-maintenance.ts
4236
4247
  import { execFile as execFile2 } from "node:child_process";
@@ -4240,7 +4251,7 @@ import os from "node:os";
4240
4251
  import path2 from "node:path";
4241
4252
  import { DatabaseSync } from "node:sqlite";
4242
4253
  import { promisify as promisify2 } from "node:util";
4243
- import { z as z35 } from "zod";
4254
+ import { z as z36 } from "zod";
4244
4255
  var execFileAsync2 = promisify2(execFile2);
4245
4256
  var USAGE_FETCH_TIMEOUT_MS = 15e3;
4246
4257
  var CURSOR_DASHBOARD_URL = "https://api2.cursor.sh/aiserver.v1.DashboardService";
@@ -4278,8 +4289,8 @@ async function readKeychainAccessToken() {
4278
4289
  return null;
4279
4290
  }
4280
4291
  }
4281
- var cursorFileCredentialsSchema = z35.object({
4282
- accessToken: z35.string().min(1).nullish()
4292
+ var cursorFileCredentialsSchema = z36.object({
4293
+ accessToken: z36.string().min(1).nullish()
4283
4294
  });
4284
4295
  async function readAccessToken() {
4285
4296
  const keychain = await readKeychainAccessToken();
@@ -4326,7 +4337,7 @@ function readAccountEmail() {
4326
4337
  database = new DatabaseSync(databasePath);
4327
4338
  database.exec("PRAGMA query_only = true");
4328
4339
  const row = database.prepare("SELECT value FROM ItemTable WHERE key = ?").get("cursorAuth/cachedEmail");
4329
- const parsed = z35.object({ value: z35.string().email() }).safeParse(row);
4340
+ const parsed = z36.object({ value: z36.string().email() }).safeParse(row);
4330
4341
  return parsed.success ? parsed.data.value : null;
4331
4342
  } catch {
4332
4343
  return null;
@@ -4430,14 +4441,14 @@ function buildAcpProviderInstallationRun(status, args) {
4430
4441
  verification: { kind: "installed" }
4431
4442
  };
4432
4443
  }
4433
- var cursorNonNegativeIntegerSchema = z35.union([
4434
- z35.number().int().nonnegative(),
4435
- z35.string().regex(/^\d+$/u).transform(Number)
4444
+ var cursorNonNegativeIntegerSchema = z36.union([
4445
+ z36.number().int().nonnegative(),
4446
+ z36.string().regex(/^\d+$/u).transform(Number)
4436
4447
  ]).refine(Number.isSafeInteger);
4437
- var cursorUsageResponseSchema = z35.object({
4448
+ var cursorUsageResponseSchema = z36.object({
4438
4449
  billingCycleEnd: cursorNonNegativeIntegerSchema.nullish(),
4439
- planUsage: z35.object({ totalPercentUsed: z35.number().nonnegative().default(0) }).nullish(),
4440
- spendLimitUsage: z35.object({
4450
+ planUsage: z36.object({ totalPercentUsed: z36.number().nonnegative().default(0) }).nullish(),
4451
+ spendLimitUsage: z36.object({
4441
4452
  overallLimit: cursorNonNegativeIntegerSchema.nullish(),
4442
4453
  overallUsed: cursorNonNegativeIntegerSchema.nullish(),
4443
4454
  individualLimit: cursorNonNegativeIntegerSchema.nullish(),
@@ -4446,8 +4457,8 @@ var cursorUsageResponseSchema = z35.object({
4446
4457
  pooledUsed: cursorNonNegativeIntegerSchema.nullish()
4447
4458
  }).nullish()
4448
4459
  }).passthrough();
4449
- var cursorPlanResponseSchema = z35.object({
4450
- planInfo: z35.object({ planName: z35.string().min(1) }).nullish()
4460
+ var cursorPlanResponseSchema = z36.object({
4461
+ planInfo: z36.object({ planName: z36.string().min(1) }).nullish()
4451
4462
  }).passthrough();
4452
4463
  function normalizeUsage(rawUsage, rawPlan, accountEmail = null) {
4453
4464
  const usage = cursorUsageResponseSchema.safeParse(rawUsage);
@@ -4659,17 +4670,17 @@ function toolKindPresentation(args) {
4659
4670
  }
4660
4671
 
4661
4672
  // ../provider-bridge-acp/src/tool-classification.ts
4662
- import { z as z37 } from "zod";
4673
+ import { z as z38 } from "zod";
4663
4674
 
4664
4675
  // ../provider-bridge-acp/src/tool-call-operation.ts
4665
4676
  import path3 from "node:path";
4666
- import { z as z36 } from "zod";
4667
- var acpRawInputCommandSchema = z36.object({ command: z36.string() }).passthrough();
4668
- var acpRawInputPathSchema = z36.object({
4669
- path: z36.string().optional(),
4670
- filePath: z36.string().optional(),
4671
- file_path: z36.string().optional(),
4672
- target_file: z36.string().optional()
4677
+ import { z as z37 } from "zod";
4678
+ var acpRawInputCommandSchema = z37.object({ command: z37.string() }).passthrough();
4679
+ var acpRawInputPathSchema = z37.object({
4680
+ path: z37.string().optional(),
4681
+ filePath: z37.string().optional(),
4682
+ file_path: z37.string().optional(),
4683
+ target_file: z37.string().optional()
4673
4684
  }).passthrough();
4674
4685
  function resolveAcpToolCallPath(value, options) {
4675
4686
  const cwd = options?.cwd;
@@ -4846,14 +4857,14 @@ function extractAcpToolCallOutputText(event) {
4846
4857
  ).trim();
4847
4858
  return rawOutputText.length > 0 ? rawOutputText : void 0;
4848
4859
  }
4849
- var commandRawOutputSchema = z37.object({
4850
- exitCode: z37.number().int().nullable().optional(),
4851
- exit_code: z37.number().int().nullable().optional(),
4852
- stdout: z37.string().optional(),
4853
- stderr: z37.string().optional(),
4854
- output_for_prompt: z37.string().optional(),
4855
- signal: z37.string().nullable().optional(),
4856
- timed_out: z37.boolean().optional()
4860
+ var commandRawOutputSchema = z38.object({
4861
+ exitCode: z38.number().int().nullable().optional(),
4862
+ exit_code: z38.number().int().nullable().optional(),
4863
+ stdout: z38.string().optional(),
4864
+ stderr: z38.string().optional(),
4865
+ output_for_prompt: z38.string().optional(),
4866
+ signal: z38.string().nullable().optional(),
4867
+ timed_out: z38.boolean().optional()
4857
4868
  }).passthrough();
4858
4869
  function emptyToUndefined(value) {
4859
4870
  return value === void 0 || value.length === 0 ? void 0 : value;
@@ -4922,10 +4933,10 @@ function extractAcpCommandResult(event) {
4922
4933
  ...output === void 0 ? {} : { output: scrubInlineImageDataUrls(output) }
4923
4934
  };
4924
4935
  }
4925
- var optionalNonBlank = z37.string().optional().transform(
4936
+ var optionalNonBlank = z38.string().optional().transform(
4926
4937
  (value) => value !== void 0 && value.trim().length > 0 ? value : void 0
4927
4938
  );
4928
- var searchRawInputSchema = z37.object({
4939
+ var searchRawInputSchema = z38.object({
4929
4940
  pattern: optionalNonBlank,
4930
4941
  query: optionalNonBlank,
4931
4942
  regex: optionalNonBlank,
@@ -4934,8 +4945,8 @@ var searchRawInputSchema = z37.object({
4934
4945
  path: optionalNonBlank,
4935
4946
  directory: optionalNonBlank
4936
4947
  }).passthrough();
4937
- var fetchRawInputSchema = z37.object({ url: optionalNonBlank, uri: optionalNonBlank }).passthrough();
4938
- var thinkRawInputSchema = z37.object({ thought: optionalNonBlank, thinking: optionalNonBlank }).passthrough();
4948
+ var fetchRawInputSchema = z38.object({ url: optionalNonBlank, uri: optionalNonBlank }).passthrough();
4949
+ var thinkRawInputSchema = z38.object({ thought: optionalNonBlank, thinking: optionalNonBlank }).passthrough();
4939
4950
  var SINGLE_TICKED_TOKEN_PATTERN = /^[^`]*`([^`\n]+)`[^`]*$/;
4940
4951
  var URL_PATTERN = /https?:\/\/[^\s`'"<>]+/g;
4941
4952
  function tickedTokenFromTitle(title) {
@@ -5128,10 +5139,10 @@ function classifyAcpToolCall2(event, injected, options) {
5128
5139
 
5129
5140
  // ../provider-bridge-acp/src/dialect.ts
5130
5141
  var GENERIC_ACP_DIALECT = { id: "acp" };
5131
- var grokToolMetaSchema = z38.object({
5132
- "x.ai/tool": z38.object({
5133
- name: z38.string().optional(),
5134
- kind: z38.string().optional()
5142
+ var grokToolMetaSchema = z39.object({
5143
+ "x.ai/tool": z39.object({
5144
+ name: z39.string().optional(),
5145
+ kind: z39.string().optional()
5135
5146
  }).passthrough()
5136
5147
  }).passthrough();
5137
5148
  function grokToolIdentity(event) {
@@ -5147,10 +5158,10 @@ function grokToolIdentity(event) {
5147
5158
  };
5148
5159
  }
5149
5160
  var GROK_SPAWN_SUBAGENT_TOOL = "spawn_subagent";
5150
- var grokSpawnSubagentInputSchema = z38.object({
5151
- description: z38.string().optional(),
5152
- prompt: z38.string().optional(),
5153
- subagent_type: z38.string().optional()
5161
+ var grokSpawnSubagentInputSchema = z39.object({
5162
+ description: z39.string().optional(),
5163
+ prompt: z39.string().optional(),
5164
+ subagent_type: z39.string().optional()
5154
5165
  }).passthrough();
5155
5166
  function grokClassifyToolCall(event) {
5156
5167
  if (grokToolIdentity(event)?.name !== GROK_SPAWN_SUBAGENT_TOOL) {
@@ -5179,14 +5190,14 @@ var GROK_ACP_DIALECT = {
5179
5190
  classifyToolCall: grokClassifyToolCall
5180
5191
  };
5181
5192
  var CURSOR_TASK_TOOL = "task";
5182
- var cursorTaskRawInputSchema = z38.object({ _toolName: z38.string().optional() }).passthrough();
5193
+ var cursorTaskRawInputSchema = z39.object({ _toolName: z39.string().optional() }).passthrough();
5183
5194
  var CURSOR_TASK_METHOD = "cursor/task";
5184
- var cursorTaskParamsSchema = z38.object({
5185
- toolCallId: z38.string(),
5186
- description: z38.string().optional(),
5187
- prompt: z38.string().optional(),
5188
- agentId: z38.string().optional(),
5189
- model: z38.string().optional()
5195
+ var cursorTaskParamsSchema = z39.object({
5196
+ toolCallId: z39.string(),
5197
+ description: z39.string().optional(),
5198
+ prompt: z39.string().optional(),
5199
+ agentId: z39.string().optional(),
5200
+ model: z39.string().optional()
5190
5201
  }).passthrough();
5191
5202
  function cursorClassifyToolCall(event) {
5192
5203
  const parsed = cursorTaskRawInputSchema.safeParse(event.rawInput);
@@ -5234,23 +5245,23 @@ var CURSOR_ACP_DIALECT = {
5234
5245
  handleClientRequest: cursorHandleClientRequest,
5235
5246
  maintenance: CURSOR_ACP_MAINTENANCE
5236
5247
  };
5237
- var ompBashRawInputSchema = z38.object({
5238
- command: z38.string(),
5239
- async: z38.boolean().optional()
5248
+ var ompBashRawInputSchema = z39.object({
5249
+ command: z39.string(),
5250
+ async: z39.boolean().optional()
5240
5251
  }).passthrough();
5241
5252
  var ompBashRawOutputSchema = commandRawOutputSchema.extend({
5242
- content: z38.array(
5243
- z38.object({
5244
- type: z38.literal("text"),
5245
- text: z38.string()
5253
+ content: z39.array(
5254
+ z39.object({
5255
+ type: z39.literal("text"),
5256
+ text: z39.string()
5246
5257
  }).passthrough()
5247
5258
  ),
5248
- details: z38.object({
5249
- exitCode: z38.number().int().optional(),
5250
- wallTimeMs: z38.number().nonnegative().optional(),
5251
- timedOut: z38.boolean().optional(),
5252
- signal: z38.unknown().optional(),
5253
- async: z38.unknown().optional()
5259
+ details: z39.object({
5260
+ exitCode: z39.number().int().optional(),
5261
+ wallTimeMs: z39.number().nonnegative().optional(),
5262
+ timedOut: z39.boolean().optional(),
5263
+ signal: z39.unknown().optional(),
5264
+ async: z39.unknown().optional()
5254
5265
  }).passthrough()
5255
5266
  });
5256
5267
  function stripOmpTrailingNotice(text, notice) {
@@ -5313,11 +5324,11 @@ var OMP_ACP_DIALECT = {
5313
5324
  id: "omp",
5314
5325
  commandResult: ompCommandResult
5315
5326
  };
5316
- var openCodeCommandRawOutputSchema = z38.object({
5317
- output: z38.unknown().optional(),
5318
- metadata: z38.object({
5319
- exit: z38.number().int().nullable().optional(),
5320
- output: z38.string().optional()
5327
+ var openCodeCommandRawOutputSchema = z39.object({
5328
+ output: z39.unknown().optional(),
5329
+ metadata: z39.object({
5330
+ exit: z39.number().int().nullable().optional(),
5331
+ output: z39.string().optional()
5321
5332
  }).passthrough().optional()
5322
5333
  }).passthrough();
5323
5334
  function normalizeOpenCodeCommandEvent(event) {
@@ -7235,7 +7246,7 @@ import { basename as basename2, dirname, join as join2, resolve as resolve2 } fr
7235
7246
  // ../provider-bridge-acp/src/bridge/tool-proxy-mcp.ts
7236
7247
  import { createConnection } from "node:net";
7237
7248
  import { createInterface as createInterface2 } from "node:readline";
7238
- import { z as z39 } from "zod";
7249
+ import { z as z40 } from "zod";
7239
7250
  var ACP_BRIDGE_MCP_SERVER_NAME = "bb-bridge";
7240
7251
  var ENV_HOST = "BB_ACP_DYNAMIC_TOOL_HOST";
7241
7252
  var ENV_PORT = "BB_ACP_DYNAMIC_TOOL_PORT";
@@ -7243,41 +7254,46 @@ var ENV_TOKEN = "BB_ACP_DYNAMIC_TOOL_TOKEN";
7243
7254
  var ENV_THREAD_ID = "BB_ACP_DYNAMIC_TOOL_THREAD_ID";
7244
7255
  var ENV_TOOLS = "BB_ACP_DYNAMIC_TOOLS";
7245
7256
  var ENV_PROGRESS_INTERVAL_MS = "BB_ACP_DYNAMIC_TOOL_PROGRESS_INTERVAL_MS";
7246
- var dynamicToolBridgeRequestSchema = z39.discriminatedUnion("kind", [
7247
- z39.object({
7248
- kind: z39.literal("initialized"),
7249
- threadId: z39.string().min(1),
7250
- token: z39.string().min(1),
7251
- toolCount: z39.number().int().nonnegative()
7257
+ var dynamicToolBridgeRequestSchema = z40.discriminatedUnion("kind", [
7258
+ z40.object({
7259
+ kind: z40.literal("initialized"),
7260
+ threadId: z40.string().min(1),
7261
+ token: z40.string().min(1),
7262
+ toolCount: z40.number().int().nonnegative()
7252
7263
  }),
7253
- z39.object({
7254
- kind: z39.literal("toolCall"),
7255
- arguments: z39.record(z39.string(), z39.unknown()).default({}),
7256
- callId: z39.string().min(1),
7257
- threadId: z39.string().min(1),
7258
- token: z39.string().min(1),
7259
- tool: z39.string().min(1)
7264
+ z40.object({
7265
+ kind: z40.literal("toolCall"),
7266
+ arguments: z40.record(z40.string(), z40.unknown()).default({}),
7267
+ callId: z40.string().min(1),
7268
+ threadId: z40.string().min(1),
7269
+ token: z40.string().min(1),
7270
+ tool: z40.string().min(1)
7260
7271
  })
7261
7272
  ]);
7262
- var bridgeToolCallResponseSchema = z39.union([
7263
- z39.object({
7264
- ok: z39.literal(true),
7265
- content: z39.string(),
7266
- contentBlocks: z39.array(
7267
- z39.discriminatedUnion("type", [
7268
- z39.object({ type: z39.literal("text"), text: z39.string() }),
7269
- z39.object({
7270
- type: z39.literal("image"),
7271
- data: z39.string(),
7272
- mimeType: z39.string()
7273
+ var bridgeToolCallResponseSchema = z40.union([
7274
+ z40.object({
7275
+ ok: z40.literal(true),
7276
+ content: z40.string(),
7277
+ contentBlocks: z40.array(
7278
+ z40.discriminatedUnion("type", [
7279
+ z40.object({ type: z40.literal("text"), text: z40.string() }),
7280
+ z40.object({
7281
+ type: z40.literal("image"),
7282
+ data: z40.string(),
7283
+ mimeType: z40.string()
7273
7284
  })
7274
7285
  ])
7275
7286
  ).optional(),
7276
- images: z39.array(z39.object({ data: z39.string(), mimeType: z39.string() })).default([]),
7277
- isError: z39.boolean().optional()
7287
+ images: z40.array(z40.object({ data: z40.string(), mimeType: z40.string() })).default([]),
7288
+ isError: z40.boolean().optional()
7278
7289
  }),
7279
- z39.object({ ok: z39.literal(false), error: z39.string() })
7290
+ z40.object({ ok: z40.literal(false), error: z40.string() })
7280
7291
  ]);
7292
+ var jsonRpcMessageSchema = z40.object({
7293
+ id: z40.union([z40.string(), z40.number().int()]).optional(),
7294
+ method: z40.string().optional(),
7295
+ params: z40.unknown().optional()
7296
+ });
7281
7297
  var nextMcpToolCallId = 0;
7282
7298
  var TOOL_CALL_PROGRESS_INTERVAL_MS = 15e3;
7283
7299
  function buildAcpMcpServerConfig(args) {
@@ -7334,9 +7350,16 @@ function mcpToolCallId(toolName) {
7334
7350
  nextMcpToolCallId += 1;
7335
7351
  return `acp-mcp-${toolName}-${Date.now()}-${nextMcpToolCallId}`;
7336
7352
  }
7337
- function callBridge(env, request) {
7353
+ function callBridge(env, request, signal) {
7338
7354
  return new Promise((resolve4, reject) => {
7339
7355
  const socket = createConnection({ host: env.host, port: env.port });
7356
+ const abort = () => {
7357
+ socket.destroy();
7358
+ reject(new Error("ACP dynamic tool call cancelled"));
7359
+ };
7360
+ signal?.addEventListener("abort", abort, { once: true });
7361
+ socket.once("close", () => signal?.removeEventListener("abort", abort));
7362
+ if (signal?.aborted) abort();
7340
7363
  let buffer = "";
7341
7364
  socket.setEncoding("utf8");
7342
7365
  socket.on("connect", () => {
@@ -7389,7 +7412,14 @@ function startProgressHeartbeat(args) {
7389
7412
  }, args.intervalMs ?? TOOL_CALL_PROGRESS_INTERVAL_MS);
7390
7413
  return () => clearInterval(timer);
7391
7414
  }
7392
- async function handleRequest(env, message) {
7415
+ async function handleRequest(env, message, pending) {
7416
+ if (message.method === PROVIDER_TOOL_CALL_CANCELLED_METHOD) {
7417
+ const cancellation = providerToolCallCancellationSchema.safeParse(
7418
+ message.params
7419
+ );
7420
+ if (cancellation.success) pending.get(cancellation.data.requestId)?.abort();
7421
+ return;
7422
+ }
7393
7423
  if (message.id === void 0 || message.method === void 0) {
7394
7424
  return;
7395
7425
  }
@@ -7420,6 +7450,7 @@ async function handleRequest(env, message) {
7420
7450
  });
7421
7451
  return;
7422
7452
  case "tools/call": {
7453
+ if (pending.has(message.id)) return;
7423
7454
  const params = objectParams(message.params);
7424
7455
  const name = typeof params.name === "string" ? params.name : "";
7425
7456
  const tool = env.tools.find((candidate) => candidate.name === name);
@@ -7429,20 +7460,29 @@ async function handleRequest(env, message) {
7429
7460
  }
7430
7461
  const rawArguments = params.arguments;
7431
7462
  const toolArguments = rawArguments && typeof rawArguments === "object" && !Array.isArray(rawArguments) ? rawArguments : {};
7463
+ const controller = new AbortController();
7464
+ pending.set(message.id, controller);
7432
7465
  const progressToken = readProgressToken(message.params);
7433
7466
  const stopHeartbeat = progressToken === null ? () => {
7434
7467
  } : startProgressHeartbeat({
7435
7468
  intervalMs: env.progressIntervalMs,
7436
7469
  progressToken
7437
7470
  });
7471
+ controller.signal.addEventListener("abort", stopHeartbeat, {
7472
+ once: true
7473
+ });
7438
7474
  try {
7439
- const result = await callBridge(env, {
7440
- kind: "toolCall",
7441
- arguments: toolArguments,
7442
- callId: mcpToolCallId(tool.name),
7443
- tool: tool.name
7444
- });
7445
- stopHeartbeat();
7475
+ const result = await callBridge(
7476
+ env,
7477
+ {
7478
+ kind: "toolCall",
7479
+ arguments: toolArguments,
7480
+ callId: mcpToolCallId(tool.name),
7481
+ tool: tool.name
7482
+ },
7483
+ controller.signal
7484
+ );
7485
+ if (controller.signal.aborted) return;
7446
7486
  if (!result.ok) {
7447
7487
  writeResult(message.id, {
7448
7488
  content: [{ type: "text", text: result.error }],
@@ -7455,7 +7495,7 @@ async function handleRequest(env, message) {
7455
7495
  ...result.isError ? { isError: true } : {}
7456
7496
  });
7457
7497
  } catch (error) {
7458
- stopHeartbeat();
7498
+ if (controller.signal.aborted) return;
7459
7499
  writeResult(message.id, {
7460
7500
  content: [
7461
7501
  {
@@ -7465,6 +7505,10 @@ async function handleRequest(env, message) {
7465
7505
  ],
7466
7506
  isError: true
7467
7507
  });
7508
+ } finally {
7509
+ stopHeartbeat();
7510
+ controller.signal.removeEventListener("abort", stopHeartbeat);
7511
+ pending.delete(message.id);
7468
7512
  }
7469
7513
  return;
7470
7514
  }
@@ -7478,7 +7522,11 @@ async function handleRequest(env, message) {
7478
7522
  }
7479
7523
  function runAcpDynamicToolMcpServer() {
7480
7524
  const env = readEnvironment();
7525
+ const pending = /* @__PURE__ */ new Map();
7481
7526
  const rl = createInterface2({ input: process.stdin, terminal: false });
7527
+ rl.on("close", () => {
7528
+ for (const controller of pending.values()) controller.abort();
7529
+ });
7482
7530
  rl.on("line", (line) => {
7483
7531
  const trimmed = line.trim();
7484
7532
  if (!trimmed) {
@@ -7486,11 +7534,11 @@ function runAcpDynamicToolMcpServer() {
7486
7534
  }
7487
7535
  let message;
7488
7536
  try {
7489
- message = JSON.parse(trimmed);
7537
+ message = jsonRpcMessageSchema.parse(JSON.parse(trimmed));
7490
7538
  } catch {
7491
7539
  return;
7492
7540
  }
7493
- void handleRequest(env, message);
7541
+ void handleRequest(env, message, pending);
7494
7542
  });
7495
7543
  }
7496
7544
 
@@ -7667,11 +7715,19 @@ var { send, sendResult, sendError } = createBridgeIo();
7667
7715
  function sendNotification(method, params) {
7668
7716
  send({ jsonrpc: "2.0", method, params });
7669
7717
  }
7670
- function sendRuntimeRequest(method, params) {
7718
+ function sendRuntimeRequest(method, params, signal) {
7719
+ signal?.throwIfAborted();
7671
7720
  runtimeRequestIdCounter += 1;
7672
7721
  const requestId = runtimeRequestIdCounter;
7722
+ let abort;
7673
7723
  const responsePromise = new Promise(
7674
7724
  (resolveResponse, rejectResponse) => {
7725
+ abort = () => {
7726
+ pendingRuntimeRequests.delete(requestId);
7727
+ sendNotification(PROVIDER_TOOL_CALL_CANCELLED_METHOD, { requestId });
7728
+ rejectResponse(new Error("ACP dynamic tool call cancelled"));
7729
+ };
7730
+ signal?.addEventListener("abort", abort, { once: true });
7675
7731
  pendingRuntimeRequests.set(requestId, (response) => {
7676
7732
  if ("error" in response) {
7677
7733
  rejectResponse(
@@ -7689,7 +7745,9 @@ function sendRuntimeRequest(method, params) {
7689
7745
  method,
7690
7746
  params
7691
7747
  });
7692
- return responsePromise;
7748
+ return responsePromise.finally(
7749
+ () => signal?.removeEventListener("abort", abort)
7750
+ );
7693
7751
  }
7694
7752
  var configuredSkillRoots = null;
7695
7753
  function sendThreadDeltas(threadId, deltas) {
@@ -7711,6 +7769,7 @@ function emitForSession(session, method, params) {
7711
7769
  );
7712
7770
  }
7713
7771
  function emitSessionError(session, message) {
7772
+ for (const controller of session.pendingToolCalls) controller.abort();
7714
7773
  if (session.activePromptKind !== null) {
7715
7774
  emitForSession(session, "error", {
7716
7775
  threadId: session.bbThreadId,
@@ -7733,40 +7792,53 @@ function resolveBridgeProcessEnvForMcpServer() {
7733
7792
  }
7734
7793
  return [{ name: "ELECTRON_RUN_AS_NODE", value: electronRunAsNode }];
7735
7794
  }
7736
- async function forwardDynamicToolCall(args) {
7795
+ async function forwardDynamicToolCall(args, signal) {
7737
7796
  const session = sessionsByBbThreadId.get(args.threadId);
7738
7797
  if (!session || !session.providerThreadId || session.stopping) {
7739
7798
  return { ok: false, error: "No active ACP session for dynamic tool call." };
7740
7799
  }
7800
+ const controller = new AbortController();
7801
+ session.pendingToolCalls.add(controller);
7741
7802
  session.translator.noteInjectedToolCall(session.bbThreadId, args.tool);
7742
7803
  try {
7743
- const result = await sendRuntimeRequest("item/tool/call", {
7744
- providerThreadId: session.providerThreadId,
7745
- threadId: session.bbThreadId,
7746
- turnId: null,
7747
- callId: args.callId,
7748
- tool: args.tool,
7749
- arguments: args.arguments
7750
- });
7804
+ const result = await sendRuntimeRequest(
7805
+ "item/tool/call",
7806
+ {
7807
+ providerThreadId: session.providerThreadId,
7808
+ threadId: session.bbThreadId,
7809
+ turnId: null,
7810
+ callId: args.callId,
7811
+ tool: args.tool,
7812
+ arguments: args.arguments
7813
+ },
7814
+ AbortSignal.any([signal, controller.signal])
7815
+ );
7751
7816
  return { ok: true, ...decodeToolCallResponsePayload(result) };
7752
7817
  } catch (error) {
7753
7818
  return {
7754
7819
  ok: false,
7755
7820
  error: error instanceof Error ? error.message : String(error)
7756
7821
  };
7822
+ } finally {
7823
+ session.pendingToolCalls.delete(controller);
7757
7824
  }
7758
7825
  }
7759
7826
  function handleDynamicToolBridgeSocket(bridge, socket) {
7827
+ const controller = new AbortController();
7828
+ socket.once("close", () => controller.abort());
7829
+ let handled = false;
7760
7830
  let buffer = "";
7761
7831
  socket.setEncoding("utf8");
7762
7832
  socket.on("error", () => {
7763
7833
  });
7764
7834
  socket.on("data", (chunk) => {
7835
+ if (handled) return;
7765
7836
  buffer += chunk;
7766
7837
  const newlineIndex = buffer.indexOf("\n");
7767
7838
  if (newlineIndex === -1) {
7768
7839
  return;
7769
7840
  }
7841
+ handled = true;
7770
7842
  const line = buffer.slice(0, newlineIndex);
7771
7843
  let parsed;
7772
7844
  try {
@@ -7793,10 +7865,13 @@ function handleDynamicToolBridgeSocket(bridge, socket) {
7793
7865
  `);
7794
7866
  return;
7795
7867
  }
7796
- void forwardDynamicToolCall(request.data).then((response) => {
7797
- socket.end(`${JSON.stringify(response)}
7868
+ void forwardDynamicToolCall(request.data, controller.signal).then(
7869
+ (response) => {
7870
+ if (controller.signal.aborted) return;
7871
+ socket.end(`${JSON.stringify(response)}
7798
7872
  `);
7799
- });
7873
+ }
7874
+ );
7800
7875
  });
7801
7876
  }
7802
7877
  async function ensureDynamicToolBridge() {
@@ -7991,7 +8066,7 @@ async function authenticateAcpAgent(args) {
7991
8066
  await args.connection.request({
7992
8067
  method: "authenticate",
7993
8068
  params: { methodId, _meta: { headless: true } },
7994
- resultSchema: z40.unknown()
8069
+ resultSchema: z41.unknown()
7995
8070
  });
7996
8071
  } catch (error) {
7997
8072
  throw new AcpAuthRequiredError(
@@ -8321,7 +8396,7 @@ async function selectAcpNativeModel(args) {
8321
8396
  configId: modelOption.id,
8322
8397
  value: selection.modelId
8323
8398
  },
8324
- resultSchema: z40.union([acpConfigStateResultSchema, z40.null()])
8399
+ resultSchema: z41.union([acpConfigStateResultSchema, z41.null()])
8325
8400
  });
8326
8401
  setModel = false;
8327
8402
  } catch {
@@ -8332,7 +8407,7 @@ async function selectAcpNativeModel(args) {
8332
8407
  configState = await args.connection.request({
8333
8408
  method: "session/set_model",
8334
8409
  params: { sessionId: args.sessionId, modelId: selection.modelId },
8335
- resultSchema: z40.union([acpConfigStateResultSchema, z40.null()])
8410
+ resultSchema: z41.union([acpConfigStateResultSchema, z41.null()])
8336
8411
  });
8337
8412
  }
8338
8413
  configOptions = configState?.configOptions ?? configOptions;
@@ -8643,6 +8718,7 @@ function liveSessionForThread(bbThreadId) {
8643
8718
  return session;
8644
8719
  }
8645
8720
  function removeSession(session) {
8721
+ for (const controller of session.pendingToolCalls) controller.abort();
8646
8722
  if (sessionsByBbThreadId.get(session.bbThreadId) === session) {
8647
8723
  sessionsByBbThreadId.delete(session.bbThreadId);
8648
8724
  }
@@ -8755,6 +8831,7 @@ async function startAgentSession(request) {
8755
8831
  stopping: false,
8756
8832
  turnSettled: void 0,
8757
8833
  pendingPermissions: /* @__PURE__ */ new Set(),
8834
+ pendingToolCalls: /* @__PURE__ */ new Set(),
8758
8835
  cursorMcpApproval: void 0,
8759
8836
  deferStartEmit: emitStartNotification
8760
8837
  };
@@ -8827,7 +8904,7 @@ async function startAgentSession(request) {
8827
8904
  cwd: params.cwd,
8828
8905
  mcpServers
8829
8906
  },
8830
- resultSchema: z40.union([acpConfigStateResultSchema, z40.null()])
8907
+ resultSchema: z41.union([acpConfigStateResultSchema, z41.null()])
8831
8908
  });
8832
8909
  loadedConfigOptions = configState?.configOptions;
8833
8910
  loadedModels = configState?.models;
@@ -9007,6 +9084,7 @@ function finishTurn(session, stopReason) {
9007
9084
  if (session.activePromptKind !== "turn") {
9008
9085
  return;
9009
9086
  }
9087
+ for (const controller of session.pendingToolCalls) controller.abort();
9010
9088
  session.activePromptKind = null;
9011
9089
  dropQueuedTurnInputs(session, "ACP turn ended before the steer was sent");
9012
9090
  session.promptRequestPending = false;
@@ -9272,12 +9350,12 @@ function decodeLaunchSpec(providerOptions) {
9272
9350
  );
9273
9351
  return launchSpec.success ? launchSpec.data : null;
9274
9352
  }
9275
- var acpProviderOptionsSchema = z40.object({
9276
- additionalWorkspaceWriteRoots: z40.array(z40.string()).optional(),
9277
- acpDialect: z40.string().min(1).optional(),
9278
- parameterizedModelPicker: z40.boolean().optional(),
9279
- primaryModels: z40.array(z40.string().min(1)).optional(),
9280
- reasoningProbePriorityModelIds: z40.array(z40.string().min(1)).optional()
9353
+ var acpProviderOptionsSchema = z41.object({
9354
+ additionalWorkspaceWriteRoots: z41.array(z41.string()).optional(),
9355
+ acpDialect: z41.string().min(1).optional(),
9356
+ parameterizedModelPicker: z41.boolean().optional(),
9357
+ primaryModels: z41.array(z41.string().min(1)).optional(),
9358
+ reasoningProbePriorityModelIds: z41.array(z41.string().min(1)).optional()
9281
9359
  }).passthrough();
9282
9360
  function decodeAcpModelPickerOptions(providerOptions) {
9283
9361
  const parsed = acpProviderOptionsSchema.parse(providerOptions ?? {});
@@ -9594,7 +9672,7 @@ var experimental_providerBridge = experimental_defineProviderBridge({
9594
9672
  });
9595
9673
 
9596
9674
  // ../provider-bridge-acp/src/probe.ts
9597
- import { z as z41 } from "zod";
9675
+ import { z as z42 } from "zod";
9598
9676
  var PROBE_TIMEOUT_MS = 1e4;
9599
9677
  function describe(error) {
9600
9678
  if (error instanceof AcpAgentExitedError) {
@@ -9652,9 +9730,9 @@ async function probeAcpAgent(request) {
9652
9730
  connected.kill();
9653
9731
  }
9654
9732
  }
9655
- var acpAgentProbeSchema = z41.union([
9656
- z41.object({ reachable: z41.literal(true), fork: z41.boolean() }),
9657
- z41.object({ reachable: z41.literal(false), reason: z41.string() })
9733
+ var acpAgentProbeSchema = z42.union([
9734
+ z42.object({ reachable: z42.literal(true), fork: z42.boolean() }),
9735
+ z42.object({ reachable: z42.literal(false), reason: z42.string() })
9658
9736
  ]);
9659
9737
  export {
9660
9738
  acpAgentProbeSchema as experimental_acpAgentProbeSchema,