@g9tm/aiassistant
The headless client of the G9 AI assistant: everything a screen needs, with no DOM, no framework and no runtime dependency. The Svelte and ReactLynx packages draw it; a host can draw it with anything else.
- An API client for the assistant's HTTP endpoints, over the host's own
fetch, so sign-in, headers and base address stay the host's. - Run state: conversations, messages, the work card, plans waiting for confirmation (one confirmation in flight at a time), questions, attachments and the assistant's mode, as one snapshot to subscribe to.
- Transports: a stream when the host gives an
EventSource, long polling otherwise, or a synchronous answer; it falls back to polling by itself. - View models for blocks (tables, charts, KPIs, comparisons), safe text with links limited to the host's own hosts, transcripts, and Persian helpers (digits, numbers, direction).
@g9tm/aiassistant/admin: readers for the manager's pages (capabilities, usage, calls, timelines, usage windows).
import { createAssistant } from "@g9tm/aiassistant";
import type { AssistantHost } from "@g9tm/aiassistant";
const host: AssistantHost = {
locale: "en",
dir: "ltr",
theme: { mode: "light", tokens: {} },
reducedMotion: false,
async fetch(input, init) {
const r = await fetch(input, { method: init?.method ?? "GET", headers: init?.headers, body: init?.body as BodyInit | undefined });
return { status: r.status, ok: r.ok, text: () => r.text() };
},
};
const assistant = createAssistant(host);
const stop = assistant.subscribe((s) => console.log(s.busy, s.messages.length));
await assistant.send("Sales of last week?");
stop();
Part of the G9 AI assistant library. Documentation: see the guides that ship with the library.