(client, cwd, options = {})
| 730 | } |
| 731 | |
| 732 | async function startThread(client, cwd, options = {}) { |
| 733 | const response = await client.request("thread/start", buildThreadParams(cwd, options)); |
| 734 | const threadId = response.thread.id; |
| 735 | if (options.threadName) { |
| 736 | try { |
| 737 | await client.request("thread/name/set", { threadId, name: options.threadName }); |
| 738 | } catch (err) { |
| 739 | // Only suppress "unknown variant/method" errors from older CLI versions |
| 740 | // that don't support thread/name/set. Rethrow auth, network, or server errors. |
| 741 | const msg = String(err?.message ?? err ?? ""); |
| 742 | if (!msg.includes("unknown variant") && !msg.includes("unknown method")) { |
| 743 | throw err; |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | return response; |
| 748 | } |
| 749 | |
| 750 | async function resumeThread(client, threadId, cwd, options = {}) { |
| 751 | return client.request("thread/resume", buildResumeParams(threadId, cwd, options)); |
no test coverage detected