الأحداث

:

{ type: "permission", id, tool, category, args, mode }

يُطلب شيء ما ، يُنْشَأ قبل ان يُنتظر ردّك على اتصالك ، اي ما يترك واجهة تدهن الحوار بينما ينتظر الوعد النقرة .

before the callbackpermission_result followsthe whole args
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

الحقول

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 ما يخبرك أن شيئاً ما يحدث

تصل أحداث الوكلاء الفرعيين إلى هنا أيضًا

وهم يحملون اسم من النوع الأول - هوية نداء المهمة الذي بدأهم - والعامل، اسمه. هويتهم الخاصة مُمهدة مع المهمة، لذا لا يصطدم اثنان أبدا. اختبر المُنَصَف قبل أن تُعامل حدثا ما على أنه الركض الرئيسي.