feat(plugin): support plugin-provided tools (#34619)
This commit is contained in:
parent
a5c51e11d0
commit
194b0615e0
52 changed files with 1633 additions and 959 deletions
|
|
@ -1,57 +1,7 @@
|
|||
import { makeDefaultApi } from "@opencode-ai/protocol/api"
|
||||
import { InvalidRequestError, SessionNotFoundError } from "@opencode-ai/protocol/errors"
|
||||
import { HttpApiMiddleware } from "effect/unstable/httpapi"
|
||||
|
||||
class LocationMiddleware extends HttpApiMiddleware.Service<LocationMiddleware>()(
|
||||
"@opencode-ai/client/LocationMiddleware",
|
||||
) {}
|
||||
|
||||
class SessionLocationMiddleware extends HttpApiMiddleware.Service<SessionLocationMiddleware>()(
|
||||
"@opencode-ai/client/SessionLocationMiddleware",
|
||||
{ error: [InvalidRequestError, SessionNotFoundError] },
|
||||
) {}
|
||||
|
||||
export const ClientApi = makeDefaultApi({
|
||||
locationMiddleware: LocationMiddleware,
|
||||
sessionLocationMiddleware: SessionLocationMiddleware,
|
||||
})
|
||||
|
||||
export const groupNames = {
|
||||
"server.health": "health",
|
||||
"server.location": "location",
|
||||
"server.agent": "agent",
|
||||
"server.session": "session",
|
||||
"server.message": "message",
|
||||
"server.model": "model",
|
||||
"server.generate": "generate",
|
||||
"server.provider": "provider",
|
||||
"server.integration": "integration",
|
||||
"server.credential": "credential",
|
||||
"server.permission": "permission",
|
||||
"server.fs": "file",
|
||||
"server.command": "command",
|
||||
"server.skill": "skill",
|
||||
"server.event": "event",
|
||||
"server.pty": "pty",
|
||||
"server.shell": "shell",
|
||||
"server.question": "question",
|
||||
"server.reference": "reference",
|
||||
"server.project": "project",
|
||||
"server.projectCopy": "projectCopy",
|
||||
} as const
|
||||
|
||||
export const endpointNames = {
|
||||
"session.messages": "list",
|
||||
"integration.connect.key": "connectKey",
|
||||
"integration.connect.oauth": "connectOauth",
|
||||
"integration.attempt.status": "attemptStatus",
|
||||
"integration.attempt.complete": "attemptComplete",
|
||||
"integration.attempt.cancel": "attemptCancel",
|
||||
"permission.request.list": "listRequests",
|
||||
"permission.saved.list": "listSaved",
|
||||
"permission.saved.remove": "removeSaved",
|
||||
"question.request.list": "listRequests",
|
||||
} as const
|
||||
|
||||
export const promiseOmitEndpoints = new Set(["pty.connect", "pty.connectToken"])
|
||||
export const effectOmitEndpoints = new Set(["fs.read", "pty.connect", "pty.connectToken"])
|
||||
export {
|
||||
ClientApi,
|
||||
effectOmitEndpoints,
|
||||
endpointNames,
|
||||
groupNames,
|
||||
promiseOmitEndpoints,
|
||||
} from "@opencode-ai/protocol/client"
|
||||
|
|
|
|||
|
|
@ -254,9 +254,9 @@ const adaptGroup3 = (raw: RawClient["server.session"]) => ({
|
|||
skill: Endpoint3_9(raw),
|
||||
compact: Endpoint3_10(raw),
|
||||
wait: Endpoint3_11(raw),
|
||||
stage: Endpoint3_12(raw),
|
||||
clear: Endpoint3_13(raw),
|
||||
commit: Endpoint3_14(raw),
|
||||
revertStage: Endpoint3_12(raw),
|
||||
revertClear: Endpoint3_13(raw),
|
||||
revertCommit: Endpoint3_14(raw),
|
||||
context: Endpoint3_15(raw),
|
||||
history: Endpoint3_16(raw),
|
||||
events: Endpoint3_17(raw),
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ import type {
|
|||
SessionCompactOutput,
|
||||
SessionWaitInput,
|
||||
SessionWaitOutput,
|
||||
SessionStageInput,
|
||||
SessionStageOutput,
|
||||
SessionClearInput,
|
||||
SessionClearOutput,
|
||||
SessionCommitInput,
|
||||
SessionCommitOutput,
|
||||
SessionRevertStageInput,
|
||||
SessionRevertStageOutput,
|
||||
SessionRevertClearInput,
|
||||
SessionRevertClearOutput,
|
||||
SessionRevertCommitInput,
|
||||
SessionRevertCommitOutput,
|
||||
SessionContextInput,
|
||||
SessionContextOutput,
|
||||
SessionHistoryInput,
|
||||
|
|
@ -465,8 +465,8 @@ export function make(options: ClientOptions) {
|
|||
},
|
||||
requestOptions,
|
||||
),
|
||||
stage: (input: SessionStageInput, requestOptions?: RequestOptions) =>
|
||||
request<{ readonly data: SessionStageOutput }>(
|
||||
revertStage: (input: SessionRevertStageInput, requestOptions?: RequestOptions) =>
|
||||
request<{ readonly data: SessionRevertStageOutput }>(
|
||||
{
|
||||
method: "POST",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`,
|
||||
|
|
@ -477,8 +477,8 @@ export function make(options: ClientOptions) {
|
|||
},
|
||||
requestOptions,
|
||||
).then((value) => value.data),
|
||||
clear: (input: SessionClearInput, requestOptions?: RequestOptions) =>
|
||||
request<SessionClearOutput>(
|
||||
revertClear: (input: SessionRevertClearInput, requestOptions?: RequestOptions) =>
|
||||
request<SessionRevertClearOutput>(
|
||||
{
|
||||
method: "POST",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/clear`,
|
||||
|
|
@ -488,8 +488,8 @@ export function make(options: ClientOptions) {
|
|||
},
|
||||
requestOptions,
|
||||
),
|
||||
commit: (input: SessionCommitInput, requestOptions?: RequestOptions) =>
|
||||
request<SessionCommitOutput>(
|
||||
revertCommit: (input: SessionRevertCommitInput, requestOptions?: RequestOptions) =>
|
||||
request<SessionRevertCommitOutput>(
|
||||
{
|
||||
method: "POST",
|
||||
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/commit`,
|
||||
|
|
|
|||
|
|
@ -577,13 +577,13 @@ export type SessionWaitInput = { readonly sessionID: { readonly sessionID: strin
|
|||
|
||||
export type SessionWaitOutput = void
|
||||
|
||||
export type SessionStageInput = {
|
||||
export type SessionRevertStageInput = {
|
||||
readonly sessionID: { readonly sessionID: string }["sessionID"]
|
||||
readonly messageID: { readonly messageID: string; readonly files?: boolean | undefined }["messageID"]
|
||||
readonly files?: { readonly messageID: string; readonly files?: boolean | undefined }["files"]
|
||||
}
|
||||
|
||||
export type SessionStageOutput = {
|
||||
export type SessionRevertStageOutput = {
|
||||
readonly data: {
|
||||
readonly messageID: string
|
||||
readonly partID?: string
|
||||
|
|
@ -599,13 +599,13 @@ export type SessionStageOutput = {
|
|||
}
|
||||
}["data"]
|
||||
|
||||
export type SessionClearInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
|
||||
export type SessionRevertClearInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
|
||||
|
||||
export type SessionClearOutput = void
|
||||
export type SessionRevertClearOutput = void
|
||||
|
||||
export type SessionCommitInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
|
||||
export type SessionRevertCommitInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
|
||||
|
||||
export type SessionCommitOutput = void
|
||||
export type SessionRevertCommitOutput = void
|
||||
|
||||
export type SessionContextInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue