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