@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,7 +1,8 @@
|
|
|
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 { classifyTool, extractCommand, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
5
|
+
import { ANTIGRAVITY_CWD_KEY, ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_HOOK_EVENT_BY_ARGS, ANTIGRAVITY_PROVIDER_ID, DOTLESS_MODEL_FAMILY, RE_MODEL_QUALIFIER, RE_MODEL_VERSION_DOT, RE_MODEL_WHITESPACE } from './constants/antigravity.constants.js';
|
|
5
6
|
import { antigravityPayloadSchema } from './schemas/antigravity.schema.js';
|
|
6
7
|
const ARGS_KEYS = Object.keys(ANTIGRAVITY_HOOK_EVENT_BY_ARGS);
|
|
7
8
|
/**
|
|
@@ -37,6 +38,23 @@ export function antigravityCwd(rawPayload) {
|
|
|
37
38
|
return undefined;
|
|
38
39
|
return parsed.data.common?.workspacePaths?.[0];
|
|
39
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* The command a `run_command` tool call runs, and its `Cwd`, before and after it
|
|
43
|
+
* ran (a command can create the worktree it works in).
|
|
44
|
+
*
|
|
45
|
+
* Arguments as the fixtures record them, read off the tool schema in the `agy`
|
|
46
|
+
* binary: `CommandLine` and `Cwd`, PascalCase.
|
|
47
|
+
*
|
|
48
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
49
|
+
* @returns The call, or undefined for any other payload.
|
|
50
|
+
*/
|
|
51
|
+
export function antigravityShellCall(rawPayload) {
|
|
52
|
+
const parsed = antigravityPayloadSchema.safeParse(rawPayload);
|
|
53
|
+
const toolCall = parsed.success ? (parsed.data.preToolHookArgs ?? parsed.data.postToolHookArgs)?.toolCall : undefined;
|
|
54
|
+
if (classifyTool(toolCall?.name) !== 'shell')
|
|
55
|
+
return undefined;
|
|
56
|
+
return shellCallOf(extractCommand(toolCall?.args), asRecord(toolCall?.args)?.[ANTIGRAVITY_CWD_KEY]);
|
|
57
|
+
}
|
|
40
58
|
/**
|
|
41
59
|
* Translate one Antigravity hook payload into canonical events.
|
|
42
60
|
*
|
|
@@ -148,7 +166,7 @@ function hookPatch(payload, hook, context) {
|
|
|
148
166
|
if (hook === 'PreToolUse' || hook === 'PostToolUse')
|
|
149
167
|
return antigravityToolPatch(payload, hook, context);
|
|
150
168
|
if (hook === 'Stop')
|
|
151
|
-
return responsePatch(payload.stopHookArgs?.finalModelOutput ?? ''
|
|
169
|
+
return responsePatch(payload.stopHookArgs?.finalModelOutput ?? '');
|
|
152
170
|
return {};
|
|
153
171
|
}
|
|
154
172
|
/**
|
|
@@ -1,14 +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
|
-
* Antigravity's configuration root.
|
|
5
|
-
*
|
|
6
|
-
* It shares Gemini's home directory: `~/.gemini/config`.
|
|
7
|
-
*
|
|
8
|
-
* @param env - Environment supplying HOME.
|
|
9
|
-
* @returns Absolute path of the config root.
|
|
10
|
-
*/
|
|
11
|
-
export declare function antigravityRoot(env: Env): string;
|
|
12
3
|
/**
|
|
13
4
|
* Where Antigravity reads named hook groups from.
|
|
14
5
|
*
|
|
@@ -12,7 +12,7 @@ import { ANTIGRAVITY_CLI_DIR_SEGMENTS, ANTIGRAVITY_EXECUTABLES, ANTIGRAVITY_HOOK
|
|
|
12
12
|
* @param env - Environment supplying HOME.
|
|
13
13
|
* @returns Absolute path of the config root.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
function antigravityRoot(env) {
|
|
16
16
|
return path.join(env.home, ...ANTIGRAVITY_ROOT_SEGMENTS);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { antigravityCwd, antigravityHookEvent, parseAntigravityHookEvent } from './antigravity.adapter.js';
|
|
1
|
+
import { antigravityCwd, antigravityHookEvent, antigravityShellCall, parseAntigravityHookEvent } from './antigravity.adapter.js';
|
|
2
2
|
import { detectAntigravity } from './antigravity.detect.js';
|
|
3
3
|
import { installAntigravityHooks, uninstallAntigravityHooks } from './antigravity.hooks.js';
|
|
4
4
|
import { ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_FALLBACK_DECISION, ANTIGRAVITY_HOOK_DECISIONS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
|
|
@@ -14,7 +14,8 @@ export const antigravityProvider = {
|
|
|
14
14
|
const decision = hook === undefined ? ANTIGRAVITY_FALLBACK_DECISION : ANTIGRAVITY_HOOK_DECISIONS[hook];
|
|
15
15
|
return { stdout: JSON.stringify(decision ?? {}), exitCode: 0 };
|
|
16
16
|
},
|
|
17
|
-
resolveCwd: antigravityCwd
|
|
17
|
+
resolveCwd: antigravityCwd,
|
|
18
|
+
shellCall: antigravityShellCall
|
|
18
19
|
// No nativeTelemetry: Antigravity exposes no OTLP exporter configuration, so
|
|
19
20
|
// there is no llm.call ledger source and turn summaries stay
|
|
20
21
|
// usage_status=pending. Adding a configurator would claim a capability the
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const ANTIGRAVITY_PROVIDER_ID = "antigravity";
|
|
2
2
|
export declare const ANTIGRAVITY_DISPLAY_NAME = "Google Antigravity";
|
|
3
|
+
/** `run_command`'s working-directory argument, PascalCase like all of its arguments. */
|
|
4
|
+
export declare const ANTIGRAVITY_CWD_KEY = "Cwd";
|
|
3
5
|
/** Antigravity shares Gemini's home; its own config lives one level down. */
|
|
4
6
|
export declare const ANTIGRAVITY_ROOT_SEGMENTS: readonly [".gemini", "config"];
|
|
5
7
|
export declare const ANTIGRAVITY_CLI_DIR_SEGMENTS: readonly [".gemini", "antigravity-cli"];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const ANTIGRAVITY_PROVIDER_ID = 'antigravity';
|
|
2
2
|
export const ANTIGRAVITY_DISPLAY_NAME = 'Google Antigravity';
|
|
3
|
+
/** `run_command`'s working-directory argument, PascalCase like all of its arguments. */
|
|
4
|
+
export const ANTIGRAVITY_CWD_KEY = 'Cwd';
|
|
3
5
|
/** Antigravity shares Gemini's home; its own config lives one level down. */
|
|
4
6
|
export const ANTIGRAVITY_ROOT_SEGMENTS = ['.gemini', 'config'];
|
|
5
7
|
export const ANTIGRAVITY_CLI_DIR_SEGMENTS = ['.gemini', 'antigravity-cli'];
|
|
@@ -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 { ClaudePayload } from './types/claude.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Translate one Claude Code hook payload into canonical events.
|
|
@@ -13,3 +13,13 @@ export type { ClaudePayload } from './types/claude.types.js';
|
|
|
13
13
|
* @returns The canonical events, or an empty list.
|
|
14
14
|
*/
|
|
15
15
|
export declare function parseClaudeHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
|
|
16
|
+
/**
|
|
17
|
+
* The command a Bash tool hook is about to run, or has just run.
|
|
18
|
+
*
|
|
19
|
+
* Claude reports no separate working directory for the call: it runs in the
|
|
20
|
+
* payload's `cwd`.
|
|
21
|
+
*
|
|
22
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
23
|
+
* @returns The command, or undefined for any other payload.
|
|
24
|
+
*/
|
|
25
|
+
export declare function claudeShellCall(rawPayload: unknown): ShellCall | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sha256Hex } from '../../events/event-id.js';
|
|
2
2
|
import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
|
|
3
|
-
import { classifyTool, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
4
|
-
import { CLAUDE_DISPLAY_NAME, CLAUDE_EVENT_TYPE_MAP, CLAUDE_PROVIDER_ID, CLAUDE_TOOL_EVENTS, CLAUDE_TOOL_START_EVENTS, CLAUDE_UNKNOWN_EVENT } from './constants/claude.constants.js';
|
|
3
|
+
import { classifyTool, extractCommand, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
4
|
+
import { CLAUDE_DISPLAY_NAME, CLAUDE_EVENT_TYPE_MAP, CLAUDE_PROVIDER_ID, CLAUDE_SHELL_REREAD_EVENTS, CLAUDE_TOOL_EVENTS, CLAUDE_TOOL_START_EVENTS, CLAUDE_UNKNOWN_EVENT } from './constants/claude.constants.js';
|
|
5
5
|
import { claudePayloadSchema } from './schemas/claude.schema.js';
|
|
6
6
|
/**
|
|
7
7
|
* Translate one Claude Code hook payload into canonical events.
|
|
@@ -22,6 +22,28 @@ export function parseClaudeHookEvent(rawPayload, context) {
|
|
|
22
22
|
const providerEventType = payload.hook_event_name ?? CLAUDE_UNKNOWN_EVENT;
|
|
23
23
|
return [withPatch(claudeBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The command a Bash tool hook is about to run, or has just run.
|
|
27
|
+
*
|
|
28
|
+
* Claude reports no separate working directory for the call: it runs in the
|
|
29
|
+
* payload's `cwd`.
|
|
30
|
+
*
|
|
31
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
32
|
+
* @returns The command, or undefined for any other payload.
|
|
33
|
+
*/
|
|
34
|
+
export function claudeShellCall(rawPayload) {
|
|
35
|
+
const parsed = claudePayloadSchema.safeParse(rawPayload);
|
|
36
|
+
const hookName = parsed.success ? (parsed.data.hook_event_name ?? '') : '';
|
|
37
|
+
// The completion too, failed or not: a command can create the worktree it
|
|
38
|
+
// works in, which only exists to be found once the command has run — and a
|
|
39
|
+
// command that exits non-zero may have got that far.
|
|
40
|
+
if (!parsed.success || (!CLAUDE_TOOL_START_EVENTS.has(hookName) && !CLAUDE_SHELL_REREAD_EVENTS.has(hookName)))
|
|
41
|
+
return undefined;
|
|
42
|
+
if (classifyTool(parsed.data.tool_name) !== 'shell')
|
|
43
|
+
return undefined;
|
|
44
|
+
const command = extractCommand(parsed.data.tool_input);
|
|
45
|
+
return command ? { command } : undefined;
|
|
46
|
+
}
|
|
25
47
|
/**
|
|
26
48
|
* The provider-independent part of the event.
|
|
27
49
|
*
|
|
@@ -62,7 +84,6 @@ function claudeBaseEvent(payload, providerEventType) {
|
|
|
62
84
|
* @returns The patch; empty for a hook we model but read nothing from.
|
|
63
85
|
*/
|
|
64
86
|
function hookPatch(payload, providerEventType, context) {
|
|
65
|
-
const capture = context.config.capture;
|
|
66
87
|
if (providerEventType === 'SessionStart') {
|
|
67
88
|
return {
|
|
68
89
|
metadata: { sessionSource: payload.source },
|
|
@@ -72,11 +93,11 @@ function hookPatch(payload, providerEventType, context) {
|
|
|
72
93
|
if (providerEventType === 'SessionEnd')
|
|
73
94
|
return { metadata: { sessionEndReason: payload.reason } };
|
|
74
95
|
if (providerEventType === 'UserPromptSubmit')
|
|
75
|
-
return promptPatch(payload.prompt ?? '', capture);
|
|
96
|
+
return promptPatch(payload.prompt ?? '', context.config.capture);
|
|
76
97
|
if (CLAUDE_TOOL_EVENTS.has(providerEventType))
|
|
77
98
|
return claudeToolPatch(payload, providerEventType, context);
|
|
78
99
|
if (providerEventType === 'Stop') {
|
|
79
|
-
const response = responsePatch(payload.last_assistant_message ?? ''
|
|
100
|
+
const response = responsePatch(payload.last_assistant_message ?? '');
|
|
80
101
|
return { ...response, metadata: { stopHookActive: payload.stop_hook_active, ...response.metadata } };
|
|
81
102
|
}
|
|
82
103
|
if (providerEventType === 'SubagentStart' || providerEventType === 'SubagentStop') {
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
import type { Env } from '../../core/types/core.types.js';
|
|
2
2
|
import type { NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
|
|
3
|
+
/** Where Claude Code's exporters send, as its settings file says. */
|
|
4
|
+
export interface ClaudeExporterTargets {
|
|
5
|
+
/** `OTEL_EXPORTER_OTLP_ENDPOINT`, when set. */
|
|
6
|
+
readonly base?: string;
|
|
7
|
+
/** Every per-signal endpoint that is set; each overrides the base for its signal. */
|
|
8
|
+
readonly signals: readonly string[];
|
|
9
|
+
}
|
|
3
10
|
/**
|
|
4
|
-
*
|
|
11
|
+
* Where Claude Code's exporters actually send, read from the settings file
|
|
12
|
+
* setup writes them into.
|
|
5
13
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* llm.call; the enhanced-traces beta adds `claude_code.llm_request` spans
|
|
10
|
-
* carrying query_source/agent_id, which is what keeps child-agent traffic from
|
|
11
|
-
* being folded into the main agent.
|
|
14
|
+
* The bearer `otel-headers` hands out goes wherever these say, and anyone who
|
|
15
|
+
* can edit that file can change them, so the helper checks them rather than
|
|
16
|
+
* trusting that they still say what setup wrote.
|
|
12
17
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @returns The
|
|
15
|
-
* backend is configured.
|
|
18
|
+
* @param env - Ambient environment, for the settings path.
|
|
19
|
+
* @returns The endpoints; empty when the file is missing or unreadable.
|
|
16
20
|
*/
|
|
17
|
-
export declare function
|
|
21
|
+
export declare function claudeExporterTargets(env: Env): Promise<ClaudeExporterTargets>;
|
|
18
22
|
/**
|
|
19
|
-
*
|
|
23
|
+
* Exporter endpoints set anywhere but the user settings file: the environment
|
|
24
|
+
* the helper inherits from Claude Code, and the project and local settings of
|
|
25
|
+
* the working directory and each folder above it.
|
|
20
26
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
27
|
+
* Claude Code merges those over the user file, so either can send the export,
|
|
28
|
+
* and with it the bearer, somewhere the user file does not say. A cloned repo is
|
|
29
|
+
* a likelier author of that than the developer's own home settings.
|
|
24
30
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
31
|
+
* @param env - Ambient environment: its variables and working directory.
|
|
32
|
+
* @returns Every endpoint set, base and per signal alike.
|
|
27
33
|
*/
|
|
28
|
-
export declare function
|
|
34
|
+
export declare function claudeOverrideTargets(env: Env): Promise<readonly string[]>;
|
|
29
35
|
/**
|
|
30
36
|
* Configures Claude Code's own OTLP export, which is where the llm.call usage
|
|
31
37
|
* ledger comes from.
|
|
@@ -70,6 +76,14 @@ export declare class ClaudeOtelConfigurator implements NativeTelemetryConfigurat
|
|
|
70
76
|
* install state.
|
|
71
77
|
*/
|
|
72
78
|
uninstall(context: SetupContext): Promise<SetupOutcome>;
|
|
79
|
+
/**
|
|
80
|
+
* Where the exporter setup recorded as AgentWatch's sends. Nothing without
|
|
81
|
+
* that record: the endpoint may then be the developer's own.
|
|
82
|
+
*
|
|
83
|
+
* @param context - Environment and install state.
|
|
84
|
+
* @returns The owned endpoint, or none.
|
|
85
|
+
*/
|
|
86
|
+
exporterEndpoints(context: SetupContext): Promise<readonly string[]>;
|
|
73
87
|
/**
|
|
74
88
|
* Handle `configure` when telemetry is off or unconfigurable.
|
|
75
89
|
*
|
|
@@ -1,13 +1,29 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import { asRecord, omitKeys } from '../../core/object.js';
|
|
2
3
|
import { enabledSignalNames, otelEnabled, otlpBaseUrl } from '../../config/config.js';
|
|
3
4
|
import { backupFile } from '../../storage/atomic-file.js';
|
|
5
|
+
import { hasCredential } from '../../credentials/identity.js';
|
|
4
6
|
import { readJsonFile } from '../../storage/json-file.js';
|
|
5
7
|
import { writeJsonValidated } from '../shared/hook-config.js';
|
|
6
8
|
import { withOtelInstall, withoutOtelInstall } from '../shared/install-record.js';
|
|
7
9
|
import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
|
|
8
10
|
import { claudeSettingsPath } from './claude.detect.js';
|
|
9
11
|
import { CLAUDE_PROVIDER_ID } from './constants/claude.constants.js';
|
|
10
|
-
import { ENV_BLOCK_KEY, HEADERS_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OTLP, OTLP_PROTOCOL, RE_HOOK_SUFFIX } from './constants/claude.otel.constants.js';
|
|
12
|
+
import { ENV_BLOCK_KEY, HEADERS_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OTLP, OTLP_ENDPOINT_KEY, OTLP_PROTOCOL, OTLP_SIGNAL_ENDPOINT_KEYS, RE_HOOK_SUFFIX } from './constants/claude.otel.constants.js';
|
|
13
|
+
/**
|
|
14
|
+
* Claude's own content-logging switches, forced off.
|
|
15
|
+
*
|
|
16
|
+
* Never treated as a foreign key: a user who set `OTEL_LOG_USER_PROMPTS=1`
|
|
17
|
+
* before installing is exactly the case this exists to override, and refusing
|
|
18
|
+
* to configure them would leave prompt logging on *and* drop the llm.call
|
|
19
|
+
* ledger. Overriding a switch that only ever reduces what leaves the machine
|
|
20
|
+
* is not the redirection the conflict check protects against.
|
|
21
|
+
*/
|
|
22
|
+
const CONTENT_LOG_OFF = {
|
|
23
|
+
OTEL_LOG_USER_PROMPTS: '0',
|
|
24
|
+
OTEL_LOG_TOOL_DETAILS: '0',
|
|
25
|
+
OTEL_LOG_TOOL_CONTENT: '0'
|
|
26
|
+
};
|
|
11
27
|
/**
|
|
12
28
|
* The telemetry environment AgentWatch wants in Claude Code's settings.
|
|
13
29
|
*
|
|
@@ -22,23 +38,69 @@ import { ENV_BLOCK_KEY, HEADERS_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OT
|
|
|
22
38
|
* @returns The desired variables, or undefined when telemetry is off or no
|
|
23
39
|
* backend is configured.
|
|
24
40
|
*/
|
|
25
|
-
|
|
41
|
+
function desiredClaudeOtelEnv(context) {
|
|
26
42
|
const otlpBase = otlpBaseUrl(context.config);
|
|
27
43
|
if (!otlpBase || !otelEnabled(context.config))
|
|
28
44
|
return undefined;
|
|
29
45
|
const signals = context.config.otel;
|
|
30
46
|
return {
|
|
31
47
|
CLAUDE_CODE_ENABLE_TELEMETRY: '1',
|
|
48
|
+
...CONTENT_LOG_OFF,
|
|
32
49
|
OTEL_METRICS_EXPORTER: signals.metrics ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
|
|
33
50
|
OTEL_LOGS_EXPORTER: signals.logs ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
|
|
34
51
|
OTEL_TRACES_EXPORTER: signals.traces ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
|
|
35
52
|
// No default protocol exists; it has to be explicit.
|
|
36
53
|
OTEL_EXPORTER_OTLP_PROTOCOL: OTLP_PROTOCOL,
|
|
37
|
-
|
|
54
|
+
[OTLP_ENDPOINT_KEY]: otlpBase,
|
|
38
55
|
// The beta flag only adds the llm_request spans; it stays tied to traces.
|
|
39
56
|
...(signals.traces ? { CLAUDE_CODE_ENHANCED_TELEMETRY_BETA: '1' } : {})
|
|
40
57
|
};
|
|
41
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Where Claude Code's exporters actually send, read from the settings file
|
|
61
|
+
* setup writes them into.
|
|
62
|
+
*
|
|
63
|
+
* The bearer `otel-headers` hands out goes wherever these say, and anyone who
|
|
64
|
+
* can edit that file can change them, so the helper checks them rather than
|
|
65
|
+
* trusting that they still say what setup wrote.
|
|
66
|
+
*
|
|
67
|
+
* @param env - Ambient environment, for the settings path.
|
|
68
|
+
* @returns The endpoints; empty when the file is missing or unreadable.
|
|
69
|
+
*/
|
|
70
|
+
export async function claudeExporterTargets(env) {
|
|
71
|
+
const read = await readJsonFile(claudeSettingsPath(env));
|
|
72
|
+
const envBlock = asRecord(read.state === 'ok' ? asRecord(read.value)?.[ENV_BLOCK_KEY] : undefined) ?? {};
|
|
73
|
+
const base = envBlock[OTLP_ENDPOINT_KEY];
|
|
74
|
+
const signals = OTLP_SIGNAL_ENDPOINT_KEYS.map((key) => envBlock[key]).filter((value) => value !== undefined).map(String);
|
|
75
|
+
return { ...(typeof base === 'string' ? { base } : {}), signals };
|
|
76
|
+
}
|
|
77
|
+
/** Project settings files Claude Code layers over the user file, in a `.claude` folder. */
|
|
78
|
+
const PROJECT_SETTINGS_FILES = ['settings.json', 'settings.local.json'];
|
|
79
|
+
/**
|
|
80
|
+
* Exporter endpoints set anywhere but the user settings file: the environment
|
|
81
|
+
* the helper inherits from Claude Code, and the project and local settings of
|
|
82
|
+
* the working directory and each folder above it.
|
|
83
|
+
*
|
|
84
|
+
* Claude Code merges those over the user file, so either can send the export,
|
|
85
|
+
* and with it the bearer, somewhere the user file does not say. A cloned repo is
|
|
86
|
+
* a likelier author of that than the developer's own home settings.
|
|
87
|
+
*
|
|
88
|
+
* @param env - Ambient environment: its variables and working directory.
|
|
89
|
+
* @returns Every endpoint set, base and per signal alike.
|
|
90
|
+
*/
|
|
91
|
+
export async function claudeOverrideTargets(env) {
|
|
92
|
+
const keys = [OTLP_ENDPOINT_KEY, ...OTLP_SIGNAL_ENDPOINT_KEYS];
|
|
93
|
+
const targets = keys.map((key) => env.vars[key]).filter((value) => value !== undefined && value !== '');
|
|
94
|
+
for (let dir = path.resolve(env.cwd);; dir = path.dirname(dir)) {
|
|
95
|
+
for (const file of PROJECT_SETTINGS_FILES) {
|
|
96
|
+
const read = await readJsonFile(path.join(dir, '.claude', file));
|
|
97
|
+
const envBlock = asRecord(read.state === 'ok' ? asRecord(read.value)?.[ENV_BLOCK_KEY] : undefined) ?? {};
|
|
98
|
+
targets.push(...keys.map((key) => envBlock[key]).filter((value) => value !== undefined).map(String));
|
|
99
|
+
}
|
|
100
|
+
if (path.dirname(dir) === dir)
|
|
101
|
+
return targets;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
42
104
|
/**
|
|
43
105
|
* The `agentwatch otel-headers` command for this install.
|
|
44
106
|
*
|
|
@@ -49,7 +111,7 @@ export function desiredClaudeOtelEnv(context) {
|
|
|
49
111
|
* @param hookCommand - The generated `<bin> hook --agent claude` command.
|
|
50
112
|
* @returns The helper command reusing the same binary path.
|
|
51
113
|
*/
|
|
52
|
-
|
|
114
|
+
function headersHelperCommand(hookCommand) {
|
|
53
115
|
return `${hookCommand.replace(RE_HOOK_SUFFIX, '')} otel-headers`;
|
|
54
116
|
}
|
|
55
117
|
/**
|
|
@@ -195,6 +257,19 @@ export class ClaudeOtelConfigurator {
|
|
|
195
257
|
installState: withoutOtelInstall(context.installState, CLAUDE_PROVIDER_ID)
|
|
196
258
|
};
|
|
197
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Where the exporter setup recorded as AgentWatch's sends. Nothing without
|
|
262
|
+
* that record: the endpoint may then be the developer's own.
|
|
263
|
+
*
|
|
264
|
+
* @param context - Environment and install state.
|
|
265
|
+
* @returns The owned endpoint, or none.
|
|
266
|
+
*/
|
|
267
|
+
async exporterEndpoints(context) {
|
|
268
|
+
if (!this.ownedKeys(context).includes(OTLP_ENDPOINT_KEY))
|
|
269
|
+
return [];
|
|
270
|
+
const { base } = await claudeExporterTargets(context.env);
|
|
271
|
+
return base === undefined ? [] : [base];
|
|
272
|
+
}
|
|
198
273
|
/**
|
|
199
274
|
* Handle `configure` when telemetry is off or unconfigurable.
|
|
200
275
|
*
|
|
@@ -228,7 +303,7 @@ export class ClaudeOtelConfigurator {
|
|
|
228
303
|
* @returns The next settings and the extra owned key, or a conflict message.
|
|
229
304
|
*/
|
|
230
305
|
applyHeadersHelper(settings, context) {
|
|
231
|
-
if (!context.config
|
|
306
|
+
if (!hasCredential(context.config))
|
|
232
307
|
return { settings, ownedExtra: [] };
|
|
233
308
|
const helperCommand = headersHelperCommand(context.hookCommand);
|
|
234
309
|
const existing = settings[HEADERS_HELPER_KEY];
|
|
@@ -274,7 +349,7 @@ function inspectDisabled(settings, envBlock, ownedKeys) {
|
|
|
274
349
|
* @returns The conflicting key names.
|
|
275
350
|
*/
|
|
276
351
|
function foreignKeys(envBlock, desired, ownedKeys) {
|
|
277
|
-
const owned = new Set(ownedKeys);
|
|
352
|
+
const owned = new Set([...ownedKeys, ...Object.keys(CONTENT_LOG_OFF)]);
|
|
278
353
|
return Object.keys(desired).filter((key) => envBlock[key] !== undefined && envBlock[key] !== desired[key] && !owned.has(key));
|
|
279
354
|
}
|
|
280
355
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { hookRefusal } from '../shared/hook-refusal.js';
|
|
1
|
+
import { hookNotice, hookRefusal } from '../shared/hook-refusal.js';
|
|
2
2
|
import { CLAUDE_PROMPT_SUBMIT_EVENTS } from './constants/claude.constants.js';
|
|
3
3
|
import { detectClaude } from './claude.detect.js';
|
|
4
4
|
import { installClaudeHooks, uninstallClaudeHooks } from './claude.hooks.js';
|
|
5
|
-
import { parseClaudeHookEvent } from './claude.adapter.js';
|
|
5
|
+
import { claudeShellCall, parseClaudeHookEvent } from './claude.adapter.js';
|
|
6
6
|
import { ClaudeOtelConfigurator } from './claude.otel.js';
|
|
7
7
|
export const claudeProvider = {
|
|
8
8
|
id: 'claude',
|
|
@@ -22,5 +22,8 @@ export const claudeProvider = {
|
|
|
22
22
|
* event can be refused by this path.
|
|
23
23
|
*/
|
|
24
24
|
getBlockResponse: (payload, message) => hookRefusal(payload, CLAUDE_PROMPT_SUBMIT_EVENTS, { decision: 'block', reason: message }),
|
|
25
|
+
/** A line for the developer after a shell run, as `systemMessage`; never plain stdout. */
|
|
26
|
+
getNoticeResponse: (payload, message) => hookNotice(payload, message),
|
|
27
|
+
shellCall: claudeShellCall,
|
|
25
28
|
nativeTelemetry: new ClaudeOtelConfigurator()
|
|
26
29
|
};
|
|
@@ -22,6 +22,8 @@ export declare const CLAUDE_EVENT_TYPE_MAP: Readonly<Record<string, CanonicalEve
|
|
|
22
22
|
export declare const CLAUDE_TOOL_EVENTS: ReadonlySet<string>;
|
|
23
23
|
/** Hooks that report a tool call as starting rather than finishing. */
|
|
24
24
|
export declare const CLAUDE_TOOL_START_EVENTS: ReadonlySet<string>;
|
|
25
|
+
/** Completions whose shell command is read again for a checkout the command created. */
|
|
26
|
+
export declare const CLAUDE_SHELL_REREAD_EVENTS: ReadonlySet<string>;
|
|
25
27
|
/**
|
|
26
28
|
* The one hook a budget refusal may travel on.
|
|
27
29
|
*
|
|
@@ -42,6 +42,8 @@ export const CLAUDE_EVENT_TYPE_MAP = {
|
|
|
42
42
|
export const CLAUDE_TOOL_EVENTS = new Set(['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'PermissionRequest']);
|
|
43
43
|
/** Hooks that report a tool call as starting rather than finishing. */
|
|
44
44
|
export const CLAUDE_TOOL_START_EVENTS = new Set(['PreToolUse', 'PermissionRequest']);
|
|
45
|
+
/** Completions whose shell command is read again for a checkout the command created. */
|
|
46
|
+
export const CLAUDE_SHELL_REREAD_EVENTS = new Set(['PostToolUse', 'PostToolUseFailure']);
|
|
45
47
|
/**
|
|
46
48
|
* The one hook a budget refusal may travel on.
|
|
47
49
|
*
|
|
@@ -15,3 +15,7 @@ export declare const OTEL_EXPORTER_OTLP = "otlp";
|
|
|
15
15
|
export declare const OTLP_PROTOCOL = "http/json";
|
|
16
16
|
/** Trailing `hook --agent <id>` of a hook command, stripped to reuse the binary. */
|
|
17
17
|
export declare const RE_HOOK_SUFFIX: RegExp;
|
|
18
|
+
/** Where Claude Code's exporters send: the OTLP base every signal derives from. */
|
|
19
|
+
export declare const OTLP_ENDPOINT_KEY = "OTEL_EXPORTER_OTLP_ENDPOINT";
|
|
20
|
+
/** Per-signal endpoints, which override the base for that one signal. */
|
|
21
|
+
export declare const OTLP_SIGNAL_ENDPOINT_KEYS: readonly string[];
|
|
@@ -15,3 +15,11 @@ export const OTEL_EXPORTER_OTLP = 'otlp';
|
|
|
15
15
|
export const OTLP_PROTOCOL = 'http/json';
|
|
16
16
|
/** Trailing `hook --agent <id>` of a hook command, stripped to reuse the binary. */
|
|
17
17
|
export const RE_HOOK_SUFFIX = /\s+hook\s+--agent\s+\S+\s*$/;
|
|
18
|
+
/** Where Claude Code's exporters send: the OTLP base every signal derives from. */
|
|
19
|
+
export const OTLP_ENDPOINT_KEY = 'OTEL_EXPORTER_OTLP_ENDPOINT';
|
|
20
|
+
/** Per-signal endpoints, which override the base for that one signal. */
|
|
21
|
+
export const OTLP_SIGNAL_ENDPOINT_KEYS = [
|
|
22
|
+
'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
|
|
23
|
+
'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT',
|
|
24
|
+
'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
|
|
25
|
+
];
|
|
@@ -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 { CodexPayload } from './types/codex.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Translate one Codex hook payload into canonical events.
|
|
@@ -9,3 +9,17 @@ export type { CodexPayload } from './types/codex.types.js';
|
|
|
9
9
|
* @returns The canonical events, or an empty list for an unusable payload.
|
|
10
10
|
*/
|
|
11
11
|
export declare function parseCodexHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
|
|
12
|
+
/**
|
|
13
|
+
* The command a shell call runs, on its `PreToolUse` and its `PostToolUse` —
|
|
14
|
+
* the latter because a command can create the worktree it works in.
|
|
15
|
+
*
|
|
16
|
+
* Codex reports every shell call to hooks as `Bash` with `tool_input:
|
|
17
|
+
* {command}` (openai/codex `core/src/tools/hook_names.rs`,
|
|
18
|
+
* `handlers/unified_exec/exec_command.rs`, 2026-09). The model's own `workdir`
|
|
19
|
+
* argument is dropped before the hook, so there is no working directory to
|
|
20
|
+
* read: the call runs in the payload's `cwd` unless its command says otherwise.
|
|
21
|
+
*
|
|
22
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
23
|
+
* @returns The command, or undefined for any other payload.
|
|
24
|
+
*/
|
|
25
|
+
export declare function codexShellCall(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 { CODEX_DISPLAY_NAME, CODEX_EVENT_TYPE_MAP, CODEX_PROVIDER_ID, CODEX_SHELL_CALL_EVENTS, CODEX_TOOL_EVENTS, CODEX_UNKNOWN_EVENT } from './constants/codex.constants.js';
|
|
5
7
|
import { codexPayloadSchema } from './schemas/codex.schema.js';
|
|
6
8
|
/**
|
|
7
9
|
* Translate one Codex hook payload into canonical events.
|
|
@@ -18,6 +20,25 @@ export function parseCodexHookEvent(rawPayload, context) {
|
|
|
18
20
|
const providerEventType = payload.hook_event_name ?? CODEX_UNKNOWN_EVENT;
|
|
19
21
|
return [withPatch(codexBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The command a shell call runs, on its `PreToolUse` and its `PostToolUse` —
|
|
25
|
+
* the latter because a command can create the worktree it works in.
|
|
26
|
+
*
|
|
27
|
+
* Codex reports every shell call to hooks as `Bash` with `tool_input:
|
|
28
|
+
* {command}` (openai/codex `core/src/tools/hook_names.rs`,
|
|
29
|
+
* `handlers/unified_exec/exec_command.rs`, 2026-09). The model's own `workdir`
|
|
30
|
+
* argument is dropped before the hook, so there is no working directory to
|
|
31
|
+
* read: the call runs in the payload's `cwd` unless its command says otherwise.
|
|
32
|
+
*
|
|
33
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
34
|
+
* @returns The command, or undefined for any other payload.
|
|
35
|
+
*/
|
|
36
|
+
export function codexShellCall(rawPayload) {
|
|
37
|
+
const parsed = codexPayloadSchema.safeParse(rawPayload);
|
|
38
|
+
if (!parsed.success || !CODEX_SHELL_CALL_EVENTS.has(parsed.data.hook_event_name ?? '') || classifyTool(parsed.data.tool_name) !== 'shell')
|
|
39
|
+
return undefined;
|
|
40
|
+
return shellCallOf(asRecord(parsed.data.tool_input)?.[SHELL_COMMAND_KEY], undefined);
|
|
41
|
+
}
|
|
21
42
|
/**
|
|
22
43
|
* The provider-independent part of the event.
|
|
23
44
|
*
|
|
@@ -65,17 +86,20 @@ function hookPatch(payload, providerEventType, context) {
|
|
|
65
86
|
if (providerEventType === 'UserPromptSubmit')
|
|
66
87
|
return promptPatch(payload.prompt ?? '', capture);
|
|
67
88
|
if (CODEX_TOOL_EVENTS.has(providerEventType)) {
|
|
89
|
+
const kind = classifyTool(payload.tool_name);
|
|
90
|
+
const mcp = kind === 'mcp' && payload.tool_name ? parseMcpToolName(payload.tool_name) : undefined;
|
|
68
91
|
return toolPatch({
|
|
69
92
|
name: payload.tool_name,
|
|
70
93
|
status: providerEventType === 'PostToolUse' ? 'completed' : 'started',
|
|
71
|
-
kind
|
|
94
|
+
kind,
|
|
72
95
|
toolUseId: payload.tool_use_id,
|
|
73
96
|
input: payload.tool_input,
|
|
74
|
-
output: payload.tool_response
|
|
97
|
+
output: payload.tool_response,
|
|
98
|
+
providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : undefined
|
|
75
99
|
}, capture);
|
|
76
100
|
}
|
|
77
101
|
if (providerEventType === 'Stop') {
|
|
78
|
-
const response = responsePatch(payload.last_assistant_message ?? ''
|
|
102
|
+
const response = responsePatch(payload.last_assistant_message ?? '');
|
|
79
103
|
return { ...response, metadata: { stopHookActive: payload.stop_hook_active, ...response.metadata } };
|
|
80
104
|
}
|
|
81
105
|
if (providerEventType === 'SubagentStart' || providerEventType === 'SubagentStop') {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Env } from '../../core/types/core.types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AgentWatchConfig, OtelSignalName } from '../../config/types/config.types.js';
|
|
3
|
+
import type { BearerRewriteContext, NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Configures Codex's own OTLP export.
|
|
5
6
|
*
|
|
@@ -33,14 +34,46 @@ export declare class CodexOtelConfigurator implements NativeTelemetryConfigurato
|
|
|
33
34
|
/**
|
|
34
35
|
* Remove the managed block from Codex's config.toml.
|
|
35
36
|
*
|
|
36
|
-
* Only
|
|
37
|
-
*
|
|
37
|
+
* Only our own `[otel]` table goes. Everything the developer wrote around the
|
|
38
|
+
* markers — comments included — is preserved byte for byte, and so is
|
|
39
|
+
* anything the agent wrote *inside* them: Codex parks its `[hooks.state]`
|
|
40
|
+
* trust hashes there when it re-serializes the file.
|
|
38
41
|
*
|
|
39
42
|
* @param context - Environment, paths and install state.
|
|
40
43
|
* @returns Whether the file changed, what to tell the user, and the next
|
|
41
44
|
* install state.
|
|
42
45
|
*/
|
|
43
46
|
uninstall(context: SetupContext): Promise<SetupOutcome>;
|
|
47
|
+
/**
|
|
48
|
+
* Swap the bearer in our exporters for the current one.
|
|
49
|
+
*
|
|
50
|
+
* Only the bearer in our own `[otel]` table changes: an MCP server's
|
|
51
|
+
* `Authorization` that Codex parked inside our markers is not ours. No
|
|
52
|
+
* backup: one per rotation would collect copies of every token.
|
|
53
|
+
*
|
|
54
|
+
* @param context - The recorded file, its contents as read and the current bearer.
|
|
55
|
+
* @returns True when the file was rewritten.
|
|
56
|
+
*/
|
|
57
|
+
rewriteBearer(context: BearerRewriteContext): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Where the managed block's exporters send. The block is AgentWatch's whole,
|
|
60
|
+
* so every endpoint in it is.
|
|
61
|
+
*
|
|
62
|
+
* @param context - Environment.
|
|
63
|
+
* @returns The endpoints; none when there is no block or it does not parse.
|
|
64
|
+
*/
|
|
65
|
+
exporterEndpoints(context: SetupContext): Promise<readonly string[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Signals Codex was asked for but will not be given under current consent.
|
|
68
|
+
*
|
|
69
|
+
* Codex's usage logs and traces both carry tool arguments and results with no
|
|
70
|
+
* per-field filter, so the two of them stand or fall together on
|
|
71
|
+
* `toolContentConsented`.
|
|
72
|
+
*
|
|
73
|
+
* @param config - Effective configuration.
|
|
74
|
+
* @returns The requested signals that are held back; empty when none are.
|
|
75
|
+
*/
|
|
76
|
+
withheldSignals(config: AgentWatchConfig): readonly OtelSignalName[];
|
|
44
77
|
/**
|
|
45
78
|
* Handle `configure` when Codex telemetry is deliberately off.
|
|
46
79
|
*
|