@agent-watch-ai/edge 0.6.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 +219 -9
- package/README.md +303 -4
- 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 +5 -2
- package/dist/events/constants/events.constants.js +4 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/product-event.d.ts +6 -3
- package/dist/events/types/events.types.d.ts +6 -0
- package/dist/events/types/replay-progress.types.d.ts +26 -0
- package/dist/events/types/replay-progress.types.js +1 -0
- package/dist/events/types/repo-tree.types.d.ts +2 -1
- package/dist/feature/ticket-candidates.d.ts +1 -1
- package/dist/git/checkout-root.d.ts +15 -0
- package/dist/git/checkout-root.js +18 -0
- package/dist/git/code-state.d.ts +2 -16
- package/dist/git/code-state.js +11 -12
- package/dist/git/constants/git.constants.d.ts +31 -11
- package/dist/git/constants/git.constants.js +36 -12
- package/dist/git/fingerprint.d.ts +3 -6
- package/dist/git/fingerprint.js +5 -8
- package/dist/git/git-context.js +5 -1
- package/dist/git/index.d.ts +1 -2
- package/dist/git/index.js +1 -1
- package/dist/git/repo-snapshot.d.ts +13 -4
- package/dist/git/repo-snapshot.js +47 -9
- package/dist/git/types/snapshot.types.d.ts +2 -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 +81 -57
- package/dist/privacy/product-capture.js +2 -0
- package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.capture.js +5 -0
- package/dist/providers/antigravity/antigravity.detect.js +8 -22
- package/dist/providers/antigravity/antigravity.provider.js +10 -3
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
- package/dist/providers/claude/claude.adapter.js +9 -6
- package/dist/providers/claude/claude.detect.js +2 -17
- package/dist/providers/claude/claude.otel.d.ts +21 -3
- package/dist/providers/claude/claude.otel.js +216 -61
- package/dist/providers/claude/claude.provider.js +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 +71 -41
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +3 -1
- package/dist/snapshot/constants/snapshot-stages.constants.js +3 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +34 -7
- package/dist/snapshot/constants/snapshot.constants.js +34 -7
- package/dist/snapshot/index.d.ts +2 -2
- package/dist/snapshot/index.js +1 -1
- package/dist/snapshot/snapshot-pipeline.js +89 -26
- package/dist/snapshot/snapshot-state.js +6 -2
- package/dist/snapshot/tree-pipeline.d.ts +1 -1
- package/dist/snapshot/tree-pipeline.js +34 -15
- package/dist/snapshot/types/snapshot.types.d.ts +20 -3
- package/dist/storage/schemas/storage.schema.d.ts +2 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/transport/delivery-stats.d.ts +13 -1
- package/dist/transport/delivery-stats.js +18 -2
- package/dist/transport/delivery.d.ts +4 -3
- package/dist/transport/delivery.js +21 -7
- package/dist/transport/identity-delivery.d.ts +20 -0
- package/dist/transport/identity-delivery.js +41 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.js +1 -0
- package/dist/transport/types/delivery-flow.types.d.ts +7 -0
- package/dist/turns/claude-transcript.js +4 -12
- package/dist/turns/codex-transcript.d.ts +9 -0
- package/dist/turns/codex-transcript.js +27 -19
- package/dist/turns/constants/turns.constants.d.ts +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 +7 -2
- 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 +17 -1
- package/dist/turns/types/turn-tracker.types.d.ts +3 -1
- package/dist/turns/work-checkout.js +1 -2
- package/docs/AUDIT_PROMPT.md +10 -0
- package/docs/DATA_HANDLING.md +193 -7
- package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
- package/docs/PERFORMANCE.md +10 -0
- package/package.json +3 -2
- package/dist/events/canonical-event.d.ts +0 -10
- package/dist/events/canonical-event.js +0 -9
- package/dist/git/repository-root.d.ts +0 -39
- package/dist/git/repository-root.js +0 -131
- package/dist/git/types/repository-root.types.d.ts +0 -11
- package/dist/transport/transport.d.ts +0 -6
- package/dist/turns/codex-originator.d.ts +0 -11
- package/dist/turns/cursor-transcript.d.ts +0 -21
- package/dist/turns/cursor-transcript.js +0 -66
- package/dist/turns/native-session-titles.d.ts +0 -26
- package/dist/turns/native-session-titles.js +0 -102
- /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
- /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
package/dist/cli/status.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { eventsUrl } from '../config/config.js';
|
|
2
2
|
import { describeCredential } from '../credentials/credential-status.js';
|
|
3
|
+
import { identityOf } from '../credentials/identity.js';
|
|
4
|
+
import { describeReplay } from '../replay/describe.js';
|
|
5
|
+
import { readReplayRecord, replayStateFile } from '../replay/replay-state.js';
|
|
6
|
+
import { identityPaths, unattributedCount, unattributedQueue } from '../transport/queue-partition.js';
|
|
3
7
|
import { collectGitContext } from '../git/git-context.js';
|
|
8
|
+
import { runCaptureRoute } from '../providers/provider.js';
|
|
4
9
|
import { providers } from '../providers/registry.js';
|
|
5
10
|
import { AUTH_BLOCK_REPROBE_MS } from '../transport/constants/transport.constants.js';
|
|
6
|
-
import {
|
|
7
|
-
import { buildAuthBlock, buildCliContext, buildDeliveryStats, buildHookCommand, buildQueue, buildTransport, resolveContextBearer } from './context.js';
|
|
11
|
+
import { buildCliContext, buildHookCommand, buildQueue, buildTransport, openIdentityDelivery, resolveContextBearer } from './context.js';
|
|
8
12
|
import { STATUS_SEND_TIMEOUT_MS } from './constants/cli.constants.js';
|
|
9
13
|
import { bold, customEndpointOverride, dim, println, symbols } from './ui.js';
|
|
10
14
|
/**
|
|
@@ -34,8 +38,22 @@ export async function runStatus(env) {
|
|
|
34
38
|
}
|
|
35
39
|
println();
|
|
36
40
|
await reportDelivery(context);
|
|
41
|
+
await reportReplay(context);
|
|
37
42
|
return 0;
|
|
38
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Where the replay of earlier sessions stands, when there has been one.
|
|
46
|
+
*
|
|
47
|
+
* @param context - Resolved CLI context.
|
|
48
|
+
*/
|
|
49
|
+
async function reportReplay(context) {
|
|
50
|
+
const record = await readReplayRecord(replayStateFile(identityPaths(context.paths, identityOf(context.identityConfig)).statsFile));
|
|
51
|
+
if (!record)
|
|
52
|
+
return;
|
|
53
|
+
println();
|
|
54
|
+
println(bold('Replay'));
|
|
55
|
+
println(`${symbols.ok} ${describeReplay(record, context.env.now().getTime())}`);
|
|
56
|
+
}
|
|
39
57
|
/**
|
|
40
58
|
* Whether a backend is configured.
|
|
41
59
|
*
|
|
@@ -116,8 +134,12 @@ async function reportAgent(provider, context) {
|
|
|
116
134
|
}
|
|
117
135
|
println(`${symbols.ok} detected ${dim(`(${detection.evidence[0] ?? ''})`)}`);
|
|
118
136
|
println(detection.hooksInstalled ? `${symbols.ok} hooks installed` : `${symbols.off} hooks not installed`);
|
|
119
|
-
if (
|
|
137
|
+
if (context.disabled)
|
|
120
138
|
return;
|
|
139
|
+
// The caveats describe what capture misses, so they are said only where capture runs.
|
|
140
|
+
if (detection.hooksInstalled)
|
|
141
|
+
for (const caveat of provider.caveats ?? [])
|
|
142
|
+
println(`${symbols.warn} ${caveat.detail}`);
|
|
121
143
|
const setupContext = {
|
|
122
144
|
env: context.env,
|
|
123
145
|
paths: context.paths,
|
|
@@ -125,6 +147,9 @@ async function reportAgent(provider, context) {
|
|
|
125
147
|
hookCommand: buildHookCommand(context.env, provider.id),
|
|
126
148
|
installState: context.installState
|
|
127
149
|
};
|
|
150
|
+
await reportRunCapture(provider, { ...setupContext, config: context.identityConfig });
|
|
151
|
+
if (!provider.nativeTelemetry)
|
|
152
|
+
return;
|
|
128
153
|
const otel = await provider.nativeTelemetry.inspect(setupContext);
|
|
129
154
|
if (otel.configured) {
|
|
130
155
|
println(`${symbols.ok} native OpenTelemetry ${otel.detail ?? 'configured'}`);
|
|
@@ -132,6 +157,19 @@ async function reportAgent(provider, context) {
|
|
|
132
157
|
}
|
|
133
158
|
println(otel.conflict ? `${symbols.warn} native OpenTelemetry: ${otel.conflict}` : `${symbols.off} native OpenTelemetry not configured`);
|
|
134
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Whether what this agent's shell tool starts has its provider calls captured.
|
|
162
|
+
*
|
|
163
|
+
* @param provider - The agent's provider.
|
|
164
|
+
* @param context - The agent's setup context, under the identity of this directory.
|
|
165
|
+
*/
|
|
166
|
+
async function reportRunCapture(provider, context) {
|
|
167
|
+
const route = runCaptureRoute(provider);
|
|
168
|
+
const capture = route ? await route.inspect(context) : { on: false, reason: 'not available for this agent yet' };
|
|
169
|
+
println(capture.on ? `${symbols.ok} run capture on` : `${symbols.off} run capture off: ${capture.reason ?? 'unknown'}`);
|
|
170
|
+
if (capture.warning)
|
|
171
|
+
println(`${symbols.warn} run capture: ${capture.warning}`);
|
|
172
|
+
}
|
|
135
173
|
/**
|
|
136
174
|
* The backlog, and everything the queue has lost.
|
|
137
175
|
*
|
|
@@ -143,8 +181,7 @@ async function reportAgent(provider, context) {
|
|
|
143
181
|
async function reportDelivery(context) {
|
|
144
182
|
println(bold('Delivery'));
|
|
145
183
|
const queue = await buildQueue(context);
|
|
146
|
-
const deliveryStats =
|
|
147
|
-
const authBlock = buildAuthBlock(context);
|
|
184
|
+
const { stats: deliveryStats, authBlock } = openIdentityDelivery(context);
|
|
148
185
|
const pending = await retryBacklog(context, queue, deliveryStats, authBlock);
|
|
149
186
|
println(pending === 0 ? `${symbols.ok} healthy` : `${symbols.warn} backlog`);
|
|
150
187
|
println(`${pending} pending event(s)`);
|
|
@@ -225,6 +262,9 @@ async function retryBacklog(context, queue, deliveryStats, authBlock) {
|
|
|
225
262
|
function reportLosses(context, stats) {
|
|
226
263
|
if (!stats)
|
|
227
264
|
return;
|
|
265
|
+
if (stats.totalCapturedDropped > 0) {
|
|
266
|
+
println(`${symbols.warn} ${stats.totalCapturedDropped} captured call(s) dropped (no session or run to attach them to, or over the spool's limit)`);
|
|
267
|
+
}
|
|
228
268
|
if (stats.totalRejected > 0) {
|
|
229
269
|
const last = stats.lastRejectedAt ? ` (last ${stats.lastRejectedCount} at ${stats.lastRejectedAt})` : '';
|
|
230
270
|
println(`${symbols.warn} ${stats.totalRejected} event(s) permanently rejected by the backend${last}`);
|
package/dist/cli/toggle.js
CHANGED
|
@@ -65,6 +65,7 @@ export async function runToggle(env, enabled) {
|
|
|
65
65
|
await writeFileAtomic(file, JSON.stringify({ providers: targets }), SECRET_FILE_MODE);
|
|
66
66
|
let installState = context.installState;
|
|
67
67
|
let failures = 0;
|
|
68
|
+
let skipped = 0;
|
|
68
69
|
const restored = [];
|
|
69
70
|
// As setup writes it: the machine's access token, or its install key while it has no device.
|
|
70
71
|
const bearer = enabled ? await nativeExporterBearer({ env, paths: context.paths, timeoutMs: SETUP_EXCHANGE_TIMEOUT_MS }, context.config) : undefined;
|
|
@@ -85,6 +86,13 @@ export async function runToggle(env, enabled) {
|
|
|
85
86
|
restored.push(provider);
|
|
86
87
|
for (const message of outcome.messages)
|
|
87
88
|
println(`${provider.displayName}: ${message}`);
|
|
89
|
+
// The developer's own telemetry config in the way is a skipped step, as
|
|
90
|
+
// in setup. Counting it would keep the marker forever, and setup refuses
|
|
91
|
+
// while it is there.
|
|
92
|
+
if (enabled && outcome.conflict) {
|
|
93
|
+
skipped++;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
88
96
|
if (!outcome.ok)
|
|
89
97
|
failures++;
|
|
90
98
|
}
|
|
@@ -110,6 +118,8 @@ export async function runToggle(env, enabled) {
|
|
|
110
118
|
if (enabled && failures === 0)
|
|
111
119
|
await fs.rm(file);
|
|
112
120
|
println(enabled && failures === 0 ? 'AgentWatch enabled.' : 'AgentWatch disabled for hooks and otel-headers.');
|
|
121
|
+
if (enabled && failures === 0 && skipped > 0)
|
|
122
|
+
println(`Native telemetry skipped for ${skipped} agent(s) with their own telemetry config; see above.`);
|
|
113
123
|
println('Restart all running coding agents to apply native telemetry changes; existing processes may retain exporters and credentials.');
|
|
114
124
|
if (failures > 0)
|
|
115
125
|
println('Native telemetry changes are incomplete. Close running agents and retry this command after repair.');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentWatchConfig, ConfigLoadResult } from '../../config/types/config.types.js';
|
|
2
2
|
import type { Env } from '../../core/types/core.types.js';
|
|
3
3
|
import type { GitRunner } from '../../git/types/git.types.js';
|
|
4
|
+
import type { AgentProvider } from '../../providers/types/provider.types.js';
|
|
4
5
|
import type { AgentWatchPaths, InstallState } from '../../storage/types/storage.types.js';
|
|
5
6
|
/** Parsed argv. */
|
|
6
7
|
export interface ParsedArgs {
|
|
@@ -46,6 +47,12 @@ export interface HookRunOptions {
|
|
|
46
47
|
readonly input?: string;
|
|
47
48
|
readonly dryRun?: boolean;
|
|
48
49
|
readonly writeStdout?: (text: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Hands a turn close's payload to a detached `agentwatch hook`; true when
|
|
52
|
+
* it was handed over. Set only by the CLI entry, so tests and the detached
|
|
53
|
+
* child process the payload in place.
|
|
54
|
+
*/
|
|
55
|
+
readonly handOff?: (agentId: string, input: string) => Promise<boolean>;
|
|
49
56
|
}
|
|
50
57
|
export interface SetupOptions {
|
|
51
58
|
readonly env: Env;
|
|
@@ -68,6 +75,8 @@ export interface SetupOptions {
|
|
|
68
75
|
readonly root?: string;
|
|
69
76
|
/** OTLP signal selection: "all", "none" or a comma list of logs,traces,metrics. */
|
|
70
77
|
readonly otel?: string;
|
|
78
|
+
/** The agents `--agent` selected; every registered agent when absent. */
|
|
79
|
+
readonly agents?: readonly AgentProvider[];
|
|
71
80
|
readonly hookCommandFor?: (providerId: string) => string;
|
|
72
81
|
/** Git runner override; tests resolve the identity without a real git. */
|
|
73
82
|
readonly gitRun?: GitRunner;
|
|
@@ -75,6 +84,10 @@ export interface SetupOptions {
|
|
|
75
84
|
readonly noBrowser?: boolean;
|
|
76
85
|
/** `--defer-sign-in`: an MDM run saves the organization and stops; the developer signs in later with `agentwatch setup`. */
|
|
77
86
|
readonly deferSignIn?: boolean;
|
|
87
|
+
/** `--replay-days`, as typed: how far back the background replay of earlier Claude Code sessions reaches. */
|
|
88
|
+
readonly replayDays?: string;
|
|
89
|
+
/** `--no-replay`: do not replay earlier sessions. */
|
|
90
|
+
readonly noReplay?: boolean;
|
|
78
91
|
/** Browser sign-in seams for tests: the gateway, the poll timer and the browser opener. */
|
|
79
92
|
readonly openUrl?: (url: string) => void;
|
|
80
93
|
readonly fetchFn?: typeof fetch;
|
|
@@ -89,7 +102,8 @@ export interface DoctorOptions {
|
|
|
89
102
|
}
|
|
90
103
|
export interface UninstallOptions {
|
|
91
104
|
readonly env: Env;
|
|
92
|
-
|
|
105
|
+
/** The agents `--agent` selected; absent means the whole install, device credential included. */
|
|
106
|
+
readonly agents?: readonly AgentProvider[];
|
|
93
107
|
/** Also delete local config, queue and state. Off by default. */
|
|
94
108
|
readonly purge?: boolean;
|
|
95
109
|
}
|
package/dist/cli/uninstall.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
-
import {
|
|
2
|
+
import { providers } from '../providers/registry.js';
|
|
3
3
|
import { saveInstallState } from '../storage/install-state.js';
|
|
4
4
|
import { uninstalledFile } from '../storage/uninstalled.js';
|
|
5
5
|
import { forgetDeviceCredentials } from '../credentials/credentials.js';
|
|
@@ -20,14 +20,14 @@ export async function runUninstall(options) {
|
|
|
20
20
|
const context = await buildCliContext(options.env);
|
|
21
21
|
println(bold('AgentWatch Uninstall'));
|
|
22
22
|
println();
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
println(`${symbols.fail}
|
|
23
|
+
const wholeInstall = options.agents === undefined;
|
|
24
|
+
if (options.purge && !wholeInstall) {
|
|
25
|
+
println(`${symbols.fail} --purge removes every agent and the local data; run it without --agent. Nothing was removed`);
|
|
26
26
|
return 1;
|
|
27
27
|
}
|
|
28
28
|
let installState = context.installState;
|
|
29
29
|
let failures = 0;
|
|
30
|
-
for (const provider of
|
|
30
|
+
for (const provider of options.agents ?? providers) {
|
|
31
31
|
println(bold(provider.displayName));
|
|
32
32
|
const setupContext = {
|
|
33
33
|
env: options.env,
|
|
@@ -54,7 +54,7 @@ export async function runUninstall(options) {
|
|
|
54
54
|
// than finding a credential nobody chose to keep. The network never fails
|
|
55
55
|
// uninstall; a credential left live is said, with who can switch it off. A
|
|
56
56
|
// config that could not be updated is a failure: nothing was revoked.
|
|
57
|
-
if (
|
|
57
|
+
if (wholeInstall) {
|
|
58
58
|
const forgotten = await forgetDeviceCredentials({ env: options.env, paths: context.paths, timeoutMs: SETUP_EXCHANGE_TIMEOUT_MS });
|
|
59
59
|
if (!forgotten.marked)
|
|
60
60
|
println(`${symbols.warn} could not record the uninstall in ${uninstalledFile(context.paths)}; a later run may enroll this machine again`);
|
|
@@ -66,30 +66,16 @@ export async function runUninstall(options) {
|
|
|
66
66
|
println(revocationLine(revocation));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
if (options.purge
|
|
69
|
+
if (options.purge) {
|
|
70
70
|
await fs.rm(context.paths.dataDir, { recursive: true, force: true });
|
|
71
71
|
await fs.rm(context.paths.configDir, { recursive: true, force: true });
|
|
72
72
|
println(`${symbols.ok} local configuration and queued data removed`);
|
|
73
73
|
}
|
|
74
|
-
if (!options.purge
|
|
74
|
+
if (!options.purge) {
|
|
75
75
|
println(`local config kept at ${context.paths.configFile} (use --purge to remove)`);
|
|
76
76
|
}
|
|
77
77
|
return failures === 0 ? 0 : 1;
|
|
78
78
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Which providers this run touches.
|
|
81
|
-
*
|
|
82
|
-
* @param agent - Value of `--agent`, when given.
|
|
83
|
-
* @returns The providers, or undefined when the named agent is unknown.
|
|
84
|
-
*/
|
|
85
|
-
function resolveTargets(agent) {
|
|
86
|
-
if (!agent)
|
|
87
|
-
return providers;
|
|
88
|
-
// This command already holds the eager list, so it names the one it wants
|
|
89
|
-
// rather than loading a sixth copy of it.
|
|
90
|
-
const provider = providers.find((candidate) => candidate.id === agent);
|
|
91
|
-
return provider ? [provider] : undefined;
|
|
92
|
-
}
|
|
93
79
|
/**
|
|
94
80
|
* Print an outcome and carry its install state forward.
|
|
95
81
|
*
|
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,15 @@ import { setVerbose } from './core/logger.js';
|
|
|
6
6
|
// Parsing lives in its own module so tests can import it without executing
|
|
7
7
|
// main(); command modules stay lazily loaded off the hook critical path.
|
|
8
8
|
import { boolFlag, parseArgs, stringFlag, valuelessFlags } from './cli/args.js';
|
|
9
|
+
import { AGENT_COMMANDS } from './cli/constants/cli.constants.js';
|
|
10
|
+
import { providerIds } from './providers/loaders.js';
|
|
9
11
|
const HELP = `agentwatch — telemetry edge for AI coding agents
|
|
10
12
|
|
|
11
13
|
Usage:
|
|
12
|
-
agentwatch setup [enrollment-url] [--endpoint <url>] [--allow-custom-endpoint] [--no-browser] [--enrollment-code -] [--token <token>] [--developer-email <email>] [--developer-name <name>] [--root <path>] [--otel <signals>]
|
|
14
|
+
agentwatch setup [enrollment-url] [--endpoint <url>] [--allow-custom-endpoint] [--no-browser] [--enrollment-code -] [--token <token>] [--developer-email <email>] [--developer-name <name>] [--root <path>] [--otel <signals>] [--replay-days <n>] [--no-replay] [--agent <id>]
|
|
15
|
+
agentwatch setup --cloud (a Claude Code cloud session's managed SessionStart hook)
|
|
13
16
|
agentwatch status
|
|
17
|
+
agentwatch replay [--machine | --root <path>] [--replay-days <n>] [--resume | --stop] [--dry-run]
|
|
14
18
|
agentwatch off
|
|
15
19
|
agentwatch on
|
|
16
20
|
agentwatch doctor [--json]
|
|
@@ -40,10 +44,11 @@ Flags:
|
|
|
40
44
|
--developer-name <name> what to call this developer in the platform's views (default:
|
|
41
45
|
git config user.name). Never an identity: nothing is keyed on it,
|
|
42
46
|
and leaving it unset keeps whatever name the platform already has
|
|
43
|
-
--root <path>
|
|
44
|
-
|
|
47
|
+
--root <path> with setup or replay, use the identity under this project root;
|
|
48
|
+
setup can file a second tenant instead of the machine default: work
|
|
45
49
|
at or below <path> uses this token, everything else keeps the
|
|
46
50
|
machine's own. Longest matching root wins
|
|
51
|
+
--machine with replay, use the machine identity regardless of this directory
|
|
47
52
|
--otel <signals> native OTLP signals agents export to the backend: comma list of
|
|
48
53
|
logs,traces,metrics, or "all"/"none" (default: logs — the
|
|
49
54
|
per-request usage/cost ledger the backend turns into llm.call)
|
|
@@ -52,7 +57,17 @@ Flags:
|
|
|
52
57
|
developer runs \`agentwatch setup\` and signs in as themselves.
|
|
53
58
|
A machine with no device and an enrollment code redeems the
|
|
54
59
|
code now instead
|
|
55
|
-
--
|
|
60
|
+
--cloud setup, in a Claude Code cloud session ($CLAUDE_CODE_REMOTE=true) with no
|
|
61
|
+
credential: claim a device with the organization's managed settings
|
|
62
|
+
($AGENTWATCH_CLOUD_ORGANIZATION, $AGENTWATCH_CLOUD_KEY) for the Claude
|
|
63
|
+
account's email. Does nothing anywhere else; always exits 0
|
|
64
|
+
--replay-days <n> setup, replay: how many days of earlier Claude Code sessions to send in the
|
|
65
|
+
background (default 30, never before the open charge period). Metadata only:
|
|
66
|
+
what the hooks send for a turn. See docs/DATA_HANDLING.md
|
|
67
|
+
--no-replay setup: do not replay earlier Claude Code sessions
|
|
68
|
+
--resume, --stop replay: carry on an unfinished replay, or end it
|
|
69
|
+
--agent <id> ${[...AGENT_COMMANDS].join(', ')}: limit the command to one agent
|
|
70
|
+
(${providerIds.join(' | ')})
|
|
56
71
|
--purge uninstall: also delete ~/.agentwatch and queued local data
|
|
57
72
|
--dry-run hook: print resulting events to stdout instead of sending
|
|
58
73
|
--json doctor: machine-readable output
|
|
@@ -89,6 +104,26 @@ async function main() {
|
|
|
89
104
|
process.stdout.write(HELP);
|
|
90
105
|
return 0;
|
|
91
106
|
}
|
|
107
|
+
// No command, or `help`, prints the help; a hook's argv is the agent's.
|
|
108
|
+
const checksFlags = parsed.command !== undefined && parsed.command !== 'help' && parsed.command !== 'hook' && parsed.command !== 'refresh-credential';
|
|
109
|
+
// A cloud session's SessionStart hook: every path exits 0, so Agent Watch never fails the session.
|
|
110
|
+
const cloud = parsed.command === 'setup' && boolFlag(parsed, 'cloud');
|
|
111
|
+
const valueless = valuelessFlags(parsed);
|
|
112
|
+
// Status always exits 0, so scripts can rely on it: a flag it does not take is named and ignored.
|
|
113
|
+
const lenient = parsed.command === 'status';
|
|
114
|
+
const ignored = lenient ? '; ignored' : '';
|
|
115
|
+
// `--endpoint --token KEY` would read the endpoint as absent, and a bare `--agent` as every agent.
|
|
116
|
+
if (checksFlags && valueless.length > 0) {
|
|
117
|
+
process.stderr.write(`agentwatch ${parsed.command}: ${valueless.map((name) => `--${name}`).join(', ')} needs a value${ignored}\n`);
|
|
118
|
+
if (!lenient)
|
|
119
|
+
return cloud ? 0 : 1;
|
|
120
|
+
}
|
|
121
|
+
// `off --agent cursor` used to switch every agent off: a flag a command does not take is refused, never ignored.
|
|
122
|
+
if (checksFlags && parsed.flags['agent'] !== undefined && !AGENT_COMMANDS.has(parsed.command ?? '')) {
|
|
123
|
+
process.stderr.write(`agentwatch ${parsed.command}: --agent is not supported here; only ${[...AGENT_COMMANDS].join(', ')} take it${ignored}\n`);
|
|
124
|
+
if (!lenient)
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
92
127
|
const env = realEnv();
|
|
93
128
|
switch (parsed.command) {
|
|
94
129
|
case 'off':
|
|
@@ -97,21 +132,31 @@ async function main() {
|
|
|
97
132
|
return runToggle(env, parsed.command === 'on');
|
|
98
133
|
}
|
|
99
134
|
case 'hook': {
|
|
100
|
-
const { runHook } = await import('./cli/hook.js');
|
|
101
|
-
|
|
135
|
+
const { handOffDetached, runHook } = await import('./cli/hook.js');
|
|
136
|
+
// `--attached` is the detached child a turn close was handed to; it processes in place.
|
|
137
|
+
const handOff = boolFlag(parsed, 'attached') || boolFlag(parsed, 'dry-run') ? undefined : handOffDetached;
|
|
138
|
+
return runHook(stringFlag(parsed, 'agent') ?? '', { env, dryRun: boolFlag(parsed, 'dry-run'), handOff });
|
|
102
139
|
}
|
|
103
140
|
case 'setup': {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return 1;
|
|
108
|
-
}
|
|
141
|
+
// Before the npx hand-off, so an unknown id installs nothing globally either.
|
|
142
|
+
const selected = await selectedAgents(parsed);
|
|
143
|
+
if (!selected)
|
|
144
|
+
return cloud ? 0 : 1;
|
|
109
145
|
const { installGloballyAndHandOff, isNpxRun } = await import('./cli/npx-install.js');
|
|
110
|
-
if (isNpxRun(process.argv[1], process.env))
|
|
111
|
-
|
|
146
|
+
if (isNpxRun(process.argv[1], process.env)) {
|
|
147
|
+
// The managed hook runs `npx … setup --cloud` on every start and resume: a VM that already has its device skips the global install.
|
|
148
|
+
if (cloud) {
|
|
149
|
+
const [{ loadConfig }, { resolvePaths }, { hasCredential }] = await Promise.all([import('./config/config-store.js'), import('./storage/paths.js'), import('./credentials/identity.js')]);
|
|
150
|
+
if (hasCredential((await loadConfig(resolvePaths(env))).config))
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
const handedOff = await installGloballyAndHandOff(process.argv.slice(2));
|
|
154
|
+
return cloud ? 0 : handedOff;
|
|
155
|
+
}
|
|
112
156
|
const { runSetup } = await import('./cli/setup.js');
|
|
113
157
|
return runSetup({
|
|
114
158
|
env,
|
|
159
|
+
cloud,
|
|
115
160
|
setupUrl: parsed.positional[0],
|
|
116
161
|
endpoint: stringFlag(parsed, 'endpoint'),
|
|
117
162
|
allowCustomEndpoint: boolFlag(parsed, 'allow-custom-endpoint'),
|
|
@@ -122,20 +167,44 @@ async function main() {
|
|
|
122
167
|
developerName: stringFlag(parsed, 'developer-name'),
|
|
123
168
|
root: stringFlag(parsed, 'root'),
|
|
124
169
|
otel: stringFlag(parsed, 'otel'),
|
|
125
|
-
|
|
170
|
+
agents: selected.agents,
|
|
171
|
+
deferSignIn: boolFlag(parsed, 'defer-sign-in'),
|
|
172
|
+
replayDays: stringFlag(parsed, 'replay-days'),
|
|
173
|
+
noReplay: boolFlag(parsed, 'no-replay')
|
|
126
174
|
});
|
|
127
175
|
}
|
|
128
176
|
case 'status': {
|
|
129
177
|
const { runStatus } = await import('./cli/status.js');
|
|
130
178
|
return runStatus(env);
|
|
131
179
|
}
|
|
180
|
+
case 'replay': {
|
|
181
|
+
const { runWithSmallHeap } = await import('./replay/start.js');
|
|
182
|
+
const rerun = runWithSmallHeap(process.argv.slice(2));
|
|
183
|
+
if (rerun !== undefined)
|
|
184
|
+
return rerun;
|
|
185
|
+
const { runReplayCommand } = await import('./cli/replay.js');
|
|
186
|
+
return runReplayCommand({
|
|
187
|
+
env,
|
|
188
|
+
machine: boolFlag(parsed, 'machine'),
|
|
189
|
+
root: stringFlag(parsed, 'root'),
|
|
190
|
+
days: stringFlag(parsed, 'replay-days'),
|
|
191
|
+
resume: boolFlag(parsed, 'resume'),
|
|
192
|
+
stop: boolFlag(parsed, 'stop'),
|
|
193
|
+
dryRun: boolFlag(parsed, 'dry-run'),
|
|
194
|
+
claimAutomatic: boolFlag(parsed, 'claim-automatic'),
|
|
195
|
+
skipIfExisting: boolFlag(parsed, 'skip-if-existing')
|
|
196
|
+
});
|
|
197
|
+
}
|
|
132
198
|
case 'doctor': {
|
|
133
199
|
const { runDoctor } = await import('./cli/doctor.js');
|
|
134
200
|
return runDoctor(env, { json: boolFlag(parsed, 'json') });
|
|
135
201
|
}
|
|
136
202
|
case 'uninstall': {
|
|
203
|
+
const selected = await selectedAgents(parsed);
|
|
204
|
+
if (!selected)
|
|
205
|
+
return 1;
|
|
137
206
|
const { runUninstall } = await import('./cli/uninstall.js');
|
|
138
|
-
return runUninstall({ env,
|
|
207
|
+
return runUninstall({ env, agents: selected.agents, purge: boolFlag(parsed, 'purge') });
|
|
139
208
|
}
|
|
140
209
|
case 'update': {
|
|
141
210
|
const { runUpdate } = await import('./cli/update.js');
|
|
@@ -162,6 +231,24 @@ async function main() {
|
|
|
162
231
|
return runFallback(parsed);
|
|
163
232
|
}
|
|
164
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* The agents `--agent` selects for setup or uninstall, refused on stderr when it names none.
|
|
236
|
+
*
|
|
237
|
+
* @param parsed - Parsed arguments; a bare `--agent` was already refused as valueless.
|
|
238
|
+
* @returns The selected providers (none without the flag), or undefined once the refusal is printed.
|
|
239
|
+
*/
|
|
240
|
+
async function selectedAgents(parsed) {
|
|
241
|
+
const agent = stringFlag(parsed, 'agent');
|
|
242
|
+
if (agent === undefined)
|
|
243
|
+
return {};
|
|
244
|
+
const { selectProviders } = await import('./providers/registry.js');
|
|
245
|
+
const selected = selectProviders(agent);
|
|
246
|
+
if ('error' in selected) {
|
|
247
|
+
process.stderr.write(`agentwatch ${parsed.command}: ${selected.error}\n`);
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
return { agents: selected.providers };
|
|
251
|
+
}
|
|
165
252
|
/**
|
|
166
253
|
* Handle `--version`, `help`, and an unrecognized command.
|
|
167
254
|
*
|
|
@@ -217,6 +304,6 @@ async function exitAfterFlush(code) {
|
|
|
217
304
|
}
|
|
218
305
|
main().then((code) => exitAfterFlush(code), (error) => {
|
|
219
306
|
process.stderr.write(`[agentwatch] fatal: ${error.stack ?? error}\n`);
|
|
220
|
-
// A crashing hook must not break the calling agent.
|
|
221
|
-
return exitAfterFlush(process.argv[2] === 'hook' ? 0 : 1);
|
|
307
|
+
// A crashing hook, or a cloud session's setup, must not break the calling agent.
|
|
308
|
+
return exitAfterFlush(process.argv[2] === 'hook' || (process.argv[2] === 'setup' && process.argv.includes('--cloud')) ? 0 : 1);
|
|
222
309
|
});
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { AgentWatchConfig, OtelConfig, OtelSignalName } from './types/config.types.js';
|
|
2
|
-
export { captureSchema, configSchema, deliverySchema, emitSchema, enforcementSchema, otelSchema } from './schemas/config.schema.js';
|
|
3
|
-
export type { AgentWatchConfig, CaptureConfig, EnforcementConfig, OtelConfig, OtelSignalName } from './types/config.types.js';
|
|
4
2
|
/**
|
|
5
3
|
* The configuration a deliberate `agentwatch setup` writes: metadata only.
|
|
6
4
|
*
|
package/dist/config/config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ENFORCEMENT_PATH, EVENTS_PATH, OTEL_ALL, OTEL_NONE, OTEL_SIGNAL_NAMES, OTEL_SIGNAL_NAME_SET, OTLP_BASE_PATH, RE_TRAILING_SLASHES } from './constants/config.constants.js';
|
|
2
2
|
import { configSchema } from './schemas/config.schema.js';
|
|
3
|
-
export { captureSchema, configSchema, deliverySchema, emitSchema, enforcementSchema, otelSchema } from './schemas/config.schema.js';
|
|
4
3
|
/**
|
|
5
4
|
* The configuration a deliberate `agentwatch setup` writes: metadata only.
|
|
6
5
|
*
|
|
@@ -123,6 +123,8 @@ export const GLOBAL_ONLY_KEYS = new Set([
|
|
|
123
123
|
'developerName',
|
|
124
124
|
'untracedNotices',
|
|
125
125
|
'updateNotices',
|
|
126
|
+
// Silences usage telemetry and budget caps: a developer's own choice, never a repository's.
|
|
127
|
+
'ignoredRoots',
|
|
126
128
|
'endpoint',
|
|
127
129
|
'eventsUrl',
|
|
128
130
|
'otlpUrl',
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EventTransport } from '../transport/types/transport.types.js';
|
|
2
|
+
import type { AgentWatchConfig, TransportLimits } from './types/config.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The transport for one config, when a backend is configured.
|
|
5
|
+
*
|
|
6
|
+
* Here, not in `src/transport`, because choosing the destination and reading
|
|
7
|
+
* the credential state are config decisions; transport sends to whatever URL
|
|
8
|
+
* it is given.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The config whose destination, capture and installation id are sent.
|
|
11
|
+
* @param bearer - What to authenticate with; see `resolveBearer`.
|
|
12
|
+
* @param limits - Request and whole-send ceilings.
|
|
13
|
+
* @returns The transport, or undefined before setup has run.
|
|
14
|
+
*/
|
|
15
|
+
export declare function transportFor(config: AgentWatchConfig, bearer: string | undefined, limits?: TransportLimits): EventTransport | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { hasCredential } from '../credentials/identity.js';
|
|
2
|
+
import { HttpTransport } from '../transport/http-transport.js';
|
|
3
|
+
import { eventsUrl } from './config.js';
|
|
4
|
+
/**
|
|
5
|
+
* The transport for one config, when a backend is configured.
|
|
6
|
+
*
|
|
7
|
+
* Here, not in `src/transport`, because choosing the destination and reading
|
|
8
|
+
* the credential state are config decisions; transport sends to whatever URL
|
|
9
|
+
* it is given.
|
|
10
|
+
*
|
|
11
|
+
* @param config - The config whose destination, capture and installation id are sent.
|
|
12
|
+
* @param bearer - What to authenticate with; see `resolveBearer`.
|
|
13
|
+
* @param limits - Request and whole-send ceilings.
|
|
14
|
+
* @returns The transport, or undefined before setup has run.
|
|
15
|
+
*/
|
|
16
|
+
export function transportFor(config, bearer, limits = {}) {
|
|
17
|
+
const url = eventsUrl(config);
|
|
18
|
+
if (!url)
|
|
19
|
+
return undefined;
|
|
20
|
+
return new HttpTransport({
|
|
21
|
+
eventsUrl: url,
|
|
22
|
+
capture: config.capture,
|
|
23
|
+
token: bearer,
|
|
24
|
+
credentialPending: hasCredential(config) && !bearer,
|
|
25
|
+
installationId: config.installationId,
|
|
26
|
+
timeoutMs: limits.timeoutMs ?? config.delivery.timeoutMs,
|
|
27
|
+
budgetMs: limits.budgetMs
|
|
28
|
+
});
|
|
29
|
+
}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* What the edge is configured to do: the global file, the repository overlay
|
|
3
3
|
* on top of it, and the routes derived from the endpoint.
|
|
4
4
|
*/
|
|
5
|
-
export type { AgentWatchConfig, CaptureConfig, ConfigLoadResult, EffectiveConfig, MergedConfig, OtelConfig, OtelSignalName, RootedConfig, RootOverride } from './types/config.types.js';
|
|
5
|
+
export type { AgentWatchConfig, CaptureConfig, ConfigLoadResult, EffectiveConfig, MergedConfig, OtelConfig, OtelSignalName, RootedConfig, RootOverride, TransportLimits } from './types/config.types.js';
|
|
6
6
|
export { CONTENT_CAPTURE_KEYS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME, ROOTS_KEY } from './constants/config.constants.js';
|
|
7
7
|
export { captureSchema, configSchema, deliverySchema, emitSchema, otelSchema } from './schemas/config.schema.js';
|
|
8
8
|
export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals, sharesOtlpCollector } from './config.js';
|
|
@@ -10,4 +10,5 @@ export { attachDevice, ensureInstallationId, loadConfig, saveConfig, updateConfi
|
|
|
10
10
|
export { findRepoConfigFile, loadEffectiveConfig, mergeRepoConfig } from './repo-config.js';
|
|
11
11
|
export { applyRootOverride, canonicalRoot, selectRoot, servesMultipleIdentities } from './root-config.js';
|
|
12
12
|
export { normalizeEndpoint, sameEndpoint, transitionDestination } from './destination.js';
|
|
13
|
+
export { transportFor } from './events-transport.js';
|
|
13
14
|
export type { Destination, DestinationTransition } from './types/destination.types.js';
|
package/dist/config/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { attachDevice, ensureInstallationId, loadConfig, saveConfig, updateConfi
|
|
|
5
5
|
export { findRepoConfigFile, loadEffectiveConfig, mergeRepoConfig } from './repo-config.js';
|
|
6
6
|
export { applyRootOverride, canonicalRoot, selectRoot, servesMultipleIdentities } from './root-config.js';
|
|
7
7
|
export { normalizeEndpoint, sameEndpoint, transitionDestination } from './destination.js';
|
|
8
|
+
export { transportFor } from './events-transport.js';
|
|
@@ -14,6 +14,18 @@ import type { AgentWatchConfig, RootedConfig, RootOverride } from './types/confi
|
|
|
14
14
|
* @returns The winning root path and its overrides, or undefined.
|
|
15
15
|
*/
|
|
16
16
|
export declare function selectRoot(roots: Readonly<Record<string, RootOverride>> | undefined, cwd: string): RootedConfig['root'];
|
|
17
|
+
/**
|
|
18
|
+
* Whether a working directory is one the developer told this machine to ignore.
|
|
19
|
+
*
|
|
20
|
+
* An entry names one directory exactly; `<dir>/**` names it and everything
|
|
21
|
+
* beneath it. Exact is the default because the directory people most want
|
|
22
|
+
* ignored is usually home, and a subtree match there would ignore every repo.
|
|
23
|
+
*
|
|
24
|
+
* @param ignored - `ignoredRoots` from the global config.
|
|
25
|
+
* @param cwd - Where the payload happened.
|
|
26
|
+
* @returns True when nothing from this directory may be captured.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isIgnoredRoot(ignored: readonly string[], cwd: string): boolean;
|
|
17
29
|
/**
|
|
18
30
|
* Whether this machine sends as more than one identity.
|
|
19
31
|
*
|
|
@@ -40,6 +40,30 @@ export function selectRoot(roots, cwd) {
|
|
|
40
40
|
// Named as configured, so `agentwatch config` shows the root the user wrote.
|
|
41
41
|
return { path: path.resolve(bestKey), override: roots[bestKey] };
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether a working directory is one the developer told this machine to ignore.
|
|
45
|
+
*
|
|
46
|
+
* An entry names one directory exactly; `<dir>/**` names it and everything
|
|
47
|
+
* beneath it. Exact is the default because the directory people most want
|
|
48
|
+
* ignored is usually home, and a subtree match there would ignore every repo.
|
|
49
|
+
*
|
|
50
|
+
* @param ignored - `ignoredRoots` from the global config.
|
|
51
|
+
* @param cwd - Where the payload happened.
|
|
52
|
+
* @returns True when nothing from this directory may be captured.
|
|
53
|
+
*/
|
|
54
|
+
export function isIgnoredRoot(ignored, cwd) {
|
|
55
|
+
const target = canonicalRoot(cwd);
|
|
56
|
+
return ignored.some((entry) => {
|
|
57
|
+
// `/**` on Windows too: people write config paths with forward slashes.
|
|
58
|
+
const subtree = entry.endsWith('/**') || entry.endsWith(`${path.sep}**`);
|
|
59
|
+
const dir = subtree ? entry.slice(0, -3) : entry;
|
|
60
|
+
// Relative for the same reason as `selectRoot`: nobody can predict it.
|
|
61
|
+
if (!path.isAbsolute(dir))
|
|
62
|
+
return false;
|
|
63
|
+
const root = canonicalRoot(dir);
|
|
64
|
+
return subtree ? contains(root, target) : root === target;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
43
67
|
/**
|
|
44
68
|
* Whether this machine sends as more than one identity.
|
|
45
69
|
*
|
|
@@ -80,6 +80,16 @@ export declare const emitSchema: z.ZodObject<{
|
|
|
80
80
|
* @returns True when the edge may send there.
|
|
81
81
|
*/
|
|
82
82
|
export declare function isAllowedHost(value: string, trusted: ReadonlySet<string>): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Whether a URL is one AgentWatch itself sends to: an Agent Watch host or an
|
|
85
|
+
* origin this machine trusts. Unlike `isAllowedHost`, loopback alone does not
|
|
86
|
+
* count, because a collector on localhost is as likely the developer's own.
|
|
87
|
+
*
|
|
88
|
+
* @param value - The URL as written.
|
|
89
|
+
* @param trusted - Origins this machine trusts (`customEndpoints`).
|
|
90
|
+
* @returns True when the URL points at Agent Watch.
|
|
91
|
+
*/
|
|
92
|
+
export declare function isAgentWatchEndpoint(value: string, trusted: ReadonlySet<string>): boolean;
|
|
83
93
|
/**
|
|
84
94
|
* The origin of a URL the edge could deliver to, for recording trust in it.
|
|
85
95
|
*
|
|
@@ -215,6 +225,7 @@ export declare const configSchema: z.ZodPipe<z.ZodObject<{
|
|
|
215
225
|
developerEmail: z.ZodOptional<z.ZodString>;
|
|
216
226
|
developerName: z.ZodOptional<z.ZodString>;
|
|
217
227
|
}, z.core.$strip>>>;
|
|
228
|
+
ignoredRoots: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
218
229
|
contentCaptureConsent: z.ZodDefault<z.ZodBoolean>;
|
|
219
230
|
customEndpoints: z.ZodDefault<z.ZodCatch<z.ZodArray<z.ZodString>>>;
|
|
220
231
|
allowlistVersion: z.ZodOptional<z.ZodNumber>;
|
|
@@ -261,6 +272,7 @@ export declare const configSchema: z.ZodPipe<z.ZodObject<{
|
|
|
261
272
|
mcpNames: boolean;
|
|
262
273
|
};
|
|
263
274
|
schemaVersion: 1;
|
|
275
|
+
ignoredRoots: string[];
|
|
264
276
|
contentCaptureConsent: boolean;
|
|
265
277
|
customEndpoints: string[];
|
|
266
278
|
untracedNotices: boolean;
|
|
@@ -322,6 +334,7 @@ export declare const configSchema: z.ZodPipe<z.ZodObject<{
|
|
|
322
334
|
}, {
|
|
323
335
|
[x: string]: unknown;
|
|
324
336
|
schemaVersion: 1;
|
|
337
|
+
ignoredRoots: string[];
|
|
325
338
|
contentCaptureConsent: boolean;
|
|
326
339
|
customEndpoints: string[];
|
|
327
340
|
untracedNotices: boolean;
|