pilot-ai 0.3.14 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +326 -0
- package/dist/agent/claude.d.ts +4 -0
- package/dist/agent/claude.d.ts.map +1 -1
- package/dist/agent/claude.js +12 -2
- package/dist/agent/claude.js.map +1 -1
- package/dist/agent/core.d.ts +1 -0
- package/dist/agent/core.d.ts.map +1 -1
- package/dist/agent/core.js +44 -2
- package/dist/agent/core.js.map +1 -1
- package/dist/agent/mcp-manager.d.ts +44 -0
- package/dist/agent/mcp-manager.d.ts.map +1 -0
- package/dist/agent/mcp-manager.js +127 -0
- package/dist/agent/mcp-manager.js.map +1 -0
- package/dist/agent/session.d.ts +44 -0
- package/dist/agent/session.d.ts.map +1 -0
- package/dist/agent/session.js +129 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/tool-descriptions.d.ts.map +1 -1
- package/dist/agent/tool-descriptions.js +15 -0
- package/dist/agent/tool-descriptions.js.map +1 -1
- package/dist/cli/init.js +60 -8
- package/dist/cli/init.js.map +1 -1
- package/dist/config/schema.d.ts +9 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +7 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/store.d.ts.map +1 -1
- package/dist/config/store.js +15 -3
- package/dist/config/store.js.map +1 -1
- package/dist/tools/google-auth.d.ts +34 -0
- package/dist/tools/google-auth.d.ts.map +1 -0
- package/dist/tools/google-auth.js +123 -0
- package/dist/tools/google-auth.js.map +1 -0
- package/dist/tools/google-calendar.d.ts +68 -0
- package/dist/tools/google-calendar.d.ts.map +1 -0
- package/dist/tools/google-calendar.js +124 -0
- package/dist/tools/google-calendar.js.map +1 -0
- package/dist/tools/google-drive.d.ts +43 -0
- package/dist/tools/google-drive.d.ts.map +1 -0
- package/dist/tools/google-drive.js +146 -0
- package/dist/tools/google-drive.js.map +1 -0
- package/dist/tools/mcp-registry.d.ts +38 -0
- package/dist/tools/mcp-registry.d.ts.map +1 -0
- package/dist/tools/mcp-registry.js +146 -0
- package/dist/tools/mcp-registry.js.map +1 -0
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Woojin Ahn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="design/logo_dark.svg" />
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="design/logo_light.svg" />
|
|
5
|
+
<img src="design/logo_light.svg" alt="Pilot-AI Logo" width="360" />
|
|
6
|
+
</picture>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>Personal AI agent that controls your macOS via Slack or Telegram</strong>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://www.npmjs.com/package/pilot-ai"><img src="https://img.shields.io/npm/v/pilot-ai.svg" alt="npm version" /></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/pilot-ai"><img src="https://img.shields.io/npm/dm/pilot-ai.svg" alt="npm downloads" /></a>
|
|
16
|
+
<img src="https://img.shields.io/badge/platform-macOS-blue.svg" alt="macOS" />
|
|
17
|
+
<img src="https://img.shields.io/badge/node-%3E%3D18-green.svg" alt="Node.js" />
|
|
18
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License" /></a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
Pilot-AI is a local AI agent that lives on your Mac. Send it natural-language commands from **Slack** or **Telegram**, and it autonomously controls your browser, files, shell, GitHub, Notion, and more — powered by [Claude Code](https://code.claude.com/) CLI.
|
|
24
|
+
|
|
25
|
+
## How it works
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
┌──────────────────┐ ┌─────────────────┐ ┌──────────────────────┐
|
|
29
|
+
│ Slack / Telegram │────▶│ Pilot-AI Agent │────▶│ Claude Code CLI │
|
|
30
|
+
│ (your phone/PC) │◀────│ (local daemon) │◀────│ (agentic reasoning) │
|
|
31
|
+
└──────────────────┘ └────────┬────────┘ └──────────────────────┘
|
|
32
|
+
│
|
|
33
|
+
┌─────────────┼─────────────┐
|
|
34
|
+
▼ ▼ ▼
|
|
35
|
+
🌐 Browser 📁 Files 🔧 Shell
|
|
36
|
+
(Playwright) (Read/Write) (Bash/Git/gh)
|
|
37
|
+
▼ ▼ ▼
|
|
38
|
+
📝 Notion 🔗 GitHub 📋 Linear
|
|
39
|
+
(API) (CLI) (API)
|
|
40
|
+
▼ ▼ ▼
|
|
41
|
+
📧 Gmail 📅 Calendar 📁 Google Drive
|
|
42
|
+
(OAuth2) (OAuth2) (OAuth2)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- **Runs locally** — your data never leaves your machine
|
|
46
|
+
- **Always on** — managed by macOS launchd, auto-restarts on crash
|
|
47
|
+
- **Agentic** — doesn't just answer, it investigates, acts, and follows through
|
|
48
|
+
- **Secure** — user allowlist, dangerous action approval, macOS Keychain for secrets
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Messenger integration** — Slack (Socket Mode) or Telegram (Long Polling), no server needed
|
|
53
|
+
- **Browser automation** — navigate, click, screenshot, fill forms via Playwright
|
|
54
|
+
- **File & shell access** — read, write, search files and run shell commands
|
|
55
|
+
- **GitHub integration** — releases, PRs, issues via `gh` CLI
|
|
56
|
+
- **Notion integration** — search, create, update pages and databases
|
|
57
|
+
- **Google integration** — Gmail, Google Calendar, and Google Drive via OAuth2
|
|
58
|
+
- **MCP auto-discovery** — agent detects needed MCP servers and proposes installation with one-click approval
|
|
59
|
+
- **Coding agent** — writes code, runs builds, executes tests, and iterates until the task is done
|
|
60
|
+
- **Session continuity** — messages in the same thread share a Claude session with full conversation context
|
|
61
|
+
- **Scheduled tasks** — cron-like jobs with natural language scheduling
|
|
62
|
+
- **Skills system** — teach the agent reusable procedures
|
|
63
|
+
- **Project awareness** — resolves projects, remembers context per project
|
|
64
|
+
- **Live status updates** — see what the agent is doing in real-time (🔍 Searching code... ⚡ Running command...)
|
|
65
|
+
- **Credential management** — agent can request and store API keys via chat
|
|
66
|
+
- **Safety controls** — dangerous actions require explicit approval via messenger buttons
|
|
67
|
+
|
|
68
|
+
## Prerequisites
|
|
69
|
+
|
|
70
|
+
- **macOS** (launchd is macOS-only)
|
|
71
|
+
- **Node.js** >= 18
|
|
72
|
+
- **Claude Code CLI** — install and authenticate:
|
|
73
|
+
```bash
|
|
74
|
+
npm install -g @anthropic-ai/claude-code
|
|
75
|
+
claude # login with your Claude Pro/Max account
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Quick Start
|
|
79
|
+
|
|
80
|
+
### 1. Install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install -g pilot-ai
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Setup
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pilot-ai init
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The interactive wizard guides you through:
|
|
93
|
+
|
|
94
|
+
1. **Claude connection** — detects CLI auth or configures API key
|
|
95
|
+
2. **Messenger** — choose Slack or Telegram, enter tokens
|
|
96
|
+
3. **Integrations** — optionally connect Google (Gmail, Calendar, Drive), Notion, Obsidian, Figma, Linear
|
|
97
|
+
4. **Browser** — installs Playwright Chromium
|
|
98
|
+
5. **Permissions** — requests macOS permissions (Accessibility, Automation, etc.)
|
|
99
|
+
|
|
100
|
+
### 3. Start
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pilot-ai start
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
That's it. Open Slack or Telegram and start chatting with your agent.
|
|
107
|
+
|
|
108
|
+
### Follow logs in real-time
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pilot-ai start -f
|
|
112
|
+
# or
|
|
113
|
+
pilot-ai logs -f
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Usage Examples
|
|
117
|
+
|
|
118
|
+
Just message your agent in Slack or Telegram:
|
|
119
|
+
|
|
120
|
+
| Command | What happens |
|
|
121
|
+
|---------|-------------|
|
|
122
|
+
| `What projects are in ~/Github?` | Lists directories, shows project names |
|
|
123
|
+
| `Show me recent releases for fridgify` | Finds the repo, runs `gh release list` |
|
|
124
|
+
| `Create today's meeting notes in Notion` | Creates a new Notion page with meeting notes |
|
|
125
|
+
| `Open browser and show top 5 from Hacker News` | Opens Playwright, scrapes HN, reports results |
|
|
126
|
+
| `Every day at 9am, notify me of GitHub PR reviews` | Creates a scheduled cron job |
|
|
127
|
+
| `Check my Google Calendar for today's schedule` | Reads Google Calendar events and summarizes |
|
|
128
|
+
| `Send a draft email to john@example.com` | Composes a Gmail draft with the given content |
|
|
129
|
+
| `List files in my Google Drive "Projects" folder` | Browses Google Drive and lists folder contents |
|
|
130
|
+
|
|
131
|
+
### Coding Sessions
|
|
132
|
+
|
|
133
|
+
The agent can write, build, test, and iterate on code — just like Claude Code. Messages in the same thread maintain full conversation context:
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
You: "Add a /health endpoint to the API server in fridgify"
|
|
137
|
+
Agent: ✏️ Editing file... ⚡ Running: npm run build... ✅ Done!
|
|
138
|
+
Added GET /health endpoint returning { status: "ok", uptime: ... }
|
|
139
|
+
Build passes, tests pass.
|
|
140
|
+
|
|
141
|
+
You: "Also add a test for it" ← same thread, agent remembers context
|
|
142
|
+
Agent: ✏️ Writing test... ⚡ Running: npm test...
|
|
143
|
+
Added test in tests/api/health.test.ts — 3 assertions, all pass.
|
|
144
|
+
|
|
145
|
+
You: "Commit and push"
|
|
146
|
+
Agent: 📂 Checking git... ⚡ Running: git commit...
|
|
147
|
+
Committed: "feat: add /health endpoint" and pushed to origin/main.
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Each Slack/Telegram thread maps to a persistent Claude session. The agent retains full context across messages — no need to repeat yourself.
|
|
151
|
+
|
|
152
|
+
## CLI Reference
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pilot-ai init # Interactive setup wizard
|
|
156
|
+
pilot-ai start [-f] # Start agent daemon (-f to follow logs)
|
|
157
|
+
pilot-ai stop # Stop agent daemon
|
|
158
|
+
pilot-ai status # Check if agent is running
|
|
159
|
+
pilot-ai logs [-f] # View agent logs
|
|
160
|
+
pilot-ai adduser <platform> <userId> # Authorize a user
|
|
161
|
+
pilot-ai removeuser <platform> <userId> # Remove a user
|
|
162
|
+
pilot-ai listusers # List authorized users
|
|
163
|
+
pilot-ai project add <name> <path> # Register a project
|
|
164
|
+
pilot-ai project list # List projects
|
|
165
|
+
pilot-ai project remove <name> # Remove a project
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Slack App Setup
|
|
169
|
+
|
|
170
|
+
1. Create a new app at [api.slack.com/apps](https://api.slack.com/apps)
|
|
171
|
+
2. **Socket Mode** — Enable
|
|
172
|
+
3. **Event Subscriptions** — Subscribe to: `message.im`, `app_mention`
|
|
173
|
+
4. **OAuth Scopes** — `chat:write`, `reactions:write`, `im:history`, `im:read`, `im:write`, `app_mentions:read`, `channels:history`
|
|
174
|
+
5. **App Home** — Turn on Messages Tab
|
|
175
|
+
6. Install to workspace, then use tokens in `pilot-ai init`
|
|
176
|
+
|
|
177
|
+
## Telegram Bot Setup
|
|
178
|
+
|
|
179
|
+
1. Message [@BotFather](https://t.me/BotFather) → `/newbot`
|
|
180
|
+
2. Copy the bot token
|
|
181
|
+
3. Use it in `pilot-ai init`
|
|
182
|
+
|
|
183
|
+
## Google Integration Setup
|
|
184
|
+
|
|
185
|
+
Pilot-AI supports **Gmail**, **Google Calendar**, and **Google Drive** via Google OAuth2.
|
|
186
|
+
|
|
187
|
+
### 1. Create a Google Cloud Project
|
|
188
|
+
|
|
189
|
+
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
190
|
+
2. Create a new project (or select an existing one)
|
|
191
|
+
3. Navigate to **APIs & Services** > **Library**
|
|
192
|
+
|
|
193
|
+
### 2. Enable APIs
|
|
194
|
+
|
|
195
|
+
Enable the following APIs for your project:
|
|
196
|
+
|
|
197
|
+
- **Gmail API** — for reading/sending emails
|
|
198
|
+
- **Google Calendar API** — for viewing/creating calendar events
|
|
199
|
+
- **Google Drive API** — for browsing/reading/creating files
|
|
200
|
+
|
|
201
|
+
### 3. Create OAuth 2.0 Credentials
|
|
202
|
+
|
|
203
|
+
1. Go to **APIs & Services** > **Credentials**
|
|
204
|
+
2. Click **Create Credentials** > **OAuth client ID**
|
|
205
|
+
3. If prompted, configure the **OAuth consent screen**:
|
|
206
|
+
- User Type: **External** (or Internal for Workspace)
|
|
207
|
+
- Add your email as a test user
|
|
208
|
+
4. Application type: **Desktop app**
|
|
209
|
+
5. Copy the **Client ID** and **Client Secret**
|
|
210
|
+
|
|
211
|
+
### 4. Configure in Pilot-AI
|
|
212
|
+
|
|
213
|
+
Run `pilot-ai init` and select **Yes** when asked about Google integration. Enter your Client ID and Client Secret, and choose which services to enable.
|
|
214
|
+
|
|
215
|
+
### 5. Authorize on First Use
|
|
216
|
+
|
|
217
|
+
When you first ask the agent to access Gmail, Calendar, or Drive, it will:
|
|
218
|
+
1. Send you an OAuth authorization URL via Slack/Telegram
|
|
219
|
+
2. You open the URL in a browser and grant permissions
|
|
220
|
+
3. Copy the authorization code back to the agent
|
|
221
|
+
4. The agent stores the tokens securely and proceeds with the task
|
|
222
|
+
|
|
223
|
+
After initial authorization, tokens refresh automatically — no further action needed.
|
|
224
|
+
|
|
225
|
+
### Supported Commands
|
|
226
|
+
|
|
227
|
+
| Service | Example commands |
|
|
228
|
+
|---------|-----------------|
|
|
229
|
+
| **Gmail** | `Check my recent emails`, `Send a draft to john@example.com`, `Search emails about "invoice"` |
|
|
230
|
+
| **Google Calendar** | `What's on my calendar today?`, `Schedule a meeting tomorrow at 2pm`, `Find free time this week` |
|
|
231
|
+
| **Google Drive** | `List files in my Drive`, `Search for "budget" in Drive`, `Read the contents of "Meeting Notes"` |
|
|
232
|
+
|
|
233
|
+
## MCP Server Auto-Discovery
|
|
234
|
+
|
|
235
|
+
Pilot-AI includes a built-in registry of 13+ MCP (Model Context Protocol) servers. Instead of manually configuring each integration, the agent **automatically detects** when a task needs an MCP server and proposes installation.
|
|
236
|
+
|
|
237
|
+
### How it works
|
|
238
|
+
|
|
239
|
+
1. You ask the agent to do something (e.g., "Check my Sentry errors")
|
|
240
|
+
2. The agent detects that the Sentry MCP server would help
|
|
241
|
+
3. It sends you an approval message via Slack/Telegram:
|
|
242
|
+
> 🔌 **MCP Server: Sentry** — View and manage Sentry error tracking issues
|
|
243
|
+
> Package: `@modelcontextprotocol/server-sentry`
|
|
244
|
+
> Required: SENTRY_AUTH_TOKEN
|
|
245
|
+
4. You approve and provide the required credentials
|
|
246
|
+
5. The server is installed and immediately available
|
|
247
|
+
|
|
248
|
+
### Built-in Registry
|
|
249
|
+
|
|
250
|
+
| Category | Servers |
|
|
251
|
+
|----------|---------|
|
|
252
|
+
| **Design** | Figma |
|
|
253
|
+
| **Development** | GitHub, Sentry, Puppeteer, Filesystem |
|
|
254
|
+
| **Productivity** | Notion, Google Drive, Memory, Brave Search |
|
|
255
|
+
| **Communication** | Slack |
|
|
256
|
+
| **Data** | PostgreSQL, SQLite |
|
|
257
|
+
|
|
258
|
+
You can also manually manage MCP servers by telling the agent: `List MCP servers`, `Install the GitHub MCP server`, or `Remove the Slack MCP server`.
|
|
259
|
+
|
|
260
|
+
## Architecture
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
src/
|
|
264
|
+
├── index.ts # CLI entry point (commander.js)
|
|
265
|
+
├── cli/ # CLI subcommands (init, start, stop, status, logs, project, user)
|
|
266
|
+
├── agent/
|
|
267
|
+
│ ├── core.ts # Main agent loop: message → auth → Claude → response
|
|
268
|
+
│ ├── claude.ts # Claude Code CLI subprocess with streaming JSONL parsing
|
|
269
|
+
│ ├── heartbeat.ts # Cron scheduler + approval flow
|
|
270
|
+
│ ├── skills.ts # Teachable skill engine
|
|
271
|
+
│ ├── memory.ts # Per-project memory context
|
|
272
|
+
│ └── safety.ts # Dangerous action approval manager
|
|
273
|
+
├── messenger/
|
|
274
|
+
│ ├── adapter.ts # MessengerAdapter interface
|
|
275
|
+
│ ├── slack.ts # Slack Bolt SDK (Socket Mode)
|
|
276
|
+
│ └── telegram.ts # Telegraf (Long Polling)
|
|
277
|
+
├── tools/ # Tool wrappers (browser, notion, github, filesystem, shell, etc.)
|
|
278
|
+
├── security/
|
|
279
|
+
│ ├── auth.ts # User allowlist check
|
|
280
|
+
│ ├── permissions.ts # macOS TCC permission management + auto-approver
|
|
281
|
+
│ ├── audit.ts # Audit logging
|
|
282
|
+
│ └── sandbox.ts # Filesystem sandbox
|
|
283
|
+
└── config/
|
|
284
|
+
├── schema.ts # Config schema (zod)
|
|
285
|
+
├── store.ts # ~/.pilot/ config + credentials store
|
|
286
|
+
└── keychain.ts # macOS Keychain integration
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## How It Stays Secure
|
|
290
|
+
|
|
291
|
+
- **User allowlist** — only authorized Slack/Telegram user IDs can interact
|
|
292
|
+
- **Approval flow** — dangerous actions (file deletion, shell commands, etc.) prompt for confirmation via messenger buttons
|
|
293
|
+
- **macOS Keychain** — all tokens and API keys are stored encrypted
|
|
294
|
+
- **Filesystem sandbox** — configurable allowed/blocked paths
|
|
295
|
+
- **Audit log** — every command and result is logged to `~/.pilot/logs/audit.jsonl`
|
|
296
|
+
- **Prompt injection guard** — basic detection for prompt injection attempts
|
|
297
|
+
|
|
298
|
+
## Configuration
|
|
299
|
+
|
|
300
|
+
All config lives in `~/.pilot/`:
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
~/.pilot/
|
|
304
|
+
├── config.json # Main configuration
|
|
305
|
+
├── credentials/ # Service API keys (chmod 700)
|
|
306
|
+
├── memory/ # Agent memory per project
|
|
307
|
+
├── skills/ # Registered skills
|
|
308
|
+
└── logs/ # Agent and audit logs
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Development
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
git clone https://github.com/ahn283/pilot-ai.git
|
|
315
|
+
cd pilot-ai
|
|
316
|
+
npm install
|
|
317
|
+
npm run build # Compile TypeScript
|
|
318
|
+
npm run dev # Watch mode
|
|
319
|
+
npm test # Run tests (vitest)
|
|
320
|
+
npm run lint # ESLint
|
|
321
|
+
npm run format # Prettier
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
[MIT](LICENSE)
|
package/dist/agent/claude.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface ClaudeCliOptions {
|
|
|
6
6
|
mcpConfigPath?: string;
|
|
7
7
|
timeoutMs?: number;
|
|
8
8
|
onToolUse?: (status: string) => void;
|
|
9
|
+
/** Start a new session with this UUID */
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
/** Resume an existing session by its UUID */
|
|
12
|
+
resumeSessionId?: string;
|
|
9
13
|
}
|
|
10
14
|
export interface ClaudeCliResult {
|
|
11
15
|
result: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/agent/claude.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/agent/claude.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAID,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,UAYjC,CAAC;AAEF;;GAEG;AACH,wBAAsB,cAAc,CAAC,MAAM,GAAE,MAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAOhF;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,GAAE,MAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAapF;AA8BD;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAoGzF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA4B5D;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlB"}
|
package/dist/agent/claude.js
CHANGED
|
@@ -85,8 +85,18 @@ function describeToolUse(toolName, input) {
|
|
|
85
85
|
* Runs `claude -p --output-format json` and parses the JSON response.
|
|
86
86
|
*/
|
|
87
87
|
export async function invokeClaudeCli(options) {
|
|
88
|
-
const { prompt, systemPrompt, cwd, allowedTools, mcpConfigPath, timeoutMs = DEFAULT_TIMEOUT_MS, onToolUse } = options;
|
|
89
|
-
const args = [
|
|
88
|
+
const { prompt, systemPrompt, cwd, allowedTools, mcpConfigPath, timeoutMs = DEFAULT_TIMEOUT_MS, onToolUse, sessionId, resumeSessionId } = options;
|
|
89
|
+
const args = [];
|
|
90
|
+
// Session management: --resume takes precedence (continuing existing session)
|
|
91
|
+
if (resumeSessionId) {
|
|
92
|
+
args.push('-p', '--resume', resumeSessionId, '--output-format', 'json');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
args.push('-p', '--output-format', 'json');
|
|
96
|
+
if (sessionId) {
|
|
97
|
+
args.push('--session-id', sessionId);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
90
100
|
if (cwd) {
|
|
91
101
|
args.push('--cwd', cwd);
|
|
92
102
|
}
|
package/dist/agent/claude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/agent/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/agent/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,SAAS,MAAM,mBAA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IAAI,MAAM,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAKrC;IACC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG,0BAA0B,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzF,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,KAAK;QACL,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;KAC9C,CAAC,CAAC;IAEH,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/agent/core.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class AgentCore {
|
|
|
12
12
|
private handleMessage;
|
|
13
13
|
/**
|
|
14
14
|
* Resolves project from message, builds memory context, and invokes Claude.
|
|
15
|
+
* Uses session continuity: messages in the same thread share a Claude session.
|
|
15
16
|
*/
|
|
16
17
|
private invokeClaudeWithContext;
|
|
17
18
|
}
|
package/dist/agent/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/agent/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,yBAAyB,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/agent/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,yBAAyB,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAqBvD,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW;IAkB5D,OAAO,CAAC,aAAa;IAOf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAMb,aAAa;IAmG3B;;;OAGG;YACW,uBAAuB;CAuGtC"}
|
package/dist/agent/core.js
CHANGED
|
@@ -10,6 +10,8 @@ import { analyzeProjectIfNew } from './project-analyzer.js';
|
|
|
10
10
|
import { buildSkillsContext } from './skills.js';
|
|
11
11
|
import { buildToolDescriptions } from './tool-descriptions.js';
|
|
12
12
|
import { getMcpConfigPathIfExists } from '../tools/figma-mcp.js';
|
|
13
|
+
import { buildMcpContext } from './mcp-manager.js';
|
|
14
|
+
import { getSession, createSession, touchSession, cleanupSessions } from './session.js';
|
|
13
15
|
import { detectPermissionError, PermissionWatcher } from '../security/permissions.js';
|
|
14
16
|
function log(message) {
|
|
15
17
|
console.log(`[${new Date().toISOString()}] ${message}`);
|
|
@@ -142,6 +144,7 @@ export class AgentCore {
|
|
|
142
144
|
}
|
|
143
145
|
/**
|
|
144
146
|
* Resolves project from message, builds memory context, and invokes Claude.
|
|
147
|
+
* Uses session continuity: messages in the same thread share a Claude session.
|
|
145
148
|
*/
|
|
146
149
|
async invokeClaudeWithContext(msg, onStatus) {
|
|
147
150
|
// Resolve project from message text
|
|
@@ -169,7 +172,25 @@ RULES:
|
|
|
169
172
|
4. USE THE RIGHT TOOL — For GitHub: use "gh" CLI. For files: use "ls", "cat", "find". For web info: use WebSearch. For Notion: use the Notion API. Think about what tool fits before defaulting to asking the user.
|
|
170
173
|
5. THINK STEP BY STEP — Before acting, plan your approach. "The user wants X. To find X, I need to check Y, which means I should run Z."
|
|
171
174
|
6. COMPLETE THE TASK — Do not stop halfway. If a command fails, try another approach. If you need more info, search for it. Only respond to the user when you have a concrete answer or have completed the action.
|
|
172
|
-
7. BE CONCISE — Report results directly. No filler, no "I'd be happy to help", no restating the question
|
|
175
|
+
7. BE CONCISE — Report results directly. No filler, no "I'd be happy to help", no restating the question.
|
|
176
|
+
8. CODING TASKS — When asked to write or modify code, follow this workflow: understand → implement → build → test → fix errors → report. You have full access to the filesystem and shell. Write code, run builds, execute tests, and iterate until the task is done. Never say "I can't write code" — you absolutely can.
|
|
177
|
+
|
|
178
|
+
CREDENTIAL MANAGEMENT:
|
|
179
|
+
You have a credential store at ~/.pilot/credentials/. Use it to store and retrieve API keys, tokens, and service account files.
|
|
180
|
+
- ALWAYS check ~/.pilot/credentials/ first before saying you can't access a service.
|
|
181
|
+
- If a credential exists (e.g. ~/.pilot/credentials/google-play.json), use it directly.
|
|
182
|
+
- If a credential is missing and you need it, ask the user to provide it. Explain exactly what is needed (e.g. "Google Play Developer API 서비스 계정 JSON 키가 필요합니다").
|
|
183
|
+
- When the user provides a credential, save it: write to ~/.pilot/credentials/<service-name> with chmod 600.
|
|
184
|
+
- For JSON keys: save as .json files. For simple tokens: save as plain text files.
|
|
185
|
+
- Common credential paths:
|
|
186
|
+
google-play.json, firebase.json, aws-credentials, vercel-token,
|
|
187
|
+
sentry-auth-token, app-store-connect.json, docker-hub-token
|
|
188
|
+
- After saving, immediately proceed with the task using the new credential. Do NOT just say "saved" and stop.
|
|
189
|
+
- NEVER say "I can't access that service" without first checking for credentials and offering to set them up.`);
|
|
190
|
+
// MCP server context (installed + available servers)
|
|
191
|
+
const mcpContext = await buildMcpContext();
|
|
192
|
+
if (mcpContext)
|
|
193
|
+
systemParts.push(mcpContext);
|
|
173
194
|
if (memoryContext)
|
|
174
195
|
systemParts.push(memoryContext);
|
|
175
196
|
if (skillsContext)
|
|
@@ -186,14 +207,35 @@ RULES:
|
|
|
186
207
|
apiKey: this.config.claude.apiKey,
|
|
187
208
|
});
|
|
188
209
|
}
|
|
210
|
+
// Session continuity: map messenger threads to Claude sessions
|
|
211
|
+
const threadId = msg.threadId ?? msg.channelId;
|
|
212
|
+
const existingSession = await getSession(msg.platform, msg.channelId, threadId);
|
|
213
|
+
let sessionId;
|
|
214
|
+
let resumeSessionId;
|
|
215
|
+
if (existingSession) {
|
|
216
|
+
// Resume existing session — Claude retains full conversation context
|
|
217
|
+
resumeSessionId = existingSession.sessionId;
|
|
218
|
+
await touchSession(msg.platform, msg.channelId, threadId);
|
|
219
|
+
log(`Resuming session ${resumeSessionId} (turn ${existingSession.turnCount + 1})`);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
// New session — create and store mapping
|
|
223
|
+
const session = await createSession(msg.platform, msg.channelId, threadId, projectPath);
|
|
224
|
+
sessionId = session.sessionId;
|
|
225
|
+
log(`New session ${sessionId}`);
|
|
226
|
+
}
|
|
227
|
+
// Periodically clean up expired sessions (non-blocking)
|
|
228
|
+
cleanupSessions().catch(() => { });
|
|
189
229
|
const mcpConfigPath = await getMcpConfigPathIfExists() ?? undefined;
|
|
190
230
|
const result = await invokeClaudeCli({
|
|
191
231
|
prompt: msg.text,
|
|
192
|
-
systemPrompt,
|
|
232
|
+
systemPrompt: resumeSessionId ? undefined : systemPrompt, // Only send system prompt on first turn
|
|
193
233
|
cwd: projectPath,
|
|
194
234
|
allowedTools: DEFAULT_ALLOWED_TOOLS,
|
|
195
235
|
mcpConfigPath,
|
|
196
236
|
onToolUse: (status) => onStatus?.(status),
|
|
237
|
+
sessionId,
|
|
238
|
+
resumeSessionId,
|
|
197
239
|
});
|
|
198
240
|
return result.result;
|
|
199
241
|
}
|
package/dist/agent/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/agent/core.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEtF,SAAS,GAAG,CAAC,OAAe;IAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,OAAO,SAAS;IACZ,SAAS,CAAmB;IAC5B,MAAM,CAAc;IACpB,eAAe,CAAkB;IACjC,iBAAiB,CAAoB;IAE7C,YAAY,SAA2B,EAAE,MAAmB;QAC1D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,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,EAAE,QAAQ,CAAC,CAAC;YAC1D,GAAG,CAAC,oBAAoB,eAAe,UAAU,eAAe,CAAC,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC;QACrF,CAAC;aAAM,CAAC;YACN,yCAAyC;YACzC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;YACxF,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;YAC9B,GAAG,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC;QAClC,CAAC;QAED,wDAAwD;QACxD,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAElC,MAAM,aAAa,GAAG,MAAM,wBAAwB,EAAE,IAAI,SAAS,CAAC;QACpE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;YACnC,MAAM,EAAE,GAAG,CAAC,IAAI;YAChB,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,EAAE,wCAAwC;YAClG,GAAG,EAAE,WAAW;YAChB,YAAY,EAAE,qBAAqB;YACnC,aAAa;YACb,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC;YACzC,SAAS;YACT,eAAe;SAChB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type McpServerEntry } from '../tools/mcp-registry.js';
|
|
2
|
+
export interface McpInstallRequest {
|
|
3
|
+
server: McpServerEntry;
|
|
4
|
+
envValues: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Checks which MCP servers are currently installed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getInstalledServers(): Promise<string[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Detects MCP servers that could help with the given user message
|
|
12
|
+
* but are not yet installed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectNeededServers(userMessage: string): Promise<McpServerEntry[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Installs and registers an MCP server.
|
|
17
|
+
* 1. Verifies the npm package can be resolved
|
|
18
|
+
* 2. Stores env vars in keychain
|
|
19
|
+
* 3. Adds to mcp-config.json
|
|
20
|
+
*/
|
|
21
|
+
export declare function installMcpServer(serverId: string, envValues: Record<string, string>): Promise<{
|
|
22
|
+
success: boolean;
|
|
23
|
+
error?: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Uninstalls an MCP server by removing it from config.
|
|
27
|
+
*/
|
|
28
|
+
export declare function uninstallMcpServer(serverId: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Lists all available MCP servers from the registry with install status.
|
|
31
|
+
*/
|
|
32
|
+
export declare function listAvailableServers(): Promise<Array<McpServerEntry & {
|
|
33
|
+
installed: boolean;
|
|
34
|
+
}>>;
|
|
35
|
+
/**
|
|
36
|
+
* Builds a user-friendly message describing an MCP server for approval.
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildApprovalMessage(server: McpServerEntry): string;
|
|
39
|
+
/**
|
|
40
|
+
* Builds the MCP context for the system prompt.
|
|
41
|
+
* Tells the agent about available and installed MCP servers.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildMcpContext(): Promise<string>;
|
|
44
|
+
//# sourceMappingURL=mcp-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-manager.d.ts","sourceRoot":"","sources":["../../src/agent/mcp-manager.ts"],"names":[],"mappings":"AAQA,OAAO,EAAuD,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAKpH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAG7D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAMxF;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAmC/C;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIxE;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAMpG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAgBnE;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAwBvD"}
|