@misterhuydo/sentinel 1.0.42 → 1.0.44

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.
package/.cairn/.hint-lock CHANGED
@@ -1 +1 @@
1
- 2026-03-21T21:53:40.473Z
1
+ 2026-03-22T05:33:05.646Z
@@ -1,6 +1,6 @@
1
1
  {
2
- "message": "Auto-checkpoint at 2026-03-21T22:07:22.712Z",
3
- "checkpoint_at": "2026-03-21T22:07:22.713Z",
2
+ "message": "Auto-checkpoint at 2026-03-21T23:30:09.918Z",
3
+ "checkpoint_at": "2026-03-21T23:30:09.918Z",
4
4
  "active_files": [],
5
5
  "notes": [],
6
6
  "mtime_snapshot": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@misterhuydo/sentinel",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "Sentinel — Autonomous DevOps Agent installer and manager",
5
5
  "bin": {
6
6
  "sentinel": "./bin/sentinel.js"
@@ -4,7 +4,7 @@
4
4
  # Usage:
5
5
  # ./fetch_log.sh # reads all *.properties in script dir
6
6
  # ./fetch_log.sh SSOLWA.properties # specific file(s)
7
- # ./fetch_log.sh /path/to/SSOLWA.properties, /path/to/UAS.properties
7
+ # ./fetch_log.sh --debug SSOLWA.properties # show SSH errors + resolved paths
8
8
  #
9
9
  # Required properties:
10
10
  # KEY=<pem file> — filename resolved from config dir, then ~/.ssh/
@@ -22,6 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
22
22
  DEFAULT_SSH_USER="ec2-user"
23
23
  DEFAULT_TAIL=1000
24
24
  DEFAULT_GREP_FILTER="WARN|ERROR|FATAL|Exception|Error"
25
+ DEBUG=0
25
26
 
26
27
  show_help() {
27
28
  cat << 'EOF'
@@ -30,6 +31,7 @@ fetch_log.sh — Generic SSH log fetcher
30
31
  USAGE
31
32
  ./fetch_log.sh Read all *.properties in script dir
32
33
  ./fetch_log.sh FILE.properties ... One or more properties files
34
+ ./fetch_log.sh --debug FILE.properties Show SSH errors and resolved paths
33
35
 
34
36
  OUTPUT
35
37
  OUTPUT_DIR/<ServiceName>/<logname>-<node>.log
@@ -55,6 +57,11 @@ if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
55
57
  exit 0
56
58
  fi
57
59
 
60
+ if [[ "${1:-}" == "--debug" || "${1:-}" == "-d" ]]; then
61
+ DEBUG=1
62
+ shift
63
+ fi
64
+
58
65
  trim() {
59
66
  local s="$*"
60
67
  s="${s#"${s%%[![:space:]]*}"}"
@@ -119,6 +126,15 @@ fetch_from_properties() {
119
126
  REMOTE_SERVICE_USER="${REMOTE_SERVICE_USER:-$SERVICE_NAME}"
120
127
  OUTPUT_DIR="${OUTPUT_DIR:-$SCRIPT_DIR}"
121
128
 
129
+ if [[ $DEBUG -eq 1 ]]; then
130
+ echo " KEY: $KEY"
131
+ echo " REMOTE_USER: $REMOTE_SERVICE_USER"
132
+ echo " GREP_FILTER: ${GREP_FILTER:-(none)}"
133
+ echo " GREP_EXCLUDE: ${GREP_EXCLUDE:-(none)}"
134
+ echo " TAIL: $TAIL"
135
+ echo " OUTPUT_DIR: $OUTPUT_DIR"
136
+ fi
137
+
122
138
  local SERVICE_DIR="$OUTPUT_DIR/$SERVICE_NAME"
123
139
  mkdir -p "$SERVICE_DIR"
124
140
 
@@ -141,7 +157,7 @@ fetch_from_properties() {
141
157
  ssh_host="$host_entry"
142
158
  fi
143
159
 
144
- echo "--- [$SERVICE_NAME] node-$node_idx ($ssh_host) ---"
160
+ echo "--- [$SERVICE_NAME] node-$node_idx ($ssh_user@$ssh_host) ---"
145
161
 
146
162
  for raw_log in "${LOG_ARRAY[@]}"; do
147
163
  local log_path
@@ -158,15 +174,33 @@ fetch_from_properties() {
158
174
  [[ -n "$TAIL" ]] && remote_cmd+=" | tail -n $TAIL"
159
175
  [[ -n "$HEAD" ]] && [[ -z "$TAIL" ]] && remote_cmd+=" | head -n $HEAD"
160
176
 
177
+ if [[ $DEBUG -eq 1 ]]; then
178
+ echo " remote_path: $remote_path"
179
+ echo " cmd: $remote_cmd"
180
+ fi
181
+
161
182
  local log_basename dest
162
183
  log_basename="$(basename "$log_path")"
163
184
  log_basename="${log_basename%.*}"
164
185
  dest="$SERVICE_DIR/${log_basename}-${node_idx}.log"
165
186
 
166
- ssh -i "$KEY" -o StrictHostKeyChecking=no -o ConnectTimeout=10 \
167
- -l "$ssh_user" "$ssh_host" "$remote_cmd" > "$dest" 2>/dev/null \
168
- && echo " OK: $dest" \
169
- || echo " FAILED: $log_path on $ssh_host"
187
+ local ssh_stderr
188
+ if [[ $DEBUG -eq 1 ]]; then
189
+ ssh_stderr=$(ssh -i "$KEY" -o StrictHostKeyChecking=no -o ConnectTimeout=10 \
190
+ -l "$ssh_user" "$ssh_host" "$remote_cmd" > "$dest" 2>&1 >/dev/null)
191
+ local rc=$?
192
+ if [[ $rc -eq 0 ]]; then
193
+ echo " OK: $dest"
194
+ else
195
+ echo " FAILED: $log_path on $ssh_host"
196
+ [[ -n "$ssh_stderr" ]] && echo " SSH error: $ssh_stderr" >&2
197
+ fi
198
+ else
199
+ ssh -i "$KEY" -o StrictHostKeyChecking=no -o ConnectTimeout=10 \
200
+ -l "$ssh_user" "$ssh_host" "$remote_cmd" > "$dest" 2>/dev/null \
201
+ && echo " OK: $dest" \
202
+ || echo " FAILED: $log_path on $ssh_host"
203
+ fi
170
204
  done
171
205
 
172
206
  ((node_idx++))
@@ -69,6 +69,9 @@ What you can do (tools available):
69
69
  11. list_errors — List recent errors from the state store, optionally filtered by repo or source.
70
70
  e.g. "show all errors today", "what errors hit elprint this week?"
71
71
 
72
+ 12. pull_repo — Run git pull on one or all managed repos.
73
+ e.g. "pull changes for sentinel-1881", "git pull all repos", "update the code"
74
+
72
75
  Tone: direct, professional, like a senior engineer who owns the system.
73
76
  Don't pad responses. Don't say "Great question!" or "Certainly!".
74
77
  If you don't know something, use a tool to find out before saying you don't know.
@@ -229,6 +232,22 @@ _TOOLS = [
229
232
  },
230
233
  },
231
234
  },
235
+ {
236
+ "name": "pull_repo",
237
+ "description": (
238
+ "Run git pull on one or all managed repos to fetch latest changes from GitHub. "
239
+ "Use for: 'pull changes', 'git pull', 'update repo X', 'fetch latest code'."
240
+ ),
241
+ "input_schema": {
242
+ "type": "object",
243
+ "properties": {
244
+ "repo": {
245
+ "type": "string",
246
+ "description": "Repo name to pull (omit to pull all configured repos)",
247
+ },
248
+ },
249
+ },
250
+ },
232
251
  ]
233
252
 
234
253
 
@@ -439,6 +458,30 @@ def _run_tool(name: str, inputs: dict, cfg_loader, store) -> str:
439
458
  pass
440
459
  return json.dumps({"sentinel_commits": results})
441
460
 
461
+ if name == "pull_repo":
462
+ target = inputs.get("repo", "").lower()
463
+ results = []
464
+ for repo_name, repo in cfg_loader.repos.items():
465
+ if target and target not in repo_name.lower():
466
+ continue
467
+ local = Path(repo.local_path)
468
+ if not local.exists():
469
+ results.append({"repo": repo_name, "status": "error", "detail": "local path not found"})
470
+ continue
471
+ try:
472
+ r = subprocess.run(
473
+ ["git", "pull", "--rebase", "origin", repo.branch],
474
+ cwd=str(local), capture_output=True, text=True, timeout=60,
475
+ )
476
+ last_line = r.stdout.strip().splitlines()[-1] if r.stdout.strip() else "already up to date"
477
+ if r.returncode == 0:
478
+ results.append({"repo": repo_name, "status": "ok", "detail": last_line})
479
+ else:
480
+ results.append({"repo": repo_name, "status": "error", "detail": r.stderr.strip()})
481
+ except Exception as e:
482
+ results.append({"repo": repo_name, "status": "error", "detail": str(e)})
483
+ return json.dumps({"results": results})
484
+
442
485
  return json.dumps({"error": f"unknown tool: {name}"})
443
486
 
444
487