@myassis/gateway 1.0.97 → 1.0.98
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.
package/dist/config/index.js
CHANGED
|
@@ -100,7 +100,7 @@ exports.appConfig = {
|
|
|
100
100
|
/** 摘要后保留的原始历史消息条数 */
|
|
101
101
|
historyKeep: parseInt(process.env.HISTORY_KEEP || '4', 10),
|
|
102
102
|
/** 保留完整输出的最近工具调用轮数 */
|
|
103
|
-
toolPairKeep: parseInt(process.env.TOOL_PAIR_KEEP || '
|
|
103
|
+
toolPairKeep: parseInt(process.env.TOOL_PAIR_KEEP || '2', 10),
|
|
104
104
|
/** 极端裁剪时至少保留的工具调用轮数 */
|
|
105
105
|
minToolPairKeep: 2,
|
|
106
106
|
/** 单次请求上下文字符预算(LLMClient 硬上限为 200000,此处留出余量) */
|
|
@@ -118,7 +118,7 @@ exports.appConfig = {
|
|
|
118
118
|
*/
|
|
119
119
|
turnCompactTriggerChars: parseInt(process.env.TURN_COMPACT_TRIGGER_CHARS || '144000', 10),
|
|
120
120
|
/** 轮内压缩时保留原文的最近工具调用轮数 */
|
|
121
|
-
turnCompactKeepPairs: parseInt(process.env.TURN_COMPACT_KEEP_PAIRS || '
|
|
121
|
+
turnCompactKeepPairs: parseInt(process.env.TURN_COMPACT_KEEP_PAIRS || '2', 10),
|
|
122
122
|
/** 单轮请求内最多做几次轮内压缩,防止摘要模型被反复调用 */
|
|
123
123
|
maxInTurnCompactions: parseInt(process.env.MAX_IN_TURN_COMPACTIONS || '4', 10),
|
|
124
124
|
/** 模型瞬时故障(空回复 / 超时 / 网络抖动)的自动重试次数 */
|
package/dist/main.js
CHANGED
|
@@ -168,26 +168,26 @@ if (cliCommand) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
else if (cliCommand === '--help' || cliCommand === '-h') {
|
|
171
|
-
console.log(`我的助手 Gateway CLI
|
|
172
|
-
|
|
173
|
-
用法: gateway <命令>
|
|
174
|
-
|
|
175
|
-
服务管理命令:
|
|
176
|
-
install 安装 Gateway 服务(后台运行)
|
|
177
|
-
uninstall 卸载 Gateway 服务
|
|
178
|
-
start 启动 Gateway 服务
|
|
179
|
-
stop 停止 Gateway 服务
|
|
180
|
-
restart 重启 Gateway 服务
|
|
181
|
-
update 更新 Gateway(需重新安装)
|
|
182
|
-
status 查看服务状态
|
|
183
|
-
|
|
184
|
-
CORS 管理命令:
|
|
185
|
-
addCors <域名> 添加允许的跨域域名
|
|
186
|
-
removeCors <域名> 移除允许的跨域域名
|
|
187
|
-
listCors 列出所有跨域域名(含内置域名)
|
|
188
|
-
|
|
189
|
-
其他:
|
|
190
|
-
--help, -h 显示本帮助信息
|
|
171
|
+
console.log(`我的助手 Gateway CLI
|
|
172
|
+
|
|
173
|
+
用法: gateway <命令>
|
|
174
|
+
|
|
175
|
+
服务管理命令:
|
|
176
|
+
install 安装 Gateway 服务(后台运行)
|
|
177
|
+
uninstall 卸载 Gateway 服务
|
|
178
|
+
start 启动 Gateway 服务
|
|
179
|
+
stop 停止 Gateway 服务
|
|
180
|
+
restart 重启 Gateway 服务
|
|
181
|
+
update 更新 Gateway(需重新安装)
|
|
182
|
+
status 查看服务状态
|
|
183
|
+
|
|
184
|
+
CORS 管理命令:
|
|
185
|
+
addCors <域名> 添加允许的跨域域名
|
|
186
|
+
removeCors <域名> 移除允许的跨域域名
|
|
187
|
+
listCors 列出所有跨域域名(含内置域名)
|
|
188
|
+
|
|
189
|
+
其他:
|
|
190
|
+
--help, -h 显示本帮助信息
|
|
191
191
|
`);
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -43,7 +43,7 @@ class RelayClient {
|
|
|
43
43
|
stopped = false;
|
|
44
44
|
/** Server 在 HELLO_ACK 中下发的参数,未收到前用协议默认值 */
|
|
45
45
|
initialWindowSize = protocol_js_1.INITIAL_WINDOW_SIZE;
|
|
46
|
-
wsInitialWindowSize = protocol_js_1.
|
|
46
|
+
wsInitialWindowSize = protocol_js_1.INITIAL_WINDOW_SIZE;
|
|
47
47
|
maxConcurrentStreams = protocol_js_1.MAX_CONCURRENT_STREAMS;
|
|
48
48
|
/**
|
|
49
49
|
* 启动中继。
|
|
@@ -353,8 +353,8 @@ class RelayClient {
|
|
|
353
353
|
this.maxConcurrentStreams = ack.maxConcurrentStreams;
|
|
354
354
|
// 旧 Server 不下发该字段:回退到 HTTP 窗口,与改造前行为一致。
|
|
355
355
|
// 两侧必须用同一个值,否则接收方会把合法数据当成「对端超发」。
|
|
356
|
-
this.wsInitialWindowSize = ack.
|
|
357
|
-
? ack.
|
|
356
|
+
this.wsInitialWindowSize = ack.initialWindowSize > 0
|
|
357
|
+
? ack.initialWindowSize
|
|
358
358
|
: this.initialWindowSize;
|
|
359
359
|
this.failureCount = 0;
|
|
360
360
|
this.lastError = undefined;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* CI 会校验本文件与源文件的一致性,不一致将导致构建失败。
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.stripHopByHopHeaders = exports.checkGatewayFeatures = exports.checkProtocolVersion = exports.ReceiveWindow = exports.SendWindow = exports.StreamIdAllocator = exports.decodeWsData = exports.encodeWsDataFrames = exports.MAX_WS_DATA_CHUNK = exports.WS_DATA_PREFIX_SIZE = exports.WsDataKind = exports.splitIntoFrames = exports.decodeJsonPayload = exports.decodeFrame = exports.encodeJsonFrame = exports.encodeFrame = exports.RelayProtocolError = exports.AbortReason = exports.isControlFrame = exports.isKnownFrameType = exports.frameTypeName = exports.FrameType = exports.CONTROL_STREAM_ID = exports.PING_TIMEOUT_MS = exports.PING_INTERVAL_MS = exports.MAX_CONCURRENT_STREAMS = exports.
|
|
12
|
+
exports.stripHopByHopHeaders = exports.checkGatewayFeatures = exports.checkProtocolVersion = exports.ReceiveWindow = exports.SendWindow = exports.StreamIdAllocator = exports.decodeWsData = exports.encodeWsDataFrames = exports.MAX_WS_DATA_CHUNK = exports.WS_DATA_PREFIX_SIZE = exports.WsDataKind = exports.splitIntoFrames = exports.decodeJsonPayload = exports.decodeFrame = exports.encodeJsonFrame = exports.encodeFrame = exports.RelayProtocolError = exports.AbortReason = exports.isControlFrame = exports.isKnownFrameType = exports.frameTypeName = exports.FrameType = exports.CONTROL_STREAM_ID = exports.PING_TIMEOUT_MS = exports.PING_INTERVAL_MS = exports.MAX_CONCURRENT_STREAMS = exports.INITIAL_WINDOW_SIZE = exports.MAX_FRAME_PAYLOAD = exports.FRAME_HEADER_SIZE = exports.RELAY_REQUIRED_FEATURE = exports.RELAY_MIN_PROTOCOL_VERSION = exports.RELAY_PROTOCOL_VERSION = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* 中继帧协议(单源实现)
|
|
15
15
|
* ============================================================
|
|
@@ -55,29 +55,8 @@ exports.FRAME_HEADER_SIZE = 5;
|
|
|
55
55
|
* 偏小是有意为之:帧越小,SSE/流式响应的转发粒度越细,首字延迟越低。
|
|
56
56
|
*/
|
|
57
57
|
exports.MAX_FRAME_PAYLOAD = 64 * 1024;
|
|
58
|
-
/**
|
|
59
|
-
* HTTP 流的初始接收窗口(信用式流控)。
|
|
60
|
-
*
|
|
61
|
-
* 保持 256KB:HTTP 流有真正的背压——信用耗尽会 req.pause() 暂停
|
|
62
|
-
* 上游,等 WINDOW_UPDATE 回来再继续,窗口小只影响吞吐不会丢数据,
|
|
63
|
-
* 而帧细粒度对 SSE 首字延迟有利。
|
|
64
|
-
*/
|
|
58
|
+
/** 每条流的初始接收窗口(信用式流控) */
|
|
65
59
|
exports.INITIAL_WINDOW_SIZE = 256 * 1024;
|
|
66
|
-
/**
|
|
67
|
-
* WebSocket 流的初始接收窗口。
|
|
68
|
-
*
|
|
69
|
-
* 必须远大于 HTTP 窗口,因为 WS 没有背压可用:ws 库不支持逗条
|
|
70
|
-
* 暂停,一条消息发不下去就只能 abortStream(见
|
|
71
|
-
* RelayHub.forwardWebSocket 与 RelayClient.onWsOpen 里的 QUOTA_EXCEEDED 分支)。
|
|
72
|
-
* 一旦中止,终端的通知通道就断了,那一段的会话镜像事件全丢。
|
|
73
|
-
*
|
|
74
|
-
* 现实触发条件:会话镜像会把含 base64 附件的用户消息整条下发,
|
|
75
|
-
* 一张 5MB 的图经 base64 膨胀约 4/3 后接近 7MB,瞬时打穿 256KB。
|
|
76
|
-
*
|
|
77
|
-
* 16MB 不是预分配:窗口只是「允许对端在未收到确认前先发多少」。
|
|
78
|
-
* 而且 WS 流数量等于在线终端数(个位数),不是 MAX_CONCURRENT_STREAMS。
|
|
79
|
-
*/
|
|
80
|
-
exports.WS_INITIAL_WINDOW_SIZE = 16 * 1024 * 1024;
|
|
81
60
|
/** 单条隧道允许的最大并发流数 */
|
|
82
61
|
exports.MAX_CONCURRENT_STREAMS = 64;
|
|
83
62
|
/** 心跳间隔与超时(毫秒) */
|