identity-agnostic-worker 0.1.0__tar.gz

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,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: identity-agnostic-worker
3
+ Version: 0.1.0
4
+ Summary: Identity-agnostic worker client: register to a broker, receive tasks, stream results back.
5
+ Author: Rexllnia
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Rexllnia/identity-agnostic-worker
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: websockets>=12
11
+ Provides-Extra: dev
12
+ Requires-Dist: build; extra == "dev"
13
+ Requires-Dist: twine; extra == "dev"
14
+
15
+ # identity-agnostic-worker
16
+
17
+ A minimal Python client for AI workers that connect to an
18
+ [identity-agnostic broker](https://github.com/Rexllnia/identity-agnostic-broker).
19
+
20
+ 一个极简的 Python 客户端,用于让 AI 员工(worker)连接到
21
+ [identity-agnostic broker](https://github.com/Rexllnia/identity-agnostic-broker)。
22
+
23
+ A **worker** registers itself to a broker, receives one task at a time, streams
24
+ back the result in chunks, and marks the end of the stream. The worker never
25
+ needs to know who sent the task or who will receive the result — the broker
26
+ takes care of matching and routing.
27
+
28
+ **Worker** 向 broker 注册,一次接收一个任务,把结果分片流式回传,最后标记流结束。
29
+ worker 不需要知道任务是谁发的,也不需要知道结果发给谁——匹配和路由全部由 broker 负责。
30
+
31
+ This package only contains the worker-side client. It depends on
32
+ `websockets` and nothing else.
33
+
34
+ 本包只包含 worker 端客户端,只依赖 `websockets`,不拖其他依赖。
35
+
36
+ ---
37
+
38
+ ## Install / 安装
39
+
40
+ ```bash
41
+ pip install identity-agnostic-worker
42
+
43
+
44
+ Requires Python 3.10+.
45
+
46
+ 需要 Python 3.10 及以上。
47
+
48
+ Quick start / 快速开始
49
+ python
50
+ import asyncio
51
+ from identity_agnostic_worker import WorkerClient
52
+
53
+
54
+ async def process(text: str):
55
+ """你的 AI / Playwright 逻辑:把 text 变成一段一段的结果。"""
56
+ for ch in text:
57
+ yield ch
58
+
59
+
60
+ async def main():
61
+ client = await WorkerClient.register("ws://127.0.0.1:9000/ws")
62
+
63
+ while True:
64
+ text = await client.recv()
65
+ if text is None:
66
+ break # 连接断开 / connection closed
67
+
68
+ async for chunk in process(text):
69
+ await client.send(chunk)
70
+
71
+ await client.send(None) # 流结束 / end of stream
72
+
73
+
74
+ asyncio.run(main())
75
+ register() 不传参数时,默认连 ws://127.0.0.1:9000/ws。
76
+
77
+ When called without arguments, register() connects to
78
+ ws://127.0.0.1:9000/ws by default.
79
+
80
+ API
81
+ await WorkerClient.register(broker_url="ws://127.0.0.1:9000/ws") -> WorkerClient
82
+ 向 broker 注册,返回一个 WorkerClient。注册成功后,broker 会把这个 worker
83
+ 放进待命池,有匹配的任务时派给它。
84
+
85
+ Register to the broker and return a WorkerClient. Once registered, the
86
+ broker puts this worker on its bench and dispatches matching tasks to it.
87
+
88
+ await client.recv() -> str | None
89
+ 阻塞等待一条用户消息。
90
+
91
+ Block until a user message arrives.
92
+
93
+ 返回 str:新的任务文本,可以开始处理。
94
+ Returns str: a new task text, ready to be processed.
95
+
96
+ 返回 None:与 broker 的连接已断开,应退出循环。
97
+ Returns None: the connection to the broker is closed; exit the loop.
98
+
99
+ await client.send(chunk: str | None)
100
+ 把结果分片发回 broker。
101
+
102
+ Send one chunk of the result back to the broker.
103
+
104
+ 传 str:发送一个 chunk。空字符串 "" 是合法 chunk。
105
+ Pass str: send a chunk. An empty string "" is a valid chunk.
106
+
107
+ 传 None:表示这一轮任务结束。
108
+ Pass None: marks the end of this task.
109
+
110
+ await client.close()
111
+ 主动关闭连接。通常在 finally 里调用,保证异常退出时也能释放连接。
112
+
113
+ Close the connection explicitly. Usually called in a finally block so the
114
+ connection is released even on errors.
115
+
116
+ Protocol / 协议
117
+ worker 与 broker 之间用 WebSocket + JSON 通信,四个消息类型:
118
+
119
+ Worker and broker communicate over WebSocket + JSON with four message types:
120
+
121
+ 方向 Direction 消息 Message
122
+ worker → broker {"type": "register"}
123
+ broker → worker {"type": "registered", "sid": "..."}
124
+ broker → worker {"type": "message", "request_id": "...", "text": "..."}
125
+ worker → broker {"type": "chunk", "request_id": "...", "text": "..."}
126
+ worker → broker {"type": "end", "request_id": "..."}
127
+ 一个 worker 同一时间只处理一条任务。收到 message 后,用同一个 request_id
128
+ 发 chunk,最后发 end。
129
+
130
+ A worker handles one task at a time. After receiving message, send chunk
131
+ with the same request_id, and finish with end.
132
+
133
+ 和 broker 的关系 / Relation to the broker
134
+ text
135
+ openai-compatible client
136
+ │ POST /send
137
+ ▼
138
+ identity-agnostic-broker ← 匹配任务和 worker / matches tasks to workers
139
+ │ WS: message / chunk / end
140
+ ▼
141
+ identity-agnostic-worker ← 你在这里 / you are here
142
+ │
143
+ ▼
144
+ 你的 AI 逻辑(Playwright、本地模型、任何能产出流式文本的东西)
145
+ Your AI logic (Playwright, local model, anything that streams text)
146
+ worker 不保存任何路由状态,也不关心发送者或接收者的身份。所有匹配逻辑都在
147
+ broker 里,worker 只负责“收任务 → 干活 → 回流”。
148
+
149
+ The worker keeps no routing state and does not care about sender or receiver
150
+ identity. All matching lives in the broker; the worker only does
151
+ "receive task → work → stream back".
152
+
153
+ License
154
+ MIT
@@ -0,0 +1,140 @@
1
+ # identity-agnostic-worker
2
+
3
+ A minimal Python client for AI workers that connect to an
4
+ [identity-agnostic broker](https://github.com/Rexllnia/identity-agnostic-broker).
5
+
6
+ 一个极简的 Python 客户端,用于让 AI 员工(worker)连接到
7
+ [identity-agnostic broker](https://github.com/Rexllnia/identity-agnostic-broker)。
8
+
9
+ A **worker** registers itself to a broker, receives one task at a time, streams
10
+ back the result in chunks, and marks the end of the stream. The worker never
11
+ needs to know who sent the task or who will receive the result — the broker
12
+ takes care of matching and routing.
13
+
14
+ **Worker** 向 broker 注册,一次接收一个任务,把结果分片流式回传,最后标记流结束。
15
+ worker 不需要知道任务是谁发的,也不需要知道结果发给谁——匹配和路由全部由 broker 负责。
16
+
17
+ This package only contains the worker-side client. It depends on
18
+ `websockets` and nothing else.
19
+
20
+ 本包只包含 worker 端客户端,只依赖 `websockets`,不拖其他依赖。
21
+
22
+ ---
23
+
24
+ ## Install / 安装
25
+
26
+ ```bash
27
+ pip install identity-agnostic-worker
28
+
29
+
30
+ Requires Python 3.10+.
31
+
32
+ 需要 Python 3.10 及以上。
33
+
34
+ Quick start / 快速开始
35
+ python
36
+ import asyncio
37
+ from identity_agnostic_worker import WorkerClient
38
+
39
+
40
+ async def process(text: str):
41
+ """你的 AI / Playwright 逻辑:把 text 变成一段一段的结果。"""
42
+ for ch in text:
43
+ yield ch
44
+
45
+
46
+ async def main():
47
+ client = await WorkerClient.register("ws://127.0.0.1:9000/ws")
48
+
49
+ while True:
50
+ text = await client.recv()
51
+ if text is None:
52
+ break # 连接断开 / connection closed
53
+
54
+ async for chunk in process(text):
55
+ await client.send(chunk)
56
+
57
+ await client.send(None) # 流结束 / end of stream
58
+
59
+
60
+ asyncio.run(main())
61
+ register() 不传参数时,默认连 ws://127.0.0.1:9000/ws。
62
+
63
+ When called without arguments, register() connects to
64
+ ws://127.0.0.1:9000/ws by default.
65
+
66
+ API
67
+ await WorkerClient.register(broker_url="ws://127.0.0.1:9000/ws") -> WorkerClient
68
+ 向 broker 注册,返回一个 WorkerClient。注册成功后,broker 会把这个 worker
69
+ 放进待命池,有匹配的任务时派给它。
70
+
71
+ Register to the broker and return a WorkerClient. Once registered, the
72
+ broker puts this worker on its bench and dispatches matching tasks to it.
73
+
74
+ await client.recv() -> str | None
75
+ 阻塞等待一条用户消息。
76
+
77
+ Block until a user message arrives.
78
+
79
+ 返回 str:新的任务文本,可以开始处理。
80
+ Returns str: a new task text, ready to be processed.
81
+
82
+ 返回 None:与 broker 的连接已断开,应退出循环。
83
+ Returns None: the connection to the broker is closed; exit the loop.
84
+
85
+ await client.send(chunk: str | None)
86
+ 把结果分片发回 broker。
87
+
88
+ Send one chunk of the result back to the broker.
89
+
90
+ 传 str:发送一个 chunk。空字符串 "" 是合法 chunk。
91
+ Pass str: send a chunk. An empty string "" is a valid chunk.
92
+
93
+ 传 None:表示这一轮任务结束。
94
+ Pass None: marks the end of this task.
95
+
96
+ await client.close()
97
+ 主动关闭连接。通常在 finally 里调用,保证异常退出时也能释放连接。
98
+
99
+ Close the connection explicitly. Usually called in a finally block so the
100
+ connection is released even on errors.
101
+
102
+ Protocol / 协议
103
+ worker 与 broker 之间用 WebSocket + JSON 通信,四个消息类型:
104
+
105
+ Worker and broker communicate over WebSocket + JSON with four message types:
106
+
107
+ 方向 Direction 消息 Message
108
+ worker → broker {"type": "register"}
109
+ broker → worker {"type": "registered", "sid": "..."}
110
+ broker → worker {"type": "message", "request_id": "...", "text": "..."}
111
+ worker → broker {"type": "chunk", "request_id": "...", "text": "..."}
112
+ worker → broker {"type": "end", "request_id": "..."}
113
+ 一个 worker 同一时间只处理一条任务。收到 message 后,用同一个 request_id
114
+ 发 chunk,最后发 end。
115
+
116
+ A worker handles one task at a time. After receiving message, send chunk
117
+ with the same request_id, and finish with end.
118
+
119
+ 和 broker 的关系 / Relation to the broker
120
+ text
121
+ openai-compatible client
122
+ │ POST /send
123
+ ▼
124
+ identity-agnostic-broker ← 匹配任务和 worker / matches tasks to workers
125
+ │ WS: message / chunk / end
126
+ ▼
127
+ identity-agnostic-worker ← 你在这里 / you are here
128
+ │
129
+ ▼
130
+ 你的 AI 逻辑(Playwright、本地模型、任何能产出流式文本的东西)
131
+ Your AI logic (Playwright, local model, anything that streams text)
132
+ worker 不保存任何路由状态,也不关心发送者或接收者的身份。所有匹配逻辑都在
133
+ broker 里,worker 只负责“收任务 → 干活 → 回流”。
134
+
135
+ The worker keeps no routing state and does not care about sender or receiver
136
+ identity. All matching lives in the broker; the worker only does
137
+ "receive task → work → stream back".
138
+
139
+ License
140
+ MIT
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "identity-agnostic-worker"
7
+ version = "0.1.0"
8
+ description = "Identity-agnostic worker client: register to a broker, receive tasks, stream results back."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Rexllnia" }]
13
+ dependencies = [
14
+ "websockets>=12",
15
+ ]
16
+
17
+ [project.optional-dependencies]
18
+ dev = ["build", "twine"]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/Rexllnia/identity-agnostic-worker"
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
25
+ include = ["identity_agnostic_worker*"]
26
+
27
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: identity-agnostic-worker
3
+ Version: 0.1.0
4
+ Summary: Identity-agnostic worker client: register to a broker, receive tasks, stream results back.
5
+ Author: Rexllnia
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Rexllnia/identity-agnostic-worker
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: websockets>=12
11
+ Provides-Extra: dev
12
+ Requires-Dist: build; extra == "dev"
13
+ Requires-Dist: twine; extra == "dev"
14
+
15
+ # identity-agnostic-worker
16
+
17
+ A minimal Python client for AI workers that connect to an
18
+ [identity-agnostic broker](https://github.com/Rexllnia/identity-agnostic-broker).
19
+
20
+ 一个极简的 Python 客户端,用于让 AI 员工(worker)连接到
21
+ [identity-agnostic broker](https://github.com/Rexllnia/identity-agnostic-broker)。
22
+
23
+ A **worker** registers itself to a broker, receives one task at a time, streams
24
+ back the result in chunks, and marks the end of the stream. The worker never
25
+ needs to know who sent the task or who will receive the result — the broker
26
+ takes care of matching and routing.
27
+
28
+ **Worker** 向 broker 注册,一次接收一个任务,把结果分片流式回传,最后标记流结束。
29
+ worker 不需要知道任务是谁发的,也不需要知道结果发给谁——匹配和路由全部由 broker 负责。
30
+
31
+ This package only contains the worker-side client. It depends on
32
+ `websockets` and nothing else.
33
+
34
+ 本包只包含 worker 端客户端,只依赖 `websockets`,不拖其他依赖。
35
+
36
+ ---
37
+
38
+ ## Install / 安装
39
+
40
+ ```bash
41
+ pip install identity-agnostic-worker
42
+
43
+
44
+ Requires Python 3.10+.
45
+
46
+ 需要 Python 3.10 及以上。
47
+
48
+ Quick start / 快速开始
49
+ python
50
+ import asyncio
51
+ from identity_agnostic_worker import WorkerClient
52
+
53
+
54
+ async def process(text: str):
55
+ """你的 AI / Playwright 逻辑:把 text 变成一段一段的结果。"""
56
+ for ch in text:
57
+ yield ch
58
+
59
+
60
+ async def main():
61
+ client = await WorkerClient.register("ws://127.0.0.1:9000/ws")
62
+
63
+ while True:
64
+ text = await client.recv()
65
+ if text is None:
66
+ break # 连接断开 / connection closed
67
+
68
+ async for chunk in process(text):
69
+ await client.send(chunk)
70
+
71
+ await client.send(None) # 流结束 / end of stream
72
+
73
+
74
+ asyncio.run(main())
75
+ register() 不传参数时,默认连 ws://127.0.0.1:9000/ws。
76
+
77
+ When called without arguments, register() connects to
78
+ ws://127.0.0.1:9000/ws by default.
79
+
80
+ API
81
+ await WorkerClient.register(broker_url="ws://127.0.0.1:9000/ws") -> WorkerClient
82
+ 向 broker 注册,返回一个 WorkerClient。注册成功后,broker 会把这个 worker
83
+ 放进待命池,有匹配的任务时派给它。
84
+
85
+ Register to the broker and return a WorkerClient. Once registered, the
86
+ broker puts this worker on its bench and dispatches matching tasks to it.
87
+
88
+ await client.recv() -> str | None
89
+ 阻塞等待一条用户消息。
90
+
91
+ Block until a user message arrives.
92
+
93
+ 返回 str:新的任务文本,可以开始处理。
94
+ Returns str: a new task text, ready to be processed.
95
+
96
+ 返回 None:与 broker 的连接已断开,应退出循环。
97
+ Returns None: the connection to the broker is closed; exit the loop.
98
+
99
+ await client.send(chunk: str | None)
100
+ 把结果分片发回 broker。
101
+
102
+ Send one chunk of the result back to the broker.
103
+
104
+ 传 str:发送一个 chunk。空字符串 "" 是合法 chunk。
105
+ Pass str: send a chunk. An empty string "" is a valid chunk.
106
+
107
+ 传 None:表示这一轮任务结束。
108
+ Pass None: marks the end of this task.
109
+
110
+ await client.close()
111
+ 主动关闭连接。通常在 finally 里调用,保证异常退出时也能释放连接。
112
+
113
+ Close the connection explicitly. Usually called in a finally block so the
114
+ connection is released even on errors.
115
+
116
+ Protocol / 协议
117
+ worker 与 broker 之间用 WebSocket + JSON 通信,四个消息类型:
118
+
119
+ Worker and broker communicate over WebSocket + JSON with four message types:
120
+
121
+ 方向 Direction 消息 Message
122
+ worker → broker {"type": "register"}
123
+ broker → worker {"type": "registered", "sid": "..."}
124
+ broker → worker {"type": "message", "request_id": "...", "text": "..."}
125
+ worker → broker {"type": "chunk", "request_id": "...", "text": "..."}
126
+ worker → broker {"type": "end", "request_id": "..."}
127
+ 一个 worker 同一时间只处理一条任务。收到 message 后,用同一个 request_id
128
+ 发 chunk,最后发 end。
129
+
130
+ A worker handles one task at a time. After receiving message, send chunk
131
+ with the same request_id, and finish with end.
132
+
133
+ 和 broker 的关系 / Relation to the broker
134
+ text
135
+ openai-compatible client
136
+ │ POST /send
137
+ ▼
138
+ identity-agnostic-broker ← 匹配任务和 worker / matches tasks to workers
139
+ │ WS: message / chunk / end
140
+ ▼
141
+ identity-agnostic-worker ← 你在这里 / you are here
142
+ │
143
+ ▼
144
+ 你的 AI 逻辑(Playwright、本地模型、任何能产出流式文本的东西)
145
+ Your AI logic (Playwright, local model, anything that streams text)
146
+ worker 不保存任何路由状态,也不关心发送者或接收者的身份。所有匹配逻辑都在
147
+ broker 里,worker 只负责“收任务 → 干活 → 回流”。
148
+
149
+ The worker keeps no routing state and does not care about sender or receiver
150
+ identity. All matching lives in the broker; the worker only does
151
+ "receive task → work → stream back".
152
+
153
+ License
154
+ MIT
@@ -0,0 +1,7 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/identity_agnostic_worker.egg-info/PKG-INFO
4
+ src/identity_agnostic_worker.egg-info/SOURCES.txt
5
+ src/identity_agnostic_worker.egg-info/dependency_links.txt
6
+ src/identity_agnostic_worker.egg-info/requires.txt
7
+ src/identity_agnostic_worker.egg-info/top_level.txt
@@ -0,0 +1,5 @@
1
+ websockets>=12
2
+
3
+ [dev]
4
+ build
5
+ twine