-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathAgentTask.ts
More file actions
40 lines (38 loc) · 1.1 KB
/
Copy pathAgentTask.ts
File metadata and controls
40 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type { AgentTaskJSON } from './JSON';
/**
* Represents a agent token resource.
*
* Agent tokens are used for testing purposes and allow creating sessions
* for users without requiring full authentication flows.
*/
export class AgentTask {
constructor(
/**
* A stable identifier for the agent, unique per agent_name within an instance.
*/
readonly agentId: string,
/**
* A unique identifier for this agent task.
* @deprecated Use agentTaskId instead.
*/
readonly taskId: string,
/**
* A unique identifier for this agent task.
*/
readonly agentTaskId: string,
/**
* The FAPI URL that, when visited, creates a session for the user.
*/
readonly url: string,
) {}
/**
* Creates a AgentTask instance from a JSON object.
*
* @param data - The JSON object containing agent task data
* @returns A new AgentTask instance
*/
static fromJSON(data: AgentTaskJSON): AgentTask {
const agentTaskId = data.agent_task_id ?? data.task_id ?? '';
return new AgentTask(data.agent_id, agentTaskId, agentTaskId, data.url);
}
}