@jsonstudio/llms 0.6.2979 → 0.6.3238
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/args-mapping.js +8 -0
- package/dist/conversion/{shared/bridge-actions.js → bridge-actions.js} +2 -1
- package/dist/conversion/{shared/bridge-id-utils.js → bridge-id-utils.js} +1 -1
- package/dist/conversion/{shared/bridge-instructions.js → bridge-instructions.js} +1 -1
- package/dist/conversion/{shared/bridge-message-utils.d.ts → bridge-message-utils.d.ts} +1 -1
- package/dist/conversion/{shared/bridge-message-utils.js → bridge-message-utils.js} +5 -149
- package/dist/conversion/{shared/bridge-metadata.js → bridge-metadata.js} +1 -1
- package/dist/conversion/{shared/bridge-policies.js → bridge-policies.js} +1 -1
- package/dist/conversion/codecs/gemini-openai-codec.js +27 -8
- package/dist/conversion/codecs/responses-openai-codec.js +1 -1
- package/dist/conversion/{shared/compaction-detect.d.ts → compaction-detect.d.ts} +1 -1
- package/dist/conversion/compaction-detect.js +4 -0
- package/dist/conversion/compat/actions/apply-patch-fixer.js +2 -2
- package/dist/conversion/compat/actions/deepseek-web-response.d.ts +0 -1
- package/dist/conversion/compat/actions/deepseek-web-response.js +15 -405
- package/dist/conversion/compat/actions/harvest-tool-calls-from-text.js +1 -1
- package/dist/conversion/compat/actions/lmstudio-responses-fc-ids.js +1 -1
- package/dist/conversion/compat/actions/qwen-transform.js +74 -2
- package/dist/conversion/compat/actions/snapshot.js +1 -1
- package/dist/conversion/compat/antigravity-session-signature.js +36 -0
- package/dist/conversion/compat/profiles/chat-deepseek-web.json +0 -22
- package/dist/conversion/compat/profiles/chat-glm.json +251 -72
- package/dist/conversion/compat/profiles/chat-iflow.json +174 -39
- package/dist/conversion/compat/profiles/chat-lmstudio.json +43 -14
- package/dist/conversion/hub/operation-table/operation-table-runner.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/anthropic-mapper.js +1 -1
- package/dist/conversion/hub/operation-table/semantic-mappers/archive/chat-mapper.archive.d.ts +8 -0
- package/dist/conversion/hub/operation-table/semantic-mappers/archive/chat-mapper.archive.js +404 -0
- package/dist/conversion/hub/operation-table/semantic-mappers/chat-mapper.js +5 -381
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +2 -2
- package/dist/conversion/hub/operation-table/semantic-mappers/responses-mapper.js +2 -8
- package/dist/conversion/hub/pipeline/hub-pipeline.d.ts +1 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +50 -3
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.d.ts +1 -1
- package/dist/conversion/hub/pipeline/stages/req_inbound/req_inbound_stage2_semantic_map/index.js +62 -0
- package/dist/conversion/hub/pipeline/stages/req_process/req_process_stage2_route_select/index.js +3 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +1 -1
- package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/chat-process-semantics-bridge.d.ts +1 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +42 -29
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage2_finalize/index.js +12 -0
- package/dist/conversion/hub/policy/protocol-spec.js +1 -1
- package/dist/conversion/hub/process/chat-process-clock-reminders.js +1 -1
- package/dist/conversion/hub/process/chat-process-clock-tools.js +1 -1
- package/dist/conversion/hub/process/chat-process-continue-execution.js +1 -1
- package/dist/conversion/hub/process/chat-process-servertool-orchestration.js +1 -1
- package/dist/conversion/hub/process/chat-process-web-search.js +1 -1
- package/dist/conversion/hub/response/provider-response.js +14 -5
- package/dist/conversion/hub/response/response-mappers.js +23 -1
- package/dist/conversion/hub/response/response-runtime.js +28 -5
- package/dist/conversion/hub/snapshot-recorder.js +3 -92
- package/dist/conversion/hub/tool-governance/engine.d.ts +8 -0
- package/dist/conversion/hub/tool-governance/engine.js +40 -193
- package/dist/conversion/hub/tool-governance/rules.js +73 -69
- package/dist/conversion/hub/tool-surface/tool-surface-engine.js +1 -1
- package/dist/conversion/index.d.ts +1 -2
- package/dist/conversion/index.js +1 -2
- package/dist/conversion/{shared/jsonish.js → jsonish.js} +1 -1
- package/dist/conversion/{shared/mcp-injection.js → mcp-injection.js} +1 -1
- package/dist/conversion/media.js +4 -0
- package/dist/conversion/{shared/metadata-passthrough.d.ts → metadata-passthrough.d.ts} +1 -1
- package/dist/conversion/{shared/metadata-passthrough.js → metadata-passthrough.js} +2 -2
- package/dist/conversion/payload-budget.js +47 -0
- package/dist/conversion/protocol-field-allowlists.d.ts +7 -0
- package/dist/conversion/protocol-field-allowlists.js +9 -0
- package/dist/conversion/{shared/protocol-state.d.ts → protocol-state.d.ts} +2 -2
- package/dist/conversion/{shared/protocol-state.js → protocol-state.js} +2 -2
- package/dist/conversion/{shared/errors.d.ts → provider-protocol-error.d.ts} +0 -3
- package/dist/conversion/provider-protocol-error.js +25 -0
- package/dist/conversion/responses/responses-openai-bridge/response-payload.js +8 -5
- package/dist/conversion/responses/responses-openai-bridge/types.d.ts +1 -1
- package/dist/conversion/responses/responses-openai-bridge.d.ts +1 -1
- package/dist/conversion/responses/responses-openai-bridge.js +43 -10
- package/dist/conversion/{shared/runtime-metadata.d.ts → runtime-metadata.d.ts} +1 -1
- package/dist/conversion/{shared/runtime-metadata.js → runtime-metadata.js} +2 -2
- package/dist/conversion/shared/anthropic-message-utils.js +19 -8
- package/dist/conversion/shared/chat-request-filters.d.ts +3 -4
- package/dist/conversion/shared/chat-request-filters.js +22 -78
- package/dist/conversion/shared/gemini-tool-utils.d.ts +1 -1
- package/dist/conversion/shared/openai-finalizer.js +1 -0
- package/dist/conversion/shared/openai-message-normalize.js +2 -2
- package/dist/conversion/shared/reasoning-normalizer.js +6 -0
- package/dist/conversion/shared/reasoning-utils.js +5 -2
- package/dist/conversion/shared/responses-conversation-store.js +1 -1
- package/dist/conversion/shared/responses-output-builder.js +55 -11
- package/dist/conversion/shared/responses-reasoning-registry.d.ts +14 -2
- package/dist/conversion/shared/responses-reasoning-registry.js +34 -6
- package/dist/conversion/shared/responses-response-utils.js +99 -9
- package/dist/conversion/shared/responses-tool-utils.js +1 -1
- package/dist/conversion/shared/text-markup-normalizer/normalize.d.ts +1 -1
- package/dist/conversion/shared/text-markup-normalizer.d.ts +2 -2
- package/dist/conversion/shared/text-markup-normalizer.js +1 -1
- package/dist/conversion/shared/tool-filter-pipeline.js +1 -1
- package/dist/conversion/shared/tool-governor.js +3 -3
- package/dist/conversion/shared/tool-mapping.d.ts +1 -1
- package/dist/conversion/{shared/snapshot-utils.d.ts → snapshot-utils.d.ts} +11 -0
- package/dist/conversion/{shared/snapshot-utils.js → snapshot-utils.js} +14 -23
- package/dist/conversion/types/text-markup-normalizer.d.ts +13 -0
- package/dist/conversion/types/text-markup-normalizer.js +1 -0
- package/dist/filters/special/request-tools-normalize.js +1 -1
- package/dist/filters/special/response-tool-text-canonicalize.js +2 -2
- package/dist/native/router_hotpath_napi.node +0 -0
- package/dist/quota/quota-manager.js +31 -59
- package/dist/quota/quota-state.js +14 -7
- package/dist/router/virtual-router/bootstrap/profile-builder.d.ts +1 -0
- package/dist/router/virtual-router/bootstrap/profile-builder.js +13 -0
- package/dist/router/virtual-router/bootstrap/provider-normalization.d.ts +2 -0
- package/dist/router/virtual-router/bootstrap/provider-normalization.js +4 -1
- package/dist/router/virtual-router/bootstrap/streaming-helpers.d.ts +7 -0
- package/dist/router/virtual-router/bootstrap/streaming-helpers.js +44 -0
- package/dist/router/virtual-router/bootstrap.js +2 -0
- package/dist/router/virtual-router/engine/routing-state/store.d.ts +1 -2
- package/dist/router/virtual-router/engine/routing-state/store.js +2 -2
- package/dist/router/virtual-router/engine-legacy/config.d.ts +11 -0
- package/dist/router/virtual-router/engine-legacy/config.js +108 -0
- package/dist/router/virtual-router/engine-legacy/direct-model.d.ts +10 -0
- package/dist/router/virtual-router/engine-legacy/direct-model.js +38 -0
- package/dist/router/virtual-router/engine-legacy/health.d.ts +13 -0
- package/dist/router/virtual-router/engine-legacy/health.js +104 -0
- package/dist/router/virtual-router/engine-legacy/helpers.d.ts +16 -0
- package/dist/router/virtual-router/engine-legacy/helpers.js +226 -0
- package/dist/router/virtual-router/engine-legacy/route-finalize.d.ts +9 -0
- package/dist/router/virtual-router/engine-legacy/route-finalize.js +84 -0
- package/dist/router/virtual-router/engine-legacy/route-selection.d.ts +17 -0
- package/dist/router/virtual-router/engine-legacy/route-selection.js +205 -0
- package/dist/router/virtual-router/engine-legacy/route-state-allowlist.d.ts +3 -0
- package/dist/router/virtual-router/engine-legacy/route-state-allowlist.js +36 -0
- package/dist/router/virtual-router/engine-legacy/route-state.d.ts +12 -0
- package/dist/router/virtual-router/engine-legacy/route-state.js +386 -0
- package/dist/router/virtual-router/engine-legacy/route-utils.d.ts +19 -0
- package/dist/router/virtual-router/engine-legacy/route-utils.js +212 -0
- package/dist/router/virtual-router/engine-legacy/routing.d.ts +8 -0
- package/dist/router/virtual-router/engine-legacy/routing.js +8 -0
- package/dist/router/virtual-router/engine-legacy/selection-core.d.ts +28 -0
- package/dist/router/virtual-router/engine-legacy/selection-core.js +112 -0
- package/dist/router/virtual-router/engine-legacy/selection-state.d.ts +16 -0
- package/dist/router/virtual-router/engine-legacy/selection-state.js +187 -0
- package/dist/router/virtual-router/engine-legacy/state-accessors.d.ts +21 -0
- package/dist/router/virtual-router/engine-legacy/state-accessors.js +118 -0
- package/dist/router/virtual-router/engine-legacy.d.ts +123 -0
- package/dist/router/virtual-router/engine-legacy.js +194 -0
- package/dist/router/virtual-router/engine-logging.d.ts +2 -0
- package/dist/router/virtual-router/engine-logging.js +7 -2
- package/dist/router/virtual-router/engine-selection/key-parsing.js +0 -3
- package/dist/router/virtual-router/engine-selection/native-chat-request-filter-semantics.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/native-chat-request-filter-semantics.js +54 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.d.ts +10 -0
- package/dist/router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js +67 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-governance-semantics.d.ts +30 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-governance-semantics.js +202 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-semantic-mappers.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-hub-pipeline-semantic-mappers.js +83 -0
- package/dist/router/virtual-router/engine-selection/native-router-hotpath-loader.js +43 -2
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.d.ts +75 -0
- package/dist/router/virtual-router/engine-selection/native-shared-conversion-semantics.js +205 -0
- package/dist/router/virtual-router/engine-selection/native-snapshot-hooks.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/native-snapshot-hooks.js +109 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-engine-proxy.d.ts +16 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-engine-proxy.js +14 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.d.ts +2 -0
- package/dist/router/virtual-router/engine-selection/native-virtual-router-routing-instructions-semantics.js +86 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-quota-integration.js +100 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +99 -0
- package/dist/router/virtual-router/engine.d.ts +22 -105
- package/dist/router/virtual-router/engine.js +274 -1641
- package/dist/router/virtual-router/load-balancer.d.ts +8 -0
- package/dist/router/virtual-router/load-balancer.js +65 -2
- package/dist/router/virtual-router/provider-registry.js +2 -0
- package/dist/router/virtual-router/routing-instructions/clean.d.ts +3 -0
- package/dist/router/virtual-router/routing-instructions/clean.js +34 -0
- package/dist/router/virtual-router/routing-instructions/parse.d.ts +18 -0
- package/dist/router/virtual-router/routing-instructions/parse.js +377 -0
- package/dist/router/virtual-router/routing-instructions/state.d.ts +4 -0
- package/dist/router/virtual-router/routing-instructions/state.js +245 -0
- package/dist/router/virtual-router/routing-instructions/types.d.ts +70 -0
- package/dist/router/virtual-router/routing-instructions/types.js +2 -0
- package/dist/router/virtual-router/routing-instructions.d.ts +5 -89
- package/dist/router/virtual-router/routing-instructions.js +4 -655
- package/dist/router/virtual-router/sticky-session-store.d.ts +4 -0
- package/dist/router/virtual-router/sticky-session-store.js +19 -81
- package/dist/router/virtual-router/tool-signals.js +21 -3
- package/dist/router/virtual-router/types.d.ts +4 -0
- package/dist/servertool/clock/session-scope.js +32 -1
- package/dist/servertool/engine.js +79 -8
- package/dist/servertool/handlers/antigravity-thought-signature-bootstrap.js +1 -1
- package/dist/servertool/handlers/clock-auto.js +1 -1
- package/dist/servertool/handlers/clock.js +1 -1
- package/dist/servertool/handlers/compaction-detect.d.ts +1 -1
- package/dist/servertool/handlers/compaction-detect.js +1 -1
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +1 -1
- package/dist/servertool/handlers/iflow-model-error-retry.js +1 -1
- package/dist/servertool/handlers/recursive-detection-guard.js +1 -1
- package/dist/servertool/handlers/review.js +1 -1
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +1 -1
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +1 -1
- package/dist/servertool/handlers/stop-message-auto.js +1 -1
- package/dist/servertool/handlers/vision.js +1 -1
- package/dist/servertool/handlers/web-search.js +1 -1
- package/dist/servertool/reenter-backend.js +1 -1
- package/dist/servertool/server-side-tools.js +2 -2
- package/dist/servertool/stop-gateway-context.js +1 -1
- package/dist/servertool/stop-message-compare-context.js +1 -1
- package/dist/sse/json-to-sse/event-generators/responses.d.ts +4 -0
- package/dist/sse/json-to-sse/event-generators/responses.js +95 -1
- package/dist/sse/json-to-sse/sequencers/responses-sequencer.js +6 -4
- package/dist/sse/sse-to-json/builders/response-builder.d.ts +8 -0
- package/dist/sse/sse-to-json/builders/response-builder.js +162 -4
- package/dist/sse/sse-to-json/responses-sse-to-json-converter.js +2 -0
- package/dist/sse/types/responses-types.d.ts +6 -2
- package/dist/tools/apply-patch/structured/coercion.js +5 -0
- package/dist/tools/args-json.js +29 -0
- package/package.json +8 -5
- package/dist/conversion/shared/args-mapping.js +0 -77
- package/dist/conversion/shared/compaction-detect.js +0 -4
- package/dist/conversion/shared/errors.js +0 -31
- package/dist/conversion/shared/media.js +0 -4
- package/dist/conversion/shared/payload-budget.js +0 -165
- package/dist/conversion/shared/protocol-field-allowlists.d.ts +0 -7
- package/dist/conversion/shared/protocol-field-allowlists.js +0 -149
- package/dist/conversion/shared/snapshot-hooks.d.ts +0 -11
- package/dist/conversion/shared/snapshot-hooks.js +0 -503
- package/dist/conversion/shared/text-markup-normalizer/extractors-apply-patch.d.ts +0 -2
- package/dist/conversion/shared/text-markup-normalizer/extractors-apply-patch.js +0 -129
- package/dist/conversion/shared/text-markup-normalizer/extractors-json.d.ts +0 -4
- package/dist/conversion/shared/text-markup-normalizer/extractors-json.js +0 -637
- package/dist/conversion/shared/text-markup-normalizer/extractors-shared.d.ts +0 -21
- package/dist/conversion/shared/text-markup-normalizer/extractors-shared.js +0 -177
- package/dist/conversion/shared/text-markup-normalizer/extractors-transcript.d.ts +0 -5
- package/dist/conversion/shared/text-markup-normalizer/extractors-transcript.js +0 -385
- package/dist/conversion/shared/text-markup-normalizer/extractors-xml.d.ts +0 -10
- package/dist/conversion/shared/text-markup-normalizer/extractors-xml.js +0 -602
- package/dist/conversion/shared/text-markup-normalizer/extractors.d.ts +0 -5
- package/dist/conversion/shared/text-markup-normalizer/extractors.js +0 -4
- package/dist/conversion/shared/tool-canonicalizer.d.ts +0 -2
- package/dist/conversion/shared/tool-canonicalizer.js +0 -38
- /package/dist/conversion/{shared/args-mapping.d.ts → args-mapping.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-actions.d.ts → bridge-actions.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-id-utils.d.ts → bridge-id-utils.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-instructions.d.ts → bridge-instructions.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-metadata.d.ts → bridge-metadata.d.ts} +0 -0
- /package/dist/conversion/{shared/bridge-policies.d.ts → bridge-policies.d.ts} +0 -0
- /package/dist/conversion/{shared/jsonish.d.ts → jsonish.d.ts} +0 -0
- /package/dist/conversion/{shared/mcp-injection.d.ts → mcp-injection.d.ts} +0 -0
- /package/dist/conversion/{shared/media.d.ts → media.d.ts} +0 -0
- /package/dist/conversion/{shared/payload-budget.d.ts → payload-budget.d.ts} +0 -0
- /package/dist/conversion/{shared → types}/bridge-message-types.d.ts +0 -0
- /package/dist/conversion/{shared → types}/bridge-message-types.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { normalizeArgsBySchemaWithNative, normalizeToolsWithNative } from '../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
|
+
export function normalizeArgsBySchema(input, schema) {
|
|
3
|
+
return normalizeArgsBySchemaWithNative(input, schema);
|
|
4
|
+
}
|
|
5
|
+
// Tools normalizer (OpenAI-like)
|
|
6
|
+
export function normalizeTools(tools) {
|
|
7
|
+
return normalizeToolsWithNative(tools);
|
|
8
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyBridgeCaptureToolResultsWithNative, applyBridgeEnsureToolPlaceholdersWithNative, applyBridgeNormalizeHistoryWithNative, applyBridgeNormalizeToolIdentifiersWithNative, applyBridgeEnsureSystemInstructionWithNative, applyBridgeInjectSystemInstructionWithNative, applyBridgeMetadataActionWithNative, applyBridgeReasoningExtractWithNative, applyBridgeResponsesOutputReasoningWithNative, ensureBridgeOutputFieldsWithNative } from '
|
|
1
|
+
import { applyBridgeCaptureToolResultsWithNative, applyBridgeEnsureToolPlaceholdersWithNative, applyBridgeNormalizeHistoryWithNative, applyBridgeNormalizeToolIdentifiersWithNative, applyBridgeEnsureSystemInstructionWithNative, applyBridgeInjectSystemInstructionWithNative, applyBridgeMetadataActionWithNative, applyBridgeReasoningExtractWithNative, applyBridgeResponsesOutputReasoningWithNative, ensureBridgeOutputFieldsWithNative } from '../router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js';
|
|
2
2
|
const registry = new Map();
|
|
3
3
|
export function registerBridgeAction(name, action) {
|
|
4
4
|
registry.set(name, action);
|
|
@@ -117,6 +117,7 @@ const extractReasoningAction = (ctx) => {
|
|
|
117
117
|
registerBridgeAction('messages.inject-system-instruction', injectSystemInstructionAction);
|
|
118
118
|
registerBridgeAction('reasoning.extract', extractReasoningAction);
|
|
119
119
|
registerBridgeAction('tools.ensure-response-placeholders', ensureToolResponsePlaceholders);
|
|
120
|
+
// (intentionally no-op: capture handled in responses-format normalization)
|
|
120
121
|
const ensureSystemInstructionAction = (ctx) => {
|
|
121
122
|
const messages = ensureMessagesArray(ctx.state);
|
|
122
123
|
const normalized = applyBridgeEnsureSystemInstructionWithNative({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clampResponsesInputItemIdWithNative, normalizeFunctionCallIdWithNative, normalizeFunctionCallOutputIdWithNative, normalizeResponsesCallIdWithNative } from '
|
|
1
|
+
import { clampResponsesInputItemIdWithNative, normalizeFunctionCallIdWithNative, normalizeFunctionCallOutputIdWithNative, normalizeResponsesCallIdWithNative } from '../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
2
|
export function normalizeFunctionCallId(options) {
|
|
3
3
|
return normalizeFunctionCallIdWithNative(options);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sanitizeReasoningTaggedTextWithNative } from '
|
|
1
|
+
import { sanitizeReasoningTaggedTextWithNative } from '../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
2
2
|
function collectTextFromBlocks(blocks) {
|
|
3
3
|
const parts = [];
|
|
4
4
|
for (const block of blocks) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BridgeInputItem } from './bridge-message-types.js';
|
|
1
|
+
import type { BridgeInputItem } from './types/bridge-message-types.js';
|
|
2
2
|
export declare function coerceBridgeRole(role: unknown): string;
|
|
3
3
|
export declare function serializeToolArguments(argsStringOrObj: unknown, _functionName: string | undefined, _tools: unknown): string;
|
|
4
4
|
export declare function serializeToolOutput(entry: BridgeInputItem): string | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { normalizeChatMessageContent } from './chat-output-normalizer.js';
|
|
2
|
-
import { normalizeFunctionCallIdWithNative as normalizeFunctionCallId,
|
|
1
|
+
import { normalizeChatMessageContent } from './shared/chat-output-normalizer.js';
|
|
2
|
+
import { normalizeFunctionCallIdWithNative as normalizeFunctionCallId, repairArgumentsToStringWithNative as repairToolArguments } from '../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
|
|
3
|
+
import { buildBridgeHistoryWithNative } from '../router/virtual-router/engine-selection/native-hub-bridge-action-semantics.js';
|
|
3
4
|
function ensureAssistantToolCallIdentity(call, fallbackId) {
|
|
4
5
|
const resolved = (typeof call.id === 'string' && call.id.trim().length ? call.id.trim() : undefined) ??
|
|
5
6
|
(typeof call.tool_call_id === 'string' && call.tool_call_id.trim().length
|
|
@@ -141,153 +142,8 @@ function extractUserTextFromEntry(entry) {
|
|
|
141
142
|
}
|
|
142
143
|
export function convertMessagesToBridgeInput(options) {
|
|
143
144
|
const { messages, tools } = options;
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
const originalSystemMessages = [];
|
|
147
|
-
let latestUserInstruction = null;
|
|
148
|
-
const pendingToolCallIds = [];
|
|
149
|
-
const knownToolCallIds = new Set();
|
|
150
|
-
for (const m of messages) {
|
|
151
|
-
if (!m || typeof m !== 'object')
|
|
152
|
-
continue;
|
|
153
|
-
const role = coerceBridgeRole(m.role || 'user');
|
|
154
|
-
const content = m.content;
|
|
155
|
-
const collectedText = collectText(content);
|
|
156
|
-
const mediaBlocks = extractMediaBlocksFromContent(content);
|
|
157
|
-
const text = role === 'system' ? collectedText : collectedText.trim();
|
|
158
|
-
if (role === 'system') {
|
|
159
|
-
if (collectedText && collectedText.length) {
|
|
160
|
-
originalSystemMessages.push(collectedText);
|
|
161
|
-
systemParts.push(collectedText);
|
|
162
|
-
}
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
if (role === 'tool') {
|
|
166
|
-
const rawToolId = m.tool_call_id ||
|
|
167
|
-
m.call_id ||
|
|
168
|
-
m.tool_use_id ||
|
|
169
|
-
m.id ||
|
|
170
|
-
undefined;
|
|
171
|
-
let callId = typeof rawToolId === 'string' && rawToolId.trim().length ? rawToolId.trim() : undefined;
|
|
172
|
-
if (callId && knownToolCallIds.has(callId)) {
|
|
173
|
-
const idx = pendingToolCallIds.indexOf(callId);
|
|
174
|
-
if (idx >= 0)
|
|
175
|
-
pendingToolCallIds.splice(idx, 1);
|
|
176
|
-
}
|
|
177
|
-
if (!callId && pendingToolCallIds.length) {
|
|
178
|
-
callId = pendingToolCallIds.shift();
|
|
179
|
-
}
|
|
180
|
-
if (!callId) {
|
|
181
|
-
callId = normalizeFunctionCallId({
|
|
182
|
-
callId,
|
|
183
|
-
fallback: `fc_call_${input.length + 1}`
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
knownToolCallIds.add(callId);
|
|
187
|
-
const normalizedId = normalizeFunctionCallOutputId({
|
|
188
|
-
callId,
|
|
189
|
-
fallback: `fc_tool_${input.length + 1}`
|
|
190
|
-
});
|
|
191
|
-
const entry = {
|
|
192
|
-
type: 'function_call_output',
|
|
193
|
-
id: normalizedId,
|
|
194
|
-
call_id: callId,
|
|
195
|
-
output: typeof text === 'string' ? text : ''
|
|
196
|
-
};
|
|
197
|
-
input.push(entry);
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const toolCalls = Array.isArray(m.tool_calls) ? m.tool_calls : [];
|
|
201
|
-
if (toolCalls.length) {
|
|
202
|
-
for (const tc of toolCalls) {
|
|
203
|
-
try {
|
|
204
|
-
const rawIdCandidate = (typeof tc?.id === 'string' && tc.id.trim().length ? tc.id.trim() : undefined) ??
|
|
205
|
-
(typeof tc?.call_id === 'string' && tc.call_id.trim().length ? tc.call_id.trim() : undefined);
|
|
206
|
-
const callId = rawIdCandidate ?? normalizeFunctionCallId({
|
|
207
|
-
callId: rawIdCandidate,
|
|
208
|
-
fallback: `fc_call_${input.length + 1}`
|
|
209
|
-
});
|
|
210
|
-
const fn = tc?.function || {};
|
|
211
|
-
const name = typeof fn?.name === 'string' ? String(fn.name) : 'tool';
|
|
212
|
-
const argsRaw = fn?.arguments;
|
|
213
|
-
const args = typeof argsRaw === 'string'
|
|
214
|
-
? argsRaw
|
|
215
|
-
: serializeToolArguments(argsRaw, name, tools);
|
|
216
|
-
const entry = {
|
|
217
|
-
type: 'function_call',
|
|
218
|
-
id: callId,
|
|
219
|
-
call_id: callId,
|
|
220
|
-
name,
|
|
221
|
-
arguments: args
|
|
222
|
-
};
|
|
223
|
-
input.push(entry);
|
|
224
|
-
knownToolCallIds.add(callId);
|
|
225
|
-
pendingToolCallIds.push(callId);
|
|
226
|
-
}
|
|
227
|
-
catch {
|
|
228
|
-
// ignore malformed tool_call
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if (typeof text === 'string' || mediaBlocks.length) {
|
|
234
|
-
const tRole = role === 'assistant' ? 'output_text' : 'input_text';
|
|
235
|
-
const blocks = [];
|
|
236
|
-
if (typeof text === 'string' && text.length) {
|
|
237
|
-
blocks.push({ type: tRole, text });
|
|
238
|
-
}
|
|
239
|
-
for (const media of mediaBlocks) {
|
|
240
|
-
const block = media.kind === 'video'
|
|
241
|
-
? {
|
|
242
|
-
type: 'input_video',
|
|
243
|
-
video_url: media.url
|
|
244
|
-
}
|
|
245
|
-
: {
|
|
246
|
-
type: 'input_image',
|
|
247
|
-
image_url: media.url
|
|
248
|
-
};
|
|
249
|
-
if (media.detail) {
|
|
250
|
-
block.detail = media.detail;
|
|
251
|
-
}
|
|
252
|
-
;
|
|
253
|
-
blocks.push(block);
|
|
254
|
-
}
|
|
255
|
-
if (blocks.length) {
|
|
256
|
-
const entry = {
|
|
257
|
-
role,
|
|
258
|
-
content: blocks
|
|
259
|
-
};
|
|
260
|
-
input.push(entry);
|
|
261
|
-
}
|
|
262
|
-
if (role === 'user') {
|
|
263
|
-
const trimmed = typeof text === 'string' ? text.trim() : '';
|
|
264
|
-
if (trimmed.length) {
|
|
265
|
-
latestUserInstruction = trimmed;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (!latestUserInstruction) {
|
|
271
|
-
for (let i = input.length - 1; i >= 0; i -= 1) {
|
|
272
|
-
const entry = input[i];
|
|
273
|
-
const roleSource = entry?.role ?? entry?.message?.role;
|
|
274
|
-
const role = typeof roleSource === 'string' ? roleSource.toLowerCase() : '';
|
|
275
|
-
if (role !== 'user')
|
|
276
|
-
continue;
|
|
277
|
-
const text = extractUserTextFromEntry(entry);
|
|
278
|
-
if (text) {
|
|
279
|
-
latestUserInstruction = text;
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const combinedSystemInstruction = systemParts.join('\n\n').trim();
|
|
285
|
-
return {
|
|
286
|
-
input,
|
|
287
|
-
combinedSystemInstruction: combinedSystemInstruction.length ? combinedSystemInstruction : undefined,
|
|
288
|
-
latestUserInstruction: latestUserInstruction || undefined,
|
|
289
|
-
originalSystemMessages
|
|
290
|
-
};
|
|
145
|
+
const native = buildBridgeHistoryWithNative({ messages, tools });
|
|
146
|
+
return native;
|
|
291
147
|
}
|
|
292
148
|
function defaultNormalizeFunctionName(raw) {
|
|
293
149
|
if (typeof raw !== 'string')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const BRIDGE_RAW_SYSTEM_METADATA_KEY = '__rcc_raw_system';
|
|
2
|
-
import { normalizeProviderProtocolTokenWithNative } from '
|
|
2
|
+
import { normalizeProviderProtocolTokenWithNative } from '../router/virtual-router/engine-selection/native-hub-pipeline-req-inbound-semantics.js';
|
|
3
3
|
export function resolveBridgeMetadataNativeProtocol() {
|
|
4
4
|
return normalizeProviderProtocolTokenWithNative('openai-responses') ?? 'openai-responses';
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveBridgePolicyActionsWithNative, resolveBridgePolicyWithNative } from '
|
|
1
|
+
import { resolveBridgePolicyActionsWithNative, resolveBridgePolicyWithNative } from '../router/virtual-router/engine-selection/native-hub-bridge-policy-semantics.js';
|
|
2
2
|
export function resolveBridgePolicy(options) {
|
|
3
3
|
const resolved = resolveBridgePolicyWithNative(options);
|
|
4
4
|
if (!resolved) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createBridgeActionState, runBridgeActionPipeline } from '../
|
|
2
|
-
import { resolveBridgePolicy, resolvePolicyActions } from '../
|
|
1
|
+
import { createBridgeActionState, runBridgeActionPipeline } from '../bridge-actions.js';
|
|
2
|
+
import { resolveBridgePolicy, resolvePolicyActions } from '../bridge-policies.js';
|
|
3
3
|
import { normalizeChatMessageContent } from '../shared/chat-output-normalizer.js';
|
|
4
4
|
import { mapBridgeToolsToChat } from '../shared/tool-mapping.js';
|
|
5
5
|
import { prepareGeminiToolsForBridge } from '../shared/gemini-tool-utils.js';
|
|
6
6
|
import { registerResponsesReasoning, consumeResponsesReasoning, registerResponsesOutputTextMeta, consumeResponsesOutputTextMeta, consumeResponsesPayloadSnapshot, registerResponsesPayloadSnapshot, consumeResponsesPassthrough, registerResponsesPassthrough } from '../shared/responses-reasoning-registry.js';
|
|
7
|
-
import { ProviderProtocolError } from '../
|
|
7
|
+
import { ProviderProtocolError } from '../provider-protocol-error.js';
|
|
8
8
|
function isObject(v) {
|
|
9
9
|
return !!v && typeof v === 'object' && !Array.isArray(v);
|
|
10
10
|
}
|
|
@@ -431,10 +431,18 @@ export function buildOpenAIChatFromGeminiResponse(payload) {
|
|
|
431
431
|
if (toolOutputs.length > 0) {
|
|
432
432
|
chatResp.tool_outputs = toolOutputs;
|
|
433
433
|
}
|
|
434
|
+
const localReasoning = reasoningParts.length
|
|
435
|
+
? {
|
|
436
|
+
content: reasoningParts.map((text) => ({ type: 'reasoning_text', text }))
|
|
437
|
+
}
|
|
438
|
+
: undefined;
|
|
434
439
|
const preservedReasoning = consumeResponsesReasoning(chatResp.id);
|
|
435
|
-
if (preservedReasoning
|
|
440
|
+
if (preservedReasoning) {
|
|
436
441
|
chatResp.__responses_reasoning = preservedReasoning;
|
|
437
442
|
}
|
|
443
|
+
else if (localReasoning) {
|
|
444
|
+
chatResp.__responses_reasoning = localReasoning;
|
|
445
|
+
}
|
|
438
446
|
const preservedOutputMeta = consumeResponsesOutputTextMeta(chatResp.id);
|
|
439
447
|
if (preservedOutputMeta) {
|
|
440
448
|
chatResp.__responses_output_text_meta = preservedOutputMeta;
|
|
@@ -521,9 +529,20 @@ export function buildGeminiFromOpenAIChat(chatResp) {
|
|
|
521
529
|
if (contentText && contentText.length) {
|
|
522
530
|
parts.push({ text: contentText });
|
|
523
531
|
}
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
532
|
+
const preservedReasoning = chatResp?.__responses_reasoning;
|
|
533
|
+
const preservedContent = Array.isArray(preservedReasoning?.content)
|
|
534
|
+
? preservedReasoning?.content?.map((entry) => String(entry.text ?? '')).filter((text) => text.trim().length > 0)
|
|
535
|
+
: [];
|
|
536
|
+
const preservedSummary = Array.isArray(preservedReasoning?.summary)
|
|
537
|
+
? preservedReasoning?.summary?.map((entry) => String(entry.text ?? '')).filter((text) => text.trim().length > 0)
|
|
538
|
+
: [];
|
|
539
|
+
const reasoningText = preservedContent.length > 0
|
|
540
|
+
? preservedContent.join('\n')
|
|
541
|
+
: (preservedSummary.length > 0
|
|
542
|
+
? preservedSummary.join('\n')
|
|
543
|
+
: (typeof msg?.reasoning_content === 'string' && msg.reasoning_content.trim().length
|
|
544
|
+
? String(msg.reasoning_content).trim()
|
|
545
|
+
: undefined));
|
|
527
546
|
if (reasoningText) {
|
|
528
547
|
parts.push({ reasoning: reasoningText });
|
|
529
548
|
}
|
|
@@ -613,7 +632,7 @@ export function buildGeminiFromOpenAIChat(chatResp) {
|
|
|
613
632
|
}
|
|
614
633
|
if (Object.keys(usageMetadata).length > 0)
|
|
615
634
|
out.usageMetadata = usageMetadata;
|
|
616
|
-
if (
|
|
635
|
+
if (chatResp?.__responses_reasoning) {
|
|
617
636
|
registerResponsesReasoning(responseId, chatResp.__responses_reasoning);
|
|
618
637
|
}
|
|
619
638
|
if (chatResp?.__responses_output_text_meta) {
|
|
@@ -160,7 +160,7 @@ export class ResponsesOpenAIConversionCodec {
|
|
|
160
160
|
// No fallback append here: pairing must be produced upstream or by standard bridge mapping.
|
|
161
161
|
// Debug snapshot after mapping to Responses JSON (non-stream)
|
|
162
162
|
try {
|
|
163
|
-
const { writeSnapshotViaHooks } = await import('../
|
|
163
|
+
const { writeSnapshotViaHooks } = await import('../snapshot-utils.js');
|
|
164
164
|
await writeSnapshotViaHooks({
|
|
165
165
|
endpoint: '/v1/responses',
|
|
166
166
|
stage: 'response_mapped_json',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { JsonObject } from '
|
|
1
|
+
import type { JsonObject } from './hub/types/json.js';
|
|
2
2
|
export declare function isCompactionRequest(payload: JsonObject): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { registerBridgeAction } from '../../
|
|
2
|
-
import { ensureMessagesArray } from '../../
|
|
1
|
+
import { registerBridgeAction } from '../../bridge-actions.js';
|
|
2
|
+
import { ensureMessagesArray } from '../../bridge-message-utils.js';
|
|
3
3
|
import { validateToolCall } from '../../../tools/tool-registry.js';
|
|
4
4
|
const fixApplyPatchAction = (ctx) => {
|
|
5
5
|
const messages = ensureMessagesArray(ctx.state);
|
|
@@ -3,7 +3,6 @@ import type { JsonObject } from '../../hub/types/json.js';
|
|
|
3
3
|
import { type TextMarkupNormalizeOptions } from '../../shared/text-markup-normalizer.js';
|
|
4
4
|
export interface DeepSeekWebResponseConfig {
|
|
5
5
|
strictToolRequired?: boolean;
|
|
6
|
-
textToolFallback?: boolean;
|
|
7
6
|
textNormalizer?: TextMarkupNormalizeOptions;
|
|
8
7
|
}
|
|
9
8
|
export declare function applyDeepSeekWebResponseTransform(payload: JsonObject, adapterContext?: AdapterContext, config?: DeepSeekWebResponseConfig): JsonObject;
|