Download packages/agent-core-v2/src/app/auth/oauthProtocol.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/auth/oauthProtocol.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/packages/agent-core-v2/src/app/auth/oauthProtocol.ts
-
curl -L -o oauthProtocol.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/packages/agent-core-v2/src/app/auth/oauthProtocol.ts
3.16 kB
| import { z } from 'zod'; | |
| import { isoDateTimeSchema } from '#/_base/utils/isoDateTime'; | |
| import { kimiRegionSchema } from '@moonshot-ai/kimi-code-oauth'; | |
| export const oauthFlowStatusEnum = z.enum([ | |
| 'pending', | |
| 'authenticated', | |
| 'denied', | |
| 'expired', | |
| 'cancelled', | |
| ]); | |
| export type OAuthFlowStatus = z.infer<typeof oauthFlowStatusEnum>; | |
| export const oauthFlowStartPendingSchema = z.object({ | |
| flow_id: z.string().min(1), | |
| provider: z.string().min(1), | |
| status: z.literal('pending'), | |
| verification_uri: z.string().url(), | |
| verification_uri_complete: z.string().url(), | |
| user_code: z.string().min(1), | |
| expires_in: z.number().int().positive(), | |
| interval: z.number().int().positive(), | |
| expires_at: isoDateTimeSchema, | |
| }); | |
| export type OAuthFlowStartPending = z.infer<typeof oauthFlowStartPendingSchema>; | |
| export const oauthFlowStartAuthenticatedSchema = z.object({ | |
| flow_id: z.string().min(1), | |
| provider: z.string().min(1), | |
| status: z.literal('authenticated'), | |
| }); | |
| export type OAuthFlowStartAuthenticated = z.infer<typeof oauthFlowStartAuthenticatedSchema>; | |
| export const oauthFlowStartSchema = z.discriminatedUnion('status', [ | |
| oauthFlowStartPendingSchema, | |
| oauthFlowStartAuthenticatedSchema, | |
| ]); | |
| export type OAuthFlowStart = z.infer<typeof oauthFlowStartSchema>; | |
| export const oauthFlowSnapshotSchema = z.object({ | |
| flow_id: z.string().min(1), | |
| provider: z.string().min(1), | |
| status: oauthFlowStatusEnum, | |
| verification_uri: z.string().url(), | |
| verification_uri_complete: z.string().url(), | |
| user_code: z.string().min(1), | |
| expires_in: z.number().int().positive(), | |
| expires_at: isoDateTimeSchema, | |
| interval: z.number().int().positive(), | |
| resolved_at: isoDateTimeSchema.optional(), | |
| error_message: z.string().optional(), | |
| }); | |
| export type OAuthFlowSnapshot = z.infer<typeof oauthFlowSnapshotSchema>; | |
| export const oauthLoginCancelResponseSchema = z.object({ | |
| cancelled: z.boolean(), | |
| status: oauthFlowStatusEnum, | |
| }); | |
| export type OAuthLoginCancelResponse = z.infer<typeof oauthLoginCancelResponseSchema>; | |
| export const oauthLogoutResponseSchema = z.object({ | |
| logged_out: z.literal(true), | |
| provider: z.string().min(1), | |
| }); | |
| export type OAuthLogoutResponse = z.infer<typeof oauthLogoutResponseSchema>; | |
| export const oauthRegionResultSchema = z.object({ | |
| region: kimiRegionSchema, | |
| }); | |
| export type OAuthRegionResult = z.infer<typeof oauthRegionResultSchema>; | |
| const providerRefreshChangeSchema = z.object({ | |
| provider_id: z.string().min(1), | |
| provider_name: z.string().min(1), | |
| added: z.number().int().min(0), | |
| removed: z.number().int().min(0), | |
| }); | |
| const providerRefreshFailureSchema = z.object({ | |
| provider: z.string().min(1), | |
| reason: z.string().min(1), | |
| }); | |
| export const refreshOAuthProviderModelsResponseSchema = z.object({ | |
| changed: z.array(providerRefreshChangeSchema), | |
| unchanged: z.array(z.string().min(1)), | |
| failed: z.array(providerRefreshFailureSchema), | |
| }); | |
| export type RefreshOAuthProviderModelsResponse = z.infer< | |
| typeof refreshOAuthProviderModelsResponseSchema | |
| >; | |
| export { | |
| managedUsageResultSchema, | |
| type ManagedUsageResult, | |
| managedUserInfoResultSchema, | |
| type ManagedUserInfoResult, | |
| } from '@moonshot-ai/kimi-code-oauth'; | |