@strav/brain 0.2.9 → 0.2.11
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": "@strav/brain",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI module for the Strav framework",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"CHANGELOG.md"
|
|
16
16
|
],
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@strav/kernel": "0.2.
|
|
18
|
+
"@strav/kernel": "0.2.9"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@strav/workflow": "0.2.
|
|
21
|
+
"@strav/workflow": "0.2.9",
|
|
22
22
|
"zod": "^3.25 || ^4.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
package/src/helpers.ts
CHANGED
|
@@ -160,7 +160,14 @@ export const brain = {
|
|
|
160
160
|
temperature: options.temperature ?? config.temperature,
|
|
161
161
|
})
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
// Extract JSON from potential markdown wrapper
|
|
164
|
+
let jsonContent = response.content.trim()
|
|
165
|
+
if (jsonContent.startsWith('```json') || jsonContent.startsWith('```')) {
|
|
166
|
+
// Strip markdown code fence wrapper
|
|
167
|
+
jsonContent = jsonContent.replace(/^```(?:json)?\n?/, '').replace(/\n?```\s*$/, '')
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const parsed = JSON.parse(jsonContent)
|
|
164
171
|
const data = options.schema?.parse ? options.schema.parse(parsed) : parsed
|
|
165
172
|
|
|
166
173
|
return {
|
|
@@ -340,7 +347,14 @@ export class AgentRunner<T extends Agent = Agent> {
|
|
|
340
347
|
let data: any = response.content
|
|
341
348
|
if (agent.output && response.content) {
|
|
342
349
|
try {
|
|
343
|
-
|
|
350
|
+
// Extract JSON from potential markdown wrapper
|
|
351
|
+
let jsonContent = response.content.trim()
|
|
352
|
+
if (jsonContent.startsWith('```json') || jsonContent.startsWith('```')) {
|
|
353
|
+
// Strip markdown code fence wrapper
|
|
354
|
+
jsonContent = jsonContent.replace(/^```(?:json)?\n?/, '').replace(/\n?```\s*$/, '')
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const parsed = JSON.parse(jsonContent)
|
|
344
358
|
data = agent.output.parse ? agent.output.parse(parsed) : parsed
|
|
345
359
|
} catch {
|
|
346
360
|
data = response.content
|
|
@@ -166,9 +166,14 @@ export class AnthropicProvider implements AIProvider {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
// Structured output
|
|
169
|
+
// Structured output (using GA API with output_config)
|
|
170
170
|
if (request.schema) {
|
|
171
|
-
body.
|
|
171
|
+
body.output_config = {
|
|
172
|
+
format: {
|
|
173
|
+
type: 'json_schema',
|
|
174
|
+
schema: request.schema
|
|
175
|
+
}
|
|
176
|
+
}
|
|
172
177
|
}
|
|
173
178
|
|
|
174
179
|
return body
|