@jsonstudio/llms 0.6.1643 → 0.6.1739
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/harvest-tool-calls-from-text.d.ts +10 -0
- package/dist/conversion/compat/actions/harvest-tool-calls-from-text.js +121 -0
- package/dist/conversion/compat/actions/iflow-kimi-cli-defaults.d.ts +10 -0
- package/dist/conversion/compat/actions/iflow-kimi-cli-defaults.js +80 -0
- package/dist/conversion/compat/actions/iflow-kimi-history-media-placeholder.d.ts +7 -0
- package/dist/conversion/compat/actions/iflow-kimi-history-media-placeholder.js +161 -0
- package/dist/conversion/compat/actions/iflow-kimi-thinking-reasoning-fill.d.ts +12 -0
- package/dist/conversion/compat/actions/iflow-kimi-thinking-reasoning-fill.js +67 -0
- package/dist/conversion/compat/actions/iflow-response-body-unwrap.d.ts +9 -0
- package/dist/conversion/compat/actions/iflow-response-body-unwrap.js +140 -0
- package/dist/conversion/compat/actions/lmstudio-responses-fc-ids.d.ts +10 -0
- package/dist/conversion/compat/actions/lmstudio-responses-fc-ids.js +59 -0
- package/dist/conversion/compat/actions/lmstudio-responses-input-stringify.d.ts +14 -0
- package/dist/conversion/compat/actions/lmstudio-responses-input-stringify.js +125 -0
- package/dist/conversion/compat/actions/normalize-tool-call-ids.d.ts +11 -0
- package/dist/conversion/compat/actions/normalize-tool-call-ids.js +140 -0
- package/dist/conversion/compat/actions/strip-orphan-function-calls-tag.d.ts +2 -0
- package/dist/conversion/compat/actions/strip-orphan-function-calls-tag.js +152 -0
- package/dist/conversion/compat/antigravity-session-signature.d.ts +1 -1
- package/dist/conversion/compat/antigravity-session-signature.js +5 -4
- package/dist/conversion/compat/profiles/chat-iflow.json +6 -0
- package/dist/conversion/compat/profiles/chat-lmstudio.json +7 -1
- package/dist/conversion/hub/operation-table/operation-table-runner.js +1 -1
- package/dist/conversion/hub/operation-table/semantic-mappers/gemini-mapper.js +19 -2
- package/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +101 -5
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.d.ts +2 -0
- package/dist/conversion/hub/pipeline/compat/compat-profile-resolver.js +63 -0
- package/dist/conversion/hub/pipeline/compat/compat-types.d.ts +18 -0
- package/dist/conversion/hub/pipeline/hub-pipeline.js +1 -1
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage1_semantic_map/index.js +8 -5
- package/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +5 -1
- package/dist/conversion/hub/pipeline/stages/resp_inbound/resp_inbound_stage1_sse_decode/index.js +113 -0
- package/dist/conversion/hub/pipeline/target-utils.js +3 -0
- package/dist/conversion/hub/response/provider-response.js +27 -1
- package/dist/conversion/responses/responses-openai-bridge.js +32 -6
- package/dist/conversion/shared/anthropic-message-utils.js +20 -5
- package/dist/conversion/shared/bridge-id-utils.d.ts +2 -0
- package/dist/conversion/shared/bridge-id-utils.js +52 -15
- package/dist/conversion/shared/responses-conversation-store.js +40 -5
- package/dist/conversion/shared/responses-output-builder.js +23 -7
- package/dist/conversion/shared/responses-tool-utils.d.ts +1 -0
- package/dist/conversion/shared/responses-tool-utils.js +30 -13
- package/dist/conversion/shared/text-markup-normalizer.d.ts +1 -0
- package/dist/conversion/shared/text-markup-normalizer.js +269 -1
- package/dist/router/virtual-router/bootstrap.js +31 -7
- package/dist/router/virtual-router/classifier.js +1 -1
- package/dist/router/virtual-router/engine/antigravity/alias-lease.d.ts +33 -0
- package/dist/router/virtual-router/engine/antigravity/alias-lease.js +247 -0
- package/dist/router/virtual-router/engine/health/index.d.ts +23 -0
- package/dist/router/virtual-router/engine/health/index.js +720 -0
- package/dist/router/virtual-router/engine/provider-key/parse.d.ts +6 -0
- package/dist/router/virtual-router/engine/provider-key/parse.js +43 -0
- package/dist/router/virtual-router/engine/routing-pools/index.d.ts +13 -0
- package/dist/router/virtual-router/engine/routing-pools/index.js +225 -0
- package/dist/router/virtual-router/engine/routing-state/keys.d.ts +3 -0
- package/dist/router/virtual-router/engine/routing-state/keys.js +30 -0
- package/dist/router/virtual-router/engine/routing-state/metadata.d.ts +6 -0
- package/dist/router/virtual-router/engine/routing-state/metadata.js +132 -0
- package/dist/router/virtual-router/engine/routing-state/store.d.ts +11 -0
- package/dist/router/virtual-router/engine/routing-state/store.js +107 -0
- package/dist/router/virtual-router/engine-health.d.ts +1 -23
- package/dist/router/virtual-router/engine-health.js +1 -720
- package/dist/router/virtual-router/engine-selection/route-utils.js +57 -0
- package/dist/router/virtual-router/engine-selection/tier-selection-select.js +8 -48
- package/dist/router/virtual-router/engine-selection/tier-selection.js +34 -17
- package/dist/router/virtual-router/engine-selection.d.ts +1 -13
- package/dist/router/virtual-router/engine-selection.js +1 -225
- package/dist/router/virtual-router/engine.d.ts +2 -23
- package/dist/router/virtual-router/engine.js +130 -603
- package/dist/router/virtual-router/message-utils.js +15 -5
- package/dist/servertool/engine.js +4 -4
- package/dist/servertool/handlers/followup-request-builder.js +46 -0
- package/dist/servertool/handlers/gemini-empty-reply-continue.js +48 -47
- package/dist/servertool/handlers/stop-message-auto.js +64 -7
- package/dist/servertool/handlers/vision.js +10 -0
- package/dist/servertool/types.d.ts +3 -0
- package/dist/sse/sse-to-json/builders/response-builder.js +6 -0
- package/dist/sse/sse-to-json/chat-sse-to-json-converter.js +32 -2
- package/dist/sse/sse-to-json/parsers/sse-parser.js +34 -0
- package/dist/sse/sse-to-json/responses-sse-to-json-converter.d.ts +1 -0
- package/dist/sse/sse-to-json/responses-sse-to-json-converter.js +33 -1
- package/dist/tools/apply-patch/args-normalizer/default-actions.d.ts +2 -0
- package/dist/tools/apply-patch/args-normalizer/default-actions.js +12 -0
- package/dist/tools/apply-patch/args-normalizer/extract-patch.d.ts +2 -0
- package/dist/tools/apply-patch/args-normalizer/extract-patch.js +15 -0
- package/dist/tools/apply-patch/args-normalizer/index.d.ts +2 -0
- package/dist/tools/apply-patch/args-normalizer/index.js +164 -0
- package/dist/tools/apply-patch/args-normalizer/structured-builders.d.ts +7 -0
- package/dist/tools/apply-patch/args-normalizer/structured-builders.js +85 -0
- package/dist/tools/apply-patch/args-normalizer/types.d.ts +54 -0
- package/dist/tools/apply-patch/args-normalizer/types.js +1 -0
- package/dist/tools/apply-patch/patch-text/looks-like-patch.js +1 -0
- package/dist/tools/apply-patch/patch-text/normalize.js +104 -5
- package/dist/tools/apply-patch/structured/coercion.js +28 -4
- package/dist/tools/apply-patch/validator.js +7 -146
- package/package.json +1 -1
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { coerceStructuredPayload } from './structured/coercion.js';
|
|
3
|
-
import { tryParseJsonLoose } from './json/parse-loose.js';
|
|
1
|
+
import { normalizeApplyPatchArgs } from './args-normalizer/index.js';
|
|
4
2
|
import { normalizeApplyPatchText, looksLikePatch } from './patch-text/normalize.js';
|
|
5
|
-
import { asString, isRecord } from './validation/shared.js';
|
|
6
3
|
export { looksLikePatch, normalizeApplyPatchText };
|
|
7
4
|
const toJson = (value) => {
|
|
8
5
|
try {
|
|
@@ -13,148 +10,12 @@ const toJson = (value) => {
|
|
|
13
10
|
}
|
|
14
11
|
};
|
|
15
12
|
export function validateApplyPatchArgs(argsString, rawArgs) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!looksJsonContainer && looksLikePatch(rawTrimmed)) {
|
|
20
|
-
const patchText = normalizeApplyPatchText(rawTrimmed);
|
|
21
|
-
if (!patchText.includes('*** Begin Patch')) {
|
|
22
|
-
return { ok: false, reason: 'unsupported_patch_format' };
|
|
23
|
-
}
|
|
24
|
-
return { ok: true, normalizedArgs: toJson({ patch: patchText, input: patchText }) };
|
|
13
|
+
const normalized = normalizeApplyPatchArgs(argsString, rawArgs);
|
|
14
|
+
if (normalized.ok === false) {
|
|
15
|
+
return { ok: false, reason: normalized.reason };
|
|
25
16
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const patchText = normalizeApplyPatchText(rawTrimmed);
|
|
30
|
-
if (!patchText.includes('*** Begin Patch'))
|
|
31
|
-
return { failureReason: 'unsupported_patch_format' };
|
|
32
|
-
return { patchText };
|
|
33
|
-
}
|
|
34
|
-
const patchField = asString(rec.patch);
|
|
35
|
-
if (patchField && looksLikePatch(patchField)) {
|
|
36
|
-
const patchText = normalizeApplyPatchText(patchField);
|
|
37
|
-
if (!patchText.includes('*** Begin Patch'))
|
|
38
|
-
return { failureReason: 'unsupported_patch_format' };
|
|
39
|
-
return { patchText };
|
|
40
|
-
}
|
|
41
|
-
const diffField = asString(rec.diff) ?? asString(rec.patchText) ?? asString(rec.body);
|
|
42
|
-
if (diffField && looksLikePatch(diffField)) {
|
|
43
|
-
const patchText = normalizeApplyPatchText(diffField);
|
|
44
|
-
if (!patchText.includes('*** Begin Patch'))
|
|
45
|
-
return { failureReason: 'unsupported_patch_format' };
|
|
46
|
-
return { patchText };
|
|
47
|
-
}
|
|
48
|
-
const inputField = asString(rec.input);
|
|
49
|
-
if (inputField && looksLikePatch(inputField)) {
|
|
50
|
-
const patchText = normalizeApplyPatchText(inputField);
|
|
51
|
-
if (!patchText.includes('*** Begin Patch'))
|
|
52
|
-
return { failureReason: 'unsupported_patch_format' };
|
|
53
|
-
return { patchText };
|
|
54
|
-
}
|
|
55
|
-
// Common shape: patch text stored under `instructions` (e.g. "*** Update File: ...").
|
|
56
|
-
const instructionsField = asString(rec.instructions);
|
|
57
|
-
if (instructionsField && looksLikePatch(instructionsField)) {
|
|
58
|
-
const patchText = normalizeApplyPatchText(instructionsField);
|
|
59
|
-
if (!patchText.includes('*** Begin Patch'))
|
|
60
|
-
return { failureReason: 'unsupported_patch_format' };
|
|
61
|
-
return { patchText };
|
|
62
|
-
}
|
|
63
|
-
// Common wrapper shape (seen in codex samples): { _raw: "{...json...}" }.
|
|
64
|
-
// `_raw` may contain either patch text or a JSON-encoded structured payload.
|
|
65
|
-
const rawEnvelope = asString(rec._raw);
|
|
66
|
-
if (rawEnvelope) {
|
|
67
|
-
const trimmed = rawEnvelope.trim();
|
|
68
|
-
if (looksLikePatch(trimmed)) {
|
|
69
|
-
const patchText = normalizeApplyPatchText(trimmed);
|
|
70
|
-
if (!patchText.includes('*** Begin Patch'))
|
|
71
|
-
return { failureReason: 'unsupported_patch_format' };
|
|
72
|
-
return { patchText };
|
|
73
|
-
}
|
|
74
|
-
const parsed = tryParseJsonLoose(trimmed);
|
|
75
|
-
if (parsed && isRecord(parsed)) {
|
|
76
|
-
return extractFromRecord(parsed);
|
|
77
|
-
}
|
|
78
|
-
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
79
|
-
const changesArray = parsed.filter((entry) => isRecord(entry));
|
|
80
|
-
if (changesArray.length && changesArray.some((c) => typeof c.kind === 'string')) {
|
|
81
|
-
const payload = { changes: changesArray };
|
|
82
|
-
try {
|
|
83
|
-
return { patchText: buildStructuredPatch(payload) };
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
if (!(error instanceof StructuredApplyPatchError))
|
|
87
|
-
throw error;
|
|
88
|
-
return { failureReason: error.reason || 'structured_apply_patch_error' };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const payload = coerceStructuredPayload(rec);
|
|
94
|
-
if (payload) {
|
|
95
|
-
try {
|
|
96
|
-
return { patchText: buildStructuredPatch(payload) };
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
if (!(error instanceof StructuredApplyPatchError))
|
|
100
|
-
throw error;
|
|
101
|
-
return { failureReason: error.reason || 'structured_apply_patch_error' };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return {};
|
|
17
|
+
return {
|
|
18
|
+
ok: true,
|
|
19
|
+
normalizedArgs: toJson({ patch: normalized.patchText, input: normalized.patchText })
|
|
105
20
|
};
|
|
106
|
-
let patchText;
|
|
107
|
-
let failureReason;
|
|
108
|
-
if (isRecord(rawArgs)) {
|
|
109
|
-
const res = extractFromRecord(rawArgs);
|
|
110
|
-
patchText = res.patchText;
|
|
111
|
-
failureReason = res.failureReason;
|
|
112
|
-
}
|
|
113
|
-
else if (Array.isArray(rawArgs) && rawArgs.length > 0) {
|
|
114
|
-
// compatibility: arguments may be either:
|
|
115
|
-
// - a single-element array [{ file, changes: [...] }]
|
|
116
|
-
// - a raw changes array [{ kind, ... }, ...]
|
|
117
|
-
const first = rawArgs.find((entry) => isRecord(entry));
|
|
118
|
-
if (first && Array.isArray(first.changes)) {
|
|
119
|
-
const res = extractFromRecord(first);
|
|
120
|
-
patchText = res.patchText;
|
|
121
|
-
failureReason = res.failureReason;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
const changesArray = rawArgs.filter((entry) => isRecord(entry));
|
|
125
|
-
if (changesArray.length && changesArray.some((c) => typeof c.kind === 'string')) {
|
|
126
|
-
const payload = { changes: changesArray };
|
|
127
|
-
try {
|
|
128
|
-
patchText = buildStructuredPatch(payload);
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
if (!(error instanceof StructuredApplyPatchError))
|
|
132
|
-
throw error;
|
|
133
|
-
failureReason = error.reason || 'structured_apply_patch_error';
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (typeof rawArgs === 'string' && looksLikePatch(rawArgs)) {
|
|
139
|
-
const normalized = normalizeApplyPatchText(rawArgs);
|
|
140
|
-
if (normalized.includes('*** Begin Patch')) {
|
|
141
|
-
patchText = normalized;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
failureReason = 'unsupported_patch_format';
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!patchText) {
|
|
148
|
-
if (failureReason)
|
|
149
|
-
return { ok: false, reason: failureReason };
|
|
150
|
-
if (looksJsonContainer &&
|
|
151
|
-
isRecord(rawArgs) &&
|
|
152
|
-
Object.keys(rawArgs).length === 0 &&
|
|
153
|
-
rawTrimmed.length > 0 &&
|
|
154
|
-
!looksLikePatch(rawTrimmed)) {
|
|
155
|
-
return { ok: false, reason: 'invalid_json' };
|
|
156
|
-
}
|
|
157
|
-
return { ok: false, reason: 'missing_changes' };
|
|
158
|
-
}
|
|
159
|
-
return { ok: true, normalizedArgs: toJson({ patch: patchText, input: patchText }) };
|
|
160
21
|
}
|