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