(
options: CompactionOptions & { api: RouterClient<AppRouter> }
)
| 1601 | * Execute a compaction command |
| 1602 | */ |
| 1603 | export async function executeCompaction( |
| 1604 | options: CompactionOptions & { api: RouterClient<AppRouter> } |
| 1605 | ): Promise<CompactionResult> { |
| 1606 | const { messageText, metadata, sendOptions } = prepareCompactionMessage(options); |
| 1607 | |
| 1608 | const result = await options.api.workspace.sendMessage({ |
| 1609 | workspaceId: options.workspaceId, |
| 1610 | message: messageText, |
| 1611 | options: { |
| 1612 | ...sendOptions, |
| 1613 | muxMetadata: metadata, |
| 1614 | editMessageId: options.editMessageId, |
| 1615 | }, |
| 1616 | }); |
| 1617 | |
| 1618 | if (!result.success) { |
| 1619 | // Convert SendMessageError to string for error display |
| 1620 | const errorString = result.error |
| 1621 | ? typeof result.error === "string" |
| 1622 | ? result.error |
| 1623 | : "type" in result.error |
| 1624 | ? result.error.type |
| 1625 | : "Failed to compact" |
| 1626 | : undefined; |
| 1627 | return { success: false, error: errorString }; |
| 1628 | } |
| 1629 | |
| 1630 | return { success: true }; |
| 1631 | } |
| 1632 | |
| 1633 | // ============================================================================ |
| 1634 | // Command Handler Types |
no test coverage detected