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
7 changes: 6 additions & 1 deletion apps/web/src/lib/apps/github-enterprise.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { AppDefinition } from "./types";
import { buildGithubAuthUrl, exchangeGithubCode } from "./github-oauth";
import {
buildGithubAuthUrl,
exchangeGithubCode,
githubEnvMappings,
} from "./github-oauth";

const cfgFromConfig = (config: Record<string, string>) => {
const baseUrl = config.baseUrl;
Expand Down Expand Up @@ -115,4 +119,5 @@ export const githubEnterprise: AppDefinition = {
clientSecret: "GITHUB_ENTERPRISE_CLIENT_SECRET",
},
},
envMappings: githubEnvMappings,
};
12 changes: 12 additions & 0 deletions apps/web/src/lib/apps/github-oauth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { EnvMapping } from "@/lib/env-mapping";
import type {
OAuthBuildAuthUrlParams,
OAuthExchangeCodeParams,
Expand All @@ -9,6 +10,17 @@ export interface GithubOAuthConfig {
apiBase: string;
}

/**
* Env var contract for GitHub OAuth connections (github.com + Enterprise).
* `gh` CLI, hub, and octokit-based tools read `GH_TOKEN` by default; the
* gateway swaps the sentinel for the real OAuth access token on outbound
* requests to `api.github.com`, `github.com`, and `raw.githubusercontent.com`
* (see gateway `apps.rs`).
*/
export const githubEnvMappings: EnvMapping[] = [
{ envName: "GH_TOKEN", placeholder: "humr:sentinel" },
];

export const buildGithubAuthUrl = (
cfg: GithubOAuthConfig,
params: OAuthBuildAuthUrlParams,
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/lib/apps/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { AppDefinition } from "./types";
import {
buildGithubAuthUrl,
exchangeGithubCode,
githubEnvMappings,
type GithubOAuthConfig,
} from "./github-oauth";

Expand Down Expand Up @@ -94,4 +95,5 @@ export const github: AppDefinition = {
clientSecret: "GITHUB_CLIENT_SECRET",
},
},
envMappings: githubEnvMappings,
};
6 changes: 6 additions & 0 deletions apps/web/src/lib/apps/resend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { EnvMapping } from "@/lib/env-mapping";
import type { AppDefinition } from "./types";

const resendEnvMappings: EnvMapping[] = [
{ envName: "RESEND_API_KEY", placeholder: "humr:sentinel" },
];

export const resend: AppDefinition = {
id: "resend",
name: "Resend",
Expand All @@ -18,4 +23,5 @@ export const resend: AppDefinition = {
],
},
available: true,
envMappings: resendEnvMappings,
};
6 changes: 6 additions & 0 deletions apps/web/src/lib/apps/spotify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { EnvMapping } from "@/lib/env-mapping";
import type { AppDefinition } from "./types";

const spotifyEnvMappings: EnvMapping[] = [
{ envName: "SPOTIFY_ACCESS_TOKEN", placeholder: "humr:sentinel" },
];

export const spotify: AppDefinition = {
id: "spotify",
name: "Spotify",
Expand Down Expand Up @@ -193,4 +198,5 @@ export const spotify: AppDefinition = {
clientSecret: "SPOTIFY_CLIENT_SECRET",
},
},
envMappings: spotifyEnvMappings,
};
7 changes: 5 additions & 2 deletions apps/web/src/lib/apps/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export interface AppDefinition {
};
/**
* Env vars a consumer should inject into any agent granted this connection.
* Omitted for apps with no known CLI integration.
* Required — every app must declare the env contract its CLI/SDK consumers
* expect so agents can call the provider without per-provider wiring. Apps
* in the same OAuth family can share an exported mapping (see
* `googleWorkspaceEnvMappings`, `githubEnvMappings`).
*/
envMappings?: EnvMapping[];
envMappings: EnvMapping[];
}
2 changes: 2 additions & 0 deletions apps/web/src/lib/apps/youtube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
exchangeGoogleCode,
googleConfigFields,
googleEnvDefaults,
googleWorkspaceEnvMappings,
} from "./google-oauth";

export const youtube: AppDefinition = {
Expand Down Expand Up @@ -48,4 +49,5 @@ export const youtube: AppDefinition = {
fields: googleConfigFields,
envDefaults: googleEnvDefaults,
},
envMappings: googleWorkspaceEnvMappings,
};
Loading