@agent-watch-ai/edge 0.2.5
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 +251 -0
- package/LICENSE +21 -0
- package/README.md +168 -0
- package/dist/billing/billing-mode.d.ts +16 -0
- package/dist/billing/billing-mode.js +139 -0
- package/dist/billing/constants/billing.constants.d.ts +37 -0
- package/dist/billing/constants/billing.constants.js +38 -0
- package/dist/billing/index.d.ts +6 -0
- package/dist/billing/index.js +6 -0
- package/dist/cli/args.d.ts +29 -0
- package/dist/cli/args.js +61 -0
- package/dist/cli/constants/cli.constants.d.ts +60 -0
- package/dist/cli/constants/cli.constants.js +60 -0
- package/dist/cli/context.d.ts +51 -0
- package/dist/cli/context.js +108 -0
- package/dist/cli/doctor.d.ts +15 -0
- package/dist/cli/doctor.js +416 -0
- package/dist/cli/hook.d.ts +20 -0
- package/dist/cli/hook.js +166 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.js +8 -0
- package/dist/cli/misc.d.ts +31 -0
- package/dist/cli/misc.js +63 -0
- package/dist/cli/setup.d.ts +32 -0
- package/dist/cli/setup.js +298 -0
- package/dist/cli/status.d.ts +11 -0
- package/dist/cli/status.js +174 -0
- package/dist/cli/types/cli.types.d.ts +69 -0
- package/dist/cli/types/cli.types.js +1 -0
- package/dist/cli/ui.d.ts +41 -0
- package/dist/cli/ui.js +78 -0
- package/dist/cli/uninstall.d.ts +13 -0
- package/dist/cli/uninstall.js +83 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +124 -0
- package/dist/config/config-store.d.ts +29 -0
- package/dist/config/config-store.js +75 -0
- package/dist/config/config.d.ts +73 -0
- package/dist/config/config.js +115 -0
- package/dist/config/constants/config.constants.d.ts +62 -0
- package/dist/config/constants/config.constants.js +70 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.js +5 -0
- package/dist/config/repo-config.d.ts +37 -0
- package/dist/config/repo-config.js +178 -0
- package/dist/config/schemas/config.schema.d.ts +409 -0
- package/dist/config/schemas/config.schema.js +97 -0
- package/dist/config/types/config.types.d.ts +33 -0
- package/dist/config/types/config.types.js +1 -0
- package/dist/core/async.d.ts +20 -0
- package/dist/core/async.js +32 -0
- package/dist/core/constants/core.constants.d.ts +18 -0
- package/dist/core/constants/core.constants.js +18 -0
- package/dist/core/env.d.ts +12 -0
- package/dist/core/env.js +20 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +8 -0
- package/dist/core/logger.d.ts +27 -0
- package/dist/core/logger.js +82 -0
- package/dist/core/number.d.ts +33 -0
- package/dist/core/number.js +47 -0
- package/dist/core/object.d.ts +78 -0
- package/dist/core/object.js +127 -0
- package/dist/core/pipe.d.ts +55 -0
- package/dist/core/pipe.js +81 -0
- package/dist/core/types/core.types.d.ts +54 -0
- package/dist/core/types/core.types.js +4 -0
- package/dist/core/version.d.ts +19 -0
- package/dist/core/version.js +35 -0
- package/dist/core/which.d.ts +13 -0
- package/dist/core/which.js +57 -0
- package/dist/enforcement/constants/enforcement.constants.d.ts +23 -0
- package/dist/enforcement/constants/enforcement.constants.js +22 -0
- package/dist/enforcement/decision-cache.d.ts +57 -0
- package/dist/enforcement/decision-cache.js +138 -0
- package/dist/enforcement/decision-client.d.ts +14 -0
- package/dist/enforcement/decision-client.js +84 -0
- package/dist/enforcement/enforcement.d.ts +17 -0
- package/dist/enforcement/enforcement.js +90 -0
- package/dist/enforcement/index.d.ts +11 -0
- package/dist/enforcement/index.js +10 -0
- package/dist/enforcement/schemas/enforcement.schema.d.ts +30 -0
- package/dist/enforcement/schemas/enforcement.schema.js +36 -0
- package/dist/enforcement/types/enforcement.types.d.ts +59 -0
- package/dist/enforcement/types/enforcement.types.js +1 -0
- package/dist/enrollment/constants/enrollment.constants.d.ts +6 -0
- package/dist/enrollment/constants/enrollment.constants.js +6 -0
- package/dist/enrollment/enrollment-provider.d.ts +5 -0
- package/dist/enrollment/enrollment-provider.js +1 -0
- package/dist/enrollment/index.d.ts +7 -0
- package/dist/enrollment/index.js +1 -0
- package/dist/enrollment/manual-enrollment.d.ts +32 -0
- package/dist/enrollment/manual-enrollment.js +72 -0
- package/dist/enrollment/types/enrollment.types.d.ts +25 -0
- package/dist/enrollment/types/enrollment.types.js +1 -0
- package/dist/events/canonical-event.d.ts +10 -0
- package/dist/events/canonical-event.js +9 -0
- package/dist/events/constants/enrich.constants.d.ts +14 -0
- package/dist/events/constants/enrich.constants.js +15 -0
- package/dist/events/constants/events.constants.d.ts +35 -0
- package/dist/events/constants/events.constants.js +57 -0
- package/dist/events/enrich.d.ts +16 -0
- package/dist/events/enrich.js +226 -0
- package/dist/events/event-id.d.ts +32 -0
- package/dist/events/event-id.js +49 -0
- package/dist/events/index.d.ts +14 -0
- package/dist/events/index.js +5 -0
- package/dist/events/llm-call.d.ts +14 -0
- package/dist/events/llm-call.js +84 -0
- package/dist/events/product-event.d.ts +39 -0
- package/dist/events/product-event.js +19 -0
- package/dist/events/types/enrich.types.d.ts +25 -0
- package/dist/events/types/enrich.types.js +1 -0
- package/dist/events/types/events.types.d.ts +112 -0
- package/dist/events/types/events.types.js +1 -0
- package/dist/events/types/llm-call.types.d.ts +79 -0
- package/dist/events/types/llm-call.types.js +1 -0
- package/dist/events/types/repo-snapshot.types.d.ts +32 -0
- package/dist/events/types/repo-snapshot.types.js +1 -0
- package/dist/feature/constants/feature.constants.d.ts +10 -0
- package/dist/feature/constants/feature.constants.js +10 -0
- package/dist/feature/index.d.ts +6 -0
- package/dist/feature/index.js +6 -0
- package/dist/feature/ticket-candidates.d.ts +13 -0
- package/dist/feature/ticket-candidates.js +26 -0
- package/dist/git/constants/git.constants.d.ts +84 -0
- package/dist/git/constants/git.constants.js +113 -0
- package/dist/git/git-context.d.ts +52 -0
- package/dist/git/git-context.js +226 -0
- package/dist/git/index.d.ts +9 -0
- package/dist/git/index.js +3 -0
- package/dist/git/remote-sanitize.d.ts +26 -0
- package/dist/git/remote-sanitize.js +92 -0
- package/dist/git/repo-snapshot.d.ts +40 -0
- package/dist/git/repo-snapshot.js +95 -0
- package/dist/git/types/git.types.d.ts +36 -0
- package/dist/git/types/git.types.js +1 -0
- package/dist/git/types/snapshot.types.d.ts +25 -0
- package/dist/git/types/snapshot.types.js +1 -0
- package/dist/otlp/constants/otlp.constants.d.ts +84 -0
- package/dist/otlp/constants/otlp.constants.js +99 -0
- package/dist/otlp/http.d.ts +24 -0
- package/dist/otlp/http.js +37 -0
- package/dist/otlp/index.d.ts +9 -0
- package/dist/otlp/index.js +3 -0
- package/dist/otlp/normalize.d.ts +14 -0
- package/dist/otlp/normalize.js +404 -0
- package/dist/otlp/types/otlp.types.d.ts +69 -0
- package/dist/otlp/types/otlp.types.js +1 -0
- package/dist/pipeline/constants/pipeline.constants.d.ts +23 -0
- package/dist/pipeline/constants/pipeline.constants.js +22 -0
- package/dist/pipeline/hook-pipeline.d.ts +14 -0
- package/dist/pipeline/hook-pipeline.js +297 -0
- package/dist/pipeline/index.d.ts +6 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline/types/pipeline.types.d.ts +48 -0
- package/dist/pipeline/types/pipeline.types.js +1 -0
- package/dist/privacy/constants/privacy.constants.d.ts +23 -0
- package/dist/privacy/constants/privacy.constants.js +38 -0
- package/dist/privacy/index.d.ts +7 -0
- package/dist/privacy/index.js +2 -0
- package/dist/privacy/sanitizer.d.ts +20 -0
- package/dist/privacy/sanitizer.js +52 -0
- package/dist/privacy/types/privacy.types.d.ts +13 -0
- package/dist/privacy/types/privacy.types.js +1 -0
- package/dist/providers/antigravity/antigravity.adapter.d.ts +54 -0
- package/dist/providers/antigravity/antigravity.adapter.js +311 -0
- package/dist/providers/antigravity/antigravity.detect.d.ts +25 -0
- package/dist/providers/antigravity/antigravity.detect.js +64 -0
- package/dist/providers/antigravity/antigravity.hooks.d.ts +24 -0
- package/dist/providers/antigravity/antigravity.hooks.js +126 -0
- package/dist/providers/antigravity/antigravity.provider.d.ts +2 -0
- package/dist/providers/antigravity/antigravity.provider.js +22 -0
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +72 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +75 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.d.ts +521 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.js +64 -0
- package/dist/providers/antigravity/types/antigravity.types.d.ts +13 -0
- package/dist/providers/antigravity/types/antigravity.types.js +1 -0
- package/dist/providers/claude/claude.adapter.d.ts +15 -0
- package/dist/providers/claude/claude.adapter.js +141 -0
- package/dist/providers/claude/claude.detect.d.ts +20 -0
- package/dist/providers/claude/claude.detect.js +57 -0
- package/dist/providers/claude/claude.hooks.d.ts +23 -0
- package/dist/providers/claude/claude.hooks.js +94 -0
- package/dist/providers/claude/claude.otel.d.ts +95 -0
- package/dist/providers/claude/claude.otel.js +331 -0
- package/dist/providers/claude/claude.provider.d.ts +2 -0
- package/dist/providers/claude/claude.provider.js +26 -0
- package/dist/providers/claude/constants/claude.constants.d.ts +34 -0
- package/dist/providers/claude/constants/claude.constants.js +54 -0
- package/dist/providers/claude/constants/claude.otel.constants.d.ts +17 -0
- package/dist/providers/claude/constants/claude.otel.constants.js +17 -0
- package/dist/providers/claude/schemas/claude.schema.d.ts +72 -0
- package/dist/providers/claude/schemas/claude.schema.js +32 -0
- package/dist/providers/claude/types/claude.types.d.ts +3 -0
- package/dist/providers/claude/types/claude.types.js +1 -0
- package/dist/providers/codex/codex.adapter.d.ts +11 -0
- package/dist/providers/codex/codex.adapter.js +106 -0
- package/dist/providers/codex/codex.detect.d.ts +30 -0
- package/dist/providers/codex/codex.detect.js +58 -0
- package/dist/providers/codex/codex.hooks.d.ts +27 -0
- package/dist/providers/codex/codex.hooks.js +129 -0
- package/dist/providers/codex/codex.otel.d.ts +51 -0
- package/dist/providers/codex/codex.otel.js +325 -0
- package/dist/providers/codex/codex.provider.d.ts +2 -0
- package/dist/providers/codex/codex.provider.js +25 -0
- package/dist/providers/codex/constants/codex.constants.d.ts +41 -0
- package/dist/providers/codex/constants/codex.constants.js +62 -0
- package/dist/providers/codex/constants/codex.otel.constants.d.ts +22 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +22 -0
- package/dist/providers/codex/schemas/codex.schema.d.ts +70 -0
- package/dist/providers/codex/schemas/codex.schema.js +32 -0
- package/dist/providers/codex/types/codex.types.d.ts +3 -0
- package/dist/providers/codex/types/codex.types.js +1 -0
- package/dist/providers/constants/provider.constants.d.ts +33 -0
- package/dist/providers/constants/provider.constants.js +33 -0
- package/dist/providers/cursor/constants/cursor.constants.d.ts +58 -0
- package/dist/providers/cursor/constants/cursor.constants.js +95 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +11 -0
- package/dist/providers/cursor/cursor.adapter.js +331 -0
- package/dist/providers/cursor/cursor.detect.d.ts +23 -0
- package/dist/providers/cursor/cursor.detect.js +66 -0
- package/dist/providers/cursor/cursor.hooks.d.ts +25 -0
- package/dist/providers/cursor/cursor.hooks.js +95 -0
- package/dist/providers/cursor/cursor.provider.d.ts +2 -0
- package/dist/providers/cursor/cursor.provider.js +27 -0
- package/dist/providers/cursor/schemas/cursor.schema.d.ts +130 -0
- package/dist/providers/cursor/schemas/cursor.schema.js +62 -0
- package/dist/providers/cursor/types/cursor.types.d.ts +3 -0
- package/dist/providers/cursor/types/cursor.types.js +1 -0
- package/dist/providers/gemini/constants/gemini.constants.d.ts +36 -0
- package/dist/providers/gemini/constants/gemini.constants.js +58 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +34 -0
- package/dist/providers/gemini/constants/gemini.otel.constants.js +48 -0
- package/dist/providers/gemini/gemini.adapter.d.ts +15 -0
- package/dist/providers/gemini/gemini.adapter.js +146 -0
- package/dist/providers/gemini/gemini.detect.d.ts +23 -0
- package/dist/providers/gemini/gemini.detect.js +78 -0
- package/dist/providers/gemini/gemini.hooks.d.ts +22 -0
- package/dist/providers/gemini/gemini.hooks.js +93 -0
- package/dist/providers/gemini/gemini.otel.d.ts +62 -0
- package/dist/providers/gemini/gemini.otel.js +274 -0
- package/dist/providers/gemini/gemini.provider.d.ts +2 -0
- package/dist/providers/gemini/gemini.provider.js +22 -0
- package/dist/providers/gemini/schemas/gemini.schema.d.ts +81 -0
- package/dist/providers/gemini/schemas/gemini.schema.js +35 -0
- package/dist/providers/gemini/types/gemini.types.d.ts +3 -0
- package/dist/providers/gemini/types/gemini.types.js +1 -0
- package/dist/providers/index.d.ts +14 -0
- package/dist/providers/index.js +8 -0
- package/dist/providers/provider.d.ts +16 -0
- package/dist/providers/provider.js +149 -0
- package/dist/providers/registry.d.ts +12 -0
- package/dist/providers/registry.js +23 -0
- package/dist/providers/shared/constants/hook-refusal.constants.d.ts +6 -0
- package/dist/providers/shared/constants/hook-refusal.constants.js +6 -0
- package/dist/providers/shared/constants/tooling.constants.d.ts +25 -0
- package/dist/providers/shared/constants/tooling.constants.js +25 -0
- package/dist/providers/shared/event-builder.d.ts +85 -0
- package/dist/providers/shared/event-builder.js +166 -0
- package/dist/providers/shared/hook-config.d.ts +80 -0
- package/dist/providers/shared/hook-config.js +164 -0
- package/dist/providers/shared/hook-refusal.d.ts +16 -0
- package/dist/providers/shared/hook-refusal.js +33 -0
- package/dist/providers/shared/install-record.d.ts +75 -0
- package/dist/providers/shared/install-record.js +113 -0
- package/dist/providers/shared/tooling.d.ts +58 -0
- package/dist/providers/shared/tooling.js +103 -0
- package/dist/providers/shared/types/adapter.types.d.ts +54 -0
- package/dist/providers/shared/types/adapter.types.js +1 -0
- package/dist/providers/shared/types/hook-config.types.d.ts +32 -0
- package/dist/providers/shared/types/hook-config.types.js +1 -0
- package/dist/providers/types/provider.types.d.ts +98 -0
- package/dist/providers/types/provider.types.js +1 -0
- package/dist/snapshot/branch-selection.d.ts +37 -0
- package/dist/snapshot/branch-selection.js +69 -0
- package/dist/snapshot/budget.d.ts +41 -0
- package/dist/snapshot/budget.js +67 -0
- package/dist/snapshot/constants/snapshot-stages.constants.d.ts +11 -0
- package/dist/snapshot/constants/snapshot-stages.constants.js +11 -0
- package/dist/snapshot/constants/snapshot.constants.d.ts +56 -0
- package/dist/snapshot/constants/snapshot.constants.js +56 -0
- package/dist/snapshot/index.d.ts +16 -0
- package/dist/snapshot/index.js +6 -0
- package/dist/snapshot/snapshot-event.d.ts +17 -0
- package/dist/snapshot/snapshot-event.js +66 -0
- package/dist/snapshot/snapshot-pipeline.d.ts +14 -0
- package/dist/snapshot/snapshot-pipeline.js +163 -0
- package/dist/snapshot/snapshot-state.d.ts +55 -0
- package/dist/snapshot/snapshot-state.js +100 -0
- package/dist/snapshot/types/snapshot.types.d.ts +86 -0
- package/dist/snapshot/types/snapshot.types.js +1 -0
- package/dist/storage/atomic-file.d.ts +25 -0
- package/dist/storage/atomic-file.js +76 -0
- package/dist/storage/constants/storage.constants.d.ts +34 -0
- package/dist/storage/constants/storage.constants.js +35 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.js +5 -0
- package/dist/storage/install-state.d.ts +20 -0
- package/dist/storage/install-state.js +40 -0
- package/dist/storage/json-file.d.ts +13 -0
- package/dist/storage/json-file.js +31 -0
- package/dist/storage/lock.d.ts +15 -0
- package/dist/storage/lock.js +70 -0
- package/dist/storage/paths.d.ts +14 -0
- package/dist/storage/paths.js +42 -0
- package/dist/storage/schemas/storage.schema.d.ts +128 -0
- package/dist/storage/schemas/storage.schema.js +27 -0
- package/dist/storage/types/storage.types.d.ts +36 -0
- package/dist/storage/types/storage.types.js +1 -0
- package/dist/transport/constants/transport.constants.d.ts +47 -0
- package/dist/transport/constants/transport.constants.js +47 -0
- package/dist/transport/cooldown.d.ts +35 -0
- package/dist/transport/cooldown.js +62 -0
- package/dist/transport/delivery-stats.d.ts +65 -0
- package/dist/transport/delivery-stats.js +186 -0
- package/dist/transport/delivery.d.ts +26 -0
- package/dist/transport/delivery.js +80 -0
- package/dist/transport/headers.d.ts +12 -0
- package/dist/transport/headers.js +19 -0
- package/dist/transport/http-transport.d.ts +39 -0
- package/dist/transport/http-transport.js +106 -0
- package/dist/transport/index.d.ts +13 -0
- package/dist/transport/index.js +7 -0
- package/dist/transport/queue.d.ts +177 -0
- package/dist/transport/queue.js +474 -0
- package/dist/transport/schemas/queue.schema.d.ts +30 -0
- package/dist/transport/schemas/queue.schema.js +18 -0
- package/dist/transport/transport.d.ts +6 -0
- package/dist/transport/transport.js +1 -0
- package/dist/transport/types/transport.types.d.ts +102 -0
- package/dist/transport/types/transport.types.js +1 -0
- package/dist/turns/aggregate-usage.d.ts +20 -0
- package/dist/turns/aggregate-usage.js +269 -0
- package/dist/turns/claude-transcript.d.ts +18 -0
- package/dist/turns/claude-transcript.js +80 -0
- package/dist/turns/constants/turns.constants.d.ts +69 -0
- package/dist/turns/constants/turns.constants.js +86 -0
- package/dist/turns/cursor-transcript.d.ts +21 -0
- package/dist/turns/cursor-transcript.js +66 -0
- package/dist/turns/index.d.ts +17 -0
- package/dist/turns/index.js +7 -0
- package/dist/turns/transcript.d.ts +74 -0
- package/dist/turns/transcript.js +188 -0
- package/dist/turns/turn-state.d.ts +94 -0
- package/dist/turns/turn-state.js +234 -0
- package/dist/turns/turn-summary.d.ts +27 -0
- package/dist/turns/turn-summary.js +164 -0
- package/dist/turns/turn-tracker.d.ts +14 -0
- package/dist/turns/turn-tracker.js +521 -0
- package/dist/turns/types/aggregate-usage.types.d.ts +26 -0
- package/dist/turns/types/aggregate-usage.types.js +1 -0
- package/dist/turns/types/transcript.types.d.ts +41 -0
- package/dist/turns/types/transcript.types.js +1 -0
- package/dist/turns/types/turn-state.types.d.ts +37 -0
- package/dist/turns/types/turn-state.types.js +1 -0
- package/dist/turns/types/turn-summary.types.d.ts +106 -0
- package/dist/turns/types/turn-summary.types.js +1 -0
- package/dist/turns/types/turn-tracker.types.d.ts +27 -0
- package/dist/turns/types/turn-tracker.types.js +1 -0
- package/example/README.md +43 -0
- package/example/server.mjs +240 -0
- package/package.json +89 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Delivery defaults. Small on purpose: hooks run on the agent's critical path. */
|
|
2
|
+
export declare const DEFAULT_SEND_TIMEOUT_MS = 1500;
|
|
3
|
+
export declare const DEFAULT_DRAIN_BATCH_SIZE = 25;
|
|
4
|
+
export declare const DEFAULT_MAX_QUEUE_EVENTS = 2000;
|
|
5
|
+
export declare const DEFAULT_MAX_ATTEMPTS = 20;
|
|
6
|
+
export declare const DEFAULT_MAX_EVENT_AGE_DAYS = 7;
|
|
7
|
+
/**
|
|
8
|
+
* Pre-turn budget check defaults.
|
|
9
|
+
*
|
|
10
|
+
* The timeout is a hard ceiling on a request that sits between the developer
|
|
11
|
+
* pressing enter and their agent starting work, and the TTL mirrors the cache
|
|
12
|
+
* the platform keeps for the same decision.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_ENFORCEMENT_TIMEOUT_MS = 300;
|
|
15
|
+
export declare const DEFAULT_ENFORCEMENT_CACHE_TTL_MS = 60000;
|
|
16
|
+
/** Native OTLP signal names, in report order. */
|
|
17
|
+
export declare const OTEL_SIGNAL_NAMES: readonly ["logs", "traces", "metrics"];
|
|
18
|
+
/** O(1) validation of a `--otel` list entry. */
|
|
19
|
+
export declare const OTEL_SIGNAL_NAME_SET: ReadonlySet<string>;
|
|
20
|
+
/** Shorthands accepted by `--otel`. */
|
|
21
|
+
export declare const OTEL_ALL = "all";
|
|
22
|
+
export declare const OTEL_NONE = "none";
|
|
23
|
+
/** Backend routes derived from the configured base endpoint. */
|
|
24
|
+
export declare const EVENTS_PATH = "/v1/events";
|
|
25
|
+
export declare const OTLP_BASE_PATH = "/v1/otlp";
|
|
26
|
+
export declare const ENFORCEMENT_PATH = "/v1/enforcement/decision";
|
|
27
|
+
/** Repository-level overrides file, found by walking up from the working directory. */
|
|
28
|
+
export declare const REPO_CONFIG_NAME = ".agentwatch.json";
|
|
29
|
+
/**
|
|
30
|
+
* Keys a repo file may not set: it is committed and shared, so secrets and
|
|
31
|
+
* per-machine identity stay in the global ~/.agentwatch/config.json only.
|
|
32
|
+
* Delivery destinations are global-only too — a repo file that redirected them
|
|
33
|
+
* would exfiltrate the global bearer token along with the telemetry.
|
|
34
|
+
*/
|
|
35
|
+
export declare const GLOBAL_ONLY_KEYS: ReadonlySet<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Whole blocks a repo file may not touch.
|
|
38
|
+
*
|
|
39
|
+
* `delivery` governs the machine-global offline queue (size bound, retry
|
|
40
|
+
* budget, age limit): a committed repo file could truncate every other repo's
|
|
41
|
+
* backlog through it. `otel` is materialized into machine-global agent config
|
|
42
|
+
* at setup time, so a repo file could never apply it — and must not be able to
|
|
43
|
+
* silence the usage ledger. `enforcement` decides whether a budget cap marked
|
|
44
|
+
* `block` is acted on: a committed repo file that could turn it off — or point
|
|
45
|
+
* the check at a server that always answers `allow` — would be a one-line,
|
|
46
|
+
* repository-wide bypass of every cap in the tenant.
|
|
47
|
+
*/
|
|
48
|
+
export declare const GLOBAL_ONLY_BLOCKS: readonly ["delivery", "otel", "enforcement"];
|
|
49
|
+
/**
|
|
50
|
+
* Emission toggles a repo file may not narrow. `llm.call` is the mandatory
|
|
51
|
+
* usage ledger and `turn.summary` is the only hook-path usage record: a repo
|
|
52
|
+
* file may narrow *capture* (prompts, responses, files) but must never be able
|
|
53
|
+
* to silence usage telemetry for everyone who clones the repository.
|
|
54
|
+
*/
|
|
55
|
+
export declare const GLOBAL_ONLY_EMIT_KEYS: ReadonlySet<string>;
|
|
56
|
+
/** Nested blocks merged field-by-field instead of replaced wholesale. */
|
|
57
|
+
export declare const MERGE_BLOCKS: readonly ["capture", "emit"];
|
|
58
|
+
/** Ceiling on the upward walk looking for a repo config. */
|
|
59
|
+
export declare const MAX_WALK_DEPTH = 32;
|
|
60
|
+
/** Capture flags that mean raw content leaves the machine. */
|
|
61
|
+
export declare const CONTENT_CAPTURE_FLAGS: readonly ["prompts", "responses", "toolInput", "toolOutput"];
|
|
62
|
+
export declare const RE_TRAILING_SLASHES: RegExp;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Delivery defaults. Small on purpose: hooks run on the agent's critical path. */
|
|
2
|
+
export const DEFAULT_SEND_TIMEOUT_MS = 1500;
|
|
3
|
+
export const DEFAULT_DRAIN_BATCH_SIZE = 25;
|
|
4
|
+
export const DEFAULT_MAX_QUEUE_EVENTS = 2000;
|
|
5
|
+
export const DEFAULT_MAX_ATTEMPTS = 20;
|
|
6
|
+
export const DEFAULT_MAX_EVENT_AGE_DAYS = 7;
|
|
7
|
+
/**
|
|
8
|
+
* Pre-turn budget check defaults.
|
|
9
|
+
*
|
|
10
|
+
* The timeout is a hard ceiling on a request that sits between the developer
|
|
11
|
+
* pressing enter and their agent starting work, and the TTL mirrors the cache
|
|
12
|
+
* the platform keeps for the same decision.
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_ENFORCEMENT_TIMEOUT_MS = 300;
|
|
15
|
+
export const DEFAULT_ENFORCEMENT_CACHE_TTL_MS = 60_000;
|
|
16
|
+
/** Native OTLP signal names, in report order. */
|
|
17
|
+
export const OTEL_SIGNAL_NAMES = ['logs', 'traces', 'metrics'];
|
|
18
|
+
/** O(1) validation of a `--otel` list entry. */
|
|
19
|
+
export const OTEL_SIGNAL_NAME_SET = new Set(OTEL_SIGNAL_NAMES);
|
|
20
|
+
/** Shorthands accepted by `--otel`. */
|
|
21
|
+
export const OTEL_ALL = 'all';
|
|
22
|
+
export const OTEL_NONE = 'none';
|
|
23
|
+
/** Backend routes derived from the configured base endpoint. */
|
|
24
|
+
export const EVENTS_PATH = '/v1/events';
|
|
25
|
+
export const OTLP_BASE_PATH = '/v1/otlp';
|
|
26
|
+
export const ENFORCEMENT_PATH = '/v1/enforcement/decision';
|
|
27
|
+
/** Repository-level overrides file, found by walking up from the working directory. */
|
|
28
|
+
export const REPO_CONFIG_NAME = '.agentwatch.json';
|
|
29
|
+
/**
|
|
30
|
+
* Keys a repo file may not set: it is committed and shared, so secrets and
|
|
31
|
+
* per-machine identity stay in the global ~/.agentwatch/config.json only.
|
|
32
|
+
* Delivery destinations are global-only too — a repo file that redirected them
|
|
33
|
+
* would exfiltrate the global bearer token along with the telemetry.
|
|
34
|
+
*/
|
|
35
|
+
export const GLOBAL_ONLY_KEYS = new Set([
|
|
36
|
+
'token',
|
|
37
|
+
'installationId',
|
|
38
|
+
'developerEmail',
|
|
39
|
+
'endpoint',
|
|
40
|
+
'eventsUrl',
|
|
41
|
+
'otlpUrl',
|
|
42
|
+
'enforcementUrl'
|
|
43
|
+
]);
|
|
44
|
+
/**
|
|
45
|
+
* Whole blocks a repo file may not touch.
|
|
46
|
+
*
|
|
47
|
+
* `delivery` governs the machine-global offline queue (size bound, retry
|
|
48
|
+
* budget, age limit): a committed repo file could truncate every other repo's
|
|
49
|
+
* backlog through it. `otel` is materialized into machine-global agent config
|
|
50
|
+
* at setup time, so a repo file could never apply it — and must not be able to
|
|
51
|
+
* silence the usage ledger. `enforcement` decides whether a budget cap marked
|
|
52
|
+
* `block` is acted on: a committed repo file that could turn it off — or point
|
|
53
|
+
* the check at a server that always answers `allow` — would be a one-line,
|
|
54
|
+
* repository-wide bypass of every cap in the tenant.
|
|
55
|
+
*/
|
|
56
|
+
export const GLOBAL_ONLY_BLOCKS = ['delivery', 'otel', 'enforcement'];
|
|
57
|
+
/**
|
|
58
|
+
* Emission toggles a repo file may not narrow. `llm.call` is the mandatory
|
|
59
|
+
* usage ledger and `turn.summary` is the only hook-path usage record: a repo
|
|
60
|
+
* file may narrow *capture* (prompts, responses, files) but must never be able
|
|
61
|
+
* to silence usage telemetry for everyone who clones the repository.
|
|
62
|
+
*/
|
|
63
|
+
export const GLOBAL_ONLY_EMIT_KEYS = new Set(['llmCalls', 'turnSummaries']);
|
|
64
|
+
/** Nested blocks merged field-by-field instead of replaced wholesale. */
|
|
65
|
+
export const MERGE_BLOCKS = ['capture', 'emit'];
|
|
66
|
+
/** Ceiling on the upward walk looking for a repo config. */
|
|
67
|
+
export const MAX_WALK_DEPTH = 32;
|
|
68
|
+
/** Capture flags that mean raw content leaves the machine. */
|
|
69
|
+
export const CONTENT_CAPTURE_FLAGS = ['prompts', 'responses', 'toolInput', 'toolOutput'];
|
|
70
|
+
export const RE_TRAILING_SLASHES = /\/+$/;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the edge is configured to do: the global file, the repository overlay
|
|
3
|
+
* on top of it, and the routes derived from the endpoint.
|
|
4
|
+
*/
|
|
5
|
+
export type { AgentWatchConfig, CaptureConfig, ConfigLoadResult, EffectiveConfig, MergedConfig, OtelConfig, OtelSignalName } from './types/config.types.js';
|
|
6
|
+
export { CONTENT_CAPTURE_FLAGS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME } from './constants/config.constants.js';
|
|
7
|
+
export { captureSchema, configSchema, deliverySchema, emitSchema, otelSchema } from './schemas/config.schema.js';
|
|
8
|
+
export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals } from './config.js';
|
|
9
|
+
export { ensureInstallationId, loadConfig, saveConfig } from './config-store.js';
|
|
10
|
+
export { findRepoConfigFile, loadEffectiveConfig, mergeRepoConfig } from './repo-config.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CONTENT_CAPTURE_FLAGS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME } from './constants/config.constants.js';
|
|
2
|
+
export { captureSchema, configSchema, deliverySchema, emitSchema, otelSchema } from './schemas/config.schema.js';
|
|
3
|
+
export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals } from './config.js';
|
|
4
|
+
export { ensureInstallationId, loadConfig, saveConfig } from './config-store.js';
|
|
5
|
+
export { findRepoConfigFile, loadEffectiveConfig, mergeRepoConfig } from './repo-config.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AgentWatchPaths } from '../storage/types/storage.types.js';
|
|
2
|
+
import type { AgentWatchConfig, EffectiveConfig, MergedConfig } from './types/config.types.js';
|
|
3
|
+
export { REPO_CONFIG_NAME } from './constants/config.constants.js';
|
|
4
|
+
export type { EffectiveConfig, MergedConfig } from './types/config.types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Locate the nearest `.agentwatch.json` at or above a directory.
|
|
7
|
+
*
|
|
8
|
+
* @param startDir - Directory to start the upward walk from.
|
|
9
|
+
* @returns The file path, or undefined when none is found.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findRepoConfigFile(startDir: string): Promise<string | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Overlay repository overrides on the global config.
|
|
14
|
+
*
|
|
15
|
+
* A repo file is committed and shared, which is what every rule here follows
|
|
16
|
+
* from: it may narrow what is captured, and it may not touch identity,
|
|
17
|
+
* credentials, delivery destinations or the usage ledger. Anything refused is
|
|
18
|
+
* reported rather than silently dropped, and an invalid *result* degrades to
|
|
19
|
+
* the global config — a broken repo file must never disable telemetry or break
|
|
20
|
+
* a hook.
|
|
21
|
+
*
|
|
22
|
+
* @param global - The machine's global config.
|
|
23
|
+
* @param repoValue - Raw decoded contents of the repo file.
|
|
24
|
+
* @returns The effective config and every override that was refused.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mergeRepoConfig(global: AgentWatchConfig, repoValue: unknown): MergedConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Global config plus the nearest repo overrides for a directory.
|
|
29
|
+
*
|
|
30
|
+
* Tolerant end to end: any failure yields the global config, because the
|
|
31
|
+
* caller is a hook that has to answer the agent either way.
|
|
32
|
+
*
|
|
33
|
+
* @param paths - Resolved AgentWatch paths.
|
|
34
|
+
* @param cwd - Directory the payload came from.
|
|
35
|
+
* @returns The effective config, its warnings, and the file that produced it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function loadEffectiveConfig(paths: AgentWatchPaths, cwd: string): Promise<EffectiveConfig>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { asRecord, omitKeys } from '../core/object.js';
|
|
4
|
+
import { debugLog } from '../core/logger.js';
|
|
5
|
+
import { readJsonFile } from '../storage/json-file.js';
|
|
6
|
+
import { loadConfig } from './config-store.js';
|
|
7
|
+
import { GLOBAL_ONLY_BLOCKS, GLOBAL_ONLY_EMIT_KEYS, GLOBAL_ONLY_KEYS, MAX_WALK_DEPTH, MERGE_BLOCKS, REPO_CONFIG_NAME } from './constants/config.constants.js';
|
|
8
|
+
import { configSchema } from './schemas/config.schema.js';
|
|
9
|
+
export { REPO_CONFIG_NAME } from './constants/config.constants.js';
|
|
10
|
+
/**
|
|
11
|
+
* Locate the nearest `.agentwatch.json` at or above a directory.
|
|
12
|
+
*
|
|
13
|
+
* @param startDir - Directory to start the upward walk from.
|
|
14
|
+
* @returns The file path, or undefined when none is found.
|
|
15
|
+
*/
|
|
16
|
+
export async function findRepoConfigFile(startDir) {
|
|
17
|
+
let dir = path.resolve(startDir);
|
|
18
|
+
for (let depth = 0; depth < MAX_WALK_DEPTH; depth++) {
|
|
19
|
+
const candidate = path.join(dir, REPO_CONFIG_NAME);
|
|
20
|
+
if (await isFile(candidate))
|
|
21
|
+
return candidate;
|
|
22
|
+
const parent = path.dirname(dir);
|
|
23
|
+
if (parent === dir)
|
|
24
|
+
return undefined;
|
|
25
|
+
dir = parent;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Overlay repository overrides on the global config.
|
|
31
|
+
*
|
|
32
|
+
* A repo file is committed and shared, which is what every rule here follows
|
|
33
|
+
* from: it may narrow what is captured, and it may not touch identity,
|
|
34
|
+
* credentials, delivery destinations or the usage ledger. Anything refused is
|
|
35
|
+
* reported rather than silently dropped, and an invalid *result* degrades to
|
|
36
|
+
* the global config — a broken repo file must never disable telemetry or break
|
|
37
|
+
* a hook.
|
|
38
|
+
*
|
|
39
|
+
* @param global - The machine's global config.
|
|
40
|
+
* @param repoValue - Raw decoded contents of the repo file.
|
|
41
|
+
* @returns The effective config and every override that was refused.
|
|
42
|
+
*/
|
|
43
|
+
export function mergeRepoConfig(global, repoValue) {
|
|
44
|
+
const repo = asRecord(repoValue);
|
|
45
|
+
if (!repo)
|
|
46
|
+
return { config: global, warnings: [`${REPO_CONFIG_NAME}: expected a JSON object`] };
|
|
47
|
+
const permitted = withoutGlobalOnly(repo);
|
|
48
|
+
const merged = overlay(global, permitted.value);
|
|
49
|
+
const parsed = configSchema.safeParse(merged);
|
|
50
|
+
if (!parsed.success) {
|
|
51
|
+
const detail = parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ');
|
|
52
|
+
return { config: global, warnings: [...permitted.warnings, `${REPO_CONFIG_NAME}: invalid overrides ignored (${detail})`] };
|
|
53
|
+
}
|
|
54
|
+
return { config: parsed.data, warnings: permitted.warnings };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Global config plus the nearest repo overrides for a directory.
|
|
58
|
+
*
|
|
59
|
+
* Tolerant end to end: any failure yields the global config, because the
|
|
60
|
+
* caller is a hook that has to answer the agent either way.
|
|
61
|
+
*
|
|
62
|
+
* @param paths - Resolved AgentWatch paths.
|
|
63
|
+
* @param cwd - Directory the payload came from.
|
|
64
|
+
* @returns The effective config, its warnings, and the file that produced it.
|
|
65
|
+
*/
|
|
66
|
+
export async function loadEffectiveConfig(paths, cwd) {
|
|
67
|
+
const loaded = await loadConfig(paths);
|
|
68
|
+
const global = loaded.config;
|
|
69
|
+
// The fail-safe stays closed: with the global config missing or corrupt the
|
|
70
|
+
// runtime is already metadata-only, and a committed repo file must not be
|
|
71
|
+
// able to re-enable content capture on top of that.
|
|
72
|
+
if (loaded.state !== 'ok') {
|
|
73
|
+
const warning = `global config ${loaded.state}; repo overrides ignored`;
|
|
74
|
+
debugLog(warning);
|
|
75
|
+
return { config: global, warnings: [warning] };
|
|
76
|
+
}
|
|
77
|
+
const repoConfigFile = await findRepoConfigFileSafely(cwd);
|
|
78
|
+
if (!repoConfigFile)
|
|
79
|
+
return { config: global, warnings: [] };
|
|
80
|
+
const read = await readJsonFile(repoConfigFile);
|
|
81
|
+
if (read.state !== 'ok') {
|
|
82
|
+
const warnings = read.state === 'invalid' ? [`${repoConfigFile}: ${read.error}`] : [];
|
|
83
|
+
for (const warning of warnings)
|
|
84
|
+
debugLog(warning);
|
|
85
|
+
return { config: global, warnings, repoConfigFile };
|
|
86
|
+
}
|
|
87
|
+
const merged = mergeRepoConfig(global, read.value);
|
|
88
|
+
for (const warning of merged.warnings)
|
|
89
|
+
debugLog(warning);
|
|
90
|
+
return { ...merged, repoConfigFile };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Strip every override a committed file is not allowed to set.
|
|
94
|
+
*
|
|
95
|
+
* Keys are removed by building a new object rather than deleting from one, so
|
|
96
|
+
* the result stays monomorphic (STYLEGUIDE 3.4).
|
|
97
|
+
*
|
|
98
|
+
* @param repo - Raw repo overrides.
|
|
99
|
+
* @returns The permitted subset and one warning per refusal.
|
|
100
|
+
*/
|
|
101
|
+
function withoutGlobalOnly(repo) {
|
|
102
|
+
const warnings = [];
|
|
103
|
+
const refused = new Set();
|
|
104
|
+
for (const key of Object.keys(repo)) {
|
|
105
|
+
if (GLOBAL_ONLY_KEYS.has(key)) {
|
|
106
|
+
warnings.push(`${REPO_CONFIG_NAME}: "${key}" is global-only and was ignored`);
|
|
107
|
+
refused.add(key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const block of GLOBAL_ONLY_BLOCKS) {
|
|
111
|
+
if (!(block in repo))
|
|
112
|
+
continue;
|
|
113
|
+
warnings.push(`${REPO_CONFIG_NAME}: "${block}" is global-only and was ignored`);
|
|
114
|
+
refused.add(block);
|
|
115
|
+
}
|
|
116
|
+
const value = omitKeys(repo, refused);
|
|
117
|
+
const emit = asRecord(value['emit']);
|
|
118
|
+
if (!emit)
|
|
119
|
+
return { value, warnings };
|
|
120
|
+
const refusedEmitKeys = new Set();
|
|
121
|
+
for (const key of Object.keys(emit)) {
|
|
122
|
+
if (!GLOBAL_ONLY_EMIT_KEYS.has(key))
|
|
123
|
+
continue;
|
|
124
|
+
warnings.push(`${REPO_CONFIG_NAME}: "emit.${key}" is mandatory/global-only and was ignored`);
|
|
125
|
+
refusedEmitKeys.add(key);
|
|
126
|
+
}
|
|
127
|
+
return { value: { ...value, emit: omitKeys(emit, refusedEmitKeys) }, warnings };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Combine global and repo values, merging the per-field blocks.
|
|
131
|
+
*
|
|
132
|
+
* Top-level keys replace; `capture` and `emit` merge field-by-field, so a repo
|
|
133
|
+
* file turning off one capture flag does not reset the others to their
|
|
134
|
+
* defaults.
|
|
135
|
+
*
|
|
136
|
+
* @param global - Global config.
|
|
137
|
+
* @param repo - Permitted repo overrides.
|
|
138
|
+
* @returns The unvalidated merge, ready for the schema.
|
|
139
|
+
*/
|
|
140
|
+
function overlay(global, repo) {
|
|
141
|
+
const merged = { ...global, ...repo };
|
|
142
|
+
for (const block of MERGE_BLOCKS) {
|
|
143
|
+
const repoBlock = asRecord(repo[block]);
|
|
144
|
+
if (!repoBlock)
|
|
145
|
+
continue;
|
|
146
|
+
merged[block] = { ...global[block], ...repoBlock };
|
|
147
|
+
}
|
|
148
|
+
return merged;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Locate the repo config, treating any failure as "there is none".
|
|
152
|
+
*
|
|
153
|
+
* @param cwd - Directory to search upward from.
|
|
154
|
+
* @returns The file path, or undefined.
|
|
155
|
+
*/
|
|
156
|
+
async function findRepoConfigFileSafely(cwd) {
|
|
157
|
+
try {
|
|
158
|
+
return await findRepoConfigFile(cwd);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Whether a path exists and is a regular file.
|
|
166
|
+
*
|
|
167
|
+
* @param candidate - Path to test.
|
|
168
|
+
* @returns True when it is a file.
|
|
169
|
+
*/
|
|
170
|
+
async function isFile(candidate) {
|
|
171
|
+
try {
|
|
172
|
+
return (await fs.stat(candidate)).isFile();
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
// Missing, or a directory we may not read; keep walking.
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|