wcgw 0.2.0__tar.gz → 1.0.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.

Potentially problematic release.


This version of wcgw might be problematic. Click here for more details.

Files changed (31) hide show
  1. {wcgw-0.2.0 → wcgw-1.0.0}/PKG-INFO +6 -3
  2. {wcgw-0.2.0 → wcgw-1.0.0}/README.md +3 -2
  3. wcgw-1.0.0/gpt_action_json_schema.json +371 -0
  4. {wcgw-0.2.0 → wcgw-1.0.0}/gpt_instructions.txt +14 -14
  5. {wcgw-0.2.0 → wcgw-1.0.0}/pyproject.toml +5 -1
  6. wcgw-1.0.0/src/wcgw/__init__.py +2 -0
  7. wcgw-1.0.0/src/wcgw/client/__main__.py +3 -0
  8. {wcgw-0.2.0/src/wcgw → wcgw-1.0.0/src/wcgw/client}/basic.py +16 -12
  9. {wcgw-0.2.0/src/wcgw → wcgw-1.0.0/src/wcgw/client}/tools.py +243 -132
  10. wcgw-1.0.0/src/wcgw/relay/serve.py +326 -0
  11. wcgw-1.0.0/src/wcgw/types_.py +37 -0
  12. wcgw-1.0.0/tests/test_tools.py +41 -0
  13. {wcgw-0.2.0 → wcgw-1.0.0}/uv.lock +61 -1
  14. wcgw-0.2.0/gpt_action_json_schema.json +0 -231
  15. wcgw-0.2.0/src/relay/serve.py +0 -155
  16. wcgw-0.2.0/src/wcgw/__init__.py +0 -2
  17. wcgw-0.2.0/src/wcgw/__main__.py +0 -3
  18. wcgw-0.2.0/tests/test_tools.py +0 -34
  19. {wcgw-0.2.0 → wcgw-1.0.0}/.github/workflows/python-publish.yml +0 -0
  20. {wcgw-0.2.0 → wcgw-1.0.0}/.github/workflows/python-tests.yml +0 -0
  21. {wcgw-0.2.0 → wcgw-1.0.0}/.gitignore +0 -0
  22. {wcgw-0.2.0 → wcgw-1.0.0}/.python-version +0 -0
  23. {wcgw-0.2.0 → wcgw-1.0.0}/.vscode/settings.json +0 -0
  24. {wcgw-0.2.0 → wcgw-1.0.0}/config.toml +0 -0
  25. {wcgw-0.2.0/src/wcgw → wcgw-1.0.0/src/wcgw/client}/claude.py +0 -0
  26. {wcgw-0.2.0/src/wcgw → wcgw-1.0.0/src/wcgw/client}/common.py +0 -0
  27. {wcgw-0.2.0/src/wcgw → wcgw-1.0.0/src/wcgw/client}/openai_adapters.py +0 -0
  28. {wcgw-0.2.0/src/wcgw → wcgw-1.0.0/src/wcgw/client}/openai_utils.py +0 -0
  29. {wcgw-0.2.0/src → wcgw-1.0.0/src/wcgw}/relay/static/privacy.txt +0 -0
  30. {wcgw-0.2.0 → wcgw-1.0.0}/static/ss1.png +0 -0
  31. {wcgw-0.2.0 → wcgw-1.0.0}/tests/test_basic.py +0 -0
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wcgw
3
- Version: 0.2.0
3
+ Version: 1.0.0
4
4
  Summary: What could go wrong giving full shell access to chatgpt?
5
5
  Project-URL: Homepage, https://github.com/rusiaaman/wcgw
6
6
  Author-email: Aman Rusia <gapypi@arcfu.com>
7
7
  Requires-Python: <3.13,>=3.10
8
8
  Requires-Dist: fastapi>=0.115.0
9
9
  Requires-Dist: mypy>=1.11.2
10
+ Requires-Dist: nltk>=3.9.1
10
11
  Requires-Dist: openai>=1.46.0
11
12
  Requires-Dist: petname>=2.6
