Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

811 B
Raw Blame
// Host-owned example. index.html does not load this file.
// Assign it before the page module runs:
// globalThis.FableLoomPlayer = { resolveTurn: globalThis.FableLoomHostResolverExample };
globalThis.FableLoomHostResolverExample = async function resolveTurn(nodeId, message) {
  const response = await globalThis.fetch('/story/turn', {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({ nodeId, message }),
  });
  if (!response.ok) return { stay: 'The host did not answer.' };
  const body = await response.json();
  if (body && body.action === 'move' && typeof body.transitionId === 'string') {
    return { move: body.transitionId };
  }
  const narration = body && typeof body.narration === 'string' ? body.narration : '';
  return { stay: narration };
};