#456

fix(chat): give CardSpecError the message streamCard already posted

Opensachinmourwants to merge intofrom

streamCard posts the partial card before it validates the final spec. When the final spec fails, for example because limits apply only to the final card, streamCard throws CardSpecError with the partial card already in the thread. The docs say you can retry or edit that message, but the error didn't carry it and streamCard never returned it. The only way to reach it was to wrap the target and capture what post returned.

streamCard now sets postedMessage on the CardSpecError it rethrows. It's the message showing the partial card, or undefined if the stream ended before anything was posted. Errors from toCard are unchanged.

try {
  await streamCard(thread, result.textStream, { limits });
} catch (error) {
  if (!(error instanceof CardSpecError)) throw error;
  const card = toCard(await fixSpec(error.issues), { limits });
  if (error.postedMessage) await error.postedMessage.edit(card);
  else await thread.post(card);
}

The API reference, the package README, and the chat skill document the property. The docs baseline fixture has the new hashes for /docs/api/chat.

Two tests cover it. A spec that streams two tables against limits: { tables: 1 } rejects with the posted message. A card that never had visible content rejects with postedMessage undefined.