(raw: unknown)
| 75 | } |
| 76 | |
| 77 | const handleDispatch = (raw: unknown): void => { |
| 78 | const d = asCommandDispatch(raw) |
| 79 | |
| 80 | if (!d) { |
| 81 | return sys('error: invalid response: command.dispatch') |
| 82 | } |
| 83 | |
| 84 | if (d.type === 'exec' || d.type === 'plugin') { |
| 85 | return sys(d.output || '(no output)') |
| 86 | } |
| 87 | |
| 88 | if (d.type === 'alias') { |
| 89 | return void handler(`/${d.target}${argTail}`) |
| 90 | } |
| 91 | |
| 92 | if (d.type === 'skill') { |
| 93 | sys(`⚡ loading skill: ${d.name}`) |
| 94 | |
| 95 | return d.message?.trim() ? send(d.message) : sys(`/${parsed.name}: skill payload missing message`) |
| 96 | } |
| 97 | |
| 98 | if (d.type === 'send') { |
| 99 | if (d.notice?.trim()) { |
| 100 | sys(d.notice) |
| 101 | } |
| 102 | |
| 103 | return d.message?.trim() ? send(d.message) : sys(`/${parsed.name}: empty message`) |
| 104 | } |
| 105 | |
| 106 | if (d.type === 'prefill') { |
| 107 | // /undo returns prefill: drop the backed-up message text into |
| 108 | // the composer so the user can edit and resubmit, instead of |
| 109 | // submitting it immediately like 'send'. |
| 110 | if (d.notice?.trim()) { |
| 111 | sys(d.notice) |
| 112 | } |
| 113 | |
| 114 | if (d.message) { |
| 115 | ctx.composer.setInput(d.message) |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | gw.request<SlashExecResponse>('slash.exec', { command: cmd.slice(1), session_id: sid }) |
| 121 | .then(r => { |
no test coverage detected