feat(core): moving sessions (#30640)

This commit is contained in:
James Long
2026-06-04 15:07:46 -04:00
committed by GitHub
parent e45e0e1125
commit ba1b660d57
36 changed files with 2189 additions and 485 deletions

View File

@@ -34,6 +34,8 @@ import type {
ExperimentalConsoleListOrgsErrors,
ExperimentalConsoleListOrgsResponses,
ExperimentalConsoleSwitchOrgResponses,
ExperimentalControlPlaneMoveSessionErrors,
ExperimentalControlPlaneMoveSessionResponses,
ExperimentalProjectCopyCreateErrors,
ExperimentalProjectCopyCreateResponses,
ExperimentalProjectCopyRefreshErrors,
@@ -108,6 +110,7 @@ import type {
McpRemoteConfig,
McpStatusErrors,
McpStatusResponses,
MoveSessionDestination,
OutputFormat,
Part as Part2,
PartDeleteErrors,
@@ -532,33 +535,38 @@ export class App extends HeyApiClient {
}
}
export class Config extends HeyApiClient {
export class ControlPlane extends HeyApiClient {
/**
* Get global configuration
* Move session
*
* Retrieve the current global OpenCode configuration settings and preferences.
* Move a session to another project directory, optionally transferring local changes.
*/
public get<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).get<GlobalConfigGetResponses, GlobalConfigGetErrors, ThrowOnError>({
url: "/global/config",
...options,
})
}
/**
* Update global configuration
*
* Update global OpenCode configuration settings and preferences.
*/
public update<ThrowOnError extends boolean = false>(
public moveSession<ThrowOnError extends boolean = false>(
parameters?: {
config?: Config3
sessionID?: string
destination?: MoveSessionDestination
moveChanges?: boolean
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }])
return (options?.client ?? this.client).patch<GlobalConfigUpdateResponses, GlobalConfigUpdateErrors, ThrowOnError>({
url: "/global/config",
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "body", key: "sessionID" },
{ in: "body", key: "destination" },
{ in: "body", key: "moveChanges" },
],
},
],
)
return (options?.client ?? this.client).post<
ExperimentalControlPlaneMoveSessionResponses,
ExperimentalControlPlaneMoveSessionErrors,
ThrowOnError
>({
url: "/experimental/control-plane/move-session",
...options,
...params,
headers: {
@@ -570,204 +578,6 @@ export class Config extends HeyApiClient {
}
}
export class Global extends HeyApiClient {
/**
* Get health
*
* Get health information about the OpenCode server.
*/
public health<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).get<GlobalHealthResponses, GlobalHealthErrors, ThrowOnError>({
url: "/global/health",
...options,
})
}
/**
* Get global events
*
* Subscribe to global events from the OpenCode system using server-sent events.
*/
public event<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).sse.get<GlobalEventResponses, GlobalEventErrors, ThrowOnError>({
url: "/global/event",
...options,
})
}
/**
* Dispose instance
*
* Clean up and dispose all OpenCode instances, releasing all resources.
*/
public dispose<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).post<GlobalDisposeResponses, GlobalDisposeErrors, ThrowOnError>({
url: "/global/dispose",
...options,
})
}
/**
* Upgrade opencode
*
* Upgrade opencode to the specified version or latest if not specified.
*/
public upgrade<ThrowOnError extends boolean = false>(
parameters?: {
target?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ in: "body", key: "target" }] }])
return (options?.client ?? this.client).post<GlobalUpgradeResponses, GlobalUpgradeErrors, ThrowOnError>({
url: "/global/upgrade",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
private _config?: Config
get config(): Config {
return (this._config ??= new Config({ client: this.client }))
}
}
export class Event extends HeyApiClient {
/**
* Subscribe to events
*
* Get events
*/
public subscribe<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).sse.get<EventSubscribeResponses, unknown, ThrowOnError>({
url: "/event",
...options,
...params,
})
}
}
export class Config2 extends HeyApiClient {
/**
* Get configuration
*
* Retrieve the current OpenCode configuration settings and preferences.
*/
public get<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<ConfigGetResponses, ConfigGetErrors, ThrowOnError>({
url: "/config",
...options,
...params,
})
}
/**
* Update configuration
*
* Update OpenCode configuration settings and preferences.
*/
public update<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
config?: Config3
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
{ key: "config", map: "body" },
],
},
],
)
return (options?.client ?? this.client).patch<ConfigUpdateResponses, ConfigUpdateErrors, ThrowOnError>({
url: "/config",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* List config providers
*
* Get a list of all configured AI providers and their default models.
*/
public providers<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<ConfigProvidersResponses, ConfigProvidersErrors, ThrowOnError>({
url: "/config/providers",
...options,
...params,
})
}
}
export class Console extends HeyApiClient {
/**
* Get active Console provider metadata
@@ -1021,10 +831,11 @@ export class ProjectCopy extends HeyApiClient {
public create<ThrowOnError extends boolean = false>(
parameters: {
projectID: string
query_directory?: string
workspace?: string
strategy?: "git_worktree"
body_directory?: string
directory?: string
name?: string
context?: string
},
options?: Options<never, ThrowOnError>,
) {
@@ -1034,18 +845,11 @@ export class ProjectCopy extends HeyApiClient {
{
args: [
{ in: "path", key: "projectID" },
{
in: "query",
key: "query_directory",
map: "directory",
},
{ in: "query", key: "workspace" },
{ in: "body", key: "strategy" },
{
in: "body",
key: "body_directory",
map: "directory",
},
{ in: "body", key: "directory" },
{ in: "body", key: "name" },
{ in: "body", key: "context" },
],
},
],
@@ -1377,6 +1181,11 @@ export class Workspace extends HeyApiClient {
}
export class Experimental extends HeyApiClient {
private _controlPlane?: ControlPlane
get controlPlane(): ControlPlane {
return (this._controlPlane ??= new ControlPlane({ client: this.client }))
}
private _console?: Console
get console(): Console {
return (this._console ??= new Console({ client: this.client }))
@@ -1403,6 +1212,242 @@ export class Experimental extends HeyApiClient {
}
}
export class Config extends HeyApiClient {
/**
* Get global configuration
*
* Retrieve the current global OpenCode configuration settings and preferences.
*/
public get<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).get<GlobalConfigGetResponses, GlobalConfigGetErrors, ThrowOnError>({
url: "/global/config",
...options,
})
}
/**
* Update global configuration
*
* Update global OpenCode configuration settings and preferences.
*/
public update<ThrowOnError extends boolean = false>(
parameters?: {
config?: Config3
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ key: "config", map: "body" }] }])
return (options?.client ?? this.client).patch<GlobalConfigUpdateResponses, GlobalConfigUpdateErrors, ThrowOnError>({
url: "/global/config",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
}
export class Global extends HeyApiClient {
/**
* Get health
*
* Get health information about the OpenCode server.
*/
public health<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).get<GlobalHealthResponses, GlobalHealthErrors, ThrowOnError>({
url: "/global/health",
...options,
})
}
/**
* Get global events
*
* Subscribe to global events from the OpenCode system using server-sent events.
*/
public event<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).sse.get<GlobalEventResponses, GlobalEventErrors, ThrowOnError>({
url: "/global/event",
...options,
})
}
/**
* Dispose instance
*
* Clean up and dispose all OpenCode instances, releasing all resources.
*/
public dispose<ThrowOnError extends boolean = false>(options?: Options<never, ThrowOnError>) {
return (options?.client ?? this.client).post<GlobalDisposeResponses, GlobalDisposeErrors, ThrowOnError>({
url: "/global/dispose",
...options,
})
}
/**
* Upgrade opencode
*
* Upgrade opencode to the specified version or latest if not specified.
*/
public upgrade<ThrowOnError extends boolean = false>(
parameters?: {
target?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ in: "body", key: "target" }] }])
return (options?.client ?? this.client).post<GlobalUpgradeResponses, GlobalUpgradeErrors, ThrowOnError>({
url: "/global/upgrade",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
private _config?: Config
get config(): Config {
return (this._config ??= new Config({ client: this.client }))
}
}
export class Event extends HeyApiClient {
/**
* Subscribe to events
*
* Get events
*/
public subscribe<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).sse.get<EventSubscribeResponses, unknown, ThrowOnError>({
url: "/event",
...options,
...params,
})
}
}
export class Config2 extends HeyApiClient {
/**
* Get configuration
*
* Retrieve the current OpenCode configuration settings and preferences.
*/
public get<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<ConfigGetResponses, ConfigGetErrors, ThrowOnError>({
url: "/config",
...options,
...params,
})
}
/**
* Update configuration
*
* Update OpenCode configuration settings and preferences.
*/
public update<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
config?: Config3
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
{ key: "config", map: "body" },
],
},
],
)
return (options?.client ?? this.client).patch<ConfigUpdateResponses, ConfigUpdateErrors, ThrowOnError>({
url: "/config",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* List config providers
*
* Get a list of all configured AI providers and their default models.
*/
public providers<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<ConfigProvidersResponses, ConfigProvidersErrors, ThrowOnError>({
url: "/config/providers",
...options,
...params,
})
}
}
export class Tool extends HeyApiClient {
/**
* List tools
@@ -5712,6 +5757,11 @@ export class OpencodeClient extends HeyApiClient {
return (this._app ??= new App({ client: this.client }))
}
private _experimental?: Experimental
get experimental(): Experimental {
return (this._experimental ??= new Experimental({ client: this.client }))
}
private _global?: Global
get global(): Global {
return (this._global ??= new Global({ client: this.client }))
@@ -5727,11 +5777,6 @@ export class OpencodeClient extends HeyApiClient {
return (this._config ??= new Config2({ client: this.client }))
}
private _experimental?: Experimental
get experimental(): Experimental {
return (this._experimental ??= new Experimental({ client: this.client }))
}
private _tool?: Tool
get tool(): Tool {
return (this._tool ??= new Tool({ client: this.client }))

View File

@@ -17,6 +17,7 @@ export type Event =
| EventMessagePartRemoved
| EventSessionNextAgentSwitched
| EventSessionNextModelSwitched
| EventSessionNextMoved
| EventSessionNextPrompted
| EventSessionNextSynthetic
| EventSessionNextShellStarted
@@ -136,6 +137,13 @@ export type InvalidRequestError = {
field?: string
}
export type MoveSessionError = {
name: "MoveSessionError"
data: {
message: string
}
}
export type SnapshotFileDiff = {
file?: string
patch?: string
@@ -812,6 +820,16 @@ export type GlobalEvent = {
}
}
}
| {
id: string
type: "session.next.moved"
properties: {
timestamp: number
sessionID: string
location: LocationRef
subdirectory?: string
}
}
| {
id: string
type: "session.next.prompted"
@@ -1556,6 +1574,7 @@ export type GlobalEvent = {
| SyncEventMessagePartRemoved
| SyncEventSessionNextAgentSwitched
| SyncEventSessionNextModelSwitched
| SyncEventSessionNextMoved
| SyncEventSessionNextPrompted
| SyncEventSessionNextSynthetic
| SyncEventSessionNextShellStarted
@@ -2397,6 +2416,13 @@ export type ProjectNotFoundError = {
message: string
}
export type ProjectCopyError = {
name: "ProjectCopyError"
data: {
message: string
}
}
export type PtyNotFoundError = {
_tag: "PtyNotFoundError"
ptyID: string
@@ -2751,6 +2777,10 @@ export type EventTuiSessionSelect2 = {
}
}
export type MoveSessionDestination = {
directory: string
}
export type ModelV2Info = {
id: string
providerID: string
@@ -2821,6 +2851,11 @@ export type ModelV2Info = {
}
}
export type LocationRef = {
directory: string
workspaceID?: string
}
export type PromptSource = {
start: number
end: number
@@ -3112,6 +3147,23 @@ export type SyncEventSessionNextModelSwitched = {
}
}
export type SyncEventSessionNextMoved = {
type: "sync"
id: string
syncEvent: {
type: "session.next.moved.1"
id: string
seq: number
aggregateID: string
data: {
timestamp: number
sessionID: string
location: LocationRef
subdirectory?: string
}
}
}
export type SyncEventSessionNextPrompted = {
type: "sync"
id: string
@@ -3588,11 +3640,6 @@ export type AgentV2Info = {
permissions: PermissionV2Ruleset
}
export type LocationRef = {
directory: string
workspaceID?: string
}
export type SessionV2Info = {
id: string
parentID?: string
@@ -4147,6 +4194,17 @@ export type EventSessionNextModelSwitched = {
}
}
export type EventSessionNextMoved = {
id: string
type: "session.next.moved"
properties: {
timestamp: number
sessionID: string
location: LocationRef
subdirectory?: string
}
}
export type EventSessionNextPrompted = {
id: string
type: "session.next.prompted"
@@ -5002,6 +5060,37 @@ export type AppLogResponses = {
export type AppLogResponse = AppLogResponses[keyof AppLogResponses]
export type ExperimentalControlPlaneMoveSessionData = {
body?: {
sessionID: string
destination: MoveSessionDestination
moveChanges?: boolean
}
path?: never
query?: never
url: "/experimental/control-plane/move-session"
}
export type ExperimentalControlPlaneMoveSessionErrors = {
/**
* MoveSessionError | InvalidRequestError
*/
400: MoveSessionError | InvalidRequestError
}
export type ExperimentalControlPlaneMoveSessionError =
ExperimentalControlPlaneMoveSessionErrors[keyof ExperimentalControlPlaneMoveSessionErrors]
export type ExperimentalControlPlaneMoveSessionResponses = {
/**
* Session moved
*/
204: void
}
export type ExperimentalControlPlaneMoveSessionResponse =
ExperimentalControlPlaneMoveSessionResponses[keyof ExperimentalControlPlaneMoveSessionResponses]
export type GlobalHealthData = {
body?: never
path?: never
@@ -6596,9 +6685,9 @@ export type ExperimentalProjectCopyRemoveData = {
export type ExperimentalProjectCopyRemoveErrors = {
/**
* BadRequest | InvalidRequestError
* ProjectCopyError | InvalidRequestError
*/
400: EffectHttpApiErrorBadRequest | InvalidRequestError
400: ProjectCopyError | InvalidRequestError
}
export type ExperimentalProjectCopyRemoveError =
@@ -6618,12 +6707,13 @@ export type ExperimentalProjectCopyCreateData = {
body?: {
strategy: "git_worktree"
directory: string
name?: string
context?: string
}
path: {
projectID: string
}
query?: {
directory?: string
workspace?: string
}
url: "/experimental/project/{projectID}/copy"
@@ -6631,9 +6721,9 @@ export type ExperimentalProjectCopyCreateData = {
export type ExperimentalProjectCopyCreateErrors = {
/**
* BadRequest | InvalidRequestError
* ProjectCopyError | InvalidRequestError
*/
400: EffectHttpApiErrorBadRequest | InvalidRequestError
400: ProjectCopyError | InvalidRequestError
}
export type ExperimentalProjectCopyCreateError =
@@ -6663,9 +6753,9 @@ export type ExperimentalProjectCopyRefreshData = {
export type ExperimentalProjectCopyRefreshErrors = {
/**
* BadRequest | InvalidRequestError
* ProjectCopyError | InvalidRequestError
*/
400: EffectHttpApiErrorBadRequest | InvalidRequestError
400: ProjectCopyError | InvalidRequestError
}
export type ExperimentalProjectCopyRefreshError =