@jeik/dingtalk-connector 0.8.21

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.
Files changed (154) hide show
  1. package/CHANGELOG.md +684 -0
  2. package/LICENSE +21 -0
  3. package/README.en.md +179 -0
  4. package/README.md +219 -0
  5. package/bin/dingtalk-connector.js +838 -0
  6. package/bin/wizard-config.mjs +94 -0
  7. package/dist/accounts-BAzdqkAV.mjs +268 -0
  8. package/dist/accounts-BQptOmgB.mjs +2 -0
  9. package/dist/chunk-upload-BBQgGtcZ.mjs +193 -0
  10. package/dist/chunk-upload-DaLXXZH3.mjs +2 -0
  11. package/dist/common-C8pYKU_y.mjs +2 -0
  12. package/dist/common-Dt9n6fQN.mjs +101 -0
  13. package/dist/connection-DHHFFNQJ.mjs +423 -0
  14. package/dist/entry-bundled.d.mts +16 -0
  15. package/dist/entry-bundled.mjs +31 -0
  16. package/dist/game-xiyou-CqHt-6Q1.mjs +4271 -0
  17. package/dist/gateway-methods-C4tcgI7P.mjs +771 -0
  18. package/dist/gateway-methods-Ci31A3vg.mjs +2 -0
  19. package/dist/http-client-CpnJHB89.mjs +2 -0
  20. package/dist/http-client-DFWZgO1n.mjs +33 -0
  21. package/dist/index.d.mts +193 -0
  22. package/dist/index.mjs +45 -0
  23. package/dist/logger-BmJkQkm1.mjs +2 -0
  24. package/dist/logger-mZ9OSbmD.mjs +58 -0
  25. package/dist/media-C_SVin7s.mjs +2 -0
  26. package/dist/media-cz72EVS3.mjs +509 -0
  27. package/dist/message-handler-DESzFFDc.mjs +1971 -0
  28. package/dist/messaging-B6l1sRvX.mjs +1044 -0
  29. package/dist/runtime-DUgpo5zC.mjs +1422 -0
  30. package/dist/session-DJ4jYqPv.mjs +114 -0
  31. package/dist/utils-Bjh4r_qS.mjs +4 -0
  32. package/dist/utils-CIfI_3Jh.mjs +63 -0
  33. package/dist/utils-legacy-CALCPP1t.mjs +230 -0
  34. package/dist/utils-legacy-CFYDBM4r.mjs +3 -0
  35. package/docs/DEAP_AGENT_GUIDE.en.md +115 -0
  36. package/docs/DEAP_AGENT_GUIDE.md +115 -0
  37. package/docs/DINGTALK_MANUAL_SETUP.md +50 -0
  38. package/docs/MULTI_AGENT_SETUP.md +306 -0
  39. package/docs/RELEASE_NOTES_V0.7.10.md +40 -0
  40. package/docs/RELEASE_NOTES_V0.7.2.md +143 -0
  41. package/docs/RELEASE_NOTES_V0.7.3.md +149 -0
  42. package/docs/RELEASE_NOTES_V0.7.4.md +206 -0
  43. package/docs/RELEASE_NOTES_V0.7.5.md +267 -0
  44. package/docs/RELEASE_NOTES_V0.7.6.md +219 -0
  45. package/docs/RELEASE_NOTES_V0.7.7.md +122 -0
  46. package/docs/RELEASE_NOTES_V0.7.8.md +101 -0
  47. package/docs/RELEASE_NOTES_V0.7.9.md +65 -0
  48. package/docs/RELEASE_NOTES_V0.8.0.md +53 -0
  49. package/docs/RELEASE_NOTES_V0.8.1.md +47 -0
  50. package/docs/RELEASE_NOTES_V0.8.10.md +49 -0
  51. package/docs/RELEASE_NOTES_V0.8.11.md +51 -0
  52. package/docs/RELEASE_NOTES_V0.8.12.md +63 -0
  53. package/docs/RELEASE_NOTES_V0.8.13-beta.0.md +69 -0
  54. package/docs/RELEASE_NOTES_V0.8.13.md +62 -0
  55. package/docs/RELEASE_NOTES_V0.8.14.md +86 -0
  56. package/docs/RELEASE_NOTES_V0.8.16.md +40 -0
  57. package/docs/RELEASE_NOTES_V0.8.17.md +87 -0
  58. package/docs/RELEASE_NOTES_V0.8.18.md +64 -0
  59. package/docs/RELEASE_NOTES_V0.8.19.md +62 -0
  60. package/docs/RELEASE_NOTES_V0.8.2.md +55 -0
  61. package/docs/RELEASE_NOTES_V0.8.20.md +49 -0
  62. package/docs/RELEASE_NOTES_V0.8.3.md +63 -0
  63. package/docs/RELEASE_NOTES_V0.8.4.md +45 -0
  64. package/docs/RELEASE_NOTES_V0.8.7.md +49 -0
  65. package/docs/RELEASE_NOTES_V0.8.8.md +63 -0
  66. package/docs/RELEASE_NOTES_V0.8.9.md +81 -0
  67. package/docs/RELEASE_NOTES_v0.7.0.md +142 -0
  68. package/docs/RELEASE_NOTES_v0.7.1.md +74 -0
  69. package/docs/TROUBLESHOOTING.md +122 -0
  70. package/index.ts +77 -0
  71. package/openclaw.plugin.json +551 -0
  72. package/package.json +147 -0
  73. package/skills/dingtalk-channel-rules/SKILL.md +91 -0
  74. package/skills/dingtalk-troubleshoot/SKILL.md +93 -0
  75. package/skills/dws-cli/SKILL.md +129 -0
  76. package/skills/dws-cli/references/error-codes.md +95 -0
  77. package/skills/dws-cli/references/field-rules.md +105 -0
  78. package/skills/dws-cli/references/global-reference.md +104 -0
  79. package/skills/dws-cli/references/intent-guide.md +114 -0
  80. package/skills/dws-cli/references/products/aitable.md +452 -0
  81. package/skills/dws-cli/references/products/attendance.md +93 -0
  82. package/skills/dws-cli/references/products/calendar.md +217 -0
  83. package/skills/dws-cli/references/products/chat.md +292 -0
  84. package/skills/dws-cli/references/products/contact.md +108 -0
  85. package/skills/dws-cli/references/products/ding.md +57 -0
  86. package/skills/dws-cli/references/products/report.md +162 -0
  87. package/skills/dws-cli/references/products/simple.md +128 -0
  88. package/skills/dws-cli/references/products/todo.md +138 -0
  89. package/skills/dws-cli/references/products/workbench.md +39 -0
  90. package/skills/dws-cli/references/recovery-guide.md +94 -0
  91. package/src/channel.ts +588 -0
  92. package/src/config/accounts.ts +242 -0
  93. package/src/config/schema.ts +180 -0
  94. package/src/core/connection.ts +741 -0
  95. package/src/core/message-handler.ts +1788 -0
  96. package/src/core/provider.ts +111 -0
  97. package/src/core/state.ts +54 -0
  98. package/src/device-auth-config.ts +14 -0
  99. package/src/device-auth.ts +197 -0
  100. package/src/directory.ts +95 -0
  101. package/src/docs.ts +293 -0
  102. package/src/game-xiyou/achievement-engine.ts +252 -0
  103. package/src/game-xiyou/bounty-system.ts +315 -0
  104. package/src/game-xiyou/commands.ts +223 -0
  105. package/src/game-xiyou/drop-engine.ts +241 -0
  106. package/src/game-xiyou/encounter-system.ts +135 -0
  107. package/src/game-xiyou/escape-engine.ts +164 -0
  108. package/src/game-xiyou/exp-calculator.ts +139 -0
  109. package/src/game-xiyou/index.ts +479 -0
  110. package/src/game-xiyou/level-system.ts +91 -0
  111. package/src/game-xiyou/monster-pool.ts +180 -0
  112. package/src/game-xiyou/pity-counter.ts +114 -0
  113. package/src/game-xiyou/random-event-engine.ts +648 -0
  114. package/src/game-xiyou/renderer.ts +679 -0
  115. package/src/game-xiyou/storage.ts +218 -0
  116. package/src/game-xiyou/treasure-system.ts +105 -0
  117. package/src/game-xiyou/types.ts +582 -0
  118. package/src/game-xiyou/uid-resolver.ts +49 -0
  119. package/src/gateway-methods.ts +740 -0
  120. package/src/onboarding.ts +553 -0
  121. package/src/policy.ts +32 -0
  122. package/src/probe.ts +210 -0
  123. package/src/reply-dispatcher.ts +874 -0
  124. package/src/runtime.ts +32 -0
  125. package/src/sdk/helpers.ts +322 -0
  126. package/src/sdk/types.ts +519 -0
  127. package/src/secret-input.ts +19 -0
  128. package/src/services/media/audio.ts +54 -0
  129. package/src/services/media/chunk-upload.ts +296 -0
  130. package/src/services/media/common.ts +155 -0
  131. package/src/services/media/file.ts +75 -0
  132. package/src/services/media/image.ts +81 -0
  133. package/src/services/media/index.ts +10 -0
  134. package/src/services/media/video.ts +162 -0
  135. package/src/services/media.ts +1143 -0
  136. package/src/services/messaging/card.ts +604 -0
  137. package/src/services/messaging/index.ts +18 -0
  138. package/src/services/messaging/mentions.ts +267 -0
  139. package/src/services/messaging/send.ts +141 -0
  140. package/src/services/messaging.ts +1191 -0
  141. package/src/services/reply-markers.ts +55 -0
  142. package/src/targets.ts +45 -0
  143. package/src/types/index.ts +59 -0
  144. package/src/types/pdf-parse.d.ts +3 -0
  145. package/src/utils/agent.ts +63 -0
  146. package/src/utils/async.ts +51 -0
  147. package/src/utils/constants.ts +27 -0
  148. package/src/utils/http-client.ts +38 -0
  149. package/src/utils/index.ts +8 -0
  150. package/src/utils/logger.ts +78 -0
  151. package/src/utils/session.ts +147 -0
  152. package/src/utils/token.ts +93 -0
  153. package/src/utils/utils-legacy.ts +454 -0
  154. package/tsconfig.json +20 -0
