@agent-watch-ai/edge 0.3.1 → 0.5.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +10 -6
  3. package/SECURITY.md +7 -4
  4. package/dist/cli/constants/cli.constants.d.ts +2 -0
  5. package/dist/cli/constants/cli.constants.js +3 -1
  6. package/dist/cli/doctor.js +13 -2
  7. package/dist/cli/setup.js +138 -29
  8. package/dist/cli/toggle.js +5 -1
  9. package/dist/cli/types/cli.types.d.ts +6 -0
  10. package/dist/cli/uninstall.js +1 -1
  11. package/dist/cli.js +14 -3
  12. package/dist/config/config-store.d.ts +1 -1
  13. package/dist/config/config-store.js +2 -2
  14. package/dist/config/constants/config.constants.d.ts +4 -1
  15. package/dist/config/constants/config.constants.js +7 -2
  16. package/dist/config/repo-config.js +1 -1
  17. package/dist/config/schemas/config.schema.d.ts +113 -767
  18. package/dist/config/schemas/config.schema.js +17 -8
  19. package/dist/credentials/constants/credentials.constants.d.ts +8 -0
  20. package/dist/credentials/constants/credentials.constants.js +9 -1
  21. package/dist/credentials/credential-status.js +8 -4
  22. package/dist/credentials/credentials.d.ts +16 -2
  23. package/dist/credentials/credentials.js +30 -5
  24. package/dist/credentials/device-api.d.ts +10 -1
  25. package/dist/credentials/device-api.js +12 -1
  26. package/dist/credentials/identity.d.ts +12 -1
  27. package/dist/credentials/identity.js +12 -1
  28. package/dist/credentials/migration.d.ts +1 -1
  29. package/dist/credentials/migration.js +1 -1
  30. package/dist/credentials/schemas/device-api.schema.d.ts +4 -51
  31. package/dist/credentials/schemas/device-state.schema.d.ts +3 -38
  32. package/dist/credentials/sign-in.d.ts +14 -1
  33. package/dist/credentials/sign-in.js +24 -5
  34. package/dist/credentials/types/credentials.types.d.ts +12 -1
  35. package/dist/enforcement/decision-client.js +2 -1
  36. package/dist/enforcement/enforcement.js +7 -5
  37. package/dist/enforcement/types/enforcement.types.d.ts +2 -2
  38. package/dist/git/code-state.d.ts +33 -0
  39. package/dist/git/code-state.js +44 -0
  40. package/dist/git/constants/git.constants.d.ts +6 -0
  41. package/dist/git/constants/git.constants.js +6 -0
  42. package/dist/git/index.d.ts +2 -1
  43. package/dist/git/index.js +1 -0
  44. package/dist/git/types/git.types.d.ts +6 -0
  45. package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
  46. package/dist/pipeline/constants/pipeline.constants.js +3 -0
  47. package/dist/pipeline/hook-pipeline.js +56 -7
  48. package/dist/privacy/command-fingerprint.d.ts +42 -0
  49. package/dist/privacy/command-fingerprint.js +249 -0
  50. package/dist/privacy/constants/command-fingerprint.constants.d.ts +34 -0
  51. package/dist/privacy/constants/command-fingerprint.constants.js +38 -0
  52. package/dist/privacy/index.d.ts +3 -1
  53. package/dist/privacy/index.js +2 -0
  54. package/dist/privacy/product-capture.js +20 -0
  55. package/dist/privacy/types/privacy.types.d.ts +7 -0
  56. package/dist/providers/antigravity/antigravity.adapter.js +3 -0
  57. package/dist/providers/antigravity/schemas/antigravity.schema.d.ts +18 -492
  58. package/dist/providers/claude/claude.adapter.js +12 -1
  59. package/dist/providers/claude/constants/claude.constants.d.ts +6 -0
  60. package/dist/providers/claude/constants/claude.constants.js +6 -0
  61. package/dist/providers/claude/schemas/claude.schema.d.ts +1 -43
  62. package/dist/providers/codex/codex.adapter.js +14 -0
  63. package/dist/providers/codex/codex.otel.d.ts +12 -1
  64. package/dist/providers/codex/codex.otel.js +61 -11
  65. package/dist/providers/codex/constants/codex.otel.constants.d.ts +5 -0
  66. package/dist/providers/codex/constants/codex.otel.constants.js +5 -0
  67. package/dist/providers/codex/schemas/codex.schema.d.ts +1 -41
  68. package/dist/providers/constants/provider.constants.d.ts +8 -0
  69. package/dist/providers/constants/provider.constants.js +8 -0
  70. package/dist/providers/cursor/constants/cursor.constants.d.ts +2 -0
  71. package/dist/providers/cursor/constants/cursor.constants.js +2 -0
  72. package/dist/providers/cursor/cursor.adapter.js +84 -5
  73. package/dist/providers/cursor/schemas/cursor.schema.d.ts +5 -85
  74. package/dist/providers/gemini/constants/gemini.constants.d.ts +2 -0
  75. package/dist/providers/gemini/constants/gemini.constants.js +2 -0
  76. package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +16 -1
  77. package/dist/providers/gemini/constants/gemini.otel.constants.js +16 -1
  78. package/dist/providers/gemini/gemini.detect.d.ts +11 -0
  79. package/dist/providers/gemini/gemini.detect.js +14 -1
  80. package/dist/providers/gemini/gemini.hooks.d.ts +3 -3
  81. package/dist/providers/gemini/gemini.hooks.js +5 -5
  82. package/dist/providers/gemini/gemini.otel.d.ts +14 -4
  83. package/dist/providers/gemini/gemini.otel.js +418 -107
  84. package/dist/providers/gemini/schemas/gemini.schema.d.ts +1 -49
  85. package/dist/providers/shared/bearer-rewrite.d.ts +19 -0
  86. package/dist/providers/shared/bearer-rewrite.js +46 -0
  87. package/dist/providers/shared/constants/tooling.constants.d.ts +6 -0
  88. package/dist/providers/shared/constants/tooling.constants.js +6 -0
  89. package/dist/providers/shared/event-builder.d.ts +17 -2
  90. package/dist/providers/shared/event-builder.js +43 -3
  91. package/dist/providers/shared/install-record.d.ts +2 -0
  92. package/dist/providers/shared/install-record.js +3 -2
  93. package/dist/providers/shared/tooling.d.ts +35 -0
  94. package/dist/providers/shared/tooling.js +61 -1
  95. package/dist/providers/shared/types/adapter.types.d.ts +18 -0
  96. package/dist/providers/types/provider.types.d.ts +24 -0
  97. package/dist/storage/atomic-file.d.ts +14 -0
  98. package/dist/storage/atomic-file.js +19 -0
  99. package/dist/storage/constants/storage.constants.d.ts +2 -0
  100. package/dist/storage/constants/storage.constants.js +2 -0
  101. package/dist/storage/schemas/storage.schema.d.ts +11 -175
  102. package/dist/storage/schemas/storage.schema.js +7 -1
  103. package/dist/transport/schemas/queue.schema.d.ts +1 -16
  104. package/dist/transport/schemas/queue.schema.js +1 -1
  105. package/dist/turns/constants/turns.constants.d.ts +17 -0
  106. package/dist/turns/constants/turns.constants.js +17 -0
  107. package/dist/turns/index.d.ts +3 -2
  108. package/dist/turns/index.js +1 -0
  109. package/dist/turns/tool-events.d.ts +15 -0
  110. package/dist/turns/tool-events.js +59 -0
  111. package/dist/turns/turn-state.js +2 -2
  112. package/dist/turns/turn-summary.d.ts +1 -1
  113. package/dist/turns/turn-summary.js +1 -0
  114. package/dist/turns/turn-tracker.js +138 -7
  115. package/dist/turns/types/turn-state.types.d.ts +28 -1
  116. package/dist/turns/types/turn-summary.types.d.ts +30 -0
  117. package/dist/turns/types/turn-tracker.types.d.ts +10 -0
  118. package/dist/turns/work-checkout.d.ts +5 -3
  119. package/dist/turns/work-checkout.js +46 -12
  120. package/docs/AUDIT_PROMPT.md +11 -0
  121. package/docs/DATA_HANDLING.md +69 -14
  122. package/docs/ENTERPRISE_DEPLOYMENT.md +21 -5
  123. package/package.json +9 -8
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import { boolFlag, parseArgs, stringFlag, valuelessFlags } from './cli/args.js';
9
9
  const HELP = `agentwatch — telemetry edge for AI coding agents
10
10
 
11
11
  Usage:
12
- agentwatch setup [enrollment-url] [--endpoint <url>] [--allow-custom-endpoint] [--no-browser] [--token <token>] [--developer-email <email>] [--developer-name <name>] [--root <path>] [--otel <signals>]
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>]
13
13
  agentwatch status
14
14
  agentwatch off
15
15
  agentwatch on
@@ -28,6 +28,10 @@ Flags:
28
28
  proxied backend). Stored in the config and shown by status and doctor
29
29
  --no-browser with an enrollment URL, print the sign-in link without opening a
30
30
  browser (never opened anyway under CI, over SSH or without a terminal)
31
+ --enrollment-code - with an enrollment URL, enroll an unattended machine with an
32
+ admin-issued code read from stdin instead of signing in through
33
+ a browser; $AGENTWATCH_ENROLLMENT_CODE works too. A code is never
34
+ accepted on the command line
31
35
  --token <token> bearer token for the backend; $AGENTWATCH_TOKEN is the private
32
36
  channel for an MDM run, where argv is visible to ps
33
37
  --developer-email <email> identity attached to turn summaries and keyed on by per-developer
@@ -43,6 +47,11 @@ Flags:
43
47
  --otel <signals> native OTLP signals agents export to the backend: comma list of
44
48
  logs,traces,metrics, or "all"/"none" (default: logs — the
45
49
  per-request usage/cost ledger the backend turns into llm.call)
50
+ --defer-sign-in with an enrollment URL, for an MDM run: save the organization and
51
+ install the hooks with no credential. Nothing is sent until the
52
+ developer runs \`agentwatch setup\` and signs in as themselves.
53
+ A machine with no device and an enrollment code redeems the
54
+ code now instead
46
55
  --agent <id> limit the command to one agent (claude | codex | cursor)
47
56
  --purge uninstall: also delete ~/.agentwatch and queued local data
48
57
  --dry-run hook: print resulting events to stdout instead of sending
@@ -54,7 +63,7 @@ Flags:
54
63
  Configuration:
55
64
  global ~/.agentwatch/config.json (written by setup)
56
65
  per repository .agentwatch.json in the repo root — overrides the global
57
- config for work in that repo; "token", "device", "installationId",
66
+ config for work in that repo; "token", "device", "organizationId", "installationId",
58
67
  "developerEmail", "developerName", "endpoint", "eventsUrl",
59
68
  "otlpUrl" and
60
69
  "roots" are global-only and ignored there
@@ -108,10 +117,12 @@ async function main() {
108
117
  allowCustomEndpoint: boolFlag(parsed, 'allow-custom-endpoint'),
109
118
  noBrowser: boolFlag(parsed, 'no-browser'),
110
119
  token: stringFlag(parsed, 'token'),
120
+ enrollmentCode: stringFlag(parsed, 'enrollment-code'),
111
121
  developerEmail: stringFlag(parsed, 'developer-email'),
112
122
  developerName: stringFlag(parsed, 'developer-name'),
113
123
  root: stringFlag(parsed, 'root'),
114
- otel: stringFlag(parsed, 'otel')
124
+ otel: stringFlag(parsed, 'otel'),
125
+ deferSignIn: boolFlag(parsed, 'defer-sign-in')
115
126
  });
116
127
  }
117
128
  case 'status': {
@@ -45,7 +45,7 @@ export declare function updateConfig(paths: AgentWatchPaths, change: (current: C
45
45
  * Record the device an install key was exchanged for, beside that key,
46
46
  * wherever the file holds it: the machine entry and every root sharing it.
47
47
  *
48
- * The key stays: Codex and Gemini still present it (AWT-357 retires it).
48
+ * The key stays, to enroll again when the device secret expires.
49
49
  *
50
50
  * @param paths - Resolved AgentWatch paths.
51
51
  * @param installKey - The key that was exchanged.
@@ -124,7 +124,7 @@ export async function updateConfig(paths, change, options = {}) {
124
124
  * Record the device an install key was exchanged for, beside that key,
125
125
  * wherever the file holds it: the machine entry and every root sharing it.
126
126
  *
127
- * The key stays: Codex and Gemini still present it (AWT-357 retires it).
127
+ * The key stays, to enroll again when the device secret expires.
128
128
  *
129
129
  * @param paths - Resolved AgentWatch paths.
130
130
  * @param installKey - The key that was exchanged.
@@ -309,5 +309,5 @@ function fallbackConfig() {
309
309
  * @returns The joined description.
310
310
  */
311
311
  function describeIssues(issues) {
312
- return issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ');
312
+ return issues.map((issue) => `${issue.path.map(String).join('.')}: ${issue.message}`).join('; ');
313
313
  }
@@ -158,7 +158,10 @@ export declare const RE_TRAILING_SLASHES: RegExp;
158
158
  export declare const ROUTE_FIELDS: readonly ["eventsUrl", "otlpUrl", "enforcementUrl"];
159
159
  /** The fields that hold an identity's credential; a root naming one replaces both. */
160
160
  export declare const CREDENTIAL_KEYS: ReadonlySet<string>;
161
- /** The device credential reference alone, removed by uninstall. */
161
+ /**
162
+ * The device credential reference, removed by uninstall, with the organization
163
+ * it was enrolled in: left behind, it would read as an install waiting for a sign-in.
164
+ */
162
165
  export declare const DEVICE_KEY: ReadonlySet<string>;
163
166
  /** One writer of config.json at a time: setup, uninstall and a hook's exchange. */
164
167
  export declare const CONFIG_LOCK = "config";
@@ -116,6 +116,8 @@ export const GLOBAL_ONLY_KEYS = new Set([
116
116
  // wrong store would leave every hook there with no bearer and every prompt
117
117
  // unchecked, a one-line budget-cap bypass.
118
118
  'device',
119
+ // Beside no credential it stops every hook: never a repository's to set.
120
+ 'organizationId',
119
121
  'installationId',
120
122
  'developerEmail',
121
123
  'developerName',
@@ -177,8 +179,11 @@ export const RE_TRAILING_SLASHES = /\/+$/;
177
179
  export const ROUTE_FIELDS = ['eventsUrl', 'otlpUrl', 'enforcementUrl'];
178
180
  /** The fields that hold an identity's credential; a root naming one replaces both. */
179
181
  export const CREDENTIAL_KEYS = new Set(['token', 'device']);
180
- /** The device credential reference alone, removed by uninstall. */
181
- export const DEVICE_KEY = new Set(['device']);
182
+ /**
183
+ * The device credential reference, removed by uninstall, with the organization
184
+ * it was enrolled in: left behind, it would read as an install waiting for a sign-in.
185
+ */
186
+ export const DEVICE_KEY = new Set(['device', 'organizationId']);
182
187
  /** One writer of config.json at a time: setup, uninstall and a hook's exchange. */
183
188
  export const CONFIG_LOCK = 'config';
184
189
  /** How long setup and uninstall wait for a hook holding the config lock; a hook holds it for one read and one write. */
@@ -51,7 +51,7 @@ export function mergeRepoConfig(global, repoValue) {
51
51
  const merged = overlay(global, narrowed.value);
52
52
  const parsed = configSchema.safeParse(merged);
53
53
  if (!parsed.success) {
54
- const detail = parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ');
54
+ const detail = parsed.error.issues.map((issue) => `${issue.path.map(String).join('.')}: ${issue.message}`).join('; ');
55
55
  return { config: global, warnings: [...warnings, `${REPO_CONFIG_NAME}: invalid overrides ignored (${detail})`] };
56
56
  }
57
57
  return { config: parsed.data, warnings };