iterate.com / config-template

git clone https://git.iterate.com/repos/config-template

config-template / tests / agent-kind.test.mjsmain at 3b8ad1b

// tests/agent-kind.test.mjs — the file the Dash loads for the kind `agent`
// (../agent-kinds/agent.ts): what its New agent appends, and that the file runs in a browser's
// frame, where an import is a stub.
// Run it from the repo's root with `node --test "tests/*.test.mjs"`.
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import kind from "../agent-kinds/agent.ts";

test("the Dash's New agent starts the kind `agent`: one keyed start fact at the new path", () => {
  assert.equal(kind.kind, "agent");
  // the Dash starts the kind whose file says so, on its first choice
  assert.equal(kind.newAgent.default, true);
  assert.deepEqual(kind.newAgent.choices, [{ id: "agent", label: "Agent", byPerson: true }]);
  const path = "/agents/people/ada/agent/2026-11-23t10-00-00";
  // the fact that stdlib's agentKindEvent answers with the agent's start facts
  assert.deepEqual(kind.newAgent.start({ choice: "agent", fields: {}, path }), [
    {
      type: "events.iterate.com/agent-ui/agent-requested",
      idempotencyKey: `agent-ui/agent-requested:${path}`,
      payload: {},
    },
  ]);
});

test("the chat is the kit's AgentChat as it is, with the answer's streamed windows", () => {
  const AgentChat = () => null;
  assert.equal(kind.view({ ui: { AgentChat } }), AgentChat);
  assert.deepEqual(kind.ephemeralEvents, ["events.iterate.com/llm-request/response-frame-received"]);
});

test("the file is one the Dash can find and run: it says `default: true` in its text, and imports nothing", () => {
  const source = readFileSync(new URL("../agent-kinds/agent.ts", import.meta.url), "utf8");
  // the Dash gives a frame only to a kind file whose text says so
  assert.match(source, /\bdefault\s*:\s*true\b/);
  assert.doesNotMatch(source, /^\s*import\s/m);
});