Skip to content
Draft
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
30 changes: 30 additions & 0 deletions nodejs/docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ An approval is remembered against the exact set of names the user saw, so an ext

An approved extension can pass a granted value to anything it starts, so ask only for what the extension genuinely needs.

## Contributing app session badges

App hosts can retain a hidden, non-conversational session for executable extensions that contribute branch or pull request badges. Use `joinAppSessionBadges()` to opt in explicitly:

```js
import { joinAppSessionBadges } from "@github/copilot-sdk/extension";

const badges = await joinAppSessionBadges();

badges.onSnapshot(async (snapshot) => {
await badges.setBadges(
snapshot.sessions.map((target) => ({
workspaceId: target.workspaceId,
sessionId: target.sessionId,
badge: {
state: "open",
label: target.branch,
},
}))
);
});
```

`setBadges()` validates the complete ordered batch before sending one
`extensions.appSessionBadges.setBadges` JSON-RPC request. Duplicate workspace and session target
pairs reject the complete batch. Use `badge: null` to clear a target. An empty batch is a local
no-op. `setBadge()` and `clearBadge()` remain available for individual updates.

Each snapshot is a full replacement of the sessions that the app considers eligible. The app owns hidden-session lifecycle, visibility filtering, and repository inspection. Native GitHub pull request badges remain authoritative, and the app can reject an update when a native badge appears after the snapshot. Extensions can publish only `draft`, `open`, `merged`, or `closed` states with an optional label; arbitrary markup, icons, colors, and URLs are not supported.

## Further Reading

- `examples.md` — Practical code examples for tools, hooks, events, and complete extensions
Expand Down
10 changes: 10 additions & 0 deletions nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
"types": "./dist/extension.d.ts",
"default": "./dist/cjs/extension.js"
}
},
"./private/app-extension": {
"import": {
"types": "./dist/appExtension.d.ts",
"default": "./dist/appExtension.js"
},
"require": {
"types": "./dist/appExtension.d.ts",
"default": "./dist/cjs/appExtension.js"
}
}
},
"type": "module",
Expand Down
Loading
Loading