@causyne/agent 1.20.7 → 1.20.9

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.
Files changed (42) hide show
  1. package/package.json +1 -1
  2. package/src/acp/agentCatalog.js +9 -3
  3. package/src/acp/agentCatalog.ts +20 -4
  4. package/src/agentLoop.js +167 -34
  5. package/src/agentLoop.ts +188 -37
  6. package/src/commands.js +25 -10
  7. package/src/compiledSkills.js +7330 -319
  8. package/src/computerUse/types.js +8 -0
  9. package/src/computerUse/types.ts +121 -0
  10. package/src/computerUse/visionGrounding.js +87 -29
  11. package/src/computerUse/visionGrounding.ts +108 -36
  12. package/src/decisionPolicy.js +7 -9
  13. package/src/decisionPolicy.ts +7 -9
  14. package/src/documentEngine/antiSlopAuditor.js +13 -43
  15. package/src/documentEngine/antiSlopAuditor.ts +15 -47
  16. package/src/documentEngine/documentForge.js +3 -3
  17. package/src/documentEngine/documentForge.ts +3 -3
  18. package/src/dynamicCatalogue.js +568 -77
  19. package/src/dynamicCatalogue.ts +608 -79
  20. package/src/launchIntent.js +3 -3
  21. package/src/launchIntent.ts +3 -3
  22. package/src/planCache.js +4 -14
  23. package/src/planCache.ts +4 -14
  24. package/src/providers/acp.js +39 -4
  25. package/src/providers/acp.ts +42 -4
  26. package/src/providers/antigravity.d.ts +7 -1
  27. package/src/providers/antigravity.js +222 -34
  28. package/src/providers/antigravity.ts +220 -33
  29. package/src/providers/base.d.ts +2 -0
  30. package/src/providers/pi.js +3 -1
  31. package/src/providers/pi.ts +4 -2
  32. package/src/sandbox.js +7 -10
  33. package/src/smartToolsUse.js +203 -0
  34. package/src/smartToolsUse.ts +263 -0
  35. package/src/taskShape.js +7 -7
  36. package/src/taskShape.ts +7 -7
  37. package/src/toolPacks.js +5 -5
  38. package/src/tools/blenderAutomator.js +198 -11
  39. package/src/tools/documentForge.js +1 -1
  40. package/src/tools/documentForge.ts +1 -1
  41. package/src/tui/modelPicker.js +288 -69
  42. package/src/tui/modelPicker.ts +333 -72
@@ -234,37 +234,166 @@ export const blenderAct = {
234
234
  }
235
235
  else if (action.type === 'autoFrameCamera') {
236
236
  {
237
- const camCode = `import bpy, math\ncam = bpy.context.scene.camera\nif not cam:\n cd = bpy.data.cameras.new('Cam')\n cam = bpy.data.objects.new('Cam', cd)\n bpy.context.scene.collection.objects.link(cam)\n bpy.context.scene.camera = cam\ncam.location = (10, -10, 8)\ncam.rotation_euler = (math.radians(50), 0, math.radians(45))\nif hasattr(cam.data, "lens"): cam.data.lens = ${action.focal_length || 65.0}\nprint('Headless 65mm camera framed at studio angle')`;
237
+ const camCode = `import bpy, math
238
+ cam = bpy.context.scene.camera
239
+ if not cam:
240
+ cd = bpy.data.cameras.new('Cam')
241
+ cam = bpy.data.objects.new('Cam', cd)
242
+ bpy.context.scene.collection.objects.link(cam)
243
+ bpy.context.scene.camera = cam
244
+ cam.location = (10, -10, 8)
245
+ cam.rotation_euler = (math.radians(50), 0, math.radians(45))
246
+ if hasattr(cam.data, "lens"):
247
+ cam.data.lens = ${action.focal_length || 65.0}
248
+ print('Headless 65mm camera framed at studio angle')`;
238
249
  await runHeadlessCli(null, camCode, results);
239
250
  }
240
251
  }
