@google/gemini-cli-core 0.68.0-preview.0 → 0.69.0-nightly.20261106.g3fd7d2634

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 (85) hide show
  1. package/dist/docs/changelogs/index.md +18 -0
  2. package/dist/docs/changelogs/latest.md +89 -84
  3. package/dist/docs/changelogs/preview.md +106 -92
  4. package/dist/docs/reference/commands.md +4 -0
  5. package/dist/docs/reference/policy-engine.md +6 -0
  6. package/dist/google-gemini-cli-core-0.69.0-nightly.20261104.g89e9d25d6.tgz +0 -0
  7. package/dist/src/agents/local-executor.js +31 -23
  8. package/dist/src/agents/local-executor.js.map +1 -1
  9. package/dist/src/agents/local-executor.test.js +59 -0
  10. package/dist/src/agents/local-executor.test.js.map +1 -1
  11. package/dist/src/config/models.js +6 -3
  12. package/dist/src/config/models.js.map +1 -1
  13. package/dist/src/config/models.test.js +21 -0
  14. package/dist/src/config/models.test.js.map +1 -1
  15. package/dist/src/confirmation-bus/types.d.ts +1 -0
  16. package/dist/src/confirmation-bus/types.js.map +1 -1
  17. package/dist/src/core/geminiChat.js +67 -29
  18. package/dist/src/core/geminiChat.js.map +1 -1
  19. package/dist/src/core/geminiChat.test.js +391 -0
  20. package/dist/src/core/geminiChat.test.js.map +1 -1
  21. package/dist/src/generated/git-commit.d.ts +2 -2
  22. package/dist/src/generated/git-commit.js +2 -2
  23. package/dist/src/generated/git-commit.js.map +1 -1
  24. package/dist/src/ide/types.d.ts +8 -8
  25. package/dist/src/index.d.ts +1 -0
  26. package/dist/src/index.js +1 -0
  27. package/dist/src/index.js.map +1 -1
  28. package/dist/src/policy/config.js +9 -0
  29. package/dist/src/policy/config.js.map +1 -1
  30. package/dist/src/policy/policies/yolo.toml +1 -0
  31. package/dist/src/policy/policy-engine.d.ts +1 -0
  32. package/dist/src/policy/policy-engine.js +31 -3
  33. package/dist/src/policy/policy-engine.js.map +1 -1
  34. package/dist/src/policy/policy-engine.test.js +1 -0
  35. package/dist/src/policy/policy-engine.test.js.map +1 -1
  36. package/dist/src/policy/policy-updater.test.js +11 -0
  37. package/dist/src/policy/policy-updater.test.js.map +1 -1
  38. package/dist/src/policy/shell-safety-regression.test.js +12 -3
  39. package/dist/src/policy/shell-safety-regression.test.js.map +1 -1
  40. package/dist/src/policy/shell-safety.test.js +116 -6
  41. package/dist/src/policy/shell-safety.test.js.map +1 -1
  42. package/dist/src/policy/toml-loader.js +4 -0
  43. package/dist/src/policy/toml-loader.js.map +1 -1
  44. package/dist/src/policy/toml-loader.test.js +21 -0
  45. package/dist/src/policy/toml-loader.test.js.map +1 -1
  46. package/dist/src/policy/types.d.ts +8 -0
  47. package/dist/src/policy/types.js.map +1 -1
  48. package/dist/src/prompts/utils.js +4 -4
  49. package/dist/src/prompts/utils.js.map +1 -1
  50. package/dist/src/prompts/utils.test.js +22 -0
  51. package/dist/src/prompts/utils.test.js.map +1 -1
  52. package/dist/src/scheduler/confirmation.d.ts +1 -0
  53. package/dist/src/scheduler/confirmation.js +12 -4
  54. package/dist/src/scheduler/confirmation.js.map +1 -1
  55. package/dist/src/scheduler/scheduler.js +8 -0
  56. package/dist/src/scheduler/scheduler.js.map +1 -1
  57. package/dist/src/scheduler/tool-executor.js +6 -1
  58. package/dist/src/scheduler/tool-executor.js.map +1 -1
  59. package/dist/src/scheduler/types.d.ts +1 -0
  60. package/dist/src/services/usageAggregator.d.ts +61 -0
  61. package/dist/src/services/usageAggregator.js +379 -0
  62. package/dist/src/services/usageAggregator.js.map +1 -0
  63. package/dist/src/services/usageAggregator.test.d.ts +6 -0
  64. package/dist/src/services/usageAggregator.test.js +257 -0
  65. package/dist/src/services/usageAggregator.test.js.map +1 -0
  66. package/dist/src/tools/mcp-client.test.js +48 -0
  67. package/dist/src/tools/mcp-client.test.js.map +1 -1
  68. package/dist/src/tools/shell.d.ts +2 -0
  69. package/dist/src/tools/shell.js +47 -4
  70. package/dist/src/tools/shell.js.map +1 -1
  71. package/dist/src/tools/shell.test.js +137 -0
  72. package/dist/src/tools/shell.test.js.map +1 -1
  73. package/dist/src/tools/tools.d.ts +3 -0
  74. package/dist/src/tools/tools.js.map +1 -1
  75. package/dist/src/utils/envExpansion.js +9 -4
  76. package/dist/src/utils/envExpansion.js.map +1 -1
  77. package/dist/src/utils/envExpansion.test.js +58 -0
  78. package/dist/src/utils/envExpansion.test.js.map +1 -1
  79. package/dist/src/utils/shell-utils.d.ts +1 -0
  80. package/dist/src/utils/shell-utils.js +899 -43
  81. package/dist/src/utils/shell-utils.js.map +1 -1
  82. package/dist/src/utils/shell-utils.test.js +113 -2
  83. package/dist/src/utils/shell-utils.test.js.map +1 -1
  84. package/dist/tsconfig.tsbuildinfo +1 -1
  85. package/package.json +1 -1
