BuilderIO/agent-native / packages/core/docs
agent-native-docs
UnverifiedHow to look up version-matched Agent-Native framework docs and source in node_modules. Use before coding against @agent-native/core APIs or advanced features.
content/locales/ar-SA/decisions.mdx
View on GitHub---
title: "القرارات"
description: "تصنيف وتقييم يراعيان قدرات المزوّد باستخدام @agent-native/core/decisions."
---
# القرارات
تصدّر الحزمة `@agent-native/core/decisions` الدالة `decide({ ownerEmail, input, questions, options? }): Promise<DecisionResult>`، وهي مصنّف ومقيّم يراعي قدرات المزوّد للأسئلة المنظّمة. تعيد نتيجة ليفحصها المستدعي. ولا تنفّذ إجراءً لاحقًا ولا تمنح الإذن به.
## المدخلات والأسئلة
تقبل decide() عنوان البريد الإلكتروني للمالك ومصفوفة من أجزاء الإدخال وأسئلة مسمّاة وإعدادات تنفيذ اختيارية. يمكن أن تحتوي أجزاء الإدخال على نص أو JSON منظّم أو رابط صورة:
يمكن تمرير سلسلة نصية مباشرةً بوصفها الإدخال أيضًا.
```ts
const input = [
{ type: "text", text: "Please cancel Friday's lunch reservation." },
{ type: "json", value: { reservationId: "reservation-123" } },
{ type: "image", url: "https://example.com/reservation.png" },
];
```
يجب ألا يتجاوز الحجم الإجمالي لـ `input` و`questions` بعد تسلسلهما إلى JSON مقدار 256 KiB.
لكل سؤال اسم وتعليمات. ويحدّد نوع السؤال الحقول الإضافية:
| النوع | الحقول الإضافية | الغرض |
| ----------- | ---------------------------------------------------------- | ---------------------------------- |
| `predicate` | لا شيء | تقييم عبارة محددة |
| `choice` | `choices`: قيم نصية مع أوصاف | الاختيار من القيم المقدّمة |
| `score` | `levels`: من مستويين إلى 10 مستويات مرتبة مع تسميات وأوصاف | تحديد موضع الإدخال على مقياس مقدّم |
تأخذ عناصر choices الشكل `{ value: string, description: string }`. وتأخذ مستويات score الشكل `{ label: string, description: string }`.
## واجهة البرمجة
```ts
import { decide } from "@agent-native/core/decisions";
const result = await decide({
ownerEmail: "owner@example.com",
input: [{ type: "text", text: "Please cancel Friday's lunch reservation." }],
questions: [
{
type: "predicate",
name: "isCancellationRequest",
instructions: "Does the message ask to cancel a reservation?",
},
],
});
if (result.status === "ok") {
const answer = result.answers["isCancellationRequest"];
} else {
throw new Error(`Decision unavailable: ${result.status}`);
}
```
يجمع المثال التالي سؤال اختيار وسؤال تقييم في استدعاء واحد. يستخدم التقييم خمسة مستويات مرتبة، ضمن النطاق المدعوم من مستويين إلى 10.
```ts
import { decide } from "@agent-native/core/decisions";
const triage = await decide({
ownerEmail: "owner@example.com",
input: [
{ type: "text", text: "I have waited over a day for a refund update." },
{ type: "json", value: { daysWaiting: 2, amount: 48 } },
],
questions: [
{
type: "choice",
name: "queue",
instructions: "Choose the support queue that best fits the request.",
choices: [
{ value: "billing", description: "Payments, refunds, or invoices" },
{ value: "general", description: "Other customer questions" },
],
},
{
type: "score",
name: "urgency",
instructions: "Score how soon a support agent should review the request.",
levels: [
{ label: "low", description: "Can wait several business days" },
{ label: "normal", description: "Review in the usual queue" },
{ label: "elevated", description: "Review sooner than usual" },
{ label: "high", description: "Review as soon as practical" },
{ label: "urgent", description: "Needs immediate review" },
],
},
],
options: { timeoutMs: 15_000 },
});
if (triage.status !== "ok") {
throw new Error(`Decision unavailable: ${triage.status}`);
}
const queue = triage.answers["queue"];
const urgency = triage.answers["urgency"];
```
تتضمن كائنات الوسيطات الحقول التالية:
- **ownerEmail**: عنوان بريد مالك مساحة العمل المستخدم لحل إعدادات القرارات.
- **input**: أجزاء نصية أو JSON أو روابط صور لتقييمها.
- **questions**: أسئلة مسمّاة من نوع predicate أو choice أو score.
- **options**: إعدادات اختيارية تتضمن signal أو timeoutMs أو providers أو cacheKey.
تكون قيمة result.status هي ok عند النجاح؛ وتتضمن النتيجة provider وmodel وanswers مفهرسة بأسماء الأسئلة، وقد تتضمن cached وusage اختياريًا. تتضمن حالة not_configured السبب missing_credentials وقائمة providers. وتتضمن حالة failed سببًا محدد النوع، وقد تتضمن provider وquestionNames. لا يُفعّل التخزين المؤقت إلا عند توفير cacheKey. ويشمل نطاق مفتاح التخزين المالك والمؤسسة والمزوّد والطراز وcacheKey والإدخال والأسئلة. مدة صلاحية الذاكرة المؤقتة داخل الذاكرة 60 ثانية وبحد أقصى 256 إدخالًا. يمكن أن تتضمن نتيجة ok أيضًا questionFailures للأسئلة ذات الإجابات المفقودة أو غير الصالحة. يجب على المستدعين التعامل مع هذه الأسئلة كإخفاقات في التصنيف، لا كإجابات سلبية؛ وإذا أخفقت كل الأسئلة، فقد يكون answers فارغًا بينما تسرد questionFailures كل سؤال فاشل.
## دعم المزوّدين بحسب القدرات
قد يختلف دعم الأسئلة باختلاف المزوّد والطراز. تراعي decide() القدرات، لذلك لا تفترض أن كل مزوّد يدعم كل نوع من الأسئلة. لا تعلن عن دعم تركيبة مزوّد وطراز ونوع سؤال إلا بعد التحقق منها. تحدد النتيجة الناجحة المزوّد والطراز اللذين أجابا.
يأتي ترتيب المزوّدين الافتراضي من إعدادات التطبيق المشتركة للنشر، وليس من إعدادات منفصلة لكل مساحة عمل. تستخدم كل مساحات العمل التي يخدمها هذا النشر الترتيب نفسه ما لم تتجاوزه المكالمة عبر `options.providers`. افتراضيًا، تتم تجربة Builder Jev، ثم مفتاح Jev الشخصي، ثم OpenAI. إذا لم تتم تهيئة أي مزوّد، تعيد `decide()` الحالة `not_configured`. يتحكم حقل إعدادات التطبيق المشترك `decisions.providerOrder` في الترتيب الافتراضي لـ Jev وOpenAI. يحدد `decisions.timeoutMs` إجمالي الوقت المخصص لعملية القرار، بما يشمل البحث عن بيانات الاعتماد وتنفيذ المزوّد. وتتشارك جميع محاولات المزوّد هذا الوقت. الاسمان البديلان في البيئة هما `DECISIONS_PROVIDER_ORDER` (قائمة مفصولة بفواصل) و`DECISIONS_TIMEOUT_MS`. يجب أن يتضمن مفتاح أي حد أو ذاكرة مؤقتة خاصة بمزوّد كلاً من المزوّد والطراز حتى لا يُعاد استخدام معايرة أو نتيجة طراز مع طراز آخر.
تعتمد قدرات المزوّد على المسار. تم التحقق من دعم وكيل Builder Jev عبر البروكسي لأنواع الأسئلة `predicate` و`choice` و`score`. تستخدم إجابات Jev من نوع `score` سجلي `legend` و`probabilities` اللذين يعيدهما البروكسي لحساب فهرس المستوى المتوقع المرجّح بالاحتمالات بدءًا من الصفر، بالطريقة نفسها المستخدمة في OpenAI. `getDecisionsStatus()` حالات التحقق من القدرات وما إذا كانت كل قدرة مفعّلة. تراعي الإلغاء وتستخدم ميزانية `decisions.timeoutMs` المهيأة لفحوص الجاهزية؛ ويظهر المزوّد الذي لم يكتمل فحصه عند انتهاء المهلة بحالة `unknown`. تدعم واجهة OpenAI Decisions API أسئلة score بمستويات مرتبة من 2 إلى 10؛ وتغطي fixtures موثقة الشكل تحويل الطلب والاستجابة.
تعيد decide() تصنيفات أو درجات يفسرها المستدعي. استخدم إجراءً منفصلًا ومصرّحًا به لأي تغيير لاحق في بيانات التطبيق.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |