MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / serviceEnvironment

Function serviceEnvironment

apps/cli/src/service.ts:170–218  ·  view source on GitHub ↗
(
  descriptor: ServiceDescriptor,
  dataDir: string,
)

Source from the content-addressed store, hash-verified

168];
169
170const serviceEnvironment = (
171 descriptor: ServiceDescriptor,
172 dataDir: string,
173): Record<string, string> => {
174 const passThroughKeys = [
175 "EXECUTOR_CLIENT",
176 "EXECUTOR_SENTRY_DSN",
177 "EXECUTOR_SENTRY_RELEASE",
178 "EXECUTOR_SENTRY_ENVIRONMENT",
179 "EXECUTOR_RUN_ID",
180 // Analytics opt-out must survive into the supervised unit's minimal env,
181 // or an opted-out install would silently re-enable analytics under launchd.
182 "DO_NOT_TRACK",
183 "EXECUTOR_DISABLE_ANALYTICS",
184 // Preserve the caller's TLS trust configuration. Corporate/intercepting
185 // CAs commonly live outside the OS trust store; dropping these paths in a
186 // minimal launchd/systemd environment makes HTTPS integrations fail only
187 // after service installation while the same CLI call succeeds.
188 "NODE_EXTRA_CA_CERTS",
189 "SSL_CERT_FILE",
190 "SSL_CERT_DIR",
191 ] as const;
192 const passThrough = Object.fromEntries(
193 passThroughKeys.flatMap((key) => {
194 const value = process.env[key];
195 return value ? [[key, value] as const] : [];
196 }),
197 );
198
199 return {
200 // Marks the process as OS-supervised so the daemon resolves its bearer token
201 // from the durable 0600 auth.json (the secret is never in the unit itself).
202 EXECUTOR_SUPERVISED: "1",
203 // Pin the data/scope dirs explicitly: launchd/systemd give a minimal
204 // environment and we never want the daemon to fall back to a different home
205 // or cwd than the user's singleton local service.
206 EXECUTOR_DATA_DIR: dataDir,
207 EXECUTOR_SCOPE_DIR: process.env.EXECUTOR_SCOPE_DIR ?? dataDir,
208 // Stamp the installing version so `service status` can flag drift after an
209 // upgrade where the unit still points at an older binary path.
210 EXECUTOR_SERVICE_VERSION: descriptor.version,
211 // A launchd/systemd unit starts with a bare PATH — without the user's PATH
212 // the daemon can't find pyenv/nvm/volta/Homebrew tools that integrations may
213 // shell out to. `service install` runs from the user's shell, so its own
214 // PATH is the right one to bake in. (Reference: opencode shell-env capture.)
215 ...(process.env.PATH ? { PATH: process.env.PATH } : {}),
216 ...passThrough,
217 };
218};
219
220// ---------------------------------------------------------------------------
221// macOS — launchd LaunchAgent (fully built)

Callers 3

makeLaunchdBackendFunction · 0.85
makeSystemdBackendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected