@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springbrand/agent-runtime",
3
- "version": "0.2.0-alpha.17",
3
+ "version": "0.2.0-alpha.18",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src",
@@ -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
  }