@nextclaw/channel-plugin-feishu 0.2.14 → 0.2.15

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 (65) hide show
  1. package/index.ts +2 -2
  2. package/package.json +1 -2
  3. package/src/accounts.ts +2 -2
  4. package/src/bitable.ts +1 -1
  5. package/src/bot.test.ts +1 -1
  6. package/src/bot.ts +2 -2
  7. package/src/card-action.ts +1 -1
  8. package/src/channel.test.ts +1 -1
  9. package/src/channel.ts +3 -3
  10. package/src/chat.ts +1 -1
  11. package/src/config-schema.ts +1 -1
  12. package/src/dedup.ts +1 -1
  13. package/src/directory.test.ts +1 -1
  14. package/src/directory.ts +2 -2
  15. package/src/docx.account-selection.test.ts +1 -1
  16. package/src/docx.ts +1 -1
  17. package/src/drive.ts +1 -1
  18. package/src/dynamic-agent.ts +1 -1
  19. package/src/media.ts +1 -1
  20. package/src/monitor.account.ts +1 -1
  21. package/src/monitor.reaction.test.ts +1 -1
  22. package/src/monitor.startup.test.ts +1 -1
  23. package/src/monitor.startup.ts +1 -1
  24. package/src/monitor.state.ts +1 -1
  25. package/src/monitor.transport.ts +1 -1
  26. package/src/monitor.ts +1 -1
  27. package/src/monitor.webhook.test-helpers.ts +1 -1
  28. package/src/nextclaw-sdk/account-id.ts +31 -0
  29. package/src/nextclaw-sdk/compat.ts +8 -0
  30. package/src/nextclaw-sdk/core-channel.ts +296 -0
  31. package/src/nextclaw-sdk/core-pairing.ts +224 -0
  32. package/src/nextclaw-sdk/core.ts +26 -0
  33. package/src/nextclaw-sdk/dedupe.ts +246 -0
  34. package/src/nextclaw-sdk/feishu.ts +77 -0
  35. package/src/nextclaw-sdk/history.ts +127 -0
  36. package/src/nextclaw-sdk/network-body.ts +245 -0
  37. package/src/nextclaw-sdk/network-fetch.ts +129 -0
  38. package/src/nextclaw-sdk/network-webhook.ts +182 -0
  39. package/src/nextclaw-sdk/network.ts +13 -0
  40. package/src/nextclaw-sdk/runtime-store.ts +26 -0
  41. package/src/nextclaw-sdk/secrets-config.ts +109 -0
  42. package/src/nextclaw-sdk/secrets-core.ts +170 -0
  43. package/src/nextclaw-sdk/secrets-prompt.ts +305 -0
  44. package/src/nextclaw-sdk/secrets.ts +18 -0
  45. package/src/nextclaw-sdk/types.ts +300 -0
  46. package/src/onboarding.status.test.ts +1 -1
  47. package/src/onboarding.ts +2 -2
  48. package/src/outbound.ts +1 -1
  49. package/src/perm.ts +1 -1
  50. package/src/policy.ts +2 -2
  51. package/src/reactions.ts +1 -1
  52. package/src/reply-dispatcher.ts +1 -1
  53. package/src/runtime.ts +2 -2
  54. package/src/secret-input.ts +1 -1
  55. package/src/send-target.test.ts +1 -1
  56. package/src/send-target.ts +1 -1
  57. package/src/send.test.ts +1 -1
  58. package/src/send.ts +1 -1
  59. package/src/streaming-card.ts +1 -1
  60. package/src/tool-account-routing.test.ts +1 -1
  61. package/src/tool-account.ts +1 -1
  62. package/src/tool-factory-test-harness.ts +1 -1
  63. package/src/types.ts +1 -1
  64. package/src/typing.ts +1 -1
  65. package/src/wiki.ts +1 -1
