mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-24 05:35:15 +00:00
feat(task): gate background tasks experimentally
This commit is contained in:
parent
a84edc224f
commit
227b8c668b
3 changed files with 11 additions and 1 deletions
|
|
@ -222,7 +222,7 @@ export const layer: Layer.Layer<
|
|||
tool.edit,
|
||||
tool.write,
|
||||
tool.task,
|
||||
tool.taskstatus,
|
||||
...(Flag.OPENCODE_EXPERIMENTAL ? [tool.taskstatus] : []),
|
||||
tool.fetch,
|
||||
tool.todo,
|
||||
tool.search,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { TuiEvent } from "@/cli/cmd/tui/event"
|
|||
import { Cause, Effect, Option, Schema } from "effect"
|
||||
import { Config } from "@/config/config"
|
||||
import { BackgroundJob } from "@/background/job"
|
||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||
|
||||
export interface TaskPromptOps {
|
||||
cancel(sessionID: SessionID): void
|
||||
|
|
@ -159,6 +160,9 @@ export const TaskTool = Tool.define(
|
|||
providerID: msg.info.providerID,
|
||||
}
|
||||
const background = params.background === true
|
||||
if (background && !Flag.OPENCODE_EXPERIMENTAL) {
|
||||
return yield* Effect.fail(new Error("Background tasks require OPENCODE_EXPERIMENTAL=true"))
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
sessionId: nextSession.id,
|
||||
|
|
|
|||
|
|
@ -15,10 +15,14 @@ import { TaskTool, type TaskPromptOps } from "../../src/tool/task"
|
|||
import { Truncate } from "@/tool/truncate"
|
||||
import { ToolRegistry } from "@/tool/registry"
|
||||
import { BackgroundJob } from "@/background/job"
|
||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||
import { provideTmpdirInstance } from "../fixture/fixture"
|
||||
import { testEffect } from "../lib/effect"
|
||||
|
||||
const originalExperimental = Flag.OPENCODE_EXPERIMENTAL
|
||||
|
||||
afterEach(async () => {
|
||||
Flag.OPENCODE_EXPERIMENTAL = originalExperimental
|
||||
await Instance.disposeAll()
|
||||
})
|
||||
|
||||
|
|
@ -442,6 +446,7 @@ describe("tool.task", () => {
|
|||
it.live("execute launches background tasks without waiting for completion", () =>
|
||||
provideTmpdirInstance(() =>
|
||||
Effect.gen(function* () {
|
||||
Flag.OPENCODE_EXPERIMENTAL = true
|
||||
const sessions = yield* Session.Service
|
||||
const jobs = yield* BackgroundJob.Service
|
||||
const { chat, assistant } = yield* seed()
|
||||
|
|
@ -485,6 +490,7 @@ describe("tool.task", () => {
|
|||
it.live("background tasks inject completion into the parent session and resume when idle", () =>
|
||||
provideTmpdirInstance(() =>
|
||||
Effect.gen(function* () {
|
||||
Flag.OPENCODE_EXPERIMENTAL = true
|
||||
const sessions = yield* Session.Service
|
||||
const jobs = yield* BackgroundJob.Service
|
||||
const { chat, assistant } = yield* seed()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue