MCPcopy
hub / github.com/codeaashu/claude-code / logSpeculation

Function logSpeculation

src/services/PromptSuggestion/speculation.ts:124–153  ·  view source on GitHub ↗
(
  id: string,
  outcome: 'accepted' | 'aborted' | 'error',
  startTime: number,
  suggestionLength: number,
  messages: Message[],
  boundary: CompletionBoundary | null,
  extras?: Record<string, string | number | boolean | undefined>,
)

Source from the content-addressed store, hash-verified

122>
123
124function logSpeculation(
125 id: string,
126 outcome: 'accepted' | 'aborted' | 'error',
127 startTime: number,
128 suggestionLength: number,
129 messages: Message[],
130 boundary: CompletionBoundary | null,
131 extras?: Record<string, string | number | boolean | undefined>,
132): void {
133 logEvent('tengu_speculation', {
134 speculation_id:
135 id as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
136 outcome:
137 outcome as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
138 duration_ms: Date.now() - startTime,
139 suggestion_length: suggestionLength,
140 tools_executed: countToolsInMessages(messages),
141 completed: boundary !== null,
142 boundary_type: boundary?.type as
143 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
144 | undefined,
145 boundary_tool: getBoundaryTool(boundary) as
146 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
147 | undefined,
148 boundary_detail: getBoundaryDetail(boundary) as
149 | AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
150 | undefined,
151 ...extras,
152 })
153}
154
155function countToolsInMessages(messages: Message[]): number {
156 const blocks = messages

Callers 4

startSpeculationFunction · 0.85
acceptSpeculationFunction · 0.85
abortSpeculationFunction · 0.85
handleSpeculationAcceptFunction · 0.85

Calls 4

logEventFunction · 0.85
countToolsInMessagesFunction · 0.85
getBoundaryToolFunction · 0.85
getBoundaryDetailFunction · 0.85

Tested by

no test coverage detected