@jsonstudio/llms 0.6.3409 → 0.6.3541
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.
- package/dist/conversion/codecs/anthropic-openai-codec.d.ts +12 -3
- package/dist/conversion/codecs/anthropic-openai-codec.js +32 -92
- package/dist/conversion/codecs/gemini-openai-codec.d.ts +6 -5
- package/dist/conversion/codecs/gemini-openai-codec.js +48 -685
- package/dist/conversion/codecs/openai-openai-codec.d.ts +1 -1
- package/dist/conversion/codecs/openai-openai-codec.js +34 -100
- package/dist/conversion/codecs/responses-openai-codec.d.ts +1 -1
- package/dist/conversion/codecs/responses-openai-codec.js +47 -159
- package/dist/conversion/compat/actions/anthropic-claude-code-system-prompt.d.ts +2 -6
- package/dist/conversion/compat/actions/anthropic-claude-code-system-prompt.js +29 -245
- package/dist/conversion/compat/actions/anthropic-claude-code-user-id.d.ts +3 -0
- package/dist/conversion/compat/actions/anthropic-claude-code-user-id.js +30 -0
- package/dist/conversion/compat/actions/antigravity-thought-signature-prepare.js +21 -232
- package/dist/conversion/compat/actions/deepseek-web-request.js +41 -276
- package/dist/conversion/compat/actions/deepseek-web-response.js +117 -855
- package/dist/conversion/compat/actions/gemini-cli-request.d.ts +1 -1
- package/dist/conversion/compat/actions/gemini-cli-request.js +20 -613
- package/dist/conversion/compat/actions/gemini-web-search.d.ts +1 -15
- package/dist/conversion/compat/actions/gemini-web-search.js +22 -69
- package/dist/conversion/compat/actions/glm-tool-extraction.d.ts +3 -2
- package/dist/conversion/compat/actions/glm-tool-extraction.js +28 -257
- package/dist/conversion/compat/actions/iflow-tool-text-fallback.d.ts +0 -8
- package/dist/conversion/compat/actions/iflow-tool-text-fallback.js +24 -206
- package/dist/conversion/compat/actions/qwen-transform.d.ts +3 -2
- package/dist/conversion/compat/actions/qwen-transform.js +30 -271
- package/dist/conversion/compat/actions/tool-text-request-guidance.js +3 -173
- package/dist/conversion/compat/actions/universal-shape-filter.d.ts +6 -23
- package/dist/conversion/compat/actions/universal-shape-filter.js +4 -383
- package/dist/conversion/hub/pipeline/compat/native-adapter-context.js +1 -0
- package/dist/conversion/pipeline/codecs/v2/anthropic-openai-pipeline.d.ts +1 -2
- package/dist/conversion/pipeline/codecs/v2/anthropic-openai-pipeline.js +50 -104
- package/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.js +12 -10
- package/dist/conversion/pipeline/codecs/v2/responses-openai-pipeline.d.ts +0 -2
- package/dist/conversion/pipeline/codecs/v2/responses-openai-pipeline.js +46 -67
- package/dist/conversion/pipeline/codecs/v2/shared/openai-chat-helpers.js +15 -40
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +47 -348
- package/dist/conversion/responses/responses-openai-bridge.js +129 -611
- package/dist/conversion/shared/chat-output-normalizer.js +6 -0
- package/dist/conversion/shared/chat-request-filters.js +1 -1
- package/dist/conversion/shared/output-content-normalizer.js +10 -0
- package/dist/conversion/shared/responses-conversation-store.js +22 -135
- package/dist/conversion/shared/responses-output-builder.d.ts +0 -2
- package/dist/conversion/shared/responses-output-builder.js +28 -318
- package/dist/conversion/shared/responses-response-utils.js +35 -86
- package/dist/conversion/shared/streaming-text-extractor.d.ts +1 -2
- package/dist/conversion/shared/streaming-text-extractor.js +13 -14
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/quota/quota-state.js +29 -7
- package/dist/quota/types.d.ts +1 -0
- package/dist/router/virtual-router/bootstrap/routing-config.js +11 -3
- package/dist/router/virtual-router/engine-legacy.d.ts +3 -3
- package/dist/router/virtual-router/engine-legacy.js +15 -7
- package/dist/router/virtual-router/engine-selection/native-compat-action-semantics.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-compat-action-semantics.js +434 -46
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +83 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +295 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-outbound-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.d.ts +7 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-resp-semantics.js +8 -1
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +383 -298
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +20 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +201 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.js +37 -0
- package/dist/router/virtual-router/engine.js +0 -38
- package/dist/router/virtual-router/features.js +44 -3
- package/dist/router/virtual-router/routing-instructions/parse.d.ts +0 -12
- package/dist/router/virtual-router/routing-instructions/parse.js +9 -389
- package/dist/router/virtual-router/stop-message-state-sync.d.ts +3 -6
- package/dist/router/virtual-router/stop-message-state-sync.js +50 -21
- package/dist/servertool/handlers/followup-request-builder.js +12 -2
- package/dist/sse/sse-to-json/anthropic-sse-to-json-converter.d.ts +1 -0
- package/dist/sse/sse-to-json/anthropic-sse-to-json-converter.js +26 -0
- package/dist/sse/sse-to-json/builders/anthropic-response-builder.js +12 -2
- package/package.json +1 -1
- package/dist/router/virtual-router/engine-legacy/route-finalize.d.ts +0 -9
- package/dist/router/virtual-router/engine-legacy/route-finalize.js +0 -84
- package/dist/router/virtual-router/engine-legacy/route-selection.d.ts +0 -17
- package/dist/router/virtual-router/engine-legacy/route-selection.js +0 -205
- package/dist/router/virtual-router/engine-legacy/route-state-allowlist.d.ts +0 -3
- package/dist/router/virtual-router/engine-legacy/route-state-allowlist.js +0 -36
- package/dist/router/virtual-router/engine-legacy/route-state.d.ts +0 -12
- package/dist/router/virtual-router/engine-legacy/route-state.js +0 -386
- package/dist/router/virtual-router/engine-legacy/routing.d.ts +0 -8
- package/dist/router/virtual-router/engine-legacy/routing.js +0 -8
|
@@ -1,285 +1,338 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import {
|
|
4
|
-
import { createRequire } from
|
|
5
|
-
import { hasCompleteNativeBinding } from
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { hasCompleteNativeBinding } from "./native-router-hotpath-policy.js";
|
|
6
|
+
function resolveLoaderModulePath() {
|
|
7
|
+
if (typeof __filename === "string" && __filename.length > 0) {
|
|
8
|
+
return __filename;
|
|
9
|
+
}
|
|
10
|
+
const stack = String(new Error().stack || "");
|
|
11
|
+
for (const line of stack.split("\n")) {
|
|
12
|
+
const match = line.match(/(file:\/\/[^\s)]+native-router-hotpath-loader\.(?:ts|js)|\/[^\s)]+native-router-hotpath-loader\.(?:ts|js))/);
|
|
13
|
+
if (!match) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const rawPath = match[1];
|
|
17
|
+
if (rawPath.startsWith("file://")) {
|
|
18
|
+
try {
|
|
19
|
+
return decodeURIComponent(new URL(rawPath).pathname);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return rawPath;
|
|
26
|
+
}
|
|
27
|
+
return path.join(process.cwd(), "src/router/virtual-router/engine-selection/native-router-hotpath-loader.ts");
|
|
28
|
+
}
|
|
29
|
+
const loaderModulePath = resolveLoaderModulePath();
|
|
30
|
+
const nodeRequire = createRequire(loaderModulePath);
|
|
31
|
+
const workspaceRoot = resolvePackageRoot(path.dirname(loaderModulePath));
|
|
8
32
|
let cachedBinding;
|
|
9
33
|
let cachedBindingCacheKey;
|
|
10
34
|
const REQUIRED_NATIVE_EXPORTS = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
35
|
+
"analyzeChatProcessMediaJson",
|
|
36
|
+
"analyzeChatWebSearchIntentJson",
|
|
37
|
+
"extractWebSearchSemanticsHintJson",
|
|
38
|
+
"extractOutputSegmentsJson",
|
|
39
|
+
"analyzeContinueExecutionInjectionJson",
|
|
40
|
+
"analyzePendingToolSyncJson",
|
|
41
|
+
"appendToolParseDiagnosticTextJson",
|
|
42
|
+
"injectToolParseDiagnosticsJson",
|
|
43
|
+
"applyReqProcessToolGovernanceJson",
|
|
44
|
+
"applyHubOperationsJson",
|
|
45
|
+
"applyReqProcessRouteSelectionJson",
|
|
46
|
+
"applyReqOutboundContextSnapshotJson",
|
|
47
|
+
"applyClaudeThinkingToolSchemaCompatJson",
|
|
48
|
+
"applyOutboundStreamPreferenceJson",
|
|
49
|
+
"applyTargetMetadataJson",
|
|
50
|
+
"applyTargetToSubjectJson",
|
|
51
|
+
"applyStopMessageInstructionJson",
|
|
52
|
+
"attachPassthroughProviderInputAuditJson",
|
|
53
|
+
"augmentContextSnapshotJson",
|
|
54
|
+
"annotatePassthroughGovernanceSkipJson",
|
|
55
|
+
"buildAnthropicToolAliasMapJson",
|
|
56
|
+
"buildOpenaiChatFromAnthropicJson",
|
|
57
|
+
"buildAnthropicFromOpenaiChatJson",
|
|
58
|
+
"buildAnthropicResponseFromChatJson",
|
|
59
|
+
"buildChatNodeResultMetadataJson",
|
|
60
|
+
"buildProcessedRequestFromChatResponseJson",
|
|
61
|
+
"applyChatProcessedRequestJson",
|
|
62
|
+
"buildChatProcessContextMetadataJson",
|
|
63
|
+
"buildChatProcessedDescriptorJson",
|
|
64
|
+
"applyClientPassthroughPatchJson",
|
|
65
|
+
"applyGovernedControlOperationsJson",
|
|
66
|
+
"applyGovernedMergeRequestJson",
|
|
67
|
+
"buildClockMarkerScheduleMessagesJson",
|
|
68
|
+
"buildClockReminderMessagesJson",
|
|
69
|
+
"buildClockReminderMetadataJson",
|
|
70
|
+
"buildProviderProtocolErrorJson",
|
|
71
|
+
"buildFormatRequestJson",
|
|
72
|
+
"buildClockStandardToolAppendOperationsJson",
|
|
73
|
+
"buildClockToolAppendOperationsJson",
|
|
74
|
+
"buildResponsesPayloadFromChatJson",
|
|
75
|
+
"buildBridgeHistoryJson",
|
|
76
|
+
"normalizeBridgeHistorySeedJson",
|
|
77
|
+
"resolveResponsesBridgeToolsJson",
|
|
78
|
+
"resolveResponsesRequestBridgeDecisionsJson",
|
|
79
|
+
"filterBridgeInputForUpstreamJson",
|
|
80
|
+
"prepareResponsesRequestEnvelopeJson",
|
|
81
|
+
"appendLocalImageBlockOnLatestUserInputJson",
|
|
82
|
+
"applyBridgeNormalizeHistoryJson",
|
|
83
|
+
"applyBridgeCaptureToolResultsJson",
|
|
84
|
+
"applyBridgeNormalizeToolIdentifiersJson",
|
|
85
|
+
"applyBridgeEnsureToolPlaceholdersJson",
|
|
86
|
+
"convertBridgeInputToChatMessagesJson",
|
|
87
|
+
"coerceBridgeRoleJson",
|
|
88
|
+
"harvestToolsJson",
|
|
89
|
+
"serializeToolArgumentsJson",
|
|
90
|
+
"pruneChatRequestPayloadJson",
|
|
91
|
+
"enforceToolCallIdStyleJson",
|
|
92
|
+
"transformToolCallIdJson",
|
|
93
|
+
"createToolCallIdTransformerJson",
|
|
94
|
+
"extractToolCallIdJson",
|
|
95
|
+
"normalizeIdValueJson",
|
|
96
|
+
"extractStreamingToolCallsJson",
|
|
97
|
+
"createStreamingToolExtractorStateJson",
|
|
98
|
+
"resetStreamingToolExtractorStateJson",
|
|
99
|
+
"feedStreamingToolExtractorJson",
|
|
100
|
+
"chunkStringJson",
|
|
101
|
+
"flattenByCommaJson",
|
|
102
|
+
"packShellArgsJson",
|
|
103
|
+
"splitCommandStringJson",
|
|
104
|
+
"repairFindMetaJson",
|
|
105
|
+
"removeTrailingUnsignedThinkingBlocksJson",
|
|
106
|
+
"filterInvalidThinkingBlocksJson",
|
|
107
|
+
"sanitizeThinkingBlockJson",
|
|
108
|
+
"hasValidThoughtSignatureJson",
|
|
109
|
+
"serializeToolOutputJson",
|
|
110
|
+
"ensureMessagesArrayJson",
|
|
111
|
+
"normalizeReasoningInChatPayloadJson",
|
|
112
|
+
"normalizeReasoningInResponsesPayloadJson",
|
|
113
|
+
"normalizeReasoningInGeminiPayloadJson",
|
|
114
|
+
"normalizeReasoningInAnthropicPayloadJson",
|
|
115
|
+
"normalizeReasoningInOpenAIPayloadJson",
|
|
116
|
+
"buildContinueExecutionOperationsJson",
|
|
117
|
+
"buildDueReminderUserMessageJson",
|
|
118
|
+
"buildGovernedFilterPayloadJson",
|
|
119
|
+
"buildPassthroughAuditJson",
|
|
120
|
+
"buildGuardedClockScheduleItemJson",
|
|
121
|
+
"buildImageAttachmentMetadataJson",
|
|
122
|
+
"buildReviewOperationsJson",
|
|
123
|
+
"buildWebSearchToolAppendOperationsJson",
|
|
124
|
+
"clampResponsesInputItemIdJson",
|
|
125
|
+
"castGovernedToolsJson",
|
|
126
|
+
"collectToolOutputsJson",
|
|
127
|
+
"buildReqInboundToolOutputSnapshotJson",
|
|
128
|
+
"mapBridgeToolsToChatJson",
|
|
129
|
+
"mapOpenaiChatToChatJson",
|
|
130
|
+
"mapOpenaiChatFromChatJson",
|
|
131
|
+
"mapChatToolsToBridgeJson",
|
|
132
|
+
"bridgeToolToChatDefinitionJson",
|
|
133
|
+
"chatToolToBridgeDefinitionJson",
|
|
134
|
+
"mapBridgeToolsToChatWithOptionsJson",
|
|
135
|
+
"mapChatToolsToBridgeWithOptionsJson",
|
|
136
|
+
"collectToolCallsFromResponsesJson",
|
|
137
|
+
"resolveFinishReasonJson",
|
|
138
|
+
"buildChatResponseFromResponsesJson",
|
|
139
|
+
"captureReqInboundResponsesContextSnapshotJson",
|
|
140
|
+
"computeQuotaBucketsJson",
|
|
141
|
+
"extractReasoningSegmentsJson",
|
|
142
|
+
"deserializeStopMessageStateJson",
|
|
143
|
+
"detectProviderResponseShapeJson",
|
|
144
|
+
"extractClockReminderDirectivesJson",
|
|
145
|
+
"extractContextLengthDiagnosticsJson",
|
|
146
|
+
"encodeMetadataPassthroughJson",
|
|
147
|
+
"prepareGeminiToolsForBridgeJson",
|
|
148
|
+
"buildGeminiToolsFromBridgeJson",
|
|
149
|
+
"pickResponsesPersistedFieldsJson",
|
|
150
|
+
"convertResponsesOutputToInputItemsJson",
|
|
151
|
+
"prepareResponsesConversationEntryJson",
|
|
152
|
+
"resumeResponsesConversationPayloadJson",
|
|
153
|
+
"extractAntigravityGeminiSessionIdJson",
|
|
154
|
+
"ensureBridgeOutputFieldsJson",
|
|
155
|
+
"lookupAntigravityPinnedAliasForSessionIdJson",
|
|
156
|
+
"unpinAntigravitySessionAliasForSessionIdJson",
|
|
157
|
+
"cacheAntigravitySessionSignatureJson",
|
|
158
|
+
"getAntigravityRequestSessionMetaJson",
|
|
159
|
+
"resetAntigravitySignatureCachesJson",
|
|
160
|
+
"coerceClientHeadersJson",
|
|
161
|
+
"extractSessionIdentifiersJson",
|
|
162
|
+
"extractTargetModelIdJson",
|
|
163
|
+
"extractClockScheduleDirectiveTextPartsJson",
|
|
164
|
+
"extractSseWrapperErrorJson",
|
|
165
|
+
"extractMetadataPassthroughJson",
|
|
166
|
+
"extractJsonToolCallsFromTextJson",
|
|
167
|
+
"extractXmlToolCallsFromTextJson",
|
|
168
|
+
"extractSimpleXmlToolsFromTextJson",
|
|
169
|
+
"extractParameterXmlToolsFromTextJson",
|
|
170
|
+
"extractInvokeToolsFromTextJson",
|
|
171
|
+
"extractToolNamespaceXmlBlocksFromTextJson",
|
|
172
|
+
"extractApplyPatchCallsFromTextJson",
|
|
173
|
+
"extractBareExecCommandFromTextJson",
|
|
174
|
+
"extractExecuteBlocksFromTextJson",
|
|
175
|
+
"extractExploredListDirectoryCallsFromTextJson",
|
|
176
|
+
"extractQwenToolCallTokensFromTextJson",
|
|
177
|
+
"extractAdapterContextMetadataFieldsJson",
|
|
178
|
+
"evaluateResponsesHostPolicyJson",
|
|
179
|
+
"enforceChatBudgetJson",
|
|
180
|
+
"resolveBudgetForModelJson",
|
|
181
|
+
"finalizeGovernedRequestJson",
|
|
182
|
+
"governResponseJson",
|
|
183
|
+
"governToolNameResponseJson",
|
|
184
|
+
"findLastUserMessageIndexJson",
|
|
185
|
+
"injectContinueExecutionDirectiveJson",
|
|
186
|
+
"injectTimeTagIntoMessagesJson",
|
|
187
|
+
"injectMcpToolsForChatJson",
|
|
188
|
+
"injectMcpToolsForResponsesJson",
|
|
189
|
+
"mapOpenaiChatToChatJson",
|
|
190
|
+
"mapOpenaiChatFromChatJson",
|
|
191
|
+
"isStopMessageStateActiveJson",
|
|
192
|
+
"isContextLengthExceededSignalJson",
|
|
193
|
+
"isCompactionRequestJson",
|
|
194
|
+
"isShellLikeToolNameTokenJson",
|
|
195
|
+
"looksLikeJsonStreamPrefixJson",
|
|
196
|
+
"mapResumeToolOutputsDetailedJson",
|
|
197
|
+
"mergeContextToolOutputsJson",
|
|
198
|
+
"mergeToolCallsJson",
|
|
199
|
+
"mergeGovernanceSummaryIntoMetadataJson",
|
|
200
|
+
"findHeaderValueJson",
|
|
201
|
+
"normalizeAliasMapJson",
|
|
202
|
+
"normalizeMessageReasoningToolsJson",
|
|
203
|
+
"normalizeOpenaiMessageJson",
|
|
204
|
+
"normalizeOpenaiChatMessagesJson",
|
|
205
|
+
"normalizeOpenaiToolJson",
|
|
206
|
+
"normalizeOpenaiToolCallJson",
|
|
207
|
+
"normalizeChatResponseReasoningToolsJson",
|
|
208
|
+
"normalizeBridgeToolCallIdsJson",
|
|
209
|
+
"normalizeChatMessageContentJson",
|
|
210
|
+
"validateResponsePayloadJson",
|
|
211
|
+
"normalizeResponsePayloadJson",
|
|
212
|
+
"applyResponseBlacklistJson",
|
|
213
|
+
"normalizeToolCallIdsJson",
|
|
214
|
+
"normalizeResponsesToolCallIdsJson",
|
|
215
|
+
"resolveToolCallIdStyleJson",
|
|
216
|
+
"stripInternalToolingMetadataJson",
|
|
217
|
+
"enforceLmstudioResponsesFcToolCallIdsJson",
|
|
218
|
+
"applyRequestRulesJson",
|
|
219
|
+
"applyAnthropicClaudeCodeUserIdJson",
|
|
220
|
+
"applyGeminiWebSearchRequestCompatJson",
|
|
221
|
+
"prepareAntigravityThoughtSignatureForGeminiRequestJson",
|
|
222
|
+
"applyIflowToolTextFallbackJson",
|
|
223
|
+
"applyToolTextRequestGuidanceJson",
|
|
224
|
+
"applyUniversalShapeRequestFilterJson",
|
|
225
|
+
"applyUniversalShapeResponseFilterJson",
|
|
226
|
+
"runOpenaiOpenaiRequestCodecJson",
|
|
227
|
+
"runOpenaiOpenaiResponseCodecJson",
|
|
228
|
+
"runResponsesOpenaiRequestCodecJson",
|
|
229
|
+
"runResponsesOpenaiResponseCodecJson",
|
|
230
|
+
"runGeminiOpenaiRequestCodecJson",
|
|
231
|
+
"runGeminiOpenaiResponseCodecJson",
|
|
232
|
+
"runGeminiFromOpenaiChatCodecJson",
|
|
233
|
+
"normalizeArgsBySchemaJson",
|
|
234
|
+
"normalizeToolsJson",
|
|
235
|
+
"normalizeFunctionCallIdJson",
|
|
236
|
+
"normalizeFunctionCallOutputIdJson",
|
|
237
|
+
"normalizeHeaderKeyJson",
|
|
238
|
+
"normalizeHubEndpointJson",
|
|
239
|
+
"normalizeOutputContentPartJson",
|
|
240
|
+
"normalizeToolSessionMessagesJson",
|
|
241
|
+
"updateToolSessionHistoryJson",
|
|
242
|
+
"normalizeContextCaptureLabelJson",
|
|
243
|
+
"normalizeSnapshotStagePayloadJson",
|
|
244
|
+
"normalizeContextToolsJson",
|
|
245
|
+
"normalizeDueInjectTextJson",
|
|
246
|
+
"normalizeProviderProtocolTokenJson",
|
|
247
|
+
"normalizeResponsesCallIdJson",
|
|
248
|
+
"normalizeMessageContentPartsJson",
|
|
249
|
+
"normalizeShellLikeToolCallsBeforeGovernanceJson",
|
|
250
|
+
"normalizeToolCallIdStyleCandidateJson",
|
|
251
|
+
"parseClockScheduleDirectiveCandidateJson",
|
|
252
|
+
"parseLenientJsonishJson",
|
|
253
|
+
"parseJsonObjectCandidateJson",
|
|
254
|
+
"parseProviderKeyJson",
|
|
255
|
+
"parseRoutingInstructionKindsJson",
|
|
256
|
+
"parseRoutingInstructionsJson",
|
|
257
|
+
"parseStopMessageInstructionJson",
|
|
258
|
+
"pinAliasQueueJson",
|
|
259
|
+
"planChatClockOperationsJson",
|
|
260
|
+
"planChatServertoolOrchestrationBundleJson",
|
|
261
|
+
"planChatWebSearchOperationsJson",
|
|
262
|
+
"planContinueExecutionOperationsJson",
|
|
263
|
+
"resolveAliasSelectionStrategyJson",
|
|
264
|
+
"resolveBridgePolicyJson",
|
|
265
|
+
"resolveBridgePolicyActionsJson",
|
|
266
|
+
"resolveAliasMapFromRespSemanticsJson",
|
|
267
|
+
"resolveClientInjectReadyJson",
|
|
268
|
+
"resolveClientToolsRawJson",
|
|
269
|
+
"resolveClientToolsRawFromRespSemanticsJson",
|
|
270
|
+
"resolveClockReminderFlowPlanJson",
|
|
271
|
+
"resolveClockConfigJson",
|
|
272
|
+
"resolveClockSessionScopeJson",
|
|
273
|
+
"resolveClockTimeTagFallbackLineJson",
|
|
274
|
+
"resolveCompatProfileJson",
|
|
275
|
+
"resolveHasActiveStopMessageForContinueExecutionJson",
|
|
276
|
+
"resolveHasInstructionRequestedPassthroughJson",
|
|
277
|
+
"resolveHubClientProtocolJson",
|
|
278
|
+
"resolveHubProtocolSpecJson",
|
|
279
|
+
"resolveHubProtocolAllowlistsJson",
|
|
280
|
+
"resolveOutboundStreamIntentJson",
|
|
281
|
+
"resolveProviderProtocolJson",
|
|
282
|
+
"resolveHubPolicyOverrideJson",
|
|
283
|
+
"resolveHubShadowCompareConfigJson",
|
|
284
|
+
"resolveApplyPatchToolModeFromToolsJson",
|
|
285
|
+
"resolveActiveProcessModeJson",
|
|
286
|
+
"resolveStopMessageRouterMetadataJson",
|
|
287
|
+
"resolveGovernanceContextJson",
|
|
288
|
+
"resolveStopMessageSessionScopeJson",
|
|
289
|
+
"VirtualRouterEngineProxy",
|
|
290
|
+
"ensureProtocolStateJson",
|
|
291
|
+
"getProtocolStateJson",
|
|
292
|
+
"readRuntimeMetadataJson",
|
|
293
|
+
"resolveDefaultToolGovernanceRulesJson",
|
|
294
|
+
"ensureRuntimeMetadataJson",
|
|
295
|
+
"cloneRuntimeMetadataJson",
|
|
296
|
+
"applyReqInboundSemanticLiftJson",
|
|
297
|
+
"pickHeaderJson",
|
|
298
|
+
"resolveReqOutboundContextMergePlanJson",
|
|
299
|
+
"runReqOutboundStage3CompatJson",
|
|
300
|
+
"runHubPipelineJson",
|
|
301
|
+
"findMappableSemanticsKeysJson",
|
|
302
|
+
"deriveToolCallKeyJson",
|
|
303
|
+
"extractToolCallsFromReasoningTextJson",
|
|
304
|
+
"mapReasoningContentToResponsesOutputJson",
|
|
305
|
+
"validateToolArgumentsJson",
|
|
306
|
+
"repairToolCallsJson",
|
|
307
|
+
"isImagePathJson",
|
|
308
|
+
"resolveServerToolFollowupSnapshotJson",
|
|
309
|
+
"resolveSseStreamModeJson",
|
|
310
|
+
"resolveSseProtocolFromMetadataJson",
|
|
311
|
+
"repairArgumentsToStringJsonishJson",
|
|
312
|
+
"runBridgeActionPipelineJson",
|
|
313
|
+
"sanitizeChatCompletionLikeJson",
|
|
314
|
+
"sanitizeFormatEnvelopeJson",
|
|
315
|
+
"sanitizeReasoningTaggedTextJson",
|
|
316
|
+
"ensureBridgeInstructionsJson",
|
|
317
|
+
"sanitizeResponsesFunctionNameJson",
|
|
318
|
+
"shouldRecordSnapshotsJson",
|
|
319
|
+
"writeSnapshotViaHooksJson",
|
|
320
|
+
"selectToolCallIdStyleJson",
|
|
321
|
+
"serializeStopMessageStateJson",
|
|
322
|
+
"shouldAttachReqOutboundContextSnapshotJson",
|
|
323
|
+
"shouldReserveClockDueReminderJson",
|
|
324
|
+
"shouldRunHubChatProcessJson",
|
|
325
|
+
"splitAntigravityTargetsJson",
|
|
326
|
+
"stripOrphanFunctionCallsTagJson",
|
|
327
|
+
"stripClockClearDirectiveTextJson",
|
|
328
|
+
"stripChatProcessHistoricalImagesJson",
|
|
329
|
+
"stripPrivateFieldsJson",
|
|
330
|
+
"cleanRoutingInstructionMarkersJson",
|
|
278
331
|
];
|
|
279
332
|
function resolvePackageRoot(startDir) {
|
|
280
333
|
let current = startDir;
|
|
281
334
|
for (let i = 0; i < 10; i += 1) {
|
|
282
|
-
if (fs.existsSync(path.join(current,
|
|
335
|
+
if (fs.existsSync(path.join(current, "package.json"))) {
|
|
283
336
|
return current;
|
|
284
337
|
}
|
|
285
338
|
const parent = path.dirname(current);
|
|
@@ -288,39 +341,49 @@ function resolvePackageRoot(startDir) {
|
|
|
288
341
|
}
|
|
289
342
|
current = parent;
|
|
290
343
|
}
|
|
291
|
-
return path.resolve(startDir,
|
|
344
|
+
return path.resolve(startDir, "../../../../");
|
|
292
345
|
}
|
|
293
346
|
function readNativePathFromEnv() {
|
|
294
|
-
const raw = String(process.env.ROUTECODEX_LLMS_ROUTER_NATIVE_PATH ||
|
|
347
|
+
const raw = String(process.env.ROUTECODEX_LLMS_ROUTER_NATIVE_PATH ||
|
|
348
|
+
process.env.RCC_LLMS_ROUTER_NATIVE_PATH ||
|
|
349
|
+
"").trim();
|
|
295
350
|
return raw || undefined;
|
|
296
351
|
}
|
|
297
352
|
function buildNativeBindingCacheKey(envPath) {
|
|
298
353
|
if (!envPath) {
|
|
299
|
-
return
|
|
354
|
+
return "auto";
|
|
300
355
|
}
|
|
301
|
-
const resolved = path.isAbsolute(envPath)
|
|
356
|
+
const resolved = path.isAbsolute(envPath)
|
|
357
|
+
? envPath
|
|
358
|
+
: path.resolve(process.cwd(), envPath);
|
|
302
359
|
return `env:${resolved}`;
|
|
303
360
|
}
|
|
304
361
|
function resolveLoadPathForNode(resolvedPath) {
|
|
305
362
|
const ext = path.extname(resolvedPath).toLowerCase();
|
|
306
|
-
if (!ext || ext ===
|
|
363
|
+
if (!ext || ext === ".node") {
|
|
307
364
|
return resolvedPath;
|
|
308
365
|
}
|
|
309
|
-
if (ext !==
|
|
366
|
+
if (ext !== ".dylib" && ext !== ".so" && ext !== ".dll") {
|
|
310
367
|
return resolvedPath;
|
|
311
368
|
}
|
|
312
|
-
return resolvedPath.replace(/\.(dylib|so|dll)$/i,
|
|
369
|
+
return resolvedPath.replace(/\.(dylib|so|dll)$/i, ".node");
|
|
313
370
|
}
|
|
314
371
|
function tryRequireFromPath(modulePath, options) {
|
|
315
372
|
try {
|
|
316
|
-
const resolved = path.isAbsolute(modulePath)
|
|
373
|
+
const resolved = path.isAbsolute(modulePath)
|
|
374
|
+
? modulePath
|
|
375
|
+
: path.resolve(process.cwd(), modulePath);
|
|
317
376
|
const loadPath = resolveLoadPathForNode(resolved);
|
|
318
|
-
const loaded =
|
|
319
|
-
if (!loaded || typeof loaded !==
|
|
377
|
+
const loaded = nodeRequire(loadPath);
|
|
378
|
+
if (!loaded || typeof loaded !== "object") {
|
|
320
379
|
return null;
|
|
321
380
|
}
|
|
322
|
-
if (options?.requireComplete !== false &&
|
|
323
|
-
|
|
381
|
+
if (options?.requireComplete !== false &&
|
|
382
|
+
!hasCompleteNativeBinding(loaded, REQUIRED_NATIVE_EXPORTS)) {
|
|
383
|
+
// Do not reject an already-loadable native binding here.
|
|
384
|
+
// Capability-level wrappers still fail fast for any missing export,
|
|
385
|
+
// while this avoids false negatives during startup/import on some Node/NAPI path combinations.
|
|
386
|
+
return loaded;
|
|
324
387
|
}
|
|
325
388
|
return loaded;
|
|
326
389
|
}
|
|
@@ -328,11 +391,34 @@ function tryRequireFromPath(modulePath, options) {
|
|
|
328
391
|
return null;
|
|
329
392
|
}
|
|
330
393
|
}
|
|
394
|
+
function dedupePaths(paths) {
|
|
395
|
+
const seen = new Set();
|
|
396
|
+
const out = [];
|
|
397
|
+
for (const candidate of paths) {
|
|
398
|
+
const normalized = path.normalize(candidate);
|
|
399
|
+
if (seen.has(normalized)) {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
seen.add(normalized);
|
|
403
|
+
out.push(candidate);
|
|
404
|
+
}
|
|
405
|
+
return out;
|
|
406
|
+
}
|
|
407
|
+
function getModuleRelativeNativeCandidates() {
|
|
408
|
+
const loaderDir = path.dirname(loaderModulePath);
|
|
409
|
+
return dedupePaths([
|
|
410
|
+
path.resolve(loaderDir, "../../../../rust-core/target/release/router_hotpath_napi.node"),
|
|
411
|
+
path.resolve(loaderDir, "../../../../rust-core/target/debug/router_hotpath_napi.node"),
|
|
412
|
+
path.resolve(loaderDir, "../../../native/router_hotpath_napi.node"),
|
|
413
|
+
]);
|
|
414
|
+
}
|
|
331
415
|
function getWorkspaceNativeCandidates() {
|
|
332
|
-
return [
|
|
416
|
+
return dedupePaths(["release", "debug"].map((mode) => path.join(workspaceRoot, "rust-core", "target", mode, "router_hotpath_napi.node")));
|
|
333
417
|
}
|
|
334
418
|
function getPackagedNativeCandidates() {
|
|
335
|
-
return [
|
|
419
|
+
return dedupePaths([
|
|
420
|
+
path.join(workspaceRoot, "dist", "native", "router_hotpath_napi.node"),
|
|
421
|
+
]);
|
|
336
422
|
}
|
|
337
423
|
export function loadNativeRouterHotpathBinding() {
|
|
338
424
|
const envPath = readNativePathFromEnv();
|
|
@@ -349,14 +435,11 @@ export function loadNativeRouterHotpathBinding() {
|
|
|
349
435
|
if (cachedBinding)
|
|
350
436
|
return cachedBinding;
|
|
351
437
|
}
|
|
352
|
-
for (const candidate of
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
for (const candidate of getPackagedNativeCandidates()) {
|
|
438
|
+
for (const candidate of [
|
|
439
|
+
...getModuleRelativeNativeCandidates(),
|
|
440
|
+
...getWorkspaceNativeCandidates(),
|
|
441
|
+
...getPackagedNativeCandidates(),
|
|
442
|
+
]) {
|
|
360
443
|
const loaded = tryRequireFromPath(candidate);
|
|
361
444
|
if (loaded) {
|
|
362
445
|
cachedBinding = loaded;
|
|
@@ -371,6 +454,8 @@ export function resolveNativeModuleUrlFromEnv() {
|
|
|
371
454
|
if (!modulePath) {
|
|
372
455
|
return undefined;
|
|
373
456
|
}
|
|
374
|
-
const normalized = path.isAbsolute(modulePath)
|
|
457
|
+
const normalized = path.isAbsolute(modulePath)
|
|
458
|
+
? modulePath
|
|
459
|
+
: path.resolve(process.cwd(), modulePath);
|
|
375
460
|
return pathToFileURL(normalized).href;
|
|
376
461
|
}
|