agentus 0.3.3 → 0.3.5
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/README.md +18 -50
- package/README.zh-CN.md +12 -42
- package/bin/agentus.mjs +4 -4
- package/docs/dev/01-dev-loop.md +1 -2
- package/docs/dev/02-verify.md +0 -1
- package/docs/dev/04-recover.md +6 -26
- package/docs/dev/05-agent-driven.md +1 -1
- package/docs/dev/README.md +4 -5
- package/docs/installation.md +76 -30
- package/docs/installation.zh-CN.md +68 -29
- package/package.json +8 -3
- package/packages/server/mock/agent.mjs +38 -0
- package/packages/server/src/acp/registry.ts +28 -1
- package/packages/server/src/acp/session-manager.ts +192 -60
- package/packages/server/src/index.ts +44 -64
- package/packages/server/src/notify/center.ts +118 -26
- package/packages/server/src/notify/types.ts +25 -0
- package/packages/server/src/settings.ts +46 -0
- package/packages/shared/src/index.ts +40 -0
- package/packages/web/dist/assets/index-DQdijjaT.css +32 -0
- package/packages/web/dist/assets/index-eHg6Cshr.js +119 -0
- package/packages/web/dist/index.html +2 -2
- package/packages/web/dist/sw.js +39 -0
- package/packages/web/dist/assets/index-CCvfL56d.css +0 -32
- package/packages/web/dist/assets/index-DCBs8dsw.js +0 -119
- package/scripts/make-cert.sh +0 -101
package/scripts/make-cert.sh
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Issue the certificate Agentus's TLS listener uses — the public hop of a plain TCP tunnel.
|
|
3
|
-
#
|
|
4
|
-
# Structure: a self-signed ROOT (10 years) + a short-lived LEAF signed by it.
|
|
5
|
-
# ca.pem → what a phone/laptop installs ONCE (public; served at /cert.crt)
|
|
6
|
-
# cert.pem/key.pem → what the listener presents; rotate these freely, devices are untouched.
|
|
7
|
-
#
|
|
8
|
-
# Why the split: Apple caps *TLS server certificate* validity (398 days since iOS 15), and one
|
|
9
|
-
# 10-year self-signed cert is exactly the shape a device refuses AFTER the user has been through
|
|
10
|
-
# the whole install dance. A root CA is not a server cert (no cap); the leaf stays under the cap,
|
|
11
|
-
# so yanking it yearly never touches a device.
|
|
12
|
-
#
|
|
13
|
-
# The CN/SAN is the DDNS NAME that is actually typed. A dynamic public IP must NOT be baked in
|
|
14
|
-
# (it changes, and a mismatch is one more warning). localhost/127.0.0.1 ride along so a local
|
|
15
|
-
# curl does not also complain about the name.
|
|
16
|
-
#
|
|
17
|
-
# scripts/make-cert.sh [name] # default: i207f47592.wicp.vip
|
|
18
|
-
# scripts/make-cert.sh --leaf-only # rotate the leaf; the root and installed devices stay
|
|
19
|
-
set -euo pipefail
|
|
20
|
-
|
|
21
|
-
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
22
|
-
# Where the TLS material goes — it MUST be the directory the server reads it from, or the
|
|
23
|
-
# listener silently stays off with a cert sitting next to it. Mirrors the resolution in
|
|
24
|
-
# packages/server/src/index.ts (that file is the source of truth; keep the two in step):
|
|
25
|
-
# 1. $AGENTUS_DATA 2. ~/.agentus (installed default, once it holds anything)
|
|
26
|
-
# 3. <repo>/packages/server/.data (a checkout that predates the install layout)
|
|
27
|
-
REPO_DATA="$ROOT_DIR/packages/server/.data"
|
|
28
|
-
DEFAULT_DATA="$HOME/.agentus"
|
|
29
|
-
if [ -n "${AGENTUS_DATA:-}" ]; then
|
|
30
|
-
DATA_DIR="$AGENTUS_DATA"
|
|
31
|
-
elif [ -d "$DEFAULT_DATA" ] && [ -n "$(ls -A "$DEFAULT_DATA" 2>/dev/null)" ]; then
|
|
32
|
-
DATA_DIR="$DEFAULT_DATA"
|
|
33
|
-
elif [ -d "$REPO_DATA" ] && [ -n "$(ls -A "$REPO_DATA" 2>/dev/null)" ]; then
|
|
34
|
-
DATA_DIR="$REPO_DATA"
|
|
35
|
-
else
|
|
36
|
-
DATA_DIR="$DEFAULT_DATA"
|
|
37
|
-
fi
|
|
38
|
-
if [ ! -d "$DATA_DIR" ]; then
|
|
39
|
-
mkdir -p "$DATA_DIR"
|
|
40
|
-
chmod 700 "$DATA_DIR" # it holds credentials and this key; the server creates it 0700 too
|
|
41
|
-
fi
|
|
42
|
-
OUT="${AGENTUS_TLS_DIR:-$DATA_DIR/tls}"
|
|
43
|
-
LEAF_ONLY=0
|
|
44
|
-
if [ "${1:-}" = "--leaf-only" ]; then LEAF_ONLY=1; shift; fi
|
|
45
|
-
NAME="${1:-${AGENTUS_TLS_NAME:-i207f47592.wicp.vip}}"
|
|
46
|
-
LEAF_DAYS="${AGENTUS_TLS_DAYS:-390}" # < 398 = Apple's cap for server certificates
|
|
47
|
-
ROOT_DAYS="${AGENTUS_TLS_ROOT_DAYS:-3650}"
|
|
48
|
-
mkdir -p "$OUT"
|
|
49
|
-
|
|
50
|
-
if [ "$LEAF_ONLY" = "0" ] || [ ! -f "$OUT/ca.pem" ] || [ ! -f "$OUT/ca.key" ]; then
|
|
51
|
-
cat > "$OUT/ca.cnf" <<EOF
|
|
52
|
-
[req]
|
|
53
|
-
distinguished_name = dn
|
|
54
|
-
x509_extensions = v3
|
|
55
|
-
prompt = no
|
|
56
|
-
|
|
57
|
-
[dn]
|
|
58
|
-
CN = Agentus self-signed root ($NAME)
|
|
59
|
-
|
|
60
|
-
[v3]
|
|
61
|
-
basicConstraints = critical,CA:TRUE,pathlen:0
|
|
62
|
-
keyUsage = critical,keyCertSign,cRLSign
|
|
63
|
-
subjectKeyIdentifier = hash
|
|
64
|
-
EOF
|
|
65
|
-
openssl req -x509 -newkey rsa:2048 -nodes -days "$ROOT_DAYS" \
|
|
66
|
-
-keyout "$OUT/ca.key" -out "$OUT/ca.pem" -config "$OUT/ca.cnf" 2>/dev/null
|
|
67
|
-
rm -f "$OUT/ca.srl"
|
|
68
|
-
echo "root CA -> $OUT/ca.pem (install THIS on devices; it is served at /cert.crt)"
|
|
69
|
-
fi
|
|
70
|
-
|
|
71
|
-
cat > "$OUT/leaf.cnf" <<EOF
|
|
72
|
-
[req]
|
|
73
|
-
distinguished_name = dn
|
|
74
|
-
prompt = no
|
|
75
|
-
|
|
76
|
-
[dn]
|
|
77
|
-
CN = $NAME
|
|
78
|
-
|
|
79
|
-
[v3]
|
|
80
|
-
subjectAltName = DNS:$NAME, DNS:localhost, IP:127.0.0.1
|
|
81
|
-
basicConstraints = critical,CA:FALSE
|
|
82
|
-
keyUsage = critical,digitalSignature,keyEncipherment
|
|
83
|
-
extendedKeyUsage = serverAuth
|
|
84
|
-
EOF
|
|
85
|
-
|
|
86
|
-
openssl req -newkey rsa:2048 -nodes -keyout "$OUT/key.pem" -out "$OUT/leaf.csr" -config "$OUT/leaf.cnf" 2>/dev/null
|
|
87
|
-
openssl x509 -req -in "$OUT/leaf.csr" -CA "$OUT/ca.pem" -CAkey "$OUT/ca.key" -CAcreateserial \
|
|
88
|
-
-days "$LEAF_DAYS" -out "$OUT/cert.pem" -extfile "$OUT/leaf.cnf" -extensions v3 2>/dev/null
|
|
89
|
-
rm -f "$OUT/leaf.csr"
|
|
90
|
-
|
|
91
|
-
chmod 600 "$OUT/key.pem" "$OUT/ca.key"
|
|
92
|
-
chmod 644 "$OUT/cert.pem" "$OUT/ca.pem" "$OUT/ca.cnf" "$OUT/leaf.cnf"
|
|
93
|
-
|
|
94
|
-
echo "leaf -> $OUT/cert.pem (what the listener serves; rotates without touching devices)"
|
|
95
|
-
openssl x509 -in "$OUT/cert.pem" -noout -subject -issuer -dates
|
|
96
|
-
# LibreSSL has no `x509 -ext`; read the SAN out of -text instead.
|
|
97
|
-
openssl x509 -in "$OUT/cert.pem" -noout -text | grep -A1 "Subject Alternative Name" || true
|
|
98
|
-
openssl x509 -in "$OUT/ca.pem" -noout -subject -dates
|
|
99
|
-
echo
|
|
100
|
-
echo "restart the server (or let tsx watch reload); devices install the root once from"
|
|
101
|
-
echo " https://$NAME:<tls-port>/cert.crt"
|