Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:23blocks OS Ai maestro Use Agent Board Hook

From Leeroopedia
Knowledge Sources
Domains UI, Task_Management
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete tool for fetching one agent's board — own cards, project cards across hosts, and shared cards with co-owners — with dedup and 5-second polling, provided by AI Maestro's `hooks/useAgentBoard.ts`.

Description

The useAgentBoard hook fetches one agent's kanban board. It calls the agent's host (`/api/agents/<id>/board`), then fetches project cards across all hosts (a project is stored on its owner's host, which may not be the agent's), and shared cards where the agent is a co-owner (via `fetchSharedCards`, passing name aliases so a host that does not know the agent can still match by name). Duplicate cards from multiple sources are deduplicated (`dedupeCards`), with the board's own copy first. The hook polls every 5 seconds. CRUD operations (`createTask`, `updateTask`, `deleteTask`, `addComment`) route through the correct host API based on the card's scope and origin.

Usage

Call with `agentId`, optional `hostUrl`, `hosts` list, and `aliases`. Read `tasks` (BoardCard[]), `loading`, `error`. Use the returned CRUD functions which route to the right host.

Code Reference

Source Location

  • Repository: ai-maestro
  • File: hooks/useAgentBoard.ts
  • Lines: L1-L146

Signature

export type BoardCard = TaskWithDeps & { hostBase?: string }

export function useAgentBoard(
  agentId: string | null,
  hostUrl?: string,
  hosts?: Host[],
  aliases?: string[]
): {
  tasks: BoardCard[]
  loading: boolean
  error: string | null
  createTask: (data: { subject: string; description?: string; blockedBy?: string[]; priority?: number }) => Promise<void>
  updateTask: (task: BoardCard, updates: TaskUpdates) => Promise<void>
  deleteTask: (task: BoardCard) => Promise<void>
  addComment: (task: BoardCard, text: string) => Promise<CommentResult>
}

Import

import { useAgentBoard } from '@/hooks/useAgentBoard'

I/O Contract

Inputs

Name Type Required Description
agentId null Yes Agent whose board to fetch
hostUrl string No Host URL where the agent lives (default: this host)
hosts Host[] No All hosts for project/shared card fan-out
aliases string[] No Name aliases for co-owner matching

Outputs

Name Type Description
tasks BoardCard[] Deduplicated cards (own + project + shared)
loading boolean True during fetch
error null Error message

Usage Examples

Render an agent's board

import { useAgentBoard } from '@/hooks/useAgentBoard'

function AgentBoard({ agentId, hosts }) {
  const { tasks, loading, error } = useAgentBoard(agentId, '', hosts, ['website'])
  if (loading) return <p>Loading…</p>
  if (error) return <p>{error}</p>
  return tasks.map(t => <Card key={t.id} task={t} />)
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment