mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Merge pull request #489 from chriswritescode-dev/fix/remote-schedule-windows-paths
fix(schedules): accept absolute Windows directories for remote schedules
This commit is contained in:
4 files changed
+46
-7
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
} from '@opencode-manager/shared/schemas'
|
||||
import { OpenCodeServerError } from '../services/opencode-server-registry'
|
||||
import { TerminalNotFoundError, type TerminalService } from '../services/terminal'
|
||||
import { isAbsoluteRemoteDirectory } from '../utils/remote-path'
|
||||
import { parseTerminalCursor } from '../utils/terminal-cursor'
|
||||
import { createBridgedSocketEvents, isAllowedUpgradeOrigin } from '../utils/websocket-bridge'
|
||||
import { handleOpenCodeError, handleServiceError, parseJsonBody } from '../utils/route-helpers'
|
||||
@@ -23,14 +24,10 @@ interface ServerTerminalSocketVariables {
|
||||
session?: Session['session']
|
||||
}
|
||||
|
||||
function isAbsoluteDirectory(directory: string): boolean {
|
||||
return directory.startsWith('/') || /^[A-Za-z]:[\\/]/.test(directory)
|
||||
}
|
||||
|
||||
function readAbsoluteDirectory(raw: string | undefined): string | null {
|
||||
if (raw === undefined) return null
|
||||
const directory = raw.trim()
|
||||
return directory.length > 0 && isAbsoluteDirectory(directory) ? directory : null
|
||||
return directory.length > 0 && isAbsoluteRemoteDirectory(directory) ? directory : null
|
||||
}
|
||||
|
||||
function rejectLocalServer(c: Context, serverId: string): Response | null {
|
||||
|
||||
@@ -64,6 +64,7 @@ import { sseAggregator, type ScheduledSessionRef } from './sse-aggregator'
|
||||
import { getErrorMessage } from '../utils/error-utils'
|
||||
import { logger } from '../utils/logger'
|
||||
import { canonicalPathSync } from '../utils/fs-safe'
|
||||
import { isAbsoluteRemoteDirectory } from '../utils/remote-path'
|
||||
import { buildAssistantRepo } from './assistant-mode'
|
||||
import { createScheduleWorktreeDescriber } from './schedule-worktree-paths'
|
||||
import { SessionSandboxError, type SessionSandboxService } from './session-sandbox'
|
||||
@@ -717,7 +718,7 @@ export class ScheduleService {
|
||||
}
|
||||
|
||||
async createServerJob(serverId: string, directory: string, input: CreateScheduleJobRequest): Promise<ScheduleJob> {
|
||||
if (!path.isAbsolute(directory)) {
|
||||
if (!isAbsoluteRemoteDirectory(directory)) {
|
||||
throw new ScheduleServiceError('A remote schedule requires an absolute target directory', 400)
|
||||
}
|
||||
return this.createJobForTarget({ kind: 'server', serverId, directory }, input)
|
||||
@@ -751,7 +752,7 @@ export class ScheduleService {
|
||||
}
|
||||
|
||||
async updateServerJob(serverId: string, jobId: number, input: UpdateScheduleJobRequest): Promise<ScheduleJob> {
|
||||
if (input.directory !== undefined && input.directory !== null && !path.isAbsolute(input.directory)) {
|
||||
if (input.directory !== undefined && input.directory !== null && !isAbsoluteRemoteDirectory(input.directory)) {
|
||||
throw new ScheduleServiceError('A remote schedule requires an absolute target directory', 400)
|
||||
}
|
||||
return this.updateJobForTarget({ kind: 'server', serverId, directory: '' }, jobId, input)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export function isAbsoluteRemoteDirectory(directory: string): boolean {
|
||||
return directory.startsWith('/') || /^[A-Za-z]:[\\/]/.test(directory)
|
||||
}
|
||||
Reference in new issue
Block a user