Initial CST-Agent: portable Linux/Termux/Windows coding agent.
Vendored sashidown, OpenAI-compatible env (OPENAI_*), and bootstrap scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#include "cst_agent.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MODEL_MAX_LEN 128
|
||||
|
||||
static int already(char out[][MODEL_MAX_LEN], int n, const char *name) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (strcmp(out[i], name) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int push(char out[][MODEL_MAX_LEN], int *n, int max, const char *name) {
|
||||
if (!name || !name[0] || *n >= max)
|
||||
return 0;
|
||||
if (already(out, *n, name))
|
||||
return 0;
|
||||
snprintf(out[*n], MODEL_MAX_LEN, "%s", name);
|
||||
(*n)++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cst_models_list(const char *current, char out[][128], int max_out) {
|
||||
if (!out || max_out <= 0)
|
||||
return 0;
|
||||
int n = 0;
|
||||
|
||||
const char *env = getenv("CST_MODELS");
|
||||
if (env && env[0]) {
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "%s", env);
|
||||
char *p = buf;
|
||||
while (*p && n < max_out) {
|
||||
while (*p == ':' || *p == ' ' || *p == ',')
|
||||
p++;
|
||||
if (!*p)
|
||||
break;
|
||||
char *start = p;
|
||||
while (*p && *p != ':' && *p != ',')
|
||||
p++;
|
||||
char save = *p;
|
||||
*p = 0;
|
||||
/* trim trailing spaces */
|
||||
char *end = start + strlen(start);
|
||||
while (end > start && (end[-1] == ' ' || end[-1] == '\t'))
|
||||
*--end = 0;
|
||||
push(out, &n, max_out, start);
|
||||
*p = save;
|
||||
if (*p)
|
||||
p++;
|
||||
}
|
||||
} else {
|
||||
push(out, &n, max_out, "MiniMax-M2.7");
|
||||
push(out, &n, max_out, "MiniMax-M2.5");
|
||||
push(out, &n, max_out, "gpt-4o");
|
||||
push(out, &n, max_out, "gpt-4o-mini");
|
||||
}
|
||||
|
||||
if (current && current[0])
|
||||
push(out, &n, max_out, current);
|
||||
|
||||
return n;
|
||||
}
|
||||
Reference in New Issue
Block a user