network-ai 3.3.0 → 3.3.2
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/LICENSE +21 -21
- package/QUICKSTART.md +260 -260
- package/README.md +783 -783
- package/SKILL.md +578 -578
- package/dist/lib/locked-blackboard.js +48 -48
- package/dist/lib/swarm-utils.js +24 -24
- package/package.json +85 -85
- package/scripts/blackboard.py +852 -852
- package/scripts/check_permission.py +699 -699
- package/scripts/revoke_token.py +243 -243
- package/scripts/swarm_guard.py +1136 -1136
- package/scripts/validate_token.py +97 -97
- package/types/agent-adapter.d.ts +244 -244
- package/types/openclaw-core.d.ts +52 -52
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Validate Grant Token
|
|
4
|
-
|
|
5
|
-
Check if a permission grant token is valid and not expired.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
python validate_token.py TOKEN
|
|
9
|
-
|
|
10
|
-
Example:
|
|
11
|
-
python validate_token.py grant_a1b2c3d4e5f6
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
import argparse
|
|
15
|
-
import json
|
|
16
|
-
import sys
|
|
17
|
-
from datetime import datetime, timezone
|
|
18
|
-
from pathlib import Path
|
|
19
|
-
from typing import Any
|
|
20
|
-
|
|
21
|
-
GRANTS_FILE = Path(__file__).parent.parent / "data" / "active_grants.json"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def validate_token(token: str) -> dict[str, Any]:
|
|
25
|
-
"""Validate a grant token and return its details."""
|
|
26
|
-
if not GRANTS_FILE.exists():
|
|
27
|
-
return {
|
|
28
|
-
"valid": False,
|
|
29
|
-
"reason": "No grants file found"
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try:
|
|
33
|
-
grants = json.loads(GRANTS_FILE.read_text())
|
|
34
|
-
except json.JSONDecodeError:
|
|
35
|
-
return {
|
|
36
|
-
"valid": False,
|
|
37
|
-
"reason": "Invalid grants file"
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if token not in grants:
|
|
41
|
-
return {
|
|
42
|
-
"valid": False,
|
|
43
|
-
"reason": "Token not found"
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
grant = grants[token]
|
|
47
|
-
|
|
48
|
-
# Check expiration
|
|
49
|
-
expires_at = grant.get("expires_at")
|
|
50
|
-
if expires_at:
|
|
51
|
-
try:
|
|
52
|
-
expiry = datetime.fromisoformat(str(expires_at).replace("Z", "+00:00"))
|
|
53
|
-
now = datetime.now(timezone.utc)
|
|
54
|
-
|
|
55
|
-
if now > expiry:
|
|
56
|
-
return {
|
|
57
|
-
"valid": False,
|
|
58
|
-
"reason": "Token has expired",
|
|
59
|
-
"expired_at": expires_at
|
|
60
|
-
}
|
|
61
|
-
except Exception:
|
|
62
|
-
pass # unparseable expiry field — treat token as non-expired
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
"valid": True,
|
|
66
|
-
"grant": grant
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def main():
|
|
71
|
-
parser = argparse.ArgumentParser(description="Validate a permission grant token")
|
|
72
|
-
parser.add_argument("token", help="Grant token to validate")
|
|
73
|
-
parser.add_argument("--json", action="store_true", help="Output as JSON")
|
|
74
|
-
|
|
75
|
-
args = parser.parse_args()
|
|
76
|
-
result = validate_token(args.token)
|
|
77
|
-
|
|
78
|
-
if args.json:
|
|
79
|
-
print(json.dumps(result, indent=2))
|
|
80
|
-
else:
|
|
81
|
-
if result["valid"]:
|
|
82
|
-
grant = result["grant"]
|
|
83
|
-
print("✅ Token is VALID")
|
|
84
|
-
print(f" Agent: {grant.get('agent_id')}")
|
|
85
|
-
print(f" Resource: {grant.get('resource_type')}")
|
|
86
|
-
print(f" Scope: {grant.get('scope', 'N/A')}")
|
|
87
|
-
print(f" Expires: {grant.get('expires_at')}")
|
|
88
|
-
print(f" Restrictions: {', '.join(grant.get('restrictions', []))}")
|
|
89
|
-
else:
|
|
90
|
-
print("❌ Token is INVALID")
|
|
91
|
-
print(f" Reason: {result.get('reason')}")
|
|
92
|
-
|
|
93
|
-
sys.exit(0 if result["valid"] else 1)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if __name__ == "__main__":
|
|
97
|
-
main()
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Validate Grant Token
|
|
4
|
+
|
|
5
|
+
Check if a permission grant token is valid and not expired.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
python validate_token.py TOKEN
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
python validate_token.py grant_a1b2c3d4e5f6
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
from datetime import datetime, timezone
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
GRANTS_FILE = Path(__file__).parent.parent / "data" / "active_grants.json"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def validate_token(token: str) -> dict[str, Any]:
|
|
25
|
+
"""Validate a grant token and return its details."""
|
|
26
|
+
if not GRANTS_FILE.exists():
|
|
27
|
+
return {
|
|
28
|
+
"valid": False,
|
|
29
|
+
"reason": "No grants file found"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
grants = json.loads(GRANTS_FILE.read_text())
|
|
34
|
+
except json.JSONDecodeError:
|
|
35
|
+
return {
|
|
36
|
+
"valid": False,
|
|
37
|
+
"reason": "Invalid grants file"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if token not in grants:
|
|
41
|
+
return {
|
|
42
|
+
"valid": False,
|
|
43
|
+
"reason": "Token not found"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
grant = grants[token]
|
|
47
|
+
|
|
48
|
+
# Check expiration
|
|
49
|
+
expires_at = grant.get("expires_at")
|
|
50
|
+
if expires_at:
|
|
51
|
+
try:
|
|
52
|
+
expiry = datetime.fromisoformat(str(expires_at).replace("Z", "+00:00"))
|
|
53
|
+
now = datetime.now(timezone.utc)
|
|
54
|
+
|
|
55
|
+
if now > expiry:
|
|
56
|
+
return {
|
|
57
|
+
"valid": False,
|
|
58
|
+
"reason": "Token has expired",
|
|
59
|
+
"expired_at": expires_at
|
|
60
|
+
}
|
|
61
|
+
except Exception:
|
|
62
|
+
pass # unparseable expiry field — treat token as non-expired
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
"valid": True,
|
|
66
|
+
"grant": grant
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def main():
|
|
71
|
+
parser = argparse.ArgumentParser(description="Validate a permission grant token")
|
|
72
|
+
parser.add_argument("token", help="Grant token to validate")
|
|
73
|
+
parser.add_argument("--json", action="store_true", help="Output as JSON")
|
|
74
|
+
|
|
75
|
+
args = parser.parse_args()
|
|
76
|
+
result = validate_token(args.token)
|
|
77
|
+
|
|
78
|
+
if args.json:
|
|
79
|
+
print(json.dumps(result, indent=2))
|
|
80
|
+
else:
|
|
81
|
+
if result["valid"]:
|
|
82
|
+
grant = result["grant"]
|
|
83
|
+
print("✅ Token is VALID")
|
|
84
|
+
print(f" Agent: {grant.get('agent_id')}")
|
|
85
|
+
print(f" Resource: {grant.get('resource_type')}")
|
|
86
|
+
print(f" Scope: {grant.get('scope', 'N/A')}")
|
|
87
|
+
print(f" Expires: {grant.get('expires_at')}")
|
|
88
|
+
print(f" Restrictions: {', '.join(grant.get('restrictions', []))}")
|
|
89
|
+
else:
|
|
90
|
+
print("❌ Token is INVALID")
|
|
91
|
+
print(f" Reason: {result.get('reason')}")
|
|
92
|
+
|
|
93
|
+
sys.exit(0 if result["valid"] else 1)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if __name__ == "__main__":
|
|
97
|
+
main()
|