2026-06-09 19:31:31 +00:00
|
|
|
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
2026-06-30 03:53:35 +00:00
|
|
|
import { Service, make } from "@opencode-ai/core/job"
|
2026-05-12 09:52:38 +00:00
|
|
|
import { InstanceState } from "@/effect/instance-state"
|
2026-06-04 03:02:17 +00:00
|
|
|
import { Effect, Layer } from "effect"
|
2026-05-12 09:52:38 +00:00
|
|
|
|
2026-06-04 03:02:17 +00:00
|
|
|
export {
|
2026-05-12 09:52:38 +00:00
|
|
|
Service,
|
2026-06-30 03:53:35 +00:00
|
|
|
type BackgroundAllInput,
|
|
|
|
|
type BlockInput,
|
|
|
|
|
type BlockResult,
|
2026-06-04 03:02:17 +00:00
|
|
|
type Info,
|
|
|
|
|
type Interface,
|
|
|
|
|
type StartInput,
|
|
|
|
|
type Status,
|
|
|
|
|
type WaitInput,
|
|
|
|
|
type WaitResult,
|
2026-06-30 03:53:35 +00:00
|
|
|
} from "@opencode-ai/core/job"
|
2026-06-04 03:02:17 +00:00
|
|
|
|
|
|
|
|
/** Keeps the legacy service instance-scoped while sharing the core registry engine. */
|
|
|
|
|
export const layer = Layer.effect(
|
2026-06-30 03:53:35 +00:00
|
|
|
Service,
|
2026-05-12 09:52:38 +00:00
|
|
|
Effect.gen(function* () {
|
2026-06-30 03:53:35 +00:00
|
|
|
const state = yield* InstanceState.make(() => make)
|
|
|
|
|
return Service.of({
|
2026-06-04 03:02:17 +00:00
|
|
|
list: () => InstanceState.useEffect(state, (jobs) => jobs.list()),
|
|
|
|
|
get: (id) => InstanceState.useEffect(state, (jobs) => jobs.get(id)),
|
|
|
|
|
start: (input) => InstanceState.useEffect(state, (jobs) => jobs.start(input)),
|
|
|
|
|
wait: (input) => InstanceState.useEffect(state, (jobs) => jobs.wait(input)),
|
2026-06-30 03:53:35 +00:00
|
|
|
block: (input) => InstanceState.useEffect(state, (jobs) => jobs.block(input)),
|
|
|
|
|
background: (id) => InstanceState.useEffect(state, (jobs) => jobs.background(id)),
|
|
|
|
|
backgroundAll: (input) => InstanceState.useEffect(state, (jobs) => jobs.backgroundAll(input)),
|
2026-06-04 03:02:17 +00:00
|
|
|
cancel: (id) => InstanceState.useEffect(state, (jobs) => jobs.cancel(id)),
|
2026-05-12 09:52:38 +00:00
|
|
|
})
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
2026-06-30 03:53:35 +00:00
|
|
|
export const node = LayerNode.make({ service: Service, layer, deps: [] })
|
2026-06-09 19:31:31 +00:00
|
|
|
|
2026-06-30 03:53:35 +00:00
|
|
|
export * as Job from "./job"
|