@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,8 +1,9 @@
|
|
|
1
1
|
import { compact } from '../core/object.js';
|
|
2
|
+
import { FAIL_OPEN_REASONS } from '../enforcement/constants/enforcement.constants.js';
|
|
2
3
|
import { deriveEventId, sha256Hex } from '../events/event-id.js';
|
|
3
4
|
import { EVENT_SCHEMA_VERSION } from '../events/constants/events.constants.js';
|
|
4
|
-
import {
|
|
5
|
-
import { MAX_TURN_FILES,
|
|
5
|
+
import { sanitizeText } from '../privacy/sanitizer.js';
|
|
6
|
+
import { MAX_SESSION_TITLE_LENGTH, MAX_TURN_FILES, MAX_TURN_TOOL_INPUTS, PROVIDER_LABELS, UNKNOWN_TOOL_NAME } from './constants/turns.constants.js';
|
|
6
7
|
/**
|
|
7
8
|
* Flatten one turn's accumulated state into the single product record the hook
|
|
8
9
|
* path emits.
|
|
@@ -16,7 +17,6 @@ import { MAX_TURN_FILES, PROMPT_JOIN_SEPARATOR, PROVIDER_LABELS, UNKNOWN_TOOL_NA
|
|
|
16
17
|
*/
|
|
17
18
|
export function buildTurnSummary(input) {
|
|
18
19
|
const files = collectToolUsage(input.tools);
|
|
19
|
-
const promptText = joinPrompts(input.prompts);
|
|
20
20
|
const startedAt = input.prompts[0]?.at;
|
|
21
21
|
const turnId = input.turnId ?? input.prompts.find((prompt) => prompt.turnId)?.turnId;
|
|
22
22
|
const jiraIds = ticketValues(input.featureCandidates);
|
|
@@ -41,17 +41,27 @@ export function buildTurnSummary(input) {
|
|
|
41
41
|
session_id: input.sessionId,
|
|
42
42
|
turn_id: turnId,
|
|
43
43
|
developer_id: input.developerId,
|
|
44
|
+
developer_name: input.developerName,
|
|
44
45
|
repository: input.git?.repository,
|
|
45
46
|
branch: input.git?.branch,
|
|
46
47
|
commit: input.git?.commit,
|
|
47
48
|
jira_ids: jiraIds.length > 0 ? jiraIds : undefined,
|
|
49
|
+
prompt_jira_ids: input.promptJiraIds?.length ? input.promptJiraIds : undefined,
|
|
48
50
|
files_changed: input.git?.changedFiles,
|
|
51
|
+
work_evidence: input.git?.repository ? input.workEvidence : undefined,
|
|
52
|
+
parent_session_id: input.parentSessionId,
|
|
53
|
+
content_hashes: input.contentHashes?.length ? input.contentHashes : undefined,
|
|
54
|
+
manifest_repository: input.manifestRepository,
|
|
49
55
|
files_touched: files.filesTouched.length > 0 ? files.filesTouched : undefined,
|
|
50
56
|
files_read: files.filesRead.length > 0 ? files.filesRead : undefined,
|
|
51
|
-
|
|
57
|
+
external_files_touched: files.externalTouched.length > 0 ? files.externalTouched : undefined,
|
|
58
|
+
external_files_read: files.externalRead.length > 0 ? files.externalRead : undefined,
|
|
52
59
|
prompt_evidence: input.prompts[0]?.evidence,
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
prompt_text: input.prompts[0]?.text,
|
|
61
|
+
session_name: boundSessionTitle(input.sessionTitles?.custom),
|
|
62
|
+
session_title: boundSessionTitle(input.sessionTitles?.generated),
|
|
63
|
+
tool_inputs: files.toolInputs.length > 0 ? files.toolInputs : undefined,
|
|
64
|
+
response_evidence: input.response,
|
|
55
65
|
tool_calls: input.tools.length,
|
|
56
66
|
tools_used: files.toolsUsed,
|
|
57
67
|
model: input.usage?.model ?? input.model,
|
|
@@ -62,60 +72,53 @@ export function buildTurnSummary(input) {
|
|
|
62
72
|
cache_creation_input_tokens: input.usage?.cacheCreationInputTokens,
|
|
63
73
|
output_tokens: input.usage?.outputTokens,
|
|
64
74
|
usage_status: input.usage ? 'provisional' : 'pending',
|
|
75
|
+
enforcement_fail_open_reason: failOpenReasonOf(input.prompts, input.endedAt),
|
|
65
76
|
started_at: startedAt,
|
|
66
77
|
ended_at: input.endedAt
|
|
67
78
|
});
|
|
68
79
|
}
|
|
69
80
|
/**
|
|
70
|
-
*
|
|
81
|
+
* Tool call counts, the files the turn read versus modified, and its tool inputs.
|
|
71
82
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* kept as the only description there is.
|
|
77
|
-
*
|
|
78
|
-
* @param summary - Summary about to be sent.
|
|
79
|
-
* @returns A copy whose evidence matches its own text.
|
|
80
|
-
*/
|
|
81
|
-
export function alignContentEvidence(summary) {
|
|
82
|
-
return {
|
|
83
|
-
...summary,
|
|
84
|
-
prompt_evidence: typeof summary.prompt === 'string' ? contentEvidence(summary.prompt) : summary.prompt_evidence,
|
|
85
|
-
response_evidence: typeof summary.response === 'string' ? contentEvidence(summary.response) : summary.response_evidence
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Tool call counts and the files the turn read versus modified.
|
|
90
|
-
*
|
|
91
|
-
* One pass over the records: tool counting and both file lists come from the
|
|
92
|
-
* same iteration rather than three filter/map chains (STYLEGUIDE 3.3). Each
|
|
93
|
-
* list stops growing at {@link MAX_TURN_FILES}, which is what keeps a
|
|
94
|
-
* file-heavy turn a summary with a truncated list rather than a summary the
|
|
95
|
-
* backend refuses whole.
|
|
83
|
+
* One pass over the records: tool counting, the file lists and the inputs come
|
|
84
|
+
* from the same iteration rather than chained filter/maps (STYLEGUIDE 3.3).
|
|
85
|
+
* Each list stops growing at its cap, which is what keeps a file-heavy turn a
|
|
86
|
+
* summary with a truncated list rather than a summary the backend refuses whole.
|
|
96
87
|
*
|
|
97
88
|
* @param tools - The turn's tool records.
|
|
98
|
-
* @returns Per-tool counts
|
|
89
|
+
* @returns Per-tool counts, the file lists and the inputs.
|
|
99
90
|
*/
|
|
100
91
|
function collectToolUsage(tools) {
|
|
101
92
|
const toolsUsed = {};
|
|
102
93
|
const filesTouched = new Set();
|
|
103
94
|
const filesRead = new Set();
|
|
95
|
+
const externalTouched = new Set();
|
|
96
|
+
const externalRead = new Set();
|
|
97
|
+
const toolInputs = [];
|
|
104
98
|
for (const tool of tools) {
|
|
105
99
|
const name = tool.tool ?? UNKNOWN_TOOL_NAME;
|
|
106
100
|
toolsUsed[name] = (toolsUsed[name] ?? 0) + 1;
|
|
107
|
-
if (
|
|
108
|
-
|
|
101
|
+
if (tool.input && toolInputs.length < MAX_TURN_TOOL_INPUTS)
|
|
102
|
+
toolInputs.push(tool.input);
|
|
109
103
|
// files_touched is documented as files the agent MODIFIED; pure reads get
|
|
110
104
|
// their own list. Legacy records without an access marker stay in
|
|
111
105
|
// files_touched (the historical behavior) rather than being dropped.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
const read = tool.access === 'read';
|
|
107
|
+
// A file outside every checkout keeps its bare basename in files_touched, as
|
|
108
|
+
// it always has, and adds its home-relative path to the external list.
|
|
109
|
+
if (tool.externalPath)
|
|
110
|
+
addCapped(read ? externalRead : externalTouched, tool.externalPath);
|
|
111
|
+
if (tool.filePath)
|
|
112
|
+
addCapped(read ? filesRead : filesTouched, tool.filePath);
|
|
117
113
|
}
|
|
118
|
-
return {
|
|
114
|
+
return {
|
|
115
|
+
toolsUsed,
|
|
116
|
+
filesTouched: [...filesTouched],
|
|
117
|
+
filesRead: [...filesRead],
|
|
118
|
+
externalTouched: [...externalTouched],
|
|
119
|
+
externalRead: [...externalRead],
|
|
120
|
+
toolInputs
|
|
121
|
+
};
|
|
119
122
|
}
|
|
120
123
|
/**
|
|
121
124
|
* Record a path while the list still has room for one.
|
|
@@ -132,20 +135,53 @@ function addCapped(paths, filePath) {
|
|
|
132
135
|
paths.add(filePath);
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
135
|
-
*
|
|
138
|
+
* A title fit to send: scrubbed whole, then cut.
|
|
139
|
+
*
|
|
140
|
+
* In that order, or a credential the cut runs through keeps a prefix no
|
|
141
|
+
* pattern matches. The cut stops before a code point that would cross the
|
|
142
|
+
* bound, so an emoji is never split into a lone surrogate.
|
|
143
|
+
*
|
|
144
|
+
* @param title - The title as the agent holds it.
|
|
145
|
+
* @returns The bounded title, or undefined when nothing is left.
|
|
146
|
+
*/
|
|
147
|
+
function boundSessionTitle(title) {
|
|
148
|
+
const scrubbed = title === undefined ? '' : sanitizeText(title).trim();
|
|
149
|
+
if (scrubbed.length <= MAX_SESSION_TITLE_LENGTH)
|
|
150
|
+
return scrubbed || undefined;
|
|
151
|
+
let out = '';
|
|
152
|
+
for (const char of scrubbed) {
|
|
153
|
+
if (out.length + char.length > MAX_SESSION_TITLE_LENGTH)
|
|
154
|
+
break;
|
|
155
|
+
out += char;
|
|
156
|
+
}
|
|
157
|
+
return out.trimEnd() || undefined;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Why the turn ran unchecked, if the prompt that opened it did.
|
|
161
|
+
*
|
|
162
|
+
* The newest prompt submitted before this Stop, and only that one. Without a
|
|
163
|
+
* turn id a Stop collects every record the session left: one from a prompt
|
|
164
|
+
* interrupted before its own Stop, and one from the next prompt racing in
|
|
165
|
+
* before this close. Neither prompt's fail-open is a fact about this turn.
|
|
136
166
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
167
|
+
* Read back from a file on disk, so checked against the closed set rather than
|
|
168
|
+
* trusted: an unrecognised value is dropped, not sent. Sending nothing is the
|
|
169
|
+
* contract's word for "no reason known".
|
|
170
|
+
*
|
|
171
|
+
* @param prompts - The turn's prompt records, oldest first.
|
|
172
|
+
* @param endedAt - The Stop's timestamp; ISO strings, compared as the tracker sorts them.
|
|
173
|
+
* @returns The recognised reason, or undefined.
|
|
139
174
|
*/
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
for (const prompt of prompts) {
|
|
143
|
-
if (
|
|
144
|
-
|
|
175
|
+
function failOpenReasonOf(prompts, endedAt) {
|
|
176
|
+
// A turn holds a prompt or two, so a reversed copy costs nothing.
|
|
177
|
+
for (const prompt of [...prompts].reverse()) {
|
|
178
|
+
if (prompt.at > endedAt)
|
|
179
|
+
continue;
|
|
180
|
+
if (prompt.failOpenReason === undefined || !FAIL_OPEN_REASONS.has(prompt.failOpenReason))
|
|
181
|
+
return undefined;
|
|
182
|
+
return prompt.failOpenReason;
|
|
145
183
|
}
|
|
146
|
-
|
|
147
|
-
return undefined;
|
|
148
|
-
return present.join(PROMPT_JOIN_SEPARATOR);
|
|
184
|
+
return undefined;
|
|
149
185
|
}
|
|
150
186
|
/**
|
|
151
187
|
* Ticket keys out of mixed feature evidence.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Env } from '../core/types/core.types.js';
|
|
1
2
|
import type { TurnSummaryEvent } from './types/turn-summary.types.js';
|
|
2
|
-
import type { TrackTurnOptions } from './types/turn-tracker.types.js';
|
|
3
|
-
export type { TrackTurnOptions } from './types/turn-tracker.types.js';
|
|
3
|
+
import type { TrackTurnOptions, TurnOutcome } from './types/turn-tracker.types.js';
|
|
4
|
+
export type { TrackTurnOptions, TurnOutcome } from './types/turn-tracker.types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Accumulate turn state across hook invocations and close the turn on
|
|
6
7
|
* `generation.completed`, producing one flat summary.
|
|
@@ -12,3 +13,21 @@ export type { TrackTurnOptions } from './types/turn-tracker.types.js';
|
|
|
12
13
|
* @returns The turn summary when this payload closed a turn.
|
|
13
14
|
*/
|
|
14
15
|
export declare function trackTurn(options: TrackTurnOptions): Promise<TurnSummaryEvent | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* {@link trackTurn}, with the local root of the checkout the summary reported
|
|
18
|
+
* beside it: the pipeline takes the repository snapshot there. The root never
|
|
19
|
+
* goes on the summary.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The payload's events, config, paths and clock.
|
|
22
|
+
* @returns The summary when this payload closed a turn, and its checkout's root.
|
|
23
|
+
*/
|
|
24
|
+
export declare function trackTurnOutcome(options: TrackTurnOptions): Promise<TurnOutcome>;
|
|
25
|
+
/**
|
|
26
|
+
* Which surface the turn happened on.
|
|
27
|
+
*
|
|
28
|
+
* @param provider - Internal provider id.
|
|
29
|
+
* @param env - Environment; Claude Code reports its own entrypoint there.
|
|
30
|
+
* @param rawPayload - Hook payload; Codex only names its originator in the transcript it points at.
|
|
31
|
+
* @returns The surface label.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveSurface(provider: string, env: Env, rawPayload?: unknown): Promise<string>;
|