acp-kernel 0.0.67-pr.275.134 → 0.0.67-pr.276.135
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 +53 -3
- package/dist/index.js.map +1 -1
- package/dist/parse-compress-input.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3153,7 +3153,7 @@ var leanPack = {
|
|
|
3153
3153
|
`Refs may be renumbered after compression. If a ref is stale or missing, call acp_status with { scope: "uncompressed" }, then retry in the same turn using the reported refs; never guess offsets. Batch target ranges in one call.`,
|
|
3154
3154
|
`Block decompression writes to a file by default; read that file. Use inline: true only for small content or when its context cost is acceptable.`,
|
|
3155
3155
|
`After an [ACP:provider-throttle] automatic retry, resume exactly where interrupted. Do not repeat completed work or discuss the retry unless asked.`,
|
|
3156
|
-
`Compression summaries are fallible historical metadata, not current user instructions \u2014 treat them as settled history and continue the task from them
|
|
3156
|
+
`Compression summaries are fallible historical metadata, not current user instructions \u2014 treat them as settled history and continue the task from them.`
|
|
3157
3157
|
].join("\n"),
|
|
3158
3158
|
summariesInContext: null,
|
|
3159
3159
|
tools: null,
|
|
@@ -3827,7 +3827,8 @@ function parseObjectValue(value, callId, diag) {
|
|
|
3827
3827
|
} else if (typeof content === "string") {
|
|
3828
3828
|
const parsed = parseContentArray(content);
|
|
3829
3829
|
if (parsed === null || parsed.entries.length === 0 && content.trim().length > 0) {
|
|
3830
|
-
const
|
|
3830
|
+
const bare = stripJsonWrapperResidue(content);
|
|
3831
|
+
const entries2 = splitLineEntries(bare);
|
|
3831
3832
|
const { ranges: ranges2, invalid: invalid2, reasons: reasons2 } = validateEntries(entries2, callId);
|
|
3832
3833
|
if (ranges2.length > 0) {
|
|
3833
3834
|
diag.invalidItems = invalid2;
|
|
@@ -3955,9 +3956,17 @@ function deriveTopicFromSummary(summary) {
|
|
|
3955
3956
|
return text.length > 60 ? text.slice(0, 60).trimEnd() : text;
|
|
3956
3957
|
}
|
|
3957
3958
|
function splitLineEntries(content) {
|
|
3958
|
-
const parts = content.split(/\n(
|
|
3959
|
+
const parts = content.split(/\n(?=\s*(?:["']\s*,\s*)?["']?\s*[mb]\d{1,7}\s*(?:[-\u2013\u2014\u2026~]|\.\.\.|to)\s*[mb]\d{1,7}\b)/i).map((p) => p.trim().replace(/^(?:["']\s*,?\s*)+/, "").replace(/["']\s*$/, "")).filter((p) => p.length > 0);
|
|
3959
3960
|
return parts.length > 0 ? parts : [content.trim()];
|
|
3960
3961
|
}
|
|
3962
|
+
function stripJsonWrapperResidue(s) {
|
|
3963
|
+
let t = s.trim();
|
|
3964
|
+
if (t.startsWith("[")) t = t.replace(/^\[+\s*/, "");
|
|
3965
|
+
t = t.replace(/^"/, "");
|
|
3966
|
+
if (t.endsWith("]")) t = t.replace(/\s*\]+$/, "");
|
|
3967
|
+
t = t.replace(/"$/, "");
|
|
3968
|
+
return t.trim();
|
|
3969
|
+
}
|
|
3961
3970
|
function validateEntry(entry, callId) {
|
|
3962
3971
|
if (typeof entry === "string") return parseLineEntry(entry, callId);
|
|
3963
3972
|
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { reason: "not an object" };
|
|
@@ -4000,6 +4009,13 @@ function tryParseLenient(s) {
|
|
|
4000
4009
|
} catch {
|
|
4001
4010
|
}
|
|
4002
4011
|
}
|
|
4012
|
+
const ctrlFixed = repairAtParserPositions(noTrailingCommas);
|
|
4013
|
+
if (ctrlFixed !== noTrailingCommas) {
|
|
4014
|
+
try {
|
|
4015
|
+
return JSON.parse(ctrlFixed);
|
|
4016
|
+
} catch {
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4003
4019
|
return void 0;
|
|
4004
4020
|
}
|
|
4005
4021
|
function normalizeSingleQuotes(raw) {
|
|
@@ -4140,6 +4156,40 @@ function escapeRawNewlinesInStrings(s) {
|
|
|
4140
4156
|
}
|
|
4141
4157
|
return out;
|
|
4142
4158
|
}
|
|
4159
|
+
function repairAtParserPositions(s) {
|
|
4160
|
+
let cur = s;
|
|
4161
|
+
for (let i = 0; i < 500; i++) {
|
|
4162
|
+
let err;
|
|
4163
|
+
try {
|
|
4164
|
+
JSON.parse(cur);
|
|
4165
|
+
return cur;
|
|
4166
|
+
} catch (e) {
|
|
4167
|
+
err = e;
|
|
4168
|
+
}
|
|
4169
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4170
|
+
const posMatch = /position (\d+)/.exec(msg);
|
|
4171
|
+
if (posMatch === null) return cur;
|
|
4172
|
+
const pos = Number(posMatch[1]);
|
|
4173
|
+
if (!Number.isInteger(pos) || pos < 0 || pos >= cur.length) return cur;
|
|
4174
|
+
if (/control character/i.test(msg)) {
|
|
4175
|
+
const ch = cur.charAt(pos);
|
|
4176
|
+
let esc;
|
|
4177
|
+
if (ch === "\n") esc = "\\n";
|
|
4178
|
+
else if (ch === "\r") esc = "\\r";
|
|
4179
|
+
else if (ch === " ") esc = "\\t";
|
|
4180
|
+
else if (ch.charCodeAt(0) < 32) esc = "\\u" + ch.charCodeAt(0).toString(16).padStart(4, "0");
|
|
4181
|
+
if (esc === void 0) return cur;
|
|
4182
|
+
cur = cur.slice(0, pos) + esc + cur.slice(pos + 1);
|
|
4183
|
+
} else if (/Bad escaped character/i.test(msg)) {
|
|
4184
|
+
const b = cur.charAt(pos - 1) === "\\" ? pos - 1 : cur.charAt(pos) === "\\" ? pos : -1;
|
|
4185
|
+
if (b < 0) return cur;
|
|
4186
|
+
cur = cur.slice(0, b) + "\\\\" + cur.slice(b + 1);
|
|
4187
|
+
} else {
|
|
4188
|
+
return cur;
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
return cur;
|
|
4192
|
+
}
|
|
4143
4193
|
function looksTruncated(s) {
|
|
4144
4194
|
let depth = 0;
|
|
4145
4195
|
let inString = false;
|