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

@ -36,7 +36,7 @@
"@opencode-ai/protocol": "workspace:*"
},
"peerDependencies": {
"effect": "4.0.0-beta.98"
"effect": "4.0.0-beta.101"
},
"peerDependenciesMeta": {
"effect": {

View file

@ -6,11 +6,86 @@ import {
groupNames,
promiseOmitEndpoints,
} from "@opencode-ai/protocol/client"
import { Effect } from "effect"
import { Agent } from "@opencode-ai/schema/agent"
import { Command } from "@opencode-ai/schema/command"
import { Credential } from "@opencode-ai/schema/credential"
import { Event } from "@opencode-ai/schema/event"
import { EventLog } from "@opencode-ai/schema/event-log"
import { FileDiff } from "@opencode-ai/schema/file-diff"
import { FileSystem } from "@opencode-ai/schema/filesystem"
import { Form } from "@opencode-ai/schema/form"
import { InstructionEntry } from "@opencode-ai/schema/instruction-entry"
import { Integration } from "@opencode-ai/schema/integration"
import { Location } from "@opencode-ai/schema/location"
import { Mcp } from "@opencode-ai/schema/mcp"
import { Model } from "@opencode-ai/schema/model"
import { Permission } from "@opencode-ai/schema/permission"
import { PermissionSaved } from "@opencode-ai/schema/permission-saved"
import { Plugin } from "@opencode-ai/schema/plugin"
import { Project } from "@opencode-ai/schema/project"
import { ProjectCopy } from "@opencode-ai/schema/project-copy"
import { AgentAttachment, FileAttachment, Prompt, PromptMention } from "@opencode-ai/schema/prompt"
import { PromptInput } from "@opencode-ai/schema/prompt-input"
import { Provider } from "@opencode-ai/schema/provider"
import { Pty } from "@opencode-ai/schema/pty"
import { PtyTicket } from "@opencode-ai/schema/pty-ticket"
import { Question } from "@opencode-ai/schema/question"
import { Reference } from "@opencode-ai/schema/reference"
import { AbsolutePath, PositiveInt, RelativePath } from "@opencode-ai/schema/schema"
import { Session } from "@opencode-ai/schema/session"
import { SessionMessage } from "@opencode-ai/schema/session-message"
import { SessionPending } from "@opencode-ai/schema/session-pending"
import { Shell } from "@opencode-ai/schema/shell"
import { Skill } from "@opencode-ai/schema/skill"
import { Vcs } from "@opencode-ai/schema/vcs"
import { WebSearch } from "@opencode-ai/schema/websearch"
import { Workspace } from "@opencode-ai/schema/workspace"
import { Effect, Schema } from "effect"
import { fileURLToPath } from "url"
const promiseContract = compile(ClientApi, { groupNames, omitEndpoints: promiseOmitEndpoints })
const effectContract = compile(ClientApi, { groupNames, omitEndpoints: effectOmitEndpoints })
const effectTypeReferences = [
...namespaceTypes("Agent", "@opencode-ai/schema/agent", Agent),
...namespaceTypes("Command", "@opencode-ai/schema/command", Command),
...namespaceTypes("Credential", "@opencode-ai/schema/credential", Credential),
...namespaceTypes("Event", "@opencode-ai/schema/event", Event),
...namespaceTypes("EventLog", "@opencode-ai/schema/event-log", EventLog),
...namespaceTypes("FileDiff", "@opencode-ai/schema/file-diff", FileDiff),
...namespaceTypes("FileSystem", "@opencode-ai/schema/filesystem", FileSystem),
...namespaceTypes("Form", "@opencode-ai/schema/form", Form),
...namespaceTypes("InstructionEntry", "@opencode-ai/schema/instruction-entry", InstructionEntry),
...namespaceTypes("Integration", "@opencode-ai/schema/integration", Integration),
...namespaceTypes("Location", "@opencode-ai/schema/location", Location),
...namespaceTypes("Mcp", "@opencode-ai/schema/mcp", Mcp),
...namespaceTypes("Model", "@opencode-ai/schema/model", Model),
...namespaceTypes("Permission", "@opencode-ai/schema/permission", Permission),
...namespaceTypes("PermissionSaved", "@opencode-ai/schema/permission-saved", PermissionSaved),
...namespaceTypes("Plugin", "@opencode-ai/schema/plugin", Plugin),
...namespaceTypes("Project", "@opencode-ai/schema/project", Project),
...namespaceTypes("ProjectCopy", "@opencode-ai/schema/project-copy", ProjectCopy),
...namespaceTypes("PromptInput", "@opencode-ai/schema/prompt-input", PromptInput),
...namespaceTypes("Provider", "@opencode-ai/schema/provider", Provider),
...namespaceTypes("Pty", "@opencode-ai/schema/pty", Pty),
...namespaceTypes("PtyTicket", "@opencode-ai/schema/pty-ticket", PtyTicket),
...namespaceTypes("Question", "@opencode-ai/schema/question", Question),
...namespaceTypes("Reference", "@opencode-ai/schema/reference", Reference),
...namespaceTypes("Session", "@opencode-ai/schema/session", Session),
...namespaceTypes("SessionMessage", "@opencode-ai/schema/session-message", SessionMessage),
...namespaceTypes("SessionPending", "@opencode-ai/schema/session-pending", SessionPending),
...namespaceTypes("Shell", "@opencode-ai/schema/shell", Shell),
...namespaceTypes("Skill", "@opencode-ai/schema/skill", Skill),
...namespaceTypes("Vcs", "@opencode-ai/schema/vcs", Vcs),
...namespaceTypes("WebSearch", "@opencode-ai/schema/websearch", WebSearch),
...namespaceTypes("Workspace", "@opencode-ai/schema/workspace", Workspace),
typeReference("Prompt", "@opencode-ai/schema/prompt", Prompt),
typeReference("PromptMention", "@opencode-ai/schema/prompt", PromptMention),
typeReference("FileAttachment", "@opencode-ai/schema/prompt", FileAttachment),
typeReference("AgentAttachment", "@opencode-ai/schema/prompt", AgentAttachment),
typeReference("AbsolutePath", "@opencode-ai/schema/schema", AbsolutePath),
typeReference("PositiveInt", "@opencode-ai/schema/schema", PositiveInt),
typeReference("RelativePath", "@opencode-ai/schema/schema", RelativePath),
]
await Effect.runPromise(
Effect.all(
@ -22,14 +97,40 @@ await Effect.runPromise(
fileURLToPath(new URL("../src/promise/generated", import.meta.url)),
),
write(
emitEffectImported(effectContract, { module: "../../contract", api: "ClientApi" }),
emitEffectImported(effectContract, {
module: "../../contract",
api: "ClientApi",
shapeModule: "../api/api.js",
}),
fileURLToPath(new URL("../src/effect/generated", import.meta.url)),
),
write(
emitEffectShape(effectContract, { module: "../../contract", api: "ClientApi" }),
emitEffectShape(effectContract, {
typeReferences: effectTypeReferences,
outputTypes: {
"event.subscribe": {
name: "OpenCodeEvent",
import: 'import type { OpenCodeEvent } from "@opencode-ai/protocol/groups/event"',
},
},
}),
fileURLToPath(new URL("../src/effect/api", import.meta.url)),
),
],
{ concurrency: 3, discard: true },
).pipe(Effect.provide(NodeFileSystem.layer)),
)
function namespaceTypes(namespace: string, module: string, values: object) {
return Object.entries(values).flatMap(([name, schema]) =>
Schema.isSchema(schema) ? [typeReference(`${namespace}.${name}`, module, schema)] : [],
)
}
function typeReference(name: string, module: string, schema: Schema.Top) {
return {
schema,
name,
import: `import type { ${name.split(".")[0]} } from ${JSON.stringify(module)}`,
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,8 @@ import type {
LocationGetOutput,
AgentListInput,
AgentListOutput,
AgentGetInput,
AgentGetOutput,
PluginListInput,
PluginListOutput,
SessionListInput,
@ -403,6 +405,18 @@ export function make(options: ClientOptions) {
},
requestOptions,
),
get: (input: AgentGetInput, requestOptions?: RequestOptions) =>
request<AgentGetOutput>(
{
method: "GET",
path: `/api/agent/${encodeURIComponent(input.agentID)}`,
query: { location: input["location"] },
successStatus: 200,
declaredStatuses: [404, 401, 400],
empty: false,
},
requestOptions,
),
},
plugin: {
list: (input?: PluginListInput, requestOptions?: RequestOptions) =>

View file

@ -6,11 +6,11 @@ export type ServiceStopResponse = { accepted: boolean }
export type ModelRef = { id: string; providerID: string; variant?: string }
export type ProviderSettings = { [x: string]: JsonValue }
export type ProviderSettings = { [x: string]: any }
export type AgentColor = string
export type PermissionV2Effect = "allow" | "deny" | "ask"
export type PermissionEffect = "allow" | "deny" | "ask"
export type PluginInfo = { id: string }
@ -175,24 +175,24 @@ export type ModelCapabilities = { tools: boolean; input: Array<string>; output:
export type ModelVariant = {
id: string
settings?: { [x: string]: JsonValue }
settings?: { [x: string]: any }
headers?: { [x: string]: string }
body?: { [x: string]: JsonValue }
body?: { [x: string]: any }
}
export type MoneyUSDPerMillionTokens = number
export type GenerateTextResponse = { data: { text: string } }
export type ProviderV2Info = {
export type ProviderInfo = {
id: string
integrationID?: string
name: string
disabled?: boolean
package: string
settings?: { [x: string]: JsonValue }
settings?: { [x: string]: any }
headers?: { [x: string]: string }
body?: { [x: string]: JsonValue }
body?: { [x: string]: any }
}
export type IntegrationWhen = { key: string; op: "eq" | "neq"; value: string }
@ -299,7 +299,7 @@ export type FormExternalField = { key: string; type: "external"; url: string; ti
export type FormValue = string | number | boolean | Array<string>
export type PermissionV2Source = { type: "tool"; messageID: string; callID: string }
export type PermissionSource = { type: "tool"; messageID: string; callID: string }
export type PermissionSavedInfo = { id: string; projectID: string; action: string; resource: string }
@ -323,9 +323,9 @@ export type FileDiffLegacyInfo = {
status?: "added" | "deleted" | "modified"
}
export type PermissionAction = "allow" | "deny" | "ask"
export type PermissionV1Action = "allow" | "deny" | "ask"
export type JSONSchema = { [x: string]: any }
export type SessionV1JSONSchema = { [x: string]: any }
export type ProviderAuthError = { name: "ProviderAuthError"; data: { providerID: string; message: string } }
@ -356,7 +356,7 @@ export type APIError = {
}
}
export type TextPart = {
export type SessionV1TextPart = {
id: string
sessionID: string
messageID: string
@ -368,7 +368,7 @@ export type TextPart = {
metadata?: { [x: string]: any } | undefined
}
export type SubtaskPart = {
export type SessionV1SubtaskPart = {
id: string
sessionID: string
messageID: string
@ -380,7 +380,7 @@ export type SubtaskPart = {
command?: string | undefined
}
export type ReasoningPart = {
export type SessionV1ReasoningPart = {
id: string
sessionID: string
messageID: string
@ -390,13 +390,13 @@ export type ReasoningPart = {
time: { start: number; end?: number | undefined }
}
export type FilePartSourceText = { value: string; start: number; end: number }
export type SessionV1FilePartSourceText = { value: string; start: number; end: number }
export type Range = { start: { line: number; character: number }; end: { line: number; character: number } }
export type SessionV1Range = { start: { line: number; character: number }; end: { line: number; character: number } }
export type ToolStatePending = { status: "pending"; input: { [x: string]: any }; raw: string }
export type SessionV1ToolStatePending = { status: "pending"; input: { [x: string]: any }; raw: string }
export type ToolStateRunning = {
export type SessionV1ToolStateRunning = {
status: "running"
input: { [x: string]: any }
title?: string | undefined
@ -404,7 +404,7 @@ export type ToolStateRunning = {
time: { start: number }
}
export type ToolStateError = {
export type SessionV1ToolStateError = {
status: "error"
input: { [x: string]: any }
error: string
@ -412,7 +412,7 @@ export type ToolStateError = {
time: { start: number; end: number }
}
export type StepStartPart = {
export type SessionV1StepStartPart = {
id: string
sessionID: string
messageID: string
@ -420,7 +420,7 @@ export type StepStartPart = {
snapshot?: string | undefined
}
export type StepFinishPart = {
export type SessionV1StepFinishPart = {
id: string
sessionID: string
messageID: string
@ -437,9 +437,15 @@ export type StepFinishPart = {
}
}
export type SnapshotPart = { id: string; sessionID: string; messageID: string; type: "snapshot"; snapshot: string }
export type SessionV1SnapshotPart = {
id: string
sessionID: string
messageID: string
type: "snapshot"
snapshot: string
}
export type PatchPart = {
export type SessionV1PatchPart = {
id: string
sessionID: string
messageID: string
@ -448,7 +454,7 @@ export type PatchPart = {
files: Array<string>
}
export type AgentPart = {
export type SessionV1AgentPart = {
id: string
sessionID: string
messageID: string
@ -457,7 +463,7 @@ export type AgentPart = {
source?: { value: string; start: number; end: number } | undefined
}
export type CompactionPart = {
export type SessionV1CompactionPart = {
id: string
sessionID: string
messageID: string
@ -467,7 +473,7 @@ export type CompactionPart = {
tail_start_id?: string | undefined
}
export type PermissionV2Reply = "once" | "always" | "reject"
export type PermissionReply = "once" | "always" | "reject"
export type Pty = {
id: string
@ -480,11 +486,11 @@ export type Pty = {
exitCode?: number
}
export type QuestionV2Option = { label: string; description: string }
export type QuestionOption = { label: string; description: string }
export type QuestionV2Tool = { messageID: string; callID: string }
export type QuestionTool = { messageID: string; callID: string }
export type QuestionV2Answer = Array<string>
export type QuestionAnswer = Array<string>
export type FormMetadata1 = { [x: string]: any }
@ -501,12 +507,6 @@ export type SessionStatus =
}
| { type: "busy" }
export type QuestionOption = { label: string; description: string }
export type QuestionTool = { messageID: string; callID: string }
export type QuestionAnswer = Array<string>
export type ShellInfo1 = {
id: string
status: "running" | "exited" | "timeout" | "killed"
@ -564,10 +564,10 @@ export type CommandInfo = {
export type ProviderRequest = {
settings: ProviderSettings
headers: { [x: string]: string }
body: { [x: string]: JsonValue }
body: { [x: string]: any }
}
export type PermissionV2Rule = { action: string; resource: string; effect: PermissionV2Effect }
export type PermissionRule = { action: string; resource: string; effect: PermissionEffect }
export type SessionAgentSelected = {
id: string
@ -1044,11 +1044,11 @@ export type ShellDeleted = {
data: { id: string }
}
export type QuestionV2Rejected = {
export type QuestionRejected = {
id: string
created: number
metadata?: { [x: string]: any }
type: "question.v2.rejected"
type: "question.rejected"
location?: LocationRef
data: { sessionID: string; requestID: string }
}
@ -1186,41 +1186,6 @@ export type McpResourcesChanged = {
data: { server: string }
}
export type PermissionAsked = {
id: string
created: number
metadata?: { [x: string]: any }
type: "permission.asked"
location?: LocationRef
data: {
id: string
sessionID: string
permission: string
patterns: Array<string>
metadata: { [x: string]: any }
always: Array<string>
tool?: { messageID: string; callID: string } | undefined
}
}
export type PermissionReplied = {
id: string
created: number
metadata?: { [x: string]: any }
type: "permission.replied"
location?: LocationRef
data: { sessionID: string; requestID: string; reply: "once" | "always" | "reject" }
}
export type QuestionRejected = {
id: string
created: number
metadata?: { [x: string]: any }
type: "question.rejected"
location?: LocationRef
data: { sessionID: string; requestID: string }
}
export type V2EventServerConnected = {
id: string
metadata?: { [x: string]: any } | undefined
@ -1544,21 +1509,21 @@ export type FormMultiselectField = {
export type FormAnswer = { [x: string]: FormValue }
export type PermissionV2Request = {
export type PermissionRequest = {
id: string
sessionID: string
action: string
resources: Array<string>
save?: Array<string>
metadata?: { [x: string]: JsonValue }
source?: PermissionV2Source
source?: PermissionSource
}
export type PermissionV2Asked = {
export type PermissionAsked = {
id: string
created: number
metadata?: { [x: string]: any }
type: "permission.v2.asked"
type: "permission.asked"
location?: LocationRef
data: {
id: string
@ -1567,17 +1532,17 @@ export type PermissionV2Asked = {
resources: Array<string>
save?: Array<string>
metadata?: { [x: string]: any }
source?: PermissionV2Source
source?: PermissionSource
}
}
export type PermissionRule = { permission: string; pattern: string; action: PermissionAction }
export type PermissionV1Rule = { permission: string; pattern: string; action: PermissionV1Action }
export type OutputFormat =
export type SessionV1OutputFormat =
| { type: "text" }
| { type: "json_schema"; schema: JSONSchema; retryCount?: number | undefined | undefined }
| { type: "json_schema"; schema: SessionV1JSONSchema; retryCount?: number | undefined | undefined }
export type AssistantMessage = {
export type SessionV1AssistantMessage = {
id: string
sessionID: string
role: "assistant"
@ -1612,7 +1577,7 @@ export type AssistantMessage = {
finish?: string | undefined
}
export type RetryPart = {
export type SessionV1RetryPart = {
id: string
sessionID: string
messageID: string
@ -1643,26 +1608,31 @@ export type SessionError = {
}
}
export type FileSource = { text: FilePartSourceText; type: "file"; path: string }
export type SessionV1FileSource = { text: SessionV1FilePartSourceText; type: "file"; path: string }
export type ResourceSource = { text: FilePartSourceText; type: "resource"; clientName: string; uri: string }
export type SessionV1ResourceSource = {
text: SessionV1FilePartSourceText
type: "resource"
clientName: string
uri: string
}
export type SymbolSource = {
text: FilePartSourceText
export type SessionV1SymbolSource = {
text: SessionV1FilePartSourceText
type: "symbol"
path: string
range: Range
range: SessionV1Range
name: string
kind: number
}
export type PermissionV2Replied = {
export type PermissionReplied = {
id: string
created: number
metadata?: { [x: string]: any }
type: "permission.v2.replied"
type: "permission.replied"
location?: LocationRef
data: { sessionID: string; requestID: string; reply: PermissionV2Reply }
data: { sessionID: string; requestID: string; reply: PermissionReply }
}
export type PtyCreated = {
@ -1683,21 +1653,21 @@ export type PtyUpdated = {
data: { info: Pty }
}
export type QuestionV2Info = {
export type QuestionInfo = {
question: string
header: string
options: Array<QuestionV2Option>
options: Array<QuestionOption>
multiple?: boolean
custom?: boolean
}
export type QuestionV2Replied = {
export type QuestionReplied = {
id: string
created: number
metadata?: { [x: string]: any }
type: "question.v2.replied"
type: "question.replied"
location?: LocationRef
data: { sessionID: string; requestID: string; answers: Array<QuestionV2Answer> }
data: { sessionID: string; requestID: string; answers: Array<QuestionAnswer> }
}
export type FormStringField1 = {
@ -1774,26 +1744,9 @@ export type SessionStatus2 = {
data: { sessionID: string; status: SessionStatus }
}
export type QuestionInfo = {
question: string
header: string
options: Array<QuestionOption>
multiple?: boolean | undefined
custom?: boolean | undefined
}
export type QuestionReplied = {
id: string
created: number
metadata?: { [x: string]: any }
type: "question.replied"
location?: LocationRef
data: { sessionID: string; requestID: string; answers: Array<QuestionAnswer> }
}
export type ReferenceSource = ReferenceLocalSource | ReferenceGitSource
export type PermissionV2Ruleset = Array<PermissionV2Rule>
export type PermissionRuleset = Array<PermissionRule>
export type SessionInfo = {
id: string
@ -1910,9 +1863,9 @@ export type ModelInfo = {
name: string
compatibility?: ModelCompatibility
package?: string
settings?: { [x: string]: JsonValue }
settings?: { [x: string]: any }
headers?: { [x: string]: string }
body?: { [x: string]: JsonValue }
body?: { [x: string]: any }
capabilities: ModelCapabilities
variants: Array<ModelVariant>
time: { released: number }
@ -1948,14 +1901,14 @@ export type FormReplied = {
data: { id: string; sessionID: string; answer: FormAnswer }
}
export type PermissionRuleset = Array<PermissionRule>
export type PermissionV1Ruleset = Array<PermissionV1Rule>
export type UserMessage = {
export type SessionV1UserMessage = {
id: string
sessionID: string
role: "user"
time: { created: number }
format?: OutputFormat | undefined
format?: SessionV1OutputFormat | undefined
summary?: { title?: string | undefined; body?: string | undefined; diffs: Array<FileDiffLegacyInfo> } | undefined
agent: string
model: { providerID: string; modelID: string; variant?: string | undefined }
@ -1963,23 +1916,18 @@ export type UserMessage = {
tools?: { [x: string]: boolean } | undefined
}
export type FilePartSource = FileSource | SymbolSource | ResourceSource
export type SessionV1FilePartSource = SessionV1FileSource | SessionV1SymbolSource | SessionV1ResourceSource
export type QuestionV2Asked = {
export type QuestionAsked = {
id: string
created: number
metadata?: { [x: string]: any }
type: "question.v2.asked"
type: "question.asked"
location?: LocationRef
data: { id: string; sessionID: string; questions: Array<QuestionV2Info>; tool?: QuestionV2Tool }
data: { id: string; sessionID: string; questions: Array<QuestionInfo>; tool?: QuestionTool }
}
export type QuestionV2Request = {
id: string
sessionID: string
questions: Array<QuestionV2Info>
tool?: QuestionV2Tool
}
export type QuestionRequest = { id: string; sessionID: string; questions: Array<QuestionInfo>; tool?: QuestionTool }
export type FormField1 =
| FormStringField1
@ -1989,15 +1937,6 @@ export type FormField1 =
| FormMultiselectField1
| FormExternalField
export type QuestionAsked = {
id: string
created: number
metadata?: { [x: string]: any }
type: "question.asked"
location?: LocationRef
data: { id: string; sessionID: string; questions: Array<QuestionInfo>; tool?: QuestionTool | undefined }
}
export type ReferenceInfo = {
name: string
path: string
@ -2017,7 +1956,7 @@ export type AgentInfo = {
hidden: boolean
color?: AgentColor
steps?: number
permissions: PermissionV2Ruleset
permissions: PermissionRuleset
}
export type SessionsResponse = { data: Array<SessionInfo>; cursor: { previous?: string | null; next?: string | null } }
@ -2075,13 +2014,13 @@ export type SessionV1Info = {
version: string
metadata?: { [x: string]: any }
time: { created: number; updated: number; compacting?: number; archived?: number }
permission?: PermissionRuleset
permission?: PermissionV1Ruleset
revert?: { messageID: string; partID?: string; snapshot?: string; diff?: string }
}
export type Message = UserMessage | AssistantMessage
export type SessionV1Message = SessionV1UserMessage | SessionV1AssistantMessage
export type FilePart = {
export type SessionV1FilePart = {
id: string
sessionID: string
messageID: string
@ -2089,7 +2028,7 @@ export type FilePart = {
mime: string
filename?: string | undefined
url: string
source?: FilePartSource | undefined
source?: SessionV1FilePartSource | undefined
}
export type FormFields1 = [FormField1, ...Array<FormField1>]
@ -2160,17 +2099,17 @@ export type MessageUpdated = {
type: "message.updated"
durable: { aggregateID: string; seq: number; version: 1 }
location?: LocationRef
data: { sessionID: string; info: Message }
data: { sessionID: string; info: SessionV1Message }
}
export type ToolStateCompleted = {
export type SessionV1ToolStateCompleted = {
status: "completed"
input: { [x: string]: any }
output: string
title: string
metadata: { [x: string]: any }
time: { start: number; end: number; compacted?: number | undefined }
attachments?: Array<FilePart> | undefined
attachments?: Array<SessionV1FilePart> | undefined
}
export type FormInfo1 = { id: string; sessionID: string; title: string; metadata?: FormMetadata1; fields: FormFields1 }
@ -2196,7 +2135,11 @@ export type SessionMessageInfo =
| SessionMessageAssistant
| SessionMessageCompaction
export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError
export type SessionV1ToolState =
| SessionV1ToolStatePending
| SessionV1ToolStateRunning
| SessionV1ToolStateCompleted
| SessionV1ToolStateError
export type FormCreated = {
id: string
@ -2252,32 +2195,32 @@ export type SessionMessagesResponse = {
cursor: { previous?: string | null; next?: string | null }
}
export type ToolPart = {
export type SessionV1ToolPart = {
id: string
sessionID: string
messageID: string
type: "tool"
callID: string
tool: string
state: ToolState
state: SessionV1ToolState
metadata?: { [x: string]: any } | undefined
}
export type SessionLogItem = SessionEventDurable | EventLogSynced
export type Part =
| TextPart
| SubtaskPart
| ReasoningPart
| FilePart
| ToolPart
| StepStartPart
| StepFinishPart
| SnapshotPart
| PatchPart
| AgentPart
| RetryPart
| CompactionPart
export type SessionV1Part =
| SessionV1TextPart
| SessionV1SubtaskPart
| SessionV1ReasoningPart
| SessionV1FilePart
| SessionV1ToolPart
| SessionV1StepStartPart
| SessionV1StepFinishPart
| SessionV1SnapshotPart
| SessionV1PatchPart
| SessionV1AgentPart
| SessionV1RetryPart
| SessionV1CompactionPart
export type MessagePartUpdated = {
id: string
@ -2286,7 +2229,7 @@ export type MessagePartUpdated = {
type: "message.part.updated"
durable: { aggregateID: string; seq: number; version: 1 }
location?: LocationRef
data: { sessionID: string; part: Part; time: number }
data: { sessionID: string; part: SessionV1Part; time: number }
}
export type V2Event =
@ -2347,8 +2290,8 @@ export type V2Event =
| SessionRevertCommitted
| FilesystemChanged
| ReferenceUpdated
| PermissionV2Asked
| PermissionV2Replied
| PermissionAsked
| PermissionReplied
| PluginAdded
| PluginUpdated
| ProjectDirectoriesUpdated
@ -2362,9 +2305,9 @@ export type V2Event =
| ShellCreated
| ShellExited
| ShellDeleted
| QuestionV2Asked
| QuestionV2Replied
| QuestionV2Rejected
| QuestionAsked
| QuestionReplied
| QuestionRejected
| FormCreated
| FormReplied
| FormCancelled
@ -2380,11 +2323,6 @@ export type V2Event =
| VcsBranchUpdated
| McpStatusChanged
| McpResourcesChanged
| PermissionAsked
| PermissionReplied
| QuestionAsked
| QuestionReplied
| QuestionRejected
| SessionError
| V2EventServerConnected
@ -2401,6 +2339,14 @@ export type InvalidRequestError = {
export const isInvalidRequestError = (value: unknown): value is InvalidRequestError =>
typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "InvalidRequestError"
export type AgentNotFoundError = {
readonly _tag: "AgentNotFoundError"
readonly agentID: string
readonly message: string
}
export const isAgentNotFoundError = (value: unknown): value is AgentNotFoundError =>
typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "AgentNotFoundError"
export type InvalidCursorError = { readonly _tag: "InvalidCursorError"; readonly message: string }
export const isInvalidCursorError = (value: unknown): value is InvalidCursorError =>
typeof value === "object" && value !== null && "_tag" in value && value["_tag"] === "InvalidCursorError"
@ -2584,6 +2530,18 @@ export type AgentListOutput = {
data: Array<AgentInfo>
}
export type AgentGetInput = {
readonly agentID: { readonly agentID: string }["agentID"]
readonly location?: {
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
}["location"]
}
export type AgentGetOutput = {
location: { directory: string; workspaceID?: string; project: { id: string; directory: string } }
data: AgentInfo
}
export type PluginListInput = {
readonly location?: {
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
@ -3312,7 +3270,7 @@ export type ProviderListInput = {
export type ProviderListOutput = {
location: { directory: string; workspaceID?: string; project: { id: string; directory: string } }
data: Array<ProviderV2Info>
data: Array<ProviderInfo>
}
export type ProviderGetInput = {
@ -3324,7 +3282,7 @@ export type ProviderGetInput = {
export type ProviderGetOutput = {
location: { directory: string; workspaceID?: string; project: { id: string; directory: string } }
data: ProviderV2Info
data: ProviderInfo
}
export type IntegrationListInput = {
@ -4476,7 +4434,7 @@ export type PermissionRequestListInput = {
export type PermissionRequestListOutput = {
location: { directory: string; workspaceID?: string; project: { id: string; directory: string } }
data: Array<PermissionV2Request>
data: Array<PermissionRequest>
}
export type PermissionSavedListInput = { readonly projectID?: { readonly projectID?: string | undefined }["projectID"] }
@ -4554,18 +4512,18 @@ export type PermissionCreateInput = {
}["agent"]
}
export type PermissionCreateOutput = { data: { id: string; effect: PermissionV2Effect } }["data"]
export type PermissionCreateOutput = { data: { id: string; effect: PermissionEffect } }["data"]
export type PermissionListInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
export type PermissionListOutput = { data: Array<PermissionV2Request> }["data"]
export type PermissionListOutput = { data: Array<PermissionRequest> }["data"]
export type PermissionGetInput = {
readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]
readonly requestID: { readonly sessionID: string; readonly requestID: string }["requestID"]
}
export type PermissionGetOutput = { data: PermissionV2Request }["data"]
export type PermissionGetOutput = { data: PermissionRequest }["data"]
export type PermissionReplyInput = {
readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]
@ -4864,12 +4822,12 @@ export type QuestionRequestListInput = {
export type QuestionRequestListOutput = {
location: { directory: string; workspaceID?: string; project: { id: string; directory: string } }
data: Array<QuestionV2Request>
data: Array<QuestionRequest>
}
export type QuestionListInput = { readonly sessionID: { readonly sessionID: string }["sessionID"] }
export type QuestionListOutput = { data: Array<QuestionV2Request> }["data"]
export type QuestionListOutput = { data: Array<QuestionRequest> }["data"]
export type QuestionReplyInput = {
readonly sessionID: { readonly sessionID: string; readonly requestID: string }["sessionID"]

View file

@ -1,5 +1,6 @@
import { Effect } from "effect"
import { OpenCode as EffectOpenCode, type AppApi as EffectApi } from "../src/effect"
import type { Session } from "@opencode-ai/schema/session"
type EffectClient = Effect.Success<ReturnType<typeof EffectOpenCode.make>>
type PromiseClient = ReturnType<typeof import("../src/promise").OpenCode.make>
@ -9,6 +10,10 @@ declare const promiseClient: PromiseClient
const effectApi: EffectApi<unknown> = effectClient
const effectSession: Effect.Effect<Session.Info, unknown> = effectClient.session.get({
sessionID: "ses_test" as Session.ID,
})
declare const sessionID: Parameters<typeof effectApi.session.instructions.entry.list>[0]["sessionID"]
const effectList: Effect.Effect<
@ -37,4 +42,4 @@ const promiseRemove: Promise<void> = promiseClient.session.instructions.entry.re
key: "review-notes",
})
void [effectList, effectPut, effectRemove, promiseList, promisePut, promiseRemove]
void [effectSession, effectList, effectPut, effectRemove, promiseList, promisePut, promiseRemove]

View file

@ -14,6 +14,14 @@ test("effect entrypoint exposes canonical Schema contracts", () => {
expect(Client.Session).toBe(Session)
})
test("generated Effect API names canonical and composed outputs", async () => {
const source = await Bun.file(new URL("../src/effect/api/api.ts", import.meta.url)).text()
expect(source).toContain("export type Endpoint5_3Output = Session.Info")
expect(source).toContain("export type Endpoint19_0Output = OpenCodeEvent")
expect(source).not.toContain("HttpApiClient.ForApi")
})
test("shared DTO schemas construct and decode plain objects", () => {
const made = Prompt.make({ text: "hello" })
const decoded = Schema.decodeUnknownSync(Prompt)({ text: "hello" })