@agent-watch-ai/edge 0.2.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +558 -0
- package/README.md +222 -97
- package/SECURITY.md +72 -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 +52 -4
- package/dist/cli/constants/cli.constants.js +56 -5
- package/dist/cli/context.d.ts +33 -2
- package/dist/cli/context.js +84 -14
- package/dist/cli/doctor.js +321 -33
- 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 +553 -103
- package/dist/cli/status.js +82 -13
- package/dist/cli/toggle.d.ts +9 -0
- package/dist/cli/toggle.js +117 -0
- package/dist/cli/types/cli.types.d.ts +43 -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 +110 -12
- 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 +116 -6
- package/dist/config/constants/config.constants.js +131 -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 +831 -84
- package/dist/config/schemas/config.schema.js +398 -16
- 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 +119 -0
- package/dist/credentials/constants/credentials.constants.js +120 -0
- package/dist/credentials/credential-status.d.ts +14 -0
- package/dist/credentials/credential-status.js +38 -0
- package/dist/credentials/credentials.d.ts +86 -0
- package/dist/credentials/credentials.js +278 -0
- package/dist/credentials/device-api.d.ts +73 -0
- package/dist/credentials/device-api.js +161 -0
- package/dist/credentials/device-state.d.ts +31 -0
- package/dist/credentials/device-state.js +51 -0
- package/dist/credentials/identity.d.ts +73 -0
- package/dist/credentials/identity.js +101 -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 +31 -0
- package/dist/credentials/sign-in.js +105 -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 +206 -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 +64 -17
- package/dist/enforcement/enforcement.d.ts +23 -2
- package/dist/enforcement/enforcement.js +107 -17
- package/dist/enforcement/index.d.ts +4 -3
- package/dist/enforcement/index.js +3 -2
- package/dist/enforcement/types/enforcement.types.d.ts +66 -2
- 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 +10 -0
- package/dist/pipeline/constants/pipeline.constants.js +10 -0
- package/dist/pipeline/hook-pipeline.js +410 -33
- 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 +75 -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 +36 -3
- package/dist/providers/codex/codex.otel.js +199 -32
- 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 +10 -0
- package/dist/providers/codex/constants/codex.otel.constants.js +10 -0
- package/dist/providers/constants/provider.constants.d.ts +8 -3
- package/dist/providers/constants/provider.constants.js +8 -3
- package/dist/providers/cursor/constants/cursor.constants.d.ts +9 -0
- package/dist/providers/cursor/constants/cursor.constants.js +9 -0
- package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
- package/dist/providers/cursor/cursor.adapter.js +129 -4
- 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 +9 -1
- package/dist/providers/gemini/constants/gemini.otel.constants.js +9 -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 +30 -21
- package/dist/providers/gemini/gemini.otel.js +166 -22
- 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/bearer-rewrite.d.ts +19 -0
- package/dist/providers/shared/bearer-rewrite.js +46 -0
- 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 +24 -2
- package/dist/providers/shared/constants/tooling.constants.js +25 -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 +40 -1
- package/dist/providers/shared/tooling.js +70 -1
- package/dist/providers/shared/types/adapter.types.d.ts +1 -2
- package/dist/providers/types/provider.types.d.ts +81 -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 +21 -0
- package/dist/storage/atomic-file.js +20 -1
- package/dist/storage/constants/storage.constants.d.ts +19 -0
- package/dist/storage/constants/storage.constants.js +19 -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 +67 -0
- package/dist/turns/work-checkout.js +700 -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 +655 -0
- package/docs/ENTERPRISE_DEPLOYMENT.md +194 -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,7 +1,13 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { enforcementUrl } from '../config/config.js';
|
|
3
|
+
import { ENFORCEMENT_WINDOW_MS } from '../config/constants/config.constants.js';
|
|
3
4
|
import { debugLog } from '../core/logger.js';
|
|
4
|
-
import {
|
|
5
|
+
import { DEVICE_SOURCE_BATCH_CODE } from '../credentials/constants/credentials.constants.js';
|
|
6
|
+
import { deviceFor, hasCredential, identityOf } from '../credentials/identity.js';
|
|
7
|
+
import { sha256Hex } from '../events/event-id.js';
|
|
8
|
+
import { BackendCooldown } from '../transport/cooldown.js';
|
|
9
|
+
import { identityPaths } from '../transport/queue-partition.js';
|
|
10
|
+
import { ALLOW, DECISION_ALLOW, ENFORCEMENT_CACHE_FILE_NAME, ENFORCEMENT_COOLDOWN_FILE_PREFIX, ENFORCEMENT_COOLDOWN_FILE_SUFFIX, ENFORCEMENT_COOLDOWN_MS, ENFORCEMENT_COOLDOWN_URL_CHARS } from './constants/enforcement.constants.js';
|
|
5
11
|
import { DecisionCache, decisionKey } from './decision-cache.js';
|
|
6
12
|
import { requestDecision } from './decision-client.js';
|
|
7
13
|
/**
|
|
@@ -14,6 +20,10 @@ import { requestDecision } from './decision-client.js';
|
|
|
14
20
|
* front of every developer's tooling, so a check that failed closed would turn
|
|
15
21
|
* an alerts-service hiccup into an outage for a whole engineering organization.
|
|
16
22
|
*
|
|
23
|
+
* An allow that exists only because nothing answered carries the reason, so
|
|
24
|
+
* the turn it lets through can say it ran unchecked. An allow because nothing
|
|
25
|
+
* was asked carries none: there was no check to fail.
|
|
26
|
+
*
|
|
17
27
|
* Never throws: a caller on the hook path has to answer the agent either way.
|
|
18
28
|
*
|
|
19
29
|
* @param options - Effective config, paths, the identity to ask about, clock.
|
|
@@ -21,52 +31,131 @@ import { requestDecision } from './decision-client.js';
|
|
|
21
31
|
*/
|
|
22
32
|
export async function resolveEnforcement(options) {
|
|
23
33
|
const url = enforcementUrl(options.config);
|
|
24
|
-
|
|
34
|
+
// A device's install key stays in the file to enroll again, but this
|
|
35
|
+
// identity sends as the device: only the caller's cached access token will do.
|
|
36
|
+
const token = options.bearer ?? (deviceFor(options.config) ? undefined : options.config.token);
|
|
25
37
|
const developerId = options.developerId;
|
|
26
|
-
// Nothing was asked, so nobody said no.
|
|
27
|
-
|
|
38
|
+
// Nothing was asked, so nobody said no. A code-enrolled device needs no email:
|
|
39
|
+
// the gateway judges it as the identity the code names.
|
|
40
|
+
if (!enforcementWouldAsk(options.config) || !url || (!developerId && deviceFor(options.config)?.source !== DEVICE_SOURCE_BATCH_CODE))
|
|
28
41
|
return ALLOW;
|
|
29
42
|
try {
|
|
30
43
|
return await decideThroughCache(options, url, token, developerId);
|
|
31
44
|
}
|
|
32
45
|
catch (error) {
|
|
33
46
|
debugLog('enforcement: check threw; allowing:', error);
|
|
34
|
-
return
|
|
47
|
+
return failOpen('unknown');
|
|
35
48
|
}
|
|
36
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* An allow that stands in for a decision that did not arrive.
|
|
52
|
+
*
|
|
53
|
+
* @param reason - Why it did not.
|
|
54
|
+
* @returns The allow, carrying the reason.
|
|
55
|
+
*/
|
|
56
|
+
function failOpen(reason) {
|
|
57
|
+
return { decision: DECISION_ALLOW, failOpenReason: reason };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether a decision would be asked for at all, from configuration alone.
|
|
61
|
+
*
|
|
62
|
+
* Exported because the caller has to know before it pays for anything the
|
|
63
|
+
* question needs. Working out where a prompt is happening costs a walk of the
|
|
64
|
+
* working copy and, on a cold checkout, a git process; spending that on a
|
|
65
|
+
* machine that will not ask is the one cost this feature must not add to the
|
|
66
|
+
* gate.
|
|
67
|
+
*
|
|
68
|
+
* Identity is not part of it: resolving that is the caller's own decision, and
|
|
69
|
+
* it is already paid for elsewhere.
|
|
70
|
+
*
|
|
71
|
+
* @param config - Effective configuration.
|
|
72
|
+
* @returns True when a configured, enabled check would reach the platform.
|
|
73
|
+
*/
|
|
74
|
+
export function enforcementWouldAsk(config) {
|
|
75
|
+
return config.enforcement.enabled && hasCredential(config) && Boolean(enforcementUrl(config));
|
|
76
|
+
}
|
|
37
77
|
/**
|
|
38
78
|
* The decision, from the local cache when it holds a live one.
|
|
39
79
|
*
|
|
40
80
|
* A miss asks the platform and stores whatever it answered. A *failure* is not
|
|
41
81
|
* stored: it is not a decision, and caching it as an allow would extend one
|
|
42
|
-
* unreachable moment across the whole TTL.
|
|
82
|
+
* unreachable moment across the whole TTL. It trips the breaker instead, so the
|
|
83
|
+
* turns after it skip the wait rather than each paying the timeout again.
|
|
84
|
+
*
|
|
85
|
+
* The cache is read before the token is needed: it is keyed on the identity,
|
|
86
|
+
* not the bearer, so a block still in force is served even when the prompt
|
|
87
|
+
* path has no valid access token to ask a new question with.
|
|
43
88
|
*
|
|
44
89
|
* @param options - As given to {@link resolveEnforcement}.
|
|
45
90
|
* @param url - The decision endpoint.
|
|
46
|
-
* @param token - Edge token.
|
|
47
|
-
* @param developerId - Identity to ask about.
|
|
91
|
+
* @param token - Edge token, when there is one to ask with.
|
|
92
|
+
* @param developerId - Identity to ask about, absent for a code-enrolled device.
|
|
48
93
|
* @returns The decision to act on.
|
|
49
94
|
*/
|
|
50
95
|
async function decideThroughCache(options, url, token, developerId) {
|
|
51
96
|
const cache = new DecisionCache(path.join(options.paths.dataDir, ENFORCEMENT_CACHE_FILE_NAME), options.now);
|
|
52
|
-
|
|
97
|
+
// `enforcementWouldAsk` already required a credential, so there is an identity.
|
|
98
|
+
const key = decisionKey(url, identityOf(options.config) ?? '', developerId ?? '', options.checkout, options.model);
|
|
53
99
|
const cached = await cache.read(key);
|
|
54
100
|
if (cached)
|
|
55
101
|
return cached;
|
|
56
|
-
|
|
102
|
+
// A question would have to be asked, and the device has no valid token to ask
|
|
103
|
+
// it with (the prompt path never refreshes): the turn runs unchecked, and says why.
|
|
104
|
+
if (!token)
|
|
105
|
+
return failOpen('token_unavailable');
|
|
106
|
+
const cooldown = new BackendCooldown(enforcementCooldownFile(options, url), options.now);
|
|
107
|
+
// Skipping is the only thing the breaker does: the turn gets the same allow a
|
|
108
|
+
// timeout would have given it, without the wait.
|
|
109
|
+
if (await cooldown.active()) {
|
|
110
|
+
debugLog('enforcement: breaker open; allowing without asking');
|
|
111
|
+
return failOpen('circuit_open');
|
|
112
|
+
}
|
|
113
|
+
const outcome = await requestDecision({
|
|
57
114
|
url,
|
|
58
115
|
token,
|
|
59
116
|
developerId,
|
|
117
|
+
checkout: options.checkout,
|
|
118
|
+
model: options.model,
|
|
60
119
|
installationId: options.config.installationId,
|
|
61
120
|
timeoutMs: options.config.enforcement.timeoutMs,
|
|
62
121
|
fetchFn: options.fetchFn
|
|
63
122
|
});
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
123
|
+
if ('failOpenReason' in outcome) {
|
|
124
|
+
await cooldown.trip(ENFORCEMENT_COOLDOWN_MS);
|
|
125
|
+
return failOpen(outcome.failOpenReason);
|
|
126
|
+
}
|
|
127
|
+
await cooldown.clear();
|
|
128
|
+
const { cacheTtlMs, ...decision } = outcome.answered;
|
|
129
|
+
const ttlMs = effectiveTtlMs(cacheTtlMs, options.config.enforcement.cacheTtlMs);
|
|
130
|
+
// Zero is the platform saying "do not keep this", which it says to every tenant
|
|
131
|
+
// that has a feature cap: which feature a branch belongs to is a fact about one
|
|
132
|
+
// checkout, and this cache is keyed on the developer. Written anyway the entry
|
|
133
|
+
// would already be expired — but it would still be a file write per gated
|
|
134
|
+
// prompt for something nothing can ever read.
|
|
135
|
+
if (ttlMs > 0) {
|
|
136
|
+
await cache.write(key, decision, ttlMs);
|
|
137
|
+
return decision;
|
|
138
|
+
}
|
|
139
|
+
// Writing is also what prunes, so an answer that must not be kept still has to
|
|
140
|
+
// sweep what an earlier one left behind.
|
|
141
|
+
await cache.prune();
|
|
68
142
|
return decision;
|
|
69
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* The enforcement breaker's file for this identity and endpoint.
|
|
146
|
+
*
|
|
147
|
+
* Per identity for the reason delivery's is: one tenant's unreachable platform
|
|
148
|
+
* or revoked token must not skip another tenant's checks. Per endpoint because
|
|
149
|
+
* one identity reaching two platforms must not let one's outage skip the other.
|
|
150
|
+
*
|
|
151
|
+
* @param options - As given to {@link resolveEnforcement}.
|
|
152
|
+
* @param url - The decision endpoint.
|
|
153
|
+
* @returns Absolute path of the state file.
|
|
154
|
+
*/
|
|
155
|
+
function enforcementCooldownFile(options, url) {
|
|
156
|
+
const name = ENFORCEMENT_COOLDOWN_FILE_PREFIX + sha256Hex(url).slice(0, ENFORCEMENT_COOLDOWN_URL_CHARS) + ENFORCEMENT_COOLDOWN_FILE_SUFFIX;
|
|
157
|
+
return path.join(path.dirname(identityPaths(options.paths, identityOf(options.config)).cooldownFile), name);
|
|
158
|
+
}
|
|
70
159
|
/**
|
|
71
160
|
* How long this answer may be reused.
|
|
72
161
|
*
|
|
@@ -77,14 +166,15 @@ async function decideThroughCache(options, url, token, developerId) {
|
|
|
77
166
|
* configured ceiling, which is what keeps the setting meaningful.
|
|
78
167
|
*
|
|
79
168
|
* No advice means the configured value, which is what a platform that predates
|
|
80
|
-
* the field produces.
|
|
169
|
+
* the field produces. Neither may exceed the promised window.
|
|
81
170
|
*
|
|
82
171
|
* @param asked - What the platform asked for, if anything.
|
|
83
172
|
* @param configured - This machine's own TTL, and its ceiling.
|
|
84
173
|
* @returns The TTL to store the entry with.
|
|
85
174
|
*/
|
|
86
175
|
function effectiveTtlMs(asked, configured) {
|
|
176
|
+
const ceiling = Math.min(configured, ENFORCEMENT_WINDOW_MS);
|
|
87
177
|
if (asked === undefined)
|
|
88
|
-
return
|
|
89
|
-
return Math.min(asked,
|
|
178
|
+
return ceiling;
|
|
179
|
+
return Math.min(asked, ceiling);
|
|
90
180
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* The pre-turn budget check: one question to the platform before a developer's
|
|
3
3
|
* agent starts a turn, and a refusal only when the platform explicitly says so.
|
|
4
4
|
*
|
|
5
|
-
* `resolveEnforcement` is the whole contract
|
|
5
|
+
* `resolveEnforcement` is the whole contract, and `enforcementWouldAsk` is the
|
|
6
|
+
* question a caller asks before paying for anything the check needs. The client, the cache and the
|
|
6
7
|
* validators are how it keeps that contract, not part of it; tests reach for
|
|
7
8
|
* them directly.
|
|
8
9
|
*/
|
|
9
|
-
export { resolveEnforcement } from './enforcement.js';
|
|
10
|
+
export { enforcementWouldAsk, resolveEnforcement } from './enforcement.js';
|
|
10
11
|
export { DECISION_BLOCK, ENFORCEMENT_CACHE_FILE_NAME } from './constants/enforcement.constants.js';
|
|
11
|
-
export type { EnforcementDecision, EnforcementOptions } from './types/enforcement.types.js';
|
|
12
|
+
export type { EnforcementDecision, EnforcementOptions, FailOpenReason, GateDecision } from './types/enforcement.types.js';
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* The pre-turn budget check: one question to the platform before a developer's
|
|
3
3
|
* agent starts a turn, and a refusal only when the platform explicitly says so.
|
|
4
4
|
*
|
|
5
|
-
* `resolveEnforcement` is the whole contract
|
|
5
|
+
* `resolveEnforcement` is the whole contract, and `enforcementWouldAsk` is the
|
|
6
|
+
* question a caller asks before paying for anything the check needs. The client, the cache and the
|
|
6
7
|
* validators are how it keeps that contract, not part of it; tests reach for
|
|
7
8
|
* them directly.
|
|
8
9
|
*/
|
|
9
|
-
export { resolveEnforcement } from './enforcement.js';
|
|
10
|
+
export { enforcementWouldAsk, resolveEnforcement } from './enforcement.js';
|
|
10
11
|
export { DECISION_BLOCK, ENFORCEMENT_CACHE_FILE_NAME } from './constants/enforcement.constants.js';
|
|
@@ -32,6 +32,39 @@ export type EnforcementDecision = {
|
|
|
32
32
|
export type AnsweredDecision = EnforcementDecision & {
|
|
33
33
|
readonly cacheTtlMs?: number;
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Why a turn ran without a decision, in the platform's closed vocabulary.
|
|
37
|
+
*
|
|
38
|
+
* A category and never a detail: no status code, no error message, no body.
|
|
39
|
+
* The body of a failed answer can name a person and what they spent, and a
|
|
40
|
+
* status code says nothing the platform's own logs do not already say better.
|
|
41
|
+
*/
|
|
42
|
+
export type FailOpenReason = 'timeout' | 'http_error' | 'network_error' | 'unreadable_response' | 'circuit_open' | 'token_unavailable' | 'unknown';
|
|
43
|
+
/**
|
|
44
|
+
* What asking the platform produced: an answer, or the reason there was none.
|
|
45
|
+
*
|
|
46
|
+
* A union rather than `AnsweredDecision | undefined` so a failure keeps what
|
|
47
|
+
* kind of failure it was, which is what the turn summary reports.
|
|
48
|
+
*/
|
|
49
|
+
export type DecisionOutcome = {
|
|
50
|
+
readonly answered: AnsweredDecision;
|
|
51
|
+
} | {
|
|
52
|
+
readonly failOpenReason: FailOpenReason;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* What the hook acts on: the decision, and — only when the turn is allowed
|
|
56
|
+
* because nothing answered — why.
|
|
57
|
+
*
|
|
58
|
+
* An allow with no reason is a real answer (or nothing was asked at all); an
|
|
59
|
+
* allow with one is a turn that ran unchecked.
|
|
60
|
+
*/
|
|
61
|
+
export type GateDecision = {
|
|
62
|
+
readonly decision: 'allow';
|
|
63
|
+
readonly failOpenReason?: FailOpenReason;
|
|
64
|
+
} | {
|
|
65
|
+
readonly decision: 'block';
|
|
66
|
+
readonly message: string;
|
|
67
|
+
};
|
|
35
68
|
/** One decision as the local cache holds it, with the deadline it expires at. */
|
|
36
69
|
export interface CachedDecision {
|
|
37
70
|
readonly decision: EnforcementDecision;
|
|
@@ -39,21 +72,52 @@ export interface CachedDecision {
|
|
|
39
72
|
}
|
|
40
73
|
/** One request to the decision endpoint. */
|
|
41
74
|
export interface DecisionRequest {
|
|
75
|
+
readonly checkout?: EnforcementCheckout;
|
|
42
76
|
readonly url: string;
|
|
43
77
|
readonly token: string;
|
|
44
|
-
/** The same identity `turn.summary.developer_id` carries. */
|
|
45
|
-
readonly developerId
|
|
78
|
+
/** The same identity `turn.summary.developer_id` carries; absent, the gateway judges the device's own. */
|
|
79
|
+
readonly developerId?: string;
|
|
46
80
|
readonly installationId?: string;
|
|
81
|
+
/** The model this session is on, when the collector learned one. */
|
|
82
|
+
readonly model?: string;
|
|
47
83
|
readonly timeoutMs: number;
|
|
48
84
|
/** Injected by tests; the real fetch otherwise. */
|
|
49
85
|
readonly fetchFn?: typeof fetch;
|
|
50
86
|
}
|
|
51
87
|
/** Everything the check needs to answer without touching ambient state. */
|
|
88
|
+
/** Where the turn is happening, when the working copy could say. */
|
|
89
|
+
interface EnforcementCheckout {
|
|
90
|
+
readonly repository: string;
|
|
91
|
+
readonly branch: string;
|
|
92
|
+
}
|
|
52
93
|
export interface EnforcementOptions {
|
|
53
94
|
readonly config: AgentWatchConfig;
|
|
54
95
|
readonly paths: AgentWatchPaths;
|
|
55
96
|
/** The identity to ask about, or undefined when this machine has none. */
|
|
56
97
|
readonly developerId?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Where the turn is happening, when the working copy could say.
|
|
100
|
+
*
|
|
101
|
+
* Both halves or neither: a branch alone identifies nothing, because every
|
|
102
|
+
* repository has a `main`, and the platform drops a half-stated pair anyway.
|
|
103
|
+
*/
|
|
104
|
+
readonly checkout?: EnforcementCheckout;
|
|
105
|
+
/**
|
|
106
|
+
* The model the turn is about, when the collector knows it.
|
|
107
|
+
*
|
|
108
|
+
* Absent is a supported answer, not a degraded one: an agent that never names
|
|
109
|
+
* its model is judged on the developer and the checkout alone, exactly as
|
|
110
|
+
* every collector was before this field existed.
|
|
111
|
+
*/
|
|
112
|
+
readonly model?: string;
|
|
113
|
+
/**
|
|
114
|
+
* What to present as the bearer: the install key or a cached access token,
|
|
115
|
+
* resolved by the caller without network work. Absent, the config's install
|
|
116
|
+
* key is used unless the identity sends as a device; a device with no cached
|
|
117
|
+
* token asks nothing and fails open as `token_unavailable`.
|
|
118
|
+
*/
|
|
119
|
+
readonly bearer?: string;
|
|
57
120
|
readonly now: () => Date;
|
|
58
121
|
readonly fetchFn?: typeof fetch;
|
|
59
122
|
}
|
|
123
|
+
export {};
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare const
|
|
3
|
-
/** Prompts the manual provider asks when it has no value yet. */
|
|
4
|
-
export declare const ENDPOINT_PROMPT = "AgentWatch backend URL: ";
|
|
5
|
-
export declare const TOKEN_PROMPT = "API token (optional, press Enter to skip): ";
|
|
6
|
-
export declare const RE_TRAILING_SLASHES: RegExp;
|
|
1
|
+
/** The organization id in an enrollment URL: a UUID, as the gateway's start route requires. */
|
|
2
|
+
export declare const RE_ORGANIZATION_ID: RegExp;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export const
|
|
3
|
-
/** Prompts the manual provider asks when it has no value yet. */
|
|
4
|
-
export const ENDPOINT_PROMPT = 'AgentWatch backend URL: ';
|
|
5
|
-
export const TOKEN_PROMPT = 'API token (optional, press Enter to skip): ';
|
|
6
|
-
export const RE_TRAILING_SLASHES = /\/+$/;
|
|
1
|
+
/** The organization id in an enrollment URL: a UUID, as the gateway's start route requires. */
|
|
2
|
+
export const RE_ORGANIZATION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EnrollmentInput, EnrollmentResult } from './types/enrollment.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Acquire the backend endpoint and token. Never prompts.
|
|
4
|
+
*
|
|
5
|
+
* No endpoint means the production Agent Watch backend. A host outside the
|
|
6
|
+
* Agent Watch allowlist needs an origin this machine already trusts, or the
|
|
7
|
+
* flag on this run. The URL is checked
|
|
8
|
+
* against the same rule the config schema applies on every later read, so a
|
|
9
|
+
* bearer can never be configured onto a destination the schema would then
|
|
10
|
+
* refuse to load.
|
|
11
|
+
*
|
|
12
|
+
* @param input - Flags and existing configuration.
|
|
13
|
+
* @returns The endpoint and token to configure.
|
|
14
|
+
* @throws When the endpoint is not usable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveEnrollment(input: EnrollmentInput): EnrollmentResult;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { deliverableOrigin, isAllowedHost } from '../config/schemas/config.schema.js';
|
|
2
|
+
import { DEFAULT_ENDPOINT, DELIVERABLE_URL_MESSAGE } from '../config/constants/config.constants.js';
|
|
3
|
+
import { normalizeEndpoint } from '../config/destination.js';
|
|
4
|
+
import { RE_ORGANIZATION_ID } from './constants/enrollment.constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* Acquire the backend endpoint and token. Never prompts.
|
|
7
|
+
*
|
|
8
|
+
* No endpoint means the production Agent Watch backend. A host outside the
|
|
9
|
+
* Agent Watch allowlist needs an origin this machine already trusts, or the
|
|
10
|
+
* flag on this run. The URL is checked
|
|
11
|
+
* against the same rule the config schema applies on every later read, so a
|
|
12
|
+
* bearer can never be configured onto a destination the schema would then
|
|
13
|
+
* refuse to load.
|
|
14
|
+
*
|
|
15
|
+
* @param input - Flags and existing configuration.
|
|
16
|
+
* @returns The endpoint and token to configure.
|
|
17
|
+
* @throws When the endpoint is not usable.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveEnrollment(input) {
|
|
20
|
+
const link = input.setupUrl ? parseEnrollmentUrl(input.setupUrl) : undefined;
|
|
21
|
+
if (link && input.token)
|
|
22
|
+
throw new Error('an enrollment URL signs in through the browser and takes no install key; drop --token / $AGENTWATCH_TOKEN');
|
|
23
|
+
if (link && input.endpoint)
|
|
24
|
+
throw new Error('an enrollment URL names its own backend; drop --endpoint');
|
|
25
|
+
const endpoint = link?.endpoint ?? input.endpoint ?? DEFAULT_ENDPOINT;
|
|
26
|
+
const trimmed = normalizeEndpoint(endpoint);
|
|
27
|
+
const origin = deliverableOrigin(trimmed);
|
|
28
|
+
if (!origin) {
|
|
29
|
+
throw new Error(`backend URL ${DELIVERABLE_URL_MESSAGE}, got ${endpoint}`);
|
|
30
|
+
}
|
|
31
|
+
// Before anything is written: a forged setup line must fail here, while the
|
|
32
|
+
// machine is still pointed where it was.
|
|
33
|
+
if (input.allowCustomEndpoint !== true && !isAllowedHost(trimmed, new Set(input.trustedOrigins))) {
|
|
34
|
+
throw new Error(`${origin} is not an Agent Watch host; nothing was written. If you trust it, re-run setup with --allow-custom-endpoint`);
|
|
35
|
+
}
|
|
36
|
+
return link ? { endpoint: trimmed, signIn: { organizationId: link.organizationId } } : { endpoint: trimmed, token: input.token };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Split an enrollment URL, `<backend>?organization=<uuid>`, into the backend and
|
|
40
|
+
* the organization's public id. The id is the only thing the link carries, so
|
|
41
|
+
* it is safe to share (SPEC R1).
|
|
42
|
+
*
|
|
43
|
+
* @param link - The URL given to `agentwatch setup`.
|
|
44
|
+
* @returns The backend origin and organization id.
|
|
45
|
+
* @throws When the link is not a URL or names no organization.
|
|
46
|
+
*/
|
|
47
|
+
function parseEnrollmentUrl(link) {
|
|
48
|
+
const url = URL.canParse(link) ? new URL(link) : undefined;
|
|
49
|
+
const organizationId = url?.searchParams.get('organization') ?? '';
|
|
50
|
+
if (!url || !RE_ORGANIZATION_ID.test(organizationId))
|
|
51
|
+
throw new Error('enrollment URL must look like https://<backend>?organization=<organization id>');
|
|
52
|
+
// A backend under a path prefix keeps it, as `--endpoint` does.
|
|
53
|
+
return { endpoint: url.origin + url.pathname.replace(/\/+$/, ''), organizationId };
|
|
54
|
+
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* setup.
|
|
5
|
-
*/
|
|
6
|
-
export type { EnrollmentInput, EnrollmentProvider, EnrollmentResult } from './types/enrollment.types.js';
|
|
7
|
-
export { ManualEnrollmentProvider } from './manual-enrollment.js';
|
|
1
|
+
/** Acquiring an endpoint and credentials. */
|
|
2
|
+
export type { EnrollmentInput, EnrollmentResult } from './types/enrollment.types.js';
|
|
3
|
+
export { resolveEnrollment } from './enrollment.js';
|
package/dist/enrollment/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { resolveEnrollment } from './enrollment.js';
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Endpoint and credential acquisition.
|
|
3
|
-
*
|
|
4
|
-
* The MVP ships a manual provider — the user types a backend URL — and a future
|
|
5
|
-
* RemoteEnrollmentProvider will implement `agentwatch setup <enrollment-url>`
|
|
6
|
-
* (fetch org config, register the device, receive installation credentials)
|
|
7
|
-
* without setup having to change.
|
|
8
|
-
*/
|
|
1
|
+
/** What `setup` has to work out before it can write a configuration. */
|
|
9
2
|
export interface EnrollmentInput {
|
|
10
3
|
/** URL passed to `agentwatch setup`, when any. */
|
|
11
4
|
readonly setupUrl?: string;
|
|
12
5
|
/** --endpoint flag, or the already-configured endpoint. */
|
|
13
6
|
readonly endpoint?: string;
|
|
7
|
+
/** `--allow-custom-endpoint`: the endpoint may be outside the Agent Watch hosts. */
|
|
8
|
+
readonly allowCustomEndpoint?: boolean;
|
|
9
|
+
/** Origins this machine already trusts (`customEndpoints`); enough without the flag. */
|
|
10
|
+
readonly trustedOrigins?: readonly string[];
|
|
14
11
|
/** --token flag, or the already-configured token. */
|
|
15
12
|
readonly token?: string;
|
|
16
|
-
/** Interactive prompt; undefined in non-interactive runs. */
|
|
17
|
-
readonly ask?: (question: string) => Promise<string>;
|
|
18
13
|
}
|
|
19
14
|
export interface EnrollmentResult {
|
|
20
15
|
readonly endpoint: string;
|
|
21
16
|
readonly token?: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
/** Set when `setup` was given an enrollment URL: the machine signs in instead of using a key. */
|
|
18
|
+
readonly signIn?: {
|
|
19
|
+
readonly organizationId: string;
|
|
20
|
+
};
|
|
25
21
|
}
|
|
@@ -12,3 +12,18 @@ export declare const HOME_PLACEHOLDER_PREFIX: string;
|
|
|
12
12
|
export declare const REPO_ROOT_PLACEHOLDER = ".";
|
|
13
13
|
/** Metadata key adapters use for the single primary file of a tool call. */
|
|
14
14
|
export declare const FILE_PATH_METADATA_KEY = "filePath";
|
|
15
|
+
/**
|
|
16
|
+
* A tool call's file outside every checkout, home-relative (`~/Documents/a.xlsx`).
|
|
17
|
+
* Its own key so `filePath` keeps meaning repo-relative.
|
|
18
|
+
*/
|
|
19
|
+
export declare const EXTERNAL_PATH_METADATA_KEY = "externalPath";
|
|
20
|
+
/**
|
|
21
|
+
* Metadata key naming the repository a tool call's file belongs to, relative
|
|
22
|
+
* to the cwd of the hook that resolved it.
|
|
23
|
+
*
|
|
24
|
+
* Local assembly state only: the turn tracker reads it to decide which
|
|
25
|
+
* repository a turn worked in, and it never reaches a product record.
|
|
26
|
+
*/
|
|
27
|
+
export declare const REPOSITORY_PATH_METADATA_KEY = "repositoryPath";
|
|
28
|
+
/** Shared empty answer for a batch with no per-file repository to resolve. */
|
|
29
|
+
export declare const EMPTY_REPOSITORIES: ReadonlyMap<string, never>;
|
|
@@ -13,3 +13,18 @@ export const HOME_PLACEHOLDER_PREFIX = `~${path.sep}`;
|
|
|
13
13
|
export const REPO_ROOT_PLACEHOLDER = '.';
|
|
14
14
|
/** Metadata key adapters use for the single primary file of a tool call. */
|
|
15
15
|
export const FILE_PATH_METADATA_KEY = 'filePath';
|
|
16
|
+
/**
|
|
17
|
+
* A tool call's file outside every checkout, home-relative (`~/Documents/a.xlsx`).
|
|
18
|
+
* Its own key so `filePath` keeps meaning repo-relative.
|
|
19
|
+
*/
|
|
20
|
+
export const EXTERNAL_PATH_METADATA_KEY = 'externalPath';
|
|
21
|
+
/**
|
|
22
|
+
* Metadata key naming the repository a tool call's file belongs to, relative
|
|
23
|
+
* to the cwd of the hook that resolved it.
|
|
24
|
+
*
|
|
25
|
+
* Local assembly state only: the turn tracker reads it to decide which
|
|
26
|
+
* repository a turn worked in, and it never reaches a product record.
|
|
27
|
+
*/
|
|
28
|
+
export const REPOSITORY_PATH_METADATA_KEY = 'repositoryPath';
|
|
29
|
+
/** Shared empty answer for a batch with no per-file repository to resolve. */
|
|
30
|
+
export const EMPTY_REPOSITORIES = new Map();
|
|
@@ -16,9 +16,13 @@ export declare const INTERNAL_HOOK_EVENT_TYPES: readonly ["session.started", "se
|
|
|
16
16
|
* layer is an overlay on work items, and a team with no tracker connected has
|
|
17
17
|
* none — the branches on a developer's machine are then the only evidence that
|
|
18
18
|
* a piece of work exists. It carries no usage and is not accounted.
|
|
19
|
+
*
|
|
20
|
+
* `session.billing` states how the session's developer pays, once, when the
|
|
21
|
+
* session opens: a turn that never reaches its Stop hook has no summary to
|
|
22
|
+
* carry that fact, and its calls would be priced as metered spend (AWT-476).
|
|
19
23
|
*/
|
|
20
|
-
export declare const PRODUCT_EVENT_TYPES: readonly ["llm.call", "turn.summary", "repo.snapshot"];
|
|
21
|
-
export declare const CANONICAL_EVENT_TYPES: readonly ["session.started", "session.ended", "prompt.submitted", "tool.started", "tool.completed", "tool.failed", "permission.requested", "file.read", "file.edited", "shell.started", "shell.completed", "mcp.started", "mcp.completed", "subagent.started", "subagent.completed", "generation.completed", "compaction.started", "compaction.completed", "agent.error", "agent.other", "llm.call", "turn.summary", "repo.snapshot"];
|
|
24
|
+
export declare const PRODUCT_EVENT_TYPES: readonly ["llm.call", "turn.summary", "repo.snapshot", "session.billing"];
|
|
25
|
+
export declare const CANONICAL_EVENT_TYPES: readonly ["session.started", "session.ended", "prompt.submitted", "tool.started", "tool.completed", "tool.failed", "permission.requested", "file.read", "file.edited", "shell.started", "shell.completed", "mcp.started", "mcp.completed", "subagent.started", "subagent.completed", "generation.completed", "compaction.started", "compaction.completed", "agent.error", "agent.other", "llm.call", "turn.summary", "repo.snapshot", "session.billing"];
|
|
22
26
|
/** O(1) membership for the hot path: queue drain checks this per entry. */
|
|
23
27
|
export declare const PRODUCT_EVENT_TYPE_SET: ReadonlySet<string>;
|
|
24
28
|
/** Canonical event types that close a turn. */
|
|
@@ -38,8 +38,12 @@ export const INTERNAL_HOOK_EVENT_TYPES = [
|
|
|
38
38
|
* layer is an overlay on work items, and a team with no tracker connected has
|
|
39
39
|
* none — the branches on a developer's machine are then the only evidence that
|
|
40
40
|
* a piece of work exists. It carries no usage and is not accounted.
|
|
41
|
+
*
|
|
42
|
+
* `session.billing` states how the session's developer pays, once, when the
|
|
43
|
+
* session opens: a turn that never reaches its Stop hook has no summary to
|
|
44
|
+
* carry that fact, and its calls would be priced as metered spend (AWT-476).
|
|
41
45
|
*/
|
|
42
|
-
export const PRODUCT_EVENT_TYPES = ['llm.call', 'turn.summary', 'repo.snapshot'];
|
|
46
|
+
export const PRODUCT_EVENT_TYPES = ['llm.call', 'turn.summary', 'repo.snapshot', 'session.billing'];
|
|
43
47
|
export const CANONICAL_EVENT_TYPES = [...INTERNAL_HOOK_EVENT_TYPES, ...PRODUCT_EVENT_TYPES];
|
|
44
48
|
/** O(1) membership for the hot path: queue drain checks this per entry. */
|
|
45
49
|
export const PRODUCT_EVENT_TYPE_SET = new Set(PRODUCT_EVENT_TYPES);
|