@@ -0,0 +1,300 @@
1
+ export type LogFn = (message: string) => void;
2
+
3
+ export type SecretRefSource = "env" | "file" | "exec";
4
+
5
+ export type SecretRef = {
6
+ source: SecretRefSource;
7
+ provider: string;
8
+ id: string;
9
+ };
10
+
11
+ export type SecretInput = string | SecretRef;
12
+
13
+ export type DmPolicy = "open" | "pairing" | "allowlist";
14
+ export type GroupPolicy = "open" | "allowlist" | "disabled";
15
+
16
+ export type AllowlistMatch<TSource extends string = string> = {
17
+ allowed: boolean;
18
+ matchKey?: string;
19
+ matchSource?: TSource;
20
+ };
21
+
22
+ export type BaseProbeResult<TTarget = string> = {
23
+ ok: boolean;
24
+ target?: TTarget;
25
+ error?: string;
26
+ [key: string]: unknown;
27
+ };
28
+
29
+ export type ReplyPayload = {
30
+ text?: string;
31
+ mediaUrl?: string;
32
+ mediaUrls?: string[];
33
+ [key: string]: unknown;
34
+ };
35
+
36
+ export type HistoryEntry = {
37
+ sender: string;
38
+ body: string;
39
+ timestamp?: number;
40
+ messageId?: string;
41
+ };
42
+
43
+ export type GroupToolPolicyConfig = Record<string, unknown>;
44
+
45
+ export type ChannelGroupContext = {
46
+ cfg: ClawdbotConfig;
47
+ groupId?: string | null;
48
+ [key: string]: unknown;
49
+ };
50
+
51
+ export type ChannelMeta = {
52
+ id: string;
53
+ label: string;
54
+ selectionLabel?: string;
55
+ docsPath?: string;
56
+ docsLabel?: string;
57
+ blurb?: string;
58
+ aliases?: string[];
59
+ order?: number;
60
+ [key: string]: unknown;
61
+ };
62
+
63
+ export type ChannelPlugin<ResolvedAccount = unknown> = {
64
+ id: string;
65
+ meta: ChannelMeta;
66
+ config?: Record<string, unknown>;
67
+ onboarding?: ChannelOnboardingAdapter;
68
+ [key: string]: unknown;
69
+ __resolvedAccountType__?: ResolvedAccount;
70
+ };
71
+
72
+ export type ChannelOutboundAdapter = Record<string, unknown>;
73
+
74
+ export type AnyAgentTool = {
75
+ name?: string;
76
+ description?: string;
77
+ parameters?: Record<string, unknown>;
78
+ execute?: (toolCallId: string, params: unknown) => Promise<unknown> | unknown;
79
+ [key: string]: unknown;
80
+ };
81
+
82
+ export type ResolvedAgentRoute = {
83
+ agentId?: string;
84
+ sessionKey?: string;
85
+ [key: string]: unknown;
86
+ };
87
+
88
+ export type InboundDebouncer<T> = {
89
+ run: (key: string, value: T, task: (value: T) => Promise<void>) => void;
90
+ clear: () => void;
91
+ };
92
+
93
+ export type PluginRuntime = {
94
+ version?: string;
95
+ config: {
96
+ loadConfig?: () => OpenClawConfig;
97
+ writeConfigFile: (next: OpenClawConfig) => Promise<void>;
98
+ };
99
+ logging: {
100
+ shouldLogVerbose: () => boolean;
101
+ };
102
+ media: {
103
+ detectMime: (params: { buffer: Buffer }) => Promise<string | undefined>;
104
+ loadWebMedia: (
105
+ url: string,
106
+ options?: Record<string, unknown>,
107
+ ) => Promise<Record<string, unknown>>;
108
+ };
109
+ channel: {
110
+ media: {
111
+ fetchRemoteMedia: (params: {
112
+ url: string;
113
+ maxBytes?: number;
114
+ }) => Promise<Record<string, unknown>>;
115
+ saveMediaBuffer: (
116
+ buffer: Buffer,
117
+ contentType?: string,
118
+ direction?: string,
119
+ maxBytes?: number,
120
+ ) => Promise<{ path: string; contentType?: string }>;
121
+ };
122
+ text: {
123
+ chunkMarkdownText: (text: string, limit: number) => string[];
124
+ resolveMarkdownTableMode: (params: Record<string, unknown>) => unknown;
125
+ convertMarkdownTables: (text: string, mode?: unknown) => string;
126
+ resolveTextChunkLimit: (
127
+ cfg: OpenClawConfig,
128
+ channel: string,
129
+ accountId?: string,
130
+ options?: Record<string, unknown>,
131
+ ) => number;
132
+ resolveChunkMode: (cfg: OpenClawConfig, channel: string) => string;
133
+ chunkTextWithMode: (text: string, limit: number, mode?: unknown) => string[];
134
+ hasControlCommand: (text: string, cfg: OpenClawConfig) => boolean;
135
+ };
136
+ reply: {
137
+ resolveEnvelopeFormatOptions: (cfg: OpenClawConfig) => Record<string, unknown>;
138
+ formatAgentEnvelope: (params: Record<string, unknown>) => string;
139
+ finalizeInboundContext: (params: Record<string, unknown>) => Record<string, unknown>;
140
+ withReplyDispatcher: (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
141
+ dispatchReplyFromConfig: (params: Record<string, unknown>) => Promise<Record<string, unknown>>;
142
+ createReplyDispatcherWithTyping: (params: Record<string, unknown>) => {
143
+ dispatcher: unknown;
144
+ replyOptions: Record<string, unknown>;
145
+ markDispatchIdle: () => void;
146
+ };
147
+ resolveHumanDelayConfig: (cfg: OpenClawConfig, agentId: string) => unknown;
148
+ dispatchReplyWithBufferedBlockDispatcher?: (
149
+ params: Record<string, unknown>,
150
+ ) => Promise<void>;
151
+ };
152
+ routing: {
153
+ resolveAgentRoute: (params: Record<string, unknown>) => ResolvedAgentRoute | null;
154
+ };
155
+ pairing: {
156
+ readAllowFromStore: (params: { channel: string; accountId?: string }) => unknown;
157
+ upsertPairingRequest: (params: Record<string, unknown>) => Promise<{
158
+ code: string;
159
+ created: boolean;
160
+ }>;
161
+ };
162
+ commands: {
163
+ shouldComputeCommandAuthorized: (text: string) => boolean;
164
+ resolveCommandAuthorizedFromAuthorizers: (
165
+ params: Record<string, unknown>,
166
+ ) => Promise<boolean> | boolean;
167
+ };
168
+ debounce: {
169
+ resolveInboundDebounceMs: (params: Record<string, unknown>) => number;
170
+ createInboundDebouncer: <T>(params: Record<string, unknown>) => InboundDebouncer<T>;
171
+ };
172
+ };
173
+ [key: string]: unknown;
174
+ };
175
+
176
+ export type RuntimeEnv = {
177
+ log?: (message: string) => void;
178
+ error?: (message: string) => void;
179
+ warn?: (message: string) => void;
180
+ debug?: (message: string) => void;
181
+ info?: (message: string) => void;
182
+ [key: string]: unknown;
183
+ };
184
+
185
+ export type OpenClawPluginApi = {
186
+ config: ClawdbotConfig;
187
+ runtime: PluginRuntime;
188
+ logger: {
189
+ info: LogFn;
190
+ warn: LogFn;
191
+ error: LogFn;
192
+ debug?: LogFn;
193
+ };
194
+ registerTool: (
195
+ tool:
196
+ | AnyAgentTool
197
+ | ((ctx: Record<string, unknown>) => AnyAgentTool | AnyAgentTool[] | null | undefined),
198
+ opts?: { name?: string; names?: string[]; optional?: boolean },
199
+ ) => void;
200
+ registerChannel: (registration: unknown) => void;
201
+ [key: string]: unknown;
202
+ };
203
+
204
+ export type WizardSelectOption<T extends string = string> = {
205
+ value: T;
206
+ label: string;
207
+ hint?: string;
208
+ };
209
+
210
+ export type WizardPrompter = {
211
+ note: (message: string, title?: string) => Promise<void>;
212
+ text: (params: {
213
+ message: string;
214
+ placeholder?: string;
215
+ initialValue?: string;
216
+ validate?: (value: string) => string | undefined;
217
+ }) => Promise<string>;
218
+ confirm: (params: { message: string; initialValue?: boolean }) => Promise<boolean>;
219
+ select: <T extends string = string>(params: {
220
+ message: string;
221
+ options: WizardSelectOption<T>[];
222
+ initialValue?: T | string;
223
+ }) => Promise<T>;
224
+ };
225
+
226
+ export type ChannelOnboardingDmPolicy = {
227
+ label: string;
228
+ channel: string;
229
+ policyKey: string;
230
+ allowFromKey: string;
231
+ getCurrent: (cfg: ClawdbotConfig) => DmPolicy;
232
+ setPolicy: (cfg: ClawdbotConfig, policy: DmPolicy) => ClawdbotConfig;
233
+ promptAllowFrom: (params: {
234
+ cfg: ClawdbotConfig;
235
+ prompter: WizardPrompter;
236
+ }) => Promise<ClawdbotConfig>;
237
+ };
238
+
239
+ export type ChannelOnboardingAdapter = {
240
+ channel: string;
241
+ getStatus: (params: { cfg: ClawdbotConfig }) => Promise<{
242
+ channel: string;
243
+ configured: boolean;
244
+ statusLines: string[];
245
+ selectionHint?: string;
246
+ quickstartScore?: number;
247
+ }>;
248
+ configure: (params: {
249
+ cfg: ClawdbotConfig;
250
+ prompter: WizardPrompter;
251
+ }) => Promise<{ cfg: ClawdbotConfig; accountId?: string }>;
252
+ dmPolicy?: ChannelOnboardingDmPolicy;
253
+ disable?: (cfg: ClawdbotConfig) => ClawdbotConfig;
254
+ };
255
+
256
+ export type OpenClawConfig = {
257
+ channels?: Record<string, Record<string, unknown> | undefined>;
258
+ bindings?: Array<{
259
+ agentId?: string;
260
+ match?: {
261
+ channel?: string;
262
+ peer?: {
263
+ kind?: string;
264
+ id?: string;
265
+ };
266
+ };
267
+ }>;
268
+ agents?: {
269
+ list?: Array<{
270
+ id: string;
271
+ workspace?: string;
272
+ agentDir?: string;
273
+ [key: string]: unknown;
274
+ }>;
275
+ [key: string]: unknown;
276
+ };
277
+ broadcast?: Record<string, string[]>;
278
+ secrets?: {
279
+ defaults?: {
280
+ env?: string;
281
+ file?: string;
282
+ exec?: string;
283
+ };
284
+ providers?: Record<
285
+ string,
286
+ {
287
+ source?: SecretRefSource;
288
+ path?: string;
289
+ mode?: "singleValue" | "json";
290
+ command?: string;
291
+ args?: string[];
292
+ [key: string]: unknown;
293
+ }
294
+ >;
295
+ [key: string]: unknown;
296
+ };
297
+ [key: string]: unknown;
298
+ };
299
+
300
+ export type ClawdbotConfig = OpenClawConfig;
@@ -1,4 +1,4 @@
1
- import type { OpenClawConfig } from "openclaw/plugin-sdk/feishu";
1
+ import type { OpenClawConfig } from "./nextclaw-sdk/feishu.js";
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { feishuOnboardingAdapter } from "./onboarding.js";
4
4
 
package/src/onboarding.ts CHANGED
@@ -5,7 +5,7 @@ import type {
5
5
  DmPolicy,
6
6
  SecretInput,
7
7
  WizardPrompter,
8
- } from "openclaw/plugin-sdk/feishu";
8
+ } from "./nextclaw-sdk/feishu.js";
9
9
  import {
10
10
  buildSingleChannelSecretPromptState,
11
11
  DEFAULT_ACCOUNT_ID,
@@ -17,7 +17,7 @@ import {
17
17
  setTopLevelChannelDmPolicyWithAllowFrom,
18
18
  setTopLevelChannelGroupPolicy,
19
19
  splitOnboardingEntries,
20
- } from "openclaw/plugin-sdk/feishu";
20
+ } from "./nextclaw-sdk/feishu.js";
21
21
  import { resolveFeishuCredentials } from "./accounts.js";
