@agent-watch-ai/edge 0.7.0 → 0.7.2

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 (118) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +4 -1
  3. package/dist/billing/session-billing.d.ts +5 -2
  4. package/dist/billing/session-billing.js +27 -6
  5. package/dist/capture/capture-env.d.ts +3 -3
  6. package/dist/capture/capture-env.js +5 -5
  7. package/dist/capture/captured-step.js +24 -0
  8. package/dist/capture/constants/capture.constants.d.ts +15 -0
  9. package/dist/capture/constants/capture.constants.js +15 -0
  10. package/dist/capture/launched-runs.d.ts +27 -0
  11. package/dist/capture/launched-runs.js +15 -9
  12. package/dist/capture/python/sitecustomize.py +11 -2
  13. package/dist/capture/venv-loader.d.ts +68 -0
  14. package/dist/capture/venv-loader.js +189 -0
  15. package/dist/cli/constants/cli.constants.d.ts +21 -0
  16. package/dist/cli/constants/cli.constants.js +22 -1
  17. package/dist/cli/doctor-run-capture.d.ts +8 -0
  18. package/dist/cli/doctor-run-capture.js +14 -0
  19. package/dist/cli/doctor.js +6 -2
  20. package/dist/cli/hook-check.d.ts +7 -2
  21. package/dist/cli/hook-check.js +30 -15
  22. package/dist/cli/hook.js +44 -3
  23. package/dist/cli/npm-global.d.ts +24 -0
  24. package/dist/cli/npm-global.js +77 -0
  25. package/dist/cli/npx-install.js +22 -6
  26. package/dist/cli/replay.js +42 -7
  27. package/dist/cli/setup.js +71 -7
  28. package/dist/cli/types/cli.types.d.ts +2 -0
  29. package/dist/cli/uninstall.js +34 -1
  30. package/dist/cli/update.js +3 -2
  31. package/dist/cli.js +4 -1
  32. package/dist/config/config-store.d.ts +15 -4
  33. package/dist/config/config-store.js +31 -7
  34. package/dist/config/config.d.ts +8 -0
  35. package/dist/config/config.js +10 -0
  36. package/dist/config/constants/config.constants.d.ts +13 -1
  37. package/dist/config/constants/config.constants.js +13 -1
  38. package/dist/config/repo-config.js +7 -2
  39. package/dist/config/schemas/config.schema.d.ts +6 -2
  40. package/dist/config/schemas/config.schema.js +17 -3
  41. package/dist/credentials/cloud-claim.d.ts +2 -0
  42. package/dist/credentials/cloud-claim.js +21 -2
  43. package/dist/credentials/constants/credentials.constants.d.ts +8 -0
  44. package/dist/credentials/constants/credentials.constants.js +8 -0
  45. package/dist/credentials/credential-status.js +1 -1
  46. package/dist/credentials/credentials.d.ts +3 -3
  47. package/dist/credentials/credentials.js +26 -12
  48. package/dist/credentials/identity.d.ts +2 -2
  49. package/dist/credentials/identity.js +2 -2
  50. package/dist/credentials/install-key.d.ts +31 -0
  51. package/dist/credentials/install-key.js +58 -0
  52. package/dist/credentials/migration.d.ts +9 -7
  53. package/dist/credentials/migration.js +58 -18
  54. package/dist/credentials/secret-store.d.ts +12 -0
  55. package/dist/credentials/secret-store.js +18 -1
  56. package/dist/enforcement/enforcement.js +1 -1
  57. package/dist/events/enrich.d.ts +14 -0
  58. package/dist/events/enrich.js +1 -1
  59. package/dist/git/constants/git.constants.d.ts +2 -0
  60. package/dist/git/constants/git.constants.js +9 -0
  61. package/dist/git/repo-snapshot.js +8 -2
  62. package/dist/git/types/snapshot.types.d.ts +4 -0
  63. package/dist/pipeline/hook-pipeline.js +5 -2
  64. package/dist/providers/antigravity/antigravity.adapter.d.ts +14 -0
  65. package/dist/providers/antigravity/antigravity.adapter.js +86 -18
  66. package/dist/providers/antigravity/antigravity.provider.js +7 -4
  67. package/dist/providers/antigravity/constants/antigravity.constants.d.ts +10 -0
  68. package/dist/providers/antigravity/constants/antigravity.constants.js +10 -0
  69. package/dist/providers/antigravity/schemas/antigravity.schema.js +7 -13
  70. package/dist/providers/claude/claude.otel.d.ts +33 -1
  71. package/dist/providers/claude/claude.otel.js +81 -12
  72. package/dist/providers/claude/claude.provider.js +12 -6
  73. package/dist/providers/codex/codex.capture.d.ts +1 -1
  74. package/dist/providers/codex/codex.capture.js +3 -3
  75. package/dist/providers/codex/codex.otel.js +2 -2
  76. package/dist/providers/codex/codex.provider.js +2 -1
  77. package/dist/providers/gemini/gemini.capture.js +2 -2
  78. package/dist/providers/gemini/gemini.otel.js +2 -2
  79. package/dist/providers/gemini/gemini.provider.js +2 -1
  80. package/dist/providers/shared/terminal-capture.js +3 -3
  81. package/dist/providers/types/provider.types.d.ts +5 -5
  82. package/dist/replay/checkout-resolver.d.ts +41 -14
  83. package/dist/replay/checkout-resolver.js +134 -30
  84. package/dist/replay/replay-runner.d.ts +3 -1
  85. package/dist/replay/replay-runner.js +74 -22
  86. package/dist/replay/replay-scan.d.ts +2 -1
  87. package/dist/replay/replay-scan.js +14 -2
  88. package/dist/replay/throttle.d.ts +2 -1
  89. package/dist/replay/throttle.js +4 -1
  90. package/dist/replay/transcript-turns.js +29 -3
  91. package/dist/replay/turn-event.d.ts +4 -2
  92. package/dist/replay/turn-event.js +22 -11
  93. package/dist/replay/types/replay.types.d.ts +39 -3
  94. package/dist/replay/worktree-map.d.ts +42 -0
  95. package/dist/replay/worktree-map.js +134 -0
  96. package/dist/snapshot/snapshot-pipeline.js +15 -4
  97. package/dist/snapshot/types/snapshot.types.d.ts +2 -0
  98. package/dist/turns/antigravity-transcript.d.ts +40 -0
  99. package/dist/turns/antigravity-transcript.js +102 -0
  100. package/dist/turns/claude-transcript.d.ts +35 -1
  101. package/dist/turns/claude-transcript.js +185 -2
  102. package/dist/turns/codex-transcript.d.ts +22 -1
  103. package/dist/turns/codex-transcript.js +161 -2
  104. package/dist/turns/constants/turns.constants.d.ts +67 -0
  105. package/dist/turns/constants/turns.constants.js +67 -0
  106. package/dist/turns/gemini-transcript.d.ts +17 -1
  107. package/dist/turns/gemini-transcript.js +36 -2
  108. package/dist/turns/transcript.d.ts +31 -1
  109. package/dist/turns/transcript.js +74 -0
  110. package/dist/turns/turn-state.d.ts +51 -1
  111. package/dist/turns/turn-state.js +124 -10
  112. package/dist/turns/turn-tracker.js +156 -18
  113. package/dist/turns/types/transcript.types.d.ts +25 -0
  114. package/dist/turns/types/turn-provider.types.d.ts +18 -1
  115. package/dist/turns/types/turn-state.types.d.ts +10 -0
  116. package/docs/DATA_HANDLING.md +11 -6
  117. package/docs/ENTERPRISE_DEPLOYMENT.md +2 -2
  118. package/package.json +1 -1