@@ -3833,6 +3833,35 @@ describe('GeminiChat', () => {
3833
3833
  expect(history).toHaveLength(2);
3834
3834
  expect(history[1].role).toBe('model');
3835
3835
  });
3836
+ it('should strip turns where all parts only contain thoughtSignature or empty text', () => {
3837
+ const chat = new GeminiChat(mockConfig, '', [], []);
3838
+ chat.setHistory([
3839
+ { role: 'user', parts: [{ text: 'User prompt' }] },
3840
+ {
3841
+ role: 'model',
3842
+ parts: [{ thoughtSignature: 'sig-only' }],
3843
+ },
3844
+ ]);
3845
+ const history = chat.getHistory(true);
3846
+ expect(history).toHaveLength(1);
3847
+ expect(history[0].role).toBe('user');
3848
+ });
3849
+ it('should preserve turns that contain valid parts alongside a trailing thoughtSignature-only part', () => {
3850
+ const chat = new GeminiChat(mockConfig, '', [], []);
3851
+ chat.setHistory([
3852
+ { role: 'user', parts: [{ text: 'User prompt' }] },
3853
+ {
3854
+ role: 'model',
3855
+ parts: [
3856
+ { text: 'Valid response text' },
3857
+ { thoughtSignature: 'sig-trailing' },
3858
+ ],
3859
+ },
3860
+ ]);
3861
+ const history = chat.getHistory(true);
3862
+ expect(history).toHaveLength(2);
3863
+ expect(history[1].role).toBe('model');
3864
+ });
3836
3865
  });
