UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

3 lines (2 loc) • 1.57 kB
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } } import{buildGoogleAuthOptions,resolveVertexProjectFromEnv}from"./chunk-74YFRVGQ.js";import{require_src}from"./chunk-QPGJHUIK.js";import"./chunk-5ROMKDLK.js";import{__toESM}from"./chunk-IKOFCODM.js";var import_google_auth_library=__toESM(require_src(),1);var CLOUD_PLATFORM_SCOPE="https://www.googleapis.com/auth/cloud-platform",authByKey=new Map;function getGoogleAuth(env){let authOptions=buildGoogleAuthOptions(env),key=authOptions?.keyFilename??"",auth=authByKey.get(key);return auth||(auth=new import_google_auth_library.GoogleAuth({...authOptions,scopes:[CLOUD_PLATFORM_SCOPE]}),authByKey.set(key,auth)),auth}async function getVertexAdcAccess(options){let auth=getGoogleAuth(options?.env),client=await auth.getClient(),{token}=await client.getAccessToken();if(!token)throw new Error("Google Application Default Credentials returned no access token.");let adcQuotaProject=client.quotaProjectId||void 0,project=resolveVertexProjectFromEnv(options)??adcQuotaProject??(await auth.getProjectId().catch(()=>null)||void 0);if(!project)throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or a quota project in Application Default Credentials.");return{accessToken:token,project,quotaProject:adcQuotaProject??project}}export{getVertexAdcAccess};