الحقول
idstringأداة دعوة أداة معر مُعرَف - نفس tool_start سوف يُحمل
toolstringما المطلوب منه
categorystringجمهورية الفئة الاجتماعية.
argsobjectالحجج الفعلية، هذا ما يجب أن يظهره الشخص
modestringالنسق المعمول به في هذه اللحظة.
نمط الإنسان في لووب
const pending = new Map();
const agent = api.agents.create({
runtime: "local", machine: pc, model, mode: "ask",
// The promise is what the loop waits on
onPermission: ({ id }) => new Promise((resolve) => pending.set(id, resolve)),
// The event is what paints the dialog
onEvent: (e) => {
if (e.type === "permission") showDialog(e.id, e.tool, e.category, e.args);
if (e.type === "permission_result") closeDialog(e.id, e.decision);
},
});
// When the person clicks
function answer(id, decision) { pending.get(id)?.(decision); pending.delete(id); }import threading
pending = {}
def on_permission(request):
# The Python callback is synchronous: block this run's thread until the person answers
answered = threading.Event()
pending[request["id"]] = {"event": answered, "decision": "deny"}
answered.wait()
return pending.pop(request["id"])["decision"]
def on_event(event):
if event["type"] == "permission":
show_dialog(event["id"], event["tool"], event["category"], event["args"])
if event["type"] == "permission_result":
close_dialog(event["id"], event["decision"])
agent = api.agents.create(runtime="local", machine=pc, model=model, mode="ask", on_permission=on_permission)
# When the person clicks (from another thread)
def answer(call_id, decision):
pending[call_id]["decision"] = decision
pending[call_id]["event"].set()permission_result
{ type: "permission_result", id, tool, decision } // "once" | "always" | "deny"{"type": "permission_result", "id": ..., "tool": ..., "decision": ...} # "once" | "always" | "deny"يتم انبعاثه بعد قرارات ردك على الطلب مع ما تقرر true & once; false, null ولا شيء من هذا deny.
هؤلاء الثلاثة يقبلون الإجابة ويعاملونها على أنها موافقة واحدة، لذا فإن الحدث الناتج يقول مرة واحدة. النداء التالي يطلب مرة أخرى، أياً كان النقر.
When no event is emitted at all
- A
read,memoryأوtask-مسموح به دائماً - نمط الخطة الرافض للتغيير - مرفوض صراحة، وفقط
tool_endيُنْقَلُ. - Full mode allowing one of the four it opens.
- نداء يغطيه "دائماً" ذكر من قبل
إذاً غياب التنبيه ليس غياب الإيجاب: tool_start ما يخبرك أن شيئاً ما يحدث
وهم يحملون اسم من النوع الأول - هوية نداء المهمة الذي بدأهم - والعامل، اسمه. هويتهم الخاصة مُمهدة مع المهمة، لذا لا يصطدم اثنان أبدا. اختبر المُنَصَف قبل أن تُعامل حدثا ما على أنه الركض الرئيسي.