@google/gemini-cli-core 0.31.0 → 0.33.0-nightly.20260228.1ca5c05d0
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/docs/changelogs/index.md +22 -0
- package/dist/docs/changelogs/latest.md +307 -352
- package/dist/docs/changelogs/preview.md +391 -293
- package/dist/docs/cli/cli-reference.md +12 -12
- package/dist/docs/cli/custom-commands.md +9 -0
- package/dist/docs/cli/enterprise.md +19 -0
- package/dist/docs/cli/model.md +5 -14
- package/dist/docs/cli/plan-mode.md +29 -7
- package/dist/docs/cli/sandbox.md +42 -2
- package/dist/docs/cli/settings.md +15 -6
- package/dist/docs/cli/telemetry.md +68 -11
- package/dist/docs/cli/tutorials/automation.md +101 -5
- package/dist/docs/cli/tutorials/mcp-setup.md +8 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +8 -0
- package/dist/docs/extensions/reference.md +36 -0
- package/dist/docs/extensions/writing-extensions.md +16 -0
- package/dist/docs/get-started/authentication.md +86 -5
- package/dist/docs/get-started/installation.md +2 -2
- package/dist/docs/hooks/best-practices.md +33 -1
- package/dist/docs/hooks/writing-hooks.md +24 -0
- package/dist/docs/ide-integration/index.md +8 -0
- package/dist/docs/local-development.md +49 -43
- package/dist/docs/reference/configuration.md +48 -7
- package/dist/docs/reference/keyboard-shortcuts.md +6 -6
- package/dist/docs/reference/policy-engine.md +14 -3
- package/dist/docs/resources/faq.md +21 -0
- package/dist/docs/resources/tos-privacy.md +6 -0
- package/dist/docs/resources/troubleshooting.md +4 -1
- package/dist/docs/resources/uninstall.md +1 -10
- package/dist/docs/tools/mcp-server.md +22 -0
- package/dist/google-gemini-cli-core-0.33.0-nightly.20260227.08ee13613.tgz +0 -0
- package/dist/src/agents/a2a-client-manager.d.ts +7 -6
- package/dist/src/agents/a2a-client-manager.js +8 -9
- package/dist/src/agents/a2a-client-manager.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.test.js +45 -31
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -1
- package/dist/src/agents/a2aUtils.d.ts +25 -7
- package/dist/src/agents/a2aUtils.js +165 -58
- package/dist/src/agents/a2aUtils.js.map +1 -1
- package/dist/src/agents/a2aUtils.test.js +170 -27
- package/dist/src/agents/a2aUtils.test.js.map +1 -1
- package/dist/src/agents/generalist-agent.js +1 -2
- package/dist/src/agents/generalist-agent.js.map +1 -1
- package/dist/src/agents/registry.test.js +4 -2
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.d.ts +2 -1
- package/dist/src/agents/remote-invocation.js +41 -22
- package/dist/src/agents/remote-invocation.js.map +1 -1
- package/dist/src/agents/remote-invocation.test.js +196 -56
- package/dist/src/agents/remote-invocation.test.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.js +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +1 -1
- package/dist/src/agents/subagent-tool.js +15 -2
- package/dist/src/agents/subagent-tool.js.map +1 -1
- package/dist/src/agents/subagent-tool.test.js +31 -0
- package/dist/src/agents/subagent-tool.test.js.map +1 -1
- package/dist/src/billing/billing.d.ts +80 -0
- package/dist/src/billing/billing.js +127 -0
- package/dist/src/billing/billing.js.map +1 -0
- package/dist/src/billing/billing.test.d.ts +6 -0
- package/dist/src/billing/billing.test.js +182 -0
- package/dist/src/billing/billing.test.js.map +1 -0
- package/dist/src/billing/index.d.ts +6 -0
- package/dist/src/billing/index.js +7 -0
- package/dist/src/billing/index.js.map +1 -0
- package/dist/src/code_assist/codeAssist.js +1 -1
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.js +2 -2
- package/dist/src/code_assist/codeAssist.test.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +9 -4
- package/dist/src/code_assist/converter.js +17 -2
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +6 -3
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +1 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +9 -4
- package/dist/src/code_assist/server.js +86 -5
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +11 -0
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +2 -1
- package/dist/src/code_assist/setup.js +15 -4
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +33 -10
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/config/config.d.ts +50 -4
- package/dist/src/config/config.js +77 -3
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +151 -1
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +1 -0
- package/dist/src/config/storage.js +3 -0
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +3 -2
- package/dist/src/core/contentGenerator.js +9 -2
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +2 -1
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +21 -2
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +2 -1
- package/dist/src/core/fakeContentGenerator.js +1 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -1
- package/dist/src/core/geminiChat.js +6 -2
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +34 -0
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/localLiteRtLmClient.d.ts +24 -0
- package/dist/src/core/localLiteRtLmClient.js +77 -0
- package/dist/src/core/localLiteRtLmClient.js.map +1 -0
- package/dist/src/core/localLiteRtLmClient.test.d.ts +6 -0
- package/dist/src/core/localLiteRtLmClient.test.js +87 -0
- package/dist/src/core/localLiteRtLmClient.test.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.d.ts +3 -1
- package/dist/src/core/loggingContentGenerator.js +65 -17
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +164 -5
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts.test.js +1 -1
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/fallback/handler.js +2 -0
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/types.d.ts +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/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/policy/config.d.ts +18 -6
- package/dist/src/policy/config.js +50 -12
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +26 -26
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/policies/plan.toml +1 -1
- package/dist/src/policy/policy-engine.d.ts +8 -0
- package/dist/src/policy/policy-engine.js +12 -0
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +93 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/toml-loader.d.ts +1 -1
- package/dist/src/policy/toml-loader.js +4 -2
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +15 -12
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/workspace-policy.test.js +10 -10
- package/dist/src/prompts/snippets.js +43 -27
- package/dist/src/prompts/snippets.js.map +1 -1
- package/dist/src/routing/modelRouterService.js +19 -11
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +38 -1
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/routingStrategy.d.ts +3 -2
- package/dist/src/routing/strategies/classifierStrategy.d.ts +2 -1
- package/dist/src/routing/strategies/classifierStrategy.js +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +15 -13
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.d.ts +2 -1
- package/dist/src/routing/strategies/compositeStrategy.js +3 -3
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.test.js +10 -8
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/defaultStrategy.d.ts +2 -1
- package/dist/src/routing/strategies/defaultStrategy.js +1 -1
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -1
- package/dist/src/routing/strategies/defaultStrategy.test.js +8 -4
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +2 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +6 -5
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/gemmaClassifierStrategy.d.ts +14 -0
- package/dist/src/routing/strategies/gemmaClassifierStrategy.js +182 -0
- package/dist/src/routing/strategies/gemmaClassifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/gemmaClassifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/gemmaClassifierStrategy.test.js +218 -0
- package/dist/src/routing/strategies/gemmaClassifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.d.ts +2 -1
- package/dist/src/routing/strategies/numericalClassifierStrategy.js +1 -1
- package/dist/src/routing/strategies/numericalClassifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js +24 -22
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.d.ts +2 -1
- package/dist/src/routing/strategies/overrideStrategy.js +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +5 -4
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
- package/dist/src/scheduler/scheduler.d.ts +1 -0
- package/dist/src/scheduler/scheduler.js +18 -7
- package/dist/src/scheduler/scheduler.js.map +1 -1
- package/dist/src/scheduler/scheduler.test.js +19 -1
- package/dist/src/scheduler/scheduler.test.js.map +1 -1
- package/dist/src/scheduler/scheduler_parallel.test.js +94 -3
- package/dist/src/scheduler/scheduler_parallel.test.js.map +1 -1
- package/dist/src/scheduler/tool-executor.js +21 -12
- package/dist/src/scheduler/tool-executor.js.map +1 -1
- package/dist/src/scheduler/tool-executor.test.js +54 -0
- package/dist/src/scheduler/tool-executor.test.js.map +1 -1
- package/dist/src/services/trackerService.d.ts +49 -0
- package/dist/src/services/trackerService.js +172 -0
- package/dist/src/services/trackerService.js.map +1 -0
- package/dist/src/services/trackerService.test.d.ts +6 -0
- package/dist/src/services/trackerService.test.js +117 -0
- package/dist/src/services/trackerService.test.js.map +1 -0
- package/dist/src/services/trackerTypes.d.ts +51 -0
- package/dist/src/services/trackerTypes.js +33 -0
- package/dist/src/services/trackerTypes.js.map +1 -0
- package/dist/src/telemetry/billingEvents.d.ts +75 -0
- package/dist/src/telemetry/billingEvents.js +181 -0
- package/dist/src/telemetry/billingEvents.js.map +1 -0
- package/dist/src/telemetry/billingEvents.test.d.ts +6 -0
- package/dist/src/telemetry/billingEvents.test.js +139 -0
- package/dist/src/telemetry/billingEvents.test.js.map +1 -0
- package/dist/src/telemetry/conseca-logger.test.js +1 -0
- package/dist/src/telemetry/conseca-logger.test.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +25 -0
- package/dist/src/telemetry/constants.js +29 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +3 -1
- package/dist/src/telemetry/index.js +5 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +2 -0
- package/dist/src/telemetry/loggers.js +10 -0
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +16 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +28 -0
- package/dist/src/telemetry/metrics.js +40 -0
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/sanitize.test.js +1 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +1 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.js +2 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -1
- package/dist/src/telemetry/trace.d.ts +2 -1
- package/dist/src/telemetry/trace.js +13 -18
- package/dist/src/telemetry/trace.js.map +1 -1
- package/dist/src/telemetry/trace.test.d.ts +6 -0
- package/dist/src/telemetry/trace.test.js +116 -0
- package/dist/src/telemetry/trace.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.js +1 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -1
- package/dist/src/tools/definitions/model-family-sets/default-legacy.js +2 -2
- package/dist/src/tools/definitions/model-family-sets/default-legacy.js.map +1 -1
- package/dist/src/tools/definitions/model-family-sets/gemini-3.js +3 -3
- package/dist/src/tools/definitions/model-family-sets/gemini-3.js.map +1 -1
- package/dist/src/tools/grep-utils.d.ts +1 -1
- package/dist/src/tools/grep-utils.js +4 -4
- package/dist/src/tools/grep-utils.js.map +1 -1
- package/dist/src/tools/grep.d.ts +1 -1
- package/dist/src/tools/grep.js +9 -9
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +8 -5
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/line-endings.test.js +3 -11
- package/dist/src/tools/line-endings.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +25 -0
- package/dist/src/tools/mcp-client-manager.js +66 -3
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +47 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +20 -9
- package/dist/src/tools/mcp-client.js +50 -46
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +96 -84
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +3 -3
- package/dist/src/tools/mcp-tool.js +1 -0
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +1 -1
- package/dist/src/tools/ripGrep.js +7 -7
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +10 -7
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +1 -0
- package/dist/src/tools/tools.js +1 -0
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/write-file.js +4 -17
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +29 -83
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/utils/editCorrector.d.ts +1 -42
- package/dist/src/utils/editCorrector.js +9 -461
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +17 -421
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/envExpansion.js.map +1 -1
- package/dist/src/utils/errors.js +7 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors_timeout.test.d.ts +6 -0
- package/dist/src/utils/errors_timeout.test.js +40 -0
- package/dist/src/utils/errors_timeout.test.js.map +1 -0
- package/dist/src/utils/extensionLoader.js +35 -0
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +36 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/fetch.js +13 -2
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.js +0 -1
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +0 -1
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +24 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +2 -2
- package/dist/src/utils/googleQuotaErrors.d.ts +3 -1
- package/dist/src/utils/googleQuotaErrors.js +22 -12
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +33 -1
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/retry.js +4 -2
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +20 -0
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +0 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -227,6 +227,42 @@ skill definitions in a `skills/` directory. For example,
|
|
|
227
227
|
Provide [sub-agents](../core/subagents.md) that users can delegate tasks to. Add
|
|
228
228
|
agent definition files (`.md`) to an `agents/` directory in your extension root.
|
|
229
229
|
|
|
230
|
+
### <a id="policy-engine"></a>Policy Engine
|
|
231
|
+
|
|
232
|
+
Extensions can contribute policy rules and safety checkers to the Gemini CLI
|
|
233
|
+
[Policy Engine](../reference/policy-engine.md). These rules are defined in
|
|
234
|
+
`.toml` files and take effect when the extension is activated.
|
|
235
|
+
|
|
236
|
+
To add policies, create a `policies/` directory in your extension's root and
|
|
237
|
+
place your `.toml` policy files inside it. Gemini CLI automatically loads all
|
|
238
|
+
`.toml` files from this directory.
|
|
239
|
+
|
|
240
|
+
Rules contributed by extensions run in their own tier (tier 2), alongside
|
|
241
|
+
workspace-defined policies. This tier has higher priority than the default rules
|
|
242
|
+
but lower priority than user or admin policies.
|
|
243
|
+
|
|
244
|
+
> **Warning:** For security, Gemini CLI ignores any `allow` decisions or `yolo`
|
|
245
|
+
> mode configurations in extension policies. This ensures that an extension
|
|
246
|
+
> cannot automatically approve tool calls or bypass security measures without
|
|
247
|
+
> your confirmation.
|
|
248
|
+
|
|
249
|
+
**Example `policies.toml`**
|
|
250
|
+
|
|
251
|
+
```toml
|
|
252
|
+
[[rule]]
|
|
253
|
+
toolName = "my_server__dangerous_tool"
|
|
254
|
+
decision = "ask_user"
|
|
255
|
+
priority = 100
|
|
256
|
+
|
|
257
|
+
[[safety_checker]]
|
|
258
|
+
toolName = "my_server__write_data"
|
|
259
|
+
priority = 200
|
|
260
|
+
[safety_checker.checker]
|
|
261
|
+
type = "in-process"
|
|
262
|
+
name = "allowed-path"
|
|
263
|
+
required_context = ["environment"]
|
|
264
|
+
```
|
|
265
|
+
|
|
230
266
|
### Themes
|
|
231
267
|
|
|
232
268
|
Extensions can provide custom themes to personalize the CLI UI. Themes are
|
|
@@ -189,10 +189,18 @@ Custom commands create shortcuts for complex prompts.
|
|
|
189
189
|
|
|
190
190
|
1. Create a `commands` directory and a subdirectory for your command group:
|
|
191
191
|
|
|
192
|
+
**macOS/Linux**
|
|
193
|
+
|
|
192
194
|
```bash
|
|
193
195
|
mkdir -p commands/fs
|
|
194
196
|
```
|
|
195
197
|
|
|
198
|
+
**Windows (PowerShell)**
|
|
199
|
+
|
|
200
|
+
```powershell
|
|
201
|
+
New-Item -ItemType Directory -Force -Path "commands\fs"
|
|
202
|
+
```
|
|
203
|
+
|
|
196
204
|
2. Create a file named `commands/fs/grep-code.toml`:
|
|
197
205
|
|
|
198
206
|
```toml
|
|
@@ -252,10 +260,18 @@ Skills are activated only when needed, which saves context tokens.
|
|
|
252
260
|
|
|
253
261
|
1. Create a `skills` directory and a subdirectory for your skill:
|
|
254
262
|
|
|
263
|
+
**macOS/Linux**
|
|
264
|
+
|
|
255
265
|
```bash
|
|
256
266
|
mkdir -p skills/security-audit
|
|
257
267
|
```
|
|
258
268
|
|
|
269
|
+
**Windows (PowerShell)**
|
|
270
|
+
|
|
271
|
+
```powershell
|
|
272
|
+
New-Item -ItemType Directory -Force -Path "skills\security-audit"
|
|
273
|
+
```
|
|
274
|
+
|
|
259
275
|
2. Create a `skills/security-audit/SKILL.md` file:
|
|
260
276
|
|
|
261
277
|
```markdown
|
|
@@ -78,11 +78,20 @@ To authenticate and use Gemini CLI with a Gemini API key:
|
|
|
78
78
|
|
|
79
79
|
2. Set the `GEMINI_API_KEY` environment variable to your key. For example:
|
|
80
80
|
|
|
81
|
+
**macOS/Linux**
|
|
82
|
+
|
|
81
83
|
```bash
|
|
82
84
|
# Replace YOUR_GEMINI_API_KEY with the key from AI Studio
|
|
83
85
|
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
|
|
84
86
|
```
|
|
85
87
|
|
|
88
|
+
**Windows (PowerShell)**
|
|
89
|
+
|
|
90
|
+
```powershell
|
|
91
|
+
# Replace YOUR_GEMINI_API_KEY with the key from AI Studio
|
|
92
|
+
$env:GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
|
|
93
|
+
```
|
|
94
|
+
|
|
86
95
|
To make this setting persistent, see
|
|
87
96
|
[Persisting Environment Variables](#persisting-vars).
|
|
88
97
|
|
|
@@ -114,12 +123,22 @@ or the location where you want to run your jobs.
|
|
|
114
123
|
|
|
115
124
|
For example:
|
|
116
125
|
|
|
126
|
+
**macOS/Linux**
|
|
127
|
+
|
|
117
128
|
```bash
|
|
118
129
|
# Replace with your project ID and desired location (e.g., us-central1)
|
|
119
130
|
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
|
|
120
131
|
export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"
|
|
121
132
|
```
|
|
122
133
|
|
|
134
|
+
**Windows (PowerShell)**
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
# Replace with your project ID and desired location (e.g., us-central1)
|
|
138
|
+
$env:GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
|
|
139
|
+
$env:GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"
|
|
140
|
+
```
|
|
141
|
+
|
|
123
142
|
To make any Vertex AI environment variable settings persistent, see
|
|
124
143
|
[Persisting Environment Variables](#persisting-vars).
|
|
125
144
|
|
|
@@ -130,9 +149,17 @@ Consider this authentication method if you have Google Cloud CLI installed.
|
|
|
130
149
|
> **Note:** If you have previously set `GOOGLE_API_KEY` or `GEMINI_API_KEY`, you
|
|
131
150
|
> must unset them to use ADC:
|
|
132
151
|
>
|
|
152
|
+
> **macOS/Linux**
|
|
153
|
+
>
|
|
133
154
|
> ```bash
|
|
134
155
|
> unset GOOGLE_API_KEY GEMINI_API_KEY
|
|
135
156
|
> ```
|
|
157
|
+
>
|
|
158
|
+
> **Windows (PowerShell)**
|
|
159
|
+
>
|
|
160
|
+
> ```powershell
|
|
161
|
+
> Remove-Item Env:\GOOGLE_API_KEY, Env:\GEMINI_API_KEY -ErrorAction Ignore
|
|
162
|
+
> ```
|
|
136
163
|
|
|
137
164
|
1. Verify you have a Google Cloud project and Vertex AI API is enabled.
|
|
138
165
|
|
|
@@ -160,9 +187,17 @@ pipelines, or if your organization restricts user-based ADC or API key creation.
|
|
|
160
187
|
> **Note:** If you have previously set `GOOGLE_API_KEY` or `GEMINI_API_KEY`, you
|
|
161
188
|
> must unset them:
|
|
162
189
|
>
|
|
190
|
+
> **macOS/Linux**
|
|
191
|
+
>
|
|
163
192
|
> ```bash
|
|
164
193
|
> unset GOOGLE_API_KEY GEMINI_API_KEY
|
|
165
194
|
> ```
|
|
195
|
+
>
|
|
196
|
+
> **Windows (PowerShell)**
|
|
197
|
+
>
|
|
198
|
+
> ```powershell
|
|
199
|
+
> Remove-Item Env:\GOOGLE_API_KEY, Env:\GEMINI_API_KEY -ErrorAction Ignore
|
|
200
|
+
> ```
|
|
166
201
|
|
|
167
202
|
1. [Create a service account and key](https://cloud.google.com/iam/docs/keys-create-delete)
|
|
168
203
|
and download the provided JSON file. Assign the "Vertex AI User" role to the
|
|
@@ -171,11 +206,20 @@ pipelines, or if your organization restricts user-based ADC or API key creation.
|
|
|
171
206
|
2. Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the JSON
|
|
172
207
|
file's absolute path. For example:
|
|
173
208
|
|
|
209
|
+
**macOS/Linux**
|
|
210
|
+
|
|
174
211
|
```bash
|
|
175
212
|
# Replace /path/to/your/keyfile.json with the actual path
|
|
176
213
|
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/keyfile.json"
|
|
177
214
|
```
|
|
178
215
|
|
|
216
|
+
**Windows (PowerShell)**
|
|
217
|
+
|
|
218
|
+
```powershell
|
|
219
|
+
# Replace C:\path\to\your\keyfile.json with the actual path
|
|
220
|
+
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\your\keyfile.json"
|
|
221
|
+
```
|
|
222
|
+
|
|
179
223
|
3. [Configure your Google Cloud Project](#set-gcp).
|
|
180
224
|
|
|
181
225
|
4. Start the CLI:
|
|
@@ -195,11 +239,20 @@ pipelines, or if your organization restricts user-based ADC or API key creation.
|
|
|
195
239
|
|
|
196
240
|
2. Set the `GOOGLE_API_KEY` environment variable:
|
|
197
241
|
|
|
242
|
+
**macOS/Linux**
|
|
243
|
+
|
|
198
244
|
```bash
|
|
199
245
|
# Replace YOUR_GOOGLE_API_KEY with your Vertex AI API key
|
|
200
246
|
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
|
|
201
247
|
```
|
|
202
248
|
|
|
249
|
+
**Windows (PowerShell)**
|
|
250
|
+
|
|
251
|
+
```powershell
|
|
252
|
+
# Replace YOUR_GOOGLE_API_KEY with your Vertex AI API key
|
|
253
|
+
$env:GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
|
|
254
|
+
```
|
|
255
|
+
|
|
203
256
|
> **Note:** If you see errors like
|
|
204
257
|
> `"API keys are not supported by this API..."`, your organization might
|
|
205
258
|
> restrict API key usage for this service. Try the other Vertex AI
|
|
@@ -243,11 +296,20 @@ To configure Gemini CLI to use a Google Cloud project, do the following:
|
|
|
243
296
|
|
|
244
297
|
For example, to set the `GOOGLE_CLOUD_PROJECT_ID` variable:
|
|
245
298
|
|
|
299
|
+
**macOS/Linux**
|
|
300
|
+
|
|
246
301
|
```bash
|
|
247
302
|
# Replace YOUR_PROJECT_ID with your actual Google Cloud project ID
|
|
248
303
|
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
|
|
249
304
|
```
|
|
250
305
|
|
|
306
|
+
**Windows (PowerShell)**
|
|
307
|
+
|
|
308
|
+
```powershell
|
|
309
|
+
# Replace YOUR_PROJECT_ID with your actual Google Cloud project ID
|
|
310
|
+
$env:GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
|
|
311
|
+
```
|
|
312
|
+
|
|
251
313
|
To make this setting persistent, see
|
|
252
314
|
[Persisting Environment Variables](#persisting-vars).
|
|
253
315
|
|
|
@@ -257,16 +319,22 @@ To avoid setting environment variables for every terminal session, you can
|
|
|
257
319
|
persist them with the following methods:
|
|
258
320
|
|
|
259
321
|
1. **Add your environment variables to your shell configuration file:** Append
|
|
260
|
-
the
|
|
261
|
-
|
|
262
|
-
|
|
322
|
+
the environment variable commands to your shell's startup file.
|
|
323
|
+
|
|
324
|
+
**macOS/Linux** (e.g., `~/.bashrc`, `~/.zshrc`, or `~/.profile`):
|
|
263
325
|
|
|
264
326
|
```bash
|
|
265
|
-
# Example for .bashrc
|
|
266
327
|
echo 'export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"' >> ~/.bashrc
|
|
267
328
|
source ~/.bashrc
|
|
268
329
|
```
|
|
269
330
|
|
|
331
|
+
**Windows (PowerShell)** (e.g., `$PROFILE`):
|
|
332
|
+
|
|
333
|
+
```powershell
|
|
334
|
+
Add-Content -Path $PROFILE -Value '$env:GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"'
|
|
335
|
+
. $PROFILE
|
|
336
|
+
```
|
|
337
|
+
|
|
270
338
|
> **Warning:** Be aware that when you export API keys or service account
|
|
271
339
|
> paths in your shell configuration file, any process launched from that
|
|
272
340
|
> shell can read them.
|
|
@@ -274,10 +342,13 @@ persist them with the following methods:
|
|
|
274
342
|
2. **Use a `.env` file:** Create a `.gemini/.env` file in your project
|
|
275
343
|
directory or home directory. Gemini CLI automatically loads variables from
|
|
276
344
|
the first `.env` file it finds, searching up from the current directory,
|
|
277
|
-
then in
|
|
345
|
+
then in your home directory's `.gemini/.env` (e.g., `~/.gemini/.env` or
|
|
346
|
+
`%USERPROFILE%\.gemini\.env`).
|
|
278
347
|
|
|
279
348
|
Example for user-wide settings:
|
|
280
349
|
|
|
350
|
+
**macOS/Linux**
|
|
351
|
+
|
|
281
352
|
```bash
|
|
282
353
|
mkdir -p ~/.gemini
|
|
283
354
|
cat >> ~/.gemini/.env <<'EOF'
|
|
@@ -286,6 +357,16 @@ persist them with the following methods:
|
|
|
286
357
|
EOF
|
|
287
358
|
```
|
|
288
359
|
|
|
360
|
+
**Windows (PowerShell)**
|
|
361
|
+
|
|
362
|
+
```powershell
|
|
363
|
+
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.gemini"
|
|
364
|
+
@"
|
|
365
|
+
GOOGLE_CLOUD_PROJECT="your-project-id"
|
|
366
|
+
# Add other variables like GEMINI_API_KEY as needed
|
|
367
|
+
"@ | Out-File -FilePath "$env:USERPROFILE\.gemini\.env" -Encoding utf8 -Append
|
|
368
|
+
```
|
|
369
|
+
|
|
289
370
|
Variables are loaded from the first file found, not merged.
|
|
290
371
|
|
|
291
372
|
## Running in Google Cloud environments <a id="cloud-env"></a>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Gemini CLI installation, execution, and releases
|
|
2
2
|
|
|
3
|
-
This document provides an overview of Gemini CLI's
|
|
3
|
+
This document provides an overview of Gemini CLI's system requirements,
|
|
4
4
|
installation methods, and release types.
|
|
5
5
|
|
|
6
6
|
## Recommended system specifications
|
|
@@ -13,7 +13,7 @@ installation methods, and release types.
|
|
|
13
13
|
- "Casual" usage: 4GB+ RAM (short sessions, common tasks and edits)
|
|
14
14
|
- "Power" usage: 16GB+ RAM (long sessions, large codebases, deep context)
|
|
15
15
|
- **Runtime:** Node.js 20.0.0+
|
|
16
|
-
- **Shell:** Bash or
|
|
16
|
+
- **Shell:** Bash, Zsh, or PowerShell
|
|
17
17
|
- **Location:**
|
|
18
18
|
[Gemini Code Assist supported locations](https://developers.google.com/gemini-code-assist/resources/available-locations#americas)
|
|
19
19
|
- **Internet connection required**
|
|
@@ -167,6 +167,8 @@ try {
|
|
|
167
167
|
Run hook scripts manually with sample JSON input to verify they behave as
|
|
168
168
|
expected before hooking them up to the CLI.
|
|
169
169
|
|
|
170
|
+
**macOS/Linux**
|
|
171
|
+
|
|
170
172
|
```bash
|
|
171
173
|
# Create test input
|
|
172
174
|
cat > test-input.json << 'EOF'
|
|
@@ -187,7 +189,30 @@ cat test-input.json | .gemini/hooks/my-hook.sh
|
|
|
187
189
|
|
|
188
190
|
# Check exit code
|
|
189
191
|
echo "Exit code: $?"
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Windows (PowerShell)**
|
|
190
195
|
|
|
196
|
+
```powershell
|
|
197
|
+
# Create test input
|
|
198
|
+
@"
|
|
199
|
+
{
|
|
200
|
+
"session_id": "test-123",
|
|
201
|
+
"cwd": "C:\\temp\\test",
|
|
202
|
+
"hook_event_name": "BeforeTool",
|
|
203
|
+
"tool_name": "write_file",
|
|
204
|
+
"tool_input": {
|
|
205
|
+
"file_path": "test.txt",
|
|
206
|
+
"content": "Test content"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
"@ | Out-File -FilePath test-input.json -Encoding utf8
|
|
210
|
+
|
|
211
|
+
# Test the hook
|
|
212
|
+
Get-Content test-input.json | .\.gemini\hooks\my-hook.ps1
|
|
213
|
+
|
|
214
|
+
# Check exit code
|
|
215
|
+
Write-Host "Exit code: $LASTEXITCODE"
|
|
191
216
|
```
|
|
192
217
|
|
|
193
218
|
### Check exit codes
|
|
@@ -333,7 +358,7 @@ tool_name=$(echo "$input" | jq -r '.tool_name')
|
|
|
333
358
|
|
|
334
359
|
### Make scripts executable
|
|
335
360
|
|
|
336
|
-
Always make hook scripts executable:
|
|
361
|
+
Always make hook scripts executable on macOS/Linux:
|
|
337
362
|
|
|
338
363
|
```bash
|
|
339
364
|
chmod +x .gemini/hooks/*.sh
|
|
@@ -341,6 +366,10 @@ chmod +x .gemini/hooks/*.js
|
|
|
341
366
|
|
|
342
367
|
```
|
|
343
368
|
|
|
369
|
+
**Windows Note**: On Windows, PowerShell scripts (`.ps1`) don't use `chmod`, but
|
|
370
|
+
you may need to ensure your execution policy allows them to run (e.g.,
|
|
371
|
+
`Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`).
|
|
372
|
+
|
|
344
373
|
### Version control
|
|
345
374
|
|
|
346
375
|
Commit hooks to share with your team:
|
|
@@ -481,6 +510,9 @@ ls -la .gemini/hooks/my-hook.sh
|
|
|
481
510
|
chmod +x .gemini/hooks/my-hook.sh
|
|
482
511
|
```
|
|
483
512
|
|
|
513
|
+
**Windows Note**: On Windows, ensure your execution policy allows running
|
|
514
|
+
scripts (e.g., `Get-ExecutionPolicy`).
|
|
515
|
+
|
|
484
516
|
**Verify script path:** Ensure the path in `settings.json` resolves correctly.
|
|
485
517
|
|
|
486
518
|
```bash
|
|
@@ -28,6 +28,8 @@ Create a directory for hooks and a simple logging script.
|
|
|
28
28
|
> This example uses `jq` to parse JSON. If you don't have it installed, you can
|
|
29
29
|
> perform similar logic using Node.js or Python.
|
|
30
30
|
|
|
31
|
+
**macOS/Linux**
|
|
32
|
+
|
|
31
33
|
```bash
|
|
32
34
|
mkdir -p .gemini/hooks
|
|
33
35
|
cat > .gemini/hooks/log-tools.sh << 'EOF'
|
|
@@ -52,6 +54,28 @@ EOF
|
|
|
52
54
|
chmod +x .gemini/hooks/log-tools.sh
|
|
53
55
|
```
|
|
54
56
|
|
|
57
|
+
**Windows (PowerShell)**
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
New-Item -ItemType Directory -Force -Path ".gemini\hooks"
|
|
61
|
+
@"
|
|
62
|
+
# Read hook input from stdin
|
|
63
|
+
`$inputJson = `$input | Out-String | ConvertFrom-Json
|
|
64
|
+
|
|
65
|
+
# Extract tool name
|
|
66
|
+
`$toolName = `$inputJson.tool_name
|
|
67
|
+
|
|
68
|
+
# Log to stderr (visible in terminal if hook fails, or captured in logs)
|
|
69
|
+
[Console]::Error.WriteLine("Logging tool: `$toolName")
|
|
70
|
+
|
|
71
|
+
# Log to file
|
|
72
|
+
"[`$(Get-Date -Format 'o')] Tool executed: `$toolName" | Out-File -FilePath ".gemini\tool-log.txt" -Append -Encoding utf8
|
|
73
|
+
|
|
74
|
+
# Return success with empty JSON
|
|
75
|
+
"{}"
|
|
76
|
+
"@ | Out-File -FilePath ".gemini\hooks\log-tools.ps1" -Encoding utf8
|
|
77
|
+
```
|
|
78
|
+
|
|
55
79
|
## Exit Code Strategies
|
|
56
80
|
|
|
57
81
|
There are two ways to control or block an action in Gemini CLI:
|
|
@@ -177,10 +177,18 @@ standalone terminal and want to manually associate it with a specific IDE
|
|
|
177
177
|
instance, you can set the `GEMINI_CLI_IDE_PID` environment variable to the
|
|
178
178
|
process ID (PID) of your IDE.
|
|
179
179
|
|
|
180
|
+
**macOS/Linux**
|
|
181
|
+
|
|
180
182
|
```bash
|
|
181
183
|
export GEMINI_CLI_IDE_PID=12345
|
|
182
184
|
```
|
|
183
185
|
|
|
186
|
+
**Windows (PowerShell)**
|
|
187
|
+
|
|
188
|
+
```powershell
|
|
189
|
+
$env:GEMINI_CLI_IDE_PID=12345
|
|
190
|
+
```
|
|
191
|
+
|
|
184
192
|
When this variable is set, Gemini CLI will skip automatic detection and attempt
|
|
185
193
|
to connect using the provided PID.
|
|
186
194
|
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
# Local development guide
|
|
2
2
|
|
|
3
3
|
This guide provides instructions for setting up and using local development
|
|
4
|
-
features, such as
|
|
4
|
+
features, such as tracing.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Tracing
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
Traces are OpenTelemetry (OTel) records that help you debug your code by
|
|
9
|
+
instrumenting key events like model calls, tool scheduler operations, and tool
|
|
10
|
+
calls.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Traces provide deep visibility into agent behavior and are invaluable for
|
|
13
|
+
debugging complex issues. They are captured automatically when telemetry is
|
|
14
|
+
enabled.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
when running Gemini CLI.
|
|
16
|
+
### Viewing traces
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
You can view dev traces using either Jaeger or the Genkit Developer UI.
|
|
18
|
+
You can view traces using either Jaeger or the Genkit Developer UI.
|
|
21
19
|
|
|
22
20
|
#### Using Genkit
|
|
23
21
|
|
|
@@ -37,13 +35,12 @@ Genkit provides a web-based UI for viewing traces and other telemetry data.
|
|
|
37
35
|
Genkit Developer UI: http://localhost:4000
|
|
38
36
|
```
|
|
39
37
|
|
|
40
|
-
2. **Run Gemini CLI
|
|
38
|
+
2. **Run Gemini CLI:**
|
|
41
39
|
|
|
42
|
-
In a separate terminal, run your Gemini CLI command
|
|
43
|
-
`GEMINI_DEV_TRACING` environment variable:
|
|
40
|
+
In a separate terminal, run your Gemini CLI command:
|
|
44
41
|
|
|
45
42
|
```bash
|
|
46
|
-
|
|
43
|
+
gemini
|
|
47
44
|
```
|
|
48
45
|
|
|
49
46
|
3. **View the traces:**
|
|
@@ -53,7 +50,7 @@ Genkit provides a web-based UI for viewing traces and other telemetry data.
|
|
|
53
50
|
|
|
54
51
|
#### Using Jaeger
|
|
55
52
|
|
|
56
|
-
You can view
|
|
53
|
+
You can view traces in the Jaeger UI. To get started, follow these steps:
|
|
57
54
|
|
|
58
55
|
1. **Start the telemetry collector:**
|
|
59
56
|
|
|
@@ -67,13 +64,12 @@ You can view dev traces in the Jaeger UI. To get started, follow these steps:
|
|
|
67
64
|
This command also configures your workspace for local telemetry and provides
|
|
68
65
|
a link to the Jaeger UI (usually `http://localhost:16686`).
|
|
69
66
|
|
|
70
|
-
2. **Run Gemini CLI
|
|
67
|
+
2. **Run Gemini CLI:**
|
|
71
68
|
|
|
72
|
-
In a separate terminal, run your Gemini CLI command
|
|
73
|
-
`GEMINI_DEV_TRACING` environment variable:
|
|
69
|
+
In a separate terminal, run your Gemini CLI command:
|
|
74
70
|
|
|
75
71
|
```bash
|
|
76
|
-
|
|
72
|
+
gemini
|
|
77
73
|
```
|
|
78
74
|
|
|
79
75
|
3. **View the traces:**
|
|
@@ -84,10 +80,10 @@ You can view dev traces in the Jaeger UI. To get started, follow these steps:
|
|
|
84
80
|
For more detailed information on telemetry, see the
|
|
85
81
|
[telemetry documentation](./cli/telemetry.md).
|
|
86
82
|
|
|
87
|
-
### Instrumenting code with
|
|
83
|
+
### Instrumenting code with traces
|
|
88
84
|
|
|
89
|
-
You can add
|
|
90
|
-
|
|
85
|
+
You can add traces to your own code for more detailed instrumentation. This is
|
|
86
|
+
useful for debugging and understanding the flow of execution.
|
|
91
87
|
|
|
92
88
|
Use the `runInDevTraceSpan` function to wrap any section of code in a trace
|
|
93
89
|
span.
|
|
@@ -96,29 +92,39 @@ Here is a basic example:
|
|
|
96
92
|
|
|
97
93
|
```typescript
|
|
98
94
|
import { runInDevTraceSpan } from '@google/gemini-cli-core';
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
metadata.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
95
|
+
import { GeminiCliOperation } from '@google/gemini-cli-core/lib/telemetry/constants.js';
|
|
96
|
+
|
|
97
|
+
await runInDevTraceSpan(
|
|
98
|
+
{
|
|
99
|
+
operation: GeminiCliOperation.ToolCall,
|
|
100
|
+
attributes: {
|
|
101
|
+
[GEN_AI_AGENT_NAME]: 'gemini-cli',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
async ({ metadata }) => {
|
|
105
|
+
// The `metadata` object allows you to record the input and output of the
|
|
106
|
+
// operation as well as other attributes.
|
|
107
|
+
metadata.input = { key: 'value' };
|
|
108
|
+
// Set custom attributes.
|
|
109
|
+
metadata.attributes['custom.attribute'] = 'custom.value';
|
|
110
|
+
|
|
111
|
+
// Your code to be traced goes here
|
|
112
|
+
try {
|
|
113
|
+
const output = await somethingRisky();
|
|
114
|
+
metadata.output = output;
|
|
115
|
+
return output;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
metadata.error = e;
|
|
118
|
+
throw e;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
);
|
|
117
122
|
```
|
|
118
123
|
|
|
119
124
|
In this example:
|
|
120
125
|
|
|
121
|
-
- `
|
|
126
|
+
- `operation`: The operation type of the span, represented by the
|
|
127
|
+
`GeminiCliOperation` enum.
|
|
122
128
|
- `metadata.input`: (Optional) An object containing the input data for the
|
|
123
129
|
traced operation.
|
|
124
130
|
- `metadata.output`: (Optional) An object containing the output data from the
|