@jeffusion/bungee-llms 5.20.0 → 5.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +8 -31
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +2158 -5530
  4. package/dist/plugin-api.d.ts +1 -4
  5. package/dist/plugin-api.js +4069 -8408
  6. package/dist/protocol-session/index.d.ts +14 -0
  7. package/dist/protocol-session/request.d.ts +5 -0
  8. package/dist/protocol-session/response.d.ts +23 -0
  9. package/dist/protocol-session/schema.d.ts +5 -0
  10. package/dist/protocol-session/stream.d.ts +35 -0
  11. package/dist/protocol-session/types.d.ts +48 -0
  12. package/dist/protocol-session/validation.d.ts +5 -0
  13. package/dist/providers/openai/index.d.ts +0 -1
  14. package/dist/responses-codec/common.d.ts +17 -2
  15. package/dist/responses-codec/events.d.ts +7 -1
  16. package/dist/responses-codec/index.d.ts +1 -1
  17. package/dist/responses-codec/request-preferences.d.ts +3 -0
  18. package/dist/responses-codec/request.d.ts +3 -1
  19. package/dist/responses-codec/web-search.d.ts +3 -0
  20. package/package.json +3 -3
  21. package/dist/protocol-converters/anthropic-to-gemini.converter.d.ts +0 -62
  22. package/dist/protocol-converters/anthropic-to-openai.converter.d.ts +0 -110
  23. package/dist/protocol-converters/base.d.ts +0 -38
  24. package/dist/protocol-converters/default-registry.d.ts +0 -1
  25. package/dist/protocol-converters/gemini-to-anthropic.converter.d.ts +0 -57
  26. package/dist/protocol-converters/gemini-to-openai.converter.d.ts +0 -31
  27. package/dist/protocol-converters/index.d.ts +0 -10
  28. package/dist/protocol-converters/openai-to-anthropic.converter.d.ts +0 -27
  29. package/dist/protocol-converters/openai-to-gemini.converter.d.ts +0 -32
  30. package/dist/protocol-converters/registry.d.ts +0 -9
  31. package/dist/protocol-converters/utils.d.ts +0 -71
  32. package/dist/providers/openai/messages-compat-normalization.d.ts +0 -42
@@ -1,71 +0,0 @@
1
- /**
2
- * Converter Utility Functions
3
- *
4
- * 提供转换器使用的通用工具函数
5
- */
6
- /**
7
- * 生成 Anthropic 风格的消息 ID
8
- *
9
- * @returns 格式为 msg_xxxxxxxxxxxxxxxxxxxxxxxx 的 ID(24位十六进制)
10
- */
11
- export declare function generateAnthropicMessageId(): string;
12
- /**
13
- * 生成 OpenAI 风格的聊天完成 ID
14
- *
15
- * @returns 格式为 chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxx 的 ID
16
- */
17
- export declare function generateOpenAIChatCompletionId(): string;
18
- /**
19
- * 生成 Gemini 风格的候选 ID
20
- *
21
- * @returns 格式为 candidate-xxxxxxxx 的 ID
22
- */
23
- export declare function generateGeminiCandidateId(): string;
24
- /**
25
- * 解析文本中的 <thinking> 标签
26
- *
27
- * @param text - 包含 <thinking> 标签的文本
28
- * @returns 解析后的内容块数组
29
- */
30
- export declare function parseThinkingTags(text: string): Array<{
31
- type: string;
32
- text?: string;
33
- thinking?: string;
34
- }>;
35
- /**
36
- * 将 thinking 块转换为 <thinking> 标签文本
37
- *
38
- * @param blocks - 内容块数组
39
- * @returns 包含 <thinking> 标签的文本
40
- */
41
- export declare function convertThinkingBlocksToTags(blocks: any[]): string;
42
- /**
43
- * 映射 Anthropic stop_reason 到 OpenAI finish_reason
44
- *
45
- * @param stopReason - Anthropic stop_reason
46
- * @returns OpenAI finish_reason
47
- */
48
- export declare function mapAnthropicStopReasonToOpenAI(stopReason: string): string;
49
- /**
50
- * 映射 OpenAI finish_reason 到 Anthropic stop_reason
51
- *
52
- * @param finishReason - OpenAI finish_reason
53
- * @returns Anthropic stop_reason
54
- */
55
- export declare function mapOpenAIFinishReasonToAnthropic(finishReason: string): string;
56
- /**
57
- * 安全解析 JSON 字符串
58
- *
59
- * @param jsonString - JSON 字符串
60
- * @param defaultValue - 解析失败时的默认值
61
- * @returns 解析结果或默认值
62
- */
63
- export declare function safeJsonParse<T = any>(jsonString: string, defaultValue?: T): T;
64
- /**
65
- * 安全 JSON 字符串化
66
- *
67
- * @param obj - 要字符串化的对象
68
- * @param defaultValue - 字符串化失败时的默认值
69
- * @returns JSON 字符串或默认值
70
- */
71
- export declare function safeJsonStringify(obj: any, defaultValue?: string): string;
@@ -1,42 +0,0 @@
1
- export interface OpenAIMessagesCompatibilityNormalizerOptions {
2
- strictValidation?: boolean;
3
- allowShortPathAlias?: boolean;
4
- }
5
- export interface OpenAIMessagesCompatibilityRequestLike {
6
- method: string;
7
- url: {
8
- pathname: string;
9
- };
10
- }
11
- export type OpenAIMessagesCompatibilityJsonObject = Record<string, unknown>;
12
- export type OpenAIMessagesCompatibilityBodyValidationResult = {
13
- ok: true;
14
- body: OpenAIMessagesCompatibilityJsonObject;
15
- } | {
16
- ok: false;
17
- message: string;
18
- };
19
- export declare class OpenAIMessagesCompatibilityNormalizer {
20
- private readonly strictValidation;
21
- private readonly allowShortPathAlias;
22
- constructor(options?: OpenAIMessagesCompatibilityNormalizerOptions);
23
- shouldHandleRequest(ctx: OpenAIMessagesCompatibilityRequestLike): boolean;
24
- validateAndNormalizeBody(rawBody: unknown): OpenAIMessagesCompatibilityBodyValidationResult;
25
- isOpenAIResponsePayload(payload: unknown): boolean;
26
- isOpenAIStreamChunk(chunk: unknown): boolean;
27
- buildBadRequest(message: string): Response;
28
- private normalizePathname;
29
- private collectConflictingFields;
30
- private parseToolsInput;
31
- private normalizeSingleTool;
32
- private normalizeTools;
33
- private normalizeToolChoice;
34
- private ensureAssistantToolCallReasoningContent;
35
- private normalizeMessage;
36
- private normalizeToolCallId;
37
- private normalizeToolResultContent;
38
- private extractThinkingText;
39
- private normalizeUserMessageWithToolResults;
40
- private normalizeAssistantMessageWithToolUse;
41
- private normalizeContentPart;
42
- }