feat(agent): inject S0 env into launchd/systemd via install CLI (S2)
- launchd writer emits <EnvironmentVariables>; systemd writer emits EnvironmentFile/Environment; originConfig zone parameterized (default 'term' preserved for relay callers). - InstallOptions threaded CLI install -> createCliDeps -> installService seam -> writers, so generated units carry BIND_HOST (defaults 127.0.0.1 for tunnel hosts), ALLOWED_ORIGINS, PORT, SHELL_PATH, IDLE_TTL, USE_TMUX. systemd rejects control chars in env values. Verified: agent typecheck+build clean; vitest 166/166 (154 baseline + 12 new).
This commit is contained in:
@@ -49,6 +49,7 @@ function deps(overrides: Partial<CliDeps> = {}, enrolled = false): { d: CliDeps;
|
||||
hostContentSecret: new Uint8Array([1]),
|
||||
}),
|
||||
runTunnel: async () => 0,
|
||||
resolveInstallOptions: () => ({ env: { BIND_HOST: '127.0.0.1' } }),
|
||||
installService: vi.fn(async () => {}),
|
||||
uninstallService: vi.fn(async () => {}),
|
||||
print: (l) => out.push(l),
|
||||
@@ -88,11 +89,22 @@ describe('runCli (T5)', () => {
|
||||
expect(out.join('\n')).not.toContain('PEM')
|
||||
})
|
||||
|
||||
it('pair --install installs the service', async () => {
|
||||
it('pair --install installs the service with the resolved options', async () => {
|
||||
const options = { env: { BIND_HOST: '127.0.0.1', PORT: '3000' } }
|
||||
const install = vi.fn(async () => {})
|
||||
const { d } = deps({ installService: install })
|
||||
const { d } = deps({ resolveInstallOptions: () => options, installService: install })
|
||||
await runCli(parseArgs(['pair', 'ABCD', '--install']), d)
|
||||
expect(install).toHaveBeenCalledOnce()
|
||||
expect(install).toHaveBeenCalledWith(CFG, options)
|
||||
})
|
||||
|
||||
it('install threads the resolved InstallOptions into installService (S2 env injection)', async () => {
|
||||
const options = { env: { BIND_HOST: '127.0.0.1' }, domain: 'yaojia.wang', zone: 'terminal' }
|
||||
const install = vi.fn(async () => {})
|
||||
const { d } = deps({ resolveInstallOptions: () => options, installService: install })
|
||||
const code = await runCli(parseArgs(['install']), d)
|
||||
expect(code).toBe(0)
|
||||
expect(install).toHaveBeenCalledWith(CFG, options)
|
||||
})
|
||||
|
||||
it('run before pairing fails fast', async () => {
|
||||
|
||||
Reference in New Issue
Block a user