@soimy/dingtalk 3.6.4 → 3.6.5
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/README.md +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6592 -5621
- package/dist/index.js.map +4 -4
- package/dist/src/card/ask-user-question-context.d.ts +17 -0
- package/dist/src/card/ask-user-question-context.d.ts.map +1 -0
- package/dist/src/card/ask-user-question.d.ts +241 -0
- package/dist/src/card/ask-user-question.d.ts.map +1 -0
- package/dist/src/card/card-action-handler.d.ts +1 -0
- package/dist/src/card/card-action-handler.d.ts.map +1 -1
- package/dist/src/card/card-template.d.ts +5 -0
- package/dist/src/card/card-template.d.ts.map +1 -1
- package/dist/src/gateway/channel-gateway.d.ts.map +1 -1
- package/dist/src/inbound-handler.d.ts.map +1 -1
- package/index.ts +18 -1
- package/openclaw.plugin.json +3 -0
- package/package.json +1 -1
- package/src/card/ask-user-question-context.ts +31 -0
- package/src/card/ask-user-question.ts +1068 -0
- package/src/card/card-action-handler.ts +14 -0
- package/src/card/card-template.ts +10 -0
- package/src/gateway/channel-gateway.ts +5 -5
- package/src/inbound-handler.ts +103 -9
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DingTalkConfig, DingTalkInboundMessage, HandleDingTalkMessageParams, Logger } from "../types";
|
|
2
|
+
export type DingTalkQuestionContext = {
|
|
3
|
+
cfg: HandleDingTalkMessageParams["cfg"];
|
|
4
|
+
accountId: string;
|
|
5
|
+
data: DingTalkInboundMessage;
|
|
6
|
+
sessionWebhook: string;
|
|
7
|
+
log?: Logger;
|
|
8
|
+
dingtalkConfig: DingTalkConfig;
|
|
9
|
+
questionScopeKey?: string;
|
|
10
|
+
onQuestionCardSent?: (event: {
|
|
11
|
+
questionId: string;
|
|
12
|
+
outTrackId: string;
|
|
13
|
+
}) => void | Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export declare function withDingTalkQuestionContext<T>(context: DingTalkQuestionContext, fn: () => Promise<T>): Promise<T>;
|
|
16
|
+
export declare function getDingTalkQuestionContext(): DingTalkQuestionContext | undefined;
|
|
17
|
+
//# sourceMappingURL=ask-user-question-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-question-context.d.ts","sourceRoot":"","sources":["../../../src/card/ask-user-question-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,2BAA2B,EAC3B,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,2BAA2B,CAAC,KAAK,CAAC,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClG,CAAC;AAIF,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,OAAO,EAAE,uBAAuB,EAChC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,wBAAgB,0BAA0B,IAAI,uBAAuB,GAAG,SAAS,CAEhF"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
2
|
+
import type { DingTalkConfig, Logger } from "../types";
|
|
3
|
+
import { type DingTalkQuestionContext } from "./ask-user-question-context";
|
|
4
|
+
type AskUserOption = {
|
|
5
|
+
label?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
};
|
|
9
|
+
type AskUserQuestion = {
|
|
10
|
+
question?: string;
|
|
11
|
+
header?: string;
|
|
12
|
+
options?: AskUserOption[];
|
|
13
|
+
multiSelect?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type FormFieldType = "TEXT" | "TEXT_ARRAY" | "TEXT_AREA" | "NUMBER" | "SELECT" | "MULTI_SELECT" | "DATE" | "TIME" | "DATETIME" | "CHECKBOX" | "SWITCH" | "CHECKBOX_GROUP" | "MULTI_CHECKBOX_GROUP";
|
|
16
|
+
type RawValue = string | number | boolean;
|
|
17
|
+
type SelectValue = {
|
|
18
|
+
index: number;
|
|
19
|
+
value: RawValue;
|
|
20
|
+
};
|
|
21
|
+
type MultiSelectValue = {
|
|
22
|
+
index: number[];
|
|
23
|
+
value: RawValue[];
|
|
24
|
+
};
|
|
25
|
+
type FormField = {
|
|
26
|
+
name: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
type: FormFieldType;
|
|
29
|
+
hidden?: boolean;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
requiredMsg?: string;
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
format?: string;
|
|
35
|
+
defaultValue?: RawValue | RawValue[] | SelectValue | MultiSelectValue;
|
|
36
|
+
defautValue?: RawValue | RawValue[] | SelectValue | MultiSelectValue;
|
|
37
|
+
options?: Array<{
|
|
38
|
+
value: string;
|
|
39
|
+
text: string;
|
|
40
|
+
}>;
|
|
41
|
+
minRows?: number;
|
|
42
|
+
maxRows?: number;
|
|
43
|
+
addText?: string;
|
|
44
|
+
};
|
|
45
|
+
type PendingQuestion = DingTalkQuestionContext & {
|
|
46
|
+
questionId: string;
|
|
47
|
+
outTrackId: string;
|
|
48
|
+
title: string;
|
|
49
|
+
questions: Array<{
|
|
50
|
+
fieldName: string;
|
|
51
|
+
title: string;
|
|
52
|
+
options: Array<{
|
|
53
|
+
value: string;
|
|
54
|
+
text: string;
|
|
55
|
+
}>;
|
|
56
|
+
multiSelect: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
submitted: boolean;
|
|
59
|
+
ownerUserId?: string;
|
|
60
|
+
ttlTimer?: ReturnType<typeof setTimeout>;
|
|
61
|
+
};
|
|
62
|
+
type ParsedCardCallback = {
|
|
63
|
+
outTrackId?: string;
|
|
64
|
+
actionId?: string;
|
|
65
|
+
params: Record<string, unknown>;
|
|
66
|
+
hasBusinessPayload: boolean;
|
|
67
|
+
};
|
|
68
|
+
export declare function buildQuestionForm(questions: AskUserQuestion[]): {
|
|
69
|
+
title: string;
|
|
70
|
+
desc: string;
|
|
71
|
+
fields: FormField[];
|
|
72
|
+
parsed: PendingQuestion["questions"];
|
|
73
|
+
};
|
|
74
|
+
export declare function buildQuestionFormFromFields(params: {
|
|
75
|
+
title?: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
fields: FormField[];
|
|
78
|
+
}): {
|
|
79
|
+
title: string;
|
|
80
|
+
desc: string;
|
|
81
|
+
fields: FormField[];
|
|
82
|
+
parsed: PendingQuestion["questions"];
|
|
83
|
+
};
|
|
84
|
+
export declare function parseAskUserCardCallback(payload: unknown): ParsedCardCallback;
|
|
85
|
+
export declare function handleDingTalkAskUserCardCallback(params: {
|
|
86
|
+
payload: unknown;
|
|
87
|
+
cfg: DingTalkQuestionContext["cfg"];
|
|
88
|
+
accountId: string;
|
|
89
|
+
config: DingTalkConfig;
|
|
90
|
+
clickerUserId?: string;
|
|
91
|
+
log?: Logger;
|
|
92
|
+
}): Promise<{
|
|
93
|
+
handled: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
declare const AskUserQuestionSchema: {
|
|
96
|
+
readonly type: "object";
|
|
97
|
+
readonly additionalProperties: false;
|
|
98
|
+
readonly anyOf: readonly [{
|
|
99
|
+
readonly required: readonly ["questions"];
|
|
100
|
+
}, {
|
|
101
|
+
readonly required: readonly ["fields"];
|
|
102
|
+
}];
|
|
103
|
+
readonly properties: {
|
|
104
|
+
readonly title: {
|
|
105
|
+
readonly type: "string";
|
|
106
|
+
readonly description: "Card title. Used with fields; omit to use the first field label.";
|
|
107
|
+
};
|
|
108
|
+
readonly description: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
readonly description: "Short description shown above the form. Used with fields.";
|
|
111
|
+
};
|
|
112
|
+
readonly questions: {
|
|
113
|
+
readonly type: "array";
|
|
114
|
+
readonly description: string;
|
|
115
|
+
readonly minItems: 1;
|
|
116
|
+
readonly maxItems: 6;
|
|
117
|
+
readonly items: {
|
|
118
|
+
readonly type: "object";
|
|
119
|
+
readonly additionalProperties: false;
|
|
120
|
+
readonly required: readonly ["question", "header", "options"];
|
|
121
|
+
readonly properties: {
|
|
122
|
+
readonly question: {
|
|
123
|
+
readonly type: "string";
|
|
124
|
+
readonly description: "The question to ask the user";
|
|
125
|
+
};
|
|
126
|
+
readonly header: {
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
readonly description: "Short label for the question (max 12 chars)";
|
|
129
|
+
};
|
|
130
|
+
readonly options: {
|
|
131
|
+
readonly type: "array";
|
|
132
|
+
readonly maxItems: 20;
|
|
133
|
+
readonly items: {
|
|
134
|
+
readonly type: "object";
|
|
135
|
+
readonly additionalProperties: false;
|
|
136
|
+
readonly required: readonly ["label"];
|
|
137
|
+
readonly properties: {
|
|
138
|
+
readonly label: {
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
readonly description: "Display text for this option";
|
|
141
|
+
};
|
|
142
|
+
readonly value: {
|
|
143
|
+
readonly type: "string";
|
|
144
|
+
readonly description: "Machine-readable value returned to the assistant; omit to use label";
|
|
145
|
+
};
|
|
146
|
+
readonly description: {
|
|
147
|
+
readonly type: "string";
|
|
148
|
+
readonly description: "Explanation of what this option means";
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
readonly description: string;
|
|
153
|
+
};
|
|
154
|
+
readonly multiSelect: {
|
|
155
|
+
readonly type: "boolean";
|
|
156
|
+
readonly description: "Whether multiple options can be selected (ignored when options is empty)";
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
readonly fields: {
|
|
162
|
+
readonly type: "array";
|
|
163
|
+
readonly description: string;
|
|
164
|
+
readonly minItems: 1;
|
|
165
|
+
readonly maxItems: 20;
|
|
166
|
+
readonly items: {
|
|
167
|
+
readonly type: "object";
|
|
168
|
+
readonly additionalProperties: false;
|
|
169
|
+
readonly required: readonly ["name", "label", "type"];
|
|
170
|
+
readonly properties: {
|
|
171
|
+
readonly name: {
|
|
172
|
+
readonly type: "string";
|
|
173
|
+
readonly description: "Unique form field key";
|
|
174
|
+
};
|
|
175
|
+
readonly label: {
|
|
176
|
+
readonly type: "string";
|
|
177
|
+
readonly description: "Field label shown to the user";
|
|
178
|
+
};
|
|
179
|
+
readonly type: {
|
|
180
|
+
readonly type: "string";
|
|
181
|
+
readonly enum: readonly ["TEXT", "TEXT_ARRAY", "TEXT_AREA", "NUMBER", "SELECT", "MULTI_SELECT", "DATE", "TIME", "DATETIME", "CHECKBOX", "SWITCH", "CHECKBOX_GROUP", "MULTI_CHECKBOX_GROUP"];
|
|
182
|
+
readonly description: "DingTalk form field type";
|
|
183
|
+
};
|
|
184
|
+
readonly hidden: {
|
|
185
|
+
readonly type: "boolean";
|
|
186
|
+
};
|
|
187
|
+
readonly required: {
|
|
188
|
+
readonly type: "boolean";
|
|
189
|
+
};
|
|
190
|
+
readonly requiredMsg: {
|
|
191
|
+
readonly type: "string";
|
|
192
|
+
};
|
|
193
|
+
readonly readOnly: {
|
|
194
|
+
readonly type: "boolean";
|
|
195
|
+
};
|
|
196
|
+
readonly placeholder: {
|
|
197
|
+
readonly type: "string";
|
|
198
|
+
};
|
|
199
|
+
readonly defaultValue: {};
|
|
200
|
+
readonly defautValue: {
|
|
201
|
+
readonly description: "Compatibility alias for DingTalk form protocol documentation typo; prefer defaultValue when possible.";
|
|
202
|
+
};
|
|
203
|
+
readonly options: {
|
|
204
|
+
readonly type: "array";
|
|
205
|
+
readonly description: "Required for SELECT, MULTI_SELECT, CHECKBOX_GROUP, and MULTI_CHECKBOX_GROUP. Each option must be { value, text }.";
|
|
206
|
+
readonly items: {
|
|
207
|
+
readonly type: "object";
|
|
208
|
+
readonly additionalProperties: false;
|
|
209
|
+
readonly required: readonly ["value", "text"];
|
|
210
|
+
readonly properties: {
|
|
211
|
+
readonly value: {
|
|
212
|
+
readonly type: "string";
|
|
213
|
+
};
|
|
214
|
+
readonly text: {
|
|
215
|
+
readonly type: "string";
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
readonly minRows: {
|
|
221
|
+
readonly type: "number";
|
|
222
|
+
};
|
|
223
|
+
readonly maxRows: {
|
|
224
|
+
readonly type: "number";
|
|
225
|
+
};
|
|
226
|
+
readonly addText: {
|
|
227
|
+
readonly type: "string";
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
export declare function getAskUserQuestionSchemaForTest(): typeof AskUserQuestionSchema;
|
|
235
|
+
export declare function registerPendingQuestionForTest(ctx: Omit<PendingQuestion, "ttlTimer" | "submitted"> & {
|
|
236
|
+
submitted?: boolean;
|
|
237
|
+
}): void;
|
|
238
|
+
export declare function clearPendingQuestionsForTest(): void;
|
|
239
|
+
export declare function registerDingTalkAskUserQuestionTool(api: OpenClawPluginApi): void;
|
|
240
|
+
export {};
|
|
241
|
+
//# sourceMappingURL=ask-user-question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-question.d.ts","sourceRoot":"","sources":["../../../src/card/ask-user-question.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,OAAO,KAAK,EAAE,cAAc,EAA0B,MAAM,EAAE,MAAM,UAAU,CAAC;AAE/E,OA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AAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CA0HhF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-action-handler.d.ts","sourceRoot":"","sources":["../../../src/card/card-action-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"card-action-handler.d.ts","sourceRoot":"","sources":["../../../src/card/card-action-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKvD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,GAAG,EAAE,cAAc,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyD5B"}
|
|
@@ -6,6 +6,7 @@ export declare const BUILTIN_DINGTALK_CARD_TEMPLATE_ID: string;
|
|
|
6
6
|
export declare const BUILTIN_DINGTALK_CARD_CONTENT_KEY = "content";
|
|
7
7
|
export declare const BUILTIN_DINGTALK_CARD_BLOCK_LIST_KEY = "blockList";
|
|
8
8
|
export declare const BUILTIN_DINGTALK_CARD_COPY_CONTENT_KEY = "copy_content";
|
|
9
|
+
export declare const BUILTIN_DINGTALK_ASK_USER_CARD_TEMPLATE_ID = "89d0c6fe-3822-44c8-950e-e950f562546d.schema";
|
|
9
10
|
export interface DingTalkCardTemplateContract {
|
|
10
11
|
templateId: string;
|
|
11
12
|
contentKey: string;
|
|
@@ -16,6 +17,10 @@ export interface DingTalkCardTemplateContract {
|
|
|
16
17
|
/** V2: key for the plain-text copy content variable (String type for card copy action). */
|
|
17
18
|
copyContentKey: string;
|
|
18
19
|
}
|
|
20
|
+
export interface DingTalkAskUserCardTemplateContract {
|
|
21
|
+
templateId: string;
|
|
22
|
+
}
|
|
19
23
|
/** Frozen singleton — no allocation on every call. */
|
|
20
24
|
export declare const DINGTALK_CARD_TEMPLATE: Readonly<DingTalkCardTemplateContract>;
|
|
25
|
+
export declare const DINGTALK_ASK_USER_CARD_TEMPLATE: Readonly<DingTalkAskUserCardTemplateContract>;
|
|
21
26
|
//# sourceMappingURL=card-template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-template.d.ts","sourceRoot":"","sources":["../../../src/card/card-template.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,eAAO,MAAM,iCAAiC,QAC0C,CAAC;AACzF,eAAO,MAAM,iCAAiC,YAAY,CAAC;AAC3D,eAAO,MAAM,oCAAoC,cAAc,CAAC;AAChE,eAAO,MAAM,sCAAsC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"card-template.d.ts","sourceRoot":"","sources":["../../../src/card/card-template.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,eAAO,MAAM,iCAAiC,QAC0C,CAAC;AACzF,eAAO,MAAM,iCAAiC,YAAY,CAAC;AAC3D,eAAO,MAAM,oCAAoC,cAAc,CAAC;AAChE,eAAO,MAAM,sCAAsC,iBAAiB,CAAC;AACrE,eAAO,MAAM,0CAA0C,gDACR,CAAC;AAEhD,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,sDAAsD;AACtD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,4BAA4B,CAMxE,CAAC;AAEH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,mCAAmC,CAGtF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-gateway.d.ts","sourceRoot":"","sources":["../../../src/gateway/channel-gateway.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"channel-gateway.d.ts","sourceRoot":"","sources":["../../../src/gateway/channel-gateway.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,qBAAqB,EAKtB,MAAM,UAAU,CAAC;AAuFlB,eAAO,MAAM,iCAAiC,EAAG,aAAsB,CAAC;AAwCxE,wBAAgB,qBAAqB,IAAI,WAAW,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAqerF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbound-handler.d.ts","sourceRoot":"","sources":["../../src/inbound-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inbound-handler.d.ts","sourceRoot":"","sources":["../../src/inbound-handler.ts"],"names":[],"mappings":"AAkFA,OAAO,KAAK,EAAE,cAAc,EAAE,2BAA2B,EAAU,SAAS,EAAE,MAAM,SAAS,CAAC;AAyQ9F,wBAAgB,wCAAwC,IAAI,IAAI,CAG/D;AA4FD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,GAAG,EACT,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA0G3B;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAe9F"}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineChannelPluginEntry, type OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
2
2
|
import { readStringParam } from "openclaw/plugin-sdk/param-readers";
|
|
3
3
|
import { getAccessToken } from "./src/auth";
|
|
4
|
+
import { registerDingTalkAskUserQuestionTool } from "./src/card/ask-user-question";
|
|
4
5
|
import { dingtalkPlugin } from "./src/channel";
|
|
5
6
|
import { getConfig, listDingTalkAccountIds, resolveDingTalkAccount } from "./src/config";
|
|
6
7
|
import {
|
|
@@ -279,7 +280,7 @@ function registerDingTalkConnectorCompatibilityGatewayMethods(api: OpenClawPlugi
|
|
|
279
280
|
export { dingtalkPlugin } from "./src/channel";
|
|
280
281
|
export { setDingTalkRuntime } from "./src/runtime";
|
|
281
282
|
|
|
282
|
-
|
|
283
|
+
const dingtalkEntry = defineChannelPluginEntry({
|
|
283
284
|
id: "dingtalk",
|
|
284
285
|
name: "DingTalk Channel",
|
|
285
286
|
description: "DingTalk (钉钉) messaging channel via Stream mode",
|
|
@@ -288,6 +289,7 @@ export default defineChannelPluginEntry({
|
|
|
288
289
|
registerFull(api) {
|
|
289
290
|
registerDingTalkDocsGatewayMethods(api);
|
|
290
291
|
registerDingTalkConnectorCompatibilityGatewayMethods(api);
|
|
292
|
+
registerDingTalkAskUserQuestionTool(api);
|
|
291
293
|
|
|
292
294
|
api.on(
|
|
293
295
|
"llm_output",
|
|
@@ -308,3 +310,18 @@ export default defineChannelPluginEntry({
|
|
|
308
310
|
);
|
|
309
311
|
},
|
|
310
312
|
});
|
|
313
|
+
|
|
314
|
+
export default {
|
|
315
|
+
...dingtalkEntry,
|
|
316
|
+
register(api: OpenClawPluginApi) {
|
|
317
|
+
const registrationMode = api.registrationMode as string | undefined;
|
|
318
|
+
if (registrationMode === "tool-discovery") {
|
|
319
|
+
registerDingTalkAskUserQuestionTool(api);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (registrationMode === "discovery") {
|
|
323
|
+
registerDingTalkAskUserQuestionTool(api);
|
|
324
|
+
}
|
|
325
|
+
dingtalkEntry.register(api);
|
|
326
|
+
},
|
|
327
|
+
};
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import type {
|
|
3
|
+
DingTalkConfig,
|
|
4
|
+
DingTalkInboundMessage,
|
|
5
|
+
HandleDingTalkMessageParams,
|
|
6
|
+
Logger,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
export type DingTalkQuestionContext = {
|
|
10
|
+
cfg: HandleDingTalkMessageParams["cfg"];
|
|
11
|
+
accountId: string;
|
|
12
|
+
data: DingTalkInboundMessage;
|
|
13
|
+
sessionWebhook: string;
|
|
14
|
+
log?: Logger;
|
|
15
|
+
dingtalkConfig: DingTalkConfig;
|
|
16
|
+
questionScopeKey?: string;
|
|
17
|
+
onQuestionCardSent?: (event: { questionId: string; outTrackId: string }) => void | Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const questionContextStorage = new AsyncLocalStorage<DingTalkQuestionContext>();
|
|
21
|
+
|
|
22
|
+
export function withDingTalkQuestionContext<T>(
|
|
23
|
+
context: DingTalkQuestionContext,
|
|
24
|
+
fn: () => Promise<T>,
|
|
25
|
+
): Promise<T> {
|
|
26
|
+
return questionContextStorage.run(context, fn);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getDingTalkQuestionContext(): DingTalkQuestionContext | undefined {
|
|
30
|
+
return questionContextStorage.getStore();
|
|
31
|
+
}
|