@im-more/dsh-wecom 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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +13 -0
  3. package/lib/index.js +2077 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/bot.d.ts +50 -0
  6. package/lib/types/bot.d.ts.map +1 -0
  7. package/lib/types/bot.js +126 -0
  8. package/lib/types/bot.js.map +1 -0
  9. package/lib/types/config.d.ts +48 -0
  10. package/lib/types/config.d.ts.map +1 -0
  11. package/lib/types/config.js +68 -0
  12. package/lib/types/config.js.map +1 -0
  13. package/lib/types/crypto.d.ts +69 -0
  14. package/lib/types/crypto.d.ts.map +1 -0
  15. package/lib/types/crypto.js +129 -0
  16. package/lib/types/crypto.js.map +1 -0
  17. package/lib/types/decode.d.ts +58 -0
  18. package/lib/types/decode.d.ts.map +1 -0
  19. package/lib/types/decode.js +182 -0
  20. package/lib/types/decode.js.map +1 -0
  21. package/lib/types/errors.d.ts +67 -0
  22. package/lib/types/errors.d.ts.map +1 -0
  23. package/lib/types/errors.js +170 -0
  24. package/lib/types/errors.js.map +1 -0
  25. package/lib/types/identity.d.ts +20 -0
  26. package/lib/types/identity.d.ts.map +1 -0
  27. package/lib/types/identity.js +34 -0
  28. package/lib/types/identity.js.map +1 -0
  29. package/lib/types/index.d.ts +19 -0
  30. package/lib/types/index.d.ts.map +1 -0
  31. package/lib/types/index.js +18 -0
  32. package/lib/types/index.js.map +1 -0
  33. package/lib/types/internal.d.ts +154 -0
  34. package/lib/types/internal.d.ts.map +1 -0
  35. package/lib/types/internal.js +115 -0
  36. package/lib/types/internal.js.map +1 -0
  37. package/lib/types/media.d.ts +44 -0
  38. package/lib/types/media.d.ts.map +1 -0
  39. package/lib/types/media.js +116 -0
  40. package/lib/types/media.js.map +1 -0
  41. package/lib/types/modes/markdown.d.ts +20 -0
  42. package/lib/types/modes/markdown.d.ts.map +1 -0
  43. package/lib/types/modes/markdown.js +205 -0
  44. package/lib/types/modes/markdown.js.map +1 -0
  45. package/lib/types/modes/shared.d.ts +227 -0
  46. package/lib/types/modes/shared.d.ts.map +1 -0
  47. package/lib/types/modes/shared.js +487 -0
  48. package/lib/types/modes/shared.js.map +1 -0
  49. package/lib/types/request.d.ts +55 -0
  50. package/lib/types/request.d.ts.map +1 -0
  51. package/lib/types/request.js +202 -0
  52. package/lib/types/request.js.map +1 -0
  53. package/lib/types/send.d.ts +54 -0
  54. package/lib/types/send.d.ts.map +1 -0
  55. package/lib/types/send.js +124 -0
  56. package/lib/types/send.js.map +1 -0
  57. package/lib/types/token.d.ts +34 -0
  58. package/lib/types/token.d.ts.map +1 -0
  59. package/lib/types/token.js +61 -0
  60. package/lib/types/token.js.map +1 -0
  61. package/lib/types/transport/webhook.d.ts +41 -0
  62. package/lib/types/transport/webhook.d.ts.map +1 -0
  63. package/lib/types/transport/webhook.js +216 -0
  64. package/lib/types/transport/webhook.js.map +1 -0
  65. package/lib/types/types.d.ts +58 -0
  66. package/lib/types/types.d.ts.map +1 -0
  67. package/lib/types/types.js +2 -0
  68. package/lib/types/types.js.map +1 -0
  69. package/lib/types/xml.d.ts +40 -0
  70. package/lib/types/xml.d.ts.map +1 -0
  71. package/lib/types/xml.js +82 -0
  72. package/lib/types/xml.js.map +1 -0
  73. package/package.json +65 -3
  74. package/src/bot.ts +195 -0
  75. package/src/config.ts +117 -0
  76. package/src/crypto.ts +172 -0
  77. package/src/decode.ts +238 -0
  78. package/src/errors.ts +199 -0
  79. package/src/identity.ts +41 -0
  80. package/src/index.ts +101 -0
  81. package/src/internal.ts +237 -0
  82. package/src/media.ts +157 -0
  83. package/src/modes/markdown.ts +263 -0
  84. package/src/modes/shared.ts +618 -0
  85. package/src/request.ts +291 -0
  86. package/src/send.ts +172 -0
  87. package/src/token.ts +75 -0
  88. package/src/transport/webhook.ts +292 -0
  89. package/src/types.ts +74 -0
  90. package/src/xml.ts +89 -0
  91. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["messageOf","messageOf","messageOf","messageOf"],"sources":["types/types.js","types/config.js","types/errors.js","types/identity.js","types/request.js","types/internal.js","types/media.js","types/modes/shared.js","types/modes/markdown.js","types/send.js","types/token.js","types/crypto.js","types/decode.js","types/xml.js","types/transport/webhook.js","types/bot.js"],"sourcesContent":["export {};\n//# sourceMappingURL=types.js.map","import z from '@deepseek-ai/schemastery';\n/** Validated WeCom adapter configuration. */\nexport const Config = z.object({\n corpId: z.string().required(),\n agentId: z.string().required(),\n secret: z.string().role('secret').required(),\n token: z.string().role('secret').required(),\n aesKey: z.string().role('secret').required(),\n path: z.string().default('/wecom'),\n apiBaseUrl: z.string().role('url').default('https://qyapi.weixin.qq.com'),\n});\n/** Length of an `EncodingAESKey`, which is the Base64 form of the 32-byte AES key without its padding. */\nexport const AES_KEY_CHARS = 43;\n/** Maximum length of a callback `Token` the platform accepts. */\nexport const TOKEN_MAX_CHARS = 32;\n/** The alphanumerical alphabet both callback credentials are drawn from. */\nconst CREDENTIAL_ALPHABET = /^[0-9A-Za-z]+$/;\n/**\n * Normalize a route path: absolute, no trailing slash.\n *\n * @param path - a configured path.\n * @returns the pathname to register on the web server.\n */\nexport function routePath(path) {\n const withSlash = path.startsWith('/') ? path : `/${path}`;\n return withSlash.length > 1 ? withSlash.replace(/\\/+$/, '') : withSlash;\n}\n/**\n * The configuration the adapter cannot work from, as far as it can tell locally.\n *\n * The check runs when the bot starts, not on the first callback: the callback is the only inbound path, so a profile\n * that cannot answer one has no way to receive anything.\n *\n * @param config - the validated configuration.\n * @returns the configuration error, or undefined when the configuration is usable.\n */\nexport function configError(config) {\n if (config.corpId === '') {\n return new Error('wecom: corpId is required (the enterprise id \"ww…\" of 我的企业 → 企业信息)');\n }\n if (config.agentId === '') {\n return new Error('wecom: agentId is required (the AgentID of the self-built application)');\n }\n if (!/^[1-9][0-9]*$/.test(config.agentId)) {\n return new Error(`wecom: agentId must be a positive integer string, got \"${config.agentId}\" (message/send takes the numeric AgentID)`);\n }\n if (config.secret === '') {\n return new Error('wecom: secret is required (the application secret, which every access_token is minted with)');\n }\n if (config.token === '') {\n return new Error('wecom: token is required (the callback Token of 接收消息 → 设置API接收)');\n }\n if (config.token.length > TOKEN_MAX_CHARS) {\n return new Error(`wecom: token must be at most ${TOKEN_MAX_CHARS} characters, got ${config.token.length}`);\n }\n if (config.aesKey === '') {\n return new Error('wecom: aesKey is required (the EncodingAESKey of 接收消息 → 设置API接收)');\n }\n if (config.aesKey.length !== AES_KEY_CHARS ||\n !CREDENTIAL_ALPHABET.test(config.aesKey)) {\n return new Error(`wecom: aesKey must be exactly ${AES_KEY_CHARS} letters or digits, got ${config.aesKey.length} characters`);\n }\n if (!config.apiBaseUrl.startsWith('https://')) {\n return new Error(`wecom: apiBaseUrl must be an https URL, got \"${config.apiBaseUrl}\"`);\n }\n return undefined;\n}\n//# sourceMappingURL=config.js.map","/**\n * Platform failures of the WeCom REST surface and their mapping onto the core taxonomy.\n *\n * Almost every failure has one shape: HTTP 200 with `{ errcode, errmsg }`, where `errcode === 0` is success. The HTTP\n * layer only fails for a transport problem or a gateway. `published: 'no'` is therefore reserved for a platform refusal\n * this adapter can classify; an answer without a code, a non-JSON page and a 5xx leave the outcome open.\n */\nimport { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\n/** One failed WeCom API call. */\nexport class WecomApiError extends Error {\n status;\n errcode;\n errmsg;\n bodyText;\n nonJson;\n constructor(message, init = {}) {\n super(message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = 'WecomApiError';\n this.status = init.status;\n this.errcode = init.errcode;\n this.errmsg = init.errmsg;\n this.bodyText = init.bodyText;\n this.nonJson = init.nonJson ?? false;\n }\n}\nconst RATE_LIMIT = { kind: 'rate-limit', published: 'no' };\nconst LIMIT = { kind: 'limit', published: 'no' };\nconst PERMISSION = { kind: 'permission', published: 'no' };\nconst NOT_FOUND = { kind: 'not-found', published: 'no' };\nconst INVALID = { kind: 'invalid', published: 'no' };\nconst RETRYABLE = { kind: 'retryable', published: 'unknown' };\n/**\n * The codes of 全局错误码 this adapter actually meets.\n *\n * A refusal the platform names is a request it rejected before publishing anything, so every entry is `published: 'no'`.\n */\nconst CODE_VERDICTS = new Map([\n [40001, PERMISSION], // invalid secret\n [40013, PERMISSION], // invalid corpId\n [40014, PERMISSION], // invalid access_token\n [42001, PERMISSION], // access_token expired\n [40003, NOT_FOUND], // invalid userid\n [40007, INVALID], // invalid media_id\n [40008, INVALID], // invalid msgtype\n [44001, INVALID], // empty media file\n [45002, LIMIT], // message content over the limit\n [45009, RATE_LIMIT], // API call rate limit\n [45033, RATE_LIMIT], // API concurrency limit\n [48002, PERMISSION], // API not enabled for the application\n [60011, PERMISSION], // no permission for the member/department/tag\n [81013, PERMISSION], // every userid/department/tag was invalid\n [82001, INVALID], // touser/toparty/totag all empty\n [830002, LIMIT], // downloaded file too large\n]);\n/** Codes outside the documented table whose whole family has one verdict. */\nconst FAMILY_VERDICTS = new Map([\n [41001, PERMISSION], // access_token missing\n [48004, PERMISSION], // API forbidden\n [60020, PERMISSION], // IP not in the trust list\n [301002, PERMISSION], // no privilege for this API\n]);\n/** Whether a code means the `access_token` was refused, so the token is re-minted and the call retried once. */\nconst TOKEN_FAILURE_CODES = new Set([42001, 40014]);\n/**\n * Verdict of one business code, by the documented table and then by family.\n *\n * @param errcode - the `errcode` of an answer.\n * @returns its classification, or undefined for a code inside no family this adapter knows.\n */\nexport function verdictOfCode(errcode) {\n const exact = CODE_VERDICTS.get(errcode) ?? FAMILY_VERDICTS.get(errcode);\n if (exact !== undefined)\n return exact;\n // `4xxxx` are parameter refusals, `5xxxx` gateway and retry classes, `6xxxx` authorization and `8xxxx` member and\n // media refusals; the platform documents each family as one behaviour.\n const family = Math.trunc(errcode / 10_000);\n if (family === 4)\n return INVALID;\n if (family === 5)\n return RETRYABLE;\n if (family === 6)\n return PERMISSION;\n if (family === 8)\n return INVALID;\n return undefined;\n}\n/**\n * Whether an `errcode` means the `access_token` was refused.\n *\n * @param errcode - the code of an answer, when it carried one.\n * @returns true for the two codes the platform documents as \"refresh and retry\".\n */\nexport function isTokenFailureCode(errcode) {\n return errcode !== undefined && TOKEN_FAILURE_CODES.has(errcode);\n}\n/**\n * Whether a failed call means the `access_token` was refused.\n *\n * @param error - the caught failure.\n * @returns true for the two codes the platform documents as \"refresh and retry\".\n */\nexport function isTokenFailure(error) {\n return error instanceof WecomApiError && isTokenFailureCode(error.errcode);\n}\n/** Whether a caught value is an abort error, including the `DOMException` a signal produces. */\nfunction isAbortError(error) {\n return ((error instanceof Error || error instanceof DOMException) &&\n error.name === 'AbortError');\n}\n/**\n * Map any failure onto the core platform taxonomy.\n *\n * @param error - the caught failure.\n * @returns the classified platform error.\n */\nexport function classifyWecomError(error) {\n if (error instanceof PlatformError)\n return error;\n if (error instanceof WecomApiError) {\n const init = {\n ...(error.status === undefined ? {} : { code: error.status }),\n cause: error,\n };\n if (error.errcode !== undefined) {\n const verdict = verdictOfCode(error.errcode) ?? RETRYABLE;\n return new PlatformError(verdict.kind, error.message, {\n ...init,\n code: error.errcode,\n published: verdict.published,\n });\n }\n if (error.status === 429) {\n // A rate limit refused the request; the platform publishes no retry delay, so none is invented.\n return new PlatformError('rate-limit', error.message, {\n ...init,\n published: 'no',\n });\n }\n // A body that is not JSON came from something in front of the API (a gateway page, a cut-off answer), and a 5xx or\n // a transport failure may still have reached the platform.\n if (error.status === undefined || error.nonJson || error.status >= 500) {\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (error.status !== undefined && error.status >= 400) {\n return new PlatformError('invalid', error.message, {\n ...init,\n published: 'no',\n });\n }\n return new PlatformError('retryable', error.message, {\n ...init,\n published: 'unknown',\n });\n }\n if (isAbortError(error)) {\n return new PlatformError('fatal', error.message, {\n published: 'unknown',\n cause: error,\n });\n }\n const message = error instanceof Error ? error.message : String(error);\n return new PlatformError('retryable', `wecom: request failed: ${message}`, {\n published: 'unknown',\n cause: error,\n });\n}\n//# sourceMappingURL=errors.js.map","/** Failure to confirm the configured application identity. */\nexport class WecomIdentityError extends Error {\n constructor(message) {\n super(message);\n this.name = 'WecomIdentityError';\n }\n}\n/**\n * Verify an `agent/get` answer against the configured `AgentID` and turn it into `bot.user`.\n *\n * `bot.id` and `selfId` are fixed at construction, so the application is identified from configuration rather than\n * discovered; this call proves the credentials belong to that application. A mismatch is a configuration error that no\n * retry repairs.\n *\n * @param agentId - the configured `AgentID`.\n * @param answer - the `GET /cgi-bin/agent/get` answer.\n * @returns the bot's own user, with the name and logo the platform reports.\n * @throws WecomIdentityError when the answer names another application.\n */\nexport function verifyIdentity(agentId, answer) {\n if (answer.agentid === undefined ||\n Number(answer.agentid) !== Number(agentId)) {\n throw new WecomIdentityError(`wecom: agentId is ${agentId} but agent/get returned ${String(answer.agentid)}`);\n }\n return {\n id: agentId,\n ...(answer.name === undefined ? {} : { name: answer.name }),\n ...(answer.square_logo_url === undefined\n ? {}\n : { avatar: answer.square_logo_url }),\n isBot: true,\n };\n}\n//# sourceMappingURL=identity.js.map","import { isTokenFailure, isTokenFailureCode, WecomApiError } from \"./errors.js\";\n/** Endpoints that mint a token themselves and therefore carry no `access_token`. */\nconst CREDENTIAL_PATHS = new Set(['/cgi-bin/gettoken']);\n/** How much of a non-JSON answer is kept in the error and the log; enough to recognise a gateway page. */\nconst BODY_PREFIX_BYTES = 512;\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** Whether a failed `ctx.http` call was the caller's cancellation rather than a transport failure. */\nfunction isCancellation(cause, signal) {\n if (signal?.aborted === true)\n return true;\n if ((cause instanceof Error || cause instanceof DOMException) &&\n cause.name === 'AbortError') {\n return true;\n }\n return signal?.reason !== undefined && cause === signal.reason;\n}\n/** A cancelled request rejects with the signal's reason, so the classifier sees the cancellation itself. */\nfunction cancellation(cause, signal) {\n return signal?.aborted === true ? signal.reason : cause;\n}\n/** One JSON object, when the value is a plain object. */\nfunction asRecord(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? value\n : undefined;\n}\n/**\n * The absolute URL of one endpoint.\n *\n * @param config - the adapter configuration holding the API root.\n * @param path - endpoint path under the root, e.g. `/cgi-bin/message/send`.\n * @returns the absolute request URL.\n */\nexport function endpointOf(config, path) {\n return `${config.apiBaseUrl.replace(/\\/+$/, '')}${path}`;\n}\n/** The request URL with the token and the query parameters applied. */\nfunction urlOf(endpoint, path, params, token) {\n const url = new URL(endpointOf(endpoint.config, path));\n if (token !== undefined)\n url.searchParams.set('access_token', token);\n for (const [name, value] of Object.entries(params ?? {})) {\n if (value !== undefined)\n url.searchParams.set(name, String(value));\n }\n return url;\n}\n/**\n * The access token of one request, or undefined for the endpoint that mints it.\n *\n * @param endpoint - the adapter whose token cache the call uses.\n * @param path - endpoint path.\n * @returns the token to carry, if the endpoint needs one.\n */\nasync function authorization(endpoint, path) {\n if (CREDENTIAL_PATHS.has(path))\n return undefined;\n return await endpoint.tokens.get();\n}\n/** Read one answer body as text, turning a cancelled read into a cancellation. */\nasync function readText(response, path, signal) {\n try {\n return await response.text();\n }\n catch (cause) {\n // Reading the body fails when the caller cancelled mid-answer; that is still a cancellation.\n if (isCancellation(cause, signal))\n throw cancellation(cause, signal);\n throw new WecomApiError(`wecom: ${path} answered ${response.status} but its body could not be read`, { status: response.status, cause });\n }\n}\n/** Send one request and unwrap its `{ errcode, errmsg }` envelope. */\nasync function send(endpoint, method, path, config, token) {\n let response;\n try {\n response = await endpoint.ctx.http(urlOf(endpoint, path, config.params, token), {\n method,\n ...(config.data === undefined ? {} : { data: config.data }),\n ...(config.signal === undefined ? {} : { signal: config.signal }),\n });\n }\n catch (cause) {\n if (isCancellation(cause, config.signal)) {\n throw cancellation(cause, config.signal);\n }\n throw new WecomApiError(`wecom: ${method} ${path} request failed: ${messageOf(cause)}`, { cause });\n }\n const text = await readText(response, path, config.signal);\n let body;\n let nonJson = false;\n if (text !== '') {\n try {\n body = JSON.parse(text);\n }\n catch {\n nonJson = true;\n }\n }\n const record = asRecord(body);\n const errcode = record?.errcode === undefined ? undefined : Number(record.errcode);\n const errmsg = typeof record?.errmsg === 'string' ? record.errmsg : undefined;\n const suffix = (errcode === undefined ? '' : ` (${errcode})`) +\n (errmsg === undefined ? '' : `: ${errmsg}`);\n const detail = {\n status: response.status,\n ...(text === '' ? {} : { bodyText: text.slice(0, BODY_PREFIX_BYTES) }),\n ...(errmsg === undefined ? {} : { errmsg }),\n };\n if (response.status < 200 || response.status >= 300 || nonJson) {\n throw new WecomApiError(`wecom: ${method} ${path} answered ${response.status}${suffix}`, { ...detail, nonJson });\n }\n if (errcode !== undefined && errcode !== 0) {\n // A business refusal arrives as HTTP 200; reading that as a success would lose the refusal.\n throw new WecomApiError(`wecom: ${method} ${path} answered ${response.status}${suffix}`, { ...detail, errcode });\n }\n return body;\n}\n/**\n * Call one WeCom endpoint.\n *\n * A call refused for its `access_token` re-mints the token and is retried once; every other failure is thrown as the\n * `WecomApiError` `classify` maps. A cancelled call rejects with the cancellation itself.\n *\n * @param endpoint - the adapter whose configuration and token cache the call uses.\n * @param method - HTTP method.\n * @param path - endpoint path under the API root.\n * @param config - body, query parameters and cancellation of the call.\n * @returns the unwrapped JSON answer.\n * @throws WecomApiError when the platform refused the call or did not answer with JSON.\n */\nexport async function invoke(endpoint, method, path, config = {}) {\n const token = await authorization(endpoint, path);\n try {\n return await send(endpoint, method, path, config, token);\n }\n catch (error) {\n // The platform documents that a token may be invalidated early, so a refused call is retried once with a fresh one.\n if (!isTokenFailure(error) || token === undefined)\n throw error;\n endpoint.tokens.invalidate();\n return await send(endpoint, method, path, config, await authorization(endpoint, path));\n }\n}\n/** One download attempt with one token. */\nasync function attempt(endpoint, path, params, signal) {\n const token = await endpoint.tokens.get();\n try {\n return await endpoint.ctx.http(urlOf(endpoint, path, params, token), {\n method: 'GET',\n ...(signal === undefined ? {} : { signal }),\n });\n }\n catch (cause) {\n if (isCancellation(cause, signal))\n throw cancellation(cause, signal);\n throw new WecomApiError(`wecom: GET ${path} request failed: ${messageOf(cause)}`, { cause });\n }\n}\n/**\n * Whether a download answer is the platform's token refusal rather than bytes.\n *\n * `media/get` answers the bytes on success and an `{ errcode }` JSON envelope on a refusal, still with HTTP 200, so the\n * token races the same invalidation a JSON call does.\n */\nasync function isTokenRefusal(response) {\n const type = response.headers.get('content-type') ?? '';\n if (!type.includes('application/json'))\n return false;\n try {\n const body = asRecord(await response.clone().json());\n const errcode = body?.errcode === undefined ? undefined : Number(body.errcode);\n return isTokenFailureCode(errcode);\n }\n catch {\n // An unreadable answer is not a token refusal; the caller maps it as a failed download.\n return false;\n }\n}\n/**\n * Download the bytes of one inbound media object.\n *\n * `media/get` answers the bytes themselves on success and a JSON `{ errcode }` envelope on failure, so the answer is\n * returned as it arrived and mapped by the caller. A refusal for the `access_token` re-mints it and retries once. A\n * cancelled download rejects with the cancellation itself.\n *\n * @param endpoint - the adapter whose credentials the download uses.\n * @param path - endpoint path under the API root.\n * @param params - query parameters of the download.\n * @param signal - cancellation.\n * @returns the answer, status and headers included.\n */\nexport async function download(endpoint, path, params, signal) {\n const response = await attempt(endpoint, path, params, signal);\n if (!(await isTokenRefusal(response)))\n return response;\n endpoint.tokens.invalidate();\n return await attempt(endpoint, path, params, signal);\n}\n//# sourceMappingURL=request.js.map","import { download, invoke } from \"./request.js\";\n/**\n * The mapped WeCom REST surface: one method per platform endpoint of the adapter's scope, and nothing hand-written on\n * top of it.\n *\n * Every method goes through `request.ts`, so `access_token` injection, `errcode` unwrapping and the refresh-and-retry of\n * a refused token are identical for all of them.\n */\nexport class Internal {\n bot;\n constructor(bot) {\n this.bot = bot;\n }\n /**\n * Exchange the enterprise credentials for an application `access_token`.\n *\n * @param input - the enterprise id and the application secret.\n * @returns the token envelope, with `expires_in`.\n */\n async getToken(input) {\n return await invoke(this.bot, 'GET', '/cgi-bin/gettoken', {\n params: { corpid: input.corpid, corpsecret: input.corpsecret },\n });\n }\n /**\n * Read one application's own description.\n *\n * @param input - the numeric `AgentID`.\n * @returns the application envelope, with `name` and `square_logo_url`.\n */\n async agentGet(input) {\n return await invoke(this.bot, 'GET', '/cgi-bin/agent/get', {\n params: { agentid: input.agentid },\n });\n }\n /**\n * Read one member of the enterprise address book.\n *\n * @param input - the member userid.\n * @returns the member envelope, with `name` when the application may see it.\n */\n async userGet(input) {\n return await invoke(this.bot, 'GET', '/cgi-bin/user/get', {\n params: { userid: input.userid },\n });\n }\n /**\n * Push one application message.\n *\n * @param input - the exact `message/send` body.\n * @returns the send envelope, with `msgid` and the invalid-recipient lists.\n */\n async messageSend(input) {\n return await invoke(this.bot, 'POST', '/cgi-bin/message/send', {\n data: input,\n });\n }\n /**\n * Upload one temporary media file.\n *\n * @param input - the platform media type (`image`, `voice`, `video`, `file`) and the multipart form.\n * @returns the upload envelope, with `media_id` and `created_at`.\n */\n async mediaUpload(input, signal) {\n return await invoke(this.bot, 'POST', '/cgi-bin/media/upload', {\n params: { type: input.type },\n data: input.media,\n ...(signal === undefined ? {} : { signal }),\n });\n }\n /**\n * Download the bytes of one temporary media file.\n *\n * @param input - the `media_id` the callback carried.\n * @param signal - cancellation.\n * @returns the answer as it arrived: the bytes, or the platform's JSON refusal.\n */\n async mediaGet(input, signal) {\n return await download(this.bot, '/cgi-bin/media/get', { media_id: input.media_id }, signal);\n }\n /**\n * Recall one published application message.\n *\n * @param input - the `msgid` the send answer carried.\n * @returns the status envelope.\n */\n async messageRecall(input) {\n return await invoke(this.bot, 'POST', '/cgi-bin/message/recall', {\n data: { msgid: input.msgid },\n });\n }\n /**\n * Update one button-interaction card, within the platform's 72-hour, single-use window.\n *\n * @param input - the recipients, the card identity and the new card or button.\n * @returns the status envelope.\n */\n async updateTemplateCard(input) {\n return await invoke(this.bot, 'POST', '/cgi-bin/message/update_template_card', {\n data: input,\n });\n }\n /**\n * Send one message into an application group chat.\n *\n * @param input - the group chat id and the message fields.\n * @returns the send envelope.\n */\n async appchatSend(input) {\n return await invoke(this.bot, 'POST', '/cgi-bin/appchat/send', {\n data: input,\n });\n }\n}\n//# sourceMappingURL=internal.js.map","/**\n * Media in both directions.\n *\n * Outbound, the platform has a real upload endpoint: the bytes are fetched, posted to `media/upload` as a multipart form\n * and the returned `media_id` is what a `message/send` of type `image`/`voice`/`video`/`file` carries. The id lives three\n * days, so the resolved resource carries an `expiresAt` and the core uploads the same content again after that instead of\n * reusing an id the platform has already dropped.\n *\n * Inbound, the callback names only a `MediaId`; the bytes are read on demand from `media/get` through the bot's own\n * `satori:` route.\n */\nimport { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\n/** How long a temporary `media_id` stays readable: the platform documents three days. */\nexport const MEDIA_LIFETIME_MS = 3 * 24 * 60 * 60 * 1_000;\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/**\n * The platform upload type of one resource kind.\n *\n * @param kind - the resource kind of the element.\n * @returns `image`, `voice`, `video` or `file`; the platform names audio `voice`.\n */\nexport function mediaTypeOf(kind) {\n switch (kind) {\n case 'image':\n return 'image';\n case 'audio':\n return 'voice';\n case 'video':\n return 'video';\n case 'file':\n return 'file';\n }\n}\n/** File name of a source, for the multipart part of an upload. */\nfunction fileNameOf(ref, fetchedName, mime) {\n if (ref.meta.name !== undefined && ref.meta.name !== '')\n return ref.meta.name;\n if (fetchedName !== undefined && fetchedName !== '')\n return fetchedName;\n const subtype = mime?.split('/')[1]?.split(';')[0];\n return `wecom-${ref.kind}${subtype === undefined ? '' : `.${subtype}`}`;\n}\n/**\n * Upload one outbound attachment and return the `media_id` a send references.\n *\n * @param bot - the adapter whose credentials the upload uses.\n * @param ref - the unresolved resource.\n * @param ctx - fetch context of the send pipeline.\n * @returns the platform media key, with the three-day expiry the core caches against.\n * @throws PlatformError with an unknown outcome when the platform accepted the upload without returning an id.\n */\nexport async function uploadMedia(bot, ref, ctx) {\n const fetched = await ctx.fetch(ref.src, ctx.signal);\n const mime = ref.meta.mime ?? fetched.mime;\n const name = fileNameOf(ref, fetched.name, mime);\n const type = mediaTypeOf(ref.kind);\n const form = new FormData();\n form.append('media', new Blob([fetched.data], mime === undefined ? {} : { type: mime }), name);\n const answer = await bot.internal.mediaUpload({ type, media: form }, ctx.signal);\n if (answer.media_id === undefined || answer.media_id === '') {\n // The request reached the platform and it answered success, but no reusable key came back.\n throw new PlatformError('invalid', 'wecom: /cgi-bin/media/upload answered without a media_id', { published: 'unknown' });\n }\n const createdAt = answer.created_at;\n return {\n key: answer.media_id,\n ...(typeof createdAt === 'number' && Number.isFinite(createdAt)\n ? { expiresAt: createdAt * 1_000 + MEDIA_LIFETIME_MS }\n : {}),\n extra: {\n type,\n name,\n ...(mime === undefined ? {} : { mime }),\n size: fetched.data.byteLength,\n },\n };\n}\n/**\n * Serve the bytes of one inbound media object.\n *\n * A `media_id` the platform no longer accepts (it lives three days), a file above the 20 MB the plain download serves and\n * a transport failure all answer `502`: the stored element keeps its label, but its bytes are gone.\n *\n * @param bot - the receiving adapter.\n * @param mediaId - the `MediaId` the callback carried.\n * @returns the bytes with their own headers, or the refusal status.\n */\nexport async function serveMedia(bot, mediaId) {\n let response;\n try {\n response = await bot.internal.mediaGet({ media_id: mediaId });\n }\n catch (error) {\n bot.ctx.logger.warn('wecom: media %s could not be downloaded: %s', mediaId, messageOf(error));\n return new Response(null, { status: 502 });\n }\n const contentType = response.headers.get('content-type') ?? '';\n if (!response.ok || contentType.includes('application/json')) {\n // A failure of this endpoint is still HTTP 200 with an `{ errcode }` envelope (40007 once the id expired).\n bot.ctx.logger.warn('wecom: media %s answered %s: %s', mediaId, String(response.status), contentType.includes('application/json')\n ? await response.text()\n : contentType);\n return new Response(null, { status: 502 });\n }\n const headers = new Headers();\n if (contentType !== '')\n headers.set('content-type', contentType);\n const disposition = response.headers.get('content-disposition');\n if (disposition !== null)\n headers.set('content-disposition', disposition);\n return new Response(response.body, { status: response.status, headers });\n}\n//# sourceMappingURL=media.js.map","/**\n * Shared types and the draft machinery of the single `markdown` mode.\n *\n * A WeCom application message is one `message/send` call, and its `msgtype` decides what it can carry: `markdown` holds\n * the formatted body, `image`/`voice`/`video`/`file` hold one `media_id` each, and `template_card` holds the buttons.\n * A draft is therefore exactly one platform message: the body is split at the documented 2,048 bytes, every media\n * element becomes a message of its own, and a message with buttons gets a card message after its body.\n */\nimport { randomBytes } from 'node:crypto';\nimport { INTERACTION_DROPPED } from '@deepseek-ai/cordis-plugin-im-core';\nimport { isPhrasingContainer } from '@deepseek-ai/satori-element';\n/** The platform's documented bounds, and nothing else. */\nexport const WECOM_LIMITS = {\n /** `text.content` and `markdown.content`: at most 2,048 bytes, counted as UTF-8. */\n payloadBytes: 2_048,\n /** `message/recall` accepts a message up to 24 hours after it was sent. */\n deleteWindow: 24 * 60 * 60 * 1_000,\n /** `button_list` of a `button_interaction` card holds at most six buttons. */\n buttonsRow: 6,\n /** The card has one button row. */\n buttonRows: 1,\n};\n/** The word joiner a card title falls back to: the platform requires `main_title`, and content is never empty. */\nexport const CARD_TITLE_FALLBACK = '\\u2060';\n/** The process-wide random segment of every `task_id`, in base 36. */\nlet bootSalt = randomBytes(6).readUIntBE(0, 6).toString(36);\n/** The sequence within this process; `task_id` must not repeat inside one application. */\nlet taskSequence = 0;\n/**\n * Pin the process-random segment of every `task_id`.\n *\n * The platform requires the id to be unique inside one application, so it is seeded from process entropy. A test that\n * compares serialized request bodies pins the segment instead, so two runs produce the same payloads; the counter keeps\n * advancing, because two cards of one run still must not share an id.\n *\n * @param salt - the segment to use: `0-9a-zA-Z_-`, at most 128 bytes together with the rest of the id.\n */\nexport function pinTaskIdSalt(salt) {\n bootSalt = salt;\n}\n/**\n * The `task_id` of one card.\n *\n * The platform requires the id to be unique within the application, so a counter alone would collide with the ids of the\n * previous process after a restart; the random boot segment makes the pair unique across restarts.\n *\n * @returns an id the platform accepts: `0-9a-zA-Z_-` only, at most 128 bytes.\n */\nexport function nextTaskId() {\n taskSequence += 1;\n return `dsh-${bootSalt}-${taskSequence}`;\n}\n/**\n * Report inline media that moves out of its text run into a message of its own.\n *\n * @param el - the media element.\n * @param ctx - the render context.\n */\nexport function reportMovedMedia(el, ctx) {\n const parent = ctx.ancestors[ctx.ancestors.length - 1];\n if (parent !== undefined && isPhrasingContainer(parent.type)) {\n ctx.report.moved.push({\n tag: el.type,\n reason: 'wecom-media-split',\n path: ctx.stableId(el),\n });\n }\n}\n/**\n * Cut one line into pieces of at most `limit` bytes, never inside a surrogate pair.\n *\n * @param text - the line to cut.\n * @param limit - the byte bound.\n * @returns the pieces, in order; concatenating them reproduces the line.\n */\nexport function hardCutBytes(text, limit) {\n const pieces = [];\n let piece = '';\n let bytes = 0;\n // `for…of` walks code points, so a surrogate pair is never split between two pieces.\n for (const character of text) {\n const size = Buffer.byteLength(character, 'utf8');\n if (bytes + size > limit && piece !== '') {\n pieces.push(piece);\n piece = '';\n bytes = 0;\n }\n piece += character;\n bytes += size;\n }\n if (piece !== '')\n pieces.push(piece);\n return pieces;\n}\n/**\n * Cut a body into chunks the platform accepts.\n *\n * Lines are accumulated while they fit; a line that would overflow closes the current chunk, and a line longer than the\n * bound is cut by bytes. A cut can land inside a formatting mark (`**`, `` ` ``), which the client then shows as literal\n * characters: the platform documents no escape syntax that would avoid it.\n *\n * @param text - the body of one logical message.\n * @param limit - the byte bound of one `markdown` message.\n * @returns one or more chunks, in order; never empty.\n */\nexport function splitMarkdownBytes(text, limit = WECOM_LIMITS.payloadBytes) {\n if (Buffer.byteLength(text, 'utf8') <= limit)\n return [text];\n const chunks = [];\n let current = '';\n let currentBytes = 0;\n const close = () => {\n if (current !== '')\n chunks.push(current);\n current = '';\n currentBytes = 0;\n };\n for (const line of text.split(/(?<=\\n)/)) {\n const lineBytes = Buffer.byteLength(line, 'utf8');\n if (currentBytes + lineBytes <= limit) {\n current += line;\n currentBytes += lineBytes;\n continue;\n }\n close();\n if (lineBytes <= limit) {\n current = line;\n currentBytes = lineBytes;\n continue;\n }\n const pieces = hardCutBytes(line, limit);\n // Everything but the last piece is one chunk of its own; the tail stays open for the next line.\n for (const piece of pieces.slice(0, -1))\n chunks.push(piece);\n current = pieces[pieces.length - 1] ?? '';\n currentBytes = Buffer.byteLength(current, 'utf8');\n }\n close();\n return chunks.length === 0 ? [''] : chunks;\n}\n/** Strip the newlines a paragraph puts around the content of one list item. */\nfunction trimEdges(nodes) {\n const out = [...nodes];\n while (out.length > 0) {\n const first = out[0];\n if (first.type !== 'text')\n break;\n const stripped = first.text.replace(/^\\n+/, '');\n if (stripped === '') {\n out.shift();\n continue;\n }\n out[0] = { type: 'text', text: stripped };\n break;\n }\n while (out.length > 0) {\n const last = out[out.length - 1];\n if (last.type !== 'text')\n break;\n const stripped = last.text.replace(/\\n+$/, '');\n if (stripped === '') {\n out.pop();\n continue;\n }\n out[out.length - 1] = { type: 'text', text: stripped };\n break;\n }\n return out;\n}\n/** Put a list marker at the start of the item's first line, or before its first media node. */\nfunction applyMarker(nodes, marker) {\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index];\n if (node.type !== 'text') {\n nodes.splice(index, 0, { type: 'text', text: marker.trimEnd() });\n return;\n }\n const leading = /^\\n*/.exec(node.text)?.[0].length ?? 0;\n if (leading < node.text.length) {\n nodes[index] = {\n type: 'text',\n text: `${node.text.slice(0, leading)}${marker}${node.text.slice(leading)}`,\n };\n return;\n }\n }\n}\n/** One list node, expanded into one line per item. */\nfunction flattenList(node, depth) {\n const out = [];\n const indent = ' '.repeat(depth);\n let number = node.start;\n node.items.forEach((item, index) => {\n const marker = node.ordered ? `${indent}${number++}. ` : `${indent}- `;\n const inner = trimEdges(flattenAt(item.type === 'item' ? item.nodes : [item], depth + 1));\n if (index > 0)\n out.push({ type: 'text', text: '\\n' });\n if (inner.length === 0) {\n out.push({ type: 'text', text: marker.trimEnd() });\n return;\n }\n applyMarker(inner, marker);\n out.push(...inner);\n });\n if (out.length > 0)\n out.push({ type: 'text', text: '\\n' });\n return out;\n}\n/** Expand every list and item of one node stream. */\nfunction flattenAt(nodes, depth) {\n const out = [];\n for (const node of nodes) {\n switch (node.type) {\n case 'text':\n case 'media':\n case 'button':\n case 'link-button':\n out.push(node);\n break;\n case 'item':\n out.push(...flattenAt(node.nodes, depth));\n break;\n case 'list': {\n const last = out[out.length - 1];\n if (last !== undefined &&\n !(last.type === 'text' && last.text.endsWith('\\n'))) {\n out.push({ type: 'text', text: '\\n' });\n }\n out.push(...flattenList(node, depth));\n break;\n }\n }\n }\n return out;\n}\n/**\n * Expand list and item nodes into the flat node stream {@link assembleDraft} splits into messages.\n *\n * @param nodes - rendered nodes, in document order.\n * @returns the same content with every list marker applied and media nodes kept in place.\n */\nexport function flattenNodes(nodes) {\n return flattenAt(nodes, 0);\n}\n/** The media draft of one media node. */\nfunction mediaDraftOf(node) {\n return {\n kind: 'media',\n media: node.media,\n ref: node.ref,\n ...(node.name === undefined ? {} : { name: node.name }),\n };\n}\n/**\n * Fold a node stream into platform messages.\n *\n * The text buffer is split by bytes and closed before every media element; the collected buttons become one card\n * message after the body, and a seventh button onwards degrades to a `[label]` line in the body. The title of the\n * envelope stays in the body as a bold line and becomes the card's `main_title` when there is a card, so a title is\n * never lost on a message without buttons.\n *\n * @param nodes - rendered nodes, in document order.\n * @param envelope - the root `<title>`, if the content carried one.\n * @param ctx - the render context, for the split and drop reports.\n * @returns one draft per platform message, in send order; never empty.\n */\nexport function assembleDraft(nodes, envelope, ctx) {\n const drafts = [];\n const buttons = [];\n let buffer = '';\n let firstLine = '';\n let split = 0;\n const noteFirstLine = (text) => {\n if (firstLine !== '')\n return;\n for (const line of text.split('\\n')) {\n const trimmed = line.trim();\n if (trimmed !== '') {\n firstLine = trimmed;\n return;\n }\n }\n };\n const flushText = () => {\n // The blank lines a paragraph puts around its text are separators inside the body, not at its edges.\n const text = buffer.replace(/^\\n+/, '').replace(/\\n+$/, '');\n buffer = '';\n if (text === '')\n return;\n noteFirstLine(text);\n const chunks = splitMarkdownBytes(text);\n split += chunks.length - 1;\n for (const chunk of chunks)\n drafts.push({ kind: 'markdown', content: chunk });\n };\n const title = envelope.title;\n const titleText = title === undefined ? '' : ctx.text(title.children).trim();\n if (titleText !== '') {\n buffer += `**${titleText}**`;\n const subtitle = title?.attrs.subtitle;\n if (subtitle !== undefined && subtitle !== '')\n buffer += `\\n${subtitle}`;\n buffer += '\\n';\n }\n for (const node of flattenNodes(nodes)) {\n switch (node.type) {\n case 'text':\n buffer += node.text;\n break;\n case 'media':\n flushText();\n drafts.push(mediaDraftOf(node));\n break;\n case 'button':\n buttons.push({ text: node.text, key: node.key });\n break;\n case 'link-button':\n buttons.push({ text: node.text, href: node.href });\n break;\n default:\n break;\n }\n }\n if (buttons.length > WECOM_LIMITS.buttonsRow) {\n // The platform refuses a seventh button, so the overflow becomes text instead of disappearing.\n for (const button of buttons.splice(WECOM_LIMITS.buttonsRow)) {\n const label = 'key' in button ? button.key : button.text;\n ctx.report.dropped.push({\n what: `button:${label}`,\n reason: INTERACTION_DROPPED,\n });\n buffer += `[${button.text}]\\n`;\n }\n }\n if (buttons.length > 0) {\n flushText();\n drafts.push({\n kind: 'card',\n title: titleText !== ''\n ? titleText\n : firstLine !== ''\n ? firstLine\n : CARD_TITLE_FALLBACK,\n taskId: nextTaskId(),\n buttons: [...buttons],\n });\n // The card is an extra platform message after a body that already exists.\n if (drafts.length > 1)\n split += 1;\n }\n else {\n flushText();\n }\n ctx.report.split += split;\n if (drafts.length === 0)\n drafts.push({ kind: 'markdown', content: CARD_TITLE_FALLBACK });\n return drafts;\n}\n/** One resolved resource key of a prepared draft. */\nfunction resolvedKey(prepared, ref) {\n const resolved = prepared.resolved.get(ref);\n if (resolved === undefined) {\n throw new Error('wecom: media was not prepared before serialize');\n }\n return resolved.key;\n}\n/**\n * Build the exact request body of one prepared draft.\n *\n * @param prepared - the draft with its resource keys resolved.\n * @param ctx - the send context: the target chat names the `touser` recipient.\n * @param agentId - the numeric `AgentID` every send carries.\n * @returns the `message/send` body.\n */\nexport function serializeDraft(prepared, ctx, agentId) {\n const touser = ctx.target.chat.id;\n const draft = prepared.draft;\n switch (draft.kind) {\n case 'markdown':\n return {\n touser,\n agentid: agentId,\n msgtype: 'markdown',\n markdown: { content: draft.content },\n };\n case 'media': {\n const mediaId = resolvedKey(prepared, draft.ref);\n switch (draft.media) {\n case 'image':\n return {\n touser,\n agentid: agentId,\n msgtype: 'image',\n image: { media_id: mediaId },\n };\n case 'voice':\n return {\n touser,\n agentid: agentId,\n msgtype: 'voice',\n voice: { media_id: mediaId },\n };\n case 'file':\n return {\n touser,\n agentid: agentId,\n msgtype: 'file',\n file: { media_id: mediaId },\n };\n case 'video':\n return {\n touser,\n agentid: agentId,\n msgtype: 'video',\n video: {\n media_id: mediaId,\n ...(draft.name === undefined ? {} : { title: draft.name }),\n },\n };\n }\n throw new Error('wecom: unknown media kind');\n }\n case 'card':\n return {\n touser,\n agentid: agentId,\n msgtype: 'template_card',\n template_card: {\n card_type: 'button_interaction',\n main_title: { title: draft.title },\n button_list: draft.buttons.map((button) => 'key' in button\n ? { text: button.text, key: button.key }\n : { text: button.text, type: 1, url: button.href }),\n task_id: draft.taskId,\n },\n };\n }\n}\n/**\n * Hard platform limits of one draft, checked before any request.\n *\n * Splitting already keeps the body inside the byte bound and the card inside the button bound; the checks stay as the\n * only place the adapter refuses a draft the platform would answer `45002` for.\n *\n * @param draft - the assembled draft.\n * @returns every violation the platform would refuse.\n */\nexport function checkDraft(draft) {\n switch (draft.kind) {\n case 'markdown': {\n const bytes = Buffer.byteLength(draft.content, 'utf8');\n if (bytes <= WECOM_LIMITS.payloadBytes)\n return [];\n return [\n {\n kind: 'size',\n key: 'limit.payload.bytes',\n limit: WECOM_LIMITS.payloadBytes,\n actual: bytes,\n message: `WeCom markdown accepts ${WECOM_LIMITS.payloadBytes} bytes, got ${bytes}`,\n },\n ];\n }\n case 'card': {\n const violations = [];\n if (draft.buttons.length > WECOM_LIMITS.buttonsRow) {\n violations.push({\n kind: 'size',\n key: 'limit.buttons.row',\n limit: WECOM_LIMITS.buttonsRow,\n actual: draft.buttons.length,\n message: `WeCom cards accept ${WECOM_LIMITS.buttonsRow} buttons, got ${draft.buttons.length}`,\n });\n }\n if (draft.taskId === '') {\n violations.push({\n kind: 'shape',\n message: 'WeCom cards need a task_id',\n });\n }\n return violations;\n }\n case 'media':\n return [];\n }\n}\n//# sourceMappingURL=shared.js.map","/**\n * `markdown` mode: the single outbound representation of an application message.\n *\n * The body is sent verbatim — the platform documents a markdown subset but no escape syntax, so nothing is escaped and\n * a pair of `*` in the text may render as bold. Headings, bold, links, inline code, block quotes, font colours,\n * mentions, lists and media have a native form; italic, underline, strike-through, spoilers, code blocks, rules,\n * tables, panels and form controls take the core fallback, which keeps their text and records the degradation.\n * Buttons become one `template_card` message after the body.\n */\nimport { ElementRegistry } from '@deepseek-ai/cordis-plugin-im-core';\nimport { assembleDraft, checkDraft, reportMovedMedia, serializeDraft, WECOM_LIMITS, } from \"./shared.js\";\n/** How a `span[color]` value maps onto the three colours the platform paints. */\nconst FONT_COLOR = {\n default: undefined,\n muted: 'comment',\n info: 'info',\n success: 'info',\n warning: 'warning',\n danger: 'warning',\n};\n/** The text run of rendered children and the nodes that cannot ride inside it. */\nfunction textRun(nodes) {\n let text = '';\n const rest = [];\n for (const node of nodes) {\n if (node.type === 'text')\n text += node.text;\n else\n rest.push(node);\n }\n return { text, rest };\n}\n/** One inline mark around the rendered children, keeping any media of the subtree outside it. */\nfunction marked(children, ctx, open, close = open) {\n const run = textRun(ctx.render(children));\n if (run.text === '')\n return run.rest;\n return [{ type: 'text', text: `${open}${run.text}${close}` }, ...run.rest];\n}\n/** One rendered line: the platform has no multiline construct, so embedded newlines become spaces. */\nfunction oneLine(text) {\n return text.replace(/\\s*\\n+\\s*/g, ' ').trim();\n}\n/** One media message; a media element standing in phrasing content is reported as moved, not as degraded. */\nfunction mediaNode(media, kind, el, ctx, src, meta) {\n reportMovedMedia(el, ctx);\n const name = meta.name !== undefined && meta.name !== '' ? meta.name : undefined;\n return {\n type: 'media',\n media,\n ref: ctx.resource(kind, src, meta),\n ...(name === undefined ? {} : { name }),\n };\n}\n/** The handler of one heading level: `#` repeated, then the text on a single line. */\nfunction heading(level) {\n return (el, ctx) => {\n const run = textRun(ctx.render(el.children));\n const text = oneLine(run.text);\n if (text === '')\n return run.rest;\n // A heading has to start a line, and it ends without one so the next line follows directly below it.\n return [\n { type: 'text', text: `\\n${'#'.repeat(level)} ${text}` },\n ...run.rest,\n ];\n };\n}\n/** The handler of one list: its items are collected into a list node the assembler expands into lines. */\nfunction list(ordered, el, ctx) {\n return {\n type: 'list',\n ordered,\n start: el.type === 'ol' ? (el.attrs.start ?? 1) : 1,\n items: ctx.render(el.children),\n };\n}\n/**\n * Build the `markdown` mode.\n *\n * @param config - the adapter configuration; it carries the numeric `AgentID` every request body repeats.\n * @returns the single mode this adapter registers.\n */\nexport function createMarkdownMode(config) {\n const elements = new ElementRegistry()\n .register('text', (el) => ({ type: 'text', text: el.attrs.content }))\n .register('br', () => ({ type: 'text', text: '\\n' }))\n // Paragraphs get a blank line between them; a paragraph that already ends on a newline is not padded twice.\n .register('p', (el, ctx) => {\n const nodes = ctx.render(el.children);\n const run = textRun(nodes);\n const out = [{ type: 'text', text: '\\n' }, ...nodes];\n if (!run.text.endsWith('\\n'))\n out.push({ type: 'text', text: '\\n' });\n return out;\n })\n .register('h1', heading(1))\n .register('h2', heading(2))\n .register('h3', heading(3))\n .register('h4', heading(4))\n .register('h5', heading(5))\n .register('h6', heading(6))\n .register('b', (el, ctx) => marked(el.children, ctx, '**'))\n .register('code', (el, ctx) => {\n // The platform documents no multiline inline code, so the newlines of the subtree become spaces.\n const text = oneLine(ctx.text(el.children));\n return text === '' ? [] : [{ type: 'text', text: `\\`${text}\\`` }];\n })\n .register('a', (el, ctx) => {\n const run = textRun(ctx.render(el.children));\n const label = run.text.trim() === '' ? el.attrs.href : run.text;\n return [\n { type: 'text', text: `[${label}](${el.attrs.href})` },\n ...run.rest,\n ];\n })\n .register('span', (el, ctx) => {\n const color = FONT_COLOR[el.attrs.color ?? 'default'];\n const run = textRun(ctx.render(el.children));\n if (run.text === '')\n return run.rest;\n if (color === undefined)\n return [{ type: 'text', text: run.text }, ...run.rest];\n return [\n { type: 'text', text: `<font color=\"${color}\">${run.text}</font>` },\n ...run.rest,\n ];\n }, { variants: ['color'] })\n // Application messages have no mention mechanism: the text is shown and nobody is notified.\n .register('at', (el) => ({\n type: 'text',\n text: `@${el.attrs.name ?? el.attrs.id ?? ''}`,\n }), { variants: ['user'] })\n .register('blockquote', (el, ctx) => {\n const run = textRun(ctx.render(el.children));\n // The paragraphs of the subtree end and start on newlines; a quote does not spell those as empty quoted lines.\n const source = run.text.replace(/^\\n+/, '').replace(/\\n+$/, '');\n if (source === '')\n return run.rest;\n const quoted = source\n .split('\\n')\n .map((line) => `> ${line}`)\n .join('\\n');\n return [{ type: 'text', text: quoted }, ...run.rest];\n })\n .register('ul', (el, ctx) => list(false, el, ctx))\n .register('ol', (el, ctx) => list(true, el, ctx))\n .register('li', (el, ctx) => ({\n type: 'item',\n nodes: ctx.render(el.children),\n }))\n .register('img', (el, ctx) => mediaNode('image', 'image', el, ctx, el.attrs.src, {}), { variants: ['inline'] })\n .register('audio', (el, ctx) => mediaNode('voice', 'audio', el, ctx, el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n ...(el.attrs.duration === undefined\n ? {}\n : { duration: el.attrs.duration }),\n }))\n .register('video', (el, ctx) => mediaNode('video', 'video', el, ctx, el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n ...(el.attrs.duration === undefined\n ? {}\n : { duration: el.attrs.duration }),\n }))\n .register('file', (el, ctx) => mediaNode('file', 'file', el, ctx, el.attrs.src, {\n ...(el.attrs.name === undefined ? {} : { name: el.attrs.name }),\n ...(el.attrs.size === undefined ? {} : { size: el.attrs.size }),\n }))\n .register('button', (el, ctx) => {\n const text = ctx.text(el.children).trim();\n const attrs = el.attrs;\n if (attrs.type === 'link') {\n return {\n type: 'link-button',\n text: text === '' ? attrs.href : text,\n href: attrs.href,\n };\n }\n if (attrs.type === 'action' || attrs.type === 'submit') {\n return {\n type: 'button',\n key: attrs.id,\n text: text === '' ? attrs.id : text,\n };\n }\n // Only `action` and `link` are declared, so the engine lowers an input button before this handler runs; the\n // inline-code form keeps the command readable.\n return { type: 'text', text: `\\`${attrs.text}\\`` };\n }, { variants: ['action', 'link'] })\n .envelope('title');\n return {\n id: 'markdown',\n elements,\n limits: {\n 'limit.payload.bytes': WECOM_LIMITS.payloadBytes,\n 'limit.delete.window': WECOM_LIMITS.deleteWindow,\n 'limit.buttons.row': WECOM_LIMITS.buttonsRow,\n 'limit.buttons.rows': WECOM_LIMITS.buttonRows,\n },\n assemble: (nodes, envelope, ctx) => assembleDraft(nodes, envelope, ctx),\n serialize: (prepared, ctx) => serializeDraft(prepared, ctx, Number(config.agentId)),\n check: (draft) => checkDraft(draft),\n };\n}\n//# sourceMappingURL=markdown.js.map","/**\n * Outbound: one `message/send` per draft, one recall per published part, and the member read of `im_members`.\n *\n * The answer is an HTTP 200 envelope whose `errcode` the transport has already checked, so what is left here is the part\n * the platform reports without failing: a recipient that does not exist (`invaliduser`), one that exists but has no\n * licence (`unlicenseduser`) and an accepted request that returned no `msgid`. Reporting any of those as a success would\n * tell the host a message was delivered when the platform dropped it.\n */\nimport { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';\n/** One `|`-separated recipient list of a send answer, as a set of userids. */\nfunction listOf(value) {\n if (value === undefined)\n return [];\n return value\n .split('|')\n .map((item) => item.trim())\n .filter((item) => item !== '');\n}\n/** The media id a payload carries, when the payload is a media message. */\nfunction mediaIdOf(payload) {\n switch (payload.msgtype) {\n case 'markdown':\n case 'template_card':\n return undefined;\n case 'image':\n return payload.image.media_id;\n case 'voice':\n return payload.voice.media_id;\n case 'video':\n return payload.video.media_id;\n case 'file':\n return payload.file.media_id;\n }\n}\n/**\n * Send one serialized payload and report the part the platform created.\n *\n * @param deps - the adapter's API surface.\n * @param payload - one `message/send` body.\n * @param target - the chat the payload goes to; its id is the `touser` recipient as well.\n * @param ctx - core send context: `quote` is present on every part, and only part 0 records it.\n * @returns the published part.\n * @throws PlatformError when the one addressee was skipped, or when the answer carried no `msgid`.\n */\nexport async function sendPayload(deps, payload, target, ctx) {\n const answer = await deps.internal.messageSend(payload);\n const recipient = target.chat.id;\n if (listOf(answer.invaliduser).includes(recipient)) {\n // `errcode` was 0 and the message went to nobody: the one addressee is not in the application's visible range.\n throw new PlatformError('not-found', `wecom: ${recipient} does not exist or is outside the application's visible range`, { published: 'no', code: 'invaliduser' });\n }\n if (listOf(answer.unlicenseduser).includes(recipient)) {\n throw new PlatformError('permission', `wecom: ${recipient} has no licence for the application`, { published: 'no', code: 'unlicenseduser' });\n }\n const msgid = answer.msgid;\n if (msgid === undefined || msgid === '') {\n // The platform accepted the request but returned no id: the message may be there, with nothing left to recall it by.\n throw new PlatformError('invalid', 'wecom: message/send answered without a msgid', { published: 'unknown' });\n }\n const mediaId = mediaIdOf(payload);\n return {\n id: msgid,\n kind: 'message',\n time: Date.now(),\n referrer: {\n userId: recipient,\n msgId: msgid,\n ...(ctx.index === 0 && ctx.quote !== undefined\n ? { quotedMessageId: ctx.quote }\n : {}),\n },\n raw: {\n msgtype: payload.msgtype,\n ...(mediaId === undefined ? {} : { mediaId }),\n ...(payload.msgtype === 'template_card'\n ? { taskId: payload.template_card.task_id }\n : {}),\n ...(answer.response_code === undefined\n ? {}\n : { responseCode: answer.response_code }),\n },\n };\n}\n/**\n * Recall one published message.\n *\n * The core only calls this inside the 24-hour window of `limit.delete.window`, and logs a refusal as a warning rather\n * than failing the caller.\n *\n * @param deps - the adapter's API surface.\n * @param part - the published part, whose id is the platform `msgid`.\n * @param _handle - unused; a recall addresses the message id alone.\n */\nexport async function deletePart(deps, part, _handle) {\n await deps.internal.messageRecall({ msgid: part.id });\n}\n/**\n * The members of one chat.\n *\n * A direct chat is the application's only conversation kind, and its one other person is the peer the chat id already\n * names; the profile request fills in the display name the callback does not carry. A userid the application may not see\n * answers `40003`, which reaches the caller as `not-found`.\n *\n * @param deps - the adapter's API surface.\n * @param chat - the chat to list.\n * @param _cursor - unused; a direct chat is a single page.\n * @param _limit - unused; a direct chat has one member.\n * @returns one page with the peer.\n */\nexport async function members(deps, chat, _cursor, _limit) {\n const answer = await deps.internal.userGet({ userid: chat.id });\n return {\n data: [\n {\n id: answer.userid === undefined || answer.userid === ''\n ? chat.id\n : answer.userid,\n ...(answer.name === undefined ? {} : { name: answer.name }),\n isBot: false,\n },\n ],\n };\n}\n//# sourceMappingURL=send.js.map","/**\n * The application `access_token` every `cgi-bin` call carries.\n *\n * The platform mints one token per application with a lifetime of 7,200 seconds, refuses a client that asks too often,\n * and may invalidate a token early. The cache is therefore lazy (no background timer to clear on disconnect),\n * single-flight (concurrent callers share one request) and invalidated by the code of a refused call rather than by a\n * deadline alone.\n */\n/** Seconds shaved off the announced lifetime, so a request never races the expiry. */\nconst REFRESH_MARGIN_SECONDS = 300;\n/** The application token, cached until shortly before the platform expires it. */\nexport class AccessTokenCache {\n mint;\n now;\n current;\n inflight;\n /**\n * @param mint - requests a new token from the platform.\n * @param now - clock of the expiry check; tests replace it.\n */\n constructor(mint, now = Date.now) {\n this.mint = mint;\n this.now = now;\n }\n /** The cached token, requesting one when none is cached or the cached one is near its expiry. */\n async get() {\n const current = this.current;\n if (current !== undefined && this.now() < current.expiresAt)\n return current.value;\n this.inflight ??= this.mint()\n .then((answer) => {\n if (answer.access_token === undefined || answer.access_token === '') {\n // A refusal must not leave the adapter sending `access_token=` on every later call.\n throw new Error(`wecom: gettoken answered without a token${answer.errmsg === undefined ? '' : `: ${answer.errmsg}`}`);\n }\n const expiresIn = answer.expires_in;\n // Without a usable lifetime the token still answers this round of callers but is not cached: a `NaN` deadline\n // would silently re-request on every call.\n if (typeof expiresIn === 'number' && Number.isFinite(expiresIn)) {\n this.current = {\n value: answer.access_token,\n expiresAt: this.now() + (expiresIn - REFRESH_MARGIN_SECONDS) * 1_000,\n };\n }\n return answer.access_token;\n })\n .finally(() => {\n this.inflight = undefined;\n });\n return await this.inflight;\n }\n /** Drop the cached token, so the next {@link get} asks the platform again. */\n invalidate() {\n this.current = undefined;\n }\n /** The token in the cache, when one is cached; for diagnostics only. */\n get cached() {\n return this.current?.value;\n }\n}\n//# sourceMappingURL=token.js.map","/**\n * Callback authentication and decryption, implemented on `node:crypto`.\n *\n * The platform hands every callback over in one encrypted envelope, and the adapter is the only place that can say\n * whether the bytes came from the platform:\n *\n * - `msg_signature = sha1(sort(token, timestamp, nonce, msg_encrypt).join(''))`, compared in constant time;\n * - `AES-256-CBC` keyed by `Base64_Decode(EncodingAESKey + \"=\")` with `IV = AESKey[0:16]` and PKCS#7 padding to\n * **32-byte** blocks (not the usual 16);\n * - the plaintext is `random(16) + msg_len(4, big endian) + msg + receiveid`, and `receiveid` must equal `corpId` for an\n * application callback.\n *\n * `tests/crypto.spec.ts` proves the three steps against the vectors the platform documents.\n */\nimport { createDecipheriv, createHash, timingSafeEqual } from 'node:crypto';\n/** Length of the decoded AES key. */\nconst AES_KEY_BYTES = 32;\n/** Length of the initialisation vector, which is the first part of the key. */\nconst IV_BYTES = 16;\n/** The padding block size this platform uses: 32 bytes, not the 16 of a plain AES-CBC block. */\nexport const PKCS7_BLOCK_BYTES = 32;\n/** Length of the random prefix of the plaintext. */\nconst RANDOM_BYTES = 16;\n/** Length of the big-endian message length between the random prefix and the message. */\nconst LENGTH_BYTES = 4;\n/** One callback payload that could not be decrypted. */\nexport class WecomCryptoError extends Error {\n constructor(message, options = {}) {\n super(message, options);\n this.name = 'WecomCryptoError';\n }\n}\n/**\n * Decode an `EncodingAESKey` into the AES key it stands for.\n *\n * The platform stores the Base64 key without its `=` padding, so the padding is restored before decoding.\n *\n * @param aesKey - the configured 43-character `EncodingAESKey`.\n * @returns the 32-byte AES key.\n * @throws WecomCryptoError when the decoded key is not 32 bytes.\n */\nexport function aesKeyOf(aesKey) {\n const key = Buffer.from(`${aesKey}=`, 'base64');\n if (key.length !== AES_KEY_BYTES) {\n throw new WecomCryptoError(`wecom: the EncodingAESKey decodes to ${key.length} bytes, expected ${AES_KEY_BYTES}`);\n }\n return key;\n}\n/**\n * The `msg_signature` of one callback.\n *\n * The four components are sorted lexicographically as strings and concatenated without a separator, then hashed with\n * SHA-1 and printed as lowercase hex.\n *\n * @param token - the configured callback token.\n * @param timestamp - the `timestamp` the platform sent.\n * @param nonce - the `nonce` the platform sent.\n * @param encrypt - the `echostr` or outer `Encrypt` value the signature covers.\n * @returns the lowercase hexadecimal SHA-1 digest.\n */\nexport function signatureOf(token, timestamp, nonce, encrypt) {\n return createHash('sha1')\n .update([token, timestamp, nonce, encrypt].sort().join(''))\n .digest('hex');\n}\n/**\n * Compare a computed signature with the one the request carried without leaking where they differ.\n *\n * @param expected - the signature computed from the request.\n * @param received - the `msg_signature` parameter, if the request carried one.\n * @returns whether the request signature matches.\n */\nexport function matchesSignature(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 * Decrypt one callback payload.\n *\n * @param aesKey - the configured `EncodingAESKey`.\n * @param encrypt - the Base64 ciphertext the callback carried.\n * @returns the message and the `receiveid` it was encrypted for.\n * @throws WecomCryptoError when the ciphertext is malformed, the padding is inconsistent, or the announced length\n * exceeds the plaintext.\n */\nexport function decryptPayload(aesKey, encrypt) {\n const key = aesKeyOf(aesKey);\n const cipher = Buffer.from(encrypt.trim(), 'base64');\n if (cipher.length === 0 || cipher.length % IV_BYTES !== 0) {\n throw new WecomCryptoError(`wecom: the callback ciphertext is ${cipher.length} bytes, which is not a whole number of AES blocks`);\n }\n const decipher = createDecipheriv('aes-256-cbc', key, key.subarray(0, IV_BYTES));\n decipher.setAutoPadding(false);\n let padded;\n try {\n padded = Buffer.concat([decipher.update(cipher), decipher.final()]);\n }\n catch (cause) {\n throw new WecomCryptoError('wecom: the callback payload could not be decrypted', { cause });\n }\n if (padded.length === 0 || padded.length % PKCS7_BLOCK_BYTES !== 0) {\n throw new WecomCryptoError(`wecom: the decrypted payload is ${padded.length} bytes, which is not padded to ${PKCS7_BLOCK_BYTES}-byte blocks`);\n }\n const padding = padded[padded.length - 1];\n if (padding < 1 || padding > PKCS7_BLOCK_BYTES || padding > padded.length) {\n throw new WecomCryptoError(`wecom: the callback padding byte is ${padding}`);\n }\n const plaintext = padded.subarray(0, padded.length - padding);\n if (plaintext.length < RANDOM_BYTES + LENGTH_BYTES) {\n throw new WecomCryptoError(`wecom: the decrypted payload is ${plaintext.length} bytes, shorter than its own header`);\n }\n const length = plaintext.readUInt32BE(RANDOM_BYTES);\n const end = RANDOM_BYTES + LENGTH_BYTES + length;\n if (end > plaintext.length) {\n throw new WecomCryptoError(`wecom: the decrypted payload announces ${length} bytes of message but carries ${plaintext.length - RANDOM_BYTES - LENGTH_BYTES}`);\n }\n return {\n message: plaintext\n .subarray(RANDOM_BYTES + LENGTH_BYTES, end)\n .toString('utf8'),\n receiveId: plaintext.subarray(end).toString('utf8'),\n };\n}\n//# sourceMappingURL=crypto.js.map","/**\n * Inbound decoding: one decrypted callback becomes an intake `Session` (`message`) or a button interaction.\n *\n * An application message arrives from exactly one member in exactly one conversation — the member's direct chat with the\n * application — so `chat.type` is always `direct`, `chat.id` is the sender's userid, and there is no mention, thread or\n * quote to decode. The content of a media message is the bot's own `satori:` route, because the callback carries only a\n * `media_id` and the bytes have to be fetched with the application's credentials.\n */\nimport { h, normalize } from '@deepseek-ai/satori-element';\n/** The chat of a callback sender: the application has only one-to-one conversations. */\nexport function chatOf(userId) {\n return { id: userId, type: 'direct' };\n}\n/** The sender of a callback: the application never learns a display name without another request. */\nexport function senderOf(userId) {\n return { id: userId, isBot: false };\n}\n/**\n * The millisecond time of a callback.\n *\n * `CreateTime` is in seconds; a body without a usable value falls back to the receipt time rather than to `NaN`.\n */\nfunction timeOf(fields) {\n const seconds = Number(fields.CreateTime);\n return Number.isFinite(seconds) ? seconds * 1000 : Date.now();\n}\n/**\n * The `satori:` source of one inbound media object.\n *\n * @param bot - the receiving adapter.\n * @param mediaId - the platform `MediaId`.\n * @returns the internal URL the host downloads through.\n */\nexport function mediaSource(bot, mediaId) {\n return bot.getInternalUrl(`/assets/${encodeURIComponent(mediaId)}`);\n}\n/**\n * The text of one location message.\n *\n * The element vocabulary has no location tag, so the place arrives as a readable line.\n *\n * @param fields - the decrypted message.\n * @returns `[位置] Label (X,Y)`, without the label when the message carries none.\n */\nexport function locationText(fields) {\n const label = fields.Label?.trim() ?? '';\n const x = fields.Location_X ?? '';\n const y = fields.Location_Y ?? '';\n return `[位置]${label === '' ? '' : ` ${label}`} (${x},${y})`;\n}\n/** The elements of one message, or undefined for a `MsgType` this adapter does not decode. */\nfunction contentOf(bot, fields, msgType) {\n switch (msgType) {\n case 'text':\n return [fields.Content ?? ''];\n case 'image': {\n const mediaId = fields.MediaId ?? '';\n return mediaId === ''\n ? []\n : [h('img', { src: mediaSource(bot, mediaId) })];\n }\n case 'voice': {\n const mediaId = fields.MediaId ?? '';\n return mediaId === ''\n ? []\n : [h('audio', { src: mediaSource(bot, mediaId) })];\n }\n case 'video': {\n const mediaId = fields.MediaId ?? '';\n return mediaId === ''\n ? []\n : [h('video', { src: mediaSource(bot, mediaId) })];\n }\n case 'location':\n return [h('p', locationText(fields))];\n case 'link': {\n const url = fields.Url ?? '';\n if (url === '')\n return [];\n const title = fields.Title?.trim() ?? '';\n const description = fields.Description?.trim() ?? '';\n return [\n h('p', h('a', { href: url }, title === '' ? url : title), ...(description === '' ? [] : ['\\n', description])),\n ];\n }\n default:\n return undefined;\n }\n}\n/** Decode one `template_card_event` into the button session the callback registry looks up. */\nexport function decodeTemplateCardEvent(bot, fields) {\n const userId = fields.FromUserName ?? '';\n const chat = chatOf(userId);\n const time = timeOf(fields);\n const referrer = {\n taskId: fields.TaskId ?? '',\n ...(fields.CardType === undefined ? {} : { cardType: fields.CardType }),\n ...(fields.ResponseCode === undefined\n ? {}\n : { responseCode: fields.ResponseCode }),\n userId,\n agentId: bot.config.agentId,\n };\n const button = {\n bot,\n id: fields.EventKey ?? '',\n user: senderOf(userId),\n chat,\n referrer,\n // The click has no platform time of its own beyond the envelope, and the platform answers nothing back here.\n time: Date.now(),\n };\n return bot.session({\n type: 'interaction/button',\n // A click carries no `MsgId`, so the dedupe id is composed of the card, the button and the callback time.\n id: `${fields.TaskId ?? ''}:${fields.EventKey ?? ''}:${fields.CreateTime ?? ''}`,\n timestamp: time,\n button,\n raw: fields,\n });\n}\n/** Decode one event message, or drop it when the contract has no consumer for it. */\nfunction decodeEvent(bot, fields) {\n switch (fields.Event) {\n case 'template_card_event':\n return decodeTemplateCardEvent(bot, fields);\n default:\n // Lifecycle events (`subscribe`, `unsubscribe`, `enter_agent`), menu events, `taskcard_click` and\n // `template_card_menu_event` all arrive here: the IM contract has no \"someone opened the application\" or \"a menu\n // was used\" event, and mapping them onto `interaction/button` would produce ids nothing registered.\n bot.ctx.logger.debug('wecom: ignoring a %s event', fields.Event ?? '(none)');\n return undefined;\n }\n}\n/**\n * Decode one decrypted callback.\n *\n * @param bot - the receiving adapter.\n * @param fields - the decrypted message fields.\n * @returns the session to publish, or undefined for a message this adapter drops.\n */\nexport function decodeMessage(bot, fields) {\n const msgType = fields.MsgType ?? '';\n if (msgType === 'event')\n return decodeEvent(bot, fields);\n const nodes = contentOf(bot, fields, msgType);\n if (nodes === undefined) {\n bot.ctx.logger.debug('wecom: ignoring a message of type %s', msgType === '' ? '(none)' : msgType);\n return undefined;\n }\n const userId = fields.FromUserName ?? '';\n const msgId = fields.MsgId ?? '';\n const time = timeOf(fields);\n const content = normalize(nodes.length > 0\n ? nodes\n : [h('raw', { platform: 'wecom', type: msgType, data: fields })]);\n const referrer = {\n corpId: bot.config.corpId,\n agentId: bot.config.agentId,\n userId,\n msgId,\n };\n const message = {\n id: msgId,\n chat: chatOf(userId),\n sender: senderOf(userId),\n content,\n // An application message has no mention mechanism: there is no group and no `@` in a one-to-one conversation.\n mentions: { self: false, all: false, users: [] },\n time,\n referrer,\n raw: fields,\n };\n return bot.session({\n type: 'message',\n id: msgId,\n timestamp: time,\n message,\n raw: fields,\n });\n}\n//# sourceMappingURL=decode.js.map","/**\n * XML parsing of the callback envelopes.\n *\n * Both the outer envelope (`<xml><ToUserName/><AgentID/><Encrypt/></xml>`) and the decrypted message are a flat map of\n * element name to text; `template_card_event`'s `SelectedItems` is the only nested value and no decision of this adapter\n * reads it. The platform's real input includes entities, CDATA, self-closing tags and a byte-order mark, so the parsing\n * is delegated to `xml2js` instead of a hand-written pattern.\n */\nimport xml2js from 'xml2js';\n/** One callback document that is not a well-formed `<xml>` field map. */\nexport class WecomXmlError extends Error {\n constructor(message, options = {}) {\n super(message, options);\n this.name = 'WecomXmlError';\n }\n}\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** One parsed field value, when the value is a scalar rather than a nested element. */\nfunction scalarOf(value) {\n if (typeof value === 'string')\n return value;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n return undefined;\n}\n/**\n * Flatten the `xml` element of a parsed document.\n *\n * @param value - the parsed document.\n * @returns its scalar fields, or undefined when the document is not an `<xml>` field map.\n */\nexport function fieldsOf(value) {\n if (typeof value !== 'object' || value === null)\n return undefined;\n const root = value.xml;\n if (typeof root !== 'object' || root === null)\n return undefined;\n const fields = {};\n for (const [name, raw] of Object.entries(root)) {\n const field = scalarOf(raw);\n if (field !== undefined)\n fields[name] = field;\n }\n return fields;\n}\n/**\n * Parse one callback document into its fields.\n *\n * @param text - the request body or the decrypted message.\n * @returns the scalar fields of the `<xml>` root.\n * @throws WecomXmlError when the document is not well-formed XML or carries no `<xml>` root.\n */\nexport async function parseXml(text) {\n let parsed;\n try {\n parsed = await xml2js.parseStringPromise(text, { explicitArray: false });\n }\n catch (cause) {\n throw new WecomXmlError(`wecom: the callback body is not XML: ${messageOf(cause)}`, { cause });\n }\n const fields = fieldsOf(parsed);\n if (fields === undefined) {\n throw new WecomXmlError('wecom: the callback body has no <xml> root');\n }\n return fields;\n}\n/**\n * Parse the plaintext of a decrypted message.\n *\n * The decrypted body is an `<xml>` document of its own, so it goes through the same parser as the outer envelope.\n *\n * @param message - the decrypted message.\n * @returns its scalar fields.\n * @throws WecomXmlError when the decrypted body is not XML.\n */\nexport async function parseMessageXml(message) {\n return await parseXml(message);\n}\n//# sourceMappingURL=xml.js.map","/**\n * The callback transport.\n *\n * A self-built application has exactly one inbound path: the platform POSTs an encrypted XML envelope to the URL saved\n * in 接收消息 → 设置API接收, and verifies that URL by a GET to the same address when the configuration is saved. Both\n * methods are answered by one handler because a `WebRoute` does not match on the method, and splitting them into two\n * routes of the same path would make the registration order decide which one sees the GET.\n *\n * The handler answers `200` only after `bot.receive` stored the message, so a platform that retries a timed-out delivery\n * finds the repeat deduplicated by `${bot.id}|${event.id}`; an intake failure answers `500` instead of pretending.\n */\nimport { routePath } from \"../config.js\";\nimport { decryptPayload, matchesSignature, signatureOf } from \"../crypto.js\";\nimport { decodeMessage } from \"../decode.js\";\nimport { parseMessageXml, parseXml, WecomXmlError } from \"../xml.js\";\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** Read a request body to its end. The callback body is small and the platform publishes no size limit. */\nasync 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/** Write one bodiless answer. */\nfunction writeStatus(response, status, headers = {}) {\n response.writeHead(status, headers);\n response.end();\n}\n/**\n * Write one plain-text answer, verbatim.\n *\n * The platform requires the decrypted `echostr` back without quotes, a byte-order mark or a trailing newline.\n */\nfunction writeText(response, status, text) {\n response.writeHead(status, {\n 'content-type': 'text/plain; charset=utf-8',\n 'content-length': String(Buffer.byteLength(text, 'utf8')),\n });\n response.end(text);\n}\n/** The decoded query of one request. */\nfunction queryOf(request) {\n try {\n return new URL(request.url ?? '/', 'http://localhost').searchParams;\n }\n catch {\n // A request target the URL parser refuses names no parameters at all.\n return new URLSearchParams();\n }\n}\n/** The one callback route of {@link WecomWebhook}. */\nexport class WecomWebhook {\n bot;\n webServer;\n dispose;\n constructor(bot, webServer) {\n this.bot = bot;\n this.webServer = webServer;\n }\n /** Register the route over the profile's web server. */\n start() {\n this.dispose = this.webServer.register({\n kind: 'exact',\n path: routePath(this.bot.config.path),\n auth: 'anonymous',\n handler: (request, response) => this.handle(request, response),\n });\n }\n /** Release the route. */\n stop() {\n this.dispose?.();\n this.dispose = undefined;\n }\n async handle(request, response) {\n try {\n switch (request.method) {\n case 'GET':\n await this.handleVerify(request, response);\n return;\n case 'POST':\n await this.handleCallback(request, response);\n return;\n default:\n writeStatus(response, 405, { allow: 'GET, POST' });\n }\n }\n catch (error) {\n this.bot.ctx.logger.warn('wecom: callback delivery failed: %s', messageOf(error));\n if (!response.headersSent)\n writeStatus(response, 500);\n else\n response.end();\n }\n }\n /** The URL verification the platform sends when the callback configuration is saved. */\n async handleVerify(request, response) {\n const query = queryOf(request);\n const msgSignature = query.get('msg_signature');\n const timestamp = query.get('timestamp');\n const nonce = query.get('nonce');\n const echostr = query.get('echostr');\n if (msgSignature === null ||\n msgSignature === '' ||\n timestamp === null ||\n timestamp === '' ||\n nonce === null ||\n nonce === '' ||\n echostr === null ||\n echostr === '') {\n writeStatus(response, 400);\n return;\n }\n const expected = signatureOf(this.bot.config.token, timestamp, nonce, echostr);\n if (!matchesSignature(expected, msgSignature)) {\n writeStatus(response, 403);\n return;\n }\n let plaintext;\n let receiveId;\n try {\n const decrypted = decryptPayload(this.bot.config.aesKey, echostr);\n plaintext = decrypted.message;\n receiveId = decrypted.receiveId;\n }\n catch (error) {\n this.bot.ctx.logger.warn('wecom: verification payload could not be decrypted: %s', messageOf(error));\n writeStatus(response, 400);\n return;\n }\n if (receiveId !== this.bot.config.corpId) {\n this.bot.ctx.logger.warn('wecom: verification payload was encrypted for %s, not corpId %s', receiveId, this.bot.config.corpId);\n writeStatus(response, 403);\n return;\n }\n writeText(response, 200, plaintext);\n }\n /** One business callback. */\n async handleCallback(request, response) {\n const query = queryOf(request);\n const body = await readBody(request);\n let outer;\n try {\n outer = await parseXml(body);\n }\n catch (error) {\n if (error instanceof WecomXmlError) {\n this.bot.ctx.logger.warn('wecom: cannot parse a callback request: %s', messageOf(error));\n writeStatus(response, 400);\n return;\n }\n throw error;\n }\n if (outer.AgentID !== this.bot.config.agentId) {\n // Another application of the same enterprise posts to the same URL; the envelope names whose callback this is.\n writeStatus(response, 403);\n return;\n }\n let fields = outer;\n const encrypt = outer.Encrypt;\n if (encrypt !== undefined && encrypt !== '') {\n const msgSignature = query.get('msg_signature');\n const timestamp = query.get('timestamp');\n const nonce = query.get('nonce');\n if (msgSignature === null ||\n msgSignature === '' ||\n timestamp === null ||\n timestamp === '' ||\n nonce === null ||\n nonce === '') {\n writeStatus(response, 400);\n return;\n }\n const expected = signatureOf(this.bot.config.token, timestamp, nonce, encrypt);\n if (!matchesSignature(expected, msgSignature)) {\n writeStatus(response, 403);\n return;\n }\n let message;\n let receiveId;\n try {\n const decrypted = decryptPayload(this.bot.config.aesKey, encrypt);\n message = decrypted.message;\n receiveId = decrypted.receiveId;\n }\n catch (error) {\n // The signature matched, so the platform sent these bytes: a payload this key cannot read names a wrong aesKey.\n this.bot.ctx.logger.warn('wecom: callback payload could not be decrypted: %s', messageOf(error));\n writeStatus(response, 403);\n return;\n }\n if (receiveId !== this.bot.config.corpId) {\n this.bot.ctx.logger.warn('wecom: callback was encrypted for %s, not corpId %s', receiveId, this.bot.config.corpId);\n writeStatus(response, 403);\n return;\n }\n try {\n fields = await parseMessageXml(message);\n }\n catch (error) {\n this.bot.ctx.logger.warn('wecom: cannot parse a decrypted callback: %s', messageOf(error));\n writeStatus(response, 400);\n return;\n }\n }\n const session = decodeMessage(this.bot, fields);\n // An event this contract has no consumer for is acknowledged and dropped; the platform must not retry it.\n if (session !== undefined)\n await this.bot.receive(session);\n writeText(response, 200, 'success');\n }\n}\n//# sourceMappingURL=webhook.js.map","import { Adapter } from '@deepseek-ai/cordis-plugin-im-core';\nimport { Config, configError } from \"./config.js\";\nimport { classifyWecomError } from \"./errors.js\";\nimport { verifyIdentity } from \"./identity.js\";\nimport { Internal } from \"./internal.js\";\nimport { serveMedia, uploadMedia } from \"./media.js\";\nimport { createMarkdownMode } from \"./modes/markdown.js\";\nimport { deletePart, members, sendPayload } from \"./send.js\";\nimport { AccessTokenCache } from \"./token.js\";\nimport { WecomWebhook } from \"./transport/webhook.js\";\n/** Message of any caught value, for a log line. */\nfunction messageOf(error) {\n return error instanceof Error ? error.message : String(error);\n}\n/** One internal-route path segment back as the value it names. */\nfunction decodeSegment(segment) {\n try {\n return decodeURIComponent(segment);\n }\n catch {\n // The segment was written unencoded: it names itself rather than a malformed escape.\n return segment;\n }\n}\n/**\n * WeCom self-built application adapter.\n *\n * The application is identified by configuration (`agentId`), confirmed with `agent/get` on connect. The encrypted XML\n * callback is the only transport, `markdown` is the only mode, and every reply is a proactive `message/send`: a passive\n * reply would have to answer inside the platform's five-second window, while a turn takes minutes. Media uploads to\n * `media/upload` and carries a three-day `media_id`; inbound media is read from the bot's own `satori:` route.\n */\nexport class WecomBot 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 = ['markdown'];\n /** The mapped platform API surface. */\n internal;\n /** The application `access_token` every `cgi-bin` call carries. */\n tokens;\n webhook;\n constructor(ctx, config) {\n super(ctx, config, {\n id: `wecom:${config.agentId}`,\n platform: 'wecom',\n adapter: 'wecom',\n });\n // `bot.id` has to be fixed at construction, so the application is configured rather than discovered; `connect`\n // proves the credentials belong to it.\n this.selfId = config.agentId;\n this.internal = new Internal(this);\n this.tokens = new AccessTokenCache(async () => {\n return await this.internal.getToken({\n corpid: config.corpId,\n corpsecret: config.secret,\n });\n });\n this.modes = { markdown: createMarkdownMode(config) };\n this.defineInternalRoute('/assets/:mediaId', async ({ params }) => serveMedia(this, decodeSegment(params.mediaId)));\n }\n async connect() {\n const invalid = configError(this.config);\n if (invalid !== undefined) {\n // `Bot.start` only stores a connect failure on `bot.error`, so log it here.\n this.ctx.logger.error('wecom: connect failed: %s', invalid.message);\n throw invalid;\n }\n const webServer = this.ctx.get('webServer');\n if (webServer === undefined) {\n const error = new Error('wecom: this adapter needs a profile-provided webServer; WeCom has only the callback transport, so add a ' +\n 'webServer row to the profile and make the callback path reachable from the enterprise network');\n this.ctx.logger.error(error.message);\n throw error;\n }\n try {\n // A profile that cannot mint a token cannot answer a callback either, so the failure surfaces here.\n await this.tokens.get();\n const answer = await this.internal.agentGet({\n agentid: Number(this.config.agentId),\n });\n this.user = verifyIdentity(this.config.agentId, answer);\n const webhook = new WecomWebhook(this, webServer);\n webhook.start();\n this.webhook = webhook;\n this.online();\n }\n catch (error) {\n this.ctx.logger.error('wecom: connect failed: %s', messageOf(error));\n throw error;\n }\n }\n async disconnect() {\n const webhook = this.webhook;\n this.webhook = undefined;\n webhook?.stop();\n }\n /**\n * Upload one outbound attachment to the platform's media endpoint.\n *\n * A `media_id` is an application-level resource, so the scope is the bot rather than the chat.\n */\n async upload(ref, _scope, ctx) {\n return await uploadMedia(this, ref, ctx);\n }\n resourceScope(_target, _kind) {\n return this.id;\n }\n async sendPayload(payload, target, ctx) {\n return await sendPayload({ internal: this.internal, config: this.config }, payload, target, ctx);\n }\n async deletePart(part, handle) {\n await deletePart({ internal: this.internal, config: this.config }, part, handle);\n }\n async members(chat, cursor, limit) {\n return await members({ internal: this.internal, config: this.config }, chat, cursor, limit);\n }\n classify(error) {\n return classifyWecomError(error);\n }\n}\nexport { Config };\nexport default WecomBot;\n//# sourceMappingURL=bot.js.map"],"mappings":";;;;;;;;;;;;;;;;;;;;ACEA,M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KAAK,OAAO;EAChB,SACO,OAAO;GACV,KAAK,IAAI,OAAO,MAAM,6BAA6B,UAAU,KAAK,CAAC;GACnE,MAAM;EACV;CACJ;CACA,MAAM,aAAa;EACf,MAAM,UAAU,KAAK;EACrB,KAAK,UAAU,KAAA;EACf,SAAS,KAAK;CAClB;;;;;;CAMA,MAAM,OAAO,KAAK,QAAQ,KAAK;EAC3B,OAAO,MAAM,YAAY,MAAM,KAAK,GAAG;CAC3C;CACA,cAAc,SAAS,OAAO;EAC1B,OAAO,KAAK;CAChB;CACA,MAAM,YAAY,SAAS,QAAQ,KAAK;EACpC,OAAO,MAAM,YAAY;GAAE,UAAU,KAAK;GAAU,QAAQ,KAAK;EAAO,GAAG,SAAS,QAAQ,GAAG;CACnG;CACA,MAAM,WAAW,MAAM,QAAQ;EAC3B,MAAM,WAAW;GAAE,UAAU,KAAK;GAAU,QAAQ,KAAK;EAAO,GAAG,MAAM,MAAM;CACnF;CACA,MAAM,QAAQ,MAAM,QAAQ,OAAO;EAC/B,OAAO,MAAM,QAAQ;GAAE,UAAU,KAAK;GAAU,QAAQ,KAAK;EAAO,GAAG,MAAM,QAAQ,KAAK;CAC9F;CACA,SAAS,OAAO;EACZ,OAAO,mBAAmB,KAAK;CACnC;AACJ"}
