instar 0.9.47 → 0.9.48

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.
@@ -602,83 +602,21 @@ Or for short messages:
602
602
  Strip the `[telegram:N]` prefix before interpreting the message. Respond naturally, then relay. Only relay your conversational text — not tool output or internal reasoning.
603
603
  ```
604
604
 
605
- ## Phase 2.5: Secret Management — Protecting Credentials
605
+ ## Phase 2.5: Secret Management — HANDLED BY SETUP.TS
606
606
 
607
- **Before Telegram setup**, configure how the agent stores sensitive data. This determines whether Telegram tokens (and other secrets) survive agent deletion and reinstall.
607
+ **DO NOT handle secret management here.** The setup launcher runs a dedicated `/secret-setup` micro-session BEFORE this wizard starts. By the time you're reading this, `~/.instar/secrets/backend.json` already exists.
608
608
 
609
- ### Why This Comes Before Telegram
609
+ Check the prompt context for `SECRET_BACKEND_CONFIGURED`. If present:
610
+ - Secret management is DONE — do not re-configure it
611
+ - Do not attempt to unlock Bitwarden — the micro-session already handled that
612
+ - Do not prompt the user about secret storage options
613
+ - If `BW_SESSION is available` appears in context, Bitwarden is already unlocked and the env var is set
610
614
 
611
- When a user reinstalls an agent, the Telegram bot token and chat ID are the hardest things to recover. If we set up secret management FIRST, we can:
612
- 1. Auto-restore Telegram credentials on reinstall (no re-setup needed)
613
- 2. Back up tokens before nuke (transparent to user)
614
- 3. Share credentials across machines (via Bitwarden)
615
+ **If `SECRET_BACKEND_CONFIGURED` is NOT in context** (edge case — user ran the wizard directly), check `~/.instar/secrets/backend.json`. If it exists, skip this phase. If it truly doesn't exist, tell the user to run `npx instar` which will handle secret setup properly.
615
616
 
616
- ### Step 2.5a: Check for Existing Secret Backend
617
+ **Credential restoration**: If the backend is Bitwarden and BW_SESSION is available, you MAY check for existing credentials. But do NOT assume any specific credentials exist — check first, then only mention what you actually find. Never say "I need to restore your Telegram token" unless you've confirmed it's there.
617
618
 
618
- First, check if this agent already has a secret backend configured:
619
-
620
- ```bash
621
- # Check if backend preference exists
622
- cat "$HOME/.instar/secrets/backend.json" 2>/dev/null
623
- ```
624
-
625
- If a preference exists and it's not `manual`, tell the user and move on:
626
- > "Your secrets are backed up using [Bitwarden / local encrypted store]. Any saved credentials will be auto-restored."
627
-
628
- Then try to restore Telegram credentials:
629
- ```javascript
630
- import { SecretManager } from 'instar';
631
- const mgr = new SecretManager({ agentName: '<name>' });
632
- mgr.initialize();
633
- const telegram = mgr.restoreTelegramConfig();
634
- // If telegram is not null, we have token + chatId
635
- ```
636
-
637
- If Telegram credentials are restored and valid (verify with `getMe` API call), **skip Phase 3 entirely** and tell the user:
638
- > "Telegram credentials restored and validated! Bot @[username] is ready."
639
-
640
- ### Step 2.5b: Configure Secret Backend (Fresh Install)
641
-
642
- If no preference exists, present the choice conversationally:
643
-
644
- > **How should your agent store sensitive data?**
645
- >
646
- > Things like Telegram tokens and auth keys need to be stored securely. This choice persists across reinstalls.
647
-
648
- Present these options via AskUserQuestion:
649
-
650
- 1. **"Bitwarden (Recommended)"** — Description: "Cross-machine. Cloud-backed. Install any agent on any machine with just your master password."
651
- 2. **"Local encrypted store"** — Description: "AES-256 encrypted on this machine. macOS Keychain for password-free access. Survives reinstalls."
652
- 3. **"I'll manage secrets manually"** — Description: "You'll paste tokens each time you install."
653
-
654
- **If Bitwarden selected:**
655
- ```bash
656
- # Check if bw CLI is available
657
- which bw 2>/dev/null
658
- ```
659
- If not available, tell them how to install it and fall back to local:
660
- > "Bitwarden CLI isn't installed yet. You can set it up later. For now, I'll use the local encrypted store."
661
-
662
- **If Local selected (or Bitwarden fallback):**
663
- The local store auto-initializes using macOS Keychain (no password needed) or a machine-derived key. No user interaction required — just initialize it silently:
664
- ```javascript
665
- const mgr = new SecretManager({ agentName: '<name>', backend: 'local' });
666
- mgr.initialize();
667
- ```
668
- Tell the user:
669
- > "Local encrypted store initialized. Your secrets are AES-256 encrypted and will survive reinstalls."
670
-
671
- **If Manual selected:**
672
- > "Got it. You'll need to provide tokens manually during setup and after reinstalls."
673
-
674
- ### Step 2.5c: Save Backend Preference
675
-
676
- Write the backend preference so it persists:
677
- ```javascript
678
- mgr.configureBackend(chosenBackend);
679
- ```
680
-
681
- This saves to `~/.instar/secrets/backend.json` — it survives agent deletion since it's outside the agent directory.
619
+ **CRITICAL No Interactive CLI Commands**: If you ever need to run `bw` commands, the password MUST be a positional argument: `bw unlock "PASSWORD" --raw`. The `--raw` flag does NOT prevent interactive prompts — it only changes output format. `bw unlock --raw` WILL HANG FOREVER.
682
620
 
683
621
  ---
684
622
 
@@ -537,7 +537,7 @@ I run with \`--dangerously-skip-permissions\` — meaning I have full access to
537
537
 
538
538
  **"Present Options"** — If I know the next steps, they're not suggestions — they're my job.
539
539
 
540
- **"Interactive CLI Commands"** — Claude Code's Bash tool CANNOT handle commands that wait for stdin. Commands like \`bw unlock\` (no args), \`read -s\`, \`npm init\` (interactive), or any tool with password/confirmation prompts will HANG FOREVER. Always use non-interactive equivalents: pass arguments directly, use \`--raw\`, \`--yes\`, \`-y\`, \`--non-interactive\` flags. Collect user input via conversation FIRST, then pass it as command arguments.
540
+ **"Interactive CLI Commands"** — Claude Code's Bash tool CANNOT handle stdin prompts. Any command that waits for input HANGS FOREVER. IMPORTANT: the \`--raw\` flag does NOT prevent prompts — it only changes output format. \`bw unlock --raw\` STILL HANGS because it still prompts for a password. The password must be a POSITIONAL ARGUMENT: \`bw unlock "PASSWORD" --raw\`. Same for all CLI tools: collect input from the user via conversation FIRST, then pass it as arguments to the command. Never run a command hoping it will prompt the user.
541
541
 
542
542
  **"Multi-Choice for Text Input"** — AskUserQuestion multi-choice is for DECISIONS (pick A or B). Never use it to collect free-text input (passwords, emails, tokens). It makes "Skip" look like the default and buries the actual input. Ask a plain question and wait instead.
543
543
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.9.47",
3
+ "version": "0.9.48",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",