@minded-ai/mindedjs 1.0.0-ec2-beta-160 → 1.0.0-ec2-beta-161

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.
@@ -276,46 +276,42 @@ async def main(session_id: str, cdp_url: str, task: str, output_schema_json: Opt
276
276
  )
277
277
 
278
278
  # Run agent with screenshot hook if configured
279
+ history = await agent.run(
280
+ on_step_end=on_step_end_hook
281
+ )
282
+ final_result = history.final_result()
283
+
284
+ # Parse result with output model if provided
285
+ parsed_result = None
286
+ if output_model and final_result:
287
+ try:
288
+ # Validate and parse the result using the Pydantic model
289
+ parsed_result = output_model.model_validate_json(final_result)
290
+ # Convert to dict for JSON serialization
291
+ parsed_result = parsed_result.model_dump()
292
+ except Exception as e:
293
+ print(f"Failed to parse result with output model: {e}")
294
+ # Fall back to raw result
295
+ parsed_result = final_result
296
+ else:
297
+ parsed_result = final_result
298
+
299
+ print("___RESULT___")
300
+ if parsed_result:
301
+ print(json.dumps(parsed_result, indent=2))
302
+ else:
303
+ print(final_result)
304
+
279
305
  try:
280
- history = await agent.run(
281
- on_step_end=on_step_end_hook
282
- )
283
- final_result = history.final_result()
284
-
285
- # Parse result with output model if provided
286
- parsed_result = None
287
- if output_model and final_result:
288
- try:
289
- # Validate and parse the result using the Pydantic model
290
- parsed_result = output_model.model_validate_json(final_result)
291
- # Convert to dict for JSON serialization
292
- parsed_result = parsed_result.model_dump()
293
- except Exception as e:
294
- print(f"Failed to parse result with output model: {e}")
295
- # Fall back to raw result
296
- parsed_result = final_result
297
- else:
298
- parsed_result = final_result
299
-
300
- print("___RESULT___")
301
- if parsed_result:
302
- print(json.dumps(parsed_result, indent=2))
306
+ logger.info(f"🍪 Saving cookies from browser session {session_id}")
307
+ current_cookies = await browser_session.get_cookies()
308
+ if current_cookies and len(current_cookies) > 0:
309
+ await cookie_store.save(current_cookies)
310
+ logger.info(f"✅ Successfully saved {len(current_cookies)} cookies from browser session")
303
311
  else:
304
- print(final_result)
305
-
306
- finally:
307
- # Save cookies from browser session before closing
308
- try:
309
- if browser_session.browser_context:
310
- logger.info(f"🍪 Saving cookies from browser session {session_id}")
311
- current_cookies = await browser_session.get_cookies()
312
- if current_cookies and len(current_cookies) > 0:
313
- await cookie_store.save(current_cookies)
314
- logger.info(f"✅ Successfully saved {len(current_cookies)} cookies from browser session")
315
- else:
316
- logger.info("No cookies to save from browser session")
317
- except Exception as e:
318
- logger.warning(f"Failed to save cookies from session {session_id}: {e}")
312
+ logger.info("No cookies to save from browser session")
313
+ except Exception as e:
314
+ logger.warning(f"Failed to save cookies from session {session_id}: {e}")
319
315
 
320
316
  if __name__ == '__main__':
321
317
  # Prefer JSON payload via stdin; fallback to argv for backwards compatibility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minded-ai/mindedjs",
3
- "version": "1.0.0-ec2-beta-160",
3
+ "version": "1.0.0-ec2-beta-161",
4
4
  "description": "MindedJS is a TypeScript library for building agents.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -276,46 +276,42 @@ async def main(session_id: str, cdp_url: str, task: str, output_schema_json: Opt
276
276
  )
277
277
 
278
278
  # Run agent with screenshot hook if configured
279
+ history = await agent.run(
280
+ on_step_end=on_step_end_hook
281
+ )
282
+ final_result = history.final_result()
283
+
284
+ # Parse result with output model if provided
285
+ parsed_result = None
286
+ if output_model and final_result:
287
+ try:
288
+ # Validate and parse the result using the Pydantic model
289
+ parsed_result = output_model.model_validate_json(final_result)
290
+ # Convert to dict for JSON serialization
291
+ parsed_result = parsed_result.model_dump()
292
+ except Exception as e:
293
+ print(f"Failed to parse result with output model: {e}")
294
+ # Fall back to raw result
295
+ parsed_result = final_result
296
+ else:
297
+ parsed_result = final_result
298
+
299
+ print("___RESULT___")
300
+ if parsed_result:
301
+ print(json.dumps(parsed_result, indent=2))
302
+ else:
303
+ print(final_result)
304
+
279
305
  try:
280
- history = await agent.run(
281
- on_step_end=on_step_end_hook
282
- )
283
- final_result = history.final_result()
284
-
285
- # Parse result with output model if provided
286
- parsed_result = None
287
- if output_model and final_result:
288
- try:
289
- # Validate and parse the result using the Pydantic model
290
- parsed_result = output_model.model_validate_json(final_result)
291
- # Convert to dict for JSON serialization
292
- parsed_result = parsed_result.model_dump()
293
- except Exception as e:
294
- print(f"Failed to parse result with output model: {e}")
295
- # Fall back to raw result
296
- parsed_result = final_result
297
- else:
298
- parsed_result = final_result
299
-
300
- print("___RESULT___")
301
- if parsed_result:
302
- print(json.dumps(parsed_result, indent=2))
306
+ logger.info(f"🍪 Saving cookies from browser session {session_id}")
307
+ current_cookies = await browser_session.get_cookies()
308
+ if current_cookies and len(current_cookies) > 0:
309
+ await cookie_store.save(current_cookies)
310
+ logger.info(f"✅ Successfully saved {len(current_cookies)} cookies from browser session")
303
311
  else:
304
- print(final_result)
305
-
306
- finally:
307
- # Save cookies from browser session before closing
308
- try:
309
- if browser_session.browser_context:
310
- logger.info(f"🍪 Saving cookies from browser session {session_id}")
311
- current_cookies = await browser_session.get_cookies()
312
- if current_cookies and len(current_cookies) > 0:
313
- await cookie_store.save(current_cookies)
314
- logger.info(f"✅ Successfully saved {len(current_cookies)} cookies from browser session")
315
- else:
316
- logger.info("No cookies to save from browser session")
317
- except Exception as e:
318
- logger.warning(f"Failed to save cookies from session {session_id}: {e}")
312
+ logger.info("No cookies to save from browser session")
313
+ except Exception as e:
314
+ logger.warning(f"Failed to save cookies from session {session_id}: {e}")
319
315
 
320
316
  if __name__ == '__main__':
321
317
  # Prefer JSON payload via stdin; fallback to argv for backwards compatibility