@framers/agentos-ext-cloud-flyio 0.1.0 → 0.1.2

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.
@@ -1,104 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * @fileoverview FlyDeployAppTool — deploy an app on Fly.io by creating a machine with a config.
4
- */
5
-
6
- import type { FlyService, FlyMachine, FlyMachineConfig, FlyApp } from '../FlyService.js';
7
-
8
- export interface FlyDeployAppInput {
9
- appName: string;
10
- image: string;
11
- region?: string;
12
- cpus?: number;
13
- cpuKind?: string;
14
- memoryMb?: number;
15
- env?: Record<string, string>;
16
- internalPort?: number;
17
- autoDestroy?: boolean;
18
- createApp?: boolean;
19
- org?: string;
20
- }
21
-
22
- export class FlyDeployAppTool {
23
- readonly id = 'flyDeployApp';
24
- readonly name = 'flyDeployApp';
25
- readonly displayName = 'Deploy Fly.io App';
26
- readonly description = 'Deploy an application on Fly.io by creating a machine with a Docker image. Creates the app first if it does not exist. Configure CPU, memory, region, environment variables, and exposed ports.';
27
- readonly category = 'cloud';
28
- readonly version = '0.1.0';
29
- readonly hasSideEffects = true;
30
-
31
- readonly inputSchema = {
32
- type: 'object' as const,
33
- properties: {
34
- appName: { type: 'string', description: 'Fly app name (e.g. "my-web-app")' },
35
- image: { type: 'string', description: 'Docker image to deploy (e.g. "registry.fly.io/my-app:latest" or "nginx:alpine")' },
36
- region: { type: 'string', description: 'Fly region code (e.g. "iad", "lax", "cdg", "nrt"). Defaults to closest.' },
37
- cpus: { type: 'number', description: 'Number of CPUs (default: 1)' },
38
- cpuKind: { type: 'string', enum: ['shared', 'performance'], description: 'CPU type (default: shared)' },
39
- memoryMb: { type: 'number', description: 'Memory in MB (default: 256)' },
40
- env: { type: 'object', description: 'Environment variables (key-value pairs)' },
41
- internalPort: { type: 'number', description: 'Internal port the app listens on (default: 8080)' },
42
- autoDestroy: { type: 'boolean', description: 'Automatically destroy the machine when it exits (default: false)' },
43
- createApp: { type: 'boolean', description: 'Create the app if it does not exist (default: true)' },
44
- org: { type: 'string', description: 'Fly organization slug (default: "personal")' },
45
- },
46
- required: ['appName', 'image'],
47
- };
48
-
49
- constructor(private service: FlyService) {}
50
-
51
- async execute(args: FlyDeployAppInput): Promise<{ success: boolean; data?: { app: FlyApp; machine: FlyMachine }; error?: string }> {
52
- try {
53
- // Create app if needed
54
- const shouldCreate = args.createApp !== false;
55
- let app: FlyApp;
56
-
57
- try {
58
- app = await this.service.getApp(args.appName);
59
- } catch {
60
- if (!shouldCreate) {
61
- return { success: false, error: `App "${args.appName}" not found. Set createApp to true to create it.` };
62
- }
63
- app = await this.service.createApp(args.appName, args.org);
64
- }
65
-
66
- // Build machine config
67
- const port = args.internalPort ?? 8080;
68
- const config: FlyMachineConfig = {
69
- image: args.image,
70
- env: args.env,
71
- guest: {
72
- cpus: args.cpus ?? 1,
73
- cpu_kind: args.cpuKind ?? 'shared',
74
- memory_mb: args.memoryMb ?? 256,
75
- },
76
- auto_destroy: args.autoDestroy ?? false,
77
- services: [
78
- {
79
- ports: [
80
- { port: 80, handlers: ['http'], force_https: true },
81
- { port: 443, handlers: ['http', 'tls'] },
82
- ],
83
- protocol: 'tcp',
84
- internal_port: port,
85
- autostart: true,
86
- autostop: true,
87
- min_machines_running: 0,
88
- },
89
- ],
90
- };
91
-
92
- const machine = await this.service.createMachine(args.appName, config, {
93
- region: args.region,
94
- });
95
-
96
- return {
97
- success: true,
98
- data: { app, machine },
99
- };
100
- } catch (err: any) {
101
- return { success: false, error: err.message };
102
- }
103
- }
104
- }
@@ -1,62 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * @fileoverview FlyListAppsTool — list all Fly.io apps and their machines.
4
- */
5
-
6
- import type { FlyService, FlyApp } from '../FlyService.js';
7
-
8
- export interface FlyListAppsInput {
9
- appName?: string;
10
- includeMachines?: boolean;
11
- }
12
-
13
- export class FlyListAppsTool {
14
- readonly id = 'flyListApps';
15
- readonly name = 'flyListApps';
16
- readonly displayName = 'List Fly.io Apps';
17
- readonly description = 'List all Fly.io apps in the account, or get details for a specific app. Optionally include machine details (state, region, config) for each app.';
18
- readonly category = 'cloud';
19
- readonly version = '0.1.0';
20
- readonly hasSideEffects = false;
21
-
22
- readonly inputSchema = {
23
- type: 'object' as const,
24
- properties: {
25
- appName: { type: 'string', description: 'Filter to a specific app by name (optional — lists all apps if omitted)' },
26
- includeMachines: { type: 'boolean', description: 'Include machine details for each app (default: true)' },
27
- },
28
- required: [] as string[],
29
- };
30
-
31
- constructor(private service: FlyService) {}
32
-
33
- async execute(args: FlyListAppsInput): Promise<{ success: boolean; data?: FlyApp[]; error?: string }> {
34
- try {
35
- const withMachines = args.includeMachines !== false;
36
-
37
- if (args.appName) {
38
- const app = await this.service.getApp(args.appName);
39
- if (withMachines) {
40
- app.machines = await this.service.listMachines(args.appName);
41
- }
42
- return { success: true, data: [app] };
43
- }
44
-
45
- const apps = await this.service.listApps();
46
-
47
- if (withMachines) {
48
- for (const app of apps) {
49
- try {
50
- app.machines = await this.service.listMachines(app.name);
51
- } catch {
52
- app.machines = [];
53
- }
54
- }
55
- }
56
-
57
- return { success: true, data: apps };
58
- } catch (err: any) {
59
- return { success: false, error: err.message };
60
- }
61
- }
62
- }
@@ -1,116 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * @fileoverview FlyScaleAppTool — scale machines for a Fly.io app.
4
- */
5
-
6
- import type { FlyService, FlyMachine, FlyMachineConfig } from '../FlyService.js';
7
-
8
- export interface FlyScaleAppInput {
9
- appName: string;
10
- count: number;
11
- cpus?: number;
12
- cpuKind?: string;
13
- memoryMb?: number;
14
- region?: string;
15
- }
16
-
17
- export class FlyScaleAppTool {
18
- readonly id = 'flyScaleApp';
19
- readonly name = 'flyScaleApp';
20
- readonly displayName = 'Scale Fly.io App';
21
- readonly description = 'Scale a Fly.io app by adjusting the number of machines and optionally their VM size. Can scale up (create new machines cloned from existing config) or scale down (destroy excess machines). Optionally resize CPUs and memory.';
22
- readonly category = 'cloud';
23
- readonly version = '0.1.0';
24
- readonly hasSideEffects = true;
25
-
26
- readonly inputSchema = {
27
- type: 'object' as const,
28
- properties: {
29
- appName: { type: 'string', description: 'Name of the Fly app to scale' },
30
- count: { type: 'number', description: 'Desired number of machines (0 to stop all)' },
31
- cpus: { type: 'number', description: 'CPUs per machine (only applied to new or resized machines)' },
32
- cpuKind: { type: 'string', enum: ['shared', 'performance'], description: 'CPU type (only applied to new or resized machines)' },
33
- memoryMb: { type: 'number', description: 'Memory in MB per machine (only applied to new or resized machines)' },
34
- region: { type: 'string', description: 'Region for new machines (e.g. "iad", "lax", "cdg")' },
35
- },
36
- required: ['appName', 'count'],
37
- };
38
-
39
- constructor(private service: FlyService) {}
40
-
41
- async execute(args: FlyScaleAppInput): Promise<{
42
- success: boolean;
43
- data?: { machines: FlyMachine[]; created: number; destroyed: number; resized: number };
44
- error?: string;
45
- }> {
46
- try {
47
- const existing = await this.service.listMachines(args.appName);
48
- const current = existing.length;
49
- const desired = args.count;
50
- let created = 0;
51
- let destroyed = 0;
52
- let resized = 0;
53
-
54
- // Determine if we need to resize existing machines
55
- const needsResize = args.cpus !== undefined || args.cpuKind !== undefined || args.memoryMb !== undefined;
56
-
57
- // Scale down: destroy excess machines
58
- if (desired < current) {
59
- const toDestroy = existing.slice(desired);
60
- for (const machine of toDestroy) {
61
- await this.service.destroyMachine(args.appName, machine.id);
62
- destroyed++;
63
- }
64
- }
65
-
66
- // Resize remaining machines if needed
67
- if (needsResize) {
68
- const toResize = existing.slice(0, Math.min(desired, current));
69
- for (const machine of toResize) {
70
- const guest = {
71
- cpus: args.cpus ?? machine.config.guest?.cpus ?? 1,
72
- cpu_kind: args.cpuKind ?? machine.config.guest?.cpu_kind ?? 'shared',
73
- memory_mb: args.memoryMb ?? machine.config.guest?.memory_mb ?? 256,
74
- };
75
- await this.service.updateMachine(args.appName, machine.id, { guest });
76
- resized++;
77
- }
78
- }
79
-
80
- // Scale up: create new machines cloned from the first machine's config
81
- if (desired > current) {
82
- const template = existing[0]?.config ?? { image: '' };
83
- const baseConfig: FlyMachineConfig = {
84
- ...template,
85
- guest: {
86
- cpus: args.cpus ?? template.guest?.cpus ?? 1,
87
- cpu_kind: args.cpuKind ?? template.guest?.cpu_kind ?? 'shared',
88
- memory_mb: args.memoryMb ?? template.guest?.memory_mb ?? 256,
89
- },
90
- };
91
-
92
- for (let i = current; i < desired; i++) {
93
- await this.service.createMachine(args.appName, baseConfig, {
94
- region: args.region,
95
- });
96
- created++;
97
- }
98
- }
99
-
100
- // Get final state
101
- const finalMachines = await this.service.listMachines(args.appName);
102
-
103
- return {
104
- success: true,
105
- data: {
106
- machines: finalMachines,
107
- created,
108
- destroyed,
109
- resized,
110
- },
111
- };
112
- } catch (err: any) {
113
- return { success: false, error: err.message };
114
- }
115
- }
116
- }