instar 0.24.13 → 0.24.15

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 (82) hide show
  1. package/dashboard/index.html +341 -0
  2. package/dist/cli.js +18 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/server.d.ts.map +1 -1
  5. package/dist/commands/server.js +188 -1
  6. package/dist/commands/server.js.map +1 -1
  7. package/dist/commands/slack-cli.d.ts +16 -0
  8. package/dist/commands/slack-cli.d.ts.map +1 -0
  9. package/dist/commands/slack-cli.js +198 -0
  10. package/dist/commands/slack-cli.js.map +1 -0
  11. package/dist/core/AgentRegistry.d.ts.map +1 -1
  12. package/dist/core/AgentRegistry.js +24 -6
  13. package/dist/core/AgentRegistry.js.map +1 -1
  14. package/dist/core/SleepWakeDetector.d.ts +11 -0
  15. package/dist/core/SleepWakeDetector.d.ts.map +1 -1
  16. package/dist/core/SleepWakeDetector.js +16 -1
  17. package/dist/core/SleepWakeDetector.js.map +1 -1
  18. package/dist/lifeline/ServerSupervisor.d.ts +13 -0
  19. package/dist/lifeline/ServerSupervisor.d.ts.map +1 -1
  20. package/dist/lifeline/ServerSupervisor.js +129 -0
  21. package/dist/lifeline/ServerSupervisor.js.map +1 -1
  22. package/dist/messaging/SessionSummarySentinel.js +1 -1
  23. package/dist/messaging/TelegramAdapter.d.ts +1 -0
  24. package/dist/messaging/TelegramAdapter.d.ts.map +1 -1
  25. package/dist/messaging/TelegramAdapter.js +4 -1
  26. package/dist/messaging/TelegramAdapter.js.map +1 -1
  27. package/dist/messaging/slack/ChannelManager.d.ts +36 -0
  28. package/dist/messaging/slack/ChannelManager.d.ts.map +1 -0
  29. package/dist/messaging/slack/ChannelManager.js +100 -0
  30. package/dist/messaging/slack/ChannelManager.js.map +1 -0
  31. package/dist/messaging/slack/FileHandler.d.ts +30 -0
  32. package/dist/messaging/slack/FileHandler.d.ts.map +1 -0
  33. package/dist/messaging/slack/FileHandler.js +87 -0
  34. package/dist/messaging/slack/FileHandler.js.map +1 -0
  35. package/dist/messaging/slack/RingBuffer.d.ts +22 -0
  36. package/dist/messaging/slack/RingBuffer.d.ts.map +1 -0
  37. package/dist/messaging/slack/RingBuffer.js +48 -0
  38. package/dist/messaging/slack/RingBuffer.js.map +1 -0
  39. package/dist/messaging/slack/SlackAdapter.d.ts +136 -0
  40. package/dist/messaging/slack/SlackAdapter.d.ts.map +1 -0
  41. package/dist/messaging/slack/SlackAdapter.js +572 -0
  42. package/dist/messaging/slack/SlackAdapter.js.map +1 -0
  43. package/dist/messaging/slack/SlackApiClient.d.ts +51 -0
  44. package/dist/messaging/slack/SlackApiClient.d.ts.map +1 -0
  45. package/dist/messaging/slack/SlackApiClient.js +94 -0
  46. package/dist/messaging/slack/SlackApiClient.js.map +1 -0
  47. package/dist/messaging/slack/SocketModeClient.d.ts +44 -0
  48. package/dist/messaging/slack/SocketModeClient.d.ts.map +1 -0
  49. package/dist/messaging/slack/SocketModeClient.js +209 -0
  50. package/dist/messaging/slack/SocketModeClient.js.map +1 -0
  51. package/dist/messaging/slack/index.d.ts +12 -0
  52. package/dist/messaging/slack/index.d.ts.map +1 -0
  53. package/dist/messaging/slack/index.js +15 -0
  54. package/dist/messaging/slack/index.js.map +1 -0
  55. package/dist/messaging/slack/sanitize.d.ts +39 -0
  56. package/dist/messaging/slack/sanitize.d.ts.map +1 -0
  57. package/dist/messaging/slack/sanitize.js +71 -0
  58. package/dist/messaging/slack/sanitize.js.map +1 -0
  59. package/dist/messaging/slack/types.d.ts +155 -0
  60. package/dist/messaging/slack/types.d.ts.map +1 -0
  61. package/dist/messaging/slack/types.js +54 -0
  62. package/dist/messaging/slack/types.js.map +1 -0
  63. package/dist/monitoring/PresenceProxy.d.ts +157 -0
  64. package/dist/monitoring/PresenceProxy.d.ts.map +1 -0
  65. package/dist/monitoring/PresenceProxy.js +891 -0
  66. package/dist/monitoring/PresenceProxy.js.map +1 -0
  67. package/dist/monitoring/SessionWatchdog.d.ts.map +1 -1
  68. package/dist/monitoring/SessionWatchdog.js +2 -0
  69. package/dist/monitoring/SessionWatchdog.js.map +1 -1
  70. package/dist/server/AgentServer.d.ts +1 -0
  71. package/dist/server/AgentServer.d.ts.map +1 -1
  72. package/dist/server/AgentServer.js +49 -47
  73. package/dist/server/AgentServer.js.map +1 -1
  74. package/dist/server/routes.d.ts +1 -0
  75. package/dist/server/routes.d.ts.map +1 -1
  76. package/dist/server/routes.js +213 -4
  77. package/dist/server/routes.js.map +1 -1
  78. package/package.json +1 -1
  79. package/src/data/builtin-manifest.json +93 -77
  80. package/src/templates/hooks/slack-channel-context.sh +98 -0
  81. package/src/templates/scripts/slack-reply.sh +64 -0
  82. package/upgrades/0.24.15.md +49 -0
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env bash
2
+ # slack-channel-context.sh — UserPromptSubmit hook
3
+ #
4
+ # Detects [slack:CHANNEL_ID] prefix in user messages and injects
5
+ # channel conversation history as JSON context.
6
+ #
7
+ # Reads from the ring buffer cache via instar server API —
8
+ # zero Slack API calls per prompt.
9
+
10
+ set -euo pipefail
11
+
12
+ # Read user prompt from stdin (JSON format from Claude Code)
13
+ INPUT=$(cat)
14
+ PROMPT=$(echo "$INPUT" | python3 -c "import json,sys; print(json.load(sys.stdin).get('userMessage',''))" 2>/dev/null) || exit 0
15
+
16
+ # Check for [slack:C...] prefix
17
+ if [[ "$PROMPT" =~ \[slack:([A-Z0-9]+)\] ]]; then
18
+ CHANNEL_ID="${BASH_REMATCH[1]}"
19
+ else
20
+ exit 0
21
+ fi
22
+
23
+ # Get port and auth from config
24
+ PORT="${INSTAR_PORT:-}"
25
+ AUTH=""
26
+
27
+ if [ -f ".instar/config.json" ]; then
28
+ if [ -z "$PORT" ]; then
29
+ CONFIG_PORT=$(python3 -c "import json; print(json.load(open('.instar/config.json')).get('port',''))" 2>/dev/null)
30
+ [ -n "$CONFIG_PORT" ] && PORT="$CONFIG_PORT"
31
+ fi
32
+ AUTH=$(python3 -c "import json; print(json.load(open('.instar/config.json')).get('authToken',''))" 2>/dev/null)
33
+ fi
34
+
35
+ PORT="${PORT:-4042}"
36
+
37
+ # Check server health
38
+ if ! curl -sf "http://localhost:${PORT}/health" >/dev/null 2>&1; then
39
+ exit 0 # Server not running — graceful degradation
40
+ fi
41
+
42
+ # Fetch channel history from ring buffer cache
43
+ MESSAGES=$(curl -sf \
44
+ ${AUTH:+-H "Authorization: Bearer $AUTH"} \
45
+ "http://localhost:${PORT}/slack/channels/${CHANNEL_ID}/messages?limit=30" 2>/dev/null) || exit 0
46
+
47
+ # Format thread history for session context
48
+ python3 -c "
49
+ import json, sys
50
+ from datetime import datetime
51
+
52
+ data = json.loads('''${MESSAGES}''')
53
+ messages = data.get('messages', [])
54
+
55
+ if not messages:
56
+ sys.exit(0)
57
+
58
+ lines = ['--- Thread History (last {} messages) ---'.format(len(messages))]
59
+ lines.append('IMPORTANT: Read this history carefully before taking any action.')
60
+ lines.append('Your task is to continue THIS conversation, not start something new.')
61
+ lines.append('Topic: slack-{}'.format('${CHANNEL_ID}'))
62
+ lines.append('')
63
+
64
+ unanswered = 0
65
+ for msg in messages:
66
+ ts = msg.get('ts', '')
67
+ try:
68
+ dt = datetime.fromtimestamp(float(ts))
69
+ time_str = dt.strftime('%H:%M:%S')
70
+ except:
71
+ time_str = ts
72
+
73
+ user = msg.get('user', 'unknown')
74
+ text = msg.get('text', '')
75
+
76
+ # Truncate very long messages
77
+ if len(text) > 2000:
78
+ text = text[:2000] + '...'
79
+
80
+ # Determine if from user or agent
81
+ sender = 'User' if msg.get('fromUser', True) else 'Agent'
82
+ lines.append('[{}] {}: {}'.format(time_str, sender, text))
83
+
84
+ lines.append('')
85
+ lines.append('--- End Thread History ---')
86
+ lines.append('')
87
+ lines.append('CRITICAL: You MUST relay your response back to Slack after responding.')
88
+ lines.append('Use the relay script:')
89
+ lines.append('')
90
+ lines.append(\"cat <<'EOF' | .claude/scripts/slack-reply.sh ${CHANNEL_ID}\")
91
+ lines.append('Your response text here')
92
+ lines.append('EOF')
93
+ lines.append('')
94
+ lines.append('Strip the [slack:${CHANNEL_ID}] prefix before interpreting the message.')
95
+ lines.append('Only relay conversational text — not tool output or internal reasoning.')
96
+
97
+ print('\n'.join(lines))
98
+ " 2>/dev/null || exit 0
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env bash
2
+ # slack-reply.sh — Send a message to a Slack channel via the instar server.
3
+ #
4
+ # Usage:
5
+ # slack-reply.sh CHANNEL_ID "message text"
6
+ # echo "message" | slack-reply.sh CHANNEL_ID
7
+ # cat <<'EOF' | slack-reply.sh CHANNEL_ID
8
+ # Multi-line message here
9
+ # EOF
10
+
11
+ set -euo pipefail
12
+
13
+ CHANNEL_ID="$1"
14
+ shift
15
+
16
+ # Read message from args or stdin
17
+ if [ $# -gt 0 ]; then
18
+ MESSAGE="$*"
19
+ else
20
+ MESSAGE="$(cat)"
21
+ fi
22
+
23
+ if [ -z "$MESSAGE" ]; then
24
+ echo "Error: no message text provided" >&2
25
+ exit 1
26
+ fi
27
+
28
+ # Get port from env or config
29
+ PORT="${INSTAR_PORT:-}"
30
+ AUTH=""
31
+
32
+ if [ -f ".instar/config.json" ]; then
33
+ if [ -z "$PORT" ]; then
34
+ CONFIG_PORT=$(python3 -c "import json; print(json.load(open('.instar/config.json')).get('port',''))" 2>/dev/null)
35
+ [ -n "$CONFIG_PORT" ] && PORT="$CONFIG_PORT"
36
+ fi
37
+ AUTH=$(python3 -c "import json; print(json.load(open('.instar/config.json')).get('authToken',''))" 2>/dev/null)
38
+ fi
39
+
40
+ PORT="${PORT:-4042}"
41
+
42
+ # JSON-escape the message
43
+ ESCAPED=$(python3 -c "import json,sys; print(json.dumps(sys.stdin.read()))" <<< "$MESSAGE" 2>/dev/null)
44
+ # Fallback to basic bash escaping if python unavailable
45
+ if [ -z "$ESCAPED" ]; then
46
+ ESCAPED="\"$(echo "$MESSAGE" | sed 's/\\/\\\\/g; s/"/\\"/g')\""
47
+ fi
48
+
49
+ # Send via Instar server
50
+ RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
51
+ "http://localhost:${PORT}/slack/reply/${CHANNEL_ID}" \
52
+ -H "Content-Type: application/json" \
53
+ ${AUTH:+-H "Authorization: Bearer $AUTH"} \
54
+ -d "{\"text\": ${ESCAPED}}")
55
+
56
+ HTTP_CODE=$(echo "$RESPONSE" | tail -1)
57
+ BODY=$(echo "$RESPONSE" | sed '$d')
58
+
59
+ if [ "$HTTP_CODE" = "200" ]; then
60
+ echo "Sent ${#MESSAGE} chars to channel ${CHANNEL_ID}"
61
+ else
62
+ echo "Failed (HTTP ${HTTP_CODE}): ${BODY}" >&2
63
+ exit 1
64
+ fi
@@ -0,0 +1,49 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- bump: minor -->
4
+
5
+ ## What Changed
6
+
7
+ ### Slack Messaging Adapter
8
+
9
+ Instar now includes a full Slack messaging adapter (`SlackAdapter`), enabling agents to send and receive messages via Slack workspaces. The adapter supports:
10
+
11
+ - Sending messages to channels and threads
12
+ - Token validation and secure credential handling
13
+ - Atomic write operations for message persistence
14
+ - CLI tooling for Slack interaction (`slack-cli`)
15
+ - Server-side routes for Slack webhook integration
16
+
17
+ The adapter follows the same pattern as existing messaging adapters (Telegram, WhatsApp) and plugs into the unified channel routing system.
18
+
19
+ ### Server-Side Process Review Dashboard
20
+
21
+ A new Systems tab on the dashboard provides real-time visibility into server processes. This includes:
22
+
23
+ - Process telemetry collection and display
24
+ - Health status monitoring for running services
25
+ - Integration with the existing dashboard infrastructure
26
+
27
+ ### Architecture Documentation
28
+
29
+ A new "Under the Hood" page on the documentation site explains Instar's internal architecture, giving developers and agents a clearer picture of how the system is structured.
30
+
31
+ ### CI Stability Improvements
32
+
33
+ Several CI fixes improve reliability: resolved flaky test exclusions, fixed WhatsApp string test, added `skipStallClear` option to prevent stall-clear interference during topic sends, and fixed test failures blocking the push gate.
34
+
35
+ ## What to Tell Your User
36
+
37
+ - **Slack support is here**: Your agent can now send and receive messages through Slack. If your team uses Slack, you can connect it as a messaging channel alongside Telegram and other platforms. Ask your agent to set it up for you.
38
+
39
+ - **Better visibility into what is running**: There is a new Systems tab on your dashboard that shows what server processes are active and their health status. Useful for troubleshooting if something feels off.
40
+
41
+ - **More reliable updates**: Several under-the-hood fixes make the CI pipeline more stable, which means smoother and more frequent releases going forward.
42
+
43
+ ## Summary of New Capabilities
44
+
45
+ | Capability | How to Use |
46
+ |-----------|-----------|
47
+ | Slack messaging | Configure Slack token via CLI, then messages route automatically |
48
+ | Process review dashboard | Visit the Systems tab on your Instar dashboard |
49
+ | Architecture docs | Check the "Under the Hood" page on the docs site |