(
sessionId: string,
taskId: string,
options?: GetTaskOptions,
)
| 38 | } |
| 39 | |
| 40 | async get( |
| 41 | sessionId: string, |
| 42 | taskId: string, |
| 43 | options?: GetTaskOptions, |
| 44 | ): Promise<BackgroundTask> { |
| 45 | await this._requireSession(sessionId); |
| 46 | const raw = await this._getAllRaw(sessionId); |
| 47 | const found = raw.find((t) => t.taskId === taskId); |
| 48 | if (found === undefined) { |
| 49 | throw new TaskNotFoundError(sessionId, taskId); |
| 50 | } |
| 51 | |
| 52 | let output: { preview: string; bytes: number } | undefined; |
| 53 | if (options?.withOutput) { |
| 54 | const tailBytes = options.outputBytes ?? DEFAULT_TASK_OUTPUT_PREVIEW_BYTES; |
| 55 | try { |
| 56 | const preview = await this.core.rpc.getBackgroundOutput({ |
| 57 | sessionId, |
| 58 | agentId: MAIN_AGENT_ID, |
| 59 | taskId, |
| 60 | tail: tailBytes, |
| 61 | }); |
| 62 | if (preview.length > 0) { |
| 63 | output = { preview, bytes: Buffer.byteLength(preview, 'utf-8') }; |
| 64 | } |
| 65 | } catch { |
| 66 | // Output may not be available yet; fall back to task metadata only. |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return toProtocolTask(sessionId, found, output); |
| 71 | } |
| 72 | |
| 73 | async cancel(sessionId: string, taskId: string): Promise<{ cancelled: true }> { |
| 74 | await this._requireSession(sessionId); |
nothing calls this directly
no test coverage detected