@agent-watch-ai/edge 0.2.5 → 0.3.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/CHANGELOG.md +512 -0
- package/README.md +217 -96
- package/SECURITY.md +69 -0
- package/dist/billing/session-billing.d.ts +19 -0
- package/dist/billing/session-billing.js +52 -0
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.js +20 -0
- package/dist/cli/constants/cli.constants.d.ts +50 -4
- package/dist/cli/constants/cli.constants.js +54 -5
- package/dist/cli/context.d.ts +33 -2
- package/dist/cli/context.js +84 -14
- package/dist/cli/doctor.js +309 -32
- package/dist/cli/hook-check.d.ts +23 -0
- package/dist/cli/hook-check.js +114 -0
- package/dist/cli/hook.js +118 -7
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/misc.d.ts +11 -0
- package/dist/cli/misc.js +80 -4
- package/dist/cli/npx-install.d.ts +37 -0
- package/dist/cli/npx-install.js +79 -0
- package/dist/cli/open-browser.d.ts +39 -0
- package/dist/cli/open-browser.js +62 -0
- package/dist/cli/setup.d.ts +17 -8
- package/dist/cli/setup.js +439 -98
- package/dist/cli/status.js +82 -13
- package/dist/cli/toggle.d.ts +9 -0
- package/dist/cli/toggle.js +113 -0
- package/dist/cli/types/cli.types.d.ts +37 -3
- package/dist/cli/ui.d.ts +7 -0
- package/dist/cli/ui.js +10 -1
- package/dist/cli/uninstall.js +39 -2
- package/dist/cli/update.d.ts +17 -0
- package/dist/cli/update.js +76 -0
- package/dist/cli.js +100 -13
- package/dist/config/config-store.d.ts +57 -0
- package/dist/config/config-store.js +250 -12
- package/dist/config/config.d.ts +53 -6
- package/dist/config/config.js +66 -6
- package/dist/config/constants/config.constants.d.ts +113 -6
- package/dist/config/constants/config.constants.js +126 -8
- package/dist/config/destination.d.ts +24 -0
- package/dist/config/destination.js +33 -0
- package/dist/config/index.d.ts +7 -4
- package/dist/config/index.js +5 -3
- package/dist/config/repo-config.d.ts +11 -7
- package/dist/config/repo-config.js +64 -15
- package/dist/config/root-config.d.ts +72 -0
- package/dist/config/root-config.js +170 -0
- package/dist/config/schemas/config.schema.d.ts +721 -84
- package/dist/config/schemas/config.schema.js +388 -15
- package/dist/config/types/config.types.d.ts +15 -1
- package/dist/config/types/destination.types.d.ts +8 -0
- package/dist/core/async.d.ts +36 -0
- package/dist/core/async.js +68 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/object.d.ts +5 -0
- package/dist/core/object.js +9 -4
- package/dist/core/pipe.d.ts +0 -13
- package/dist/core/pipe.js +1 -9
- package/dist/core/types/core.types.d.ts +9 -0
- package/dist/core/types/core.types.js +0 -3
- package/dist/core/which.d.ts +14 -0
- package/dist/core/which.js +43 -3
- package/dist/credentials/budget.d.ts +9 -0
- package/dist/credentials/budget.js +16 -0
- package/dist/credentials/command-runner.d.ts +16 -0
- package/dist/credentials/command-runner.js +37 -0
- package/dist/credentials/constants/credentials.constants.d.ts +111 -0
- package/dist/credentials/constants/credentials.constants.js +112 -0
- package/dist/credentials/credential-status.d.ts +14 -0
- package/dist/credentials/credential-status.js +34 -0
- package/dist/credentials/credentials.d.ts +72 -0
- package/dist/credentials/credentials.js +253 -0
- package/dist/credentials/device-api.d.ts +64 -0
- package/dist/credentials/device-api.js +150 -0
- package/dist/credentials/device-state.d.ts +31 -0
- package/dist/credentials/device-state.js +51 -0
- package/dist/credentials/identity.d.ts +62 -0
- package/dist/credentials/identity.js +90 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/migration.d.ts +46 -0
- package/dist/credentials/migration.js +164 -0
- package/dist/credentials/schemas/device-api.schema.d.ts +77 -0
- package/dist/credentials/schemas/device-api.schema.js +33 -0
- package/dist/credentials/schemas/device-state.schema.d.ts +51 -0
- package/dist/credentials/schemas/device-state.schema.js +20 -0
- package/dist/credentials/secret-store.d.ts +54 -0
- package/dist/credentials/secret-store.js +217 -0
- package/dist/credentials/sign-in.d.ts +18 -0
- package/dist/credentials/sign-in.js +86 -0
- package/dist/credentials/token-refresher.d.ts +39 -0
- package/dist/credentials/token-refresher.js +185 -0
- package/dist/credentials/types/credentials.types.d.ts +195 -0
- package/dist/credentials/types/credentials.types.js +1 -0
- package/dist/enforcement/constants/enforcement.constants.d.ts +47 -1
- package/dist/enforcement/constants/enforcement.constants.js +56 -0
- package/dist/enforcement/decision-cache.d.ts +20 -1
- package/dist/enforcement/decision-cache.js +65 -2
- package/dist/enforcement/decision-client.d.ts +9 -8
- package/dist/enforcement/decision-client.js +62 -16
- package/dist/enforcement/enforcement.d.ts +23 -2
- package/dist/enforcement/enforcement.js +103 -15
- package/dist/enforcement/index.d.ts +4 -3
- package/dist/enforcement/index.js +3 -2
- package/dist/enforcement/types/enforcement.types.d.ts +64 -0
- package/dist/enrollment/constants/enrollment.constants.d.ts +2 -6
- package/dist/enrollment/constants/enrollment.constants.js +2 -6
- package/dist/enrollment/enrollment.d.ts +16 -0
- package/dist/enrollment/enrollment.js +54 -0
- package/dist/enrollment/index.d.ts +3 -7
- package/dist/enrollment/index.js +1 -1
- package/dist/enrollment/types/enrollment.types.d.ts +9 -13
- package/dist/events/constants/enrich.constants.d.ts +15 -0
- package/dist/events/constants/enrich.constants.js +15 -0
- package/dist/events/constants/events.constants.d.ts +6 -2
- package/dist/events/constants/events.constants.js +5 -1
- package/dist/events/enrich.js +92 -10
- package/dist/events/event-id.d.ts +0 -8
- package/dist/events/event-id.js +0 -10
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/product-event.d.ts +9 -6
- package/dist/events/types/repo-snapshot.types.d.ts +7 -0
- package/dist/events/types/session-billing.types.d.ts +16 -0
- package/dist/events/types/session-billing.types.js +1 -0
- package/dist/feature/constants/feature.constants.d.ts +7 -0
- package/dist/feature/constants/feature.constants.js +7 -0
- package/dist/feature/index.d.ts +1 -1
- package/dist/feature/index.js +1 -1
- package/dist/feature/ticket-candidates.d.ts +14 -0
- package/dist/feature/ticket-candidates.js +26 -8
- package/dist/git/blob-hash.d.ts +21 -0
- package/dist/git/blob-hash.js +69 -0
- package/dist/git/checkout-root.d.ts +27 -0
- package/dist/git/checkout-root.js +75 -0
- package/dist/git/constants/git.constants.d.ts +160 -0
- package/dist/git/constants/git.constants.js +181 -0
- package/dist/git/fingerprint.d.ts +74 -0
- package/dist/git/fingerprint.js +219 -0
- package/dist/git/gate-checkout.d.ts +44 -0
- package/dist/git/gate-checkout.js +201 -0
- package/dist/git/git-context.d.ts +45 -0
- package/dist/git/git-context.js +61 -3
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +2 -1
- package/dist/git/manifest-repository.d.ts +13 -0
- package/dist/git/manifest-repository.js +92 -0
- package/dist/git/repo-snapshot.d.ts +29 -3
- package/dist/git/repo-snapshot.js +110 -7
- package/dist/git/repository-root.d.ts +39 -0
- package/dist/git/repository-root.js +131 -0
- package/dist/git/types/git.types.d.ts +55 -0
- package/dist/git/types/repository-root.types.d.ts +11 -0
- package/dist/git/types/repository-root.types.js +1 -0
- package/dist/git/types/snapshot.types.d.ts +9 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +7 -0
- package/dist/pipeline/constants/pipeline.constants.js +7 -0
- package/dist/pipeline/hook-pipeline.js +360 -32
- package/dist/pipeline/types/pipeline.types.d.ts +39 -4
- package/dist/privacy/constants/privacy.constants.js +15 -1
- package/dist/privacy/index.d.ts +1 -0
- package/dist/privacy/index.js +1 -0
- package/dist/privacy/product-capture.d.ts +12 -0
- package/dist/privacy/product-capture.js +73 -0
- package/dist/privacy/sanitizer.d.ts +21 -3
- package/dist/privacy/sanitizer.js +52 -8
- package/dist/process/ancestors.d.ts +39 -0
- package/dist/process/ancestors.js +121 -0
- package/dist/process/constants/process.constants.d.ts +34 -0
- package/dist/process/constants/process.constants.js +34 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +2 -0
- package/dist/process/types/process.types.d.ts +23 -0
- package/dist/process/types/process.types.js +1 -0
- package/dist/providers/antigravity/antigravity.adapter.d.ts +12 -1
- package/dist/providers/antigravity/antigravity.adapter.js +21 -3
- package/dist/providers/antigravity/antigravity.detect.d.ts +0 -9
- package/dist/providers/antigravity/antigravity.detect.js +1 -1
- package/dist/providers/antigravity/antigravity.provider.js +3 -2
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +2 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +2 -0
- package/dist/providers/claude/claude.adapter.d.ts +11 -1
- package/dist/providers/claude/claude.adapter.js +26 -5
- package/dist/providers/claude/claude.otel.d.ts +32 -18
- package/dist/providers/claude/claude.otel.js +81 -6
- package/dist/providers/claude/claude.provider.js +5 -2
- package/dist/providers/claude/constants/claude.constants.d.ts +2 -0
- package/dist/providers/claude/constants/claude.constants.js +2 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +4 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +8 -0
- package/dist/providers/codex/codex.adapter.d.ts +15 -1
- package/dist/providers/codex/codex.adapter.js +29 -5
- package/dist/providers/codex/codex.otel.d.ts +24 -2
- package/dist/providers/codex/codex.otel.js +147 -30
- package/dist/providers/codex/codex.provider.js +5 -2
- package/dist/providers/codex/constants/codex.constants.d.ts +2 -0
- package/dist/providers/codex/constants/codex.constants.js +16 -0
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +5 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +5 -0
- package/dist/providers/constants/provider.constants.d.ts +0 -3
- package/dist/providers/constants/provider.constants.js +0 -3
- package/dist/providers/cursor/constants/cursor.constants.d.ts +7 -0
- package/dist/providers/cursor/constants/cursor.constants.js +7 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
- package/dist/providers/cursor/cursor.adapter.js +52 -3
- package/dist/providers/cursor/cursor.detect.d.ts +0 -7
- package/dist/providers/cursor/cursor.detect.js +1 -1
- package/dist/providers/cursor/cursor.provider.js +5 -2
- package/dist/providers/gemini/constants/gemini.constants.d.ts +9 -0
- package/dist/providers/gemini/constants/gemini.constants.js +9 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +3 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +3 -0
- package/dist/providers/gemini/gemini.adapter.d.ts +14 -1
- package/dist/providers/gemini/gemini.adapter.js +25 -5
- package/dist/providers/gemini/gemini.detect.d.ts +0 -7
- package/dist/providers/gemini/gemini.detect.js +1 -1
- package/dist/providers/gemini/gemini.otel.d.ts +19 -20
- package/dist/providers/gemini/gemini.otel.js +121 -17
- package/dist/providers/gemini/gemini.provider.js +2 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/loaders.d.ts +10 -0
- package/dist/providers/loaders.js +40 -0
- package/dist/providers/provider.d.ts +11 -0
- package/dist/providers/provider.js +1 -1
- package/dist/providers/registry.d.ts +11 -8
- package/dist/providers/registry.js +11 -15
- package/dist/providers/shared/constants/hook-refusal.constants.d.ts +7 -0
- package/dist/providers/shared/constants/hook-refusal.constants.js +7 -0
- package/dist/providers/shared/constants/shell-directories.constants.d.ts +30 -0
- package/dist/providers/shared/constants/shell-directories.constants.js +39 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +18 -2
- package/dist/providers/shared/constants/tooling.constants.js +19 -3
- package/dist/providers/shared/event-builder.d.ts +12 -14
- package/dist/providers/shared/event-builder.js +20 -14
- package/dist/providers/shared/exporter-allowlist.d.ts +20 -0
- package/dist/providers/shared/exporter-allowlist.js +49 -0
- package/dist/providers/shared/hook-config.d.ts +2 -21
- package/dist/providers/shared/hook-config.js +5 -4
- package/dist/providers/shared/hook-refusal.d.ts +12 -0
- package/dist/providers/shared/hook-refusal.js +17 -1
- package/dist/providers/shared/install-record.d.ts +12 -2
- package/dist/providers/shared/install-record.js +5 -2
- package/dist/providers/shared/shell-directories.d.ts +24 -0
- package/dist/providers/shared/shell-directories.js +90 -0
- package/dist/providers/shared/tooling.d.ts +12 -1
- package/dist/providers/shared/tooling.js +18 -0
- package/dist/providers/shared/types/adapter.types.d.ts +1 -2
- package/dist/providers/types/provider.types.d.ts +57 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +32 -0
- package/dist/snapshot/constants/snapshot.constants.js +33 -0
- package/dist/snapshot/snapshot-event.js +52 -11
- package/dist/snapshot/snapshot-pipeline.js +1 -1
- package/dist/snapshot/types/snapshot.types.d.ts +2 -0
- package/dist/storage/atomic-file.d.ts +7 -0
- package/dist/storage/atomic-file.js +1 -1
- package/dist/storage/constants/storage.constants.d.ts +17 -0
- package/dist/storage/constants/storage.constants.js +17 -0
- package/dist/storage/disabled.d.ts +13 -0
- package/dist/storage/disabled.js +24 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/paths.js +3 -2
- package/dist/storage/schemas/storage.schema.d.ts +72 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/storage/sweep-marker.d.ts +19 -0
- package/dist/storage/sweep-marker.js +55 -0
- package/dist/storage/types/storage.types.d.ts +2 -0
- package/dist/storage/uninstalled.d.ts +58 -0
- package/dist/storage/uninstalled.js +107 -0
- package/dist/transport/auth-block.d.ts +66 -0
- package/dist/transport/auth-block.js +129 -0
- package/dist/transport/constants/transport.constants.d.ts +82 -3
- package/dist/transport/constants/transport.constants.js +83 -4
- package/dist/transport/cooldown.js +8 -1
- package/dist/transport/delivery.d.ts +14 -6
- package/dist/transport/delivery.js +80 -55
- package/dist/transport/http-transport.d.ts +1 -0
- package/dist/transport/http-transport.js +52 -10
- package/dist/transport/index.d.ts +6 -3
- package/dist/transport/index.js +3 -0
- package/dist/transport/queue-partition.d.ts +91 -0
- package/dist/transport/queue-partition.js +143 -0
- package/dist/transport/queue.d.ts +99 -20
- package/dist/transport/queue.js +210 -69
- package/dist/transport/response-body.d.ts +25 -0
- package/dist/transport/response-body.js +64 -0
- package/dist/transport/send.d.ts +11 -0
- package/dist/transport/send.js +17 -0
- package/dist/transport/types/delivery-flow.types.d.ts +19 -0
- package/dist/transport/types/delivery-flow.types.js +1 -0
- package/dist/transport/types/transport.types.d.ts +45 -0
- package/dist/turns/claude-transcript.d.ts +19 -1
- package/dist/turns/claude-transcript.js +46 -1
- package/dist/turns/codex-originator.d.ts +11 -0
- package/dist/turns/codex-originator.js +31 -0
- package/dist/turns/codex-transcript.d.ts +30 -0
- package/dist/turns/codex-transcript.js +88 -0
- package/dist/turns/constants/turns.constants.d.ts +141 -5
- package/dist/turns/constants/turns.constants.js +155 -5
- package/dist/turns/file-identity.d.ts +27 -0
- package/dist/turns/file-identity.js +48 -0
- package/dist/turns/gemini-transcript.d.ts +30 -0
- package/dist/turns/gemini-transcript.js +96 -0
- package/dist/turns/index.d.ts +3 -3
- package/dist/turns/index.js +1 -1
- package/dist/turns/inherited-checkout.d.ts +54 -0
- package/dist/turns/inherited-checkout.js +155 -0
- package/dist/turns/native-session-titles.d.ts +26 -0
- package/dist/turns/native-session-titles.js +102 -0
- package/dist/turns/transcript.d.ts +3 -2
- package/dist/turns/transcript.js +5 -1
- package/dist/turns/turn-state.d.ts +224 -3
- package/dist/turns/turn-state.js +456 -21
- package/dist/turns/turn-summary.d.ts +1 -14
- package/dist/turns/turn-summary.js +87 -51
- package/dist/turns/turn-tracker.d.ts +21 -2
- package/dist/turns/turn-tracker.js +379 -56
- package/dist/turns/types/transcript.types.d.ts +5 -0
- package/dist/turns/types/turn-state.types.d.ts +116 -5
- package/dist/turns/types/turn-summary.types.d.ts +64 -14
- package/dist/turns/types/turn-tracker.types.d.ts +27 -1
- package/dist/turns/work-checkout.d.ts +65 -0
- package/dist/turns/work-checkout.js +666 -0
- package/dist/untraced/constants/untraced.constants.d.ts +31 -0
- package/dist/untraced/constants/untraced.constants.js +63 -0
- package/dist/untraced/untraced.d.ts +35 -0
- package/dist/untraced/untraced.js +105 -0
- package/dist/update/constants/update.constants.d.ts +18 -0
- package/dist/update/constants/update.constants.js +20 -0
- package/dist/update/update-check.d.ts +52 -0
- package/dist/update/update-check.js +113 -0
- package/docs/AUDIT_PROMPT.md +129 -0
- package/docs/DATA_HANDLING.md +648 -0
- package/docs/ENTERPRISE_DEPLOYMENT.md +179 -0
- package/docs/PERFORMANCE.md +81 -0
- package/package.json +14 -4
- package/dist/enrollment/enrollment-provider.d.ts +0 -5
- package/dist/enrollment/manual-enrollment.d.ts +0 -32
- package/dist/enrollment/manual-enrollment.js +0 -72
- package/example/README.md +0 -43
- package/example/server.mjs +0 -240
- /package/dist/{enrollment/enrollment-provider.js → config/types/destination.types.js} +0 -0
|
@@ -16,7 +16,9 @@ export declare const LEGACY_HELPER_KEY = "otelHeadersHelper";
|
|
|
16
16
|
* Covers settings written before install state existed, and keeps the names an
|
|
17
17
|
* older version wrote (GEMINI_ENABLE_TELEMETRY) so those are cleaned up too.
|
|
18
18
|
*/
|
|
19
|
-
export declare const GEMINI_LEGACY_OWNED_KEYS: readonly ["GEMINI_TELEMETRY_ENABLED", "GEMINI_TELEMETRY_TARGET", "GEMINI_TELEMETRY_OTLP_ENDPOINT", "GEMINI_TELEMETRY_OTLP_PROTOCOL", "GEMINI_TELEMETRY_TRACES_ENABLED", "GEMINI_ENABLE_TELEMETRY", "OTEL_METRICS_EXPORTER", "OTEL_LOGS_EXPORTER", "OTEL_TRACES_EXPORTER", "OTEL_EXPORTER_OTLP_PROTOCOL", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_EXPORTER_OTLP_HEADERS", "otelHeadersHelper"];
|
|
19
|
+
export declare const GEMINI_LEGACY_OWNED_KEYS: readonly ["GEMINI_TELEMETRY_ENABLED", "GEMINI_TELEMETRY_LOG_PROMPTS", "GEMINI_TELEMETRY_TARGET", "GEMINI_TELEMETRY_OTLP_ENDPOINT", "GEMINI_TELEMETRY_OTLP_PROTOCOL", "GEMINI_TELEMETRY_TRACES_ENABLED", "GEMINI_ENABLE_TELEMETRY", "OTEL_METRICS_EXPORTER", "OTEL_LOGS_EXPORTER", "OTEL_TRACES_EXPORTER", "OTEL_EXPORTER_OTLP_PROTOCOL", "OTEL_EXPORTER_OTLP_ENDPOINT", "OTEL_EXPORTER_OTLP_HEADERS", "otelHeadersHelper"];
|
|
20
|
+
/** The keys that say where Gemini's exporters send. */
|
|
21
|
+
export declare const GEMINI_ENDPOINT_KEYS: readonly string[];
|
|
20
22
|
export declare const OTEL_EXPORTER_NONE = "none";
|
|
21
23
|
export declare const OTEL_EXPORTER_OTLP = "otlp";
|
|
22
24
|
/**
|
|
@@ -18,6 +18,7 @@ export const LEGACY_HELPER_KEY = 'otelHeadersHelper';
|
|
|
18
18
|
*/
|
|
19
19
|
export const GEMINI_LEGACY_OWNED_KEYS = [
|
|
20
20
|
'GEMINI_TELEMETRY_ENABLED',
|
|
21
|
+
'GEMINI_TELEMETRY_LOG_PROMPTS',
|
|
21
22
|
'GEMINI_TELEMETRY_TARGET',
|
|
22
23
|
'GEMINI_TELEMETRY_OTLP_ENDPOINT',
|
|
23
24
|
'GEMINI_TELEMETRY_OTLP_PROTOCOL',
|
|
@@ -31,6 +32,8 @@ export const GEMINI_LEGACY_OWNED_KEYS = [
|
|
|
31
32
|
OTLP_HEADERS_KEY,
|
|
32
33
|
LEGACY_HELPER_KEY
|
|
33
34
|
];
|
|
35
|
+
/** The keys that say where Gemini's exporters send. */
|
|
36
|
+
export const GEMINI_ENDPOINT_KEYS = ['GEMINI_TELEMETRY_OTLP_ENDPOINT', 'OTEL_EXPORTER_OTLP_ENDPOINT'];
|
|
34
37
|
export const OTEL_EXPORTER_NONE = 'none';
|
|
35
38
|
export const OTEL_EXPORTER_OTLP = 'otlp';
|
|
36
39
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentWatchEvent } from '../../events/types/events.types.js';
|
|
2
|
-
import type { HookContext } from '../types/provider.types.js';
|
|
2
|
+
import type { HookContext, ShellCall } from '../types/provider.types.js';
|
|
3
3
|
export type { GeminiPayload } from './types/gemini.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Translate one Gemini CLI hook payload into canonical events.
|
|
@@ -13,3 +13,16 @@ export type { GeminiPayload } from './types/gemini.types.js';
|
|
|
13
13
|
* @returns The canonical events, or an empty list for an unusable payload.
|
|
14
14
|
*/
|
|
15
15
|
export declare function parseGeminiHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
|
|
16
|
+
/**
|
|
17
|
+
* The command a `run_shell_command` call is about to run, and its `dir_path`.
|
|
18
|
+
*
|
|
19
|
+
* Gemini CLI's shell tool takes `command` and an optional `dir_path`
|
|
20
|
+
* (google-gemini/gemini-cli `packages/core/src/tools/definitions/base-declarations.ts`,
|
|
21
|
+
* 2026-09); the hook's `tool_input` is the model's raw arguments. `dir_path`
|
|
22
|
+
* counts only when absolute: Gemini resolves a relative one against its project
|
|
23
|
+
* root, which the hook payload does not name.
|
|
24
|
+
*
|
|
25
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
26
|
+
* @returns The call, or undefined for any other payload.
|
|
27
|
+
*/
|
|
28
|
+
export declare function geminiShellCall(rawPayload: unknown): ShellCall | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { sha256Hex } from '../../events/event-id.js';
|
|
2
2
|
import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { asRecord } from '../../core/object.js';
|
|
4
|
+
import { SHELL_COMMAND_KEY } from '../shared/constants/tooling.constants.js';
|
|
5
|
+
import { classifyTool, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
6
|
+
import { GEMINI_DISPLAY_NAME, GEMINI_EVENT_TYPE_MAP, GEMINI_PROMPT_EVENTS, GEMINI_PROVIDER_ID, GEMINI_STOP_EVENTS, GEMINI_TOOL_COMPLETE_EVENTS, GEMINI_TOOL_EVENTS, GEMINI_SHELL_DIR_KEY, GEMINI_SHELL_CALL_EVENTS, GEMINI_TOOL_START_EVENTS, GEMINI_UNKNOWN_EVENT } from './constants/gemini.constants.js';
|
|
5
7
|
import { geminiPayloadSchema } from './schemas/gemini.schema.js';
|
|
6
8
|
/**
|
|
7
9
|
* Translate one Gemini CLI hook payload into canonical events.
|
|
@@ -22,6 +24,25 @@ export function parseGeminiHookEvent(rawPayload, context) {
|
|
|
22
24
|
const providerEventType = payload.hook_event_name ?? GEMINI_UNKNOWN_EVENT;
|
|
23
25
|
return [withPatch(geminiBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
|
|
24
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The command a `run_shell_command` call is about to run, and its `dir_path`.
|
|
29
|
+
*
|
|
30
|
+
* Gemini CLI's shell tool takes `command` and an optional `dir_path`
|
|
31
|
+
* (google-gemini/gemini-cli `packages/core/src/tools/definitions/base-declarations.ts`,
|
|
32
|
+
* 2026-09); the hook's `tool_input` is the model's raw arguments. `dir_path`
|
|
33
|
+
* counts only when absolute: Gemini resolves a relative one against its project
|
|
34
|
+
* root, which the hook payload does not name.
|
|
35
|
+
*
|
|
36
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
37
|
+
* @returns The call, or undefined for any other payload.
|
|
38
|
+
*/
|
|
39
|
+
export function geminiShellCall(rawPayload) {
|
|
40
|
+
const parsed = geminiPayloadSchema.safeParse(rawPayload);
|
|
41
|
+
if (!parsed.success || !GEMINI_SHELL_CALL_EVENTS.has(parsed.data.hook_event_name ?? '') || classifyTool(parsed.data.tool_name) !== 'shell')
|
|
42
|
+
return undefined;
|
|
43
|
+
const input = asRecord(parsed.data.tool_input);
|
|
44
|
+
return shellCallOf(input?.[SHELL_COMMAND_KEY], input?.[GEMINI_SHELL_DIR_KEY]);
|
|
45
|
+
}
|
|
25
46
|
/**
|
|
26
47
|
* The provider-independent part of the event.
|
|
27
48
|
*
|
|
@@ -63,7 +84,6 @@ function geminiBaseEvent(payload, providerEventType) {
|
|
|
63
84
|
* @returns The patch; empty for a hook we model but read nothing from.
|
|
64
85
|
*/
|
|
65
86
|
function hookPatch(payload, providerEventType, context) {
|
|
66
|
-
const capture = context.config.capture;
|
|
67
87
|
if (providerEventType === 'SessionStart') {
|
|
68
88
|
return {
|
|
69
89
|
metadata: { sessionSource: payload.source },
|
|
@@ -73,13 +93,13 @@ function hookPatch(payload, providerEventType, context) {
|
|
|
73
93
|
if (providerEventType === 'SessionEnd')
|
|
74
94
|
return { metadata: { sessionEndReason: payload.reason } };
|
|
75
95
|
if (GEMINI_PROMPT_EVENTS.has(providerEventType))
|
|
76
|
-
return promptPatch(payload.prompt ?? '', capture);
|
|
96
|
+
return promptPatch(payload.prompt ?? '', context.config.capture);
|
|
77
97
|
if (GEMINI_TOOL_EVENTS.has(providerEventType))
|
|
78
98
|
return geminiToolPatch(payload, providerEventType, context);
|
|
79
99
|
if (GEMINI_STOP_EVENTS.has(providerEventType)) {
|
|
80
100
|
// Gemini reports the answer as `prompt_response`; the other name is what
|
|
81
101
|
// installations registered before the rename still send.
|
|
82
|
-
const response = responsePatch(payload.prompt_response ?? payload.last_assistant_message ?? ''
|
|
102
|
+
const response = responsePatch(payload.prompt_response ?? payload.last_assistant_message ?? '');
|
|
83
103
|
return { ...response, metadata: { stopHookActive: payload.stop_hook_active, ...response.metadata } };
|
|
84
104
|
}
|
|
85
105
|
if (providerEventType === 'SubagentStart' || providerEventType === 'SubagentStop') {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { Env } from '../../core/types/core.types.js';
|
|
2
2
|
import type { DetectionResult } from '../types/provider.types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Gemini CLI's configuration root.
|
|
5
|
-
*
|
|
6
|
-
* @param env - Environment supplying HOME and GEMINI_HOME.
|
|
7
|
-
* @returns `$GEMINI_HOME`, or `~/.gemini`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function geminiHome(env: Env): string;
|
|
10
3
|
/**
|
|
11
4
|
* Where Gemini CLI reads hooks and telemetry settings from.
|
|
12
5
|
*
|
|
@@ -11,7 +11,7 @@ import { GEMINI_CLI_VAR, GEMINI_EXECUTABLES, GEMINI_HOME_DIR, GEMINI_HOME_VAR, G
|
|
|
11
11
|
* @param env - Environment supplying HOME and GEMINI_HOME.
|
|
12
12
|
* @returns `$GEMINI_HOME`, or `~/.gemini`.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
function geminiHome(env) {
|
|
15
15
|
return env.vars[GEMINI_HOME_VAR] ?? path.join(env.home, GEMINI_HOME_DIR);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
import type { Env } from '../../core/types/core.types.js';
|
|
2
|
+
import type { AgentWatchConfig, OtelSignalName } from '../../config/types/config.types.js';
|
|
2
3
|
import type { NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
|
|
3
|
-
/**
|
|
4
|
-
* The environment Gemini CLI actually reads.
|
|
5
|
-
*
|
|
6
|
-
* Every name here was verified against the installed `@google/gemini-cli`
|
|
7
|
-
* bundle (`resolveTelemetrySettings`), because the previous set was written
|
|
8
|
-
* from Claude Code's vocabulary and Gemini reads none of it:
|
|
9
|
-
*
|
|
10
|
-
* - `GEMINI_TELEMETRY_ENABLED`, not `GEMINI_ENABLE_TELEMETRY`. The latter
|
|
11
|
-
* appears nowhere in the CLI, and `initializeTelemetry()` returns immediately
|
|
12
|
-
* unless the former is set, so no exporter was ever created.
|
|
13
|
-
* - Auth travels in `OTEL_EXPORTER_OTLP_HEADERS`. Gemini has no
|
|
14
|
-
* `otelHeadersHelper` — that is a Claude Code setting — so with the helper
|
|
15
|
-
* alone the exporter posted without an Authorization header and the gateway,
|
|
16
|
-
* which is fail-closed, answered 401 to every batch.
|
|
17
|
-
*
|
|
18
|
-
* @param context - Environment, paths and effective config.
|
|
19
|
-
* @returns The desired variables, or undefined when telemetry is off or no
|
|
20
|
-
* backend is configured.
|
|
21
|
-
*/
|
|
22
|
-
export declare function desiredGeminiOtelEnv(context: SetupContext): Record<string, string> | undefined;
|
|
23
4
|
/** Configures Gemini CLI's own OTLP export. */
|
|
24
5
|
export declare class GeminiOtelConfigurator implements NativeTelemetryConfigurator {
|
|
25
6
|
/**
|
|
@@ -52,6 +33,13 @@ export declare class GeminiOtelConfigurator implements NativeTelemetryConfigurat
|
|
|
52
33
|
* install state.
|
|
53
34
|
*/
|
|
54
35
|
uninstall(context: SetupContext): Promise<SetupOutcome>;
|
|
36
|
+
/**
|
|
37
|
+
* Where the exporter keys `uninstall` would remove send.
|
|
38
|
+
*
|
|
39
|
+
* @param context - Environment and install state.
|
|
40
|
+
* @returns The owned endpoints.
|
|
41
|
+
*/
|
|
42
|
+
exporterEndpoints(context: SetupContext): Promise<readonly string[]>;
|
|
55
43
|
/**
|
|
56
44
|
* Handle `configure` when telemetry is off or unconfigurable.
|
|
57
45
|
*
|
|
@@ -59,4 +47,15 @@ export declare class GeminiOtelConfigurator implements NativeTelemetryConfigurat
|
|
|
59
47
|
* @returns The outcome.
|
|
60
48
|
*/
|
|
61
49
|
private configureDisabled;
|
|
50
|
+
/**
|
|
51
|
+
* Signals Gemini was asked for but will not be given under current consent.
|
|
52
|
+
*
|
|
53
|
+
* Its usage logs always carry function arguments, and its detailed traces can
|
|
54
|
+
* carry prompts — so logs wait on tool-content consent and traces are never
|
|
55
|
+
* given, which is why the answer is per signal rather than all-or-nothing.
|
|
56
|
+
*
|
|
57
|
+
* @param config - Effective configuration.
|
|
58
|
+
* @returns The requested signals that are held back; empty when none are.
|
|
59
|
+
*/
|
|
60
|
+
withheldSignals(config: AgentWatchConfig): readonly OtelSignalName[];
|
|
62
61
|
}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { asRecord, omitKeys } from '../../core/object.js';
|
|
2
|
-
import { enabledSignalNames,
|
|
3
|
-
import {
|
|
2
|
+
import { enabledSignalNames, otlpBaseUrl, toolContentConsented } from '../../config/config.js';
|
|
3
|
+
import { INSTALLATION_HEADER } from '../../transport/constants/transport.constants.js';
|
|
4
|
+
import { backupFile, currentMode } from '../../storage/atomic-file.js';
|
|
5
|
+
import { SECRET_FILE_MODE } from '../../storage/constants/storage.constants.js';
|
|
4
6
|
import { readJsonFile } from '../../storage/json-file.js';
|
|
5
7
|
import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
|
|
6
8
|
import { writeJsonValidated } from '../shared/hook-config.js';
|
|
7
9
|
import { withOtelInstall, withoutOtelInstall } from '../shared/install-record.js';
|
|
8
10
|
import { geminiSettingsPath } from './gemini.detect.js';
|
|
9
11
|
import { GEMINI_PROVIDER_ID } from './constants/gemini.constants.js';
|
|
10
|
-
import { ENV_BLOCK_KEY, GEMINI_LEGACY_OWNED_KEYS, GEMINI_OTLP_PROTOCOL, GEMINI_TELEMETRY_TARGET_LOCAL, LEGACY_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OTLP, OTLP_HEADERS_KEY, STANDARD_OTLP_PROTOCOL } from './constants/gemini.otel.constants.js';
|
|
12
|
+
import { ENV_BLOCK_KEY, GEMINI_ENDPOINT_KEYS, GEMINI_LEGACY_OWNED_KEYS, GEMINI_OTLP_PROTOCOL, GEMINI_TELEMETRY_TARGET_LOCAL, LEGACY_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OTLP, OTLP_HEADERS_KEY, STANDARD_OTLP_PROTOCOL } from './constants/gemini.otel.constants.js';
|
|
13
|
+
/**
|
|
14
|
+
* Gemini's own prompt-logging switch, forced off.
|
|
15
|
+
*
|
|
16
|
+
* Never treated as a foreign key: a user who set it to `true` before installing
|
|
17
|
+
* is exactly the case this exists to override, and refusing to configure it
|
|
18
|
+
* would leave prompt logging on *and* drop the llm.call ledger. Overriding a
|
|
19
|
+
* switch that only ever reduces what leaves the machine is not the redirection
|
|
20
|
+
* the conflict check protects against. Mirrors `CONTENT_LOG_OFF` in claude.otel.
|
|
21
|
+
*/
|
|
22
|
+
const CONTENT_LOG_OFF = {
|
|
23
|
+
GEMINI_TELEMETRY_LOG_PROMPTS: 'false'
|
|
24
|
+
};
|
|
11
25
|
/**
|
|
12
26
|
* The environment Gemini CLI actually reads.
|
|
13
27
|
*
|
|
@@ -27,13 +41,14 @@ import { ENV_BLOCK_KEY, GEMINI_LEGACY_OWNED_KEYS, GEMINI_OTLP_PROTOCOL, GEMINI_T
|
|
|
27
41
|
* @returns The desired variables, or undefined when telemetry is off or no
|
|
28
42
|
* backend is configured.
|
|
29
43
|
*/
|
|
30
|
-
|
|
44
|
+
function desiredGeminiOtelEnv(context) {
|
|
31
45
|
const otlpBase = otlpBaseUrl(context.config);
|
|
32
|
-
|
|
46
|
+
const signals = safeGeminiSignals(context.config);
|
|
47
|
+
if (!otlpBase || !anySignal(signals))
|
|
33
48
|
return undefined;
|
|
34
|
-
const signals = context.config.otel;
|
|
35
49
|
return {
|
|
36
50
|
GEMINI_TELEMETRY_ENABLED: 'true',
|
|
51
|
+
...CONTENT_LOG_OFF,
|
|
37
52
|
GEMINI_TELEMETRY_TARGET: GEMINI_TELEMETRY_TARGET_LOCAL,
|
|
38
53
|
GEMINI_TELEMETRY_OTLP_ENDPOINT: otlpBase,
|
|
39
54
|
GEMINI_TELEMETRY_OTLP_PROTOCOL: GEMINI_OTLP_PROTOCOL,
|
|
@@ -43,9 +58,32 @@ export function desiredGeminiOtelEnv(context) {
|
|
|
43
58
|
OTEL_TRACES_EXPORTER: signals.traces ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
|
|
44
59
|
OTEL_EXPORTER_OTLP_PROTOCOL: STANDARD_OTLP_PROTOCOL,
|
|
45
60
|
OTEL_EXPORTER_OTLP_ENDPOINT: otlpBase,
|
|
46
|
-
...(context.config.token
|
|
61
|
+
...(context.config.token
|
|
62
|
+
? { [OTLP_HEADERS_KEY]: otlpHeaders(context.config.token, context.config.installationId) }
|
|
63
|
+
: {})
|
|
47
64
|
};
|
|
48
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The `OTEL_EXPORTER_OTLP_HEADERS` value: comma-separated `key=value` pairs.
|
|
68
|
+
*
|
|
69
|
+
* Carries the installation id beside the bearer so a Gemini call that no turn
|
|
70
|
+
* summary claimed can still be traced to the machine that made it. Only the id
|
|
71
|
+
* — a locally generated UUID — travels here; no developer identity does.
|
|
72
|
+
*
|
|
73
|
+
* Takes the token rather than the config it came from, like `tomlHeaders` does
|
|
74
|
+
* for Codex: a header builder that reads a config can be handed one with no
|
|
75
|
+
* token and quietly emit `Bearer ` rather than refusing to be called.
|
|
76
|
+
*
|
|
77
|
+
* @param token - The ingest token; the caller has already checked there is one.
|
|
78
|
+
* @param installationId - This installation's id, when one exists.
|
|
79
|
+
* @returns The header list for the exporter.
|
|
80
|
+
*/
|
|
81
|
+
function otlpHeaders(token, installationId) {
|
|
82
|
+
const pairs = [`Authorization=Bearer ${token}`];
|
|
83
|
+
if (installationId)
|
|
84
|
+
pairs.push(`${INSTALLATION_HEADER}=${installationId}`);
|
|
85
|
+
return pairs.join(',');
|
|
86
|
+
}
|
|
49
87
|
/** Configures Gemini CLI's own OTLP export. */
|
|
50
88
|
export class GeminiOtelConfigurator {
|
|
51
89
|
/**
|
|
@@ -64,7 +102,7 @@ export class GeminiOtelConfigurator {
|
|
|
64
102
|
* @returns The status, naming any foreign configuration in the way.
|
|
65
103
|
*/
|
|
66
104
|
async inspect(context) {
|
|
67
|
-
const disabled = !
|
|
105
|
+
const disabled = !anySignal(safeGeminiSignals(context.config));
|
|
68
106
|
const read = await readJsonFile(geminiSettingsPath(context.env));
|
|
69
107
|
const settings = read.state === 'ok' ? asRecord(read.value) : undefined;
|
|
70
108
|
if (!settings) {
|
|
@@ -130,20 +168,27 @@ export class GeminiOtelConfigurator {
|
|
|
130
168
|
// Gemini never read this; leaving it behind only confuses the next reader.
|
|
131
169
|
const nextSettings = hasOurLegacyHelper(withEnv) ? omitKeys(withEnv, new Set([LEGACY_HELPER_KEY])) : withEnv;
|
|
132
170
|
const changed = JSON.stringify(nextSettings) !== JSON.stringify(settings);
|
|
171
|
+
// Only when the block actually carries the bearer. This file is Gemini's,
|
|
172
|
+
// not ours, and `writeFileAtomic` preserves the target's mode by design —
|
|
173
|
+
// so tightening it unconditionally changed another tool's permissions on a
|
|
174
|
+
// shared workstation for no reason, and could never be undone.
|
|
175
|
+
const carriesCredential = desired[OTLP_HEADERS_KEY] !== undefined;
|
|
176
|
+
const priorMode = carriesCredential ? await currentMode(settingsPath) : undefined;
|
|
133
177
|
if (changed) {
|
|
134
178
|
await backupFile(settingsPath, context.paths.backupsDir, context.env.now());
|
|
135
|
-
await writeJsonValidated(settingsPath, nextSettings);
|
|
179
|
+
await writeJsonValidated(settingsPath, nextSettings, carriesCredential ? SECRET_FILE_MODE : undefined);
|
|
136
180
|
}
|
|
137
181
|
return {
|
|
138
182
|
ok: true,
|
|
139
183
|
changed,
|
|
140
184
|
messages: changed
|
|
141
|
-
? [`native OpenTelemetry configured (signals: ${enabledSignalNames(context.config
|
|
185
|
+
? [`native OpenTelemetry configured (signals: ${enabledSignalNames(safeGeminiSignals(context.config)).join(', ')})`, 'restart running Gemini CLI sessions to pick it up']
|
|
142
186
|
: ['native OpenTelemetry already up to date'],
|
|
143
187
|
installState: withOtelInstall(context.installState, GEMINI_PROVIDER_ID, {
|
|
144
188
|
configPath: settingsPath,
|
|
145
189
|
ownedKeys: Object.keys(desired),
|
|
146
|
-
configuredAt: context.env.now()
|
|
190
|
+
configuredAt: context.env.now(),
|
|
191
|
+
...(changed && priorMode !== undefined && priorMode !== SECRET_FILE_MODE ? { priorMode } : {})
|
|
147
192
|
})
|
|
148
193
|
};
|
|
149
194
|
}
|
|
@@ -171,7 +216,10 @@ export class GeminiOtelConfigurator {
|
|
|
171
216
|
const changed = JSON.stringify(nextSettings) !== JSON.stringify(settings);
|
|
172
217
|
if (changed) {
|
|
173
218
|
await backupFile(settingsPath, context.paths.backupsDir, context.env.now());
|
|
174
|
-
|
|
219
|
+
// The mode the file had before AgentWatch tightened it, when it was
|
|
220
|
+
// tightened. `writeJsonValidated` with no mode would otherwise keep our
|
|
221
|
+
// 0600 on a file that no longer holds a token.
|
|
222
|
+
await writeJsonValidated(settingsPath, nextSettings, context.installState.agents[GEMINI_PROVIDER_ID]?.otelPriorMode);
|
|
175
223
|
}
|
|
176
224
|
return {
|
|
177
225
|
ok: true,
|
|
@@ -180,6 +228,26 @@ export class GeminiOtelConfigurator {
|
|
|
180
228
|
installState: withoutOtelInstall(context.installState, GEMINI_PROVIDER_ID)
|
|
181
229
|
};
|
|
182
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Where the exporter keys `uninstall` would remove send.
|
|
233
|
+
*
|
|
234
|
+
* @param context - Environment and install state.
|
|
235
|
+
* @returns The owned endpoints.
|
|
236
|
+
*/
|
|
237
|
+
async exporterEndpoints(context) {
|
|
238
|
+
const read = await readJsonFile(geminiSettingsPath(context.env));
|
|
239
|
+
const envBlock = asRecord(read.state === 'ok' ? asRecord(read.value)?.[ENV_BLOCK_KEY] : undefined);
|
|
240
|
+
// No record owns nothing: unlike an explicit `uninstall`, the sweep runs
|
|
241
|
+
// unasked, and Gemini installed after setup holds only the developer's keys.
|
|
242
|
+
const owned = new Set(context.installState.agents[GEMINI_PROVIDER_ID]?.otelOwnedKeys ?? []);
|
|
243
|
+
const endpoints = [];
|
|
244
|
+
for (const key of GEMINI_ENDPOINT_KEYS) {
|
|
245
|
+
const value = envBlock?.[key];
|
|
246
|
+
if (owned.has(key) && typeof value === 'string')
|
|
247
|
+
endpoints.push(value);
|
|
248
|
+
}
|
|
249
|
+
return endpoints;
|
|
250
|
+
}
|
|
183
251
|
/**
|
|
184
252
|
* Handle `configure` when telemetry is off or unconfigurable.
|
|
185
253
|
*
|
|
@@ -187,7 +255,7 @@ export class GeminiOtelConfigurator {
|
|
|
187
255
|
* @returns The outcome.
|
|
188
256
|
*/
|
|
189
257
|
async configureDisabled(context) {
|
|
190
|
-
if (
|
|
258
|
+
if (anySignal(safeGeminiSignals(context.config)))
|
|
191
259
|
return { ok: false, changed: false, messages: ['no backend endpoint configured'] };
|
|
192
260
|
const removed = await this.uninstall(context);
|
|
193
261
|
if (!removed.ok)
|
|
@@ -197,12 +265,48 @@ export class GeminiOtelConfigurator {
|
|
|
197
265
|
changed: removed.changed,
|
|
198
266
|
messages: [
|
|
199
267
|
removed.changed
|
|
200
|
-
? 'native OpenTelemetry disabled
|
|
201
|
-
: 'native OpenTelemetry disabled
|
|
268
|
+
? 'native OpenTelemetry disabled by config or content consent; previous configuration removed'
|
|
269
|
+
: 'native OpenTelemetry disabled by config or content consent'
|
|
202
270
|
],
|
|
203
271
|
installState: removed.installState
|
|
204
272
|
};
|
|
205
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Signals Gemini was asked for but will not be given under current consent.
|
|
276
|
+
*
|
|
277
|
+
* Its usage logs always carry function arguments, and its detailed traces can
|
|
278
|
+
* carry prompts — so logs wait on tool-content consent and traces are never
|
|
279
|
+
* given, which is why the answer is per signal rather than all-or-nothing.
|
|
280
|
+
*
|
|
281
|
+
* @param config - Effective configuration.
|
|
282
|
+
* @returns The requested signals that are held back; empty when none are.
|
|
283
|
+
*/
|
|
284
|
+
withheldSignals(config) {
|
|
285
|
+
const safe = safeGeminiSignals(config);
|
|
286
|
+
return enabledSignalNames(config.otel).filter((name) => !safe[name]);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Gemini logs always carry function arguments, so they need tool-content
|
|
291
|
+
* consent. Detailed traces can carry prompts unbounded and unscrubbed, outside
|
|
292
|
+
* the summary's `promptText` path, so no configuration makes them safe.
|
|
293
|
+
* @param config - Global, consent-gated configuration.
|
|
294
|
+
* @returns The signals safe to materialize in Gemini settings.
|
|
295
|
+
*/
|
|
296
|
+
function safeGeminiSignals(config) {
|
|
297
|
+
return {
|
|
298
|
+
logs: config.otel.logs && toolContentConsented(config),
|
|
299
|
+
traces: false,
|
|
300
|
+
metrics: config.otel.metrics
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Whether Gemini has at least one safe signal to export.
|
|
305
|
+
* @param signals - Consent-filtered signal selection.
|
|
306
|
+
* @returns True when one signal remains.
|
|
307
|
+
*/
|
|
308
|
+
function anySignal(signals) {
|
|
309
|
+
return signals.logs || signals.traces || signals.metrics;
|
|
206
310
|
}
|
|
207
311
|
/**
|
|
208
312
|
* Settings keys a previous AgentWatch setup recorded as its own.
|
|
@@ -224,7 +328,7 @@ function ownedKeysOf(context) {
|
|
|
224
328
|
function inspectDisabled(settings, envBlock, ownedKeys) {
|
|
225
329
|
const leftover = ownedKeys.some((key) => (key === LEGACY_HELPER_KEY ? settings[key] !== undefined : envBlock[key] !== undefined)) || hasOurLegacyHelper(settings);
|
|
226
330
|
if (!leftover)
|
|
227
|
-
return { supported: true, configured: true, detail: 'disabled
|
|
331
|
+
return { supported: true, configured: true, detail: 'disabled by config or content consent' };
|
|
228
332
|
return {
|
|
229
333
|
supported: true,
|
|
230
334
|
configured: false,
|
|
@@ -240,7 +344,7 @@ function inspectDisabled(settings, envBlock, ownedKeys) {
|
|
|
240
344
|
* @returns The conflicting key names.
|
|
241
345
|
*/
|
|
242
346
|
function foreignKeys(envBlock, desired, ownedKeys) {
|
|
243
|
-
const owned = new Set(ownedKeys);
|
|
347
|
+
const owned = new Set([...ownedKeys, ...Object.keys(CONTENT_LOG_OFF)]);
|
|
244
348
|
return Object.keys(desired).filter((key) => envBlock[key] !== undefined && envBlock[key] !== desired[key] && !owned.has(key));
|
|
245
349
|
}
|
|
246
350
|
/**
|
|
@@ -2,7 +2,7 @@ import { hookRefusal } from '../shared/hook-refusal.js';
|
|
|
2
2
|
import { GEMINI_PROMPT_EVENTS } from './constants/gemini.constants.js';
|
|
3
3
|
import { detectGemini } from './gemini.detect.js';
|
|
4
4
|
import { installGeminiHooks, uninstallGeminiHooks } from './gemini.hooks.js';
|
|
5
|
-
import { parseGeminiHookEvent } from './gemini.adapter.js';
|
|
5
|
+
import { geminiShellCall, parseGeminiHookEvent } from './gemini.adapter.js';
|
|
6
6
|
import { GeminiOtelConfigurator } from './gemini.otel.js';
|
|
7
7
|
export const geminiProvider = {
|
|
8
8
|
id: 'gemini',
|
|
@@ -18,5 +18,6 @@ export const geminiProvider = {
|
|
|
18
18
|
* set across both namings — exactly the hooks a refusal may travel on.
|
|
19
19
|
*/
|
|
20
20
|
getBlockResponse: (payload, message) => hookRefusal(payload, GEMINI_PROMPT_EVENTS, { decision: 'deny', reason: message }),
|
|
21
|
+
shellCall: geminiShellCall,
|
|
21
22
|
nativeTelemetry: new GeminiOtelConfigurator()
|
|
22
23
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export type { AgentProvider, DetectionResult, HookContext, McpToolName, NativeTelemetryConfigurator, NativeTelemetryStatus, ProviderHookResponse, SetupContext, SetupOutcome, ToolKind, ToolStatus } from './types/provider.types.js';
|
|
7
7
|
export { HOOK_COMMAND_MARKER, KNOWN_AGENT_IDS } from './constants/provider.constants.js';
|
|
8
8
|
export { isAgentWatchHookCommand } from './provider.js';
|
|
9
|
-
export {
|
|
9
|
+
export { loadProvider, providerIds, providers } from './registry.js';
|
|
10
10
|
export { classifyTool, contentEvidence, extractCommand, extractFilePath, parseMcpToolName, toolCompleteType, toolStartType } from './shared/tooling.js';
|
|
11
11
|
export { baseEvent, filePathPatch, promptPatch, providerPatch, responsePatch, toolPatch, withPatch } from './shared/event-builder.js';
|
|
12
12
|
export { registerOurHandlers, stripOurHandlers, sweepUnregisteredEvents, withHooksBlock, writeJsonValidated } from './shared/hook-config.js';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { HOOK_COMMAND_MARKER, KNOWN_AGENT_IDS } from './constants/provider.constants.js';
|
|
2
2
|
export { isAgentWatchHookCommand } from './provider.js';
|
|
3
|
-
export {
|
|
3
|
+
export { loadProvider, providerIds, providers } from './registry.js';
|
|
4
4
|
export { classifyTool, contentEvidence, extractCommand, extractFilePath, parseMcpToolName, toolCompleteType, toolStartType } from './shared/tooling.js';
|
|
5
5
|
export { baseEvent, filePathPatch, promptPatch, providerPatch, responsePatch, toolPatch, withPatch } from './shared/event-builder.js';
|
|
6
6
|
export { registerOurHandlers, stripOurHandlers, sweepUnregisteredEvents, withHooksBlock, writeJsonValidated } from './shared/hook-config.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AgentProvider } from './types/provider.types.js';
|
|
2
|
+
/** Every agent id the CLI accepts, for help and error messages. */
|
|
3
|
+
export declare const providerIds: readonly string[];
|
|
4
|
+
/**
|
|
5
|
+
* The provider for an agent id, loading only that agent's code.
|
|
6
|
+
*
|
|
7
|
+
* @param id - Agent id as passed to `agentwatch hook --agent <id>`.
|
|
8
|
+
* @returns The provider, or undefined for an unknown agent.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadProvider(id: string): Promise<AgentProvider | undefined>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One dynamic import per agent, so a hook loads the agent it was invoked for
|
|
3
|
+
* and no other.
|
|
4
|
+
*
|
|
5
|
+
* The hook path resolves exactly one provider per invocation, and importing the
|
|
6
|
+
* eager registry pulled in all five with their adapters, schemas and constants
|
|
7
|
+
* — measurably the largest single cost in the hook's own import graph, paid ten
|
|
8
|
+
* to fifteen times per turn on every developer's machine. `cli.ts` already goes
|
|
9
|
+
* to trouble to lazy-import command modules "so the hook path does not pay
|
|
10
|
+
* their startup"; this is the same argument applied to the agents.
|
|
11
|
+
*
|
|
12
|
+
* This literal and `registry.providers` are two hand-maintained lists of the
|
|
13
|
+
* same five agents, and they cannot be derived from one another: the eager list
|
|
14
|
+
* holds the provider objects, and having these loaders produce it would import
|
|
15
|
+
* every agent, which is the cost this file exists to avoid. `tests/providers.test.ts`
|
|
16
|
+
* asserts the two agree, so a sixth agent registered in only one of them fails
|
|
17
|
+
* the suite rather than installing hooks whose every invocation resolves no
|
|
18
|
+
* provider and drops the agent's telemetry in silence.
|
|
19
|
+
*/
|
|
20
|
+
const PROVIDER_LOADERS = {
|
|
21
|
+
claude: async () => (await import('./claude/claude.provider.js')).claudeProvider,
|
|
22
|
+
codex: async () => (await import('./codex/codex.provider.js')).codexProvider,
|
|
23
|
+
cursor: async () => (await import('./cursor/cursor.provider.js')).cursorProvider,
|
|
24
|
+
gemini: async () => (await import('./gemini/gemini.provider.js')).geminiProvider,
|
|
25
|
+
antigravity: async () => (await import('./antigravity/antigravity.provider.js')).antigravityProvider
|
|
26
|
+
};
|
|
27
|
+
/** Every agent id the CLI accepts, for help and error messages. */
|
|
28
|
+
export const providerIds = Object.keys(PROVIDER_LOADERS);
|
|
29
|
+
/**
|
|
30
|
+
* The provider for an agent id, loading only that agent's code.
|
|
31
|
+
*
|
|
32
|
+
* @param id - Agent id as passed to `agentwatch hook --agent <id>`.
|
|
33
|
+
* @returns The provider, or undefined for an unknown agent.
|
|
34
|
+
*/
|
|
35
|
+
export async function loadProvider(id) {
|
|
36
|
+
const load = PROVIDER_LOADERS[id];
|
|
37
|
+
if (!load)
|
|
38
|
+
return undefined;
|
|
39
|
+
return load();
|
|
40
|
+
}
|
|
@@ -14,3 +14,14 @@ export type { AgentProvider, DetectionResult, HookContext, McpToolName, NativeTe
|
|
|
14
14
|
* @returns True only when AgentWatch wrote it.
|
|
15
15
|
*/
|
|
16
16
|
export declare function isAgentWatchHookCommand(command: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Minimal tokenizer for the exact commands buildHookCommand emits.
|
|
19
|
+
*
|
|
20
|
+
* Supports quoted paths and their escaped quote/backslash forms, and rejects
|
|
21
|
+
* any command containing a shell control operator — a command we cannot fully
|
|
22
|
+
* understand is one we must not claim ownership of.
|
|
23
|
+
*
|
|
24
|
+
* @param command - The command line.
|
|
25
|
+
* @returns Its tokens, or undefined when the command is not one we emit.
|
|
26
|
+
*/
|
|
27
|
+
export declare function tokenizeHookCommand(command: string): string[] | undefined;
|
|
@@ -99,7 +99,7 @@ function pathBase(value) {
|
|
|
99
99
|
* @param command - The command line.
|
|
100
100
|
* @returns Its tokens, or undefined when the command is not one we emit.
|
|
101
101
|
*/
|
|
102
|
-
function tokenizeHookCommand(command) {
|
|
102
|
+
export function tokenizeHookCommand(command) {
|
|
103
103
|
const tokens = [];
|
|
104
104
|
let token = '';
|
|
105
105
|
let started = false;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { AgentProvider } from './types/provider.types.js';
|
|
2
|
-
|
|
3
|
-
export declare const providers: readonly AgentProvider[];
|
|
2
|
+
export { loadProvider, providerIds } from './loaders.js';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Every provider, eagerly.
|
|
5
|
+
*
|
|
6
|
+
* For the commands that genuinely need all five — `setup`, `status`, `doctor`,
|
|
7
|
+
* `uninstall`, `toggle` — each of which asks every agent about itself. The hook
|
|
8
|
+
* path must not import this module: it needs one agent, and `loadProvider` in
|
|
9
|
+
* `loaders.js` is how it gets exactly that one.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
11
|
+
* Adding an agent = implementing AgentProvider, registering it here, and adding
|
|
12
|
+
* its loader in `loaders.js`. Both, or `tests/providers.test.ts` fails: an agent
|
|
13
|
+
* present here and missing there installs hooks that resolve no provider.
|
|
9
14
|
*/
|
|
10
|
-
export declare
|
|
11
|
-
/** Every agent id the CLI accepts, for help and error messages. */
|
|
12
|
-
export declare const providerIds: readonly string[];
|
|
15
|
+
export declare const providers: readonly AgentProvider[];
|
|
@@ -3,21 +3,17 @@ import { claudeProvider } from './claude/claude.provider.js';
|
|
|
3
3
|
import { codexProvider } from './codex/codex.provider.js';
|
|
4
4
|
import { cursorProvider } from './cursor/cursor.provider.js';
|
|
5
5
|
import { geminiProvider } from './gemini/gemini.provider.js';
|
|
6
|
-
|
|
7
|
-
export const providers = [claudeProvider, codexProvider, cursorProvider, geminiProvider, antigravityProvider];
|
|
8
|
-
/**
|
|
9
|
-
* Index built once at module load: the hook path resolves a provider on every
|
|
10
|
-
* single invocation, and a linear scan there is pure waste (STYLEGUIDE 3.2).
|
|
11
|
-
*/
|
|
12
|
-
const byId = new Map(providers.map((provider) => [provider.id, provider]));
|
|
6
|
+
export { loadProvider, providerIds } from './loaders.js';
|
|
13
7
|
/**
|
|
14
|
-
*
|
|
8
|
+
* Every provider, eagerly.
|
|
15
9
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* For the commands that genuinely need all five — `setup`, `status`, `doctor`,
|
|
11
|
+
* `uninstall`, `toggle` — each of which asks every agent about itself. The hook
|
|
12
|
+
* path must not import this module: it needs one agent, and `loadProvider` in
|
|
13
|
+
* `loaders.js` is how it gets exactly that one.
|
|
14
|
+
*
|
|
15
|
+
* Adding an agent = implementing AgentProvider, registering it here, and adding
|
|
16
|
+
* its loader in `loaders.js`. Both, or `tests/providers.test.ts` fails: an agent
|
|
17
|
+
* present here and missing there installs hooks that resolve no provider.
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
20
|
-
return byId.get(id);
|
|
21
|
-
}
|
|
22
|
-
/** Every agent id the CLI accepts, for help and error messages. */
|
|
23
|
-
export const providerIds = providers.map((provider) => provider.id);
|
|
19
|
+
export const providers = [claudeProvider, codexProvider, cursorProvider, geminiProvider, antigravityProvider];
|
|
@@ -4,3 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Every JSON hook protocol AgentWatch registers names its event under this key. */
|
|
6
6
|
export declare const PAYLOAD_HOOK_EVENT_KEY = "hook_event_name";
|
|
7
|
+
/**
|
|
8
|
+
* The hooks a notice travels on, in both Claude Code and Codex: the untraced
|
|
9
|
+
* notice after a run, the update notice as a session starts. Both protocols
|
|
10
|
+
* take `systemMessage` on each (Codex: `SessionStartCommandOutputWire` flattens
|
|
11
|
+
* `HookUniversalOutputWire`, checked 2026-10-13).
|
|
12
|
+
*/
|
|
13
|
+
export declare const NOTICE_EVENTS: ReadonlySet<string>;
|
|
@@ -4,3 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/** Every JSON hook protocol AgentWatch registers names its event under this key. */
|
|
6
6
|
export const PAYLOAD_HOOK_EVENT_KEY = 'hook_event_name';
|
|
7
|
+
/**
|
|
8
|
+
* The hooks a notice travels on, in both Claude Code and Codex: the untraced
|
|
9
|
+
* notice after a run, the update notice as a session starts. Both protocols
|
|
10
|
+
* take `systemMessage` on each (Codex: `SessionStartCommandOutputWire` flattens
|
|
11
|
+
* `HookUniversalOutputWire`, checked 2026-10-13).
|
|
12
|
+
*/
|
|
13
|
+
export const NOTICE_EVENTS = new Set(['PostToolUse', 'SessionStart']);
|