@jsonstudio/llms 0.6.568 → 0.6.626

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/conversion/compat/profiles/chat-gemini.json +15 -15
  2. package/dist/conversion/compat/profiles/chat-glm.json +194 -194
  3. package/dist/conversion/compat/profiles/chat-iflow.json +199 -199
  4. package/dist/conversion/compat/profiles/chat-lmstudio.json +43 -43
  5. package/dist/conversion/compat/profiles/chat-qwen.json +20 -20
  6. package/dist/conversion/compat/profiles/responses-c4m.json +42 -42
  7. package/dist/conversion/compat/profiles/responses-output2choices-test.json +9 -10
  8. package/dist/conversion/hub/pipeline/hub-pipeline.d.ts +0 -1
  9. package/dist/conversion/hub/pipeline/hub-pipeline.js +68 -69
  10. package/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +0 -34
  11. package/dist/conversion/hub/process/chat-process.js +37 -16
  12. package/dist/conversion/hub/response/provider-response.js +0 -8
  13. package/dist/conversion/hub/response/response-runtime.js +47 -1
  14. package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +59 -4
  15. package/dist/conversion/hub/semantic-mappers/chat-mapper.d.ts +8 -0
  16. package/dist/conversion/hub/semantic-mappers/chat-mapper.js +93 -12
  17. package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +208 -31
  18. package/dist/conversion/hub/semantic-mappers/responses-mapper.js +280 -14
  19. package/dist/conversion/hub/standardized-bridge.js +11 -2
  20. package/dist/conversion/hub/types/chat-envelope.d.ts +10 -0
  21. package/dist/conversion/hub/types/standardized.d.ts +2 -1
  22. package/dist/conversion/responses/responses-openai-bridge.d.ts +3 -2
  23. package/dist/conversion/responses/responses-openai-bridge.js +1 -13
  24. package/dist/conversion/shared/text-markup-normalizer.d.ts +20 -0
  25. package/dist/conversion/shared/text-markup-normalizer.js +84 -5
  26. package/dist/conversion/shared/tool-filter-pipeline.d.ts +1 -1
  27. package/dist/conversion/shared/tool-filter-pipeline.js +54 -29
  28. package/dist/filters/index.d.ts +1 -0
  29. package/dist/filters/special/response-apply-patch-toon-decode.js +15 -7
  30. package/dist/filters/special/response-tool-arguments-toon-decode.js +108 -22
  31. package/dist/guidance/index.js +2 -0
  32. package/dist/router/virtual-router/classifier.js +16 -12
  33. package/dist/router/virtual-router/engine.js +45 -4
  34. package/dist/router/virtual-router/tool-signals.d.ts +2 -1
  35. package/dist/router/virtual-router/tool-signals.js +293 -134
  36. package/dist/router/virtual-router/types.d.ts +1 -1
  37. package/dist/router/virtual-router/types.js +1 -1
  38. package/dist/servertool/handlers/gemini-empty-reply-continue.js +28 -4
  39. package/dist/sse/json-to-sse/event-generators/responses.js +9 -2
  40. package/dist/sse/sse-to-json/builders/anthropic-response-builder.js +7 -3
  41. package/dist/tools/apply-patch-structured.js +4 -3
  42. package/package.json +2 -2
@@ -1,17 +1,17 @@
1
1
  {
2
- "id": "chat:gemini",
3
- "protocol": "gemini-chat",
4
- "request": {
5
- "mappings": [
6
- { "action": "snapshot", "phase": "compat-pre" },
7
- { "action": "claude_thinking_tool_schema" },
8
- {
9
- "action": "gemini_web_search_request"
10
- },
11
- { "action": "snapshot", "phase": "compat-post" }
12
- ]
13
- },
14
- "response": {
15
- "mappings": []
16
- }
2
+ "id": "chat:gemini",
3
+ "protocol": "gemini-chat",
4
+ "request": {
5
+ "mappings": [
6
+ { "action": "snapshot", "phase": "compat-pre" },
7
+ { "action": "claude_thinking_tool_schema" },
8
+ {
9
+ "action": "gemini_web_search_request"
10
+ },
11
+ { "action": "snapshot", "phase": "compat-post" }
12
+ ]
13
+ },
14
+ "response": {
15
+ "mappings": []
16
+ }
17
17
  }
