baro-ai 0.81.2 → 0.81.3
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/run-architect.mjs +42 -10
- package/dist/run-architect.mjs.map +1 -1
- package/package.json +1 -1
package/dist/run-architect.mjs
CHANGED
|
@@ -48055,6 +48055,9 @@ async function compileBatch(input) {
|
|
|
48055
48055
|
});
|
|
48056
48056
|
return drafts;
|
|
48057
48057
|
} catch (error) {
|
|
48058
|
+
if (isOutputLimitError(error, input.options.isOutputLimitError) && input.targets.length >= 2) {
|
|
48059
|
+
return await bisectOutputLimitedBatch(input, error);
|
|
48060
|
+
}
|
|
48058
48061
|
if (attempt === 2) {
|
|
48059
48062
|
throw new ArchitectObligationSegmentError(
|
|
48060
48063
|
`architect obligation batch ${input.batchId} remained invalid after one repair: ${safeReason(error)}`,
|
|
@@ -48163,11 +48166,18 @@ function parseSegmentResponse(raw, targets, decisionIds, maxObligations) {
|
|
|
48163
48166
|
);
|
|
48164
48167
|
}
|
|
48165
48168
|
let value;
|
|
48169
|
+
const candidate = extractModelJsonObject(raw);
|
|
48166
48170
|
try {
|
|
48167
|
-
value = JSON.parse(
|
|
48171
|
+
value = JSON.parse(candidate);
|
|
48168
48172
|
} catch {
|
|
48173
|
+
const tail = raw.replace(/\s+/gu, " ").trim().slice(-160);
|
|
48174
|
+
if (jsonAppearsTruncated(candidate)) {
|
|
48175
|
+
throw new ArchitectObligationOutputLimitError(
|
|
48176
|
+
`architect obligation segment JSON is cut off mid-stream \u2014 emit fewer, more concise obligations (response ends: "\u2026${tail}")`
|
|
48177
|
+
);
|
|
48178
|
+
}
|
|
48169
48179
|
throw new ArchitectObligationSegmentError(
|
|
48170
|
-
|
|
48180
|
+
`architect obligation segment is not valid JSON (response ends: "\u2026${tail}")`
|
|
48171
48181
|
);
|
|
48172
48182
|
}
|
|
48173
48183
|
if (!exactRecord3(value, ["schemaVersion", "obligations"])) {
|
|
@@ -48195,24 +48205,24 @@ function parseSegmentResponse(raw, targets, decisionIds, maxObligations) {
|
|
|
48195
48205
|
"expectedOutcome",
|
|
48196
48206
|
"evidence"
|
|
48197
48207
|
];
|
|
48198
|
-
const numbered = value.obligations.map((
|
|
48199
|
-
if (!exactRecord3(
|
|
48208
|
+
const numbered = value.obligations.map((candidate2, index) => {
|
|
48209
|
+
if (!exactRecord3(candidate2, DRAFT_KEYS) && !exactRecord3(candidate2, [...DRAFT_KEYS, "id"])) {
|
|
48200
48210
|
throw new ArchitectObligationSegmentError(
|
|
48201
48211
|
`architect obligation draft ${index + 1} must use the exact shape without an id`
|
|
48202
48212
|
);
|
|
48203
48213
|
}
|
|
48204
48214
|
draftDecisionIds.push(validateDraftDecisionIds(
|
|
48205
|
-
|
|
48215
|
+
candidate2.adrIds,
|
|
48206
48216
|
decisionRank,
|
|
48207
48217
|
index + 1
|
|
48208
48218
|
));
|
|
48209
48219
|
return {
|
|
48210
48220
|
id: `O-${String(index + 1).padStart(3, "0")}`,
|
|
48211
|
-
invariantIds:
|
|
48212
|
-
subject:
|
|
48213
|
-
scenario:
|
|
48214
|
-
expectedOutcome:
|
|
48215
|
-
evidence:
|
|
48221
|
+
invariantIds: candidate2.invariantIds,
|
|
48222
|
+
subject: candidate2.subject,
|
|
48223
|
+
scenario: candidate2.scenario,
|
|
48224
|
+
expectedOutcome: candidate2.expectedOutcome,
|
|
48225
|
+
evidence: candidate2.evidence
|
|
48216
48226
|
};
|
|
48217
48227
|
});
|
|
48218
48228
|
let validated;
|
|
@@ -48376,6 +48386,28 @@ function throwIfAborted(signal) {
|
|
|
48376
48386
|
error.name = "AbortError";
|
|
48377
48387
|
throw error;
|
|
48378
48388
|
}
|
|
48389
|
+
function jsonAppearsTruncated(candidate) {
|
|
48390
|
+
const text = candidate.trimStart();
|
|
48391
|
+
if (!text.startsWith("{")) return false;
|
|
48392
|
+
let depth = 0;
|
|
48393
|
+
let inString = false;
|
|
48394
|
+
let escaped = false;
|
|
48395
|
+
for (const char of text) {
|
|
48396
|
+
if (escaped) {
|
|
48397
|
+
escaped = false;
|
|
48398
|
+
} else if (char === "\\") {
|
|
48399
|
+
escaped = inString;
|
|
48400
|
+
} else if (char === '"') {
|
|
48401
|
+
inString = !inString;
|
|
48402
|
+
} else if (!inString && char === "{") {
|
|
48403
|
+
depth += 1;
|
|
48404
|
+
} else if (!inString && char === "}") {
|
|
48405
|
+
depth -= 1;
|
|
48406
|
+
if (depth === 0) return false;
|
|
48407
|
+
}
|
|
48408
|
+
}
|
|
48409
|
+
return true;
|
|
48410
|
+
}
|
|
48379
48411
|
function safeReason(error) {
|
|
48380
48412
|
const raw = error instanceof Error ? error.message : String(error);
|
|
48381
48413
|
return raw.replace(/[\u0000-\u001f\u007f]/gu, " ").replace(/\s+/gu, " ").trim().slice(0, 1e3) || "invalid response";
|