241
252
  else if (action.type === 'smartGeometry') {
242
253
  {
243
- const geomCode = `import bpy, math\ntargets = [bpy.data.objects.get(${JSON.stringify(action.name || "")})] if ${JSON.stringify(action.name || "")} else [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get() and not any(k in o.name.lower() for k in ['floor', 'plane', 'backdrop', 'studio', 'ground', 'cove'])]\ntargets = [t for t in targets if t]\nfor o in targets:\n if hasattr(o.data, "use_auto_smooth"): o.data.use_auto_smooth = True\n for p in o.data.polygons: p.use_smooth = True\n if not any(m.type == 'BEVEL' for m in o.modifiers):\n bev = o.modifiers.new(name="StudioBevel", type='BEVEL'); bev.width = ${action.bevel_width || 0.015}; bev.segments = 3; bev.limit_method = 'ANGLE'; bev.angle_limit = math.radians(35)\n if ${action.subsurf !== false} and not any(m.type == 'SUBSURF' for m in o.modifiers):\n sub = o.modifiers.new(name="StudioSubsurf", type='SUBSURF'); sub.levels = 2; sub.render_levels = 2\nprint("Headless applied Studio Bevel and Subsurf")`;
254
+ const geomCode = `import bpy, math
255
+ target_name = ${JSON.stringify(action.name || "")}
256
+ targets = [bpy.data.objects.get(target_name)] if target_name else [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get() and not any(k in o.name.lower() for k in ['floor', 'plane', 'backdrop', 'studio', 'ground', 'cove'])]
257
+ targets = [t for t in targets if t]
258
+ for o in targets:
259
+ if hasattr(o.data, "use_auto_smooth"):
260
+ o.data.use_auto_smooth = True
261
+ for p in o.data.polygons:
262
+ p.use_smooth = True
263
+ if not any(m.type == 'BEVEL' for m in o.modifiers):
264
+ bev = o.modifiers.new(name="StudioBevel", type='BEVEL')
265
+ bev.width = ${action.bevel_width || 0.015}
266
+ bev.segments = 3
267
+ bev.limit_method = 'ANGLE'
268
+ bev.angle_limit = math.radians(35)
269
+ if ${action.subsurf !== false} and not any(m.type == 'SUBSURF' for m in o.modifiers):
270
+ sub = o.modifiers.new(name="StudioSubsurf", type='SUBSURF')
271
+ sub.levels = 2
272
+ sub.render_levels = 2
273
+ print("Headless applied Studio Bevel and Subsurf")`;
244
274
  await runHeadlessCli(null, geomCode, results);
245
275
  }
246
276
  }
