()
| 99 | } |
| 100 | |
| 101 | async startGoal() { |
| 102 | const { isGuestMode, isValidGuest } = this.guestSettings; |
| 103 | if (isGuestMode && !isValidGuest && !this.modelSettings.customApiKey) { |
| 104 | this.sendErrorMessage( |
| 105 | `${i18n?.t("errors.invalid-guest-key", { ns: "chat" })}` |
| 106 | ); |
| 107 | this.stopAgent(); |
| 108 | return; |
| 109 | } |
| 110 | this.sendGoalMessage(); |
| 111 | this.sendThinkingMessage(); |
| 112 | |
| 113 | // Initialize by getting taskValues |
| 114 | try { |
| 115 | const taskValues = await this.getInitialTasks(); |
| 116 | for (const value of taskValues) { |
| 117 | await new Promise((r) => setTimeout(r, TIMOUT_SHORT)); |
| 118 | const task: Task = { |
| 119 | taskId: v1().toString(), |
| 120 | value, |
| 121 | status: TASK_STATUS_STARTED, |
| 122 | type: MESSAGE_TYPE_TASK, |
| 123 | }; |
| 124 | this.sendMessage(task); |
| 125 | } |
| 126 | } catch (e) { |
| 127 | console.log(e); |
| 128 | this.sendErrorMessage(getMessageFromError(e)); |
| 129 | this.shutdown(); |
| 130 | return; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | async loop() { |
| 135 | this.conditionalPause(); |
no test coverage detected