owpenwork 0.1.1

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/install.sh ADDED
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ OWPENBOT_REF="${OWPENBOT_REF:-dev}"
5
+ OWPENBOT_REPO="${OWPENBOT_REPO:-https://github.com/different-ai/openwork.git}"
6
+ OWPENBOT_INSTALL_DIR="${OWPENBOT_INSTALL_DIR:-$HOME/.owpenbot/openwork}"
7
+ OWPENBOT_BIN_DIR="${OWPENBOT_BIN_DIR:-$HOME/.local/bin}"
8
+
9
+ usage() {
10
+ cat <<'EOF'
11
+ Owpenbot installer (WhatsApp-first)
12
+
13
+ Environment variables:
14
+ OWPENBOT_INSTALL_DIR Install directory (default: ~/.owpenbot/openwork)
15
+ OWPENBOT_REPO Git repo (default: https://github.com/different-ai/openwork.git)
16
+ OWPENBOT_REF Git ref/branch (default: dev)
17
+ OWPENBOT_BIN_DIR Bin directory for owpenbot shim (default: ~/.local/bin)
18
+
19
+ Example:
20
+ OWPENBOT_INSTALL_DIR=~/owpenbot curl -fsSL https://raw.githubusercontent.com/different-ai/openwork/dev/packages/owpenbot/install.sh | bash
21
+ EOF
22
+ }
23
+
24
+ if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
25
+ usage
26
+ exit 0
27
+ fi
28
+
29
+ require_bin() {
30
+ if ! command -v "$1" >/dev/null 2>&1; then
31
+ echo "Missing $1. Please install it and retry." >&2
32
+ exit 1
33
+ fi
34
+ }
35
+
36
+ require_bin git
37
+ require_bin node
38
+
39
+ if ! command -v pnpm >/dev/null 2>&1; then
40
+ if command -v corepack >/dev/null 2>&1; then
41
+ corepack enable >/dev/null 2>&1 || true
42
+ corepack prepare pnpm@10.27.0 --activate
43
+ else
44
+ echo "pnpm is required. Install pnpm or enable corepack, then retry." >&2
45
+ exit 1
46
+ fi
47
+ fi
48
+
49
+ if [[ -d "$OWPENBOT_INSTALL_DIR/.git" ]]; then
50
+ echo "Updating owpenbot source in $OWPENBOT_INSTALL_DIR"
51
+ git -C "$OWPENBOT_INSTALL_DIR" fetch origin --prune
52
+ if git -C "$OWPENBOT_INSTALL_DIR" show-ref --verify --quiet "refs/remotes/origin/$OWPENBOT_REF"; then
53
+ git -C "$OWPENBOT_INSTALL_DIR" checkout -B "$OWPENBOT_REF" "origin/$OWPENBOT_REF"
54
+ git -C "$OWPENBOT_INSTALL_DIR" pull --ff-only origin "$OWPENBOT_REF"
55
+ else
56
+ git -C "$OWPENBOT_INSTALL_DIR" checkout -f
57
+ git -C "$OWPENBOT_INSTALL_DIR" pull --ff-only
58
+ fi
59
+ else
60
+ echo "Cloning owpenbot source to $OWPENBOT_INSTALL_DIR"
61
+ mkdir -p "$OWPENBOT_INSTALL_DIR"
62
+ git clone --depth 1 "$OWPENBOT_REPO" "$OWPENBOT_INSTALL_DIR"
63
+ if git -C "$OWPENBOT_INSTALL_DIR" show-ref --verify --quiet "refs/remotes/origin/$OWPENBOT_REF"; then
64
+ git -C "$OWPENBOT_INSTALL_DIR" checkout -B "$OWPENBOT_REF" "origin/$OWPENBOT_REF"
65
+ fi
66
+ fi
67
+
68
+ if [[ ! -d "$OWPENBOT_INSTALL_DIR/packages/owpenbot" ]]; then
69
+ echo "owpenbot package not found on ref '$OWPENBOT_REF'. Trying dev/main..." >&2
70
+ git -C "$OWPENBOT_INSTALL_DIR" fetch origin --prune
71
+ if git -C "$OWPENBOT_INSTALL_DIR" show-ref --verify --quiet refs/remotes/origin/dev; then
72
+ git -C "$OWPENBOT_INSTALL_DIR" checkout -B dev origin/dev
73
+ elif git -C "$OWPENBOT_INSTALL_DIR" show-ref --verify --quiet refs/remotes/origin/main; then
74
+ git -C "$OWPENBOT_INSTALL_DIR" checkout -B main origin/main
75
+ fi
76
+ fi
77
+
78
+ if [[ ! -d "$OWPENBOT_INSTALL_DIR/packages/owpenbot" ]]; then
79
+ echo "owpenbot package not found after checkout. Aborting." >&2
80
+ exit 1
81
+ fi
82
+
83
+ echo "Installing dependencies..."
84
+ pnpm -C "$OWPENBOT_INSTALL_DIR" install
85
+
86
+ echo "Building owpenbot..."
87
+ pnpm -C "$OWPENBOT_INSTALL_DIR/packages/owpenbot" build
88
+
89
+ ENV_PATH="$OWPENBOT_INSTALL_DIR/packages/owpenbot/.env"
90
+ ENV_EXAMPLE="$OWPENBOT_INSTALL_DIR/packages/owpenbot/.env.example"
91
+ if [[ ! -f "$ENV_PATH" ]]; then
92
+ if [[ -f "$ENV_EXAMPLE" ]]; then
93
+ cp "$ENV_EXAMPLE" "$ENV_PATH"
94
+ echo "Created $ENV_PATH"
95
+ else
96
+ cat <<EOF > "$ENV_PATH"
97
+ OPENCODE_URL=http://127.0.0.1:4096
98
+ OPENCODE_DIRECTORY=
99
+ WHATSAPP_AUTH_DIR=~/.owpenbot/whatsapp
100
+ EOF
101
+ echo "Created $ENV_PATH (minimal)"
102
+ fi
103
+ fi
104
+
105
+ mkdir -p "$OWPENBOT_BIN_DIR"
106
+ cat <<EOF > "$OWPENBOT_BIN_DIR/owpenbot"
107
+ #!/usr/bin/env bash
108
+ set -euo pipefail
109
+ node "$OWPENBOT_INSTALL_DIR/packages/owpenbot/dist/cli.js" "$@"
110
+ EOF
111
+ chmod 755 "$OWPENBOT_BIN_DIR/owpenbot"
112
+
113
+ if ! echo ":$PATH:" | grep -q ":$OWPENBOT_BIN_DIR:"; then
114
+ shell_name="$(basename "${SHELL:-}" 2>/dev/null || true)"
115
+ case "$shell_name" in
116
+ fish)
117
+ echo "Add to PATH (fish): set -Ux PATH $OWPENBOT_BIN_DIR \$PATH"
118
+ ;;
119
+ zsh)
120
+ echo "Add to PATH (zsh): echo 'export PATH=\"$OWPENBOT_BIN_DIR:\$PATH\"' >> ~/.zshrc"
121
+ ;;
122
+ bash)
123
+ echo "Add to PATH (bash): echo 'export PATH=\"$OWPENBOT_BIN_DIR:\$PATH\"' >> ~/.bashrc"
124
+ ;;
125
+ *)
126
+ echo "Add to PATH: export PATH=\"$OWPENBOT_BIN_DIR:\$PATH\""
127
+ ;;
128
+ esac
129
+ fi
130
+
131
+ cat <<EOF
132
+
133
+ Owpenbot installed.
134
+
135
+ Next steps:
136
+ 1) Edit $ENV_PATH (optional)
137
+ 2) Run setup: owpenbot setup
138
+ 3) Link WhatsApp: owpenbot whatsapp login
139
+ 4) Start bridge: owpenbot start
140
+
141
+ Owpenbot will print a QR code during login and keep the session alive.
142
+ EOF
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "owpenwork",
3
+ "version": "0.1.1",
4
+ "description": "WhatsApp bridge for a running OpenCode server",
5
+ "private": false,
6
+ "type": "module",
7
+ "bin": {
8
+ "owpenwork": "dist/cli.js",
9
+ "owpenbot": "dist/cli.js"
10
+ },
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/different-ai/openwork.git",
15
+ "directory": "packages/owpenbot"
16
+ },
17
+ "keywords": [
18
+ "opencode",
19
+ "whatsapp",
20
+ "bridge",
21
+ "bot"
22
+ ],
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ ".env.example",
27
+ "install.sh"
28
+ ],
29
+ "scripts": {
30
+ "dev": "tsx src/cli.ts",
31
+ "build": "tsc -p tsconfig.json",
32
+ "start": "node dist/cli.js start",
33
+ "whatsapp:login": "node dist/cli.js whatsapp login",
34
+ "pairing-code": "node dist/cli.js pairing-code",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit",
36
+ "setup": "node scripts/setup.mjs",
37
+ "test:unit": "pnpm build && node --test test/*.test.js",
38
+ "test:smoke": "node scripts/smoke.mjs"
39
+ },
40
+ "dependencies": {
41
+ "@opencode-ai/sdk": "^1.1.19",
42
+ "@whiskeysockets/baileys": "7.0.0-rc.9",
43
+ "better-sqlite3": "^11.7.0",
44
+ "commander": "^12.1.0",
45
+ "dotenv": "^16.4.7",
46
+ "grammy": "^1.39.3",
47
+ "pino": "^9.6.0",
48
+ "qrcode-terminal": "^0.12.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/better-sqlite3": "^7.6.12",
52
+ "@types/node": "^22.10.2",
53
+ "@types/qrcode-terminal": "^0.12.0",
54
+ "tsx": "^4.19.2",
55
+ "typescript": "^5.6.3"
56
+ }
57
+ }