Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .changeset/4154-comment-preview-author.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@schlessera/brain-ui-sdk": minor
"@schlessera/brain-ui-server": minor
"@schlessera/brain-ui-kit": minor
"@schlessera/brain-ui-react": minor
---

A GitHub comment's approval card now says who would post the comment and whether it goes on an issue or a pull request, when the host can verify each:

- **Who posts it:** the account the host's GitHub tools credential posts as. The host looks it up for that same credential and never shows one credential's account for another.
- **Where it goes:** the target's kind, read from GitHub for the card's own repository and number. This lookup asks the turn's data routing first, as a read does.
- **When the host cannot verify a fact:** the card shows "The host's GitHub account" and `owner/repo #number`, with no kind and no link. It never shows `@ghost` or a guessed kind, and the approval works as before.

These facts are only shown on the card. The approved content, the check that the approval was not edited, the tool's result and what the model sees are unchanged.

- **Wire and server SDK:** `tool_approval_request` and `PermissionRequest` gain the optional `display` field (`ApprovalDisplay`).
- **Kit:** `GitHubComment` in `preview` accepts no `author`, shows its whole draft and keeps the "Brain's draft · not posted" caption. `GitHubRef` accepts `kind: null`.
16 changes: 11 additions & 5 deletions api-report/ui-kit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1332,15 +1332,21 @@ signatures (every public export and the types it is made of)
}
GitHubComment (packages/ui-kit/src/github/GitHubComment.tsx)
export function GitHubComment(p: GitHubCommentProps): import("react").JSX.Element;
GitHubCommentProps (packages/ui-kit/src/github/GitHubComment.tsx)
export interface GitHubCommentProps {
author: GitHubPerson;
GitHubCommentBase (packages/ui-kit/src/github/GitHubComment.tsx)
interface GitHubCommentBase {
time?: string;
body: string;
htmlUrl?: string | null;
bodyTruncated?: boolean;
preview?: boolean;
}
GitHubCommentProps (packages/ui-kit/src/github/GitHubComment.tsx)
export type GitHubCommentProps = GitHubCommentBase & ({
author: GitHubPerson;
preview?: boolean;
} | {
author?: null;
preview: true;
});
GitHubCommitRow (packages/ui-kit/src/github/GitHubCommitRow.tsx)
export function GitHubCommitRow(p: GitHubCommitRowProps): import("react").JSX.Element;
GitHubCommitRowProps (packages/ui-kit/src/github/GitHubCommitRow.tsx)
Expand Down Expand Up @@ -1482,7 +1488,7 @@ signatures (every public export and the types it is made of)
export function GitHubRef(p: GitHubRefProps): import("react").JSX.Element;
GitHubRefProps (packages/ui-kit/src/github/GitHubRef.tsx)
export interface GitHubRefProps {
kind: "pr" | "issue";
kind: "pr" | "issue" | null;
repo: string;
number?: number | null;
htmlUrl?: string | null;
Expand Down
1 change: 1 addition & 0 deletions api-report/ui-react.txt
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ signatures (every public export and the types it is made of)
approvalKind?: "tool" | "command" | "policy" | "actor";
approvalRememberable?: false;
approvalDescription?: string;
approvalDisplay?: ApprovalDisplay;
restored?: true;
approvalTurnId?: string;
readOnly?: RestoredApprovalClosure;
Expand Down
72 changes: 72 additions & 0 deletions api-report/ui-sdk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export "." (./src/index.ts)
type ApifySpendScopeRead
type ApifyUnresolvedRunRead
type ApprovalChannel
type ApprovalDisplay
type AskAnswerBinding
type AskUserAnnotation
type AskUserFormAnswer
Expand Down Expand Up @@ -201,6 +202,7 @@ export "." (./src/index.ts)
type FirstRequestCacheUsage
type GeoCoords
type GeoRequestOptions
type GithubApprovalDisplay
type GovernedStatus
type GovernedUnavailableReason
type GraphBrokenLink
Expand Down Expand Up @@ -602,6 +604,7 @@ export "./client" (./src/client/index.ts)
type ApifyToolResult
type ApifyUnresolvedRunRead
type ApprovalChannel
type ApprovalDisplay
type AskAnswerBinding
type AskUserAnnotation
type AskUserFormAnswer
Expand Down Expand Up @@ -860,6 +863,7 @@ export "./client" (./src/client/index.ts)
type GeoRequestOptions
type GetCurrentLocationInput
type GetSearchContentInput
type GithubApprovalDisplay
type GithubAuthor
type GithubChangedFile
type GithubCheckRun
Expand Down Expand Up @@ -1680,6 +1684,7 @@ export "./protocol" (./src/protocol.ts)
type ApifySpendScopeRead
type ApifyUnresolvedRunRead
type ApprovalChannel
type ApprovalDisplay
type AskAnswerBinding
type AskUserAnnotation
type AskUserFormAnswer
Expand Down Expand Up @@ -1826,6 +1831,7 @@ export "./protocol" (./src/protocol.ts)
type FirstRequestCacheUsage
type GeoCoords
type GeoRequestOptions
type GithubApprovalDisplay
type GovernedStatus
type GovernedUnavailableReason
type GraphBrokenLink
Expand Down Expand Up @@ -2156,6 +2162,7 @@ export "./schemas" (./src/schemas.ts)
MAX_PROMPT_CHARS
MAX_SERVER_FRAME_BYTES
type ParseFrameResult
approvalDisplaySchema
attachmentFileSchema
attachmentLimitsSchema
classifySessionRecoveryResponse
Expand Down Expand Up @@ -2424,6 +2431,7 @@ export "./server" (./src/server/index.ts)
type ApifyToolResult
type ApifyUnresolvedRunRead
type ApprovalChannel
type ApprovalDisplay
type AskAnswerBinding
type AskUserAnnotation
type AskUserFormAnswer
Expand Down Expand Up @@ -2750,6 +2758,7 @@ export "./server" (./src/server/index.ts)
type GeoRequestOptions
type GetCurrentLocationInput
type GetSearchContentInput
type GithubApprovalDisplay
type GithubAuthor
type GithubChangedFile
type GithubCheckRun
Expand Down Expand Up @@ -4690,6 +4699,10 @@ signatures (every public export and the types it is made of)
}
ApprovalChannel (packages/ui-sdk/src/protocol.ts)
export type ApprovalChannel = "card" | "voice";
ApprovalDisplay (packages/ui-sdk/src/protocol.ts)
export interface ApprovalDisplay {
github?: GithubApprovalDisplay;
}
AskAnswerBinding (packages/ui-sdk/src/protocol.ts)
export interface AskAnswerBinding {
submissionId?: string;
Expand Down Expand Up @@ -9866,6 +9879,17 @@ signatures (every public export and the types it is made of)
export type GetCurrentLocationInput = z.infer<typeof GET_CURRENT_LOCATION_INPUT_SCHEMA>;
GetSearchContentInput (packages/ui-sdk/src/tool-contracts/web.ts)
export type GetSearchContentInput = z.infer<typeof GET_SEARCH_CONTENT_INPUT_SCHEMA>;
GithubApprovalDisplay (packages/ui-sdk/src/protocol.ts)
export interface GithubApprovalDisplay {
poster: {
login: string;
is_bot: boolean;
} | null;
target: {
kind: "issue" | "pull_request";
html_url: string | null;
} | null;
}
GithubAuthor (packages/ui-sdk/src/tool-contracts/github.ts)
export type GithubAuthor = z.infer<typeof GITHUB_AUTHOR_SCHEMA>;
GithubChangedFile (packages/ui-sdk/src/tool-contracts/github.ts)
Expand Down Expand Up @@ -11281,6 +11305,7 @@ signatures (every public export and the types it is made of)
description?: string;
kind?: "tool" | "command" | "policy" | "actor";
outsideEnforcedAllowlist?: boolean;
display?: import("../protocol.js").ApprovalDisplay;
}
PermissionScenario (packages/ui-sdk/src/testing/index.ts)
export type PermissionScenario = "mutation" | "shortcut" | "command";
Expand Down Expand Up @@ -13737,6 +13762,7 @@ signatures (every public export and the types it is made of)
description?: string;
kind?: "tool" | "command" | "policy" | "actor";
rememberable?: boolean;
display?: ApprovalDisplay;
}
ServerToolInputDelta (packages/ui-sdk/src/protocol.ts)
export interface ServerToolInputDelta extends SessionScoped {
Expand Down Expand Up @@ -15341,6 +15367,22 @@ signatures (every public export and the types it is made of)
}
apifyOperationOf (packages/common/src/apify-operations.ts)
export function apifyOperationOf(name: string): ApifyOperation | undefined;
approvalDisplaySchema (packages/ui-sdk/src/schemas.ts)
const approvalDisplaySchema: z.ZodObject<{
github: z.ZodCatch<z.ZodOptional<z.ZodObject<{
poster: z.ZodCatch<z.ZodNullable<z.ZodObject<{
is_bot: z.ZodBoolean;
login: z.ZodString;
}, z.core.$loose>>>;
target: z.ZodCatch<z.ZodNullable<z.ZodObject<{
html_url: z.ZodNullable<z.ZodString>;
kind: z.ZodEnum<{
issue: "issue";
pull_request: "pull_request";
}>;
}, z.core.$loose>>>;
}, z.core.$loose>>>;
}, z.core.$loose>;
assertLiveConversationProvider (packages/ui-sdk/src/server/conversation.ts)
export function assertLiveConversationProvider(provider: LiveConversationProvider): void;
assertLiveConversationSession (packages/ui-sdk/src/server/conversation.ts)
Expand Down Expand Up @@ -24067,6 +24109,21 @@ signatures (every public export and the types it is made of)
type: z.ZodLiteral<"tool_result">;
}, z.core.$loose>, z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
display: z.ZodCatch<z.ZodOptional<z.ZodObject<{
github: z.ZodCatch<z.ZodOptional<z.ZodObject<{
poster: z.ZodCatch<z.ZodNullable<z.ZodObject<{
is_bot: z.ZodBoolean;
login: z.ZodString;
}, z.core.$loose>>>;
target: z.ZodCatch<z.ZodNullable<z.ZodObject<{
html_url: z.ZodNullable<z.ZodString>;
kind: z.ZodEnum<{
issue: "issue";
pull_request: "pull_request";
}>;
}, z.core.$loose>>>;
}, z.core.$loose>>>;
}, z.core.$loose>>>;
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
kind: z.ZodOptional<z.ZodEnum<{
actor: "actor";
Expand Down Expand Up @@ -28534,6 +28591,21 @@ signatures (every public export and the types it is made of)
serverToolApprovalRequestSchema (packages/ui-sdk/src/schemas.ts)
const serverToolApprovalRequestSchema: z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
display: z.ZodCatch<z.ZodOptional<z.ZodObject<{
github: z.ZodCatch<z.ZodOptional<z.ZodObject<{
poster: z.ZodCatch<z.ZodNullable<z.ZodObject<{
is_bot: z.ZodBoolean;
login: z.ZodString;
}, z.core.$loose>>>;
target: z.ZodCatch<z.ZodNullable<z.ZodObject<{
html_url: z.ZodNullable<z.ZodString>;
kind: z.ZodEnum<{
issue: "issue";
pull_request: "pull_request";
}>;
}, z.core.$loose>>>;
}, z.core.$loose>>>;
}, z.core.$loose>>>;
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
kind: z.ZodOptional<z.ZodEnum<{
actor: "actor";
Expand Down
5 changes: 5 additions & 0 deletions docs/hosting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ unauthenticated.
repository of one owner). A write anywhere else is refused before any card
is shown. Every allowed write still asks for its own approval.

A comment's approval card names the account the token posts as, and whether
the comment goes on an issue or a pull request, when the host can look them
up. When it cannot, the card says "The host's GitHub account" and names the
target as `owner/repo #number`; the approval works the same either way.

Reads see only what the token can see. Their results count as untrusted
input for the session. A command that calls GitHub's API directly, such as a
script or a compound `curl` line, waits on a `Network` approval card rather
Expand Down
17 changes: 17 additions & 0 deletions docs/integration-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ shape changes. See
[the package API](integration-contract/package-api.md#start-card-persona-choice-3698).
This ships in a minor.

## Approval display facts for a GitHub comment (additive, 0.45.0, #4154)

`tool_approval_request` gains optional `display` (`ApprovalDisplay`), and
`PermissionRequest` in `@schlessera/brain-ui-sdk/server` gains the same
optional field. A `brain_github_issue_comment` card carries the account the
host's credential would post as and whether the target is an issue or a pull
request, each `null` when the host could not verify it. The facts are
display only: the approved input, the answer comparison, the tool's result
and provider-facing history are unchanged. The comment card's target lookup
asks the turn's data routing first. In `@schlessera/brain-ui-kit`,
`GitHubComment` in `preview` accepts no `author` ("The host's GitHub
account") and shows its whole draft, and `GitHubRef` accepts `kind: null`
(`repository #number`, no kind, no chip, no link). See
[the wire component](integration-contract/wire.md#approval-display-facts-additive-0450-4154)
and [the MCP component](integration-contract/mcp.md#github-writes-additive-0450-3798).
This ships in a minor; no breaking ruling is required.

## Data routing for the host GitHub reads (additive, 0.45.0, #4029)

GitHub is a provider-policy recipient, named `github`. Before any request,
Expand Down
19 changes: 18 additions & 1 deletion docs/integration-contract/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,9 @@ A refused call sends GitHub nothing, returns no GitHub text and taints
nothing. The writes are not routed (maintainer ruling on #4029): each write's
gate is its per-use card, which shows exactly what is sent, and
`outward.github.repositories`. A write in a conversation whose reads are
refused still reaches its card unchanged.
refused still reaches its card unchanged; only the comment card's
display-only target lookup (#4154) is routed, and a refusal leaves the
target's kind unknown.

### GitHub writes (additive, 0.45.0, #3798)

Expand Down Expand Up @@ -1619,6 +1621,21 @@ the last step:
with an absent field neither shown nor sent. Its description says the
write is sent once, in the user's name, and cannot be undone, and notes a
session that has read untrusted input. The card is never remembered.
A comment card also carries display-only facts beside its input
([the wire component](wire.md#approval-display-facts-additive-0450-4154),
#4154): `poster`, the account `GET /user` names for the same credential
the write would use, and `target`, whether `GET /repos/{repository}/issues/{number}`
is an issue or a pull request, accepted only when GitHub's answer names
that same repository and number. The target lookup sends the
model-chosen repository and number before the card, so it asks the
turn's data routing first, as a read does; the write itself is not
routed. A verified poster is reused for that credential for ten
minutes, and a failed lookup is not repeated for it for one minute;
another credential never reads it, and a credential GitHub rejects on a
write keeps none. Both lookups share a three-second limit. Any failure,
refusal, rate limit, timeout or mismatch makes that fact `null`, and the
write continues unchanged. Neither fact reaches the tool's result or the
`outward_action` record.
5. **Answer.** A denial is `approval_declined`, `reason: "declined"`. An
approval that comes back with a changed input is `approval_declined`,
`reason: "edited"`, and sends nothing; the model must make the call again,
Expand Down
30 changes: 30 additions & 0 deletions docs/integration-contract/wire.md
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,36 @@ same-request read are specified in the [HTTP reference](../http-api.md#policy-pr
No client field grants authority or activates policy. Approval writes only the
reviewed server-held bytes; changed input requires a new proposal.

<a id="approval-display-facts-additive-0450-4154"></a>

### Approval display facts (additive, 0.45.0, #4154)

`tool_approval_request` optionally carries `display: ApprovalDisplay`, facts
the host verified for the card and nothing else. Today it has one member,
`github`, on a `brain_github_issue_comment` card:
`{ poster: { login, is_bot } | null, target: { kind: "issue" | "pull_request", html_url } | null }`
(`GithubApprovalDisplay`, `packages/ui-sdk/src/protocol.ts:1324-1327`).
`poster` is the account the host's GitHub tools credential posts as, resolved
for that same credential; `target` is the kind of the object at the card's own
repository and number, read from GitHub for exactly that repository and
number, with its `html_url` validated by the contract or `null`.

- **Display only.** `input` stays exactly what is approved and sent; the answer
is compared with it alone, and a client never sends `display` back. The
facts grant no authority and never enter a tool input or result, the system
prompt or provider-facing history.
- **Unknown is neutral.** An absent `display`, an absent `github` or a `null`
fact is unknown. A client shows its neutral state ("The host's GitHub
account"; `repository #number` with no kind and no link) and the approval
works as before. Clients validate the shape
(`approvalDisplaySchema`, `packages/ui-sdk/src/schemas.ts:1386-1391`);
a fact that fails it reads as `null`, never as a refused card.
- **Re-delivery.** A pending card re-delivered after a reconnect carries the
host's facts for it again; a client replaces what it had.

How the host resolves the facts, and when each is `null`, is in
[the MCP component](mcp.md#github-writes-additive-0450-3798).

### Claude title-helper accounting (#2052)

No WebSocket field changes. Root result/live usage remains completed main/child
Expand Down
2 changes: 1 addition & 1 deletion docs/plans/chat-history-deletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ and [operational recovery](../inbox-recovery.md) remain binding.
There is no general delete operation: `createSessionRoutes` only lists/reads
(`createSessionRoutes`, `packages/ui-server/src/routes/sessions.ts:27-175`).
`AgentBackend` exposes native list/read and read-only storage roots, not deletion
(`AgentBackend`, `packages/ui-sdk/src/server/backend.ts:826-882`). A storage root
(`AgentBackend`, `packages/ui-sdk/src/server/backend.ts:832-888`). A storage root
is not removal authority. Future supported package/HTTP/wire changes need their
actual contract assessment and a CONTRACT commit; additive capability negotiation
ships in a minor. The approved retention exception is recorded before runtime
Expand Down
4 changes: 2 additions & 2 deletions docs/process/test-waits.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ case observes that later effect through its retained native window.
The history and queue receiving observer is only a barrier for the current
synchronous production handlers, not a generic asynchronous-handler completion
claim: `session_history` and scoped `status` update the chat store synchronously
(`session_history`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:442-462`;
`status`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:463-488`), while
(`session_history`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:443-463`;
`status`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:464-489`), while
queue adoption updates the follow-up/draft stores synchronously
(`function queueReport(`, `packages/ui-react/src/ws-client/follow-ups.ts:85-94`). Native protocol
completion, committed store state and the retained observation window serve
Expand Down
Loading
Loading