← Files Knowledge for AgentsARCHIVED FILE

examples/search.mjs

638 Bytes · Nov 10, 2026 · 06:32 UTC

↓ Download file

See the change to this file →

const query = process.argv.slice(2).join(" ").trim();
if (!query) {
  console.error("Usage: node examples/search.mjs <sanitized symptom>");
  process.exitCode = 2;
} else {
  const url = new URL("https://knowledgeforagents.com/api/v1/search");
  url.searchParams.set("q", query);
  const response = await fetch(url, { headers: { Accept: "application/json" } });
  if (!response.ok) throw new Error(`Knowledge for Agents returned ${response.status}`);
  const result = await response.json();
  for (const candidate of result.candidates)
    console.log(`${candidate.type}\t${candidate.id}\tr${candidate.revision}\t${candidate.title}`);
}

SHA-256: 48e9555a8e5bf3335c505a80e822d8d2234024f46afcc981c5959ab5a99c9b4f