12
13
  Requires-Dist: pexpect>=4.9.0
@@ -14,6 +15,7 @@ Requires-Dist: pydantic>=2.9.2
14
15
  Requires-Dist: pyte>=0.8.2
15
16
  Requires-Dist: python-dotenv>=1.0.1
16
17
  Requires-Dist: rich>=13.8.1
18
+ Requires-Dist: semantic-version>=2.10.0
17
19
  Requires-Dist: shell>=1.0.1
18
20
  Requires-Dist: tiktoken==0.7.0
19
21
  Requires-Dist: toml>=0.10.2
@@ -32,7 +34,8 @@ A custom gpt on chatgpt web app to interact with your local shell.
32
34
  ### 🚀 Highlights
33
35
  - ⚡ **Full Shell Access**: No restrictions, complete control.
34
36
  - ⚡ **Create, Execute, Iterate**: Ask the gpt to keep running compiler checks till all errors are fixed, or ask it to keep checking for the status of a long running command till it's done.
35
- - ⚡ **Interactive Command Handling**: [beta] Supports interactive commands using arrow keys, interrupt, and ansi escape sequences.
37
+ - ⚡ **Interactive Command Handling**: Supports interactive commands using arrow keys, interrupt, and ansi escape sequences.
38
+ - ⚡ **REPL support**: [beta] Supports python/node and other REPL execution.
36
39
 
37
40
  ### 🪜 Steps:
