@agent-watch-ai/edge 0.2.5 → 0.4.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 +558 -0
- package/README.md +222 -97
- package/SECURITY.md +72 -0
- package/dist/billing/session-billing.d.ts +19 -0
- package/dist/billing/session-billing.js +52 -0
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.js +20 -0
- package/dist/cli/constants/cli.constants.d.ts +52 -4
- package/dist/cli/constants/cli.constants.js +56 -5
- package/dist/cli/context.d.ts +33 -2
- package/dist/cli/context.js +84 -14
- package/dist/cli/doctor.js +321 -33
- package/dist/cli/hook-check.d.ts +23 -0
- package/dist/cli/hook-check.js +114 -0
- package/dist/cli/hook.js +118 -7
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/misc.d.ts +11 -0
- package/dist/cli/misc.js +80 -4
- package/dist/cli/npx-install.d.ts +37 -0
- package/dist/cli/npx-install.js +79 -0
- package/dist/cli/open-browser.d.ts +39 -0
- package/dist/cli/open-browser.js +62 -0
- package/dist/cli/setup.d.ts +17 -8
- package/dist/cli/setup.js +553 -103
- package/dist/cli/status.js +82 -13
- package/dist/cli/toggle.d.ts +9 -0
- package/dist/cli/toggle.js +117 -0
- package/dist/cli/types/cli.types.d.ts +43 -3
- package/dist/cli/ui.d.ts +7 -0
- package/dist/cli/ui.js +10 -1
- package/dist/cli/uninstall.js +39 -2
- package/dist/cli/update.d.ts +17 -0
- package/dist/cli/update.js +76 -0
- package/dist/cli.js +110 -12
- package/dist/config/config-store.d.ts +57 -0
- package/dist/config/config-store.js +250 -12
- package/dist/config/config.d.ts +53 -6
- package/dist/config/config.js +66 -6
- package/dist/config/constants/config.constants.d.ts +116 -6
- package/dist/config/constants/config.constants.js +131 -8
- package/dist/config/destination.d.ts +24 -0
- package/dist/config/destination.js +33 -0
- package/dist/config/index.d.ts +7 -4
- package/dist/config/index.js +5 -3
- package/dist/config/repo-config.d.ts +11 -7
- package/dist/config/repo-config.js +64 -15
- package/dist/config/root-config.d.ts +72 -0
- package/dist/config/root-config.js +170 -0
- package/dist/config/schemas/config.schema.d.ts +831 -84
- package/dist/config/schemas/config.schema.js +398 -16
- package/dist/config/types/config.types.d.ts +15 -1
- package/dist/config/types/destination.types.d.ts +8 -0
- package/dist/core/async.d.ts +36 -0
- package/dist/core/async.js +68 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/object.d.ts +5 -0
- package/dist/core/object.js +9 -4
- package/dist/core/pipe.d.ts +0 -13
- package/dist/core/pipe.js +1 -9
- package/dist/core/types/core.types.d.ts +9 -0
- package/dist/core/types/core.types.js +0 -3
- package/dist/core/which.d.ts +14 -0
- package/dist/core/which.js +43 -3
- package/dist/credentials/budget.d.ts +9 -0
- package/dist/credentials/budget.js +16 -0
- package/dist/credentials/command-runner.d.ts +16 -0
- package/dist/credentials/command-runner.js +37 -0
- package/dist/credentials/constants/credentials.constants.d.ts +119 -0
- package/dist/credentials/constants/credentials.constants.js +120 -0
- package/dist/credentials/credential-status.d.ts +14 -0
- package/dist/credentials/credential-status.js +38 -0
- package/dist/credentials/credentials.d.ts +86 -0
- package/dist/credentials/credentials.js +278 -0
- package/dist/credentials/device-api.d.ts +73 -0
- package/dist/credentials/device-api.js +161 -0
- package/dist/credentials/device-state.d.ts +31 -0
- package/dist/credentials/device-state.js +51 -0
- package/dist/credentials/identity.d.ts +73 -0
- package/dist/credentials/identity.js +101 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/migration.d.ts +46 -0
- package/dist/credentials/migration.js +164 -0
- package/dist/credentials/schemas/device-api.schema.d.ts +77 -0
- package/dist/credentials/schemas/device-api.schema.js +33 -0
- package/dist/credentials/schemas/device-state.schema.d.ts +51 -0
- package/dist/credentials/schemas/device-state.schema.js +20 -0
- package/dist/credentials/secret-store.d.ts +54 -0
- package/dist/credentials/secret-store.js +217 -0
- package/dist/credentials/sign-in.d.ts +31 -0
- package/dist/credentials/sign-in.js +105 -0
- package/dist/credentials/token-refresher.d.ts +39 -0
- package/dist/credentials/token-refresher.js +185 -0
- package/dist/credentials/types/credentials.types.d.ts +206 -0
- package/dist/credentials/types/credentials.types.js +1 -0
- package/dist/enforcement/constants/enforcement.constants.d.ts +47 -1
- package/dist/enforcement/constants/enforcement.constants.js +56 -0
- package/dist/enforcement/decision-cache.d.ts +20 -1
- package/dist/enforcement/decision-cache.js +65 -2
- package/dist/enforcement/decision-client.d.ts +9 -8
- package/dist/enforcement/decision-client.js +64 -17
- package/dist/enforcement/enforcement.d.ts +23 -2
- package/dist/enforcement/enforcement.js +107 -17
- package/dist/enforcement/index.d.ts +4 -3
- package/dist/enforcement/index.js +3 -2
- package/dist/enforcement/types/enforcement.types.d.ts +66 -2
- package/dist/enrollment/constants/enrollment.constants.d.ts +2 -6
- package/dist/enrollment/constants/enrollment.constants.js +2 -6
- package/dist/enrollment/enrollment.d.ts +16 -0
- package/dist/enrollment/enrollment.js +54 -0
- package/dist/enrollment/index.d.ts +3 -7
- package/dist/enrollment/index.js +1 -1
- package/dist/enrollment/types/enrollment.types.d.ts +9 -13
- package/dist/events/constants/enrich.constants.d.ts +15 -0
- package/dist/events/constants/enrich.constants.js +15 -0
- package/dist/events/constants/events.constants.d.ts +6 -2
- package/dist/events/constants/events.constants.js +5 -1
- package/dist/events/enrich.js +92 -10
- package/dist/events/event-id.d.ts +0 -8
- package/dist/events/event-id.js +0 -10
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/product-event.d.ts +9 -6
- package/dist/events/types/repo-snapshot.types.d.ts +7 -0
- package/dist/events/types/session-billing.types.d.ts +16 -0
- package/dist/events/types/session-billing.types.js +1 -0
- package/dist/feature/constants/feature.constants.d.ts +7 -0
- package/dist/feature/constants/feature.constants.js +7 -0
- package/dist/feature/index.d.ts +1 -1
- package/dist/feature/index.js +1 -1
- package/dist/feature/ticket-candidates.d.ts +14 -0
- package/dist/feature/ticket-candidates.js +26 -8
- package/dist/git/blob-hash.d.ts +21 -0
- package/dist/git/blob-hash.js +69 -0
- package/dist/git/checkout-root.d.ts +27 -0
- package/dist/git/checkout-root.js +75 -0
- package/dist/git/constants/git.constants.d.ts +160 -0
- package/dist/git/constants/git.constants.js +181 -0
- package/dist/git/fingerprint.d.ts +74 -0
- package/dist/git/fingerprint.js +219 -0
- package/dist/git/gate-checkout.d.ts +44 -0
- package/dist/git/gate-checkout.js +201 -0
- package/dist/git/git-context.d.ts +45 -0
- package/dist/git/git-context.js +61 -3
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +2 -1
- package/dist/git/manifest-repository.d.ts +13 -0
- package/dist/git/manifest-repository.js +92 -0
- package/dist/git/repo-snapshot.d.ts +29 -3
- package/dist/git/repo-snapshot.js +110 -7
- package/dist/git/repository-root.d.ts +39 -0
- package/dist/git/repository-root.js +131 -0
- package/dist/git/types/git.types.d.ts +55 -0
- package/dist/git/types/repository-root.types.d.ts +11 -0
- package/dist/git/types/repository-root.types.js +1 -0
- package/dist/git/types/snapshot.types.d.ts +9 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +10 -0
- package/dist/pipeline/constants/pipeline.constants.js +10 -0
- package/dist/pipeline/hook-pipeline.js +410 -33
- package/dist/pipeline/types/pipeline.types.d.ts +39 -4
- package/dist/privacy/constants/privacy.constants.js +15 -1
- package/dist/privacy/index.d.ts +1 -0
- package/dist/privacy/index.js +1 -0
- package/dist/privacy/product-capture.d.ts +12 -0
- package/dist/privacy/product-capture.js +75 -0
- package/dist/privacy/sanitizer.d.ts +21 -3
- package/dist/privacy/sanitizer.js +52 -8
- package/dist/process/ancestors.d.ts +39 -0
- package/dist/process/ancestors.js +121 -0
- package/dist/process/constants/process.constants.d.ts +34 -0
- package/dist/process/constants/process.constants.js +34 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +2 -0
- package/dist/process/types/process.types.d.ts +23 -0
- package/dist/process/types/process.types.js +1 -0
- package/dist/providers/antigravity/antigravity.adapter.d.ts +12 -1
- package/dist/providers/antigravity/antigravity.adapter.js +21 -3
- package/dist/providers/antigravity/antigravity.detect.d.ts +0 -9
- package/dist/providers/antigravity/antigravity.detect.js +1 -1
- package/dist/providers/antigravity/antigravity.provider.js +3 -2
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +2 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +2 -0
- package/dist/providers/claude/claude.adapter.d.ts +11 -1
- package/dist/providers/claude/claude.adapter.js +26 -5
- package/dist/providers/claude/claude.otel.d.ts +32 -18
- package/dist/providers/claude/claude.otel.js +81 -6
- package/dist/providers/claude/claude.provider.js +5 -2
- package/dist/providers/claude/constants/claude.constants.d.ts +2 -0
- package/dist/providers/claude/constants/claude.constants.js +2 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +4 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +8 -0
- package/dist/providers/codex/codex.adapter.d.ts +15 -1
- package/dist/providers/codex/codex.adapter.js +29 -5
- package/dist/providers/codex/codex.otel.d.ts +36 -3
- package/dist/providers/codex/codex.otel.js +199 -32
- package/dist/providers/codex/codex.provider.js +5 -2
- package/dist/providers/codex/constants/codex.constants.d.ts +2 -0
- package/dist/providers/codex/constants/codex.constants.js +16 -0
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +10 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +10 -0
- package/dist/providers/constants/provider.constants.d.ts +8 -3
- package/dist/providers/constants/provider.constants.js +8 -3
- package/dist/providers/cursor/constants/cursor.constants.d.ts +9 -0
- package/dist/providers/cursor/constants/cursor.constants.js +9 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
- package/dist/providers/cursor/cursor.adapter.js +129 -4
- package/dist/providers/cursor/cursor.detect.d.ts +0 -7
- package/dist/providers/cursor/cursor.detect.js +1 -1
- package/dist/providers/cursor/cursor.provider.js +5 -2
- package/dist/providers/gemini/constants/gemini.constants.d.ts +9 -0
- package/dist/providers/gemini/constants/gemini.constants.js +9 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +9 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +9 -0
- package/dist/providers/gemini/gemini.adapter.d.ts +14 -1
- package/dist/providers/gemini/gemini.adapter.js +25 -5
- package/dist/providers/gemini/gemini.detect.d.ts +0 -7
- package/dist/providers/gemini/gemini.detect.js +1 -1
- package/dist/providers/gemini/gemini.otel.d.ts +30 -21
- package/dist/providers/gemini/gemini.otel.js +166 -22
- package/dist/providers/gemini/gemini.provider.js +2 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/loaders.d.ts +10 -0
- package/dist/providers/loaders.js +40 -0
- package/dist/providers/provider.d.ts +11 -0
- package/dist/providers/provider.js +1 -1
- package/dist/providers/registry.d.ts +11 -8
- package/dist/providers/registry.js +11 -15
- package/dist/providers/shared/bearer-rewrite.d.ts +19 -0
- package/dist/providers/shared/bearer-rewrite.js +46 -0
- package/dist/providers/shared/constants/hook-refusal.constants.d.ts +7 -0
- package/dist/providers/shared/constants/hook-refusal.constants.js +7 -0
- package/dist/providers/shared/constants/shell-directories.constants.d.ts +30 -0
- package/dist/providers/shared/constants/shell-directories.constants.js +39 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +24 -2
- package/dist/providers/shared/constants/tooling.constants.js +25 -3
- package/dist/providers/shared/event-builder.d.ts +12 -14
- package/dist/providers/shared/event-builder.js +20 -14
- package/dist/providers/shared/exporter-allowlist.d.ts +20 -0
- package/dist/providers/shared/exporter-allowlist.js +49 -0
- package/dist/providers/shared/hook-config.d.ts +2 -21
- package/dist/providers/shared/hook-config.js +5 -4
- package/dist/providers/shared/hook-refusal.d.ts +12 -0
- package/dist/providers/shared/hook-refusal.js +17 -1
- package/dist/providers/shared/install-record.d.ts +12 -2
- package/dist/providers/shared/install-record.js +5 -2
- package/dist/providers/shared/shell-directories.d.ts +24 -0
- package/dist/providers/shared/shell-directories.js +90 -0
- package/dist/providers/shared/tooling.d.ts +40 -1
- package/dist/providers/shared/tooling.js +70 -1
- package/dist/providers/shared/types/adapter.types.d.ts +1 -2
- package/dist/providers/types/provider.types.d.ts +81 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +32 -0
- package/dist/snapshot/constants/snapshot.constants.js +33 -0
- package/dist/snapshot/snapshot-event.js +52 -11
- package/dist/snapshot/snapshot-pipeline.js +1 -1
- package/dist/snapshot/types/snapshot.types.d.ts +2 -0
- package/dist/storage/atomic-file.d.ts +21 -0
- package/dist/storage/atomic-file.js +20 -1
- package/dist/storage/constants/storage.constants.d.ts +19 -0
- package/dist/storage/constants/storage.constants.js +19 -0
- package/dist/storage/disabled.d.ts +13 -0
- package/dist/storage/disabled.js +24 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/paths.js +3 -2
- package/dist/storage/schemas/storage.schema.d.ts +72 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/storage/sweep-marker.d.ts +19 -0
- package/dist/storage/sweep-marker.js +55 -0
- package/dist/storage/types/storage.types.d.ts +2 -0
- package/dist/storage/uninstalled.d.ts +58 -0
- package/dist/storage/uninstalled.js +107 -0
- package/dist/transport/auth-block.d.ts +66 -0
- package/dist/transport/auth-block.js +129 -0
- package/dist/transport/constants/transport.constants.d.ts +82 -3
- package/dist/transport/constants/transport.constants.js +83 -4
- package/dist/transport/cooldown.js +8 -1
- package/dist/transport/delivery.d.ts +14 -6
- package/dist/transport/delivery.js +80 -55
- package/dist/transport/http-transport.d.ts +1 -0
- package/dist/transport/http-transport.js +52 -10
- package/dist/transport/index.d.ts +6 -3
- package/dist/transport/index.js +3 -0
- package/dist/transport/queue-partition.d.ts +91 -0
- package/dist/transport/queue-partition.js +143 -0
- package/dist/transport/queue.d.ts +99 -20
- package/dist/transport/queue.js +210 -69
- package/dist/transport/response-body.d.ts +25 -0
- package/dist/transport/response-body.js +64 -0
- package/dist/transport/send.d.ts +11 -0
- package/dist/transport/send.js +17 -0
- package/dist/transport/types/delivery-flow.types.d.ts +19 -0
- package/dist/transport/types/delivery-flow.types.js +1 -0
- package/dist/transport/types/transport.types.d.ts +45 -0
- package/dist/turns/claude-transcript.d.ts +19 -1
- package/dist/turns/claude-transcript.js +46 -1
- package/dist/turns/codex-originator.d.ts +11 -0
- package/dist/turns/codex-originator.js +31 -0
- package/dist/turns/codex-transcript.d.ts +30 -0
- package/dist/turns/codex-transcript.js +88 -0
- package/dist/turns/constants/turns.constants.d.ts +141 -5
- package/dist/turns/constants/turns.constants.js +155 -5
- package/dist/turns/file-identity.d.ts +27 -0
- package/dist/turns/file-identity.js +48 -0
- package/dist/turns/gemini-transcript.d.ts +30 -0
- package/dist/turns/gemini-transcript.js +96 -0
- package/dist/turns/index.d.ts +3 -3
- package/dist/turns/index.js +1 -1
- package/dist/turns/inherited-checkout.d.ts +54 -0
- package/dist/turns/inherited-checkout.js +155 -0
- package/dist/turns/native-session-titles.d.ts +26 -0
- package/dist/turns/native-session-titles.js +102 -0
- package/dist/turns/transcript.d.ts +3 -2
- package/dist/turns/transcript.js +5 -1
- package/dist/turns/turn-state.d.ts +224 -3
- package/dist/turns/turn-state.js +456 -21
- package/dist/turns/turn-summary.d.ts +1 -14
- package/dist/turns/turn-summary.js +87 -51
- package/dist/turns/turn-tracker.d.ts +21 -2
- package/dist/turns/turn-tracker.js +379 -56
- package/dist/turns/types/transcript.types.d.ts +5 -0
- package/dist/turns/types/turn-state.types.d.ts +116 -5
- package/dist/turns/types/turn-summary.types.d.ts +64 -14
- package/dist/turns/types/turn-tracker.types.d.ts +27 -1
- package/dist/turns/work-checkout.d.ts +67 -0
- package/dist/turns/work-checkout.js +700 -0
- package/dist/untraced/constants/untraced.constants.d.ts +31 -0
- package/dist/untraced/constants/untraced.constants.js +63 -0
- package/dist/untraced/untraced.d.ts +35 -0
- package/dist/untraced/untraced.js +105 -0
- package/dist/update/constants/update.constants.d.ts +18 -0
- package/dist/update/constants/update.constants.js +20 -0
- package/dist/update/update-check.d.ts +52 -0
- package/dist/update/update-check.js +113 -0
- package/docs/AUDIT_PROMPT.md +129 -0
- package/docs/DATA_HANDLING.md +655 -0
- package/docs/ENTERPRISE_DEPLOYMENT.md +194 -0
- package/docs/PERFORMANCE.md +81 -0
- package/package.json +14 -4
- package/dist/enrollment/enrollment-provider.d.ts +0 -5
- package/dist/enrollment/manual-enrollment.d.ts +0 -32
- package/dist/enrollment/manual-enrollment.js +0 -72
- package/example/README.md +0 -43
- package/example/server.mjs +0 -240
- /package/dist/{enrollment/enrollment-provider.js → config/types/destination.types.js} +0 -0
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import { parse as parseToml } from 'smol-toml';
|
|
3
3
|
import { asRecord } from '../../core/object.js';
|
|
4
|
-
import { joinUrl, otlpBaseUrl } from '../../config/config.js';
|
|
5
|
-
import { backupFile, writeFileAtomic } from '../../storage/atomic-file.js';
|
|
4
|
+
import { joinUrl, otlpBaseUrl, toolContentConsented } from '../../config/config.js';
|
|
5
|
+
import { backupFile, currentMode, writeFileAtomic, writeIfUnchanged } from '../../storage/atomic-file.js';
|
|
6
6
|
import { SECRET_FILE_MODE } from '../../storage/constants/storage.constants.js';
|
|
7
|
+
import { deviceFor, hasCredential } from '../../credentials/identity.js';
|
|
8
|
+
import { BEARER_PLACEHOLDER } from '../constants/provider.constants.js';
|
|
7
9
|
import { withOtelInstall, withoutOtelInstall } from '../shared/install-record.js';
|
|
10
|
+
import { INSTALLATION_HEADER } from '../../transport/constants/transport.constants.js';
|
|
8
11
|
import { codexConfigTomlPath } from './codex.detect.js';
|
|
9
12
|
import { CODEX_PROVIDER_ID } from './constants/codex.constants.js';
|
|
10
|
-
import { BLOCK_END, BLOCK_START, CODEX_OTEL_SIGNALS, LOGS_PATH, OTEL_TABLE_KEY, RE_LEADING_NEWLINE, RE_TOML_BACKSLASH, RE_TOML_QUOTE, RE_TRAILING_NEWLINES, TRACES_PATH } from './constants/codex.otel.constants.js';
|
|
13
|
+
import { BLOCK_END, BLOCK_START, CODEX_EXPORTER_KEYS, CODEX_OTEL_SIGNALS, LOGS_PATH, OTEL_TABLE_KEY, OTLP_HTTP_KEY, RE_BEARER_HEADER, RE_LEADING_NEWLINE, RE_TOML_BACKSLASH, RE_TOML_QUOTE, RE_TOML_TABLE_HEADER, RE_TRAILING_NEWLINES, TRACES_PATH } from './constants/codex.otel.constants.js';
|
|
11
14
|
/**
|
|
12
15
|
* Configures Codex's own OTLP export.
|
|
13
16
|
*
|
|
@@ -40,8 +43,10 @@ export class CodexOtelConfigurator {
|
|
|
40
43
|
return { supported: true, configured: false, detail: 'no config.toml' };
|
|
41
44
|
}
|
|
42
45
|
const hasBlock = raw.includes(BLOCK_START);
|
|
43
|
-
if (disabled)
|
|
44
|
-
|
|
46
|
+
if (disabled) {
|
|
47
|
+
const detail = context.config.otel.logs || context.config.otel.traces ? 'disabled by content consent' : 'disabled in config (otel)';
|
|
48
|
+
return inspectDisabled(hasBlock, detail);
|
|
49
|
+
}
|
|
45
50
|
if (hasBlock)
|
|
46
51
|
return inspectManagedBlock(raw, context.config);
|
|
47
52
|
const parsed = tryParseToml(raw);
|
|
@@ -67,7 +72,7 @@ export class CodexOtelConfigurator {
|
|
|
67
72
|
return { ok: false, changed: false, messages: ['no backend endpoint configured'] };
|
|
68
73
|
const configPath = codexConfigTomlPath(context.env);
|
|
69
74
|
const raw = (await readFileOrUndefined(configPath)) ?? '';
|
|
70
|
-
const block = renderBlock(otlpBase, context.config.
|
|
75
|
+
const block = renderBlock(otlpBase, context.bearer, context.config.otel, context.config.installationId);
|
|
71
76
|
const next = raw.includes(BLOCK_START) ? replaceBlock(raw, block) : appendBlock(raw, block);
|
|
72
77
|
if (typeof next !== 'string')
|
|
73
78
|
return { ok: false, changed: false, messages: [next.error(configPath)] };
|
|
@@ -79,8 +84,11 @@ export class CodexOtelConfigurator {
|
|
|
79
84
|
return { ok: false, changed: false, messages: ['internal error: generated config.toml would not parse; nothing written'] };
|
|
80
85
|
}
|
|
81
86
|
await backupFile(configPath, context.paths.backupsDir, context.env.now());
|
|
82
|
-
// The managed block may carry the bearer token, so the file becomes private
|
|
83
|
-
|
|
87
|
+
// The managed block may carry the bearer token, so the file becomes private
|
|
88
|
+
// — but this file is Codex's, not ours, so the mode it had first is
|
|
89
|
+
// recorded and uninstall puts it back.
|
|
90
|
+
const priorMode = context.bearer ? await currentMode(configPath) : undefined;
|
|
91
|
+
await writeFileAtomic(configPath, next, context.bearer ? SECRET_FILE_MODE : undefined);
|
|
84
92
|
return {
|
|
85
93
|
ok: true,
|
|
86
94
|
changed: true,
|
|
@@ -88,15 +96,18 @@ export class CodexOtelConfigurator {
|
|
|
88
96
|
installState: withOtelInstall(context.installState, CODEX_PROVIDER_ID, {
|
|
89
97
|
configPath,
|
|
90
98
|
ownedKeys: [OTEL_TABLE_KEY],
|
|
91
|
-
configuredAt: context.env.now()
|
|
99
|
+
configuredAt: context.env.now(),
|
|
100
|
+
...(priorMode !== undefined && priorMode !== SECRET_FILE_MODE ? { priorMode } : {})
|
|
92
101
|
})
|
|
93
102
|
};
|
|
94
103
|
}
|
|
95
104
|
/**
|
|
96
105
|
* Remove the managed block from Codex's config.toml.
|
|
97
106
|
*
|
|
98
|
-
* Only
|
|
99
|
-
*
|
|
107
|
+
* Only our own `[otel]` table goes. Everything the developer wrote around the
|
|
108
|
+
* markers — comments included — is preserved byte for byte, and so is
|
|
109
|
+
* anything the agent wrote *inside* them: Codex parks its `[hooks.state]`
|
|
110
|
+
* trust hashes there when it re-serializes the file.
|
|
100
111
|
*
|
|
101
112
|
* @param context - Environment, paths and install state.
|
|
102
113
|
* @returns Whether the file changed, what to tell the user, and the next
|
|
@@ -111,8 +122,17 @@ export class CodexOtelConfigurator {
|
|
|
111
122
|
const next = replaceBlock(raw, undefined);
|
|
112
123
|
if (typeof next !== 'string')
|
|
113
124
|
return { ok: false, changed: false, messages: [next.error(configPath)] };
|
|
125
|
+
// Removal now lifts the agent's own tables back out of the span, so it can
|
|
126
|
+
// reorder the file. A config that parsed before must still parse after; one
|
|
127
|
+
// that never parsed is not ours to refuse over.
|
|
128
|
+
if (tryParseToml(raw) !== undefined && tryParseToml(next) === undefined) {
|
|
129
|
+
return { ok: false, changed: false, messages: [`removing the AgentWatch block from ${configPath} would leave it unparseable; nothing written`] };
|
|
130
|
+
}
|
|
114
131
|
await backupFile(configPath, context.paths.backupsDir, context.env.now());
|
|
115
|
-
|
|
132
|
+
// Restore the mode the file carried before AgentWatch tightened it:
|
|
133
|
+
// `writeFileAtomic` with no mode preserves the target's current one, which
|
|
134
|
+
// is our 0600 on a file that no longer holds a token.
|
|
135
|
+
await writeFileAtomic(configPath, next, context.installState.agents[CODEX_PROVIDER_ID]?.otelPriorMode);
|
|
116
136
|
return {
|
|
117
137
|
ok: true,
|
|
118
138
|
changed: true,
|
|
@@ -120,6 +140,56 @@ export class CodexOtelConfigurator {
|
|
|
120
140
|
installState: withoutOtelInstall(context.installState, CODEX_PROVIDER_ID)
|
|
121
141
|
};
|
|
122
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Swap the bearer in our exporters for the current one.
|
|
145
|
+
*
|
|
146
|
+
* Only the bearer in our own `[otel]` table changes: an MCP server's
|
|
147
|
+
* `Authorization` that Codex parked inside our markers is not ours. No
|
|
148
|
+
* backup: one per rotation would collect copies of every token.
|
|
149
|
+
*
|
|
150
|
+
* @param context - The recorded file, its contents as read and the current bearer.
|
|
151
|
+
* @returns True when the file was rewritten.
|
|
152
|
+
*/
|
|
153
|
+
async rewriteBearer(context) {
|
|
154
|
+
const next = withBearer(context.raw, context.bearer);
|
|
155
|
+
if (next === undefined || next === context.raw || tryParseToml(next) === undefined)
|
|
156
|
+
return false;
|
|
157
|
+
return writeIfUnchanged(context.configPath, context.raw, next, SECRET_FILE_MODE);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Where the managed block's exporters send. The block is AgentWatch's whole,
|
|
161
|
+
* so every endpoint in it is.
|
|
162
|
+
*
|
|
163
|
+
* @param context - Environment.
|
|
164
|
+
* @returns The endpoints; none when there is no block or it does not parse.
|
|
165
|
+
*/
|
|
166
|
+
async exporterEndpoints(context) {
|
|
167
|
+
const raw = await readFileOrUndefined(codexConfigTomlPath(context.env));
|
|
168
|
+
const block = raw?.includes(BLOCK_START) ? extractBlock(raw) : undefined;
|
|
169
|
+
const otel = asRecord((block === undefined ? undefined : tryParseToml(block))?.[OTEL_TABLE_KEY]);
|
|
170
|
+
const endpoints = [];
|
|
171
|
+
for (const key of CODEX_EXPORTER_KEYS) {
|
|
172
|
+
const endpoint = asRecord(asRecord(otel?.[key])?.[OTLP_HTTP_KEY])?.['endpoint'];
|
|
173
|
+
if (typeof endpoint === 'string')
|
|
174
|
+
endpoints.push(endpoint);
|
|
175
|
+
}
|
|
176
|
+
return endpoints;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Signals Codex was asked for but will not be given under current consent.
|
|
180
|
+
*
|
|
181
|
+
* Codex's usage logs and traces both carry tool arguments and results with no
|
|
182
|
+
* per-field filter, so the two of them stand or fall together on
|
|
183
|
+
* `toolContentConsented`.
|
|
184
|
+
*
|
|
185
|
+
* @param config - Effective configuration.
|
|
186
|
+
* @returns The requested signals that are held back; empty when none are.
|
|
187
|
+
*/
|
|
188
|
+
withheldSignals(config) {
|
|
189
|
+
if (codexOtelEnabled(config))
|
|
190
|
+
return [];
|
|
191
|
+
return CODEX_OTEL_SIGNALS.filter((name) => config.otel[name]);
|
|
192
|
+
}
|
|
123
193
|
/**
|
|
124
194
|
* Handle `configure` when Codex telemetry is deliberately off.
|
|
125
195
|
*
|
|
@@ -135,8 +205,8 @@ export class CodexOtelConfigurator {
|
|
|
135
205
|
changed: removed.changed,
|
|
136
206
|
messages: [
|
|
137
207
|
removed.changed
|
|
138
|
-
? 'native OpenTelemetry disabled
|
|
139
|
-
: 'native OpenTelemetry disabled
|
|
208
|
+
? 'native OpenTelemetry disabled by config or content consent; previous configuration removed'
|
|
209
|
+
: 'native OpenTelemetry disabled by config or content consent'
|
|
140
210
|
],
|
|
141
211
|
installState: removed.installState
|
|
142
212
|
};
|
|
@@ -151,6 +221,8 @@ export class CodexOtelConfigurator {
|
|
|
151
221
|
* @returns True when logs or traces are on.
|
|
152
222
|
*/
|
|
153
223
|
function codexOtelEnabled(config) {
|
|
224
|
+
if (!toolContentConsented(config))
|
|
225
|
+
return false;
|
|
154
226
|
return config.otel.logs || config.otel.traces;
|
|
155
227
|
}
|
|
156
228
|
/**
|
|
@@ -166,15 +238,16 @@ function codexSignalNames(signals) {
|
|
|
166
238
|
* Status when Codex telemetry is deliberately off.
|
|
167
239
|
*
|
|
168
240
|
* @param hasBlock - Whether our managed block is still in the file.
|
|
241
|
+
* @param detail - Why native telemetry should be absent.
|
|
169
242
|
* @returns Configured, unless our leftovers are still there.
|
|
170
243
|
*/
|
|
171
|
-
function inspectDisabled(hasBlock) {
|
|
244
|
+
function inspectDisabled(hasBlock, detail) {
|
|
172
245
|
if (!hasBlock)
|
|
173
|
-
return { supported: true, configured: true, detail
|
|
246
|
+
return { supported: true, configured: true, detail };
|
|
174
247
|
return {
|
|
175
248
|
supported: true,
|
|
176
249
|
configured: false,
|
|
177
|
-
detail:
|
|
250
|
+
detail: `${detail}, but the AgentWatch [otel] block remains — run \`agentwatch setup\``
|
|
178
251
|
};
|
|
179
252
|
}
|
|
180
253
|
/**
|
|
@@ -188,8 +261,15 @@ function inspectManagedBlock(raw, config) {
|
|
|
188
261
|
const otlpBase = otlpBaseUrl(config);
|
|
189
262
|
if (!otlpBase)
|
|
190
263
|
return { supported: true, configured: false, detail: 'no backend endpoint configured' };
|
|
191
|
-
|
|
192
|
-
|
|
264
|
+
// The bearer's value is not compared: it is the access token, which the hook
|
|
265
|
+
// path rotates. Only whether a header is there, when there is a credential.
|
|
266
|
+
// An install key still in the block once a device exists is stale.
|
|
267
|
+
const block = extractBlock(raw);
|
|
268
|
+
const device = deviceFor(config);
|
|
269
|
+
if (device && config.token && block?.includes(config.token))
|
|
270
|
+
return { supported: true, configured: false, detail: 'AgentWatch [otel] block still holds the install key — run `agentwatch setup`' };
|
|
271
|
+
const actual = block?.replace(RE_BEARER_HEADER, `$1${BEARER_PLACEHOLDER}$3`);
|
|
272
|
+
const expected = renderBlock(otlpBase, hasCredential(config) ? BEARER_PLACEHOLDER : undefined, config.otel, config.installationId).trim();
|
|
193
273
|
if (actual === expected)
|
|
194
274
|
return { supported: true, configured: true };
|
|
195
275
|
return { supported: true, configured: false, detail: 'AgentWatch [otel] block is incomplete or stale — run `agentwatch setup`' };
|
|
@@ -203,13 +283,22 @@ function inspectManagedBlock(raw, config) {
|
|
|
203
283
|
* @param otlpBase - Backend OTLP base URL.
|
|
204
284
|
* @param token - Bearer token, when one is configured.
|
|
205
285
|
* @param signals - The signal selection.
|
|
286
|
+
* @param installationId - This installation's id, when one exists.
|
|
206
287
|
* @returns The block text, newline-terminated.
|
|
207
288
|
*/
|
|
208
|
-
function renderBlock(otlpBase, token, signals) {
|
|
209
|
-
|
|
289
|
+
function renderBlock(otlpBase, token, signals, installationId) {
|
|
290
|
+
// Codex has no header helper and reads this map once, when a session starts
|
|
291
|
+
// (docs/NATIVE_OTLP_TOKENS.md), so the bearer is the short-lived access token
|
|
292
|
+
// and the hook path rewrites it as it rotates. The installation id is fixed
|
|
293
|
+
// for the life of the config, so that suits it; a developer identity would
|
|
294
|
+
// not, which is why one is never put here.
|
|
295
|
+
const headers = token
|
|
296
|
+
? `, headers = { ${tomlHeaders(token, installationId)} }`
|
|
297
|
+
: '';
|
|
210
298
|
return [
|
|
211
299
|
BLOCK_START,
|
|
212
300
|
`[${OTEL_TABLE_KEY}]`,
|
|
301
|
+
'log_user_prompt = false',
|
|
213
302
|
signals.logs
|
|
214
303
|
? `exporter = { otlp-http = { endpoint = "${escapeTomlString(joinUrl(otlpBase, LOGS_PATH))}", protocol = "json"${headers} } }`
|
|
215
304
|
: 'exporter = "none"',
|
|
@@ -222,22 +311,77 @@ function renderBlock(otlpBase, token, signals) {
|
|
|
222
311
|
''
|
|
223
312
|
].join('\n');
|
|
224
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* The `key = "value"` pairs of a Codex exporter's header map.
|
|
316
|
+
*
|
|
317
|
+
* Bearer first, so a reader of the config sees the credential where the other
|
|
318
|
+
* agents put it. The installation id is omitted rather than written empty: an
|
|
319
|
+
* absent header and a header naming nothing are different claims, and only the
|
|
320
|
+
* first is true before an install has an id.
|
|
321
|
+
*/
|
|
322
|
+
function tomlHeaders(token, installationId) {
|
|
323
|
+
const pairs = [`"Authorization" = "Bearer ${escapeTomlString(token)}"`];
|
|
324
|
+
if (installationId) {
|
|
325
|
+
pairs.push(`"${INSTALLATION_HEADER}" = "${escapeTomlString(installationId)}"`);
|
|
326
|
+
}
|
|
327
|
+
return pairs.join(', ');
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The file with our exporters' bearer set to this one.
|
|
331
|
+
*
|
|
332
|
+
* @param raw - The whole config.toml.
|
|
333
|
+
* @param bearer - The bearer to present.
|
|
334
|
+
* @returns The next contents, or undefined when there is no well-formed block.
|
|
335
|
+
*/
|
|
336
|
+
function withBearer(raw, bearer) {
|
|
337
|
+
const span = managedSpan(raw);
|
|
338
|
+
if (!span)
|
|
339
|
+
return undefined;
|
|
340
|
+
// Our table runs from its `[otel]` header to the first foreign table;
|
|
341
|
+
// `managed` re-joins the span without that, so its length up to the end
|
|
342
|
+
// marker is ours in the raw text. A table Codex parked before our header, or
|
|
343
|
+
// a span with no header at all, is never touched.
|
|
344
|
+
const ownedEnd = span.start + span.managed.length - BLOCK_END.length;
|
|
345
|
+
const header = raw.indexOf(`\n[${OTEL_TABLE_KEY}]`, span.start);
|
|
346
|
+
const ownedStart = header + 1;
|
|
347
|
+
if (header === -1 || ownedStart >= ownedEnd)
|
|
348
|
+
return undefined;
|
|
349
|
+
const owned = raw.slice(ownedStart, ownedEnd).replace(RE_BEARER_HEADER, (_match, head, _old, tail) => head + escapeTomlString(bearer) + tail);
|
|
350
|
+
return raw.slice(0, ownedStart) + owned + raw.slice(ownedEnd);
|
|
351
|
+
}
|
|
225
352
|
/**
|
|
226
353
|
* Replace, or remove, the marker-delimited block.
|
|
227
354
|
*
|
|
355
|
+
* Only our own `[otel]` table goes. Codex re-serializes config.toml as it runs
|
|
356
|
+
* and writes its own tables — the `[hooks.state]` trust hashes among them —
|
|
357
|
+
* after `[otel]` but before our end marker, which puts them inside the span.
|
|
358
|
+
* Deleting the span whole took those with it, so every `off`/`on` cost the
|
|
359
|
+
* developer another `codex` → `/hooks` → trust round.
|
|
360
|
+
*
|
|
228
361
|
* @param raw - The whole config.toml.
|
|
229
362
|
* @param block - The new block, or undefined to remove it.
|
|
230
363
|
* @returns The next contents, or a failure when the markers are malformed.
|
|
231
364
|
*/
|
|
232
365
|
function replaceBlock(raw, block) {
|
|
233
|
-
const
|
|
234
|
-
if (!
|
|
366
|
+
const span = managedSpan(raw);
|
|
367
|
+
if (!span)
|
|
235
368
|
return malformedMarkers;
|
|
236
|
-
const head = raw.slice(0,
|
|
237
|
-
const tail = raw.slice(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
369
|
+
const head = raw.slice(0, span.start);
|
|
370
|
+
const tail = raw.slice(span.end).replace(RE_LEADING_NEWLINE, '');
|
|
371
|
+
const kept = block === undefined ? head.replace(RE_TRAILING_NEWLINES, '\n') : head + block;
|
|
372
|
+
return withForeign(kept, span.foreign) + tail;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Put back the TOML the agent wrote inside our markers.
|
|
376
|
+
*
|
|
377
|
+
* @param base - Everything up to and including our block, when it stays.
|
|
378
|
+
* @param foreign - The lifted tables, without surrounding blank lines.
|
|
379
|
+
* @returns The two, separated by a blank line.
|
|
380
|
+
*/
|
|
381
|
+
function withForeign(base, foreign) {
|
|
382
|
+
if (foreign === '')
|
|
383
|
+
return base;
|
|
384
|
+
return base === '' ? `${foreign}\n` : `${base}\n${foreign}\n`;
|
|
241
385
|
}
|
|
242
386
|
/**
|
|
243
387
|
* Append the managed block to a config that has none.
|
|
@@ -270,16 +414,39 @@ function blockBounds(raw) {
|
|
|
270
414
|
return { start, end: endMarker + BLOCK_END.length };
|
|
271
415
|
}
|
|
272
416
|
/**
|
|
273
|
-
*
|
|
417
|
+
* Split the marker span at the first table header that is not ours.
|
|
418
|
+
*
|
|
419
|
+
* Everything from our `[otel]` header to the next `[table]` is the block; the
|
|
420
|
+
* rest of the span belongs to whoever wrote it and has to survive.
|
|
274
421
|
*
|
|
275
422
|
* @param raw - The whole config.toml.
|
|
276
|
-
* @returns The
|
|
423
|
+
* @returns The split span, or undefined when the markers are broken.
|
|
277
424
|
*/
|
|
278
|
-
function
|
|
425
|
+
function managedSpan(raw) {
|
|
279
426
|
const bounds = blockBounds(raw);
|
|
280
427
|
if (!bounds)
|
|
281
428
|
return undefined;
|
|
282
|
-
|
|
429
|
+
const span = raw.slice(bounds.start, bounds.end);
|
|
430
|
+
const inner = span.slice(BLOCK_START.length, span.length - BLOCK_END.length);
|
|
431
|
+
const lines = inner.split('\n');
|
|
432
|
+
const ours = lines.findIndex((line) => line.trimStart().startsWith(`[${OTEL_TABLE_KEY}]`));
|
|
433
|
+
const next = lines.findIndex((line, index) => index > ours && RE_TOML_TABLE_HEADER.test(line));
|
|
434
|
+
if (ours === -1 || next === -1)
|
|
435
|
+
return { ...bounds, managed: span, foreign: '' };
|
|
436
|
+
return {
|
|
437
|
+
...bounds,
|
|
438
|
+
managed: BLOCK_START + lines.slice(0, next).join('\n') + BLOCK_END,
|
|
439
|
+
foreign: lines.slice(next).join('\n').trim()
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* The managed block as it currently stands in the file, foreign tables excluded.
|
|
444
|
+
*
|
|
445
|
+
* @param raw - The whole config.toml.
|
|
446
|
+
* @returns The block text, or undefined when the markers are broken.
|
|
447
|
+
*/
|
|
448
|
+
function extractBlock(raw) {
|
|
449
|
+
return managedSpan(raw)?.managed.trim();
|
|
283
450
|
}
|
|
284
451
|
/**
|
|
285
452
|
* Escape a string for a TOML basic-string literal.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { hookRefusal } from '../shared/hook-refusal.js';
|
|
1
|
+
import { hookNotice, hookRefusal } from '../shared/hook-refusal.js';
|
|
2
2
|
import { CODEX_PROMPT_SUBMIT_EVENTS } from './constants/codex.constants.js';
|
|
3
3
|
import { detectCodex } from './codex.detect.js';
|
|
4
4
|
import { installCodexHooks, uninstallCodexHooks } from './codex.hooks.js';
|
|
5
|
-
import { parseCodexHookEvent } from './codex.adapter.js';
|
|
5
|
+
import { codexShellCall, parseCodexHookEvent } from './codex.adapter.js';
|
|
6
6
|
import { CodexOtelConfigurator } from './codex.otel.js';
|
|
7
7
|
export const codexProvider = {
|
|
8
8
|
id: 'codex',
|
|
@@ -21,5 +21,8 @@ export const codexProvider = {
|
|
|
21
21
|
* parser accepts.
|
|
22
22
|
*/
|
|
23
23
|
getBlockResponse: (payload, message) => hookRefusal(payload, CODEX_PROMPT_SUBMIT_EVENTS, { continue: false, stopReason: message, systemMessage: message }),
|
|
24
|
+
/** A line for the developer after a shell run, as `systemMessage`; never plain stdout. */
|
|
25
|
+
getNoticeResponse: (payload, message) => hookNotice(payload, message),
|
|
26
|
+
shellCall: codexShellCall,
|
|
24
27
|
nativeTelemetry: new CodexOtelConfigurator()
|
|
25
28
|
};
|
|
@@ -28,6 +28,8 @@ export declare const CODEX_HOOKS_DISABLED_WARNING = "warning: [features] hooks =
|
|
|
28
28
|
export declare const CODEX_EVENT_TYPE_MAP: Readonly<Record<string, CanonicalEventType>>;
|
|
29
29
|
/** Hooks whose canonical type depends on which tool ran. */
|
|
30
30
|
export declare const CODEX_TOOL_EVENTS: ReadonlySet<string>;
|
|
31
|
+
/** The hooks a shell call is read on: once before it runs, once after (same `tool_input`). */
|
|
32
|
+
export declare const CODEX_SHELL_CALL_EVENTS: ReadonlySet<string>;
|
|
31
33
|
/**
|
|
32
34
|
* The one hook a budget refusal may travel on.
|
|
33
35
|
*
|
|
@@ -49,6 +49,8 @@ export const CODEX_EVENT_TYPE_MAP = {
|
|
|
49
49
|
};
|
|
50
50
|
/** Hooks whose canonical type depends on which tool ran. */
|
|
51
51
|
export const CODEX_TOOL_EVENTS = new Set(['PreToolUse', 'PostToolUse', 'PermissionRequest']);
|
|
52
|
+
/** The hooks a shell call is read on: once before it runs, once after (same `tool_input`). */
|
|
53
|
+
export const CODEX_SHELL_CALL_EVENTS = new Set(['PreToolUse', 'PostToolUse']);
|
|
52
54
|
/**
|
|
53
55
|
* The one hook a budget refusal may travel on.
|
|
54
56
|
*
|
|
@@ -59,4 +61,18 @@ export const CODEX_TOOL_EVENTS = new Set(['PreToolUse', 'PostToolUse', 'Permissi
|
|
|
59
61
|
* because the developer and the transcript both need it.
|
|
60
62
|
*/
|
|
61
63
|
export const CODEX_PROMPT_SUBMIT_EVENTS = new Set(['UserPromptSubmit']);
|
|
64
|
+
/*
|
|
65
|
+
* The untraced-run notice (AWT-310) travels on `PostToolUse` as
|
|
66
|
+
* `{"systemMessage": …}`. Verified against openai/codex
|
|
67
|
+
* `codex-rs/hooks/src/schema.rs`, 2026-10-07: `PostToolUseCommandOutputWire`
|
|
68
|
+
* flattens `HookUniversalOutputWire` (`continue`, `stopReason`,
|
|
69
|
+
* `suppressOutput`, `systemMessage`), so the key survives `deny_unknown_fields`.
|
|
70
|
+
*
|
|
71
|
+
* Shown only in the interactive TUI ("PostToolUse (completed) says: …", seen
|
|
72
|
+
* live on codex-cli 0.150.0, 2026-10-08). `codex exec` prints no hook's
|
|
73
|
+
* `systemMessage` on any event (`exec/src/event_processor_with_human_output.rs`
|
|
74
|
+
* logs only the event name and status; JSON mode drops hooks; still so in
|
|
75
|
+
* 0.160.1), so a pending notice replayed at `UserPromptSubmit` would be dropped
|
|
76
|
+
* the same way. Accepted: exec runs are headless, with nobody to read it.
|
|
77
|
+
*/
|
|
62
78
|
export const CODEX_UNKNOWN_EVENT = 'unknown';
|
|
@@ -11,6 +11,9 @@ export declare const BLOCK_START = "# >>> agentwatch managed block \u2014 do not
|
|
|
11
11
|
export declare const BLOCK_END = "# <<< agentwatch managed block <<<";
|
|
12
12
|
/** The one config key the managed block owns. */
|
|
13
13
|
export declare const OTEL_TABLE_KEY = "otel";
|
|
14
|
+
/** The `[otel]` keys that hold an exporter, and the table naming its OTLP/HTTP target. */
|
|
15
|
+
export declare const CODEX_EXPORTER_KEYS: readonly string[];
|
|
16
|
+
export declare const OTLP_HTTP_KEY = "otlp-http";
|
|
14
17
|
/** Signals Codex actually exports; `metrics` has no effect there. */
|
|
15
18
|
export declare const CODEX_OTEL_SIGNALS: readonly ["logs", "traces"];
|
|
16
19
|
/** OTLP/HTTP signal routes; Codex needs full endpoints, not a base. */
|
|
@@ -20,3 +23,10 @@ export declare const RE_LEADING_NEWLINE: RegExp;
|
|
|
20
23
|
export declare const RE_TRAILING_NEWLINES: RegExp;
|
|
21
24
|
export declare const RE_TOML_BACKSLASH: RegExp;
|
|
22
25
|
export declare const RE_TOML_QUOTE: RegExp;
|
|
26
|
+
/** Start of any TOML table header, used to find where our block stops being ours. */
|
|
27
|
+
export declare const RE_TOML_TABLE_HEADER: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* The bearer in our exporters' header maps, value captured. A token rotation
|
|
30
|
+
* changes only this, so drift checks ignore it and the hook rewrites it alone.
|
|
31
|
+
*/
|
|
32
|
+
export declare const RE_BEARER_HEADER: RegExp;
|
|
@@ -11,6 +11,9 @@ export const BLOCK_START = '# >>> agentwatch managed block — do not edit; `age
|
|
|
11
11
|
export const BLOCK_END = '# <<< agentwatch managed block <<<';
|
|
12
12
|
/** The one config key the managed block owns. */
|
|
13
13
|
export const OTEL_TABLE_KEY = 'otel';
|
|
14
|
+
/** The `[otel]` keys that hold an exporter, and the table naming its OTLP/HTTP target. */
|
|
15
|
+
export const CODEX_EXPORTER_KEYS = ['exporter', 'trace_exporter'];
|
|
16
|
+
export const OTLP_HTTP_KEY = 'otlp-http';
|
|
14
17
|
/** Signals Codex actually exports; `metrics` has no effect there. */
|
|
15
18
|
export const CODEX_OTEL_SIGNALS = ['logs', 'traces'];
|
|
16
19
|
/** OTLP/HTTP signal routes; Codex needs full endpoints, not a base. */
|
|
@@ -20,3 +23,10 @@ export const RE_LEADING_NEWLINE = /^\n/;
|
|
|
20
23
|
export const RE_TRAILING_NEWLINES = /\n+$/;
|
|
21
24
|
export const RE_TOML_BACKSLASH = /\\/g;
|
|
22
25
|
export const RE_TOML_QUOTE = /"/g;
|
|
26
|
+
/** Start of any TOML table header, used to find where our block stops being ours. */
|
|
27
|
+
export const RE_TOML_TABLE_HEADER = /^\s*\[/;
|
|
28
|
+
/**
|
|
29
|
+
* The bearer in our exporters' header maps, value captured. A token rotation
|
|
30
|
+
* changes only this, so drift checks ignore it and the hook rewrites it alone.
|
|
31
|
+
*/
|
|
32
|
+
export const RE_BEARER_HEADER = /("Authorization" = "Bearer )((?:[^"\\]|\\.)*)(")/g;
|
|
@@ -28,6 +28,11 @@ export declare const RE_SHELL_CONTROL: RegExp;
|
|
|
28
28
|
/** Characters a double quote still escapes inside a quoted argument. */
|
|
29
29
|
export declare const RE_DOUBLE_QUOTE_ESCAPABLE: RegExp;
|
|
30
30
|
export declare const RE_WHITESPACE: RegExp;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Stands in for the bearer when a drift check compares an agent's config with
|
|
33
|
+
* what setup would write: the access token rotates hourly, and a rotated token
|
|
34
|
+
* is not drift.
|
|
35
|
+
*/
|
|
36
|
+
export declare const BEARER_PLACEHOLDER = "<access token>";
|
|
37
|
+
/** How every literal bearer the edge writes into an agent's config starts. */
|
|
38
|
+
export declare const BEARER_PREFIX = "Bearer ";
|
|
@@ -28,6 +28,11 @@ export const RE_SHELL_CONTROL = /[|&;<>\r\n]/;
|
|
|
28
28
|
/** Characters a double quote still escapes inside a quoted argument. */
|
|
29
29
|
export const RE_DOUBLE_QUOTE_ESCAPABLE = /["\\$`]/;
|
|
30
30
|
export const RE_WHITESPACE = /\s/;
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Stands in for the bearer when a drift check compares an agent's config with
|
|
33
|
+
* what setup would write: the access token rotates hourly, and a rotated token
|
|
34
|
+
* is not drift.
|
|
35
|
+
*/
|
|
36
|
+
export const BEARER_PLACEHOLDER = '<access token>';
|
|
37
|
+
/** How every literal bearer the edge writes into an agent's config starts. */
|
|
38
|
+
export const BEARER_PREFIX = 'Bearer ';
|
|
@@ -44,6 +44,15 @@ export declare const CURSOR_TOOL_KINDS: Readonly<Record<string, ToolKind>>;
|
|
|
44
44
|
export declare const CURSOR_READ_TOOL_NAME = "Read";
|
|
45
45
|
export declare const CURSOR_EDIT_TOOL_NAME = "Edit";
|
|
46
46
|
export declare const CURSOR_SHELL_TOOL_NAME = "Shell";
|
|
47
|
+
/** Server segment of an MCP key when a Cursor hook names neither a server, a url nor a command. */
|
|
48
|
+
export declare const CURSOR_UNKNOWN_MCP_SERVER = "unknown";
|
|
49
|
+
/** The dedicated shell hooks, with `command` (and, before the call, `cwd`) at the top level. */
|
|
50
|
+
export declare const CURSOR_SHELL_EVENTS: ReadonlySet<string>;
|
|
51
|
+
/** The generic hook that fires before any tool call, the shell's included. */
|
|
52
|
+
export declare const CURSOR_GENERIC_TOOL_START_EVENT = "preToolUse";
|
|
53
|
+
/** Where `preToolUse` for `Shell` puts the command and its directory in `tool_input`. */
|
|
54
|
+
export declare const CURSOR_SHELL_COMMAND_KEY = "command";
|
|
55
|
+
export declare const CURSOR_SHELL_WORKDIR_KEY = "working_directory";
|
|
47
56
|
/** Attachment field carrying a file path. */
|
|
48
57
|
export declare const ATTACHMENT_FILE_PATH_KEY = "file_path";
|
|
49
58
|
/**
|
|
@@ -81,6 +81,15 @@ export const CURSOR_TOOL_KINDS = {
|
|
|
81
81
|
export const CURSOR_READ_TOOL_NAME = 'Read';
|
|
82
82
|
export const CURSOR_EDIT_TOOL_NAME = 'Edit';
|
|
83
83
|
export const CURSOR_SHELL_TOOL_NAME = 'Shell';
|
|
84
|
+
/** Server segment of an MCP key when a Cursor hook names neither a server, a url nor a command. */
|
|
85
|
+
export const CURSOR_UNKNOWN_MCP_SERVER = 'unknown';
|
|
86
|
+
/** The dedicated shell hooks, with `command` (and, before the call, `cwd`) at the top level. */
|
|
87
|
+
export const CURSOR_SHELL_EVENTS = new Set(['beforeShellExecution', 'afterShellExecution']);
|
|
88
|
+
/** The generic hook that fires before any tool call, the shell's included. */
|
|
89
|
+
export const CURSOR_GENERIC_TOOL_START_EVENT = 'preToolUse';
|
|
90
|
+
/** Where `preToolUse` for `Shell` puts the command and its directory in `tool_input`. */
|
|
91
|
+
export const CURSOR_SHELL_COMMAND_KEY = 'command';
|
|
92
|
+
export const CURSOR_SHELL_WORKDIR_KEY = 'working_directory';
|
|
84
93
|
/** Attachment field carrying a file path. */
|
|
85
94
|
export const ATTACHMENT_FILE_PATH_KEY = 'file_path';
|
|
86
95
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentWatchEvent } from '../../events/types/events.types.js';
|
|
2
|
-
import type { HookContext } from '../types/provider.types.js';
|
|
2
|
+
import type { HookContext, ShellCall } from '../types/provider.types.js';
|
|
3
3
|
export type { CursorPayload } from './types/cursor.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Translate one Cursor hook payload into canonical events.
|
|
@@ -9,3 +9,35 @@ export type { CursorPayload } from './types/cursor.types.js';
|
|
|
9
9
|
* @returns The canonical events, or an empty list for an unusable payload.
|
|
10
10
|
*/
|
|
11
11
|
export declare function parseCursorHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
|
|
12
|
+
/**
|
|
13
|
+
* The command a shell call is about to run, and the directory it runs in.
|
|
14
|
+
*
|
|
15
|
+
* Cursor announces one call twice (cursor.com/docs/hooks): `beforeShellExecution`
|
|
16
|
+
* with `command` and `cwd` at the top level, and the generic `preToolUse` for
|
|
17
|
+
* `Shell` with `tool_input.command` and `tool_input.working_directory`. Both are
|
|
18
|
+
* read, so both name the same checkout; a hook left unread would instead vote
|
|
19
|
+
* for the cwd it sits in. `afterShellExecution` is read too: a command can
|
|
20
|
+
* create the worktree it works in.
|
|
21
|
+
*
|
|
22
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
23
|
+
* @returns The call, or undefined for any other payload.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cursorShellCall(rawPayload: unknown): ShellCall | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The folders the Cursor window has open, absolute paths only.
|
|
28
|
+
*
|
|
29
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
30
|
+
* @returns The roots; empty when the payload names none.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cursorWorkspaceRoots(rawPayload: unknown): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Where a payload that reports no `cwd` happened: the first workspace root.
|
|
35
|
+
*
|
|
36
|
+
* Cursor puts `cwd` on its shell and tool hooks only; the prompt, file-edit and
|
|
37
|
+
* stop hooks would otherwise resolve against the directory the hook process
|
|
38
|
+
* started in, which Cursor does not promise is the workspace.
|
|
39
|
+
*
|
|
40
|
+
* @param rawPayload - Raw JSON from the hook's stdin.
|
|
41
|
+
* @returns The first workspace root, or undefined.
|
|
42
|
+
*/
|
|
43
|
+
export declare function cursorCwd(rawPayload: unknown): string | undefined;
|