22
22
  import { probeFeishu } from "./probe.js";
23
23
  import type { FeishuConfig } from "./types.js";
package/src/outbound.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk/feishu";
3
+ import type { ChannelOutboundAdapter } from "./nextclaw-sdk/feishu.js";
4
4
  import { resolveFeishuAccount } from "./accounts.js";
5
5
  import { sendMediaFeishu } from "./media.js";
6
6
  import { getFeishuRuntime } from "./runtime.js";
package/src/perm.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk/feishu";
2
+ import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
3
  import { listEnabledFeishuAccounts } from "./accounts.js";
4
4
  import { FeishuPermSchema, type FeishuPermParams } from "./perm-schema.js";
5
5
  import { createFeishuToolClient, resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
package/src/policy.ts CHANGED
@@ -2,8 +2,8 @@ import type {
2
2
  AllowlistMatch,
3
3
  ChannelGroupContext,
4
4
  GroupToolPolicyConfig,
5
- } from "openclaw/plugin-sdk/feishu";
6
- import { evaluateSenderGroupAccessForPolicy } from "openclaw/plugin-sdk/feishu";
5
+ } from "./nextclaw-sdk/feishu.js";
6
+ import { evaluateSenderGroupAccessForPolicy } from "./nextclaw-sdk/feishu.js";
7
7
  import { normalizeFeishuTarget } from "./targets.js";
