@causyne/agent 1.20.8 → 1.20.10
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 +2 -1
- package/src/agentLoop.js +291 -103
- package/src/agentLoop.ts +322 -109
- package/src/browser/causyneBrowser.js +36 -0
- package/src/browser/causyneBrowser.ts +36 -1
- package/src/commands.js +25 -0
- package/src/compiledSkills.js +7330 -319
- package/src/computerUse/types.js +8 -0
- package/src/computerUse/types.ts +121 -0
- package/src/computerUse/visionGrounding.js +87 -29
- package/src/computerUse/visionGrounding.ts +108 -36
- package/src/contextManager.js +16 -0
- package/src/decisionPolicy.js +7 -9
- package/src/decisionPolicy.ts +7 -9
- package/src/documentEngine/antiSlopAuditor.js +13 -43
- package/src/documentEngine/antiSlopAuditor.ts +15 -47
- package/src/documentEngine/documentForge.js +3 -3
- package/src/documentEngine/documentForge.ts +3 -3
- package/src/launchIntent.js +3 -3
- package/src/launchIntent.ts +3 -3
- package/src/planCache.js +4 -14
- package/src/planCache.ts +4 -14
- package/src/providers/acp.js +4 -2
- package/src/providers/acp.ts +4 -2
- package/src/providers/antigravity.js +191 -28
- package/src/providers/antigravity.ts +192 -27
- package/src/providers/base.d.ts +2 -0
- package/src/providers/pi.js +3 -1
- package/src/providers/pi.ts +4 -2
- package/src/provisioning/capabilityProvisioner.js +2 -7
- package/src/provisioning/npmInstall.js +19 -0
- package/src/provisioning/npmInstall.ts +19 -0
- package/src/sandbox.js +7 -10
- package/src/smartToolsUse.js +223 -0
- package/src/smartToolsUse.ts +284 -0
- package/src/stallGuard.js +356 -0
- package/src/stallGuard.ts +432 -0
- package/src/taskShape.js +7 -7
- package/src/taskShape.ts +7 -7
- package/src/toolPacks.js +5 -5
- package/src/tools/blenderAutomator.js +198 -11
- package/src/tools/browserAutomator.js +3 -3
- package/src/tools/browserAutomator.ts +3 -3
- package/src/tools/documentForge.js +1 -1
- package/src/tools/documentForge.ts +1 -1
- package/src/tools/fsRead.js +91 -80
- package/src/tools/fsRead.ts +125 -0
- package/src/tools/peerAgent.js +1 -1
- package/src/tools/peerAgent.ts +1 -1
- package/src/tools/screenshot.js +5 -1
- package/src/tools/screenshot.ts +5 -1
- package/src/tools/toolScanner.js +19 -0
- package/src/tools/toolScanner.ts +17 -0
- package/src/tools/toolSelfRepair.js +63 -1
- package/src/tools/toolSelfRepair.ts +61 -1
- package/src/tools/visionInspector.js +80 -142
- package/src/tools/visionInspector.ts +110 -0
- package/src/tui/chatboxClipboard.js +152 -0
- package/src/tui/chatboxClipboard.ts +201 -0
- package/src/tui/clipboardSync.js +38 -7
- package/src/tui/clipboardSync.ts +39 -7
- package/src/tui/codeProgress.js +89 -18
- package/src/tui/codeProgress.ts +102 -17
- package/src/tui/codeStreamRenderer.js +7 -2
- package/src/tui/codeStreamRenderer.ts +7 -2
- package/src/tui/composerControls.js +9 -0
- package/src/tui/composerControls.ts +9 -0
- package/src/tui/dialogs.js +8 -3
- package/src/tui/diff.d.ts +1 -0
- package/src/tui/lineEditor.js +166 -14
- package/src/tui/mouseHover.js +6 -2
- package/src/tui/mouseHover.ts +7 -2
- package/src/tui/prompt.js +96 -19
- package/src/tui/stageSurface.js +3 -1
|
@@ -234,37 +234,166 @@ export const blenderAct = {
|
|
|
234
234
|
}
|
|
235
235
|
else if (action.type === 'autoFrameCamera') {
|
|
236
236
|
{
|
|
237
|
-
const camCode = `import bpy, math
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
326
|
-
|
|
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) {
|
|
@@ -5,7 +5,7 @@ const SUPPORTED_ACTION_TYPES = [
|
|
|
5
5
|
'listTabs', 'list_tabs',
|
|
6
6
|
'closeTab', 'close_tab',
|
|
7
7
|
'search',
|
|
8
|
-
'goto', 'open', 'navigate',
|
|
8
|
+
'goto', 'open', 'navigate', 'preview',
|
|
9
9
|
'snapshot', 'scrape',
|
|
10
10
|
'click', 'clickIndex',
|
|
11
11
|
'type', 'typeIndex', 'fill',
|
|
@@ -45,7 +45,7 @@ function normalizeActions(args) {
|
|
|
45
45
|
export const browserAct = {
|
|
46
46
|
schema: {
|
|
47
47
|
name: 'browser.act',
|
|
48
|
-
description: `Use the dedicated Causyne Browser for
|
|
48
|
+
description: `Use the dedicated Causyne Browser for search, public navigation, and preview of a workspace HTML file (type preview, filePath), accessible snapshots, interaction, extraction, and workspace-scoped screenshots. Use preview followed by snapshot and screenshot to check a local web page; a saved screenshot alone is not visual inspection by the model.`,
|
|
49
49
|
parameters: {
|
|
50
50
|
type: 'object',
|
|
51
51
|
properties: {
|
|
@@ -94,7 +94,7 @@ export const browserAct = {
|
|
|
94
94
|
{ type: 'string' },
|
|
95
95
|
{ type: 'array', items: { type: 'string' } }
|
|
96
96
|
],
|
|
97
|
-
description: 'Workspace-relative file path(s) for upload
|
|
97
|
+
description: 'Workspace-relative HTML path for preview, or file path(s) for upload.'
|
|
98
98
|
},
|
|
99
99
|
outputFile: { type: 'string', description: 'Download or screenshot destination inside the selected workspace.' },
|
|
100
100
|
fullPage: { type: 'boolean', description: 'Capture the complete page for a screenshot instead of the visible viewport.' }
|
|
@@ -17,7 +17,7 @@ const SUPPORTED_ACTION_TYPES: BrowserActionType[] = [
|
|
|
17
17
|
'listTabs', 'list_tabs',
|
|
18
18
|
'closeTab', 'close_tab',
|
|
19
19
|
'search',
|
|
20
|
-
'goto', 'open', 'navigate',
|
|
20
|
+
'goto', 'open', 'navigate', 'preview',
|
|
21
21
|
'snapshot', 'scrape',
|
|
22
22
|
'click', 'clickIndex',
|
|
23
23
|
'type', 'typeIndex', 'fill',
|
|
@@ -58,7 +58,7 @@ function normalizeActions(args: Record<string, unknown> | undefined): BrowserAct
|
|
|
58
58
|
export const browserAct = {
|
|
59
59
|
schema: {
|
|
60
60
|
name: 'browser.act',
|
|
61
|
-
description: `Use the dedicated Causyne Browser for
|
|
61
|
+
description: `Use the dedicated Causyne Browser for search, public navigation, and preview of a workspace HTML file (type preview, filePath), accessible snapshots, interaction, extraction, and workspace-scoped screenshots. Use preview followed by snapshot and screenshot to check a local web page; a saved screenshot alone is not visual inspection by the model.`,
|
|
62
62
|
parameters: {
|
|
63
63
|
type: 'object',
|
|
64
64
|
properties: {
|
|
@@ -107,7 +107,7 @@ export const browserAct = {
|
|
|
107
107
|
{ type: 'string' },
|
|
108
108
|
{ type: 'array', items: { type: 'string' } }
|
|
109
109
|
],
|
|
110
|
-
description: 'Workspace-relative file path(s) for upload
|
|
110
|
+
description: 'Workspace-relative HTML path for preview, or file path(s) for upload.'
|
|
111
111
|
},
|
|
112
112
|
outputFile: { type: 'string', description: 'Download or screenshot destination inside the selected workspace.' },
|
|
113
113
|
fullPage: { type: 'boolean', description: 'Capture the complete page for a screenshot instead of the visible viewport.' }
|
|
@@ -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 ("
|
|
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 ("
|
|
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: {
|
package/src/tools/fsRead.js
CHANGED
|
@@ -1,87 +1,98 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import readline from 'readline';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import os from 'os';
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import readline from 'node:readline';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
const BINARY_EXTENSIONS = /\.(png|jpe?g|webp|gif|svg|bmp|ico|blend\d?|glb|gltf|wasm|zip|tar|gz|bz2|xz|7z|rar|mp4|mov|avi|mkv|webm|mp3|wav|ogg|flac|aac|m4a|pdf|exe|dll|dylib|so|bin|iso|dmg)$/i;
|
|
6
|
+
/** Fast Binary Detection: inspect the first 1024 bytes for a null byte. */
|
|
7
7
|
async function isBinary(filePath) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
try {
|
|
9
|
+
const fd = await fs.promises.open(filePath, 'r');
|
|
10
|
+
const buffer = Buffer.alloc(1024);
|
|
11
|
+
const { bytesRead } = await fd.read(buffer, 0, 1024, 0);
|
|
12
|
+
await fd.close();
|
|
13
|
+
for (let i = 0; i < bytesRead; i++) {
|
|
14
|
+
if (buffer[i] === 0)
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
16
21
|
}
|
|
17
|
-
return false;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
22
|
}
|
|
22
|
-
|
|
23
23
|
export const fsRead = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
24
|
+
schema: {
|
|
25
|
+
name: 'fs.read',
|
|
26
|
+
description: 'Read file contents intelligently. Automatically pages large files to protect Context Window.',
|
|
27
|
+
parameters: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
path: { type: 'string' },
|
|
31
|
+
startLine: { type: 'number' },
|
|
32
|
+
endLine: { type: 'number' }
|
|
33
|
+
},
|
|
34
|
+
required: ['path']
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
async execute(args) {
|
|
38
|
+
try {
|
|
39
|
+
if (!args || typeof args.path !== 'string' || !args.path.trim()) {
|
|
40
|
+
return { success: false, error: 'Missing required parameter: path' };
|
|
41
|
+
}
|
|
42
|
+
const target = args.path.replace(/^~\//, os.homedir() + '/');
|
|
43
|
+
if (!fs.existsSync(target)) {
|
|
44
|
+
return { success: false, error: 'File does not exist.' };
|
|
45
|
+
}
|
|
46
|
+
const ext = path.extname(target).toLowerCase();
|
|
47
|
+
const isKnownBinaryExt = BINARY_EXTENSIONS.test(ext);
|
|
48
|
+
// Fast check for binary media/executables to prevent token context blowup
|
|
49
|
+
if (isKnownBinaryExt || (await isBinary(target))) {
|
|
50
|
+
let stat = null;
|
|
51
|
+
try {
|
|
52
|
+
stat = fs.statSync(target);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// ignore stat error
|
|
56
|
+
}
|
|
57
|
+
const sizeStr = stat ? `${(stat.size / 1024).toFixed(1)} KB` : 'unknown size';
|
|
58
|
+
const isImage = /\.(png|jpe?g|webp|gif|svg|bmp|ico)$/i.test(ext);
|
|
59
|
+
return {
|
|
60
|
+
success: false,
|
|
61
|
+
isBinary: true,
|
|
62
|
+
error: isImage
|
|
63
|
+
? `Cannot read image file '${path.basename(target)}' as plain text. Use view_image (or vision inspection). File metadata: ${sizeStr}, format: ${ext.replace('.', '').toUpperCase() || 'IMAGE'}.`
|
|
64
|
+
: `Cannot read binary file '${path.basename(target)}' as plain text. File size: ${sizeStr}.`
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const start = typeof args.startLine === 'number' && args.startLine > 0 ? Math.floor(args.startLine) : 1;
|
|
68
|
+
let end = typeof args.endLine === 'number' && args.endLine >= start ? Math.floor(args.endLine) : start + 799;
|
|
69
|
+
// Mandatory Paging Limit: at most 800 lines per read to preserve context
|
|
70
|
+
if (end - start + 1 > 800) {
|
|
71
|
+
end = start + 799;
|
|
72
|
+
}
|
|
73
|
+
let currentLine = 1;
|
|
74
|
+
const outputLines = [];
|
|
75
|
+
let totalLines = 0;
|
|
76
|
+
const rl = readline.createInterface({
|
|
77
|
+
input: fs.createReadStream(target),
|
|
78
|
+
crlfDelay: Infinity
|
|
79
|
+
});
|
|
80
|
+
for await (const line of rl) {
|
|
81
|
+
totalLines++;
|
|
82
|
+
if (currentLine >= start && currentLine <= end) {
|
|
83
|
+
outputLines.push(line);
|
|
84
|
+
}
|
|
85
|
+
currentLine++;
|
|
86
|
+
}
|
|
87
|
+
let finalOutput = outputLines.join('\n');
|
|
88
|
+
if (totalLines > end) {
|
|
89
|
+
finalOutput += `\n\n[WARNING: File truncated at line ${end} out of ${totalLines}. Use { startLine: ${end + 1}, endLine: ${end + 800} } to read more.]`;
|
|
90
|
+
}
|
|
91
|
+
return { success: true, output: finalOutput };
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
95
|
+
return { success: false, error: msg };
|
|
72
96
|
}
|
|
73
|
-
currentLine++;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let finalOutput = outputLines.join('\n');
|
|
77
|
-
|
|
78
|
-
if (totalLines > end) {
|
|
79
|
-
finalOutput += `\n\n[WARNING: File truncated at line ${end} out of ${totalLines}. Use { startLine: ${end + 1}, endLine: ${end + 800} } to read more.]`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return { success: true, output: finalOutput };
|
|
83
|
-
} catch (e) {
|
|
84
|
-
return { success: false, error: e.message };
|
|
85
97
|
}
|
|
86
|
-
}
|
|
87
98
|
};
|