@google/gemini-cli-core 0.7.0-preview.1 → 0.7.1
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.
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/src/config/config.d.ts +0 -7
- package/dist/src/config/config.js +1 -29
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/core/client.js +2 -1
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +39 -0
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +3 -12
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +0 -99
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +3 -4
- package/dist/src/core/geminiChat.js +52 -44
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +26 -115
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +2 -4
- package/dist/src/ide/detect-ide.js +1 -7
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +0 -23
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +1 -2
- package/dist/src/ide/ide-client.js +17 -22
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +2 -2
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +3 -4
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +2 -6
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +0 -34
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +1 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +0 -4
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -3
- package/dist/src/telemetry/constants.js +0 -3
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +1 -2
- package/dist/src/telemetry/index.js +1 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +1 -3
- package/dist/src/telemetry/loggers.js +2 -36
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +3 -31
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +1 -2
- package/dist/src/telemetry/metrics.js +1 -14
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/sdk.js +1 -4
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +0 -13
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +3 -18
- package/dist/src/telemetry/types.js +2 -28
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/tools/edit.js +0 -6
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +0 -41
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.js +2 -30
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +0 -117
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/ripGrep.js +1 -1
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +2 -2
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/smart-edit.js +0 -6
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +0 -45
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +3 -11
- package/dist/src/tools/tools.js +3 -94
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/telemetry/config.d.ts +0 -31
- package/dist/src/telemetry/config.js +0 -76
- package/dist/src/telemetry/config.js.map +0 -1
- package/dist/src/telemetry/config.test.d.ts +0 -6
- package/dist/src/telemetry/config.test.js +0 -124
- package/dist/src/telemetry/config.test.js.map +0 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +0 -6
- package/dist/src/tools/message-bus-integration.test.js +0 -183
- package/dist/src/tools/message-bus-integration.test.js.map +0 -1
- package/dist/src/tools/write-todos.d.ts +0 -25
- package/dist/src/tools/write-todos.js +0 -150
- package/dist/src/tools/write-todos.js.map +0 -1
- package/dist/src/tools/write-todos.test.d.ts +0 -6
- package/dist/src/tools/write-todos.test.js +0 -89
- package/dist/src/tools/write-todos.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/gemini-cli-core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Gemini CLI Core",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
|
|
25
25
|
"@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
|
|
26
26
|
"@google-cloud/logging": "^11.2.1",
|
|
27
|
-
"@joshua.litt/get-ripgrep": "^0.0.2",
|
|
28
27
|
"@modelcontextprotocol/sdk": "^1.11.0",
|
|
29
28
|
"@opentelemetry/api": "^1.9.0",
|
|
30
29
|
"@opentelemetry/exporter-logs-otlp-grpc": "^0.203.0",
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
"fast-uri": "^3.0.6",
|
|
49
48
|
"fdir": "^6.4.6",
|
|
50
49
|
"fzf": "^0.5.2",
|
|
50
|
+
"get-ripgrep": "file:../../third_party/get-ripgrep",
|
|
51
51
|
"glob": "^10.4.5",
|
|
52
52
|
"google-auth-library": "^9.11.0",
|
|
53
53
|
"html-to-text": "^9.0.5",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { TelemetrySettings } from '../config/config.js';
|
|
7
|
-
import { TelemetryTarget } from './index.js';
|
|
8
|
-
/**
|
|
9
|
-
* Parse a boolean environment flag. Accepts 'true'/'1' as true.
|
|
10
|
-
*/
|
|
11
|
-
export declare function parseBooleanEnvFlag(value: string | undefined): boolean | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Normalize a telemetry target value into TelemetryTarget or undefined.
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseTelemetryTargetValue(value: string | TelemetryTarget | undefined): TelemetryTarget | undefined;
|
|
16
|
-
export interface TelemetryArgOverrides {
|
|
17
|
-
telemetry?: boolean;
|
|
18
|
-
telemetryTarget?: string | TelemetryTarget;
|
|
19
|
-
telemetryOtlpEndpoint?: string;
|
|
20
|
-
telemetryOtlpProtocol?: string;
|
|
21
|
-
telemetryLogPrompts?: boolean;
|
|
22
|
-
telemetryOutfile?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Build TelemetrySettings by resolving from argv (highest), env, then settings.
|
|
26
|
-
*/
|
|
27
|
-
export declare function resolveTelemetrySettings(options: {
|
|
28
|
-
argv?: TelemetryArgOverrides;
|
|
29
|
-
env?: Record<string, string | undefined>;
|
|
30
|
-
settings?: TelemetrySettings;
|
|
31
|
-
}): Promise<TelemetrySettings>;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { FatalConfigError } from '../utils/errors.js';
|
|
7
|
-
import { TelemetryTarget } from './index.js';
|
|
8
|
-
/**
|
|
9
|
-
* Parse a boolean environment flag. Accepts 'true'/'1' as true.
|
|
10
|
-
*/
|
|
11
|
-
export function parseBooleanEnvFlag(value) {
|
|
12
|
-
if (value === undefined)
|
|
13
|
-
return undefined;
|
|
14
|
-
return value === 'true' || value === '1';
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Normalize a telemetry target value into TelemetryTarget or undefined.
|
|
18
|
-
*/
|
|
19
|
-
export function parseTelemetryTargetValue(value) {
|
|
20
|
-
if (value === undefined)
|
|
21
|
-
return undefined;
|
|
22
|
-
if (value === TelemetryTarget.LOCAL || value === 'local') {
|
|
23
|
-
return TelemetryTarget.LOCAL;
|
|
24
|
-
}
|
|
25
|
-
if (value === TelemetryTarget.GCP || value === 'gcp') {
|
|
26
|
-
return TelemetryTarget.GCP;
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Build TelemetrySettings by resolving from argv (highest), env, then settings.
|
|
32
|
-
*/
|
|
33
|
-
export async function resolveTelemetrySettings(options) {
|
|
34
|
-
const argv = options.argv ?? {};
|
|
35
|
-
const env = options.env ?? {};
|
|
36
|
-
const settings = options.settings ?? {};
|
|
37
|
-
const enabled = argv.telemetry ??
|
|
38
|
-
parseBooleanEnvFlag(env['GEMINI_TELEMETRY_ENABLED']) ??
|
|
39
|
-
settings.enabled;
|
|
40
|
-
const rawTarget = argv.telemetryTarget ??
|
|
41
|
-
env['GEMINI_TELEMETRY_TARGET'] ??
|
|
42
|
-
settings.target;
|
|
43
|
-
const target = parseTelemetryTargetValue(rawTarget);
|
|
44
|
-
if (rawTarget !== undefined && target === undefined) {
|
|
45
|
-
throw new FatalConfigError(`Invalid telemetry target: ${String(rawTarget)}. Valid values are: local, gcp`);
|
|
46
|
-
}
|
|
47
|
-
const otlpEndpoint = argv.telemetryOtlpEndpoint ??
|
|
48
|
-
env['GEMINI_TELEMETRY_OTLP_ENDPOINT'] ??
|
|
49
|
-
env['OTEL_EXPORTER_OTLP_ENDPOINT'] ??
|
|
50
|
-
settings.otlpEndpoint;
|
|
51
|
-
const rawProtocol = argv.telemetryOtlpProtocol ??
|
|
52
|
-
env['GEMINI_TELEMETRY_OTLP_PROTOCOL'] ??
|
|
53
|
-
settings.otlpProtocol;
|
|
54
|
-
const otlpProtocol = ['grpc', 'http'].find((p) => p === rawProtocol);
|
|
55
|
-
if (rawProtocol !== undefined && otlpProtocol === undefined) {
|
|
56
|
-
throw new FatalConfigError(`Invalid telemetry OTLP protocol: ${String(rawProtocol)}. Valid values are: grpc, http`);
|
|
57
|
-
}
|
|
58
|
-
const logPrompts = argv.telemetryLogPrompts ??
|
|
59
|
-
parseBooleanEnvFlag(env['GEMINI_TELEMETRY_LOG_PROMPTS']) ??
|
|
60
|
-
settings.logPrompts;
|
|
61
|
-
const outfile = argv.telemetryOutfile ??
|
|
62
|
-
env['GEMINI_TELEMETRY_OUTFILE'] ??
|
|
63
|
-
settings.outfile;
|
|
64
|
-
const useCollector = parseBooleanEnvFlag(env['GEMINI_TELEMETRY_USE_COLLECTOR']) ??
|
|
65
|
-
settings.useCollector;
|
|
66
|
-
return {
|
|
67
|
-
enabled,
|
|
68
|
-
target,
|
|
69
|
-
otlpEndpoint,
|
|
70
|
-
otlpProtocol,
|
|
71
|
-
logPrompts,
|
|
72
|
-
outfile,
|
|
73
|
-
useCollector,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../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-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { describe, it, expect } from 'vitest';
|
|
7
|
-
import { parseBooleanEnvFlag, parseTelemetryTargetValue, resolveTelemetrySettings, } from './config.js';
|
|
8
|
-
import { TelemetryTarget } from './index.js';
|
|
9
|
-
describe('telemetry/config helpers', () => {
|
|
10
|
-
describe('parseBooleanEnvFlag', () => {
|
|
11
|
-
it('returns undefined for undefined', () => {
|
|
12
|
-
expect(parseBooleanEnvFlag(undefined)).toBeUndefined();
|
|
13
|
-
});
|
|
14
|
-
it('parses true values', () => {
|
|
15
|
-
expect(parseBooleanEnvFlag('true')).toBe(true);
|
|
16
|
-
expect(parseBooleanEnvFlag('1')).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
it('parses false/other values as false', () => {
|
|
19
|
-
expect(parseBooleanEnvFlag('false')).toBe(false);
|
|
20
|
-
expect(parseBooleanEnvFlag('0')).toBe(false);
|
|
21
|
-
expect(parseBooleanEnvFlag('TRUE')).toBe(false);
|
|
22
|
-
expect(parseBooleanEnvFlag('random')).toBe(false);
|
|
23
|
-
expect(parseBooleanEnvFlag('')).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('parseTelemetryTargetValue', () => {
|
|
27
|
-
it('parses string values', () => {
|
|
28
|
-
expect(parseTelemetryTargetValue('local')).toBe(TelemetryTarget.LOCAL);
|
|
29
|
-
expect(parseTelemetryTargetValue('gcp')).toBe(TelemetryTarget.GCP);
|
|
30
|
-
});
|
|
31
|
-
it('accepts enum values', () => {
|
|
32
|
-
expect(parseTelemetryTargetValue(TelemetryTarget.LOCAL)).toBe(TelemetryTarget.LOCAL);
|
|
33
|
-
expect(parseTelemetryTargetValue(TelemetryTarget.GCP)).toBe(TelemetryTarget.GCP);
|
|
34
|
-
});
|
|
35
|
-
it('returns undefined for unknown', () => {
|
|
36
|
-
expect(parseTelemetryTargetValue('other')).toBeUndefined();
|
|
37
|
-
expect(parseTelemetryTargetValue(undefined)).toBeUndefined();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('resolveTelemetrySettings', () => {
|
|
41
|
-
it('falls back to settings when no argv/env provided', async () => {
|
|
42
|
-
const settings = {
|
|
43
|
-
enabled: false,
|
|
44
|
-
target: TelemetryTarget.LOCAL,
|
|
45
|
-
otlpEndpoint: 'http://localhost:4317',
|
|
46
|
-
otlpProtocol: 'grpc',
|
|
47
|
-
logPrompts: false,
|
|
48
|
-
outfile: 'settings.log',
|
|
49
|
-
useCollector: false,
|
|
50
|
-
};
|
|
51
|
-
const resolved = await resolveTelemetrySettings({ settings });
|
|
52
|
-
expect(resolved).toEqual(settings);
|
|
53
|
-
});
|
|
54
|
-
it('uses env over settings and argv over env', async () => {
|
|
55
|
-
const settings = {
|
|
56
|
-
enabled: false,
|
|
57
|
-
target: TelemetryTarget.LOCAL,
|
|
58
|
-
otlpEndpoint: 'http://settings:4317',
|
|
59
|
-
otlpProtocol: 'grpc',
|
|
60
|
-
logPrompts: false,
|
|
61
|
-
outfile: 'settings.log',
|
|
62
|
-
useCollector: false,
|
|
63
|
-
};
|
|
64
|
-
const env = {
|
|
65
|
-
GEMINI_TELEMETRY_ENABLED: '1',
|
|
66
|
-
GEMINI_TELEMETRY_TARGET: 'gcp',
|
|
67
|
-
GEMINI_TELEMETRY_OTLP_ENDPOINT: 'http://env:4317',
|
|
68
|
-
GEMINI_TELEMETRY_OTLP_PROTOCOL: 'http',
|
|
69
|
-
GEMINI_TELEMETRY_LOG_PROMPTS: 'true',
|
|
70
|
-
GEMINI_TELEMETRY_OUTFILE: 'env.log',
|
|
71
|
-
GEMINI_TELEMETRY_USE_COLLECTOR: 'true',
|
|
72
|
-
};
|
|
73
|
-
const argv = {
|
|
74
|
-
telemetry: false,
|
|
75
|
-
telemetryTarget: 'local',
|
|
76
|
-
telemetryOtlpEndpoint: 'http://argv:4317',
|
|
77
|
-
telemetryOtlpProtocol: 'grpc',
|
|
78
|
-
telemetryLogPrompts: false,
|
|
79
|
-
telemetryOutfile: 'argv.log',
|
|
80
|
-
};
|
|
81
|
-
const resolvedEnv = await resolveTelemetrySettings({ env, settings });
|
|
82
|
-
expect(resolvedEnv).toEqual({
|
|
83
|
-
enabled: true,
|
|
84
|
-
target: TelemetryTarget.GCP,
|
|
85
|
-
otlpEndpoint: 'http://env:4317',
|
|
86
|
-
otlpProtocol: 'http',
|
|
87
|
-
logPrompts: true,
|
|
88
|
-
outfile: 'env.log',
|
|
89
|
-
useCollector: true,
|
|
90
|
-
});
|
|
91
|
-
const resolvedArgv = await resolveTelemetrySettings({
|
|
92
|
-
argv,
|
|
93
|
-
env,
|
|
94
|
-
settings,
|
|
95
|
-
});
|
|
96
|
-
expect(resolvedArgv).toEqual({
|
|
97
|
-
enabled: false,
|
|
98
|
-
target: TelemetryTarget.LOCAL,
|
|
99
|
-
otlpEndpoint: 'http://argv:4317',
|
|
100
|
-
otlpProtocol: 'grpc',
|
|
101
|
-
logPrompts: false,
|
|
102
|
-
outfile: 'argv.log',
|
|
103
|
-
useCollector: true, // from env as no argv option
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
it('falls back to OTEL_EXPORTER_OTLP_ENDPOINT when GEMINI var is missing', async () => {
|
|
107
|
-
const settings = {};
|
|
108
|
-
const env = {
|
|
109
|
-
OTEL_EXPORTER_OTLP_ENDPOINT: 'http://otel:4317',
|
|
110
|
-
};
|
|
111
|
-
const resolved = await resolveTelemetrySettings({ env, settings });
|
|
112
|
-
expect(resolved.otlpEndpoint).toBe('http://otel:4317');
|
|
113
|
-
});
|
|
114
|
-
it('throws on unknown protocol values', async () => {
|
|
115
|
-
const env = { GEMINI_TELEMETRY_OTLP_PROTOCOL: 'unknown' };
|
|
116
|
-
await expect(resolveTelemetrySettings({ env })).rejects.toThrow(/Invalid telemetry OTLP protocol/i);
|
|
117
|
-
});
|
|
118
|
-
it('throws on unknown target values', async () => {
|
|
119
|
-
const env = { GEMINI_TELEMETRY_TARGET: 'unknown' };
|
|
120
|
-
await expect(resolveTelemetrySettings({ env })).rejects.toThrow(/Invalid telemetry target/i);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
//# sourceMappingURL=config.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.test.js","sourceRoot":"","sources":["../../../src/telemetry/config.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACzC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACzD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;YAC5B,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACjD,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC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AC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,GAAG,GAAG,EAAE,uBAAuB,EAAE,SAAS,EAG/C,CAAC;YACF,MAAM,MAAM,CAAC,wBAAwB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAC7D,2BAA2B,CAC5B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { describe, it, expect, beforeEach, afterEach, vi, } from 'vitest';
|
|
7
|
-
import { BaseToolInvocation, BaseDeclarativeTool, Kind, } from './tools.js';
|
|
8
|
-
import { MessageBus } from '../confirmation-bus/message-bus.js';
|
|
9
|
-
import { PolicyEngine } from '../policy/policy-engine.js';
|
|
10
|
-
import { MessageBusType, } from '../confirmation-bus/types.js';
|
|
11
|
-
import { randomUUID } from 'node:crypto';
|
|
12
|
-
// Mock crypto module
|
|
13
|
-
vi.mock('node:crypto', () => ({
|
|
14
|
-
randomUUID: vi.fn(),
|
|
15
|
-
}));
|
|
16
|
-
class TestToolInvocation extends BaseToolInvocation {
|
|
17
|
-
getDescription() {
|
|
18
|
-
return `Test tool with param: ${this.params.testParam}`;
|
|
19
|
-
}
|
|
20
|
-
async execute() {
|
|
21
|
-
return {
|
|
22
|
-
llmContent: `Executed with ${this.params.testParam}`,
|
|
23
|
-
returnDisplay: `Test result: ${this.params.testParam}`,
|
|
24
|
-
testValue: this.params.testParam,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
class TestTool extends BaseDeclarativeTool {
|
|
29
|
-
constructor(messageBus) {
|
|
30
|
-
super('test-tool', 'Test Tool', 'A test tool for message bus integration', Kind.Other, {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
testParam: { type: 'string' },
|
|
34
|
-
},
|
|
35
|
-
required: ['testParam'],
|
|
36
|
-
}, true, false, messageBus);
|
|
37
|
-
}
|
|
38
|
-
createInvocation(params, messageBus) {
|
|
39
|
-
return new TestToolInvocation(params, messageBus);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
describe('Message Bus Integration', () => {
|
|
43
|
-
let policyEngine;
|
|
44
|
-
let messageBus;
|
|
45
|
-
let mockUUID;
|
|
46
|
-
beforeEach(() => {
|
|
47
|
-
vi.resetAllMocks();
|
|
48
|
-
policyEngine = new PolicyEngine();
|
|
49
|
-
messageBus = new MessageBus(policyEngine);
|
|
50
|
-
mockUUID = vi.mocked(randomUUID);
|
|
51
|
-
mockUUID.mockReturnValue('test-correlation-id');
|
|
52
|
-
});
|
|
53
|
-
afterEach(() => {
|
|
54
|
-
vi.restoreAllMocks();
|
|
55
|
-
});
|
|
56
|
-
describe('BaseToolInvocation with MessageBus', () => {
|
|
57
|
-
it('should use message bus for confirmation when available', async () => {
|
|
58
|
-
const tool = new TestTool(messageBus);
|
|
59
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
60
|
-
// Mock message bus publish and subscribe
|
|
61
|
-
const publishSpy = vi.spyOn(messageBus, 'publish');
|
|
62
|
-
const subscribeSpy = vi.spyOn(messageBus, 'subscribe');
|
|
63
|
-
const unsubscribeSpy = vi.spyOn(messageBus, 'unsubscribe');
|
|
64
|
-
// Start confirmation process
|
|
65
|
-
const confirmationPromise = invocation.shouldConfirmExecute(new AbortController().signal);
|
|
66
|
-
// Verify confirmation request was published
|
|
67
|
-
expect(publishSpy).toHaveBeenCalledWith({
|
|
68
|
-
type: MessageBusType.TOOL_CONFIRMATION_REQUEST,
|
|
69
|
-
toolCall: {
|
|
70
|
-
name: 'TestToolInvocation',
|
|
71
|
-
args: { testParam: 'test-value' },
|
|
72
|
-
},
|
|
73
|
-
correlationId: 'test-correlation-id',
|
|
74
|
-
});
|
|
75
|
-
// Verify subscription to response
|
|
76
|
-
expect(subscribeSpy).toHaveBeenCalledWith(MessageBusType.TOOL_CONFIRMATION_RESPONSE, expect.any(Function));
|
|
77
|
-
// Simulate confirmation response
|
|
78
|
-
const responseHandler = subscribeSpy.mock.calls[0][1];
|
|
79
|
-
const response = {
|
|
80
|
-
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
81
|
-
correlationId: 'test-correlation-id',
|
|
82
|
-
confirmed: true,
|
|
83
|
-
};
|
|
84
|
-
responseHandler(response);
|
|
85
|
-
const result = await confirmationPromise;
|
|
86
|
-
expect(result).toBe(false); // No further confirmation needed
|
|
87
|
-
expect(unsubscribeSpy).toHaveBeenCalled();
|
|
88
|
-
});
|
|
89
|
-
it('should reject promise when confirmation is denied', async () => {
|
|
90
|
-
const tool = new TestTool(messageBus);
|
|
91
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
92
|
-
const subscribeSpy = vi.spyOn(messageBus, 'subscribe');
|
|
93
|
-
const confirmationPromise = invocation.shouldConfirmExecute(new AbortController().signal);
|
|
94
|
-
// Simulate denial response
|
|
95
|
-
const responseHandler = subscribeSpy.mock.calls[0][1];
|
|
96
|
-
const response = {
|
|
97
|
-
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
98
|
-
correlationId: 'test-correlation-id',
|
|
99
|
-
confirmed: false,
|
|
100
|
-
};
|
|
101
|
-
responseHandler(response);
|
|
102
|
-
// Should reject with error when denied
|
|
103
|
-
await expect(confirmationPromise).rejects.toThrow('Tool execution denied by policy');
|
|
104
|
-
});
|
|
105
|
-
it('should handle timeout', async () => {
|
|
106
|
-
vi.useFakeTimers();
|
|
107
|
-
const tool = new TestTool(messageBus);
|
|
108
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
109
|
-
const confirmationPromise = invocation.shouldConfirmExecute(new AbortController().signal);
|
|
110
|
-
// Fast-forward past timeout
|
|
111
|
-
vi.advanceTimersByTime(30000);
|
|
112
|
-
const result = await confirmationPromise;
|
|
113
|
-
expect(result).toBe(false);
|
|
114
|
-
vi.useRealTimers();
|
|
115
|
-
});
|
|
116
|
-
it('should handle abort signal', async () => {
|
|
117
|
-
const tool = new TestTool(messageBus);
|
|
118
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
119
|
-
const abortController = new AbortController();
|
|
120
|
-
const confirmationPromise = invocation.shouldConfirmExecute(abortController.signal);
|
|
121
|
-
// Abort the operation
|
|
122
|
-
abortController.abort();
|
|
123
|
-
await expect(confirmationPromise).rejects.toThrow('Tool confirmation aborted');
|
|
124
|
-
});
|
|
125
|
-
it('should fall back to default behavior when no message bus', async () => {
|
|
126
|
-
const tool = new TestTool(); // No message bus
|
|
127
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
128
|
-
const result = await invocation.shouldConfirmExecute(new AbortController().signal);
|
|
129
|
-
expect(result).toBe(false);
|
|
130
|
-
});
|
|
131
|
-
it('should ignore responses with wrong correlation ID', async () => {
|
|
132
|
-
vi.useFakeTimers();
|
|
133
|
-
const tool = new TestTool(messageBus);
|
|
134
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
135
|
-
const subscribeSpy = vi.spyOn(messageBus, 'subscribe');
|
|
136
|
-
const confirmationPromise = invocation.shouldConfirmExecute(new AbortController().signal);
|
|
137
|
-
// Send response with wrong correlation ID
|
|
138
|
-
const responseHandler = subscribeSpy.mock.calls[0][1];
|
|
139
|
-
const wrongResponse = {
|
|
140
|
-
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
141
|
-
correlationId: 'wrong-id',
|
|
142
|
-
confirmed: true,
|
|
143
|
-
};
|
|
144
|
-
responseHandler(wrongResponse);
|
|
145
|
-
// Should timeout since correct response wasn't received
|
|
146
|
-
vi.advanceTimersByTime(30000);
|
|
147
|
-
const result = await confirmationPromise;
|
|
148
|
-
expect(result).toBe(false);
|
|
149
|
-
vi.useRealTimers();
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
describe('Backward Compatibility', () => {
|
|
153
|
-
it('should work with existing tools that do not use message bus', async () => {
|
|
154
|
-
const tool = new TestTool(); // No message bus
|
|
155
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
156
|
-
// Should execute normally
|
|
157
|
-
const result = await invocation.execute(new AbortController().signal);
|
|
158
|
-
expect(result.testValue).toBe('test-value');
|
|
159
|
-
expect(result.llmContent).toBe('Executed with test-value');
|
|
160
|
-
});
|
|
161
|
-
it('should work with tools that have message bus but use default confirmation', async () => {
|
|
162
|
-
const tool = new TestTool(messageBus);
|
|
163
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
164
|
-
// Should execute normally even with message bus available
|
|
165
|
-
const result = await invocation.execute(new AbortController().signal);
|
|
166
|
-
expect(result.testValue).toBe('test-value');
|
|
167
|
-
expect(result.llmContent).toBe('Executed with test-value');
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
describe('Error Handling', () => {
|
|
171
|
-
it('should handle message bus publish errors gracefully', async () => {
|
|
172
|
-
const tool = new TestTool(messageBus);
|
|
173
|
-
const invocation = tool.build({ testParam: 'test-value' });
|
|
174
|
-
// Mock publish to throw error
|
|
175
|
-
vi.spyOn(messageBus, 'publish').mockImplementation(() => {
|
|
176
|
-
throw new Error('Message bus error');
|
|
177
|
-
});
|
|
178
|
-
const result = await invocation.shouldConfirmExecute(new AbortController().signal);
|
|
179
|
-
expect(result).toBe(false); // Should gracefully fall back
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
//# sourceMappingURL=message-bus-integration.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-bus-integration.test.js","sourceRoot":"","sources":["../../../src/tools/message-bus-integration.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,QAAQ,EACR,EAAE,EACF,MAAM,EACN,UAAU,EACV,SAAS,EACT,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CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;YACnE,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;YACtC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;YAE3D,8BAA8B;YAC9B,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE;gBACtD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,oBAAoB,CAClD,IAAI,eAAe,EAAE,CAAC,MAAM,CAC7B,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,8BAA8B;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import type { ToolInvocation } from './tools.js';
|
|
7
|
-
import { BaseDeclarativeTool, type ToolResult } from './tools.js';
|
|
8
|
-
export declare const WRITE_TODOS_DESCRIPTION = "This tool can help you list out the current subtasks that are required to be completed for a given user request. The list of subtasks helps you keep track of the current task, organize complex queries and help ensure that you don't miss any steps. With this list, the user can also see the current progress you are making in executing a given task.\n\nDepending on the task complexity, you should first divide a given task into subtasks and then use this tool to list out the subtasks that are required to be completed for a given user request.\nEach of the subtasks should be clear and distinct. \n\nUse this tool for complex queries that require multiple steps. If you find that the request is actually complex after you have started executing the user task, create a todo list and use it. If execution of the user task requires multiple steps, planning and generally is higher complexity than a simple Q&A, use this tool.\n\nDO NOT use this tool for simple tasks that can be completed in less than 2 steps. If the user query is simple and straightforward, do not use the tool. If you can respond with an answer in a single turn then this tool is not required.\n\n## Task state definitions\n\n- pending: Work has not begun on a given subtask.\n- in_progress: Marked just prior to beginning work on a given subtask. You should only have one subtask as in_progress at a time.\n- completed: Subtask was succesfully completed with no errors or issues. If the subtask required more steps to complete, update the todo list with the subtasks. All steps should be identified as completed only when they are completed.\n- cancelled: As you update the todo list, some tasks are not required anymore due to the dynamic nature of the task. In this case, mark the subtasks as cancelled.\n\n\n## Methodology for using this tool\n1. Use this todo list list as soon as you receive a user request based on the complexity of the task.\n2. Keep track of every subtask that you update the list with.\n3. Mark a subtask as in_progress before you begin working on it. You should only have one subtask as in_progress at a time.\n4. Update the subtask list as you proceed in executing the task. The subtask list is not static and should reflect your progress and current plans, which may evolve as you acquire new information.\n5. Mark a subtask as completed when you have completed it.\n6. Mark a subtask as cancelled if the subtask is no longer needed.\n7. You must update the todo list as soon as you start, stop or cancel a subtask. Don't batch or wait to update the todo list.\n\n\n## Examples of When to Use the Todo List\n\n<example>\nUser request: Create a website with a React for creating fancy logos using gemini-2.5-flash-image\n\nToDo list created by the agent:\n1. Initialize a new React project environment (e.g., using Vite).\n2. Design and build the core UI components: a text input (prompt field) for the logo description, selection controls for style parameters (if the API supports them), and an image preview area.\n3. Implement state management (e.g., React Context or Zustand) to manage the user's input prompt, the API loading status (pending, success, error), and the resulting image data.\n4. Create an API service module within the React app (using \"fetch\" or \"axios\") to securely format and send the prompt data via an HTTP POST request to the specified \"gemini-2.5-flash-image\" (Gemini model) endpoint.\n5. Implement asynchronous logic to handle the API call: show a loading indicator while the request is pending, retrieve the generated image (e.g., as a URL or base64 string) upon success, and display any errors.\n6. Display the returned \"fancy logo\" from the API response in the preview area component.\n7. Add functionality (e.g., a \"Download\" button) to allow the user to save the generated image file.\n8. Deploy the application to a web server or hosting platform.\n\n<reasoning>\nThe agent used the todo list to break the task into distinct, manageable steps:\n1. Building an entire interactive web application from scratch is a highly complex, multi-stage process involving setup, UI development, logic integration, and deployment.\n2. The agent inferred the core functionality required for a \"logo creator,\" such as UI controls for customization (Task 3) and an export feature (Task 7), which must be tracked as distinct goals.\n3. The agent rightly inferred the requirement of an API service model for interacting with the image model endpoint.\n</reasoning>\n</example>\n\n\n## Examples of When NOT to Use the Todo List\n\n<example>\nUser request: Ensure that the test <test file> passes.\n\nAgent:\n<Goes into a loop of running the test, identifying errors, and updating the code until the test passes.>\n\n<reasoning>\nThe agent did not use the todo list because this task could be completed by a tight loop of execute test->edit->execute test.\n</reasoning>\n</example>\n";
|
|
9
|
-
export type TodoStatus = 'pending' | 'in_progress' | 'completed' | 'cancelled';
|
|
10
|
-
export interface Todo {
|
|
11
|
-
description: string;
|
|
12
|
-
status: TodoStatus;
|
|
13
|
-
}
|
|
14
|
-
export interface WriteTodosToolParams {
|
|
15
|
-
/**
|
|
16
|
-
* The full list of todos. This will overwrite any existing list.
|
|
17
|
-
*/
|
|
18
|
-
todos: Todo[];
|
|
19
|
-
}
|
|
20
|
-
export declare class WriteTodosTool extends BaseDeclarativeTool<WriteTodosToolParams, ToolResult> {
|
|
21
|
-
static readonly Name: string;
|
|
22
|
-
constructor();
|
|
23
|
-
protected validateToolParamValues(params: WriteTodosToolParams): string | null;
|
|
24
|
-
protected createInvocation(params: WriteTodosToolParams): ToolInvocation<WriteTodosToolParams, ToolResult>;
|
|
25
|
-
}
|