From fd621f4b115589295ac0b1f9dc20bb5357a5643e Mon Sep 17 00:00:00 2001 From: iroiro147 Date: Sun, 2 Aug 2026 18:13:50 +0530 Subject: [PATCH] fix(eve): vendor content-hashed declaration chunks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The chat and @chat-adapter/twilio vendor configs previously only matched `jsx-runtime-.d.ts` (chat) or nothing at all (twilio) via `discoverExtraFiles`. The upstream bundler emits additional content-hashed declaration chunks — `messages-BSoJG691.d.ts` (chat) and `types-WYjTBVDi.d.ts` (twilio) — that index.d.ts imports by relative path. Drop those chunks from the published tarball and ~120 chat exports plus ~10 twilio exports degrade to `any`; consumers with `skipLibCheck: false` hit TS2307 + TS2741 (see #1500). Extend `createDeclarationCopier` so the discoverExtraFiles-selected chunks flow through the same rewrite pass (mdast stub, @workflow/serde symbol stub, …) as the named entry files — the chunk contains `import { Root } from 'mdast'` and would otherwise leak a bare specifier that the published package cannot resolve. Then broaden the chat regex to also match `messages-.d.ts` and add the twilio discovery block patterned after @chat-adapter/slack's. Co-copying the chunk surfaces the chat type graph precisely, which exposes a small set of type-surface leaks in eve sources and tests that were silently relying on the previous `any` fallback. Tighten them: - chatSdkChannel.ts: `Thread` from `ActionEvent` no longer coerces silently to the declared `Thread` (TState = Record<…>) parameter of `ChatSdkSendOptions.thread` — cast the event.thread field through the declared alias. - photon channel tests: `new Message({...})` mocks lacked the now-required `formatted` (mdast Root), `metadata` (dateSent + edited), and `attachments` fields; supplement them so the strict constructor accepts the object. - photon channel tests: `Author` mocks lacked the newly-strict `fullName` field. Verified: `pnpm build:compiled` regenerates `.generated/compiled/` with both chunks present and the mdast/@workflow/serde rewrites applied to the copied chunk (`from './_mdast.js'`, `from './_workflow-serde.js'`); `npx tsc --noEmit -p tsconfig.json` drops from 5 pre-existing errors to 0; `npx tsc -p tsconfig.build.json` passes; `pnpm run test:unit` passes 5870/5875 (the 5 baseline Node-v24-bootstrap failures are unchanged). Resolves #1500. Signed-off-by: Sarthak Singh Signed-off-by: iroiro147 --- .../fix-1500-missing-declaration-chunks.md | 5 ++++ .../vendor-compiled/@chat-adapter/twilio.mjs | 9 ++++++ .../eve/scripts/vendor-compiled/_shared.mjs | 29 ++++++++++++------- packages/eve/scripts/vendor-compiled/chat.mjs | 10 ++++++- .../channels/chat-sdk/chatSdkChannel.ts | 2 +- .../channels/photon/inboundContent.test.ts | 4 ++- .../photon/photonIMessageChannel.test.ts | 15 ++++++++-- 7 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 .changeset/fix-1500-missing-declaration-chunks.md diff --git a/.changeset/fix-1500-missing-declaration-chunks.md b/.changeset/fix-1500-missing-declaration-chunks.md new file mode 100644 index 0000000000..79ccfbb3ad --- /dev/null +++ b/.changeset/fix-1500-missing-declaration-chunks.md @@ -0,0 +1,5 @@ +--- +"eve": patch +--- + +Fix missing content-hashed declaration chunks in the published `eve` tarball. The chat and twilio vendor configs previously only co-copied `jsx-runtime-.d.ts` (chat) or no hashed chunks at all (twilio), so the upstream `messages-.d.ts` and `types-.d.ts` files were dropped from the published package — degrading ~120 chat exports to `any` and producing TS2307 errors with `skipLibCheck: false`. Extend `discoverExtraFiles` in `_shared.mjs` to fold the hashed siblings into the same declaration-rewrite pass as the named entry files, and add the chunk patterns (`messages-`, `types-`) to the chat and twilio configs. Also fixes a small set of `chat` and `@chat-adapter/twilio` type-surface leaks in eve sources and tests that were silently relying on the previous `any` fallback. Resolves #1500. diff --git a/packages/eve/scripts/vendor-compiled/@chat-adapter/twilio.mjs b/packages/eve/scripts/vendor-compiled/@chat-adapter/twilio.mjs index 39b2fd9575..6413544493 100644 --- a/packages/eve/scripts/vendor-compiled/@chat-adapter/twilio.mjs +++ b/packages/eve/scripts/vendor-compiled/@chat-adapter/twilio.mjs @@ -35,5 +35,14 @@ export default { rewrites: { chat: { kind: "vendored", compiledPath: "chat" }, }, + discoverExtraFiles: (distEntries) => + // The upstream bundler emits content-hashed sibling declaration + // chunks (`types-.d.ts`) that the entry .d.ts files import by + // relative path. Co-copy them verbatim so the specifier resolves + // inside the published tarball — the miss here produced TS2307 for + // `TwilioWebhookUrl` and `TwilioVerifiedRequest` under + // skipLibCheck:false (see #1500). Mirrors the @chat-adapter/slack + // pattern a few directories over. + distEntries.filter((name) => /^types-[^./]+\.d\.ts$/.test(name)), }), }; diff --git a/packages/eve/scripts/vendor-compiled/_shared.mjs b/packages/eve/scripts/vendor-compiled/_shared.mjs index ec095cd3b8..cbdf0863a2 100644 --- a/packages/eve/scripts/vendor-compiled/_shared.mjs +++ b/packages/eve/scripts/vendor-compiled/_shared.mjs @@ -120,8 +120,21 @@ export function createDeclarationCopier({ ? files : [{ source: "index.d.ts", output: "index.d.ts" }]; + // discoverExtraFiles names content-hashed sibling chunks (e.g. + // `messages-.d.ts`, `types-.d.ts`) that the upstream + // bundler emits next to the entry .d.ts. They must flow through the + // same rewrite pass as the named `files` — chat's `messages-` + // chunk imports `mdast`, and the published package cannot ship that + // bare specifier (no @types/mdast in scope; see #1500). + const extraFileNames = + typeof discoverExtraFiles === "function" ? discoverExtraFiles(distEntries) : []; + const allFiles = [ + ...declarationFiles, + ...extraFileNames.map((name) => ({ source: name, output: name })), + ]; + const declarations = await Promise.all( - declarationFiles.map(async (file) => ({ + allFiles.map(async (file) => ({ ...file, sourceText: await readFile(join(distDir, file.source), "utf8"), })), @@ -178,16 +191,10 @@ export function createDeclarationCopier({ }), ); - if (typeof discoverExtraFiles === "function") { - const extras = discoverExtraFiles(distEntries); - await Promise.all( - extras.map(async (file) => { - const outputPath = join(destinationRoot, file); - await mkdir(dirname(outputPath), { recursive: true }); - await copyFile(join(distDir, file), outputPath); - }), - ); - } + // NOTE: the previous tail block that re-copied each extra file verbatim + // (via copyFile) is removed — extras are folded into `declarations` + // above so they receive the same rewrite pass. Re-adding it would + // overwrite the rewritten output with the un-rewritten source. }; } diff --git a/packages/eve/scripts/vendor-compiled/chat.mjs b/packages/eve/scripts/vendor-compiled/chat.mjs index affcc5ff86..e4df9bcb6a 100644 --- a/packages/eve/scripts/vendor-compiled/chat.mjs +++ b/packages/eve/scripts/vendor-compiled/chat.mjs @@ -38,6 +38,14 @@ export default { }, }, discoverExtraFiles: (distEntries) => - distEntries.filter((name) => /^jsx-runtime-[^./]+\.d\.ts$/.test(name)), + // Co-copy the sibling content-hashed declaration chunks the upstream + // build emits that the entry .d.ts imports by relative path: + // `jsx-runtime-.d.ts` (pre-existing) and `messages-.d.ts` + // (previously missed — its absence with skipLibCheck:false produced + // TS2307 across ~120 chat exports, see #1500). The hash suffix is + // content-derived and drifts on every upstream build. + distEntries.filter((name) => + /^(jsx-runtime|messages)-[^./]+\.d\.ts$/.test(name), + ), }), }; diff --git a/packages/eve/src/public/channels/chat-sdk/chatSdkChannel.ts b/packages/eve/src/public/channels/chat-sdk/chatSdkChannel.ts index 516cd531ec..b844ad82c6 100644 --- a/packages/eve/src/public/channels/chat-sdk/chatSdkChannel.ts +++ b/packages/eve/src/public/channels/chat-sdk/chatSdkChannel.ts @@ -270,7 +270,7 @@ export function chatSdkChannel( { inputResponses: [response] }, { auth: config.resolveInputAuth ? await config.resolveInputAuth(event) : null, - thread: event.thread, + thread: event.thread as Thread, }, ); }); diff --git a/packages/eve/src/public/channels/photon/inboundContent.test.ts b/packages/eve/src/public/channels/photon/inboundContent.test.ts index c031c075e9..9eb68138c6 100644 --- a/packages/eve/src/public/channels/photon/inboundContent.test.ts +++ b/packages/eve/src/public/channels/photon/inboundContent.test.ts @@ -6,8 +6,10 @@ import { photonInboundContent } from "#public/channels/photon/inboundContent.js" function message(text: string, attachments: Message["attachments"] = []): Message { return new Message({ attachments, - author: { isBot: false, isMe: false, userId: "user", userName: "user" }, + author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" }, + formatted: { type: "root", children: [] }, id: "message-id", + metadata: { dateSent: new Date(), edited: false }, raw: {}, text, threadId: "thread-id", diff --git a/packages/eve/src/public/channels/photon/photonIMessageChannel.test.ts b/packages/eve/src/public/channels/photon/photonIMessageChannel.test.ts index e52be32b96..3a8d2e9e2d 100644 --- a/packages/eve/src/public/channels/photon/photonIMessageChannel.test.ts +++ b/packages/eve/src/public/channels/photon/photonIMessageChannel.test.ts @@ -42,8 +42,11 @@ describe("photonIMessageChannel", () => { if (handler === undefined) throw new Error("Expected an inbound direct-message handler."); const thread = { id: "thread-id" }; const message = new Message({ - author: { isBot: false, isMe: false, userId: "user", userName: "user" }, + attachments: [], + author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" }, + formatted: { type: "root", children: [] }, id: "message-id", + metadata: { dateSent: new Date(), edited: false }, raw: {}, text: "Steer this response", threadId: thread.id, @@ -65,8 +68,11 @@ describe("photonIMessageChannel", () => { if (handler === undefined) throw new Error("Expected an inbound direct-message handler."); const thread = { id: "thread-id" }; const message = new Message({ - author: { isBot: false, isMe: false, userId: "user", userName: "user" }, + attachments: [], + author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" }, + formatted: { type: "root", children: [] }, id: "message-id", + metadata: { dateSent: new Date(), edited: false }, raw: {}, text: " \n", threadId: thread.id, @@ -87,8 +93,11 @@ describe("photonIMessageChannel", () => { } const thread = { id: "group-thread-id" }; const message = new Message({ - author: { isBot: false, isMe: false, userId: "user", userName: "user" }, + attachments: [], + author: { fullName: "user", isBot: false, isMe: false, userId: "user", userName: "user" }, + formatted: { type: "root", children: [] }, id: "message-id", + metadata: { dateSent: new Date(), edited: false }, raw: {}, text: "Hello group", threadId: thread.id,