@0xmaxma/claude-gateway 1.1.9 → 1.2.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 (67) hide show
  1. package/README.md +61 -1
  2. package/dist/agent/builtin-commands.d.ts +10 -0
  3. package/dist/agent/builtin-commands.d.ts.map +1 -0
  4. package/dist/agent/builtin-commands.js +38 -0
  5. package/dist/agent/builtin-commands.js.map +1 -0
  6. package/dist/agent/runner.d.ts +7 -5
  7. package/dist/agent/runner.d.ts.map +1 -1
  8. package/dist/agent/runner.js +56 -30
  9. package/dist/agent/runner.js.map +1 -1
  10. package/dist/agent/workspace-loader.d.ts.map +1 -1
  11. package/dist/agent/workspace-loader.js +9 -4
  12. package/dist/agent/workspace-loader.js.map +1 -1
  13. package/dist/api/apps-router.d.ts +7 -0
  14. package/dist/api/apps-router.d.ts.map +1 -0
  15. package/dist/api/apps-router.js +242 -0
  16. package/dist/api/apps-router.js.map +1 -0
  17. package/dist/api/gateway-router.d.ts +17 -1
  18. package/dist/api/gateway-router.d.ts.map +1 -1
  19. package/dist/api/gateway-router.js +171 -2
  20. package/dist/api/gateway-router.js.map +1 -1
  21. package/dist/api/router.d.ts.map +1 -1
  22. package/dist/api/router.js +385 -4
  23. package/dist/api/router.js.map +1 -1
  24. package/dist/apps/agent-manager.d.ts +76 -0
  25. package/dist/apps/agent-manager.d.ts.map +1 -0
  26. package/dist/apps/agent-manager.js +311 -0
  27. package/dist/apps/agent-manager.js.map +1 -0
  28. package/dist/apps/compose-generator.d.ts +108 -0
  29. package/dist/apps/compose-generator.d.ts.map +1 -0
  30. package/dist/apps/compose-generator.js +687 -0
  31. package/dist/apps/compose-generator.js.map +1 -0
  32. package/dist/apps/installer.d.ts +101 -0
  33. package/dist/apps/installer.d.ts.map +1 -0
  34. package/dist/apps/installer.js +898 -0
  35. package/dist/apps/installer.js.map +1 -0
  36. package/dist/apps/registry-client.d.ts +37 -0
  37. package/dist/apps/registry-client.d.ts.map +1 -0
  38. package/dist/apps/registry-client.js +106 -0
  39. package/dist/apps/registry-client.js.map +1 -0
  40. package/dist/apps/registry.d.ts +54 -0
  41. package/dist/apps/registry.d.ts.map +1 -0
  42. package/dist/apps/registry.js +182 -0
  43. package/dist/apps/registry.js.map +1 -0
  44. package/dist/apps/socket-server.d.ts +46 -0
  45. package/dist/apps/socket-server.d.ts.map +1 -0
  46. package/dist/apps/socket-server.js +297 -0
  47. package/dist/apps/socket-server.js.map +1 -0
  48. package/dist/config/watcher.d.ts +1 -0
  49. package/dist/config/watcher.d.ts.map +1 -1
  50. package/dist/config/watcher.js +55 -2
  51. package/dist/config/watcher.js.map +1 -1
  52. package/dist/index.js +170 -3
  53. package/dist/index.js.map +1 -1
  54. package/dist/session/process.d.ts.map +1 -1
  55. package/dist/session/process.js +47 -6
  56. package/dist/session/process.js.map +1 -1
  57. package/dist/types.d.ts +6 -0
  58. package/dist/types.d.ts.map +1 -1
  59. package/mcp/server.ts +2 -0
  60. package/mcp/tools/apps/client.ts +78 -0
  61. package/mcp/tools/apps/module.ts +211 -0
  62. package/mcp/tools/apps/skills/app-status/SKILL.md +48 -0
  63. package/mcp/tools/apps/skills/create-app-yaml/SKILL.md +94 -0
  64. package/mcp/tools/apps/skills/install-app/SKILL.md +102 -0
  65. package/mcp/tools/apps/skills/list-apps/SKILL.md +34 -0
  66. package/mcp/tools/telegram/receiver-server.ts +36 -2
  67. package/package.json +1 -1
