v0.8.7: tool capability metadata, in-process engine, Qt app, Android engine
The engine can be embedded now instead of only driven from a terminal: the same objects link into a Qt front end (app/) that owns a cst_agent_t inside its own process -- no port, no token, no second process -- and that front end now runs on the desktop and, engine-side, on the phone. Capability metadata (include/cst_tools.h, src/tools/registry.c): - cst_tool_def_t gains perm_name, platforms and available (a probe that returns a reason), so a permission is addressable by name and a tool can say why it cannot run here. - cst_platform_name(), cst_tool_platform_ok(), cst_tool_available(), cst_tool_meta_reload(), cst_tool_perm_name() and CST_PLAT_DESKTOP[]. - cst_tool_register() may take over a built-in name that is not runnable on this platform, so a front end replaces it with its own implementation. - the registry entries carry their class (delete_file -> "delete"), the desktop clipboard tools carry a clipboard probe; find/active/run gate on it. - /api/settings.tools[] exposes perm_name, platforms, available, why and the declared parameters. Engine as a library (Makefile, CMakeLists.txt): - libcstcore.a from the CORE_OBJ set, and a CMake cstcore target shared by the CLI and by app/ (-DCST_BUILD_APP=ON): the engine is compiled once. - Android branch for the vendored sashidown: a per-ABI archive built with the NDK's aarch64-linux-android24-clang wrapper, because CMake's compiler is plain clang and keeps --target/--sysroot in its own variables. Qt front end (app/, new): - AgentCore wraps one cst_agent_t: turns run on a worker thread, every cst_agent_hooks_t callback becomes a Qt signal, and the two hooks that need an answer (on_permission, on_ask_user) block the worker until the GUI replies; mode, approval and plan mode go through the engine's config. - ToolProvider hands the front end's tools to the engine (owner "app:*"); the Linux one is notification_send with a probe for notify-send/D-Bus. - Main.qml: transcript, tool blocks, consent dialog (Deny/Once/Always -> CST_PERM_*), ask_user, mode switch, Esc to cancel; --selftest stays headless and runs the embedding checks without QML. Android (scripts/, docs/android.md, new): - scripts/build_third_party_android.sh builds static mbedTLS + libcurl for an ABI (CA path /system/etc/security/cacerts); build_android.sh builds cst-agent, libcstcore.a and the test binaries for the phone, can push them and run the whole suite there. - sandbox_exec.c keeps the plain exec path on Android: the seccomp supervisor compiled in and the probe reported "seccomp", but writes outside the workspace were not denied on the device -- claiming a sandbox that does not hold is worse than reporting none. - tests/test_diff.c compares layouts only against real GNU diffutils: toybox's diff prints the same hunk header with its own hunk/context rules. Tests: test_tool_meta (metadata, platform gate, probe reasons, takeover of a built-in name) and test_embed (in-process embedding contract) are new; the existing registry/llm_body assertions now follow availability. 38 test binaries pass on the host, 36/36 on arm64-v8a Android 16, cst-app-selftest passes in both the standalone app/ build and the repo build. Version 0.8.7.
This commit is contained in:
+56
-10
@@ -6,6 +6,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
option(CST_BUILD_TUI "Build ncurses/PDCurses TUI" ON)
|
||||
option(CST_BUILD_WEBUI "Build the HTTP/SSE WebUI (--web)" ON)
|
||||
option(CST_BUILD_APP "Build the Qt front end in app/ (in-process engine, no port)" OFF)
|
||||
option(CST_NATIVE_ARCH "Pass -march=native to sashidown" OFF)
|
||||
option(CST_BUNDLE_BUSYBOX "Install placeholder/scripts for busybox beside binary" ON)
|
||||
|
||||
@@ -64,6 +65,29 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
COMMAND ${CST_MAKE} -C "${SD_DIR}" clean
|
||||
COMMENT "Building libsashidown for MinGW"
|
||||
VERBATIM)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
# The host archive has to stay host-built (the CLI, the tests and the
|
||||
# Makefile link it), so the NDK build keeps its own copy, one per ABI.
|
||||
# CMake's compiler is plain clang (the --target/--sysroot flags live in its
|
||||
# own variables), so the vendor make gets the per-target wrapper instead:
|
||||
# aarch64-linux-android24-clang carries both.
|
||||
get_filename_component(_SD_CC_BIN "${CMAKE_C_COMPILER}" DIRECTORY)
|
||||
string(REPLACE "-none" "" _SD_TRIPLE "${CMAKE_C_COMPILER_TARGET}")
|
||||
set(_SD_CC "${_SD_CC_BIN}/${_SD_TRIPLE}-clang")
|
||||
if(NOT EXISTS "${_SD_CC}")
|
||||
set(_SD_CC "${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
set(SASHIDOWN_A "${SD_DIR}/libsashidown-${ANDROID_ABI}.a")
|
||||
add_custom_command(
|
||||
OUTPUT "${SASHIDOWN_A}"
|
||||
COMMAND ${CST_MAKE} -C "${SD_DIR}" clean
|
||||
COMMAND ${CST_MAKE} -C "${SD_DIR}" libsashidown.a
|
||||
CC=${_SD_CC} AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${SD_DIR}/libsashidown.a" "${SASHIDOWN_A}"
|
||||
COMMAND ${CST_MAKE} -C "${SD_DIR}" clean
|
||||
COMMENT "Building libsashidown for Android (${ANDROID_ABI})"
|
||||
VERBATIM)
|
||||
else()
|
||||
set(SASHIDOWN_A "${SD_DIR}/libsashidown.a")
|
||||
add_custom_command(
|
||||
@@ -181,7 +205,34 @@ if(WIN32)
|
||||
set_source_files_properties(${_CST_TRE_SOURCES} PROPERTIES COMPILE_OPTIONS "-w")
|
||||
endif()
|
||||
|
||||
set(CST_SOURCES ${CST_CORE_SOURCES} src/main.c)
|
||||
# --- the engine as a library ---------------------------------------------
|
||||
# cstcore is the core without main()/TUI: the CLI links it and the Qt front
|
||||
# end in app/ (CST_BUILD_APP) embeds the very same objects in-process, so the
|
||||
# engine is compiled once per build instead of once per front end.
|
||||
add_library(cstcore STATIC ${CST_CORE_SOURCES})
|
||||
add_dependencies(cstcore sashidown)
|
||||
target_include_directories(cstcore PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${SD_DIR}/include"
|
||||
"${CJSON_DIR}"
|
||||
)
|
||||
target_compile_definitions(cstcore PRIVATE _GNU_SOURCE)
|
||||
if(WIN32)
|
||||
target_compile_definitions(cstcore PRIVATE _WIN32_WINNT=0x0A00)
|
||||
target_link_libraries(cstcore PUBLIC
|
||||
"${SASHIDOWN_A}" CURL::libcurl Threads::Threads
|
||||
ws2_32 crypt32 secur32 bcrypt advapi32 user32)
|
||||
else()
|
||||
target_compile_definitions(cstcore PRIVATE _XOPEN_SOURCE_EXTENDED)
|
||||
target_link_libraries(cstcore PUBLIC
|
||||
"${SASHIDOWN_A}" CURL::libcurl Threads::Threads m)
|
||||
endif()
|
||||
|
||||
if(CST_BUILD_APP)
|
||||
add_subdirectory(app)
|
||||
endif()
|
||||
|
||||
set(CST_SOURCES src/main.c)
|
||||
|
||||
if(CST_BUILD_TUI)
|
||||
list(APPEND CST_SOURCES src/textsel.c src/tui.c)
|
||||
@@ -204,14 +255,8 @@ if(NOT WIN32)
|
||||
target_compile_definitions(cst-agent PRIVATE _XOPEN_SOURCE_EXTENDED)
|
||||
endif()
|
||||
|
||||
target_link_libraries(cst-agent PRIVATE
|
||||
"${SASHIDOWN_A}"
|
||||
CURL::libcurl
|
||||
Threads::Threads
|
||||
)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(cst-agent PRIVATE m)
|
||||
endif()
|
||||
# cstcore carries sashidown, curl, threads and libm as usage requirements.
|
||||
target_link_libraries(cst-agent PRIVATE cstcore)
|
||||
|
||||
set(CST_WIN_CURSES "ncurses" CACHE STRING "Windows TUI backend: ncurses or pdcurses")
|
||||
set_property(CACHE CST_WIN_CURSES PROPERTY STRINGS ncurses pdcurses)
|
||||
@@ -330,7 +375,8 @@ set(_CST_CORE_TESTS test_llm_body test_prefix_stable test_sse_decode
|
||||
test_undo test_config test_models test_model_registry test_sandbox
|
||||
test_keymap test_shell_compact test_skills
|
||||
test_plugins test_mcp test_subagent test_lowil
|
||||
test_win_utf8 test_os_dir test_tmpdir)
|
||||
test_win_utf8 test_os_dir test_tmpdir
|
||||
test_tool_meta test_embed)
|
||||
if(CST_BUILD_WEBUI)
|
||||
# test_webui drives the real server; the stub has nothing to test.
|
||||
list(APPEND _CST_CORE_TESTS test_webui)
|
||||
|
||||
Reference in New Issue
Block a user