@im-more/dsh-milky 0.0.0-stage → 0.1.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 (76) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +11 -0
  3. package/lib/index.js +2311 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/bot.d.ts +127 -0
  6. package/lib/types/bot.d.ts.map +1 -0
  7. package/lib/types/bot.js +303 -0
  8. package/lib/types/bot.js.map +1 -0
  9. package/lib/types/config.d.ts +24 -0
  10. package/lib/types/config.d.ts.map +1 -0
  11. package/lib/types/config.js +39 -0
  12. package/lib/types/config.js.map +1 -0
  13. package/lib/types/decode.d.ts +43 -0
  14. package/lib/types/decode.d.ts.map +1 -0
  15. package/lib/types/decode.js +277 -0
  16. package/lib/types/decode.js.map +1 -0
  17. package/lib/types/errors.d.ts +66 -0
  18. package/lib/types/errors.d.ts.map +1 -0
  19. package/lib/types/errors.js +170 -0
  20. package/lib/types/errors.js.map +1 -0
  21. package/lib/types/identity.d.ts +24 -0
  22. package/lib/types/identity.d.ts.map +1 -0
  23. package/lib/types/identity.js +33 -0
  24. package/lib/types/identity.js.map +1 -0
  25. package/lib/types/ids.d.ts +110 -0
  26. package/lib/types/ids.d.ts.map +1 -0
  27. package/lib/types/ids.js +166 -0
  28. package/lib/types/ids.js.map +1 -0
  29. package/lib/types/index.d.ts +10 -0
  30. package/lib/types/index.d.ts.map +1 -0
  31. package/lib/types/index.js +9 -0
  32. package/lib/types/index.js.map +1 -0
  33. package/lib/types/internal.d.ts +2002 -0
  34. package/lib/types/internal.d.ts.map +1 -0
  35. package/lib/types/internal.js +408 -0
  36. package/lib/types/internal.js.map +1 -0
  37. package/lib/types/modes/text.d.ts +66 -0
  38. package/lib/types/modes/text.d.ts.map +1 -0
  39. package/lib/types/modes/text.js +275 -0
  40. package/lib/types/modes/text.js.map +1 -0
  41. package/lib/types/reads.d.ts +57 -0
  42. package/lib/types/reads.d.ts.map +1 -0
  43. package/lib/types/reads.js +219 -0
  44. package/lib/types/reads.js.map +1 -0
  45. package/lib/types/request.d.ts +55 -0
  46. package/lib/types/request.d.ts.map +1 -0
  47. package/lib/types/request.js +174 -0
  48. package/lib/types/request.js.map +1 -0
  49. package/lib/types/send.d.ts +34 -0
  50. package/lib/types/send.d.ts.map +1 -0
  51. package/lib/types/send.js +99 -0
  52. package/lib/types/send.js.map +1 -0
  53. package/lib/types/types/schema.d.ts +11726 -0
  54. package/lib/types/types/schema.d.ts.map +1 -0
  55. package/lib/types/types/schema.js +1422 -0
  56. package/lib/types/types/schema.js.map +1 -0
  57. package/lib/types/ws.d.ts +60 -0
  58. package/lib/types/ws.d.ts.map +1 -0
  59. package/lib/types/ws.js +335 -0
  60. package/lib/types/ws.js.map +1 -0
  61. package/package.json +62 -3
  62. package/src/bot.ts +431 -0
  63. package/src/config.ts +61 -0
  64. package/src/decode.ts +367 -0
  65. package/src/errors.ts +195 -0
  66. package/src/identity.ts +43 -0
  67. package/src/ids.ts +226 -0
  68. package/src/index.ts +44 -0
  69. package/src/internal.ts +657 -0
  70. package/src/modes/text.ts +368 -0
  71. package/src/reads.ts +315 -0
  72. package/src/request.ts +230 -0
  73. package/src/send.ts +175 -0
  74. package/src/types/schema.ts +1827 -0
  75. package/src/ws.ts +383 -0
  76. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["chatOf","messageOf"],"sources":["types/config.js","types/errors.js","types/identity.js","types/request.js","types/internal.js","types/ids.js","types/modes/text.js","types/decode.js","types/reads.js","types/send.js","types/ws.js","types/bot.js"],"sourcesContent":["/** Milky adapter configuration: the protocol endpoint, its optional access token, the bot account and the WS budget. */\nimport z from '@deepseek-ai/schemastery';\n/** Validated Milky adapter configuration. */\nexport const Config = z.object({\n endpoint: z\n .string()\n .role('url')\n .required()\n .description('协议端根 URL,例如 http://127.0.0.1:3000;只使用其 origin。'),\n token: z\n .string()\n .role('secret')\n .default('')\n .description('协议端 access_token;留空表示未设置。'),\n selfId: z\n .string()\n .pattern(/^\\d+$/)\n .required()\n .description('机器人 QQ 号,必须与 get_login_info.uin 一致。'),\n ws: z\n .object({\n retryTimes: z\n .natural()\n .default(6)\n .description('快重试预算;用完后改用惰性间隔,但永不放弃。'),\n retryIntervalMs: z\n .natural()\n .role('ms')\n .default(5_000)\n .description('快重试间隔。'),\n retryLazyMs: z\n .natural()\n .role('ms')\n .default(60_000)\n .description('快重试预算用完后的惰性间隔。'),\n })\n .default({}),\n});\n//# sourceMappingURL=config.js.map","/**\n * Milky failures and their mapping onto the core platform taxonomy.\n *\n * `MilkyApiError` carries the facts the classification table of the design needs: the API name, the HTTP status, the\n * protocol envelope status and retcode, and whether the call reached the protocol endpoint at all.\n */\nimport { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\n/** A configuration value that can never work (bad `endpoint`, bad `selfId`). */\nexport class MilkyConfigError extends Error {\n name = 'MilkyConfigError';\n /**\n * @param message - what is wrong with the configuration.\n * @param options - the caught cause, when any.\n */\n constructor(message, options) {\n super(message, options?.cause === undefined ? undefined : { cause: options.cause });\n }\n}\n/**\n * The protocol endpoint is logged into a different account than the configured `selfId`.\n *\n * Runtime permanent: retrying cannot fix a misconfigured endpoint, and continuing would admit another account's events.\n */\nexport class MilkyIdentityError extends Error {\n name = 'MilkyIdentityError';\n /**\n * @param message - which account was expected and which one answered.\n */\n constructor(message) {\n super(message);\n }\n}\n/** One failed Milky API call. */\nexport class MilkyApiError extends Error {\n name = 'MilkyApiError';\n api;\n httpStatus;\n status;\n retcode;\n /**\n * @param message - human-readable failure, already carrying the API name.\n * @param init - what the call observed.\n */\n constructor(message, init) {\n super(message, init.cause === undefined ? undefined : { cause: init.cause });\n this.api = init.api;\n this.httpStatus = init.httpStatus;\n this.status = init.status;\n this.retcode = init.retcode;\n }\n}\n/**\n * Map any failure onto the core platform taxonomy.\n *\n * HTTP 401 / 404 / 415 and every `status: 'failed'` answer are refusals of a request the endpoint understood, so\n * nothing was published; a 5xx, a transport failure or a 2xx answer that cannot be parsed leaves the outcome unknown.\n *\n * @param error - the caught failure.\n * @returns the classified platform error.\n */\nexport function classifyMilkyError(error) {\n if (error instanceof PlatformError)\n return error;\n if (error instanceof MilkyApiError) {\n const code = error.retcode ?? error.httpStatus;\n const init = {\n ...(code === undefined ? {} : { code }),\n cause: error,\n };\n const httpStatus = error.httpStatus;\n if (httpStatus === undefined) {\n // The call never reached the endpoint (dial failure, timeout, reset): whether it ran is unknowable.\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (httpStatus < 200 || httpStatus >= 300) {\n if (httpStatus === 401)\n return new PlatformError('permission', error.message, {\n ...init,\n published: 'no',\n });\n if (httpStatus === 404)\n return new PlatformError('fatal', error.message, {\n ...init,\n published: 'no',\n });\n if (httpStatus === 415)\n return new PlatformError('fatal', error.message, {\n ...init,\n published: 'no',\n });\n if (httpStatus >= 500)\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n if (httpStatus >= 400)\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'no',\n });\n // 1xx/3xx: the request did not reach the API the way it was meant to; whether it ran is unknowable.\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (error.status === 'failed') {\n switch (error.retcode) {\n case -400:\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'no',\n });\n case -403:\n return new PlatformError('permission', error.message, {\n ...init,\n published: 'no',\n });\n case -404:\n return new PlatformError('not-found', error.message, {\n ...init,\n published: 'no',\n });\n default:\n // The specification fixes only -400 and -403; every other retcode is the endpoint's own refusal.\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'no',\n });\n }\n }\n // A 2xx answer without a usable envelope: the endpoint processed the call, the receipt is incomplete.\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (error instanceof MilkyConfigError) {\n return new PlatformError('fatal', error.message, {\n published: 'no',\n cause: error,\n });\n }\n if (error instanceof MilkyIdentityError) {\n return new PlatformError('permission', error.message, {\n published: 'no',\n cause: error,\n });\n }\n if (isAbortError(error)) {\n return new PlatformError('fatal', error.message, {\n published: 'unknown',\n cause: error,\n });\n }\n const message = error instanceof Error ? error.message : String(error);\n return new PlatformError('retryable', `milky request failed: ${message}`, {\n published: 'unknown',\n cause: error,\n });\n}\n/** Whether a caught value is an abort, including the `DOMException` an aborted signal produces. */\nfunction isAbortError(error) {\n return ((error instanceof Error || error instanceof DOMException) &&\n error.name === 'AbortError');\n}\n//# sourceMappingURL=errors.js.map","/** Bot identity: `get_login_info` must name the configured QQ account, and the endpoint version is reported, not trusted. */\nimport { MilkyIdentityError } from \"./errors.js\";\n/**\n * Verify a `get_login_info` answer against the configured account.\n * @param selfId - configured QQ number.\n * @param login - `get_login_info` result.\n * @returns the bot's own user.\n * @throws MilkyIdentityError when the endpoint is logged into another account.\n */\nexport function verifyIdentity(selfId, login) {\n const actual = String(login.uin);\n if (actual !== selfId) {\n throw new MilkyIdentityError(`milky: the endpoint is logged into account ${actual}, but this adapter is configured for ${selfId}`);\n }\n return { id: actual, name: login.nickname };\n}\n/**\n * Whether the endpoint implements the Milky major version this adapter targets.\n * @param version - `milky_version` of `get_impl_info`.\n * @returns true for a `1.x` implementation.\n */\nexport function implementsMilky1(version) {\n return /^1\\./.test(version);\n}\n/**\n * Describe one `get_impl_info` answer for a warning about an unexpected version.\n * @param info - `get_impl_info` result.\n * @returns the diagnostic line.\n */\nexport function versionWarning(info) {\n return `milky: the endpoint implements Milky ${info.milky_version} (${info.impl_name} ${info.impl_version}); this adapter targets 1.x`;\n}\n//# sourceMappingURL=identity.js.map","/**\n * Milky wire transport: `POST <origin>/api/<name>` with the protocol's JSON envelope and a bearer token.\n *\n * The HTTP and WebSocket addresses are derived from the `origin` of `endpoint` only: the protocol endpoint serves\n * `/api` and `/event` next to each other at its root, so a path, query or hash of the configured URL is ignored (the\n * same rule the upstream adapter applies).\n */\nimport { MilkyApiError, MilkyConfigError } from \"./errors.js\";\n/**\n * Normalize the configured endpoint: drop trailing slashes, keep everything else for {@link milkyOrigin} to judge.\n * @param endpoint - `config.endpoint` as given.\n * @returns the endpoint without a trailing slash.\n */\nexport function normalizeEndpoint(endpoint) {\n return endpoint.replace(/\\/+$/, '');\n}\n/**\n * Origin (scheme + host + port) of the protocol endpoint.\n * @param endpoint - normalized endpoint.\n * @returns the origin both the API and the event socket are built from.\n * @throws MilkyConfigError when the endpoint is not a URL or does not use `http:` / `https:`.\n */\nexport function milkyOrigin(endpoint) {\n let url;\n try {\n url = new URL(endpoint);\n }\n catch (cause) {\n throw new MilkyConfigError(`milky: endpoint \"${endpoint}\" is not a valid URL`, { cause });\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new MilkyConfigError(`milky: endpoint must use http: or https:, got \"${url.protocol}\"`);\n }\n return url.origin;\n}\n/**\n * Build the shared request endpoints of one bot.\n * @param ctx - context whose isolated `http` service performs the calls.\n * @param token - configured access token.\n * @param origin - origin of the protocol endpoint.\n * @returns the request endpoints.\n */\nexport function createMilkyRequest(ctx, token, origin) {\n return { ctx, token, origin };\n}\n/**\n * Event socket address of one request endpoint.\n * @param request - request endpoints of the bot.\n * @returns `ws(s)://<origin>/event`.\n */\nexport function eventUrl(request) {\n const url = new URL(request.origin);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.pathname = '/event';\n return url.href;\n}\n/**\n * Call one Milky API method through the shared envelope and error path.\n *\n * @param request - request endpoints of the bot.\n * @param api - API name (`send_group_message`).\n * @param payload - JSON request body; `{}` for the parameterless APIs.\n * @param signal - cancellation of the caller.\n * @returns the `data` field of a `status: 'ok'` answer.\n * @throws MilkyApiError for every non-ok answer, including an unparsable one.\n */\nexport async function invoke(request, api, payload = {}, signal) {\n const headers = { 'content-type': 'application/json' };\n if (request.token !== '')\n headers.authorization = `Bearer ${request.token}`;\n let response;\n try {\n response = (await request.ctx.http(`${request.origin}/api/${api}`, {\n method: 'POST',\n data: payload,\n headers,\n ...(signal === undefined ? {} : { signal }),\n }));\n }\n catch (cause) {\n if (isCancellation(cause, signal))\n throw cancellation(cause, signal);\n throw new MilkyApiError(`milky ${api} request failed`, { api, cause });\n }\n let text;\n try {\n text = await response.text();\n }\n catch (cause) {\n if (signal?.aborted === true)\n throw cancellation(cause, signal);\n throw new MilkyApiError(`milky ${api} answered ${response.status} with an unreadable body`, {\n api,\n httpStatus: response.status,\n cause,\n });\n }\n if (signal?.aborted === true)\n throw cancellation(signal.reason, signal);\n const envelope = parseEnvelope(text);\n const reported = typeof envelope?.message === 'string' ? envelope.message : undefined;\n const retcode = typeof envelope?.retcode === 'number' ? envelope.retcode : undefined;\n if (response.status < 200 || response.status >= 300) {\n throw new MilkyApiError(`milky ${api} answered ${response.status}${reported === undefined ? '' : `: ${reported}`}`, {\n api,\n httpStatus: response.status,\n ...(envelope?.status === 'failed' || envelope?.status === 'ok'\n ? { status: envelope.status }\n : {}),\n ...(retcode === undefined ? {} : { retcode }),\n });\n }\n if (envelope === undefined) {\n throw new MilkyApiError(`milky ${api} answered ${response.status} without a JSON envelope`, {\n api,\n httpStatus: response.status,\n });\n }\n if (envelope.status === 'failed') {\n throw new MilkyApiError(`milky ${api} failed${retcode === undefined ? '' : ` with retcode ${retcode}`}${reported === undefined ? '' : `: ${reported}`}`, {\n api,\n httpStatus: response.status,\n status: 'failed',\n ...(retcode === undefined ? {} : { retcode }),\n });\n }\n if (envelope.status !== 'ok') {\n throw new MilkyApiError(`milky ${api} answered ${response.status} without an envelope status`, {\n api,\n httpStatus: response.status,\n });\n }\n return envelope.data;\n}\n/** Parse a response body as an envelope object; anything else is `undefined`. */\nfunction parseEnvelope(text) {\n let value;\n try {\n value = JSON.parse(text);\n }\n catch (error) {\n // A body that is not JSON is reported as a malformed answer by the caller; the parse failure itself carries nothing.\n void error;\n return;\n }\n if (!value || typeof value !== 'object' || Array.isArray(value))\n return;\n return value;\n}\n/**\n * Whether a failed request was cancelled rather than refused by the transport.\n * @param cause - the value `ctx.http` rejected with.\n * @param signal - the cancellation signal handed to the request.\n * @returns true when the caller cancelled the request.\n */\nfunction isCancellation(cause, signal) {\n if (signal?.aborted === true)\n return true;\n if ((cause instanceof Error || cause instanceof DOMException) &&\n cause.name === 'AbortError')\n return true;\n return signal?.reason !== undefined && cause === signal.reason;\n}\n/**\n * The value a cancelled request rejects with: the signal's reason, so the classifier recognises the cancellation\n * instead of a wrapped transport failure.\n * @param cause - the value `ctx.http` rejected with.\n * @param signal - the cancellation signal handed to the request.\n * @returns the abort error to rethrow.\n */\nfunction cancellation(cause, signal) {\n return signal?.aborted === true ? signal.reason : cause;\n}\n//# sourceMappingURL=request.js.map","import { invoke } from \"./request.js\";\nexport class Internal {\n client;\n constructor(client) {\n this.client = client;\n }\n async request(urlPath, data) {\n return await invoke(this.client, urlPath.replace(/^\\/api\\//, ''), data ?? {});\n }\n /** 获取登录信息 */\n async getLoginInfo() {\n return await this.request('/api/get_login_info', {});\n }\n /** 获取协议端信息 */\n async getImplInfo() {\n return await this.request('/api/get_impl_info', {});\n }\n /** 获取用户个人信息 */\n async getUserProfile(user_id) {\n return await this.request('/api/get_user_profile', {\n user_id,\n });\n }\n /** 获取好友列表 */\n async getFriendList(no_cache) {\n return await this.request('/api/get_friend_list', {\n no_cache,\n });\n }\n /** 获取好友信息 */\n async getFriendInfo(user_id, no_cache) {\n return await this.request('/api/get_friend_info', {\n user_id,\n no_cache,\n });\n }\n /** 获取群列表 */\n async getGroupList(no_cache) {\n return await this.request('/api/get_group_list', {\n no_cache,\n });\n }\n /** 获取群信息 */\n async getGroupInfo(group_id, no_cache) {\n return await this.request('/api/get_group_info', {\n group_id,\n no_cache,\n });\n }\n /** 获取群成员列表 */\n async getGroupMemberList(group_id, no_cache) {\n return await this.request('/api/get_group_member_list', { group_id, no_cache });\n }\n /** 获取群成员信息 */\n async getGroupMemberInfo(group_id, user_id, no_cache) {\n return await this.request('/api/get_group_member_info', { group_id, user_id, no_cache });\n }\n /** 获取置顶的好友和群列表 */\n async getPeerPins() {\n return await this.request('/api/get_peer_pins', {});\n }\n /** 设置好友或群的置顶状态 */\n async setPeerPin(message_scene, peer_id, is_pinned) {\n return await this.request('/api/set_peer_pin', {\n message_scene,\n peer_id,\n is_pinned,\n });\n }\n /** 设置 QQ 账号头像 */\n async setAvatar(uri) {\n return await this.request('/api/set_avatar', { uri });\n }\n /** 设置 QQ 账号昵称 */\n async setNickname(new_nickname) {\n return await this.request('/api/set_nickname', { new_nickname });\n }\n /** 设置 QQ 账号个性签名 */\n async setBio(new_bio) {\n return await this.request('/api/set_bio', { new_bio });\n }\n /** 获取自定义表情 URL 列表 */\n async getCustomFaceUrlList() {\n return await this.request('/api/get_custom_face_url_list', {});\n }\n /** 获取 Cookies */\n async getCookies(domain) {\n return await this.request('/api/get_cookies', { domain });\n }\n /** 获取 CSRF Token */\n async getCSRFToken() {\n return await this.request('/api/get_csrf_token', {});\n }\n /** 发送私聊消息 */\n async sendPrivateMessage(user_id, message) {\n return await this.request('/api/send_private_message', { user_id, message });\n }\n /** 发送群消息 */\n async sendGroupMessage(group_id, message) {\n return await this.request('/api/send_group_message', { group_id, message });\n }\n /** 获取消息 */\n async getMessage(message_scene, peer_id, message_seq) {\n return await this.request('/api/get_message', {\n message_scene,\n peer_id,\n message_seq,\n });\n }\n /** 获取历史消息 */\n async getHistoryMessages(message_scene, peer_id, start_message_seq, limit) {\n return await this.request('/api/get_history_messages', { message_scene, peer_id, start_message_seq, limit });\n }\n /** 获取临时资源链接 */\n async getResourceTempUrl(resource_id) {\n return await this.request('/api/get_resource_temp_url', { resource_id });\n }\n /** 获取合并转发消息内容 */\n async getForwardedMessages(forward_id) {\n return await this.request('/api/get_forwarded_messages', { forward_id });\n }\n /** 撤回私聊消息 */\n async recallPrivateMessage(user_id, message_seq) {\n return await this.request('/api/recall_private_message', {\n user_id,\n message_seq,\n });\n }\n /** 撤回群消息 */\n async recallGroupMessage(group_id, message_seq) {\n return await this.request('/api/recall_group_message', {\n group_id,\n message_seq,\n });\n }\n /** 标记消息为已读 */\n async markMessageAsRead(message_scene, peer_id, message_seq) {\n return await this.request('/api/mark_message_as_read', {\n message_scene,\n peer_id,\n message_seq,\n });\n }\n /** 发送好友戳一戳 */\n async sendFriendNudge(user_id, is_self) {\n return await this.request('/api/send_friend_nudge', {\n user_id,\n is_self,\n });\n }\n /** 发送名片点赞 */\n async sendProfileLike(user_id, count) {\n return await this.request('/api/send_profile_like', { user_id, count });\n }\n /** 删除好友 */\n async deleteFriend(user_id) {\n return await this.request('/api/delete_friend', { user_id });\n }\n /** 获取好友请求列表 */\n async getFriendRequests(limit, is_filtered) {\n return await this.request('/api/get_friend_requests', { limit, is_filtered });\n }\n /** 同意好友请求 */\n async acceptFriendRequest(initiator_uid, is_filtered) {\n return await this.request('/api/accept_friend_request', {\n initiator_uid,\n is_filtered,\n });\n }\n /** 拒绝好友请求 */\n async rejectFriendRequest(initiator_uid, is_filtered, reason) {\n return await this.request('/api/reject_friend_request', {\n initiator_uid,\n is_filtered,\n reason,\n });\n }\n /** 设置群名称 */\n async setGroupName(group_id, new_group_name) {\n return await this.request('/api/set_group_name', {\n group_id,\n new_group_name,\n });\n }\n /** 设置群头像 */\n async setGroupAvatar(group_id, image_uri) {\n return await this.request('/api/set_group_avatar', {\n group_id,\n image_uri,\n });\n }\n /** 设置群名片 */\n async setGroupMemberCard(group_id, user_id, card) {\n return await this.request('/api/set_group_member_card', {\n group_id,\n user_id,\n card,\n });\n }\n /** 设置群成员专属头衔 */\n async setGroupMemberSpecialTitle(group_id, user_id, special_title) {\n return await this.request('/api/set_group_member_special_title', {\n group_id,\n user_id,\n special_title,\n });\n }\n /** 设置群管理员 */\n async setGroupMemberAdmin(group_id, user_id, is_set) {\n return await this.request('/api/set_group_member_admin', {\n group_id,\n user_id,\n is_set,\n });\n }\n /** 设置群成员禁言 */\n async setGroupMemberMute(group_id, user_id, duration) {\n return await this.request('/api/set_group_member_mute', {\n group_id,\n user_id,\n duration,\n });\n }\n /** 设置群全员禁言 */\n async setGroupWholeMute(group_id, is_mute) {\n return await this.request('/api/set_group_whole_mute', {\n group_id,\n is_mute,\n });\n }\n /** 踢出群成员 */\n async kickGroupMember(group_id, user_id, reject_add_request) {\n return await this.request('/api/kick_group_member', {\n group_id,\n user_id,\n reject_add_request,\n });\n }\n /** 获取群公告列表 */\n async getGroupAnnouncements(group_id) {\n return await this.request('/api/get_group_announcements', { group_id });\n }\n /** 发送群公告 */\n async sendGroupAnnouncement(group_id, content, image_uri) {\n return await this.request('/api/send_group_announcement', {\n group_id,\n content,\n image_uri,\n });\n }\n /** 删除群公告 */\n async deleteGroupAnnouncement(group_id, announcement_id) {\n return await this.request('/api/delete_group_announcement', {\n group_id,\n announcement_id,\n });\n }\n /** 获取群精华消息列表 */\n async getGroupEssenceMessages(group_id, page_index, page_size) {\n return await this.request('/api/get_group_essence_messages', { group_id, page_index, page_size });\n }\n /** 设置群精华消息 */\n async setGroupEssenceMessage(group_id, message_seq, is_set) {\n return await this.request('/api/set_group_essence_message', {\n group_id,\n message_seq,\n is_set,\n });\n }\n /** 退出群 */\n async quitGroup(group_id) {\n return await this.request('/api/quit_group', { group_id });\n }\n /** 发送群消息表情回应 */\n async sendGroupMessageReaction(group_id, message_seq, reaction, reaction_type, is_add) {\n return await this.request('/api/send_group_message_reaction', {\n group_id,\n message_seq,\n reaction,\n reaction_type,\n is_add,\n });\n }\n /** 发送群戳一戳 */\n async sendGroupNudge(group_id, user_id) {\n return await this.request('/api/send_group_nudge', {\n group_id,\n user_id,\n });\n }\n /** 获取群通知列表 */\n async getGroupNotifications(start_notification_seq, is_filtered, limit) {\n return await this.request('/api/get_group_notifications', { start_notification_seq, is_filtered, limit });\n }\n /** 同意入群/邀请他人入群请求 */\n async acceptGroupRequest(notification_seq, notification_type, group_id, is_filtered) {\n return await this.request('/api/accept_group_request', {\n notification_seq,\n notification_type,\n group_id,\n is_filtered,\n });\n }\n /** 拒绝入群/邀请他人入群请求 */\n async rejectGroupRequest(notification_seq, notification_type, group_id, is_filtered, reason) {\n return await this.request('/api/reject_group_request', {\n notification_seq,\n notification_type,\n group_id,\n is_filtered,\n reason,\n });\n }\n /** 同意他人邀请自身入群 */\n async acceptGroupInvitation(group_id, invitation_seq) {\n return await this.request('/api/accept_group_invitation', {\n group_id,\n invitation_seq,\n });\n }\n /** 拒绝他人邀请自身入群 */\n async rejectGroupInvitation(group_id, invitation_seq) {\n return await this.request('/api/reject_group_invitation', {\n group_id,\n invitation_seq,\n });\n }\n /** 上传私聊文件 */\n async uploadPrivateFile(user_id, file_uri, file_name) {\n return await this.request('/api/upload_private_file', { user_id, file_uri, file_name });\n }\n /** 上传群文件 */\n async uploadGroupFile(group_id, parent_folder_id, file_uri, file_name) {\n return await this.request('/api/upload_group_file', {\n group_id,\n parent_folder_id,\n file_uri,\n file_name,\n });\n }\n /** 获取私聊文件下载链接 */\n async getPrivateFileDownloadUrl(user_id, file_id, file_hash, is_self_send) {\n return await this.request('/api/get_private_file_download_url', { user_id, file_id, file_hash, is_self_send });\n }\n /** 获取群文件下载链接 */\n async getGroupFileDownloadUrl(group_id, file_id) {\n return await this.request('/api/get_group_file_download_url', { group_id, file_id });\n }\n /** 获取群文件列表 */\n async getGroupFiles(group_id, parent_folder_id) {\n return await this.request('/api/get_group_files', {\n group_id,\n parent_folder_id,\n });\n }\n /** 移动群文件 */\n async moveGroupFile(group_id, file_id, parent_folder_id, target_folder_id) {\n return await this.request('/api/move_group_file', {\n group_id,\n file_id,\n parent_folder_id,\n target_folder_id,\n });\n }\n /** 重命名群文件 */\n async renameGroupFile(group_id, file_id, parent_folder_id, new_file_name) {\n return await this.request('/api/rename_group_file', {\n group_id,\n file_id,\n parent_folder_id,\n new_file_name,\n });\n }\n /** 删除群文件 */\n async deleteGroupFile(group_id, file_id) {\n return await this.request('/api/delete_group_file', {\n group_id,\n file_id,\n });\n }\n /** 转存群文件为永久文件 */\n async persistGroupFile(group_id, file_id) {\n return await this.request('/api/persist_group_file', {\n group_id,\n file_id,\n });\n }\n /** 创建群文件夹 */\n async createGroupFolder(group_id, folder_name) {\n return await this.request('/api/create_group_folder', { group_id, folder_name });\n }\n /** 重命名群文件夹 */\n async renameGroupFolder(group_id, folder_id, new_folder_name) {\n return await this.request('/api/rename_group_folder', {\n group_id,\n folder_id,\n new_folder_name,\n });\n }\n /** 删除群文件夹 */\n async deleteGroupFolder(group_id, folder_id) {\n return await this.request('/api/delete_group_folder', {\n group_id,\n folder_id,\n });\n }\n}\n//# sourceMappingURL=internal.js.map","/**\n * Identifiers shared by decode, send and the reads.\n *\n * Milky names a conversation by `(message_scene, peer_id)` and a message by `message_seq`, which is only unique inside\n * that conversation. DSH needs ids that are globally unique per bot, readable in logs, and decomposable before a\n * platform call, so both are compound text:\n *\n * - chat: `group:<group_id>` / `private:<user_id>` / `temporary:<user_id>`;\n * - message: `g|f|t:<peer_id>:<message_seq>`;\n * - file part (an upload to the file area, not a message): `g|f|t:<peer_id>:file:<file_id>`.\n */\n/** Scene letter of a message / file part id. */\nconst SCENE_PREFIX = {\n group: 'g',\n friend: 'f',\n temp: 't',\n};\nconst PREFIX_SCENE = {\n g: 'group',\n f: 'friend',\n t: 'temp',\n};\n/** Chat id prefix of a scene. */\nconst CHAT_PREFIX = {\n group: 'group',\n friend: 'private',\n temp: 'temporary',\n};\nconst CHAT_SCENE = {\n group: 'group',\n private: 'friend',\n temporary: 'temp',\n};\n/** Chat type DSH sees for a scene. */\nexport function chatTypeOf(scene) {\n return scene === 'group' ? 'group' : 'direct';\n}\n/**\n * Chat id of one scene and peer.\n * @param scene - Milky message scene.\n * @param peerId - group number or user number.\n * @returns the stable chat id.\n */\nexport function chatIdOf(scene, peerId) {\n return `${CHAT_PREFIX[scene]}:${peerId}`;\n}\n/**\n * Split a chat id back into its scene and peer.\n * @param chatId - chat id as this adapter writes it.\n * @returns the parts, or `undefined` for a chat id of another adapter.\n */\nexport function decodeChatId(chatId) {\n const match = /^(group|private|temporary):(\\d+)$/.exec(chatId);\n if (!match)\n return;\n const scene = CHAT_SCENE[match[1]];\n const peerId = Number(match[2]);\n if (!Number.isSafeInteger(peerId))\n return;\n return { scene, peerId };\n}\n/**\n * Chat reference of one scene and peer.\n * @param scene - Milky message scene.\n * @param peerId - group number or user number.\n * @param name - chat name, when the event carries one.\n * @returns the chat reference.\n */\nexport function chatRefOf(scene, peerId, name) {\n return {\n id: chatIdOf(scene, peerId),\n type: chatTypeOf(scene),\n ...(name === undefined || name === '' ? {} : { name }),\n };\n}\n/**\n * Message id of one platform message.\n * @param scene - Milky message scene.\n * @param peerId - group number or user number.\n * @param messageSeq - `message_seq` inside that conversation.\n * @returns the message id.\n */\nexport function messageIdOf(scene, peerId, messageSeq) {\n return `${SCENE_PREFIX[scene]}:${peerId}:${messageSeq}`;\n}\n/**\n * Split a message id back into scene, peer and sequence.\n * @param id - message id as this adapter writes it.\n * @returns the parts, or `undefined` when `id` is not a message id (a file part id included).\n */\nexport function decodeMessageId(id) {\n const match = /^([gft]):(\\d+):(\\d+)$/.exec(id);\n if (!match)\n return;\n const scene = PREFIX_SCENE[match[1]];\n const peerId = Number(match[2]);\n const messageSeq = Number(match[3]);\n if (!Number.isSafeInteger(peerId) || !Number.isSafeInteger(messageSeq))\n return;\n return { scene, peerId, messageSeq };\n}\n/**\n * File part id of one upload to the QQ file area.\n * @param scene - Milky message scene of the chat.\n * @param peerId - group number or user number.\n * @param fileId - platform `file_id` the upload returned.\n * @returns the file part id.\n */\nexport function filePartIdOf(scene, peerId, fileId) {\n return `${SCENE_PREFIX[scene]}:${peerId}:file:${fileId}`;\n}\n/**\n * Split a file part id back into scene, peer and file id.\n * @param id - part id as this adapter writes it.\n * @returns the parts, or `undefined` when `id` is not a file part id.\n */\nexport function decodeFilePartId(id) {\n const match = /^([gft]):(\\d+):file:(.+)$/.exec(id);\n if (!match)\n return;\n return {\n scene: PREFIX_SCENE[match[1]],\n peerId: Number(match[2]),\n fileId: match[3],\n };\n}\n/**\n * Whether a decomposed id names the given chat.\n * @param scene - scene of the id.\n * @param peerId - peer of the id.\n * @param chat - chat id the caller is sending into.\n * @returns true when they describe the same conversation.\n */\nexport function idNamesChat(scene, peerId, chat) {\n return chat !== undefined && chat.scene === scene && chat.peerId === peerId;\n}\n/** Scene token of the `/files/:scene/:peer/:fileId` internal route. */\nexport function fileSceneToken(scene) {\n return scene === 'group' ? 'group' : scene === 'friend' ? 'private' : 'temp';\n}\n/**\n * Event id of one recall, unique per recalled message.\n * @param scene - scene of the recalled message.\n * @param peerId - peer of the recalled message.\n * @param messageSeq - sequence of the recalled message.\n * @returns the event id.\n */\nexport function recallEventId(scene, peerId, messageSeq) {\n return `recall:${SCENE_PREFIX[scene]}:${peerId}:${messageSeq}`;\n}\n/**\n * Event id of one reaction change. `isAdd` is part of the key because the same user may add and remove the same\n * reaction more than once.\n *\n * @param groupId - group the reaction happened in.\n * @param messageSeq - reacted message sequence.\n * @param userId - user who reacted.\n * @param reactionType - `face` or `emoji`.\n * @param faceId - reaction id.\n * @param isAdd - whether the reaction was added (`false` = removed).\n * @returns the event id.\n */\nexport function reactionEventId(groupId, messageSeq, userId, reactionType, faceId, isAdd) {\n return `reaction:${groupId}:${messageSeq}:${userId}:${reactionType}:${faceId}:${isAdd ? 1 : 0}`;\n}\n//# sourceMappingURL=ids.js.map","/**\n * The one `text` mode: a Milky message is a JSON array of segments, so there is no markup dialect to choose between.\n *\n * The mode collects the segments of one logical message. Text, mentions and media ride one `send_*_message` request;\n * a `<file>` cannot be a segment (Milky's `OutgoingSegment` has no file type) and becomes its own draft, uploaded to\n * the QQ file area by `sendPayload`.\n */\nimport { defineMode, ElementRegistry, PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { decodeChatId, decodeFilePartId, decodeMessageId, idNamesChat, } from \"../ids.js\";\n/** Register `text`, `p` and `br` (the mandatory base tags) plus every element Milky can render natively. */\nfunction buildRegistry() {\n return (new ElementRegistry()\n .register('text', (el) => ({ type: 'text', text: el.attrs.content }))\n .register('p', (el, ctx) => [\n ...ctx.render(el.children),\n { type: 'text', text: '\\n' },\n ])\n .register('br', () => ({ type: 'text', text: '\\n' }))\n // `at[type=user]` must stay native: the `im` system prompt asks the model to notify people with `<at user_id>`,\n // and a fallback would silently turn every mention into plain text. A non-numeric id names another platform's\n // user and can only be shown, not notified.\n .register('at', (el) => {\n // The vocabulary makes `type` required, but content in the wild (and the shared corpus) omits it for a user.\n const type = el.attrs.type ?? 'user';\n const { id, name } = el.attrs;\n if (type === 'all')\n return { type: 'mention_all' };\n if (type === 'user' && id !== undefined && /^\\d+$/.test(id))\n return { type: 'mention', userId: id };\n return { type: 'text', text: `@${name ?? id ?? type}` };\n }, \n // `here` and `role` are not declared: Milky has no segment for them and core's fallback renders text.\n { variants: ['user', 'all'] })\n .register('img', (el, ctx) => ({\n type: 'media',\n kind: 'image',\n ref: ctx.resource('image', el.attrs.src, {\n ...(el.attrs.width === undefined ? {} : { width: el.attrs.width }),\n ...(el.attrs.height === undefined\n ? {}\n : { height: el.attrs.height }),\n }),\n }), { variants: ['inline'] })\n .register('audio', (el, ctx) => ({\n type: 'media',\n kind: 'record',\n ref: ctx.resource('audio', el.attrs.src, {\n ...(el.attrs.duration === undefined\n ? {}\n : { duration: el.attrs.duration }),\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n }),\n }))\n .register('video', (el, ctx) => ({\n type: 'media',\n kind: 'video',\n ref: ctx.resource('video', el.attrs.src, {\n ...(el.attrs.duration === undefined\n ? {}\n : { duration: el.attrs.duration }),\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n }),\n }))\n // A file cannot be a segment; the handler still produces its own draft, so `assemble` sees the node.\n .register('file', (el, ctx) => ({\n type: 'file',\n ref: ctx.resource('file', el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n }),\n }))\n // A Milky text segment has no hyperlink: keep the label and append the target the way the upstream adapter did.\n .fallback('a', (el) => [...el.children, `(${el.attrs.href})`]));\n}\n/** Strip leading and trailing newlines of the message text (a `p` always ends with one) and drop empty text nodes. */\nfunction trimMessage(draft) {\n const first = draft.segments[0];\n if (first?.type === 'text')\n first.text = first.text.replace(/^\\n+/, '');\n const last = draft.segments[draft.segments.length - 1];\n if (last?.type === 'text')\n last.text = last.text.replace(/\\n+$/, '');\n for (let index = draft.segments.length - 1; index >= 0; index--) {\n const node = draft.segments[index];\n if (node.type === 'text' && node.text === '')\n draft.segments.splice(index, 1);\n }\n}\n/**\n * Build the `text` mode.\n * @returns the mode (registered under `text`).\n */\nexport function createMilkyTextMode() {\n return defineMode()({\n id: 'text',\n elements: buildRegistry(),\n limits: {\n // One logical message uses at most one segment message; each `<file>` goes to the file area instead.\n 'limit.message.parts': 1,\n },\n assemble: (nodes, envelope, ctx) => {\n const drafts = [];\n // A holder keeps the lazy draft visible across the closure without control-flow narrowing the variable.\n const state = {};\n const messageDraft = () => {\n if (state.message === undefined) {\n const draft = { kind: 'message', segments: [] };\n state.message = draft;\n drafts.push(draft);\n }\n return state.message;\n };\n for (const node of nodes) {\n if (node.type === 'file') {\n drafts.push({\n kind: 'file',\n ref: node.ref,\n name: node.ref.meta.name ?? 'file',\n });\n continue;\n }\n const draft = messageDraft();\n if (node.type === 'text') {\n const last = draft.segments[draft.segments.length - 1];\n if (last?.type === 'text')\n last.text += node.text;\n else\n draft.segments.push({ ...node });\n }\n else {\n draft.segments.push(node);\n }\n }\n const message = state.message;\n if (message !== undefined) {\n trimMessage(message);\n }\n attachQuote(state.message, envelope.quote, ctx);\n // No segments at all: return the empty draft so `check` rejects it before any request.\n if (drafts.length === 0)\n drafts.push({ kind: 'message', segments: [] });\n return drafts;\n },\n serialize: (prepared, ctx) => serializeDraft(prepared, ctx),\n check: (draft) => {\n if (draft.kind === 'file')\n return [];\n if (draft.segments.length > 0)\n return [];\n return [\n {\n kind: 'size',\n key: 'limit.elements',\n limit: 1,\n actual: 0,\n message: 'milky: empty message',\n },\n ];\n },\n });\n}\n/**\n * Decide what happens to an envelope `<quote id>`.\n *\n * A quote that parses as a Milky message id or a file part id is kept for {@link serializeDraft}, which owns the\n * chat-membership check and its precise refusal (a quote of another conversation, or a file part that has no\n * sequence, must not be sent here). A quote that is neither cannot have been published by this adapter, so the reply\n * is dropped and reported — the content still sends, and a `strict` send rejects the report.\n *\n * @param message - the segment draft that would carry the reply, if the content produced one.\n * @param quote - the quoted platform message id.\n * @param ctx - render context (target chat and report).\n */\nfunction attachQuote(message, quote, ctx) {\n if (quote === undefined)\n return;\n if (message === undefined) {\n // A reply can only ride a segment message, and this content produced none.\n ctx.report.dropped.push({ what: 'quote', reason: 'milky-file-only' });\n return;\n }\n if (decodeMessageId(quote) === undefined &&\n decodeFilePartId(quote) === undefined) {\n ctx.report.dropped.push({\n what: 'quote',\n reason: 'milky-quote-unparseable',\n });\n return;\n }\n message.replyTo = quote;\n}\n/** Resolved URI of one resource; a draft reaching serialize unprepared is an adapter bug. */\nfunction resolvedKey(prepared, ref) {\n const resolved = prepared.resolved.get(ref);\n if (resolved === undefined) {\n throw new PlatformError('invalid', `milky: ${ref.kind} \"${ref.src}\" was not prepared before serialize`, {\n published: 'no',\n });\n }\n return resolved.key;\n}\n/** Sequence of the quoted message, which must belong to the chat the payload goes to. */\nfunction replySeqOf(replyTo, chatId) {\n if (decodeFilePartId(replyTo) !== undefined) {\n throw new PlatformError('invalid', `milky: \"${replyTo}\" is a file part id, not a message, and cannot be quoted`, { published: 'no' });\n }\n const decoded = decodeMessageId(replyTo);\n const chat = decodeChatId(chatId);\n if (decoded === undefined ||\n !idNamesChat(decoded.scene, decoded.peerId, chat)) {\n throw new PlatformError('invalid', `milky: quoted message \"${replyTo}\" is not a message of chat \"${chatId}\" and cannot be answered here`, { published: 'no' });\n }\n return decoded.messageSeq;\n}\n/** One node → its outgoing segment; media take their prepared URI. */\nfunction segmentOf(prepared, node) {\n switch (node.type) {\n case 'text':\n return { type: 'text', data: { text: node.text } };\n case 'mention':\n return { type: 'mention', data: { user_id: Number(node.userId) } };\n case 'mention_all':\n return { type: 'mention_all', data: {} };\n case 'media': {\n const uri = resolvedKey(prepared, node.ref);\n switch (node.kind) {\n case 'image':\n return { type: 'image', data: { uri, sub_type: 'normal' } };\n case 'record':\n return { type: 'record', data: { uri } };\n case 'video':\n return { type: 'video', data: { uri } };\n }\n }\n case 'file':\n // A file node never reaches `segmentOf`: `assemble` gives it a draft of its own.\n throw new PlatformError('invalid', 'milky: a file cannot ride a message segment', { published: 'no' });\n }\n}\n/** Name an uploaded file: the element's `name`, else the fetched name recorded by `upload`, else `file`. */\nfunction fileNameOf(prepared, ref) {\n const name = ref.meta.name;\n if (name !== undefined && name !== '')\n return name;\n const extra = prepared.resolved.get(ref)?.extra;\n if (extra && typeof extra === 'object' && 'name' in extra) {\n const fetched = extra.name;\n if (typeof fetched === 'string' && fetched !== '')\n return fetched;\n }\n return 'file';\n}\n/** Serialize one prepared draft into the exact request body. */\nfunction serializeDraft(prepared, ctx) {\n const { draft } = prepared;\n const chatId = ctx.target.chat.id;\n if (draft.kind === 'file') {\n return {\n kind: 'file',\n chatId,\n uri: resolvedKey(prepared, draft.ref),\n name: fileNameOf(prepared, draft.ref),\n };\n }\n const segments = [];\n if (draft.replyTo !== undefined) {\n segments.push({\n type: 'reply',\n data: { message_seq: replySeqOf(draft.replyTo, chatId) },\n });\n }\n for (const node of draft.segments)\n segments.push(segmentOf(prepared, node));\n return { kind: 'message', chatId, segments };\n}\n//# sourceMappingURL=text.js.map","/**\n * Inbound decoding: one Milky event or message becomes a DSH session without any platform I/O.\n *\n * Media never carries bytes or a `temp_url` into the session: both expire, so a segment decodes to a `satori:` route\n * of this bot (`/resources/:resourceId`, `/files/:scene/:peer/:fileId`) that the host fetches when it needs the bytes.\n */\nimport { h, normalize, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { chatRefOf, fileSceneToken, messageIdOf, reactionEventId, recallEventId, } from \"./ids.js\";\n/**\n * Decode one event frame into a session.\n *\n * Only `message_receive`, `message_recall` and `group_message_reaction` have DSH consumers; every other event is left\n * for the transport to log at debug level.\n *\n * @param bot - receiving bot (`selfId` decides `mentions.self`, the platform prefix names internal routes).\n * @param event - one decoded protocol event.\n * @returns the session, or `undefined` for an event this adapter does not surface.\n */\nexport function decodeFrame(bot, event) {\n switch (event.event_type) {\n case 'message_receive': {\n const message = decodeMessage(bot, event.data);\n return bot.session({\n type: 'message',\n id: message.id,\n timestamp: message.time,\n message,\n });\n }\n case 'message_recall': {\n const { message_scene, peer_id, message_seq, operator_id } = event.data;\n return bot.session({\n type: 'message-deleted',\n id: recallEventId(message_scene, peer_id, message_seq),\n timestamp: event.time * 1000,\n deleted: {\n id: messageIdOf(message_scene, peer_id, message_seq),\n chat: chatRefOf(message_scene, peer_id),\n operator: { id: String(operator_id) },\n },\n });\n }\n case 'group_message_reaction': {\n const { group_id, message_seq, user_id, reaction_type, face_id, is_add } = event.data;\n return bot.session({\n type: is_add ? 'reaction-added' : 'reaction-removed',\n id: reactionEventId(group_id, message_seq, user_id, reaction_type, face_id, is_add),\n timestamp: event.time * 1000,\n reaction: {\n message: {\n id: messageIdOf('group', group_id, message_seq),\n chat: chatRefOf('group', group_id),\n },\n // The same `<reaction_type>|<reaction_id>` spelling `createReaction` parses back.\n emoji: `${reaction_type}|${face_id}`,\n user: { id: String(user_id) },\n },\n });\n }\n default:\n return undefined;\n }\n}\n/**\n * Decode one received message.\n *\n * @param bot - receiving bot.\n * @param input - `IncomingMessage` of the event (or of a `get_message` answer).\n * @returns the inbound message; its content is never empty.\n */\nexport function decodeMessage(bot, input) {\n const scene = input.message_scene;\n const chat = chatOf(input);\n const segments = input.segments;\n const mentions = {\n self: false,\n all: false,\n users: [],\n };\n const nodes = [];\n let quote;\n for (const segment of segments) {\n if (segment.type === 'reply') {\n quote = decodeQuote(bot, input, segment.data);\n continue;\n }\n nodes.push(...segmentNodes(bot, scene, input.peer_id, segment, mentions, 'element'));\n }\n const message = {\n id: messageIdOf(scene, input.peer_id, input.message_seq),\n chat,\n sender: senderOf(input),\n content: decodeContent(input, nodes),\n mentions,\n time: input.time * 1000,\n referrer: referrerOf(input),\n ...(quote === undefined ? {} : { quote }),\n };\n return message;\n}\n/** The chat a message names (`group:…` / `private:…` / `temporary:…`), with its display name when the event has one. */\nfunction chatOf(input) {\n switch (input.message_scene) {\n case 'group':\n return chatRefOf('group', input.peer_id, input.group.group_name);\n case 'friend':\n return chatRefOf('friend', input.peer_id, input.friend.nickname);\n case 'temp':\n return chatRefOf('temp', input.peer_id);\n }\n}\n/** The sender, with the group card preferred over the account nickname and the group role when known. */\nfunction senderOf(input) {\n const id = String(input.sender_id);\n switch (input.message_scene) {\n case 'group': {\n const member = input.group_member;\n const name = member.card || member.nickname;\n return { id, ...(name === '' ? {} : { name }), role: member.role };\n }\n case 'friend': {\n const name = input.friend.nickname;\n return { id, ...(name === '' ? {} : { name }) };\n }\n case 'temp':\n return { id };\n }\n}\n/** The reply context: the quoted message is always in the same conversation as the reply. */\nfunction referrerOf(input) {\n return {\n scene: input.message_scene,\n peerId: input.peer_id,\n messageSeq: input.message_seq,\n senderId: input.sender_id,\n time: input.time,\n };\n}\n/**\n * Normalize the decoded segments, falling back to the raw payload when nothing rendered.\n *\n * @param input - the message the segments belong to.\n * @param nodes - nodes the segment decoder produced.\n * @returns non-empty content.\n */\nfunction decodeContent(input, nodes) {\n const content = normalize(nodes);\n if (content.children.length > 0)\n return content;\n // `content` is never empty: a message whose segments all decode to nothing (or that carries only an unsupported\n // segment) keeps its raw payload so the host can still show that something arrived.\n return normalize([\n h('raw', { platform: 'milky', type: 'message', data: input }),\n ]);\n}\n/** One `reply` segment → the quoted message; its `segments` are used when the endpoint sent them (Milky ≥ 1.2). */\nfunction decodeQuote(bot, input, data) {\n const id = messageIdOf(input.message_scene, input.peer_id, data.message_seq);\n const sender = {\n id: String(data.sender_id),\n ...(data.sender_name === undefined ||\n data.sender_name === null ||\n data.sender_name === ''\n ? {}\n : { name: data.sender_name }),\n };\n const segments = data.segments;\n if (!Array.isArray(segments) || segments.length === 0)\n return { id, sender };\n const mentions = {\n self: false,\n all: false,\n users: [],\n };\n const nodes = [];\n for (const segment of segments) {\n // A reply inside a quoted message would recurse without end; the quote of a quote is not part of its content.\n if (segment.type === 'reply')\n continue;\n nodes.push(...segmentNodes(bot, input.message_scene, input.peer_id, segment, mentions, 'element'));\n }\n const content = normalize(nodes);\n if (content.children.length === 0)\n return { id, sender };\n return { id, sender, content };\n}\n/**\n * Map one segment to elements.\n *\n * @param bot - receiving bot, used for internal media routes and `mentions.self`.\n * @param scene - scene of the message the segment belongs to.\n * @param peerId - peer of that message.\n * @param segment - one incoming segment.\n * @param mentions - accumulator of the message's mention facts.\n * @param forwardStyle - how a merged forward segment renders.\n * @returns the elements of the segment (possibly none).\n */\nfunction segmentNodes(bot, scene, peerId, segment, mentions, forwardStyle) {\n switch (segment.type) {\n case 'text':\n return [h('text', { content: segment.data.text })];\n case 'mention': {\n const id = String(segment.data.user_id);\n const name = segment.data.name;\n if (!mentions.users.some((user) => user.id === id)) {\n mentions.users.push({ id, ...(name === '' ? {} : { name }) });\n }\n if (id === bot.selfId)\n mentions.self = true;\n return [h('at', { type: 'user', id, ...(name === '' ? {} : { name }) })];\n }\n case 'mention_all':\n mentions.all = true;\n return [h('at', { type: 'all' })];\n case 'image':\n return [\n h('img', {\n src: resourceRoute(bot, segment.data.resource_id),\n width: segment.data.width,\n height: segment.data.height,\n }),\n ];\n case 'record':\n return [\n h('audio', {\n src: resourceRoute(bot, segment.data.resource_id),\n duration: segment.data.duration,\n }),\n ];\n case 'video':\n return [\n h('video', {\n src: resourceRoute(bot, segment.data.resource_id),\n duration: segment.data.duration,\n }),\n ];\n case 'file':\n return [fileElement(bot, scene, peerId, segment.data)];\n case 'face':\n return [h('emoji', { id: segment.data.face_id, name: '[表情]' })];\n case 'market_face':\n return segment.data.url === ''\n ? [h('text', { content: '[表情]' })]\n : [h('img', { src: segment.data.url })];\n case 'forward':\n return forwardStyle === 'text'\n ? [h('text', { content: `[合并转发 #${segment.data.forward_id}]` })]\n : [h('forward', { id: segment.data.forward_id })];\n case 'light_app':\n return [\n h('raw', { platform: 'milky', type: 'light_app', data: segment.data }),\n ];\n case 'xml':\n return [h('raw', { platform: 'milky', type: 'xml', data: segment.data })];\n case 'markdown':\n return [h('text', { content: segment.data.content })];\n default: {\n // A segment type a newer endpoint added: the compatibility policy is to show text, never to drop the frame.\n const unknown = segment;\n const type = typeof unknown.type === 'string' ? unknown.type : 'unknown';\n return [h('text', { content: `[不支持的${type}消息]` })];\n }\n }\n}\n/** Internal route of one message resource (`resource_id` is stable; `temp_url` is not). */\nfunction resourceRoute(bot, resourceId) {\n return bot.getInternalUrl(`/resources/${encodeURIComponent(resourceId)}`);\n}\n/** An inbound file, routed through the `/files/:scene/:peer/:fileId` internal route (with its hash when private). */\nfunction fileElement(bot, scene, peerId, data) {\n const hash = data.file_hash;\n return h('file', {\n src: bot.getInternalUrl(`/files/${fileSceneToken(scene)}/${peerId}/${encodeURIComponent(data.file_id)}`, hash === undefined || hash === null || hash === '' ? undefined : { hash }),\n name: data.file_name,\n });\n}\n//# sourceMappingURL=decode.js.map","/**\n * The read surface: members, one message by id (with merged forwards expanded) and group reactions.\n *\n * These are the only platform reads the adapter performs on request; inbound decoding itself does none.\n */\nimport { PlatformError, h, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { decodeMessage } from \"./decode.js\";\nimport { decodeChatId, decodeMessageId, idNamesChat } from \"./ids.js\";\n/**\n * One page of the people a chat lists as its members.\n *\n * Milky's member API has no paging parameters, so the cursor is the adapter's own index into the full list; a private\n * chat lists its single peer.\n *\n * @param internal - platform API client.\n * @param chat - chat to list.\n * @param cursor - `next` of the previous page.\n * @param limit - page-size hint from the host.\n * @returns one page.\n * @throws PlatformError `invalid` for a chat id this adapter did not write or a cursor that is not an index.\n */\nexport async function members(internal, chat, cursor, limit) {\n const decoded = decodeChatId(chat.id);\n if (decoded === undefined) {\n throw new PlatformError('invalid', `milky: \"${chat.id}\" is not a milky chat id`);\n }\n const offset = cursor === undefined ? 0 : Number(cursor);\n if (!Number.isSafeInteger(offset) || offset < 0) {\n throw new PlatformError('invalid', `milky: \"${cursor}\" is not a member-list cursor of chat \"${chat.id}\"`);\n }\n if (decoded.scene !== 'group') {\n // A private (or temporary) conversation has exactly one counterpart.\n if (offset > 0)\n return { data: [] };\n const profile = await internal.getUserProfile(decoded.peerId);\n const name = profile?.nickname;\n return {\n data: [\n {\n id: String(decoded.peerId),\n ...(name === undefined || name === '' ? {} : { name }),\n },\n ],\n };\n }\n const result = await internal.getGroupMemberList(decoded.peerId);\n const list = Array.isArray(result?.members) ? result.members : [];\n const size = limit === undefined || limit <= 0 ? list.length : limit;\n const data = list.slice(offset, offset + size).map((member) => ({\n id: String(member.user_id),\n name: member.card || member.nickname,\n role: member.role,\n }));\n const next = offset + size < list.length ? String(offset + size) : undefined;\n return { data, ...(next === undefined ? {} : { next }) };\n}\n/**\n * Read one message by id.\n *\n * @param bot - bot whose platform prefix names internal media routes.\n * @param chat - the chat the caller asked about; the id must belong to it.\n * @param id - platform message id (`g|f|t:<peer>:<seq>`).\n * @returns the message, with merged-forward entries expanded.\n * @throws PlatformError `invalid` for an id of another chat or a file part id (those carry no `message_seq`).\n */\nexport async function getMessage(bot, chat, id) {\n const decoded = decodeMessageId(id);\n const target = decodeChatId(chat.id);\n if (decoded === undefined ||\n !idNamesChat(decoded.scene, decoded.peerId, target)) {\n throw new PlatformError('invalid', `milky: \"${id}\" is not a message of chat \"${chat.id}\" and cannot be read there`);\n }\n const result = await bot.internal.getMessage(decoded.scene, decoded.peerId, decoded.messageSeq);\n const input = result?.message;\n if (input === undefined || input === null) {\n throw new PlatformError('invalid', `milky: get_message answered without a message for \"${id}\"`);\n }\n const message = decodeMessage(bot, input);\n if (message.chat.id !== chat.id) {\n throw new PlatformError('invalid', `milky: \"${id}\" belongs to chat \"${message.chat.id}\", not \"${chat.id}\"`);\n }\n await expandForward(bot, message);\n return message;\n}\n/**\n * Fill the entries of a root merged-forward placeholder.\n *\n * A `<forward>` from decoding carries only its id; only a platform read knows the entries, so the host asks for the\n * expansion when it needs the content (`im_read`). Entries become one text line each; a nested forward stays a\n * `[合并转发 #id]` placeholder so one read cannot fan out without bound.\n *\n * @param bot - platform API client of the reading bot.\n * @param message - the message whose forward placeholder to expand.\n */\nasync function expandForward(bot, message) {\n const forward = message.content.children.find((el) => el.type === 'forward' && el.children.length === 0);\n if (forward === undefined)\n return;\n const result = await bot.internal.getForwardedMessages(forward.attrs.id);\n const entries = Array.isArray(result?.messages) ? result.messages : [];\n const children = [];\n entries.forEach((entry, index) => {\n if (index > 0)\n children.push(h('br'));\n const text = forwardedText(entry.segments);\n children.push(h('text', { content: `${entry.sender_name}: ${text}` }));\n });\n forward.children = children;\n}\n/**\n * Inline text of one forwarded entry: blocks flattened into one line, media and nested forwards as placeholders.\n * @param segments - segments of the forwarded message.\n * @returns its text, without line breaks.\n */\nfunction forwardedText(segments) {\n const parts = [];\n for (const segment of segments) {\n switch (segment.type) {\n case 'text':\n parts.push(segment.data.text);\n break;\n case 'mention':\n parts.push(`@${segment.data.name}`);\n break;\n case 'mention_all':\n parts.push('@全体');\n break;\n case 'face':\n case 'market_face':\n parts.push('[表情]');\n break;\n case 'image':\n parts.push('[图片]');\n break;\n case 'record':\n parts.push('[语音]');\n break;\n case 'video':\n parts.push('[视频]');\n break;\n case 'file':\n parts.push(`[文件${segment.data.file_name === '' ? '' : `: ${segment.data.file_name}`}]`);\n break;\n case 'forward':\n parts.push(`[合并转发 #${segment.data.forward_id}]`);\n break;\n case 'light_app':\n parts.push(`[小程序${segment.data.app_name === '' ? '' : `: ${segment.data.app_name}`}]`);\n break;\n case 'xml':\n parts.push('[XML 消息]');\n break;\n case 'markdown':\n parts.push(segment.data.content);\n break;\n case 'reply':\n break;\n default: {\n const unknown = segment;\n const type = typeof unknown.type === 'string' ? unknown.type : 'unknown';\n parts.push(`[不支持的${type}消息]`);\n }\n }\n }\n return parts.join('').replace(/\\s+/g, ' ').trim();\n}\n/** The group and sequence one reaction targets, refusing anything that is not a group message of this chat. */\nfunction reactionTarget(message) {\n const decoded = decodeMessageId(message.id);\n const chat = decodeChatId(message.chat.id);\n if (message.chat.type !== 'group' || chat?.scene !== 'group') {\n throw new PlatformError('invalid', 'milky: reactions are only available in group chats', { published: 'no' });\n }\n if (decoded === undefined ||\n decoded.scene !== 'group' ||\n !idNamesChat(decoded.scene, decoded.peerId, chat)) {\n throw new PlatformError('invalid', `milky: \"${message.id}\" is not a message of group \"${message.chat.id}\"`, { published: 'no' });\n }\n return { groupId: chat.peerId, messageSeq: decoded.messageSeq };\n}\n/**\n * Parse the adapter's `<reaction_type>|<reaction_id>` reaction encoding; a bare value is a QQ face id.\n * @param emoji - reaction the host asked for.\n * @returns the protocol reaction type and id.\n * @throws PlatformError `invalid` for an unknown reaction type prefix.\n */\nexport function parseReaction(emoji) {\n const index = emoji.indexOf('|');\n if (index < 0)\n return { type: 'face', id: emoji };\n const type = emoji.slice(0, index);\n if (type !== 'face' && type !== 'emoji') {\n throw new PlatformError('invalid', `milky: \"${emoji}\" does not name a reaction type (expected face|<id> or emoji|<id>)`, { published: 'no' });\n }\n return { type, id: emoji.slice(index + 1) };\n}\n/**\n * Add one group reaction.\n * @param internal - platform API client.\n * @param message - the reacted message.\n * @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.\n */\nexport async function createReaction(internal, message, emoji) {\n const { groupId, messageSeq } = reactionTarget(message);\n const reaction = parseReaction(emoji);\n await internal.sendGroupMessageReaction(groupId, messageSeq, reaction.id, reaction.type, true);\n}\n/**\n * Remove one group reaction.\n * @param internal - platform API client.\n * @param message - the reacted message.\n * @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.\n */\nexport async function deleteReaction(internal, message, emoji) {\n const { groupId, messageSeq } = reactionTarget(message);\n const reaction = parseReaction(emoji);\n await internal.sendGroupMessageReaction(groupId, messageSeq, reaction.id, reaction.type, false);\n}\n//# sourceMappingURL=reads.js.map","/**\n * Outbound calls: one segment message (`send_group_message` / `send_private_message`), one file upload to the QQ file\n * area (`upload_group_file` / `upload_private_file`), and the two deletion paths (`recall_*_message`,\n * `delete_group_file`).\n *\n * Milky's `OutgoingSegment` has no file type, so a `<file>` is not a chat message at all: it is a real upload that\n * returns a `file_id`, and the sent part carries `<scene>:<peer>:file:<file_id>` with `kind: 'file'`.\n */\nimport { PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { decodeChatId, decodeFilePartId, decodeMessageId, filePartIdOf, idNamesChat, messageIdOf, } from \"./ids.js\";\n/** Whether the target asked for a thread, which Milky cannot follow. */\nfunction refuseThread(target) {\n if (typeof target.thread === 'string') {\n throw new PlatformError('invalid', `milky: message threads are not supported (thread \"${target.thread}\")`, { published: 'no' });\n }\n}\n/** The chat a payload names, refusing an id this adapter did not write. */\nfunction chatOf(chatId) {\n const chat = decodeChatId(chatId);\n if (chat === undefined) {\n throw new PlatformError('invalid', `milky: \"${chatId}\" is not a milky chat id (expected group:, private: or temporary:)`, { published: 'no' });\n }\n return chat;\n}\n/**\n * Send one serialized payload.\n *\n * @param deps - adapter services.\n * @param payload - the serialized draft.\n * @param target - the chat the payload goes to.\n * @param ctx - core send context (cancellation, part index).\n * @returns the published part.\n */\nexport async function sendPayload(deps, payload, target, _ctx) {\n refuseThread(target);\n const chat = chatOf(payload.chatId);\n if (payload.kind === 'file') {\n const response = chat.scene === 'group'\n ? await deps.internal.uploadGroupFile(chat.peerId, undefined, payload.uri, payload.name)\n : await deps.internal.uploadPrivateFile(chat.peerId, payload.uri, payload.name);\n const fileId = response?.file_id;\n if (typeof fileId !== 'string' || fileId === '') {\n // The upload may well have happened; only its receipt is unusable.\n throw new PlatformError('invalid', 'milky: the file upload answered without a file_id', { published: 'unknown' });\n }\n return {\n id: filePartIdOf(chat.scene, chat.peerId, fileId),\n kind: 'file',\n time: Date.now(),\n };\n }\n const response = chat.scene === 'group'\n ? await deps.internal.sendGroupMessage(chat.peerId, payload.segments)\n : await deps.internal.sendPrivateMessage(chat.peerId, payload.segments);\n const messageSeq = response?.message_seq;\n if (typeof messageSeq !== 'number' || !Number.isSafeInteger(messageSeq)) {\n throw new PlatformError('invalid', 'milky: the send answered without a message_seq', { published: 'unknown' });\n }\n return {\n id: messageIdOf(chat.scene, chat.peerId, messageSeq),\n kind: 'message',\n time: typeof response?.time === 'number' ? response.time * 1000 : Date.now(),\n };\n}\n/**\n * Delete one published part: recall a message, or remove a group file from the file area.\n *\n * @param deps - adapter services.\n * @param part - the published part.\n * @param handle - the message handle (carries the target chat).\n */\nexport async function deletePart(deps, part, handle) {\n const chat = chatOf(handle.target.chat.id);\n if (part.kind === 'file') {\n const decoded = decodeFilePartId(part.id);\n if (decoded === undefined ||\n !idNamesChat(decoded.scene, decoded.peerId, chat)) {\n throw new PlatformError('invalid', `milky: file part \"${part.id}\" does not belong to chat \"${handle.target.chat.id}\"`, { published: 'no' });\n }\n if (chat.scene !== 'group') {\n // 1.3 has no endpoint that deletes a file sent to a private chat.\n throw new PlatformError('invalid', 'milky: a file uploaded to a private chat cannot be deleted', {\n published: 'no',\n });\n }\n await deps.internal.deleteGroupFile(chat.peerId, decoded.fileId);\n return;\n }\n const decoded = decodeMessageId(part.id);\n if (decoded === undefined ||\n !idNamesChat(decoded.scene, decoded.peerId, chat)) {\n throw new PlatformError('invalid', `milky: message part \"${part.id}\" does not belong to chat \"${handle.target.chat.id}\"`, { published: 'no' });\n }\n if (chat.scene === 'group')\n await deps.internal.recallGroupMessage(chat.peerId, decoded.messageSeq);\n else\n await deps.internal.recallPrivateMessage(chat.peerId, decoded.messageSeq);\n}\n//# sourceMappingURL=send.js.map","/**\n * The client WebSocket to `<origin>/event`: a self-written loop because core's `WsClientBase` treats `retryTimes` as\n * a give-up limit.\n *\n * Three failure classes are kept apart:\n * - configuration failures are found by `connect()` before the loop starts and thrown there;\n * - transport failures (dial, handshake, socket close, identity read) log a warning and enter the reconnect loop;\n * - runtime permanent failures (the endpoint is logged into another account, or a frame names another `self_id`)\n * log an error, take the bot offline and stop the loop.\n *\n * Frames are handled one at a time in arrival order. A frame whose intake throws is logged and dropped — the protocol\n * has no acknowledgement and no redelivery, so retrying it would only delay the frames behind it.\n */\nimport { Status } from '@deepseek-ai/cordis-plugin-im-core';\nimport { decodeFrame } from \"./decode.js\";\nimport { MilkyIdentityError } from \"./errors.js\";\n/** Resolve after `ms`, or as soon as `signal` aborts. */\nfunction sleep(ms, signal) {\n return new Promise((resolve) => {\n if (signal.aborted) {\n resolve();\n return;\n }\n const onAbort = () => {\n clearTimeout(timer);\n resolve();\n };\n const timer = setTimeout(() => {\n signal.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal.addEventListener('abort', onAbort, { once: true });\n });\n}\n/** A settled promise nobody waits for. */\nconst noop = () => { };\n/** Describe a caught value for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** The event stream of one Milky protocol endpoint. */\nexport class MilkyWs {\n bot;\n controller;\n running;\n socket;\n queue = [];\n draining;\n processing = false;\n stopping = false;\n warnedDepth = 0;\n /**\n * @param bot - the adapter whose identity, configuration and logger the loop uses.\n */\n constructor(bot) {\n this.bot = bot;\n }\n /** Start the reconnect loop; resolves immediately, without waiting for the first connection. */\n start() {\n if (this.controller !== undefined)\n return;\n const controller = new AbortController();\n this.controller = controller;\n this.stopping = false;\n const running = this.loop(controller.signal);\n this.running = running;\n void running.catch(noop);\n }\n /**\n * Stop the stream: abort the loop, close the socket, drop the frames that have not started, and wait for the frame\n * being handled to finish.\n */\n async stop() {\n this.stopping = true;\n this.controller?.abort(new Error('adapter stopped'));\n this.controller = undefined;\n this.closeSocket(1000, 'adapter stopped');\n this.dropQueue();\n await this.running?.catch(noop);\n this.running = undefined;\n await this.draining?.catch(noop);\n this.draining = undefined;\n }\n /** The reconnect loop: dial, identify, consume, then retry at the fast or lazy interval. */\n async loop(signal) {\n let failures = 0;\n while (!signal.aborted) {\n try {\n const socket = await this.dial(signal);\n if (signal.aborted) {\n this.closeSocketOf(socket, 1000, 'adapter stopped');\n return;\n }\n this.socket = socket;\n await this.bot.identify();\n failures = 0;\n this.bot.online();\n const closed = await this.consume(socket, signal);\n if (signal.aborted)\n return;\n throw new Error(`websocket closed with ${closed.code}${closed.reason === '' ? '' : `: ${closed.reason}`}`);\n }\n catch (error) {\n this.closeSocket(3000, 'milky connection failed');\n if (signal.aborted)\n return;\n if (error instanceof MilkyIdentityError) {\n this.bot.ctx.logger.error('milky: %s', error.message);\n this.bot.offline(error);\n this.stopping = true;\n return;\n }\n this.bot.ctx.logger.warn('milky: connection failed: %s', messageOf(error));\n this.bot.status = Status.RECONNECT;\n // `retryTimes` is a fast-retry budget, not a give-up limit: the loop keeps retrying at the lazy interval.\n const delay = failures < this.bot.config.ws.retryTimes\n ? this.bot.config.ws.retryIntervalMs\n : this.bot.config.ws.retryLazyMs;\n failures += 1;\n await sleep(delay, signal);\n }\n finally {\n this.socket = undefined;\n }\n }\n }\n /** Open one socket and wait for its `open` event; a close or error before that is a transport failure. */\n dial(signal) {\n return new Promise((resolve, reject) => {\n let socket;\n try {\n socket = this.bot.openEventSocket();\n }\n catch (error) {\n reject(error);\n return;\n }\n const cleanup = () => {\n socket.removeEventListener('open', onOpen);\n socket.removeEventListener('close', onClose);\n socket.removeEventListener('error', onError);\n signal.removeEventListener('abort', onAbort);\n };\n const onOpen = () => {\n cleanup();\n resolve(socket);\n };\n const onClose = (event) => {\n cleanup();\n reject(new Error(`websocket closed with ${event.code} before it opened`));\n };\n const onError = (event) => {\n cleanup();\n reject(new Error(event.message ?? 'websocket transport error before it opened'));\n };\n const onAbort = () => {\n cleanup();\n this.closeSocketOf(socket, 1000, 'adapter stopped');\n reject(signal.reason ?? new Error('adapter stopped'));\n };\n socket.addEventListener('open', onOpen);\n socket.addEventListener('close', onClose);\n socket.addEventListener('error', onError);\n signal.addEventListener('abort', onAbort, { once: true });\n if (signal.aborted)\n onAbort();\n });\n }\n /** Deliver every frame of one open socket until it closes; resolves with the close details. */\n consume(socket, signal) {\n return new Promise((resolve) => {\n const cleanup = () => {\n socket.removeEventListener('message', onMessage);\n socket.removeEventListener('close', onClose);\n socket.removeEventListener('error', onError);\n signal.removeEventListener('abort', onAbort);\n };\n const onMessage = (event) => {\n if (typeof event.data === 'string')\n this.accept(event.data);\n else\n this.bot.ctx.logger.warn('milky: ignored a websocket frame that was not text');\n };\n const onClose = (event) => {\n cleanup();\n resolve({ code: event.code, reason: event.reason });\n };\n const onError = () => {\n this.bot.ctx.logger.warn('milky: websocket transport error');\n };\n const onAbort = () => {\n cleanup();\n this.closeSocketOf(socket, 1000, 'adapter stopped');\n resolve({ code: 1000, reason: 'adapter stopped' });\n };\n socket.addEventListener('message', onMessage);\n socket.addEventListener('close', onClose);\n socket.addEventListener('error', onError);\n signal.addEventListener('abort', onAbort, { once: true });\n if (signal.aborted)\n onAbort();\n // A socket that reported close before this listener was attached would never fire it again.\n else if (socket.readyState === 3) {\n cleanup();\n resolve({ code: 1006, reason: 'closed before the frame listener' });\n }\n });\n }\n /** Parse, validate and queue one frame. */\n accept(raw) {\n let parsed;\n try {\n parsed = JSON.parse(raw);\n }\n catch (error) {\n // A frame this adapter cannot read is dropped; the next frame is unaffected.\n this.bot.ctx.logger.warn('milky: ignored a frame that is not JSON: %s', messageOf(error));\n return;\n }\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n this.bot.ctx.logger.warn('milky: ignored a frame that is not an event object');\n return;\n }\n const event = parsed;\n if (typeof event.event_type !== 'string' ||\n typeof event.self_id !== 'number' ||\n typeof event.time !== 'number') {\n this.bot.ctx.logger.warn('milky: ignored a frame without event_type, self_id or time');\n return;\n }\n if (String(event.self_id) !== this.bot.selfId) {\n // Another account's event would be stored as this bot's message: permanent, and retrying cannot fix it.\n this.halt(new MilkyIdentityError(`milky: a frame names account ${String(event.self_id)}, but this adapter is configured for ${this.bot.selfId}`));\n return;\n }\n this.enqueue(event);\n }\n /** Queue one frame behind the frames already waiting, warning once per doubling of the backlog. */\n enqueue(event) {\n this.queue.push(event);\n const depth = this.queue.length;\n if (depth >= 2 && (depth & (depth - 1)) === 0 && depth > this.warnedDepth) {\n this.warnedDepth = depth;\n this.bot.ctx.logger.warn('milky: %d events are waiting for intake', depth);\n }\n if (this.processing)\n return;\n const draining = this.drain();\n this.draining = draining;\n void draining.finally(() => {\n if (this.draining === draining)\n this.draining = undefined;\n });\n }\n /** Handle queued frames one at a time, in arrival order. */\n async drain() {\n if (this.processing)\n return;\n this.processing = true;\n try {\n while (this.queue.length > 0) {\n if (this.stopping) {\n this.dropQueue();\n return;\n }\n const event = this.queue.shift();\n await this.handle(event);\n }\n this.warnedDepth = 0;\n }\n finally {\n this.processing = false;\n }\n }\n /** Decode and receive one frame; a failure drops that frame and nothing else. */\n async handle(event) {\n if (event.event_type === 'bot_offline') {\n this.bot.ctx.logger.warn('milky: the protocol endpoint reports the account offline: %s', event.data.reason);\n return;\n }\n let session;\n try {\n session = decodeFrame(this.bot, event);\n }\n catch (error) {\n this.bot.ctx.logger.error('milky: a %s frame could not be decoded: %s', event.event_type, messageOf(error));\n return;\n }\n if (session === undefined) {\n this.bot.ctx.logger.debug('milky: ignored event %s', event.event_type);\n return;\n }\n try {\n await this.bot.receive(session);\n }\n catch (error) {\n this.bot.ctx.logger.error('milky: event %s could not be received: %s', session.event.id ?? event.event_type, messageOf(error));\n }\n }\n /** Stop the loop for a failure that reconnecting cannot fix. */\n halt(error) {\n this.bot.ctx.logger.error('milky: %s', error.message);\n this.bot.offline(error);\n this.stopping = true;\n this.controller?.abort(error);\n this.closeSocket(1000, 'milky identity mismatch');\n }\n /** Drop every frame that has not started; the frame being handled still finishes. */\n dropQueue() {\n const count = this.queue.length;\n if (count === 0)\n return;\n this.queue = [];\n this.warnedDepth = 0;\n this.bot.ctx.logger.warn('milky: dropped %d event(s) that had not started yet', count);\n }\n /** Close the current socket, ignoring a socket that is already gone. */\n closeSocket(code, reason) {\n const socket = this.socket;\n this.socket = undefined;\n if (socket !== undefined)\n this.closeSocketOf(socket, code, reason);\n }\n /** Close one socket, ignoring a close that the transport refuses because it is already closed. */\n closeSocketOf(socket, code, reason) {\n try {\n socket.close(code, reason);\n }\n catch (error) {\n // A socket that already reported close rejects a second close; there is nothing left to release.\n this.bot.ctx.logger.debug('milky: a closed socket was closed again: %s', messageOf(error));\n }\n }\n}\n//# sourceMappingURL=ws.js.map","/**\n * The Milky adapter: an application-side client of one protocol endpoint (LLOneBot, NapCat, …).\n *\n * The endpoint is a plain HTTP server with `/api` for calls and `/event` for the event stream. This adapter is an HTTP\n * client and a WebSocket client; it never serves anything and registers no `webServer` route. Its only inbound surface\n * is the `satori:` media routes it defines for the host to fetch lazily.\n */\nimport { Adapter, PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { Config } from \"./config.js\";\nimport { classifyMilkyError, MilkyApiError, MilkyConfigError, } from \"./errors.js\";\nimport { implementsMilky1, verifyIdentity, versionWarning } from \"./identity.js\";\nimport { Internal } from \"./internal.js\";\nimport { createMilkyTextMode, } from \"./modes/text.js\";\nimport { createReaction, deleteReaction, getMessage, members } from \"./reads.js\";\nimport { createMilkyRequest, eventUrl, milkyOrigin, normalizeEndpoint, } from \"./request.js\";\nimport { deletePart, sendPayload } from \"./send.js\";\nimport { MilkyWs } from \"./ws.js\";\n/**\n * Milky adapter for one protocol endpoint.\n *\n * Identity comes from the required `selfId`, verified against `get_login_info.uin` on every connection; events arrive\n * over a reconnecting client WebSocket, while every write is an independent HTTP call.\n */\nexport class MilkyBot extends Adapter {\n /** The adapter waits for the Satori service; the Loader row isolates `http` for this adapter. */\n static inject = ['satori', 'http'];\n /** The Loader applies this schema to a profile row's `config` before the constructor runs. */\n static Config = Config;\n modes = { text: createMilkyTextMode() };\n modeOrder = ['text'];\n /** API endpoints derived from the origin of `endpoint`. */\n request;\n /** The whole Milky API surface, including the methods the DSH host does not call. */\n internal;\n endpointError;\n ws;\n /**\n * @param ctx - plugin context.\n * @param config - validated configuration; the constructor still asserts `selfId` against a config that bypassed the\n * schema, because `bot.id` must be stable before any connection.\n * @throws MilkyConfigError when `selfId` is not a QQ number.\n */\n constructor(ctx, config) {\n const selfId = String(config.selfId);\n if (!/^\\d+$/.test(selfId)) {\n throw new MilkyConfigError(`milky: selfId must be the bot QQ number (digits only), got \"${config.selfId}\"`);\n }\n const endpoint = normalizeEndpoint(config.endpoint);\n let origin = '';\n let endpointError;\n try {\n origin = milkyOrigin(endpoint);\n }\n catch (error) {\n endpointError = error instanceof Error ? error : new Error(String(error));\n }\n super(ctx, { ...config, endpoint }, { id: `milky:${selfId}`, platform: 'milky', adapter: 'milky' });\n this.selfId = selfId;\n this.request = createMilkyRequest(ctx, config.token, origin);\n this.internal = new Internal(this.request);\n this.endpointError = endpointError;\n // Inbound media becomes a `satori:` route; the host fetches it only when it needs the bytes.\n this.defineInternalRoute('/resources/:resourceId', async ({ params }) => this.serveResource(params.resourceId));\n this.defineInternalRoute('/files/:scene/:peer/:fileId', async ({ params, query }) => this.serveFile(params.scene, params.peer, params.fileId, query.get('hash')));\n }\n /**\n * Validate the endpoint and start the reconnect loop. Returns immediately: the loop dials in the background, so a\n * protocol endpoint that starts later does not hold up the plugin row.\n * @throws MilkyConfigError when `endpoint` is not an http(s) URL.\n */\n async connect() {\n if (this.endpointError !== undefined) {\n this.ctx.logger.error('milky: %s', this.endpointError.message);\n throw this.endpointError;\n }\n const ws = new MilkyWs(this);\n this.ws = ws;\n ws.start();\n }\n /** Stop the event stream and wait for the frame being handled. */\n async disconnect() {\n const ws = this.ws;\n this.ws = undefined;\n await ws?.stop();\n }\n /** Address of the event socket (`ws(s)://<origin>/event`) with the configured bearer token. */\n openEventSocket() {\n return this.ctx.http.ws(eventUrl(this.request), {\n ...(this.config.token === ''\n ? {}\n : { headers: { authorization: `Bearer ${this.config.token}` } }),\n });\n }\n /**\n * Read and verify the endpoint identity, then report an unexpected protocol version.\n * @throws MilkyIdentityError when the endpoint is logged into another account.\n * @throws MilkyApiError when `get_login_info` itself fails (a transport failure, retried by the loop).\n */\n async identify() {\n const login = await this.internal.getLoginInfo();\n if (login === undefined ||\n login === null ||\n typeof login.uin !== 'number') {\n // A 200 answer without the required field: the call ran, the receipt is incomplete.\n throw new MilkyApiError('milky: get_login_info answered without a uin', {\n api: 'get_login_info',\n httpStatus: 200,\n });\n }\n this.user = verifyIdentity(this.selfId, login);\n try {\n const info = await this.internal.getImplInfo();\n if (!implementsMilky1(info.milky_version))\n this.ctx.logger.warn('%s', versionWarning(info));\n }\n catch (error) {\n // The compatibility policy is forward-compatible, so a version read failure only costs the diagnostic.\n this.ctx.logger.warn('milky: reading the endpoint implementation failed: %s', messageOf(error));\n }\n }\n /**\n * Turn a media source into a URI the protocol endpoint can read.\n *\n * Milky has no message-media upload endpoint: image / record / video segments take a `file://`, `http(s)://` or\n * `base64://` URI and the endpoint fetches it itself. No size limit is applied here; the endpoint decides what it\n * accepts.\n *\n * @param ref - the resource placeholder produced by the mode.\n * @param _scope - cache scope from {@link resourceScope} (unused: the key is the source itself).\n * @param ctx - prepare context (byte fetch for `data:` / `satori:` sources).\n * @returns the URI to place in the segment.\n */\n async upload(ref, _scope, ctx) {\n const src = ref.src;\n if (/^https?:/i.test(src) ||\n src.startsWith('file:') ||\n src.startsWith('base64:'))\n return { key: src };\n if (/^data:/i.test(src)) {\n const base64 = /^data:[^,]*;base64,([\\s\\S]*)$/.exec(src);\n if (base64 !== null)\n return { key: `base64://${base64[1]}` };\n return await this.fetchAsBase64(src, ctx);\n }\n if (src.startsWith('satori:'))\n return await this.fetchAsBase64(src, ctx);\n throw new PlatformError('invalid', `milky: unsupported media source \"${preview(src)}\"`, { published: 'no' });\n }\n /** No platform-side resource is reused by this adapter; the scope only separates bots in the prepare cache. */\n resourceScope(_target, _kind) {\n return this.id;\n }\n /**\n * Publish one serialized payload: a segment message, or one file uploaded to the QQ file area.\n * @param payload - the payload `serialize` produced.\n * @param target - destination chat.\n * @param ctx - core send context.\n * @returns the published part.\n */\n async sendPayload(payload, target, ctx) {\n return await sendPayload({ internal: this.internal }, payload, target, ctx);\n }\n /**\n * Delete one published part: recall a message, or delete a group file.\n * @param part - the published part.\n * @param handle - the message handle (carries the target chat).\n */\n async deletePart(part, handle) {\n await deletePart({ internal: this.internal }, part, handle);\n }\n classify(error) {\n return classifyMilkyError(error);\n }\n /**\n * List the people a chat lists as its members.\n * @param chat - chat to list.\n * @param cursor - `next` of the previous page.\n * @param limit - page-size hint from the host.\n * @returns one page.\n */\n async members(chat, cursor, limit) {\n return await members(this.internal, chat, cursor, limit);\n }\n /**\n * Read one message by id, expanding a merged forward placeholder.\n * @param chat - chat the caller asks about.\n * @param id - platform message id.\n * @returns the message.\n */\n async getMessage(chat, id) {\n return await getMessage(this, chat, id);\n }\n /**\n * Add one reaction (group chats only).\n * @param message - the reacted message.\n * @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.\n */\n async createReaction(message, emoji) {\n await createReaction(this.internal, message, emoji);\n }\n /**\n * Remove one reaction (group chats only).\n * @param message - the reacted message.\n * @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.\n */\n async deleteReaction(message, emoji) {\n await deleteReaction(this.internal, message, emoji);\n }\n /** Fetch a source into a `base64://` URI, keeping the name the source reported. */\n async fetchAsBase64(src, ctx) {\n const fetched = await ctx.fetch(src, ctx.signal);\n return {\n key: `base64://${Buffer.from(fetched.data).toString('base64')}`,\n ...(fetched.name === undefined || fetched.name === ''\n ? {}\n : { extra: { name: fetched.name } }),\n };\n }\n /** Serve one `resource_id` by resolving it to a temporary URL when the host reads it. */\n async serveResource(resourceId) {\n const id = decodeURIComponentOrUndefined(resourceId);\n if (id === undefined)\n return new Response(null, { status: 400 });\n try {\n const result = await this.internal.getResourceTempUrl(id);\n const url = result?.url;\n if (typeof url !== 'string' || url === '')\n return new Response(null, { status: 502 });\n return await this.proxy(url);\n }\n catch (error) {\n // The upstream error can carry a CDN URL with its token, so only the failure class is logged.\n this.ctx.logger.warn('milky: resource %s could not be served (%s)', id, failureOf(error));\n return new Response(null, { status: 502 });\n }\n }\n /** Serve one file of the file area through `get_*_file_download_url`. */\n async serveFile(scene, peer, fileId, hash) {\n const file = decodeURIComponentOrUndefined(fileId);\n if (file === undefined)\n return new Response(null, { status: 400 });\n const peerId = Number(peer);\n if (!Number.isSafeInteger(peerId) || peerId <= 0)\n return new Response(null, { status: 400 });\n try {\n let url;\n if (scene === 'group') {\n url = (await this.internal.getGroupFileDownloadUrl(peerId, file))\n ?.download_url;\n }\n else if (scene === 'private' || scene === 'temp') {\n if (hash === null || hash === '')\n return new Response(null, { status: 400 });\n url = (await this.internal.getPrivateFileDownloadUrl(peerId, file, hash))?.download_url;\n }\n else {\n return new Response(null, { status: 400 });\n }\n if (typeof url !== 'string' || url === '')\n return new Response(null, { status: 502 });\n return await this.proxy(url);\n }\n catch (error) {\n this.ctx.logger.warn('milky: file %s could not be served (%s)', file, failureOf(error));\n return new Response(null, { status: 502 });\n }\n }\n /** Fetch an upstream URL and pass its status, body and content type through. */\n async proxy(url) {\n const response = await this.ctx.http(url, {});\n const headers = new Headers();\n const contentType = response.headers.get('content-type');\n if (contentType !== null)\n headers.set('content-type', contentType);\n return new Response(response.body, { status: response.status, headers });\n }\n}\n/** Decode one URL path parameter, or refuse a malformed escape. */\nfunction decodeURIComponentOrUndefined(value) {\n try {\n return decodeURIComponent(value);\n }\n catch (error) {\n void error;\n return undefined;\n }\n}\n/** A short, token-free description of a caught failure for a log line. */\nfunction failureOf(error) {\n if (error instanceof MilkyApiError)\n return `${error.api} failed (${error.httpStatus ?? error.retcode ?? 'no status'})`;\n return error instanceof Error ? error.name : 'unknown error';\n}\n/** Describe a caught value for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** A source shortened for a diagnostic (a data: URL can be megabytes long). */\nfunction preview(src) {\n return src.length <= 120 ? src : `${src.slice(0, 120)}…`;\n}\nexport default MilkyBot;\n//# sourceMappingURL=bot.js.map"],"mappings":";;;;;AAGA,MAAa,SAAS,EAAE,OAAO;CAC3B,UAAU,EACL,OAAO,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,KAAK,CAAC;GACtF,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;EAC7C;CACJ;;CAEA,MAAM,MAAM,KAAK;EACb,MAAM,WAAW,MAAM,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC;EAC5C,MAAM,UAAU,IAAI,QAAQ;EAC5B,MAAM,cAAc,SAAS,QAAQ,IAAI,cAAc;EACvD,IAAI,gBAAgB,MAChB,QAAQ,IAAI,gBAAgB,WAAW;EAC3C,OAAO,IAAI,SAAS,SAAS,MAAM;GAAE,QAAQ,SAAS;GAAQ;EAAQ,CAAC;CAC3E;AACJ;;AAEA,SAAS,8BAA8B,OAAO;CAC1C,IAAI;EACA,OAAO,mBAAmB,KAAK;CACnC,SACO,OAAO;EAEV;CACJ;AACJ;;AAEA,SAAS,UAAU,OAAO;CACtB,IAAI,iBAAiB,eACjB,OAAO,GAAG,MAAM,IAAI,WAAW,MAAM,cAAc,MAAM,WAAW,YAAY;CACpF,OAAO,iBAAiB,QAAQ,MAAM,OAAO;AACjD;;AAEA,SAAS,UAAU,OAAO;CACtB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAChE;;AAEA,SAAS,QAAQ,KAAK;CAClB,OAAO,IAAI,UAAU,MAAM,MAAM,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE;AAC1D"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * The Milky adapter: an application-side client of one protocol endpoint (LLOneBot, NapCat, …).
