MCPcopy Create free account
hub / github.com/WJX20/claude-code / registerRemoteAgentTask

Function registerRemoteAgentTask

src/tasks/RemoteAgentTask/RemoteAgentTask.tsx:393–473  ·  view source on GitHub ↗
(options: {
  remoteTaskType: RemoteTaskType;
  session: {
    id: string;
    title: string;
  };
  command: string;
  context: TaskContext;
  toolUseId?: string;
  isRemoteReview?: boolean;
  isUltraplan?: boolean;
  isLongRunning?: boolean;
  remoteTaskMetadata?: RemoteTaskMetadata;
})

Source from the content-addressed store, hash-verified

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

Callers 3

callFunction · 0.85
launchDetachedFunction · 0.85
launchRemoteReviewFunction · 0.85

Calls 6

generateTaskIdFunction · 0.85
initTaskOutputFunction · 0.85
createTaskStateBaseFunction · 0.85
registerTaskFunction · 0.85

Tested by

no test coverage detected