@jsonstudio/llms 0.6.3685 → 0.6.3688
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/compat/actions/antigravity-thought-signature-cache.js +2 -22
- package/dist/conversion/compat/actions/deepseek-web-response.js +7 -0
- package/dist/conversion/compat/actions/field-mapping.js +153 -2
- package/dist/conversion/compat/actions/lmstudio-responses-input-stringify.js +104 -3
- package/dist/conversion/hub/node-support.js +1 -1
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +1 -9
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +28 -35
- package/dist/conversion/hub/pipeline/hub-pipeline.js +121 -197
- package/dist/conversion/hub/pipeline/hub-stage-timing.d.ts +1 -0
- package/dist/conversion/hub/pipeline/hub-stage-timing.js +14 -8
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.d.ts +4 -4
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +37 -20
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.d.ts +7 -6
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +41 -69
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +0 -3
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +1 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +0 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +0 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +2 -3
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +5 -18
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +2 -1
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +16 -0
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.d.ts +1 -1
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +50 -27
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +0 -1
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +1 -1
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.d.ts +1 -1
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +5 -9
- package/dist/conversion/hub/process/chat-process-continue-execution.js +3 -0
- package/dist/conversion/hub/process/chat-process-media.d.ts +2 -1
- package/dist/conversion/hub/process/chat-process-media.js +63 -9
- package/dist/conversion/hub/process/chat-process-session-usage.d.ts +6 -24
- package/dist/conversion/hub/process/chat-process-session-usage.js +101 -200
- package/dist/conversion/hub/response/provider-response.js +13 -13
- package/dist/conversion/hub/types/chat-envelope.d.ts +0 -1
- package/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.js +4 -0
- package/dist/conversion/responses/responses-openai-bridge.d.ts +0 -1
- package/dist/conversion/responses/responses-openai-bridge.js +34 -28
- package/dist/conversion/shared/anthropic-message-utils.js +1 -14
- package/dist/conversion/shared/reasoning-normalizer.js +22 -41
- package/dist/conversion/shared/responses-tool-utils.js +2 -3
- package/dist/conversion/shared/tool-governor.js +4 -2
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/router/virtual-router/engine/routing-state/store.js +2 -21
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +0 -1
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +0 -1
- package/dist/router/virtual-router/engine-selection/native-compat-action-semantics.d.ts +0 -3
- package/dist/router/virtual-router/engine-selection/native-compat-action-semantics.js +0 -72
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.d.ts +1 -1
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js +1 -1
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts +2 -2
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.js +96 -80
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +29 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +2 -6
- package/dist/router/virtual-router/engine.js +6 -9
- package/dist/router/virtual-router/routing-instructions/state.js +27 -37
- package/dist/router/virtual-router/routing-instructions/types.d.ts +4 -6
- package/dist/router/virtual-router/token-estimator.js +0 -21
- package/dist/servertool/handlers/stop-message-auto.js +1 -11
- package/dist/tools/apply-patch/execution-capturer.d.ts +1 -1
- package/dist/tools/apply-patch/execution-capturer.js +2 -1
- package/dist/tools/apply-patch/regression-capturer.js +1 -2
- package/dist/tools/tool-registry.js +2 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ import { captureReqInboundResponsesContextSnapshotWithNative, mapReqInboundBridg
|
|
|
9
9
|
import { appendLocalImageBlockOnLatestUserInputWithNative, buildBridgeHistoryWithNative, filterBridgeInputForUpstreamWithNative, normalizeBridgeHistorySeedWithNative, prepareResponsesRequestEnvelopeWithNative, resolveResponsesRequestBridgeDecisionsWithNative, resolveResponsesBridgeToolsWithNative, runBridgeActionPipelineWithNative } from '../../router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js';
|
|
10
10
|
// --- Utilities (ported strictly) ---
|
|
11
11
|
import { resolveBridgePolicy, resolvePolicyActions } from '../bridge-policies.js';
|
|
12
|
+
import { logHubStageTiming } from '../hub/pipeline/hub-stage-timing.js';
|
|
12
13
|
function isObject(v) {
|
|
13
14
|
return !!v && typeof v === 'object' && !Array.isArray(v);
|
|
14
15
|
}
|
|
@@ -38,20 +39,24 @@ function runNativeResponsesBridgePipeline(input) {
|
|
|
38
39
|
: undefined
|
|
39
40
|
};
|
|
40
41
|
}
|
|
42
|
+
function filterRedundantResponsesReasoningAction(actions) {
|
|
43
|
+
return actions?.filter((action) => {
|
|
44
|
+
const name = typeof action?.name === 'string' ? action.name.trim().toLowerCase() : '';
|
|
45
|
+
return name !== 'reasoning.extract';
|
|
46
|
+
});
|
|
47
|
+
}
|
|
41
48
|
// normalizeTools unified in ../args-mapping.ts
|
|
42
49
|
// NOTE: 自修复提示已移除(统一标准:不做模糊兜底)。
|
|
43
50
|
// --- Public bridge functions ---
|
|
44
51
|
export function captureResponsesContext(payload, dto) {
|
|
45
|
-
const preservedInput =
|
|
52
|
+
const preservedInput = Array.isArray(payload.input)
|
|
53
|
+
? payload.input
|
|
54
|
+
: undefined;
|
|
46
55
|
ensureBridgeInstructions(payload);
|
|
47
|
-
const requestForCapture = {
|
|
48
|
-
...payload,
|
|
49
|
-
...(preservedInput ? { input: preservedInput } : {})
|
|
50
|
-
};
|
|
51
56
|
const captured = captureReqInboundResponsesContextSnapshotWithNative({
|
|
52
|
-
rawRequest:
|
|
57
|
+
rawRequest: payload,
|
|
53
58
|
requestId: dto?.route?.requestId,
|
|
54
|
-
toolCallIdStyle: payload?.toolCallIdStyle
|
|
59
|
+
toolCallIdStyle: payload?.toolCallIdStyle ?? payload?.metadata?.toolCallIdStyle
|
|
55
60
|
});
|
|
56
61
|
const instructionReasoning = payload?.__rcc_reasoning_instructions;
|
|
57
62
|
if (instructionReasoning !== undefined && instructionReasoning !== null) {
|
|
@@ -71,30 +76,40 @@ export function captureResponsesContext(payload, dto) {
|
|
|
71
76
|
}
|
|
72
77
|
if (captured.metadata && isJsonObject(captured.metadata)) {
|
|
73
78
|
const cloned = jsonClone(captured.metadata);
|
|
74
|
-
delete cloned.toolCallIdStyle;
|
|
75
79
|
delete cloned.extraFields;
|
|
76
80
|
captured.metadata = cloned;
|
|
77
81
|
}
|
|
78
82
|
return captured;
|
|
79
83
|
}
|
|
80
84
|
export function buildChatRequestFromResponses(payload, context) {
|
|
85
|
+
const requestId = typeof context.requestId === 'string' && context.requestId.trim().length
|
|
86
|
+
? context.requestId
|
|
87
|
+
: 'unknown';
|
|
81
88
|
// V3: 对 Responses 路径仅做“形状转换”,不做参数解析/修复。
|
|
82
89
|
// 将顶层 { type,name,description,parameters,strict } 归一为 OpenAI Chat tools 形状:
|
|
83
90
|
// { type:'function', function:{ name,description,parameters,strict? } }
|
|
84
91
|
const toolsNormalized = Array.isArray(context.toolsNormalized) && context.toolsNormalized.length
|
|
85
|
-
?
|
|
92
|
+
? context.toolsNormalized
|
|
86
93
|
: mapReqInboundBridgeToolsToChatWithNative(payload.tools);
|
|
87
94
|
// 不在 Responses 路径进行 MCP 工具注入;统一由 Chat 后半段治理注入
|
|
95
|
+
logHubStageTiming(requestId, 'req_inbound.responses.convert_input_to_messages', 'start');
|
|
96
|
+
const convertStart = Date.now();
|
|
88
97
|
let messages = convertBridgeInputToChatMessages({
|
|
89
98
|
input: context.input,
|
|
90
99
|
tools: toolsNormalized,
|
|
91
100
|
normalizeFunctionName: 'responses',
|
|
92
101
|
toolResultFallbackText: 'Command succeeded (no output).'
|
|
93
102
|
});
|
|
103
|
+
logHubStageTiming(requestId, 'req_inbound.responses.convert_input_to_messages', 'completed', {
|
|
104
|
+
elapsedMs: Date.now() - convertStart,
|
|
105
|
+
forceLog: true
|
|
106
|
+
});
|
|
94
107
|
try {
|
|
95
108
|
const bridgePolicy = resolveBridgePolicy({ protocol: 'openai-responses', moduleType: 'openai-responses' });
|
|
96
|
-
const policyActions = resolvePolicyActions(bridgePolicy, 'request_inbound');
|
|
109
|
+
const policyActions = filterRedundantResponsesReasoningAction(resolvePolicyActions(bridgePolicy, 'request_inbound'));
|
|
97
110
|
if (policyActions?.length) {
|
|
111
|
+
logHubStageTiming(requestId, 'req_inbound.responses.inbound_policy', 'start');
|
|
112
|
+
const policyStart = Date.now();
|
|
98
113
|
const actionState = runNativeResponsesBridgePipeline({
|
|
99
114
|
stage: 'request_inbound',
|
|
100
115
|
actions: policyActions,
|
|
@@ -106,6 +121,10 @@ export function buildChatRequestFromResponses(payload, context) {
|
|
|
106
121
|
rawRequest: payload
|
|
107
122
|
});
|
|
108
123
|
messages = actionState.messages;
|
|
124
|
+
logHubStageTiming(requestId, 'req_inbound.responses.inbound_policy', 'completed', {
|
|
125
|
+
elapsedMs: Date.now() - policyStart,
|
|
126
|
+
forceLog: true
|
|
127
|
+
});
|
|
109
128
|
}
|
|
110
129
|
}
|
|
111
130
|
catch {
|
|
@@ -172,13 +191,16 @@ export function buildResponsesRequestFromChat(payload, ctx, extras) {
|
|
|
172
191
|
const chat = unwrapData(payload);
|
|
173
192
|
const out = {};
|
|
174
193
|
const envelopeMetadata = ctx?.metadata && typeof ctx.metadata === 'object' ? ctx.metadata : undefined;
|
|
194
|
+
const requestMetadata = chat && typeof chat === 'object' && chat.metadata && typeof chat.metadata === 'object'
|
|
195
|
+
? chat.metadata
|
|
196
|
+
: undefined;
|
|
175
197
|
// 基本字段
|
|
176
198
|
out.model = chat.model;
|
|
177
199
|
let messages = Array.isArray(chat.messages) ? chat.messages : [];
|
|
178
200
|
let bridgeMetadata;
|
|
179
201
|
try {
|
|
180
202
|
const bridgePolicy = resolveBridgePolicy({ protocol: 'openai-responses', moduleType: 'openai-responses' });
|
|
181
|
-
const policyActions = resolvePolicyActions(bridgePolicy, 'request_outbound');
|
|
203
|
+
const policyActions = filterRedundantResponsesReasoningAction(resolvePolicyActions(bridgePolicy, 'request_outbound'));
|
|
182
204
|
if (policyActions?.length) {
|
|
183
205
|
const actionState = runNativeResponsesBridgePipeline({
|
|
184
206
|
stage: 'request_outbound',
|
|
@@ -201,7 +223,7 @@ export function buildResponsesRequestFromChat(payload, ctx, extras) {
|
|
|
201
223
|
const metadataExtraFields = extractMetadataExtraFields(envelopeMetadata);
|
|
202
224
|
const bridgeDecisions = resolveResponsesRequestBridgeDecisionsWithNative({
|
|
203
225
|
context: ctx && typeof ctx === 'object' ? ctx : undefined,
|
|
204
|
-
|
|
226
|
+
requestMetadata,
|
|
205
227
|
envelopeMetadata,
|
|
206
228
|
bridgeMetadata,
|
|
207
229
|
extraBridgeHistory: extras?.bridgeHistory
|
|
@@ -302,22 +324,6 @@ export function buildResponsesRequestFromChat(payload, ctx, extras) {
|
|
|
302
324
|
ensureBridgeInstructions(out);
|
|
303
325
|
return { request: out, originalSystemMessages };
|
|
304
326
|
}
|
|
305
|
-
function cloneBridgeEntries(entries) {
|
|
306
|
-
if (!Array.isArray(entries)) {
|
|
307
|
-
return undefined;
|
|
308
|
-
}
|
|
309
|
-
return entries.map((entry) => {
|
|
310
|
-
if (!entry || typeof entry !== 'object') {
|
|
311
|
-
return entry;
|
|
312
|
-
}
|
|
313
|
-
try {
|
|
314
|
-
return JSON.parse(JSON.stringify(entry));
|
|
315
|
-
}
|
|
316
|
-
catch {
|
|
317
|
-
return entry;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
327
|
function extractMetadataExtraFields(metadata) {
|
|
322
328
|
if (!metadata) {
|
|
323
329
|
return undefined;
|
|
@@ -16,9 +16,6 @@ function safeJson(v) {
|
|
|
16
16
|
return '{}';
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function pickBoolean(value) {
|
|
20
|
-
return typeof value === 'boolean' ? value : undefined;
|
|
21
|
-
}
|
|
22
19
|
function stripOpenAIChatToolAliasFields(messages) {
|
|
23
20
|
// No-op: preserve tool_call_id/call_id for downstream consumers and regression parity.
|
|
24
21
|
void messages;
|
|
@@ -205,8 +202,7 @@ const ANTHROPIC_TOP_LEVEL_FIELDS = new Set([
|
|
|
205
202
|
'metadata',
|
|
206
203
|
'stream',
|
|
207
204
|
'tool_choice',
|
|
208
|
-
'thinking'
|
|
209
|
-
'disable_parallel_tool_use'
|
|
205
|
+
'thinking'
|
|
210
206
|
]);
|
|
211
207
|
const ANTHROPIC_STABLE_TOOL_SCHEMA_NAMES = new Set([
|
|
212
208
|
'exec_command',
|
|
@@ -530,10 +526,6 @@ export function buildOpenAIChatFromAnthropic(payload, options) {
|
|
|
530
526
|
}
|
|
531
527
|
if ('tool_choice' in body)
|
|
532
528
|
request.tool_choice = body.tool_choice;
|
|
533
|
-
const disableParallelToolUse = pickBoolean(body.disable_parallel_tool_use ?? body.disableParallelToolUse);
|
|
534
|
-
if (disableParallelToolUse !== undefined) {
|
|
535
|
-
request.parallel_tool_calls = !disableParallelToolUse;
|
|
536
|
-
}
|
|
537
529
|
const normalizedTools = mapAnthropicToolsToChat(body.tools);
|
|
538
530
|
if (normalizedTools !== undefined) {
|
|
539
531
|
request.tools = normalizedTools;
|
|
@@ -1085,11 +1077,6 @@ export function buildAnthropicRequestFromOpenAIChat(chatReq) {
|
|
|
1085
1077
|
if (normalizedToolChoice !== undefined) {
|
|
1086
1078
|
out.tool_choice = normalizedToolChoice;
|
|
1087
1079
|
}
|
|
1088
|
-
const parallelToolCalls = pickBoolean(requestBody.parallel_tool_calls
|
|
1089
|
-
?? requestBody.parallelToolCalls);
|
|
1090
|
-
if (parallelToolCalls !== undefined) {
|
|
1091
|
-
out.disable_parallel_tool_use = !parallelToolCalls;
|
|
1092
|
-
}
|
|
1093
1080
|
if (requestBody.thinking !== undefined) {
|
|
1094
1081
|
try {
|
|
1095
1082
|
out.thinking = JSON.parse(JSON.stringify(requestBody.thinking));
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { normalizeReasoningInAnthropicPayloadWithNative, normalizeReasoningInChatPayloadWithNative, normalizeReasoningInGeminiPayloadWithNative, normalizeReasoningInOpenAIPayloadWithNative, normalizeReasoningInResponsesPayloadWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
2
|
export const RESPONSES_INSTRUCTIONS_REASONING_FIELD = '__rcc_reasoning_instructions';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
lower.includes('``` think') ||
|
|
15
|
-
lower.includes('``` reflection'));
|
|
3
|
+
const REASONING_TEXT_MARKERS = [
|
|
4
|
+
'<think',
|
|
5
|
+
'</think',
|
|
6
|
+
'<reflection',
|
|
7
|
+
'</reflection',
|
|
8
|
+
'```think',
|
|
9
|
+
'```reflection'
|
|
10
|
+
];
|
|
11
|
+
function stringHasReasoningMarker(value) {
|
|
12
|
+
const lower = value.toLowerCase();
|
|
13
|
+
return REASONING_TEXT_MARKERS.some((marker) => lower.includes(marker));
|
|
16
14
|
}
|
|
17
15
|
function valueMayContainReasoningMarkup(value) {
|
|
18
16
|
if (typeof value === 'string') {
|
|
19
|
-
return
|
|
17
|
+
return stringHasReasoningMarker(value);
|
|
18
|
+
}
|
|
19
|
+
if (!value || typeof value !== 'object') {
|
|
20
|
+
return false;
|
|
20
21
|
}
|
|
21
22
|
if (Array.isArray(value)) {
|
|
22
23
|
for (const entry of value) {
|
|
@@ -26,38 +27,14 @@ function valueMayContainReasoningMarkup(value) {
|
|
|
26
27
|
}
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
for (const entry of Object.values(value)) {
|
|
30
|
+
const record = value;
|
|
31
|
+
for (const entry of Object.values(record)) {
|
|
33
32
|
if (valueMayContainReasoningMarkup(entry)) {
|
|
34
33
|
return true;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
return false;
|
|
38
37
|
}
|
|
39
|
-
function responsesPayloadMayNeedReasoningNormalization(payload, options) {
|
|
40
|
-
if (!payload || typeof payload !== 'object') {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
const includeOutput = options.includeOutput ?? true;
|
|
44
|
-
const includeInput = options.includeInput ?? false;
|
|
45
|
-
const includeRequiredAction = options.includeRequiredAction ?? false;
|
|
46
|
-
const includeInstructions = options.includeInstructions ?? false;
|
|
47
|
-
if (includeOutput && valueMayContainReasoningMarkup(payload.output)) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
if (includeInput && valueMayContainReasoningMarkup(payload.input)) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
if (includeInstructions && valueMayContainReasoningMarkup(payload.instructions)) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
if (includeRequiredAction && valueMayContainReasoningMarkup(payload.required_action)) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
38
|
function assertReasoningNormalizerNativeAvailable() {
|
|
62
39
|
if (typeof normalizeReasoningInChatPayloadWithNative !== 'function' ||
|
|
63
40
|
typeof normalizeReasoningInResponsesPayloadWithNative !== 'function' ||
|
|
@@ -80,7 +57,11 @@ export function normalizeReasoningInResponsesPayload(payload, options = { includ
|
|
|
80
57
|
assertReasoningNormalizerNativeAvailable();
|
|
81
58
|
if (!payload)
|
|
82
59
|
return;
|
|
83
|
-
|
|
60
|
+
const shouldNormalize = (options.includeInput === true && valueMayContainReasoningMarkup(payload.input)) ||
|
|
61
|
+
(options.includeOutput === true && valueMayContainReasoningMarkup(payload.output)) ||
|
|
62
|
+
(options.includeInstructions === true && valueMayContainReasoningMarkup(payload.instructions)) ||
|
|
63
|
+
(options.includeRequiredAction === true && valueMayContainReasoningMarkup(payload.required_action));
|
|
64
|
+
if (!shouldNormalize) {
|
|
84
65
|
return;
|
|
85
66
|
}
|
|
86
67
|
const normalized = normalizeReasoningInResponsesPayloadWithNative(payload, options);
|
|
@@ -94,9 +94,8 @@ export function enforceToolCallIdStyle(input, transformer) {
|
|
|
94
94
|
if (type === 'function_call_output' || type === 'tool_result' || type === 'tool_message') {
|
|
95
95
|
const normalizedCallId = transformer.normalizeCallId(entry.call_id ?? entry.tool_call_id ?? entry.id);
|
|
96
96
|
entry.call_id = normalizedCallId;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
97
|
+
// Keep tool_call_id for providers that expect it (e.g., Qwen)
|
|
98
|
+
entry.tool_call_id = normalizedCallId;
|
|
100
99
|
entry.id = transformer.normalizeOutputId(normalizedCallId, entry.id);
|
|
101
100
|
}
|
|
102
101
|
}
|
|
@@ -374,7 +374,8 @@ export function normalizeApplyPatchToolCallsOnResponse(chat) {
|
|
|
374
374
|
originalArgs: rawArgs,
|
|
375
375
|
normalizedArgs: argsStr,
|
|
376
376
|
validationError: reason,
|
|
377
|
-
source: 'tool-governor.response'
|
|
377
|
+
source: 'tool-governor.response',
|
|
378
|
+
meta: { applyPatchToolMode: 'freeform' }
|
|
378
379
|
});
|
|
379
380
|
const snippet = typeof argsStr === 'string' && argsStr.trim().length
|
|
380
381
|
? argsStr.trim().slice(0, 200).replace(/\s+/g, ' ')
|
|
@@ -454,7 +455,8 @@ function normalizeSpecialToolCallsOnRequest(request) {
|
|
|
454
455
|
originalArgs: rawArgs,
|
|
455
456
|
normalizedArgs: argsStr,
|
|
456
457
|
validationError: reason,
|
|
457
|
-
source: 'tool-governor.request'
|
|
458
|
+
source: 'tool-governor.request',
|
|
459
|
+
meta: { applyPatchToolMode: 'freeform' }
|
|
458
460
|
});
|
|
459
461
|
const snippet = typeof argsStr === 'string' && argsStr.trim().length
|
|
460
462
|
? argsStr.trim().slice(0, 200).replace(/\s+/g, ' ')
|
|
Binary file
|
|
@@ -49,12 +49,6 @@ export function getRoutingInstructionState(stickyKey, routingInstructionState, r
|
|
|
49
49
|
existing.stopMessageAiMode = merged.stopMessageAiMode;
|
|
50
50
|
existing.stopMessageAiSeedPrompt = merged.stopMessageAiSeedPrompt;
|
|
51
51
|
existing.stopMessageAiHistory = merged.stopMessageAiHistory;
|
|
52
|
-
existing.chatProcessInputTokens = persisted?.chatProcessInputTokens;
|
|
53
|
-
existing.chatProcessMessageCount = persisted?.chatProcessMessageCount;
|
|
54
|
-
existing.chatProcessToolsSignature = persisted?.chatProcessToolsSignature;
|
|
55
|
-
existing.chatProcessParametersSignature = persisted?.chatProcessParametersSignature;
|
|
56
|
-
existing.chatProcessBoundarySignature = persisted?.chatProcessBoundarySignature;
|
|
57
|
-
existing.chatProcessUpdatedAt = persisted?.chatProcessUpdatedAt;
|
|
58
52
|
if (persisted) {
|
|
59
53
|
existing.preCommandSource = persisted.preCommandSource;
|
|
60
54
|
existing.preCommandScriptPath = persisted.preCommandScriptPath;
|
|
@@ -91,13 +85,7 @@ export function getRoutingInstructionState(stickyKey, routingInstructionState, r
|
|
|
91
85
|
stopMessageAiHistory: undefined,
|
|
92
86
|
preCommandSource: undefined,
|
|
93
87
|
preCommandScriptPath: undefined,
|
|
94
|
-
preCommandUpdatedAt: undefined
|
|
95
|
-
chatProcessInputTokens: undefined,
|
|
96
|
-
chatProcessMessageCount: undefined,
|
|
97
|
-
chatProcessToolsSignature: undefined,
|
|
98
|
-
chatProcessParametersSignature: undefined,
|
|
99
|
-
chatProcessBoundarySignature: undefined,
|
|
100
|
-
chatProcessUpdatedAt: undefined
|
|
88
|
+
preCommandUpdatedAt: undefined
|
|
101
89
|
};
|
|
102
90
|
}
|
|
103
91
|
routingInstructionState.set(key, initial);
|
|
@@ -121,12 +109,6 @@ function isRoutingStateEmpty(state) {
|
|
|
121
109
|
(typeof state.stopMessageAiMode !== 'string' || !state.stopMessageAiMode.trim());
|
|
122
110
|
const noPreCommand = (!state.preCommandScriptPath || !state.preCommandScriptPath.trim()) &&
|
|
123
111
|
(typeof state.preCommandUpdatedAt !== 'number' || !Number.isFinite(state.preCommandUpdatedAt));
|
|
124
|
-
const noChatProcessUsage = (typeof state.chatProcessInputTokens !== 'number' || !Number.isFinite(state.chatProcessInputTokens)) &&
|
|
125
|
-
(typeof state.chatProcessMessageCount !== 'number' || !Number.isFinite(state.chatProcessMessageCount)) &&
|
|
126
|
-
(!state.chatProcessToolsSignature || !state.chatProcessToolsSignature.trim()) &&
|
|
127
|
-
(!state.chatProcessParametersSignature || !state.chatProcessParametersSignature.trim()) &&
|
|
128
|
-
(!state.chatProcessBoundarySignature || !state.chatProcessBoundarySignature.trim()) &&
|
|
129
|
-
(typeof state.chatProcessUpdatedAt !== 'number' || !Number.isFinite(state.chatProcessUpdatedAt));
|
|
130
112
|
return (noForced &&
|
|
131
113
|
noSticky &&
|
|
132
114
|
noPrefer &&
|
|
@@ -135,8 +117,7 @@ function isRoutingStateEmpty(state) {
|
|
|
135
117
|
noDisabledKeys &&
|
|
136
118
|
noDisabledModels &&
|
|
137
119
|
noStopMessage &&
|
|
138
|
-
noPreCommand
|
|
139
|
-
noChatProcessUsage);
|
|
120
|
+
noPreCommand);
|
|
140
121
|
}
|
|
141
122
|
export function persistRoutingInstructionState(key, state, routingStateStore) {
|
|
142
123
|
if (!isPersistentScopeKey(key)) {
|
package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js
CHANGED
|
@@ -19,7 +19,6 @@ function parsePayload(raw) {
|
|
|
19
19
|
messages,
|
|
20
20
|
...(row.tools !== undefined ? { tools: row.tools } : {}),
|
|
21
21
|
...(row.tool_choice !== undefined ? { tool_choice: row.tool_choice } : {}),
|
|
22
|
-
...(row.parallel_tool_calls !== undefined ? { parallel_tool_calls: row.parallel_tool_calls } : {}),
|
|
23
22
|
stream: row.stream,
|
|
24
23
|
parameters
|
|
25
24
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export declare function normalizeResponsePayloadWithNative(payload: Record<string, unknown>, config?: Record<string, unknown>): Record<string, unknown>;
|
|
2
2
|
export declare function validateResponsePayloadWithNative(payload: Record<string, unknown>): void;
|
|
3
3
|
export declare function applyRequestRulesWithNative(payload: Record<string, unknown>, config?: Record<string, unknown>): Record<string, unknown>;
|
|
4
|
-
export declare function applyFieldMappingsWithNative(payload: Record<string, unknown>, mappings: Record<string, unknown>[]): Record<string, unknown>;
|
|
5
|
-
export declare function stringifyLmstudioResponsesInputWithNative(payload: Record<string, unknown>, adapterContext?: Record<string, unknown>): Record<string, unknown>;
|
|
6
4
|
export declare function applyResponseBlacklistWithNative(payload: Record<string, unknown>, config?: Record<string, unknown>): Record<string, unknown>;
|
|
7
5
|
export declare function normalizeToolCallIdsWithNative(payload: Record<string, unknown>): Record<string, unknown>;
|
|
8
6
|
export declare function enforceLmstudioResponsesFcToolCallIdsWithNative(payload: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -18,7 +16,6 @@ export declare function buildAnthropicFromOpenAIChatWithNative(payload: Record<s
|
|
|
18
16
|
export declare function runOpenAIRequestCodecWithNative(payload: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
19
17
|
export declare function runOpenAIResponseCodecWithNative(payload: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
20
18
|
export declare function runResponsesOpenAIRequestCodecWithNative(payload: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
21
|
-
export declare function runResponsesOpenAIReqInboundSemanticMapWithNative(payload: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
22
19
|
export declare function runResponsesOpenAIResponseCodecWithNative(payload: Record<string, unknown>, context: Record<string, unknown>): Record<string, unknown>;
|
|
23
20
|
export declare function runGeminiOpenAIRequestCodecWithNative(payload: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
24
21
|
export declare function runGeminiOpenAIResponseCodecWithNative(payload: Record<string, unknown>, options?: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -101,54 +101,6 @@ export function applyRequestRulesWithNative(payload, config) {
|
|
|
101
101
|
return fail(reason);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
export function applyFieldMappingsWithNative(payload, mappings) {
|
|
105
|
-
const capability = "applyFieldMappingsJson";
|
|
106
|
-
const fail = (reason) => failNativeRequired(capability, reason);
|
|
107
|
-
if (isNativeDisabledByEnv())
|
|
108
|
-
return fail("native disabled");
|
|
109
|
-
const fn = readNativeFunction(capability);
|
|
110
|
-
if (!fn)
|
|
111
|
-
return fail();
|
|
112
|
-
const payloadJson = safeStringify(payload);
|
|
113
|
-
const mappingsJson = safeStringify(Array.isArray(mappings) ? mappings : []);
|
|
114
|
-
if (!payloadJson || !mappingsJson)
|
|
115
|
-
return fail("json stringify failed");
|
|
116
|
-
try {
|
|
117
|
-
const raw = fn(payloadJson, mappingsJson);
|
|
118
|
-
if (typeof raw !== "string" || !raw)
|
|
119
|
-
return fail("empty result");
|
|
120
|
-
const parsed = parseRecord(raw);
|
|
121
|
-
return parsed ?? fail("invalid payload");
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
const reason = error instanceof Error ? error.message : String(error ?? "unknown");
|
|
125
|
-
return fail(reason);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
export function stringifyLmstudioResponsesInputWithNative(payload, adapterContext) {
|
|
129
|
-
const capability = "stringifyLmstudioResponsesInputJson";
|
|
130
|
-
const fail = (reason) => failNativeRequired(capability, reason);
|
|
131
|
-
if (isNativeDisabledByEnv())
|
|
132
|
-
return fail("native disabled");
|
|
133
|
-
const fn = readNativeFunction(capability);
|
|
134
|
-
if (!fn)
|
|
135
|
-
return fail();
|
|
136
|
-
const payloadJson = safeStringify(payload);
|
|
137
|
-
const contextJson = adapterContext ? safeStringify(adapterContext) : "{}";
|
|
138
|
-
if (!payloadJson || !contextJson)
|
|
139
|
-
return fail("json stringify failed");
|
|
140
|
-
try {
|
|
141
|
-
const raw = fn(payloadJson, contextJson);
|
|
142
|
-
if (typeof raw !== "string" || !raw)
|
|
143
|
-
return fail("empty result");
|
|
144
|
-
const parsed = parseRecord(raw);
|
|
145
|
-
return parsed ?? fail("invalid payload");
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
const reason = error instanceof Error ? error.message : String(error ?? "unknown");
|
|
149
|
-
return fail(reason);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
104
|
export function applyResponseBlacklistWithNative(payload, config) {
|
|
153
105
|
const capability = "applyResponseBlacklistJson";
|
|
154
106
|
const fail = (reason) => failNativeRequired(capability, reason);
|
|
@@ -509,30 +461,6 @@ export function runResponsesOpenAIRequestCodecWithNative(payload, options) {
|
|
|
509
461
|
return fail(reason);
|
|
510
462
|
}
|
|
511
463
|
}
|
|
512
|
-
export function runResponsesOpenAIReqInboundSemanticMapWithNative(payload, options) {
|
|
513
|
-
const capability = "runResponsesOpenaiReqInboundSemanticMapJson";
|
|
514
|
-
const fail = (reason) => failNativeRequired(capability, reason);
|
|
515
|
-
if (isNativeDisabledByEnv())
|
|
516
|
-
return fail("native disabled");
|
|
517
|
-
const fn = readNativeFunction(capability);
|
|
518
|
-
if (!fn)
|
|
519
|
-
return fail();
|
|
520
|
-
const payloadJson = safeStringify(payload);
|
|
521
|
-
const optionsJson = options ? safeStringify(options) : "{}";
|
|
522
|
-
if (!payloadJson || !optionsJson)
|
|
523
|
-
return fail("json stringify failed");
|
|
524
|
-
try {
|
|
525
|
-
const raw = fn(payloadJson, optionsJson);
|
|
526
|
-
if (typeof raw !== "string" || !raw)
|
|
527
|
-
return fail("empty result");
|
|
528
|
-
const parsed = parseRecord(raw);
|
|
529
|
-
return parsed ?? fail("invalid payload");
|
|
530
|
-
}
|
|
531
|
-
catch (error) {
|
|
532
|
-
const reason = error instanceof Error ? error.message : String(error ?? "unknown");
|
|
533
|
-
return fail(reason);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
464
|
export function runResponsesOpenAIResponseCodecWithNative(payload, context) {
|
|
537
465
|
const capability = "runResponsesOpenaiResponseCodecJson";
|
|
538
466
|
const fail = (reason) => failNativeRequired(capability, reason);
|
|
@@ -47,7 +47,7 @@ export interface NativeResolveResponsesBridgeToolsOutput {
|
|
|
47
47
|
}
|
|
48
48
|
export interface NativeResolveResponsesRequestBridgeDecisionsInput {
|
|
49
49
|
context?: Record<string, unknown>;
|
|
50
|
-
|
|
50
|
+
requestMetadata?: Record<string, unknown>;
|
|
51
51
|
envelopeMetadata?: Record<string, unknown>;
|
|
52
52
|
bridgeMetadata?: Record<string, unknown>;
|
|
53
53
|
extraBridgeHistory?: Record<string, unknown>;
|
|
@@ -600,7 +600,7 @@ export function resolveResponsesRequestBridgeDecisionsWithNative(input) {
|
|
|
600
600
|
}
|
|
601
601
|
const payloadJson = safeStringify({
|
|
602
602
|
context: input.context,
|
|
603
|
-
|
|
603
|
+
requestMetadata: input.requestMetadata,
|
|
604
604
|
envelopeMetadata: input.envelopeMetadata,
|
|
605
605
|
bridgeMetadata: input.bridgeMetadata,
|
|
606
606
|
extraBridgeHistory: input.extraBridgeHistory
|
package/dist/router/virtual-router/engine-selection/native-hub-pipeline-edge-stage-semantics.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function parseRespInboundFormatEnvelopeWithNative(input: {
|
|
|
12
12
|
protocol: string;
|
|
13
13
|
}): Record<string, unknown>;
|
|
14
14
|
export declare function validateChatEnvelopeWithNative(chatEnvelope: unknown, options: {
|
|
15
|
-
stage:
|
|
16
|
-
direction:
|
|
15
|
+
stage: "req_inbound" | "req_outbound" | "resp_inbound" | "resp_outbound";
|
|
16
|
+
direction: "request" | "response";
|
|
17
17
|
source?: string;
|
|
18
18
|
}): void;
|