Images - vision gate: text-only models get a note instead of image parts and no view_image tool; unknown models retry once without images on HTTP 400 - paste: Ctrl+V and /attach paste read the clipboard (wl-paste, xclip, pngpaste/osascript, Win32 PNG or CF_DIB converted to PNG); pasting image file paths attaches them - MCP image content is stored in the session and sent with the tool result - attach: rel path validation, base64 decode, /retry keeps images Model registry - built-in src/models_builtin.json embedded at build time, merged with <config>/models.json and cached GET /models metadata (context, vision, pricing); most specific rule wins per field - /model labels, /status source, --list-models [provider] Cache and cost - stable request prefix (frozen tools, notes as messages), DeepSeek prefix completion, OpenAI/Anthropic cache hints, /cost and hit rate in the status
66 lines
3.2 KiB
C
66 lines
3.2 KiB
C
#ifndef CST_TOOLS_INTERNAL_H
|
|
#define CST_TOOLS_INTERNAL_H
|
|
|
|
#include "cst_tools.h"
|
|
#include "cst_util.h"
|
|
|
|
#define READ_FILE_MAX (2 * 1024 * 1024)
|
|
|
|
/* Value of key, or NULL when absent. */
|
|
const char *tool_arg(const ctl_tool_call_t *call, const char *key);
|
|
const char *tool_arg_n(const ctl_tool_call_t *call, const char *key,
|
|
size_t *len);
|
|
/* Integer arg, def when absent or empty. */
|
|
long tool_arg_long(const ctl_tool_call_t *call, const char *key, long def);
|
|
int tool_arg_bool(const ctl_tool_call_t *call, const char *key, int def);
|
|
|
|
int tool_set_result(cst_tool_result_t *r, const char *s, int code);
|
|
int tool_set_resultf(cst_tool_result_t *r, int code, const char *fmt, ...);
|
|
int tool_take_buf(cst_tool_result_t *r, cst_buf_t *b, int code);
|
|
|
|
/* Whole file (NULL when missing, unreadable or larger than max>0). */
|
|
char *tool_slurp(const char *full, size_t *out_len, size_t max);
|
|
int tool_write_whole(const char *full, const char *data, size_t n);
|
|
void tool_ensure_parent_dirs(const char *workspace_root, const char *rel);
|
|
void tool_append_diff(cst_buf_t *b, const char *relpath, const char *oldc,
|
|
size_t olen, const char *newc, size_t nlen);
|
|
int tool_is_binary(const char *s, size_t n);
|
|
/* Workspace-relative display form of an absolute resolved path. */
|
|
const char *tool_rel(const char *workspace_real, const char *full);
|
|
|
|
int cst_tool_read_file2(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_list_dir(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_glob(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_grep(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_edit_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_delete_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_move_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_todo_write(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_ask_user(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_web_fetch(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
int cst_tool_view_image(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
cst_tool_result_t *r);
|
|
|
|
int cst_preview_write_file(const cst_tool_ctx_t *ctx,
|
|
const ctl_tool_call_t *c, char **out);
|
|
int cst_preview_apply_patch(const cst_tool_ctx_t *ctx,
|
|
const ctl_tool_call_t *c, char **out);
|
|
int cst_preview_edit_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
char **out);
|
|
int cst_preview_delete_file(const cst_tool_ctx_t *ctx,
|
|
const ctl_tool_call_t *c, char **out);
|
|
int cst_preview_move_file(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
|
char **out);
|
|
|
|
#endif
|