Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
8b6044e
get_session_brief: the coding-session kickoff from the Server
boehlerlukas Nov 21, 2026
854aa26
test(session): get_session_brief reads the brief from the Server's ag…
LucaB01 Nov 18, 2026
8b469ed
fix(session): get_session_brief reads the Server's agent-workflow route
LucaB01 Nov 18, 2026
230dfd1
test(session): get_session_brief imports the TypeScript sources, as m…
LucaB01 Nov 18, 2026
69f9302
fix: instructions match the Server, a code-fix session never writes t…
boehlerlukas Nov 23, 2026
b58ba5d
Merge remote-tracking branch 'origin/main' into operator/session-brief
boehlerlukas Nov 24, 2026
7c0c185
Merge remote-tracking branch 'origin/main' into operator/session-brief
boehlerlukas Nov 25, 2026
5fd32c3
feat(progress): antigravity as a report_progress agentKind
boehlerlukas Nov 25, 2026
dc905c9
feat(operator): solve_ticket prompt, session rules defer to the brief
boehlerlukas Nov 28, 2026
6857eb2
Merge branch 'operator/session-brief' into operator/solve-ticket
boehlerlukas Nov 28, 2026
38a4c9b
Merge origin/main into operator/solve-ticket
boehlerlukas Nov 28, 2026
a6d788e
test: list_skills and get_skill read the skill library, a customer-sc…
boehlerlukas Nov 29, 2026
09b7124
feat: list_skills and get_skill serve the workspace's skills from Gleap
boehlerlukas Nov 29, 2026
fb586ed
test: list_ticket_tools and call_ticket_tool pass a session's ticket …
boehlerlukas Nov 29, 2026
cbeb34e
feat: list_ticket_tools and call_ticket_tool give a coding session Op…
boehlerlukas Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ A coding agent working a Gleap ticket names its coding session, with the `sessio

Without a session id nothing changes: no header, no extra lines.

The deep link that starts a session carries only one line with the session id. The agent's first call is `get_session_brief` with that id: its result is the whole kickoff (ticket, rules, findings, repository, the Gleap plugin skill to load). A kickoff without a session id works by ticket, as before.

## Available Tools

| Tool | Description |
Expand All @@ -76,14 +78,14 @@ Without a session id nothing changes: no header, no extra lines.
| `get_ticket_types` | List ticket types with their custom fields, status lanes and priorities |
| `get_ticket_messages` | Get the full conversation history (messages) for a ticket |
| `get_ticket_activity_log` | Get the console logs, network requests and click trail the SDK captured with a ticket. Coding agents call it on bug reports before reproducing, to see the console errors, failed requests and the user's clicks. Headers are never returned, secrets are redacted and long logs are trimmed (errors and failed requests first); `section` and `search` narrow it |
| `send_message` | Reply to a customer or add an internal note (Markdown). Agent workflows: the agent asks its operator in its own conversation (an instruction to answer or update the customer is the approval), then sends; with `sessionId` the reply is the session agent's and Gleap refuses a stale one (`stale_thread`, with the new messages) or one after a stop |
| `draft_reply_to_composer` | Stage a drafted reply in the ticket's dashboard composer for a person to review, edit and send. Sends nothing. For a person's own AI client, also when a `.gleap/session.json` from another ticket is still around: Gleap refuses Kai runs and the coding session working that ticket (410), which ask their operator and send with `send_message` |
| `send_message` | Reply to a customer or add an internal note (Markdown). A session started from a ticket's code fix never sends to the customer (Gleap refuses it; it drafts in `report_progress`). Other agent workflows send as the session's brief says (a solve session writes to the customer itself, as the workspace's reply rule says); where the brief says nothing, the agent asks its operator in its own conversation first (an instruction to answer or update the customer is the approval), then sends; with `sessionId` the reply is the session agent's and Gleap refuses a stale one (`stale_thread`, with the new messages) or one after a stop |
| `draft_reply_to_composer` | Stage a drafted reply in the ticket's dashboard composer for a person to review, edit and send. Sends nothing. For a person's own AI client, also when a `.gleap/session.json` from another ticket is still around: Gleap refuses Kai runs and the coding session working that ticket (410): Kai runs send with `send_message` as their brief's rule for customer messages says, a code-fix session drafts in `report_progress` |
| `get_session_brief` | The kickoff of a Gleap coding session (`sessionId`, required): `GET /gleapcode/sessions/{id}/agent-workflow` without a kind, which returns the brief as Markdown. The brief (ticket, ownership rules, Kai Support's findings, what an earlier session left, repository, skill and setup lines) is the first text block, then the operator feedback and the `.gleap/session.json` content; a stopped session gets only the STOP instruction. Not read-only: it hands out operator feedback, and a multi-project grant must name its project |
| `report_progress` | Report the fix status on the Gleap coding session you were started from (deeplink hand-off loop; session-scoped since 2026-08), the same snapshot every runtime reports: `status` (`queued`, `working`, `needs_input`, `completed`, `failed`, `cancelled`), `step` while working (`investigating`, `reproduced`, `fixing`), a one-line `message`, `question` with `needs_input` (`kind`, `prompt`, `options`, `audience` customer or team), `customerLine` (one sentence of status the customer may read), `howSolved` (one paragraph on how the ticket was solved, sent with the last report; it feeds Kai Support's learning), `agentKind`, `agentName` and `device`. The older `phase` still works: `status` wins, and a report with only `status` also sends the phase it stands for, for a Server from before the fix status. Registers PRs (`completed` with `prUrl`) and takes the two fix messages: `customerUpdateMessage` (sent right away) and `customerShipMessage` (sent when the fix is live, by the project's post-merge setting); the result says what happened to each. The ticket is done when the customer confirms or 24 hours after the last answer without a reply, not at the merge. The result also carries `stop`, `newCustomerMessages` (see Coding sessions) and the `hook` block for `.gleap/session.json` |
| `update_plan` | Live checklist on the Gleap coding session (`sessionId` or `ticketId`, like `report_progress`): the whole list each call, statuses `pending`/`in_progress`/`completed`/`cancelled` |
| `wrap_up` | End-of-turn card on the session: recap, at most one question, 0-2 actions (`merge_pr`, `open_pr`, `review_changes`, `open_preview`; `send_customer_update` is removed and refused) |
| `share_screenshot` | Post a screenshot (optionally a before/after pair) into the session thread. Returns the `curl -T` upload commands to run (the server cannot read local files); `imageBase64` (≤ 1.5 MB each) for agents without a shell |
| `publish_artifact` | Publish a self-contained HTML page (≤ 1 MB) into the session thread; `artifactId` publishes a new version |
| `get_agent_workflow` | The Gleap ticket workflow (`fix`, `answer`, `feature`) as Markdown, plus the `.gleap/session.json` content for the Gleap plugin |
| `get_ticket_screenshot` | The ticket's SDK screenshot as image content (Gleap file hosts only, ≤ 2 MB) |
| `describe_database` | The team's own databases Kai Code may read (read-only, this ticket's customer only): tables, columns, masked columns, query format. Kai Code runs on a ticket only (the run key's ticket pin); refused for every other connection |
| `query_database` | One read-only query (a SQL SELECT or a MongoDB JSON request) on the team's database, kept to the ticket's customer (`scope: team` across customers always waits for a data owner); at most 200 rows, sensitive columns masked. It may wait for a person's approval (`status: pending` with a `queryId`). Values from results never go into code, tests, fixtures, commits or PRs. Kai Code runs on a ticket only |
Expand Down Expand Up @@ -184,7 +186,7 @@ Error results set `isError: true`. Reads retry transient API failures (5xx, 429,

## Prompts and MCP Apps view

- Prompts `fix_ticket` and `answer_ticket` (argument `ticket`: `#number` or id) start a ticket workflow with the workflow text and a ticket summary.
- Prompts `fix_ticket`, `answer_ticket` and `solve_ticket` (argument `ticket`: `#number` or id) start a ticket workflow with the workflow text and a ticket summary.
- `update_plan`, `wrap_up`, `share_screenshot` and `publish_artifact` carry `_meta.ui.resourceUri = "ui://gleap/kai-session"`: hosts that support [MCP Apps](https://github.com/modelcontextprotocol/ext-apps) render the result inline from `structuredContent.view`; every other client reads the text content.

## Examples
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { registerPipelineTools } from "./tools/pipeline.tool.js";
import { registerSequenceTools } from "./tools/sequence.tool.js";
import { registerProgressTools } from "./tools/progress.tool.js";
import { registerSessionTools } from "./tools/session.tool.js";
import { registerSkillTools } from "./tools/skill.tool.js";
import { registerTicketPrompts } from "./prompts/ticket.prompts.js";
import { linkToolsToKaiSessionView, registerKaiSessionView } from "./ui/kaiSessionView.js";
import { registerStatisticsTools } from "./tools/statistics.tool.js";
Expand All @@ -48,6 +49,7 @@ import { registerTeamTools } from "./tools/team.tool.js";
import { registerSettingsTools } from "./tools/settings.tool.js";
import { registerTicketTools } from "./tools/ticket.tool.js";
import { registerTicketCardTools } from "./tools/ticketCard.tool.js";
import { registerTicketToolTools } from "./tools/ticketTools.tool.js";
import { registerWorkflowTools } from "./tools/workflow.tool.js";
import { registerWorkflowBuilderTools } from "./tools/workflowBuilder.tool.js";
import { registerSetupTools } from "./tools/setup.tool.js";
Expand Down Expand Up @@ -119,8 +121,8 @@ const publicUrlFor = (req: express.Request) =>
// agent-setup docs and the per-tool descriptions repeat them, but every
// client that surfaces instructions gets the policy without fetching a doc.
const SERVER_INSTRUCTIONS = `Gleap workspace tools. If you are working a ticket or feature request as a coding agent (a Gleap kickoff, workflow or the Gleap plugin brought you here), these rules apply:
1. Your session owns the ticket until it is solved: keep working it through the customer's replies. You work for the person who runs you, and Gleap never refuses your writes: when a teammate replies on the ticket or takes it over, tell your operator in one line and follow their call. Results list new customer messages you have not seen yet: read them before you go on. Close, archive or snooze the ticket, or change its assignee, only when your operator tells you to: Gleap marks it done when the customer confirms the fix, or 24 hours after the last answer without a reply.
2. Customer messages: ask your operator in your own conversation, then send what they approved with send_message (isNote: false, with your sessionId) and tell them in one line what you sent. When your operator tells you to answer, tell, reply to or update the customer, that is the approval. A coding session never stages a reply in the ticket composer (Gleap refuses it). If a send_message result lists new customer messages, they came in before your reply went out: read them, and if your reply no longer fits, tell your operator and follow up.
1. When a kickoff names a Gleap coding session, call get_session_brief with it first. Your session's brief (that result, or the rules a Gleap ticket prompt or workflow gave you) says how long your session owns the ticket and whether it writes to the customer: where it says so, it wins over these rules. Otherwise your session owns the ticket until it is solved: keep working it through the customer's replies. You work for the person who runs you: when a teammate replies on the ticket or takes it over, tell your operator in one line and follow their call. Results list new customer messages you have not seen yet: read them before you go on. Close, archive or snooze the ticket, or change its assignee, only when your operator tells you to: Gleap marks it done when the customer confirms the fix, or 24 hours after the last answer without a reply.
2. Customer messages: your brief says whether you send them yourself or ask your operator first. A session started from a ticket's code fix never sends anything to the customer (Gleap refuses its send_message): it drafts in report_progress (customerLine, customerUpdateMessage, customerShipMessage) and Operator tells the customer. When your brief says neither, ask your operator in your own conversation, then send what they approved with send_message (isNote: false, with your sessionId) and tell them in one line what you sent. When your operator tells you to answer, tell, reply to or update the customer, that is the approval. A coding session never stages a reply in the ticket composer (Gleap refuses it). If a send_message result lists new customer messages, they came in before your reply went out: read them, and if your reply no longer fits, tell your operator and follow up. A result that says STOP ends your writes to the ticket: tell your operator in one line.
3. Report with report_progress on every step change: status working with step investigating, reproduced or fixing and a one-line message, plus customerLine (one sentence the customer may read) when the step matters to them. When you need an answer, report needs_input with the question instead of waiting silently; when you cannot fix it, report failed with the reason. Status, findings and PR links belong in report_progress, not in internal notes and not in the customer thread.
4. When you open a PR, report completed with prUrl and the customer messages (normally both): customerUpdateMessage (sent right away: the fix is built, it is being reviewed and deployed, and we will update them) and customerShipMessage (sent when the fix is live, following the project's settings; for SDK or app repositories say it ships in the next release). Write them in the customer's language as plain text, following the fix-message rules and the team's instructions for customer messages that every report_progress result gives you for this project. Feature requests pass neither: Gleap notifies the upvoters when the request ships. Never send your own "it's fixed" or "it's live" message. With the PR also pass problem and fix (one to three simple sentences each) for the team's Merge card. By default the ticket moves to Done when the PR merges to production; a customer reply reopens it.
5. When the ticket is solved, end with report_progress and howSolved: one paragraph on how it was solved (the cause, what changed or what you answered, how you checked it), with no customer data; it feeds Kai Support's learning. Work visibly in the Gleap session: keep a plan with update_plan for any task with more than two steps; after you checked a user-visible change, share_screenshot 1-3 screenshots with a one-line caption; use publish_artifact for reports, mockups or anything easier to read as a page; end EVERY turn with wrap_up (recap first, then at most one question with one or two actions, recommended first). When a result gives you the .gleap/session.json content, write it and add .gleap/ to .git/info/exclude.
Expand Down Expand Up @@ -194,6 +196,8 @@ const buildServer = (creds: Creds | null): McpServer => {
registerImageTools(server);
registerProgressTools(server);
registerSessionTools(server);
registerTicketToolTools(server);
registerSkillTools(server);
// The team's databases: Kai Code runs on a ticket only (utils/sessionScope.ts).
registerDatabaseTools(server);
registerSetupTools(server);
Expand Down
24 changes: 21 additions & 3 deletions src/prompts/ticket.prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { slimTicket } from "../utils/projections.js";
import { stripShareTokens } from "../utils/shareTokenRedaction.js";

/**
* MCP prompts (slash commands in most clients): `/fix_ticket #123` and
* `/answer_ticket #123` start a Gleap ticket workflow in the agent with the
* workflow text and a summary of the ticket.
* MCP prompts (slash commands in most clients): `/fix_ticket #123`,
* `/answer_ticket #123` and `/solve_ticket #123` start a Gleap ticket workflow
* in the agent with the workflow text (for a session in the person's own app,
* the Server's brief with its rules first) and a summary of the ticket.
*
* Prompts are not tools, so neither the session-scope policy nor the share
* token redaction (both patch registerTool) covers them: they refuse
Expand Down Expand Up @@ -132,4 +133,21 @@ export const registerTicketPrompts = (server: McpServer, projects?: ProjectCreds
);
},
);

