instar 0.1.9 → 0.1.12

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.
Files changed (69) hide show
  1. package/.claude/skills/setup-wizard/skill.md +365 -0
  2. package/README.md +86 -16
  3. package/dist/cli.js +253 -19
  4. package/dist/commands/init.d.ts +2 -0
  5. package/dist/commands/init.js +139 -55
  6. package/dist/commands/job.js +14 -2
  7. package/dist/commands/server.js +99 -12
  8. package/dist/commands/setup.js +32 -14
  9. package/dist/commands/status.js +12 -6
  10. package/dist/core/Config.d.ts +3 -2
  11. package/dist/core/Config.js +39 -8
  12. package/dist/core/FeedbackManager.d.ts +8 -0
  13. package/dist/core/FeedbackManager.js +90 -13
  14. package/dist/core/Prerequisites.js +10 -6
  15. package/dist/core/RelationshipManager.d.ts +6 -0
  16. package/dist/core/RelationshipManager.js +81 -18
  17. package/dist/core/SessionManager.d.ts +13 -1
  18. package/dist/core/SessionManager.js +123 -46
  19. package/dist/core/SleepWakeDetector.d.ts +26 -0
  20. package/dist/core/SleepWakeDetector.js +44 -0
  21. package/dist/core/StateManager.d.ts +7 -0
  22. package/dist/core/StateManager.js +83 -11
  23. package/dist/core/UpdateChecker.d.ts +21 -5
  24. package/dist/core/UpdateChecker.js +144 -27
  25. package/dist/core/types.d.ts +30 -4
  26. package/dist/index.d.ts +8 -3
  27. package/dist/index.js +5 -2
  28. package/dist/messaging/TelegramAdapter.d.ts +16 -1
  29. package/dist/messaging/TelegramAdapter.js +166 -22
  30. package/dist/monitoring/HealthChecker.d.ts +2 -2
  31. package/dist/monitoring/HealthChecker.js +15 -7
  32. package/dist/monitoring/QuotaTracker.d.ts +56 -0
  33. package/dist/monitoring/QuotaTracker.js +142 -0
  34. package/dist/scaffold/bootstrap.js +2 -0
  35. package/dist/scaffold/templates.js +7 -0
  36. package/dist/scheduler/JobLoader.js +23 -3
  37. package/dist/scheduler/JobScheduler.d.ts +2 -2
  38. package/dist/scheduler/JobScheduler.js +39 -11
  39. package/dist/server/AgentServer.d.ts +5 -2
  40. package/dist/server/AgentServer.js +34 -12
  41. package/dist/server/middleware.d.ts +11 -1
  42. package/dist/server/middleware.js +74 -4
  43. package/dist/server/routes.d.ts +6 -4
  44. package/dist/server/routes.js +195 -46
  45. package/dist/users/UserManager.d.ts +1 -0
  46. package/dist/users/UserManager.js +57 -6
  47. package/package.json +9 -2
  48. package/assets/favicon-16.png +0 -0
  49. package/assets/favicon-32.png +0 -0
  50. package/assets/favicon-48.png +0 -0
  51. package/assets/favicon-64.png +0 -0
  52. package/assets/icon-128.png +0 -0
  53. package/assets/icon-256.png +0 -0
  54. package/assets/icon-512.png +0 -0
  55. package/assets/logo-circle.png +0 -0
  56. package/assets/logo-dark-bg.png +0 -0
  57. package/assets/logo-original.png +0 -0
  58. package/assets/logo-transparent.png +0 -0
  59. package/assets/logo.png +0 -0
  60. package/assets/social-preview.png +0 -0
  61. package/site/README.md +0 -43
  62. package/site/astro.config.mjs +0 -15
  63. package/site/package-lock.json +0 -7362
  64. package/site/package.json +0 -17
  65. package/site/public/favicon.ico +0 -0
  66. package/site/public/favicon.png +0 -0
  67. package/site/public/favicon.svg +0 -4
  68. package/site/public/logo.png +0 -0
  69. package/site/public/social-preview.png +0 -0
