pycodex-ws 0.6.0__tar.gz → 0.6.2__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.
Files changed (126) hide show
  1. pycodex_ws-0.6.0/README.md → pycodex_ws-0.6.2/PKG-INFO +34 -0
  2. pycodex_ws-0.6.0/PKG-INFO → pycodex_ws-0.6.2/README.md +23 -11
  3. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/protocol.py +10 -1
  4. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/server.py +40 -8
  5. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/feishu_card.py +34 -19
  6. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/feishu_render.py +3 -1
  7. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/server_support.py +5 -2
  8. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pyproject.toml +2 -2
  9. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/WORKSPACE_API.md +131 -8
  10. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/app.py +162 -34
  11. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/content_views.mjs +7 -7
  12. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/content_views.mjs +3 -4
  13. pycodex_ws-0.6.2/workspace_server/one_line_agent.py +391 -0
  14. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/README.md +2 -0
  15. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/README.md +51 -0
  16. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/preview.png +0 -0
  17. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/source/custom.css +1 -0
  18. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/source/custom.js +6 -0
  19. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/source/skill-completion.css +21 -0
  20. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/source/skill-completion.mjs +175 -0
  21. pycodex_ws-0.6.2/workspace_server/optional_features/skill-completion/source/verify.mjs +19 -0
  22. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/README.md +151 -0
  23. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/preview-mobile.png +0 -0
  24. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/preview.png +0 -0
  25. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/source/custom.css +1 -0
  26. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/source/custom.js +6 -0
  27. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/source/verify.cjs +326 -0
  28. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/source/voice-input.css +46 -0
  29. pycodex_ws-0.6.2/workspace_server/optional_features/voice-input/source/voice-input.js +350 -0
  30. pycodex_ws-0.6.2/workspace_server/reloader.py +449 -0
  31. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/routes.py +21 -16
  32. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/session_view.py +81 -117
  33. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/workspace.html +303 -12
  34. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/workspaces.py +33 -3
  35. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/.gitignore +0 -0
  36. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/LICENSE +0 -0
  37. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/__init__.py +0 -0
  38. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/__main__.py +0 -0
  39. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/browser.py +0 -0
  40. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/client.py +0 -0
  41. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_router/index.html +0 -0
  42. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/__init__.py +0 -0
  43. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/feishu_auth.py +0 -0
  44. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/feishu_connection.py +0 -0
  45. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/feishu_link.py +0 -0
  46. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/feishu_oauth.py +0 -0
  47. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/pycodex_ws/workspace_config.py +0 -0
  48. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/__init__.py +0 -0
  49. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/__main__.py +0 -0
  50. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/agent_access.py +0 -0
  51. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/content_views.LICENSE.txt +0 -0
  52. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/content_views.css +0 -0
  53. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/customization.py +0 -0
  54. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/editor.css +0 -0
  55. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/editor.mjs +0 -0
  56. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/.gitignore +0 -0
  57. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/build.mjs +0 -0
  58. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/composer.mjs +0 -0
  59. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/content_views.css +0 -0
  60. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/editor.css +0 -0
  61. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/editor.mjs +0 -0
  62. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/editor_context.mjs +0 -0
  63. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/package-lock.json +0 -0
  64. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/package.json +0 -0
  65. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/prompt_history.mjs +0 -0
  66. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/touch_selection.mjs +0 -0
  67. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/transcript.mjs +0 -0
  68. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/frontend/view_labels.mjs +0 -0
  69. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/CONTRIBUTING.md +0 -0
  70. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/README.md +0 -0
  71. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/preview-mobile.png +0 -0
  72. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/preview.html +0 -0
  73. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/preview.png +0 -0
  74. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/source/custom.css +0 -0
  75. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/source/custom.js +0 -0
  76. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/source/fixture.mjs +0 -0
  77. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/clock-ticks/source/verify.mjs +0 -0
  78. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/README.md +0 -0
  79. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/preview-mobile.png +0 -0
  80. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/preview.html +0 -0
  81. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/preview.png +0 -0
  82. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/source/fixture.mjs +0 -0
  83. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/source/tool-groups.css +0 -0
  84. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/source/tool-groups.js +0 -0
  85. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/consecutive-tool-groups/source/verify.mjs +0 -0
  86. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/README.md +0 -0
  87. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/preview-mobile.png +0 -0
  88. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/preview.html +0 -0
  89. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/preview.png +0 -0
  90. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/source/custom.css +0 -0
  91. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/source/custom.js +0 -0
  92. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/source/fixture.mjs +0 -0
  93. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/exec-status/source/verify.mjs +0 -0
  94. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/README.md +0 -0
  95. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/preview-mobile.png +0 -0
  96. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/preview.html +0 -0
  97. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/preview.png +0 -0
  98. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/source/custom.css +0 -0
  99. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/source/custom.js +0 -0
  100. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/source/fixture.mjs +0 -0
  101. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/reasoning-display/source/verify.mjs +0 -0
  102. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/README.md +0 -0
  103. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/preview-mobile.png +0 -0
  104. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/preview.html +0 -0
  105. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/preview.png +0 -0
  106. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/source/custom.css +0 -0
  107. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/source/custom.js +0 -0
  108. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/source/fixture.mjs +0 -0
  109. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/source/session-tips.js +0 -0
  110. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/session-tips/source/verify.mjs +0 -0
  111. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/README.md +0 -0
  112. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/preview-mobile.png +0 -0
  113. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/preview.html +0 -0
  114. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/preview.png +0 -0
  115. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/source/custom.css +0 -0
  116. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/source/custom.js +0 -0
  117. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/source/fixture.mjs +0 -0
  118. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/optional_features/tool-calls/source/verify.mjs +0 -0
  119. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/owned_process.py +0 -0
  120. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/runtime_info.py +0 -0
  121. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/session_api.py +0 -0
  122. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/sessions.py +0 -0
  123. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/sharing.py +0 -0
  124. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/view_sources.py +0 -0
  125. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/workspace_views.py +0 -0
  126. {pycodex_ws-0.6.0 → pycodex_ws-0.6.2}/workspace_server/workspaces.html +0 -0
@@ -1,3 +1,14 @@
1
+ Metadata-Version: 2.1
2
+ Name: pycodex-ws
3
+ Version: 0.6.2
4
+ Summary: Browser workspace and optional Feishu integration for python-codex
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.7
7
+ Requires-Dist: pillow>=9.0.0
8
+ Requires-Dist: python-codex==0.6.2
9
+ Requires-Dist: websockets<16,>=11
10
+ Description-Content-Type: text/markdown
11
+
1
12
  # pycodex-ws
2
13
 
3
14
  Browser conversations, a live HTML Canvas, read-only file/diff viewers and
@@ -44,6 +55,10 @@ running sessions and unread replies. `/cd <directory>` changes the current
44
55
  session's working directory while idle; `/model`, `/resume`, `/compact` and
45
56
  other core session commands are also available.
46
57
 
58
+ Use **New session** for the default profile, or its **+** button to choose one.
59
+ Profiles reload when you open the chooser or create a session, so config changes
60
+ apply to new sessions without restarting the server. Existing sessions keep their configuration.
61
+
47
62
  Consecutive model reconnection diagnostics share one collapsed `Model retries`
48
63
  row per sequence. The summary shows the number of recorded retries, the latest
49
64
  attempt and its HTTP status when available. Expand it to read the original errors
@@ -124,6 +139,25 @@ permissions. An unprotected server must configure its administrator password
124
139
  before enabling sharing. Router authentication is unchanged: a link through a
125
140
  router still requires its normal login.
126
141
 
142
+ ## One-line Agent
143
+
144
+ An Agent that runs directly in most shells without installation, for bootstrapping
145
+ an Agent environment or simple debugging.
146
+
147
+ Open **Settings → One-line Agent**, choose a profile and click **Enable One-line Agent**.
148
+ Copy the Bash or PowerShell command, replace the example task `看一下这台机器`,
149
+ and run it in the target terminal. Commands execute on that machine; the terminal
150
+ shows their results and the Agent's final replies.
151
+
152
+ Leave the terminal running to continue the conversation from its workspace
153
+ session. When idle, you can also edit the task and rerun the command with the same
154
+ key to keep the existing history. For another terminal or an independent session,
155
+ change the key's final session suffix from `1` to `2`, `3`, etc.
156
+
157
+ Use **Stop** to end the service and its sessions. Closing a session and reusing
158
+ its key starts a fresh conversation. After a server restart, enable the service
159
+ again and copy a new command; recorded history is kept.
160
+
127
161
  ## Storage
128
162
 
129
163
  Paths in `workspaces.json` resolve from the configuration directory.
@@ -1,14 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: pycodex-ws
3
- Version: 0.6.0
4
- Summary: Browser workspace and optional Feishu integration for python-codex
5
- License-File: LICENSE
6
- Requires-Python: >=3.7
7
- Requires-Dist: pillow>=9.0.0
8
- Requires-Dist: python-codex==0.6.0
9
- Requires-Dist: websockets<16,>=11
10
- Description-Content-Type: text/markdown
11
-
12
1
  # pycodex-ws
13
2
 
14
3
  Browser conversations, a live HTML Canvas, read-only file/diff viewers and
