Use official global UI system prompt and verify outbound delivery

This commit is contained in:
Mikei386 committed 2026-10-12 16:38:03 +02:00
1 parent 4d1dbed1bf
commit dd4bd73fd7
9 files changed
+274 -42

No files matched your search

@@ -23,9 +23,18 @@ existing=c.execute('select content,is_active,is_global from function where id=?'
if existing:
assert existing[0]==payload['content'],'Different installed version; back up and inspect before update'
if existing[1] and existing[2]:
print(json.dumps({'id':ident,'active':True,'global':True,'already_installed':True}));sys.exit(0)
pass # Still verify/apply supplied valves below.
f=api('/api/v1/functions/id/'+ident) if existing else api('/api/v1/functions/create',{'id':ident,'name':'Athena Tool Context Guard','content':payload['content'],'meta':{'description':'Bounds native tool output before every model request.'}})
if not f.get('is_active'):f=api('/api/v1/functions/id/'+ident+'/toggle',{})
if not f.get('is_global'):f=api('/api/v1/functions/id/'+ident+'/toggle/global',{})
print(json.dumps({'id':f['id'],'active':f['is_active'],'global':f['is_global']}))
assert f['is_active'] and f['is_global']
# The API accepts the valve dictionary directly, not {"valves": ...}.
if 'valves' in payload:
desired=dict(payload['valves']);desired.pop('audit_chat_ids',None)
result=api('/api/v1/functions/id/'+ident+'/valves/update',desired)
assert result==desired,'API silently ignored or altered valves'
stored=json.loads(c.execute('select valves from function where id=?',(ident,)).fetchone()[0] or '{}')
assert stored==desired,'Persisted valves differ'
print(json.dumps({'valves_verified':True,'audit_enabled':False}))