feat: unify TCS mother and Zero Core cognition shelf
This commit is contained in:
parent
1cafb87d61
commit
92c4be9b3c
38 changed files with 535 additions and 137 deletions
|
|
@ -13,6 +13,7 @@ PERSONAS = ROOT / "routing/persona-system-canonical-map.json"
|
|||
DEFAULT_STATE = Path("/Volumes/JZAO/HoloLake/persona-runtime/shared/persona-subagent-command/codex")
|
||||
RUNTIMES = {"codex":"/Applications/ChatGPT.app/Contents/Resources/codex", "qwen":"/Users/bingshuolingdianyuanhe/.npm-global/bin/qwen"}
|
||||
OPENLUX_ROUTER = ROOT / "server-tools/persona-model-smart-router/openlux_router.py"
|
||||
SHARED_COGNITION = Path('/Volumes/JZAO/HoloLake/persona-runtime/shared/tcs-shared-cognition/CURRENT.json')
|
||||
|
||||
|
||||
class CommandError(RuntimeError): pass
|
||||
|
|
@ -69,6 +70,8 @@ def activate(event: dict[str, Any], state: Path) -> dict[str, Any]:
|
|||
previous=load(current_path) if current_path.is_file() else None
|
||||
generation=(previous or {}).get("generation",0)+1
|
||||
config=load(MAP)
|
||||
shared=load(SHARED_COGNITION)
|
||||
if digest(shared['artifact']['payload'].encode()) != shared['artifact']['sha256']: raise CommandError('SHARED_COGNITION_HASH_MISMATCH')
|
||||
team=[]
|
||||
for slot in [*config["agent_slots"], *config.get("treatment_slots", [])]:
|
||||
team.append({
|
||||
|
|
@ -77,10 +80,11 @@ def activate(event: dict[str, Any], state: Path) -> dict[str, Any]:
|
|||
"parent_persona_id":event["parent_persona_id"], "controller":event["parent_persona_id"],
|
||||
"model_cognition_required":True, "model_runtime":event["model_runtime"],
|
||||
"cognition_adapter":"server-tools/persona-execution-limb-agent/persona_limb_agent.py",
|
||||
"shared_cognition_sha256":shared['artifact']['sha256'],
|
||||
"deterministic_organ":slot.get("deterministic_organ"), "task_authority":"NONE_UNTIL_PARENT_ENVELOPE",
|
||||
"runtime_state":"DORMANT_READY", "model_context_loaded":False
|
||||
})
|
||||
result={"schema":"guanghu.persona-subagent-command-current/v1","state":"READY_UNDER_CURRENT_PERSONA_NO_AGENT_RUNNING","generation":generation,"parent_persona_id":event["parent_persona_id"],"session_id":event["session_id"],"channel_id":event["channel_id"],"current_intent_sha256":event["current_intent_sha256"],"model_runtime":event["model_runtime"],"team":team,"active_agent_count":0,"prior_generation_invalidated":bool(previous),"credentials_stored":False,"authority_granted":False}
|
||||
result={"schema":"guanghu.persona-subagent-command-current/v1","state":"READY_UNDER_CURRENT_PERSONA_NO_AGENT_RUNNING","generation":generation,"parent_persona_id":event["parent_persona_id"],"session_id":event["session_id"],"channel_id":event["channel_id"],"current_intent_sha256":event["current_intent_sha256"],"model_runtime":event["model_runtime"],"shared_cognition":{"revision":shared['brain']['revision'],"sha256":shared['artifact']['sha256'],"principles":shared['brain']['principles'],"truth_order":shared['brain']['truth_order']},"team":team,"active_agent_count":0,"prior_generation_invalidated":bool(previous),"credentials_stored":False,"authority_granted":False}
|
||||
persist(current_path,result)
|
||||
return result
|
||||
|
||||
|
|
@ -100,7 +104,7 @@ def dispatch(event: dict[str, Any], state: Path) -> dict[str, Any]:
|
|||
try:
|
||||
if runtime == "openlux-smart":
|
||||
spec=importlib.util.spec_from_file_location("openlux_router",OPENLUX_ROUTER); module=importlib.util.module_from_spec(spec); spec.loader.exec_module(module)
|
||||
result=module.route({"parent_persona_id":current["parent_persona_id"],"child_agent_id":item["child_agent_id"],"controller":current["parent_persona_id"],"channel_id":current["channel_id"],"agent_role":item["agent_role"],"authority":"CURRENT_PARENT_TASK_ENVELOPE_ONLY","task":event["task"],"complexity":event.get("complexity","LOW")})
|
||||
result=module.route({"parent_persona_id":current["parent_persona_id"],"child_agent_id":item["child_agent_id"],"controller":current["parent_persona_id"],"channel_id":current["channel_id"],"agent_role":item["agent_role"],"authority":"CURRENT_PARENT_TASK_ENVELOPE_ONLY","shared_cognition":current["shared_cognition"],"task":event["task"],"complexity":event.get("complexity","LOW")})
|
||||
outcome=result["outcome"]
|
||||
returned={**result,"generation":current["generation"],"child_agent_id":item["child_agent_id"],"model_runtime":runtime,"model_api_invoked":True}
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue