@google/gemini-cli-core 0.15.0-nightly.20251110.c0b766ad → 0.15.0-nightly.20251111.51f952e7

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.
Files changed (34) hide show
  1. package/dist/google-gemini-cli-core-0.15.0-nightly.20251107.b8eeb553.tgz +0 -0
  2. package/dist/src/core/coreToolScheduler.js +7 -1
  3. package/dist/src/core/coreToolScheduler.js.map +1 -1
  4. package/dist/src/core/coreToolScheduler.test.js +136 -357
  5. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  6. package/dist/src/generated/git-commit.d.ts +2 -2
  7. package/dist/src/generated/git-commit.js +2 -2
  8. package/dist/src/hooks/hookRunner.d.ts +42 -0
  9. package/dist/src/hooks/hookRunner.js +272 -0
  10. package/dist/src/hooks/hookRunner.js.map +1 -0
  11. package/dist/src/hooks/hookRunner.test.d.ts +6 -0
  12. package/dist/src/hooks/hookRunner.test.js +468 -0
  13. package/dist/src/hooks/hookRunner.test.js.map +1 -0
  14. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +1 -0
  15. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +1 -0
  16. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  17. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
  18. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +28 -1
  19. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
  20. package/dist/src/tools/mcp-client.js +22 -12
  21. package/dist/src/tools/mcp-client.js.map +1 -1
  22. package/dist/src/tools/mcp-client.test.js +6 -0
  23. package/dist/src/tools/mcp-client.test.js.map +1 -1
  24. package/dist/src/tools/modifiable-tool.d.ts +5 -1
  25. package/dist/src/tools/modifiable-tool.js +34 -13
  26. package/dist/src/tools/modifiable-tool.js.map +1 -1
  27. package/dist/src/tools/modifiable-tool.test.js +56 -22
  28. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  29. package/dist/src/tools/ripGrep.js +22 -30
  30. package/dist/src/tools/ripGrep.js.map +1 -1
  31. package/dist/src/tools/ripGrep.test.js +216 -24
  32. package/dist/src/tools/ripGrep.test.js.map +1 -1
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +1 -1
@@ -7,6 +7,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
7
7
  import { CoreToolScheduler, convertToFunctionResponse, truncateAndSaveToFile, } from './coreToolScheduler.js';
8
8
  import { DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES, DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD, BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, ApprovalMode, } from '../index.js';
9
9
  import { MockModifiableTool, MockTool, MOCK_TOOL_SHOULD_CONFIRM_EXECUTE, } from '../test-utils/mock-tool.js';
10
+ import * as modifiableToolModule from '../tools/modifiable-tool.js';
10
11
  import * as fs from 'node:fs/promises';
11
12
  import * as path from 'node:path';
12
13
  import { isShellInvocationAllowlisted } from '../utils/shell-utils.js';
@@ -122,6 +123,50 @@ async function waitForStatus(onToolCallsUpdate, status, timeout = 5000) {
122
123
  check();
123
124
  });
124
125
  }
126
+ function createMockConfig(overrides = {}) {
127
+ const defaultToolRegistry = {
128
+ getTool: () => undefined,
129
+ getToolByName: () => undefined,
130
+ getFunctionDeclarations: () => [],
131
+ tools: new Map(),
132
+ discovery: {},
133
+ registerTool: () => { },
134
+ getToolByDisplayName: () => undefined,
135
+ getTools: () => [],
136
+ discoverTools: async () => { },
137
+ getAllTools: () => [],
138
+ getToolsByServer: () => [],
139
+ };
140
+ const baseConfig = {
141
+ getSessionId: () => 'test-session-id',
142
+ getUsageStatisticsEnabled: () => true,
143
+ getDebugMode: () => false,
144
+ getApprovalMode: () => ApprovalMode.DEFAULT,
145
+ setApprovalMode: () => { },
146
+ getAllowedTools: () => [],
147
+ getContentGeneratorConfig: () => ({
148
+ model: 'test-model',
149
+ authType: 'oauth-personal',
150
+ }),
151
+ getShellExecutionConfig: () => ({
152
+ terminalWidth: 90,
153
+ terminalHeight: 30,
154
+ }),
155
+ storage: {
156
+ getProjectTempDir: () => '/tmp',
157
+ },
158
+ getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
159
+ getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
160
+ getToolRegistry: () => defaultToolRegistry,
161
+ getUseSmartEdit: () => false,
162
+ getUseModelRouter: () => false,
163
+ getGeminiClient: () => null,
164
+ getEnableMessageBusIntegration: () => false,
165
+ getMessageBus: () => null,
166
+ getPolicyEngine: () => null,
167
+ };
168
+ return { ...baseConfig, ...overrides };
169
+ }
125
170
  describe('CoreToolScheduler', () => {
126
171
  it('should cancel a tool call if the signal is aborted before confirmation', async () => {
127
172
  const mockTool = new MockTool({
@@ -144,33 +189,9 @@ describe('CoreToolScheduler', () => {
144
189
  };
145
190
  const onAllToolCallsComplete = vi.fn();
146
191
  const onToolCallsUpdate = vi.fn();
147
- const mockConfig = {
148
- getSessionId: () => 'test-session-id',
149
- getUsageStatisticsEnabled: () => true,
150
- getDebugMode: () => false,
151
- getApprovalMode: () => ApprovalMode.DEFAULT,
152
- getAllowedTools: () => [],
153
- getContentGeneratorConfig: () => ({
154
- model: 'test-model',
155
- authType: 'oauth-personal',
156
- }),
157
- getShellExecutionConfig: () => ({
158
- terminalWidth: 90,
159
- terminalHeight: 30,
160
- }),
161
- storage: {
162
- getProjectTempDir: () => '/tmp',
163
- },
164
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
165
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
192
+ const mockConfig = createMockConfig({
166
193
  getToolRegistry: () => mockToolRegistry,
167
- getUseSmartEdit: () => false,
168
- getUseModelRouter: () => false,
169
- getGeminiClient: () => null, // No client needed for these tests
170
- getEnableMessageBusIntegration: () => false,
171
- getMessageBus: () => null,
172
- getPolicyEngine: () => null,
173
- };
194
+ });
174
195
  const scheduler = new CoreToolScheduler({
175
196
  config: mockConfig,
176
197
  onAllToolCallsComplete,
@@ -231,33 +252,9 @@ describe('CoreToolScheduler', () => {
231
252
  };
232
253
  const onAllToolCallsComplete = vi.fn();
233
254
  const onToolCallsUpdate = vi.fn();
234
- const mockConfig = {
235
- getSessionId: () => 'test-session-id',
236
- getUsageStatisticsEnabled: () => true,
237
- getDebugMode: () => false,
238
- getApprovalMode: () => ApprovalMode.DEFAULT,
239
- getAllowedTools: () => [],
240
- getContentGeneratorConfig: () => ({
241
- model: 'test-model',
242
- authType: 'oauth-personal',
243
- }),
244
- getShellExecutionConfig: () => ({
245
- terminalWidth: 90,
246
- terminalHeight: 30,
247
- }),
248
- storage: {
249
- getProjectTempDir: () => '/tmp',
250
- },
251
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
252
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
255
+ const mockConfig = createMockConfig({
253
256
  getToolRegistry: () => mockToolRegistry,
254
- getUseSmartEdit: () => false,
255
- getUseModelRouter: () => false,
256
- getGeminiClient: () => null, // No client needed for these tests
257
- getEnableMessageBusIntegration: () => false,
258
- getMessageBus: () => null,
259
- getPolicyEngine: () => null,
260
- };
257
+ });
261
258
  const scheduler = new CoreToolScheduler({
262
259
  config: mockConfig,
263
260
  onAllToolCallsComplete,
@@ -344,33 +341,9 @@ describe('CoreToolScheduler', () => {
344
341
  };
345
342
  const onAllToolCallsComplete = vi.fn();
346
343
  const onToolCallsUpdate = vi.fn();
347
- const mockConfig = {
348
- getSessionId: () => 'test-session-id',
349
- getUsageStatisticsEnabled: () => true,
350
- getDebugMode: () => false,
351
- getApprovalMode: () => ApprovalMode.DEFAULT,
352
- getAllowedTools: () => [],
353
- getContentGeneratorConfig: () => ({
354
- model: 'test-model',
355
- authType: 'oauth-personal',
356
- }),
357
- getShellExecutionConfig: () => ({
358
- terminalWidth: 90,
359
- terminalHeight: 30,
360
- }),
361
- storage: {
362
- getProjectTempDir: () => '/tmp',
363
- },
364
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
365
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
344
+ const mockConfig = createMockConfig({
366
345
  getToolRegistry: () => mockToolRegistry,
367
- getUseSmartEdit: () => false,
368
- getUseModelRouter: () => false,
369
- getGeminiClient: () => null, // No client needed for these tests
370
- getEnableMessageBusIntegration: () => false,
371
- getMessageBus: () => null,
372
- getPolicyEngine: () => null,
373
- };
346
+ });
374
347
  const scheduler = new CoreToolScheduler({
375
348
  config: mockConfig,
376
349
  onAllToolCallsComplete,
@@ -438,33 +411,9 @@ describe('CoreToolScheduler', () => {
438
411
  };
439
412
  const onAllToolCallsComplete = vi.fn();
440
413
  const onToolCallsUpdate = vi.fn();
441
- const mockConfig = {
442
- getSessionId: () => 'test-session-id',
443
- getUsageStatisticsEnabled: () => true,
444
- getDebugMode: () => false,
445
- getApprovalMode: () => ApprovalMode.DEFAULT,
446
- getAllowedTools: () => [],
447
- getContentGeneratorConfig: () => ({
448
- model: 'test-model',
449
- authType: 'oauth-personal',
450
- }),
451
- getShellExecutionConfig: () => ({
452
- terminalWidth: 90,
453
- terminalHeight: 30,
454
- }),
455
- storage: {
456
- getProjectTempDir: () => '/tmp',
457
- },
458
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
459
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
414
+ const mockConfig = createMockConfig({
460
415
  getToolRegistry: () => mockToolRegistry,
461
- getUseSmartEdit: () => false,
462
- getUseModelRouter: () => false,
463
- getGeminiClient: () => null,
464
- getEnableMessageBusIntegration: () => false,
465
- getMessageBus: () => null,
466
- getPolicyEngine: () => null,
467
- };
416
+ });
468
417
  const scheduler = new CoreToolScheduler({
469
418
  config: mockConfig,
470
419
  onAllToolCallsComplete,
@@ -493,15 +442,9 @@ describe('CoreToolScheduler', () => {
493
442
  const mockToolRegistry = {
494
443
  getAllToolNames: () => ['list_files', 'read_file', 'write_file'],
495
444
  };
496
- const mockConfig = {
445
+ const mockConfig = createMockConfig({
497
446
  getToolRegistry: () => mockToolRegistry,
498
- getUseSmartEdit: () => false,
499
- getUseModelRouter: () => false,
500
- getGeminiClient: () => null, // No client needed for these tests
501
- getEnableMessageBusIntegration: () => false,
502
- getMessageBus: () => null,
503
- getPolicyEngine: () => null,
504
- };
447
+ });
505
448
  // Create scheduler
506
449
  const scheduler = new CoreToolScheduler({
507
450
  config: mockConfig,
@@ -543,33 +486,9 @@ describe('CoreToolScheduler with payload', () => {
543
486
  };
544
487
  const onAllToolCallsComplete = vi.fn();
545
488
  const onToolCallsUpdate = vi.fn();
546
- const mockConfig = {
547
- getSessionId: () => 'test-session-id',
548
- getUsageStatisticsEnabled: () => true,
549
- getDebugMode: () => false,
550
- getApprovalMode: () => ApprovalMode.DEFAULT,
551
- getAllowedTools: () => [],
552
- getContentGeneratorConfig: () => ({
553
- model: 'test-model',
554
- authType: 'oauth-personal',
555
- }),
556
- getShellExecutionConfig: () => ({
557
- terminalWidth: 90,
558
- terminalHeight: 30,
559
- }),
560
- storage: {
561
- getProjectTempDir: () => '/tmp',
562
- },
563
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
564
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
489
+ const mockConfig = createMockConfig({
565
490
  getToolRegistry: () => mockToolRegistry,
566
- getUseSmartEdit: () => false,
567
- getUseModelRouter: () => false,
568
- getGeminiClient: () => null, // No client needed for these tests
569
- getEnableMessageBusIntegration: () => false,
570
- getMessageBus: () => null,
571
- getPolicyEngine: () => null,
572
- };
491
+ });
573
492
  const scheduler = new CoreToolScheduler({
574
493
  config: mockConfig,
575
494
  onAllToolCallsComplete,
@@ -823,31 +742,9 @@ describe('CoreToolScheduler edit cancellation', () => {
823
742
  };
824
743
  const onAllToolCallsComplete = vi.fn();
825
744
  const onToolCallsUpdate = vi.fn();
826
- const mockConfig = {
827
- getSessionId: () => 'test-session-id',
828
- getUsageStatisticsEnabled: () => true,
829
- getDebugMode: () => false,
830
- getApprovalMode: () => ApprovalMode.DEFAULT,
831
- getAllowedTools: () => [],
832
- getContentGeneratorConfig: () => ({
833
- model: 'test-model',
834
- authType: 'oauth-personal',
835
- }),
836
- getShellExecutionConfig: () => ({
837
- terminalWidth: 90,
838
- terminalHeight: 30,
839
- }),
840
- storage: {
841
- getProjectTempDir: () => '/tmp',
842
- },
745
+ const mockConfig = createMockConfig({
843
746
  getToolRegistry: () => mockToolRegistry,
844
- getUseSmartEdit: () => false,
845
- getUseModelRouter: () => false,
846
- getGeminiClient: () => null, // No client needed for these tests
847
- getEnableMessageBusIntegration: () => false,
848
- getMessageBus: () => null,
849
- getPolicyEngine: () => null,
850
- };
747
+ });
851
748
  const scheduler = new CoreToolScheduler({
852
749
  config: mockConfig,
853
750
  onAllToolCallsComplete,
@@ -912,33 +809,10 @@ describe('CoreToolScheduler YOLO mode', () => {
912
809
  const onAllToolCallsComplete = vi.fn();
913
810
  const onToolCallsUpdate = vi.fn();
914
811
  // Configure the scheduler for YOLO mode.
915
- const mockConfig = {
916
- getSessionId: () => 'test-session-id',
917
- getUsageStatisticsEnabled: () => true,
918
- getDebugMode: () => false,
919
- getApprovalMode: () => ApprovalMode.YOLO,
920
- getAllowedTools: () => [],
921
- getContentGeneratorConfig: () => ({
922
- model: 'test-model',
923
- authType: 'oauth-personal',
924
- }),
925
- getShellExecutionConfig: () => ({
926
- terminalWidth: 90,
927
- terminalHeight: 30,
928
- }),
929
- storage: {
930
- getProjectTempDir: () => '/tmp',
931
- },
812
+ const mockConfig = createMockConfig({
932
813
  getToolRegistry: () => mockToolRegistry,
933
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
934
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
935
- getUseSmartEdit: () => false,
936
- getUseModelRouter: () => false,
937
- getGeminiClient: () => null, // No client needed for these tests
938
- getEnableMessageBusIntegration: () => false,
939
- getMessageBus: () => null,
940
- getPolicyEngine: () => null,
941
- };
814
+ getApprovalMode: () => ApprovalMode.YOLO,
815
+ });
942
816
  const scheduler = new CoreToolScheduler({
943
817
  config: mockConfig,
944
818
  onAllToolCallsComplete,
@@ -1009,33 +883,10 @@ describe('CoreToolScheduler request queueing', () => {
1009
883
  };
1010
884
  const onAllToolCallsComplete = vi.fn();
1011
885
  const onToolCallsUpdate = vi.fn();
1012
- const mockConfig = {
1013
- getSessionId: () => 'test-session-id',
1014
- getUsageStatisticsEnabled: () => true,
1015
- getDebugMode: () => false,
1016
- getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
1017
- getAllowedTools: () => [],
1018
- getContentGeneratorConfig: () => ({
1019
- model: 'test-model',
1020
- authType: 'oauth-personal',
1021
- }),
1022
- getShellExecutionConfig: () => ({
1023
- terminalWidth: 90,
1024
- terminalHeight: 30,
1025
- }),
1026
- storage: {
1027
- getProjectTempDir: () => '/tmp',
1028
- },
1029
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1030
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
886
+ const mockConfig = createMockConfig({
1031
887
  getToolRegistry: () => mockToolRegistry,
1032
- getUseSmartEdit: () => false,
1033
- getUseModelRouter: () => false,
1034
- getGeminiClient: () => null, // No client needed for these tests
1035
- getEnableMessageBusIntegration: () => false,
1036
- getMessageBus: () => null,
1037
- getPolicyEngine: () => null,
1038
- };
888
+ getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
889
+ });
1039
890
  const scheduler = new CoreToolScheduler({
1040
891
  config: mockConfig,
1041
892
  onAllToolCallsComplete,
@@ -1122,35 +973,14 @@ describe('CoreToolScheduler request queueing', () => {
1122
973
  const onAllToolCallsComplete = vi.fn();
1123
974
  const onToolCallsUpdate = vi.fn();
1124
975
  // Configure the scheduler to auto-approve the specific tool call.
1125
- const mockConfig = {
1126
- getSessionId: () => 'test-session-id',
1127
- getUsageStatisticsEnabled: () => true,
1128
- getDebugMode: () => false,
1129
- getApprovalMode: () => ApprovalMode.DEFAULT, // Not YOLO mode
976
+ const mockConfig = createMockConfig({
1130
977
  getAllowedTools: () => ['mockTool'], // Auto-approve this tool
1131
978
  getToolRegistry: () => toolRegistry,
1132
- getContentGeneratorConfig: () => ({
1133
- model: 'test-model',
1134
- authType: 'oauth-personal',
1135
- }),
1136
979
  getShellExecutionConfig: () => ({
1137
980
  terminalWidth: 80,
1138
981
  terminalHeight: 24,
1139
982
  }),
1140
- getTerminalWidth: vi.fn(() => 80),
1141
- getTerminalHeight: vi.fn(() => 24),
1142
- storage: {
1143
- getProjectTempDir: () => '/tmp',
1144
- },
1145
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1146
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1147
- getUseSmartEdit: () => false,
1148
- getUseModelRouter: () => false,
1149
- getGeminiClient: () => null, // No client needed for these tests
1150
- getEnableMessageBusIntegration: () => false,
1151
- getMessageBus: () => null,
1152
- getPolicyEngine: () => null,
1153
- };
983
+ });
1154
984
  const scheduler = new CoreToolScheduler({
1155
985
  config: mockConfig,
1156
986
  onAllToolCallsComplete,
@@ -1231,35 +1061,14 @@ describe('CoreToolScheduler request queueing', () => {
1231
1061
  };
1232
1062
  const onAllToolCallsComplete = vi.fn();
1233
1063
  const onToolCallsUpdate = vi.fn();
1234
- const mockConfig = {
1235
- getSessionId: () => 'test-session-id',
1236
- getUsageStatisticsEnabled: () => true,
1237
- getDebugMode: () => false,
1238
- getApprovalMode: () => ApprovalMode.DEFAULT,
1064
+ const mockConfig = createMockConfig({
1239
1065
  getAllowedTools: () => ['run_shell_command(git)'],
1240
- getContentGeneratorConfig: () => ({
1241
- model: 'test-model',
1242
- authType: 'oauth-personal',
1243
- }),
1244
1066
  getShellExecutionConfig: () => ({
1245
1067
  terminalWidth: 80,
1246
1068
  terminalHeight: 24,
1247
1069
  }),
1248
- getTerminalWidth: vi.fn(() => 80),
1249
- getTerminalHeight: vi.fn(() => 24),
1250
- storage: {
1251
- getProjectTempDir: () => '/tmp',
1252
- },
1253
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1254
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1255
1070
  getToolRegistry: () => toolRegistry,
1256
- getUseSmartEdit: () => false,
1257
- getUseModelRouter: () => false,
1258
- getGeminiClient: () => null,
1259
- getEnableMessageBusIntegration: () => false,
1260
- getMessageBus: () => null,
1261
- getPolicyEngine: () => null,
1262
- };
1071
+ });
1263
1072
  const scheduler = new CoreToolScheduler({
1264
1073
  config: mockConfig,
1265
1074
  onAllToolCallsComplete,
@@ -1305,33 +1114,10 @@ describe('CoreToolScheduler request queueing', () => {
1305
1114
  };
1306
1115
  const onAllToolCallsComplete = vi.fn();
1307
1116
  const onToolCallsUpdate = vi.fn();
1308
- const mockConfig = {
1309
- getSessionId: () => 'test-session-id',
1310
- getUsageStatisticsEnabled: () => true,
1311
- getDebugMode: () => false,
1312
- getApprovalMode: () => ApprovalMode.YOLO,
1313
- getAllowedTools: () => [],
1314
- getContentGeneratorConfig: () => ({
1315
- model: 'test-model',
1316
- authType: 'oauth-personal',
1317
- }),
1318
- getShellExecutionConfig: () => ({
1319
- terminalWidth: 90,
1320
- terminalHeight: 30,
1321
- }),
1322
- storage: {
1323
- getProjectTempDir: () => '/tmp',
1324
- },
1325
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1326
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1117
+ const mockConfig = createMockConfig({
1327
1118
  getToolRegistry: () => mockToolRegistry,
1328
- getUseSmartEdit: () => false,
1329
- getUseModelRouter: () => false,
1330
- getGeminiClient: () => null, // No client needed for these tests
1331
- getEnableMessageBusIntegration: () => false,
1332
- getMessageBus: () => null,
1333
- getPolicyEngine: () => null,
1334
- };
1119
+ getApprovalMode: () => ApprovalMode.YOLO,
1120
+ });
1335
1121
  const scheduler = new CoreToolScheduler({
1336
1122
  config: mockConfig,
1337
1123
  onAllToolCallsComplete,
@@ -1368,31 +1154,12 @@ describe('CoreToolScheduler request queueing', () => {
1368
1154
  });
1369
1155
  it('should auto-approve remaining tool calls when first tool call is approved with ProceedAlways', async () => {
1370
1156
  let approvalMode = ApprovalMode.DEFAULT;
1371
- const mockConfig = {
1372
- getSessionId: () => 'test-session-id',
1373
- getUsageStatisticsEnabled: () => true,
1374
- getDebugMode: () => false,
1157
+ const mockConfig = createMockConfig({
1375
1158
  getApprovalMode: () => approvalMode,
1376
- getAllowedTools: () => [],
1377
1159
  setApprovalMode: (mode) => {
1378
1160
  approvalMode = mode;
1379
1161
  },
1380
- getShellExecutionConfig: () => ({
1381
- terminalWidth: 90,
1382
- terminalHeight: 30,
1383
- }),
1384
- storage: {
1385
- getProjectTempDir: () => '/tmp',
1386
- },
1387
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1388
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1389
- getUseSmartEdit: () => false,
1390
- getUseModelRouter: () => false,
1391
- getGeminiClient: () => null, // No client needed for these tests
1392
- getEnableMessageBusIntegration: () => false,
1393
- getMessageBus: () => null,
1394
- getPolicyEngine: () => null,
1395
- };
1162
+ });
1396
1163
  const testTool = new TestApprovalTool(mockConfig);
1397
1164
  const toolRegistry = {
1398
1165
  getTool: () => testTool,
@@ -1530,32 +1297,10 @@ describe('CoreToolScheduler Sequential Execution', () => {
1530
1297
  };
1531
1298
  const onAllToolCallsComplete = vi.fn();
1532
1299
  const onToolCallsUpdate = vi.fn();
1533
- const mockConfig = {
1534
- getSessionId: () => 'test-session-id',
1535
- getUsageStatisticsEnabled: () => true,
1536
- getDebugMode: () => false,
1537
- getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
1538
- getAllowedTools: () => [],
1539
- getContentGeneratorConfig: () => ({
1540
- model: 'test-model',
1541
- authType: 'oauth-personal',
1542
- }),
1543
- getShellExecutionConfig: () => ({
1544
- terminalWidth: 90,
1545
- terminalHeight: 30,
1546
- }),
1547
- storage: {
1548
- getProjectTempDir: () => '/tmp',
1549
- },
1300
+ const mockConfig = createMockConfig({
1550
1301
  getToolRegistry: () => mockToolRegistry,
1551
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1552
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1553
- getUseSmartEdit: () => false,
1554
- getUseModelRouter: () => false,
1555
- getGeminiClient: () => null,
1556
- getEnableMessageBusIntegration: () => false,
1557
- getMessageBus: () => null,
1558
- };
1302
+ getApprovalMode: () => ApprovalMode.YOLO, // Use YOLO to avoid confirmation prompts
1303
+ });
1559
1304
  const scheduler = new CoreToolScheduler({
1560
1305
  config: mockConfig,
1561
1306
  onAllToolCallsComplete,
@@ -1638,32 +1383,10 @@ describe('CoreToolScheduler Sequential Execution', () => {
1638
1383
  };
1639
1384
  const onAllToolCallsComplete = vi.fn();
1640
1385
  const onToolCallsUpdate = vi.fn();
1641
- const mockConfig = {
1642
- getSessionId: () => 'test-session-id',
1643
- getUsageStatisticsEnabled: () => true,
1644
- getDebugMode: () => false,
1645
- getApprovalMode: () => ApprovalMode.YOLO,
1646
- getAllowedTools: () => [],
1647
- getContentGeneratorConfig: () => ({
1648
- model: 'test-model',
1649
- authType: 'oauth-personal',
1650
- }),
1651
- getShellExecutionConfig: () => ({
1652
- terminalWidth: 90,
1653
- terminalHeight: 30,
1654
- }),
1655
- storage: {
1656
- getProjectTempDir: () => '/tmp',
1657
- },
1386
+ const mockConfig = createMockConfig({
1658
1387
  getToolRegistry: () => mockToolRegistry,
1659
- getTruncateToolOutputThreshold: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
1660
- getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
1661
- getUseSmartEdit: () => false,
1662
- getUseModelRouter: () => false,
1663
- getGeminiClient: () => null,
1664
- getEnableMessageBusIntegration: () => false,
1665
- getMessageBus: () => null,
1666
- };
1388
+ getApprovalMode: () => ApprovalMode.YOLO,
1389
+ });
1667
1390
  const scheduler = new CoreToolScheduler({
1668
1391
  config: mockConfig,
1669
1392
  onAllToolCallsComplete,
@@ -1720,6 +1443,62 @@ describe('CoreToolScheduler Sequential Execution', () => {
1720
1443
  expect(call2?.status).toBe('cancelled');
1721
1444
  expect(call3?.status).toBe('cancelled');
1722
1445
  });
1446
+ it('should pass confirmation diff data into modifyWithEditor overrides', async () => {
1447
+ const modifyWithEditorSpy = vi
1448
+ .spyOn(modifiableToolModule, 'modifyWithEditor')
1449
+ .mockResolvedValue({
1450
+ updatedParams: { param: 'updated' },
1451
+ updatedDiff: 'updated diff',
1452
+ });
1453
+ const mockModifiableTool = new MockModifiableTool('mockModifiableTool');
1454
+ const mockToolRegistry = {
1455
+ getTool: () => mockModifiableTool,
1456
+ getToolByName: () => mockModifiableTool,
1457
+ getFunctionDeclarations: () => [],
1458
+ tools: new Map(),
1459
+ discovery: {},
1460
+ registerTool: () => { },
1461
+ getToolByDisplayName: () => mockModifiableTool,
1462
+ getTools: () => [],
1463
+ discoverTools: async () => { },
1464
+ getAllTools: () => [],
1465
+ getToolsByServer: () => [],
1466
+ };
1467
+ const onAllToolCallsComplete = vi.fn();
1468
+ const onToolCallsUpdate = vi.fn();
1469
+ const mockConfig = createMockConfig({
1470
+ getToolRegistry: () => mockToolRegistry,
1471
+ });
1472
+ const scheduler = new CoreToolScheduler({
1473
+ config: mockConfig,
1474
+ onAllToolCallsComplete,
1475
+ onToolCallsUpdate,
1476
+ getPreferredEditor: () => 'vscode',
1477
+ onEditorClose: vi.fn(),
1478
+ });
1479
+ const abortController = new AbortController();
1480
+ await scheduler.schedule([
1481
+ {
1482
+ callId: '1',
1483
+ name: 'mockModifiableTool',
1484
+ args: {},
1485
+ isClientInitiated: false,
1486
+ prompt_id: 'prompt-1',
1487
+ },
1488
+ ], abortController.signal);
1489
+ const toolCall = scheduler
1490
+ .toolCalls[0];
1491
+ expect(toolCall.status).toBe('awaiting_approval');
1492
+ const confirmationSignal = new AbortController().signal;
1493
+ await scheduler.handleConfirmationResponse(toolCall.request.callId, async () => { }, ToolConfirmationOutcome.ModifyWithEditor, confirmationSignal);
1494
+ expect(modifyWithEditorSpy).toHaveBeenCalled();
1495
+ const overrides = modifyWithEditorSpy.mock.calls[modifyWithEditorSpy.mock.calls.length - 1][5];
1496
+ expect(overrides).toEqual({
1497
+ currentContent: 'originalContent',
1498
+ proposedContent: 'newContent',
1499
+ });
1500
+ modifyWithEditorSpy.mockRestore();
1501
+ });
1723
1502
  });
1724
1503
  describe('truncateAndSaveToFile', () => {
1725
1504
  const mockWriteFile = vi.mocked(fs.writeFile);