|
|
@@ -2,6 +2,7 @@ const dir = process.env.OPENCODE_E2E_PROJECT_DIR ?? process.cwd()
|
|
|
const title = process.env.OPENCODE_E2E_SESSION_TITLE ?? "E2E Session"
|
|
|
const text = process.env.OPENCODE_E2E_MESSAGE ?? "Seeded for UI e2e"
|
|
|
const model = process.env.OPENCODE_E2E_MODEL ?? "opencode/gpt-5-nano"
|
|
|
+const requirePaid = process.env.OPENCODE_E2E_REQUIRE_PAID === "true"
|
|
|
const parts = model.split("/")
|
|
|
const providerID = parts[0] ?? "opencode"
|
|
|
const modelID = parts[1] ?? "gpt-5-nano"
|
|
|
@@ -11,6 +12,7 @@ const seed = async () => {
|
|
|
const { Instance } = await import("../src/project/instance")
|
|
|
const { InstanceBootstrap } = await import("../src/project/bootstrap")
|
|
|
const { Config } = await import("../src/config/config")
|
|
|
+ const { Provider } = await import("../src/provider/provider")
|
|
|
const { Session } = await import("../src/session")
|
|
|
const { MessageID, PartID } = await import("../src/session/schema")
|
|
|
const { Project } = await import("../src/project/project")
|
|
|
@@ -25,6 +27,19 @@ const seed = async () => {
|
|
|
await Config.waitForDependencies()
|
|
|
await ToolRegistry.ids()
|
|
|
|
|
|
+ if (requirePaid && providerID === "opencode" && !process.env.OPENCODE_API_KEY) {
|
|
|
+ throw new Error("OPENCODE_API_KEY is required when OPENCODE_E2E_REQUIRE_PAID=true")
|
|
|
+ }
|
|
|
+
|
|
|
+ const info = await Provider.getModel(ProviderID.make(providerID), ModelID.make(modelID))
|
|
|
+ if (requirePaid) {
|
|
|
+ const paid =
|
|
|
+ info.cost.input > 0 || info.cost.output > 0 || info.cost.cache.read > 0 || info.cost.cache.write > 0
|
|
|
+ if (!paid) {
|
|
|
+ throw new Error(`OPENCODE_E2E_MODEL must resolve to a paid model: ${providerID}/${modelID}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const session = await Session.create({ title })
|
|
|
const messageID = MessageID.ascending()
|
|
|
const partID = PartID.ascending()
|