@@ -55,6 +44,10 @@ running sessions and unread replies. `/cd <directory>` changes the current
55
44
  session's working directory while idle; `/model`, `/resume`, `/compact` and
56
45
  other core session commands are also available.
57
46
 
47
+ Use **New session** for the default profile, or its **+** button to choose one.
48
+ Profiles reload when you open the chooser or create a session, so config changes
49
+ apply to new sessions without restarting the server. Existing sessions keep their configuration.
50
+
58
51
  Consecutive model reconnection diagnostics share one collapsed `Model retries`
59
52
  row per sequence. The summary shows the number of recorded retries, the latest
60
53
  attempt and its HTTP status when available. Expand it to read the original errors
@@ -135,6 +128,25 @@ permissions. An unprotected server must configure its administrator password
135
128
  before enabling sharing. Router authentication is unchanged: a link through a
136
129
  router still requires its normal login.
137
130
 
131
+ ## One-line Agent
132
+
133
+ An Agent that runs directly in most shells without installation, for bootstrapping
134
+ an Agent environment or simple debugging.
135
+
136
+ Open **Settings → One-line Agent**, choose a profile and click **Enable One-line Agent**.
137
+ Copy the Bash or PowerShell command, replace the example task `看一下这台机器`,
138
+ and run it in the target terminal. Commands execute on that machine; the terminal
139
+ shows their results and the Agent's final replies.
140
+
141
+ Leave the terminal running to continue the conversation from its workspace
142
+ session. When idle, you can also edit the task and rerun the command with the same
143
+ key to keep the existing history. For another terminal or an independent session,
144
+ change the key's final session suffix from `1` to `2`, `3`, etc.
145
+
146
+ Use **Stop** to end the service and its sessions. Closing a session and reusing
147
+ its key starts a fresh conversation. After a server restart, enable the service
148
+ again and copy a new command; recorded history is kept.
149
+
138
150
  ## Storage
139
151
 
140
152
  Paths in `workspaces.json` resolve from the configuration directory.
@@ -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]{52})?(?:/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)",
55
55
  route_path(scope),
56
56
  )
57
57
  return match is not None and scope["method"] == (
@@ -59,6 +59,15 @@ def agent_api_request(scope):
59
59
  )
60
60
 
61
61
 
62
+ def one_line_agent_request(scope):
63
+ """Only the terminal exchange endpoint; its workspace validates the temporary token."""
64
+ return (
65
+ scope["type"] == "http" and scope["method"] == "POST"
66
+ and re.fullmatch(r"(?:/w/[A-Za-z0-9_-]+)?/b", route_path(scope))
67
+ is not None
68
+ )
69
+
70
+
62
71
  def trusted_agent_request(scope):
63
72
  # This flag comes only from the private socket or an authenticated tunnel
64
73
  # envelope, never from HTTP headers or the forwarded ASGI scope.
@@ -27,6 +27,7 @@ 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,
30
31
  decode,
31
32
  device_id,
32
33
  encode,
@@ -75,9 +76,10 @@ def normalize_alias(value):
75
76
 
76
77
 
77
78
  class Node:
78
- def __init__(self, websocket, node_id, name, workspaces):
79
+ def __init__(self, websocket, node_id, name, workspaces, identity_key):
79
80
  self.websocket = websocket
80
81
  self.id = node_id
82
+ self.identity_key = identity_key
81
83
  self.name = name
82
84
  self.workspaces = workspaces
83
85
  self.streams = {}
@@ -181,7 +183,7 @@ class Router:
181
183
  if self.aliases_path is not None and self.aliases_path.exists():
182
184
  aliases = json.loads(self.aliases_path.read_text(encoding="utf-8"))
183
185
  if not isinstance(aliases, dict) or any(
184
- not re.fullmatch("[a-z2-7]{52}", node_id)
186
+ not re.fullmatch("[a-z2-7]{16}(?:[a-z2-7]{36})?", node_id)
185
187
  or not isinstance(alias, str)
186
188
  or (alias and normalize_alias(alias) != alias)
187
189
  for node_id, alias in aliases.items()
@@ -273,7 +275,12 @@ class Router:
273
275
  node_id = device_id(authorization[7:])
274
276
  except ValueError:
275
277
  return None
276
- return self.nodes.get(node_id)
278
+ node = self.nodes.get(node_id)
279
+ if node is not None and secrets.compare_digest(
280
+ authorization[7:], node.identity_key,
281
+ ):
282
+ return node
283
+ return None
277
284
 
278
285
  async def control(self, websocket):
279
286
  if not await self.accept_tunnel(websocket):
@@ -307,10 +314,19 @@ class Router:
307
314
  node_id,
308
315
  name,
309
316
  validate_inventory(message["workspaces"]),
317
+ message["identity_key"],
310
318
  )