@@ -0,0 +1,2 @@
1
+ import { t as registerGatewayMethods } from "./gateway-methods-C4tcgI7P.mjs";
2
+ export { registerGatewayMethods };
@@ -0,0 +1,2 @@
1
+ import { n as dingtalkOapiHttp, t as dingtalkHttp } from "./http-client-DFWZgO1n.mjs";
2
+ export { dingtalkHttp, dingtalkOapiHttp };
@@ -0,0 +1,33 @@
1
+ import axios from "axios";
2
+ //#region src/utils/http-client.ts
3
+ /**
4
+ * HTTP 客户端配置模块
5
+ *
6
+ * 提供统一的 axios 实例,用于钉钉 API 请求。
7
+ * 所有钉钉 API 调用必须使用此模块导出的实例,禁止直接使用 axios 或 fetch。
8
+ *
9
+ * 使用方式:
10
+ * ```typescript
11
+ * import { dingtalkHttp } from './utils/http-client.ts';
12
+ *
13
+ * const response = await dingtalkHttp.post('/api/endpoint', data);
14
+ * ```
15
+ */
16
+ /** 钉钉新版 API 专用 HTTP 客户端(30 秒超时,用于 api.dingtalk.com) */
17
+ const dingtalkHttp = axios.create({
18
+ timeout: 3e4,
19
+ headers: { "Content-Type": "application/json" }
20
+ });
21
+ /** 钉钉 OAPI 专用 HTTP 客户端(60 秒超时,用于媒体上传等) */
22
+ const dingtalkOapiHttp = axios.create({
23
+ timeout: 6e4,
24
+ headers: { "Content-Type": "application/json" }
25
+ });
26
+ /** 文件上传专用 HTTP 客户端(120 秒超时,无 body 大小限制) */
27
+ const dingtalkUploadHttp = axios.create({
28
+ timeout: 12e4,
29
+ maxContentLength: Infinity,
30
+ maxBodyLength: Infinity
31
+ });
32
+ //#endregion
33
+ export { dingtalkOapiHttp as n, dingtalkUploadHttp as r, dingtalkHttp as t };
@@ -0,0 +1,193 @@
1
+ import { z as z$1 } from "zod";
2
+ import { ChannelPlugin, OpenClawPluginApi, PluginRuntime } from "openclaw/plugin-sdk";
3
+
4
+ //#region src/config/schema.d.ts
5
+ declare const DingtalkConfigSchema: z$1.ZodObject<{
6
+ dmPolicy: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodEnum<{
7
+ open: "open";
8
+ pairing: "pairing";
9
+ allowlist: "allowlist";
10
+ }>>>;
11
+ groupPolicy: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodEnum<{
12
+ open: "open";
13
+ allowlist: "allowlist";
14
+ disabled: "disabled";
15
+ }>>>;
16
+ requireMention: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
17
+ separateSessionByConversation: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
18
+ sharedMemoryAcrossConversations: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
19
+ groupSessionScope: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodOptional<z$1.ZodEnum<{
20
+ group: "group";
21
+ group_sender: "group_sender";
22
+ }>>>>;
23
+ accounts: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodOptional<z$1.ZodObject<{
24
+ dmPolicy: z$1.ZodOptional<z$1.ZodEnum<{
25
+ open: "open";
26
+ pairing: "pairing";
27
+ allowlist: "allowlist";
28
+ }>>;
29
+ allowFrom: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>>;
30
+ groupPolicy: z$1.ZodOptional<z$1.ZodEnum<{
31
+ open: "open";
32
+ allowlist: "allowlist";
33
+ disabled: "disabled";
34
+ }>>;
35
+ groupAllowFrom: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>>;
36
+ requireMention: z$1.ZodOptional<z$1.ZodBoolean>;
37
+ groups: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodOptional<z$1.ZodObject<{
38
+ requireMention: z$1.ZodOptional<z$1.ZodBoolean>;
39
+ tools: z$1.ZodOptional<z$1.ZodObject<{
40
+ allow: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
41
+ deny: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
42
+ }, z$1.core.$strict>>;
43
+ enabled: z$1.ZodOptional<z$1.ZodBoolean>;
44
+ allowFrom: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>>;
45
+ systemPrompt: z$1.ZodOptional<z$1.ZodString>;
46
+ groupSessionScope: z$1.ZodOptional<z$1.ZodEnum<{
47
+ group: "group";
48
+ group_sender: "group_sender";
49
+ }>>;
50
+ }, z$1.core.$strict>>>>;
51
+ historyLimit: z$1.ZodOptional<z$1.ZodNumber>;
52
+ textChunkLimit: z$1.ZodOptional<z$1.ZodNumber>;
53
+ mediaMaxMb: z$1.ZodOptional<z$1.ZodNumber>;
54
+ tools: z$1.ZodOptional<z$1.ZodObject<{
55
+ docs: z$1.ZodOptional<z$1.ZodBoolean>;
56
+ media: z$1.ZodOptional<z$1.ZodBoolean>;
57
+ }, z$1.core.$strict>>;
58
+ typingIndicator: z$1.ZodOptional<z$1.ZodBoolean>;
59
+ resolveSenderNames: z$1.ZodOptional<z$1.ZodBoolean>;
60
+ separateSessionByConversation: z$1.ZodOptional<z$1.ZodBoolean>;
61
+ sharedMemoryAcrossConversations: z$1.ZodOptional<z$1.ZodBoolean>;
62
+ groupSessionScope: z$1.ZodOptional<z$1.ZodEnum<{
63
+ group: "group";
64
+ group_sender: "group_sender";
65
+ }>>;
66
+ asyncMode: z$1.ZodOptional<z$1.ZodBoolean>;
67
+ ackText: z$1.ZodOptional<z$1.ZodString>;
68
+ endpoint: z$1.ZodOptional<z$1.ZodString>;
69
+ debug: z$1.ZodOptional<z$1.ZodBoolean>;
70
+ enableMediaUpload: z$1.ZodOptional<z$1.ZodBoolean>;
71
+ systemPrompt: z$1.ZodOptional<z$1.ZodString>;
72
+ groupReplyMode: z$1.ZodOptional<z$1.ZodEnum<{
73
+ aicard: "aicard";
74
+ text: "text";
75
+ markdown: "markdown";
76
+ }>>;
77
+ cardTemplateId: z$1.ZodOptional<z$1.ZodString>;
78
+ cardContentVar: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
79
+ cardProcessVar: z$1.ZodOptional<z$1.ZodString>;
80
+ cardToolVar: z$1.ZodOptional<z$1.ZodString>;
81
+ enabled: z$1.ZodOptional<z$1.ZodBoolean>;
82
+ name: z$1.ZodOptional<z$1.ZodString>;
83
+ clientId: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>;
84
+ clientSecret: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
85
+ source: z$1.ZodEnum<{
86
+ file: "file";
87
+ env: "env";
88
+ exec: "exec";
89
+ }>;
90
+ provider: z$1.ZodString;
91
+ id: z$1.ZodString;
92
+ }, z$1.core.$strip>]>>;
93
+ chatbotUserId: z$1.ZodOptional<z$1.ZodString>;
94
+ chatbotCorpId: z$1.ZodOptional<z$1.ZodString>;
95
+ }, z$1.core.$strict>>>>;
96
+ allowFrom: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>>;
97
+ groupAllowFrom: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>>;
98
+ groups: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodOptional<z$1.ZodObject<{
99
+ requireMention: z$1.ZodOptional<z$1.ZodBoolean>;
100
+ tools: z$1.ZodOptional<z$1.ZodObject<{
101
+ allow: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
102
+ deny: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
103
+ }, z$1.core.$strict>>;
104
+ enabled: z$1.ZodOptional<z$1.ZodBoolean>;
105
+ allowFrom: z$1.ZodOptional<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>>;
106
+ systemPrompt: z$1.ZodOptional<z$1.ZodString>;
107
+ groupSessionScope: z$1.ZodOptional<z$1.ZodEnum<{
108
+ group: "group";
109
+ group_sender: "group_sender";
110
+ }>>;
111
+ }, z$1.core.$strict>>>>;
112
+ historyLimit: z$1.ZodOptional<z$1.ZodNumber>;
113
+ textChunkLimit: z$1.ZodOptional<z$1.ZodNumber>;
114
+ mediaMaxMb: z$1.ZodOptional<z$1.ZodNumber>;
115
+ tools: z$1.ZodOptional<z$1.ZodObject<{
116
+ docs: z$1.ZodOptional<z$1.ZodBoolean>;
117
+ media: z$1.ZodOptional<z$1.ZodBoolean>;
118
+ }, z$1.core.$strict>>;
119
+ typingIndicator: z$1.ZodOptional<z$1.ZodBoolean>;
120
+ resolveSenderNames: z$1.ZodOptional<z$1.ZodBoolean>;
121
+ asyncMode: z$1.ZodOptional<z$1.ZodBoolean>;
122
+ ackText: z$1.ZodOptional<z$1.ZodString>;
123
+ endpoint: z$1.ZodOptional<z$1.ZodString>;
124
+ debug: z$1.ZodOptional<z$1.ZodBoolean>;
125
+ enableMediaUpload: z$1.ZodOptional<z$1.ZodBoolean>;
126
+ systemPrompt: z$1.ZodOptional<z$1.ZodString>;
127
+ groupReplyMode: z$1.ZodOptional<z$1.ZodEnum<{
128
+ aicard: "aicard";
129
+ text: "text";
130
+ markdown: "markdown";
131
+ }>>;
132
+ cardTemplateId: z$1.ZodOptional<z$1.ZodString>;
133
+ cardContentVar: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
134
+ cardProcessVar: z$1.ZodOptional<z$1.ZodString>;
135
+ cardToolVar: z$1.ZodOptional<z$1.ZodString>;
136
+ enabled: z$1.ZodOptional<z$1.ZodBoolean>;
137
+ defaultAccount: z$1.ZodOptional<z$1.ZodString>;
138
+ clientId: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber]>>;
139
+ clientSecret: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodObject<{
140
+ source: z$1.ZodEnum<{
141
+ file: "file";
142
+ env: "env";
143
+ exec: "exec";
144
+ }>;
145
+ provider: z$1.ZodString;
146
+ id: z$1.ZodString;
147
+ }, z$1.core.$strip>]>>;
148
+ }, z$1.core.$strict>;
149
+ //#endregion
150
+ //#region src/types/index.d.ts
151
+ type DingtalkConfig = z$1.infer<typeof DingtalkConfigSchema>;
152
+ type DingtalkDefaultAccountSelectionSource = "explicit-default" | "mapped-default" | "fallback";
153
+ type DingtalkAccountSelectionSource = "explicit" | DingtalkDefaultAccountSelectionSource;
154
+ type ResolvedDingtalkAccount = {
155
+ accountId: string;
156
+ selectionSource: DingtalkAccountSelectionSource;
157
+ enabled: boolean;
158
+ configured: boolean;
159
+ name?: string;
160
+ clientId?: string;
161
+ clientSecret?: string; /** Merged config (top-level defaults + account-specific overrides) */
162
+ config: DingtalkConfig;
163
+ };
164
+ //#endregion
165
+ //#region src/channel.d.ts
166
+ declare const dingtalkPlugin: ChannelPlugin<ResolvedDingtalkAccount>;
167
+ /**
168
+ * Synchronously initializes `dingtalkPlugin.configSchema` using `createRequire`.
169
+ *
170
+ * Static `import ... from "openclaw/plugin-sdk/core"` causes
171
+ * "Cannot find package 'openclaw'" when the plugin is installed to
172
+ * `~/.openclaw/extensions/` (Issue #527) because the ESM loader resolves
173
+ * bare specifiers at parse time before the gateway's jiti alias map is active.
174
+ *
175
+ * By deferring the resolve to `register()` time and using `createRequire`
176
+ * (which searches the gateway's own `node_modules`), we avoid the crash
177
+ * while keeping the call synchronous as required by the plugin API.
178
+ */
179
+ declare function initDingtalkPluginConfigSchema(): void;
180
+ //#endregion
181
+ //#region src/runtime.d.ts
182
+ declare const setDingtalkRuntime: (next: PluginRuntime) => void, getDingtalkRuntime: () => PluginRuntime;
183
+ //#endregion
184
+ //#region src/gateway-methods.d.ts
185
+ /**
186
+ * 注册所有 Gateway Methods
187
+ */
188
+ declare function registerGatewayMethods(api: OpenClawPluginApi): void;
189
+ //#endregion
190
+ //#region index.d.ts
191
+ declare function register(api: OpenClawPluginApi): void;
192
+ //#endregion
193
+ export { register as default, dingtalkPlugin, initDingtalkPluginConfigSchema, registerGatewayMethods, setDingtalkRuntime };
package/dist/index.mjs ADDED
@@ -0,0 +1,45 @@
1
+ import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-DUgpo5zC.mjs";
2
+ import { t as registerGatewayMethods } from "./gateway-methods-C4tcgI7P.mjs";
3
+ //#region index.ts
4
+ /**
5
+ * 检测同一 plugin id 在多个路径被加载的情况。
6
+ *
7
+ * 典型场景:`openclaw.json` 里配了本地 `plugins.load.paths`(开发源码),同时 `~/.openclaw/extensions/dingtalk-connector`
8
+ * 也装了 npm 全局扩展,两份 dist/index.mjs 都被 gateway 加载 → 两份 stream 订阅互相抢占,
9
+ * 表现就是"消息时而能收到,时而收不到 / 回复丢失"。
10
+ *
11
+ * 这里做一个轻量自检:
12
+ * - 把当前 index.mjs 的绝对路径写入全局 Symbol 表
13
+ * - 同名 plugin id 被第二次注册时打印警告(或在 `DINGTALK_STRICT_DUPLICATE_LOAD=1` 时直接抛错)
14
+ *
15
+ * 作为运行时兜底,建议同时在 `openclaw.json` 只保留一条加载路径。
16
+ */
17
+ const DUPLICATE_LOAD_SYMBOL = Symbol.for("@dingtalk-connector/loaded-paths");
18
+ function recordAndCheckLoadPath(api) {
19
+ try {
20
+ const g = globalThis;
21
+ const store = g[DUPLICATE_LOAD_SYMBOL] ?? /* @__PURE__ */ new Map();
22
+ g[DUPLICATE_LOAD_SYMBOL] = store;
23
+ const pluginId = "dingtalk-connector";
24
+ const here = typeof import.meta !== "undefined" && import.meta?.url ? String(import.meta.url) : "<unknown>";
25
+ const paths = store.get(pluginId) ?? /* @__PURE__ */ new Set();
26
+ paths.add(here);
27
+ store.set(pluginId, paths);
28
+ if (paths.size > 1) {
29
+ const msg = `[dingtalk-connector] 检测到同 plugin id 被多个路径加载:\n - ${Array.from(paths).join("\n - ")}\n这会导致 stream 回调互相抢占、消息丢失。请在 openclaw.json 里只保留一条加载方式:\n • 本地开发:保留 plugins.load.paths,删除 ~/.openclaw/extensions/dingtalk-connector\n • 生产:只保留 extensions 安装目录,删除 plugins.load.paths 里对本地仓库的引用`;
30
+ if (process.env.DINGTALK_STRICT_DUPLICATE_LOAD === "1") throw new Error(msg);
31
+ api.logger?.warn?.(msg);
32
+ }
33
+ } catch (err) {
34
+ if (process.env.DINGTALK_STRICT_DUPLICATE_LOAD === "1") throw err;
35
+ }
36
+ }
37
+ function register(api) {
38
+ recordAndCheckLoadPath(api);
39
+ setDingtalkRuntime(api.runtime);
40
+ initDingtalkPluginConfigSchema();
41
+ api.registerChannel({ plugin: dingtalkPlugin });
42
+ registerGatewayMethods(api);
43
+ }
44
+ //#endregion
45
+ export { register as default, dingtalkPlugin, initDingtalkPluginConfigSchema, registerGatewayMethods, setDingtalkRuntime };
@@ -0,0 +1,2 @@
1
+ import { n as createLoggerFromConfig } from "./logger-mZ9OSbmD.mjs";
2
+ export { createLoggerFromConfig };
@@ -0,0 +1,58 @@
1
+ //#region src/utils/logger.ts
2
+ /**
3
+ * 日志工具模块
4
+ * 根据 debug 配置控制日志输出
5
+ */
6
+ /**
7
+ * 创建日志记录器
8
+ * @param debug - 是否启用 debug 模式
9
+ * @param prefix - 日志前缀
10
+ * @returns 日志记录器对象
11
+ */
12
+ function createLogger(debug = false, prefix = "") {
13
+ return {
14
+ /**
15
+ * 打印 info 级别日志
16
+ * 仅在 debug 模式下输出
17
+ */
18
+ info(...args) {
19
+ if (debug) if (prefix) console.log(`[${prefix}]`, ...args);
20
+ else console.log(...args);
21
+ },
22
+ /**
23
+ * 打印 warn 级别日志
24
+ * 始终输出
25
+ */
26
+ warn(...args) {
27
+ if (prefix) console.warn(`[${prefix}]`, ...args);
28
+ else console.warn(...args);
29
+ },
30
+ /**
31
+ * 打印 error 级别日志
32
+ * 始终输出
33
+ */
34
+ error(...args) {
35
+ if (prefix) console.error(`[${prefix}]`, ...args);
36
+ else console.error(...args);
37
+ },
38
+ /**
39
+ * 打印 debug 级别日志
40
+ * 仅在 debug 模式下输出
41
+ */
42
+ debug(...args) {
43
+ if (debug) if (prefix) console.log(`[DEBUG][${prefix}]`, ...args);
44
+ else console.log("[DEBUG]", ...args);
45
+ }
46
+ };
47
+ }
48
+ /**
49
+ * 从配置中创建日志记录器
50
+ * @param config - 包含 debug 配置的对象(可选)
51
+ * @param prefix - 日志前缀
52
+ * @returns 日志记录器对象
53
+ */
54
+ function createLoggerFromConfig(config, prefix = "") {
55
+ return createLogger(!!config?.debug, prefix);
56
+ }
57
+ //#endregion
58
+ export { createLoggerFromConfig as n, createLogger as t };
@@ -0,0 +1,2 @@
1
+ import { a as processVideoMarkers, i as processRawMediaPaths, l as toLocalPath, s as sendFileProactive } from "./media-cz72EVS3.mjs";
2
+ export { processRawMediaPaths, processVideoMarkers, sendFileProactive, toLocalPath };