Download packages/agent-core-v2/src/app/hostFolderBrowser/hostFolderBrowser.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/hostFolderBrowser/hostFolderBrowser.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/app/hostFolderBrowser/hostFolderBrowser.ts
-
curl -L -o hostFolderBrowser.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/hostFolderBrowser/hostFolderBrowser.ts
2.26 kB
| import { z } from 'zod'; | |
| import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation'; | |
| import { CoreErrors } from '#/_base/errors/codes'; | |
| import { Error2 } from '#/_base/errors/errors'; | |
| import { FsErrors } from '#/workspace/workspaceFs/internal/errors'; | |
| export const fsBrowseQuerySchema = z.object({ | |
| path: z.string().min(1).optional(), | |
| }); | |
| export type FsBrowseQuery = z.infer<typeof fsBrowseQuerySchema>; | |
| export const fsBrowseEntrySchema = z.object({ | |
| name: z.string().min(1), | |
| path: z.string().min(1), | |
| is_dir: z.literal(true), | |
| }); | |
| export type FsBrowseEntry = z.infer<typeof fsBrowseEntrySchema>; | |
| export const fsBrowseResponseSchema = z.object({ | |
| path: z.string().min(1), | |
| parent: z.string().min(1).nullable(), | |
| entries: z.array(fsBrowseEntrySchema), | |
| }); | |
| export type FsBrowseResponse = z.infer<typeof fsBrowseResponseSchema>; | |
| export const fsHomeResponseSchema = z.object({ | |
| home: z.string().min(1), | |
| recent_roots: z.array(z.string().min(1)), | |
| }); | |
| export type FsHomeResponse = z.infer<typeof fsHomeResponseSchema>; | |
| export class HostFolderNotAbsoluteError extends Error2 { | |
| readonly path: string; | |
| constructor(path: string) { | |
| super(CoreErrors.codes.VALIDATION_FAILED, `path must be absolute: ${path}`, { | |
| details: { path }, | |
| }); | |
| this.name = 'HostFolderNotAbsoluteError'; | |
| this.path = path; | |
| } | |
| } | |
| export class HostFolderNotFoundError extends Error2 { | |
| readonly path: string; | |
| constructor(path: string) { | |
| super(FsErrors.codes.FS_PATH_NOT_FOUND, `path not found: ${path}`, { details: { path } }); | |
| this.name = 'HostFolderNotFoundError'; | |
| this.path = path; | |
| } | |
| } | |
| export class HostFolderPermissionError extends Error2 { | |
| readonly path: string; | |
| constructor(path: string) { | |
| super(FsErrors.codes.FS_PERMISSION_DENIED, `permission denied: ${path}`, { details: { path } }); | |
| this.name = 'HostFolderPermissionError'; | |
| this.path = path; | |
| } | |
| } | |
| export interface IHostFolderBrowser { | |
| readonly _serviceBrand: undefined; | |
| browse(absPath?: string): Promise<FsBrowseResponse>; | |
| home(): Promise<FsHomeResponse>; | |
| } | |
| export const IHostFolderBrowser: ServiceIdentifier<IHostFolderBrowser> = | |
| createDecorator<IHostFolderBrowser>('hostFolderBrowser'); | |
| export const RECENT_ROOTS_LIMIT = 8; | |