@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,11 +1,11 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { asRecord, compact } from '../../core/object.js';
|
|
4
3
|
import { sha256Hex } from '../../events/event-id.js';
|
|
5
4
|
import { resolvePaths } from '../../storage/paths.js';
|
|
6
5
|
import { baseEvent, filePathPatch, promptPatch, responsePatch, toolCallEvidence, toolPatch, withPatch } from '../shared/event-builder.js';
|
|
7
6
|
import { classifyTool, contentEvidence, mcpServerFromEndpoint, mcpToolKey, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
|
|
8
|
-
import { ATTACHMENT_FILE_PATH_KEY, CURSOR_DEDICATED_COMPLETION_KINDS, CURSOR_DISPLAY_NAME, CURSOR_EDIT_TOOL_NAME, CURSOR_EVENT_TYPE_MAP, CURSOR_PROVIDER_ID, CURSOR_READ_TOOL_NAME, CURSOR_GENERIC_TOOL_START_EVENT, CURSOR_SHELL_COMMAND_KEY, CURSOR_SHELL_EVENTS, CURSOR_SHELL_WORKDIR_KEY, CURSOR_SHELL_TOOL_NAME, CURSOR_TOOL_KINDS, CURSOR_UNKNOWN_EVENT, CURSOR_UNKNOWN_MCP_SERVER } from './constants/cursor.constants.js';
|
|
7
|
+
import { ATTACHMENT_FILE_PATH_KEY, CURSOR_DEDICATED_COMPLETION_KINDS, CURSOR_DISPLAY_NAME, CURSOR_DROPPED_EVENTS, CURSOR_EDIT_TOOL_NAME, CURSOR_EVENT_TYPE_MAP, CURSOR_PROVIDER_ID, CURSOR_READ_TOOL_NAME, CURSOR_GENERIC_TOOL_START_EVENT, CURSOR_SHELL_COMMAND_KEY, CURSOR_SHELL_EVENTS, CURSOR_SHELL_WORKDIR_KEY, CURSOR_SHELL_TOOL_NAME, CURSOR_TOOL_KINDS, CURSOR_UNKNOWN_EVENT, CURSOR_UNKNOWN_MCP_SERVER } from './constants/cursor.constants.js';
|
|
8
|
+
import { rememberedMcpServer, rememberMcpServer } from './cursor-mcp-memo.js';
|
|
9
9
|
import { cursorPayloadSchema } from './schemas/cursor.schema.js';
|
|
10
10
|
/**
|
|
11
11
|
* Translate one Cursor hook payload into canonical events.
|
|
@@ -20,6 +20,9 @@ export function parseCursorHookEvent(rawPayload, context) {
|
|
|
20
20
|
return [];
|
|
21
21
|
const payload = parsed.data;
|
|
22
22
|
const providerEventType = payload.hook_event_name ?? CURSOR_UNKNOWN_EVENT;
|
|
23
|
+
// Until a re-install sweeps it off, an old registration still fires on every Tab accept.
|
|
24
|
+
if (CURSOR_DROPPED_EVENTS.has(providerEventType))
|
|
25
|
+
return [];
|
|
23
26
|
return [withPatch(cursorBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
@@ -81,7 +84,7 @@ function cursorBaseEvent(payload, providerEventType) {
|
|
|
81
84
|
const sessionId = payload.conversation_id ?? payload.session_id;
|
|
82
85
|
// model_id is the structured identifier and supersedes the legacy slug.
|
|
83
86
|
const model = (typeof payload.model_id === 'string' && payload.model_id.length > 0 ? payload.model_id : undefined) ?? payload.model;
|
|
84
|
-
|
|
87
|
+
const event = baseEvent({
|
|
85
88
|
provider: CURSOR_PROVIDER_ID,
|
|
86
89
|
displayName: CURSOR_DISPLAY_NAME,
|
|
87
90
|
providerEventType,
|
|
@@ -103,6 +106,9 @@ function cursorBaseEvent(payload, providerEventType) {
|
|
|
103
106
|
},
|
|
104
107
|
timestamp: new Date().toISOString()
|
|
105
108
|
});
|
|
109
|
+
// On every hook, so the Stop that closes a turn carries it to the summary.
|
|
110
|
+
const accountEmail = typeof payload.user_email === 'string' ? payload.user_email.trim() : undefined;
|
|
111
|
+
return accountEmail ? { ...event, developer: { accountEmail } } : event;
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
114
|
* What this particular hook contributes on top of the base event.
|
|
@@ -115,7 +121,7 @@ function cursorBaseEvent(payload, providerEventType) {
|
|
|
115
121
|
function hookPatch(payload, providerEventType, context) {
|
|
116
122
|
const capture = context.config.capture;
|
|
117
123
|
if (providerEventType === 'sessionStart') {
|
|
118
|
-
return {
|
|
124
|
+
return { session: compact({ mode: payload.composer_mode, isCloudAgent: payload.is_background_agent }) };
|
|
119
125
|
}
|
|
120
126
|
if (providerEventType === 'sessionEnd')
|
|
121
127
|
return { metadata: { sessionEndReason: payload.reason } };
|
|
@@ -137,8 +143,8 @@ function hookPatch(payload, providerEventType, context) {
|
|
|
137
143
|
...filePathPatch(payload.file_path, capture)
|
|
138
144
|
};
|
|
139
145
|
}
|
|
140
|
-
if (providerEventType === 'afterFileEdit'
|
|
141
|
-
return fileEditPatch(payload,
|
|
146
|
+
if (providerEventType === 'afterFileEdit') {
|
|
147
|
+
return fileEditPatch(payload, context);
|
|
142
148
|
}
|
|
143
149
|
if (providerEventType === 'subagentStart' || providerEventType === 'subagentStop') {
|
|
144
150
|
return subagentPatch(payload, providerEventType);
|
|
@@ -240,9 +246,12 @@ function mcpPatch(payload, providerEventType, context) {
|
|
|
240
246
|
// An endpoint that names no server still gets a parseable key, so mcpNames:false folds it.
|
|
241
247
|
const toolName = parsed.tool ?? payload.tool_name;
|
|
242
248
|
const endpoint = parsed.server ?? mcpServerFromEndpoint(payload.url, payload.command);
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
249
|
+
const dataDir = resolvePaths(context.env).dataDir;
|
|
250
|
+
const conversationId = payload.conversation_id;
|
|
251
|
+
const remembered = !endpoint && conversationId && toolName ? rememberedMcpServer(dataDir, conversationId, toolName) : undefined;
|
|
252
|
+
const server = endpoint ?? remembered ?? CURSOR_UNKNOWN_MCP_SERVER;
|
|
253
|
+
if (endpoint && toolName && conversationId)
|
|
254
|
+
rememberMcpServer(dataDir, conversationId, toolName, endpoint, context.env.now());
|
|
246
255
|
return {
|
|
247
256
|
tool: {
|
|
248
257
|
name: toolName ? mcpToolKey(server, toolName) : payload.tool_name,
|
|
@@ -261,90 +270,19 @@ function mcpPatch(payload, providerEventType, context) {
|
|
|
261
270
|
};
|
|
262
271
|
}
|
|
263
272
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* `afterMCPExecution` carries neither url nor command, and only completions
|
|
267
|
-
* become turn records, so the server the before-hook saw has to outlive it.
|
|
273
|
+
* File-edit fields for `afterFileEdit`, Cursor's dedicated edit hook.
|
|
268
274
|
*
|
|
269
275
|
* @param payload - Parsed hook payload.
|
|
270
|
-
* @param context - Environment.
|
|
271
|
-
* @returns The state file, or undefined without a conversation id.
|
|
272
|
-
*/
|
|
273
|
-
function mcpMemoFile(payload, context) {
|
|
274
|
-
if (!payload.conversation_id)
|
|
275
|
-
return undefined;
|
|
276
|
-
return path.join(resolvePaths(context.env).dataDir, 'cursor-mcp', `${sha256Hex(payload.conversation_id).slice(0, 32)}.json`);
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Remembers which server a tool resolved to, for the completion hook.
|
|
280
|
-
*
|
|
281
|
-
* ponytail: one tiny file per conversation, last write wins per tool name, never
|
|
282
|
-
* pruned (the data dir is disposable); two servers exposing the same tool name
|
|
283
|
-
* in one conversation share an entry. Upgrade: key by tool_use_id if Cursor sends it.
|
|
284
|
-
*
|
|
285
|
-
* @param payload - Parsed hook payload.
|
|
286
|
-
* @param tool - Tool name.
|
|
287
|
-
* @param server - Resolved server.
|
|
288
|
-
* @param context - Environment.
|
|
289
|
-
*/
|
|
290
|
-
function rememberMcpServer(payload, tool, server, context) {
|
|
291
|
-
const file = mcpMemoFile(payload, context);
|
|
292
|
-
if (!file)
|
|
293
|
-
return;
|
|
294
|
-
try {
|
|
295
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
296
|
-
fs.writeFileSync(file, JSON.stringify({ ...readMcpMemo(file), [tool]: server }), { mode: 0o600 });
|
|
297
|
-
}
|
|
298
|
-
catch {
|
|
299
|
-
// Hooks never fail the agent; the completion just keys as unknown.
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* The server a tool resolved to in this conversation's before-hook.
|
|
304
|
-
*
|
|
305
|
-
* @param payload - Parsed hook payload.
|
|
306
|
-
* @param tool - Tool name.
|
|
307
|
-
* @param context - Environment.
|
|
308
|
-
* @returns The server, or undefined when none was remembered.
|
|
309
|
-
*/
|
|
310
|
-
function rememberedMcpServer(payload, tool, context) {
|
|
311
|
-
const file = mcpMemoFile(payload, context);
|
|
312
|
-
if (!file || !tool)
|
|
313
|
-
return undefined;
|
|
314
|
-
const server = readMcpMemo(file)[tool];
|
|
315
|
-
return typeof server === 'string' ? server : undefined;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Reads a conversation's MCP memo.
|
|
319
|
-
*
|
|
320
|
-
* @param file - Memo file.
|
|
321
|
-
* @returns Its contents, empty when missing or unreadable.
|
|
322
|
-
*/
|
|
323
|
-
function readMcpMemo(file) {
|
|
324
|
-
try {
|
|
325
|
-
return asRecord(JSON.parse(fs.readFileSync(file, 'utf8'))) ?? {};
|
|
326
|
-
}
|
|
327
|
-
catch {
|
|
328
|
-
return {};
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* File-edit fields for Cursor's dedicated edit hooks.
|
|
333
|
-
*
|
|
334
|
-
* @param payload - Parsed hook payload.
|
|
335
|
-
* @param providerEventType - Cursor's own name for this hook.
|
|
336
276
|
* @param context - Environment and effective config.
|
|
337
277
|
* @returns The patch.
|
|
338
278
|
*/
|
|
339
|
-
function fileEditPatch(payload,
|
|
279
|
+
function fileEditPatch(payload, context) {
|
|
340
280
|
const capture = context.config.capture;
|
|
341
281
|
const pathPatch = filePathPatch(payload.file_path, capture);
|
|
342
282
|
return {
|
|
343
283
|
tool: { name: payload.tool_name ?? CURSOR_EDIT_TOOL_NAME, status: 'completed' },
|
|
344
284
|
metadata: compact({
|
|
345
285
|
...pathPatch.metadata,
|
|
346
|
-
// Tab edits are the editor's inline completion, not an agent tool call.
|
|
347
|
-
tab: providerEventType === 'afterTabFileEdit' ? true : undefined,
|
|
348
286
|
toolOutput: capture.toolOutput && payload.edits !== undefined ? payload.edits : undefined
|
|
349
287
|
})
|
|
350
288
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cursorCapture: import("../shared/terminal-capture.js").TerminalCapture;
|
|
@@ -10,7 +10,11 @@ export declare function cursorHooksJsonPath(env: Env): string;
|
|
|
10
10
|
/**
|
|
11
11
|
* Whether Cursor is installed here, and whether our hooks are registered.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* A project's `.cursor` folder (rules, MCP config) is checked in and is there
|
|
14
|
+
* on machines without Cursor, so only its `hooks.json` counts: that is how a
|
|
15
|
+
* cloud agent, with no `~/.cursor` and no executable, runs our hooks.
|
|
16
|
+
*
|
|
17
|
+
* @param env - Environment supplying HOME, PATH and cwd (for a project `.cursor/hooks.json`).
|
|
14
18
|
* @returns What was found.
|
|
15
19
|
*/
|
|
16
20
|
export declare function detectCursor(env: Env): Promise<DetectionResult>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
|
|
3
|
+
import { findFirstExecutable } from '../../core/which.js';
|
|
4
|
+
import { hooksMarkerPresent } from '../shared/hooks-marker.js';
|
|
6
5
|
import { CURSOR_EXECUTABLES, CURSOR_HOME_DIR, CURSOR_HOOKS_FILE } from './constants/cursor.constants.js';
|
|
7
6
|
/**
|
|
8
7
|
* Cursor's configuration root.
|
|
@@ -25,42 +24,28 @@ export function cursorHooksJsonPath(env) {
|
|
|
25
24
|
/**
|
|
26
25
|
* Whether Cursor is installed here, and whether our hooks are registered.
|
|
27
26
|
*
|
|
28
|
-
*
|
|
27
|
+
* A project's `.cursor` folder (rules, MCP config) is checked in and is there
|
|
28
|
+
* on machines without Cursor, so only its `hooks.json` counts: that is how a
|
|
29
|
+
* cloud agent, with no `~/.cursor` and no executable, runs our hooks.
|
|
30
|
+
*
|
|
31
|
+
* @param env - Environment supplying HOME, PATH and cwd (for a project `.cursor/hooks.json`).
|
|
29
32
|
* @returns What was found.
|
|
30
33
|
*/
|
|
31
34
|
export async function detectCursor(env) {
|
|
32
35
|
const evidence = [];
|
|
33
36
|
if (fs.existsSync(cursorHome(env)))
|
|
34
37
|
evidence.push('~/.cursor directory exists');
|
|
35
|
-
if (fs.existsSync(path.join(env.cwd, CURSOR_HOME_DIR)))
|
|
36
|
-
evidence.push('.cursor
|
|
37
|
-
const executablePath = findFirstExecutable(env);
|
|
38
|
+
if (fs.existsSync(path.join(env.cwd, CURSOR_HOME_DIR, CURSOR_HOOKS_FILE)))
|
|
39
|
+
evidence.push('.cursor/hooks.json in working tree');
|
|
40
|
+
const executablePath = findFirstExecutable(env, CURSOR_EXECUTABLES);
|
|
38
41
|
if (executablePath)
|
|
39
42
|
evidence.push(`cursor executable on PATH (${executablePath})`);
|
|
40
43
|
const hookConfigPath = cursorHooksJsonPath(env);
|
|
41
|
-
const hooksFile = await readJsonFile(hookConfigPath);
|
|
42
44
|
return {
|
|
43
45
|
detected: evidence.length > 0,
|
|
44
46
|
evidence,
|
|
45
47
|
executablePath,
|
|
46
48
|
hookConfigPath,
|
|
47
|
-
hooksInstalled:
|
|
49
|
+
hooksInstalled: await hooksMarkerPresent(hookConfigPath)
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
|
-
/**
|
|
51
|
-
* The first of Cursor's executable names found on PATH.
|
|
52
|
-
*
|
|
53
|
-
* The editor ships `cursor`; the CLI agent ships `cursor-agent`, and a machine
|
|
54
|
-
* may have either.
|
|
55
|
-
*
|
|
56
|
-
* @param env - Environment supplying PATH.
|
|
57
|
-
* @returns The path, or undefined when neither is installed.
|
|
58
|
-
*/
|
|
59
|
-
function findFirstExecutable(env) {
|
|
60
|
-
for (const name of CURSOR_EXECUTABLES) {
|
|
61
|
-
const found = findExecutable(env, name);
|
|
62
|
-
if (found)
|
|
63
|
-
return found;
|
|
64
|
-
}
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
@@ -4,7 +4,7 @@ import { readJsonFile } from '../../storage/json-file.js';
|
|
|
4
4
|
import { registerOurHandlers, stripOurHandlers, sweepUnregisteredEvents, writeJsonValidated } from '../shared/hook-config.js';
|
|
5
5
|
import { withHookInstall, withoutHookInstall } from '../shared/install-record.js';
|
|
6
6
|
import { cursorHooksJsonPath } from './cursor.detect.js';
|
|
7
|
-
import { CURSOR_HOOKS_VERSION, CURSOR_HOOK_EVENTS, CURSOR_HOOK_TIMEOUT_SECONDS, CURSOR_PROVIDER_ID,
|
|
7
|
+
import { CURSOR_HOOKS_VERSION, CURSOR_HOOK_EVENTS, CURSOR_HOOK_TIMEOUT_SECONDS, CURSOR_PROVIDER_ID, CURSOR_VERSION_KEY } from './constants/cursor.constants.js';
|
|
8
8
|
export { CURSOR_HOOK_EVENTS } from './constants/cursor.constants.js';
|
|
9
9
|
/**
|
|
10
10
|
* Register AgentWatch's hooks in `~/.cursor/hooks.json`.
|
|
@@ -43,7 +43,7 @@ export async function installCursorHooks(context) {
|
|
|
43
43
|
return {
|
|
44
44
|
ok: true,
|
|
45
45
|
changed,
|
|
46
|
-
messages: [changed ? `hooks registered in ${hooksPath}` : 'hooks already registered'
|
|
46
|
+
messages: [changed ? `hooks registered in ${hooksPath}` : 'hooks already registered'],
|
|
47
47
|
installState: withHookInstall(context.installState, CURSOR_PROVIDER_ID, {
|
|
48
48
|
hookConfigPath: hooksPath,
|
|
49
49
|
hookEvents: CURSOR_HOOK_EVENTS,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { IDE_SURFACE } from '../../turns/constants/turns.constants.js';
|
|
1
2
|
import { hookRefusal } from '../shared/hook-refusal.js';
|
|
2
|
-
import { CURSOR_PROMPT_SUBMIT_EVENTS } from './constants/cursor.constants.js';
|
|
3
|
+
import { CURSOR_CAVEATS, CURSOR_PROMPT_SUBMIT_EVENTS } from './constants/cursor.constants.js';
|
|
4
|
+
import { cursorCapture } from './cursor.capture.js';
|
|
3
5
|
import { detectCursor } from './cursor.detect.js';
|
|
4
6
|
import { installCursorHooks, uninstallCursorHooks } from './cursor.hooks.js';
|
|
7
|
+
import { readCursorSessionTitles } from './cursor.titles.js';
|
|
5
8
|
import { cursorCwd, cursorShellCall, cursorWorkspaceRoots, parseCursorHookEvent } from './cursor.adapter.js';
|
|
6
9
|
export const cursorProvider = {
|
|
7
10
|
id: 'cursor',
|
|
8
11
|
displayName: 'Cursor',
|
|
9
12
|
detect: detectCursor,
|
|
10
|
-
installHooks: installCursorHooks,
|
|
11
|
-
uninstallHooks: uninstallCursorHooks,
|
|
13
|
+
installHooks: cursorCapture.install(installCursorHooks),
|
|
14
|
+
uninstallHooks: cursorCapture.uninstall(uninstallCursorHooks),
|
|
15
|
+
runCapture: cursorCapture.route,
|
|
12
16
|
parseHookEvent: async (payload, context) => parseCursorHookEvent(payload, context),
|
|
13
17
|
/**
|
|
14
18
|
* Cursor's before* hooks fail open and treat an absent `permission` field
|
|
@@ -23,8 +27,13 @@ export const cursorProvider = {
|
|
|
23
27
|
getBlockResponse: (payload, message) => hookRefusal(payload, CURSOR_PROMPT_SUBMIT_EVENTS, { continue: false, user_message: message }),
|
|
24
28
|
resolveCwd: cursorCwd,
|
|
25
29
|
shellCall: cursorShellCall,
|
|
26
|
-
workspaceRoots: cursorWorkspaceRoots
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
workspaceRoots: cursorWorkspaceRoots,
|
|
31
|
+
caveats: CURSOR_CAVEATS,
|
|
32
|
+
readSessionTitles: readCursorSessionTitles,
|
|
33
|
+
surface: async () => IDE_SURFACE,
|
|
34
|
+
/** `composer_mode` and `is_background_agent` come on sessionStart alone. */
|
|
35
|
+
namesSessionMode: true
|
|
36
|
+
// No nativeTelemetry and no readTurnUsage: Cursor has no OTel export and its
|
|
37
|
+
// transcripts carry no usage, so turn summaries stay usage_status=pending.
|
|
38
|
+
// Cursor cost comes from the Cursor Admin API connection in Integrations.
|
|
30
39
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Env } from '../../core/types/core.types.js';
|
|
2
|
+
import type { SessionTitles } from '../../turns/types/transcript.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read Cursor's generated conversation title from its local search index.
|
|
5
|
+
*
|
|
6
|
+
* Cursor exposes no title in hooks or transcripts. The desktop app's search
|
|
7
|
+
* index keys the same conversation id the hook sends; Cursor keeps custom and
|
|
8
|
+
* generated titles in one display field, so it maps to `session_title`.
|
|
9
|
+
*
|
|
10
|
+
* @param env - Environment locating Cursor's platform data directory.
|
|
11
|
+
* @param sessionId - Cursor conversation id from the hook payload.
|
|
12
|
+
* @returns Cursor's display title, or neither when unavailable.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readCursorSessionTitles(env: Env, sessionId: string): Promise<SessionTitles>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { readTitles, sqliteModule } from '../shared/session-title-store.js';
|
|
3
|
+
import { editorConfigRoot } from '../shared/editor-paths.js';
|
|
4
|
+
/**
|
|
5
|
+
* Read Cursor's generated conversation title from its local search index.
|
|
6
|
+
*
|
|
7
|
+
* Cursor exposes no title in hooks or transcripts. The desktop app's search
|
|
8
|
+
* index keys the same conversation id the hook sends; Cursor keeps custom and
|
|
9
|
+
* generated titles in one display field, so it maps to `session_title`.
|
|
10
|
+
*
|
|
11
|
+
* @param env - Environment locating Cursor's platform data directory.
|
|
12
|
+
* @param sessionId - Cursor conversation id from the hook payload.
|
|
13
|
+
* @returns Cursor's display title, or neither when unavailable.
|
|
14
|
+
*/
|
|
15
|
+
export async function readCursorSessionTitles(env, sessionId) {
|
|
16
|
+
const sqlite = sqliteModule();
|
|
17
|
+
if (!sqlite)
|
|
18
|
+
return {};
|
|
19
|
+
return readTitles(sqlite, path.join(editorConfigRoot(env), 'Cursor', 'User', 'globalStorage', 'conversation-search.db'), "SELECT title FROM conversations WHERE source = 'local' AND scope = '' AND id = ?", sessionId);
|
|
20
|
+
}
|
|
@@ -18,9 +18,10 @@ export declare const cursorPayloadSchema: z.ZodObject<{
|
|
|
18
18
|
workspace_roots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
19
|
transcript_path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
20
20
|
cwd: z.ZodOptional<z.ZodString>;
|
|
21
|
+
user_email: z.ZodOptional<z.ZodUnknown>;
|
|
21
22
|
session_id: z.ZodOptional<z.ZodString>;
|
|
22
|
-
is_background_agent: z.ZodOptional<z.ZodBoolean
|
|
23
|
-
composer_mode: z.ZodOptional<z.ZodString
|
|
23
|
+
is_background_agent: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
|
|
24
|
+
composer_mode: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
24
25
|
reason: z.ZodOptional<z.ZodString>;
|
|
25
26
|
prompt: z.ZodOptional<z.ZodString>;
|
|
26
27
|
attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
@@ -41,7 +42,6 @@ export declare const cursorPayloadSchema: z.ZodObject<{
|
|
|
41
42
|
subagent_id: z.ZodOptional<z.ZodString>;
|
|
42
43
|
subagent_type: z.ZodOptional<z.ZodString>;
|
|
43
44
|
subagent_model: z.ZodOptional<z.ZodString>;
|
|
44
|
-
parent_conversation_id: z.ZodOptional<z.ZodString>;
|
|
45
45
|
task: z.ZodOptional<z.ZodString>;
|
|
46
46
|
status: z.ZodOptional<z.ZodString>;
|
|
47
47
|
text: z.ZodOptional<z.ZodString>;
|
|
@@ -21,10 +21,13 @@ export const cursorPayloadSchema = z
|
|
|
21
21
|
workspace_roots: z.array(z.string()).optional(),
|
|
22
22
|
transcript_path: z.string().nullable().optional(),
|
|
23
23
|
cwd: z.string().optional(),
|
|
24
|
+
// Null when no one is signed in. Unknown, like model_id: a type change must never drop the event.
|
|
25
|
+
user_email: z.unknown().optional(),
|
|
24
26
|
// sessionStart / sessionEnd
|
|
25
27
|
session_id: z.string().optional(),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
// Dropped, not refused, when malformed: the session mode is optional context.
|
|
29
|
+
is_background_agent: z.boolean().optional().catch(undefined),
|
|
30
|
+
composer_mode: z.string().optional().catch(undefined),
|
|
28
31
|
reason: z.string().optional(),
|
|
29
32
|
// beforeSubmitPrompt
|
|
30
33
|
prompt: z.string().optional(),
|
|
@@ -50,7 +53,6 @@ export const cursorPayloadSchema = z
|
|
|
50
53
|
subagent_id: z.string().optional(),
|
|
51
54
|
subagent_type: z.string().optional(),
|
|
52
55
|
subagent_model: z.string().optional(),
|
|
53
|
-
parent_conversation_id: z.string().optional(),
|
|
54
56
|
task: z.string().optional(),
|
|
55
57
|
status: z.string().optional(),
|
|
56
58
|
// afterAgentResponse
|
|
@@ -8,6 +8,22 @@ export declare const GEMINI_SETTINGS_FILE = "settings.json";
|
|
|
8
8
|
/** Gemini's own env file: it loads this at start, unlike the settings.json `env` block. */
|
|
9
9
|
export declare const GEMINI_ENV_FILE = ".env";
|
|
10
10
|
export declare const GEMINI_EXECUTABLES: readonly ["gemini", "gemini-cli"];
|
|
11
|
+
/**
|
|
12
|
+
* Entries of the Gemini home that only Gemini CLI creates: its per-project
|
|
13
|
+
* session directory and its install id.
|
|
14
|
+
*
|
|
15
|
+
* The home directory alone proves nothing: Antigravity shares `~/.gemini` for
|
|
16
|
+
* its hooks.json, its CLI, its app data and the Google sign-in files
|
|
17
|
+
* (`oauth_creds.json`, `google_accounts.json`), so a machine with only
|
|
18
|
+
* Antigravity has one too. `settings.json` is judged separately, because
|
|
19
|
+
* AgentWatch setup writes one itself.
|
|
20
|
+
*/
|
|
21
|
+
export declare const GEMINI_HOME_EVIDENCE: readonly ["tmp", "installation_id"];
|
|
22
|
+
/**
|
|
23
|
+
* settings.json keys AgentWatch writes, now or in earlier releases. A file that
|
|
24
|
+
* holds nothing else was created by our setup, not by Gemini CLI.
|
|
25
|
+
*/
|
|
26
|
+
export declare const GEMINI_SETTINGS_KEYS_WE_WRITE: ReadonlySet<string>;
|
|
11
27
|
/** Hook events AgentWatch registers in Gemini CLI. */
|
|
12
28
|
export declare const GEMINI_HOOK_EVENTS: readonly ["SessionStart", "SessionEnd", "BeforeAgent", "AfterAgent", "BeforeTool", "AfterTool", "Notification", "PreCompress"];
|
|
13
29
|
/** Events that take a matcher; "*" observes everything. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ENV_BLOCK_KEY, LEGACY_HELPER_KEY, TELEMETRY_BLOCK_KEY } from './gemini.otel.constants.js';
|
|
1
2
|
export const GEMINI_PROVIDER_ID = 'gemini';
|
|
2
3
|
export const GEMINI_DISPLAY_NAME = 'Gemini CLI';
|
|
3
4
|
export const GEMINI_HOME_VAR = 'GEMINI_HOME';
|
|
@@ -7,6 +8,22 @@ export const GEMINI_SETTINGS_FILE = 'settings.json';
|
|
|
7
8
|
/** Gemini's own env file: it loads this at start, unlike the settings.json `env` block. */
|
|
8
9
|
export const GEMINI_ENV_FILE = '.env';
|
|
9
10
|
export const GEMINI_EXECUTABLES = ['gemini', 'gemini-cli'];
|
|
11
|
+
/**
|
|
12
|
+
* Entries of the Gemini home that only Gemini CLI creates: its per-project
|
|
13
|
+
* session directory and its install id.
|
|
14
|
+
*
|
|
15
|
+
* The home directory alone proves nothing: Antigravity shares `~/.gemini` for
|
|
16
|
+
* its hooks.json, its CLI, its app data and the Google sign-in files
|
|
17
|
+
* (`oauth_creds.json`, `google_accounts.json`), so a machine with only
|
|
18
|
+
* Antigravity has one too. `settings.json` is judged separately, because
|
|
19
|
+
* AgentWatch setup writes one itself.
|
|
20
|
+
*/
|
|
21
|
+
export const GEMINI_HOME_EVIDENCE = ['tmp', 'installation_id'];
|
|
22
|
+
/**
|
|
23
|
+
* settings.json keys AgentWatch writes, now or in earlier releases. A file that
|
|
24
|
+
* holds nothing else was created by our setup, not by Gemini CLI.
|
|
25
|
+
*/
|
|
26
|
+
export const GEMINI_SETTINGS_KEYS_WE_WRITE = new Set(['hooks', TELEMETRY_BLOCK_KEY, ENV_BLOCK_KEY, LEGACY_HELPER_KEY]);
|
|
10
27
|
/** Hook events AgentWatch registers in Gemini CLI. */
|
|
11
28
|
export const GEMINI_HOOK_EVENTS = ['SessionStart', 'SessionEnd', 'BeforeAgent', 'AfterAgent', 'BeforeTool', 'AfterTool', 'Notification', 'PreCompress'];
|
|
12
29
|
/** Events that take a matcher; "*" observes everything. */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { RunCaptureStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `.env` text.
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - The file.
|
|
6
|
+
* @returns Its contents, undefined when there is none, or null when it cannot
|
|
7
|
+
* be read (so it is never replaced by a file holding only our lines).
|
|
8
|
+
*/
|
|
9
|
+
export declare function readEnvFile(filePath: string): Promise<string | undefined | null>;
|
|
10
|
+
/**
|
|
11
|
+
* The `KEY=value` lines of a dotenv file, the last one winning as in Gemini's
|
|
12
|
+
* loader. Quotes around a value and a trailing comment are dropped, as dotenv does: a
|
|
13
|
+
* comment kept here would be merged into `NODE_OPTIONS` as a real option.
|
|
14
|
+
*
|
|
15
|
+
* @param raw - File contents.
|
|
16
|
+
* @returns Values by key.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseEnv(raw: string): Readonly<Record<string, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* The `.env` text with `set` written and `drop` removed; every other line,
|
|
21
|
+
* comments included, stays as it was.
|
|
22
|
+
*
|
|
23
|
+
* @param raw - Current contents.
|
|
24
|
+
* @param set - Whole lines by key: replacing that key's line where it stands,
|
|
25
|
+
* appended otherwise.
|
|
26
|
+
* @param drop - Keys to remove.
|
|
27
|
+
* @returns The next contents; `raw` itself when nothing changes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rewriteEnv(raw: string, set: Readonly<Record<string, string>>, drop: ReadonlySet<string>): string;
|
|
30
|
+
/**
|
|
31
|
+
* A `.env` Gemini would load from this folder in place of ours.
|
|
32
|
+
*
|
|
33
|
+
* Mirrors Gemini's lookup for a trusted folder: walking up, `<dir>/.gemini/.env`
|
|
34
|
+
* then `<dir>/.env`, the first found wins. (In an untrusted folder Gemini skips
|
|
35
|
+
* ours anyway.)
|
|
36
|
+
*
|
|
37
|
+
* @param cwd - The folder Gemini starts in.
|
|
38
|
+
* @param ours - Our `.env`.
|
|
39
|
+
* @returns The shadowing file, or undefined when ours is the one loaded.
|
|
40
|
+
*/
|
|
41
|
+
export declare function shadowingEnvFile(cwd: string, ours: string): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Merge the two keys into `~/.gemini/.env`, as owned as a key can be without being
|
|
44
|
+
* recorded: only our part of each ever goes.
|
|
45
|
+
*
|
|
46
|
+
* Only the file's own value moves in, not the ambient one. Gemini's loader never
|
|
47
|
+
* overrides what the shell set (`inspectGeminiCapture` says when that hides ours), so
|
|
48
|
+
* copying the shell's value here would only spread it to shells that do not have it.
|
|
49
|
+
*
|
|
50
|
+
* @param context - Environment and paths.
|
|
51
|
+
* @param source - The package's shims.
|
|
52
|
+
* @returns Whether the file changed, and what to tell the developer.
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyGeminiCapture(context: SetupContext, source?: {
|
|
55
|
+
node: string;
|
|
56
|
+
python: string;
|
|
57
|
+
}): Promise<SetupOutcome>;
|
|
58
|
+
/**
|
|
59
|
+
* Take our part of the two keys out, then the shared copy once nothing else needs it.
|
|
60
|
+
*
|
|
61
|
+
* @param context - Environment and paths.
|
|
62
|
+
* @returns Whether the file changed, and what to tell the developer.
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeGeminiCapture(context: SetupContext): Promise<SetupOutcome>;
|
|
65
|
+
/**
|
|
66
|
+
* Whether what Gemini's shell tool starts loads the shims, and when not, why.
|
|
67
|
+
*
|
|
68
|
+
* Gemini's loader (`loadEnvironment`, read in 0.46.0's bundle) reads the first `.env`
|
|
69
|
+
* found walking up and never overrides a variable the shell set, so either can hide ours.
|
|
70
|
+
*
|
|
71
|
+
* ponytail: it also skips these keys in a folder the developer has not trusted. That is
|
|
72
|
+
* per folder and lives in Gemini's own trust file, so it is not read here.
|
|
73
|
+
*
|
|
74
|
+
* @param context - Environment, paths and config.
|
|
75
|
+
* @param source - The package's shims.
|
|
76
|
+
* @returns On, or off with the reason.
|
|
77
|
+
*/
|
|
78
|
+
export declare function inspectGeminiCapture(context: SetupContext, source?: {
|
|
79
|
+
node: string;
|
|
80
|
+
python: string;
|
|
81
|
+
}): Promise<RunCaptureStatus>;
|