{"version":3,"file":"agent/execution-session.mjs","sources":["../../../src/agent/execution-session.ts"],"sourcesContent":["import { type TaskExecutionError, TaskRunner } from '@/task-runner';\nimport type {\n  ExecutionTaskApply,\n  ExecutionTaskProgressOptions,\n  UIContext,\n} from '@/types';\n\ntype ExecutionSessionOptions = ExecutionTaskProgressOptions & {\n  tasks?: ExecutionTaskApply[];\n  onTaskUpdate?: (\n    runner: TaskRunner,\n    error?: TaskExecutionError,\n  ) => Promise<void> | void;\n};\n\n/**\n * Thin wrapper around {@link TaskRunner} that represents a single linear execution run.\n */\nexport class ExecutionSession {\n  private readonly runner: TaskRunner;\n\n  constructor(\n    name: string,\n    contextProvider: () => Promise<UIContext>,\n    options?: ExecutionSessionOptions,\n  ) {\n    this.runner = new TaskRunner(name, contextProvider, options);\n  }\n\n  async append(\n    tasks: ExecutionTaskApply[] | ExecutionTaskApply,\n    options?: { allowWhenError?: boolean },\n  ) {\n    await this.runner.append(tasks, options);\n  }\n\n  async appendAndRun(\n    tasks: ExecutionTaskApply[] | ExecutionTaskApply,\n    options?: { allowWhenError?: boolean },\n  ) {\n    return this.runner.appendAndFlush(tasks, options);\n  }\n\n  async run(options?: { allowWhenError?: boolean }) {\n    return this.runner.flush(options);\n  }\n\n  isInErrorState() {\n    return this.runner.isInErrorState();\n  }\n\n  latestErrorTask() {\n    return this.runner.latestErrorTask();\n  }\n\n  appendErrorPlan(errorMsg: string) {\n    return this.runner.appendErrorPlan(errorMsg);\n  }\n\n  getRunner() {\n    return this.runner;\n  }\n}\n"],"names":["ExecutionSession","tasks","options","errorMsg","name","contextProvider","TaskRunner"],"mappings":";;;;;;;;;;;AAkBO,MAAMA;IAWX,MAAM,OACJC,KAAgD,EAChDC,OAAsC,EACtC;QACA,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAACD,OAAOC;IAClC;IAEA,MAAM,aACJD,KAAgD,EAChDC,OAAsC,EACtC;QACA,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAACD,OAAOC;IAC3C;IAEA,MAAM,IAAIA,OAAsC,EAAE;QAChD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAACA;IAC3B;IAEA,iBAAiB;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc;IACnC;IAEA,kBAAkB;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe;IACpC;IAEA,gBAAgBC,QAAgB,EAAE;QAChC,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAACA;IACrC;IAEA,YAAY;QACV,OAAO,IAAI,CAAC,MAAM;IACpB;IAxCA,YACEC,IAAY,EACZC,eAAyC,EACzCH,OAAiC,CACjC;QANF,uBAAiB,UAAjB;QAOE,IAAI,CAAC,MAAM,GAAG,IAAII,WAAWF,MAAMC,iBAAiBH;IACtD;AAmCF"}