a2d238d92e
Make Zed Agent closer to Cursor: deterministic DevOps path index, live Traefik port probe before blind edits, stop-after-edit, and quieter Russian progress.
83 lines
2.8 KiB
Bash
83 lines
2.8 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
ssh -o BatchMode=yes eventhub-ift 'bash -s' <<'REMOTE'
|
|
set -euo pipefail
|
|
cd /opt/ai-router-stack
|
|
set -a; source .env; set +a
|
|
BASE="${PUBLIC_URL:-https://ai-router.ift.calentiq.com}"
|
|
KEY="${ROUTER_API_KEY:-$LITELLM_MASTER_KEY}"
|
|
test -f /tmp/agent-plan.json && echo "plan_ok $(wc -c </tmp/agent-plan.json)" || echo "no plan"
|
|
python3 <<'PY'
|
|
import json
|
|
d=json.load(open("/tmp/agent-plan.json"))
|
|
content=((d.get("choices") or [{}])[0].get("message") or {}).get("content") or ""
|
|
tools=[{
|
|
"type":"function",
|
|
"function":{
|
|
"name":"read_file",
|
|
"description":"Read a file",
|
|
"parameters":{"type":"object","properties":{"path":{"type":"string"}},"required":["path"]}
|
|
}
|
|
},{
|
|
"type":"function",
|
|
"function":{
|
|
"name":"edit_file",
|
|
"description":"Edit a file",
|
|
"parameters":{"type":"object","properties":{
|
|
"path":{"type":"string"},
|
|
"edits":{"type":"array","items":{"type":"object","properties":{
|
|
"old_text":{"type":"string"},"new_text":{"type":"string"}
|
|
}}}
|
|
},"required":["path","edits"]}
|
|
}
|
|
}]
|
|
body={
|
|
"model":"smart-router",
|
|
"stream": False,
|
|
"tools": tools,
|
|
"messages":[
|
|
{"role":"user","content":"observer.ift.calentiq.com не работает - Bad Gateway почини"},
|
|
{"role":"assistant","content":content},
|
|
{"role":"user","content":"ok"}
|
|
]
|
|
}
|
|
json.dump(body, open("/tmp/agent-approve-req.json","w"), ensure_ascii=False)
|
|
print("req_ok", len(content), "tools", len(tools))
|
|
PY
|
|
code=$(curl -sS --max-time 180 -o /tmp/agent-exec1.json -w "%{http_code}" \
|
|
"$BASE/v1/chat/completions" \
|
|
-H "Authorization: Bearer $KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-H "X-AI-Orchestrate: force" \
|
|
-H "X-AI-Quality: balanced" \
|
|
-d @/tmp/agent-approve-req.json || true)
|
|
echo "http=$code bytes=$(wc -c </tmp/agent-exec1.json)"
|
|
head -c 500 /tmp/agent-exec1.json; echo
|
|
python3 <<'PY'
|
|
import json
|
|
raw=open("/tmp/agent-exec1.json").read().strip()
|
|
if not raw:
|
|
print("EMPTY"); raise SystemExit
|
|
d=json.loads(raw)
|
|
if d.get("error"):
|
|
print("ERROR", d["error"]); raise SystemExit
|
|
ch=(d.get("choices") or [{}])[0]
|
|
msg=ch.get("message") or {}
|
|
print("finish", ch.get("finish_reason"))
|
|
print("content_head:")
|
|
print((msg.get("content") or "")[:1500])
|
|
tcs=msg.get("tool_calls") or []
|
|
print("n_tools", len(tcs))
|
|
for tc in tcs:
|
|
fn=tc.get("function") or {}
|
|
print("TOOL", fn.get("name"))
|
|
print("ARGS", (fn.get("arguments") or "")[:400])
|
|
meta=d.get("x_router_meta") or {}
|
|
print("phase", meta.get("agent_phase"), "exec", meta.get("executor_model") or meta.get("selected_model"),
|
|
"force", meta.get("executor_force_edit_after_read"), "stop", meta.get("executor_stop_after_edit"))
|
|
PY
|
|
docker service logs --since 4m --raw ai-router_router 2>&1 \
|
|
| grep -iE 'path_index|force edit|stop after|phase=|executor result|kickstart|Выполн' \
|
|
| tail -25
|
|
REMOTE
|