3837
3866
  describe('applyRetryNudge', () => {
3838
3867
  it('should return original contents if nudge message is empty', () => {
@@ -4396,6 +4425,328 @@ describe('GeminiChat', () => {
4396
4425
  { role: 'model', parts: [{ text: 'Continuing' }] },
4397
4426
  ]);
4398
4427
  });
4428
+ it('should close an unanswered tool response turn when the trailing model turn only has empty text with thoughtSignature (issue #30074)', async () => {
4429
+ chat.setHistory([
4430
+ {
4431
+ id: 'u1',
4432
+ content: { role: 'user', parts: [{ text: 'Describe image.png' }] },
4433
+ },
4434
+ {
4435
+ id: 'm1',
4436
+ content: {
4437
+ role: 'model',
4438
+ parts: [
4439
+ {
4440
+ functionCall: {
4441
+ id: 'read_file__call_1',
4442
+ name: 'read_file',
4443
+ args: { file_path: 'image.png' },
4444
+ },
4445
+ thoughtSignature: 'sig-call',
4446
+ },
4447
+ ],
4448
+ },
4449
+ },
4450
+ ]);
4451
+ // Turn 1: Send the image tool response; model stream yields only an empty text part with a thoughtSignature on STOP.
4452
+ vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValueOnce((async function* () {
4453
+ yield {
4454
+ candidates: [
4455
+ {
4456
+ content: {
4457
+ role: 'model',
4458
+ parts: [
4459
+ {
4460
+ text: '',
4461
+ thoughtSignature: 'sig-empty-stop',
4462
+ },
4463
+ ],
4464
+ },
4465
+ finishReason: 'STOP',
4466
+ },
4467
+ ],
4468
+ };
4469
+ })());
4470
+ const toolResponseStream = await chat.sendMessageStream({ model: 'gemini-3-flash-preview' }, [
4471
+ {
4472
+ functionResponse: {
4473
+ id: 'read_file__call_1',
4474
+ name: 'read_file',
4475
+ response: { output: 'Binary content provided (image/png).' },
4476
+ parts: [
4477
+ {
4478
+ inlineData: {
4479
+ mimeType: 'image/png',
4480
+ data: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=',
4481
+ },
4482
+ },
4483
+ ],
4484
+ },
4485
+ },
4486
+ ], 'prompt-image-read', new AbortController().signal, LlmRole.MAIN);
4487
+ for await (const _ of toolResponseStream) {
4488
+ // consume
4489
+ }
4490
+ // Turn 2: Empty response nudge sends 'Please continue.'
4491
+ let capturedNudgeContents;
4492
+ vi.mocked(mockContentGenerator.generateContentStream).mockImplementationOnce(async (params) => {
4493
+ capturedNudgeContents = params.contents;
4494
+ return (async function* () {
4495
+ yield {
4496
+ candidates: [
4497
+ {
4498
+ content: {
4499
+ role: 'model',
4500
+ parts: [{ text: 'The image is a 1x1 pixel PNG.' }],
4501
+ },
4502
+ finishReason: 'STOP',
4503
+ },
4504
+ ],
4505
+ };
4506
+ })();
4507
+ });
4508
+ const nudgeStream = await chat.sendMessageStream({ model: 'gemini-3-flash-preview' }, [{ text: CONTINUE_PROMPT_TEXT }], 'prompt-image-read', new AbortController().signal, LlmRole.MAIN);
4509
+ for await (const _ of nudgeStream) {
4510
+ // consume
4511
+ }
4512
+ expect(capturedNudgeContents).toBeDefined();
4513
+ expect(capturedNudgeContents.at(-2)).toEqual({
4514
+ role: 'model',
4515
+ parts: [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }],
4516
+ });
4517
+ expect(capturedNudgeContents.at(-1)).toEqual({
4518
+ role: 'user',
4519
+ parts: [{ text: CONTINUE_PROMPT_TEXT }],
4520
+ });
4521
+ });
4522
+ it('should populate a pre-existing trailing model turn containing only empty text and thoughtSignature in place', async () => {
4523
+ chat.setHistory([
4524
+ {
4525
+ id: 'u1',
4526
+ content: { role: 'user', parts: [{ text: 'Read image' }] },
4527
+ },
4528
+ {
4529
+ id: 'm1',
4530
+ content: {
4531
+ role: 'model',
4532
+ parts: [
4533
+ { functionCall: { id: 'c1', name: 'read_file', args: {} } },
4534
+ ],
4535
+ },
4536
+ },
4537
+ {
4538
+ id: 'u2',
4539
+ content: {
4540
+ role: 'user',
4541
+ parts: [
4542
+ {
4543
+ functionResponse: {
4544
+ id: 'c1',
4545
+ name: 'read_file',
4546
+ response: { output: 'ok' },
4547
+ },
4548
+ },
4549
+ ],
4550
+ },
4551
+ },
4552
+ {
4553
+ id: 'm2',
4554
+ content: {
4555
+ role: 'model',
4556
+ parts: [{ text: '', thoughtSignature: 'sig-only' }],
4557
+ },
4558
+ },
4559
+ ]);
4560
+ let capturedContents;
4561
+ vi.mocked(mockContentGenerator.generateContentStream).mockImplementationOnce(async (params) => {
4562
+ capturedContents = params.contents;
4563
+ return (async function* () {
4564
+ yield {
4565
+ candidates: [
4566
+ {
4567
+ content: { role: 'model', parts: [{ text: 'Done' }] },
4568
+ finishReason: 'STOP',
4569
+ },
4570
+ ],
4571
+ };
4572
+ })();
4573
+ });
4574
+ const stream = await chat.sendMessageStream({ model: 'gemini-3-flash-preview' }, 'Next prompt', 'prompt-thought-sig-model-turn', new AbortController().signal, LlmRole.MAIN);
4575
+ for await (const _ of stream) {
4576
+ // consume
4577
+ }
4578
+ expect(capturedContents).toBeDefined();
4579
+ expect(capturedContents.at(-2)).toEqual({
4580
+ role: 'model',
4581
+ parts: [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }],
4582
+ });
4583
+ expect(capturedContents.at(-1)).toEqual({
4584
+ role: 'user',
4585
+ parts: [{ text: 'Next prompt' }],
4586
+ });
4587
+ });
4588
+ it('should guarantee terminal user turn even when stripToolCallIdPrefixes removes a trailing user turn with only thoughtSignature', async () => {
4589
+ const apiHistoryOverride = [
4590
+ { role: 'user', parts: [{ text: 'Initial question' }] },
4591
+ { role: 'model', parts: [{ text: 'Initial answer' }] },
4592
+ {
4593
+ role: 'user',
4594
+ parts: [{ text: '', thoughtSignature: 'sig-empty' }],
4595
+ },
4596
+ ];
4597
+ let capturedContents;
4598
+ vi.mocked(mockContentGenerator.generateContentStream).mockImplementationOnce(async (params) => {
4599
+ capturedContents = params.contents;
4600
+ return (async function* () {
4601
+ yield {
4602
+ candidates: [
4603
+ {
4604
+ content: { role: 'model', parts: [{ text: 'Response' }] },
4605
+ finishReason: 'STOP',
4606
+ },
4607
+ ],
4608
+ };
4609
+ })();
4610
+ });
4611
+ const stream = await chat.sendMessageStream({ model: 'gemini-3-flash-preview' }, 'Follow-up', 'prompt-strip-then-ensure', new AbortController().signal, LlmRole.MAIN, undefined, apiHistoryOverride);
4612
+ for await (const _ of stream) {
4613
+ // consume
4614
+ }
4615
+ expect(capturedContents).toBeDefined();
4616
+ expect(capturedContents.at(-1)).toEqual({
4617
+ role: 'user',
4618
+ parts: [{ text: CONTINUE_PROMPT_TEXT }],
4619
+ });
4620
+ });
4621
+ it('should preserve role alternation and terminal user turn when apiHistoryOverride has an empty thoughtSignature model turn after a tool response', async () => {
4622
+ const apiHistoryOverride = [
4623
+ { role: 'user', parts: [{ text: 'Describe image.png' }] },
4624
+ {
4625
+ role: 'model',
4626
+ parts: [
4627
+ {
4628
+ functionCall: {
4629
+ id: 'read_file__call_1',
4630
+ name: 'read_file',
4631
+ args: { file_path: 'image.png' },
4632
+ },
4633
+ thoughtSignature: 'sig-call',
4634
+ },
4635
+ ],
4636
+ },
4637
+ {
4638
+ role: 'user',
4639
+ parts: [
4640
+ {
4641
+ functionResponse: {
4642
+ id: 'read_file__call_1',
4643
+ name: 'read_file',
4644
+ response: { output: 'Binary content provided (1 item(s)).' },
4645
+ },
4646
+ },
4647
+ {
4648
+ inlineData: {
4649
+ mimeType: 'image/png',
4650
+ data: 'base64data',
4651
+ },
4652
+ },
4653
+ ],
4654
+ },
4655
+ {
4656
+ role: 'model',
4657
+ parts: [{ text: '', thoughtSignature: 'sig-empty' }],
4658
+ },
4659
+ ];
4660
+ let capturedContents;
4661
+ vi.mocked(mockContentGenerator.generateContentStream).mockImplementationOnce(async (params) => {
4662
+ capturedContents = params.contents;
4663
+ return (async function* () {
4664
+ yield {
4665
+ candidates: [
4666
+ {
4667
+ content: {
4668
+ role: 'model',
4669
+ parts: [{ text: 'Image description' }],
4670
+ },
4671
+ finishReason: 'STOP',
4672
+ },
4673
+ ],
4674
+ };
4675
+ })();
4676
+ });
4677
+ const stream = await chat.sendMessageStream({ model: 'gemini-3-flash-preview' }, CONTINUE_PROMPT_TEXT, 'prompt-override-empty-model-after-tool', new AbortController().signal, LlmRole.MAIN, undefined, apiHistoryOverride);
4678
+ for await (const _ of stream) {
4679
+ // consume
4680
+ }
4681
+ expect(capturedContents).toBeDefined();
4682
+ expect(capturedContents.at(-2)).toEqual({
4683
+ role: 'model',
4684
+ parts: [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }],
4685
+ });
4686
+ expect(capturedContents.at(-1)).toEqual({
4687
+ role: 'user',
4688
+ parts: [{ text: CONTINUE_PROMPT_TEXT }],
4689
+ });
4690
+ });
4691
+ it('should prevent fusing a follow-up user turn into a tool response turn when stripToolCallIdPrefixes encounters an interior empty model turn', () => {
4692
+ const contents = [
4693
+ { role: 'user', parts: [{ text: 'Describe image.png' }] },
4694
+ {
4695
+ role: 'model',
4696
+ parts: [
4697
+ {
4698
+ functionCall: {
4699
+ id: 'read_file__call_1',
4700
+ name: 'read_file',
4701
+ args: { file_path: 'image.png' },
4702
+ },
4703
+ },
4704
+ ],
4705
+ },
4706
+ {
4707
+ role: 'user',
4708
+ parts: [
4709
+ {
4710
+ functionResponse: {
4711
+ id: 'read_file__call_1',
4712
+ name: 'read_file',
4713
+ response: { output: 'Binary content provided (1 item(s)).' },
4714
+ },
4715
+ },
4716
+ ],
4717
+ },
4718
+ {
4719
+ role: 'model',
4720
+ parts: [{ text: '', thoughtSignature: 'sig-empty' }],
4721
+ },
4722
+ {
4723
+ role: 'user',
4724
+ parts: [{ text: 'Please summarize the image.' }],
4725
+ },
4726
+ ];
4727
+ const stripped = stripToolCallIdPrefixes(contents);
4728
+ expect(stripped).toHaveLength(5);
4729
+ expect(stripped[2]).toEqual({
4730
+ role: 'user',
4731
+ parts: [
4732
+ {
4733
+ functionResponse: {
4734
+ id: 'call_1',
4735
+ name: 'read_file',
4736
+ response: { output: 'Binary content provided (1 item(s)).' },
4737
+ },
4738
+ },
4739
+ ],
4740
+ });
4741
+ expect(stripped[3]).toEqual({
4742
+ role: 'model',
4743
+ parts: [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }],
4744
+ });
4745
+ expect(stripped[4]).toEqual({
4746
+ role: 'user',
4747
+ parts: [{ text: 'Please summarize the image.' }],
4748
+ });
4749
+ });
4399
4750
  });
