pycodex-ws 0.6.3__tar.gz → 0.7.1__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.
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/PKG-INFO +65 -34
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/README.md +62 -32
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/client.py +0 -33
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/protocol.py +5 -4
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/server.py +2 -2
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/__init__.py +8 -2
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/feishu_card.py +28 -2
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/feishu_link.py +2 -1
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/feishu_render.py +1 -1
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/server_support.py +17 -12
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pyproject.toml +13 -2
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/WORKSPACE_API.md +137 -111
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/agent_access.py +64 -7
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/app.py +99 -167
- pycodex_ws-0.7.1/workspace_server/banners.mjs +351 -0
- pycodex_ws-0.7.1/workspace_server/content_views.css +1 -0
- pycodex_ws-0.7.1/workspace_server/content_views.mjs +43 -0
- pycodex_ws-0.7.1/workspace_server/conversation.mjs +326 -0
- pycodex_ws-0.7.1/workspace_server/custom_frontend.mjs +47 -0
- pycodex_ws-0.7.1/workspace_server/dialogs.mjs +476 -0
- pycodex_ws-0.7.1/workspace_server/external_call.py +300 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/build.mjs +32 -1
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/content_views.css +84 -4
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/content_views.mjs +358 -87
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/transcript.mjs +10 -17
- pycodex_ws-0.7.1/workspace_server/markdown.mjs +379 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/README.md +27 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/source/upload_browser.py +1 -2
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/README.md +3 -2
- pycodex_ws-0.7.1/workspace_server/optional_features/session-time-sort/README.md +50 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/session-time-sort/source/custom.css +17 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/session-time-sort/source/custom.js +6 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/session-time-sort/source/session-time-sort.mjs +169 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/session-time-sort/source/verify.mjs +189 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/source/verify.cjs +11 -10
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/README.md +187 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/preview-mobile.png +0 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/preview.png +0 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/notifications.py +277 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/runtime_checks.py +132 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/summarize.py +88 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/test_notifications.py +329 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/test_xiaoai.py +275 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/verify.cjs +97 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/workspace.patch +191 -0
- pycodex_ws-0.7.1/workspace_server/optional_features/xiaoai-notifications/source/xiaoai.py +430 -0
- pycodex_ws-0.7.1/workspace_server/owned_process.py +168 -0
- pycodex_ws-0.7.1/workspace_server/reloader.py +130 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/routes.py +369 -64
- pycodex_ws-0.7.1/workspace_server/runtime_info.py +97 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/session_api.py +44 -18
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/session_view.py +154 -19
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/sessions.py +99 -11
- pycodex_ws-0.7.1/workspace_server/sessions_ui.mjs +351 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/sharing.py +1 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/view_sources.py +14 -11
- pycodex_ws-0.7.1/workspace_server/vscode_server.py +1587 -0
- pycodex_ws-0.7.1/workspace_server/workspace.css +1721 -0
- pycodex_ws-0.7.1/workspace_server/workspace.html +370 -0
- pycodex_ws-0.7.1/workspace_server/workspace.mjs +1069 -0
- pycodex_ws-0.7.1/workspace_server/workspace.template.html +354 -0
- pycodex_ws-0.7.1/workspace_server/workspace_dom.mjs +41 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/workspace_views.py +14 -12
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/workspaces.html +13 -29
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/workspaces.py +25 -6
- pycodex_ws-0.6.3/workspace_server/content_views.css +0 -1
- pycodex_ws-0.6.3/workspace_server/content_views.mjs +0 -37
- pycodex_ws-0.6.3/workspace_server/one_line_agent.py +0 -391
- pycodex_ws-0.6.3/workspace_server/optional_features/README.md +0 -33
- pycodex_ws-0.6.3/workspace_server/owned_process.py +0 -57
- pycodex_ws-0.6.3/workspace_server/reloader.py +0 -449
- pycodex_ws-0.6.3/workspace_server/runtime_info.py +0 -48
- pycodex_ws-0.6.3/workspace_server/workspace.html +0 -4158
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/.gitignore +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/LICENSE +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/__init__.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/__main__.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/browser.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_router/index.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/feishu_auth.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/feishu_connection.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/feishu_oauth.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/pycodex_ws/workspace_config.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/__init__.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/__main__.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/content_views.LICENSE.txt +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/customization.py +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/editor.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/editor.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/.gitignore +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/composer.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/editor.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/editor.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/editor_context.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/package-lock.json +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/package.json +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/prompt_history.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/touch_selection.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/frontend/view_labels.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/CONTRIBUTING.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/preview.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/source/fixture.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/clock-ticks/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/preview.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/source/fixture.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/source/tool-groups.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/source/tool-groups.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/consecutive-tool-groups/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/preview.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/source/fixture.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/exec-status/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/source/upload_core.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/source/upload_core.test.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/file-attachments/source/uploads.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/preview.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/source/fixture.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/reasoning-display/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/preview.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/source/fixture.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/source/session-tips.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/session-tips/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/source/skill-completion.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/source/skill-completion.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/skill-completion/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/preview.html +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/source/fixture.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/tool-calls/source/verify.mjs +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/README.md +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/preview-mobile.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/preview.png +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/source/custom.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/source/custom.js +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/source/voice-input.css +0 -0
- {pycodex_ws-0.6.3 → pycodex_ws-0.7.1}/workspace_server/optional_features/voice-input/source/voice-input.js +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pycodex-ws
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Browser workspace and optional Feishu integration for python-codex
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Requires-Python: >=3.7
|
|
7
7
|
Requires-Dist: pillow>=9.0.0
|
|
8
|
-
Requires-Dist:
|
|
8
|
+
Requires-Dist: pyagy==0.7.1
|
|
9
|
+
Requires-Dist: python-codex==0.7.1
|
|
9
10
|
Requires-Dist: websockets<16,>=11
|
|
10
11
|
Description-Content-Type: text/markdown
|
|
11
12
|
|
|
@@ -16,8 +17,8 @@ optional Feishu integration for
|
|
|
16
17
|
[`python-codex`](https://pypi.org/project/python-codex/).
|
|
17
18
|
Requires Python 3.7+ and installs the matching core version.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
For changes since 0.6.0 and Python integration updates, see the
|
|
21
|
+
[0.7.0 release notes](https://github.com/Randomizez/pycodex/blob/v0.7.0/docs/RELEASE_0.7.0.md).
|
|
21
22
|
|
|
22
23
|
## Quick start
|
|
23
24
|
|
|
@@ -43,6 +44,10 @@ Open `http://127.0.0.1:6007`. Use `python3 -m workspace_server` if the command
|
|
|
43
44
|
is not on `PATH`. Keep stdin open while the server runs; EOF initiates shutdown.
|
|
44
45
|
Model configuration comes from `~/.codex/config.toml`.
|
|
45
46
|
|
|
47
|
+
With `pycodex-ws --listen-to KEY@router:6000`, the OS assigns a free local
|
|
48
|
+
loopback port. The CLI prints the local URL and registers that port with the
|
|
49
|
+
router. Add `--listen 127.0.0.1:6007` to use a fixed port.
|
|
50
|
+
|
|
46
51
|
## Conversations and views
|
|
47
52
|
|
|
48
53
|
The session sidebar starts collapsed. Hover to preview it, click to keep it
|
|
@@ -50,7 +55,8 @@ open, and click the toggle or empty space again to close it. Expansion narrows
|
|
|
50
55
|
the conversation while keeping the board fixed. On phones, use the header
|
|
51
56
|
buttons to switch between chat and board.
|
|
52
57
|
|
|
53
|
-
Use the expanded sidebar to create, rename or close sessions.
|
|
58
|
+
Use the expanded sidebar to create, rename or close sessions. Click × and
|
|
59
|
+
confirm to close a session; the last session stays open. Status dots show
|
|
54
60
|
running sessions and unread replies. `/cd <directory>` changes the current
|
|
55
61
|
session's working directory while idle; `/model`, `/resume`, `/compact` and
|
|
56
62
|
other core session commands are also available.
|
|
@@ -59,6 +65,15 @@ Use **New session** for the default profile, or its **+** button to choose one.
|
|
|
59
65
|
Profiles reload when you open the chooser or create a session, so config changes
|
|
60
66
|
apply to new sessions without restarting the server. Existing sessions keep their configuration.
|
|
61
67
|
|
|
68
|
+
Administrators can use **Settings → Reload PyCodex** and choose **Reboot** or
|
|
69
|
+
**Update & reboot** to restart on updated code without restarting the process.
|
|
70
|
+
Idle sessions close at once and running turns finish first (no new turns start
|
|
71
|
+
meanwhile); background exec processes are terminated, clock periods resume, and
|
|
72
|
+
sessions are restored from disk. Logins and share passwords are cleared; refresh
|
|
73
|
+
the page afterwards. The endpoint `POST api/reload` accepts `{"upgrade": true}`
|
|
74
|
+
or `{"upgrade": "VERSION"}`, which runs `pip install --upgrade pycodex-ws` with
|
|
75
|
+
the server's Python first. The router connection (`--listen-to`) stays up.
|
|
76
|
+
|
|
62
77
|
Consecutive model reconnection diagnostics share one collapsed `Model retries`
|
|
63
78
|
row per sequence. The summary shows the number of recorded retries, the latest
|
|
64
79
|
attempt and its HTTP status when available. Expand it to read the original errors
|
|
@@ -66,11 +81,19 @@ in a scrollable log. New retries update the same row and preserve its open state
|
|
|
66
81
|
refreshing starts collapsed. Other model diagnostics and final errors stay visible.
|
|
67
82
|
|
|
68
83
|
Click Markdown links to open files and comparisons, for example
|
|
69
|
-
`[source](app.py:42)` or `[changes](diff:HEAD:app.py)`.
|
|
70
|
-
|
|
84
|
+
`[source](app.py:42)` or `[changes](diff:HEAD:app.py)`. A Markdown link such as
|
|
85
|
+
`[source](file:///data/project/app.py#L42-L48)` opens the workspace file at line 42.
|
|
86
|
+
In a local Markdown preview, `` displays the image beside the Markdown file.
|
|
87
|
+
Assistant replies can embed a local plot by absolute path, such as ``.
|
|
88
|
+
In a code or diff view, select text and choose **Insert into chat** to add editable context to the draft.
|
|
71
89
|
Click a context block to edit or remove it before sending.
|
|
72
90
|
See [view links and supported formats](../../docs/RUNTIME.md#workspace-content-views).
|
|
73
91
|
|
|
92
|
+
With embedded VS Code enabled, clicking a file or diff link opens it in the
|
|
93
|
+
current browser tab's workbench. You can open the same folder in several tabs
|
|
94
|
+
and use each editor independently. Git comparisons display symbolic links as
|
|
95
|
+
their target paths. VS Code handles large files using its own editor limits.
|
|
96
|
+
|
|
74
97
|
When using a router, its directory groups workspaces by device and lists unread
|
|
75
98
|
workspaces at the top. Device handles reorder the list; pencil buttons edit
|
|
76
99
|
device names.
|
|
@@ -84,19 +107,24 @@ identifying the source of a user message. The history API returns it, and
|
|
|
84
107
|
recorded sessions preserve it across resume. It is metadata only: the model request and frontend display do
|
|
85
108
|
not include it. See the [message API contract](workspace_server/WORKSPACE_API.md#commands-and-results).
|
|
86
109
|
|
|
87
|
-
The [VS Code extension](extensions/vscode/README.md) uses this backend and is
|
|
88
|
-
distributed separately as a VSIX.
|
|
89
|
-
|
|
90
110
|
## Customize the interface
|
|
91
111
|
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
Choose **Settings → Customize Agent** from the conversation header to open a
|
|
113
|
+
conversation and the
|
|
114
|
+
[optional feature catalog](workspace_server/optional_features/README.md), with
|
|
115
|
+
a **Customize Agent** banner at the top of the chat for reopening the catalog,
|
|
116
|
+
switching to `?builtin=1`, copying the frontend directory or opening `WORKSPACE_API.md`.
|
|
117
|
+
Browse the feature descriptions, then send a feature name, ID or your own
|
|
118
|
+
interface request in chat. The Agent starts with that message.
|
|
94
119
|
Custom files live in the server user's `~/.pycodex/frontend/`:
|
|
95
120
|
|
|
96
121
|
- `custom.css` and `custom.js`: optional styles and an ES module, loaded automatically.
|
|
97
122
|
- `workspace.html`: optional full-page override; otherwise the packaged page is used.
|
|
98
123
|
- Other files: available at workspace-relative `frontend/<path>` URLs.
|
|
99
124
|
|
|
125
|
+
The frontend build embeds the page styles and JavaScript in the packaged `workspace.html`.
|
|
126
|
+
Once the updated files are on the server, refresh the browser to load the new interface.
|
|
127
|
+
|
|
100
128
|
Refresh to apply changes and keep the selected conversation. Open the workspace
|
|
101
129
|
with `?builtin=1` to bypass all customizations; click “Re-enable customizations”
|
|
102
130
|
to return. Changes apply to all workspaces for that OS user.
|
|
@@ -104,16 +132,16 @@ See the [customization contract](../../docs/RUNTIME.md#frontend-customization).
|
|
|
104
132
|
For custom interfaces, the [resource API](../../docs/WORKSPACE_API.md) exposes
|
|
105
133
|
state, model catalogs, asynchronous command results, paginated history, event
|
|
106
134
|
replay and sub-agent/background-work inventories. A `mount(host)` export in
|
|
107
|
-
`custom.js` can access the built-in page's session, draft
|
|
135
|
+
`custom.js` can access the built-in page's session, draft, banner (`host.setBanner`)
|
|
136
|
+
and view controls, and host wrappers can embed `<script type="application/json" data-pycodex-banner>` banners.
|
|
108
137
|
|
|
109
138
|
Backend module ownership and the preserved session interfaces are documented in
|
|
110
139
|
the [runtime guide](../../docs/RUNTIME.md#workspace-session-api).
|
|
111
140
|
File/Git source resolution and view storage retain their existing public classes;
|
|
112
141
|
see [content views](../../docs/RUNTIME.md#workspace-content-views).
|
|
113
142
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
their source into your frontend. To share a local change, ask it to publish a
|
|
143
|
+
The Agent adapts the selected feature's source into your frontend.
|
|
144
|
+
To share a local change, ask it to publish a
|
|
117
145
|
feature PR on GitHub; the [contribution guide](workspace_server/optional_features/CONTRIBUTING.md)
|
|
118
146
|
specifies the source, documentation, validation and PR format.
|
|
119
147
|
|
|
@@ -139,24 +167,27 @@ permissions. An unprotected server must configure its administrator password
|
|
|
139
167
|
before enabling sharing. Router authentication is unchanged: a link through a
|
|
140
168
|
router still requires its normal login.
|
|
141
169
|
|
|
142
|
-
##
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
Copy the
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
170
|
+
## External Call
|
|
171
|
+
|
|
172
|
+
Open **Settings → External Call**, pick a profile and click
|
|
173
|
+
**Create session**. The workspace selects the new conversation and pins an
|
|
174
|
+
**External Call** banner at the top of the chat with **Copy Bash**,
|
|
175
|
+
**Copy PowerShell** and expandable **Details** for the full commands and
|
|
176
|
+
endpoint URL. Copy the command for your client machine and run it in a terminal.
|
|
177
|
+
|
|
178
|
+
Send the task from the Web conversation. External Call sessions inject
|
|
179
|
+
contextual guidance distinguishing the host workspace machine (`exec_command`
|
|
180
|
+
and other standard tools, `<environment_context>`, `AGENTS.md`, skills) from the
|
|
181
|
+
connected client machine (`client_exec_command`). The terminal prints each
|
|
182
|
+
command and its output, and returns the output and exit status to the
|
|
183
|
+
conversation. The Bash and PowerShell commands are client examples over the
|
|
184
|
+
session's `b/<code>` HTTP endpoint; custom scripts or executables (such as Python
|
|
185
|
+
or `cmd`) can pull commands with `GET` and return results with `POST` or `GET`.
|
|
186
|
+
|
|
187
|
+
Each new session gets its own connection code. Closing its tab invalidates that
|
|
188
|
+
code, releases pending requests and stops the terminal loop. After a server
|
|
189
|
+
restart, create a new session to reconnect a terminal. Previous conversations
|
|
190
|
+
retain their recorded history.
|
|
160
191
|
|
|
161
192
|
## Storage
|
|
162
193
|
|
|
@@ -5,8 +5,8 @@ optional Feishu integration for
|
|
|
5
5
|
[`python-codex`](https://pypi.org/project/python-codex/).
|
|
6
6
|
Requires Python 3.7+ and installs the matching core version.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
For changes since 0.6.0 and Python integration updates, see the
|
|
9
|
+
[0.7.0 release notes](https://github.com/Randomizez/pycodex/blob/v0.7.0/docs/RELEASE_0.7.0.md).
|
|
10
10
|
|
|
11
11
|
## Quick start
|
|
12
12
|
|
|
@@ -32,6 +32,10 @@ Open `http://127.0.0.1:6007`. Use `python3 -m workspace_server` if the command
|
|
|
32
32
|
is not on `PATH`. Keep stdin open while the server runs; EOF initiates shutdown.
|
|
33
33
|
Model configuration comes from `~/.codex/config.toml`.
|
|
34
34
|
|
|
35
|
+
With `pycodex-ws --listen-to KEY@router:6000`, the OS assigns a free local
|
|
36
|
+
loopback port. The CLI prints the local URL and registers that port with the
|
|
37
|
+
router. Add `--listen 127.0.0.1:6007` to use a fixed port.
|
|
38
|
+
|
|
35
39
|
## Conversations and views
|
|
36
40
|
|
|
37
41
|
The session sidebar starts collapsed. Hover to preview it, click to keep it
|
|
@@ -39,7 +43,8 @@ open, and click the toggle or empty space again to close it. Expansion narrows
|
|
|
39
43
|
the conversation while keeping the board fixed. On phones, use the header
|
|
40
44
|
buttons to switch between chat and board.
|
|
41
45
|
|
|
42
|
-
Use the expanded sidebar to create, rename or close sessions.
|
|
46
|
+
Use the expanded sidebar to create, rename or close sessions. Click × and
|
|
47
|
+
confirm to close a session; the last session stays open. Status dots show
|
|
43
48
|
running sessions and unread replies. `/cd <directory>` changes the current
|
|
44
49
|
session's working directory while idle; `/model`, `/resume`, `/compact` and
|
|
45
50
|
other core session commands are also available.
|
|
@@ -48,6 +53,15 @@ Use **New session** for the default profile, or its **+** button to choose one.
|
|
|
48
53
|
Profiles reload when you open the chooser or create a session, so config changes
|
|
49
54
|
apply to new sessions without restarting the server. Existing sessions keep their configuration.
|
|
50
55
|
|
|
56
|
+
Administrators can use **Settings → Reload PyCodex** and choose **Reboot** or
|
|
57
|
+
**Update & reboot** to restart on updated code without restarting the process.
|
|
58
|
+
Idle sessions close at once and running turns finish first (no new turns start
|
|
59
|
+
meanwhile); background exec processes are terminated, clock periods resume, and
|
|
60
|
+
sessions are restored from disk. Logins and share passwords are cleared; refresh
|
|
61
|
+
the page afterwards. The endpoint `POST api/reload` accepts `{"upgrade": true}`
|
|
62
|
+
or `{"upgrade": "VERSION"}`, which runs `pip install --upgrade pycodex-ws` with
|
|
63
|
+
the server's Python first. The router connection (`--listen-to`) stays up.
|
|
64
|
+
|
|
51
65
|
Consecutive model reconnection diagnostics share one collapsed `Model retries`
|
|
52
66
|
row per sequence. The summary shows the number of recorded retries, the latest
|
|
53
67
|
attempt and its HTTP status when available. Expand it to read the original errors
|
|
@@ -55,11 +69,19 @@ in a scrollable log. New retries update the same row and preserve its open state
|
|
|
55
69
|
refreshing starts collapsed. Other model diagnostics and final errors stay visible.
|
|
56
70
|
|
|
57
71
|
Click Markdown links to open files and comparisons, for example
|
|
58
|
-
`[source](app.py:42)` or `[changes](diff:HEAD:app.py)`.
|
|
59
|
-
|
|
72
|
+
`[source](app.py:42)` or `[changes](diff:HEAD:app.py)`. A Markdown link such as
|
|
73
|
+
`[source](file:///data/project/app.py#L42-L48)` opens the workspace file at line 42.
|
|
74
|
+
In a local Markdown preview, `` displays the image beside the Markdown file.
|
|
75
|
+
Assistant replies can embed a local plot by absolute path, such as ``.
|
|
76
|
+
In a code or diff view, select text and choose **Insert into chat** to add editable context to the draft.
|
|
60
77
|
Click a context block to edit or remove it before sending.
|
|
61
78
|
See [view links and supported formats](../../docs/RUNTIME.md#workspace-content-views).
|
|
62
79
|
|
|
80
|
+
With embedded VS Code enabled, clicking a file or diff link opens it in the
|
|
81
|
+
current browser tab's workbench. You can open the same folder in several tabs
|
|
82
|
+
and use each editor independently. Git comparisons display symbolic links as
|
|
83
|
+
their target paths. VS Code handles large files using its own editor limits.
|
|
84
|
+
|
|
63
85
|
When using a router, its directory groups workspaces by device and lists unread
|
|
64
86
|
workspaces at the top. Device handles reorder the list; pencil buttons edit
|
|
65
87
|
device names.
|
|
@@ -73,19 +95,24 @@ identifying the source of a user message. The history API returns it, and
|
|
|
73
95
|
recorded sessions preserve it across resume. It is metadata only: the model request and frontend display do
|
|
74
96
|
not include it. See the [message API contract](workspace_server/WORKSPACE_API.md#commands-and-results).
|
|
75
97
|
|
|
76
|
-
The [VS Code extension](extensions/vscode/README.md) uses this backend and is
|
|
77
|
-
distributed separately as a VSIX.
|
|
78
|
-
|
|
79
98
|
## Customize the interface
|
|
80
99
|
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
Choose **Settings → Customize Agent** from the conversation header to open a
|
|
101
|
+
conversation and the
|
|
102
|
+
[optional feature catalog](workspace_server/optional_features/README.md), with
|
|
103
|
+
a **Customize Agent** banner at the top of the chat for reopening the catalog,
|
|
104
|
+
switching to `?builtin=1`, copying the frontend directory or opening `WORKSPACE_API.md`.
|
|
105
|
+
Browse the feature descriptions, then send a feature name, ID or your own
|
|
106
|
+
interface request in chat. The Agent starts with that message.
|
|
83
107
|
Custom files live in the server user's `~/.pycodex/frontend/`:
|
|
84
108
|
|
|
85
109
|
- `custom.css` and `custom.js`: optional styles and an ES module, loaded automatically.
|
|
86
110
|
- `workspace.html`: optional full-page override; otherwise the packaged page is used.
|
|
87
111
|
- Other files: available at workspace-relative `frontend/<path>` URLs.
|
|
88
112
|
|
|
113
|
+
The frontend build embeds the page styles and JavaScript in the packaged `workspace.html`.
|
|
114
|
+
Once the updated files are on the server, refresh the browser to load the new interface.
|
|
115
|
+
|
|
89
116
|
Refresh to apply changes and keep the selected conversation. Open the workspace
|
|
90
117
|
with `?builtin=1` to bypass all customizations; click “Re-enable customizations”
|
|
91
118
|
to return. Changes apply to all workspaces for that OS user.
|
|
@@ -93,16 +120,16 @@ See the [customization contract](../../docs/RUNTIME.md#frontend-customization).
|
|
|
93
120
|
For custom interfaces, the [resource API](../../docs/WORKSPACE_API.md) exposes
|
|
94
121
|
state, model catalogs, asynchronous command results, paginated history, event
|
|
95
122
|
replay and sub-agent/background-work inventories. A `mount(host)` export in
|
|
96
|
-
`custom.js` can access the built-in page's session, draft
|
|
123
|
+
`custom.js` can access the built-in page's session, draft, banner (`host.setBanner`)
|
|
124
|
+
and view controls, and host wrappers can embed `<script type="application/json" data-pycodex-banner>` banners.
|
|
97
125
|
|
|
98
126
|
Backend module ownership and the preserved session interfaces are documented in
|
|
99
127
|
the [runtime guide](../../docs/RUNTIME.md#workspace-session-api).
|
|
100
128
|
File/Git source resolution and view storage retain their existing public classes;
|
|
101
129
|
see [content views](../../docs/RUNTIME.md#workspace-content-views).
|
|
102
130
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
their source into your frontend. To share a local change, ask it to publish a
|
|
131
|
+
The Agent adapts the selected feature's source into your frontend.
|
|
132
|
+
To share a local change, ask it to publish a
|
|
106
133
|
feature PR on GitHub; the [contribution guide](workspace_server/optional_features/CONTRIBUTING.md)
|
|
107
134
|
specifies the source, documentation, validation and PR format.
|
|
108
135
|
|
|
@@ -128,24 +155,27 @@ permissions. An unprotected server must configure its administrator password
|
|
|
128
155
|
before enabling sharing. Router authentication is unchanged: a link through a
|
|
129
156
|
router still requires its normal login.
|
|
130
157
|
|
|
131
|
-
##
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
Copy the
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
## External Call
|
|
159
|
+
|
|
160
|
+
Open **Settings → External Call**, pick a profile and click
|
|
161
|
+
**Create session**. The workspace selects the new conversation and pins an
|
|
162
|
+
**External Call** banner at the top of the chat with **Copy Bash**,
|
|
163
|
+
**Copy PowerShell** and expandable **Details** for the full commands and
|
|
164
|
+
endpoint URL. Copy the command for your client machine and run it in a terminal.
|
|
165
|
+
|
|
166
|
+
Send the task from the Web conversation. External Call sessions inject
|
|
167
|
+
contextual guidance distinguishing the host workspace machine (`exec_command`
|
|
168
|
+
and other standard tools, `<environment_context>`, `AGENTS.md`, skills) from the
|
|
169
|
+
connected client machine (`client_exec_command`). The terminal prints each
|
|
170
|
+
command and its output, and returns the output and exit status to the
|
|
171
|
+
conversation. The Bash and PowerShell commands are client examples over the
|
|
172
|
+
session's `b/<code>` HTTP endpoint; custom scripts or executables (such as Python
|
|
173
|
+
or `cmd`) can pull commands with `GET` and return results with `POST` or `GET`.
|
|
174
|
+
|
|
175
|
+
Each new session gets its own connection code. Closing its tab invalidates that
|
|
176
|
+
code, releases pending requests and stops the terminal loop. After a server
|
|
177
|
+
restart, create a new session to reconnect a terminal. Previous conversations
|
|
178
|
+
retain their recorded history.
|
|
149
179
|
|
|
150
180
|
## Storage
|
|
151
181
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import logging
|
|
3
3
|
import secrets
|
|
4
|
-
import socket
|
|
5
|
-
from contextlib import asynccontextmanager
|
|
6
4
|
|
|
7
5
|
from websockets.exceptions import ConnectionClosed, InvalidHandshake, InvalidStatusCode
|
|
8
6
|
from websockets.legacy.client import connect
|
|
@@ -230,34 +228,3 @@ class RouterClient:
|
|
|
230
228
|
self._logger.warning("Router request disconnected (%s)", type(exc).__name__)
|
|
231
229
|
except Exception as exc:
|
|
232
230
|
self._logger.error("Router request failed (%s)", type(exc).__name__)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
def attach_router(app, registry, target, port):
|
|
236
|
-
def inventory():
|
|
237
|
-
return [
|
|
238
|
-
{
|
|
239
|
-
"id": workspace["id"],
|
|
240
|
-
"work_dir": workspace["work_dir"],
|
|
241
|
-
"state_path": workspace["state_path"],
|
|
242
|
-
"enable_board": workspace["enable_board"],
|
|
243
|
-
"session_count": len(workspace["sessions"]),
|
|
244
|
-
"running": any(session["running"] for session in workspace["sessions"]),
|
|
245
|
-
"unread": any(session["unread"] for session in workspace["sessions"]),
|
|
246
|
-
}
|
|
247
|
-
for workspace in registry.list_workspaces()
|
|
248
|
-
]
|
|
249
|
-
|
|
250
|
-
client = RouterClient(app, target, socket.gethostname(), port, inventory)
|
|
251
|
-
original_lifespan = app.router.lifespan_context
|
|
252
|
-
|
|
253
|
-
@asynccontextmanager
|
|
254
|
-
async def lifespan(application):
|
|
255
|
-
async with original_lifespan(application) as state:
|
|
256
|
-
await client.start()
|
|
257
|
-
try:
|
|
258
|
-
yield state
|
|
259
|
-
finally:
|
|
260
|
-
await client.close()
|
|
261
|
-
|
|
262
|
-
app.router.lifespan_context = lifespan
|
|
263
|
-
app.state.router_client = client
|
|
@@ -51,7 +51,7 @@ def agent_api_request(scope):
|
|
|
51
51
|
if scope["type"] != "http":
|
|
52
52
|
return False
|
|
53
53
|
match = re.fullmatch(
|
|
54
|
-
r"(?:/n/[a-z2-7]{5}(?:[a-z2-7]{47})?)?(?:/w/[^/]+)?/api/(workspaces|sessions|session|session/message)",
|
|
54
|
+
r"(?:/n/[a-z2-7]{5}(?:[a-z2-7]{47})?)?(?:/w/[^/]+)?/api/(workspaces|sessions|session|session/message|help)",
|
|
55
55
|
route_path(scope),
|
|
56
56
|
)
|
|
57
57
|
return match is not None and scope["method"] == (
|
|
@@ -59,11 +59,12 @@ def agent_api_request(scope):
|
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
def
|
|
62
|
+
def external_call_request(scope):
|
|
63
63
|
"""Only the terminal exchange endpoint; its workspace validates the temporary token."""
|
|
64
64
|
return (
|
|
65
|
-
scope["type"] == "http"
|
|
66
|
-
and
|
|
65
|
+
scope["type"] == "http"
|
|
66
|
+
and scope["method"] in {"GET", "POST"}
|
|
67
|
+
and re.fullmatch(r"(?:/w/[A-Za-z0-9_-]+)?/b/[^/]+", route_path(scope))
|
|
67
68
|
is not None
|
|
68
69
|
)
|
|
69
70
|
|
|
@@ -27,10 +27,10 @@ from pycodex_ws.workspace_config import normalize_workspace_id
|
|
|
27
27
|
|
|
28
28
|
from .browser import BrowserAccess, require_login
|
|
29
29
|
from .protocol import (
|
|
30
|
-
one_line_agent_request,
|
|
31
30
|
decode,
|
|
32
31
|
device_id,
|
|
33
32
|
encode,
|
|
33
|
+
external_call_request,
|
|
34
34
|
normalize_api_url,
|
|
35
35
|
request_scope,
|
|
36
36
|
response_headers,
|
|
@@ -432,7 +432,7 @@ class Router:
|
|
|
432
432
|
agent_access = trusted_agent_request(scope)
|
|
433
433
|
if blocked or not (
|
|
434
434
|
agent_access
|
|
435
|
-
or
|
|
435
|
+
or external_call_request(scope)
|
|
436
436
|
or auth_cookie_matches(
|
|
437
437
|
self.browser_token, connection.cookies.get("pycodex_router_auth")
|
|
438
438
|
)
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
from importlib import import_module
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def
|
|
6
|
+
def active_preview(active):
|
|
7
|
+
return active["reasoning"] or active["assistant_text"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def register_feishu_commands(runtime, preview_reasoning=False):
|
|
7
11
|
"""Attach Feishu commands and connection cleanup to an existing runtime."""
|
|
8
12
|
link = None
|
|
9
13
|
|
|
@@ -30,9 +34,11 @@ def register_feishu_commands(runtime):
|
|
|
30
34
|
raise ValueError("Usage: /link <feishu-email|open_id|chat_id>")
|
|
31
35
|
if link is not None:
|
|
32
36
|
raise RuntimeError("A Feishu card is already linked. Use /unlink first.")
|
|
37
|
+
from .feishu_card import PycodexCard
|
|
33
38
|
from .feishu_link import PycodexRuntimeLink
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
card = PycodexCard.from_env(preview_reasoning=preview_reasoning)
|
|
41
|
+
link = await PycodexRuntimeLink(runtime, target, card=card).start_async()
|
|
36
42
|
return {
|
|
37
43
|
"kind": "connection",
|
|
38
44
|
"lines": [
|
|
@@ -7,6 +7,7 @@ import requests
|
|
|
7
7
|
|
|
8
8
|
from pycodex.events import (
|
|
9
9
|
DEFAULT_MAIN_PROMPT,
|
|
10
|
+
AssistantDeltaEvent,
|
|
10
11
|
CommandCompletedEvent,
|
|
11
12
|
CommandFailedEvent,
|
|
12
13
|
Event,
|
|
@@ -14,15 +15,18 @@ from pycodex.events import (
|
|
|
14
15
|
InputQueuedEvent,
|
|
15
16
|
InputRequestedEvent,
|
|
16
17
|
MessagesAddedEvent,
|
|
18
|
+
ReasoningEvent,
|
|
17
19
|
SessionStateEvent,
|
|
18
20
|
StreamErrorEvent,
|
|
19
21
|
TurnCompletedEvent,
|
|
20
22
|
TurnFailedEvent,
|
|
23
|
+
TurnInterruptedEvent,
|
|
21
24
|
TurnStartedEvent,
|
|
22
25
|
)
|
|
23
26
|
from pycodex.protocol import AssistantMessage
|
|
24
27
|
from pycodex.utils.history import conversation_history_to_turns
|
|
25
28
|
|
|
29
|
+
from . import active_preview
|
|
26
30
|
from .feishu_auth import (
|
|
27
31
|
FEISHU_API_BASE,
|
|
28
32
|
FEISHU_DOMAIN,
|
|
@@ -42,6 +46,9 @@ CARD_CONTENT_ERROR_MARKER = "Failed to create card content"
|
|
|
42
46
|
|
|
43
47
|
|
|
44
48
|
class PycodexCard:
|
|
49
|
+
preview_reasoning = False
|
|
50
|
+
_preview = ""
|
|
51
|
+
|
|
45
52
|
def __init__(
|
|
46
53
|
self,
|
|
47
54
|
app_id: "typing.Union[str, None]" = None,
|
|
@@ -51,7 +58,9 @@ class PycodexCard:
|
|
|
51
58
|
verification_token: "typing.Union[str, None]" = None,
|
|
52
59
|
encrypt_key: "typing.Union[str, None]" = None,
|
|
53
60
|
session: "typing.Union[requests.Session, None]" = None,
|
|
61
|
+
preview_reasoning: bool = False,
|
|
54
62
|
) -> None:
|
|
63
|
+
self.preview_reasoning = preview_reasoning
|
|
55
64
|
self.app_id = app_id
|
|
56
65
|
self.app_secret = app_secret
|
|
57
66
|
self.api_base = api_base
|
|
@@ -83,9 +92,10 @@ class PycodexCard:
|
|
|
83
92
|
self._tenant_token_expires_at = 0.0
|
|
84
93
|
|
|
85
94
|
@classmethod
|
|
86
|
-
def from_env(cls) -> "PycodexCard":
|
|
95
|
+
def from_env(cls, preview_reasoning: bool = False) -> "PycodexCard":
|
|
87
96
|
api_base = os.environ.get("FEISHU_API_BASE", FEISHU_API_BASE)
|
|
88
97
|
return cls(
|
|
98
|
+
preview_reasoning=preview_reasoning,
|
|
89
99
|
app_id=_env("FEISHU_APP_ID", "LARK_APP_ID"),
|
|
90
100
|
app_secret=_env("FEISHU_APP_SECRET", "LARK_APP_SECRET"),
|
|
91
101
|
api_base=api_base,
|
|
@@ -175,7 +185,11 @@ class PycodexCard:
|
|
|
175
185
|
def detach(self) -> None:
|
|
176
186
|
self.detached = True
|
|
177
187
|
|
|
178
|
-
|
|
188
|
+
@property
|
|
189
|
+
def preview_output(self):
|
|
190
|
+
return self._preview or self.working_output
|
|
191
|
+
|
|
192
|
+
def apply_event(self, event: "Event", active_turn=None) -> None:
|
|
179
193
|
if isinstance(event, SessionStateEvent):
|
|
180
194
|
state = event.state
|
|
181
195
|
self.model_name = state["model"]
|
|
@@ -190,6 +204,8 @@ class PycodexCard:
|
|
|
190
204
|
self.history_index = None
|
|
191
205
|
active = state["active_turn"]
|
|
192
206
|
self.working_output = active["assistant_text"] if active is not None else ""
|
|
207
|
+
active_turn = active
|
|
208
|
+
self._preview = ""
|
|
193
209
|
self._active_turn_id = active["turn_id"] if active is not None else None
|
|
194
210
|
if active is not None:
|
|
195
211
|
current = self._append_messages(active["messages"], active["turn_id"])
|
|
@@ -219,6 +235,16 @@ class PycodexCard:
|
|
|
219
235
|
elif any(isinstance(message, AssistantMessage) for message in event.messages):
|
|
220
236
|
self.display.stream_buffer = ""
|
|
221
237
|
self.working_output = turn["response"] if turn else ""
|
|
238
|
+
if self.preview_reasoning:
|
|
239
|
+
if active_turn is not None:
|
|
240
|
+
self._preview = active_preview(active_turn)
|
|
241
|
+
elif isinstance(event, ReasoningEvent):
|
|
242
|
+
self._preview = event.text
|
|
243
|
+
elif isinstance(event, (
|
|
244
|
+
AssistantDeltaEvent, MessagesAddedEvent, StreamErrorEvent, TurnStartedEvent,
|
|
245
|
+
TurnCompletedEvent, TurnInterruptedEvent, TurnFailedEvent,
|
|
246
|
+
)):
|
|
247
|
+
self._preview = ""
|
|
222
248
|
event.render(self.display)
|
|
223
249
|
if self.display.stream_buffer:
|
|
224
250
|
self.working_output = self.display.stream_buffer
|
|
@@ -85,7 +85,8 @@ class PycodexRuntimeLink:
|
|
|
85
85
|
def _handle_runtime_event(self, event) -> None:
|
|
86
86
|
if self._detached:
|
|
87
87
|
return
|
|
88
|
-
self.
|
|
88
|
+
active = self.runtime.active_turn_snapshot() if self.card.preview_reasoning else None
|
|
89
|
+
self.card.apply_event(event, active)
|
|
89
90
|
self._update_card()
|
|
90
91
|
|
|
91
92
|
async def _submit(
|
|
@@ -13,7 +13,7 @@ def render_card(
|
|
|
13
13
|
status = "Closed" if state.display.closed else state.status
|
|
14
14
|
input_disabled = not state.accepts_input or state.detached or state.display.closed
|
|
15
15
|
output = _truncate(state.output_text, CARD_OUTPUT_LIMIT) or "Ready."
|
|
16
|
-
working_output = _truncate(state.
|
|
16
|
+
working_output = _truncate(state.preview_output, CARD_OUTPUT_LIMIT)
|
|
17
17
|
color = _status_color("Detached" if state.detached else status or "Idle")
|
|
18
18
|
body_elements = [
|
|
19
19
|
_output_box(
|