@agent-watch-ai/edge 0.2.5
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 +251 -0
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/dist/billing/billing-mode.d.ts +16 -0
- package/dist/billing/billing-mode.js +139 -0
- package/dist/billing/constants/billing.constants.d.ts +37 -0
- package/dist/billing/constants/billing.constants.js +38 -0
- package/dist/billing/index.d.ts +6 -0
- package/dist/billing/index.js +6 -0
- package/dist/cli/args.d.ts +29 -0
- package/dist/cli/args.js +61 -0
- package/dist/cli/constants/cli.constants.d.ts +60 -0
- package/dist/cli/constants/cli.constants.js +60 -0
- package/dist/cli/context.d.ts +51 -0
- package/dist/cli/context.js +108 -0
- package/dist/cli/doctor.d.ts +15 -0
- package/dist/cli/doctor.js +416 -0
- package/dist/cli/hook.d.ts +20 -0
- package/dist/cli/hook.js +166 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +8 -0
- package/dist/cli/misc.d.ts +31 -0
- package/dist/cli/misc.js +63 -0
- package/dist/cli/setup.d.ts +32 -0
- package/dist/cli/setup.js +298 -0
- package/dist/cli/status.d.ts +11 -0
- package/dist/cli/status.js +174 -0
- package/dist/cli/types/cli.types.d.ts +69 -0
- package/dist/cli/types/cli.types.js +1 -0
- package/dist/cli/ui.d.ts +41 -0
- package/dist/cli/ui.js +78 -0
- package/dist/cli/uninstall.d.ts +13 -0
- package/dist/cli/uninstall.js +83 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +124 -0
- package/dist/config/config-store.d.ts +29 -0
- package/dist/config/config-store.js +75 -0
- package/dist/config/config.d.ts +73 -0
- package/dist/config/config.js +115 -0
- package/dist/config/constants/config.constants.d.ts +62 -0
- package/dist/config/constants/config.constants.js +70 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.js +5 -0
- package/dist/config/repo-config.d.ts +37 -0
- package/dist/config/repo-config.js +178 -0
- package/dist/config/schemas/config.schema.d.ts +409 -0
- package/dist/config/schemas/config.schema.js +97 -0
- package/dist/config/types/config.types.d.ts +33 -0
- package/dist/config/types/config.types.js +1 -0
- package/dist/core/async.d.ts +20 -0
- package/dist/core/async.js +32 -0
- package/dist/core/constants/core.constants.d.ts +18 -0
- package/dist/core/constants/core.constants.js +18 -0
- package/dist/core/env.d.ts +12 -0
- package/dist/core/env.js +20 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +8 -0
- package/dist/core/logger.d.ts +27 -0
- package/dist/core/logger.js +82 -0
- package/dist/core/number.d.ts +33 -0
- package/dist/core/number.js +47 -0
- package/dist/core/object.d.ts +78 -0
- package/dist/core/object.js +127 -0
- package/dist/core/pipe.d.ts +55 -0
- package/dist/core/pipe.js +81 -0
- package/dist/core/types/core.types.d.ts +54 -0
- package/dist/core/types/core.types.js +4 -0
- package/dist/core/version.d.ts +19 -0
- package/dist/core/version.js +35 -0
- package/dist/core/which.d.ts +13 -0
- package/dist/core/which.js +57 -0
- package/dist/enforcement/constants/enforcement.constants.d.ts +23 -0
- package/dist/enforcement/constants/enforcement.constants.js +22 -0
- package/dist/enforcement/decision-cache.d.ts +57 -0
- package/dist/enforcement/decision-cache.js +138 -0
- package/dist/enforcement/decision-client.d.ts +14 -0
- package/dist/enforcement/decision-client.js +84 -0
- package/dist/enforcement/enforcement.d.ts +17 -0
- package/dist/enforcement/enforcement.js +90 -0
- package/dist/enforcement/index.d.ts +11 -0
- package/dist/enforcement/index.js +10 -0
- package/dist/enforcement/schemas/enforcement.schema.d.ts +30 -0
- package/dist/enforcement/schemas/enforcement.schema.js +36 -0
- package/dist/enforcement/types/enforcement.types.d.ts +59 -0
- package/dist/enforcement/types/enforcement.types.js +1 -0
- package/dist/enrollment/constants/enrollment.constants.d.ts +6 -0
- package/dist/enrollment/constants/enrollment.constants.js +6 -0
- package/dist/enrollment/enrollment-provider.d.ts +5 -0
- package/dist/enrollment/enrollment-provider.js +1 -0
- package/dist/enrollment/index.d.ts +7 -0
- package/dist/enrollment/index.js +1 -0
- package/dist/enrollment/manual-enrollment.d.ts +32 -0
- package/dist/enrollment/manual-enrollment.js +72 -0
- package/dist/enrollment/types/enrollment.types.d.ts +25 -0
- package/dist/enrollment/types/enrollment.types.js +1 -0
- package/dist/events/canonical-event.d.ts +10 -0
- package/dist/events/canonical-event.js +9 -0
- package/dist/events/constants/enrich.constants.d.ts +14 -0
- package/dist/events/constants/enrich.constants.js +15 -0
- package/dist/events/constants/events.constants.d.ts +35 -0
- package/dist/events/constants/events.constants.js +57 -0
- package/dist/events/enrich.d.ts +16 -0
- package/dist/events/enrich.js +226 -0
- package/dist/events/event-id.d.ts +32 -0
- package/dist/events/event-id.js +49 -0
- package/dist/events/index.d.ts +14 -0
- package/dist/events/index.js +5 -0
- package/dist/events/llm-call.d.ts +14 -0
- package/dist/events/llm-call.js +84 -0
- package/dist/events/product-event.d.ts +39 -0
- package/dist/events/product-event.js +19 -0
- package/dist/events/types/enrich.types.d.ts +25 -0
- package/dist/events/types/enrich.types.js +1 -0
- package/dist/events/types/events.types.d.ts +112 -0
- package/dist/events/types/events.types.js +1 -0
- package/dist/events/types/llm-call.types.d.ts +79 -0
- package/dist/events/types/llm-call.types.js +1 -0
- package/dist/events/types/repo-snapshot.types.d.ts +32 -0
- package/dist/events/types/repo-snapshot.types.js +1 -0
- package/dist/feature/constants/feature.constants.d.ts +10 -0
- package/dist/feature/constants/feature.constants.js +10 -0
- package/dist/feature/index.d.ts +6 -0
- package/dist/feature/index.js +6 -0
- package/dist/feature/ticket-candidates.d.ts +13 -0
- package/dist/feature/ticket-candidates.js +26 -0
- package/dist/git/constants/git.constants.d.ts +84 -0
- package/dist/git/constants/git.constants.js +113 -0
- package/dist/git/git-context.d.ts +52 -0
- package/dist/git/git-context.js +226 -0
- package/dist/git/index.d.ts +9 -0
- package/dist/git/index.js +3 -0
- package/dist/git/remote-sanitize.d.ts +26 -0
- package/dist/git/remote-sanitize.js +92 -0
- package/dist/git/repo-snapshot.d.ts +40 -0
- package/dist/git/repo-snapshot.js +95 -0
- package/dist/git/types/git.types.d.ts +36 -0
- package/dist/git/types/git.types.js +1 -0
- package/dist/git/types/snapshot.types.d.ts +25 -0
- package/dist/git/types/snapshot.types.js +1 -0
- package/dist/otlp/constants/otlp.constants.d.ts +84 -0
- package/dist/otlp/constants/otlp.constants.js +99 -0
- package/dist/otlp/http.d.ts +24 -0
- package/dist/otlp/http.js +37 -0
- package/dist/otlp/index.d.ts +9 -0
- package/dist/otlp/index.js +3 -0
- package/dist/otlp/normalize.d.ts +14 -0
- package/dist/otlp/normalize.js +404 -0
- package/dist/otlp/types/otlp.types.d.ts +69 -0
- package/dist/otlp/types/otlp.types.js +1 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +23 -0
- package/dist/pipeline/constants/pipeline.constants.js +22 -0
- package/dist/pipeline/hook-pipeline.d.ts +14 -0
- package/dist/pipeline/hook-pipeline.js +297 -0
- package/dist/pipeline/index.d.ts +6 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline/types/pipeline.types.d.ts +48 -0
- package/dist/pipeline/types/pipeline.types.js +1 -0
- package/dist/privacy/constants/privacy.constants.d.ts +23 -0
- package/dist/privacy/constants/privacy.constants.js +38 -0
- package/dist/privacy/index.d.ts +7 -0
- package/dist/privacy/index.js +2 -0
- package/dist/privacy/sanitizer.d.ts +20 -0
- package/dist/privacy/sanitizer.js +52 -0
- package/dist/privacy/types/privacy.types.d.ts +13 -0
- package/dist/privacy/types/privacy.types.js +1 -0
- package/dist/providers/antigravity/antigravity.adapter.d.ts +54 -0
- package/dist/providers/antigravity/antigravity.adapter.js +311 -0
- package/dist/providers/antigravity/antigravity.detect.d.ts +25 -0
- package/dist/providers/antigravity/antigravity.detect.js +64 -0
- package/dist/providers/antigravity/antigravity.hooks.d.ts +24 -0
- package/dist/providers/antigravity/antigravity.hooks.js +126 -0
- package/dist/providers/antigravity/antigravity.provider.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.provider.js +22 -0
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +72 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +75 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.d.ts +521 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.js +64 -0
- package/dist/providers/antigravity/types/antigravity.types.d.ts +13 -0
- package/dist/providers/antigravity/types/antigravity.types.js +1 -0
- package/dist/providers/claude/claude.adapter.d.ts +15 -0
- package/dist/providers/claude/claude.adapter.js +141 -0
- package/dist/providers/claude/claude.detect.d.ts +20 -0
- package/dist/providers/claude/claude.detect.js +57 -0
- package/dist/providers/claude/claude.hooks.d.ts +23 -0
- package/dist/providers/claude/claude.hooks.js +94 -0
- package/dist/providers/claude/claude.otel.d.ts +95 -0
- package/dist/providers/claude/claude.otel.js +331 -0
- package/dist/providers/claude/claude.provider.d.ts +2 -0
- package/dist/providers/claude/claude.provider.js +26 -0
- package/dist/providers/claude/constants/claude.constants.d.ts +34 -0
- package/dist/providers/claude/constants/claude.constants.js +54 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +17 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +17 -0
- package/dist/providers/claude/schemas/claude.schema.d.ts +72 -0
- package/dist/providers/claude/schemas/claude.schema.js +32 -0
- package/dist/providers/claude/types/claude.types.d.ts +3 -0
- package/dist/providers/claude/types/claude.types.js +1 -0
- package/dist/providers/codex/codex.adapter.d.ts +11 -0
- package/dist/providers/codex/codex.adapter.js +106 -0
- package/dist/providers/codex/codex.detect.d.ts +30 -0
- package/dist/providers/codex/codex.detect.js +58 -0
- package/dist/providers/codex/codex.hooks.d.ts +27 -0
- package/dist/providers/codex/codex.hooks.js +129 -0
- package/dist/providers/codex/codex.otel.d.ts +51 -0
- package/dist/providers/codex/codex.otel.js +325 -0
- package/dist/providers/codex/codex.provider.d.ts +2 -0
- package/dist/providers/codex/codex.provider.js +25 -0
- package/dist/providers/codex/constants/codex.constants.d.ts +41 -0
- package/dist/providers/codex/constants/codex.constants.js +62 -0
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +22 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +22 -0
- package/dist/providers/codex/schemas/codex.schema.d.ts +70 -0
- package/dist/providers/codex/schemas/codex.schema.js +32 -0
- package/dist/providers/codex/types/codex.types.d.ts +3 -0
- package/dist/providers/codex/types/codex.types.js +1 -0
- package/dist/providers/constants/provider.constants.d.ts +33 -0
- package/dist/providers/constants/provider.constants.js +33 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +58 -0
- package/dist/providers/cursor/constants/cursor.constants.js +95 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +11 -0
- package/dist/providers/cursor/cursor.adapter.js +331 -0
- package/dist/providers/cursor/cursor.detect.d.ts +23 -0
- package/dist/providers/cursor/cursor.detect.js +66 -0
- package/dist/providers/cursor/cursor.hooks.d.ts +25 -0
- package/dist/providers/cursor/cursor.hooks.js +95 -0
- package/dist/providers/cursor/cursor.provider.d.ts +2 -0
- package/dist/providers/cursor/cursor.provider.js +27 -0
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +130 -0
- package/dist/providers/cursor/schemas/cursor.schema.js +62 -0
- package/dist/providers/cursor/types/cursor.types.d.ts +3 -0
- package/dist/providers/cursor/types/cursor.types.js +1 -0
- package/dist/providers/gemini/constants/gemini.constants.d.ts +36 -0
- package/dist/providers/gemini/constants/gemini.constants.js +58 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +34 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.js +48 -0
- package/dist/providers/gemini/gemini.adapter.d.ts +15 -0
- package/dist/providers/gemini/gemini.adapter.js +146 -0
- package/dist/providers/gemini/gemini.detect.d.ts +23 -0
- package/dist/providers/gemini/gemini.detect.js +78 -0
- package/dist/providers/gemini/gemini.hooks.d.ts +22 -0
- package/dist/providers/gemini/gemini.hooks.js +93 -0
- package/dist/providers/gemini/gemini.otel.d.ts +62 -0
- package/dist/providers/gemini/gemini.otel.js +274 -0
- package/dist/providers/gemini/gemini.provider.d.ts +2 -0
- package/dist/providers/gemini/gemini.provider.js +22 -0
- package/dist/providers/gemini/schemas/gemini.schema.d.ts +81 -0
- package/dist/providers/gemini/schemas/gemini.schema.js +35 -0
- package/dist/providers/gemini/types/gemini.types.d.ts +3 -0
- package/dist/providers/gemini/types/gemini.types.js +1 -0
- package/dist/providers/index.d.ts +14 -0
- package/dist/providers/index.js +8 -0
- package/dist/providers/provider.d.ts +16 -0
- package/dist/providers/provider.js +149 -0
- package/dist/providers/registry.d.ts +12 -0
- package/dist/providers/registry.js +23 -0
- package/dist/providers/shared/constants/hook-refusal.constants.d.ts +6 -0
- package/dist/providers/shared/constants/hook-refusal.constants.js +6 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +25 -0
- package/dist/providers/shared/constants/tooling.constants.js +25 -0
- package/dist/providers/shared/event-builder.d.ts +85 -0
- package/dist/providers/shared/event-builder.js +166 -0
- package/dist/providers/shared/hook-config.d.ts +80 -0
- package/dist/providers/shared/hook-config.js +164 -0
- package/dist/providers/shared/hook-refusal.d.ts +16 -0
- package/dist/providers/shared/hook-refusal.js +33 -0
- package/dist/providers/shared/install-record.d.ts +75 -0
- package/dist/providers/shared/install-record.js +113 -0
- package/dist/providers/shared/tooling.d.ts +58 -0
- package/dist/providers/shared/tooling.js +103 -0
- package/dist/providers/shared/types/adapter.types.d.ts +54 -0
- package/dist/providers/shared/types/adapter.types.js +1 -0
- package/dist/providers/shared/types/hook-config.types.d.ts +32 -0
- package/dist/providers/shared/types/hook-config.types.js +1 -0
- package/dist/providers/types/provider.types.d.ts +98 -0
- package/dist/providers/types/provider.types.js +1 -0
- package/dist/snapshot/branch-selection.d.ts +37 -0
- package/dist/snapshot/branch-selection.js +69 -0
- package/dist/snapshot/budget.d.ts +41 -0
- package/dist/snapshot/budget.js +67 -0
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +11 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +11 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +56 -0
- package/dist/snapshot/constants/snapshot.constants.js +56 -0
- package/dist/snapshot/index.d.ts +16 -0
- package/dist/snapshot/index.js +6 -0
- package/dist/snapshot/snapshot-event.d.ts +17 -0
- package/dist/snapshot/snapshot-event.js +66 -0
- package/dist/snapshot/snapshot-pipeline.d.ts +14 -0
- package/dist/snapshot/snapshot-pipeline.js +163 -0
- package/dist/snapshot/snapshot-state.d.ts +55 -0
- package/dist/snapshot/snapshot-state.js +100 -0
- package/dist/snapshot/types/snapshot.types.d.ts +86 -0
- package/dist/snapshot/types/snapshot.types.js +1 -0
- package/dist/storage/atomic-file.d.ts +25 -0
- package/dist/storage/atomic-file.js +76 -0
- package/dist/storage/constants/storage.constants.d.ts +34 -0
- package/dist/storage/constants/storage.constants.js +35 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.js +5 -0
- package/dist/storage/install-state.d.ts +20 -0
- package/dist/storage/install-state.js +40 -0
- package/dist/storage/json-file.d.ts +13 -0
- package/dist/storage/json-file.js +31 -0
- package/dist/storage/lock.d.ts +15 -0
- package/dist/storage/lock.js +70 -0
- package/dist/storage/paths.d.ts +14 -0
- package/dist/storage/paths.js +42 -0
- package/dist/storage/schemas/storage.schema.d.ts +128 -0
- package/dist/storage/schemas/storage.schema.js +27 -0
- package/dist/storage/types/storage.types.d.ts +36 -0
- package/dist/storage/types/storage.types.js +1 -0
- package/dist/transport/constants/transport.constants.d.ts +47 -0
- package/dist/transport/constants/transport.constants.js +47 -0
- package/dist/transport/cooldown.d.ts +35 -0
- package/dist/transport/cooldown.js +62 -0
- package/dist/transport/delivery-stats.d.ts +65 -0
- package/dist/transport/delivery-stats.js +186 -0
- package/dist/transport/delivery.d.ts +26 -0
- package/dist/transport/delivery.js +80 -0
- package/dist/transport/headers.d.ts +12 -0
- package/dist/transport/headers.js +19 -0
- package/dist/transport/http-transport.d.ts +39 -0
- package/dist/transport/http-transport.js +106 -0
- package/dist/transport/index.d.ts +13 -0
- package/dist/transport/index.js +7 -0
- package/dist/transport/queue.d.ts +177 -0
- package/dist/transport/queue.js +474 -0
- package/dist/transport/schemas/queue.schema.d.ts +30 -0
- package/dist/transport/schemas/queue.schema.js +18 -0
- package/dist/transport/transport.d.ts +6 -0
- package/dist/transport/transport.js +1 -0
- package/dist/transport/types/transport.types.d.ts +102 -0
- package/dist/transport/types/transport.types.js +1 -0
- package/dist/turns/aggregate-usage.d.ts +20 -0
- package/dist/turns/aggregate-usage.js +269 -0
- package/dist/turns/claude-transcript.d.ts +18 -0
- package/dist/turns/claude-transcript.js +80 -0
- package/dist/turns/constants/turns.constants.d.ts +69 -0
- package/dist/turns/constants/turns.constants.js +86 -0
- package/dist/turns/cursor-transcript.d.ts +21 -0
- package/dist/turns/cursor-transcript.js +66 -0
- package/dist/turns/index.d.ts +17 -0
- package/dist/turns/index.js +7 -0
- package/dist/turns/transcript.d.ts +74 -0
- package/dist/turns/transcript.js +188 -0
- package/dist/turns/turn-state.d.ts +94 -0
- package/dist/turns/turn-state.js +234 -0
- package/dist/turns/turn-summary.d.ts +27 -0
- package/dist/turns/turn-summary.js +164 -0
- package/dist/turns/turn-tracker.d.ts +14 -0
- package/dist/turns/turn-tracker.js +521 -0
- package/dist/turns/types/aggregate-usage.types.d.ts +26 -0
- package/dist/turns/types/aggregate-usage.types.js +1 -0
- package/dist/turns/types/transcript.types.d.ts +41 -0
- package/dist/turns/types/transcript.types.js +1 -0
- package/dist/turns/types/turn-state.types.d.ts +37 -0
- package/dist/turns/types/turn-state.types.js +1 -0
- package/dist/turns/types/turn-summary.types.d.ts +106 -0
- package/dist/turns/types/turn-summary.types.js +1 -0
- package/dist/turns/types/turn-tracker.types.d.ts +27 -0
- package/dist/turns/types/turn-tracker.types.js +1 -0
- package/example/README.md +43 -0
- package/example/server.mjs +240 -0
- package/package.json +89 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { sha256Hex } from '../../events/event-id.js';
|
|
2
|
+
import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
|
|
3
|
+
import { classifyTool, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
4
|
+
import { 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
|
+
import { antigravityPayloadSchema } from './schemas/antigravity.schema.js';
|
|
6
|
+
const ARGS_KEYS = Object.keys(ANTIGRAVITY_HOOK_EVENT_BY_ARGS);
|
|
7
|
+
/**
|
|
8
|
+
* Which hook this payload is.
|
|
9
|
+
*
|
|
10
|
+
* `HookArgs` carries no event-name field: the event is whichever member of its
|
|
11
|
+
* oneof is set. Anything that is not a recognizable `HookArgs` returns
|
|
12
|
+
* undefined, so a schema change shows up as no telemetry rather than as
|
|
13
|
+
* mis-attributed telemetry.
|
|
14
|
+
*
|
|
15
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
16
|
+
* @returns The hook name, or undefined.
|
|
17
|
+
*/
|
|
18
|
+
export function antigravityHookEvent(rawPayload) {
|
|
19
|
+
const parsed = antigravityPayloadSchema.safeParse(rawPayload);
|
|
20
|
+
if (!parsed.success)
|
|
21
|
+
return undefined;
|
|
22
|
+
const key = ARGS_KEYS.find((candidate) => parsed.data[candidate] !== undefined);
|
|
23
|
+
return key ? ANTIGRAVITY_HOOK_EVENT_BY_ARGS[key] : undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Working directory for git and repo-config lookups.
|
|
27
|
+
*
|
|
28
|
+
* Antigravity reports a workspace list rather than a single `cwd`; the first
|
|
29
|
+
* entry is the primary workspace root.
|
|
30
|
+
*
|
|
31
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
32
|
+
* @returns The primary workspace path, or undefined.
|
|
33
|
+
*/
|
|
34
|
+
export function antigravityCwd(rawPayload) {
|
|
35
|
+
const parsed = antigravityPayloadSchema.safeParse(rawPayload);
|
|
36
|
+
if (!parsed.success)
|
|
37
|
+
return undefined;
|
|
38
|
+
return parsed.data.common?.workspacePaths?.[0];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Translate one Antigravity hook payload into canonical events.
|
|
42
|
+
*
|
|
43
|
+
* The two-level execution model matters for attribution: an *execution* is one
|
|
44
|
+
* agent run — the turn — and PreInvocation/PostInvocation bracket the individual
|
|
45
|
+
* model calls inside it. Treating an invocation as a turn boundary would emit
|
|
46
|
+
* one turn summary per model call and inflate every per-turn aggregate, so only
|
|
47
|
+
* `Stop` closes a turn here.
|
|
48
|
+
*
|
|
49
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
50
|
+
* @param context - Environment and effective config.
|
|
51
|
+
* @returns The canonical events, or an empty list for an unusable payload.
|
|
52
|
+
*/
|
|
53
|
+
export function parseAntigravityHookEvent(rawPayload, context) {
|
|
54
|
+
const parsed = antigravityPayloadSchema.safeParse(rawPayload);
|
|
55
|
+
if (!parsed.success)
|
|
56
|
+
return [];
|
|
57
|
+
const payload = parsed.data;
|
|
58
|
+
const hook = antigravityHookEvent(rawPayload);
|
|
59
|
+
if (!hook)
|
|
60
|
+
return [];
|
|
61
|
+
return [withPatch(antigravityBaseEvent(payload, hook), hookPatch(payload, hook, context))];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The model id behind Antigravity's display name.
|
|
65
|
+
*
|
|
66
|
+
* Exported for the same reason it exists: `Claude Opus 4.6 (Thinking)` is not a
|
|
67
|
+
* model any price list, any other provider's records, or any group-by-model
|
|
68
|
+
* report can match, and the turn it describes is the only place the name
|
|
69
|
+
* appears. This translates the picker's label into the id every other agent
|
|
70
|
+
* reports — and leaves an id that already looks like one untouched, so it is
|
|
71
|
+
* safe to apply to whatever the payload happens to carry.
|
|
72
|
+
*
|
|
73
|
+
* @param displayName - `common.modelName`, as Antigravity wrote it.
|
|
74
|
+
* @returns The canonical id, or undefined when no model was named.
|
|
75
|
+
*/
|
|
76
|
+
export function canonicalModelName(displayName) {
|
|
77
|
+
if (!displayName)
|
|
78
|
+
return undefined;
|
|
79
|
+
const hyphenated = displayName
|
|
80
|
+
.toLowerCase()
|
|
81
|
+
.replace(RE_MODEL_QUALIFIER, '')
|
|
82
|
+
.trim()
|
|
83
|
+
.replace(RE_MODEL_WHITESPACE, '-');
|
|
84
|
+
if (!hyphenated)
|
|
85
|
+
return undefined;
|
|
86
|
+
if (!hyphenated.startsWith(DOTLESS_MODEL_FAMILY))
|
|
87
|
+
return hyphenated;
|
|
88
|
+
return hyphenated.replace(RE_MODEL_VERSION_DOT, '-');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The provider-independent part of the event.
|
|
92
|
+
*
|
|
93
|
+
* @param payload - Parsed hook payload.
|
|
94
|
+
* @param hook - Which hook fired.
|
|
95
|
+
* @returns The base event.
|
|
96
|
+
*/
|
|
97
|
+
function antigravityBaseEvent(payload, hook) {
|
|
98
|
+
const common = payload.common;
|
|
99
|
+
const stepIdx = stepIdxOf(payload, hook);
|
|
100
|
+
const model = canonicalModelName(common?.modelName);
|
|
101
|
+
return baseEvent({
|
|
102
|
+
provider: ANTIGRAVITY_PROVIDER_ID,
|
|
103
|
+
displayName: ANTIGRAVITY_DISPLAY_NAME,
|
|
104
|
+
providerEventType: hook,
|
|
105
|
+
eventType: canonicalType(payload, hook),
|
|
106
|
+
sessionId: common?.conversationId,
|
|
107
|
+
// An execution is the turn: `StopHookArgs.executionNum` numbers executions
|
|
108
|
+
// within a conversation, and Stop fires once per execution.
|
|
109
|
+
turnId: common?.executionId,
|
|
110
|
+
toolUseId: stepIdx,
|
|
111
|
+
payloadFingerprint: sha256Hex(JSON.stringify(fingerprintParts(payload, hook))),
|
|
112
|
+
ai: model ? { model, billingMode: 'unknown' } : undefined,
|
|
113
|
+
providerMetadata: {
|
|
114
|
+
// The picker's own wording, kept beside the id it was translated into: it
|
|
115
|
+
// carries the thinking/effort selection, which the id does not.
|
|
116
|
+
modelDisplayName: common?.modelName,
|
|
117
|
+
transcriptPath: common?.transcriptPath,
|
|
118
|
+
artifactDirectoryPath: common?.artifactDirectoryPath,
|
|
119
|
+
stepIdx,
|
|
120
|
+
isBattleMode: common?.isBattleMode,
|
|
121
|
+
terminationReason: payload.stopHookArgs?.terminationReason,
|
|
122
|
+
fullyIdle: payload.stopHookArgs?.fullyIdle
|
|
123
|
+
},
|
|
124
|
+
timestamp: new Date().toISOString()
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* What this particular hook contributes on top of the base event.
|
|
129
|
+
*
|
|
130
|
+
* @param payload - Parsed hook payload.
|
|
131
|
+
* @param hook - Which hook fired.
|
|
132
|
+
* @param context - Environment and effective config.
|
|
133
|
+
* @returns The patch; empty for a hook we model but read nothing from.
|
|
134
|
+
*/
|
|
135
|
+
function hookPatch(payload, hook, context) {
|
|
136
|
+
if (hook === 'PreInvocation') {
|
|
137
|
+
// Antigravity has no "user prompt submitted" hook: the prompt is carried on
|
|
138
|
+
// `common.lastUserInput` by every hook of the execution. The first
|
|
139
|
+
// invocation is therefore where the turn's prompt is recorded; later
|
|
140
|
+
// invocations are model calls inside the same turn.
|
|
141
|
+
if (!isFirstInvocation(payload.preInvocationHookArgs?.invocationNum))
|
|
142
|
+
return {};
|
|
143
|
+
return promptPatch(payload.common?.lastUserInput ?? '', context.config.capture);
|
|
144
|
+
}
|
|
145
|
+
if (hook === 'PostInvocation') {
|
|
146
|
+
return { metadata: { invocationNum: numeric(payload.postInvocationHookArgs?.invocationNum) } };
|
|
147
|
+
}
|
|
148
|
+
if (hook === 'PreToolUse' || hook === 'PostToolUse')
|
|
149
|
+
return antigravityToolPatch(payload, hook, context);
|
|
150
|
+
if (hook === 'Stop')
|
|
151
|
+
return responsePatch(payload.stopHookArgs?.finalModelOutput ?? '', context.config.capture);
|
|
152
|
+
return {};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Tool fields for one of Antigravity's two tool hooks.
|
|
156
|
+
*
|
|
157
|
+
* @param payload - Parsed hook payload.
|
|
158
|
+
* @param hook - Which of the two fired.
|
|
159
|
+
* @param context - Environment and effective config.
|
|
160
|
+
* @returns The patch.
|
|
161
|
+
*/
|
|
162
|
+
function antigravityToolPatch(payload, hook, context) {
|
|
163
|
+
const toolCall = toolCallOf(payload, hook);
|
|
164
|
+
const kind = classifyTool(toolCall?.name);
|
|
165
|
+
const failed = hook === 'PostToolUse' && payload.postToolHookArgs?.error !== undefined;
|
|
166
|
+
const mcp = kind === 'mcp' && toolCall?.name ? parseMcpToolName(toolCall.name) : undefined;
|
|
167
|
+
return toolPatch({
|
|
168
|
+
name: toolCall?.name,
|
|
169
|
+
status: toolStatus(hook, failed),
|
|
170
|
+
kind,
|
|
171
|
+
input: toolCall?.args,
|
|
172
|
+
output: hook === 'PostToolUse' ? payload.postToolHookArgs?.result : undefined,
|
|
173
|
+
error: failed ? payload.postToolHookArgs?.error : undefined,
|
|
174
|
+
providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : undefined
|
|
175
|
+
}, context.config.capture);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Whether a tool hook reports a start, a failure, or a completion.
|
|
179
|
+
*
|
|
180
|
+
* @param hook - Which of the two tool hooks fired.
|
|
181
|
+
* @param failed - Whether the post-tool payload carried an error.
|
|
182
|
+
* @returns The tool status.
|
|
183
|
+
*/
|
|
184
|
+
function toolStatus(hook, failed) {
|
|
185
|
+
if (hook === 'PreToolUse')
|
|
186
|
+
return 'started';
|
|
187
|
+
return failed ? 'failed' : 'completed';
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Canonical type for a hook.
|
|
191
|
+
*
|
|
192
|
+
* @param payload - Parsed hook payload.
|
|
193
|
+
* @param hook - Which hook fired.
|
|
194
|
+
* @returns The canonical event type.
|
|
195
|
+
*/
|
|
196
|
+
function canonicalType(payload, hook) {
|
|
197
|
+
if (hook === 'SessionStart')
|
|
198
|
+
return 'session.started';
|
|
199
|
+
if (hook === 'Stop')
|
|
200
|
+
return 'generation.completed';
|
|
201
|
+
if (hook === 'PreInvocation') {
|
|
202
|
+
return isFirstInvocation(payload.preInvocationHookArgs?.invocationNum) ? 'prompt.submitted' : 'agent.other';
|
|
203
|
+
}
|
|
204
|
+
if (hook === 'PostInvocation')
|
|
205
|
+
return 'agent.other';
|
|
206
|
+
if (hook === 'PreToolUse')
|
|
207
|
+
return toolStartType(classifyTool(payload.preToolHookArgs?.toolCall?.name));
|
|
208
|
+
if (payload.postToolHookArgs?.error !== undefined)
|
|
209
|
+
return 'tool.failed';
|
|
210
|
+
return toolCompleteType(classifyTool(payload.postToolHookArgs?.toolCall?.name));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Whether an invocation counter names the execution's first model call.
|
|
214
|
+
*
|
|
215
|
+
* The counter's base is not documented, so both 0 and 1 are treated as first. A
|
|
216
|
+
* repeat is harmless: the prompt record is keyed by the event id, which is
|
|
217
|
+
* stable for one execution and one prompt.
|
|
218
|
+
*
|
|
219
|
+
* @param invocationNum - The reported counter, in either proto3 JSON encoding.
|
|
220
|
+
* @returns True when this is the first invocation.
|
|
221
|
+
*/
|
|
222
|
+
function isFirstInvocation(invocationNum) {
|
|
223
|
+
const value = numeric(invocationNum);
|
|
224
|
+
return value === undefined || value <= 1;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The tool call one of the tool hooks carries.
|
|
228
|
+
*
|
|
229
|
+
* @param payload - Parsed hook payload.
|
|
230
|
+
* @param hook - Which hook fired.
|
|
231
|
+
* @returns The call, or undefined for a non-tool hook.
|
|
232
|
+
*/
|
|
233
|
+
function toolCallOf(payload, hook) {
|
|
234
|
+
if (hook === 'PreToolUse')
|
|
235
|
+
return payload.preToolHookArgs?.toolCall;
|
|
236
|
+
if (hook === 'PostToolUse')
|
|
237
|
+
return payload.postToolHookArgs?.toolCall;
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The step index of a tool hook, as a string id.
|
|
242
|
+
*
|
|
243
|
+
* @param payload - Parsed hook payload.
|
|
244
|
+
* @param hook - Which hook fired.
|
|
245
|
+
* @returns The index, or undefined for a non-tool hook.
|
|
246
|
+
*/
|
|
247
|
+
function stepIdxOf(payload, hook) {
|
|
248
|
+
const value = numeric(rawStepIdx(payload, hook));
|
|
249
|
+
return value === undefined ? undefined : String(value);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The step index as the payload encodes it.
|
|
253
|
+
*
|
|
254
|
+
* @param payload - Parsed hook payload.
|
|
255
|
+
* @param hook - Which hook fired.
|
|
256
|
+
* @returns The raw value, or undefined for a non-tool hook.
|
|
257
|
+
*/
|
|
258
|
+
function rawStepIdx(payload, hook) {
|
|
259
|
+
if (hook === 'PreToolUse')
|
|
260
|
+
return payload.preToolHookArgs?.stepIdx;
|
|
261
|
+
if (hook === 'PostToolUse')
|
|
262
|
+
return payload.postToolHookArgs?.stepIdx;
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* What makes this event distinct from its siblings in the same turn.
|
|
267
|
+
*
|
|
268
|
+
* A prompt is identified by its text and nothing else: the invocation counter's
|
|
269
|
+
* base is undocumented, so the first-invocation test admits both 0 and 1, and
|
|
270
|
+
* including the counter here would give the same prompt two ids and append it to
|
|
271
|
+
* the turn twice. Every other event stays keyed by its own counter, which is
|
|
272
|
+
* what keeps successive invocations and tool calls apart.
|
|
273
|
+
*
|
|
274
|
+
* @param payload - Parsed hook payload.
|
|
275
|
+
* @param hook - Which hook fired.
|
|
276
|
+
* @returns The parts to hash.
|
|
277
|
+
*/
|
|
278
|
+
function fingerprintParts(payload, hook) {
|
|
279
|
+
if (hook === 'PreInvocation' && isFirstInvocation(payload.preInvocationHookArgs?.invocationNum)) {
|
|
280
|
+
return ['prompt', payload.common?.lastUserInput ?? ''];
|
|
281
|
+
}
|
|
282
|
+
return [payload.common?.modelName, toolCallOf(payload, hook)?.name, invocationOf(payload, hook)];
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The invocation counter of an invocation hook.
|
|
286
|
+
*
|
|
287
|
+
* @param payload - Parsed hook payload.
|
|
288
|
+
* @param hook - Which hook fired.
|
|
289
|
+
* @returns The counter, or undefined for other hooks.
|
|
290
|
+
*/
|
|
291
|
+
function invocationOf(payload, hook) {
|
|
292
|
+
if (hook === 'PreInvocation')
|
|
293
|
+
return numeric(payload.preInvocationHookArgs?.invocationNum);
|
|
294
|
+
if (hook === 'PostInvocation')
|
|
295
|
+
return numeric(payload.postInvocationHookArgs?.invocationNum);
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* A proto3 JSON integer as a number, whichever encoding it arrived in.
|
|
300
|
+
*
|
|
301
|
+
* @param value - A number or its string form.
|
|
302
|
+
* @returns The finite number, or undefined.
|
|
303
|
+
*/
|
|
304
|
+
function numeric(value) {
|
|
305
|
+
if (typeof value === 'number')
|
|
306
|
+
return Number.isFinite(value) ? value : undefined;
|
|
307
|
+
if (typeof value !== 'string' || value.trim() === '')
|
|
308
|
+
return undefined;
|
|
309
|
+
const parsed = Number(value);
|
|
310
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
311
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Env } from '../../core/types/core.types.js';
|
|
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
|
+
/**
|
|
13
|
+
* Where Antigravity reads named hook groups from.
|
|
14
|
+
*
|
|
15
|
+
* @param env - Environment supplying HOME.
|
|
16
|
+
* @returns Absolute path of `hooks.json`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function antigravityHooksPath(env: Env): string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether Antigravity is installed here, and whether our hooks are registered.
|
|
21
|
+
*
|
|
22
|
+
* @param env - Environment supplying HOME and PATH.
|
|
23
|
+
* @returns What was found.
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectAntigravity(env: Env): Promise<DetectionResult>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { findExecutable } from '../../core/which.js';
|
|
4
|
+
import { readJsonFile } from '../../storage/json-file.js';
|
|
5
|
+
import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
|
|
6
|
+
import { ANTIGRAVITY_CLI_DIR_SEGMENTS, ANTIGRAVITY_EXECUTABLES, ANTIGRAVITY_HOOKS_FILE, ANTIGRAVITY_ROOT_SEGMENTS } from './constants/antigravity.constants.js';
|
|
7
|
+
/**
|
|
8
|
+
* Antigravity's configuration root.
|
|
9
|
+
*
|
|
10
|
+
* It shares Gemini's home directory: `~/.gemini/config`.
|
|
11
|
+
*
|
|
12
|
+
* @param env - Environment supplying HOME.
|
|
13
|
+
* @returns Absolute path of the config root.
|
|
14
|
+
*/
|
|
15
|
+
export function antigravityRoot(env) {
|
|
16
|
+
return path.join(env.home, ...ANTIGRAVITY_ROOT_SEGMENTS);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Where Antigravity reads named hook groups from.
|
|
20
|
+
*
|
|
21
|
+
* @param env - Environment supplying HOME.
|
|
22
|
+
* @returns Absolute path of `hooks.json`.
|
|
23
|
+
*/
|
|
24
|
+
export function antigravityHooksPath(env) {
|
|
25
|
+
return path.join(antigravityRoot(env), ANTIGRAVITY_HOOKS_FILE);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether Antigravity is installed here, and whether our hooks are registered.
|
|
29
|
+
*
|
|
30
|
+
* @param env - Environment supplying HOME and PATH.
|
|
31
|
+
* @returns What was found.
|
|
32
|
+
*/
|
|
33
|
+
export async function detectAntigravity(env) {
|
|
34
|
+
const evidence = [];
|
|
35
|
+
if (fs.existsSync(path.join(env.home, ...ANTIGRAVITY_CLI_DIR_SEGMENTS))) {
|
|
36
|
+
evidence.push('~/.gemini/antigravity-cli directory exists');
|
|
37
|
+
}
|
|
38
|
+
const executablePath = findFirstExecutable(env);
|
|
39
|
+
if (executablePath)
|
|
40
|
+
evidence.push(`agy executable on PATH (${executablePath})`);
|
|
41
|
+
const hookConfigPath = antigravityHooksPath(env);
|
|
42
|
+
const read = await readJsonFile(hookConfigPath);
|
|
43
|
+
return {
|
|
44
|
+
detected: evidence.length > 0,
|
|
45
|
+
evidence,
|
|
46
|
+
executablePath,
|
|
47
|
+
hookConfigPath,
|
|
48
|
+
hooksInstalled: read.state === 'ok' && JSON.stringify(read.value).includes(HOOK_COMMAND_MARKER)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The first of Antigravity's executable names found on PATH.
|
|
53
|
+
*
|
|
54
|
+
* @param env - Environment supplying PATH.
|
|
55
|
+
* @returns The path, or undefined when neither is installed.
|
|
56
|
+
*/
|
|
57
|
+
function findFirstExecutable(env) {
|
|
58
|
+
for (const name of ANTIGRAVITY_EXECUTABLES) {
|
|
59
|
+
const found = findExecutable(env, name);
|
|
60
|
+
if (found)
|
|
61
|
+
return found;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SetupContext, SetupOutcome } from '../types/provider.types.js';
|
|
2
|
+
export { ANTIGRAVITY_HOOK_EVENTS } from './constants/antigravity.constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Register AgentWatch's hooks in `~/.gemini/config/hooks.json`.
|
|
5
|
+
*
|
|
6
|
+
* The file is a map of *named* groups, so AgentWatch owns exactly one top-level
|
|
7
|
+
* key and never touches another tool's group.
|
|
8
|
+
*
|
|
9
|
+
* @param context - Environment, paths, config and the hook command to write.
|
|
10
|
+
* @returns Whether the file changed, what to tell the user, and the next
|
|
11
|
+
* install state.
|
|
12
|
+
*/
|
|
13
|
+
export declare function installAntigravityHooks(context: SetupContext): Promise<SetupOutcome>;
|
|
14
|
+
/**
|
|
15
|
+
* Remove AgentWatch's hooks from `~/.gemini/config/hooks.json`.
|
|
16
|
+
*
|
|
17
|
+
* Our own group goes wholesale; a group somebody else owns is only filtered, in
|
|
18
|
+
* case an AgentWatch command was hand-added to it.
|
|
19
|
+
*
|
|
20
|
+
* @param context - Environment, paths and current install state.
|
|
21
|
+
* @returns Whether the file changed, what to tell the user, and the next
|
|
22
|
+
* install state.
|
|
23
|
+
*/
|
|
24
|
+
export declare function uninstallAntigravityHooks(context: SetupContext): Promise<SetupOutcome>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { asRecord, omitKeys } from '../../core/object.js';
|
|
2
|
+
import { backupFile } from '../../storage/atomic-file.js';
|
|
3
|
+
import { readJsonFile } from '../../storage/json-file.js';
|
|
4
|
+
import { registerOurHandlers, stripOurHandlers, sweepUnregisteredEvents, writeJsonValidated } from '../shared/hook-config.js';
|
|
5
|
+
import { withHookInstall, withoutAgent } from '../shared/install-record.js';
|
|
6
|
+
import { antigravityHooksPath } from './antigravity.detect.js';
|
|
7
|
+
import { ANTIGRAVITY_GROUP_NAME, ANTIGRAVITY_HOOK_EVENTS, ANTIGRAVITY_HOOK_TIMEOUT_MILLISECONDS, ANTIGRAVITY_MATCHED_EVENTS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
|
|
8
|
+
export { ANTIGRAVITY_HOOK_EVENTS } from './constants/antigravity.constants.js';
|
|
9
|
+
/** Antigravity accepts a bare handler as well as a matcher group. */
|
|
10
|
+
const STRIP_OPTIONS = { allowBareHandlers: true };
|
|
11
|
+
/**
|
|
12
|
+
* Register AgentWatch's hooks in `~/.gemini/config/hooks.json`.
|
|
13
|
+
*
|
|
14
|
+
* The file is a map of *named* groups, so AgentWatch owns exactly one top-level
|
|
15
|
+
* key and never touches another tool's group.
|
|
16
|
+
*
|
|
17
|
+
* @param context - Environment, paths, config and the hook command to write.
|
|
18
|
+
* @returns Whether the file changed, what to tell the user, and the next
|
|
19
|
+
* install state.
|
|
20
|
+
*/
|
|
21
|
+
export async function installAntigravityHooks(context) {
|
|
22
|
+
const target = antigravityHooksPath(context.env);
|
|
23
|
+
const read = await readJsonFile(target);
|
|
24
|
+
if (read.state === 'invalid') {
|
|
25
|
+
return { ok: false, changed: false, messages: [`refusing to modify unparseable ${target} (${read.error})`] };
|
|
26
|
+
}
|
|
27
|
+
if (read.state === 'ok' && !asRecord(read.value)) {
|
|
28
|
+
return { ok: false, changed: false, messages: [`refusing to modify ${target}: top level is not an object`] };
|
|
29
|
+
}
|
|
30
|
+
const file = (read.state === 'ok' ? asRecord(read.value) : undefined) ?? {};
|
|
31
|
+
const group = asRecord(file[ANTIGRAVITY_GROUP_NAME]) ?? {};
|
|
32
|
+
const registered = registerOurHandlers(group, ANTIGRAVITY_HOOK_EVENTS, hookEntryFor(context.hookCommand), STRIP_OPTIONS);
|
|
33
|
+
const nextFile = {
|
|
34
|
+
...file,
|
|
35
|
+
[ANTIGRAVITY_GROUP_NAME]: sweepUnregisteredEvents(registered, ANTIGRAVITY_HOOK_EVENTS, STRIP_OPTIONS)
|
|
36
|
+
};
|
|
37
|
+
const changed = JSON.stringify(nextFile) !== JSON.stringify(file);
|
|
38
|
+
if (changed) {
|
|
39
|
+
await backupFile(target, context.paths.backupsDir, context.env.now());
|
|
40
|
+
await writeJsonValidated(target, nextFile);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
ok: true,
|
|
44
|
+
changed,
|
|
45
|
+
messages: [
|
|
46
|
+
changed ? `hooks registered in ${target}` : 'hooks already registered',
|
|
47
|
+
...(changed ? ['restart running Antigravity sessions to pick them up'] : [])
|
|
48
|
+
],
|
|
49
|
+
installState: withHookInstall(context.installState, ANTIGRAVITY_PROVIDER_ID, {
|
|
50
|
+
hookConfigPath: target,
|
|
51
|
+
hookEvents: ANTIGRAVITY_HOOK_EVENTS,
|
|
52
|
+
hookCommand: context.hookCommand,
|
|
53
|
+
installedAt: context.env.now()
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Remove AgentWatch's hooks from `~/.gemini/config/hooks.json`.
|
|
59
|
+
*
|
|
60
|
+
* Our own group goes wholesale; a group somebody else owns is only filtered, in
|
|
61
|
+
* case an AgentWatch command was hand-added to it.
|
|
62
|
+
*
|
|
63
|
+
* @param context - Environment, paths and current install state.
|
|
64
|
+
* @returns Whether the file changed, what to tell the user, and the next
|
|
65
|
+
* install state.
|
|
66
|
+
*/
|
|
67
|
+
export async function uninstallAntigravityHooks(context) {
|
|
68
|
+
const target = antigravityHooksPath(context.env);
|
|
69
|
+
const read = await readJsonFile(target);
|
|
70
|
+
const forgotten = withoutAgent(context.installState, ANTIGRAVITY_PROVIDER_ID);
|
|
71
|
+
if (read.state === 'missing') {
|
|
72
|
+
return { ok: true, changed: false, messages: ['no Antigravity hooks file'], installState: forgotten };
|
|
73
|
+
}
|
|
74
|
+
if (read.state === 'invalid') {
|
|
75
|
+
return { ok: false, changed: false, messages: [`refusing to modify unparseable ${target} (${read.error})`] };
|
|
76
|
+
}
|
|
77
|
+
const file = asRecord(read.value);
|
|
78
|
+
if (!file) {
|
|
79
|
+
return { ok: false, changed: false, messages: [`refusing to modify ${target}: top level is not an object`] };
|
|
80
|
+
}
|
|
81
|
+
const nextFile = strippedGroups(file);
|
|
82
|
+
const changed = JSON.stringify(nextFile) !== JSON.stringify(file);
|
|
83
|
+
if (changed) {
|
|
84
|
+
await backupFile(target, context.paths.backupsDir, context.env.now());
|
|
85
|
+
await writeJsonValidated(target, nextFile);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
ok: true,
|
|
89
|
+
changed,
|
|
90
|
+
messages: [changed ? 'AgentWatch hooks removed' : 'no AgentWatch hooks found'],
|
|
91
|
+
installState: forgotten
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every group with our handlers removed, and emptied groups dropped.
|
|
96
|
+
*
|
|
97
|
+
* @param file - The whole hooks file.
|
|
98
|
+
* @returns The next file contents.
|
|
99
|
+
*/
|
|
100
|
+
function strippedGroups(file) {
|
|
101
|
+
const emptied = new Set();
|
|
102
|
+
const next = { ...file };
|
|
103
|
+
for (const [name, value] of Object.entries(file)) {
|
|
104
|
+
const group = asRecord(value);
|
|
105
|
+
if (!group)
|
|
106
|
+
continue;
|
|
107
|
+
const stripped = stripOurHandlers(group, STRIP_OPTIONS).hooks;
|
|
108
|
+
if (Object.keys(stripped).length === 0) {
|
|
109
|
+
emptied.add(name);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
next[name] = stripped;
|
|
113
|
+
}
|
|
114
|
+
return omitKeys(next, emptied);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Our entry for one event: a matcher group for tool events, a bare handler
|
|
118
|
+
* otherwise — both shapes Antigravity accepts.
|
|
119
|
+
*
|
|
120
|
+
* @param hookCommand - Command line agents will invoke.
|
|
121
|
+
* @returns A factory producing the entry for a given event name.
|
|
122
|
+
*/
|
|
123
|
+
function hookEntryFor(hookCommand) {
|
|
124
|
+
const handler = { type: 'command', command: hookCommand, timeout: ANTIGRAVITY_HOOK_TIMEOUT_MILLISECONDS };
|
|
125
|
+
return (eventName) => (ANTIGRAVITY_MATCHED_EVENTS.has(eventName) ? { matcher: '*', hooks: [handler] } : handler);
|
|
126
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { antigravityCwd, antigravityHookEvent, parseAntigravityHookEvent } from './antigravity.adapter.js';
|
|
2
|
+
import { detectAntigravity } from './antigravity.detect.js';
|
|
3
|
+
import { installAntigravityHooks, uninstallAntigravityHooks } from './antigravity.hooks.js';
|
|
4
|
+
import { ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_FALLBACK_DECISION, ANTIGRAVITY_HOOK_DECISIONS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
|
|
5
|
+
export const antigravityProvider = {
|
|
6
|
+
id: ANTIGRAVITY_PROVIDER_ID,
|
|
7
|
+
displayName: ANTIGRAVITY_DISPLAY_NAME,
|
|
8
|
+
detect: detectAntigravity,
|
|
9
|
+
installHooks: installAntigravityHooks,
|
|
10
|
+
uninstallHooks: uninstallAntigravityHooks,
|
|
11
|
+
parseHookEvent: async (payload, context) => parseAntigravityHookEvent(payload, context),
|
|
12
|
+
getHookResponse: (payload) => {
|
|
13
|
+
const hook = antigravityHookEvent(payload);
|
|
14
|
+
const decision = hook === undefined ? ANTIGRAVITY_FALLBACK_DECISION : ANTIGRAVITY_HOOK_DECISIONS[hook];
|
|
15
|
+
return { stdout: JSON.stringify(decision ?? {}), exitCode: 0 };
|
|
16
|
+
},
|
|
17
|
+
resolveCwd: antigravityCwd
|
|
18
|
+
// No nativeTelemetry: Antigravity exposes no OTLP exporter configuration, so
|
|
19
|
+
// there is no llm.call ledger source and turn summaries stay
|
|
20
|
+
// usage_status=pending. Adding a configurator would claim a capability the
|
|
21
|
+
// agent does not have.
|
|
22
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare const ANTIGRAVITY_PROVIDER_ID = "antigravity";
|
|
2
|
+
export declare const ANTIGRAVITY_DISPLAY_NAME = "Google Antigravity";
|
|
3
|
+
/** Antigravity shares Gemini's home; its own config lives one level down. */
|
|
4
|
+
export declare const ANTIGRAVITY_ROOT_SEGMENTS: readonly [".gemini", "config"];
|
|
5
|
+
export declare const ANTIGRAVITY_CLI_DIR_SEGMENTS: readonly [".gemini", "antigravity-cli"];
|
|
6
|
+
export declare const ANTIGRAVITY_HOOKS_FILE = "hooks.json";
|
|
7
|
+
export declare const ANTIGRAVITY_EXECUTABLES: readonly ["agy", "antigravity"];
|
|
8
|
+
/**
|
|
9
|
+
* Antigravity reads `~/.gemini/config/hooks.json` as a map of *named* hook
|
|
10
|
+
* groups — its log line is "loaded N named hooks from N hooks.json file(s)" — so
|
|
11
|
+
* AgentWatch owns exactly one top-level key and never touches another tool's
|
|
12
|
+
* group.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ANTIGRAVITY_GROUP_NAME = "agentwatch";
|
|
15
|
+
export declare const ANTIGRAVITY_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PreInvocation", "PostInvocation", "Stop"];
|
|
16
|
+
/** Tool-scoped events take a matcher; the rest are plain handler lists. */
|
|
17
|
+
export declare const ANTIGRAVITY_MATCHED_EVENTS: ReadonlySet<string>;
|
|
18
|
+
/**
|
|
19
|
+
* `HookHandlerConfig.timeout` carries no unit suffix, and Gemini CLI — the same
|
|
20
|
+
* Google hook runner — reads the field as milliseconds with a 60,000 default. A
|
|
21
|
+
* bare `30` there timed every AgentWatch hook out before node could start; see
|
|
22
|
+
* the identical constant in gemini.constants.ts. Milliseconds is also the safe
|
|
23
|
+
* reading of the two: an over-large upper bound costs nothing, because the hook
|
|
24
|
+
* exits in well under a second either way.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ANTIGRAVITY_HOOK_TIMEOUT_MILLISECONDS = 30000;
|
|
27
|
+
/**
|
|
28
|
+
* The decision each hook result must carry.
|
|
29
|
+
*
|
|
30
|
+
* `decision` is a required field of both `PreToolHookResult` and
|
|
31
|
+
* `StopHookResult`, and Antigravity has a dedicated `PreToolHookDeniedError`
|
|
32
|
+
* for a pre-tool hook that does not answer. A single `{}` for every hook — the
|
|
33
|
+
* previous behavior — therefore did not merely fail to observe: it blocked every
|
|
34
|
+
* tool call the agent tried to make. The remaining result messages
|
|
35
|
+
* (`PostToolHookResult`, the invocation hooks, `SessionStartHookResult`) carry
|
|
36
|
+
* no decision, so silence is correct for those.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ANTIGRAVITY_HOOK_DECISIONS: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
39
|
+
/**
|
|
40
|
+
* Answer used for a payload we cannot classify at all.
|
|
41
|
+
*
|
|
42
|
+
* A pre-tool allow: the one payload shape we cannot read is also the one where
|
|
43
|
+
* staying silent would stall the agent, and telemetry must never do that.
|
|
44
|
+
*/
|
|
45
|
+
export declare const ANTIGRAVITY_FALLBACK_DECISION: Readonly<Record<string, string>>;
|
|
46
|
+
/**
|
|
47
|
+
* Antigravity names its model the way its picker shows it — `Claude Opus 4.6
|
|
48
|
+
* (Thinking)`, `Gemini 3 Pro (High)` — not the way an API does. Every other
|
|
49
|
+
* agent reports a model *id*, so a display name reaches the backend as a model
|
|
50
|
+
* nobody has a price for and as a second name for a model the ledger already
|
|
51
|
+
* knows under its id. The patterns below turn one into the other.
|
|
52
|
+
*/
|
|
53
|
+
/** Trailing selector the picker appends: `(Thinking)`, `(High)`, `(Fast)`. */
|
|
54
|
+
export declare const RE_MODEL_QUALIFIER: RegExp;
|
|
55
|
+
/** Any run of whitespace, which in an id is a single hyphen. */
|
|
56
|
+
export declare const RE_MODEL_WHITESPACE: RegExp;
|
|
57
|
+
/**
|
|
58
|
+
* Anthropic writes a version as `claude-opus-4-6`; Google and OpenAI keep the
|
|
59
|
+
* dot (`gemini-3.1-pro`, `gpt-5.2`). Converting dots for everyone would invent
|
|
60
|
+
* `gemini-3-1-pro`, which matches no price and no other row in the ledger.
|
|
61
|
+
*/
|
|
62
|
+
export declare const RE_MODEL_VERSION_DOT: RegExp;
|
|
63
|
+
export declare const DOTLESS_MODEL_FAMILY = "claude";
|
|
64
|
+
/** oneof member of `HookArgs` -> the hook Antigravity fired, in hooks.json naming. */
|
|
65
|
+
export declare const ANTIGRAVITY_HOOK_EVENT_BY_ARGS: {
|
|
66
|
+
readonly preToolHookArgs: "PreToolUse";
|
|
67
|
+
readonly postToolHookArgs: "PostToolUse";
|
|
68
|
+
readonly preInvocationHookArgs: "PreInvocation";
|
|
69
|
+
readonly postInvocationHookArgs: "PostInvocation";
|
|
70
|
+
readonly stopHookArgs: "Stop";
|
|
71
|
+
readonly sessionStartHookArgs: "SessionStart";
|
|
72
|
+
};
|