@clawdbot/zalouser 2026.1.20 → 2026.1.21
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/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/zca.ts +26 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/zca.ts
CHANGED
|
@@ -114,11 +114,36 @@ export function runZcaInteractive(
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
function stripAnsi(str: string): string {
|
|
118
|
+
return str.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
|
|
119
|
+
}
|
|
120
|
+
|
|
117
121
|
export function parseJsonOutput<T>(stdout: string): T | null {
|
|
118
122
|
try {
|
|
119
123
|
return JSON.parse(stdout) as T;
|
|
120
124
|
} catch {
|
|
121
|
-
|
|
125
|
+
const cleaned = stripAnsi(stdout);
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
return JSON.parse(cleaned) as T;
|
|
129
|
+
} catch {
|
|
130
|
+
// zca may prefix output with INFO/log lines, try to find JSON
|
|
131
|
+
const lines = cleaned.split("\n");
|
|
132
|
+
|
|
133
|
+
for (let i = 0; i < lines.length; i++) {
|
|
134
|
+
const line = lines[i].trim();
|
|
135
|
+
if (line.startsWith("{") || line.startsWith("[")) {
|
|
136
|
+
// Try parsing from this line to the end
|
|
137
|
+
const jsonCandidate = lines.slice(i).join("\n").trim();
|
|
138
|
+
try {
|
|
139
|
+
return JSON.parse(jsonCandidate) as T;
|
|
140
|
+
} catch {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
122
147
|
}
|
|
123
148
|
}
|
|
124
149
|
|