koishi-plugin-chatluna-affinity 0.3.0-beta.4 → 0.3.1
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/index.d.ts +17 -14
- package/lib/index.js +39 -14
- package/package.json +19 -17
- package/readme.md +24 -145
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as cosmokit from 'cosmokit';
|
|
2
2
|
import { Schema, Session, Context } from 'koishi';
|
|
3
3
|
import { CharacterServiceLike as CharacterServiceLike$1, TempLike, CompletionMessagesLike } from 'shared-chatluna-xmltools';
|
|
4
4
|
|
|
@@ -193,7 +193,7 @@ declare const RelationshipSchema: Schema<Schemastery.ObjectS<{
|
|
|
193
193
|
userId?: string | null | undefined;
|
|
194
194
|
relation?: string | null | undefined;
|
|
195
195
|
note?: string | null | undefined;
|
|
196
|
-
} &
|
|
196
|
+
} & cosmokit.Dict)[], Schemastery.ObjectT<{
|
|
197
197
|
userId: Schema<string, string>;
|
|
198
198
|
relation: Schema<string, string>;
|
|
199
199
|
note: Schema<string, string>;
|
|
@@ -203,7 +203,7 @@ declare const RelationshipSchema: Schema<Schemastery.ObjectS<{
|
|
|
203
203
|
max?: number | null | undefined;
|
|
204
204
|
relation?: string | null | undefined;
|
|
205
205
|
note?: string | null | undefined;
|
|
206
|
-
} &
|
|
206
|
+
} & cosmokit.Dict)[], Schemastery.ObjectT<{
|
|
207
207
|
min: Schema<number, number>;
|
|
208
208
|
max: Schema<number, number>;
|
|
209
209
|
relation: Schema<string, string>;
|
|
@@ -214,7 +214,7 @@ declare const RelationshipSchema: Schema<Schemastery.ObjectS<{
|
|
|
214
214
|
userId?: string | null | undefined;
|
|
215
215
|
relation?: string | null | undefined;
|
|
216
216
|
note?: string | null | undefined;
|
|
217
|
-
} &
|
|
217
|
+
} & cosmokit.Dict)[], Schemastery.ObjectT<{
|
|
218
218
|
userId: Schema<string, string>;
|
|
219
219
|
relation: Schema<string, string>;
|
|
220
220
|
note: Schema<string, string>;
|
|
@@ -224,7 +224,7 @@ declare const RelationshipSchema: Schema<Schemastery.ObjectS<{
|
|
|
224
224
|
max?: number | null | undefined;
|
|
225
225
|
relation?: string | null | undefined;
|
|
226
226
|
note?: string | null | undefined;
|
|
227
|
-
} &
|
|
227
|
+
} & cosmokit.Dict)[], Schemastery.ObjectT<{
|
|
228
228
|
min: Schema<number, number>;
|
|
229
229
|
max: Schema<number, number>;
|
|
230
230
|
relation: Schema<string, string>;
|
|
@@ -267,24 +267,24 @@ declare const ConfigSchema: Schema<{
|
|
|
267
267
|
demoteThreshold?: number | null | undefined;
|
|
268
268
|
longTermPromoteStep?: number | null | undefined;
|
|
269
269
|
longTermDemoteStep?: number | null | undefined;
|
|
270
|
-
} &
|
|
270
|
+
} & cosmokit.Dict) | null | undefined;
|
|
271
271
|
actionWindow?: ({
|
|
272
272
|
windowHours?: number | null | undefined;
|
|
273
273
|
increaseBonus?: number | null | undefined;
|
|
274
274
|
decreaseBonus?: number | null | undefined;
|
|
275
275
|
bonusChatThreshold?: number | null | undefined;
|
|
276
276
|
maxEntries?: number | null | undefined;
|
|
277
|
-
} &
|
|
277
|
+
} & cosmokit.Dict) | null | undefined;
|
|
278
278
|
coefficient?: ({
|
|
279
279
|
base?: number | null | undefined;
|
|
280
280
|
maxDrop?: number | null | undefined;
|
|
281
281
|
maxBoost?: number | null | undefined;
|
|
282
282
|
decayPerDay?: number | null | undefined;
|
|
283
283
|
boostPerDay?: number | null | undefined;
|
|
284
|
-
} &
|
|
285
|
-
} &
|
|
284
|
+
} & cosmokit.Dict) | null | undefined;
|
|
285
|
+
} & cosmokit.Dict) | null | undefined;
|
|
286
286
|
rankDefaultLimit?: number | null | undefined;
|
|
287
|
-
} &
|
|
287
|
+
} & cosmokit.Dict & {
|
|
288
288
|
blacklistLogInterception?: boolean | null | undefined;
|
|
289
289
|
shortTermBlacklistPenalty?: number | null | undefined;
|
|
290
290
|
unblockPermanentInitialAffinity?: number | null | undefined;
|
|
@@ -294,13 +294,13 @@ declare const ConfigSchema: Schema<{
|
|
|
294
294
|
userId?: string | null | undefined;
|
|
295
295
|
relation?: string | null | undefined;
|
|
296
296
|
note?: string | null | undefined;
|
|
297
|
-
} &
|
|
297
|
+
} & cosmokit.Dict)[] | null | undefined;
|
|
298
298
|
relationshipAffinityLevels?: ({
|
|
299
299
|
min?: number | null | undefined;
|
|
300
300
|
max?: number | null | undefined;
|
|
301
301
|
relation?: string | null | undefined;
|
|
302
302
|
note?: string | null | undefined;
|
|
303
|
-
} &
|
|
303
|
+
} & cosmokit.Dict)[] | null | undefined;
|
|
304
304
|
} & {
|
|
305
305
|
scopeId?: string | null | undefined;
|
|
306
306
|
botSelfIds?: string[] | null | undefined;
|
|
@@ -313,6 +313,7 @@ declare const ConfigSchema: Schema<{
|
|
|
313
313
|
characterPromptTemplate?: string | null | undefined;
|
|
314
314
|
} & {
|
|
315
315
|
affinityVariableName?: string | null | undefined;
|
|
316
|
+
showChatCountInAffinityVariable?: boolean | null | undefined;
|
|
316
317
|
affinityDisplayRange?: number | null | undefined;
|
|
317
318
|
relationshipLevelVariableName?: string | null | undefined;
|
|
318
319
|
blacklistListVariableName?: string | null | undefined;
|
|
@@ -366,7 +367,7 @@ declare const ConfigSchema: Schema<{
|
|
|
366
367
|
}>>;
|
|
367
368
|
}>;
|
|
368
369
|
rankDefaultLimit: number;
|
|
369
|
-
} &
|
|
370
|
+
} & cosmokit.Dict & {
|
|
370
371
|
blacklistLogInterception: boolean;
|
|
371
372
|
shortTermBlacklistPenalty: number;
|
|
372
373
|
unblockPermanentInitialAffinity: number;
|
|
@@ -395,6 +396,7 @@ declare const ConfigSchema: Schema<{
|
|
|
395
396
|
characterPromptTemplate: string;
|
|
396
397
|
} & {
|
|
397
398
|
affinityVariableName: string;
|
|
399
|
+
showChatCountInAffinityVariable: boolean;
|
|
398
400
|
affinityDisplayRange: number;
|
|
399
401
|
relationshipLevelVariableName: string;
|
|
400
402
|
blacklistListVariableName: string;
|
|
@@ -714,6 +716,7 @@ interface ManualRelationship {
|
|
|
714
716
|
}
|
|
715
717
|
interface VariableSettings {
|
|
716
718
|
affinityVariableName: string;
|
|
719
|
+
showChatCountInAffinityVariable: boolean;
|
|
717
720
|
relationshipLevelVariableName: string;
|
|
718
721
|
blacklistListVariableName: string;
|
|
719
722
|
}
|
|
@@ -1805,6 +1808,6 @@ declare function callOneBotAPI(internal: OneBotInternal, action: string, params:
|
|
|
1805
1808
|
* 导出插件元信息和 apply 函数
|
|
1806
1809
|
*/
|
|
1807
1810
|
|
|
1808
|
-
declare const usage = "\n## \u66F4\u65B0\u65E5\u5FD7\n\n0.3.0
|
|
1811
|
+
declare const usage = "\n## \u4F7F\u7528\u8BF4\u660E\n\n\u9996\u6B21\u4F7F\u7528\u524D\u8BF7\u5148\u9605\u8BFB [readme.md](https://github.com/Sor85/AAAAACAT-chatluna-plugins/blob/main/plugins/chatluna-affinity/readme.md)\uFF0C\u6309\u6587\u6863\u5B8C\u6210\u4F9D\u8D56\u5B89\u88C5\u3001`scopeId` \u914D\u7F6E\u3001\u53D8\u91CF\u6CE8\u5165\u548C XML \u5DE5\u5177\u63A5\u5165\u3002\n\n\u5982\u679C\u4F60\u4E3B\u8981\u5728 ChatLuna Character \u4E2D\u4F7F\u7528\u672C\u63D2\u4EF6\uFF0C\u8BF7\u4F18\u5148\u67E5\u770B readme.md \u4E2D\u7684\u201C\u5FEB\u901F\u4E0A\u624B\u201D\u548C\u201C\u53D8\u91CF\u201D\u7AE0\u8282\u3002\n\n## \u66F4\u65B0\u65E5\u5FD7\n\n0.3.0\n\n### \u91CD\u6784\n- \u5F15\u5165 `scopeId` \u4F5C\u4E3A\u65B0\u7684\u6838\u5FC3\u4F5C\u7528\u57DF\u8BED\u4E49\uFF1B\u6570\u636E\u9694\u79BB\u4ECE\u65E7\u7248\u6309 bot / \u65E7\u4E3B\u952E\u5207\u6362\u4E3A\u6309 `scopeId` \u9694\u79BB\u3002\n- \u5355\u4E2A\u5B9E\u4F8B\u5185\u7684\u591A\u4E2A bot \u73B0\u5728\u5171\u4EAB\u540C\u4E00\u4EFD `scopeId` \u6570\u636E\uFF1B\u5171\u4EAB\u8303\u56F4\u8986\u76D6\u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u3001\u7279\u6B8A\u5173\u7CFB\u4E0E\u6635\u79F0\u3002\n- \u6570\u636E\u5E93\u6A21\u578B\u5347\u7EA7\u4E3A v2\uFF1A\n - `chatluna_affinity` -> `chatluna_affinity_v2`\n - `chatluna_blacklist` -> `chatluna_blacklist_v2`\n - `chatluna_user_alias` -> `chatluna_user_alias_v2`\n- \u65B0\u589E\u6570\u636E\u5E93\u8FC1\u79FB\u670D\u52A1\u4E0E\u8FC1\u79FB\u8BB0\u5F55\u8868\uFF0C\u542F\u52A8\u65F6\u4F1A\u81EA\u52A8\u5C06\u65E7\u8868\u8FC1\u79FB\u5230 v2 \u7ED3\u6784\u3002\n- \u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u4E0E\u6A21\u578B\u54CD\u5E94\u5904\u7406\u94FE\u8DEF\u91CD\u6784\u4E3A\u66F4\u6E05\u6670\u7684\u670D\u52A1\u5316\u7ED3\u6784\u3002\n\n### \u65B0\u589E\n- \u65B0\u589E `scopeId` \u914D\u7F6E\uFF1B\u5F53\u524D\u7248\u672C\u6309 `scopeId` \u533A\u5206\u6570\u636E\uFF0C\u4E0D\u540C\u5B9E\u4F8B\u4E4B\u95F4\u5B8C\u5168\u9694\u79BB\u3002\n- \u65B0\u589E `botSelfIds` \u914D\u7F6E\uFF0C\u7528\u4E8E\u58F0\u660E\u54EA\u4E9B bot \u5F52\u5C5E\u5F53\u524D `scopeId`\uFF1B\u540C\u4E00 `scopeId` \u4E0B\u591A\u4E2A bot \u5171\u4EAB\u6570\u636E\uFF0C\u7528\u4E8E\u9996\u6B21\u4E92\u52A8\u521D\u59CB\u5316\u597D\u611F\u5EA6\u3002\n- \u65B0\u589E\u4F5C\u7528\u57DF\u5316\u547D\u4EE4\u524D\u7F00\uFF0C\u547D\u4EE4\u7531\u56FA\u5B9A `affinity.*` \u6539\u4E3A `${scopeId}.*`\u3002\n- \u65B0\u589E\u6C38\u4E45\u9ED1\u540D\u5355\u89E3\u9664\u540E\u7684\u597D\u611F\u5EA6\u91CD\u7F6E\u903B\u8F91\uFF1B\u89E3\u9664\u540E\u4F1A\u540C\u65F6\u91CD\u7F6E\u597D\u611F\u5EA6\u76F8\u5173\u72B6\u6001\u3002\n- \u65B0\u589E\u4F5C\u7528\u57DF\u5316\u53D8\u91CF\u8C03\u7528\u8981\u6C42\uFF0C\u53D8\u91CF\u73B0\u5728\u9700\u8981\u663E\u5F0F\u4F20\u5165 `scopeId`\u3002\n- \u65B0\u589E `affinity` \u53D8\u91CF\u7684 `chatcount` \u8F93\u51FA\uFF0C\u9ED8\u8BA4\u663E\u793A\u7528\u6237\u5BF9\u8BDD\u6B21\u6570\uFF0C\u53EF\u5728\u53D8\u91CF\u8BBE\u7F6E\u4E2D\u5173\u95ED\u3002\n- \u65B0\u589E `injectXmlToolAsReplyTool` \u9009\u9879\uFF0C\u53EF\u5C06 XML \u5DE5\u5177\u6CE8\u5165\u5230 ChatLuna Character \u7684\u5B9E\u9A8C\u6027\u5DE5\u5177\u8C03\u7528\u56DE\u590D\u53C2\u6570\u4E2D\u3002\n\n### \u4FEE\u6539\n- \u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u3001\u6635\u79F0\u6570\u636E\u7684\u5199\u5165\u4E0E\u8BFB\u53D6\u4E3B\u952E\u8BED\u4E49\u6539\u4E3A\u4EE5 `scopeId` \u4E3A\u6838\u5FC3\uFF1A\n - \u597D\u611F\u5EA6\uFF1A`scopeId + userId`\n - \u9ED1\u540D\u5355\uFF1A`scopeId + userId + mode`\n - \u7528\u6237\u6635\u79F0\uFF1A`scopeId + userId`\n- \u591A bot \u5171\u4EAB\u65B9\u6848\u4ECE\u65E7\u7248\u5206\u7EC4\u914D\u7F6E\u6539\u4E3A\u7EDF\u4E00\u7684 `scopeId` \u8BED\u4E49\u3002\n- \u597D\u611F\u5EA6\u521D\u59CB\u5316\u65F6\u673A\u6539\u4E3A\u201C\u4E0E bot \u9996\u6B21\u6709\u6548\u4EA4\u4E92\u65F6\u5165\u5E93\u201D\uFF0C\u4E0D\u518D\u5728\u6536\u5230\u6D88\u606F\u65F6\u63D0\u524D\u521D\u59CB\u5316\u3002\n- \u968F\u673A\u521D\u59CB\u597D\u611F\u5EA6\u6539\u4E3A\u56FA\u5B9A\u521D\u59CB\u597D\u611F\u5EA6\uFF0C\u9ED8\u8BA4\u503C\u4E3A `30`\u3002\n- `userAlias` \u7684\u6635\u79F0\u4FE1\u606F\u5DF2\u878D\u5165 `affinity` \u53D8\u91CF\u8F93\u51FA\uFF1B\u5F53\u524D\u8F93\u51FA\u5F62\u6001\u4E3A `id name nickname affinity relationship chatcount`\u3002\n- \u5BF9\u4E8E\u5C1A\u672A\u4E0E bot \u4EA7\u751F\u6709\u6548\u4E92\u52A8\u7684\u7528\u6237\uFF0C`affinity` \u53D8\u91CF\u73B0\u5728\u4F1A\u76F4\u63A5\u663E\u793A\u9ED8\u8BA4\u597D\u611F\u5EA6\uFF0C\u4EE5\u53CA\u8BE5\u9ED8\u8BA4\u503C\u5BF9\u5E94\u7684\u5173\u7CFB\u3002\n- \u5173\u7CFB\u533A\u95F4\u53D8\u91CF\u540D\u7531 `relationshipAffinityLevel` \u7B80\u5316\u4E3A `relationshipLevel`\u3002\n- \u6240\u6709\u53D8\u91CF\u73B0\u5728\u90FD\u9700\u8981\u663E\u5F0F\u4F20\u5165 `scopeId`\uFF0C\u4F8B\u5982\uFF1A\n - `relationshipLevel(scopeId)`\n - `affinity(scopeId)`\n - `blacklistList(scopeId)`\n- XML \u5DE5\u5177\u8C03\u7528\u53C2\u6570\u6539\u4E3A\u663E\u5F0F\u4F5C\u7528\u57DF\u98CE\u683C\uFF0C\u6838\u5FC3\u5B57\u6BB5\u7EDF\u4E00\u4E3A `scopeId + userId`\u3002\n- `scopeId` \u4F1A\u76F4\u63A5\u4F5C\u4E3A\u6307\u4EE4\u524D\u7F00\uFF1B\u4E0D\u8981\u4F7F\u7528\u4E0E bot \u540D\u79F0\u76F8\u540C\u7684 `scopeId`\uFF0C\u5EFA\u8BAE\u4F18\u5148\u4F7F\u7528\u82F1\u6587\u3002\n- \u65E5\u7A0B\u3001\u5929\u6C14\u80FD\u529B\u62C6\u5206\u81F3 `koishi-plugin-chatluna-schedule`\u3002\n- \u66F4\u591A\u53D8\u91CF\u4E0E XML \u5DE5\u5177\u80FD\u529B\u62C6\u5206\u81F3 `koishi-plugin-chatluna-toolbox`\u3002\n\n### \u5220\u9664\n- \u5220\u9664 ChatLuna \u539F\u751F\u5DE5\u5177\u6CE8\u518C\u80FD\u529B\uFF0C\u5F53\u524D\u7248\u672C\u4E0D\u518D\u63D0\u4F9B\u539F\u751F\u5DE5\u5177\u3002\n- \u5220\u9664\u65E7\u7248 `affinityGroups` \u5171\u4EAB\u5206\u7EC4\u914D\u7F6E\u3002\n- \u5220\u9664\u56FA\u5B9A\u547D\u4EE4\u524D\u7F00 `affinity.*` \u7684\u547D\u540D\u65B9\u5F0F\u3002\n- \u5220\u9664 `relationshipAffinityLevel` \u65E7\u547D\u540D\u3002\n- \u5220\u9664\u4EE5\u4E0B\u52A8\u6001\u914D\u7F6E\u9879\uFF1A\n - \u5355\u6B21\u589E\u52A0\u7684\u77ED\u671F\u597D\u611F\u6700\u5927\u5E45\u5EA6\n - \u5355\u6B21\u51CF\u5C11\u7684\u77ED\u671F\u597D\u611F\u6700\u5927\u5E45\u5EA6\n - \u5141\u8BB8\u989D\u5916\u589E\u51CF\u7A81\u7834\u5355\u6B21\u4E0A\u9650\n- `userAlias` \u4E0D\u518D\u4F5C\u4E3A\u72EC\u7ACB\u53D8\u91CF\u66B4\u9732\uFF1B\u6635\u79F0\u80FD\u529B\u4FDD\u7559\u5728 XML \u4E0E `affinity` \u53D8\u91CF\u8F93\u51FA\u4E2D\u3002\n\n### \u517C\u5BB9\u6027\u63D0\u9192\n- \u8FD9\u662F\u4E00\u6B21\u5E26\u6709\u7834\u574F\u6027\u517C\u5BB9\u53D8\u66F4\u7684\u91CD\u6784\u5347\u7EA7\uFF1B\u65E7\u547D\u4EE4\u3001\u65E7 XML \u53C2\u6570\u548C\u65E7\u53D8\u91CF\u8C03\u7528\u65B9\u5F0F\u90FD\u9700\u8981\u540C\u6B65\u8C03\u6574\u3002\n- \u8FC1\u79FB\u4F1A\u628A\u65E7\u6570\u636E\u6574\u4F53\u5F52\u5165\u5F53\u524D\u5B9E\u4F8B\u7684 `scopeId`\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u62C6\u5206\u4E3A\u591A\u4E2A\u4F5C\u7528\u57DF\u3002\n";
|
|
1809
1812
|
|
|
1810
1813
|
export { ACTION_WINDOW_DEFAULTS, AFFINITY_DEFAULTS, AFFINITY_DYNAMICS_DEFAULTS, ALL_MEMBER_INFO_ITEMS, type ActionCounts, type ActionEntry, type ActionStats, type ActionType, type ActionWindowConfig, type AffinityCache, type AffinityDynamicsConfig, type AffinityProvider, type AffinityProviderDeps, type AffinityRecord, AffinitySchema, type AffinityState, type AffinityStore, type AffinityStoreOptions, type ApplyAffinityDeltaParams, type ApplyAffinityDeltaResult, BASE_AFFINITY_DEFAULTS, BLACKLIST_MODEL_NAME, BLACKLIST_MODEL_NAME_V2, BLACKLIST_REPLY_TEMPLATE, type BlacklistCommandDeps, type BlacklistDetail, type BlacklistEnrichedItem, type BlacklistEntry, type BlacklistGuard, type BlacklistGuardOptions, type BlacklistItem, type BlacklistListProvider, type BlacklistListProviderDeps, type BlacklistMode, type BlacklistRecord, type BlacklistRenderer, BlacklistSchema, type BlacklistService, type BlacklistServiceOptions, type BlockCommandDeps, CLOUD_TYPES, COEFFICIENT_DEFAULTS, COMMON_STYLE, type CharacterTempModelResponseRuntime, type CharacterTempModelResponseRuntimeParams, type ClampFn, type CoefficientConfig, type CoefficientResult, type CoefficientState, type CombinedState, type CommandDependencies, ConfigSchema as Config, ConfigSchema, DEFAULT_MEMBER_INFO_ITEMS, type Element, FETCH_CONSTANTS, type HistoryEntry, type InMemoryTemporaryEntry, type InitialRange, type InspectData, type InspectRenderer, type LegacyAffinityRecord, type LegacyBlacklistRecord, type LegacyUserAliasRecord, type LevelResolver, type LogFn, type LogLevel, MIGRATION_MODEL_NAME, MODEL_NAME, MODEL_NAME_V2, type ManualConfigOptions, type ManualRelationship, type ManualRelationshipManager, type MemberInfo, type MemberInfoField, type MessageHistory, type MessageHistoryOptions, type MessageStore, type MessageStoreOptions, type MigrationOptions, type MigrationRecord, type ModelResponseContext, type ModelResponseProcessorParams, type OneBotInternal, type OneBotProtocol, OtherSettingsSchema, type Page, type Puppeteer, RENDER_CONSTANTS, ROLE_MAPPING, type RankItem, type RankLineItem, type RankListRenderer, type RelationshipLevel, type RelationshipLevelProvider, type RelationshipLevelProviderDeps, RelationshipSchema, type RenderMemberInfoOptions, type RenderOptions, type RenderService, type RenderServiceOptions, type ResolvedActionWindowConfig, type ResolvedCoefficientConfig, type ResolvedShortTermConfig, type RoleMapping, type RoleTranslation, SHORT_TERM_DEFAULTS, type SaveExtra, type SessionSeed, type ShortTermConfig, type StoredMessage, type SummarizedActions, THRESHOLDS, TIME_CONSTANTS, TIMING_CONSTANTS, type TableRenderOptions, type TableRenderer, type TempBlockCommandDeps, type TemporaryBlacklistEntry, USER_ALIAS_MODEL_NAME, USER_ALIAS_MODEL_NAME_V2, type UnblockPermanentDeps, type UnblockPermanentInput, type UnblockPermanentResult, type UserAliasRecord, type UserAliasService, type UserAliasServiceOptions, type VariableSettings, type XmlToolSettings, appendActionEntry, apply, applyAffinityDelta, assertScopeId, buildScopedCommandName, callOneBotAPI, clamp, clampFloat, collectNicknameCandidates, collectRoleCandidates, composeState, computeCoefficientValue, computeDailyStreak, computeShortTermReset, createAffinityCache, createAffinityProvider, createAffinityStore, createBlacklistGuard, createBlacklistListProvider, createBlacklistRenderer, createBlacklistService, createCharacterTempModelResponseRuntime, createInspectRenderer, createLevelResolver, createLogger, createManualRelationshipManager, createMessageHistory, createMessageStore, createMigrationService, createModelResponseProcessor, createPermanentUnblockHandler, createRankListRenderer, createRelationshipLevelProvider, createRenderService, createTableRenderer, createUserAliasService, dayNumber, ensureOneBotSession, escapeHtml, escapeHtmlForRender, extendAffinityModel, extendBlacklistModel, extendMigrationModel, extendUserAliasModel, fetchGroupMemberIds, fetchMember, findMemberByName, formatActionCounts, formatBeijingTimestamp, formatDateOnly, formatDateTime, formatTimestamp, getChannelId, getDateString, getGuildId, getPlatform, getPuppeteer, getRoleDisplay, getSelfId, getTimeString, getUserId, hasReplyToolsEnabled, inject, isFiniteNumber, isValidScopeId, makeUserKey, name, normalizeScopeId, normalizeTimestamp, pickFirst, registerAdjustCommand, registerBlacklistCommand, registerBlockCommand, registerCharacterReplyTools, registerClearAllCommand, registerInspectCommand, registerModels, registerRankCommand, registerTempBlockCommand, renderHtml, renderInfoField, renderMemberInfo, renderTemplate, resolveActionWindowConfig, resolveBotInfo, resolveCoefficientConfig, resolveGroupId, resolveRoleLabel, resolveScopedVariableArgs, resolveShortTermConfig, resolveUserIdentity, resolveUserInfo, resolveXmlScopeId, roundTo, sanitizeChannel, stripAtPrefix, summarizeActionEntries, toDate, translateGender, translateRole, truncate, usage };
|
package/lib/index.js
CHANGED
|
@@ -201,6 +201,10 @@ var require_lib = __commonJS({
|
|
|
201
201
|
writable: true
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
+
function createMessageFingerprint(message, response) {
|
|
205
|
+
const type = String(message.type ?? message.role ?? "").trim().toLowerCase();
|
|
206
|
+
return `${type}:${response}`;
|
|
207
|
+
}
|
|
204
208
|
function restoreDispatcher(key, dispatcher) {
|
|
205
209
|
if (dispatcher.messages.push === dispatcher.patchedPush) {
|
|
206
210
|
dispatcher.messages.push = dispatcher.originalPush;
|
|
@@ -212,17 +216,22 @@ var require_lib = __commonJS({
|
|
|
212
216
|
let dispatcher = getDispatcher(messages, key);
|
|
213
217
|
if (!dispatcher) {
|
|
214
218
|
const listeners = /* @__PURE__ */ new Set();
|
|
215
|
-
const processedMessages = /* @__PURE__ */ new
|
|
219
|
+
const processedMessages = /* @__PURE__ */ new WeakMap();
|
|
216
220
|
const originalPush = messages.push;
|
|
217
221
|
const patchedPush = function patchedPush2(...items) {
|
|
218
222
|
const result = originalPush.apply(this, items);
|
|
219
223
|
for (const item of items) {
|
|
220
224
|
if (!item || typeof item !== "object") continue;
|
|
221
|
-
if (processedMessages.has(item)) continue;
|
|
222
|
-
processedMessages.add(item);
|
|
223
225
|
const message = item;
|
|
224
226
|
const response = extractAssistantText(message);
|
|
225
227
|
if (!response) continue;
|
|
228
|
+
const fingerprint = createMessageFingerprint(
|
|
229
|
+
item,
|
|
230
|
+
response
|
|
231
|
+
);
|
|
232
|
+
const previousFingerprint = processedMessages.get(item);
|
|
233
|
+
if (previousFingerprint === fingerprint) continue;
|
|
234
|
+
processedMessages.set(item, fingerprint);
|
|
226
235
|
for (const listener2 of Array.from(listeners)) {
|
|
227
236
|
try {
|
|
228
237
|
listener2(message);
|
|
@@ -835,12 +844,13 @@ var XmlToolSettingsSchema = import_koishi4.Schema.object({
|
|
|
835
844
|
<userAlias scopeId="{scopeId}" userId="123456" name="\u5C0F\u7965"/>
|
|
836
845
|
</actions>
|
|
837
846
|
\`\`\``
|
|
838
|
-
).description("\u6A21\u578B\u56DE\u590D XML \u53C2\u8003\u63D0\u793A\u8BCD\
|
|
847
|
+
).description("\u6A21\u578B\u56DE\u590D XML \u53C2\u8003\u63D0\u793A\u8BCD\u3002\u6B64\u5185\u5BB9\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165\u5230\u89D2\u8272\u63D0\u793A\u8BCD\u4E2D\uFF1B\u8BF7\u5148\u5C06 {scopeId} \u66FF\u6362\u4E3A\u5B9E\u9645 scopeId\uFF0C\u518D\u624B\u52A8\u590D\u5236\u5230 ChatLuna Character \u7684\u89D2\u8272\u63D0\u793A\u8BCD\u91CC\u3002\u82E5\u5F00\u542F\u201C\u5C06 XML \u5DE5\u5177\u6539\u4E3A\u6CE8\u5165\u5B9E\u9A8C\u6027\u5DE5\u5177\u8C03\u7528\u56DE\u590D\u201D\uFF0C\u5219\u53EA\u9700\u5728\u63D0\u793A\u8BCD\u4E2D\u544A\u77E5 AI \u4F60\u7684 scopeId").collapse()
|
|
839
848
|
}).description("XML \u5DE5\u5177\u8BBE\u7F6E");
|
|
840
849
|
var VariableSettingsSchema = import_koishi4.Schema.object({
|
|
841
850
|
affinityVariableName: import_koishi4.Schema.string().default("affinity").description(
|
|
842
|
-
'\u597D\u611F\u5EA6\u53D8\u91CF\u540D\u79F0\uFF0C\u8C03\u7528\u793A\u4F8B\uFF1A{affinity("scopeId")}\uFF0C\u8BF7\u5C06 scopeId \u66FF\u6362\u4E3A\u4F60\u8BBE\u5B9A\u7684\u5B9E\u9645 scopeId\u3002\u8FD4\u56DE\u683C\u5F0F\u4E3A\u6587\u672C\u884C\uFF0C\u5305\u542B id\u3001name\u3001nickname\u3001affinity\u3001relationship\uFF1B\u5F53\u5C55\u793A\u8303\u56F4\u5927\u4E8E 1 \u65F6\u4F1A\u8FD4\u56DE\u591A\u884C\u3002'
|
|
851
|
+
'\u597D\u611F\u5EA6\u53D8\u91CF\u540D\u79F0\uFF0C\u8C03\u7528\u793A\u4F8B\uFF1A{affinity("scopeId")}\uFF0C\u8BF7\u5C06 scopeId \u66FF\u6362\u4E3A\u4F60\u8BBE\u5B9A\u7684\u5B9E\u9645 scopeId\u3002\u8FD4\u56DE\u683C\u5F0F\u4E3A\u6587\u672C\u884C\uFF0C\u5305\u542B id\u3001name\u3001nickname\u3001affinity\u3001relationship\u3001chatcount\uFF1B\u5F53\u5C55\u793A\u8303\u56F4\u5927\u4E8E 1 \u65F6\u4F1A\u8FD4\u56DE\u591A\u884C\u3002'
|
|
843
852
|
),
|
|
853
|
+
showChatCountInAffinityVariable: import_koishi4.Schema.boolean().default(true).description("\u5728\u597D\u611F\u5EA6\u53D8\u91CF\u4E2D\u663E\u793A\u5BF9\u8BDD\u6B21\u6570 chatcount"),
|
|
844
854
|
affinityDisplayRange: import_koishi4.Schema.number().default(1).min(1).step(1).description("\u663E\u793A\u5F53\u524D\u4E0A\u4E0B\u6587\u4E2D\u591A\u5C11\u4F4D\u7528\u6237\u7684\u597D\u611F\u5EA6\u4FE1\u606F"),
|
|
845
855
|
relationshipLevelVariableName: import_koishi4.Schema.string().default("relationshipLevel").description(
|
|
846
856
|
'\u597D\u611F\u5EA6\u533A\u95F4\u53D8\u91CF\u540D\u79F0\uFF0C\u8C03\u7528\u793A\u4F8B\uFF1A{relationshipLevel("scopeId")}\uFF0C\u8BF7\u5C06 scopeId \u66FF\u6362\u4E3A\u4F60\u8BBE\u5B9A\u7684\u5B9E\u9645 scopeId\u3002\u8FD4\u56DE\u683C\u5F0F\u4E3A\u6587\u672C\u884C\uFF0C\u5217\u51FA\u5F53\u524D\u914D\u7F6E\u4E2D\u7684\u6240\u6709\u533A\u95F4\uFF0C\u5305\u542B min\u3001max\u3001relationship\u3001note\u3002'
|
|
@@ -4500,7 +4510,8 @@ function createAffinityProvider(deps) {
|
|
|
4500
4510
|
`name:${row.name}`,
|
|
4501
4511
|
row.nickname ? `nickname:${row.nickname}` : "",
|
|
4502
4512
|
`affinity:${row.affinity}`,
|
|
4503
|
-
`relationship:${row.relationship}
|
|
4513
|
+
`relationship:${row.relationship}`,
|
|
4514
|
+
config.variableSettings.showChatCountInAffinityVariable ? `chatcount:${row.chatCount}` : ""
|
|
4504
4515
|
].filter(Boolean);
|
|
4505
4516
|
return parts.join(" ");
|
|
4506
4517
|
};
|
|
@@ -4515,7 +4526,7 @@ function createAffinityProvider(deps) {
|
|
|
4515
4526
|
const platform = session.platform;
|
|
4516
4527
|
const targetUserId = resolved?.targetUserId || session.userId;
|
|
4517
4528
|
const cached = cache.get(scopeId, targetUserId);
|
|
4518
|
-
if (cached !== null && (config.affinityDisplayRange ?? 1) <= 1) {
|
|
4529
|
+
if (cached !== null && (config.affinityDisplayRange ?? 1) <= 1 && !config.variableSettings.showChatCountInAffinityVariable) {
|
|
4519
4530
|
const cachedNickname = await resolveNickname(
|
|
4520
4531
|
scopeId,
|
|
4521
4532
|
platform,
|
|
@@ -4526,7 +4537,8 @@ function createAffinityProvider(deps) {
|
|
|
4526
4537
|
name: targetUserId,
|
|
4527
4538
|
nickname: cachedNickname,
|
|
4528
4539
|
affinity: cached,
|
|
4529
|
-
relationship: resolveRelationByAffinity(cached)
|
|
4540
|
+
relationship: resolveRelationByAffinity(cached),
|
|
4541
|
+
chatCount: 0
|
|
4530
4542
|
});
|
|
4531
4543
|
}
|
|
4532
4544
|
const currentRecord = await store.load(scopeId, targetUserId);
|
|
@@ -4549,7 +4561,8 @@ function createAffinityProvider(deps) {
|
|
|
4549
4561
|
name: currentName,
|
|
4550
4562
|
nickname: currentNickname,
|
|
4551
4563
|
affinity: currentAffinity,
|
|
4552
|
-
relationship: currentRelation
|
|
4564
|
+
relationship: currentRelation,
|
|
4565
|
+
chatCount: currentRecord?.chatCount || 0
|
|
4553
4566
|
});
|
|
4554
4567
|
}
|
|
4555
4568
|
if (typeof fetchEntries !== "function") {
|
|
@@ -4558,7 +4571,8 @@ function createAffinityProvider(deps) {
|
|
|
4558
4571
|
name: currentName,
|
|
4559
4572
|
nickname: currentNickname,
|
|
4560
4573
|
affinity: currentAffinity,
|
|
4561
|
-
relationship: currentRelation
|
|
4574
|
+
relationship: currentRelation,
|
|
4575
|
+
chatCount: currentRecord?.chatCount || 0
|
|
4562
4576
|
});
|
|
4563
4577
|
}
|
|
4564
4578
|
const entries = await fetchEntries(session, Math.max(1, displayRange * 10));
|
|
@@ -4582,7 +4596,8 @@ function createAffinityProvider(deps) {
|
|
|
4582
4596
|
name: currentName,
|
|
4583
4597
|
nickname: currentNickname,
|
|
4584
4598
|
affinity: currentAffinity,
|
|
4585
|
-
relationship: currentRelation
|
|
4599
|
+
relationship: currentRelation,
|
|
4600
|
+
chatCount: currentRecord?.chatCount || 0
|
|
4586
4601
|
})
|
|
4587
4602
|
);
|
|
4588
4603
|
if (!orderedUsers.length) return rows.join("\n");
|
|
@@ -4598,7 +4613,8 @@ function createAffinityProvider(deps) {
|
|
|
4598
4613
|
name: name2,
|
|
4599
4614
|
nickname,
|
|
4600
4615
|
affinity,
|
|
4601
|
-
relationship: relation
|
|
4616
|
+
relationship: relation,
|
|
4617
|
+
chatCount: record?.chatCount || 0
|
|
4602
4618
|
});
|
|
4603
4619
|
})
|
|
4604
4620
|
);
|
|
@@ -5273,6 +5289,7 @@ function normalizeToolSettings(config) {
|
|
|
5273
5289
|
};
|
|
5274
5290
|
const variableSettings = {
|
|
5275
5291
|
affinityVariableName: config.variableSettings?.affinityVariableName || config.affinityVariableName || "affinity",
|
|
5292
|
+
showChatCountInAffinityVariable: config.variableSettings?.showChatCountInAffinityVariable ?? config.showChatCountInAffinityVariable ?? true,
|
|
5276
5293
|
relationshipLevelVariableName: config.variableSettings?.relationshipLevelVariableName || config.relationshipLevelVariableName || "relationshipLevel",
|
|
5277
5294
|
blacklistListVariableName: config.variableSettings?.blacklistListVariableName || config.blacklistListVariableName || "blacklistList"
|
|
5278
5295
|
};
|
|
@@ -5697,9 +5714,15 @@ async function callOneBotAPI(internal, action, params, fallbacks = []) {
|
|
|
5697
5714
|
|
|
5698
5715
|
// src/index.ts
|
|
5699
5716
|
var usage = `
|
|
5717
|
+
## \u4F7F\u7528\u8BF4\u660E
|
|
5718
|
+
|
|
5719
|
+
\u9996\u6B21\u4F7F\u7528\u524D\u8BF7\u5148\u9605\u8BFB [readme.md](https://github.com/Sor85/AAAAACAT-chatluna-plugins/blob/main/plugins/chatluna-affinity/readme.md)\uFF0C\u6309\u6587\u6863\u5B8C\u6210\u4F9D\u8D56\u5B89\u88C5\u3001\`scopeId\` \u914D\u7F6E\u3001\u53D8\u91CF\u6CE8\u5165\u548C XML \u5DE5\u5177\u63A5\u5165\u3002
|
|
5720
|
+
|
|
5721
|
+
\u5982\u679C\u4F60\u4E3B\u8981\u5728 ChatLuna Character \u4E2D\u4F7F\u7528\u672C\u63D2\u4EF6\uFF0C\u8BF7\u4F18\u5148\u67E5\u770B readme.md \u4E2D\u7684\u201C\u5FEB\u901F\u4E0A\u624B\u201D\u548C\u201C\u53D8\u91CF\u201D\u7AE0\u8282\u3002
|
|
5722
|
+
|
|
5700
5723
|
## \u66F4\u65B0\u65E5\u5FD7
|
|
5701
5724
|
|
|
5702
|
-
0.3.0
|
|
5725
|
+
0.3.0
|
|
5703
5726
|
|
|
5704
5727
|
### \u91CD\u6784
|
|
5705
5728
|
- \u5F15\u5165 \`scopeId\` \u4F5C\u4E3A\u65B0\u7684\u6838\u5FC3\u4F5C\u7528\u57DF\u8BED\u4E49\uFF1B\u6570\u636E\u9694\u79BB\u4ECE\u65E7\u7248\u6309 bot / \u65E7\u4E3B\u952E\u5207\u6362\u4E3A\u6309 \`scopeId\` \u9694\u79BB\u3002
|
|
@@ -5717,6 +5740,8 @@ var usage = `
|
|
|
5717
5740
|
- \u65B0\u589E\u4F5C\u7528\u57DF\u5316\u547D\u4EE4\u524D\u7F00\uFF0C\u547D\u4EE4\u7531\u56FA\u5B9A \`affinity.*\` \u6539\u4E3A \`\${scopeId}.*\`\u3002
|
|
5718
5741
|
- \u65B0\u589E\u6C38\u4E45\u9ED1\u540D\u5355\u89E3\u9664\u540E\u7684\u597D\u611F\u5EA6\u91CD\u7F6E\u903B\u8F91\uFF1B\u89E3\u9664\u540E\u4F1A\u540C\u65F6\u91CD\u7F6E\u597D\u611F\u5EA6\u76F8\u5173\u72B6\u6001\u3002
|
|
5719
5742
|
- \u65B0\u589E\u4F5C\u7528\u57DF\u5316\u53D8\u91CF\u8C03\u7528\u8981\u6C42\uFF0C\u53D8\u91CF\u73B0\u5728\u9700\u8981\u663E\u5F0F\u4F20\u5165 \`scopeId\`\u3002
|
|
5743
|
+
- \u65B0\u589E \`affinity\` \u53D8\u91CF\u7684 \`chatcount\` \u8F93\u51FA\uFF0C\u9ED8\u8BA4\u663E\u793A\u7528\u6237\u5BF9\u8BDD\u6B21\u6570\uFF0C\u53EF\u5728\u53D8\u91CF\u8BBE\u7F6E\u4E2D\u5173\u95ED\u3002
|
|
5744
|
+
- \u65B0\u589E \`injectXmlToolAsReplyTool\` \u9009\u9879\uFF0C\u53EF\u5C06 XML \u5DE5\u5177\u6CE8\u5165\u5230 ChatLuna Character \u7684\u5B9E\u9A8C\u6027\u5DE5\u5177\u8C03\u7528\u56DE\u590D\u53C2\u6570\u4E2D\u3002
|
|
5720
5745
|
|
|
5721
5746
|
### \u4FEE\u6539
|
|
5722
5747
|
- \u597D\u611F\u5EA6\u3001\u9ED1\u540D\u5355\u3001\u6635\u79F0\u6570\u636E\u7684\u5199\u5165\u4E0E\u8BFB\u53D6\u4E3B\u952E\u8BED\u4E49\u6539\u4E3A\u4EE5 \`scopeId\` \u4E3A\u6838\u5FC3\uFF1A
|
|
@@ -5726,7 +5751,7 @@ var usage = `
|
|
|
5726
5751
|
- \u591A bot \u5171\u4EAB\u65B9\u6848\u4ECE\u65E7\u7248\u5206\u7EC4\u914D\u7F6E\u6539\u4E3A\u7EDF\u4E00\u7684 \`scopeId\` \u8BED\u4E49\u3002
|
|
5727
5752
|
- \u597D\u611F\u5EA6\u521D\u59CB\u5316\u65F6\u673A\u6539\u4E3A\u201C\u4E0E bot \u9996\u6B21\u6709\u6548\u4EA4\u4E92\u65F6\u5165\u5E93\u201D\uFF0C\u4E0D\u518D\u5728\u6536\u5230\u6D88\u606F\u65F6\u63D0\u524D\u521D\u59CB\u5316\u3002
|
|
5728
5753
|
- \u968F\u673A\u521D\u59CB\u597D\u611F\u5EA6\u6539\u4E3A\u56FA\u5B9A\u521D\u59CB\u597D\u611F\u5EA6\uFF0C\u9ED8\u8BA4\u503C\u4E3A \`30\`\u3002
|
|
5729
|
-
- \`userAlias\` \u7684\u6635\u79F0\u4FE1\u606F\u5DF2\u878D\u5165 \`affinity\` \u53D8\u91CF\u8F93\u51FA\uFF1B\u5F53\u524D\u8F93\u51FA\u5F62\u6001\u4E3A \`id name nickname affinity relationship\`\u3002
|
|
5754
|
+
- \`userAlias\` \u7684\u6635\u79F0\u4FE1\u606F\u5DF2\u878D\u5165 \`affinity\` \u53D8\u91CF\u8F93\u51FA\uFF1B\u5F53\u524D\u8F93\u51FA\u5F62\u6001\u4E3A \`id name nickname affinity relationship chatcount\`\u3002
|
|
5730
5755
|
- \u5BF9\u4E8E\u5C1A\u672A\u4E0E bot \u4EA7\u751F\u6709\u6548\u4E92\u52A8\u7684\u7528\u6237\uFF0C\`affinity\` \u53D8\u91CF\u73B0\u5728\u4F1A\u76F4\u63A5\u663E\u793A\u9ED8\u8BA4\u597D\u611F\u5EA6\uFF0C\u4EE5\u53CA\u8BE5\u9ED8\u8BA4\u503C\u5BF9\u5E94\u7684\u5173\u7CFB\u3002
|
|
5731
5756
|
- \u5173\u7CFB\u533A\u95F4\u53D8\u91CF\u540D\u7531 \`relationshipAffinityLevel\` \u7B80\u5316\u4E3A \`relationshipLevel\`\u3002
|
|
5732
5757
|
- \u6240\u6709\u53D8\u91CF\u73B0\u5728\u90FD\u9700\u8981\u663E\u5F0F\u4F20\u5165 \`scopeId\`\uFF0C\u4F8B\u5982\uFF1A
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-chatluna-affinity",
|
|
3
3
|
"description": "ChatLuna Character 好感度系统,提供 {好感度}、{关系}、{黑名单} 变量与工具,并支持 XML 工具调用,仅支持 onebot 平台。",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -10,36 +10,42 @@
|
|
|
10
10
|
"client"
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup && vite build",
|
|
15
|
+
"watch": "tsup --watch",
|
|
16
|
+
"clean": "rimraf lib dist",
|
|
17
|
+
"typecheck": "yarn workspace shared-chatluna-xmltools build && tsc --noEmit",
|
|
18
|
+
"test": "node --import tsx --test --test-name-pattern='.*' $(find tests -name '*.test.ts' -print)"
|
|
19
|
+
},
|
|
13
20
|
"keywords": [
|
|
14
21
|
"chatbot",
|
|
15
22
|
"koishi",
|
|
16
23
|
"plugin"
|
|
17
24
|
],
|
|
18
|
-
"homepage": "https://github.com/Sor85/
|
|
25
|
+
"homepage": "https://github.com/Sor85/AAAAACAT-chatluna-plugins",
|
|
19
26
|
"repository": {
|
|
20
27
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/Sor85/
|
|
28
|
+
"url": "https://github.com/Sor85/AAAAACAT-chatluna-plugins.git"
|
|
22
29
|
},
|
|
23
|
-
"dependencies": {},
|
|
24
30
|
"peerDependencies": {
|
|
31
|
+
"@koishijs/plugin-console": "^5.30.0",
|
|
25
32
|
"koishi": "^4.18.7",
|
|
26
33
|
"koishi-plugin-chatluna": "*",
|
|
27
34
|
"koishi-plugin-chatluna-character": "*",
|
|
28
|
-
"@koishijs/plugin-console": "^5.30.0",
|
|
29
35
|
"koishi-plugin-chatluna-group-analysis": "*"
|
|
30
36
|
},
|
|
31
37
|
"peerDependenciesMeta": {
|
|
32
|
-
"koishi-plugin-chatluna-character": {
|
|
33
|
-
"optional": true
|
|
34
|
-
},
|
|
35
38
|
"@koishijs/plugin-console": {
|
|
36
39
|
"optional": true
|
|
37
40
|
},
|
|
38
|
-
"koishi-plugin-
|
|
41
|
+
"koishi-plugin-chatluna-character": {
|
|
39
42
|
"optional": true
|
|
40
43
|
},
|
|
41
44
|
"koishi-plugin-chatluna-group-analysis": {
|
|
42
45
|
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"koishi-plugin-puppeteer": {
|
|
48
|
+
"optional": true
|
|
43
49
|
}
|
|
44
50
|
},
|
|
45
51
|
"devDependencies": {
|
|
@@ -48,16 +54,12 @@
|
|
|
48
54
|
"@vitejs/plugin-vue": "^6.0.2",
|
|
49
55
|
"rimraf": "^5.0.5",
|
|
50
56
|
"sass": "^1.77.0",
|
|
57
|
+
"shared-chatluna-xmltools": "0.0.1",
|
|
58
|
+
"shared-nav": "0.0.1",
|
|
51
59
|
"tsup": "^8.0.0",
|
|
60
|
+
"tsx": "^4.20.6",
|
|
52
61
|
"typescript": "^5.7.2",
|
|
53
62
|
"vite": "^6.0.0",
|
|
54
|
-
"
|
|
55
|
-
"shared-nav": "0.0.1"
|
|
56
|
-
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"build": "tsup && vite build",
|
|
59
|
-
"watch": "tsup --watch",
|
|
60
|
-
"clean": "rimraf lib dist",
|
|
61
|
-
"test": "node --test --test-name-pattern='.*' test/*.test.js"
|
|
63
|
+
"vue": "^3.5.21"
|
|
62
64
|
}
|
|
63
65
|
}
|
package/readme.md
CHANGED
|
@@ -34,13 +34,15 @@
|
|
|
34
34
|
### 安装插件
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
|
|
37
|
+
yarn add koishi-plugin-chatluna-affinity
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
安装后,在 Koishi 中启用本插件并完成配置。
|
|
41
41
|
|
|
42
42
|
## 快速上手
|
|
43
43
|
|
|
44
|
+
如果你主要是想在 ChatLuna Character 里使用本插件,建议先看这份伪装成接入指南的教程:[ChatLuna Character 接入指南](./character-prompt-guide.md)。它给出了角色提示词里应该放哪些变量,以及传统 XML 回复和实验性工具调用回复两种接入方式。
|
|
45
|
+
|
|
44
46
|
### 1. 先配置 `scopeId`
|
|
45
47
|
|
|
46
48
|
这是最重要的配置项。
|
|
@@ -80,6 +82,8 @@ npm install koishi-plugin-chatluna-affinity
|
|
|
80
82
|
- 模板里放 `{affinity("你的scopeId")}`
|
|
81
83
|
- 提示词里允许模型输出 `<affinity .../>`、`<relationship .../>`、`<blacklist .../>`、`<userAlias .../>`
|
|
82
84
|
|
|
85
|
+
如果开启 `injectXmlToolAsReplyTool`(界面显示为“将 XML 工具改为注入实验性‘工具调用回复’的参数中”),就不需要把完整 XML 参考提示词塞进角色提示词里;只需要告诉模型当前 `scopeId`,插件会把可用 XML 工具注入到 ChatLuna Character 的工具调用回复参数中。
|
|
86
|
+
|
|
83
87
|
## 变量
|
|
84
88
|
|
|
85
89
|
默认变量名如下:
|
|
@@ -107,12 +111,13 @@ npm install koishi-plugin-chatluna-affinity
|
|
|
107
111
|
输出示例:
|
|
108
112
|
|
|
109
113
|
```text
|
|
110
|
-
id:123456 name:xxx nickname:xxx姐姐 affinity:20 relationship:熟悉
|
|
114
|
+
id:123456 name:xxx nickname:xxx姐姐 affinity:20 relationship:熟悉 chatcount:12
|
|
111
115
|
```
|
|
112
116
|
|
|
113
117
|
说明:
|
|
114
118
|
|
|
115
119
|
- `nickname` 只有在用户设置了自定义昵称时才会出现
|
|
120
|
+
- `chatcount` 为该用户的对话次数,默认显示,可在变量设置中关闭
|
|
116
121
|
- 当未显式传入 `userId` 时,默认取当前上下文用户
|
|
117
122
|
- `scopeId` 必须显式传入,不传就返回空字符串
|
|
118
123
|
|
|
@@ -124,16 +129,14 @@ id:123456 name:xxx nickname:xxx姐姐 affinity:20 relationship:熟悉
|
|
|
124
129
|
|
|
125
130
|
返回当前上下文可见范围内的黑名单信息。
|
|
126
131
|
|
|
127
|
-
|
|
132
|
+
说明:
|
|
128
133
|
|
|
129
134
|
- 黑名单的实际生效范围是当前 `scopeId`
|
|
130
|
-
-
|
|
131
|
-
|
|
132
|
-
别把展示过滤当成存储隔离,这是两回事。
|
|
135
|
+
- 群聊里的列表展示会按当前群成员过滤
|
|
133
136
|
|
|
134
137
|
### 变量调用注意事项
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
变量调用时,`scopeId` 必须写在引号里。
|
|
137
140
|
|
|
138
141
|
正确:
|
|
139
142
|
|
|
@@ -158,6 +161,15 @@ id:123456 name:xxx nickname:xxx姐姐 affinity:20 relationship:熟悉
|
|
|
158
161
|
|
|
159
162
|
这些能力分别受对应配置开关控制。
|
|
160
163
|
|
|
164
|
+
### 实验性工具调用回复注入
|
|
165
|
+
|
|
166
|
+
`injectXmlToolAsReplyTool` 对应控制台选项“将 XML 工具改为注入实验性‘工具调用回复’的参数中”,默认关闭。
|
|
167
|
+
|
|
168
|
+
- 关闭时:插件按传统方式从模型原始输出中解析 XML 标签,角色提示词中需要包含 XML 格式说明。
|
|
169
|
+
- 开启时:插件会把已启用的 XML 工具作为 ChatLuna Character 的工具调用回复参数注入,角色提示词中只需要提供当前 `scopeId`。
|
|
170
|
+
- 这个模式仍然遵守 `enableAffinityXmlToolCall`、`enableBlacklistXmlToolCall`、`enableRelationshipXmlToolCall`、`enableUserAliasXmlToolCall` 等开关。
|
|
171
|
+
- 这是实验性能力。如果模型无法稳定触发工具调用回复,保持关闭并继续使用原始 XML 输出方式。
|
|
172
|
+
|
|
161
173
|
### XML 规则
|
|
162
174
|
|
|
163
175
|
所有 XML 工具都遵守下面这几条:
|
|
@@ -243,7 +255,7 @@ scopeId.指令名
|
|
|
243
255
|
- 黑名单设置:默认列表、临时拉黑处罚、解除永久拉黑后的初始值等
|
|
244
256
|
- 关系设置:区间关系与特殊关系
|
|
245
257
|
- 变量设置:变量名重命名
|
|
246
|
-
- XML 工具设置:是否启用各类 XML
|
|
258
|
+
- XML 工具设置:是否启用各类 XML、是否注入实验性工具调用回复,以及参考提示词
|
|
247
259
|
- 其他设置:图片渲染、调试日志、详情显示印象等
|
|
248
260
|
|
|
249
261
|
如果你只是正常使用,优先关注这几个配置:
|
|
@@ -255,9 +267,12 @@ scopeId.指令名
|
|
|
255
267
|
- `rankDefaultLimit`
|
|
256
268
|
- `unblockPermanentInitialAffinity`
|
|
257
269
|
- `debugLogging`
|
|
270
|
+
- `injectXmlToolAsReplyTool`
|
|
258
271
|
- `characterPromptTemplate`
|
|
259
272
|
|
|
260
|
-
`
|
|
273
|
+
`injectXmlToolAsReplyTool` 默认关闭。只有当你想让插件把 XML 工具注入到 ChatLuna Character 的实验性工具调用回复参数中时,才需要开启它。
|
|
274
|
+
|
|
275
|
+
`characterPromptTemplate` 里出现的 `{scopeId}` 不会自动替换,它只是参考占位符,使用时需要手动替换成真实值。
|
|
261
276
|
|
|
262
277
|
|
|
263
278
|
## 调试建议
|
|
@@ -281,139 +296,3 @@ scopeId.指令名
|
|
|
281
296
|
## 许可证
|
|
282
297
|
|
|
283
298
|
MIT © 2024-present chatluna-affinity contributors
|
|
284
|
-
|
|
285
|
-
## 更新日志
|
|
286
|
-
|
|
287
|
-
> 以下为历史版本记录,当前可用能力请以本文上方「变量与模板占位符 / 指令 / 工具」章节为准。
|
|
288
|
-
|
|
289
|
-
0.3.0-alpha.1
|
|
290
|
-
|
|
291
|
-
### 重构
|
|
292
|
-
- 引入 `scopeId` 作为新的核心作用域语义;数据隔离从旧版按 bot / 旧主键切换为按 `scopeId` 隔离。
|
|
293
|
-
- 单个实例内的多个 bot 现在共享同一份 `scopeId` 数据;共享范围覆盖好感度、黑名单、特殊关系与昵称。
|
|
294
|
-
- 数据库模型升级为 v2:
|
|
295
|
-
- `chatluna_affinity` -> `chatluna_affinity_v2`
|
|
296
|
-
- `chatluna_blacklist` -> `chatluna_blacklist_v2`
|
|
297
|
-
- `chatluna_user_alias` -> `chatluna_user_alias_v2`
|
|
298
|
-
- 新增数据库迁移服务与迁移记录表,启动时会自动将旧表迁移到 v2 结构。
|
|
299
|
-
- 好感度、黑名单与模型响应处理链路重构为更清晰的服务化结构。
|
|
300
|
-
|
|
301
|
-
### 新增
|
|
302
|
-
- 新增 `scopeId` 配置;当前版本按 `scopeId` 区分数据,不同实例之间完全隔离。
|
|
303
|
-
- 新增 `botSelfIds` 配置,用于声明哪些 bot 归属当前 `scopeId`;同一 `scopeId` 下多个 bot 共享数据,用于首次互动初始化好感度。
|
|
304
|
-
- 新增作用域化命令前缀,命令由固定 `affinity.*` 改为 `${scopeId}.*`。
|
|
305
|
-
- 新增永久黑名单解除后的好感度重置逻辑;解除后会同时重置好感度相关状态。
|
|
306
|
-
- 新增作用域化变量调用要求,变量现在需要显式传入 `scopeId`。
|
|
307
|
-
|
|
308
|
-
### 修改
|
|
309
|
-
- 好感度、黑名单、昵称数据的写入与读取主键语义改为以 `scopeId` 为核心:
|
|
310
|
-
- 好感度:`scopeId + userId`
|
|
311
|
-
- 黑名单:`scopeId + userId + mode`
|
|
312
|
-
- 用户昵称:`scopeId + userId`
|
|
313
|
-
- 多 bot 共享方案从旧版分组配置改为统一的 `scopeId` 语义。
|
|
314
|
-
- 好感度初始化时机改为“与 bot 首次有效交互时入库”,不再在收到消息时提前初始化。
|
|
315
|
-
- 随机初始好感度改为固定初始好感度,默认值为 `30`。
|
|
316
|
-
- `userAlias` 的昵称信息已融入 `affinity` 变量输出;当前输出形态为 `id name nickname affinity relationship`。
|
|
317
|
-
- 对于尚未与 bot 产生有效互动的用户,`affinity` 变量现在会直接显示默认好感度,以及该默认值对应的关系。
|
|
318
|
-
- 关系区间变量名由 `relationshipAffinityLevel` 简化为 `relationshipLevel`。
|
|
319
|
-
- 所有变量现在都需要显式传入 `scopeId`,例如:
|
|
320
|
-
- `relationshipLevel(scopeId)`
|
|
321
|
-
- `affinity(scopeId)`
|
|
322
|
-
- `blacklistList(scopeId)`
|
|
323
|
-
- XML 工具调用参数改为显式作用域风格,核心字段统一为 `scopeId + userId`;
|
|
324
|
-
- `scopeId` 会直接作为指令前缀;不要使用与 bot 名称相同的 `scopeId`,建议优先使用英文。
|
|
325
|
-
|
|
326
|
-
### 删除
|
|
327
|
-
- 删除 ChatLuna 原生工具注册能力,当前版本不再提供原生工具。
|
|
328
|
-
- 删除旧版 `affinityGroups` 共享分组配置。
|
|
329
|
-
- 删除固定命令前缀 `affinity.*` 的命名方式。
|
|
330
|
-
- 删除 `relationshipAffinityLevel` 旧命名。
|
|
331
|
-
- 删除以下动态配置项:
|
|
332
|
-
- 单次增加的短期好感最大幅度
|
|
333
|
-
- 单次减少的短期好感最大幅度
|
|
334
|
-
- 允许额外增减突破单次上限
|
|
335
|
-
- `userAlias` 不再作为独立变量暴露;昵称能力保留在 XML 与 `affinity` 变量输出中。
|
|
336
|
-
|
|
337
|
-
### 兼容性提醒
|
|
338
|
-
- 这是一次带有破坏性兼容变更的重构升级;旧命令、旧 XML 参数和旧变量调用方式都需要同步调整。
|
|
339
|
-
- 迁移会把旧数据整体归入当前实例的 `scopeId`,不会自动拆分为多个作用域。
|
|
340
|
-
|
|
341
|
-
0.2.6
|
|
342
|
-
|
|
343
|
-
### 新增
|
|
344
|
-
- 黑名单、关系调整 XML 工具调用。
|
|
345
|
-
- 黑名单临时拉黑能力(XML)。
|
|
346
|
-
- `blacklistList` 变量(当前群黑名单信息)。
|
|
347
|
-
- 用户自定义昵称能力:`userAlias` XML 工具,昵称会融入 `affinity` 变量输出,数据持久化到数据库。
|
|
348
|
-
|
|
349
|
-
### 调整
|
|
350
|
-
- 黑名单能力改为由 Bot 通过 XML 自主决策(含永久/临时与解除)。
|
|
351
|
-
- 黑名单相关数据由配置存储迁移为数据库存储。
|
|
352
|
-
- `contextAffinity` 变量能力并入 `affinity` 变量。
|
|
353
|
-
- 日程、天气能力拆分至 `koishi-plugin-chatluna-schedule`。
|
|
354
|
-
- 更多变量与 XML 工具能力拆分至 `koishi-plugin-chatluna-toolbox`。
|
|
355
|
-
|
|
356
|
-
### 移除
|
|
357
|
-
- 天气、日程、冗余变量与冗余工具(由拆分插件承接)。
|
|
358
|
-
- 设置好感度工具。
|
|
359
|
-
- 自动拉黑逻辑,改为由 Bot 决策触发。
|
|
360
|
-
|
|
361
|
-
0.2.5
|
|
362
|
-
- 将 puppeteer 从可选依赖改为可选服务
|
|
363
|
-
|
|
364
|
-
0.2.4
|
|
365
|
-
- userInfo 变量新增 chatCount 字段,可展示聊天次数
|
|
366
|
-
- 修复状态改变后 XML 工具拦截失效的问题
|
|
367
|
-
|
|
368
|
-
0.2.3
|
|
369
|
-
- OneBot 协议新增 NapCat/LLBot 独立选项,按配置选择协议
|
|
370
|
-
|
|
371
|
-
0.2.3-alpha.4
|
|
372
|
-
- 修复日程生成提示词人设注入变量 {persona} 失效的问题,新增模型选择与人设注入选项
|
|
373
|
-
- 天气服务切换为 open-meteo,不再需要提供 token
|
|
374
|
-
|
|
375
|
-
0.2.3-alpha.3
|
|
376
|
-
- 修复无法选择日程模型的问题
|
|
377
|
-
|
|
378
|
-
0.2.3-alpha.2
|
|
379
|
-
- 修复好感度更新时未更新 chatCount 的问题
|
|
380
|
-
|
|
381
|
-
0.2.3-alpha.1
|
|
382
|
-
- 新增 XML 工具,解析原始输出中的 <poke id=\"\" /> 戳一戳、<emoji id=\"\" /> 表情回应、<delete message_id=\"\" /> 撤回消息
|
|
383
|
-
- 重构好感度,从依赖外部模型改为解析原始输出中的 <affinity delta=\"\" action=\"increase|decrease\" id=\"\" />
|
|
384
|
-
|
|
385
|
-
0.2.2-alpha.13
|
|
386
|
-
- 新增 send_fake_msg 工具,用于伪造消息并发送合并转发
|
|
387
|
-
|
|
388
|
-
0.2.2-alpha.12
|
|
389
|
-
- groupInfo 变量新增 includeOwnersAndAdmins 配置,用于展示群主/管理员名单
|
|
390
|
-
- 关系设置新增新增好感度区间变量 relationshipLevel ,按配置逐行展示所有好感度区间、关系与备注
|
|
391
|
-
|
|
392
|
-
0.2.2-alpha.11
|
|
393
|
-
- 撤回工具修改为按 messageid 撤回,移除 lastN/关键词等模糊匹配路径
|
|
394
|
-
- 新增 set_msg_emoji 工具,按 messageid + emoji_id 对消息添加表情
|
|
395
|
-
- 新增 send_forward_msg 合并转发工具(未完成)
|
|
396
|
-
- 新增 varslist/toolslist 指令,分别列出已启用的变量与工具
|
|
397
|
-
|
|
398
|
-
0.2.2-alpha.10
|
|
399
|
-
- 好感度详情新增“印象”显示开关 inspectShowImpression,可关闭印象获取与展示(affinity.inspect)
|
|
400
|
-
|
|
401
|
-
0.2.2-alpha.9
|
|
402
|
-
- 新增群昵称工具,支持修改群成员昵称(OneBot 平台,需群管理权限)
|
|
403
|
-
- 好感度分析提示词调整:若 Bot 回复已包含好感度变化倾向,则以回复为准,避免冲突
|
|
404
|
-
|
|
405
|
-
0.2.2-alpha.8
|
|
406
|
-
- 好感度设置中新增“使用原始输出”开关,开启后好感度分析直接使用 chatluna-character 的原始输出
|
|
407
|
-
- 天气设置新增 get_weather 工具注册,可通过工具查询指定城市天气
|
|
408
|
-
|
|
409
|
-
0.2.2-alpha.7
|
|
410
|
-
- 在好感度分析提示词中新增 currentRelationship 变量
|
|
411
|
-
|
|
412
|
-
0.2.2-alpha.6
|
|
413
|
-
- 新增 weather、outfit 变量
|
|
414
|
-
|
|
415
|
-
0.2.2-alpha.5
|
|
416
|
-
- fix
|
|
417
|
-
|
|
418
|
-
0.2.2-alpha.4
|
|
419
|
-
- 修改好感度分组的存储键格式,使用 groupName,selfId 作为数据库记录的 selfId 字段
|