MCPcopy
hub / github.com/vectorize-io/hindsight / configureProfile

Method configureProfile

hindsight-all-npm/src/server.ts:169–198  ·  view source on GitHub ↗

* Run `profile create --merge --port [--env K=V ...]`. * Every entry in the merged env that was passed via userEnv (or * auto-applied by the CPU workaround) is forwarded as `--env`.

(env: NodeJS.ProcessEnv)

Source from the content-addressed store, hash-verified

167 * auto-applied by the CPU workaround) is forwarded as `--env`.
168 */
169 private async configureProfile(env: NodeJS.ProcessEnv): Promise<void> {
170 this.logger.info(`[hindsight] configuring profile "${this.profile}"`);
171
172 const [cmd, ...baseArgs] = getEmbedCommand({
173 embedVersion: this.embedVersion,
174 embedPackagePath: this.embedPackagePath,
175 });
176 const createArgs = [
177 ...baseArgs,
178 "profile",
179 "create",
180 this.profile,
181 "--merge",
182 "--port",
183 String(this.port),
184 ];
185
186 // Forward every env var that the caller intended for the daemon as --env.
187 // We only forward keys the caller explicitly set (userEnv) plus the CPU
188 // workaround values — not the entire process.env, to avoid leaking random
189 // host state into profile config.
190 const envForProfile = this.collectProfileEnv(env);
191 for (const [key, value] of Object.entries(envForProfile)) {
192 createArgs.push("--env", `${key}=${value}`);
193 }
194
195 createArgs.push(...this.extraProfileCreateArgs);
196
197 await this.runCommand(cmd, createArgs, env, "profile.create");
198 }
199
200 /** Collect only the env vars that should be written into the profile file. */
201 private collectProfileEnv(env: NodeJS.ProcessEnv): Record<string, string> {

Callers 1

startMethod · 0.95

Calls 4

collectProfileEnvMethod · 0.95
runCommandMethod · 0.95
getEmbedCommandFunction · 0.85
infoMethod · 0.65

Tested by

no test coverage detected