@aalis/plugin-trigger-policy 0.13.0 → 0.15.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aalis/plugin-trigger-policy",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,7 +12,7 @@
12
12
  "url": "https://github.com/AalisLabs/Aalis/issues"
13
13
  },
14
14
  "homepage": "https://github.com/AalisLabs/Aalis#readme",
15
- "description": "触发策略:@/名字/关键词/计数/评分 决定是否回应",
15
+ "description": "触发策略:@/名字/关键词/计数/评分 决定是否回应,闲置时主动开口",
16
16
  "type": "module",
17
17
  "keywords": [
18
18
  "aalis",
@@ -24,19 +24,20 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@aalis/schema-config": ">=0.13.0 <1.0.0",
27
+ "@aalis/schema-config": ">=0.14.0 <1.0.0",
28
28
  "@aalis/api-flow-control": ">=0.7.0 <1.0.0",
29
- "@aalis/api-gateway": ">=0.7.0 <1.0.0",
29
+ "@aalis/api-gateway": ">=0.8.0 <1.0.0",
30
30
  "@aalis/api-message-archive": ">=0.7.0 <1.0.0",
31
31
  "@aalis/api-persona": ">=0.8.0 <1.0.0",
32
+ "@aalis/api-session-manager": ">=0.10.0 <1.0.0",
32
33
  "@aalis/schema-message": ">=0.9.0 <1.0.0",
33
- "@aalis/api-hooks": ">=0.1.0 <1.0.0"
34
+ "@aalis/api-hooks": ">=0.1.0 <1.0.0",
35
+ "@aalis/api-trigger": ">=0.1.0 <1.0.0"
34
36
  },
35
37
  "devDependencies": {
36
38
  "@types/node": "^22.0.0",
37
39
  "typescript": "^5.7.0",
38
- "@aalis/core": "0.18.0",
39
- "@aalis/api-webui": "0.11.0"
40
+ "@aalis/core": "0.19.1"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "@aalis/core": ">=0.18.0 <1.0.0"
@@ -45,18 +46,22 @@
45
46
  "service": {
46
47
  "required": [
47
48
  "config",
49
+ "events",
48
50
  "gateway",
49
51
  "hooks",
52
+ "lifecycle",
50
53
  "logger",
51
54
  "provide"
52
55
  ],
53
56
  "optional": [
54
57
  "flow-control",
55
58
  "persona",
56
- "message-archive"
59
+ "session-manager",
60
+ "message-archive",
61
+ "trigger"
57
62
  ],
58
63
  "provides": [
59
- "trigger-policy"
64
+ "trigger"
60
65
  ]
61
66
  }
62
67
  },
