acp-kernel 0.0.98-pr.485.342 → 0.0.99-pr.477.345

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
@@ -7529,12 +7529,30 @@ function parseStringCore(cleaned, callId, diag) {
7529
7529
  if (value !== null && typeof value === "object" && !Array.isArray(value)) {
7530
7530
  return parseObjectValue(value, callId, diag);
7531
7531
  }
7532
+ if (typeof value === "string") {
7533
+ const recovered2 = salvageLineFormEntries(value, callId);
7534
+ if (recovered2.ranges.length > 0)
7535
+ return finishLineFormSalvage(recovered2, diag, false);
7536
+ }
7532
7537
  if (value !== void 0) {
7533
7538
  diag.kind = "not-object";
7534
7539
  return finish([], diag);
7535
7540
  }
7536
- const entries = salvageContentEntries(cleaned);
7537
- return finishSalvage(entries, callId, diag, looksTruncated(cleaned));
7541
+ let entries = salvageContentEntries(cleaned);
7542
+ let fromStringSlot = false;
7543
+ if (entries.length === 0) {
7544
+ entries = salvageStringSlotEntries(cleaned);
7545
+ fromStringSlot = entries.length > 0;
7546
+ }
7547
+ if (entries.length > 0) {
7548
+ const out = finishSalvage(entries, callId, diag, true);
7549
+ if (fromStringSlot && out.ranges.length > 0) diag.contentSalvage = true;
7550
+ return out;
7551
+ }
7552
+ const recovered = salvageLineFormEntries(cleaned, callId);
7553
+ if (recovered.ranges.length > 0)
7554
+ return finishLineFormSalvage(recovered, diag, looksTruncated(cleaned));
7555
+ return finishSalvage([], callId, diag, looksTruncated(cleaned));
7538
7556
  }
7539
7557
  function parseObjectValue(value, callId, diag) {
7540
7558
  diag.keys = Object.keys(value);
@@ -7556,11 +7574,11 @@ function parseObjectValue(value, callId, diag) {
7556
7574
  const parsed = parseContentArray(content);
7557
7575
  if (parsed === null || parsed.entries.length === 0 && content.trim().length > 0) {
7558
7576
  const bare = stripJsonWrapperResidue(content);
7559
- const entries2 = splitLineEntries(bare);
7577
+ const entries2 = inlineSingleLineEntry(splitLineEntries(bare));
7560
7578
  const { ranges: ranges2, invalid: invalid2, reasons: reasons2 } = validateEntries(entries2, callId);
7579
+ diag.invalidItems = invalid2;
7580
+ if (reasons2.length > 0) diag.invalidReasons = reasons2;
7561
7581
  if (ranges2.length > 0) {
7562
- diag.invalidItems = invalid2;
7563
- if (reasons2.length > 0) diag.invalidReasons = reasons2;
7564
7582
  diag.kind = "ok";
7565
7583
  return finish(ranges2, diag);
7566
7584
  }
@@ -8021,6 +8039,56 @@ function looksTruncated(s) {
8021
8039
  }
8022
8040
  return depth > 0 || inString;
8023
8041
  }
8042
+ function inlineSingleLineEntry(entries) {
8043
+ if (entries.length !== 1) return entries;
8044
+ const e = entries[0];
8045
+ if (typeof e !== "string" || e.includes("\n")) return entries;
8046
+ const head = e.trim();
8047
+ const m = REF_PAIR_IN_LINE.exec(head) ?? SINGLE_REF_IN_LINE.exec(head);
8048
+ if (m === null) return entries;
8049
+ const rest = head.slice(m.index + m[0].length).trim();
8050
+ if (!/\p{L}|\p{N}/u.test(rest)) return entries;
8051
+ return [m[0] + "\n" + rest];
8052
+ }
8053
+ function salvageLineFormEntries(text, callId) {
8054
+ return validateEntries(
8055
+ inlineSingleLineEntry(splitLineEntries(stripJsonWrapperResidue(text))),
8056
+ callId
8057
+ );
8058
+ }
8059
+ function finishLineFormSalvage(result, diag, truncatedShape) {
8060
+ diag.stringSalvage = true;
8061
+ diag.invalidItems = result.invalid;
8062
+ if (result.reasons.length > 0) diag.invalidReasons = result.reasons;
8063
+ diag.kind = truncatedShape ? "truncated" : "ok";
8064
+ return finish(result.ranges, diag);
8065
+ }
8066
+ function salvageStringSlotEntries(raw) {
8067
+ const match = /"content"\s*:\s*"/.exec(raw);
8068
+ if (match === null) return [];
8069
+ const start = match.index + match[0].length;
8070
+ let i = start;
8071
+ let terminated = false;
8072
+ while (i < raw.length) {
8073
+ const ch = raw.charAt(i);
8074
+ if (ch === "\\") {
8075
+ i += 2;
8076
+ continue;
8077
+ }
8078
+ if (ch === '"') {
8079
+ terminated = true;
8080
+ break;
8081
+ }
8082
+ i++;
8083
+ }
8084
+ const body = raw.slice(start, i).replace(/\\n/g, "\n");
8085
+ const parts = splitLineEntries(body);
8086
+ if (!terminated) {
8087
+ if (parts.length <= 1) return [];
8088
+ parts.pop();
8089
+ }
8090
+ return parts;
8091
+ }
8024
8092
  function salvageContentEntries(raw) {
8025
8093
  const match = /"content"\s*:\s*\[/.exec(raw);
8026
8094
  if (match === null) return [];