247
277
  else if (action.type === 'smartMaterial') {
248
278
  {
249
- const matCode = `import bpy, time\npreset = ${JSON.stringify(action.preset || "custom")}.lower()\ntargets = [bpy.data.objects.get(${JSON.stringify(action.name || "")})] if ${JSON.stringify(action.name || "")} else [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get() and not any(k in o.name.lower() for k in ['floor', 'plane', 'backdrop', 'studio', 'ground', 'cove'])]\ntargets = [t for t in targets if t]\nmat = bpy.data.materials.new(name=f"CausynePBR_{preset.capitalize()}_{int(time.time()*1000)%10000}"); mat.use_nodes = True; nodes = mat.node_tree.nodes; links = mat.node_tree.links; nodes.clear()\nbsdf = nodes.new(type="ShaderNodeBsdfPrincipled"); bsdf.location = (0, 0); out = nodes.new(type="ShaderNodeOutputMaterial"); out.location = (300, 0); links.new(bsdf.outputs["BSDF"], out.inputs["Surface"])\nif preset in ["gold", "gold_brushed", "aztec_gold"]:\n bsdf.inputs["Base Color"].default_value = (1.0, 0.766, 0.336, 1.0); bsdf.inputs["Metallic"].default_value = 1.0; bsdf.inputs["Roughness"].default_value = 0.18\nelif preset in ["sandstone", "ancient_stone", "pyramid_stone"]:\n bsdf.inputs["Base Color"].default_value = (0.68, 0.55, 0.40, 1.0); bsdf.inputs["Roughness"].default_value = 0.85\nelif preset in ["velvet", "cushion_velvet", "watch_cushion"]:\n bsdf.inputs["Base Color"].default_value = (0.05, 0.06, 0.08, 1.0); bsdf.inputs["Roughness"].default_value = 0.9\nelif preset in ["chrome", "steel", "watch_case"]:\n bsdf.inputs["Base Color"].default_value = (0.88, 0.89, 0.90, 1.0); bsdf.inputs["Metallic"].default_value = 1.0; bsdf.inputs["Roughness"].default_value = 0.08\nfor o in targets:\n if len(o.data.materials) == 0: o.data.materials.append(mat)\n else: o.data.materials[0] = mat\nprint(f"Headless applied Smart PBR Material ({preset})")`;
279
+ const matCode = `import bpy, time
280
+ preset = ${JSON.stringify(action.preset || "custom")}.lower()
281
+ target_name = ${JSON.stringify(action.name || "")}
282
+ targets = [bpy.data.objects.get(target_name)] if target_name else [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get() and not any(k in o.name.lower() for k in ['floor', 'plane', 'backdrop', 'studio', 'ground', 'cove'])]
283
+ targets = [t for t in targets if t]
284
+ mat = bpy.data.materials.new(name=f"CausynePBR_{preset.capitalize()}_{int(time.time()*1000)%10000}")
285
+ mat.use_nodes = True
286
+ nodes = mat.node_tree.nodes
287
+ links = mat.node_tree.links
288
+ nodes.clear()
289
+ bsdf = nodes.new(type="ShaderNodeBsdfPrincipled")
290
+ bsdf.location = (0, 0)
291
+ out = nodes.new(type="ShaderNodeOutputMaterial")
292
+ out.location = (300, 0)
293
+ links.new(bsdf.outputs["BSDF"], out.inputs["Surface"])
294
+ if preset in ["gold", "gold_brushed", "aztec_gold"]:
295
+ bsdf.inputs["Base Color"].default_value = (1.0, 0.766, 0.336, 1.0)
296
+ bsdf.inputs["Metallic"].default_value = 1.0
297
+ bsdf.inputs["Roughness"].default_value = 0.18
298
+ elif preset in ["sandstone", "ancient_stone", "pyramid_stone"]:
299
+ bsdf.inputs["Base Color"].default_value = (0.68, 0.55, 0.40, 1.0)
300
+ bsdf.inputs["Roughness"].default_value = 0.85
301
+ elif preset in ["velvet", "cushion_velvet", "watch_cushion"]:
302
+ bsdf.inputs["Base Color"].default_value = (0.05, 0.06, 0.08, 1.0)
303
+ bsdf.inputs["Roughness"].default_value = 0.9
304
+ elif preset in ["chrome", "steel", "watch_case"]:
305
+ bsdf.inputs["Base Color"].default_value = (0.88, 0.89, 0.90, 1.0)
306
+ bsdf.inputs["Metallic"].default_value = 1.0
307
+ bsdf.inputs["Roughness"].default_value = 0.08
308
+ for o in targets:
309
+ if len(o.data.materials) == 0:
310
+ o.data.materials.append(mat)
311
+ else:
312
+ o.data.materials[0] = mat
313
+ print(f"Headless applied Smart PBR Material ({preset})")`;
250
314
  await runHeadlessCli(null, matCode, results);
251
315
  }
252
316
  }
