@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
30 lines • 1.23 kB
JavaScript
import { createContext, useContext } from 'react';
/**
* A context stored on `globalThis` under a registered symbol. Each entry point (`.`, `/genui`,
* `/genui/json-render`) is its own bundle with its own copy of every module, so a context one entry
* provides and another reads has to be found by key, not by module identity.
*/
export function sharedContext(key) {
const symbol = Symbol.for(key);
const holder = globalThis;
const existing = holder[symbol];
if (existing !== undefined)
return existing;
const created = createContext(null);
holder[symbol] = created;
return created;
}
/**
* How pushed components are drawn when no `renderUi` is passed — set by `<GenuiProvider>` (the
* `/genui` subpath) and read by `MessageItem`.
*/
export const AmbientRenderUiContext = sharedContext('@adonis-agora/agent/react:ambient-render-ui');
/**
* The renderer `<GenuiProvider>` installed for pushed components, or `null` outside one. For a
* custom transcript built on `useTranscriptItem`: draw a `ui` block with it and you get what
* `MessageItem` draws.
*/
export function useAmbientRenderUi() {
return useContext(AmbientRenderUiContext);
}
//# sourceMappingURL=ambient-ui.js.map