@springbrand/agent-runtime 0.2.0-alpha.17 → 0.2.0-alpha.18
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/package.json
CHANGED
|
@@ -41,6 +41,10 @@ function textOf(message: AssistantMessage): string {
|
|
|
41
41
|
.trim();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
function structuredText(text: string): string {
|
|
45
|
+
return /^```(?:json)?\s*\n([\s\S]*?)\n```$/i.exec(text)?.[1] ?? text;
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
function toolErrorText(result: unknown): string {
|
|
45
49
|
if (
|
|
46
50
|
typeof result === "object" &&
|
|
@@ -161,7 +165,7 @@ export async function runCloudflareSubAgent(
|
|
|
161
165
|
|
|
162
166
|
let output: unknown;
|
|
163
167
|
try {
|
|
164
|
-
output = JSON.parse(text);
|
|
168
|
+
output = JSON.parse(structuredText(text));
|
|
165
169
|
} catch {
|
|
166
170
|
throw new Error("SubAgent output is not valid JSON");
|
|
167
171
|
}
|