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
|
|
@ -1,6 +1,6 @@
|
|||
import { describe, expect } from "bun:test"
|
||||
import { Effect } from "effect"
|
||||
import { OpenCode, Session } from "@opencode-ai/core/public"
|
||||
import { Effect, Schema } from "effect"
|
||||
import { OpenCode, Session, Tool } from "@opencode-ai/core/public"
|
||||
import { testEffect } from "./lib/effect"
|
||||
|
||||
const it = testEffect(OpenCode.layer)
|
||||
|
|
@ -10,6 +10,8 @@ describe("public native OpenCode API", () => {
|
|||
Effect.gen(function* () {
|
||||
const opencode = yield* OpenCode.Service
|
||||
|
||||
expect(Object.keys(opencode).sort()).toEqual(["sessions", "tools"])
|
||||
|
||||
expect(Object.keys(opencode.sessions).sort()).toEqual([
|
||||
"context",
|
||||
"create",
|
||||
|
|
@ -23,6 +25,14 @@ describe("public native OpenCode API", () => {
|
|||
expect(Session.ID.create()).toStartWith("ses_")
|
||||
expect(Session.MessageID.create()).toStartWith("msg_")
|
||||
expect(yield* opencode.sessions.list()).toBeArray()
|
||||
yield* opencode.tools.attach({
|
||||
public_tool: Tool.make({
|
||||
description: "Public tool",
|
||||
parameters: Schema.Struct({}),
|
||||
success: Schema.Struct({ ok: Schema.Boolean }),
|
||||
execute: () => Effect.succeed({ ok: true }),
|
||||
}),
|
||||
})
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue