diff options
Diffstat (limited to 'src/goal.h')
| -rw-r--r-- | src/goal.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/goal.h b/src/goal.h new file mode 100644 index 0000000..6ef823d --- /dev/null +++ b/src/goal.h @@ -0,0 +1,53 @@ +#ifndef LLSH_GOAL_H +#define LLSH_GOAL_H + +#include "util.h" + +/* Pure helpers for the /goal goal-based loop (mirrors goal.rs): parse the + * command, build each attempt's prompt, parse the evaluator's verdict. + * Side-effect free; the evaluator's model call lives in the session and the + * iteration loop in main. */ + +#define GOAL_DEFAULT_MAX_TRIES 5UL + +/* Parsed /goal command: success criteria + attempt cap. */ +typedef struct { + char *criteria; /* owned */ + unsigned long max_tries; +} goal_spec; + +/* Evaluator's judgment of a single attempt. reason is owned. */ +typedef struct { + bool met; + char *reason; +} goal_verdict; + +/* Summary of a finished /goal run. criteria is owned. */ +typedef struct { + char *criteria; + unsigned long max_tries; + unsigned long turns_done; + unsigned long long tokens_used; + bool met; +} goal_report; + +void goal_spec_free(goal_spec *s); +void goal_report_free(goal_report *r); + +/* System preamble for the tool-less goal evaluator. */ +const char *goal_evaluator_preamble(void); + +/* Parse "<criteria>[, stop after <N> tries]". + * Returns 1 on success (fills *out), 0 on failure (*err set, caller frees). */ +int goal_parse(const char *input, goal_spec *out, char **err); + +/* Prompt for a goal attempt (attempt starts at 1; feedback may be NULL). + * Caller frees. */ +char *goal_prompt(const goal_spec *spec, unsigned long attempt, + const char *feedback); + +/* Parse the evaluator's reply into a verdict (conservative: met only when + * MET appears and NOT MET does not). Caller frees out->reason. */ +void goal_parse_verdict(const char *reply, goal_verdict *out); + +#endif |