(input: {
readonly dataDir: string;
readonly scopeDir: string;
readonly baseUrl: string;
readonly authToken: string;
readonly childPid: number;
})
| 127 | }; |
| 128 | |
| 129 | const 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 | |
| 169 | const resolveSidecarCommand = (input: { |
| 170 | readonly port: number; |
no test coverage detected