koishi-plugin-chatluna 1.1.4 → 1.2.0-alpha.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/index.cjs CHANGED
@@ -547,7 +547,7 @@ function apply2(ctx, config, chain) {
547
547
  });
548
548
  });
549
549
  ctx.command("chatluna.chat.rollback [message:text]").option("room", "-r <room:string>").option("i", "-i <i: string>").action(async ({ options, session }, message) => {
550
- const elements = import_koishi2.h.parse(message);
550
+ const elements = message ? import_koishi2.h.parse(message) : void 0;
551
551
  await chain.receiveCommand(session, "rollback", {
552
552
  message: elements,
553
553
  room_resolve: {
@@ -569,7 +569,7 @@ function apply2(ctx, config, chain) {
569
569
  });
570
570
  });
571
571
  ctx.command("chatluna.chat.voice <message:text>").option("room", "-r <room:string>").option("speaker", "-s <speakerId:number>", { authority: 1 }).action(async ({ options, session }, message) => {
572
- const elements = import_koishi2.h.parse(message);
572
+ const elements = message ? import_koishi2.h.parse(message) : void 0;
573
573
  await chain.receiveCommand(session, "", {
574
574
  message: elements,
575
575
  renderOptions: {
@@ -2090,7 +2090,7 @@ function apply13(ctx, config, chain) {
2090
2090
  chain.middleware("allow_reply", async (session, context) => {
2091
2091
  if (ctx.bots[session.uid]) return 1 /* STOP */;
2092
2092
  context.options.reply_status = false;
2093
- const content = import_koishi6.h.select(session.elements, "text").join("");
2093
+ const content = import_koishi6.h.select(session.elements, "text").join("").trimStart();
2094
2094
  if (session.isDirect && config.allowPrivate && (context.command != null || config.privateChatWithoutCommand)) {
2095
2095
  return await checkReplyPermission();
2096
2096
  }
@@ -2110,7 +2110,7 @@ function apply13(ctx, config, chain) {
2110
2110
  if (config.allowQuoteReply && session.quote?.user?.id === botId) {
2111
2111
  return await checkReplyPermission();
2112
2112
  }
2113
- if (config.botNames.some((name2) => content.startsWith(name2)) && config.isNickname || config.isNickNameWithContent && config.botNames.some((name2) => content.includes(name2))) {
2113
+ if (config.isNickname && config.botNames.some((name2) => content.startsWith(name2)) || config.isNickNameWithContent && config.botNames.some((name2) => content.includes(name2))) {
2114
2114
  return await checkReplyPermission();
2115
2115
  }
2116
2116
  if (Math.random() < await session.resolve(config.randomReplyFrequency)) {
@@ -4420,7 +4420,7 @@ function apply45(ctx, config, chain) {
4420
4420
  if (config.allowChatWithRoomName) {
4421
4421
  const needContinue = context.command == null;
4422
4422
  const rawMessageContent = context.message;
4423
- const messageContent = typeof rawMessageContent === "string" ? rawMessageContent : import_koishi11.h.select(rawMessageContent, "text").join("");
4423
+ const messageContent = typeof rawMessageContent === "string" ? rawMessageContent : import_koishi11.h.select(rawMessageContent, "text").join("").trimStart();
4424
4424
  const splitContent = messageContent.split(" ");
4425
4425
  let matchedRoom;
4426
4426
  if (splitContent.length > 1) {
@@ -4430,7 +4430,7 @@ function apply45(ctx, config, chain) {
4430
4430
  splitContent.shift()
4431
4431
  );
4432
4432
  }
4433
- if (matchedRoom == null && !needContinue) {
4433
+ if (matchedRoom == null || !needContinue) {
4434
4434
  return 1 /* STOP */;
4435
4435
  }
4436
4436
  if (matchedRoom != null) {
package/lib/index.mjs CHANGED
@@ -516,7 +516,7 @@ function apply2(ctx, config, chain) {
516
516
  });
517
517
  });
518
518
  ctx.command("chatluna.chat.rollback [message:text]").option("room", "-r <room:string>").option("i", "-i <i: string>").action(async ({ options, session }, message) => {
519
- const elements = h.parse(message);
519
+ const elements = message ? h.parse(message) : void 0;
520
520
  await chain.receiveCommand(session, "rollback", {
521
521
  message: elements,
522
522
  room_resolve: {
@@ -538,7 +538,7 @@ function apply2(ctx, config, chain) {
538
538
  });
539
539
  });
540
540
  ctx.command("chatluna.chat.voice <message:text>").option("room", "-r <room:string>").option("speaker", "-s <speakerId:number>", { authority: 1 }).action(async ({ options, session }, message) => {
541
- const elements = h.parse(message);
541
+ const elements = message ? h.parse(message) : void 0;
542
542
  await chain.receiveCommand(session, "", {
543
543
  message: elements,
544
544
  renderOptions: {
@@ -2081,7 +2081,7 @@ function apply13(ctx, config, chain) {
2081
2081
  chain.middleware("allow_reply", async (session, context) => {
2082
2082
  if (ctx.bots[session.uid]) return 1 /* STOP */;
2083
2083
  context.options.reply_status = false;
2084
- const content = h3.select(session.elements, "text").join("");
2084
+ const content = h3.select(session.elements, "text").join("").trimStart();
2085
2085
  if (session.isDirect && config.allowPrivate && (context.command != null || config.privateChatWithoutCommand)) {
2086
2086
  return await checkReplyPermission();
2087
2087
  }
@@ -2101,7 +2101,7 @@ function apply13(ctx, config, chain) {
2101
2101
  if (config.allowQuoteReply && session.quote?.user?.id === botId) {
2102
2102
  return await checkReplyPermission();
2103
2103
  }
2104
- if (config.botNames.some((name2) => content.startsWith(name2)) && config.isNickname || config.isNickNameWithContent && config.botNames.some((name2) => content.includes(name2))) {
2104
+ if (config.isNickname && config.botNames.some((name2) => content.startsWith(name2)) || config.isNickNameWithContent && config.botNames.some((name2) => content.includes(name2))) {
2105
2105
  return await checkReplyPermission();
2106
2106
  }
2107
2107
  if (Math.random() < await session.resolve(config.randomReplyFrequency)) {
@@ -4426,7 +4426,7 @@ function apply45(ctx, config, chain) {
4426
4426
  if (config.allowChatWithRoomName) {
4427
4427
  const needContinue = context.command == null;
4428
4428
  const rawMessageContent = context.message;
4429
- const messageContent = typeof rawMessageContent === "string" ? rawMessageContent : h5.select(rawMessageContent, "text").join("");
4429
+ const messageContent = typeof rawMessageContent === "string" ? rawMessageContent : h5.select(rawMessageContent, "text").join("").trimStart();
4430
4430
  const splitContent = messageContent.split(" ");
4431
4431
  let matchedRoom;
4432
4432
  if (splitContent.length > 1) {
@@ -4436,7 +4436,7 @@ function apply45(ctx, config, chain) {
4436
4436
  splitContent.shift()
4437
4437
  );
4438
4438
  }
4439
- if (matchedRoom == null && !needContinue) {
4439
+ if (matchedRoom == null || !needContinue) {
4440
4440
  return 1 /* STOP */;
4441
4441
  }
4442
4442
  if (matchedRoom != null) {
@@ -1333,7 +1333,10 @@ function renderTextDescriptionAndArgs(tools) {
1333
1333
  }
1334
1334
  return tools.map(
1335
1335
  (tool) => `${tool.name}: ${tool.description}, args: ${JSON.stringify(
1336
- (0, import_zod_to_json_schema.zodToJsonSchema)(tool.schema).properties
1336
+ (0, import_zod_to_json_schema.zodToJsonSchema)(
1337
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1338
+ tool.schema
1339
+ ).properties
1337
1340
  )}`
1338
1341
  ).join("\n");
1339
1342
  }
@@ -1323,7 +1323,10 @@ function renderTextDescriptionAndArgs(tools) {
1323
1323
  }
1324
1324
  return tools.map(
1325
1325
  (tool) => `${tool.name}: ${tool.description}, args: ${JSON.stringify(
1326
- zodToJsonSchema(tool.schema).properties
1326
+ zodToJsonSchema(
1327
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1328
+ tool.schema
1329
+ ).properties
1327
1330
  )}`
1328
1331
  ).join("\n");
1329
1332
  }
@@ -11,7 +11,7 @@ export declare class ChatLunaSaveableVectorStore<T extends VectorStore = VectorS
11
11
  constructor(_store: T, input: ChatLunaSaveableVectorStoreInput<T>);
12
12
  addVectors(...args: Parameters<typeof this._store.addVectors>): Promise<void | string[]>;
13
13
  addDocuments(...args: Parameters<T['addDocuments']>): Promise<void | string[]>;
14
- similaritySearchVectorWithScore(...args: Parameters<T['similaritySearchVectorWithScore']>): Promise<[Document<Record<string, any>>, number][]>;
14
+ similaritySearchVectorWithScore(...args: Parameters<T['similaritySearchVectorWithScore']>): Promise<[import("@langchain/core/documents").DocumentInterface<Record<string, any>>, number][]>;
15
15
  editDocument(oldDocumentId: string, newDocument: Document): Promise<void>;
16
16
  save(): Promise<void>;
17
17
  delete(input: ChatLunaSaveableVectorDelete): Promise<void>;
@@ -782,6 +782,9 @@ Please consider this quote when generating your response. User's message: ${mess
782
782
  delete this._transformFunctions[type];
783
783
  };
784
784
  }
785
+ has(type) {
786
+ return this._transformFunctions[type] != null;
787
+ }
785
788
  };
786
789
 
787
790
  // src/services/chat.ts
@@ -771,6 +771,9 @@ Please consider this quote when generating your response. User's message: ${mess
771
771
  delete this._transformFunctions[type];
772
772
  };
773
773
  }
774
+ has(type) {
775
+ return this._transformFunctions[type] != null;
776
+ }
774
777
  };
775
778
 
776
779
  // src/services/chat.ts
@@ -8,5 +8,6 @@ export declare class MessageTransformer {
8
8
  transform(session: Session, elements: h[], message?: Message, quote?: boolean, model?: string): Promise<Message>;
9
9
  intercept(type: string, transformFunction: MessageTransformFunction): () => void;
10
10
  replace(type: string, transformFunction: MessageTransformFunction): () => void;
11
+ has(type: string): boolean;
11
12
  }
12
13
  export type MessageTransformFunction = (session: Session, element: h, message: Message, model?: string) => Promise<boolean | void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chatluna",
3
3
  "description": "chatluna for koishi",
4
- "version": "1.1.4",
4
+ "version": "1.2.0-alpha.0",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",
@@ -211,23 +211,23 @@
211
211
  "langchain"
212
212
  ],
213
213
  "dependencies": {
214
- "@langchain/core": "^0.3.18",
215
- "decimal.js": "^10.4.3",
214
+ "@langchain/core": "^0.3.43",
215
+ "decimal.js": "^10.5.0",
216
216
  "he": "^1.2.0",
217
- "https-proxy-agent": "^7.0.5",
218
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.15",
217
+ "https-proxy-agent": "^7.0.6",
218
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19",
219
219
  "js-yaml": "^4.1.0",
220
220
  "koishi-plugin-markdown": "^1.1.1",
221
- "lru-cache": "^11.0.2",
222
- "marked": "^15.0.1",
221
+ "lru-cache": "^11.1.0",
222
+ "marked": "^15.0.7",
223
223
  "md5": "^2.3.0",
224
- "socks": "^2.8.2",
225
- "socks-proxy-agent": "^8.0.4",
226
- "undici": "^6.21.0",
224
+ "socks": "^2.8.4",
225
+ "socks-proxy-agent": "^8.0.5",
226
+ "undici": "^6.21.2",
227
227
  "uuid": "^9.0.1",
228
- "ws": "^8.18.0",
229
- "zod": "^3.24.0-canary.20241107T043915",
230
- "zod-to-json-schema": "^3.23.5"
228
+ "ws": "^8.18.1",
229
+ "zod": "^3.25.0-canary.20250211T214501",
230
+ "zod-to-json-schema": "^3.24.5"
231
231
  },
232
232
  "devDependencies": {
233
233
  "@initencounter/sst": "^0.0.1",
@@ -244,20 +244,20 @@
244
244
  "atsc": "^2.1.0"
245
245
  },
246
246
  "peerDependencies": {
247
- "koishi": "^4.18.4"
247
+ "koishi": "^4.18.7"
248
248
  },
249
249
  "resolutions": {
250
250
  "@langchain/core": "0.3.18",
251
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.15"
251
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19"
252
252
  },
253
253
  "overrides": {
254
254
  "@langchain/core": "0.3.18",
255
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.15"
255
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19"
256
256
  },
257
257
  "pnpm": {
258
258
  "overrides": {
259
259
  "@langchain/core": "0.3.18",
260
- "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.15"
260
+ "js-tiktoken": "npm:@dingyi222666/js-tiktoken@^1.0.19"
261
261
  }
262
262
  },
263
263
  "koishi": {