test fixes
This commit is contained in:
@@ -11,16 +11,7 @@ import "@opencode-ai/core/catalog"
|
|||||||
import "@opencode-ai/core/session-event"
|
import "@opencode-ai/core/session-event"
|
||||||
import { Context, Effect, Layer, Option } from "effect"
|
import { Context, Effect, Layer, Option } from "effect"
|
||||||
|
|
||||||
const syncDefinitions = new WeakMap<EventV2.Definition, SyncEvent.Definition>()
|
export function toSyncDefinition<D extends EventV2.Definition>(definition: D) {
|
||||||
|
|
||||||
export function toSyncDefinition<D extends EventV2.Definition>(
|
|
||||||
definition: D,
|
|
||||||
): SyncEvent.Definition<D["type"], D["data"], D["data"]> {
|
|
||||||
const cached = syncDefinitions.get(definition)
|
|
||||||
if (cached) return cached as SyncEvent.Definition<D["type"], D["data"], D["data"]>
|
|
||||||
if (definition.version === undefined)
|
|
||||||
throw new Error(`Event.toSyncDefinition: version required for ${definition.type}`)
|
|
||||||
if (!definition.aggregate) throw new Error(`Event.toSyncDefinition: aggregate required for ${definition.type}`)
|
|
||||||
const result = {
|
const result = {
|
||||||
type: definition.type,
|
type: definition.type,
|
||||||
version: definition.version,
|
version: definition.version,
|
||||||
@@ -28,8 +19,7 @@ export function toSyncDefinition<D extends EventV2.Definition>(
|
|||||||
schema: definition.data,
|
schema: definition.data,
|
||||||
properties: definition.data,
|
properties: definition.data,
|
||||||
}
|
}
|
||||||
syncDefinitions.set(definition, result)
|
return result as SyncEvent.Definition<D["type"], D["data"], D["data"]>
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Service extends Context.Service<Service, EventV2.Interface>()("@opencode/EventV2Bridge") {}
|
export class Service extends Context.Service<Service, EventV2.Interface>()("@opencode/EventV2Bridge") {}
|
||||||
|
|||||||
@@ -227,6 +227,16 @@ export function reset() {
|
|||||||
|
|
||||||
export function init(input: { projectors: Array<[Definition, ProjectorFunc]>; convertEvent?: ConvertEvent }) {
|
export function init(input: { projectors: Array<[Definition, ProjectorFunc]>; convertEvent?: ConvertEvent }) {
|
||||||
projectors = new Map(input.projectors)
|
projectors = new Map(input.projectors)
|
||||||
|
for (let entry of EventV2.registry.values()) {
|
||||||
|
if (!entry.version || !entry.aggregate) continue
|
||||||
|
register({
|
||||||
|
type: entry.type,
|
||||||
|
version: entry.version,
|
||||||
|
aggregate: entry.aggregate,
|
||||||
|
properties: entry.data,
|
||||||
|
schema: entry.data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Install all the latest event defs to the bus. We only ever emit
|
// Install all the latest event defs to the bus. We only ever emit
|
||||||
// latest versions from code, and keep around old versions for
|
// latest versions from code, and keep around old versions for
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ export type ClientOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type Event =
|
export type Event =
|
||||||
|
| EventTuiPromptAppend
|
||||||
|
| EventTuiCommandExecute
|
||||||
|
| EventTuiToastShow1
|
||||||
|
| EventTuiSessionSelect
|
||||||
|
| EventServerConnected
|
||||||
|
| EventGlobalDisposed
|
||||||
| EventServerInstanceDisposed
|
| EventServerInstanceDisposed
|
||||||
| EventFileEdited
|
| EventFileEdited
|
||||||
| EventFileWatcherUpdated
|
| EventFileWatcherUpdated
|
||||||
@@ -21,10 +27,6 @@ export type Event =
|
|||||||
| EventTodoUpdated
|
| EventTodoUpdated
|
||||||
| EventSessionStatus
|
| EventSessionStatus
|
||||||
| EventSessionIdle
|
| EventSessionIdle
|
||||||
| EventTuiPromptAppend
|
|
||||||
| EventTuiCommandExecute
|
|
||||||
| EventTuiToastShow1
|
|
||||||
| EventTuiSessionSelect
|
|
||||||
| EventMcpToolsChanged
|
| EventMcpToolsChanged
|
||||||
| EventMcpBrowserOpenFailed
|
| EventMcpBrowserOpenFailed
|
||||||
| EventCommandExecuted
|
| EventCommandExecuted
|
||||||
@@ -49,9 +51,6 @@ export type Event =
|
|||||||
| EventSessionCreated
|
| EventSessionCreated
|
||||||
| EventSessionUpdated
|
| EventSessionUpdated
|
||||||
| EventSessionDeleted
|
| EventSessionDeleted
|
||||||
| EventServerConnected
|
|
||||||
| EventGlobalDisposed
|
|
||||||
| EventCatalogModelUpdated
|
|
||||||
| EventSessionNextAgentSwitched
|
| EventSessionNextAgentSwitched
|
||||||
| EventSessionNextModelSwitched
|
| EventSessionNextModelSwitched
|
||||||
| EventSessionNextPrompted
|
| EventSessionNextPrompted
|
||||||
@@ -78,6 +77,7 @@ export type Event =
|
|||||||
| EventSessionNextCompactionStarted
|
| EventSessionNextCompactionStarted
|
||||||
| EventSessionNextCompactionDelta
|
| EventSessionNextCompactionDelta
|
||||||
| EventSessionNextCompactionEnded
|
| EventSessionNextCompactionEnded
|
||||||
|
| EventCatalogModelUpdated
|
||||||
|
|
||||||
export type OAuth = {
|
export type OAuth = {
|
||||||
type: "oauth"
|
type: "oauth"
|
||||||
@@ -104,6 +104,61 @@ export type WellKnownAuth = {
|
|||||||
|
|
||||||
export type Auth = OAuth | ApiAuth | WellKnownAuth
|
export type Auth = OAuth | ApiAuth | WellKnownAuth
|
||||||
|
|
||||||
|
export type EventTuiPromptAppend = {
|
||||||
|
id: string
|
||||||
|
type: "tui.prompt.append"
|
||||||
|
properties: {
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EventTuiCommandExecute = {
|
||||||
|
id: string
|
||||||
|
type: "tui.command.execute"
|
||||||
|
properties: {
|
||||||
|
command:
|
||||||
|
| "session.list"
|
||||||
|
| "session.new"
|
||||||
|
| "session.share"
|
||||||
|
| "session.interrupt"
|
||||||
|
| "session.compact"
|
||||||
|
| "session.page.up"
|
||||||
|
| "session.page.down"
|
||||||
|
| "session.line.up"
|
||||||
|
| "session.line.down"
|
||||||
|
| "session.half.page.up"
|
||||||
|
| "session.half.page.down"
|
||||||
|
| "session.first"
|
||||||
|
| "session.last"
|
||||||
|
| "prompt.clear"
|
||||||
|
| "prompt.submit"
|
||||||
|
| "agent.cycle"
|
||||||
|
| string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EventTuiToastShow = {
|
||||||
|
id: string
|
||||||
|
type: "tui.toast.show"
|
||||||
|
properties: {
|
||||||
|
title?: string
|
||||||
|
message: string
|
||||||
|
variant: "info" | "success" | "warning" | "error"
|
||||||
|
duration?: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EventTuiSessionSelect = {
|
||||||
|
id: string
|
||||||
|
type: "tui.session.select"
|
||||||
|
properties: {
|
||||||
|
/**
|
||||||
|
* Session ID to navigate to
|
||||||
|
*/
|
||||||
|
sessionID: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type PermissionRequest = {
|
export type PermissionRequest = {
|
||||||
id: string
|
id: string
|
||||||
sessionID: string
|
sessionID: string
|
||||||
@@ -281,61 +336,6 @@ export type SessionStatus =
|
|||||||
type: "busy"
|
type: "busy"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EventTuiPromptAppend = {
|
|
||||||
id: string
|
|
||||||
type: "tui.prompt.append"
|
|
||||||
properties: {
|
|
||||||
text: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventTuiCommandExecute = {
|
|
||||||
id: string
|
|
||||||
type: "tui.command.execute"
|
|
||||||
properties: {
|
|
||||||
command:
|
|
||||||
| "session.list"
|
|
||||||
| "session.new"
|
|
||||||
| "session.share"
|
|
||||||
| "session.interrupt"
|
|
||||||
| "session.compact"
|
|
||||||
| "session.page.up"
|
|
||||||
| "session.page.down"
|
|
||||||
| "session.line.up"
|
|
||||||
| "session.line.down"
|
|
||||||
| "session.half.page.up"
|
|
||||||
| "session.half.page.down"
|
|
||||||
| "session.first"
|
|
||||||
| "session.last"
|
|
||||||
| "prompt.clear"
|
|
||||||
| "prompt.submit"
|
|
||||||
| "agent.cycle"
|
|
||||||
| string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventTuiToastShow = {
|
|
||||||
id: string
|
|
||||||
type: "tui.toast.show"
|
|
||||||
properties: {
|
|
||||||
title?: string
|
|
||||||
message: string
|
|
||||||
variant: "info" | "success" | "warning" | "error"
|
|
||||||
duration?: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventTuiSessionSelect = {
|
|
||||||
id: string
|
|
||||||
type: "tui.session.select"
|
|
||||||
properties: {
|
|
||||||
/**
|
|
||||||
* Session ID to navigate to
|
|
||||||
*/
|
|
||||||
sessionID: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Project = {
|
export type Project = {
|
||||||
id: string
|
id: string
|
||||||
worktree: string
|
worktree: string
|
||||||
@@ -790,6 +790,12 @@ export type GlobalEvent = {
|
|||||||
project?: string
|
project?: string
|
||||||
workspace?: string
|
workspace?: string
|
||||||
payload:
|
payload:
|
||||||
|
| EventTuiPromptAppend
|
||||||
|
| EventTuiCommandExecute
|
||||||
|
| EventTuiToastShow
|
||||||
|
| EventTuiSessionSelect
|
||||||
|
| EventServerConnected
|
||||||
|
| EventGlobalDisposed
|
||||||
| EventServerInstanceDisposed
|
| EventServerInstanceDisposed
|
||||||
| EventFileEdited
|
| EventFileEdited
|
||||||
| EventFileWatcherUpdated
|
| EventFileWatcherUpdated
|
||||||
@@ -806,10 +812,6 @@ export type GlobalEvent = {
|
|||||||
| EventTodoUpdated
|
| EventTodoUpdated
|
||||||
| EventSessionStatus
|
| EventSessionStatus
|
||||||
| EventSessionIdle
|
| EventSessionIdle
|
||||||
| EventTuiPromptAppend
|
|
||||||
| EventTuiCommandExecute
|
|
||||||
| EventTuiToastShow
|
|
||||||
| EventTuiSessionSelect
|
|
||||||
| EventMcpToolsChanged
|
| EventMcpToolsChanged
|
||||||
| EventMcpBrowserOpenFailed
|
| EventMcpBrowserOpenFailed
|
||||||
| EventCommandExecuted
|
| EventCommandExecuted
|
||||||
@@ -834,9 +836,6 @@ export type GlobalEvent = {
|
|||||||
| EventSessionCreated
|
| EventSessionCreated
|
||||||
| EventSessionUpdated
|
| EventSessionUpdated
|
||||||
| EventSessionDeleted
|
| EventSessionDeleted
|
||||||
| EventServerConnected
|
|
||||||
| EventGlobalDisposed
|
|
||||||
| EventCatalogModelUpdated
|
|
||||||
| EventSessionNextAgentSwitched
|
| EventSessionNextAgentSwitched
|
||||||
| EventSessionNextModelSwitched
|
| EventSessionNextModelSwitched
|
||||||
| EventSessionNextPrompted
|
| EventSessionNextPrompted
|
||||||
@@ -863,6 +862,7 @@ export type GlobalEvent = {
|
|||||||
| EventSessionNextCompactionStarted
|
| EventSessionNextCompactionStarted
|
||||||
| EventSessionNextCompactionDelta
|
| EventSessionNextCompactionDelta
|
||||||
| EventSessionNextCompactionEnded
|
| EventSessionNextCompactionEnded
|
||||||
|
| EventCatalogModelUpdated
|
||||||
| SyncEventMessageUpdated
|
| SyncEventMessageUpdated
|
||||||
| SyncEventMessageRemoved
|
| SyncEventMessageRemoved
|
||||||
| SyncEventMessagePartUpdated
|
| SyncEventMessagePartUpdated
|
||||||
@@ -2403,6 +2403,22 @@ export type SyncEventSessionNextCompactionEnded = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type EventServerConnected = {
|
||||||
|
id: string
|
||||||
|
type: "server.connected"
|
||||||
|
properties: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EventGlobalDisposed = {
|
||||||
|
id: string
|
||||||
|
type: "global.disposed"
|
||||||
|
properties: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type EventServerInstanceDisposed = {
|
export type EventServerInstanceDisposed = {
|
||||||
id: string
|
id: string
|
||||||
type: "server.instance.disposed"
|
type: "server.instance.disposed"
|
||||||
@@ -2748,128 +2764,6 @@ export type EventSessionDeleted = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EventServerConnected = {
|
|
||||||
id: string
|
|
||||||
type: "server.connected"
|
|
||||||
properties: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventGlobalDisposed = {
|
|
||||||
id: string
|
|
||||||
type: "global.disposed"
|
|
||||||
properties: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ModelV2Info = {
|
|
||||||
id: string
|
|
||||||
apiID: string
|
|
||||||
providerID: string
|
|
||||||
family?: string
|
|
||||||
name: string
|
|
||||||
endpoint:
|
|
||||||
| {
|
|
||||||
type: "unknown"
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: "openai/responses"
|
|
||||||
url: string
|
|
||||||
websocket?: boolean
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: "openai/completions"
|
|
||||||
url: string
|
|
||||||
reasoning?:
|
|
||||||
| {
|
|
||||||
type: "reasoning_content"
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: "reasoning_details"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: "anthropic/messages"
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
type: "aisdk"
|
|
||||||
package: string
|
|
||||||
url?: string
|
|
||||||
}
|
|
||||||
capabilities: {
|
|
||||||
tools: boolean
|
|
||||||
input: Array<string>
|
|
||||||
output: Array<string>
|
|
||||||
}
|
|
||||||
options: {
|
|
||||||
headers: {
|
|
||||||
[key: string]: string
|
|
||||||
}
|
|
||||||
body: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
aisdk: {
|
|
||||||
provider: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
request: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
variant?: string
|
|
||||||
}
|
|
||||||
variants: Array<{
|
|
||||||
id: string
|
|
||||||
headers: {
|
|
||||||
[key: string]: string
|
|
||||||
}
|
|
||||||
body: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
aisdk: {
|
|
||||||
provider: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
request: {
|
|
||||||
[key: string]: unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
time: {
|
|
||||||
released: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
|
|
||||||
}
|
|
||||||
cost: Array<{
|
|
||||||
tier?: {
|
|
||||||
type: "context"
|
|
||||||
size: number
|
|
||||||
}
|
|
||||||
input: number
|
|
||||||
output: number
|
|
||||||
cache: {
|
|
||||||
read: number
|
|
||||||
write: number
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
status: "alpha" | "beta" | "deprecated" | "active"
|
|
||||||
enabled: boolean
|
|
||||||
limit: {
|
|
||||||
context: number
|
|
||||||
input?: number
|
|
||||||
output: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventCatalogModelUpdated = {
|
|
||||||
id: string
|
|
||||||
type: "catalog.model.updated"
|
|
||||||
properties: {
|
|
||||||
model: ModelV2Info
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type EventSessionNextAgentSwitched = {
|
export type EventSessionNextAgentSwitched = {
|
||||||
id: string
|
id: string
|
||||||
type: "session.next.agent.switched"
|
type: "session.next.agent.switched"
|
||||||
@@ -3251,6 +3145,112 @@ export type EventSessionNextCompactionEnded = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ModelV2Info = {
|
||||||
|
id: string
|
||||||
|
apiID: string
|
||||||
|
providerID: string
|
||||||
|
family?: string
|
||||||
|
name: string
|
||||||
|
endpoint:
|
||||||
|
| {
|
||||||
|
type: "unknown"
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "openai/responses"
|
||||||
|
url: string
|
||||||
|
websocket?: boolean
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "openai/completions"
|
||||||
|
url: string
|
||||||
|
reasoning?:
|
||||||
|
| {
|
||||||
|
type: "reasoning_content"
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "reasoning_details"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "anthropic/messages"
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "aisdk"
|
||||||
|
package: string
|
||||||
|
url?: string
|
||||||
|
}
|
||||||
|
capabilities: {
|
||||||
|
tools: boolean
|
||||||
|
input: Array<string>
|
||||||
|
output: Array<string>
|
||||||
|
}
|
||||||
|
options: {
|
||||||
|
headers: {
|
||||||
|
[key: string]: string
|
||||||
|
}
|
||||||
|
body: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
aisdk: {
|
||||||
|
provider: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
request: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
variant?: string
|
||||||
|
}
|
||||||
|
variants: Array<{
|
||||||
|
id: string
|
||||||
|
headers: {
|
||||||
|
[key: string]: string
|
||||||
|
}
|
||||||
|
body: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
aisdk: {
|
||||||
|
provider: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
request: {
|
||||||
|
[key: string]: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
time: {
|
||||||
|
released: number | "NaN" | "Infinity" | "-Infinity" | "Infinity" | "-Infinity" | "NaN"
|
||||||
|
}
|
||||||
|
cost: Array<{
|
||||||
|
tier?: {
|
||||||
|
type: "context"
|
||||||
|
size: number
|
||||||
|
}
|
||||||
|
input: number
|
||||||
|
output: number
|
||||||
|
cache: {
|
||||||
|
read: number
|
||||||
|
write: number
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
status: "alpha" | "beta" | "deprecated" | "active"
|
||||||
|
enabled: boolean
|
||||||
|
limit: {
|
||||||
|
context: number
|
||||||
|
input?: number
|
||||||
|
output: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EventCatalogModelUpdated = {
|
||||||
|
id: string
|
||||||
|
type: "catalog.model.updated"
|
||||||
|
properties: {
|
||||||
|
model: ModelV2Info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type SessionInfo = {
|
export type SessionInfo = {
|
||||||
id: string
|
id: string
|
||||||
parentID?: string
|
parentID?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user