@copado/agentia-cli 0.56.0-alpha.0 → 0.58.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.
Files changed (142) hide show
  1. package/README.md +1180 -117
  2. package/dist/commands/cicd/data/commit/create.d.ts +11 -0
  3. package/dist/commands/cicd/data/commit/create.js +41 -0
  4. package/dist/commands/cicd/data/commit/create.js.map +1 -0
  5. package/dist/commands/cicd/data/commit/list.d.ts +10 -0
  6. package/dist/commands/cicd/data/commit/list.js +42 -0
  7. package/dist/commands/cicd/data/commit/list.js.map +1 -0
  8. package/dist/commands/cicd/data/dataset-file/content.d.ts +10 -0
  9. package/dist/commands/cicd/data/dataset-file/content.js +53 -0
  10. package/dist/commands/cicd/data/dataset-file/content.js.map +1 -0
  11. package/dist/commands/cicd/data/dataset-file/list.d.ts +10 -0
  12. package/dist/commands/cicd/data/dataset-file/list.js +42 -0
  13. package/dist/commands/cicd/data/dataset-file/list.js.map +1 -0
  14. package/dist/commands/cicd/data/filter/add.d.ts +13 -0
  15. package/dist/commands/cicd/data/filter/add.js +42 -0
  16. package/dist/commands/cicd/data/filter/add.js.map +1 -0
  17. package/dist/commands/cicd/data/filter/delete.d.ts +10 -0
  18. package/dist/commands/cicd/data/filter/delete.js +33 -0
  19. package/dist/commands/cicd/data/filter/delete.js.map +1 -0
  20. package/dist/commands/cicd/data/filter/list.d.ts +10 -0
  21. package/dist/commands/cicd/data/filter/list.js +42 -0
  22. package/dist/commands/cicd/data/filter/list.js.map +1 -0
  23. package/dist/commands/cicd/data/filter/update.d.ts +14 -0
  24. package/dist/commands/cicd/data/filter/update.js +46 -0
  25. package/dist/commands/cicd/data/filter/update.js.map +1 -0
  26. package/dist/commands/cicd/data/formula/create.d.ts +16 -0
  27. package/dist/commands/cicd/data/formula/create.js +62 -0
  28. package/dist/commands/cicd/data/formula/create.js.map +1 -0
  29. package/dist/commands/cicd/data/formula/list.d.ts +10 -0
  30. package/dist/commands/cicd/data/formula/list.js +42 -0
  31. package/dist/commands/cicd/data/formula/list.js.map +1 -0
  32. package/dist/commands/cicd/data/formula/update.d.ts +18 -0
  33. package/dist/commands/cicd/data/formula/update.js +78 -0
  34. package/dist/commands/cicd/data/formula/update.js.map +1 -0
  35. package/dist/commands/cicd/data/records/match.d.ts +11 -0
  36. package/dist/commands/cicd/data/records/match.js +39 -0
  37. package/dist/commands/cicd/data/records/match.js.map +1 -0
  38. package/dist/commands/cicd/data/records/search.d.ts +14 -0
  39. package/dist/commands/cicd/data/records/search.js +65 -0
  40. package/dist/commands/cicd/data/records/search.js.map +1 -0
  41. package/dist/commands/cicd/data/sobject/fields.d.ts +13 -0
  42. package/dist/commands/cicd/data/sobject/fields.js +56 -0
  43. package/dist/commands/cicd/data/sobject/fields.js.map +1 -0
  44. package/dist/commands/cicd/data/sobject/relationships.d.ts +13 -0
  45. package/dist/commands/cicd/data/sobject/relationships.js +66 -0
  46. package/dist/commands/cicd/data/sobject/relationships.js.map +1 -0
  47. package/dist/commands/cicd/data/sync/apply.d.ts +11 -0
  48. package/dist/commands/cicd/data/sync/apply.js +40 -0
  49. package/dist/commands/cicd/data/sync/apply.js.map +1 -0
  50. package/dist/commands/cicd/data/sync/preview-updates.d.ts +11 -0
  51. package/dist/commands/cicd/data/sync/preview-updates.js +58 -0
  52. package/dist/commands/cicd/data/sync/preview-updates.js.map +1 -0
  53. package/dist/commands/cicd/data/template/convert-old.d.ts +9 -0
  54. package/dist/commands/cicd/data/template/convert-old.js +29 -0
  55. package/dist/commands/cicd/data/template/convert-old.js.map +1 -0
  56. package/dist/commands/cicd/data/template/create.d.ts +13 -0
  57. package/dist/commands/cicd/data/template/create.js +56 -0
  58. package/dist/commands/cicd/data/template/create.js.map +1 -0
  59. package/dist/commands/cicd/data/template/delete.d.ts +9 -0
  60. package/dist/commands/cicd/data/template/delete.js +29 -0
  61. package/dist/commands/cicd/data/template/delete.js.map +1 -0
  62. package/dist/commands/cicd/data/template/get-detail.d.ts +10 -0
  63. package/dist/commands/cicd/data/template/get-detail.js +29 -0
  64. package/dist/commands/cicd/data/template/get-detail.js.map +1 -0
  65. package/dist/commands/cicd/data/template/get.d.ts +10 -0
  66. package/dist/commands/cicd/data/template/get.js +29 -0
  67. package/dist/commands/cicd/data/template/get.js.map +1 -0
  68. package/dist/commands/cicd/data/template/list.d.ts +11 -0
  69. package/dist/commands/cicd/data/template/list.js +44 -0
  70. package/dist/commands/cicd/data/template/list.js.map +1 -0
  71. package/dist/commands/cicd/data/template/save-detail.d.ts +13 -0
  72. package/dist/commands/cicd/data/template/save-detail.js +42 -0
  73. package/dist/commands/cicd/data/template/save-detail.js.map +1 -0
  74. package/dist/commands/cicd/function/defaults.d.ts +12 -0
  75. package/dist/commands/cicd/function/defaults.js +31 -0
  76. package/dist/commands/cicd/function/defaults.js.map +1 -0
  77. package/dist/commands/cicd/function/delete.d.ts +11 -0
  78. package/dist/commands/cicd/function/delete.js +29 -0
  79. package/dist/commands/cicd/function/delete.js.map +1 -0
  80. package/dist/commands/cicd/function/get.d.ts +10 -0
  81. package/dist/commands/cicd/function/get.js +30 -0
  82. package/dist/commands/cicd/function/get.js.map +1 -0
  83. package/dist/commands/cicd/function/list.d.ts +10 -0
  84. package/dist/commands/cicd/function/list.js +36 -0
  85. package/dist/commands/cicd/function/list.js.map +1 -0
  86. package/dist/commands/cicd/function/result/get.d.ts +10 -0
  87. package/dist/commands/cicd/function/result/get.js +30 -0
  88. package/dist/commands/cicd/function/result/get.js.map +1 -0
  89. package/dist/commands/cicd/function/result/log/get.d.ts +17 -0
  90. package/dist/commands/cicd/function/result/log/get.js +41 -0
  91. package/dist/commands/cicd/function/result/log/get.js.map +1 -0
  92. package/dist/commands/cicd/function/run-local.d.ts +17 -0
  93. package/dist/commands/cicd/function/run-local.js +64 -0
  94. package/dist/commands/cicd/function/run-local.js.map +1 -0
  95. package/dist/commands/cicd/function/run.d.ts +16 -0
  96. package/dist/commands/cicd/function/run.js +42 -0
  97. package/dist/commands/cicd/function/run.js.map +1 -0
  98. package/dist/commands/cicd/function/upsert.d.ts +27 -0
  99. package/dist/commands/cicd/function/upsert.js +45 -0
  100. package/dist/commands/cicd/function/upsert.js.map +1 -0
  101. package/dist/commands/cicd/promotion/run.d.ts +23 -0
  102. package/dist/commands/cicd/promotion/run.js +137 -0
  103. package/dist/commands/cicd/promotion/run.js.map +1 -0
  104. package/dist/commands/cicd/work/promote.d.ts +25 -0
  105. package/dist/commands/cicd/work/promote.js +141 -0
  106. package/dist/commands/cicd/work/promote.js.map +1 -0
  107. package/dist/lib/cicd-gateway.js +3 -2
  108. package/dist/lib/cicd-gateway.js.map +1 -1
  109. package/dist/lib/data-flags.d.ts +14 -0
  110. package/dist/lib/data-flags.js +61 -0
  111. package/dist/lib/data-flags.js.map +1 -0
  112. package/dist/lib/data-types.d.ts +322 -0
  113. package/dist/lib/data-types.js +176 -0
  114. package/dist/lib/data-types.js.map +1 -0
  115. package/dist/lib/function-flags.d.ts +69 -0
  116. package/dist/lib/function-flags.js +199 -0
  117. package/dist/lib/function-flags.js.map +1 -0
  118. package/dist/lib/function-local-run.d.ts +64 -0
  119. package/dist/lib/function-local-run.js +148 -0
  120. package/dist/lib/function-local-run.js.map +1 -0
  121. package/dist/lib/function-types.d.ts +106 -0
  122. package/dist/lib/function-types.js +171 -0
  123. package/dist/lib/function-types.js.map +1 -0
  124. package/dist/lib/mcp/data-tools.d.ts +159 -0
  125. package/dist/lib/mcp/data-tools.js +547 -0
  126. package/dist/lib/mcp/data-tools.js.map +1 -0
  127. package/dist/lib/mcp/tools.d.ts +231 -0
  128. package/dist/lib/mcp/tools.js +288 -0
  129. package/dist/lib/mcp/tools.js.map +1 -1
  130. package/dist/lib/mcp/work-tools.d.ts +29 -0
  131. package/dist/lib/mcp/work-tools.js +62 -0
  132. package/dist/lib/mcp/work-tools.js.map +1 -1
  133. package/dist/lib/promotion-run.d.ts +105 -0
  134. package/dist/lib/promotion-run.js +481 -0
  135. package/dist/lib/promotion-run.js.map +1 -0
  136. package/dist/lib/salesforce-id.d.ts +9 -0
  137. package/dist/lib/salesforce-id.js +30 -0
  138. package/dist/lib/salesforce-id.js.map +1 -1
  139. package/dist/lib/sf-org-context.js +5 -5
  140. package/dist/lib/sf-org-context.js.map +1 -1
  141. package/oclif.manifest.json +4818 -2752
  142. package/package.json +28 -1
