acp-kernel 0.0.46 → 0.0.47-pr.174.25
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 +21 -13
- package/dist/index.js.map +1 -1
- package/dist/parse-compress-input.d.ts +2 -0
- package/dist/parse-compress-input.d.ts.map +1 -1
- package/dist/persist/index.js +132 -45
- package/dist/persist/index.js.map +1 -1
- package/dist/persist/store.d.ts +46 -5
- package/dist/persist/store.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3153,9 +3153,9 @@ function parseObjectValue(value, callId, diag) {
|
|
|
3153
3153
|
const content = value["content"];
|
|
3154
3154
|
if (content === void 0) {
|
|
3155
3155
|
const single = validateEntry(value, callId);
|
|
3156
|
-
if (single) {
|
|
3156
|
+
if ("range" in single) {
|
|
3157
3157
|
diag.kind = "ok";
|
|
3158
|
-
return finish([single], diag);
|
|
3158
|
+
return finish([single.range], diag);
|
|
3159
3159
|
}
|
|
3160
3160
|
diag.kind = "missing-content";
|
|
3161
3161
|
return finish([], diag);
|
|
@@ -3176,7 +3176,7 @@ function parseObjectValue(value, callId, diag) {
|
|
|
3176
3176
|
diag.kind = "content-not-array";
|
|
3177
3177
|
return finish([], diag);
|
|
3178
3178
|
}
|
|
3179
|
-
const { ranges, invalid } = validateEntries(entries, callId);
|
|
3179
|
+
const { ranges, invalid, reasons } = validateEntries(entries, callId);
|
|
3180
3180
|
const topTopic = stringOr(value["topic"]);
|
|
3181
3181
|
const topMaxChars = value["summaryMaxChars"];
|
|
3182
3182
|
const hasTopMaxChars = typeof topMaxChars === "number" && Number.isFinite(topMaxChars);
|
|
@@ -3187,6 +3187,7 @@ function parseObjectValue(value, callId, diag) {
|
|
|
3187
3187
|
}
|
|
3188
3188
|
}
|
|
3189
3189
|
diag.invalidItems = invalid;
|
|
3190
|
+
if (reasons.length > 0) diag.invalidReasons = reasons;
|
|
3190
3191
|
diag.kind = salvaged ? "truncated" : ranges.length > 0 ? "ok" : "no-valid-ranges";
|
|
3191
3192
|
return finish(ranges, diag);
|
|
3192
3193
|
}
|
|
@@ -3210,36 +3211,43 @@ function finish(ranges, diag) {
|
|
|
3210
3211
|
return { ranges, diagnostics: diag };
|
|
3211
3212
|
}
|
|
3212
3213
|
function finishSalvage(entries, callId, diag, truncatedShape) {
|
|
3213
|
-
const { ranges, invalid } = validateEntries(entries, callId);
|
|
3214
|
+
const { ranges, invalid, reasons } = validateEntries(entries, callId);
|
|
3214
3215
|
diag.invalidItems = invalid;
|
|
3216
|
+
if (reasons.length > 0) diag.invalidReasons = reasons;
|
|
3215
3217
|
diag.kind = entries.length > 0 || truncatedShape ? "truncated" : "malformed-json";
|
|
3216
3218
|
return finish(ranges, diag);
|
|
3217
3219
|
}
|
|
3218
3220
|
function validateEntries(entries, callId) {
|
|
3219
3221
|
const ranges = [];
|
|
3222
|
+
const reasons = [];
|
|
3220
3223
|
let invalid = 0;
|
|
3221
|
-
for (
|
|
3222
|
-
const
|
|
3223
|
-
if (range
|
|
3224
|
-
else
|
|
3224
|
+
for (let i = 0; i < entries.length; i++) {
|
|
3225
|
+
const outcome = validateEntry(entries[i], callId);
|
|
3226
|
+
if ("range" in outcome) ranges.push(outcome.range);
|
|
3227
|
+
else {
|
|
3228
|
+
invalid++;
|
|
3229
|
+
reasons.push(`entry ${i}: ${outcome.reason}`);
|
|
3230
|
+
}
|
|
3225
3231
|
}
|
|
3226
|
-
return { ranges, invalid };
|
|
3232
|
+
return { ranges, invalid, reasons };
|
|
3227
3233
|
}
|
|
3228
3234
|
function validateEntry(entry, callId) {
|
|
3229
|
-
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return
|
|
3235
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { reason: "not an object" };
|
|
3230
3236
|
const e = entry;
|
|
3231
3237
|
const start = stringOr(e["startRef"]) ?? stringOr(e["startId"]) ?? stringOr(e["messageId"]);
|
|
3232
3238
|
const end = stringOr(e["endRef"]) ?? stringOr(e["endId"]) ?? stringOr(e["messageId"]);
|
|
3233
|
-
if (start === void 0 || end === void 0)
|
|
3239
|
+
if (start === void 0 || end === void 0) {
|
|
3240
|
+
return { reason: "missing range bounds (need startRef/startId and endRef/endId)" };
|
|
3241
|
+
}
|
|
3234
3242
|
const summary = stringOr(e["summary"]);
|
|
3235
|
-
if (summary === void 0) return
|
|
3243
|
+
if (summary === void 0) return { reason: "missing summary" };
|
|
3236
3244
|
const range = { startRef: start, endRef: end, summary };
|
|
3237
3245
|
const topic = stringOr(e["topic"]);
|
|
3238
3246
|
if (topic !== void 0) range.topic = topic;
|
|
3239
3247
|
const maxChars = e["summaryMaxChars"];
|
|
3240
3248
|
if (typeof maxChars === "number" && Number.isFinite(maxChars)) range.summaryMaxChars = maxChars;
|
|
3241
3249
|
if (callId !== void 0) range.compressCallId = callId;
|
|
3242
|
-
return range;
|
|
3250
|
+
return { range };
|
|
3243
3251
|
}
|
|
3244
3252
|
function stringOr(value) {
|
|
3245
3253
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|