chore: prepare GoodBuddy 0.8.2
Cross-platform packages / Validate source (push) Waiting to run
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, macos, macos-15-intel) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / Publish GitHub Release (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
Cross-platform packages / Validate source (push) Waiting to run
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, macos, macos-15-intel) (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
Cross-platform packages / Publish GitHub Release (push) Blocked by required conditions
Cross-platform packages / ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
This commit is contained in:
@@ -45,24 +45,53 @@ export class SubagentService {
|
||||
constructor(
|
||||
private runtime: AgentRuntime,
|
||||
private readonly database: AssistantDatabase,
|
||||
private readonly scheduler = new SubagentScheduler()
|
||||
private readonly scheduler = new SubagentScheduler(),
|
||||
private profileRuntimes: ReadonlyMap<string, AgentRuntime> =
|
||||
new Map()
|
||||
) {}
|
||||
|
||||
async replaceRuntime(runtime: AgentRuntime): Promise<void> {
|
||||
if (runtime === this.runtime) {
|
||||
await this.replaceRuntimes(runtime, new Map())
|
||||
}
|
||||
|
||||
async replaceRuntimes(
|
||||
runtime: AgentRuntime,
|
||||
profileRuntimes: ReadonlyMap<string, AgentRuntime>
|
||||
): Promise<void> {
|
||||
const nextProfiles = new Map(profileRuntimes)
|
||||
if (
|
||||
runtime === this.runtime &&
|
||||
nextProfiles.size === this.profileRuntimes.size &&
|
||||
[...nextProfiles].every(
|
||||
([profileId, profileRuntime]) =>
|
||||
this.profileRuntimes.get(profileId) === profileRuntime
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
this.scheduler.cancelAll(new Error('默认模型设置已更改'))
|
||||
const previous = this.runtime
|
||||
const previous = new Set([
|
||||
this.runtime,
|
||||
...this.profileRuntimes.values()
|
||||
])
|
||||
this.runtime = runtime
|
||||
this.profileRuntimes = nextProfiles
|
||||
await this.scheduler.waitForIdle()
|
||||
await previous.dispose()
|
||||
const retained = new Set([runtime, ...nextProfiles.values()])
|
||||
await Promise.allSettled(
|
||||
[...previous]
|
||||
.filter((candidate) => !retained.has(candidate))
|
||||
.map((candidate) => candidate.dispose())
|
||||
)
|
||||
}
|
||||
|
||||
async dispose(): Promise<void> {
|
||||
this.scheduler.dispose()
|
||||
await this.scheduler.waitForIdle()
|
||||
await this.runtime.dispose()
|
||||
await Promise.allSettled(
|
||||
[...new Set([this.runtime, ...this.profileRuntimes.values()])]
|
||||
.map((runtime) => runtime.dispose())
|
||||
)
|
||||
}
|
||||
|
||||
cancelAll(reason: string): void {
|
||||
@@ -149,7 +178,10 @@ export class SubagentService {
|
||||
started = true
|
||||
this.database.updateTaskStatus(childTaskId, 'running')
|
||||
this.emit(input, { childTaskId, state: 'running' })
|
||||
const runtime = this.runtime
|
||||
const runtime =
|
||||
(input.expert.modelProfileId
|
||||
? this.profileRuntimes.get(input.expert.modelProfileId)
|
||||
: undefined) ?? this.runtime
|
||||
let output = ''
|
||||
let completed = false
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user