Merge branch 'refactor/effectify-snapshot' into refactor/effectify-truncate
This commit is contained in:
commit
c3e10ab25b
2 changed files with 43 additions and 33 deletions
|
|
@ -11,46 +11,52 @@ const seed = async () => {
|
||||||
const { Instance } = await import("../src/project/instance")
|
const { Instance } = await import("../src/project/instance")
|
||||||
const { InstanceBootstrap } = await import("../src/project/bootstrap")
|
const { InstanceBootstrap } = await import("../src/project/bootstrap")
|
||||||
const { Config } = await import("../src/config/config")
|
const { Config } = await import("../src/config/config")
|
||||||
|
const { disposeRuntime } = await import("../src/effect/runtime")
|
||||||
const { Session } = await import("../src/session")
|
const { Session } = await import("../src/session")
|
||||||
const { MessageID, PartID } = await import("../src/session/schema")
|
const { MessageID, PartID } = await import("../src/session/schema")
|
||||||
const { Project } = await import("../src/project/project")
|
const { Project } = await import("../src/project/project")
|
||||||
const { ModelID, ProviderID } = await import("../src/provider/schema")
|
const { ModelID, ProviderID } = await import("../src/provider/schema")
|
||||||
const { ToolRegistry } = await import("../src/tool/registry")
|
const { ToolRegistry } = await import("../src/tool/registry")
|
||||||
|
|
||||||
await Instance.provide({
|
try {
|
||||||
directory: dir,
|
await Instance.provide({
|
||||||
init: InstanceBootstrap,
|
directory: dir,
|
||||||
fn: async () => {
|
init: InstanceBootstrap,
|
||||||
await Config.waitForDependencies()
|
fn: async () => {
|
||||||
await ToolRegistry.ids()
|
await Config.waitForDependencies()
|
||||||
|
await ToolRegistry.ids()
|
||||||
|
|
||||||
const session = await Session.create({ title })
|
const session = await Session.create({ title })
|
||||||
const messageID = MessageID.ascending()
|
const messageID = MessageID.ascending()
|
||||||
const partID = PartID.ascending()
|
const partID = PartID.ascending()
|
||||||
const message = {
|
const message = {
|
||||||
id: messageID,
|
id: messageID,
|
||||||
sessionID: session.id,
|
sessionID: session.id,
|
||||||
role: "user" as const,
|
role: "user" as const,
|
||||||
time: { created: now },
|
time: { created: now },
|
||||||
agent: "build",
|
agent: "build",
|
||||||
model: {
|
model: {
|
||||||
providerID: ProviderID.make(providerID),
|
providerID: ProviderID.make(providerID),
|
||||||
modelID: ModelID.make(modelID),
|
modelID: ModelID.make(modelID),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const part = {
|
const part = {
|
||||||
id: partID,
|
id: partID,
|
||||||
sessionID: session.id,
|
sessionID: session.id,
|
||||||
messageID,
|
messageID,
|
||||||
type: "text" as const,
|
type: "text" as const,
|
||||||
text,
|
text,
|
||||||
time: { start: now },
|
time: { start: now },
|
||||||
}
|
}
|
||||||
await Session.updateMessage(message)
|
await Session.updateMessage(message)
|
||||||
await Session.updatePart(part)
|
await Session.updatePart(part)
|
||||||
await Project.update({ projectID: Instance.project.id, name: "E2E Project" })
|
await Project.update({ projectID: Instance.project.id, name: "E2E Project" })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
} finally {
|
||||||
|
await Instance.disposeAll().catch(() => {})
|
||||||
|
await disposeRuntime().catch(() => {})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await seed()
|
await seed()
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,7 @@ export const runtime = ManagedRuntime.make(
|
||||||
export function runPromiseInstance<A, E>(effect: Effect.Effect<A, E, InstanceServices>) {
|
export function runPromiseInstance<A, E>(effect: Effect.Effect<A, E, InstanceServices>) {
|
||||||
return runtime.runPromise(effect.pipe(Effect.provide(Instances.get(Instance.directory))))
|
return runtime.runPromise(effect.pipe(Effect.provide(Instances.get(Instance.directory))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function disposeRuntime() {
|
||||||
|
return runtime.dispose()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue