51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""Профиль агента: studio (Коди) по умолчанию, client — агент клиента Autopilot со своим именем."""
|
||
import os
|
||
import subprocess
|
||
import sys
|
||
|
||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
CODE = ("import json; from harness.levels import LEVELS, PROFILE, OWNER; "
|
||
"print(json.dumps({'p': PROFILE, 'o': OWNER, 'm': {k: v.mandate for k, v in LEVELS.items()}}))")
|
||
|
||
|
||
def run(env):
|
||
e = {k: v for k, v in os.environ.items() if not k.startswith("SIMBIOT_")}
|
||
e.update(env)
|
||
out = subprocess.run([sys.executable, "-c", CODE], cwd=ROOT, env=e, capture_output=True, text=True, check=True)
|
||
import json
|
||
return json.loads(out.stdout)
|
||
|
||
|
||
def main():
|
||
ok = bad = 0
|
||
|
||
def eq(c, msg):
|
||
nonlocal ok, bad
|
||
if c:
|
||
ok += 1
|
||
else:
|
||
bad += 1
|
||
print("FAIL", msg)
|
||
|
||
st = run({"SIMBIOT_PROFILE": "studio"})
|
||
eq(st["p"] == "studio", "studio profile")
|
||
eq("Коди" in st["m"]["min"] and "@juno42bot" in st["m"]["min"], "studio min is Cody")
|
||
eq("booking_slots" in st["m"]["min"], "studio has booking")
|
||
|
||
cl = run({"SIMBIOT_PROFILE": "client", "SIMBIOT_AGENT_DISPLAY_NAME": "Acme Autopilot",
|
||
"SIMBIOT_OWNER_NAME": "Ann Bee", "SIMBIOT_COMPANY": "Acme"})
|
||
eq(cl["o"] == "Ann Bee", "owner")
|
||
for lvl in ("min", "hour", "day"):
|
||
m = cl["m"][lvl]
|
||
eq("Acme Autopilot" in m and "«Acme»" in m and "Ann Bee" in m, f"{lvl}: identity")
|
||
eq("@juno42bot" not in m and "Алекс" not in m and "Alex" not in m, f"{lvl}: no Cody/Alex")
|
||
eq("booking_slots" not in m and "list_members" not in m and "treasury_status" not in m, f"{lvl}: no studio tools")
|
||
eq("git_repo_create" in m and "product_create" in m, f"{lvl}: client tools")
|
||
eq(cl["m"]["sec"] == st["m"]["sec"], "sec level shared")
|
||
|
||
print(f"{ok} ok, {bad} fail")
|
||
sys.exit(1 if bad else 0)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|