@stll/folio-agents
Version:
Framework-neutral LLM tool layer over folio's ai-edits engine: function-calling tools so an agent can read and mutate .docx documents through @stll/folio-core.
23 lines (22 loc) • 1.05 kB
JavaScript
//#region src/bridge.ts
const decodedCommentHandlers = /* @__PURE__ */ new WeakMap();
const registerDecodedCommentHandlers = (bridge, handlers) => {
decodedCommentHandlers.set(bridge, handlers);
return bridge;
};
const getDecodedCommentHandlers = (bridge) => decodedCommentHandlers.get(bridge);
/**
* The document session an operation id is unique within. The reviewer bridge
* registers its reviewer, which holds one document for its lifetime, so a
* host that builds a new bridge per call keeps one session. Any other bridge
* is its own session: a live editor can load another document under the same
* ref, so a host builds one bridge per loaded document.
*/
const operationSessions = /* @__PURE__ */ new WeakMap();
const registerOperationSession = (bridge, session) => {
operationSessions.set(bridge, session);
return bridge;
};
const getOperationSession = (bridge) => operationSessions.get(bridge) ?? bridge;
//#endregion
export { getDecodedCommentHandlers, getOperationSession, registerDecodedCommentHandlers, registerOperationSession };