koishi-plugin-dify-ai 0.1.1 → 0.1.3
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.js +17 -25
- package/package.json +1 -1
- package/lib/commands/app.d.ts +0 -4
- package/lib/commands/rule.d.ts +0 -4
- package/lib/services/app-service.d.ts +0 -17
package/lib/index.js
CHANGED
|
@@ -61,35 +61,35 @@ var conditionSchema = import_koishi.Schema.union([
|
|
|
61
61
|
import_koishi.Schema.object({
|
|
62
62
|
type: import_koishi.Schema.const("keyword-prefix").required(),
|
|
63
63
|
keywords: import_koishi.Schema.string().role("textarea").required().description("关键词,每行一个")
|
|
64
|
-
}).description("关键词开头"),
|
|
64
|
+
}).default({ type: "keyword-prefix", keywords: "" }).description("关键词开头"),
|
|
65
65
|
import_koishi.Schema.object({
|
|
66
66
|
type: import_koishi.Schema.const("keyword-contains").required(),
|
|
67
67
|
keywords: import_koishi.Schema.string().role("textarea").required().description("关键词,每行一个")
|
|
68
|
-
}).description("包含关键词"),
|
|
68
|
+
}).default({ type: "keyword-contains", keywords: "" }).description("包含关键词"),
|
|
69
69
|
import_koishi.Schema.object({
|
|
70
70
|
type: import_koishi.Schema.const("at-bot").required()
|
|
71
|
-
}).description("@ 机器人"),
|
|
71
|
+
}).default({ type: "at-bot" }).description("@ 机器人"),
|
|
72
72
|
import_koishi.Schema.object({
|
|
73
73
|
type: import_koishi.Schema.const("at-user").required(),
|
|
74
74
|
userIds: import_koishi.Schema.string().role("textarea").required().description("用户 ID,每行一个")
|
|
75
|
-
}).description("@ 指定用户"),
|
|
75
|
+
}).default({ type: "at-user", userIds: "" }).description("@ 指定用户"),
|
|
76
76
|
import_koishi.Schema.object({
|
|
77
77
|
type: import_koishi.Schema.const("quote-bot").required()
|
|
78
|
-
}).description("引用机器人"),
|
|
78
|
+
}).default({ type: "quote-bot" }).description("引用机器人"),
|
|
79
79
|
import_koishi.Schema.object({
|
|
80
80
|
type: import_koishi.Schema.const("quote-user").required(),
|
|
81
81
|
userIds: import_koishi.Schema.string().role("textarea").required().description("用户 ID,每行一个")
|
|
82
|
-
}).description("引用指定用户"),
|
|
82
|
+
}).default({ type: "quote-user", userIds: "" }).description("引用指定用户"),
|
|
83
83
|
import_koishi.Schema.object({
|
|
84
84
|
type: import_koishi.Schema.const("schedule").required(),
|
|
85
85
|
cron: import_koishi.Schema.string().default("").description("Cron 表达式"),
|
|
86
86
|
intervalMinutes: import_koishi.Schema.number().default(0).min(0).description("间隔分钟")
|
|
87
|
-
}).description("定时"),
|
|
87
|
+
}).default({ type: "schedule", cron: "", intervalMinutes: 0 }).description("定时"),
|
|
88
88
|
import_koishi.Schema.object({
|
|
89
89
|
type: import_koishi.Schema.const("density").required(),
|
|
90
90
|
densityCount: import_koishi.Schema.natural().default(5).description("条数阈值"),
|
|
91
91
|
densityWindowSeconds: import_koishi.Schema.natural().default(60).description("窗口秒数")
|
|
92
|
-
}).description("消息密度")
|
|
92
|
+
}).default({ type: "density", densityCount: 5, densityWindowSeconds: 60 }).description("消息密度")
|
|
93
93
|
]);
|
|
94
94
|
var sessionKeySchema = import_koishi.Schema.union([
|
|
95
95
|
import_koishi.Schema.const("userId").description("用户 ID"),
|
|
@@ -112,25 +112,17 @@ var metaKeySchema = import_koishi.Schema.union([
|
|
|
112
112
|
import_koishi.Schema.const("triggerTime").description("触发时间")
|
|
113
113
|
]);
|
|
114
114
|
var variableSchema = import_koishi.Schema.union([
|
|
115
|
-
import_koishi.Schema.
|
|
116
|
-
import_koishi.Schema.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
import_koishi.Schema.union([
|
|
122
|
-
import_koishi.Schema.object({
|
|
123
|
-
key: import_koishi.Schema.const("history").required(),
|
|
124
|
-
limit: import_koishi.Schema.natural().default(0).min(0).max(100).description("条数,0 用全局")
|
|
125
|
-
}),
|
|
126
|
-
import_koishi.Schema.object({})
|
|
127
|
-
])
|
|
128
|
-
]).description("会话字段"),
|
|
115
|
+
import_koishi.Schema.object({
|
|
116
|
+
source: import_koishi.Schema.const("session").required(),
|
|
117
|
+
field: import_koishi.Schema.string().required().description("字段名"),
|
|
118
|
+
key: sessionKeySchema.default("content").description("变量"),
|
|
119
|
+
limit: import_koishi.Schema.natural().default(0).min(0).max(100).description("条数,选历史消息时生效")
|
|
120
|
+
}).default({ source: "session", field: "", key: "content", limit: 0 }).description("会话字段"),
|
|
129
121
|
import_koishi.Schema.object({
|
|
130
122
|
source: import_koishi.Schema.const("meta").required(),
|
|
131
123
|
field: import_koishi.Schema.string().required().description("字段名"),
|
|
132
124
|
key: metaKeySchema.default("triggerType").description("变量")
|
|
133
|
-
}).description("触发元信息")
|
|
125
|
+
}).default({ source: "meta", field: "", key: "triggerType" }).description("触发元信息")
|
|
134
126
|
]);
|
|
135
127
|
var Config = import_koishi.Schema.intersect([
|
|
136
128
|
import_koishi.Schema.object({
|
|
@@ -292,8 +284,8 @@ function normalizeConfig(config) {
|
|
|
292
284
|
const rules = [];
|
|
293
285
|
for (const entry of config.rules ?? []) {
|
|
294
286
|
if (!entry.name?.trim() || entry.enabled === false) continue;
|
|
295
|
-
const conditions = (entry.conditions ?? []).map(toCondition).filter((condition) => condition != null);
|
|
296
|
-
const variables = (entry.variables ?? []).map(toVariable).filter((variable) => variable != null);
|
|
287
|
+
const conditions = (entry.conditions ?? []).filter((condition) => condition != null).map(toCondition).filter((condition) => condition != null);
|
|
288
|
+
const variables = (entry.variables ?? []).filter((variable) => variable != null).map(toVariable).filter((variable) => variable != null);
|
|
297
289
|
rules.push({
|
|
298
290
|
name: entry.name.trim(),
|
|
299
291
|
enabled: true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-dify-ai",
|
|
3
3
|
"description": "Invoke Dify apps (chatflow / workflow / completion) in Koishi with triggers and conversation bindings",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"author": "PinkElysia",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/PinkElysiaDev/dify-ai-plugin-for-Koishi#readme",
|
package/lib/commands/app.d.ts
DELETED
package/lib/commands/rule.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Context } from 'koishi';
|
|
2
|
-
import { RequestRunner } from '../requester/runner';
|
|
3
|
-
import { DifyApp } from '../state/tables';
|
|
4
|
-
/** 应用接入的共享业务层:命令(dify.app.*)调用。 */
|
|
5
|
-
/** 新建应用接入(重名拒绝);返回新行 id */
|
|
6
|
-
export declare function createApp(ctx: Context, runner: RequestRunner, input: {
|
|
7
|
-
name: string;
|
|
8
|
-
apiURL: string;
|
|
9
|
-
apiKey: string;
|
|
10
|
-
}): Promise<string>;
|
|
11
|
-
/** 探测应用类型(GET /info + /parameters),成败都回写 status/lastCheckAt */
|
|
12
|
-
export declare function testApp(ctx: Context, runner: RequestRunner, app: DifyApp): Promise<{
|
|
13
|
-
mode: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}>;
|
|
16
|
-
/** 删除应用;被规则引用时拒绝 */
|
|
17
|
-
export declare function deleteApp(ctx: Context, runner: RequestRunner, app: DifyApp): Promise<void>;
|