Skip to content
1,137 linesCodeBlameRaw
1/**
2 * A workspace's own agents: named members with a job, a personality,
3 * routing limits and a budget, kept by the agents service
4 * (`services/agents`). Every workspace also has `@g1t`, its built-in
5 * orchestrator, kept the same way (`builtin`).
6 *
7 * Wire shapes are snake_case end to end.
8 */
9import type { ServiceBinding } from "./clients";
10import type { Role, User } from "./identity";
11import type { Result } from "./result";
12import type { CardActionResult } from "./chat";
13
14// Model tiers (`ModelTier`, `MODEL_TIERS`) are integrations.ts's, the
15// same ones runs are routed between.
16import type { ModelTier } from "./integrations";
17import type { ExtensionInstall, InstallRequest, InstallRequestStatus, InstallRequests } from "./marketplace";
18import type { AgentAbilities, AgentAbilitiesChange, McpServer } from "./abilities";
19import type { AgentLook } from "./agent-look";
20import type { AgentComputerCommand, AgentComputerStatus } from "./runner";
21
22/** The built-in orchestrator's handle; nobody else's agent may take it. */
23export const BUILTIN_AGENT_HANDLE = "g1t";
24
25/** The built-in orchestrator's template id: not one a workspace can adopt. */
26export const ORCHESTRATOR_TEMPLATE = "orchestrator";
27
28/** Voice presets; free text in `personality` refines them. */
29export type PersonalityPreset = "crisp" | "friendly" | "socratic" | "terse";
30
31export type AgentRouting = {
32 /** Never route below this tier. Null: no floor. */
33 floor: ModelTier | null;
34 /** Never route above this tier. Null: no ceiling. */
35 ceiling: ModelTier | null;
36 /**
37 * Where its model calls may go. Empty: anything the workspace allows.
38 * `g1t`: g1t's hosted models. `workspace`: the workspace's own providers
39 * (Integrations), whichever they are. Any other entry: one of the
40 * workspace's own providers by integration id. Entries combine, so
41 * `["g1t", "workspace"]` is both.
42 */
43 providers: string[];
44 /** Advanced: a fixed `provider/model`, for own endpoints. Usually null. */
45 pinned: string | null;
46 /**
47 * How hard it works (docs.g1t.sh/guides/agents/#effort): the tier its
48 * work starts on, how hard the model reasons, and how many steps a
49 * session may take. `auto` (the default; absent means it) picks per
50 * piece of work. The floor and ceiling still hold.
51 */
52 effort?: AgentEffort;
53};
54
55/** An agent's effort setting, cheapest first after `auto`. */
56export type AgentEffort = "auto" | "low" | "medium" | "high" | "max";
57
58export const AGENT_EFFORTS: readonly AgentEffort[] = ["auto", "low", "medium", "high", "max"];
59
60/** A level work actually ran at: what `auto` resolves to each time. */
61export type EffortLevel = Exclude<AgentEffort, "auto">;
62
63export const EFFORT_LEVELS: readonly EffortLevel[] = ["low", "medium", "high", "max"];
64
65export type AgentBudget = {
66 /** Monthly cap in micro-dollars. Null: only the workspace limit applies. */
67 monthly_micros: number | null;
68 daily_micros: number | null;
69 /** Default cap for one task. */
70 task_micros: number | null;
71};
72
73export type AgentAutonomy = {
74 open_pull_requests: "alone" | "approval";
75 merge: "alone" | "approval" | "never";
76 deploy_production: "approval" | "never";
77 edit_docs: "alone" | "suggest";
78};
79
80export type AgentStatus = "idle" | "working" | "waiting" | "out_of_budget" | "paused";
81
82export type WorkspaceAgent = {
83 id: string;
84 workspace_id: string;
85 /** Lowercase, unique in the workspace, never `g1t`. Mentioned as `@handle`. */
86 handle: string;
87 display_name: string;
88 /** Uploaded avatar hash, or null for the generated mark. */
89 avatar: string | null;
90 /**
91 * What its generated face is drawn from (./agent-look.ts `lookFromSeed`),
92 * the same for the same seed everywhere. Set from the handle when it is
93 * made; changing it gives the agent a new face.
94 */
95 avatar_seed: string;
96 /**
97 * Its face as its owner chose it, part by part (./agent-look.ts), or
98 * null: the face `avatar_seed` draws. Shown wherever the agent appears.
99 */
100 look: AgentLook | null;
101 /**
102 * One line, as lists show it: "QA Engineer". Its title when not written.
103 */
104 role: string;
105 /**
106 * Agents are hired into roles, not tasks: a title and broad
107 * responsibilities. The teams it is on are team memberships, as a
108 * person's are (identity `team_agents`), never part of the agent.
109 */
110 title: string;
111 /** What it is responsible for: 2 to 8 short duties, or none yet. */
112 responsibilities: string[];
113 /**
114 * Specialised help it will use inside its own work. Never members, never
115 * wider than their agent. Stored now; they run with tasks and sessions.
116 */
117 subagents: SubagentDef[];
118 /**
119 * Its required reading: Docs spaces (by id) it checks first, every time
120 * it answers or works. It still reads only what the person it acts for,
121 * and everyone reading its answer, can read.
122 */
123 reading: string[];
124 /**
125 * g1t's foundational skills turned off for it, by id (./skills.ts):
126 * every one is on unless named here. Off takes the skill's playbook out of
127 * its instructions; its tools stay as they are.
128 */
129 skills_off: string[];
130 /**
131 * What it may do (./abilities.ts, docs.g1t.sh/guides/agent-abilities/):
132 * its level and credentials for each ability it has a choice about, and
133 * the MCP servers an owner added to it. Empty means every default.
134 */
135 abilities: AgentAbilities;
136 /**
137 * Who it works with: `internal`, the workspace's own people (back
138 * office), or `customers` (front office). Only `internal` for now.
139 */
140 faces: AgentFaces;
141 /** The job: what it is responsible for and how it works. */
142 instructions: string;
143 personality_preset: PersonalityPreset;
144 /** Free text refining the voice. Never changes what it may do. */
145 personality: string;
146 routing: AgentRouting;
147 budget: AgentBudget;
148 autonomy: AgentAutonomy;
149 /** Tasks it works at once; more queue on its desk. */
150 capacity: number;
151 /** The template it was made from, if any. */
152 template: string | null;
153 /**
154 * The workspace's built-in orchestrator, `@g1t`: every workspace has one,
155 * made the first time its agents are asked for. It cannot be archived,
156 * and its handle, name, role and job are fixed; its `instructions` are
157 * added to that job. Listed first.
158 */
159 builtin: boolean;
160 /**
161 * Who it belongs to (docs.g1t.sh/guides/agents/, "Personal agents"):
162 * `workspace`, the workspace's own, which owners keep; or `personal`, a
163 * member's own, which only that member talks to, in their direct message
164 * with it, and whose spend counts against that member's budget.
165 */
166 scope: WorkspaceAgentScope;
167 /** For a personal agent, the member it belongs to: their user id and username. Null for a workspace agent. */
168 personal_owner_id: string | null;
169 personal_owner: string | null;
170 version: number;
171 status: AgentStatus;
172 /** Spend this calendar month, in micro-dollars. */
173 spent_month_micros: number;
174 created_by: string;
175 created_at: string;
176 updated_at: string;
177 archived_at: string | null;
178 /** Who archived it, by username; null while it is live, or for one archived before this was kept. */
179 archived_by?: string | null;
180};
181
182/**
183 * An archived agent as the Agents page's Archived section lists it
184 * (docs.g1t.sh/guides/agents/, "Archive, restore and delete"): enough to
185 * draw its row and to say what deleting it for good takes with it.
186 */
187export type ArchivedAgent = {
188 id: string;
189 handle: string;
190 display_name: string;
191 title: string;
192 role: string;
193 avatar: string | null;
194 avatar_seed: string;
195 look: AgentLook | null;
196 scope: WorkspaceAgentScope;
197 personal_owner: string | null;
198 archived_at: string;
199 archived_by: string | null;
200 /** What goes with it when it is deleted. */
201 counts: { sessions: number; replies: number; memories: number; routines: number };
202};
203
204/**
205 * Back office or front office (docs.g1t.sh/guides/agents/, "Back office
206 * and front office"). Customer-facing agents are not available yet.
207 */
208export type AgentFaces = "internal" | "customers";
209
210/** A workspace agent, which owners keep, or a member's personal agent. */
211export type WorkspaceAgentScope = "workspace" | "personal";
212
213/** What a personal agent starts with, unless its creator gives it other caps: $20 a month and $2 a session. */
214export const PERSONAL_AGENT_BUDGET = { monthly_micros: 20_000_000, daily_micros: null, task_micros: 2_000_000 } as const;
215
216/** Most personal agents one member keeps in a workspace. */
217export const MAX_PERSONAL_AGENTS = 10;
218
219/**
220 * A subagent: help an agent keeps for its own work, such as Margo's
221 * `flake-hunter`. Its routing limits sit within its agent's: a floor below
222 * the agent's is raised to it, a ceiling above is lowered to it.
223 */
224export type SubagentDef = {
225 /** Lowercase letters, digits and hyphens: `flake-hunter`. Unique on the agent. */
226 name: string;
227 /** One line: what it is for. */
228 description: string;
229 instructions: string;
230 routing: { floor: ModelTier | null; ceiling: ModelTier | null };
231 /** How many of it may run at once inside one task, 1 to 8. */
232 max_parallel: number;
233};
234
235export type NewWorkspaceAgent = {
236 handle: string;
237 display_name: string;
238 /** Left out or empty: its title. */
239 role?: string;
240 title?: string;
241 responsibilities?: string[];
242 subagents?: SubagentDef[];
243 /** Docs spaces (by id) it reads first; at most 10. */
244 reading?: string[];
245 /** Foundational skills to turn off, by id (./skills.ts). */
246 skills_off?: string[];
247 /**
248 * Its abilities' levels and credentials (./abilities.ts), whole: what is
249 * sent replaces what it had. MCP servers are added and removed with
250 * `addMcpServer` and `removeMcpServer`, never here.
251 */
252 abilities?: AgentAbilitiesChange;
253 /** Only `internal` for now; `customers` is refused. */
254 faces?: AgentFaces;
255 instructions: string;
256 personality_preset?: PersonalityPreset;
257 personality?: string;
258 routing?: Partial<AgentRouting>;
259 budget?: Partial<AgentBudget>;
260 autonomy?: Partial<AgentAutonomy>;
261 capacity?: number;
262 template?: string | null;
263 /** Its avatar's seed; left out, the handle. */
264 avatar_seed?: string;
265 /** Its face, chosen part by part (./agent-look.ts); null goes back to the seed's face. */
266 look?: AgentLook | null;
267 /**
268 * When creating: `workspace` (owners only, and their default) or
269 * `personal` (any member, when the workspace lets members make them; a
270 * member's default). Ignored on a change: an owner promotes instead.
271 */
272 scope?: WorkspaceAgentScope;
273};
274
275/**
276 * What g1t drafted from a description (docs.g1t.sh/guides/agents/,
277 * "Describe it"): a whole definition to edit before anything is saved,
278 * and what the agent will want around it. Nothing here is saved until the
279 * agent is created.
280 */
281export type AgentProposal = {
282 /** A complete definition, ready to create as it is. */
283 definition: NewWorkspaceAgent & { scope: WorkspaceAgentScope };
284 /** Other names that suit it, for the shuffle. */
285 name_ideas: string[];
286 /** Foundational skills it should keep on, by id (./skills.ts); the rest are off in `definition.skills_off`. */
287 skills: string[];
288 /** Integrations the job needs, from the catalog (./connectors.ts), with why. */
289 integrations: { id: string; why: string }[];
290 /** Routines that would suit it, to set up on its Routines tab once it exists. */
291 routines: { name: string; when: string; instructions: string }[];
292 /** What drafting it cost, charged to the person who asked (micro-dollars). */
293 charged_micros: number;
294};
295
296/** One line of a Try it conversation, held by the page, never saved. */
297export type DraftTurn = { role: "user" | "assistant"; content: string };
298
299/** A Try it answer, and what it cost the person trying it. */
300export type DraftReply = { text: string; charged_micros: number };
301
302/** Changes drafted from "Tell <name> what to change", to review before they are saved as a new version. */
303export type AgentRedraft = {
304 /** The changes to save, as `update` takes them: only fields that differ. */
305 changes: Partial<NewWorkspaceAgent>;
306 /** One line on what changed. */
307 summary: string;
308 /** The version it was drafted from. */
309 from_version: number;
310 charged_micros: number;
311};
312
313/**
314 * A role to hire an agent into, by title. Agents get names, not job
315 * titles ("Margo", the QA Engineer). A template never puts an agent on a
316 * team.
317 */
318export type AgentTemplate = {
319 id: string;
320 /** The name it suggests first. */
321 display_name: string;
322 handle: string;
323 /** Other names that suit it, for the form's shuffle. Each is also a valid handle, lowercased. */
324 name_ideas: string[];
325 role: string;
326 title: string;
327 responsibilities: string[];
328 subagents: SubagentDef[];
329 instructions: string;
330 personality_preset: PersonalityPreset;
331 routing: AgentRouting;
332};
333
334/** What the chat service hands an agent: a message it should answer. */
335export type AgentDelivery = {
336 workspace: string;
337 workspace_id: string;
338 channel_id: string;
339 channel_kind: "channel" | "dm";
340 channel_name: string | null;
341 agent_id: string;
342 /** The message that woke it. */
343 message_id: string;
344 thread_root: string | null;
345 /** Who asked: the person's user id. */
346 asked_by: string;
347 /** Agent-to-agent hops so far in this chain. */
348 hops: number;
349 /**
350 * What the person who asked may do, from the viewer the chat service
351 * already holds when the message is posted (`askerAccess`). An agent
352 * never does more for someone than they could do themselves. Absent
353 * from an older chat service: the agent then treats the asker as unable
354 * to change code.
355 */
356 asker?: AskerAccess | null;
357 /**
358 * The agents that handled this request before this one, by id, oldest
359 * first; the last sent the work here. An agent never hands back or
360 * consults the one that sent it work, and the hop limit counts every
361 * hand-off and consult along the chain. Absent: none (a person asked).
362 */
363 chain?: string[];
364 /**
365 * Where the conversation is: g1t's own chat, or later another chat app
366 * the workspace connected. The agent reads and replies through that
367 * surface; its definition, budget and replies are the same everywhere.
368 * Absent: `g1t`.
369 */
370 surface?: AgentSurface;
371};
372
373/** The chat surfaces an agent answers on. Only g1t's own today. */
374export type AgentSurface = "g1t";
375
376/** Who asked an agent, as far as its reply needs to know. */
377export type AskerAccess = {
378 username: string;
379 /** Their role in the workspace; `outside` for someone who is not a member. */
380 role: Role | "outside";
381 /**
382 * Whether they can change code in the workspace: Code is on for them
383 * and they hold write access (or more) on at least one of its
384 * repositories, through the base permission or a grant.
385 */
386 can_write: boolean;
387};
388
389const WRITING_ROLES = new Set(["write", "maintain", "admin"]);
390
391/**
392 * `user`'s access in `workspace`, for `AgentDelivery.asker`. Pure, with no
393 * imports, so the chat service computes it from its viewer for free.
394 */
395export function askerAccess(user: User, workspace: string): AskerAccess {
396 const slug = workspace.toLowerCase();
397 const membership = user.workspaces?.find((m) => m.slug.toLowerCase() === slug);
398 // Someone who uses only Chat, Docs and agents sees no repository at all.
399 const code = membership?.code_access !== false;
400 const base = membership ? membership.role === "owner" || WRITING_ROLES.has(membership.base_permission ?? "write") : false;
401 const granted = (user.grants ?? []).some((grant) => grant.workspace.toLowerCase() === slug && WRITING_ROLES.has(grant.role));
402 return {
403 username: user.username,
404 role: membership?.role ?? "outside",
405 can_write: code && (base || granted),
406 };
407}
408
409/**
410 * A session: one bounded piece of work an agent took on
411 * (docs.g1t.sh/guides/agent-sessions/). A conversation with an agent is
412 * not a session: talking stays cheap and quick, and when a request needs
413 * real work the agent spins off a session for it, with its own context, transcript, budget and live card in
414 * the conversation. Sessions start other sessions (one of the agent's
415 * subagents, or a colleague brought in), and everything a tree of sessions
416 * spends is charged to the agent at its root, so a chain never escapes the
417 * budget that started it.
418 */
419export type AgentSessionKind =
420 /** Spun off from a conversation: someone asked for work. */
421 | "chat"
422 /** A routine's run. */
423 | "routine"
424 /** A colleague brought in by another session. */
425 | "helper"
426 /** One of the agent's own subagents, inside another session. */
427 | "subagent";
428
429export type AgentSessionStatus =
430 | "queued"
431 | "working"
432 /** Waiting on sessions it started. */
433 | "waiting"
434 /** Stopped at its spend cap: someone who may raise it decides. */
435 | "needs_approval"
436 | "done"
437 | "failed"
438 | "stopped";
439
440/** The statuses of a session that is not over. */
441export const SESSION_LIVE: readonly AgentSessionStatus[] = ["queued", "working", "waiting", "needs_approval"];
442
443export type AgentSession = {
444 id: string;
445 workspace_id: string;
446 agent_id: string;
447 /** The agent's handle, name and face, for lists. */
448 agent_handle: string;
449 agent_name: string;
450 agent_avatar_seed: string;
451 agent_look: AgentLook | null;
452 /** The subagent running it, by name, when kind is `subagent`. */
453 subagent: string | null;
454 kind: AgentSessionKind;
455 /** The session that started it, and the root of its tree. */
456 parent_id: string | null;
457 root_id: string;
458 /** Whose budget pays for it: the agent at the root of its tree. */
459 payer_agent_id: string;
460 title: string;
461 goal: string;
462 status: AgentSessionStatus;
463 /** Why it is waiting, stopped or failed, in a line. */
464 status_note: string | null;
465 /** What it found or did, once done: its report. */
466 summary: string | null;
467 /** Where it reports: the conversation it was started from. */
468 channel_id: string;
469 channel_kind: "channel" | "dm";
470 channel_name: string | null;
471 /** Its live card in that conversation; its updates go in the card's thread. */
472 card_message_id: string | null;
473 asked_by: string | null;
474 asked_by_username: string | null;
475 routine_id: string | null;
476 steps: number;
477 tool_calls: number;
478 input_tokens: number;
479 output_tokens: number;
480 /**
481 * At list price, what it counts against budgets: the model at the
482 * provider's price with billing's model margin, plus g1t's agent rate on
483 * every token. A root session's includes everything its tree spent.
484 */
485 charged_micros: number;
486 /** What its own steps' model answers cost at the provider's price, its tree's not included. */
487 cost_micros: number;
488 /** The most it may spend before someone approves more. */
489 cap_micros: number | null;
490 model: string | null;
491 /** The effort level it ran at (the highest, when `auto` raised it); null for sessions from before effort was recorded. */
492 effort: EffortLevel | null;
493 /** What it produced: issues filed, sessions started. */
494 outputs: SessionOutput[];
495 created_at: string;
496 updated_at: string;
497 finished_at: string | null;
498 /**
499 * False when the viewer is not among the people of the conversation it
500 * came from: they see that it ran and what it cost, never its title,
501 * goal, report or transcript.
502 */
503 visible: boolean;
504};
505
506export type SessionOutput =
507 | { kind: "issue"; repo: string; number: number; title: string }
508 | { kind: "session"; id: string; agent_handle: string; title: string }
509 | { kind: "memory"; id: string; body: string };
510
511/** One entry of a session's transcript, as its page shows it. */
512export type SessionEvent = {
513 seq: number;
514 kind: "goal" | "text" | "tool" | "command" | "steer" | "update" | "child" | "result" | "note";
515 /** Who: the agent's handle, a person's username (steering), or null for g1t's notes. */
516 by: string | null;
517 /** For `command`: the command on its first line, then its output, cut. */
518 body: string;
519 /** For `tool`: the tool, and whether it read, was withheld, refused or failed. For `command`: the directory it ran in. */
520 tool: string | null;
521 /** For `command`: `exit <code> · <duration>`, with `timed out` or `truncated` when so. */
522 outcome: string | null;
523 created_at: string;
524};
525
526/** An agent's computer as its Computer tab shows it (docs.g1t.sh/guides/agents/, "Its computer"). */
527export type AgentComputerView = {
528 status: AgentComputerStatus;
529 /** The most recent commands, newest first. */
530 commands: AgentComputerCommand[];
531 /** Whether the viewer may wake, sleep and reset it: owners, and the member of a personal agent. */
532 can_manage: boolean;
533};
534
535export type AgentSessionDetail = {
536 session: AgentSession;
537 events: SessionEvent[];
538 /** Every session in its tree, root first. */
539 tree: AgentSession[];
540 /** Whether the viewer may stop it, steer it, or approve more spend. */
541 can_stop: boolean;
542 can_steer: boolean;
543 can_approve: boolean;
544};
545
546/**
547 * What an agent remembers (docs.g1t.sh/guides/agent-memory/). Every fact
548 * carries where it came from, and its scope decides, in code, where it may
549 * be recalled and who may see it:
550 *
551 * - `workspace`: anywhere in the workspace. Owners write these, or an agent
552 * from a public channel, which every member can read already.
553 * - `channel`: only in that channel and its threads.
554 * - `person`: only in a direct message with that one person.
555 */
556export type AgentMemoryScope = "workspace" | "channel" | "person";
557
558export type AgentMemory = {
559 id: string;
560 agent_id: string;
561 scope: AgentMemoryScope;
562 /** The channel's id or the person's user id; empty for `workspace`. */
563 scope_ref: string;
564 /** The channel's name or the person's username, for display. */
565 scope_label: string | null;
566 body: string;
567 source_kind: "message" | "session" | "person";
568 /** A message id, a session id, or the username of who wrote it. */
569 source_ref: string | null;
570 source_label: string | null;
571 /** The channel the source is in, for a link. */
572 source_channel_id: string | null;
573 created_by: string;
574 created_by_kind: "agent" | "user";
575 pinned: boolean;
576 created_at: string;
577 updated_at: string;
578};
579
580/** When a routine runs, in UTC. */
581export type RoutineSchedule = {
582 every: "hour" | "day" | "weekday" | "week";
583 /** Minute of the hour, 0 to 59. */
584 minute: number;
585 /** Hour of the day (UTC), 0 to 23; not used for `hour`. */
586 hour: number;
587 /** Day of the week for `week`, 0 (Sunday) to 6. */
588 weekday: number;
589};
590
591/**
592 * Things that happen in the workspace a routine can run on
593 * (docs.g1t.sh/guides/agent-routines/). Each run is one session about the one
594 * thing that happened, in a repository its sponsor can read.
595 */
596export const ROUTINE_EVENTS = [
597 { key: "pull_ready", label: "A pull request is ready for review", hint: "Opened ready, or moved out of draft." },
598 { key: "pull_merged", label: "A pull request is merged", hint: "On any branch it targets." },
599 { key: "checks_failed", label: "Checks fail on a pull request", hint: "Its required checks failed or errored." },
600 { key: "issue_opened", label: "An issue is opened", hint: "By a person or an agent." },
601 { key: "deploy_failed", label: "A deploy fails", hint: "A production or preview deploy." },
602] as const;
603
604export type RoutineEvent = (typeof ROUTINE_EVENTS)[number]["key"];
605
606/**
607 * A routine: work an agent does on a schedule or when something happens, such as Sam's Monday digest
608 * of support themes. Each run is a session posted in the routine's channel,
609 * paid from the agent's budget, and run with the access of the person who
610 * set it up (its sponsor), never more.
611 */
612export type AgentRoutine = {
613 id: string;
614 agent_id: string;
615 name: string;
616 instructions: string;
617 /** When it runs on a clock; null when it runs only on events. */
618 schedule: RoutineSchedule | null;
619 /** What it runs on; empty when it runs only on its schedule. */
620 events: RoutineEvent[];
621 /** Which repositories its events come from, by `workspace/name`; empty: every one its sponsor can read. */
622 repos: string[];
623 channel_id: string;
624 channel_name: string | null;
625 sponsor: string;
626 sponsor_username: string | null;
627 enabled: boolean;
628 /** Why g1t paused it, when it did. */
629 paused_note: string | null;
630 next_run_at: string | null;
631 last_run_at: string | null;
632 last_session_id: string | null;
633 runs: number;
634 created_at: string;
635 updated_at: string;
636};
637
638/** A routine suggested from an agent's responsibilities, for an owner to add in one step. */
639export type RoutineSuggestion = { responsibility: string; routine: Omit<NewRoutine, "channel_id"> };
640
641export type NewRoutine = {
642 name: string;
643 instructions: string;
644 /** A schedule, events, or both; at least one. */
645 schedule: RoutineSchedule | null;
646 events?: RoutineEvent[];
647 repos?: string[];
648 /** A channel the agent is in, by id. */
649 channel_id: string;
650 enabled?: boolean;
651};
652
653/**
654 * The workspace's say over all its agents together, set by owners: one
655 * monthly budget across every agent, the budget a new agent starts with,
656 * and the cap a session starts with. The workspace's spend limit and AI
657 * credit (billing) sit above all of it.
658 */
659export type AgentPolicy = {
660 /** Every agent's spend together in a month. Null: only the workspace's spend limit. */
661 monthly_micros: number | null;
662 /** The monthly budget a new agent gets. Null: none. */
663 default_agent_monthly_micros: number | null;
664 /** The cap one session starts with, unless its agent's per-task cap is lower. */
665 default_session_micros: number;
666 /**
667 * What the agents working for one person (their replies and sessions,
668 * asked for by that person) may spend together in a month, unless the
669 * person has a budget of their own. Null: no budget per person.
670 */
671 person_monthly_micros: number | null;
672 /**
673 * Whether members who aren't owners may create personal agents
674 * (docs.g1t.sh/guides/agents/, "Personal agents"). On unless an owner
675 * turns it off; off, existing personal agents keep working.
676 */
677 members_create_agents: boolean;
678};
679
680/** One person's budget: what agents working for them may spend in a month, and what they have. */
681export type PersonBudget = {
682 username: string;
683 /** The budget that applies: their own, or the workspace's per-person default. Null: none. */
684 monthly_micros: number | null;
685 /** Whether it is their own, set by an owner, rather than the default. */
686 own: boolean;
687 /** What agents spent for them this month (UTC). */
688 spent_micros: number;
689};
690
691/** Budgets per person: the default, and each person who has one of their own or has spent this month. */
692export type PersonBudgets = {
693 period: string;
694 default_micros: number | null;
695 /** Owners see everyone; anyone else sees only themselves. Most spent first. */
696 people: PersonBudget[];
697};
698
699export type SpendSlice = { key: string; label: string; micros: number; count: number };
700
701/** Which days a breakdown covers: this month (the default), last month, or the last 7 or 30 days, in UTC. */
702export type SpendPeriod = "month" | "last_month" | "7d" | "30d";
703
704/** Where an agent's (or every agent's) spend went over a period. */
705export type AgentSpendBreakdown = {
706 /** `YYYY-MM` for a month; for a span of days, the month it ends in. */
707 period: string;
708 /** The span asked for, and its first and last day (`YYYY-MM-DD`, both included). */
709 span: SpendPeriod;
710 from: string;
711 until: string;
712 /** The one person it is about (work asked for by them), or null for everyone's. */
713 person: string | null;
714 total_micros: number;
715 /** Chat replies, sessions, routines, helping colleagues. */
716 by_kind: SpendSlice[];
717 by_model: SpendSlice[];
718 /** Who asked: the work done for each person. */
719 by_person: SpendSlice[];
720 by_agent: SpendSlice[];
721 by_team: SpendSlice[];
722 /**
723 * Where it was asked: a channel by id (labelled `#name`), direct
724 * messages together (`dm`), and channels the viewer can't read together
725 * (`private`).
726 */
727 by_channel: SpendSlice[];
728 /** The costliest sessions in the period. */
729 top_sessions: AgentSession[];
730 /** Spend by day in the period. */
731 days: { day: string; micros: number }[];
732};
733
734/**
735 * What each effort level has cost one agent, from its own finished
736 * sessions (docs.g1t.sh/guides/spend/#effort): measured, never estimated
737 * from other agents or list prices. A level it has not run at has no
738 * figures.
739 */
740export type EffortCost = {
741 effort: EffortLevel;
742 /** Its sessions (with everything they brought in) that finished in the window. */
743 sessions: number;
744 /** The median charged for one of them: a typical task. Null with none. */
745 typical_micros: number | null;
746 /** Of those, the share finished with nobody having to step in: no steering, not stopped or failed. Null with none. */
747 accepted_share: number | null;
748};
749
750export type AgentEffortCosts = {
751 handle: string;
752 /** Its setting now. */
753 effort: AgentEffort;
754 /** Days of history the figures cover. */
755 window_days: number;
756 levels: EffortCost[];
757};
758
759/** One side of a recommendation's evidence: the agent's sessions at one level. */
760export type EffortEvidence = {
761 effort: EffortLevel;
762 sessions: number;
763 /** Finished with nobody having to step in. */
764 accepted: number;
765 typical_micros: number;
766 mean_micros: number;
767};
768
769/**
770 * A way to spend less without losing quality, checked against the agent's
771 * own past work (docs.g1t.sh/guides/spend/#spend-less-keep-quality). The
772 * weekly check proposes one only when the cheaper level's measured
773 * outcomes hold up; when there is too little history to tell, it says so
774 * (`thin`) instead of proposing anything.
775 */
776export type AgentRecommendation = {
777 id: string;
778 agent_id: string;
779 agent_handle: string;
780 agent_name: string;
781 agent_avatar_seed: string;
782 agent_look: AgentLook | null;
783 /** Lowering its effort setting. */
784 kind: "effort";
785 /** `thin`: not enough history to recommend anything yet. */
786 status: "open" | "applied" | "dismissed" | "thin";
787 from_effort: AgentEffort;
788 to_effort: EffortLevel;
789 /** What it says to do, in a line. */
790 title: string;
791 /** Why, from the numbers in `evidence`, in a sentence. */
792 reason: string;
793 /** What it was measured on: the level it runs at now, and the cheaper one. Null sides had no sessions. */
794 evidence: { window_days: number; current: EffortEvidence | null; cheaper: EffortEvidence | null; needed: number };
795 /** About what a month it would save at the recent pace, from the measured costs. Null when thin. */
796 saving_month_micros: number | null;
797 checked_at: string;
798 resolved_by: string | null;
799 resolved_at: string | null;
800};
801
802export type AgentRecommendations = {
803 /** When the check last ran for the workspace; null before the first. */
804 checked_at: string | null;
805 window_days: number;
806 /** To act on, largest saving first. */
807 open: AgentRecommendation[];
808 /** Agents with too little history to say. */
809 thin: AgentRecommendation[];
810 /** Applied or dismissed in the last 30 days. */
811 resolved: AgentRecommendation[];
812};
813
814/** Agents mode's front page. */
815export type AgentsOverview = {
816 policy: AgentPolicy;
817 /** Every agent's spend this month, against the policy's budget. */
818 spent_month_micros: number;
819 /** The highest alert this month: 75, 90 or 100 (% of the workspace's agent budget). */
820 alert: number | null;
821 agents: WorkspaceAgent[];
822 /** Live sessions, counted by agent id, for the roster. */
823 live_by_agent: Record<string, number>;
824 /** Sessions live now that the viewer can see. */
825 live: AgentSession[];
826 /** Sessions waiting on the viewer: spend they may approve. */
827 waiting_on_you: AgentSession[];
828 /** Recently finished sessions the viewer can see. */
829 recent: AgentSession[];
830 /** The next routines to run on a schedule. */
831 upcoming: (AgentRoutine & { agent_handle: string; agent_name: string })[];
832 spend: AgentSpendBreakdown;
833 can_manage: boolean;
834};
835
836/** One thing an agent did, for its Activity tab. */
837export type AgentActivity = {
838 id: string;
839 kind: "reply" | "session";
840 status: string;
841 channel_id: string;
842 channel_name: string | null;
843 /** The session's title; null for a reply or one the viewer can't see. */
844 title: string | null;
845 asked_by_username: string | null;
846 model: string | null;
847 tools: number;
848 charged_micros: number;
849 created_at: string;
850 visible: boolean;
851 /** For a reply, the message it posted; for a session, its id. */
852 ref: string | null;
853};
854
855export type AgentVersion = { version: number; changed_by: string; created_at: string; definition: Partial<NewWorkspaceAgent> };
856
857/** A card action, as chat hands it to agents. */
858export type AgentCardAction = {
859 workspace: string;
860 channel_id: string;
861 message_id: string;
862 viewer: User;
863 card: { kind: string; ref: string | null };
864 action_id: string;
865 input: string | null;
866};
867
868export type WorkspaceAgentsApi = {
869 /**
870 * The workspace's agents. Personal agents are left out unless asked
871 * for: `mine`, the viewer's own; `all`, every member's for an owner (the
872 * viewer's own for anyone else).
873 */
874 list(workspace: string, viewer: User, options?: { personal?: "mine" | "all" | null }): Promise<Result<WorkspaceAgent[]>>;
875 get(workspace: string, handle: string, viewer: User): Promise<Result<WorkspaceAgent>>;
876 /** Internal: by id, for the chat service resolving members. */
877 byIds(ids: string[]): Promise<WorkspaceAgent[]>;
878 /**
879 * `teams`: the workspace's teams to add it to as it is made, by slug,
880 * each one the viewer manages (owners and the team's maintainers). The
881 * membership is the team's, as anyone's is; a personal agent joins none.
882 */
883 create(workspace: string, viewer: User, input: NewWorkspaceAgent, options?: { teams?: string[] }): Promise<Result<WorkspaceAgent>>;
884 update(
885 workspace: string,
886 handle: string,
887 viewer: User,
888 changes: Partial<NewWorkspaceAgent>,
889 ): Promise<Result<WorkspaceAgent>>;
890 archive(workspace: string, handle: string, viewer: User): Promise<Result<null>>;
891 /**
892 * The workspace's archived agents, newest archived first: every one for
893 * an owner, their own archived personal agents for anyone else.
894 */
895 listArchived(workspace: string, viewer: User): Promise<Result<ArchivedAgent[]>>;
896 /**
897 * Brings an archived agent back, under its handle or `options.handle`.
898 * `conflict` when a live agent holds the handle. Owners any agent, a
899 * member their own personal one.
900 */
901 restore(workspace: string, handle: string, viewer: User, options?: { handle?: string | null; id?: string | null }): Promise<Result<WorkspaceAgent>>;
902 /**
903 * Deletes an archived agent for good: its definition and versions,
904 * sessions, replies, memories, routines, drafts and computer, and its
905 * chat memberships. Its messages stay in chat under its last name, and
906 * its spend on the workspace's statement. `confirm` must be the handle.
907 * A live agent is archived first (`invalid`). Owners any agent, a member
908 * their own personal one; a second call is `not_found`.
909 */
910 destroy(workspace: string, handle: string, viewer: User, confirm: string, options?: { id?: string | null }): Promise<Result<null>>;
911 /**
912 * Drafts a whole agent from a description, with a fast model call charged
913 * to the viewer. Nothing is saved. Whoever may create the agent may draft it.
914 */
915 draft(workspace: string, viewer: User, input: { description: string; scope?: WorkspaceAgentScope | null }): Promise<Result<AgentProposal>>;
916 /**
917 * Try it: the unsaved definition answers the conversation so far, as it
918 * would in a direct message, without tools or memory. Charged to the
919 * viewer; nothing is saved.
920 */
921 tryDraft(workspace: string, viewer: User, input: { definition: NewWorkspaceAgent; messages: DraftTurn[] }): Promise<Result<DraftReply>>;
922 /** Drafts changes to an agent from a request in words; saved only through `update`. Whoever may change the agent may ask. */
923 redraft(workspace: string, handle: string, viewer: User, request: string): Promise<Result<AgentRedraft>>;
924 /**
925 * Owners make a member's personal agent a workspace agent: its definition
926 * and every version move to a workspace agent with the same handle, and
927 * the personal one is archived, with its memory and direct messages.
928 */
929 promote(workspace: string, handle: string, viewer: User): Promise<Result<WorkspaceAgent>>;
930 /**
931 * Adds an MCP server to an agent (docs.g1t.sh/guides/agent-abilities/,
932 * "MCP servers"): its host is checked, its tools are listed from it, and
933 * the agent gets a new version with each tool as an ability. Owners only.
934 */
935 addMcpServer(workspace: string, handle: string, viewer: User, input: { name: string; url: string }): Promise<Result<McpServer>>;
936 /** Takes an MCP server off an agent, with its abilities: a new version. Owners only. */
937 removeMcpServer(workspace: string, handle: string, viewer: User, id: string): Promise<Result<null>>;
938 /** Lists a server's tools again, for one that changed; a new version when they did. Owners only. */
939 refreshMcpServer(workspace: string, handle: string, viewer: User, id: string): Promise<Result<McpServer>>;
940 templates(): Promise<AgentTemplate[]>;
941 /**
942 * Internal: the workspace's built-in `@g1t` agent, made if it does not
943 * exist yet. The chat service asks for it when someone mentions @g1t in
944 * a channel it is not in yet.
945 */
946 builtin(workspace: string, workspaceId: string): Promise<Result<WorkspaceAgent>>;
947 /** The chat service hands over a message for an agent to answer. Returns at once. */
948 deliver(delivery: AgentDelivery): Promise<Result<null>>;
949 overview(workspace: string, viewer: User): Promise<Result<AgentsOverview>>;
950 sessions(
951 workspace: string,
952 viewer: User,
953 filter?: { handle?: string | null; status?: "live" | "done" | null; limit?: number | null },
954 ): Promise<Result<AgentSession[]>>;
955 session(workspace: string, id: string, viewer: User): Promise<Result<AgentSessionDetail>>;
956 /** Stops a session and every session under it. */
957 stopSession(workspace: string, id: string, viewer: User): Promise<Result<AgentSession>>;
958 /** Raises a stopped session's cap and lets it go on. Owners only. */
959 approveSession(workspace: string, id: string, viewer: User, capMicros: number): Promise<Result<AgentSession>>;
960 /** A person's message to a session, running or finished: it reads it and goes on. */
961 steerSession(workspace: string, id: string, viewer: User, body: string): Promise<Result<AgentSession>>;
962 /**
963 * The agent's computer: its state, disk and recent commands. Anyone who
964 * may see the agent; `can_manage` says whether the viewer may act on it.
965 */
966 computer(workspace: string, handle: string, viewer: User): Promise<Result<AgentComputerView>>;
967 /** Wakes it, restoring its home; metered until it sleeps. Owners, or a personal agent's member. */
968 wakeComputer(workspace: string, handle: string, viewer: User): Promise<Result<AgentComputerView>>;
969 /** Saves its home and stops it. Owners, or a personal agent's member. */
970 sleepComputer(workspace: string, handle: string, viewer: User): Promise<Result<AgentComputerView>>;
971 /** Wipes its home and its command history; memory and artifacts are kept. Owners, or a personal agent's member. */
972 resetComputer(workspace: string, handle: string, viewer: User): Promise<Result<AgentComputerView>>;
973 /** Its recent commands, newest first; `sessionId` narrows them to one session's. */
974 computerCommands(workspace: string, handle: string, viewer: User, sessionId?: string | null): Promise<Result<AgentComputerCommand[]>>;
975 memories(workspace: string, handle: string, viewer: User): Promise<Result<AgentMemory[]>>;
976 remember(
977 workspace: string,
978 handle: string,
979 viewer: User,
980 input: { body: string; scope: AgentMemoryScope; scope_ref?: string | null },
981 ): Promise<Result<AgentMemory>>;
982 updateMemory(
983 workspace: string,
984 handle: string,
985 viewer: User,
986 id: string,
987 changes: { body?: string; pinned?: boolean },
988 ): Promise<Result<AgentMemory>>;
989 forget(workspace: string, handle: string, viewer: User, id: string): Promise<Result<null>>;
990 routines(workspace: string, handle: string, viewer: User): Promise<Result<{ routines: AgentRoutine[]; suggestions: RoutineSuggestion[] }>>;
991 saveRoutine(workspace: string, handle: string, viewer: User, input: NewRoutine, id?: string | null): Promise<Result<AgentRoutine>>;
992 deleteRoutine(workspace: string, handle: string, viewer: User, id: string): Promise<Result<null>>;
993 /** Runs a routine now, as a session. */
994 runRoutine(workspace: string, handle: string, viewer: User, id: string): Promise<Result<AgentSession>>;
995 /**
996 * Where the spend went: one agent's, or every agent's; this month unless
997 * `period` says otherwise; for everyone, or only the work one `person`
998 * (by username) asked for.
999 */
1000 spend(workspace: string, viewer: User, handle?: string | null, options?: { period?: SpendPeriod | null; person?: string | null }): Promise<Result<AgentSpendBreakdown>>;
1001 /** Budgets per person this month: owners see everyone's, anyone else their own. */
1002 personBudgets(workspace: string, viewer: User): Promise<Result<PersonBudgets>>;
1003 /**
1004 * Gives one person a monthly budget of their own (`monthly_micros`; 0 for
1005 * no budget at all), or with null puts them back on the default. Owners only.
1006 */
1007 setPersonBudget(workspace: string, viewer: User, username: string, monthlyMicros: number | null): Promise<Result<PersonBudgets>>;
1008 activity(workspace: string, handle: string, viewer: User): Promise<Result<AgentActivity[]>>;
1009 /** What each effort level has cost this agent, from its own finished sessions. Members only. */
1010 effortCosts(workspace: string, handle: string, viewer: User): Promise<Result<AgentEffortCosts>>;
1011 /** Ways to spend less, checked against past work: every agent's, or one's. Members only. */
1012 recommendations(workspace: string, viewer: User, handle?: string | null): Promise<Result<AgentRecommendations>>;
1013 /**
1014 * Owners apply one (the agent's effort changes, as a new version, and
1015 * the audit log says so) or dismiss it.
1016 */
1017 resolveRecommendation(workspace: string, viewer: User, id: string, action: "apply" | "dismiss"): Promise<Result<AgentRecommendation>>;
1018 /** What an agent is told about its teams this turn, word for word. Members only. */
1019 teamContext(workspace: string, handle: string, viewer: User): Promise<Result<AgentTeamContext>>;
1020 versions(workspace: string, handle: string, viewer: User): Promise<Result<AgentVersion[]>>;
1021 /**
1022 * Internal, from chat: a person pressed an action on one of agents'
1023 * cards. Agents checks they may, acts, and updates the card.
1024 */
1025 cardAction(input: AgentCardAction): Promise<Result<CardActionResult>>;
1026 policy(workspace: string, viewer: User): Promise<Result<AgentPolicy>>;
1027 setPolicy(workspace: string, viewer: User, policy: Partial<AgentPolicy>): Promise<Result<AgentPolicy>>;
1028 /**
1029 * The Marketplace's install requests (./marketplace.ts): every one in the
1030 * workspace for an owner, a member's own for anyone else.
1031 */
1032 installRequests(workspace: string, viewer: User): Promise<Result<InstallRequests>>;
1033 /**
1034 * A member asks the workspace's owners to add a listing
1035 * (`extension:<id>` or `integration:<connector>`), and every owner is
1036 * notified. Owners add
1037 * things themselves, so they don't ask. Asking again while a request for
1038 * the same listing is open is a conflict.
1039 */
1040 requestInstall(workspace: string, viewer: User, listing: string, note?: string | null): Promise<Result<InstallRequest>>;
1041 /** An owner marks a request added (`done`) or turns it down (`declined`); whoever asked is told. */
1042 resolveInstallRequest(workspace: string, viewer: User, id: string, status: Exclude<InstallRequestStatus, "open">): Promise<Result<InstallRequest>>;
1043 /** The extensions installed in the workspace; any member sees them. */
1044 extensionInstalls(workspace: string, viewer: User): Promise<Result<ExtensionInstall[]>>;
1045 /** Owners install a published extension at its current version; open requests for it are answered. */
1046 installExtension(workspace: string, viewer: User, extension: string): Promise<Result<ExtensionInstall>>;
1047 /** Owners switch an install on or off: off is the kill switch. */
1048 setExtensionEnabled(workspace: string, viewer: User, listing: string, enabled: boolean): Promise<Result<ExtensionInstall>>;
1049 /** Owners cap what an install spends a month; null leaves it to the workspace's limit. */
1050 setExtensionBudget(workspace: string, viewer: User, listing: string, monthlyMicros: number | null): Promise<Result<ExtensionInstall>>;
1051 uninstallExtension(workspace: string, viewer: User, listing: string): Promise<Result<null>>;
1052};
1053
1054async function rpc<T>(service: ServiceBinding, method: string, args: object): Promise<T> {
1055 const response = await service.fetch(`https://service/rpc/${method}`, {
1056 method: "POST",
1057 headers: { "content-type": "application/json" },
1058 body: JSON.stringify(args),
1059 });
1060 if (!response.ok) {
1061 throw new Error(`${method} failed with status ${response.status}`);
1062 }
1063 return (await response.json()) as T;
1064}
1065
1066/**
1067 * What an agent is told about its teams every turn (docs.g1t.sh/guides/people-and-teams/,
1068 * "What agents are told"): the visible teams it is on, by slug, and the text
1069 * itself; null when it is on none.
1070 */
1071export type AgentTeamContext = { handle: string; teams: string[]; text: string | null };
1072
1073export function workspaceAgentsClient(service: ServiceBinding): WorkspaceAgentsApi {
1074 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
1075 return {
1076 list: (workspace, viewer, options) => call("list", { workspace, viewer, personal: options?.personal ?? null }),
1077 get: (workspace, handle, viewer) => call("get", { workspace, handle, viewer }),
1078 byIds: (ids) => call("by_ids", { ids }),
1079 create: (workspace, viewer, input, options) => call("create", { workspace, viewer, input, teams: options?.teams ?? [] }),
1080 update: (workspace, handle, viewer, changes) => call("update", { workspace, handle, viewer, changes }),
1081 archive: (workspace, handle, viewer) => call("archive", { workspace, handle, viewer }),
1082 listArchived: (workspace, viewer) => call("list_archived", { workspace, viewer }),
1083 restore: (workspace, handle, viewer, options) => call("restore", { workspace, handle, viewer, id: options?.id ?? null, new_handle: options?.handle ?? null }),
1084 destroy: (workspace, handle, viewer, confirm, options) => call("destroy", { workspace, handle, viewer, confirm, id: options?.id ?? null }),
1085 draft: (workspace, viewer, input) => call("draft", { workspace, viewer, description: input.description, scope: input.scope ?? null }),
1086 tryDraft: (workspace, viewer, input) => call("try_draft", { workspace, viewer, definition: input.definition, messages: input.messages }),
1087 redraft: (workspace, handle, viewer, request) => call("redraft", { workspace, handle, viewer, request }),
1088 promote: (workspace, handle, viewer) => call("promote", { workspace, handle, viewer }),
1089 addMcpServer: (workspace, handle, viewer, input) => call("add_mcp_server", { workspace, handle, viewer, name: input.name, url: input.url }),
1090 removeMcpServer: (workspace, handle, viewer, id) => call("remove_mcp_server", { workspace, handle, viewer, id }),
1091 refreshMcpServer: (workspace, handle, viewer, id) => call("refresh_mcp_server", { workspace, handle, viewer, id }),
1092 templates: () => call("templates", {}),
1093 builtin: (workspace, workspaceId) => call("builtin", { workspace, workspace_id: workspaceId }),
1094 deliver: (delivery) => call("deliver", delivery),
1095 overview: (workspace, viewer) => call("overview", { workspace, viewer }),
1096 sessions: (workspace, viewer, filter) => call("sessions", { workspace, viewer, ...(filter ?? {}) }),
1097 session: (workspace, id, viewer) => call("session", { workspace, id, viewer }),
1098 stopSession: (workspace, id, viewer) => call("stop_session", { workspace, id, viewer }),
1099 approveSession: (workspace, id, viewer, capMicros) => call("approve_session", { workspace, id, viewer, cap_micros: capMicros }),
1100 steerSession: (workspace, id, viewer, body) => call("steer_session", { workspace, id, viewer, body }),
1101 computer: (workspace, handle, viewer) => call("computer", { workspace, handle, viewer }),
1102 wakeComputer: (workspace, handle, viewer) => call("computer_wake", { workspace, handle, viewer }),
1103 sleepComputer: (workspace, handle, viewer) => call("computer_sleep", { workspace, handle, viewer }),
1104 resetComputer: (workspace, handle, viewer) => call("computer_reset", { workspace, handle, viewer }),
1105 computerCommands: (workspace, handle, viewer, sessionId) => call("computer_commands", { workspace, handle, viewer, session_id: sessionId ?? null }),
1106 memories: (workspace, handle, viewer) => call("memories", { workspace, handle, viewer }),
1107 remember: (workspace, handle, viewer, input) => call("remember", { workspace, handle, viewer, input }),
1108 updateMemory: (workspace, handle, viewer, id, changes) => call("update_memory", { workspace, handle, viewer, id, changes }),
1109 forget: (workspace, handle, viewer, id) => call("forget", { workspace, handle, viewer, id }),
1110 routines: (workspace, handle, viewer) => call("routines", { workspace, handle, viewer }),
1111 saveRoutine: (workspace, handle, viewer, input, id) => call("save_routine", { workspace, handle, viewer, input, id: id ?? null }),
1112 deleteRoutine: (workspace, handle, viewer, id) => call("delete_routine", { workspace, handle, viewer, id }),
1113 runRoutine: (workspace, handle, viewer, id) => call("run_routine", { workspace, handle, viewer, id }),
1114 spend: (workspace, viewer, handle, options) =>
1115 call("spend", { workspace, viewer, handle: handle ?? null, period: options?.period ?? null, person: options?.person ?? null }),
1116 personBudgets: (workspace, viewer) => call("person_budgets", { workspace, viewer }),
1117 teamContext: (workspace, handle, viewer) => call("team_context", { workspace, handle, viewer }),
1118 setPersonBudget: (workspace, viewer, username, monthlyMicros) =>
1119 call("set_person_budget", { workspace, viewer, username, monthly_micros: monthlyMicros }),
1120 activity: (workspace, handle, viewer) => call("activity", { workspace, handle, viewer }),
1121 effortCosts: (workspace, handle, viewer) => call("effort_costs", { workspace, handle, viewer }),
1122 recommendations: (workspace, viewer, handle) => call("recommendations", { workspace, viewer, handle: handle ?? null }),
1123 resolveRecommendation: (workspace, viewer, id, action) => call("resolve_recommendation", { workspace, viewer, id, action }),
1124 versions: (workspace, handle, viewer) => call("versions", { workspace, handle, viewer }),
1125 cardAction: (input) => call("card_action", input),
1126 policy: (workspace, viewer) => call("policy", { workspace, viewer }),
1127 setPolicy: (workspace, viewer, policy) => call("set_policy", { workspace, viewer, policy }),
1128 installRequests: (workspace, viewer) => call("install_requests", { workspace, viewer }),
1129 requestInstall: (workspace, viewer, listing, note) => call("request_install", { workspace, viewer, listing, note: note ?? null }),
1130 resolveInstallRequest: (workspace, viewer, id, status) => call("resolve_install_request", { workspace, viewer, id, status }),
1131 extensionInstalls: (workspace, viewer) => call("extension_installs", { workspace, viewer }),
1132 installExtension: (workspace, viewer, extension) => call("install_extension", { workspace, viewer, extension }),
1133 setExtensionEnabled: (workspace, viewer, listing, enabled) => call("set_extension_enabled", { workspace, viewer, listing, enabled }),
1134 setExtensionBudget: (workspace, viewer, listing, monthlyMicros) => call("set_extension_budget", { workspace, viewer, listing, monthly_micros: monthlyMicros }),
1135 uninstallExtension: (workspace, viewer, listing) => call("uninstall_extension", { workspace, viewer, listing }),
1136 };
1137}