mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-06 08:57:23 +00:00
Refactor agent loop (#4412)
This commit is contained in:
@@ -7,7 +7,7 @@ import { Log } from "../util/log"
|
||||
import { splitWhen } from "remeda"
|
||||
import { Storage } from "../storage/storage"
|
||||
import { Bus } from "../bus"
|
||||
import { SessionLock } from "./lock"
|
||||
import { SessionPrompt } from "./prompt"
|
||||
|
||||
export namespace SessionRevert {
|
||||
const log = Log.create({ service: "session.revert" })
|
||||
@@ -20,11 +20,7 @@ export namespace SessionRevert {
|
||||
export type RevertInput = z.infer<typeof RevertInput>
|
||||
|
||||
export async function revert(input: RevertInput) {
|
||||
SessionLock.assertUnlocked(input.sessionID)
|
||||
using _ = SessionLock.acquire({
|
||||
sessionID: input.sessionID,
|
||||
})
|
||||
|
||||
SessionPrompt.assertNotBusy(input.sessionID)
|
||||
const all = await Session.messages({ sessionID: input.sessionID })
|
||||
let lastUser: MessageV2.User | undefined
|
||||
const session = await Session.get(input.sessionID)
|
||||
@@ -70,10 +66,7 @@ export namespace SessionRevert {
|
||||
|
||||
export async function unrevert(input: { sessionID: string }) {
|
||||
log.info("unreverting", input)
|
||||
SessionLock.assertUnlocked(input.sessionID)
|
||||
using _ = SessionLock.acquire({
|
||||
sessionID: input.sessionID,
|
||||
})
|
||||
SessionPrompt.assertNotBusy(input.sessionID)
|
||||
const session = await Session.get(input.sessionID)
|
||||
if (!session.revert) return session
|
||||
if (session.revert.snapshot) await Snapshot.restore(session.revert.snapshot)
|
||||
|
||||
Reference in New Issue
Block a user