253
317
  else if (action.type === 'cinematicAtmosphere') {
254
318
  {
255
- const atmoCode = `import bpy, math\nw = bpy.context.scene.world or bpy.data.worlds.new("CausyneWorld"); bpy.context.scene.world = w; w.use_nodes = True; nodes = w.node_tree.nodes; links = w.node_tree.links; nodes.clear()\nbg = nodes.new("ShaderNodeBackground"); out = nodes.new("ShaderNodeOutputWorld"); sky = nodes.new("ShaderNodeTexSky"); sky.sky_type = 'MULTIPLE_SCATTERING' if hasattr(sky, 'sky_type') else 'HOSEK_WILKIE'; if hasattr(sky, 'sun_elevation'): sky.sun_elevation = math.radians(${action.sun_elevation || 12.0}); sky.sun_rotation = math.radians(-45.0); links.new(sky.outputs["Color"], bg.inputs["Color"]); links.new(bg.outputs["Background"], out.inputs["Surface"])\nif ${action.volumetric_fog !== false}:\n fm = bpy.data.materials.new("CausyneFog"); fm.use_nodes = True; fn = fm.node_tree.nodes; fl = fm.node_tree.links; fn.clear(); vol = fn.new("ShaderNodeVolumeScatter"); vol.inputs["Density"].default_value = ${action.fog_density || 0.015}; fo = fn.new("ShaderNodeOutputMaterial"); fl.new(vol.outputs["Volume"], fo.inputs["Volume"])\n bpy.ops.mesh.primitive_cube_add(size=40.0, location=(0,0,10)); fb = bpy.context.active_object; fb.name = "CausyneAtmosphereVolume"; fb.display_type = 'WIRE'; fb.data.materials.append(fm)\nprint("Headless applied Cinematic Atmosphere (Nishita Sky + Volumetric Fog)")`;
319
+ const atmoCode = `import bpy, math
320
+ w = bpy.context.scene.world or bpy.data.worlds.new("CausyneWorld")
321
+ bpy.context.scene.world = w
322
+ w.use_nodes = True
323
+ nodes = w.node_tree.nodes
324
+ links = w.node_tree.links
325
+ nodes.clear()
326
+ bg = nodes.new("ShaderNodeBackground")
327
+ out = nodes.new("ShaderNodeOutputWorld")
328
+ sky = nodes.new("ShaderNodeTexSky")
329
+ sky.sky_type = 'MULTIPLE_SCATTERING' if hasattr(sky, 'sky_type') else 'HOSEK_WILKIE'
330
+ if hasattr(sky, 'sun_elevation'):
331
+ sky.sun_elevation = math.radians(${action.sun_elevation || 12.0})
332
+ sky.sun_rotation = math.radians(-45.0)
333
+ links.new(sky.outputs["Color"], bg.inputs["Color"])
334
+ links.new(bg.outputs["Background"], out.inputs["Surface"])
335
+ if ${action.volumetric_fog !== false}:
336
+ fm = bpy.data.materials.new("CausyneFog")
337
+ fm.use_nodes = True
338
+ fn = fm.node_tree.nodes
339
+ fl = fm.node_tree.links
340
+ fn.clear()
341
+ vol = fn.new("ShaderNodeVolumeScatter")
342
+ vol.inputs["Density"].default_value = ${action.fog_density || 0.015}
343
+ fo = fn.new("ShaderNodeOutputMaterial")
344
+ fl.new(vol.outputs["Volume"], fo.inputs["Volume"])
345
+ bpy.ops.mesh.primitive_cube_add(size=40.0, location=(0,0,10))
346
+ fb = bpy.context.active_object
347
+ fb.name = "CausyneAtmosphereVolume"
348
+ fb.display_type = 'WIRE'
349
+ fb.data.materials.append(fm)
350
+ print("Headless applied Cinematic Atmosphere (Nishita Sky + Volumetric Fog)")`;
256
351
  await runHeadlessCli(null, atmoCode, results);
257
352
  }
258
353
  }
