host: expose harness state and actions over the world API

This commit is contained in:
2026-11-07 19:22:06 +00:00
parent c3c5b36d09
commit 5dc4833e28
33 changed files with 33178 additions and 112 deletions
+7 -1
View File
@@ -30662,6 +30662,7 @@ async function loadExtensions(harness2, registry2, storage2, models2, context, b
for (const { name, module } of modules) {
const facet = scope(name, staged);
next.push(facet);
facet.actions = Object.fromEntries((module.userActions ?? []).filter((key) => typeof module.actions?.[key] === "function").map((key) => [key, module.actions[key]]));
facet.extension = typeof module.default === "function" ? await module.default(facet.host) : module.default;
if (!facet.extension || facet.extension.name !== name) throw new Error(`Extension name must match ${name}`);
}
@@ -30727,7 +30728,12 @@ Last good: ${fallback}` : failed;
if (active) await enqueue2();
}
})();
return { reload: enqueue2, state: () => ({ ...state }), close: async () => {
return { reload: enqueue2, state: () => ({ ...state }), async invoke(name, key, args, signal, conversationId) {
const facet = facets.find((f) => f.extension.name === name);
const action = facet?.actions?.[key];
if (!action) throw Object.assign(new Error("Unknown user action"), { status: 404 });
return action(args, { host: facet.host, signal, conversationId, source: "ui" });
}, close: async () => {
active = false;
Deno.core.close(rid);
await pending;