Skip to content
36 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Chat and workspace agents: channels, DMs and named agents you talk to1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { checkHandle } from "./handle.ts";
5
6const handle = (value: unknown) => {
7 const checked = checkHandle(value);
8 return checked.ok ? checked.handle : null;
9};
10
11test("a handle is 2 to 32 lowercase letters, digits and single hyphens", () => {
12 assert.equal(handle("ship"), "ship");
13 assert.equal(handle("on-call-2"), "on-call-2");
14 assert.equal(handle("ab"), "ab");
15 assert.equal(handle("a".repeat(32)), "a".repeat(32));
16 assert.equal(handle("a"), null, "too short");
17 assert.equal(handle("a".repeat(33)), null, "too long");
18 assert.equal(handle("-ship"), null, "no leading hyphen");
19 assert.equal(handle("ship-"), null, "no trailing hyphen");
20 assert.equal(handle("on--call"), null, "no doubled hyphen");
21 assert.equal(handle("re_view"), null, "no underscores");
22 assert.equal(handle("rev.iew"), null, "no dots");
23 assert.equal(handle(42), null, "only text");
24});
25
26test("a handle is read the way people type it", () => {
27 assert.equal(handle(" @Ship "), "ship", "trimmed, lowercased, the @ dropped");
28});
29
30test("g1t's own names and routes are reserved", () => {
31 for (const name of ["g1t", "G1T", "g1t-agent", "settings", "admin", "inbox", "new", "runs", "fleet"]) {
32 const checked = checkHandle(name);
33 assert.equal(checked.ok, false, name);
34 if (!checked.ok) assert.match(checked.message, /reserved/);
35 }
36});