MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / setVaultValue

Function setVaultValue

scripts/web-env/shared.ts:353–421  ·  view source on GitHub ↗
(vaultId: string, name: string, value: string)

Source from the content-addressed store, hash-verified

351 vercel(undefined, ['whoami', '--format=json'], undefined, { includeFailureOutput: true }),
352 'Vercel login'
353 );
354 } catch (error) {
355 if (error instanceof MissingCommandError) throw error;
356 throw vercelAccessError(error);
357 }
358 const team = isRecord(whoami.team) ? whoami.team : undefined;
359 const orgId = team ? stringValue(team, 'id') : undefined;
360 if (!orgId || stringValue(team ?? {}, 'slug') !== 'kilocode') {
361 throw vercelAccessError(
362 new Error('The authenticated Vercel account is not scoped to the kilocode team.')
363 );
364 }
365
366 const contexts: VercelContext[] = [];
367 const missingProjects: Project[] = [];
368 for (const project of PROJECTS) {
369 const context = { project, orgId, cwd: tempDirectory };
370 if (projectExists(context)) contexts.push(context);
371 else missingProjects.push(project);
372 }
373 return { contexts, missingProjects };
374}
375
376export type EnvRecord = {
377 id: string;
378 key: string;
379 type: string;
380 target: string[];
381 customEnvironmentIds: string[];
382 gitBranch?: string;
383 configurationId?: string;
384 value?: string;
385};
386
387// Vercel returns `target` as either one string or an array of strings.
388function stringArray(value: unknown): string[] {
389 if (typeof value === 'string') return [value];
390 return Array.isArray(value)
391 ? value.filter((item): item is string => typeof item === 'string')
392 : [];
393}
394
395export function listEnvRecords(context: VercelContext): EnvRecord[] {
396 const operation = `List ${context.project} environment variables`;
397 const response = vercelApi(
398 context,
399 `/v10/projects/${encodeURIComponent(context.project)}/env`,
400 operation
401 );
402 if (isRecord(response.pagination) && response.pagination.next != null) {
403 throw new Error(`${operation} returned more than one page.`);
404 }
405 const hidden = response.hiddenProductionEnvCount;
406 if (typeof hidden === 'number' && hidden > 0) {
407 throw new Error(
408 `${operation}: ${hidden} production variables are hidden from your Vercel account. Ask for access to them first.`
409 );
410 }

Callers 2

mainFunction · 0.85
captureOpInvocationsFunction · 0.85

Calls 8

auditNoteFunction · 0.85
findVaultItemFunction · 0.85
runOpWithTemplateFunction · 0.85
recordsFunction · 0.85
stringValueFunction · 0.85
setAuditNoteFunction · 0.85
parseJsonFunction · 0.70
runFunction · 0.70

Tested by 1

captureOpInvocationsFunction · 0.68