felo-ai 0.2.18 → 0.2.19
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/felo-superAgent/README.md +354 -80
- package/felo-superAgent/SKILL.md +459 -63
- package/felo-superAgent/scripts/run_superagent.mjs +568 -0
- package/package.json +2 -3
package/felo-superAgent/SKILL.md
CHANGED
|
@@ -1,65 +1,102 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: felo-superAgent
|
|
3
|
-
description: "Felo SuperAgent API: AI conversation with real-time SSE streaming
|
|
3
|
+
description: "Felo SuperAgent API: AI conversation with real-time SSE streaming on a persistent LiveDoc canvas. Use when users want SuperAgent chat, continuous conversation, tweet writing, logo/branding design, or e-commerce product images. Explicit commands: /felo-superagent."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Felo SuperAgent Skill
|
|
7
7
|
|
|
8
|
+
## Constraints (MUST READ FIRST)
|
|
9
|
+
|
|
10
|
+
These rules are mandatory. Violating any of them will produce incorrect behavior.
|
|
11
|
+
|
|
12
|
+
1. **`--live-doc-id` is REQUIRED when creating a conversation.** Never call `run_superagent.mjs` without `--live-doc-id`. If you do not have one yet, obtain it first (see Step 2 below).
|
|
13
|
+
|
|
14
|
+
2. **One LiveDoc per session.** All conversations within a session MUST use the same `--live-doc-id`. Do NOT create a new LiveDoc unless the user explicitly asks to "open a new canvas" / "start a new LiveDoc" / "create a new workspace".
|
|
15
|
+
|
|
16
|
+
3. **Default behavior is follow-up, not new conversation.** After the first question, every subsequent user message is a follow-up. You MUST pass `--thread-id` from the previous response. Only omit `--thread-id` (to start a new thread on the same LiveDoc) when the user explicitly says "new topic" / "change subject" / "start over".
|
|
17
|
+
|
|
18
|
+
4. **Always persist state.** After every call, save the returned `thread_short_id` and `live_doc_short_id`. Use them in the next call. Losing these IDs breaks conversation continuity.
|
|
19
|
+
|
|
20
|
+
5. **Skill ID auto-detection.** When creating a new conversation (no `--thread-id`), detect user intent and set `--skill-id` accordingly:
|
|
21
|
+
|
|
22
|
+
| User intent | `--skill-id` value |
|
|
23
|
+
| ------------------------------------------------ | --------------------------- |
|
|
24
|
+
| Write/post/compose/draft a tweet | `twitter-writer` |
|
|
25
|
+
| Create a logo or brand design | `logo-and-branding` |
|
|
26
|
+
| Generate e-commerce / product images | `ecommerce-product-image` |
|
|
27
|
+
| All other conversations | Do NOT pass `--skill-id` |
|
|
28
|
+
|
|
29
|
+
`--skill-id` is only effective when creating a new conversation. It is ignored in follow-up mode (`--thread-id`).
|
|
30
|
+
|
|
31
|
+
6. **Never create a new LiveDoc casually.** Reuse the existing one. The only exception is an explicit user request for a new canvas/workspace.
|
|
32
|
+
|
|
8
33
|
## When to Use
|
|
9
34
|
|
|
10
|
-
Trigger this skill
|
|
35
|
+
Trigger this skill when users want:
|
|
36
|
+
|
|
37
|
+
- **SuperAgent conversation:** AI conversation with Felo SuperAgent, with real-time streaming output
|
|
38
|
+
- **Continuous conversation:** Multi-turn Q&A on a persistent LiveDoc canvas
|
|
39
|
+
- **Tweet writing:** Compose or post tweets (auto-selects `twitter-writer` skill)
|
|
40
|
+
- **Logo & branding:** Create logos or brand designs (auto-selects `logo-and-branding` skill)
|
|
41
|
+
- **E-commerce images:** Generate product images (auto-selects `ecommerce-product-image` skill)
|
|
42
|
+
- **Tool-augmented answers:** Responses that may include image generation, document creation, PPT generation, or Twitter/X search
|
|
43
|
+
- **Streaming responses:** Real-time answer generation with Server-Sent Events (SSE)
|
|
11
44
|
|
|
12
|
-
|
|
13
|
-
- **LiveDoc 关联**:每次会话对应一个 LiveDoc,可后续查看资源
|
|
14
|
-
- **连续对话**:在已有 LiveDoc 上继续提问(传入 `live_doc_short_id`)
|
|
15
|
-
- **多轮对话**:需要 thread_short_id / live_doc_short_id 以便后续查询会话详情
|
|
45
|
+
**Trigger words:**
|
|
16
46
|
|
|
17
|
-
|
|
47
|
+
- English: superagent, super agent, stream chat, streaming conversation, livedoc conversation, continuous chat, follow-up question, write a tweet, post a tweet, create a logo, brand design, product image, e-commerce image
|
|
48
|
+
- Simplified Chinese (pinyin): chao ji zhu shou, liu shi dui hua, lian xu dui hua, zhui wen, fa tui wen, xie tui wen, she ji logo, pin pai she ji, dian shang tu pian
|
|
49
|
+
- Traditional Chinese (pinyin): chao ji zhu shou, liu shi dui hua, lian xu dui hua, zhui wen, fa tui wen, xie tui wen, she ji logo, pin pai she ji, dian shang tu pian
|
|
50
|
+
- Japanese (romaji): suupaa eejento, sutoriimingu kaiwa, keizoku kaiwa, tsuiito wo kaku, rogo sakusei, shouhin gazou
|
|
18
51
|
|
|
19
|
-
-
|
|
20
|
-
- English: superagent, super agent, stream chat, livedoc, conversation
|
|
21
|
-
- **Explicit commands:** `/felo-superagent`, "use felo superagent", "felo superagent"
|
|
52
|
+
**Explicit commands:** `/felo-superagent`, "use felo superagent", "felo superagent"
|
|
22
53
|
|
|
23
54
|
**Do NOT use for:**
|
|
24
55
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
56
|
+
- Simple one-off Q&A or real-time information queries (prefer `felo-search`)
|
|
57
|
+
- Web page content fetching only (use `felo-web-fetch`)
|
|
58
|
+
- PPT/slide generation only (use `felo-slides`)
|
|
59
|
+
- LiveDoc knowledge base management only (use `felo-livedoc`)
|
|
60
|
+
- Twitter/X search only (use `felo-x-search`)
|
|
29
61
|
|
|
30
62
|
## Setup
|
|
31
63
|
|
|
32
|
-
### 1. Get API Key
|
|
64
|
+
### 1. Get Your API Key
|
|
33
65
|
|
|
34
66
|
1. Visit [felo.ai](https://felo.ai) and log in (or register)
|
|
35
|
-
2. Click your avatar
|
|
36
|
-
3.
|
|
67
|
+
2. Click your avatar in the top right corner → Settings
|
|
68
|
+
3. Navigate to the "API Keys" tab
|
|
69
|
+
4. Click "Create New Key" to generate a new API Key
|
|
70
|
+
5. Copy and save your API Key securely
|
|
37
71
|
|
|
38
|
-
### 2. Configure
|
|
72
|
+
### 2. Configure API Key
|
|
39
73
|
|
|
40
74
|
Set the `FELO_API_KEY` environment variable:
|
|
41
75
|
|
|
42
76
|
**Linux/macOS:**
|
|
43
|
-
|
|
44
77
|
```bash
|
|
45
78
|
export FELO_API_KEY="your-api-key-here"
|
|
46
79
|
```
|
|
47
80
|
|
|
48
81
|
**Windows (PowerShell):**
|
|
49
|
-
|
|
50
82
|
```powershell
|
|
51
83
|
$env:FELO_API_KEY="your-api-key-here"
|
|
52
84
|
```
|
|
53
85
|
|
|
54
86
|
**Windows (CMD):**
|
|
55
|
-
|
|
56
87
|
```cmd
|
|
57
88
|
set FELO_API_KEY=your-api-key-here
|
|
58
89
|
```
|
|
59
90
|
|
|
91
|
+
For permanent configuration, add it to your shell profile (~/.bashrc, ~/.zshrc) or system environment variables.
|
|
92
|
+
|
|
93
|
+
### 3. Dependency: felo-livedoc
|
|
94
|
+
|
|
95
|
+
This skill depends on the `felo-livedoc` skill to obtain and create LiveDocs. Ensure `felo-livedoc/scripts/run_livedoc.mjs` is available at the same level as `felo-superAgent/`.
|
|
96
|
+
|
|
60
97
|
## How to Execute
|
|
61
98
|
|
|
62
|
-
|
|
99
|
+
When this skill is triggered, follow these steps strictly in order. Execute all commands using the Bash tool.
|
|
63
100
|
|
|
64
101
|
### Step 1: Check API Key
|
|
65
102
|
|
|
@@ -72,91 +109,450 @@ fi
|
|
|
72
109
|
|
|
73
110
|
If not set, stop and show the user the setup instructions above.
|
|
74
111
|
|
|
75
|
-
### Step 2:
|
|
112
|
+
### Step 2: Obtain `live_doc_short_id`
|
|
76
113
|
|
|
77
|
-
|
|
114
|
+
This step ensures you always have a valid `--live-doc-id` before creating any conversation.
|
|
115
|
+
|
|
116
|
+
**2a. If you already have a `live_doc_short_id` from a previous call in this session:**
|
|
117
|
+
Skip to Step 3. Reuse the same ID.
|
|
118
|
+
|
|
119
|
+
**2b. If this is the first call in the session — fetch the LiveDoc list:**
|
|
78
120
|
|
|
79
121
|
```bash
|
|
80
|
-
node felo-
|
|
81
|
-
--query "USER_QUERY_HERE" \
|
|
82
|
-
--timeout 60
|
|
122
|
+
node felo-livedoc/scripts/run_livedoc.mjs list --json
|
|
83
123
|
```
|
|
84
124
|
|
|
85
|
-
|
|
125
|
+
Parse the JSON output. The response contains `data.items` — an array of LiveDoc objects sorted by modification time. Pick the first item's `short_id` as your `live_doc_short_id`.
|
|
126
|
+
|
|
127
|
+
Example response:
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"status": "ok",
|
|
131
|
+
"data": {
|
|
132
|
+
"total": 3,
|
|
133
|
+
"items": [
|
|
134
|
+
{ "short_id": "QPetunwpGnkKuZHStP7gwt", "name": "My Workspace", "modified_at": "..." },
|
|
135
|
+
...
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Use: `live_doc_short_id = items[0].short_id`
|
|
142
|
+
|
|
143
|
+
**2c. If the list is empty (no LiveDocs exist) — create one:**
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
node felo-livedoc/scripts/run_livedoc.mjs create --name "SuperAgent Workspace" --json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Parse the JSON output and extract `data.short_id` as your `live_doc_short_id`.
|
|
150
|
+
|
|
151
|
+
Example response:
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"status": "ok",
|
|
155
|
+
"data": {
|
|
156
|
+
"short_id": "NewDocId123abc",
|
|
157
|
+
"name": "SuperAgent Workspace",
|
|
158
|
+
...
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**2d. If the user explicitly requests a new canvas/workspace:**
|
|
164
|
+
|
|
165
|
+
Create a new LiveDoc (same as 2c), then use the new ID for all subsequent calls. Discard the old `live_doc_short_id`.
|
|
166
|
+
|
|
167
|
+
### Step 3: Determine Conversation Mode
|
|
168
|
+
|
|
169
|
+
Decide whether this is a **new conversation** or a **follow-up**:
|
|
170
|
+
|
|
171
|
+
| Condition | Mode | What to pass |
|
|
172
|
+
| ------------------------------------------------------------ | ---------------- | ------------------------------------------- |
|
|
173
|
+
| First question in session (no `thread_short_id` yet) | New conversation | `--live-doc-id` only |
|
|
174
|
+
| User asks a follow-up / continues the topic (DEFAULT) | Follow-up | `--thread-id` AND `--live-doc-id` |
|
|
175
|
+
| User explicitly says "new topic" / "change subject" | New conversation | `--live-doc-id` only (same LiveDoc) |
|
|
176
|
+
| User explicitly says "new canvas" / "new LiveDoc" | New conversation | New `--live-doc-id` from Step 2d |
|
|
86
177
|
|
|
87
|
-
|
|
88
|
-
- **Reuse LiveDoc (连续对话):** `--live-doc-id "PvyKouzJirXjFdst4uKRK3"`
|
|
89
|
-
- **JSON output:** `--json` (includes thread_short_id, live_doc_short_id, full answer)
|
|
90
|
-
- **Verbose:** `--verbose` (logs stream connection to stderr)
|
|
178
|
+
**IMPORTANT:** The default for any user message after the first one is ALWAYS follow-up. Only treat it as a new conversation if the user explicitly requests it.
|
|
91
179
|
|
|
92
|
-
|
|
180
|
+
### Step 4: Detect Skill ID (New Conversations Only)
|
|
93
181
|
|
|
182
|
+
If this is a new conversation (no `--thread-id`), check the user's intent:
|
|
183
|
+
|
|
184
|
+
- If the user wants to **write/post/compose/draft a tweet** → add `--skill-id twitter-writer`
|
|
185
|
+
- If the user wants to **create a logo or brand design** → add `--skill-id logo-and-branding`
|
|
186
|
+
- If the user wants to **generate e-commerce/product images** → add `--skill-id ecommerce-product-image`
|
|
187
|
+
- Otherwise → do NOT pass `--skill-id`
|
|
188
|
+
|
|
189
|
+
If this is a follow-up (`--thread-id` is set), skip this step entirely. `--skill-id` is ignored in follow-up mode.
|
|
190
|
+
|
|
191
|
+
### Step 5: Run the Script
|
|
192
|
+
|
|
193
|
+
Construct and execute the command. Always use `--json` to capture metadata for state management.
|
|
194
|
+
|
|
195
|
+
**New conversation (first question):**
|
|
94
196
|
```bash
|
|
95
197
|
node felo-superAgent/scripts/run_superagent.mjs \
|
|
96
|
-
--query "
|
|
198
|
+
--query "USER_QUERY_HERE" \
|
|
199
|
+
--live-doc-id "LIVE_DOC_SHORT_ID" \
|
|
97
200
|
--accept-language en \
|
|
98
|
-
--timeout
|
|
201
|
+
--timeout 60 \
|
|
99
202
|
--json
|
|
100
203
|
```
|
|
101
204
|
|
|
102
|
-
|
|
205
|
+
**New conversation with skill ID (e.g., tweet writing):**
|
|
206
|
+
```bash
|
|
207
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
208
|
+
--query "Write a tweet about the latest AI trends" \
|
|
209
|
+
--live-doc-id "LIVE_DOC_SHORT_ID" \
|
|
210
|
+
--skill-id twitter-writer \
|
|
211
|
+
--accept-language en \
|
|
212
|
+
--timeout 60 \
|
|
213
|
+
--json
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Follow-up question (DEFAULT for 2nd+ messages):**
|
|
217
|
+
```bash
|
|
218
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
219
|
+
--query "USER_FOLLOW_UP_QUERY" \
|
|
220
|
+
--thread-id "THREAD_SHORT_ID_FROM_PREVIOUS" \
|
|
221
|
+
--live-doc-id "LIVE_DOC_SHORT_ID" \
|
|
222
|
+
--timeout 60 \
|
|
223
|
+
--json
|
|
224
|
+
```
|
|
103
225
|
|
|
104
|
-
|
|
105
|
-
|
|
226
|
+
### Step 6: Save State and Present Result
|
|
227
|
+
|
|
228
|
+
After every call, parse the JSON output and:
|
|
229
|
+
|
|
230
|
+
1. **Save** `thread_short_id` and `live_doc_short_id` from the response — you MUST use these in the next call.
|
|
231
|
+
2. **Present** the answer to the user.
|
|
232
|
+
|
|
233
|
+
JSON response structure:
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"status": "ok",
|
|
237
|
+
"data": {
|
|
238
|
+
"answer": "complete answer text",
|
|
239
|
+
"thread_short_id": "CmYpuGwBgCnrUdDx5ZtmxA",
|
|
240
|
+
"live_doc_short_id": "QPetunwpGnkKuZHStP7gwt",
|
|
241
|
+
"live_doc_url": "https://felo.ai/livedoc/QPetunwpGnkKuZHStP7gwt",
|
|
242
|
+
"image_urls": [{"url": "...", "title": "..."}],
|
|
243
|
+
"discoveries": [{"title": "Research Report"}],
|
|
244
|
+
"documents": [{"title": "Generated Document"}],
|
|
245
|
+
"ppts": [{"title": "Presentation"}],
|
|
246
|
+
"htmls": [{"title": "HTML Page"}],
|
|
247
|
+
"search_x": [{"tweets": [...]}]
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
106
251
|
|
|
107
|
-
Present to the user
|
|
252
|
+
Present to the user:
|
|
108
253
|
|
|
109
254
|
```markdown
|
|
110
255
|
## SuperAgent Answer
|
|
111
256
|
|
|
112
|
-
[Full answer text from
|
|
257
|
+
[Full answer text from the "answer" field]
|
|
113
258
|
|
|
114
|
-
##
|
|
259
|
+
## Generated Resources (if any)
|
|
115
260
|
|
|
116
|
-
-
|
|
117
|
-
-
|
|
261
|
+
- Images: [list image titles and URLs]
|
|
262
|
+
- Documents: [list document titles]
|
|
263
|
+
- Presentations: [list PPT titles]
|
|
264
|
+
- Twitter Results: [summarize tweets]
|
|
265
|
+
|
|
266
|
+
## Session Info
|
|
267
|
+
|
|
268
|
+
- LiveDoc: [live_doc_url]
|
|
118
269
|
```
|
|
119
270
|
|
|
120
|
-
|
|
271
|
+
Do NOT show `thread_short_id` or `live_doc_short_id` to the user unless they ask for it. These are internal state for the skill to manage.
|
|
272
|
+
|
|
273
|
+
## Complete Workflow Examples
|
|
274
|
+
|
|
275
|
+
### Example A: Multi-turn Conversation (Most Common)
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
User: "What is quantum computing?"
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Step 2b:** Fetch LiveDoc list → get `live_doc_short_id = "QPetunwpGnkKuZHStP7gwt"`
|
|
282
|
+
**Step 3:** First question → New conversation
|
|
283
|
+
**Step 4:** No special skill → no `--skill-id`
|
|
284
|
+
**Step 5:**
|
|
285
|
+
```bash
|
|
286
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
287
|
+
--query "What is quantum computing?" \
|
|
288
|
+
--live-doc-id "QPetunwpGnkKuZHStP7gwt" \
|
|
289
|
+
--accept-language en --timeout 60 --json
|
|
290
|
+
```
|
|
291
|
+
**Step 6:** Save `thread_short_id = "CmYpuGwBgCnrUdDx5ZtmxA"`, `live_doc_short_id = "QPetunwpGnkKuZHStP7gwt"`
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
User: "What are its practical applications?"
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Step 2a:** Already have `live_doc_short_id` → skip
|
|
298
|
+
**Step 3:** Follow-up (default) → use saved `thread_short_id`
|
|
299
|
+
**Step 5:**
|
|
300
|
+
```bash
|
|
301
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
302
|
+
--query "What are its practical applications?" \
|
|
303
|
+
--thread-id "CmYpuGwBgCnrUdDx5ZtmxA" \
|
|
304
|
+
--live-doc-id "QPetunwpGnkKuZHStP7gwt" \
|
|
305
|
+
--timeout 60 --json
|
|
306
|
+
```
|
|
307
|
+
**Step 6:** Save updated `thread_short_id` (may be the same), keep `live_doc_short_id`
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
User: "Tell me more about quantum error correction"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Step 3:** Still follow-up (same topic) → use saved `thread_short_id`
|
|
314
|
+
**Step 5:** Same pattern as above with new query
|
|
315
|
+
|
|
316
|
+
### Example B: Tweet Writing
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
User: "Help me write a tweet about AI trends"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Step 2a:** Already have `live_doc_short_id` → reuse
|
|
323
|
+
**Step 3:** New conversation (different intent from previous thread)
|
|
324
|
+
**Step 4:** Detected "write a tweet" → `--skill-id twitter-writer`
|
|
325
|
+
**Step 5:**
|
|
326
|
+
```bash
|
|
327
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
328
|
+
--query "Help me write a tweet about AI trends" \
|
|
329
|
+
--live-doc-id "QPetunwpGnkKuZHStP7gwt" \
|
|
330
|
+
--skill-id twitter-writer \
|
|
331
|
+
--accept-language en --timeout 60 --json
|
|
332
|
+
```
|
|
333
|
+
**Step 6:** Save new `thread_short_id`, keep same `live_doc_short_id`
|
|
334
|
+
|
|
335
|
+
```
|
|
336
|
+
User: "Make it more casual and add some emojis"
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Step 3:** Follow-up → use saved `thread_short_id`
|
|
340
|
+
**Step 5:**
|
|
341
|
+
```bash
|
|
342
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
343
|
+
--query "Make it more casual and add some emojis" \
|
|
344
|
+
--thread-id "NEW_THREAD_FROM_TWEET" \
|
|
345
|
+
--live-doc-id "QPetunwpGnkKuZHStP7gwt" \
|
|
346
|
+
--timeout 60 --json
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Example C: Logo Design
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
User: "Design a logo for my coffee shop called Bean & Brew"
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Step 4:** Detected "design a logo" → `--skill-id logo-and-branding`
|
|
356
|
+
**Step 5:**
|
|
357
|
+
```bash
|
|
358
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
359
|
+
--query "Design a logo for my coffee shop called Bean & Brew" \
|
|
360
|
+
--live-doc-id "QPetunwpGnkKuZHStP7gwt" \
|
|
361
|
+
--skill-id logo-and-branding \
|
|
362
|
+
--accept-language en --timeout 90 --json
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Example D: E-commerce Product Image
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
User: "Generate a product image for a wireless headphone on white background"
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Step 4:** Detected "product image" → `--skill-id ecommerce-product-image`
|
|
372
|
+
**Step 5:**
|
|
373
|
+
```bash
|
|
374
|
+
node felo-superAgent/scripts/run_superagent.mjs \
|
|
375
|
+
--query "Generate a product image for a wireless headphone on white background" \
|
|
376
|
+
--live-doc-id "QPetunwpGnkKuZHStP7gwt" \
|
|
377
|
+
--skill-id ecommerce-product-image \
|
|
378
|
+
--accept-language en --timeout 90 --json
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Example E: User Requests a New Canvas
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
User: "Open a new canvas for a different project"
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Step 2d:** Create new LiveDoc:
|
|
388
|
+
```bash
|
|
389
|
+
node felo-livedoc/scripts/run_livedoc.mjs create --name "New Project" --json
|
|
390
|
+
```
|
|
391
|
+
Extract new `live_doc_short_id`. Discard the old one. All subsequent calls use the new ID.
|
|
392
|
+
|
|
393
|
+
## Available Script Options
|
|
394
|
+
|
|
395
|
+
**Core parameters:**
|
|
396
|
+
- `--query <text>` (REQUIRED) — User question, 1-2000 characters
|
|
397
|
+
- `--live-doc-id <id>` (REQUIRED for new conversations) — LiveDoc short_id to associate with
|
|
398
|
+
- `--thread-id <id>` — Thread ID from previous response, for follow-up conversations
|
|
399
|
+
- `--timeout <seconds>` — Request/stream timeout, default 60 seconds
|
|
400
|
+
|
|
401
|
+
**Skill parameters (new conversations only, ignored in follow-up):**
|
|
402
|
+
- `--skill-id <id>` — Skill ID (see Skill ID auto-detection table in Constraints)
|
|
403
|
+
- `--selected-resource-ids <ids>` — Comma-separated resource IDs to include
|
|
404
|
+
- `--ext <json>` — Extra parameters as JSON object
|
|
405
|
+
|
|
406
|
+
**Output control:**
|
|
407
|
+
- `--json` / `-j` — Output JSON format with full metadata (RECOMMENDED: always use this)
|
|
408
|
+
- `--verbose` / `-v` — Log stream connection details to stderr
|
|
409
|
+
- `--accept-language <lang>` — Language preference (e.g., zh, en, ja)
|
|
121
410
|
|
|
122
411
|
## API Workflow (Reference)
|
|
123
412
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
413
|
+
The script handles this workflow automatically:
|
|
414
|
+
|
|
415
|
+
1. **Create conversation:**
|
|
416
|
+
- New: `POST /v2/conversations` (requires `live_doc_short_id` in body)
|
|
417
|
+
- Follow-up: `POST /v2/conversations/{threadId}/follow_up`
|
|
418
|
+
- Returns: `stream_key`, `thread_short_id`, `live_doc_short_id`
|
|
419
|
+
|
|
420
|
+
2. **Consume SSE stream:**
|
|
421
|
+
- `GET /v2/conversations/stream/{stream_key}`
|
|
422
|
+
- Supports offset parameter for resuming: `?offset={lastOffset}`
|
|
423
|
+
- Reconnects automatically if connection drops (2-second delay)
|
|
424
|
+
|
|
425
|
+
3. **Parse events:**
|
|
426
|
+
- `message` — Direct text content
|
|
427
|
+
- `stream` — Wrapped content with type information
|
|
428
|
+
- `heartbeat` — Keep-alive signal
|
|
429
|
+
- `done` / `completed` / `complete` — Stream finished
|
|
430
|
+
- `error` — Error event (non-terminal, continues reading)
|
|
431
|
+
|
|
432
|
+
4. **Extract tool results:**
|
|
433
|
+
- Image generation (`generate_images`)
|
|
434
|
+
- Research reports (`generate_discovery`)
|
|
435
|
+
- Document generation (`generate_document`)
|
|
436
|
+
- PPT generation (`generate_ppt`)
|
|
437
|
+
- HTML generation (`generate_html`)
|
|
438
|
+
- Twitter/X search (`search_x`)
|
|
127
439
|
|
|
128
440
|
Base URL: `https://openapi.felo.ai` (override with `FELO_API_BASE` if needed).
|
|
129
441
|
|
|
442
|
+
## Tool Support
|
|
443
|
+
|
|
444
|
+
SuperAgent may invoke tools during conversation. The script automatically extracts and displays:
|
|
445
|
+
|
|
446
|
+
**Image Generation:**
|
|
447
|
+
- Tool: `generate_images`
|
|
448
|
+
- Output: Image URLs and titles
|
|
449
|
+
|
|
450
|
+
**Research & Discovery:**
|
|
451
|
+
- Tool: `generate_discovery`
|
|
452
|
+
- Output: Research report titles and status
|
|
453
|
+
|
|
454
|
+
**Document Generation:**
|
|
455
|
+
- Tool: `generate_document`
|
|
456
|
+
- Output: Document titles and status
|
|
457
|
+
|
|
458
|
+
**Presentation Generation:**
|
|
459
|
+
- Tool: `generate_ppt`
|
|
460
|
+
- Output: PPT titles and status
|
|
461
|
+
|
|
462
|
+
**HTML Generation:**
|
|
463
|
+
- Tool: `generate_html`
|
|
464
|
+
- Output: HTML page titles and status
|
|
465
|
+
|
|
466
|
+
**Twitter/X Search:**
|
|
467
|
+
- Tool: `search_x`
|
|
468
|
+
- Output: Tweet content, author info, metrics (likes, retweets, views)
|
|
469
|
+
|
|
130
470
|
## Error Handling
|
|
131
471
|
|
|
132
|
-
|
|
133
|
-
| -------------------------------------- | ---- | ------------------------ |
|
|
134
|
-
| INVALID_API_KEY | 401 | API Key 无效或已撤销 |
|
|
135
|
-
| SUPER_AGENT_CONVERSATION_CREATE_FAILED | 502 | 创建会话失败(下游错误) |
|
|
136
|
-
| SUPER_AGENT_CONVERSATION_QUERY_FAILED | 502 | 查询会话详情失败 |
|
|
472
|
+
### Common Error Codes
|
|
137
473
|
|
|
138
|
-
|
|
474
|
+
| Code | HTTP | Description |
|
|
475
|
+
| -------------------------------------- | ---- | ------------------------------------------------- |
|
|
476
|
+
| INVALID_API_KEY | 401 | API Key is invalid or has been revoked |
|
|
477
|
+
| SUPER_AGENT_CONVERSATION_CREATE_FAILED | 502 | Failed to create conversation (upstream error) |
|
|
478
|
+
| SUPER_AGENT_CONVERSATION_QUERY_FAILED | 502 | Failed to query conversation details |
|
|
139
479
|
|
|
140
|
-
|
|
480
|
+
### SSE Stream Errors
|
|
141
481
|
|
|
142
|
-
|
|
482
|
+
The stream may send:
|
|
483
|
+
- `event: error` with `data: {"message": "..."}` — treat as failure and show message
|
|
484
|
+
- Connection timeout — script automatically reconnects with 2-second delay
|
|
485
|
+
- Idle timeout (2 hours) — stream aborted if no data received
|
|
486
|
+
|
|
487
|
+
### Missing API Key
|
|
488
|
+
|
|
489
|
+
If `FELO_API_KEY` is not set, display this message:
|
|
143
490
|
|
|
144
491
|
```
|
|
145
|
-
|
|
492
|
+
ERROR: FELO_API_KEY not set
|
|
493
|
+
|
|
494
|
+
To use this skill, you need to set up your Felo API Key:
|
|
495
|
+
|
|
496
|
+
1. Get your API key from https://felo.ai (Settings -> API Keys)
|
|
497
|
+
2. Set the environment variable:
|
|
146
498
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
499
|
+
Linux/macOS:
|
|
500
|
+
export FELO_API_KEY="your-api-key-here"
|
|
501
|
+
|
|
502
|
+
Windows (PowerShell):
|
|
503
|
+
$env:FELO_API_KEY="your-api-key-here"
|
|
504
|
+
|
|
505
|
+
3. Restart Claude Code or reload the environment
|
|
150
506
|
```
|
|
151
507
|
|
|
508
|
+
### Timeout Handling
|
|
509
|
+
|
|
510
|
+
- Default timeout: 60 seconds (increase to 90 for image/design generation)
|
|
511
|
+
- Idle timeout: 2 hours (no data received)
|
|
512
|
+
- Increase timeout for complex queries: `--timeout 120`
|
|
513
|
+
|
|
152
514
|
## Important Notes
|
|
153
515
|
|
|
154
|
-
- Execute this skill
|
|
155
|
-
- After create,
|
|
156
|
-
- Use the bundled Node script to consume SSE; do not assume `jq` or other tools for parsing SSE
|
|
157
|
-
- Same API key as other Felo skills (`FELO_API_KEY`)
|
|
516
|
+
- Execute this skill immediately using the Bash tool — do not just describe what you would do
|
|
517
|
+
- After create, the script connects to the stream **immediately** — the `stream_key` has a limited validity period
|
|
518
|
+
- Use the bundled Node script to consume SSE; do not assume `jq` or other tools for parsing SSE
|
|
519
|
+
- Same API key as other Felo skills (`FELO_API_KEY`)
|
|
520
|
+
- The script handles reconnection automatically if the stream drops
|
|
521
|
+
- Tool results are deduplicated to avoid showing the same resource multiple times
|
|
522
|
+
- Always use `--json` flag to capture `thread_short_id` and `live_doc_short_id` for state management
|
|
523
|
+
- Multi-language support: Fully supports Simplified Chinese, Traditional Chinese, Japanese, and English
|
|
524
|
+
- The API returns results in the same language as the query when possible
|
|
525
|
+
|
|
526
|
+
## Decision Flowchart
|
|
527
|
+
|
|
528
|
+
```
|
|
529
|
+
User sends a message
|
|
530
|
+
|
|
|
531
|
+
v
|
|
532
|
+
Have live_doc_short_id?
|
|
533
|
+
NO --> Step 2b: fetch list --> got items?
|
|
534
|
+
YES --> use items[0].short_id
|
|
535
|
+
NO --> Step 2c: create new LiveDoc
|
|
536
|
+
YES --> continue
|
|
537
|
+
|
|
|
538
|
+
v
|
|
539
|
+
Have thread_short_id from previous call?
|
|
540
|
+
NO --> This is a NEW conversation
|
|
541
|
+
--> Step 4: detect skill-id
|
|
542
|
+
--> Step 5: run WITHOUT --thread-id
|
|
543
|
+
YES --> Is user explicitly starting a new topic?
|
|
544
|
+
YES --> NEW conversation (same live-doc-id, no --thread-id)
|
|
545
|
+
NO --> FOLLOW-UP (pass --thread-id)
|
|
546
|
+
|
|
|
547
|
+
v
|
|
548
|
+
Run script --> parse JSON --> save thread_short_id + live_doc_short_id
|
|
549
|
+
|
|
|
550
|
+
v
|
|
551
|
+
Present answer to user
|
|
552
|
+
```
|
|
158
553
|
|
|
159
554
|
## References
|
|
160
555
|
|
|
161
556
|
- [SuperAgent API (Felo Open Platform)](https://openapi.felo.ai/docs/api-reference/v2/superagent.html)
|
|
162
557
|
- [Felo Open Platform](https://openapi.felo.ai/docs/)
|
|
558
|
+
- [Get API Key](https://felo.ai) (Settings -> API Keys)
|