@structured-world/gitlab-mcp 7.5.0 → 7.6.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 +4 -4
- package/dist/src/entities/context/types.d.ts +2 -1
- package/dist/src/entities/context/whoami.js +20 -4
- package/dist/src/entities/context/whoami.js.map +1 -1
- package/dist/src/entities/core/registry.js +29 -3
- package/dist/src/entities/core/registry.js.map +1 -1
- package/dist/src/entities/core/schema-readonly.d.ts +1 -0
- package/dist/src/entities/core/schema-readonly.js +4 -0
- package/dist/src/entities/core/schema-readonly.js.map +1 -1
- package/dist/src/entities/core/schema.d.ts +3 -0
- package/dist/src/entities/core/schema.js +7 -0
- package/dist/src/entities/core/schema.js.map +1 -1
- package/dist/src/entities/environments/registry.d.ts +3 -0
- package/dist/src/entities/environments/registry.js +151 -0
- package/dist/src/entities/environments/registry.js.map +1 -0
- package/dist/src/entities/environments/schema-readonly.d.ts +50 -0
- package/dist/src/entities/environments/schema-readonly.js +72 -0
- package/dist/src/entities/environments/schema-readonly.js.map +1 -0
- package/dist/src/entities/environments/schema.d.ts +48 -0
- package/dist/src/entities/environments/schema.js +78 -0
- package/dist/src/entities/environments/schema.js.map +1 -0
- package/dist/src/registry-manager.d.ts +1 -0
- package/dist/src/registry-manager.js +34 -7
- package/dist/src/registry-manager.js.map +1 -1
- package/dist/src/services/InstanceCapabilities.d.ts +1 -1
- package/dist/src/services/InstanceCapabilities.js +9 -9
- package/dist/src/services/InstanceCapabilities.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +16 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.environmentsToolRegistry = void 0;
|
|
37
|
+
exports.getEnvironmentsReadOnlyToolNames = getEnvironmentsReadOnlyToolNames;
|
|
38
|
+
const z = __importStar(require("zod"));
|
|
39
|
+
const schema_readonly_1 = require("./schema-readonly");
|
|
40
|
+
const schema_1 = require("./schema");
|
|
41
|
+
const gitlab_api_1 = require("../../utils/gitlab-api");
|
|
42
|
+
const utils_1 = require("../utils");
|
|
43
|
+
exports.environmentsToolRegistry = new Map([
|
|
44
|
+
[
|
|
45
|
+
'browse_environments',
|
|
46
|
+
{
|
|
47
|
+
name: 'browse_environments',
|
|
48
|
+
description: 'Inspect project environments and their deployments. Actions: list (environments filtered by state/name), get (single environment with its last deployment), list_deployments (deployment history, filterable by environment and status). Related: manage_environment to create, update, stop, or delete environments and update deployment status.',
|
|
49
|
+
inputSchema: z.toJSONSchema(schema_readonly_1.BrowseEnvironmentsSchema),
|
|
50
|
+
requirements: { default: { tier: 'free', minVersion: '8.0' } },
|
|
51
|
+
gate: { envVar: 'USE_ENVIRONMENTS', defaultValue: true },
|
|
52
|
+
handler: async (args) => {
|
|
53
|
+
const input = schema_readonly_1.BrowseEnvironmentsSchema.parse(args);
|
|
54
|
+
(0, utils_1.assertActionAllowed)('browse_environments', input.action);
|
|
55
|
+
const encodedProjectId = encodeURIComponent(input.project_id);
|
|
56
|
+
switch (input.action) {
|
|
57
|
+
case 'list': {
|
|
58
|
+
const { action: _action, project_id: _projectId, ...queryOptions } = input;
|
|
59
|
+
return gitlab_api_1.gitlab.get(`projects/${encodedProjectId}/environments`, {
|
|
60
|
+
query: (0, gitlab_api_1.toQuery)(queryOptions, []),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
case 'get': {
|
|
64
|
+
return gitlab_api_1.gitlab.get(`projects/${encodedProjectId}/environments/${input.environment_id}`);
|
|
65
|
+
}
|
|
66
|
+
case 'list_deployments': {
|
|
67
|
+
const { action: _action, project_id: _projectId, ...queryOptions } = input;
|
|
68
|
+
return gitlab_api_1.gitlab.get(`projects/${encodedProjectId}/deployments`, {
|
|
69
|
+
query: (0, gitlab_api_1.toQuery)(queryOptions, []),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
throw new Error(`Unknown action: ${input.action}`);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'manage_environment',
|
|
80
|
+
{
|
|
81
|
+
name: 'manage_environment',
|
|
82
|
+
description: 'Create and control project environments and deployment status. Actions: create (new environment), update (external_url/tier/description), stop (required before delete), delete (stopped environment), update_deployment_status (set a non-pipeline deployment to running/success/failed/canceled). Related: browse_environments to list and inspect.',
|
|
83
|
+
inputSchema: z.toJSONSchema(schema_1.ManageEnvironmentSchema),
|
|
84
|
+
requirements: { default: { tier: 'free', minVersion: '8.0' } },
|
|
85
|
+
gate: { envVar: 'USE_ENVIRONMENTS', defaultValue: true },
|
|
86
|
+
handler: async (args) => {
|
|
87
|
+
const input = schema_1.ManageEnvironmentSchema.parse(args);
|
|
88
|
+
(0, utils_1.assertActionAllowed)('manage_environment', input.action);
|
|
89
|
+
const encodedProjectId = encodeURIComponent(input.project_id);
|
|
90
|
+
switch (input.action) {
|
|
91
|
+
case 'create': {
|
|
92
|
+
const { name, external_url, tier, description } = input;
|
|
93
|
+
const body = { name };
|
|
94
|
+
if (external_url !== undefined)
|
|
95
|
+
body.external_url = external_url;
|
|
96
|
+
if (tier !== undefined)
|
|
97
|
+
body.tier = tier;
|
|
98
|
+
if (description !== undefined)
|
|
99
|
+
body.description = description;
|
|
100
|
+
return gitlab_api_1.gitlab.post(`projects/${encodedProjectId}/environments`, {
|
|
101
|
+
body,
|
|
102
|
+
contentType: 'json',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
case 'update': {
|
|
106
|
+
const { environment_id, external_url, tier, description } = input;
|
|
107
|
+
const body = {};
|
|
108
|
+
if (external_url !== undefined)
|
|
109
|
+
body.external_url = external_url;
|
|
110
|
+
if (tier !== undefined)
|
|
111
|
+
body.tier = tier;
|
|
112
|
+
if (description !== undefined)
|
|
113
|
+
body.description = description;
|
|
114
|
+
return gitlab_api_1.gitlab.put(`projects/${encodedProjectId}/environments/${environment_id}`, {
|
|
115
|
+
body,
|
|
116
|
+
contentType: 'json',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
case 'stop': {
|
|
120
|
+
const { environment_id, force } = input;
|
|
121
|
+
const body = {};
|
|
122
|
+
if (force !== undefined)
|
|
123
|
+
body.force = force;
|
|
124
|
+
return gitlab_api_1.gitlab.post(`projects/${encodedProjectId}/environments/${environment_id}/stop`, {
|
|
125
|
+
body,
|
|
126
|
+
contentType: 'json',
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
case 'delete': {
|
|
130
|
+
const { environment_id } = input;
|
|
131
|
+
await gitlab_api_1.gitlab.delete(`projects/${encodedProjectId}/environments/${environment_id}`);
|
|
132
|
+
return { deleted: true, environment_id };
|
|
133
|
+
}
|
|
134
|
+
case 'update_deployment_status': {
|
|
135
|
+
const { deployment_id, status } = input;
|
|
136
|
+
return gitlab_api_1.gitlab.put(`projects/${encodedProjectId}/deployments/${deployment_id}`, {
|
|
137
|
+
body: { status },
|
|
138
|
+
contentType: 'json',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
default:
|
|
142
|
+
throw new Error(`Unknown action: ${input.action}`);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
]);
|
|
148
|
+
function getEnvironmentsReadOnlyToolNames() {
|
|
149
|
+
return ['browse_environments'];
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/entities/environments/registry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmJA,4EAEC;AArJD,uCAAyB;AACzB,uDAA6D;AAC7D,qCAAmD;AACnD,uDAAyD;AAEzD,oCAA+C;AAYlC,QAAA,wBAAwB,GAAiB,IAAI,GAAG,CAAiC;IAI5F;QACE,qBAAqB;QACrB;YACE,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EACT,oVAAoV;YACtV,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,0CAAwB,CAAC;YACrD,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,E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wBACxC,OAAO,mBAAM,CAAC,GAAG,CAAC,YAAY,gBAAgB,gBAAgB,aAAa,EAAE,EAAE;4BAC7E,IAAI,EAAE,EAAE,MAAM,EAAE;4BAChB,WAAW,EAAE,MAAM;yBACpB,CAAC,CAAC;oBACL,CAAC;oBAGD;wBACE,MAAM,IAAI,KAAK,CAAC,mBAAoB,KAA4B,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC/E,CAAC;YACH,CAAC;SACF;KACF;CACF,CAAC,CAAC;AAKH,SAAgB,gCAAgC;IAC9C,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const BrowseEnvironmentsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
4
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
action: z.ZodLiteral<"list">;
|
|
6
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
7
|
+
name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
search: z.ZodOptional<z.ZodString>;
|
|
9
|
+
states: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
stopped: "stopped";
|
|
11
|
+
available: "available";
|
|
12
|
+
stopping: "stopping";
|
|
13
|
+
}>>;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
action: z.ZodLiteral<"get">;
|
|
16
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
17
|
+
environment_id: z.ZodCoercedNumber<unknown>;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
+
per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
20
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
action: z.ZodLiteral<"list_deployments">;
|
|
22
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
23
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
24
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
success: "success";
|
|
26
|
+
failed: "failed";
|
|
27
|
+
running: "running";
|
|
28
|
+
created: "created";
|
|
29
|
+
blocked: "blocked";
|
|
30
|
+
canceled: "canceled";
|
|
31
|
+
skipped: "skipped";
|
|
32
|
+
}>>;
|
|
33
|
+
order_by: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
id: "id";
|
|
35
|
+
created_at: "created_at";
|
|
36
|
+
updated_at: "updated_at";
|
|
37
|
+
iid: "iid";
|
|
38
|
+
ref: "ref";
|
|
39
|
+
finished_at: "finished_at";
|
|
40
|
+
}>>;
|
|
41
|
+
sort: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
asc: "asc";
|
|
43
|
+
desc: "desc";
|
|
44
|
+
}>>;
|
|
45
|
+
updated_after: z.ZodOptional<z.ZodString>;
|
|
46
|
+
updated_before: z.ZodOptional<z.ZodString>;
|
|
47
|
+
finished_after: z.ZodOptional<z.ZodString>;
|
|
48
|
+
finished_before: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>], "action">;
|
|
50
|
+
export type BrowseEnvironmentsInput = z.infer<typeof BrowseEnvironmentsSchema>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowseEnvironmentsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const projectIdField = utils_1.requiredId.describe("Project ID or URL-encoded path (e.g., 'my-group/my-project')");
|
|
7
|
+
const environmentIdField = zod_1.z.coerce
|
|
8
|
+
.number()
|
|
9
|
+
.int()
|
|
10
|
+
.positive()
|
|
11
|
+
.describe('Numeric ID of the environment');
|
|
12
|
+
const ListEnvironmentsSchema = zod_1.z.object({
|
|
13
|
+
action: zod_1.z.literal('list').describe('List environments for a project'),
|
|
14
|
+
project_id: projectIdField,
|
|
15
|
+
name: zod_1.z.string().optional().describe('Return the environment with this exact name'),
|
|
16
|
+
search: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.min(3)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Return environments matching this search term (min 3 characters)'),
|
|
21
|
+
states: zod_1.z
|
|
22
|
+
.enum(['available', 'stopping', 'stopped'])
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Filter environments by state'),
|
|
25
|
+
...(0, utils_1.paginationFields)(),
|
|
26
|
+
});
|
|
27
|
+
const GetEnvironmentSchema = zod_1.z.object({
|
|
28
|
+
action: zod_1.z
|
|
29
|
+
.literal('get')
|
|
30
|
+
.describe('Get a single environment by ID, including its last deployment'),
|
|
31
|
+
project_id: projectIdField,
|
|
32
|
+
environment_id: environmentIdField,
|
|
33
|
+
});
|
|
34
|
+
const ListDeploymentsSchema = zod_1.z.object({
|
|
35
|
+
action: zod_1.z
|
|
36
|
+
.literal('list_deployments')
|
|
37
|
+
.describe('List deployments for a project, optionally filtered by environment'),
|
|
38
|
+
project_id: projectIdField,
|
|
39
|
+
environment: zod_1.z.string().optional().describe('Filter deployments by environment name'),
|
|
40
|
+
status: zod_1.z
|
|
41
|
+
.enum(['created', 'running', 'success', 'failed', 'canceled', 'skipped', 'blocked'])
|
|
42
|
+
.optional()
|
|
43
|
+
.describe('Filter deployments by status'),
|
|
44
|
+
order_by: zod_1.z
|
|
45
|
+
.enum(['id', 'iid', 'created_at', 'updated_at', 'finished_at', 'ref'])
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('Order deployments by field (default: id)'),
|
|
48
|
+
sort: zod_1.z.enum(['asc', 'desc']).optional().describe('Sort direction (default: asc)'),
|
|
49
|
+
updated_after: zod_1.z
|
|
50
|
+
.string()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe('Return deployments updated after this ISO 8601 date'),
|
|
53
|
+
updated_before: zod_1.z
|
|
54
|
+
.string()
|
|
55
|
+
.optional()
|
|
56
|
+
.describe('Return deployments updated before this ISO 8601 date'),
|
|
57
|
+
finished_after: zod_1.z
|
|
58
|
+
.string()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Return deployments finished after this ISO 8601 date (requires order_by=finished_at)'),
|
|
61
|
+
finished_before: zod_1.z
|
|
62
|
+
.string()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe('Return deployments finished before this ISO 8601 date (requires order_by=finished_at)'),
|
|
65
|
+
...(0, utils_1.paginationFields)(),
|
|
66
|
+
});
|
|
67
|
+
exports.BrowseEnvironmentsSchema = zod_1.z.discriminatedUnion('action', [
|
|
68
|
+
ListEnvironmentsSchema,
|
|
69
|
+
GetEnvironmentSchema,
|
|
70
|
+
ListDeploymentsSchema,
|
|
71
|
+
]);
|
|
72
|
+
//# sourceMappingURL=schema-readonly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-readonly.js","sourceRoot":"","sources":["../../../../src/entities/environments/schema-readonly.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,oCAAwD;AAUxD,MAAM,cAAc,GAAG,kBAAU,CAAC,QAAQ,CACxC,8DAA8D,CAC/D,CAAC;AACF,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM;KAChC,MAAM,EAAE;KACR,GAAG,EAAE;KACL,QAAQ,EAAE;KACV,QAAQ,CAAC,+BAA+B,CAAC,CAAC;AAG7C,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IACrE,UAAU,EAAE,cAAc;IAC1B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IACnF,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,GAAG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;IAClF,aAAa,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,qDAAqD,CAAC;IAClE,cAAc,EAAE,OAAC;SACd,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,sDAAsD,CAAC;IACnE,cAAc,EAAE,OAAC;SACd,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,sFAAsF,CACvF;IACH,eAAe,EAAE,OAAC;SACf,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,uFAAuF,CACxF;IACH,GAAG,IAAA,wBAAgB,GAAE;CACtB,CAAC,CAAC;AAGU,QAAA,wBAAwB,GAAG,OAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE;IACrE,sBAAsB;IACtB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ManageEnvironmentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
action: z.ZodLiteral<"create">;
|
|
4
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
external_url: z.ZodOptional<z.ZodString>;
|
|
7
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
other: "other";
|
|
9
|
+
production: "production";
|
|
10
|
+
staging: "staging";
|
|
11
|
+
testing: "testing";
|
|
12
|
+
development: "development";
|
|
13
|
+
}>>;
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
action: z.ZodLiteral<"update">;
|
|
17
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
18
|
+
environment_id: z.ZodCoercedNumber<unknown>;
|
|
19
|
+
external_url: z.ZodOptional<z.ZodString>;
|
|
20
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
other: "other";
|
|
22
|
+
production: "production";
|
|
23
|
+
staging: "staging";
|
|
24
|
+
testing: "testing";
|
|
25
|
+
development: "development";
|
|
26
|
+
}>>;
|
|
27
|
+
description: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
29
|
+
action: z.ZodLiteral<"stop">;
|
|
30
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
31
|
+
environment_id: z.ZodCoercedNumber<unknown>;
|
|
32
|
+
force: z.ZodOptional<z.ZodPreprocess<z.ZodBoolean>>;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
action: z.ZodLiteral<"delete">;
|
|
35
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
36
|
+
environment_id: z.ZodCoercedNumber<unknown>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
action: z.ZodLiteral<"update_deployment_status">;
|
|
39
|
+
project_id: z.ZodPreprocess<z.ZodCoercedString<unknown>>;
|
|
40
|
+
deployment_id: z.ZodCoercedNumber<unknown>;
|
|
41
|
+
status: z.ZodEnum<{
|
|
42
|
+
success: "success";
|
|
43
|
+
failed: "failed";
|
|
44
|
+
running: "running";
|
|
45
|
+
canceled: "canceled";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strip>], "action">;
|
|
48
|
+
export type ManageEnvironmentInput = z.infer<typeof ManageEnvironmentSchema>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManageEnvironmentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const projectIdField = utils_1.requiredId.describe("Project ID or URL-encoded path (e.g., 'my-group/my-project')");
|
|
7
|
+
const environmentIdField = zod_1.z.coerce
|
|
8
|
+
.number()
|
|
9
|
+
.int()
|
|
10
|
+
.positive()
|
|
11
|
+
.describe('Numeric ID of the environment');
|
|
12
|
+
const tierField = zod_1.z
|
|
13
|
+
.enum(['production', 'staging', 'testing', 'development', 'other'])
|
|
14
|
+
.describe('Deployment tier of the environment');
|
|
15
|
+
const externalUrlField = zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.url()
|
|
18
|
+
.describe('URL where the deployed environment can be reached (e.g., https://staging.example.com)');
|
|
19
|
+
const descriptionField = zod_1.z.string().describe('Description of the environment');
|
|
20
|
+
const CreateEnvironmentSchema = zod_1.z.object({
|
|
21
|
+
action: zod_1.z.literal('create').describe('Create a new environment'),
|
|
22
|
+
project_id: projectIdField,
|
|
23
|
+
name: zod_1.z.string().describe('Name of the environment'),
|
|
24
|
+
external_url: externalUrlField.optional(),
|
|
25
|
+
tier: tierField.optional(),
|
|
26
|
+
description: descriptionField.optional(),
|
|
27
|
+
});
|
|
28
|
+
const UpdateEnvironmentSchema = zod_1.z.object({
|
|
29
|
+
action: zod_1.z
|
|
30
|
+
.literal('update')
|
|
31
|
+
.describe('Update an existing environment (name cannot be changed via the API)'),
|
|
32
|
+
project_id: projectIdField,
|
|
33
|
+
environment_id: environmentIdField,
|
|
34
|
+
external_url: externalUrlField.optional(),
|
|
35
|
+
tier: tierField.optional(),
|
|
36
|
+
description: descriptionField.optional(),
|
|
37
|
+
});
|
|
38
|
+
const StopEnvironmentSchema = zod_1.z.object({
|
|
39
|
+
action: zod_1.z.literal('stop').describe('Stop an environment (required before it can be deleted)'),
|
|
40
|
+
project_id: projectIdField,
|
|
41
|
+
environment_id: environmentIdField,
|
|
42
|
+
force: utils_1.flexibleBoolean
|
|
43
|
+
.optional()
|
|
44
|
+
.describe('Force the stop, skipping the on_stop action if one is defined'),
|
|
45
|
+
});
|
|
46
|
+
const DeleteEnvironmentSchema = zod_1.z.object({
|
|
47
|
+
action: zod_1.z.literal('delete').describe('Delete a stopped environment'),
|
|
48
|
+
project_id: projectIdField,
|
|
49
|
+
environment_id: environmentIdField,
|
|
50
|
+
});
|
|
51
|
+
const UpdateDeploymentStatusSchema = zod_1.z.object({
|
|
52
|
+
action: zod_1.z
|
|
53
|
+
.literal('update_deployment_status')
|
|
54
|
+
.describe('Update the status of a deployment. Only deployments not tied to a pipeline job can be updated.'),
|
|
55
|
+
project_id: projectIdField,
|
|
56
|
+
deployment_id: zod_1.z.coerce
|
|
57
|
+
.number()
|
|
58
|
+
.int()
|
|
59
|
+
.positive()
|
|
60
|
+
.describe('Numeric ID of the deployment to update'),
|
|
61
|
+
status: zod_1.z.enum(['running', 'success', 'failed', 'canceled']).describe('New deployment status'),
|
|
62
|
+
});
|
|
63
|
+
exports.ManageEnvironmentSchema = zod_1.z
|
|
64
|
+
.discriminatedUnion('action', [
|
|
65
|
+
CreateEnvironmentSchema,
|
|
66
|
+
UpdateEnvironmentSchema,
|
|
67
|
+
StopEnvironmentSchema,
|
|
68
|
+
DeleteEnvironmentSchema,
|
|
69
|
+
UpdateDeploymentStatusSchema,
|
|
70
|
+
])
|
|
71
|
+
.refine((data) => data.action !== 'update' ||
|
|
72
|
+
data.external_url !== undefined ||
|
|
73
|
+
data.tier !== undefined ||
|
|
74
|
+
data.description !== undefined, {
|
|
75
|
+
message: 'update requires at least one of: external_url, tier, description',
|
|
76
|
+
path: ['external_url'],
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/entities/environments/schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,oCAAuD;AAWvD,MAAM,cAAc,GAAG,kBAAU,CAAC,QAAQ,CACxC,8DAA8D,CAC/D,CAAC;AACF,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM;KAChC,MAAM,EAAE;KACR,GAAG,EAAE;KACL,QAAQ,EAAE;KACV,QAAQ,CAAC,+BAA+B,CAAC,CAAC;AAC7C,M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,6 +21,7 @@ const registry_17 = require("./entities/context/registry");
|
|
|
21
21
|
const registry_18 = require("./entities/iterations/registry");
|
|
22
22
|
const registry_19 = require("./entities/job-token-scope/registry");
|
|
23
23
|
const registry_20 = require("./entities/deploy-keys/registry");
|
|
24
|
+
const registry_21 = require("./entities/environments/registry");
|
|
24
25
|
const config_1 = require("./config");
|
|
25
26
|
const InstanceCapabilities_1 = require("./services/InstanceCapabilities");
|
|
26
27
|
const ConnectionManager_1 = require("./services/ConnectionManager");
|
|
@@ -107,6 +108,9 @@ class RegistryManager {
|
|
|
107
108
|
this.registries.set('job-token-scope', registry_19.jobTokenScopeToolRegistry);
|
|
108
109
|
this.registries.set('deploy-keys', registry_20.deployKeysToolRegistry);
|
|
109
110
|
}
|
|
111
|
+
if (config_1.USE_ENVIRONMENTS) {
|
|
112
|
+
this.registries.set('environments', registry_21.environmentsToolRegistry);
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
loadDescriptionOverrides() {
|
|
112
116
|
this.descriptionOverrides = (0, config_1.getToolDescriptionOverrides)();
|
|
@@ -173,6 +177,9 @@ class RegistryManager {
|
|
|
173
177
|
readOnlyTools.push(...(0, registry_19.getJobTokenScopeReadOnlyToolNames)());
|
|
174
178
|
readOnlyTools.push(...(0, registry_20.getDeployKeysReadOnlyToolNames)());
|
|
175
179
|
}
|
|
180
|
+
if (config_1.USE_ENVIRONMENTS) {
|
|
181
|
+
readOnlyTools.push(...(0, registry_21.getEnvironmentsReadOnlyToolNames)());
|
|
182
|
+
}
|
|
176
183
|
return readOnlyTools;
|
|
177
184
|
}
|
|
178
185
|
getReadOnlyTools() {
|
|
@@ -189,6 +196,16 @@ class RegistryManager {
|
|
|
189
196
|
if (!isExpectedInitError(err))
|
|
190
197
|
throw err;
|
|
191
198
|
}
|
|
199
|
+
if (instanceInfo) {
|
|
200
|
+
try {
|
|
201
|
+
instanceInfo.adminModeActive =
|
|
202
|
+
ConnectionManager_1.ConnectionManager.getInstance().getAdminInfo(instanceUrl)?.adminModeActive;
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
if (!isExpectedInitError(err))
|
|
206
|
+
throw err;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
192
209
|
let tokenScopes;
|
|
193
210
|
try {
|
|
194
211
|
const scopeInfo = ConnectionManager_1.ConnectionManager.getInstance().getTokenScopeInfo(instanceUrl);
|
|
@@ -210,11 +227,12 @@ class RegistryManager {
|
|
|
210
227
|
if (ctx.tokenScopes && !(0, TokenScopeDetector_1.isToolAvailableForScopes)(toolName, ctx.tokenScopes))
|
|
211
228
|
return 'scopes';
|
|
212
229
|
const isContextTool = this.registries.get('context')?.has(toolName) ?? false;
|
|
213
|
-
if (!isContextTool &&
|
|
214
|
-
ctx.instanceInfo
|
|
215
|
-
|
|
216
|
-
!(0, InstanceCapabilities_1.isToolAvailable)(tool.requirements, ctx.instanceInfo))
|
|
217
|
-
|
|
230
|
+
if (!isContextTool && ctx.instanceInfo) {
|
|
231
|
+
if (tool.requirements?.default.requiresAdmin && ctx.instanceInfo.adminModeActive === false)
|
|
232
|
+
return 'admin';
|
|
233
|
+
if (!(0, InstanceCapabilities_1.isToolAvailable)(tool.requirements, ctx.instanceInfo))
|
|
234
|
+
return 'tier';
|
|
235
|
+
}
|
|
218
236
|
const allActions = (0, schema_utils_1.extractActionsFromSchema)(tool.inputSchema);
|
|
219
237
|
if (allActions.length > 0 && (0, schema_utils_1.shouldRemoveTool)(toolName, allActions))
|
|
220
238
|
return 'actionDenial';
|
|
@@ -230,7 +248,7 @@ class RegistryManager {
|
|
|
230
248
|
continue;
|
|
231
249
|
}
|
|
232
250
|
let transformedSchema = (0, schema_utils_1.transformToolSchema)(toolName, tool.inputSchema);
|
|
233
|
-
if (ctx.instanceInfo
|
|
251
|
+
if (ctx.instanceInfo) {
|
|
234
252
|
const restrictedParams = (0, InstanceCapabilities_1.getRestrictedParameters)(tool.requirements, ctx.instanceInfo);
|
|
235
253
|
if (restrictedParams.length > 0) {
|
|
236
254
|
transformedSchema = (0, schema_utils_1.stripTierRestrictedParameters)(transformedSchema, restrictedParams);
|
|
@@ -413,6 +431,7 @@ class RegistryManager {
|
|
|
413
431
|
const useSearch = process.env.USE_SEARCH !== 'false';
|
|
414
432
|
const useIterations = process.env.USE_ITERATIONS !== 'false';
|
|
415
433
|
const useCiTokens = process.env.USE_CI_TOKENS !== 'false';
|
|
434
|
+
const useEnvironments = process.env.USE_ENVIRONMENTS !== 'false';
|
|
416
435
|
const registriesToUse = new Map();
|
|
417
436
|
registriesToUse.set('core', registry_1.coreToolRegistry);
|
|
418
437
|
registriesToUse.set('context', registry_17.contextToolRegistry);
|
|
@@ -452,6 +471,8 @@ class RegistryManager {
|
|
|
452
471
|
registriesToUse.set('job-token-scope', registry_19.jobTokenScopeToolRegistry);
|
|
453
472
|
registriesToUse.set('deploy-keys', registry_20.deployKeysToolRegistry);
|
|
454
473
|
}
|
|
474
|
+
if (useEnvironments)
|
|
475
|
+
registriesToUse.set('environments', registry_21.environmentsToolRegistry);
|
|
455
476
|
const descOverrides = (0, config_1.getToolDescriptionOverrides)();
|
|
456
477
|
for (const registry of registriesToUse.values()) {
|
|
457
478
|
for (const [toolName, tool] of registry) {
|
|
@@ -524,6 +545,7 @@ class RegistryManager {
|
|
|
524
545
|
registry_18.iterationsToolRegistry,
|
|
525
546
|
registry_19.jobTokenScopeToolRegistry,
|
|
526
547
|
registry_20.deployKeysToolRegistry,
|
|
548
|
+
registry_21.environmentsToolRegistry,
|
|
527
549
|
];
|
|
528
550
|
for (const registry of allRegistries) {
|
|
529
551
|
for (const [, tool] of registry) {
|
|
@@ -572,6 +594,7 @@ class RegistryManager {
|
|
|
572
594
|
byScopes: 0,
|
|
573
595
|
byTier: 0,
|
|
574
596
|
byActionDenial: 0,
|
|
597
|
+
byAdmin: 0,
|
|
575
598
|
};
|
|
576
599
|
const counterByReason = {
|
|
577
600
|
readOnly: 'byReadOnly',
|
|
@@ -579,6 +602,7 @@ class RegistryManager {
|
|
|
579
602
|
scopes: 'byScopes',
|
|
580
603
|
tier: 'byTier',
|
|
581
604
|
actionDenial: 'byActionDenial',
|
|
605
|
+
admin: 'byAdmin',
|
|
582
606
|
};
|
|
583
607
|
for (const registry of this.registries.values()) {
|
|
584
608
|
for (const [toolName, tool] of registry) {
|
|
@@ -619,6 +643,7 @@ class RegistryManager {
|
|
|
619
643
|
filteredByTier: 0,
|
|
620
644
|
filteredByDeniedRegex: byDeniedRegex,
|
|
621
645
|
filteredByActionDenial: byActionDenial,
|
|
646
|
+
filteredByAdmin: 0,
|
|
622
647
|
};
|
|
623
648
|
}
|
|
624
649
|
let ctx;
|
|
@@ -639,9 +664,10 @@ class RegistryManager {
|
|
|
639
664
|
filteredByTier: 0,
|
|
640
665
|
filteredByDeniedRegex: 0,
|
|
641
666
|
filteredByActionDenial: 0,
|
|
667
|
+
filteredByAdmin: 0,
|
|
642
668
|
});
|
|
643
669
|
}
|
|
644
|
-
const { available: availableTools, byReadOnly: filteredByReadOnly, byDeniedRegex: filteredByDeniedRegex, byScopes: filteredByScopes, byTier: filteredByTier, byActionDenial: filteredByActionDenial, } = this.aggregateFilterCounters(ctx, contextTools);
|
|
670
|
+
const { available: availableTools, byReadOnly: filteredByReadOnly, byDeniedRegex: filteredByDeniedRegex, byScopes: filteredByScopes, byTier: filteredByTier, byActionDenial: filteredByActionDenial, byAdmin: filteredByAdmin, } = this.aggregateFilterCounters(ctx, contextTools);
|
|
645
671
|
const stats = {
|
|
646
672
|
available: availableTools,
|
|
647
673
|
total: totalTools,
|
|
@@ -650,6 +676,7 @@ class RegistryManager {
|
|
|
650
676
|
filteredByTier,
|
|
651
677
|
filteredByDeniedRegex,
|
|
652
678
|
filteredByActionDenial,
|
|
679
|
+
filteredByAdmin,
|
|
653
680
|
};
|
|
654
681
|
this.filterStatsCaches.set(url, stats);
|
|
655
682
|
return stats;
|