259
354
  else if (action.type === 'smartGeoNodes') {
260
355
  {
261
- const gnCode = `import bpy\ngen = ${JSON.stringify(action.generator || "masonry_brick_wall")}\ntargets = [o for o in bpy.context.scene.objects if o.type == 'MESH' and "Volume" not in o.name and "Floor" not in o.name]\nfor o in targets:\n mod = o.modifiers.new(name=f"GeoNode_{gen}", type='NODES')\n ng = bpy.data.node_groups.get(f"GN_{gen}")\n if not ng:\n ng = bpy.data.node_groups.new(f"GN_{gen}", 'GeometryNodeTree')\n ng.interface.new_socket("Geometry", in_out='INPUT', socket_type='NodeSocketGeometry')\n ng.interface.new_socket("Geometry", in_out='OUTPUT', socket_type='NodeSocketGeometry')\n gi = ng.nodes.new('NodeGroupInput'); gi.location = (-400,0); go = ng.nodes.new('NodeGroupOutput'); go.location = (400,0)\n if gen == "masonry_brick_wall":\n s = ng.nodes.new('GeometryNodeSubdivideMesh'); s.location = (-150,0); s.inputs["Level"].default_value = ${action.subdivisions || 3}\n ng.links.new(gi.outputs["Geometry"], s.inputs["Mesh"]); ng.links.new(s.outputs["Mesh"], go.inputs["Geometry"])\n else: ng.links.new(gi.outputs["Geometry"], go.inputs["Geometry"])\n mod.node_group = ng\nprint(f"Headless attached Geometry Nodes ({gen})")`;
356
+ const gnCode = `import bpy
357
+ gen = ${JSON.stringify(action.generator || "masonry_brick_wall")}
358
+ targets = [o for o in bpy.context.scene.objects if o.type == 'MESH' and "Volume" not in o.name and "Floor" not in o.name]
359
+ for o in targets:
360
+ mod = o.modifiers.new(name=f"GeoNode_{gen}", type='NODES')
361
+ ng = bpy.data.node_groups.get(f"GN_{gen}")
362
+ if not ng:
363
+ ng = bpy.data.node_groups.new(f"GN_{gen}", 'GeometryNodeTree')
364
+ ng.interface.new_socket("Geometry", in_out='INPUT', socket_type='NodeSocketGeometry')
365
+ ng.interface.new_socket("Geometry", in_out='OUTPUT', socket_type='NodeSocketGeometry')
366
+ gi = ng.nodes.new('NodeGroupInput')
367
+ gi.location = (-400,0)
368
+ go = ng.nodes.new('NodeGroupOutput')
369
+ go.location = (400,0)
370
+ if gen == "masonry_brick_wall":
371
+ s = ng.nodes.new('GeometryNodeSubdivideMesh')
372
+ s.location = (-150,0)
373
+ s.inputs["Level"].default_value = ${action.subdivisions || 3}
374
+ ng.links.new(gi.outputs["Geometry"], s.inputs["Mesh"])
375
+ ng.links.new(s.outputs["Mesh"], go.inputs["Geometry"])
376
+ else:
377
+ ng.links.new(gi.outputs["Geometry"], go.inputs["Geometry"])
378
+ mod.node_group = ng
379
+ print(f"Headless attached Geometry Nodes ({gen})")`;
262
380
  await runHeadlessCli(null, gnCode, results);
263
381
  }
264
382
  }
265
383
  else if (action.type === 'setupStudioLighting') {
266
384
  {
267
- const lightCode = `import bpy, math\nfor o in list(bpy.context.scene.objects):\n if o.type == 'LIGHT': bpy.data.objects.remove(o, do_unlink=True)\nkd = bpy.data.lights.new('Key', 'AREA'); kd.energy = ${action.key_energy || 800}; kd.size = 5.0; ko = bpy.data.objects.new('Key', kd); ko.location = (6, -6, 8); ko.rotation_euler = (math.radians(45), 0, math.radians(45)); bpy.context.scene.collection.objects.link(ko)\nprint('Headless studio lighting built')`;
385
+ const lightCode = `import bpy, math
386
+ for o in list(bpy.context.scene.objects):
387
+ if o.type == 'LIGHT':
388
+ bpy.data.objects.remove(o, do_unlink=True)
389
+ kd = bpy.data.lights.new('Key', 'AREA')
390
+ kd.energy = ${action.key_energy || 800}
391
+ kd.size = 5.0
392
+ ko = bpy.data.objects.new('Key', kd)
393
+ ko.location = (6, -6, 8)
394
+ ko.rotation_euler = (math.radians(45), 0, math.radians(45))
395
+ bpy.context.scene.collection.objects.link(ko)
396
+ print('Headless studio lighting built')`;
268
397
  await runHeadlessCli(null, lightCode, results);
269
398
  }
270
399
  }
@@ -274,14 +403,31 @@ export const blenderAct = {
274
403
  const fmts = action.formats || ['blend', 'glb'];
275
404
 
276
405
  {
277
- const exportCode = `import bpy, os\nd = "${destDir}"\nos.makedirs(d, exist_ok=True)\nif "blend" in ${JSON.stringify(fmts)}:\n bpy.ops.wm.save_as_mainfile(filepath=os.path.join(d, "${prefix}.blend"))\nif "glb" in ${JSON.stringify(fmts)}:\n bpy.ops.export_scene.gltf(filepath=os.path.join(d, "${prefix}.glb"), export_format="GLB")\nif "obj" in ${JSON.stringify(fmts)}:\n if hasattr(bpy.ops.wm, "obj_export"): bpy.ops.wm.obj_export(filepath=os.path.join(d, "${prefix}.obj"))\n else: bpy.ops.export_scene.obj(filepath=os.path.join(d, "${prefix}.obj"))\nprint(f"Headless exported formats to {d}")`;
406
+ const exportCode = `import bpy, os
407
+ d = "${destDir}"
408
+ os.makedirs(d, exist_ok=True)
409
+ if "blend" in ${JSON.stringify(fmts)}:
410
+ bpy.ops.wm.save_as_mainfile(filepath=os.path.join(d, "${prefix}.blend"))
411
+ if "glb" in ${JSON.stringify(fmts)}:
412
+ bpy.ops.export_scene.gltf(filepath=os.path.join(d, "${prefix}.glb"), export_format="GLB")
413
+ if "obj" in ${JSON.stringify(fmts)}:
414
+ if hasattr(bpy.ops.wm, "obj_export"):
415
+ bpy.ops.wm.obj_export(filepath=os.path.join(d, "${prefix}.obj"))
416
+ else:
417
+ bpy.ops.export_scene.obj(filepath=os.path.join(d, "${prefix}.obj"))
418
+ print(f"Headless exported formats to {d}")`;
278
419
  await runHeadlessCli(null, exportCode, results);
279
420
  }
280
421
  }
