koishi-plugin-satori-ai 2.2.0 → 2.3.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/lib/abstractGame.d.ts +13 -2
- package/lib/api.d.ts +1 -4
- package/lib/favorability.d.ts +1 -0
- package/lib/game.d.ts +5 -0
- package/lib/gameOneTouch.d.ts +48 -1
- package/lib/gameOneTouchPvp.d.ts +46 -0
- package/lib/index.d.ts +15 -1
- package/lib/index.js +3502 -899
- package/lib/memory/context.d.ts +17 -11
- package/lib/memory/group-digest.d.ts +39 -0
- package/lib/memory/group-recorder.d.ts +41 -0
- package/lib/memory/group.d.ts +71 -0
- package/lib/memory/index.d.ts +44 -3
- package/lib/memory/profile.d.ts +27 -1
- package/lib/memory/prompts.d.ts +42 -0
- package/lib/memory/repository.d.ts +16 -4
- package/lib/memory/short-term.d.ts +17 -1
- package/lib/memory/summarizer.d.ts +60 -0
- package/lib/memory/text.d.ts +4 -0
- package/lib/middleware.d.ts +1 -1
- package/lib/mood.d.ts +10 -1
- package/lib/oneTouchEngine.d.ts +157 -0
- package/lib/oneTouchWeights.d.ts +20 -0
- package/lib/proactive.d.ts +27 -0
- package/lib/schedule.d.ts +49 -0
- package/lib/types.d.ts +20 -17
- package/lib/utils.d.ts +4 -0
- package/package.json +1 -1
- package/readme.md +148 -19
package/lib/abstractGame.d.ts
CHANGED
|
@@ -4,10 +4,18 @@ declare module 'koishi' {
|
|
|
4
4
|
'game-result'(session: Session, result: gameResult): void;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
export interface gamePlayerResult {
|
|
8
|
+
playerID: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
win: number;
|
|
11
|
+
bonus: number;
|
|
12
|
+
}
|
|
7
13
|
export interface gameResult {
|
|
8
14
|
playerID: string;
|
|
9
15
|
message: string;
|
|
10
16
|
gameName: string;
|
|
17
|
+
playerResults?: gamePlayerResult[];
|
|
18
|
+
cancelled?: boolean;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
* 单局游戏的抽象基类,提供通用生命周期方法
|
|
@@ -16,16 +24,19 @@ export declare abstract class abstractGameSingleGame {
|
|
|
16
24
|
protected session: Session;
|
|
17
25
|
protected disposeListener: () => boolean;
|
|
18
26
|
protected lastActionTime: number;
|
|
27
|
+
protected playerIDs: string[];
|
|
19
28
|
constructor(disposeListener: () => boolean, session: Session);
|
|
20
29
|
startGame(): Promise<string>;
|
|
21
|
-
endGame(): Promise<{
|
|
30
|
+
endGame(session?: Session): Promise<{
|
|
22
31
|
message: string;
|
|
23
32
|
gameName: string;
|
|
24
33
|
playerID: string;
|
|
25
34
|
}>;
|
|
26
35
|
getPlayerID(): string;
|
|
36
|
+
getPlayerIDs(): string[];
|
|
37
|
+
acceptsInput(userId: string): boolean;
|
|
27
38
|
getLastActionTime(): number;
|
|
28
|
-
processInput(str: string): Promise<string>;
|
|
39
|
+
processInput(str: string, session?: Session): Promise<string>;
|
|
29
40
|
}
|
|
30
41
|
type Constructor<T> = new (...args: any[]) => T;
|
|
31
42
|
/**
|
package/lib/api.d.ts
CHANGED
|
@@ -30,13 +30,10 @@ export declare class APIClient {
|
|
|
30
30
|
private pruneTicketFailures;
|
|
31
31
|
private ticketAuxiliaryRoute;
|
|
32
32
|
private defaultAuxiliaryRoute;
|
|
33
|
-
generateUserPortrait(user: User, messages: Sat.Msg[]): Promise<{
|
|
34
|
-
content: string;
|
|
35
|
-
error: boolean;
|
|
36
|
-
}>;
|
|
37
33
|
private createPayload;
|
|
38
34
|
private createAuxiliaryPayload;
|
|
39
35
|
private tryRequest;
|
|
36
|
+
private sendChat;
|
|
40
37
|
private createHeaders;
|
|
41
38
|
private handleAPIError;
|
|
42
39
|
private rotateKey;
|
package/lib/favorability.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { User, FavorabilityLevel, FavorabilityConfig } from './types';
|
|
|
3
3
|
import { MoodManager } from './mood';
|
|
4
4
|
import { Sat } from './types';
|
|
5
5
|
export declare function handleFavorabilitySystem(ctx: Context, session: Session, config: FavorabilityConfig): Promise<string | void>;
|
|
6
|
+
export declare function isFamilyLevel(level: FavorabilityLevel): boolean;
|
|
6
7
|
export declare function getFavorabilityLevel(user: User, config: FavorabilityConfig): FavorabilityLevel;
|
|
7
8
|
export declare function generateLevelPrompt(level: FavorabilityLevel, config: FavorabilityConfig, user: User): string;
|
|
8
9
|
export declare function generateAuxiliaryPrompt(prompt: string, responseContent: string, user: User, config: FavorabilityConfig): Sat.Msg[];
|
package/lib/game.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class Game {
|
|
|
14
14
|
private GAMES;
|
|
15
15
|
private channelGames;
|
|
16
16
|
private availableGames;
|
|
17
|
+
private oneTouchPvp;
|
|
17
18
|
private userUsage;
|
|
18
19
|
private context;
|
|
19
20
|
private config;
|
|
@@ -21,9 +22,13 @@ export declare class Game {
|
|
|
21
22
|
constructor(ctx: Context, cfg: Sat.Config, sat: SAT);
|
|
22
23
|
private registerCommands;
|
|
23
24
|
startGame(session: Session, gameName: string, args: string[]): Promise<string>;
|
|
25
|
+
private startOneTouchPvp;
|
|
24
26
|
endGame(session: Session): Promise<string>;
|
|
27
|
+
hasActiveGame(channelId: string): boolean;
|
|
28
|
+
private getGameController;
|
|
25
29
|
private chat;
|
|
26
30
|
private getGameCd;
|
|
27
31
|
private getGameList;
|
|
28
32
|
private resultJudge;
|
|
33
|
+
private judgePvp;
|
|
29
34
|
}
|
package/lib/gameOneTouch.d.ts
CHANGED
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
import { Session, Context } from 'koishi';
|
|
2
2
|
import { abstractGame, abstractGameSingleGame, gameResult } from './abstractGame';
|
|
3
3
|
import { winFlag } from './game';
|
|
4
|
+
export declare enum playerStatus {
|
|
5
|
+
Normal = 0,// 正常状态
|
|
6
|
+
Stunned = 1,// 眩晕状态
|
|
7
|
+
lastStunned = 2
|
|
8
|
+
}
|
|
9
|
+
export interface PlayerState {
|
|
10
|
+
left: number;
|
|
11
|
+
right: number;
|
|
12
|
+
hp: number;
|
|
13
|
+
shield?: number;
|
|
14
|
+
strength?: number;
|
|
15
|
+
bleed?: number;
|
|
16
|
+
counterAttack?: number;
|
|
17
|
+
vulnerablility?: number;
|
|
18
|
+
status: playerStatus;
|
|
19
|
+
}
|
|
20
|
+
export interface SkillEffect {
|
|
21
|
+
name?: string;
|
|
22
|
+
damage?: number;
|
|
23
|
+
damageTimes?: number;
|
|
24
|
+
pierceDamage?: number;
|
|
25
|
+
heal?: number;
|
|
26
|
+
shield?: number;
|
|
27
|
+
bleed?: number;
|
|
28
|
+
selfbleed?: number;
|
|
29
|
+
stun?: boolean;
|
|
30
|
+
destroyShield?: number;
|
|
31
|
+
weakStun?: boolean;
|
|
32
|
+
selfStun?: boolean;
|
|
33
|
+
strengthChange?: number;
|
|
34
|
+
selfstrengthChange?: number;
|
|
35
|
+
addSelfLeft?: number;
|
|
36
|
+
addSelfRight?: number;
|
|
37
|
+
addLeft?: number;
|
|
38
|
+
addRight?: number;
|
|
39
|
+
counterAttack?: number;
|
|
40
|
+
vulnerablility?: number;
|
|
41
|
+
magnificentEnd?: boolean;
|
|
42
|
+
revwersalOfStrength?: boolean;
|
|
43
|
+
}
|
|
4
44
|
export interface OneTouchResult extends gameResult {
|
|
5
45
|
win: winFlag;
|
|
6
46
|
bonus: number;
|
|
7
47
|
}
|
|
48
|
+
export declare const SKILL_MAP: {
|
|
49
|
+
[key: string]: SkillEffect;
|
|
50
|
+
};
|
|
8
51
|
declare class OneTouchSingleGame extends abstractGameSingleGame {
|
|
9
52
|
private player;
|
|
10
53
|
private ai;
|
|
@@ -38,13 +81,17 @@ declare class OneTouchSingleGame extends abstractGameSingleGame {
|
|
|
38
81
|
private generatePossibleMoves;
|
|
39
82
|
private cloneState;
|
|
40
83
|
private simulateMove;
|
|
41
|
-
private evaluateState;
|
|
42
84
|
private generateChat;
|
|
43
85
|
private instuction;
|
|
44
86
|
private skillList;
|
|
45
87
|
}
|
|
88
|
+
export declare const ONE_TOUCH_SKILL_LIST: string;
|
|
89
|
+
export declare function resolveCombo(a: number, b: number): SkillEffect | null;
|
|
90
|
+
export declare function applySkillEffect(self: PlayerState, enemy: PlayerState, effect: SkillEffect, isCombo: boolean): void;
|
|
91
|
+
export declare function buildEffectMessage(effect: SkillEffect, isCombo: boolean, self: PlayerState, enemy: PlayerState): string;
|
|
46
92
|
export declare class OneTouchGame extends abstractGame<OneTouchSingleGame> {
|
|
47
93
|
constructor();
|
|
48
94
|
startGame(session: Session, ctx: Context, args: string[]): Promise<OneTouchSingleGame>;
|
|
49
95
|
}
|
|
96
|
+
export declare function wrapInHTML(str: string): Promise<string>;
|
|
50
97
|
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Session, Context } from 'koishi';
|
|
2
|
+
import { abstractGame, abstractGameSingleGame, gameResult } from './abstractGame';
|
|
3
|
+
/**
|
|
4
|
+
* 一碰一 1v1 对战单局。双方都是真人,bot 只负责结算规则。
|
|
5
|
+
*/
|
|
6
|
+
export declare class OneTouchPvpSingleGame extends abstractGameSingleGame {
|
|
7
|
+
private ctx;
|
|
8
|
+
private players;
|
|
9
|
+
private maxHp;
|
|
10
|
+
private turn;
|
|
11
|
+
private phase;
|
|
12
|
+
private inviteTimer;
|
|
13
|
+
private turnTimer;
|
|
14
|
+
private onFinish;
|
|
15
|
+
constructor(disposeListener: () => boolean, session: Session, ctx: Context, opponent: {
|
|
16
|
+
id: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
}, maxHp: number, onFinish: () => void);
|
|
19
|
+
private createPlayer;
|
|
20
|
+
private initState;
|
|
21
|
+
startGame(): Promise<string>;
|
|
22
|
+
processInput(input: string, session?: Session): Promise<string>;
|
|
23
|
+
private startBattle;
|
|
24
|
+
private render;
|
|
25
|
+
private executeTurn;
|
|
26
|
+
private buildTurnText;
|
|
27
|
+
private formatStatus;
|
|
28
|
+
private buildAttackerBonus;
|
|
29
|
+
private buildDefenderBonus;
|
|
30
|
+
private settleTurnBonus;
|
|
31
|
+
private clearTurnTimer;
|
|
32
|
+
private clearTimers;
|
|
33
|
+
private resetTurnTimer;
|
|
34
|
+
private settle;
|
|
35
|
+
private abort;
|
|
36
|
+
private finish;
|
|
37
|
+
endGame(session?: Session): Promise<gameResult>;
|
|
38
|
+
private rules;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 一碰一 对战控制器:负责邀请、双方消息转发与单局生命周期。
|
|
42
|
+
*/
|
|
43
|
+
export declare class OneTouchPvpGame extends abstractGame<OneTouchPvpSingleGame> {
|
|
44
|
+
constructor();
|
|
45
|
+
startGame(session: Session, ctx: Context, args: string[]): Promise<abstractGameSingleGame | null>;
|
|
46
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Sat, User } from './types';
|
|
|
3
3
|
import Puppeteer from 'koishi-plugin-puppeteer';
|
|
4
4
|
import { BroadcastManager } from './broadcast';
|
|
5
5
|
import { WeatherManager } from './weather';
|
|
6
|
+
import { ProactiveManager } from './proactive';
|
|
6
7
|
export declare let puppeteer: Puppeteer | null;
|
|
7
8
|
export declare function refreshPuppeteer(ctx: Context): void;
|
|
8
9
|
export declare class SAT extends Sat {
|
|
@@ -14,6 +15,7 @@ export declare class SAT extends Sat {
|
|
|
14
15
|
private moodManager;
|
|
15
16
|
broadcastManager: BroadcastManager;
|
|
16
17
|
weatherManager: WeatherManager;
|
|
18
|
+
proactive: ProactiveManager;
|
|
17
19
|
private usersToWarn;
|
|
18
20
|
private puppeteer;
|
|
19
21
|
private game;
|
|
@@ -44,11 +46,18 @@ export declare class SAT extends Sat {
|
|
|
44
46
|
error: boolean;
|
|
45
47
|
reasoning_content?: string;
|
|
46
48
|
}>;
|
|
47
|
-
getChatResponse(user: User, messages: Sat.Msg[], prompt: string): Promise<{
|
|
49
|
+
getChatResponse(user: User, messages: Sat.Msg[], prompt: string, session?: Session): Promise<{
|
|
48
50
|
content: string;
|
|
49
51
|
error: boolean;
|
|
50
52
|
reasoning_content?: string;
|
|
51
53
|
}>;
|
|
54
|
+
/**
|
|
55
|
+
* 生成一条主动消息(不写入长期记忆,不扣使用次数)。
|
|
56
|
+
* idleMinutes 用于告诉模型沉默时长;queryHint 用用户最后一句做记忆检索。
|
|
57
|
+
*/
|
|
58
|
+
generateProactive(session: Session, idleMinutes: number, queryHint?: string): Promise<string>;
|
|
59
|
+
/** 主动消息成功后由发送方调用,只写短期记忆 */
|
|
60
|
+
recordProactive(session: Session, content: string): void;
|
|
52
61
|
private buildMessages;
|
|
53
62
|
private buildSystemPrompt;
|
|
54
63
|
private getThinkingPrompt;
|
|
@@ -60,9 +69,14 @@ export declare class SAT extends Sat {
|
|
|
60
69
|
addGroupCommonSense(session: Session, content: string, groupId: string): Promise<string>;
|
|
61
70
|
private handleUserLevel;
|
|
62
71
|
private handleUserUsage;
|
|
72
|
+
isGameActive(session: Session): boolean;
|
|
63
73
|
handleRandomMiddleware(session: Session): Promise<string>;
|
|
74
|
+
/** 群聊环境里代表 bot 自己的名字:昵称列表第一个加「(你)」,让模型能分辨这是自己的发言 */
|
|
75
|
+
private getSelfDialogueName;
|
|
64
76
|
handleNickNameMiddleware(session: Session, prompt: string): Promise<string>;
|
|
65
77
|
handleChannelMemoryManager(session: Session): Promise<void>;
|
|
78
|
+
private handleDigest;
|
|
79
|
+
private renderDigestCard;
|
|
66
80
|
dispose(): Promise<void>;
|
|
67
81
|
}
|
|
68
82
|
export default SAT;
|