refactor(core): unify v2 tool architecture (#31168)
This commit is contained in:
parent
effd27b239
commit
660a00d317
46 changed files with 2297 additions and 2041 deletions
|
|
@ -3,7 +3,7 @@ export { Agent } from "./agent"
|
|||
export { Model } from "./model"
|
||||
export { OpenCode } from "./opencode"
|
||||
export { Session } from "./session"
|
||||
export { Tool } from "./tool"
|
||||
export * as Tool from "./tool"
|
||||
export { Location } from "./location"
|
||||
export { Prompt } from "../session/prompt"
|
||||
export { AbsolutePath } from "../schema"
|
||||
|
|
|
|||
|
|
@ -13,11 +13,10 @@ 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
|
||||
readonly tools: import("./tool").Service
|
||||
}
|
||||
|
||||
/** Intentional public native API for Effect applications embedding OpenCode. */
|
||||
|
|
@ -88,7 +87,7 @@ export const layer = Layer.effect(
|
|||
const tools = yield* ApplicationTools.Service
|
||||
const validation = yield* SessionModelValidation
|
||||
return Service.of({
|
||||
tools: { attach: tools.attach },
|
||||
tools: { register: tools.register },
|
||||
sessions: {
|
||||
create: (input) =>
|
||||
sessions.create({
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
export * as Tool from "./tool"
|
||||
|
||||
import { Effect, Scope } from "effect"
|
||||
import type { NativeTool } from "../tool/native"
|
||||
|
||||
export { Failure, make } from "../tool/native"
|
||||
export type { Any, Content, Context, Executable } from "../tool/native"
|
||||
export { Failure, RegistrationError, make } from "../tool/tool"
|
||||
export type { AnyTool, Content, Context, Tool } from "../tool/tool"
|
||||
|
||||
export interface Service {
|
||||
/**
|
||||
* Attach same-process tools to this OpenCode instance for the current Scope.
|
||||
* Register same-process tools on this OpenCode instance for the current Scope.
|
||||
* Location tools with the same name take precedence where they are installed.
|
||||
* Closing the Scope removes the tools immediately, so calls that have not
|
||||
* started settling may fail because the tool is no longer available.
|
||||
*/
|
||||
readonly attach: (tools: Readonly<Record<string, NativeTool.Any>>) => Effect.Effect<void, never, Scope.Scope>
|
||||
readonly register: (
|
||||
tools: Readonly<Record<string, import("../tool/tool").AnyTool>>,
|
||||
) => Effect.Effect<void, import("../tool/tool").RegistrationError, Scope.Scope>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue