feat!: redo Panel; decouple Panel from Agent

BREAKING CHANGES: Agent and Panel API Changes
This commit is contained in:
Simon
2026-01-17 23:14:26 +08:00
parent 8abe3afed9
commit 1ede1d9911
13 changed files with 565 additions and 466 deletions

View File

@@ -56,9 +56,9 @@ export class LLM extends EventTarget {
// retry settings
{
maxRetries: this.config.maxRetries,
onRetry: (current: number) => {
onRetry: (attempt: number) => {
this.dispatchEvent(
new CustomEvent('retry', { detail: { current, max: this.config.maxRetries } })
new CustomEvent('retry', { detail: { attempt, maxAttempts: this.config.maxRetries } })
)
},
onError: (error: Error) => {
@@ -73,15 +73,15 @@ async function withRetry<T>(
fn: () => Promise<T>,
settings: {
maxRetries: number
onRetry: (retries: number) => void
onRetry: (attempt: number) => void
onError: (error: Error) => void
}
): Promise<T> {
let retries = 0
let attempt = 0
let lastError: Error | null = null
while (retries <= settings.maxRetries) {
if (retries > 0) {
settings.onRetry(retries)
while (attempt <= settings.maxRetries) {
if (attempt > 0) {
settings.onRetry(attempt)
await new Promise((resolve) => setTimeout(resolve, 100))
}
@@ -98,7 +98,7 @@ async function withRetry<T>(
if (error instanceof InvokeError && !error.retryable) throw error
lastError = error as Error
retries++
attempt++
await new Promise((resolve) => setTimeout(resolve, 100))
}