311
319
  if node_id not in self.aliases:
312
320
  aliases = dict(self.aliases)
313
- aliases[node_id] = ""
321
+ short_id = node_id[:16]
322
+ if short_id in aliases:
323
+ # Recover names/order saved by the earlier short-identity version.
324
+ aliases = {
325
+ node_id if key == short_id else key: alias
326
+ for key, alias in aliases.items()
327
+ }
328
+ else:
329
+ aliases[node_id] = ""
314
330
  self._save_aliases(aliases)
315
331
  self.nodes[node_id] = node
316
332
  api_url = self.api_url
@@ -350,10 +366,12 @@ class Router:
350
366
  try:
351
367
  message = await asyncio.wait_for(control_message(websocket), 10)
352
368
  stream = self.streams.get(message["stream_id"])
369
+ node = self.nodes.get(stream.node_id) if stream is not None else None
353
370
  if (
354
371
  stream is None
372
+ or node is None
355
373
  or stream.ready.done()
356
- or device_id(message["identity_key"]) != stream.node_id
374
+ or not secrets.compare_digest(message["identity_key"], node.identity_key)
357
375
  ):
358
376
  await close_websocket(websocket, 1008)
359
377
  return
@@ -367,15 +385,22 @@ class Router:
367
385
  finally:
368
386
  await close_websocket(websocket)
369
387
 
388
+ def node_for_route(self, route_id):
389
+ if len(route_id) != 5:
390
+ return self.nodes.get(route_id)
391
+ # Include offline identities so a saved short link cannot target a peer.
392
+ matches = [node_id for node_id in self.aliases if node_id[:5] == route_id]
393
+ return self.nodes.get(matches[0]) if len(matches) == 1 else None
394
+
370
395
  @asynccontextmanager
371
396
  async def connection(self, node_id):
372
- node = self.nodes.get(node_id)
397
+ node = self.node_for_route(node_id)
373
398
  if node is None:
374
399
  raise TunnelUnavailable("Workspace device is offline.")
375
400
  if len(node.streams) >= self.max_connections:
376
401
  raise TunnelUnavailable("Workspace device has too many open requests.")
377
402
  stream_id = uuid4().hex
378
- stream = Stream(node_id)
403
+ stream = Stream(node.id)
379
404
  node.streams[stream_id] = stream
380
405
  self.streams[stream_id] = stream
381
406
  try:
@@ -407,6 +432,7 @@ class Router:
407
432
  agent_access = trusted_agent_request(scope)
