agent-squad-swift
Fungsinya
Panduan ini membantu AI membangun aplikasi Swift yang memakai kerangka kerja AgentSquad untuk mengoordinasikan agent AI di perangkat. Panduan ini cocok untuk pengembang Swift yang mengerjakan aplikasi iOS atau macOS.
Kapan dipakai
- โSaat saya ingin menambahkan satu asisten AI ke aplikasi iPhone atau Mac yang ditulis dengan Swift.
- โSaat saya membutuhkan beberapa agent AI spesialis, dan router memilih yang tepat untuk setiap pesan.
- โSaat aplikasi saya membutuhkan jawaban AI yang harus sesuai dengan data langsung, seperti harga atau saldo.
Link skill
https://github.com/2FastLabs/agent-squad/blob/main/swift/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
โSaya ingin menambahkan asisten AI multi-agent ke aplikasi iPhone Swift saya menggunakan AgentSquad. Dari mana saya harus mulai?โ
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Panduan ini mengarahkan AI ke blok bangunan yang tepat, seperti agent, router, dan alat, lalu menjelaskan hal-hal yang perlu diwaspadai. Panduan ini tidak menggantikan referensi resmi.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
AgentSquad Swift โ assistant guide
Protocol-driven, on-device multi-agent framework (Swift 6.2, iOS 16+ / macOS 14+; persistence via
FileChatStorage on iOS 16+, DeviceChatStorage on iOS 17+). This is guidance and
a map โ not an API reference. Read the exact signatures from the source (swift/Sources/AgentSquad/)
and the worked recipes from the docs site sources (docs/src/content/docs/swift/); this file tells
you what to use, when, and what to watch out for.
When to use what
- One assistant โ an
Agent(orGroundedAgent) + anOrchestratorwith no classifier. No routing hop. - Several specialists โ multiple agents + an
LLMClassifier; the orchestrator routes each turn. - Answers must not drift from data (prices, stock, balances) โ
GroundedAgent: a Brain calls tools, an isolated Presenter speaks only from the curated results (it can be a smaller/local model). - Voice โ a
VoiceAssistant(a peer of the orchestrator, not an agent):OpenAIVoiceAssistant(single LLM + tools, speaks directly โ the spoken analog ofAgent) orOpenAIGroundedVoiceAssistant(Brain โ Presenter, can't drift from data โ analog ofGroundedAgent).
Every component is a Sendable protocol with one built-in implementation โ swap in your own anywhere.
Modules (import only what you use)
| Import | Pulls in | Contents |
|---|---|---|
AgentSquad |
nothing external | protocols, Agent, GroundedAgent, Orchestrator, LLMClassifier, ChatCompletionsClient, DakeraRetriever, FileChatStorage, DeviceChatStorage, InMemoryChatStorage, TransformingChatStorage, SummarizingChatStorage, OSLogTracer, OTLP export |
AgentSquadMCP |
MCP Swift SDK | MCPServer (= MCPToolProvider), SDKMCPClient |
AgentSquadAudio |
AVFoundation | VoiceProcessedAudioIO (capture+playback, one engine, AEC โ the recommended wiring), MicCapture (voice-processed/AEC by default), AudioPlayback, VoiceProcessing, AudioSessionPolicy (needs NSMicrophoneUsageDescription) |
SwiftPM: .package(url: "https://github.com/2FastLabs/agent-squad", branch: "main").
How a turn works
Two peer runtimes share contracts but not a control loop: a turn-based Orchestrator
(classify? โ run agent โ stream โ persist) and a long-lived VoiceAssistant for voice. Either
way you consume an AsyncThrowingStream<AgentEvent, any Error> โ the one idiom worth memorizing:
for try await event in orchestrator.route(.text("hello"), userId: "u1", sessionId: "s1") {
switch event {
case .textDelta(let token): /* stream tokens */
case .final(let message): /* the message that was persisted */
case .toolCall, .widget, .thinking, .error: break // .error is a user-facing string
}
}
.error carries a user-facing message; real programmer/transport failures throw through the
stream. .final is what the orchestrator persists. Inputs/messages are value types
(AgentInput.text, ConversationMessage, ContentPart, JSONValue) in Sources/AgentSquad/Core/.
The pieces
Orchestratordrives a turn. The classifier is optional โ omit it for a single agent.Agentis one LLM with an internal tool loop.GroundedAgentis two LLMs (Brain + isolated Presenter) for answers that must stay grounded in tool results. The Presenter never sees chat history or the Brain's transcript;presenterInputpicks.questionAndData(default) or.dataOnly.ChatCompletionsClientspeaks the OpenAI wire โ point itsbaseURLat OpenAI, Azure, OpenRouter, Groq, or a local Ollama/llama.cpp. ImplementLLMClientfor anything else.- Tools come from a
ToolProvider. Built-ins:ToolKitholds native tools โTool.local(Swift closure) andTool.http/Tool.get/.post(declarative HTTP, with aToolParameterDSL so you don't hand-write JSON Schema);HTTPToolGroup(baseURL:โฆ)declares one API's shared config once, then one line per endpoint;MCPServer(url:)connects an MCP server; andAggregateToolProvidercomposes any mix behind one seam;DakeraRetriever(namespace:โฆ)is aToolProviderbacked by a self-hosted Dakera memory server โ it exposes asearch_memorytool for grounding (and a directretrieve(_:)API), talking to Dakera's REST endpoint overURLSessionwith no extra dependency. AToolResultis three-part: text โ the model's context,structuredContentโ curator/UI data,
Pertanyaan umum
Sistem Apple mana yang didukung?
Kerangka kerja ini ditujukan untuk iOS 16 ke atas dan macOS 14 ke atas.
Apakah panduan ini hanya untuk ahli?
Panduan ini ditujukan untuk pengembang yang sudah membangun aplikasi Swift dan ingin memakai kerangka kerja ini.
Apakah agent bisa memakai alat dari luar?
Bisa. Kerangka kerja ini mendukung alat bawaan dan alat yang disediakan oleh server MCP.
Detail
Deskripsi asli dari pembuat
Use when building or modifying a Swift app that uses the AgentSquad Swift framework โ on-device multi-agent orchestration for iOS 16+ / macOS 14+: orchestrator, agents (Agent, GroundedAgent), classifier routing, LLM clients (OpenAI-compatible), tools (native + MCP), tool UIs/widgets, on-device storage, tracing, and realtime voice โ built-in types and custom implementations.
repo: 2FastLabs/agent-squad
Popularitas
- Bintang GitHub
- 7.8k
- Peringkat
- #12831
- Lisensi
- Apache-2.0
- Diperbarui
- 8/10/2026
Komentar
- โฆ
Skill lain dari repositori ini
agent-squad-python
7.8kMembantu agent Anda membangun aplikasi Python dengan paket agent-squad, sebuah kerangka kerja untuk mengoordinasikan beberapa agent AI, mengarahkan permintaan, dan berbagi alat.
agent-squad-typescript
7.8kMembantu agent Anda membangun aplikasi Node.js tempat beberapa agent AI bekerja sama, dengan perutean, penyimpanan data, dan koneksi ke alat eksternal.
Skill serupa
add-model-provider
394kMemungkinkan agent Anda menghubungkan penyedia model AI baru ke OpenClaw dengan perintah pengaturan yang aman, menjaga kunci API tetap di luar teks biasa, dan menjalankan uji langsung.
acp-router
394kMembantu agent Anda mengirim tugas ke asisten pemrograman seperti Claude Code atau Cursor lewat OpenClaw, sehingga pekerjaan dijalankan di alat tersebut.
browser-automation
394kMengajari agent Anda mengendalikan halaman web langkah demi langkah, termasuk login, tab, dan pemulihan saat halaman berhenti merespons.