mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
feat(servers): run Manager automation on linked servers
This commit is contained in:
1 parent
c591c15743
commit
a9bdb8358f
131 files changed
+6568
-949
No files matched your search
@@ -62,9 +62,15 @@ export const MultiRunFusionSchema = z.object({
|
||||
|
||||
export type MultiRunFusion = z.infer<typeof MultiRunFusionSchema>;
|
||||
|
||||
export type MultiRunTarget =
|
||||
| { kind: "repo"; repoId: number }
|
||||
| { kind: "server"; serverId: string; directory: string };
|
||||
|
||||
export const MultiRunSchema = z.object({
|
||||
id: z.number().int(),
|
||||
repoId: z.number().int(),
|
||||
repoId: z.number().int().nullable(),
|
||||
serverId: z.string(),
|
||||
directory: z.string().nullable(),
|
||||
name: z.string(),
|
||||
prompt: z.string(),
|
||||
isolated: z.boolean(),
|
||||
@@ -76,19 +82,30 @@ export const MultiRunSchema = z.object({
|
||||
|
||||
export type MultiRun = z.infer<typeof MultiRunSchema>;
|
||||
|
||||
export const LaunchMultiRunRequestSchema = z.object({
|
||||
repoId: z.number().int(),
|
||||
name: z.string().trim().min(1).max(MULTI_RUN_NAME_MAX_LENGTH),
|
||||
prompt: z.string().trim().min(1).max(SESSION_PROMPT_MAX_LENGTH),
|
||||
models: z
|
||||
.array(z.string().min(3))
|
||||
.min(1)
|
||||
.max(MULTI_RUN_MAX_MODELS)
|
||||
.refine((models) => new Set(models).size === models.length, { message: "Models must be unique" }),
|
||||
isolate: z.boolean(),
|
||||
baseRef: z.string().trim().min(1).optional(),
|
||||
agent: z.string().optional(),
|
||||
});
|
||||
export const LaunchMultiRunRequestSchema = z
|
||||
.object({
|
||||
repoId: z.number().int().optional(),
|
||||
serverId: z.string().trim().min(1).optional(),
|
||||
directory: z.string().trim().min(1).optional(),
|
||||
name: z.string().trim().min(1).max(MULTI_RUN_NAME_MAX_LENGTH),
|
||||
prompt: z.string().trim().min(1).max(SESSION_PROMPT_MAX_LENGTH),
|
||||
models: z
|
||||
.array(z.string().min(3))
|
||||
.min(1)
|
||||
.max(MULTI_RUN_MAX_MODELS)
|
||||
.refine((models) => new Set(models).size === models.length, { message: "Models must be unique" }),
|
||||
isolate: z.boolean(),
|
||||
baseRef: z.string().trim().min(1).optional(),
|
||||
agent: z.string().optional(),
|
||||
})
|
||||
.refine((data) => (data.repoId === undefined) !== (data.serverId === undefined), {
|
||||
message: "Provide either repoId or serverId",
|
||||
path: ["repoId"],
|
||||
})
|
||||
.refine((data) => (data.serverId === undefined) === (data.directory === undefined), {
|
||||
message: "A server target needs a directory",
|
||||
path: ["directory"],
|
||||
});
|
||||
|
||||
export type LaunchMultiRunRequest = z.infer<typeof LaunchMultiRunRequestSchema>;
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ export const PushNotificationPayloadSchema = z.object({
|
||||
directory: z.string().optional(),
|
||||
repoId: z.number().optional(),
|
||||
repoName: z.string().optional(),
|
||||
serverId: z.string().optional(),
|
||||
serverName: z.string().optional(),
|
||||
priority: z.enum(["normal", "high"]).optional(),
|
||||
})
|
||||
.optional(),
|
||||
|
||||
@@ -13,8 +13,10 @@ export type ScheduleMode = z.infer<typeof ScheduleModeSchema>
|
||||
* Where a scheduled run executes. `worktree` gives every run a fresh worktree that is
|
||||
* removed when the run ends, `kept-worktree` keeps each run's worktree afterwards, and
|
||||
* `shared-worktree` reuses one worktree and branch for every run of the schedule.
|
||||
* `in-place` runs directly in the target directory and is the only mode available for a
|
||||
* project on a linked remote OpenCode server, which has no local checkout to branch from.
|
||||
*/
|
||||
export const ScheduleWorkspaceModeSchema = z.enum(['worktree', 'kept-worktree', 'shared-worktree'])
|
||||
export const ScheduleWorkspaceModeSchema = z.enum(['worktree', 'kept-worktree', 'shared-worktree', 'in-place'])
|
||||
export type ScheduleWorkspaceMode = z.infer<typeof ScheduleWorkspaceModeSchema>
|
||||
|
||||
/**
|
||||
@@ -171,7 +173,9 @@ export function buildSchedulePermissionRuleset(
|
||||
|
||||
export const ScheduleJobSchema = z.object({
|
||||
id: z.number(),
|
||||
repoId: z.number(),
|
||||
repoId: z.number().nullable(),
|
||||
serverId: z.string().optional(),
|
||||
directory: z.string().nullable().optional(),
|
||||
name: z.string(),
|
||||
description: z.string().nullable(),
|
||||
enabled: z.boolean(),
|
||||
@@ -197,7 +201,8 @@ export type ScheduleJob = z.infer<typeof ScheduleJobSchema>
|
||||
export const ScheduleRunSchema = z.object({
|
||||
id: z.number(),
|
||||
jobId: z.number(),
|
||||
repoId: z.number(),
|
||||
repoId: z.number().nullable(),
|
||||
serverId: z.string().optional(),
|
||||
triggerSource: ScheduleRunTriggerSourceSchema,
|
||||
status: ScheduleRunStatusSchema,
|
||||
startedAt: z.number(),
|
||||
@@ -227,6 +232,7 @@ const ScheduleJobBaseRequestSchema = z.object({
|
||||
mcpServers: ScheduleMcpServersSchema.optional(),
|
||||
branch: z.string().min(1).max(200).nullable().optional(),
|
||||
workspaceMode: ScheduleWorkspaceModeSchema.optional(),
|
||||
directory: z.string().min(1).max(4096).optional(),
|
||||
})
|
||||
|
||||
export const CreateScheduleJobRequestSchema = z.discriminatedUnion('scheduleMode', [
|
||||
@@ -258,6 +264,7 @@ export const UpdateScheduleJobRequestSchema = z.object({
|
||||
mcpServers: ScheduleMcpServersSchema.optional(),
|
||||
branch: z.string().min(1).max(200).nullable().optional(),
|
||||
workspaceMode: ScheduleWorkspaceModeSchema.optional(),
|
||||
directory: z.string().min(1).max(4096).nullable().optional(),
|
||||
})
|
||||
export type UpdateScheduleJobRequest = z.infer<typeof UpdateScheduleJobRequestSchema>
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ export type SessionGoalTurnState = z.infer<typeof SessionGoalTurnStateSchema>;
|
||||
export const SessionGoalSchema = z.object({
|
||||
id: z.number().int(),
|
||||
sessionId: z.string(),
|
||||
serverId: z.string(),
|
||||
directory: z.string(),
|
||||
objective: z.string(),
|
||||
status: SessionGoalStatusSchema,
|
||||
@@ -66,6 +67,7 @@ export function isTerminalSessionGoal(goal: SessionGoal | null | undefined): goa
|
||||
|
||||
export const StartSessionGoalRequestSchema = z.object({
|
||||
sessionId: z.string().min(1),
|
||||
serverId: z.string().min(1).optional(),
|
||||
directory: z.string().min(1),
|
||||
objective: z.string().trim().min(1).max(SESSION_PROMPT_MAX_LENGTH),
|
||||
maxContinuations: z.number().int().min(GOAL_MAX_CONTINUATIONS_MIN).max(GOAL_MAX_CONTINUATIONS_MAX).optional(),
|
||||
|
||||
@@ -11,6 +11,7 @@ export type SessionLockReason = z.infer<typeof SessionLockReasonSchema>;
|
||||
export const SetSessionPermissionModeRequestSchema = z.object({
|
||||
directory: z.string().min(1),
|
||||
mode: SessionPermissionModeSchema,
|
||||
serverId: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export type SetSessionPermissionModeRequest = z.infer<typeof SetSessionPermissionModeRequestSchema>;
|
||||
|
||||
@@ -10,6 +10,7 @@ export const SSEVisibilitySchema = z.object({
|
||||
clientId: z.string().min(1),
|
||||
visible: z.boolean(),
|
||||
activeSessionId: z.string().nullable().optional(),
|
||||
activeServerId: z.string().min(1).optional(),
|
||||
});
|
||||
|
||||
export type SSESubscribeRequest = z.infer<typeof SSESubscribeSchema>;
|
||||
|
||||
@@ -22,6 +22,10 @@ export function buildSessionPath(
|
||||
return `/repos/${repoId}/sessions/${sessionId}${search ? `?${search}` : ''}`
|
||||
}
|
||||
|
||||
export function buildServerSessionPath(serverId: string, sessionId: string): string {
|
||||
return `/servers/${encodeURIComponent(serverId)}/sessions/${encodeURIComponent(sessionId)}`
|
||||
}
|
||||
|
||||
function trimTrailingChar(value: string, char: string): string {
|
||||
let end = value.length
|
||||
while (end > 0 && value[end - 1] === char) end--
|
||||
|
||||
Reference in new issue
Block a user