@@ -0,0 +1,50 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import { Adapter } from '@deepseek-ai/cordis-plugin-im-core';
3
+ import type { ChatRef, MembersPage, MessageHandle, Mode, PrepareContext, ResolvedResource, ResourceKind, ResourceRef, SendContext, SentPart, Target } from '@deepseek-ai/cordis-plugin-im-core';
4
+ import { Config } from './config.ts';
5
+ import { Internal } from './internal.ts';
6
+ import type { WecomModeTypes } from './modes/shared.ts';
7
+ import { AccessTokenCache } from './token.ts';
8
+ /** The single mode this adapter always registers. */
9
+ export interface WecomModes {
10
+ [mode: string]: Mode<WecomModeTypes>;
11
+ markdown: Mode<WecomModeTypes>;
12
+ }
13
+ /**
14
+ * WeCom self-built application adapter.
15
+ *
16
+ * The application is identified by configuration (`agentId`), confirmed with `agent/get` on connect. The encrypted XML
17
+ * callback is the only transport, `markdown` is the only mode, and every reply is a proactive `message/send`: a passive
18
+ * reply would have to answer inside the platform's five-second window, while a turn takes minutes. Media uploads to
19
+ * `media/upload` and carries a three-day `media_id`; inbound media is read from the bot's own `satori:` route.
20
+ */
21
+ export declare class WecomBot extends Adapter<Config, WecomModes> {
22
+ /** The adapter needs the Satori service and the isolated `http` service. */
23
+ static inject: string[];
24
+ /** The Loader applies this schema to a profile row's `config` before the constructor runs. */
25
+ static readonly Config: import("@deepseek-ai/schemastery").default<Config>;
26
+ readonly modes: WecomModes;
27
+ readonly modeOrder: readonly ["markdown"];
28
+ /** The mapped platform API surface. */
29
+ readonly internal: Internal;
30
+ /** The application `access_token` every `cgi-bin` call carries. */
31
+ readonly tokens: AccessTokenCache;
32
+ private webhook;
33
+ constructor(ctx: Context, config: Config);
34
+ connect(): Promise<void>;
35
+ disconnect(): Promise<void>;
36
+ /**
37
+ * Upload one outbound attachment to the platform's media endpoint.
38
+ *
39
+ * A `media_id` is an application-level resource, so the scope is the bot rather than the chat.
40
+ */
41
+ upload(ref: ResourceRef, _scope: string, ctx: PrepareContext): Promise<ResolvedResource>;
42
+ resourceScope(_target: Target, _kind: ResourceKind): string;
43
+ sendPayload(payload: unknown, target: Target, ctx: SendContext): Promise<SentPart>;
44
+ deletePart(part: SentPart, handle: MessageHandle): Promise<void>;
45
+ members(chat: ChatRef, cursor?: string, limit?: number): Promise<MembersPage>;
46
+ classify(error: unknown): import("@deepseek-ai/cordis-plugin-im-core").PlatformError;
47
+ }
48
+ export { Config };
49
+ export default WecomBot;
50
+ //# 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,EAAE,OAAO,E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AAC,gBAAgB,CAAC;IAInB,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,CACvB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC;IAQD,OAAO,CACpB,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC;IASd,QAAQ,CAAC,KAAK,EAAE,OAAO;CAGjC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,126 @@
1
+ import { Adapter } from '@deepseek-ai/cordis-plugin-im-core';
2
+ import { Config, configError } from "./config.js";
3
+ import { classifyWecomError } from "./errors.js";
4
+ import { verifyIdentity } from "./identity.js";
5
+ import { Internal } from "./internal.js";
6
+ import { serveMedia, uploadMedia } from "./media.js";
7
+ import { createMarkdownMode } from "./modes/markdown.js";
8
+ import { deletePart, members, sendPayload } from "./send.js";
9
+ import { AccessTokenCache } from "./token.js";
10
+ import { WecomWebhook } from "./transport/webhook.js";
11
+ /** Message of any caught value, for a log line. */
12
+ function messageOf(error) {
13
+ return error instanceof Error ? error.message : String(error);
14
+ }
15
+ /** One internal-route path segment back as the value it names. */
16
+ function decodeSegment(segment) {
17
+ try {
18
+ return decodeURIComponent(segment);
19
+ }
20
+ catch {
21
+ // The segment was written unencoded: it names itself rather than a malformed escape.
22
+ return segment;
23
+ }
24
+ }
25
+ /**
26
+ * WeCom self-built application adapter.
27
+ *
28
+ * The application is identified by configuration (`agentId`), confirmed with `agent/get` on connect. The encrypted XML
29
+ * callback is the only transport, `markdown` is the only mode, and every reply is a proactive `message/send`: a passive
30
+ * reply would have to answer inside the platform's five-second window, while a turn takes minutes. Media uploads to
31
+ * `media/upload` and carries a three-day `media_id`; inbound media is read from the bot's own `satori:` route.
32
+ */
33
+ export class WecomBot extends Adapter {
34
+ /** The adapter needs the Satori service and the isolated `http` service. */
35
+ static inject = ['satori', 'http'];
36
+ /** The Loader applies this schema to a profile row's `config` before the constructor runs. */
37
+ static Config = Config;
38
+ modes;
39
+ modeOrder = ['markdown'];
40
+ /** The mapped platform API surface. */
41
+ internal;
42
+ /** The application `access_token` every `cgi-bin` call carries. */
43
+ tokens;
44
+ webhook;
45
+ constructor(ctx, config) {
46
+ super(ctx, config, {
47
+ id: `wecom:${config.agentId}`,
48
+ platform: 'wecom',
49
+ adapter: 'wecom',
50
+ });
51
+ // `bot.id` has to be fixed at construction, so the application is configured rather than discovered; `connect`
52
+ // proves the credentials belong to it.
53
+ this.selfId = config.agentId;
54
+ this.internal = new Internal(this);
55
+ this.tokens = new AccessTokenCache(async () => {
56
+ return await this.internal.getToken({
57
+ corpid: config.corpId,
58
+ corpsecret: config.secret,
59
+ });
60
+ });
61
+ this.modes = { markdown: createMarkdownMode(config) };
62
+ this.defineInternalRoute('/assets/:mediaId', async ({ params }) => serveMedia(this, decodeSegment(params.mediaId)));
63
+ }
64
+ async connect() {
65
+ const invalid = configError(this.config);
66
+ if (invalid !== undefined) {
67
+ // `Bot.start` only stores a connect failure on `bot.error`, so log it here.
68
+ this.ctx.logger.error('wecom: connect failed: %s', invalid.message);
69
+ throw invalid;
70
+ }
71
+ const webServer = this.ctx.get('webServer');
72
+ if (webServer === undefined) {
73
+ const error = new Error('wecom: this adapter needs a profile-provided webServer; WeCom has only the callback transport, so add a ' +
74
+ 'webServer row to the profile and make the callback path reachable from the enterprise network');
75
+ this.ctx.logger.error(error.message);
76
+ throw error;
77
+ }
78
+ try {
79
+ // A profile that cannot mint a token cannot answer a callback either, so the failure surfaces here.
80
+ await this.tokens.get();
81
+ const answer = await this.internal.agentGet({
82
+ agentid: Number(this.config.agentId),
83
+ });
84
+ this.user = verifyIdentity(this.config.agentId, answer);
85
+ const webhook = new WecomWebhook(this, webServer);
86
+ webhook.start();
87
+ this.webhook = webhook;
88
+ this.online();
89
+ }
90
+ catch (error) {
91
+ this.ctx.logger.error('wecom: connect failed: %s', messageOf(error));
92
+ throw error;
93
+ }
94
+ }
95
+ async disconnect() {
96
+ const webhook = this.webhook;
97
+ this.webhook = undefined;
98
+ webhook?.stop();
99
+ }
100
+ /**
101
+ * Upload one outbound attachment to the platform's media endpoint.
102
+ *
103
+ * A `media_id` is an application-level resource, so the scope is the bot rather than the chat.
104
+ */
105
+ async upload(ref, _scope, ctx) {
106
+ return await uploadMedia(this, ref, ctx);
107
+ }
108
+ resourceScope(_target, _kind) {
109
+ return this.id;
110
+ }
111
+ async sendPayload(payload, target, ctx) {
112
+ return await sendPayload({ internal: this.internal, config: this.config }, payload, target, ctx);
113
+ }
114
+ async deletePart(part, handle) {
115
+ await deletePart({ internal: this.internal, config: this.config }, part, handle);
116
+ }
117
+ async members(chat, cursor, limit) {
118
+ return await members({ internal: this.internal, config: this.config }, chat, cursor, limit);
119
+ }
120
+ classify(error) {
121
+ return classifyWecomError(error);
122
+ }
123
+ }
124
+ export { Config };
125
+ export default WecomBot;
126
+ //# sourceMappingURL=bot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bot.js","sourceRoot":"","sources":["../../src/bot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAc5D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MA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,GAAG,CACJ,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,UAAU,CACvB,IAAc,EACd,MAAqB;QAErB,MAAM,UAAU,CACd,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAChD,IAAI,EACJ,MAAM,CACP,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,OAAO,CACpB,IAAa,EACb,MAAe,EACf,KAAc;QAEd,OAAO,MAAM,OAAO,CAClB,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAChD,IAAI,EACJ,MAAM,EACN,KAAK,CACN,CAAA;IACH,CAAC;IAEQ,QAAQ,CAAC,KAAc;QAC9B,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;;AAGH,OAAO,EAAE,MAAM,EAAE,CAAA;AAEjB,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,48 @@
1
+ import z from '@deepseek-ai/schemastery';
2
+ /**
3
+ * One WeCom self-built application: the `AgentID` of the application page, its secret, and the callback credentials of
4
+ * 「接收消息 → 设置API接收」.
5
+ *
6
+ * There is no transport switch: a self-built application can only be reached through the encrypted XML callback, so a
7
+ * profile without `webServer` cannot use this adapter at all.
8
+ */
9
+ export interface Config {
10
+ /** Enterprise id (`ww…`): the `corpid` of `gettoken` and the `receiveid` a callback must decrypt to. */
11
+ corpId: string;
12
+ /** Application `AgentID`: `selfId`, `bot.id`, the `agentid` of every send and the outer `AgentID` filter. */
13
+ agentId: string;
14
+ /** Application secret (`corpsecret`). */
15
+ secret: string;
16
+ /** Callback token: one component of `msg_signature`. */
17
+ token: string;
18
+ /** Callback `EncodingAESKey`: 43 characters, decoded to the 32-byte AES key. */
19
+ aesKey: string;
20
+ /** Inbound callback path, absolute and without a trailing slash. */
21
+ path: string;
22
+ /** API root every `cgi-bin` call is made against. */
23
+ apiBaseUrl: string;
24
+ }
25
+ /** Validated WeCom adapter configuration. */
26
+ export declare const Config: z<Config>;
27
+ /** Length of an `EncodingAESKey`, which is the Base64 form of the 32-byte AES key without its padding. */
28
+ export declare const AES_KEY_CHARS = 43;
29
+ /** Maximum length of a callback `Token` the platform accepts. */
30
+ export declare const TOKEN_MAX_CHARS = 32;
31
+ /**
32
+ * Normalize a route path: absolute, no trailing slash.
33
+ *
34
+ * @param path - a configured path.
35
+ * @returns the pathname to register on the web server.
36
+ */
37
+ export declare function routePath(path: string): string;
38
+ /**
39
+ * The configuration the adapter cannot work from, as far as it can tell locally.
40
+ *
41
+ * The check runs when the bot starts, not on the first callback: the callback is the only inbound path, so a profile
42
+ * that cannot answer one has no way to receive anything.
43
+ *
44
+ * @param config - the validated configuration.
45
+ * @returns the configuration error, or undefined when the configuration is usable.
46
+ */
47
+ export declare function configError(config: Config): Error | undefined;
48
+ //# 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;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACrB,wGAAwG;IACxG,MAAM,EAAE,MAAM,CAAA;IACd,6GAA6G;IAC7G,OAAO,EAAE,MAAM,CAAA;IACf,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,6CAA6C;AAC7C,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAQ3B,CAAA;AAEF,0GAA0G;AAC1G,eAAO,MAAM,aAAa,KAAK,CAAA;AAE/B,iEAAiE;AACjE,eAAO,MAAM,eAAe,KAAK,CAAA;AAKjC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAkD7D"}