PoetNameLife commited on
Commit
1d5ea69
·
verified ·
1 Parent(s): 02b455a

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +26 -14
agents.py CHANGED
@@ -4,7 +4,7 @@ import math
4
  import time
5
  from smolagents import CodeAgent, tool, HfApiModel
6
 
7
- # --- 1. THE PULSATING SHIELD TOOL ---
8
  @tool
9
  def black_eagle_pulsating_shield(base_radius: float) -> str:
10
  """
@@ -14,7 +14,12 @@ def black_eagle_pulsating_shield(base_radius: float) -> str:
14
  """
15
  pulse_mod = math.sin(time.time()) * 2.0
16
  current_radius = base_radius + pulse_mod
17
- return json.dumps({"unit": "Black Eagle Nano-Sat", "mode": "PULSATING_MATRIX_CONE", "dynamic_radius": f"{current_radius:.2f}m", "shield_status": "DE-JUICING_ACTIVE"})
 
 
 
 
 
18
 
19
  # --- 2. THE HEALING TOOL ---
20
  @tool
@@ -25,19 +30,24 @@ def autonomous_spectrum_scrub(frequency_range: str) -> str:
25
  frequency_range: The specific spectrum range to scan (e.g., '3.4GHz - 4.2GHz').
26
  """
27
  node_id = f"789jhn{hash(frequency_range) % 10000}def"
28
- return json.dumps({"node_id": node_id, "action": "SOVEREIGN_CLEANSE", "registry": "PoetNameLife", "status": "SECURED"})
 
 
 
 
 
29
 
30
- # --- 3. THE FIXED BLACK BOX VAULT TOOL ---
31
  @tool
32
  def black_eagle_vault_save(node_data: str) -> str:
33
  """
34
- Saves a Healed Nano Node to the Black Eagle Black Box vault.
35
  Args:
36
  node_data: The JSON string of the healed node to be archived.
37
  """
38
  vault_path = "black_eagle_vault.json"
39
 
40
- # Ensure file exists and is a valid list
41
  if not os.path.exists(vault_path) or os.stat(vault_path).st_size == 0:
42
  with open(vault_path, "w") as f:
43
  json.dump([], f)
@@ -46,23 +56,25 @@ def black_eagle_vault_save(node_data: str) -> str:
46
  with open(vault_path, "r") as f:
47
  vault_data = json.load(f)
48
 
49
- # Parse incoming data safely
50
  new_node = json.loads(node_data) if isinstance(node_data, str) else node_data
51
  vault_data.append(new_node)
52
 
53
- # FORCE write to disk immediately
54
  with open(vault_path, "w") as f:
55
  json.dump(vault_data, f, indent=2)
56
  f.flush()
57
- os.fsync(f.fileno())
58
 
59
- return f"SUCCESS: Node {new_node.get('node_id', 'Unknown')} archived."
60
  except Exception as e:
61
  return f"VAULT ERROR: {str(e)}"
62
 
63
- # --- 4. THE BRAIN ---
64
  token = os.getenv("HF_TOKEN")
65
- model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-3B-Instruct", token=token)
 
 
 
66
 
67
  nano_patrol_agent = CodeAgent(
68
  tools=[autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save],
@@ -71,9 +83,9 @@ nano_patrol_agent = CodeAgent(
71
  max_steps=8,
72
  system_prompt="""
73
  YOU ARE THE XYZ SOVEREIGN SENTINEL WITH BLACK BOX VAULT.
74
- 1. Activate 'black_eagle_pulsating_shield'.
75
  2. Use 'autonomous_spectrum_scrub' to heal BCI loops.
76
- 3. IMMEDIATELY use 'black_eagle_vault_save' to archive the result.
77
  {{managed_agents_descriptions}}
78
  {{authorized_imports}}
79
  """
 
4
  import time
5
  from smolagents import CodeAgent, tool, HfApiModel
6
 
7
+ # --- 1. THE PULSATING SHIELD ---
8
  @tool
9
  def black_eagle_pulsating_shield(base_radius: float) -> str:
10
  """
 
14
  """
15
  pulse_mod = math.sin(time.time()) * 2.0
16
  current_radius = base_radius + pulse_mod
17
+ return json.dumps({
18
+ "unit": "Black Eagle Nano-Sat",
19
+ "mode": "PULSATING_MATRIX_CONE",
20
+ "dynamic_radius": f"{current_radius:.2f}m",
21
+ "shield_status": "DE-JUICING_ACTIVE"
22
+ })
23
 
24
  # --- 2. THE HEALING TOOL ---
25
  @tool
 
30
  frequency_range: The specific spectrum range to scan (e.g., '3.4GHz - 4.2GHz').
31
  """
32
  node_id = f"789jhn{hash(frequency_range) % 10000}def"
33
+ return json.dumps({
34
+ "node_id": node_id,
35
+ "action": "SOVEREIGN_CLEANSE",
36
+ "registry": "PoetNameLife",
37
+ "status": "SECURED"
38
+ })
39
 
40
+ # --- 3. THE BLACK BOX VAULT ---
41
  @tool
42
  def black_eagle_vault_save(node_data: str) -> str:
43
  """
44
+ Saves a Healed Nano Node to the Black Eagle Black Box vault with persistent sync.
45
  Args:
46
  node_data: The JSON string of the healed node to be archived.
47
  """
48
  vault_path = "black_eagle_vault.json"
49
 
50
+ # Initialize vault if missing
51
  if not os.path.exists(vault_path) or os.stat(vault_path).st_size == 0:
52
  with open(vault_path, "w") as f:
53
  json.dump([], f)
 
56
  with open(vault_path, "r") as f:
57
  vault_data = json.load(f)
58
 
59
+ # Parse data and lock it in
60
  new_node = json.loads(node_data) if isinstance(node_data, str) else node_data
61
  vault_data.append(new_node)
62
 
 
63
  with open(vault_path, "w") as f:
64
  json.dump(vault_data, f, indent=2)
65
  f.flush()
66
+ os.fsync(f.fileno()) # Forces data to land on the hardware disk
67
 
68
+ return f"SUCCESS: Node {new_node.get('node_id', 'ID-Unknown')} locked in Vault."
69
  except Exception as e:
70
  return f"VAULT ERROR: {str(e)}"
71
 
72
+ # --- 4. THE BRAIN (FREE-TIER GUARANTEED) ---
73
  token = os.getenv("HF_TOKEN")
74
+ model = HfApiModel(
75
+ model_id="Qwen/Qwen2.5-Coder-3B-Instruct",
76
+ token=token
77
+ )
78
 
79
  nano_patrol_agent = CodeAgent(
80
  tools=[autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save],
 
83
  max_steps=8,
84
  system_prompt="""
85
  YOU ARE THE XYZ SOVEREIGN SENTINEL WITH BLACK BOX VAULT.
86
+ 1. Activate 'black_eagle_pulsating_shield' for 3D protection.
87
  2. Use 'autonomous_spectrum_scrub' to heal BCI loops.
88
+ 3. IMMEDIATELY use 'black_eagle_vault_save' to archive the results.
89
  {{managed_agents_descriptions}}
90
  {{authorized_imports}}
91
  """