mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
chore(opencode): move the OpenCode pin and supported floor to 2.4.2
This commit is contained in:
1 parent
bf2f81f921
commit
68f67327fc
19 files changed
+281
-170
No files matched your search
@@ -6,12 +6,14 @@ import { randomBytes } from 'crypto'
|
||||
import os from 'os'
|
||||
import path from 'path'
|
||||
import { z } from 'zod'
|
||||
import { buildOpenCodeBasicAuth, isSameOpenCodeMajor, isSupportedOpenCodeVersion } from '@opencode-manager/shared/opencode'
|
||||
import { buildOpenCodeBasicAuth, isSameOpenCodeMajor, isSupportedOpenCodeVersion, type OpenCodeApi } from '@opencode-manager/shared/opencode'
|
||||
import { OPENCODE_SERVICE_SERVE_ARGS, getOpenCodeServiceRegistrationPath, writeOpenCodeServiceSettings } from '../../src/services/opencode-service-mode'
|
||||
|
||||
const VERSION_TIMEOUT_MS = 5000
|
||||
const SERVE_READY_TIMEOUT_MS = 60000
|
||||
const SERVE_POLL_INTERVAL_MS = 250
|
||||
const PLUGIN_LOAD_TIMEOUT_MS = 30000
|
||||
const PLUGIN_POLL_INTERVAL_MS = 100
|
||||
const RUN_TIMEOUT_MS = 90000
|
||||
const STOP_TIMEOUT_MS = 5000
|
||||
const KILL_CONFIRM_MS = 2000
|
||||
@@ -44,6 +46,22 @@ function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
export async function waitForOpenCodePluginsLoaded(
|
||||
client: { api: OpenCodeApi },
|
||||
timeoutMs: number = PLUGIN_LOAD_TIMEOUT_MS,
|
||||
): Promise<void> {
|
||||
const deadline = Date.now() + timeoutMs
|
||||
while (Date.now() < deadline) {
|
||||
try {
|
||||
const { data } = await client.api.plugin.list()
|
||||
if (data.length > 0) return
|
||||
} catch {
|
||||
}
|
||||
await delay(PLUGIN_POLL_INTERVAL_MS)
|
||||
}
|
||||
throw new Error(`OpenCode server plugins did not load within ${timeoutMs}ms`)
|
||||
}
|
||||
|
||||
export function readOpenCodeVersion(binary: string): string | null {
|
||||
const result = spawnSync(binary, ['--version'], { encoding: 'utf8', timeout: VERSION_TIMEOUT_MS })
|
||||
if (result.status !== 0) return null
|
||||
|
||||
Reference in new issue
Block a user