instar 0.7.11 → 0.7.13
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.
|
@@ -458,6 +458,23 @@ curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
|
|
|
458
458
|
6. If auto-detection fails, send another message, wait, and retry once
|
|
459
459
|
7. If still failing, ask the user for the chat ID manually (look at the URL in Telegram Web — prepend `-100` to the number)
|
|
460
460
|
|
|
461
|
+
**Step 3e-vi: Create the Lifeline topic**
|
|
462
|
+
|
|
463
|
+
The Lifeline topic is the always-available channel between user and agent. Create it via the Bot API (not browser — more reliable):
|
|
464
|
+
|
|
465
|
+
```bash
|
|
466
|
+
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/createForumTopic" \
|
|
467
|
+
-H 'Content-Type: application/json' \
|
|
468
|
+
-d '{"chat_id": "'${CHAT_ID}'", "name": "Lifeline", "icon_color": 9367192}'
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
- `icon_color: 9367192` = green (matches the "always available" meaning)
|
|
472
|
+
- Parse the response to get `message_thread_id` — **save this** for sending the greeting
|
|
473
|
+
|
|
474
|
+
If the API call fails (e.g., topics not enabled yet), that's OK — the greeting will go to General instead.
|
|
475
|
+
|
|
476
|
+
**CRITICAL: Store the `message_thread_id`** in the config alongside the token and chat ID. The agent will use this as its primary communication channel.
|
|
477
|
+
|
|
461
478
|
#### Step 3f: Confirm Success
|
|
462
479
|
|
|
463
480
|
After all steps succeed, tell the user:
|
|
@@ -482,6 +499,7 @@ Walk the user through each step with clear instructions:
|
|
|
482
499
|
curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?offset=-1" > /dev/null
|
|
483
500
|
curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
|
|
484
501
|
```
|
|
502
|
+
6. **Create Lifeline topic** — Even in manual mode, create the Lifeline topic via Bot API (Step 3e-vi). This doesn't require browser automation.
|
|
485
503
|
|
|
486
504
|
### Browser Automation Tips
|
|
487
505
|
|
|
@@ -603,29 +621,41 @@ curl -s http://localhost:<port>/health
|
|
|
603
621
|
|
|
604
622
|
If the health check fails, retry once. If still failing, tell the user what happened and suggest `instar server start` manually.
|
|
605
623
|
|
|
606
|
-
### Step 5b: Agent Greets the User
|
|
624
|
+
### Step 5b: Agent Greets the User in the Lifeline Topic
|
|
607
625
|
|
|
608
|
-
**If Telegram was configured, the new agent should reach out to the user.** This is the magic moment — the agent comes alive.
|
|
626
|
+
**If Telegram was configured, the new agent should reach out to the user in the Lifeline topic.** This is the magic moment — the agent comes alive.
|
|
609
627
|
|
|
610
|
-
Send
|
|
628
|
+
Send the greeting to the Lifeline topic (using the `message_thread_id` from Step 3e-vi):
|
|
611
629
|
|
|
612
630
|
```bash
|
|
613
631
|
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMessage" \
|
|
614
632
|
-H 'Content-Type: application/json' \
|
|
615
|
-
-d '{"chat_id": "<CHAT_ID>", "text": "<GREETING>"}'
|
|
633
|
+
-d '{"chat_id": "<CHAT_ID>", "message_thread_id": <LIFELINE_THREAD_ID>, "text": "<GREETING>"}'
|
|
616
634
|
```
|
|
617
635
|
|
|
618
|
-
|
|
636
|
+
If the Lifeline topic wasn't created (Step 3e-vi failed), fall back to General (omit `message_thread_id`).
|
|
637
|
+
|
|
638
|
+
The greeting should be **in the agent's voice** AND explain how Telegram topics work. For example, if the agent is named "Scout" and is casual:
|
|
619
639
|
|
|
620
|
-
>
|
|
640
|
+
> Hey! I'm Scout, your new project agent. I'm up and running.
|
|
641
|
+
>
|
|
642
|
+
> This is the **Lifeline** topic — it's always here, always available. Think of it as the main channel between us.
|
|
643
|
+
>
|
|
644
|
+
> **How topics work:**
|
|
645
|
+
> - Each topic is a separate conversation thread (like Slack channels)
|
|
646
|
+
> - Ask me to create new topics for different tasks or focus areas — e.g., "create a topic for deployment issues"
|
|
647
|
+
> - I can proactively create topics when I notice something worth discussing
|
|
648
|
+
> - The Lifeline topic is always here for anything that doesn't fit elsewhere
|
|
649
|
+
>
|
|
650
|
+
> What should we work on first?
|
|
621
651
|
|
|
622
|
-
|
|
652
|
+
Adapt the tone and examples to the agent's personality and role. Keep it warm and practical.
|
|
623
653
|
|
|
624
654
|
### Step 5c: Tell the User
|
|
625
655
|
|
|
626
656
|
After the server is running and the greeting is sent:
|
|
627
657
|
|
|
628
|
-
> "All done! [Agent name] just messaged you in Telegram. From here on, that's your primary channel — just talk to your agent there."
|
|
658
|
+
> "All done! [Agent name] just messaged you in the Lifeline topic on Telegram. From here on, that's your primary channel — just talk to your agent there."
|
|
629
659
|
>
|
|
630
660
|
> "As long as your computer is running the Instar server, your agent is available."
|
|
631
661
|
|
package/dist/commands/setup.js
CHANGED
|
@@ -450,21 +450,59 @@ async function runClassicSetup() {
|
|
|
450
450
|
const { startServer } = await import('./server.js');
|
|
451
451
|
await startServer({ foreground: false });
|
|
452
452
|
if (telegramConfig?.chatId) {
|
|
453
|
-
//
|
|
453
|
+
// Create the Lifeline topic — the always-available channel
|
|
454
|
+
let lifelineThreadId = null;
|
|
454
455
|
try {
|
|
455
|
-
const
|
|
456
|
+
const topicResult = execFileSync('curl', [
|
|
457
|
+
'-s', '-X', 'POST',
|
|
458
|
+
`https://api.telegram.org/bot${telegramConfig.token}/createForumTopic`,
|
|
459
|
+
'-H', 'Content-Type: application/json',
|
|
460
|
+
'-d', JSON.stringify({ chat_id: telegramConfig.chatId, name: 'Lifeline', icon_color: 9367192 }),
|
|
461
|
+
], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], timeout: 10000 });
|
|
462
|
+
const parsed = JSON.parse(topicResult);
|
|
463
|
+
if (parsed.ok && parsed.result?.message_thread_id) {
|
|
464
|
+
lifelineThreadId = parsed.result.message_thread_id;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
catch {
|
|
468
|
+
// Non-fatal — greeting will go to General
|
|
469
|
+
}
|
|
470
|
+
// Send greeting to the Lifeline topic (or General if topic creation failed)
|
|
471
|
+
try {
|
|
472
|
+
const greeting = [
|
|
473
|
+
`Hey! I'm ${projectName}, your new agent. I'm up and running.`,
|
|
474
|
+
'',
|
|
475
|
+
'This is the **Lifeline** topic — it\'s always here, always available.',
|
|
476
|
+
'',
|
|
477
|
+
'**How topics work:**',
|
|
478
|
+
'- Each topic is a separate conversation thread',
|
|
479
|
+
'- Ask me to create new topics for different tasks or focus areas',
|
|
480
|
+
'- I can proactively create topics when something needs attention',
|
|
481
|
+
'- Lifeline is always here for anything that doesn\'t fit elsewhere',
|
|
482
|
+
'',
|
|
483
|
+
'What should we work on first?',
|
|
484
|
+
].join('\n');
|
|
485
|
+
const payload = {
|
|
486
|
+
chat_id: telegramConfig.chatId,
|
|
487
|
+
text: greeting,
|
|
488
|
+
parse_mode: 'Markdown',
|
|
489
|
+
};
|
|
490
|
+
if (lifelineThreadId) {
|
|
491
|
+
payload.message_thread_id = lifelineThreadId;
|
|
492
|
+
}
|
|
456
493
|
execFileSync('curl', [
|
|
457
494
|
'-s', '-X', 'POST',
|
|
458
495
|
`https://api.telegram.org/bot${telegramConfig.token}/sendMessage`,
|
|
459
496
|
'-H', 'Content-Type: application/json',
|
|
460
|
-
'-d', JSON.stringify(
|
|
497
|
+
'-d', JSON.stringify(payload),
|
|
461
498
|
], { stdio: ['pipe', 'pipe', 'pipe'], timeout: 10000 });
|
|
462
499
|
}
|
|
463
500
|
catch {
|
|
464
501
|
// Non-fatal — the agent will greet on first session
|
|
465
502
|
}
|
|
466
503
|
console.log();
|
|
467
|
-
|
|
504
|
+
const topicNote = lifelineThreadId ? ' in the Lifeline topic' : '';
|
|
505
|
+
console.log(pc.bold(` All done! ${projectName} just messaged you${topicNote} on Telegram.`));
|
|
468
506
|
console.log(pc.dim(' That\'s your primary channel from here on — no terminal needed.'));
|
|
469
507
|
console.log(pc.dim(' As long as your computer is running the Instar server, your agent is available.'));
|
|
470
508
|
}
|