@copado/agentia-cli 0.57.0-alpha.0 → 0.59.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 (133) hide show
  1. package/README.md +1090 -116
  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/lib/cicd-gateway.js +3 -2
  102. package/dist/lib/cicd-gateway.js.map +1 -1
  103. package/dist/lib/cli-update.d.ts +2 -0
  104. package/dist/lib/cli-update.js +20 -1
  105. package/dist/lib/cli-update.js.map +1 -1
  106. package/dist/lib/data-flags.d.ts +14 -0
  107. package/dist/lib/data-flags.js +61 -0
  108. package/dist/lib/data-flags.js.map +1 -0
  109. package/dist/lib/data-types.d.ts +322 -0
  110. package/dist/lib/data-types.js +176 -0
  111. package/dist/lib/data-types.js.map +1 -0
  112. package/dist/lib/function-flags.d.ts +69 -0
  113. package/dist/lib/function-flags.js +199 -0
  114. package/dist/lib/function-flags.js.map +1 -0
  115. package/dist/lib/function-local-run.d.ts +64 -0
  116. package/dist/lib/function-local-run.js +148 -0
  117. package/dist/lib/function-local-run.js.map +1 -0
  118. package/dist/lib/function-types.d.ts +106 -0
  119. package/dist/lib/function-types.js +171 -0
  120. package/dist/lib/function-types.js.map +1 -0
  121. package/dist/lib/mcp/data-tools.d.ts +159 -0
  122. package/dist/lib/mcp/data-tools.js +547 -0
  123. package/dist/lib/mcp/data-tools.js.map +1 -0
  124. package/dist/lib/mcp/tools.d.ts +188 -0
  125. package/dist/lib/mcp/tools.js +215 -0
  126. package/dist/lib/mcp/tools.js.map +1 -1
  127. package/dist/lib/salesforce-id.d.ts +9 -0
  128. package/dist/lib/salesforce-id.js +30 -0
  129. package/dist/lib/salesforce-id.js.map +1 -1
  130. package/dist/lib/sf-org-context.js +5 -5
  131. package/dist/lib/sf-org-context.js.map +1 -1
  132. package/oclif.manifest.json +4876 -3011
  133. 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';
@@ -267,6 +268,55 @@ declare function repositoryValidate(args: {
267
268
  }): Promise<{
268
269
  validation: RepositoryValidateResult;
269
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>;
270
320
  declare function userGet(args?: {
271
321
  id?: string;
272
322
  }): Promise<{
@@ -1008,6 +1058,15 @@ export declare const agentiaMcpToolHandlers: {
1008
1058
  environmentGet: typeof environmentGet;
1009
1059
  environmentList: typeof environmentList;
1010
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;
1011
1070
  jobGet: typeof jobGet;
1012
1071
  jobKill: typeof jobKill;
1013
1072
  jobList: typeof jobList;
@@ -1048,6 +1107,135 @@ export declare const agentiaMcpToolHandlers: {
1048
1107
  repositoryValidate: typeof repositoryValidate;
1049
1108
  userGet: typeof userGet;
1050
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
+ }>;
1051
1239
  aiAsk: (args: {
1052
1240
  agent: import("../ai-types.js").AiAgent;
1053
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';
@@ -35,6 +37,7 @@ import { getUserContext } from '../user-context.js';
35
37
  import { DEFAULT_USER_ID, resolveUserId, userEndpoint } from '../user-types.js';
36
38
  import { workStatusEndpoint } from '../work-types.js';
37
39
  import { agentiaMcpAiToolHandlers, registerAgentiaMcpAiTools } from './ai-tools.js';
40
+ import { agentiaMcpDataToolHandlers, registerAgentiaMcpDataTools } from './data-tools.js';
38
41
  import { safelyHandleTool } from './result.js';
39
42
  import { agentiaMcpTestingToolHandlers, registerAgentiaMcpTestingTools } from './testing-tools.js';
40
43
  import { agentiaMcpWorkToolHandlers, registerAgentiaMcpWorkTools } from './work-tools.js';
@@ -394,6 +397,107 @@ async function repositoryValidate(args) {
394
397
  });
395
398
  return { validation: normalizeRepositoryValidateResult(response) };
396
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
+ }
397
501
  function buildRepositoryMcpPayload(args) {
398
502
  const payload = {};
399
503
  for (const [key, value] of Object.entries(args)) {
@@ -781,6 +885,7 @@ async function navigationResolve(args) {
781
885
  }
782
886
  export const agentiaMcpToolHandlers = {
783
887
  ...agentiaMcpAiToolHandlers,
888
+ ...agentiaMcpDataToolHandlers,
784
889
  authGet,
785
890
  authSet,
786
891
  credentialCreate,
@@ -790,6 +895,15 @@ export const agentiaMcpToolHandlers = {
790
895
  environmentGet,
791
896
  environmentList,
792
897
  environmentUpdate,
898
+ functionDefaults,
899
+ functionDelete,
900
+ functionGet,
901
+ functionList,
902
+ functionResultGet,
903
+ functionResultLogGet,
904
+ functionRun,
905
+ functionRunLocal,
906
+ functionUpsert,
793
907
  jobGet,
794
908
  jobKill,
795
909
  jobList,
@@ -890,6 +1004,7 @@ const promotionListSchema = {
890
1004
  };
891
1005
  export function registerAgentiaMcpTools(server) {
892
1006
  registerAgentiaMcpAiTools(server);
1007
+ registerAgentiaMcpDataTools(server);
893
1008
  registerAgentiaMcpTestingTools(server);
894
1009
  server.registerTool('agentia_environment_list', {
895
1010
  description: 'List Copado environments via the CICD gateway.',
@@ -1275,6 +1390,106 @@ export function registerAgentiaMcpTools(server) {
1275
1390
  inputSchema: { id: z.string().describe('Copado Git repository ID.') },
1276
1391
  title: 'Agentia Repository Validate',
1277
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)));
1278
1493
  server.registerTool('agentia_promotion_conflict_list', {
1279
1494
  description: 'List merge conflicts for a Copado promotion.',
1280
1495
  inputSchema: { promotionId: z.string().describe('Copado promotion ID.') },