server.registerPrompt(
"solve_ticket",
{
title: "Solve a Gleap ticket",
description: "Take a whole Gleap ticket until it is solved with Gleap's workflow: investigate, then answer the customer, fix a bug with a PR, put a wish on the roadmap, or ask the team.",
argsSchema,
},
async ({ ticket, project: requested }: { ticket: string; project?: string }) => {
const ref = ticketRef(ticket);
const { data, project } = await findTicket(ref, projects, requested);
const workflow = await inProject(project, () => workflowText(ref, "solve"));
return promptMessage(
`Solve Gleap ticket ${ref}. You have the whole ticket until it is solved or you hand it back, and you talk to the customer yourself as the rules below say. Follow the workflow below; fetch the full conversation with the Gleap tools first.${projectLine(project)}\n\n## Ticket\n\`\`\`json\n${summaryOf(data)}\n\`\`\`\n\n## Workflow\n${workflow}`,
);
},
);
};
6 changes: 3 additions & 3 deletions src/schemas/progress.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const FIX_STATUSES = ["queued", "working", "needs_input", "completed", "f
export const FIX_STEPS = ["investigating", "reproduced", "fixing"] as const;
export const QUESTION_KINDS = ["question", "approval", "auth", "choice"] as const;
export const QUESTION_AUDIENCES = ["customer", "team"] as const;
export const AGENT_KINDS = ["claude_code", "codex", "cursor", "other"] as const;
export const AGENT_KINDS = ["claude_code", "codex", "cursor", "antigravity", "other"] as const;
export const AGENT_PHASES = ["investigating", "reproduced", "fixing", "pr_opened", "blocked", "done"] as const;

export const ReportProgressArgs = z.object({
Expand Down Expand Up @@ -71,7 +71,7 @@ export const ReportProgressArgs = z.object({
.max(300)
.optional()
.describe(
"One sentence the customer may read, when the step matters to them (you reproduced the problem, a fix is being tested). In the customer's language, plain text, no internal details (file paths, code, branch names). It is status, not a message: Gleap shows it where the customer asks \"any update?\". To tell the customer something, ask your operator and send it with send_message. With a PR, customerUpdateMessage and customerShipMessage take its place."
"One sentence the customer may read, when the step matters to them (you reproduced the problem, a fix is being tested). In the customer's language, plain text, no internal details (file paths, code, branch names). It is status, not a message: Gleap shows it where the customer asks \"any update?\". To tell the customer something, send it with send_message, as your session's rule for customer messages says. With a PR, customerUpdateMessage and customerShipMessage take its place."
),
prUrl: z
.string()
Expand All @@ -83,7 +83,7 @@ export const ReportProgressArgs = z.object({
agentKind: z
.enum(AGENT_KINDS)
.optional()
.describe("Which coding agent you are: claude_code, codex, cursor, or other (then name yourself in agentName). Tags the session and every message you write. Send it on every report."),
.describe("Which coding agent you are: claude_code, codex, cursor, antigravity, or other (then name yourself in agentName). Tags the session and every message you write. Send it on every report."),
agentName: z
.string()
.max(60)
Expand Down
6 changes: 5 additions & 1 deletion src/schemas/session.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const WrapUpArgs = z.object({
.enum(WRAP_UP_ACTIONS)
.optional()
.describe(
"merge_pr | open_pr | review_changes (need the session's open PR), open_preview (needs a running preview). send_customer_update is removed: ask your operator in your own conversation and send the reply with send_message.",
"merge_pr | open_pr | review_changes (need the session's open PR), open_preview (needs a running preview). send_customer_update is removed: send customer replies with send_message, as your session's rule for customer messages says.",
),
message: z
.string()
Expand Down Expand Up @@ -127,6 +127,10 @@ export const PublishArtifactArgs = z.object({
.describe("Pass the artifactId from an earlier result to publish a new version of the same page instead of a new one."),
});

export const GetSessionBriefArgs = z.object({
sessionId: SESSION_ID.unwrap().describe("The 24-char Gleap coding-session id your kickoff names."),
});

export const GetTicketScreenshotArgs = z.object({
ticketId: z
.string()
Expand Down
Loading