@agenteract/core 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cjs/package.json +3 -1
  2. package/dist/cjs/src/config-types.d.ts +29 -0
  3. package/dist/cjs/src/config-types.js +2 -0
  4. package/dist/cjs/src/index.d.ts +1 -0
  5. package/dist/cjs/src/index.js +15 -0
  6. package/dist/cjs/src/node/config.d.ts +52 -0
  7. package/dist/cjs/src/node/config.js +324 -0
  8. package/dist/cjs/src/node/index.d.ts +2 -0
  9. package/dist/cjs/src/node/index.js +18 -0
  10. package/dist/cjs/src/node/pnpm.d.ts +5 -0
  11. package/dist/cjs/src/node/pnpm.js +12 -0
  12. package/dist/esm/package.json +3 -1
  13. package/dist/esm/src/config-types.d.ts +29 -0
  14. package/dist/esm/src/config-types.js +1 -0
  15. package/dist/esm/src/index.d.ts +1 -0
  16. package/dist/esm/src/index.js +1 -0
  17. package/dist/esm/src/node/config.d.ts +52 -0
  18. package/dist/esm/src/node/config.js +303 -0
  19. package/dist/esm/src/node/index.d.ts +2 -0
  20. package/dist/esm/src/node/index.js +2 -0
  21. package/dist/esm/src/node/pnpm.d.ts +5 -0
  22. package/dist/esm/src/node/pnpm.js +9 -0
  23. package/dist/src/config-types.d.ts +29 -0
  24. package/dist/src/config-types.js +1 -0
  25. package/dist/src/index.d.ts +19 -0
  26. package/dist/src/index.js +25 -0
  27. package/dist/src/node/config.d.ts +52 -0
  28. package/dist/src/node/config.js +303 -0
  29. package/dist/src/node/index.d.ts +2 -0
  30. package/dist/src/node/index.js +2 -0
  31. package/dist/src/node/pnpm.d.ts +5 -0
  32. package/dist/src/node/pnpm.js +9 -0
  33. package/package.json +16 -3
  34. package/NOTICE +0 -4
  35. package/dist/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  36. package/dist/esm/tsconfig.esm.tsbuildinfo +0 -1
  37. package/src/index.ts +0 -43
  38. package/tsconfig.cjs.json +0 -8
  39. package/tsconfig.esm.json +0 -8
  40. package/tsconfig.json +0 -11
