(path: string, payload: Record<string, unknown>)
| 146 | }; |
| 147 | |
| 148 | const post = async (path: string, payload: Record<string, unknown>): Promise<unknown> => { |
| 149 | const response = await doFetch(`${getExecutorApiBaseUrl()}${path}`, { |
| 150 | method: "POST", |
| 151 | headers: requestHeaders(), |
| 152 | body: JSON.stringify(payload), |
| 153 | }); |
| 154 | if (!response.ok) { |
| 155 | const text = await response.text(); |
| 156 | // An approval that outlived its window is an ordinary outcome, not a |
| 157 | // fault: nothing ran, and the fix is to trigger the action again. Say that |
| 158 | // instead of surfacing the transport's error body, which reached the user |
| 159 | // as a raw `ExecutionNotFoundError` inside a JSON-RPC envelope. |
| 160 | if (response.status === APPROVAL_EXPIRED_STATUS) { |
| 161 | // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: the shell's tool proxy is Promise-based and surfaces rejections as component errors |
| 162 | throw new Error(APPROVAL_EXPIRED_MESSAGE); |
| 163 | } |
| 164 | // oxlint-disable-next-line executor/no-try-catch-or-throw, executor/no-error-constructor -- boundary: the shell's tool proxy is Promise-based and surfaces rejections as component errors |
| 165 | throw new Error(text || `Executor API request failed with ${response.status}`); |
| 166 | } |
| 167 | return response.json(); |
| 168 | }; |
| 169 | |
| 170 | return { |
| 171 | getHostContext: () => ({ theme: prefersDark() ? "dark" : "light" }), |
no test coverage detected