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

Function writeSidecarManifest

apps/desktop/src/main/sidecar.ts:129–167  ·  view source on GitHub ↗
(input: {
  readonly dataDir: string;
  readonly scopeDir: string;
  readonly baseUrl: string;
  readonly authToken: string;
  readonly childPid: number;
})

Source from the content-addressed store, hash-verified

127};
128
129const writeSidecarManifest = (input: {
130 readonly dataDir: string;
131 readonly scopeDir: string;
132 readonly baseUrl: string;
133 readonly authToken: string;
134 readonly childPid: number;
135}) => {
136 const connection = normalizeExecutorServerConnection({
137 kind: "desktop-sidecar",
138 key: "desktop-sidecar",
139 origin: input.baseUrl,
140 displayName: "Desktop sidecar",
141 auth: { kind: "bearer" as const, token: input.authToken },
142 });
143 mkdirSync(serverControlDir(input.dataDir), { recursive: true });
144 const manifestPath = localServerManifestPath(input.dataDir);
145 writeFileSync(
146 manifestPath,
147 serializeExecutorLocalServerManifest({
148 version: 1,
149 kind: "desktop-sidecar",
150 pid: input.childPid,
151 startedAt: new Date().toISOString(),
152 dataDir: input.dataDir,
153 scopeDir: input.scopeDir,
154 connection,
155 owner: {
156 client: "desktop",
157 version: app.getVersion() || null,
158 executablePath: process.execPath || null,
159 },
160 }),
161 { mode: 0o600 },
162 );
163 // The manifest embeds the bearer token; keep it owner-only even if a looser
164 // file already existed (writeFileSync's mode does not re-apply on overwrite).
165 chmodSync(manifestPath, 0o600);
166 sidecarManifestPathByPid.set(input.childPid, input.dataDir);
167};
168
169const resolveSidecarCommand = (input: {
170 readonly port: number;

Callers 1

onStdoutFunction · 0.85

Calls 5

setMethod · 0.80
serverControlDirFunction · 0.70
localServerManifestPathFunction · 0.70

Tested by

no test coverage detected