@im-more/dsh-onebot 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 (86) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +11 -0
  3. package/lib/index.js +2003 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/bot.d.ts +55 -0
  6. package/lib/types/bot.d.ts.map +1 -0
  7. package/lib/types/bot.js +140 -0
  8. package/lib/types/bot.js.map +1 -0
  9. package/lib/types/config.d.ts +40 -0
  10. package/lib/types/config.d.ts.map +1 -0
  11. package/lib/types/config.js +33 -0
  12. package/lib/types/config.js.map +1 -0
  13. package/lib/types/cqcode.d.ts +29 -0
  14. package/lib/types/cqcode.d.ts.map +1 -0
  15. package/lib/types/cqcode.js +73 -0
  16. package/lib/types/cqcode.js.map +1 -0
  17. package/lib/types/decode.d.ts +106 -0
  18. package/lib/types/decode.d.ts.map +1 -0
  19. package/lib/types/decode.js +433 -0
  20. package/lib/types/decode.js.map +1 -0
  21. package/lib/types/errors.d.ts +32 -0
  22. package/lib/types/errors.d.ts.map +1 -0
  23. package/lib/types/errors.js +117 -0
  24. package/lib/types/errors.js.map +1 -0
  25. package/lib/types/identity.d.ts +18 -0
  26. package/lib/types/identity.d.ts.map +1 -0
  27. package/lib/types/identity.js +27 -0
  28. package/lib/types/identity.js.map +1 -0
  29. package/lib/types/index.d.ts +7 -0
  30. package/lib/types/index.d.ts.map +1 -0
  31. package/lib/types/index.js +6 -0
  32. package/lib/types/index.js.map +1 -0
  33. package/lib/types/modes/segment.d.ts +16 -0
  34. package/lib/types/modes/segment.d.ts.map +1 -0
  35. package/lib/types/modes/segment.js +80 -0
  36. package/lib/types/modes/segment.js.map +1 -0
  37. package/lib/types/modes/shared.d.ts +101 -0
  38. package/lib/types/modes/shared.d.ts.map +1 -0
  39. package/lib/types/modes/shared.js +208 -0
  40. package/lib/types/modes/shared.js.map +1 -0
  41. package/lib/types/request.d.ts +64 -0
  42. package/lib/types/request.d.ts.map +1 -0
  43. package/lib/types/request.js +108 -0
  44. package/lib/types/request.js.map +1 -0
  45. package/lib/types/send.d.ts +93 -0
  46. package/lib/types/send.d.ts.map +1 -0
  47. package/lib/types/send.js +161 -0
  48. package/lib/types/send.js.map +1 -0
  49. package/lib/types/transport/http.d.ts +29 -0
  50. package/lib/types/transport/http.d.ts.map +1 -0
  51. package/lib/types/transport/http.js +158 -0
  52. package/lib/types/transport/http.js.map +1 -0
  53. package/lib/types/transport/shared.d.ts +48 -0
  54. package/lib/types/transport/shared.d.ts.map +1 -0
  55. package/lib/types/transport/shared.js +75 -0
  56. package/lib/types/transport/shared.js.map +1 -0
  57. package/lib/types/transport/ws-reverse.d.ts +42 -0
  58. package/lib/types/transport/ws-reverse.d.ts.map +1 -0
  59. package/lib/types/transport/ws-reverse.js +178 -0
  60. package/lib/types/transport/ws-reverse.js.map +1 -0
  61. package/lib/types/transport/ws.d.ts +40 -0
  62. package/lib/types/transport/ws.d.ts.map +1 -0
  63. package/lib/types/transport/ws.js +233 -0
  64. package/lib/types/transport/ws.js.map +1 -0
  65. package/lib/types/types.d.ts +495 -0
  66. package/lib/types/types.d.ts.map +1 -0
  67. package/lib/types/types.js +191 -0
  68. package/lib/types/types.js.map +1 -0
  69. package/package.json +68 -3
  70. package/src/bot.ts +230 -0
  71. package/src/config.ts +66 -0
  72. package/src/cqcode.ts +85 -0
  73. package/src/decode.ts +524 -0
  74. package/src/errors.ts +134 -0
  75. package/src/identity.ts +34 -0
  76. package/src/index.ts +18 -0
  77. package/src/modes/segment.ts +109 -0
  78. package/src/modes/shared.ts +277 -0
  79. package/src/request.ts +128 -0
  80. package/src/send.ts +233 -0
  81. package/src/transport/http.ts +221 -0
  82. package/src/transport/shared.ts +98 -0
  83. package/src/transport/ws-reverse.ts +236 -0
  84. package/src/transport/ws.ts +286 -0
  85. package/src/types.ts +743 -0
  86. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["types/config.js","types/types.js","types/errors.js","types/modes/shared.js","types/modes/segment.js","types/cqcode.js","types/decode.js","types/send.js","types/request.js","types/transport/shared.js","types/transport/http.js","types/transport/ws-reverse.js","types/identity.js","types/transport/ws.js","types/bot.js"],"sourcesContent":["import z from '@deepseek-ai/schemastery';\n/** Validated OneBot 11 adapter configuration. */\nexport const Config = z.object({\n selfId: z.string().required(),\n token: z.string().role('secret').default(''),\n secret: z.string().role('secret').default(''),\n protocol: z.union(['http', 'ws', 'ws-reverse']).default('ws-reverse'),\n endpoint: z.string().role('url').default(''),\n path: z.string().default('/onebot'),\n ws: z\n .object({\n retryTimes: z.natural().default(6),\n retryInterval: z.natural().role('ms').default(5_000),\n retryLazy: z.natural().role('ms').default(60_000),\n responseTimeout: z.natural().role('ms').default(60_000),\n })\n .default({}),\n advanced: z\n .object({\n splitMixedContent: z.boolean().default(true),\n })\n .default({}),\n});\n/**\n * Normalize an inbound route path: absolute, no trailing slash.\n * @param path - the configured `path`.\n * @returns the pathname to register.\n */\nexport function routePath(path) {\n const withSlash = path.startsWith('/') ? path : `/${path}`;\n return withSlash.length > 1 ? withSlash.replace(/\\/+$/, '') : withSlash;\n}\n//# sourceMappingURL=config.js.map","/* eslint-disable @typescript-eslint/naming-convention */\nimport { camelize } from '@deepseek-ai/cosmokit';\nexport var SafetyLevel;\n(function (SafetyLevel) {\n SafetyLevel[SafetyLevel[\"safe\"] = 0] = \"safe\";\n SafetyLevel[SafetyLevel[\"unknown\"] = 1] = \"unknown\";\n SafetyLevel[SafetyLevel[\"danger\"] = 2] = \"danger\";\n})(SafetyLevel || (SafetyLevel = {}));\nexport class TimeoutError extends Error {\n constructor(args, url) {\n super(`Timeout with request ${url}, args: ${JSON.stringify(args)}`);\n Object.defineProperties(this, {\n args: { value: args },\n url: { value: url },\n });\n }\n}\nclass SenderError extends Error {\n constructor(args, url, retcode) {\n super(`Error with request ${url}, args: ${JSON.stringify(args)}, retcode: ${retcode}`);\n Object.defineProperties(this, {\n code: { value: retcode },\n args: { value: args },\n url: { value: url },\n });\n }\n}\nexport class Internal {\n bot;\n constructor(bot) {\n this.bot = bot;\n }\n async _get(action, params = {}) {\n this.bot.ctx.logger.debug('[request] %s %o', action, params);\n const response = await this._request(action, params);\n this.bot.ctx.logger.debug('[response] %o', response);\n const { data, retcode } = response;\n if (retcode === 0)\n return data;\n throw new SenderError(params, action, retcode);\n }\n async setGroupAnonymousBan(group_id, meta, duration) {\n const args = { group_id, duration };\n args[typeof meta === 'string' ? 'flag' : 'anonymous'] = meta;\n await this._get('set_group_anonymous_ban', args);\n }\n async setGroupAnonymousBanAsync(group_id, meta, duration) {\n const args = { group_id, duration };\n args[typeof meta === 'string' ? 'flag' : 'anonymous'] = meta;\n await this._get('set_group_anonymous_ban_async', args);\n }\n static asyncPrefixes = ['set', 'send', 'delete', 'create', 'upload', 'move', 'rename'];\n static prepareMethod(name) {\n const prop = camelize(name.replace(/^[_.]/, ''));\n const isAsync = Internal.asyncPrefixes.some(prefix => prop.startsWith(prefix));\n return [prop, isAsync];\n }\n static prepareArg(name, params, args) {\n const fixedArg = Object.fromEntries(params.map((name, index) => [name, args[index]]));\n for (const key in fixedArg) {\n if (!name.includes('guild') && key.endsWith('_id')) {\n const value = +fixedArg[key];\n if (Math.abs(value) < 4294967296) {\n fixedArg[key] = value;\n }\n }\n }\n return fixedArg;\n }\n static define(name, ...params) {\n const [prop, isAsync] = Internal.prepareMethod(name);\n Internal.prototype[prop] = async function (...args) {\n const data = await this._get(name, Internal.prepareArg(name, params, args));\n if (!isAsync)\n return data;\n };\n isAsync && (Internal.prototype[prop + 'Async'] = async function (...args) {\n await this._get(name + '_async', Internal.prepareArg(name, params, args));\n });\n }\n static defineExtract(name, key, ...params) {\n const [prop, isAsync] = Internal.prepareMethod(name);\n Internal.prototype[prop] = async function (...args) {\n const data = await this._get(name, Internal.prepareArg(name, params, args));\n return data[key];\n };\n isAsync && (Internal.prototype[prop + 'Async'] = async function (...args) {\n await this._get(name + '_async', Internal.prepareArg(name, params, args));\n });\n }\n}\n// messages\nInternal.defineExtract('send_msg', 'message_id', 'user_id', 'group_id', 'message', 'auto_escape');\nInternal.defineExtract('send_private_msg', 'message_id', 'user_id', 'message', 'auto_escape');\nInternal.defineExtract('send_group_msg', 'message_id', 'group_id', 'message', 'auto_escape');\nInternal.defineExtract('send_group_forward_msg', 'message_id', 'group_id', 'messages');\nInternal.defineExtract('send_private_forward_msg', 'message_id', 'user_id', 'messages');\nInternal.define('delete_msg', 'message_id');\nInternal.define('mark_msg_as_read', 'message_id');\nInternal.define('set_essence_msg', 'message_id');\nInternal.define('delete_essence_msg', 'message_id');\nInternal.define('send_group_sign', 'group_id');\nInternal.define('send_like', 'user_id', 'times');\nInternal.define('get_msg', 'message_id');\nInternal.define('get_essence_msg_list', 'group_id');\nInternal.define('ocr_image', 'image');\nInternal.defineExtract('get_forward_msg', 'messages', 'message_id');\nInternal.defineExtract('.get_word_slices', 'slices', 'content');\nInternal.define('get_group_msg_history', 'group_id', 'message_seq');\nInternal.defineExtract('get_friend_msg_history', 'messages', 'user_id', 'message_seq', 'count', 'reverseOrder');\nInternal.define('set_friend_add_request', 'flag', 'approve', 'remark');\nInternal.define('set_group_add_request', 'flag', 'sub_type', 'approve', 'reason');\nInternal.defineExtract('_get_model_show', 'variants', 'model');\nInternal.define('_set_model_show', 'model', 'model_show');\n// group operations\nInternal.define('set_group_kick', 'group_id', 'user_id', 'reject_add_request');\nInternal.define('set_group_ban', 'group_id', 'user_id', 'duration');\nInternal.define('set_group_whole_ban', 'group_id', 'enable');\nInternal.define('set_group_admin', 'group_id', 'user_id', 'enable');\nInternal.define('set_group_anonymous', 'group_id', 'enable');\nInternal.define('set_group_card', 'group_id', 'user_id', 'card');\nInternal.define('set_group_leave', 'group_id', 'is_dismiss');\nInternal.define('set_group_special_title', 'group_id', 'user_id', 'special_title', 'duration');\nInternal.define('set_group_name', 'group_id', 'group_name');\nInternal.define('set_group_portrait', 'group_id', 'file', 'cache');\nInternal.define('_send_group_notice', 'group_id', 'content', 'image', 'pinned', 'confirm_required');\nInternal.define('_get_group_notice', 'group_id');\nInternal.define('_del_group_notice', 'group_id', 'notice_id');\nInternal.define('get_group_at_all_remain', 'group_id');\n// accounts\nInternal.define('get_login_info');\nInternal.define('qidian_get_login_info');\nInternal.define('set_qq_profile', 'nickname', 'company', 'email', 'college', 'personal_note');\nInternal.define('set_qq_avatar', 'file');\nInternal.define('set_online_status', 'status', 'ext_status', 'battery_status');\nInternal.define('get_stranger_info', 'user_id', 'no_cache');\nInternal.define('_get_vip_info', 'user_id');\nInternal.define('get_friend_list');\nInternal.define('get_unidirectional_friend_list');\nInternal.define('delete_friend', 'user_id');\nInternal.define('delete_unidirectional_friend', 'user_id');\nInternal.define('get_group_info', 'group_id', 'no_cache');\nInternal.define('get_group_list', 'no_cache');\nInternal.define('get_group_member_info', 'group_id', 'user_id', 'no_cache');\nInternal.define('get_group_member_list', 'group_id');\nInternal.define('get_group_honor_info', 'group_id', 'type');\nInternal.define('get_group_system_msg');\nInternal.define('get_group_file_system_info', 'group_id');\nInternal.define('get_group_root_files', 'group_id');\nInternal.define('get_group_files_by_folder', 'group_id', 'folder_id');\nInternal.define('upload_private_file', 'user_id', 'file', 'name');\nInternal.define('upload_group_file', 'group_id', 'file', 'name', 'folder');\nInternal.define('create_group_file_folder', 'group_id', 'folder_id', 'name');\nInternal.define('delete_group_folder', 'group_id', 'folder_id');\nInternal.define('delete_group_file', 'group_id', 'folder_id', 'file_id', 'busid');\nInternal.defineExtract('get_group_file_url', 'url', 'group_id', 'file_id', 'busid');\nInternal.defineExtract('download_file', 'file', 'url', 'headers', 'thread_count');\nInternal.defineExtract('get_online_clients', 'clients', 'no_cache');\nInternal.defineExtract('check_url_safely', 'level', 'url');\nInternal.define('get_group_signed_list', 'group_id');\nInternal.defineExtract('get_cookies', 'cookies', 'domain');\nInternal.defineExtract('get_csrf_token', 'token');\nInternal.define('get_credentials', 'domain');\nInternal.define('get_record', 'file', 'out_format', 'full_path');\nInternal.define('get_image', 'file');\nInternal.defineExtract('can_send_image', 'yes');\nInternal.defineExtract('can_send_record', 'yes');\nInternal.define('get_status');\nInternal.define('get_version_info');\nInternal.define('set_restart', 'delay');\nInternal.define('reload_event_filter');\nInternal.define('clean_cache');\nInternal.define('get_guild_service_profile');\nInternal.define('get_guild_list');\nInternal.define('get_guild_meta_by_guest', 'guild_id');\nInternal.define('get_guild_channel_list', 'guild_id', 'no_cache');\nInternal.define('get_guild_member_list', 'guild_id', 'next_token');\nInternal.define('get_guild_member_profile', 'guild_id', 'user_id');\nInternal.defineExtract('send_guild_channel_msg', 'message_id', 'guild_id', 'channel_id', 'message');\n// lagrange\n// TODO lagrange 和 gocqhttp 接口并不一致,目前就按照参数多的来写了\nInternal.define('upload_image', 'file');\nInternal.defineExtract('get_private_file_url', 'url', 'user_id', 'file_id', 'file_hash');\nInternal.define('move_group_file', 'group_id', 'file_id', 'parent_directory', 'target_directory');\n// Internal.define('delete_group_file', 'group_id', 'file_id')\n// Internal.define('create_group_file_folder', 'group_id', 'name', 'parent_id')\nInternal.define('delete_group_file_folder', 'group_id', 'folder_id');\nInternal.define('rename_group_file_folder', 'group_id', 'folder_id', 'new_folder_name');\n// reaction\nInternal.define('set_msg_emoji_like', 'message_id', 'emoji_id', 'set');\n//# sourceMappingURL=types.js.map","import { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\nimport { TimeoutError } from \"./types.js\";\n/**\n * A failed `protocol: 'http'` API call: the status the implementation answered with, or `0` when the request never\n * produced a response.\n */\nexport class OneBotHttpError extends Error {\n status;\n constructor(message, status, options = {}) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.status = status;\n this.name = 'OneBotHttpError';\n }\n}\n/** Whether a caught value is the abort error of a cancelled request. */\nfunction isAbortError(error) {\n return ((error instanceof Error || error instanceof DOMException) &&\n error.name === 'AbortError');\n}\n/**\n * The `retcode` a failed action carries.\n *\n * The upstream `SenderError` attaches `code` with `Object.defineProperties` and is not exported, so the classifier\n * reads the field structurally. A transport failure carries a string `code` (`ECONNREFUSED`, …) and is not one.\n *\n * @param error - the caught failure.\n * @returns the numeric `retcode`, or undefined when the failure is not an action refusal.\n */\nexport function senderCodeOf(error) {\n if (typeof error !== 'object' || error === null)\n return undefined;\n const code = error.code;\n return typeof code === 'number' ? code : undefined;\n}\n/**\n * Map any OneBot failure onto the core platform taxonomy.\n *\n * A refusal the implementation answered with is certainly unpublished; transport failures, timeouts and the\n * `status: 'async'` acknowledgement leave the outcome unknown.\n *\n * @param error - the caught failure.\n * @returns the classified platform error.\n */\nexport function classifyOneBotError(error) {\n if (error instanceof PlatformError)\n return error;\n // A `DOMException` carries a numeric `code` too (20 for `AbortError`), so cancellation is recognised before the\n // retcode branch can read it as an implementation refusal.\n if (isAbortError(error))\n return new PlatformError('fatal', error instanceof Error ? error.message : 'onebot request aborted', { published: 'unknown', cause: error });\n const retcode = senderCodeOf(error);\n if (retcode !== undefined) {\n const message = error instanceof Error ? error.message : String(error);\n const init = { code: retcode, cause: error };\n // 0 never reaches the classifier (`Internal._get` returns it as success); 1 is `status: 'async'`.\n if (retcode === 1)\n return new PlatformError('retryable', message, {\n ...init,\n published: 'unknown',\n });\n if (retcode === 1401 || retcode === 1403)\n return new PlatformError('permission', message, {\n ...init,\n published: 'no',\n });\n if (retcode === 1404)\n return new PlatformError('not-found', message, {\n ...init,\n published: 'no',\n });\n if (retcode === 1400)\n return new PlatformError('invalid', message, { ...init, published: 'no' });\n // Implementation-specific codes (go-cqhttp 100/103/120/200/1500, …) have no standard meaning.\n return new PlatformError('retryable', message, {\n ...init,\n published: 'unknown',\n });\n }\n if (error instanceof OneBotHttpError) {\n const init = { cause: error };\n if (error.status === 401 || error.status === 403)\n return new PlatformError('permission', error.message, {\n ...init,\n published: 'no',\n });\n if (error.status === 404)\n return new PlatformError('not-found', error.message, {\n ...init,\n published: 'no',\n });\n if (error.status >= 500)\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n if (error.status >= 400)\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'no',\n });\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (error instanceof TimeoutError)\n return new PlatformError('retryable', error.message, {\n published: 'unknown',\n cause: error,\n });\n const message = error instanceof Error ? error.message : String(error);\n return new PlatformError('retryable', `onebot request failed: ${message}`, {\n published: 'unknown',\n cause: error,\n });\n}\n//# sourceMappingURL=errors.js.map","/** Group chat id prefix; the private prefix is the upstream one. */\nexport const GROUP_PREFIX = 'group:';\n/** Private chat id prefix, unchanged from the upstream adapter. */\nexport const PRIVATE_PREFIX = 'private:';\n/** A text segment node. */\nexport function textNode(text) {\n return { kind: 'segment', segment: { type: 'text', data: { text } } };\n}\n/** The accumulated text of a draft's last item, when it is a text segment. */\nfunction trailingText(items) {\n const last = items[items.length - 1];\n if (last === undefined || last.kind !== 'segment')\n return undefined;\n return last.segment.type === 'text' ? last.segment : undefined;\n}\n/** Drop the whitespace-only ends of a draft and the blank text segments around them. */\nfunction trimItems(input) {\n const items = [...input];\n const textAt = (index) => {\n const item = items[index];\n if (item === undefined || item.kind !== 'segment')\n return undefined;\n return item.segment.type === 'text' ? item.segment : undefined;\n };\n while (items.length > 0) {\n const first = textAt(0);\n if (first === undefined)\n break;\n const text = String(first.data.text).trimStart();\n if (text !== '') {\n first.data.text = text;\n break;\n }\n items.shift();\n }\n while (items.length > 0) {\n const last = textAt(items.length - 1);\n if (last === undefined)\n break;\n const text = String(last.data.text).trimEnd();\n if (text !== '') {\n last.data.text = text;\n break;\n }\n items.pop();\n }\n return items.length > 0 ? items : undefined;\n}\n/**\n * Fold the rendered node stream into platform messages.\n *\n * Consecutive inline nodes share one message segment array; `audio` / `video` / `file` start a new message first, as\n * the upstream encoder flushes before them. Paragraph breaks collapse into one newline so `<p>a</p><p>b</p>` becomes\n * `a\\nb`. With `splitMixedContent` a space is kept between text and an image, in both directions. The ends of every\n * message are trimmed and an all-whitespace message is dropped.\n *\n * @param nodes - rendered nodes in document order.\n * @param splitMixedContent - the `advanced.splitMixedContent` setting.\n * @returns one draft per platform message; empty when the content renders nothing.\n */\nexport function assembleDraft(nodes, splitMixedContent) {\n const drafts = [];\n let items = [];\n let pendingSpace = false;\n const flush = () => {\n const trimmed = trimItems(items);\n if (trimmed !== undefined)\n drafts.push({ kind: 'message', items: trimmed });\n items = [];\n pendingSpace = false;\n };\n const pushText = (source) => {\n let text = source;\n if (text === '')\n return;\n if (pendingSpace) {\n pendingSpace = false;\n if (!/^\\s/.test(text))\n text = ` ${text}`;\n }\n const last = trailingText(items);\n if (last === undefined) {\n items.push({ kind: 'segment', segment: { type: 'text', data: { text } } });\n return;\n }\n last.data.text = `${String(last.data.text)}${text}`;\n };\n const ensureNewline = () => {\n pendingSpace = false;\n const last = trailingText(items);\n if (last === undefined) {\n items.push({\n kind: 'segment',\n segment: { type: 'text', data: { text: '\\n' } },\n });\n return;\n }\n const text = String(last.data.text);\n if (!text.endsWith('\\n'))\n last.data.text = `${text}\\n`;\n };\n const pushMedia = (type, ref) => {\n if (splitMixedContent) {\n const last = trailingText(items);\n if (last !== undefined && !/\\s$/.test(String(last.data.text))) {\n last.data.text = `${String(last.data.text)} `;\n }\n pendingSpace = true;\n }\n items.push({ kind: 'media', type, ref });\n };\n for (const node of nodes) {\n switch (node.kind) {\n case 'newline':\n ensureNewline();\n break;\n case 'segment':\n if (node.segment.type === 'text')\n pushText(String(node.segment.data.text ?? ''));\n else\n items.push({ kind: 'segment', segment: node.segment });\n break;\n case 'media':\n if (node.type !== 'image')\n flush();\n pushMedia(node.type, node.ref);\n break;\n case 'file':\n flush();\n drafts.push({ kind: 'file', ref: node.ref, name: node.name });\n break;\n }\n }\n flush();\n return drafts;\n}\n/** The platform key `prepare` resolved for one placeholder. */\nfunction resolvedKey(prepared, ref) {\n const resolved = prepared.resolved.get(ref);\n if (resolved === undefined) {\n throw new Error('onebot: the resource was not prepared before serialize');\n }\n return resolved.key;\n}\n/**\n * Build the exact request data of one draft.\n *\n * Nothing is escaped: the array message format carries every field value literally. Only the first part answers the\n * quoted message, because a split message would otherwise repeat the quote on every part.\n *\n * @param prepared - the draft with its resources resolved.\n * @param ctx - serialize context (target chat, part index, quote).\n * @returns the request data of one platform message or file upload.\n */\nexport function serializeDraft(prepared, ctx) {\n const { draft } = prepared;\n const chat = ctx.target.chat;\n if (draft.kind === 'file') {\n return {\n kind: 'file',\n chat,\n key: resolvedKey(prepared, draft.ref),\n name: draft.name,\n };\n }\n const replyTo = ctx.index === 0 && ctx.quote !== undefined ? ctx.quote : undefined;\n const segments = replyTo === undefined ? [] : [{ type: 'reply', data: { id: replyTo } }];\n for (const item of draft.items) {\n if (item.kind === 'segment') {\n segments.push(item.segment);\n }\n else {\n segments.push({\n type: item.type,\n data: { file: resolvedKey(prepared, item.ref), cache: 0 },\n });\n }\n }\n return {\n kind: 'message',\n chat,\n segments,\n ...(replyTo === undefined ? {} : { replyTo }),\n };\n}\n/**\n * The file name of an outbound `<file>` element.\n * @param name - the element's `name` attribute, when set.\n * @param src - the element's source.\n * @returns the declared name, else the last path segment of the source, else `file`.\n */\nexport function fileName(name, src) {\n if (name !== undefined && name !== '')\n return name;\n try {\n const path = new URL(src).pathname;\n const segment = path.slice(path.lastIndexOf('/') + 1);\n if (segment !== '')\n return decodeURIComponent(segment);\n }\n catch {\n // Not a URL: the source itself is the best name available.\n if (src !== '' && !src.includes('/'))\n return src;\n }\n return 'file';\n}\n//# sourceMappingURL=shared.js.map","/**\n * `segment` mode: the OneBot 11 array message format.\n *\n * Native tags are the ones the upstream encoder produces (`text`, `p`, `br`, `at`, `emoji`, `channel`, `a`, `img`,\n * `audio`, `video`, `file`); everything else takes the core fallback, which keeps its text. There is no second mode:\n * the platform has no other way to render a message.\n */\nimport { ElementRegistry } from '@deepseek-ai/cordis-plugin-im-core';\nimport { assembleDraft, fileName, serializeDraft, textNode, } from \"./shared.js\";\n/**\n * Build the `segment` mode.\n * @param splitMixedContent - pad a space around mixed text and images (`advanced.splitMixedContent`).\n * @returns the only mode of this adapter.\n */\nexport function createSegmentMode(splitMixedContent) {\n const elements = new ElementRegistry()\n .register('text', (el) => textNode(el.attrs.content))\n // A paragraph opens and closes a line; `assemble` collapses consecutive newlines.\n .register('p', (el, ctx) => [\n { kind: 'newline' },\n ...ctx.render(el.children),\n { kind: 'newline' },\n ])\n .register('br', () => ({ kind: 'newline' }))\n .register('at', (el) => el.attrs.type === 'all'\n ? { kind: 'segment', segment: { type: 'at', data: { qq: 'all' } } }\n : {\n kind: 'segment',\n segment: {\n type: 'at',\n data: {\n qq: el.attrs.id ?? '',\n ...(el.attrs.name === undefined\n ? {}\n : { name: el.attrs.name }),\n },\n },\n }, { variants: ['user', 'all'] })\n // A QQ face is a numeric id; any other emoji has no segment and stays its name.\n .register('emoji', (el) => /^\\d+$/.test(el.attrs.id)\n ? {\n kind: 'segment',\n segment: { type: 'face', data: { id: el.attrs.id } },\n }\n : textNode(el.attrs.name ?? ''))\n .register('channel', (el) => textNode(el.attrs.id))\n .register('a', (el, ctx) => [\n ...ctx.render(el.children),\n // OneBot clients do not render links, so the URL has to be visible (upstream issue #23).\n textNode(`(${el.attrs.href})`),\n ])\n .register('img', (el, ctx) => ({\n kind: 'media',\n type: 'image',\n ref: ctx.resource('image', el.attrs.src, {}),\n }), { variants: ['inline'] })\n .register('audio', (el, ctx) => ({\n kind: 'media',\n type: 'record',\n ref: ctx.resource('audio', el.attrs.src, {}),\n }))\n .register('video', (el, ctx) => ({\n kind: 'media',\n type: 'video',\n ref: ctx.resource('video', el.attrs.src, {}),\n }))\n .register('file', (el, ctx) => ({\n kind: 'file',\n name: fileName(el.attrs.name, el.attrs.src),\n ref: ctx.resource('file', el.attrs.src, el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n }));\n return {\n id: 'segment',\n elements,\n limits: {},\n assemble: (nodes) => assembleDraft(nodes, splitMixedContent),\n serialize: (prepared, ctx) => serializeDraft(prepared, ctx),\n };\n}\n//# sourceMappingURL=segment.js.map","/** Segment types are `\\w+` in CQ code; anything else is literal text. */\nconst TYPE = /^[A-Za-z0-9_.-]+$/;\n/**\n * Undo the CQ code escapes of text outside segments and of one parameter value.\n * @param source - escaped text.\n * @returns the text with `&#91;`, `&#93;`, `&#44;` and `&amp;` restored.\n */\nexport function unescapeCQ(source) {\n return source\n .replaceAll('&#91;', '[')\n .replaceAll('&#93;', ']')\n .replaceAll('&#44;', ',')\n .replaceAll('&amp;', '&');\n}\n/** Parse the parameter list after `[CQ:type`; a value may itself contain `=`. */\nfunction parseParams(body) {\n const data = {};\n if (body === '')\n return data;\n for (const pair of body.split(',')) {\n const equals = pair.indexOf('=');\n if (equals <= 0)\n continue;\n data[pair.slice(0, equals)] = unescapeCQ(pair.slice(equals + 1));\n }\n return data;\n}\n/**\n * Parse a string-format (CQ code) message into segments.\n *\n * Text outside segments becomes a `text` segment with its escapes undone. A `[CQ:` that does not open a well-formed\n * segment stays literal text. Only the first `]` closes a segment: `]` inside a value is escaped as `&#93;`.\n *\n * @param source - the raw `message` string (or `raw_message`).\n * @returns the segments in order; empty for an empty input.\n */\nexport function parseCqCode(source) {\n const segments = [];\n let cursor = 0;\n let search = 0;\n const flushText = (end) => {\n if (end <= cursor)\n return;\n const text = unescapeCQ(source.slice(cursor, end));\n if (text !== '')\n segments.push({ type: 'text', data: { text } });\n };\n while (search < source.length) {\n const start = source.indexOf('[CQ:', search);\n if (start < 0)\n break;\n const end = source.indexOf(']', start + 4);\n if (end < 0)\n break;\n const body = source.slice(start + 4, end);\n const comma = body.indexOf(',');\n const type = comma < 0 ? body : body.slice(0, comma);\n if (!TYPE.test(type)) {\n search = start + 4;\n continue;\n }\n flushText(start);\n segments.push({\n type,\n data: parseParams(comma < 0 ? '' : body.slice(comma + 1)),\n });\n cursor = end + 1;\n search = cursor;\n }\n flushText(source.length);\n return segments;\n}\n//# sourceMappingURL=cqcode.js.map","/**\n * Inbound decoding: one OneBot 11 event becomes an intake `Session`.\n *\n * Message events and the two recall notices are decoded; every other `post_type` is ignored. Segment content keeps\n * its text: a segment the vocabulary cannot express becomes a readable placeholder instead of disappearing, and an\n * event that carries no segment at all becomes an inbound `<raw>` element, because `InboundMessage.content` may not\n * be empty.\n */\nimport { h, normalize, PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { parseCqCode } from \"./cqcode.js\";\nimport { GROUP_PREFIX, PRIVATE_PREFIX } from \"./modes/shared.js\";\n/** Text of a segment that has no element of its own. */\nfunction placeholderOf(type, data) {\n switch (type) {\n case 'poke':\n return '[戳一戳]';\n case 'rps':\n return '[猜拳]';\n case 'dice':\n return '[骰子]';\n case 'shake':\n return '[抖动]';\n case 'anonymous':\n return '[匿名消息]';\n case 'contact':\n return '[名片]';\n case 'music':\n return '[音乐]';\n case 'tts':\n return '[语音]';\n case 'mface':\n return '[表情]';\n case 'markdown':\n return '[Markdown]';\n case 'keyboard':\n return '[按钮]';\n case 'node':\n return '[合并转发节点]';\n case 'location':\n return `[位置 ${data.lat ?? '?'},${data.lon ?? '?'}]`;\n default:\n return undefined;\n }\n}\n/** The title of a JSON/XML card, when it carries one; the card body itself is not printed. */\nfunction cardTitle(source) {\n let parsed;\n try {\n parsed = JSON.parse(source);\n }\n catch (error) {\n // Not JSON: an XML card or a malformed payload, nothing to extract.\n void error;\n return undefined;\n }\n if (typeof parsed !== 'object' || parsed === null)\n return undefined;\n const meta = parsed.meta;\n if (typeof meta === 'object' && meta !== null) {\n const detail = meta.detail_1;\n if (typeof detail === 'object' && detail !== null) {\n const title = detail.title;\n if (typeof title === 'string' && title !== '')\n return title;\n }\n }\n const prompt = parsed.prompt;\n if (typeof prompt === 'string' && prompt !== '')\n return prompt;\n return undefined;\n}\n/**\n * Validate one wire segment list.\n *\n * The array message format is JSON from another process, so every field is checked: a segment without a string `type`\n * is dropped, and parameter values are kept only when they are strings or numbers.\n *\n * @param value - a `message` field or a forwarded node's `content`.\n * @returns the segments that can be decoded.\n */\nexport function normalizeSegments(value) {\n if (typeof value === 'string')\n return parseCqCode(value);\n if (!Array.isArray(value))\n return [];\n const segments = [];\n for (const item of value) {\n if (typeof item !== 'object' || item === null)\n continue;\n const type = item.type;\n if (typeof type !== 'string' || type === '')\n continue;\n const source = item.data;\n const data = {};\n if (typeof source === 'object' && source !== null) {\n for (const [key, entry] of Object.entries(source)) {\n if (typeof entry === 'string')\n data[key] = entry;\n else if (typeof entry === 'number')\n data[key] = String(entry);\n }\n }\n segments.push({ type, data });\n }\n return segments;\n}\n/** The segments of one message: the `message` field by value, else the CQ string in `raw_message`. */\nfunction segmentsOf(data) {\n if (data.message !== undefined && data.message !== null) {\n const segments = normalizeSegments(data.message);\n if (segments.length > 0)\n return segments;\n }\n return typeof data.raw_message === 'string'\n ? parseCqCode(data.raw_message)\n : [];\n}\n/**\n * Decode one message's segments into the element vocabulary.\n *\n * @param bot - the receiving adapter (its `selfId` decides `mentions.self`).\n * @param segments - validated segments.\n * @returns the content nodes, the quoted message id and the mentions.\n */\nexport function decodeSegments(bot, segments) {\n const nodes = [];\n const mentions = {\n self: false,\n all: false,\n users: [],\n };\n let quote;\n for (const segment of segments) {\n const data = segment.data;\n switch (segment.type) {\n case 'text':\n nodes.push(h.text(data.text ?? ''));\n break;\n case 'face':\n nodes.push(h('emoji', {\n id: data.id ?? '',\n ...(data.name === undefined ? {} : { name: data.name }),\n }));\n break;\n case 'image':\n // The implementation's `url` or `file` is the source as-is; a bare file name is left for the host to skip.\n nodes.push(h('img', { src: data.url || data.file || '' }));\n if (data.type === 'flash')\n nodes.push(h.text('[闪照]'));\n break;\n case 'record':\n nodes.push(h('audio', { src: data.url || data.file || '' }));\n break;\n case 'video':\n nodes.push(h('video', { src: data.url || data.file || '' }));\n break;\n case 'file':\n nodes.push(h('file', {\n src: data.url || data.file || '',\n ...(data.name === undefined ? {} : { name: data.name }),\n }));\n break;\n case 'at': {\n const qq = data.qq ?? '';\n if (qq === 'all') {\n mentions.all = true;\n nodes.push(h('at', { type: 'all' }));\n break;\n }\n mentions.users.push({\n id: qq,\n ...(data.name === undefined ? {} : { name: data.name }),\n });\n if (qq === bot.selfId)\n mentions.self = true;\n nodes.push(h('at', {\n type: 'user',\n id: qq,\n ...(data.name === undefined ? {} : { name: data.name }),\n }));\n break;\n }\n case 'reply':\n // The quoted message is an id only; the host formats the reply from what it stored.\n quote = data.id ?? '';\n break;\n case 'forward':\n nodes.push(h('forward', { id: data.id ?? '' }));\n break;\n case 'share':\n nodes.push(h('a', { href: data.url ?? '' }, data.title ?? ''));\n break;\n case 'json':\n case 'xml': {\n const title = cardTitle(data.data ?? '');\n nodes.push(h.text(title === undefined ? '[卡片]' : `[卡片] ${title}`));\n break;\n }\n default: {\n const placeholder = placeholderOf(segment.type, data);\n if (placeholder !== undefined) {\n nodes.push(h.text(placeholder));\n break;\n }\n const text = data.text;\n nodes.push(h.text(text !== undefined && text !== '' ? text : `[${segment.type}]`));\n break;\n }\n }\n }\n return { nodes, quote, mentions };\n}\n/** A bounded description of an event that decoded to no content, so `<raw>` stays small. */\nfunction rawPreview(data) {\n const preview = {};\n for (const key of [\n 'post_type',\n 'message_type',\n 'notice_type',\n 'sub_type',\n 'message_id',\n 'group_id',\n 'user_id',\n ]) {\n const value = data[key];\n if (value !== undefined)\n preview[key] = String(value);\n }\n return preview;\n}\n/** The chat a message was sent in. */\nexport function chatOfMessage(data) {\n if (data.message_type === 'group' ||\n (data.message_type === undefined && data.group_id !== undefined)) {\n return { id: `${GROUP_PREFIX}${data.group_id ?? 0}`, type: 'group' };\n }\n const userId = data.sender?.user_id ?? data.user_id ?? data.target_id ?? 0;\n return { id: `${PRIVATE_PREFIX}${userId}`, type: 'direct' };\n}\n/** The sender of one message; an anonymous group message has no usable sender, so its anonymous id stands in. */\nfunction senderOf(data) {\n if (data.anonymous !== undefined) {\n return { id: String(data.anonymous.id), name: '匿名用户' };\n }\n const sender = data.sender ?? {};\n const name = sender.card || sender.nickname;\n return {\n id: String(sender.user_id ?? data.user_id ?? 0),\n ...(name === undefined || name === '' ? {} : { name }),\n ...(sender.role === undefined ? {} : { role: sender.role }),\n };\n}\n/**\n * Decode one message payload.\n * @param bot - the receiving adapter.\n * @param data - a message event, or a `get_msg` answer.\n * @param chat - the chat to report; a `get_msg` answer carries no group id, so the caller passes its own.\n * @returns the inbound message.\n */\nexport function decodeMessage(bot, data, chat = chatOfMessage(data)) {\n const parts = decodeSegments(bot, segmentsOf(data));\n const id = String(data.message_id ?? 0);\n const time = (data.time ?? Math.floor(Date.now() / 1_000)) * 1_000;\n const content = normalize(parts.nodes.length > 0\n ? parts.nodes\n : [\n h('raw', {\n platform: 'onebot',\n type: data.post_type ?? 'message',\n data: rawPreview(data),\n }, h.text('')),\n ]);\n const realId = data.real_id;\n return {\n id,\n ...(realId === undefined || String(realId) === id\n ? {}\n : { aliases: [String(realId)] }),\n chat,\n sender: senderOf(data),\n content,\n ...(parts.quote === undefined ? {} : { quote: { id: parts.quote } }),\n mentions: parts.mentions,\n time,\n referrer: { chatId: chat.id, messageId: id, time },\n raw: data,\n };\n}\n/** One `notice` that reports a recalled message. */\nfunction deletedSession(bot, data) {\n const group = data.notice_type === 'group_recall';\n const chat = group\n ? { id: `${GROUP_PREFIX}${data.group_id ?? 0}`, type: 'group' }\n : {\n id: `${PRIVATE_PREFIX}${data.user_id ?? data.target_id ?? 0}`,\n type: 'direct',\n };\n const time = (data.time ?? Math.floor(Date.now() / 1_000)) * 1_000;\n return bot.session({\n type: 'message-deleted',\n id: `notice:${data.notice_type}:${data.time}:${data.message_id}`,\n timestamp: time,\n deleted: {\n id: String(data.message_id),\n chat,\n ...(data.operator_id === undefined\n ? {}\n : { operator: { id: String(data.operator_id) } }),\n },\n raw: data,\n });\n}\n/**\n * Decode one platform event.\n *\n * The event id is synthesized because OneBot events carry none, and the host dedupes on it: `message_id` alone would\n * collide with the ids some implementations restart from zero.\n *\n * @param bot - the receiving adapter.\n * @param data - the event payload.\n * @returns the session to publish, or undefined for an ignored event.\n */\nexport function decodePayload(bot, data) {\n if (data.post_type === 'message') {\n if (data.message_type !== 'private' && data.message_type !== 'group') {\n return undefined;\n }\n const message = decodeMessage(bot, data);\n return bot.session({\n type: 'message',\n id: `message:${data.message_id}:${data.time}`,\n timestamp: message.time,\n message,\n raw: data,\n });\n }\n if (data.post_type === 'notice') {\n if (data.notice_type === 'group_recall' ||\n data.notice_type === 'friend_recall') {\n return deletedSession(bot, data);\n }\n }\n return undefined;\n}\n/**\n * Whether a parsed frame is one platform event.\n * @param value - a parsed JSON frame from the implementation.\n * @returns whether it is an event rather than an action answer.\n */\nexport function isPayload(value) {\n if (typeof value !== 'object' || value === null)\n return false;\n return typeof value.post_type === 'string';\n}\n/** Read the node list of a `get_forward_msg` answer; the standard calls it `message`, go-cqhttp `messages`. */\nfunction forwardNodesOf(source) {\n if (typeof source !== 'object' || source === null)\n return [];\n const record = source;\n const list = Array.isArray(record.messages)\n ? record.messages\n : Array.isArray(record.message)\n ? record.message\n : [];\n const nodes = [];\n for (const entry of list) {\n if (typeof entry !== 'object' || entry === null)\n continue;\n if (entry.type !== 'node')\n continue;\n const data = entry.data;\n if (typeof data !== 'object' || data === null)\n continue;\n const fields = data;\n const nickname = typeof fields.nickname === 'string'\n ? fields.nickname\n : typeof fields.name === 'string'\n ? fields.name\n : '';\n nodes.push({ nickname, content: fields.content });\n }\n return nodes;\n}\n/** Collect the empty `forward` placeholders of a decoded message. */\nfunction collectForwards(content) {\n const found = [];\n const walk = (element) => {\n if (element.type === 'forward') {\n if (element.children.length === 0)\n found.push(element);\n return;\n }\n for (const child of element.children)\n walk(child);\n };\n walk(content);\n return found;\n}\n/**\n * Expand the merged forwards of one message into phrasing content, as the host's `im_read` expects.\n *\n * One forwarded node renders as its author in bold, a colon, the node content and a line break. The content model of\n * `<forward>` is phrasing, so no block element may be inserted.\n *\n * @param bot - the adapter, used for the `get_forward_msg` call.\n * @param message - the decoded message.\n * @returns the same message with every `forward` element expanded.\n */\nexport async function expandForward(bot, message) {\n const forwards = collectForwards(message.content);\n if (forwards.length === 0)\n return message;\n const request = bot.internal._request;\n if (request === undefined) {\n throw new PlatformError('retryable', 'onebot: cannot read the forwarded message while the transport is not connected', { published: 'unknown' });\n }\n for (const element of forwards) {\n const response = await request('get_forward_msg', {\n message_id: element.attrs.id,\n });\n if (response.retcode !== 0)\n continue;\n const children = [];\n for (const node of forwardNodesOf(response.data)) {\n children.push(h('b', {}, h.text(node.nickname)), h.text(': '));\n children.push(...decodeSegments(bot, normalizeSegments(node.content)).nodes);\n children.push(h('br'));\n }\n element.children = children;\n }\n return message;\n}\n//# sourceMappingURL=decode.js.map","/**\n * Outbound hooks: the send pipeline's payload, deletion, member reads, message reads and reactions.\n *\n * Requests go through the migrated `Internal` surface, so the action names and parameter order are the upstream ones.\n * Images, records and videos travel as the source string itself; a `<file>` becomes `download_file` plus\n * `upload_group_file` / `upload_private_file`, because those actions accept only a path on the implementation's host.\n */\nimport { PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { randomUUID } from 'node:crypto';\nimport { fileURLToPath } from 'node:url';\nimport { decodeMessage, expandForward } from \"./decode.js\";\nimport { GROUP_PREFIX, PRIVATE_PREFIX, } from \"./modes/shared.js\";\n/**\n * Split a DSH chat id into the OneBot action family and the platform id.\n * @param chat - the target chat.\n * @returns kind and raw id.\n * @throws PlatformError `invalid` for a chat id this adapter did not produce.\n */\nexport function chatTarget(chat) {\n if (chat.id.startsWith(GROUP_PREFIX)) {\n return { kind: 'group', id: chat.id.slice(GROUP_PREFIX.length) };\n }\n if (chat.id.startsWith(PRIVATE_PREFIX)) {\n return { kind: 'private', id: chat.id.slice(PRIVATE_PREFIX.length) };\n }\n throw new PlatformError('invalid', `onebot: chat id \"${chat.id}\" must start with \"group:\" or \"private:\"`);\n}\n/** Data URI prefix of an inline image; the implementation wants the `base64://` form instead. */\nconst DATA_URL = /^data:([\\w/.+-]+);base64,/;\n/**\n * Normalize one media source without fetching it.\n *\n * A `data:` URI becomes the `base64://` form the implementation decodes; every other source (an `http(s)` URL, a\n * `base64://` payload, a path) is passed through unchanged, because the implementation fetches it itself.\n *\n * @param src - the element's source.\n * @returns the string to put in the segment's `file` field.\n */\nexport function normalizeSource(src) {\n const match = DATA_URL.exec(src);\n return match === null ? src : `base64://${src.slice(match[0].length)}`;\n}\n/**\n * Send one serialized payload.\n * @param deps - the action client.\n * @param payload - the mode's request data.\n * @param target - the target chat.\n * @param ctx - part index, quote and options.\n * @returns the published part.\n */\nexport async function sendPayload(deps, payload, _target, _ctx) {\n if (payload.kind === 'file') {\n const chat = chatTarget(payload.chat);\n if (chat.kind === 'group') {\n await deps.internal.uploadGroupFile(chat.id, payload.key, payload.name);\n }\n else {\n await deps.internal.uploadPrivateFile(chat.id, payload.key, payload.name);\n }\n // Neither action answers with a message id, so the part carries a synthesized one the platform cannot address.\n const id = `onebot-file:${randomUUID()}`;\n return {\n id,\n kind: 'file',\n time: Date.now(),\n referrer: { chatId: payload.chat.id, messageId: id },\n };\n }\n const chat = chatTarget(payload.chat);\n const segments = payload.segments;\n const sent = chat.kind === 'group'\n ? await deps.internal.sendGroupMsg(chat.id, segments)\n : await deps.internal.sendPrivateMsg(chat.id, segments);\n const messageId = sent;\n if (messageId === undefined) {\n // The request reached the implementation, so the outcome is unknown rather than unpublished.\n throw new PlatformError('invalid', 'onebot: the implementation answered a send without message_id', { published: 'unknown' });\n }\n const id = String(messageId);\n return {\n id,\n kind: 'message',\n time: Date.now(),\n referrer: { chatId: payload.chat.id, messageId: id },\n };\n}\n/**\n * Recall one published part.\n *\n * A file part carries a synthesized id that no platform message answers, so it is skipped instead of recalling an\n * unrelated message.\n *\n * @param deps - the action client.\n * @param part - the part to recall.\n */\nexport async function deletePart(deps, part) {\n if (part.kind === 'file')\n return;\n await deps.internal.deleteMsg(part.id);\n}\n/**\n * List the members of one group.\n * @param deps - the action client.\n * @param chat - the group chat.\n * @returns the whole member list; the standard offers no paging.\n */\nexport async function members(deps, chat) {\n const target = chatTarget(chat);\n if (target.kind !== 'group') {\n throw new PlatformError('invalid', 'onebot: members() is only available in a group chat');\n }\n const list = await deps.internal.getGroupMemberList(target.id);\n const data = list.map((member) => {\n const name = member.card || member.nickname;\n return {\n id: String(member.user_id),\n ...(name === '' ? {} : { name }),\n ...(member.role === undefined ? {} : { role: member.role }),\n };\n });\n return { data };\n}\n/**\n * Read one message, expanding any merged forward it carries.\n * @param deps - the action client.\n * @param bot - the adapter, needed by the forward expansion.\n * @param chat - the chat the caller asked about; the answer carries no chat, so it is reused verbatim.\n * @param id - platform message id.\n * @returns the decoded message, with the same `chat.id` the caller passed.\n */\nexport async function getMessage(deps, bot, chat, id) {\n const data = await deps.internal.getMsg(id);\n return expandForward(bot, decodeMessage(bot, data, chat));\n}\n/**\n * Add one reaction to a published message.\n * @param deps - the action client.\n * @param message - the message to react to.\n * @param emoji - platform emoji id.\n */\nexport async function createReaction(deps, message, emoji) {\n await deps.internal.setMsgEmojiLike(message.id, emoji, true);\n}\n/**\n * Remove one reaction from a published message.\n * @param deps - the action client.\n * @param message - the message to react to.\n * @param emoji - platform emoji id.\n */\nexport async function deleteReaction(deps, message, emoji) {\n await deps.internal.setMsgEmojiLike(message.id, emoji, false);\n}\n/**\n * Convert a `file:` source into the local path an upload action accepts.\n * @param src - a `file:` URI.\n * @returns the filesystem path.\n */\nexport function localPathOf(src) {\n return fileURLToPath(src);\n}\n//# sourceMappingURL=send.js.map","import { TimeoutError } from \"./types.js\";\n/**\n * Action calls over one WebSocket connection.\n *\n * The implementation answers an action with the envelope it was sent, in `echo`; the pending table is per connection\n * so a reconnect can never deliver an answer to the previous socket. A request that is not answered within\n * `ws.responseTimeout` is rejected with the upstream `TimeoutError` and forgotten, and closing the connection rejects\n * everything still waiting.\n */\nexport class ActionRequests {\n send;\n timeoutMs;\n echo = 0;\n pending = new Map();\n closed;\n constructor(send, timeoutMs) {\n this.send = send;\n this.timeoutMs = timeoutMs;\n }\n /**\n * Send one action and wait for its answer.\n * @param action - OneBot 11 action name (`send_group_msg`, …).\n * @param params - action parameters.\n * @returns the answer envelope (the caller reads `retcode` / `data`).\n */\n request = (action, params) => {\n if (this.closed !== undefined)\n return Promise.reject(this.closed);\n const echo = ++this.echo;\n const frame = { action, params, echo };\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n this.pending.delete(echo);\n reject(new TimeoutError(params, action));\n }, this.timeoutMs);\n this.pending.set(echo, { resolve, reject, timer });\n try {\n this.send(frame);\n }\n catch (error) {\n this.settle(echo, error);\n }\n });\n };\n /**\n * Deliver one answer to its waiting call.\n * @param response - the parsed frame.\n * @returns whether an outstanding call was waiting for it.\n */\n resolve(response) {\n if (typeof response.echo !== 'number')\n return false;\n const pending = this.pending.get(response.echo);\n if (pending === undefined)\n return false;\n this.pending.delete(response.echo);\n clearTimeout(pending.timer);\n pending.resolve(response);\n return true;\n }\n /**\n * Refuse every waiting call; calls made afterwards fail immediately.\n * @param error - the failure to reject with.\n */\n rejectAll(error) {\n this.closed = error;\n for (const [echo, pending] of this.pending) {\n this.pending.delete(echo);\n clearTimeout(pending.timer);\n pending.reject(error);\n }\n }\n settle(echo, error) {\n const pending = this.pending.get(echo);\n if (pending === undefined)\n return;\n this.pending.delete(echo);\n clearTimeout(pending.timer);\n pending.reject(error instanceof Error ? error : new Error(String(error)));\n }\n}\n/**\n * Make a connection's `request` the bot's action entry point (`bot.internal._request`).\n * @param bot - the adapter instance.\n * @param request - action caller of the live connection.\n */\nexport function installRequest(bot, request) {\n bot.internal._request = request;\n}\n/**\n * Make every action call of the bot fail without a connection.\n * @param bot - the adapter instance.\n * @param error - the failure calls report.\n */\nexport function rejectRequests(bot, error) {\n bot.internal._request = () => Promise.reject(error);\n}\n/**\n * Whether a parsed frame is one action answer.\n * @param value - a parsed JSON frame from the implementation.\n * @returns whether it carries an `echo`.\n */\nexport function isResponse(value) {\n if (typeof value !== 'object' || value === null)\n return false;\n return typeof value.echo === 'number';\n}\n//# sourceMappingURL=request.js.map","import { createHmac, timingSafeEqual } from 'node:crypto';\n/**\n * Compare a received credential with the configured one without leaking its length through early exits.\n * @param expected - the configured secret or token.\n * @param received - the presented value, when one was sent.\n * @returns whether they are equal.\n */\nexport function matchesSecret(expected, received) {\n if (received === undefined)\n return false;\n const left = Buffer.from(expected, 'utf8');\n const right = Buffer.from(received, 'utf8');\n if (left.length !== right.length)\n return false;\n return timingSafeEqual(left, right);\n}\n/**\n * One header of an inbound request, when it arrived exactly once.\n * @param request - the inbound request.\n * @param name - lower-case header name.\n * @returns the header value, or undefined when absent or repeated.\n */\nexport function headerOf(request, name) {\n const value = request.headers[name];\n return typeof value === 'string' ? value : undefined;\n}\n/**\n * Read a request body to its end. The adapter imposes no size limit, as the upstream plugin does not.\n * @param request - the inbound request.\n * @returns the decoded body.\n */\nexport async function readBody(request) {\n const chunks = [];\n for await (const chunk of request) {\n chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));\n }\n return Buffer.concat(chunks).toString('utf8');\n}\n/**\n * Answer an inbound request with an empty response.\n * @param response - the server response.\n * @param status - HTTP status code.\n * @param headers - extra response headers.\n */\nexport function writeStatus(response, status, headers = {}) {\n response.writeHead(status, headers);\n response.end();\n}\n/**\n * Refuse an HTTP upgrade that the adapter does not accept, before handing the socket to a WebSocket server.\n * @param socket - the raw connection.\n * @param status - HTTP status code.\n * @param reason - reason phrase.\n */\nexport function rejectUpgrade(socket, status, reason) {\n socket.write(`HTTP/1.1 ${status} ${reason}\\r\\nConnection: close\\r\\nContent-Length: 0\\r\\n\\r\\n`);\n socket.destroy();\n}\n/**\n * The `X-Signature` value of one event report.\n *\n * The upstream plugin signs the re-serialized parsed body rather than the raw bytes; this keeps that behaviour because\n * it is what implementations in the field have been verifying against for years.\n *\n * @param secret - the configured `secret`.\n * @param body - the parsed event payload.\n * @returns `sha1=<hex digest>`.\n */\nexport function signatureOf(secret, body) {\n const digest = createHmac('sha1', secret)\n .update(JSON.stringify(body))\n .digest('hex');\n return `sha1=${digest}`;\n}\n//# sourceMappingURL=shared.js.map","/**\n * HTTP transport (`protocol: 'http'`): an outbound `POST {endpoint}/{action}` client and an inbound event route.\n *\n * Both directions run at once, as in the upstream plugin. The outbound call authenticates with the standard\n * `Authorization: Bearer` header; the inbound route checks `X-Signature` (HMAC-SHA1 over the re-serialized parsed body,\n * the upstream behaviour implementations in the field verify) and `X-Self-ID`, and answers `204` only after the host\n * accepted the event.\n */\nimport { routePath } from \"../config.js\";\nimport { decodePayload } from \"../decode.js\";\nimport { OneBotHttpError } from \"../errors.js\";\nimport { installRequest } from \"../request.js\";\nimport { headerOf, matchesSecret, readBody, signatureOf, writeStatus, } from \"./shared.js\";\n/** The HTTP service's failure carries the response it refused; recover it structurally. */\nfunction responseOf(cause) {\n if (typeof cause !== 'object' || cause === null || !('response' in cause))\n return undefined;\n const response = cause.response;\n return response instanceof Response ? response : undefined;\n}\n/** The HTTP transport of one bot. */\nexport class OneBotHttp {\n bot;\n dispose;\n warnedNoSecret = false;\n constructor(bot) {\n this.bot = bot;\n }\n /**\n * Claim the event route and install the action caller.\n */\n async start() {\n const webServer = this.bot.ctx.get('webServer');\n if (webServer === undefined) {\n throw this.fail('onebot: protocol \"http\" needs a profile-provided webServer to receive event reports');\n }\n const path = routePath(this.bot.config.path);\n try {\n this.dispose = webServer.register({\n kind: 'exact',\n path,\n auth: 'anonymous',\n handler: (request, response) => this.handle(request, response),\n });\n }\n catch (error) {\n throw this.fail(`onebot: cannot claim the http event route ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n const endpoint = this.bot.config.endpoint;\n installRequest(this.bot, (action, params) => this.call(endpoint, action, params));\n this.bot.user = {\n id: this.bot.config.selfId,\n name: this.bot.config.selfId,\n isBot: true,\n };\n this.bot.online();\n }\n /** Release the event route. */\n async stop() {\n this.dispose?.();\n this.dispose = undefined;\n }\n /** Log a start failure before throwing it, because `Bot.start` only stores a connect failure on `bot.error`. */\n fail(message) {\n this.bot.ctx.logger.error(message);\n return new Error(message);\n }\n /** One action call against `{endpoint}/{action}`. */\n async call(endpoint, action, params) {\n const url = `${endpoint.replace(/\\/+$/, '')}/${action}`;\n const { token } = this.bot.config;\n let response;\n try {\n response = await this.bot.ctx.http(url, {\n method: 'POST',\n data: params,\n ...(token === ''\n ? {}\n : { headers: { Authorization: `Bearer ${token}` } }),\n });\n }\n catch (cause) {\n const refused = responseOf(cause);\n if (refused !== undefined) {\n const body = await refused.text().catch(() => '');\n throw new OneBotHttpError(`onebot: ${action} was refused with HTTP ${refused.status}${body === '' ? '' : `: ${body.slice(0, 200)}`}`, refused.status, { cause });\n }\n throw new OneBotHttpError(`onebot: ${action} request failed: ${cause instanceof Error ? cause.message : String(cause)}`, 0, { cause });\n }\n let body;\n try {\n body = await response.json();\n }\n catch (cause) {\n throw new OneBotHttpError(`onebot: ${action} answered with a body that is not JSON`, response.status, { cause });\n }\n if (typeof body !== 'object' || body === null) {\n throw new OneBotHttpError(`onebot: ${action} answered with a body that is not an action envelope`, response.status);\n }\n return body;\n }\n /** Check and deliver one event report. */\n async handle(request, response) {\n try {\n if (request.method !== 'POST') {\n writeStatus(response, 405, { allow: 'POST' });\n return;\n }\n const { secret } = this.bot.config;\n const signature = headerOf(request, 'x-signature');\n if (secret === '') {\n if (!this.warnedNoSecret) {\n this.warnedNoSecret = true;\n this.bot.ctx.logger.warn('onebot: secret is empty, so event reports are accepted without X-Signature');\n }\n }\n else if (signature === undefined || signature === '') {\n writeStatus(response, 401);\n return;\n }\n const body = await readBody(request);\n let parsed;\n try {\n parsed = JSON.parse(body);\n }\n catch (error) {\n this.bot.ctx.logger.debug('onebot: event report is not JSON: %s', error instanceof Error ? error.message : String(error));\n writeStatus(response, 400);\n return;\n }\n if (secret !== '' &&\n !matchesSecret(signatureOf(secret, parsed), signature)) {\n writeStatus(response, 403);\n return;\n }\n if (headerOf(request, 'x-self-id') !== this.bot.config.selfId) {\n writeStatus(response, 403);\n return;\n }\n if (typeof parsed !== 'object' || parsed === null) {\n writeStatus(response, 400);\n return;\n }\n const session = decodePayload(this.bot, parsed);\n if (session !== undefined)\n await this.bot.receive(session);\n writeStatus(response, 204);\n }\n catch (error) {\n this.bot.ctx.logger.warn('onebot: event report failed: %s', error instanceof Error ? error.message : String(error));\n if (!response.headersSent)\n writeStatus(response, 500);\n else\n response.end();\n }\n }\n}\n//# sourceMappingURL=http.js.map","/**\n * Reverse WebSocket transport (`protocol: 'ws-reverse'`).\n *\n * The implementation dials the harness; the adapter owns the endpoint through the profile's `webServer` and keeps\n * listening between connections. A connection that fails the handshake checks is refused and dropped, because the\n * implementation's configuration can change without a restart of this process.\n */\nimport { Status } from '@deepseek-ai/cordis-plugin-im-core';\nimport { WebSocketServer } from 'ws';\nimport { routePath } from \"../config.js\";\nimport { decodePayload, isPayload } from \"../decode.js\";\nimport { ActionRequests, installRequest, isResponse, rejectRequests, } from \"../request.js\";\nimport { headerOf, matchesSecret, rejectUpgrade } from \"./shared.js\";\n/** The reverse WebSocket server of one bot. */\nexport class OneBotWsServer {\n bot;\n server;\n dispose;\n connection;\n requests;\n warnedNoToken = false;\n constructor(bot) {\n this.bot = bot;\n }\n /**\n * Claim the upgrade route. The endpoint then stays available across implementation restarts.\n */\n async start() {\n const webServer = this.bot.ctx.get('webServer');\n if (webServer === undefined) {\n throw this.fail('onebot: protocol \"ws-reverse\" needs a profile-provided webServer; use protocol \"ws\" instead');\n }\n const path = routePath(this.bot.config.path);\n const server = new WebSocketServer({ noServer: true });\n try {\n this.dispose = webServer.registerUpgrade({\n path,\n auth: 'anonymous',\n handler: (request, socket, head) => {\n this.upgrade(server, request, socket, head);\n },\n });\n }\n catch (error) {\n server.close();\n throw this.fail(`onebot: cannot claim the ws-reverse route ${path}: ${error instanceof Error ? error.message : String(error)}`);\n }\n this.server = server;\n }\n /** Release the route and close the connected implementation. */\n async stop() {\n this.dispose?.();\n this.dispose = undefined;\n this.closeConnection();\n const server = this.server;\n this.server = undefined;\n if (server !== undefined) {\n await new Promise((resolve) => server.close(() => resolve()));\n }\n }\n /** Log a start failure before throwing it, because `Bot.start` only stores a connect failure on `bot.error`. */\n fail(message) {\n this.bot.ctx.logger.error(message);\n return new Error(message);\n }\n /** Validate one upgrade request and hand the accepted socket to `ws`. */\n upgrade(server, request, socket, head) {\n const { token } = this.bot.config;\n if (token === '') {\n if (!this.warnedNoToken) {\n this.warnedNoToken = true;\n this.bot.ctx.logger.warn('onebot: token is empty, so reverse WebSocket connections are accepted without Authorization');\n }\n }\n else {\n const presented = headerOf(request, 'authorization')?.replace(/^Bearer\\s+/i, '');\n if (!matchesSecret(token, presented)) {\n rejectUpgrade(socket, 401, 'Unauthorized');\n return;\n }\n }\n if (headerOf(request, 'x-client-role') !== 'Universal') {\n rejectUpgrade(socket, 403, 'Forbidden');\n return;\n }\n if (headerOf(request, 'x-self-id') !== this.bot.config.selfId) {\n rejectUpgrade(socket, 403, 'Forbidden');\n return;\n }\n server.handleUpgrade(request, socket, head, (ws) => {\n this.accept(ws);\n });\n }\n /**\n * Take over one accepted socket. A newer connection replaces the previous one.\n * @param socket - the upgraded WebSocket connection of the implementation.\n */\n accept(socket) {\n this.closeConnection(1008, 'replaced by a new connection');\n this.connection = socket;\n const requests = new ActionRequests((frame) => socket.send(JSON.stringify(frame)), this.bot.config.ws.responseTimeout);\n this.requests = requests;\n installRequest(this.bot, requests.request);\n socket.on('message', (raw) => {\n this.dispatch(raw.toString(), requests);\n });\n socket.on('close', () => {\n this.drop(socket);\n });\n this.bot.user = {\n id: this.bot.config.selfId,\n name: this.bot.config.selfId,\n isBot: true,\n };\n this.bot.online();\n }\n closeConnection(code = 1000, reason = 'adapter stopped') {\n const socket = this.connection;\n const requests = this.requests;\n this.connection = undefined;\n this.requests = undefined;\n requests?.rejectAll(new Error('onebot: the reverse WebSocket connection has closed'));\n try {\n socket?.close(code, reason);\n }\n catch (error) {\n // The socket is already closed or closing; nothing left to release.\n void error;\n }\n }\n /** The current connection closed: refuse its pending calls and wait for the implementation to dial again. */\n drop(socket) {\n if (this.connection !== socket)\n return;\n this.connection = undefined;\n const failure = new Error('onebot: the reverse WebSocket connection has closed');\n this.requests?.rejectAll(failure);\n this.requests = undefined;\n rejectRequests(this.bot, failure);\n this.bot.status = Status.RECONNECT;\n }\n /** Dispatch one received frame: an event, an action answer, or noise. */\n dispatch(text, requests) {\n let parsed;\n try {\n parsed = JSON.parse(text);\n }\n catch (error) {\n this.bot.ctx.logger.warn('onebot: cannot parse a WebSocket frame: %s', error instanceof Error ? error.message : String(error));\n return;\n }\n if (isPayload(parsed)) {\n void this.receive(parsed);\n return;\n }\n if (isResponse(parsed) && requests.resolve(parsed))\n return;\n }\n /** Publish one event; a failed intake is logged because the platform will not redeliver it. */\n async receive(data) {\n if (data.post_type === 'meta_event') {\n this.bot.ctx.logger.debug('onebot: %s heartbeat ignored', data.meta_event_type ?? 'meta');\n return;\n }\n const session = decodePayload(this.bot, data);\n if (session === undefined) {\n this.bot.ctx.logger.debug('onebot: ignored %s event', data.post_type ?? 'unknown');\n return;\n }\n try {\n await this.bot.receive(session);\n }\n catch (error) {\n this.bot.ctx.logger.error('onebot: intake failed: %s', error instanceof Error ? error.message : String(error));\n }\n }\n}\n//# sourceMappingURL=ws-reverse.js.map","/** The configured `selfId` and the account the implementation reports disagree. */\nexport class OneBotIdentityError extends Error {\n constructor(message) {\n super(message);\n this.name = 'OneBotIdentityError';\n }\n}\n/**\n * Compare `get_login_info.user_id` with the configured account.\n *\n * A mismatch is a configuration error: reconnecting cannot change it, so the caller stops the reconnect loop instead\n * of retrying.\n *\n * @param internal - the account's action client.\n * @param selfId - the configured account.\n * @returns the login info of the matching account.\n * @throws OneBotIdentityError when the implementation reports another account.\n */\nexport async function verifyIdentity(internal, selfId) {\n const info = await internal.getLoginInfo();\n const actual = String(info.user_id);\n if (actual !== selfId) {\n throw new OneBotIdentityError(`onebot: selfId is configured as ${selfId} but the implementation reports account ${actual}; fix selfId and restart`);\n }\n return info;\n}\n//# sourceMappingURL=identity.js.map","/**\n * Forward WebSocket transport (`protocol: 'ws'`).\n *\n * The adapter dials the implementation's WebSocket endpoint and dials again forever: `ws.retryTimes` is a fast-retry\n * budget, not a give-up count, so an implementation that starts after the harness still comes online without a\n * restart. Configuration failures are the caller's to fix and throw out of `connect()`; transport failures retry.\n */\nimport { Status } from '@deepseek-ai/cordis-plugin-im-core';\nimport { decodePayload, isPayload } from \"../decode.js\";\nimport { OneBotIdentityError, verifyIdentity } from \"../identity.js\";\nimport { ActionRequests, installRequest, isResponse, rejectRequests, } from \"../request.js\";\n/** Waitable sleep that resolves early on abort. */\nfunction sleep(ms, signal) {\n return new Promise((resolve) => {\n if (signal.aborted) {\n resolve();\n return;\n }\n const timer = setTimeout(() => {\n signal.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n const onAbort = () => {\n clearTimeout(timer);\n resolve();\n };\n signal.addEventListener('abort', onAbort, { once: true });\n });\n}\n/** Text of one WebSocket frame. */\nfunction frameText(data) {\n return typeof data === 'string' ? data : String(data);\n}\n/** The forward WebSocket client of one bot. */\nexport class OneBotWsClient {\n bot;\n controller;\n running;\n socket;\n constructor(bot) {\n this.bot = bot;\n }\n /**\n * Validate the endpoint and start the reconnect loop.\n *\n * Returning before the first dial is deliberate: `Bot.start` awaits `connect()`, so waiting here would hold up\n * plugin initialization for as long as the implementation is late.\n */\n async start() {\n const endpoint = this.bot.config.endpoint;\n if (endpoint === '') {\n throw this.fail('onebot: protocol \"ws\" needs endpoint (the implementation\\'s ws:// URL)');\n }\n this.controller = new AbortController();\n this.running = this.loop(endpoint, this.controller.signal);\n }\n /** Stop the loop and wait for it to unwind. */\n async stop() {\n this.controller?.abort();\n this.controller = undefined;\n this.closeSocket();\n await this.running?.catch(() => undefined);\n this.running = undefined;\n }\n /** Log a start failure before throwing it, because `Bot.start` only stores a connect failure on `bot.error`. */\n fail(message) {\n this.bot.ctx.logger.error(message);\n return new Error(message);\n }\n closeSocket() {\n const socket = this.socket;\n this.socket = undefined;\n try {\n socket?.close(1000, 'adapter stopped');\n }\n catch (error) {\n // The socket is already closed or closing; nothing left to release.\n void error;\n }\n }\n async loop(endpoint, signal) {\n const { config } = this.bot;\n let failures = 0;\n while (!signal.aborted) {\n try {\n const socket = await this.dial(endpoint, signal);\n failures = 0;\n await this.accept(socket, signal);\n if (signal.aborted)\n return;\n this.bot.ctx.logger.warn('onebot: the WebSocket connection closed; reconnecting');\n this.bot.status = Status.RECONNECT;\n // The connection was working, so the next dial goes out at the fast interval.\n await sleep(config.ws.retryInterval, signal);\n }\n catch (error) {\n if (signal.aborted)\n return;\n if (error instanceof OneBotIdentityError) {\n // A wrong selfId cannot be fixed by reconnecting: report it and stop until the profile is edited.\n this.bot.ctx.logger.error('onebot: %s', error.message);\n this.bot.offline(error);\n return;\n }\n const message = error instanceof Error ? error.message : String(error);\n this.bot.ctx.logger.warn('onebot: %s; reconnecting', message);\n this.bot.status = Status.RECONNECT;\n const base = failures < config.ws.retryTimes\n ? config.ws.retryInterval\n : config.ws.retryLazy;\n failures += 1;\n await sleep(base, signal);\n }\n }\n }\n /** Dial the endpoint and resolve once the socket is open. */\n dial(endpoint, signal) {\n const { token } = this.bot.config;\n const socket = this.bot.ctx.http.ws(endpoint, token === '' ? {} : { headers: { Authorization: `Bearer ${token}` } });\n return new Promise((resolve, reject) => {\n const cleanup = () => {\n socket.removeEventListener('open', onOpen);\n socket.removeEventListener('error', onError);\n socket.removeEventListener('close', onClose);\n signal.removeEventListener('abort', onAbort);\n };\n const onOpen = () => {\n cleanup();\n resolve(socket);\n };\n const onError = (event) => {\n cleanup();\n reject(new Error(`onebot: WebSocket error${event.message === undefined ? '' : `: ${event.message}`}`));\n };\n const onClose = (event) => {\n cleanup();\n reject(new Error(`onebot: WebSocket closed before opening (code ${event.code})`));\n };\n const onAbort = () => {\n cleanup();\n reject(signal.reason ?? new Error('onebot: adapter stopped'));\n };\n if (signal.aborted) {\n onAbort();\n return;\n }\n socket.addEventListener('open', onOpen);\n socket.addEventListener('error', onError);\n socket.addEventListener('close', onClose);\n signal.addEventListener('abort', onAbort, { once: true });\n });\n }\n /**\n * Take over one open socket: install the action caller, check the identity, publish events until the socket closes.\n */\n async accept(socket, signal) {\n this.socket = socket;\n const requests = new ActionRequests((frame) => socket.send(JSON.stringify(frame)), this.bot.config.ws.responseTimeout);\n installRequest(this.bot, requests.request);\n const closed = new Promise((resolve) => {\n socket.addEventListener('close', () => resolve());\n });\n socket.addEventListener('message', (event) => {\n this.dispatch(frameText(event.data), requests);\n });\n const onAbort = () => {\n requests.rejectAll(new Error('onebot: adapter stopped'));\n this.closeSocket();\n };\n signal.addEventListener('abort', onAbort, { once: true });\n try {\n const login = await verifyIdentity(this.bot.internal, this.bot.config.selfId);\n this.bot.user = {\n id: String(login.user_id),\n name: login.nickname,\n isBot: true,\n };\n this.bot.online();\n }\n catch (error) {\n const failure = error instanceof Error ? error : new Error(String(error));\n requests.rejectAll(failure);\n rejectRequests(this.bot, failure);\n this.closeSocket();\n throw failure;\n }\n finally {\n signal.removeEventListener('abort', onAbort);\n }\n await closed;\n const failure = new Error('onebot: the WebSocket connection has closed');\n requests.rejectAll(failure);\n // Calls made after the close must not hang on the dead socket.\n rejectRequests(this.bot, failure);\n this.socket = undefined;\n }\n /** Dispatch one received frame: an event, an action answer, or noise. */\n dispatch(text, requests) {\n let parsed;\n try {\n parsed = JSON.parse(text);\n }\n catch (error) {\n this.bot.ctx.logger.warn('onebot: cannot parse a WebSocket frame: %s', error instanceof Error ? error.message : String(error));\n return;\n }\n if (isPayload(parsed)) {\n void this.receive(parsed);\n return;\n }\n if (isResponse(parsed) && requests.resolve(parsed))\n return;\n }\n /** Publish one event; a failed intake is logged because the platform will not redeliver it. */\n async receive(data) {\n if (data.post_type === 'meta_event') {\n this.bot.ctx.logger.debug('onebot: %s heartbeat ignored', data.meta_event_type ?? 'meta');\n return;\n }\n const session = decodePayload(this.bot, data);\n if (session === undefined) {\n this.bot.ctx.logger.debug('onebot: ignored %s event', data.post_type ?? 'unknown');\n return;\n }\n try {\n await this.bot.receive(session);\n }\n catch (error) {\n this.bot.ctx.logger.error('onebot: intake failed: %s', error instanceof Error ? error.message : String(error));\n }\n }\n}\n//# sourceMappingURL=ws.js.map","import { Adapter, PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';\nimport { fileURLToPath } from 'node:url';\nimport { Config } from \"./config.js\";\nimport { classifyOneBotError } from \"./errors.js\";\nimport { createSegmentMode } from \"./modes/segment.js\";\nimport { createReaction, deletePart, deleteReaction, getMessage, members, normalizeSource, sendPayload, } from \"./send.js\";\nimport { OneBotHttp } from \"./transport/http.js\";\nimport { OneBotWsServer } from \"./transport/ws-reverse.js\";\nimport { OneBotWsClient } from \"./transport/ws.js\";\nimport { Internal } from \"./types.js\";\n/**\n * OneBot 11 adapter.\n *\n * The implementation is a third-party process; this adapter is the framework side of the protocol. Identity is the\n * configured `selfId`, verified with `get_login_info` on the forward WebSocket, and the transports are the three\n * `protocol` values of the upstream plugin.\n */\nexport class OneBotBot extends Adapter {\n /** The adapter needs the Satori service and the isolated `http` service. */\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;\n modeOrder = ['segment'];\n /** Full typed OneBot 11 action surface registered by the migrated declarations. */\n internal;\n transport;\n constructor(ctx, config) {\n super(ctx, config, {\n id: `onebot:${config.selfId}`,\n platform: 'onebot',\n adapter: 'onebot',\n });\n this.selfId = config.selfId;\n this.modes = {\n segment: createSegmentMode(config.advanced.splitMixedContent),\n };\n this.internal = new Internal(this);\n }\n async connect() {\n this.validate();\n const transport = this.createTransport();\n this.transport = transport;\n try {\n await transport.start();\n }\n catch (error) {\n this.transport = undefined;\n throw error;\n }\n }\n async disconnect() {\n const transport = this.transport;\n this.transport = undefined;\n await transport?.stop();\n }\n /**\n * Resolve one outbound resource.\n *\n * OneBot has no upload endpoint: an image, record or video segment carries its source, which the implementation\n * fetches itself. A `<file>` needs a path on the implementation's host, so a local `file:` source is used directly\n * and anything else is handed to `download_file`.\n */\n async upload(ref, _scope, _ctx) {\n if (ref.kind !== 'file')\n return { key: normalizeSource(ref.src) };\n if (ref.src.startsWith('file:')) {\n return { key: fileURLToPath(ref.src) };\n }\n const downloaded = await this.internal.downloadFile(ref.src);\n if (downloaded === undefined) {\n throw new PlatformError('not-found', `onebot: download_file returned no path for ${ref.src}`);\n }\n return { key: downloaded };\n }\n resourceScope(_target, _kind) {\n return this.id;\n }\n async sendPayload(payload, target, ctx) {\n return await sendPayload(this.sendDeps(), payload, target, ctx);\n }\n async deletePart(part) {\n await deletePart(this.sendDeps(), part);\n }\n async members(chat, _cursor, _limit) {\n return await members(this.sendDeps(), chat);\n }\n async getMessage(chat, id) {\n return await getMessage(this.sendDeps(), this, chat, id);\n }\n async createReaction(message, emoji) {\n await createReaction(this.sendDeps(), message, emoji);\n }\n async deleteReaction(message, emoji) {\n await deleteReaction(this.sendDeps(), message, emoji);\n }\n classify(error) {\n return classifyOneBotError(error);\n }\n sendDeps() {\n return { internal: this.internal };\n }\n /** Reject a configuration the selected transport cannot work from; such a failure is not retryable. */\n validate() {\n const { protocol, endpoint } = this.config;\n if (protocol === 'ws-reverse')\n return;\n if (endpoint === '') {\n throw this.fail(`onebot: protocol \"${protocol}\" needs endpoint (the implementation's ${protocol === 'ws' ? 'ws' : 'http'}:// URL)`);\n }\n let url;\n try {\n url = new URL(endpoint);\n }\n catch {\n throw this.fail(`onebot: endpoint \"${endpoint}\" is not a valid URL`);\n }\n const accepted = protocol === 'ws' ? ['ws:', 'wss:'] : ['http:', 'https:'];\n if (!accepted.includes(url.protocol)) {\n throw this.fail(`onebot: endpoint \"${endpoint}\" must be a ${accepted.join(' or ')} URL for protocol \"${protocol}\"`);\n }\n }\n fail(message) {\n this.ctx.logger.error(message);\n return new Error(message);\n }\n createTransport() {\n switch (this.config.protocol) {\n case 'ws':\n return new OneBotWsClient(this);\n case 'ws-reverse':\n return new OneBotWsServer(this);\n case 'http':\n return new OneBotHttp(this);\n }\n }\n}\nexport { Config };\nexport default OneBotBot;\n//# sourceMappingURL=bot.js.map"],"mappings":";;;;;;;;AAEA,MAAa,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;CACA,MAAM,eAAe,SAAS,OAAO;EACjC,MAAM,eAAe,KAAK,SAAS,GAAG,SAAS,KAAK;CACxD;CACA,SAAS,OAAO;EACZ,OAAO,oBAAoB,KAAK;CACpC;CACA,WAAW;EACP,OAAO,EAAE,UAAU,KAAK,SAAS;CACrC;;CAEA,WAAW;EACP,MAAM,EAAE,UAAU,aAAa,KAAK;EACpC,IAAI,aAAa,cACb;EACJ,IAAI,aAAa,IACb,MAAM,KAAK,KAAK,qBAAqB,SAAS,yCAAyC,aAAa,OAAO,OAAO,OAAO,SAAS;EAEtI,IAAI;EACJ,IAAI;GACA,MAAM,IAAI,IAAI,QAAQ;EAC1B,QACM;GACF,MAAM,KAAK,KAAK,qBAAqB,SAAS,qBAAqB;EACvE;EACA,MAAM,WAAW,aAAa,OAAO,CAAC,OAAO,MAAM,IAAI,CAAC,SAAS,QAAQ;EACzE,IAAI,CAAC,SAAS,SAAS,IAAI,QAAQ,GAC/B,MAAM,KAAK,KAAK,qBAAqB,SAAS,cAAc,SAAS,KAAK,MAAM,EAAE,qBAAqB,SAAS,EAAE;CAE1H;CACA,KAAK,SAAS;EACV,KAAK,IAAI,OAAO,MAAM,OAAO;EAC7B,OAAO,IAAI,MAAM,OAAO;CAC5B;CACA,kBAAkB;EACd,QAAQ,KAAK,OAAO,UAApB;GACI,KAAK,MACD,OAAO,IAAI,eAAe,IAAI;GAClC,KAAK,cACD,OAAO,IAAI,eAAe,IAAI;GAClC,KAAK,QACD,OAAO,IAAI,WAAW,IAAI;EAClC;CACJ;AACJ"}