@@ -40,11 +40,36 @@ export interface ReadTurnUsageRetry {
40
40
  * @param excludeMessageIds - Messages another turn has already claimed.
41
41
  */
42
42
  export type TranscriptReader = (transcriptPath: string, startedAt: string, retry: ReadTurnUsageRetry, untilIso: string, excludeMessageIds: ReadonlySet<string>) => Promise<TurnUsage | undefined>;
43
+ /**
44
+ * Reads the usage a turn's subagents recorded in their own transcripts.
45
+ *
46
+ * Each agent says which lines are the turn's: by the prompt id a subagent's
47
+ * lines name where it writes one (Claude Code), else by the turn's window.
48
+ *
49
+ * @param payload - The raw hook payload: a Stop names the parent transcript, a
50
+ * subagent's own stop also names that subagent.
51
+ * @param turn - The turn: its id when it has one, and its window.
52
+ * @param excludeMessageIds - Messages already claimed, by any turn or by the parent's own read.
53
+ */
54
+ export type SubagentUsageReader = (payload: unknown, turn: SubagentTurn, excludeMessageIds: ReadonlySet<string>) => Promise<TurnUsage | undefined>;
55
+ /** The turn a subagent reader reads for. */
56
+ export interface SubagentTurn {
57
+ readonly turnId?: string;
58
+ /** When the turn began; a file not written since holds none of it. */
59
+ readonly startedAt: string;
60
+ /** Upper bound of the turn's window. */
61
+ readonly untilIso?: string;
62
+ }
43
63
  /** One assistant entry's usage, keyed by message id during accumulation. */
44
64
  export interface TranscriptUsageEntry {
45
65
  readonly model?: string;
46
66
  readonly usage: Readonly<Record<string, unknown>>;
47
67
  }
68
+ /** A transcript's tail and the byte offset of its first kept line. */
69
+ export interface TailSnapshot {
70
+ readonly raw: string;
71
+ readonly start: number;
72
+ }
48
73
  /** A transcript tail and the turn window to filter its lines by, both bounds in epoch ms. */
49
74
  export interface WindowedTail {
50
75
  /** The tail text. */
@@ -1,6 +1,6 @@
1
1
  import type { BillingSource } from '../../billing/types/billing.types.js';
2
2
  import type { Env } from '../../core/types/core.types.js';
3
- import type { SessionTitles, TranscriptReader } from './transcript.types.js';
3
+ import type { SessionTitles, SubagentUsageReader, TranscriptReader } from './transcript.types.js';
4
4
  /**
5
5
  * What the turn tracker asks of the agent a hook came from.
6
6
  *
@@ -12,6 +12,23 @@ export interface TurnProvider extends BillingSource {
12
12
  readonly id: string;
13
13
  /** Provisional usage out of the transcript the hook payload points at. */
14
14
  readonly readTurnUsage?: TranscriptReader;
15
+ /**
16
+ * Where this agent's payload names its transcript, when not at the top-level
17
+ * `transcript_path` (Antigravity nests or camel-cases it, or names none).
18
+ */
19
+ readonly transcriptPath?: (rawPayload: unknown, env: Env) => string | undefined;
20
+ /**
21
+ * Provisional usage of the turn's subagents, out of their own transcripts
22
+ * (Claude Code). Claimed with the turn's own usage; a background subagent that
23
+ * finishes after the turn closed re-sends the turn with its usage added.
24
+ */
25
+ readonly readSubagentUsage?: SubagentUsageReader;
26
+ /**
27
+ * The turns a stopping subagent's own lines name, oldest first, when its stop
28
+ * payload does not name the turn that launched it (Claude Code). Without it,
29
+ * the stop's own turn id is the only one tried.
30
+ */
31
+ readonly readSubagentTurnIds?: (payload: unknown) => Promise<readonly string[]>;
15
32
  /**
16
33
  * The session's titles out of the agent's own local store (Codex, Cursor),
17
34
  * read only under `capture.sessionTitle`.
@@ -1,6 +1,8 @@
1
1
  import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
2
2
  import type { ContentEvidence } from '../../events/types/events.types.js';
3
3
  import type { Fingerprint } from '../../git/types/git.types.js';
4
+ import type { CaptureConfig } from '../../config/types/config.types.js';
5
+ import type { TurnSummaryEvent } from './turn-summary.types.js';
4
6
  /** A prompt the developer submitted: when, its length and SHA-256, and its text when `promptText` is on. */
5
7
  export interface PromptRecord {
6
8
  readonly kind: 'prompt';
@@ -182,3 +184,11 @@ export interface TurnStateEntry {
182
184
  readonly file: string;
183
185
  readonly record: TurnRecord;
184
186
  }
187
+ /** A turn's summary as it went out, with the checkout it was routed by (`TurnOutcome`). */
188
+ export interface SentTurn {
189
+ readonly summary: TurnSummaryEvent;
190
+ /** Where the turn's window was cut: the next prompt's start when it raced in, else the Stop. */
191
+ readonly untilIso?: string;
192
+ readonly workRoot?: string;
193
+ readonly capture?: CaptureConfig;
194
+ }
@@ -307,6 +307,9 @@ left. `agentwatch off` keeps the copy, because sessions already running still lo
307
307
  restart those sessions after an uninstall. A process whose entry is a coding agent
308
308
  (`claude`, `codex`, `gemini`, `cursor`, `cursor-agent`, `antigravity`, `agy`) captures
309
309
  nothing. `AGENTWATCH_CAPTURE=off` in a process's environment turns the shim off for it.
310
+ The machine-wide switch is `capture.runs` in the global config (`setup --capture-runs on|off`,
311
+ on by default). It is apart from `otel`: captured calls travel as events, not OTLP, so
312
+ `--otel none` leaves capture on. A repository file cannot set it.
310
313
 
311
314
  The entries live in Claude Code's `settings.json` `env` block, in
312
315
  `[shell_environment_policy.set]` of Codex's `config.toml`, and in `~/.gemini/.env`. For
@@ -709,9 +712,11 @@ their own session/account/resource identifiers independently.
709
712
  Global configuration is stored in `~/.agentwatch/config.json` (0600). The
710
713
  organization install key written by setup (from `--token`, `$AGENTWATCH_TOKEN`
711
714
  or the prompt) is exchanged once through `POST /v1/devices/enroll` for a device
712
- credential of this machine's own, and the config records `device: { id, store }`
713
- beside the key. The key stays in the file to enroll again when the device
714
- secret expires. The Claude hooks and header helper send the device's access
715
+ credential of this machine's own, and the config records `device: { id, store }`.
716
+ The key then leaves the file: it is kept in the same store as the device secret
717
+ (account `<id>.install-key`), only to enroll again when the secret expires, and
718
+ `uninstall` removes it. A config written by an earlier version loses the key on
719
+ the next setup. The Claude hooks and header helper send the device's access
715
720
  token and never the key once the device is recorded; Codex and Gemini get the
716
721
  same access token in their own config, rewritten by each hook as it rotates
717
722
  (docs/NATIVE_OTLP_TOKENS.md). The device reference is an id
@@ -735,7 +740,7 @@ revoked or secret expired) are permanent; anything else is retried after the
735
740
  cooldown. A refused refresh stops sends for that identity,
736
741
  queues every record, is said once on stderr and stays visible in `status` and
737
742
  `doctor` until the machine is enrolled again: by itself when the secret only
738
- expired (hourly backoff), and only by `setup --token <install key>` when the
743
+ expired (hourly backoff), and only by `setup` (with the stored key, or `--token <install key>`) when the
739
744
  device was revoked or is unknown, so a hook never undoes a revocation. `uninstall` (all agents)
740
745
  first revokes the device on the platform (`POST /v1/devices/revoke`, the
741
746
  secret in the body), then removes the device secret, the cached token and the
@@ -865,7 +870,7 @@ Enforcement is fail-open on unexpected errors, timeouts, invalid responses and
865
870
  unreachable services. A refused root base has no usable decision route; doctor
866
871
  reports that budget caps are not enforced, with a failure and a repair instruction.
867
872
  It does not send that root's bearer to machine enforcement as a fallback. A supported hook blocks only on an explicit backend block
868
- decision. Defaults are a 300 ms request timeout and 60-second local decision
873
+ decision. Defaults are a 500 ms request timeout and 60-second local decision
869
874
  cache. Antigravity has no verified blocking response. This is not a local signed
870
875
  enforcement policy or tamper-resistant control.
871
876
 
@@ -885,7 +890,7 @@ answered as it is today.
885
890
 
886
891
  **The gate makes a network request.** Before a turn starts, the pre-prompt hook
887
892
  reads a local decision cache and, on a miss, asks the platform — one bounded
888
- request, 300 ms ceiling, every failure allowing the turn. Stating the model adds
893
+ request, 500 ms ceiling, every failure allowing the turn. Stating the model adds
889
894
  one read of a small local file to that, and nothing else: no subprocess, no
890
895
  second request, and a file that cannot be read means no model is stated rather
891
896
  than a gate that waits. Two consequences are worth stating rather than leaving
@@ -43,8 +43,8 @@ sends nothing until its developer runs `agentwatch setup` and signs in.
43
43
 
44
44
  A legacy MDM rollout that sets `$AGENTWATCH_TOKEN` hands setup the install key as
45
45
  before; the edge exchanges it for a device credential during that setup run, or
46
- on the first later run that reaches the backend. The key stays in `config.json`
47
- (0600) beside the device, to enroll again when the device secret expires; Codex
46
+ on the first later run that reaches the backend. The key then leaves `config.json`
47
+ and is kept in the device secret's store, to enroll again when the secret expires; Codex
48
48
  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
49
49
  enrolling a new one. On Windows the exchange happens in setup only. Headless Linux has no keychain: the secret is a 0600 file and
50
50
  `agentwatch doctor` reports the credential check as a warning.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-watch-ai/edge",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Usage and cost telemetry for Claude Code, Codex, Cursor, Gemini CLI and Antigravity. No daemon, no proxy.",
5
5
  "license": "MIT",
6
6
  "type": "module",