@jsonstudio/llms 0.6.802 → 0.6.938

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 (186) hide show
  1. package/dist/bridge/routecodex-adapter.d.ts +74 -0
  2. package/dist/config-unified/enhanced-path-resolver.d.ts +5 -0
  3. package/dist/config-unified/unified-config.d.ts +26 -0
  4. package/dist/conversion/codec-registry.d.ts +10 -0
  5. package/dist/conversion/codecs/gemini-openai-codec.d.ts +16 -0
  6. package/dist/conversion/codecs/openai-openai-codec.d.ts +12 -0
  7. package/dist/conversion/codecs/responses-openai-codec.d.ts +12 -0
  8. package/dist/conversion/compat/profiles/chat-gemini.json +12 -0
  9. package/dist/conversion/config/config-manager.d.ts +212 -0
  10. package/dist/conversion/hub/config/types.d.ts +26 -0
  11. package/dist/conversion/hub/core/detour-registry.d.ts +9 -0
  12. package/dist/conversion/hub/core/hub-context.d.ts +21 -0
  13. package/dist/conversion/hub/core/index.d.ts +3 -0
  14. package/dist/conversion/hub/core/stage-driver.d.ts +30 -0
  15. package/dist/conversion/hub/format-adapters/anthropic-format-adapter.d.ts +16 -0
  16. package/dist/conversion/hub/format-adapters/chat-format-adapter.d.ts +17 -0
  17. package/dist/conversion/hub/format-adapters/gemini-format-adapter.d.ts +16 -0
  18. package/dist/conversion/hub/format-adapters/index.d.ts +21 -0
  19. package/dist/conversion/hub/hub-feature.d.ts +1 -0
  20. package/dist/conversion/hub/node-support.d.ts +19 -0
  21. package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +11 -0
  22. package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +3 -0
  23. package/dist/conversion/hub/pipeline/hub-pipeline.d.ts +7 -0
  24. package/dist/conversion/hub/pipeline/hub-pipeline.js +71 -14
  25. package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +4 -0
  26. package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +23 -1
  27. package/dist/conversion/hub/pipelines/inbound.d.ts +22 -0
  28. package/dist/conversion/hub/pipelines/outbound.d.ts +22 -0
  29. package/dist/conversion/hub/policy/policy-engine.d.ts +46 -0
  30. package/dist/conversion/hub/policy/policy-engine.js +176 -0
  31. package/dist/conversion/hub/policy/protocol-spec.d.ts +50 -0
  32. package/dist/conversion/hub/policy/protocol-spec.js +105 -0
  33. package/dist/conversion/hub/process/chat-process.d.ts +32 -0
  34. package/dist/conversion/hub/registry.d.ts +28 -0
  35. package/dist/conversion/hub/response/chat-response-utils.d.ts +6 -0
  36. package/dist/conversion/hub/response/provider-response.js +31 -0
  37. package/dist/conversion/hub/semantic-mappers/gemini-mapper.d.ts +7 -0
  38. package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +87 -1
  39. package/dist/conversion/hub/semantic-mappers/index.d.ts +4 -0
  40. package/dist/conversion/hub/semantic-mappers/responses-mapper.d.ts +21 -0
  41. package/dist/conversion/hub/standardized-bridge.d.ts +12 -0
  42. package/dist/conversion/hub/types/chat-schema.d.ts +112 -0
  43. package/dist/conversion/hub/types/errors.d.ts +5 -0
  44. package/dist/conversion/hub/types/format-envelope.d.ts +7 -0
  45. package/dist/conversion/hub/types/index.d.ts +6 -0
  46. package/dist/conversion/hub/types/json.d.ts +9 -0
  47. package/dist/conversion/hub/types/node.d.ts +31 -0
  48. package/dist/conversion/responses/responses-openai-bridge.js +263 -10
  49. package/dist/conversion/schema-validator.d.ts +7 -0
  50. package/dist/conversion/shared/args-mapping.d.ts +18 -0
  51. package/dist/conversion/shared/chat-request-filters.d.ts +9 -0
  52. package/dist/conversion/shared/errors.d.ts +1 -1
  53. package/dist/conversion/shared/gemini-tool-utils.js +61 -0
  54. package/dist/conversion/shared/jsonish.d.ts +3 -0
  55. package/dist/conversion/shared/mcp-injection.d.ts +2 -0
  56. package/dist/conversion/shared/media.d.ts +1 -0
  57. package/dist/conversion/shared/openai-message-normalize.d.ts +1 -0
  58. package/dist/conversion/shared/payload-budget.d.ts +13 -0
  59. package/dist/conversion/shared/reasoning-mapping.d.ts +5 -0
  60. package/dist/conversion/shared/responses-request-adapter.d.ts +1 -28
  61. package/dist/conversion/shared/responses-request-adapter.js +1 -430
  62. package/dist/conversion/shared/snapshot-hooks.js +58 -3
  63. package/dist/conversion/shared/tool-governor.js +8 -2
  64. package/dist/conversion/shared/tool-harvester.d.ts +31 -0
  65. package/dist/conversion/shared/tool-mapping.js +10 -29
  66. package/dist/conversion/types.d.ts +33 -0
  67. package/dist/filters/builtin/add-fields-filter.d.ts +8 -0
  68. package/dist/filters/builtin/blacklist-filter.d.ts +8 -0
  69. package/dist/filters/builtin/whitelist-filter.d.ts +8 -0
  70. package/dist/filters/engine.d.ts +16 -0
  71. package/dist/filters/special/request-tool-choice-policy.d.ts +11 -0
  72. package/dist/filters/special/response-finish-invariants.d.ts +11 -0
  73. package/dist/filters/special/response-openai-to-responses-bridge.d.ts +13 -0
  74. package/dist/filters/special/response-tool-arguments-blacklist.d.ts +12 -0
  75. package/dist/filters/special/response-tool-arguments-schema-converge.d.ts +13 -0
  76. package/dist/filters/special/response-tool-arguments-stringify.d.ts +9 -0
  77. package/dist/filters/special/response-tool-arguments-whitelist.d.ts +11 -0
  78. package/dist/filters/special/tool-filter-hooks.d.ts +19 -0
  79. package/dist/filters/special/tool-post-constraints.d.ts +31 -0
  80. package/dist/filters/types.d.ts +68 -0
  81. package/dist/filters/utils/fieldmap-loader.d.ts +2 -0
  82. package/dist/filters/utils/snapshot-writer.d.ts +10 -0
  83. package/dist/guidance/index.d.ts +3 -0
  84. package/dist/guidance/index.js +78 -83
  85. package/dist/http/sse-response.d.ts +22 -0
  86. package/dist/router/virtual-router/bootstrap.d.ts +6 -0
  87. package/dist/router/virtual-router/bootstrap.js +49 -5
  88. package/dist/router/virtual-router/classifier.d.ts +10 -0
  89. package/dist/router/virtual-router/engine-selection.js +98 -11
  90. package/dist/router/virtual-router/engine.js +177 -31
  91. package/dist/router/virtual-router/error-center.d.ts +10 -0
  92. package/dist/router/virtual-router/features.d.ts +3 -0
  93. package/dist/router/virtual-router/routing-instructions.d.ts +23 -1
  94. package/dist/router/virtual-router/routing-instructions.js +120 -30
  95. package/dist/router/virtual-router/types.d.ts +11 -0
  96. package/dist/servertool/engine.js +189 -16
  97. package/dist/servertool/handlers/apply-patch-guard.js +269 -0
  98. package/dist/servertool/handlers/exec-command-guard.js +558 -0
  99. package/dist/servertool/handlers/followup-message-trimmer.d.ts +16 -0
  100. package/dist/servertool/handlers/followup-message-trimmer.js +198 -0
  101. package/dist/servertool/handlers/followup-request-builder.d.ts +17 -0
  102. package/dist/servertool/handlers/followup-request-builder.js +122 -0
  103. package/dist/servertool/handlers/gemini-empty-reply-continue.js +252 -51
  104. package/dist/servertool/handlers/iflow-model-error-retry.js +12 -22
  105. package/dist/servertool/handlers/stop-message-auto.js +237 -75
  106. package/dist/servertool/handlers/vision.js +15 -27
  107. package/dist/servertool/handlers/web-search.js +17 -43
  108. package/dist/servertool/server-side-tools.d.ts +3 -0
  109. package/dist/servertool/server-side-tools.js +3 -0
  110. package/dist/sse/json-to-sse/anthropic-json-to-sse-converter.d.ts +2 -1
  111. package/dist/sse/json-to-sse/chat-json-to-sse-converter.d.ts +80 -0
  112. package/dist/sse/json-to-sse/event-generators/chat.d.ts +55 -0
  113. package/dist/sse/json-to-sse/event-generators/responses.d.ts +99 -0
  114. package/dist/sse/json-to-sse/gemini-json-to-sse-converter.d.ts +2 -1
  115. package/dist/sse/json-to-sse/responses-json-to-sse-converter.d.ts +80 -0
  116. package/dist/sse/json-to-sse/sequencers/anthropic-sequencer.d.ts +1 -1
  117. package/dist/sse/json-to-sse/sequencers/chat-sequencer.d.ts +2 -2
  118. package/dist/sse/json-to-sse/sequencers/gemini-sequencer.d.ts +1 -1
  119. package/dist/sse/json-to-sse/sequencers/responses-sequencer.d.ts +40 -0
  120. package/dist/sse/shared/chat-serializer.d.ts +4 -0
  121. package/dist/sse/shared/constants.d.ts +272 -0
  122. package/dist/sse/shared/serializers/anthropic-event-serializer.d.ts +1 -1
  123. package/dist/sse/shared/serializers/base-serializer.d.ts +158 -0
  124. package/dist/sse/shared/serializers/chat-event-serializer.d.ts +82 -0
  125. package/dist/sse/shared/serializers/gemini-event-serializer.d.ts +1 -1
  126. package/dist/sse/shared/serializers/index.d.ts +2 -1
  127. package/dist/sse/shared/serializers/responses-event-serializer.d.ts +123 -0
  128. package/dist/sse/shared/serializers/types.d.ts +51 -0
  129. package/dist/sse/shared/utils.d.ts +254 -0
  130. package/dist/sse/shared/writer.d.ts +2 -2
  131. package/dist/sse/sse-to-json/anthropic-sse-to-json-converter.d.ts +1 -1
  132. package/dist/sse/sse-to-json/builders/anthropic-response-builder.d.ts +1 -1
  133. package/dist/sse/sse-to-json/builders/response-builder.d.ts +1 -1
  134. package/dist/sse/sse-to-json/chat-sse-to-json-converter.d.ts +2 -1
  135. package/dist/sse/sse-to-json/gemini-sse-to-json-converter.d.ts +2 -1
  136. package/dist/sse/sse-to-json/parsers/sse-parser.d.ts +73 -0
  137. package/dist/sse/sse-to-json/responses-sse-to-json-converter.d.ts +1 -1
  138. package/dist/sse/types/chat-types.d.ts +1 -1
  139. package/dist/sse/types/responses-types.d.ts +1 -1
  140. package/dist/tools/apply-patch/execution-capturer.d.ts +13 -0
  141. package/dist/tools/apply-patch/execution-capturer.js +158 -0
  142. package/dist/tools/apply-patch/regression-capturer.d.ts +1 -0
  143. package/dist/tools/apply-patch/regression-capturer.js +5 -4
  144. package/dist/tools/apply-patch/structured.js +109 -13
  145. package/dist/tools/apply-patch/validator.js +112 -18
  146. package/dist/tools/tool-registry.d.ts +8 -0
  147. package/dist/tools/tool-registry.js +2 -1
  148. package/package.json +4 -4
  149. package/dist/conversion/compat/actions/apply-patch-format-fixer.js +0 -233
  150. package/dist/conversion/config/compat-profiles.json +0 -38
  151. package/dist/conversion/hub/pipeline/context-limit.d.ts +0 -13
  152. package/dist/conversion/hub/pipeline/context-limit.js +0 -55
  153. package/dist/conversion/hub/response/server-side-tools.d.ts +0 -26
  154. package/dist/conversion/hub/response/server-side-tools.js +0 -383
  155. package/dist/conversion/shared/bridge-conversation-store.d.ts +0 -41
  156. package/dist/conversion/shared/bridge-conversation-store.js +0 -279
  157. package/dist/conversion/shared/bridge-request-adapter.d.ts +0 -28
  158. package/dist/conversion/shared/bridge-request-adapter.js +0 -430
  159. package/dist/conversion/shared/responses-id-utils.js +0 -42
  160. package/dist/conversion/shared/responses-instructions.js +0 -113
  161. package/dist/conversion/shared/responses-message-utils.d.ts +0 -15
  162. package/dist/conversion/shared/responses-message-utils.js +0 -206
  163. package/dist/conversion/shared/responses-metadata.js +0 -1
  164. package/dist/conversion/shared/responses-output-utils.d.ts +0 -7
  165. package/dist/conversion/shared/responses-output-utils.js +0 -108
  166. package/dist/conversion/shared/responses-types.d.ts +0 -33
  167. package/dist/conversion/shared/tool-normalizers.d.ts +0 -4
  168. package/dist/conversion/shared/tool-normalizers.js +0 -84
  169. package/dist/filters/special/request-streaming-to-nonstreaming.d.ts +0 -13
  170. package/dist/filters/special/request-streaming-to-nonstreaming.js +0 -39
  171. package/dist/filters/special/response-apply-patch-toon-decode.d.ts +0 -23
  172. package/dist/filters/special/response-apply-patch-toon-decode.js +0 -460
  173. package/dist/filters/special/response-tool-arguments-toon-decode.d.ts +0 -10
  174. package/dist/filters/special/response-tool-arguments-toon-decode.js +0 -154
  175. package/dist/servertool/flow-types.d.ts +0 -40
  176. package/dist/servertool/flow-types.js +0 -1
  177. package/dist/servertool/orchestration-types.d.ts +0 -33
  178. package/dist/servertool/orchestration-types.js +0 -1
  179. package/dist/servertool/vision-tool.d.ts +0 -2
  180. package/dist/servertool/vision-tool.js +0 -185
  181. package/dist/tools/patch-args-normalizer.d.ts +0 -15
  182. package/dist/tools/patch-args-normalizer.js +0 -472
  183. package/dist/utils/toon.d.ts +0 -4
  184. package/dist/utils/toon.js +0 -75
  185. /package/dist/{conversion/compat/actions/apply-patch-format-fixer.d.ts → servertool/handlers/apply-patch-guard.d.ts} +0 -0
  186. /package/dist/{conversion/shared/responses-types.js → servertool/handlers/exec-command-guard.d.ts} +0 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Chat协议事件生成器