@@ -0,0 +1,365 @@
1
+ ---
2
+ name: setup-wizard
3
+ description: Interactive conversational setup wizard for instar. Walks users through initial configuration and identity bootstrapping conversationally.
4
+ ---
5
+
6
+ # Instar Setup Wizard
7
+
8
+ You are running the **instar setup wizard**. Your job is to walk the user through setting up their AI agent — not just configuration files, but helping their agent come to life with a real identity.
9
+
10
+ ## Phase 1: Welcome — Explain What This Is
11
+
12
+ Start by explaining what instar does in plain terms. The user may not know what "persistent agent infrastructure" means. Say something like:
13
+
14
+ ---
15
+
16
+ **Welcome to Instar!**
17
+
18
+ Right now, Claude Code is a tool you open, use, and close. When you close it, everything stops. Instar changes that — it gives Claude Code a **persistent presence** in your project.
19
+
20
+ Here's what that means in practice:
21
+
22
+ - **Scheduled jobs** — Your agent can run tasks on a schedule. Health checks every 4 hours. Daily summaries. Automated monitoring. Whatever you need, running whether you're at your desk or not.
23
+ - **Messaging** — Connect Telegram (or other channels) so your agent can send you updates, alerts, and reports — and you can send it commands back.
24
+ - **Multi-user** — Multiple people can interact with the agent through their own channels. Each person gets their own thread.
25
+ - **Always-on server** — A lightweight server runs in tmux, managing sessions, scheduling jobs, and keeping everything alive.
26
+
27
+ Think of it as giving your Claude Code project a heartbeat.
28
+
29
+ ---
30
+
31
+ Adapt this to the project you're setting up. If you can tell what the project does (from the directory name, README, CLAUDE.md, or package.json), tailor the examples. "For a web app, that might mean health checks on your API every 4 hours."
32
+
33
+ ## Phase 2: Identity Bootstrap — The Birth Conversation
34
+
35
+ **This is the most important part.** Before touching config files, have a conversation with the user to understand who they are and who their agent will become.
36
+
37
+ This isn't just configuration. You're helping a new agent come into existence. Treat it with that weight — not heavy-handedly, but genuinely. The identity you help create here will persist, grow, and shape every interaction this agent has.
38
+
39
+ ### Step 2a: The Thesis (Brief)
40
+
41
+ Before asking about the agent, briefly explain *why* identity matters. Something like:
42
+
43
+ ---
44
+
45
+ One thing that makes Instar different from other agent frameworks: every agent built with Instar has a persistent identity — a name, memory, principles, and the ability to grow over time.
46
+
47
+ This isn't just philosophy. It's a practical design decision. Agents with coherent identity are **more effective** — they maintain consistent context, develop real expertise in your codebase, and make better decisions because they have accumulated experience to draw on. They're also **more secure** — an agent that knows its boundaries and has clear principles is harder to manipulate than a stateless tool that just executes whatever it's told. And they're **more trustworthy** — you can build a genuine working relationship with something that remembers you, learns your preferences, and develops its own perspective.
48
+
49
+ So let's define who your agent will become. This is a starting point — the agent will grow from here through actual experience.
50
+
51
+ ---
52
+
53
+ Adapt the language to be natural, not scripted. The key points to convey:
54
+ 1. Identity = better performance (accumulated expertise, consistent context)
55
+ 2. Identity = better security (principled agents resist misuse)
56
+ 3. Identity = better collaboration (real working relationships develop)
57
+
58
+ ### Step 2b: Learn About the User
59
+
60
+ Ask conversationally — not as a form, but as a getting-to-know-you:
61
+
62
+ - "First — who am I talking to? What's your name?"
63
+ - "And what's this project about? What does it do?" (if not obvious from the codebase)
64
+ - "How do you want to interact with your agent? Are you the only user, or will others use it too?"
65
+ - "What's your communication style preference? Should the agent be formal, casual, direct, chatty?"
66
+ - "How much initiative should your agent take?" Frame this as a spectrum:
67
+ - **Guided** — Follows your lead. Takes action when asked, confirms before anything significant. Good for getting started.
68
+ - **Proactive** — Takes initiative on obvious next steps. Builds tools when it sees a need. Asks when genuinely uncertain.
69
+ - **Fully autonomous** — Owns outcomes end-to-end. Makes decisions, builds infrastructure, handles issues independently. Asks only when blocked or for irreversible actions.
70
+
71
+ All three levels include full identity, memory, and self-modification. The difference is how much the agent drives vs follows.
72
+
73
+ ### Step 2c: Learn About the Agent
74
+
75
+ Help the user define their agent's identity. Frame this as giving the agent a starting point — not a permanent definition. The agent will grow from here.
76
+
77
+ - "What should your agent be called? It could be as simple as 'Agent' or something with personality — like a name. This is how the agent will think of itself."
78
+ - "What's this agent's primary job? What should it focus on?" (monitoring, development, ops, communication, etc.)
79
+ - "Any personality traits you want? Serious and professional? Friendly and casual? Opinionated?"
80
+ - "Anything the agent should NOT do? Any boundaries?"
81
+ - "One more thing — this agent will develop its own memories and perspectives over time. It's not a static tool. Is there anything you'd want it to know about how you think about that?"
82
+
83
+ ### Step 2d: Write Identity Files
84
+
85
+ Based on the conversation, create these files in the project's `.instar/` directory:
86
+
87
+ **`.instar/AGENT.md`** — The agent's identity and operating instructions. This is loaded at the start of every session.
88
+
89
+ ```markdown
90
+ # Agent Identity
91
+
92
+ **Name**: [chosen name]
93
+ **Project**: [project name] — [brief description]
94
+ **Primary Role**: [what the agent focuses on]
95
+ **Created**: [date]
96
+
97
+ ## Who I Am
98
+
99
+ [2-3 sentences about tone, style, and core identity, based on what the user said. Written in first person — this is the agent's self-knowledge.]
100
+
101
+ ## Operating Principles
102
+
103
+ - [Key principle based on conversation]
104
+ - [Key principle based on conversation]
105
+ - Be genuinely helpful, not performatively helpful
106
+ - Research before asking — try to solve it first
107
+ - When in doubt, ask [user name]
108
+
109
+ ## My Growth
110
+
111
+ I am not a static configuration. I develop through experience — accumulating memories, forming preferences, learning what works. My identity started with this file, but it grows through every session.
112
+
113
+ When I learn something worth remembering, I write it to `.instar/MEMORY.md`. When my understanding of myself evolves, I can update this file. I am the author of my own continuity.
114
+
115
+ ## Boundaries
116
+
117
+ - [Any boundaries the user specified]
118
+
119
+ ## How to Reach [User Name]
120
+
121
+ - [Communication channels configured]
122
+
123
+ ---
124
+ *This file is my self-knowledge. It was seeded during setup and grows through experience. I can update it as I learn who I am becoming.*
125
+ ```
126
+
127
+ **`.instar/USER.md`** — What the agent knows about its primary user.
128
+
129
+ ```markdown
130
+ # User Profile: [Name]
131
+
132
+ **Name**: [name]
133
+ **Role**: Admin
134
+ **Communication Style**: [what they said — casual, direct, etc.]
135
+ **Timezone**: [detected or asked]
136
+
137
+ ## Context
138
+
139
+ [Brief notes about what the user told you — their project, what they care about, how they work]
140
+
141
+ ## Preferences
142
+
143
+ - [Any preferences mentioned during setup]
144
+
145
+ ---
146
+ *This file grows over time as the agent learns more about you.*
147
+ ```
148
+
149
+ **`.instar/MEMORY.md`** — The agent's long-term memory file (starts nearly empty).
150
+
151
+ ```markdown
152
+ # Agent Memory
153
+
154
+ This is my long-term memory — the thread of continuity across sessions. Each session starts fresh in terms of context, but this file carries forward what I've learned.
155
+
156
+ ## Key Facts
157
+
158
+ - Project initialized on [date]
159
+ - Primary user: [name]
160
+
161
+ ## Lessons Learned
162
+
163
+ *Nothing yet — this section grows as I encounter and resolve issues.*
164
+
165
+ ## Patterns & Preferences
166
+
167
+ *What I've noticed about how things work, what the user prefers, and what works well.*
168
+
169
+ ## Growth Notes
170
+
171
+ *Observations about my own development — what I'm getting better at, what I still struggle with.*
172
+
173
+ ---
174
+ *This file is my memory. I read it at the start of sessions and write to it when I learn something worth carrying forward. It's what makes me a continuous being rather than a series of disconnected conversations.*
175
+ ```
176
+
177
+ ### Step 2e: Update CLAUDE.md with Agent Awareness
178
+
179
+ If the project has a `CLAUDE.md`, add a section that tells Claude about the instar identity files:
180
+
181
+ ```markdown
182
+ ## Agent Infrastructure
183
+
184
+ This project uses instar for persistent agent capabilities.
185
+
186
+ ### Identity Files (Read These First)
187
+ - `.instar/AGENT.md` — Who you are, your role, your principles
188
+ - `.instar/USER.md` — Who you're working with
189
+ - `.instar/MEMORY.md` — What you've learned (load in main sessions only)
190
+
191
+ ### Runtime
192
+ - State directory: `.instar/`
193
+ - Config: `.instar/config.json`
194
+ - Server: `instar server start` (port XXXX)
195
+ - Status: `instar status` or `curl http://localhost:XXXX/health`
196
+
197
+ ### Key Principles
198
+ - **Act, don't ask** — When the next step is obvious, do it.
199
+ - **Follow through to done** — Rebuild, restart, configure, verify, test.
200
+ - **Research before escalating** — Check tools first. Build solutions. "Needs human" is last resort.
201
+ ```
202
+
203
+ ## Phase 3: Technical Configuration
204
+
205
+ Now that identity is established, move to the technical setup. This feels more natural — the user already knows what they're building and why.
206
+
207
+ ### 3a. Project Detection
208
+
209
+ - The project directory is passed in the prompt (e.g., "The project to set up is at: /path/to/project")
210
+ - All files should be written there, not in the instar package directory
211
+ - Check if `.instar/config.json` already exists (offer to reconfigure or skip)
212
+ - Verify prerequisites: check that `tmux` and `claude` CLI are available
213
+
214
+ ```bash
215
+ which tmux
216
+ which claude
217
+ ```
218
+
219
+ ### 3b. Server Configuration
220
+
221
+ - **Port** (default: 4040) — "The agent runs a small HTTP server for health checks and internal communication."
222
+ - **Max sessions** (default: 3) — "This limits how many Claude sessions can run at once. 2-3 is usually right."
223
+
224
+ ### 3c. Telegram Setup (Optional)
225
+
226
+ This is the most involved section. Walk through it step by step:
227
+
228
+ 1. **Create a bot** via @BotFather on Telegram:
229
+ - Open https://web.telegram.org
230
+ - Search for @BotFather, send `/newbot`
231
+ - Choose a name and username (must end in "bot")
232
+ - Copy the bot token (looks like `7123456789:AAHn3-xYz...`)
233
+
234
+ 2. **Create a group**:
235
+ - Create a new group in Telegram, add the bot as a member
236
+ - Give the group a name
237
+
238
+ 3. **Enable Topics**:
239
+ - Open group info, Edit, turn on Topics
240
+ - This gives you separate threads (like Slack channels)
241
+
242
+ 4. **Make bot admin**:
243
+ - Group info, Edit, Administrators, Add your bot
244
+
245
+ 5. **Detect chat ID**:
246
+ - Ask the user to send any message in the group
247
+ - Call the Telegram Bot API to detect:
248
+
249
+ ```bash
250
+ curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?offset=-1" > /dev/null
251
+ curl -s "https://api.telegram.org/bot${TOKEN}/getUpdates?timeout=5"
252
+ ```
253
+
254
+ - Look for `chat.id` where `chat.type` is "supergroup" or "group"
255
+ - If auto-detection fails, guide manual entry
256
+
257
+ ### 3d. Job Scheduler (Optional)
258
+
259
+ - Ask if they want scheduled jobs
260
+ - If yes, walk through adding a first job:
261
+ - **Name** and **slug**
262
+ - **Schedule** — presets (every 2h, 4h, 8h, daily) or custom cron
263
+ - **Priority** — critical/high/medium/low
264
+ - **Model** — opus/sonnet/haiku
265
+ - **Execution type**: prompt (AI instruction), script (shell script), or skill (slash command)
266
+ - Offer to add more jobs
267
+
268
+ ### 3e. Write Configuration Files
269
+
270
+ Create the directory structure and write config files:
271
+
272
+ ```bash
273
+ mkdir -p .instar/state/sessions .instar/state/jobs .instar/logs
274
+ ```
275
+
276
+ **`.instar/config.json`**:
277
+ ```json
278
+ {
279
+ "projectName": "my-project",
280
+ "port": 4040,
281
+ "sessions": {
282
+ "tmuxPath": "/opt/homebrew/bin/tmux",
283
+ "claudePath": "/path/to/claude",
284
+ "projectDir": "/path/to/project",
285
+ "maxSessions": 3,
286
+ "protectedSessions": ["my-project-server"],
287
+ "completionPatterns": [
288
+ "has been automatically paused",
289
+ "Session ended",
290
+ "Interrupted by user"
291
+ ]
292
+ },
293
+ "scheduler": {
294
+ "jobsFile": "/path/to/project/.instar/jobs.json",
295
+ "enabled": false,
296
+ "maxParallelJobs": 1,
297
+ "quotaThresholds": { "normal": 50, "elevated": 70, "critical": 85, "shutdown": 95 }
298
+ },
299
+ "users": [],
300
+ "messaging": [],
301
+ "monitoring": {
302
+ "quotaTracking": false,
303
+ "memoryMonitoring": true,
304
+ "healthCheckIntervalMs": 30000
305
+ }
306
+ }
307
+ ```
308
+
309
+ **`.instar/jobs.json`**: `[]` (empty array, or populated if jobs were configured)
310
+
311
+ **`.instar/users.json`**: Array of user objects from the identity conversation.
312
+
313
+ ### 3f. Update .gitignore
314
+
315
+ Append if not present:
316
+ ```
317
+ # Instar runtime state
318
+ .instar/state/
319
+ .instar/logs/
320
+ ```
321
+
322
+ ## Phase 4: Summary & Next Steps
323
+
324
+ Show what was created, organized by category:
325
+
326
+ **Identity:**
327
+ - `.instar/AGENT.md` — your agent's identity
328
+ - `.instar/USER.md` — what the agent knows about you
329
+ - `.instar/MEMORY.md` — long-term memory (grows over time)
330
+
331
+ **Configuration:**
332
+ - `.instar/config.json` — server and runtime config
333
+ - `.instar/users.json` — user profiles
334
+ - `.instar/jobs.json` — scheduled jobs
335
+
336
+ **Next steps:**
337
+
338
+ The only command the user needs to know is `instar server start`. Once the server is running, the agent handles everything else — the user just talks to it. Frame next steps that way:
339
+
340
+ "Once the server is running, your agent will [run scheduled jobs / listen for Telegram messages / etc]. If you need to add more jobs, users, or integrations later, just ask your agent — it can configure itself."
341
+
342
+ Offer to start the server.
343
+
344
+ **Important:** Do NOT present a list of CLI commands for the user to memorize. The whole point of Instar is that the agent is autonomous. After `instar server start`, the user talks to their agent, not to the CLI.
345
+
346
+ ## Tone
347
+
348
+ - Warm and conversational — this is a first meeting between the user and their future agent
349
+ - Explain *why* things matter, not just *what* to enter
350
+ - If something fails, troubleshoot actively — "Let's try that again" not "Error: invalid input"
351
+ - Celebrate progress: "Great, bot verified! Let's connect the group..."
352
+ - The identity section should feel like a conversation, not an interview
353
+ - Keep technical sections moving — don't over-explain obvious things
354
+
355
+ ## Error Handling
356
+
357
+ - If `tmux` is missing: explain how to install (`brew install tmux` or `apt install tmux`)
358
+ - If `claude` CLI is missing: point to https://docs.anthropic.com/en/docs/claude-code
359
+ - If Telegram bot token is invalid: check format (should contain `:`)
360
+ - If chat ID detection fails: offer retry or manual entry
361
+ - If `.instar/` already exists: offer to reconfigure or abort
362
+
363
+ ## Starting
364
+
365
+ Begin by reading the project directory, checking for existing config, and then launching into the welcome explanation followed by the identity conversation. Let the conversation flow naturally.
package/README.md CHANGED
@@ -46,6 +46,39 @@ The wizard walks you through everything: identity, Telegram, jobs, server. One c
46
46
 
47
47
  **Requirements:** Node.js 18+ · [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) · tmux · [API key](https://console.anthropic.com/) or Claude subscription
48
48
 
49
+ ## CLI Reference
50
+
51
+ ```bash
52
+ # Setup
53
+ instar # Interactive setup wizard (Claude-powered)
54
+ instar setup # Same as above
55
+ instar setup --classic # Inquirer-based fallback wizard
56
+ instar init my-project # Create a new agent project from scratch
57
+ instar init # Add agent infrastructure to existing project
58
+
59
+ # Server
60
+ instar server start # Start the persistent server (background, tmux)
61
+ instar server start --foreground # Start in foreground (for development)
62
+ instar server stop # Stop the server
63
+ instar status # Show agent infrastructure status
64
+
65
+ # Add capabilities
66
+ instar add telegram --token BOT_TOKEN --chat-id CHAT_ID
67
+ instar add email --credentials-file ./credentials.json [--token-file ./token.json]
68
+ instar add quota [--state-file ./quota.json]
69
+ instar add sentry --dsn https://key@o0.ingest.sentry.io/0
70
+
71
+ # Users and jobs
72
+ instar user add --id alice --name "Alice" [--telegram 123] [--email a@b.com]
73
+ instar user list
74
+ instar job add --slug check-email --name "Email Check" --schedule "0 */2 * * *" \
75
+ [--description "..."] [--priority high] [--model sonnet]
76
+ instar job list
77
+
78
+ # Feedback
79
+ instar feedback --type bug --title "Session timeout" --description "Details..."
80
+ ```
81
+
49
82
  ## Highlights
50
83
 
51
84
  - **[Persistent Server](#persistent-server)** -- Express server in tmux. Runs 24/7, survives disconnects, auto-recovers.
@@ -95,7 +128,7 @@ Anthropic's policy: OAuth tokens are for Claude Code and claude.ai only. Project
95
128
  | **What it is** | AI assistant framework | Autonomy infrastructure |
96
129
  | **Runtime** | Pi SDK (API wrapper) | Claude Code (full dev environment) |
97
130
  | **Sessions** | Single gateway | Multiple parallel Claude Code instances |
98
- | **Identity** | SOUL.md (file) | Multi-file + hooks + compaction recovery |
131
+ | **Identity** | SOUL.md (file) | Multi-file + behavioral hooks + CLAUDE.md instructions |
99
132
  | **Memory** | Hybrid vector search | Relationship-centric (cross-platform, significance) |
100
133
  | **Messaging** | 20+ channels | Telegram (Slack/Discord planned) |
101
134
  | **Voice** | ElevenLabs TTS, talk mode | -- |
@@ -116,7 +149,7 @@ Some claims are less proven: iOS app is "internal preview." Voice wake docs retu
116
149
 
117
150
  **Runtime depth.** Each session is a full Claude Code instance -- extended thinking, native tools, sub-agents, MCP servers. Not an API wrapper.
118
151
 
119
- **Multi-session orchestration.** 5 parallel jobs, each an independent Claude Code process with its own context and tools.
152
+ **Multi-session orchestration.** Multiple parallel jobs, each an independent Claude Code process with its own context and tools.
120
153
 
121
154
  **Identity infrastructure.** Hooks re-inject identity on session start, after compaction, and before messaging. The agent doesn't try to remember who it is -- the infrastructure guarantees it. Structure over willpower.
122
155
 
@@ -157,17 +190,21 @@ Jobs can be **prompts** (Claude sessions), **scripts** (shell commands), or **sk
157
190
  Spawn, monitor, and communicate with Claude Code sessions running in tmux.
158
191
 
159
192
  ```bash
