@agent-watch-ai/edge 0.2.5 → 0.3.1
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 +512 -0
- package/README.md +217 -96
- package/SECURITY.md +69 -0
- package/dist/billing/session-billing.d.ts +19 -0
- package/dist/billing/session-billing.js +52 -0
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.js +20 -0
- package/dist/cli/constants/cli.constants.d.ts +50 -4
- package/dist/cli/constants/cli.constants.js +54 -5
- package/dist/cli/context.d.ts +33 -2
- package/dist/cli/context.js +84 -14
- package/dist/cli/doctor.js +309 -32
- package/dist/cli/hook-check.d.ts +23 -0
- package/dist/cli/hook-check.js +114 -0
- package/dist/cli/hook.js +118 -7
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/misc.d.ts +11 -0
- package/dist/cli/misc.js +80 -4
- package/dist/cli/npx-install.d.ts +37 -0
- package/dist/cli/npx-install.js +79 -0
- package/dist/cli/open-browser.d.ts +39 -0
- package/dist/cli/open-browser.js +62 -0
- package/dist/cli/setup.d.ts +17 -8
- package/dist/cli/setup.js +439 -98
- package/dist/cli/status.js +82 -13
- package/dist/cli/toggle.d.ts +9 -0
- package/dist/cli/toggle.js +113 -0
- package/dist/cli/types/cli.types.d.ts +37 -3
- package/dist/cli/ui.d.ts +7 -0
- package/dist/cli/ui.js +10 -1
- package/dist/cli/uninstall.js +39 -2
- package/dist/cli/update.d.ts +17 -0
- package/dist/cli/update.js +76 -0
- package/dist/cli.js +100 -13
- package/dist/config/config-store.d.ts +57 -0
- package/dist/config/config-store.js +250 -12
- package/dist/config/config.d.ts +53 -6
- package/dist/config/config.js +66 -6
- package/dist/config/constants/config.constants.d.ts +113 -6
- package/dist/config/constants/config.constants.js +126 -8
- package/dist/config/destination.d.ts +24 -0
- package/dist/config/destination.js +33 -0
- package/dist/config/index.d.ts +7 -4
- package/dist/config/index.js +5 -3
- package/dist/config/repo-config.d.ts +11 -7
- package/dist/config/repo-config.js +64 -15
- package/dist/config/root-config.d.ts +72 -0
- package/dist/config/root-config.js +170 -0
- package/dist/config/schemas/config.schema.d.ts +721 -84
- package/dist/config/schemas/config.schema.js +388 -15
- package/dist/config/types/config.types.d.ts +15 -1
- package/dist/config/types/destination.types.d.ts +8 -0
- package/dist/core/async.d.ts +36 -0
- package/dist/core/async.js +68 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/object.d.ts +5 -0
- package/dist/core/object.js +9 -4
- package/dist/core/pipe.d.ts +0 -13
- package/dist/core/pipe.js +1 -9
- package/dist/core/types/core.types.d.ts +9 -0
- package/dist/core/types/core.types.js +0 -3
- package/dist/core/which.d.ts +14 -0
- package/dist/core/which.js +43 -3
- package/dist/credentials/budget.d.ts +9 -0
- package/dist/credentials/budget.js +16 -0
- package/dist/credentials/command-runner.d.ts +16 -0
- package/dist/credentials/command-runner.js +37 -0
- package/dist/credentials/constants/credentials.constants.d.ts +111 -0
- package/dist/credentials/constants/credentials.constants.js +112 -0
- package/dist/credentials/credential-status.d.ts +14 -0
- package/dist/credentials/credential-status.js +34 -0
- package/dist/credentials/credentials.d.ts +72 -0
- package/dist/credentials/credentials.js +253 -0
- package/dist/credentials/device-api.d.ts +64 -0
- package/dist/credentials/device-api.js +150 -0
- package/dist/credentials/device-state.d.ts +31 -0
- package/dist/credentials/device-state.js +51 -0
- package/dist/credentials/identity.d.ts +62 -0
- package/dist/credentials/identity.js +90 -0
- package/dist/credentials/index.d.ts +7 -0
- package/dist/credentials/index.js +5 -0
- package/dist/credentials/migration.d.ts +46 -0
- package/dist/credentials/migration.js +164 -0
- package/dist/credentials/schemas/device-api.schema.d.ts +77 -0
- package/dist/credentials/schemas/device-api.schema.js +33 -0
- package/dist/credentials/schemas/device-state.schema.d.ts +51 -0
- package/dist/credentials/schemas/device-state.schema.js +20 -0
- package/dist/credentials/secret-store.d.ts +54 -0
- package/dist/credentials/secret-store.js +217 -0
- package/dist/credentials/sign-in.d.ts +18 -0
- package/dist/credentials/sign-in.js +86 -0
- package/dist/credentials/token-refresher.d.ts +39 -0
- package/dist/credentials/token-refresher.js +185 -0
- package/dist/credentials/types/credentials.types.d.ts +195 -0
- package/dist/credentials/types/credentials.types.js +1 -0
- package/dist/enforcement/constants/enforcement.constants.d.ts +47 -1
- package/dist/enforcement/constants/enforcement.constants.js +56 -0
- package/dist/enforcement/decision-cache.d.ts +20 -1
- package/dist/enforcement/decision-cache.js +65 -2
- package/dist/enforcement/decision-client.d.ts +9 -8
- package/dist/enforcement/decision-client.js +62 -16
- package/dist/enforcement/enforcement.d.ts +23 -2
- package/dist/enforcement/enforcement.js +103 -15
- package/dist/enforcement/index.d.ts +4 -3
- package/dist/enforcement/index.js +3 -2
- package/dist/enforcement/types/enforcement.types.d.ts +64 -0
- package/dist/enrollment/constants/enrollment.constants.d.ts +2 -6
- package/dist/enrollment/constants/enrollment.constants.js +2 -6
- package/dist/enrollment/enrollment.d.ts +16 -0
- package/dist/enrollment/enrollment.js +54 -0
- package/dist/enrollment/index.d.ts +3 -7
- package/dist/enrollment/index.js +1 -1
- package/dist/enrollment/types/enrollment.types.d.ts +9 -13
- package/dist/events/constants/enrich.constants.d.ts +15 -0
- package/dist/events/constants/enrich.constants.js +15 -0
- package/dist/events/constants/events.constants.d.ts +6 -2
- package/dist/events/constants/events.constants.js +5 -1
- package/dist/events/enrich.js +92 -10
- package/dist/events/event-id.d.ts +0 -8
- package/dist/events/event-id.js +0 -10
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/product-event.d.ts +9 -6
- package/dist/events/types/repo-snapshot.types.d.ts +7 -0
- package/dist/events/types/session-billing.types.d.ts +16 -0
- package/dist/events/types/session-billing.types.js +1 -0
- package/dist/feature/constants/feature.constants.d.ts +7 -0
- package/dist/feature/constants/feature.constants.js +7 -0
- package/dist/feature/index.d.ts +1 -1
- package/dist/feature/index.js +1 -1
- package/dist/feature/ticket-candidates.d.ts +14 -0
- package/dist/feature/ticket-candidates.js +26 -8
- package/dist/git/blob-hash.d.ts +21 -0
- package/dist/git/blob-hash.js +69 -0
- package/dist/git/checkout-root.d.ts +27 -0
- package/dist/git/checkout-root.js +75 -0
- package/dist/git/constants/git.constants.d.ts +160 -0
- package/dist/git/constants/git.constants.js +181 -0
- package/dist/git/fingerprint.d.ts +74 -0
- package/dist/git/fingerprint.js +219 -0
- package/dist/git/gate-checkout.d.ts +44 -0
- package/dist/git/gate-checkout.js +201 -0
- package/dist/git/git-context.d.ts +45 -0
- package/dist/git/git-context.js +61 -3
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +2 -1
- package/dist/git/manifest-repository.d.ts +13 -0
- package/dist/git/manifest-repository.js +92 -0
- package/dist/git/repo-snapshot.d.ts +29 -3
- package/dist/git/repo-snapshot.js +110 -7
- package/dist/git/repository-root.d.ts +39 -0
- package/dist/git/repository-root.js +131 -0
- package/dist/git/types/git.types.d.ts +55 -0
- package/dist/git/types/repository-root.types.d.ts +11 -0
- package/dist/git/types/repository-root.types.js +1 -0
- package/dist/git/types/snapshot.types.d.ts +9 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +7 -0
- package/dist/pipeline/constants/pipeline.constants.js +7 -0
- package/dist/pipeline/hook-pipeline.js +360 -32
- package/dist/pipeline/types/pipeline.types.d.ts +39 -4
- package/dist/privacy/constants/privacy.constants.js +15 -1
- package/dist/privacy/index.d.ts +1 -0
- package/dist/privacy/index.js +1 -0
- package/dist/privacy/product-capture.d.ts +12 -0
- package/dist/privacy/product-capture.js +73 -0
- package/dist/privacy/sanitizer.d.ts +21 -3
- package/dist/privacy/sanitizer.js +52 -8
- package/dist/process/ancestors.d.ts +39 -0
- package/dist/process/ancestors.js +121 -0
- package/dist/process/constants/process.constants.d.ts +34 -0
- package/dist/process/constants/process.constants.js +34 -0
- package/dist/process/index.d.ts +7 -0
- package/dist/process/index.js +2 -0
- package/dist/process/types/process.types.d.ts +23 -0
- package/dist/process/types/process.types.js +1 -0
- package/dist/providers/antigravity/antigravity.adapter.d.ts +12 -1
- package/dist/providers/antigravity/antigravity.adapter.js +21 -3
- package/dist/providers/antigravity/antigravity.detect.d.ts +0 -9
- package/dist/providers/antigravity/antigravity.detect.js +1 -1
- package/dist/providers/antigravity/antigravity.provider.js +3 -2
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +2 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +2 -0
- package/dist/providers/claude/claude.adapter.d.ts +11 -1
- package/dist/providers/claude/claude.adapter.js +26 -5
- package/dist/providers/claude/claude.otel.d.ts +32 -18
- package/dist/providers/claude/claude.otel.js +81 -6
- package/dist/providers/claude/claude.provider.js +5 -2
- package/dist/providers/claude/constants/claude.constants.d.ts +2 -0
- package/dist/providers/claude/constants/claude.constants.js +2 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +4 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +8 -0
- package/dist/providers/codex/codex.adapter.d.ts +15 -1
- package/dist/providers/codex/codex.adapter.js +29 -5
- package/dist/providers/codex/codex.otel.d.ts +24 -2
- package/dist/providers/codex/codex.otel.js +147 -30
- package/dist/providers/codex/codex.provider.js +5 -2
- package/dist/providers/codex/constants/codex.constants.d.ts +2 -0
- package/dist/providers/codex/constants/codex.constants.js +16 -0
- 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 +0 -3
- package/dist/providers/constants/provider.constants.js +0 -3
- package/dist/providers/cursor/constants/cursor.constants.d.ts +7 -0
- package/dist/providers/cursor/constants/cursor.constants.js +7 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
- package/dist/providers/cursor/cursor.adapter.js +52 -3
- package/dist/providers/cursor/cursor.detect.d.ts +0 -7
- package/dist/providers/cursor/cursor.detect.js +1 -1
- package/dist/providers/cursor/cursor.provider.js +5 -2
- package/dist/providers/gemini/constants/gemini.constants.d.ts +9 -0
- package/dist/providers/gemini/constants/gemini.constants.js +9 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +3 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +3 -0
- package/dist/providers/gemini/gemini.adapter.d.ts +14 -1
- package/dist/providers/gemini/gemini.adapter.js +25 -5
- package/dist/providers/gemini/gemini.detect.d.ts +0 -7
- package/dist/providers/gemini/gemini.detect.js +1 -1
- package/dist/providers/gemini/gemini.otel.d.ts +19 -20
- package/dist/providers/gemini/gemini.otel.js +121 -17
- package/dist/providers/gemini/gemini.provider.js +2 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/loaders.d.ts +10 -0
- package/dist/providers/loaders.js +40 -0
- package/dist/providers/provider.d.ts +11 -0
- package/dist/providers/provider.js +1 -1
- package/dist/providers/registry.d.ts +11 -8
- package/dist/providers/registry.js +11 -15
- package/dist/providers/shared/constants/hook-refusal.constants.d.ts +7 -0
- package/dist/providers/shared/constants/hook-refusal.constants.js +7 -0
- package/dist/providers/shared/constants/shell-directories.constants.d.ts +30 -0
- package/dist/providers/shared/constants/shell-directories.constants.js +39 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +18 -2
- package/dist/providers/shared/constants/tooling.constants.js +19 -3
- package/dist/providers/shared/event-builder.d.ts +12 -14
- package/dist/providers/shared/event-builder.js +20 -14
- package/dist/providers/shared/exporter-allowlist.d.ts +20 -0
- package/dist/providers/shared/exporter-allowlist.js +49 -0
- package/dist/providers/shared/hook-config.d.ts +2 -21
- package/dist/providers/shared/hook-config.js +5 -4
- package/dist/providers/shared/hook-refusal.d.ts +12 -0
- package/dist/providers/shared/hook-refusal.js +17 -1
- package/dist/providers/shared/install-record.d.ts +12 -2
- package/dist/providers/shared/install-record.js +5 -2
- package/dist/providers/shared/shell-directories.d.ts +24 -0
- package/dist/providers/shared/shell-directories.js +90 -0
- package/dist/providers/shared/tooling.d.ts +12 -1
- package/dist/providers/shared/tooling.js +18 -0
- package/dist/providers/shared/types/adapter.types.d.ts +1 -2
- package/dist/providers/types/provider.types.d.ts +57 -1
- package/dist/snapshot/constants/snapshot.constants.d.ts +32 -0
- package/dist/snapshot/constants/snapshot.constants.js +33 -0
- package/dist/snapshot/snapshot-event.js +52 -11
- package/dist/snapshot/snapshot-pipeline.js +1 -1
- package/dist/snapshot/types/snapshot.types.d.ts +2 -0
- package/dist/storage/atomic-file.d.ts +7 -0
- package/dist/storage/atomic-file.js +1 -1
- package/dist/storage/constants/storage.constants.d.ts +17 -0
- package/dist/storage/constants/storage.constants.js +17 -0
- package/dist/storage/disabled.d.ts +13 -0
- package/dist/storage/disabled.js +24 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/paths.js +3 -2
- package/dist/storage/schemas/storage.schema.d.ts +72 -0
- package/dist/storage/schemas/storage.schema.js +6 -0
- package/dist/storage/sweep-marker.d.ts +19 -0
- package/dist/storage/sweep-marker.js +55 -0
- package/dist/storage/types/storage.types.d.ts +2 -0
- package/dist/storage/uninstalled.d.ts +58 -0
- package/dist/storage/uninstalled.js +107 -0
- package/dist/transport/auth-block.d.ts +66 -0
- package/dist/transport/auth-block.js +129 -0
- package/dist/transport/constants/transport.constants.d.ts +82 -3
- package/dist/transport/constants/transport.constants.js +83 -4
- package/dist/transport/cooldown.js +8 -1
- package/dist/transport/delivery.d.ts +14 -6
- package/dist/transport/delivery.js +80 -55
- package/dist/transport/http-transport.d.ts +1 -0
- package/dist/transport/http-transport.js +52 -10
- package/dist/transport/index.d.ts +6 -3
- package/dist/transport/index.js +3 -0
- package/dist/transport/queue-partition.d.ts +91 -0
- package/dist/transport/queue-partition.js +143 -0
- package/dist/transport/queue.d.ts +99 -20
- package/dist/transport/queue.js +210 -69
- package/dist/transport/response-body.d.ts +25 -0
- package/dist/transport/response-body.js +64 -0
- package/dist/transport/send.d.ts +11 -0
- package/dist/transport/send.js +17 -0
- package/dist/transport/types/delivery-flow.types.d.ts +19 -0
- package/dist/transport/types/delivery-flow.types.js +1 -0
- package/dist/transport/types/transport.types.d.ts +45 -0
- package/dist/turns/claude-transcript.d.ts +19 -1
- package/dist/turns/claude-transcript.js +46 -1
- package/dist/turns/codex-originator.d.ts +11 -0
- package/dist/turns/codex-originator.js +31 -0
- package/dist/turns/codex-transcript.d.ts +30 -0
- package/dist/turns/codex-transcript.js +88 -0
- package/dist/turns/constants/turns.constants.d.ts +141 -5
- package/dist/turns/constants/turns.constants.js +155 -5
- package/dist/turns/file-identity.d.ts +27 -0
- package/dist/turns/file-identity.js +48 -0
- package/dist/turns/gemini-transcript.d.ts +30 -0
- package/dist/turns/gemini-transcript.js +96 -0
- package/dist/turns/index.d.ts +3 -3
- package/dist/turns/index.js +1 -1
- package/dist/turns/inherited-checkout.d.ts +54 -0
- package/dist/turns/inherited-checkout.js +155 -0
- package/dist/turns/native-session-titles.d.ts +26 -0
- package/dist/turns/native-session-titles.js +102 -0
- package/dist/turns/transcript.d.ts +3 -2
- package/dist/turns/transcript.js +5 -1
- package/dist/turns/turn-state.d.ts +224 -3
- package/dist/turns/turn-state.js +456 -21
- package/dist/turns/turn-summary.d.ts +1 -14
- package/dist/turns/turn-summary.js +87 -51
- package/dist/turns/turn-tracker.d.ts +21 -2
- package/dist/turns/turn-tracker.js +379 -56
- package/dist/turns/types/transcript.types.d.ts +5 -0
- package/dist/turns/types/turn-state.types.d.ts +116 -5
- package/dist/turns/types/turn-summary.types.d.ts +64 -14
- package/dist/turns/types/turn-tracker.types.d.ts +27 -1
- package/dist/turns/work-checkout.d.ts +65 -0
- package/dist/turns/work-checkout.js +666 -0
- package/dist/untraced/constants/untraced.constants.d.ts +31 -0
- package/dist/untraced/constants/untraced.constants.js +63 -0
- package/dist/untraced/untraced.d.ts +35 -0
- package/dist/untraced/untraced.js +105 -0
- package/dist/update/constants/update.constants.d.ts +18 -0
- package/dist/update/constants/update.constants.js +20 -0
- package/dist/update/update-check.d.ts +52 -0
- package/dist/update/update-check.js +113 -0
- package/docs/AUDIT_PROMPT.md +129 -0
- package/docs/DATA_HANDLING.md +648 -0
- package/docs/ENTERPRISE_DEPLOYMENT.md +179 -0
- package/docs/PERFORMANCE.md +81 -0
- package/package.json +14 -4
- package/dist/enrollment/enrollment-provider.d.ts +0 -5
- package/dist/enrollment/manual-enrollment.d.ts +0 -32
- package/dist/enrollment/manual-enrollment.js +0 -72
- package/example/README.md +0 -43
- package/example/server.mjs +0 -240
- /package/dist/{enrollment/enrollment-provider.js → config/types/destination.types.js} +0 -0
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
|
|
1
2
|
import type { ContentEvidence } from '../../events/types/events.types.js';
|
|
2
|
-
|
|
3
|
+
import type { Fingerprint } from '../../git/types/git.types.js';
|
|
4
|
+
/** A prompt the developer submitted: when, its length and SHA-256, and its text when `promptText` is on. */
|
|
3
5
|
export interface PromptRecord {
|
|
4
6
|
readonly kind: 'prompt';
|
|
5
7
|
readonly at: string;
|
|
6
8
|
readonly turnId?: string;
|
|
7
|
-
readonly text?: string;
|
|
8
9
|
readonly evidence?: ContentEvidence;
|
|
10
|
+
/** Scrubbed and bounded; present only when `capture.promptText` was on at the prompt hook. */
|
|
11
|
+
readonly text?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Why this prompt ran without an enforcement decision, when it did.
|
|
14
|
+
*
|
|
15
|
+
* On the prompt record because the check and the summary happen in different
|
|
16
|
+
* hook processes, and this record is the file the prompt hook writes anyway —
|
|
17
|
+
* so reporting a fail-open costs no write of its own, and it belongs to exactly
|
|
18
|
+
* the turn it happened on.
|
|
19
|
+
*/
|
|
20
|
+
readonly failOpenReason?: FailOpenReason;
|
|
9
21
|
}
|
|
10
22
|
/** One tool call the agent completed. */
|
|
11
23
|
export interface ToolRecord {
|
|
@@ -14,22 +26,121 @@ export interface ToolRecord {
|
|
|
14
26
|
readonly turnId?: string;
|
|
15
27
|
readonly tool?: string;
|
|
16
28
|
readonly filePath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The absolute root of the checkout `filePath` is relative to, wherever it
|
|
31
|
+
* lies; absent for a file in no checkout, whose path is a bare basename.
|
|
32
|
+
*
|
|
33
|
+
* Local turn state only, never on the wire: it exists so the closing turn can
|
|
34
|
+
* decide which checkout the turn worked in. Absolute because the cwd each
|
|
35
|
+
* hook reports moves with a lasting `cd`, so a path relative to the tool
|
|
36
|
+
* hook's cwd means nothing to the Stop hook's.
|
|
37
|
+
*/
|
|
38
|
+
readonly repositoryRoot?: string;
|
|
17
39
|
/**
|
|
18
40
|
* Reads and edits are different product signals: a file the agent merely
|
|
19
41
|
* read must not appear in the summary's files_touched (modified) list.
|
|
20
42
|
*/
|
|
21
43
|
readonly access?: 'read' | 'edit';
|
|
44
|
+
/** A file outside every checkout, home-relative; under `capture.files`. */
|
|
45
|
+
readonly externalPath?: string;
|
|
46
|
+
/** The shell command or connector call, bounded; under `capture.toolInput`. */
|
|
47
|
+
readonly input?: ToolInputSummary;
|
|
48
|
+
}
|
|
49
|
+
/** What went into one shell or connector (MCP) call, as the turn summary sends it. */
|
|
50
|
+
export interface ToolInputSummary {
|
|
51
|
+
readonly tool: string;
|
|
52
|
+
/** Shell command text. */
|
|
53
|
+
readonly command?: string;
|
|
54
|
+
/** Connector server: its name, or for Cursor its url or launch command. */
|
|
55
|
+
readonly server?: string;
|
|
56
|
+
/** Connector tool name. */
|
|
57
|
+
readonly name?: string;
|
|
58
|
+
/** Connector arguments as JSON text, cut at the bound. */
|
|
59
|
+
readonly arguments?: string;
|
|
22
60
|
}
|
|
23
|
-
/**
|
|
61
|
+
/** How a turn came to name a checkout. */
|
|
62
|
+
export type CheckoutVia = 'cwd' | 'file' | 'shell';
|
|
63
|
+
/**
|
|
64
|
+
* A checkout a turn named, from one tool hook. Local turn state only, never sent.
|
|
65
|
+
*
|
|
66
|
+
* The first record of a root in a turn carries its `seq` (order of first
|
|
67
|
+
* sight) and its `baseline`; later ones are votes. A root's record from a shell
|
|
68
|
+
* call is a vote for it; the call's own cwd votes only when the call named no
|
|
69
|
+
* checkout (`named: false`), because where an agent sits is weaker evidence
|
|
70
|
+
* than where it says it is looking.
|
|
71
|
+
*/
|
|
72
|
+
export interface CheckoutRecord {
|
|
73
|
+
readonly kind: 'checkout';
|
|
74
|
+
readonly at: string;
|
|
75
|
+
readonly turnId?: string;
|
|
76
|
+
/** Canonical absolute root. */
|
|
77
|
+
readonly root: string;
|
|
78
|
+
readonly via: CheckoutVia;
|
|
79
|
+
/** The call named a checkout in its shell command. */
|
|
80
|
+
readonly named: boolean;
|
|
81
|
+
/** Order of first sight in the turn; only on a root's first record. */
|
|
82
|
+
readonly seq?: number;
|
|
83
|
+
/** The checkout when the turn first named it; absent when git could not say. */
|
|
84
|
+
readonly baseline?: Fingerprint;
|
|
85
|
+
}
|
|
86
|
+
/** A response delivered outside the Stop event (Cursor's afterAgentResponse); evidence only. */
|
|
24
87
|
export interface ResponseRecord {
|
|
25
88
|
readonly kind: 'response';
|
|
26
89
|
readonly at: string;
|
|
27
90
|
readonly turnId?: string;
|
|
28
|
-
readonly text?: string;
|
|
29
91
|
readonly evidence?: ContentEvidence;
|
|
30
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* What model a session is on, as the agent named it.
|
|
95
|
+
*
|
|
96
|
+
* Not a `TurnRecord`: it belongs to the session rather than to a turn, is never
|
|
97
|
+
* collected into a summary, and outlives every record until the session ends.
|
|
98
|
+
*/
|
|
99
|
+
export interface SessionModelRecord {
|
|
100
|
+
readonly model: string;
|
|
101
|
+
}
|
|
31
102
|
/** Anything the accumulator persists between hook invocations. */
|
|
32
|
-
export type TurnRecord = PromptRecord | ToolRecord | ResponseRecord;
|
|
103
|
+
export type TurnRecord = PromptRecord | ToolRecord | ResponseRecord | CheckoutRecord;
|
|
104
|
+
/** The session's last changed checkout, as `work-checkout.json` holds it. Local only. */
|
|
105
|
+
export interface WorkCheckoutMemo {
|
|
106
|
+
readonly root: string;
|
|
107
|
+
readonly repository: string;
|
|
108
|
+
readonly at: string;
|
|
109
|
+
/** The branch the session changed there; another session sharing the checkout reads it (SPEC §3a). */
|
|
110
|
+
readonly branch?: string;
|
|
111
|
+
/** The files the session's changing turns reported there on that branch, capped. */
|
|
112
|
+
readonly files?: readonly string[];
|
|
113
|
+
}
|
|
114
|
+
/** What another active session on the machine has changed, for a turn sharing its checkout. Local only. */
|
|
115
|
+
export interface SessionActivity {
|
|
116
|
+
readonly memo?: WorkCheckoutMemo;
|
|
117
|
+
/** Its open turns' edit-tool files: repository-relative, with the absolute root they are relative to; `current` when of its newest turn. */
|
|
118
|
+
readonly edits: readonly {
|
|
119
|
+
readonly root: string;
|
|
120
|
+
readonly filePath: string;
|
|
121
|
+
readonly current: boolean;
|
|
122
|
+
}[];
|
|
123
|
+
/** The branch each checkout its newest open turn named was on when that turn first named it. */
|
|
124
|
+
readonly baselines: readonly {
|
|
125
|
+
readonly root: string;
|
|
126
|
+
readonly branch: string;
|
|
127
|
+
}[];
|
|
128
|
+
}
|
|
129
|
+
/** The agent process a session runs in, as `agent-process.json` holds it. Local only. */
|
|
130
|
+
export interface AgentProcessRecord {
|
|
131
|
+
readonly pid: number;
|
|
132
|
+
/** `ps` start time, so a reused pid is not mistaken for the session's agent. */
|
|
133
|
+
readonly started?: string;
|
|
134
|
+
}
|
|
135
|
+
/** What a session inherited from the process that started it, as `inherited-checkout.json` holds it. Local only. */
|
|
136
|
+
export interface InheritedCheckoutMemo {
|
|
137
|
+
/** The live parent agent session found among the ancestors. */
|
|
138
|
+
readonly parent?: string;
|
|
139
|
+
/** The nearest ancestor's checkout, for when the parent has none (yet). */
|
|
140
|
+
readonly root?: string;
|
|
141
|
+
/** How many walks the deadline cut or that failed, set only while the session may walk again. */
|
|
142
|
+
readonly cuts?: number;
|
|
143
|
+
}
|
|
33
144
|
/** A record together with the file it was read from, so it can be consumed. */
|
|
34
145
|
export interface TurnStateEntry {
|
|
35
146
|
readonly file: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
|
|
1
2
|
import type { AgentWatchEvent, ContentEvidence, EventGit, FeatureCandidate, UsageBillingMode } from '../../events/types/events.types.js';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
3
|
+
import type { ContentHash } from '../../git/types/git.types.js';
|
|
4
|
+
import type { PromptRecord, ToolInputSummary, ToolRecord } from './turn-state.types.js';
|
|
5
|
+
import type { SessionTitles, TurnUsage } from './transcript.types.js';
|
|
4
6
|
/**
|
|
5
7
|
* Usage attributed to one agent inside a turn — the main agent, or one of the
|
|
6
8
|
* child agents it spawned — derived from the same call ledger as the totals.
|
|
@@ -26,10 +28,21 @@ export interface AgentUsageSummary {
|
|
|
26
28
|
* batches may still arrive. `complete` — the backend has decided none can.
|
|
27
29
|
*/
|
|
28
30
|
export type TurnUsageStatus = 'pending' | 'provisional' | 'complete' | 'partial';
|
|
31
|
+
/**
|
|
32
|
+
* How a turn's checkout was chosen: it `changed` there; it changed nothing and
|
|
33
|
+
* `carried` the session's last changed checkout; it only `referenced` one; or it
|
|
34
|
+
* reports the folder it ended in (`cwd`), as before this existed. A session
|
|
35
|
+
* started outside any checkout reports the one of the process that started it
|
|
36
|
+
* (`inherited`).
|
|
37
|
+
*/
|
|
38
|
+
export type WorkEvidence = 'changed' | 'carried' | 'referenced' | 'cwd' | 'inherited';
|
|
29
39
|
/**
|
|
30
40
|
* One prompt→response turn, flattened for direct backend consumption: who
|
|
31
|
-
* (developer), where (repo/branch/commit/ticket), what (prompt
|
|
32
|
-
* tools, files) and how much it cost.
|
|
41
|
+
* (developer), where (repo/branch/commit/ticket), what (prompt and response
|
|
42
|
+
* evidence, tools, files) and how much it cost.
|
|
43
|
+
*
|
|
44
|
+
* Prompt text and tool inputs ride along only under their opt-in content flags;
|
|
45
|
+
* there is no response text field: the agent's replies are never collected.
|
|
33
46
|
*
|
|
34
47
|
* The only product record the hook path emits; the backend finalizes its usage
|
|
35
48
|
* from the atomic llm.call rows.
|
|
@@ -40,19 +53,41 @@ export interface TurnSummaryEvent extends AgentWatchEvent<'turn.summary'> {
|
|
|
40
53
|
readonly session_id?: string;
|
|
41
54
|
readonly turn_id?: string;
|
|
42
55
|
readonly developer_id?: string;
|
|
56
|
+
/** What to call this developer; the platform keeps its own if this is absent. */
|
|
57
|
+
readonly developer_name?: string;
|
|
43
58
|
readonly repository?: string;
|
|
44
59
|
readonly branch?: string;
|
|
45
60
|
readonly commit?: string;
|
|
46
61
|
readonly jira_ids?: readonly string[];
|
|
47
|
-
/**
|
|
62
|
+
/** Ticket keys the session's opening prompt named, in order; the same on every turn of the session. Under `capture.git`. */
|
|
63
|
+
readonly prompt_jira_ids?: readonly string[];
|
|
64
|
+
/** The files this turn changed in its checkout: its edits, its commits' files, its new dirt. */
|
|
48
65
|
readonly files_changed?: readonly string[];
|
|
66
|
+
/** How the repository and branch above were chosen; absent when the turn names none. */
|
|
67
|
+
readonly work_evidence?: WorkEvidence;
|
|
68
|
+
/** The session id of the agent that started this one: declared by its launcher, or the live parent an `inherited` checkout came from. */
|
|
69
|
+
readonly parent_session_id?: string;
|
|
70
|
+
/** One-way content ids of files the turn's tools named, in a folder with no git; under `capture.files`. */
|
|
71
|
+
readonly content_hashes?: readonly ContentHash[];
|
|
72
|
+
/** The repository address the nearest project manifest names, cleaned like a git remote; under `capture.files`. */
|
|
73
|
+
readonly manifest_repository?: string;
|
|
49
74
|
/** Files edited by the agent's tools during this turn (repo-relative). */
|
|
50
75
|
readonly files_touched?: readonly string[];
|
|
51
76
|
/** Files the agent's tools only read during this turn (repo-relative). */
|
|
52
77
|
readonly files_read?: readonly string[];
|
|
53
|
-
|
|
78
|
+
/** Files outside every checkout the turn's tools edited, home-relative (`~/Documents/a.xlsx`). */
|
|
79
|
+
readonly external_files_touched?: readonly string[];
|
|
80
|
+
/** Files outside every checkout the turn's tools only read, home-relative. */
|
|
81
|
+
readonly external_files_read?: readonly string[];
|
|
54
82
|
readonly prompt_evidence?: ContentEvidence;
|
|
55
|
-
|
|
83
|
+
/** The turn's first prompt, harness blocks removed, scrubbed, bounded; under `capture.promptText`. */
|
|
84
|
+
readonly prompt_text?: string;
|
|
85
|
+
/** The session's latest name, scrubbed then cut to 200; under `capture.sessionTitle`; when the provider exposes one. */
|
|
86
|
+
readonly session_name?: string;
|
|
87
|
+
/** The session's latest generated/display title, scrubbed then cut to 200; under `capture.sessionTitle`; when exposed. Can paraphrase the first prompt. */
|
|
88
|
+
readonly session_title?: string;
|
|
89
|
+
/** The turn's shell commands and connector calls, bounded; under `capture.toolInput`. */
|
|
90
|
+
readonly tool_inputs?: readonly ToolInputSummary[];
|
|
56
91
|
readonly response_evidence?: ContentEvidence;
|
|
57
92
|
readonly tool_calls: number;
|
|
58
93
|
readonly tools_used: Readonly<Record<string, number>>;
|
|
@@ -72,14 +107,16 @@ export interface TurnSummaryEvent extends AgentWatchEvent<'turn.summary'> {
|
|
|
72
107
|
readonly agent_usage?: readonly AgentUsageSummary[];
|
|
73
108
|
/** Hook summaries start pending/provisional; only backend aggregation is complete. */
|
|
74
109
|
readonly usage_status: TurnUsageStatus;
|
|
110
|
+
/**
|
|
111
|
+
* Present only when the turn ran because no enforcement decision arrived, and
|
|
112
|
+
* then only as a category. Absent — never null — when the turn had a decision
|
|
113
|
+
* or nothing was asked. Top-level, beside `usage_status`: the platform reads it
|
|
114
|
+
* nowhere else.
|
|
115
|
+
*/
|
|
116
|
+
readonly enforcement_fail_open_reason?: FailOpenReason;
|
|
75
117
|
readonly started_at?: string;
|
|
76
118
|
readonly ended_at: string;
|
|
77
119
|
}
|
|
78
|
-
/** The response the user actually saw, however the provider delivered it. */
|
|
79
|
-
export interface TurnResponse {
|
|
80
|
-
readonly text?: string;
|
|
81
|
-
readonly evidence?: ContentEvidence;
|
|
82
|
-
}
|
|
83
120
|
export interface BuildTurnSummaryInput {
|
|
84
121
|
/** Internal provider id ('claude' | 'codex' | ...); mapped to the public label. */
|
|
85
122
|
readonly provider: string;
|
|
@@ -87,20 +124,33 @@ export interface BuildTurnSummaryInput {
|
|
|
87
124
|
readonly sessionId?: string;
|
|
88
125
|
readonly turnId?: string;
|
|
89
126
|
readonly developerId?: string;
|
|
127
|
+
readonly developerName?: string;
|
|
90
128
|
readonly installationId?: string;
|
|
91
129
|
readonly git?: EventGit;
|
|
92
130
|
readonly featureCandidates?: readonly FeatureCandidate[];
|
|
131
|
+
/** The session's opening prompt keys, as the tracker remembered them. */
|
|
132
|
+
readonly promptJiraIds?: readonly string[];
|
|
133
|
+
readonly workEvidence?: WorkEvidence;
|
|
134
|
+
readonly parentSessionId?: string;
|
|
135
|
+
readonly contentHashes?: readonly ContentHash[];
|
|
136
|
+
readonly manifestRepository?: string;
|
|
93
137
|
readonly prompts: readonly PromptRecord[];
|
|
138
|
+
/** The session's latest native name and generated/display title as the agent holds them, unscrubbed. */
|
|
139
|
+
readonly sessionTitles?: SessionTitles;
|
|
94
140
|
readonly tools: readonly ToolRecord[];
|
|
95
|
-
|
|
141
|
+
/** Evidence of the response the user actually saw, however the provider delivered it. */
|
|
142
|
+
readonly response?: ContentEvidence;
|
|
96
143
|
readonly usage?: TurnUsage;
|
|
97
144
|
readonly model?: string;
|
|
98
145
|
readonly billingMode?: UsageBillingMode;
|
|
99
146
|
readonly endedAt: string;
|
|
100
147
|
}
|
|
101
|
-
/** Files the turn's tools read versus modified. */
|
|
148
|
+
/** Files the turn's tools read versus modified, inside and outside a checkout. */
|
|
102
149
|
export interface TouchedFiles {
|
|
103
150
|
readonly toolsUsed: Readonly<Record<string, number>>;
|
|
104
151
|
readonly filesTouched: readonly string[];
|
|
105
152
|
readonly filesRead: readonly string[];
|
|
153
|
+
readonly externalTouched: readonly string[];
|
|
154
|
+
readonly externalRead: readonly string[];
|
|
155
|
+
readonly toolInputs: readonly ToolInputSummary[];
|
|
106
156
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { AgentWatchConfig } from '../../config/types/config.types.js';
|
|
1
|
+
import type { AgentWatchConfig, CaptureConfig, ConfigLoadResult } from '../../config/types/config.types.js';
|
|
2
|
+
import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
|
|
2
3
|
import type { Env } from '../../core/types/core.types.js';
|
|
3
4
|
import type { AgentWatchEvent } from '../../events/types/events.types.js';
|
|
5
|
+
import type { AgentWatchPaths } from '../../storage/types/storage.types.js';
|
|
6
|
+
import type { TurnSummaryEvent } from './turn-summary.types.js';
|
|
4
7
|
export interface TrackTurnOptions {
|
|
5
8
|
readonly agentId: string;
|
|
6
9
|
/** Raw provider payload; source of the transcript path. */
|
|
@@ -8,12 +11,35 @@ export interface TrackTurnOptions {
|
|
|
8
11
|
/** Enriched + sanitized canonical events produced from this payload. */
|
|
9
12
|
readonly events: readonly AgentWatchEvent[];
|
|
10
13
|
readonly config: AgentWatchConfig;
|
|
14
|
+
/**
|
|
15
|
+
* The machine-global config as loaded, roots intact. `config` is the start
|
|
16
|
+
* folder's effective config with its roots stripped, and a session started
|
|
17
|
+
* above its repositories needs both: which tenant each repository beneath the
|
|
18
|
+
* start folder belongs to, and that repository's own `.agentwatch.json`.
|
|
19
|
+
*/
|
|
20
|
+
readonly globalConfig: ConfigLoadResult;
|
|
21
|
+
readonly paths: AgentWatchPaths;
|
|
11
22
|
readonly turnsDir: string;
|
|
12
23
|
readonly locksDir: string;
|
|
13
24
|
readonly env: Env;
|
|
14
25
|
readonly cwd: string;
|
|
15
26
|
/** Preview a Stop without appending, consuming, claiming, or sweeping state. */
|
|
16
27
|
readonly readOnly?: boolean;
|
|
28
|
+
/** Why this payload's prompt was allowed without a decision, when it was. */
|
|
29
|
+
readonly failOpenReason?: FailOpenReason;
|
|
30
|
+
/** Real roots of the checkouts this payload's shell command named; roots only. */
|
|
31
|
+
readonly nominations?: readonly string[];
|
|
32
|
+
/** Real roots of the folders the agent has open (Cursor's workspace roots); weak candidates, like the cwd. */
|
|
33
|
+
readonly workspaceRoots?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
/** What one hook payload did to its turn. */
|
|
36
|
+
export interface TurnOutcome {
|
|
37
|
+
/** The summary, when this payload closed a turn. */
|
|
38
|
+
readonly summary?: TurnSummaryEvent;
|
|
39
|
+
/** Local root of the checkout that summary reported. Never sent. */
|
|
40
|
+
readonly workRoot?: string;
|
|
41
|
+
/** That checkout's own capture policy, when it is not the hook folder's. */
|
|
42
|
+
readonly capture?: CaptureConfig;
|
|
17
43
|
}
|
|
18
44
|
/** The window a closing turn may claim transcript usage from. */
|
|
19
45
|
export interface TurnWindow {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { CaptureConfig } from '../config/types/config.types.js';
|
|
2
|
+
import type { AgentWatchEvent, EventGit, FeatureCandidate } from '../events/types/events.types.js';
|
|
3
|
+
import type { TurnStateStore } from './turn-state.js';
|
|
4
|
+
import type { ToolRecord, TurnRecord } from './types/turn-state.types.js';
|
|
5
|
+
import type { WorkEvidence } from './types/turn-summary.types.js';
|
|
6
|
+
import type { TrackTurnOptions } from './types/turn-tracker.types.js';
|
|
7
|
+
/** What a closing turn reports about where it worked. */
|
|
8
|
+
export interface WorkCheckout {
|
|
9
|
+
/** The checkout's git fields as the summary sends them; absent when it names none. */
|
|
10
|
+
readonly git?: EventGit;
|
|
11
|
+
readonly featureCandidates?: readonly FeatureCandidate[];
|
|
12
|
+
/**
|
|
13
|
+
* The turn's tools with every repo-relative path dropped that lies outside the
|
|
14
|
+
* reported checkout. A file in no checkout keeps its home-relative `externalPath`.
|
|
15
|
+
*/
|
|
16
|
+
readonly tools: readonly ToolRecord[];
|
|
17
|
+
readonly evidence?: WorkEvidence;
|
|
18
|
+
/** The live parent agent session an `inherited` checkout came from. */
|
|
19
|
+
readonly parentSessionId?: string;
|
|
20
|
+
/** Local root of the reported checkout. Never sent. */
|
|
21
|
+
readonly root?: string;
|
|
22
|
+
/** The reported checkout's own capture policy, which delivery re-applies. */
|
|
23
|
+
readonly capture?: CaptureConfig;
|
|
24
|
+
/** Every file the turn changed there, uncapped, for the session's memo. Never sent. */
|
|
25
|
+
readonly changed?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Write down the checkouts this tool hook names, for its turn's close.
|
|
29
|
+
*
|
|
30
|
+
* On a tool-start hook: the checkout of the hook's cwd, of a file tool's path,
|
|
31
|
+
* and of every directory the shell command named (`options.nominations`, roots
|
|
32
|
+
* only). On a completion hook: the file's checkout and the shell command's
|
|
33
|
+
* checkouts, when the turn has not named them yet — a command can create the
|
|
34
|
+
* worktree it then works in. The first time a turn names a checkout, its baseline fingerprint is
|
|
35
|
+
* taken — the one git process a tool hook may add — and later sightings are
|
|
36
|
+
* votes, one small file each.
|
|
37
|
+
*
|
|
38
|
+
* Only checkouts this session may report are written: the same admission the
|
|
39
|
+
* close applies, asked early so no git process runs in another tenant's
|
|
40
|
+
* checkout.
|
|
41
|
+
*
|
|
42
|
+
* @param store - Per-session state store.
|
|
43
|
+
* @param sessionId - Provider session id.
|
|
44
|
+
* @param event - The tool event, already enriched.
|
|
45
|
+
* @param options - Tracking options.
|
|
46
|
+
*/
|
|
47
|
+
export declare function recordCheckouts(store: TurnStateStore, sessionId: string, event: AgentWatchEvent, options: TrackTurnOptions): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Which checkout a closing turn worked in, and what it changed there.
|
|
50
|
+
*
|
|
51
|
+
* Every admitted checkout the turn named is fingerprinted again, all at once,
|
|
52
|
+
* and compared with its baseline. The turn reports, in this order: the one it
|
|
53
|
+
* changed most (`changed`); else the session's last changed checkout
|
|
54
|
+
* (`carried`); else the one it named most (`referenced`); else the Stop folder's
|
|
55
|
+
* own repository, as before this existed (`cwd`). Ties go to the checkout named
|
|
56
|
+
* first. Every failure makes a candidate lose, never the summary.
|
|
57
|
+
*
|
|
58
|
+
* @param store - Per-session state store.
|
|
59
|
+
* @param sessionId - Provider session id.
|
|
60
|
+
* @param records - This turn's records.
|
|
61
|
+
* @param stopEvent - The closing event, enriched for the Stop folder.
|
|
62
|
+
* @param options - Tracking options.
|
|
63
|
+
* @returns The checkout to report and the tools with its paths only.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveWorkCheckout(store: TurnStateStore, sessionId: string, records: readonly TurnRecord[], stopEvent: AgentWatchEvent, options: TrackTurnOptions): Promise<WorkCheckout>;
|