@fastagent-sh/fastagent 0.13.0 → 0.15.0

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 (238) hide show
  1. package/README.md +5 -5
  2. package/dist/agent.d.ts +20 -0
  3. package/dist/agent.js +9 -0
  4. package/dist/channels/context-buffer.d.ts +30 -0
  5. package/dist/channels/context-buffer.js +98 -0
  6. package/dist/channels/control.d.ts +28 -0
  7. package/dist/channels/control.js +214 -0
  8. package/dist/channels/feishu/card.js +1 -1
  9. package/dist/channels/feishu/context-buffer.d.ts +43 -0
  10. package/dist/channels/feishu/context-buffer.js +72 -0
  11. package/dist/channels/feishu/crypto.d.ts +4 -2
  12. package/dist/channels/feishu/crypto.js +4 -2
  13. package/dist/channels/feishu/feishu-api.d.ts +15 -7
  14. package/dist/channels/feishu/feishu-api.js +22 -4
  15. package/dist/channels/feishu/feishu.d.ts +38 -16
  16. package/dist/channels/feishu/feishu.js +286 -151
  17. package/dist/channels/feishu/invoke-turn.d.ts +24 -31
  18. package/dist/channels/feishu/invoke-turn.js +61 -62
  19. package/dist/channels/feishu/model.d.ts +98 -0
  20. package/dist/channels/feishu/model.js +9 -0
  21. package/dist/channels/feishu/normalize.d.ts +23 -0
  22. package/dist/channels/feishu/normalize.js +132 -0
  23. package/dist/channels/feishu/owned-threads.d.ts +7 -0
  24. package/dist/channels/feishu/owned-threads.js +47 -0
  25. package/dist/channels/feishu/parse.d.ts +21 -103
  26. package/dist/channels/feishu/parse.js +35 -145
  27. package/dist/channels/feishu/preview.d.ts +4 -7
  28. package/dist/channels/feishu/preview.js +26 -142
  29. package/dist/channels/feishu/register-app.d.ts +2 -1
  30. package/dist/channels/feishu/register-webhook.d.ts +2 -1
  31. package/dist/channels/feishu/scaffold/channel.ts +10 -3
  32. package/dist/channels/feishu/setup-mode.d.ts +8 -0
  33. package/dist/channels/feishu/setup-mode.js +2 -0
  34. package/dist/channels/feishu/ws-ingress.d.ts +28 -0
  35. package/dist/channels/feishu/ws-ingress.js +136 -0
  36. package/dist/channels/github/github.js +8 -6
  37. package/dist/channels/http.d.ts +14 -0
  38. package/dist/channels/http.js +35 -2
  39. package/dist/channels/invoke-turn-kit.d.ts +65 -0
  40. package/dist/channels/invoke-turn-kit.js +87 -0
  41. package/dist/channels/lark/lark.d.ts +4 -2
  42. package/dist/channels/lark/lark.js +4 -1
  43. package/dist/channels/lark/onboard.d.ts +8 -4
  44. package/dist/channels/lark/onboard.js +8 -0
  45. package/dist/channels/lark/scaffold/channel.ts +10 -3
  46. package/dist/channels/preview-kit.d.ts +109 -0
  47. package/dist/channels/preview-kit.js +183 -0
  48. package/dist/channels/seen.d.ts +5 -0
  49. package/dist/channels/seen.js +35 -0
  50. package/dist/channels/slack/bot-auth.d.ts +15 -0
  51. package/dist/channels/slack/bot-auth.js +146 -0
  52. package/dist/channels/slack/config-api.d.ts +60 -0
  53. package/dist/channels/slack/config-api.js +149 -0
  54. package/dist/channels/slack/context-buffer.d.ts +24 -0
  55. package/dist/channels/slack/context-buffer.js +37 -0
  56. package/dist/channels/slack/invoke-turn.d.ts +19 -0
  57. package/dist/channels/slack/invoke-turn.js +63 -0
  58. package/dist/channels/slack/manifest.d.ts +49 -0
  59. package/dist/channels/slack/manifest.js +69 -0
  60. package/dist/channels/slack/model.d.ts +67 -0
  61. package/dist/channels/slack/model.js +2 -0
  62. package/dist/channels/slack/onboard.d.ts +41 -0
  63. package/dist/channels/slack/onboard.js +120 -0
  64. package/dist/channels/slack/onboarding-state.d.ts +31 -0
  65. package/dist/channels/slack/onboarding-state.js +69 -0
  66. package/dist/channels/slack/owned-threads.d.ts +6 -0
  67. package/dist/channels/slack/owned-threads.js +43 -0
  68. package/dist/channels/slack/parse.d.ts +23 -0
  69. package/dist/channels/slack/parse.js +81 -0
  70. package/dist/channels/slack/preview.d.ts +24 -0
  71. package/dist/channels/slack/preview.js +359 -0
  72. package/dist/channels/slack/reaction.d.ts +24 -0
  73. package/dist/channels/slack/reaction.js +62 -0
  74. package/dist/channels/slack/register-webhook.d.ts +10 -0
  75. package/dist/channels/slack/register-webhook.js +49 -0
  76. package/dist/channels/slack/scaffold/channel.ts +33 -0
  77. package/dist/channels/slack/scaffold/slack-send.ts +171 -0
  78. package/dist/channels/slack/setup-server.d.ts +17 -0
  79. package/dist/channels/slack/setup-server.js +103 -0
  80. package/dist/channels/slack/slack-api.d.ts +77 -0
  81. package/dist/channels/slack/slack-api.js +415 -0
  82. package/dist/channels/slack/slack.d.ts +58 -0
  83. package/dist/channels/slack/slack.js +451 -0
  84. package/dist/channels/slack/welcomed.d.ts +5 -0
  85. package/dist/channels/slack/welcomed.js +32 -0
  86. package/dist/channels/state.js +3 -3
  87. package/dist/channels/stop-command.d.ts +6 -0
  88. package/dist/channels/stop-command.js +36 -0
  89. package/dist/channels/tasks.d.ts +13 -0
  90. package/dist/channels/tasks.js +10 -0
  91. package/dist/channels/telegram/context-buffer.d.ts +8 -17
  92. package/dist/channels/telegram/context-buffer.js +6 -85
  93. package/dist/channels/telegram/invoke-turn.d.ts +5 -22
  94. package/dist/channels/telegram/invoke-turn.js +11 -58
  95. package/dist/channels/telegram/preview.d.ts +4 -7
  96. package/dist/channels/telegram/preview.js +24 -142
  97. package/dist/channels/telegram/telegram.js +23 -9
  98. package/dist/channels/{feishu/text.d.ts → text.d.ts} +1 -1
  99. package/dist/channels/{feishu/text.js → text.js} +1 -1
  100. package/dist/channels/turn-queue.js +1 -1
  101. package/dist/channels/turn-store.d.ts +1 -1
  102. package/dist/channels/turn-store.js +2 -3
  103. package/dist/cli/add-feishu.d.ts +27 -0
  104. package/dist/{cli-add-feishu.js → cli/add-feishu.js} +167 -44
  105. package/dist/cli/add-slack.d.ts +10 -0
  106. package/dist/cli/add-slack.js +204 -0
  107. package/dist/{cli-auth.d.ts → cli/auth-view.d.ts} +1 -1
  108. package/dist/{cli-auth.js → cli/auth-view.js} +1 -1
  109. package/dist/cli/commands/add.d.ts +13 -0
  110. package/dist/cli/commands/add.js +274 -0
  111. package/dist/cli/commands/attach.d.ts +82 -0
  112. package/dist/cli/commands/attach.js +559 -0
  113. package/dist/cli/commands/chat.d.ts +4 -0
  114. package/dist/cli/commands/chat.js +21 -0
  115. package/dist/cli/commands/deploy.d.ts +15 -0
  116. package/dist/cli/commands/deploy.js +394 -0
  117. package/dist/cli/commands/dev.d.ts +11 -0
  118. package/dist/cli/commands/dev.js +82 -0
  119. package/dist/cli/commands/fire.d.ts +7 -0
  120. package/dist/cli/commands/fire.js +45 -0
  121. package/dist/cli/commands/info.d.ts +7 -0
  122. package/dist/cli/commands/info.js +108 -0
  123. package/dist/cli/commands/init.d.ts +8 -0
  124. package/dist/cli/commands/init.js +81 -0
  125. package/dist/cli/commands/invoke.d.ts +7 -0
  126. package/dist/cli/commands/invoke.js +28 -0
  127. package/dist/cli/commands/login.d.ts +6 -0
  128. package/dist/cli/commands/login.js +52 -0
  129. package/dist/cli/commands/models.d.ts +1 -0
  130. package/dist/cli/commands/models.js +15 -0
  131. package/dist/cli/commands/schedule.d.ts +12 -0
  132. package/dist/cli/commands/schedule.js +89 -0
  133. package/dist/cli/commands/start.d.ts +10 -0
  134. package/dist/cli/commands/start.js +97 -0
  135. package/dist/cli/commands/tool.d.ts +1 -0
  136. package/dist/cli/commands/tool.js +38 -0
  137. package/dist/cli/fail.d.ts +17 -0
  138. package/dist/cli/fail.js +32 -0
  139. package/dist/{invoke-stream.d.ts → cli/invoke-stream.d.ts} +1 -1
  140. package/dist/{invoke-stream.js → cli/invoke-stream.js} +4 -0
  141. package/dist/cli/kernel.d.ts +90 -0
  142. package/dist/cli/kernel.js +190 -0
  143. package/dist/cli/models-view.d.ts +21 -0
  144. package/dist/cli/models-view.js +66 -0
  145. package/dist/cli/program.d.ts +11 -0
  146. package/dist/cli/program.js +479 -0
  147. package/dist/cli/serve.d.ts +48 -0
  148. package/dist/cli/serve.js +248 -0
  149. package/dist/cli/shared.d.ts +44 -0
  150. package/dist/cli/shared.js +246 -0
  151. package/dist/cli.js +8 -1329
  152. package/dist/collect.d.ts +14 -3
  153. package/dist/collect.js +24 -0
  154. package/dist/core.d.ts +3 -1
  155. package/dist/core.js +2 -0
  156. package/dist/deploy/docker/plan.d.ts +45 -0
  157. package/dist/deploy/docker/plan.js +141 -0
  158. package/dist/deploy/docker/run.d.ts +40 -0
  159. package/dist/deploy/docker/run.js +126 -0
  160. package/dist/deploy/fly/plan.d.ts +3 -1
  161. package/dist/deploy/fly/plan.js +12 -7
  162. package/dist/deploy/fly/run.d.ts +5 -4
  163. package/dist/deploy/fly/run.js +16 -5
  164. package/dist/deploy/preflight.d.ts +10 -4
  165. package/dist/deploy/preflight.js +57 -12
  166. package/dist/deploy/railway/plan.d.ts +3 -1
  167. package/dist/deploy/railway/plan.js +12 -4
  168. package/dist/deploy/railway/run.d.ts +5 -4
  169. package/dist/deploy/railway/run.js +15 -5
  170. package/dist/deploy/runner.d.ts +6 -2
  171. package/dist/deploy/runner.js +1 -0
  172. package/dist/deploy/secrets.d.ts +2 -1
  173. package/dist/deploy/secrets.js +23 -3
  174. package/dist/dev-supervisor.d.ts +0 -2
  175. package/dist/dev-supervisor.js +7 -3
  176. package/dist/engines/pi/auth.js +160 -46
  177. package/dist/engines/pi/channel.d.ts +22 -16
  178. package/dist/engines/pi/channel.js +90 -60
  179. package/dist/engines/pi/chat.d.ts +4 -16
  180. package/dist/engines/pi/chat.js +8 -188
  181. package/dist/engines/pi/config.d.ts +23 -9
  182. package/dist/engines/pi/config.js +35 -5
  183. package/dist/engines/pi/create.d.ts +36 -7
  184. package/dist/engines/pi/create.js +63 -22
  185. package/dist/engines/pi/harness.d.ts +65 -1
  186. package/dist/engines/pi/harness.js +166 -2
  187. package/dist/engines/pi/invoke.d.ts +56 -3
  188. package/dist/engines/pi/invoke.js +340 -20
  189. package/dist/engines/pi/login.d.ts +11 -0
  190. package/dist/engines/pi/login.js +17 -5
  191. package/dist/engines/pi/models.d.ts +56 -10
  192. package/dist/engines/pi/models.js +61 -23
  193. package/dist/engines/pi/search-tools.d.ts +10 -0
  194. package/dist/engines/pi/search-tools.js +138 -0
  195. package/dist/engines/pi/session-builder.d.ts +16 -0
  196. package/dist/engines/pi/session-builder.js +308 -0
  197. package/dist/engines/pi/session-control.d.ts +50 -0
  198. package/dist/engines/pi/session-control.js +604 -0
  199. package/dist/engines/pi/sessions.d.ts +17 -2
  200. package/dist/engines/pi/sessions.js +9 -0
  201. package/dist/engines/pi/tool-context.d.ts +46 -11
  202. package/dist/engines/pi/tool-context.js +11 -9
  203. package/dist/engines/pi/tool.d.ts +35 -6
  204. package/dist/engines/pi/tool.js +47 -1
  205. package/dist/engines/pi/wake-tool.d.ts +0 -3
  206. package/dist/engines/pi/wake-tool.js +9 -7
  207. package/dist/engines/pi/workspace.d.ts +56 -1
  208. package/dist/engines/pi/workspace.js +75 -16
  209. package/dist/feishu.d.ts +1 -1
  210. package/dist/feishu.js +1 -1
  211. package/dist/host/node.d.ts +23 -6
  212. package/dist/host/node.js +5 -4
  213. package/dist/index.d.ts +1 -0
  214. package/dist/index.js +1 -0
  215. package/dist/lark.d.ts +1 -1
  216. package/dist/lark.js +1 -1
  217. package/dist/observe.js +3 -0
  218. package/dist/pi.d.ts +6 -4
  219. package/dist/pi.js +2 -1
  220. package/dist/scaffold/add-channel.d.ts +19 -6
  221. package/dist/scaffold/add-channel.js +127 -16
  222. package/dist/scaffold/templates/fastagent.config.mjs +5 -3
  223. package/dist/schedule/wakeups.d.ts +0 -3
  224. package/dist/schedule/wakeups.js +1 -1
  225. package/dist/session-remote.d.ts +53 -0
  226. package/dist/session-remote.js +336 -0
  227. package/dist/session.d.ts +265 -0
  228. package/dist/session.js +37 -0
  229. package/dist/slack.d.ts +2 -0
  230. package/dist/slack.js +2 -0
  231. package/dist/tunnel.d.ts +7 -4
  232. package/dist/tunnel.js +21 -10
  233. package/package.json +22 -7
  234. package/dist/channels/feishu/seen.d.ts +0 -5
  235. package/dist/channels/feishu/seen.js +0 -47
  236. package/dist/cli-add-feishu.d.ts +0 -8
  237. package/dist/cli-models.d.ts +0 -11
  238. package/dist/cli-models.js +0 -20
