Jaarvis / plugins /_template.py
abc1181's picture
Jaarvis voice Space (assembled from monorepo)
370c3e4
Raw History Blame Contribute Delete
1.85 kB
"""
Drop-in JARVIS plugin template.
Copy this file, rename it (no leading underscore), fill in PLUGIN and run().
No other file needs to change — JARVIS discovers this automatically at startup.
"""
PLUGIN = {
"name": "my_plugin", # snake_case, unique, ^[a-zA-Z_][a-zA-Z0-9_]{0,63}$
"description": (
"One or two sentences Gemini uses to decide when to call this tool. "
"Be explicit about trigger phrases and, if it could be confused with "
"another tool, say which tool NOT to use instead (see game_updater's "
"description in main.py for the pattern)."
),
"parameters": {
"type": "OBJECT",
"properties": {
"example_arg": {"type": "STRING", "description": "What this argument means"},
},
"required": [], # omit or leave empty for a zero-argument tool
},
}
def run(parameters: dict, player=None, session_memory=None) -> str:
"""
parameters: dict of the args Gemini extracted, matching PLUGIN['parameters'].
player: the JarvisUI instance — use player.write_log(f"JARVIS: ...") to log,
same as actions/*.py. May be None.
session_memory: reserved, usually None today (core tools mostly pass None too).
Return a short natural-language string — this is spoken back to the user.
Never raise: catch your own errors and return a spoken error string instead
(the loader also catches exceptions as a second safety net, but don't rely on it).
"""
example_arg = parameters.get("example_arg", "")
try:
result_text = f"Did the thing with {example_arg}."
except Exception as e:
return f"Sir, my_plugin failed: {e}"
if player:
try:
player.write_log(f"JARVIS: {result_text}")
except Exception:
pass
return result_text