@shadowob/connector 1.1.3-dev.271 → 1.1.4
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 +33 -7
- package/dist/cli.js +593 -81
- package/dist/index.cjs +52 -18
- package/dist/index.js +50 -18
- package/hermes-shadowob-plugin/README.md +2 -2
- package/hermes-shadowob-plugin/adapter.py +124 -32
- package/hermes-shadowob-plugin/shadow_sdk.py +33 -2
- package/hermes-shadowob-plugin/tests/test_adapter_env.py +102 -0
- package/package.json +6 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
import sys
|
|
3
|
+
import asyncio
|
|
3
4
|
|
|
4
5
|
ROOT = Path(__file__).resolve().parents[1]
|
|
5
6
|
if str(ROOT) not in sys.path:
|
|
@@ -83,6 +84,107 @@ def test_remote_config_entries_filter_listen_policy():
|
|
|
83
84
|
assert entries[0][1]['serverId'] == 'server-1'
|
|
84
85
|
|
|
85
86
|
|
|
87
|
+
def test_resolve_channels_creates_owner_dm_home_channel_when_empty():
|
|
88
|
+
class FakeClient:
|
|
89
|
+
async def get_agent_config(self, agent_id):
|
|
90
|
+
assert agent_id == 'agent-1'
|
|
91
|
+
return {
|
|
92
|
+
'agentId': 'agent-1',
|
|
93
|
+
'botUserId': 'bot-1',
|
|
94
|
+
'ownerId': 'owner-1',
|
|
95
|
+
'servers': [],
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async def create_direct_channel(self, user_id):
|
|
99
|
+
assert user_id == 'owner-1'
|
|
100
|
+
return {'id': 'dm-owner', 'kind': 'dm', 'name': 'Owner DM'}
|
|
101
|
+
|
|
102
|
+
class FakeSocket:
|
|
103
|
+
def __init__(self):
|
|
104
|
+
self.joined = []
|
|
105
|
+
|
|
106
|
+
async def join_channel(self, channel_id):
|
|
107
|
+
self.joined.append(channel_id)
|
|
108
|
+
return {'ok': True}
|
|
109
|
+
|
|
110
|
+
instance = adapter.ShadowOBAdapter.__new__(adapter.ShadowOBAdapter)
|
|
111
|
+
instance.client = FakeClient()
|
|
112
|
+
instance.socket = FakeSocket()
|
|
113
|
+
instance._agent_id = 'agent-1'
|
|
114
|
+
instance._bot_user_id = 'bot-1'
|
|
115
|
+
instance._slash_commands = []
|
|
116
|
+
instance._channel_ids = []
|
|
117
|
+
instance._configured_channel_ids = set()
|
|
118
|
+
instance._remote_channel_ids = set()
|
|
119
|
+
instance._channel_policies = {}
|
|
120
|
+
instance._remote_config = None
|
|
121
|
+
instance._channel_cache = {}
|
|
122
|
+
instance._server_ids = []
|
|
123
|
+
instance._auto_discover = False
|
|
124
|
+
|
|
125
|
+
asyncio.run(instance._resolve_channels(sync_socket=True))
|
|
126
|
+
|
|
127
|
+
assert instance._channel_ids == ['dm-owner']
|
|
128
|
+
assert instance._channel_cache['dm-owner']['kind'] == 'dm'
|
|
129
|
+
assert instance.socket.joined == ['dm-owner']
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_member_added_refreshes_remote_config_and_joins_channel():
|
|
133
|
+
class FakeClient:
|
|
134
|
+
async def get_agent_config(self, agent_id):
|
|
135
|
+
assert agent_id == 'agent-1'
|
|
136
|
+
return {
|
|
137
|
+
'agentId': 'agent-1',
|
|
138
|
+
'botUserId': 'bot-1',
|
|
139
|
+
'servers': [
|
|
140
|
+
{
|
|
141
|
+
'id': 'server-1',
|
|
142
|
+
'name': 'Server',
|
|
143
|
+
'channels': [
|
|
144
|
+
{
|
|
145
|
+
'id': 'channel-1',
|
|
146
|
+
'name': 'general',
|
|
147
|
+
'policy': {'listen': True, 'reply': True},
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async def get_channel(self, channel_id):
|
|
155
|
+
return {'id': channel_id, 'kind': 'channel', 'name': 'general'}
|
|
156
|
+
|
|
157
|
+
class FakeSocket:
|
|
158
|
+
def __init__(self):
|
|
159
|
+
self.joined = []
|
|
160
|
+
|
|
161
|
+
async def join_channel(self, channel_id):
|
|
162
|
+
self.joined.append(channel_id)
|
|
163
|
+
return {'ok': True}
|
|
164
|
+
|
|
165
|
+
instance = adapter.ShadowOBAdapter.__new__(adapter.ShadowOBAdapter)
|
|
166
|
+
instance.client = FakeClient()
|
|
167
|
+
instance.socket = FakeSocket()
|
|
168
|
+
instance._agent_id = 'agent-1'
|
|
169
|
+
instance._bot_user_id = 'bot-1'
|
|
170
|
+
instance._slash_commands = []
|
|
171
|
+
instance._channel_ids = []
|
|
172
|
+
instance._configured_channel_ids = set()
|
|
173
|
+
instance._remote_channel_ids = set()
|
|
174
|
+
instance._channel_policies = {}
|
|
175
|
+
instance._remote_config = None
|
|
176
|
+
instance._channel_cache = {}
|
|
177
|
+
instance._server_ids = []
|
|
178
|
+
instance._auto_discover = False
|
|
179
|
+
instance._catchup_minutes = 0
|
|
180
|
+
|
|
181
|
+
asyncio.run(instance._on_channel_member_added({'channelId': 'channel-1'}))
|
|
182
|
+
|
|
183
|
+
assert instance._channel_ids == ['channel-1']
|
|
184
|
+
assert instance._channel_policies['channel-1']['reply'] is True
|
|
185
|
+
assert instance.socket.joined == ['channel-1']
|
|
186
|
+
|
|
187
|
+
|
|
86
188
|
def test_slash_command_prompt_and_interactive_block():
|
|
87
189
|
commands = [
|
|
88
190
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shadowob/connector",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Shadow connector helpers for OpenClaw, Hermes Agent, and cc-connect",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,6 +47,11 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"dotenv": "^17.4.2",
|
|
52
|
+
"smol-toml": "^1.6.1",
|
|
53
|
+
"yaml": "^2.8.4"
|
|
54
|
+
},
|
|
50
55
|
"scripts": {
|
|
51
56
|
"build": "tsup",
|
|
52
57
|
"dev": "tsup --watch",
|