@evex-dev/linejs-cli 0.1.3 → 0.1.4

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.
package/dist/line.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as runCli } from "./cli-CitLKLHn.mjs";
2
+ import { t as runCli } from "./cli-B-byNdKi.mjs";
3
3
  // src/bin.ts
4
4
  const argv = process.argv.slice(2);
5
5
  if (argv[0] === "--") argv.shift();
@@ -1,5 +1,5 @@
1
1
  import { r as errorMessage } from "./errors-pVbxr1wG.mjs";
2
- import { a as commandMetadata, i as resolveCommandTokens, n as VERSION, o as isMcpExecutable, r as allCommands, s as splitLeadingGlobalOptions, t as runCli } from "./cli-CitLKLHn.mjs";
2
+ import { a as commandMetadata, i as resolveCommandTokens, n as VERSION, o as isMcpExecutable, r as allCommands, s as splitLeadingGlobalOptions, t as runCli } from "./cli-B-byNdKi.mjs";
3
3
  import { createHash, createHmac, randomBytes, timingSafeEqual } from "node:crypto";
4
4
  import { once } from "node:events";
5
5
  import { createInterface } from "node:readline";
@@ -1238,4 +1238,4 @@ async function runMcpServer(options = {}) {
1238
1238
  }
1239
1239
  export { runMcpServer };
1240
1240
 