@@ -2,6 +2,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { type CicdRegion } from '../cicd-region.js';
3
3
  import { type CredentialType } from '../credential-store.js';
4
4
  import { type Environment, type EnvironmentListFilters } from '../environment-types.js';
5
+ import { type FunctionCreateDefaultsPayload, type FunctionListType, type FunctionRunPayload, type FunctionRuntime, type FunctionUpsertInput } from '../function-types.js';
5
6
  import { type JobListFilters } from '../job-types.js';
6
7
  import { type ComparisonMode, type ContentSource, type DependencyResult, type IndexSearchResult, type IndexSource, type MetadataContentResult, type ModuleType, type OrderDirection, type PlatformExperience, type RetrieveMode } from '../metadata-common.js';
7
8
  import { type IndexRefreshResult, type RefreshDeletedMetadataIndexResult } from '../metadata-refresh.js';
@@ -10,6 +11,7 @@ import { type PipelineConnection, type PipelineDescribe, type PipelineListFilter
10
11
  import { type ProjectDefaultScope } from '../project-defaults.js';
11
12
  import { type Project, type ProjectListFilters } from '../project-types.js';
12
13
  import { type PromotionConflict, type PromotionConflictMode, type PromotionConflictResolutionResult, type PromotionConflictUndoResult } from '../promotion-conflicts.js';
14
+ import { type PromotionOperation } from '../promotion-run.js';
13
15
  import { type PromotionDetail, type PromotionListFilters } from '../promotion-types.js';
14
16
  import { type GitRepository, type RepositoryValidateResult } from '../repository-types.js';
15
17
  import { type User } from '../user-types.js';
@@ -178,12 +180,26 @@ declare function environmentGet(args: {
178
180
  environment: Environment;
179
181
  }>;
180
182
  type PromotionListArgs = PromotionListFilters;
183
+ type PromotionRunArgs = {
184
+ confirmRecreate?: boolean;
185
+ deploymentStepIds?: string[];
186
+ ignoredMetadata?: unknown[];
187
+ operation?: PromotionOperation;
188
+ promotionId: string;
189
+ recreatePromotionBranch?: boolean;
190
+ resumeJobExecutionId?: string;
191
+ wait?: boolean;
192
+ waitTimeout?: number;
193
+ };
181
194
  declare function promotionList(args?: PromotionListArgs): Promise<Record<string, unknown>>;
182
195
  declare function promotionGet(args: {
183
196
  id: string;
184
197
  }): Promise<{
185
198
  promotion: PromotionDetail;
186
199
  }>;
200
+ declare function promotionRun(args: PromotionRunArgs): Promise<{
201
+ result: import("../promotion-run.js").PromotionRunResult;
202
+ }>;
187
203
  declare function environmentCreate(args: EnvironmentCreateArgs): Promise<{
188
204
  environment: Environment;
189
205
  }>;
@@ -252,6 +268,55 @@ declare function repositoryValidate(args: {
252
268
  }): Promise<{
253
269
  validation: RepositoryValidateResult;
254
270
  }>;
271
+ declare function functionList(args?: {
272
+ type?: FunctionListType;
273
+ }): Promise<{
274
+ functions: import("../function-types.js").CopadoFunction[];
275
+ }>;
276
+ declare function functionGet(args: {
277
+ apiName: string;
278
+ }): Promise<{
279
+ function: import("../function-types.js").CopadoFunction;
280
+ }>;
281
+ declare function functionDefaults(args: FunctionCreateDefaultsPayload): Promise<{
282
+ function: import("../function-types.js").CopadoFunction;
283
+ }>;
284
+ declare function functionUpsert(args: FunctionUpsertInput & {
285
+ apiName: string;
286
+ }): Promise<{
287
+ function: import("../function-types.js").CopadoFunction;
288
+ }>;
289
+ declare function functionDelete(args: {
290
+ apiName: string;
291
+ }): Promise<{
292
+ apiName: string;
293
+ }>;
294
+ declare function functionRun(args: FunctionRunPayload & {
295
+ apiName: string;
296
+ }): Promise<{
297
+ run: import("../function-types.js").FunctionRunResult;
298
+ }>;
299
+ declare function functionResultGet(args: {
300
+ resultId: string;
301
+ }): Promise<{
302
+ result: import("../function-types.js").FunctionResultStatus;
303
+ }>;
304
+ declare function functionResultLogGet(args: {
305
+ resultId: string;
306
+ type?: string;
307
+ }): Promise<{
308
+ type?: string | undefined;
309
+ log: string;
310
+ resultId: string;
311
+ }>;
312
+ declare function functionRunLocal(args: {
313
+ cwd?: string;
314
+ image?: string;
315
+ parameters?: Record<string, string>;
316
+ platform?: string;
317
+ runtime?: FunctionRuntime;
318
+ script: string;
319
+ }): Promise<import("../function-local-run.js").LocalFunctionRunResult>;
255
320
  declare function userGet(args?: {
256
321
  id?: string;
257
322
  }): Promise<{
@@ -475,6 +540,33 @@ export declare const agentiaMcpToolHandlers: {
475
540
  assignedToMe?: boolean;
476
541
  ownedByMe?: boolean;
477
542
  }) => Promise<Record<string, unknown>>;
543
+ workPromote: (args?: {
544
+ cloud?: boolean;
545
+ confirmRecreate?: boolean;
546
+ deploy?: boolean;
547
+ deploymentStepIds?: string[];
548
+ id?: string;
549
+ ignoredMetadata?: unknown[];
550
+ promotionId?: string;
551
+ recreatePromotionBranch?: boolean;
552
+ wait?: boolean;
553
+ waitTimeout?: number;
554
+ }) => Promise<{
555
+ workItemId: string;
556
+ context: Record<string, unknown>;
557
+ deploymentSteps: import("../promotion-run.js").PromotionDeploymentStep[];
558
+ ignoredMetadata?: unknown[];
559
+ jobMonitors: import("../promotion-run.js").PromotionJobMonitor[];
560
+ mode: "resume" | "run";
561
+ operation?: PromotionOperation;
562
+ promotionAfter?: PromotionDetail;
563
+ promotionBefore: PromotionDetail;
564
+ promotionId: string;
565
+ request?: import("../promotion-run.js").PromotionRunRequest;
566
+ resultId: string;
567
+ run: import("../promotion-run.js").PromotionRunResponse;
568
+ wait: boolean;
569
+ }>;
478
570
  workPush: () => Promise<import("../work-types.js").WorkPushResult>;
479
571
  workSet: (args: {
480
572
  baseBranch?: string;
@@ -966,6 +1058,15 @@ export declare const agentiaMcpToolHandlers: {
966
1058
  environmentGet: typeof environmentGet;
967
1059
  environmentList: typeof environmentList;
968
1060
  environmentUpdate: typeof environmentUpdate;
1061
+ functionDefaults: typeof functionDefaults;
1062
+ functionDelete: typeof functionDelete;
1063
+ functionGet: typeof functionGet;
1064
+ functionList: typeof functionList;
1065
+ functionResultGet: typeof functionResultGet;
1066
+ functionResultLogGet: typeof functionResultLogGet;
1067
+ functionRun: typeof functionRun;
1068
+ functionRunLocal: typeof functionRunLocal;
1069
+ functionUpsert: typeof functionUpsert;
969
1070
  jobGet: typeof jobGet;
970
1071
  jobKill: typeof jobKill;
971
1072
  jobList: typeof jobList;
@@ -996,6 +1097,7 @@ export declare const agentiaMcpToolHandlers: {
996
1097
  promotionConflictUnresolve: typeof promotionConflictUnresolve;
997
1098
  promotionGet: typeof promotionGet;
998
1099
  promotionList: typeof promotionList;
1100
+ promotionRun: typeof promotionRun;
999
1101
  repositoryCreate: typeof repositoryCreate;
1000
1102
  repositoryDelete: typeof repositoryDelete;
1001
1103
  repositoryGet: typeof repositoryGet;
@@ -1005,6 +1107,135 @@ export declare const agentiaMcpToolHandlers: {
1005
1107
  repositoryValidate: typeof repositoryValidate;
1006
1108
  userGet: typeof userGet;
1007
1109
  workStatus: typeof workStatus;
1110
+ dataCommitCreate: (args: import("../data-types.js").DataCommitApiRequest) => Promise<{
1111
+ result: import("../data-types.js").DataCommitResponse;
1112
+ }>;
1113
+ dataCommitList: (args: {
1114
+ userStoryId: string;
1115
+ }) => Promise<{
1116
+ result: import("../data-types.js").UserStoryDataCommitRecord[];
1117
+ }>;
1118
+ dataDatasetFileContent: (args: {
1119
+ contentVersionId: string;
1120
+ }) => Promise<{
1121
+ result: import("../data-types.js").DatasetFileContentResult[];
1122
+ }>;
1123
+ dataDatasetFileList: (args: {
1124
+ userStoryDataCommitId: string;
1125
+ }) => Promise<{
1126
+ result: import("../data-types.js").DatasetFileMetadata[];
1127
+ }>;
1128
+ dataFilterAdd: (args: {
1129
+ body: import("../data-types.js").AdvancedFilterRequest;
1130
+ dataTemplateId: string;
1131
+ }) => Promise<{
1132
+ result: string;
1133
+ }>;
1134
+ dataFilterDelete: (args: {
1135
+ dataTemplateId: string;
1136
+ uuid: string;
1137
+ }) => Promise<{
1138
+ result: string;
1139
+ }>;
1140
+ dataFilterList: (args: {
1141
+ dataTemplateId: string;
1142
+ }) => Promise<{
1143
+ result: import("../data-types.js").AdvancedFilter[];
1144
+ }>;
1145
+ dataFilterUpdate: (args: {
1146
+ body: import("../data-types.js").AdvancedFilterRequest;
1147
+ dataTemplateId: string;
1148
+ uuid: string;
1149
+ }) => Promise<{
1150
+ result: string;
1151
+ }>;
1152
+ dataFormulaCreate: (args: {
1153
+ dataTemplateId: string;
1154
+ fields: string[];
1155
+ hashFormula?: boolean;
1156
+ name: string;
1157
+ objectApiName: string;
1158
+ }) => Promise<{
1159
+ result: import("../data-types.js").RecordMatchingFormulaVm;
1160
+ }>;
1161
+ dataFormulaList: (args: {
1162
+ objectApiName: string;
1163
+ }) => Promise<{
1164
+ result: import("../data-types.js").RecordMatchingFormulaVm[];
1165
+ }>;
1166
+ dataFormulaUpdate: (args: {
1167
+ body: import("../data-types.js").RecordMatchingFormulaRequest;
1168
+ formulaId: string;
1169
+ }) => Promise<{
1170
+ result: import("../data-types.js").RecordMatchingFormulaVm;
1171
+ }>;
1172
+ dataRecordsMatch: (args: import("../data-types.js").MatchDataRecordRequest) => Promise<{
1173
+ result: import("../data-types.js").DataRecord | null;
1174
+ }>;
1175
+ dataRecordsSearch: (args: import("../data-types.js").DataRecordRequest) => Promise<{
1176
+ result: import("../data-types.js").DataRecordSearchResult;
1177
+ }>;
1178
+ dataSobjectFields: (args: {
1179
+ credentialId: string;
1180
+ sobjectApiName: string;
1181
+ }) => Promise<{
1182
+ result: import("../data-types.js").SObjectFields;
1183
+ }>;
1184
+ dataSobjectRelationships: (args: {
1185
+ credentialId: string;
1186
+ sobjectApiName: string;
1187
+ }) => Promise<{
1188
+ result: import("../data-types.js").SObjectRelationships;
1189
+ }>;
1190
+ dataSyncApply: (args: {
1191
+ entries: import("../data-types.js").DataTemplateSyncEntryRequest[];
1192
+ }) => Promise<{
1193
+ result: import("../data-types.js").DataTemplateSyncResponseEntry[];
1194
+ }>;
1195
+ dataSyncPreviewUpdates: (args: import("../data-types.js").DataTemplateUpdatePreviewRequest) => Promise<{
1196
+ result: import("../data-types.js").DataTemplateUpdatePreview[];
1197
+ }>;
1198
+ dataTemplateConvertOld: (args: {
1199
+ id: string;
1200
+ }) => Promise<{
1201
+ result: string;
1202
+ }>;
1203
+ dataTemplateCreate: (args: {
1204
+ apiName: string;
1205
+ credentialId: string;
1206
+ mainObjectApiName: string;
1207
+ mainObjectLabel: string;
1208
+ templateName: string;
1209
+ }) => Promise<{
1210
+ result: string;
1211
+ }>;
1212
+ dataTemplateDelete: (args: {
1213
+ id: string;
1214
+ }) => Promise<{
1215
+ result: boolean;
1216
+ }>;
1217
+ dataTemplateGet: (args: {
1218
+ id: string;
1219
+ }) => Promise<{
1220
+ result: Record<string, import("../data-types.js").V2TemplateDetail>;
1221
+ }>;
1222
+ dataTemplateGetDetail: (args: {
1223
+ id: string;
1224
+ }) => Promise<{
1225
+ result: import("../data-types.js").V2Template;
1226
+ }>;
1227
+ dataTemplateList: (args?: {
1228
+ active?: boolean;
1229
+ fetchRelated?: boolean;
1230
+ }) => Promise<{
1231
+ result: import("../data-types.js").DataTemplate[];
1232
+ }>;
1233
+ dataTemplateSaveDetail: (args: {
1234
+ body: import("../data-types.js").V2Template;
1235
+ id: string;
1236
+ }) => Promise<{
1237
+ result: boolean;
1238
+ }>;
1008
1239
  aiAsk: (args: {
1009
1240
  agent: import("../ai-types.js").AiAgent;
1010
1241
  component?: string;
@@ -16,6 +16,8 @@ import { collectCredentialUpdateFlagKeys, validateCredentialName, } from '../env
16
16
  import { createEnvironmentCredential, resolveEnvironmentOrgType, updateEnvironmentCredential, } from '../environment-credential-operations.js';
17
17
  import { buildCreatePayload, buildMutationPayload, ENVIRONMENT_STRING_VALIDATION_KEYS, validateNonEmptyStringFields, } from '../environment-flags.js';
18
18
  import { DEFAULT_ENVIRONMENT_PLATFORM, DEFAULT_ENVIRONMENT_TYPE, ENVIRONMENT_TYPES, environmentEndpoint, environmentsListEndpoint, } from '../environment-types.js';
19
+ import { executeLocalFunctionRun } from '../function-local-run.js';
20
+ import { FUNCTION_LIST_TYPES, FUNCTION_RUNTIMES, functionEndpoint, functionResultEndpoint, functionResultLogEndpoint, functionRunEndpoint, functionsEndpoint, normalizeFunction, normalizeFunctionResultStatus, normalizeFunctionRunResult, normalizeFunctionsList, normalizeFunctionUpsertPayload, } from '../function-types.js';
19
21
  import { jobEndpoint, jobKillEndpoint, jobListEndpoint, jobPauseEndpoint, jobResultLogEndpoint, jobResumeEndpoint, jobRunEndpoint, normalizeJob, normalizeJobOperation, normalizeJobsListPage, resolveJobStepForLog, } from '../job-types.js';
20
22
  import { listPaginationZodFields, mcpPaginatedListPayload } from '../list-pagination.js';
21
23
  import { normalizeLocalGatewayBaseUrl, readLocalGatewayConfig } from '../local-gateway-config.js';
@@ -27,6 +29,7 @@ import { buildSetValues, collectSelectedKeys } from '../project-default-flags.js
27
29
  import { PROJECT_DEFAULT_KEYS } from '../project-defaults.js';
28
30
  import { normalizeProject, normalizeProjectsListPage, projectEndpoint, projectsListEndpoint, } from '../project-types.js';
29
31
  import { buildPromotionConflictResolutionRequest, normalizePromotionConflicts, PROMOTION_CONFLICT_MODES, promotionConflictContentEndpoint, promotionConflictResolveEndpoint, promotionConflictsEndpoint, promotionConflictUndoEndpoint, withPromotionConflictErrorTranslation, } from '../promotion-conflicts.js';
32
+ import { performPromotionResume, performPromotionRun, PROMOTION_OPERATIONS, PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS, } from '../promotion-run.js';
30
33
  import { normalizePromotionDetail, normalizePromotionsListPage, promotionEndpoint, promotionListEndpoint, } from '../promotion-types.js';
31
34
  import { REPOSITORY_STRING_VALIDATION_KEYS, validateNonEmptyStringFields as validateRepositoryNonEmptyStringFields, } from '../repository-flags.js';
32
35
  import { normalizeRepositoriesListPage, normalizeRepository, normalizeRepositoryValidateResult, repositoriesEndpoint, REPOSITORY_AUTH_TYPES, REPOSITORY_PROVIDERS, REPOSITORY_SOURCE_FORMATS, repositoryEndpoint, repositoryResetEndpoint, repositoryValidateEndpoint, withRequiredRepositoryFields, } from '../repository-types.js';
@@ -34,6 +37,7 @@ import { getUserContext } from '../user-context.js';
34
37
  import { DEFAULT_USER_ID, resolveUserId, userEndpoint } from '../user-types.js';
35
38
  import { workStatusEndpoint } from '../work-types.js';
36
39
  import { agentiaMcpAiToolHandlers, registerAgentiaMcpAiTools } from './ai-tools.js';
40
+ import { agentiaMcpDataToolHandlers, registerAgentiaMcpDataTools } from './data-tools.js';
37
41
  import { safelyHandleTool } from './result.js';
38
42
  import { agentiaMcpTestingToolHandlers, registerAgentiaMcpTestingTools } from './testing-tools.js';
39
43
  import { agentiaMcpWorkToolHandlers, registerAgentiaMcpWorkTools } from './work-tools.js';
@@ -52,6 +56,10 @@ async function environmentGet(args) {
52
56
  });
53
57
  return { environment };
54
58
  }
59
+ const silentPromotionRunHooks = {
60
+ log() { },
61
+ withSpinner: async (_message, action) => action(),
62
+ };
55
63
  async function promotionList(args = {}) {
56
64
  const response = await CicdGateway.call({
57
65
  endpoint: promotionListEndpoint(args),
@@ -66,6 +74,45 @@ async function promotionGet(args) {
66
74
  });
67
75
  return { promotion: normalizePromotionDetail(response) };
68
76
  }
77
+ async function promotionRun(args) {
78
+ const waitTimeout = args.waitTimeout ?? PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS;
79
+ if (!Number.isInteger(waitTimeout) || waitTimeout <= 0) {
80
+ throw new Error('waitTimeout must be a positive integer.');
81
+ }
82
+ if (args.recreatePromotionBranch === true && args.confirmRecreate !== true) {
83
+ throw new Error('recreatePromotionBranch requires confirmRecreate=true.');
84
+ }
85
+ if (args.resumeJobExecutionId !== undefined) {
86
+ if (args.operation !== undefined ||
87
+ args.deploymentStepIds !== undefined ||
88
+ args.ignoredMetadata !== undefined ||
89
+ args.recreatePromotionBranch !== undefined) {
90
+ throw new Error('resumeJobExecutionId cannot be combined with run request fields.');
91
+ }
92
+ const result = await performPromotionResume({
93
+ hooks: silentPromotionRunHooks,
94
+ jobExecutionId: args.resumeJobExecutionId,
95
+ promotionId: args.promotionId,
96
+ timeoutSeconds: waitTimeout,
97
+ wait: args.wait ?? true,
98
+ });
99
+ return { result };
100
+ }
101
+ if (args.operation === undefined) {
102
+ throw new Error('operation is required unless resumeJobExecutionId is provided.');
103
+ }
104
+ const result = await performPromotionRun({
105
+ deploymentStepIds: args.deploymentStepIds,
106
+ hooks: silentPromotionRunHooks,
107
+ ignoredMetadata: args.ignoredMetadata,
108
+ operation: args.operation,
109
+ promotionId: args.promotionId,
110
+ recreatePromotionBranch: args.recreatePromotionBranch,
111
+ timeoutSeconds: waitTimeout,
112
+ wait: args.wait ?? true,
113
+ });
114
+ return { result };
115
+ }
69
116
  async function environmentCreate(args) {
70
117
  const payload = buildCreatePayload(args.name, {
71
118
  'apex-test-level': args.apexTestLevel,
@@ -350,6 +397,107 @@ async function repositoryValidate(args) {
350
397
  });
351
398
  return { validation: normalizeRepositoryValidateResult(response) };
352
399
  }
400
+ async function functionList(args = {}) {
401
+ const response = await CicdGateway.call({
402
+ endpoint: functionsEndpoint({ type: args.type ?? 'custom' }),
403
+ method: 'GET',
404
+ });
405
+ return { functions: normalizeFunctionsList(response) };
406
+ }
407
+ async function functionGet(args) {
408
+ const response = await CicdGateway.call({
409
+ endpoint: functionEndpoint(assertRequired(args.apiName, 'apiName')),
410
+ method: 'GET',
411
+ });
412
+ return { function: normalizeFunction(response) };
413
+ }
414
+ async function functionDefaults(args) {
415
+ const response = await CicdGateway.call({
416
+ body: {
417
+ imageName: args.imageName ?? 'copado-function-core:v1',
418
+ name: assertRequired(args.name, 'name'),
419
+ runtime: args.runtime ?? 'bash',
420
+ },
421
+ endpoint: functionsEndpoint(),
422
+ headers: {
423
+ 'Content-Type': 'application/json',
424
+ },
425
+ method: 'POST',
426
+ });
427
+ return { function: normalizeFunction(response) };
428
+ }
429
+ async function functionUpsert(args) {
430
+ const apiName = assertRequired(args.apiName, 'apiName');
431
+ const payload = normalizeFunctionUpsertPayload(apiName, args);
432
+ const response = await CicdGateway.call({
433
+ body: payload,
434
+ endpoint: functionEndpoint(apiName),
435
+ headers: {
436
+ 'Content-Type': 'application/json',
437
+ },
438
+ method: 'PUT',
439
+ });
440
+ return { function: normalizeFunction(response) };
441
+ }
442
+ async function functionDelete(args) {
443
+ const apiName = assertRequired(args.apiName, 'apiName');
444
+ await CicdGateway.call({
445
+ endpoint: functionEndpoint(apiName),
446
+ method: 'DELETE',
447
+ });
448
+ return { apiName };
449
+ }
450
+ async function functionRun(args) {
451
+ const apiName = assertRequired(args.apiName, 'apiName');
452
+ const response = await CicdGateway.call({
453
+ body: {
454
+ deployFirst: args.deployFirst ?? false,
455
+ showValidationErrors: args.showValidationErrors ?? true,
456
+ ...(args.contextId === undefined || args.contextId === null ? {} : { contextId: args.contextId }),
457
+ ...(args.parameters === undefined || args.parameters === null ? {} : { parameters: args.parameters }),
458
+ ...(args.function === undefined || args.function === null ? {} : { function: args.function }),
459
+ },
460
+ endpoint: functionRunEndpoint(apiName),
461
+ headers: {
462
+ 'Content-Type': 'application/json',
463
+ },
464
+ method: 'POST',
465
+ });
466
+ return { run: normalizeFunctionRunResult(response) };
467
+ }
468
+ async function functionResultGet(args) {
469
+ const response = await CicdGateway.call({
470
+ endpoint: functionResultEndpoint(assertRequired(args.resultId, 'resultId')),
471
+ method: 'GET',
472
+ });
473
+ return { result: normalizeFunctionResultStatus(response) };
474
+ }
475
+ async function functionResultLogGet(args) {
476
+ const resultId = assertRequired(args.resultId, 'resultId');
477
+ const log = await CicdGateway.call({
478
+ endpoint: functionResultLogEndpoint(resultId, args.type),
479
+ method: 'GET',
480
+ responseType: 'text',
481
+ });
482
+ return {
483
+ log,
484
+ resultId,
485
+ ...(args.type === undefined ? {} : { type: args.type }),
486
+ };
487
+ }
488
+ async function functionRunLocal(args) {
489
+ const parameter = args.parameters === undefined
490
+ ? undefined
491
+ : Object.entries(args.parameters).map(([key, value]) => `${key}=${value}`);
492
+ return executeLocalFunctionRun({
493
+ cwd: args.cwd,
494
+ image: args.image,
495
+ parameter,
496
+ platform: args.platform,
497
+ runtime: args.runtime,
498
+ script: assertRequired(args.script, 'script'),
499
+ });
500
+ }
353
501
  function buildRepositoryMcpPayload(args) {
354
502
  const payload = {};
355
503
  for (const [key, value] of Object.entries(args)) {
@@ -737,6 +885,7 @@ async function navigationResolve(args) {
737
885
  }
738
886
  export const agentiaMcpToolHandlers = {
739
887
  ...agentiaMcpAiToolHandlers,
888
+ ...agentiaMcpDataToolHandlers,
740
889
  authGet,
741
890
  authSet,
742
891
  credentialCreate,
@@ -746,6 +895,15 @@ export const agentiaMcpToolHandlers = {
746
895
  environmentGet,
747
896
  environmentList,
748
897
  environmentUpdate,
898
+ functionDefaults,
899
+ functionDelete,
900
+ functionGet,
901
+ functionList,
902
+ functionResultGet,
903
+ functionResultLogGet,
904
+ functionRun,
905
+ functionRunLocal,
906
+ functionUpsert,
749
907
  jobGet,
750
908
  jobKill,
751
909
  jobList,
@@ -776,6 +934,7 @@ export const agentiaMcpToolHandlers = {
776
934
  promotionConflictUnresolve,
777
935
  promotionGet,
778
936
  promotionList,
937
+ promotionRun,
779
938
  repositoryCreate,
780
939
  repositoryDelete,
781
940
  repositoryGet,
@@ -845,6 +1004,7 @@ const promotionListSchema = {
845
1004
  };
846
1005
  export function registerAgentiaMcpTools(server) {
847
1006
  registerAgentiaMcpAiTools(server);
1007
+ registerAgentiaMcpDataTools(server);
848
1008
  registerAgentiaMcpTestingTools(server);
849
1009
  server.registerTool('agentia_environment_list', {
850
1010
  description: 'List Copado environments via the CICD gateway.',
@@ -912,6 +1072,34 @@ export function registerAgentiaMcpTools(server) {
912
1072
  },
913
1073
  title: 'Agentia Promotion Get',
914
1074
  }, (args) => safelyHandleTool(() => promotionGet(args)));
1075
+ server.registerTool('agentia_promotion_run', {
1076
+ description: 'Preflight, start, and optionally wait for a Copado promotion. Can also resume an existing execution without starting a duplicate run.',
1077
+ inputSchema: {
1078
+ confirmRecreate: z
1079
+ .boolean()
1080
+ .optional()
1081
+ .describe('Required true when recreatePromotionBranch is true because MCP cannot prompt.'),
1082
+ deploymentStepIds: z
1083
+ .array(z.string())
1084
+ .optional()
1085
+ .describe('Ordered deployment-step Salesforce IDs. The gateway order is used when omitted.'),
1086
+ ignoredMetadata: z.array(z.unknown()).optional().describe('Ignored metadata persisted before starting the run.'),
1087
+ operation: z
1088
+ .enum(PROMOTION_OPERATIONS)
1089
+ .optional()
1090
+ .describe('Promotion operation. Required unless resumeJobExecutionId is supplied.'),
1091
+ promotionId: z.string().describe('18-character Salesforce Promotion ID.'),
1092
+ recreatePromotionBranch: z.boolean().optional().describe('Recreate the promotion branch before execution.'),
1093
+ resumeJobExecutionId: z.string().optional().describe('Resume this existing promotion execution instead of /run.'),
1094
+ wait: z.boolean().optional().describe('Poll all created executions to terminal status. Defaults to true.'),
1095
+ waitTimeout: z
1096
+ .number()
1097
+ .int()
1098
+ .optional()
1099
+ .describe(`Maximum total wait in seconds. Defaults to ${PROMOTION_RUN_DEFAULT_TIMEOUT_SECONDS}.`),
1100
+ },
1101
+ title: 'Agentia Promotion Run',
1102
+ }, (args) => safelyHandleTool(() => promotionRun(args)));
915
1103
  server.registerTool('agentia_job_list', {
916
1104
  description: 'List Copado job executions via the CICD gateway.',
917
1105
  inputSchema: {
@@ -1202,6 +1390,106 @@ export function registerAgentiaMcpTools(server) {
1202
1390
  inputSchema: { id: z.string().describe('Copado Git repository ID.') },
1203
1391
  title: 'Agentia Repository Validate',
1204
1392
  }, (args) => safelyHandleTool(() => repositoryValidate(args)));
1393
+ server.registerTool('agentia_function_list', {
1394
+ description: 'List Copado Functions via the CICD gateway.',
1395
+ inputSchema: {
1396
+ type: z.enum(FUNCTION_LIST_TYPES).optional().describe('List Custom functions only, or all functions.'),
1397
+ },
1398
+ title: 'Agentia Function List',
1399
+ }, (args) => safelyHandleTool(() => functionList(args)));
1400
+ server.registerTool('agentia_function_get', {
1401
+ description: 'Get a Copado Function by API name via the CICD gateway.',
1402
+ inputSchema: { apiName: z.string().describe('Function API name.') },
1403
+ title: 'Agentia Function Get',
1404
+ }, (args) => safelyHandleTool(() => functionGet(args)));
1405
+ server.registerTool('agentia_function_defaults', {
1406
+ description: 'Scaffold default Copado Function metadata without writing to Salesforce.',
1407
+ inputSchema: {
1408
+ imageName: z.string().optional().describe('Function container image.'),
1409
+ name: z.string().describe('Function display name.'),
1410
+ runtime: z.enum(FUNCTION_RUNTIMES).optional().describe('Script runtime.'),
1411
+ },
1412
+ title: 'Agentia Function Defaults',
1413
+ }, (args) => safelyHandleTool(() => functionDefaults(args)));
1414
+ server.registerTool('agentia_function_upsert', {
1415
+ description: 'Create or update a Copado Function by API name via the CICD gateway.',
1416
+ inputSchema: {
1417
+ apexClass: z.string().nullable().optional().describe('Apex callback class.'),
1418
+ apiName: z.string().describe('Function API name.'),
1419
+ callback: z.string().nullable().optional().describe('Function callback type.'),
1420
+ description: z.string().nullable().optional().describe('Function description.'),
1421
+ flowHandler: z.string().nullable().optional().describe('Flow handler name.'),
1422
+ imageName: z.string().optional().describe('Function container image.'),
1423
+ name: z.string().optional().describe('Function display name; defaults to apiName when omitted.'),
1424
+ parameters: z
1425
+ .array(z.object({
1426
+ defaultValue: z.string().optional(),
1427
+ name: z.string(),
1428
+ required: z.boolean().optional(),
1429
+ }))
1430
+ .optional()
1431
+ .describe('Function parameters.'),
1432
+ script: z
1433
+ .object({
1434
+ content: z.string(),
1435
+ extension: z.enum(['sh', 'js', 'py']).optional(),
1436
+ runtime: z.enum(FUNCTION_RUNTIMES).optional(),
1437
+ })
1438
+ .describe('Function script body and runtime.'),
1439
+ size: z.string().optional().describe('Function size.'),
1440
+ timeout: z.number().int().nullable().optional().describe('Timeout in seconds.'),
1441
+ type: z.string().optional().describe('Function type.'),
1442
+ version: z.string().optional().describe('Function version.'),
1443
+ },
1444
+ title: 'Agentia Function Upsert',
1445
+ }, (args) => safelyHandleTool(() => functionUpsert(args)));
1446
+ server.registerTool('agentia_function_delete', {
1447
+ description: 'Delete a Copado Function by API name via the CICD gateway.',
1448
+ inputSchema: { apiName: z.string().describe('Function API name.') },
1449
+ title: 'Agentia Function Delete',
1450
+ }, (args) => safelyHandleTool(() => functionDelete(args)));
1451
+ server.registerTool('agentia_function_run', {
1452
+ description: 'Run a Copado Function and return the result Id.',
1453
+ inputSchema: {
1454
+ apiName: z.string().describe('Function API name.'),
1455
+ contextId: z.string().nullable().optional().describe('Execution context Id.'),
1456
+ deployFirst: z.boolean().optional().describe('Deploy related metadata before running.'),
1457
+ parameters: z.record(z.string(), z.string()).optional().describe('Run parameters as key/value strings.'),
1458
+ showValidationErrors: z.boolean().optional().describe('Surface validation errors from the gateway.'),
1459
+ },
1460
+ title: 'Agentia Function Run',
1461
+ }, (args) => safelyHandleTool(() => functionRun(args)));
1462
+ server.registerTool('agentia_function_run_local', {
1463
+ description: 'Run a Copado Function script locally in Docker without calling the CICD gateway. Override image when the Copado registry is unavailable.',
1464
+ inputSchema: {
1465
+ cwd: z
1466
+ .string()
1467
+ .optional()
1468
+ .describe('Host directory bind-mounted at /app inside the container (defaults to process cwd).'),
1469
+ image: z
1470
+ .string()
1471
+ .optional()
1472
+ .describe('Docker image (default copado-function-core:v1). Override for partner/local registries.'),
1473
+ parameters: z.record(z.string(), z.string()).optional().describe('Environment variables as key/value strings.'),
1474
+ platform: z.string().optional().describe('Docker --platform value (e.g. linux/amd64).'),
1475
+ runtime: z.enum(FUNCTION_RUNTIMES).optional().describe('Override runtime detection from the script extension.'),
1476
+ script: z.string().describe('Path to the local function script (.sh, .js, or .py).'),
1477
+ },
1478
+ title: 'Agentia Function Run Local',
1479
+ }, (args) => safelyHandleTool(() => functionRunLocal(args)));
1480
+ server.registerTool('agentia_function_result_get', {
1481
+ description: 'Get Copado Function execution status by result Id.',
1482
+ inputSchema: { resultId: z.string().describe('Function result Id.') },
1483
+ title: 'Agentia Function Result Get',
1484
+ }, (args) => safelyHandleTool(() => functionResultGet(args)));
1485
+ server.registerTool('agentia_function_result_log_get', {
1486
+ description: 'Get log output for a Copado Function result.',
1487
+ inputSchema: {
1488
+ resultId: z.string().describe('Function result Id.'),
1489
+ type: z.string().optional().describe('Optional log file type filter.'),
1490
+ },
1491
+ title: 'Agentia Function Result Log Get',
1492
+ }, (args) => safelyHandleTool(() => functionResultLogGet(args)));
1205
1493
  server.registerTool('agentia_promotion_conflict_list', {
1206
1494
  description: 'List merge conflicts for a Copado promotion.',
1207
1495
  inputSchema: { promotionId: z.string().describe('Copado promotion ID.') },