@agent-watch-ai/edge 0.5.0 → 0.7.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 +238 -7
- package/README.md +308 -8
- package/dist/billing/billing-mode.d.ts +37 -5
- package/dist/billing/billing-mode.js +28 -19
- package/dist/billing/constants/billing.constants.d.ts +0 -2
- package/dist/billing/constants/billing.constants.js +0 -2
- package/dist/billing/index.d.ts +2 -1
- package/dist/billing/index.js +1 -1
- package/dist/billing/session-billing.d.ts +3 -2
- package/dist/billing/session-billing.js +8 -8
- package/dist/billing/types/billing.types.d.ts +7 -0
- package/dist/capture/capture-env.d.ts +147 -0
- package/dist/capture/capture-env.js +301 -0
- package/dist/capture/captured-step.d.ts +88 -0
- package/dist/capture/captured-step.js +479 -0
- package/dist/capture/constants/capture.constants.d.ts +70 -0
- package/dist/capture/constants/capture.constants.js +72 -0
- package/dist/capture/launched-runs.d.ts +16 -0
- package/dist/capture/launched-runs.js +151 -0
- package/dist/capture/node.cjs +697 -0
- package/dist/capture/node.d.cts +32 -0
- package/dist/capture/python/sitecustomize.py +823 -0
- package/dist/capture/schemas/capture.schema.d.ts +35 -0
- package/dist/capture/schemas/capture.schema.js +31 -0
- package/dist/capture/types/capture.types.d.ts +20 -0
- package/dist/cli/constants/cli.constants.d.ts +2 -6
- package/dist/cli/constants/cli.constants.js +3 -7
- package/dist/cli/context.d.ts +19 -22
- package/dist/cli/context.js +23 -54
- package/dist/cli/doctor-run-capture.d.ts +13 -0
- package/dist/cli/doctor-run-capture.js +19 -0
- package/dist/cli/doctor.js +16 -67
- package/dist/cli/hook.d.ts +14 -0
- package/dist/cli/hook.js +40 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/misc.js +10 -2
- package/dist/cli/replay.d.ts +33 -0
- package/dist/cli/replay.js +193 -0
- package/dist/cli/setup.d.ts +10 -2
- package/dist/cli/setup.js +154 -26
- package/dist/cli/status.js +45 -5
- package/dist/cli/toggle.js +10 -0
- package/dist/cli/types/cli.types.d.ts +15 -1
- package/dist/cli/uninstall.js +8 -22
- package/dist/cli.js +104 -17
- package/dist/config/config.d.ts +0 -2
- package/dist/config/config.js +0 -1
- package/dist/config/constants/config.constants.js +2 -0
- package/dist/config/events-transport.d.ts +15 -0
- package/dist/config/events-transport.js +29 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/config/root-config.d.ts +12 -0
- package/dist/config/root-config.js +24 -0
- package/dist/config/schemas/config.schema.d.ts +13 -0
- package/dist/config/schemas/config.schema.js +42 -6
- package/dist/config/types/config.types.d.ts +7 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/version.d.ts +9 -0
- package/dist/core/version.js +14 -0
- package/dist/core/which.d.ts +11 -0
- package/dist/core/which.js +18 -0
- package/dist/credentials/cloud-claim.d.ts +32 -0
- package/dist/credentials/cloud-claim.js +42 -0
- package/dist/credentials/constants/credentials.constants.d.ts +8 -1
- package/dist/credentials/constants/credentials.constants.js +9 -2
- package/dist/credentials/device-api.d.ts +15 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/sign-in.d.ts +27 -0
- package/dist/credentials/sign-in.js +31 -1
- package/dist/credentials/token-refresher.d.ts +5 -1
- package/dist/credentials/token-refresher.js +10 -2
- package/dist/events/constants/events.constants.d.ts +8 -2
- package/dist/events/constants/events.constants.js +7 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/product-event.d.ts +10 -4
- package/dist/events/types/events.types.d.ts +6 -0
- package/dist/events/types/replay-progress.types.d.ts +26 -0
- package/dist/events/types/replay-progress.types.js +1 -0
- package/dist/events/types/repo-snapshot.types.d.ts +1 -4
- package/dist/events/types/repo-tree.types.d.ts +25 -0
- package/dist/events/types/repo-tree.types.js +1 -0
- package/dist/feature/ticket-candidates.d.ts +1 -1
- package/dist/git/checkout-root.d.ts +15 -0
- package/dist/git/checkout-root.js +18 -0
- package/dist/git/code-state.d.ts +2 -16
- package/dist/git/code-state.js +11 -12
- package/dist/git/constants/git.constants.d.ts +31 -11
- package/dist/git/constants/git.constants.js +36 -12
- package/dist/git/constants/tree.constants.d.ts +71 -0
- package/dist/git/constants/tree.constants.js +92 -0
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.d.ts +1 -0
- package/dist/git/git-context.js +8 -3
- package/dist/git/index.d.ts +1 -2
- package/dist/git/index.js +1 -1
- package/dist/git/repo-snapshot.d.ts +13 -4
- package/dist/git/repo-snapshot.js +47 -9
- package/dist/git/repo-tree.d.ts +69 -0
- package/dist/git/repo-tree.js +130 -0
- package/dist/git/types/git.types.d.ts +5 -2
- package/dist/git/types/snapshot.types.d.ts +14 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
- package/dist/pipeline/constants/pipeline.constants.js +3 -0
- package/dist/pipeline/hook-pipeline.js +112 -72
- package/dist/privacy/product-capture.js +36 -5
- package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.capture.js +5 -0
- package/dist/providers/antigravity/antigravity.detect.js +8 -22
- package/dist/providers/antigravity/antigravity.provider.js +10 -3
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
- package/dist/providers/claude/claude.adapter.js +9 -6
- package/dist/providers/claude/claude.detect.js +2 -17
- package/dist/providers/claude/claude.otel.d.ts +21 -3
- package/dist/providers/claude/claude.otel.js +216 -61
- package/dist/providers/claude/claude.provider.js +17 -1
- package/dist/providers/claude/claude.version.d.ts +9 -0
- package/dist/providers/claude/claude.version.js +28 -0
- package/dist/providers/claude/constants/claude.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.constants.js +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +27 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +45 -5
- package/dist/providers/claude/types/claude.types.d.ts +13 -0
- package/dist/providers/codex/codex.capture.d.ts +76 -0
- package/dist/providers/codex/codex.capture.js +454 -0
- package/dist/providers/codex/codex.detect.js +2 -4
- package/dist/providers/codex/codex.otel.d.ts +38 -2
- package/dist/providers/codex/codex.otel.js +50 -6
- package/dist/providers/codex/codex.provider.js +8 -0
- package/dist/providers/codex/codex.surface.d.ts +9 -0
- package/dist/{turns/codex-originator.js → providers/codex/codex.surface.js} +17 -3
- package/dist/providers/codex/codex.titles.d.ts +14 -0
- package/dist/providers/codex/codex.titles.js +35 -0
- package/dist/providers/codex/constants/codex.constants.d.ts +4 -0
- package/dist/providers/codex/constants/codex.constants.js +4 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +17 -4
- package/dist/providers/cursor/constants/cursor.constants.js +25 -5
- package/dist/providers/cursor/cursor-mcp-memo.d.ts +34 -0
- package/dist/providers/cursor/cursor-mcp-memo.js +94 -0
- package/dist/providers/cursor/cursor.adapter.js +20 -82
- package/dist/providers/cursor/cursor.capture.d.ts +1 -0
- package/dist/providers/cursor/cursor.capture.js +4 -0
- package/dist/providers/cursor/cursor.detect.d.ts +5 -1
- package/dist/providers/cursor/cursor.detect.js +11 -26
- package/dist/providers/cursor/cursor.hooks.js +2 -2
- package/dist/providers/cursor/cursor.provider.js +16 -7
- package/dist/providers/cursor/cursor.titles.d.ts +14 -0
- package/dist/providers/cursor/cursor.titles.js +20 -0
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +3 -3
- package/dist/providers/cursor/schemas/cursor.schema.js +5 -3
- package/dist/providers/gemini/constants/gemini.constants.d.ts +16 -0
- package/dist/providers/gemini/constants/gemini.constants.js +17 -0
- package/dist/providers/gemini/gemini.capture.d.ts +81 -0
- package/dist/providers/gemini/gemini.capture.js +210 -0
- package/dist/providers/gemini/gemini.detect.js +57 -24
- package/dist/providers/gemini/gemini.otel.d.ts +38 -2
- package/dist/providers/gemini/gemini.otel.js +56 -125
- package/dist/providers/gemini/gemini.provider.js +5 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/provider.d.ts +8 -0
- package/dist/providers/provider.js +9 -0
- package/dist/providers/registry.d.ts +14 -0
- package/dist/providers/registry.js +14 -0
- package/dist/providers/shared/constants/hook-config.constants.d.ts +2 -0
- package/dist/providers/shared/constants/hook-config.constants.js +2 -0
- package/dist/providers/shared/constants/terminal-capture.constants.d.ts +6 -0
- package/dist/providers/shared/constants/terminal-capture.constants.js +6 -0
- package/dist/providers/shared/editor-paths.d.ts +8 -0
- package/dist/providers/shared/editor-paths.js +18 -0
- package/dist/providers/shared/hook-config.d.ts +5 -0
- package/dist/providers/shared/hook-config.js +39 -1
- package/dist/providers/shared/hooks-marker.d.ts +14 -0
- package/dist/providers/shared/hooks-marker.js +23 -0
- package/dist/providers/shared/install-record.d.ts +29 -0
- package/dist/providers/shared/install-record.js +52 -0
- package/dist/providers/shared/session-title-store.d.ts +23 -0
- package/dist/providers/shared/session-title-store.js +50 -0
- package/dist/providers/shared/terminal-capture.d.ts +41 -0
- package/dist/providers/shared/terminal-capture.js +109 -0
- package/dist/providers/shared/tooling.d.ts +21 -0
- package/dist/providers/shared/tooling.js +36 -1
- package/dist/providers/types/provider.types.d.ts +57 -4
- package/dist/replay/checkout-resolver.d.ts +29 -0
- package/dist/replay/checkout-resolver.js +69 -0
- package/dist/replay/codex-turns.d.ts +24 -0
- package/dist/replay/codex-turns.js +221 -0
- package/dist/replay/constants/replay.constants.d.ts +99 -0
- package/dist/replay/constants/replay.constants.js +102 -0
- package/dist/replay/describe.d.ts +10 -0
- package/dist/replay/describe.js +31 -0
- package/dist/replay/gemini-turns.d.ts +36 -0
- package/dist/replay/gemini-turns.js +192 -0
- package/dist/replay/machine.d.ts +34 -0
- package/dist/replay/machine.js +68 -0
- package/dist/replay/progress-event.d.ts +21 -0
- package/dist/replay/progress-event.js +45 -0
- package/dist/replay/replay-runner.d.ts +58 -0
- package/dist/replay/replay-runner.js +529 -0
- package/dist/replay/replay-scan.d.ts +83 -0
- package/dist/replay/replay-scan.js +170 -0
- package/dist/replay/replay-state.d.ts +108 -0
- package/dist/replay/replay-state.js +199 -0
- package/dist/replay/resume.d.ts +18 -0
- package/dist/replay/resume.js +34 -0
- package/dist/replay/start.d.ts +23 -0
- package/dist/replay/start.js +39 -0
- package/dist/replay/throttle.d.ts +35 -0
- package/dist/replay/throttle.js +41 -0
- package/dist/replay/transcript-turns.d.ts +35 -0
- package/dist/replay/transcript-turns.js +215 -0
- package/dist/replay/turn-event.d.ts +38 -0
- package/dist/replay/turn-event.js +116 -0
- package/dist/replay/types/replay.types.d.ts +162 -0
- package/dist/replay/types/replay.types.js +1 -0
- package/dist/replay/window.d.ts +28 -0
- package/dist/replay/window.js +41 -0
- package/dist/snapshot/branch-selection.d.ts +40 -23
- package/dist/snapshot/branch-selection.js +74 -42
- package/dist/snapshot/budget.js +2 -2
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +10 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +10 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +37 -4
- package/dist/snapshot/constants/snapshot.constants.js +37 -4
- package/dist/snapshot/index.d.ts +6 -1
- package/dist/snapshot/index.js +3 -1
- package/dist/snapshot/snapshot-event.d.ts +7 -0
- package/dist/snapshot/snapshot-event.js +8 -5
- package/dist/snapshot/snapshot-pipeline.js +89 -26
- package/dist/snapshot/snapshot-state.js +24 -2
- package/dist/snapshot/tree-event.d.ts +14 -0
- package/dist/snapshot/tree-event.js +91 -0
- package/dist/snapshot/tree-pipeline.d.ts +12 -0
- package/dist/snapshot/tree-pipeline.js +172 -0
- package/dist/snapshot/types/snapshot.types.d.ts +62 -2
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/constants/transport.constants.d.ts +5 -0
- package/dist/transport/constants/transport.constants.js +5 -0
- package/dist/transport/delivery-stats.d.ts +13 -1
- package/dist/transport/delivery-stats.js +18 -2
- package/dist/transport/delivery.d.ts +4 -3
- package/dist/transport/delivery.js +21 -7
- package/dist/transport/identity-delivery.d.ts +20 -0
- package/dist/transport/identity-delivery.js +41 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/queue.js +40 -6
- package/dist/transport/types/delivery-flow.types.d.ts +7 -0
- package/dist/turns/claude-transcript.js +4 -12
- package/dist/turns/codex-transcript.d.ts +9 -0
- package/dist/turns/codex-transcript.js +27 -19
- package/dist/turns/constants/turns.constants.d.ts +13 -12
- package/dist/turns/constants/turns.constants.js +15 -19
- package/dist/turns/gemini-transcript.d.ts +19 -1
- package/dist/turns/gemini-transcript.js +29 -18
- package/dist/turns/index.d.ts +3 -4
- package/dist/turns/index.js +2 -3
- package/dist/turns/run-state.d.ts +71 -0
- package/dist/turns/run-state.js +114 -0
- package/dist/turns/tool-events.d.ts +11 -1
- package/dist/turns/tool-events.js +32 -9
- package/dist/turns/transcript.d.ts +15 -14
- package/dist/turns/transcript.js +23 -4
- package/dist/turns/turn-state.d.ts +49 -7
- package/dist/turns/turn-state.js +78 -10
- package/dist/turns/turn-summary.js +10 -6
- package/dist/turns/turn-tracker.d.ts +9 -16
- package/dist/turns/turn-tracker.js +162 -86
- package/dist/turns/types/transcript.types.d.ts +11 -1
- package/dist/turns/types/turn-provider.types.d.ts +33 -0
- package/dist/turns/types/turn-provider.types.js +1 -0
- package/dist/turns/types/turn-state.types.d.ts +9 -0
- package/dist/turns/types/turn-summary.types.d.ts +20 -6
- package/dist/turns/types/turn-tracker.types.d.ts +3 -1
- package/dist/turns/work-checkout.js +1 -2
- package/docs/AUDIT_PROMPT.md +10 -0
- package/docs/DATA_HANDLING.md +269 -32
- package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
- package/docs/PERFORMANCE.md +27 -0
- package/package.json +3 -2
- package/dist/events/canonical-event.d.ts +0 -10
- package/dist/events/canonical-event.js +0 -9
- package/dist/git/repository-root.d.ts +0 -39
- package/dist/git/repository-root.js +0 -131
- package/dist/git/types/repository-root.types.d.ts +0 -11
- package/dist/transport/transport.d.ts +0 -6
- package/dist/turns/codex-originator.d.ts +0 -11
- package/dist/turns/cursor-transcript.d.ts +0 -21
- package/dist/turns/cursor-transcript.js +0 -66
- package/dist/turns/native-session-titles.d.ts +0 -26
- package/dist/turns/native-session-titles.js +0 -102
- /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
- /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { performance } from 'node:perf_hooks';
|
|
3
|
+
import { armCaptureStage, capturedAtSessionEnd, capturedStage, runWasCaptured } from '../capture/captured-step.js';
|
|
4
|
+
import { STAGE_CAPTURE_ARM, STAGE_CAPTURED, STAGE_CAPTURED_AT_END } from '../capture/constants/capture.constants.js';
|
|
3
5
|
import { asRecord } from '../core/object.js';
|
|
4
6
|
import { applyProductCapture } from '../privacy/product-capture.js';
|
|
5
7
|
import { debugLog } from '../core/logger.js';
|
|
6
8
|
import { next, runFlow, step, stop } from '../core/pipe.js';
|
|
7
9
|
import { loadEffectiveConfig } from '../config/repo-config.js';
|
|
10
|
+
import { transportFor } from '../config/events-transport.js';
|
|
8
11
|
import { CREDENTIAL_BUDGET_SHARE, NOT_SIGNED_IN } from '../credentials/constants/credentials.constants.js';
|
|
9
12
|
import { cachedBearer, resolveBearer } from '../credentials/credentials.js';
|
|
10
|
-
import { awaitingSignIn, deviceFor,
|
|
11
|
-
import { cachedAccessToken } from '../credentials/token-refresher.js';
|
|
12
|
-
import { credentialScope, inheritedRootConfig, selectRoot, servesMultipleIdentities } from '../config/root-config.js';
|
|
13
|
+
import { awaitingSignIn, deviceFor, identityFingerprint, identityOf } from '../credentials/identity.js';
|
|
14
|
+
import { cachedAccessToken, currentAccessToken } from '../credentials/token-refresher.js';
|
|
15
|
+
import { credentialScope, inheritedRootConfig, isIgnoredRoot, selectRoot, servesMultipleIdentities } from '../config/root-config.js';
|
|
13
16
|
import { DECISION_BLOCK } from '../enforcement/constants/enforcement.constants.js';
|
|
14
17
|
import { enforcementWouldAsk, resolveEnforcement } from '../enforcement/enforcement.js';
|
|
15
18
|
import { sessionBillingFact } from '../billing/session-billing.js';
|
|
@@ -22,23 +25,20 @@ import { rewriteNativeBearers } from '../providers/shared/bearer-rewrite.js';
|
|
|
22
25
|
import { isUninstalled } from '../storage/uninstalled.js';
|
|
23
26
|
import { shellDirectories } from '../providers/shared/shell-directories.js';
|
|
24
27
|
import { runSnapshotPipeline } from '../snapshot/snapshot-pipeline.js';
|
|
28
|
+
import { runTreePipeline } from '../snapshot/tree-pipeline.js';
|
|
25
29
|
import { SnapshotStateStore } from '../snapshot/snapshot-state.js';
|
|
26
30
|
import { SNAPSHOT_BUDGET_MS } from '../snapshot/constants/snapshot.constants.js';
|
|
27
|
-
import { BackendAuthBlock } from '../transport/auth-block.js';
|
|
28
|
-
import { BackendCooldown } from '../transport/cooldown.js';
|
|
29
|
-
import { DeliveryStats } from '../transport/delivery-stats.js';
|
|
30
31
|
import { deliverEvents } from '../transport/delivery.js';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import { identityPaths, settleLegacyQueue } from '../transport/queue-partition.js';
|
|
34
|
-
import { eventsUrl } from '../config/config.js';
|
|
32
|
+
import { identityDelivery } from '../transport/identity-delivery.js';
|
|
33
|
+
import { settleLegacyQueue } from '../transport/queue-partition.js';
|
|
35
34
|
import { untracedNotice as untracedNoticeText } from '../untraced/constants/untraced.constants.js';
|
|
36
35
|
import { isRunCommand, manifestVerdict, rootHash } from '../untraced/untraced.js';
|
|
36
|
+
import { resumeReplayIfOwed } from '../replay/resume.js';
|
|
37
37
|
import { installedPackage, startUpdateCheck, updateNotice } from '../update/update-check.js';
|
|
38
38
|
import { TurnStateStore } from '../turns/turn-state.js';
|
|
39
39
|
import { MAX_TURN_CHECKOUTS, SHELL_REREAD_TYPES, TOOL_START_TYPES } from '../turns/constants/turns.constants.js';
|
|
40
40
|
import { resolveSurface, trackTurnOutcome } from '../turns/turn-tracker.js';
|
|
41
|
-
import { PAYLOAD_CWD_KEY, PROMPT_SUBMITTED_TYPE, STAGE_DELIVER, STAGE_ENFORCE, STAGE_ENRICH, MAX_WORKSPACE_ROOTS, STAGE_NOMINATE, STAGE_PARSE_EVENTS, STAGE_RESOLVE_CONTEXT, STAGE_REWRITE_BEARERS, STAGE_SNAPSHOT, STAGE_TRACK_TURN, STAGE_UNTRACED, STAGE_UPDATE, QUIET_SESSION_SOURCES, STOP_DRY_RUN, STAGE_AWAIT_SIGN_IN, STOP_NO_EVENTS, STOP_NOT_SIGNED_IN, STOP_NO_SNAPSHOT } from './constants/pipeline.constants.js';
|
|
41
|
+
import { PAYLOAD_CWD_KEY, PROMPT_SUBMITTED_TYPE, STAGE_DELIVER, STAGE_ENFORCE, STAGE_ENRICH, STAGE_IGNORED_ROOT, MAX_WORKSPACE_ROOTS, STAGE_NOMINATE, STAGE_PARSE_EVENTS, STAGE_RESOLVE_CONTEXT, STAGE_REWRITE_BEARERS, STAGE_SNAPSHOT, STAGE_TRACK_TURN, STAGE_UNTRACED, STAGE_REPLAY_RESUME, STAGE_UPDATE, QUIET_SESSION_SOURCES, STOP_DRY_RUN, STOP_IGNORED_ROOT, STAGE_AWAIT_SIGN_IN, STOP_NO_EVENTS, STOP_NOT_SIGNED_IN, STOP_NO_SNAPSHOT } from './constants/pipeline.constants.js';
|
|
42
42
|
/**
|
|
43
43
|
* The hook flow, as the list of stages it is.
|
|
44
44
|
*
|
|
@@ -52,15 +52,20 @@ import { PAYLOAD_CWD_KEY, PROMPT_SUBMITTED_TYPE, STAGE_DELIVER, STAGE_ENFORCE, S
|
|
|
52
52
|
* reordering a step is a change to this array rather than to a call graph.
|
|
53
53
|
*/
|
|
54
54
|
const HOOK_STAGES = [
|
|
55
|
+
step(STAGE_IGNORED_ROOT, ignoredRoot),
|
|
55
56
|
step(STAGE_RESOLVE_CONTEXT, resolveContext),
|
|
56
57
|
step(STAGE_PARSE_EVENTS, parseEvents),
|
|
58
|
+
step(STAGE_CAPTURE_ARM, armCaptureStage),
|
|
57
59
|
step(STAGE_AWAIT_SIGN_IN, awaitSignIn),
|
|
58
60
|
step(STAGE_NOMINATE, nominate),
|
|
59
61
|
step(STAGE_UNTRACED, untracedNotice),
|
|
60
62
|
step(STAGE_UPDATE, updateNoticeStage),
|
|
63
|
+
step(STAGE_REPLAY_RESUME, resumeReplayStage),
|
|
61
64
|
step(STAGE_ENFORCE, enforce),
|
|
62
65
|
step(STAGE_ENRICH, enrich),
|
|
66
|
+
step(STAGE_CAPTURED_AT_END, (state) => capturedAtSessionEnd(state, openDelivery(state).queue)),
|
|
63
67
|
step(STAGE_TRACK_TURN, trackTurnStage),
|
|
68
|
+
step(STAGE_CAPTURED, (state) => capturedStage(state, openDelivery(state).queue)),
|
|
64
69
|
step(STAGE_DELIVER, deliver),
|
|
65
70
|
step(STAGE_REWRITE_BEARERS, rewriteBearers),
|
|
66
71
|
step(STAGE_SNAPSHOT, snapshot)
|
|
@@ -89,6 +94,20 @@ export function runHookPipeline(input) {
|
|
|
89
94
|
debugLog(`hook flow ${trace.outcome} at ${trace.step}${trace.reason ? `: ${trace.reason}` : ''}`);
|
|
90
95
|
});
|
|
91
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* End the flow in a directory the developer listed in `ignoredRoots`.
|
|
99
|
+
*
|
|
100
|
+
* First, so nothing is parsed, enforced, sent or queued — the same as a
|
|
101
|
+
* disabled machine, but only here.
|
|
102
|
+
*
|
|
103
|
+
* @param state - Current flow state.
|
|
104
|
+
* @returns A stop in an ignored directory, otherwise the state unchanged.
|
|
105
|
+
*/
|
|
106
|
+
function ignoredRoot(state) {
|
|
107
|
+
if (isIgnoredRoot(state.globalConfig.config.ignoredRoots, state.cwd))
|
|
108
|
+
return stop(state, STOP_IGNORED_ROOT);
|
|
109
|
+
return next(state);
|
|
110
|
+
}
|
|
92
111
|
/**
|
|
93
112
|
* Apply the repository's `.agentwatch.json` on top of the global config.
|
|
94
113
|
*
|
|
@@ -206,6 +225,24 @@ async function updateNoticeStage(state) {
|
|
|
206
225
|
const notice = await updateNotice(state.paths.dataDir, state.env.now(), installedPackage().version, () => startUpdateCheck(state.env));
|
|
207
226
|
return next(notice === undefined ? state : { ...state, notice });
|
|
208
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Pick an unfinished replay of earlier sessions up again, as a session opens.
|
|
230
|
+
*
|
|
231
|
+
* One `stat` of a marker that is absent unless a replay is owed; the work
|
|
232
|
+
* itself runs in a process of its own. Never delays or fails the hook.
|
|
233
|
+
*
|
|
234
|
+
* @param state - Current flow state.
|
|
235
|
+
* @returns The state, unchanged.
|
|
236
|
+
*/
|
|
237
|
+
async function resumeReplayStage(state) {
|
|
238
|
+
if (state.dryRun || !isLoudSessionStart(state))
|
|
239
|
+
return next(state);
|
|
240
|
+
await resumeReplayIfOwed(state.env, state.paths, identityOf(state.config), state.credentialScope).catch((error) => debugLog('replay: resume check failed:', error));
|
|
241
|
+
if (state.credentialScope !== undefined) {
|
|
242
|
+
await resumeReplayIfOwed(state.env, state.paths, identityOf(state.globalConfig.config)).catch((error) => debugLog('replay: machine resume check failed:', error));
|
|
243
|
+
}
|
|
244
|
+
return next(state);
|
|
245
|
+
}
|
|
209
246
|
/**
|
|
210
247
|
* Tell the developer, once per repository per session, that a run called an
|
|
211
248
|
* LLM with no tracing (AWT-310).
|
|
@@ -228,6 +265,9 @@ async function untracedNotice(state) {
|
|
|
228
265
|
const call = state.provider.shellCall?.(state.payload);
|
|
229
266
|
if (typeof call?.command !== 'string' || !isRunCommand(call.command))
|
|
230
267
|
return next(state);
|
|
268
|
+
// Its calls are counted, so there is nothing to tell the developer about this run.
|
|
269
|
+
if (await runWasCaptured(state, sessionId))
|
|
270
|
+
return next(state);
|
|
231
271
|
const workdir = typeof call.workdir === 'string' && path.isAbsolute(call.workdir) ? call.workdir : state.cwd;
|
|
232
272
|
// The checkouts the command names, then the one the agent sits in: the run may be in either.
|
|
233
273
|
const here = await checkoutRootOf(workdir);
|
|
@@ -466,8 +506,8 @@ async function trackTurnStage(state) {
|
|
|
466
506
|
*/
|
|
467
507
|
async function billingFactSafely(state) {
|
|
468
508
|
try {
|
|
469
|
-
const surface = await resolveSurface(state.
|
|
470
|
-
return await sessionBillingFact(new TurnStateStore(state.paths.turnsDir), state.events, state.provider
|
|
509
|
+
const surface = await resolveSurface(state.provider, state.env, state.payload);
|
|
510
|
+
return await sessionBillingFact(new TurnStateStore(state.paths.turnsDir), state.events, state.provider, state.env, surface);
|
|
471
511
|
}
|
|
472
512
|
catch (error) {
|
|
473
513
|
debugLog('session billing fact failed:', error);
|
|
@@ -483,7 +523,7 @@ async function billingFactSafely(state) {
|
|
|
483
523
|
async function trackTurnSafely(state) {
|
|
484
524
|
try {
|
|
485
525
|
return await trackTurnOutcome({
|
|
486
|
-
|
|
526
|
+
provider: state.provider,
|
|
487
527
|
rawPayload: state.payload,
|
|
488
528
|
events: state.events,
|
|
489
529
|
config: state.config,
|
|
@@ -516,7 +556,7 @@ async function deliver(state) {
|
|
|
516
556
|
// `globalConfig`, not `config`: roots are stripped from the effective config
|
|
517
557
|
// once applied, and the question is what the *machine* sends as.
|
|
518
558
|
await settleLegacyQueue(state.paths.queueDir, identityOf(state.config), servesMultipleIdentities(state.globalConfig.config));
|
|
519
|
-
const
|
|
559
|
+
const opened = openDelivery(state);
|
|
520
560
|
// One budget for the credential and the send: credential work (a keychain
|
|
521
561
|
// read, a refresh, an exchange) may spend its share of it and no more, and
|
|
522
562
|
// the send gets what is left. A hook never waits longer than it did before.
|
|
@@ -526,7 +566,25 @@ async function deliver(state) {
|
|
|
526
566
|
const started = performance.now();
|
|
527
567
|
const bearer = await resolveBearer({ ...credentialContext(state, budgetMs), deadline: started + budgetMs * CREDENTIAL_BUDGET_SHARE }, state.config);
|
|
528
568
|
const remaining = Math.max(0, budgetMs - (performance.now() - started));
|
|
529
|
-
const delivery = await deliverEvents(state.outbound,
|
|
569
|
+
const delivery = await deliverEvents(state.outbound, transportFor(state.config, bearer, { budgetMs: remaining }), opened.queue, state.config.delivery.drainBatchSize, opened.cooldown, opened.stats, opened.authBlock,
|
|
570
|
+
// A plain 401 for a device access token: one forced refresh, and a transport
|
|
571
|
+
// on the new token for the resend, within what is left of the hook's budget.
|
|
572
|
+
async () => {
|
|
573
|
+
const left = budgetMs - (performance.now() - started);
|
|
574
|
+
if (!bearer || !deviceFor(state.config) || left <= 0)
|
|
575
|
+
return undefined;
|
|
576
|
+
try {
|
|
577
|
+
const ctx = { ...credentialContext(state, left), deadline: performance.now() + left * CREDENTIAL_BUDGET_SHARE };
|
|
578
|
+
const renewed = await currentAccessToken(ctx, state.config, { force: true });
|
|
579
|
+
if (!renewed || renewed === bearer)
|
|
580
|
+
return undefined;
|
|
581
|
+
return transportFor(state.config, renewed, { budgetMs: Math.max(0, budgetMs - (performance.now() - started)) });
|
|
582
|
+
}
|
|
583
|
+
catch (error) {
|
|
584
|
+
debugLog('credentials: refreshing after a 401 failed; queueing instead:', error);
|
|
585
|
+
return undefined;
|
|
586
|
+
}
|
|
587
|
+
});
|
|
530
588
|
debugLog(`delivery: sent=${delivery.delivered} queued=${delivery.queued} drained=${delivery.drained} rejected=${delivery.rejected}`);
|
|
531
589
|
return next({ ...state, delivery });
|
|
532
590
|
}
|
|
@@ -575,73 +633,55 @@ async function snapshot(state) {
|
|
|
575
633
|
const capture = state.workCapture ?? state.config.capture;
|
|
576
634
|
if (!repository || state.summary?.work_evidence === 'inherited' || !capture.git)
|
|
577
635
|
return stop(state, STOP_NO_SNAPSHOT);
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
});
|
|
636
|
+
const input = {
|
|
637
|
+
// The checkout the summary named, which need not be the folder the agent sits in.
|
|
638
|
+
cwd: state.workRoot ?? state.cwd,
|
|
639
|
+
// The repository's own policy, which may lower the global one: file names
|
|
640
|
+
// off means the files listing never runs, not that it is emptied later.
|
|
641
|
+
files: capture.files !== false,
|
|
642
|
+
// A digest, never the credential: the tree is owed per repository and identity.
|
|
643
|
+
identity: treeIdentity(state),
|
|
644
|
+
repository,
|
|
645
|
+
provider: state.summary?.provider ?? state.provider.id,
|
|
646
|
+
surface: state.summary?.surface ?? state.provider.id,
|
|
647
|
+
agentName: state.summary?.agent.name ?? state.provider.id,
|
|
648
|
+
developerId: state.summary?.developer_id,
|
|
649
|
+
installationId: state.config.installationId,
|
|
650
|
+
sessionId: state.summary?.session_id,
|
|
651
|
+
capturedAt: state.env.now().toISOString(),
|
|
652
|
+
// Real time, deliberately, where the line above uses the injected clock:
|
|
653
|
+
// this bounds subprocess timeouts, which are measured against the wall.
|
|
654
|
+
deadline: Date.now() + SNAPSHOT_BUDGET_MS,
|
|
655
|
+
run: runGit
|
|
656
|
+
};
|
|
657
|
+
const store = new SnapshotStateStore(state.paths.snapshotsDir);
|
|
658
|
+
const { queue } = openDelivery(state);
|
|
659
|
+
await runSnapshotPipeline({ input, store, queue });
|
|
660
|
+
// The trunk's paths and declaration names, per repository and identity and when the trunk changes,
|
|
661
|
+
// inside the same deadline. File names off means no listing at all.
|
|
662
|
+
if (input.files)
|
|
663
|
+
await runTreePipeline({ input, store, queue });
|
|
601
664
|
return next(state);
|
|
602
665
|
}
|
|
603
666
|
/**
|
|
604
|
-
* The
|
|
605
|
-
* `deliver` settles a pre-partition backlog before the first build.
|
|
667
|
+
* The identity a tree is recorded as sent for: a re-setup with a new credential owes it again.
|
|
606
668
|
*
|
|
607
669
|
* @param state - Current flow state.
|
|
608
|
-
* @returns
|
|
670
|
+
* @returns The identity's on-disk fingerprint, or undefined with no credential.
|
|
609
671
|
*/
|
|
610
|
-
function
|
|
611
|
-
const identity =
|
|
612
|
-
return
|
|
613
|
-
queueDir: identity.queueDir,
|
|
614
|
-
locksDir: state.paths.locksDir,
|
|
615
|
-
maxEvents: state.config.delivery.maxQueueEvents,
|
|
616
|
-
maxAttempts: state.config.delivery.maxAttempts,
|
|
617
|
-
maxEventAgeDays: state.config.delivery.maxEventAgeDays,
|
|
618
|
-
now: state.env.now,
|
|
619
|
-
// So the entries the bound sacrifices are counted wherever an enqueue
|
|
620
|
-
// happens, the snapshot pipeline's included.
|
|
621
|
-
stats: new DeliveryStats(identity.statsFile, state.env.now, state.paths.locksDir)
|
|
622
|
-
});
|
|
672
|
+
function treeIdentity(state) {
|
|
673
|
+
const identity = identityOf(state.config);
|
|
674
|
+
return identity ? identityFingerprint(identity) : undefined;
|
|
623
675
|
}
|
|
624
676
|
/**
|
|
625
|
-
*
|
|
677
|
+
* This run's delivery state, for the identity it sends as. `deliver` settles a
|
|
678
|
+
* pre-partition backlog before it first opens this; `snapshot` runs after it.
|
|
626
679
|
*
|
|
627
680
|
* @param state - Current flow state.
|
|
628
|
-
* @
|
|
629
|
-
* @param budgetMs - What is left of the delivery budget.
|
|
630
|
-
* @returns The transport, or undefined before setup has run.
|
|
681
|
+
* @returns The queue, stats, cooldown and auth block of this run's identity.
|
|
631
682
|
*/
|
|
632
|
-
function
|
|
633
|
-
|
|
634
|
-
if (!url)
|
|
635
|
-
return undefined;
|
|
636
|
-
return new HttpTransport({
|
|
637
|
-
eventsUrl: url,
|
|
638
|
-
capture: state.config.capture,
|
|
639
|
-
token: bearer,
|
|
640
|
-
credentialPending: hasCredential(state.config) && !bearer,
|
|
641
|
-
installationId: state.config.installationId,
|
|
642
|
-
timeoutMs: state.config.delivery.timeoutMs,
|
|
643
|
-
budgetMs
|
|
644
|
-
});
|
|
683
|
+
function openDelivery(state) {
|
|
684
|
+
return identityDelivery(state.paths, identityOf(state.config), state.config.delivery, state.env.now);
|
|
645
685
|
}
|
|
646
686
|
/**
|
|
647
687
|
* What the credential code needs from this run.
|
|
@@ -16,16 +16,21 @@ export function applyProductCapture(event, capture) {
|
|
|
16
16
|
if (event.event.type === 'repo.snapshot') {
|
|
17
17
|
if (capture?.git === false)
|
|
18
18
|
return undefined;
|
|
19
|
-
|
|
19
|
+
const snapshot = withoutUnreadSnapshotFields(event);
|
|
20
|
+
return sanitizeValue(capture?.files === false ? withoutCommitFiles(snapshot) : snapshot);
|
|
20
21
|
}
|
|
22
|
+
// A tree is nothing but paths and the names declared in them: it goes with
|
|
23
|
+
// either flag, queued records included, and is never sent emptied.
|
|
24
|
+
if (event.event.type === 'repo.tree')
|
|
25
|
+
return capture?.git === false || capture?.files === false ? undefined : sanitizeValue(event);
|
|
21
26
|
if (event.event.type !== 'turn.summary')
|
|
22
27
|
return sanitizeValue(event);
|
|
23
28
|
const summary = event;
|
|
24
29
|
// Response text goes unconditionally: this release never builds it, but a
|
|
25
30
|
// summary queued by an older one can still carry it. `prompt` is that older
|
|
26
31
|
// release's field and goes the same way; prompt text now rides only as
|
|
27
|
-
// `prompt_text`.
|
|
28
|
-
//
|
|
32
|
+
// `prompt_text`. The prompt and response evidence (length + sha256) goes
|
|
33
|
+
// too: nothing in the platform reads it.
|
|
29
34
|
//
|
|
30
35
|
// The content fields need an explicit `true`: they are opt-in, and a
|
|
31
36
|
// missing policy is not consent. The path and repository fields need an
|
|
@@ -36,6 +41,8 @@ export function applyProductCapture(event, capture) {
|
|
|
36
41
|
return sanitizeValue({
|
|
37
42
|
...event,
|
|
38
43
|
prompt: undefined,
|
|
44
|
+
prompt_evidence: undefined,
|
|
45
|
+
response_evidence: undefined,
|
|
39
46
|
tools_used: capture?.mcpNames === false ? foldMcpNames(summary.tools_used) : summary.tools_used,
|
|
40
47
|
response: undefined,
|
|
41
48
|
prompt_text: capture?.promptText === true ? summary.prompt_text : undefined,
|
|
@@ -46,14 +53,17 @@ export function applyProductCapture(event, capture) {
|
|
|
46
53
|
branch: git ? undefined : summary.branch,
|
|
47
54
|
commit: git ? undefined : summary.commit,
|
|
48
55
|
jira_ids: git ? undefined : summary.jira_ids,
|
|
49
|
-
prompt_jira_ids: git ? undefined : summary.prompt_jira_ids,
|
|
56
|
+
prompt_jira_ids: git ? undefined : summary.prompt_jira_ids?.slice(0, 1),
|
|
50
57
|
work_evidence: git ? undefined : summary.work_evidence,
|
|
51
58
|
parent_session_id: git ? undefined : summary.parent_session_id,
|
|
52
59
|
// Content-free (ids, times, outcome, digests), but on by default with git
|
|
53
60
|
// context and withheld whole without it: a digest of a command still says
|
|
54
61
|
// which command ran when.
|
|
55
62
|
tool_events: git ? undefined : withMcpPolicy(summary.tool_events, capture?.mcpNames === false),
|
|
56
|
-
|
|
63
|
+
// A name only, and withheld with the tool events it describes the turn beside.
|
|
64
|
+
command: git ? undefined : summary.command,
|
|
65
|
+
// The blob id is what is matched; the path beside it in older records is not read.
|
|
66
|
+
content_hashes: files ? undefined : summary.content_hashes?.map(({ blob_sha }) => ({ blob_sha })),
|
|
57
67
|
manifest_repository: files ? undefined : summary.manifest_repository,
|
|
58
68
|
files_changed: files ? undefined : summary.files_changed,
|
|
59
69
|
files_touched: files ? undefined : summary.files_touched,
|
|
@@ -76,6 +86,27 @@ function withMcpPolicy(events, fold) {
|
|
|
76
86
|
return events;
|
|
77
87
|
return events.map((event) => ({ ...event, tool: foldMcpName(event.tool) }));
|
|
78
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* A snapshot without the fields nothing in the platform reads: branch
|
|
91
|
+
* `last_commit_at`, commit `authored_at` and each file's status letter.
|
|
92
|
+
* The builder no longer sets them; a snapshot an older release queued
|
|
93
|
+
* loses them here.
|
|
94
|
+
*
|
|
95
|
+
* @param event - Snapshot, possibly from an older installation.
|
|
96
|
+
* @returns A copy without them.
|
|
97
|
+
*/
|
|
98
|
+
function withoutUnreadSnapshotFields(event) {
|
|
99
|
+
return {
|
|
100
|
+
...event,
|
|
101
|
+
branches: event.branches.map(({ last_commit_at: _lastCommitAt, ...branch }) => ({
|
|
102
|
+
...branch,
|
|
103
|
+
commits: branch.commits.map(({ authored_at: _authoredAt, ...commit }) => ({
|
|
104
|
+
...commit,
|
|
105
|
+
files: commit.files?.map(({ path }) => ({ path }))
|
|
106
|
+
}))
|
|
107
|
+
}))
|
|
108
|
+
};
|
|
109
|
+
}
|
|
79
110
|
/**
|
|
80
111
|
* A snapshot with no commit file names, for a policy that withholds paths.
|
|
81
112
|
*
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { terminalCapture } from '../shared/terminal-capture.js';
|
|
2
|
+
/** Flip to true, with the PR's verification done on the installed app. */
|
|
3
|
+
const ANTIGRAVITY_ROUTE_VERIFIED = false;
|
|
4
|
+
/** Antigravity is built on VS Code's settings too, so the route is Cursor's in its own folder. */
|
|
5
|
+
export const antigravityCapture = terminalCapture('Antigravity', ANTIGRAVITY_ROUTE_VERIFIED);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ANTIGRAVITY_CLI_DIR_SEGMENTS, ANTIGRAVITY_EXECUTABLES, ANTIGRAVITY_HOOKS_FILE, ANTIGRAVITY_ROOT_SEGMENTS } from './constants/antigravity.constants.js';
|
|
3
|
+
import { findFirstExecutable } from '../../core/which.js';
|
|
4
|
+
import { hooksMarkerPresent } from '../shared/hooks-marker.js';
|
|
5
|
+
import { ANTIGRAVITY_BIN_DIR_SEGMENTS, ANTIGRAVITY_CLI_DIR_SEGMENTS, ANTIGRAVITY_EXECUTABLES, ANTIGRAVITY_HOOKS_FILE, ANTIGRAVITY_ROOT_SEGMENTS } from './constants/antigravity.constants.js';
|
|
7
6
|
/**
|
|
8
7
|
* Antigravity's configuration root.
|
|
9
8
|
*
|
|
@@ -35,30 +34,17 @@ export async function detectAntigravity(env) {
|
|
|
35
34
|
if (fs.existsSync(path.join(env.home, ...ANTIGRAVITY_CLI_DIR_SEGMENTS))) {
|
|
36
35
|
evidence.push('~/.gemini/antigravity-cli directory exists');
|
|
37
36
|
}
|
|
38
|
-
const
|
|
37
|
+
const bundledBin = path.join(env.home, ...ANTIGRAVITY_BIN_DIR_SEGMENTS);
|
|
38
|
+
const executablePath = findFirstExecutable(env, ANTIGRAVITY_EXECUTABLES)
|
|
39
|
+
?? findFirstExecutable({ ...env, vars: { ...env.vars, PATH: bundledBin } }, ANTIGRAVITY_EXECUTABLES);
|
|
39
40
|
if (executablePath)
|
|
40
|
-
evidence.push(`agy executable
|
|
41
|
+
evidence.push(`agy executable found (${executablePath})`);
|
|
41
42
|
const hookConfigPath = antigravityHooksPath(env);
|
|
42
|
-
const read = await readJsonFile(hookConfigPath);
|
|
43
43
|
return {
|
|
44
44
|
detected: evidence.length > 0,
|
|
45
45
|
evidence,
|
|
46
46
|
executablePath,
|
|
47
47
|
hookConfigPath,
|
|
48
|
-
hooksInstalled:
|
|
48
|
+
hooksInstalled: await hooksMarkerPresent(hookConfigPath)
|
|
49
49
|
};
|
|
50
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
|
-
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { googleAccountBillingMode } from '../../billing/billing-mode.js';
|
|
2
|
+
import { IDE_SURFACE } from '../../turns/constants/turns.constants.js';
|
|
1
3
|
import { antigravityCwd, antigravityHookEvent, antigravityShellCall, parseAntigravityHookEvent } from './antigravity.adapter.js';
|
|
4
|
+
import { antigravityCapture } from './antigravity.capture.js';
|
|
2
5
|
import { detectAntigravity } from './antigravity.detect.js';
|
|
3
6
|
import { installAntigravityHooks, uninstallAntigravityHooks } from './antigravity.hooks.js';
|
|
4
7
|
import { ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_FALLBACK_DECISION, ANTIGRAVITY_HOOK_DECISIONS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
|
|
@@ -6,8 +9,9 @@ export const antigravityProvider = {
|
|
|
6
9
|
id: ANTIGRAVITY_PROVIDER_ID,
|
|
7
10
|
displayName: ANTIGRAVITY_DISPLAY_NAME,
|
|
8
11
|
detect: detectAntigravity,
|
|
9
|
-
installHooks: installAntigravityHooks,
|
|
10
|
-
uninstallHooks: uninstallAntigravityHooks,
|
|
12
|
+
installHooks: antigravityCapture.install(installAntigravityHooks),
|
|
13
|
+
uninstallHooks: antigravityCapture.uninstall(uninstallAntigravityHooks),
|
|
14
|
+
runCapture: antigravityCapture.route,
|
|
11
15
|
parseHookEvent: async (payload, context) => parseAntigravityHookEvent(payload, context),
|
|
12
16
|
getHookResponse: (payload) => {
|
|
13
17
|
const hook = antigravityHookEvent(payload);
|
|
@@ -15,7 +19,10 @@ export const antigravityProvider = {
|
|
|
15
19
|
return { stdout: JSON.stringify(decision ?? {}), exitCode: 0 };
|
|
16
20
|
},
|
|
17
21
|
resolveCwd: antigravityCwd,
|
|
18
|
-
shellCall: antigravityShellCall
|
|
22
|
+
shellCall: antigravityShellCall,
|
|
23
|
+
surface: async () => IDE_SURFACE,
|
|
24
|
+
/** Signed in through the shared `~/.gemini` Google account, as Gemini CLI is. */
|
|
25
|
+
billingMode: googleAccountBillingMode
|
|
19
26
|
// No nativeTelemetry: Antigravity exposes no OTLP exporter configuration, so
|
|
20
27
|
// there is no llm.call ledger source and turn summaries stay
|
|
21
28
|
// usage_status=pending. Adding a configurator would claim a capability the
|
|
@@ -5,6 +5,7 @@ export declare const ANTIGRAVITY_CWD_KEY = "Cwd";
|
|
|
5
5
|
/** Antigravity shares Gemini's home; its own config lives one level down. */
|
|
6
6
|
export declare const ANTIGRAVITY_ROOT_SEGMENTS: readonly [".gemini", "config"];
|
|
7
7
|
export declare const ANTIGRAVITY_CLI_DIR_SEGMENTS: readonly [".gemini", "antigravity-cli"];
|
|
8
|
+
export declare const ANTIGRAVITY_BIN_DIR_SEGMENTS: readonly [".gemini", "bin"];
|
|
8
9
|
export declare const ANTIGRAVITY_HOOKS_FILE = "hooks.json";
|
|
9
10
|
export declare const ANTIGRAVITY_EXECUTABLES: readonly ["agy", "antigravity"];
|
|
10
11
|
/**
|
|
@@ -5,6 +5,7 @@ export const ANTIGRAVITY_CWD_KEY = 'Cwd';
|
|
|
5
5
|
/** Antigravity shares Gemini's home; its own config lives one level down. */
|
|
6
6
|
export const ANTIGRAVITY_ROOT_SEGMENTS = ['.gemini', 'config'];
|
|
7
7
|
export const ANTIGRAVITY_CLI_DIR_SEGMENTS = ['.gemini', 'antigravity-cli'];
|
|
8
|
+
export const ANTIGRAVITY_BIN_DIR_SEGMENTS = ['.gemini', 'bin'];
|
|
8
9
|
export const ANTIGRAVITY_HOOKS_FILE = 'hooks.json';
|
|
9
10
|
export const ANTIGRAVITY_EXECUTABLES = ['agy', 'antigravity'];
|
|
10
11
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sha256Hex } from '../../events/event-id.js';
|
|
2
|
-
import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.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, RE_CLAUDE_EXIT_CODE } from './constants/claude.constants.js';
|
|
2
|
+
import { baseEvent, promptPatch, providerPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
|
|
3
|
+
import { classifyTool, extractCommand, parseMcpToolName, skillName, slashCommandName, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
4
|
+
import { CLAUDE_DISPLAY_NAME, CLAUDE_EVENT_TYPE_MAP, CLAUDE_PROVIDER_ID, CLAUDE_SHELL_REREAD_EVENTS, CLAUDE_SKILL_TOOL, CLAUDE_TOOL_EVENTS, CLAUDE_TOOL_START_EVENTS, CLAUDE_UNKNOWN_EVENT, RE_CLAUDE_EXIT_CODE } 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.
|
|
@@ -92,8 +92,11 @@ function hookPatch(payload, providerEventType, context) {
|
|
|
92
92
|
}
|
|
93
93
|
if (providerEventType === 'SessionEnd')
|
|
94
94
|
return { metadata: { sessionEndReason: payload.reason } };
|
|
95
|
-
if (providerEventType === 'UserPromptSubmit')
|
|
96
|
-
|
|
95
|
+
if (providerEventType === 'UserPromptSubmit') {
|
|
96
|
+
const prompt = promptPatch(payload.prompt ?? '', context.config.capture);
|
|
97
|
+
// The command's name only, read here in memory; its arguments stay in the prompt (AWT-711).
|
|
98
|
+
return { metadata: { ...prompt.metadata, ...providerPatch({ command: slashCommandName(payload.prompt) }).metadata } };
|
|
99
|
+
}
|
|
97
100
|
if (CLAUDE_TOOL_EVENTS.has(providerEventType))
|
|
98
101
|
return claudeToolPatch(payload, providerEventType, context);
|
|
99
102
|
if (providerEventType === 'Stop') {
|
|
@@ -125,7 +128,7 @@ function claudeToolPatch(payload, providerEventType, context) {
|
|
|
125
128
|
output: payload.tool_response,
|
|
126
129
|
error: providerEventType === 'PostToolUseFailure' ? payload.tool_error : undefined,
|
|
127
130
|
exitCode: providerEventType === 'PostToolUseFailure' && kind === 'shell' ? exitCodeIn(payload.tool_error) : undefined,
|
|
128
|
-
providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : undefined
|
|
131
|
+
providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : { skill: payload.tool_name === CLAUDE_SKILL_TOOL ? skillName(payload.tool_input, 'skill') : undefined }
|
|
129
132
|
}, context.config.capture);
|
|
130
133
|
}
|
|
131
134
|
/**
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { asRecord } from '../../core/object.js';
|
|
4
3
|
import { findExecutable } from '../../core/which.js';
|
|
5
|
-
import {
|
|
6
|
-
import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
|
|
4
|
+
import { hooksMarkerPresent } from '../shared/hooks-marker.js';
|
|
7
5
|
import { CLAUDE_EXECUTABLE, CLAUDE_HOME_DIR, CLAUDE_SETTINGS_FILE } from './constants/claude.constants.js';
|
|
8
6
|
/**
|
|
9
7
|
* Where Claude Code keeps the settings file AgentWatch registers hooks in.
|
|
@@ -39,19 +37,6 @@ export async function detectClaude(env) {
|
|
|
39
37
|
evidence,
|
|
40
38
|
executablePath,
|
|
41
39
|
hookConfigPath,
|
|
42
|
-
hooksInstalled: await
|
|
40
|
+
hooksInstalled: await hooksMarkerPresent(hookConfigPath, 'hooks')
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Whether the settings file already names the agentwatch hook command.
|
|
47
|
-
*
|
|
48
|
-
* @param settingsPath - Claude settings file.
|
|
49
|
-
* @returns True when our marker appears in the hooks block.
|
|
50
|
-
*/
|
|
51
|
-
async function hasOurHooks(settingsPath) {
|
|
52
|
-
const read = await readJsonFile(settingsPath);
|
|
53
|
-
const settings = read.state === 'ok' ? asRecord(read.value) : undefined;
|
|
54
|
-
if (!settings)
|
|
55
|
-
return false;
|
|
56
|
-
return JSON.stringify(settings['hooks'] ?? {}).includes(HOOK_COMMAND_MARKER);
|
|
57
|
-
}
|
|
@@ -1,5 +1,6 @@
|
|
|
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
|
+
import { claudeSettingsPath } from './claude.detect.js';
|
|
3
4
|
/** Where Claude Code's exporters send, as its settings file says. */
|
|
4
5
|
export interface ClaudeExporterTargets {
|
|
5
6
|
/** `OTEL_EXPORTER_OTLP_ENDPOINT`, when set. */
|
|
@@ -37,6 +38,21 @@ export declare function claudeOverrideTargets(env: Env): Promise<readonly string
|
|
|
37
38
|
* ledger comes from.
|
|
38
39
|
*/
|
|
39
40
|
export declare class ClaudeOtelConfigurator implements NativeTelemetryConfigurator {
|
|
41
|
+
private readonly captureSource;
|
|
42
|
+
/**
|
|
43
|
+
* Bind to the shims setup copies.
|
|
44
|
+
*
|
|
45
|
+
* @param captureSource - The package's shims; tests name their own.
|
|
46
|
+
*/
|
|
47
|
+
constructor(captureSource?: {
|
|
48
|
+
node: string;
|
|
49
|
+
python: string;
|
|
50
|
+
});
|
|
51
|
+
/** Run capture rides in the same env block, and comes and goes with the exporters. */
|
|
52
|
+
readonly runCapture: {
|
|
53
|
+
configPath: typeof claudeSettingsPath;
|
|
54
|
+
inspect: (context: SetupContext) => Promise<import("../types/provider.types.js").RunCaptureStatus>;
|
|
55
|
+
};
|
|
40
56
|
/**
|
|
41
57
|
* Whether this agent can export native telemetry at all.
|
|
42
58
|
*
|
|
@@ -67,9 +83,11 @@ export declare class ClaudeOtelConfigurator implements NativeTelemetryConfigurat
|
|
|
67
83
|
/**
|
|
68
84
|
* Remove the telemetry configuration AgentWatch wrote.
|
|
69
85
|
*
|
|
70
|
-
* Only our own keys go
|
|
71
|
-
*
|
|
72
|
-
*
|
|
86
|
+
* Only our own keys go, and a key the developer had before setup gets its
|
|
87
|
+
* value back. Without a recorded key list, keys holding values AgentWatch
|
|
88
|
+
* writes go only while the base endpoint is an Agent Watch one, and a signal
|
|
89
|
+
* the developer sends to their own collector keeps what it needs. Whatever is
|
|
90
|
+
* left in place for want of proof is named, never dropped silently.
|
|
73
91
|
*
|
|
74
92
|
* @param context - Environment, paths, config and install state.
|
|
75
93
|
* @returns Whether the file changed, what to tell the user, and the next
|