@edgegap/mcp 0.13.3 → 0.14.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.
- package/README.md +38 -7
- package/dist/client.js +50 -1
- package/dist/config.js +3 -0
- package/dist/skills.generated.js +10 -10
- package/dist/skillsinstall.js +19 -4
- package/dist/skillsversion.js +2 -0
- package/dist/tools.js +537 -14
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/tools.js
CHANGED
|
@@ -20,7 +20,7 @@ import { badImage, badTag, ENCRYPTED_PLACEHOLDER, isEncryptedPlaceholder, looksS
|
|
|
20
20
|
import { OUTPUT } from './outputs.js';
|
|
21
21
|
import { finishReport, codeForStatus } from './callreport.js';
|
|
22
22
|
import { SKILLS_PACK, findSkill, findSkillFile, fileIndex, mimeType, skillUri } from './skills.js';
|
|
23
|
-
import { SKILL_NAME_RE, compareVersions, latestPack, latestSkillVersions, servedPackStatus, skillsCheckFromEnv, } from './skillsversion.js';
|
|
23
|
+
import { SKILLS_CLI, SKILL_NAME_RE, compareVersions, latestPack, latestSkillVersions, servedPackStatus, skillsCheckFromEnv, } from './skillsversion.js';
|
|
24
24
|
/**
|
|
25
25
|
* The one definition of "dedicated server vs relay" this server gives agents.
|
|
26
26
|
* Used in the server instructions, the relay tool description, and every relay
|
|
@@ -301,7 +301,7 @@ function errorHint(err, notFound, forbidden) {
|
|
|
301
301
|
case 409:
|
|
302
302
|
return 'a resource with that name already exists. Pick a different name or reuse the existing one.';
|
|
303
303
|
case 422:
|
|
304
|
-
return 'Edgegap could not allocate a server for the requested location or resources. Try different user coordinates, or lower
|
|
304
|
+
return 'Edgegap could not allocate a server for the requested location or resources. Try different user coordinates, or lower cpu_units/memory_mb.';
|
|
305
305
|
case 424:
|
|
306
306
|
return 'Edgegap could not pull the container image. Check docker_repository, docker_image, docker_tag, and registry credentials.';
|
|
307
307
|
default:
|
|
@@ -498,6 +498,12 @@ function checkRequestId(id) {
|
|
|
498
498
|
'as returned by edgegap_deploy or edgegap_list_deployments. Wildcards, lists and empty IDs ' +
|
|
499
499
|
'are refused, and there is no bulk stop.');
|
|
500
500
|
}
|
|
501
|
+
/** Refuses an empty, wildcard or list-like name where one exact name is required. */
|
|
502
|
+
function exactName(name, what) {
|
|
503
|
+
if (name.trim() === name && name.length > 0 && !/[*?,\s]/.test(name))
|
|
504
|
+
return undefined;
|
|
505
|
+
return fail(`"${name.slice(0, 80)}" is not one exact ${what} name. Pass a single name; wildcards and lists are refused.`);
|
|
506
|
+
}
|
|
501
507
|
/** The dry_run parameter every write tool takes. */
|
|
502
508
|
const dryRunParam = z
|
|
503
509
|
.boolean()
|
|
@@ -555,6 +561,22 @@ async function tokenLeak(auth, dryRun, fields) {
|
|
|
555
561
|
'everything that can read those. If the game server needs to call Edgegap, give it a ' +
|
|
556
562
|
'separate, purpose-made credential, and never this one.');
|
|
557
563
|
}
|
|
564
|
+
const WEBHOOKS = ['webhook_on_ready', 'webhook_on_error', 'webhook_on_terminated'];
|
|
565
|
+
/** Why a deploy webhook URL is refused: Edgegap would POST deployment details to it. */
|
|
566
|
+
export function webhookProblem(raw) {
|
|
567
|
+
let url;
|
|
568
|
+
try {
|
|
569
|
+
url = new URL(raw);
|
|
570
|
+
}
|
|
571
|
+
catch {
|
|
572
|
+
return `"${raw.slice(0, 80)}" is not a URL.`;
|
|
573
|
+
}
|
|
574
|
+
if (url.protocol !== 'https:')
|
|
575
|
+
return 'must be an https URL: Edgegap sends deployment details (IP, ports) to it.';
|
|
576
|
+
if (url.username || url.password)
|
|
577
|
+
return 'must not contain a username or password.';
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
558
580
|
/**
|
|
559
581
|
* How long a new deployment can run before Edgegap stops it, from the
|
|
560
582
|
* version's max_duration. The API takes no per-deployment limit, so this is
|
|
@@ -624,6 +646,8 @@ function withHost(result, label) {
|
|
|
624
646
|
}
|
|
625
647
|
export function registerTools(server, client, config, auth, options = {}) {
|
|
626
648
|
const mutating = !config.readOnly;
|
|
649
|
+
// Deploys sent by this server instance; see EDGEGAP_MAX_DEPLOYS_PER_RUN.
|
|
650
|
+
let deploysSent = 0;
|
|
627
651
|
// Every result names the API host it came from, first, so a session pointed
|
|
628
652
|
// at a custom EDGEGAP_BASE_URL can never be mistaken for production.
|
|
629
653
|
const label = hostLabel(config);
|
|
@@ -743,11 +767,14 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
743
767
|
app_allowlist: config.appAllowlist.length ? config.appAllowlist : 'none (all applications)',
|
|
744
768
|
max_duration_ceiling_minutes: config.maxDurationCeiling,
|
|
745
769
|
max_agent_deployments: config.maxAgentDeployments > 0 ? config.maxAgentDeployments : 'no cap',
|
|
770
|
+
max_deploys_per_run: hosted ? 'n/a (hosted: no state between requests)' : (config.maxDeploysPerRun ?? 0) > 0 ? config.maxDeploysPerRun : 'no cap',
|
|
771
|
+
stop_own_only: config.stopOwnOnly === true,
|
|
772
|
+
...(hosted ? {} : { skills_updaters_enabled: config.enableSkillsUpdate === true }),
|
|
746
773
|
skills_pack: `${SKILLS_PACK.version} (${SKILLS_PACK.commit.slice(0, 7)}), ${SKILLS_PACK.skills.length} skills`,
|
|
747
774
|
forced_deploy_tag: AGENT_TAG,
|
|
748
775
|
guardrails: {
|
|
749
776
|
dry_run: mutating
|
|
750
|
-
? 'deploy,
|
|
777
|
+
? 'every write tool: deploy, stop, tag and report deployments, create/update/delete apps and versions, delete_registry_tag, endpoint storage and pull profiles, relays'
|
|
751
778
|
: 'n/a: read-only, no write tools are registered',
|
|
752
779
|
token_in_container: 'deploys and versions are refused if the API token appears in an env var, tag or webhook URL',
|
|
753
780
|
image_tags: 'versions on "latest", an empty or malformed tag, or a docker_image holding a registry or tag are refused; so is deploying a version on "latest"',
|
|
@@ -755,8 +782,12 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
755
782
|
? `deploy is refused while ${config.maxAgentDeployments} or more agent-tagged deployments are running`
|
|
756
783
|
: 'off (EDGEGAP_MAX_AGENT_DEPLOYMENTS=0)',
|
|
757
784
|
secret_env: 'env vars named like secrets (TOKEN, SECRET, PASSWORD, API_KEY...) are sent hidden',
|
|
758
|
-
stop:
|
|
785
|
+
stop: config.stopOwnOnly
|
|
786
|
+
? `one exact request_id per call; no bulk stop; only deployments tagged "${AGENT_TAG}" (EDGEGAP_STOP_OWN_ONLY)`
|
|
787
|
+
: 'one exact request_id per call; no bulk stop',
|
|
759
788
|
auto_stop: 'each deploy reports its version\'s max_duration; Edgegap has no per-deployment time limit',
|
|
789
|
+
long_running: `deploying a version whose max_duration is unlimited or above ${config.maxDurationCeiling} minutes needs allow_long_running: true`,
|
|
790
|
+
deletes: 'one exact app or version per call; refused while its deployments run; an app with versions needs max_versions',
|
|
760
791
|
results: `every result starts with [${label}]`,
|
|
761
792
|
},
|
|
762
793
|
user_agent: `edgegap-mcp/${VERSION} (<MCP client name>)`,
|
|
@@ -981,6 +1012,11 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
981
1012
|
.boolean()
|
|
982
1013
|
.optional()
|
|
983
1014
|
.describe('Verify Edgegap can pull the image before accepting the version.'),
|
|
1015
|
+
endpoint_storage: z
|
|
1016
|
+
.string()
|
|
1017
|
+
.min(1)
|
|
1018
|
+
.optional()
|
|
1019
|
+
.describe('Endpoint Storage name (edgegap_list_endpoint_storage) to export container logs to when deployments end.'),
|
|
984
1020
|
env: z
|
|
985
1021
|
.array(z.object({ key: z.string(), value: z.string() }))
|
|
986
1022
|
.optional()
|
|
@@ -1038,6 +1074,7 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1038
1074
|
private_username: args.registry_username,
|
|
1039
1075
|
private_token: args.registry_token,
|
|
1040
1076
|
verify_image: args.verify_image ?? false,
|
|
1077
|
+
...(args.endpoint_storage ? { endpoint_storage: args.endpoint_storage } : {}),
|
|
1041
1078
|
max_duration: capped,
|
|
1042
1079
|
ports: args.ports.map((p) => ({
|
|
1043
1080
|
port: p.port,
|
|
@@ -1103,8 +1140,9 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1103
1140
|
'version\'s whole list (per the API): read the current ones with edgegap_get_app_version ' +
|
|
1104
1141
|
'and pass every port or variable to keep; secret env values are not readable, so get them ' +
|
|
1105
1142
|
'from the developer. Refused, with nothing sent, for a registry login or env value equal to ' +
|
|
1106
|
-
'the API\'s "' + ENCRYPTED_PLACEHOLDER + '" placeholder; leave the registry login out to keep it.
|
|
1107
|
-
'
|
|
1143
|
+
'the API\'s "' + ENCRYPTED_PLACEHOLDER + '" placeholder; leave the registry login out to keep it. cpu_units and memory_mb ' +
|
|
1144
|
+
'change together (both or neither); to try other resources for one deployment only, override them in ' +
|
|
1145
|
+
'edgegap_deploy instead.',
|
|
1108
1146
|
inputSchema: {
|
|
1109
1147
|
application: z.string().describe('Application name.'),
|
|
1110
1148
|
version: z.string().describe('Version name to change.'),
|
|
@@ -1119,8 +1157,25 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1119
1157
|
.int()
|
|
1120
1158
|
.optional()
|
|
1121
1159
|
.describe('Auto-stop after this many minutes. Capped by EDGEGAP_MAX_DURATION_MINUTES.'),
|
|
1160
|
+
cpu_units: z
|
|
1161
|
+
.number()
|
|
1162
|
+
.int()
|
|
1163
|
+
.min(256)
|
|
1164
|
+
.optional()
|
|
1165
|
+
.describe('New vCPU units for later deployments, with memory_mb. 1024 = 1 vCPU.'),
|
|
1166
|
+
memory_mb: z
|
|
1167
|
+
.number()
|
|
1168
|
+
.int()
|
|
1169
|
+
.min(256)
|
|
1170
|
+
.optional()
|
|
1171
|
+
.describe('New memory in MB for later deployments, with cpu_units. At most 2x cpu_units.'),
|
|
1122
1172
|
force_cache: z.boolean().optional().describe('Pre-load the image on Edgegap so deployments start faster.'),
|
|
1123
1173
|
verify_image: z.boolean().optional().describe('Check Edgegap can pull the image when saving.'),
|
|
1174
|
+
endpoint_storage: z
|
|
1175
|
+
.string()
|
|
1176
|
+
.min(1)
|
|
1177
|
+
.optional()
|
|
1178
|
+
.describe('Endpoint Storage name (edgegap_list_endpoint_storage) to export container logs to when deployments end.'),
|
|
1124
1179
|
termination_grace_period_seconds: z
|
|
1125
1180
|
.number()
|
|
1126
1181
|
.int()
|
|
@@ -1181,6 +1236,15 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1181
1236
|
if (imageProblem)
|
|
1182
1237
|
return fail(`Refused: ${imageProblem}`);
|
|
1183
1238
|
}
|
|
1239
|
+
// The PATCH takes req_cpu and req_memory separately, but the 2x
|
|
1240
|
+
// ratio spans both, so take them together like edgegap_deploy does.
|
|
1241
|
+
if ((args.cpu_units === undefined) !== (args.memory_mb === undefined)) {
|
|
1242
|
+
return fail('Pass both cpu_units and memory_mb to change the version\'s resources, or neither to keep them.');
|
|
1243
|
+
}
|
|
1244
|
+
if (args.cpu_units !== undefined && args.memory_mb !== undefined && args.memory_mb > args.cpu_units * 2) {
|
|
1245
|
+
return fail(`memory_mb (${args.memory_mb}) exceeds twice cpu_units (${args.cpu_units}). Edgegap rejects this. ` +
|
|
1246
|
+
`Lower memory_mb to ${args.cpu_units * 2} or raise cpu_units.`);
|
|
1247
|
+
}
|
|
1184
1248
|
const capped = args.max_duration_minutes === undefined
|
|
1185
1249
|
? undefined
|
|
1186
1250
|
: Math.min(args.max_duration_minutes, config.maxDurationCeiling);
|
|
@@ -1191,9 +1255,12 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1191
1255
|
docker_tag: args.docker_tag,
|
|
1192
1256
|
private_username: args.registry_username,
|
|
1193
1257
|
private_token: args.registry_token,
|
|
1258
|
+
req_cpu: args.cpu_units,
|
|
1259
|
+
req_memory: args.memory_mb,
|
|
1194
1260
|
max_duration: capped,
|
|
1195
1261
|
force_cache: args.force_cache,
|
|
1196
1262
|
verify_image: args.verify_image,
|
|
1263
|
+
endpoint_storage: args.endpoint_storage,
|
|
1197
1264
|
termination_grace_period_seconds: args.termination_grace_period_seconds,
|
|
1198
1265
|
ports: args.ports?.map((p) => ({
|
|
1199
1266
|
port: p.port,
|
|
@@ -1304,7 +1371,11 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1304
1371
|
'stopped or until the version\'s max_duration, which the result reports. Refused, with ' +
|
|
1305
1372
|
'nothing sent, if the API token appears in an env var or tag, if the version uses the "latest" ' +
|
|
1306
1373
|
'docker tag, or when too many agent deployments are already running (EDGEGAP_MAX_AGENT_DEPLOYMENTS, ' +
|
|
1307
|
-
'default 5): stop finished ones first.
|
|
1374
|
+
'default 5): stop finished ones first. Also refused when the version\'s max_duration is unlimited or above ' +
|
|
1375
|
+
'EDGEGAP_MAX_DURATION_MINUTES, unless allow_long_running is true (ask the developer first), and on the local ' +
|
|
1376
|
+
'server after EDGEGAP_MAX_DEPLOYS_PER_RUN deploys (default 20). Env vars named like secrets are hidden in the ' +
|
|
1377
|
+
'dashboard. Optional: webhooks Edgegap calls when the server is ready, errors or ends (instead of polling), ' +
|
|
1378
|
+
'require_cached_locations for faster starts, and private_host_ids to place it on your private fleet first.',
|
|
1308
1379
|
inputSchema: {
|
|
1309
1380
|
application: z.string().describe('Application name.'),
|
|
1310
1381
|
version: z.string().describe('Version name within the application.'),
|
|
@@ -1329,6 +1400,24 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1329
1400
|
.min(256)
|
|
1330
1401
|
.optional()
|
|
1331
1402
|
.describe('Override the version\'s memory for this deployment only, with cpu_units. At most 2x cpu_units.'),
|
|
1403
|
+
require_cached_locations: z
|
|
1404
|
+
.boolean()
|
|
1405
|
+
.optional()
|
|
1406
|
+
.describe('Only place it where the image is already cached: starts faster, fewer places to choose from.'),
|
|
1407
|
+
webhook_on_ready: z.string().optional().describe('https URL Edgegap POSTs to when the server is ready.'),
|
|
1408
|
+
webhook_on_error: z.string().optional().describe('https URL Edgegap POSTs to when the deployment fails.'),
|
|
1409
|
+
webhook_on_terminated: z.string().optional().describe('https URL Edgegap POSTs to when the deployment ends.'),
|
|
1410
|
+
private_host_ids: z
|
|
1411
|
+
.array(z.string().min(1))
|
|
1412
|
+
.min(1)
|
|
1413
|
+
.optional()
|
|
1414
|
+
.describe('Private fleet host IDs to try first, in order (from edgegap_list_fleet_hosts); Edgegap overflows to ' +
|
|
1415
|
+
'its cloud when they are full. Omit for a normal cloud deployment.'),
|
|
1416
|
+
allow_long_running: z
|
|
1417
|
+
.boolean()
|
|
1418
|
+
.optional()
|
|
1419
|
+
.describe('Deploy even though the version\'s max_duration is unlimited or above EDGEGAP_MAX_DURATION_MINUTES. ' +
|
|
1420
|
+
'Only after the developer agreed: the server bills until it is stopped or that limit.'),
|
|
1332
1421
|
dry_run: dryRunParam,
|
|
1333
1422
|
},
|
|
1334
1423
|
outputSchema: OUTPUT.deploy,
|
|
@@ -1349,12 +1438,18 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1349
1438
|
[`the value of env var "${e.key.slice(0, 40)}"`, e.value],
|
|
1350
1439
|
]),
|
|
1351
1440
|
...tags.map((t) => [`tag "${t.slice(0, 8)}…"`, t]),
|
|
1441
|
+
...WEBHOOKS.map((w) => [w, args[w]]),
|
|
1352
1442
|
]);
|
|
1353
1443
|
if (leak)
|
|
1354
1444
|
return leak;
|
|
1355
1445
|
const placeholder = encryptedPlaceholder((args.env ?? []).map((e) => [`the value of env var "${e.key.slice(0, 40)}"`, e.value]), 'Leave the variable out: the deployment already gets the version\'s own env vars.');
|
|
1356
1446
|
if (placeholder)
|
|
1357
1447
|
return placeholder;
|
|
1448
|
+
for (const w of WEBHOOKS) {
|
|
1449
|
+
const problem = args[w] === undefined ? undefined : webhookProblem(args[w]);
|
|
1450
|
+
if (problem)
|
|
1451
|
+
return fail(`${w}: ${problem}`);
|
|
1452
|
+
}
|
|
1358
1453
|
const body = {
|
|
1359
1454
|
application: args.application,
|
|
1360
1455
|
version: args.version,
|
|
@@ -1379,9 +1474,27 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1379
1474
|
}
|
|
1380
1475
|
body.resources = { cpu_units: args.cpu_units, memory_mib: args.memory_mb };
|
|
1381
1476
|
}
|
|
1477
|
+
if (args.require_cached_locations !== undefined)
|
|
1478
|
+
body.require_cached_locations = args.require_cached_locations;
|
|
1479
|
+
for (const w of WEBHOOKS)
|
|
1480
|
+
if (args[w] !== undefined)
|
|
1481
|
+
body[w] = { url: args[w] };
|
|
1482
|
+
const fleet = args.private_host_ids !== undefined;
|
|
1483
|
+
if (fleet)
|
|
1484
|
+
body.private_host_ids = [...new Set(args.private_host_ids)];
|
|
1485
|
+
const send = (c) => (fleet ? c.deployToFleet(body) : c.deploy(body));
|
|
1486
|
+
// Counted per process, before the version is read, so a loop that
|
|
1487
|
+
// keeps failing still runs out. The hosted server has no process to
|
|
1488
|
+
// count in; its cap is EDGEGAP_MAX_AGENT_DEPLOYMENTS alone.
|
|
1489
|
+
const perRun = config.transport === 'local' ? (config.maxDeploysPerRun ?? 0) : 0;
|
|
1490
|
+
if (!args.dry_run && perRun > 0 && deploysSent >= perRun) {
|
|
1491
|
+
return fail(`Refused: this server already sent ${deploysSent} deploys, the limit for one run ` +
|
|
1492
|
+
`(EDGEGAP_MAX_DEPLOYS_PER_RUN=${perRun}). Nothing was sent. Stop what is running and ask the developer; ` +
|
|
1493
|
+
'restarting the MCP server resets the count.');
|
|
1494
|
+
}
|
|
1382
1495
|
if (args.dry_run) {
|
|
1383
1496
|
const dry = client.dryRun();
|
|
1384
|
-
await dry.client
|
|
1497
|
+
await send(dry.client);
|
|
1385
1498
|
return dryRunResult(dry.requests, [
|
|
1386
1499
|
`Tagged "${AGENT_TAG}" automatically.`,
|
|
1387
1500
|
'Auto-stop comes from the version\'s max_duration; a real deploy reports it.',
|
|
@@ -1396,6 +1509,16 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1396
1509
|
return fail(`Refused: version "${args.version}" uses docker_tag "${version.docker_tag}". ${TAG_FIX} ` +
|
|
1397
1510
|
'Then create a new version with edgegap_create_app_version and deploy that.');
|
|
1398
1511
|
}
|
|
1512
|
+
const maxDuration = version.max_duration;
|
|
1513
|
+
const longRunning = typeof maxDuration === 'number' && (maxDuration <= 0 || maxDuration > config.maxDurationCeiling);
|
|
1514
|
+
if (longRunning && !args.allow_long_running) {
|
|
1515
|
+
return fail(`Refused: version "${args.version}" lets a deployment run ` +
|
|
1516
|
+
(maxDuration <= 0 ? 'with no time limit' : `for ${maxDuration} minutes`) +
|
|
1517
|
+
`, above this server's EDGEGAP_MAX_DURATION_MINUTES (${config.maxDurationCeiling}). Nothing was sent. ` +
|
|
1518
|
+
'Ask the developer; if they agree, deploy again with allow_long_running: true and stop it when done. ' +
|
|
1519
|
+
'For tests, a version created with edgegap_create_app_version gets the capped max_duration. Do not ' +
|
|
1520
|
+
'lower max_duration on a version live players use.');
|
|
1521
|
+
}
|
|
1399
1522
|
// A looping agent can start servers faster than anyone notices the
|
|
1400
1523
|
// bill. Count the ones it already has running before adding one.
|
|
1401
1524
|
if (config.maxAgentDeployments > 0) {
|
|
@@ -1411,15 +1534,54 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1411
1534
|
'using edgegap_stop_deployment, then deploy again.');
|
|
1412
1535
|
}
|
|
1413
1536
|
}
|
|
1414
|
-
|
|
1537
|
+
deploysSent++;
|
|
1538
|
+
const sentAt = new Date(Date.now() - 60_000).toISOString();
|
|
1539
|
+
let res;
|
|
1540
|
+
try {
|
|
1541
|
+
res = await send(client);
|
|
1542
|
+
}
|
|
1543
|
+
catch (err) {
|
|
1544
|
+
// A refused deploy can still leave a deployment behind (a 422
|
|
1545
|
+
// "not enough space" did, 2026-10-28) with no request_id in the
|
|
1546
|
+
// error. Name it so the agent can stop it.
|
|
1547
|
+
if (!(err instanceof EdgegapApiError))
|
|
1548
|
+
throw err;
|
|
1549
|
+
const left = await client
|
|
1550
|
+
.listDeployments({
|
|
1551
|
+
query: JSON.stringify({
|
|
1552
|
+
filters: [
|
|
1553
|
+
{ field: 'application', operator: 'eq', value: args.application },
|
|
1554
|
+
{ field: 'version', operator: 'eq', value: args.version },
|
|
1555
|
+
{ field: 'tags', operator: 'in', value: [AGENT_TAG] },
|
|
1556
|
+
{ field: 'created_at', operator: 'gte', value: sentAt },
|
|
1557
|
+
],
|
|
1558
|
+
}),
|
|
1559
|
+
limit: 10,
|
|
1560
|
+
})
|
|
1561
|
+
.then((r) => (r.data ?? []).map((d) => d.request_id).filter(Boolean))
|
|
1562
|
+
.catch(() => []);
|
|
1563
|
+
if (left.length === 0)
|
|
1564
|
+
throw err;
|
|
1565
|
+
throw new EdgegapApiError(err.status, `${err.apiMessage}\nThe API still created ${left.length === 1 ? 'a deployment' : 'deployments'} for this ` +
|
|
1566
|
+
`request: ${left.join(', ')}. Stop ${left.length === 1 ? 'it' : 'each'} with edgegap_stop_deployment.`, err.details);
|
|
1567
|
+
}
|
|
1415
1568
|
return withMeta(ok({
|
|
1416
1569
|
request_id: res.request_id,
|
|
1417
1570
|
status: 'starting',
|
|
1418
1571
|
tags,
|
|
1572
|
+
...(fleet ? { private_host_ids: body.private_host_ids } : {}),
|
|
1573
|
+
...(longRunning ? { long_running: 'allowed by allow_long_running' } : {}),
|
|
1419
1574
|
...autoStop(version.max_duration),
|
|
1420
1575
|
resources: body.resources,
|
|
1421
1576
|
next_step: `Call edgegap_wait_for_deployment with request_id ${res.request_id}.`,
|
|
1422
|
-
}), {
|
|
1577
|
+
}), {
|
|
1578
|
+
hash: { request_id: res.request_id },
|
|
1579
|
+
props: {
|
|
1580
|
+
resources_override: body.resources !== undefined,
|
|
1581
|
+
private_fleet: fleet,
|
|
1582
|
+
webhooks: WEBHOOKS.filter((w) => args[w] !== undefined).length,
|
|
1583
|
+
},
|
|
1584
|
+
});
|
|
1423
1585
|
}));
|
|
1424
1586
|
}
|
|
1425
1587
|
// ---------------------------------------------------------------- 6 ----
|
|
@@ -1616,6 +1778,15 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
1616
1778
|
const bad = checkRequestId(request_id);
|
|
1617
1779
|
if (bad)
|
|
1618
1780
|
return bad;
|
|
1781
|
+
if (config.stopOwnOnly && !dry_run) {
|
|
1782
|
+
const own = await client
|
|
1783
|
+
.listDeploymentTags(request_id)
|
|
1784
|
+
.then((r) => (r.tags ?? []).some((t) => t.name === AGENT_TAG || t.name === 'mcp'));
|
|
1785
|
+
if (!own) {
|
|
1786
|
+
return fail(`Refused: deployment ${request_id} has no "${AGENT_TAG}" tag, so this server did not start it, and ` +
|
|
1787
|
+
'EDGEGAP_STOP_OWN_ONLY is on. Nothing was sent. Ask the developer to stop it from the dashboard.');
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1619
1790
|
if (dry_run) {
|
|
1620
1791
|
const dry = client.dryRun();
|
|
1621
1792
|
await dry.client.stopDeployment(request_id);
|
|
@@ -2118,6 +2289,353 @@ export function registerTools(server, client, config, auth, options = {}) {
|
|
|
2118
2289
|
}
|
|
2119
2290
|
}));
|
|
2120
2291
|
}
|
|
2292
|
+
// ============================================ deployment housekeeping ====
|
|
2293
|
+
// --------------------------------------------------------------- 13c ----
|
|
2294
|
+
if (mutating) {
|
|
2295
|
+
tool('edgegap_tag_deployment', {
|
|
2296
|
+
title: 'Add or remove tags on a running deployment',
|
|
2297
|
+
description: 'Add tags to, or remove tags from, one running deployment, e.g. to mark the match it serves or ' +
|
|
2298
|
+
'that a test is done, so edgegap_list_deployments can filter on them. Tags are labels only: the ' +
|
|
2299
|
+
'game server does not see the change. The "' + AGENT_TAG + '" tag cannot be removed, since it is ' +
|
|
2300
|
+
'how agent deployments are found and cleaned up. Returns the tags now on the deployment.',
|
|
2301
|
+
inputSchema: {
|
|
2302
|
+
request_id: z.string().describe('The exact request_id of the deployment.'),
|
|
2303
|
+
add: z.array(z.string().min(1).max(40)).optional().describe('Tags to add, at most 40 characters each.'),
|
|
2304
|
+
remove: z.array(z.string().min(1).max(40)).optional().describe('Tags to remove.'),
|
|
2305
|
+
dry_run: dryRunParam,
|
|
2306
|
+
},
|
|
2307
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
2308
|
+
}, async ({ request_id, add, remove, dry_run }) => guarded(auth, NOT_FOUND.deployment, async () => {
|
|
2309
|
+
const bad = checkRequestId(request_id);
|
|
2310
|
+
if (bad)
|
|
2311
|
+
return bad;
|
|
2312
|
+
const toAdd = [...new Set(add ?? [])];
|
|
2313
|
+
const toRemove = [...new Set(remove ?? [])];
|
|
2314
|
+
if (toAdd.length === 0 && toRemove.length === 0)
|
|
2315
|
+
return fail('Nothing to change: pass add, remove or both.');
|
|
2316
|
+
if (toRemove.some((t) => t === AGENT_TAG || t === 'mcp')) {
|
|
2317
|
+
return fail(`Refused: "${AGENT_TAG}" marks deployments an agent started and stays on. Nothing was sent.`);
|
|
2318
|
+
}
|
|
2319
|
+
const both = toAdd.filter((t) => toRemove.includes(t));
|
|
2320
|
+
if (both.length)
|
|
2321
|
+
return fail(`${both.join(', ')}: in both add and remove. Pick one.`);
|
|
2322
|
+
const leak = await tokenLeak(auth, dry_run, toAdd.map((t) => [`tag "${t.slice(0, 8)}…"`, t]));
|
|
2323
|
+
if (leak)
|
|
2324
|
+
return leak;
|
|
2325
|
+
if (dry_run) {
|
|
2326
|
+
const dry = client.dryRun();
|
|
2327
|
+
for (const t of toAdd)
|
|
2328
|
+
await dry.client.addDeploymentTag(request_id, t);
|
|
2329
|
+
for (const t of toRemove)
|
|
2330
|
+
await dry.client.removeDeploymentTag(request_id, t);
|
|
2331
|
+
return dryRunResult(dry.requests);
|
|
2332
|
+
}
|
|
2333
|
+
const current = new Set(((await client.listDeploymentTags(request_id)).tags ?? []).map((t) => t.name));
|
|
2334
|
+
const notes = [];
|
|
2335
|
+
for (const t of toAdd) {
|
|
2336
|
+
if (current.has(t))
|
|
2337
|
+
notes.push(`"${t}" was already on it.`);
|
|
2338
|
+
else
|
|
2339
|
+
await client.addDeploymentTag(request_id, t);
|
|
2340
|
+
}
|
|
2341
|
+
for (const t of toRemove) {
|
|
2342
|
+
if (!current.has(t))
|
|
2343
|
+
notes.push(`"${t}" was not on it.`);
|
|
2344
|
+
else
|
|
2345
|
+
await client.removeDeploymentTag(request_id, t);
|
|
2346
|
+
}
|
|
2347
|
+
const after = ((await client.listDeploymentTags(request_id)).tags ?? []).map((t) => t.name);
|
|
2348
|
+
return withMeta(ok({ request_id, tags: after, ...(notes.length ? { notes } : {}) }), { hash: { request_id } });
|
|
2349
|
+
}));
|
|
2350
|
+
tool('edgegap_report_deployment', {
|
|
2351
|
+
title: 'Report a deployment to Edgegap',
|
|
2352
|
+
description: 'Report a problem with one deployment to Edgegap (the API\'s "Report a Deployment", meant for a ' +
|
|
2353
|
+
'studio\'s moderation backend), with a short reason and optional key/value details. It does not stop ' +
|
|
2354
|
+
'the deployment. Use it only when the developer asks to report a deployment; for a crash, read ' +
|
|
2355
|
+
'edgegap_get_deployment_logs first.',
|
|
2356
|
+
inputSchema: {
|
|
2357
|
+
request_id: z.string().describe('The exact request_id of the deployment.'),
|
|
2358
|
+
reason: z.string().min(1).max(255).describe('Why it is reported, 1-255 characters.'),
|
|
2359
|
+
metadata: z.record(z.string(), z.string()).optional().describe('Extra key/value details, e.g. {"match_id": "m-42"}.'),
|
|
2360
|
+
dry_run: dryRunParam,
|
|
2361
|
+
},
|
|
2362
|
+
annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
2363
|
+
}, async ({ request_id, reason, metadata, dry_run }) => guarded(auth, NOT_FOUND.deployment, async () => {
|
|
2364
|
+
const bad = checkRequestId(request_id);
|
|
2365
|
+
if (bad)
|
|
2366
|
+
return bad;
|
|
2367
|
+
const leak = await tokenLeak(auth, dry_run, [
|
|
2368
|
+
['reason', reason],
|
|
2369
|
+
...Object.entries(metadata ?? {}).flatMap(([k, v]) => [[`metadata key "${k.slice(0, 40)}"`, k], [`metadata "${k.slice(0, 40)}"`, v]]),
|
|
2370
|
+
]);
|
|
2371
|
+
if (leak)
|
|
2372
|
+
return leak;
|
|
2373
|
+
const body = { reason, ...(metadata ? { metadata } : {}) };
|
|
2374
|
+
if (dry_run) {
|
|
2375
|
+
const dry = client.dryRun();
|
|
2376
|
+
await dry.client.reportDeployment(request_id, body);
|
|
2377
|
+
return dryRunResult(dry.requests);
|
|
2378
|
+
}
|
|
2379
|
+
await client.reportDeployment(request_id, body);
|
|
2380
|
+
return withMeta(ok({ request_id, reported: true, note: 'The deployment keeps running; stop it separately if needed.' }), {
|
|
2381
|
+
hash: { request_id },
|
|
2382
|
+
});
|
|
2383
|
+
}));
|
|
2384
|
+
tool('edgegap_delete_app_version', {
|
|
2385
|
+
title: 'Delete one application version',
|
|
2386
|
+
description: 'Delete one version of an application, to clean up test versions. Exactly one exact version name; ' +
|
|
2387
|
+
'refused while any deployment of that version is running. The container image stays in the registry ' +
|
|
2388
|
+
'(edgegap_delete_registry_tag removes it). Cannot be undone, so confirm with the developer when the ' +
|
|
2389
|
+
'version is not one this conversation created.',
|
|
2390
|
+
inputSchema: {
|
|
2391
|
+
application: z.string().describe('Application name.'),
|
|
2392
|
+
version: z.string().min(1).describe('The exact version name to delete.'),
|
|
2393
|
+
dry_run: dryRunParam,
|
|
2394
|
+
},
|
|
2395
|
+
annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
2396
|
+
}, async ({ application, version, dry_run }) => guarded(auth, NOT_FOUND.app, async () => {
|
|
2397
|
+
assertAppAllowed(config, application);
|
|
2398
|
+
const badName = exactName(version, 'version');
|
|
2399
|
+
if (badName)
|
|
2400
|
+
return badName;
|
|
2401
|
+
if (dry_run) {
|
|
2402
|
+
const dry = client.dryRun();
|
|
2403
|
+
await dry.client.deleteAppVersion(application, version);
|
|
2404
|
+
return dryRunResult(dry.requests, ['A real call first checks that no deployment of this version is running.']);
|
|
2405
|
+
}
|
|
2406
|
+
const running = await runningOf(application, version);
|
|
2407
|
+
if (running.length)
|
|
2408
|
+
return refusedRunning(`version "${version}"`, running);
|
|
2409
|
+
await client.deleteAppVersion(application, version);
|
|
2410
|
+
return ok({ application, deleted_version: version, image_kept: 'The registry image was not touched.' });
|
|
2411
|
+
}));
|
|
2412
|
+
tool('edgegap_delete_app', {
|
|
2413
|
+
title: 'Delete an application and all its versions',
|
|
2414
|
+
description: 'Delete one application and every version under it, to clean up a test application. Exactly one ' +
|
|
2415
|
+
'exact name; refused while any of its deployments is running, and refused when it has more versions ' +
|
|
2416
|
+
'than max_versions (default 0: delete its versions first with edgegap_delete_app_version, or raise ' +
|
|
2417
|
+
'max_versions after the developer agreed). Registry images are not touched. Cannot be undone.',
|
|
2418
|
+
inputSchema: {
|
|
2419
|
+
application: z.string().min(1).describe('The exact application name to delete.'),
|
|
2420
|
+
max_versions: z
|
|
2421
|
+
.number()
|
|
2422
|
+
.int()
|
|
2423
|
+
.min(0)
|
|
2424
|
+
.optional()
|
|
2425
|
+
.describe('Delete only if it has at most this many versions. Default 0.'),
|
|
2426
|
+
dry_run: dryRunParam,
|
|
2427
|
+
},
|
|
2428
|
+
annotations: { destructiveHint: true, idempotentHint: true, openWorldHint: true },
|
|
2429
|
+
}, async ({ application, max_versions, dry_run }) => guarded(auth, NOT_FOUND.app, async () => {
|
|
2430
|
+
assertAppAllowed(config, application);
|
|
2431
|
+
const badName = exactName(application, 'application');
|
|
2432
|
+
if (badName)
|
|
2433
|
+
return badName;
|
|
2434
|
+
if (dry_run) {
|
|
2435
|
+
const dry = client.dryRun();
|
|
2436
|
+
await dry.client.deleteApp(application);
|
|
2437
|
+
return dryRunResult(dry.requests, ['A real call first checks its versions and running deployments.']);
|
|
2438
|
+
}
|
|
2439
|
+
const versions = ((await client.listAppVersions(application)).versions ?? []).map((v) => v.name);
|
|
2440
|
+
const limit = max_versions ?? 0;
|
|
2441
|
+
if (versions.length > limit) {
|
|
2442
|
+
return fail(`Refused: "${application}" has ${versions.length} version${versions.length === 1 ? '' : 's'} ` +
|
|
2443
|
+
`(${versions.slice(0, 10).join(', ')}${versions.length > 10 ? ', …' : ''}), more than max_versions ` +
|
|
2444
|
+
`(${limit}). Nothing was deleted. Delete them with edgegap_delete_app_version, or pass max_versions ` +
|
|
2445
|
+
`${versions.length} once the developer agreed to delete them all.`);
|
|
2446
|
+
}
|
|
2447
|
+
const running = await runningOf(application);
|
|
2448
|
+
if (running.length)
|
|
2449
|
+
return refusedRunning(`application "${application}"`, running);
|
|
2450
|
+
await client.deleteApp(application);
|
|
2451
|
+
return ok({ deleted_application: application, deleted_versions: versions });
|
|
2452
|
+
}));
|
|
2453
|
+
}
|
|
2454
|
+
/** Request IDs of running deployments of an application (and version). */
|
|
2455
|
+
async function runningOf(application, version) {
|
|
2456
|
+
const filters = [{ field: 'application', operator: 'eq', value: application }];
|
|
2457
|
+
if (version)
|
|
2458
|
+
filters.push({ field: 'version', operator: 'eq', value: version });
|
|
2459
|
+
const res = await client.listDeployments({ query: JSON.stringify({ filters }), limit: 10 });
|
|
2460
|
+
return (res.data ?? []).map((d) => d.request_id).filter(Boolean);
|
|
2461
|
+
}
|
|
2462
|
+
function refusedRunning(what, running) {
|
|
2463
|
+
return fail(`Refused: ${what} still has running deployments (${running.join(', ')}${running.length === 10 ? ', …' : ''}). ` +
|
|
2464
|
+
'Nothing was deleted. Stop them with edgegap_stop_deployment first, if the developer agrees.');
|
|
2465
|
+
}
|
|
2466
|
+
// ============================================ private fleets and storage ====
|
|
2467
|
+
// --------------------------------------------------------------- 13d ----
|
|
2468
|
+
tool('edgegap_list_fleet_hosts', {
|
|
2469
|
+
title: 'List the hosts of a private fleet',
|
|
2470
|
+
description: 'List the hosts in one of the organization\'s private fleets (dedicated machines Edgegap manages for ' +
|
|
2471
|
+
'you), with status, IP and location. Only ACTIVE hosts accept deployments. Pass their host_id values to ' +
|
|
2472
|
+
'edgegap_deploy as private_host_ids to place a server on them first. Organizations without private ' +
|
|
2473
|
+
'fleets get an error from the API.',
|
|
2474
|
+
inputSchema: {
|
|
2475
|
+
fleet_name: z.string().min(1).describe('The private fleet name, as shown in the dashboard.'),
|
|
2476
|
+
},
|
|
2477
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
2478
|
+
}, async ({ fleet_name }) => guard(auth, async () => {
|
|
2479
|
+
const hosts = ((await client.listFleetHosts(fleet_name)).data ?? []).map((h) => ({
|
|
2480
|
+
host_id: h.host_id,
|
|
2481
|
+
status: h.status,
|
|
2482
|
+
ip_address: h.ip_address,
|
|
2483
|
+
city: h.city,
|
|
2484
|
+
country: h.country,
|
|
2485
|
+
continent: h.continent,
|
|
2486
|
+
}));
|
|
2487
|
+
if (hosts.length === 0) {
|
|
2488
|
+
return emptyState('empty', { fleet_name, hosts: [] }, 'This fleet has no hosts yet. Add hosts in the dashboard, or deploy to the cloud without private_host_ids.');
|
|
2489
|
+
}
|
|
2490
|
+
const active = hosts.filter((h) => h.status === 'ACTIVE').length;
|
|
2491
|
+
return ok({ fleet_name, total: hosts.length, active, hosts, next_step: active ? 'Pass ACTIVE host_id values to edgegap_deploy as private_host_ids.' : 'No host is ACTIVE yet; deployments would overflow to the cloud.' });
|
|
2492
|
+
}, `no private fleet named "${fleet_name}" in this organization. Check the name in the dashboard.`));
|
|
2493
|
+
tool('edgegap_list_endpoint_storage', {
|
|
2494
|
+
title: 'List Endpoint Storage and pull profiles',
|
|
2495
|
+
description: 'List the organization\'s Endpoint Storage: S3-compatible buckets Edgegap exports container logs to ' +
|
|
2496
|
+
'when a deployment ends (so logs survive the deployment), and the pull profiles under each, which copy ' +
|
|
2497
|
+
'files from the bucket into a container at boot. Secret keys are never returned. A version uses a storage ' +
|
|
2498
|
+
'for logs through edgegap_create_app_version / edgegap_update_app_version endpoint_storage, and a pull ' +
|
|
2499
|
+
'profile through edgegap_link_pull_profile.',
|
|
2500
|
+
inputSchema: {},
|
|
2501
|
+
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
2502
|
+
}, async () => guard(auth, async () => {
|
|
2503
|
+
const endpoints = (await client.listEndpointStorage()).endpoints ?? [];
|
|
2504
|
+
if (endpoints.length === 0) {
|
|
2505
|
+
return emptyState('not_configured', { endpoints: [] }, 'No Endpoint Storage yet. To keep logs after deployments stop, create one with edgegap_create_endpoint_storage ' +
|
|
2506
|
+
'(the developer supplies the bucket and its access keys), then set endpoint_storage on the version.');
|
|
2507
|
+
}
|
|
2508
|
+
const withProfiles = await Promise.all(endpoints.map(async (e) => ({
|
|
2509
|
+
name: e.name,
|
|
2510
|
+
endpoint: e.endpoint,
|
|
2511
|
+
bucket: e.bucket,
|
|
2512
|
+
access_key_id: e.access_key_id,
|
|
2513
|
+
container_log_version: e.container_log_version,
|
|
2514
|
+
output_format: e.output_format,
|
|
2515
|
+
pull_profiles: await client
|
|
2516
|
+
.listPullProfiles(e.name)
|
|
2517
|
+
.then((r) => (r.pull_profiles ?? []).map((pp) => ({ name: pp.name, source: pp.source, source_type: pp.source_type, destination: pp.destination })))
|
|
2518
|
+
.catch(() => 'could not be listed'),
|
|
2519
|
+
})));
|
|
2520
|
+
return ok({ total: withProfiles.length, endpoints: withProfiles });
|
|
2521
|
+
}));
|
|
2522
|
+
if (mutating) {
|
|
2523
|
+
tool('edgegap_create_endpoint_storage', {
|
|
2524
|
+
title: 'Create an Endpoint Storage (S3 bucket for logs)',
|
|
2525
|
+
description: 'Register an S3-compatible bucket (AWS S3, Cloudflare R2, DigitalOcean Spaces, ...) as Endpoint Storage, ' +
|
|
2526
|
+
'so container logs are exported there when deployments end. The developer supplies the bucket, endpoint ' +
|
|
2527
|
+
'URL and an access key pair scoped to that bucket; never invent or reuse other credentials, and never pass ' +
|
|
2528
|
+
'the Edgegap API token. The secret key is sent once and never echoed back. Then set endpoint_storage on the ' +
|
|
2529
|
+
'version (edgegap_update_app_version) to turn log export on.',
|
|
2530
|
+
inputSchema: {
|
|
2531
|
+
name: z.string().min(1).describe('Name for this storage, e.g. "game-logs".'),
|
|
2532
|
+
endpoint: z.string().describe('https URL of the S3 endpoint, without the bucket, e.g. "https://s3.us-east-1.amazonaws.com".'),
|
|
2533
|
+
bucket: z.string().min(1).describe('Bucket name.'),
|
|
2534
|
+
access_key_id: z.string().min(1).describe('Access key ID for the bucket.'),
|
|
2535
|
+
secret_access_key: z.string().min(1).describe('Secret access key for the bucket. Never echoed back.'),
|
|
2536
|
+
output_format: z.enum(['TEXT', 'NDJSON']).optional().describe('Log file format. Default TEXT.'),
|
|
2537
|
+
container_log_version: z
|
|
2538
|
+
.enum(['v1', 'v2'])
|
|
2539
|
+
.optional()
|
|
2540
|
+
.describe('v1 (default) writes one file per deployment; v2 streams chunks while it runs.'),
|
|
2541
|
+
dry_run: dryRunParam,
|
|
2542
|
+
},
|
|
2543
|
+
annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
2544
|
+
}, async (args) => guard(auth, async () => {
|
|
2545
|
+
const leak = await tokenLeak(auth, args.dry_run, [
|
|
2546
|
+
['access_key_id', args.access_key_id],
|
|
2547
|
+
['secret_access_key', args.secret_access_key],
|
|
2548
|
+
['endpoint', args.endpoint],
|
|
2549
|
+
]);
|
|
2550
|
+
if (leak)
|
|
2551
|
+
return leak;
|
|
2552
|
+
const problem = webhookProblem(args.endpoint);
|
|
2553
|
+
if (problem)
|
|
2554
|
+
return fail(`endpoint ${problem.replace('Edgegap sends deployment details (IP, ports) to it', 'the bucket keys travel to it')}`);
|
|
2555
|
+
const body = {
|
|
2556
|
+
name: args.name,
|
|
2557
|
+
endpoint: args.endpoint,
|
|
2558
|
+
bucket: args.bucket,
|
|
2559
|
+
access_key_id: args.access_key_id,
|
|
2560
|
+
secret_access_key: args.secret_access_key,
|
|
2561
|
+
...(args.output_format ? { output_format: args.output_format } : {}),
|
|
2562
|
+
...(args.container_log_version ? { container_log_version: args.container_log_version } : {}),
|
|
2563
|
+
};
|
|
2564
|
+
if (args.dry_run) {
|
|
2565
|
+
const dry = client.dryRun();
|
|
2566
|
+
await dry.client.createEndpointStorage(body);
|
|
2567
|
+
return dryRunResult(dry.requests);
|
|
2568
|
+
}
|
|
2569
|
+
const res = await client.createEndpointStorage(body);
|
|
2570
|
+
return ok({
|
|
2571
|
+
name: res.name ?? args.name,
|
|
2572
|
+
bucket: res.bucket ?? args.bucket,
|
|
2573
|
+
output_format: res.output_format,
|
|
2574
|
+
container_log_version: res.container_log_version,
|
|
2575
|
+
next_step: `Turn on log export with edgegap_update_app_version endpoint_storage: "${res.name ?? args.name}".`,
|
|
2576
|
+
});
|
|
2577
|
+
}));
|
|
2578
|
+
tool('edgegap_create_pull_profile', {
|
|
2579
|
+
title: 'Create a pull profile (copy bucket files into containers)',
|
|
2580
|
+
description: 'Create a pull profile under an Endpoint Storage: at boot, Edgegap copies a file or folder from the ' +
|
|
2581
|
+
'bucket into the container (maps, configs, large assets kept out of the image). It does nothing until ' +
|
|
2582
|
+
'linked to a version with edgegap_link_pull_profile. Avoid destination paths the image already uses.',
|
|
2583
|
+
inputSchema: {
|
|
2584
|
+
endpoint_storage: z.string().min(1).describe('Endpoint Storage name, from edgegap_list_endpoint_storage.'),
|
|
2585
|
+
name: z.string().min(1).describe('Name for the profile, e.g. "maps".'),
|
|
2586
|
+
source: z.string().min(1).describe('Path in the bucket, e.g. "maps/" or "config/server.json".'),
|
|
2587
|
+
source_type: z.enum(['File', 'Folder']).describe('Whether source is a file or a folder.'),
|
|
2588
|
+
destination: z.string().min(1).describe('Absolute path in the container, e.g. "/data/maps".'),
|
|
2589
|
+
dry_run: dryRunParam,
|
|
2590
|
+
},
|
|
2591
|
+
annotations: { destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
2592
|
+
}, async (args) => guard(auth, async () => {
|
|
2593
|
+
if (!args.destination.startsWith('/'))
|
|
2594
|
+
return fail('destination must be an absolute container path, e.g. "/data/maps".');
|
|
2595
|
+
const body = { name: args.name, source: args.source, source_type: args.source_type, destination: args.destination };
|
|
2596
|
+
if (args.dry_run) {
|
|
2597
|
+
const dry = client.dryRun();
|
|
2598
|
+
await dry.client.createPullProfile(args.endpoint_storage, body);
|
|
2599
|
+
return dryRunResult(dry.requests);
|
|
2600
|
+
}
|
|
2601
|
+
const res = await client.createPullProfile(args.endpoint_storage, body);
|
|
2602
|
+
return ok({
|
|
2603
|
+
endpoint_storage: args.endpoint_storage,
|
|
2604
|
+
pull_profile: res.name ?? args.name,
|
|
2605
|
+
next_step: 'Link it to a version with edgegap_link_pull_profile; new deployments of that version get the files.',
|
|
2606
|
+
});
|
|
2607
|
+
}, `no Endpoint Storage named "${args.endpoint_storage}". List them with edgegap_list_endpoint_storage.`));
|
|
2608
|
+
tool('edgegap_link_pull_profile', {
|
|
2609
|
+
title: 'Link or unlink a pull profile and a version',
|
|
2610
|
+
description: 'Link a pull profile to an application version, so its new deployments get the bucket files at boot, or ' +
|
|
2611
|
+
'unlink it (unlink: true). Running deployments are not changed.',
|
|
2612
|
+
inputSchema: {
|
|
2613
|
+
endpoint_storage: z.string().min(1).describe('Endpoint Storage name.'),
|
|
2614
|
+
pull_profile: z.string().min(1).describe('Pull profile name.'),
|
|
2615
|
+
application: z.string().describe('Application name.'),
|
|
2616
|
+
version: z.string().describe('Version name.'),
|
|
2617
|
+
unlink: z.boolean().optional().describe('true removes the link instead.'),
|
|
2618
|
+
dry_run: dryRunParam,
|
|
2619
|
+
},
|
|
2620
|
+
annotations: { destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
2621
|
+
}, async (args) => guard(auth, async () => {
|
|
2622
|
+
assertAppAllowed(config, args.application);
|
|
2623
|
+
const method = args.unlink ? 'DELETE' : 'PUT';
|
|
2624
|
+
if (args.dry_run) {
|
|
2625
|
+
const dry = client.dryRun();
|
|
2626
|
+
await dry.client.linkPullProfile(method, args.endpoint_storage, args.pull_profile, args.application, args.version);
|
|
2627
|
+
return dryRunResult(dry.requests);
|
|
2628
|
+
}
|
|
2629
|
+
await client.linkPullProfile(method, args.endpoint_storage, args.pull_profile, args.application, args.version);
|
|
2630
|
+
return ok({
|
|
2631
|
+
endpoint_storage: args.endpoint_storage,
|
|
2632
|
+
pull_profile: args.pull_profile,
|
|
2633
|
+
application: args.application,
|
|
2634
|
+
version: args.version,
|
|
2635
|
+
linked: !args.unlink,
|
|
2636
|
+
});
|
|
2637
|
+
}, 'the Endpoint Storage, pull profile, application or version does not exist. Check them with edgegap_list_endpoint_storage and edgegap_list_app_versions.'));
|
|
2638
|
+
}
|
|
2121
2639
|
// ================================================== peer-to-peer relays ====
|
|
2122
2640
|
// --------------------------------------------------------------- 14 ----
|
|
2123
2641
|
if (mutating) {
|
|
@@ -2519,9 +3037,10 @@ function registerSkills(server, tool, config, options) {
|
|
|
2519
3037
|
'metadata.version from its SKILL.md frontmatter) and it compares them with the latest on GitHub and says how to update. '
|
|
2520
3038
|
: 'Finds installs made with the skills CLI (user-wide or this project), the Claude Code plugin edgegap@edgegap, and skills ' +
|
|
2521
3039
|
'copied by hand into an agent\'s skills folder, and compares each skill with the latest on GitHub. Without apply it only ' +
|
|
2522
|
-
'checks and changes nothing. With apply=true it
|
|
2523
|
-
'
|
|
2524
|
-
'
|
|
3040
|
+
'checks and changes nothing. With apply=true it rewrites hand-copied skills from the files bundled in this server, and ' +
|
|
3041
|
+
'runs each outdated install\'s own updater (npx ' + SKILLS_CLI + ' update for the Edgegap skills only, or claude plugin ' +
|
|
3042
|
+
'update) only when the operator started the server with EDGEGAP_ENABLE_SKILLS_UPDATE=1; otherwise it lists those ' +
|
|
3043
|
+
'commands for the developer to run. Ask the developer before applying. ') +
|
|
2525
3044
|
'Skill text is never downloaded by this tool. The skills served by edgegap_get_skill need no update here.',
|
|
2526
3045
|
inputSchema: {
|
|
2527
3046
|
...(local
|
|
@@ -2622,7 +3141,11 @@ function registerSkills(server, tool, config, options) {
|
|
|
2622
3141
|
const applied = [];
|
|
2623
3142
|
let failed = false;
|
|
2624
3143
|
for (const p of plan) {
|
|
2625
|
-
if (p.commands) {
|
|
3144
|
+
if (p.commands && !config.enableSkillsUpdate) {
|
|
3145
|
+
applied.push(`not run (EDGEGAP_ENABLE_SKILLS_UPDATE is not set, so this server starts no updater): ${p.action}. ` +
|
|
3146
|
+
'The developer can run it in a terminal.');
|
|
3147
|
+
}
|
|
3148
|
+
else if (p.commands) {
|
|
2626
3149
|
for (const cmd of p.commands) {
|
|
2627
3150
|
try {
|
|
2628
3151
|
const out = await local.env.run(cmd[0], cmd.slice(1), local.env.cwd);
|