import { kody } from 'kody:runtime' /** * Cross-package calls run through `kody.execute` with a literal static * import inside the executed module, NOT a top-level `kody:@` import here. * Reason: @kentcdodds/discord and @kentcdodds/grok-bot statically import * `quiet-hours/status` (hot path), and waiting-on-me depends on grok-bot. * Static imports of discord or waiting-on-me from this package would form a * `kody.dependencies` cycle, which publish rejects. Same pattern as * discord's handle-decision-reaction → grok-bot wake. */ export const WAITING_ON_ME_CREATE_CODE = [ "import create from 'kody:@kentcdodds/waiting-on-me/create'", '', 'export default async function main(params = {}) {', ' return await create(params)', '}', ].join('\n') export const DISCORD_POST_MESSAGE_CODE = [ "import postMessage from 'kody:@kentcdodds/discord/post-message'", '', 'export default async function main(params = {}) {', ' return await postMessage(params)', '}', ].join('\n') export async function executeExport(code: string, params: Record) { const executed = (await kody.execute({ code, params, writable: true })) as unknown const row = executed && typeof executed === 'object' ? (executed as Record) : null if (row?.ok === false) { throw new Error(typeof row.error === 'string' ? row.error : 'execute failed') } return row && 'result' in row ? row.result : executed }