@@ -1,18 +0,0 @@
1
- import type { PersonaService } from '@aalis/api-persona';
2
- import type { ServiceRef } from '@aalis/core';
3
- import type { TriggerPolicyConfig } from './config.js';
4
- /** 名字检测只在调用的那一刻读当前 persona 提供者,不建立跟随状态,因此只需要这一面 */
5
- export type PersonaRef = Pick<ServiceRef<PersonaService>, 'current'>;
6
- /**
7
- * @ 检测:只认 `<at self>` 标记。
8
- *
9
- * OneBot 的字符串消息格式(含 `[CQ:at,…]`)由 adapter 入站规范化成消息段,再经
10
- * segmentsToText 渲染成 `<at self id="…">`,CQ 码不会流到这里。其它平台适配器若要支持
11
- * @ 判定,须同样把提及渲染成 `<at self …>`——本函数只认这一种文法。
12
- */
13
- export declare function checkImmediateMention(content: string): boolean;
14
- export declare function getBotNames(persona: PersonaRef, cfg: TriggerPolicyConfig): string[];
15
- export declare function checkNameMention(content: string, names: string[]): boolean;
16
- export declare function checkImmediateTrigger(persona: PersonaRef, cfg: TriggerPolicyConfig, content: string): boolean;
17
- export declare function checkMuteKeyword(cfg: TriggerPolicyConfig, content: string): boolean;
18
- //# sourceMappingURL=detector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvD,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAYnF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAK1E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAI7G;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAKnF"}
package/dist/detector.js DELETED
@@ -1,47 +0,0 @@
1
- /**
2
- * @ 检测:只认 `<at self>` 标记。
3
- *
4
- * OneBot 的字符串消息格式(含 `[CQ:at,…]`)由 adapter 入站规范化成消息段,再经
5
- * segmentsToText 渲染成 `<at self id="…">`,CQ 码不会流到这里。其它平台适配器若要支持
6
- * @ 判定,须同样把提及渲染成 `<at self …>`——本函数只认这一种文法。
7
- */
8
- export function checkImmediateMention(content) {
9
- return /<at self[\s>][\s\S]*?<\/at>/.test(content);
10
- }
11
- export function getBotNames(persona, cfg) {
12
- const names = [...cfg.triggerNames];
13
- const service = persona.current;
14
- if (service) {
15
- const personaName = service.getPersonaName();
16
- if (personaName && !names.includes(personaName))
17
- names.push(personaName);
18
- const nicks = service.getNickNames?.() ?? [];
19
- for (const n of nicks) {
20
- if (n && !names.includes(n))
21
- names.push(n);
22
- }
23
- }
24
- return names;
25
- }
26
- export function checkNameMention(content, names) {
27
- for (const name of names) {
28
- if (name && content.includes(name))
29
- return true;
30
- }
31
- return false;
32
- }
33
- export function checkImmediateTrigger(persona, cfg, content) {
34
- if (cfg.triggerOnAt && checkImmediateMention(content))
35
- return true;
36
- if (checkNameMention(content, getBotNames(persona, cfg)))
37
- return true;
38
- return false;
39
- }
40
- export function checkMuteKeyword(cfg, content) {
41
- for (const kw of cfg.muteKeywords) {
42
- if (content.includes(kw))
43
- return true;
44
- }
45
- return false;
46
- }
47
- //# sourceMappingURL=detector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detector.js","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,OAAO,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAmB,EAAE,GAAwB;IACvE,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7C,IAAI,WAAW,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC;QAC7C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAe,EAAE,KAAe;IAC/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAmB,EAAE,GAAwB,EAAE,OAAe;IAClG,IAAI,GAAG,CAAC,WAAW,IAAI,qBAAqB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACnE,IAAI,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACtE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAwB,EAAE,OAAe;IACxE,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QAClC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { IncomingMessage } from '@aalis/schema-message';
2
- export type TriggerKind = 'immediate' | 'interval' | 'swallow' | 'direct';
3
- export interface TriggerDecision {
4
- kind: TriggerKind;
5
- /** 调试/日志用 */
6
- reason: string;
7
- }
8
- export interface TriggerPolicyService {
9
- /** 综合决策(含 @/名字检测、间隔/评分判定、私聊直放等) */
10
- decide(message: IncomingMessage): TriggerDecision;
11
- /** 当前生效的 bot 名称别名列表(含 persona) */
12
- getBotNames(): string[];
13
- /** 检查内容是否含 mute 关键词 */
14
- detectMuteKeyword(content: string): boolean;
15
- }
16
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,eAAe,CAAC;IAClD,kCAAkC;IAClC,WAAW,IAAI,MAAM,EAAE,CAAC;IACxB,uBAAuB;IACvB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7C"}
package/dist/types.js DELETED
@@ -1,6 +0,0 @@
1
- // ----- Trigger Policy 服务接口 -----
2
- //
3
- // TriggerPolicyService 决定一条入站消息是否应当触发 agent。
4
- // 决策只读:实际状态变更(计数器重置、冷却记录)由 FlowControlService 完成。
5
- export {};
6
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,6CAA6C;AAC7C,kDAAkD"}