@agent-watch-ai/edge 0.7.0 → 0.7.2
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 +92 -0
- package/README.md +4 -1
- package/dist/billing/session-billing.d.ts +5 -2
- package/dist/billing/session-billing.js +27 -6
- package/dist/capture/capture-env.d.ts +3 -3
- package/dist/capture/capture-env.js +5 -5
- package/dist/capture/captured-step.js +24 -0
- package/dist/capture/constants/capture.constants.d.ts +15 -0
- package/dist/capture/constants/capture.constants.js +15 -0
- package/dist/capture/launched-runs.d.ts +27 -0
- package/dist/capture/launched-runs.js +15 -9
- package/dist/capture/python/sitecustomize.py +11 -2
- 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 +21 -0
- package/dist/cli/constants/cli.constants.js +22 -1
- package/dist/cli/doctor-run-capture.d.ts +8 -0
- package/dist/cli/doctor-run-capture.js +14 -0
- package/dist/cli/doctor.js +6 -2
- package/dist/cli/hook-check.d.ts +7 -2
- package/dist/cli/hook-check.js +30 -15
- package/dist/cli/hook.js +44 -3
- 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.js +42 -7
- package/dist/cli/setup.js +71 -7
- package/dist/cli/types/cli.types.d.ts +2 -0
- package/dist/cli/uninstall.js +34 -1
- package/dist/cli/update.js +3 -2
- package/dist/cli.js +4 -1
- package/dist/config/config-store.d.ts +15 -4
- package/dist/config/config-store.js +31 -7
- package/dist/config/config.d.ts +8 -0
- package/dist/config/config.js +10 -0
- package/dist/config/constants/config.constants.d.ts +13 -1
- package/dist/config/constants/config.constants.js +13 -1
- package/dist/config/repo-config.js +7 -2
- package/dist/config/schemas/config.schema.d.ts +6 -2
- package/dist/config/schemas/config.schema.js +17 -3
- package/dist/credentials/cloud-claim.d.ts +2 -0
- package/dist/credentials/cloud-claim.js +21 -2
- package/dist/credentials/constants/credentials.constants.d.ts +8 -0
- package/dist/credentials/constants/credentials.constants.js +8 -0
- 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/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/enforcement/enforcement.js +1 -1
- package/dist/events/enrich.d.ts +14 -0
- package/dist/events/enrich.js +1 -1
- package/dist/git/constants/git.constants.d.ts +2 -0
- package/dist/git/constants/git.constants.js +9 -0
- package/dist/git/repo-snapshot.js +8 -2
- package/dist/git/types/snapshot.types.d.ts +4 -0
- package/dist/pipeline/hook-pipeline.js +5 -2
- package/dist/providers/antigravity/antigravity.adapter.d.ts +14 -0
- package/dist/providers/antigravity/antigravity.adapter.js +86 -18
- package/dist/providers/antigravity/antigravity.provider.js +7 -4
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +10 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +10 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.js +7 -13
- package/dist/providers/claude/claude.otel.d.ts +33 -1
- package/dist/providers/claude/claude.otel.js +81 -12
- package/dist/providers/claude/claude.provider.js +12 -6
- package/dist/providers/codex/codex.capture.d.ts +1 -1
- package/dist/providers/codex/codex.capture.js +3 -3
- package/dist/providers/codex/codex.otel.js +2 -2
- package/dist/providers/codex/codex.provider.js +2 -1
- package/dist/providers/gemini/gemini.capture.js +2 -2
- package/dist/providers/gemini/gemini.otel.js +2 -2
- package/dist/providers/gemini/gemini.provider.js +2 -1
- package/dist/providers/shared/terminal-capture.js +3 -3
- package/dist/providers/types/provider.types.d.ts +5 -5
- package/dist/replay/checkout-resolver.d.ts +41 -14
- package/dist/replay/checkout-resolver.js +134 -30
- package/dist/replay/replay-runner.d.ts +3 -1
- package/dist/replay/replay-runner.js +74 -22
- package/dist/replay/replay-scan.d.ts +2 -1
- package/dist/replay/replay-scan.js +14 -2
- package/dist/replay/throttle.d.ts +2 -1
- package/dist/replay/throttle.js +4 -1
- package/dist/replay/transcript-turns.js +29 -3
- package/dist/replay/turn-event.d.ts +4 -2
- package/dist/replay/turn-event.js +22 -11
- package/dist/replay/types/replay.types.d.ts +39 -3
- package/dist/replay/worktree-map.d.ts +42 -0
- package/dist/replay/worktree-map.js +134 -0
- package/dist/snapshot/snapshot-pipeline.js +15 -4
- package/dist/snapshot/types/snapshot.types.d.ts +2 -0
- package/dist/turns/antigravity-transcript.d.ts +40 -0
- package/dist/turns/antigravity-transcript.js +102 -0
- package/dist/turns/claude-transcript.d.ts +35 -1
- package/dist/turns/claude-transcript.js +185 -2
- package/dist/turns/codex-transcript.d.ts +22 -1
- package/dist/turns/codex-transcript.js +161 -2
- package/dist/turns/constants/turns.constants.d.ts +67 -0
- package/dist/turns/constants/turns.constants.js +67 -0
- package/dist/turns/gemini-transcript.d.ts +17 -1
- package/dist/turns/gemini-transcript.js +36 -2
- package/dist/turns/transcript.d.ts +31 -1
- package/dist/turns/transcript.js +74 -0
- package/dist/turns/turn-state.d.ts +51 -1
- package/dist/turns/turn-state.js +124 -10
- package/dist/turns/turn-tracker.js +156 -18
- package/dist/turns/types/transcript.types.d.ts +25 -0
- package/dist/turns/types/turn-provider.types.d.ts +18 -1
- package/dist/turns/types/turn-state.types.d.ts +10 -0
- package/docs/DATA_HANDLING.md +11 -6
- package/docs/ENTERPRISE_DEPLOYMENT.md +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { copiedShims, inspectCaptureEnv, installedCaptureEnv, removeCaptureCopy, shimPaths, withoutCaptureEnv } from '../../capture/capture-env.js';
|
|
2
|
+
import { copiedShims, inspectCaptureEnv, installedCaptureEnv, removeCaptureCopy, shimPaths, skippedOnError, withoutCaptureEnv } from '../../capture/capture-env.js';
|
|
3
3
|
import { asRecord, omitKeys } from '../../core/object.js';
|
|
4
|
-
import { enabledSignalNames, otelEnabled, otlpBaseUrl } from '../../config/config.js';
|
|
4
|
+
import { enabledSignalNames, otelEnabled, otlpBaseUrl, runCaptureEnabled } from '../../config/config.js';
|
|
5
5
|
import { isAgentWatchEndpoint } from '../../config/schemas/config.schema.js';
|
|
6
6
|
import { backupFile } from '../../storage/atomic-file.js';
|
|
7
7
|
import { hasCredential } from '../../credentials/identity.js';
|
|
@@ -116,13 +116,13 @@ export class ClaudeOtelConfigurator {
|
|
|
116
116
|
constructor(captureSource = shimPaths()) {
|
|
117
117
|
this.captureSource = captureSource;
|
|
118
118
|
}
|
|
119
|
-
/** Run capture rides in the same env block,
|
|
119
|
+
/** Run capture rides in the same env block, on its own switch (`capture.runs`), not the exporters'. */
|
|
120
120
|
runCapture = {
|
|
121
121
|
configPath: claudeSettingsPath,
|
|
122
122
|
inspect: async (context) => {
|
|
123
123
|
const read = await readJsonFile(claudeSettingsPath(context.env));
|
|
124
124
|
const block = asRecord(read.state === 'ok' ? asRecord(read.value)?.[ENV_BLOCK_KEY] : undefined) ?? {};
|
|
125
|
-
return inspectCaptureEnv(block, context.config,
|
|
125
|
+
return inspectCaptureEnv(block, context.config, runCaptureEnabled(context.config), context.paths.dataDir, this.captureSource);
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
/**
|
|
@@ -195,11 +195,13 @@ export class ClaudeOtelConfigurator {
|
|
|
195
195
|
const ownedKeys = this.ownedKeys(context);
|
|
196
196
|
const conflicting = foreignKeys(envBlock, desired, ownedKeys, context);
|
|
197
197
|
if (conflicting.length > 0) {
|
|
198
|
+
// The developer's own exporter skips ours, never the capture switch.
|
|
199
|
+
const capture = await this.captureOnly(context);
|
|
198
200
|
return {
|
|
199
201
|
ok: false,
|
|
200
|
-
changed:
|
|
202
|
+
changed: capture.changed,
|
|
201
203
|
conflict: true,
|
|
202
|
-
messages: [`skipping native OpenTelemetry: ${conflicting.join(', ')} already set in ${settingsPath} (not AgentWatch-owned)
|
|
204
|
+
messages: [`skipping native OpenTelemetry: ${conflicting.join(', ')} already set in ${settingsPath} (not AgentWatch-owned)`, ...capture.messages]
|
|
203
205
|
};
|
|
204
206
|
}
|
|
205
207
|
// Signals disabled since the previous run leave stale AgentWatch-owned keys
|
|
@@ -208,10 +210,11 @@ export class ClaudeOtelConfigurator {
|
|
|
208
210
|
const previous = otelPriorValuesOf(context.installState, CLAUDE_PROVIDER_ID);
|
|
209
211
|
const stale = new Set(ownedKeys.filter((key) => key !== HEADERS_HELPER_KEY && desired[key] === undefined));
|
|
210
212
|
// Merged, never recorded as owned: uninstall takes our part of these two, not the keys.
|
|
211
|
-
const withEnv = { ...settings, [ENV_BLOCK_KEY]: { ...withRestored(await
|
|
213
|
+
const withEnv = { ...settings, [ENV_BLOCK_KEY]: { ...withRestored(await this.capturedEnv(envBlock, context), stale, restoredEnv(previous, stale)), ...desired } };
|
|
212
214
|
const helper = this.applyHeadersHelper(withEnv, context);
|
|
213
215
|
if ('conflict' in helper) {
|
|
214
|
-
|
|
216
|
+
const capture = await this.captureOnly(context);
|
|
217
|
+
return { ok: false, changed: capture.changed, conflict: true, messages: [helper.conflict, ...capture.messages] };
|
|
215
218
|
}
|
|
216
219
|
const changed = JSON.stringify(helper.settings) !== JSON.stringify(settings);
|
|
217
220
|
if (changed) {
|
|
@@ -246,6 +249,16 @@ export class ClaudeOtelConfigurator {
|
|
|
246
249
|
* install state.
|
|
247
250
|
*/
|
|
248
251
|
async uninstall(context) {
|
|
252
|
+
return this.removeTelemetry(context, false);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Uninstall's work, optionally leaving run capture's part of the env block.
|
|
256
|
+
*
|
|
257
|
+
* @param context - Environment, paths, config and install state.
|
|
258
|
+
* @param keepCapture - Leave run capture in: `otel: none` with `capture.runs` on.
|
|
259
|
+
* @returns As `uninstall`.
|
|
260
|
+
*/
|
|
261
|
+
async removeTelemetry(context, keepCapture) {
|
|
249
262
|
const settingsPath = claudeSettingsPath(context.env);
|
|
250
263
|
const read = await readJsonFile(settingsPath);
|
|
251
264
|
if (read.state === 'missing') {
|
|
@@ -258,7 +271,7 @@ export class ClaudeOtelConfigurator {
|
|
|
258
271
|
const envBlock = asRecord(settings[ENV_BLOCK_KEY]);
|
|
259
272
|
const { removable, kept, reason } = removableEnvKeys(envBlock ?? {}, this.ownedKeys(context), context);
|
|
260
273
|
const restored = restoredEnv(otelPriorValuesOf(context.installState, CLAUDE_PROVIDER_ID), removable);
|
|
261
|
-
const next = strippedSettings(settings, envBlock && withoutCaptureEnv(envBlock, copiedShims(context.paths.dataDir)), restored, removable, isOurHelper(settings[HEADERS_HELPER_KEY]));
|
|
274
|
+
const next = strippedSettings(settings, envBlock && (keepCapture ? envBlock : withoutCaptureEnv(envBlock, copiedShims(context.paths.dataDir))), restored, removable, isOurHelper(settings[HEADERS_HELPER_KEY]));
|
|
262
275
|
const changed = JSON.stringify(next) !== JSON.stringify(settings);
|
|
263
276
|
const left = keptMessages(kept, reason, settingsPath);
|
|
264
277
|
if (changed) {
|
|
@@ -297,22 +310,78 @@ export class ClaudeOtelConfigurator {
|
|
|
297
310
|
return { ok: false, changed: false, messages: ['no backend endpoint configured'] };
|
|
298
311
|
// Deliberately off: the desired state is "no AgentWatch telemetry", which
|
|
299
312
|
// means removing whatever a previous setup left behind.
|
|
300
|
-
|
|
313
|
+
// Capture is not telemetry: its calls go out as events, so `otel: none` leaves it on.
|
|
314
|
+
const keepCapture = runCaptureEnabled(context.config);
|
|
315
|
+
const removed = await this.removeTelemetry(context, keepCapture);
|
|
301
316
|
if (!removed.ok)
|
|
302
317
|
return removed;
|
|
318
|
+
const capture = keepCapture ? await this.captureOnly(context) : undefined;
|
|
303
319
|
return {
|
|
304
320
|
ok: true,
|
|
305
|
-
changed: removed.changed,
|
|
321
|
+
changed: removed.changed || capture?.changed === true,
|
|
306
322
|
messages: [
|
|
307
323
|
removed.changed
|
|
308
324
|
? 'native OpenTelemetry disabled in config; previous configuration removed'
|
|
309
325
|
: 'native OpenTelemetry disabled in config (otel: none)',
|
|
310
326
|
// Past uninstall's own headline: the keys it left and why.
|
|
311
|
-
...removed.messages.slice(1)
|
|
327
|
+
...removed.messages.slice(1),
|
|
328
|
+
...(capture?.messages ?? [])
|
|
312
329
|
],
|
|
313
330
|
installState: removed.installState
|
|
314
331
|
};
|
|
315
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* The env block with run capture in or out, as `capture.runs` says.
|
|
335
|
+
*
|
|
336
|
+
* @param envBlock - The env block as it stands.
|
|
337
|
+
* @param context - Environment, paths and config.
|
|
338
|
+
* @returns The next env block.
|
|
339
|
+
*/
|
|
340
|
+
async capturedEnv(envBlock, context) {
|
|
341
|
+
if (!runCaptureEnabled(context.config))
|
|
342
|
+
return withoutCaptureEnv(envBlock, copiedShims(context.paths.dataDir));
|
|
343
|
+
return installedCaptureEnv(envBlock, context.env.vars, context.paths.dataDir, this.captureSource);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Run capture alone, as a step that says rather than throws when it cannot write: an
|
|
347
|
+
* optional key must never fail setup or `agentwatch on` (`withCaptureOutcome`).
|
|
348
|
+
*
|
|
349
|
+
* @param context - Environment, paths and config.
|
|
350
|
+
* @returns Whether the file changed, and what to tell the user.
|
|
351
|
+
*/
|
|
352
|
+
captureOnly(context) {
|
|
353
|
+
const step = this.writeCaptureOnly(context).then((changed) => ({
|
|
354
|
+
ok: true,
|
|
355
|
+
changed,
|
|
356
|
+
messages: changed ? [`run capture ${runCaptureEnabled(context.config) ? 'configured' : 'removed'} (capture.runs); restart running Claude Code sessions to pick it up`] : []
|
|
357
|
+
}));
|
|
358
|
+
return skippedOnError(step);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Write run capture alone, in or out as `capture.runs` says, when the exporters are
|
|
362
|
+
* off or skipped over a conflict.
|
|
363
|
+
*
|
|
364
|
+
* @param context - Environment, paths and config.
|
|
365
|
+
* @returns Whether the file changed; an unreadable or non-object file is left alone.
|
|
366
|
+
*/
|
|
367
|
+
async writeCaptureOnly(context) {
|
|
368
|
+
const settingsPath = claudeSettingsPath(context.env);
|
|
369
|
+
const read = await readJsonFile(settingsPath);
|
|
370
|
+
if (read.state === 'invalid')
|
|
371
|
+
return false;
|
|
372
|
+
const settings = read.state === 'ok' ? asRecord(read.value) : {};
|
|
373
|
+
if (!settings)
|
|
374
|
+
return false;
|
|
375
|
+
const envBlock = asRecord(settings[ENV_BLOCK_KEY]) ?? {};
|
|
376
|
+
const nextEnv = await this.capturedEnv(envBlock, context);
|
|
377
|
+
// Compared on the block, so a file with nothing to add never gains an empty `env`.
|
|
378
|
+
if (JSON.stringify(nextEnv) === JSON.stringify(envBlock))
|
|
379
|
+
return false;
|
|
380
|
+
const next = { ...settings, [ENV_BLOCK_KEY]: nextEnv };
|
|
381
|
+
await backupFile(settingsPath, context.paths.backupsDir, context.env.now());
|
|
382
|
+
await writeJsonValidated(settingsPath, next);
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
316
385
|
/**
|
|
317
386
|
* Add the header-helper command when a token needs one.
|
|
318
387
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { claudeBillingMode } from '../../billing/billing-mode.js';
|
|
2
|
-
import { asRecord } from '../../core/object.js';
|
|
2
|
+
import { asRecord, firstStringOf } from '../../core/object.js';
|
|
3
3
|
import { hookNotice, hookRefusal } from '../shared/hook-refusal.js';
|
|
4
|
-
import { readClaudeSessionTitles, readTurnUsage } from '../../turns/claude-transcript.js';
|
|
4
|
+
import { readClaudeSessionTitles, readClaudeSubagentTurnIds, readClaudeSubagentUsage, readTurnUsage } from '../../turns/claude-transcript.js';
|
|
5
5
|
import { CLAUDE_DETACHED_EVENTS, CLAUDE_ENTRYPOINT_VAR, CLAUDE_INTERACTIVE_ENTRYPOINTS, CLAUDE_PROMPT_SUBMIT_EVENTS } from './constants/claude.constants.js';
|
|
6
6
|
import { detectClaude } from './claude.detect.js';
|
|
7
7
|
import { installClaudeHooks, uninstallClaudeHooks } from './claude.hooks.js';
|
|
@@ -30,13 +30,19 @@ export const claudeProvider = {
|
|
|
30
30
|
/** A line for the developer after a shell run, as `systemMessage`; never plain stdout. */
|
|
31
31
|
getNoticeResponse: (payload, message) => hookNotice(payload, message),
|
|
32
32
|
/**
|
|
33
|
-
* Stop and SubagentStop of a terminal session; anywhere else the session may end at once
|
|
34
|
-
*
|
|
35
|
-
* its `SessionEnd`; upgrade path is a pending-close marker that `SessionEnd` waits on.
|
|
33
|
+
* Stop and SubagentStop of a terminal session; anywhere else the session may end at once.
|
|
34
|
+
* An `/exit` or `/clear` right after the Stop finds the pending-close marker and leaves the clear to the close.
|
|
36
35
|
*/
|
|
37
|
-
|
|
36
|
+
detachedSession: (payload, env) => {
|
|
37
|
+
const record = asRecord(payload);
|
|
38
|
+
if (!CLAUDE_DETACHED_EVENTS.has(String(record?.['hook_event_name'])) || !CLAUDE_INTERACTIVE_ENTRYPOINTS.has(env.vars[CLAUDE_ENTRYPOINT_VAR] ?? ''))
|
|
39
|
+
return undefined;
|
|
40
|
+
return firstStringOf(record?.['session_id']);
|
|
41
|
+
},
|
|
38
42
|
shellCall: claudeShellCall,
|
|
39
43
|
readTurnUsage,
|
|
44
|
+
readSubagentUsage: readClaudeSubagentUsage,
|
|
45
|
+
readSubagentTurnIds: readClaudeSubagentTurnIds,
|
|
40
46
|
billingMode: claudeBillingMode,
|
|
41
47
|
readTranscriptTitles: readClaudeSessionTitles,
|
|
42
48
|
/** Claude Code names its own entrypoint (`cli`, `claude-vscode`, `sdk-ts`, ...). */
|
|
@@ -63,7 +63,7 @@ export declare function filteredCaptureKeys(policy: UnknownRecord): {
|
|
|
63
63
|
/**
|
|
64
64
|
* Whether what Codex's shell tool starts loads the shims, and when not, why.
|
|
65
65
|
*
|
|
66
|
-
* Gated on `
|
|
66
|
+
* Gated on `capture.runs` as every route is, not on `otel` or the tool-content consent that holds Codex's
|
|
67
67
|
* own export back: a captured call is usage only, it carries no tool content.
|
|
68
68
|
*
|
|
69
69
|
* @param context - Environment, paths and config.
|
|
@@ -4,7 +4,7 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
4
4
|
import { parse as parseToml, stringify as stringifyToml } from 'smol-toml';
|
|
5
5
|
import { copiedShims, inspectCaptureEnv, installedCaptureEnv, isLinkedConfig, linkedConfigReason, removeCaptureCopy, shimPaths, withoutCaptureEnv } from '../../capture/capture-env.js';
|
|
6
6
|
import { RUN_CAPTURE_ENV_NODE, RUN_CAPTURE_ENV_PYTHON, SPOOL_DIR_NAME } from '../../capture/constants/capture.constants.js';
|
|
7
|
-
import {
|
|
7
|
+
import { runCaptureEnabled } from '../../config/config.js';
|
|
8
8
|
import { asRecord } from '../../core/object.js';
|
|
9
9
|
import { backupFile, currentMode, writeFileAtomic, writeIfUnchanged } from '../../storage/atomic-file.js';
|
|
10
10
|
import { SECRET_FILE_MODE } from '../../storage/constants/storage.constants.js';
|
|
@@ -386,7 +386,7 @@ export function filteredCaptureKeys(policy) {
|
|
|
386
386
|
/**
|
|
387
387
|
* Whether what Codex's shell tool starts loads the shims, and when not, why.
|
|
388
388
|
*
|
|
389
|
-
* Gated on `
|
|
389
|
+
* Gated on `capture.runs` as every route is, not on `otel` or the tool-content consent that holds Codex's
|
|
390
390
|
* own export back: a captured call is usage only, it carries no tool content.
|
|
391
391
|
*
|
|
392
392
|
* @param context - Environment, paths and config.
|
|
@@ -399,7 +399,7 @@ export async function inspectCodexCapture(context, source = shimPaths()) {
|
|
|
399
399
|
const parsed = raw ? tryParse(raw) : {};
|
|
400
400
|
if (raw === null || parsed === undefined)
|
|
401
401
|
return { on: false, reason: `${file} cannot be read as TOML` };
|
|
402
|
-
const status = await inspectCaptureEnv(setBlock(parsed), context.config,
|
|
402
|
+
const status = await inspectCaptureEnv(setBlock(parsed), context.config, runCaptureEnabled(context.config), context.paths.dataDir, source);
|
|
403
403
|
if (!status.on && (await isLinkedConfig(file)))
|
|
404
404
|
return { on: false, reason: linkedConfigReason(file) };
|
|
405
405
|
if (!status.on)
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import { parse as parseToml } from 'smol-toml';
|
|
3
3
|
import { shimPaths, skippedOnError, withCaptureOutcome } from '../../capture/capture-env.js';
|
|
4
4
|
import { asRecord } from '../../core/object.js';
|
|
5
|
-
import { joinUrl,
|
|
5
|
+
import { joinUrl, otlpBaseUrl, runCaptureEnabled, toolContentConsented } from '../../config/config.js';
|
|
6
6
|
import { backupFile, currentMode, writeFileAtomic, writeIfUnchanged } from '../../storage/atomic-file.js';
|
|
7
7
|
import { SECRET_FILE_MODE } from '../../storage/constants/storage.constants.js';
|
|
8
8
|
import { deviceFor, hasCredential } from '../../credentials/identity.js';
|
|
@@ -86,7 +86,7 @@ export class CodexOtelConfigurator {
|
|
|
86
86
|
*/
|
|
87
87
|
async configure(context) {
|
|
88
88
|
const outcome = await this.configureExport(context);
|
|
89
|
-
const capture =
|
|
89
|
+
const capture = runCaptureEnabled(context.config) ? await skippedOnError(applyCodexCapture(context, this.captureSource)) : await removeCodexCapture(context);
|
|
90
90
|
return withCaptureOutcome(outcome, capture);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { codexBillingMode } from '../../billing/billing-mode.js';
|
|
2
2
|
import { hookNotice, hookRefusal } from '../shared/hook-refusal.js';
|
|
3
|
-
import { readCodexTurnUsage } from '../../turns/codex-transcript.js';
|
|
3
|
+
import { readCodexSubagentUsage, readCodexTurnUsage } from '../../turns/codex-transcript.js';
|
|
4
4
|
import { CODEX_PROMPT_SUBMIT_EVENTS } from './constants/codex.constants.js';
|
|
5
5
|
import { detectCodex } from './codex.detect.js';
|
|
6
6
|
import { installCodexHooks, uninstallCodexHooks } from './codex.hooks.js';
|
|
@@ -29,6 +29,7 @@ export const codexProvider = {
|
|
|
29
29
|
getNoticeResponse: (payload, message) => hookNotice(payload, message),
|
|
30
30
|
shellCall: codexShellCall,
|
|
31
31
|
readTurnUsage: readCodexTurnUsage,
|
|
32
|
+
readSubagentUsage: readCodexSubagentUsage,
|
|
32
33
|
billingMode: codexBillingMode,
|
|
33
34
|
readSessionTitles: readCodexSessionTitles,
|
|
34
35
|
surface: codexSurface,
|
|
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { copiedShims, inspectCaptureEnv, installedCaptureEnv, isLinkedConfig, linkedConfigReason, removeCaptureCopy, shimPaths, withoutCaptureEnv } from '../../capture/capture-env.js';
|
|
5
5
|
import { RUN_CAPTURE_ENV_NODE, RUN_CAPTURE_ENV_PYTHON } from '../../capture/constants/capture.constants.js';
|
|
6
|
-
import {
|
|
6
|
+
import { runCaptureEnabled } from '../../config/config.js';
|
|
7
7
|
import { backupFile, writeFileAtomic } from '../../storage/atomic-file.js';
|
|
8
8
|
import { GEMINI_ENV_FILE, GEMINI_HOME_DIR } from './constants/gemini.constants.js';
|
|
9
9
|
import { RE_ENV_LINE } from './constants/gemini.otel.constants.js';
|
|
@@ -197,7 +197,7 @@ export async function inspectGeminiCapture(context, source = shimPaths()) {
|
|
|
197
197
|
return { on: false, reason: `${file} cannot be read` };
|
|
198
198
|
if (wouldHideHomeEnv(context, raw))
|
|
199
199
|
return { on: false, reason: hidesHomeEnv(context, file) };
|
|
200
|
-
const status = await inspectCaptureEnv(parseEnv(raw ?? ''), context.config,
|
|
200
|
+
const status = await inspectCaptureEnv(parseEnv(raw ?? ''), context.config, runCaptureEnabled(context.config), context.paths.dataDir, source);
|
|
201
201
|
if (!status.on)
|
|
202
202
|
return (await isLinkedConfig(file)) ? { on: false, reason: linkedConfigReason(file) } : status;
|
|
203
203
|
const shadow = shadowingEnvFile(context.env.cwd, file);
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { shimPaths, skippedOnError, withCaptureOutcome } from '../../capture/capture-env.js';
|
|
4
4
|
import { asRecord, omitKeys } from '../../core/object.js';
|
|
5
|
-
import { enabledSignalNames,
|
|
5
|
+
import { enabledSignalNames, otlpBaseUrl, runCaptureEnabled, toolContentConsented } from '../../config/config.js';
|
|
6
6
|
import { INSTALLATION_HEADER } from '../../transport/constants/transport.constants.js';
|
|
7
7
|
import { backupFile, currentMode, writeFileAtomic, writeIfUnchanged } from '../../storage/atomic-file.js';
|
|
8
8
|
import { SECRET_FILE_MODE } from '../../storage/constants/storage.constants.js';
|
|
@@ -204,7 +204,7 @@ export class GeminiOtelConfigurator {
|
|
|
204
204
|
*/
|
|
205
205
|
async configure(context) {
|
|
206
206
|
const outcome = await this.configureExport(context);
|
|
207
|
-
const capture =
|
|
207
|
+
const capture = runCaptureEnabled(context.config) ? await skippedOnError(applyGeminiCapture(context, this.captureSource)) : await removeGeminiCapture(context);
|
|
208
208
|
return withCaptureOutcome(outcome, capture);
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { googleAccountBillingMode } from '../../billing/billing-mode.js';
|
|
2
2
|
import { hookRefusal } from '../shared/hook-refusal.js';
|
|
3
|
-
import { readGeminiTurnUsage } from '../../turns/gemini-transcript.js';
|
|
3
|
+
import { readGeminiSubagentUsage, readGeminiTurnUsage } from '../../turns/gemini-transcript.js';
|
|
4
4
|
import { GEMINI_PROMPT_EVENTS } from './constants/gemini.constants.js';
|
|
5
5
|
import { detectGemini } from './gemini.detect.js';
|
|
6
6
|
import { installGeminiHooks, uninstallGeminiHooks } from './gemini.hooks.js';
|
|
@@ -22,6 +22,7 @@ export const geminiProvider = {
|
|
|
22
22
|
getBlockResponse: (payload, message) => hookRefusal(payload, GEMINI_PROMPT_EVENTS, { decision: 'deny', reason: message }),
|
|
23
23
|
shellCall: geminiShellCall,
|
|
24
24
|
readTurnUsage: readGeminiTurnUsage,
|
|
25
|
+
readSubagentUsage: readGeminiSubagentUsage,
|
|
25
26
|
/** Signed in through the shared `~/.gemini` Google account, as Antigravity is. */
|
|
26
27
|
billingMode: googleAccountBillingMode,
|
|
27
28
|
nativeTelemetry: new GeminiOtelConfigurator()
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { copiedShims, inspectCaptureEnv, installedCaptureEnv, removeCaptureCopy, shimPaths, skippedOnError, withCaptureOutcome, withoutCaptureEnv } from '../../capture/capture-env.js';
|
|
5
|
-
import {
|
|
5
|
+
import { runCaptureEnabled } from '../../config/config.js';
|
|
6
6
|
import { asRecord, omitKeys } from '../../core/object.js';
|
|
7
7
|
import { backupFile } from '../../storage/atomic-file.js';
|
|
8
8
|
import { readJsonFile } from '../../storage/json-file.js';
|
|
@@ -97,12 +97,12 @@ export function terminalCapture(app, verified, source = shimPaths()) {
|
|
|
97
97
|
if (read.state === 'invalid')
|
|
98
98
|
return { on: false, reason: `${file} is not plain JSON, so Edge cannot edit it` };
|
|
99
99
|
const block = asRecord(asRecord(read.state === 'ok' ? read.value : undefined)?.[terminalEnvKey(context.env)]) ?? {};
|
|
100
|
-
return inspectCaptureEnv(block, context.config,
|
|
100
|
+
return inspectCaptureEnv(block, context.config, runCaptureEnabled(context.config), context.paths.dataDir, source);
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
install: (inner) => async (context) => {
|
|
104
104
|
const outcome = await inner(context);
|
|
105
|
-
return withCaptureOutcome(outcome, await (verified &&
|
|
105
|
+
return withCaptureOutcome(outcome, await (verified && runCaptureEnabled(context.config) ? skippedOnError(apply(context)) : remove(context)));
|
|
106
106
|
},
|
|
107
107
|
uninstall: (inner) => async (context) => withCaptureOutcome(await inner(context), await remove(context))
|
|
108
108
|
};
|
|
@@ -148,12 +148,12 @@ export interface AgentProvider extends TurnProvider {
|
|
|
148
148
|
*/
|
|
149
149
|
getNoticeResponse?(payload: unknown, message: string): ProviderHookResponse | undefined;
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
152
|
-
* agent is answered at once instead of waiting on the send.
|
|
153
|
-
*
|
|
154
|
-
* session
|
|
151
|
+
* The session whose turn close this payload hands to a detached `agentwatch
|
|
152
|
+
* hook`, so the agent is answered at once instead of waiting on the send.
|
|
153
|
+
* Undefined processes it in place. Only for a hook that answers nothing; the
|
|
154
|
+
* session is named so its `SessionEnd` can see the close is still pending.
|
|
155
155
|
*/
|
|
156
|
-
|
|
156
|
+
detachedSession?(payload: unknown, env: Env): string | undefined;
|
|
157
157
|
/**
|
|
158
158
|
* Working directory this payload was produced in, when the provider does not
|
|
159
159
|
* report it as a top-level `cwd`. Git context, repository config and ticket
|
|
@@ -1,29 +1,56 @@
|
|
|
1
|
-
import type { ReplayCheckout, ReplayTurn } from './types/replay.types.js';
|
|
1
|
+
import type { ReplayCheckout, ReplayTool, ReplayTurn } from './types/replay.types.js';
|
|
2
|
+
import { type WorktreeMap } from './worktree-map.js';
|
|
2
3
|
/** Answers "which repository is this folder in?" for a transcript's folders, asking git once per folder. */
|
|
3
4
|
export type CheckoutResolver = (cwd: string) => Promise<ReplayCheckout | undefined>;
|
|
4
5
|
/**
|
|
5
6
|
* A resolver that remembers its answers for the run.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* folder that no longer exists answers
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Three git processes per distinct folder, however many turns ran there. A
|
|
9
|
+
* folder that no longer exists answers from the worktrees the transcripts
|
|
10
|
+
* recorded, and otherwise nothing, and so do the turns that ran in it (their
|
|
11
|
+
* tokens still count, with no repository). Not the whole git context the hooks
|
|
12
|
+
* take: no commit or status, because the commit is not known.
|
|
12
13
|
*
|
|
14
|
+
* @param worktrees - What the transcripts recorded about worktrees; filled before the first answer.
|
|
13
15
|
* @returns The resolver.
|
|
14
16
|
*/
|
|
15
|
-
export declare function createCheckoutResolver(): CheckoutResolver;
|
|
17
|
+
export declare function createCheckoutResolver(worktrees?: WorktreeMap): CheckoutResolver;
|
|
16
18
|
/**
|
|
17
|
-
* The checkout a turn
|
|
19
|
+
* The checkout a turn reports, by the live hook's ladder as far as a transcript allows: `changed`, `carried`, then its folder.
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* The checkout that holds the most of the turn's edits wins (first seen on a tie), so an edit in another worktree
|
|
22
|
+
* is no longer dropped for the folder the session sat in. A turn with no edit in any checkout falls to the checkout
|
|
23
|
+
* the session last changed, then its folder; a turn whose edits all lie elsewhere reports neither, as live
|
|
24
|
+
* (`fileEvidenceAllows`: a session that wrote files elsewhere is not working in the one its shell sits in).
|
|
25
|
+
* Reads name no checkout: the live `referenced` rung is weaker than `changed` and would send that repository's snapshot.
|
|
23
26
|
*
|
|
24
27
|
* @param turn - The turn.
|
|
25
28
|
* @param resolve - The run's resolver.
|
|
26
29
|
* @param accept - Whether a tool file's checkout may be used (it may belong to another root's identity); a refused one is passed over.
|
|
27
|
-
* @
|
|
30
|
+
* @param carried - The checkout the session last changed.
|
|
31
|
+
* @returns The checkout and how it was known (no `evidence`: the folder); undefined when none resolves.
|
|
28
32
|
*/
|
|
29
|
-
export declare function checkoutOfTurn(turn: Pick<ReplayTurn, 'cwd' | 'tools'>, resolve: CheckoutResolver, accept?: (checkout: ReplayCheckout) => boolean): Promise<ReplayCheckout | undefined>;
|
|
33
|
+
export declare function checkoutOfTurn(turn: Pick<ReplayTurn, 'cwd' | 'tools' | 'branch' | 'startedAt'>, resolve: CheckoutResolver, accept?: (checkout: ReplayCheckout) => boolean, carried?: ReplayCheckout): Promise<ReplayCheckout | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Whether a tool call edited a file at a known place.
|
|
36
|
+
*
|
|
37
|
+
* @param tool - The call.
|
|
38
|
+
* @returns True for an edit with an absolute path.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isEdit(tool: ReplayTool): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The turn's tools with every file that lies in no checkout marked, as the live hook tells them apart.
|
|
43
|
+
*
|
|
44
|
+
* A folder that is gone answers nothing, so its files read as outside too, unless the path belongs to another
|
|
45
|
+
* identity's root or an ignored one, whose files are left out.
|
|
46
|
+
* ponytail: a root-scoped replay also leaves out files beyond its root, which a live hook would send. Ceiling: a
|
|
47
|
+
* root-scoped identity loses that outside-repo evidence; upgrade path: a scope port that tells "no root" from "another root".
|
|
48
|
+
* ponytail: asks git once per distinct folder of the run (the resolver remembers), with no per-turn cap. Ceiling:
|
|
49
|
+
* a machine whose agents touch tens of thousands of folders; the replay is niced and paced, so it only runs longer.
|
|
50
|
+
*
|
|
51
|
+
* @param tools - The turn's tools.
|
|
52
|
+
* @param resolve - The run's resolver.
|
|
53
|
+
* @param inScope - Whether a folder belongs to this identity.
|
|
54
|
+
* @returns A new list; a file inside some checkout is left unmarked.
|
|
55
|
+
*/
|
|
56
|
+
export declare function markFilesOutsideCheckouts(tools: readonly ReplayTool[], resolve: CheckoutResolver, inScope?: (folder: string) => boolean): Promise<ReplayTool[]>;
|