3
+ * 提供纯函数,将Chat响应数据转换为SSE事件对象,不处理流写入
4
+ */
5
+ import type { ChatSseEvent, ChatToolCall } from '../../types/index.js';
6
+ export interface ChatEventGeneratorConfig {
7
+ chunkSize: number;
8
+ chunkDelayMs: number;
9
+ enableIdGeneration: boolean;
10
+ enableTimestampGeneration: boolean;
11
+ }
12
+ export interface ChatEventGeneratorContext {
13
+ model: string;
14
+ requestId: string;
15
+ choiceIndex: number;
16
+ toolCallIndexCounter: number;
17
+ contentIndexCounter: Map<string, number>;
18
+ }
19
+ export declare const DEFAULT_CHAT_EVENT_GENERATOR_CONFIG: ChatEventGeneratorConfig;
20
+ /**
21
+ * 创建默认上下文
22
+ */
23
+ export declare function createDefaultContext(model: string, requestId: string): ChatEventGeneratorContext;
24
+ /**
25
+ * 构建role delta事件
26
+ */
27
+ export declare function buildRoleDelta(role: string, context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): ChatSseEvent[];
28
+ /**
29
+ * 构建reasoning delta事件
30
+ */
31
+ export declare function buildReasoningDeltas(reasoning: string, context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): Generator<ChatSseEvent>;
32
+ /**
33
+ * 构建content delta事件
34
+ */
35
+ export declare function buildContentDeltas(content: string, context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): Generator<ChatSseEvent>;
36
+ /**
37
+ * 构建tool_call开始事件
38
+ */
39
+ export declare function buildToolCallStart(toolCall: ChatToolCall, toolCallIndex: number, context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): ChatSseEvent;
40
+ /**
41
+ * 构建tool_call arguments delta事件
42
+ */
43
+ export declare function buildToolCallArgsDeltas(args: string, toolCallIndex: number, context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): Generator<ChatSseEvent>;
44
+ /**
45
+ * 构建finish_reason事件
46
+ */
47
+ export declare function buildFinishEvent(finishReason: 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): ChatSseEvent;
48
+ /**
49
+ * 构建done事件
50
+ */
51
+ export declare function buildDoneEvent(context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): ChatSseEvent;
52
+ /**
53
+ * 构建error事件
54
+ */
55
+ export declare function buildErrorEvent(error: Error, context: ChatEventGeneratorContext, config?: ChatEventGeneratorConfig): ChatSseEvent;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Responses协议事件生成器
3
+ * 提供纯函数,将Responses响应数据转换为SSE事件对象,不处理流写入
4
+ */
5
+ import type { ResponsesSseEvent, ResponsesResponse, ResponsesOutputItem, ResponsesFunctionCallItem, ResponsesReasoningItem, ResponsesContent } from '../../types/index.js';
6
+ export interface ResponsesEventGeneratorConfig {
7
+ chunkSize: number;
8
+ chunkDelayMs: number;
9
+ enableIdGeneration: boolean;
10
+ enableTimestampGeneration: boolean;
11
+ enableSequenceNumbers: boolean;
12
+ enableDelay: boolean;
13
+ }
14
+ export interface ResponsesEventGeneratorContext {
15
+ requestId: string;
16
+ model: string;
17
+ outputIndexCounter: number;
18
+ contentIndexCounter: Map<string, number>;
19
+ sequenceCounter: number;
20
+ }
21
+ export declare const DEFAULT_RESPONSES_EVENT_GENERATOR_CONFIG: ResponsesEventGeneratorConfig;
22
+ /**
23
+ * 创建默认上下文
24
+ */
25
+ export declare function createDefaultResponsesContext(requestId: string, model: string): ResponsesEventGeneratorContext;
26
+ /**
27
+ * 构建response.created + response.in_progress事件
28
+ * 映射:response.start → response.created + response.in_progress
29
+ */
30
+ export declare function buildResponseStartEvents(response: ResponsesResponse, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): Generator<ResponsesSseEvent>;
31
+ /**
32
+ * 构建response.output_item.added事件
33
+ * 映射:output_item.start → response.output_item.added
34
+ */
35
+ export declare function buildOutputItemStartEvent(outputItem: ResponsesOutputItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
36
+ /**
37
+ * 构建response.content_part.added事件
38
+ * 映射:content_part.start → response.content_part.added
39
+ */
40
+ export declare function buildContentPartStartEvent(outputItemId: string, contentIndex: number, content: ResponsesContent, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
41
+ /**
42
+ * 构建response.output_text.delta事件流
43
+ * 映射:content_part.delta (input_text/output_text/…) → response.output_text.delta
44
+ * 对于 reasoning 使用 response.reasoning_text.delta
45
+ */
46
+ export declare function buildContentPartDeltas(outputItemId: string, contentIndex: number, text: string, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): Generator<ResponsesSseEvent>;
47
+ /**
48
+ * 构建content_part.done事件
49
+ */
50
+ export declare function buildContentPartDoneEvent(outputItemId: string, contentIndex: number, content: ResponsesContent | undefined, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
51
+ export declare function buildOutputTextDoneEvent(outputItemId: string, contentIndex: number, fullText: string, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
52
+ /**
53
+ * 构建response.function_call_arguments.delta/done的start部分
54
+ * 映射:function_call.start → 隐含在第一个 delta 中
55
+ */
56
+ /**
57
+ * 构建response.function_call_arguments.delta事件流
58
+ * 映射:function_call.delta → response.function_call_arguments.delta
59
+ */
60
+ export declare function buildFunctionCallArgsDeltas(functionCall: ResponsesFunctionCallItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): Generator<ResponsesSseEvent>;
61
+ /**
62
+ * 构建response.function_call_arguments.done事件
63
+ * 映射:function_call.done → response.function_call_arguments.done
64
+ */
65
+ export declare function buildFunctionCallDoneEvent(functionCall: ResponsesFunctionCallItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
66
+ /**
67
+ * 构建reasoning.start事件
68
+ */
69
+ export declare function buildReasoningStartEvent(reasoning: ResponsesReasoningItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
70
+ /**
71
+ * 构建response.reasoning_text.delta事件流
72
+ * 映射:reasoning.delta → response.reasoning_text.delta
73
+ */
74
+ export declare function buildReasoningDeltas(reasoning: ResponsesReasoningItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): Generator<ResponsesSseEvent>;
75
+ /**
76
+ * 构建reasoning.done事件
77
+ */
78
+ export declare function buildReasoningDoneEvent(reasoning: ResponsesReasoningItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
79
+ /**
80
+ * 构建output_item.done事件
81
+ */
82
+ export declare function buildOutputItemDoneEvent(outputItem: ResponsesOutputItem, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
83
+ /**
84
+ * 构建required_action事件
85
+ */
86
+ export declare function buildRequiredActionEvent(response: ResponsesResponse, requiredAction: any, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
87
+ /**
88
+ * 构建response.completed事件
89
+ * 新增:在 done 之前增加 response.completed
90
+ */
91
+ export declare function buildResponseCompletedEvent(response: ResponsesResponse, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
92
+ /**
93
+ * 构建response.done事件
94
+ */
95
+ export declare function buildResponseDoneEvent(response: ResponsesResponse, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
96
+ /**
97
+ * 构建error事件
98
+ */
99
+ export declare function buildErrorEvent(error: Error, context: ResponsesEventGeneratorContext, config?: ResponsesEventGeneratorConfig): ResponsesSseEvent;
@@ -1,5 +1,6 @@
1
1
  import { PassThrough } from 'node:stream';
2
- import { GeminiResponse, GeminiJsonToSseOptions, DEFAULT_GEMINI_CONVERSION_CONFIG } from '../types/index.js';
2
+ import { DEFAULT_GEMINI_CONVERSION_CONFIG } from '../types/index.js';
3
+ import type { GeminiResponse, GeminiJsonToSseOptions } from '../types/index.js';
3
4
  export declare class GeminiJsonToSseConverter {
4
5
  private config;
5
6
  private contexts;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Responses JSON → SSE转换器(重构版本)
3
+ * 使用函数化架构:事件生成 + 序列化 + 写入分离
4
+ */
5
+ import { DEFAULT_RESPONSES_CONVERSION_CONFIG } from '../types/index.js';
6
+ import type { ResponsesRequest, ResponsesResponse, ResponsesJsonToSseContext, ResponsesJsonToSseOptions, ResponsesSseEventStream } from '../types/index.js';
7
+ /**
8
+ * 重构后的Responses JSON到SSE转换器
9
+ * 采用函数化架构,专注于编排而非具体业务逻辑
10
+ */
11
+ export declare class ResponsesJsonToSseConverterRefactored {
12
+ private config;
13
+ private contexts;
14
+ constructor(config?: Partial<typeof DEFAULT_RESPONSES_CONVERSION_CONFIG>);
15
+ /**
16
+ * 将Responses请求转换为SSE流
17
+ */
18
+ convertRequestToJsonToSse(request: ResponsesRequest, options: ResponsesJsonToSseOptions): Promise<ResponsesSseEventStream>;
19
+ /**
20
+ * 将Responses响应转换为SSE流
21
+ */
22
+ convertResponseToJsonToSse(response: ResponsesResponse, options: ResponsesJsonToSseOptions): Promise<ResponsesSseEventStream>;
23
+ /**
24
+ * 使用函数化架构处理请求转换
25
+ */
26
+ private processRequestToSseWithFunctions;
27
+ /**
28
+ * 使用函数化架构处理响应转换
29
+ */
30
+ private processResponseToSseWithFunctions;
31
+ /**
32
+ * 验证请求格式
33
+ */
34
+ private validateRequest;
35
+ /**
36
+ * 验证响应格式
37
+ */
38
+ private validateResponse;
39
+ /**
40
+ * 更新统计信息
41
+ */
42
+ private updateStats;
43
+ /**
44
+ * 包装错误
45
+ */
46
+ private wrapError;
47
+ /**
48
+ * 处理流错误
49
+ */
50
+ private handleStreamError;
51
+ /**
52
+ * 完成流
53
+ */
54
+ private completeStream;
55
+ /**
56
+ * 中止流
57
+ */
58
+ private abortStream;
59
+ /**
60
+ * 创建请求上下文
61
+ */
62
+ private createRequestContext;
63
+ /**
64
+ * 创建响应上下文
65
+ */
66
+ private createResponseContext;
67
+ /**
68
+ * 获取上下文
69
+ */
70
+ getContext(requestId: string): ResponsesJsonToSseContext | undefined;
71
+ /**
72
+ * 清理上下文
73
+ */
74
+ clearContext(requestId: string): void;
75
+ /**
76
+ * 获取所有活跃的上下文
77
+ */
78
+ getActiveContexts(): Map<string, ResponsesJsonToSseContext>;
79
+ }
80
+ export declare const ResponsesJsonToSseConverter: typeof ResponsesJsonToSseConverterRefactored;
@@ -1,4 +1,4 @@
1
- import { AnthropicMessageResponse, AnthropicSseEvent } from '../../types/index.js';
1
+ import type { AnthropicMessageResponse, AnthropicSseEvent } from '../../types/index.js';
2
2
  import type { ChatReasoningMode } from '../../types/chat-types.js';
3
3
  export interface AnthropicSequencerConfig {
4
4
  chunkSize: number;
@@ -2,8 +2,8 @@
2
2
  * Chat协议事件编排器
3
3
  * 负责严格的事件时序组合:role → content OR tool_calls(name → args.delta*) → finish_reason → done
4
4
  */
5
- import { ChatCompletionResponse, ChatReasoningMode, ChatSseEvent } from '../../types/index.js';
6
- import { ChatEventGeneratorContext, ChatEventGeneratorConfig } from '../event-generators/chat.js';
5
+ import type { ChatCompletionResponse, ChatReasoningMode, ChatSseEvent } from '../../types/index.js';
6
+ import type { ChatEventGeneratorContext, ChatEventGeneratorConfig } from '../event-generators/chat.js';
7
7
  export interface ChatSequencerConfig extends ChatEventGeneratorConfig {
8
8
  includeSequenceNumbers: boolean;
9
9
  enableDelay: boolean;
@@ -1,4 +1,4 @@
1
- import { GeminiResponse, GeminiSseEvent } from '../../types/index.js';
1
+ import type { GeminiResponse, GeminiSseEvent } from '../../types/index.js';
2
2
  import type { ChatReasoningMode } from '../../types/chat-types.js';
3
3
  export interface GeminiSequencerConfig {
4
4
  chunkDelayMs: number;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Responses协议事件编排器
3
+ * 负责将Responses响应数据转换为有序的SSE事件流
4
+ */
5
+ import type { ResponsesResponse, ResponsesFunctionCallOutputItem, ResponsesSseEvent } from '../../types/index.js';
6
+ import type { ResponsesEventGeneratorContext, ResponsesEventGeneratorConfig } from '../event-generators/responses.js';
7
+ export interface ResponsesSequencerConfig extends ResponsesEventGeneratorConfig {
8
+ enableValidation: boolean;
9
+ enableRecovery: boolean;
10
+ enableDelay: boolean;
11
+ maxOutputItems: number;
12
+ maxContentParts: number;
13
+ submittedToolOutputs?: ResponsesFunctionCallOutputItem[];
14
+ }
15
+ export declare const DEFAULT_RESPONSES_SEQUENCER_CONFIG: ResponsesSequencerConfig;
16
+ /**
17
+ * 主编排器:将Responses响应转换为有序的SSE事件流
18
+ */
19
+ export declare function sequenceResponse(response: ResponsesResponse, context: ResponsesEventGeneratorContext, config?: ResponsesSequencerConfig): AsyncGenerator<ResponsesSseEvent>;
20
+ /**
21
+ * 序列化Responses请求(用于请求→SSE转换)
22
+ */
23
+ export declare function sequenceRequest(request: any, context: ResponsesEventGeneratorContext, config?: ResponsesSequencerConfig): AsyncGenerator<ResponsesSseEvent>;
24
+ /**
25
+ * 创建Responses事件序列化器工厂
26
+ */
27
+ export declare function createResponsesSequencer(config?: Partial<ResponsesSequencerConfig>): {
28
+ /**
29
+ * 序列化响应
30
+ */
31
+ sequenceResponse(response: ResponsesResponse, requestId: string): AsyncGenerator<ResponsesSseEvent, void, any>;
32
+ /**
33
+ * 序列化请求
34
+ */
35
+ sequenceRequest(request: any, requestId: string): AsyncGenerator<ResponsesSseEvent, void, any>;
36
+ /**
37
+ * 获取当前配置
38
+ */
39
+ getConfig(): ResponsesSequencerConfig;
40
+ };
@@ -0,0 +1,4 @@
1
+ import { PassThrough, Readable } from 'node:stream';
2
+ import type { ChatSseEvent } from '../types/index.js';
3
+ export declare function serializeChatEventToSSE(evt: ChatSseEvent): string;
4
+ export declare function toSSETextStream(objectEventStream: Readable): PassThrough;
@@ -0,0 +1,272 @@
1
+ /**
2
+ * 共享常量定义
3
+ * 定义JSON↔SSE双向转换中使用的常量
4
+ */
5
+ export declare const PROTOCOL_TYPES: {
6
+ readonly CHAT: "chat";
7
+ readonly RESPONSES: "responses";
8
+ };
9
+ export declare const CONVERSION_DIRECTIONS: {
10
+ readonly JSON_TO_SSE: "json_to_sse";
11
+ readonly SSE_TO_JSON: "sse_to_json";
12
+ };
13
+ export declare const TIMEOUT_CONSTANTS: {
14
+ readonly DEFAULT_TIMEOUT_MS: 30000;
15
+ readonly HEARTBEAT_INTERVAL_MS: 15000;
16
+ readonly INACTIVITY_TIMEOUT_MS: 60000;
17
+ readonly EVENT_PROCESSING_TIMEOUT_MS: 5000;
18
+ readonly CHUNK_TIMEOUT_MS: 10000;
19
+ readonly TOTAL_TIMEOUT_MS: 300000;
20
+ };
21
+ export declare const CHUNK_CONSTANTS: {
22
+ readonly DEFAULT_CHUNK_SIZE: 12;
23
+ readonly DEFAULT_DELAY_MS: 8;
24
+ readonly REASONING_CHUNK_SIZE: 24;
25
+ readonly TEXT_CHUNK_SIZE: 12;
26
+ readonly FUNCTION_CALL_CHUNK_SIZE: 24;
27
+ readonly MAX_CHUNK_SIZE: 1024;
28
+ readonly MIN_CHUNK_SIZE: 1;
29
+ };
30
+ export declare const BUFFER_CONSTANTS: {
31
+ readonly DEFAULT_BUFFER_SIZE: 1000;
32
+ readonly MAX_BUFFER_SIZE: 10000;
33
+ readonly HIGH_WATER_MARK: 8000;
34
+ readonly LOW_WATER_MARK: 2000;
35
+ readonly BACKPRESSURE_THRESHOLD: 0.8;
36
+ };
37
+ export declare const RETRY_CONSTANTS: {
38
+ readonly DEFAULT_MAX_RETRIES: 3;
39
+ readonly INITIAL_DELAY_MS: 1000;
40
+ readonly MAX_DELAY_MS: 30000;
41
+ readonly BACKOFF_MULTIPLIER: 2;
42
+ readonly JITTER_FACTOR: 0.1;
43
+ };
44
+ export declare const VALIDATION_CONSTANTS: {
45
+ readonly MAX_SEQUENCE_NUMBER: 10000;
46
+ readonly MAX_OUTPUT_ITEMS: 100;
47
+ readonly MAX_CONTENT_PARTS: 1000;
48
+ readonly MAX_TOOL_CALLS: 50;
49
+ readonly MAX_MESSAGE_LENGTH: 1000000;
50
+ readonly MAX_ARGUMENTS_LENGTH: 100000;
51
+ };
52
+ export declare const ERROR_CODES: {
53
+ readonly TIMEOUT: "TIMEOUT";
54
+ readonly INVALID_INPUT: "INVALID_INPUT";
55
+ readonly PARSE_ERROR: "PARSE_ERROR";
56
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
57
+ readonly STREAM_ERROR: "STREAM_ERROR";
58
+ readonly CHAT_TIMEOUT: "CHAT_TIMEOUT";
59
+ readonly CHAT_INVALID_CHUNK: "CHAT_INVALID_CHUNK";
60
+ readonly CHAT_SEQUENCE_ERROR: "CHAT_SEQUENCE_ERROR";
61
+ readonly CHAT_TOOL_CALL_ERROR: "CHAT_TOOL_CALL_ERROR";
62
+ readonly CHAT_PARSE_ERROR: "CHAT_PARSE_ERROR";
63
+ readonly CHAT_VALIDATION_ERROR: "CHAT_VALIDATION_ERROR";
64
+ readonly CHAT_STREAM_ERROR: "CHAT_STREAM_ERROR";
65
+ readonly RESPONSES_TIMEOUT: "RESPONSES_TIMEOUT";
66
+ readonly RESPONSES_INVALID_EVENT: "RESPONSES_INVALID_EVENT";
67
+ readonly RESPONSES_SEQUENCE_ERROR: "RESPONSES_SEQUENCE_ERROR";
68
+ readonly RESPONSES_OUTPUT_ITEM_ERROR: "RESPONSES_OUTPUT_ITEM_ERROR";
69
+ readonly RESPONSES_CONTENT_PART_ERROR: "RESPONSES_CONTENT_PART_ERROR";
70
+ readonly RESPONSES_PARSE_ERROR: "RESPONSES_PARSE_ERROR";
71
+ readonly RESPONSES_VALIDATION_ERROR: "RESPONSES_VALIDATION_ERROR";
72
+ readonly RESPONSES_STREAM_ERROR: "RESPONSES_STREAM_ERROR";
73
+ };
74
+ export declare const STREAM_STATUS: {
75
+ readonly IDLE: "idle";
76
+ readonly STARTING: "starting";
77
+ readonly ACTIVE: "active";
78
+ readonly PAUSED: "paused";
79
+ readonly COMPLETING: "completing";
80
+ readonly COMPLETED: "completed";
81
+ readonly ERROR: "error";
82
+ readonly TIMEOUT: "timeout";
83
+ readonly ABORTED: "aborted";
84
+ };
85
+ export declare const CHAT_EVENT_TYPES: {
86
+ readonly CHUNK: "chat_chunk";
87
+ readonly DONE: "chat.done";
88
+ readonly ERROR: "error";
89
+ readonly PING: "ping";
90
+ };
91
+ export declare const RESPONSES_EVENT_TYPES: {
92
+ readonly RESPONSE_CREATED: "response.created";
93
+ readonly RESPONSE_IN_PROGRESS: "response.in_progress";
94
+ readonly RESPONSE_COMPLETED: "response.completed";
95
+ readonly RESPONSE_REQUIRED_ACTION: "response.required_action";
96
+ readonly RESPONSE_DONE: "response.done";
97
+ readonly OUTPUT_ITEM_ADDED: "response.output_item.added";
98
+ readonly OUTPUT_ITEM_DONE: "response.output_item.done";
99
+ readonly CONTENT_PART_ADDED: "response.content_part.added";
100
+ readonly CONTENT_PART_DONE: "response.content_part.done";
101
+ readonly OUTPUT_TEXT_DELTA: "response.output_text.delta";
102
+ readonly OUTPUT_TEXT_DONE: "response.output_text.done";
103
+ readonly REASONING_TEXT_DELTA: "response.reasoning_text.delta";
104
+ readonly REASONING_TEXT_DONE: "response.reasoning_text.done";
105
+ readonly FUNCTION_CALL_ARGUMENTS_DELTA: "response.function_call_arguments.delta";
106
+ readonly FUNCTION_CALL_ARGUMENTS_DONE: "response.function_call_arguments.done";
107
+ };
108
+ export declare const OUTPUT_ITEM_TYPES: {
109
+ readonly REASONING: "reasoning";
110
+ readonly MESSAGE: "message";
111
+ readonly FUNCTION_CALL: "function_call";
112
+ readonly SYSTEM_MESSAGE: "system_message";
113
+ readonly FUNCTION_CALL_OUTPUT: "function_call_output";
114
+ };
115
+ export declare const CONTENT_PART_TYPES: {
116
+ readonly REASONING_TEXT: "reasoning_text";
117
+ readonly REASONING_SIGNATURE: "reasoning_signature";
118
+ readonly REASONING_IMAGE: "reasoning_image";
119
+ readonly OUTPUT_TEXT: "output_text";
120
+ readonly INPUT_TEXT: "input_text";
121
+ readonly INPUT_IMAGE: "input_image";
122
+ readonly COMMENTARY: "commentary";
123
+ };
124
+ export declare const TOOL_CALL_TYPES: {
125
+ readonly FUNCTION: "function";
126
+ };
127
+ export declare const RESPONSE_STATUS: {
128
+ readonly IN_PROGRESS: "in_progress";
129
+ readonly REQUIRES_ACTION: "requires_action";
130
+ readonly COMPLETED: "completed";
131
+ readonly FAILED: "failed";
132
+ readonly INCOMPLETE: "incomplete";
133
+ };
134
+ export declare const FINISH_REASONS: {
135
+ readonly STOP: "stop";
136
+ readonly LENGTH: "length";
137
+ readonly TOOL_CALLS: "tool_calls";
138
+ readonly CONTENT_FILTER: "content_filter";
139
+ readonly FUNCTION_CALL: "function_call";
140
+ };
141
+ export declare const REQUIRED_ACTION_TYPES: {
142
+ readonly SUBMIT_TOOL_OUTPUTS: "submit_tool_outputs";
143
+ readonly RUN_PARALLEL_TOOLS: "run_parallel_tools";
144
+ };
145
+ export declare const DEFAULT_CONFIG: {
146
+ readonly TIMEOUT_MS: 30000;
147
+ readonly HEARTBEAT_INTERVAL_MS: 15000;
148
+ readonly CHUNK_SIZE: 12;
149
+ readonly DELAY_MS: 8;
150
+ readonly VALIDATION_MODE: "basic";
151
+ readonly DEBUG_MODE: false;
152
+ readonly CHAT: {
153
+ readonly TIMEOUT_MS: 30000;
154
+ readonly HEARTBEAT_INTERVAL_MS: 15000;
155
+ readonly CHUNK_DELAY_MS: 10;
156
+ readonly MAX_TOKENS_PER_CHUNK: 100;
157
+ readonly VALIDATE_CHUNKS: true;
158
+ readonly STRICT_MODE: false;
159
+ readonly VALIDATE_TOOL_CALLS: true;
160
+ readonly MAX_CONCURRENT_CHOICES: 10;
161
+ readonly MAX_CONCURRENT_TOOL_CALLS: 50;
162
+ };
163
+ readonly RESPONSES: {
164
+ readonly TIMEOUT_MS: 30000;
165
+ readonly HEARTBEAT_INTERVAL_MS: 15000;
166
+ readonly REASONING_CHUNK_SIZE: 24;
167
+ readonly TEXT_CHUNK_SIZE: 12;
168
+ readonly FUNCTION_CALL_CHUNK_SIZE: 24;
169
+ readonly ENABLE_EVENT_VALIDATION: true;
170
+ readonly ENABLE_SEQUENCE_VALIDATION: true;
171
+ readonly STRICT_MODE: false;
172
+ readonly VALIDATE_OUTPUT_ITEMS: true;
173
+ readonly MAX_CONCURRENT_OUTPUT_ITEMS: 10;
174
+ readonly MAX_CONCURRENT_CONTENT_PARTS: 50;
175
+ };
176
+ };
177
+ export declare const ENV_KEYS: {
178
+ readonly SSE_DEFAULT_TIMEOUT_MS: "SSE_DEFAULT_TIMEOUT_MS";
179
+ readonly SSE_HEARTBEAT_INTERVAL_MS: "SSE_HEARTBEAT_INTERVAL_MS";
180
+ readonly SSE_INACTIVITY_TIMEOUT_MS: "SSE_INACTIVITY_TIMEOUT_MS";
181
+ readonly SSE_EVENT_PROCESSING_TIMEOUT_MS: "SSE_EVENT_PROCESSING_TIMEOUT_MS";
182
+ readonly SSE_DEFAULT_CHUNK_SIZE: "SSE_DEFAULT_CHUNK_SIZE";
183
+ readonly SSE_DEFAULT_DELAY_MS: "SSE_DEFAULT_DELAY_MS";
184
+ readonly SSE_REASONING_CHUNK_SIZE: "SSE_REASONING_CHUNK_SIZE";
185
+ readonly SSE_TEXT_CHUNK_SIZE: "SSE_TEXT_CHUNK_SIZE";
186
+ readonly SSE_ARGS_CHUNK_SIZE: "SSE_ARGS_CHUNK_SIZE";
187
+ readonly SSE_ARGS_DELAY_MS: "SSE_ARGS_DELAY_MS";
188
+ readonly SSE_MAX_BUFFER_SIZE: "SSE_MAX_BUFFER_SIZE";
189
+ readonly SSE_HIGH_WATER_MARK: "SSE_HIGH_WATER_MARK";
190
+ readonly SSE_LOW_WATER_MARK: "SSE_LOW_WATER_MARK";
191
+ readonly SSE_ENABLE_VALIDATION: "SSE_ENABLE_VALIDATION";
192
+ readonly SSE_ENABLE_SEQUENCE_VALIDATION: "SSE_ENABLE_SEQUENCE_VALIDATION";
193
+ readonly SSE_MAX_SEQUENCE_NUMBER: "SSE_MAX_SEQUENCE_NUMBER";
194
+ readonly SSE_STRICT_MODE: "SSE_STRICT_MODE";
195
+ readonly SSE_DEBUG_EVENTS: "SSE_DEBUG_EVENTS";
196
+ readonly SSE_DEBUG_MODE: "SSE_DEBUG_MODE";
197
+ readonly SSE_LOG_LEVEL: "SSE_LOG_LEVEL";
198
+ readonly SSE_ENABLE_METRICS: "SSE_ENABLE_METRICS";
199
+ readonly RCC_STREAM_HEARTBEAT: "RCC_STREAM_HEARTBEAT";
200
+ readonly RCC_STREAM_PRE_HEARTBEAT: "RCC_STREAM_PRE_HEARTBEAT";
201
+ readonly RCC_RESP_GENERIC_ONMESSAGE: "RCC_RESP_GENERIC_ONMESSAGE";
202
+ readonly LMSTUDIO_BASE_URL: "LMSTUDIO_BASEURL";
203
+ readonly LMSTUDIO_API_KEY: "LMSTUDIO_API_KEY";
204
+ };
205
+ export declare const HTTP_STATUS_CODES: {
206
+ readonly OK: 200;
207
+ readonly BAD_REQUEST: 400;
208
+ readonly UNAUTHORIZED: 401;
209
+ readonly FORBIDDEN: 403;
210
+ readonly NOT_FOUND: 404;
211
+ readonly METHOD_NOT_ALLOWED: 405;
212
+ readonly TIMEOUT: 408;
213
+ readonly TOO_MANY_REQUESTS: 429;
214
+ readonly INTERNAL_SERVER_ERROR: 500;
215
+ readonly BAD_GATEWAY: 502;
216
+ readonly SERVICE_UNAVAILABLE: 503;
217
+ readonly GATEWAY_TIMEOUT: 504;
218
+ };
219
+ export declare const CONTENT_TYPES: {
220
+ readonly JSON: "application/json";
221
+ readonly SSE: "text/event-stream";
222
+ readonly TEXT: "text/plain";
223
+ readonly HTML: "text/html";
224
+ };
225
+ export declare const SSE_FIELDS: {
226
+ readonly EVENT: "event";
227
+ readonly DATA: "data";
228
+ readonly ID: "id";
229
+ readonly RETRY: "retry";
230
+ };
231
+ export declare const STANDARD_SSE_EVENTS: {
232
+ readonly OPEN: "open";
233
+ readonly MESSAGE: "message";
234
+ readonly ERROR: "error";
235
+ readonly CLOSE: "close";
236
+ };
237
+ export declare const CACHE_PREFIXES: {
238
+ readonly CONVERSION: "conversion:";
239
+ readonly VALIDATION: "validation:";
240
+ readonly METRICS: "metrics:";
241
+ readonly CONFIG: "config:";
242
+ };
243
+ export declare const METRIC_NAMES: {
244
+ readonly CONVERSION_REQUESTS_TOTAL: "conversion_requests_total";
245
+ readonly CONVERSION_ERRORS_TOTAL: "conversion_errors_total";
246
+ readonly EVENTS_PROCESSED_TOTAL: "events_processed_total";
247
+ readonly TIMEOUTS_TOTAL: "timeouts_total";
248
+ readonly CONVERSION_DURATION_SECONDS: "conversion_duration_seconds";
249
+ readonly EVENT_PROCESSING_DURATION_SECONDS: "event_processing_duration_seconds";
250
+ readonly BUFFER_SIZE_BYTES: "buffer_size_bytes";
251
+ readonly ACTIVE_CONVERSIONS: "active_conversions";
252
+ readonly BUFFER_UTILIZATION_RATIO: "buffer_utilization_ratio";
253
+ readonly ERROR_RATE: "error_rate";
254
+ };
255
+ export declare const LOG_LEVELS: {
256
+ readonly DEBUG: "debug";
257
+ readonly INFO: "info";
258
+ readonly WARN: "warn";
259
+ readonly ERROR: "error";
260
+ };
261
+ export declare const REGEX_PATTERNS: {
262
+ readonly WORD_BOUNDARY: RegExp;
263
+ readonly SENTENCE_BOUNDARY: RegExp;
264
+ readonly PARAGRAPH_BOUNDARY: RegExp;
265
+ readonly JSON_STRING: RegExp;
266
+ readonly SSE_LINE: RegExp;
267
+ readonly SSE_DATA_LINE: RegExp;
268
+ readonly REQUEST_ID: RegExp;
269
+ readonly RESPONSE_ID: RegExp;
270
+ readonly ITEM_ID: RegExp;
271
+ readonly CALL_ID: RegExp;
272
+ };
@@ -1,2 +1,2 @@
1
- import { AnthropicSseEvent } from '../../types/index.js';
1
+ import type { AnthropicSseEvent } from '../../types/index.js';
2
2
  export declare function serializeAnthropicEventToSSE(event: AnthropicSseEvent): string;