Files
learnharness/components/artifacts/index.ts
T
Amos df16750560 W2: async job infra + researcher sub-agent
- src/store/jobs.ts: per-job JSON store in data/jobs (create/get/update/list,
  dedup by toolCallId)
- src/agent/tools/jobs.ts: research tool — client-side (no execute), turn ends
  at the call; input per contracts ResearchToolInput
- src/agent/tools/web.ts: server-side web_search (Google CSE) + web_fetch
  (Readability/Turndown/linkedom, Jina fallback) — errors return as strings,
  never thrown into the agent loop. Deps: @mozilla/readability, linkedom,
  turndown (+@types/turndown dev)
- src/agent/subagents/researcher.ts: isolated ToolLoopAgent (web tools only,
  12-step cap), researcher prompt ported from pi
- src/agent/subagents/runner.ts: spawnPendingJobs hook + runResearchJob —
  fire-and-forget, activity line per tool call, fulfills the part in the
  LATEST chat record (output-available) before flipping job status; failure
  still fulfills the part so the teacher learns the outcome
- src/server/chat-handler.ts: onFinish spawn hook after saveMessages
- app/api/jobs/route.ts: GET ?chatId= polling endpoint
- components/artifacts/job-card.tsx + registry entry: polling activity card
  (2s) → syncFromServer on finish; research-brief card (markdown + sources)
- src/agent/prompts/20-jobs.md: research doctrine for the teacher
- tests/jobs.test.ts: store CRUD, spawn hook via scripted mock teacher,
  runner completion/failure with fake model + stubbed fetch
2026-08-22 09:36:15 +03:00

21 lines
872 B
TypeScript

import type { ComponentType } from "react";
import type { ArtifactPartProps } from "@/src/core/contracts";
import { JobCard } from "@/components/artifacts/job-card";
/**
* Artifact renderer registry — the extension point for tool-part UI.
*
* chat.tsx renders any tool part it doesn't specially handle (i.e. not
* quiz/ask) by looking the tool name up here. Add your renderer — do NOT
* edit chat.tsx (see docs/plan.md file-ownership rules).
*
* Typical shape: while the part is input-available render an activity card
* (poll GET /api/jobs?chatId=…; on completion call
* ChatActionsContext.syncFromServer()); when output-available render the
* artifact itself from part.output.
*/
export const artifactRenderers: Record<string, ComponentType<ArtifactPartProps>> = {
research: JobCard,
// W6: "demo" → sandboxed iframe card, "visual" → svg card
};