@copado/agentia-cli 0.22.0-alpha.0 → 0.24.0-alpha.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.
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-lines -- Tool schemas and registrations are intentionally colocated. */
1
2
  import { z } from 'zod';
2
3
  import { normalizeEnvironments } from '../../commands/environment/list.js';
3
4
  import { buildMetadataCompareFileRequests } from '../../commands/metadata/content/compare.js';
@@ -5,23 +6,31 @@ import { buildMetadataContentRequest } from '../../commands/metadata/content/get
5
6
  import { buildMetadataCompareRequest } from '../../commands/metadata/index/compare.js';
6
7
  import { buildMetadataIndexRequest } from '../../commands/metadata/list.js';
7
8
  import { assertRequired } from '../assert.js';
8
- import { CicdGateway } from '../cicd-gateway.js';
9
- import { readDefaults, resolveDefaults, unsetDefaults, writeDefaults } from '../defaults-store.js';
9
+ import { CicdGateway, normalizeCicdBaseUrl } from '../cicd-gateway.js';
10
+ import { CICD_REGIONS } from '../cicd-region.js';
11
+ import { ALL_CREDENTIAL_TYPES, credentialLabel, getCicdBaseUrl, getCredential, maskSecret, setCicdBaseUrl, setCredential, } from '../credential-store.js';
12
+ import { readDefaults, readLastBaseBranch, readLastWorkItem, resolveDefaults, unsetDefaults, writeDefaults, writeLastWorkSelection, } from '../defaults-store.js';
13
+ import { runEnvironmentAuthStatus } from '../environment-auth-status.js';
10
14
  import { buildCreatePayload, buildMutationPayload, ENVIRONMENT_STRING_VALIDATION_KEYS, validateNonEmptyStringFields, } from '../environment-flags.js';
11
15
  import { DEFAULT_ENVIRONMENT_PLATFORM, DEFAULT_ENVIRONMENT_TYPE, ENVIRONMENT_TYPES, environmentEndpoint, environmentsListEndpoint, } from '../environment-types.js';
12
- import { JOB_LIST_LIMIT_MAX, JOB_LIST_LIMIT_MIN, jobEndpoint, jobKillEndpoint, jobListEndpoint, jobPauseEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobs, } from '../job-types.js';
16
+ import { checkoutFeatureBranch, fetchOriginBranch, getCurrentBranch, hasUnpushedCommits, listPendingChanges, } from '../git-worktree.js';
17
+ import { JOB_LIST_LIMIT_MAX, JOB_LIST_LIMIT_MIN, jobEndpoint, jobKillEndpoint, jobListEndpoint, jobPauseEndpoint, jobResultLogEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobs, resolveJobStepForLog, } from '../job-types.js';
18
+ import { normalizeLocalGatewayBaseUrl, readLocalGatewayConfig } from '../local-gateway-config.js';
13
19
  import { COMPARISON_MODES, CONTENT_SOURCES, contentResultToCompareSide, createUnifiedDiff, INDEX_SOURCES, MODULE_TYPES, ORDER_DIRECTIONS, PLATFORM_EXPERIENCES, RETRIEVE_MODES, sourceSideLabel, } from '../metadata-common.js';
20
+ import { buildRefreshDeletedRequest, buildRefreshIndexRequest, refreshStatusEndpoint, resolveRefreshSourceFromEnv, } from '../metadata-refresh.js';
14
21
  import { normalizePipelineDescribe, normalizePipelines, pipelineConnectionsFromPipelines, pipelineDescribeEndpoint, pipelineListEndpoint, } from '../pipeline-types.js';
15
22
  import { buildSetValues, collectSelectedKeys } from '../project-default-flags.js';
16
23
  import { PROJECT_DEFAULT_KEYS } from '../project-defaults.js';
17
- import { normalizeProjects, projectsListEndpoint } from '../project-types.js';
24
+ import { normalizeProject, normalizeProjects, projectEndpoint, projectsListEndpoint, } from '../project-types.js';
25
+ import { buildPromotionConflictResolutionRequest, normalizePromotionConflicts, PROMOTION_CONFLICT_MODES, promotionConflictContentEndpoint, promotionConflictResolveEndpoint, promotionConflictsEndpoint, promotionConflictUndoEndpoint, withPromotionConflictErrorTranslation, } from '../promotion-conflicts.js';
18
26
  import { normalizePromotionDetail, normalizePromotions, PROMOTION_LIST_LIMIT_MAX, PROMOTION_LIST_LIMIT_MIN, promotionEndpoint, promotionListEndpoint, } from '../promotion-types.js';
