mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
94 lines
2.5 KiB
TypeScript
94 lines
2.5 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
export const RepoStatusSchema = z.enum(['cloning', 'ready', 'error'])
|
|
|
|
export const RepoSchema = z.object({
|
|
id: z.number(),
|
|
repoUrl: z.string().url().optional(),
|
|
localPath: z.string(),
|
|
fullPath: z.string(),
|
|
sourcePath: z.string().optional(),
|
|
branch: z.string().optional(),
|
|
defaultBranch: z.string(),
|
|
cloneStatus: RepoStatusSchema,
|
|
clonedAt: z.number(),
|
|
lastPulled: z.number().optional(),
|
|
lastAccessedAt: z.number().optional(),
|
|
openCodeConfigName: z.string().optional(),
|
|
isWorktree: z.boolean().optional(),
|
|
isLocal: z.boolean().optional(),
|
|
})
|
|
|
|
export const CreateRepoRequestSchema = z.object({
|
|
repoUrl: z.string().url().optional(),
|
|
localPath: z.string().optional(),
|
|
branch: z.string().optional(),
|
|
openCodeConfigName: z.string().optional(),
|
|
useWorktree: z.boolean().optional(),
|
|
skipSSHVerification: z.boolean().optional(),
|
|
}).refine(
|
|
(data) => data.repoUrl || data.localPath,
|
|
{
|
|
message: "Either repoUrl or localPath must be provided",
|
|
path: ["repoUrl"],
|
|
}
|
|
)
|
|
|
|
export const DiscoverReposRequestSchema = z.object({
|
|
rootPath: z.string().trim().min(1),
|
|
maxDepth: z.number().int().min(0).max(8).optional(),
|
|
})
|
|
|
|
export const DiscoverReposResponseSchema = z.object({
|
|
repos: z.array(RepoSchema),
|
|
discoveredCount: z.number().int().nonnegative(),
|
|
existingCount: z.number().int().nonnegative(),
|
|
errors: z.array(
|
|
z.object({
|
|
path: z.string(),
|
|
error: z.string(),
|
|
})
|
|
),
|
|
})
|
|
|
|
export const AssistantModeFileSchema = z.object({
|
|
path: z.string(),
|
|
exists: z.boolean(),
|
|
created: z.boolean(),
|
|
})
|
|
|
|
export const AssistantModeStatusSchema = z.object({
|
|
repoId: z.number(),
|
|
directory: z.string(),
|
|
relativePath: z.literal('repos/assistant'),
|
|
files: z.object({
|
|
agentsMd: AssistantModeFileSchema,
|
|
opencodeJson: AssistantModeFileSchema,
|
|
}),
|
|
internalToken: z.object({
|
|
path: z.string(),
|
|
created: z.boolean(),
|
|
exists: z.boolean().optional(),
|
|
}).optional(),
|
|
schedulesSkill: z.object({
|
|
path: z.string(),
|
|
created: z.boolean(),
|
|
exists: z.boolean().optional(),
|
|
}).optional(),
|
|
notificationsSkill: z.object({
|
|
path: z.string(),
|
|
created: z.boolean(),
|
|
exists: z.boolean().optional(),
|
|
}).optional(),
|
|
settingsSkill: z.object({
|
|
path: z.string(),
|
|
created: z.boolean(),
|
|
exists: z.boolean().optional(),
|
|
}).optional(),
|
|
})
|
|
|
|
export const AssistantModeInitRequestSchema = z.object({
|
|
overwriteAgentsMd: z.boolean().optional(),
|
|
overwriteOpenCodeConfig: z.boolean().optional(),
|
|
})
|