@@ -1 +1,3 @@
1
- {"type":"commonjs"}
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,29 @@
1
+ export interface DevServerConfig {
2
+ command: string;
3
+ port: number;
4
+ cwd?: string;
5
+ env?: Record<string, string>;
6
+ validation?: {
7
+ fileExists?: string[];
8
+ commandInPath?: string;
9
+ errorHints?: Record<string, string>;
10
+ };
11
+ keyCommands?: Record<string, string>;
12
+ }
13
+ export interface ProjectConfig {
14
+ name: string;
15
+ path: string;
16
+ type?: 'expo' | 'vite' | 'flutter' | 'native' | 'auto';
17
+ ptyPort?: number;
18
+ devServer?: DevServerConfig;
19
+ scheme?: string;
20
+ }
21
+ export interface AgenteractConfig {
22
+ server?: {
23
+ port?: number;
24
+ wsPort?: number;
25
+ logPort?: number;
26
+ };
27
+ port?: number;
28
+ projects: ProjectConfig[];
29
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -16,3 +16,4 @@ export declare function detectInvoker(): {
16
16
  isNpx: boolean;
17
17
  isPnpmDlx: boolean;
18
18
  };
19
+ export * from './config-types.js';
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.AGENTERACT_PROTOCOL_VERSION = void 0;
4
18
  exports.encodeMessage = encodeMessage;
@@ -30,3 +44,4 @@ function detectInvoker() {
30
44
  const isPnpmDlx = pkgManager === 'pnpm' && process.argv[1]?.includes('dlx');
31
45
  return { pkgManager, isNpx, isPnpmDlx };
32
46
  }
47
+ __exportStar(require("./config-types.js"), exports);
@@ -0,0 +1,52 @@
1
+ import { AgenteractConfig, DevServerConfig, ProjectConfig } from '../config-types.js';
2
+ export interface RuntimeConfig {
3
+ host: string;
4
+ port: number;
5
+ token: string;
6
+ defaultDevices?: Record<string, string>;
7
+ }
8
+ export declare function getRuntimeConfigPath(cwd?: string): string;
9
+ export declare function saveRuntimeConfig(config: RuntimeConfig, cwd?: string): Promise<void>;
10
+ export declare function loadRuntimeConfig(cwd?: string): Promise<RuntimeConfig | null>;
11
+ export declare function deleteRuntimeConfig(cwd?: string): Promise<void>;
12
+ export declare function generateAuthToken(): string;
13
+ /**
14
+ * Set the default device for a project
15
+ */
16
+ export declare function setDefaultDevice(projectName: string, deviceId: string, cwd?: string): Promise<void>;
17
+ /**
18
+ * Get the default device for a project
19
+ */
20
+ export declare function getDefaultDevice(projectName: string, cwd?: string): Promise<string | undefined>;
21
+ export declare class MissingConfigError extends Error {
22
+ constructor(message: string);
23
+ }
24
+ export declare function loadConfig(rootDir: string): Promise<AgenteractConfig>;
25
+ /**
26
+ * Find the root directory containing agenteract.config.js
27
+ * Searches upward from the current working directory
28
+ */
29
+ export declare function findConfigRoot(startDir?: string): Promise<string | null>;
30
+ /**
31
+ * Get the URL for the agent server
32
+ */
33
+ export declare function getAgentServerUrl(config: AgenteractConfig): string;
34
+ /**
35
+ * Get the URL for a project's dev server
36
+ */
37
+ export declare function getProjectServerUrl(config: AgenteractConfig, projectName: string): string | null;
38
+ /**
39
+ * Get the URL for a dev server by type
40
+ */
41
+ export declare function getDevServerUrlByType(config: AgenteractConfig, type: 'expo' | 'vite' | 'flutter'): string | null;
42
+ /**
43
+ * Type presets for backward compatibility
44
+ * Maps old 'type' field to new devServer configuration
45
+ */
46
+ export declare const TYPE_PRESETS: Record<string, Omit<DevServerConfig, 'port'>>;
47
+ export declare function addConfig(rootDir: string, projectPath: string, name: string, typeOrCommand: string, port?: number, scheme?: string): Promise<void>;
48
+ /**
49
+ * Normalize project config: migrate old format to new format
50
+ * Logs deprecation warnings when using old 'type' field
51
+ */
52
+ export declare function normalizeProjectConfig(project: ProjectConfig, rootDir: string): ProjectConfig;
@@ -0,0 +1,324 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TYPE_PRESETS = exports.MissingConfigError = void 0;
7
+ exports.getRuntimeConfigPath = getRuntimeConfigPath;
8
+ exports.saveRuntimeConfig = saveRuntimeConfig;
9
+ exports.loadRuntimeConfig = loadRuntimeConfig;
10
+ exports.deleteRuntimeConfig = deleteRuntimeConfig;
11
+ exports.generateAuthToken = generateAuthToken;
12
+ exports.setDefaultDevice = setDefaultDevice;
13
+ exports.getDefaultDevice = getDefaultDevice;
14
+ exports.loadConfig = loadConfig;
15
+ exports.findConfigRoot = findConfigRoot;
16
+ exports.getAgentServerUrl = getAgentServerUrl;
17
+ exports.getProjectServerUrl = getProjectServerUrl;
18
+ exports.getDevServerUrlByType = getDevServerUrlByType;
19
+ exports.addConfig = addConfig;
20
+ exports.normalizeProjectConfig = normalizeProjectConfig;
21
+ const promises_1 = __importDefault(require("fs/promises"));
22
+ const path_1 = __importDefault(require("path"));
23
+ const crypto_1 = require("crypto");
24
+ function getRuntimeConfigPath(cwd = process.cwd()) {
25
+ return path_1.default.join(cwd, '.agenteract-runtime.json');
26
+ }
27
+ async function saveRuntimeConfig(config, cwd = process.cwd()) {
28
+ await promises_1.default.writeFile(getRuntimeConfigPath(cwd), JSON.stringify(config, null, 2));
29
+ }
30
+ async function loadRuntimeConfig(cwd = process.cwd()) {
31
+ try {
32
+ const content = await promises_1.default.readFile(getRuntimeConfigPath(cwd), 'utf-8');
33
+ return JSON.parse(content);
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ async function deleteRuntimeConfig(cwd = process.cwd()) {
40
+ try {
41
+ await promises_1.default.unlink(getRuntimeConfigPath(cwd));
42
+ }
43
+ catch {
44
+ // Ignore if file doesn't exist
45
+ }
46
+ }
47
+ function generateAuthToken() {
48
+ return (0, crypto_1.randomUUID)();
49
+ }
50
+ /**
51
+ * Set the default device for a project
52
+ */
53
+ async function setDefaultDevice(projectName, deviceId, cwd = process.cwd()) {
54
+ const config = await loadRuntimeConfig(cwd);
55
+ if (!config) {
56
+ throw new Error('Runtime config not found. Is the server running?');
57
+ }
58
+ if (!config.defaultDevices) {
59
+ config.defaultDevices = {};
60
+ }
61
+ config.defaultDevices[projectName] = deviceId;
62
+ await saveRuntimeConfig(config, cwd);
63
+ }
64
+ /**
65
+ * Get the default device for a project
66
+ */
67
+ async function getDefaultDevice(projectName, cwd = process.cwd()) {
68
+ const config = await loadRuntimeConfig(cwd);
69
+ return config?.defaultDevices?.[projectName];
70
+ }
71
+ class MissingConfigError extends Error {
72
+ constructor(message) {
73
+ super(message);
74
+ this.name = 'MissingConfigError';
75
+ }
76
+ }
77
+ exports.MissingConfigError = MissingConfigError;
78
+ async function loadConfig(rootDir) {
79
+ const configPath = path_1.default.join(rootDir, 'agenteract.config.js');
80
+ try {
81
+ await promises_1.default.access(configPath);
82
+ }
83
+ catch (error) {
84
+ throw new MissingConfigError('Agenteract config file not found');
85
+ }
86
+ // In a Jest environment, dynamic import() of file URLs can be tricky.
87
+ // A simple and effective workaround is to read the file and evaluate it.
88
+ // This avoids the module resolution issues within the test runner.
89
+ const configContent = await promises_1.default.readFile(configPath, 'utf-8');
90
+ // A simple regex to extract the default export object.
91
+ // This is not a full parser, but it's robust enough for our config file format.
92
+ const match = configContent.match(/export default (\{[\s\S]*\});/);
93
+ if (!match) {
94
+ console.error(`configContent: ${configContent}`);
95
+ throw new Error('Could not parse agenteract.config.js. Make sure it has a default export.');
96
+ }
97
+ // We can use Function to evaluate the object literal.
98
+ // It's safer than eval() because it doesn't have access to the outer scope.
99
+ return new Function(`return ${match[1]}`)();
100
+ }
101
+ /**
102
+ * Find the root directory containing agenteract.config.js
103
+ * Searches upward from the current working directory
104
+ */
105
+ async function findConfigRoot(startDir = process.cwd()) {
106
+ let currentDir = startDir;
107
+ const root = path_1.default.parse(currentDir).root;
108
+ while (currentDir !== root) {
109
+ const configPath = path_1.default.join(currentDir, 'agenteract.config.js');
110
+ try {
111
+ await promises_1.default.access(configPath);
112
+ return currentDir;
113
+ }
114
+ catch {
115
+ currentDir = path_1.default.dirname(currentDir);
116
+ }
117
+ }
118
+ return null;
119
+ }
120
+ /**
121
+ * Get the URL for the agent server
122
+ */
123
+ function getAgentServerUrl(config) {
124
+ return `http://localhost:${config.port || 8766}`;
125
+ }
126
+ /**
127
+ * Get the URL for a project's dev server
128
+ */
129
+ function getProjectServerUrl(config, projectName) {
130
+ const project = config.projects.find(p => p.name === projectName);
131
+ if (!project)
132
+ return null;
133
+ // Check new devServer format first, then legacy ptyPort
134
+ const port = project.devServer?.port || project.ptyPort;
135
+ if (!port) {
136
+ return null;
137
+ }
138
+ return `http://localhost:${port}`;
139
+ }
140
+ /**
141
+ * Get the URL for a dev server by type
142
+ */
143
+ function getDevServerUrlByType(config, type) {
144
+ const project = config.projects.find(p => p.type === type && (p.ptyPort || p.devServer?.port));
145
+ if (!project) {
146
+ return null;
147
+ }
148
+ const port = project.devServer?.port || project.ptyPort;
149
+ return `http://localhost:${port}`;
150
+ }
151
+ /**
152
+ * Type presets for backward compatibility
153
+ * Maps old 'type' field to new devServer configuration
154
+ */
155
+ exports.TYPE_PRESETS = {
156
+ expo: {
157
+ command: 'npx expo start',
158
+ keyCommands: { reload: 'r', ios: 'i', android: 'a' }
159
+ },
160
+ vite: {
161
+ command: 'npx vite',
162
+ keyCommands: { reload: 'r', quit: 'q' }
163
+ },
164
+ flutter: {
165
+ command: 'flutter run',
166
+ validation: {
167
+ fileExists: ['pubspec.yaml'],
168
+ commandInPath: 'flutter',
169
+ errorHints: {
170
+ 'command not found': 'Install Flutter: https://flutter.dev/docs/get-started/install',
171
+ 'No pubspec.yaml': 'Flutter projects require a pubspec.yaml file in the project directory'
172
+ }
173
+ },
174
+ keyCommands: { reload: 'r', restart: 'R', quit: 'q', help: 'h' }
175
+ }
176
+ };
177
+ /**
178
+ * Get default PTY port for a given type
179
+ */
180
+ function getDefaultPortForType(type) {
181
+ const defaults = {
182
+ expo: 8790,
183
+ vite: 8791,
184
+ flutter: 8792
185
+ };
186
+ return defaults[type] || 8790;
187
+ }
188
+ async function addConfig(rootDir, projectPath, name, typeOrCommand, port, scheme) {
189
+ const configPath = path_1.default.join(rootDir, 'agenteract.config.js');
190
+ let config;
191
+ try {
192
+ config = await loadConfig(rootDir);
193
+ }
194
+ catch (error) {
195
+ if (error instanceof MissingConfigError) {
196
+ config = { port: 8766, projects: [] };
197
+ }
198
+ else {
199
+ // For other errors (like parsing), we should not proceed.
200
+ throw error;
201
+ }
202
+ }
203
+ config.projects = config.projects || [];
204
+ let nameExists = config.projects.find((p) => p.name === name);
205
+ let pathExists = config.projects.find((p) => p.path === projectPath);
206
+ if ((nameExists || pathExists) && nameExists !== pathExists) {
207
+ console.error('project name and path exist across multiple projects. Please use a different name or path.');
208
+ console.error(`name: ${name}, path: ${projectPath}`);
209
+ return;
210
+ }
211
+ let update = nameExists || pathExists;
212
+ // Determine if this is legacy format (type) or new format (command)
213
+ const LEGACY_TYPES = ['expo', 'vite', 'flutter', 'native'];
214
+ const isLegacyFormat = LEGACY_TYPES.includes(typeOrCommand);
215
+ // Allocate a port if not provided
216
+ let ptyPort;
217
+ if (port) {
218
+ // Explicit port provided
219
+ ptyPort = port;
220
+ }
221
+ else if (update) {
222
+ // Reuse existing port when updating
223
+ ptyPort = update.ptyPort || update.devServer?.port || 8790;
224
+ }
225
+ else {
226
+ // Find next available port for new project
227
+ ptyPort = 8790;
228
+ while (config.projects.some((p) => (p.ptyPort === ptyPort) || (p.devServer?.port === ptyPort))) {
229
+ ptyPort++;
230
+ }
231
+ }
232
+ let newProjectConfig;
233
+ if (isLegacyFormat) {
234
+ // Legacy format: use old 'type' field for backwards compatibility
235
+ // Native apps don't have dev servers
236
+ if (typeOrCommand === 'native') {
237
+ newProjectConfig = {
238
+ name,
239
+ path: projectPath,
240
+ type: 'native',
241
+ ...(scheme && { scheme })
242
+ };
243
+ }
244
+ else {
245
+ // For non-native legacy types, create with new devServer format
246
+ const preset = exports.TYPE_PRESETS[typeOrCommand];
247
+ if (!preset) {
248
+ console.error(`Unknown type '${typeOrCommand}'`);
249
+ return;
250
+ }
251
+ newProjectConfig = {
252
+ name,
253
+ path: projectPath,
254
+ devServer: {
255
+ ...preset,
256
+ port: ptyPort
257
+ },
258
+ ...(scheme && { scheme })
259
+ };
260
+ console.log(`ℹ️ Creating config with new devServer format (migrated from legacy type '${typeOrCommand}')`);
261
+ }
262
+ }
263
+ else {
264
+ // New format: generic dev server command
265
+ newProjectConfig = {
266
+ name,
267
+ path: projectPath,
268
+ devServer: {
269
+ command: typeOrCommand,
270
+ port: ptyPort
271
+ },
272
+ ...(scheme && { scheme })
273
+ };
274
+ }
275
+ // If the project already exists, replace it completely
276
+ if (update) {
277
+ // Find the index and replace the entire object to avoid keeping old fields
278
+ const index = config.projects.indexOf(update);
279
+ config.projects[index] = newProjectConfig;
280
+ }
281
+ else {
282
+ config.projects.push(newProjectConfig);
283
+ }
284
+ await promises_1.default.writeFile(configPath, `export default ${JSON.stringify(config, null, 2)};`);
285
+ console.log(`✅ Config updated: ${name} at ${projectPath}`);
286
+ if (newProjectConfig.devServer) {
287
+ console.log(` Dev server: ${newProjectConfig.devServer.command} (port: ${newProjectConfig.devServer.port})`);
288
+ }
289
+ if (scheme) {
290
+ console.log(` URL scheme: ${scheme}`);
291
+ }
292
+ }
293
+ /**
294
+ * Normalize project config: migrate old format to new format
295
+ * Logs deprecation warnings when using old 'type' field
296
+ */
297
+ function normalizeProjectConfig(project, rootDir) {
298
+ // Already using new format
299
+ if (project.devServer) {
300
+ return project;
301
+ }
302
+ // Native type has no dev server
303
+ if (project.type === 'native') {
304
+ return project;
305
+ }
306
+ // Auto-migrate from old type-based format
307
+ if (project.type && project.type !== 'auto') {
308
+ console.warn(`⚠️ [${project.name}] Using deprecated 'type' field. ` +
309
+ `Migrate to 'devServer' config. See docs/MIGRATION_V2.md`);
310
+ const preset = exports.TYPE_PRESETS[project.type];
311
+ if (!preset) {
312
+ console.error(`Unknown type '${project.type}' for project '${project.name}'`);
313
+ return project;
314
+ }
315
+ return {
316
+ ...project,
317
+ devServer: {
318
+ ...preset,
319
+ port: project.ptyPort || getDefaultPortForType(project.type)
320
+ }
321
+ };
322
+ }
323
+ return project;
324
+ }
@@ -0,0 +1,2 @@
1
+ export * from './config.js';
2
+ export * from './pnpm.js';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config.js"), exports);
18
+ __exportStar(require("./pnpm.js"), exports);
@@ -0,0 +1,5 @@
1
+ /**
2
+ * if we're running in the agenteract monorepo, set node's CWD back to the original working directory
3
+ * otherwise pnpm commands have CWD set to the monorepo root
4
+ */
5
+ export declare function resetPNPMWorkspaceCWD(): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resetPNPMWorkspaceCWD = resetPNPMWorkspaceCWD;
4
+ /**
5
+ * if we're running in the agenteract monorepo, set node's CWD back to the original working directory
6
+ * otherwise pnpm commands have CWD set to the monorepo root
7
+ */
8
+ function resetPNPMWorkspaceCWD() {
9
+ if (process.env.PNPM_PACKAGE_NAME == 'agenteract' && process.env.PWD && process.env.PWD !== process.cwd()) {
10
+ process.chdir(process.env.PWD);
11
+ }
12
+ }
@@ -1 +1,3 @@
1
- {"type":"module"}
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,29 @@
1
+ export interface DevServerConfig {
2
+ command: string;
3
+ port: number;
4
+ cwd?: string;
5
+ env?: Record<string, string>;
6
+ validation?: {
7
+ fileExists?: string[];
8
+ commandInPath?: string;
9
+ errorHints?: Record<string, string>;
10
+ };
11
+ keyCommands?: Record<string, string>;
12
+ }
13
+ export interface ProjectConfig {
14
+ name: string;
15
+ path: string;
16
+ type?: 'expo' | 'vite' | 'flutter' | 'native' | 'auto';
17
+ ptyPort?: number;
18
+ devServer?: DevServerConfig;
19
+ scheme?: string;
20
+ }
21
+ export interface AgenteractConfig {
22
+ server?: {
23
+ port?: number;
24
+ wsPort?: number;
25
+ logPort?: number;
26
+ };
27
+ port?: number;
28
+ projects: ProjectConfig[];
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -16,3 +16,4 @@ export declare function detectInvoker(): {
16
16
  isNpx: boolean;
17
17
  isPnpmDlx: boolean;
18
18
  };
19
+ export * from './config-types.js';
@@ -22,3 +22,4 @@ export function detectInvoker() {
22
22
  const isPnpmDlx = pkgManager === 'pnpm' && process.argv[1]?.includes('dlx');
23
23
  return { pkgManager, isNpx, isPnpmDlx };
24
24
  }
25
+ export * from './config-types.js';
@@ -0,0 +1,52 @@
1
+ import { AgenteractConfig, DevServerConfig, ProjectConfig } from '../config-types.js';
2
+ export interface RuntimeConfig {
3
+ host: string;
4
+ port: number;
5
+ token: string;
6
+ defaultDevices?: Record<string, string>;
7
+ }
8
+ export declare function getRuntimeConfigPath(cwd?: string): string;
9
+ export declare function saveRuntimeConfig(config: RuntimeConfig, cwd?: string): Promise<void>;
10
+ export declare function loadRuntimeConfig(cwd?: string): Promise<RuntimeConfig | null>;
11
+ export declare function deleteRuntimeConfig(cwd?: string): Promise<void>;
12
+ export declare function generateAuthToken(): string;
13
+ /**
14
+ * Set the default device for a project
15
+ */
16
+ export declare function setDefaultDevice(projectName: string, deviceId: string, cwd?: string): Promise<void>;
17
+ /**
18
+ * Get the default device for a project
19
+ */
20
+ export declare function getDefaultDevice(projectName: string, cwd?: string): Promise<string | undefined>;
21
+ export declare class MissingConfigError extends Error {
22
+ constructor(message: string);
23
+ }
24
+ export declare function loadConfig(rootDir: string): Promise<AgenteractConfig>;
25
+ /**
26
+ * Find the root directory containing agenteract.config.js
27
+ * Searches upward from the current working directory
28
+ */
29
+ export declare function findConfigRoot(startDir?: string): Promise<string | null>;
30
+ /**
31
+ * Get the URL for the agent server
32
+ */
33
+ export declare function getAgentServerUrl(config: AgenteractConfig): string;
34
+ /**
35
+ * Get the URL for a project's dev server
36
+ */
37
+ export declare function getProjectServerUrl(config: AgenteractConfig, projectName: string): string | null;
38
+ /**
39
+ * Get the URL for a dev server by type
40
+ */
41
+ export declare function getDevServerUrlByType(config: AgenteractConfig, type: 'expo' | 'vite' | 'flutter'): string | null;
42
+ /**
43
+ * Type presets for backward compatibility
44
+ * Maps old 'type' field to new devServer configuration
45
+ */
46
+ export declare const TYPE_PRESETS: Record<string, Omit<DevServerConfig, 'port'>>;
47
+ export declare function addConfig(rootDir: string, projectPath: string, name: string, typeOrCommand: string, port?: number, scheme?: string): Promise<void>;
48
+ /**
49
+ * Normalize project config: migrate old format to new format
50
+ * Logs deprecation warnings when using old 'type' field
51
+ */
52
+ export declare function normalizeProjectConfig(project: ProjectConfig, rootDir: string): ProjectConfig;