Skip to content
33 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 to1/**
2 * An agent's handle: how it is mentioned (`@ship`). Pure, so it is tested
3 * on its own.
4 *
5 * Lowercase letters, digits and hyphens, 2 to 32 characters, with no
6 * leading, trailing or doubled hyphen (the same shape as a username, so a
7 * mention reads the same for both). Never a name nobody may register:
8 * `g1t` is the platform's own agent, and routes such as `settings` would
9 * read as links.
10 */
11import { isReservedName } from "../../../packages/contracts/src/names.ts";
12
13/**
14 * Handles the site's agent pages would read as their own routes
The Marketplace adds what g1t doesn't do and connects what you already use: extensions (Mail, Support, CRM, Recruiting, On-call, and bridges to a helpdesk, CRM or ERP you run, all Soon), starter kits, and integrations connected by the workspace or by each person; agents aren't installed there. Agent templates live in Agents, as starting points you configure, at Agents → Templates, and the Marketplace's old agent addresses lead there. The marketplace and agents guides say how.15 * (`/<workspace>/-/agents/new`, `…/templates`, `…/runs`, `…/fleet`),
16 * besides the names nobody may register.
Chat and workspace agents: channels, DMs and named agents you talk to17 */
The Marketplace adds what g1t doesn't do and connects what you already use: extensions (Mail, Support, CRM, Recruiting, On-call, and bridges to a helpdesk, CRM or ERP you run, all Soon), starter kits, and integrations connected by the workspace or by each person; agents aren't installed there. Agent templates live in Agents, as starting points you configure, at Agents → Templates, and the Marketplace's old agent addresses lead there. The marketplace and agents guides say how.18const ROUTES = new Set(["new", "templates", "runs", "fleet"]);
Chat and workspace agents: channels, DMs and named agents you talk to19
20const HANDLE = /^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){1,31}$/;
21
22export const HANDLE_RULE = "A handle is 2 to 32 lowercase letters, digits and single hyphens, starting and ending with a letter or digit.";
23
24export type HandleCheck = { ok: true; handle: string } | { ok: false; message: string };
25
26/** `value` as a handle (trimmed, lowercased, a leading `@` dropped), or why it cannot be one. */
27export function checkHandle(value: unknown): HandleCheck {
28 if (typeof value !== "string") return { ok: false, message: HANDLE_RULE };
29 const handle = value.trim().replace(/^@/, "").toLowerCase();
30 if (!HANDLE.test(handle)) return { ok: false, message: HANDLE_RULE };
31 if (isReservedName(handle) || ROUTES.has(handle)) return { ok: false, message: `@${handle} is reserved. Choose another handle.` };
32 return { ok: true, handle };
33}