8
8
  import type { FeishuConfig, FeishuGroupConfig } from "./types.js";
9
9
 
package/src/reactions.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
1
+ import type { ClawdbotConfig } from "./nextclaw-sdk/feishu.js";
2
2
  import { resolveFeishuAccount } from "./accounts.js";
3
3
  import { createFeishuClient } from "./client.js";
4
4
 
@@ -5,7 +5,7 @@ import {
5
5
  type ClawdbotConfig,
6
6
  type ReplyPayload,
7
7
  type RuntimeEnv,
8
- } from "openclaw/plugin-sdk/feishu";
8
+ } from "./nextclaw-sdk/feishu.js";
9
9
  import { resolveFeishuAccount } from "./accounts.js";
10
10
  import { createFeishuClient } from "./client.js";
11
11
  import { sendMediaFeishu } from "./media.js";
package/src/runtime.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { createPluginRuntimeStore } from "openclaw/plugin-sdk/compat";
2
- import type { PluginRuntime } from "openclaw/plugin-sdk/feishu";
1
+ import { createPluginRuntimeStore } from "./nextclaw-sdk/compat.js";
2
+ import type { PluginRuntime } from "./nextclaw-sdk/feishu.js";
3
3
 
4
4
  const { setRuntime: setFeishuRuntime, getRuntime: getFeishuRuntime } =
