feat(core): attach global native tools (#30832)
This commit is contained in:
parent
17ba5539e7
commit
64dc6d39ab
39 changed files with 647 additions and 71 deletions
|
|
@ -9,10 +9,13 @@ import { SessionV2 } from "../session"
|
|||
import * as SessionExecutionLocal from "../session/execution/local"
|
||||
import { SessionProjector } from "../session/projector"
|
||||
import { SessionStore } from "../session/store"
|
||||
import { ApplicationTools } from "../tool/application-tools"
|
||||
import { Session } from "./session"
|
||||
import { Tool } from "./tool"
|
||||
|
||||
export interface Interface {
|
||||
readonly sessions: Session.Interface
|
||||
readonly tools: Tool.Service
|
||||
}
|
||||
|
||||
/** Intentional public native API for Effect applications embedding OpenCode. */
|
||||
|
|
@ -28,13 +31,16 @@ const SessionsLayer = SessionV2.layer.pipe(
|
|||
Layer.provide(ProjectV2.defaultLayer),
|
||||
Layer.orDie,
|
||||
)
|
||||
const ApplicationToolsLayer = ApplicationTools.layer
|
||||
|
||||
// TODO: Accept explicit storage so tests and embeddings can select disposable or application-owned persistence.
|
||||
export const layer = Layer.effect(
|
||||
Service,
|
||||
Effect.gen(function* () {
|
||||
const sessions = yield* SessionV2.Service
|
||||
const tools = yield* ApplicationTools.Service
|
||||
return Service.of({
|
||||
tools: { attach: tools.attach },
|
||||
sessions: {
|
||||
create: (input) =>
|
||||
sessions.create({
|
||||
|
|
@ -65,6 +71,6 @@ export const layer = Layer.effect(
|
|||
},
|
||||
})
|
||||
}),
|
||||
).pipe(Layer.provide(SessionsLayer))
|
||||
).pipe(Layer.provide(Layer.merge(ApplicationToolsLayer, SessionsLayer)))
|
||||
|
||||
// TODO: Add OpenCode.create(...) as the Promise facade over the same native API semantics.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue