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.
- agent_log_server-0.2.122.dist-info/METADATA +186 -0
- agent_log_server-0.2.122.dist-info/RECORD +256 -0
- agent_log_server-0.2.122.dist-info/WHEEL +5 -0
- agent_log_server-0.2.122.dist-info/entry_points.txt +4 -0
- agent_log_server-0.2.122.dist-info/licenses/LICENSE +649 -0
- agent_log_server-0.2.122.dist-info/top_level.txt +6 -0
- agent_log_server_rs/DEVELOPER_MESSAGE_TEMPLATE.md +517 -0
- agent_log_server_rs/__init__.py +1 -0
- agent_log_server_rs/adapter_protocol.py +548 -0
- agent_log_server_rs/adapters/__init__.py +1 -0
- agent_log_server_rs/adapters/embedded_adapter.py +157 -0
- agent_log_server_rs/adapters/extension_adapter.py +1925 -0
- agent_log_server_rs/adapters/rpc_common.py +137 -0
- agent_log_server_rs/bin/als-server +0 -0
- agent_log_server_rs/bin/als-server.manifest.json +10 -0
- agent_log_server_rs/bootstrap.py +706 -0
- agent_log_server_rs/codec.py +85 -0
- agent_log_server_rs/extension_cli.py +520 -0
- agent_log_server_rs/rust/crates/als-server/src/static/app.js +151 -0
- agent_log_server_rs/rust/crates/als-server/src/static/appserver.css +240 -0
- agent_log_server_rs/rust/crates/als-server/src/static/appserver.js +208 -0
- agent_log_server_rs/rust/crates/als-server/src/static/codex_agent.css +4024 -0
- agent_log_server_rs/rust/crates/als-server/src/static/codex_agent.ts +2610 -0
- agent_log_server_rs/rust/crates/als-server/src/static/codexas-icon.svg +5 -0
- agent_log_server_rs/rust/crates/als-server/src/static/dist/codex_agent.js +26 -0
- agent_log_server_rs/rust/crates/als-server/src/static/dist/codex_agent.js.map +7 -0
- agent_log_server_rs/rust/crates/als-server/src/static/images/green-right-arrow.png +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/approvals/ui.ts +949 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/assistant_stream.ts +165 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/boot/init_flow.ts +341 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/boot/input_flow.ts +592 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/client_identity.ts +10 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/composer/runtime.ts +1065 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation/runtime.ts +345 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer/actions.ts +523 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer/index.ts +100 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer/list.ts +966 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_drawer.ts +1 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/conversation_modal.ts +147 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/diff/rendering.ts +857 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/events/router.ts +779 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/events/socket.ts +140 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/host/runtime.ts +357 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/layout/viewport.ts +95 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/layout/widescreen.ts +168 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/markdown.ts +576 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/orchestrator/rpc_flow.ts +73 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/orchestrator/session_flow.ts +191 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/path_label.ts +76 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/plan/runtime.ts +446 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/plan_modal.ts +102 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/plan_overlay.ts +235 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/project_modal.ts +1398 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/render/utils.ts +456 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/request_cards/runtime.ts +236 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/conversations/client.ts +1021 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/conversations/contract.ts +406 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/namespaces.ts +18 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/registry.ts +113 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/settings/client.ts +662 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/settings/contract.ts +49 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/transport.ts +463 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/ui/client.ts +588 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/rpc/ui/contract.ts +50 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/runtime_footer.ts +373 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/settings/runtime_helpers.ts +20 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/settings/save_flow.ts +332 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/settings/ui_flow.ts +1148 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/shared_types.ts +61 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/shell_render.ts +377 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/shell_semantic.ts +606 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/subagents/collapsible.ts +224 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/terminal_ansi.ts +134 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/live_items.ts +594 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/replay.ts +820 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/rows.ts +290 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline/virtualizer.ts +1123 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/timeline_sticky_headers.ts +492 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/tool_render.ts +789 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_card_metadata.ts +228 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_cards.ts +780 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_config.ts +10 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_loader.ts +511 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_metrics.ts +28 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_stream.ts +561 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/transcript_stream_url.ts +7 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/vendor_modules.d.ts +5 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/codex_agent/vendor_runtime.ts +106 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/console_bridge.js +229 -0
- agent_log_server_rs/rust/crates/als-server/src/static/js/socketio_runtime.js +27 -0
- agent_log_server_rs/rust/crates/als-server/src/static/modals/rollout_picker.ts +46 -0
- agent_log_server_rs/rust/crates/als-server/src/static/modals/settings_modal.ts +63 -0
- agent_log_server_rs/rust/crates/als-server/src/static/modals/settings_schema.ts +3666 -0
- agent_log_server_rs/rust/crates/als-server/src/static/modals/warning_modal.ts +65 -0
- agent_log_server_rs/rust/crates/als-server/src/static/style.css +194 -0
- agent_log_server_rs/rust/crates/als-server/src/static/ui/extension_settings.ts +493 -0
- agent_log_server_rs/rust/crates/als-server/src/static/ui/splash_settings.ts +41 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-400-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-400-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-500-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-500-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-600-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-600-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-700-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-700-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-400-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-400-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-500-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-500-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-600-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-600-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-700-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext-700-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-400-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-400-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-500-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-500-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-600-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-600-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-700-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-greek-700-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-400-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-500-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-600-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-700-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-700-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-latin-ext-700-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-400-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-400-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-500-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-500-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-600-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-600-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-700-italic.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono/jetbrains-mono-vietnamese-700-normal.woff2 +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/fonts/jetbrains-mono.css +481 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/socket.io/socket.io.min.js +7 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/socket.io-msgpack-parser/socket.io-msgpack-parser.js +2 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/socket.io-msgpack-parser/socket.io-msgpack-parser.js.map +7 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/tree-sitter-bash/highlights.scm +56 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/tree-sitter-bash/tree-sitter-bash.wasm +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/tree-sitter.js +3278 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/tree-sitter.wasm +0 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/web-tree-sitter.js +4007 -0
- agent_log_server_rs/rust/crates/als-server/src/static/vendor/web-tree-sitter/web-tree-sitter.wasm +0 -0
- agent_log_server_rs/shellspec/extension_adapter.yaml +15 -0
- agent_log_server_rs/tests/test_bootstrap.py +435 -0
- agent_log_server_rs/tests/test_codec.py +97 -0
- agent_log_server_rs/tests/test_codex_ext_client_resume.py +37 -0
- agent_log_server_rs/tests/test_codex_ext_router_atomic_diff.py +221 -0
- agent_log_server_rs/tests/test_codex_ext_runtime_protocol.py +109 -0
- agent_log_server_rs/tests/test_codex_ext_transport_resume.py +190 -0
- agent_log_server_rs/tests/test_extension_adapter_dispatch.py +170 -0
- agent_log_server_rs/tests/test_kb_and_codex_search.py +415 -0
- agent_log_server_rs/tests/test_mcp_socketio_serializer.py +53 -0
- agent_log_server_rs/tests/test_release_binary_wheel.py +119 -0
- als_deprecated/__init__.py +2 -0
- als_deprecated/__main__.py +5 -0
- als_deprecated/agent_log_subsystem.py +276 -0
- als_deprecated/agent_pty_http_shim_lifecycle.py +171 -0
- als_deprecated/appserver_routes.py +1930 -0
- als_deprecated/appserver_socketio.py +1223 -0
- als_deprecated/ask_user_interactions.py +415 -0
- als_deprecated/conversation_store.py +279 -0
- als_deprecated/conversation_todos.py +271 -0
- als_deprecated/conversations_rpc_contract.py +849 -0
- als_deprecated/extension_api.py +1041 -0
- als_deprecated/extension_cli.py +347 -0
- als_deprecated/host_routes.py +493 -0
- als_deprecated/index.py +30 -0
- als_deprecated/ipc_auth.py +36 -0
- als_deprecated/markdown_sections.py +141 -0
- als_deprecated/mcp_agent_pty_http_shim.py +30 -0
- als_deprecated/page_routes.py +71 -0
- als_deprecated/pending_context.py +671 -0
- als_deprecated/prompt_context.py +165 -0
- als_deprecated/repo_memory_delta.py +126 -0
- als_deprecated/rpc_stdio_mirror.py +134 -0
- als_deprecated/server.py +2004 -0
- als_deprecated/settings_ui_rpc_contract.py +311 -0
- als_deprecated/shellspec/agent_log.yaml +13 -0
- als_deprecated/shellspec/mcp_agent_pty.yaml +54 -0
- als_deprecated/socketio_config.py +53 -0
- als_deprecated/te2_assets/console_bridge.js +208 -0
- als_deprecated/te2_assets/framework_shells_README.md +448 -0
- als_deprecated/te2_assets/proxy_shell_wrapper_README.md +18 -0
- als_deprecated/te2_mcp_config.py +83 -0
- als_deprecated/te2_runtime.py +35 -0
- als_deprecated/te2_sync.py +78 -0
- als_deprecated/templates/template.html +46 -0
- als_deprecated/transcript_card_metadata.py +211 -0
- als_deprecated/typing_helpers.py +26 -0
- als_deprecated/web_pages.py +770 -0
- extensions/__init__.py +3107 -0
- extensions/codex_ext/__init__.py +1 -0
- extensions/codex_ext/client.py +1843 -0
- extensions/codex_ext/dependencies.py +143 -0
- extensions/codex_ext/devins_contract.py +25 -0
- extensions/codex_ext/manifest.json +138 -0
- extensions/codex_ext/mcp_contract.py +183 -0
- extensions/codex_ext/plan_utils.py +74 -0
- extensions/codex_ext/rollout_import.py +204 -0
- extensions/codex_ext/router.py +3772 -0
- extensions/codex_ext/runtime_protocol.py +1699 -0
- extensions/codex_ext/settings_schema.json +172 -0
- extensions/codex_ext/shellspec/app_server.yaml +19 -0
- extensions/codex_ext/transport.py +1412 -0
- extensions/codex_ext/ui/request_cards/codex_ext_request_card.js +882 -0
- extensions/copilot_sdk/VENDORED_SDK.md +17 -0
- extensions/copilot_sdk/__init__.py +2 -0
- extensions/copilot_sdk/_vendor/__init__.py +1 -0
- extensions/copilot_sdk/_vendor/copilot/__init__.py +80 -0
- extensions/copilot_sdk/_vendor/copilot/_diagnostics.py +29 -0
- extensions/copilot_sdk/_vendor/copilot/_jsonrpc.py +442 -0
- extensions/copilot_sdk/_vendor/copilot/_sdk_protocol_version.py +19 -0
- extensions/copilot_sdk/_vendor/copilot/_telemetry.py +48 -0
- extensions/copilot_sdk/_vendor/copilot/client.py +3157 -0
- extensions/copilot_sdk/_vendor/copilot/generated/__init__.py +0 -0
- extensions/copilot_sdk/_vendor/copilot/generated/rpc.py +7149 -0
- extensions/copilot_sdk/_vendor/copilot/generated/session_events.py +5009 -0
- extensions/copilot_sdk/_vendor/copilot/py.typed +1 -0
- extensions/copilot_sdk/_vendor/copilot/session.py +2415 -0
- extensions/copilot_sdk/_vendor/copilot/session_fs_provider.py +223 -0
- extensions/copilot_sdk/_vendor/copilot/tools.py +327 -0
- extensions/copilot_sdk/client.py +3871 -0
- extensions/copilot_sdk/dependencies.py +108 -0
- extensions/copilot_sdk/devins_contract.py +25 -0
- extensions/copilot_sdk/file_change_preview.py +80 -0
- extensions/copilot_sdk/fws_pipe_process.py +382 -0
- extensions/copilot_sdk/manifest.json +135 -0
- extensions/copilot_sdk/mcp_contract.py +63 -0
- extensions/copilot_sdk/plan_utils.py +56 -0
- extensions/copilot_sdk/protocol_adapter.py +342 -0
- extensions/copilot_sdk/protocol_registry.py +149 -0
- extensions/copilot_sdk/router.py +1789 -0
- extensions/copilot_sdk/schemas/api.schema.json +1063 -0
- extensions/copilot_sdk/schemas/session-events.schema.json +6369 -0
- extensions/copilot_sdk/settings_schema.json +165 -0
- extensions/copilot_sdk/shellspec/copilot_cli.yaml +20 -0
- extensions/copilot_sdk/te2_runtime.py +78 -0
- extensions/copilot_sdk/ui/request_cards/copilot_request_card.js +449 -0
- extensions/extensions.json +19 -0
- extensions/message_card_contracts.py +213 -0
- extensions/tool_card_contracts.py +102 -0
- mcp_agent_pty_http_shim.py +321 -0
- mcp_agent_pty_server.py +2931 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import type { HighlightJsLike, UnknownRecord } from '../shared_types.ts';
|
|
2
|
+
|
|
3
|
+
declare const hljs: HighlightJsLike | undefined;
|
|
4
|
+
|
|
5
|
+
export type StructuredViewLine = {
|
|
6
|
+
line_no: number;
|
|
7
|
+
content: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
interface RenderUtilsState {
|
|
11
|
+
conversationSettings?: { cwd?: string };
|
|
12
|
+
conversationMeta?: { cwd?: string };
|
|
13
|
+
viewWrapEnabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface RenderUtilsContext {
|
|
17
|
+
getState(): RenderUtilsState;
|
|
18
|
+
documentRef: Document;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const FILE_EXT_LANG_MAP: Record<string, string> = {
|
|
22
|
+
js: 'javascript', mjs: 'javascript', ts: 'typescript', tsx: 'typescript', jsx: 'javascript',
|
|
23
|
+
py: 'python', rb: 'ruby', rs: 'rust', go: 'go',
|
|
24
|
+
java: 'java', kt: 'kotlin', scala: 'scala',
|
|
25
|
+
c: 'c', h: 'c', cpp: 'cpp', cc: 'cpp', hpp: 'cpp',
|
|
26
|
+
cs: 'csharp', fs: 'fsharp',
|
|
27
|
+
php: 'php', swift: 'swift', r: 'r',
|
|
28
|
+
json: 'json', yaml: 'yaml', yml: 'yaml', toml: 'toml',
|
|
29
|
+
xml: 'xml', html: 'html', htm: 'html', css: 'css', scss: 'scss',
|
|
30
|
+
md: 'markdown', markdown: 'markdown',
|
|
31
|
+
sh: 'bash', bash: 'bash', zsh: 'bash', fish: 'bash',
|
|
32
|
+
sql: 'sql', graphql: 'graphql', gql: 'graphql',
|
|
33
|
+
dockerfile: 'dockerfile', makefile: 'makefile',
|
|
34
|
+
tf: 'hcl', hcl: 'hcl',
|
|
35
|
+
lua: 'lua', vim: 'vim', el: 'lisp', clj: 'clojure',
|
|
36
|
+
ex: 'elixir', exs: 'elixir', erl: 'erlang',
|
|
37
|
+
hs: 'haskell', ml: 'ocaml', nim: 'nim', zig: 'zig',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function bindRenderUtils(ctx: RenderUtilsContext) {
|
|
41
|
+
const { getState, documentRef } = ctx;
|
|
42
|
+
|
|
43
|
+
function escapeHtml(value: unknown) {
|
|
44
|
+
return String(value ?? '').replace(/[&<>"']/g, (char) => ({
|
|
45
|
+
'&': '&',
|
|
46
|
+
'<': '<',
|
|
47
|
+
'>': '>',
|
|
48
|
+
'"': '"',
|
|
49
|
+
'\'': ''',
|
|
50
|
+
}[char] || char));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function stripCitations(text: string | null | undefined) {
|
|
54
|
+
if (!text) return text;
|
|
55
|
+
return text.replace(/'citeturn\d+file\d+(?:L\d+(?:-L\d+)?)?'/g, '');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function detectLangFromPath(file: string | null | undefined) {
|
|
59
|
+
if (!file) return null;
|
|
60
|
+
const ext = file.split('.').pop()?.toLowerCase();
|
|
61
|
+
if (ext && FILE_EXT_LANG_MAP[ext]) return FILE_EXT_LANG_MAP[ext];
|
|
62
|
+
const basename = file.split('/').pop()?.toLowerCase();
|
|
63
|
+
if (basename === 'dockerfile') return 'dockerfile';
|
|
64
|
+
if (basename === 'makefile' || basename === 'gnumakefile') return 'makefile';
|
|
65
|
+
if (basename?.endsWith('rc') || basename?.startsWith('.')) return 'bash';
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resolveHljsLanguage(lang: string | null | undefined) {
|
|
70
|
+
if (typeof hljs === 'undefined' || !lang) return null;
|
|
71
|
+
const requested = String(lang).trim().toLowerCase();
|
|
72
|
+
if (!requested) return null;
|
|
73
|
+
const fallbackMap: Record<string, string[]> = {
|
|
74
|
+
javascript: ['javascript', 'typescript'],
|
|
75
|
+
jsx: ['javascript', 'typescript'],
|
|
76
|
+
typescript: ['typescript', 'javascript'],
|
|
77
|
+
tsx: ['typescript', 'javascript'],
|
|
78
|
+
html: ['html', 'xml'],
|
|
79
|
+
htm: ['html', 'xml'],
|
|
80
|
+
xml: ['xml', 'html'],
|
|
81
|
+
markdown: ['markdown'],
|
|
82
|
+
md: ['markdown'],
|
|
83
|
+
json: ['json'],
|
|
84
|
+
css: ['css', 'scss'],
|
|
85
|
+
scss: ['scss', 'css'],
|
|
86
|
+
yaml: ['yaml'],
|
|
87
|
+
yml: ['yaml'],
|
|
88
|
+
toml: ['ini'],
|
|
89
|
+
bash: ['bash'],
|
|
90
|
+
sh: ['bash'],
|
|
91
|
+
};
|
|
92
|
+
const candidates = fallbackMap[requested] || [requested];
|
|
93
|
+
for (const candidate of candidates) {
|
|
94
|
+
if (candidate && hljs?.getLanguage?.(candidate)) return candidate;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function buildViewCardTitle(path: string, viewRange: unknown, fallbackTitle = '') {
|
|
100
|
+
const shortPath = path ? String(path).split('/').pop() : '';
|
|
101
|
+
if (
|
|
102
|
+
Array.isArray(viewRange)
|
|
103
|
+
&& viewRange.length >= 2
|
|
104
|
+
&& Number.isFinite(Number(viewRange[0]))
|
|
105
|
+
&& Number.isFinite(Number(viewRange[1]))
|
|
106
|
+
) {
|
|
107
|
+
return `${shortPath || fallbackTitle || 'view'} Lines ${Number(viewRange[0])}–${Number(viewRange[1])}`;
|
|
108
|
+
}
|
|
109
|
+
if (Array.isArray(viewRange) && viewRange.length === 1 && Number.isFinite(Number(viewRange[0]))) {
|
|
110
|
+
return `${shortPath || fallbackTitle || 'view'} Line ${Number(viewRange[0])}+`;
|
|
111
|
+
}
|
|
112
|
+
return shortPath || fallbackTitle || 'view';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function detectLangFromCommand(command: string | null | undefined) {
|
|
116
|
+
if (!command) return null;
|
|
117
|
+
|
|
118
|
+
const shCMatch = command.match(/sh\s+-[lc]+\s+['"](.+)['"]\s*$/);
|
|
119
|
+
const innerCmd = shCMatch ? shCMatch[1] : command;
|
|
120
|
+
|
|
121
|
+
if (commandContainsGitDiff(command)) return 'diff';
|
|
122
|
+
|
|
123
|
+
const catMatch = innerCmd.match(/\b(?:cat|head|tail|less|more|bat)\s+['"]*([^\s'"]+)/);
|
|
124
|
+
if (catMatch) {
|
|
125
|
+
const lang = detectLangFromPath(catMatch[1]);
|
|
126
|
+
if (lang) return lang;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const sedMatch = innerCmd.match(/\bsed\s+(?:-[^\s]+\s+)*'[^']+'\s+([^\s'"]+)\s*$/);
|
|
130
|
+
if (sedMatch) {
|
|
131
|
+
const lang = detectLangFromPath(sedMatch[1]);
|
|
132
|
+
if (lang) return lang;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const awkGrepMatch = innerCmd.match(/\b(?:awk|grep)\s+(?:-[^\s]+\s+)*(?:'[^']+'|"[^"]+")\s+([^\s'"]+)\s*$/);
|
|
136
|
+
if (awkGrepMatch) {
|
|
137
|
+
const lang = detectLangFromPath(awkGrepMatch[1]);
|
|
138
|
+
if (lang) return lang;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const segments = innerCmd.split(/\s*(?:\|\||&&|\||;)\s*/g);
|
|
142
|
+
let best = null;
|
|
143
|
+
for (const segment of segments) {
|
|
144
|
+
const tokens = segment.match(/(?:'[^']*'|"[^"]*"|`[^`]*`|[^\s]+)/g) || [];
|
|
145
|
+
for (const token of tokens) {
|
|
146
|
+
const raw = String(token || '').trim();
|
|
147
|
+
if (!raw) continue;
|
|
148
|
+
const unquoted = (
|
|
149
|
+
(raw.startsWith('"') && raw.endsWith('"'))
|
|
150
|
+
|| (raw.startsWith('\'') && raw.endsWith('\''))
|
|
151
|
+
|| (raw.startsWith('`') && raw.endsWith('`'))
|
|
152
|
+
)
|
|
153
|
+
? raw.slice(1, -1)
|
|
154
|
+
: raw;
|
|
155
|
+
if (unquoted.startsWith('-')) continue;
|
|
156
|
+
const match = unquoted.match(/([^\s'"]+\.\w+)$/);
|
|
157
|
+
if (match) {
|
|
158
|
+
const lang = detectLangFromPath(match[1]);
|
|
159
|
+
if (lang) best = lang;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (best) return best;
|
|
164
|
+
|
|
165
|
+
const anyFileMatch = innerCmd.match(/([^\s'"]+\.\w+)\s*$/);
|
|
166
|
+
if (anyFileMatch) {
|
|
167
|
+
const lang = detectLangFromPath(anyFileMatch[1]);
|
|
168
|
+
if (lang) return lang;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (innerCmd.includes('python') || innerCmd.includes('python3')) return 'python';
|
|
172
|
+
if (innerCmd.includes('node ') || innerCmd.includes('npx ')) return 'javascript';
|
|
173
|
+
if (innerCmd.includes('ruby ')) return 'ruby';
|
|
174
|
+
if (innerCmd.includes('go run')) return 'go';
|
|
175
|
+
if (innerCmd.includes('rustc') || innerCmd.includes('cargo')) return 'rust';
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function highlightCodeAlways(text: string, lang: string | null | undefined) {
|
|
180
|
+
if (typeof hljs === 'undefined' || !text?.trim()) {
|
|
181
|
+
return escapeHtml(text || '');
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const resolvedLang = resolveHljsLanguage(lang);
|
|
185
|
+
if (resolvedLang && hljs.highlight) {
|
|
186
|
+
return hljs.highlight(text, { language: resolvedLang, ignoreIllegals: true }).value;
|
|
187
|
+
}
|
|
188
|
+
const result = hljs.highlightAuto?.(text);
|
|
189
|
+
if (result && result.relevance > 5) {
|
|
190
|
+
return result.value;
|
|
191
|
+
}
|
|
192
|
+
} catch {
|
|
193
|
+
// fall through
|
|
194
|
+
}
|
|
195
|
+
return escapeHtml(text || '');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function normalizeStructuredViewLines(lines: unknown): StructuredViewLine[] | null {
|
|
199
|
+
if (!Array.isArray(lines) || !lines.length) return null;
|
|
200
|
+
const normalized: StructuredViewLine[] = [];
|
|
201
|
+
for (const entry of lines) {
|
|
202
|
+
if (!entry || typeof entry !== 'object') return null;
|
|
203
|
+
const record = entry as UnknownRecord;
|
|
204
|
+
const rawLineNo = record.line_no ?? record.lineNo;
|
|
205
|
+
const lineNo = Number(rawLineNo);
|
|
206
|
+
if (!Number.isFinite(lineNo)) return null;
|
|
207
|
+
normalized.push({
|
|
208
|
+
line_no: lineNo,
|
|
209
|
+
content: record.content === null || record.content === undefined
|
|
210
|
+
? ''
|
|
211
|
+
: String(record.content),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return normalized;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function synthesizeStructuredViewLines(content: unknown, viewRange: unknown): StructuredViewLine[] | null {
|
|
218
|
+
if (typeof content !== 'string') return null;
|
|
219
|
+
if (!Array.isArray(viewRange) || !viewRange.length) return null;
|
|
220
|
+
const startLine = Number(viewRange[0]);
|
|
221
|
+
if (!Number.isFinite(startLine)) return null;
|
|
222
|
+
if (!content) return [];
|
|
223
|
+
const normalizedContent = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
224
|
+
const rawLines = normalizedContent.split('\n');
|
|
225
|
+
if (rawLines.length && rawLines[rawLines.length - 1] === '') {
|
|
226
|
+
rawLines.pop();
|
|
227
|
+
}
|
|
228
|
+
return rawLines.map((rawLine, idx) => ({
|
|
229
|
+
line_no: startLine + idx,
|
|
230
|
+
content: rawLine,
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function splitHighlightedHtmlIntoLines(highlightedHtml: string) {
|
|
235
|
+
const html = String(highlightedHtml || '');
|
|
236
|
+
const tokens = html.split(/(<[^>]+>)/g);
|
|
237
|
+
const openTags: Array<{ name: string; open: string }> = [];
|
|
238
|
+
const lines: string[] = [];
|
|
239
|
+
let current = '';
|
|
240
|
+
|
|
241
|
+
const closeAllTags = () => openTags.slice().reverse().map((tag) => `</${tag.name}>`).join('');
|
|
242
|
+
const reopenAllTags = () => openTags.map((tag) => tag.open).join('');
|
|
243
|
+
|
|
244
|
+
for (const token of tokens) {
|
|
245
|
+
if (!token) continue;
|
|
246
|
+
if (token.startsWith('<')) {
|
|
247
|
+
current += token;
|
|
248
|
+
if (token.startsWith('<!--') || token.startsWith('<!')) continue;
|
|
249
|
+
const match = token.match(/^<\s*(\/?)\s*([a-zA-Z0-9:-]+)/);
|
|
250
|
+
if (!match) continue;
|
|
251
|
+
const isClosing = Boolean(match[1]);
|
|
252
|
+
const tagName = String(match[2] || '').toLowerCase();
|
|
253
|
+
const selfClosing = /\/\s*>$/.test(token) || ['br', 'hr', 'img', 'input', 'meta', 'link'].includes(tagName);
|
|
254
|
+
if (isClosing) {
|
|
255
|
+
for (let idx = openTags.length - 1; idx >= 0; idx -= 1) {
|
|
256
|
+
if (openTags[idx].name === tagName) {
|
|
257
|
+
openTags.splice(idx, 1);
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
} else if (!selfClosing) {
|
|
262
|
+
openTags.push({ name: tagName, open: token });
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const textParts = token.split('\n');
|
|
268
|
+
for (let idx = 0; idx < textParts.length; idx += 1) {
|
|
269
|
+
current += textParts[idx];
|
|
270
|
+
if (idx < textParts.length - 1) {
|
|
271
|
+
lines.push(current + closeAllTags());
|
|
272
|
+
current = reopenAllTags();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
lines.push(current);
|
|
278
|
+
return lines;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function buildHighlightedViewLineHtml(lines: StructuredViewLine[], lang: string | null) {
|
|
282
|
+
if (!Array.isArray(lines) || !lines.length) return [];
|
|
283
|
+
const highlighted = highlightCodeAlways(lines.map((line) => line.content).join('\n'), lang);
|
|
284
|
+
const htmlLines = splitHighlightedHtmlIntoLines(highlighted);
|
|
285
|
+
return htmlLines.length === lines.length ? htmlLines : [];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function getStructuredViewGutterDigits(lines: StructuredViewLine[]) {
|
|
289
|
+
if (!Array.isArray(lines) || !lines.length) return 1;
|
|
290
|
+
let maxDigits = 1;
|
|
291
|
+
lines.forEach((line) => {
|
|
292
|
+
const raw = Number(line?.line_no);
|
|
293
|
+
const digits = Number.isFinite(raw) ? String(Math.abs(Math.trunc(raw))).length : 1;
|
|
294
|
+
if (digits > maxDigits) maxDigits = digits;
|
|
295
|
+
});
|
|
296
|
+
return maxDigits;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function renderStructuredViewLineTable(lines: StructuredViewLine[], path: string) {
|
|
300
|
+
const output = documentRef.createElement('div');
|
|
301
|
+
output.className = 'command-output view-card-lines';
|
|
302
|
+
output.classList.toggle('wrap-enabled', getState().viewWrapEnabled === true);
|
|
303
|
+
|
|
304
|
+
const table = documentRef.createElement('table');
|
|
305
|
+
table.className = 'view-card-table';
|
|
306
|
+
const gutterDigits = getStructuredViewGutterDigits(lines);
|
|
307
|
+
table.style.setProperty('--view-card-gutter-ch', String(gutterDigits));
|
|
308
|
+
const tableBody = documentRef.createElement('tbody');
|
|
309
|
+
|
|
310
|
+
const lang = detectLangFromPath(path);
|
|
311
|
+
const highlightedLines = typeof hljs !== 'undefined' ? buildHighlightedViewLineHtml(lines, lang) : [];
|
|
312
|
+
|
|
313
|
+
lines.forEach((line, idx) => {
|
|
314
|
+
const row = documentRef.createElement('tr');
|
|
315
|
+
row.className = 'view-card-line';
|
|
316
|
+
row.dataset.lineNo = String(line.line_no);
|
|
317
|
+
|
|
318
|
+
const gutter = documentRef.createElement('td');
|
|
319
|
+
gutter.className = 'view-card-line-no transcript-line-no';
|
|
320
|
+
gutter.dataset.lineNo = String(line.line_no);
|
|
321
|
+
gutter.textContent = String(line.line_no).padStart(gutterDigits, ' ');
|
|
322
|
+
|
|
323
|
+
const content = documentRef.createElement('td');
|
|
324
|
+
content.className = 'view-card-line-content transcript-line-content';
|
|
325
|
+
content.dataset.lineNo = String(line.line_no);
|
|
326
|
+
const lineHtml = highlightedLines[idx];
|
|
327
|
+
if (typeof lineHtml === 'string') {
|
|
328
|
+
content.innerHTML = lineHtml;
|
|
329
|
+
} else {
|
|
330
|
+
content.textContent = line.content;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
row.appendChild(gutter);
|
|
334
|
+
row.appendChild(content);
|
|
335
|
+
tableBody.appendChild(row);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
table.appendChild(tableBody);
|
|
339
|
+
output.appendChild(table);
|
|
340
|
+
return output;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function renderWithHighlighting(container: HTMLElement, text: string | null | undefined) {
|
|
344
|
+
if (!text) return;
|
|
345
|
+
const cleanText = stripCitations(text) || '';
|
|
346
|
+
|
|
347
|
+
const codeBlockRegex = /```(\w*)\n([\s\S]*?)```/g;
|
|
348
|
+
let lastIndex = 0;
|
|
349
|
+
let match: RegExpExecArray | null;
|
|
350
|
+
let hasCodeBlocks = false;
|
|
351
|
+
|
|
352
|
+
while ((match = codeBlockRegex.exec(cleanText)) !== null) {
|
|
353
|
+
hasCodeBlocks = true;
|
|
354
|
+
if (match.index > lastIndex) {
|
|
355
|
+
const textBefore = cleanText.slice(lastIndex, match.index);
|
|
356
|
+
const span = documentRef.createElement('span');
|
|
357
|
+
span.textContent = textBefore;
|
|
358
|
+
container.appendChild(span);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const lang = match[1] || '';
|
|
362
|
+
const code = match[2];
|
|
363
|
+
const pre = documentRef.createElement('pre');
|
|
364
|
+
const codeEl = documentRef.createElement('code');
|
|
365
|
+
if (lang) codeEl.className = `language-${lang}`;
|
|
366
|
+
codeEl.textContent = code;
|
|
367
|
+
pre.appendChild(codeEl);
|
|
368
|
+
container.appendChild(pre);
|
|
369
|
+
|
|
370
|
+
if (hljs?.highlightElement) {
|
|
371
|
+
hljs.highlightElement(codeEl);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
lastIndex = match.index + match[0].length;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (hasCodeBlocks) {
|
|
378
|
+
if (lastIndex < cleanText.length) {
|
|
379
|
+
const span = documentRef.createElement('span');
|
|
380
|
+
span.textContent = cleanText.slice(lastIndex);
|
|
381
|
+
container.appendChild(span);
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
container.textContent = cleanText;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function toRelativePath(absPath: string | null | undefined) {
|
|
389
|
+
if (!absPath) return '';
|
|
390
|
+
const { conversationSettings = {}, conversationMeta = {} } = getState();
|
|
391
|
+
const cwd = conversationSettings.cwd || conversationMeta.cwd || '';
|
|
392
|
+
if (cwd && absPath.startsWith(cwd)) {
|
|
393
|
+
let rel = absPath.slice(cwd.length);
|
|
394
|
+
if (rel.startsWith('/')) rel = rel.slice(1);
|
|
395
|
+
return rel || absPath;
|
|
396
|
+
}
|
|
397
|
+
const home = '/data/data/com.termux/files/home';
|
|
398
|
+
if (absPath.startsWith(`${home}/`)) {
|
|
399
|
+
const cwdExpanded = typeof cwd === 'string' && cwd.startsWith('~') ? `${home}${cwd.slice(1)}` : cwd;
|
|
400
|
+
if (cwdExpanded && absPath.startsWith(cwdExpanded)) {
|
|
401
|
+
let rel = absPath.slice(cwdExpanded.length);
|
|
402
|
+
if (rel.startsWith('/')) rel = rel.slice(1);
|
|
403
|
+
return rel || absPath;
|
|
404
|
+
}
|
|
405
|
+
return `~/${absPath.slice(home.length + 1)}`;
|
|
406
|
+
}
|
|
407
|
+
return absPath;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function setPill(el: HTMLElement | null, text: string, cls?: string) {
|
|
411
|
+
if (!el) return;
|
|
412
|
+
el.textContent = text;
|
|
413
|
+
el.className = `pill ${cls || ''}`.trim();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
escapeHtml,
|
|
418
|
+
stripCitations,
|
|
419
|
+
detectLangFromPath,
|
|
420
|
+
resolveHljsLanguage,
|
|
421
|
+
buildViewCardTitle,
|
|
422
|
+
detectLangFromCommand,
|
|
423
|
+
highlightCodeAlways,
|
|
424
|
+
normalizeStructuredViewLines,
|
|
425
|
+
synthesizeStructuredViewLines,
|
|
426
|
+
renderStructuredViewLineTable,
|
|
427
|
+
renderWithHighlighting,
|
|
428
|
+
toRelativePath,
|
|
429
|
+
setPill,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export function commandContainsGitDiff(command: string | null | undefined): boolean {
|
|
434
|
+
if (!command) return false;
|
|
435
|
+
const shellWrapper = command.match(
|
|
436
|
+
/(?:^|\s)(?:[^\s'"]*\/)?(?:ba|da|z)?sh\s+-[lc]+\s+(['"])([\s\S]*)\1\s*$/i,
|
|
437
|
+
);
|
|
438
|
+
const candidate = shellWrapper ? shellWrapper[2] : command;
|
|
439
|
+
const tokens = candidate.match(/(?:'[^']*'|"[^"]*"|`[^`]*`|&&|\|\||[|;]|[^\s]+)/g) || [];
|
|
440
|
+
let sawGit = false;
|
|
441
|
+
for (const rawToken of tokens) {
|
|
442
|
+
const token = rawToken.replace(/^[('"`]+|[)'"`;]+$/g, '');
|
|
443
|
+
if (!token) continue;
|
|
444
|
+
if (token === '&&' || token === '||' || token === '|' || token === ';') {
|
|
445
|
+
sawGit = false;
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (!sawGit) {
|
|
449
|
+
const executable = token.split('/').pop()?.toLowerCase();
|
|
450
|
+
sawGit = executable === 'git';
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (token.toLowerCase() === 'diff') return true;
|
|
454
|
+
}
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { createSettingsRpcClient } from '../rpc/settings/client.ts';
|
|
2
|
+
|
|
3
|
+
type JsonObject = Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
interface RequestCardMatchEntry {
|
|
6
|
+
request_method: string;
|
|
7
|
+
kind: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface RequestCardDescriptor extends JsonObject {
|
|
11
|
+
module_url?: unknown;
|
|
12
|
+
export?: unknown;
|
|
13
|
+
matches?: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface RequestCardConfig {
|
|
17
|
+
extension_id: string;
|
|
18
|
+
cards: RequestCardDescriptor[];
|
|
19
|
+
schemas: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface RequestCardEvent extends JsonObject {
|
|
23
|
+
request_method?: unknown;
|
|
24
|
+
requestMethod?: unknown;
|
|
25
|
+
kind?: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface RequestCardRenderContext extends JsonObject {
|
|
29
|
+
extensionId?: unknown;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface RequestCardModuleInitContext {
|
|
33
|
+
extensionId: string;
|
|
34
|
+
cards: RequestCardDescriptor[];
|
|
35
|
+
schemas: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type RequestCardRenderer = (ctx: RequestCardRenderContext & {
|
|
39
|
+
extensionId: string;
|
|
40
|
+
event: RequestCardEvent;
|
|
41
|
+
card: RequestCardDescriptor;
|
|
42
|
+
config: RequestCardConfig;
|
|
43
|
+
schema: unknown;
|
|
44
|
+
}) => Promise<unknown> | unknown;
|
|
45
|
+
|
|
46
|
+
interface RequestCardModule {
|
|
47
|
+
default?: RequestCardRenderer;
|
|
48
|
+
initializeRequestCardModule?: (ctx: RequestCardModuleInitContext) => Promise<unknown> | unknown;
|
|
49
|
+
initializeExtensionCardModule?: (ctx: RequestCardModuleInitContext) => Promise<unknown> | unknown;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface RequestCardRuntimeContext {
|
|
54
|
+
sioCall(event: string, payload?: Record<string, unknown>, options?: Record<string, unknown>): Promise<unknown>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface RequestCardRuntimeBinding {
|
|
58
|
+
preload(extensionId: string): Promise<RequestCardConfig>;
|
|
59
|
+
render(evt: RequestCardEvent, renderCtx: RequestCardRenderContext): Promise<boolean>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function normalizeRequestMethod(value: unknown): string {
|
|
63
|
+
return typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function normalizeMatchEntries(card: RequestCardDescriptor | null | undefined): RequestCardMatchEntry[] {
|
|
67
|
+
const matches = Array.isArray(card?.matches) ? card.matches : [];
|
|
68
|
+
return matches
|
|
69
|
+
.filter((entry): entry is JsonObject => Boolean(entry) && typeof entry === 'object')
|
|
70
|
+
.map((entry) => ({
|
|
71
|
+
request_method: normalizeRequestMethod(entry.request_method || entry.requestMethod),
|
|
72
|
+
kind: typeof entry.kind === 'string' ? entry.kind.trim() : '',
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function requestCardProxyBase(): string {
|
|
77
|
+
if (typeof window === 'undefined') return '';
|
|
78
|
+
const path = typeof window.location?.pathname === 'string' ? window.location.pathname : '';
|
|
79
|
+
const match = path.match(/^(\/api\/app\/[^/]+\/proxy)(?:\/|$)/);
|
|
80
|
+
return match && match[1] ? match[1] : '';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function resolveRequestCardUrl(rawUrl: unknown): string {
|
|
84
|
+
const url = typeof rawUrl === 'string' ? rawUrl.trim() : '';
|
|
85
|
+
if (!url) return '';
|
|
86
|
+
if (/^(?:[a-z]+:)?\/\//i.test(url) || url.startsWith('data:') || url.startsWith('blob:')) {
|
|
87
|
+
return url;
|
|
88
|
+
}
|
|
89
|
+
const proxyBase = requestCardProxyBase();
|
|
90
|
+
if (proxyBase && url.startsWith('/')) {
|
|
91
|
+
return `${proxyBase}${url}`;
|
|
92
|
+
}
|
|
93
|
+
return url;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function normalizeConfigResponse(extensionId: string, data: unknown): RequestCardConfig {
|
|
97
|
+
if (!data || typeof data !== 'object') {
|
|
98
|
+
return { extension_id: extensionId, cards: [], schemas: {} };
|
|
99
|
+
}
|
|
100
|
+
const payload = data as JsonObject;
|
|
101
|
+
if (payload.ok === false) {
|
|
102
|
+
return { extension_id: extensionId, cards: [], schemas: {} };
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
extension_id: typeof payload.extension_id === 'string' ? payload.extension_id : extensionId,
|
|
106
|
+
cards: Array.isArray(payload.cards) ? payload.cards.filter((card): card is RequestCardDescriptor => Boolean(card) && typeof card === 'object') : [],
|
|
107
|
+
schemas: payload.schemas && typeof payload.schemas === 'object' ? (payload.schemas as Record<string, unknown>) : {},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function bindRequestCardRuntime(ctx: RequestCardRuntimeContext): RequestCardRuntimeBinding {
|
|
112
|
+
const { sioCall } = ctx;
|
|
113
|
+
const settingsRpcClient = createSettingsRpcClient({ sioCall });
|
|
114
|
+
const configCache = new Map<string, Promise<RequestCardConfig>>();
|
|
115
|
+
const moduleCache = new Map<string, Promise<RequestCardModule | null>>();
|
|
116
|
+
|
|
117
|
+
async function fetchConfig(extensionId: string): Promise<RequestCardConfig> {
|
|
118
|
+
const normalizedId = typeof extensionId === 'string' ? extensionId.trim() : '';
|
|
119
|
+
if (!normalizedId) return { extension_id: '', cards: [], schemas: {} };
|
|
120
|
+
const cachedConfig = configCache.get(normalizedId);
|
|
121
|
+
if (cachedConfig) {
|
|
122
|
+
return cachedConfig;
|
|
123
|
+
}
|
|
124
|
+
const promise = (async () => {
|
|
125
|
+
try {
|
|
126
|
+
const data = await settingsRpcClient.getExtensionRequestCards({
|
|
127
|
+
extensionId: normalizedId,
|
|
128
|
+
});
|
|
129
|
+
return normalizeConfigResponse(normalizedId, data);
|
|
130
|
+
} catch {
|
|
131
|
+
return { extension_id: normalizedId, cards: [], schemas: {} };
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
configCache.set(normalizedId, promise);
|
|
135
|
+
return promise;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function loadCardModule(
|
|
139
|
+
config: RequestCardConfig,
|
|
140
|
+
card: RequestCardDescriptor | null | undefined,
|
|
141
|
+
): Promise<RequestCardModule | null> {
|
|
142
|
+
const moduleUrl = resolveRequestCardUrl(card?.module_url);
|
|
143
|
+
if (!moduleUrl) return null;
|
|
144
|
+
const exportName = typeof card?.export === 'string' && card.export.trim() ? card.export.trim() : 'renderRequestCard';
|
|
145
|
+
const cacheKey = `${moduleUrl}#${exportName}`;
|
|
146
|
+
const cachedModule = moduleCache.get(cacheKey);
|
|
147
|
+
if (cachedModule) {
|
|
148
|
+
return cachedModule;
|
|
149
|
+
}
|
|
150
|
+
const promise = (async () => {
|
|
151
|
+
const mod = (await import(moduleUrl)) as RequestCardModule;
|
|
152
|
+
const init = mod?.initializeRequestCardModule || mod?.initializeExtensionCardModule;
|
|
153
|
+
if (typeof init === 'function') {
|
|
154
|
+
await init({
|
|
155
|
+
extensionId: config.extension_id,
|
|
156
|
+
cards: Array.isArray(config.cards) ? config.cards : [],
|
|
157
|
+
schemas: config.schemas && typeof config.schemas === 'object' ? config.schemas : {},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return mod;
|
|
161
|
+
})();
|
|
162
|
+
moduleCache.set(cacheKey, promise);
|
|
163
|
+
return promise;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function findMatchingCard(
|
|
167
|
+
config: RequestCardConfig | null | undefined,
|
|
168
|
+
evt: RequestCardEvent | null | undefined,
|
|
169
|
+
): RequestCardDescriptor | null {
|
|
170
|
+
const cards = Array.isArray(config?.cards) ? config.cards : [];
|
|
171
|
+
const requestMethod = normalizeRequestMethod(evt?.request_method || evt?.requestMethod);
|
|
172
|
+
const kind = typeof evt?.kind === 'string' ? evt.kind.trim() : '';
|
|
173
|
+
return cards.find((card) => {
|
|
174
|
+
const matches = normalizeMatchEntries(card);
|
|
175
|
+
if (!matches.length) return false;
|
|
176
|
+
return matches.some((match) => {
|
|
177
|
+
if (match.request_method && match.request_method !== requestMethod) return false;
|
|
178
|
+
if (match.kind && match.kind !== kind) return false;
|
|
179
|
+
return true;
|
|
180
|
+
});
|
|
181
|
+
}) || null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function preload(extensionId: string): Promise<RequestCardConfig> {
|
|
185
|
+
const config = await fetchConfig(extensionId);
|
|
186
|
+
const cards = Array.isArray(config.cards) ? config.cards : [];
|
|
187
|
+
await Promise.all(cards.map((card) => loadCardModule(config, card).catch(() => null)));
|
|
188
|
+
return config;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function render(
|
|
192
|
+
evt: RequestCardEvent,
|
|
193
|
+
renderCtx: RequestCardRenderContext,
|
|
194
|
+
): Promise<boolean> {
|
|
195
|
+
const extensionId = typeof renderCtx?.extensionId === 'string' && renderCtx.extensionId.trim()
|
|
196
|
+
? renderCtx.extensionId.trim()
|
|
197
|
+
: '';
|
|
198
|
+
if (!extensionId) return false;
|
|
199
|
+
const config = await fetchConfig(extensionId);
|
|
200
|
+
const card = findMatchingCard(config, evt);
|
|
201
|
+
if (!card) return false;
|
|
202
|
+
let mod: RequestCardModule | null;
|
|
203
|
+
try {
|
|
204
|
+
mod = await loadCardModule(config, card);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error('[request-cards] failed to load card module', {
|
|
207
|
+
extensionId,
|
|
208
|
+
moduleUrl: card?.module_url || null,
|
|
209
|
+
error,
|
|
210
|
+
});
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (!mod) return false;
|
|
214
|
+
const exportName = typeof card.export === 'string' && card.export.trim() ? card.export.trim() : 'renderRequestCard';
|
|
215
|
+
const renderFn = exportName === 'default'
|
|
216
|
+
? mod.default
|
|
217
|
+
: mod[exportName];
|
|
218
|
+
if (typeof renderFn !== 'function') return false;
|
|
219
|
+
const requestMethod = normalizeRequestMethod(evt?.request_method || evt?.requestMethod);
|
|
220
|
+
const schema = requestMethod ? (config.schemas?.[requestMethod] || null) : null;
|
|
221
|
+
const handled = await renderFn({
|
|
222
|
+
extensionId,
|
|
223
|
+
event: evt,
|
|
224
|
+
card,
|
|
225
|
+
config,
|
|
226
|
+
schema,
|
|
227
|
+
...renderCtx,
|
|
228
|
+
});
|
|
229
|
+
return handled === true;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
preload,
|
|
234
|
+
render,
|
|
235
|
+
};
|
|
236
|
+
}
|