agent-log-server 0.2.122__py3-none-android_24_arm64_v8a.whl

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 (256) hide show
  1. agent_log_server-0.2.122.dist-info/METADATA +186 -0
  2. agent_log_server-0.2.122.dist-info/RECORD +256 -0
  3. agent_log_server-0.2.122.dist-info/WHEEL +5 -0
  4. agent_log_server-0.2.122.dist-info/entry_points.txt +4 -0
  5. agent_log_server-0.2.122.dist-info/licenses/LICENSE +649 -0
  6. agent_log_server-0.2.122.dist-info/top_level.txt +6 -0
  7. agent_log_server_rs/DEVELOPER_MESSAGE_TEMPLATE.md +517 -0
  8. agent_log_server_rs/__init__.py +1 -0
  9. agent_log_server_rs/adapter_protocol.py +548 -0
  10. agent_log_server_rs/adapters/__init__.py +1 -0
  11. agent_log_server_rs/adapters/embedded_adapter.py +157 -0
  12. agent_log_server_rs/adapters/extension_adapter.py +1925 -0
  13. agent_log_server_rs/adapters/rpc_common.py +137 -0
  14. agent_log_server_rs/bin/als-server +0 -0
  15. agent_log_server_rs/bin/als-server.manifest.json +10 -0
  16. agent_log_server_rs/bootstrap.py +706 -0
  17. agent_log_server_rs/codec.py +85 -0
  18. agent_log_server_rs/extension_cli.py +520 -0
  19. agent_log_server_rs/rust/crates/als-server/src/static/app.js +151 -0
  20. agent_log_server_rs/rust/crates/als-server/src/static/appserver.css +240 -0
  21. agent_log_server_rs/rust/crates/als-server/src/static/appserver.js +208 -0
  22. agent_log_server_rs/rust/crates/als-server/src/static/codex_agent.css +4024 -0
  23. agent_log_server_rs/rust/crates/als-server/src/static/codex_agent.ts +2610 -0
  24. agent_log_server_rs/rust/crates/als-server/src/static/codexas-icon.svg +5 -0
  25. agent_log_server_rs/rust/crates/als-server/src/static/dist/codex_agent.js +26 -0
  26. agent_log_server_rs/rust/crates/als-server/src/static/dist/codex_agent.js.map +7 -0
  27. agent_log_server_rs/rust/crates/als-server/src/static/images/green-right-arrow.png +0 -0
  28. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/approvals/ui.ts +949 -0
  29. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/assistant_stream.ts +165 -0
  30. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/boot/init_flow.ts +341 -0
  31. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/boot/input_flow.ts +592 -0
  32. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/client_identity.ts +10 -0
  33. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/composer/runtime.ts +1065 -0
  34. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation/runtime.ts +345 -0
  35. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer/actions.ts +523 -0
  36. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer/index.ts +100 -0
  37. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer/list.ts +966 -0
  38. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer.ts +1 -0
  39. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_modal.ts +147 -0
  40. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/diff/rendering.ts +857 -0
  41. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/events/router.ts +779 -0
  42. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/events/socket.ts +140 -0
  43. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/host/runtime.ts +357 -0
  44. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/layout/viewport.ts +95 -0
  45. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/layout/widescreen.ts +168 -0
  46. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/markdown.ts +576 -0
  47. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/orchestrator/rpc_flow.ts +73 -0
  48. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/orchestrator/session_flow.ts +191 -0
  49. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/path_label.ts +76 -0
  50. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/plan/runtime.ts +446 -0
  51. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/plan_modal.ts +102 -0
  52. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/plan_overlay.ts +235 -0
  53. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/project_modal.ts +1398 -0
  54. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/render/utils.ts +456 -0
  55. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/request_cards/runtime.ts +236 -0
  56. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/conversations/client.ts +1021 -0
  57. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/conversations/contract.ts +406 -0
  58. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/namespaces.ts +18 -0
  59. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/registry.ts +113 -0
  60. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/settings/client.ts +662 -0
  61. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/settings/contract.ts +49 -0
  62. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/transport.ts +463 -0
  63. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/ui/client.ts +588 -0
  64. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/ui/contract.ts +50 -0
  65. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/runtime_footer.ts +373 -0
  66. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/settings/runtime_helpers.ts +20 -0
  67. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/settings/save_flow.ts +332 -0
  68. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/settings/ui_flow.ts +1148 -0
  69. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/shared_types.ts +61 -0
  70. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/shell_render.ts +377 -0
  71. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/shell_semantic.ts +606 -0
  72. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/subagents/collapsible.ts +224 -0
  73. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/terminal_ansi.ts +134 -0
  74. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/live_items.ts +594 -0
  75. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/replay.ts +820 -0
  76. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/rows.ts +290 -0
  77. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/virtualizer.ts +1123 -0
  78. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline_sticky_headers.ts +492 -0
  79. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/tool_render.ts +789 -0
  80. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_card_metadata.ts +228 -0
  81. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_cards.ts +780 -0
  82. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_config.ts +10 -0
  83. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_loader.ts +511 -0
  84. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_metrics.ts +28 -0
  85. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_stream.ts +561 -0
  86. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_stream_url.ts +7 -0
  87. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/vendor_modules.d.ts +5 -0
  88. agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/vendor_runtime.ts +106 -0
  89. agent_log_server_rs/rust/crates/als-server/src/static/js/console_bridge.js +229 -0
  90. agent_log_server_rs/rust/crates/als-server/src/static/js/socketio_runtime.js +27 -0
  91. agent_log_server_rs/rust/crates/als-server/src/static/modals/rollout_picker.ts +46 -0
  92. agent_log_server_rs/rust/crates/als-server/src/static/modals/settings_modal.ts +63 -0
  93. agent_log_server_rs/rust/crates/als-server/src/static/modals/settings_schema.ts +3666 -0
  94. agent_log_server_rs/rust/crates/als-server/src/static/modals/warning_modal.ts +65 -0
  95. agent_log_server_rs/rust/crates/als-server/src/static/style.css +194 -0
  96. agent_log_server_rs/rust/crates/als-server/src/static/ui/extension_settings.ts +493 -0
  97. agent_log_server_rs/rust/crates/als-server/src/static/ui/splash_settings.ts +41 -0
  98. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-400-italic.woff2 +0 -0
  99. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-400-normal.woff2 +0 -0
  100. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-500-italic.woff2 +0 -0
  101. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-500-normal.woff2 +0 -0
  102. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-600-italic.woff2 +0 -0
  103. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-600-normal.woff2 +0 -0
  104. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-700-italic.woff2 +0 -0
  105. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-700-normal.woff2 +0 -0
  106. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-400-italic.woff2 +0 -0
  107. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-400-normal.woff2 +0 -0
  108. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-500-italic.woff2 +0 -0
  109. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-500-normal.woff2 +0 -0
  110. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-600-italic.woff2 +0 -0
  111. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-600-normal.woff2 +0 -0
  112. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-700-italic.woff2 +0 -0
  113. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-700-normal.woff2 +0 -0
  114. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-400-italic.woff2 +0 -0
  115. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-400-normal.woff2 +0 -0
  116. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-500-italic.woff2 +0 -0
  117. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-500-normal.woff2 +0 -0
  118. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-600-italic.woff2 +0 -0
  119. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-600-normal.woff2 +0 -0
  120. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-700-italic.woff2 +0 -0
  121. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-700-normal.woff2 +0 -0
  122. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-400-italic.woff2 +0 -0
  123. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
  124. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-500-italic.woff2 +0 -0
  125. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2 +0 -0
  126. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-600-italic.woff2 +0 -0
  127. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2 +0 -0
  128. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-700-italic.woff2 +0 -0
  129. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2 +0 -0
  130. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-italic.woff2 +0 -0
  131. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
  132. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-italic.woff2 +0 -0
  133. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-normal.woff2 +0 -0
  134. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-italic.woff2 +0 -0
  135. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-normal.woff2 +0 -0
  136. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-italic.woff2 +0 -0
  137. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-normal.woff2 +0 -0
  138. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-400-italic.woff2 +0 -0
  139. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-400-normal.woff2 +0 -0
  140. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-500-italic.woff2 +0 -0
  141. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-500-normal.woff2 +0 -0
  142. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-600-italic.woff2 +0 -0
  143. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-600-normal.woff2 +0 -0
  144. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-700-italic.woff2 +0 -0
  145. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-700-normal.woff2 +0 -0
  146. agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono.css +481 -0
  147. agent_log_server_rs/rust/crates/als-server/src/static/vendor/socket.io/socket.io.min.js +7 -0
  148. agent_log_server_rs/rust/crates/als-server/src/static/vendor/socket.io-msgpack-parser/socket.io-msgpack-parser.js +2 -0
  149. agent_log_server_rs/rust/crates/als-server/src/static/vendor/socket.io-msgpack-parser/socket.io-msgpack-parser.js.map +7 -0
  150. agent_log_server_rs/rust/crates/als-server/src/static/vendor/tree-sitter-bash/highlights.scm +56 -0
  151. agent_log_server_rs/rust/crates/als-server/src/static/vendor/tree-sitter-bash/tree-sitter-bash.wasm +0 -0
  152. agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/tree-sitter.js +3278 -0
  153. agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/tree-sitter.wasm +0 -0
  154. agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/web-tree-sitter.js +4007 -0
  155. agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/web-tree-sitter.wasm +0 -0
  156. agent_log_server_rs/shellspec/extension_adapter.yaml +15 -0
  157. agent_log_server_rs/tests/test_bootstrap.py +435 -0
  158. agent_log_server_rs/tests/test_codec.py +97 -0
  159. agent_log_server_rs/tests/test_codex_ext_client_resume.py +37 -0
  160. agent_log_server_rs/tests/test_codex_ext_router_atomic_diff.py +221 -0
  161. agent_log_server_rs/tests/test_codex_ext_runtime_protocol.py +109 -0
  162. agent_log_server_rs/tests/test_codex_ext_transport_resume.py +190 -0
  163. agent_log_server_rs/tests/test_extension_adapter_dispatch.py +170 -0
  164. agent_log_server_rs/tests/test_kb_and_codex_search.py +415 -0
  165. agent_log_server_rs/tests/test_mcp_socketio_serializer.py +53 -0
  166. agent_log_server_rs/tests/test_release_binary_wheel.py +119 -0
  167. als_deprecated/__init__.py +2 -0
  168. als_deprecated/__main__.py +5 -0
  169. als_deprecated/agent_log_subsystem.py +276 -0
  170. als_deprecated/agent_pty_http_shim_lifecycle.py +171 -0
  171. als_deprecated/appserver_routes.py +1930 -0
  172. als_deprecated/appserver_socketio.py +1223 -0
  173. als_deprecated/ask_user_interactions.py +415 -0
  174. als_deprecated/conversation_store.py +279 -0
  175. als_deprecated/conversation_todos.py +271 -0
  176. als_deprecated/conversations_rpc_contract.py +849 -0
  177. als_deprecated/extension_api.py +1041 -0
  178. als_deprecated/extension_cli.py +347 -0
  179. als_deprecated/host_routes.py +493 -0
  180. als_deprecated/index.py +30 -0
  181. als_deprecated/ipc_auth.py +36 -0
  182. als_deprecated/markdown_sections.py +141 -0
  183. als_deprecated/mcp_agent_pty_http_shim.py +30 -0
  184. als_deprecated/page_routes.py +71 -0
  185. als_deprecated/pending_context.py +671 -0
  186. als_deprecated/prompt_context.py +165 -0
  187. als_deprecated/repo_memory_delta.py +126 -0
  188. als_deprecated/rpc_stdio_mirror.py +134 -0
  189. als_deprecated/server.py +2004 -0
  190. als_deprecated/settings_ui_rpc_contract.py +311 -0
  191. als_deprecated/shellspec/agent_log.yaml +13 -0
  192. als_deprecated/shellspec/mcp_agent_pty.yaml +54 -0
  193. als_deprecated/socketio_config.py +53 -0
  194. als_deprecated/te2_assets/console_bridge.js +208 -0
  195. als_deprecated/te2_assets/framework_shells_README.md +448 -0
  196. als_deprecated/te2_assets/proxy_shell_wrapper_README.md +18 -0
  197. als_deprecated/te2_mcp_config.py +83 -0
  198. als_deprecated/te2_runtime.py +35 -0
  199. als_deprecated/te2_sync.py +78 -0
  200. als_deprecated/templates/template.html +46 -0
  201. als_deprecated/transcript_card_metadata.py +211 -0
  202. als_deprecated/typing_helpers.py +26 -0
  203. als_deprecated/web_pages.py +770 -0
  204. extensions/__init__.py +3107 -0
  205. extensions/codex_ext/__init__.py +1 -0
  206. extensions/codex_ext/client.py +1843 -0
  207. extensions/codex_ext/dependencies.py +143 -0
  208. extensions/codex_ext/devins_contract.py +25 -0
  209. extensions/codex_ext/manifest.json +138 -0
  210. extensions/codex_ext/mcp_contract.py +183 -0
  211. extensions/codex_ext/plan_utils.py +74 -0
  212. extensions/codex_ext/rollout_import.py +204 -0
  213. extensions/codex_ext/router.py +3772 -0
  214. extensions/codex_ext/runtime_protocol.py +1699 -0
  215. extensions/codex_ext/settings_schema.json +172 -0
  216. extensions/codex_ext/shellspec/app_server.yaml +19 -0
  217. extensions/codex_ext/transport.py +1412 -0
  218. extensions/codex_ext/ui/request_cards/codex_ext_request_card.js +882 -0
  219. extensions/copilot_sdk/VENDORED_SDK.md +17 -0
  220. extensions/copilot_sdk/__init__.py +2 -0
  221. extensions/copilot_sdk/_vendor/__init__.py +1 -0
  222. extensions/copilot_sdk/_vendor/copilot/__init__.py +80 -0
  223. extensions/copilot_sdk/_vendor/copilot/_diagnostics.py +29 -0
  224. extensions/copilot_sdk/_vendor/copilot/_jsonrpc.py +442 -0
  225. extensions/copilot_sdk/_vendor/copilot/_sdk_protocol_version.py +19 -0
  226. extensions/copilot_sdk/_vendor/copilot/_telemetry.py +48 -0
  227. extensions/copilot_sdk/_vendor/copilot/client.py +3157 -0
  228. extensions/copilot_sdk/_vendor/copilot/generated/__init__.py +0 -0
  229. extensions/copilot_sdk/_vendor/copilot/generated/rpc.py +7149 -0
  230. extensions/copilot_sdk/_vendor/copilot/generated/session_events.py +5009 -0
  231. extensions/copilot_sdk/_vendor/copilot/py.typed +1 -0
  232. extensions/copilot_sdk/_vendor/copilot/session.py +2415 -0
  233. extensions/copilot_sdk/_vendor/copilot/session_fs_provider.py +223 -0
  234. extensions/copilot_sdk/_vendor/copilot/tools.py +327 -0
  235. extensions/copilot_sdk/client.py +3871 -0
  236. extensions/copilot_sdk/dependencies.py +108 -0
  237. extensions/copilot_sdk/devins_contract.py +25 -0
  238. extensions/copilot_sdk/file_change_preview.py +80 -0
  239. extensions/copilot_sdk/fws_pipe_process.py +382 -0
  240. extensions/copilot_sdk/manifest.json +135 -0
  241. extensions/copilot_sdk/mcp_contract.py +63 -0
  242. extensions/copilot_sdk/plan_utils.py +56 -0
  243. extensions/copilot_sdk/protocol_adapter.py +342 -0
  244. extensions/copilot_sdk/protocol_registry.py +149 -0
  245. extensions/copilot_sdk/router.py +1789 -0
  246. extensions/copilot_sdk/schemas/api.schema.json +1063 -0
  247. extensions/copilot_sdk/schemas/session-events.schema.json +6369 -0
  248. extensions/copilot_sdk/settings_schema.json +165 -0
  249. extensions/copilot_sdk/shellspec/copilot_cli.yaml +20 -0
  250. extensions/copilot_sdk/te2_runtime.py +78 -0
  251. extensions/copilot_sdk/ui/request_cards/copilot_request_card.js +449 -0
  252. extensions/extensions.json +19 -0
  253. extensions/message_card_contracts.py +213 -0
  254. extensions/tool_card_contracts.py +102 -0
  255. mcp_agent_pty_http_shim.py +321 -0
  256. mcp_agent_pty_server.py +2931 -0
