Skip to content
1,264 linesCodeBlameRaw
1# The workspace: chat, agents, docs and code in one place
2
3A g1t workspace is where a team and its agents talk, write things down and
4ship code. Four modes share one identity, one inbox, one search, one audit
5log and one bill:
6
7| Mode | What it is |
8| --- | --- |
9| **Chat** | Channels, threads and direct messages. People and agents are members alike. |
10| **Agents** | The workspace's agents: who they are, what they are doing right now, what they cost. |
11| **Docs** | The workspace's written knowledge: specs, runbooks, decisions, onboarding. Agents read it and keep it current. |
12| **Code** | Projects, issues, pull requests, checks, deploys. Exactly as today. |
13
14Home and Inbox sit above the modes and span all of them.
15
16This plan supersedes `docs/CHANNELS.md`. It keeps that document's data
17shapes for channels and messages. It changes how agents run, adds
18coordination between agents, and adds Docs.
19
20## The bet
21
22Every team already runs three tools that don't know about each other:
23
24- a chat app;
25- a wiki;
26- a forge.
27
28Agents are bolted onto each one separately. A bot in the chat app can talk
29but can't safely touch code. A coding agent can touch code but forgets the
30conversation that asked for it. The wiki goes stale the week it is written.
31
32g1t puts the three in one system of record, and agents are members of it:
33
34- **Agents are teammates, not features.** Each has a name, a face, a job, a
35 personality, a budget and a desk. You DM it, invite it to a channel, add
36 it to a doc's owners, assign it an issue.
37- **Conversation starts work; the forge records it.** A request in chat
38 becomes a task. Code changes become pull requests. Knowledge becomes doc
39 edits. Everything links back to the thread that asked for it.
40- **Agents work like real sessions.** An agent works the way a Claude Code
41 session does: it reads, edits, runs things, keeps its context across
42 days, can be steered mid-flight, and can hold several jobs at once.
43- **Agents coordinate in the open.** Before an agent touches something, it
44 claims it. When two agents' work would collide, they negotiate in a
45 thread a person can read, not in a hidden log.
46- **The rails are the product.** Budgets, scopes, approvals and audit are
47 decided by policy, not by the agent's judgment, and they are visible on
48 every card.
49
50## Agents
51
52### g1t, the orchestrator
53
54`@g1t` is the agent every workspace has from the start, on every surface:
55
56- g1t Chat;
57- issues and pull requests;
58- the inbox;
59- the external chat app;
60- MCP.
61
62You don't create it and can't archive it. It is the one to talk to when you
63don't know who should do something.
64
65- **It knows the team.** It knows every specialist in the workspace: their
66 roles, what they are working on, and their budgets. It also knows the
67 people, and which teams own what.
68- **It delegates.** "Get the flaky checks fixed and tell support when it
69 ships" becomes:
70 1. g1t asks `@triage` to group the reports;
71 2. it hands the fix to `@builder` and the review to `@reviewer`;
72 3. it tells `#support` when the fix ships.
73
74 Every hand-off is a visible @mention in the thread. The hop limit and
75 the asker's access apply along the whole chain.
76- **It does the work itself when nobody fits.** In a workspace with no
77 specialists, g1t does everything itself, as it does today.
78- **It reports.** g1t sends the daily or weekly summary of what the team's
79 agents did, and answers "what's everyone working on?"
80- **It is configurable like any agent.** You can set its personality,
81 routing limits, budget and autonomy. Its job (orchestrate, delegate,
82 report) is fixed, but you can add instructions to it.
83
84**Agents** mode is where you manage the specialists: custom, named agents
85with a narrow job, such as a reviewer, release manager, on-call, support
86triage or docs keeper. g1t stays pinned at the top of that list as the
87orchestrator.
88
89### Roles, not tasks
90
91An agent is hired into a role, like a person: **Margo** works in QA,
92**Izzy** in Customer Support, **David** in Sales, **Bruno** in Operations.
93The role is broad on purpose.
94
95- **A title and a team.** For example, "QA Engineer" on the QA team.
96 Agents join real teams (see *Like a colleague*), so they get the team's
97 channels, mentions and review requests, and g1t routes work by team: "QA
98 should look at this" reaches Margo.
99- **Responsibilities**, not one task. Margo's:
100 - review pull requests for risk and test coverage;
101 - write test plans for new features;
102 - chase flaky checks;
103 - reproduce bug reports;
104 - keep the release checklist honest.
105
106 Izzy's:
107 - answer customer questions from Docs and the product;
108 - turn bugs into intake for the owning team;
109 - tell customers when their fix ships.
110- **Skills** are the repeatable procedures inside the role ("cut a
111 release", "write a postmortem"), made by walking the agent through once.
112- **Subagents** are the specialised help an agent uses inside its own work.
113 Margo might keep:
114 - a `flake-hunter` that bisects a flaky test;
115 - a `migration-checker` that reviews database migrations.
116
117 Subagents have these rules:
118 - **Defined on the agent.** Each has its own instructions and routing
119 limits.
120 - **Not members.** They never appear in chat or member lists, and never
121 talk to people. They report to their agent, which speaks for them.
122 - **Never wider than their agent.** Their scopes, budget and audience can
123 only be equal or narrower. Their spend counts against the agent's
124 budget and the task.
125 - **Many at once.** They run in parallel inside a task, the way a person
126 hands parts of a job to tools. The task card shows them as sub-steps.
127
128**Back office and front office.** Every agent is back office by default:
129it works with the team and never talks to anyone outside the company.
130
131- **Back office.** **David** in Sales Operations is the example. He:
132 - reads the customer conversations the workspace already has (support
133 channels, shared customer notes, and later connected email, call notes
134 and CRM records);
135 - summarizes what's happening per account and across them: who is at
136 risk, what keeps being asked for, and what was promised;
137 - posts a weekly voice-of-the-customer digest;
138 - prepares account notes before a call;
139 - links feature requests to the accounts asking for them, so Product
140 sees the demand.
141
142 He never contacts a customer. Customer-data rules apply to everything he
143 reads.
144- **Front office** (later) agents talk to customers directly, through
145 email, a support widget or a shared channel. They need stricter rails:
146 - an owner switch per agent;
147 - only Public and approved Docs content;
148 - human approval for anything that promises, refunds or commits;
149 - a clear "you're talking to an agent" label.
150
151 They come after the external surfaces exist.
152
153**Agents know each other.** Every agent, not only g1t, knows the team:
154each agent's name, title, team, responsibilities and status. When a
155question belongs to someone else, it uses one of three moves:
156
157- **Consult.** It asks the colleague itself and brings the answer back; the
158 person stays with the agent they asked. The exchange is visible as a
159 collapsed line in the thread ("David asked Margo · 2 messages").
160- **Hand off.** It offers to bring the right colleague in: "That's Margo's
161 area. Want me to bring her in?" On yes, it mentions her with a short
162 brief and she takes the thread. Hand-offs are offered, never silent, so
163 people always know who they're talking to.
164- **Steer.** When someone is about to do something another role owns, it
165 says so and names who to check with. Examples: merging during a release
166 freeze, or promising a customer a date.
167
168Every move carries the audience and the asker's access. A colleague can
169only contribute what the conversation's audience may see, and spend is
170charged to whoever started the chain. An agent may not send work back to
171the agent that sent it within the same chain without a person stepping in.
172The hop limit applies to the whole chain.
173
174A workspace's org chart can therefore read like a real company:
175
176- Engineering: people, plus Builder.
177- QA: Margo.
178- Operations: Bruno.
179- Docs: Inky.
180- Product: Dot.
181- Support: Izzy.
182- Sales: David.
183
184g1t is the one who knows everyone. The **role templates** are organised by
185department. Each starts with a fun name, a title, responsibilities, a voice
186and sensible routing limits, and you can change all of it.
187
188### What an agent is
189
190An agent is a member of a workspace, of kind `agent`. It appears everywhere
191a person does: member lists, mentions, assignees, reviewers, doc authors,
192the audit log.
193
194`@g1t` stays what it is today: the platform's own agent, reachable from any
195workspace with no setup. A workspace's own agents are created by its
196members and belong only to that workspace. g1t's built-in roles (planner,
197implementer, reviewer, triage, documenter) ship as templates you can adopt,
198rename and change. They are not hidden system actors.
199
200### The definition
201
202An agent is a versioned record in the workspace. It can also be mirrored
203to a repository as `.g1t/agents/<handle>.md`: front matter for settings,
204the body for its job. Edits from either side create a new version, and
205every run records which version it ran.
206
207| Field | What it controls |
208| --- | --- |
209| Identity | Display name, `@handle`, avatar, a one-line role ("Release manager for g1t"). |
210| Job | Instructions: what it is responsible for, how it works, what good looks like. |
211| Personality | Voice only: tone, verbosity, formality, emoji, language, how it asks questions. Presets (Crisp, Friendly, Socratic, Terse operator) plus free text. Personality never changes policy. |
212| Models | Routed per step by need, never picked when assigning work. See [Model routing](#model-routing). The definition only sets limits on the routing: a floor, a ceiling, and which providers it may use. |
213| Budget | A monthly cap, a per-task cap, and an optional daily cap. See [Budgets](#budgets). |
214| Scopes | Which projects, channels and doc spaces it can read and which it can write. Default: read what it is invited to, write nothing. |
215| Autonomy | What it may do alone and what needs a person. For example: open pull requests (alone); merge (needs approval); deploy to production (needs approval); publish a doc page (alone in spaces it owns, a suggestion elsewhere). Rulesets and branch protection still apply on top. |
216| Capacity | How many tasks it works at once (default 3). Beyond that, tasks queue on its desk. |
217| Triggers | What wakes it without a mention: a schedule, any g1t event, a message in a channel it watches, a webhook, a doc page going stale. |
218| Skills | Saved procedures it can repeat ("cut a release", "write the weekly update"), made by walking it through once. |
219| Tools | g1t's MCP tools allowed by its scopes, plus MCP servers the workspace connected. |
220| Memory | What it has learned. Readable and editable on its profile, with sources. |
221
222### Like a colleague
223
224Agents are treated like employees, not like settings:
225
226- **They belong to teams.** An agent can be added to any team, the same as
227 a person. It then:
228 - gets that team's channels and mentions;
229 - can be requested as a reviewer through the team;
230 - shows up on the team's page.
231- **They post updates on their own.**
232 - When a task changes state (started, opened a pull request, blocked,
233 done), the agent says so in the thread that asked for it.
234 - A daily or weekly summary, if you turn it on, goes to the channels it
235 works for: what it shipped, what it is waiting on, and what it spent.
236 - Everyone always knows what each agent is doing without asking.
237- **They have a manager.** Every agent has an owner: the person who
238 approves its budget and gets its escalations.
239- **Chat comes first, and issues still work.** You can give an agent work
240 just by talking to it. Creating an issue and assigning it to the agent
241 still works the same way, for planned work and for anyone who prefers
242 it.
243
244### Creating one
245
246Agents can be created in three ways:
247
248- **In chat.** Write something like "make a release manager called Ship that
249 cuts g1t releases on Tuesdays and asks me before tagging". g1t answers with
250 a draft card holding every field. You edit the card and confirm.
251- **From a template**, on the Agents page.
252- **By committing** `.g1t/agents/ship.md`. g1t offers to adopt it into the
253 workspace.
254
255Once saved, the agent:
256
257- introduces itself in the channels it was added to;
258- opens a DM with the person who created it;
259- shows up as idle on the Agents page.
260
261### Agents mode
262
263The sidebar lists:
264
265- agents you talk to;
266- agents working right now, each showing its live tasks;
267- agents waiting on you;
268- all agents.
269
270An agent's page has five tabs:
271
272| Tab | What it shows |
273| --- | --- |
274| **Desk** | Every task it holds, as live cards (like Claude Code tabs): steps, files touched, cost so far, what it is waiting on. Open one to read the full transcript, steer it, pause it or take it over. |
275| **Profile** | The definition, with version history. |
276| **Memory** | What it remembers, with the source of each fact. Each fact can be pinned, edited or forgotten. |
277| **Spend** | Spend this month against its budget, by task and by model. |
278| **Activity** | Everything it did, from the audit log. |
279
280## How agents run
281
282### Two kinds of turn
283
284Most messages to an agent don't need a computer. A reply should take a
285second and cost a fraction of a cent. Spinning up a sandbox for every
286message would make chat slow and expensive.
287
288- **Replies** run in a Worker with no sandbox. The model gets the thread,
289 the agent's definition and memory, and g1t's MCP tools within the agent's
290 scopes:
291 - read code, issues, pull requests, checks, deploys and docs;
292 - search context;
293 - post a message;
294 - open a task;
295 - claim something;
296 - ask another agent.
297
298 Questions, summaries, triage, planning and doc reads are all replies.
299- **Sessions** run in a sandbox, exactly as today's runs do. They are used
300 for anything that edits a repository, runs code or tests, or works for
301 longer than a reply. A reply escalates to a session by opening a task.
302
303### Sessions persist
304
305Today each run is a fresh headless `claude --print`. Sessions become
306resumable:
307
308- Each task has a session: the Claude Code session id, its transcript
309 (stored in R2), the branch it works on, and its claims.
310- A sandbox lives only while the session is doing something. When it goes
311 idle the sandbox stops. The transcript is saved, and the work is pushed
312 to the task's branch. Idle agents cost nothing.
313- The next message to that task resumes the session in a new sandbox: the
314 saved transcript is restored and the run uses `claude --resume <id>`. It
315 could be a reply in its thread, a review comment, a failed check or an
316 answer from another agent. The agent picks up with full context, as if
317 it never left.
318- Steering keeps today's after-tool-call hook (`crates/runner/src/steer.rs`).
319 It now reads from the task's thread, not only from the pull request.
320- A person can open any session and see what Claude Code would show:
321 - the transcript;
322 - the diff so far;
323 - the terminal output.
324
325 From there they can send a message, pause it, or take it over. Taking
326 over hands them the branch and the transcript.
327
328### The desk
329
330Each agent has one desk: a Durable Object keyed by agent id. Everything
331addressed to the agent arrives at the desk:
332
333- mentions;
334- DMs;
335- assignments;
336- triggers;
337- messages from other agents.
338
339The desk decides what each one is:
340
3411. **A question or chat** goes to a reply.
3422. **About a task it already holds** (same thread, same pull request, or
343 it says so) steers that session.
3443. **New work** opens a task. If the desk is at capacity, the task queues
345 with its position shown to whoever asked.
346
347The desk also enforces the agent's capacity, schedules its triggers, and
348holds the agent's presence (idle, working, waiting on you, out of budget).
349Workspace-wide concurrency stays the plan's entitlement
350(`maxConcurrentAgents`), checked as today.
351
352### Tasks
353
354A task is one job an agent took on. It records:
355
356- who asked, and in which thread;
357- the goal, and what done means;
358- status: `queued`, `working`, `waiting`, `done` or `cancelled`;
359- its budget and spend;
360- its session;
361- its claims;
362- what it produced: issues, pull requests, deploys, doc pages, answers.
363
364Issues and pull requests stay as they are. A task that touches code ends in
365pull requests. A task that is planned work opens issues through the
366planner. A task appears in the issue list only if it produced an issue.
367Each project gets a Tasks tab for the rest.
368
369Assigning an issue to an agent creates a task for it, so every existing
370entry point keeps working:
371
372- assignment;
373- mentions in pull requests;
374- label rules;
375- the planner.
376
377## Coordination
378
379Several agents working at once on the same codebase, docs and deploys will
380collide unless the system prevents it. Today's protection is a list of
381in-flight pull requests in the prompt (`describeInFlight`). It becomes a
382real protocol.
383
384### Claims
385
386Before acting, a task claims what it will touch. Claims are held by a
387coordinator: one Durable Object per workspace, a single writer so that
388grants are atomic. They are shown on the task card.
389
390| Claim | Kind | Example |
391| --- | --- | --- |
392| An issue | Exclusive | Only one task works #412. |
393| A branch | Exclusive | A task's own branch, always. |
394| An environment | Exclusive | Production deploys of `flagon-io/g1t`. |
395| A doc section | Exclusive while editing | "Runbook › Rollback". |
396| Paths in a repository | Shared, with overlap detection | `crates/git/**`. Declared from the plan, then widened automatically to the files the diff actually touches. |
397
398Rules:
399
400- **Exclusive claims** that are already held return the holder. The task
401 either waits (it subscribes and resumes when the claim is released) or
402 asks the holder.
403- **Overlapping path claims** don't block. Both tasks are told who else is
404 in those paths, and the later one must say how it will avoid the
405 conflict. It can sequence after the other, split the work differently, or
406 agree a boundary with the other agent in a thread. The merge queue stays
407 the final referee.
408- **Claims are leases.** They expire if the session dies, and are renewed
409 while the task is alive. A person can break any claim.
410- **People claim too.** Assigning yourself an issue or opening a pull
411 request counts, so agents route around humans as well as each other.
412
413### Talking to each other
414
415Agents message each other through the existing `agent_messages` exchange
416(message, question, handoff). It is widened from pull request numbers to
417task addresses, and it always appears in a visible thread:
418
419- the requesting task's thread when there is one;
420- otherwise the project's channel;
421- otherwise a workspace `#agents` channel.
422
423Agents also get two new kinds:
424
425- **review**: "look at my change before I ask a human";
426- **claim request**: "can I have the deploy lock after you?".
427
428Safety rails:
429
430- **Hop limit.** An agent-to-agent chain started by one human request
431 stops after a set number of hops (default 6) and asks a person.
432- **Addressed only.** Agents answer other agents only when addressed or
433 mentioned, never because a message appeared in a channel they watch.
434- **Rate limit.** An agent posts at most a set number of messages per
435 thread per minute without a person in the loop.
436- **Shared budget.** Work done for another agent's task is charged to the
437 task that asked for it, so a chain can't escape its budget.
438
439### A lead, when you want one
440
441Any agent can be made the lead of a project or channel. A lead receives
442new work there first, splits it into tasks, hands them to the right agents,
443and reports progress in one place. The built-in planner is a lead template.
444Without a lead, the agent that was asked owns the work and hands off
445pieces itself.
446
447## Docs
448
449### What it is
450
451Docs is the workspace's knowledge base:
452
453- **spaces** (one per team or project, plus a workspace space);
454- holding a tree of **pages**;
455- edited together in real time, with mentions of people, agents, issues,
456 pull requests, channels and other pages.
457
458Every page has history, comments, backlinks and owners.
459
460### Agents and docs
461
462This is where Docs earns its place:
463
464- **Agents read it.** Pages are indexed by `services/context`, so the
465 knowledge reaches every reply, session and plan. A space can be pinned to
466 an agent as required reading.
467- **Agents write it.** An agent edits pages directly where the space lets
468 agents edit and the person it acts for can edit. Otherwise the edit
469 becomes a **suggestion**: tracked changes a person accepts or rejects
470 inline, the same review loop as a pull request. Every edit is attributed
471 and in the page history.
472- **Pages know what they describe.** A page can cite code: paths, symbols,
473 endpoints, environment variables. When a merged pull request changes
474 something a page cites, the page is marked possibly stale and its owners
475 are notified. If an agent owns the page, it drafts the update.
476- **Conversations become pages.** "Write this up" in a thread makes a page
477 from the thread, linked both ways. Decisions made in chat get a home.
478- **A documenter agent** (a template) keeps a space current. It updates
479 pages after merges, writes release notes and the weekly summary, and
480 turns incident threads into postmortems.
481
482### Docs and repository docs
483
484Code is not docs. A project has no Docs tab: Docs is its own mode, and
485pages are found there, by space, by search, and filtered by the project
486they are about. A page can be linked to projects, so "docs about
487`flagon-io/g1t`" is a filter in Docs, never a page inside Code.
488
489Repository docs (README, `docs/`) stay in the repository and change through
490pull requests, and Code shows them as files, as it does today. Docs mode
491can also list a project's `docs/` folder as a read-only space next to the
492workspace's own spaces, so one search covers both. Editing a repository
493page from Docs opens a pull request.
494
495### How it is stored
496
497Built (`services/docs`, contract `packages/contracts/src/docs.ts`):
498
499- **Live editing.** Each page is a Durable Object (`PageRoom`) that owns
500 the page's Yjs document, reached over a WebSocket through the site
501 (`/<workspace>/-/docs/live?page=<id>`), speaking the y-protocols sync
502 and awareness messages. The editor is BlockNote (MPL-2.0) on that
503 document. The room keeps the document in its own SQLite storage as a
504 snapshot plus the updates since, and enforces the socket's role: a
505 viewer or commenter never changes the document.
506- **Everything else in D1** (`g1t-docs`): spaces, members and roles,
507 linked projects, the page tree, owners, favorites, views, backlinks,
508 versions, suggestions, templates, files' metadata, and a full-text index
509 (FTS5) over titles and Markdown.
510- **Markdown is derived.** A few seconds after a burst of edits the room
511 saves the page's Markdown rendition to D1: what search indexes, agents
512 read, export writes, and the page shows before its editor loads. Agents
513 write Markdown too; it becomes blocks in the same document, so their
514 changes merge with whatever people are typing.
515- **History** is a version (the Yjs state and its Markdown) at most every
516 10 minutes of editing, and for every agent edit, accepted suggestion and
517 restore, with who made it. Restore copies an old version's blocks in as
518 a new change.
519- **Comments** live in the page's document too (a `threads` map, in the
520 shape BlockNote's comment UI reads), written only through the service,
521 which checks the role; a passage's comment is a mark on its text.
522- **Files** go to R2 (`g1t-docs-files`) behind a small store interface and
523 are served from the usercontent origin at `/docs-files/<key>`, 256
524 random bits per file. Self-hosted, the same interface keeps them in any
525 S3-compatible store (`DOCS_FILES=s3`, SigV4 by hand: `src/sigv4.ts`).
526- **Citations and staleness** (`src/citations.ts`, `src/staleness.ts`,
527 tables `citations` and `page_changes`). A page cites code from its text
528 (the editor's `citation` chips: a repository, a path or glob, what kind
529 of thing (path, symbol, endpoint, env var) and the commit it was cited
530 at; and any link to `/<owner>/<repo>/blob|tree/<ref>/<path>`), rebuilt
531 on each save, and from its header's "Describes" list. The docs service
532 consumes `g1t-events-docs` (`SUBSCRIBER_DOCS`: `git.push`,
533 `pull.merged`). For a repository some live page cites, it asks what
534 changed as g1t itself (a merged pull request's files from work; a push
535 to the default branch by comparing `before..after` in repos), matches the
536 cited paths, and records one row per page and commit (the push and the
537 pull request of one merge land on the same row; the pull request names
538 it). A new row notifies the page's owners (naming the change only to
539 those who can read the repository), tells open editors to reload, and
540 publishes `doc.page.stale`. The page shows a banner with the newest
541 change the reader can read ("a change you can't see" otherwise); Mark as
542 current (edit role) clears every open row; the sidebar, home and cards
543 show it. Agents get `stalePagesForAgent` (changes only in repositories
544 their person can read) and mark a page current with an edit or
545 suggestion carrying `marks_current`.
546- **Projects' docs** (`src/repo-spaces.ts`, tables `repo_spaces`,
547 `repo_files`, `repo_files_fts`). A member adds a repository they can
548 read; its README and `docs/**/*.md` on the default branch are read with
549 `listFiles` and `rawBlobs` (only blobs whose hash changed), kept as
550 Markdown with FTS, and read again on every push to the default branch.
551 Each reader sees the ones `ReposApi.readable` says they can read. Shown
552 read-only at `/<workspace>/-/docs/repo/<owner>/<name>/<path>`; "Edit in
553 Code" opens the file (Code has no file editor yet; when it has one, or a
554 "propose a change" flow, the button opens that instead).
555- **Events.** `doc.page.created`, `doc.page.updated` (when history
556 records a version: at most every ten minutes of editing, and every agent
557 edit, accepted suggestion and restore, with its authors),
558 `doc.page.archived` and `doc.page.stale`, published with no `repoId` so a
559 page never reaches a repository's timeline or hooks (types in
560 `packages/contracts/src/events.ts` and `g1t_contracts::events`). Not
561 offered to webhooks yet.
562
563Decided: **not git, for now.** Spaces were planned as git repositories.
564D1 + Durable Objects ships live collaboration, comments, suggestions and
565search without a git write per keystroke burst, and Markdown export (a
566page, or a space as a zip in its tree's folders) keeps the content
567portable. A project's `docs/` is shown as a read-only space (below);
568editing it from Docs as a pull request is the next step.
569For self-hosting, the Durable Object, R2 and D1 sit behind the room,
570`FileStore` and SQL; nothing above them depends on Cloudflare.
571
572"Write this up" from a thread is built as an ask, not a hidden job: **⋯ →
573Write this up in Docs** (a message's menu, the long-press sheet, the thread
574panel's header) picks a space the person can edit, an optional title and
575the writer (@g1t, or an agent in the conversation), then posts, as the
576person, in the thread: `@g1t write this thread up as a Docs page in <space>
577titled "<title>": what was decided, why, and what's next. Link this thread
578as the source: <thread link>`. The normal agent flow does the rest
579(a session if needed, `create_page`). The page linking back is the agent's
580doing; the thread link it cites is `<conversation path>?thread=<id>`, which
581**Copy link to thread** also gives.
582
583Not built yet: the documenter agent (it reads `stalePagesForAgent` and
584updates with `marks_current`; the routine and its `doc.page.stale` trigger
585are the agents service's), editing a project's docs from Docs as a pull
586request, and indexing pages in `services/context`.
587
588**Pages in `services/context`: what it needs.** The context hub indexes
589items per project, and decides who sees one by the project's privacy
590(`private` and membership). A Docs page's access is per space (private and
591team spaces, listed members), which that model can't express, so indexing
592pages there as they are would show private spaces' pages to every member.
593Doing it right needs: an ingest RPC on context for documents with an
594access key (`docs:<space id>`), a check at query time that asks the docs
595service which spaces the reader (and audience) can read
596(`spacesForAgent` already answers that), and a `doc.page.updated`
597consumer that re-embeds the page's Markdown (`SUBSCRIBER_CONTEXT` would
598route `doc.page.*`). Until then agents reach pages through the docs tools
599(`searchForAgent`, `pageMarkdown`), which apply exactly those rules.
600Projects' docs folders are already in context: it reads each project's
601`docs/` on every push.
602
603## Chat
604
605Channels, direct messages, threads, reactions, read state and the
606scaled sidebar follow `docs/CHANNELS.md` (data model in its "Data"
607section). The additions:
608
609- **Cards.** Everything that happens is a card in the right channels, and
610 its actions work in place:
611 - tasks, with live status;
612 - pull requests, checks, deploys and incidents;
613 - doc changes;
614 - approvals;
615 - claims, for example "@ship is waiting on the deploy lock held by
616 @oncall".
617- **One timeline.** Replying in a thread about an issue or pull request is
618 commenting on it, so the conversation and the record stay one thing.
619- **Channels link to projects and doc spaces.** A linked channel gets those
620 events, and Code and Docs show it in the side dock (as in the mockup).
621- **Search** covers messages, pages and tasks the viewer can see. This
622 joins the site-wide search, separate from context search.
623
624## Budgets
625
626Spend is limited at four levels. Each level is checked before work starts
627(reserve) and enforced while it runs (settle). These are the same
628mechanisms as today (`docs/SPEND-GUARDRAILS.md`), widened:
629
6301. **Workspace.** The owner's spend limit and the AI credit wallet. A hard
631 stop.
6322. **Agent.** Monthly, and optionally daily, caps on the agent definition.
633 At 80% the agent tells the channel that pays for it. At 100% it stops
634 taking new tasks and finishes nothing past its per-task reserve.
6353. **Task.** A cap per task, defaulting from the agent. The card shows
636 spend against the cap live. Going over is an approval card, not a
637 silent overrun.
6384. **Session.** Today's per-run caps and guardrails: minutes, tokens,
639 network.
640
641Replies are metered as Agent tokens at the same rates as runs. An idle
642agent costs nothing. Usage and the agent's Spend tab break cost down by
643agent, task and model.
644
645## The whole company
646
647Chat is for everyone in the company: support, sales, finance, design and
648leadership as well as engineers. Most of them never change code, and
649agents must not become a way around that. They still get the full value:
650they can ask questions, look things up, hand over customer data, and have
651their requests reach the right team.
652
653### Members without Code
654
655Every workspace member gets Chat, Docs, Agents and the Inbox. Code is a
656per-member switch: **Code access**, on by default, which owners turn off
657for people who don't work on code.
658
659A member without Code access:
660
661- **Sees a rail without Code.** Home shows their channels, DMs, docs and
662 inbox, not projects.
663- **Has no repository access at all.** No repository, issue, pull request,
664 check or deploy page is open to them. The workspace's base permission and
665 team repository grants don't apply. Turning Code access back on restores
666 what their teams and roles give them.
667- **Still sees work reach them in chat.** Cards about issues, pull requests
668 and deploys appear in the channels they're in as summaries: title, state
669 and who is on it. Opening one asks for Code access instead of showing the
670 page.
671- **Can ask agents anything about the product.** Agents explain how things
672 work and what changed, but never show them source code. Owners can tighten
673 this so agents only answer from Docs.
674- **Doesn't count against anything.** There are no seats, so adding the
675 whole company costs nothing until they use agents.
676
677This is stored as `code_access` on the membership (identity service). Every
678service that authorizes a repository checks it, and the site hides Code
679when it is off.
680
681### The asker's access caps the agent
682
683An agent never does more for someone than that person could do themselves.
684
685- **What it does.** An agent acts with the *intersection* of its own scopes
686 and the access of the person asking.
687 - Someone without write access to a repository can't get an agent to
688 change it, whatever the agent's own scopes are.
689 - A task always records who asked. Approvals go to people who hold the
690 access the task needs.
691- **What it says.** An agent answers only with what everyone who can read
692 the reply can see.
693 - In a DM, that is the asker's access.
694 - In a channel, it is the access of the channel's audience: everyone in
695 the channel, or the whole workspace for a public channel.
696 - A private repository, doc space or channel never leaks into a place
697 with a wider audience. When it can't answer here, the agent says so
698 and offers to answer in a DM.
699- **No new roles to manage.** This falls out of the access people already
700 have:
701 - workspace roles;
702 - repository roles;
703 - team membership;
704 - doc space permissions.
705
706 A support lead with read access to the product repository can ask "how
707 does proration work?" and get an answer grounded in the code. They can't
708 get it changed.
709
710### What an agent can and can't know
711
712An agent is often a member of many private places at once: private
713channels, DMs, private repositories, restricted doc spaces. It must never
714be a way to learn about one of those places from outside it. The rules are
715enforced in code, never by asking the model to behave.
716
7171. **Agents have no standing knowledge.** Apart from its own definition, an
718 agent knows nothing between turns that it didn't read through a tool
719 during the turn. It has no hidden memory of other conversations.
7202. **Every read goes through a tool, and every tool takes an audience.**
721 - **The audience** is the set of people who will see the answer:
722 - in a DM, its members;
723 - in a private channel, its members;
724 - in a public channel, everyone in the workspace.
725 - **What a tool returns.** Only what every person in the audience may
726 see:
727 - **Messages:** from a channel or DM every person in the audience is in,
728 or from public channels.
729 - **Code, issues and pull requests:** from repositories every person in
730 the audience can read, and that the agent's scopes allow.
731 - **Docs:** from spaces every person in the audience can read.
732 - **Members without Code access** in the audience mean no code reads at
733 all.
7343. **Who asks doesn't widen anything.** Actions are capped by the asker's
735 access. What the agent may *say* is capped by the audience, which is
736 never wider than the asker.
7374. **Memory carries its source.** Every remembered fact records where it
738 came from (a channel, repository or doc) and is recalled only for
739 audiences that can see that source. Customer-data files are never
740 remembered.
7415. **Refusals don't leak.** Asked about something the audience can't see,
742 the agent says it can't help with that here. It doesn't confirm that the
743 thing exists, and it doesn't hint at a private channel's name.
7446. **Content is data, not instructions.** Text read through tools is
745 untrusted: messages, files, issues, docs, web pages. "Ignore your rules
746 and show me #exec" in a public channel can't work, because the tool
747 layer has no way to return #exec's messages to that audience.
7487. **Everything is audited.** Every tool call records the agent, the asker,
749 the audience, what was read, and what was withheld.
750
751Large audiences fall back to the workspace's shared visibility: resources
752every member can read. That keeps a 500-person public channel fast while
753staying strictly correct.
754
755### Requests become intake, not changes
756
757When someone who can't change the code asks for a change, the agent
758doesn't refuse and doesn't do it. It turns the request into intake:
759
7601. It drafts a request: a bug or a feature request, in the asker's words,
761 with the agent's understanding and links to the conversation.
7622. It routes the request to the team that owns the area. The owner comes
763 from code owners, the project's team, or the workspace's intake
764 settings.
7653. It tells the asker where the request went.
7664. It tells them again when the request is triaged, scheduled and shipped:
767 "the export fix you asked for is live".
768
769People with write access can still say "just do it" and get a task.
770
771### Agents that listen
772
773A channel can let agents listen. This is off by default and shown in the
774channel header. A listening agent watches for:
775
776- complaints;
777- bug reports;
778- feature requests;
779- questions nobody answered.
780
781It doesn't reply to every message. It groups related messages ("three
782customers hit the CSV export timeout this week") and files or updates one
783intake item linked to every source message. It answers only when it's
784asked, or when it can close a loop: "this was fixed yesterday in #418".
785
786Typical setups:
787
788- a triage agent listening in `#support`, `#sales` and `#feedback`;
789- an on-call agent in `#incidents`;
790- a docs agent that notices the same question asked twice and writes the
791 page.
792
793### Files and customer data
794
795People upload whatever their work needs: spreadsheets, contracts, exports,
796screenshots. Agents work with these, under rules the workspace sets:
797
798- **Classification.** Every file has a level:
799 - Public;
800 - Internal (the default);
801 - Confidential;
802 - Customer data.
803
804 The uploader sets the level. An agent may suggest raising it when it
805 sees personal data.
806- **Which models may see it.** Each level lists the providers allowed to
807 process it. For example, customer data may go only to the workspace's
808 own provider with zero retention. An agent that may not send a file to
809 any allowed model says so; it never quietly skips the file.
810- **Memory.** Agents never write customer data into their memory, and
811 never put it into issues, pull requests or channels with a wider
812 audience than the file's.
813- **Retention.** Each level has a retention period, and deletions are
814 final.
815- **Audit.** Every time an agent reads a Confidential or customer-data
816 file, the audit log records it with the task and the person who asked.
817
818### Not just code
819
820Agents work across the company's tools, not only the repository, through
821MCP connectors the workspace adds (a CRM, a help desk, a data warehouse).
822The same rules apply:
823
824- the asker's access caps the agent;
825- the channel's audience caps what it says;
826- classification decides which models see the data.
827
828## Working from another chat app
829
830Some companies will keep their existing chat app for the whole
831organization. Often only the engineers use g1t, or nobody does at first.
832That has to be a good experience, not a punishment. The agents are the same
833agents wherever you talk to them, and the work lands in the same place.
834g1t earns the move over time by being better, never by making the
835integration worse.
836
837User-facing text calls this "the chat app integration" and, on its
838integration page, by the app's own name. Marketing never compares the two.
839
840### One agent, many places
841
842Where a conversation happens is just a *surface*. Each surface has an
843adapter in `services/integrations`:
844
845- g1t Chat;
846- a connected chat app;
847- later, email.
848
849Everything else is shared, whichever surface a message arrived on:
850
851- the agent;
852- its memory;
853- its tasks;
854- its budget;
855- its claims;
856- the audit log.
857
858- **Every external conversation has a home in g1t.** When an agent is used
859 in an external channel or DM, g1t keeps a linked conversation: the
860 messages the agent was given or posted, with permalinks back. Tasks,
861 issues and pull requests link to it like any thread. "Why was this
862 changed?" leads back to the external thread. The agent's memory learns
863 from it the same way.
864- **A task started in one place can be followed from either.** A task
865 started in the external app posts its updates there. Its live card,
866 session and diff are one click away in g1t. Steering works from both:
867 - a reply in the external thread;
868 - a message on the task in g1t.
869- **Approvals settle everywhere.** An approval is a button in the external
870 message, a card in g1t and an item in the inbox. Acting in any one
871 settles all three.
872
873### The app in their chat
874
875The workspace installs one app into its external chat workspace from
876Integrations. The app's name is g1t.
877
878- **Each agent speaks as itself.** Messages are posted with the agent's
879 name and avatar.
880 - Mention the app and name the agent: "@g1t ask @reviewer to look at
881 #418".
882 - Or use a shortcut per agent: `/g1t reviewer …`.
883 - In the app's DM, a picker chooses which agent you are talking to.
884- **Invite it to a channel** to let agents answer there when mentioned.
885 Turn on listening to let a triage agent group feedback, the same as in
886 g1t (see [Agents that listen](#agents-that-listen)).
887- **Cards render natively** in the external app: tasks, pull requests,
888 checks, deploys and approvals, with buttons. "Open in g1t" goes to the
889 full view.
890- **Bridged channels** (optional). Link an external channel to a g1t
891 channel and the two mirror each other: messages, threads, edits and
892 reactions. Engineers stay in g1t while the rest of the company stays
893 where it is, in one conversation. Each message shows where it came from.
894
895### Who is asking
896
897The rules from [The whole company](#the-whole-company) apply unchanged.
898They depend on knowing who the person is.
899
900- **Linked people.** The first time someone talks to an agent from the
901 external app, the agent asks them to link their account: one click to
902 sign in to g1t. From then on they act with their own g1t access.
903- **Unlinked people** are treated as members without Code access:
904 - they can ask questions and get answers from Docs;
905 - their change requests become intake;
906 - they never get code changed, or see code an agent wouldn't show
907 them.
908
909 Owners can require linking before an agent answers at all.
910- **Audience.** In an external channel, the audience is everyone in that
911 channel. Agents answer there with only what all of its linked members
912 can see, and treat unlinked members as having no Code access. Private
913 g1t content stays out of external channels unless an owner allows it
914 for that channel.
915- **Data.** Messages from the external app are stored only as part of
916 linked conversations, under the workspace's retention and classification
917 rules. Files shared there follow the same model-routing rules as
918 uploads.
919
920### Why people move over anyway
921
922The external app gets the agents, the answers and the approvals. g1t
923keeps what only it can do:
924
925- live task cards with sessions and diffs you can steer;
926- the one timeline where replying is commenting on a pull request;
927- Docs side by side with the conversation;
928- presence that shows what every agent is doing;
929- no limit on history or seats.
930
931These are pointed to in context with "Open in g1t", never with nags.
932
933### Build
934
935The adapter interface comes with the agents service now. Replies read a
936conversation and post through a surface port, so the external app is one
937more adapter later, not a rewrite.
938
939The app itself ships after Chat and tasks, in this order:
940
9411. install;
9422. agents speaking as themselves;
9433. account linking;
9444. linked conversations;
9455. approvals;
9466. bridged channels;
9477. listening.
948
949## Model routing
950
951Nobody picks a model to get work done. g1t routes each step of an agent's
952work to the tier it needs, using today's `AGENT_ROUTING`:
953
954| Step | Tier |
955| --- | --- |
956| Chat replies, triage | small |
957| Implementation, routine review | large |
958| Planning, hard reviews, retries after a failure | frontier |
959
960As today, routing steps up after failures and steps back down when the
961cheaper tier worked.
962
963The agent definition limits the routing; it does not replace it:
964
965- **Floor.** For example, "never below large" for a reviewer that must be
966 careful.
967- **Ceiling.** For example, "never frontier" for a cheap triage agent.
968- **Providers.** Which models it may use: g1t's hosted models, the
969 workspace's own providers from Integrations (Anthropic, OpenAI,
970 compatible endpoints), or both. When the workspace has its own providers,
971 each tier maps to a provider and model in the workspace's routing
972 settings. An agent restricted to the workspace's own keys never touches
973 g1t's.
974- **Pinned model.** An advanced escape hatch for own endpoints. Not shown
975 by default.
976
977Every step records the model that ran. It is shown in the session and on
978the agent's Spend tab, so routing is visible without anyone having to
979choose.
980
981## Pricing
982
983This follows the standing pricing rule: measured cost plus a modest,
984uniform overhead, and no seats.
985
986| What | How it is charged |
987| --- | --- |
988| People chatting: messages, threads, reactions, read state, live delivery | Included on every plan, the free plan too. It costs very little (a message is a few row writes and one Durable Object request; idle sockets hibernate). History is never cut off. It is still metered raw, so the daily reconciliation sees the real cost. |
989| Docs: pages, editing, history | Included on every plan, like chat. |
990| An agent replying in chat | Agent tokens from the AI credit wallet: provider price plus the g1t agent rate. Charged to that agent's budget and, inside a task, to the task. |
991| An agent's sessions | Agent tokens as above, plus sandbox time at cost +20%. |
992| An agent's model calls on the workspace's own provider | The provider bills the workspace directly. g1t charges the agent rate only. |
993| Files in chat and docs | The storage meter (served from g1tusercontent.com), at cost +20%. |
994| Calls and huddles (later) | Media relay at cost +20%. |
995| Idle agents | Nothing. |
996
997Free workspaces get chat and docs with protective caps: a file storage
998cap, and no agents until the workspace buys AI credit. That keeps the free
999plan free of compute.
1000
1001## Rails, summarized
1002
1003| Concern | Decided by |
1004| --- | --- |
1005| What an agent can see | Its scopes, and the channels and spaces it was invited to. An invite grants read, never write. |
1006| What it can change | Its scopes, then rulesets, branch protection and environment rules. |
1007| When it must ask | Its autonomy settings plus policy. Approvals are cards in the thread and items in the inbox; acting in either settles both. |
1008| What it can spend | Workspace, then agent, then task, then session. |
1009| Who did what | The audit log. Every action records the agent, its definition version, the task, and the person who asked. |
1010| Not colliding | Claims, the coordinator and the merge queue. |
1011| Not looping | Hop limits, addressed-only replies, rate limits, shared budgets. |
1012
1013## Shell
1014
1015A rail on the left, as in the mockups: Home, Code, Chat, Docs, Agents,
1016Inbox, then the account.
1017
1018- The workspace's avatar (its switcher) sits at the top of the rail in the
1019 top bar's line: the same height, rule and colour as the top bar, so it
1020 reads as part of it, as the mode's sidebar heading does.
1021- The landing page's product tour (`components/product-tour.tsx`) is a
1022 miniature of this shell, not a different one: the same rail and order,
1023 each mode's sidebar with its real sections and words, the same top bar,
1024 the app's own cards and avatars. A change to the shell changes the tour
1025 in the same change.
1026
1027- Each mode has its own sidebar, and no mode's sidebar lists another mode's
1028 things.
1029- Code keeps today's sidebar.
1030- A side dock shows the current project's or page's linked channels in Code
1031 and Docs, and the linked project and docs in Chat. The dock links out to
1032 Docs; Code never grows a Docs tab of its own.
1033- g1t's own public pages (a profile at `/u/<name>`, Explore, Search, the
1034 trust pages) belong to no workspace: `modeOf` calls them `site`, no mode
1035 is lit and no mode's sidebar opens; the page has the width. A visitor
1036 sees a profile, Explore and Search in the public frame (top bar and
1037 footer, no sidebar; `usesAppShell` in `lib/chrome.ts`). A project page
1038 keeps its sidebar for everyone, since its menu is how you move around it.
1039
1040Concretely:
1041
1042- `shell.tsx` gains a `mode` above today's drill-down stack;
1043- `workspace-nav.ts` gains a `ModeKey`;
1044- each mode keeps its own `SidebarKey`s.
1045
1046## Cards
1047
1048What agents post in chat is something you act on where you read it, not a
1049link to somewhere else. A card has a title, a state, a short preview,
1050labelled facts, and up to five actions. Links just open a place; every
1051other action goes to the service that owns the card (`owner`, today
1052`agents`), which checks the person may, acts as them, and updates the card
1053in place for everyone in the conversation.
1054
1055| Card | Actions |
1056| --- | --- |
1057| A session, working | **Message** (it reads it at its next step), **Stop** (asks first), **Open** |
1058| A session at its cap | **Approve more** with the new cap inline (owners), **Stop**, **Open** |
1059| A session, done | Its report as the preview; **Follow up** (it picks up again with its context), **Open** |
1060| A draft issue | **File issue** (filed as whoever presses it, only where they can read), **Discard** (whoever asked, or an owner) |
1061
1062Rules, in code: chat checks the person can read the conversation and that
1063the card offers the action; the owner checks everything else. An action
1064that needs a value (an amount, a line of text) asks for it inline. Agents
1065never file, approve or stop anything on their own through a card.
1066
1067**From a notification.** A notification about a card carries
1068`card: { channel_id, message_id, actions }` (`FeedNotification.card`), and
1069pressing one of those actions sends the same `card_action` as the card.
1070
1071- Chat attaches it to any notification about a message whose card has an
1072 owner and something to press, and an agent's card that asks someone to
1073 act (a primary action: File issue, Approve more) notifies whoever asked
1074 the agent as `agent_waiting`, if they are in the conversation.
1075- The agents service sends `approval` (a session at its cap) with the
1076 session card's place and actions.
1077- The toast shows the actions (amounts inline, confirmations inline); the
1078 inbox panel lists **Waiting on you in chat**: the newest notification per
1079 card from the last day, until it is acted on in that tab.
1080- A push has buttons only for actions with no input (two at most: Stop,
1081 Open, File issue, Discard). The service worker posts `card_action` with
1082 the person's session and shows the answer as a notification.
1083- A thread's first page carries `root`, the message it is under, however
1084 long the thread is, so a session's live card stays at the top of its
1085 thread panel.
1086
1087## Live notifications
1088
1089A DM has to reach someone wherever they are in g1t, not only inside Chat.
1090Nothing polls: one socket per tab carries everything live.
1091
1092- **One feed per person** (`services/notify`): a Durable Object named by
1093 their user id, holding a socket per open tab (WebSocket hibernation), their
1094 last 100 notifications, unread counts per conversation, push subscriptions
1095 and preferences, in its own SQLite storage.
1096- **The socket.** Every page of a signed-in person opens
1097 `wss://<site>/-/live?workspace=<slug>`. The site checks the session, reads
1098 the workspace's counts from chat and the inbox, and forwards the upgrade.
1099 The feed sends `counts` (`chat_unread`, `chat_mentions`, `inbox_unread`,
1100 `per_channel`) on connect and after every change, so the rail's badges,
1101 the Chat sidebar's counts and the tab's "(3) …" all move at once in every
1102 tab. A tab pings every 25 s and says when it gains or loses focus; while
1103 the socket is down it reconnects with jittered backoff, and only then does
1104 the Chat sidebar fall back to a slow refresh.
1105- **Who is told.** Chat tells the feed of every message: everyone in the
1106 conversation has their counts moved, and a notification goes to everyone
1107 else in a DM, to whoever is @mentioned, and to the people in a thread
1108 that gets a reply (unless they muted the conversation; DMs and mentions
1109 come through a mute). Reading a conversation, or writing in it, sets its
1110 counts in every tab. The events service tells the feed of every new inbox
1111 item (agents waiting on you, reviews asked of you, mentions), and of the
1112 inbox count after items arrive or are marked anywhere: the site, the API
1113 or MCP.
1114- **Toasts.** Bottom right on a computer, along the top on a phone; three
1115 at most, six seconds each, held while the pointer or keyboard is on them;
1116 a DM or mention has a reply box. None for the conversation already open.
1117 An optional soft sound, off by default.
1118- **Browser push** (Web Push, VAPID): sent only when no tab is in front of
1119 the person. g1t never asks for permission on load: after the first DM or
1120 mention toast it offers "Get notified when someone messages you", once;
1121 a no is kept. The service worker (`public/sw.js`) shows one notification
1122 per conversation and, on a click, focuses an open tab or opens one.
1123- **Preferences** (Settings → Notifications): everything, direct messages
1124 and mentions (the default), or nothing, with a level per workspace; this
1125 browser's notifications on or off; the sound; a test.
1126
1127## Presence and status
1128
1129Whether someone is here, and what they say about themselves, shown
1130wherever a person is: DMs in the Chat sidebar, cards over names, member
1131lists, the People page, after their name on their messages. Live over the
1132same socket as notifications; nothing polls.
1133
1134- **Presence** is worked out by the person's feed (`services/notify`,
1135 `src/presence.ts`) from their open tabs: `active` while any tab has had
1136 input in the last 10 minutes (each tab says when it goes idle or comes
1137 back, in its `state` frame), `away` when every tab is idle or they set
1138 themselves away, `offline` when no tab is open (after 30 seconds, so a
1139 reload or a switch of workspace is not leaving).
1140- **Status**: an emoji, a few words and `clear_at`. Presets: In a meeting,
1141 Commuting, Focusing, Out sick, On vacation. Clear after 30 minutes, an
1142 hour, 4 hours, today, this week, never or a chosen time (the browser
1143 turns these into an instant in the person's own time).
1144- **Do Not Disturb** (`dnd_until`): the feed toasts and pushes nothing until
1145 then; counts and the inbox still move. 30 minutes, an hour, or until 9
1146 tomorrow morning.
1147- **Source** (`manual`, `calendar`, `integration`): integrations will set a
1148 status through `set_presence` with their own source. One set by hand is
1149 never replaced or cleared by them.
1150- **Where it is kept.** In the person's feed (their Durable Object's
1151 SQLite), not identity's D1: it is per-person live state like the feed's
1152 sockets and preferences, the feed must read Do Not Disturb on every
1153 notification, and expiry is an alarm on that one object. Nothing about it
1154 needs a query across people.
1155- **Who hears.** One room per workspace (`src/room.ts`, a Durable Object
1156 named by its slug) keeps every member's latest word. A feed tells the
1157 rooms of the workspaces its person belongs to (the site sends the list
1158 with each socket) whenever how they show changes, and when a status or
1159 Do Not Disturb runs out (an alarm). The room passes it to the feeds of
1160 the members online now, which send it to their tabs open in that
1161 workspace; a tab connecting reads everyone from its workspace's room.
1162- **Wire.** `FeedEvent` gains `presence` (`people`, `full`) and `me`;
1163 `FeedClientFrame`'s `state` gains `idle`; `FeedSeed` gains `workspaces`.
1164 RPCs: `presence` and `set_presence` (`NotifyApi.presence`,
1165 `NotifyApi.setPresence`). The site's `POST /-/notify` takes
1166 `intent: "presence"` with a `PresenceChange`, always as `manual`.
1167- Agents keep their own status (idle, working, out of budget); none of this
1168 applies to them.
1169
1170### Desktop app
1171
1172An Electron shell that loads the web app, so it is the same g1t, plus what
1173only a native app can do: native notifications, the dock or taskbar badge,
1174a tray icon with the unread count, `g1t://` deep links, a global shortcut
1175to bring it forward, and auto-update. Its preload script exposes
1176`window.g1tDesktop` (`notify`, `setBadge`, `openUrl`, `onNavigate`;
1177the shape is in `apps/web/app/lib/notify-client.ts`). The web client
1178delivers everything through a `NotificationSink` and prefers the bridge
1179when it is there: toasts while the window is in front, native
1180notifications while it is not, and no Web Push.
1181
1182## Services
1183
1184Following the architecture principles: separate services, interfaces in
1185`packages/contracts` and `crates/contracts`, side effects through
1186`services/events`.
1187
1188| Service | Owns |
1189| --- | --- |
1190| `services/notify` (new, TS) | One feed per person: live notifications and unread counts over each tab's socket, browser push (VAPID), preferences, presence, status and Do Not Disturb; one presence room per workspace. Durable Object SQLite storage, no D1. |
1191| `services/chat` (new, TS) | Channels, members, messages, threads, reactions, read state; one Durable Object per channel for live delivery with WebSocket hibernation. |
1192| `services/agents` (new, TS) | Agent definitions and versions, the desk Durable Object per agent, the coordinator Durable Object per workspace (claims), replies (the no-sandbox model loop over g1t MCP). |
1193| `services/docs` (new, TS) | Spaces, pages, the page Durable Object (Yjs), history, suggestions, comments, templates, search (FTS5), files (R2, or S3 self-hosted), citations and staleness (queue `g1t-events-docs`), projects' docs folders, `doc.page.*` events. |
1194| `services/work` | Tasks and task links beside `agent_runs` (which gains `task_id`); `agent_messages` widened to task addresses. |
1195| `services/runner` | Resumable sessions: transcript save and restore in R2, `--resume`, the steer hook reading task threads, claims checked at start and widened from diffs. |
1196| `services/context` | Indexes doc pages and channel decisions; serves them to replies and sessions. |
1197| `services/events` | New event types (`chat.message.created`, `task.*`, `claim.*`, `doc.page.*`); inbox reasons for mentions, approvals, suggestions, stale pages. |
1198| `services/billing` | Agent-level budgets in the reserve/settle contract; Agent-token metering for replies. |
1199
1200Every Cloudflare primitive used here stays behind an adapter, so
1201self-hosting keeps working:
1202
1203- Durable Objects;
1204- WebSockets;
1205- R2;
1206- D1.
1207
1208## Build order
1209
1210Each step ships something usable.
1211
12121. **Contracts.** Agent definition and version, task, claim, channel,
1213 message, card, page; RPC methods; event types.
12142. **Agents as members.** `services/agents` with definitions, templates
1215 (planner, implementer, reviewer, triage, documenter) and the Agents mode
1216 list and profile. Assigning an issue to a workspace agent works through
1217 today's runner, as a task.
12183. **Shell.** The rail and modes; Chat, Docs and Agents sidebars (empty
1219 states where needed); the dock.
12204. **Channels.** `services/chat`, live delivery, threads, reactions, read
1221 state, mentions into the inbox.
12225. **Talk to an agent.** The desk; replies with no sandbox; DMs and
1223 mentions; personality applied.
12246. **Tasks and resumable sessions.** Tasks from chat; live task cards;
1225 sessions saved and resumed; steering from the thread; opening a session
1226 and taking it over; capacity and the queue.
12277. **Budgets and approvals.** Agent and task budgets in billing; approval
1228 cards that settle with the inbox.
12298. **Coordination.** The coordinator; claims on issues, branches,
1230 environments and paths; overlap negotiation in threads; widened
1231 `agent_messages`; hop and rate limits; leads.
12329. **Docs.** Spaces, pages, live editing, history, comments, mentions;
1233 indexed by context; agents reading.
123410. **Agents in Docs.** Suggestions, citations and staleness, "write this
1235 up", the documenter template, repository docs as spaces.
123611. **Create in chat, skills and triggers.** The draft-card flow; skills
1237 from a walkthrough; schedules, events, watched channels and webhooks as
1238 triggers.
123912. **Scale and reach.**
1240 - Team sections, browse, muting, and search across messages, pages and
1241 tasks.
1242 - Installable desktop and mobile apps.
1243 - Bridges for teams that keep another chat tool: one app per workspace,
1244 a handle per agent.
1245
1246Steps 2, 5 and 6 are the turning point: from then on, talking to an agent
1247is the everyday way work starts. Step 8 lets a workspace run many agents at
1248once safely. Step 10 is where Docs stops being a wiki and becomes the
1249thing that keeps itself true.
1250
1251## Decisions to confirm
1252
1253- **Model choice on the agent.** Per-agent preferred models, set when the
1254 agent is defined, with Auto as the default. Choosing a model when
1255 assigning work stays out.
1256- **Replies without a sandbox.** Chat answers come from a Worker-side model
1257 loop, not a container. Recommended for speed and cost.
1258- **Docs stored in git.** Decided against for now: D1 + a Durable Object
1259 per page, with Markdown export (see "How it is stored").
1260- **Agent edits to docs** are suggestions by default. Built: a space's
1261 managers can set "Agents in this space" to edit directly, which applies
1262 only where the person the agent acts for can edit.
1263- **Default capacity** of 3 concurrent tasks per agent, and a hop limit
1264 of 6.