( apiKind: ClassifierApiKind, body: unknown, overrides?: NormalizeOverrides )
| 87 | 'postgres', |
| 88 | 'postgresql', |
| 89 | 'private', |
| 90 | 'public', |
| 91 | 'redis', |
| 92 | 'root', |
| 93 | 'secret', |
| 94 | 'service', |
| 95 | 'session', |
| 96 | 'signing', |
| 97 | 'sql', |
| 98 | 'subscription', |
| 99 | ]; |
| 100 | // A qualifier only counts when it ends immediately before a credential word, so |
| 101 | // the scan before each occurrence never needs more than the longest qualifier. |
| 102 | const MAX_QUALIFIER_LENGTH = Math.max(...SENSITIVE_KEY_QUALIFIERS.map(q => q.length)); |
| 103 | // These words also begin common English words, so they count only as an exact |
| 104 | // token or a qualified occurrence, not at any token start. |
| 105 | const TOKEN_START_EXCLUDED_WORDS: Record<string, true> = { pass: true }; |
| 106 | // Content-part `type` values that carry a tool/function result rather than text. |
| 107 | const TOOL_RESULT_CONTENT_TYPES: ReadonlySet<string> = new Set([ |
| 108 | 'function_call_output', |
| 109 | 'tool_call_output', |
| 110 | 'tool_result', |
| 111 | ]); |
| 112 | // The subset whose result text lives under `output`; the rest use `content`. |
| 113 | const OUTPUT_KEYED_RESULT_TYPES: ReadonlySet<string> = new Set([ |
| 114 | 'function_call_output', |
| 115 | 'tool_call_output', |
| 116 | ]); |
| 117 | function isToolResultContentType(type: string): boolean { |
| 118 | return TOOL_RESULT_CONTENT_TYPES.has(type); |
| 119 | } |
| 120 | function isOutputKeyedResultType(type: string): boolean { |
| 121 | return OUTPUT_KEYED_RESULT_TYPES.has(type); |
| 122 | } |
| 123 | |
| 124 | export type ClassifierApiKind = NormalizedClassifierInput['apiKind']; |
| 125 | |
| 126 | const modelSchema = z.string().trim().min(1); |
| 127 | const messageSchema = z.looseObject({ |
| 128 | role: z.string(), |
| 129 | content: z.unknown().optional(), |
| 130 | }); |
| 131 | |
| 132 | const commonBodySchema = { |
| 133 | model: modelSchema, |
| 134 | stream: z.boolean().optional(), |
| 135 | provider: z.unknown().optional(), |
| 136 | providerOptions: z.unknown().optional(), |
| 137 | tools: z.array(z.unknown()).optional(), |
| 138 | }; |
| 139 | |
| 140 | const chatCompletionBodySchema = z.looseObject({ |
| 141 | ...commonBodySchema, |
| 142 | messages: z.array(messageSchema), |
no test coverage detected