Skip to content

Commit 1c84640

Browse files
authored
docs(ai-sre): audit drift fixes + Automations & GitHub App pages (#96)
* docs(ai-sre): audit-driven drift fixes + Automations & GitHub App pages Audit of the ai-sre module (fc-safari@feat/ai-sre + ai-sre-web@feat/ai-sre) against the zh/en docs. 19 findings (4 high, 8 medium, 7 low) applied. New pages: - automations: scheduled / API-triggered hidden sessions (cron, templates, run history) - github: GitHub App (connect org, per-turn repo-scoped token, gh/git in the repo) Fixes to existing pages: - insight: 3-layer -> 6-part report; keep-rule >=2 user turns OR >=3 tool calls; verbatim-quote evidence (session IDs internal-only); balanced coach framing - mcp: mcp_load -> tool_search; settings-side connector authorization surface; marketplace card vs detail; requires_runner vs stdio - agents: add Subagent concept (20-concurrency cap, depth 3); drop fabricated emoji - sessions: sandbox lifecycle card, session feedback, 9-file attachment cap, auto-naming - skills: bundled github skill, .zip/.skill/.tar.gz/.tgz archives, slash-arg substitution - overview + docs.json: register and link the two new pages * docs(ai-sre): use "MCP server" term + GitHub repo re-auth note (review) Addresses PR #96 review feedback: - mcp/github: drop the non-product term "连接器"/"Connector" (zero usage in the FE); use the actual user-facing "MCP 服务器 / MCP Server" (marketplace = MCP 市场 / MCP Directory) - github: add an "add/adjust repository access" subsection — re-authorize to re-sync granted repos (setup_action=update), with an uninstall-and- reauthorize fallback via the App's GitHub Configure → Danger zone Subagent concurrency wording ("最多同时运行 20 个 Subagent") verified correct against types/task.go + logic/task/service.go — no change. * docs(ai-sre): rename GitHub App page to "Apps" to match the console tab (review) The console tab is literally "Apps" (GitHub is its current sole app, shown as a card inside it) — the same way the skills/agents/mcp pages map to the other Plugins sub-tabs. Rename github.mdx -> apps.mdx, retitle to "Apps", and frame GitHub as the current (only) app. Update docs.json nav, the overview capability card + the Plugins sub-tab list (now four: Apps/Skill/Agents/MCP), and the skills.mdx cross-link.
1 parent cd15c8b commit 1c84640

17 files changed

Lines changed: 1017 additions & 67 deletions

docs.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@
551551
"icon": "comments",
552552
"pages": [
553553
"zh/ai-sre/sessions",
554-
"zh/ai-sre/im"
554+
"zh/ai-sre/im",
555+
"zh/ai-sre/automations"
555556
]
556557
},
557558
{
@@ -560,7 +561,8 @@
560561
"pages": [
561562
"zh/ai-sre/mcp",
562563
"zh/ai-sre/skills",
563-
"zh/ai-sre/agents"
564+
"zh/ai-sre/agents",
565+
"zh/ai-sre/apps"
564566
]
565567
},
566568
{
@@ -1654,7 +1656,8 @@
16541656
"icon": "comments",
16551657
"pages": [
16561658
"en/ai-sre/sessions",
1657-
"en/ai-sre/im"
1659+
"en/ai-sre/im",
1660+
"en/ai-sre/automations"
16581661
]
16591662
},
16601663
{
@@ -1663,7 +1666,8 @@
16631666
"pages": [
16641667
"en/ai-sre/mcp",
16651668
"en/ai-sre/skills",
1666-
"en/ai-sre/agents"
1669+
"en/ai-sre/agents",
1670+
"en/ai-sre/apps"
16671671
]
16681672
},
16691673
{

en/ai-sre/agents.mdx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,42 @@ sidebarTitle: Agent
2424
</Card>
2525
</CardGroup>
2626

27-
Delegation does not make you wait: after AI SRE hands a task to a remote agent, the conversation continues immediately, so you can keep working or delegate several tasks at once. When the remote agent finishes, its result appears in the conversation as a new message. Each A2A delegation appears in the conversation stream as a **task card** (🛰️) showing the remote agent name, task intent, run status (initializing / in progress / completed / failed / interrupted), and usage metrics such as tool call count, tokens, and elapsed time. Click the card to view the full delegation trace in the right-hand panel.
27+
Delegation does not make you wait: after AI SRE hands a task to a remote agent, the conversation continues immediately, so you can keep working or delegate several tasks at once. When the remote agent finishes, its result appears in the conversation as a new message. Each A2A delegation appears in the conversation stream as a **task card** carrying an `A2A` badge, showing the remote agent name, task intent, run status (initializing / in progress / completed / failed / interrupted), and usage metrics such as tool call count, tokens, and elapsed time. Click the card to view the full delegation trace in the right-hand panel.
2828

2929
<Tip>
3030
**The description is the core signal for agent selection.** Before delegating, AI SRE sees a list of available agents where each entry is `name: description`. Write descriptions as prescriptive imperatives (e.g., "USE THIS FIRST for …", "prefer-over-X when …") that clearly state **when to prefer this agent, what it excels at, and what it is not suited for** — the more precise the description, the better AI SRE can delegate the right task to the right agent.
3131
</Tip>
3232

3333
The A2A agent list and management entry point are on the **Plugins → Agents** page (menu tab labeled **Agents**).
3434

35+
<Note>
36+
**Agents covers two distinct concepts.** This page (Agents) currently manages **A2A Agents** (external agent-to-agent calls). The other concept is the **Subagent** — a platform-built-in task executor that AI SRE dispatches on demand within a session. Subagents have no create / edit entry point; you only observe their behavior in sessions. See "[Subagent](#subagent)" below.
37+
</Note>
38+
39+
## Subagent
40+
41+
---
42+
43+
A **Subagent** is a platform **built-in** task executor. During an investigation, AI SRE can **dispatch** a self-contained subtask to a Subagent that completes it independently — dispatch always goes through the single long-running tool `agent_dispatch`, rather than exposing a separate tool per Subagent.
44+
45+
The platform ships several **bootstrap Subagents** that work out of the box:
46+
47+
| Name | Role |
48+
| --- | --- |
49+
| `general` | General-purpose worker with full tool access. Use it to offload work whose intermediate steps would otherwise pollute the parent's context (long reports, multi-file edits, end-to-end builds, repeated probing). Dispatch several in parallel for independent units of work |
50+
| `explore` | Read-only investigator restricted to `grep` / `glob` / `read`; it cannot write or execute. Returns a compact summary rather than raw search output — ideal for locating evidence inside a codebase or knowledge dump |
51+
52+
**In the conversation**: each dispatch also appears as a **task card** in the conversation stream and shares the same status lifecycle as an A2A delegation (initializing / in progress / completed / failed / interrupted). The difference is the badge — a Subagent task card carries an `Agent` badge, whereas an A2A delegation carries an `A2A` badge.
53+
54+
**Runtime limits**:
55+
56+
- **Concurrency cap**: a session runs **at most 20 Subagents concurrently** (`TaskMaxConcurrentPerSession = 20`). This caps how many run at the same instant, not how many a session dispatches over its lifetime — completing one frees a slot, so total work is unbounded. Dispatching past the cap errors (`too many active subagents (… running, limit 20)`), prompting the model to stop and wait for the running ones to finish before dispatching the rest.
57+
- **Nesting depth**: a dispatch chain nests **at most 3 levels deep** (`TaskMaxNestingDepth = 3`), preventing a Subagent from spawning itself indefinitely.
58+
59+
<Note>
60+
**Subagents currently have no user-facing create / management UI.** They are a built-in runtime capability: you can observe Subagent task cards and their sub-session traces within a session, but you cannot add, edit, or delete a Subagent the way you can an A2A Agent. This page (Agents) currently manages only A2A Agents.
61+
</Note>
62+
3563
## Registering an Outbound A2A Agent
3664

3765
---

en/ai-sre/apps.mdx

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
title: Apps
3+
description: Apps are authorized external applications in AI SRE — currently GitHub. Once authorized, the agent can work directly inside your code repositories: read code, investigate recent changes / commits / PRs, trace a PR from a change ticket, and (when you ask) fix a bug, open a PR, or file an issue. It all runs through plain gh / git, using a short-lived, repo-scoped GitHub App token issued per turn.
4+
keywords: ["AI SRE", "Apps", "GitHub App", "App", "gh", "git", "repository", "pull request", "issue", "installation token", "Customize"]
5+
sidebarTitle: Apps
6+
---
7+
8+
<Info>
9+
**Private beta**: AI SRE is currently in private beta and available to invited accounts only. To join the whitelist test, contact the Flashduty sales team to request access; features and the UI may change during the beta.
10+
</Info>
11+
12+
## Overview
13+
14+
---
15+
16+
An **App** is an authorized external application — today there is exactly one, **GitHub**. Once you authorize a GitHub App, AI SRE can **work directly inside your GitHub repositories** during a session: understand and explore code, investigate recent changes / commits / PRs, trace a PR from a change ticket, answer questions about a codebase, and — when you ask — fix a bug, open a PR, or file an issue.
17+
18+
The mechanism is plain: the agent operates on your repository with native `gh` and `git` commands inside its own sandbox, using a GitHub App installation token that Safari issues **per turn** and scopes to **only the repositories you granted**. The agent never sees or types that token.
19+
20+
<Warning>
21+
The **GitHub App** on this page and the **MCP server** that uses GitHub as an example in [MCP](/en/ai-sre/mcp) are **two different mechanisms** — don't confuse them:
22+
23+
- **GitHub App (this page)**: the agent runs `gh` / `git` **directly** in its sandbox against your repository — clone, `git log`, `gh pr diff`, open a PR — like an engineer working in a terminal.
24+
- **MCP server**: the agent makes **tool calls** to a hosted MCP server, and that server performs the operation and returns the result.
25+
26+
One is "the agent runs git/gh in a shell"; the other is "the agent calls tools on a remote MCP server." This page covers only the former.
27+
</Warning>
28+
29+
## Where to Find It
30+
31+
---
32+
33+
Go to **Plugins → Apps**. Apps is the **first and default** tab in the Plugins area — opening Plugins lands you here.
34+
35+
<Note>
36+
Viewing the Apps tab requires the appropriate permission; without it, the tab is hidden. Authorizing, revoking, and enabling / disabling each require their own action permission — when you lack one, the corresponding button is shown disabled.
37+
</Note>
38+
39+
## Connecting a GitHub Organization
40+
41+
---
42+
43+
Start the authorization from the GitHub card on the Apps page. The whole install completes in a popup through GitHub's official install page, and the list refreshes automatically after the callback.
44+
45+
<Steps>
46+
<Step title="Start the authorization">
47+
Click **Authorize** on the GitHub card (if the card already has an installation, the button reads **Connect another organization**). The backend returns the GitHub App's install URL, and the frontend opens a popup of roughly **1024 × 760**.
48+
</Step>
49+
<Step title="Pick the organization and repositories on GitHub">
50+
The popup loads the GitHub App install page. Choose the **organization** (or personal account) to install into, and grant a repository scope — **All repositories** or **Only select repositories**. The set of granted repositories determines which repositories AI SRE can access afterward.
51+
</Step>
52+
<Step title="GitHub calls back, the frontend refreshes">
53+
After you confirm on GitHub, GitHub calls back to the backend; the backend 302-redirects to the frontend callback page `/ai-sre/app-callback`, which then forwards the result to the Apps tab via `postMessage` and closes the popup. On success, the Apps page shows **Authorized** and refreshes the installation list, and the new organization appears.
54+
</Step>
55+
</Steps>
56+
57+
<Note>
58+
If you are not the owner of the organization, GitHub routes the request to the organization owner through its request-to-install approval flow; the installation activates only after approval. Which organization to install into and which repositories to grant are decided entirely on GitHub's install page — Flashduty does not select on your behalf.
59+
</Note>
60+
61+
## Managing Installations
62+
63+
---
64+
65+
Each authorized organization adds one installation row under the GitHub card. Each row shows:
66+
67+
| Element | Description |
68+
|---|---|
69+
| Organization name | The GitHub organization / account login the installation lives on (`github_target`) |
70+
| Status dot | A colored dot plus a label: **Connected** (`active`), **Suspended** (`suspended`), **Revoked** (`revoked`) |
71+
| Repository count | The number of repositories currently granted to this installation |
72+
73+
<AccordionGroup>
74+
<Accordion title="Enable / Disable (suspend / resume)" icon="toggle-on">
75+
The toggle in the top-right of the card switches between Enabled and Disabled, which moves the App's installations as a whole between **active ↔ suspended**. **Disable = suspend**: while suspended, no installation token is issued and the agent can no longer reach those repositories — but the **GitHub installation itself is kept**, so you can re-enable instantly with one click, without going through the GitHub authorization again. An App counts as "enabled" as long as it has at least one **Connected** installation.
76+
</Accordion>
77+
<Accordion title="Revoke" icon="trash">
78+
Click **Revoke** on a row to open a confirmation dialog — "Revoke authorization for organization '…'? After revoking, AI SRE will no longer be able to access this organization's repositories. You can re-authorize at any time." On confirm, the installation is set to **Revoked** and no token is issued from then on; any cached token also expires naturally within its TTL of at most 1 hour. A revoked installation is hidden from the card; re-authorizing the same organization restores it.
79+
</Accordion>
80+
</AccordionGroup>
81+
82+
<Note>
83+
**Suspend** vs. **Revoke**: suspend turns it off temporarily, keeps the GitHub installation, and resumes with one click; revoke disconnects this authorization and requires going through the GitHub authorization again to use it.
84+
</Note>
85+
86+
### Adding or Adjusting Repository Access
87+
88+
The organization is already connected, but you want AI SRE to reach more of its repositories — you don't need to revoke and reconnect. In **Plugins → Apps**, click **Authorize / Connect another organization** again for that organization (or open the App's **Configure** page on GitHub directly). GitHub shows the **Repository access** screen; select the additional repositories and save. The callback takes the install callback's `setup_action=update` path, so AI SRE **re-syncs** the granted repository list automatically, and the new repositories become available without re-creating the connection.
89+
90+
<Note>
91+
**Fallback**: if a newly added repository still reports "cannot access / 404 / 403" in a session, open the Flashduty App's page on GitHub (e.g. `github.com/apps/flashduty`) → **Configure** → select the organization → scroll to the **Danger zone****Uninstall**. Then return to **Plugins → Apps** in Flashduty and authorize the organization again, granting **all** the repositories you need in one pass.
92+
</Note>
93+
94+
## How AI SRE Uses It
95+
96+
---
97+
98+
After authorization, you need no extra configuration. When you ask AI SRE to work on a task in a repository during a session, it does the work itself inside the sandbox — behavior governed by the built-in `github` Skill.
99+
100+
### The token: short-lived, repo-scoped, least-privilege
101+
102+
- **Issued per turn**: Safari injects a GitHub App installation token into the bash environment for each turn and wires `git` to use `gh`'s credential helper — `gh` reads the token automatically, and `git` HTTPS clone / push just work, with **nothing written** to `.git/config` or any URL. The token expires automatically at the end of the turn (cache TTL ≤ 1 hour); nothing to revoke.
103+
- **Least privilege**: the token carries only the permissions it needs — `contents` / `pull_requests` / `issues` are **write**, `metadata` is **read**.
104+
- **The agent never touches the token**: the agent never sees, types, pastes, or echoes it. Operations like `echo $GH_TOKEN`, `env`, `printenv`, or embedding the token in a URL (`https://x:TOKEN@github.com/...`) are blocked by the **bash guard**, so the token cannot leak into the transcript.
105+
- **Scope limited to granted repositories**: the token is scoped to the repositories granted at install. A `404` / `403` on an ungranted repository means "add that repository to the installation" — at which point the agent asks you to do so rather than trying to work around scope.
106+
107+
<Note>
108+
**Cloud sessions** use the account's GitHub App installation. If `gh auth status` reports not logged in, the account has no GitHub App installed — or it is not installed on the target repository — and the agent tells you to install the GitHub App from **Plugins → Apps** and grant the repository. It does **not** ask you for a token.
109+
110+
**BYOC sessions** are different: they use the runner host's **own `gh`** (you run `gh auth login` on the host, or set `GH_TOKEN` in the runner environment), **not** this App token. For differences between environments, see [Environments (BYOC)](/en/ai-sre/environments).
111+
</Note>
112+
113+
### Typical actions
114+
115+
The agent works like an engineer joining the project — understand first, then change, then verify:
116+
117+
- **Enter the repository**: clone it into its own workspace (`gh repo clone OWNER/REPO`) and read the repo's own conventions first (`CLAUDE.md`, `AGENTS.md`, `README`, `CONTRIBUTING`).
118+
- **Investigate changes / PRs**: `git log`, `gh pr list`, `gh pr view <number>`, `gh pr diff <number>`, `gh search prs` — to trace a PR named in an incident or change ticket, see what a release shipped, or read a diff before deciding anything.
119+
- **Change and propose**: create a branch, make a minimal diff, open a reviewable PR with `gh pr create`, or file an issue with `gh issue create`, and report the PR / issue URL back to you.
120+
121+
### Hard guardrails
122+
123+
The agent never crosses these:
124+
125+
- **Never force-push** (`git push --force` / `-f`).
126+
- **Never push the default branch directly** — always a branch + PR.
127+
- **One logical change per PR**, kept reviewable; if a change balloons beyond a focused diff, it stops and hands the analysis back to you.
128+
- Never delete branches, close others' issues / PRs, or change repository settings; never commit secrets, credentials, or build artifacts.
129+
130+
## Permissions & Scope
131+
132+
---
133+
134+
GitHub App **authorize** and **revoke** are **account-level** operations (`team_id = 0`). **The account is the only security boundary**; the team here is just an ownership / audit tag:
135+
136+
- **Who can authorize / revoke / enable / disable**: **any** account member with the corresponding action permission can authorize a new organization, revoke any installation, or enable / disable the whole App — these operations act on all installations in the account, not narrowed by team.
137+
- **Runtime token resolution is account-level too**: when a session needs a repository, the token is resolved and minted from **any connected installation in the account** (`ResolveSessionToken` does not filter by team). Members of an account share one authorization — consistent with AI SRE's "usage = account-level, ownership = team tag" model for other resources.
138+
139+
## Related Pages
140+
141+
---
142+
143+
<CardGroup cols={2}>
144+
<Card title="MCP (External Tools)" icon="plug" href="/en/ai-sre/mcp">
145+
The other way to connect external capabilities: tool calls to a hosted MCP server.
146+
</Card>
147+
<Card title="Console" icon="comments" href="/en/ai-sre/sessions">
148+
Watch the agent clone a repo, read a diff, and open a PR during a session.
149+
</Card>
150+
<Card title="BYOC" icon="server" href="/en/ai-sre/environments">
151+
BYOC sessions use the runner host's own gh, not the account's GitHub App token.
152+
</Card>
153+
<Card title="Skills" icon="wrench" href="/en/ai-sre/skills">
154+
The built-in github Skill governs how the agent works inside a repository.
155+
</Card>
156+
</CardGroup>

0 commit comments

Comments
 (0)