@jsonstudio/llms 0.6.3541 → 0.6.3685
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 +23 -114
- package/dist/conversion/compat/actions/auto-thinking.js +3 -2
- package/dist/conversion/compat/actions/deepseek-web-response.js +9 -50
- package/dist/conversion/compat/actions/field-mapping.js +2 -153
- package/dist/conversion/compat/actions/gemini-cli-request.d.ts +2 -0
- package/dist/conversion/compat/actions/gemini-cli-request.js +1 -1
- package/dist/conversion/compat/actions/glm-history-image-trim.js +3 -37
- package/dist/conversion/compat/actions/glm-image-content.js +3 -32
- package/dist/conversion/compat/actions/glm-native-compat.d.ts +6 -0
- package/dist/conversion/compat/actions/glm-native-compat.js +34 -0
- package/dist/conversion/compat/actions/glm-vision-prompt.js +3 -76
- package/dist/conversion/compat/actions/glm-web-search.js +10 -43
- package/dist/conversion/compat/actions/iflow-kimi-cli-defaults.js +4 -53
- package/dist/conversion/compat/actions/iflow-kimi-history-media-placeholder.js +5 -141
- package/dist/conversion/compat/actions/iflow-kimi-thinking-reasoning-fill.js +7 -28
- package/dist/conversion/compat/actions/iflow-native-compat.d.ts +6 -0
- package/dist/conversion/compat/actions/iflow-native-compat.js +36 -0
- package/dist/conversion/compat/actions/iflow-response-body-unwrap.js +4 -119
- package/dist/conversion/compat/actions/iflow-web-search.js +14 -55
- package/dist/conversion/compat/actions/lmstudio-responses-input-stringify.js +3 -104
- package/dist/conversion/hub/node-support.js +1 -1
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +9 -1
- package/dist/conversion/hub/operation-table/semantic-mappers/archive/chat-mapper.archive.js +5 -0
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +34 -14
- package/dist/conversion/hub/pipeline/hub-pipeline.d.ts +14 -14
- package/dist/conversion/hub/pipeline/hub-pipeline.js +838 -524
- package/dist/conversion/hub/pipeline/hub-stage-timing.d.ts +6 -0
- package/dist/conversion/hub/pipeline/hub-stage-timing.js +178 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage1_format_parse/index.js +6 -4
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +46 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.d.ts +3 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-capture-orchestration.js +2 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/context-factories.js +2 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/index.js +1 -0
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.d.ts +3 -2
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage3_context_capture/responses-context-snapshot.js +18 -5
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.d.ts +1 -2
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/context-merge.js +0 -16
- 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 +30 -12
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.d.ts +1 -0
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage1_tool_governance/index.js +5 -2
- 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 +9 -5
- package/dist/conversion/hub/process/chat-process-continue-execution.js +2 -4
- package/dist/conversion/hub/process/chat-process-governance-orchestration.js +3 -1
- package/dist/conversion/hub/process/chat-process-media.d.ts +1 -0
- package/dist/conversion/hub/process/chat-process-media.js +36 -0
- package/dist/conversion/hub/process/chat-process-session-usage.d.ts +25 -0
- package/dist/conversion/hub/process/chat-process-session-usage.js +246 -0
- package/dist/conversion/hub/response/provider-response.js +13 -0
- package/dist/conversion/hub/types/chat-envelope.d.ts +1 -0
- package/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.js +0 -4
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +0 -12
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -9
- package/dist/conversion/responses/responses-openai-bridge.d.ts +1 -0
- package/dist/conversion/responses/responses-openai-bridge.js +51 -24
- package/dist/conversion/shared/anthropic-message-utils.js +14 -1
- package/dist/conversion/shared/reasoning-normalizer.js +61 -0
- package/dist/conversion/shared/tool-governor.js +2 -4
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/quota/quota-state.js +1 -6
- package/dist/router/virtual-router/bootstrap/profile-builder.js +1 -0
- package/dist/router/virtual-router/bootstrap/provider-normalization.d.ts +1 -0
- package/dist/router/virtual-router/bootstrap/provider-normalization.js +6 -0
- package/dist/router/virtual-router/bootstrap.js +1 -6
- package/dist/router/virtual-router/engine/routing-state/store.js +21 -2
- package/dist/router/virtual-router/engine-legacy.js +43 -0
- package/dist/router/virtual-router/engine-logging.d.ts +3 -0
- package/dist/router/virtual-router/engine-logging.js +29 -3
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-process-governed-filter-semantics.js +1 -0
- package/dist/router/virtual-router/engine-selection/native-compat-action-semantics.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-compat-action-semantics.js +72 -0
- 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-inbound-outbound-semantics.d.ts +0 -1
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-inbound-outbound-semantics.js +0 -29
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-req-process-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +6 -2
- package/dist/router/virtual-router/engine.js +28 -13
- package/dist/router/virtual-router/provider-registry.js +1 -0
- package/dist/router/virtual-router/routing-instructions/state.js +44 -2
- package/dist/router/virtual-router/routing-instructions/types.d.ts +6 -0
- package/dist/router/virtual-router/token-estimator.js +21 -0
- package/dist/router/virtual-router/types.d.ts +7 -0
- package/dist/servertool/engine.js +3 -34
- package/dist/servertool/handlers/followup-request-builder.js +0 -6
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +3 -274
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +0 -3
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +0 -29
- package/dist/servertool/handlers/stop-message-auto.js +11 -9
- package/dist/servertool/handlers/vision.js +4 -1
- package/dist/servertool/server-side-tools.d.ts +0 -1
- package/dist/servertool/server-side-tools.js +67 -5
- package/dist/tools/apply-patch/execution-capturer.d.ts +1 -1
- package/dist/tools/apply-patch/execution-capturer.js +1 -2
- package/dist/tools/apply-patch/regression-capturer.js +2 -1
- package/dist/tools/tool-registry.js +1 -2
- package/package.json +1 -1
|
@@ -1,95 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
function extractTextParts(content) {
|
|
5
|
-
const out = [];
|
|
6
|
-
if (typeof content === 'string' && content.trim().length) {
|
|
7
|
-
out.push(content.trim());
|
|
8
|
-
return out;
|
|
9
|
-
}
|
|
10
|
-
if (!Array.isArray(content)) {
|
|
11
|
-
return out;
|
|
12
|
-
}
|
|
13
|
-
for (const part of content) {
|
|
14
|
-
if (!isRecord(part))
|
|
15
|
-
continue;
|
|
16
|
-
const type = typeof part.type === 'string' ? String(part.type).trim().toLowerCase() : '';
|
|
17
|
-
const text = typeof part.text === 'string'
|
|
18
|
-
? part.text
|
|
19
|
-
: typeof part.content === 'string'
|
|
20
|
-
? String(part.content)
|
|
21
|
-
: undefined;
|
|
22
|
-
if (typeof text === 'string' && text.trim().length) {
|
|
23
|
-
out.push(text.trim());
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
// OpenAI Responses content parts often use { type: 'input_text'|'output_text', text: '...' }.
|
|
27
|
-
if ((type === 'input_text' || type === 'output_text') && typeof part.text === 'string') {
|
|
28
|
-
const t = String(part.text).trim();
|
|
29
|
-
if (t.length)
|
|
30
|
-
out.push(t);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return out;
|
|
34
|
-
}
|
|
35
|
-
function stringifyInputItems(input) {
|
|
36
|
-
if (!Array.isArray(input))
|
|
37
|
-
return null;
|
|
38
|
-
const chunks = [];
|
|
39
|
-
for (const item of input) {
|
|
40
|
-
if (!isRecord(item))
|
|
41
|
-
continue;
|
|
42
|
-
const type = typeof item.type === 'string' ? String(item.type).trim().toLowerCase() : '';
|
|
43
|
-
const roleCandidate = typeof item.role === 'string' ? String(item.role).trim() : '';
|
|
44
|
-
const messageNode = isRecord(item.message) ? item.message : undefined;
|
|
45
|
-
const nestedRoleCandidate = messageNode && typeof messageNode.role === 'string' ? String(messageNode.role).trim() : '';
|
|
46
|
-
// OpenAI Responses supports message-like items without an explicit `type` field:
|
|
47
|
-
// { role: 'user'|'assistant'|'system', content: [...] }
|
|
48
|
-
if (type === 'message' || (!type && (roleCandidate || nestedRoleCandidate))) {
|
|
49
|
-
const role = roleCandidate ||
|
|
50
|
-
nestedRoleCandidate ||
|
|
51
|
-
'user';
|
|
52
|
-
const contentNode = item.content !== undefined ? item.content : messageNode?.content;
|
|
53
|
-
const parts = extractTextParts(contentNode);
|
|
54
|
-
if (parts.length) {
|
|
55
|
-
chunks.push(`${role}: ${parts.join('\n')}`);
|
|
56
|
-
}
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (type === 'function_call') {
|
|
60
|
-
const name = typeof item.name === 'string' ? String(item.name).trim() : 'tool';
|
|
61
|
-
const args = typeof item.arguments === 'string'
|
|
62
|
-
? String(item.arguments)
|
|
63
|
-
: (() => {
|
|
64
|
-
try {
|
|
65
|
-
return JSON.stringify(item.arguments ?? null);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
return String(item.arguments ?? '');
|
|
69
|
-
}
|
|
70
|
-
})();
|
|
71
|
-
chunks.push(`assistant tool_call ${name}: ${args}`);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (type === 'function_call_output') {
|
|
75
|
-
const output = typeof item.output === 'string'
|
|
76
|
-
? String(item.output)
|
|
77
|
-
: (() => {
|
|
78
|
-
try {
|
|
79
|
-
return JSON.stringify(item.output ?? null);
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return String(item.output ?? '');
|
|
83
|
-
}
|
|
84
|
-
})();
|
|
85
|
-
chunks.push(`tool_output: ${output}`);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (!chunks.length)
|
|
90
|
-
return '';
|
|
91
|
-
return chunks.join('\n\n');
|
|
92
|
-
}
|
|
1
|
+
import { buildNativeReqOutboundCompatAdapterContext } from '../../hub/pipeline/compat/native-adapter-context.js';
|
|
2
|
+
import { stringifyLmstudioResponsesInputWithNative } from '../../../router/virtual-router/engine-selection/native-compat-action-semantics.js';
|
|
93
3
|
/**
|
|
94
4
|
* Legacy compatibility shim:
|
|
95
5
|
* Some older LM Studio builds rejected the array form of `input` ("Invalid type for 'input'").
|
|
@@ -110,16 +20,5 @@ export function stringifyLmstudioResponsesInput(payload, adapterContext) {
|
|
|
110
20
|
if (!adapterContext || adapterContext.providerProtocol !== 'openai-responses') {
|
|
111
21
|
return payload;
|
|
112
22
|
}
|
|
113
|
-
|
|
114
|
-
const input = record.input;
|
|
115
|
-
if (!Array.isArray(input)) {
|
|
116
|
-
return payload;
|
|
117
|
-
}
|
|
118
|
-
const flattened = stringifyInputItems(input);
|
|
119
|
-
if (flattened === null) {
|
|
120
|
-
return payload;
|
|
121
|
-
}
|
|
122
|
-
const instructions = typeof record.instructions === 'string' ? record.instructions.trim() : '';
|
|
123
|
-
record.input = instructions.length ? `${instructions}\n\n${flattened}`.trim() : flattened;
|
|
124
|
-
return payload;
|
|
23
|
+
return stringifyLmstudioResponsesInputWithNative(payload, buildNativeReqOutboundCompatAdapterContext(adapterContext));
|
|
125
24
|
}
|
|
@@ -108,7 +108,7 @@ function deriveAdapterContext(context, fallbackProtocol) {
|
|
|
108
108
|
(typeof metadata.providerProtocol === 'string' ? metadata.providerProtocol : undefined) ||
|
|
109
109
|
fallbackProtocol;
|
|
110
110
|
const streamingHint = metadata.stream === true ? 'force' : metadata.stream === false ? 'disable' : 'auto';
|
|
111
|
-
const toolCallIdStyle = normalizeToolCallIdStyleCandidate(
|
|
111
|
+
const toolCallIdStyle = normalizeToolCallIdStyleCandidate(requestContext.toolCallIdStyle);
|
|
112
112
|
return {
|
|
113
113
|
requestId: context.request.id,
|
|
114
114
|
entryEndpoint: (typeof requestContext.entryEndpoint === 'string' ? requestContext.entryEndpoint : context.request.endpoint) ||
|
|
@@ -29,7 +29,8 @@ const ANTHROPIC_TOP_LEVEL_FIELDS = new Set([
|
|
|
29
29
|
'metadata',
|
|
30
30
|
'stream',
|
|
31
31
|
'tool_choice',
|
|
32
|
-
'thinking'
|
|
32
|
+
'thinking',
|
|
33
|
+
'disable_parallel_tool_use'
|
|
33
34
|
]);
|
|
34
35
|
const PASSTHROUGH_METADATA_PREFIX = 'rcc_passthrough_';
|
|
35
36
|
const PASSTHROUGH_PARAMETERS = ['tool_choice'];
|
|
@@ -94,6 +95,9 @@ function collectParameters(payload) {
|
|
|
94
95
|
params[key] = payload[key];
|
|
95
96
|
}
|
|
96
97
|
}
|
|
98
|
+
if (typeof payload.disable_parallel_tool_use === 'boolean') {
|
|
99
|
+
params.parallel_tool_calls = !payload.disable_parallel_tool_use;
|
|
100
|
+
}
|
|
97
101
|
if (Array.isArray(payload.stop_sequences)) {
|
|
98
102
|
params.stop = payload.stop_sequences;
|
|
99
103
|
}
|
|
@@ -384,6 +388,10 @@ export class AnthropicSemanticMapper {
|
|
|
384
388
|
}
|
|
385
389
|
if (trimmedParameters) {
|
|
386
390
|
for (const [key, value] of Object.entries(trimmedParameters)) {
|
|
391
|
+
if (key === 'parallel_tool_calls') {
|
|
392
|
+
baseRequest.parallel_tool_calls = value;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
387
395
|
if (ANTHROPIC_TOP_LEVEL_FIELDS.has(key) || key === 'stop') {
|
|
388
396
|
if (key === 'messages' || key === 'tools') {
|
|
389
397
|
continue;
|
|
@@ -2,6 +2,11 @@ import { isJsonObject, jsonClone } from '../../../types/json.js';
|
|
|
2
2
|
import { normalizeChatMessageContentWithNative, normalizeOpenaiChatMessagesWithNative } from '../../../../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
3
3
|
import { ensureProtocolState } from '../../../../protocol-state.js';
|
|
4
4
|
import { mapReqInboundBridgeToolsToChatWithNative } from '../../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
5
|
+
const ALLOW_ARCHIVE_IMPORTS = process.env.LLMSWITCH_ALLOW_ARCHIVE_IMPORTS === '1' ||
|
|
6
|
+
process.env.ROUTECODEX_ALLOW_ARCHIVE_IMPORTS === '1';
|
|
7
|
+
if (!ALLOW_ARCHIVE_IMPORTS) {
|
|
8
|
+
throw new Error('[archive] chat-mapper.archive is fail-closed. Set LLMSWITCH_ALLOW_ARCHIVE_IMPORTS=1 only for explicit parity/compare scripts.');
|
|
9
|
+
}
|
|
5
10
|
const CHAT_PARAMETER_KEYS = [
|
|
6
11
|
'model',
|
|
7
12
|
'temperature',
|
|
@@ -2,6 +2,8 @@ import { isJsonObject, jsonClone } from '../../types/json.js';
|
|
|
2
2
|
import { captureResponsesContext, buildChatRequestFromResponses, buildResponsesRequestFromChat } from '../../../responses/responses-openai-bridge.js';
|
|
3
3
|
import { maybeAugmentApplyPatchErrorContent } from './chat-mapper.js';
|
|
4
4
|
import { mapReqInboundBridgeToolsToChatWithNative, mapReqInboundResumeToolOutputsDetailedWithNative } from '../../../../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
5
|
+
import { mapOpenaiChatToChatWithNative } from '../../../../router/virtual-router/engine-selection/native-hub-pipeline-semantic-mappers.js';
|
|
6
|
+
import { runResponsesOpenAIRequestCodecWithNative } from '../../../../router/virtual-router/engine-selection/native-compat-action-semantics.js';
|
|
5
7
|
const RESPONSES_PARAMETER_KEYS = [
|
|
6
8
|
'model',
|
|
7
9
|
'temperature',
|
|
@@ -337,29 +339,19 @@ function collectSubmitToolOutputs(chat, responsesContext) {
|
|
|
337
339
|
}
|
|
338
340
|
return outputs;
|
|
339
341
|
}
|
|
340
|
-
function resolveSubmitStreamFlag(chat, _ctx,
|
|
342
|
+
function resolveSubmitStreamFlag(chat, _ctx, _responsesContext) {
|
|
341
343
|
if (chat.parameters && typeof chat.parameters.stream === 'boolean') {
|
|
342
344
|
return chat.parameters.stream;
|
|
343
345
|
}
|
|
344
|
-
if (responsesContext && typeof responsesContext.stream === 'boolean') {
|
|
345
|
-
return responsesContext.stream;
|
|
346
|
-
}
|
|
347
346
|
return undefined;
|
|
348
347
|
}
|
|
349
|
-
function resolveSubmitModel(chat,
|
|
348
|
+
function resolveSubmitModel(chat, _responsesContext) {
|
|
350
349
|
const direct = chat.parameters && typeof chat.parameters.model === 'string'
|
|
351
350
|
? chat.parameters.model.trim()
|
|
352
351
|
: undefined;
|
|
353
352
|
if (direct) {
|
|
354
353
|
return direct;
|
|
355
354
|
}
|
|
356
|
-
if (responsesContext && typeof responsesContext.parameters === 'object') {
|
|
357
|
-
const params = responsesContext.parameters;
|
|
358
|
-
const model = typeof params.model === 'string' ? params.model.trim() : undefined;
|
|
359
|
-
if (model) {
|
|
360
|
-
return model;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
355
|
return undefined;
|
|
364
356
|
}
|
|
365
357
|
function buildSubmitToolOutputsPayload(chat, ctx, responsesContext) {
|
|
@@ -401,12 +393,38 @@ function buildSubmitToolOutputsPayload(chat, ctx, responsesContext) {
|
|
|
401
393
|
export class ResponsesSemanticMapper {
|
|
402
394
|
async toChat(format, ctx) {
|
|
403
395
|
const payload = format.payload || {};
|
|
396
|
+
if (!isSubmitToolOutputsEndpoint(ctx)) {
|
|
397
|
+
const codecResult = runResponsesOpenAIRequestCodecWithNative(payload, { requestId: ctx.requestId });
|
|
398
|
+
const request = isJsonObject(codecResult.request)
|
|
399
|
+
? codecResult.request
|
|
400
|
+
: undefined;
|
|
401
|
+
const responsesContext = isJsonObject(codecResult.context)
|
|
402
|
+
? codecResult.context
|
|
403
|
+
: undefined;
|
|
404
|
+
if (request && responsesContext) {
|
|
405
|
+
const chatEnvelope = mapOpenaiChatToChatWithNative(request, ctx);
|
|
406
|
+
const missingFields = [];
|
|
407
|
+
const toolOutputs = mapToolOutputs(payload.tool_outputs, missingFields);
|
|
408
|
+
if (toolOutputs?.length) {
|
|
409
|
+
chatEnvelope.toolOutputs = toolOutputs;
|
|
410
|
+
}
|
|
411
|
+
if (missingFields.length) {
|
|
412
|
+
const metadata = chatEnvelope.metadata && typeof chatEnvelope.metadata === 'object'
|
|
413
|
+
? chatEnvelope.metadata
|
|
414
|
+
: { context: ctx };
|
|
415
|
+
metadata.missingFields = missingFields;
|
|
416
|
+
chatEnvelope.metadata = metadata;
|
|
417
|
+
}
|
|
418
|
+
chatEnvelope.semantics = attachResponsesSemantics(chatEnvelope.semantics, responsesContext, undefined);
|
|
419
|
+
return chatEnvelope;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
404
422
|
const responsesContext = captureResponsesContext(payload, { route: { requestId: ctx.requestId } });
|
|
405
423
|
const { request, toolsNormalized } = buildChatRequestFromResponses(payload, responsesContext);
|
|
406
424
|
const missingFields = [];
|
|
407
425
|
const messages = normalizeMessages(request.messages, missingFields);
|
|
408
426
|
let toolOutputs = mapToolOutputs(payload.tool_outputs, missingFields);
|
|
409
|
-
const parameters = collectParameters(payload,
|
|
427
|
+
const parameters = collectParameters(payload, typeof payload.stream === 'boolean' ? payload.stream : undefined);
|
|
410
428
|
const metadata = { context: ctx };
|
|
411
429
|
if (missingFields.length) {
|
|
412
430
|
metadata.missingFields = missingFields;
|
|
@@ -452,7 +470,9 @@ export class ResponsesSemanticMapper {
|
|
|
452
470
|
.map(message => serializeSystemContent(message))
|
|
453
471
|
.filter((content) => typeof content === 'string' && content.length > 0);
|
|
454
472
|
responsesContext.originalSystemMessages = originalSystemMessages;
|
|
455
|
-
const responsesResult = buildResponsesRequestFromChat(requestShape, responsesContext
|
|
473
|
+
const responsesResult = buildResponsesRequestFromChat(requestShape, responsesContext, {
|
|
474
|
+
routeToolCallIdStyle: ctx.toolCallIdStyle
|
|
475
|
+
});
|
|
456
476
|
const responses = responsesResult.request;
|
|
457
477
|
if (chat.parameters && chat.parameters.stream !== undefined) {
|
|
458
478
|
responses.stream = chat.parameters.stream;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Readable } from
|
|
2
|
-
import type { StandardizedRequest, ProcessedRequest } from
|
|
3
|
-
import type { JsonObject } from
|
|
4
|
-
import type { VirtualRouterConfig, RoutingDecision, RoutingDiagnostics, TargetMetadata, VirtualRouterHealthStore, ProviderQuotaView } from
|
|
5
|
-
import { type HubProcessNodeResult } from
|
|
6
|
-
import { type HubPolicyConfig } from
|
|
7
|
-
import { type HubToolSurfaceConfig } from
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import type { StandardizedRequest, ProcessedRequest } from "../types/standardized.js";
|
|
3
|
+
import type { JsonObject } from "../types/json.js";
|
|
4
|
+
import type { VirtualRouterConfig, RoutingDecision, RoutingDiagnostics, TargetMetadata, VirtualRouterHealthStore, ProviderQuotaView } from "../../../router/virtual-router/types.js";
|
|
5
|
+
import { type HubProcessNodeResult } from "../process/chat-process.js";
|
|
6
|
+
import { type HubPolicyConfig } from "../policy/policy-engine.js";
|
|
7
|
+
import { type HubToolSurfaceConfig } from "../tool-surface/tool-surface-engine.js";
|
|
8
8
|
export interface HubPipelineConfig {
|
|
9
9
|
virtualRouter: VirtualRouterConfig;
|
|
10
10
|
/**
|
|
@@ -40,9 +40,9 @@ export interface HubPipelineConfig {
|
|
|
40
40
|
export interface HubPipelineRequestMetadata extends Record<string, unknown> {
|
|
41
41
|
entryEndpoint?: string;
|
|
42
42
|
providerProtocol?: string;
|
|
43
|
-
processMode?:
|
|
44
|
-
stage?:
|
|
45
|
-
direction?:
|
|
43
|
+
processMode?: "chat" | "passthrough";
|
|
44
|
+
stage?: "inbound" | "outbound";
|
|
45
|
+
direction?: "request" | "response";
|
|
46
46
|
stream?: boolean;
|
|
47
47
|
routeHint?: string;
|
|
48
48
|
}
|
|
@@ -54,7 +54,7 @@ export interface HubPipelineRequest {
|
|
|
54
54
|
} | Readable;
|
|
55
55
|
metadata?: HubPipelineRequestMetadata;
|
|
56
56
|
}
|
|
57
|
-
type HubPipelineNodeMetadata = HubProcessNodeResult[
|
|
57
|
+
type HubPipelineNodeMetadata = HubProcessNodeResult["metadata"] | Record<string, unknown>;
|
|
58
58
|
export interface HubPipelineNodeResult {
|
|
59
59
|
id: string;
|
|
60
60
|
success: boolean;
|
|
@@ -79,9 +79,9 @@ export declare class HubPipeline {
|
|
|
79
79
|
private unsubscribeProviderSuccess?;
|
|
80
80
|
constructor(config: HubPipelineConfig);
|
|
81
81
|
updateRuntimeDeps(deps: {
|
|
82
|
-
healthStore?: HubPipelineConfig[
|
|
83
|
-
routingStateStore?: HubPipelineConfig[
|
|
84
|
-
quotaView?: HubPipelineConfig[
|
|
82
|
+
healthStore?: HubPipelineConfig["healthStore"] | null;
|
|
83
|
+
routingStateStore?: HubPipelineConfig["routingStateStore"] | null;
|
|
84
|
+
quotaView?: HubPipelineConfig["quotaView"] | null;
|
|
85
85
|
}): void;
|
|
86
86
|
updateVirtualRouterConfig(nextConfig: VirtualRouterConfig): void;
|
|
87
87
|
dispose(): void;
|