Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
ci:
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ export default defineConfig([
'isTeammateRelayLine',
'isTranscriptTurnLine',
'isTurnBoundary',
'isTurnNumberLine',
'isUserChunkLine',
'lastAssistantTotalTokens',
'readConfig',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"analyze:sessions": "tsx src/cli/sessionInventory.ts",
"loops:import": "tsx src/cli/importLoops.ts",
"turn-spend:stats": "tsx src/cli/turnSpendStats.ts",
"session:sums": "tsx src/cli/sessionSums.ts",
"standalone:build": "electron-vite build && vite build --config vite.standalone.config.ts",
"standalone:start": "node dist-standalone/index.cjs"
},
Expand Down
4 changes: 4 additions & 0 deletions scripts/turn-accounting.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export declare function isTranscriptTurnLine(m: AccountableMessage): boolean;
/** Turn boundary: user-initiated message or compaction marker. */
export declare function isTurnBoundary(m: AccountableMessage): boolean;

/** Which boundary consumes a turn number: real user messages only (compact
* resets the bucket but opens no turn — app parity, CompactChunk). */
export declare function isTurnNumberLine(m: AccountableMessage): boolean;

/** Main-chain assistant line — the only lines billed to the turn's re-read
* (sidechain/synthetic excluded; detector and panel see the same set). */
export declare function isMainChainAssistantLine(m: AccountableMessage): boolean;
Expand Down
8 changes: 8 additions & 0 deletions scripts/turn-accounting.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ export function isTurnBoundary(m) {
return isUserChunkLine(m) || m.isCompactSummary === true;
}

/** Which boundary CONSUMES a turn number: real user messages only. A
* compaction marker resets the budget bucket (isTurnBoundary) but opens no
* turn — app parity: CompactChunk is a structural boundary, the post-compact
* segment keeps the current number until the next real user message. */
export function isTurnNumberLine(m) {
return isUserChunkLine(m) && m.isCompactSummary !== true;
}

/** Main-chain assistant line — the only lines whose usage is billed to the
* turn's re-read. Sidechain (subagent) rounds run in their own context and
* synthetic lines carry no real request; the detector (loopDetection.ts)
Expand Down
3 changes: 3 additions & 0 deletions scripts/turn-budget-hook.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export declare function isRealUserLine(m: AccountableMessage): boolean;
/** Turn boundary: real user message or compaction marker. */
export declare function isTurnBoundary(m: AccountableMessage): boolean;

/** Which boundary consumes a turn number: real user messages only. */
export declare function isTurnNumberLine(m: AccountableMessage): boolean;

/** Main-chain assistant line — billed to the turn's re-read. */
export declare function isMainChainAssistantLine(m: AccountableMessage): boolean;

Expand Down
2 changes: 2 additions & 0 deletions scripts/turn-budget-hook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
isMainChainAssistantLine,
isRealUserLine,
isTurnBoundary,
isTurnNumberLine,
lastAssistantTotalTokens,
} from './turn-accounting.mjs';

Expand All @@ -63,6 +64,7 @@ export {
isMainChainAssistantLine,
isRealUserLine,
isTurnBoundary,
isTurnNumberLine,
lastAssistantTotalTokens,
};

Expand Down
Loading
Loading