(options: {
remoteTaskType: RemoteTaskType;
session: {
id: string;
title: string;
};
command: string;
context: TaskContext;
toolUseId?: string;
isRemoteReview?: boolean;
isUltraplan?: boolean;
isLongRunning?: boolean;
remoteTaskMetadata?: RemoteTaskMetadata;
})
| 384 | * Callers remain responsible for custom pre-registration logic (git dialogs, transcript upload, teleport options). |
| 385 | */ |
| 386 | export function registerRemoteAgentTask(options: { |
| 387 | remoteTaskType: RemoteTaskType; |
| 388 | session: { |
| 389 | id: string; |
| 390 | title: string; |
| 391 | }; |
| 392 | command: string; |
| 393 | context: TaskContext; |
| 394 | toolUseId?: string; |
| 395 | isRemoteReview?: boolean; |
| 396 | isUltraplan?: boolean; |
| 397 | isLongRunning?: boolean; |
| 398 | remoteTaskMetadata?: RemoteTaskMetadata; |
| 399 | }): { |
| 400 | taskId: string; |
| 401 | sessionId: string; |
| 402 | cleanup: () => void; |
| 403 | } { |
| 404 | const { |
| 405 | remoteTaskType, |
| 406 | session, |
| 407 | command, |
| 408 | context, |
| 409 | toolUseId, |
| 410 | isRemoteReview, |
| 411 | isUltraplan, |
| 412 | isLongRunning, |
| 413 | remoteTaskMetadata |
| 414 | } = options; |
| 415 | const taskId = generateTaskId('remote_agent'); |
| 416 | |
| 417 | // Create the output file before registering the task. |
| 418 | // RemoteAgentTask uses appendTaskOutput() (not TaskOutput), so |
| 419 | // the file must exist for readers before any output arrives. |
| 420 | void initTaskOutput(taskId); |
| 421 | const taskState: RemoteAgentTaskState = { |
| 422 | ...createTaskStateBase(taskId, 'remote_agent', session.title, toolUseId), |
| 423 | type: 'remote_agent', |
| 424 | remoteTaskType, |
| 425 | status: 'running', |
| 426 | sessionId: session.id, |
| 427 | command, |
| 428 | title: session.title, |
| 429 | todoList: [], |
| 430 | log: [], |
| 431 | isRemoteReview, |
| 432 | isUltraplan, |
| 433 | isLongRunning, |
| 434 | pollStartedAt: Date.now(), |
| 435 | remoteTaskMetadata |
| 436 | }; |
| 437 | registerTask(taskState, context.setAppState); |
| 438 | |
| 439 | // Persist identity to the session sidecar so --resume can reconnect to |
| 440 | // still-running remote sessions. Status is not stored — it's fetched |
| 441 | // fresh from CCR on restore. |
| 442 | void persistRemoteAgentMetadata({ |
| 443 | taskId, |
no test coverage detected