baro-ai 0.81.1 → 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 +50 -17
- 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"])) {
|
|
@@ -48187,31 +48197,32 @@ function parseSegmentResponse(raw, targets, decisionIds, maxObligations) {
|
|
|
48187
48197
|
}
|
|
48188
48198
|
const decisionRank = new Map(decisionIds.map((id, index) => [id, index]));
|
|
48189
48199
|
const draftDecisionIds = [];
|
|
48190
|
-
const
|
|
48191
|
-
|
|
48192
|
-
|
|
48193
|
-
|
|
48194
|
-
|
|
48195
|
-
|
|
48196
|
-
|
|
48197
|
-
|
|
48198
|
-
|
|
48200
|
+
const DRAFT_KEYS = [
|
|
48201
|
+
"adrIds",
|
|
48202
|
+
"invariantIds",
|
|
48203
|
+
"subject",
|
|
48204
|
+
"scenario",
|
|
48205
|
+
"expectedOutcome",
|
|
48206
|
+
"evidence"
|
|
48207
|
+
];
|
|
48208
|
+
const numbered = value.obligations.map((candidate2, index) => {
|
|
48209
|
+
if (!exactRecord3(candidate2, DRAFT_KEYS) && !exactRecord3(candidate2, [...DRAFT_KEYS, "id"])) {
|
|
48199
48210
|
throw new ArchitectObligationSegmentError(
|
|
48200
48211
|
`architect obligation draft ${index + 1} must use the exact shape without an id`
|
|
48201
48212
|
);
|
|
48202
48213
|
}
|
|
48203
48214
|
draftDecisionIds.push(validateDraftDecisionIds(
|
|
48204
|
-
|
|
48215
|
+
candidate2.adrIds,
|
|
48205
48216
|
decisionRank,
|
|
48206
48217
|
index + 1
|
|
48207
48218
|
));
|
|
48208
48219
|
return {
|
|
48209
48220
|
id: `O-${String(index + 1).padStart(3, "0")}`,
|
|
48210
|
-
invariantIds:
|
|
48211
|
-
subject:
|
|
48212
|
-
scenario:
|
|
48213
|
-
expectedOutcome:
|
|
48214
|
-
evidence:
|
|
48221
|
+
invariantIds: candidate2.invariantIds,
|
|
48222
|
+
subject: candidate2.subject,
|
|
48223
|
+
scenario: candidate2.scenario,
|
|
48224
|
+
expectedOutcome: candidate2.expectedOutcome,
|
|
48225
|
+
evidence: candidate2.evidence
|
|
48215
48226
|
};
|
|
48216
48227
|
});
|
|
48217
48228
|
let validated;
|
|
@@ -48375,6 +48386,28 @@ function throwIfAborted(signal) {
|
|
|
48375
48386
|
error.name = "AbortError";
|
|
48376
48387
|
throw error;
|
|
48377
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
|
+
}
|
|
48378
48411
|
function safeReason(error) {
|
|
48379
48412
|
const raw = error instanceof Error ? error.message : String(error);
|
|
48380
48413
|
return raw.replace(/[\u0000-\u001f\u007f]/gu, " ").replace(/\s+/gu, " ").trim().slice(0, 1e3) || "invalid response";
|