refactor(core): consolidate tool architecture

This commit is contained in:
Dax Raad 2026-07-26 20:08:55 -04:00
commit 8db7487c89
466 changed files with 9405 additions and 11071 deletions

View file

@ -1,2 +1,3 @@
export { Failure, RegistrationError, make } from "@opencode-ai/plugin/v2/effect/tool"
export type { Any, Content, Context, Tool } from "@opencode-ai/plugin/v2/effect/tool"
export { RegistrationError } from "@opencode-ai/core/tool"
export { Error } from "@opencode-ai/schema/tool"
export type { Context, Info } from "@opencode-ai/schema/tool"

View file

@ -1,9 +1,5 @@
import { expect, test } from "bun:test"
import { AgentV2 } from "@opencode-ai/core/agent"
import { Location as CoreLocation } from "@opencode-ai/core/location"
import { ModelV2 } from "@opencode-ai/core/model"
import { ProjectV2 } from "@opencode-ai/core/project"
import { SessionV2 } from "@opencode-ai/core/session"
import { SessionPending as CoreSessionPending } from "@opencode-ai/core/session/pending"
import { SessionMessage as CoreSessionMessage } from "@opencode-ai/core/session/message"
import { Agent } from "@opencode-ai/schema/agent"
@ -21,6 +17,10 @@ import { ClientApi, groupNames, promiseOmitEndpoints } from "@opencode-ai/protoc
import { compile, emitPromise } from "@opencode-ai/httpapi-codegen"
const SDK = await import("../src/index")
const CoreAgent = await import("@opencode-ai/core/agent")
const CoreModel = await import("@opencode-ai/core/model")
const CoreProject = await import("@opencode-ai/core/project")
const CoreSession = await import("@opencode-ai/core/session")
test("re-exports canonical contracts directly from Schema", () => {
expect(SDK.Agent).toBe(Agent)
@ -59,13 +59,13 @@ test("re-exports canonical contracts directly from Schema", () => {
})
test("Core and Server reuse the authoritative Schema and Protocol values", () => {
expect(AgentV2.ID).toBe(Agent.ID)
expect(CoreAgent.ID).toBe(Agent.ID)
expect(CoreLocation.Ref).toBe(Location.Ref)
expect(ModelV2.Ref).toBe(Model.Ref)
expect(SessionV2.Info).toBe(Session.Info)
expect(ProjectV2.Current).toBe(Project.Current)
expect(ProjectV2.Directory).toBe(Project.Directory)
expect(ProjectV2.Directories).toBe(Project.Directories)
expect(CoreModel.Ref).toBe(Model.Ref)
expect(CoreSession.Info).toBe(Session.Info)
expect(CoreProject.Current).toBe(Project.Current)
expect(CoreProject.Directory).toBe(Project.Directory)
expect(CoreProject.Directories).toBe(Project.Directories)
expect(CoreSessionPending.Message).toBe(SessionPending.Message)
expect(CoreSessionPending.User).toBe(SessionPending.User)
expect(CoreSessionPending.Synthetic).toBe(SessionPending.Synthetic)

View file

@ -72,8 +72,8 @@ it.live(
yield* ctx.tool
.transform((draft) =>
draft.add(
"bootstrap_sdk_tool",
fixture.sdk.Tool.make({
({
name: "bootstrap_sdk_tool",
description: "Marks the initial Location plugin generation",
input: Schema.Struct({}),
output: Schema.Void,
@ -99,8 +99,8 @@ it.live(
yield* ctx.tool
.transform((draft) =>
draft.add(
"late_sdk_tool",
fixture.sdk.Tool.make({
({
name: "late_sdk_tool",
description: "Tool registered after Location boot",
input: Schema.Struct({}),
output: Schema.Void,
@ -220,8 +220,8 @@ it.live(
ctx.tool
.transform((draft) =>
draft.add(
"embedded_tool",
fixture.sdk.Tool.make({
({
name: "embedded_tool",
description: "Embedded test tool",
input: Schema.Struct({}),
output: Schema.Struct({ ok: Schema.Boolean }),