Download packages/agent-core-v2/src/features/externalHooks/configSection.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/features/externalHooks/configSection.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/features/externalHooks/configSection.ts
-
curl -L -o configSection.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/features/externalHooks/configSection.ts
1.18 kB
| import { z } from 'zod'; | |
| import { registerConfigSection } from '#/app/config/configSectionContributions'; | |
| import { isPlainObject, plainObjectToToml, transformPlainObject } from '#/app/config/toml'; | |
| import { HOOK_EVENT_TYPES } from './internal/types'; | |
| export const HOOKS_SECTION = 'hooks'; | |
| export const HookDefSchema = z | |
| .object({ | |
| event: z.enum(HOOK_EVENT_TYPES), | |
| matcher: z.string().optional(), | |
| command: z.string().min(1), | |
| timeout: z.number().int().min(1).max(600).optional(), | |
| }) | |
| .strict(); | |
| export type HookDefConfig = z.infer<typeof HookDefSchema>; | |
| export const HooksConfigSchema = z.array(HookDefSchema); | |
| export const hooksFromToml = (rawSnake: unknown): unknown => { | |
| if (!Array.isArray(rawSnake)) return rawSnake; | |
| return rawSnake.map((hook) => (isPlainObject(hook) ? transformPlainObject(hook) : hook)); | |
| }; | |
| export const hooksToToml = (value: unknown, _rawSnake: unknown): unknown => { | |
| if (!Array.isArray(value)) return value; | |
| return value.map((hook) => (isPlainObject(hook) ? plainObjectToToml(hook, undefined) : hook)); | |
| }; | |
| registerConfigSection(HOOKS_SECTION, HooksConfigSchema, { | |
| fromToml: hooksFromToml, | |
| toToml: hooksToToml, | |
| }); | |