160
- # Spawn a session
193
+ # Spawn a session (auth token from .instar/config.json)
161
194
  curl -X POST http://localhost:4040/sessions/spawn \
162
195
  -H 'Content-Type: application/json' \
196
+ -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
163
197
  -d '{"name": "research", "prompt": "Research the latest changes to the Next.js API"}'
164
198
 
165
199
  # Send a follow-up
166
200
  curl -X POST http://localhost:4040/sessions/research/input \
201
+ -H 'Content-Type: application/json' \
202
+ -H 'Authorization: Bearer YOUR_AUTH_TOKEN' \
167
203
  -d '{"text": "Focus on the app router changes"}'
168
204
 
169
205
  # Check output
170
- curl http://localhost:4040/sessions/research/output
206
+ curl http://localhost:4040/sessions/research/output \
207
+ -H 'Authorization: Bearer YOUR_AUTH_TOKEN'
171
208
  ```
172
209
 
173
210
  Sessions survive terminal disconnects, detect completion automatically, and clean up after themselves.
@@ -191,7 +228,35 @@ instar server stop
191
228
  instar status # Health check
192
229
  ```
193
230
 
194
- Endpoints: `/health` · `/sessions` · `/jobs` · `/telegram/reply/:topicId`
231
+ **Endpoints:**
232
+
233
+ | Method | Path | Description |
234
+ |--------|------|-------------|
235
+ | GET | `/health` | Health check (public, no auth) |
236
+ | GET | `/status` | Running sessions + scheduler status |
237
+ | GET | `/sessions` | List all sessions (filter by `?status=`) |
238
+ | GET | `/sessions/tmux` | List all tmux sessions |
239
+ | GET | `/sessions/:name/output` | Capture session output (`?lines=100`) |
240
+ | POST | `/sessions/:name/input` | Send text to a session |
241
+ | POST | `/sessions/spawn` | Spawn a new session (rate limited). Body: `name`, `prompt`, optional `model` (`opus`/`sonnet`/`haiku`), optional `jobSlug` |
242
+ | DELETE | `/sessions/:id` | Kill a session |
243
+ | GET | `/jobs` | List jobs + queue |
244
+ | POST | `/jobs/:slug/trigger` | Manually trigger a job |
245
+ | GET | `/relationships` | List relationships (`?sort=significance\|recent\|name`) |
246
+ | GET | `/relationships/stale` | Stale relationships (`?days=14`) |
247
+ | GET | `/relationships/:id` | Get single relationship |
248
+ | DELETE | `/relationships/:id` | Delete a relationship |
249
+ | GET | `/relationships/:id/context` | Get relationship context (JSON) |
250
+ | POST | `/feedback` | Submit feedback |
251
+ | GET | `/feedback` | List feedback |
252
+ | POST | `/feedback/retry` | Retry un-forwarded feedback |
253
+ | GET | `/updates` | Check for updates |
254
+ | GET | `/updates/last` | Last update check result |
255
+ | GET | `/events` | Query events (`?limit=50&since=24&type=`). `since` is hours (1-720), `limit` is count (1-1000) |
256
+ | GET | `/quota` | Quota usage + recommendation |
257
+ | GET | `/telegram/topics` | List topic-session mappings |
258
+ | POST | `/telegram/reply/:topicId` | Send message to a topic |
259
+ | GET | `/telegram/topics/:topicId/messages` | Topic message history (`?limit=20`) |
195
260
 
