You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// frontend/lib/errand/api.ts — 심부름 에이전트 시작·조회
|
|
import type { ErrandTask } from "@/lib/types";
|
|
|
|
const BASE = process.env.NEXT_PUBLIC_API_BASE ?? "http://localhost:31800";
|
|
|
|
export interface ErrandStartBody {
|
|
kind: string;
|
|
title: string;
|
|
goal: string;
|
|
target?: string | null;
|
|
tone?: string | null;
|
|
}
|
|
|
|
export async function listErrands(signal?: AbortSignal): Promise<ErrandTask[]> {
|
|
const res = await fetch(`${BASE}/api/agents/errand`, { signal, cache: "no-store" });
|
|
if (!res.ok) throw new Error(`errand list ${res.status}`);
|
|
return res.json();
|
|
}
|
|
|
|
export async function getErrand(eid: string, signal?: AbortSignal): Promise<ErrandTask> {
|
|
const res = await fetch(`${BASE}/api/agents/errand/${eid}`, { signal, cache: "no-store" });
|
|
if (!res.ok) throw new Error(`errand ${res.status}`);
|
|
return res.json();
|
|
}
|
|
|
|
export async function startErrand(body: ErrandStartBody): Promise<ErrandTask> {
|
|
const res = await fetch(`${BASE}/api/agents/errand`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
});
|
|
if (!res.ok) throw new Error(`errand start ${res.status}`);
|
|
return res.json();
|
|
}
|