plugin-sensitive-filter-xr 0.1.21 → 0.1.22
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/README.md +1 -1
- package/dist/lib/sensitiveFilter.d.ts.map +1 -1
- package/dist/lib/sensitiveFilter.js +27 -17
- package/dist/lib/types.d.ts +0 -15
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
| Field | Type | Required | Default | Description |
|
|
30
30
|
| --- | --- | --- | --- | --- |
|
|
31
31
|
| `enabled` | `boolean` | No | `true` | Turn notification on/off. |
|
|
32
|
-
| `groups` | `Array<{
|
|
32
|
+
| `groups` | `Array<{webhookUrl}>` | Runtime-required for sending | `[]` | One or more WeCom group webhook targets. |
|
|
33
33
|
| `timeoutMs` | `number` | No | `10000` | Per webhook request timeout (max `120000`). |
|
|
34
34
|
|
|
35
35
|
### Rule Mode (`mode=rule`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensitiveFilter.d.ts","sourceRoot":"","sources":["../../src/lib/sensitiveFilter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAa,oBAAoB,EAA8B,MAAM,kBAAkB,CAAA;AAGnG,OAAO,EACL,eAAe,EAGf,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAML,qBAAqB,EAMtB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"sensitiveFilter.d.ts","sourceRoot":"","sources":["../../src/lib/sensitiveFilter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAa,oBAAoB,EAA8B,MAAM,kBAAkB,CAAA;AAGnG,OAAO,EACL,eAAe,EAGf,uBAAuB,EACvB,wBAAwB,EAEzB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAML,qBAAqB,EAMtB,MAAM,YAAY,CAAA;AA07BnB,qBAEa,yBAA0B,YAAW,wBAAwB,CAAC,qBAAqB,CAAC;IAE/F,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAY;IAEvC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAmQlC;IAEK,gBAAgB,CACpB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,eAAe,CAAC;IAa3B,OAAO,CAAC,wBAAwB;IA2UhC,OAAO,CAAC,uBAAuB;CAwhBhC;AAED,YAAY,EAAE,qBAAqB,EAAE,CAAA"}
|
|
@@ -48,7 +48,6 @@ function resolveRuntimeWecomConfig(config) {
|
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
50
|
groups.push({
|
|
51
|
-
name: toNonEmptyString(item.name) ?? undefined,
|
|
52
51
|
webhookUrl,
|
|
53
52
|
});
|
|
54
53
|
}
|
|
@@ -657,9 +656,8 @@ async function dispatchWecomNotification(wecomConfig, message) {
|
|
|
657
656
|
}
|
|
658
657
|
}
|
|
659
658
|
catch (error) {
|
|
660
|
-
const target = group.name ? `${group.name}(${group.webhookUrl})` : group.webhookUrl;
|
|
661
659
|
// Notify failure should not break model execution.
|
|
662
|
-
console.warn(`[${SENSITIVE_FILTER_MIDDLEWARE_NAME}] Failed to send WeCom notification to ${
|
|
660
|
+
console.warn(`[${SENSITIVE_FILTER_MIDDLEWARE_NAME}] Failed to send WeCom notification to ${group.webhookUrl}: ${getErrorText(error)}`);
|
|
663
661
|
}
|
|
664
662
|
}
|
|
665
663
|
}
|
|
@@ -951,10 +949,6 @@ let SensitiveFilterMiddleware = class SensitiveFilterMiddleware {
|
|
|
951
949
|
items: {
|
|
952
950
|
type: 'object',
|
|
953
951
|
properties: {
|
|
954
|
-
name: {
|
|
955
|
-
type: 'string',
|
|
956
|
-
title: { en_US: 'Group Name', zh_Hans: '群名称(可选)' },
|
|
957
|
-
},
|
|
958
952
|
webhookUrl: {
|
|
959
953
|
type: 'string',
|
|
960
954
|
title: { en_US: 'Webhook URL', zh_Hans: 'Webhook 地址' },
|
|
@@ -1248,17 +1242,25 @@ let SensitiveFilterMiddleware = class SensitiveFilterMiddleware {
|
|
|
1248
1242
|
return replaceModelResponseText(response, rewrittenOutput);
|
|
1249
1243
|
},
|
|
1250
1244
|
afterAgent: async () => {
|
|
1251
|
-
await persistAuditSnapshot();
|
|
1252
1245
|
const matchedRecords = auditEntries.filter((entry) => entry.matched);
|
|
1253
|
-
|
|
1254
|
-
|
|
1246
|
+
const notification = matchedRecords.length > 0
|
|
1247
|
+
? buildMatchedNotificationMessage({
|
|
1255
1248
|
mode: 'rule',
|
|
1256
1249
|
nodeTitle: context.node.title ?? SENSITIVE_FILTER_MIDDLEWARE_NAME,
|
|
1257
1250
|
finalAction,
|
|
1258
1251
|
records: matchedRecords,
|
|
1259
1252
|
runtimeConfigurable,
|
|
1260
|
-
})
|
|
1261
|
-
|
|
1253
|
+
})
|
|
1254
|
+
: null;
|
|
1255
|
+
const [persistResult, notifyResult] = await Promise.allSettled([
|
|
1256
|
+
persistAuditSnapshot(),
|
|
1257
|
+
notification ? dispatchWecomNotification(wecomConfig, notification) : Promise.resolve(undefined),
|
|
1258
|
+
]);
|
|
1259
|
+
if (persistResult.status === 'rejected') {
|
|
1260
|
+
console.warn(`[${SENSITIVE_FILTER_MIDDLEWARE_NAME}] Failed to persist audit snapshot: ${getErrorText(persistResult.reason)}`);
|
|
1261
|
+
}
|
|
1262
|
+
if (notifyResult.status === 'rejected') {
|
|
1263
|
+
console.warn(`[${SENSITIVE_FILTER_MIDDLEWARE_NAME}] Failed to dispatch WeCom notification: ${getErrorText(notifyResult.reason)}`);
|
|
1262
1264
|
}
|
|
1263
1265
|
return undefined;
|
|
1264
1266
|
},
|
|
@@ -1678,17 +1680,25 @@ let SensitiveFilterMiddleware = class SensitiveFilterMiddleware {
|
|
|
1678
1680
|
return replaceModelResponseText(response, toNonEmptyString(decision.replacementText) ?? llmConfig.rewriteFallbackText);
|
|
1679
1681
|
},
|
|
1680
1682
|
afterAgent: async () => {
|
|
1681
|
-
await persistAuditSnapshot();
|
|
1682
1683
|
const matchedRecords = auditEntries.filter((entry) => entry.matched);
|
|
1683
|
-
|
|
1684
|
-
|
|
1684
|
+
const notification = matchedRecords.length > 0
|
|
1685
|
+
? buildMatchedNotificationMessage({
|
|
1685
1686
|
mode: 'llm',
|
|
1686
1687
|
nodeTitle: context.node.title ?? SENSITIVE_FILTER_MIDDLEWARE_NAME,
|
|
1687
1688
|
finalAction,
|
|
1688
1689
|
records: matchedRecords,
|
|
1689
1690
|
runtimeConfigurable,
|
|
1690
|
-
})
|
|
1691
|
-
|
|
1691
|
+
})
|
|
1692
|
+
: null;
|
|
1693
|
+
const [persistResult, notifyResult] = await Promise.allSettled([
|
|
1694
|
+
persistAuditSnapshot(),
|
|
1695
|
+
notification ? dispatchWecomNotification(wecomConfig, notification) : Promise.resolve(undefined),
|
|
1696
|
+
]);
|
|
1697
|
+
if (persistResult.status === 'rejected') {
|
|
1698
|
+
console.warn(`[${SENSITIVE_FILTER_MIDDLEWARE_NAME}] Failed to persist audit snapshot: ${getErrorText(persistResult.reason)}`);
|
|
1699
|
+
}
|
|
1700
|
+
if (notifyResult.status === 'rejected') {
|
|
1701
|
+
console.warn(`[${SENSITIVE_FILTER_MIDDLEWARE_NAME}] Failed to dispatch WeCom notification: ${getErrorText(notifyResult.reason)}`);
|
|
1692
1702
|
}
|
|
1693
1703
|
return undefined;
|
|
1694
1704
|
},
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ export type LlmModeConfig = {
|
|
|
40
40
|
};
|
|
41
41
|
export type SensitiveFilterConfig = RuleModeConfig | LlmModeConfig;
|
|
42
42
|
export type WecomNotifyGroup = {
|
|
43
|
-
name?: string | null;
|
|
44
43
|
webhookUrl?: string | null;
|
|
45
44
|
};
|
|
46
45
|
export type WecomNotifyConfig = {
|
|
@@ -94,27 +93,22 @@ export declare const sensitiveFilterConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
94
93
|
wecom: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
95
94
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
96
95
|
groups: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodObject<{
|
|
97
|
-
name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
98
96
|
webhookUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
99
97
|
}, "strip", z.ZodTypeAny, {
|
|
100
|
-
name?: string;
|
|
101
98
|
webhookUrl?: string;
|
|
102
99
|
}, {
|
|
103
|
-
name?: string;
|
|
104
100
|
webhookUrl?: string;
|
|
105
101
|
}>>, "many">>>;
|
|
106
102
|
timeoutMs: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
107
103
|
}, "strip", z.ZodTypeAny, {
|
|
108
104
|
enabled?: boolean;
|
|
109
105
|
groups?: {
|
|
110
|
-
name?: string;
|
|
111
106
|
webhookUrl?: string;
|
|
112
107
|
}[];
|
|
113
108
|
timeoutMs?: number;
|
|
114
109
|
}, {
|
|
115
110
|
enabled?: boolean;
|
|
116
111
|
groups?: {
|
|
117
|
-
name?: string;
|
|
118
112
|
webhookUrl?: string;
|
|
119
113
|
}[];
|
|
120
114
|
timeoutMs?: number;
|
|
@@ -137,7 +131,6 @@ export declare const sensitiveFilterConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
137
131
|
wecom?: {
|
|
138
132
|
enabled?: boolean;
|
|
139
133
|
groups?: {
|
|
140
|
-
name?: string;
|
|
141
134
|
webhookUrl?: string;
|
|
142
135
|
}[];
|
|
143
136
|
timeoutMs?: number;
|
|
@@ -160,7 +153,6 @@ export declare const sensitiveFilterConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
160
153
|
wecom?: {
|
|
161
154
|
enabled?: boolean;
|
|
162
155
|
groups?: {
|
|
163
|
-
name?: string;
|
|
164
156
|
webhookUrl?: string;
|
|
165
157
|
}[];
|
|
166
158
|
timeoutMs?: number;
|
|
@@ -206,27 +198,22 @@ export declare const sensitiveFilterConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
206
198
|
wecom: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
207
199
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
208
200
|
groups: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNullable<z.ZodObject<{
|
|
209
|
-
name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
210
201
|
webhookUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
211
202
|
}, "strip", z.ZodTypeAny, {
|
|
212
|
-
name?: string;
|
|
213
203
|
webhookUrl?: string;
|
|
214
204
|
}, {
|
|
215
|
-
name?: string;
|
|
216
205
|
webhookUrl?: string;
|
|
217
206
|
}>>, "many">>>;
|
|
218
207
|
timeoutMs: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
219
208
|
}, "strip", z.ZodTypeAny, {
|
|
220
209
|
enabled?: boolean;
|
|
221
210
|
groups?: {
|
|
222
|
-
name?: string;
|
|
223
211
|
webhookUrl?: string;
|
|
224
212
|
}[];
|
|
225
213
|
timeoutMs?: number;
|
|
226
214
|
}, {
|
|
227
215
|
enabled?: boolean;
|
|
228
216
|
groups?: {
|
|
229
|
-
name?: string;
|
|
230
217
|
webhookUrl?: string;
|
|
231
218
|
}[];
|
|
232
219
|
timeoutMs?: number;
|
|
@@ -243,7 +230,6 @@ export declare const sensitiveFilterConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
243
230
|
wecom?: {
|
|
244
231
|
enabled?: boolean;
|
|
245
232
|
groups?: {
|
|
246
|
-
name?: string;
|
|
247
233
|
webhookUrl?: string;
|
|
248
234
|
}[];
|
|
249
235
|
timeoutMs?: number;
|
|
@@ -269,7 +255,6 @@ export declare const sensitiveFilterConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
269
255
|
wecom?: {
|
|
270
256
|
enabled?: boolean;
|
|
271
257
|
groups?: {
|
|
272
|
-
name?: string;
|
|
273
258
|
webhookUrl?: string;
|
|
274
259
|
}[];
|
|
275
260
|
timeoutMs?: number;
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;IACzB,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;IAClC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAA;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAEhC,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAClD,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,UAAU,GAAG,YAAY,CAAA;AAC3E,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SA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