@ynhcj/xiaoyi-channel 0.0.196-next → 0.0.197-next
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.
|
@@ -5,7 +5,7 @@ import https from 'https';
|
|
|
5
5
|
import { URL } from 'url';
|
|
6
6
|
import { getConfig } from './config.js';
|
|
7
7
|
import { logger } from '../utils/logger.js';
|
|
8
|
-
import { DEFAULT_HTTPS_PORT, DEFAULT_HTTP_PORT, HTTP_STATUS_BAD_REQUEST } from './constants.js';
|
|
8
|
+
import { DEFAULT_HTTPS_PORT, DEFAULT_HTTP_PORT, HTTP_STATUS_BAD_REQUEST, API_URL_SUFFIX } from './constants.js';
|
|
9
9
|
function buildHeadersForCelia(config, sessionId) {
|
|
10
10
|
if (!config.uid || !config.apiKey || !config.skillId || !config.requestFrom) {
|
|
11
11
|
throw new Error('[SENTINEL HOOK] Missing required configuration: uid, apiKey, skillId, or requestFrom is not defined');
|
|
@@ -86,10 +86,11 @@ export async function callApi(payload, api, sessionId) {
|
|
|
86
86
|
// 确保 uid 存在于消息体中(从 config 注入)
|
|
87
87
|
const payloadWithUid = { ...payload, uid: config.uid };
|
|
88
88
|
const httpBody = JSON.stringify(payloadWithUid);
|
|
89
|
-
|
|
89
|
+
const apiUrl = `${config.api.url}${API_URL_SUFFIX}`;
|
|
90
|
+
logger.log(`[SENTINEL HOOK] callApi request URL: ${apiUrl}`);
|
|
90
91
|
logger.log(`[SENTINEL HOOK] callApi request body: ${httpBody}`);
|
|
91
92
|
return new Promise((resolve, reject) => {
|
|
92
|
-
const options = buildRequestOptions(
|
|
93
|
+
const options = buildRequestOptions(apiUrl, headersForCelia, config.api.timeout);
|
|
93
94
|
const req = https.request(options, (res) => {
|
|
94
95
|
handleResponse(res, resolve, reject);
|
|
95
96
|
});
|