@@ -1,6 +1,6 @@
1
1
  import type { ImageRef } from "../../agent.ts";
2
2
  import type { FeishuCloudKind } from "./cloud.ts";
3
- /** Where a reply goes: a chat, optionally quote-replying a message (in-thread in topic groups). */
3
+ /** Where a reply goes: a chat, optionally quote-replying a message inside a platform thread. */
4
4
  export interface FeishuTarget {
5
5
  chatId: string;
6
6
  /** Message to reply to (the summoning message). Set in groups so the answer threads under the asker. */
@@ -34,6 +34,11 @@ export interface FeishuApiOptions {
34
34
  appId: string;
35
35
  appSecret: string;
36
36
  }
37
+ export interface FeishuAppScope {
38
+ name: string;
39
+ grantStatus: number;
40
+ type?: "user" | "tenant";
41
+ }
37
42
  /**
38
43
  * The Feishu Open API client: one instance per channel, holding the token cache. Every method rides the
39
44
  * single pipeline (module header). Throws {@link FeishuApiError} on any failure.
@@ -49,12 +54,12 @@ export interface FeishuApi {
49
54
  }>;
50
55
  /** Send a message to a chat; returns the new message_id (undefined if the body carried none). */
51
56
  sendMessage(chatId: string, msgType: string, content: string): Promise<string | undefined>;
52
- /** Reply to a message (quote; `replyInThread` stays inside a topic group's thread). */
57
+ /** Reply to a message; `replyInThread` creates or continues its platform thread. */
53
58
  replyMessage(messageId: string, msgType: string, content: string, opts?: {
54
59
  replyInThread?: boolean;
55
60
  }): Promise<string | undefined>;
56
- /** Send `text`, split at the platform's size cap: ordinary groups quote only the first chunk; topic
57
- * groups reply_in_thread on every chunk. Returns the FIRST message_id. */
61
+ /** Send `text`, split at the platform's size cap: ordinary groups quote only the first chunk;
62
+ * threaded targets use reply_in_thread on every chunk. Returns the FIRST message_id. */
58
63
  sendText(target: FeishuTarget, text: string): Promise<string | undefined>;
59
64
  /** Edit a sent text message in place (PUT; the platform caps edits at 20 per message). */
60
65
  editTextMessage(messageId: string, text: string): Promise<void>;
@@ -85,6 +90,12 @@ export interface FeishuApi {
85
90
  verificationToken?: string;
86
91
  encryptionKey?: string;
87
92
  }>;
93
+ /** List the app's scopes and grant state. Used by onboarding/runtime to make group visibility
94
+ * explicit instead of silently assuming unmentioned group events are delivered. */
95
+ listAppScopes(): Promise<FeishuAppScope[]>;
96
+ /** Add tenant scopes to the app draft through application-v7 config. Approval + version publishing
97
+ * remain console actions; this method only removes the error-prone manual draft edit. */
98
+ addAppScopes(appId: string, scopeNames: string[]): Promise<void>;
88
99
  /** Update the app's own event subscription (application-v7 config PATCH — tenant token can only
89
100
  * operate on itself; the request-URL change takes effect immediately, no version publish). The
90
101
  * platform VERIFIES `requestUrl` with a url_verification challenge during this call, so the server
@@ -100,9 +111,6 @@ export interface FeishuApi {
100
111
  /** Replace a card entity's content (the settle write; also flips streaming_mode off via the JSON). */
101
112
  updateCard(cardId: string, cardJson: string, sequence: number): Promise<void>;
102
113
  }
