diff --git a/plugins/planner/planner.c b/plugins/planner/planner.c index d02258d..8dc2869 100644 --- a/plugins/planner/planner.c +++ b/plugins/planner/planner.c @@ -6,6 +6,7 @@ * Integrates with /goal (focus plugin) to prevent drift. */ #include +#include #include #include #include @@ -29,6 +30,26 @@ struct ptask { int active; }; +static pthread_mutex_t plan_lock; +static pthread_once_t plan_lock_once = PTHREAD_ONCE_INIT; + +static void +plan_lock_init(void) +{ + pthread_mutexattr_t a; + + pthread_mutexattr_init(&a); + pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&plan_lock, &a); + pthread_mutexattr_destroy(&a); +} + +#define PLAN_LOCK() do { \ + pthread_once(&plan_lock_once, plan_lock_init); \ + pthread_mutex_lock(&plan_lock); \ +} while (0) +#define PLAN_UNLOCK() pthread_mutex_unlock(&plan_lock) + static struct sp_host *host_ref; static struct ptask tasks[PT_MAX]; static size_t ntasks; @@ -172,7 +193,7 @@ static void focus_task(struct ptask *t) { sp_buf_free(&out); } -static int tool_add(const char *args, struct sp_buf *out, void *ctx) { +static int tool_add_locked(const char *args, struct sp_buf *out, void *ctx) { char desc[PT_DESC], ra[64]; struct ptask *t; (void)ctx; ensure_dir(); load_tasks(); desc[0]=ra[0]='\0'; @@ -192,7 +213,7 @@ static int tool_add(const char *args, struct sp_buf *out, void *ctx) { return 0; } -static int tool_list(const char *args, struct sp_buf *out, void *ctx) { +static int tool_list_locked(const char *args, struct sp_buf *out, void *ctx) { size_t i; (void)args;(void)ctx; ensure_dir(); load_tasks(); if(ntasks==0) return sp_buf_puts(out,"(no plan tasks) use plan_task_add\n"); sp_buf_puts(out,"plan tasks (session-persistent):\n"); @@ -206,7 +227,7 @@ static int tool_list(const char *args, struct sp_buf *out, void *ctx) { return 0; } -static int tool_update(const char *args, struct sp_buf *out, void *ctx) { +static int tool_update_locked(const char *args, struct sp_buf *out, void *ctx) { char ids[32], st[24], desc[PT_DESC], ra[64], note[256]; int id; struct ptask *t; (void)ctx; ensure_dir(); load_tasks(); ids[0]=st[0]=desc[0]=ra[0]=note[0]='\0'; @@ -240,13 +261,13 @@ static void mark_doing(struct ptask *t){ else current_id=-1; } -static int cmd_tasks(struct sp_host *h, const char *args, struct sp_buf *out, void *ctx){ +static int cmd_tasks_locked(struct sp_host *h, const char *args, struct sp_buf *out, void *ctx){ (void)ctx; host_ref=h; ensure_dir(); load_tasks(); - if(!args||!*args||strcmp(args,"ls")==0||strcmp(args,"list")==0) return tool_list(NULL,out,NULL); + if(!args||!*args||strcmp(args,"ls")==0||strcmp(args,"list")==0) return tool_list_locked(NULL,out,NULL); if(strncmp(args,"add ",4)==0){ struct sp_buf a; if(sp_buf_init(&a)!=0) return -1; sp_buf_printf(&a,"{\"description\":\"%s\"}", args+4); - { int rc=tool_add(a.p,out,NULL); sp_buf_free(&a); return rc; } + { int rc=tool_add_locked(a.p,out,NULL); sp_buf_free(&a); return rc; } } if(strncmp(args,"work",4)==0){ const char *p=args+4; while(*p==' ') p++; @@ -311,7 +332,7 @@ static int cmd_tasks(struct sp_host *h, const char *args, struct sp_buf *out, vo return sp_buf_puts(out,"usage: /tasks [ls|add |work |work all|choose|next|done [id]|wait <+secs|epoch> [note]]\n"); } -static int tick(struct sp_host *h, const char *name, void *c){ +static int tick_locked(struct sp_host *h, const char *name, void *c){ long now = (long)time(NULL); size_t i; int changed=0; (void)name;(void)c; host_ref=h; ensure_dir(); load_tasks(); for(i=0;isplinter_

An agent harness you own: chat in the terminal, tools with authorization classes, plugins, any model that speaks OpenAI — built by us so we can change it, instead of getting used to how somebody else's client behaves.

-

23769 lines of C99/POSIX · +

23845 lines of C99/POSIX · 23 tools · 31 test programs · 16 plugins · 42 palettes · BSD-3-Clause

diff --git a/src/www/index.html b/src/www/index.html index 09f097b..06abbc8 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }

splinter_

Ein Agent-Harness, das dir gehoert: Chat im Terminal, Werkzeuge mit Autorisierungsklassen, Plugins, jedes Modell das OpenAI spricht — von uns gebaut, damit wir es umbauen koennen, statt uns an das Verhalten eines fremden Clients zu gewoehnen.

-

23769 Zeilen C99/POSIX · +

23845 Zeilen C99/POSIX · 23 Werkzeuge · 31 Test-Programme · 16 Plugins · 42 Farbschemata · BSD-3-Clause

diff --git a/src/www/index.pt.html b/src/www/index.pt.html index e335f05..a6d074b 100644 --- a/src/www/index.pt.html +++ b/src/www/index.pt.html @@ -53,7 +53,7 @@ hr { border: 0; border-top: 1px solid #1d2126; margin: 3em 0 1.5em 0; }

splinter_

Um harness de agente que e seu: chat no terminal, ferramentas com classes de autorizacao, plugins, qualquer modelo que fale OpenAI - escrito por nos para poder mudar-lo, em vez de nos acostumar com o comportamento de um cliente alheio.

-

23769 linhas C99/POSIX · +

23845 linhas C99/POSIX · 23 ferramentas · 31 programas de teste · 16 plugins · 42 paletas · BSD-3-Clause