@@ -0,0 +1,55 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { Adapter, PlatformError, type ChatRef, type InboundMessage, type MembersPage, type MessageRef, type Mode, type PrepareContext, type ResolvedResource, type ResourceKind, type ResourceRef, type SendContext, type SentPart, type Target } from '@deepseek-ai/cordis-plugin-im-core';
3
+ import { Config } from './config.ts';
4
+ import type { OneBotModeTypes } from './modes/shared.ts';
5
+ import { Internal } from './types.ts';
6
+ /** The single mode this adapter always registers. */
7
+ export interface OneBotModes {
8
+ [mode: string]: Mode<OneBotModeTypes>;
9
+ segment: Mode<OneBotModeTypes>;
10
+ }
11
+ /**
12
+ * OneBot 11 adapter.
13
+ *
14
+ * The implementation is a third-party process; this adapter is the framework side of the protocol. Identity is the
15
+ * configured `selfId`, verified with `get_login_info` on the forward WebSocket, and the transports are the three
16
+ * `protocol` values of the upstream plugin.
17
+ */
18
+ export declare class OneBotBot extends Adapter<Config, OneBotModes> {
19
+ /** The adapter needs the Satori service and the isolated `http` service. */
20
+ static inject: string[];
21
+ /** The Loader applies this schema to a profile row's `config` before the constructor runs. */
22
+ static readonly Config: import("@deepseek-ai/schemastery").default<Config>;
23
+ readonly modes: OneBotModes;
24
+ readonly modeOrder: readonly ["segment"];
25
+ /** Full typed OneBot 11 action surface registered by the migrated declarations. */
26
+ readonly internal: Internal;
27
+ private transport;
28
+ constructor(ctx: Context, config: Config);
29
+ connect(): Promise<void>;
30
+ disconnect(): Promise<void>;
31
+ /**
32
+ * Resolve one outbound resource.
33
+ *
34
+ * OneBot has no upload endpoint: an image, record or video segment carries its source, which the implementation
35
+ * fetches itself. A `<file>` needs a path on the implementation's host, so a local `file:` source is used directly
36
+ * and anything else is handed to `download_file`.
37
+ */
38
+ upload(ref: ResourceRef, _scope: string, _ctx: PrepareContext): Promise<ResolvedResource>;
39
+ resourceScope(_target: Target, _kind: ResourceKind): string;
40
+ sendPayload(payload: unknown, target: Target, ctx: SendContext): Promise<SentPart>;
41
+ deletePart(part: SentPart): Promise<void>;
42
+ members(chat: ChatRef, _cursor?: string, _limit?: number): Promise<MembersPage>;
43
+ getMessage(chat: ChatRef, id: string): Promise<InboundMessage>;
44
+ createReaction(message: MessageRef, emoji: string): Promise<void>;
45
+ deleteReaction(message: MessageRef, emoji: string): Promise<void>;
46
+ classify(error: unknown): PlatformError;
47
+ private sendDeps;
48
+ /** Reject a configuration the selected transport cannot work from; such a failure is not retryable. */
49
+ private validate;
50
+ private fail;
51
+ private createTransport;
52
+ }
53
+ export { Config };
54
+ export default OneBotBot;
55
+ //# sourceMappingURL=bot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../src/bot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EACL,OAAO,EACP,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,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,EACZ,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,mBAAmB,CAAA;AAcvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,CAAA;IACrC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;CAC/B;AAQD;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC;IACzD,4EAA4E;IAC5E,OAAgB,MAAM,WAAqB;IAC3C,8FAA8F;IAC9F,MAAM,CAAC,QAAQ,CAAC,MAAM,qDAAS;IAE/B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;IAC3B,QAAQ,CAAC,SAAS,uBAAuB;IAEzC,mFAAmF;IACnF,SAAkB,QAAQ,EAAE,QAAQ,CAAA;IAEpC,OAAO,CAAC,SAAS,CAA6B;gBAElC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;IAazB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAYxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1C;;;;;;OAMG;IACY,MAAM,CACnB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC;IAiBnB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM;IAIrD,WAAW,CACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,QAAQ,CAAC;IASL,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,OAAO,CACpB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC;IAIR,UAAU,CACvB,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC;IAIX,cAAc,CAC3B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAID,cAAc,CAC3B,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAIP,QAAQ,CAAC,KAAK,EAAE,OAAO;IAIhC,OAAO,CAAC,QAAQ;IAIhB,uGAAuG;IACvG,OAAO,CAAC,QAAQ;IAsBhB,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,eAAe;CAUxB;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAe,SAAS,CAAA"}
@@ -0,0 +1,140 @@
1
+ import { Adapter, PlatformError, } from '@deepseek-ai/cordis-plugin-im-core';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { Config } from "./config.js";
4
+ import { classifyOneBotError } from "./errors.js";
5
+ import { createSegmentMode } from "./modes/segment.js";
6
+ import { createReaction, deletePart, deleteReaction, getMessage, members, normalizeSource, sendPayload, } from "./send.js";
7
+ import { OneBotHttp } from "./transport/http.js";
8
+ import { OneBotWsServer } from "./transport/ws-reverse.js";
9
+ import { OneBotWsClient } from "./transport/ws.js";
10
+ import { Internal } from "./types.js";
11
+ /**
12
+ * OneBot 11 adapter.
13
+ *
14
+ * The implementation is a third-party process; this adapter is the framework side of the protocol. Identity is the
15
+ * configured `selfId`, verified with `get_login_info` on the forward WebSocket, and the transports are the three
16
+ * `protocol` values of the upstream plugin.
17
+ */
18
+ export class OneBotBot extends Adapter {
19
+ /** The adapter needs the Satori service and the isolated `http` service. */
20
+ static inject = ['satori', 'http'];
21
+ /** The Loader applies this schema to a profile row's `config` before the constructor runs. */
22
+ static Config = Config;
23
+ modes;
24
+ modeOrder = ['segment'];
25
+ /** Full typed OneBot 11 action surface registered by the migrated declarations. */
26
+ internal;
27
+ transport;
28
+ constructor(ctx, config) {
29
+ super(ctx, config, {
30
+ id: `onebot:${config.selfId}`,
31
+ platform: 'onebot',
32
+ adapter: 'onebot',
33
+ });
34
+ this.selfId = config.selfId;
35
+ this.modes = {
36
+ segment: createSegmentMode(config.advanced.splitMixedContent),
37
+ };
38
+ this.internal = new Internal(this);
39
+ }
40
+ async connect() {
41
+ this.validate();
42
+ const transport = this.createTransport();
43
+ this.transport = transport;
44
+ try {
45
+ await transport.start();
46
+ }
47
+ catch (error) {
48
+ this.transport = undefined;
49
+ throw error;
50
+ }
51
+ }
52
+ async disconnect() {
53
+ const transport = this.transport;
54
+ this.transport = undefined;
55
+ await transport?.stop();
56
+ }
57
+ /**
58
+ * Resolve one outbound resource.
59
+ *
60
+ * OneBot has no upload endpoint: an image, record or video segment carries its source, which the implementation
61
+ * fetches itself. A `<file>` needs a path on the implementation's host, so a local `file:` source is used directly
62
+ * and anything else is handed to `download_file`.
63
+ */
64
+ async upload(ref, _scope, _ctx) {
65
+ if (ref.kind !== 'file')
66
+ return { key: normalizeSource(ref.src) };
67
+ if (ref.src.startsWith('file:')) {
68
+ return { key: fileURLToPath(ref.src) };
69
+ }
70
+ const downloaded = await this.internal.downloadFile(ref.src);
71
+ if (downloaded === undefined) {
72
+ throw new PlatformError('not-found', `onebot: download_file returned no path for ${ref.src}`);
73
+ }
74
+ return { key: downloaded };
75
+ }
76
+ resourceScope(_target, _kind) {
77
+ return this.id;
78
+ }
79
+ async sendPayload(payload, target, ctx) {
80
+ return await sendPayload(this.sendDeps(), payload, target, ctx);
81
+ }
82
+ async deletePart(part) {
83
+ await deletePart(this.sendDeps(), part);
84
+ }
85
+ async members(chat, _cursor, _limit) {
86
+ return await members(this.sendDeps(), chat);
87
+ }
88
+ async getMessage(chat, id) {
89
+ return await getMessage(this.sendDeps(), this, chat, id);
90
+ }
91
+ async createReaction(message, emoji) {
92
+ await createReaction(this.sendDeps(), message, emoji);
93
+ }
94
+ async deleteReaction(message, emoji) {
95
+ await deleteReaction(this.sendDeps(), message, emoji);
96
+ }
97
+ classify(error) {
98
+ return classifyOneBotError(error);
99
+ }
100
+ sendDeps() {
101
+ return { internal: this.internal };
102
+ }
103
+ /** Reject a configuration the selected transport cannot work from; such a failure is not retryable. */
104
+ validate() {
105
+ const { protocol, endpoint } = this.config;
106
+ if (protocol === 'ws-reverse')
107
+ return;
108
+ if (endpoint === '') {
109
+ throw this.fail(`onebot: protocol "${protocol}" needs endpoint (the implementation's ${protocol === 'ws' ? 'ws' : 'http'}:// URL)`);
110
+ }
111
+ let url;
112
+ try {
113
+ url = new URL(endpoint);
114
+ }
115
+ catch {
116
+ throw this.fail(`onebot: endpoint "${endpoint}" is not a valid URL`);
117
+ }
118
+ const accepted = protocol === 'ws' ? ['ws:', 'wss:'] : ['http:', 'https:'];
119
+ if (!accepted.includes(url.protocol)) {
120
+ throw this.fail(`onebot: endpoint "${endpoint}" must be a ${accepted.join(' or ')} URL for protocol "${protocol}"`);
121
+ }
122
+ }
123
+ fail(message) {
124
+ this.ctx.logger.error(message);
125
+ return new Error(message);
126
+ }
127
+ createTransport() {
128
+ switch (this.config.protocol) {
129
+ case 'ws':
130
+ return new OneBotWsClient(this);
131
+ case 'ws-reverse':
132
+ return new OneBotWsServer(this);
133
+ case 'http':
134
+ return new OneBotHttp(this);
135
+ }
136
+ }
137
+ }
138
+ export { Config };
139
+ export default OneBotBot;
140
+ //# sourceMappingURL=bot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot.js","sourceRoot":"","sources":["../../src/bot.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,aAAa,GAad,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EACL,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACV,OAAO,EACP,eAAe,EACf,WAAW,GAEZ,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAcrC;;;;;;GAMG;AACH,MAAM,OAAO,SAAU,SAAQ,OAA4B;IACzD,4EAA4E;IAC5E,MAAM,CAAU,MAAM,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC3C,8FAA8F;IAC9F,MAAM,CAAU,MAAM,GAAG,MAAM,CAAA;IAEtB,KAAK,CAAa;IAClB,SAAS,GAAG,CAAC,SAAS,CAAU,CAAA;IAEzC,mFAAmF;IACjE,QAAQ,CAAU;IAE5B,SAAS,CAA6B;IAE9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ACH,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,OAAe;QAC1B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC9B,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC3B,CAAC;IAEO,eAAe;QACrB,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7B,KAAK,IAAI;gBACP,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;YACjC,KAAK,YAAY;gBACf,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA;YACjC,KAAK,MAAM;gBACT,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;;AAGH,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAe,SAAS,CAAA"}
@@ -0,0 +1,40 @@
1
+ import z from '@deepseek-ai/schemastery';
2
+ /** How the adapter carries OneBot 11: which side opens the connection. */
3
+ export type OneBotProtocol = 'http' | 'ws' | 'ws-reverse';
4
+ /** One OneBot 11 account. */
5
+ export interface Config {
6
+ /** The account the implementation reports as `get_login_info.user_id`. */
7
+ selfId: string;
8
+ /** Access token: `Authorization: Bearer` outbound, checked on inbound transports. */
9
+ token: string;
10
+ /** HMAC-SHA1 key of the `X-Signature` header of `protocol: 'http'` event reports. */
11
+ secret: string;
12
+ protocol: OneBotProtocol;
13
+ /** Implementation endpoint of the `ws` / `http` transports. */
14
+ endpoint: string;
15
+ /** Inbound route of the `ws-reverse` / `http` transports. */
16
+ path: string;
17
+ ws: {
18
+ /** Fast-retry budget of the forward WebSocket reconnect loop; it never gives up. */
19
+ retryTimes: number;
20
+ /** Delay between dials while the fast-retry budget lasts. */
21
+ retryInterval: number;
22
+ /** Delay between dials once the fast-retry budget is spent. */
23
+ retryLazy: number;
24
+ /** How long one action waits for its answer. */
25
+ responseTimeout: number;
26
+ };
27
+ advanced: {
28
+ /** Pad a space around mixed text and images, as the upstream adapter does. */
29
+ splitMixedContent: boolean;
30
+ };
31
+ }
32
+ /** Validated OneBot 11 adapter configuration. */
33
+ export declare const Config: z<Config>;
34
+ /**
35
+ * Normalize an inbound route path: absolute, no trailing slash.
36
+ * @param path - the configured `path`.
37
+ * @returns the pathname to register.
38
+ */
39
+ export declare function routePath(path: string): string;
40
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY,CAAA;AAEzD,6BAA6B;AAC7B,MAAM,WAAW,MAAM;IACrB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;IACd,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAA;IACb,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,cAAc,CAAA;IACxB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAA;IAChB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE;QACF,oFAAoF;QACpF,UAAU,EAAE,MAAM,CAAA;QAClB,6DAA6D;QAC7D,aAAa,EAAE,MAAM,CAAA;QACrB,+DAA+D;QAC/D,SAAS,EAAE,MAAM,CAAA;QACjB,gDAAgD;QAChD,eAAe,EAAE,MAAM,CAAA;KACxB,CAAA;IACD,QAAQ,EAAE;QACR,8EAA8E;QAC9E,iBAAiB,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF;AAED,iDAAiD;AACjD,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAoB3B,CAAA;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C"}
@@ -0,0 +1,33 @@
1
+ import z from '@deepseek-ai/schemastery';
2
+ /** Validated OneBot 11 adapter configuration. */
3
+ export const Config = z.object({
4
+ selfId: z.string().required(),
5
+ token: z.string().role('secret').default(''),
6
+ secret: z.string().role('secret').default(''),
7
+ protocol: z.union(['http', 'ws', 'ws-reverse']).default('ws-reverse'),
8
+ endpoint: z.string().role('url').default(''),
9
+ path: z.string().default('/onebot'),
10
+ ws: z
11
+ .object({
12
+ retryTimes: z.natural().default(6),
13
+ retryInterval: z.natural().role('ms').default(5_000),
14
+ retryLazy: z.natural().role('ms').default(60_000),
15
+ responseTimeout: z.natural().role('ms').default(60_000),
16
+ })
17
+ .default({}),
18
+ advanced: z
19
+ .object({
20
+ splitMixedContent: z.boolean().default(true),
21
+ })
22
+ .default({}),
23
+ });
24
+ /**
25
+ * Normalize an inbound route path: absolute, no trailing slash.
26
+ * @param path - the configured `path`.
27
+ * @returns the pathname to register.
28
+ */
29
+ export function routePath(path) {
30
+ const withSlash = path.startsWith('/') ? path : `/${path}`;
31
+ return withSlash.length > 1 ? withSlash.replace(/\/+$/, '') : withSlash;
32
+ }
33
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAkCxC,iDAAiD;AACjD,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,C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