{"version":3,"file":"agent/event/types.mjs","sources":["webpack://@agent-infra/browser-use/./src/agent/event/types.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/nanobrowser/nanobrowser/blob/master/chrome-extension/src/background/agent/event/types.ts\n *\n * Apache-2.0 License\n * Copyright (c) 2024 alexchenzl\n * https://github.com/nanobrowser/nanobrowser/blob/master/LICENSE\n */\nimport { BrowserState, PageState } from '../../browser/types';\n\nexport enum Actors {\n  SYSTEM = 'system',\n  USER = 'user',\n  PLANNER = 'planner',\n  NAVIGATOR = 'navigator',\n  VALIDATOR = 'validator',\n}\n\nexport enum EventType {\n  /**\n   * Type of events that can be subscribed to.\n   *\n   * For now, only execution events are supported.\n   */\n  EXECUTION = 'execution',\n}\n\nexport enum ExecutionState {\n  /**\n   * States representing different phases in the execution lifecycle.\n   *\n   * Format: <SCOPE>.<STATUS>\n   * Scopes: task, step, act\n   * Statuses: start, ok, fail, cancel\n   *\n   * Examples:\n   *     TASK_OK = \"task.ok\"  // Task completed successfully\n   *     STEP_FAIL = \"step.fail\"  // Step failed\n   *     ACT_START = \"act.start\"  // Action started\n   */\n  // Task level states\n  TASK_START = 'task.start',\n  TASK_OK = 'task.ok',\n  TASK_FAIL = 'task.fail',\n  TASK_PAUSE = 'task.pause',\n  TASK_RESUME = 'task.resume',\n  TASK_CANCEL = 'task.cancel',\n\n  // Step level states\n  STEP_START = 'step.start',\n  STEP_OK = 'step.ok',\n  STEP_FAIL = 'step.fail',\n  STEP_CANCEL = 'step.cancel',\n\n  // Action/Tool level states\n  ACT_START = 'act.start',\n  ACT_OK = 'act.ok',\n  ACT_FAIL = 'act.fail',\n}\n\nexport interface EventData {\n  /** Data associated with an event */\n  taskId: string;\n  /** step is the step number of the task where the event occurred */\n  step: number;\n  /** max_steps is the maximum number of steps in the task */\n  maxSteps: number;\n  /** details is the content of the event */\n  details: string;\n  /** browserState is the browser state of the task where the event occurred */\n  browserState?: BrowserState;\n}\n\nexport class AgentEvent {\n  /**\n   * Represents a state change event in the task execution system.\n   * Each event has a type, a specific state that changed,\n   * the actor that triggered the change, and associated data.\n   */\n  constructor(\n    public actor: Actors,\n    public state: ExecutionState,\n    public data: EventData,\n    public timestamp: number = Date.now(),\n    public type: EventType = EventType.EXECUTION,\n  ) {}\n}\n\n// The type of callback for event subscribers\nexport type EventCallback = (event: AgentEvent) => Promise<void>;\n"],"names":["Actors","EventType","ExecutionState","AgentEvent","actor","state","data","timestamp","Date","type"],"mappings":";;;;AAOC;;;;;;;;;;AAGM,IAAKA,eAAMA,WAAAA,GAAAA,SAANA,MAAM;;;;;;WAANA;;AAQL,IAAKC,kBAASA,WAAAA,GAAAA,SAATA,SAAS;IAKlB;WALSA;;AASL,IAAKC,uBAAcA,WAAAA,GAAAA,SAAdA,cAAc;;;;;;;;;;;;;;WAAdA;;AA8CL,MAAMC;IAMX,YACSC,KAAa,EACbC,KAAqB,EACrBC,IAAe,EACfC,YAAoBC,KAAK,GAAG,EAAE,EAC9BC,OAAAA,WAAqC,CAC5C;;;;;;aALOL,KAAK,GAALA;aACAC,KAAK,GAALA;aACAC,IAAI,GAAJA;aACAC,SAAS,GAATA;aACAE,IAAI,GAAJA;IACN;AACL"}