@agent-watch-ai/edge 0.7.1 → 0.7.3
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 +29 -0
- package/README.md +2 -1
- package/dist/capture/capture-env.d.ts +3 -3
- package/dist/capture/capture-env.js +5 -5
- package/dist/capture/captured-step.js +1 -1
- package/dist/cli/constants/cli.constants.js +1 -1
- package/dist/cli/setup.js +26 -3
- package/dist/cli/types/cli.types.d.ts +2 -0
- package/dist/cli/uninstall.js +1 -1
- package/dist/cli.js +7 -4
- package/dist/config/config.d.ts +8 -0
- package/dist/config/config.js +10 -0
- package/dist/config/constants/config.constants.d.ts +5 -0
- package/dist/config/constants/config.constants.js +5 -0
- package/dist/config/repo-config.js +7 -2
- package/dist/config/schemas/config.schema.d.ts +4 -0
- package/dist/config/schemas/config.schema.js +7 -1
- package/dist/enrollment/enrollment.js +7 -4
- package/dist/pipeline/hook-pipeline.js +3 -1
- package/dist/providers/antigravity/antigravity.adapter.d.ts +14 -0
- package/dist/providers/antigravity/antigravity.adapter.js +86 -18
- package/dist/providers/antigravity/antigravity.provider.js +7 -4
- package/dist/providers/antigravity/constants/antigravity.constants.d.ts +10 -0
- package/dist/providers/antigravity/constants/antigravity.constants.js +10 -0
- package/dist/providers/antigravity/schemas/antigravity.schema.js +7 -13
- package/dist/providers/claude/claude.otel.d.ts +33 -1
- package/dist/providers/claude/claude.otel.js +81 -12
- package/dist/providers/claude/claude.provider.js +3 -1
- package/dist/providers/codex/codex.capture.d.ts +1 -1
- package/dist/providers/codex/codex.capture.js +3 -3
- package/dist/providers/codex/codex.otel.js +2 -2
- package/dist/providers/codex/codex.provider.js +2 -1
- package/dist/providers/gemini/gemini.capture.js +2 -2
- package/dist/providers/gemini/gemini.otel.js +2 -2
- package/dist/providers/gemini/gemini.provider.js +2 -1
- package/dist/providers/shared/terminal-capture.js +3 -3
- package/dist/turns/antigravity-transcript.d.ts +40 -0
- package/dist/turns/antigravity-transcript.js +102 -0
- package/dist/turns/claude-transcript.d.ts +35 -1
- package/dist/turns/claude-transcript.js +185 -2
- package/dist/turns/codex-transcript.d.ts +22 -1
- package/dist/turns/codex-transcript.js +161 -2
- package/dist/turns/constants/turns.constants.d.ts +51 -0
- package/dist/turns/constants/turns.constants.js +51 -0
- package/dist/turns/gemini-transcript.d.ts +17 -1
- package/dist/turns/gemini-transcript.js +36 -2
- package/dist/turns/transcript.d.ts +31 -1
- package/dist/turns/transcript.js +74 -0
- package/dist/turns/turn-state.d.ts +18 -1
- package/dist/turns/turn-state.js +45 -10
- package/dist/turns/turn-tracker.js +154 -16
- package/dist/turns/types/transcript.types.d.ts +25 -0
- package/dist/turns/types/turn-provider.types.d.ts +18 -1
- package/dist/turns/types/turn-state.types.d.ts +10 -0
- package/docs/DATA_HANDLING.md +3 -0
- package/package.json +1 -1
|
@@ -2,8 +2,9 @@ import path from 'node:path';
|
|
|
2
2
|
import { pollUntil } from '../core/async.js';
|
|
3
3
|
import { debugLog } from '../core/logger.js';
|
|
4
4
|
import { asRecord, compact } from '../core/object.js';
|
|
5
|
+
import { add } from '../core/number.js';
|
|
5
6
|
import { billingModeOf } from '../billing/billing-mode.js';
|
|
6
|
-
import { sha256Hex } from '../events/event-id.js';
|
|
7
|
+
import { deriveEventId, sha256Hex } from '../events/event-id.js';
|
|
7
8
|
import { REPOSITORY_PATH_METADATA_KEY } from '../events/constants/enrich.constants.js';
|
|
8
9
|
import { codeStateAt } from '../git/code-state.js';
|
|
9
10
|
import { developerDisplayName, developerIdentity } from '../git/git-context.js';
|
|
@@ -15,6 +16,7 @@ import { MAX_WORK_CHANGED_FILES } from '../git/constants/git.constants.js';
|
|
|
15
16
|
import { PARENT_SESSION_VAR, RE_PARENT_SESSION_ID, CLOUD_SURFACE, DEFAULT_SURFACE, EXTERNAL_PATH_KEY, FILE_PATH_KEY, LOCK_KEY_HASH_LENGTH, MAX_PROMPT_TEXT_LENGTH, MAX_TOOL_INPUT_LENGTH, PROMPT_EVIDENCE_KEY, PROMPT_JIRA_IDS_KEY, PROMPT_TEXT_KEY, RESPONSE_EVIDENCE_KEY, INT32_MAX, INT32_MIN, RE_SHA256_HEX, TOOL_CALL_KEY, TOOL_COMPLETION_TYPES, TOOL_START_TYPES, TRANSCRIPT_PATH_KEY, TURN_STATE_TTL_MS, USAGE_LOCK_POLL_MS, USAGE_LOCK_WAIT_MS, USAGE_RETRY } from './constants/turns.constants.js';
|
|
16
17
|
import { resolveFileIdentity } from './file-identity.js';
|
|
17
18
|
import { toSessionMode, TurnStateStore } from './turn-state.js';
|
|
19
|
+
import { mergeUsage } from './transcript.js';
|
|
18
20
|
import { buildToolEvents, callKey } from './tool-events.js';
|
|
19
21
|
import { buildTurnSummary } from './turn-summary.js';
|
|
20
22
|
import { rememberInheritance, retryInheritance } from './inherited-checkout.js';
|
|
@@ -101,6 +103,8 @@ async function processEvent(store, sessionId, event, options) {
|
|
|
101
103
|
await store.sweep(TURN_STATE_TTL_MS);
|
|
102
104
|
return outcome;
|
|
103
105
|
}
|
|
106
|
+
if (type === 'subagent.completed')
|
|
107
|
+
return lateSubagentUsage(store, sessionId, event, options);
|
|
104
108
|
if (type === 'session.ended') {
|
|
105
109
|
await store.endSession(sessionId);
|
|
106
110
|
await store.sweep(TURN_STATE_TTL_MS);
|
|
@@ -422,6 +426,20 @@ async function closeTurnLocked(store, sessionId, stopEvent, options, readOnly =
|
|
|
422
426
|
await store.remove(consumable([...mine, ...late], collected).map((entry) => entry.file));
|
|
423
427
|
if (!readOnly && stopTurnId !== undefined)
|
|
424
428
|
await store.markTurnClosed(sessionId, stopTurnId);
|
|
429
|
+
const outcome = { summary: sanitizeValue(summary), workRoot: work.root, capture: work.capture };
|
|
430
|
+
// Kept for a background subagent of this turn that is still running (a
|
|
431
|
+
// provider that reads none keeps nothing); its own catch, as below. Not for a
|
|
432
|
+
// turn whose usage was never read (lock timeout): adding a subagent's tokens
|
|
433
|
+
// alone would state a provisional total the parent's are missing from.
|
|
434
|
+
// Nor for a turn whose summary was never sent (`emit.turnSummaries` off).
|
|
435
|
+
if (!readOnly && stopTurnId !== undefined && usage && options.config.emit.turnSummaries && options.provider.readSubagentUsage) {
|
|
436
|
+
// Without the transient fields: core relays a turn's prompt text and tool
|
|
437
|
+
// inputs to an LLM read, which a re-send must not pay for twice, and stores neither.
|
|
438
|
+
const kept = { ...outcome, untilIso: window.untilIso, summary: compact({ ...outcome.summary, prompt_text: undefined, tool_inputs: undefined }) };
|
|
439
|
+
await store.rememberSentTurn(sessionId, stopTurnId, kept).catch((error) => {
|
|
440
|
+
debugLog('could not keep the turn summary:', error);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
425
443
|
// The next turn that changes nothing carries this one; the prompt gate asks it too.
|
|
426
444
|
if (!readOnly && work.evidence === 'changed' && work.root && work.git?.repository) {
|
|
427
445
|
// After the records are consumed, so a failure here must not cost the summary.
|
|
@@ -429,7 +447,7 @@ async function closeTurnLocked(store, sessionId, stopEvent, options, readOnly =
|
|
|
429
447
|
debugLog('could not record the work checkout:', error);
|
|
430
448
|
});
|
|
431
449
|
}
|
|
432
|
-
return
|
|
450
|
+
return outcome;
|
|
433
451
|
}
|
|
434
452
|
/**
|
|
435
453
|
* Remember the checkout this turn changed, with its branch and the files the
|
|
@@ -559,22 +577,22 @@ function resolveWindow(all, mine, stopAt) {
|
|
|
559
577
|
async function resolveAndClaimUsage(store, sessionId, stopEvent, options, window, readOnly) {
|
|
560
578
|
if (!options.provider.readTurnUsage || window.startedAt === undefined)
|
|
561
579
|
return undefined;
|
|
580
|
+
const turnId = stopEvent.session.turnId;
|
|
562
581
|
if (readOnly) {
|
|
563
|
-
return readTranscriptUsage(options, window, await store.claimedMessageIds(sessionId));
|
|
582
|
+
return readTranscriptUsage(options, window, await store.claimedMessageIds(sessionId), turnId);
|
|
564
583
|
}
|
|
565
|
-
const
|
|
566
|
-
const release = await waitForUsageLock(options, lockName);
|
|
584
|
+
const release = await waitForUsageLock(options, sessionId);
|
|
567
585
|
if (!release) {
|
|
568
586
|
debugLog('turn usage lock timed out; omitting transcript usage');
|
|
569
587
|
return undefined;
|
|
570
588
|
}
|
|
571
589
|
try {
|
|
572
590
|
const claimed = await store.claimedMessageIds(sessionId);
|
|
573
|
-
const usage = await readTranscriptUsage(options, window, claimed);
|
|
591
|
+
const usage = await readTranscriptUsage(options, window, claimed, turnId);
|
|
574
592
|
if (usage?.messageIds && usage.messageIds.length > 0) {
|
|
575
593
|
// Old Claude versions have no prompt id; the Stop event id still gives
|
|
576
594
|
// every completed turn a distinct ledger file.
|
|
577
|
-
await store.claimUsage(sessionId,
|
|
595
|
+
await store.claimUsage(sessionId, turnId ?? stopEvent.id, usage.messageIds);
|
|
578
596
|
}
|
|
579
597
|
return usage;
|
|
580
598
|
}
|
|
@@ -586,26 +604,146 @@ async function resolveAndClaimUsage(store, sessionId, stopEvent, options, window
|
|
|
586
604
|
* Acquire the session usage lock, waiting a bounded time.
|
|
587
605
|
*
|
|
588
606
|
* @param options - Tracking options supplying the locks directory and clock.
|
|
589
|
-
* @param
|
|
607
|
+
* @param sessionId - The session the lock serializes claims for.
|
|
590
608
|
* @returns The release function, or undefined on timeout.
|
|
591
609
|
*/
|
|
592
|
-
function waitForUsageLock(options,
|
|
610
|
+
function waitForUsageLock(options, sessionId) {
|
|
611
|
+
const lockName = `turn-usage-${sha256Hex(sessionId).slice(0, LOCK_KEY_HASH_LENGTH)}`;
|
|
593
612
|
return pollUntil(() => acquireLock(options.locksDir, lockName, options.env.now), USAGE_LOCK_WAIT_MS, USAGE_LOCK_POLL_MS);
|
|
594
613
|
}
|
|
595
614
|
/**
|
|
596
|
-
* Run this provider's transcript
|
|
615
|
+
* Run this provider's transcript readers over the turn: its own transcript in
|
|
616
|
+
* the window, then its subagents' by turn id, excluding what the first counted.
|
|
597
617
|
*
|
|
598
618
|
* @param options - Tracking options carrying the raw payload.
|
|
599
619
|
* @param window - Bounds this turn may claim from.
|
|
600
620
|
* @param excludeMessageIds - Messages other turns already claimed.
|
|
621
|
+
* @param turnId - The turn's id, when it has one.
|
|
601
622
|
* @returns The usage, or undefined when the provider reports none.
|
|
602
623
|
*/
|
|
603
|
-
async function readTranscriptUsage(options, window, excludeMessageIds) {
|
|
604
|
-
const
|
|
605
|
-
const transcriptPath =
|
|
606
|
-
if (!
|
|
624
|
+
async function readTranscriptUsage(options, window, excludeMessageIds, turnId) {
|
|
625
|
+
const { readTurnUsage, readSubagentUsage } = options.provider;
|
|
626
|
+
const transcriptPath = transcriptPathOf(options);
|
|
627
|
+
if (!readTurnUsage || window.startedAt === undefined || typeof transcriptPath !== 'string')
|
|
628
|
+
return undefined;
|
|
629
|
+
const parent = await readTurnUsage(transcriptPath, window.startedAt, USAGE_RETRY, window.untilIso, excludeMessageIds);
|
|
630
|
+
if (!readSubagentUsage)
|
|
631
|
+
return parent;
|
|
632
|
+
const turn = { turnId, startedAt: window.startedAt, untilIso: window.untilIso };
|
|
633
|
+
const subagents = await readSubagentUsage(options.rawPayload, turn, new Set([...excludeMessageIds, ...(parent?.messageIds ?? [])]));
|
|
634
|
+
return mergeUsage(parent, subagents);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* The transcript this hook names: the provider's own reading, else the
|
|
638
|
+
* top-level `transcript_path` every other agent uses.
|
|
639
|
+
*
|
|
640
|
+
* @param options - Tracking options carrying the provider and raw payload.
|
|
641
|
+
* @returns The path, or undefined when the payload names none.
|
|
642
|
+
*/
|
|
643
|
+
function transcriptPathOf(options) {
|
|
644
|
+
return options.provider.transcriptPath?.(options.rawPayload, options.env) ?? asRecord(options.rawPayload)?.[TRANSCRIPT_PATH_KEY];
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* A subagent's own stop, for a turn that already closed: claim what that
|
|
648
|
+
* subagent recorded since the turn's read and send the turn again with it added.
|
|
649
|
+
* The turn is the one the subagent's lines name, which need not be the one its
|
|
650
|
+
* stop names (Claude names the current prompt).
|
|
651
|
+
*
|
|
652
|
+
* A background subagent keeps running after the prompt that launched it has
|
|
653
|
+
* its Stop, and its usage would otherwise be no turn's. Core restates a turn
|
|
654
|
+
* on a resend with the same turn id (tokens replaced, every other field kept
|
|
655
|
+
* when the resend states it too), so the resend is the summary the turn went
|
|
656
|
+
* out with, totals raised, under a new event id. A turn still open reads its
|
|
657
|
+
* subagents at its own Stop, so a foreground subagent's stop sends nothing.
|
|
658
|
+
*
|
|
659
|
+
* ponytail: a subagent stopping between the turn's claim and the summary being
|
|
660
|
+
* kept finds nothing to add to, and what it wrote after the turn's read stays
|
|
661
|
+
* unclaimed; native OTel still counts it. Keep the summary under the usage
|
|
662
|
+
* lock if that window shows up.
|
|
663
|
+
*
|
|
664
|
+
* @param store - Per-session state store.
|
|
665
|
+
* @param sessionId - Provider session id.
|
|
666
|
+
* @param event - The subagent's stop.
|
|
667
|
+
* @param options - Tracking options carrying the raw payload.
|
|
668
|
+
* @returns The re-sent summary, or undefined when there is nothing late to add.
|
|
669
|
+
*/
|
|
670
|
+
async function lateSubagentUsage(store, sessionId, event, options) {
|
|
671
|
+
const { readSubagentUsage, readSubagentTurnIds } = options.provider;
|
|
672
|
+
if (!readSubagentUsage)
|
|
673
|
+
return undefined;
|
|
674
|
+
const candidates = readSubagentTurnIds ? await readSubagentTurnIds(options.rawPayload) : [event.session.turnId];
|
|
675
|
+
// ponytail: one summary per hook, so a subagent resumed across two closed
|
|
676
|
+
// turns re-sends the first with late lines; the other's stay unclaimed.
|
|
677
|
+
for (const turnId of candidates) {
|
|
678
|
+
const resent = turnId === undefined ? undefined : await resendWithLateUsage(store, sessionId, turnId, readSubagentUsage, options);
|
|
679
|
+
if (resent)
|
|
680
|
+
return resent;
|
|
681
|
+
}
|
|
682
|
+
return undefined;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Claim one closed turn's late subagent usage and build its re-send.
|
|
686
|
+
*
|
|
687
|
+
* @param store - Per-session state store.
|
|
688
|
+
* @param sessionId - Provider session id.
|
|
689
|
+
* @param turnId - A turn the subagent's lines name.
|
|
690
|
+
* @param read - The provider's subagent reader.
|
|
691
|
+
* @param options - Tracking options carrying the raw payload.
|
|
692
|
+
* @returns The re-send, or undefined when the turn is open, kept nothing, or has nothing late.
|
|
693
|
+
*/
|
|
694
|
+
async function resendWithLateUsage(store, sessionId, turnId, read, options) {
|
|
695
|
+
// Checked before the lock: most subagents stop inside their turn.
|
|
696
|
+
if (!(await store.readSentTurn(sessionId, turnId)))
|
|
697
|
+
return undefined;
|
|
698
|
+
const release = await waitForUsageLock(options, sessionId);
|
|
699
|
+
if (!release)
|
|
607
700
|
return undefined;
|
|
608
|
-
|
|
701
|
+
try {
|
|
702
|
+
const sent = await store.readSentTurn(sessionId, turnId);
|
|
703
|
+
if (!sent)
|
|
704
|
+
return undefined;
|
|
705
|
+
// Bounded where the turn's own window was: a window reader must not take a later turn's rows.
|
|
706
|
+
const turn = { turnId, startedAt: sent.summary.started_at ?? sent.summary.ended_at, untilIso: sent.untilIso ?? sent.summary.ended_at };
|
|
707
|
+
const usage = await read(options.rawPayload, turn, await store.claimedMessageIds(sessionId));
|
|
708
|
+
if (!usage?.messageIds?.length)
|
|
709
|
+
return undefined;
|
|
710
|
+
const resent = { ...sent, summary: withLateUsage(sent.summary, usage) };
|
|
711
|
+
await store.claimUsage(sessionId, turnId, usage.messageIds);
|
|
712
|
+
// Its own catch: the claim is written, so the re-send must still go out.
|
|
713
|
+
await store.rememberSentTurn(sessionId, turnId, resent).catch((error) => {
|
|
714
|
+
debugLog('could not keep the re-sent turn summary:', error);
|
|
715
|
+
});
|
|
716
|
+
return resent;
|
|
717
|
+
}
|
|
718
|
+
finally {
|
|
719
|
+
await release();
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* A sent summary with late subagent usage added to its totals.
|
|
724
|
+
*
|
|
725
|
+
* @param summary - The summary the turn last went out with.
|
|
726
|
+
* @param usage - Usage no turn has claimed yet.
|
|
727
|
+
* @returns The summary to re-send, under an id of its own.
|
|
728
|
+
*/
|
|
729
|
+
function withLateUsage(summary, usage) {
|
|
730
|
+
return compact({
|
|
731
|
+
...summary,
|
|
732
|
+
id: deriveEventId({
|
|
733
|
+
provider: summary.provider,
|
|
734
|
+
providerEventType: 'turn.summary',
|
|
735
|
+
sessionId: summary.session_id,
|
|
736
|
+
turnId: summary.turn_id,
|
|
737
|
+
timestamp: summary.ended_at,
|
|
738
|
+
payloadFingerprint: sha256Hex(JSON.stringify([summary.id, ...(usage.messageIds ?? [])]))
|
|
739
|
+
}),
|
|
740
|
+
model: summary.model ?? usage.model,
|
|
741
|
+
input_tokens: add(summary.input_tokens, usage.inputTokens),
|
|
742
|
+
cached_input_tokens: add(summary.cached_input_tokens, usage.cachedInputTokens),
|
|
743
|
+
cache_creation_input_tokens: add(summary.cache_creation_input_tokens, usage.cacheCreationInputTokens),
|
|
744
|
+
output_tokens: add(summary.output_tokens, usage.outputTokens),
|
|
745
|
+
usage_status: 'provisional'
|
|
746
|
+
});
|
|
609
747
|
}
|
|
610
748
|
/**
|
|
611
749
|
* The session's name and generated title, when the config lets them leave the machine.
|
|
@@ -633,7 +771,7 @@ async function resolveSessionTitles(store, sessionId, options, readOnly) {
|
|
|
633
771
|
const { readSessionTitles, readTranscriptTitles } = options.provider;
|
|
634
772
|
if (readSessionTitles)
|
|
635
773
|
return safeNativeTitles(() => readSessionTitles(options.env, sessionId));
|
|
636
|
-
const transcriptPath =
|
|
774
|
+
const transcriptPath = transcriptPathOf(options);
|
|
637
775
|
if (!readTranscriptTitles || typeof transcriptPath !== 'string')
|
|
638
776
|
return {};
|
|
639
777
|
try {
|
|
@@ -40,11 +40,36 @@ export interface ReadTurnUsageRetry {
|
|
|
40
40
|
* @param excludeMessageIds - Messages another turn has already claimed.
|
|
41
41
|
*/
|
|
42
42
|
export type TranscriptReader = (transcriptPath: string, startedAt: string, retry: ReadTurnUsageRetry, untilIso: string, excludeMessageIds: ReadonlySet<string>) => Promise<TurnUsage | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Reads the usage a turn's subagents recorded in their own transcripts.
|
|
45
|
+
*
|
|
46
|
+
* Each agent says which lines are the turn's: by the prompt id a subagent's
|
|
47
|
+
* lines name where it writes one (Claude Code), else by the turn's window.
|
|
48
|
+
*
|
|
49
|
+
* @param payload - The raw hook payload: a Stop names the parent transcript, a
|
|
50
|
+
* subagent's own stop also names that subagent.
|
|
51
|
+
* @param turn - The turn: its id when it has one, and its window.
|
|
52
|
+
* @param excludeMessageIds - Messages already claimed, by any turn or by the parent's own read.
|
|
53
|
+
*/
|
|
54
|
+
export type SubagentUsageReader = (payload: unknown, turn: SubagentTurn, excludeMessageIds: ReadonlySet<string>) => Promise<TurnUsage | undefined>;
|
|
55
|
+
/** The turn a subagent reader reads for. */
|
|
56
|
+
export interface SubagentTurn {
|
|
57
|
+
readonly turnId?: string;
|
|
58
|
+
/** When the turn began; a file not written since holds none of it. */
|
|
59
|
+
readonly startedAt: string;
|
|
60
|
+
/** Upper bound of the turn's window. */
|
|
61
|
+
readonly untilIso?: string;
|
|
62
|
+
}
|
|
43
63
|
/** One assistant entry's usage, keyed by message id during accumulation. */
|
|
44
64
|
export interface TranscriptUsageEntry {
|
|
45
65
|
readonly model?: string;
|
|
46
66
|
readonly usage: Readonly<Record<string, unknown>>;
|
|
47
67
|
}
|
|
68
|
+
/** A transcript's tail and the byte offset of its first kept line. */
|
|
69
|
+
export interface TailSnapshot {
|
|
70
|
+
readonly raw: string;
|
|
71
|
+
readonly start: number;
|
|
72
|
+
}
|
|
48
73
|
/** A transcript tail and the turn window to filter its lines by, both bounds in epoch ms. */
|
|
49
74
|
export interface WindowedTail {
|
|
50
75
|
/** The tail text. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BillingSource } from '../../billing/types/billing.types.js';
|
|
2
2
|
import type { Env } from '../../core/types/core.types.js';
|
|
3
|
-
import type { SessionTitles, TranscriptReader } from './transcript.types.js';
|
|
3
|
+
import type { SessionTitles, SubagentUsageReader, TranscriptReader } from './transcript.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* What the turn tracker asks of the agent a hook came from.
|
|
6
6
|
*
|
|
@@ -12,6 +12,23 @@ export interface TurnProvider extends BillingSource {
|
|
|
12
12
|
readonly id: string;
|
|
13
13
|
/** Provisional usage out of the transcript the hook payload points at. */
|
|
14
14
|
readonly readTurnUsage?: TranscriptReader;
|
|
15
|
+
/**
|
|
16
|
+
* Where this agent's payload names its transcript, when not at the top-level
|
|
17
|
+
* `transcript_path` (Antigravity nests or camel-cases it, or names none).
|
|
18
|
+
*/
|
|
19
|
+
readonly transcriptPath?: (rawPayload: unknown, env: Env) => string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Provisional usage of the turn's subagents, out of their own transcripts
|
|
22
|
+
* (Claude Code). Claimed with the turn's own usage; a background subagent that
|
|
23
|
+
* finishes after the turn closed re-sends the turn with its usage added.
|
|
24
|
+
*/
|
|
25
|
+
readonly readSubagentUsage?: SubagentUsageReader;
|
|
26
|
+
/**
|
|
27
|
+
* The turns a stopping subagent's own lines name, oldest first, when its stop
|
|
28
|
+
* payload does not name the turn that launched it (Claude Code). Without it,
|
|
29
|
+
* the stop's own turn id is the only one tried.
|
|
30
|
+
*/
|
|
31
|
+
readonly readSubagentTurnIds?: (payload: unknown) => Promise<readonly string[]>;
|
|
15
32
|
/**
|
|
16
33
|
* The session's titles out of the agent's own local store (Codex, Cursor),
|
|
17
34
|
* read only under `capture.sessionTitle`.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
|
|
2
2
|
import type { ContentEvidence } from '../../events/types/events.types.js';
|
|
3
3
|
import type { Fingerprint } from '../../git/types/git.types.js';
|
|
4
|
+
import type { CaptureConfig } from '../../config/types/config.types.js';
|
|
5
|
+
import type { TurnSummaryEvent } from './turn-summary.types.js';
|
|
4
6
|
/** A prompt the developer submitted: when, its length and SHA-256, and its text when `promptText` is on. */
|
|
5
7
|
export interface PromptRecord {
|
|
6
8
|
readonly kind: 'prompt';
|
|
@@ -182,3 +184,11 @@ export interface TurnStateEntry {
|
|
|
182
184
|
readonly file: string;
|
|
183
185
|
readonly record: TurnRecord;
|
|
184
186
|
}
|
|
187
|
+
/** A turn's summary as it went out, with the checkout it was routed by (`TurnOutcome`). */
|
|
188
|
+
export interface SentTurn {
|
|
189
|
+
readonly summary: TurnSummaryEvent;
|
|
190
|
+
/** Where the turn's window was cut: the next prompt's start when it raced in, else the Stop. */
|
|
191
|
+
readonly untilIso?: string;
|
|
192
|
+
readonly workRoot?: string;
|
|
193
|
+
readonly capture?: CaptureConfig;
|
|
194
|
+
}
|
package/docs/DATA_HANDLING.md
CHANGED
|
@@ -307,6 +307,9 @@ left. `agentwatch off` keeps the copy, because sessions already running still lo
|
|
|
307
307
|
restart those sessions after an uninstall. A process whose entry is a coding agent
|
|
308
308
|
(`claude`, `codex`, `gemini`, `cursor`, `cursor-agent`, `antigravity`, `agy`) captures
|
|
309
309
|
nothing. `AGENTWATCH_CAPTURE=off` in a process's environment turns the shim off for it.
|
|
310
|
+
The machine-wide switch is `capture.runs` in the global config (`setup --capture-runs on|off`,
|
|
311
|
+
on by default). It is apart from `otel`: captured calls travel as events, not OTLP, so
|
|
312
|
+
`--otel none` leaves capture on. A repository file cannot set it.
|
|
310
313
|
|
|
311
314
|
The entries live in Claude Code's `settings.json` `env` block, in
|
|
312
315
|
`[shell_environment_policy.set]` of Codex's `config.toml`, and in `~/.gemini/.env`. For
|
package/package.json
CHANGED