4400
4751
  describe('ensureTerminalUserTurn', () => {
4401
4752
  it('returns the same array when the last turn is a user turn with content', () => {
@@ -4563,6 +4914,46 @@ describe('GeminiChat', () => {
4563
4914
  ],
4564
4915
  });
4565
4916
  });
4917
+ it('drops parts that only contain empty text and thoughtSignature while keeping thoughtSignature on functionCall parts', () => {
4918
+ const result = stripToolCallIdPrefixes([
4919
+ {
4920
+ role: 'user',
4921
+ parts: [{ text: 'Read file' }],
4922
+ },
4923
+ {
4924
+ role: 'model',
4925
+ parts: [
4926
+ {
4927
+ text: '',
4928
+ functionCall: {
4929
+ id: 'read_file__1',
4930
+ name: 'read_file',
4931
+ args: { file_path: 'a.png' },
4932
+ },
4933
+ thoughtSignature: 'sig-keep',
4934
+ },
4935
+ {
4936
+ text: '',
4937
+ thoughtSignature: 'sig-drop',
4938
+ },
4939
+ {
4940
+ thoughtSignature: 'sig-drop-no-text',
4941
+ },
4942
+ ],
4943
+ },
4944
+ ]);
4945
+ expect(result).toHaveLength(2);
4946
+ expect(result[1].parts).toEqual([
4947
+ {
4948
+ functionCall: {
4949
+ id: '1',
4950
+ name: 'read_file',
4951
+ args: { file_path: 'a.png' },
4952
+ },
4953
+ thoughtSignature: 'sig-keep',
4954
+ },
4955
+ ]);
4956
+ });
4566
4957
  });
4567
4958
  describe('coalesceConsecutiveContents', () => {
4568
4959
  it('does not merge adjacent contents without a role', () => {