19
27
  import { getUserContext } from '../user-context.js';
20
28
  import { DEFAULT_USER_ID, resolveUserId, userEndpoint } from '../user-types.js';
21
29
  import { resolveWorkItemId } from '../work-active.js';
22
30
  import { buildWorkCreatePayload } from '../work-defaults.js';
23
31
  import { validateNonEmptyStringFields as validateWorkNonEmptyStringFields, WORK_STRING_VALIDATION_KEYS, } from '../work-flags.js';
24
- import { normalizeUserStories, workCreateEndpoint, workEndpoint, workListEndpoint, } from '../work-types.js';
32
+ import { performWorkPush } from '../work-push.js';
33
+ import { extractUserStoryFromFeatureBranch, featureBranchName, normalizeUserStories, workCreateEndpoint, workDoneEndpoint, workEndpoint, workListEndpoint, workSetEndpoint, workStatusEndpoint, workSubmitEndpoint, } from '../work-types.js';
25
34
  import { safelyHandleTool } from './result.js';
26
35
  const MAX_LIMIT = 2000;
27
36
  const WORK_MUTATION_PAYLOAD_KEYS = [
@@ -185,6 +194,13 @@ async function jobList(args) {
185
194
  status: args.status,
186
195
  type: args.type,
187
196
  };
197
+ if (args.mine) {
198
+ const userId = (await getUserContext()).id?.trim();
199
+ if (userId === undefined || userId.length === 0) {
200
+ throw new Error('Current user ID is unavailable from the CICD gateway context.');
201
+ }
202
+ filters.ownerId = userId;
203
+ }
188
204
  const response = await CicdGateway.call({
189
205
  endpoint: jobListEndpoint(filters),
190
206
  method: 'GET',
@@ -576,7 +592,244 @@ async function workDelete(args) {
576
592
  });
577
593
  return { deleted: true, id };
578
594
  }
595
+ function authCredentialResult(type) {
596
+ if (type === 'cicd') {
597
+ const localConfig = readLocalGatewayConfig();
598
+ const credential = localConfig.enabled ? localConfig.apiKey || getCredential(type) : getCredential(type);
599
+ if (credential === null || credential.trim().length === 0) {
600
+ return {
601
+ ...(localConfig.enabled ? { baseUrl: normalizeLocalGatewayBaseUrl(localConfig.url), local: true } : {}),
602
+ label: credentialLabel(type),
603
+ set: false,
604
+ type,
605
+ };
606
+ }
607
+ return {
608
+ baseUrl: localConfig.enabled ? normalizeLocalGatewayBaseUrl(localConfig.url) : getCicdBaseUrl(),
609
+ label: credentialLabel(type),
610
+ ...(localConfig.enabled ? { local: true } : {}),
611
+ masked: maskSecret(credential),
612
+ set: true,
613
+ type,
614
+ };
615
+ }
616
+ const credential = getCredential(type);
617
+ return credential === null
618
+ ? { label: credentialLabel(type), set: false, type }
619
+ : { label: credentialLabel(type), masked: maskSecret(credential), set: true, type };
620
+ }
621
+ async function authGet(args = {}) {
622
+ const types = [];
623
+ if (args.cicd)
624
+ types.push('cicd');
625
+ if (args.crt)
626
+ types.push('crt');
627
+ return { credentials: (types.length > 0 ? types : ALL_CREDENTIAL_TYPES).map((type) => authCredentialResult(type)) };
628
+ }
629
+ async function authSet(args) {
630
+ if (args.cicd === undefined && args.crt === undefined) {
631
+ throw new Error('Must provide at least one of cicd or crt.');
632
+ }
633
+ if ((args.region !== undefined || args.customUrl !== undefined) && args.cicd === undefined) {
634
+ throw new Error('region and customUrl can only be used together with cicd.');
635
+ }
636
+ if ([args.cicd, args.crt].some((value) => value !== undefined && value.trim().length === 0)) {
637
+ throw new Error('Credential values cannot be empty.');
638
+ }
639
+ if (args.customUrl !== undefined)
640
+ normalizeCicdBaseUrl(args.customUrl);
641
+ let baseUrl;
642
+ if (args.cicd !== undefined) {
643
+ try {
644
+ baseUrl = await CicdGateway.resolveAndValidateEndpoint(args.cicd, {
645
+ customUrl: args.customUrl,
646
+ region: args.region,
647
+ });
648
+ }
649
+ catch {
650
+ throw new Error('CICD API key could not be validated for the selected endpoint.');
651
+ }
652
+ setCicdBaseUrl(baseUrl);
653
+ }
654
+ const stored = [];
655
+ for (const [type, value] of [
656
+ ['cicd', args.cicd],
657
+ ['crt', args.crt],
658
+ ]) {
659
+ if (value !== undefined) {
660
+ setCredential(type, value);
661
+ stored.push({ label: credentialLabel(type), type });
662
+ }
663
+ }
664
+ if (args.cicd !== undefined) {
665
+ await getUserContext({ forceRefresh: true });
666
+ }
667
+ return { ...(baseUrl === undefined ? {} : { baseUrl }), stored };
668
+ }
669
+ async function environmentAuthStatus(args) {
670
+ return runEnvironmentAuthStatus({
671
+ credentialId: args.credentialId,
672
+ environmentId: assertRequired(args.id, 'id'),
673
+ });
674
+ }
675
+ async function jobLogGet(args) {
676
+ const jobId = assertRequired(args.id, 'id');
677
+ const response = await CicdGateway.call({ endpoint: jobEndpoint(jobId), method: 'GET' });
678
+ const { resultId, step } = resolveJobStepForLog(normalizeJob(response).steps, args.step);
679
+ const log = await CicdGateway.call({
680
+ endpoint: jobResultLogEndpoint(resultId),
681
+ method: 'GET',
682
+ responseType: 'text',
683
+ });
684
+ return { jobId, log, resultId, ...(step.id === undefined || step.id === null ? {} : { stepId: step.id }) };
685
+ }
686
+ async function projectGet(args) {
687
+ const response = await CicdGateway.call({
688
+ endpoint: projectEndpoint(assertRequired(args.id, 'id')),
689
+ method: 'GET',
690
+ });
691
+ return { project: normalizeProject(response) };
692
+ }
693
+ async function promotionConflictList(args) {
694
+ const conflicts = await withPromotionConflictErrorTranslation(() => CicdGateway.call({
695
+ endpoint: promotionConflictsEndpoint(args.promotionId),
696
+ method: 'GET',
697
+ }));
698
+ return { conflicts: normalizePromotionConflicts(conflicts) };
699
+ }
700
+ async function promotionConflictGet(args) {
701
+ const content = await withPromotionConflictErrorTranslation(() => CicdGateway.call({
702
+ endpoint: promotionConflictContentEndpoint(args.promotionId, args.id),
703
+ method: 'GET',
704
+ responseType: 'text',
705
+ }));
706
+ return { conflictId: args.id, content, promotionId: args.promotionId };
707
+ }
708
+ async function promotionConflictResolve(args) {
709
+ if (args.mode === 'auto' && args.content !== undefined) {
710
+ throw new Error('content can only be used when mode is manual.');
711
+ }
712
+ return withPromotionConflictErrorTranslation(() => CicdGateway.call({
713
+ body: buildPromotionConflictResolutionRequest(args.mode, args.content),
714
+ endpoint: promotionConflictResolveEndpoint(args.promotionId, args.id),
715
+ headers: { 'Content-Type': 'application/json' },
716
+ method: 'POST',
717
+ }));
718
+ }
719
+ async function promotionConflictUnresolve(args) {
720
+ return withPromotionConflictErrorTranslation(() => CicdGateway.call({
721
+ endpoint: promotionConflictUndoEndpoint(args.promotionId, args.id),
722
+ method: 'POST',
723
+ }));
724
+ }
725
+ async function metadataRefreshRun(args) {
726
+ const sourceContext = await resolveRefreshSourceFromEnv(args.env, {
727
+ sourceCredentialId: args.sourceCredentialId,
728
+ sourceOrgId: args.sourceOrgId,
729
+ });
730
+ const result = await CicdGateway.call({
731
+ body: buildRefreshIndexRequest({ ...sourceContext, ...args }),
732
+ endpoint: '/release/metadata/index/refresh',
733
+ headers: { 'Content-Type': 'application/json', 'platform-experience': args.platformExperience ?? 'salesforce' },
734
+ method: 'POST',
735
+ });
736
+ return { result };
737
+ }
738
+ async function metadataRefreshStatus(args) {
739
+ const result = await CicdGateway.call({
740
+ endpoint: refreshStatusEndpoint(args.jobId, args.moduleType),
741
+ headers: { 'platform-experience': args.platformExperience ?? 'salesforce' },
742
+ method: 'GET',
743
+ });
744
+ return { result };
745
+ }
746
+ async function metadataRefreshDeleted(args) {
747
+ const sourceContext = await resolveRefreshSourceFromEnv(args.env, {
748
+ sourceCredentialId: args.sourceCredentialId,
749
+ sourceOrgId: args.sourceOrgId,
750
+ });
751
+ const result = await CicdGateway.call({
752
+ body: buildRefreshDeletedRequest(sourceContext.sourceCredentialId, args.moduleType),
753
+ endpoint: '/release/metadata/index/refresh-deleted',
754
+ headers: { 'Content-Type': 'application/json' },
755
+ method: 'POST',
756
+ });
757
+ return { result };
758
+ }
759
+ function assertCleanWorktree(pendingFiles) {
760
+ if (pendingFiles.length > 0) {
761
+ throw new Error(`Uncommitted tracked changes present:\n${pendingFiles.map((file) => ` ${file}`).join('\n')}`);
762
+ }
763
+ }
764
+ const mcpWorkPushHooks = {
765
+ display: (render) => render(),
766
+ log() { },
767
+ withSpinner: async (_message, action) => action(),
768
+ };
769
+ async function workSet(args) {
770
+ const setResponse = await CicdGateway.call({
771
+ body: { workItem: assertRequired(args.id, 'id') },
772
+ endpoint: workSetEndpoint(),
773
+ headers: { 'Content-Type': 'application/json' },
774
+ method: 'POST',
775
+ });
776
+ const baseBranch = args.baseBranch?.trim() || setResponse.baseBranch?.trim();
777
+ const userStoryId = setResponse.workItem.id?.trim();
778
+ const userStoryName = setResponse.workItem.name?.trim();
779
+ if (!baseBranch || !userStoryId || !userStoryName)
780
+ throw new Error('Work set response is missing a base branch, user story ID, or name.');
781
+ assertCleanWorktree(await listPendingChanges());
782
+ const branch = featureBranchName(userStoryName);
783
+ await fetchOriginBranch(baseBranch);
784
+ const checkout = await checkoutFeatureBranch(branch, baseBranch);
785
+ await writeLastWorkSelection({ lastBaseBranch: baseBranch, lastWorkItem: userStoryName, lastWorkItemId: userStoryId });
786
+ return { ...setResponse, baseBranch, git: { branch: checkout.branch, branchCreated: checkout.created, fetched: true } };
787
+ }
788
+ async function resolveCurrentWorkBranch() {
789
+ const branch = await getCurrentBranch();
790
+ const workItem = extractUserStoryFromFeatureBranch(branch);
791
+ if (workItem === undefined)
792
+ throw new Error(`Current branch '${branch}' is not a feature/US-XXXX branch.`);
793
+ assertCleanWorktree(await listPendingChanges());
794
+ return { branch, workItem };
795
+ }
796
+ async function workPush() {
797
+ const { branch, workItem } = await resolveCurrentWorkBranch();
798
+ const baseBranch = (await readLastBaseBranch())?.trim();
799
+ if (!baseBranch)
800
+ throw new Error('No base branch recorded. Run work set first.');
801
+ return performWorkPush({ baseBranch, branch, hooks: mcpWorkPushHooks, workItem });
802
+ }
803
+ async function workStatus(args = {}) {
804
+ const workItem = args.id?.trim() || (await readLastWorkItem());
805
+ if (!workItem)
806
+ throw new Error('No work item specified and no last work item recorded.');
807
+ const result = await CicdGateway.call({ endpoint: workStatusEndpoint(workItem), method: 'GET' });
808
+ return { result };
809
+ }
810
+ async function workSubmitOrDone(kind) {
811
+ const { branch, workItem } = await resolveCurrentWorkBranch();
812
+ const pushed = await hasUnpushedCommits(branch);
813
+ const push = pushed ? await workPush() : undefined;
814
+ const endpoint = kind === 'submit' ? workSubmitEndpoint() : workDoneEndpoint();
815
+ const result = await CicdGateway.call({
816
+ body: { workItem },
817
+ endpoint,
818
+ headers: { 'Content-Type': 'application/json' },
819
+ method: 'POST',
820
+ });
821
+ return { branch, [kind]: result, ...(push === undefined ? {} : { push }), pushed, workItem };
822
+ }
823
+ async function workSubmit() {
824
+ return workSubmitOrDone('submit');
825
+ }
826
+ async function workDone() {
827
+ return workSubmitOrDone('done');
828
+ }
579
829
  export const agentiaMcpToolHandlers = {
830
+ authGet,
831
+ authSet,
832
+ environmentAuthStatus,
580
833
  environmentCreate,
581
834
  environmentGet,
582
835
  environmentList,
@@ -584,6 +837,7 @@ export const agentiaMcpToolHandlers = {
584
837
  jobGet,
585
838
  jobKill,
586
839
  jobList,
840
+ jobLogGet,
587
841
  jobPause,
588
842
  jobResume,
589
843
  jobRun,
@@ -592,20 +846,33 @@ export const agentiaMcpToolHandlers = {
592
846
  metadataDependencyList,
593
847
  metadataIndexCompare,
594
848
  metadataList,
849
+ metadataRefreshDeleted,
850
+ metadataRefreshRun,
851
+ metadataRefreshStatus,
595
852
  pipelineConnectionList,
596
853
  pipelineGet,
597
854
  pipelineList,
598
855
  projectDefaultGet,
599
856
  projectDefaultSet,
600
857
  projectDefaultUnset,
858
+ projectGet,
601
859
  projectList,
860
+ promotionConflictGet,
861
+ promotionConflictList,
862
+ promotionConflictResolve,
863
+ promotionConflictUnresolve,
602
864
  promotionGet,
603
865
  promotionList,
604
866
  userGet,
605
867
  workCreate,
606
868
  workDelete,
869
+ workDone,
607
870
  workGet,
608
871
  workList,
872
+ workPush,
873
+ workSet,
874
+ workStatus,
875
+ workSubmit,
609
876
  workUpdate,
610
877
  };
611
878
  const environmentMutationSchema = {
@@ -753,6 +1020,7 @@ export function registerAgentiaMcpTools(server) {
753
1020
  .max(JOB_LIST_LIMIT_MAX)
754
1021
  .optional()
755
1022
  .describe(`Maximum number of jobs to return (${JOB_LIST_LIMIT_MIN}-${JOB_LIST_LIMIT_MAX}).`),
1023
+ mine: z.boolean().optional().describe('List only jobs owned by the current user.'),
756
1024
  name: z.string().optional().describe('Contains match on JobExecution name.'),
757
1025
  parent: z.string().optional().describe('Exact parent record Id.'),
758
1026
  status: z.string().optional().describe('Exact Copado job status.'),
@@ -974,5 +1242,140 @@ export function registerAgentiaMcpTools(server) {
974
1242
  },
975
1243
  title: 'Agentia Metadata Dependency List',
976
1244
  }, (args) => safelyHandleTool(() => metadataDependencyList(args)));
1245
+ server.registerTool('agentia_auth_get', {
1246
+ description: 'Show masked Agentia credential status from the system keychain.',
1247
+ inputSchema: {
1248
+ cicd: z.boolean().optional().describe('Include the CICD credential.'),
1249
+ crt: z.boolean().optional().describe('Include the CRT credential.'),
1250
+ },
1251
+ title: 'Agentia Auth Get',
1252
+ }, (args) => safelyHandleTool(() => authGet(args || {})));
1253
+ server.registerTool('agentia_auth_set', {
1254
+ description: 'Store CICD and/or CRT credentials in the system keychain. Credential input is sensitive.',
1255
+ inputSchema: {
1256
+ cicd: z.string().optional().describe('CICD API key to store.'),
1257
+ crt: z.string().optional().describe('CRT personal access token to store.'),
1258
+ customUrl: z.string().optional().describe('CICD gateway URL to validate with the CICD API key.'),
1259
+ region: z.enum(CICD_REGIONS).optional().describe('CICD region to validate with the CICD API key.'),
1260
+ },
1261
+ title: 'Agentia Auth Set',
1262
+ }, (args) => safelyHandleTool(() => authSet(args)));
1263
+ server.registerTool('agentia_environment_auth_status', {
1264
+ description: 'Validate an environment credential through the CICD gateway.',
1265
+ inputSchema: {
1266
+ credentialId: z.string().optional().describe('Credential ID when selection is ambiguous.'),
1267
+ id: z.string().describe('Copado environment ID.'),
1268
+ },
1269
+ title: 'Agentia Environment Auth Status',
1270
+ }, (args) => safelyHandleTool(() => environmentAuthStatus(args)));
1271
+ server.registerTool('agentia_job_log_get', {
1272
+ description: 'Get raw log output for a Copado job execution step.',
1273
+ inputSchema: {
1274
+ id: z.string().describe('JobExecution ID.'),
1275
+ step: z.string().optional().describe('Job step ID. Defaults to the first step with a result ID.'),
1276
+ },
1277
+ title: 'Agentia Job Log Get',
1278
+ }, (args) => safelyHandleTool(() => jobLogGet(args)));
1279
+ server.registerTool('agentia_project_get', {
1280
+ description: 'Get a Copado project by ID via the CICD gateway.',
1281
+ inputSchema: { id: z.string().describe('Copado project ID.') },
1282
+ title: 'Agentia Project Get',
1283
+ }, (args) => safelyHandleTool(() => projectGet(args)));
1284
+ server.registerTool('agentia_promotion_conflict_list', {
1285
+ description: 'List merge conflicts for a Copado promotion.',
1286
+ inputSchema: { promotionId: z.string().describe('Copado promotion ID.') },
1287
+ title: 'Agentia Promotion Conflict List',
1288
+ }, (args) => safelyHandleTool(() => promotionConflictList(args)));
1289
+ server.registerTool('agentia_promotion_conflict_get', {
1290
+ description: 'Get raw merge-conflict content for a Copado promotion file.',
1291
+ inputSchema: {
1292
+ id: z.string().describe('Conflict attachment ID.'),
1293
+ promotionId: z.string().describe('Copado promotion ID.'),
1294
+ },
1295
+ title: 'Agentia Promotion Conflict Get',
1296
+ }, (args) => safelyHandleTool(() => promotionConflictGet(args)));
1297
+ server.registerTool('agentia_promotion_conflict_resolve', {
1298
+ description: 'Resolve a promotion merge conflict automatically or with manual content.',
1299
+ inputSchema: {
1300
+ content: z.string().optional().describe('Manual resolved content. Required when mode is manual.'),
1301
+ id: z.string().describe('Conflict attachment ID.'),
1302
+ mode: z.enum(PROMOTION_CONFLICT_MODES).describe('Conflict resolution mode.'),
1303
+ promotionId: z.string().describe('Copado promotion ID.'),
1304
+ },
1305
+ title: 'Agentia Promotion Conflict Resolve',
1306
+ }, (args) => safelyHandleTool(() => promotionConflictResolve(args)));
1307
+ server.registerTool('agentia_promotion_conflict_unresolve', {
1308
+ description: 'Undo a promotion conflict resolution.',
1309
+ inputSchema: {
1310
+ id: z.string().describe('Conflict attachment ID.'),
1311
+ promotionId: z.string().describe('Copado promotion ID.'),
1312
+ },
1313
+ title: 'Agentia Promotion Conflict Unresolve',
1314
+ }, (args) => safelyHandleTool(() => promotionConflictUnresolve(args)));
1315
+ server.registerTool('agentia_metadata_refresh_run', {
1316
+ description: 'Trigger a metadata index refresh via the CICD gateway.',
1317
+ inputSchema: {
1318
+ all: z.boolean().optional().describe('Replace the metadata index instead of merging it.'),
1319
+ env: z.string().describe('Environment ID used to resolve source configuration.'),
1320
+ gitFiles: z.array(z.string()).optional().describe('Git file paths to refresh.'),
1321
+ moduleType: z.enum(MODULE_TYPES).optional().describe('Optional addon module type.'),
1322
+ pipelineId: z.string().optional().describe('Optional pipeline ID.'),
1323
+ platformExperience: z.enum(PLATFORM_EXPERIENCES).optional().describe('Gateway platform experience header.'),
1324
+ refreshMode: z.string().optional().describe('Optional refresh mode.'),
1325
+ selectedName: z.string().optional().describe('Selected metadata API name.'),
1326
+ selectedType: z.string().optional().describe('Selected metadata type.'),
1327
+ sourceCredentialId: z.string().optional().describe('Override the source credential ID.'),
1328
+ sourceOrgId: z.string().optional().describe('Override the source org ID.'),
1329
+ targetOrgId: z.string().optional().describe('Optional target org ID.'),
1330
+ },
1331
+ title: 'Agentia Metadata Refresh Run',
1332
+ }, (args) => safelyHandleTool(() => metadataRefreshRun(args)));
1333
+ server.registerTool('agentia_metadata_refresh_status', {
1334
+ description: 'Get metadata index refresh status via the CICD gateway.',
1335
+ inputSchema: {
1336
+ jobId: z.string().describe('Metadata refresh event ID.'),
1337
+ moduleType: z.enum(MODULE_TYPES).optional().describe('Addon module type used by the refresh.'),
1338
+ platformExperience: z.enum(PLATFORM_EXPERIENCES).optional().describe('Gateway platform experience header.'),
1339
+ },
1340
+ title: 'Agentia Metadata Refresh Status',
1341
+ }, (args) => safelyHandleTool(() => metadataRefreshStatus(args)));
1342
+ server.registerTool('agentia_metadata_refresh_deleted', {
1343
+ description: 'Refresh deleted metadata index entries via the CICD gateway.',
1344
+ inputSchema: {
1345
+ env: z.string().describe('Environment ID used to resolve the source credential.'),
1346
+ moduleType: z.enum(MODULE_TYPES).optional().describe('Optional addon module type.'),
1347
+ sourceCredentialId: z.string().optional().describe('Override the source credential ID.'),
1348
+ sourceOrgId: z.string().optional().describe('Override the source org ID for environment validation.'),
1349
+ },
1350
+ title: 'Agentia Metadata Refresh Deleted',
1351
+ }, (args) => safelyHandleTool(() => metadataRefreshDeleted(args)));
1352
+ server.registerTool('agentia_work_set', {
1353
+ description: 'Set the active work item, then fetch and check out its feature branch in the MCP server current Git repository. Changes the current branch.',
1354
+ inputSchema: {
1355
+ baseBranch: z.string().optional().describe('Override the base branch returned by Copado.'),
1356
+ id: z.string().describe('User story ID or name.'),
1357
+ },
1358
+ title: 'Agentia Work Set',
1359
+ }, (args) => safelyHandleTool(() => workSet(args)));
1360
+ server.registerTool('agentia_work_status', {
1361
+ description: 'Get work status and related jobs. Defaults to the active work item from work set.',
1362
+ inputSchema: { id: z.string().optional().describe('User story ID or name.') },
1363
+ title: 'Agentia Work Status',
1364
+ }, (args) => safelyHandleTool(() => workStatus(args || {})));
1365
+ server.registerTool('agentia_work_push', {
1366
+ description: 'Push and register commits for the current feature branch in the MCP server current Git repository. Pushes to origin.',
1367
+ inputSchema: {},
1368
+ title: 'Agentia Work Push',
1369
+ }, () => safelyHandleTool(() => workPush()));
1370
+ server.registerTool('agentia_work_submit', {
1371
+ description: 'Submit the current feature-branch work item. Pushes and registers unpushed commits in the MCP server current Git repository first.',
1372
+ inputSchema: {},
1373
+ title: 'Agentia Work Submit',
1374
+ }, () => safelyHandleTool(() => workSubmit()));
1375
+ server.registerTool('agentia_work_done', {
1376
+ description: 'Mark the current feature-branch work item done. Pushes and registers unpushed commits in the MCP server current Git repository first.',
1377
+ inputSchema: {},
1378
+ title: 'Agentia Work Done',
1379
+ }, () => safelyHandleTool(() => workDone()));
977
1380
  }
978
1381
  //# sourceMappingURL=tools.js.map