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