Download packages/kap-server/src/protocol/envelope.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 762 Bytes
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/protocol/envelope.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/kap-server/src/protocol/envelope.ts
-
curl -L -o envelope.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/kap-server/src/protocol/envelope.ts
762 Bytes
| import { z } from 'zod'; | |
| export const envelopeSchema = <T extends z.ZodTypeAny>(data: T) => | |
| z.object({ | |
| code: z.number().int(), | |
| msg: z.string(), | |
| data: data.nullable(), | |
| request_id: z.string(), | |
| details: z.unknown().optional(), | |
| stack: z.string().optional(), | |
| }); | |
| export interface Envelope<T> { | |
| code: number; | |
| msg: string; | |
| data: T | null; | |
| request_id: string; | |
| details?: unknown; | |
| stack?: string; | |
| } | |
| export function okEnvelope<T>(data: T, requestId: string): Envelope<T> { | |
| return { code: 0, msg: 'success', data, request_id: requestId }; | |
| } | |
| export function errEnvelope( | |
| code: number, | |
| msg: string, | |
| requestId: string, | |
| stack?: string, | |
| ): Envelope<null> { | |
| return { code, msg, data: null, request_id: requestId, stack }; | |
| } | |