mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* feat(ocm-cli): add session warp with progress reporting Add warp functionality for moving sessions between local and remote Managers. Includes TUI dialogs, remote replay, progress reporting during event transfer, and comprehensive test coverage. * feat(ocm-cli): add granular push progress with phase reporting and upload tracking * chore(ocm-cli): bump version to 0.2.5 * docs(ocm-cli): document push progress phases in README
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { spawnSync } from 'node:child_process'
|
|
import { buildRemoteAttachEnv } from './remote-context.js'
|
|
|
|
export type WarpTarget = {
|
|
managerUrl: string
|
|
token: string
|
|
directory: string
|
|
sessionID: string
|
|
repoName: string
|
|
}
|
|
|
|
export type WarpSpawn = (
|
|
command: string,
|
|
args: string[],
|
|
options: { stdio: 'inherit'; env: NodeJS.ProcessEnv },
|
|
) => unknown
|
|
|
|
let pending: WarpTarget | undefined
|
|
|
|
export function setPendingWarp(target: WarpTarget): void {
|
|
pending = target
|
|
}
|
|
|
|
export function takePendingWarp(): WarpTarget | undefined {
|
|
const t = pending
|
|
pending = undefined
|
|
return t
|
|
}
|
|
|
|
export function buildAttachArgs(target: WarpTarget): string[] {
|
|
return [
|
|
'attach',
|
|
`${target.managerUrl}/api/opencode-proxy`,
|
|
'--dir', target.directory,
|
|
'--session', target.sessionID,
|
|
'--password', target.token,
|
|
'--username', 'opencode',
|
|
]
|
|
}
|
|
|
|
export function runPendingWarp(spawn: WarpSpawn = spawnSync): void {
|
|
const target = takePendingWarp()
|
|
if (!target) return
|
|
try {
|
|
spawn('opencode', buildAttachArgs(target), {
|
|
stdio: 'inherit',
|
|
env: { ...process.env, ...buildRemoteAttachEnv(target.managerUrl, target.repoName) },
|
|
})
|
|
} catch {
|
|
void 0
|
|
}
|
|
} |