|
| 1 | +import type { PromptOrigin } from '@pymodel/agent-core-v2'; |
| 2 | +import { type SurveyTurnRecovery } from './survey-turns'; |
| 3 | +import type { RatingCooldownStore } from './cooldown-store'; |
| 4 | +import { SessionRatingLedger, type RatingTracker } from './ledger'; |
| 5 | +import type { RatingOffer } from '../common/types'; |
| 6 | +import { type SurveyPopupPayload } from '../common/survey-popup-config'; |
| 7 | +export type SessionFact = { |
| 8 | + readonly kind: 'turn-started'; |
| 9 | + readonly origin: PromptOrigin | undefined; |
| 10 | +} | { |
| 11 | + readonly kind: 'turn-ended'; |
| 12 | + readonly traceId?: string; |
| 13 | +} | { |
| 14 | + readonly kind: 'tool-call-started'; |
| 15 | + readonly toolCallId: string; |
| 16 | + readonly toolName: string; |
| 17 | +} | { |
| 18 | + readonly kind: 'tool-call-ended'; |
| 19 | + readonly toolCallId: string; |
| 20 | +} | { |
| 21 | + readonly kind: 'subagent-spawned'; |
| 22 | + readonly parentToolCallId?: string; |
| 23 | + readonly dynamicWorkflowIndex?: number; |
| 24 | + readonly model?: string; |
| 25 | +} | { |
| 26 | + readonly kind: 'compaction-completed'; |
| 27 | +}; |
| 28 | +export interface ResumedAgentSeed { |
| 29 | + readonly type: string; |
| 30 | + readonly profileName?: string; |
| 31 | + readonly dynamicWorkflowItem?: string; |
| 32 | + readonly sessionInit?: string; |
| 33 | +} |
| 34 | +export interface RatingEnvironment { |
| 35 | + readonly sessionId: string; |
| 36 | + readonly currentModel: string; |
| 37 | + readonly cumulativeTokens: number; |
| 38 | + readonly contextTokens: number; |
| 39 | + readonly permissionMode: string; |
| 40 | + readonly thinkingEffort: string; |
| 41 | + readonly busy: boolean; |
| 42 | + readonly telemetryDisabled: boolean; |
| 43 | + readonly ratingDisabled: boolean; |
| 44 | + readonly historyUserTurnCount?: number; |
| 45 | + readonly resumedAgents?: Readonly<Record<string, ResumedAgentSeed>>; |
| 46 | +} |
| 47 | +export interface RatingConfigFeed { |
| 48 | + readyForEvaluation(): boolean; |
| 49 | + payload(): SurveyPopupPayload; |
| 50 | +} |
| 51 | +export interface SessionRatingDeps { |
| 52 | + readonly environment: () => RatingEnvironment; |
| 53 | + readonly config: RatingConfigFeed; |
| 54 | + readonly cooldown: RatingCooldownStore; |
| 55 | + readonly ledger: SessionRatingLedger; |
| 56 | + readonly track: RatingTracker; |
| 57 | + readonly now?: () => number; |
| 58 | + readonly wallNow?: () => number; |
| 59 | + readonly random?: () => number; |
| 60 | + readonly appearanceId?: () => string; |
| 61 | +} |
| 62 | +export interface SessionRatingMount { |
| 63 | + observe(fact: SessionFact): void; |
| 64 | + recover(recovery: SurveyTurnRecovery): void; |
| 65 | + evaluate(): RatingOffer | undefined; |
| 66 | + end(): void; |
| 67 | +} |
| 68 | +export declare function mountSessionRating(deps: SessionRatingDeps): SessionRatingMount; |
0 commit comments