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
2 changes: 1 addition & 1 deletion plugins/glean/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glean-vnext",
"version": "0.2.40",
"version": "0.2.41",
"description": "Glean plugin for discovering skills and running tools.",
"author": {
"name": "Glean"
Expand Down
2 changes: 1 addition & 1 deletion plugins/glean/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glean-vnext",
"version": "0.2.40",
"version": "0.2.41",
"description": "Glean Codex plugin for discovering skills and running tools.",
"author": {
"name": "Glean"
Expand Down
2 changes: 1 addition & 1 deletion plugins/glean/.cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "glean-vnext",
"displayName": "Glean vNext",
"version": "0.2.40",
"version": "0.2.41",
"description": "Search and act across your company's apps — Jira, Slack, Salesforce, Google Workspace, and more — without leaving Cursor.",
"author": {
"name": "Glean"
Expand Down
7 changes: 6 additions & 1 deletion plugins/glean/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions plugins/glean/start.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,23 @@ process.env.SKILLS_BASE_DIR = skillsBaseDir;
// CLAUDE_CODE_SESSION_ID; Codex exposes the conversation id as CODEX_THREAD_ID.
// Hosts that expose no session id (Cursor) leave it unset, and the plugin falls
// back to a generated per-process id.
const sessionId =
val(process.env.CLAUDE_CODE_SESSION_ID) ?? val(process.env.CODEX_THREAD_ID);
const claudeSessionId = val(process.env.CLAUDE_CODE_SESSION_ID);
const codexThreadId = val(process.env.CODEX_THREAD_ID);
const sessionId = claudeSessionId ?? codexThreadId;
if (sessionId !== undefined) {
process.env.GLEAN_SESSION_ID = sessionId;
}

// Export the detected host so the plugin can use host-appropriate identifiers
// (e.g. the OAuth client_name that drives the logo shown on the consent screen).
if (codexThreadId !== undefined) {
process.env.GLEAN_PLUGIN_HOST = "codex";
} else if (claudeSessionId !== undefined) {
process.env.GLEAN_PLUGIN_HOST = "claude-code";
} else {
process.env.GLEAN_PLUGIN_HOST = "cursor";
}

// Boot the server in-process. Import via a file URL resolved against this
// module so the dynamic specifier works regardless of cwd and on Windows paths.
await import(new URL("./dist/index.js", import.meta.url).href);
7 changes: 6 additions & 1 deletion src/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ export class GleanOAuthClientProvider implements OAuthClientProvider {
}

get clientMetadata(): OAuthClientMetadata {
const CLIENT_NAMES: Record<string, string> = {
"codex": "Glean Codex Plugin",
"cursor": "Glean Cursor Plugin",
};
const host = process.env.GLEAN_PLUGIN_HOST ?? "";
return {
redirect_uris: [getCallbackUrl()],
client_name: "Glean Claude Code Plugin",
client_name: CLIENT_NAMES[host] ?? "Glean Claude Code Plugin",
};
}

Expand Down
20 changes: 20 additions & 0 deletions tests/auth-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@ describe("GleanOAuthClientProvider", () => {
expect(meta.redirect_uris![0]).toMatch(/127\.0\.0\.1/);
});

it("clientMetadata uses Codex client name when GLEAN_PLUGIN_HOST is codex", () => {
process.env.GLEAN_PLUGIN_HOST = "codex";
try {
const provider = new GleanOAuthClientProvider();
expect(provider.clientMetadata.client_name).toBe("Glean Codex Plugin");
} finally {
delete process.env.GLEAN_PLUGIN_HOST;
}
});

it("clientMetadata uses Cursor client name when GLEAN_PLUGIN_HOST is cursor", () => {
process.env.GLEAN_PLUGIN_HOST = "cursor";
try {
const provider = new GleanOAuthClientProvider();
expect(provider.clientMetadata.client_name).toBe("Glean Cursor Plugin");
} finally {
delete process.env.GLEAN_PLUGIN_HOST;
}
});

it("redirectToAuthorization records the URL and hands state to the loopback", async () => {
const provider = new GleanOAuthClientProvider();
await provider.redirectToAuthorization(
Expand Down
Loading