MCPcopy
hub / github.com/7836246/cursor2api / complete

Method complete

src/logger.ts:1107–1134  ·  view source on GitHub ↗
(responseChars: number, stopReason?: string)

Source from the content-addressed store, hash-verified

1105 }
1106
1107 complete(responseChars: number, stopReason?: string): void {
1108 this.endPhase();
1109 const duration = Date.now() - this.summary.startTime;
1110 const assessment = assessCompletionOutcome(this.summary, this.payload, stopReason);
1111 this.summary.endTime = Date.now();
1112 this.summary.status = assessment.status;
1113 this.summary.statusReason = assessment.statusReason;
1114 this.summary.issueTags = assessment.issueTags;
1115 this.summary.responseChars = responseChars;
1116 this.summary.stopReason = stopReason;
1117 const completionMessage = assessment.status === 'degraded'
1118 ? `降级完成 (${duration}ms, ${responseChars} chars, stop=${stopReason})${assessment.statusReason ? ` - ${assessment.statusReason}` : ''}`
1119 : `完成 (${duration}ms, ${responseChars} chars, stop=${stopReason})`;
1120 this.log(assessment.status === 'degraded' ? 'warn' : 'info', 'System', 'complete', completionMessage);
1121 logEmitter.emit('summary', this.summary);
1122
1123 // ★ 持久化到文件
1124 persistRequest(this.summary, this.payload);
1125
1126 const retryInfo = this.summary.retryCount > 0 ? ` retry=${this.summary.retryCount}` : '';
1127 const contInfo = this.summary.continuationCount > 0 ? ` cont=${this.summary.continuationCount}` : '';
1128 const toolInfo = this.summary.toolCallsDetected > 0 ? ` tools_called=${this.summary.toolCallsDetected}` : '';
1129 const ttftInfo = this.summary.ttft ? ` ttft=${this.summary.ttft}ms` : '';
1130 const statusColor = assessment.status === 'degraded' ? '\x1b[33m' : '\x1b[32m';
1131 const statusLabel = assessment.status === 'degraded' ? 'DEGRADED' : 'OK';
1132 const reasonInfo = assessment.statusReason ? ` | reason=${assessment.statusReason}` : '';
1133 console.log(`${statusColor}${statusLabel}\x1b[0m [${this.requestId}] ${duration}ms | ${responseChars} chars | stop=${stopReason || 'end_turn'}${ttftInfo}${retryInfo}${contInfo}${toolInfo}${reasonInfo}`);
1134 }
1135
1136 intercepted(reason: string): void {
1137 this.summary.status = 'intercepted';

Callers 9

handleOpenAIStreamFunction · 0.80
handleOpenAINonStreamFunction · 0.80
handleResponsesStreamFunction · 0.80
handleResponsesNonStreamFunction · 0.80
handleDirectTextStreamFunction · 0.80
handleStreamFunction · 0.80
handleNonStreamFunction · 0.80

Calls 4

endPhaseMethod · 0.95
logMethod · 0.95
assessCompletionOutcomeFunction · 0.85
persistRequestFunction · 0.85

Tested by

no test coverage detected