5
5
  createPluginRuntimeStore<PluginRuntime>("Feishu runtime not initialized");
@@ -3,7 +3,7 @@ import {
3
3
  hasConfiguredSecretInput,
4
4
  normalizeResolvedSecretInputString,
5
5
  normalizeSecretInputString,
6
- } from "openclaw/plugin-sdk/feishu";
6
+ } from "./nextclaw-sdk/feishu.js";
7
7
 
8
8
  export {
9
9
  buildSecretInputSchema,
@@ -1,4 +1,4 @@
1
- import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
1
+ import type { ClawdbotConfig } from "./nextclaw-sdk/feishu.js";
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { resolveFeishuSendTarget } from "./send-target.js";
4
4
 
@@ -1,4 +1,4 @@
1
- import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
1
+ import type { ClawdbotConfig } from "./nextclaw-sdk/feishu.js";
2
2
  import { resolveFeishuAccount } from "./accounts.js";
3
3
  import { createFeishuClient } from "./client.js";
4
4
  import { resolveReceiveIdType, normalizeFeishuTarget } from "./targets.js";
package/src/send.test.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
1
+ import type { ClawdbotConfig } from "./nextclaw-sdk/feishu.js";
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { getMessageFeishu } from "./send.js";
4
4
 
package/src/send.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
1
+ import type { ClawdbotConfig } from "./nextclaw-sdk/feishu.js";
2
2
  import { resolveFeishuAccount } from "./accounts.js";
3
3
  import { createFeishuClient } from "./client.js";
4
4
  import type { MentionTarget } from "./mention.js";
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { Client } from "@larksuiteoapi/node-sdk";
6
- import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/feishu";
6
+ import { fetchWithSsrFGuard } from "./nextclaw-sdk/feishu.js";
7
7
  import type { FeishuDomain } from "./types.js";
8
8
 
9
9
  type Credentials = { appId: string; appSecret: string; domain?: FeishuDomain };
@@ -1,4 +1,4 @@
1
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk/feishu";
1
+ import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
2
2
  import { beforeEach, describe, expect, test, vi } from "vitest";
3
3
  import { registerFeishuBitableTools } from "./bitable.js";
4
4
  import { registerFeishuDriveTools } from "./drive.js";
@@ -1,5 +1,5 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk/feishu";
2
+ import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
3
  import { resolveFeishuAccount } from "./accounts.js";
4
4
  import { createFeishuClient } from "./client.js";
5
5
  import { resolveToolsConfig } from "./tools-config.js";
@@ -1,4 +1,4 @@
1
- import type { AnyAgentTool, OpenClawPluginApi } from "openclaw/plugin-sdk/feishu";
1
+ import type { AnyAgentTool, OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
2
2
 
3
3
  type ToolContextLike = {
4
4
  agentAccountId?: string;
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BaseProbeResult } from "openclaw/plugin-sdk/feishu";
1
+ import type { BaseProbeResult } from "./nextclaw-sdk/feishu.js";
2
2
  import type {
3
3
  FeishuConfigSchema,
4
4
  FeishuGroupSchema,
package/src/typing.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClawdbotConfig, RuntimeEnv } from "openclaw/plugin-sdk/feishu";
1
+ import type { ClawdbotConfig, RuntimeEnv } from "./nextclaw-sdk/feishu.js";
2
2
  import { resolveFeishuAccount } from "./accounts.js";
3
3
  import { createFeishuClient } from "./client.js";
4
4
  import { getFeishuRuntime } from "./runtime.js";
package/src/wiki.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type * as Lark from "@larksuiteoapi/node-sdk";
2
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk/feishu";
2
+ import type { OpenClawPluginApi } from "./nextclaw-sdk/feishu.js";
3
3
  import { listEnabledFeishuAccounts } from "./accounts.js";
4
4
  import { createFeishuToolClient, resolveAnyEnabledFeishuToolsConfig } from "./tool-account.js";
5
5
  import {