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 to | 1 | /** |
| 2 | * Agents as stored in D1, and their spend. Shared by the RPC methods and | |
| 3 | * the desk. | |
| 4 | */ | |
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 5 | import type { AgentAbilities, SubagentDef, WorkspaceAgent } from "@g1t/contracts"; |
| Chat and workspace agents: channels, DMs and named agents you talk to | 6 | |
| 7 | import { agentStatus, budgetBlock, dayKey, monthKey } from "./budget.ts"; | |
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 8 | import { EMPTY_ABILITIES } from "../../../packages/contracts/src/abilities.ts"; |
| Agents have faces, and are never mistaken for people. Every agent wears a little bot face drawn from a look it owns, shape, colour, eyes, mouth, antenna, accessory and pattern, chosen in its builder and on its Profile tab with a live preview, Shuffle and a way back to the face its seed gives it; the face blinks on its own time, breathes, narrows its eyes while the agent works, shuts them asleep and bounces when it finishes, all of it still for anyone who asked for less motion. Wherever an agent shows, in chat, in a list, on a mention, on a review or a commit, its avatar carries an agent marker, and the people reading it are told so. In Chat, direct messages are two lists: People, and Agents, which also holds the agents you haven't talked to yet; a conversation with both a person and an agent in it is marked in the list, named in the conversation's header, spelled out by the composer and explained once the first time it opens. Agents keep their look in the agents service, which every service passes along. The chat and agents guides say so, and CONTRIBUTING makes the shared avatar the only way to draw an agent. | 9 | import { readLook } from "../../../packages/contracts/src/agent-look.ts"; |
| An agent is on teams the way a person is: through team membership, with no team or department of its own. Add it to teams when you create it, from its profile or from the team's page; the Agents sidebar groups agents by the teams they're on, with those on none last; what an agent is told about its teammates, team budgets, skills reach, Spend's By team and the People pages all read memberships. Agents with an old team name matching a team are moved onto it once; the rest are left off a team. Templates name a role only. The agents, teams and people guides say how. | 10 | import { type Definition, DEFAULT_AUTONOMY, DEFAULT_BUDGET, DEFAULT_ROUTING, legacyRoleOf, PRESETS, readJson } from "./definition.ts"; |
| Chat and workspace agents: channels, DMs and named agents you talk to | 11 | |
| 12 | export type Row = { | |
| 13 | id: string; | |
| 14 | workspace_id: string; | |
| 15 | handle: string; | |
| 16 | display_name: string; | |
| 17 | avatar: string | null; | |
| 18 | role: string; | |
| 19 | instructions: string; | |
| 20 | personality_preset: string; | |
| 21 | personality: string; | |
| 22 | routing: string; | |
| 23 | budget: string; | |
| 24 | autonomy: string; | |
| 25 | capacity: number; | |
| 26 | template: string | null; | |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 27 | avatar_seed: string | null; |
| Agents have faces, and are never mistaken for people. Every agent wears a little bot face drawn from a look it owns, shape, colour, eyes, mouth, antenna, accessory and pattern, chosen in its builder and on its Profile tab with a live preview, Shuffle and a way back to the face its seed gives it; the face blinks on its own time, breathes, narrows its eyes while the agent works, shuts them asleep and bounces when it finishes, all of it still for anyone who asked for less motion. Wherever an agent shows, in chat, in a list, on a mention, on a review or a commit, its avatar carries an agent marker, and the people reading it are told so. In Chat, direct messages are two lists: People, and Agents, which also holds the agents you haven't talked to yet; a conversation with both a person and an agent in it is marked in the list, named in the conversation's header, spelled out by the composer and explained once the first time it opens. Agents keep their look in the agents service, which every service passes along. The chat and agents guides say so, and CONTRIBUTING makes the shared avatar the only way to draw an agent. | 28 | /** Its chosen face (JSON, @g1t/contracts agent-look.ts); null or missing before looks. */ |
| 29 | look?: string | null; | |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 30 | title: string | null; |
| An agent is on teams the way a person is: through team membership, with no team or department of its own. Add it to teams when you create it, from its profile or from the team's page; the Agents sidebar groups agents by the teams they're on, with those on none last; what an agent is told about its teammates, team budgets, skills reach, Spend's By team and the People pages all read memberships. Agents with an old team name matching a team are moved onto it once; the rest are left off a team. Templates name a role only. The agents, teams and people guides say how. | 31 | /** |
| 32 | * Unused columns from when an agent carried its own team and department. | |
| 33 | * Teams are memberships in identity now; `team` is read once, by the move | |
| 34 | * to them (team-move.ts), and `role` made from them follows the title. | |
| 35 | */ | |
| 36 | team?: string | null; | |
| 37 | department?: string | null; | |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 38 | responsibilities: string | null; |
| 39 | subagents: string | null; | |
| 40 | faces: string | null; | |
| Agents recall what Docs say before they answer or work, and each has required reading | 41 | reading?: string | null; |
| Every agent starts with g1t's foundational skills, playbooks for documents, research, data, code, communication, and files and media, each using only tools the agent already has and saying plainly what isn't possible yet: agents make PDFs, Word documents, spreadsheets, CSV and Markdown files with make_file, kept with a doc in Artifacts and served from g1tusercontent.com; an agent's Skills tab shows what each skill can do and with which tools, and owners turn a skill off per agent; the agent skills guide says how. | 42 | skills_off?: string | null; |
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 43 | /** Its abilities (JSON); missing before abilities. */ |
| 44 | abilities?: string | null; | |
| Chat and workspace agents: channels, DMs and named agents you talk to | 45 | version: number; |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 46 | /** 1 for the workspace's built-in @g1t. */ |
| 47 | builtin: number; | |
| Anyone makes an agent by describing it: one box drafts the whole agent (name, job, responsibilities, voice, skills to keep, integrations it needs, model limits and budget) as a card to change and try in a chat beside it before creating it, and an agent changes later by saying what to change, shown as a diff before it's saved. Members can make personal agents, which only they talk to and which spend from their own budget, unless owners turn that off; owners promote one to a workspace agent. The agents guide says how. | 48 | /** `workspace`, or `personal` (a member's own); missing before personal agents. */ |
| 49 | scope?: string | null; | |
| 50 | /** A personal agent's member: user id and username. */ | |
| 51 | owner_id?: string | null; | |
| 52 | owner_username?: string | null; | |
| Chat and workspace agents: channels, DMs and named agents you talk to | 53 | busy_until: string | null; |
| 54 | created_by: string; | |
| 55 | created_at: string; | |
| 56 | updated_at: string; | |
| 57 | archived_at: string | null; | |
| 58 | /** Joined from agent_spend: this month and today. */ | |
| 59 | spent_month?: number | null; | |
| 60 | spent_day?: number | null; | |
| 61 | }; | |
| 62 | ||
| 63 | /** | |
| 64 | * Agents with this month's and today's spend: `where` filters `agents` | |
| 65 | * (aliased `a`); its parameters follow the two periods. | |
| 66 | */ | |
| 67 | export function selectAgents(where: string): string { | |
| 68 | return `SELECT a.*, m.micros AS spent_month, d.micros AS spent_day FROM agents a | |
| 69 | LEFT JOIN agent_spend m ON m.agent_id = a.id AND m.period = ?1 | |
| 70 | LEFT JOIN agent_spend d ON d.agent_id = a.id AND d.period = ?2 | |
| 71 | WHERE ${where}`; | |
| 72 | } | |
| 73 | ||
| 74 | export function periods(now: Date): [string, string] { | |
| 75 | return [monthKey(now), dayKey(now)]; | |
| 76 | } | |
| 77 | ||
| 78 | export function definitionOf(row: Row): Definition { | |
| An agent is on teams the way a person is: through team membership, with no team or department of its own. Add it to teams when you create it, from its profile or from the team's page; the Agents sidebar groups agents by the teams they're on, with those on none last; what an agent is told about its teammates, team budgets, skills reach, Spend's By team and the People pages all read memberships. Agents with an old team name matching a team are moved onto it once; the rest are left off a team. Templates name a role only. The agents, teams and people guides say how. | 79 | const title = row.title ?? ""; |
| 80 | // A role made from the title and its old team or department is the title alone. | |
| 81 | const made = (row.team || row.department?.trim()) && row.role === legacyRoleOf(title, row.team ?? null, row.department ?? null); | |
| Chat and workspace agents: channels, DMs and named agents you talk to | 82 | return { |
| 83 | handle: row.handle, | |
| 84 | display_name: row.display_name, | |
| An agent is on teams the way a person is: through team membership, with no team or department of its own. Add it to teams when you create it, from its profile or from the team's page; the Agents sidebar groups agents by the teams they're on, with those on none last; what an agent is told about its teammates, team budgets, skills reach, Spend's By team and the People pages all read memberships. Agents with an old team name matching a team are moved onto it once; the rest are left off a team. Templates name a role only. The agents, teams and people guides say how. | 85 | role: made && title.trim() ? title.trim() : row.role, |
| Chat and workspace agents: channels, DMs and named agents you talk to | 86 | instructions: row.instructions, |
| 87 | personality_preset: PRESETS.includes(row.personality_preset as Definition["personality_preset"]) | |
| 88 | ? (row.personality_preset as Definition["personality_preset"]) | |
| 89 | : "crisp", | |
| 90 | personality: row.personality, | |
| 91 | routing: readJson(row.routing, DEFAULT_ROUTING), | |
| 92 | budget: readJson(row.budget, DEFAULT_BUDGET), | |
| 93 | autonomy: readJson(row.autonomy, DEFAULT_AUTONOMY), | |
| 94 | capacity: row.capacity, | |
| 95 | template: row.template, | |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 96 | avatar_seed: row.avatar_seed || row.handle, |
| Agents have faces, and are never mistaken for people. Every agent wears a little bot face drawn from a look it owns, shape, colour, eyes, mouth, antenna, accessory and pattern, chosen in its builder and on its Profile tab with a live preview, Shuffle and a way back to the face its seed gives it; the face blinks on its own time, breathes, narrows its eyes while the agent works, shuts them asleep and bounces when it finishes, all of it still for anyone who asked for less motion. Wherever an agent shows, in chat, in a list, on a mention, on a review or a commit, its avatar carries an agent marker, and the people reading it are told so. In Chat, direct messages are two lists: People, and Agents, which also holds the agents you haven't talked to yet; a conversation with both a person and an agent in it is marked in the list, named in the conversation's header, spelled out by the composer and explained once the first time it opens. Agents keep their look in the agents service, which every service passes along. The chat and agents guides say so, and CONTRIBUTING makes the shared avatar the only way to draw an agent. | 97 | look: readLook(row.look ?? null), |
| An agent is on teams the way a person is: through team membership, with no team or department of its own. Add it to teams when you create it, from its profile or from the team's page; the Agents sidebar groups agents by the teams they're on, with those on none last; what an agent is told about its teammates, team budgets, skills reach, Spend's By team and the People pages all read memberships. Agents with an old team name matching a team are moved onto it once; the rest are left off a team. Templates name a role only. The agents, teams and people guides say how. | 98 | title, |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 99 | responsibilities: readList<string>(row.responsibilities), |
| 100 | subagents: readList<SubagentDef>(row.subagents), | |
| 101 | faces: "internal", | |
| Agents recall what Docs say before they answer or work, and each has required reading | 102 | reading: readList<string>(row.reading ?? null), |
| Every agent starts with g1t's foundational skills, playbooks for documents, research, data, code, communication, and files and media, each using only tools the agent already has and saying plainly what isn't possible yet: agents make PDFs, Word documents, spreadsheets, CSV and Markdown files with make_file, kept with a doc in Artifacts and served from g1tusercontent.com; an agent's Skills tab shows what each skill can do and with which tools, and owners turn a skill off per agent; the agent skills guide says how. | 103 | skills_off: readList<string>(row.skills_off ?? null), |
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 104 | abilities: abilitiesRead(row.abilities ?? null), |
| Chat and workspace agents: channels, DMs and named agents you talk to | 105 | }; |
| 106 | } | |
| 107 | ||
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 108 | /** A stored abilities column, read defensively: settings by id and the MCP servers, each a list or an object or nothing. */ |
| 109 | function abilitiesRead(raw: string | null): AgentAbilities { | |
| 110 | const read = readJson<Partial<AgentAbilities>>(raw, {}); | |
| 111 | return { | |
| 112 | settings: read.settings && typeof read.settings === "object" && !Array.isArray(read.settings) ? read.settings : {}, | |
| 113 | mcp_servers: Array.isArray(read.mcp_servers) ? read.mcp_servers : EMPTY_ABILITIES.mcp_servers, | |
| 114 | }; | |
| 115 | } | |
| 116 | ||
| Chat and workspace agents: channels, DMs and named agents you talk to | 117 | export function toAgent(row: Row, now: Date): WorkspaceAgent { |
| 118 | const definition = definitionOf(row); | |
| 119 | const spent = { month: row.spent_month ?? 0, day: row.spent_day ?? 0 }; | |
| 120 | return { | |
| 121 | id: row.id, | |
| 122 | workspace_id: row.workspace_id, | |
| 123 | avatar: row.avatar, | |
| 124 | ...definition, | |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 125 | builtin: !!row.builtin, |
| Anyone makes an agent by describing it: one box drafts the whole agent (name, job, responsibilities, voice, skills to keep, integrations it needs, model limits and budget) as a card to change and try in a chat beside it before creating it, and an agent changes later by saying what to change, shown as a diff before it's saved. Members can make personal agents, which only they talk to and which spend from their own budget, unless owners turn that off; owners promote one to a workspace agent. The agents guide says how. | 126 | scope: isPersonal(row) ? "personal" : "workspace", |
| 127 | personal_owner_id: isPersonal(row) ? (row.owner_id ?? null) : null, | |
| 128 | personal_owner: isPersonal(row) ? (row.owner_username ?? null) : null, | |
| Chat and workspace agents: channels, DMs and named agents you talk to | 129 | version: row.version, |
| 130 | status: row.archived_at ? "paused" : agentStatus({ busyUntil: row.busy_until, now, blocked: budgetBlock(definition.budget, spent, now) !== null }), | |
| 131 | spent_month_micros: spent.month, | |
| 132 | created_by: row.created_by, | |
| 133 | created_at: row.created_at, | |
| 134 | updated_at: row.updated_at, | |
| 135 | archived_at: row.archived_at, | |
| 136 | }; | |
| 137 | } | |
| 138 | ||
| Anyone makes an agent by describing it: one box drafts the whole agent (name, job, responsibilities, voice, skills to keep, integrations it needs, model limits and budget) as a card to change and try in a chat beside it before creating it, and an agent changes later by saying what to change, shown as a diff before it's saved. Members can make personal agents, which only they talk to and which spend from their own budget, unless owners turn that off; owners promote one to a workspace agent. The agents guide says how. | 139 | /** Whether a row is a member's personal agent. */ |
| 140 | export function isPersonal(row: Pick<Row, "scope">): boolean { | |
| 141 | return row.scope === "personal"; | |
| 142 | } | |
| 143 | ||
| Agents work in sessions: bounded, visible, steerable work spun off from chat, with subagents and colleagues in a tree paid by its root; memory with sources and scopes; routines; a workspace budget for every agent; agents file issues for whoever asked | 144 | /** |
| 145 | * Adds a charge to the paying agent's month and day: a reply's, or a | |
| 146 | * session step's (`task`), counted as one of each. | |
| 147 | */ | |
| 148 | export function spendStatements(db: D1Database, agentId: string, micros: number, now: Date, task: "reply" | "session" = "reply"): D1PreparedStatement[] { | |
| 149 | const [replies, sessions] = task === "reply" ? [1, 0] : [0, 1]; | |
| Chat and workspace agents: channels, DMs and named agents you talk to | 150 | return periods(now).map((period) => |
| 151 | db | |
| 152 | .prepare( | |
| Agents work in sessions: bounded, visible, steerable work spun off from chat, with subagents and colleagues in a tree paid by its root; memory with sources and scopes; routines; a workspace budget for every agent; agents file issues for whoever asked | 153 | `INSERT INTO agent_spend (agent_id, period, micros, replies, sessions) VALUES (?1, ?2, ?3, ?4, ?5) |
| 154 | ON CONFLICT (agent_id, period) DO UPDATE SET micros = micros + ?3, replies = replies + ?4, sessions = sessions + ?5`, | |
| Chat and workspace agents: channels, DMs and named agents you talk to | 155 | ) |
| Agents work in sessions: bounded, visible, steerable work spun off from chat, with subagents and colleagues in a tree paid by its root; memory with sources and scopes; routines; a workspace budget for every agent; agents file issues for whoever asked | 156 | .bind(agentId, period, Math.max(0, Math.ceil(micros)), replies, sessions), |
| Chat and workspace agents: channels, DMs and named agents you talk to | 157 | ); |
| 158 | } | |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 159 | |
| 160 | /** A stored JSON list, read defensively: anything else is empty. */ | |
| 161 | function readList<T>(raw: string | null): T[] { | |
| 162 | if (!raw) return []; | |
| 163 | try { | |
| 164 | const parsed = JSON.parse(raw) as unknown; | |
| 165 | return Array.isArray(parsed) ? (parsed as T[]) : []; | |
| 166 | } catch { | |
| 167 | return []; | |
| 168 | } | |
| 169 | } | |
| 170 | ||
| 171 | /** | |
| 172 | * The agents table's definition columns, in the order `definitionColumns` | |
| 173 | * gives their values. Statements are built from this one list, so a new | |
| 174 | * field is added in one place. | |
| 175 | */ | |
| 176 | export const DEFINITION_COLUMNS = [ | |
| 177 | "handle", | |
| 178 | "display_name", | |
| 179 | "role", | |
| 180 | "instructions", | |
| 181 | "personality_preset", | |
| 182 | "personality", | |
| 183 | "routing", | |
| 184 | "budget", | |
| 185 | "autonomy", | |
| 186 | "capacity", | |
| 187 | "template", | |
| 188 | "avatar_seed", | |
| Agents have faces, and are never mistaken for people. Every agent wears a little bot face drawn from a look it owns, shape, colour, eyes, mouth, antenna, accessory and pattern, chosen in its builder and on its Profile tab with a live preview, Shuffle and a way back to the face its seed gives it; the face blinks on its own time, breathes, narrows its eyes while the agent works, shuts them asleep and bounces when it finishes, all of it still for anyone who asked for less motion. Wherever an agent shows, in chat, in a list, on a mention, on a review or a commit, its avatar carries an agent marker, and the people reading it are told so. In Chat, direct messages are two lists: People, and Agents, which also holds the agents you haven't talked to yet; a conversation with both a person and an agent in it is marked in the list, named in the conversation's header, spelled out by the composer and explained once the first time it opens. Agents keep their look in the agents service, which every service passes along. The chat and agents guides say so, and CONTRIBUTING makes the shared avatar the only way to draw an agent. | 189 | "look", |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 190 | "title", |
| 191 | "responsibilities", | |
| 192 | "subagents", | |
| 193 | "faces", | |
| Agents recall what Docs say before they answer or work, and each has required reading | 194 | "reading", |
| Every agent starts with g1t's foundational skills, playbooks for documents, research, data, code, communication, and files and media, each using only tools the agent already has and saying plainly what isn't possible yet: agents make PDFs, Word documents, spreadsheets, CSV and Markdown files with make_file, kept with a doc in Artifacts and served from g1tusercontent.com; an agent's Skills tab shows what each skill can do and with which tools, and owners turn a skill off per agent; the agent skills guide says how. | 195 | "skills_off", |
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 196 | "abilities", |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 197 | ] as const; |
| 198 | ||
| 199 | /** A definition's values, in `DEFINITION_COLUMNS` order. */ | |
| 200 | export function definitionColumns(d: Definition): (string | number | null)[] { | |
| 201 | return [ | |
| 202 | d.handle, | |
| 203 | d.display_name, | |
| 204 | d.role, | |
| 205 | d.instructions, | |
| 206 | d.personality_preset, | |
| 207 | d.personality, | |
| 208 | JSON.stringify(d.routing), | |
| 209 | JSON.stringify(d.budget), | |
| 210 | JSON.stringify(d.autonomy), | |
| 211 | d.capacity, | |
| 212 | d.template, | |
| 213 | d.avatar_seed, | |
| Agents have faces, and are never mistaken for people. Every agent wears a little bot face drawn from a look it owns, shape, colour, eyes, mouth, antenna, accessory and pattern, chosen in its builder and on its Profile tab with a live preview, Shuffle and a way back to the face its seed gives it; the face blinks on its own time, breathes, narrows its eyes while the agent works, shuts them asleep and bounces when it finishes, all of it still for anyone who asked for less motion. Wherever an agent shows, in chat, in a list, on a mention, on a review or a commit, its avatar carries an agent marker, and the people reading it are told so. In Chat, direct messages are two lists: People, and Agents, which also holds the agents you haven't talked to yet; a conversation with both a person and an agent in it is marked in the list, named in the conversation's header, spelled out by the composer and explained once the first time it opens. Agents keep their look in the agents service, which every service passes along. The chat and agents guides say so, and CONTRIBUTING makes the shared avatar the only way to draw an agent. | 214 | d.look ? JSON.stringify(d.look) : null, |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 215 | d.title, |
| 216 | JSON.stringify(d.responsibilities), | |
| 217 | JSON.stringify(d.subagents), | |
| 218 | d.faces, | |
| Agents recall what Docs say before they answer or work, and each has required reading | 219 | JSON.stringify(d.reading ?? []), |
| Every agent starts with g1t's foundational skills, playbooks for documents, research, data, code, communication, and files and media, each using only tools the agent already has and saying plainly what isn't possible yet: agents make PDFs, Word documents, spreadsheets, CSV and Markdown files with make_file, kept with a doc in Artifacts and served from g1tusercontent.com; an agent's Skills tab shows what each skill can do and with which tools, and owners turn a skill off per agent; the agent skills guide says how. | 220 | JSON.stringify(d.skills_off ?? []), |
| Each agent has an Abilities tab: g1t's built-ins, always on within the asker's access; its computer, coming; each connected integration's actions one row each, read, import, comment or resolve, with a level for each, alone, alone when the person asked for it, ask first or never, and whose connection it runs on; and MCP servers an owner adds. Reading is alone, writing inside g1t follows today's choices, anything that leaves g1t asks first, and production deploys can't go above ask. The agents service enforces every level: ask first posts a card to allow or deny and parks a session until it's answered, a refusal names its rule in the transcript and the audit log, and a missing ability posts a request to owners. The agent abilities guide says how. | 221 | JSON.stringify(d.abilities ?? EMPTY_ABILITIES), |
| Merge the workspace shell: navigation and phone shell, g1t as orchestrator, agents in roles with audience-checked reads, reactions and custom emoji, live notifications and browser push, the homepage tour (agents 0002, chat 0002) | 222 | ]; |
| 223 | } | |
| 224 | ||
| 225 | /** | |
| 226 | * A new agent row: `id`, `workspace_id`, the definition, then `extra` | |
| 227 | * columns (version, builtin, who made it, when), all bound in order. | |
| 228 | */ | |
| 229 | export function insertAgent(db: D1Database, id: string, workspaceId: string, d: Definition, extra: Record<string, string | number>, orIgnore = false): D1PreparedStatement { | |
| 230 | const names = ["id", "workspace_id", ...DEFINITION_COLUMNS, ...Object.keys(extra)]; | |
| 231 | const values = [id, workspaceId, ...definitionColumns(d), ...Object.values(extra)]; | |
| 232 | return db | |
| 233 | .prepare(`INSERT ${orIgnore ? "OR IGNORE " : ""}INTO agents (${names.join(", ")}) VALUES (${names.map(() => "?").join(", ")})`) | |
| 234 | .bind(...values); | |
| 235 | } | |
| 236 | ||
| 237 | /** Sets a row's definition, from the version read only, with `extra` columns. */ | |
| 238 | export function updateAgent(db: D1Database, id: string, readVersion: number, d: Definition, extra: Record<string, string | number>): D1PreparedStatement { | |
| 239 | const names = [...DEFINITION_COLUMNS, ...Object.keys(extra)]; | |
| 240 | return db | |
| 241 | .prepare(`UPDATE agents SET ${names.map((name) => `${name} = ?`).join(", ")} WHERE id = ? AND version = ?`) | |
| 242 | .bind(...definitionColumns(d), ...Object.values(extra), id, readVersion); | |
| 243 | } | |
| 244 | ||
| 245 | /** A version of a definition, as saved. */ | |
| 246 | export function versionStatement(db: D1Database, agentId: string, version: number, d: Definition, by: string, at: string): D1PreparedStatement { | |
| 247 | return db | |
| 248 | .prepare("INSERT INTO agent_versions (agent_id, version, definition, changed_by, created_at) VALUES (?, ?, ?, ?, ?)") | |
| 249 | .bind(agentId, version, JSON.stringify(d), by, at); | |
| 250 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.