@agent-watch-ai/edge 0.4.0 → 0.6.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 +50 -0
- package/README.md +8 -7
- package/SECURITY.md +1 -1
- package/dist/config/config-store.js +1 -1
- package/dist/config/repo-config.js +1 -1
- package/dist/config/schemas/config.schema.d.ts +93 -857
- package/dist/config/schemas/config.schema.js +5 -5
- package/dist/credentials/credentials.js +2 -2
- package/dist/credentials/schemas/device-api.schema.d.ts +4 -51
- package/dist/credentials/schemas/device-state.schema.d.ts +3 -38
- 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 +7 -4
- package/dist/events/types/repo-snapshot.types.d.ts +1 -4
- package/dist/events/types/repo-tree.types.d.ts +24 -0
- package/dist/events/types/repo-tree.types.js +1 -0
- package/dist/git/code-state.d.ts +33 -0
- package/dist/git/code-state.js +44 -0
- package/dist/git/constants/git.constants.d.ts +6 -0
- package/dist/git/constants/git.constants.js +6 -0
- package/dist/git/constants/tree.constants.d.ts +71 -0
- package/dist/git/constants/tree.constants.js +92 -0
- package/dist/git/git-context.d.ts +1 -0
- package/dist/git/git-context.js +3 -2
- package/dist/git/index.d.ts +2 -1
- package/dist/git/index.js +1 -0
- package/dist/git/repo-tree.d.ts +69 -0
- package/dist/git/repo-tree.js +130 -0
- package/dist/git/types/git.types.d.ts +11 -2
- package/dist/git/types/snapshot.types.d.ts +12 -0
- package/dist/pipeline/hook-pipeline.js +40 -24
- package/dist/privacy/command-fingerprint.d.ts +42 -0
- package/dist/privacy/command-fingerprint.js +249 -0
- package/dist/privacy/constants/command-fingerprint.constants.d.ts +34 -0
- package/dist/privacy/constants/command-fingerprint.constants.js +38 -0
- package/dist/privacy/index.d.ts +3 -1
- package/dist/privacy/index.js +2 -0
- package/dist/privacy/product-capture.js +53 -6
- package/dist/privacy/types/privacy.types.d.ts +7 -0
- package/dist/providers/antigravity/antigravity.adapter.js +3 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.d.ts +18 -492
- package/dist/providers/claude/claude.adapter.js +12 -1
- package/dist/providers/claude/constants/claude.constants.d.ts +6 -0
- package/dist/providers/claude/constants/claude.constants.js +6 -0
- package/dist/providers/claude/schemas/claude.schema.d.ts +1 -43
- package/dist/providers/codex/codex.adapter.js +14 -0
- package/dist/providers/codex/schemas/codex.schema.d.ts +1 -41
- package/dist/providers/cursor/cursor.adapter.js +5 -2
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +5 -85
- package/dist/providers/gemini/constants/gemini.constants.d.ts +2 -0
- package/dist/providers/gemini/constants/gemini.constants.js +2 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +10 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +11 -2
- package/dist/providers/gemini/gemini.detect.d.ts +11 -0
- package/dist/providers/gemini/gemini.detect.js +14 -1
- package/dist/providers/gemini/gemini.hooks.d.ts +3 -3
- package/dist/providers/gemini/gemini.hooks.js +5 -5
- package/dist/providers/gemini/gemini.otel.d.ts +6 -6
- package/dist/providers/gemini/gemini.otel.js +392 -121
- package/dist/providers/gemini/schemas/gemini.schema.d.ts +1 -49
- package/dist/providers/shared/event-builder.d.ts +17 -2
- package/dist/providers/shared/event-builder.js +43 -3
- package/dist/providers/shared/install-record.d.ts +2 -0
- package/dist/providers/shared/install-record.js +3 -2
- package/dist/providers/shared/tooling.d.ts +7 -0
- package/dist/providers/shared/tooling.js +10 -1
- package/dist/providers/shared/types/adapter.types.d.ts +18 -0
- package/dist/snapshot/branch-selection.js +3 -1
- package/dist/snapshot/budget.js +2 -2
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +8 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +8 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +6 -0
- package/dist/snapshot/constants/snapshot.constants.js +6 -0
- package/dist/snapshot/index.d.ts +5 -0
- package/dist/snapshot/index.js +2 -0
- package/dist/snapshot/snapshot-event.d.ts +7 -0
- package/dist/snapshot/snapshot-event.js +8 -5
- package/dist/snapshot/snapshot-state.js +19 -1
- package/dist/snapshot/tree-event.d.ts +14 -0
- package/dist/snapshot/tree-event.js +91 -0
- package/dist/snapshot/tree-pipeline.d.ts +12 -0
- package/dist/snapshot/tree-pipeline.js +153 -0
- package/dist/snapshot/types/snapshot.types.d.ts +44 -1
- package/dist/storage/schemas/storage.schema.d.ts +11 -175
- package/dist/storage/schemas/storage.schema.js +7 -1
- package/dist/transport/constants/transport.constants.d.ts +5 -0
- package/dist/transport/constants/transport.constants.js +5 -0
- package/dist/transport/queue.js +40 -6
- package/dist/transport/schemas/queue.schema.d.ts +1 -16
- package/dist/transport/schemas/queue.schema.js +1 -1
- package/dist/turns/constants/turns.constants.d.ts +17 -0
- package/dist/turns/constants/turns.constants.js +17 -0
- package/dist/turns/index.d.ts +3 -2
- package/dist/turns/index.js +1 -0
- package/dist/turns/tool-events.d.ts +15 -0
- package/dist/turns/tool-events.js +59 -0
- package/dist/turns/turn-state.js +2 -2
- package/dist/turns/turn-summary.d.ts +1 -1
- package/dist/turns/turn-summary.js +4 -4
- package/dist/turns/turn-tracker.js +138 -7
- package/dist/turns/types/turn-state.types.d.ts +28 -1
- package/dist/turns/types/turn-summary.types.d.ts +33 -5
- package/dist/turns/types/turn-tracker.types.d.ts +10 -0
- package/docs/AUDIT_PROMPT.md +11 -0
- package/docs/DATA_HANDLING.md +132 -33
- package/docs/ENTERPRISE_DEPLOYMENT.md +2 -1
- package/docs/PERFORMANCE.md +17 -0
- package/package.json +9 -8
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names the rules in `tests/fixtures/command-vectors.json`, a byte copy of
|
|
3
|
+
* core's `packages/fingerprint/test/command-vectors.json`. Command digests
|
|
4
|
+
* from different schemes never compare.
|
|
5
|
+
*/
|
|
6
|
+
export const COMMAND_SCHEME = 'agent-watch-command/1';
|
|
7
|
+
/**
|
|
8
|
+
* A check is an allowlisted command that ran this long (workflow SPEC §12.1).
|
|
9
|
+
* The edge decides the flag, since only it holds the duration and the command
|
|
10
|
+
* together; core sees the flag alone.
|
|
11
|
+
*/
|
|
12
|
+
export const CHECK_MIN_DURATION_MS = 60_000;
|
|
13
|
+
/** Bounds the lexer's work on hostile input; core cuts at the same code point. */
|
|
14
|
+
export const MAX_COMMAND_CODE_POINTS = 16_384;
|
|
15
|
+
/** `npm`, `pnpm` and `yarn` scripts that are checks, alone or as `name:variant` (`test:unit`). */
|
|
16
|
+
export const CHECK_SCRIPTS = new Set(['test', 'verify', 'lint', 'typecheck', 'check', 'build']);
|
|
17
|
+
export const CHECK_PROGRAMS = new Set(['vitest', 'jest', 'tsc', 'pytest', 'pr-tests.sh']);
|
|
18
|
+
export const SCRIPT_RUNNERS = new Set(['npm', 'pnpm', 'yarn']);
|
|
19
|
+
/** `go test`, `cargo test`, `make test`, `make check`: the first argument decides. */
|
|
20
|
+
export const SUBCOMMAND_CHECKS = new Map([
|
|
21
|
+
['go', new Set(['test'])],
|
|
22
|
+
['cargo', new Set(['test'])],
|
|
23
|
+
['make', new Set(['test', 'check'])]
|
|
24
|
+
]);
|
|
25
|
+
/** The `npm run` words that name a script as their next argument. */
|
|
26
|
+
export const RUN_SCRIPT_WORDS = new Set(['run', 'run-script']);
|
|
27
|
+
/** Inside `"…"`, a backslash escapes only these. */
|
|
28
|
+
export const DOUBLE_QUOTE_ESCAPES = new Set(['"', '\\', '$', '`']);
|
|
29
|
+
/** Shells whose `-c` / `-lc` script is the command an argv runs. */
|
|
30
|
+
export const SHELL_WRAPPERS = new Set(['bash', 'sh', 'zsh']);
|
|
31
|
+
export const SHELL_SCRIPT_FLAGS = new Set(['-c', '-lc']);
|
|
32
|
+
export const RE_ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
33
|
+
export const RE_FD_PREFIX = /^\d+$/;
|
|
34
|
+
export const RE_PYTHON = /^python[0-9.]*$/;
|
|
35
|
+
/** What may follow `>&` in a duplication (`2>&1`, `>&-`). */
|
|
36
|
+
export const RE_DUPLICATION_CHAR = /[0-9-]/;
|
|
37
|
+
/** A script's `:variant` suffix (`test:unit`). */
|
|
38
|
+
export const RE_SCRIPT_VARIANT = /:.*/s;
|
package/dist/privacy/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* The last gate before anything leaves the machine: known credential shapes
|
|
3
3
|
* are removed from every outgoing value, whatever the capture settings.
|
|
4
4
|
*/
|
|
5
|
-
export type { SecretPattern } from './types/privacy.types.js';
|
|
5
|
+
export type { CommandFingerprint, SecretPattern } from './types/privacy.types.js';
|
|
6
6
|
export { REDACTED, SECRET_PATTERNS, SENSITIVE_KEY_PATTERN } from './constants/privacy.constants.js';
|
|
7
7
|
export { sanitizeText, sanitizeValue } from './sanitizer.js';
|
|
8
8
|
export { applyProductCapture } from './product-capture.js';
|
|
9
|
+
export { CHECK_MIN_DURATION_MS, COMMAND_SCHEME } from './constants/command-fingerprint.constants.js';
|
|
10
|
+
export { checkSegment, commandFingerprint, commandText, normaliseCommand } from './command-fingerprint.js';
|
package/dist/privacy/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { REDACTED, SECRET_PATTERNS, SENSITIVE_KEY_PATTERN } from './constants/privacy.constants.js';
|
|
2
2
|
export { sanitizeText, sanitizeValue } from './sanitizer.js';
|
|
3
3
|
export { applyProductCapture } from './product-capture.js';
|
|
4
|
+
export { CHECK_MIN_DURATION_MS, COMMAND_SCHEME } from './constants/command-fingerprint.constants.js';
|
|
5
|
+
export { checkSegment, commandFingerprint, commandText, normaliseCommand } from './command-fingerprint.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { foldMcpNames } from '../providers/shared/tooling.js';
|
|
1
|
+
import { foldMcpName, foldMcpNames } from '../providers/shared/tooling.js';
|
|
2
2
|
import { sanitizeValue } from './sanitizer.js';
|
|
3
3
|
/**
|
|
4
4
|
* Reapply current capture policy to persisted records before queueing or sending.
|
|
@@ -16,16 +16,21 @@ export function applyProductCapture(event, capture) {
|
|
|
16
16
|
if (event.event.type === 'repo.snapshot') {
|
|
17
17
|
if (capture?.git === false)
|
|
18
18
|
return undefined;
|
|
19
|
-
|
|
19
|
+
const snapshot = withoutUnreadSnapshotFields(event);
|
|
20
|
+
return sanitizeValue(capture?.files === false ? withoutCommitFiles(snapshot) : snapshot);
|
|
20
21
|
}
|
|
22
|
+
// A tree is nothing but paths and the names declared in them: it goes with
|
|
23
|
+
// either flag, queued records included, and is never sent emptied.
|
|
24
|
+
if (event.event.type === 'repo.tree')
|
|
25
|
+
return capture?.git === false || capture?.files === false ? undefined : sanitizeValue(event);
|
|
21
26
|
if (event.event.type !== 'turn.summary')
|
|
22
27
|
return sanitizeValue(event);
|
|
23
28
|
const summary = event;
|
|
24
29
|
// Response text goes unconditionally: this release never builds it, but a
|
|
25
30
|
// summary queued by an older one can still carry it. `prompt` is that older
|
|
26
31
|
// release's field and goes the same way; prompt text now rides only as
|
|
27
|
-
// `prompt_text`.
|
|
28
|
-
//
|
|
32
|
+
// `prompt_text`. The prompt and response evidence (length + sha256) goes
|
|
33
|
+
// too: nothing in the platform reads it.
|
|
29
34
|
//
|
|
30
35
|
// The content fields need an explicit `true`: they are opt-in, and a
|
|
31
36
|
// missing policy is not consent. The path and repository fields need an
|
|
@@ -36,6 +41,8 @@ export function applyProductCapture(event, capture) {
|
|
|
36
41
|
return sanitizeValue({
|
|
37
42
|
...event,
|
|
38
43
|
prompt: undefined,
|
|
44
|
+
prompt_evidence: undefined,
|
|
45
|
+
response_evidence: undefined,
|
|
39
46
|
tools_used: capture?.mcpNames === false ? foldMcpNames(summary.tools_used) : summary.tools_used,
|
|
40
47
|
response: undefined,
|
|
41
48
|
prompt_text: capture?.promptText === true ? summary.prompt_text : undefined,
|
|
@@ -46,10 +53,15 @@ export function applyProductCapture(event, capture) {
|
|
|
46
53
|
branch: git ? undefined : summary.branch,
|
|
47
54
|
commit: git ? undefined : summary.commit,
|
|
48
55
|
jira_ids: git ? undefined : summary.jira_ids,
|
|
49
|
-
prompt_jira_ids: git ? undefined : summary.prompt_jira_ids,
|
|
56
|
+
prompt_jira_ids: git ? undefined : summary.prompt_jira_ids?.slice(0, 1),
|
|
50
57
|
work_evidence: git ? undefined : summary.work_evidence,
|
|
51
58
|
parent_session_id: git ? undefined : summary.parent_session_id,
|
|
52
|
-
|
|
59
|
+
// Content-free (ids, times, outcome, digests), but on by default with git
|
|
60
|
+
// context and withheld whole without it: a digest of a command still says
|
|
61
|
+
// which command ran when.
|
|
62
|
+
tool_events: git ? undefined : withMcpPolicy(summary.tool_events, capture?.mcpNames === false),
|
|
63
|
+
// The blob id is what is matched; the path beside it in older records is not read.
|
|
64
|
+
content_hashes: files ? undefined : summary.content_hashes?.map(({ blob_sha }) => ({ blob_sha })),
|
|
53
65
|
manifest_repository: files ? undefined : summary.manifest_repository,
|
|
54
66
|
files_changed: files ? undefined : summary.files_changed,
|
|
55
67
|
files_touched: files ? undefined : summary.files_touched,
|
|
@@ -58,6 +70,41 @@ export function applyProductCapture(event, capture) {
|
|
|
58
70
|
external_files_read: files ? undefined : summary.external_files_read
|
|
59
71
|
});
|
|
60
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Tool events with MCP names folded as `tools_used` folds them, when the
|
|
75
|
+
* policy withholds them: one name per call would otherwise say what the
|
|
76
|
+
* counts were folded to hide.
|
|
77
|
+
*
|
|
78
|
+
* @param events - The summary's tool events, if any.
|
|
79
|
+
* @param fold - Whether `capture.mcpNames` is off.
|
|
80
|
+
* @returns The events, folded when asked.
|
|
81
|
+
*/
|
|
82
|
+
function withMcpPolicy(events, fold) {
|
|
83
|
+
if (!fold || events === undefined)
|
|
84
|
+
return events;
|
|
85
|
+
return events.map((event) => ({ ...event, tool: foldMcpName(event.tool) }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A snapshot without the fields nothing in the platform reads: branch
|
|
89
|
+
* `last_commit_at`, commit `authored_at` and each file's status letter.
|
|
90
|
+
* The builder no longer sets them; a snapshot an older release queued
|
|
91
|
+
* loses them here.
|
|
92
|
+
*
|
|
93
|
+
* @param event - Snapshot, possibly from an older installation.
|
|
94
|
+
* @returns A copy without them.
|
|
95
|
+
*/
|
|
96
|
+
function withoutUnreadSnapshotFields(event) {
|
|
97
|
+
return {
|
|
98
|
+
...event,
|
|
99
|
+
branches: event.branches.map(({ last_commit_at: _lastCommitAt, ...branch }) => ({
|
|
100
|
+
...branch,
|
|
101
|
+
commits: branch.commits.map(({ authored_at: _authoredAt, ...commit }) => ({
|
|
102
|
+
...commit,
|
|
103
|
+
files: commit.files?.map(({ path }) => ({ path }))
|
|
104
|
+
}))
|
|
105
|
+
}))
|
|
106
|
+
};
|
|
107
|
+
}
|
|
61
108
|
/**
|
|
62
109
|
* A snapshot with no commit file names, for a policy that withholds paths.
|
|
63
110
|
*
|
|
@@ -11,3 +11,10 @@ export interface SecretPattern {
|
|
|
11
11
|
*/
|
|
12
12
|
readonly replacement?: string;
|
|
13
13
|
}
|
|
14
|
+
/** What the edge sends for one shell call. Never the command itself. */
|
|
15
|
+
export interface CommandFingerprint {
|
|
16
|
+
/** sha256 hex of the check segment when there is one, else of the whole normalised command; null when nothing is left. */
|
|
17
|
+
readonly digest: string | null;
|
|
18
|
+
/** A segment is on the check allowlist. A check also needs `CHECK_MIN_DURATION_MS`. */
|
|
19
|
+
readonly matchesCheck: boolean;
|
|
20
|
+
}
|
|
@@ -187,6 +187,9 @@ function antigravityToolPatch(payload, hook, context) {
|
|
|
187
187
|
status: toolStatus(hook, failed),
|
|
188
188
|
kind,
|
|
189
189
|
input: toolCall?.args,
|
|
190
|
+
// Unique within an execution, which is the turn: it pairs the two hooks
|
|
191
|
+
// of one call, and is never sent as the call's id.
|
|
192
|
+
pairingKey: stepIdxOf(payload, hook),
|
|
190
193
|
output: hook === 'PostToolUse' ? payload.postToolHookArgs?.result : undefined,
|
|
191
194
|
error: failed ? payload.postToolHookArgs?.error : undefined,
|
|
192
195
|
providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : undefined
|