@yeaft/webchat-agent 1.0.180 → 1.0.181
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/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 1. Chain depth — a message's `causedBy` chain (A → @B → @C → @A …) must
|
|
7
7
|
* not exceed a max depth. Each route_forward call stamps the outbound
|
|
8
8
|
* envelope's `meta.causedBy` with a chain of msgIds, and the guard
|
|
9
|
-
* rejects when the chain length would exceed MAX_CHAIN_DEPTH (
|
|
9
|
+
* rejects when the chain length would exceed MAX_CHAIN_DEPTH (30).
|
|
10
10
|
*
|
|
11
11
|
* 2. Rate throttle — within a sliding window (WINDOW_MS = 5000, default
|
|
12
12
|
* MAX_HITS_PER_WINDOW = 8), a single (sessionId, vpId) target may be
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
* advance the rate counter.
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
|
-
export const MAX_CHAIN_DEPTH =
|
|
46
|
+
export const MAX_CHAIN_DEPTH = 30;
|
|
47
47
|
export const DEFAULT_WINDOW_MS = 5_000;
|
|
48
48
|
export const DEFAULT_MAX_HITS_PER_WINDOW = 8;
|
|
49
49
|
export const DEFAULT_MAX_KEYS = 1_000;
|
|
@@ -137,7 +137,7 @@ export function createLoopGuard(options = {}) {
|
|
|
137
137
|
if (!sessionId || !targetVpId) {
|
|
138
138
|
return { ok: false, reason: 'chain_depth_exceeded', detail: { missing: true } };
|
|
139
139
|
}
|
|
140
|
-
if (Array.isArray(chain) && chain.length
|
|
140
|
+
if (Array.isArray(chain) && chain.length > maxChainDepth) {
|
|
141
141
|
return {
|
|
142
142
|
ok: false,
|
|
143
143
|
reason: 'chain_depth_exceeded',
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* `{ ok: false, error }` so the VP can pivot (apologise, retry, ...).
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import { MAX_CHAIN_DEPTH } from '../routing/loop-guard.js';
|
|
26
27
|
import { defineTool } from './types.js';
|
|
27
28
|
|
|
28
29
|
export default defineTool({
|
|
@@ -50,7 +51,7 @@ Arguments:
|
|
|
50
51
|
Rules:
|
|
51
52
|
- Forwarding to yourself is rejected (self_forward_rejected).
|
|
52
53
|
- Forwarding to a non-member is rejected (target_not_in_roster).
|
|
53
|
-
- Forwards carry a causedBy chain; chains deeper than
|
|
54
|
+
- Forwards carry a causedBy chain; chains deeper than ${MAX_CHAIN_DEPTH} hops are blocked
|
|
54
55
|
(chain_depth_exceeded).
|
|
55
56
|
- A single target may be forwarded to at most 8 times per 5-second window
|
|
56
57
|
per session (throttled).
|
|
@@ -69,7 +70,7 @@ Returns JSON: { ok, dispatched?, error?, detail? }.`,
|
|
|
69
70
|
规则:
|
|
70
71
|
- 转发给自己会被拒绝(self_forward_rejected)。
|
|
71
72
|
- 转发给非成员会被拒绝(target_not_in_roster)。
|
|
72
|
-
- 转发带有 causedBy 链;超过
|
|
73
|
+
- 转发带有 causedBy 链;超过 ${MAX_CHAIN_DEPTH} 跳的链会被阻止(chain_depth_exceeded)。
|
|
73
74
|
- 同一目标在每 5 秒窗口内最多被转发 8 次(节流限制)。
|
|
74
75
|
|
|
75
76
|
返回 JSON:{ ok, dispatched?, error?, detail? }。`
|