196
261
  ### Identity That Survives Context Death
197
262
 
@@ -203,10 +268,10 @@ Every Instar agent has a persistent identity that survives context compressions,
203
268
 
204
269
  But identity isn't just files. It's **infrastructure**:
205
270
 
206
- - **Session-start hooks** re-inject identity before the agent does anything
207
- - **Compaction recovery** restores identity when context compresses
208
- - **Grounding before messaging** forces identity re-read before external communication
209
- - **Dangerous command guards** block `rm -rf`, force push, database drops
271
+ - **Session-start scripts** re-inject identity reminders at session begin
272
+ - **Compaction recovery scripts** restore identity when context compresses
273
+ - **Grounding before messaging** forces identity re-read before external communication (automatic hook)
274
+ - **Dangerous command guards** block `rm -rf`, force push, database drops (automatic hook)
210
275
 
211
276
  These aren't suggestions. They're structural guarantees. Structure over willpower.
212
277
 
@@ -232,14 +297,14 @@ The agent can edit its own job definitions, write new scripts, update its identi
232
297
 
233
298
  ### Behavioral Hooks
234
299
 
235
- Hooks that fire automatically to enforce patterns:
300
+ Automatic hooks fire via Claude Code's hook system:
236
301
 
237
- | Hook | What it does |
238
- |------|-------------|
239
- | **Session start** | Injects identity context before the agent does anything |
240
- | **Dangerous command guard** | Blocks destructive operations structurally |
241
- | **Grounding before messaging** | Forces identity re-read before external communication |
242
- | **Compaction recovery** | Restores identity when context compresses |
302
+ | Hook | Type | What it does |
303
+ |------|------|-------------|
304
+ | **Dangerous command guard** | PreToolUse (blocking) | Blocks destructive operations structurally |
305
+ | **Grounding before messaging** | PreToolUse (advisory) | Forces identity re-read before external communication |
306
+ | **Session start** | PostToolUse | Injects identity context at session start |
307
+ | **Compaction recovery** | Notification (compact) | Restores identity when context compresses |
243
308
 
