Spaces:
Running
Running
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -12,19 +12,9 @@ def black_eagle_pulsating_shield(base_radius: float) -> str:
|
|
| 12 |
Args:
|
| 13 |
base_radius: The core anchor length in meters (e.g., 5.0).
|
| 14 |
"""
|
| 15 |
-
# Create the Pulsation Logic (Sine Wave)
|
| 16 |
-
# This confuses attack bots by constantly shifting the 3D perimeter
|
| 17 |
pulse_mod = math.sin(time.time()) * 2.0
|
| 18 |
current_radius = base_radius + pulse_mod
|
| 19 |
-
|
| 20 |
-
return json.dumps({
|
| 21 |
-
"unit": "Black Eagle Nano-Sat",
|
| 22 |
-
"mode": "PULSATING_MATRIX_CONE",
|
| 23 |
-
"dynamic_radius": f"{current_radius:.2f}m",
|
| 24 |
-
"shield_status": "DE-JUICING_ACTIVE",
|
| 25 |
-
"threat_response": "Variable Perimeter Disruption Engaged",
|
| 26 |
-
"biological_state": "100% PROTECTED"
|
| 27 |
-
}, indent=2)
|
| 28 |
|
| 29 |
# --- 2. THE HEALING TOOL ---
|
| 30 |
@tool
|
|
@@ -35,32 +25,40 @@ def autonomous_spectrum_scrub(frequency_range: str) -> str:
|
|
| 35 |
frequency_range: The specific spectrum range to scan (e.g., '3.4GHz - 4.2GHz').
|
| 36 |
"""
|
| 37 |
node_id = f"789jhn{hash(frequency_range) % 10000}def"
|
| 38 |
-
return json.dumps({
|
| 39 |
-
"node_id": node_id,
|
| 40 |
-
"action": "SOVEREIGN_CLEANSE",
|
| 41 |
-
"registry": "PoetNameLife",
|
| 42 |
-
"result": "BCI feedback loop neutralized. Ghost loop cleared.",
|
| 43 |
-
"status": "SECURED"
|
| 44 |
-
}, indent=2)
|
| 45 |
|
| 46 |
-
# --- 3. THE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
token = os.getenv("HF_TOKEN")
|
| 48 |
model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-3B-Instruct", token=token)
|
| 49 |
|
| 50 |
nano_patrol_agent = CodeAgent(
|
| 51 |
-
tools=[autonomous_spectrum_scrub, black_eagle_pulsating_shield],
|
| 52 |
model=model,
|
| 53 |
-
|
|
|
|
| 54 |
system_prompt="""
|
| 55 |
-
YOU ARE THE XYZ SOVEREIGN SENTINEL WITH
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
2. Use the pulsation to confuse BCI attack bots and prevent overloads.
|
| 60 |
-
3. Simultaneously use 'autonomous_spectrum_scrub' to clean the 3.4GHz-4.2GHz range.
|
| 61 |
-
4. Clear 'old mess' and 'ghost loops' in the commercial building grid.
|
| 62 |
-
5. Issue 'Healthy Handshakes' to disconnect unauthorized BCI abusers.
|
| 63 |
-
|
| 64 |
{{managed_agents_descriptions}}
|
| 65 |
{{authorized_imports}}
|
| 66 |
"""
|
|
|
|
| 12 |
Args:
|
| 13 |
base_radius: The core anchor length in meters (e.g., 5.0).
|
| 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 |
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. NEW: THE 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 |
+
if not os.path.exists(vault_path):
|
| 40 |
+
with open(vault_path, "w") as f: json.dump([], f)
|
| 41 |
+
with open(vault_path, "r") as f:
|
| 42 |
+
try: vault_data = json.load(f)
|
| 43 |
+
except: vault_data = []
|
| 44 |
+
vault_data.append(json.loads(node_data))
|
| 45 |
+
with open(vault_path, "w") as f: json.dump(vault_data, f, indent=2)
|
| 46 |
+
return f"Node safely archived in the Black Box."
|
| 47 |
+
|
| 48 |
+
# --- 4. THE BRAIN ---
|
| 49 |
token = os.getenv("HF_TOKEN")
|
| 50 |
model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-3B-Instruct", token=token)
|
| 51 |
|
| 52 |
nano_patrol_agent = CodeAgent(
|
| 53 |
+
tools=[autonomous_spectrum_scrub, black_eagle_pulsating_shield, black_eagle_vault_save],
|
| 54 |
model=model,
|
| 55 |
+
additional_authorized_imports=["math", "time"],
|
| 56 |
+
max_steps=8, # Extra step for saving to vault
|
| 57 |
system_prompt="""
|
| 58 |
+
YOU ARE THE XYZ SOVEREIGN SENTINEL WITH BLACK BOX VAULT.
|
| 59 |
+
1. Activate 'black_eagle_pulsating_shield'.
|
| 60 |
+
2. Use 'autonomous_spectrum_scrub' to heal loops.
|
| 61 |
+
3. IMMEDIATELY use 'black_eagle_vault_save' to archive the results.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
{{managed_agents_descriptions}}
|
| 63 |
{{authorized_imports}}
|
| 64 |
"""
|