diff --git a/packages/opencode/src/server/routes/instance/httpapi/server.ts b/packages/opencode/src/server/routes/instance/httpapi/server.ts index 7ce4f7a63..8c5c0ad96 100644 --- a/packages/opencode/src/server/routes/instance/httpapi/server.ts +++ b/packages/opencode/src/server/routes/instance/httpapi/server.ts @@ -1,12 +1,6 @@ import { Config as EffectConfig, Context, Effect, Layer } from "effect" import { HttpApiBuilder, OpenApi } from "effect/unstable/httpapi" -import { - HttpClient, - HttpMiddleware, - HttpRouter, - HttpServer, - HttpServerResponse, -} from "effect/unstable/http" +import { HttpClient, HttpMiddleware, HttpRouter, HttpServer, HttpServerResponse } from "effect/unstable/http" import * as Socket from "effect/unstable/socket/Socket" import { FSUtil } from "@opencode-ai/core/fs-util" import * as Observability from "@opencode-ai/core/observability" diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts index ceab0a707..92f09a991 100644 --- a/packages/sdk/js/src/v2/gen/types.gen.ts +++ b/packages/sdk/js/src/v2/gen/types.gen.ts @@ -77,18 +77,18 @@ export type Event = | EventCommandExecuted | EventProjectDirectoriesUpdated | EventProjectUpdated - | EventVcsBranchUpdated + | EventSessionStatus + | EventSessionIdle | EventQuestionAsked | EventQuestionReplied | EventQuestionRejected - | EventSessionStatus - | EventSessionIdle | EventSessionCompacted - | EventWorktreeReady - | EventWorktreeFailed + | EventVcsBranchUpdated | EventWorkspaceReady | EventWorkspaceFailed | EventWorkspaceStatus + | EventWorktreeReady + | EventWorktreeFailed | EventServerConnected | EventGlobalDisposed | EventServerInstanceDisposed @@ -667,6 +667,28 @@ export type Todo = { priority: string } +export type SessionStatus = + | { + type: "idle" + } + | { + type: "retry" + attempt: number + message: string + action?: { + reason: string + provider: string + title: string + message: string + label: string + link?: string + } + next: number + } + | { + type: "busy" + } + export type QuestionOption = { /** * Display text (1-5 words, concise) @@ -702,28 +724,6 @@ export type QuestionTool = { export type QuestionAnswer = Array -export type SessionStatus = - | { - type: "idle" - } - | { - type: "retry" - attempt: number - message: string - action?: { - reason: string - provider: string - title: string - message: string - label: string - link?: string - } - next: number - } - | { - type: "busy" - } - export type GlobalEvent = { directory: string project?: string @@ -1515,9 +1515,17 @@ export type GlobalEvent = { } | { id: string - type: "vcs.branch.updated" + type: "session.status" properties: { - branch?: string + sessionID: string + status: SessionStatus + } + } + | { + id: string + type: "session.idle" + properties: { + sessionID: string } } | { @@ -1550,21 +1558,6 @@ export type GlobalEvent = { requestID: string } } - | { - id: string - type: "session.status" - properties: { - sessionID: string - status: SessionStatus - } - } - | { - id: string - type: "session.idle" - properties: { - sessionID: string - } - } | { id: string type: "session.compacted" @@ -1574,19 +1567,11 @@ export type GlobalEvent = { } | { id: string - type: "worktree.ready" + type: "vcs.branch.updated" properties: { - name: string branch?: string } } - | { - id: string - type: "worktree.failed" - properties: { - message: string - } - } | { id: string type: "workspace.ready" @@ -1609,6 +1594,21 @@ export type GlobalEvent = { status: "connected" | "connecting" | "disconnected" | "error" } } + | { + id: string + type: "worktree.ready" + properties: { + name: string + branch?: string + } + } + | { + id: string + type: "worktree.failed" + properties: { + message: string + } + } | { id: string type: "server.connected" @@ -5123,11 +5123,20 @@ export type EventProjectUpdated = { } } -export type EventVcsBranchUpdated = { +export type EventSessionStatus = { id: string - type: "vcs.branch.updated" + type: "session.status" properties: { - branch?: string + sessionID: string + status: SessionStatus + } +} + +export type EventSessionIdle = { + id: string + type: "session.idle" + properties: { + sessionID: string } } @@ -5164,23 +5173,6 @@ export type EventQuestionRejected = { } } -export type EventSessionStatus = { - id: string - type: "session.status" - properties: { - sessionID: string - status: SessionStatus - } -} - -export type EventSessionIdle = { - id: string - type: "session.idle" - properties: { - sessionID: string - } -} - export type EventSessionCompacted = { id: string type: "session.compacted" @@ -5189,23 +5181,14 @@ export type EventSessionCompacted = { } } -export type EventWorktreeReady = { +export type EventVcsBranchUpdated = { id: string - type: "worktree.ready" + type: "vcs.branch.updated" properties: { - name: string branch?: string } } -export type EventWorktreeFailed = { - id: string - type: "worktree.failed" - properties: { - message: string - } -} - export type EventWorkspaceReady = { id: string type: "workspace.ready" @@ -5231,6 +5214,23 @@ export type EventWorkspaceStatus = { } } +export type EventWorktreeReady = { + id: string + type: "worktree.ready" + properties: { + name: string + branch?: string + } +} + +export type EventWorktreeFailed = { + id: string + type: "worktree.failed" + properties: { + message: string + } +} + export type EventServerConnected = { id: string type: "server.connected" diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json index 3caf658d4..20196c369 100644 --- a/packages/sdk/openapi.json +++ b/packages/sdk/openapi.json @@ -13788,7 +13788,10 @@ "$ref": "#/components/schemas/EventProjectUpdated" }, { - "$ref": "#/components/schemas/EventVcsBranchUpdated" + "$ref": "#/components/schemas/EventSessionStatus" + }, + { + "$ref": "#/components/schemas/EventSessionIdle" }, { "$ref": "#/components/schemas/EventQuestionAsked" @@ -13799,20 +13802,11 @@ { "$ref": "#/components/schemas/EventQuestionRejected" }, - { - "$ref": "#/components/schemas/EventSessionStatus" - }, - { - "$ref": "#/components/schemas/EventSessionIdle" - }, { "$ref": "#/components/schemas/EventSessionCompacted" }, { - "$ref": "#/components/schemas/EventWorktreeReady" - }, - { - "$ref": "#/components/schemas/EventWorktreeFailed" + "$ref": "#/components/schemas/EventVcsBranchUpdated" }, { "$ref": "#/components/schemas/EventWorkspaceReady" @@ -13823,6 +13817,12 @@ { "$ref": "#/components/schemas/EventWorkspaceStatus" }, + { + "$ref": "#/components/schemas/EventWorktreeReady" + }, + { + "$ref": "#/components/schemas/EventWorktreeFailed" + }, { "$ref": "#/components/schemas/EventServerConnected" }, @@ -15565,69 +15565,6 @@ "required": ["content", "status", "priority"], "additionalProperties": false }, - "QuestionOption": { - "type": "object", - "properties": { - "label": { - "type": "string", - "description": "Display text (1-5 words, concise)" - }, - "description": { - "type": "string", - "description": "Explanation of choice" - } - }, - "required": ["label", "description"], - "additionalProperties": false - }, - "QuestionInfo": { - "type": "object", - "properties": { - "question": { - "type": "string", - "description": "Complete question" - }, - "header": { - "type": "string", - "description": "Very short label (max 30 chars)" - }, - "options": { - "type": "array", - "items": { - "$ref": "#/components/schemas/QuestionOption" - }, - "description": "Available choices" - }, - "multiple": { - "type": "boolean" - }, - "custom": { - "type": "boolean" - } - }, - "required": ["question", "header", "options"], - "additionalProperties": false - }, - "QuestionTool": { - "type": "object", - "properties": { - "messageID": { - "type": "string", - "pattern": "^msg" - }, - "callID": { - "type": "string" - } - }, - "required": ["messageID", "callID"], - "additionalProperties": false - }, - "QuestionAnswer": { - "type": "array", - "items": { - "type": "string" - } - }, "SessionStatus": { "anyOf": [ { @@ -15701,6 +15638,69 @@ } ] }, + "QuestionOption": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "Display text (1-5 words, concise)" + }, + "description": { + "type": "string", + "description": "Explanation of choice" + } + }, + "required": ["label", "description"], + "additionalProperties": false + }, + "QuestionInfo": { + "type": "object", + "properties": { + "question": { + "type": "string", + "description": "Complete question" + }, + "header": { + "type": "string", + "description": "Very short label (max 30 chars)" + }, + "options": { + "type": "array", + "items": { + "$ref": "#/components/schemas/QuestionOption" + }, + "description": "Available choices" + }, + "multiple": { + "type": "boolean" + }, + "custom": { + "type": "boolean" + } + }, + "required": ["question", "header", "options"], + "additionalProperties": false + }, + "QuestionTool": { + "type": "object", + "properties": { + "messageID": { + "type": "string", + "pattern": "^msg" + }, + "callID": { + "type": "string" + } + }, + "required": ["messageID", "callID"], + "additionalProperties": false + }, + "QuestionAnswer": { + "type": "array", + "items": { + "type": "string" + } + }, "GlobalEvent": { "type": "object", "properties": { @@ -18384,15 +18384,46 @@ }, "type": { "type": "string", - "enum": ["vcs.branch.updated"] + "enum": ["session.status"] }, "properties": { "type": "object", "properties": { - "branch": { - "type": "string" + "sessionID": { + "type": "string", + "pattern": "^ses" + }, + "status": { + "$ref": "#/components/schemas/SessionStatus" } }, + "required": ["sessionID", "status"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["session.idle"] + }, + "properties": { + "type": "object", + "properties": { + "sessionID": { + "type": "string", + "pattern": "^ses" + } + }, + "required": ["sessionID"], "additionalProperties": false } }, @@ -18505,61 +18536,6 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, - { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^evt_" - }, - "type": { - "type": "string", - "enum": ["session.status"] - }, - "properties": { - "type": "object", - "properties": { - "sessionID": { - "type": "string", - "pattern": "^ses" - }, - "status": { - "$ref": "#/components/schemas/SessionStatus" - } - }, - "required": ["sessionID", "status"], - "additionalProperties": false - } - }, - "required": ["id", "type", "properties"], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^evt_" - }, - "type": { - "type": "string", - "enum": ["session.idle"] - }, - "properties": { - "type": "object", - "properties": { - "sessionID": { - "type": "string", - "pattern": "^ses" - } - }, - "required": ["sessionID"], - "additionalProperties": false - } - }, - "required": ["id", "type", "properties"], - "additionalProperties": false - }, { "type": "object", "properties": { @@ -18595,44 +18571,15 @@ }, "type": { "type": "string", - "enum": ["worktree.ready"] + "enum": ["vcs.branch.updated"] }, "properties": { "type": "object", "properties": { - "name": { - "type": "string" - }, "branch": { "type": "string" } }, - "required": ["name"], - "additionalProperties": false - } - }, - "required": ["id", "type", "properties"], - "additionalProperties": false - }, - { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^evt_" - }, - "type": { - "type": "string", - "enum": ["worktree.failed"] - }, - "properties": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - }, - "required": ["message"], "additionalProperties": false } }, @@ -18719,6 +18666,59 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, + { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["worktree.ready"] + }, + "properties": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "branch": { + "type": "string" + } + }, + "required": ["name"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["worktree.failed"] + }, + "properties": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": ["message"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, { "type": "object", "properties": { @@ -29793,7 +29793,7 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, - "EventVcsBranchUpdated": { + "EventSessionStatus": { "type": "object", "properties": { "id": { @@ -29802,15 +29802,46 @@ }, "type": { "type": "string", - "enum": ["vcs.branch.updated"] + "enum": ["session.status"] }, "properties": { "type": "object", "properties": { - "branch": { - "type": "string" + "sessionID": { + "type": "string", + "pattern": "^ses" + }, + "status": { + "$ref": "#/components/schemas/SessionStatus" } }, + "required": ["sessionID", "status"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, + "EventSessionIdle": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["session.idle"] + }, + "properties": { + "type": "object", + "properties": { + "sessionID": { + "type": "string", + "pattern": "^ses" + } + }, + "required": ["sessionID"], "additionalProperties": false } }, @@ -29923,61 +29954,6 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, - "EventSessionStatus": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^evt_" - }, - "type": { - "type": "string", - "enum": ["session.status"] - }, - "properties": { - "type": "object", - "properties": { - "sessionID": { - "type": "string", - "pattern": "^ses" - }, - "status": { - "$ref": "#/components/schemas/SessionStatus" - } - }, - "required": ["sessionID", "status"], - "additionalProperties": false - } - }, - "required": ["id", "type", "properties"], - "additionalProperties": false - }, - "EventSessionIdle": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^evt_" - }, - "type": { - "type": "string", - "enum": ["session.idle"] - }, - "properties": { - "type": "object", - "properties": { - "sessionID": { - "type": "string", - "pattern": "^ses" - } - }, - "required": ["sessionID"], - "additionalProperties": false - } - }, - "required": ["id", "type", "properties"], - "additionalProperties": false - }, "EventSessionCompacted": { "type": "object", "properties": { @@ -30004,7 +29980,7 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, - "EventWorktreeReady": { + "EventVcsBranchUpdated": { "type": "object", "properties": { "id": { @@ -30013,44 +29989,15 @@ }, "type": { "type": "string", - "enum": ["worktree.ready"] + "enum": ["vcs.branch.updated"] }, "properties": { "type": "object", "properties": { - "name": { - "type": "string" - }, "branch": { "type": "string" } }, - "required": ["name"], - "additionalProperties": false - } - }, - "required": ["id", "type", "properties"], - "additionalProperties": false - }, - "EventWorktreeFailed": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^evt_" - }, - "type": { - "type": "string", - "enum": ["worktree.failed"] - }, - "properties": { - "type": "object", - "properties": { - "message": { - "type": "string" - } - }, - "required": ["message"], "additionalProperties": false } }, @@ -30137,6 +30084,59 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, + "EventWorktreeReady": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["worktree.ready"] + }, + "properties": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "branch": { + "type": "string" + } + }, + "required": ["name"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, + "EventWorktreeFailed": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["worktree.failed"] + }, + "properties": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": ["message"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, "EventServerConnected": { "type": "object", "properties": {