Skillpedia
الوكلاء7.8k · #12832

agent-squad-typescript

ما الذي تفعله

يساعد هذا الدليل الذكاء الاصطناعي على كتابة تطبيق Node.js أو TypeScript يستخدم حزمة agent-squad لتشغيل عدة وكلاء ذكاء اصطناعي. وهو موجه إلى المطورين الذين يبنون مساعدين ذكيين على الخادم.

متى تستخدمها

  • ✓عندما أريد بناء فريق من وكلاء الذكاء الاصطناعي، يتولى كل واحد منهم موضوعاً مختلفاً.
  • ✓عندما أحتاج إلى سلسلة خطوات ذكاء اصطناعي، تمرر فيها كل خطوة نتيجتها إلى التي تليها.
  • ✓عندما يجب أن تستند إجابات الذكاء الاصطناعي إلى مستنداتي أو قاعدة معرفتي.

رابط المهارة

https://github.com/2FastLabs/agent-squad/blob/main/typescript/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/2FastLabs/agent-squad/blob/main/typescript/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أريد إعداد تطبيق TypeScript يجيب فيه عدة وكلاء ذكاء اصطناعي عن أنواع مختلفة من الأسئلة. كيف أبدأ؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يخبر الدليل الذكاء الاصطناعي بالأجزاء التي يجب استخدامها من الحزمة، مثل المنسّق والوكلاء والتوجيه والتخزين، وما يجب تجنبه. أما تفاصيل الشيفرة الدقيقة فتأتي من الحزمة نفسها.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

agent-squad TypeScript — assistant guide

Node.js / TypeScript multi-agent orchestration framework (npm package agent-squad). All public symbols are exported from a single barrel typescript/src/index.ts. This file is guidance and a map — not an API reference. Read exact signatures from typescript/src/ and worked recipes from docs/src/content/docs/; this file tells you what to use, when, and what to watch out for.

When to use what

  • One assistant → a single Agent subclass + AgentSquad with no routing. Or skip the orchestrator entirely and call agent.processRequest(...) directly.
  • Several specialists → multiple agents registered with orchestrator.addAgent(agent), a classifier routes each turn.
  • Answers must not drift from data (prices, balances, live lookups) → GroundedAgent: a gatherer LLM calls tools, an isolated presenter LLM speaks only from the curated results.
  • Fixed pipeline → ChainAgent: each agent's output is the next agent's input.
  • One lead LLM coordinating a team → SupervisorAgent: the lead calls sub-agents as tools.
  • External tools via MCP → MCPToolProvider (async factory pattern, optional peer dep).
  • RAG context → attach a Retriever to any agent that supports retriever? in its options.

How to install

npm install agent-squad

Optional peer dependencies — install only what you use:

Package Used by
@aws-sdk/client-bedrock-runtime BedrockLLMAgent, BedrockClassifier (already a hard dep in current releases)
@anthropic-ai/sdk AnthropicAgent, AnthropicClassifier (already a hard dep)
openai OpenAIAgent, OpenAIClassifier (already a hard dep)
@modelcontextprotocol/sdk MCPToolProvider — lazy await import() at connect time
@dakera-ai/dakera DakeraRetriever — lazy require() at construction time

@modelcontextprotocol/sdk and @dakera-ai/dakera are the only two true optional peer deps; everything else ships as a hard dependency at the moment.

How a turn works

routeRequest is the single entry point. It classifies the input, dispatches to the selected agent, saves the exchange, and returns an AgentResponse. The response is either a plain string or a Node.js Transform stream:

import { AgentSquad, BedrockLLMAgent, BedrockClassifier } from 'agent-squad';

const orchestrator = new AgentSquad({
  classifier: new BedrockClassifier(),   // default when omitted
  // storage: new DynamoDbChatStorage(...),
  // config: { LOG_AGENT_CHAT: true, MAX_MESSAGE_PAIRS_PER_AGENT: 50 },
});

orchestrator.addAgent(new BedrockLLMAgent({
  name: 'Tech Support',
  description: 'Handles technical questions about software and hardware',
  streaming: true,
}));

const response = await orchestrator.routeRequest(
  userInput,
  userId,
  sessionId,
  additionalParams   // optional Record<string, any>
);

if (response.streaming) {
  // response.output is an AccumulatorTransform (Node.js Transform)
  for await (const chunk of response.output) {
    process.stdout.write(chunk);
  }
} else {
  // response.output is a string
  console.log(response.output);
  // response.thinking? is set when the agent used extended thinking
}

// response.metadata: { agentId, agentName, userId, sessionId, userInput, additionalParams }

routeRequest never throws — it catches all errors and returns them as a non-streaming AgentResponse with the error string in output (configurable via GENERAL_ROUTING_ERROR_MSG_MESSAGE).

The pieces

Orchestrator: AgentSquad

new AgentSquad(options?: OrchestratorOptions)

Key OrchestratorOptions fields:

Field Default Notes
classifier new BedrockClassifier() Any Classifier subclass
storage new InMemoryChatStorage() Any ChatStorage subclass
defaultAgent undefined Used when classifier returns no match and USE_DEFAULT_AGENT_IF_NONE_IDENTIFIED is true
config.USE_DEFAULT_AGENT_IF_NONE_IDENTIFIED true Fall back to defaultAgent or return NO_SELECTED_AGENT_MESSAGE
config.MAX_MESSAGE_PAIRS_PER_AGENT 100 Per-agent history cap (pairs = user+assistant)
config.MAX_RETRIES 3 Classifier retries on bad XML response
config.LOG_AGENT_CHAT false

Useful methods: addAgent(agent), setDefaultAgent(agent), getDefaultAgent(), getAllAgents(), analyzeAgentOverlap(), classifyRequest(...), `agentProcess

الأسئلة الشائعة

أين يمكن تخزين بيانات الوكلاء؟

تدعم الحزمة التخزين في الذاكرة وDynamoDB وقواعد SQL، فتختار ما يناسبك.

كيف تُثبَّت الحزمة؟

يستخدم الدليل أمر npm install المعتاد لحزمة agent-squad، وتُضاف الإضافات الاختيارية عند الحاجة فقط.

هل يمكن للوكلاء استخدام أدوات MCP؟

نعم. يتيح مزود أدوات MCP للوكلاء استخدام أدوات من خوادم خارجية.

التفاصيل

الوصف الأصلي من المؤلف

Use when building or modifying a Node.js / TypeScript app that uses the agent-squad npm package — multi-agent orchestration: orchestrator, agents (all built-in types + GroundedAgent), classifier routing (Bedrock / Anthropic / OpenAI), storage (in-memory / DynamoDB / SQL), retrievers (Amazon KB / Dakera), and tools (AgentTools + MCPToolProvider).

repo: 2FastLabs/agent-squad

الشعبية

نجوم GitHub
7.8k
الترتيب
#12832
الترخيص
Apache-2.0
آخر تحديث
8‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة