xonecas.io
7814
Ta

tiny-c-agent / files

tiny-c-agent / src / headless.h

933 bytes
1// tiny headless projection.
2//
3// Statuses and tool activity go to stderr; the final assistant text goes to
4// stdout, so the output can be piped. Tool bodies (the call arguments) are
5// never printed; tool output is.
6
7#ifndef TINY_HEADLESS_H
8#define TINY_HEADLESS_H
9
10#include <stdbool.h>
11#include <stdio.h>
12
13#include "event.h"
14
15typedef struct {
16    FILE *out;
17    FILE *err;
18    char *text;        // accumulated text of the current assistant message
19    size_t text_len;
20    size_t text_cap;
21    bool failed;
22    bool cancelled;
23    bool no_model;
24} tiny_headless;
25
26void tiny_headless_init(tiny_headless *h, FILE *out, FILE *err);
27
28// Suitable as an agent's on_event callback, with `user` set to the headless.
29void tiny_headless_event(const tiny_event *event, void *user);
30
31// Prints the final text and returns the process exit code.
32int tiny_headless_finish(tiny_headless *h);
33
34void tiny_headless_free(tiny_headless *h);
35
36#endif