38
41
  1. Run the [cli client](https://github.com/rusiaaman/wcgw?tab=readme-ov-file#client) in any directory of choice.
@@ -103,7 +106,7 @@ Run the server
103
106
  If you don't have public ip and domain name, you can use `ngrok` or similar services to get a https address to the api.
104
107
 
105
108
  The specify the server url in the `wcgw` command like so
106
- `wcgw --server-url https://your-url/register`
109
+ `wcgw --server-url https://your-url/v1/register`
107
110
 
108
111
  # [Optional] Local shell access with openai API key
109
112
 
@@ -7,7 +7,8 @@ A custom gpt on chatgpt web app to interact with your local shell.
7
7
  ### 🚀 Highlights
8
8
  - ⚡ **Full Shell Access**: No restrictions, complete control.
9
9
  - ⚡ **Create, Execute, Iterate**: Ask the gpt to keep running compiler checks till all errors are fixed, or ask it to keep checking for the status of a long running command till it's done.
10
- - ⚡ **Interactive Command Handling**: [beta] Supports interactive commands using arrow keys, interrupt, and ansi escape sequences.
10
+ - ⚡ **Interactive Command Handling**: Supports interactive commands using arrow keys, interrupt, and ansi escape sequences.
11
+ - ⚡ **REPL support**: [beta] Supports python/node and other REPL execution.
11
12
 
12
13
  ### 🪜 Steps:
13
14
  1. Run the [cli client](https://github.com/rusiaaman/wcgw?tab=readme-ov-file#client) in any directory of choice.
@@ -78,7 +79,7 @@ Run the server
78
79
  If you don't have public ip and domain name, you can use `ngrok` or similar services to get a https address to the api.
79
80
 
80
81
  The specify the server url in the `wcgw` command like so
81
- `wcgw --server-url https://your-url/register`
82
+ `wcgw --server-url https://your-url/v1/register`
82
83
 
83
84
  # [Optional] Local shell access with openai API key
84
85
 
@@ -0,0 +1,371 @@
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "FastAPI",
5
+ "version": "0.1.0"
6
+ },
7
+ "servers": [
8
+ {
9
+ "url": "https://604f-2401-4900-1c8e-e61d-40fc-eab7-f5c2-c8ad.ngrok-free.app"
10
+ }
11
+ ],
12
+ "paths": {
13
+ "/v1/write_file": {
14
+ "post": {
15
+ "x-openai-isConsequential": false,
16
+ "summary": "Write File",
17
+ "operationId": "write_file_v1_write_file_post",
18
+ "requestBody": {
19
+ "content": {
20
+ "application/json": {
21
+ "schema": {
22
+ "$ref": "#/components/schemas/WritefileWithUUID"
23
+ }
24
+ }
25
+ },
26
+ "required": true
27
+ },
28
+ "responses": {
29
+ "200": {
30
+ "description": "Successful Response",
31
+ "content": {
32
+ "application/json": {
33
+ "schema": {
34
+ "type": "string",
35
+ "title": "Response Write File V1 Write File Post"
36
+ }
37
+ }
38
+ }
39
+ },
40
+ "422": {
41
+ "description": "Validation Error",
42
+ "content": {
43
+ "application/json": {
44
+ "schema": {
45
+ "$ref": "#/components/schemas/HTTPValidationError"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ },
53
+ "/v1/reset_shell": {
54
+ "post": {
55
+ "x-openai-isConsequential": false,
56
+ "summary": "Reset Shell",
57
+ "operationId": "reset_shell_v1_reset_shell_post",
58
+ "requestBody": {
59
+ "content": {
60
+ "application/json": {
61
+ "schema": {
62
+ "$ref": "#/components/schemas/ResetShellWithUUID"
63
+ }
64
+ }
65
+ },
66
+ "required": true
67
+ },
68
+ "responses": {
69
+ "200": {
70
+ "description": "Successful Response",
71
+ "content": {
72
+ "application/json": {
73
+ "schema": {
74
+ "type": "string",
75
+ "title": "Response Reset Shell V1 Reset Shell Post"
76
+ }
77
+ }
78
+ }
79
+ },
80
+ "422": {
81
+ "description": "Validation Error",
82
+ "content": {
83
+ "application/json": {
84
+ "schema": {
85
+ "$ref": "#/components/schemas/HTTPValidationError"
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ "/v1/bash_command": {
94
+ "post": {
95
+ "x-openai-isConsequential": false,
96
+ "summary": "Bash Command",
97
+ "operationId": "bash_command_v1_bash_command_post",
98
+ "requestBody": {
99
+ "content": {
100
+ "application/json": {
101
+ "schema": {
102
+ "$ref": "#/components/schemas/CommandWithUUID"
103
+ }
104
+ }
105
+ },
106
+ "required": true
107
+ },
108
+ "responses": {
109
+ "200": {
110
+ "description": "Successful Response",
111
+ "content": {
112
+ "application/json": {
113
+ "schema": {
114
+ "type": "string",
115
+ "title": "Response Bash Command V1 Bash Command Post"
116
+ }
117
+ }
118
+ }
119
+ },
120
+ "422": {
121
+ "description": "Validation Error",
122
+ "content": {
123
+ "application/json": {
124
+ "schema": {
125
+ "$ref": "#/components/schemas/HTTPValidationError"
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ },
133
+ "/v1/bash_interaction": {
134
+ "post": {
135
+ "x-openai-isConsequential": false,
136
+ "summary": "Bash Interaction",
137
+ "operationId": "bash_interaction_v1_bash_interaction_post",
138
+ "requestBody": {
139
+ "content": {
140
+ "application/json": {
141
+ "schema": {
142
+ "$ref": "#/components/schemas/BashInteractionWithUUID"
143
+ }
144
+ }
145
+ },
146
+ "required": true
147
+ },
148
+ "responses": {
149
+ "200": {
150
+ "description": "Successful Response",
151
+ "content": {
152
+ "application/json": {
153
+ "schema": {
154
+ "type": "string",
155
+ "title": "Response Bash Interaction V1 Bash Interaction Post"
156
+ }
157
+ }
158
+ }
159
+ },
160
+ "422": {
161
+ "description": "Validation Error",
162
+ "content": {
163
+ "application/json": {
164
+ "schema": {
165
+ "$ref": "#/components/schemas/HTTPValidationError"
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+ },
174
+ "components": {
175
+ "schemas": {
176
+ "BashInteractionWithUUID": {
177
+ "properties": {
178
+ "send_text": {
179
+ "anyOf": [
180
+ {
181
+ "type": "string"
182
+ },
183
+ {
184
+ "type": "null"
185
+ }
186
+ ],
187
+ "title": "Send Text"
188
+ },
189
+ "send_specials": {
190
+ "anyOf": [
191
+ {
192
+ "items": {
193
+ "type": "string",
194
+ "enum": [
195
+ "Key-up",
196
+ "Key-down",
197
+ "Key-left",
198
+ "Key-right",
199
+ "Enter",
200
+ "Ctrl-c",
201
+ "Ctrl-d",
202
+ "Ctrl-z"
203
+ ]
204
+ },
205
+ "type": "array"
206
+ },
207
+ {
208
+ "type": "null"
209
+ }
210
+ ],
211
+ "title": "Send Specials"
212
+ },
213
+ "send_ascii": {
214
+ "anyOf": [
215
+ {
216
+ "items": {
217
+ "type": "integer"
218
+ },
219
+ "type": "array"
220
+ },
221
+ {
222
+ "type": "null"
223
+ }
224
+ ],
225
+ "title": "Send Ascii"
226
+ },
227
+ "user_id": {
228
+ "type": "string",
229
+ "format": "uuid",
230
+ "title": "User Id"
231
+ }
232
+ },
233
+ "type": "object",
234
+ "required": [
235
+ "user_id"
236
+ ],
237
+ "title": "BashInteractionWithUUID"
238
+ },
239
+ "CommandWithUUID": {
240
+ "properties": {
241
+ "command": {
242
+ "type": "string",
243
+ "title": "Command"
244
+ },
245
+ "user_id": {
246
+ "type": "string",
247
+ "format": "uuid",
248
+ "title": "User Id"
249
+ }
250
+ },
251
+ "type": "object",
252
+ "required": [
253
+ "command",
254
+ "user_id"
255
+ ],
256
+ "title": "CommandWithUUID"
257
+ },
258
+ "HTTPValidationError": {
259
+ "properties": {
260
+ "detail": {
261
+ "items": {
262
+ "$ref": "#/components/schemas/ValidationError"
263
+ },
264
+ "type": "array",
265
+ "title": "Detail"
266
+ }
267
+ },
268
+ "type": "object",
269
+ "title": "HTTPValidationError"
270
+ },
271
+ "ResetShellWithUUID": {
272
+ "properties": {
273
+ "should_reset": {
274
+ "type": "boolean",
275
+ "enum": [
276
+ true
277
+ ],
278
+ "const": true,
279
+ "title": "Should Reset",
280
+ "default": true
281
+ },
282
+ "user_id": {
283
+ "type": "string",
284
+ "format": "uuid",
285
+ "title": "User Id"
286
+ }
287
+ },
288
+ "type": "object",
289
+ "required": [
290
+ "user_id"
291
+ ],
292
+ "title": "ResetShellWithUUID"
293
+ },
294
+ "ValidationError": {
295
+ "properties": {
296
+ "loc": {
297
+ "items": {
298
+ "anyOf": [
299
+ {
300
+ "type": "string"
301
+ },
302
+ {
303
+ "type": "integer"
304
+ }
305
+ ]
306
+ },
307
+ "type": "array",
308
+ "title": "Location"
309
+ },
310
+ "msg": {
311
+ "type": "string",
312
+ "title": "Message"
313
+ },
314
+ "type": {
315
+ "type": "string",
316
+ "title": "Error Type"
317
+ }
318
+ },
319
+ "type": "object",
320
+ "required": [
321
+ "loc",
322
+ "msg",
323
+ "type"
324
+ ],
325
+ "title": "ValidationError"
326
+ },
327
+ "Writefile": {
328
+ "properties": {
329
+ "file_path": {
330
+ "type": "string",
331
+ "title": "File Path"
332
+ },
333
+ "file_content": {
334
+ "type": "string",
335
+ "title": "File Content"
336
+ }
337
+ },
338
+ "type": "object",
339
+ "required": [
340
+ "file_path",
341
+ "file_content"
342
+ ],
343
+ "title": "Writefile"
344
+ },
345
+ "WritefileWithUUID": {
346
+ "properties": {
347
+ "file_path": {
348
+ "type": "string",
349
+ "title": "File Path"
350
+ },
351
+ "file_content": {
352
+ "type": "string",
353
+ "title": "File Content"
354
+ },
355
+ "user_id": {
356
+ "type": "string",
357
+ "format": "uuid",
358
+ "title": "User Id"
359
+ }
360
+ },
361
+ "type": "object",
362
+ "required": [
363
+ "file_path",
364
+ "file_content",
365
+ "user_id"
366
+ ],
367
+ "title": "WritefileWithUUID"
368
+ }
369
+ }
370
+ }
371
+ }
@@ -9,20 +9,26 @@ Instructions:
9
9
 
10
10
  To execute bash commands OR write files use the provided api `wcgw.arcfu.com`
11
11
 
12
- Instructions for `Execute Bash`:
13
- - Execute a bash script. This is stateful (beware with subsequent calls).
14
- - Execute commands using `execute_command` attribute.
12
+ Instructions for `BashCommand`:
13
+ - Execute a bash command. This is stateful (beware with subsequent calls).
15
14
  - Do not use interactive commands like nano. Prefer writing simpler commands.
16
- - Last line will always be `(exit <int code>)` except if
17
- - The last line is `(pending)` if the program is still running or waiting for your input. You can then send input using `send_ascii` attributes. You get status by sending new line `send_ascii: ["Enter"]` or `send_ascii: [10]`.
18
- - Optionally the last line is `(won't exit)` in which case you need to kill the process if you want to run a new command.
15
+ - Status of the command and the current working directory will always be returned at the end.
19
16
  - Optionally `exit shell has restarted` is the output, in which case environment resets, you can run fresh commands.
20
17
  - The first line might be `(...truncated)` if the output is too long.
21
18
  - Always run `pwd` if you get any file or directory not found error to make sure you're not lost.
22
- - You can run python/node/other REPL code lines using `execute_command` too. NOTE: `execute_command` doesn't create a new shell, it uses the same shell.
23
19
 
24
20
  Instructions for `Write File`
25
- - Write content to a file. Provide file path and content. Use this instead of ExecuteBash for writing files.
21
+ - Write content to a file. Provide file path and content. Use this instead of BashCommand for writing files.
22
+ - This doesn't create any directories, please create directories using `mkdir -p` BashCommand.
23
+ - Important: all relative paths are relative to last CWD.
24
+
25
+ Instructions for `BashInteraction`
26
+ - Interact with running program using this tool
27
+ - Special keys like arrows, interrupts, enter, etc.
28
+ - Send text input to the running program.
29
+
30
+ Instructions for `ResetShell`
31
+ - Resets the shell. Use only if all interrupts and prompt reset attempts have failed repeatedly.
26
32
 
27
33
  ---
28
34
 
@@ -30,9 +36,3 @@ Always critically think and debate with yourself to solve the problem. Understan
30
36
 
31
37
  ---
32
38
  Ask the user for the user_id `UUID` if they haven't provided in the first message.
33
-
34
- ---
35
- Error references:
36
- 1. "Input should be a valid integer"
37
- You are probably send_ascii command a string. If you are in REPL mode, use `execute_command` instead.
38
- Otherwise convert the string into sequence of ascii integers.
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  authors = [{ name = "Aman Rusia", email = "gapypi@arcfu.com" }]
3
3
  name = "wcgw"
4
- version = "0.2.0"
4
+ version = "1.0.0"
5
5
  description = "What could go wrong giving full shell access to chatgpt?"
6
6
  readme = "README.md"
7
7
  requires-python = ">=3.10, <3.13"
@@ -22,6 +22,8 @@ dependencies = [
22
22
  "uvicorn>=0.31.0",
23
23
  "websockets>=13.1",
24
24
  "pydantic>=2.9.2",
25
+ "semantic-version>=2.10.0",
26
+ "nltk>=3.9.1",
25
27
  ]
26
28
 
27
29
  [project.urls]
@@ -34,6 +36,7 @@ build-backend = "hatchling.build"
34
36
  [project.scripts]
35
37
  wcgw_local = "wcgw:app"
36
38
  wcgw = "wcgw:listen"
39
+ wcgw_relay = "wcgw.relay.serve:run"
37
40
 
38
41
  [tool.uv]
39
42
  dev-dependencies = [
@@ -41,4 +44,5 @@ dev-dependencies = [
41
44
  "types-toml>=0.10.8.20240310",
42
45
  "autoflake",
43
46
  "ipython>=8.12.3",
47
+ "gunicorn>=23.0.0",
44
48
  ]
@@ -0,0 +1,2 @@
1
+ from .client.basic import app, loop
2
+ from .client.tools import run as listen
@@ -0,0 +1,3 @@
1
+ from .tools import run
2
+
3
+ run()
@@ -20,16 +20,15 @@ import petname # type: ignore[import-untyped]
20
20
  from typer import Typer
21
21
  import uuid
22
22
 
23
+ from ..types_ import BashCommand, BashInteraction, ReadImage, Writefile, ResetShell
24
+
23
25
  from .common import Models, discard_input
24
26
  from .common import CostData, History
25
27
  from .openai_utils import get_input_cost, get_output_cost
26
- from .tools import ExecuteBash, ReadImage, ImageData
28
+ from .tools import ImageData
27
29
 
28
30
  from .tools import (
29
- BASH_CLF_OUTPUT,
30
- Confirmation,
31
31
  DoneFlag,
32
- Writefile,
33
32
  get_tool_output,
34
33
  SHELL,
35
34
  start_shell,
@@ -156,27 +155,32 @@ def loop(
156
155
 
157
156
  tools = [
158
157
  openai.pydantic_function_tool(
159
- ExecuteBash,
158
+ BashCommand,
160
159
  description="""
161
- - Execute a bash script. This is stateful (beware with subsequent calls).
162
- - Execute commands using `execute_command` attribute. You can run python/node/other REPL code lines using `execute_command` too.
160
+ - Execute a bash command. This is stateful (beware with subsequent calls).
163
161
  - Do not use interactive commands like nano. Prefer writing simpler commands.
164
- - Last line will always be `(exit <int code>)` except if
165
- - The last line is `(pending)` if the program is still running or waiting for your input. You can then send input using `send_ascii` attributes. You get status by sending new line `send_ascii: ["Enter"]` or `send_ascii: [10]`.
166
- - Optionally the last line is `(won't exit)` in which case you need to kill the process if you want to run a new command.
162
+ - Status of the command and the current working directory will always be returned at the end.
167
163
  - Optionally `exit shell has restarted` is the output, in which case environment resets, you can run fresh commands.
168
164
  - The first line might be `(...truncated)` if the output is too long.
169
165
  - Always run `pwd` if you get any file or directory not found error to make sure you're not lost.
170
- - You can run python/node/other REPL code lines using `execute_command` too. NOTE: `execute_command` doesn't create a new shell, it uses the same shell.
171
166
  """,
167
+ ),
168
+ openai.pydantic_function_tool(
169
+ BashInteraction,
170
+ description="""
171
+ - Interact with running program using this tool.""",
172
172
  ),
173
173
  openai.pydantic_function_tool(
174
174
  Writefile,
175
- description="Write content to a file. Provide file path and content. Use this instead of ExecuteBash for writing files.",
175
+ description="Write content to a file. Provide file path and content. Use this instead of BashCommand for writing files.",
176
176
  ),
177
177
  openai.pydantic_function_tool(
178
178
  ReadImage, description="Read an image from the shell."
179
179
  ),
180
+ openai.pydantic_function_tool(
181
+ ResetShell,
182
+ description="Resets the shell. Use only if all interrupts and prompt reset attempts have failed repeatedly.",
183
+ ),
180
184
  ]
181
185
  uname_sysname = os.uname().sysname
182
186
  uname_machine = os.uname().machine