@agent-watch-ai/edge 0.2.5 → 0.4.0
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 +558 -0
- package/README.md +222 -97
- package/SECURITY.md +72 -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 +52 -4
- package/dist/cli/constants/cli.constants.js +56 -5
- package/dist/cli/context.d.ts +33 -2
- package/dist/cli/context.js +84 -14
- package/dist/cli/doctor.js +321 -33
- 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 +553 -103
- package/dist/cli/status.js +82 -13
- package/dist/cli/toggle.d.ts +9 -0
- package/dist/cli/toggle.js +117 -0
- package/dist/cli/types/cli.types.d.ts +43 -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 +110 -12
- 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 +116 -6
- package/dist/config/constants/config.constants.js +131 -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 +831 -84
- package/dist/config/schemas/config.schema.js +398 -16
- 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 +119 -0
- package/dist/credentials/constants/credentials.constants.js +120 -0
- package/dist/credentials/credential-status.d.ts +14 -0
- package/dist/credentials/credential-status.js +38 -0
- package/dist/credentials/credentials.d.ts +86 -0
- package/dist/credentials/credentials.js +278 -0
- package/dist/credentials/device-api.d.ts +73 -0
- package/dist/credentials/device-api.js +161 -0
- package/dist/credentials/device-state.d.ts +31 -0
- package/dist/credentials/device-state.js +51 -0
- package/dist/credentials/identity.d.ts +73 -0
- package/dist/credentials/identity.js +101 -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 +31 -0
- package/dist/credentials/sign-in.js +105 -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 +206 -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 +64 -17
- package/dist/enforcement/enforcement.d.ts +23 -2
- package/dist/enforcement/enforcement.js +107 -17
- package/dist/enforcement/index.d.ts +4 -3
- package/dist/enforcement/index.js +3 -2
- package/dist/enforcement/types/enforcement.types.d.ts +66 -2
- 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 +10 -0
- package/dist/pipeline/constants/pipeline.constants.js +10 -0
- package/dist/pipeline/hook-pipeline.js +410 -33
- 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 +75 -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 +36 -3
- package/dist/providers/codex/codex.otel.js +199 -32
- 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 +10 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +10 -0
- package/dist/providers/constants/provider.constants.d.ts +8 -3
- package/dist/providers/constants/provider.constants.js +8 -3
- package/dist/providers/cursor/constants/cursor.constants.d.ts +9 -0
- package/dist/providers/cursor/constants/cursor.constants.js +9 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
- package/dist/providers/cursor/cursor.adapter.js +129 -4
- 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 +9 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +9 -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 +30 -21
- package/dist/providers/gemini/gemini.otel.js +166 -22
- 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/bearer-rewrite.d.ts +19 -0
- package/dist/providers/shared/bearer-rewrite.js +46 -0
- 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 +24 -2
- package/dist/providers/shared/constants/tooling.constants.js +25 -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 +40 -1
- package/dist/providers/shared/tooling.js +70 -1
- package/dist/providers/shared/types/adapter.types.d.ts +1 -2
- package/dist/providers/types/provider.types.d.ts +81 -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 +21 -0
- package/dist/storage/atomic-file.js +20 -1
- package/dist/storage/constants/storage.constants.d.ts +19 -0
- package/dist/storage/constants/storage.constants.js +19 -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 +67 -0
- package/dist/turns/work-checkout.js +700 -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 +655 -0
- package/docs/ENTERPRISE_DEPLOYMENT.md +194 -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
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
1
3
|
import { asRecord, compact } from '../../core/object.js';
|
|
2
4
|
import { sha256Hex } from '../../events/event-id.js';
|
|
5
|
+
import { resolvePaths } from '../../storage/paths.js';
|
|
3
6
|
import { baseEvent, filePathPatch, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
|
|
4
|
-
import { classifyTool, contentEvidence, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
5
|
-
import { ATTACHMENT_FILE_PATH_KEY, CURSOR_DEDICATED_COMPLETION_KINDS, CURSOR_DISPLAY_NAME, CURSOR_EDIT_TOOL_NAME, CURSOR_EVENT_TYPE_MAP, CURSOR_PROVIDER_ID, CURSOR_READ_TOOL_NAME, CURSOR_SHELL_TOOL_NAME, CURSOR_TOOL_KINDS, CURSOR_UNKNOWN_EVENT } from './constants/cursor.constants.js';
|
|
7
|
+
import { classifyTool, contentEvidence, mcpServerFromEndpoint, mcpToolKey, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
8
|
+
import { ATTACHMENT_FILE_PATH_KEY, CURSOR_DEDICATED_COMPLETION_KINDS, CURSOR_DISPLAY_NAME, CURSOR_EDIT_TOOL_NAME, CURSOR_EVENT_TYPE_MAP, CURSOR_PROVIDER_ID, CURSOR_READ_TOOL_NAME, CURSOR_GENERIC_TOOL_START_EVENT, CURSOR_SHELL_COMMAND_KEY, CURSOR_SHELL_EVENTS, CURSOR_SHELL_WORKDIR_KEY, CURSOR_SHELL_TOOL_NAME, CURSOR_TOOL_KINDS, CURSOR_UNKNOWN_EVENT, CURSOR_UNKNOWN_MCP_SERVER } from './constants/cursor.constants.js';
|
|
6
9
|
import { cursorPayloadSchema } from './schemas/cursor.schema.js';
|
|
7
10
|
/**
|
|
8
11
|
* Translate one Cursor hook payload into canonical events.
|
|
@@ -19,6 +22,54 @@ export function parseCursorHookEvent(rawPayload, context) {
|
|
|
19
22
|
const providerEventType = payload.hook_event_name ?? CURSOR_UNKNOWN_EVENT;
|
|
20
23
|
return [withPatch(cursorBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
|
|
21
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The command a shell call is about to run, and the directory it runs in.
|
|
27
|
+
*
|
|
28
|
+
* Cursor announces one call twice (cursor.com/docs/hooks): `beforeShellExecution`
|
|
29
|
+
* with `command` and `cwd` at the top level, and the generic `preToolUse` for
|
|
30
|
+
* `Shell` with `tool_input.command` and `tool_input.working_directory`. Both are
|
|
31
|
+
* read, so both name the same checkout; a hook left unread would instead vote
|
|
32
|
+
* for the cwd it sits in. `afterShellExecution` is read too: a command can
|
|
33
|
+
* create the worktree it works in.
|
|
34
|
+
*
|
|
35
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
36
|
+
* @returns The call, or undefined for any other payload.
|
|
37
|
+
*/
|
|
38
|
+
export function cursorShellCall(rawPayload) {
|
|
39
|
+
const parsed = cursorPayloadSchema.safeParse(rawPayload);
|
|
40
|
+
if (!parsed.success)
|
|
41
|
+
return undefined;
|
|
42
|
+
const payload = parsed.data;
|
|
43
|
+
if (CURSOR_SHELL_EVENTS.has(payload.hook_event_name ?? ''))
|
|
44
|
+
return shellCallOf(payload.command, payload.cwd);
|
|
45
|
+
if (payload.hook_event_name !== CURSOR_GENERIC_TOOL_START_EVENT || cursorToolKind(payload.tool_name) !== 'shell')
|
|
46
|
+
return undefined;
|
|
47
|
+
const input = asRecord(payload.tool_input);
|
|
48
|
+
return shellCallOf(input?.[CURSOR_SHELL_COMMAND_KEY], input?.[CURSOR_SHELL_WORKDIR_KEY]);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The folders the Cursor window has open, absolute paths only.
|
|
52
|
+
*
|
|
53
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
54
|
+
* @returns The roots; empty when the payload names none.
|
|
55
|
+
*/
|
|
56
|
+
export function cursorWorkspaceRoots(rawPayload) {
|
|
57
|
+
const parsed = cursorPayloadSchema.safeParse(rawPayload);
|
|
58
|
+
return parsed.success ? (parsed.data.workspace_roots ?? []).filter((root) => path.isAbsolute(root)) : [];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Where a payload that reports no `cwd` happened: the first workspace root.
|
|
62
|
+
*
|
|
63
|
+
* Cursor puts `cwd` on its shell and tool hooks only; the prompt, file-edit and
|
|
64
|
+
* stop hooks would otherwise resolve against the directory the hook process
|
|
65
|
+
* started in, which Cursor does not promise is the workspace.
|
|
66
|
+
*
|
|
67
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
68
|
+
* @returns The first workspace root, or undefined.
|
|
69
|
+
*/
|
|
70
|
+
export function cursorCwd(rawPayload) {
|
|
71
|
+
return cursorWorkspaceRoots(rawPayload)[0];
|
|
72
|
+
}
|
|
22
73
|
/**
|
|
23
74
|
* The provider-independent part of the event.
|
|
24
75
|
*
|
|
@@ -96,7 +147,7 @@ function hookPatch(payload, providerEventType, context) {
|
|
|
96
147
|
return { metadata: { compactionTrigger: payload.trigger, contextUsagePercent: payload.context_usage_percent } };
|
|
97
148
|
}
|
|
98
149
|
if (providerEventType === 'afterAgentResponse')
|
|
99
|
-
return responsePatch(payload.text ?? ''
|
|
150
|
+
return responsePatch(payload.text ?? '');
|
|
100
151
|
if (providerEventType === 'stop')
|
|
101
152
|
return { metadata: { stopStatus: payload.status } };
|
|
102
153
|
return {};
|
|
@@ -184,9 +235,15 @@ function shellPatch(payload, providerEventType, context) {
|
|
|
184
235
|
function mcpPatch(payload, providerEventType, context) {
|
|
185
236
|
const capture = context.config.capture;
|
|
186
237
|
const parsed = payload.tool_name ? parseMcpToolName(payload.tool_name) : {};
|
|
238
|
+
// An endpoint that names no server still gets a parseable key, so mcpNames:false folds it.
|
|
239
|
+
const toolName = parsed.tool ?? payload.tool_name;
|
|
240
|
+
const endpoint = parsed.server ?? mcpServerFromEndpoint(payload.url, payload.command);
|
|
241
|
+
const server = endpoint ?? rememberedMcpServer(payload, toolName, context) ?? CURSOR_UNKNOWN_MCP_SERVER;
|
|
242
|
+
if (endpoint && toolName)
|
|
243
|
+
rememberMcpServer(payload, toolName, endpoint, context);
|
|
187
244
|
return {
|
|
188
245
|
tool: {
|
|
189
|
-
name: payload.tool_name,
|
|
246
|
+
name: toolName ? mcpToolKey(server, toolName) : payload.tool_name,
|
|
190
247
|
status: providerEventType === 'beforeMCPExecution' ? 'started' : 'completed',
|
|
191
248
|
durationMs: payload.duration
|
|
192
249
|
},
|
|
@@ -200,6 +257,74 @@ function mcpPatch(payload, providerEventType, context) {
|
|
|
200
257
|
})
|
|
201
258
|
};
|
|
202
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Where a conversation's MCP servers are remembered between its hooks.
|
|
262
|
+
*
|
|
263
|
+
* `afterMCPExecution` carries neither url nor command, and only completions
|
|
264
|
+
* become turn records, so the server the before-hook saw has to outlive it.
|
|
265
|
+
*
|
|
266
|
+
* @param payload - Parsed hook payload.
|
|
267
|
+
* @param context - Environment.
|
|
268
|
+
* @returns The state file, or undefined without a conversation id.
|
|
269
|
+
*/
|
|
270
|
+
function mcpMemoFile(payload, context) {
|
|
271
|
+
if (!payload.conversation_id)
|
|
272
|
+
return undefined;
|
|
273
|
+
return path.join(resolvePaths(context.env).dataDir, 'cursor-mcp', `${sha256Hex(payload.conversation_id).slice(0, 32)}.json`);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Remembers which server a tool resolved to, for the completion hook.
|
|
277
|
+
*
|
|
278
|
+
* ponytail: one tiny file per conversation, last write wins per tool name, never
|
|
279
|
+
* pruned (the data dir is disposable); two servers exposing the same tool name
|
|
280
|
+
* in one conversation share an entry. Upgrade: key by tool_use_id if Cursor sends it.
|
|
281
|
+
*
|
|
282
|
+
* @param payload - Parsed hook payload.
|
|
283
|
+
* @param tool - Tool name.
|
|
284
|
+
* @param server - Resolved server.
|
|
285
|
+
* @param context - Environment.
|
|
286
|
+
*/
|
|
287
|
+
function rememberMcpServer(payload, tool, server, context) {
|
|
288
|
+
const file = mcpMemoFile(payload, context);
|
|
289
|
+
if (!file)
|
|
290
|
+
return;
|
|
291
|
+
try {
|
|
292
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
293
|
+
fs.writeFileSync(file, JSON.stringify({ ...readMcpMemo(file), [tool]: server }), { mode: 0o600 });
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
// Hooks never fail the agent; the completion just keys as unknown.
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* The server a tool resolved to in this conversation's before-hook.
|
|
301
|
+
*
|
|
302
|
+
* @param payload - Parsed hook payload.
|
|
303
|
+
* @param tool - Tool name.
|
|
304
|
+
* @param context - Environment.
|
|
305
|
+
* @returns The server, or undefined when none was remembered.
|
|
306
|
+
*/
|
|
307
|
+
function rememberedMcpServer(payload, tool, context) {
|
|
308
|
+
const file = mcpMemoFile(payload, context);
|
|
309
|
+
if (!file || !tool)
|
|
310
|
+
return undefined;
|
|
311
|
+
const server = readMcpMemo(file)[tool];
|
|
312
|
+
return typeof server === 'string' ? server : undefined;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Reads a conversation's MCP memo.
|
|
316
|
+
*
|
|
317
|
+
* @param file - Memo file.
|
|
318
|
+
* @returns Its contents, empty when missing or unreadable.
|
|
319
|
+
*/
|
|
320
|
+
function readMcpMemo(file) {
|
|
321
|
+
try {
|
|
322
|
+
return asRecord(JSON.parse(fs.readFileSync(file, 'utf8'))) ?? {};
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
return {};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
203
328
|
/**
|
|
204
329
|
* File-edit fields for Cursor's dedicated edit hooks.
|
|
205
330
|
*
|
|
@@ -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
|
-
* Cursor's configuration root.
|
|
5
|
-
*
|
|
6
|
-
* @param env - Environment supplying HOME.
|
|
7
|
-
* @returns Absolute path of `~/.cursor`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function cursorHome(env: Env): string;
|
|
10
3
|
/**
|
|
11
4
|
* Where Cursor reads user-level hook registrations from.
|
|
12
5
|
*
|
|
@@ -10,7 +10,7 @@ import { CURSOR_EXECUTABLES, CURSOR_HOME_DIR, CURSOR_HOOKS_FILE } from './consta
|
|
|
10
10
|
* @param env - Environment supplying HOME.
|
|
11
11
|
* @returns Absolute path of `~/.cursor`.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
function cursorHome(env) {
|
|
14
14
|
return path.join(env.home, CURSOR_HOME_DIR);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -2,7 +2,7 @@ import { hookRefusal } from '../shared/hook-refusal.js';
|
|
|
2
2
|
import { CURSOR_PROMPT_SUBMIT_EVENTS } from './constants/cursor.constants.js';
|
|
3
3
|
import { detectCursor } from './cursor.detect.js';
|
|
4
4
|
import { installCursorHooks, uninstallCursorHooks } from './cursor.hooks.js';
|
|
5
|
-
import { parseCursorHookEvent } from './cursor.adapter.js';
|
|
5
|
+
import { cursorCwd, cursorShellCall, cursorWorkspaceRoots, parseCursorHookEvent } from './cursor.adapter.js';
|
|
6
6
|
export const cursorProvider = {
|
|
7
7
|
id: 'cursor',
|
|
8
8
|
displayName: 'Cursor',
|
|
@@ -20,7 +20,10 @@ export const cursorProvider = {
|
|
|
20
20
|
* A budget refusal on `beforeSubmitPrompt`: the prompt is not submitted and
|
|
21
21
|
* `user_message` explains why.
|
|
22
22
|
*/
|
|
23
|
-
getBlockResponse: (payload, message) => hookRefusal(payload, CURSOR_PROMPT_SUBMIT_EVENTS, { continue: false, user_message: message })
|
|
23
|
+
getBlockResponse: (payload, message) => hookRefusal(payload, CURSOR_PROMPT_SUBMIT_EVENTS, { continue: false, user_message: message }),
|
|
24
|
+
resolveCwd: cursorCwd,
|
|
25
|
+
shellCall: cursorShellCall,
|
|
26
|
+
workspaceRoots: cursorWorkspaceRoots
|
|
24
27
|
// No nativeTelemetry: Cursor has no OTel export, so there is no llm.call
|
|
25
28
|
// ledger source. Turn summaries stay usage_status=pending until Cursor
|
|
26
29
|
// enriches its transcripts with usage (see cursor-transcript.ts).
|
|
@@ -33,4 +33,13 @@ export declare const GEMINI_TOOL_EVENTS: ReadonlySet<string>;
|
|
|
33
33
|
export declare const GEMINI_TOOL_START_EVENTS: ReadonlySet<string>;
|
|
34
34
|
/** Tool hooks that report a completion. */
|
|
35
35
|
export declare const GEMINI_TOOL_COMPLETE_EVENTS: ReadonlySet<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Tool hooks a shell call is read on: the ones that fire once before it runs,
|
|
38
|
+
* and once after it ran (a command can create the worktree it works in), across
|
|
39
|
+
* both namings. `PermissionRequest` also counts as a start, but only for calls
|
|
40
|
+
* that ask, and reading it too would count those calls twice.
|
|
41
|
+
*/
|
|
42
|
+
export declare const GEMINI_SHELL_CALL_EVENTS: ReadonlySet<string>;
|
|
43
|
+
/** `run_shell_command`'s working-directory argument. */
|
|
44
|
+
export declare const GEMINI_SHELL_DIR_KEY = "dir_path";
|
|
36
45
|
export declare const GEMINI_UNKNOWN_EVENT = "unknown";
|
|
@@ -55,4 +55,13 @@ export const GEMINI_TOOL_EVENTS = new Set([
|
|
|
55
55
|
export const GEMINI_TOOL_START_EVENTS = new Set(['BeforeTool', 'PreToolUse', 'PermissionRequest']);
|
|
56
56
|
/** Tool hooks that report a completion. */
|
|
57
57
|
export const GEMINI_TOOL_COMPLETE_EVENTS = new Set(['AfterTool', 'PostToolUse', 'PostToolUseFailure']);
|
|
58
|
+
/**
|
|
59
|
+
* Tool hooks a shell call is read on: the ones that fire once before it runs,
|
|
60
|
+
* and once after it ran (a command can create the worktree it works in), across
|
|
61
|
+
* both namings. `PermissionRequest` also counts as a start, but only for calls
|
|
62
|
+
* that ask, and reading it too would count those calls twice.
|
|
63
|
+
*/
|
|
64
|
+
export const GEMINI_SHELL_CALL_EVENTS = new Set(['BeforeTool', 'PreToolUse', 'AfterTool', 'PostToolUse']);
|
|
65
|
+
/** `run_shell_command`'s working-directory argument. */
|
|
66
|
+
export const GEMINI_SHELL_DIR_KEY = 'dir_path';
|
|
58
67
|
export const GEMINI_UNKNOWN_EVENT = 'unknown';
|
|
@@ -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
|
/**
|
|
@@ -32,3 +34,9 @@ export declare const STANDARD_OTLP_PROTOCOL = "http/json";
|
|
|
32
34
|
* that is not a default worth inheriting.
|
|
33
35
|
*/
|
|
34
36
|
export declare const GEMINI_TELEMETRY_TARGET_LOCAL = "local";
|
|
37
|
+
/**
|
|
38
|
+
* The bearer inside the `OTEL_EXPORTER_OTLP_HEADERS` list, value captured. A
|
|
39
|
+
* token rotation changes only this, so drift checks ignore it and the hook
|
|
40
|
+
* rewrites it alone.
|
|
41
|
+
*/
|
|
42
|
+
export declare const RE_BEARER_PAIR: RegExp;
|
|
@@ -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
|
/**
|
|
@@ -46,3 +49,9 @@ export const STANDARD_OTLP_PROTOCOL = 'http/json';
|
|
|
46
49
|
* that is not a default worth inheriting.
|
|
47
50
|
*/
|
|
48
51
|
export const GEMINI_TELEMETRY_TARGET_LOCAL = 'local';
|
|
52
|
+
/**
|
|
53
|
+
* The bearer inside the `OTEL_EXPORTER_OTLP_HEADERS` list, value captured. A
|
|
54
|
+
* token rotation changes only this, so drift checks ignore it and the hook
|
|
55
|
+
* rewrites it alone.
|
|
56
|
+
*/
|
|
57
|
+
export const RE_BEARER_PAIR = /(Authorization=Bearer )([^,]*)/g;
|
|
@@ -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 {
|
|
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;
|
|
2
|
+
import type { AgentWatchConfig, OtelSignalName } from '../../config/types/config.types.js';
|
|
3
|
+
import type { BearerRewriteContext, NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
|
|
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,25 @@ export declare class GeminiOtelConfigurator implements NativeTelemetryConfigurat
|
|
|
59
47
|
* @returns The outcome.
|
|
60
48
|
*/
|
|
61
49
|
private configureDisabled;
|
|
50
|
+
/**
|
|
51
|
+
* Swap the bearer in our `OTEL_EXPORTER_OTLP_HEADERS` for the current one.
|
|
52
|
+
*
|
|
53
|
+
* Only when a setup recorded the key as ours, and only the bearer in it
|
|
54
|
+
* changes. No backup: one per rotation would collect copies of every token.
|
|
55
|
+
*
|
|
56
|
+
* @param context - The recorded file, its contents as read, install state and the current bearer.
|
|
57
|
+
* @returns True when the file was rewritten.
|
|
58
|
+
*/
|
|
59
|
+
rewriteBearer(context: BearerRewriteContext): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Signals Gemini was asked for but will not be given under current consent.
|
|
62
|
+
*
|
|
63
|
+
* Its usage logs always carry function arguments, and its detailed traces can
|
|
64
|
+
* carry prompts — so logs wait on tool-content consent and traces are never
|
|
65
|
+
* given, which is why the answer is per signal rather than all-or-nothing.
|
|
66
|
+
*
|
|
67
|
+
* @param config - Effective configuration.
|
|
68
|
+
* @returns The requested signals that are held back; empty when none are.
|
|
69
|
+
*/
|
|
70
|
+
withheldSignals(config: AgentWatchConfig): readonly OtelSignalName[];
|
|
62
71
|
}
|