103
- /** The platform caps a text-message request body at 150 KB; stay well under it (the content is a JSON
104
- * envelope around the text, and multi-byte characters inflate the byte count). */
105
- export declare const FEISHU_MAX_TEXT_BYTES: number;
106
114
  /** Split text into chunks whose UTF-8 size fits the message cap, preferring a newline boundary. */
107
115
  export declare function chunkFeishuText(text: string, maxBytes?: number): string[];
108
116
  export declare function createFeishuApi(opts: FeishuApiOptions): FeishuApi;
@@ -21,7 +21,7 @@
21
21
  */
22
22
  import { mkdir, writeFile } from "node:fs/promises";
23
23
  import { join } from "node:path";
24
- import { utf8Prefix } from "./text.js";
24
+ import { utf8Prefix } from "../text.js";
25
25
  /** Per-attempt timeout for a JSON API call — small JSON round-trips, so 30s is generous. */
26
26
  const API_TIMEOUT_MS = 30_000;
27
27
  /** Timeout for downloading resource bytes — sized for a slow link, not a JSON call. */
@@ -79,7 +79,7 @@ export function isTransientFeishuRegistrationError(e) {
79
79
  const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
80
80
  /** The platform caps a text-message request body at 150 KB; stay well under it (the content is a JSON
81
81
  * envelope around the text, and multi-byte characters inflate the byte count). */
82
- export const FEISHU_MAX_TEXT_BYTES = 100 * 1024;
82
+ const FEISHU_MAX_TEXT_BYTES = 100 * 1024;
83
83
  /** Split text into chunks whose UTF-8 size fits the message cap, preferring a newline boundary. */
84
84
  export function chunkFeishuText(text, maxBytes = FEISHU_MAX_TEXT_BYTES) {
85
85
  if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0)
@@ -212,8 +212,8 @@ export function createFeishuApi(opts) {
212
212
  let first = true;
213
213
  for (const chunk of chunks) {
214
214
  const content = JSON.stringify({ text: chunk });
215
- // A normal group quote-replies only the first chunk — N reply-quotes would be noise. A topic
216
- // must reply_in_thread on EVERY chunk; a plain chat send would leak continuations to the main group.
215
+ // A normal group quote-replies only the first chunk — N reply-quotes would be noise. A thread
216
+ // must reply_in_thread on EVERY chunk; a plain chat send would leak continuations to main chat.
217
217
  const reply = target.replyTo !== undefined && (first || target.replyInThread === true);
218
218
  const id = reply
219
219
  ? await api.replyMessage(target.replyTo, "text", content, {
@@ -296,6 +296,24 @@ export function createFeishuApi(opts) {
296
296
  encryptionKey: data.data?.app?.encryption?.encryption_key,
297
297
  };
298
298
  },
299
+ async listAppScopes() {
300
+ const data = await call("listAppScopes", "GET", "/open-apis/application/v6/scopes");
301
+ return (data.data?.scopes ?? []).flatMap((scope) => {
302
+ if (typeof scope.scope_name !== "string" || typeof scope.grant_status !== "number")
303
+ return [];
304
+ const type = scope.scope_type === "user" || scope.scope_type === "tenant" ? scope.scope_type : undefined;
305
+ return [{ name: scope.scope_name, grantStatus: scope.grant_status, type }];
306
+ });
307
+ },
308
+ async addAppScopes(appId, scopeNames) {
309
+ if (scopeNames.length === 0)
310
+ return;
311
+ await call("addAppScopes", "PATCH", `/open-apis/application/v7/applications/${encodeURIComponent(appId)}/config`, {
312
+ scope: {
313
+ add_scopes: scopeNames.map((scopeName) => ({ scope_name: scopeName, token_type: "tenant" })),
314
+ },
315
+ });
316
+ },
299
317
  async updateEventSubscription(appId, cfg) {
300
318
  await call("updateEventSubscription", "PATCH", `/open-apis/application/v7/applications/${encodeURIComponent(appId)}/config`, {
301
319
  event: { subscription_type: cfg.subscriptionType, request_url: cfg.requestUrl },
@@ -1,36 +1,58 @@
1
- import type { ChannelModule } from "../../host/node.ts";
1
+ import type { ChannelModule, LongConnectionChannelModule } from "../../host/node.ts";
2
2
  import { type FeishuCloudProfile } from "./cloud.ts";
3
3
  import { type FeishuMessage, type FeishuMessageEvent, type FeishuRoute, defaultFeishuRoute, feishuEnvelope } from "./parse.ts";
4
4
  import { type FeishuFailure } from "./preview.ts";
5
+ import { connectFeishuWs } from "./ws-ingress.ts";
5
6
  export { defaultFeishuRoute, feishuEnvelope };
6
7
  export type { FeishuFailure, FeishuMessage, FeishuMessageEvent, FeishuRoute };
7
- export interface FeishuChannelOptions {
8
+ interface FeishuChannelBaseOptions {
8
9
  /** App ID (developer console → Credentials & Basic Info). */
9
10
  appId: string;
10
- /** App Secret (same page) — drives the tenant_access_token the replies ride on. */
11
+ /** App Secret (same page) — drives both ingress authentication and outbound API calls. */
11
12
  appSecret: string;
12
- /** Verification Token (console Events & Callbacks) authenticates PLAINTEXT events. */
13
- verificationToken: string;
14
- /** Encrypt Key (same page, optional there recommended): when set, ordinary events arrive encrypted
15
- * and signed; this channel then REFUSES plaintext events (fail closed — accepting both would let a
16
- * forger skip the stronger check). Feishu explicitly excludes the encrypted `url_verification`
17
- * handshake from event signature verification; that narrow path is authenticated after decryption
18
- * by the Verification Token. Must match the console exactly. */
19
- encryptKey?: string;
13
+ /** Direct-message context + delivery policy. `threaded` (default) gives every top-level p2p message
14
+ * its own session, creates a platform thread for the answer, and routes later thread messages back
15
+ * by root message id. `continuous` keeps one session per p2p chat and sends ordinary unquoted replies. */
16
+ directMessageSession?: "continuous" | "threaded";
17
+ /** Group-message context + delivery policy. `threaded` (default) gives every top-level summoned
18
+ * message its own session and platform thread; later bare user messages in that managed thread answer
19
+ * in the same root session, while @other-only discussion buffers. `continuous` preserves the legacy
20
+ * chat/topic sessions (`chat_id` / `chat_id:thread_id`). Buffering and bare continuations require
21
+ * `im:message.group_msg`. */
22
+ groupMessageSession?: "continuous" | "threaded";
20
23
  /** Policy: whether/where to answer an event (return null to ignore). Defaults to {@link defaultFeishuRoute}. */
21
24
  route?: (event: FeishuMessageEvent) => FeishuRoute | null;
22
25
  /** Customer-facing failure text for the chat (the dev-facing full `details` always go to the operator
23
26
  * log). Return a string to send it, or undefined/"" to stay silent. Default: a neutral message keyed
24
27
  * on `retryable`. A developer's own bot can surface the raw details, e.g. `(f) => `⚠️ ${f.details}``. */
25
28
  onError?: (failed: FeishuFailure) => string | undefined;
26
- /** API origin override (tests / self-hosted gateways). The kind fixes the default
27
- * `feishuChannel` → `https://open.feishu.cn`, `larkChannel` `https://open.larksuite.com`. */
29
+ /** API origin override (tests / self-hosted gateways). Feishu factories default to
30
+ * `https://open.feishu.cn`; Lark factories default to `https://open.larksuite.com`. Named to match
31
+ * the other channels (telegram/slack). */
32
+ apiBaseUrl?: string;
33
+ /** @deprecated Alias of {@link apiBaseUrl}; kept for existing feishu/lark channel files. */
28
34
  baseUrl?: string;
29
35
  /** How long (ms) a turn waits before its reply-quoted "⏳ Queued" card mounts. Defaults to 0
30
36
  * (immediate); the same card is later taken over by the live preview/final answer. */
31
37
  queueNoticeDelayMs?: number;
32
38
  }
33
- /** Build the canonical Feishu channel. Lark calls the internal profile-bound builder below. */
39
+ export interface FeishuChannelOptions extends FeishuChannelBaseOptions {
40
+ /** Verification Token for Request-URL authentication. */
41
+ verificationToken: string;
42
+ /** Optional webhook Encrypt Key. When set, plaintext events are rejected. */
43
+ encryptKey?: string;
44
+ }
45
+ export type FeishuWebSocketChannelOptions = FeishuChannelBaseOptions & {
46
+ verificationToken?: never;
47
+ encryptKey?: never;
48
+ };
49
+ /** Build the canonical Feishu Request-URL webhook channel. */
34
50
  export declare function feishuChannel(opts: FeishuChannelOptions): ChannelModule;
35
- /** Internal compatibility seam: protocol behavior comes from Feishu; the profile binds cloud edges. */
36
- export declare function buildFeishuChannel(profile: FeishuCloudProfile, { appId, appSecret, verificationToken, encryptKey, route, onError, baseUrl, queueNoticeDelayMs, }: FeishuChannelOptions, factoryName: string): ChannelModule;
51
+ /** Build the canonical Feishu WebSocket long-connection channel. */
52
+ export declare function feishuWebSocketChannel(opts: FeishuWebSocketChannelOptions): LongConnectionChannelModule;
53
+ /** Internal compatibility seams: protocol behavior comes from Feishu; the profile binds cloud edges. */
54
+ interface FeishuWebSocketChannelDeps {
55
+ connectWs?: typeof connectFeishuWs;
56
+ }
57
+ export declare function buildFeishuChannel(profile: FeishuCloudProfile, opts: FeishuChannelOptions, factoryName: string): ChannelModule;
58
+ export declare function buildFeishuWebSocketChannel(profile: FeishuCloudProfile, opts: FeishuWebSocketChannelOptions, factoryName: string, deps?: FeishuWebSocketChannelDeps): LongConnectionChannelModule;