@agent-watch-ai/edge 0.3.1 → 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 +46 -0
- package/README.md +7 -3
- package/SECURITY.md +7 -4
- package/dist/cli/constants/cli.constants.d.ts +2 -0
- package/dist/cli/constants/cli.constants.js +3 -1
- package/dist/cli/doctor.js +13 -2
- package/dist/cli/setup.js +138 -29
- package/dist/cli/toggle.js +5 -1
- package/dist/cli/types/cli.types.d.ts +6 -0
- package/dist/cli/uninstall.js +1 -1
- package/dist/cli.js +14 -3
- package/dist/config/config-store.d.ts +1 -1
- package/dist/config/config-store.js +1 -1
- package/dist/config/constants/config.constants.d.ts +4 -1
- package/dist/config/constants/config.constants.js +7 -2
- package/dist/config/schemas/config.schema.d.ts +110 -0
- package/dist/config/schemas/config.schema.js +12 -3
- package/dist/credentials/constants/credentials.constants.d.ts +8 -0
- package/dist/credentials/constants/credentials.constants.js +9 -1
- package/dist/credentials/credential-status.js +8 -4
- package/dist/credentials/credentials.d.ts +16 -2
- package/dist/credentials/credentials.js +28 -3
- package/dist/credentials/device-api.d.ts +10 -1
- package/dist/credentials/device-api.js +12 -1
- package/dist/credentials/identity.d.ts +12 -1
- package/dist/credentials/identity.js +12 -1
- package/dist/credentials/migration.d.ts +1 -1
- package/dist/credentials/migration.js +1 -1
- package/dist/credentials/sign-in.d.ts +14 -1
- package/dist/credentials/sign-in.js +24 -5
- package/dist/credentials/types/credentials.types.d.ts +12 -1
- package/dist/enforcement/decision-client.js +2 -1
- package/dist/enforcement/enforcement.js +7 -5
- package/dist/enforcement/types/enforcement.types.d.ts +2 -2
- 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 +56 -7
- package/dist/privacy/product-capture.js +2 -0
- package/dist/providers/codex/codex.otel.d.ts +12 -1
- package/dist/providers/codex/codex.otel.js +61 -11
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +5 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +5 -0
- package/dist/providers/constants/provider.constants.d.ts +8 -0
- package/dist/providers/constants/provider.constants.js +8 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +2 -0
- package/dist/providers/cursor/constants/cursor.constants.js +2 -0
- package/dist/providers/cursor/cursor.adapter.js +79 -3
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +6 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.js +6 -0
- package/dist/providers/gemini/gemini.otel.d.ts +11 -1
- package/dist/providers/gemini/gemini.otel.js +52 -12
- package/dist/providers/shared/bearer-rewrite.d.ts +19 -0
- package/dist/providers/shared/bearer-rewrite.js +46 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +6 -0
- package/dist/providers/shared/constants/tooling.constants.js +6 -0
- package/dist/providers/shared/tooling.d.ts +28 -0
- package/dist/providers/shared/tooling.js +52 -1
- package/dist/providers/types/provider.types.d.ts +24 -0
- package/dist/storage/atomic-file.d.ts +14 -0
- package/dist/storage/atomic-file.js +19 -0
- package/dist/storage/constants/storage.constants.d.ts +2 -0
- package/dist/storage/constants/storage.constants.js +2 -0
- package/dist/turns/work-checkout.d.ts +5 -3
- package/dist/turns/work-checkout.js +46 -12
- package/docs/DATA_HANDLING.md +11 -4
- package/docs/ENTERPRISE_DEPLOYMENT.md +19 -4
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { asRecord, firstString } from '../../core/object.js';
|
|
3
|
+
import { sanitizeText } from '../../privacy/sanitizer.js';
|
|
3
4
|
import { sha256Hex } from '../../events/event-id.js';
|
|
4
|
-
import { COMMAND_KEYS, FILE_EDIT_TOOLS, FILE_PATH_KEYS, FILE_READ_TOOLS, MCP_TOOL_PREFIX, MCP_TOOL_SEPARATOR, SHELL_TOOLS } from './constants/tooling.constants.js';
|
|
5
|
+
import { COMMAND_KEYS, FILE_EDIT_TOOLS, FILE_PATH_KEYS, FILE_READ_TOOLS, COMMAND_HEAD, MAX_TOOL_KEY_LENGTH, MCP_FOLDED_KEY, MCP_TOOL_PREFIX, MCP_TOOL_SEPARATOR, SHELL_TOOLS } from './constants/tooling.constants.js';
|
|
5
6
|
/**
|
|
6
7
|
* What kind of thing a tool call is, whatever the agent calls it.
|
|
7
8
|
*
|
|
@@ -66,6 +67,56 @@ export function parseMcpToolName(toolName) {
|
|
|
66
67
|
const parts = toolName.split(MCP_TOOL_SEPARATOR);
|
|
67
68
|
return { server: parts[1], tool: parts.slice(2).join(MCP_TOOL_SEPARATOR) || undefined };
|
|
68
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* The `tools_used` key of an MCP call: `mcp__<server>__<tool>`, no arguments.
|
|
72
|
+
*
|
|
73
|
+
* One builder for every provider so the backend can split the key back apart.
|
|
74
|
+
* Scrubbed and cut at the bridge's bound, because a server can come from a
|
|
75
|
+
* URL host or a command and must never carry a credential into a key.
|
|
76
|
+
*
|
|
77
|
+
* @param server - Server's logical name, host or command base name.
|
|
78
|
+
* @param tool - Tool name on that server.
|
|
79
|
+
* @returns The key.
|
|
80
|
+
*/
|
|
81
|
+
export function mcpToolKey(server, tool) {
|
|
82
|
+
return sanitizeText(`${MCP_TOOL_PREFIX}${server}${MCP_TOOL_SEPARATOR}${tool}`).slice(0, MAX_TOOL_KEY_LENGTH);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Fold every `mcp__*` key of a `tools_used` map into `mcp`, keeping the count.
|
|
86
|
+
*
|
|
87
|
+
* @param toolsUsed - Per-tool call counts.
|
|
88
|
+
* @returns The counts with MCP server and tool names withheld.
|
|
89
|
+
*/
|
|
90
|
+
export function foldMcpNames(toolsUsed) {
|
|
91
|
+
const folded = {};
|
|
92
|
+
for (const [name, count] of Object.entries(toolsUsed)) {
|
|
93
|
+
const key = name.startsWith(MCP_TOOL_PREFIX) ? MCP_FOLDED_KEY : name;
|
|
94
|
+
folded[key] = (folded[key] ?? 0) + count;
|
|
95
|
+
}
|
|
96
|
+
return folded;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Server name of a Cursor MCP hook that carries no `mcp__` name: the host of a
|
|
100
|
+
* remote endpoint, else the base name of a stdio command (first word, quote-aware).
|
|
101
|
+
*
|
|
102
|
+
* @param url - The remote endpoint, if any.
|
|
103
|
+
* @param command - The stdio command line, if any.
|
|
104
|
+
* @returns The server, or undefined when neither yields one.
|
|
105
|
+
*/
|
|
106
|
+
export function mcpServerFromEndpoint(url, command) {
|
|
107
|
+
if (url) {
|
|
108
|
+
try {
|
|
109
|
+
return new URL(url).host || undefined;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const executable = command ? COMMAND_HEAD.exec(command) : null;
|
|
116
|
+
const head = executable?.[1] ?? executable?.[2] ?? executable?.[3];
|
|
117
|
+
// ponytail: an unquoted path with spaces is ambiguous and splits at the first space; npx/uvx/docker name the launcher, not the server.
|
|
118
|
+
return head ? head.split(/[\\/]/).pop() || undefined : undefined;
|
|
119
|
+
}
|
|
69
120
|
/**
|
|
70
121
|
* Length and hash of text, as evidence for content we may not transmit.
|
|
71
122
|
*
|
|
@@ -20,6 +20,23 @@ export interface SetupContext {
|
|
|
20
20
|
readonly hookCommand: string;
|
|
21
21
|
/** What setup has recorded so far; an operation returns the next version. */
|
|
22
22
|
readonly installState: InstallState;
|
|
23
|
+
/**
|
|
24
|
+
* The bearer an agent's own config may hold (Codex, Gemini): the machine's
|
|
25
|
+
* device access token, which the hook path rewrites as it rotates. Never the
|
|
26
|
+
* install key or the device secret (SPEC R8). Absent writes no header.
|
|
27
|
+
*/
|
|
28
|
+
readonly bearer?: string;
|
|
29
|
+
}
|
|
30
|
+
/** What a hook needs to swap the bearer in an agent's config for a newer one. */
|
|
31
|
+
export interface BearerRewriteContext {
|
|
32
|
+
/** The file setup recorded, which a hook's environment may not point at. */
|
|
33
|
+
readonly configPath: string;
|
|
34
|
+
/** Which entries are AgentWatch's to touch. */
|
|
35
|
+
readonly installState: InstallState;
|
|
36
|
+
/** The machine's current access token. */
|
|
37
|
+
readonly bearer: string;
|
|
38
|
+
/** The agent's config file as the caller just read it. */
|
|
39
|
+
readonly raw: string;
|
|
23
40
|
}
|
|
24
41
|
export interface SetupOutcome {
|
|
25
42
|
readonly ok: boolean;
|
|
@@ -74,6 +91,13 @@ export interface NativeTelemetryConfigurator {
|
|
|
74
91
|
* this and is never reported as held back.
|
|
75
92
|
*/
|
|
76
93
|
withheldSignals?(config: AgentWatchConfig): readonly OtelSignalName[];
|
|
94
|
+
/**
|
|
95
|
+
* Swap the bearer an earlier `configure` wrote for the current one, touching
|
|
96
|
+
* nothing else, atomically at 0600. For agents that read a literal header
|
|
97
|
+
* once at session start (Codex, Gemini): the hook keeps their file on the
|
|
98
|
+
* live access token so the next session starts with one.
|
|
99
|
+
*/
|
|
100
|
+
rewriteBearer?(context: BearerRewriteContext): Promise<boolean>;
|
|
77
101
|
}
|
|
78
102
|
export interface AgentProvider {
|
|
79
103
|
readonly id: string;
|
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
* target's.
|
|
15
15
|
*/
|
|
16
16
|
export declare function writeFileAtomic(filePath: string, contents: string, mode?: number): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Replace another tool's file only if it still holds what we read.
|
|
19
|
+
*
|
|
20
|
+
* For a write the edge makes while that tool may be running and rewriting the
|
|
21
|
+
* file itself (Codex re-serializes its config.toml): a change since our read is
|
|
22
|
+
* the tool's, and it wins. The window left is the re-read to the rename.
|
|
23
|
+
*
|
|
24
|
+
* @param filePath - The file.
|
|
25
|
+
* @param read - Its contents when the change was computed.
|
|
26
|
+
* @param contents - The new contents.
|
|
27
|
+
* @param mode - Permission bits to force.
|
|
28
|
+
* @returns True when the file was written.
|
|
29
|
+
*/
|
|
30
|
+
export declare function writeIfUnchanged(filePath: string, read: string, contents: string, mode: number): Promise<boolean>;
|
|
17
31
|
/**
|
|
18
32
|
* Copy a file into the backups directory before we mutate it.
|
|
19
33
|
*
|
|
@@ -38,6 +38,25 @@ export async function writeFileAtomic(filePath, contents, mode) {
|
|
|
38
38
|
throw error;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Replace another tool's file only if it still holds what we read.
|
|
43
|
+
*
|
|
44
|
+
* For a write the edge makes while that tool may be running and rewriting the
|
|
45
|
+
* file itself (Codex re-serializes its config.toml): a change since our read is
|
|
46
|
+
* the tool's, and it wins. The window left is the re-read to the rename.
|
|
47
|
+
*
|
|
48
|
+
* @param filePath - The file.
|
|
49
|
+
* @param read - Its contents when the change was computed.
|
|
50
|
+
* @param contents - The new contents.
|
|
51
|
+
* @param mode - Permission bits to force.
|
|
52
|
+
* @returns True when the file was written.
|
|
53
|
+
*/
|
|
54
|
+
export async function writeIfUnchanged(filePath, read, contents, mode) {
|
|
55
|
+
if ((await fs.readFile(filePath, 'utf8').catch(() => undefined)) !== read)
|
|
56
|
+
return false;
|
|
57
|
+
await writeFileAtomic(filePath, contents, mode);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
41
60
|
/**
|
|
42
61
|
* Copy a file into the backups directory before we mutate it.
|
|
43
62
|
*
|
|
@@ -13,6 +13,8 @@ export declare const DATA_DIR_VAR = "AGENTWATCH_DATA_DIR";
|
|
|
13
13
|
* wins, so an interactive run is unaffected.
|
|
14
14
|
*/
|
|
15
15
|
export declare const TOKEN_VAR = "AGENTWATCH_TOKEN";
|
|
16
|
+
/** An admin-issued enrollment code for an unattended setup: never argv, where `ps` reads it (SPEC R4). */
|
|
17
|
+
export declare const ENROLLMENT_CODE_VAR = "AGENTWATCH_ENROLLMENT_CODE";
|
|
16
18
|
export declare const CONFIG_FILE_NAME = "config.json";
|
|
17
19
|
export declare const INSTALL_STATE_FILE_NAME = "install-state.json";
|
|
18
20
|
/** Sub-directories of the data root. */
|
|
@@ -14,6 +14,8 @@ export const DATA_DIR_VAR = 'AGENTWATCH_DATA_DIR';
|
|
|
14
14
|
* wins, so an interactive run is unaffected.
|
|
15
15
|
*/
|
|
16
16
|
export const TOKEN_VAR = 'AGENTWATCH_TOKEN';
|
|
17
|
+
/** An admin-issued enrollment code for an unattended setup: never argv, where `ps` reads it (SPEC R4). */
|
|
18
|
+
export const ENROLLMENT_CODE_VAR = 'AGENTWATCH_ENROLLMENT_CODE';
|
|
17
19
|
export const CONFIG_FILE_NAME = 'config.json';
|
|
18
20
|
export const INSTALL_STATE_FILE_NAME = 'install-state.json';
|
|
19
21
|
/** Sub-directories of the data root. */
|
|
@@ -51,9 +51,11 @@ export declare function recordCheckouts(store: TurnStateStore, sessionId: string
|
|
|
51
51
|
* Every admitted checkout the turn named is fingerprinted again, all at once,
|
|
52
52
|
* and compared with its baseline. The turn reports, in this order: the one it
|
|
53
53
|
* changed most (`changed`); else the session's last changed checkout
|
|
54
|
-
* (`carried`); else the one it named most (`referenced`); else the Stop
|
|
55
|
-
* own repository, as before this existed (`cwd`).
|
|
56
|
-
*
|
|
54
|
+
* (`carried`); else the one it named most (`referenced`); else the Stop
|
|
55
|
+
* folder's own repository, as before this existed (`cwd`). Below `changed`, a
|
|
56
|
+
* checkout is reported only while the turn touched no file or one there. Ties
|
|
57
|
+
* go to the checkout named first. Every failure makes a candidate lose, never
|
|
58
|
+
* the summary.
|
|
57
59
|
*
|
|
58
60
|
* @param store - Per-session state store.
|
|
59
61
|
* @param sessionId - Provider session id.
|
|
@@ -87,9 +87,11 @@ export async function recordCheckouts(store, sessionId, event, options) {
|
|
|
87
87
|
* Every admitted checkout the turn named is fingerprinted again, all at once,
|
|
88
88
|
* and compared with its baseline. The turn reports, in this order: the one it
|
|
89
89
|
* changed most (`changed`); else the session's last changed checkout
|
|
90
|
-
* (`carried`); else the one it named most (`referenced`); else the Stop
|
|
91
|
-
* own repository, as before this existed (`cwd`).
|
|
92
|
-
*
|
|
90
|
+
* (`carried`); else the one it named most (`referenced`); else the Stop
|
|
91
|
+
* folder's own repository, as before this existed (`cwd`). Below `changed`, a
|
|
92
|
+
* checkout is reported only while the turn touched no file or one there. Ties
|
|
93
|
+
* go to the checkout named first. Every failure makes a candidate lose, never
|
|
94
|
+
* the summary.
|
|
93
95
|
*
|
|
94
96
|
* @param store - Per-session state store.
|
|
95
97
|
* @param sessionId - Provider session id.
|
|
@@ -137,16 +139,24 @@ export async function resolveWorkCheckout(store, sessionId, records, stopEvent,
|
|
|
137
139
|
return reportCheckout({ root: byChange.root, evidence: 'changed', probed: probes.get(byChange.root), changed: changed.get(byChange.root), withhold: false }, tools, options);
|
|
138
140
|
// Carried only while the folder is still the repository that was
|
|
139
141
|
// remembered: a directory re-cloned from another remote is not that work.
|
|
142
|
+
// Every rung below `changed` also needs the turn's edits, when it made any,
|
|
143
|
+
// to include one there (AWT-618, AWT-620, AWT-621): a session that changed
|
|
144
|
+
// one checkout and then wrote files elsewhere is not working in it, nor in
|
|
145
|
+
// the one its shell sits in. A turn that edited no file reports as before,
|
|
146
|
+
// whatever it read.
|
|
140
147
|
const carriedProbe = carried === undefined ? undefined : probes.get(carried);
|
|
141
|
-
const
|
|
148
|
+
const allows = fileEvidenceAllows(tools);
|
|
149
|
+
const stillSame = carriedProbe?.closing !== undefined
|
|
150
|
+
&& repositoryIdentity(carried, carriedProbe.remote).repository === memo?.repository
|
|
151
|
+
&& allows(carried);
|
|
142
152
|
if (stillSame)
|
|
143
153
|
return reportCheckout({ root: carried, evidence: 'carried', probed: carriedProbe, changed: [], withhold: withheld(carried, carriedProbe.branch) }, tools, options);
|
|
144
|
-
const byVotes = best(reportable, (candidate) => candidate.votes + candidate.read.size);
|
|
154
|
+
const byVotes = best(reportable.filter((candidate) => allows(candidate.root)), (candidate) => candidate.votes + candidate.read.size);
|
|
145
155
|
const votedProbe = byVotes === undefined ? undefined : probes.get(byVotes.root);
|
|
146
156
|
if (byVotes)
|
|
147
157
|
return reportCheckout({ root: byVotes.root, evidence: 'referenced', probed: votedProbe, changed: [], withhold: withheld(byVotes.root, votedProbe.branch) }, tools, options);
|
|
148
158
|
const stopRoot = await checkoutRootOf(options.cwd);
|
|
149
|
-
const inherited = stopRoot === undefined ? await inheritedCheckout(store, sessionId, options, tools) : undefined;
|
|
159
|
+
const inherited = stopRoot === undefined ? await inheritedCheckout(store, sessionId, options, tools, allows) : undefined;
|
|
150
160
|
if (inherited)
|
|
151
161
|
return inherited;
|
|
152
162
|
// The Stop folder's own repository is held to the same admission as every
|
|
@@ -154,7 +164,7 @@ export async function resolveWorkCheckout(store, sessionId, records, stopEvent,
|
|
|
154
164
|
// outside the start folder.
|
|
155
165
|
// A folder whose checkout cannot be found is not admitted either: git may
|
|
156
166
|
// still have named a repository there, past what the walk reaches.
|
|
157
|
-
if (stopRoot === undefined || !admits(stopRoot))
|
|
167
|
+
if (stopRoot === undefined || !admits(stopRoot) || !allows(stopRoot))
|
|
158
168
|
return { tools: keepingPathsIn(tools, undefined) };
|
|
159
169
|
// Enrichment read the folder's branch; a detached review gets its pull
|
|
160
170
|
// request's (SPEC §3b), withheld by the same rule as any other.
|
|
@@ -200,11 +210,12 @@ export async function resolveWorkCheckout(store, sessionId, records, stopEvent,
|
|
|
200
210
|
* @param sessionId - Provider session id.
|
|
201
211
|
* @param options - Tracking options.
|
|
202
212
|
* @param tools - The turn's tool records.
|
|
213
|
+
* @param allows - The turn's file test (`fileEvidenceAllows`).
|
|
203
214
|
* @returns The report, or undefined when nothing was inherited or it cannot be read.
|
|
204
215
|
*/
|
|
205
|
-
async function inheritedCheckout(store, sessionId, options, tools) {
|
|
216
|
+
async function inheritedCheckout(store, sessionId, options, tools, allows) {
|
|
206
217
|
const found = await resolveInherited(store, sessionId, admission(options, (await store.readStart(sessionId)) ?? options.cwd, true));
|
|
207
|
-
if (!found)
|
|
218
|
+
if (!found || !allows(found.root))
|
|
208
219
|
return undefined;
|
|
209
220
|
const probed = await probe(emptyCandidate(found.root, 0));
|
|
210
221
|
if (!probed.closing)
|
|
@@ -331,15 +342,38 @@ function candidatesOf(records, admits) {
|
|
|
331
342
|
candidate.votes += 1;
|
|
332
343
|
continue;
|
|
333
344
|
}
|
|
334
|
-
|
|
335
|
-
// may never have touched, and carries no access marker.
|
|
336
|
-
if (record.kind !== 'tool' || typeof record.filePath !== 'string' || (record.access !== 'read' && record.access !== 'edit'))
|
|
345
|
+
if (!touchedFile(record))
|
|
337
346
|
continue;
|
|
338
347
|
const candidate = at(record.repositoryRoot);
|
|
339
348
|
candidate?.[record.access === 'read' ? 'read' : 'edited'].add(record.filePath);
|
|
340
349
|
}
|
|
341
350
|
return [...byRoot.values()].sort(byFirstSight).slice(0, MAX_TURN_CHECKOUTS);
|
|
342
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Whether a turn's edits let a rung below `changed` report a checkout: the
|
|
354
|
+
* turn edited no file, or one of its edits is in it. Reads decide nothing (a
|
|
355
|
+
* turn running tests in a checkout may read `/tmp/out.txt`), though they still
|
|
356
|
+
* rank the checkouts this admits on the `referenced` rung. A file's root is
|
|
357
|
+
* its innermost checkout, so a worktree nested in that folder does not count.
|
|
358
|
+
*
|
|
359
|
+
* @param tools - The turn's tool records.
|
|
360
|
+
* @returns A test of one canonical checkout root.
|
|
361
|
+
*/
|
|
362
|
+
function fileEvidenceAllows(tools) {
|
|
363
|
+
const roots = tools.filter((record) => touchedFile(record) && record.access === 'edit').map((record) => (typeof record.repositoryRoot === 'string' ? canonicalRoot(record.repositoryRoot) : undefined));
|
|
364
|
+
return (root) => roots.length === 0 || roots.includes(root);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Whether a record is a file the turn read or edited. Only a completed read or
|
|
368
|
+
* edit is evidence: a failed call names a file it may never have touched, and
|
|
369
|
+
* carries no access marker.
|
|
370
|
+
*
|
|
371
|
+
* @param record - A turn record.
|
|
372
|
+
* @returns True for a completed read or edit of a file.
|
|
373
|
+
*/
|
|
374
|
+
function touchedFile(record) {
|
|
375
|
+
return record.kind === 'tool' && typeof record.filePath === 'string' && (record.access === 'read' || record.access === 'edit');
|
|
376
|
+
}
|
|
343
377
|
/**
|
|
344
378
|
* A checkout at the Stop: fingerprint and remote together, then the commit diff
|
|
345
379
|
* when HEAD moved. A checkout whose directory is gone keeps its baseline's
|
package/docs/DATA_HANDLING.md
CHANGED
|
@@ -162,6 +162,12 @@ prompt evidence hashes the prompt as the agent reported it.
|
|
|
162
162
|
transcript tail no longer reaches one, and deleted with the session. Codex and
|
|
163
163
|
Cursor's SQLite indexes are opened read-only through Node's standard library;
|
|
164
164
|
Node versions before 22.12 omit those optional title fields.
|
|
165
|
+
- `tools_used`: per-tool call counts. An MCP call is keyed `mcp__<server>__<tool>`
|
|
166
|
+
(the server's name, else a remote endpoint's host:port or a stdio command's base name,
|
|
167
|
+
else `unknown`; never arguments. Cursor keys are cut at 200 characters; every key is
|
|
168
|
+
secret-scrubbed before it is sent). `capture.mcpNames: false`
|
|
169
|
+
folds every MCP key into `mcp`, keeping the count; a repository file can set it
|
|
170
|
+
false, never true. It is metadata, so `toolInput` does not gate it.
|
|
165
171
|
- `tool_inputs` (only under `toolInput` with consent): per shell or connector (MCP)
|
|
166
172
|
call, `{tool, command}` or `{tool, server, name, arguments}` with the arguments as
|
|
167
173
|
JSON text; sensitive argument keys are redacted before that, every string is cut
|
|
@@ -419,10 +425,11 @@ Global configuration is stored in `~/.agentwatch/config.json` (0600). The
|
|
|
419
425
|
organization install key written by setup (from `--token`, `$AGENTWATCH_TOKEN`
|
|
420
426
|
or the prompt) is exchanged once through `POST /v1/devices/enroll` for a device
|
|
421
427
|
credential of this machine's own, and the config records `device: { id, store }`
|
|
422
|
-
beside the key. The key stays in the file
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
428
|
+
beside the key. The key stays in the file to enroll again when the device
|
|
429
|
+
secret expires. The Claude hooks and header helper send the device's access
|
|
430
|
+
token and never the key once the device is recorded; Codex and Gemini get the
|
|
431
|
+
same access token in their own config, rewritten by each hook as it rotates
|
|
432
|
+
(docs/NATIVE_OTLP_TOKENS.md). The device reference is an id
|
|
426
433
|
derived from the install key's digest and the name of the store that holds the
|
|
427
434
|
secret. The device secret lives in the macOS Keychain (service
|
|
428
435
|
`agentwatch-device`), the Secret Service keyring through `secret-tool` (only
|
|
@@ -36,11 +36,15 @@ or the Secret Service keyring (Linux with a desktop session). `uninstall` withou
|
|
|
36
36
|
`--agent` removes it; a Windows DPAPI blob or the no-keychain fallback file lives
|
|
37
37
|
in `~/.agentwatch/credentials/` and goes with `--purge` as well.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
The MDM templates in `examples/mdm/` deploy no key: `agentwatch setup
|
|
40
|
+
<enrollment-url> --defer-sign-in` configures the organization, and the machine
|
|
41
|
+
sends nothing until its developer runs `agentwatch setup` and signs in.
|
|
42
|
+
|
|
43
|
+
A legacy MDM rollout that sets `$AGENTWATCH_TOKEN` hands setup the install key as
|
|
40
44
|
before; the edge exchanges it for a device credential during that setup run, or
|
|
41
45
|
on the first later run that reaches the backend. The key stays in `config.json`
|
|
42
|
-
(0600) beside the device
|
|
43
|
-
|
|
46
|
+
(0600) beside the device, to enroll again when the device secret expires; Codex
|
|
47
|
+
and Gemini get the device's access token, and the key only until the exchange succeeds. Re-running setup with the same key keeps the existing device rather than
|
|
44
48
|
enrolling a new one. On Windows the exchange happens in setup only. Headless Linux has no keychain: the secret is a 0600 file and
|
|
45
49
|
`agentwatch doctor` reports the credential check as a warning.
|
|
46
50
|
|
|
@@ -84,7 +88,18 @@ The npm package itself is never removed by `uninstall`; `npm rm -g
|
|
|
84
88
|
|
|
85
89
|
## Release operation
|
|
86
90
|
|
|
87
|
-
Nothing runs on
|
|
91
|
+
Nothing runs on PRs or branch pushes. The runtime packages `@agent-watch-ai/otel`
|
|
92
|
+
and `agent-watch-otel` are released together by pushing an `otel-vX.Y.Z` tag on
|
|
93
|
+
`main` (`otel-release.yml`, gated by the `otel-release` environment, trusted
|
|
94
|
+
publishing on npm and PyPI). Before the first tag: on PyPI, change the
|
|
95
|
+
`agent-watch-otel` trusted publisher from `python-release.yml` / `pypi-release`
|
|
96
|
+
to `otel-release.yml` / `otel-release`. npm trusted publishing can only be set
|
|
97
|
+
up on a package that exists, so the first publish uses a short-lived granular
|
|
98
|
+
npm token (read and write on the `@agent-watch-ai` scope, 2FA bypass) stored as
|
|
99
|
+
the `NPM_TOKEN` secret of the `otel-release` environment; then add the npm
|
|
100
|
+
trusted publisher (`otel-release.yml`, `otel-release`), delete the secret
|
|
101
|
+
and revoke the token. The workflow publishes PyPI first, then npm; a rerun skips
|
|
102
|
+
what is already published. The CLI release starts with a `workflow_dispatch` of
|
|
88
103
|
`release.yml`, which verifies and builds artifacts; locally the same is: run
|
|
89
104
|
`npm ci`, the test/lint/typecheck/build checks, then `npm run release:artifacts`
|
|
90
105
|
to create a verified tarball, production dependency SBOM, and `SHA256SUMS`.
|
package/package.json
CHANGED