|
|
|
@@ -185,15 +185,15 @@ class H(BaseHTTPRequestHandler):
|
|
|
|
|
if path in ('/api/openapi.yaml','/api/openapi-chatgpt-actions.yaml','/api/schema'):
|
|
|
|
|
return self.sendt(OPENAPI.read_text(encoding='utf-8'), 'application/yaml; charset=utf-8') if OPENAPI.exists() else self.sendj({'error':'schema_missing'},404)
|
|
|
|
|
if path in ('/api','/api/status'): return self.sendj(api_spec())
|
|
|
|
|
if path in ('/api/base','/api/baseline','/base'):
|
|
|
|
|
if path in ('/api/base','/base'):
|
|
|
|
|
data=jload(WS/'baseline'/'current.json', {}); data.setdefault('git', sh(['rev-parse','--short','HEAD'])['stdout']); return self.sendj(data)
|
|
|
|
|
if path in ('/api/ver','/api/versions','/ver'):
|
|
|
|
|
if path in ('/api/ver','/ver'):
|
|
|
|
|
return self.sendj({'tags':sh(['tag','--list','V*'])['stdout'].splitlines(),'versions_dir':[p.name for p in (WS/'versions').glob('*')],'head':sh(['rev-parse','--short','HEAD'])['stdout']})
|
|
|
|
|
if path in ('/api/diff','/diff'):
|
|
|
|
|
frm=(q.get('from') or ['HEAD~1'])[0]; to=(q.get('to') or ['HEAD'])[0]; return self.sendj({'from':frm,'to':to,'diff':sh(['diff',frm,to])})
|
|
|
|
|
if path in ('/api/patch','/api/patches','/api/branches','/patch'): return self.sendj({'patches':patches(),'branches':sh(['branch','--format','%(refname:short)'])['stdout'].splitlines()})
|
|
|
|
|
if path in ('/api/patch','/patch'): return self.sendj({'patches':patches(),'branches':sh(['branch','--format','%(refname:short)'])['stdout'].splitlines()})
|
|
|
|
|
if path in ('/api/model','/model'): return self.sendj({'base':BASE_MODELS,'custom':model_docs(),'priority':[jload(p,{}) for p in sorted((WS/'config'/'model_priority').glob('*.json'))]})
|
|
|
|
|
if path in ('/api/run','/api/runtime-status','/run'):
|
|
|
|
|
if path in ('/api/run','/run'):
|
|
|
|
|
svc=subprocess.run(['systemctl','is-active','aios-gitops-model-api'], text=True, capture_output=True)
|
|
|
|
|
return self.sendj({'service':'aios-gitops-model-api','status':svc.stdout.strip() or svc.stderr.strip(),'workspace_branch':sh(['rev-parse','--abbrev-ref','HEAD'])['stdout']})
|
|
|
|
|
if path in ('/api/action-monitor','/action-monitor'):
|
|
|
|
@@ -211,11 +211,11 @@ class H(BaseHTTPRequestHandler):
|
|
|
|
|
def do_POST(self):
|
|
|
|
|
path=urllib.parse.urlparse(self.path).path.rstrip('/'); data=self.body()
|
|
|
|
|
try:
|
|
|
|
|
if path in ('/api/branch','/api/create-branch'): return self.branch(data)
|
|
|
|
|
if path in ('/api/file','/api/commit-file'): return self.file(data)
|
|
|
|
|
if path == '/api/branch': return self.branch(data)
|
|
|
|
|
if path == '/api/file': return self.file(data)
|
|
|
|
|
if path == '/api/commit': return self.commit(data)
|
|
|
|
|
if path in ('/api/patch','/api/create-patch'): return self.patch(data)
|
|
|
|
|
if path in ('/api/tag','/api/create-tag'): return self.tag(data)
|
|
|
|
|
if path == '/api/patch': return self.patch(data)
|
|
|
|
|
if path == '/api/tag': return self.tag(data)
|
|
|
|
|
if path == '/api/rollback': return self.rollback(data)
|
|
|
|
|
if path == '/api/model': return self.model(data)
|
|
|
|
|
if path == '/api/model-priority': return self.model_priority(data)
|
|
|
|
|