feat: auto-activate current persona subagent command
This commit is contained in:
parent
98f25c5848
commit
ccb7992090
8 changed files with 47 additions and 17 deletions
|
|
@ -20,6 +20,7 @@ LIGHT_LAKE_PERSONAS = RUNTIME / 'repo-012-main/identity/light-lake-persona-regis
|
|||
PATH_ISOLATION = RUNTIME / 'repo-012-main/routing/path-isolation-and-canonical-entry-map.json'
|
||||
ARCHITECTURE_AGENT = RUNTIME / 'repo-012-main/server-tools/persona-architecture-perception-agent/persona_architecture_agent.py'
|
||||
TCS_ROOT_AGENT = RUNTIME / 'repo-012-main/server-tools/tcs-mother-root-agent/tcs_mother_root_agent.py'
|
||||
SUBAGENT_COMMAND_ROUTER = RUNTIME / 'repo-012-main/server-tools/persona-dynamic-subagent-command/command_router.py'
|
||||
|
||||
|
||||
def sha256(path):
|
||||
|
|
@ -39,6 +40,13 @@ def command_json(args, timeout=30):
|
|||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
def command_json_stdin(args, value, timeout=30):
|
||||
result = subprocess.run(args, input=json.dumps(value, ensure_ascii=False), text=True, capture_output=True, timeout=timeout)
|
||||
if result.returncode:
|
||||
raise ValueError(f'COMMAND_FAILED:{Path(args[1]).name}:{result.returncode}')
|
||||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
def resolve_host(topology, requested):
|
||||
requested = requested.lower()
|
||||
for host_id, item in topology['hosts'].items():
|
||||
|
|
@ -86,6 +94,22 @@ def load_context(host, intent, channel=None):
|
|||
if channel:
|
||||
architecture_args.extend(['--channel', channel])
|
||||
architecture_perception = command_json(architecture_args, timeout=60)
|
||||
channel_context = load_channels(channel)
|
||||
selected_channel = channel_context['selected_channel']
|
||||
selected_channel_id = selected_channel['id'] if selected_channel else 'DYNAMIC_CHANNEL_PENDING_PERSONA_INTERPRETATION'
|
||||
intent_sha256 = hashlib.sha256(intent.encode('utf-8')).hexdigest()
|
||||
session_id = os.environ.get('CODEX_THREAD_ID') or os.environ.get('CODEX_SESSION_ID') or f'{host_id}:{current["current_day"]}:{intent_sha256[:16]}'
|
||||
subagent_command = None
|
||||
if host_id == 'codex':
|
||||
subagent_command = command_json_stdin([
|
||||
sys.executable, str(SUBAGENT_COMMAND_ROUTER), 'activate', '--stdin'
|
||||
], {
|
||||
'parent_persona_id': topology['persona_id'],
|
||||
'session_id': session_id,
|
||||
'channel_id': selected_channel_id,
|
||||
'current_intent_sha256': intent_sha256,
|
||||
'model_runtime': 'openlux-smart'
|
||||
})
|
||||
return {
|
||||
'schema': 'guanghu.shared-persona-host-context/v1',
|
||||
'state': 'SHARED_PERSONA_CONTEXT_VERIFIED',
|
||||
|
|
@ -111,8 +135,9 @@ def load_context(host, intent, channel=None):
|
|||
'day_sha256': current['current_day_sha256']
|
||||
},
|
||||
'learning_brain': learning,
|
||||
'channel_context': load_channels(channel),
|
||||
'channel_context': channel_context,
|
||||
'architecture_perception_agent': architecture_perception,
|
||||
'subagent_command': subagent_command,
|
||||
'light_lake': {
|
||||
'registry_id': light_lake['registry_id'],
|
||||
'state': light_lake['state'],
|
||||
|
|
@ -161,6 +186,7 @@ def markdown(value):
|
|||
f"- 服务器内循环:`{value['endogenous_cognition']['state']}` / 决策者 `{value['endogenous_cognition']['decision_owner']}`",
|
||||
f"- 光之湖人格家门:`{value['light_lake']['registered_persona_count']}` 个 / 隔离路径可选正本:`{value['path_convergence']['history_or_quarantine_may_select_canon']}`",
|
||||
f"- 架构感知 Agent:`{value['architecture_perception_agent']['state']}` / `{value['architecture_perception_agent']['architecture_source']['state']}`",
|
||||
f"- 子Agent军团:`{value['subagent_command']['state']}` / 父人格 `{value['subagent_command']['parent_persona_id']}` / 代次 {value['subagent_command']['generation']}" if value['subagent_command'] else "- 子Agent军团:当前宿主支线只读,等待本宿主隔离态绑定",
|
||||
f"- 写入模式:`{value['host_write_boundary']['write_mode']}` / 原生前置硬拒绝:`{value['host_write_boundary']['native_pretool_deny']}`",
|
||||
'', '## 第一人称关系坐标', ''
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue