acp-kernel 0.0.56-pr.210.62 → 0.0.56-pr.212.63
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/index.js
CHANGED
|
@@ -3251,6 +3251,23 @@ function parseStringInput(raw, callId, diag) {
|
|
|
3251
3251
|
diag.rawPrefix = raw.slice(0, 800);
|
|
3252
3252
|
diag.length = raw.length;
|
|
3253
3253
|
const cleaned = stripFence(raw.trim());
|
|
3254
|
+
const first = parseStringCore(cleaned, callId, diag);
|
|
3255
|
+
if (first.ranges.length === 0 || first.diagnostics.invalidItems > 0) {
|
|
3256
|
+
const normalized = normalizeSingleQuotes(cleaned);
|
|
3257
|
+
if (normalized !== void 0) {
|
|
3258
|
+
const retryDiag = { ok: false, kind: "ok", invalidItems: 0 };
|
|
3259
|
+
retryDiag.rawPrefix = diag.rawPrefix;
|
|
3260
|
+
retryDiag.length = diag.length;
|
|
3261
|
+
const retry = parseStringCore(normalized, callId, retryDiag);
|
|
3262
|
+
if (retry.ranges.length > first.ranges.length) {
|
|
3263
|
+
retryDiag.quoteSalvage = true;
|
|
3264
|
+
return retry;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
return first;
|
|
3269
|
+
}
|
|
3270
|
+
function parseStringCore(cleaned, callId, diag) {
|
|
3254
3271
|
if (cleaned === "") {
|
|
3255
3272
|
diag.kind = "empty-input";
|
|
3256
3273
|
return finish([], diag);
|
|
@@ -3294,6 +3311,7 @@ function parseObjectValue(value, callId, diag) {
|
|
|
3294
3311
|
}
|
|
3295
3312
|
entries = parsed.entries;
|
|
3296
3313
|
salvaged = parsed.salvaged;
|
|
3314
|
+
if (parsed.quoteRepaired) diag.quoteSalvage = true;
|
|
3297
3315
|
} else {
|
|
3298
3316
|
diag.kind = "content-not-array";
|
|
3299
3317
|
return finish([], diag);
|
|
@@ -3315,7 +3333,17 @@ function parseObjectValue(value, callId, diag) {
|
|
|
3315
3333
|
}
|
|
3316
3334
|
function parseContentArray(s) {
|
|
3317
3335
|
const cleaned = stripFence(s.trim());
|
|
3318
|
-
|
|
3336
|
+
const direct = parseContentArrayCore(cleaned);
|
|
3337
|
+
if (direct !== null && direct.entries.length > 0) return direct;
|
|
3338
|
+
const normalized = normalizeSingleQuotes(cleaned);
|
|
3339
|
+
if (normalized !== void 0) {
|
|
3340
|
+
const retry = parseContentArrayCore(normalized);
|
|
3341
|
+
if (retry !== null && retry.entries.length > 0) return { ...retry, quoteRepaired: true };
|
|
3342
|
+
}
|
|
3343
|
+
return direct;
|
|
3344
|
+
}
|
|
3345
|
+
function parseContentArrayCore(s) {
|
|
3346
|
+
let value = s === "" ? void 0 : tryParseLenient(s);
|
|
3319
3347
|
if (typeof value === "string") {
|
|
3320
3348
|
value = tryParseLenient(stripFence(value));
|
|
3321
3349
|
}
|
|
@@ -3323,7 +3351,7 @@ function parseContentArray(s) {
|
|
|
3323
3351
|
return { entries: value, salvaged: false };
|
|
3324
3352
|
}
|
|
3325
3353
|
if (value === void 0) {
|
|
3326
|
-
const entries = salvageContentEntries('{"content": ' +
|
|
3354
|
+
const entries = salvageContentEntries('{"content": ' + s);
|
|
3327
3355
|
return { entries, salvaged: entries.length > 0 };
|
|
3328
3356
|
}
|
|
3329
3357
|
return null;
|
|
@@ -3396,6 +3424,71 @@ function tryParseLenient(s) {
|
|
|
3396
3424
|
}
|
|
3397
3425
|
return void 0;
|
|
3398
3426
|
}
|
|
3427
|
+
function normalizeSingleQuotes(raw) {
|
|
3428
|
+
if (!raw.includes("'") || !raw.includes("{") && !raw.includes("[")) return void 0;
|
|
3429
|
+
let out = "";
|
|
3430
|
+
let changed = false;
|
|
3431
|
+
let inDouble = false;
|
|
3432
|
+
let inSingle = false;
|
|
3433
|
+
for (let i = 0; i < raw.length; i++) {
|
|
3434
|
+
const ch = raw.charAt(i);
|
|
3435
|
+
if (inDouble) {
|
|
3436
|
+
out += ch;
|
|
3437
|
+
if (ch === "\\" && i + 1 < raw.length) {
|
|
3438
|
+
out += raw.charAt(i + 1);
|
|
3439
|
+
i++;
|
|
3440
|
+
} else if (ch === '"') {
|
|
3441
|
+
inDouble = false;
|
|
3442
|
+
}
|
|
3443
|
+
continue;
|
|
3444
|
+
}
|
|
3445
|
+
if (inSingle) {
|
|
3446
|
+
if (ch === "\\" && i + 1 < raw.length) {
|
|
3447
|
+
const next = raw.charAt(i + 1);
|
|
3448
|
+
out += next === "'" ? "'" : "\\" + next;
|
|
3449
|
+
i++;
|
|
3450
|
+
continue;
|
|
3451
|
+
}
|
|
3452
|
+
if (ch === "'") {
|
|
3453
|
+
out += '"';
|
|
3454
|
+
inSingle = false;
|
|
3455
|
+
changed = true;
|
|
3456
|
+
continue;
|
|
3457
|
+
}
|
|
3458
|
+
if (ch === '"') {
|
|
3459
|
+
out += '\\"';
|
|
3460
|
+
continue;
|
|
3461
|
+
}
|
|
3462
|
+
if (ch === "\n") {
|
|
3463
|
+
out += "\\n";
|
|
3464
|
+
continue;
|
|
3465
|
+
}
|
|
3466
|
+
if (ch === "\r") {
|
|
3467
|
+
out += "\\r";
|
|
3468
|
+
continue;
|
|
3469
|
+
}
|
|
3470
|
+
if (ch === " ") {
|
|
3471
|
+
out += "\\t";
|
|
3472
|
+
continue;
|
|
3473
|
+
}
|
|
3474
|
+
out += ch;
|
|
3475
|
+
continue;
|
|
3476
|
+
}
|
|
3477
|
+
if (ch === '"') {
|
|
3478
|
+
inDouble = true;
|
|
3479
|
+
out += ch;
|
|
3480
|
+
continue;
|
|
3481
|
+
}
|
|
3482
|
+
if (ch === "'") {
|
|
3483
|
+
inSingle = true;
|
|
3484
|
+
out += '"';
|
|
3485
|
+
changed = true;
|
|
3486
|
+
continue;
|
|
3487
|
+
}
|
|
3488
|
+
out += ch;
|
|
3489
|
+
}
|
|
3490
|
+
return changed ? out : void 0;
|
|
3491
|
+
}
|
|
3399
3492
|
function stripFence(s) {
|
|
3400
3493
|
if (!s.startsWith("```")) return s;
|
|
3401
3494
|
const firstNewline = s.indexOf("\n");
|