@daileyos/mcp-server 1.21.2 → 1.21.4
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.
- package/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +23 -2
- package/dist/api.js.map +1 -1
- package/dist/index.js +24 -17
- package/dist/index.js.map +1 -1
- package/dist/tools/accounts.js +1 -1
- package/dist/tools/accounts.js.map +1 -1
- package/dist/tools/ai.d.ts.map +1 -1
- package/dist/tools/ai.js +7 -1
- package/dist/tools/ai.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +25 -6
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/backups.d.ts.map +1 -1
- package/dist/tools/backups.js +3 -1
- package/dist/tools/backups.js.map +1 -1
- package/dist/tools/build-logs.d.ts.map +1 -1
- package/dist/tools/build-logs.js +3 -1
- package/dist/tools/build-logs.js.map +1 -1
- package/dist/tools/credentials-reveal.d.ts.map +1 -1
- package/dist/tools/credentials-reveal.js +3 -1
- package/dist/tools/credentials-reveal.js.map +1 -1
- package/dist/tools/dailey-images.js +3 -3
- package/dist/tools/dailey-images.js.map +1 -1
- package/dist/tools/db-migrate.js +5 -5
- package/dist/tools/db-migrate.js.map +1 -1
- package/dist/tools/db.d.ts.map +1 -1
- package/dist/tools/db.js +17 -1
- package/dist/tools/db.js.map +1 -1
- package/dist/tools/deploy-status.d.ts.map +1 -1
- package/dist/tools/deploy-status.js +3 -1
- package/dist/tools/deploy-status.js.map +1 -1
- package/dist/tools/deploy.d.ts.map +1 -1
- package/dist/tools/deploy.js +9 -1
- package/dist/tools/deploy.js.map +1 -1
- package/dist/tools/domains.d.ts.map +1 -1
- package/dist/tools/domains.js +3 -1
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/email.d.ts.map +1 -1
- package/dist/tools/email.js +7 -1
- package/dist/tools/email.js.map +1 -1
- package/dist/tools/env.d.ts.map +1 -1
- package/dist/tools/env.js +5 -1
- package/dist/tools/env.js.map +1 -1
- package/dist/tools/environments.js +3 -3
- package/dist/tools/environments.js.map +1 -1
- package/dist/tools/exec-run.d.ts.map +1 -1
- package/dist/tools/exec-run.js +7 -1
- package/dist/tools/exec-run.js.map +1 -1
- package/dist/tools/images.d.ts.map +1 -1
- package/dist/tools/images.js +5 -1
- package/dist/tools/images.js.map +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/lifecycle.js +5 -1
- package/dist/tools/lifecycle.js.map +1 -1
- package/dist/tools/links.d.ts.map +1 -1
- package/dist/tools/links.js +3 -1
- package/dist/tools/links.js.map +1 -1
- package/dist/tools/platform.d.ts.map +1 -1
- package/dist/tools/platform.js +3 -1
- package/dist/tools/platform.js.map +1 -1
- package/dist/tools/processes.d.ts.map +1 -1
- package/dist/tools/processes.js +11 -1
- package/dist/tools/processes.js.map +1 -1
- package/dist/tools/projects.d.ts.map +1 -1
- package/dist/tools/projects.js +36 -12
- package/dist/tools/projects.js.map +1 -1
- package/dist/tools/resource-config.d.ts.map +1 -1
- package/dist/tools/resource-config.js +3 -1
- package/dist/tools/resource-config.js.map +1 -1
- package/dist/tools/scale.d.ts.map +1 -1
- package/dist/tools/scale.js +3 -1
- package/dist/tools/scale.js.map +1 -1
- package/dist/tools/storage.d.ts.map +1 -1
- package/dist/tools/storage.js +11 -1
- package/dist/tools/storage.js.map +1 -1
- package/dist/tools/support.d.ts.map +1 -1
- package/dist/tools/support.js +3 -1
- package/dist/tools/support.js.map +1 -1
- package/dist/tools/usage.d.ts.map +1 -1
- package/dist/tools/usage.js +3 -1
- package/dist/tools/usage.js.map +1 -1
- package/dist/tools/wordpress-import.d.ts.map +1 -1
- package/dist/tools/wordpress-import.js +3 -1
- package/dist/tools/wordpress-import.js.map +1 -1
- package/dist/tools/wordpress-migrate.d.ts.map +1 -1
- package/dist/tools/wordpress-migrate.js +3 -1
- package/dist/tools/wordpress-migrate.js.map +1 -1
- package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
- package/dist/tools/wordpress-snapshot.js +9 -1
- package/dist/tools/wordpress-snapshot.js.map +1 -1
- package/package.json +4 -1
- package/.dockerignore +0 -6
- package/.github/workflows/publish.yml +0 -120
- package/Dockerfile +0 -19
- package/claude-config.json +0 -13
- package/docs/superpowers/plans/2026-08-09-remote-mcp-endpoint.md +0 -663
- package/docs/superpowers/specs/2026-08-09-remote-mcp-endpoint-design.md +0 -66
- package/src/api.ts +0 -263
- package/src/context.ts +0 -12
- package/src/http.ts +0 -160
- package/src/index.ts +0 -94
- package/src/server.ts +0 -188
- package/src/tools/accounts.ts +0 -119
- package/src/tools/addons.ts +0 -124
- package/src/tools/admin.ts +0 -42
- package/src/tools/ai.ts +0 -83
- package/src/tools/analyze.ts +0 -108
- package/src/tools/auth.ts +0 -177
- package/src/tools/backups.ts +0 -84
- package/src/tools/billing.ts +0 -34
- package/src/tools/build-logs.ts +0 -65
- package/src/tools/bundle.ts +0 -129
- package/src/tools/cli.ts +0 -76
- package/src/tools/credentials-reveal.ts +0 -64
- package/src/tools/credits.ts +0 -97
- package/src/tools/dailey-images.ts +0 -151
- package/src/tools/db-migrate.ts +0 -211
- package/src/tools/db.ts +0 -391
- package/src/tools/deploy-status.ts +0 -247
- package/src/tools/deploy.ts +0 -101
- package/src/tools/diagnose.ts +0 -567
- package/src/tools/domains.ts +0 -156
- package/src/tools/email.ts +0 -101
- package/src/tools/env.ts +0 -205
- package/src/tools/environments.ts +0 -138
- package/src/tools/exec-run.ts +0 -91
- package/src/tools/images.ts +0 -221
- package/src/tools/lifecycle.ts +0 -75
- package/src/tools/links.ts +0 -69
- package/src/tools/platform.ts +0 -209
- package/src/tools/processes.ts +0 -182
- package/src/tools/project-transfer.ts +0 -129
- package/src/tools/projects.ts +0 -287
- package/src/tools/resource-config.ts +0 -84
- package/src/tools/scale.ts +0 -33
- package/src/tools/storage.ts +0 -281
- package/src/tools/support.ts +0 -42
- package/src/tools/usage.ts +0 -128
- package/src/tools/wordpress-import.ts +0 -174
- package/src/tools/wordpress-live-edit.ts +0 -250
- package/src/tools/wordpress-migrate.ts +0 -104
- package/src/tools/wordpress-snapshot.ts +0 -225
- package/src/tools/wordpress-targeting.ts +0 -188
- package/src/upload.ts +0 -35
- package/src/version.ts +0 -70
- package/test/context.test.ts +0 -36
- package/test/http.test.ts +0 -103
- package/test/server-surface.test.ts +0 -36
- package/test/use-account-sticky.test.ts +0 -28
- package/test/wordpress-import.test.ts +0 -223
- package/test/wordpress-live-edit.test.ts +0 -159
- package/test/wordpress-targeting.test.ts +0 -162
- package/tests/dailey-images.test.mjs +0 -156
- package/tests/environments.test.mjs +0 -230
- package/tests/mcp-protocol-smoke.mjs +0 -149
- package/tests/new-tools-smoke.mjs +0 -217
- package/tests/pack1-mcp-preflight.test.mjs +0 -184
- package/tests/pack6-smoke.mjs +0 -222
- package/tests/wp-snapshot-labels.test.mjs +0 -21
- package/tests/wp-snapshot.test.mjs +0 -261
- package/tsconfig.json +0 -19
package/src/tools/processes.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { apiRequest, formatError, textResult } from '../api.js';
|
|
4
|
-
|
|
5
|
-
interface Process {
|
|
6
|
-
name: string;
|
|
7
|
-
type?: string;
|
|
8
|
-
command?: string;
|
|
9
|
-
port?: number;
|
|
10
|
-
replicas?: number;
|
|
11
|
-
cpu_millicores?: number;
|
|
12
|
-
memory_mb?: number;
|
|
13
|
-
timeout_seconds?: number;
|
|
14
|
-
namespace?: string;
|
|
15
|
-
domain?: string;
|
|
16
|
-
status?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface ProcessLogsResponse {
|
|
20
|
-
pods?: Array<{ pod: string; status: string; node: string; restarts: number; log: string }>;
|
|
21
|
-
logs?: string[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface ProcessMetricsResponse {
|
|
25
|
-
usage?: {
|
|
26
|
-
cpu_millicores?: number;
|
|
27
|
-
memory_mb?: number;
|
|
28
|
-
pods_ready?: number;
|
|
29
|
-
pods_total?: number;
|
|
30
|
-
restarts?: number;
|
|
31
|
-
};
|
|
32
|
-
resources?: {
|
|
33
|
-
cpu_limit_millicores?: number;
|
|
34
|
-
memory_limit_mb?: number;
|
|
35
|
-
replicas?: number;
|
|
36
|
-
};
|
|
37
|
-
pods?: Array<{ name: string; node: string }>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function registerProcessTools(server: McpServer) {
|
|
41
|
-
server.tool(
|
|
42
|
-
'dailey_processes',
|
|
43
|
-
'List processes defined in a project. For multi-process projects with a dailey.yaml manifest, returns each declared process (web/worker/release) with resource limits and status. For single-container projects (most Dailey OS projects), returns an empty list — use dailey_project_info and dailey_scale for resource management in that case.',
|
|
44
|
-
{ project_id: z.string().describe('The project ID') },
|
|
45
|
-
async ({ project_id }) => {
|
|
46
|
-
const res = await apiRequest<{ processes: Process[] }>('GET', `/projects/${project_id}/processes`);
|
|
47
|
-
if (!res.ok) return textResult(formatError(res));
|
|
48
|
-
|
|
49
|
-
const procs = res.data.processes || [];
|
|
50
|
-
if (procs.length === 0) {
|
|
51
|
-
return textResult([
|
|
52
|
-
'No processes manifest (dailey.yaml) found — this is a single-container project.',
|
|
53
|
-
'',
|
|
54
|
-
'For single-container projects:',
|
|
55
|
-
' - dailey_project_info to see current replicas/CPU/memory',
|
|
56
|
-
' - dailey_scale to change replicas',
|
|
57
|
-
' - dailey_app_logs to tail runtime logs',
|
|
58
|
-
' - dailey_app_restart to roll the deployment',
|
|
59
|
-
'',
|
|
60
|
-
'dailey_processes/dailey_process_* are only meaningful when a repo ships a dailey.yaml declaring multiple processes.',
|
|
61
|
-
].join('\n'));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const lines = [
|
|
65
|
-
`Processes (${procs.length})`,
|
|
66
|
-
`${'Name'.padEnd(20)} ${'Type'.padEnd(10)} ${'Replicas'.padEnd(9)} ${'CPU'.padEnd(8)} ${'Memory'.padEnd(10)} Status`,
|
|
67
|
-
'─'.repeat(80),
|
|
68
|
-
];
|
|
69
|
-
for (const p of procs) {
|
|
70
|
-
lines.push(
|
|
71
|
-
`${(p.name || '').padEnd(20)} ${(p.type || '-').padEnd(10)} ${String(p.replicas ?? '-').padEnd(9)} ${String(p.cpu_millicores ?? '-').padEnd(8)} ${String(p.memory_mb ?? '-').padEnd(10)} ${p.status || '-'}`,
|
|
72
|
-
);
|
|
73
|
-
if (p.command) lines.push(` cmd: ${p.command}`);
|
|
74
|
-
}
|
|
75
|
-
return textResult(lines.join('\n'));
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
server.tool(
|
|
80
|
-
'dailey_process_logs',
|
|
81
|
-
'Fetch logs for a specific process in a multi-process project.',
|
|
82
|
-
{
|
|
83
|
-
project_id: z.string().describe('The project ID'),
|
|
84
|
-
process_name: z.string().describe('The process name (from dailey_processes)'),
|
|
85
|
-
tail: z.number().int().min(1).max(2000).optional().describe('Number of log lines to fetch (default: 100)'),
|
|
86
|
-
},
|
|
87
|
-
async ({ project_id, process_name, tail }) => {
|
|
88
|
-
const query = tail ? `?tail=${tail}` : '?tail=100';
|
|
89
|
-
const res = await apiRequest<ProcessLogsResponse>(
|
|
90
|
-
'GET',
|
|
91
|
-
`/projects/${project_id}/processes/${encodeURIComponent(process_name)}/logs${query}`,
|
|
92
|
-
);
|
|
93
|
-
if (!res.ok) return textResult(formatError(res));
|
|
94
|
-
|
|
95
|
-
const logs = res.data.logs || [];
|
|
96
|
-
if (logs.length === 0) return textResult(`No logs for process ${process_name}.`);
|
|
97
|
-
return textResult([`Logs for ${process_name} (last ${tail || 100} lines):`, '', ...logs].join('\n'));
|
|
98
|
-
},
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
server.tool(
|
|
102
|
-
'dailey_process_restart',
|
|
103
|
-
'Restart a single process (rolling restart). Only affects the named process — other processes keep running.',
|
|
104
|
-
{
|
|
105
|
-
project_id: z.string().describe('The project ID'),
|
|
106
|
-
process_name: z.string().describe('The process name to restart'),
|
|
107
|
-
},
|
|
108
|
-
async ({ project_id, process_name }) => {
|
|
109
|
-
const res = await apiRequest(
|
|
110
|
-
'POST',
|
|
111
|
-
`/projects/${project_id}/processes/${encodeURIComponent(process_name)}/restart`,
|
|
112
|
-
);
|
|
113
|
-
if (!res.ok) return textResult(formatError(res));
|
|
114
|
-
return textResult(`Restart initiated for process ${process_name}. Pods will roll one-by-one.`);
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
server.tool(
|
|
119
|
-
'dailey_process_metrics',
|
|
120
|
-
'Get live resource usage and pod health for a process: pods ready, restarts, CPU/memory limits.',
|
|
121
|
-
{
|
|
122
|
-
project_id: z.string().describe('The project ID'),
|
|
123
|
-
process_name: z.string().describe('The process name'),
|
|
124
|
-
},
|
|
125
|
-
async ({ project_id, process_name }) => {
|
|
126
|
-
const res = await apiRequest<ProcessMetricsResponse>(
|
|
127
|
-
'GET',
|
|
128
|
-
`/projects/${project_id}/processes/${encodeURIComponent(process_name)}/metrics`,
|
|
129
|
-
);
|
|
130
|
-
if (!res.ok) return textResult(formatError(res));
|
|
131
|
-
|
|
132
|
-
const usage = res.data.usage || {};
|
|
133
|
-
const resources = res.data.resources || {};
|
|
134
|
-
const pods = res.data.pods || [];
|
|
135
|
-
|
|
136
|
-
const lines = [
|
|
137
|
-
`Process: ${process_name}`,
|
|
138
|
-
'─'.repeat(40),
|
|
139
|
-
`Pods ready: ${usage.pods_ready ?? 0} / ${usage.pods_total ?? 0}`,
|
|
140
|
-
`Restarts: ${usage.restarts ?? 0}`,
|
|
141
|
-
`CPU limit: ${resources.cpu_limit_millicores ?? '-'}m`,
|
|
142
|
-
`Mem limit: ${resources.memory_limit_mb ?? '-'} MB`,
|
|
143
|
-
`Replicas: ${resources.replicas ?? '-'}`,
|
|
144
|
-
];
|
|
145
|
-
if (pods.length > 0) {
|
|
146
|
-
lines.push('');
|
|
147
|
-
lines.push('Pods:');
|
|
148
|
-
for (const pod of pods) lines.push(` ${pod.name} on ${pod.node}`);
|
|
149
|
-
}
|
|
150
|
-
return textResult(lines.join('\n'));
|
|
151
|
-
},
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
server.tool(
|
|
155
|
-
'dailey_process_resources',
|
|
156
|
-
'Update replicas, CPU, or memory limits for a specific process. Omit fields you do not want to change.',
|
|
157
|
-
{
|
|
158
|
-
project_id: z.string().describe('The project ID'),
|
|
159
|
-
process_name: z.string().describe('The process name'),
|
|
160
|
-
replicas: z.number().int().min(0).max(20).optional().describe('Replicas (0-20)'),
|
|
161
|
-
cpu_millicores: z.number().int().min(10).max(8000).optional().describe('CPU limit in millicores (10-8000)'),
|
|
162
|
-
memory_mb: z.number().int().min(64).max(32768).optional().describe('Memory limit in MB (64-32768)'),
|
|
163
|
-
},
|
|
164
|
-
async ({ project_id, process_name, replicas, cpu_millicores, memory_mb }) => {
|
|
165
|
-
const body: Record<string, number> = {};
|
|
166
|
-
if (replicas !== undefined) body.replicas = replicas;
|
|
167
|
-
if (cpu_millicores !== undefined) body.cpu_millicores = cpu_millicores;
|
|
168
|
-
if (memory_mb !== undefined) body.memory_mb = memory_mb;
|
|
169
|
-
if (Object.keys(body).length === 0) {
|
|
170
|
-
return textResult('Error: specify at least one of replicas, cpu_millicores, or memory_mb.');
|
|
171
|
-
}
|
|
172
|
-
const res = await apiRequest(
|
|
173
|
-
'POST',
|
|
174
|
-
`/projects/${project_id}/processes/${encodeURIComponent(process_name)}/resources`,
|
|
175
|
-
body,
|
|
176
|
-
);
|
|
177
|
-
if (!res.ok) return textResult(formatError(res));
|
|
178
|
-
const changed = Object.entries(body).map(([k, v]) => `${k}=${v}`).join(', ');
|
|
179
|
-
return textResult(`Updated process ${process_name}: ${changed}`);
|
|
180
|
-
},
|
|
181
|
-
);
|
|
182
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Admin-only tools for the project-transfer primitive. These move a whole
|
|
3
|
-
* customer project (code + DB + storage + DNS + secrets) between customer
|
|
4
|
-
* accounts with isolation verification and rollback. See
|
|
5
|
-
* Dailey OS/Product/2026-04-24 project-transfer primitive — design + security
|
|
6
|
-
* model.md and the companion runbook for details.
|
|
7
|
-
*
|
|
8
|
-
* Flow: plan → apply → (verify externally) → complete (irreversible)
|
|
9
|
-
* └─→ rollback (only before complete)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
13
|
-
import { z } from 'zod';
|
|
14
|
-
import { apiRequest, textResult, formatError } from '../api.js';
|
|
15
|
-
|
|
16
|
-
export function registerProjectTransferTools(server: McpServer) {
|
|
17
|
-
server.tool(
|
|
18
|
-
'dailey_project_transfer_plan',
|
|
19
|
-
'Admin-only. Generate a transfer plan for moving a project from its current customer to a target customer. This is pure validation — no resources created. Returns plan_id, source + target endpoint details (namespaces, DB names, R2 prefixes), the 12-step pipeline, and any pre-flight issues (target slug collision, NetworkPolicy missing, etc.). Plan expires in 1 hour.',
|
|
20
|
-
{
|
|
21
|
-
project_id: z.string().describe('The source project ID'),
|
|
22
|
-
to_customer_slug: z.string().describe('The slug of the target customer (e.g. "zena", not the customer_id)'),
|
|
23
|
-
},
|
|
24
|
-
async ({ project_id, to_customer_slug }) => {
|
|
25
|
-
const res = await apiRequest<any>('POST', `/admin/transfers/plan`, { project_id, to_customer_slug });
|
|
26
|
-
if (!res.ok) return textResult(formatError(res));
|
|
27
|
-
const p = res.data;
|
|
28
|
-
const lines = [
|
|
29
|
-
`Transfer plan: ${p.plan_id}`,
|
|
30
|
-
`Source: ${p.source?.customer_slug} → ${p.source?.namespace} / ${p.source?.database_name}`,
|
|
31
|
-
`Target: ${p.target?.customer_slug} → ${p.target?.namespace} / ${p.target?.database_name}`,
|
|
32
|
-
`Prod host: ${p.prod_hostname}`,
|
|
33
|
-
`Temp host: ${p.temp_hostname}`,
|
|
34
|
-
`Expires: ${p.expires_at}`,
|
|
35
|
-
'',
|
|
36
|
-
`Steps (${p.steps?.length || 0}):`,
|
|
37
|
-
];
|
|
38
|
-
for (const s of p.steps || []) lines.push(` ${s.n}. ${s.id}: ${s.description}`);
|
|
39
|
-
if (p.risks?.length) {
|
|
40
|
-
lines.push('', 'Risks:');
|
|
41
|
-
for (const r of p.risks) lines.push(` ⚠ ${r}`);
|
|
42
|
-
}
|
|
43
|
-
lines.push('', 'Next: dailey_project_transfer_apply(plan_id).');
|
|
44
|
-
return textResult(lines.join('\n'));
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
server.tool(
|
|
49
|
-
'dailey_project_transfer_apply',
|
|
50
|
-
'Admin-only. Execute the transfer. Runs 11 steps: snapshot source, provision target DB + storage creds, copy Postgres data via ephemeral Pod, copy R2 objects, rotate app secrets, stage target Deployment, smoke-test, pre-flight isolation check, DNS cutover, flip customer_projects authz, post-cutover isolation verify (all 8 checks). Source is still alive (scaled to 0) — can be restored via rollback. If any step fails or isolation verification fails, auto-rolls back and returns state=rolled_back. ⚠ All app user sessions invalidate (SHIM_JWT_SECRET rotated).',
|
|
51
|
-
{
|
|
52
|
-
plan_id: z.string().describe('The plan_id from dailey_project_transfer_plan'),
|
|
53
|
-
},
|
|
54
|
-
async ({ plan_id }) => {
|
|
55
|
-
const res = await apiRequest<any>('POST', `/admin/transfers/apply`, { plan_id });
|
|
56
|
-
if (!res.ok) return textResult(formatError(res));
|
|
57
|
-
const d = res.data;
|
|
58
|
-
const lines = [
|
|
59
|
-
`Apply: ${d.state}${d.state === 'applied' ? ' ✓' : ''}`,
|
|
60
|
-
`Ready for completion: ${d.ready_for_completion ? 'yes' : 'no'}`,
|
|
61
|
-
`Isolation passed: ${d.verification?.passed ? 'yes' : 'no'}`,
|
|
62
|
-
];
|
|
63
|
-
if (d.applied_steps?.length) {
|
|
64
|
-
lines.push('', 'Steps:');
|
|
65
|
-
for (const s of d.applied_steps) {
|
|
66
|
-
const m = s.status === 'ok' ? '✓' : s.status === 'skipped' ? '○' : '✗';
|
|
67
|
-
lines.push(` ${m} ${s.step}. ${s.id} (${s.duration_ms}ms)${s.message ? ' — ' + s.message.slice(0, 120) : ''}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (d.verification?.checks?.length) {
|
|
71
|
-
const failed = d.verification.checks.filter((c: any) => !c.passed);
|
|
72
|
-
if (failed.length) {
|
|
73
|
-
lines.push('', 'Failed isolation checks:');
|
|
74
|
-
for (const c of failed) lines.push(` ✗ ${c.name}: ${c.observed}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (d.state === 'applied') {
|
|
78
|
-
lines.push('', 'Next: verify the target is working (see runbook), then dailey_project_transfer_complete.');
|
|
79
|
-
lines.push(' Or: dailey_project_transfer_rollback if something is wrong.');
|
|
80
|
-
}
|
|
81
|
-
return textResult(lines.join('\n'));
|
|
82
|
-
},
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
server.tool(
|
|
86
|
-
'dailey_project_transfer_complete',
|
|
87
|
-
'Admin-only. IRREVERSIBLE teardown of the source side. Only call after manually verifying the target is fully functional. Drops source Postgres DB + role, deletes source R2 prefix, deletes source k8s Deployment/Service/Secret/Ingress. After this, the only recovery path is from backups. A metadata-only snapshot remains in project_transfer_snapshots for 90 days (no data).',
|
|
88
|
-
{
|
|
89
|
-
plan_id: z.string().describe('The plan_id (state must be "applied")'),
|
|
90
|
-
},
|
|
91
|
-
async ({ plan_id }) => {
|
|
92
|
-
const res = await apiRequest<any>('POST', `/admin/transfers/complete`, { plan_id });
|
|
93
|
-
if (!res.ok) return textResult(formatError(res));
|
|
94
|
-
const d = res.data;
|
|
95
|
-
const lines = [
|
|
96
|
-
`Complete: ${d.state}${d.state === 'completed' ? ' ✓ (source torn down)' : ''}`,
|
|
97
|
-
];
|
|
98
|
-
if (d.teardown_steps?.length) {
|
|
99
|
-
lines.push('', 'Teardown:');
|
|
100
|
-
for (const s of d.teardown_steps) {
|
|
101
|
-
const m = s.status === 'ok' ? '✓' : '✗';
|
|
102
|
-
lines.push(` ${m} ${s.id} (${s.duration_ms}ms)${s.message ? ' — ' + s.message : ''}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return textResult(lines.join('\n'));
|
|
106
|
-
},
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
server.tool(
|
|
110
|
-
'dailey_project_transfer_rollback',
|
|
111
|
-
'Admin-only. Undo an applied transfer (only valid before complete). Reverses steps 10 → 1: flips customer_projects back to source, restores source Ingress at prod hostname, deletes target Deployment/Service/Secrets, deletes target R2 objects, drops target Postgres DB + role. Source Deployment scales back up. ~30s downtime during DNS re-swap. All app sessions stay invalidated (the rotated secret is not un-rotated, since it may already have been exposed).',
|
|
112
|
-
{
|
|
113
|
-
plan_id: z.string().describe('The plan_id (state must be "applied")'),
|
|
114
|
-
},
|
|
115
|
-
async ({ plan_id }) => {
|
|
116
|
-
const res = await apiRequest<any>('POST', `/admin/transfers/rollback`, { plan_id });
|
|
117
|
-
if (!res.ok) return textResult(formatError(res));
|
|
118
|
-
const d = res.data;
|
|
119
|
-
const lines = [
|
|
120
|
-
`Rollback: ${d.state}${d.state === 'rolled_back' ? ' ✓ (source restored)' : ''}`,
|
|
121
|
-
];
|
|
122
|
-
if (d.rolled_back_steps?.length) {
|
|
123
|
-
lines.push('', 'Reversed:');
|
|
124
|
-
for (const id of d.rolled_back_steps) lines.push(` ↻ ${id}`);
|
|
125
|
-
}
|
|
126
|
-
return textResult(lines.join('\n'));
|
|
127
|
-
},
|
|
128
|
-
);
|
|
129
|
-
}
|
package/src/tools/projects.ts
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { apiRequest, formatError, textResult } from '../api.js';
|
|
4
|
-
|
|
5
|
-
interface Project {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
slug?: string;
|
|
9
|
-
status?: string;
|
|
10
|
-
repo_url?: string;
|
|
11
|
-
branch?: string;
|
|
12
|
-
replicas?: number;
|
|
13
|
-
created_at?: string;
|
|
14
|
-
url?: string;
|
|
15
|
-
needs_database?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function registerProjectTools(server: McpServer) {
|
|
19
|
-
server.tool(
|
|
20
|
-
'dailey_list_projects',
|
|
21
|
-
'List all projects with status',
|
|
22
|
-
{},
|
|
23
|
-
async () => {
|
|
24
|
-
const res = await apiRequest<{ projects: Project[] }>('GET', '/projects');
|
|
25
|
-
if (!res.ok) return textResult(formatError(res));
|
|
26
|
-
|
|
27
|
-
const projects = res.data.projects;
|
|
28
|
-
if (!projects || projects.length === 0) {
|
|
29
|
-
return textResult(
|
|
30
|
-
`No projects found.\n\nNew to Dailey OS? Open your dashboard at https://os.dailey.cloud — it walks you through connecting your machine (CLI, GitHub, MCP) and creating your first app.`,
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Include slug — when multiple projects share a name (common with
|
|
35
|
-
// template-generated repos or duplicated test projects) the slug is
|
|
36
|
-
// the disambiguator callers need to pick the right project_id.
|
|
37
|
-
const lines = [
|
|
38
|
-
`Projects (${projects.length})`,
|
|
39
|
-
`${'ID'.padEnd(38)} ${'Name'.padEnd(22)} ${'Slug'.padEnd(24)} ${'Status'.padEnd(10)} Replicas`,
|
|
40
|
-
'─'.repeat(110),
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
for (const p of projects) {
|
|
44
|
-
lines.push(
|
|
45
|
-
`${(p.id || '').padEnd(38)} ${(p.name || '').padEnd(22)} ${(p.slug || '').padEnd(24)} ${(p.status || 'unknown').padEnd(10)} ${p.replicas ?? '-'}`,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return textResult(lines.join('\n'));
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
server.tool(
|
|
54
|
-
'dailey_project_info',
|
|
55
|
-
'Get detailed info about a project including linked services',
|
|
56
|
-
{ project_id: z.string().describe('The project ID') },
|
|
57
|
-
async ({ project_id }) => {
|
|
58
|
-
const res = await apiRequest<any>('GET', `/projects/${project_id}`);
|
|
59
|
-
if (!res.ok) return textResult(formatError(res));
|
|
60
|
-
|
|
61
|
-
const p = res.data;
|
|
62
|
-
const lines = [
|
|
63
|
-
`Project: ${p.name}`,
|
|
64
|
-
`─────────────────────────────`,
|
|
65
|
-
`ID: ${p.id}`,
|
|
66
|
-
`Status: ${p.status || 'unknown'}`,
|
|
67
|
-
`Repo: ${p.repo_url || 'none'}`,
|
|
68
|
-
`Branch: ${p.branch || 'main'}`,
|
|
69
|
-
`Replicas: ${p.replicas ?? '-'}`,
|
|
70
|
-
`Database: ${p.database_name ? `${p.database_name} (${p.database_type || 'mysql'})` : 'none'}`,
|
|
71
|
-
`URL: ${p.url || 'none'}`,
|
|
72
|
-
`Created: ${p.created_at || 'unknown'}`,
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
const services = p.services;
|
|
76
|
-
if (services?.length > 0) {
|
|
77
|
-
lines.push('');
|
|
78
|
-
lines.push(`Services (${services.length + 1}):`);
|
|
79
|
-
lines.push(` ● ${p.slug} [primary] ${p.status}`);
|
|
80
|
-
for (const svc of services) {
|
|
81
|
-
lines.push(` ● ${svc.slug || svc.name} [${svc.service_role || 'secondary'}] ${svc.status}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return textResult(lines.join('\n'));
|
|
86
|
-
},
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
server.tool(
|
|
90
|
-
'dailey_project_services',
|
|
91
|
-
'List all services in a multi-container project',
|
|
92
|
-
{ project_id: z.string().describe('The project ID') },
|
|
93
|
-
async ({ project_id }) => {
|
|
94
|
-
const res = await apiRequest<any>('GET', `/projects/${project_id}`);
|
|
95
|
-
if (!res.ok) return textResult(formatError(res));
|
|
96
|
-
|
|
97
|
-
const p = res.data;
|
|
98
|
-
const services = p.services || [];
|
|
99
|
-
|
|
100
|
-
if (services.length === 0) {
|
|
101
|
-
return textResult(`${p.name} is a single-container project with no linked services.`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const lines = [
|
|
105
|
-
`Services for ${p.name} (${services.length + 1} total)`,
|
|
106
|
-
'─'.repeat(60),
|
|
107
|
-
`● ${(p.slug || '').padEnd(30)} primary ${p.status}`,
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
for (const svc of services) {
|
|
111
|
-
lines.push(`● ${(svc.slug || svc.name || '').padEnd(30)} ${(svc.service_role || 'secondary').padEnd(12)} ${svc.status}`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return textResult(lines.join('\n'));
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
server.tool(
|
|
119
|
-
'dailey_deploy_multi',
|
|
120
|
-
'Trigger a multi-container deploy for a project with multiple services',
|
|
121
|
-
{
|
|
122
|
-
project_id: z.string().describe('The project ID'),
|
|
123
|
-
selected_services: z.array(z.object({
|
|
124
|
-
name: z.string(),
|
|
125
|
-
type: z.enum(['managed', 'app_service']),
|
|
126
|
-
provider: z.string().optional(),
|
|
127
|
-
dockerfile: z.string().optional(),
|
|
128
|
-
buildContext: z.string().optional(),
|
|
129
|
-
})).optional().describe('Services to deploy (if omitted, deploys all detected services)'),
|
|
130
|
-
},
|
|
131
|
-
async ({ project_id, selected_services }) => {
|
|
132
|
-
// If no services provided, analyze first to discover them
|
|
133
|
-
let services = selected_services;
|
|
134
|
-
if (!services) {
|
|
135
|
-
const projRes = await apiRequest<any>('GET', `/projects/${project_id}`);
|
|
136
|
-
if (!projRes.ok) return textResult(formatError(projRes));
|
|
137
|
-
|
|
138
|
-
const analyzeRes = await apiRequest<any>('POST', '/projects/analyze', {
|
|
139
|
-
repo_url: projRes.data.repo_url,
|
|
140
|
-
branch: projRes.data.branch,
|
|
141
|
-
});
|
|
142
|
-
if (!analyzeRes.ok) return textResult(formatError(analyzeRes));
|
|
143
|
-
|
|
144
|
-
const manifest = analyzeRes.data.services_manifest;
|
|
145
|
-
if (!manifest?.entries?.length) {
|
|
146
|
-
return textResult('No multi-service manifest found. For single-container projects use dailey_deploy_bundle (creates + deploys in one call), or dailey_deploy with an existing project_id to redeploy.');
|
|
147
|
-
}
|
|
148
|
-
services = manifest.entries.filter((e: any) => e.type === 'managed' || e.type === 'app_service');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Safety: ensure at least one service is marked 'app_service' so the
|
|
152
|
-
// deployer knows which one gets the public ingress. Without this, all
|
|
153
|
-
// services deploy as "internal only" and the project is unreachable
|
|
154
|
-
// with no warning. (Scott hit this on 2026-04-20.)
|
|
155
|
-
const hasAppService = services?.some((s: any) => s.type === 'app_service');
|
|
156
|
-
if (services?.length && !hasAppService) {
|
|
157
|
-
services[0].type = 'app_service';
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const res = await apiRequest<any>('POST', `/projects/${project_id}/deploy-multi`, {
|
|
161
|
-
selected_services: services,
|
|
162
|
-
});
|
|
163
|
-
if (!res.ok) return textResult(formatError(res));
|
|
164
|
-
|
|
165
|
-
const primary = services?.find((s: any) => s.type === 'app_service')?.name;
|
|
166
|
-
return textResult([
|
|
167
|
-
`Multi-container deploy triggered!`,
|
|
168
|
-
``,
|
|
169
|
-
`Build ID: ${res.data.build_id}`,
|
|
170
|
-
`Deploy Group: ${res.data.deploy_group_id}`,
|
|
171
|
-
`Services: ${services?.length || 0}`,
|
|
172
|
-
`Primary (web): ${primary || 'none — check deploy log'}`,
|
|
173
|
-
``,
|
|
174
|
-
`Next: call dailey_deploy_status with project_id=${project_id} to watch progress.`,
|
|
175
|
-
` If it fails, call dailey_build_logs with project_id=${project_id} for full output.`,
|
|
176
|
-
].join('\n'));
|
|
177
|
-
},
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
server.tool(
|
|
181
|
-
'dailey_create_project',
|
|
182
|
-
'Create a project row AND auto-queue the first build. Prefer dailey_deploy_bundle when you also need env vars, service links, or a custom domain — it does create + configure + deploy in a single call. Use this tool only for the bare "just create + build" case.',
|
|
183
|
-
{
|
|
184
|
-
name: z.string().describe('Project name'),
|
|
185
|
-
repo_url: z.string().describe('Git repository URL'),
|
|
186
|
-
branch: z.string().optional().describe('Branch to deploy (default: main)'),
|
|
187
|
-
needs_database: z.boolean().optional().describe('Whether the project needs a database'),
|
|
188
|
-
},
|
|
189
|
-
async ({ name, repo_url, branch, needs_database }) => {
|
|
190
|
-
const body: Record<string, unknown> = { name, repo_url };
|
|
191
|
-
if (branch) body.branch = branch;
|
|
192
|
-
if (needs_database !== undefined) body.needs_database = needs_database;
|
|
193
|
-
|
|
194
|
-
const res = await apiRequest<Project & { build_id?: string }>('POST', '/projects', body);
|
|
195
|
-
if (!res.ok) return textResult(formatError(res));
|
|
196
|
-
|
|
197
|
-
const p = res.data;
|
|
198
|
-
return textResult(
|
|
199
|
-
[
|
|
200
|
-
`Project created successfully!`,
|
|
201
|
-
``,
|
|
202
|
-
`ID: ${p.id}`,
|
|
203
|
-
`Name: ${p.name}`,
|
|
204
|
-
`Status: ${p.status || 'pending'}`,
|
|
205
|
-
`Repo: ${p.repo_url}`,
|
|
206
|
-
...(p.build_id ? [`Build: ${p.build_id} (auto-queued — watch with dailey_deploy_status)`] : []),
|
|
207
|
-
`Branch: ${p.branch || 'main'}`,
|
|
208
|
-
`Database: ${p.needs_database ? 'yes' : 'no'}`,
|
|
209
|
-
].join('\n'),
|
|
210
|
-
);
|
|
211
|
-
},
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
server.tool(
|
|
215
|
-
'dailey_deploy',
|
|
216
|
-
'Trigger a build + deploy for an existing single-container project. Use this to redeploy a project that already exists (e.g., after pushing new commits to the repo). For multi-service projects use dailey_deploy_multi. To create AND deploy a new project, use dailey_deploy_bundle.',
|
|
217
|
-
{
|
|
218
|
-
project_id: z.string().describe('The project ID to deploy'),
|
|
219
|
-
commit_sha: z.string().optional().describe('Specific commit SHA to deploy (default: HEAD of the configured branch)'),
|
|
220
|
-
},
|
|
221
|
-
async ({ project_id, commit_sha }) => {
|
|
222
|
-
const res = await apiRequest<any>('POST', '/deploys', {
|
|
223
|
-
project_id,
|
|
224
|
-
commit_sha: commit_sha || 'HEAD',
|
|
225
|
-
});
|
|
226
|
-
if (!res.ok) return textResult(formatError(res));
|
|
227
|
-
|
|
228
|
-
const d = res.data || {};
|
|
229
|
-
return textResult([
|
|
230
|
-
`Deploy triggered!`,
|
|
231
|
-
``,
|
|
232
|
-
`Project: ${project_id}`,
|
|
233
|
-
`Build ID: ${d.build_id || '(unknown)'}`,
|
|
234
|
-
`Commit: ${commit_sha || 'HEAD'}`,
|
|
235
|
-
``,
|
|
236
|
-
`Next: dailey_deploy_status with project_id=${project_id} to watch progress.`,
|
|
237
|
-
` dailey_build_logs with project_id=${project_id} if it fails.`,
|
|
238
|
-
].join('\n'));
|
|
239
|
-
},
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
server.tool(
|
|
243
|
-
'dailey_delete_project',
|
|
244
|
-
'Delete a project — IRREVERSIBLE. Tears down Deployment, Service, Ingress, Secrets, DB, R2 prefix, DNS. Requires confirm=true to actually delete; calling without confirm returns the project\'s current state + a summary of what would be destroyed so you can verify before committing. (Pitfall #15)',
|
|
245
|
-
{
|
|
246
|
-
project_id: z.string().describe('The project ID to delete'),
|
|
247
|
-
confirm: z.boolean().optional().describe('MUST be true to actually delete. Default false — returns preview only.'),
|
|
248
|
-
},
|
|
249
|
-
async ({ project_id, confirm }) => {
|
|
250
|
-
if (!confirm) {
|
|
251
|
-
// Preview what would be deleted.
|
|
252
|
-
const info = await apiRequest<any>('GET', `/projects/${project_id}`);
|
|
253
|
-
if (!info.ok) return textResult(formatError(info));
|
|
254
|
-
const p = info.data;
|
|
255
|
-
const lines = [
|
|
256
|
-
`⚠ DELETE PREVIEW — not executed. Re-call with confirm=true to destroy.`,
|
|
257
|
-
'',
|
|
258
|
-
`Project: ${p.name} (${p.slug})`,
|
|
259
|
-
`ID: ${p.id}`,
|
|
260
|
-
`Status: ${p.status}`,
|
|
261
|
-
`Namespace: ${p.namespace || '-'}`,
|
|
262
|
-
`Database: ${p.database_name ? `${p.database_name} (${p.database_type})` : 'none'}`,
|
|
263
|
-
`URL: ${p.url || 'none'}`,
|
|
264
|
-
`Replicas: ${p.replicas ?? '-'}`,
|
|
265
|
-
'',
|
|
266
|
-
'Will be destroyed:',
|
|
267
|
-
' • k8s Deployment + Service + Ingress in namespace',
|
|
268
|
-
' • All Secrets (db creds, env, storage creds if project-local)',
|
|
269
|
-
' • Postgres/MySQL database + scoped role (if managed DB)',
|
|
270
|
-
' • R2 storage prefix for this project (if storage-enabled)',
|
|
271
|
-
' • DNS record at <slug>.dailey.cloud',
|
|
272
|
-
' • Customer registry image tags (not shared baseline images)',
|
|
273
|
-
'',
|
|
274
|
-
'Will survive:',
|
|
275
|
-
' • Audit logs, billing usage records (history)',
|
|
276
|
-
' • Nightly DB backups — retained per retention policy',
|
|
277
|
-
'',
|
|
278
|
-
`To delete: dailey_delete_project(project_id="${project_id}", confirm=true)`,
|
|
279
|
-
];
|
|
280
|
-
return textResult(lines.join('\n'));
|
|
281
|
-
}
|
|
282
|
-
const res = await apiRequest('DELETE', `/projects/${project_id}`);
|
|
283
|
-
if (!res.ok) return textResult(formatError(res));
|
|
284
|
-
return textResult(`Project ${project_id} deleted successfully.`);
|
|
285
|
-
},
|
|
286
|
-
);
|
|
287
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { apiRequest, formatError, textResult } from '../api.js';
|
|
4
|
-
|
|
5
|
-
interface ResourceConfigResponse {
|
|
6
|
-
cpu?: number;
|
|
7
|
-
memory_mb?: number;
|
|
8
|
-
storage_gb?: number;
|
|
9
|
-
replicas?: number;
|
|
10
|
-
project?: {
|
|
11
|
-
cpu_request?: string;
|
|
12
|
-
cpu_limit?: string;
|
|
13
|
-
memory_request?: string;
|
|
14
|
-
memory_limit?: string;
|
|
15
|
-
storage_limit?: string;
|
|
16
|
-
replicas?: number;
|
|
17
|
-
};
|
|
18
|
-
pool?: {
|
|
19
|
-
plan?: string;
|
|
20
|
-
cpu_total?: number;
|
|
21
|
-
cpu_used?: number;
|
|
22
|
-
memory_total_mb?: number;
|
|
23
|
-
memory_used_mb?: number;
|
|
24
|
-
storage_total_gb?: number;
|
|
25
|
-
storage_used_gb?: number;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function registerResourceConfigTools(server: McpServer) {
|
|
30
|
-
server.tool(
|
|
31
|
-
'dailey_resource_config',
|
|
32
|
-
'Get or set CPU/memory/storage limits for a project. Pool shows remaining plan capacity.',
|
|
33
|
-
{
|
|
34
|
-
project_id: z.string().describe('The project ID'),
|
|
35
|
-
action: z.enum(['get', 'set']).describe('get | set'),
|
|
36
|
-
cpu: z.number().optional().describe('CPU cores (e.g., 0.5, 1, 2). Used by set.'),
|
|
37
|
-
memory_mb: z.number().int().optional().describe('Memory in MB. Used by set.'),
|
|
38
|
-
storage_gb: z.number().optional().describe('Storage in GB. Used by set.'),
|
|
39
|
-
replicas: z.number().int().min(0).max(20).optional().describe('Replicas. Used by set.'),
|
|
40
|
-
},
|
|
41
|
-
async ({ project_id, action, cpu, memory_mb, storage_gb, replicas }) => {
|
|
42
|
-
if (action === 'get') {
|
|
43
|
-
const res = await apiRequest<ResourceConfigResponse>('GET', `/projects/${project_id}/resource-config`);
|
|
44
|
-
if (!res.ok) return textResult(formatError(res));
|
|
45
|
-
|
|
46
|
-
const d = res.data;
|
|
47
|
-
const proj = d.project || {};
|
|
48
|
-
const pool = d.pool || {};
|
|
49
|
-
|
|
50
|
-
const lines = [
|
|
51
|
-
`Resource config for project ${project_id}`,
|
|
52
|
-
'─'.repeat(50),
|
|
53
|
-
`CPU: ${d.cpu ?? 0} cores (limit: ${proj.cpu_limit || '-'}, request: ${proj.cpu_request || '-'})`,
|
|
54
|
-
`Memory: ${d.memory_mb ?? 0} MB (limit: ${proj.memory_limit || '-'}, request: ${proj.memory_request || '-'})`,
|
|
55
|
-
`Storage: ${d.storage_gb ?? 0} GB (limit: ${proj.storage_limit || '-'})`,
|
|
56
|
-
`Replicas: ${d.replicas ?? 1}`,
|
|
57
|
-
'',
|
|
58
|
-
`Plan: ${pool.plan || 'unknown'}`,
|
|
59
|
-
`CPU pool: ${pool.cpu_used ?? 0}/${pool.cpu_total ?? 0} cores used`,
|
|
60
|
-
`Memory pool: ${pool.memory_used_mb ?? 0}/${pool.memory_total_mb ?? 0} MB used`,
|
|
61
|
-
`Storage pool: ${pool.storage_used_gb ?? 0}/${pool.storage_total_gb ?? 0} GB used`,
|
|
62
|
-
];
|
|
63
|
-
return textResult(lines.join('\n'));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (action === 'set') {
|
|
67
|
-
const body: Record<string, number> = {};
|
|
68
|
-
if (cpu !== undefined) body.cpu = cpu;
|
|
69
|
-
if (memory_mb !== undefined) body.memory_mb = memory_mb;
|
|
70
|
-
if (storage_gb !== undefined) body.storage_gb = storage_gb;
|
|
71
|
-
if (replicas !== undefined) body.replicas = replicas;
|
|
72
|
-
if (Object.keys(body).length === 0) {
|
|
73
|
-
return textResult('Error: specify at least one of cpu, memory_mb, storage_gb, replicas.');
|
|
74
|
-
}
|
|
75
|
-
const res = await apiRequest('PUT', `/projects/${project_id}/resource-config`, body);
|
|
76
|
-
if (!res.ok) return textResult(formatError(res));
|
|
77
|
-
const changed = Object.entries(body).map(([k, v]) => `${k}=${v}`).join(', ');
|
|
78
|
-
return textResult(`Resource config updated: ${changed}.\n\nChanges take effect on the next deploy (or use dailey_process_restart).`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return textResult('Invalid action. Use get or set.');
|
|
82
|
-
},
|
|
83
|
-
);
|
|
84
|
-
}
|