()
| 497 | } |
| 498 | |
| 499 | emitStatusUpdated(): void { |
| 500 | if (this.records.restoring) return; |
| 501 | if (!this.config.hasModel) return; |
| 502 | |
| 503 | const contextTokens = this.context.tokenCount; |
| 504 | const maxContextTokens = this.config.modelCapabilities.max_context_tokens; |
| 505 | const contextUsage = |
| 506 | maxContextTokens !== undefined && maxContextTokens > 0 |
| 507 | ? contextTokens / maxContextTokens |
| 508 | : undefined; |
| 509 | const usage: UsageStatus | undefined = this.usage.status(); |
| 510 | const model = this.config.model; |
| 511 | |
| 512 | this.emitEvent({ |
| 513 | type: 'agent.status.updated', |
| 514 | model, |
| 515 | contextTokens, |
| 516 | maxContextTokens, |
| 517 | contextUsage, |
| 518 | planMode: this.planMode.isActive, |
| 519 | swarmMode: this.swarmMode.isActive, |
| 520 | permission: this.permission.mode, |
| 521 | usage, |
| 522 | }); |
| 523 | } |
| 524 | |
| 525 | private emitRecordsWriteError(error: unknown, record?: AgentRecord | undefined): void { |
| 526 | const message = error instanceof Error ? error.message : String(error); |
no test coverage detected