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.
54 lines
2.1 KiB
C
54 lines
2.1 KiB
C
#ifndef CST_CLIPBOARD_H
|
|
#define CST_CLIPBOARD_H
|
|
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Image bytes on the system clipboard (PNG, or BMP from a Windows DIB).
|
|
* Wayland: wl-paste; X11: xclip; macOS: pngpaste or osascript; Windows: the
|
|
* clipboard API. Returns 0 with *data malloc'd, or -1 with err filled in
|
|
* ("no image on the clipboard", "install wl-clipboard", ...). */
|
|
int cst_clipboard_image(char **data, size_t *n, char *err, size_t err_sz);
|
|
|
|
/* Cap on text moved through the clipboard (read and write). */
|
|
#define CST_CLIPBOARD_TEXT_MAX (1024 * 1024)
|
|
|
|
/* UTF-8 text on the system clipboard: Wayland (wl-paste), X11 (xclip),
|
|
* macOS (pbpaste), Windows (CF_UNICODETEXT). Returns 0 with *data malloc'd
|
|
* and NUL-terminated, or -1 with err filled in ("no text on the clipboard",
|
|
* "reading the clipboard needs wl-clipboard", ...). */
|
|
int cst_clipboard_text(char **data, size_t *n, char *err, size_t err_sz);
|
|
|
|
/* Replace the clipboard with UTF-8 text: wl-copy / xclip / pbcopy, or the
|
|
* Windows clipboard API. Returns 0 on success, else -1 with err. */
|
|
int cst_clipboard_set_text(const char *text, size_t n, char *err,
|
|
size_t err_sz);
|
|
|
|
/* Windows CF_DIB bytes (BITMAPINFOHEADER + pixels) as an image file: a PNG
|
|
* for uncompressed 24/32-bit bitmaps, else a BMP. NULL when malformed. */
|
|
char *cst_dib_to_image(const void *dib, size_t sz, size_t *n);
|
|
|
|
/* 0 when this host has a clipboard to talk to (a helper on PATH, or the
|
|
* Win32/AppKit API), -1 with a reason otherwise. Cheap: no forks. */
|
|
int cst_clipboard_available(char *why, size_t why_sz);
|
|
|
|
#define CST_PASTE_MAX_PATHS 8
|
|
#define CST_PASTE_PATH_MAX 1024
|
|
|
|
/* Split pasted text into file paths the way terminals paste dropped files:
|
|
* whitespace- or newline-separated, '...' / "..." quoting, file:// URIs
|
|
* (percent-decoded) and, outside Windows, backslash escapes. Returns the
|
|
* count, or -1 when the text is empty or holds more than max paths. Whether
|
|
* the paths exist is up to the caller. */
|
|
int cst_paste_paths(const char *text, size_t len,
|
|
char out[][CST_PASTE_PATH_MAX], int max);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|