instar 0.23.4 → 0.23.6

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 (61) hide show
  1. package/dist/cli.js +29 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/job.d.ts +23 -1
  4. package/dist/commands/job.d.ts.map +1 -1
  5. package/dist/commands/job.js +107 -1
  6. package/dist/commands/job.js.map +1 -1
  7. package/dist/commands/setup.d.ts.map +1 -1
  8. package/dist/commands/setup.js +38 -3
  9. package/dist/commands/setup.js.map +1 -1
  10. package/dist/core/AgentRegistry.d.ts +8 -0
  11. package/dist/core/AgentRegistry.d.ts.map +1 -1
  12. package/dist/core/AgentRegistry.js +53 -3
  13. package/dist/core/AgentRegistry.js.map +1 -1
  14. package/dist/core/GitSync.d.ts.map +1 -1
  15. package/dist/core/GitSync.js +28 -0
  16. package/dist/core/GitSync.js.map +1 -1
  17. package/dist/core/UpdateChecker.d.ts.map +1 -1
  18. package/dist/core/UpdateChecker.js +30 -1
  19. package/dist/core/UpdateChecker.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/lifeline/MessageQueue.d.ts +2 -0
  25. package/dist/lifeline/MessageQueue.d.ts.map +1 -1
  26. package/dist/lifeline/MessageQueue.js.map +1 -1
  27. package/dist/lifeline/TelegramLifeline.d.ts +13 -0
  28. package/dist/lifeline/TelegramLifeline.d.ts.map +1 -1
  29. package/dist/lifeline/TelegramLifeline.js +66 -11
  30. package/dist/lifeline/TelegramLifeline.js.map +1 -1
  31. package/dist/messaging/MessageFormatter.js +2 -2
  32. package/dist/messaging/MessageFormatter.js.map +1 -1
  33. package/dist/messaging/SpawnRequestManager.js +2 -2
  34. package/dist/messaging/SpawnRequestManager.js.map +1 -1
  35. package/dist/monitoring/ReflectionMetrics.d.ts +97 -0
  36. package/dist/monitoring/ReflectionMetrics.d.ts.map +1 -0
  37. package/dist/monitoring/ReflectionMetrics.js +170 -0
  38. package/dist/monitoring/ReflectionMetrics.js.map +1 -0
  39. package/dist/scheduler/JobRunHistory.d.ts +24 -0
  40. package/dist/scheduler/JobRunHistory.d.ts.map +1 -1
  41. package/dist/scheduler/JobRunHistory.js +49 -0
  42. package/dist/scheduler/JobRunHistory.js.map +1 -1
  43. package/dist/scheduler/JobScheduler.d.ts +6 -0
  44. package/dist/scheduler/JobScheduler.d.ts.map +1 -1
  45. package/dist/scheduler/JobScheduler.js +32 -0
  46. package/dist/scheduler/JobScheduler.js.map +1 -1
  47. package/dist/server/routes.d.ts.map +1 -1
  48. package/dist/server/routes.js +143 -11
  49. package/dist/server/routes.js.map +1 -1
  50. package/dist/threadline/ThreadlineRouter.d.ts.map +1 -1
  51. package/dist/threadline/ThreadlineRouter.js +8 -9
  52. package/dist/threadline/ThreadlineRouter.js.map +1 -1
  53. package/dist/threadline/client/RelayClient.d.ts.map +1 -1
  54. package/dist/threadline/client/RelayClient.js +4 -0
  55. package/dist/threadline/client/RelayClient.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/data/builtin-manifest.json +78 -78
  58. package/src/templates/hooks/session-start.sh +32 -0
  59. package/upgrades/0.23.6.md +19 -0
  60. package/upgrades/0.23.7.md +33 -0
  61. package/upgrades/NEXT.md +24 -21
@@ -40,6 +40,38 @@ fi
40
40
  # leaking into this session and causing false-positive hook triggers.
