Skip to content
pi-c Documentation
Login

Documentation

/* pic's terminal UI (app.c): plain pic in a terminal. Each request runs as a
 * child `pic --json ask` process and is known only through its JSON events;
 * the journal stays the record, so a UI fault cannot touch a run. */
#ifndef PIC_TUI_H
#define PIC_TUI_H

#include <stddef.h>

typedef struct {
    const char *self;      /* this executable, for the child processes */
    const char *db;        /* journal path */
    const char *workspace;
    const char *model;     /* provider/model */
    const char *default_model; /* the saved default (or pic's own), marked in the picker */
    int exec_seconds;
    long context_window;   /* -1: the model's */
    const char *resume;    /* NULL: a new conversation; "latest" or an id */
    const char *new_id;    /* --session-id naming no conversation yet: the first request creates it under this id */
    int pick;              /* -r: open the conversation picker at start */
    const char *tui_mode;  /* --tui-mode: "fullscreen" or "regular"; NULL: the tuiMode setting */
    const char *theme;     /* --theme: a theme name or "light/dark", for this run; NULL: the theme setting */
    /* Options every child request takes too, as Pi applies them to the whole session. */
    const char *system_replace;       /* --system-prompt; NULL: none */
    const char *const *system_append; /* --append-system-prompt arguments */
    size_t system_nappend;
    const char *tools, *exclude_tools; /* --tools, --exclude-tools; NULL: none */
    int no_tools, no_builtin_tools;    /* --no-tools, --no-builtin-tools */
    const char *key;                   /* --key: the label the model's provider uses this run; NULL: none */
    const char *permission_mode;       /* --permission-mode: the conversation's from its next request; NULL: none */
    int model_named;                   /* --model was given: a conversation taken up keeps this model */
    const char *model_note;            /* under the banner: why this model, or that there is no key; NULL: none */
    /* Answers a command (Pi's RPC JSON, with pic's own commands) in this process, for the
     * conversation SESSION ("" before one) on MODEL: Pi's response object, malloc'd, or NULL.
     * The interface reaches components and core state only through it. */
    char *(*ask)(const char *session, const char *model, const char *line);
} pic_tui_options;

/* Runs until the person quits; 0, or 1 when the terminal could not be used. */
int pic_tui_main(const pic_tui_options *o);

#endif