@@ -1,204 +1,204 @@
1
1
  {
2
- "id": "chat:glm",
3
- "protocol": "openai-chat",
4
- "request": {
5
- "mappings": [
6
- { "action": "snapshot", "phase": "compat-pre" },
7
- { "action": "dto_unwrap" },
8
- {
9
- "action": "remove",
10
- "path": "parallel_tool_calls"
11
- },
12
- {
13
- "action": "glm_image_content"
14
- },
15
- {
16
- "action": "glm_vision_prompt"
17
- },
18
- {
19
- "action": "rename",
20
- "from": "response_format",
21
- "to": "metadata.generation.response_format"
22
- },
23
- {
24
- "action": "remove",
25
- "path": "metadata.clientModelId"
26
- },
27
- {
28
- "action": "shape_filter",
29
- "target": "request",
30
- "config": {
31
- "request": {
32
- "allowTopLevel": [
33
- "model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
34
- "max_tokens", "tools", "tool_choice", "stop", "response_format", "web_search"
35
- ],
36
- "messages": {
37
- "allowedRoles": ["system", "user", "assistant", "tool"],
38
- "assistantWithToolCallsContentNull": true,
39
- "toolContentStringify": false
2
+ "id": "chat:glm",
3
+ "protocol": "openai-chat",
4
+ "request": {
5
+ "mappings": [
6
+ { "action": "snapshot", "phase": "compat-pre" },
7
+ { "action": "dto_unwrap" },
8
+ {
9
+ "action": "remove",
10
+ "path": "parallel_tool_calls"
40
11
  },
41
- "messagesRules": [],
42
- "tools": {
43
- "normalize": false,
44
- "forceToolChoiceAuto": true
12
+ {
13
+ "action": "glm_image_content"
45
14
  },
46
- "assistantToolCalls": { "functionArgumentsType": "string" }
47
- },
48
- "response": {
49
- "allowTopLevel": [
50
- "id", "request_id", "created", "model",
51
- "choices", "usage", "video_result", "web_search", "content_filter",
52
- "required_action", "output", "output_text", "status"
53
- ],
54
- "choices": {
55
- "required": true,
56
- "message": {
57
- "allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
58
- "roleDefault": "assistant",
59
- "contentNullWhenToolCalls": true,
60
- "tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
61
- },
62
- "finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
15
+ {
16
+ "action": "glm_vision_prompt"
63
17
  },
64
- "usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
65
- }
66
- }
67
- },
68
- {
69
- "action": "apply_rules",
70
- "config": {
71
- "tools": {
72
- "function": {
73
- "removeKeys": ["strict", "json_schema"]
74
- }
75
- },
76
- "messages": {
77
- "assistantToolCalls": {
78
- "function": {
79
- "removeKeys": ["strict"]
80
- }
81
- }
82
- },
83
- "topLevel": {
84
- "conditional": [
85
- { "when": { "tools": "empty" }, "remove": ["tool_choice"] }
86
- ]
87
- }
88
- }
89
- },
90
- {
91
- "action": "field_map",
92
- "direction": "incoming",
93
- "config": [
94
- { "sourcePath": "usage.prompt_tokens", "targetPath": "usage.input_tokens", "type": "number" },
95
- { "sourcePath": "usage.completion_tokens", "targetPath": "usage.output_tokens", "type": "number" },
96
- { "sourcePath": "created", "targetPath": "created_at", "type": "number" },
97
- { "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
98
- { "sourcePath": "model", "targetPath": "model", "type": "string", "transform": "normalizeModelName" },
99
- {
100
- "sourcePath": "choices[*].message.tool_calls[*].function.arguments",
101
- "targetPath": "choices[*].message.tool_calls[*].function.arguments",
102
- "type": "string"
103
- }
18
+ {
19
+ "action": "rename",
20
+ "from": "response_format",
21
+ "to": "metadata.generation.response_format"
22
+ },
23
+ {
24
+ "action": "remove",
25
+ "path": "metadata.clientModelId"
26
+ },
27
+ {
28
+ "action": "shape_filter",
29
+ "target": "request",
30
+ "config": {
31
+ "request": {
32
+ "allowTopLevel": [
33
+ "model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
34
+ "max_tokens", "tools", "tool_choice", "stop", "response_format", "web_search"
35
+ ],
36
+ "messages": {
37
+ "allowedRoles": ["system", "user", "assistant", "tool"],
38
+ "assistantWithToolCallsContentNull": true,
39
+ "toolContentStringify": false
40
+ },
41
+ "messagesRules": [],
42
+ "tools": {
43
+ "normalize": false,
44
+ "forceToolChoiceAuto": true
45
+ },
46
+ "assistantToolCalls": { "functionArgumentsType": "string" }
47
+ },
48
+ "response": {
49
+ "allowTopLevel": [
50
+ "id", "request_id", "created", "model",
51
+ "choices", "usage", "video_result", "web_search", "content_filter",
52
+ "required_action", "output", "output_text", "status"
53
+ ],
54
+ "choices": {
55
+ "required": true,
56
+ "message": {
57
+ "allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
58
+ "roleDefault": "assistant",
59
+ "contentNullWhenToolCalls": true,
60
+ "tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
61
+ },
62
+ "finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
63
+ },
64
+ "usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
65
+ }
66
+ }
67
+ },
68
+ {
69
+ "action": "apply_rules",
70
+ "config": {
71
+ "tools": {
72
+ "function": {
73
+ "removeKeys": ["strict", "json_schema"]
74
+ }
75
+ },
76
+ "messages": {
77
+ "assistantToolCalls": {
78
+ "function": {
79
+ "removeKeys": ["strict"]
80
+ }
81
+ }
82
+ },
83
+ "topLevel": {
84
+ "conditional": [
85
+ { "when": { "tools": "empty" }, "remove": ["tool_choice"] }
86
+ ]
87
+ }
88
+ }
89
+ },
90
+ {
91
+ "action": "field_map",
92
+ "direction": "incoming",
93
+ "config": [
94
+ { "sourcePath": "usage.prompt_tokens", "targetPath": "usage.input_tokens", "type": "number" },
95
+ { "sourcePath": "usage.completion_tokens", "targetPath": "usage.output_tokens", "type": "number" },
96
+ { "sourcePath": "created", "targetPath": "created_at", "type": "number" },
97
+ { "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
98
+ { "sourcePath": "model", "targetPath": "model", "type": "string", "transform": "normalizeModelName" },
99
+ {
100
+ "sourcePath": "choices[*].message.tool_calls[*].function.arguments",
101
+ "targetPath": "choices[*].message.tool_calls[*].function.arguments",
102
+ "type": "string"
103
+ }
104
+ ]
105
+ },
106
+ { "action": "tool_schema_sanitize", "mode": "glm_shell" },
107
+ {
108
+ "action": "glm_web_search_request"
109
+ },
110
+ {
111
+ "action": "auto_thinking",
112
+ "config": {
113
+ "modelPrefixes": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-z1"],
114
+ "excludePrefixes": ["glm-4.6v"]
115
+ }
116
+ },
117
+ { "action": "snapshot", "phase": "compat-post" },
118
+ { "action": "dto_rewrap" }
104
119
  ]
105
- },
106
- { "action": "tool_schema_sanitize", "mode": "glm_shell" },
107
- {
108
- "action": "glm_web_search_request"
109
- },
110
- {
111
- "action": "auto_thinking",
112
- "config": {
113
- "modelPrefixes": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-z1"],
114
- "excludePrefixes": ["glm-4.6v"]
115
- }
116
- },
117
- { "action": "snapshot", "phase": "compat-post" },
118
- { "action": "dto_rewrap" }
119
- ]
120
- },
121
- "response": {
122
- "mappings": [
123
- { "action": "snapshot", "phase": "compat-pre" },
124
- { "action": "dto_unwrap" },
125
- {
126
- "action": "resp_blacklist",
127
- "config": {
128
- "paths": ["usage.prompt_tokens_details.cached_tokens"],
129
- "keepCritical": true
130
- }
131
- },
132
- {
133
- "action": "shape_filter",
134
- "target": "response",
135
- "config": {
136
- "request": {
137
- "allowTopLevel": [
138
- "model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
139
- "max_tokens", "tools", "tool_choice", "stop", "response_format"
140
- ],
141
- "messages": {
142
- "allowedRoles": ["system", "user", "assistant", "tool"],
143
- "assistantWithToolCallsContentNull": true,
144
- "toolContentStringify": false
120
+ },
121
+ "response": {
122
+ "mappings": [
123
+ { "action": "snapshot", "phase": "compat-pre" },
124
+ { "action": "dto_unwrap" },
125
+ {
126
+ "action": "resp_blacklist",
127
+ "config": {
128
+ "paths": ["usage.prompt_tokens_details.cached_tokens"],
129
+ "keepCritical": true
130
+ }
145
131
  },
146
- "messagesRules": [],
147
- "tools": {
148
- "normalize": false,
149
- "forceToolChoiceAuto": true
132
+ {
133
+ "action": "shape_filter",
134
+ "target": "response",
135
+ "config": {
136
+ "request": {
137
+ "allowTopLevel": [
138
+ "model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
139
+ "max_tokens", "tools", "tool_choice", "stop", "response_format"
140
+ ],
141
+ "messages": {
142
+ "allowedRoles": ["system", "user", "assistant", "tool"],
143
+ "assistantWithToolCallsContentNull": true,
144
+ "toolContentStringify": false
145
+ },
146
+ "messagesRules": [],
147
+ "tools": {
148
+ "normalize": false,
149
+ "forceToolChoiceAuto": true
150
+ },
151
+ "assistantToolCalls": { "functionArgumentsType": "string" }
152
+ },
153
+ "response": {
154
+ "allowTopLevel": [
155
+ "id", "request_id", "created", "model",
156
+ "choices", "usage", "video_result", "web_search", "content_filter",
157
+ "required_action", "output", "output_text", "status"
158
+ ],
159
+ "choices": {
160
+ "required": true,
161
+ "message": {
162
+ "allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
163
+ "roleDefault": "assistant",
164
+ "contentNullWhenToolCalls": true,
165
+ "tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
166
+ },
167
+ "finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
168
+ },
169
+ "usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
170
+ }
171
+ }
150
172
  },
151
- "assistantToolCalls": { "functionArgumentsType": "string" }
152
- },
153
- "response": {
154
- "allowTopLevel": [
155
- "id", "request_id", "created", "model",
156
- "choices", "usage", "video_result", "web_search", "content_filter",
157
- "required_action", "output", "output_text", "status"
158
- ],
159
- "choices": {
160
- "required": true,
161
- "message": {
162
- "allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
163
- "roleDefault": "assistant",
164
- "contentNullWhenToolCalls": true,
165
- "tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
166
- },
167
- "finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
173
+ {
174
+ "action": "field_map",
175
+ "direction": "outgoing",
176
+ "config": [
177
+ { "sourcePath": "usage.input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
178
+ { "sourcePath": "usage.output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
179
+ { "sourcePath": "usage.total_input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
180
+ { "sourcePath": "usage.total_output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
181
+ { "sourcePath": "created_at", "targetPath": "created", "type": "number" },
182
+ { "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
183
+ {
184
+ "sourcePath": "choices[*].finish_reason",
185
+ "targetPath": "choices[*].finish_reason",
186
+ "type": "string",
187
+ "transform": "normalizeFinishReason"
188
+ },
189
+ {
190
+ "sourcePath": "choices[*].message.tool_calls[*].function.arguments",
191
+ "targetPath": "choices[*].message.tool_calls[*].function.arguments",
192
+ "type": "string"
193
+ }
194
+ ]
168
195
  },
169
- "usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
170
- }
171
- }
172
- },
173
- {
174
- "action": "field_map",
175
- "direction": "outgoing",
176
- "config": [
177
- { "sourcePath": "usage.input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
178
- { "sourcePath": "usage.output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
179
- { "sourcePath": "usage.total_input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
180
- { "sourcePath": "usage.total_output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
181
- { "sourcePath": "created_at", "targetPath": "created", "type": "number" },
182
- { "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
183
- {
184
- "sourcePath": "choices[*].finish_reason",
185
- "targetPath": "choices[*].finish_reason",
186
- "type": "string",
187
- "transform": "normalizeFinishReason"
188
- },
189
- {
190
- "sourcePath": "choices[*].message.tool_calls[*].function.arguments",
191
- "targetPath": "choices[*].message.tool_calls[*].function.arguments",
192
- "type": "string"
193
- }
196
+ { "action": "tool_schema_sanitize", "mode": "glm_shell" },
197
+ { "action": "response_normalize" },
198
+ { "action": "extract_glm_tool_markup" },
199
+ { "action": "response_validate" },
200
+ { "action": "snapshot", "phase": "compat-post" },
201
+ { "action": "dto_rewrap" }
194
202
  ]
195
- },
196
- { "action": "tool_schema_sanitize", "mode": "glm_shell" },
197
- { "action": "response_normalize" },
198
- { "action": "extract_glm_tool_markup" },
199
- { "action": "response_validate" },
200
- { "action": "snapshot", "phase": "compat-post" },
201
- { "action": "dto_rewrap" }
202
- ]
203
- }
203
+ }
204
204
  }