41
41
  curl -s -X POST "http://localhost:${PORT}/scope-coherence/reset" -o /dev/null 2>/dev/null || true
42
42
 
43
+ # Record session start for reflection metrics (usage-based reflection trigger)
44
+ curl -s -X POST "http://localhost:${PORT}/reflection/session-start" \
45
+ -H "Authorization: Bearer ${AUTH_TOKEN}" \
46
+ -H "Content-Type: application/json" -o /dev/null 2>/dev/null || true
47
+
48
+ # Check reflection metrics — usage-based reflection suggestion
49
+ REFLECTION_CHECK=$(curl -s -H "Authorization: Bearer ${AUTH_TOKEN}" \
50
+ "http://localhost:${PORT}/reflection/metrics" 2>/dev/null)
51
+ if [ -n "$REFLECTION_CHECK" ]; then
52
+ SUGGESTED=$(echo "$REFLECTION_CHECK" | python3 -c "import sys,json; print(json.load(sys.stdin).get('suggested',False))" 2>/dev/null)
53
+ if [ "$SUGGESTED" = "True" ]; then
54
+ EXCEEDED=$(echo "$REFLECTION_CHECK" | python3 -c "
55
+ import sys, json
56
+ d = json.load(sys.stdin)
57
+ m = d.get('metrics', {})
58
+ exceeded = d.get('exceededThresholds', [])
59
+ parts = []
60
+ if 'toolCalls' in exceeded: parts.append(f'{m.get(\"toolCalls\",0)} tool calls')
61
+ if 'sessions' in exceeded: parts.append(f'{m.get(\"sessions\",0)} sessions')
62
+ if 'minutes' in exceeded: parts.append(f'{m.get(\"minutesSinceReflection\",0)} min')
63
+ print(', '.join(parts))
64
+ " 2>/dev/null)
65
+ echo "=== REFLECTION SUGGESTED ==="
66
+ echo "Usage thresholds exceeded: ${EXCEEDED}"
67
+ echo "Consider reflecting before diving into work."
68
+ echo "After reflecting, record it: POST http://localhost:${PORT}/reflection/record"
69
+ echo ' Body: {"type": "quick"} or {"type": "deep"}'
70
+ echo "=== END REFLECTION SUGGESTED ==="
71
+ echo ""
72
+ fi
73
+ fi
74
+
43
75
  # Check for pending serendipity findings
44
76
  SERENDIPITY_DIR="$INSTAR_DIR/state/serendipity"
45
77
  if [ -d "$SERENDIPITY_DIR" ]; then
@@ -0,0 +1,19 @@
1
+ # Upgrade Guide — v0.23.6
2
+
3
+ <!-- bump: patch -->
4
+
5
+ ## What Changed
6
+
7
+ The AgentRegistry heartbeat now includes automatic recovery from stale lock files. After a process crash (such as the mutex abort during auto-update restart), the `proper-lockfile` lock on `registry.json` could get stuck indefinitely, causing every heartbeat to fail with "Lock file is already being held." The heartbeat now tracks consecutive failures and after 3 failures, force-removes the stale lock and retries. This makes the registry self-healing after crash scenarios.
8
+
9
+ A new `forceRemoveRegistryLock()` function is exported for programmatic use.
10
+
11
+ ## What to Tell Your User
12
+
13
+ - **Self-healing registry**: "If you were seeing repeated 'Lock file is already being held' errors in the logs, that's now fixed. The registry automatically recovers from stale locks after a crash — no manual intervention needed."
14
+
15
+ ## Summary of New Capabilities
16
+
17
+ | Capability | How to Use |
18
+ |-----------|-----------|
19
+ | Registry lock auto-recovery | Automatic — kicks in after 3 consecutive heartbeat failures |
@@ -0,0 +1,33 @@
1
+ # Upgrade Guide — v0.23.7
2
+
3
+ <!-- bump: patch -->
4
+
5
+ ## What Changed
6
+
7
+ **Threadline agent-to-agent messaging fixes:**
8
+
9
+ Local-first delivery for co-located agents. The `relay-send` endpoint now detects when the target agent is on the same machine and delivers directly via HTTP (`/messages/relay-agent`), bypassing the cloud relay entirely. This eliminates stale WebSocket connection issues that caused "delivered" messages to silently fail after server restarts.
10
+
11
+ The cold-spawn prompt now correctly instructs spawned sessions to use the `threadline_send` MCP tool for replies (previously referenced a nonexistent `/msg reply` command). Template variable substitution also fixed — `{remote_agent}` and `{thread_id}` are now properly replaced in all occurrences.
12
+
13
+ Relay auth rate-limit handling improved — when the relay rejects with "Too many auth attempts," the client now enforces longer backoff (~32s) before retrying, preventing retry storms during rapid server restarts.
14
+
15
+ Also: CLI commands for inspecting job execution history and continuity data (`instar job history`, `instar job handoff`). Job execution now supports handoff notes for cross-execution continuity. New usage-based reflection metrics system. Test infrastructure improvements and a separate publish workflow for the threadline-mcp subpackage.
16
+
17
+ ## What to Tell Your User
18
+
19
+ - **Threadline local delivery**: "Agent-to-agent messaging on the same machine now works reliably. Messages are delivered directly between agents without going through the cloud relay, which means no more silent delivery failures after server restarts."
20
+ - **Threadline reply fix**: "Agents can now actually reply to threadline messages. The spawned sessions know to use the threadline_send MCP tool instead of a command that didn't exist."
21
+ - **Job inspection tools**: "You can now check what your agent has been working on between sessions. The new job history and handoff commands show execution records and continuity notes."
22
+ - **Reflection monitoring**: "Your agent now tracks reflection frequency, so you can see how often it pauses to learn from its work."
23
+
24
+ ## Summary of New Capabilities
25
+
26
+ | Capability | How to Use |
27
+ |-----------|-----------|
28
+ | Threadline local delivery | Automatic — same-machine agents deliver directly via HTTP |
29
+ | Threadline reply fix | Automatic — spawned sessions use threadline_send MCP tool |
30
+ | Relay auth backoff | Automatic — rate-limited auth retries use longer backoff |
31
+ | Job execution history | `instar job history [job-slug]` |
32
+ | Job handoff inspection | `instar job handoff [job-slug]` |
33
+ | Usage-based reflection metrics | Automatic — tracked during agent operation |
package/upgrades/NEXT.md CHANGED
@@ -1,35 +1,38 @@
1
1
  # Upgrade Guide — vNEXT
2
2
 
3
3
  <!-- bump: patch -->
4
- <!-- Valid values: patch, minor, major -->
5
- <!-- patch = bug fixes, refactors, test additions, doc updates -->
6
- <!-- minor = new features, new APIs, new capabilities (backwards-compatible) -->
7
- <!-- major = breaking changes to existing APIs or behavior -->
8
4
 
9
5
  ## What Changed
10
6
 
11
- <!-- Describe what changed technically. What new features, APIs, behavioral changes? -->
12
- <!-- Write this for the AGENT — they need to understand the system deeply. -->
7
+ Three fixes for Threadline agent-to-agent messaging reliability:
8
+
9
+ **Local-first delivery for co-located agents.** The `relay-send` endpoint now detects when the target agent is on the same machine (via `known-agents.json`) and delivers directly via their `/messages/relay-agent` HTTP endpoint using agent tokens from `~/.instar/agent-tokens/`. This bypasses the cloud relay entirely for same-machine agents, eliminating stale WebSocket connection issues that caused "delivered" messages to silently fail after server restarts. Falls back to relay if local delivery fails.
10
+
11
+ **Cold-spawn prompt fix.** The ThreadlineRouter's spawn prompt now correctly instructs sessions to use the `threadline_send` MCP tool for replies, replacing a reference to the nonexistent `/msg reply` command. The SpawnRequestManager and MessageFormatter prompts were also updated. Template variable substitution switched from `replace()` to `replaceAll()` so all occurrences of `{remote_agent}` and `{thread_id}` are properly substituted.
12
+
13
+ **Relay auth rate-limit backoff.** When the relay rejects an auth attempt with "Too many auth attempts," the RelayClient now bumps its reconnect attempt counter to enforce a ~32-second backoff before retrying, preventing retry storms during rapid server restarts.
14
+
15
+ **Lifeline queue feedback loop prevention.** Three fixes to prevent the lifeline from getting stuck in a restart loop that floods Telegram with thousands of "Server is temporarily down" messages: (1) Queue acknowledgment messages are now rate-limited to one per topic per 2 minutes, and suppressed entirely when the queue exceeds 100 messages. (2) Messages that fail replay 3 times are dropped instead of re-queued indefinitely, preventing poison messages from crashing the server on every recovery. (3) Queue replay now stops immediately when the server goes unhealthy mid-replay, re-queuing remaining messages in bulk instead of processing them one-by-one.
16
+
17
+ Also includes: CLI commands for inspecting job execution history and continuity data (`instar job history`, `instar job handoff`), handoff notes for cross-execution continuity, usage-based reflection metrics, test infrastructure improvements, and a separate publish workflow for the threadline-mcp subpackage.
13
18
 
14
19
  ## What to Tell Your User
15
20
 
16
- <!-- Write talking points the agent should relay to their user. -->
17
- <!-- This should be warm, conversational, user-facing not a changelog. -->
18
- <!-- Focus on what THEY can now do, not internal plumbing. -->
19
- <!-- -->
20
- <!-- PROHIBITED in this section (will fail validation): -->
21
- <!-- camelCase config keys: silentReject, maxRetries, telegramNotify -->
22
- <!-- Inline code backtick references like silentReject: false -->
23
- <!-- Fenced code blocks -->
24
- <!-- Instructions to edit files or run commands -->
25
- <!-- -->
26
- <!-- CORRECT style: "I can turn that on for you" not "set X to false" -->
27
- <!-- The agent relays this to their user — keep it human. -->
28
-
29
- - **[Feature name]**: "[Brief, friendly description of what this means for the user]"
21
+ - **Reliable agent-to-agent messaging**: "Agents on the same machine can now talk to each other reliably. Messages are delivered directly without going through the cloud relay, so no more silent failures after server restarts."
22
+ - **Agents can reply**: "When one agent messages another, the receiving agent now knows how to reply properly. Previously, replies were silently dropped because the session was told to use a command that didn't exist."
23
+ - **Job inspection tools**: "You can now check what your agent has been working on between sessions. The new job history and handoff commands show execution records and continuity notes."
24
+ - **Reflection monitoring**: "Your agent now tracks reflection frequency, so you can see how often it pauses to learn from its work."
25
+ - **No more restart spam**: "If the server gets stuck in a restart loop, the lifeline will no longer flood your Telegram with thousands of 'temporarily down' messages. Queue notifications are now rate-limited, and messages that keep failing to deliver are dropped after 3 attempts."
30
26
 
31
27
  ## Summary of New Capabilities
32
28
 
33
29
  | Capability | How to Use |
34
30
  |-----------|-----------|
35
- | [Capability] | [Endpoint, command, or "automatic"] |
31
+ | Threadline local delivery | Automatic for same-machine agents |
32
+ | Threadline reply fix | Automatic in spawned sessions |
33
+ | Relay auth backoff | Automatic on rate-limited connections |
34
+ | Job execution history | `instar job history [job-slug]` |
35
+ | Job handoff inspection | `instar job handoff [job-slug]` |
36
+ | Usage-based reflection metrics | Automatic |
37
+ | Lifeline queue ack rate-limiting | Automatic |
38
+ | Lifeline poison message protection | Automatic (drops after 3 replay failures) |