408
433
  if blocked or not (
409
434
  agent_access
435
+ or one_line_agent_request(scope)
410
436
  or auth_cookie_matches(
411
437
  self.browser_token, connection.cookies.get("pycodex_router_auth")
412
438
  )
@@ -491,7 +517,13 @@ class Router:
491
517
  if node_id not in self.nodes:
492
518
  continue
493
519
  node = self.nodes[node_id]
494
- base = request.scope.get("root_path", "") + "/n/" + node.id + "/"
520
+ route_id = node.id
521
+ # Older Agent API bridges only accept full identity paths.
522
+ if not request.scope.get("pycodex.agent_access"):
523
+ short_id = node.id[:5]
524
+ if self.node_for_route(short_id) is node:
525
+ route_id = short_id
526
+ base = request.scope.get("root_path", "") + "/n/" + route_id + "/"
495
527
  nodes.append({
496
528
  "id": node.id,
497
529
  "name": node.name,
@@ -13,13 +13,15 @@ from pycodex.events import (
13
13
  EventDisplay,
14
14
  InputQueuedEvent,
15
15
  InputRequestedEvent,
16
+ MessagesAddedEvent,
16
17
  SessionStateEvent,
17
18
  StreamErrorEvent,
18
19
  TurnCompletedEvent,
19
20
  TurnFailedEvent,
20
21
  TurnStartedEvent,
21
22
  )
22
- from pycodex.utils.event_helpers import completed_history
23
+ from pycodex.protocol import AssistantMessage
24
+ from pycodex.utils.history import conversation_history_to_turns
23
25
 
24
26
  from .feishu_auth import (
25
27
  FEISHU_API_BASE,
@@ -182,42 +184,48 @@ class PycodexCard:
182
184
  if event.reason in {"attach", "history"}:
183
185
  self.output_text = ""
184
186
  self.activity_text = ""
185
- self.turn_history = list(completed_history(state))
187
+ self.turn_history = [
188
+ turn for turn in state["history"] if turn["kind"] == "assistant"
189
+ ]
186
190
  self.history_index = None
187
191
  active = state["active_turn"]
188
192
  self.working_output = active["assistant_text"] if active is not None else ""
189
193
  self._active_turn_id = active["turn_id"] if active is not None else None
190
- self.user_prompt = (
191
- "\n".join(active["user_texts"])
192
- if active is not None
193
- else self.turn_history[-1][0] if self.turn_history else ""
194
- )
194
+ if active is not None:
195
+ current = self._append_messages(active["messages"], active["turn_id"])
196
+ if not self.working_output and current is not None:
197
+ self.working_output = current["response"]
198
+ else:
199
+ current = self.turn_history[-1] if self.turn_history else None
200
+ self.user_prompt = "\n".join(message.text for message in current["messages"]) if current else ""
195
201
  self.display.stream_buffer = ""
196
202
  self.prompt_text = DEFAULT_MAIN_PROMPT
197
203
  if state["busy"]:
198
204
  self._set_status("working")
199
205
  else:
200
206
  self.display.set_idle_status(state["background_work_count"])
201
- for _prompt, response in self.turn_history[-1:]:
202
- self.output_text = response
207
+ for turn in (self.earlier_turns() if active is not None else self.turn_history)[-1:]:
208
+ self.output_text = turn["response"]
203
209
  if state["busy"]:
204
210
  self._mark_last_turn_output()
205
- elif isinstance(event, (InputQueuedEvent, TurnStartedEvent)):
211
+ elif isinstance(event, InputQueuedEvent):
206
212
  self._mark_last_turn_output()
213
+ elif isinstance(event, (TurnStartedEvent, MessagesAddedEvent)):
214
+ turn = self._append_messages(event.messages, event.turn_id)
215
+ self.user_prompt = "\n".join(message.text for message in turn["messages"]) if turn else ""
207
216
  if isinstance(event, TurnStartedEvent):
208
- prompt = event.visualize()
209
- if event.turn_id == self._active_turn_id and self.user_prompt:
210
- self.user_prompt += "\n" + prompt
211
- else:
212
- self.user_prompt = prompt
217
+ self._mark_last_turn_output()
213
218
  self._active_turn_id = event.turn_id
219
+ elif any(isinstance(message, AssistantMessage) for message in event.messages):
220
+ self.display.stream_buffer = ""
221
+ self.working_output = turn["response"] if turn else ""
214
222
  event.render(self.display)
215
223
  if self.display.stream_buffer:
216
224
  self.working_output = self.display.stream_buffer
217
225
  if isinstance(event, TurnCompletedEvent):
218
- if event.output_text:
219
- self.output_text = event.output_text
220
- self.turn_history.append((self.user_prompt, event.output_text))
226
+ for turn in self.turn_history:
227
+ if turn["turn_id"] == event.turn_id and turn["response"]:
228
+ self.output_text = turn["response"]
221
229
  self.activity_text = ""
222
230
  self.working_output = ""
223
231
  self._active_turn_id = None
@@ -232,6 +240,13 @@ class PycodexCard:
232
240
  request = event.state["input_request"]
233
241
  self.activity_text = request.visualize() if request is not None else ""
234
242
 
243
+ def _append_messages(self, messages, turn_id):
244
+ self.turn_history = [
245
+ turn for turn in conversation_history_to_turns(messages, self.turn_history)
246
+ if turn["kind"] == "assistant"
247
+ ]
248
+ return next((turn for turn in self.turn_history if turn["turn_id"] == turn_id), None)
249
+
235
250
  def _mark_last_turn_output(self) -> None:
236
251
  prefix = "(*last turn)\n"
237
252
  if self.output_text and not self.output_text.startswith(prefix):
@@ -252,7 +267,7 @@ class PycodexCard:
252
267
 
253
268
  def earlier_turns(self):
254
269
  if self._active_turn_id is not None:
255
- return self.turn_history
270
+ return [turn for turn in self.turn_history if turn["turn_id"] != self._active_turn_id]
256
271
  return self.turn_history[:-1]
257
272
 
258
273
  def show_history(self, index):
@@ -126,7 +126,9 @@ def _render_output_content(output: str, output_mode: str) -> str:
126
126
 
127
127
 
128
128
  def _history_panel(history, index, expanded, output_mode, interactive):
129
- prompt, response = history[index]
129
+ turn = history[index]
130
+ prompt = "\n".join(message.text for message in turn["messages"])
131
+ response = turn["response"]
130
132
  content = _truncate(
131
133
  "user> {0}\n\nassistant> {1}".format(prompt, response), CARD_OUTPUT_LIMIT
132
134
  )
@@ -15,7 +15,7 @@ from starlette.requests import Request
15
15
  from starlette.responses import HTMLResponse, JSONResponse, RedirectResponse
16
16
  from starlette.routing import Route
17
17
 
18
- from pycodex_router.protocol import route_path, trusted_agent_request
18
+ from pycodex_router.protocol import one_line_agent_request, route_path, trusted_agent_request
19
19
 
20
20
  AUTH_COOKIE_NAME = "pycodex_ws_auth"
21
21
 
@@ -199,6 +199,9 @@ def install_auth(
199
199
  root = request.scope.get("root_path", "")
200
200
  if sharing is not None:
201
201
  target = sharing.workspace(path)
202
+ if one_line_agent_request(request.scope):
203
+ # This endpoint validates its own workspace-scoped temporary token.
204
+ return await call_next(request)
202
205
  cookie = request.cookies.get(cookie_name)
203
206
  if path in {"/favicon.ico", "/login"}:
204
207
  return await call_next(request)
@@ -207,7 +210,7 @@ def install_auth(
207
210
  return await call_next(request)
208
211
  grant = None if target is None else sharing.grant(target[0], cookie)
209
212
  if grant is not None:
210
- if target[1].rstrip("/") == "/api/share":
213
+ if target[1].rstrip("/") in {"/api/share", "/api/reload", "/api/one-line-agent"}:
211
214
  return JSONResponse({"error": "administrator access required"}, 403)
212
215
  request.scope["pycodex.access_role"] = "visitor"
213
216
  return await call_next(request)
@@ -4,12 +4,12 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pycodex-ws"
7
- version = "0.6.0"
7
+ version = "0.6.2"
8
8
  description = "Browser workspace and optional Feishu integration for python-codex"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
11
11
  dependencies = [
12
- "python-codex==0.6.0",
12
+ "python-codex==0.6.2",
13
13
  "pillow>=9.0.0",
14
14
  "websockets>=11,<16",
15
15
  ]
@@ -35,19 +35,108 @@ Custom frontends can use `__ACCESS_ROLE__` to hide management controls; authoriz
35
35
  is enforced on the server regardless of UI visibility. Sharing does not reduce
36
36
  Agent execution permissions, and does not replace Router authentication.
37
37
 
38
+ ## One-line Agent
39
+
40
+ `GET/POST/DELETE api/one-line-agent` require workspace administrator authentication.
41
+ POST requires `{"profile": "<name>"}`; `null` selects the current default.
42
+ It enables the workspace's single reusable One-line Agent service without creating a
43
+ session. An existing enabled service returns 409; DELETE revokes it and closes all
44
+ its runs. GET and successful mutations return `{binding, profiles, default_profile}`
45
+ with `Cache-Control: no-store`.
46
+ `binding` is null when no service is registered; otherwise it contains `session_id`
47
+ (latest session whose tab is still open, or null), `session_count` (open session
48
+ tabs, including completed conversations), `profile`,
49
+ `enabled` and
50
+ `one_liners: {linux, windows}` (null after revocation). One-liners contain the
51
+ temporary credential; these responses are administrator-only and not persisted.
52
+ The selected profile is loaded directly; ordinary workspace session factories are
53
+ unchanged. Recorded history is retained, but temporary tabs are not restored after
54
+ a server restart.
55
+
56
+ `POST b` uses `T`, independently of workspace and Router
57
+ cookies. The short path is relative to the workspace URL, retaining any
58
+ Router/node/workspace prefix. This is the only POST endpoint reachable with
59
+ the token. The first 12 characters of `T` must match the workspace's token
60
+ (72 random bits, URL-safe); the remaining nonempty suffix identifies a session.
61
+ The token and every derived key remain valid until explicit revocation or
62
+ server restart. The supplied one-liners hardcode suffix `1`; use a different suffix for
63
+ an independent session or concurrent client. Suffixes are opaque strings, not counters
64
+ allocated or advanced by the server.
65
+
66
+ The first request for a suffix immediately creates a session and submits its body
67
+ as the task. Its initial tab title is `OneLineAgent-<suffix>`. Subsequent requests
68
+ with the same complete key return command results to that session and wait for
69
+ the next command. Task completion returns a quoted `echo` command containing the
70
+ final response; after its result is acknowledged, the channel waits for more
71
+ commands. Interruption and model failure leave the waiting request pending.
72
+ Further prompts and steer use the ordinary Web session input
73
+ (`POST api/session/message` or its WebSocket equivalent), retaining the Runtime
74
+ and history. Steer waits for issued synchronous commands to return before
75
+ starting the revised turn.
76
+ If the existing Runtime is idle and no command result is pending, a new request
77
+ with the same key treats its body as a new task and reuses that Runtime/history.
78
+ The adapter replaces the old reply channel before admitting the task; any previous
79
+ waiting request ends with HTTP 409 (`terminal connection was replaced`), so it
80
+ cannot consume the new caller's command. Idle status is queried on the session's
81
+ worker loop. During model execution or startup, a request with no pending command
82
+ result is rejected with 409.
83
+ There is no handshake, step counter, replay cache or
84
+ automatic retry. Closing a session ends that Runtime; the next request with its
85
+ key creates a fresh session and treats the body as its first task. It does not
86
+ restore the closed session's history. Service revocation still
87
+ invalidates every derived key and releases waiting requests with HTTP errors.
88
+ A missing suffix or invalid task returns 422.
89
+ Use one terminal loop per key.
90
+
91
+ Every client sends raw UTF-8 text. The initial body is only the prompt, with no cwd
92
+ or other client metadata. Command-result bodies contain combined stdout/stderr followed
93
+ by `LF + [exit N]`, where `N` is the integer process exit code. Invalid UTF-8 or
94
+ result format returns 422. Requests are limited to 1 MiB on the wire (413).
95
+ Successful responses are `text/plain; charset=utf-8`: the next tool `cmd` or a
96
+ server-generated `echo` command displaying the final response.
97
+ Idle requests remain pending; there is no polling or empty completion response.
98
+ No session ID, message type or platform-specific encoding is returned.
99
+ Final text is quoted literally
100
+ for Bash and PowerShell, including ASCII and typographic apostrophes. Its display
101
+ command uses the same raw command/result protocol. The server consumes that
102
+ result regardless of exit code, without adding a tool result or user message to
103
+ model history. It tracks the command actually sent, so the display acknowledgement
104
+ cannot resolve a queued tool's result. All assistant messages retain their normal
105
+ workspace history; commentary is not sent to the terminal.
106
+ Model failures remain visible in the
107
+ Web session while the execution channel waits for commands from later turns.
108
+
109
+ The client executes each response locally, displays the command and completed
110
+ result, and returns that result. The one-liner contains an
111
+ editable example task and starts without an input prompt. Bash uses curl's
112
+ `--data-raw`; PowerShell uses `irm` with a UTF-8 byte body. `exec_command` accepts only `cmd`;
113
+ each command inherits the terminal's current directory without automatic `cd`.
114
+ The complete client loop remains inline in the one-liner; no startup script is fetched.
115
+
116
+ Requests wait for the next command regardless of task boundaries. Clients execute a response
117
+ only after the HTTP request succeeds, and stop on any network or HTTP error. The server
118
+ session can still be inspected or closed from the workspace after a client exits.
119
+ The local loop has no task-completion exit condition and stays connected for Web
120
+ follow-ups. An idle session can also be continued by rerunning the one-liner with
121
+ the same key and a new task. This does not replay disconnected command execution or restore sessions
122
+ after server restart.
123
+
38
124
  ## Creating sessions
39
125
 
40
126
  `GET api/sessions` returns `{sessions, profiles, default_profile}`. `profiles`
41
127
  contains only names from the server's Codex config; no provider configuration
42
128
  or credentials are returned. The catalog combines adjacent `*.config.toml` files
43
- and embedded `[profiles.NAME]` tables and rejects duplicate names. It is loaded
44
- when the workspace is built. `default_profile` is the launch `--profile`, then
45
- the top-level config `profile`, or `null` for the base configuration.
129
+ and embedded `[profiles.NAME]` tables and rejects duplicate names. It is reloaded
130
+ on every catalog request and session creation; additions, edits and removals
131
+ take effect without restarting the server. Responses use `Cache-Control: no-store`.
132
+ `default_profile` is the launch `--profile`, then the current top-level config
133
+ `profile`, or `null` for the base configuration. Invalid catalog configuration
134
+ or duplicate names return HTTP 400 rather than a stale catalog.
46
135
  Each session list entry includes its effective `profile` name or `null`.
47
136
 
48
137
  `POST api/sessions` accepts `{title?, prompt?, profile?, name?}`. Title and prompt are
49
138
  strings and default to empty. Profile is a string name; omission or `null` uses
50
- the server default. An unknown name returns HTTP 400; an invalid field type
139
+ the current server default. An unknown or removed name returns HTTP 400; an invalid field type
51
140
  returns HTTP 422. An empty body still creates a default session.
52
141
  The selected profile configures both the model and Agent instructions; CLI
53
142
  overrides still apply. A nonempty prompt is submitted through Runtime.
@@ -94,10 +183,12 @@ State includes:
94
183
 
95
184
  - `model: {name, reasoning_effort}`, `title`, and `cwd`;
96
185
  - `busy`, `running`, `closed`, and `accepts_input`;
97
- - `active_turn`: IDs, user texts, accumulated assistant text and model errors,
186
+ - `active_turn`: IDs, complete `messages` passed to the current execution,
187
+ accumulated assistant text and model errors,
98
188
  or `null`; completed history is excluded;
99
189
  - `queued_inputs`: `submission_id`, `turn_id`, `queue` (`steer` or `enqueue`)
100
- and `prompts`, in execution order; merged steer inputs share one ID;
190
+ and visible input `messages`, in execution order; merged steer inputs share one
191
+ submission ID while each message retains its own ID, author and creation time;
101
192
  - `commands`: currently queued/running commands with their submission IDs;
102
193
  - `input_request`, `plan`, and `background_work_count`;
103
194
  - `context_window`, `max_context_window`, `auto_compact_token_limit`,
@@ -205,8 +296,30 @@ It is returned as `payload.name` on user messages in the history API; old record
205
296
  without the field use `"user"`. Recording-enabled sessions persist it in the
206
297
  rollout and restore it on resume, including retained messages in compaction
207
298
  checkpoints. Unrecorded sessions keep it in memory. Model request serialization omits `name`, including
208
- after resume and during compaction. The built-in frontend does not display it;
209
- its aggregated conversation snapshots remain unchanged.
299
+ after resume and during compaction.
300
+
301
+ The display snapshot at `GET api/session` exposes `turns[].messages` as an ordered
302
+ array of `{message_id, text, name, created_at}`. Each input appears separately
303
+ with its author and time, including inputs with identical text. `prompt` is
304
+ derived by joining those texts, and `prompt_at` is the first input's creation
305
+ time. `response_at` is the committed assistant message's creation time. These
306
+ timestamps survive queueing, steer and resume; unknown legacy times stay `null`.
307
+ `response_phase` carries the latest committed assistant message's phase. While
308
+ the turn is running, non-final replies retain the temporary-reply animation,
309
+ including after commentary is committed and tools are executing.
310
+ Temporary replies omit the displayed timestamp and duration; their stored
311
+ creation time remains available in the snapshot and rollout.
312
+ Local message IDs are distinct from provider response-item `id` values and are
313
+ not sent to the model. Legacy display messages receive stable IDs on read.
314
+ Restoration reads backwards from the rollout tail for the latest 80 complete
315
+ display rows, including compaction markers. This display limit does not truncate
316
+ the active model context restored by resume.
317
+
318
+ Wire events carry complete message data in `input_queued.payload.message`,
319
+ `turn_started.payload.messages` and `messages_added.payload.messages`.
320
+ `messages_added` means history was committed, including retained partial replies;
321
+ terminal events update execution status. Attach/history snapshots restore the
322
+ view directly without replaying turn or stream events.
210
323
 
211
324
  Regular workspace message receipts are also queryable. Their successful result
212
325
  contains `turn_id`, `output_text`, and `iterations`. Command events observed
@@ -277,6 +390,15 @@ are created when first observed and have separate cursors, excluding earlier
277
390
  events. Their WS connection is read-only: `ping` works; `send`/`answer` is rejected.
278
391
  Observing a child does not enable interactive requests or rollout recording.
279
392
 
393
+ ## Skill catalog
394
+
395
+ `GET api/skills` returns `{skills: [{name, description}]}` with `Cache-Control:
396
+ no-store`. It uses the workspace's configured Codex home and the shared
397
+ `list_skills` discovery operation. Workspace authentication and URL scoping apply;
398
+ no model session is created, and file paths or skill bodies are not returned.
399
+ Optional frontend code performs matching and insertion through the existing
400
+ extension host. The default page makes no automatic skill catalog requests.
401
+
280
402
  ## Built-in page extension host
281
403
 
282
404
  An optional `mount(host)` export in `~/.pycodex/frontend/custom.js` is called
@@ -306,6 +428,7 @@ The frozen host has `apiVersion: 1`:
306
428
  | `selectSession(id)` | Switch to an existing tab; returns a promise |
307
429
  | `onSessionChanged(handler)` | Subscribe; returns an unsubscribe function |
308
430
  | `getDraft()` | Structured composer draft, including context parts |
431
+ | `replaceDraftText(start, end, text)` | Undoable text replacement using draft offsets; context parts count as one position |
309
432
  | `setDraft(draft)` | Replace current draft; `draft.parts` must be an array |
310
433
  | `openView(href, srcPath)` | Open a file/Git/workspace link for the current session |
311
434
  | `request(path, options)` | Fetch workspace-relative JSON; HTTP failures reject |