feat: add v2 task control and asynchronous isolated workers
This commit is contained in:
+11
-5
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "cJSON.h"
|
||||
#include "cst_clipboard.h"
|
||||
#include "cst_runtime.h"
|
||||
#include "cst_tools.h"
|
||||
#include "cst_util.h"
|
||||
#include "tools_internal.h"
|
||||
@@ -28,6 +29,10 @@ static int run_apply_patch(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
||||
}
|
||||
static int run_shell(const cst_tool_ctx_t *ctx, const ctl_tool_call_t *c,
|
||||
cst_tool_result_t *r) {
|
||||
if (ctx->agent && ctx->compact) {
|
||||
const cst_agent_config_t *cfg = cst_agent_config(ctx->agent);
|
||||
if (cfg->runtime && !cfg->depth) return cst_runtime_shell(ctx, c, r);
|
||||
}
|
||||
int rc = cst_tool_run_shell_ex(ctx->workspace_root, c, r, ctx->sandbox);
|
||||
if (rc == 0 && ctx->compact && r->out) {
|
||||
size_t n = 0;
|
||||
@@ -86,7 +91,9 @@ static const cst_tool_def_t TOOLS[] = {
|
||||
"+ tail. Prefer read_file/grep/glob/list_dir over cat/grep/find.",
|
||||
"Run a shell command in the workspace root (non-interactive, stdin is "
|
||||
"empty, killed after a timeout). Returns combined stdout+stderr.",
|
||||
{{"cmd", S, 1, "shell command"}},
|
||||
{{"cmd", S, 1, "shell command"},
|
||||
{"effect", S, 0, "workspace (interruptible) or external (protected; default)"},
|
||||
{"resource", S, 0, "resource lock such as a device identifier"}},
|
||||
CST_TP_SHELL, 1, run_shell, NULL, NO_DYN, NO_META},
|
||||
{"write_file",
|
||||
"Create a file or replace a whole file (parent directories are "
|
||||
@@ -566,14 +573,13 @@ int cst_tool_active(const cst_agent_config_t *cfg, const cst_tool_def_t *t) {
|
||||
/* plan_mode is enforced when a call runs, so tools[] stays the same */
|
||||
if (cfg->read_only && (t->perm == CST_TP_WRITE || t->perm == CST_TP_SHELL))
|
||||
return 0;
|
||||
if (cfg->orchestrate && cfg->depth == 0 &&
|
||||
(t->perm == CST_TP_WRITE || t->perm == CST_TP_SHELL))
|
||||
return 0;
|
||||
if ((cfg->read_only || (cfg->orchestrate && cfg->depth == 0)) &&
|
||||
if (cfg->read_only &&
|
||||
strcmp(t->name, "download") == 0)
|
||||
return 0; /* network download writes a workspace file */
|
||||
if (cfg->depth > 0 && strcmp(t->name, "task") == 0)
|
||||
return 0;
|
||||
if (cfg->depth > 0 && (!strcmp(t->owner ? t->owner : "", "builtin:runtime") ||
|
||||
!strncmp(t->name, "worker_", 7))) return 0;
|
||||
if (cfg->tools_only[0]) {
|
||||
char key[CTL_MAX_NAME + 2];
|
||||
snprintf(key, sizeof(key), ",%s,", t->name);
|
||||
|
||||
Reference in New Issue
Block a user