3
+ *
4
+ * The endpoint is a plain HTTP server with `/api` for calls and `/event` for the event stream. This adapter is an HTTP
5
+ * client and a WebSocket client; it never serves anything and registers no `webServer` route. Its only inbound surface
6
+ * is the `satori:` media routes it defines for the host to fetch lazily.
7
+ */
8
+ import { Adapter, PlatformError, type ChatRef, type Context, type InboundMessage, type MembersPage, type MessageHandle, type MessageRef, type Mode, type PrepareContext, type ResolvedResource, type ResourceKind, type ResourceRef, type SendContext, type SentPart, type Target, type WebSocket } from '@deepseek-ai/cordis-plugin-im-core';
9
+ import { Config } from './config.ts';
10
+ import { Internal } from './internal.ts';
11
+ import { type MilkyModeTypes } from './modes/text.ts';
12
+ import { type MilkyRequest } from './request.ts';
13
+ /** The modes this adapter always registers. */
14
+ export interface MilkyModes {
15
+ [mode: string]: Mode<MilkyModeTypes>;
16
+ text: Mode<MilkyModeTypes>;
17
+ }
18
+ /**
19
+ * Milky adapter for one protocol endpoint.
20
+ *
21
+ * Identity comes from the required `selfId`, verified against `get_login_info.uin` on every connection; events arrive
22
+ * over a reconnecting client WebSocket, while every write is an independent HTTP call.
23
+ */
24
+ export declare class MilkyBot extends Adapter<Config, MilkyModes> {
25
+ /** The adapter waits for the Satori service; the Loader row isolates `http` for this adapter. */
26
+ static inject: string[];
27
+ /** The Loader applies this schema to a profile row's `config` before the constructor runs. */
28
+ static readonly Config: import("@deepseek-ai/schemastery").default<Config>;
29
+ readonly modes: MilkyModes;
30
+ readonly modeOrder: readonly ["text"];
31
+ /** API endpoints derived from the origin of `endpoint`. */
32
+ readonly request: MilkyRequest;
33
+ /** The whole Milky API surface, including the methods the DSH host does not call. */
34
+ readonly internal: Internal;
35
+ private readonly endpointError;
36
+ private ws;
37
+ /**
38
+ * @param ctx - plugin context.
39
+ * @param config - validated configuration; the constructor still asserts `selfId` against a config that bypassed the
40
+ * schema, because `bot.id` must be stable before any connection.
41
+ * @throws MilkyConfigError when `selfId` is not a QQ number.
42
+ */
43
+ constructor(ctx: Context, config: Config);
44
+ /**
45
+ * Validate the endpoint and start the reconnect loop. Returns immediately: the loop dials in the background, so a
46
+ * protocol endpoint that starts later does not hold up the plugin row.
47
+ * @throws MilkyConfigError when `endpoint` is not an http(s) URL.
48
+ */
49
+ connect(): Promise<void>;
50
+ /** Stop the event stream and wait for the frame being handled. */
51
+ disconnect(): Promise<void>;
52
+ /** Address of the event socket (`ws(s)://<origin>/event`) with the configured bearer token. */
53
+ openEventSocket(): WebSocket;
54
+ /**
55
+ * Read and verify the endpoint identity, then report an unexpected protocol version.
56
+ * @throws MilkyIdentityError when the endpoint is logged into another account.
57
+ * @throws MilkyApiError when `get_login_info` itself fails (a transport failure, retried by the loop).
58
+ */
59
+ identify(): Promise<void>;
60
+ /**
61
+ * Turn a media source into a URI the protocol endpoint can read.
62
+ *
63
+ * Milky has no message-media upload endpoint: image / record / video segments take a `file://`, `http(s)://` or
64
+ * `base64://` URI and the endpoint fetches it itself. No size limit is applied here; the endpoint decides what it
65
+ * accepts.
66
+ *
67
+ * @param ref - the resource placeholder produced by the mode.
68
+ * @param _scope - cache scope from {@link resourceScope} (unused: the key is the source itself).
69
+ * @param ctx - prepare context (byte fetch for `data:` / `satori:` sources).
70
+ * @returns the URI to place in the segment.
71
+ */
72
+ upload(ref: ResourceRef, _scope: string, ctx: PrepareContext): Promise<ResolvedResource>;
73
+ /** No platform-side resource is reused by this adapter; the scope only separates bots in the prepare cache. */
74
+ resourceScope(_target: Target, _kind: ResourceKind): string;
75
+ /**
76
+ * Publish one serialized payload: a segment message, or one file uploaded to the QQ file area.
77
+ * @param payload - the payload `serialize` produced.
78
+ * @param target - destination chat.
79
+ * @param ctx - core send context.
80
+ * @returns the published part.
81
+ */
82
+ sendPayload(payload: unknown, target: Target, ctx: SendContext): Promise<SentPart>;
83
+ /**
84
+ * Delete one published part: recall a message, or delete a group file.
85
+ * @param part - the published part.
86
+ * @param handle - the message handle (carries the target chat).
87
+ */
88
+ deletePart(part: SentPart, handle: MessageHandle): Promise<void>;
89
+ classify(error: unknown): PlatformError;
90
+ /**
91
+ * List the people a chat lists as its members.
92
+ * @param chat - chat to list.
93
+ * @param cursor - `next` of the previous page.
94
+ * @param limit - page-size hint from the host.
95
+ * @returns one page.
96
+ */
97
+ members(chat: ChatRef, cursor?: string, limit?: number): Promise<MembersPage>;
98
+ /**
99
+ * Read one message by id, expanding a merged forward placeholder.
100
+ * @param chat - chat the caller asks about.
101
+ * @param id - platform message id.
102
+ * @returns the message.
103
+ */
104
+ getMessage(chat: ChatRef, id: string): Promise<InboundMessage>;
105
+ /**
106
+ * Add one reaction (group chats only).
107
+ * @param message - the reacted message.
108
+ * @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.
109
+ */
110
+ createReaction(message: MessageRef, emoji: string): Promise<void>;
111
+ /**
112
+ * Remove one reaction (group chats only).
113
+ * @param message - the reacted message.
114
+ * @param emoji - `<reaction_type>|<reaction_id>`, or a bare face id.
115
+ */
116
+ deleteReaction(message: MessageRef, emoji: string): Promise<void>;
117
+ /** Fetch a source into a `base64://` URI, keeping the name the source reported. */
118
+ private fetchAsBase64;
119
+ /** Serve one `resource_id` by resolving it to a temporary URL when the host reads it. */
120
+ private serveResource;
121
+ /** Serve one file of the file area through `get_*_file_download_url`. */
122
+ private serveFile;
123
+ /** Fetch an upstream URL and pass its status, body and content type through. */
124
+ private proxy;
125
+ }
126
+ export default MilkyBot;
127
+ //# sourceMappingURL=bot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/bot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,SAAS,EACf,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAOpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAEL,KAAK,cAAc,EAEpB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAA;AAIrB,+CAA+C;AAC/C,MAAM,WA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