Skip to content

Commit 03751dd

Browse files
plossonclaude
andcommitted
refactor: remove deprecated gateway alias and legacy compat
- Remove the hidden `agentio gateway` alias of `agentio daemon` - Delete the config.gateway → config.daemon migration and the legacy `gateway` config field - Drop the AGENTIO_GATEWAY_URL / AGENTIO_GATEWAY_API_KEY env fallbacks (AGENTIO_DAEMON_* only) Typecheck clean; 215 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a09987c commit 03751dd

7 files changed

Lines changed: 9 additions & 137 deletions

File tree

src/commands/config-import.test.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,6 @@ const SAMPLE_SERVER: ServerStateLike = {
147147
],
148148
};
149149

150-
const SAMPLE_GATEWAY = {
151-
apiKey: 'gw_preserved_gateway_key',
152-
server: { port: 7890, host: '0.0.0.0' },
153-
};
154-
155150
/* ------------------------------------------------------------------ */
156151
/* replace mode preserves config.server */
157152
/* ------------------------------------------------------------------ */
@@ -194,59 +189,6 @@ describe('config import (replace mode) — preserves config.server', () => {
194189
expect(server.clients).toEqual(SAMPLE_SERVER.clients);
195190
});
196191

197-
test('preserves config.gateway across import (migrated to daemon)', async () => {
198-
await writeConfig({
199-
profiles: { rss: [{ name: 'feeds' }] },
200-
gateway: SAMPLE_GATEWAY,
201-
});
202-
const { key, blob } = await exportCurrentConfig();
203-
204-
await writeConfig({
205-
profiles: {},
206-
gateway: SAMPLE_GATEWAY,
207-
});
208-
const importRes = await runCli(['config', 'import'], {
209-
AGENTIO_KEY: key,
210-
AGENTIO_CONFIG: blob,
211-
});
212-
expect(importRes.exitCode).toBe(0);
213-
214-
// loadConfig migrates gateway → daemon on first load; the vault is
215-
// re-persisted with daemon, so readConfig() (which reads the raw vault)
216-
// sees daemon, not gateway.
217-
const final = await readConfig();
218-
expect(final.daemon).toEqual(SAMPLE_GATEWAY);
219-
expect(final.gateway).toBeUndefined();
220-
expect(profileNames(final, 'rss')).toEqual(['feeds']);
221-
});
222-
223-
test('preserves both server and gateway in the same config (gateway migrated to daemon)', async () => {
224-
await writeConfig({
225-
profiles: { gmail: [{ name: 'p1' }] },
226-
server: SAMPLE_SERVER,
227-
gateway: SAMPLE_GATEWAY,
228-
});
229-
const { key, blob } = await exportCurrentConfig();
230-
231-
await writeConfig({
232-
profiles: {},
233-
server: SAMPLE_SERVER,
234-
gateway: SAMPLE_GATEWAY,
235-
});
236-
const importRes = await runCli(['config', 'import'], {
237-
AGENTIO_KEY: key,
238-
AGENTIO_CONFIG: blob,
239-
});
240-
expect(importRes.exitCode).toBe(0);
241-
242-
// loadConfig migrates gateway → daemon on first load; the vault is
243-
// re-persisted with daemon, not gateway.
244-
const final = await readConfig();
245-
expect(final.server).toEqual(SAMPLE_SERVER);
246-
expect(final.daemon).toEqual(SAMPLE_GATEWAY);
247-
expect(final.gateway).toBeUndefined();
248-
});
249-
250192
test('replace still REPLACES profiles (not merge)', async () => {
251193
await writeConfig({
252194
profiles: { gmail: [{ name: 'p1' }] },

src/config/config-manager.test.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
22
import { mkdtemp, rm } from 'fs/promises';
33
import { tmpdir } from 'os';
44
import { join } from 'path';
5-
import { migrateGatewayToDaemon, resolveProfile, setProfile } from './config-manager';
5+
import { resolveProfile, setProfile } from './config-manager';
66
import { clearVaultCache, saveVault, CURRENT_VAULT_VERSION } from '../vault/vault';
77
import {
88
clearPassphraseCache,
@@ -60,30 +60,3 @@ describe('resolveProfile multi-profile case', () => {
6060
}
6161
});
6262
});
63-
64-
describe('migrateGatewayToDaemon', () => {
65-
test('copies gateway into daemon when daemon absent', () => {
66-
const input = { profiles: {}, gateway: { apiKey: 'k' } };
67-
const out = migrateGatewayToDaemon(input);
68-
expect(out.daemon).toEqual({ apiKey: 'k' });
69-
expect(out.gateway).toBeUndefined();
70-
});
71-
72-
test('leaves daemon alone when already present', () => {
73-
const input = {
74-
profiles: {},
75-
gateway: { apiKey: 'old' },
76-
daemon: { apiKey: 'new' },
77-
};
78-
const out = migrateGatewayToDaemon(input);
79-
expect(out.daemon?.apiKey).toBe('new');
80-
expect(out.gateway).toBeUndefined();
81-
});
82-
83-
test('is a no-op when neither is present', () => {
84-
const input = { profiles: {} };
85-
const out = migrateGatewayToDaemon(input);
86-
expect(out.daemon).toBeUndefined();
87-
expect(out.gateway).toBeUndefined();
88-
});
89-
});

src/config/config-manager.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,9 @@ export async function ensureConfigDir(): Promise<void> {
3030
}
3131
}
3232

33-
/**
34-
* Migrate legacy `config.gateway` into `config.daemon` in place.
35-
* Pure: returns a new Config value; does not mutate input.
36-
* - If `daemon` already exists, drops `gateway` untouched.
37-
* - Otherwise moves `gateway` verbatim under `daemon`.
38-
*/
39-
export function migrateGatewayToDaemon(config: Config): Config {
40-
if (!config.gateway) return config;
41-
if (config.daemon) {
42-
const { gateway: _drop, ...rest } = config;
43-
return rest;
44-
}
45-
const { gateway, ...rest } = config;
46-
return { ...rest, daemon: gateway };
47-
}
48-
4933
export async function loadConfig(): Promise<Config> {
5034
const vault = await loadVault();
51-
const migrated = migrateGatewayToDaemon(vault.config);
52-
// If migration changed anything, persist it.
53-
if (migrated !== vault.config) {
54-
await saveVault({
55-
version: CURRENT_VAULT_VERSION,
56-
config: migrated,
57-
credentials: vault.credentials,
58-
});
59-
}
60-
return migrated;
35+
return vault.config;
6136
}
6237

6338
export async function saveConfig(config: Config): Promise<void> {

src/daemon/client.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CliError } from '../utils/errors';
22
import { loadConfig } from '../config/config-manager';
33
import { getEnv } from '../config/config-manager';
4-
import type { GatewayConfig, HealthResponse } from './types';
4+
import type { HealthResponse } from './types';
55

66
let cachedConfig: { url: string; apiKey: string } | null = null;
77

@@ -11,25 +11,19 @@ let cachedConfig: { url: string; apiKey: string } | null = null;
1111
async function getDaemonConnection(): Promise<{ url: string; apiKey: string }> {
1212
if (cachedConfig) return cachedConfig;
1313

14-
// Check environment variables first; legacy AGENTIO_GATEWAY_* still works.
14+
// Check environment variables first.
1515
const envUrl =
16-
process.env.AGENTIO_DAEMON_URL || process.env.AGENTIO_GATEWAY_URL ||
17-
await getEnv('AGENTIO_DAEMON_URL') || await getEnv('AGENTIO_GATEWAY_URL');
16+
process.env.AGENTIO_DAEMON_URL || await getEnv('AGENTIO_DAEMON_URL');
1817
const envApiKey =
19-
process.env.AGENTIO_DAEMON_API_KEY || process.env.AGENTIO_GATEWAY_API_KEY ||
20-
await getEnv('AGENTIO_DAEMON_API_KEY') || await getEnv('AGENTIO_GATEWAY_API_KEY');
18+
process.env.AGENTIO_DAEMON_API_KEY || await getEnv('AGENTIO_DAEMON_API_KEY');
2119

2220
if (envUrl) {
2321
cachedConfig = { url: envUrl, apiKey: envApiKey || '' };
2422
return cachedConfig;
2523
}
2624

27-
// Load from config (post-migration: config.daemon; pre-migration: config.gateway)
28-
const config = await loadConfig() as unknown as {
29-
daemon?: GatewayConfig;
30-
gateway?: GatewayConfig;
31-
};
32-
const daemonConfig = config.daemon ?? config.gateway;
25+
const config = await loadConfig();
26+
const daemonConfig = config.daemon;
3327

3428
// Construct URL from server host:port (local daemon)
3529
const host = daemonConfig?.server?.host ?? '127.0.0.1';
@@ -64,7 +58,7 @@ async function request<T>(method: string, endpoint: string, body?: unknown): Pro
6458

6559
if (!response.ok) {
6660
if (response.status === 401) {
67-
throw new CliError('AUTH_FAILED', 'Daemon authentication failed', 'Check AGENTIO_DAEMON_API_KEY (or legacy AGENTIO_GATEWAY_API_KEY)');
61+
throw new CliError('AUTH_FAILED', 'Daemon authentication failed', 'Check AGENTIO_DAEMON_API_KEY');
6862
}
6963

7064
const errorData = await response.json().catch(() => ({})) as { error?: string };

src/index-program.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export function createProgram(): Command {
8484
registerMcpCommands(program);
8585
registerDocsCommand(program);
8686
registerDaemonCommands(program);
87-
registerDaemonCommands(program, { base: 'gateway', deprecated: true });
8887
registerDoctorCommand(program);
8988
registerProfileCommands(program);
9089
registerReauthCommand(program);

src/types/config.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,4 @@ describe('DaemonConfig', () => {
1313
};
1414
expect(cfg.scheduler?.watchedFolders[0].path).toBe('/tmp/x');
1515
});
16-
17-
test('Config accepts both daemon and gateway (back-compat)', () => {
18-
const cfg: Config = {
19-
profiles: {},
20-
daemon: { apiKey: 'a' },
21-
gateway: { apiKey: 'b' },
22-
};
23-
expect(cfg.daemon?.apiKey).toBe('a');
24-
expect(cfg.gateway?.apiKey).toBe('b');
25-
});
2616
});

src/types/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export interface Config {
5656
};
5757
env?: Record<string, string>;
5858
daemon?: DaemonConfig;
59-
gateway?: GatewayConfig; // legacy; read-only, migrated to daemon on load
6059
}
6160

6261
export type ServiceName = 'gdocs' | 'gdrive' | 'gmail' | 'gcal' | 'gtasks' | 'gchat' | 'gsheets' | 'gslides' | 'gscript' | 'github' | 'jira' | 'confluence' | 'slack' | 'telegram' | 'discourse' | 'sql';

0 commit comments

Comments
 (0)