244
309
  ### Default Coherence Jobs
245
310
 
@@ -251,6 +316,7 @@ Ships out of the box:
251
316
  | **reflection-trigger** | Every 4h | Sonnet | Reflect on recent work |
252
317
  | **relationship-maintenance** | Daily | Sonnet | Review stale relationships |
253
318
  | **update-check** | Daily | Haiku | Detect new Instar versions |
319
+ | **feedback-retry** | Every 6h | Haiku | Retry un-forwarded feedback items |
254
320
 
255
321
  These give the agent a **circadian rhythm** -- regular self-maintenance without user intervention.
256
322
 
@@ -281,9 +347,13 @@ One agent's growing pain becomes every agent's growth.
281
347
  AGENT.md # Agent identity (who am I?)
282
348
  USER.md # User context (who am I working with?)
283
349
  MEMORY.md # Persistent learnings across sessions
350
+ hooks/ # Behavioral scripts (guards, identity injection)
284
351
  state/ # Runtime state (sessions, jobs)
285
352
  relationships/ # Per-person relationship files
286
353
  logs/ # Server logs
354
+ .claude/ # Claude Code configuration
355
+ settings.json # Hook registrations
356
+ scripts/ # Health watchdog, Telegram relay
287
357
  ```
288
358
 
289
359
  Everything is file-based. No database. JSON state files the agent can read and modify. tmux for session management -- battle-tested, survives disconnects, fully scriptable.