@nextclaw/core 0.4.8

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.
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ usage() {
5
+ cat <<'USAGE'
6
+ Usage: find-sessions.sh [-L socket-name|-S socket-path|-A] [-q pattern]
7
+
8
+ List tmux sessions on a socket (default tmux socket if none provided).
9
+
10
+ Options:
11
+ -L, --socket tmux socket name (passed to tmux -L)
12
+ -S, --socket-path tmux socket path (passed to tmux -S)
13
+ -A, --all scan all sockets under NEXTCLAW_TMUX_SOCKET_DIR
14
+ -q, --query case-insensitive substring to filter session names
15
+ -h, --help show this help
16
+ USAGE
17
+ }
18
+
19
+ socket_name=""
20
+ socket_path=""
21
+ query=""
22
+ scan_all=false
23
+ socket_dir="${NEXTCLAW_TMUX_SOCKET_DIR:-${TMPDIR:-/tmp}/nextclaw-tmux-sockets}"
24
+
25
+ while [[ $# -gt 0 ]]; do
26
+ case "$1" in
27
+ -L|--socket) socket_name="${2-}"; shift 2 ;;
28
+ -S|--socket-path) socket_path="${2-}"; shift 2 ;;
29
+ -A|--all) scan_all=true; shift ;;
30
+ -q|--query) query="${2-}"; shift 2 ;;
31
+ -h|--help) usage; exit 0 ;;
32
+ *) echo "Unknown option: $1" >&2; usage; exit 1 ;;
33
+ esac
34
+ done
35
+
36
+ if [[ "$scan_all" == true && ( -n "$socket_name" || -n "$socket_path" ) ]]; then
37
+ echo "Cannot combine --all with -L or -S" >&2
38
+ exit 1
39
+ fi
40
+
41
+ if [[ -n "$socket_name" && -n "$socket_path" ]]; then
42
+ echo "Use either -L or -S, not both" >&2
43
+ exit 1
44
+ fi
45
+
46
+ if ! command -v tmux >/dev/null 2>&1; then
47
+ echo "tmux not found in PATH" >&2
48
+ exit 1
49
+ fi
50
+
51
+ list_sessions() {
52
+ local label="$1"; shift
53
+ local tmux_cmd=(tmux "$@")
54
+
55
+ if ! sessions="$("${tmux_cmd[@]}" list-sessions -F '#{session_name}\t#{session_attached}\t#{session_created_string}' 2>/dev/null)"; then
56
+ echo "No tmux server found on $label" >&2
57
+ return 1
58
+ fi
59
+
60
+ if [[ -n "$query" ]]; then
61
+ sessions="$(printf '%s\n' "$sessions" | grep -i -- "$query" || true)"
62
+ fi
63
+
64
+ if [[ -z "$sessions" ]]; then
65
+ echo "No sessions found on $label"
66
+ return 0
67
+ fi
68
+
69
+ echo "Sessions on $label:"
70
+ printf '%s\n' "$sessions" | while IFS=$'\t' read -r name attached created; do
71
+ attached_label=$([[ "$attached" == "1" ]] && echo "attached" || echo "detached")
72
+ printf ' - %s (%s, started %s)\n' "$name" "$attached_label" "$created"
73
+ done
74
+ }
75
+
76
+ if [[ "$scan_all" == true ]]; then
77
+ if [[ ! -d "$socket_dir" ]]; then
78
+ echo "Socket directory not found: $socket_dir" >&2
79
+ exit 1
80
+ fi
81
+
82
+ shopt -s nullglob
83
+ sockets=("$socket_dir"/*)
84
+ shopt -u nullglob
85
+
86
+ if [[ "${#sockets[@]}" -eq 0 ]]; then
87
+ echo "No sockets found under $socket_dir" >&2
88
+ exit 1
89
+ fi
90
+
91
+ exit_code=0
92
+ for sock in "${sockets[@]}"; do
93
+ if [[ ! -S "$sock" ]]; then
94
+ continue
95
+ fi
96
+ list_sessions "socket path '$sock'" -S "$sock" || exit_code=$?
97
+ done
98
+ exit "$exit_code"
99
+ fi
100
+
101
+ tmux_cmd=(tmux)
102
+ socket_label="default socket"
103
+
104
+ if [[ -n "$socket_name" ]]; then
105
+ tmux_cmd+=(-L "$socket_name")
106
+ socket_label="socket name '$socket_name'"
107
+ elif [[ -n "$socket_path" ]]; then
108
+ tmux_cmd+=(-S "$socket_path")
109
+ socket_label="socket path '$socket_path'"
110
+ fi
111
+
112
+ list_sessions "$socket_label" "${tmux_cmd[@]:1}"
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ usage() {
5
+ cat <<'USAGE'
6
+ Usage: wait-for-text.sh -t target -p pattern [options]
7
+
8
+ Poll a tmux pane for text and exit when found.
9
+
10
+ Options:
11
+ -t, --target tmux target (session:window.pane), required
12
+ -p, --pattern regex pattern to look for, required
13
+ -F, --fixed treat pattern as a fixed string (grep -F)
14
+ -T, --timeout seconds to wait (integer, default: 15)
15
+ -i, --interval poll interval in seconds (default: 0.5)
16
+ -l, --lines number of history lines to inspect (integer, default: 1000)
17
+ -h, --help show this help
18
+ USAGE
19
+ }
20
+
21
+ target=""
22
+ pattern=""
23
+ grep_flag="-E"
24
+ timeout=15
25
+ interval=0.5
26
+ lines=1000
27
+
28
+ while [[ $# -gt 0 ]]; do
29
+ case "$1" in
30
+ -t|--target) target="${2-}"; shift 2 ;;
31
+ -p|--pattern) pattern="${2-}"; shift 2 ;;
32
+ -F|--fixed) grep_flag="-F"; shift ;;
33
+ -T|--timeout) timeout="${2-}"; shift 2 ;;
34
+ -i|--interval) interval="${2-}"; shift 2 ;;
35
+ -l|--lines) lines="${2-}"; shift 2 ;;
36
+ -h|--help) usage; exit 0 ;;
37
+ *) echo "Unknown option: $1" >&2; usage; exit 1 ;;
38
+ esac
39
+ done
40
+
41
+ if [[ -z "$target" || -z "$pattern" ]]; then
42
+ echo "target and pattern are required" >&2
43
+ usage
44
+ exit 1
45
+ fi
46
+
47
+ if ! [[ "$timeout" =~ ^[0-9]+$ ]]; then
48
+ echo "timeout must be an integer number of seconds" >&2
49
+ exit 1
50
+ fi
51
+
52
+ if ! [[ "$lines" =~ ^[0-9]+$ ]]; then
53
+ echo "lines must be an integer" >&2
54
+ exit 1
55
+ fi
56
+
57
+ if ! command -v tmux >/dev/null 2>&1; then
58
+ echo "tmux not found in PATH" >&2
59
+ exit 1
60
+ fi
61
+
62
+ # End time in epoch seconds (integer, good enough for polling)
63
+ start_epoch=$(date +%s)
64
+ deadline=$((start_epoch + timeout))
65
+
66
+ while true; do
67
+ # -J joins wrapped lines, -S uses negative index to read last N lines
68
+ pane_text="$(tmux capture-pane -p -J -t "$target" -S "-${lines}" 2>/dev/null || true)"
69
+
70
+ if printf '%s\n' "$pane_text" | grep $grep_flag -- "$pattern" >/dev/null 2>&1; then
71
+ exit 0
72
+ fi
73
+
74
+ now=$(date +%s)
75
+ if (( now >= deadline )); then
76
+ echo "Timed out after ${timeout}s waiting for pattern: $pattern" >&2
77
+ echo "Last ${lines} lines from $target:" >&2
78
+ printf '%s\n' "$pane_text" >&2
79
+ exit 1
80
+ fi
81
+
82
+ sleep "$interval"
83
+ done
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: weather
3
+ description: Get current weather and forecasts (no API key required).
4
+ homepage: https://wttr.in/:help
5
+ metadata: {"nextclaw":{"emoji":"🌤️","requires":{"bins":["curl"]}}}
6
+ ---
7
+
8
+ # Weather
9
+
10
+ Two free services, no API keys needed.
11
+
12
+ ## wttr.in (primary)
13
+
14
+ Quick one-liner:
15
+ ```bash
16
+ curl -s "wttr.in/London?format=3"
17
+ # Output: London: ⛅️ +8°C
18
+ ```
19
+
20
+ Compact format:
21
+ ```bash
22
+ curl -s "wttr.in/London?format=%l:+%c+%t+%h+%w"
23
+ # Output: London: ⛅️ +8°C 71% ↙5km/h
24
+ ```
25
+
26
+ Full forecast:
27
+ ```bash
28
+ curl -s "wttr.in/London?T"
29
+ ```
30
+
31
+ Format codes: `%c` condition · `%t` temp · `%h` humidity · `%w` wind · `%l` location · `%m` moon
32
+
33
+ Tips:
34
+ - URL-encode spaces: `wttr.in/New+York`
35
+ - Airport codes: `wttr.in/JFK`
36
+ - Units: `?m` (metric) `?u` (USCS)
37
+ - Today only: `?1` · Current only: `?0`
38
+ - PNG: `curl -s "wttr.in/Berlin.png" -o /tmp/weather.png`
39
+
40
+ ## Open-Meteo (fallback, JSON)
41
+
42
+ Free, no key, good for programmatic use:
43
+ ```bash
44
+ curl -s "https://api.open-meteo.com/v1/forecast?latitude=51.5&longitude=-0.12&current_weather=true"
45
+ ```
46
+
47
+ Find coordinates for a city, then query. Returns JSON with temp, windspeed, weathercode.
48
+
49
+ Docs: https://open-meteo.com/en/docs
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@nextclaw/core",
3
+ "version": "0.4.8",
4
+ "private": false,
5
+ "description": "Nextclaw runtime core (agent, channels, providers, config).",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "dependencies": {
17
+ "@larksuiteoapi/node-sdk": "^1.58.0",
18
+ "@slack/socket-mode": "^1.3.3",
19
+ "@slack/web-api": "^7.6.0",
20
+ "chokidar": "^3.6.0",
21
+ "commander": "^12.1.0",
22
+ "cron-parser": "^4.9.0",
23
+ "dingtalk-stream": "^2.1.4",
24
+ "discord.js": "^14.16.3",
25
+ "dotenv": "^16.4.5",
26
+ "imapflow": "^1.0.214",
27
+ "mailparser": "^3.7.1",
28
+ "node-telegram-bot-api": "^0.66.0",
29
+ "nodemailer": "^6.9.15",
30
+ "openai": "^4.74.0",
31
+ "pino": "^9.4.0",
32
+ "qq-official-bot": "^1.0.12",
33
+ "socket.io-client": "^4.7.5",
34
+ "socket.io-msgpack-parser": "^3.0.2",
35
+ "undici": "^6.21.0",
36
+ "ws": "^8.18.0",
37
+ "zod": "^3.23.8",
38
+ "zod-to-json-schema": "^3.23.5"
39
+ },
40
+ "devDependencies": {
41
+ "@types/mailparser": "^3.4.6",
42
+ "@types/node": "^20.17.6",
43
+ "@types/node-telegram-bot-api": "^0.64.8",
44
+ "@types/nodemailer": "^6.4.17",
45
+ "@types/ws": "^8.5.14",
46
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
47
+ "@typescript-eslint/parser": "^7.18.0",
48
+ "eslint": "^8.57.1",
49
+ "eslint-config-prettier": "^9.1.0",
50
+ "prettier": "^3.3.3",
51
+ "tsup": "^8.3.5",
52
+ "tsx": "^4.19.2",
53
+ "typescript": "^5.6.3",
54
+ "vitest": "^2.1.2"
55
+ },
56
+ "scripts": {
57
+ "build": "tsup src/index.ts --format esm --dts --out-dir dist && node scripts/copy-skills.mjs",
58
+ "lint": "eslint .",
59
+ "tsc": "tsc -p tsconfig.json",
60
+ "test": "vitest"
61
+ }
62
+ }