1241
- //# sourceMappingURL=server-BliXvGMY.mjs.map
1241
+ //# sourceMappingURL=server-DGKFX_3-.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-BliXvGMY.mjs","names":["dnsLookup","request","httpsRequest"],"sources":["../src/mcp/webhook.ts","../src/mcp/events.ts","../src/mcp/listen-source.ts","../src/mcp/server.ts"],"sourcesContent":["import { createHmac } from \"node:crypto\";\nimport { lookup as dnsLookup } from \"node:dns/promises\";\nimport { request as httpsRequest } from \"node:https\";\nimport { isIP } from \"node:net\";\n\n/**\n * Webhook delivery for the MCP Events extension.\n *\n * Deliveries follow the Standard Webhooks profile described by\n * https://github.com/modelcontextprotocol/experimental-ext-triggers-events and\n * are hardened against SSRF: the hostname is resolved and validated on every\n * attempt, the connection is pinned to the validated address, and redirects\n * are never followed.\n */\n\nexport const WEBHOOK_SECRET_PREFIX = \"whsec_\";\nexport const MAX_WEBHOOK_BODY_BYTES = 256 * 1024;\n\nconst MAX_RESPONSE_BYTES = 64 * 1024;\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nexport type WebhookErrorCategory =\n\t| \"connection_refused\"\n\t| \"timeout\"\n\t| \"tls_error\"\n\t| \"http_4xx\"\n\t| \"http_5xx\"\n\t| \"challenge_failed\";\n\nexport class WebhookDeliveryError extends Error {\n\treadonly category: WebhookErrorCategory;\n\n\tconstructor(category: WebhookErrorCategory, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WebhookDeliveryError\";\n\t\tthis.category = category;\n\t}\n}\n\nexport interface WebhookRequest {\n\turl: string;\n\theaders: Record<string, string>;\n\tbody: string;\n\ttimeoutMs?: number;\n}\n\nexport interface WebhookResponse {\n\tstatus: number;\n\t/** Response body, truncated to 64 KiB. */\n\tbody: string;\n}\n\nexport interface WebhookTransport {\n\tpost(request: WebhookRequest): Promise<WebhookResponse>;\n}\n\nexport interface ResolvedAddress {\n\taddress: string;\n\tfamily: number;\n}\n\n/** Returns a human-readable problem when `value` is not a Standard Webhooks secret. */\nexport function webhookSecretProblem(value: unknown): string | null {\n\tif (typeof value !== \"string\") return \"delivery.secret must be a string\";\n\tif (!value.startsWith(WEBHOOK_SECRET_PREFIX)) {\n\t\treturn `delivery.secret must start with ${WEBHOOK_SECRET_PREFIX}`;\n\t}\n\tconst encoded = value.slice(WEBHOOK_SECRET_PREFIX.length);\n\tif (!/^[A-Za-z0-9+/]+={0,2}$/.test(encoded)) {\n\t\treturn \"delivery.secret must be base64 after the whsec_ prefix\";\n\t}\n\tconst bytes = Buffer.from(encoded, \"base64\");\n\tif (bytes.length < 24 || bytes.length > 64) {\n\t\treturn \"delivery.secret must decode to 24-64 bytes\";\n\t}\n\treturn null;\n}\n\nexport function decodeWebhookSecret(secret: string): Buffer {\n\tconst encoded = secret.startsWith(WEBHOOK_SECRET_PREFIX)\n\t\t? secret.slice(WEBHOOK_SECRET_PREFIX.length)\n\t\t: secret;\n\treturn Buffer.from(encoded, \"base64\");\n}\n\n/**\n * Standard Webhooks signature: `v1,<base64 HMAC-SHA256(secret, id.timestamp.body)>`.\n * The body must be the exact bytes sent on the wire.\n */\nexport function signWebhook(\n\tsecret: string,\n\twebhookId: string,\n\ttimestampSeconds: number,\n\tbody: string,\n): string {\n\tconst digest = createHmac(\"sha256\", decodeWebhookSecret(secret))\n\t\t.update(`${webhookId}.${timestampSeconds}.${body}`, \"utf8\")\n\t\t.digest(\"base64\");\n\treturn `v1,${digest}`;\n}\n\n/** Space-delimited multi-signature header, used for secret rotation. */\nexport function webhookSignatureHeader(\n\tsecrets: readonly string[],\n\twebhookId: string,\n\ttimestampSeconds: number,\n\tbody: string,\n): string {\n\treturn secrets\n\t\t.filter((secret): secret is string => typeof secret === \"string\" && secret.length > 0)\n\t\t.map((secret) => signWebhook(secret, webhookId, timestampSeconds, body))\n\t\t.join(\" \");\n}\n\nexport function webhookErrorCategory(status: number): WebhookErrorCategory {\n\treturn status >= 500 ? \"http_5xx\" : \"http_4xx\";\n}\n\n/** Parse and enforce the `https` requirement for callback URLs. */\nexport function parseCallbackUrl(value: unknown): URL {\n\tif (typeof value !== \"string\" || !value.trim()) {\n\t\tthrow new Error(\"delivery.url must be a non-empty string\");\n\t}\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(value);\n\t} catch {\n\t\tthrow new Error(\"delivery.url must be an absolute URL\");\n\t}\n\tif (url.protocol !== \"https:\") throw new Error(\"delivery.url must use https\");\n\tif (!url.hostname) throw new Error(\"delivery.url must include a hostname\");\n\tif (url.username || url.password) throw new Error(\"delivery.url must not embed credentials\");\n\tif (url.hash) throw new Error(\"delivery.url must not include a fragment\");\n\treturn url;\n}\n\nconst V4_BLOCKLIST: ReadonlyArray<readonly [string, number]> = [\n\t[\"0.0.0.0\", 8],\n\t[\"10.0.0.0\", 8],\n\t[\"100.64.0.0\", 10],\n\t[\"127.0.0.0\", 8],\n\t[\"169.254.0.0\", 16],\n\t[\"172.16.0.0\", 12],\n\t[\"192.0.0.0\", 24],\n\t[\"192.0.2.0\", 24],\n\t[\"192.88.99.0\", 24],\n\t[\"192.168.0.0\", 16],\n\t[\"198.18.0.0\", 15],\n\t[\"198.51.100.0\", 24],\n\t[\"203.0.113.0\", 24],\n\t[\"224.0.0.0\", 4],\n\t[\"240.0.0.0\", 4],\n];\n\nfunction ipv4ToInt(address: string): number {\n\treturn address\n\t\t.split(\".\")\n\t\t.reduce((total, part) => ((total << 8) | (Number(part) & 0xff)) >>> 0, 0);\n}\n\nfunction inV4Range(value: number, base: string, prefix: number): boolean {\n\tconst mask = prefix === 0 ? 0 : (0xffffffff << (32 - prefix)) >>> 0;\n\treturn (value & mask) >>> 0 === (ipv4ToInt(base) & mask) >>> 0;\n}\n\nfunction isPublicV4(address: string): boolean {\n\tconst value = ipv4ToInt(address);\n\treturn !V4_BLOCKLIST.some(([base, prefix]) => inV4Range(value, base, prefix));\n}\n\nfunction isPublicV6(address: string): boolean {\n\tconst normalized =\n\t\taddress\n\t\t\t.toLowerCase()\n\t\t\t.replace(/^\\[|\\]$/g, \"\")\n\t\t\t.split(\"%\")[0] ?? \"\";\n\tif (normalized === \"::\" || normalized === \"::1\") return false;\n\tconst mapped = /^::ffff:(\\d+\\.\\d+\\.\\d+\\.\\d+)$/.exec(normalized);\n\tif (mapped?.[1]) return isPublicV4(mapped[1]);\n\tconst first = normalized.split(\":\")[0] ?? \"\";\n\tif (!first) return false;\n\tconst prefix = Number.parseInt(first.padEnd(4, \"0\"), 16);\n\tif (Number.isNaN(prefix)) return false;\n\t// fc00::/7 (unique local), fe80::/10 (link local), ff00::/8 (multicast),\n\t// 2001:db8::/32 (documentation), 100::/64 (discard-only).\n\tif ((prefix & 0xfe00) === 0xfc00) return false;\n\tif ((prefix & 0xffc0) === 0xfe80) return false;\n\tif ((prefix & 0xff00) === 0xff00) return false;\n\tif (normalized.startsWith(\"2001:db8:\")) return false;\n\tif (normalized === \"100::\" || normalized.startsWith(\"100::\")) return false;\n\treturn true;\n}\n\n/** True when the address is globally routable per the IANA special-purpose registries. */\nexport function isPublicAddress(address: string): boolean {\n\tconst family = isIP(address);\n\tif (family === 4) return isPublicV4(address);\n\tif (family === 6) return isPublicV6(address);\n\treturn false;\n}\n\nexport interface WebhookTransportOptions {\n\t/** Resolve a hostname to candidate addresses. Defaults to dns.lookup({ all: true }). */\n\tresolve?(hostname: string): Promise<ResolvedAddress[]>;\n\ttimeoutMs?: number;\n}\n\n/**\n * Deliveries resolve the callback host on every attempt and connect to the\n * validated address while keeping the original hostname for TLS verification.\n */\nexport function createWebhookTransport(options: WebhookTransportOptions = {}): WebhookTransport {\n\tconst resolve =\n\t\toptions.resolve ?? (async (hostname: string) => dnsLookup(hostname, { all: true }));\n\tconst timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\n\treturn {\n\t\tasync post(request: WebhookRequest): Promise<WebhookResponse> {\n\t\t\tconst url = new URL(request.url);\n\t\t\tconst hostname = url.hostname.replace(/^\\[|\\]$/g, \"\");\n\n\t\t\tlet addresses: ResolvedAddress[];\n\t\t\ttry {\n\t\t\t\taddresses = await resolve(hostname);\n\t\t\t} catch {\n\t\t\t\tthrow new WebhookDeliveryError(\"connection_refused\", `could not resolve ${hostname}`);\n\t\t\t}\n\t\t\tif (!addresses.length) {\n\t\t\t\tthrow new WebhookDeliveryError(\"connection_refused\", `${hostname} did not resolve`);\n\t\t\t}\n\t\t\t// Reject the whole callback when any candidate is non-public: the\n\t\t\t// address actually used must not be attacker-selected at connect time.\n\t\t\tif (addresses.some((entry) => !isPublicAddress(entry.address))) {\n\t\t\t\tthrow new WebhookDeliveryError(\n\t\t\t\t\t\"connection_refused\",\n\t\t\t\t\t`${hostname} resolves to a non-public address`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst target = addresses[0]!;\n\t\t\tconst body = request.body;\n\n\t\t\treturn await new Promise<WebhookResponse>((resolveRequest, rejectRequest) => {\n\t\t\t\tconst headers: Record<string, string> = {\n\t\t\t\t\t...request.headers,\n\t\t\t\t\thost: url.host,\n\t\t\t\t\t\"content-length\": String(Buffer.byteLength(body, \"utf8\")),\n\t\t\t\t};\n\t\t\t\tconst signal = AbortSignal.timeout(request.timeoutMs ?? timeoutMs);\n\t\t\t\tconst call = httpsRequest(\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\thost: hostname,\n\t\t\t\t\t\tport: url.port ? Number(url.port) : 443,\n\t\t\t\t\t\tpath: `${url.pathname}${url.search}`,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\t// SNI and certificate identity checks keep using the hostname\n\t\t\t\t\t\t// while the TCP connection goes to the validated address.\n\t\t\t\t\t\t...(isIP(hostname) ? {} : { servername: hostname }),\n\t\t\t\t\t\tlookup: (_host, lookupOptions, callback) => {\n\t\t\t\t\t\t\tif (lookupOptions?.all) {\n\t\t\t\t\t\t\t\tcallback(null, [{ address: target.address, family: target.family }]);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcallback(null, target.address, target.family);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t},\n\t\t\t\t\t(response) => {\n\t\t\t\t\t\tconst chunks: Buffer[] = [];\n\t\t\t\t\t\tlet size = 0;\n\t\t\t\t\t\tresponse.on(\"data\", (chunk: Buffer) => {\n\t\t\t\t\t\t\tif (size >= MAX_RESPONSE_BYTES) return;\n\t\t\t\t\t\t\tconst slice = chunk.subarray(0, MAX_RESPONSE_BYTES - size);\n\t\t\t\t\t\t\tchunks.push(slice);\n\t\t\t\t\t\t\tsize += slice.length;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.on(\"end\", () => {\n\t\t\t\t\t\t\tresolveRequest({\n\t\t\t\t\t\t\t\tstatus: response.statusCode ?? 0,\n\t\t\t\t\t\t\t\tbody: Buffer.concat(chunks).toString(\"utf8\"),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.on(\"error\", rejectRequest);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tcall.on(\"error\", rejectRequest);\n\t\t\t\tcall.end(body);\n\t\t\t}).catch((error: unknown) => {\n\t\t\t\tthrow toWebhookDeliveryError(error);\n\t\t\t});\n\t\t},\n\t};\n}\n\nconst TLS_ERROR_CODES = [\n\t\"ERR_TLS_CERT_ALTNAME_INVALID\",\n\t\"DEPTH_ZERO_SELF_SIGNED_CERT\",\n\t\"SELF_SIGNED_CERT_IN_CHAIN\",\n\t\"UNABLE_TO_VERIFY_LEAF_SIGNATURE\",\n\t\"UNABLE_TO_GET_ISSUER_CERT_LOCALLY\",\n\t\"CERT_HAS_EXPIRED\",\n\t\"ERR_SSL_WRONG_VERSION_NUMBER\",\n\t\"ERR_SSL_PACKET_LENGTH_MISMATCH\",\n\t\"EPROTO\",\n];\n\nfunction toWebhookDeliveryError(error: unknown): WebhookDeliveryError {\n\tif (error instanceof WebhookDeliveryError) return error;\n\tif (error instanceof Error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code ?? \"\";\n\t\tif (error.name === \"AbortError\" || code === \"ETIMEDOUT\" || code === \"UND_ERR_CONNECT_TIMEOUT\") {\n\t\t\treturn new WebhookDeliveryError(\"timeout\", \"callback endpoint timed out\");\n\t\t}\n\t\tif (\n\t\t\tTLS_ERROR_CODES.includes(code) ||\n\t\t\tcode.startsWith(\"ERR_TLS\") ||\n\t\t\tcode.startsWith(\"ERR_SSL\")\n\t\t) {\n\t\t\treturn new WebhookDeliveryError(\"tls_error\", \"callback endpoint failed TLS verification\");\n\t\t}\n\t\tif (code === \"ECONNREFUSED\" || code === \"ENOTFOUND\" || code === \"EHOSTUNREACH\") {\n\t\t\treturn new WebhookDeliveryError(\n\t\t\t\t\"connection_refused\",\n\t\t\t\t\"callback endpoint refused the connection\",\n\t\t\t);\n\t\t}\n\t\treturn new WebhookDeliveryError(\"connection_refused\", error.message);\n\t}\n\treturn new WebhookDeliveryError(\"connection_refused\", String(error));\n}\n","import { createHash, randomBytes, timingSafeEqual } from \"node:crypto\";\nimport { VERSION } from \"../version.ts\";\nimport {\n\tMAX_WEBHOOK_BODY_BYTES,\n\tWebhookDeliveryError,\n\ttype WebhookTransport,\n\tcreateWebhookTransport,\n\tisPublicAddress,\n\tparseCallbackUrl,\n\twebhookErrorCategory,\n\twebhookSecretProblem,\n\twebhookSignatureHeader,\n} from \"./webhook.ts\";\n\n/**\n * MCP Events (webhook delivery), following the draft extension in\n * https://github.com/modelcontextprotocol/experimental-ext-triggers-events and\n * the subset ChatGPT implements (events/list, events/subscribe,\n * events/unsubscribe, signed webhook deliveries, callback verification).\n */\n\nexport const EVENT_ERROR_NOT_FOUND = -32023;\nexport const EVENT_ERROR_FORBIDDEN = -32024;\nexport const EVENT_ERROR_RESOURCE_EXHAUSTED = -32025;\nexport const EVENT_ERROR_UNSUPPORTED = -32026;\nexport const EVENT_ERROR_CALLBACK = -32027;\nexport const EVENT_ERROR_INVALID_PARAMS = -32602;\n\nexport class EventRpcError extends Error {\n\treadonly code: number;\n\treadonly data?: Record<string, unknown>;\n\n\tconstructor(code: number, message: string, data?: Record<string, unknown>) {\n\t\tsuper(message);\n\t\tthis.name = \"EventRpcError\";\n\t\tthis.code = code;\n\t\tthis.data = data;\n\t}\n}\n\nexport interface McpEventDefinition {\n\tname: string;\n\tdescription: string;\n\t/** Delivery modes this server offers for the event. */\n\tdelivery: readonly string[];\n\tinputSchema: Record<string, unknown>;\n\tpayloadSchema: Record<string, unknown>;\n}\n\ninterface SchemaProperty {\n\ttype?: string;\n\tenum?: readonly unknown[];\n}\n\nconst FILTER_PROPERTIES: Record<\n\tstring,\n\tSchemaProperty & { description: string; default?: unknown }\n> = {\n\tchatId: {\n\t\ttype: \"string\",\n\t\tdescription:\n\t\t\t'Only deliver messages from chats whose id matches this glob pattern (e.g. \"c0123456789abcdef\"). Omit to match every chat.',\n\t},\n\tfrom: {\n\t\ttype: \"string\",\n\t\tdescription:\n\t\t\t\"Only deliver messages whose sender mid matches this glob pattern. Omit to match every sender.\",\n\t},\n\tincludeText: {\n\t\ttype: \"boolean\",\n\t\tdefault: true,\n\t\tdescription:\n\t\t\t\"Include a truncated text preview in the payload. Disable to keep user-authored text out of webhook infrastructure.\",\n\t},\n};\n\nfunction inputSchema(): Record<string, unknown> {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: FILTER_PROPERTIES,\n\t\tadditionalProperties: false,\n\t};\n}\n\nfunction payloadSchema(timestampKey: \"receivedAt\" | \"updatedAt\"): Record<string, unknown> {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: {\n\t\t\tmessageId: { type: \"string\", description: \"Stable LINE message id, usable for dedup.\" },\n\t\t\tchatId: { type: \"string\", description: \"Chat (or OpenChat room) the message belongs to.\" },\n\t\t\tfrom: { type: \"string\", description: \"Sender mid.\" },\n\t\t\tcontentType: { type: \"string\", description: \"LINE content type, e.g. TEXT or IMAGE.\" },\n\t\t\ttext: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Truncated text preview. Omitted when includeText is false or the message has no text.\",\n\t\t\t},\n\t\t\t[timestampKey]: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tformat: \"date-time\",\n\t\t\t\tdescription: \"When the message was sent (ISO 8601).\",\n\t\t\t},\n\t\t},\n\t\trequired: [\"messageId\", \"chatId\", \"from\", \"contentType\", timestampKey],\n\t\tadditionalProperties: false,\n\t};\n}\n\nexport const EVENT_DEFINITIONS: readonly McpEventDefinition[] = [\n\t{\n\t\tname: \"line.message.received\",\n\t\tdescription:\n\t\t\t\"Fires when the connected LINE account receives a new talk message in a one-to-one or group chat.\",\n\t\tdelivery: [\"webhook\"],\n\t\tinputSchema: inputSchema(),\n\t\tpayloadSchema: payloadSchema(\"receivedAt\"),\n\t},\n\t{\n\t\tname: \"line.message.edited\",\n\t\tdescription: \"Fires when a talk message the account can see is edited.\",\n\t\tdelivery: [\"webhook\"],\n\t\tinputSchema: inputSchema(),\n\t\tpayloadSchema: payloadSchema(\"updatedAt\"),\n\t},\n\t{\n\t\tname: \"line.openchat.message.received\",\n\t\tdescription: \"Fires when a message arrives in an OpenChat (square) room.\",\n\t\tdelivery: [\"webhook\"],\n\t\tinputSchema: inputSchema(),\n\t\tpayloadSchema: payloadSchema(\"receivedAt\"),\n\t},\n];\n\nexport type McpEventSourceKind = \"talk\" | \"square\";\n\n/** A single occurrence produced by an event source before per-subscription filtering. */\nexport interface McpEventRecord {\n\tname: string;\n\t/** ISO 8601 timestamp of the occurrence. */\n\toccurredAt: string;\n\tdata: Record<string, unknown>;\n}\n\nexport interface McpEventSource {\n\t/** Resolve once the upstream listener is connected, reject when it cannot start. */\n\tstart(onEvent: (record: McpEventRecord) => void): Promise<void>;\n\tstop(): Promise<void>;\n}\n\nexport type McpEventSourceFactory = (kind: McpEventSourceKind) => McpEventSource;\n\nexport interface McpEventLimits {\n\tmaxSubscriptions: number;\n\tmaxQueue: number;\n\tmaxAttempts: number;\n\tretryBaseMs: number;\n\tretryMaxDelayMs: number;\n\tsuspendAfterFailures: number;\n\tdefaultTtlMs: number;\n\tminTtlMs: number;\n\tmaxTtlMs: number;\n\tverificationTtlMs: number;\n}\n\n/** Longest text preview kept in an event payload. */\nexport const PREVIEW_TEXT_LIMIT = 400;\n\n/** Collapse whitespace and truncate user-authored text for payload minimality. */\nexport function previewText(value: unknown): string | undefined {\n\tif (typeof value !== \"string\" || !value) return undefined;\n\tconst flat = value.replace(/\\s+/g, \" \").trim();\n\tif (!flat) return undefined;\n\treturn flat.length > PREVIEW_TEXT_LIMIT ? `${flat.slice(0, PREVIEW_TEXT_LIMIT)}…` : flat;\n}\n\nconst DEFAULT_LIMITS: McpEventLimits = {\n\tmaxSubscriptions: 20,\n\tmaxQueue: 50,\n\tmaxAttempts: 4,\n\tretryBaseMs: 1_000,\n\tretryMaxDelayMs: 15_000,\n\tsuspendAfterFailures: 5,\n\tdefaultTtlMs: 15 * 60_000,\n\tminTtlMs: 60_000,\n\tmaxTtlMs: 60 * 60_000,\n\tverificationTtlMs: 30 * 60_000,\n};\n\nexport interface McpEventHubOptions {\n\t/** Canonical identity of the caller; the stdio transport uses the local LINE profile. */\n\tprincipal: string;\n\tdefinitions?: readonly McpEventDefinition[];\n\ttransport?: WebhookTransport;\n\t/** Factory used to lazily start the LINE listener for a delivery kind. */\n\tsourceFactory?: McpEventSourceFactory;\n\tnow?: () => number;\n\tdelay?: (ms: number) => Promise<void>;\n\tlog?: (message: string) => void;\n\tlimits?: Partial<McpEventLimits>;\n\t/** Sweep expired subscriptions on an interval. Defaults to true. */\n\tautoSweep?: boolean;\n}\n\nexport interface EventSubscribeResult {\n\tid: string;\n\trefreshBefore: string | null;\n\tcursor: null;\n\ttruncated: boolean;\n\tdeliveryStatus?: Record<string, unknown>;\n}\n\ninterface DeliveryJob {\n\toccurrence: McpEventOccurrence;\n\tbody: string;\n}\n\ninterface McpEventOccurrence {\n\teventId: string;\n\tname: string;\n\ttimestamp: string;\n\tdata: Record<string, unknown>;\n\tcursor: null;\n}\n\ninterface Subscription {\n\tid: string;\n\tprincipal: string;\n\tname: string;\n\targuments: Record<string, unknown>;\n\turl: string;\n\tsecret: string;\n\tpreviousSecret?: string;\n\tpreviousSecretUntil?: number;\n\texpiresAt: number;\n\tactive: boolean;\n\tlastDeliveryAt?: string;\n\tlastError?: string;\n\tfailedSince?: string;\n\tconsecutiveFailures: number;\n\tqueue: DeliveryJob[];\n\tdraining: boolean;\n\tremoved: boolean;\n}\n\nfunction canonicalize(value: unknown): string {\n\tif (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n\tif (Array.isArray(value)) return `[${value.map(canonicalize).join(\",\")}]`;\n\tconst entries = Object.entries(value as Record<string, unknown>)\n\t\t.filter(([, entry]) => entry !== undefined)\n\t\t.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n\treturn `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonicalize(entry)}`).join(\",\")}}`;\n}\n\n/** Canonical JSON with sorted keys, so equivalent arguments share one subscription. */\nexport function canonicalJson(value: unknown): string {\n\treturn canonicalize(value ?? {});\n}\n\nfunction globToRegExp(pattern: string): RegExp {\n\tlet source = \"\";\n\tfor (const character of pattern) {\n\t\tif (character === \"*\") source += \".*\";\n\t\telse if (character === \"?\") source += \".\";\n\t\telse source += character.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t}\n\treturn new RegExp(`^${source}$`, \"u\");\n}\n\nfunction matchesFilters(filters: Record<string, unknown>, data: Record<string, unknown>): boolean {\n\tconst chatId = typeof filters.chatId === \"string\" ? filters.chatId : undefined;\n\tif (chatId && !globToRegExp(chatId).test(String(data.chatId ?? \"\"))) return false;\n\tconst from = typeof filters.from === \"string\" ? filters.from : undefined;\n\tif (from && !globToRegExp(from).test(String(data.from ?? \"\"))) return false;\n\treturn true;\n}\n\nfunction validateArguments(\n\tdefinition: McpEventDefinition,\n\tvalue: unknown,\n): Record<string, unknown> {\n\tif (value === undefined || value === null) return {};\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.arguments must be an object\");\n\t}\n\tconst properties = (definition.inputSchema.properties ?? {}) as Record<string, SchemaProperty>;\n\tconst entries = value as Record<string, unknown>;\n\tfor (const key of Object.keys(entries)) {\n\t\tif (!(key in properties)) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t`Unknown argument for ${definition.name}: ${key}`,\n\t\t\t\t{ argument: key },\n\t\t\t);\n\t\t}\n\t}\n\tfor (const [key, schema] of Object.entries(properties)) {\n\t\tconst entry = entries[key];\n\t\tif (entry === undefined) continue;\n\t\tconst invalid = () => {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t`Argument ${key} must be ${schema.type}`,\n\t\t\t\t{ argument: key },\n\t\t\t);\n\t\t};\n\t\tif (schema.type === \"string\") {\n\t\t\tif (typeof entry !== \"string\" || entry.length > 512) invalid();\n\t\t} else if (schema.type === \"boolean\") {\n\t\t\tif (typeof entry !== \"boolean\") invalid();\n\t\t} else if (schema.type === \"integer\") {\n\t\t\tif (!Number.isInteger(entry)) invalid();\n\t\t} else if (schema.type === \"number\") {\n\t\t\tif (typeof entry !== \"number\" || !Number.isFinite(entry)) invalid();\n\t\t}\n\t\tif (schema.enum && !schema.enum.includes(entry)) invalid();\n\t}\n\treturn entries;\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n\tconst a = Buffer.from(left, \"utf8\");\n\tconst b = Buffer.from(right, \"utf8\");\n\tif (a.length !== b.length) return false;\n\treturn timingSafeEqual(a, b);\n}\n\nexport class McpEventHub {\n\treadonly principal: string;\n\treadonly definitions: readonly McpEventDefinition[];\n\treadonly limits: McpEventLimits;\n\n\tprivate readonly transport: WebhookTransport;\n\tprivate readonly sourceFactory: McpEventSourceFactory | undefined;\n\tprivate readonly clock: () => number;\n\tprivate readonly delay: (ms: number) => Promise<void>;\n\tprivate readonly log: (message: string) => void;\n\tprivate readonly subscriptions = new Map<string, Subscription>();\n\tprivate readonly sources = new Map<McpEventSourceKind, McpEventSource>();\n\tprivate readonly verified = new Map<string, number>();\n\tprivate readonly workers = new Set<Promise<void>>();\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate closed = false;\n\n\tconstructor(options: McpEventHubOptions) {\n\t\tthis.principal = options.principal;\n\t\tthis.definitions = options.definitions ?? EVENT_DEFINITIONS;\n\t\tthis.limits = { ...DEFAULT_LIMITS, ...options.limits };\n\t\tthis.transport = options.transport ?? createWebhookTransport();\n\t\tthis.sourceFactory = options.sourceFactory;\n\t\tthis.clock = options.now ?? Date.now;\n\t\tthis.delay =\n\t\t\toptions.delay ??\n\t\t\t((ms) =>\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\tconst timer = setTimeout(resolve, ms);\n\t\t\t\t\ttimer.unref?.();\n\t\t\t\t}));\n\t\tthis.log = options.log ?? (() => {});\n\t\tif (options.autoSweep !== false) {\n\t\t\tthis.timer = setInterval(() => this.sweep(), 30_000);\n\t\t\tthis.timer.unref?.();\n\t\t}\n\t}\n\n\tget activeSubscriptionCount(): number {\n\t\treturn this.subscriptions.size;\n\t}\n\n\tlist(params: Record<string, unknown> = {}): Record<string, unknown> {\n\t\tconst cursor = params.cursor;\n\t\tif (cursor !== undefined && cursor !== null && typeof cursor !== \"string\") {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.cursor must be a string\");\n\t\t}\n\t\t// The catalogue is small enough to return in a single page.\n\t\treturn {\n\t\t\tevents: this.definitions.map((definition) => ({\n\t\t\t\tname: definition.name,\n\t\t\t\tdescription: definition.description,\n\t\t\t\tdelivery: [...definition.delivery],\n\t\t\t\tinputSchema: definition.inputSchema,\n\t\t\t\tpayloadSchema: definition.payloadSchema,\n\t\t\t})),\n\t\t};\n\t}\n\n\tasync subscribe(params: Record<string, unknown>): Promise<EventSubscribeResult> {\n\t\tconst definition = this.definitionFor(params.name);\n\t\tconst filters = validateArguments(definition, params.arguments);\n\t\tconst delivery = this.validateDelivery(params.delivery);\n\t\tconst ttlMs = this.grantTtl(params.ttlMs);\n\t\tconst id = this.subscriptionId(delivery.url, definition.name, filters);\n\t\tconst existing = this.subscriptions.get(id);\n\t\tif (!existing && this.subscriptions.size >= this.limits.maxSubscriptions) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_RESOURCE_EXHAUSTED,\n\t\t\t\t`At most ${this.limits.maxSubscriptions} webhook subscriptions are supported`,\n\t\t\t\t{ limit: \"subscriptions\", max: this.limits.maxSubscriptions },\n\t\t\t);\n\t\t}\n\n\t\tawait this.verifyEndpoint(delivery.url, delivery.secret, id);\n\n\t\tconst now = this.clock();\n\t\t// Report the state the refresh replaces: `active: false` tells the client\n\t\t// deliveries had been suspended and that this refresh reactivates them.\n\t\tconst previousStatus = existing\n\t\t\t? {\n\t\t\t\t\tactive: existing.active,\n\t\t\t\t\tlastDeliveryAt: existing.lastDeliveryAt ?? null,\n\t\t\t\t\tlastError: existing.lastError ?? null,\n\t\t\t\t\t...(existing.failedSince ? { failedSince: existing.failedSince } : {}),\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tconst subscription: Subscription = existing ?? {\n\t\t\tid,\n\t\t\tprincipal: this.principal,\n\t\t\tname: definition.name,\n\t\t\targuments: filters,\n\t\t\turl: delivery.url,\n\t\t\tsecret: delivery.secret,\n\t\t\texpiresAt: now + ttlMs,\n\t\t\tactive: true,\n\t\t\tconsecutiveFailures: 0,\n\t\t\tqueue: [],\n\t\t\tdraining: false,\n\t\t\tremoved: false,\n\t\t};\n\t\tsubscription.secret = delivery.secret;\n\t\tif (existing?.secret && existing.secret !== delivery.secret) {\n\t\t\t// Standard Webhooks multi-signature grace window for secret rotation.\n\t\t\tsubscription.previousSecret = existing.secret;\n\t\t\tsubscription.previousSecretUntil = now + 5 * 60_000;\n\t\t}\n\t\tsubscription.expiresAt = now + ttlMs;\n\t\tsubscription.active = true;\n\t\tsubscription.consecutiveFailures = 0;\n\t\tsubscription.removed = false;\n\t\tthis.subscriptions.set(id, subscription);\n\n\t\ttry {\n\t\t\tawait this.ensureSources();\n\t\t} catch (error) {\n\t\t\t// A refresh keeps the existing subscription; only a brand-new one is rolled back.\n\t\t\tif (!existing) this.dropSubscription(subscription);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (existing) this.scheduleDrain(subscription);\n\t\treturn {\n\t\t\tid,\n\t\t\trefreshBefore: new Date(subscription.expiresAt).toISOString(),\n\t\t\tcursor: null,\n\t\t\ttruncated: false,\n\t\t\t...(previousStatus ? { deliveryStatus: previousStatus } : {}),\n\t\t};\n\t}\n\n\tunsubscribe(params: Record<string, unknown>): Record<string, never> {\n\t\tconst definition = this.definitionFor(params.name);\n\t\tconst filters = validateArguments(definition, params.arguments);\n\t\tconst delivery = this.validateDelivery(params.delivery, { requireSecret: false });\n\t\tconst id = this.subscriptionId(delivery.url, definition.name, filters);\n\t\tconst subscription = this.subscriptions.get(id);\n\t\t// Idempotent: an unknown key is not an error.\n\t\tif (subscription) this.dropSubscription(subscription);\n\t\tvoid this.stopUnusedSources();\n\t\treturn {};\n\t}\n\n\t/** Deliver one occurrence to every active, matching subscription. */\n\temit(record: McpEventRecord): void {\n\t\tif (this.closed) return;\n\t\tconst timestamp = record.occurredAt || new Date(this.clock()).toISOString();\n\t\tfor (const subscription of this.subscriptions.values()) {\n\t\t\tif (subscription.removed || !subscription.active) continue;\n\t\t\tif (subscription.name !== record.name) continue;\n\t\t\tif (!matchesFilters(subscription.arguments, record.data)) continue;\n\t\t\tconst stampKey = subscription.name === \"line.message.edited\" ? \"updatedAt\" : \"receivedAt\";\n\t\t\tconst data = this.projectPayload(subscription.name, record.data, stampKey, timestamp);\n\t\t\tif (subscription.arguments.includeText === false) delete data.text;\n\t\t\tthis.enqueue(subscription, {\n\t\t\t\teventId: this.eventIdFor(subscription.name, data, timestamp),\n\t\t\t\tname: subscription.name,\n\t\t\t\ttimestamp,\n\t\t\t\tdata,\n\t\t\t\tcursor: null,\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Keep only the fields advertised by the event's payloadSchema. */\n\tprivate projectPayload(\n\t\tname: string,\n\t\tsource: Record<string, unknown>,\n\t\tstampKey: \"receivedAt\" | \"updatedAt\",\n\t\ttimestamp: string,\n\t): Record<string, unknown> {\n\t\tconst definition = this.definitions.find((entry) => entry.name === name);\n\t\tconst properties = (definition?.payloadSchema.properties ?? {}) as Record<string, unknown>;\n\t\tconst data: Record<string, unknown> = {};\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst value = key === stampKey ? timestamp : source[key];\n\t\t\tif (value !== undefined && value !== null) data[key] = value;\n\t\t}\n\t\treturn data;\n\t}\n\n\t/** Wait for queued deliveries to finish (used by tests and graceful shutdown). */\n\tasync flushDeliveries(): Promise<void> {\n\t\twhile (this.workers.size) {\n\t\t\tawait Promise.allSettled(this.workers);\n\t\t}\n\t}\n\n\t/** Drop expired subscriptions. Returns the ids that were removed. */\n\tsweep(): string[] {\n\t\tconst now = this.clock();\n\t\tconst removed: string[] = [];\n\t\tfor (const subscription of this.subscriptions.values()) {\n\t\t\tif (subscription.expiresAt <= now) {\n\t\t\t\tthis.dropSubscription(subscription);\n\t\t\t\tremoved.push(subscription.id);\n\t\t\t}\n\t\t}\n\t\tfor (const [key, expiresAt] of this.verified) {\n\t\t\tif (expiresAt <= now) this.verified.delete(key);\n\t\t}\n\t\tvoid this.stopUnusedSources();\n\t\treturn removed;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.closed = true;\n\t\tif (this.timer) clearInterval(this.timer);\n\t\tthis.timer = undefined;\n\t\tfor (const subscription of this.subscriptions.values()) this.dropSubscription(subscription);\n\t\tconst sources = [...this.sources.values()];\n\t\tthis.sources.clear();\n\t\tawait Promise.all(sources.map(async (source) => await source.stop().catch(() => {})));\n\t}\n\n\tprivate definitionFor(name: unknown): McpEventDefinition {\n\t\tif (typeof name !== \"string\" || !name) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.name must be a string\");\n\t\t}\n\t\tconst definition = this.definitions.find((entry) => entry.name === name);\n\t\tif (!definition) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_NOT_FOUND, `Unknown event: ${name}`, {\n\t\t\t\tkind: \"event\",\n\t\t\t});\n\t\t}\n\t\treturn definition;\n\t}\n\n\tprivate validateDelivery(\n\t\tvalue: unknown,\n\t\toptions: { requireSecret?: boolean } = {},\n\t): { url: string; secret: string } {\n\t\tconst requireSecret = options.requireSecret ?? true;\n\t\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.delivery must be an object\");\n\t\t}\n\t\tconst delivery = value as Record<string, unknown>;\n\t\tif (delivery.mode !== undefined && delivery.mode !== \"webhook\") {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_UNSUPPORTED,\n\t\t\t\t`Unsupported delivery mode: ${String(delivery.mode)}`,\n\t\t\t\t{ feature: \"deliveryMode\", value: delivery.mode ?? null },\n\t\t\t);\n\t\t}\n\t\tlet url: URL;\n\t\ttry {\n\t\t\turl = parseCallbackUrl(delivery.url);\n\t\t} catch (error) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t}\n\t\tconst hostname = url.hostname.replace(/^\\[|\\]$/g, \"\");\n\t\tif (/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(hostname) || hostname.includes(\":\")) {\n\t\t\tif (!isPublicAddress(hostname)) {\n\t\t\t\tthrow new EventRpcError(\n\t\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t\t\"delivery.url must point at a globally routable address\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tlet secret = \"\";\n\t\tif (requireSecret || delivery.secret !== undefined) {\n\t\t\tconst problem = webhookSecretProblem(delivery.secret);\n\t\t\tif (problem) throw new EventRpcError(EVENT_ERROR_INVALID_PARAMS, problem);\n\t\t\tsecret = delivery.secret as string;\n\t\t}\n\t\treturn { url: url.toString(), secret };\n\t}\n\n\tprivate grantTtl(requested: unknown): number {\n\t\tif (requested === null) {\n\t\t\t// No-expiry grants would require durable storage; this server keeps\n\t\t\t// subscriptions in memory and answers a finite grant instead.\n\t\t\treturn this.limits.maxTtlMs;\n\t\t}\n\t\tif (requested === undefined) return this.limits.defaultTtlMs;\n\t\tif (typeof requested !== \"number\" || !Number.isFinite(requested) || requested <= 0) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t\"params.ttlMs must be a positive integer\",\n\t\t\t);\n\t\t}\n\t\tconst floored = Math.max(Math.floor(requested), this.limits.minTtlMs);\n\t\treturn Math.min(floored, this.limits.maxTtlMs);\n\t}\n\n\tprivate subscriptionId(url: string, name: string, filters: Record<string, unknown>): string {\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(canonicalJson({ principal: this.principal, url, name, arguments: filters }))\n\t\t\t.digest(\"hex\");\n\t\treturn `sub_${digest.slice(0, 16)}`;\n\t}\n\n\tprivate async verifyEndpoint(url: string, secret: string, subscriptionId: string): Promise<void> {\n\t\tconst key = `${this.principal}\\u0000${url}`;\n\t\tconst cached = this.verified.get(key);\n\t\tif (cached !== undefined && cached > this.clock()) return;\n\n\t\tconst challenge = randomBytes(24).toString(\"base64url\");\n\t\tconst body = JSON.stringify({ type: \"verification\", challenge });\n\t\tconst webhookId = `msg_verification_${randomBytes(8).toString(\"hex\")}`;\n\t\tconst timestamp = Math.floor(this.clock() / 1000);\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await this.transport.post({\n\t\t\t\turl,\n\t\t\t\tbody,\n\t\t\t\theaders: {\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\t\"webhook-id\": webhookId,\n\t\t\t\t\t\"webhook-timestamp\": String(timestamp),\n\t\t\t\t\t\"webhook-signature\": webhookSignatureHeader([secret], webhookId, timestamp, body),\n\t\t\t\t\t\"x-mcp-subscription-id\": subscriptionId,\n\t\t\t\t\t\"user-agent\": `linejs-cli/${VERSION}`,\n\t\t\t\t},\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconst reason = error instanceof WebhookDeliveryError ? error.category : \"connection_refused\";\n\t\t\tthrow new EventRpcError(EVENT_ERROR_CALLBACK, \"Could not verify the callback endpoint\", {\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t\tif (response.status < 200 || response.status >= 300) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_CALLBACK, \"Could not verify the callback endpoint\", {\n\t\t\t\treason: webhookErrorCategory(response.status),\n\t\t\t});\n\t\t}\n\t\tlet echoed: unknown;\n\t\ttry {\n\t\t\techoed = (JSON.parse(response.body) as Record<string, unknown>).challenge;\n\t\t} catch {\n\t\t\techoed = undefined;\n\t\t}\n\t\tif (typeof echoed !== \"string\" || !constantTimeEqual(echoed, challenge)) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_CALLBACK, \"Could not verify the callback endpoint\", {\n\t\t\t\treason: \"challenge_failed\",\n\t\t\t});\n\t\t}\n\t\tthis.verified.set(key, this.clock() + this.limits.verificationTtlMs);\n\t}\n\n\tprivate eventIdFor(name: string, data: Record<string, unknown>, timestamp: string): string {\n\t\tconst messageId = typeof data.messageId === \"string\" ? data.messageId : undefined;\n\t\tif (!messageId) return `evt_${randomBytes(12).toString(\"hex\")}`;\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(`${name}\\u0000${messageId}\\u0000${timestamp}`)\n\t\t\t.digest(\"hex\");\n\t\treturn `evt_${digest.slice(0, 24)}`;\n\t}\n\n\tprivate enqueue(subscription: Subscription, occurrence: McpEventOccurrence): void {\n\t\tconst body = JSON.stringify(occurrence);\n\t\tif (Buffer.byteLength(body, \"utf8\") > MAX_WEBHOOK_BODY_BYTES) {\n\t\t\tthis.log(`dropped oversized event ${occurrence.eventId} (${occurrence.name})`);\n\t\t\treturn;\n\t\t}\n\t\tif (subscription.queue.length >= this.limits.maxQueue) {\n\t\t\tconst dropped = subscription.queue.shift();\n\t\t\tif (dropped) {\n\t\t\t\tthis.log(\n\t\t\t\t\t`delivery queue full for ${subscription.id}; dropped ${dropped.occurrence.eventId}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tsubscription.queue.push({ occurrence, body });\n\t\tthis.scheduleDrain(subscription);\n\t}\n\n\tprivate scheduleDrain(subscription: Subscription): void {\n\t\tif (subscription.draining) return;\n\t\tconst worker: Promise<void> = this.drain(subscription).finally(() => {\n\t\t\tthis.workers.delete(worker);\n\t\t});\n\t\tthis.workers.add(worker);\n\t}\n\n\tprivate async drain(subscription: Subscription): Promise<void> {\n\t\tif (subscription.draining || this.closed) return;\n\t\tsubscription.draining = true;\n\t\ttry {\n\t\t\twhile (\n\t\t\t\t!this.closed &&\n\t\t\t\t!subscription.removed &&\n\t\t\t\tsubscription.active &&\n\t\t\t\tsubscription.queue.length\n\t\t\t) {\n\t\t\t\tconst job = subscription.queue.shift()!;\n\t\t\t\tawait this.deliver(subscription, job);\n\t\t\t}\n\t\t} finally {\n\t\t\tsubscription.draining = false;\n\t\t}\n\t}\n\n\tprivate async deliver(subscription: Subscription, job: DeliveryJob): Promise<void> {\n\t\tfor (let attempt = 1; attempt <= this.limits.maxAttempts; attempt += 1) {\n\t\t\tif (this.closed || subscription.removed || !subscription.active) return;\n\t\t\tconst timestamp = Math.floor(this.clock() / 1000);\n\t\t\tconst secrets = [subscription.secret];\n\t\t\tif (subscription.previousSecret) secrets.push(subscription.previousSecret);\n\t\t\tlet status = 0;\n\t\t\ttry {\n\t\t\t\tconst response = await this.transport.post({\n\t\t\t\t\turl: subscription.url,\n\t\t\t\t\tbody: job.body,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\t\t\"webhook-id\": job.occurrence.eventId,\n\t\t\t\t\t\t\"webhook-timestamp\": String(timestamp),\n\t\t\t\t\t\t\"webhook-signature\": webhookSignatureHeader(\n\t\t\t\t\t\t\tsecrets,\n\t\t\t\t\t\t\tjob.occurrence.eventId,\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t\tjob.body,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t\"x-mcp-subscription-id\": subscription.id,\n\t\t\t\t\t\t\"user-agent\": `linejs-cli/${VERSION}`,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tstatus = response.status;\n\t\t\t} catch (error) {\n\t\t\t\tconst reason =\n\t\t\t\t\terror instanceof WebhookDeliveryError ? error.category : \"connection_refused\";\n\t\t\t\tthis.recordFailure(subscription, reason);\n\t\t\t\tif (attempt >= this.limits.maxAttempts) return;\n\t\t\t\tawait this.backoff(attempt);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (status >= 200 && status < 300) {\n\t\t\t\tsubscription.lastDeliveryAt = new Date(this.clock()).toISOString();\n\t\t\t\tsubscription.lastError = undefined;\n\t\t\t\tsubscription.failedSince = undefined;\n\t\t\t\tsubscription.consecutiveFailures = 0;\n\t\t\t\tif (\n\t\t\t\t\tsubscription.previousSecretUntil !== undefined &&\n\t\t\t\t\tthis.clock() >= subscription.previousSecretUntil\n\t\t\t\t) {\n\t\t\t\t\tsubscription.previousSecret = undefined;\n\t\t\t\t\tsubscription.previousSecretUntil = undefined;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.recordFailure(subscription, webhookErrorCategory(status));\n\t\t\t// 410 Gone and 413 Payload Too Large are deliberately final.\n\t\t\tif (status === 410 || status === 413) return;\n\t\t\tif (attempt >= this.limits.maxAttempts) return;\n\t\t\tawait this.backoff(attempt);\n\t\t}\n\t}\n\n\tprivate async backoff(attempt: number): Promise<void> {\n\t\tconst delay = Math.min(\n\t\t\tthis.limits.retryBaseMs * 2 ** (attempt - 1),\n\t\t\tthis.limits.retryMaxDelayMs,\n\t\t);\n\t\tawait this.delay(delay);\n\t}\n\n\tprivate recordFailure(subscription: Subscription, reason: string): void {\n\t\tsubscription.consecutiveFailures += 1;\n\t\tsubscription.lastError = reason;\n\t\tsubscription.failedSince ??= new Date(this.clock()).toISOString();\n\t\tif (subscription.consecutiveFailures >= this.limits.suspendAfterFailures) {\n\t\t\tsubscription.active = false;\n\t\t\tthis.log(`suspended webhook delivery for ${subscription.id} after repeated failures`);\n\t\t}\n\t}\n\n\tprivate dropSubscription(subscription: Subscription): void {\n\t\tsubscription.removed = true;\n\t\tsubscription.active = false;\n\t\tsubscription.queue.length = 0;\n\t\tthis.subscriptions.delete(subscription.id);\n\t\tvoid this.stopUnusedSources();\n\t}\n\n\tprivate requiredSourceKinds(): Set<McpEventSourceKind> {\n\t\tconst kinds = new Set<McpEventSourceKind>();\n\t\tfor (const subscription of this.subscriptions.values()) {\n\t\t\tif (subscription.name === \"line.openchat.message.received\") kinds.add(\"square\");\n\t\t\telse kinds.add(\"talk\");\n\t\t}\n\t\treturn kinds;\n\t}\n\n\tprivate async ensureSources(): Promise<void> {\n\t\tconst required = this.requiredSourceKinds();\n\t\tfor (const kind of [\"talk\", \"square\"] as const) {\n\t\t\tif (!required.has(kind)) continue;\n\t\t\tconst existing = this.sources.get(kind);\n\t\t\tif (!existing) {\n\t\t\t\tawait this.startSource(kind);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// A refresh also gives a listener that died (network drop, expired\n\t\t\t// session) another chance to reconnect.\n\t\t\tawait existing.start(this.sourceListener).catch((error: unknown) => {\n\t\t\t\tthis.log(\n\t\t\t\t\t`could not restart the ${kind} LINE listener: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tawait this.stopUnusedSources();\n\t}\n\n\tprivate readonly sourceListener = (record: McpEventRecord): void => {\n\t\tthis.emit(record);\n\t};\n\n\tprivate async startSource(kind: McpEventSourceKind): Promise<void> {\n\t\tif (!this.sourceFactory) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_UNSUPPORTED,\n\t\t\t\t\"Webhook delivery is not available: this server has no LINE event source\",\n\t\t\t\t{ feature: \"events\" },\n\t\t\t);\n\t\t}\n\t\tconst source = this.sourceFactory(kind);\n\t\ttry {\n\t\t\tawait source.start(this.sourceListener);\n\t\t} catch (error) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_FORBIDDEN,\n\t\t\t\t`The LINE listener could not start: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t{ reason: \"upstream_unavailable\" },\n\t\t\t);\n\t\t}\n\t\tthis.sources.set(kind, source);\n\t}\n\n\tprivate async stopUnusedSources(): Promise<void> {\n\t\tconst required = this.requiredSourceKinds();\n\t\tfor (const [kind, source] of this.sources) {\n\t\t\tif (required.has(kind)) continue;\n\t\t\tthis.sources.delete(kind);\n\t\t\tawait source.stop().catch(() => {});\n\t\t}\n\t}\n}\n","import { runCli } from \"../cli.ts\";\nimport {\n\ttype McpEventRecord,\n\ttype McpEventSource,\n\ttype McpEventSourceKind,\n\tpreviewText,\n} from \"./events.ts\";\n\nexport interface LineEventSourceOptions {\n\tkind: McpEventSourceKind;\n\t/** Profile name or path forwarded to `line listen --profile`. */\n\tprofile?: string;\n\t/** Defaults to runCli; injectable for tests. */\n\trun?: typeof runCli;\n\t/** How long to wait for the listener to connect before declaring success. */\n\treadyTimeoutMs?: number;\n\t/** Called when an established listener exits on its own (not via stop()). */\n\tonExit?: (reason: string) => void;\n\tenv?: NodeJS.ProcessEnv;\n}\n\nfunction asString(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && value ? value : undefined;\n}\n\nfunction asTime(value: unknown): string | undefined {\n\tif (typeof value === \"number\" && Number.isFinite(value)) return new Date(value).toISOString();\n\tif (typeof value === \"string\") {\n\t\tconst parsed = new Date(value);\n\t\tif (!Number.isNaN(parsed.getTime())) return parsed.toISOString();\n\t}\n\treturn undefined;\n}\n\nconst EVENT_NAMES: Record<string, string> = {\n\ttalk: \"line.message.received\",\n\t\"talk:edit\": \"line.message.edited\",\n\tsquare: \"line.openchat.message.received\",\n};\n\n/** Map one `line listen --json` NDJSON record onto an MCP event occurrence. */\nexport function toEventRecord(value: Record<string, unknown>): McpEventRecord | undefined {\n\tconst name = typeof value.type === \"string\" ? EVENT_NAMES[value.type] : undefined;\n\tif (!name) return undefined;\n\tconst messageId = asString(value.id);\n\tconst chatId = asString(value.chatMid);\n\tif (!messageId || !chatId) return undefined;\n\tconst occurredAt = asTime(value.createdTime) ?? asTime(value.at) ?? new Date().toISOString();\n\tconst data: Record<string, unknown> = {\n\t\tmessageId,\n\t\tchatId,\n\t\tfrom: asString(value.from) ?? \"\",\n\t\tcontentType: asString(value.contentType) ?? \"UNKNOWN\",\n\t};\n\tconst text = previewText(value.text);\n\tif (text !== undefined) data.text = text;\n\treturn { name, occurredAt, data };\n}\n\n/**\n * Event source backed by the CLI's own `listen --json` command. Running the\n * command in-process reuses the profile, token refresh, and reconnect logic\n * that every other CLI command already uses.\n */\nexport function createLineEventSource(options: LineEventSourceOptions): McpEventSource {\n\tconst run = options.run ?? runCli;\n\tconst readyTimeoutMs = options.readyTimeoutMs ?? 1_500;\n\tconst env = options.env ?? process.env;\n\tlet controller: AbortController | undefined;\n\tlet running: Promise<void> | undefined;\n\n\treturn {\n\t\tasync start(onEvent) {\n\t\t\tif (running) return;\n\t\t\tcontroller = new AbortController();\n\t\t\tconst abortController = controller;\n\n\t\t\tconst args = [...(options.profile ? [\"--profile\", options.profile] : []), \"listen\", \"--json\"];\n\t\t\tif (options.kind === \"square\") args.push(\"--square\");\n\n\t\t\tlet settled = false;\n\t\t\tlet resolveReady: () => void = () => {};\n\t\t\tlet rejectReady: (error: Error) => void = () => {};\n\t\t\tconst ready = new Promise<void>((resolve, reject) => {\n\t\t\t\tresolveReady = resolve;\n\t\t\t\trejectReady = reject;\n\t\t\t});\n\n\t\t\tconst stderr: string[] = [];\n\t\t\tlet stderrSize = 0;\n\t\t\tconst captureStderr = (chunk: string) => {\n\t\t\t\tif (stderrSize >= 4_000) return;\n\t\t\t\tstderr.push(chunk);\n\t\t\t\tstderrSize += chunk.length;\n\t\t\t};\n\n\t\t\tlet buffer = \"\";\n\t\t\tconst onStdout = (chunk: string) => {\n\t\t\t\tbuffer += chunk;\n\t\t\t\tlet index = buffer.indexOf(\"\\n\");\n\t\t\t\twhile (index >= 0) {\n\t\t\t\t\tconst line = buffer.slice(0, index).trim();\n\t\t\t\t\tbuffer = buffer.slice(index + 1);\n\t\t\t\t\tindex = buffer.indexOf(\"\\n\");\n\t\t\t\t\tif (!line) continue;\n\t\t\t\t\tlet parsed: unknown;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tparsed = JSON.parse(line);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) continue;\n\t\t\t\t\tconst record = toEventRecord(parsed as Record<string, unknown>);\n\t\t\t\t\tif (!record) continue;\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tresolveReady();\n\t\t\t\t\t}\n\t\t\t\t\tonEvent(record);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolveReady();\n\t\t\t}, readyTimeoutMs);\n\t\t\ttimer.unref?.();\n\n\t\t\tconst execution = run(args, {\n\t\t\t\tstdout: onStdout,\n\t\t\t\tstderr: captureStderr,\n\t\t\t\tinteractive: false,\n\t\t\t\tmcp: true,\n\t\t\t\thandleSignals: false,\n\t\t\t\tsignal: abortController.signal,\n\t\t\t\tenv: { ...env, LINEJS_NONINTERACTIVE: \"1\" },\n\t\t\t}).then(\n\t\t\t\tasync (result) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tconst detail = stderr.join(\"\").trim();\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\trejectReady(new Error(detail || `line listen exited with code ${result.exitCode}`));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (!abortController.signal.aborted) {\n\t\t\t\t\t\toptions.onExit?.(detail || `line listen exited with code ${result.exitCode}`);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync (error: unknown) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\trejectReady(new Error(detail));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (!abortController.signal.aborted) options.onExit?.(detail);\n\t\t\t\t},\n\t\t\t);\n\t\t\trunning = execution;\n\t\t\t// Clear the handle once the listener exits so a later start() reconnects.\n\t\t\tvoid execution\n\t\t\t\t.catch(() => {})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tif (running === execution) running = undefined;\n\t\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait ready;\n\t\t\t} catch (error) {\n\t\t\t\tabortController.abort();\n\t\t\t\trunning = undefined;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tasync stop() {\n\t\t\tcontroller?.abort();\n\t\t\tcontroller = undefined;\n\t\t\tconst pending = running;\n\t\t\trunning = undefined;\n\t\t\tawait pending?.catch(() => {});\n\t\t},\n\t};\n}\n","import { once } from \"node:events\";\nimport { createInterface } from \"node:readline\";\nimport type { Readable, Writable } from \"node:stream\";\nimport { splitLeadingGlobalOptions } from \"../args.ts\";\nimport { type CommandSpec, commandMetadata, isMcpExecutable } from \"../command.ts\";\nimport { allCommands, resolveCommandTokens } from \"../registry.ts\";\nimport { runCli } from \"../cli.ts\";\nimport { VERSION } from \"../version.ts\";\nimport { errorMessage } from \"../errors.ts\";\nimport { EventRpcError, McpEventHub } from \"./events.ts\";\nimport { createLineEventSource } from \"./listen-source.ts\";\n\nexport const LIST_TOOL_NAME = \"list_linejs_cli\";\nexport const EXECUTE_TOOL_NAME = \"execute_linejs_cli\";\n\nconst PROTOCOL_VERSIONS = [\"2024-11-05\", \"2025-03-26\", \"2025-06-18\"] as const;\nconst LATEST_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1]!;\n\nexport interface ToolDefinition {\n\tname: string;\n\tdescription: string;\n\tinputSchema: Record<string, unknown>;\n}\n\nexport function createToolDefinitions(\n\tcommands: readonly CommandSpec[] = allCommands,\n): ToolDefinition[] {\n\tconst categories = [...new Set(commands.map((command) => command.category))].sort();\n\treturn [\n\t\t{\n\t\t\tname: LIST_TOOL_NAME,\n\t\t\tdescription:\n\t\t\t\t\"List every LINEJS CLI command with its arguments, options, category, and whether it can run through execute_linejs_cli. Use this before calling execute_linejs_cli.\",\n\t\t\tinputSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tcategory: {\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\tdescription: `Only include commands in this category. One of: ${categories.join(\", \")}.`,\n\t\t\t\t\t},\n\t\t\t\t\tincludeOptions: {\n\t\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\t\tdescription: \"Include each command's option metadata (default: true).\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: EXECUTE_TOOL_NAME,\n\t\t\tdescription:\n\t\t\t\t'Execute the LINEJS CLI directly (no shell) with an argv array. Example: {\"args\":[\"profile\",\"get\",\"--json\"]}. The tool forces --json and rejects long-running or nested MCP commands.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\targs: {\n\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\tdescription: 'Arguments after the `line` executable, e.g. [\"chats\",\"list\",\"--json\"].',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"args\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t];\n}\n\nexport interface CliExecutionResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\nexport type CliExecutor = (args: string[]) => Promise<CliExecutionResult>;\n\nexport const defaultCliExecutor: CliExecutor = async (args) => {\n\tconst stdout: string[] = [];\n\tconst stderr: string[] = [];\n\tconst result = await runCli(args, {\n\t\tstdout: (chunk) => stdout.push(chunk),\n\t\tstderr: (chunk) => stderr.push(chunk),\n\t\tinteractive: false,\n\t\tmcp: true,\n\t\thandleSignals: false,\n\t\tenv: { ...process.env, LINEJS_NONINTERACTIVE: \"1\" },\n\t});\n\treturn { exitCode: result.exitCode, stdout: stdout.join(\"\"), stderr: stderr.join(\"\") };\n};\n\nfunction jsonRpcResult(id: string | number | null, result: unknown) {\n\treturn { jsonrpc: \"2.0\", id, result };\n}\n\nfunction jsonRpcError(id: string | number | null, code: number, message: string, data?: unknown) {\n\treturn {\n\t\tjsonrpc: \"2.0\",\n\t\tid,\n\t\terror: { code, message, ...(data === undefined ? {} : { data }) },\n\t};\n}\n\nfunction toolText(text: string, isError = false, structuredContent?: Record<string, unknown>) {\n\treturn {\n\t\tcontent: [{ type: \"text\", text }],\n\t\t...(isError ? { isError: true } : {}),\n\t\t...(structuredContent ? { structuredContent } : {}),\n\t};\n}\n\nfunction listCommands(argumentsValue: Record<string, unknown>) {\n\tconst category =\n\t\ttypeof argumentsValue.category === \"string\" ? argumentsValue.category : undefined;\n\tconst includeOptions = argumentsValue.includeOptions !== false;\n\tconst normalized = category?.trim().toLowerCase();\n\tconst commands = allCommands\n\t\t.filter((command) => {\n\t\t\tif (!normalized) return true;\n\t\t\treturn (\n\t\t\t\tcommand.category.toLowerCase().includes(normalized) ||\n\t\t\t\tcommand.name.toLowerCase().includes(normalized)\n\t\t\t);\n\t\t})\n\t\t.map((command) => commandMetadata(command, includeOptions));\n\treturn {\n\t\tcommandCount: commands.length,\n\t\tcommands,\n\t};\n}\n\nasync function executeCommand(\n\targumentsValue: Record<string, unknown>,\n\texecutor: CliExecutor,\n): Promise<Record<string, unknown>> {\n\tif (\n\t\t!Array.isArray(argumentsValue.args) ||\n\t\t!argumentsValue.args.every((entry) => typeof entry === \"string\")\n\t) {\n\t\treturn toolText(\"execute_linejs_cli requires args: string[].\", true);\n\t}\n\tconst args = argumentsValue.args as string[];\n\tif (!args.length) return toolText(\"execute_linejs_cli requires at least one argument.\", true);\n\tif (args.includes(\"--password-stdin\")) {\n\t\treturn toolText(\n\t\t\t\"--password-stdin reads stdin, which belongs to the MCP transport. Use --password, or log in from a terminal.\",\n\t\t\ttrue,\n\t\t);\n\t}\n\tconst argsFileIndex = args.findIndex(\n\t\t(arg) => arg === \"--args-file\" || arg.startsWith(\"--args-file=\"),\n\t);\n\tif (\n\t\targsFileIndex !== -1 &&\n\t\t(args[argsFileIndex] === \"--args-file=-\" || args[argsFileIndex + 1] === \"-\")\n\t) {\n\t\treturn toolText(\n\t\t\t\"--args-file - reads stdin, which belongs to the MCP transport. Use a file path.\",\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tlet rest: string[];\n\ttry {\n\t\t({ rest } = splitLeadingGlobalOptions(args));\n\t} catch (error) {\n\t\treturn toolText(errorMessage(error), true);\n\t}\n\tconst resolution = resolveCommandTokens(rest);\n\tconst command = resolution.command;\n\tif (!command) {\n\t\tconst detail = resolution.group\n\t\t\t? `\"${resolution.group}\" is a command group, not an executable command. Run list_linejs_cli for exact names.`\n\t\t\t: `Unknown command: ${resolution.unknown ?? rest[0] ?? \"(none)\"}. Run list_linejs_cli first.`;\n\t\treturn toolText(detail, true);\n\t}\n\tif (command.name === \"mcp\") {\n\t\treturn toolText(\"The mcp command cannot be nested inside an MCP server.\", true);\n\t}\n\tif (!isMcpExecutable(command)) {\n\t\treturn toolText(\n\t\t\t`${command.name} is ${command.longRunning ? \"long-running\" : \"not exposed to MCP\"} and cannot run through execute_linejs_cli.`,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst separator = args.indexOf(\"--\");\n\tconst executionArgs =\n\t\tseparator === -1\n\t\t\t? [...args, \"--json\"]\n\t\t\t: [...args.slice(0, separator), \"--json\", ...args.slice(separator)];\n\tconst execution = await executor(executionArgs);\n\tconst output = execution.stdout.trimEnd();\n\tconst errorText = execution.stderr.trimEnd();\n\tconst content = [\n\t\t{\n\t\t\ttype: \"text\",\n\t\t\ttext: output || errorText || `(no output; exit code ${execution.exitCode})`,\n\t\t},\n\t\t...(errorText && output ? [{ type: \"text\", text: `stderr:\\n${errorText}` }] : []),\n\t];\n\treturn {\n\t\tcontent,\n\t\t...(execution.exitCode === 0 ? {} : { isError: true }),\n\t\tstructuredContent: {\n\t\t\texitCode: execution.exitCode,\n\t\t\tstdout: execution.stdout,\n\t\t\tstderr: execution.stderr,\n\t\t},\n\t};\n}\n\nexport async function handleMcpMessage(\n\tmessage: unknown,\n\toptions: {\n\t\tcommands?: readonly CommandSpec[];\n\t\texecutor?: CliExecutor;\n\t\tevents?: McpEventHub;\n\t} = {},\n): Promise<unknown | null> {\n\tif (!message || typeof message !== \"object\" || Array.isArray(message)) {\n\t\treturn jsonRpcError(null, -32600, \"Invalid Request\");\n\t}\n\tconst request = message as Record<string, unknown>;\n\tconst id = (request.id as string | number | null | undefined) ?? null;\n\tconst isNotification = request.id === undefined;\n\tconst method = request.method;\n\tif (typeof method !== \"string\") {\n\t\treturn isNotification ? null : jsonRpcError(id, -32600, \"Invalid Request\");\n\t}\n\tif (request.jsonrpc !== \"2.0\") {\n\t\treturn isNotification ? null : jsonRpcError(id, -32600, \"Invalid Request\");\n\t}\n\n\tif (isNotification) return null;\n\n\tswitch (method) {\n\t\tcase \"initialize\": {\n\t\t\tconst params = (request.params ?? {}) as Record<string, unknown>;\n\t\t\tconst requested = params.protocolVersion;\n\t\t\tconst protocolVersion =\n\t\t\t\ttypeof requested === \"string\" &&\n\t\t\t\t(PROTOCOL_VERSIONS as readonly string[]).includes(requested)\n\t\t\t\t\t? requested\n\t\t\t\t\t: LATEST_PROTOCOL_VERSION;\n\t\t\treturn jsonRpcResult(id, {\n\t\t\t\tprotocolVersion,\n\t\t\t\tcapabilities: { tools: { listChanged: false }, events: {} },\n\t\t\t\tserverInfo: { name: \"@evex-dev/linejs-cli\", version: VERSION },\n\t\t\t\tinstructions:\n\t\t\t\t\t\"Use list_linejs_cli to discover commands, then execute_linejs_cli with an argv array. No shell is involved; --json is forced. Long-running commands such as listen are rejected. MCP Events (webhook delivery) are available through events/list, events/subscribe, and events/unsubscribe.\",\n\t\t\t});\n\t\t}\n\t\tcase \"ping\":\n\t\t\treturn jsonRpcResult(id, {});\n\t\tcase \"tools/list\": {\n\t\t\treturn jsonRpcResult(id, {\n\t\t\t\ttools: createToolDefinitions(options.commands ?? allCommands),\n\t\t\t});\n\t\t}\n\t\tcase \"tools/call\": {\n\t\t\tconst params = (request.params ?? {}) as Record<string, unknown>;\n\t\t\tconst name = params.name;\n\t\t\tconst argumentsValue =\n\t\t\t\tparams.arguments && typeof params.arguments === \"object\" && !Array.isArray(params.arguments)\n\t\t\t\t\t? (params.arguments as Record<string, unknown>)\n\t\t\t\t\t: {};\n\t\t\tif (name === LIST_TOOL_NAME) {\n\t\t\t\tconst result = listCommands(argumentsValue);\n\t\t\t\treturn jsonRpcResult(id, {\n\t\t\t\t\tcontent: [{ type: \"text\", text: JSON.stringify(result, null, 2) }],\n\t\t\t\t\tstructuredContent: result,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (name === EXECUTE_TOOL_NAME) {\n\t\t\t\treturn jsonRpcResult(\n\t\t\t\t\tid,\n\t\t\t\t\tawait executeCommand(argumentsValue, options.executor ?? defaultCliExecutor),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn jsonRpcError(id, -32602, `Unknown tool: ${String(name)}`);\n\t\t}\n\t\tcase \"events/list\":\n\t\tcase \"events/subscribe\":\n\t\tcase \"events/unsubscribe\": {\n\t\t\tconst hub = options.events;\n\t\t\tif (!hub) return jsonRpcError(id, -32601, `Method not found: ${method}`);\n\t\t\tconst params = (request.params ?? {}) as Record<string, unknown>;\n\t\t\ttry {\n\t\t\t\tif (method === \"events/list\") return jsonRpcResult(id, hub.list(params));\n\t\t\t\tif (method === \"events/subscribe\") {\n\t\t\t\t\treturn jsonRpcResult(id, await hub.subscribe(params));\n\t\t\t\t}\n\t\t\t\treturn jsonRpcResult(id, hub.unsubscribe(params));\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof EventRpcError) {\n\t\t\t\t\treturn jsonRpcError(id, error.code, error.message, error.data);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tcase \"resources/list\":\n\t\t\treturn jsonRpcResult(id, { resources: [] });\n\t\tcase \"prompts/list\":\n\t\t\treturn jsonRpcResult(id, { prompts: [] });\n\t\tcase \"logging/setLevel\":\n\t\t\treturn jsonRpcResult(id, {});\n\t\tdefault:\n\t\t\treturn jsonRpcError(id, -32601, `Method not found: ${method}`);\n\t}\n}\n\nexport interface RunMcpServerOptions {\n\tinput?: Readable;\n\toutput?: Writable;\n\terror?: Writable;\n\tcommands?: readonly CommandSpec[];\n\texecutor?: CliExecutor;\n\tsignal?: AbortSignal;\n\t/** Identity used to scope webhook subscriptions; defaults to \"stdio\". */\n\tprincipal?: string;\n\t/** Profile name or path the event listener should use. */\n\tprofile?: string;\n\t/** Inject a hub (tests); otherwise one backed by `line listen` is created. */\n\tevents?: McpEventHub;\n}\n\nexport async function runMcpServer(options: RunMcpServerOptions = {}): Promise<number> {\n\tconst input = options.input ?? process.stdin;\n\tconst output = options.output ?? process.stdout;\n\tconst error = options.error ?? process.stderr;\n\tconst commands = options.commands ?? allCommands;\n\tconst executor = options.executor ?? defaultCliExecutor;\n\tconst events =\n\t\toptions.events ??\n\t\tnew McpEventHub({\n\t\t\tprincipal: options.principal ?? \"stdio\",\n\t\t\tsourceFactory: (kind) =>\n\t\t\t\tcreateLineEventSource({\n\t\t\t\t\tkind,\n\t\t\t\t\tprofile: options.profile,\n\t\t\t\t\tonExit: (reason) => error.write(`[mcp-events] LINE listener exited: ${reason}\\n`),\n\t\t\t\t}),\n\t\t\tlog: (message) => error.write(`[mcp-events] ${message}\\n`),\n\t\t});\n\n\tconst write = async (value: unknown) => {\n\t\tif (!output.write(`${JSON.stringify(value)}\\n`)) {\n\t\t\tawait once(output, \"drain\");\n\t\t}\n\t};\n\n\terror.write(\"@evex-dev/linejs-cli MCP server listening on stdio\\n\");\n\n\tconst lines = createInterface({ input, crlfDelay: Infinity });\n\tconst onAbort = () => lines.close();\n\tif (options.signal) {\n\t\tif (options.signal.aborted) lines.close();\n\t\telse options.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t}\n\tlet queue: Promise<void> = Promise.resolve();\n\tfor await (const line of lines) {\n\t\tif (!line.trim()) continue;\n\t\tqueue = queue.then(async () => {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(line);\n\t\t\t} catch (parseError) {\n\t\t\t\tawait write(jsonRpcError(null, -32700, \"Parse error\", String(parseError)));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (Array.isArray(parsed)) {\n\t\t\t\t\tconst responses = [];\n\t\t\t\t\tfor (const entry of parsed) {\n\t\t\t\t\t\tconst response = await handleMcpMessage(entry, { commands, executor, events });\n\t\t\t\t\t\tif (response !== null) responses.push(response);\n\t\t\t\t\t}\n\t\t\t\t\tif (responses.length) await write(responses);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst response = await handleMcpMessage(parsed, { commands, executor, events });\n\t\t\t\tif (response !== null) await write(response);\n\t\t\t} catch (handlerError) {\n\t\t\t\tawait write(\n\t\t\t\t\tjsonRpcError(\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t-32603,\n\t\t\t\t\t\t\"Internal error\",\n\t\t\t\t\t\thandlerError instanceof Error ? handlerError.message : String(handlerError),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}\n\tawait queue;\n\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\tawait events.close();\n\treturn 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB;AAGrC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAU3B,IAAa,uBAAb,cAA0C,MAAM;CAC/C;CAEA,YAAY,UAAgC,SAAiB;EAC5D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;A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IACA,MAAM,WAAW,MAAM,iBAAiB,QAAQ;KAAE;KAAU;KAAU;IAAO,CAAC;IAC9E,IAAI,aAAa,MAAM,MAAM,MAAM,QAAQ;GAC5C,SAAS,cAAc;IACtB,MAAM,MACL,aACC,MACA,QACA,kBACA,wBAAwB,QAAQ,aAAa,UAAU,OAAO,YAAY,CAC3E,CACD;GACD;EACD,CAAC;CACF;CACA,MAAM;CACN,QAAQ,QAAQ,oBAAoB,SAAS,OAAO;CACpD,MAAM,OAAO,MAAM;CACnB,OAAO;AACR"}
1
+ {"version":3,"file":"server-DGKFX_3-.mjs","names":["dnsLookup","request","httpsRequest"],"sources":["../src/mcp/webhook.ts","../src/mcp/events.ts","../src/mcp/listen-source.ts","../src/mcp/server.ts"],"sourcesContent":["import { createHmac } from \"node:crypto\";\nimport { lookup as dnsLookup } from \"node:dns/promises\";\nimport { request as httpsRequest } from \"node:https\";\nimport { isIP } from \"node:net\";\n\n/**\n * Webhook delivery for the MCP Events extension.\n *\n * Deliveries follow the Standard Webhooks profile described by\n * https://github.com/modelcontextprotocol/experimental-ext-triggers-events and\n * are hardened against SSRF: the hostname is resolved and validated on every\n * attempt, the connection is pinned to the validated address, and redirects\n * are never followed.\n */\n\nexport const WEBHOOK_SECRET_PREFIX = \"whsec_\";\nexport const MAX_WEBHOOK_BODY_BYTES = 256 * 1024;\n\nconst MAX_RESPONSE_BYTES = 64 * 1024;\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nexport type WebhookErrorCategory =\n\t| \"connection_refused\"\n\t| \"timeout\"\n\t| \"tls_error\"\n\t| \"http_4xx\"\n\t| \"http_5xx\"\n\t| \"challenge_failed\";\n\nexport class WebhookDeliveryError extends Error {\n\treadonly category: WebhookErrorCategory;\n\n\tconstructor(category: WebhookErrorCategory, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WebhookDeliveryError\";\n\t\tthis.category = category;\n\t}\n}\n\nexport interface WebhookRequest {\n\turl: string;\n\theaders: Record<string, string>;\n\tbody: string;\n\ttimeoutMs?: number;\n}\n\nexport interface WebhookResponse {\n\tstatus: number;\n\t/** Response body, truncated to 64 KiB. */\n\tbody: string;\n}\n\nexport interface WebhookTransport {\n\tpost(request: WebhookRequest): Promise<WebhookResponse>;\n}\n\nexport interface ResolvedAddress {\n\taddress: string;\n\tfamily: number;\n}\n\n/** Returns a human-readable problem when `value` is not a Standard Webhooks secret. */\nexport function webhookSecretProblem(value: unknown): string | null {\n\tif (typeof value !== \"string\") return \"delivery.secret must be a string\";\n\tif (!value.startsWith(WEBHOOK_SECRET_PREFIX)) {\n\t\treturn `delivery.secret must start with ${WEBHOOK_SECRET_PREFIX}`;\n\t}\n\tconst encoded = value.slice(WEBHOOK_SECRET_PREFIX.length);\n\tif (!/^[A-Za-z0-9+/]+={0,2}$/.test(encoded)) {\n\t\treturn \"delivery.secret must be base64 after the whsec_ prefix\";\n\t}\n\tconst bytes = Buffer.from(encoded, \"base64\");\n\tif (bytes.length < 24 || bytes.length > 64) {\n\t\treturn \"delivery.secret must decode to 24-64 bytes\";\n\t}\n\treturn null;\n}\n\nexport function decodeWebhookSecret(secret: string): Buffer {\n\tconst encoded = secret.startsWith(WEBHOOK_SECRET_PREFIX)\n\t\t? secret.slice(WEBHOOK_SECRET_PREFIX.length)\n\t\t: secret;\n\treturn Buffer.from(encoded, \"base64\");\n}\n\n/**\n * Standard Webhooks signature: `v1,<base64 HMAC-SHA256(secret, id.timestamp.body)>`.\n * The body must be the exact bytes sent on the wire.\n */\nexport function signWebhook(\n\tsecret: string,\n\twebhookId: string,\n\ttimestampSeconds: number,\n\tbody: string,\n): string {\n\tconst digest = createHmac(\"sha256\", decodeWebhookSecret(secret))\n\t\t.update(`${webhookId}.${timestampSeconds}.${body}`, \"utf8\")\n\t\t.digest(\"base64\");\n\treturn `v1,${digest}`;\n}\n\n/** Space-delimited multi-signature header, used for secret rotation. */\nexport function webhookSignatureHeader(\n\tsecrets: readonly string[],\n\twebhookId: string,\n\ttimestampSeconds: number,\n\tbody: string,\n): string {\n\treturn secrets\n\t\t.filter((secret): secret is string => typeof secret === \"string\" && secret.length > 0)\n\t\t.map((secret) => signWebhook(secret, webhookId, timestampSeconds, body))\n\t\t.join(\" \");\n}\n\nexport function webhookErrorCategory(status: number): WebhookErrorCategory {\n\treturn status >= 500 ? \"http_5xx\" : \"http_4xx\";\n}\n\n/** Parse and enforce the `https` requirement for callback URLs. */\nexport function parseCallbackUrl(value: unknown): URL {\n\tif (typeof value !== \"string\" || !value.trim()) {\n\t\tthrow new Error(\"delivery.url must be a non-empty string\");\n\t}\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(value);\n\t} catch {\n\t\tthrow new Error(\"delivery.url must be an absolute URL\");\n\t}\n\tif (url.protocol !== \"https:\") throw new Error(\"delivery.url must use https\");\n\tif (!url.hostname) throw new Error(\"delivery.url must include a hostname\");\n\tif (url.username || url.password) throw new Error(\"delivery.url must not embed credentials\");\n\tif (url.hash) throw new Error(\"delivery.url must not include a fragment\");\n\treturn url;\n}\n\nconst V4_BLOCKLIST: ReadonlyArray<readonly [string, number]> = [\n\t[\"0.0.0.0\", 8],\n\t[\"10.0.0.0\", 8],\n\t[\"100.64.0.0\", 10],\n\t[\"127.0.0.0\", 8],\n\t[\"169.254.0.0\", 16],\n\t[\"172.16.0.0\", 12],\n\t[\"192.0.0.0\", 24],\n\t[\"192.0.2.0\", 24],\n\t[\"192.88.99.0\", 24],\n\t[\"192.168.0.0\", 16],\n\t[\"198.18.0.0\", 15],\n\t[\"198.51.100.0\", 24],\n\t[\"203.0.113.0\", 24],\n\t[\"224.0.0.0\", 4],\n\t[\"240.0.0.0\", 4],\n];\n\nfunction ipv4ToInt(address: string): number {\n\treturn address\n\t\t.split(\".\")\n\t\t.reduce((total, part) => ((total << 8) | (Number(part) & 0xff)) >>> 0, 0);\n}\n\nfunction inV4Range(value: number, base: string, prefix: number): boolean {\n\tconst mask = prefix === 0 ? 0 : (0xffffffff << (32 - prefix)) >>> 0;\n\treturn (value & mask) >>> 0 === (ipv4ToInt(base) & mask) >>> 0;\n}\n\nfunction isPublicV4(address: string): boolean {\n\tconst value = ipv4ToInt(address);\n\treturn !V4_BLOCKLIST.some(([base, prefix]) => inV4Range(value, base, prefix));\n}\n\nfunction isPublicV6(address: string): boolean {\n\tconst normalized =\n\t\taddress\n\t\t\t.toLowerCase()\n\t\t\t.replace(/^\\[|\\]$/g, \"\")\n\t\t\t.split(\"%\")[0] ?? \"\";\n\tif (normalized === \"::\" || normalized === \"::1\") return false;\n\tconst mapped = /^::ffff:(\\d+\\.\\d+\\.\\d+\\.\\d+)$/.exec(normalized);\n\tif (mapped?.[1]) return isPublicV4(mapped[1]);\n\tconst first = normalized.split(\":\")[0] ?? \"\";\n\tif (!first) return false;\n\tconst prefix = Number.parseInt(first.padEnd(4, \"0\"), 16);\n\tif (Number.isNaN(prefix)) return false;\n\t// fc00::/7 (unique local), fe80::/10 (link local), ff00::/8 (multicast),\n\t// 2001:db8::/32 (documentation), 100::/64 (discard-only).\n\tif ((prefix & 0xfe00) === 0xfc00) return false;\n\tif ((prefix & 0xffc0) === 0xfe80) return false;\n\tif ((prefix & 0xff00) === 0xff00) return false;\n\tif (normalized.startsWith(\"2001:db8:\")) return false;\n\tif (normalized === \"100::\" || normalized.startsWith(\"100::\")) return false;\n\treturn true;\n}\n\n/** True when the address is globally routable per the IANA special-purpose registries. */\nexport function isPublicAddress(address: string): boolean {\n\tconst family = isIP(address);\n\tif (family === 4) return isPublicV4(address);\n\tif (family === 6) return isPublicV6(address);\n\treturn false;\n}\n\nexport interface WebhookTransportOptions {\n\t/** Resolve a hostname to candidate addresses. Defaults to dns.lookup({ all: true }). */\n\tresolve?(hostname: string): Promise<ResolvedAddress[]>;\n\ttimeoutMs?: number;\n}\n\n/**\n * Deliveries resolve the callback host on every attempt and connect to the\n * validated address while keeping the original hostname for TLS verification.\n */\nexport function createWebhookTransport(options: WebhookTransportOptions = {}): WebhookTransport {\n\tconst resolve =\n\t\toptions.resolve ?? (async (hostname: string) => dnsLookup(hostname, { all: true }));\n\tconst timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\n\treturn {\n\t\tasync post(request: WebhookRequest): Promise<WebhookResponse> {\n\t\t\tconst url = new URL(request.url);\n\t\t\tconst hostname = url.hostname.replace(/^\\[|\\]$/g, \"\");\n\n\t\t\tlet addresses: ResolvedAddress[];\n\t\t\ttry {\n\t\t\t\taddresses = await resolve(hostname);\n\t\t\t} catch {\n\t\t\t\tthrow new WebhookDeliveryError(\"connection_refused\", `could not resolve ${hostname}`);\n\t\t\t}\n\t\t\tif (!addresses.length) {\n\t\t\t\tthrow new WebhookDeliveryError(\"connection_refused\", `${hostname} did not resolve`);\n\t\t\t}\n\t\t\t// Reject the whole callback when any candidate is non-public: the\n\t\t\t// address actually used must not be attacker-selected at connect time.\n\t\t\tif (addresses.some((entry) => !isPublicAddress(entry.address))) {\n\t\t\t\tthrow new WebhookDeliveryError(\n\t\t\t\t\t\"connection_refused\",\n\t\t\t\t\t`${hostname} resolves to a non-public address`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst target = addresses[0]!;\n\t\t\tconst body = request.body;\n\n\t\t\treturn await new Promise<WebhookResponse>((resolveRequest, rejectRequest) => {\n\t\t\t\tconst headers: Record<string, string> = {\n\t\t\t\t\t...request.headers,\n\t\t\t\t\thost: url.host,\n\t\t\t\t\t\"content-length\": String(Buffer.byteLength(body, \"utf8\")),\n\t\t\t\t};\n\t\t\t\tconst signal = AbortSignal.timeout(request.timeoutMs ?? timeoutMs);\n\t\t\t\tconst call = httpsRequest(\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\thost: hostname,\n\t\t\t\t\t\tport: url.port ? Number(url.port) : 443,\n\t\t\t\t\t\tpath: `${url.pathname}${url.search}`,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\t// SNI and certificate identity checks keep using the hostname\n\t\t\t\t\t\t// while the TCP connection goes to the validated address.\n\t\t\t\t\t\t...(isIP(hostname) ? {} : { servername: hostname }),\n\t\t\t\t\t\tlookup: (_host, lookupOptions, callback) => {\n\t\t\t\t\t\t\tif (lookupOptions?.all) {\n\t\t\t\t\t\t\t\tcallback(null, [{ address: target.address, family: target.family }]);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcallback(null, target.address, target.family);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t},\n\t\t\t\t\t(response) => {\n\t\t\t\t\t\tconst chunks: Buffer[] = [];\n\t\t\t\t\t\tlet size = 0;\n\t\t\t\t\t\tresponse.on(\"data\", (chunk: Buffer) => {\n\t\t\t\t\t\t\tif (size >= MAX_RESPONSE_BYTES) return;\n\t\t\t\t\t\t\tconst slice = chunk.subarray(0, MAX_RESPONSE_BYTES - size);\n\t\t\t\t\t\t\tchunks.push(slice);\n\t\t\t\t\t\t\tsize += slice.length;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.on(\"end\", () => {\n\t\t\t\t\t\t\tresolveRequest({\n\t\t\t\t\t\t\t\tstatus: response.statusCode ?? 0,\n\t\t\t\t\t\t\t\tbody: Buffer.concat(chunks).toString(\"utf8\"),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.on(\"error\", rejectRequest);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tcall.on(\"error\", rejectRequest);\n\t\t\t\tcall.end(body);\n\t\t\t}).catch((error: unknown) => {\n\t\t\t\tthrow toWebhookDeliveryError(error);\n\t\t\t});\n\t\t},\n\t};\n}\n\nconst TLS_ERROR_CODES = [\n\t\"ERR_TLS_CERT_ALTNAME_INVALID\",\n\t\"DEPTH_ZERO_SELF_SIGNED_CERT\",\n\t\"SELF_SIGNED_CERT_IN_CHAIN\",\n\t\"UNABLE_TO_VERIFY_LEAF_SIGNATURE\",\n\t\"UNABLE_TO_GET_ISSUER_CERT_LOCALLY\",\n\t\"CERT_HAS_EXPIRED\",\n\t\"ERR_SSL_WRONG_VERSION_NUMBER\",\n\t\"ERR_SSL_PACKET_LENGTH_MISMATCH\",\n\t\"EPROTO\",\n];\n\nfunction toWebhookDeliveryError(error: unknown): WebhookDeliveryError {\n\tif (error instanceof WebhookDeliveryError) return error;\n\tif (error instanceof Error) {\n\t\tconst code = (error as NodeJS.ErrnoException).code ?? \"\";\n\t\tif (error.name === \"AbortError\" || code === \"ETIMEDOUT\" || code === \"UND_ERR_CONNECT_TIMEOUT\") {\n\t\t\treturn new WebhookDeliveryError(\"timeout\", \"callback endpoint timed out\");\n\t\t}\n\t\tif (\n\t\t\tTLS_ERROR_CODES.includes(code) ||\n\t\t\tcode.startsWith(\"ERR_TLS\") ||\n\t\t\tcode.startsWith(\"ERR_SSL\")\n\t\t) {\n\t\t\treturn new WebhookDeliveryError(\"tls_error\", \"callback endpoint failed TLS verification\");\n\t\t}\n\t\tif (code === \"ECONNREFUSED\" || code === \"ENOTFOUND\" || code === \"EHOSTUNREACH\") {\n\t\t\treturn new WebhookDeliveryError(\n\t\t\t\t\"connection_refused\",\n\t\t\t\t\"callback endpoint refused the connection\",\n\t\t\t);\n\t\t}\n\t\treturn new WebhookDeliveryError(\"connection_refused\", error.message);\n\t}\n\treturn new WebhookDeliveryError(\"connection_refused\", String(error));\n}\n","import { createHash, randomBytes, timingSafeEqual } from \"node:crypto\";\nimport { VERSION } from \"../version.ts\";\nimport {\n\tMAX_WEBHOOK_BODY_BYTES,\n\tWebhookDeliveryError,\n\ttype WebhookTransport,\n\tcreateWebhookTransport,\n\tisPublicAddress,\n\tparseCallbackUrl,\n\twebhookErrorCategory,\n\twebhookSecretProblem,\n\twebhookSignatureHeader,\n} from \"./webhook.ts\";\n\n/**\n * MCP Events (webhook delivery), following the draft extension in\n * https://github.com/modelcontextprotocol/experimental-ext-triggers-events and\n * the subset ChatGPT implements (events/list, events/subscribe,\n * events/unsubscribe, signed webhook deliveries, callback verification).\n */\n\nexport const EVENT_ERROR_NOT_FOUND = -32023;\nexport const EVENT_ERROR_FORBIDDEN = -32024;\nexport const EVENT_ERROR_RESOURCE_EXHAUSTED = -32025;\nexport const EVENT_ERROR_UNSUPPORTED = -32026;\nexport const EVENT_ERROR_CALLBACK = -32027;\nexport const EVENT_ERROR_INVALID_PARAMS = -32602;\n\nexport class EventRpcError extends Error {\n\treadonly code: number;\n\treadonly data?: Record<string, unknown>;\n\n\tconstructor(code: number, message: string, data?: Record<string, unknown>) {\n\t\tsuper(message);\n\t\tthis.name = \"EventRpcError\";\n\t\tthis.code = code;\n\t\tthis.data = data;\n\t}\n}\n\nexport interface McpEventDefinition {\n\tname: string;\n\tdescription: string;\n\t/** Delivery modes this server offers for the event. */\n\tdelivery: readonly string[];\n\tinputSchema: Record<string, unknown>;\n\tpayloadSchema: Record<string, unknown>;\n}\n\ninterface SchemaProperty {\n\ttype?: string;\n\tenum?: readonly unknown[];\n}\n\nconst FILTER_PROPERTIES: Record<\n\tstring,\n\tSchemaProperty & { description: string; default?: unknown }\n> = {\n\tchatId: {\n\t\ttype: \"string\",\n\t\tdescription:\n\t\t\t'Only deliver messages from chats whose id matches this glob pattern (e.g. \"c0123456789abcdef\"). Omit to match every chat.',\n\t},\n\tfrom: {\n\t\ttype: \"string\",\n\t\tdescription:\n\t\t\t\"Only deliver messages whose sender mid matches this glob pattern. Omit to match every sender.\",\n\t},\n\tincludeText: {\n\t\ttype: \"boolean\",\n\t\tdefault: true,\n\t\tdescription:\n\t\t\t\"Include a truncated text preview in the payload. Disable to keep user-authored text out of webhook infrastructure.\",\n\t},\n};\n\nfunction inputSchema(): Record<string, unknown> {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: FILTER_PROPERTIES,\n\t\tadditionalProperties: false,\n\t};\n}\n\nfunction payloadSchema(timestampKey: \"receivedAt\" | \"updatedAt\"): Record<string, unknown> {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: {\n\t\t\tmessageId: { type: \"string\", description: \"Stable LINE message id, usable for dedup.\" },\n\t\t\tchatId: { type: \"string\", description: \"Chat (or OpenChat room) the message belongs to.\" },\n\t\t\tfrom: { type: \"string\", description: \"Sender mid.\" },\n\t\t\tcontentType: { type: \"string\", description: \"LINE content type, e.g. TEXT or IMAGE.\" },\n\t\t\ttext: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Truncated text preview. Omitted when includeText is false or the message has no text.\",\n\t\t\t},\n\t\t\t[timestampKey]: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tformat: \"date-time\",\n\t\t\t\tdescription: \"When the message was sent (ISO 8601).\",\n\t\t\t},\n\t\t},\n\t\trequired: [\"messageId\", \"chatId\", \"from\", \"contentType\", timestampKey],\n\t\tadditionalProperties: false,\n\t};\n}\n\nexport const EVENT_DEFINITIONS: readonly McpEventDefinition[] = [\n\t{\n\t\tname: \"line.message.received\",\n\t\tdescription:\n\t\t\t\"Fires when the connected LINE account receives a new talk message in a one-to-one or group chat.\",\n\t\tdelivery: [\"webhook\"],\n\t\tinputSchema: inputSchema(),\n\t\tpayloadSchema: payloadSchema(\"receivedAt\"),\n\t},\n\t{\n\t\tname: \"line.message.edited\",\n\t\tdescription: \"Fires when a talk message the account can see is edited.\",\n\t\tdelivery: [\"webhook\"],\n\t\tinputSchema: inputSchema(),\n\t\tpayloadSchema: payloadSchema(\"updatedAt\"),\n\t},\n\t{\n\t\tname: \"line.openchat.message.received\",\n\t\tdescription: \"Fires when a message arrives in an OpenChat (square) room.\",\n\t\tdelivery: [\"webhook\"],\n\t\tinputSchema: inputSchema(),\n\t\tpayloadSchema: payloadSchema(\"receivedAt\"),\n\t},\n];\n\nexport type McpEventSourceKind = \"talk\" | \"square\";\n\n/** A single occurrence produced by an event source before per-subscription filtering. */\nexport interface McpEventRecord {\n\tname: string;\n\t/** ISO 8601 timestamp of the occurrence. */\n\toccurredAt: string;\n\tdata: Record<string, unknown>;\n}\n\nexport interface McpEventSource {\n\t/** Resolve once the upstream listener is connected, reject when it cannot start. */\n\tstart(onEvent: (record: McpEventRecord) => void): Promise<void>;\n\tstop(): Promise<void>;\n}\n\nexport type McpEventSourceFactory = (kind: McpEventSourceKind) => McpEventSource;\n\nexport interface McpEventLimits {\n\tmaxSubscriptions: number;\n\tmaxQueue: number;\n\tmaxAttempts: number;\n\tretryBaseMs: number;\n\tretryMaxDelayMs: number;\n\tsuspendAfterFailures: number;\n\tdefaultTtlMs: number;\n\tminTtlMs: number;\n\tmaxTtlMs: number;\n\tverificationTtlMs: number;\n}\n\n/** Longest text preview kept in an event payload. */\nexport const PREVIEW_TEXT_LIMIT = 400;\n\n/** Collapse whitespace and truncate user-authored text for payload minimality. */\nexport function previewText(value: unknown): string | undefined {\n\tif (typeof value !== \"string\" || !value) return undefined;\n\tconst flat = value.replace(/\\s+/g, \" \").trim();\n\tif (!flat) return undefined;\n\treturn flat.length > PREVIEW_TEXT_LIMIT ? `${flat.slice(0, PREVIEW_TEXT_LIMIT)}…` : flat;\n}\n\nconst DEFAULT_LIMITS: McpEventLimits = {\n\tmaxSubscriptions: 20,\n\tmaxQueue: 50,\n\tmaxAttempts: 4,\n\tretryBaseMs: 1_000,\n\tretryMaxDelayMs: 15_000,\n\tsuspendAfterFailures: 5,\n\tdefaultTtlMs: 15 * 60_000,\n\tminTtlMs: 60_000,\n\tmaxTtlMs: 60 * 60_000,\n\tverificationTtlMs: 30 * 60_000,\n};\n\nexport interface McpEventHubOptions {\n\t/** Canonical identity of the caller; the stdio transport uses the local LINE profile. */\n\tprincipal: string;\n\tdefinitions?: readonly McpEventDefinition[];\n\ttransport?: WebhookTransport;\n\t/** Factory used to lazily start the LINE listener for a delivery kind. */\n\tsourceFactory?: McpEventSourceFactory;\n\tnow?: () => number;\n\tdelay?: (ms: number) => Promise<void>;\n\tlog?: (message: string) => void;\n\tlimits?: Partial<McpEventLimits>;\n\t/** Sweep expired subscriptions on an interval. Defaults to true. */\n\tautoSweep?: boolean;\n}\n\nexport interface EventSubscribeResult {\n\tid: string;\n\trefreshBefore: string | null;\n\tcursor: null;\n\ttruncated: boolean;\n\tdeliveryStatus?: Record<string, unknown>;\n}\n\ninterface DeliveryJob {\n\toccurrence: McpEventOccurrence;\n\tbody: string;\n}\n\ninterface McpEventOccurrence {\n\teventId: string;\n\tname: string;\n\ttimestamp: string;\n\tdata: Record<string, unknown>;\n\tcursor: null;\n}\n\ninterface Subscription {\n\tid: string;\n\tprincipal: string;\n\tname: string;\n\targuments: Record<string, unknown>;\n\turl: string;\n\tsecret: string;\n\tpreviousSecret?: string;\n\tpreviousSecretUntil?: number;\n\texpiresAt: number;\n\tactive: boolean;\n\tlastDeliveryAt?: string;\n\tlastError?: string;\n\tfailedSince?: string;\n\tconsecutiveFailures: number;\n\tqueue: DeliveryJob[];\n\tdraining: boolean;\n\tremoved: boolean;\n}\n\nfunction canonicalize(value: unknown): string {\n\tif (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n\tif (Array.isArray(value)) return `[${value.map(canonicalize).join(\",\")}]`;\n\tconst entries = Object.entries(value as Record<string, unknown>)\n\t\t.filter(([, entry]) => entry !== undefined)\n\t\t.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n\treturn `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonicalize(entry)}`).join(\",\")}}`;\n}\n\n/** Canonical JSON with sorted keys, so equivalent arguments share one subscription. */\nexport function canonicalJson(value: unknown): string {\n\treturn canonicalize(value ?? {});\n}\n\nfunction globToRegExp(pattern: string): RegExp {\n\tlet source = \"\";\n\tfor (const character of pattern) {\n\t\tif (character === \"*\") source += \".*\";\n\t\telse if (character === \"?\") source += \".\";\n\t\telse source += character.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\t}\n\treturn new RegExp(`^${source}$`, \"u\");\n}\n\nfunction matchesFilters(filters: Record<string, unknown>, data: Record<string, unknown>): boolean {\n\tconst chatId = typeof filters.chatId === \"string\" ? filters.chatId : undefined;\n\tif (chatId && !globToRegExp(chatId).test(String(data.chatId ?? \"\"))) return false;\n\tconst from = typeof filters.from === \"string\" ? filters.from : undefined;\n\tif (from && !globToRegExp(from).test(String(data.from ?? \"\"))) return false;\n\treturn true;\n}\n\nfunction validateArguments(\n\tdefinition: McpEventDefinition,\n\tvalue: unknown,\n): Record<string, unknown> {\n\tif (value === undefined || value === null) return {};\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.arguments must be an object\");\n\t}\n\tconst properties = (definition.inputSchema.properties ?? {}) as Record<string, SchemaProperty>;\n\tconst entries = value as Record<string, unknown>;\n\tfor (const key of Object.keys(entries)) {\n\t\tif (!(key in properties)) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t`Unknown argument for ${definition.name}: ${key}`,\n\t\t\t\t{ argument: key },\n\t\t\t);\n\t\t}\n\t}\n\tfor (const [key, schema] of Object.entries(properties)) {\n\t\tconst entry = entries[key];\n\t\tif (entry === undefined) continue;\n\t\tconst invalid = () => {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t`Argument ${key} must be ${schema.type}`,\n\t\t\t\t{ argument: key },\n\t\t\t);\n\t\t};\n\t\tif (schema.type === \"string\") {\n\t\t\tif (typeof entry !== \"string\" || entry.length > 512) invalid();\n\t\t} else if (schema.type === \"boolean\") {\n\t\t\tif (typeof entry !== \"boolean\") invalid();\n\t\t} else if (schema.type === \"integer\") {\n\t\t\tif (!Number.isInteger(entry)) invalid();\n\t\t} else if (schema.type === \"number\") {\n\t\t\tif (typeof entry !== \"number\" || !Number.isFinite(entry)) invalid();\n\t\t}\n\t\tif (schema.enum && !schema.enum.includes(entry)) invalid();\n\t}\n\treturn entries;\n}\n\nfunction constantTimeEqual(left: string, right: string): boolean {\n\tconst a = Buffer.from(left, \"utf8\");\n\tconst b = Buffer.from(right, \"utf8\");\n\tif (a.length !== b.length) return false;\n\treturn timingSafeEqual(a, b);\n}\n\nexport class McpEventHub {\n\treadonly principal: string;\n\treadonly definitions: readonly McpEventDefinition[];\n\treadonly limits: McpEventLimits;\n\n\tprivate readonly transport: WebhookTransport;\n\tprivate readonly sourceFactory: McpEventSourceFactory | undefined;\n\tprivate readonly clock: () => number;\n\tprivate readonly delay: (ms: number) => Promise<void>;\n\tprivate readonly log: (message: string) => void;\n\tprivate readonly subscriptions = new Map<string, Subscription>();\n\tprivate readonly sources = new Map<McpEventSourceKind, McpEventSource>();\n\tprivate readonly verified = new Map<string, number>();\n\tprivate readonly workers = new Set<Promise<void>>();\n\tprivate timer: NodeJS.Timeout | undefined;\n\tprivate closed = false;\n\n\tconstructor(options: McpEventHubOptions) {\n\t\tthis.principal = options.principal;\n\t\tthis.definitions = options.definitions ?? EVENT_DEFINITIONS;\n\t\tthis.limits = { ...DEFAULT_LIMITS, ...options.limits };\n\t\tthis.transport = options.transport ?? createWebhookTransport();\n\t\tthis.sourceFactory = options.sourceFactory;\n\t\tthis.clock = options.now ?? Date.now;\n\t\tthis.delay =\n\t\t\toptions.delay ??\n\t\t\t((ms) =>\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\tconst timer = setTimeout(resolve, ms);\n\t\t\t\t\ttimer.unref?.();\n\t\t\t\t}));\n\t\tthis.log = options.log ?? (() => {});\n\t\tif (options.autoSweep !== false) {\n\t\t\tthis.timer = setInterval(() => this.sweep(), 30_000);\n\t\t\tthis.timer.unref?.();\n\t\t}\n\t}\n\n\tget activeSubscriptionCount(): number {\n\t\treturn this.subscriptions.size;\n\t}\n\n\tlist(params: Record<string, unknown> = {}): Record<string, unknown> {\n\t\tconst cursor = params.cursor;\n\t\tif (cursor !== undefined && cursor !== null && typeof cursor !== \"string\") {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.cursor must be a string\");\n\t\t}\n\t\t// The catalogue is small enough to return in a single page.\n\t\treturn {\n\t\t\tevents: this.definitions.map((definition) => ({\n\t\t\t\tname: definition.name,\n\t\t\t\tdescription: definition.description,\n\t\t\t\tdelivery: [...definition.delivery],\n\t\t\t\tinputSchema: definition.inputSchema,\n\t\t\t\tpayloadSchema: definition.payloadSchema,\n\t\t\t})),\n\t\t};\n\t}\n\n\tasync subscribe(params: Record<string, unknown>): Promise<EventSubscribeResult> {\n\t\tconst definition = this.definitionFor(params.name);\n\t\tconst filters = validateArguments(definition, params.arguments);\n\t\tconst delivery = this.validateDelivery(params.delivery);\n\t\tconst ttlMs = this.grantTtl(params.ttlMs);\n\t\tconst id = this.subscriptionId(delivery.url, definition.name, filters);\n\t\tconst existing = this.subscriptions.get(id);\n\t\tif (!existing && this.subscriptions.size >= this.limits.maxSubscriptions) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_RESOURCE_EXHAUSTED,\n\t\t\t\t`At most ${this.limits.maxSubscriptions} webhook subscriptions are supported`,\n\t\t\t\t{ limit: \"subscriptions\", max: this.limits.maxSubscriptions },\n\t\t\t);\n\t\t}\n\n\t\tawait this.verifyEndpoint(delivery.url, delivery.secret, id);\n\n\t\tconst now = this.clock();\n\t\t// Report the state the refresh replaces: `active: false` tells the client\n\t\t// deliveries had been suspended and that this refresh reactivates them.\n\t\tconst previousStatus = existing\n\t\t\t? {\n\t\t\t\t\tactive: existing.active,\n\t\t\t\t\tlastDeliveryAt: existing.lastDeliveryAt ?? null,\n\t\t\t\t\tlastError: existing.lastError ?? null,\n\t\t\t\t\t...(existing.failedSince ? { failedSince: existing.failedSince } : {}),\n\t\t\t\t}\n\t\t\t: undefined;\n\t\tconst subscription: Subscription = existing ?? {\n\t\t\tid,\n\t\t\tprincipal: this.principal,\n\t\t\tname: definition.name,\n\t\t\targuments: filters,\n\t\t\turl: delivery.url,\n\t\t\tsecret: delivery.secret,\n\t\t\texpiresAt: now + ttlMs,\n\t\t\tactive: true,\n\t\t\tconsecutiveFailures: 0,\n\t\t\tqueue: [],\n\t\t\tdraining: false,\n\t\t\tremoved: false,\n\t\t};\n\t\tsubscription.secret = delivery.secret;\n\t\tif (existing?.secret && existing.secret !== delivery.secret) {\n\t\t\t// Standard Webhooks multi-signature grace window for secret rotation.\n\t\t\tsubscription.previousSecret = existing.secret;\n\t\t\tsubscription.previousSecretUntil = now + 5 * 60_000;\n\t\t}\n\t\tsubscription.expiresAt = now + ttlMs;\n\t\tsubscription.active = true;\n\t\tsubscription.consecutiveFailures = 0;\n\t\tsubscription.removed = false;\n\t\tthis.subscriptions.set(id, subscription);\n\n\t\ttry {\n\t\t\tawait this.ensureSources();\n\t\t} catch (error) {\n\t\t\t// A refresh keeps the existing subscription; only a brand-new one is rolled back.\n\t\t\tif (!existing) this.dropSubscription(subscription);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (existing) this.scheduleDrain(subscription);\n\t\treturn {\n\t\t\tid,\n\t\t\trefreshBefore: new Date(subscription.expiresAt).toISOString(),\n\t\t\tcursor: null,\n\t\t\ttruncated: false,\n\t\t\t...(previousStatus ? { deliveryStatus: previousStatus } : {}),\n\t\t};\n\t}\n\n\tunsubscribe(params: Record<string, unknown>): Record<string, never> {\n\t\tconst definition = this.definitionFor(params.name);\n\t\tconst filters = validateArguments(definition, params.arguments);\n\t\tconst delivery = this.validateDelivery(params.delivery, { requireSecret: false });\n\t\tconst id = this.subscriptionId(delivery.url, definition.name, filters);\n\t\tconst subscription = this.subscriptions.get(id);\n\t\t// Idempotent: an unknown key is not an error.\n\t\tif (subscription) this.dropSubscription(subscription);\n\t\tvoid this.stopUnusedSources();\n\t\treturn {};\n\t}\n\n\t/** Deliver one occurrence to every active, matching subscription. */\n\temit(record: McpEventRecord): void {\n\t\tif (this.closed) return;\n\t\tconst timestamp = record.occurredAt || new Date(this.clock()).toISOString();\n\t\tfor (const subscription of this.subscriptions.values()) {\n\t\t\tif (subscription.removed || !subscription.active) continue;\n\t\t\tif (subscription.name !== record.name) continue;\n\t\t\tif (!matchesFilters(subscription.arguments, record.data)) continue;\n\t\t\tconst stampKey = subscription.name === \"line.message.edited\" ? \"updatedAt\" : \"receivedAt\";\n\t\t\tconst data = this.projectPayload(subscription.name, record.data, stampKey, timestamp);\n\t\t\tif (subscription.arguments.includeText === false) delete data.text;\n\t\t\tthis.enqueue(subscription, {\n\t\t\t\teventId: this.eventIdFor(subscription.name, data, timestamp),\n\t\t\t\tname: subscription.name,\n\t\t\t\ttimestamp,\n\t\t\t\tdata,\n\t\t\t\tcursor: null,\n\t\t\t});\n\t\t}\n\t}\n\n\t/** Keep only the fields advertised by the event's payloadSchema. */\n\tprivate projectPayload(\n\t\tname: string,\n\t\tsource: Record<string, unknown>,\n\t\tstampKey: \"receivedAt\" | \"updatedAt\",\n\t\ttimestamp: string,\n\t): Record<string, unknown> {\n\t\tconst definition = this.definitions.find((entry) => entry.name === name);\n\t\tconst properties = (definition?.payloadSchema.properties ?? {}) as Record<string, unknown>;\n\t\tconst data: Record<string, unknown> = {};\n\t\tfor (const key of Object.keys(properties)) {\n\t\t\tconst value = key === stampKey ? timestamp : source[key];\n\t\t\tif (value !== undefined && value !== null) data[key] = value;\n\t\t}\n\t\treturn data;\n\t}\n\n\t/** Wait for queued deliveries to finish (used by tests and graceful shutdown). */\n\tasync flushDeliveries(): Promise<void> {\n\t\twhile (this.workers.size) {\n\t\t\tawait Promise.allSettled(this.workers);\n\t\t}\n\t}\n\n\t/** Drop expired subscriptions. Returns the ids that were removed. */\n\tsweep(): string[] {\n\t\tconst now = this.clock();\n\t\tconst removed: string[] = [];\n\t\tfor (const subscription of this.subscriptions.values()) {\n\t\t\tif (subscription.expiresAt <= now) {\n\t\t\t\tthis.dropSubscription(subscription);\n\t\t\t\tremoved.push(subscription.id);\n\t\t\t}\n\t\t}\n\t\tfor (const [key, expiresAt] of this.verified) {\n\t\t\tif (expiresAt <= now) this.verified.delete(key);\n\t\t}\n\t\tvoid this.stopUnusedSources();\n\t\treturn removed;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tthis.closed = true;\n\t\tif (this.timer) clearInterval(this.timer);\n\t\tthis.timer = undefined;\n\t\tfor (const subscription of this.subscriptions.values()) this.dropSubscription(subscription);\n\t\tconst sources = [...this.sources.values()];\n\t\tthis.sources.clear();\n\t\tawait Promise.all(sources.map(async (source) => await source.stop().catch(() => {})));\n\t}\n\n\tprivate definitionFor(name: unknown): McpEventDefinition {\n\t\tif (typeof name !== \"string\" || !name) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.name must be a string\");\n\t\t}\n\t\tconst definition = this.definitions.find((entry) => entry.name === name);\n\t\tif (!definition) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_NOT_FOUND, `Unknown event: ${name}`, {\n\t\t\t\tkind: \"event\",\n\t\t\t});\n\t\t}\n\t\treturn definition;\n\t}\n\n\tprivate validateDelivery(\n\t\tvalue: unknown,\n\t\toptions: { requireSecret?: boolean } = {},\n\t): { url: string; secret: string } {\n\t\tconst requireSecret = options.requireSecret ?? true;\n\t\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_INVALID_PARAMS, \"params.delivery must be an object\");\n\t\t}\n\t\tconst delivery = value as Record<string, unknown>;\n\t\tif (delivery.mode !== undefined && delivery.mode !== \"webhook\") {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_UNSUPPORTED,\n\t\t\t\t`Unsupported delivery mode: ${String(delivery.mode)}`,\n\t\t\t\t{ feature: \"deliveryMode\", value: delivery.mode ?? null },\n\t\t\t);\n\t\t}\n\t\tlet url: URL;\n\t\ttry {\n\t\t\turl = parseCallbackUrl(delivery.url);\n\t\t} catch (error) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t}\n\t\tconst hostname = url.hostname.replace(/^\\[|\\]$/g, \"\");\n\t\tif (/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(hostname) || hostname.includes(\":\")) {\n\t\t\tif (!isPublicAddress(hostname)) {\n\t\t\t\tthrow new EventRpcError(\n\t\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t\t\"delivery.url must point at a globally routable address\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tlet secret = \"\";\n\t\tif (requireSecret || delivery.secret !== undefined) {\n\t\t\tconst problem = webhookSecretProblem(delivery.secret);\n\t\t\tif (problem) throw new EventRpcError(EVENT_ERROR_INVALID_PARAMS, problem);\n\t\t\tsecret = delivery.secret as string;\n\t\t}\n\t\treturn { url: url.toString(), secret };\n\t}\n\n\tprivate grantTtl(requested: unknown): number {\n\t\tif (requested === null) {\n\t\t\t// No-expiry grants would require durable storage; this server keeps\n\t\t\t// subscriptions in memory and answers a finite grant instead.\n\t\t\treturn this.limits.maxTtlMs;\n\t\t}\n\t\tif (requested === undefined) return this.limits.defaultTtlMs;\n\t\tif (typeof requested !== \"number\" || !Number.isFinite(requested) || requested <= 0) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_INVALID_PARAMS,\n\t\t\t\t\"params.ttlMs must be a positive integer\",\n\t\t\t);\n\t\t}\n\t\tconst floored = Math.max(Math.floor(requested), this.limits.minTtlMs);\n\t\treturn Math.min(floored, this.limits.maxTtlMs);\n\t}\n\n\tprivate subscriptionId(url: string, name: string, filters: Record<string, unknown>): string {\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(canonicalJson({ principal: this.principal, url, name, arguments: filters }))\n\t\t\t.digest(\"hex\");\n\t\treturn `sub_${digest.slice(0, 16)}`;\n\t}\n\n\tprivate async verifyEndpoint(url: string, secret: string, subscriptionId: string): Promise<void> {\n\t\tconst key = `${this.principal}\\u0000${url}`;\n\t\tconst cached = this.verified.get(key);\n\t\tif (cached !== undefined && cached > this.clock()) return;\n\n\t\tconst challenge = randomBytes(24).toString(\"base64url\");\n\t\tconst body = JSON.stringify({ type: \"verification\", challenge });\n\t\tconst webhookId = `msg_verification_${randomBytes(8).toString(\"hex\")}`;\n\t\tconst timestamp = Math.floor(this.clock() / 1000);\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await this.transport.post({\n\t\t\t\turl,\n\t\t\t\tbody,\n\t\t\t\theaders: {\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\t\"webhook-id\": webhookId,\n\t\t\t\t\t\"webhook-timestamp\": String(timestamp),\n\t\t\t\t\t\"webhook-signature\": webhookSignatureHeader([secret], webhookId, timestamp, body),\n\t\t\t\t\t\"x-mcp-subscription-id\": subscriptionId,\n\t\t\t\t\t\"user-agent\": `linejs-cli/${VERSION}`,\n\t\t\t\t},\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconst reason = error instanceof WebhookDeliveryError ? error.category : \"connection_refused\";\n\t\t\tthrow new EventRpcError(EVENT_ERROR_CALLBACK, \"Could not verify the callback endpoint\", {\n\t\t\t\treason,\n\t\t\t});\n\t\t}\n\t\tif (response.status < 200 || response.status >= 300) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_CALLBACK, \"Could not verify the callback endpoint\", {\n\t\t\t\treason: webhookErrorCategory(response.status),\n\t\t\t});\n\t\t}\n\t\tlet echoed: unknown;\n\t\ttry {\n\t\t\techoed = (JSON.parse(response.body) as Record<string, unknown>).challenge;\n\t\t} catch {\n\t\t\techoed = undefined;\n\t\t}\n\t\tif (typeof echoed !== \"string\" || !constantTimeEqual(echoed, challenge)) {\n\t\t\tthrow new EventRpcError(EVENT_ERROR_CALLBACK, \"Could not verify the callback endpoint\", {\n\t\t\t\treason: \"challenge_failed\",\n\t\t\t});\n\t\t}\n\t\tthis.verified.set(key, this.clock() + this.limits.verificationTtlMs);\n\t}\n\n\tprivate eventIdFor(name: string, data: Record<string, unknown>, timestamp: string): string {\n\t\tconst messageId = typeof data.messageId === \"string\" ? data.messageId : undefined;\n\t\tif (!messageId) return `evt_${randomBytes(12).toString(\"hex\")}`;\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(`${name}\\u0000${messageId}\\u0000${timestamp}`)\n\t\t\t.digest(\"hex\");\n\t\treturn `evt_${digest.slice(0, 24)}`;\n\t}\n\n\tprivate enqueue(subscription: Subscription, occurrence: McpEventOccurrence): void {\n\t\tconst body = JSON.stringify(occurrence);\n\t\tif (Buffer.byteLength(body, \"utf8\") > MAX_WEBHOOK_BODY_BYTES) {\n\t\t\tthis.log(`dropped oversized event ${occurrence.eventId} (${occurrence.name})`);\n\t\t\treturn;\n\t\t}\n\t\tif (subscription.queue.length >= this.limits.maxQueue) {\n\t\t\tconst dropped = subscription.queue.shift();\n\t\t\tif (dropped) {\n\t\t\t\tthis.log(\n\t\t\t\t\t`delivery queue full for ${subscription.id}; dropped ${dropped.occurrence.eventId}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tsubscription.queue.push({ occurrence, body });\n\t\tthis.scheduleDrain(subscription);\n\t}\n\n\tprivate scheduleDrain(subscription: Subscription): void {\n\t\tif (subscription.draining) return;\n\t\tconst worker: Promise<void> = this.drain(subscription).finally(() => {\n\t\t\tthis.workers.delete(worker);\n\t\t});\n\t\tthis.workers.add(worker);\n\t}\n\n\tprivate async drain(subscription: Subscription): Promise<void> {\n\t\tif (subscription.draining || this.closed) return;\n\t\tsubscription.draining = true;\n\t\ttry {\n\t\t\twhile (\n\t\t\t\t!this.closed &&\n\t\t\t\t!subscription.removed &&\n\t\t\t\tsubscription.active &&\n\t\t\t\tsubscription.queue.length\n\t\t\t) {\n\t\t\t\tconst job = subscription.queue.shift()!;\n\t\t\t\tawait this.deliver(subscription, job);\n\t\t\t}\n\t\t} finally {\n\t\t\tsubscription.draining = false;\n\t\t}\n\t}\n\n\tprivate async deliver(subscription: Subscription, job: DeliveryJob): Promise<void> {\n\t\tfor (let attempt = 1; attempt <= this.limits.maxAttempts; attempt += 1) {\n\t\t\tif (this.closed || subscription.removed || !subscription.active) return;\n\t\t\tconst timestamp = Math.floor(this.clock() / 1000);\n\t\t\tconst secrets = [subscription.secret];\n\t\t\tif (subscription.previousSecret) secrets.push(subscription.previousSecret);\n\t\t\tlet status = 0;\n\t\t\ttry {\n\t\t\t\tconst response = await this.transport.post({\n\t\t\t\t\turl: subscription.url,\n\t\t\t\t\tbody: job.body,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\t\t\"webhook-id\": job.occurrence.eventId,\n\t\t\t\t\t\t\"webhook-timestamp\": String(timestamp),\n\t\t\t\t\t\t\"webhook-signature\": webhookSignatureHeader(\n\t\t\t\t\t\t\tsecrets,\n\t\t\t\t\t\t\tjob.occurrence.eventId,\n\t\t\t\t\t\t\ttimestamp,\n\t\t\t\t\t\t\tjob.body,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t\"x-mcp-subscription-id\": subscription.id,\n\t\t\t\t\t\t\"user-agent\": `linejs-cli/${VERSION}`,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tstatus = response.status;\n\t\t\t} catch (error) {\n\t\t\t\tconst reason =\n\t\t\t\t\terror instanceof WebhookDeliveryError ? error.category : \"connection_refused\";\n\t\t\t\tthis.recordFailure(subscription, reason);\n\t\t\t\tif (attempt >= this.limits.maxAttempts) return;\n\t\t\t\tawait this.backoff(attempt);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (status >= 200 && status < 300) {\n\t\t\t\tsubscription.lastDeliveryAt = new Date(this.clock()).toISOString();\n\t\t\t\tsubscription.lastError = undefined;\n\t\t\t\tsubscription.failedSince = undefined;\n\t\t\t\tsubscription.consecutiveFailures = 0;\n\t\t\t\tif (\n\t\t\t\t\tsubscription.previousSecretUntil !== undefined &&\n\t\t\t\t\tthis.clock() >= subscription.previousSecretUntil\n\t\t\t\t) {\n\t\t\t\t\tsubscription.previousSecret = undefined;\n\t\t\t\t\tsubscription.previousSecretUntil = undefined;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.recordFailure(subscription, webhookErrorCategory(status));\n\t\t\t// 410 Gone and 413 Payload Too Large are deliberately final.\n\t\t\tif (status === 410 || status === 413) return;\n\t\t\tif (attempt >= this.limits.maxAttempts) return;\n\t\t\tawait this.backoff(attempt);\n\t\t}\n\t}\n\n\tprivate async backoff(attempt: number): Promise<void> {\n\t\tconst delay = Math.min(\n\t\t\tthis.limits.retryBaseMs * 2 ** (attempt - 1),\n\t\t\tthis.limits.retryMaxDelayMs,\n\t\t);\n\t\tawait this.delay(delay);\n\t}\n\n\tprivate recordFailure(subscription: Subscription, reason: string): void {\n\t\tsubscription.consecutiveFailures += 1;\n\t\tsubscription.lastError = reason;\n\t\tsubscription.failedSince ??= new Date(this.clock()).toISOString();\n\t\tif (subscription.consecutiveFailures >= this.limits.suspendAfterFailures) {\n\t\t\tsubscription.active = false;\n\t\t\tthis.log(`suspended webhook delivery for ${subscription.id} after repeated failures`);\n\t\t}\n\t}\n\n\tprivate dropSubscription(subscription: Subscription): void {\n\t\tsubscription.removed = true;\n\t\tsubscription.active = false;\n\t\tsubscription.queue.length = 0;\n\t\tthis.subscriptions.delete(subscription.id);\n\t\tvoid this.stopUnusedSources();\n\t}\n\n\tprivate requiredSourceKinds(): Set<McpEventSourceKind> {\n\t\tconst kinds = new Set<McpEventSourceKind>();\n\t\tfor (const subscription of this.subscriptions.values()) {\n\t\t\tif (subscription.name === \"line.openchat.message.received\") kinds.add(\"square\");\n\t\t\telse kinds.add(\"talk\");\n\t\t}\n\t\treturn kinds;\n\t}\n\n\tprivate async ensureSources(): Promise<void> {\n\t\tconst required = this.requiredSourceKinds();\n\t\tfor (const kind of [\"talk\", \"square\"] as const) {\n\t\t\tif (!required.has(kind)) continue;\n\t\t\tconst existing = this.sources.get(kind);\n\t\t\tif (!existing) {\n\t\t\t\tawait this.startSource(kind);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// A refresh also gives a listener that died (network drop, expired\n\t\t\t// session) another chance to reconnect.\n\t\t\tawait existing.start(this.sourceListener).catch((error: unknown) => {\n\t\t\t\tthis.log(\n\t\t\t\t\t`could not restart the ${kind} LINE listener: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\t\tawait this.stopUnusedSources();\n\t}\n\n\tprivate readonly sourceListener = (record: McpEventRecord): void => {\n\t\tthis.emit(record);\n\t};\n\n\tprivate async startSource(kind: McpEventSourceKind): Promise<void> {\n\t\tif (!this.sourceFactory) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_UNSUPPORTED,\n\t\t\t\t\"Webhook delivery is not available: this server has no LINE event source\",\n\t\t\t\t{ feature: \"events\" },\n\t\t\t);\n\t\t}\n\t\tconst source = this.sourceFactory(kind);\n\t\ttry {\n\t\t\tawait source.start(this.sourceListener);\n\t\t} catch (error) {\n\t\t\tthrow new EventRpcError(\n\t\t\t\tEVENT_ERROR_FORBIDDEN,\n\t\t\t\t`The LINE listener could not start: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t{ reason: \"upstream_unavailable\" },\n\t\t\t);\n\t\t}\n\t\tthis.sources.set(kind, source);\n\t}\n\n\tprivate async stopUnusedSources(): Promise<void> {\n\t\tconst required = this.requiredSourceKinds();\n\t\tfor (const [kind, source] of this.sources) {\n\t\t\tif (required.has(kind)) continue;\n\t\t\tthis.sources.delete(kind);\n\t\t\tawait source.stop().catch(() => {});\n\t\t}\n\t}\n}\n","import { runCli } from \"../cli.ts\";\nimport {\n\ttype McpEventRecord,\n\ttype McpEventSource,\n\ttype McpEventSourceKind,\n\tpreviewText,\n} from \"./events.ts\";\n\nexport interface LineEventSourceOptions {\n\tkind: McpEventSourceKind;\n\t/** Profile name or path forwarded to `line listen --profile`. */\n\tprofile?: string;\n\t/** Defaults to runCli; injectable for tests. */\n\trun?: typeof runCli;\n\t/** How long to wait for the listener to connect before declaring success. */\n\treadyTimeoutMs?: number;\n\t/** Called when an established listener exits on its own (not via stop()). */\n\tonExit?: (reason: string) => void;\n\tenv?: NodeJS.ProcessEnv;\n}\n\nfunction asString(value: unknown): string | undefined {\n\treturn typeof value === \"string\" && value ? value : undefined;\n}\n\nfunction asTime(value: unknown): string | undefined {\n\tif (typeof value === \"number\" && Number.isFinite(value)) return new Date(value).toISOString();\n\tif (typeof value === \"string\") {\n\t\tconst parsed = new Date(value);\n\t\tif (!Number.isNaN(parsed.getTime())) return parsed.toISOString();\n\t}\n\treturn undefined;\n}\n\nconst EVENT_NAMES: Record<string, string> = {\n\ttalk: \"line.message.received\",\n\t\"talk:edit\": \"line.message.edited\",\n\tsquare: \"line.openchat.message.received\",\n};\n\n/** Map one `line listen --json` NDJSON record onto an MCP event occurrence. */\nexport function toEventRecord(value: Record<string, unknown>): McpEventRecord | undefined {\n\tconst name = typeof value.type === \"string\" ? EVENT_NAMES[value.type] : undefined;\n\tif (!name) return undefined;\n\tconst messageId = asString(value.id);\n\tconst chatId = asString(value.chatMid);\n\tif (!messageId || !chatId) return undefined;\n\tconst occurredAt = asTime(value.createdTime) ?? asTime(value.at) ?? new Date().toISOString();\n\tconst data: Record<string, unknown> = {\n\t\tmessageId,\n\t\tchatId,\n\t\tfrom: asString(value.from) ?? \"\",\n\t\tcontentType: asString(value.contentType) ?? \"UNKNOWN\",\n\t};\n\tconst text = previewText(value.text);\n\tif (text !== undefined) data.text = text;\n\treturn { name, occurredAt, data };\n}\n\n/**\n * Event source backed by the CLI's own `listen --json` command. Running the\n * command in-process reuses the profile, token refresh, and reconnect logic\n * that every other CLI command already uses.\n */\nexport function createLineEventSource(options: LineEventSourceOptions): McpEventSource {\n\tconst run = options.run ?? runCli;\n\tconst readyTimeoutMs = options.readyTimeoutMs ?? 1_500;\n\tconst env = options.env ?? process.env;\n\tlet controller: AbortController | undefined;\n\tlet running: Promise<void> | undefined;\n\n\treturn {\n\t\tasync start(onEvent) {\n\t\t\tif (running) return;\n\t\t\tcontroller = new AbortController();\n\t\t\tconst abortController = controller;\n\n\t\t\tconst args = [...(options.profile ? [\"--profile\", options.profile] : []), \"listen\", \"--json\"];\n\t\t\tif (options.kind === \"square\") args.push(\"--square\");\n\n\t\t\tlet settled = false;\n\t\t\tlet resolveReady: () => void = () => {};\n\t\t\tlet rejectReady: (error: Error) => void = () => {};\n\t\t\tconst ready = new Promise<void>((resolve, reject) => {\n\t\t\t\tresolveReady = resolve;\n\t\t\t\trejectReady = reject;\n\t\t\t});\n\n\t\t\tconst stderr: string[] = [];\n\t\t\tlet stderrSize = 0;\n\t\t\tconst captureStderr = (chunk: string) => {\n\t\t\t\tif (stderrSize >= 4_000) return;\n\t\t\t\tstderr.push(chunk);\n\t\t\t\tstderrSize += chunk.length;\n\t\t\t};\n\n\t\t\tlet buffer = \"\";\n\t\t\tconst onStdout = (chunk: string) => {\n\t\t\t\tbuffer += chunk;\n\t\t\t\tlet index = buffer.indexOf(\"\\n\");\n\t\t\t\twhile (index >= 0) {\n\t\t\t\t\tconst line = buffer.slice(0, index).trim();\n\t\t\t\t\tbuffer = buffer.slice(index + 1);\n\t\t\t\t\tindex = buffer.indexOf(\"\\n\");\n\t\t\t\t\tif (!line) continue;\n\t\t\t\t\tlet parsed: unknown;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tparsed = JSON.parse(line);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) continue;\n\t\t\t\t\tconst record = toEventRecord(parsed as Record<string, unknown>);\n\t\t\t\t\tif (!record) continue;\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\tresolveReady();\n\t\t\t\t\t}\n\t\t\t\t\tonEvent(record);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst timer = setTimeout(() => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolveReady();\n\t\t\t}, readyTimeoutMs);\n\t\t\ttimer.unref?.();\n\n\t\t\tconst execution = run(args, {\n\t\t\t\tstdout: onStdout,\n\t\t\t\tstderr: captureStderr,\n\t\t\t\tinteractive: false,\n\t\t\t\tmcp: true,\n\t\t\t\thandleSignals: false,\n\t\t\t\tsignal: abortController.signal,\n\t\t\t\tenv: { ...env, LINEJS_NONINTERACTIVE: \"1\" },\n\t\t\t}).then(\n\t\t\t\tasync (result) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tconst detail = stderr.join(\"\").trim();\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\trejectReady(new Error(detail || `line listen exited with code ${result.exitCode}`));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (!abortController.signal.aborted) {\n\t\t\t\t\t\toptions.onExit?.(detail || `line listen exited with code ${result.exitCode}`);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync (error: unknown) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tif (!settled) {\n\t\t\t\t\t\tsettled = true;\n\t\t\t\t\t\trejectReady(new Error(detail));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (!abortController.signal.aborted) options.onExit?.(detail);\n\t\t\t\t},\n\t\t\t);\n\t\t\trunning = execution;\n\t\t\t// Clear the handle once the listener exits so a later start() reconnects.\n\t\t\tvoid execution\n\t\t\t\t.catch(() => {})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tif (running === execution) running = undefined;\n\t\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait ready;\n\t\t\t} catch (error) {\n\t\t\t\tabortController.abort();\n\t\t\t\trunning = undefined;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tasync stop() {\n\t\t\tcontroller?.abort();\n\t\t\tcontroller = undefined;\n\t\t\tconst pending = running;\n\t\t\trunning = undefined;\n\t\t\tawait pending?.catch(() => {});\n\t\t},\n\t};\n}\n","import { once } from \"node:events\";\nimport { createInterface } from \"node:readline\";\nimport type { Readable, Writable } from \"node:stream\";\nimport { splitLeadingGlobalOptions } from \"../args.ts\";\nimport { type CommandSpec, commandMetadata, isMcpExecutable } from \"../command.ts\";\nimport { allCommands, resolveCommandTokens } from \"../registry.ts\";\nimport { runCli } from \"../cli.ts\";\nimport { VERSION } from \"../version.ts\";\nimport { errorMessage } from \"../errors.ts\";\nimport { EventRpcError, McpEventHub } from \"./events.ts\";\nimport { createLineEventSource } from \"./listen-source.ts\";\n\nexport const LIST_TOOL_NAME = \"list_linejs_cli\";\nexport const EXECUTE_TOOL_NAME = \"execute_linejs_cli\";\n\nconst PROTOCOL_VERSIONS = [\"2024-11-05\", \"2025-03-26\", \"2025-06-18\"] as const;\nconst LATEST_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1]!;\n\nexport interface ToolDefinition {\n\tname: string;\n\tdescription: string;\n\tinputSchema: Record<string, unknown>;\n}\n\nexport function createToolDefinitions(\n\tcommands: readonly CommandSpec[] = allCommands,\n): ToolDefinition[] {\n\tconst categories = [...new Set(commands.map((command) => command.category))].sort();\n\treturn [\n\t\t{\n\t\t\tname: LIST_TOOL_NAME,\n\t\t\tdescription:\n\t\t\t\t\"List every LINEJS CLI command with its arguments, options, category, and whether it can run through execute_linejs_cli. Use this before calling execute_linejs_cli.\",\n\t\t\tinputSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tcategory: {\n\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\tdescription: `Only include commands in this category. One of: ${categories.join(\", \")}.`,\n\t\t\t\t\t},\n\t\t\t\t\tincludeOptions: {\n\t\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\t\tdescription: \"Include each command's option metadata (default: true).\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: EXECUTE_TOOL_NAME,\n\t\t\tdescription:\n\t\t\t\t'Execute the LINEJS CLI directly (no shell) with an argv array. Example: {\"args\":[\"profile\",\"get\",\"--json\"]}. The tool forces --json and rejects long-running or nested MCP commands.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\targs: {\n\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\tdescription: 'Arguments after the `line` executable, e.g. [\"chats\",\"list\",\"--json\"].',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"args\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t];\n}\n\nexport interface CliExecutionResult {\n\texitCode: number;\n\tstdout: string;\n\tstderr: string;\n}\n\nexport type CliExecutor = (args: string[]) => Promise<CliExecutionResult>;\n\nexport const defaultCliExecutor: CliExecutor = async (args) => {\n\tconst stdout: string[] = [];\n\tconst stderr: string[] = [];\n\tconst result = await runCli(args, {\n\t\tstdout: (chunk) => stdout.push(chunk),\n\t\tstderr: (chunk) => stderr.push(chunk),\n\t\tinteractive: false,\n\t\tmcp: true,\n\t\thandleSignals: false,\n\t\tenv: { ...process.env, LINEJS_NONINTERACTIVE: \"1\" },\n\t});\n\treturn { exitCode: result.exitCode, stdout: stdout.join(\"\"), stderr: stderr.join(\"\") };\n};\n\nfunction jsonRpcResult(id: string | number | null, result: unknown) {\n\treturn { jsonrpc: \"2.0\", id, result };\n}\n\nfunction jsonRpcError(id: string | number | null, code: number, message: string, data?: unknown) {\n\treturn {\n\t\tjsonrpc: \"2.0\",\n\t\tid,\n\t\terror: { code, message, ...(data === undefined ? {} : { data }) },\n\t};\n}\n\nfunction toolText(text: string, isError = false, structuredContent?: Record<string, unknown>) {\n\treturn {\n\t\tcontent: [{ type: \"text\", text }],\n\t\t...(isError ? { isError: true } : {}),\n\t\t...(structuredContent ? { structuredContent } : {}),\n\t};\n}\n\nfunction listCommands(argumentsValue: Record<string, unknown>) {\n\tconst category =\n\t\ttypeof argumentsValue.category === \"string\" ? argumentsValue.category : undefined;\n\tconst includeOptions = argumentsValue.includeOptions !== false;\n\tconst normalized = category?.trim().toLowerCase();\n\tconst commands = allCommands\n\t\t.filter((command) => {\n\t\t\tif (!normalized) return true;\n\t\t\treturn (\n\t\t\t\tcommand.category.toLowerCase().includes(normalized) ||\n\t\t\t\tcommand.name.toLowerCase().includes(normalized)\n\t\t\t);\n\t\t})\n\t\t.map((command) => commandMetadata(command, includeOptions));\n\treturn {\n\t\tcommandCount: commands.length,\n\t\tcommands,\n\t};\n}\n\nasync function executeCommand(\n\targumentsValue: Record<string, unknown>,\n\texecutor: CliExecutor,\n): Promise<Record<string, unknown>> {\n\tif (\n\t\t!Array.isArray(argumentsValue.args) ||\n\t\t!argumentsValue.args.every((entry) => typeof entry === \"string\")\n\t) {\n\t\treturn toolText(\"execute_linejs_cli requires args: string[].\", true);\n\t}\n\tconst args = argumentsValue.args as string[];\n\tif (!args.length) return toolText(\"execute_linejs_cli requires at least one argument.\", true);\n\tif (args.includes(\"--password-stdin\")) {\n\t\treturn toolText(\n\t\t\t\"--password-stdin reads stdin, which belongs to the MCP transport. Use --password, or log in from a terminal.\",\n\t\t\ttrue,\n\t\t);\n\t}\n\tconst argsFileIndex = args.findIndex(\n\t\t(arg) => arg === \"--args-file\" || arg.startsWith(\"--args-file=\"),\n\t);\n\tif (\n\t\targsFileIndex !== -1 &&\n\t\t(args[argsFileIndex] === \"--args-file=-\" || args[argsFileIndex + 1] === \"-\")\n\t) {\n\t\treturn toolText(\n\t\t\t\"--args-file - reads stdin, which belongs to the MCP transport. Use a file path.\",\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tlet rest: string[];\n\ttry {\n\t\t({ rest } = splitLeadingGlobalOptions(args));\n\t} catch (error) {\n\t\treturn toolText(errorMessage(error), true);\n\t}\n\tconst resolution = resolveCommandTokens(rest);\n\tconst command = resolution.command;\n\tif (!command) {\n\t\tconst detail = resolution.group\n\t\t\t? `\"${resolution.group}\" is a command group, not an executable command. Run list_linejs_cli for exact names.`\n\t\t\t: `Unknown command: ${resolution.unknown ?? rest[0] ?? \"(none)\"}. Run list_linejs_cli first.`;\n\t\treturn toolText(detail, true);\n\t}\n\tif (command.name === \"mcp\") {\n\t\treturn toolText(\"The mcp command cannot be nested inside an MCP server.\", true);\n\t}\n\tif (!isMcpExecutable(command)) {\n\t\treturn toolText(\n\t\t\t`${command.name} is ${command.longRunning ? \"long-running\" : \"not exposed to MCP\"} and cannot run through execute_linejs_cli.`,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst separator = args.indexOf(\"--\");\n\tconst executionArgs =\n\t\tseparator === -1\n\t\t\t? [...args, \"--json\"]\n\t\t\t: [...args.slice(0, separator), \"--json\", ...args.slice(separator)];\n\tconst execution = await executor(executionArgs);\n\tconst output = execution.stdout.trimEnd();\n\tconst errorText = execution.stderr.trimEnd();\n\tconst content = [\n\t\t{\n\t\t\ttype: \"text\",\n\t\t\ttext: output || errorText || `(no output; exit code ${execution.exitCode})`,\n\t\t},\n\t\t...(errorText && output ? [{ type: \"text\", text: `stderr:\\n${errorText}` }] : []),\n\t];\n\treturn {\n\t\tcontent,\n\t\t...(execution.exitCode === 0 ? {} : { isError: true }),\n\t\tstructuredContent: {\n\t\t\texitCode: execution.exitCode,\n\t\t\tstdout: execution.stdout,\n\t\t\tstderr: execution.stderr,\n\t\t},\n\t};\n}\n\nexport async function handleMcpMessage(\n\tmessage: unknown,\n\toptions: {\n\t\tcommands?: readonly CommandSpec[];\n\t\texecutor?: CliExecutor;\n\t\tevents?: McpEventHub;\n\t} = {},\n): Promise<unknown | null> {\n\tif (!message || typeof message !== \"object\" || Array.isArray(message)) {\n\t\treturn jsonRpcError(null, -32600, \"Invalid Request\");\n\t}\n\tconst request = message as Record<string, unknown>;\n\tconst id = (request.id as string | number | null | undefined) ?? null;\n\tconst isNotification = request.id === undefined;\n\tconst method = request.method;\n\tif (typeof method !== \"string\") {\n\t\treturn isNotification ? null : jsonRpcError(id, -32600, \"Invalid Request\");\n\t}\n\tif (request.jsonrpc !== \"2.0\") {\n\t\treturn isNotification ? null : jsonRpcError(id, -32600, \"Invalid Request\");\n\t}\n\n\tif (isNotification) return null;\n\n\tswitch (method) {\n\t\tcase \"initialize\": {\n\t\t\tconst params = (request.params ?? {}) as Record<string, unknown>;\n\t\t\tconst requested = params.protocolVersion;\n\t\t\tconst protocolVersion =\n\t\t\t\ttypeof requested === \"string\" &&\n\t\t\t\t(PROTOCOL_VERSIONS as readonly string[]).includes(requested)\n\t\t\t\t\t? requested\n\t\t\t\t\t: LATEST_PROTOCOL_VERSION;\n\t\t\treturn jsonRpcResult(id, {\n\t\t\t\tprotocolVersion,\n\t\t\t\tcapabilities: { tools: { listChanged: false }, events: {} },\n\t\t\t\tserverInfo: { name: \"@evex-dev/linejs-cli\", version: VERSION },\n\t\t\t\tinstructions:\n\t\t\t\t\t\"Use list_linejs_cli to discover commands, then execute_linejs_cli with an argv array. No shell is involved; --json is forced. Long-running commands such as listen are rejected. MCP Events (webhook delivery) are available through events/list, events/subscribe, and events/unsubscribe.\",\n\t\t\t});\n\t\t}\n\t\tcase \"ping\":\n\t\t\treturn jsonRpcResult(id, {});\n\t\tcase \"tools/list\": {\n\t\t\treturn jsonRpcResult(id, {\n\t\t\t\ttools: createToolDefinitions(options.commands ?? allCommands),\n\t\t\t});\n\t\t}\n\t\tcase \"tools/call\": {\n\t\t\tconst params = (request.params ?? {}) as Record<string, unknown>;\n\t\t\tconst name = params.name;\n\t\t\tconst argumentsValue =\n\t\t\t\tparams.arguments && typeof params.arguments === \"object\" && !Array.isArray(params.arguments)\n\t\t\t\t\t? (params.arguments as Record<string, unknown>)\n\t\t\t\t\t: {};\n\t\t\tif (name === LIST_TOOL_NAME) {\n\t\t\t\tconst result = listCommands(argumentsValue);\n\t\t\t\treturn jsonRpcResult(id, {\n\t\t\t\t\tcontent: [{ type: \"text\", text: JSON.stringify(result, null, 2) }],\n\t\t\t\t\tstructuredContent: result,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (name === EXECUTE_TOOL_NAME) {\n\t\t\t\treturn jsonRpcResult(\n\t\t\t\t\tid,\n\t\t\t\t\tawait executeCommand(argumentsValue, options.executor ?? defaultCliExecutor),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn jsonRpcError(id, -32602, `Unknown tool: ${String(name)}`);\n\t\t}\n\t\tcase \"events/list\":\n\t\tcase \"events/subscribe\":\n\t\tcase \"events/unsubscribe\": {\n\t\t\tconst hub = options.events;\n\t\t\tif (!hub) return jsonRpcError(id, -32601, `Method not found: ${method}`);\n\t\t\tconst params = (request.params ?? {}) as Record<string, unknown>;\n\t\t\ttry {\n\t\t\t\tif (method === \"events/list\") return jsonRpcResult(id, hub.list(params));\n\t\t\t\tif (method === \"events/subscribe\") {\n\t\t\t\t\treturn jsonRpcResult(id, await hub.subscribe(params));\n\t\t\t\t}\n\t\t\t\treturn jsonRpcResult(id, hub.unsubscribe(params));\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof EventRpcError) {\n\t\t\t\t\treturn jsonRpcError(id, error.code, error.message, error.data);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t\tcase \"resources/list\":\n\t\t\treturn jsonRpcResult(id, { resources: [] });\n\t\tcase \"prompts/list\":\n\t\t\treturn jsonRpcResult(id, { prompts: [] });\n\t\tcase \"logging/setLevel\":\n\t\t\treturn jsonRpcResult(id, {});\n\t\tdefault:\n\t\t\treturn jsonRpcError(id, -32601, `Method not found: ${method}`);\n\t}\n}\n\nexport interface RunMcpServerOptions {\n\tinput?: Readable;\n\toutput?: Writable;\n\terror?: Writable;\n\tcommands?: readonly CommandSpec[];\n\texecutor?: CliExecutor;\n\tsignal?: AbortSignal;\n\t/** Identity used to scope webhook subscriptions; defaults to \"stdio\". */\n\tprincipal?: string;\n\t/** Profile name or path the event listener should use. */\n\tprofile?: string;\n\t/** Inject a hub (tests); otherwise one backed by `line listen` is created. */\n\tevents?: McpEventHub;\n}\n\nexport async function runMcpServer(options: RunMcpServerOptions = {}): Promise<number> {\n\tconst input = options.input ?? process.stdin;\n\tconst output = options.output ?? process.stdout;\n\tconst error = options.error ?? process.stderr;\n\tconst commands = options.commands ?? allCommands;\n\tconst executor = options.executor ?? defaultCliExecutor;\n\tconst events =\n\t\toptions.events ??\n\t\tnew McpEventHub({\n\t\t\tprincipal: options.principal ?? \"stdio\",\n\t\t\tsourceFactory: (kind) =>\n\t\t\t\tcreateLineEventSource({\n\t\t\t\t\tkind,\n\t\t\t\t\tprofile: options.profile,\n\t\t\t\t\tonExit: (reason) => error.write(`[mcp-events] LINE listener exited: ${reason}\\n`),\n\t\t\t\t}),\n\t\t\tlog: (message) => error.write(`[mcp-events] ${message}\\n`),\n\t\t});\n\n\tconst write = async (value: unknown) => {\n\t\tif (!output.write(`${JSON.stringify(value)}\\n`)) {\n\t\t\tawait once(output, \"drain\");\n\t\t}\n\t};\n\n\terror.write(\"@evex-dev/linejs-cli MCP server listening on stdio\\n\");\n\n\tconst lines = createInterface({ input, crlfDelay: Infinity });\n\tconst onAbort = () => lines.close();\n\tif (options.signal) {\n\t\tif (options.signal.aborted) lines.close();\n\t\telse options.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t}\n\tlet queue: Promise<void> = Promise.resolve();\n\tfor await (const line of lines) {\n\t\tif (!line.trim()) continue;\n\t\tqueue = queue.then(async () => {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(line);\n\t\t\t} catch (parseError) {\n\t\t\t\tawait write(jsonRpcError(null, -32700, \"Parse error\", String(parseError)));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (Array.isArray(parsed)) {\n\t\t\t\t\tconst responses = [];\n\t\t\t\t\tfor (const entry of parsed) {\n\t\t\t\t\t\tconst response = await handleMcpMessage(entry, { commands, executor, events });\n\t\t\t\t\t\tif (response !== null) responses.push(response);\n\t\t\t\t\t}\n\t\t\t\t\tif (responses.length) await write(responses);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst response = await handleMcpMessage(parsed, { commands, executor, events });\n\t\t\t\tif (response !== null) await write(response);\n\t\t\t} catch (handlerError) {\n\t\t\t\tawait write(\n\t\t\t\t\tjsonRpcError(\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t-32603,\n\t\t\t\t\t\t\"Internal error\",\n\t\t\t\t\t\thandlerError instanceof Error ? handlerError.message : String(handlerError),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t}\n\tawait queue;\n\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\tawait events.close();\n\treturn 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB;AAGrC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAU3B,IAAa,uBAAb,cAA0C,MAAM;CAC/C;CAEA,YAAY,UAAgC,SAAiB;EAC5D,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;AACD;;AAyBA,SAAgB,qBAAqB,OAA+B;CACnE,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,WAAA,QAAgC,GAC1C,OAAO,mCAAmC;CAE3C,MAAM,UAAU,MAAM,MAAM,CAA4B;CACxD,IAAI,CAAC,yBAAyB,KAAK,OAAO,GACzC,OAAO;CAER,MAAM,QAAQ,OAAO,KAAK,SAAS,QAAQ;CAC3C,IAAI,MAAM,SAAS,MAAM,MAAM,SAAS,IACvC,OAAO;CAER,OAAO;AACR;AAEA,SAAgB,oBAAoB,QAAwB;CAC3D,MAAM,UAAU,OAAO,WAAA,QAAgC,IACpD,OAAO,MAAM,CAA4B,IACzC;CACH,OAAO,OAAO,KAAK,SAAS,QAAQ;AACrC;;;;;AAMA,SAAgB,YACf,QACA,WACA,kBACA,MACS;CAIT,OAAO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;CAClC,IAAI,QAAQ,QAAQ;EACnB,IAAI,QAAQ,OAAO,SAAS,MAAM,MAAM;OACnC,QAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CACtE;CACA,IAAI,QAAuB,QAAQ,QAAQ;CAC3C,WAAW,MAAM,QAAQ,OAAO;EAC/B,IAAI,CAAC,KAAK,KAAK,GAAG;EAClB,QAAQ,MAAM,KAAK,YAAY;GAC9B,IAAI;GACJ,IAAI;IACH,SAAS,KAAK,MAAM,IAAI;GACzB,SAAS,YAAY;IACpB,MAAM,MAAM,aAAa,MAAM,QAAQ,eAAe,OAAO,UAAU,CAAC,CAAC;IACzE;GACD;GACA,IAAI;IACH,IAAI,MAAM,QAAQ,MAAM,GAAG;KAC1B,MAAM,YAAY,CAAC;KACnB,KAAK,MAAM,SAAS,QAAQ;MAC3B,MAAM,WAAW,MAAM,iBAAiB,OAAO;OAAE;OAAU;OAAU;MAAO,CAAC;MAC7E,IAAI,aAAa,MAAM,UAAU,KAAK,QAAQ;KAC/C;KACA,IAAI,UAAU,QAAQ,MAAM,MAAM,SAAS;KAC3C;IACD;IACA,MAAM,WAAW,MAAM,iBAAiB,QAAQ;KAAE;KAAU;KAAU;IAAO,CAAC;IAC9E,IAAI,aAAa,MAAM,MAAM,MAAM,QAAQ;GAC5C,SAAS,cAAc;IACtB,MAAM,MACL,aACC,MACA,QACA,kBACA,wBAAwB,QAAQ,aAAa,UAAU,OAAO,YAAY,CAC3E,CACD;GACD;EACD,CAAC;CACF;CACA,MAAM;CACN,QAAQ,QAAQ,oBAAoB,SAAS,OAAO;CACpD,MAAM,OAAO,MAAM;CACnB,OAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evex-dev/linejs-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Command-line interface and MCP server for LINEJS",
5
5
  "keywords": [
6
6
  "cli",
@@ -31,8 +31,8 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@evex-dev/linejs": "^3.6.3",
35
- "@evex-dev/linejs-types": "^3.6.3",
34
+ "@evex-dev/linejs": "^3.6.5",
35
+ "@evex-dev/linejs-types": "^3.6.5",
36
36
  "uqr": "^0.1.3"
37
37
  },
38
38
  "devDependencies": {