281
422
  else if (action.type === 'clearScene') {
282
423
  const keep = action.keep_lights_camera !== false;
283
424
  {
284
- const clearCode = `import bpy\nfor o in list(bpy.context.scene.objects):\n if ${keep} and o.type in ['CAMERA', 'LIGHT']: continue\n bpy.data.objects.remove(o, do_unlink=True)\nprint("Headless cleared scene meshes")`;
425
+ const clearCode = `import bpy
426
+ for o in list(bpy.context.scene.objects):
427
+ if ${keep} and o.type in ['CAMERA', 'LIGHT']:
428
+ continue
429
+ bpy.data.objects.remove(o, do_unlink=True)
430
+ print("Headless cleared scene meshes")`;
285
431
  await runHeadlessCli(null, clearCode, results);
286
432
  }
287
433
  }
@@ -306,7 +452,10 @@ export const blenderAct = {
306
452
  else if (action.type === 'captureViewport') {
307
453
  const targetPath = action.filepath || path.join(getWorkspaceTempDir(), `causyne_3d_preview_${Date.now()}.png`);
308
454
  {
309
- const captureCode = `import bpy, os\nos.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)\nbpy.ops.render.opengl(write_still=True, filepath="${targetPath}")\nprint("Captured headless viewport to ${targetPath}")`;
455
+ const captureCode = `import bpy, os
456
+ os.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)
457
+ bpy.ops.render.opengl(write_still=True, filepath="${targetPath}")
458
+ print("Captured headless viewport to ${targetPath}")`;
310
459
  try {
311
460
  await runHeadlessCli(null, captureCode, results);
312
461
  } catch (cliErr) {
@@ -322,8 +471,46 @@ export const blenderAct = {
322
471
 
323
472
  {
324
473
  const renderCode = isAnimation ?
325
- `import bpy, os, time\nos.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)\nbpy.context.scene.frame_start = ${startFrame}\nbpy.context.scene.frame_end = ${endFrame}\nif "${action.engine || ''}": bpy.context.scene.render.engine = "${action.engine || ''}"\ntry:\n bpy.context.scene.render.filepath = "${targetPath}"\n bpy.context.scene.render.image_settings.file_format = 'FFMPEG'\n if hasattr(bpy.context.scene.render, 'ffmpeg'):\n bpy.context.scene.render.ffmpeg.format = 'MPEG4' if "${targetPath}".lower().endswith('.mp4') else 'MKV'\n bpy.context.scene.render.ffmpeg.codec = 'H264'\n bpy.ops.render.render(animation=True)\n print(f"Rendered MP4 animation directly to ${targetPath}")\nexcept Exception:\n import subprocess, shutil as sh_util\n td = os.path.join(os.path.dirname("${targetPath}"), ".causyne_temp_frames_" + str(int(time.time())))\n os.makedirs(td, exist_ok=True)\n bpy.context.scene.render.image_settings.file_format = 'PNG'\n bpy.context.scene.render.filepath = os.path.join(td, "frame_")\n bpy.ops.render.render(animation=True)\n fps = getattr(bpy.context.scene.render, "fps", 30)\n fb = sh_util.which("ffmpeg")\n if not fb:\n for cand in ["/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg", "C:\\\\Program Files\\\\ffmpeg\\\\bin\\\\ffmpeg.exe"]:\n if os.path.exists(cand): fb = cand; break\n if not fb: fb = "ffmpeg"\n subprocess.run([fb, "-y", "-framerate", str(fps), "-i", os.path.join(td, "frame_%04d.png"), "-c:v", "libx264", "-pix_fmt", "yuv420p", "${targetPath}"], check=True)\n sh_util.rmtree(td, ignore_errors=True)\n print(f"Rendered MP4 animation via sequence to ${targetPath}")` :
326
- `import bpy, os\nos.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)\nbpy.context.scene.render.filepath = "${targetPath}"\nif "${action.engine || ''}": bpy.context.scene.render.engine = "${action.engine || ''}"\nbpy.ops.render.render(write_still=True)\nprint(f"Rendered still frame to ${targetPath}")`;
474
+ `import bpy, os, time
475
+ os.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)
476
+ bpy.context.scene.frame_start = ${startFrame}
477
+ bpy.context.scene.frame_end = ${endFrame}
478
+ if "${action.engine || ''}":
479
+ bpy.context.scene.render.engine = "${action.engine || ''}"
480
+ try:
481
+ bpy.context.scene.render.filepath = "${targetPath}"
482
+ bpy.context.scene.render.image_settings.file_format = 'FFMPEG'
483
+ if hasattr(bpy.context.scene.render, 'ffmpeg'):
484
+ bpy.context.scene.render.ffmpeg.format = 'MPEG4' if "${targetPath}".lower().endsWith('.mp4') else 'MKV'
485
+ bpy.context.scene.render.ffmpeg.codec = 'H264'
486
+ bpy.ops.render.render(animation=True)
487
+ print(f"Rendered MP4 animation directly to ${targetPath}")
488
+ except Exception:
489
+ import subprocess, shutil as sh_util
490
+ td = os.path.join(os.path.dirname("${targetPath}"), ".causyne_temp_frames_" + str(int(time.time())))
491
+ os.makedirs(td, exist_ok=True)
492
+ bpy.context.scene.render.image_settings.file_format = 'PNG'
493
+ bpy.context.scene.render.filepath = os.path.join(td, "frame_")
494
+ bpy.ops.render.render(animation=True)
495
+ fps = getattr(bpy.context.scene.render, "fps", 30)
496
+ fb = sh_util.which("ffmpeg")
497
+ if not fb:
498
+ for cand in ["/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg", "C:\\\\Program Files\\\\ffmpeg\\\\bin\\\\ffmpeg.exe"]:
499
+ if os.path.exists(cand):
500
+ fb = cand
501
+ break
502
+ if not fb:
503
+ fb = "ffmpeg"
504
+ subprocess.run([fb, "-y", "-framerate", str(fps), "-i", os.path.join(td, "frame_%04d.png"), "-c:v", "libx264", "-pix_fmt", "yuv420p", "${targetPath}"], check=True)
505
+ sh_util.rmtree(td, ignore_errors=True)
506
+ print(f"Rendered MP4 animation via sequence to ${targetPath}")` :
507
+ `import bpy, os
508
+ os.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)
509
+ bpy.context.scene.render.filepath = "${targetPath}"
510
+ if "${action.engine || ''}":
511
+ bpy.context.scene.render.engine = "${action.engine || ''}"
512
+ bpy.ops.render.render(write_still=True)
513
+ print(f"Rendered still frame to ${targetPath}")`;
327
514
  try {
328
515
  await runHeadlessCli(null, renderCode, results);
329
516
  } catch (cliErr) {
@@ -15,7 +15,7 @@ import { resolveUserPath } from '../utils/paths.js';
15
15
  export const documentForgeTool = {
16
16
  schema: {
17
17
  name: 'document_forge',
18
- description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Lihat Hasilnya"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
18
+ description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Inspect Results"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
19
19
  parameters: {
20
20
  type: 'object',
21
21
  properties: {
@@ -55,7 +55,7 @@ export interface DocumentForgeArgs {
55
55
  export const documentForgeTool = {
56
56
  schema: {
57
57
  name: 'document_forge',
58
- description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Lihat Hasilnya"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
58
+ description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Inspect Results"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
59
59
  parameters: {
60
60
  type: 'object',
61
61
  properties: {