@@ -0,0 +1,311 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AgentManager = void 0;
40
+ const fs = __importStar(require("node:fs"));
41
+ const path = __importStar(require("node:path"));
42
+ const os = __importStar(require("node:os"));
43
+ const node_child_process_1 = require("node:child_process");
44
+ const js_yaml_1 = __importDefault(require("js-yaml"));
45
+ // ─── Constants ────────────────────────────────────────────────────────────────
46
+ const DEFAULT_CONFIG_PATH = path.join(os.homedir(), '.claude-gateway', 'config.json');
47
+ const DEFAULT_AGENTS_DIR = path.join(os.homedir(), '.claude-gateway', 'agents');
48
+ // ─── AgentManager ────────────────────────────────────────────────────────────
49
+ class AgentManager {
50
+ constructor(configPath = DEFAULT_CONFIG_PATH, agentsDir = DEFAULT_AGENTS_DIR) {
51
+ this.configPath = configPath;
52
+ this.agentsDir = agentsDir;
53
+ /** Serialises concurrent config reads/writes within this process. */
54
+ this.configLock = Promise.resolve();
55
+ }
56
+ async withConfigLock(fn) {
57
+ let release;
58
+ const prev = this.configLock;
59
+ this.configLock = new Promise((r) => { release = r; });
60
+ await prev;
61
+ try {
62
+ return fn();
63
+ }
64
+ finally {
65
+ release();
66
+ }
67
+ }
68
+ // ─── Public API ────────────────────────────────────────────────────────────
69
+ /**
70
+ * Detect host binary paths for injection into the agent container.
71
+ * Runs once at install time; results stored in apps.json.
72
+ */
73
+ detectAgentPaths() {
74
+ const run = (cmd) => (0, node_child_process_1.execSync)(cmd, { encoding: 'utf-8' }).toString().trim();
75
+ const claudeBin = run('which claude');
76
+ const realClaudeBin = fs.realpathSync(claudeBin);
77
+ const nodeBin = fs.realpathSync(run('which node'));
78
+ const npmRoot = run('npm root -g');
79
+ return { claudeBin: realClaudeBin, nodeBin, npmRoot };
80
+ }
81
+ /**
82
+ * Inject the `agent` service into an already-generated docker-compose.yml.
83
+ * No-op if entry has no agentDeclaration or agentPaths.
84
+ *
85
+ * Uses debian:stable-slim (glibc required — host node binary is glibc-linked).
86
+ * All binaries and auth files are bind-mounted directly from their resolved host paths.
87
+ */
88
+ injectAgentService(entry) {
89
+ if (!entry.agentDeclaration || !entry.agentPaths)
90
+ return;
91
+ const composePath = path.join(entry.installPath, 'docker-compose.yml');
92
+ const raw = fs.readFileSync(composePath, 'utf-8');
93
+ const compose = js_yaml_1.default.load(raw, { schema: js_yaml_1.default.DEFAULT_SCHEMA });
94
+ const { name: agentName, path: agentRelPath } = entry.agentDeclaration;
95
+ const { claudeBin, nodeBin, npmRoot } = entry.agentPaths;
96
+ const homeDir = os.homedir();
97
+ // Resolve symlinks so Docker daemon gets the real path — avoids Docker creating
98
+ // a root-owned empty directory instead of bind-mounting the existing one.
99
+ const workspaceDir = fs.realpathSync(path.join(entry.installPath, agentRelPath));
100
+ let uid = 1000;
101
+ try {
102
+ uid = os.userInfo().uid;
103
+ }
104
+ catch { /* use 1000 */ }
105
+ // Write Dockerfile.agent: install curl + pre-create ~/.claude owned by host uid so
106
+ // Docker bind-mounts land inside a uid-1000-owned dir and Claude Code can freely
107
+ // create subdirs (session-env, todos, etc.) at runtime without cap_drop: ALL blocking chown.
108
+ const dockerfileAgentPath = path.join(entry.installPath, 'Dockerfile.agent');
109
+ fs.writeFileSync(dockerfileAgentPath, [
110
+ 'FROM debian:stable-slim',
111
+ `RUN apt-get update && apt-get install -y curl --no-install-recommends \\`,
112
+ ` && rm -rf /var/lib/apt/lists/* \\`,
113
+ ` && mkdir -p ${homeDir}/.claude \\`,
114
+ ` && chown -R ${uid}:${uid} ${homeDir}`,
115
+ ].join('\n') + '\n');
116
+ const agentService = {
117
+ build: { context: entry.installPath, dockerfile: 'Dockerfile.agent' },
118
+ user: `${uid}:${uid}`,
119
+ command: `sleep infinity`,
120
+ container_name: `${entry.name}-agent`,
121
+ restart: 'unless-stopped',
122
+ cap_drop: ['ALL'],
123
+ security_opt: ['no-new-privileges'],
124
+ env_file: '.env',
125
+ volumes: [
126
+ `${claudeBin}:${claudeBin}:ro`,
127
+ `${nodeBin}:/usr/bin/node:ro`,
128
+ `${npmRoot}:${npmRoot}:ro`,
129
+ `${homeDir}/.claude.json:${homeDir}/.claude.json:ro`,
130
+ `${homeDir}/.claude/settings.json:${homeDir}/.claude/settings.json:ro`,
131
+ `${workspaceDir}:/workspace`,
132
+ ],
133
+ };
134
+ const services = (compose.services ?? {});
135
+ services['agent'] = agentService;
136
+ compose['services'] = services;
137
+ fs.writeFileSync(composePath, js_yaml_1.default.dump(compose, { lineWidth: -1 }), 'utf-8');
138
+ }
139
+ /**
140
+ * Create ~/.claude-gateway/agents/{agentName} → ~/.claude-gateway/apps/{app}/agent
141
+ * symlink and upsert the config.json entry.
142
+ *
143
+ * Docker mounts the real targetDir directly, so it never touches this symlink
144
+ * and cannot pre-create it as a root-owned directory.
145
+ * Idempotent — safe to call multiple times (reconcile, reinstall).
146
+ */
147
+ async upsertAgent(entry) {
148
+ if (!entry.agentDeclaration || !entry.agentPaths)
149
+ return;
150
+ const { name: agentName, path: agentRelPath } = entry.agentDeclaration;
151
+ // Layout mirrors a normal agent: agents/{agentName}/ (real dir) + workspace/ (symlink)
152
+ // This ensures process.ts configPath resolution (workspace/../../.. → gateway base) is correct.
153
+ const agentDir = path.join(this.agentsDir, agentName);
154
+ const workspaceLink = path.join(agentDir, 'workspace');
155
+ const targetDir = fs.realpathSync(path.join(entry.installPath, agentRelPath));
156
+ fs.mkdirSync(agentDir, { recursive: true });
157
+ try {
158
+ fs.rmSync(workspaceLink, { force: true, recursive: true });
159
+ }
160
+ catch { /* ignore */ }
161
+ fs.symlinkSync(targetDir, workspaceLink);
162
+ try {
163
+ await this.upsertConfigEntry(agentName, {
164
+ id: agentName,
165
+ type: 'app-agent',
166
+ description: `Agent for app ${entry.name}`,
167
+ container: `${entry.name}-agent`,
168
+ claudeBin: entry.agentPaths.claudeBin,
169
+ workspace: workspaceLink,
170
+ env: '',
171
+ allow_tools: true,
172
+ claude: {
173
+ model: 'claude-sonnet-4-6',
174
+ dangerouslySkipPermissions: true,
175
+ extraFlags: [],
176
+ },
177
+ });
178
+ }
179
+ catch (err) {
180
+ // Rollback workspace symlink if config write fails to avoid orphaned symlink
181
+ try {
182
+ fs.rmSync(workspaceLink, { force: true });
183
+ }
184
+ catch { /* best-effort */ }
185
+ throw err;
186
+ }
187
+ }
188
+ /**
189
+ * Remove the workspace symlink and config entry for this app's agent.
190
+ * Preserves the agent dir (and its sessions) so reinstalling picks up history.
191
+ */
192
+ async deleteAgent(entry) {
193
+ if (!entry.agentDeclaration)
194
+ return;
195
+ await this.deleteAgentByName(entry.agentDeclaration.name);
196
+ }
197
+ /**
198
+ * Remove by agent name — used in install rollback where AppEntry may not be in scope.
199
+ * Only removes the workspace symlink; preserves sessions/ and other data so that
200
+ * a reinstall picks up the same conversation history.
201
+ */
202
+ async deleteAgentByName(agentName) {
203
+ const workspaceLink = path.join(this.agentsDir, agentName, 'workspace');
204
+ try {
205
+ fs.rmSync(workspaceLink, { force: true });
206
+ }
207
+ catch { /* already gone */ }
208
+ await this.removeConfigEntry(agentName);
209
+ }
210
+ /**
211
+ * Idempotent reconcile — called at gateway startup to ensure all app-agents
212
+ * that are running have their symlink + config.json entry in place.
213
+ * Returns a list of errors for apps that could not be reconciled (non-fatal).
214
+ */
215
+ async reconcileAgents(registry) {
216
+ const apps = await registry.list();
217
+ const errors = [];
218
+ for (const app of apps) {
219
+ if (app.agentDeclaration && app.status === 'running') {
220
+ try {
221
+ await this.upsertAgent(app);
222
+ }
223
+ catch (err) {
224
+ errors.push({ app: app.name, error: err.message });
225
+ }
226
+ }
227
+ }
228
+ return errors;
229
+ }
230
+ /**
231
+ * Read MEMORY.md for the given agent, returning its content or null if absent.
232
+ * Called before an update to preserve agent memory across version swaps.
233
+ */
234
+ backupMemory(agentName) {
235
+ const workspace = this.getWorkspacePath(agentName);
236
+ if (!workspace)
237
+ return null;
238
+ try {
239
+ return fs.readFileSync(path.join(workspace, 'MEMORY.md'), 'utf-8');
240
+ }
241
+ catch {
242
+ return null;
243
+ }
244
+ }
245
+ /**
246
+ * Write MEMORY.md back after a successful update.
247
+ */
248
+ restoreMemory(agentName, content) {
249
+ const workspace = this.getWorkspacePath(agentName);
250
+ if (!workspace)
251
+ return;
252
+ fs.writeFileSync(path.join(workspace, 'MEMORY.md'), content, 'utf-8');
253
+ }
254
+ getWorkspacePath(agentName) {
255
+ const config = this.readConfig();
256
+ const agent = config.agents.find((a) => a['id'] === agentName && a['type'] === 'app-agent');
257
+ return agent ? agent['workspace'] : null;
258
+ }
259
+ /**
260
+ * Return the agentName registered for a given appName, or null if none.
261
+ * Used by the installer conflict check.
262
+ */
263
+ async findAgentByName(agentName) {
264
+ return this.withConfigLock(() => {
265
+ const config = this.readConfig();
266
+ const found = config.agents.find((a) => a['id'] === agentName && a['type'] === 'app-agent');
267
+ return found ? found['id'] : null;
268
+ });
269
+ }
270
+ // ─── Config I/O ────────────────────────────────────────────────────────────
271
+ readConfig() {
272
+ try {
273
+ const raw = fs.readFileSync(this.configPath, 'utf-8');
274
+ const parsed = JSON.parse(raw);
275
+ if (!Array.isArray(parsed.agents))
276
+ parsed.agents = [];
277
+ return parsed;
278
+ }
279
+ catch {
280
+ return { gateway: { logDir: 'logs', timezone: 'UTC' }, agents: [] };
281
+ }
282
+ }
283
+ writeConfig(config) {
284
+ fs.mkdirSync(path.dirname(this.configPath), { recursive: true });
285
+ const tmp = `${this.configPath}.tmp.${process.pid}`;
286
+ fs.writeFileSync(tmp, JSON.stringify(config, null, 2), 'utf-8');
287
+ fs.renameSync(tmp, this.configPath);
288
+ }
289
+ async upsertConfigEntry(agentId, entry) {
290
+ return this.withConfigLock(() => {
291
+ const config = this.readConfig();
292
+ const idx = config.agents.findIndex((a) => a['id'] === agentId);
293
+ if (idx >= 0) {
294
+ config.agents[idx] = entry;
295
+ }
296
+ else {
297
+ config.agents.push(entry);
298
+ }
299
+ this.writeConfig(config);
300
+ });
301
+ }
302
+ async removeConfigEntry(agentId) {
303
+ return this.withConfigLock(() => {
304
+ const config = this.readConfig();
305
+ config.agents = config.agents.filter((a) => a['id'] !== agentId);
306
+ this.writeConfig(config);
307
+ });
308
+ }
309
+ }
310
+ exports.AgentManager = AgentManager;
311
+ //# sourceMappingURL=agent-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-manager.js","sourceRoot":"","sources":["../../src/apps/agent-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,4CAA8B;AAC9B,2DAA8C;AAC9C,sDAA2B;AAiB3B,iFAAiF;AAEjF,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;AACtF,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AAEhF,gFAAgF;AAEhF,MAAa,YAAY;IAIvB,YACmB,aAAqB,mBAAmB,EACxC,YAAoB,kBAAkB;QADt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AAI,CAAC,cAAc,CAAC,GAAG,EAAE;YAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC;YAChE,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;gBACb,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,OAAe;QAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE;YAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC;YACjE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9QD,oCA8QC"}
@@ -0,0 +1,108 @@
1
+ export interface AppYamlPort {
2
+ name: string;
3
+ host: number;
4
+ container: number;
5
+ type?: 'api' | 'web';
6
+ rate_limit?: number;
7
+ }
8
+ export interface AppYamlScriptArg {
9
+ name: string;
10
+ type: string;
11
+ pattern?: string;
12
+ }
13
+ export interface AppYamlScript {
14
+ path: string;
15
+ timeout?: string;
16
+ args?: AppYamlScriptArg[];
17
+ }
18
+ export interface AppYamlGatewayApi {
19
+ socket: string;
20
+ scripts?: Record<string, AppYamlScript>;
21
+ }
22
+ export interface AppYamlHealthcheck {
23
+ test: string;
24
+ interval?: string;
25
+ timeout?: string;
26
+ retries?: number;
27
+ }
28
+ export interface AppYamlService {
29
+ build?: string;
30
+ image?: string;
31
+ command?: string | string[];
32
+ entrypoint?: string | string[];
33
+ working_dir?: string;
34
+ user?: string;
35
+ environment?: string[];
36
+ volumes?: string[];
37
+ ports?: AppYamlPort[];
38
+ depends_on?: string[];
39
+ healthcheck?: AppYamlHealthcheck;
40
+ gateway_api?: AppYamlGatewayApi;
41
+ cap_add?: string[];
42
+ resources?: {
43
+ cpu?: number;
44
+ memory?: string;
45
+ };
46
+ }
47
+ export interface AppYamlAgentService {
48
+ path: string;
49
+ name: string;
50
+ }
51
+ export interface AppYaml {
52
+ apiVersion: string;
53
+ name: string;
54
+ version: string;
55
+ description?: string;
56
+ author?: string;
57
+ resources?: {
58
+ cpu?: number;
59
+ memory?: string;
60
+ };
61
+ services: Record<string, AppYamlService | AppYamlAgentService>;
62
+ }
63
+ export interface ComposePort {
64
+ name: string;
65
+ service: string;
66
+ hostPort: number;
67
+ containerPort: number;
68
+ type: 'api' | 'web';
69
+ rateLimit: number;
70
+ }
71
+ export interface ScriptConfig {
72
+ path: string;
73
+ timeout: string;
74
+ args?: Array<{
75
+ name: string;
76
+ type: string;
77
+ pattern?: string;
78
+ }>;
79
+ }
80
+ export interface ComposeSocket {
81
+ service: string;
82
+ hostSocketPath: string;
83
+ scripts: Record<string, ScriptConfig>;
84
+ }
85
+ export interface AgentDeclaration {
86
+ path: string;
87
+ name: string;
88
+ }
89
+ export interface GeneratedCompose {
90
+ ports: ComposePort[];
91
+ sockets: ComposeSocket[];
92
+ secretKeys: string[];
93
+ agentDeclaration: AgentDeclaration | null;
94
+ warnings: string[];
95
+ }
96
+ /**
97
+ * Parse and validate app.yaml content.
98
+ * appDir is used to resolve and range-check build/script paths.
99
+ */
100
+ export declare function parseAppYaml(content: string, appDir: string): AppYaml;
101
+ /**
102
+ * Generate docker-compose.yml from a parsed app.yaml.
103
+ * Writes the file to outputPath and returns metadata for the installer.
104
+ */
105
+ export declare function generateCompose(appYaml: AppYaml, appName: string, appDir: string, outputPath: string): GeneratedCompose;
106
+ /** Read app.yaml from appDir, parse, validate, and generate docker-compose.yml. */
107
+ export declare function processAppYaml(appDir: string, appName: string, outputPath: string): GeneratedCompose;
108
+ //# sourceMappingURL=compose-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-generator.d.ts","sourceRoot":"","sources":["../../src/apps/compose-generator.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,G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