@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
36 lines • 1.8 kB
JavaScript
/**
* Announce this app's Poppy endpoints to an authorization server in the same process —
* `@adonis-agora/authkit-server` reads this slot when it builds `poppy.json`, so the conversation
* endpoint never has to be repeated in its config
* (`agent.protocols: [{ type: 'poppy', endpoint, description }]`, §3.1, §8.1).
* Like `Symbol.for('@adonis-agora/oauth:resources')` for MCP, the contract is the global symbol:
* neither package imports the other.
*
* @experimental Implements Personal Agent Protocol 1.0 (https://personalagentprotocol.org/docs/1.0/spec).
* The surface may still change between minor releases of this package while it settles.
*/
export const POPPY_ENDPOINTS_SLOT = Symbol.for('@adonis-agora/poppy:endpoints');
/**
* The `description` of the `poppy` entry when the app gives none: 1.0 requires one, and allows it
* to say the agent can help with anything (§8.1).
*/
export const DEFAULT_POPPY_DESCRIPTION = 'Can help with anything.';
/** The absolute conversation endpoint for a public origin and a mount path. */
export function poppyConversationsUrl(baseUrl, path) {
return `${baseUrl.replace(/\/+$/, '')}/${path.replace(/^\/+|\/+$/g, '')}`;
}
/** Merge `endpoints` into the slot, keeping what another package announced. */
export function announcePoppyEndpoints(endpoints) {
const slot = globalThis;
const existing = slot[POPPY_ENDPOINTS_SLOT];
slot[POPPY_ENDPOINTS_SLOT] = {
...(existing && typeof existing === 'object' ? existing : {}),
...endpoints,
};
}
/** What the slot holds now (a copy), or `{}`. */
export function announcedPoppyEndpoints() {
const existing = globalThis[POPPY_ENDPOINTS_SLOT];
return existing && typeof existing === 'object' ? { ...existing } : {};
}
//# sourceMappingURL=endpoints.js.map