mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-08 21:25:00 +09:00
#3788: Claude's confirm gate re-derived the action class from English words and ignored each Dev Tools entry's declared cost, so the network entry dt-prov-test read as a plain write and could auto-run at write + auto. The entry's cost now travels with the ask (`declared`) and the gate takes the stricter of the two classes. Live drive: at level write the entry is now refused as a network action (needs manage); before, it was not asked about. #3789: jsonAfter sliced to the LAST } or ] in the output, so a trailing log line holding one dropped valid JSON. It now finds the bracket that closes the first one, skipping strings. Co-Authored-By: RuFlo <ruv@ruv.net>
23 lines
650 B
TypeScript
23 lines
650 B
TypeScript
/** The index of the bracket that closes the one at `start`, skipping strings; -1 when it never closes. A trailing log line with a stray `}` or `]` is not part of the JSON. */
|
|
export function closeOf(text: string, start: number): number {
|
|
let depth = 0
|
|
let inString = false
|
|
|
|
for (let i = start; i < text.length; i++) {
|
|
const ch = text[i]
|
|
|
|
if (inString) {
|
|
if (ch === '\\') i++
|
|
else if (ch === '"') inString = false
|
|
} else if (ch === '"') {
|
|
inString = true
|
|
} else if (ch === '{' || ch === '[') {
|
|
depth++
|
|
} else if ((ch === '}' || ch === ']') && --depth === 0) {
|
|
return i
|
|
}
|
|
}
|
|
|
|
return -1
|
|
}
|