MCPcopy Create free account
hub / github.com/arctic-cli/interface / onboardManagedProject

Function onboardManagedProject

packages/arctic/src/provider/usage.ts:1125–1193  ·  view source on GitHub ↗
(
      accessToken: string,
      tierId: string,
      projectId?: string,
      attempts = 10,
      delayMs = 5000,
    )

Source from the content-addressed store, hash-verified

1123 }
1124
1125 async function onboardManagedProject(
1126 accessToken: string,
1127 tierId: string,
1128 projectId?: string,
1129 attempts = 10,
1130 delayMs = 5000,
1131 ): Promise<string | undefined> {
1132 const metadata: { [key: string]: string } = {
1133 ideType: "IDE_UNSPECIFIED",
1134 platform: "PLATFORM_UNSPECIFIED",
1135 pluginType: "GEMINI",
1136 }
1137 if (projectId) {
1138 metadata.duetProject = projectId
1139 }
1140
1141 const requestBody: { [key: string]: unknown } = {
1142 tierId,
1143 metadata,
1144 }
1145
1146 if (tierId !== "FREE" && !projectId) {
1147 throw new Error("Google Gemini requires a Google Cloud project. Set GOOGLE_CLOUD_PROJECT.")
1148 }
1149
1150 if (projectId) {
1151 requestBody.cloudaicompanionProject = projectId
1152 }
1153
1154 for (let attempt = 0; attempt < attempts; attempt += 1) {
1155 let response: any
1156 try {
1157 response = await globalThis.fetch("https://cloudcode-pa.googleapis.com/v1internal:onboardUser", {
1158 method: "POST",
1159 headers: {
1160 "Content-Type": "application/json",
1161 Authorization: `Bearer ${accessToken}`,
1162 ...codeAssistHeaders,
1163 },
1164 body: JSON.stringify(requestBody),
1165 })
1166 } catch (error) {
1167 await logDebug("onboardUser.error", {
1168 error: error instanceof Error ? error.message : String(error),
1169 })
1170 return undefined
1171 }
1172
1173 if (!response.ok) {
1174 const errorText = await readResponseBody(response)
1175 await logDebug("onboardUser.failed", { ...responseMeta(response), body: errorText })
1176 return undefined
1177 }
1178
1179 const payload = await response.json()
1180 await logDebug("onboardUser.ok", { done: payload?.done ?? null })
1181 const managedProjectId = payload?.response?.cloudaicompanionProject?.id
1182 if (payload?.done && managedProjectId) {

Callers 1

ensureProjectContextFunction · 0.70

Calls 4

readResponseBodyFunction · 0.85
responseMetaFunction · 0.85
logDebugFunction · 0.70
jsonMethod · 0.65

Tested by

no test coverage detected