@@ -0,0 +1,706 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import fcntl
5
+ import hashlib
6
+ import importlib
7
+ import importlib.metadata
8
+ import json
9
+ import os
10
+ import platform
11
+ import re
12
+ import secrets
13
+ import shutil
14
+ import signal
15
+ import subprocess
16
+ import sys
17
+ import sysconfig
18
+ from collections.abc import Callable, Generator, MutableMapping
19
+ from contextlib import contextmanager
20
+ from dataclasses import dataclass
21
+ from pathlib import Path
22
+ from types import FrameType
23
+ from typing import Sequence, cast
24
+
25
+ APP_ID = "als-rs"
26
+ DEFAULT_HOST = "127.0.0.1"
27
+ DEFAULT_PORT = "12459"
28
+ SERVER_PACKAGE = "als-server"
29
+ PACKAGED_SERVER_MANIFEST_SCHEMA = 1
30
+ PACKAGED_SERVER_MANIFEST_NAME = "als-server.manifest.json"
31
+
32
+ _INCLUDE_LITERAL_PATTERN = re.compile(
33
+ rb'include_(?:str|bytes)!\(\s*"([^"\\]+)"\s*\)',
34
+ )
35
+
36
+ SignalHandler = int | signal.Handlers | Callable[[int, FrameType | None], object]
37
+
38
+
39
+ @dataclass(frozen=True)
40
+ class BootstrapArgs:
41
+ host: str
42
+ port: str
43
+ data_dir: str | None
44
+ cache_dir: str | None
45
+ config_dir: str | None
46
+ static_dir: str | None
47
+ server_bin: str | None
48
+ cargo_manifest: str | None
49
+ debug: bool
50
+ framework_shells_base_dir: str | None
51
+ framework_shells_secret: str | None
52
+ framework_shells_repo_fingerprint: str | None
53
+ framework_shells_secret_fingerprint: str | None
54
+ framework_shells_fws_socketio_server_pid: str | None
55
+ framework_shells_run_id: str | None
56
+
57
+
58
+ def main(argv: Sequence[str] | None = None) -> int:
59
+ argv = list(argv if argv is not None else sys.argv[1:])
60
+ if argv and argv[0] == "extension":
61
+ from agent_log_server_rs.extension_cli import run_extension_cli
62
+
63
+ return run_extension_cli(argv[1:])
64
+ args = _parse_args(argv)
65
+ env = _build_env(args)
66
+ command = _server_command(args, env)
67
+ return _run_child(command, env)
68
+
69
+
70
+ def _parse_args(argv: Sequence[str] | None) -> BootstrapArgs:
71
+ parser = argparse.ArgumentParser(
72
+ prog="als-rs",
73
+ usage=(
74
+ "als-rs [options]\n"
75
+ " als-rs extension {validate,install,update,remove,reload,list} ..."
76
+ ),
77
+ description=(
78
+ "Launch the ALS-RS Rust server with isolated runtime roots.\n\n"
79
+ "Subcommands:\n"
80
+ " extension Manage extension packages. Run `als-rs extension -h` for details."
81
+ ),
82
+ epilog=(
83
+ "Examples:\n"
84
+ " als-rs\n"
85
+ " als-rs --debug\n"
86
+ " als-rs --port 12459\n"
87
+ " als-rs extension list\n"
88
+ " als-rs extension install --path /path/to/extension --install-dependencies\n"
89
+ " als-rs extension validate --git https://example.invalid/repo.git --ref main"
90
+ ),
91
+ formatter_class=argparse.RawDescriptionHelpFormatter,
92
+ )
93
+ parser.add_argument("--host", default=os.environ.get("ALS_RS_HOST", DEFAULT_HOST))
94
+ parser.add_argument("--port", default=os.environ.get("ALS_RS_PORT", DEFAULT_PORT))
95
+ parser.add_argument("--data-dir", default=os.environ.get("ALS_RS_DATA_DIR"))
96
+ parser.add_argument("--cache-dir", default=os.environ.get("ALS_RS_CACHE_DIR"))
97
+ parser.add_argument("--config-dir", default=os.environ.get("ALS_RS_CONFIG_DIR"))
98
+ parser.add_argument("--static-dir", default=os.environ.get("ALS_RS_STATIC_DIR"))
99
+ parser.add_argument(
100
+ "--server-bin",
101
+ default=os.environ.get("ALS_RS_SERVER_BIN"),
102
+ help=(
103
+ "Path to an installed als-server binary. Defaults to the fingerprinted Cargo "
104
+ "release cache; use --debug for the debug profile."
105
+ ),
106
+ )
107
+ parser.add_argument(
108
+ "--cargo-manifest",
109
+ default=os.environ.get("ALS_RS_CARGO_MANIFEST"),
110
+ help="Path to rust/Cargo.toml for development launches.",
111
+ )
112
+ parser.add_argument(
113
+ "--debug",
114
+ action="store_true",
115
+ help="Build and run the Rust server with Cargo's debug profile (release is the default).",
116
+ )
117
+ parser.add_argument(
118
+ "--framework-shells-base-dir",
119
+ default=os.environ.get("FRAMEWORK_SHELLS_BASE_DIR"),
120
+ )
121
+ parser.add_argument(
122
+ "--framework-shells-secret",
123
+ default=os.environ.get("FRAMEWORK_SHELLS_SECRET"),
124
+ )
125
+ parser.add_argument(
126
+ "--framework-shells-repo-fingerprint",
127
+ default=os.environ.get("FRAMEWORK_SHELLS_REPO_FINGERPRINT"),
128
+ )
129
+ parser.add_argument(
130
+ "--framework-shells-secret-fingerprint",
131
+ default=os.environ.get("FRAMEWORK_SHELLS_SECRET_FINGERPRINT"),
132
+ )
133
+ parser.add_argument(
134
+ "--framework-shells-fws-socketio-server-pid",
135
+ default=os.environ.get("FRAMEWORK_SHELLS_FWS_SOCKETIO_SERVER_PID"),
136
+ )
137
+ parser.add_argument(
138
+ "--framework-shells-run-id",
139
+ default=os.environ.get("FRAMEWORK_SHELLS_RUN_ID"),
140
+ )
141
+ raw = parser.parse_args(argv)
142
+ return BootstrapArgs(
143
+ host=cast(str, raw.host),
144
+ port=cast(str, raw.port),
145
+ data_dir=cast(str | None, raw.data_dir),
146
+ cache_dir=cast(str | None, raw.cache_dir),
147
+ config_dir=cast(str | None, raw.config_dir),
148
+ static_dir=cast(str | None, raw.static_dir),
149
+ server_bin=cast(str | None, raw.server_bin),
150
+ cargo_manifest=cast(str | None, raw.cargo_manifest),
151
+ debug=cast(bool, raw.debug),
152
+ framework_shells_base_dir=cast(str | None, raw.framework_shells_base_dir),
153
+ framework_shells_secret=cast(str | None, raw.framework_shells_secret),
154
+ framework_shells_repo_fingerprint=cast(str | None, raw.framework_shells_repo_fingerprint),
155
+ framework_shells_secret_fingerprint=cast(str | None, raw.framework_shells_secret_fingerprint),
156
+ framework_shells_fws_socketio_server_pid=cast(
157
+ str | None,
158
+ raw.framework_shells_fws_socketio_server_pid,
159
+ ),
160
+ framework_shells_run_id=cast(str | None, raw.framework_shells_run_id),
161
+ )
162
+
163
+
164
+ def _build_env(args: BootstrapArgs) -> dict[str, str]:
165
+ env = os.environ.copy()
166
+ data_dir = Path(args.data_dir) if args.data_dir else _default_data_dir()
167
+ cache_dir = Path(args.cache_dir) if args.cache_dir else _default_cache_dir()
168
+ config_dir = Path(args.config_dir) if args.config_dir else data_dir
169
+ static_dir = Path(args.static_dir) if args.static_dir else _default_static_dir()
170
+
171
+ for root in (data_dir, cache_dir, config_dir):
172
+ root.mkdir(parents=True, exist_ok=True)
173
+
174
+ env["ALS_RS_HOST"] = str(args.host)
175
+ env["ALS_RS_PORT"] = str(args.port)
176
+ env["ALS_RS_DATA_DIR"] = str(data_dir)
177
+ env["ALS_RS_CACHE_DIR"] = str(cache_dir)
178
+ env["ALS_RS_CONFIG_DIR"] = str(config_dir)
179
+ env["ALS_RS_STATIC_DIR"] = str(static_dir)
180
+ env.setdefault("ALS_RS_EXTENSIONS_DIR", str(_default_extensions_dir()))
181
+ template_path = _default_developer_message_template_path()
182
+ if template_path.is_file():
183
+ env.setdefault("TE2_DEVELOPER_MESSAGE_TEMPLATE_PATH", str(template_path))
184
+ env["ALS_RS_PYTHON_BIN"] = sys.executable
185
+ _ensure_framework_shells_env(env, args, data_dir)
186
+ return env
187
+
188
+
189
+ def build_env(args: BootstrapArgs) -> dict[str, str]:
190
+ return _build_env(args)
191
+
192
+
193
+ def _server_command(args: BootstrapArgs, env: MutableMapping[str, str] | None = None) -> list[str]:
194
+ runtime_env = env if env is not None else os.environ
195
+ framework_shell_args = _framework_shell_args(args)
196
+ if args.server_bin:
197
+ return [str(Path(args.server_bin)), *framework_shell_args]
198
+
199
+ if not args.cargo_manifest:
200
+ packaged_binary = _packaged_server_binary()
201
+ if packaged_binary is not None:
202
+ if args.debug:
203
+ raise RuntimeError(
204
+ "--debug requires an ALS-RS source checkout; the installed binary-release "
205
+ "wheel contains only the verified release server"
206
+ )
207
+ return [str(packaged_binary), *framework_shell_args]
208
+
209
+ manifest = Path(args.cargo_manifest) if args.cargo_manifest else _default_rust_manifest()
210
+ target_dir = _bootstrap_cargo_target_dir(manifest, runtime_env)
211
+ cargo_profile = "debug" if args.debug else "release"
212
+ fingerprint = _rust_source_fingerprint(manifest, profile=cargo_profile)
213
+ cache_dir = Path(runtime_env.get("ALS_RS_CACHE_DIR") or args.cache_dir or _default_cache_dir())
214
+ binary_name = _server_binary_name()
215
+ bin_root = cache_dir / "bin"
216
+ cached_binary = bin_root / fingerprint / cargo_profile / binary_name
217
+
218
+ with _exclusive_build_cache_lock(cache_dir):
219
+ if _cached_binary_is_usable(cached_binary):
220
+ _prune_final_binary_cache(bin_root, cached_binary)
221
+ return [str(cached_binary), *framework_shell_args]
222
+
223
+ command = [
224
+ "cargo",
225
+ "build",
226
+ "--manifest-path",
227
+ str(manifest),
228
+ "-p",
229
+ SERVER_PACKAGE,
230
+ ]
231
+ if not args.debug:
232
+ command.append("--release")
233
+ build_env = dict(runtime_env)
234
+ build_env["CARGO_TARGET_DIR"] = str(target_dir)
235
+ result = subprocess.run(command, env=build_env, check=False)
236
+ if result.returncode != 0:
237
+ raise SystemExit(result.returncode)
238
+
239
+ built_binary = target_dir / cargo_profile / binary_name
240
+ if not _cached_binary_is_usable(built_binary):
241
+ raise SystemExit(
242
+ f"Rust server build finished but binary is missing or unusable: {built_binary}"
243
+ )
244
+ _publish_cached_binary(built_binary, cached_binary)
245
+ _prune_final_binary_cache(bin_root, cached_binary)
246
+
247
+ return [str(cached_binary), *framework_shell_args]
248
+
249
+
250
+ def _packaged_server_binary() -> Path | None:
251
+ binary_dir = _package_root() / "bin"
252
+ manifest_path = binary_dir / PACKAGED_SERVER_MANIFEST_NAME
253
+ binary_path = binary_dir / _server_binary_name()
254
+ if not manifest_path.is_file():
255
+ if binary_path.exists():
256
+ raise RuntimeError(
257
+ f"ALS-RS binary-release payload is incomplete: missing {manifest_path}"
258
+ )
259
+ return None
260
+
261
+ try:
262
+ loaded = cast(object, json.loads(manifest_path.read_text(encoding="utf-8")))
263
+ except (OSError, json.JSONDecodeError) as exc:
264
+ raise RuntimeError(
265
+ f"ALS-RS binary-release manifest is unreadable: {manifest_path}: {exc}"
266
+ ) from exc
267
+ if not isinstance(loaded, dict):
268
+ raise RuntimeError(f"ALS-RS binary-release manifest must be an object: {manifest_path}")
269
+ raw = cast(dict[str, object], loaded)
270
+
271
+ schema = raw.get("schema")
272
+ package_version = raw.get("package_version")
273
+ binary_name = raw.get("binary")
274
+ target = raw.get("target")
275
+ platform_tag = raw.get("platform_tag")
276
+ source_commit = raw.get("source_commit")
277
+ source_dirty = raw.get("source_dirty")
278
+ expected_digest = raw.get("sha256")
279
+ if schema != PACKAGED_SERVER_MANIFEST_SCHEMA:
280
+ raise RuntimeError(f"Unsupported ALS-RS binary-release manifest schema: {schema!r}")
281
+ if not isinstance(package_version, str) or not package_version:
282
+ raise RuntimeError("ALS-RS binary-release manifest has no package_version")
283
+ if binary_name != _server_binary_name():
284
+ raise RuntimeError(f"ALS-RS binary-release manifest has invalid binary: {binary_name!r}")
285
+ if not isinstance(target, str) or not target:
286
+ raise RuntimeError("ALS-RS binary-release manifest has no target")
287
+ if not isinstance(platform_tag, str) or not platform_tag:
288
+ raise RuntimeError("ALS-RS binary-release manifest has no platform_tag")
289
+ if not isinstance(source_commit, str) or not re.fullmatch(r"[0-9a-f]{7,64}", source_commit):
290
+ raise RuntimeError("ALS-RS binary-release manifest has invalid source_commit")
291
+ if not isinstance(source_dirty, bool):
292
+ raise RuntimeError("ALS-RS binary-release manifest has invalid source_dirty")
293
+ if not isinstance(expected_digest, str) or not re.fullmatch(r"[0-9a-f]{64}", expected_digest):
294
+ raise RuntimeError("ALS-RS binary-release manifest has invalid sha256")
295
+
296
+ installed_version = _installed_package_version()
297
+ if installed_version is not None and package_version != installed_version:
298
+ raise RuntimeError(
299
+ "ALS-RS binary-release package version mismatch: "
300
+ f"manifest={package_version}, installed={installed_version}"
301
+ )
302
+ _validate_packaged_target(target, platform_tag)
303
+ if not _cached_binary_is_usable(binary_path):
304
+ raise RuntimeError(f"ALS-RS packaged server is missing or unusable: {binary_path}")
305
+ actual_digest = _sha256_file(binary_path)
306
+ if actual_digest != expected_digest:
307
+ raise RuntimeError(
308
+ "ALS-RS packaged server digest mismatch: "
309
+ f"expected={expected_digest}, actual={actual_digest}"
310
+ )
311
+ return binary_path
312
+
313
+
314
+ def _installed_package_version() -> str | None:
315
+ try:
316
+ return importlib.metadata.version("agent-log-server")
317
+ except importlib.metadata.PackageNotFoundError:
318
+ return None
319
+
320
+
321
+ def _validate_packaged_target(target: str, platform_tag: str) -> None:
322
+ machine = platform.machine().strip().lower().replace("amd64", "x86_64")
323
+ machine = machine.replace("arm64", "aarch64")
324
+ sys_platform = sys.platform.lower()
325
+ is_android = sys_platform == "android" or bool(os.environ.get("ANDROID_ROOT"))
326
+ if not is_android:
327
+ sysconfig_platform = sysconfig.get_platform().lower()
328
+ multiarch = str(sysconfig.get_config_var("MULTIARCH") or "").lower()
329
+ is_android = "android" in sysconfig_platform or "android" in multiarch
330
+ is_linux_kernel = sys_platform.startswith("linux") or sys_platform == "android"
331
+
332
+ if target == "x86_64-unknown-linux-gnu":
333
+ compatible = is_linux_kernel and machine == "x86_64" and not is_android
334
+ elif target == "aarch64-linux-android":
335
+ compatible = is_linux_kernel and machine == "aarch64" and is_android
336
+ else:
337
+ raise RuntimeError(f"Unsupported ALS-RS packaged server target: {target}")
338
+ if not compatible:
339
+ raise RuntimeError(
340
+ "ALS-RS packaged server is incompatible with this runtime: "
341
+ f"target={target}, platform_tag={platform_tag}, "
342
+ f"runtime={sys_platform}/{machine}, android={is_android}"
343
+ )
344
+
345
+
346
+ def _sha256_file(path: Path) -> str:
347
+ hasher = hashlib.sha256()
348
+ with path.open("rb") as file_handle:
349
+ for chunk in iter(lambda: file_handle.read(1024 * 1024), b""):
350
+ hasher.update(chunk)
351
+ return hasher.hexdigest()
352
+
353
+
354
+ @contextmanager
355
+ def _exclusive_build_cache_lock(cache_dir: Path) -> Generator[None, None, None]:
356
+ cache_dir.mkdir(parents=True, exist_ok=True)
357
+ lock_path = cache_dir / ".build.lock"
358
+ with lock_path.open("a+b") as lock_file:
359
+ fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX)
360
+ try:
361
+ yield
362
+ finally:
363
+ fcntl.flock(lock_file.fileno(), fcntl.LOCK_UN)
364
+
365
+
366
+ def _cached_binary_is_usable(path: Path) -> bool:
367
+ try:
368
+ return path.is_file() and path.stat().st_size > 0 and os.access(path, os.X_OK)
369
+ except OSError:
370
+ return False
371
+
372
+
373
+ def _publish_cached_binary(source: Path, destination: Path) -> None:
374
+ destination.parent.mkdir(parents=True, exist_ok=True)
375
+ temporary = destination.with_name(f".{destination.name}.tmp-{os.getpid()}")
376
+ try:
377
+ shutil.copy2(source, temporary)
378
+ temporary.chmod(temporary.stat().st_mode | 0o755)
379
+ with temporary.open("rb") as file_handle:
380
+ os.fsync(file_handle.fileno())
381
+ if not _cached_binary_is_usable(temporary):
382
+ raise RuntimeError(f"published Rust server binary is unusable: {temporary}")
383
+ os.replace(temporary, destination)
384
+ _fsync_directory(destination.parent)
385
+ finally:
386
+ temporary.unlink(missing_ok=True)
387
+
388
+
389
+ def _prune_final_binary_cache(bin_root: Path, selected_binary: Path) -> None:
390
+ if not _cached_binary_is_usable(selected_binary):
391
+ raise RuntimeError(
392
+ f"refusing to prune before the selected binary validates: {selected_binary}"
393
+ )
394
+
395
+ selected_profile_dir = selected_binary.parent
396
+ selected_fingerprint_dir = selected_profile_dir.parent
397
+ if selected_fingerprint_dir.parent != bin_root:
398
+ raise RuntimeError(
399
+ f"selected binary is outside the final binary cache: {selected_binary}"
400
+ )
401
+
402
+ for fingerprint_entry in tuple(bin_root.iterdir()):
403
+ if fingerprint_entry != selected_fingerprint_dir:
404
+ _remove_cache_entry(fingerprint_entry)
405
+ for profile_entry in tuple(selected_fingerprint_dir.iterdir()):
406
+ if profile_entry != selected_profile_dir:
407
+ _remove_cache_entry(profile_entry)
408
+ for binary_entry in tuple(selected_profile_dir.iterdir()):
409
+ if binary_entry != selected_binary:
410
+ _remove_cache_entry(binary_entry)
411
+ _fsync_directory(bin_root)
412
+
413
+
414
+ def _remove_cache_entry(path: Path) -> None:
415
+ if path.is_symlink() or path.is_file():
416
+ path.unlink(missing_ok=True)
417
+ elif path.exists():
418
+ shutil.rmtree(path)
419
+
420
+
421
+ def _fsync_directory(path: Path) -> None:
422
+ descriptor = os.open(path, os.O_RDONLY | getattr(os, "O_DIRECTORY", 0))
423
+ try:
424
+ os.fsync(descriptor)
425
+ finally:
426
+ os.close(descriptor)
427
+
428
+
429
+ def _server_binary_name() -> str:
430
+ suffix = ".exe" if sys.platform == "win32" else ""
431
+ return f"{SERVER_PACKAGE}{suffix}"
432
+
433
+
434
+ def _rust_source_fingerprint(manifest: Path, *, profile: str) -> str:
435
+ workspace = manifest.parent
436
+ hasher = hashlib.sha256()
437
+ hasher.update(b"als-rs-server-build-cache-v1\0")
438
+ hasher.update(str(workspace).encode("utf-8", "surrogateescape"))
439
+ hasher.update(b"\0")
440
+ hasher.update(profile.encode("utf-8"))
441
+ hasher.update(b"\0")
442
+ hasher.update(sys.platform.encode("utf-8"))
443
+ hasher.update(b"\0")
444
+ uname_result = os.uname() if hasattr(os, "uname") else None
445
+ hasher.update(uname_result.machine.encode("utf-8") if uname_result is not None else b"")
446
+ for path in _rust_fingerprint_paths(workspace):
447
+ relative = path.relative_to(workspace).as_posix()
448
+ hasher.update(b"\0path:")
449
+ hasher.update(relative.encode("utf-8", "surrogateescape"))
450
+ hasher.update(b"\0")
451
+ hasher.update(path.read_bytes())
452
+ return hasher.hexdigest()[:24]
453
+
454
+
455
+ def _rust_fingerprint_paths(workspace: Path) -> list[Path]:
456
+ candidates: set[Path] = set()
457
+ for relative in ("Cargo.toml", "Cargo.lock"):
458
+ path = workspace / relative
459
+ if path.is_file():
460
+ candidates.add(path)
461
+
462
+ crates_root = workspace / "crates"
463
+ if not crates_root.is_dir():
464
+ return sorted(candidates)
465
+
466
+ rust_sources: list[Path] = []
467
+ for path in crates_root.rglob("*"):
468
+ if not path.is_file():
469
+ continue
470
+ if path.name in {"Cargo.toml", "build.rs"} or path.suffix == ".rs":
471
+ candidates.add(path)
472
+ if path.suffix == ".rs":
473
+ rust_sources.append(path)
474
+
475
+ for source in rust_sources:
476
+ source_bytes = source.read_bytes()
477
+ for match in _INCLUDE_LITERAL_PATTERN.finditer(source_bytes):
478
+ included = source.parent / os.fsdecode(match.group(1))
479
+ if included.is_file():
480
+ candidates.add(included)
481
+ return sorted(candidates)
482
+
483
+
484
+ def _bootstrap_cargo_target_dir(manifest: Path, runtime_env: MutableMapping[str, str]) -> Path:
485
+ configured_target_dir = runtime_env.get("CARGO_TARGET_DIR")
486
+ if configured_target_dir:
487
+ return Path(configured_target_dir)
488
+
489
+ cache_dir = Path(runtime_env.get("ALS_RS_CACHE_DIR") or _default_cache_dir())
490
+ runtime_env.setdefault("ALS_RS_CACHE_DIR", str(cache_dir))
491
+ manifest_key = hashlib.sha256(str(manifest.parent).encode("utf-8")).hexdigest()[:16]
492
+ target_dir = cache_dir / "cargo-target" / manifest_key
493
+ runtime_env["CARGO_TARGET_DIR"] = str(target_dir)
494
+ return target_dir
495
+
496
+
497
+ def _framework_shell_args(args: BootstrapArgs) -> list[str]:
498
+ values = [
499
+ ("--framework-shells-base-dir", args.framework_shells_base_dir),
500
+ ("--framework-shells-secret", args.framework_shells_secret),
501
+ ("--framework-shells-repo-fingerprint", args.framework_shells_repo_fingerprint),
502
+ (
503
+ "--framework-shells-secret-fingerprint",
504
+ args.framework_shells_secret_fingerprint or args.framework_shells_repo_fingerprint,
505
+ ),
506
+ (
507
+ "--framework-shells-fws-socketio-server-pid",
508
+ args.framework_shells_fws_socketio_server_pid,
509
+ ),
510
+ ("--framework-shells-run-id", args.framework_shells_run_id),
511
+ ]
512
+ rendered: list[str] = []
513
+ for flag, value in values:
514
+ if value:
515
+ rendered.extend((flag, value))
516
+ return rendered
517
+
518
+
519
+ def _set_if_present(env: dict[str, str], key: str, value: str | None) -> None:
520
+ if value:
521
+ env[key] = value
522
+
523
+
524
+ def _ensure_framework_shells_env(
525
+ env: dict[str, str],
526
+ args: BootstrapArgs,
527
+ data_dir: Path,
528
+ ) -> None:
529
+ _set_if_present(env, "FRAMEWORK_SHELLS_BASE_DIR", args.framework_shells_base_dir)
530
+ _set_if_present(env, "FRAMEWORK_SHELLS_SECRET", args.framework_shells_secret)
531
+ _set_if_present(
532
+ env,
533
+ "FRAMEWORK_SHELLS_REPO_FINGERPRINT",
534
+ args.framework_shells_repo_fingerprint,
535
+ )
536
+ _set_if_present(
537
+ env,
538
+ "FRAMEWORK_SHELLS_SECRET_FINGERPRINT",
539
+ args.framework_shells_secret_fingerprint or args.framework_shells_repo_fingerprint,
540
+ )
541
+ _set_if_present(
542
+ env,
543
+ "FRAMEWORK_SHELLS_FWS_SOCKETIO_SERVER_PID",
544
+ args.framework_shells_fws_socketio_server_pid,
545
+ )
546
+ _set_if_present(env, "FRAMEWORK_SHELLS_RUN_ID", args.framework_shells_run_id)
547
+ env.setdefault("FRAMEWORK_SHELLS_RUN_ID", "app-server")
548
+ env.setdefault("FRAMEWORK_SHELLS_SIGWINCH_ON_RESIZE", "1")
549
+
550
+ if env.get("FRAMEWORK_SHELLS_SECRET"):
551
+ _prime_framework_shells_import(env)
552
+ return
553
+
554
+ fingerprint = env.get("FRAMEWORK_SHELLS_REPO_FINGERPRINT")
555
+ if not fingerprint:
556
+ fingerprint = _framework_shells_fingerprint(data_dir)
557
+ env["FRAMEWORK_SHELLS_REPO_FINGERPRINT"] = fingerprint
558
+ env.setdefault("FRAMEWORK_SHELLS_SECRET_FINGERPRINT", fingerprint)
559
+
560
+ base_dir = Path(
561
+ env.get("FRAMEWORK_SHELLS_BASE_DIR") or _default_framework_shells_base_dir()
562
+ )
563
+ secret_dir = base_dir / "runtimes" / fingerprint
564
+ secret_file = secret_dir / "secret"
565
+ if secret_file.is_file():
566
+ secret = secret_file.read_text(encoding="utf-8").strip()
567
+ else:
568
+ secret_dir.mkdir(parents=True, exist_ok=True)
569
+ secret = secrets.token_hex(32)
570
+ secret_file.write_text(secret, encoding="utf-8")
571
+ try:
572
+ os.chmod(secret_file, 0o600)
573
+ except OSError:
574
+ pass
575
+
576
+ env["FRAMEWORK_SHELLS_BASE_DIR"] = str(base_dir)
577
+ env["FRAMEWORK_SHELLS_SECRET"] = secret
578
+ _prime_framework_shells_import(env)
579
+
580
+
581
+ def _framework_shells_fingerprint(data_dir: Path) -> str:
582
+ root = _cwd_for_fingerprint() or data_dir
583
+ return hashlib.sha256(str(root).encode("utf-8")).hexdigest()[:16]
584
+
585
+
586
+ def _cwd_for_fingerprint() -> Path | None:
587
+ pwd = os.environ.get("PWD")
588
+ if pwd:
589
+ path = Path(pwd)
590
+ if path.is_dir():
591
+ return path
592
+ try:
593
+ return Path.cwd()
594
+ except OSError:
595
+ return None
596
+
597
+
598
+ def _default_framework_shells_base_dir() -> Path:
599
+ return Path(os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache"))) / "framework_shells"
600
+
601
+
602
+ def _prime_framework_shells_import(env: dict[str, str]) -> None:
603
+ try:
604
+ framework_shells = importlib.import_module("framework_shells")
605
+ except ImportError:
606
+ return
607
+ get_secret = getattr(framework_shells, "get_secret", None)
608
+ if not callable(get_secret):
609
+ return
610
+
611
+ framework_env = {
612
+ key: value for key, value in env.items() if key.startswith("FRAMEWORK_SHELLS_")
613
+ }
614
+ previous = {key: os.environ.get(key) for key in framework_env}
615
+ try:
616
+ os.environ.update(framework_env)
617
+ get_secret()
618
+ finally:
619
+ for key, old_value in previous.items():
620
+ if old_value is None:
621
+ os.environ.pop(key, None)
622
+ else:
623
+ os.environ[key] = old_value
624
+
625
+
626
+ def _run_child(command: Sequence[str], env: dict[str, str]) -> int:
627
+ child = subprocess.Popen(command, env=env)
628
+ previous_handlers: dict[signal.Signals, SignalHandler] = {}
629
+
630
+ def forward_signal(signum: int, _frame: FrameType | None) -> object:
631
+ if child.poll() is None:
632
+ child.send_signal(signum)
633
+
634
+ for signum in (signal.SIGINT, signal.SIGTERM):
635
+ previous_handlers[signum] = cast(SignalHandler, signal.getsignal(signum))
636
+ signal.signal(signum, forward_signal)
637
+
638
+ try:
639
+ return child.wait()
640
+ finally:
641
+ for signum, handler in previous_handlers.items():
642
+ signal.signal(signum, handler)
643
+
644
+
645
+ def _default_data_dir() -> Path:
646
+ return Path(os.environ.get("XDG_DATA_HOME", str(Path.home() / ".local" / "share"))) / APP_ID
647
+
648
+
649
+ def _default_cache_dir() -> Path:
650
+ return Path(os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache"))) / APP_ID
651
+
652
+
653
+ def _default_extensions_dir() -> Path:
654
+ extensions_dir = _source_root() / "extensions"
655
+ if (extensions_dir / "extensions.json").is_file():
656
+ return extensions_dir
657
+ return extensions_dir
658
+
659
+
660
+ def _default_static_dir() -> Path:
661
+ source_static = _source_root() / "rust" / "crates" / "als-server" / "src" / "static"
662
+ if source_static.is_dir():
663
+ return source_static
664
+ packaged_static = _package_root() / "rust" / "crates" / "als-server" / "src" / "static"
665
+ return packaged_static
666
+
667
+
668
+ def _default_developer_message_template_path() -> Path:
669
+ packaged_template = _package_root() / "DEVELOPER_MESSAGE_TEMPLATE.md"
670
+ if packaged_template.is_file():
671
+ return packaged_template
672
+ source_template = _source_root() / "DEVELOPER_MESSAGE_TEMPLATE.md"
673
+ if source_template.is_file():
674
+ return source_template
675
+ return packaged_template
676
+
677
+
678
+ def _source_root() -> Path:
679
+ return Path(__file__).parent.parent
680
+
681
+
682
+ def source_root() -> Path:
683
+ return _source_root()
684
+
685
+
686
+ def _package_root() -> Path:
687
+ return Path(__file__).parent
688
+
689
+
690
+ def _packaged_rust_manifest() -> Path | None:
691
+ manifest = _package_root() / "rust" / "Cargo.toml"
692
+ return manifest if manifest.is_file() else None
693
+
694
+
695
+ def _default_rust_manifest() -> Path:
696
+ source_manifest = _source_root() / "rust" / "Cargo.toml"
697
+ if source_manifest.is_file():
698
+ return source_manifest
699
+ packaged_manifest = _packaged_rust_manifest()
700
+ if packaged_manifest is not None:
701
+ return packaged_manifest
702
+ return source_manifest
703
+
704
+
705
+ if __name__ == "__main__":
706
+ sys.exit(main())