koishi-plugin-chatluna-google-gemini-adapter 1.2.0-alpha.2 → 1.2.0-alpha.4

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
@@ -51,7 +51,8 @@ __export(index_exports, {
51
51
  apply: () => apply,
52
52
  inject: () => inject,
53
53
  logger: () => logger,
54
- name: () => name
54
+ name: () => name,
55
+ reusable: () => reusable
55
56
  });
56
57
  module.exports = __toCommonJS(index_exports);
57
58
  var import_chat = require("koishi-plugin-chatluna/services/chat");
@@ -285,29 +286,27 @@ function formatToolToGeminiAITool(tool) {
285
286
  }
286
287
  __name(formatToolToGeminiAITool, "formatToolToGeminiAITool");
287
288
  function removeAdditionalProperties(schema) {
288
- const updatedSchema = { ...schema };
289
- if (Object.hasOwn(updatedSchema, "additionalProperties")) {
290
- delete updatedSchema["additionalProperties"];
291
- }
292
- if (Object.hasOwn(updatedSchema, "$schema")) {
293
- delete updatedSchema["$schema"];
294
- }
295
- if (updatedSchema["properties"]) {
296
- const keys = Object.keys(updatedSchema["properties"]);
297
- removeProperties(updatedSchema["properties"], keys, 0);
289
+ if (!schema || typeof schema !== "object") return schema;
290
+ const stack = [[schema, null]];
291
+ while (stack.length > 0) {
292
+ const [current] = stack.pop();
293
+ if (typeof current !== "object" || current === null) continue;
294
+ if (Object.hasOwn(current, "additionalProperties")) {
295
+ delete current["additionalProperties"];
296
+ }
297
+ if (Object.hasOwn(current, "$schema")) {
298
+ delete current["$schema"];
299
+ }
300
+ for (const key of Object.keys(current)) {
301
+ const value = current[key];
302
+ if (value && typeof value === "object") {
303
+ stack.push([value, key]);
304
+ }
305
+ }
298
306
  }
299
- return updatedSchema;
307
+ return schema;
300
308
  }
301
309
  __name(removeAdditionalProperties, "removeAdditionalProperties");
302
- function removeProperties(properties, keys, index) {
303
- if (index >= keys.length) {
304
- return;
305
- }
306
- const key = keys[index];
307
- properties[key] = removeAdditionalProperties(properties[key]);
308
- removeProperties(properties, keys, index + 1);
309
- }
310
- __name(removeProperties, "removeProperties");
311
310
  function messageTypeToGeminiRole(type) {
312
311
  switch (type) {
313
312
  case "system":
@@ -734,6 +733,7 @@ var GeminiClient = class extends import_client.PlatformModelAndEmbeddingsClient
734
733
  // src/index.ts
735
734
  var import_logger = require("koishi-plugin-chatluna/utils/logger");
736
735
  var logger;
736
+ var reusable = true;
737
737
  function apply(ctx, config) {
738
738
  const plugin = new import_chat.ChatLunaPlugin(ctx, config, config.platform);
739
739
  logger = (0, import_logger.createLogger)(ctx, "chatluna-gemini-adapter");
@@ -793,5 +793,6 @@ var name = "chatluna-google-gemini-adapter";
793
793
  apply,
794
794
  inject,
795
795
  logger,
796
- name
796
+ name,
797
+ reusable
797
798
  });
package/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ChatLunaPlugin } from 'koishi-plugin-chatluna/services/chat';
2
2
  import { Context, Logger, Schema } from 'koishi';
3
3
  export declare let logger: Logger;
4
+ export declare const reusable = true;
4
5
  export declare function apply(ctx: Context, config: Config): void;
5
6
  export interface Config extends ChatLunaPlugin.Config {
6
7
  apiKeys: [string, string][];
package/lib/index.mjs CHANGED
@@ -269,29 +269,27 @@ function formatToolToGeminiAITool(tool) {
269
269
  }
270
270
  __name(formatToolToGeminiAITool, "formatToolToGeminiAITool");
271
271
  function removeAdditionalProperties(schema) {
272
- const updatedSchema = { ...schema };
273
- if (Object.hasOwn(updatedSchema, "additionalProperties")) {
274
- delete updatedSchema["additionalProperties"];
275
- }
276
- if (Object.hasOwn(updatedSchema, "$schema")) {
277
- delete updatedSchema["$schema"];
278
- }
279
- if (updatedSchema["properties"]) {
280
- const keys = Object.keys(updatedSchema["properties"]);
281
- removeProperties(updatedSchema["properties"], keys, 0);
272
+ if (!schema || typeof schema !== "object") return schema;
273
+ const stack = [[schema, null]];
274
+ while (stack.length > 0) {
275
+ const [current] = stack.pop();
276
+ if (typeof current !== "object" || current === null) continue;
277
+ if (Object.hasOwn(current, "additionalProperties")) {
278
+ delete current["additionalProperties"];
279
+ }
280
+ if (Object.hasOwn(current, "$schema")) {
281
+ delete current["$schema"];
282
+ }
283
+ for (const key of Object.keys(current)) {
284
+ const value = current[key];
285
+ if (value && typeof value === "object") {
286
+ stack.push([value, key]);
287
+ }
288
+ }
282
289
  }
283
- return updatedSchema;
290
+ return schema;
284
291
  }
285
292
  __name(removeAdditionalProperties, "removeAdditionalProperties");
286
- function removeProperties(properties, keys, index) {
287
- if (index >= keys.length) {
288
- return;
289
- }
290
- const key = keys[index];
291
- properties[key] = removeAdditionalProperties(properties[key]);
292
- removeProperties(properties, keys, index + 1);
293
- }
294
- __name(removeProperties, "removeProperties");
295
293
  function messageTypeToGeminiRole(type) {
296
294
  switch (type) {
297
295
  case "system":
@@ -718,6 +716,7 @@ var GeminiClient = class extends PlatformModelAndEmbeddingsClient {
718
716
  // src/index.ts
719
717
  import { createLogger } from "koishi-plugin-chatluna/utils/logger";
720
718
  var logger;
719
+ var reusable = true;
721
720
  function apply(ctx, config) {
722
721
  const plugin = new ChatLunaPlugin(ctx, config, config.platform);
723
722
  logger = createLogger(ctx, "chatluna-gemini-adapter");
@@ -776,5 +775,6 @@ export {
776
775
  apply,
777
776
  inject,
778
777
  logger,
779
- name
778
+ name,
779
+ reusable
780
780
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chatluna-google-gemini-adapter",
3
3
  "description": "google-gemini adapter for chatluna",
4
- "version": "1.2.0-alpha.2",
4
+ "version": "1.2.0-alpha.4",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.mjs",
7
7
  "typings": "lib/index.d.ts",