({ threadId, objective = null, status = null })
| 397 | } |
| 398 | |
| 399 | async setThreadGoal({ threadId, objective = null, status = null }) { |
| 400 | if (!this.threads.has(threadId)) { |
| 401 | throw new Error(`thread not found: ${threadId}`); |
| 402 | } |
| 403 | const current = this.threadGoals.get(threadId) ?? null; |
| 404 | const nextObjective = typeof objective === 'string' && objective.trim() |
| 405 | ? objective.trim() |
| 406 | : current?.objective ?? ''; |
| 407 | if (!nextObjective) { |
| 408 | throw new Error('missing goal objective'); |
| 409 | } |
| 410 | const next = { |
| 411 | threadId, |
| 412 | objective: nextObjective, |
| 413 | status: typeof status === 'string' && status.trim() ? status.trim() : 'active', |
| 414 | tokenBudget: null, |
| 415 | tokensUsed: 0, |
| 416 | timeUsedSeconds: 0, |
| 417 | createdAt: current?.createdAt ?? new Date(this.nextUpdatedAt()).toISOString(), |
| 418 | updatedAt: new Date(this.nextUpdatedAt()).toISOString(), |
| 419 | }; |
| 420 | this.threadGoals.set(threadId, next); |
| 421 | return { ...next }; |
| 422 | } |
| 423 | |
| 424 | async clearThreadGoal({ threadId }) { |
| 425 | this.threadGoals.delete(threadId); |
nothing calls this directly
no test coverage detected