// jobs/myJobs.ts
client.defineJob({
  id: "my-job",
  ...
});

// someFile.ts
...
const runs = await client.getRuns("my-job");
if (runs.length === 0) {
  throw new Error("No runs found");
}

const runDetail = await client.getRun(runs[0].id);
console.log(runDetail.tasks.length);
...

These are the docs for Trigger.dev v2 which will be deprecated on January 31st, 2025. You probably want the v3 docs.

Parameters

runId
string
required

The Run ID you want to get the details for

options
Object

Returns

id
string | undefined

The id of the run

status
RunStatus | undefined

The status of the run. Can be one of the following: PENDING, CANCELED, SUCCESS, QUEUED, WAITING_ON_CONNECTIONS, PREPROCESSING, STARTED, FAILURE, TIMED_OUT, ABORTED

startedAt
Date | undefined

The time the run started

completedAt
Date | undefined

The time the run completed

output
any

Whatever you returned from your run function, can be undefined

tasks
Task[]

The tasks from the run

nextCursor
string

If there are more tasks, you can use this to get them

// jobs/myJobs.ts
client.defineJob({
  id: "my-job",
  ...
});

// someFile.ts
...
const runs = await client.getRuns("my-job");
if (runs.length === 0) {
  throw new Error("No runs found");
}

const runDetail = await client.getRun(runs[0].id);
console.log(runDetail.tasks.length);
...