@agent-watch-ai/edge 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +288 -9
- package/README.md +307 -5
- 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 +7 -3
- package/dist/billing/session-billing.js +34 -13
- 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 +503 -0
- package/dist/capture/constants/capture.constants.d.ts +85 -0
- package/dist/capture/constants/capture.constants.js +87 -0
- package/dist/capture/launched-runs.d.ts +43 -0
- package/dist/capture/launched-runs.js +157 -0
- package/dist/capture/node.cjs +697 -0
- package/dist/capture/node.d.cts +32 -0
- package/dist/capture/python/sitecustomize.py +832 -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/capture/venv-loader.d.ts +68 -0
- package/dist/capture/venv-loader.js +189 -0
- package/dist/cli/constants/cli.constants.d.ts +23 -6
- package/dist/cli/constants/cli.constants.js +24 -7
- package/dist/cli/context.d.ts +19 -22
- package/dist/cli/context.js +23 -54
- package/dist/cli/doctor-run-capture.d.ts +21 -0
- package/dist/cli/doctor-run-capture.js +33 -0
- package/dist/cli/doctor.js +21 -68
- package/dist/cli/hook-check.d.ts +7 -2
- package/dist/cli/hook-check.js +30 -15
- package/dist/cli/hook.d.ts +14 -0
- package/dist/cli/hook.js +82 -1
- 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/npm-global.d.ts +24 -0
- package/dist/cli/npm-global.js +77 -0
- package/dist/cli/npx-install.js +22 -6
- package/dist/cli/replay.d.ts +33 -0
- package/dist/cli/replay.js +228 -0
- package/dist/cli/setup.d.ts +10 -2
- package/dist/cli/setup.js +200 -31
- 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 +42 -23
- package/dist/cli/update.js +3 -2
- package/dist/cli.js +104 -17
- package/dist/config/config-store.d.ts +15 -4
- package/dist/config/config-store.js +31 -7
- package/dist/config/config.d.ts +0 -2
- package/dist/config/config.js +0 -1
- package/dist/config/constants/config.constants.d.ts +8 -1
- package/dist/config/constants/config.constants.js +10 -1
- 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 +15 -2
- package/dist/config/schemas/config.schema.js +52 -8
- 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 +34 -0
- package/dist/credentials/cloud-claim.js +61 -0
- package/dist/credentials/constants/credentials.constants.d.ts +16 -1
- package/dist/credentials/constants/credentials.constants.js +17 -2
- package/dist/credentials/credential-status.js +1 -1
- package/dist/credentials/credentials.d.ts +3 -3
- package/dist/credentials/credentials.js +26 -12
- package/dist/credentials/device-api.d.ts +15 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/identity.d.ts +2 -2
- package/dist/credentials/identity.js +2 -2
- package/dist/credentials/install-key.d.ts +31 -0
- package/dist/credentials/install-key.js +58 -0
- package/dist/credentials/migration.d.ts +9 -7
- package/dist/credentials/migration.js +58 -18
- package/dist/credentials/secret-store.d.ts +12 -0
- package/dist/credentials/secret-store.js +18 -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/enforcement/enforcement.js +1 -1
- package/dist/events/constants/events.constants.d.ts +5 -2
- package/dist/events/constants/events.constants.js +4 -1
- package/dist/events/enrich.d.ts +14 -0
- package/dist/events/enrich.js +1 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/product-event.d.ts +6 -3
- 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-tree.types.d.ts +2 -1
- 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 +33 -11
- package/dist/git/constants/git.constants.js +45 -12
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.js +5 -1
- 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 +53 -9
- package/dist/git/types/snapshot.types.d.ts +6 -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 +82 -57
- package/dist/privacy/product-capture.js +2 -0
- 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 +21 -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 +56 -0
- package/dist/replay/checkout-resolver.js +173 -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 +60 -0
- package/dist/replay/replay-runner.js +581 -0
- package/dist/replay/replay-scan.d.ts +84 -0
- package/dist/replay/replay-scan.js +182 -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 +36 -0
- package/dist/replay/throttle.js +44 -0
- package/dist/replay/transcript-turns.d.ts +35 -0
- package/dist/replay/transcript-turns.js +241 -0
- package/dist/replay/turn-event.d.ts +40 -0
- package/dist/replay/turn-event.js +127 -0
- package/dist/replay/types/replay.types.d.ts +198 -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/replay/worktree-map.d.ts +42 -0
- package/dist/replay/worktree-map.js +134 -0
- package/dist/snapshot/branch-selection.d.ts +40 -23
- package/dist/snapshot/branch-selection.js +71 -41
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +3 -1
- package/dist/snapshot/constants/snapshot-stages.constants.js +3 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +34 -7
- package/dist/snapshot/constants/snapshot.constants.js +34 -7
- package/dist/snapshot/index.d.ts +2 -2
- package/dist/snapshot/index.js +1 -1
- package/dist/snapshot/snapshot-pipeline.js +100 -26
- package/dist/snapshot/snapshot-state.js +6 -2
- package/dist/snapshot/tree-pipeline.d.ts +1 -1
- package/dist/snapshot/tree-pipeline.js +34 -15
- package/dist/snapshot/types/snapshot.types.d.ts +22 -3
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -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/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 +29 -12
- package/dist/turns/constants/turns.constants.js +31 -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 +82 -7
- package/dist/turns/turn-state.js +157 -10
- package/dist/turns/turn-summary.js +7 -2
- package/dist/turns/turn-tracker.d.ts +9 -16
- package/dist/turns/turn-tracker.js +163 -87
- 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 +17 -1
- 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 +201 -13
- package/docs/ENTERPRISE_DEPLOYMENT.md +3 -3
- package/docs/PERFORMANCE.md +10 -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';
|
|
@@ -25,21 +28,17 @@ import { runSnapshotPipeline } from '../snapshot/snapshot-pipeline.js';
|
|
|
25
28
|
import { runTreePipeline } from '../snapshot/tree-pipeline.js';
|
|
26
29
|
import { SnapshotStateStore } from '../snapshot/snapshot-state.js';
|
|
27
30
|
import { SNAPSHOT_BUDGET_MS } from '../snapshot/constants/snapshot.constants.js';
|
|
28
|
-
import { BackendAuthBlock } from '../transport/auth-block.js';
|
|
29
|
-
import { BackendCooldown } from '../transport/cooldown.js';
|
|
30
|
-
import { DeliveryStats } from '../transport/delivery-stats.js';
|
|
31
31
|
import { deliverEvents } from '../transport/delivery.js';
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { identityPaths, settleLegacyQueue } from '../transport/queue-partition.js';
|
|
35
|
-
import { eventsUrl } from '../config/config.js';
|
|
32
|
+
import { identityDelivery } from '../transport/identity-delivery.js';
|
|
33
|
+
import { settleLegacyQueue } from '../transport/queue-partition.js';
|
|
36
34
|
import { untracedNotice as untracedNoticeText } from '../untraced/constants/untraced.constants.js';
|
|
37
35
|
import { isRunCommand, manifestVerdict, rootHash } from '../untraced/untraced.js';
|
|
36
|
+
import { resumeReplayIfOwed } from '../replay/resume.js';
|
|
38
37
|
import { installedPackage, startUpdateCheck, updateNotice } from '../update/update-check.js';
|
|
39
38
|
import { TurnStateStore } from '../turns/turn-state.js';
|
|
40
39
|
import { MAX_TURN_CHECKOUTS, SHELL_REREAD_TYPES, TOOL_START_TYPES } from '../turns/constants/turns.constants.js';
|
|
41
40
|
import { resolveSurface, trackTurnOutcome } from '../turns/turn-tracker.js';
|
|
42
|
-
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';
|
|
43
42
|
/**
|
|
44
43
|
* The hook flow, as the list of stages it is.
|
|
45
44
|
*
|
|
@@ -53,15 +52,20 @@ import { PAYLOAD_CWD_KEY, PROMPT_SUBMITTED_TYPE, STAGE_DELIVER, STAGE_ENFORCE, S
|
|
|
53
52
|
* reordering a step is a change to this array rather than to a call graph.
|
|
54
53
|
*/
|
|
55
54
|
const HOOK_STAGES = [
|
|
55
|
+
step(STAGE_IGNORED_ROOT, ignoredRoot),
|
|
56
56
|
step(STAGE_RESOLVE_CONTEXT, resolveContext),
|
|
57
57
|
step(STAGE_PARSE_EVENTS, parseEvents),
|
|
58
|
+
step(STAGE_CAPTURE_ARM, armCaptureStage),
|
|
58
59
|
step(STAGE_AWAIT_SIGN_IN, awaitSignIn),
|
|
59
60
|
step(STAGE_NOMINATE, nominate),
|
|
60
61
|
step(STAGE_UNTRACED, untracedNotice),
|
|
61
62
|
step(STAGE_UPDATE, updateNoticeStage),
|
|
63
|
+
step(STAGE_REPLAY_RESUME, resumeReplayStage),
|
|
62
64
|
step(STAGE_ENFORCE, enforce),
|
|
63
65
|
step(STAGE_ENRICH, enrich),
|
|
66
|
+
step(STAGE_CAPTURED_AT_END, (state) => capturedAtSessionEnd(state, openDelivery(state).queue)),
|
|
64
67
|
step(STAGE_TRACK_TURN, trackTurnStage),
|
|
68
|
+
step(STAGE_CAPTURED, (state) => capturedStage(state, openDelivery(state).queue)),
|
|
65
69
|
step(STAGE_DELIVER, deliver),
|
|
66
70
|
step(STAGE_REWRITE_BEARERS, rewriteBearers),
|
|
67
71
|
step(STAGE_SNAPSHOT, snapshot)
|
|
@@ -90,6 +94,20 @@ export function runHookPipeline(input) {
|
|
|
90
94
|
debugLog(`hook flow ${trace.outcome} at ${trace.step}${trace.reason ? `: ${trace.reason}` : ''}`);
|
|
91
95
|
});
|
|
92
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
|
+
}
|
|
93
111
|
/**
|
|
94
112
|
* Apply the repository's `.agentwatch.json` on top of the global config.
|
|
95
113
|
*
|
|
@@ -207,6 +225,24 @@ async function updateNoticeStage(state) {
|
|
|
207
225
|
const notice = await updateNotice(state.paths.dataDir, state.env.now(), installedPackage().version, () => startUpdateCheck(state.env));
|
|
208
226
|
return next(notice === undefined ? state : { ...state, notice });
|
|
209
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
|
+
}
|
|
210
246
|
/**
|
|
211
247
|
* Tell the developer, once per repository per session, that a run called an
|
|
212
248
|
* LLM with no tracing (AWT-310).
|
|
@@ -229,6 +265,9 @@ async function untracedNotice(state) {
|
|
|
229
265
|
const call = state.provider.shellCall?.(state.payload);
|
|
230
266
|
if (typeof call?.command !== 'string' || !isRunCommand(call.command))
|
|
231
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);
|
|
232
271
|
const workdir = typeof call.workdir === 'string' && path.isAbsolute(call.workdir) ? call.workdir : state.cwd;
|
|
233
272
|
// The checkouts the command names, then the one the agent sits in: the run may be in either.
|
|
234
273
|
const here = await checkoutRootOf(workdir);
|
|
@@ -467,8 +506,9 @@ async function trackTurnStage(state) {
|
|
|
467
506
|
*/
|
|
468
507
|
async function billingFactSafely(state) {
|
|
469
508
|
try {
|
|
470
|
-
const surface = await resolveSurface(state.
|
|
471
|
-
|
|
509
|
+
const surface = await resolveSurface(state.provider, state.env, state.payload);
|
|
510
|
+
const rooted = Object.keys(state.globalConfig.config.roots ?? {}).length > 0;
|
|
511
|
+
return await sessionBillingFact(new TurnStateStore(state.paths.turnsDir), state.events, state.provider, state.env, surface, rooted);
|
|
472
512
|
}
|
|
473
513
|
catch (error) {
|
|
474
514
|
debugLog('session billing fact failed:', error);
|
|
@@ -484,7 +524,7 @@ async function billingFactSafely(state) {
|
|
|
484
524
|
async function trackTurnSafely(state) {
|
|
485
525
|
try {
|
|
486
526
|
return await trackTurnOutcome({
|
|
487
|
-
|
|
527
|
+
provider: state.provider,
|
|
488
528
|
rawPayload: state.payload,
|
|
489
529
|
events: state.events,
|
|
490
530
|
config: state.config,
|
|
@@ -517,7 +557,7 @@ async function deliver(state) {
|
|
|
517
557
|
// `globalConfig`, not `config`: roots are stripped from the effective config
|
|
518
558
|
// once applied, and the question is what the *machine* sends as.
|
|
519
559
|
await settleLegacyQueue(state.paths.queueDir, identityOf(state.config), servesMultipleIdentities(state.globalConfig.config));
|
|
520
|
-
const
|
|
560
|
+
const opened = openDelivery(state);
|
|
521
561
|
// One budget for the credential and the send: credential work (a keychain
|
|
522
562
|
// read, a refresh, an exchange) may spend its share of it and no more, and
|
|
523
563
|
// the send gets what is left. A hook never waits longer than it did before.
|
|
@@ -527,7 +567,25 @@ async function deliver(state) {
|
|
|
527
567
|
const started = performance.now();
|
|
528
568
|
const bearer = await resolveBearer({ ...credentialContext(state, budgetMs), deadline: started + budgetMs * CREDENTIAL_BUDGET_SHARE }, state.config);
|
|
529
569
|
const remaining = Math.max(0, budgetMs - (performance.now() - started));
|
|
530
|
-
const delivery = await deliverEvents(state.outbound,
|
|
570
|
+
const delivery = await deliverEvents(state.outbound, transportFor(state.config, bearer, { budgetMs: remaining }), opened.queue, state.config.delivery.drainBatchSize, opened.cooldown, opened.stats, opened.authBlock,
|
|
571
|
+
// A plain 401 for a device access token: one forced refresh, and a transport
|
|
572
|
+
// on the new token for the resend, within what is left of the hook's budget.
|
|
573
|
+
async () => {
|
|
574
|
+
const left = budgetMs - (performance.now() - started);
|
|
575
|
+
if (!bearer || !deviceFor(state.config) || left <= 0)
|
|
576
|
+
return undefined;
|
|
577
|
+
try {
|
|
578
|
+
const ctx = { ...credentialContext(state, left), deadline: performance.now() + left * CREDENTIAL_BUDGET_SHARE };
|
|
579
|
+
const renewed = await currentAccessToken(ctx, state.config, { force: true });
|
|
580
|
+
if (!renewed || renewed === bearer)
|
|
581
|
+
return undefined;
|
|
582
|
+
return transportFor(state.config, renewed, { budgetMs: Math.max(0, budgetMs - (performance.now() - started)) });
|
|
583
|
+
}
|
|
584
|
+
catch (error) {
|
|
585
|
+
debugLog('credentials: refreshing after a 401 failed; queueing instead:', error);
|
|
586
|
+
return undefined;
|
|
587
|
+
}
|
|
588
|
+
});
|
|
531
589
|
debugLog(`delivery: sent=${delivery.delivered} queued=${delivery.queued} drained=${delivery.drained} rejected=${delivery.rejected}`);
|
|
532
590
|
return next({ ...state, delivery });
|
|
533
591
|
}
|
|
@@ -582,7 +640,7 @@ async function snapshot(state) {
|
|
|
582
640
|
// The repository's own policy, which may lower the global one: file names
|
|
583
641
|
// off means the files listing never runs, not that it is emptied later.
|
|
584
642
|
files: capture.files !== false,
|
|
585
|
-
// A digest, never the credential: the tree is owed
|
|
643
|
+
// A digest, never the credential: the tree is owed per repository and identity.
|
|
586
644
|
identity: treeIdentity(state),
|
|
587
645
|
repository,
|
|
588
646
|
provider: state.summary?.provider ?? state.provider.id,
|
|
@@ -598,9 +656,9 @@ async function snapshot(state) {
|
|
|
598
656
|
run: runGit
|
|
599
657
|
};
|
|
600
658
|
const store = new SnapshotStateStore(state.paths.snapshotsDir);
|
|
601
|
-
const queue =
|
|
659
|
+
const { queue } = openDelivery(state);
|
|
602
660
|
await runSnapshotPipeline({ input, store, queue });
|
|
603
|
-
// The trunk's paths and declaration names,
|
|
661
|
+
// The trunk's paths and declaration names, per repository and identity and when the trunk changes,
|
|
604
662
|
// inside the same deadline. File names off means no listing at all.
|
|
605
663
|
if (input.files)
|
|
606
664
|
await runTreePipeline({ input, store, queue });
|
|
@@ -617,47 +675,14 @@ function treeIdentity(state) {
|
|
|
617
675
|
return identity ? identityFingerprint(identity) : undefined;
|
|
618
676
|
}
|
|
619
677
|
/**
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
*
|
|
623
|
-
* @param state - Current flow state.
|
|
624
|
-
* @returns A queue bound to this run's paths and delivery limits.
|
|
625
|
-
*/
|
|
626
|
-
function buildQueue(state) {
|
|
627
|
-
const identity = identityPaths(state.paths, identityOf(state.config));
|
|
628
|
-
return new EventQueue({
|
|
629
|
-
queueDir: identity.queueDir,
|
|
630
|
-
locksDir: state.paths.locksDir,
|
|
631
|
-
maxEvents: state.config.delivery.maxQueueEvents,
|
|
632
|
-
maxAttempts: state.config.delivery.maxAttempts,
|
|
633
|
-
maxEventAgeDays: state.config.delivery.maxEventAgeDays,
|
|
634
|
-
now: state.env.now,
|
|
635
|
-
// So the entries the bound sacrifices are counted wherever an enqueue
|
|
636
|
-
// happens, the snapshot pipeline's included.
|
|
637
|
-
stats: new DeliveryStats(identity.statsFile, state.env.now, state.paths.locksDir)
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* The transport for this run, when a backend is configured.
|
|
678
|
+
* This run's delivery state, for the identity it sends as. `deliver` settles a
|
|
679
|
+
* pre-partition backlog before it first opens this; `snapshot` runs after it.
|
|
642
680
|
*
|
|
643
681
|
* @param state - Current flow state.
|
|
644
|
-
* @
|
|
645
|
-
* @param budgetMs - What is left of the delivery budget.
|
|
646
|
-
* @returns The transport, or undefined before setup has run.
|
|
682
|
+
* @returns The queue, stats, cooldown and auth block of this run's identity.
|
|
647
683
|
*/
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
if (!url)
|
|
651
|
-
return undefined;
|
|
652
|
-
return new HttpTransport({
|
|
653
|
-
eventsUrl: url,
|
|
654
|
-
capture: state.config.capture,
|
|
655
|
-
token: bearer,
|
|
656
|
-
credentialPending: hasCredential(state.config) && !bearer,
|
|
657
|
-
installationId: state.config.installationId,
|
|
658
|
-
timeoutMs: state.config.delivery.timeoutMs,
|
|
659
|
-
budgetMs
|
|
660
|
-
});
|
|
684
|
+
function openDelivery(state) {
|
|
685
|
+
return identityDelivery(state.paths, identityOf(state.config), state.config.delivery, state.env.now);
|
|
661
686
|
}
|
|
662
687
|
/**
|
|
663
688
|
* What the credential code needs from this run.
|
|
@@ -60,6 +60,8 @@ export function applyProductCapture(event, capture) {
|
|
|
60
60
|
// context and withheld whole without it: a digest of a command still says
|
|
61
61
|
// which command ran when.
|
|
62
62
|
tool_events: git ? undefined : withMcpPolicy(summary.tool_events, capture?.mcpNames === false),
|
|
63
|
+
// A name only, and withheld with the tool events it describes the turn beside.
|
|
64
|
+
command: git ? undefined : summary.command,
|
|
63
65
|
// The blob id is what is matched; the path beside it in older records is not read.
|
|
64
66
|
content_hashes: files ? undefined : summary.content_hashes?.map(({ blob_sha }) => ({ blob_sha })),
|
|
65
67
|
manifest_repository: files ? undefined : summary.manifest_repository,
|
|
@@ -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
|