@office-ai/aioncli-core 0.18.6 → 0.24.0-preview.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/docs/CONTRIBUTING.md +546 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +592 -0
- package/dist/docs/changelogs/latest.md +225 -0
- package/dist/docs/changelogs/preview.md +129 -0
- package/dist/docs/changelogs/releases.md +896 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +354 -0
- package/dist/docs/cli/configuration.md +780 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +108 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +63 -0
- package/dist/docs/cli/keyboard-shortcuts.md +143 -0
- package/dist/docs/cli/model-routing.md +37 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +114 -0
- package/dist/docs/cli/skills.md +156 -0
- package/dist/docs/cli/system-prompt.md +93 -0
- package/dist/docs/cli/telemetry.md +791 -0
- package/dist/docs/cli/themes.md +237 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +124 -0
- package/dist/docs/cli/tutorials.md +87 -0
- package/dist/docs/cli/uninstall.md +47 -0
- package/dist/docs/core/index.md +101 -0
- package/dist/docs/core/memport.md +244 -0
- package/dist/docs/core/policy-engine.md +267 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extension.md +160 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +245 -0
- package/dist/docs/extensions/index.md +293 -0
- package/dist/docs/faq.md +154 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +888 -0
- package/dist/docs/get-started/configuration.md +1536 -0
- package/dist/docs/get-started/deployment.md +143 -0
- package/dist/docs/get-started/examples.md +219 -0
- package/dist/docs/get-started/gemini-3.md +116 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +856 -0
- package/dist/docs/hooks/index.md +687 -0
- package/dist/docs/hooks/reference.md +168 -0
- package/dist/docs/hooks/writing-hooks.md +1026 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +202 -0
- package/dist/docs/index.md +147 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +301 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +95 -0
- package/dist/docs/tools/mcp-server.md +1044 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +57 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +158 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.d.ts +78 -0
- package/dist/src/agents/a2a-client-manager.js +295 -0
- package/dist/src/agents/a2a-client-manager.js.map +1 -0
- package/dist/src/agents/a2a-client-manager.test.d.ts +6 -0
- package/dist/src/agents/a2a-client-manager.test.js +237 -0
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +28 -0
- package/dist/src/agents/a2aUtils.js +111 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/a2aUtils.test.d.ts +6 -0
- package/dist/src/agents/a2aUtils.test.js +147 -0
- package/dist/src/agents/a2aUtils.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +5 -4
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.d.ts +19 -0
- package/dist/src/agents/delegate-to-agent-tool.js +115 -0
- package/dist/src/agents/delegate-to-agent-tool.js.map +1 -0
- package/dist/src/agents/delegate-to-agent-tool.test.d.ts +6 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js +165 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
- package/dist/src/agents/introspection-agent.d.ts +23 -0
- package/dist/src/agents/introspection-agent.js +72 -0
- package/dist/src/agents/introspection-agent.js.map +1 -0
- package/dist/src/agents/introspection-agent.test.d.ts +6 -0
- package/dist/src/agents/introspection-agent.test.js +47 -0
- package/dist/src/agents/introspection-agent.test.js.map +1 -0
- package/dist/src/agents/local-executor.d.ts +108 -0
- package/dist/src/agents/local-executor.js +801 -0
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/local-executor.test.d.ts +6 -0
- package/dist/src/agents/local-executor.test.js +1380 -0
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/local-invocation.d.ts +45 -0
- package/dist/src/agents/local-invocation.js +101 -0
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/local-invocation.test.d.ts +6 -0
- package/dist/src/agents/local-invocation.test.js +218 -0
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +25 -1
- package/dist/src/agents/registry.js +149 -5
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +247 -25
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.d.ts +35 -0
- package/dist/src/agents/remote-invocation.js +129 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/remote-invocation.test.d.ts +6 -0
- package/dist/src/agents/remote-invocation.test.js +201 -0
- package/dist/src/agents/remote-invocation.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +2 -2
- package/dist/src/agents/subagent-tool-wrapper.js +11 -6
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +25 -17
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/toml-loader.d.ts +74 -0
- package/dist/src/agents/toml-loader.js +248 -0
- package/dist/src/agents/toml-loader.js.map +1 -0
- package/dist/src/agents/toml-loader.test.d.ts +6 -0
- package/dist/src/agents/toml-loader.test.js +309 -0
- package/dist/src/agents/toml-loader.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +18 -4
- package/dist/src/availability/errorClassification.d.ts +7 -0
- package/dist/src/availability/errorClassification.js +20 -0
- package/dist/src/availability/errorClassification.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +36 -0
- package/dist/src/availability/modelAvailabilityService.js +87 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.test.d.ts +6 -0
- package/dist/src/availability/modelAvailabilityService.test.js +140 -0
- package/dist/src/availability/modelAvailabilityService.test.js.map +1 -0
- package/dist/src/availability/modelPolicy.d.ts +49 -0
- package/dist/src/availability/modelPolicy.js +7 -0
- package/dist/src/availability/modelPolicy.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +23 -0
- package/dist/src/availability/policyCatalog.js +82 -0
- package/dist/src/availability/policyCatalog.js.map +1 -0
- package/dist/src/availability/policyCatalog.test.d.ts +6 -0
- package/dist/src/availability/policyCatalog.test.js +70 -0
- package/dist/src/availability/policyCatalog.test.js.map +1 -0
- package/dist/src/availability/policyHelpers.d.ts +52 -0
- package/dist/src/availability/policyHelpers.js +136 -0
- package/dist/src/availability/policyHelpers.js.map +1 -0
- package/dist/src/availability/policyHelpers.test.d.ts +6 -0
- package/dist/src/availability/policyHelpers.test.js +182 -0
- package/dist/src/availability/policyHelpers.test.js.map +1 -0
- package/dist/src/availability/testUtils.d.ts +10 -0
- package/dist/src/availability/testUtils.js +22 -0
- package/dist/src/availability/testUtils.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.js +3 -2
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.test.js +7 -10
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.js +2 -2
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -0
- package/dist/src/code_assist/oauth2.js +73 -17
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +195 -18
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +10 -1
- package/dist/src/code_assist/server.js +81 -15
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +221 -25
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +6 -4
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +63 -0
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.d.ts +14 -0
- package/dist/src/code_assist/telemetry.js +156 -0
- package/dist/src/code_assist/telemetry.js.map +1 -0
- package/dist/src/code_assist/telemetry.test.d.ts +6 -0
- package/dist/src/code_assist/telemetry.test.js +300 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +84 -1
- package/dist/src/code_assist/types.js +21 -0
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +53 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/init.test.d.ts +6 -0
- package/dist/src/commands/init.test.js +25 -0
- package/dist/src/commands/init.test.js.map +1 -0
- package/dist/src/commands/restore.d.ts +9 -0
- package/dist/src/commands/restore.js +46 -0
- package/dist/src/commands/restore.js.map +1 -0
- package/dist/src/commands/restore.test.d.ts +6 -0
- package/dist/src/commands/restore.test.js +137 -0
- package/dist/src/commands/restore.test.js.map +1 -0
- package/dist/src/commands/types.d.ts +41 -0
- package/dist/src/commands/types.js +7 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/config/config.d.ts +120 -23
- package/dist/src/config/config.js +336 -116
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +373 -95
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +46 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +11 -35
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/config/models.d.ts +29 -15
- package/dist/src/config/models.js +78 -28
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +91 -77
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +4 -0
- package/dist/src/config/storage.js +12 -0
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +16 -0
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.js +66 -3
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +29 -2
- package/dist/src/confirmation-bus/types.js +3 -0
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +30 -2
- package/dist/src/core/baseLlmClient.js +107 -49
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +271 -13
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +5 -1
- package/dist/src/core/client.js +241 -63
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +462 -72
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.d.ts +36 -0
- package/dist/src/core/clientHookTriggers.js +76 -0
- package/dist/src/core/clientHookTriggers.js.map +1 -0
- package/dist/src/core/contentGenerator.js +17 -4
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +132 -3
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +55 -0
- package/dist/src/core/coreToolHookTriggers.js +304 -0
- package/dist/src/core/coreToolHookTriggers.js.map +1 -0
- package/dist/src/core/coreToolHookTriggers.test.d.ts +6 -0
- package/dist/src/core/coreToolHookTriggers.test.js +191 -0
- package/dist/src/core/coreToolHookTriggers.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +6 -85
- package/dist/src/core/coreToolScheduler.js +69 -267
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +161 -346
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +132 -76
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +240 -257
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +64 -0
- package/dist/src/core/geminiChatHookTriggers.js +136 -0
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -0
- package/dist/src/core/geminiChat_network_retry.test.d.ts +6 -0
- package/dist/src/core/geminiChat_network_retry.test.js +196 -0
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.js +23 -6
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +13 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +25 -0
- package/dist/src/core/openaiContentGenerator.js +243 -14
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/prompts.js +82 -26
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +102 -3
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/sessionHookTriggers.d.ts +29 -0
- package/dist/src/core/sessionHookTriggers.js +75 -0
- package/dist/src/core/sessionHookTriggers.js.map +1 -0
- package/dist/src/core/turn.d.ts +34 -21
- package/dist/src/core/turn.js +33 -13
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +0 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +101 -93
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +186 -173
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +8 -0
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.js +7 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +113 -0
- package/dist/src/hooks/hookEventHandler.js +571 -0
- package/dist/src/hooks/hookEventHandler.js.map +1 -0
- package/dist/src/hooks/hookEventHandler.test.d.ts +6 -0
- package/dist/src/hooks/hookEventHandler.test.js +461 -0
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +1 -5
- package/dist/src/hooks/hookPlanner.js +2 -7
- package/dist/src/hooks/hookPlanner.js.map +1 -1
- package/dist/src/hooks/hookPlanner.test.js +62 -2
- package/dist/src/hooks/hookPlanner.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.d.ts +6 -18
- package/dist/src/hooks/hookRegistry.js +49 -35
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +167 -8
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.d.ts +5 -3
- package/dist/src/hooks/hookRunner.js +74 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +174 -36
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +40 -0
- package/dist/src/hooks/hookSystem.js +65 -0
- package/dist/src/hooks/hookSystem.js.map +1 -0
- package/dist/src/hooks/hookSystem.test.d.ts +6 -0
- package/dist/src/hooks/hookSystem.test.js +319 -0
- package/dist/src/hooks/hookSystem.test.js.map +1 -0
- package/dist/src/hooks/index.d.ts +17 -0
- package/dist/src/hooks/index.js +18 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/trustedHooks.d.ts +28 -0
- package/dist/src/hooks/trustedHooks.js +90 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -0
- package/dist/src/hooks/trustedHooks.test.d.ts +6 -0
- package/dist/src/hooks/trustedHooks.test.js +154 -0
- package/dist/src/hooks/trustedHooks.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +21 -11
- package/dist/src/hooks/types.js +31 -27
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +5 -24
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +32 -1
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +9 -4
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +17 -0
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +1 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +4 -4
- package/dist/src/index.d.ts +17 -1
- package/dist/src/index.js +18 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/auth-provider.d.ts +16 -0
- package/dist/src/mcp/auth-provider.js +7 -0
- package/dist/src/mcp/auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +10 -2
- package/dist/src/mcp/google-auth-provider.js +28 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +45 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +6 -2
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +4 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +8 -1
- package/dist/src/mcp/oauth-utils.js +31 -2
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +42 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +2 -2
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/output/json-formatter.d.ts +2 -2
- package/dist/src/output/json-formatter.js +6 -3
- package/dist/src/output/json-formatter.js.map +1 -1
- package/dist/src/output/json-formatter.test.js +37 -9
- package/dist/src/output/json-formatter.test.js.map +1 -1
- package/dist/src/output/stream-json-formatter.js +6 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -1
- package/dist/src/output/stream-json-formatter.test.js +98 -100
- package/dist/src/output/stream-json-formatter.test.js.map +1 -1
- package/dist/src/output/types.d.ts +3 -0
- package/dist/src/output/types.js.map +1 -1
- package/dist/src/policy/config.js +140 -15
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +21 -0
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/persistence.test.d.ts +6 -0
- package/dist/src/policy/persistence.test.js +154 -0
- package/dist/src/policy/persistence.test.js.map +1 -0
- package/dist/src/policy/policies/agent.toml +31 -0
- package/dist/src/policy/policies/read-only.toml +5 -0
- package/dist/src/policy/policies/write.toml +5 -0
- package/dist/src/policy/policies/yolo.toml +1 -0
- package/dist/src/policy/policy-engine.d.ts +30 -1
- package/dist/src/policy/policy-engine.js +192 -5
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +520 -3
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/policy-updater.test.d.ts +6 -0
- package/dist/src/policy/policy-updater.test.js +116 -0
- package/dist/src/policy/policy-updater.test.js.map +1 -0
- package/dist/src/policy/shell-safety.test.d.ts +6 -0
- package/dist/src/policy/shell-safety.test.js +75 -0
- package/dist/src/policy/shell-safety.test.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +3 -5
- package/dist/src/policy/toml-loader.js +12 -60
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +38 -7
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +72 -1
- package/dist/src/policy/types.js +21 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +42 -0
- package/dist/src/policy/utils.js.map +1 -0
- package/dist/src/policy/utils.test.d.ts +6 -0
- package/dist/src/policy/utils.test.js +64 -0
- package/dist/src/policy/utils.test.js.map +1 -0
- package/dist/src/resources/resource-registry.d.ts +30 -0
- package/dist/src/resources/resource-registry.js +57 -0
- package/dist/src/resources/resource-registry.js.map +1 -0
- package/dist/src/resources/resource-registry.test.d.ts +6 -0
- package/dist/src/resources/resource-registry.test.js +54 -0
- package/dist/src/resources/resource-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +0 -15
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +0 -62
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js +10 -21
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +2 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +4 -2
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.test.js +11 -10
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +20 -12
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +63 -39
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +3 -2
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/safety/checker-runner.js +17 -6
- package/dist/src/safety/checker-runner.js.map +1 -1
- package/dist/src/scheduler/tool-executor.d.ts +22 -0
- package/dist/src/scheduler/tool-executor.js +198 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/tool-executor.test.d.ts +6 -0
- package/dist/src/scheduler/tool-executor.test.js +231 -0
- package/dist/src/scheduler/tool-executor.test.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +95 -0
- package/dist/src/scheduler/types.js +7 -0
- package/dist/src/scheduler/types.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +1 -0
- package/dist/src/services/chatCompressionService.js +38 -8
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +35 -31
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +14 -0
- package/dist/src/services/chatRecordingService.js +37 -0
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +29 -0
- package/dist/src/services/contextManager.js +71 -0
- package/dist/src/services/contextManager.js.map +1 -0
- package/dist/src/services/contextManager.test.d.ts +6 -0
- package/dist/src/services/contextManager.test.js +104 -0
- package/dist/src/services/contextManager.test.js.map +1 -0
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +141 -0
- package/dist/src/services/environmentSanitization.js.map +1 -0
- package/dist/src/services/environmentSanitization.test.d.ts +6 -0
- package/dist/src/services/environmentSanitization.test.js +284 -0
- package/dist/src/services/environmentSanitization.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +0 -9
- package/dist/src/services/fileSystemService.js +0 -11
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/gitService.js +18 -2
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +56 -0
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +5 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +14 -8
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.js +32 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +1 -1
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +4 -0
- package/dist/src/services/modelConfigService.js +8 -3
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +221 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -1
- package/dist/src/services/modelConfigServiceTestUtils.d.ts +10 -0
- package/dist/src/services/modelConfigServiceTestUtils.js +17 -0
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryService.d.ts +28 -0
- package/dist/src/services/sessionSummaryService.js +131 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -0
- package/dist/src/services/sessionSummaryService.test.d.ts +6 -0
- package/dist/src/services/sessionSummaryService.test.js +785 -0
- package/dist/src/services/sessionSummaryService.test.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.d.ts +16 -0
- package/dist/src/services/sessionSummaryUtils.js +129 -0
- package/dist/src/services/sessionSummaryUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.test.d.ts +6 -0
- package/dist/src/services/sessionSummaryUtils.test.js +137 -0
- package/dist/src/services/sessionSummaryUtils.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +4 -0
- package/dist/src/services/shellExecutionService.js +45 -27
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +240 -8
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +238 -0
- package/dist/src/services/test-data/resolved-aliases.golden.json +36 -0
- package/dist/src/skills/skillLoader.d.ts +28 -0
- package/dist/src/skills/skillLoader.js +77 -0
- package/dist/src/skills/skillLoader.js.map +1 -0
- package/dist/src/skills/skillLoader.test.d.ts +1 -0
- package/dist/src/skills/skillLoader.test.js +2 -0
- package/dist/src/skills/skillLoader.test.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +51 -0
- package/dist/src/skills/skillManager.js +89 -0
- package/dist/src/skills/skillManager.js.map +1 -0
- package/dist/src/skills/skillManager.test.d.ts +6 -0
- package/dist/src/skills/skillManager.test.js +128 -0
- package/dist/src/skills/skillManager.test.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +11 -7
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +127 -47
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +105 -18
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +9 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +20 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.js +2 -0
- package/dist/src/telemetry/config.js.map +1 -1
- package/dist/src/telemetry/config.test.js +25 -0
- package/dist/src/telemetry/config.test.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +4 -3
- package/dist/src/telemetry/gcp-exporters.js +8 -4
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -1
- package/dist/src/telemetry/index.js +2 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +5 -3
- package/dist/src/telemetry/loggers.js +353 -334
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +1 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +238 -31
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +22 -0
- package/dist/src/telemetry/metrics.js +32 -0
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +64 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sanitize.d.ts +25 -0
- package/dist/src/telemetry/sanitize.js +48 -0
- package/dist/src/telemetry/sanitize.js.map +1 -0
- package/dist/src/telemetry/sanitize.test.d.ts +6 -0
- package/dist/src/telemetry/sanitize.test.js +279 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -2
- package/dist/src/telemetry/sdk.js +142 -17
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +130 -28
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.js +1 -1
- package/dist/src/telemetry/semantic.js.map +1 -1
- package/dist/src/telemetry/startupProfiler.d.ts +51 -0
- package/dist/src/telemetry/startupProfiler.js +170 -0
- package/dist/src/telemetry/startupProfiler.js.map +1 -0
- package/dist/src/telemetry/startupProfiler.test.d.ts +6 -0
- package/dist/src/telemetry/startupProfiler.test.js +285 -0
- package/dist/src/telemetry/startupProfiler.test.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.js +10 -3
- package/dist/src/telemetry/telemetry.test.js.map +1 -1
- package/dist/src/telemetry/trace.js +2 -2
- package/dist/src/telemetry/trace.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +62 -16
- package/dist/src/telemetry/types.js +157 -27
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -0
- package/dist/src/telemetry/uiTelemetry.js +2 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +4 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-message-bus.d.ts +61 -0
- package/dist/src/test-utils/mock-message-bus.js +160 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +5 -3
- package/dist/src/test-utils/mock-tool.js +12 -11
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/activate-skill.d.ts +27 -0
- package/dist/src/tools/activate-skill.js +120 -0
- package/dist/src/tools/activate-skill.js.map +1 -0
- package/dist/src/tools/activate-skill.test.d.ts +6 -0
- package/dist/src/tools/activate-skill.test.js +95 -0
- package/dist/src/tools/activate-skill.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
- package/dist/src/tools/confirmation-policy.test.js +142 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +27 -5
- package/dist/src/tools/edit.js +449 -137
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +258 -526
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +129 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
- package/dist/src/tools/get-internal-docs.test.js +57 -0
- package/dist/src/tools/get-internal-docs.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +2 -2
- package/dist/src/tools/glob.js +1 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +2 -1
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +2 -2
- package/dist/src/tools/grep.js +1 -1
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +5 -4
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +2 -2
- package/dist/src/tools/ls.js +2 -2
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +2 -1
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +3 -1
- package/dist/src/tools/mcp-client-manager.js +42 -9
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +66 -10
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +44 -6
- package/dist/src/tools/mcp-client.js +476 -176
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +633 -36
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +2 -2
- package/dist/src/tools/mcp-tool.js +20 -7
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +35 -5
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +3 -3
- package/dist/src/tools/memoryTool.js +3 -4
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +5 -2
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +10 -37
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +22 -13
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +2 -2
- package/dist/src/tools/read-file.js +2 -2
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +3 -2
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +2 -2
- package/dist/src/tools/read-many-files.js +7 -6
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +4 -3
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +3 -2
- package/dist/src/tools/ripGrep.js +18 -7
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +60 -4
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +5 -7
- package/dist/src/tools/shell.js +77 -51
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +59 -63
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +2 -1
- package/dist/src/tools/tool-error.js +2 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +59 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.d.ts +6 -0
- package/dist/src/tools/tool-names.test.js +43 -0
- package/dist/src/tools/tool-names.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +11 -7
- package/dist/src/tools/tool-registry.js +15 -10
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +16 -11
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +25 -6
- package/dist/src/tools/tools.js +44 -25
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +3 -1
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +2 -2
- package/dist/src/tools/web-fetch.js +22 -9
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +18 -19
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +2 -2
- package/dist/src/tools/web-search.js +5 -5
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +2 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +2 -2
- package/dist/src/tools/write-file.js +10 -4
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +4 -1
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +2 -2
- package/dist/src/tools/write-todos.js +5 -4
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -1
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.d.ts +8 -0
- package/dist/src/utils/bfsFileSearch.js +63 -23
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +65 -1
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/checkpointUtils.d.ts +82 -0
- package/dist/src/utils/checkpointUtils.js +117 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -0
- package/dist/src/utils/checkpointUtils.test.d.ts +6 -0
- package/dist/src/utils/checkpointUtils.test.js +229 -0
- package/dist/src/utils/checkpointUtils.test.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.d.ts +9 -0
- package/dist/src/utils/customHeaderUtils.js +34 -0
- package/dist/src/utils/customHeaderUtils.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.test.d.ts +6 -0
- package/dist/src/utils/customHeaderUtils.test.js +77 -0
- package/dist/src/utils/customHeaderUtils.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +3 -0
- package/dist/src/utils/debugLogger.js +28 -0
- package/dist/src/utils/debugLogger.js.map +1 -1
- package/dist/src/utils/editCorrector.js +6 -5
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +7 -3
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +9 -1
- package/dist/src/utils/editor.js +23 -14
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +1 -0
- package/dist/src/utils/environmentContext.js +4 -0
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +2 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errorReporting.js +13 -12
- package/dist/src/utils/errorReporting.js.map +1 -1
- package/dist/src/utils/errorReporting.test.js +17 -14
- package/dist/src/utils/errorReporting.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +8 -0
- package/dist/src/utils/errors.js +39 -2
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.d.ts +6 -0
- package/dist/src/utils/errors.test.js +155 -0
- package/dist/src/utils/errors.test.js.map +1 -0
- package/dist/src/utils/events.d.ts +49 -19
- package/dist/src/utils/events.js +21 -9
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/events.test.js +25 -0
- package/dist/src/utils/events.test.js.map +1 -1
- package/dist/src/utils/exitCodes.d.ts +12 -0
- package/dist/src/utils/exitCodes.js +13 -0
- package/dist/src/utils/exitCodes.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +2 -2
- package/dist/src/utils/extensionLoader.js +5 -6
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +11 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/fetch.d.ts +1 -1
- package/dist/src/utils/fetch.js +3 -3
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +53 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +127 -1
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +1 -1
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.d.ts +11 -0
- package/dist/src/utils/geminiIgnoreParser.js +20 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.test.js +48 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +3 -1
- package/dist/src/utils/generateContentResponseUtilities.js +106 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +279 -2
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.js +7 -2
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/googleErrors.js +31 -18
- package/dist/src/utils/googleErrors.js.map +1 -1
- package/dist/src/utils/googleErrors.test.js +10 -2
- package/dist/src/utils/googleErrors.test.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.d.ts +3 -3
- package/dist/src/utils/googleQuotaErrors.js +32 -6
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +94 -2
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +5 -0
- package/dist/src/utils/memoryDiscovery.js +9 -5
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +31 -1
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +4 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +14 -0
- package/dist/src/utils/package.js +15 -2
- package/dist/src/utils/package.js.map +1 -1
- package/dist/src/utils/pathCorrector.js +12 -2
- package/dist/src/utils/pathCorrector.js.map +1 -1
- package/dist/src/utils/pathCorrector.test.js +6 -2
- package/dist/src/utils/pathCorrector.test.js.map +1 -1
- package/dist/src/utils/retry.d.ts +11 -0
- package/dist/src/utils/retry.js +62 -21
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +170 -10
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.d.ts +1 -1
- package/dist/src/utils/schemaValidator.js +1 -1
- package/dist/src/utils/shell-permissions.d.ts +52 -0
- package/dist/src/utils/shell-permissions.js +188 -0
- package/dist/src/utils/shell-permissions.js.map +1 -0
- package/dist/src/utils/shell-permissions.test.d.ts +6 -0
- package/dist/src/utils/shell-permissions.test.js +369 -0
- package/dist/src/utils/shell-permissions.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +16 -47
- package/dist/src/utils/shell-utils.js +99 -195
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +99 -288
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +2 -2
- package/dist/src/utils/stdio.js +2 -2
- package/dist/src/utils/stdio.js.map +1 -1
- package/dist/src/utils/stdio.test.js +5 -5
- package/dist/src/utils/stdio.test.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +3 -2
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +4 -0
- package/dist/src/utils/terminal.js +12 -0
- package/dist/src/utils/terminal.js.map +1 -1
- package/dist/src/utils/terminalSerializer.test.js +17 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -1
- package/dist/src/utils/tokenCalculation.d.ts +19 -0
- package/dist/src/utils/tokenCalculation.js +85 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -0
- package/dist/src/utils/tokenCalculation.test.d.ts +6 -0
- package/dist/src/utils/tokenCalculation.test.js +87 -0
- package/dist/src/utils/tokenCalculation.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +9 -0
- package/dist/src/utils/tool-utils.js +29 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +17 -2
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/version.d.ts +6 -0
- package/dist/src/utils/version.js +15 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/utils/version.test.d.ts +6 -0
- package/dist/src/utils/version.test.js +39 -0
- package/dist/src/utils/version.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
|
@@ -0,0 +1,856 @@
|
|
|
1
|
+
# Hooks on Gemini CLI: Best practices
|
|
2
|
+
|
|
3
|
+
This guide covers security considerations, performance optimization, debugging
|
|
4
|
+
techniques, and privacy considerations for developing and deploying hooks in
|
|
5
|
+
Gemini CLI.
|
|
6
|
+
|
|
7
|
+
## Performance
|
|
8
|
+
|
|
9
|
+
### Keep hooks fast
|
|
10
|
+
|
|
11
|
+
Hooks run synchronously—slow hooks delay the agent loop. Optimize for speed by
|
|
12
|
+
using parallel operations:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// Sequential operations are slower
|
|
16
|
+
const data1 = await fetch(url1).then((r) => r.json());
|
|
17
|
+
const data2 = await fetch(url2).then((r) => r.json());
|
|
18
|
+
const data3 = await fetch(url3).then((r) => r.json());
|
|
19
|
+
|
|
20
|
+
// Prefer parallel operations for better performance
|
|
21
|
+
// Start requests concurrently
|
|
22
|
+
const p1 = fetch(url1).then((r) => r.json());
|
|
23
|
+
const p2 = fetch(url2).then((r) => r.json());
|
|
24
|
+
const p3 = fetch(url3).then((r) => r.json());
|
|
25
|
+
|
|
26
|
+
// Wait for all results
|
|
27
|
+
const [data1, data2, data3] = await Promise.all([p1, p2, p3]);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Cache expensive operations
|
|
31
|
+
|
|
32
|
+
Store results between invocations to avoid repeated computation:
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
const fs = require('fs');
|
|
36
|
+
const path = require('path');
|
|
37
|
+
|
|
38
|
+
const CACHE_FILE = '.gemini/hook-cache.json';
|
|
39
|
+
|
|
40
|
+
function readCache() {
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
|
|
43
|
+
} catch {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function writeCache(data) {
|
|
49
|
+
fs.writeFileSync(CACHE_FILE, JSON.stringify(data, null, 2));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function main() {
|
|
53
|
+
const cache = readCache();
|
|
54
|
+
const cacheKey = `tool-list-${(Date.now() / 3600000) | 0}`; // Hourly cache
|
|
55
|
+
|
|
56
|
+
if (cache[cacheKey]) {
|
|
57
|
+
console.log(JSON.stringify(cache[cacheKey]));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Expensive operation
|
|
62
|
+
const result = await computeExpensiveResult();
|
|
63
|
+
cache[cacheKey] = result;
|
|
64
|
+
writeCache(cache);
|
|
65
|
+
|
|
66
|
+
console.log(JSON.stringify(result));
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Use appropriate events
|
|
71
|
+
|
|
72
|
+
Choose hook events that match your use case to avoid unnecessary execution.
|
|
73
|
+
`AfterAgent` fires once per agent loop completion, while `AfterModel` fires
|
|
74
|
+
after every LLM call (potentially multiple times per loop):
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
// If checking final completion, use AfterAgent instead of AfterModel
|
|
78
|
+
{
|
|
79
|
+
"hooks": {
|
|
80
|
+
"AfterAgent": [
|
|
81
|
+
{
|
|
82
|
+
"matcher": "*",
|
|
83
|
+
"hooks": [
|
|
84
|
+
{
|
|
85
|
+
"name": "final-checker",
|
|
86
|
+
"command": "./check-completion.sh"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Filter with matchers
|
|
96
|
+
|
|
97
|
+
Use specific matchers to avoid unnecessary hook execution. Instead of matching
|
|
98
|
+
all tools with `*`, specify only the tools you need:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"matcher": "write_file|replace",
|
|
103
|
+
"hooks": [
|
|
104
|
+
{
|
|
105
|
+
"name": "validate-writes",
|
|
106
|
+
"command": "./validate.sh"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Optimize JSON parsing
|
|
113
|
+
|
|
114
|
+
For large inputs, use streaming JSON parsers to avoid loading everything into
|
|
115
|
+
memory:
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
// Standard approach: parse entire input
|
|
119
|
+
const input = JSON.parse(await readStdin());
|
|
120
|
+
const content = input.tool_input.content;
|
|
121
|
+
|
|
122
|
+
// For very large inputs: stream and extract only needed fields
|
|
123
|
+
const { createReadStream } = require('fs');
|
|
124
|
+
const JSONStream = require('JSONStream');
|
|
125
|
+
|
|
126
|
+
const stream = createReadStream(0).pipe(JSONStream.parse('tool_input.content'));
|
|
127
|
+
let content = '';
|
|
128
|
+
stream.on('data', (chunk) => {
|
|
129
|
+
content += chunk;
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Debugging
|
|
134
|
+
|
|
135
|
+
### Log to files
|
|
136
|
+
|
|
137
|
+
Write debug information to dedicated log files:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
#!/usr/bin/env bash
|
|
141
|
+
LOG_FILE=".gemini/hooks/debug.log"
|
|
142
|
+
|
|
143
|
+
# Log with timestamp
|
|
144
|
+
log() {
|
|
145
|
+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$LOG_FILE"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
input=$(cat)
|
|
149
|
+
log "Received input: ${input:0:100}..."
|
|
150
|
+
|
|
151
|
+
# Hook logic here
|
|
152
|
+
|
|
153
|
+
log "Hook completed successfully"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Use stderr for errors
|
|
157
|
+
|
|
158
|
+
Error messages on stderr are surfaced appropriately based on exit codes:
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
try {
|
|
162
|
+
const result = dangerousOperation();
|
|
163
|
+
console.log(JSON.stringify({ result }));
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error(`Hook error: ${error.message}`);
|
|
166
|
+
process.exit(2); // Blocking error
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Test hooks independently
|
|
171
|
+
|
|
172
|
+
Run hook scripts manually with sample JSON input:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Create test input
|
|
176
|
+
cat > test-input.json << 'EOF'
|
|
177
|
+
{
|
|
178
|
+
"session_id": "test-123",
|
|
179
|
+
"cwd": "/tmp/test",
|
|
180
|
+
"hook_event_name": "BeforeTool",
|
|
181
|
+
"tool_name": "write_file",
|
|
182
|
+
"tool_input": {
|
|
183
|
+
"file_path": "test.txt",
|
|
184
|
+
"content": "Test content"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
EOF
|
|
188
|
+
|
|
189
|
+
# Test the hook
|
|
190
|
+
cat test-input.json | .gemini/hooks/my-hook.sh
|
|
191
|
+
|
|
192
|
+
# Check exit code
|
|
193
|
+
echo "Exit code: $?"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Check exit codes
|
|
197
|
+
|
|
198
|
+
Ensure your script returns the correct exit code:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
#!/usr/bin/env bash
|
|
202
|
+
set -e # Exit on error
|
|
203
|
+
|
|
204
|
+
# Hook logic
|
|
205
|
+
process_input() {
|
|
206
|
+
# ...
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if process_input; then
|
|
210
|
+
echo "Success message"
|
|
211
|
+
exit 0
|
|
212
|
+
else
|
|
213
|
+
echo "Error message" >&2
|
|
214
|
+
exit 2
|
|
215
|
+
fi
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Enable telemetry
|
|
219
|
+
|
|
220
|
+
Hook execution is logged when `telemetry.logPrompts` is enabled:
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"telemetry": {
|
|
225
|
+
"logPrompts": true
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
View hook telemetry in logs to debug execution issues.
|
|
231
|
+
|
|
232
|
+
### Use hook panel
|
|
233
|
+
|
|
234
|
+
The `/hooks panel` command shows execution status and recent output:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
/hooks panel
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Check for:
|
|
241
|
+
|
|
242
|
+
- Hook execution counts
|
|
243
|
+
- Recent successes/failures
|
|
244
|
+
- Error messages
|
|
245
|
+
- Execution timing
|
|
246
|
+
|
|
247
|
+
## Development
|
|
248
|
+
|
|
249
|
+
### Start simple
|
|
250
|
+
|
|
251
|
+
Begin with basic logging hooks before implementing complex logic:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
#!/usr/bin/env bash
|
|
255
|
+
# Simple logging hook to understand input structure
|
|
256
|
+
input=$(cat)
|
|
257
|
+
echo "$input" >> .gemini/hook-inputs.log
|
|
258
|
+
echo "Logged input"
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Use JSON libraries
|
|
262
|
+
|
|
263
|
+
Parse JSON with proper libraries instead of text processing:
|
|
264
|
+
|
|
265
|
+
**Bad:**
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Fragile text parsing
|
|
269
|
+
tool_name=$(echo "$input" | grep -oP '"tool_name":\s*"\K[^"]+')
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Good:**
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# Robust JSON parsing
|
|
276
|
+
tool_name=$(echo "$input" | jq -r '.tool_name')
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Make scripts executable
|
|
280
|
+
|
|
281
|
+
Always make hook scripts executable:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
chmod +x .gemini/hooks/*.sh
|
|
285
|
+
chmod +x .gemini/hooks/*.js
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Version control
|
|
289
|
+
|
|
290
|
+
Commit hooks to share with your team:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
git add .gemini/hooks/
|
|
294
|
+
git add .gemini/settings.json
|
|
295
|
+
git commit -m "Add project hooks for security and testing"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**`.gitignore` considerations:**
|
|
299
|
+
|
|
300
|
+
```gitignore
|
|
301
|
+
# Ignore hook cache and logs
|
|
302
|
+
.gemini/hook-cache.json
|
|
303
|
+
.gemini/hook-debug.log
|
|
304
|
+
.gemini/memory/session-*.jsonl
|
|
305
|
+
|
|
306
|
+
# Keep hook scripts
|
|
307
|
+
!.gemini/hooks/*.sh
|
|
308
|
+
!.gemini/hooks/*.js
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Document behavior
|
|
312
|
+
|
|
313
|
+
Add descriptions to help others understand your hooks:
|
|
314
|
+
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"hooks": {
|
|
318
|
+
"BeforeTool": [
|
|
319
|
+
{
|
|
320
|
+
"matcher": "write_file|replace",
|
|
321
|
+
"hooks": [
|
|
322
|
+
{
|
|
323
|
+
"name": "secret-scanner",
|
|
324
|
+
"type": "command",
|
|
325
|
+
"command": "$GEMINI_PROJECT_DIR/.gemini/hooks/block-secrets.sh",
|
|
326
|
+
"description": "Scans code changes for API keys, passwords, and other secrets before writing"
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Add comments in hook scripts:
|
|
336
|
+
|
|
337
|
+
```javascript
|
|
338
|
+
#!/usr/bin/env node
|
|
339
|
+
/**
|
|
340
|
+
* RAG Tool Filter Hook
|
|
341
|
+
*
|
|
342
|
+
* This hook reduces the tool space from 100+ tools to ~15 relevant ones
|
|
343
|
+
* by extracting keywords from the user's request and filtering tools
|
|
344
|
+
* based on semantic similarity.
|
|
345
|
+
*
|
|
346
|
+
* Performance: ~500ms average, cached tool embeddings
|
|
347
|
+
* Dependencies: @google/generative-ai
|
|
348
|
+
*/
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Troubleshooting
|
|
352
|
+
|
|
353
|
+
### Hook not executing
|
|
354
|
+
|
|
355
|
+
**Check hook name in `/hooks panel`:**
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
/hooks panel
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Verify the hook appears in the list and is enabled.
|
|
362
|
+
|
|
363
|
+
**Verify matcher pattern:**
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
# Test regex pattern
|
|
367
|
+
echo "write_file|replace" | grep -E "write_.*|replace"
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Check disabled list:**
|
|
371
|
+
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"hooks": {
|
|
375
|
+
"disabled": ["my-hook-name"]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Ensure script is executable:**
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
ls -la .gemini/hooks/my-hook.sh
|
|
384
|
+
chmod +x .gemini/hooks/my-hook.sh
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Verify script path:**
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# Check path expansion
|
|
391
|
+
echo "$GEMINI_PROJECT_DIR/.gemini/hooks/my-hook.sh"
|
|
392
|
+
|
|
393
|
+
# Verify file exists
|
|
394
|
+
test -f "$GEMINI_PROJECT_DIR/.gemini/hooks/my-hook.sh" && echo "File exists"
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Hook timing out
|
|
398
|
+
|
|
399
|
+
**Check configured timeout:**
|
|
400
|
+
|
|
401
|
+
```json
|
|
402
|
+
{
|
|
403
|
+
"name": "slow-hook",
|
|
404
|
+
"timeout": 60000
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Optimize slow operations:**
|
|
409
|
+
|
|
410
|
+
```javascript
|
|
411
|
+
// Before: Sequential operations (slow)
|
|
412
|
+
for (const item of items) {
|
|
413
|
+
await processItem(item);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// After: Parallel operations (fast)
|
|
417
|
+
await Promise.all(items.map((item) => processItem(item)));
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Use caching:**
|
|
421
|
+
|
|
422
|
+
```javascript
|
|
423
|
+
const cache = new Map();
|
|
424
|
+
|
|
425
|
+
async function getCachedData(key) {
|
|
426
|
+
if (cache.has(key)) {
|
|
427
|
+
return cache.get(key);
|
|
428
|
+
}
|
|
429
|
+
const data = await fetchData(key);
|
|
430
|
+
cache.set(key, data);
|
|
431
|
+
return data;
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**Consider splitting into multiple faster hooks:**
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"hooks": {
|
|
440
|
+
"BeforeTool": [
|
|
441
|
+
{
|
|
442
|
+
"matcher": "write_file",
|
|
443
|
+
"hooks": [
|
|
444
|
+
{
|
|
445
|
+
"name": "quick-check",
|
|
446
|
+
"command": "./quick-validation.sh",
|
|
447
|
+
"timeout": 1000
|
|
448
|
+
}
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
"matcher": "write_file",
|
|
453
|
+
"hooks": [
|
|
454
|
+
{
|
|
455
|
+
"name": "deep-check",
|
|
456
|
+
"command": "./deep-analysis.sh",
|
|
457
|
+
"timeout": 30000
|
|
458
|
+
}
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Invalid JSON output
|
|
467
|
+
|
|
468
|
+
**Validate JSON before outputting:**
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
#!/usr/bin/env bash
|
|
472
|
+
output='{"decision": "allow"}'
|
|
473
|
+
|
|
474
|
+
# Validate JSON
|
|
475
|
+
if echo "$output" | jq empty 2>/dev/null; then
|
|
476
|
+
echo "$output"
|
|
477
|
+
else
|
|
478
|
+
echo "Invalid JSON generated" >&2
|
|
479
|
+
exit 1
|
|
480
|
+
fi
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**Ensure proper quoting and escaping:**
|
|
484
|
+
|
|
485
|
+
```javascript
|
|
486
|
+
// Bad: Unescaped string interpolation
|
|
487
|
+
const message = `User said: ${userInput}`;
|
|
488
|
+
console.log(JSON.stringify({ message }));
|
|
489
|
+
|
|
490
|
+
// Good: Automatic escaping
|
|
491
|
+
console.log(JSON.stringify({ message: `User said: ${userInput}` }));
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
**Check for binary data or control characters:**
|
|
495
|
+
|
|
496
|
+
```javascript
|
|
497
|
+
function sanitizeForJSON(str) {
|
|
498
|
+
return str.replace(/[\x00-\x1F\x7F-\x9F]/g, ''); // Remove control chars
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const cleanContent = sanitizeForJSON(content);
|
|
502
|
+
console.log(JSON.stringify({ content: cleanContent }));
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### Exit code issues
|
|
506
|
+
|
|
507
|
+
**Verify script returns correct codes:**
|
|
508
|
+
|
|
509
|
+
```bash
|
|
510
|
+
#!/usr/bin/env bash
|
|
511
|
+
set -e # Exit on error
|
|
512
|
+
|
|
513
|
+
# Processing logic
|
|
514
|
+
if validate_input; then
|
|
515
|
+
echo "Success"
|
|
516
|
+
exit 0
|
|
517
|
+
else
|
|
518
|
+
echo "Validation failed" >&2
|
|
519
|
+
exit 2
|
|
520
|
+
fi
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**Check for unintended errors:**
|
|
524
|
+
|
|
525
|
+
```bash
|
|
526
|
+
#!/usr/bin/env bash
|
|
527
|
+
# Don't use 'set -e' if you want to handle errors explicitly
|
|
528
|
+
# set -e
|
|
529
|
+
|
|
530
|
+
if ! command_that_might_fail; then
|
|
531
|
+
# Handle error
|
|
532
|
+
echo "Command failed but continuing" >&2
|
|
533
|
+
fi
|
|
534
|
+
|
|
535
|
+
# Always exit explicitly
|
|
536
|
+
exit 0
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
**Use trap for cleanup:**
|
|
540
|
+
|
|
541
|
+
```bash
|
|
542
|
+
#!/usr/bin/env bash
|
|
543
|
+
|
|
544
|
+
cleanup() {
|
|
545
|
+
# Cleanup logic
|
|
546
|
+
rm -f /tmp/hook-temp-*
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
trap cleanup EXIT
|
|
550
|
+
|
|
551
|
+
# Hook logic here
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### Environment variables not available
|
|
555
|
+
|
|
556
|
+
**Check if variable is set:**
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
#!/usr/bin/env bash
|
|
560
|
+
|
|
561
|
+
if [ -z "$GEMINI_PROJECT_DIR" ]; then
|
|
562
|
+
echo "GEMINI_PROJECT_DIR not set" >&2
|
|
563
|
+
exit 1
|
|
564
|
+
fi
|
|
565
|
+
|
|
566
|
+
if [ -z "$CUSTOM_VAR" ]; then
|
|
567
|
+
echo "Warning: CUSTOM_VAR not set, using default" >&2
|
|
568
|
+
CUSTOM_VAR="default-value"
|
|
569
|
+
fi
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**Debug available variables:**
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
#!/usr/bin/env bash
|
|
576
|
+
|
|
577
|
+
# List all environment variables
|
|
578
|
+
env > .gemini/hook-env.log
|
|
579
|
+
|
|
580
|
+
# Check specific variables
|
|
581
|
+
echo "GEMINI_PROJECT_DIR: $GEMINI_PROJECT_DIR" >> .gemini/hook-env.log
|
|
582
|
+
echo "GEMINI_SESSION_ID: $GEMINI_SESSION_ID" >> .gemini/hook-env.log
|
|
583
|
+
echo "GEMINI_API_KEY: ${GEMINI_API_KEY:+<set>}" >> .gemini/hook-env.log
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**Use .env files:**
|
|
587
|
+
|
|
588
|
+
```bash
|
|
589
|
+
#!/usr/bin/env bash
|
|
590
|
+
|
|
591
|
+
# Load .env file if it exists
|
|
592
|
+
if [ -f "$GEMINI_PROJECT_DIR/.env" ]; then
|
|
593
|
+
source "$GEMINI_PROJECT_DIR/.env"
|
|
594
|
+
fi
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
## Using Hooks Securely
|
|
598
|
+
|
|
599
|
+
### Threat Model
|
|
600
|
+
|
|
601
|
+
Understanding where hooks come from and what they can do is critical for secure
|
|
602
|
+
usage.
|
|
603
|
+
|
|
604
|
+
| Hook Source | Description |
|
|
605
|
+
| :---------------------------- | :------------------------------------------------------------------------------------------------------------------------- |
|
|
606
|
+
| **System** | Configured by system administrators (e.g., `/etc/gemini-cli/settings.json`, `/Library/...`). Assumed to be the **safest**. |
|
|
607
|
+
| **User** (`~/.gemini/...`) | Configured by you. You are responsible for ensuring they are safe. |
|
|
608
|
+
| **Extensions** | You explicitly approve and install these. Security depends on the extension source (integrity). |
|
|
609
|
+
| **Project** (`./.gemini/...`) | **Untrusted by default.** Safest in trusted internal repos; higher risk in third-party/public repos. |
|
|
610
|
+
|
|
611
|
+
#### Project Hook Security
|
|
612
|
+
|
|
613
|
+
When you open a project with hooks defined in `.gemini/settings.json`:
|
|
614
|
+
|
|
615
|
+
1. **Detection**: Gemini CLI detects the hooks.
|
|
616
|
+
2. **Identification**: A unique identity is generated for each hook based on its
|
|
617
|
+
`name` and `command`.
|
|
618
|
+
3. **Warning**: If this specific hook identity has not been seen before, a
|
|
619
|
+
**warning** is displayed.
|
|
620
|
+
4. **Execution**: The hook is executed (unless specific security settings block
|
|
621
|
+
it).
|
|
622
|
+
5. **Trust**: The hook is marked as "trusted" for this project.
|
|
623
|
+
|
|
624
|
+
> [!IMPORTANT] **Modification Detection**: If the `command` string of a project
|
|
625
|
+
> hook is changed (e.g., by a `git pull`), its identity changes. Gemini CLI will
|
|
626
|
+
> treat it as a **new, untrusted hook** and warn you again. This prevents
|
|
627
|
+
> malicious actors from silently swapping a verified command for a malicious
|
|
628
|
+
> one.
|
|
629
|
+
|
|
630
|
+
### Risks
|
|
631
|
+
|
|
632
|
+
| Risk | Description |
|
|
633
|
+
| :--------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- |
|
|
634
|
+
| **Arbitrary Code Execution** | Hooks run as your user. They can do anything you can do (delete files, install software). |
|
|
635
|
+
| **Data Exfiltration** | A hook could read your input (prompts), output (code), or environment variables (`GEMINI_API_KEY`) and send them to a remote server. |
|
|
636
|
+
| **Prompt Injection** | Malicious content in a file or web page could trick an LLM into running a tool that triggers a hook in an unexpected way. |
|
|
637
|
+
|
|
638
|
+
### Mitigation Strategies
|
|
639
|
+
|
|
640
|
+
#### Verify the source
|
|
641
|
+
|
|
642
|
+
**Verify the source** of any project hooks or extensions before enabling them.
|
|
643
|
+
|
|
644
|
+
- For open-source projects, a quick review of the hook scripts is recommended.
|
|
645
|
+
- For extensions, ensure you trust the author or publisher (e.g., verified
|
|
646
|
+
publishers, well-known community members).
|
|
647
|
+
- Be cautious with obfuscated scripts or compiled binaries from unknown sources.
|
|
648
|
+
|
|
649
|
+
#### Sanitize Environment
|
|
650
|
+
|
|
651
|
+
Hooks inherit the environment of the Gemini CLI process, which may include
|
|
652
|
+
sensitive API keys. Gemini CLI attempts to sanitize sensitive variables, but you
|
|
653
|
+
should be cautious.
|
|
654
|
+
|
|
655
|
+
- **Avoid printing environment variables** to stdout/stderr unless necessary.
|
|
656
|
+
- **Use `.env` files** to securely manage sensitive variables, ensuring they are
|
|
657
|
+
excluded from version control.
|
|
658
|
+
|
|
659
|
+
**System Administrators:** You can enforce environment variable redaction by
|
|
660
|
+
default in the system configuration (e.g., `/etc/gemini-cli/settings.json`):
|
|
661
|
+
|
|
662
|
+
```json
|
|
663
|
+
{
|
|
664
|
+
"security": {
|
|
665
|
+
"environmentVariableRedaction": {
|
|
666
|
+
"enabled": true,
|
|
667
|
+
"blocked": ["MY_SECRET_KEY"],
|
|
668
|
+
"allowed": ["SAFE_VAR"]
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
## Authoring Secure Hooks
|
|
675
|
+
|
|
676
|
+
When writing your own hooks, follow these practices to ensure they are robust
|
|
677
|
+
and secure.
|
|
678
|
+
|
|
679
|
+
### Validate all inputs
|
|
680
|
+
|
|
681
|
+
Never trust data from hooks without validation. Hook inputs often come from the
|
|
682
|
+
LLM or user prompts, which can be manipulated.
|
|
683
|
+
|
|
684
|
+
```bash
|
|
685
|
+
#!/usr/bin/env bash
|
|
686
|
+
input=$(cat)
|
|
687
|
+
|
|
688
|
+
# Validate JSON structure
|
|
689
|
+
if ! echo "$input" | jq empty 2>/dev/null; then
|
|
690
|
+
echo "Invalid JSON input" >&2
|
|
691
|
+
exit 1
|
|
692
|
+
fi
|
|
693
|
+
|
|
694
|
+
# Validate tool_name explicitly
|
|
695
|
+
tool_name=$(echo "$input" | jq -r '.tool_name // empty')
|
|
696
|
+
if [[ "$tool_name" != "write_file" && "$tool_name" != "read_file" ]]; then
|
|
697
|
+
echo "Unexpected tool: $tool_name" >&2
|
|
698
|
+
exit 1
|
|
699
|
+
fi
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
### Use timeouts
|
|
703
|
+
|
|
704
|
+
Prevent denial-of-service (hanging agents) by enforcing timeouts. Gemini CLI
|
|
705
|
+
defaults to 60 seconds, but you should set stricter limits for fast hooks.
|
|
706
|
+
|
|
707
|
+
```json
|
|
708
|
+
{
|
|
709
|
+
"hooks": {
|
|
710
|
+
"BeforeTool": [
|
|
711
|
+
{
|
|
712
|
+
"matcher": "*",
|
|
713
|
+
"hooks": [
|
|
714
|
+
{
|
|
715
|
+
"name": "fast-validator",
|
|
716
|
+
"command": "./hooks/validate.sh",
|
|
717
|
+
"timeout": 5000 // 5 seconds
|
|
718
|
+
}
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
]
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
### Limit permissions
|
|
727
|
+
|
|
728
|
+
Run hooks with minimal required permissions:
|
|
729
|
+
|
|
730
|
+
```bash
|
|
731
|
+
#!/usr/bin/env bash
|
|
732
|
+
# Don't run as root
|
|
733
|
+
if [ "$EUID" -eq 0 ]; then
|
|
734
|
+
echo "Hook should not run as root" >&2
|
|
735
|
+
exit 1
|
|
736
|
+
fi
|
|
737
|
+
|
|
738
|
+
# Check file permissions before writing
|
|
739
|
+
if [ -w "$file_path" ]; then
|
|
740
|
+
# Safe to write
|
|
741
|
+
else
|
|
742
|
+
echo "Insufficient permissions" >&2
|
|
743
|
+
exit 1
|
|
744
|
+
fi
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
### Example: Secret Scanner
|
|
748
|
+
|
|
749
|
+
Use `BeforeTool` hooks to prevent committing sensitive data. This is a powerful
|
|
750
|
+
pattern for enhancing security in your workflow.
|
|
751
|
+
|
|
752
|
+
```javascript
|
|
753
|
+
const SECRET_PATTERNS = [
|
|
754
|
+
/api[_-]?key\s*[:=]\s*['"]?[a-zA-Z0-9_-]{20,}['"]?/i,
|
|
755
|
+
/password\s*[:=]\s*['"]?[^\s'"]{8,}['"]?/i,
|
|
756
|
+
/secret\s*[:=]\s*['"]?[a-zA-Z0-9_-]{20,}['"]?/i,
|
|
757
|
+
/AKIA[0-9A-Z]{16}/, // AWS access key
|
|
758
|
+
/ghp_[a-zA-Z0-9]{36}/, // GitHub personal access token
|
|
759
|
+
/sk-[a-zA-Z0-9]{48}/, // OpenAI API key
|
|
760
|
+
];
|
|
761
|
+
|
|
762
|
+
function containsSecret(content) {
|
|
763
|
+
return SECRET_PATTERNS.some((pattern) => pattern.test(content));
|
|
764
|
+
}
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
## Privacy considerations
|
|
768
|
+
|
|
769
|
+
Hook inputs and outputs may contain sensitive information. Gemini CLI respects
|
|
770
|
+
the `telemetry.logPrompts` setting for hook data logging.
|
|
771
|
+
|
|
772
|
+
### What data is collected
|
|
773
|
+
|
|
774
|
+
Hook telemetry may include:
|
|
775
|
+
|
|
776
|
+
- **Hook inputs:** User prompts, tool arguments, file contents
|
|
777
|
+
- **Hook outputs:** Hook responses, decision reasons, added context
|
|
778
|
+
- **Standard streams:** stdout and stderr from hook processes
|
|
779
|
+
- **Execution metadata:** Hook name, event type, duration, success/failure
|
|
780
|
+
|
|
781
|
+
### Privacy settings
|
|
782
|
+
|
|
783
|
+
**Enabled (default):**
|
|
784
|
+
|
|
785
|
+
Full hook I/O is logged to telemetry. Use this when:
|
|
786
|
+
|
|
787
|
+
- Developing and debugging hooks
|
|
788
|
+
- Telemetry is redirected to a trusted enterprise system
|
|
789
|
+
- You understand and accept the privacy implications
|
|
790
|
+
|
|
791
|
+
**Disabled:**
|
|
792
|
+
|
|
793
|
+
Only metadata is logged (event name, duration, success/failure). Hook inputs and
|
|
794
|
+
outputs are excluded. Use this when:
|
|
795
|
+
|
|
796
|
+
- Sending telemetry to third-party systems
|
|
797
|
+
- Working with sensitive data
|
|
798
|
+
- Privacy regulations require minimizing data collection
|
|
799
|
+
|
|
800
|
+
### Configuration
|
|
801
|
+
|
|
802
|
+
**Disable PII logging in settings:**
|
|
803
|
+
|
|
804
|
+
```json
|
|
805
|
+
{
|
|
806
|
+
"telemetry": {
|
|
807
|
+
"logPrompts": false
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
**Disable via environment variable:**
|
|
813
|
+
|
|
814
|
+
```bash
|
|
815
|
+
export GEMINI_TELEMETRY_LOG_PROMPTS=false
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
### Sensitive data in hooks
|
|
819
|
+
|
|
820
|
+
If your hooks process sensitive data:
|
|
821
|
+
|
|
822
|
+
1. **Minimize logging:** Don't write sensitive data to log files
|
|
823
|
+
2. **Sanitize outputs:** Remove sensitive data before outputting
|
|
824
|
+
3. **Use secure storage:** Encrypt sensitive data at rest
|
|
825
|
+
4. **Limit access:** Restrict hook script permissions
|
|
826
|
+
|
|
827
|
+
**Example sanitization:**
|
|
828
|
+
|
|
829
|
+
```javascript
|
|
830
|
+
function sanitizeOutput(data) {
|
|
831
|
+
const sanitized = { ...data };
|
|
832
|
+
|
|
833
|
+
// Remove sensitive fields
|
|
834
|
+
delete sanitized.apiKey;
|
|
835
|
+
delete sanitized.password;
|
|
836
|
+
|
|
837
|
+
// Redact sensitive strings
|
|
838
|
+
if (sanitized.content) {
|
|
839
|
+
sanitized.content = sanitized.content.replace(
|
|
840
|
+
/api[_-]?key\s*[:=]\s*['"]?[a-zA-Z0-9_-]{20,}['"]?/gi,
|
|
841
|
+
'[REDACTED]',
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
return sanitized;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
console.log(JSON.stringify(sanitizeOutput(hookOutput)));
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
## Learn more
|
|
852
|
+
|
|
853
|
+
- [Hooks Reference](index.md) - Complete API reference
|
|
854
|
+
- [Writing Hooks](writing-hooks.md) - Tutorial and examples
|
|
855
|
+
- [Configuration](../cli/configuration.md) - Gemini CLI settings
|
|
856
|
+
- [Hooks Design Document](../hooks-design.md) - Technical architecture
|