@copado/agentia-cli 1.0.0-beta.8 → 1.0.0-beta.9

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.
@@ -8,6 +8,7 @@ export default class AdvAuthStatus extends AgentiaCommand {
8
8
  '<%= config.bin %> <%= command.id %> --json',
9
9
  ];
10
10
  async run() {
11
+ await this.parse(AdvAuthStatus);
11
12
  const result = await this.withSpinner('Checking Pipelines Advanced authentication', () => getAdvAuthStatus());
12
13
  this.display(() => {
13
14
  this.log(formatAdvRecord(result));
@@ -29,6 +29,9 @@ export default class AdvComponentAdd extends AgentiaCommand {
29
29
  };
30
30
  async run() {
31
31
  const { args, flags } = await this.parse(AdvComponentAdd);
32
+ if (flags.component === undefined && flags.file === undefined && flags['json-file'] === undefined) {
33
+ this.error('Provide one component input: --component, --file, or --json-file.', { exit: 2 });
34
+ }
32
35
  const components = flags.file === undefined
33
36
  ? flags['json-file'] === undefined
34
37
  ? (flags.component ?? []).map((component) => parseAdvComponentSpec(component))
@@ -24,6 +24,9 @@ export default class AdvComponentRemove extends AgentiaCommand {
24
24
  };
25
25
  async run() {
26
26
  const { args, flags } = await this.parse(AdvComponentRemove);
27
+ if (flags.component === undefined && flags['json-file'] === undefined) {
28
+ this.error('Provide one component input: --component or --json-file.', { exit: 2 });
29
+ }
27
30
  const components = flags['json-file'] === undefined
28
31
  ? (flags.component ?? []).map((component) => parseAdvComponentSpec(component))
29
32
  : readAdvComponentsFromJsonFile(flags['json-file']);
@@ -8,6 +8,7 @@ export default class AdvComponentTypes extends AgentiaCommand {
8
8
  '<%= config.bin %> <%= command.id %> --json',
9
9
  ];
10
10
  async run() {
11
+ await this.parse(AdvComponentTypes);
11
12
  const result = await this.withSpinner('Fetching Pipelines Advanced component types', () => listAdvComponentTypes());
12
13
  this.display(() => this.log(formatAdvRecord({ views: result.views.length })));
13
14
  return result;
@@ -13,7 +13,7 @@ export default class AdvJobWait extends AgentiaCommand {
13
13
  ];
14
14
  static flags = {
15
15
  interval: Flags.integer({ description: 'Seconds between job status polls (default: 3).' }),
16
- timeout: Flags.integer({ description: 'Maximum seconds to wait (default: 3600).' }),
16
+ timeout: Flags.integer({ description: 'Maximum seconds to wait; the remote run continues after timeout (default: 3600).' }),
17
17
  };
18
18
  async run() {
19
19
  const { args, flags } = await this.parse(AdvJobWait);
@@ -8,6 +8,7 @@ export default class AdvOrganizationList extends AgentiaCommand {
8
8
  '<%= config.bin %> <%= command.id %> --json',
9
9
  ];
10
10
  async run() {
11
+ await this.parse(AdvOrganizationList);
11
12
  const result = await this.withSpinner('Fetching Pipelines Advanced organizations', () => listAdvOrganizations());
12
13
  this.display(() => {
13
14
  if (result.organizations.length === 0)
@@ -0,0 +1,42 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
3
+ import { buildTemplateDefaultsQuery, resolveTemplateWritePath, templateDefaultsFlags } from '../../../lib/template-flags.js';
4
+ import { formatTemplateDetail, normalizeTemplate, templateDefaultsEndpoint, writeTemplateDiskFile, } from '../../../lib/template-types.js';
5
+ export default class TemplateDefaults extends AgentiaCommand {
6
+ static description = 'Scaffold default Copado Job Template metadata without writing to Salesforce (legacy create ≈ defaults --write)';
7
+ static examples = [
8
+ '<%= config.bin %> <%= command.id %> --name MyTemplate',
9
+ '<%= config.bin %> <%= command.id %> --name MyTemplate --api-name MyTemplate_1 --write',
10
+ '<%= config.bin %> <%= command.id %> --name MyTemplate --output ./copado/templates/MyTemplate_1.metadata.json --json',
11
+ ];
12
+ static flags = templateDefaultsFlags;
13
+ async run() {
14
+ const { flags } = await this.parse(TemplateDefaults);
15
+ let query;
16
+ try {
17
+ query = buildTemplateDefaultsQuery(flags);
18
+ }
19
+ catch (error) {
20
+ this.error(error instanceof Error ? error.message : String(error), { exit: 2 });
21
+ }
22
+ const response = await this.withSpinner('Scaffolding template defaults', () => CicdGateway.call({
23
+ endpoint: templateDefaultsEndpoint(query),
24
+ method: 'GET',
25
+ }));
26
+ const template = normalizeTemplate(response);
27
+ let filePath;
28
+ const writePath = resolveTemplateWritePath(template.apiName, flags);
29
+ if (writePath !== undefined) {
30
+ filePath = await writeTemplateDiskFile(template, writePath);
31
+ }
32
+ this.display(() => {
33
+ this.log('Scaffolded template defaults (not persisted).');
34
+ this.log(formatTemplateDetail(template));
35
+ if (filePath !== undefined) {
36
+ this.log(`Wrote ${filePath}`);
37
+ }
38
+ });
39
+ return filePath === undefined ? template : { ...template, filePath };
40
+ }
41
+ }
42
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1,36 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { assertValidTemplateApiName, templateEndpoint } from '../../../lib/template-types.js';
5
+ export default class TemplateDelete extends AgentiaCommand {
6
+ static args = {
7
+ 'api-name': Args.string({
8
+ description: 'Template API name',
9
+ required: true,
10
+ }),
11
+ };
12
+ static description = 'Delete a Copado Job Template by API name';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> MyTemplate_1',
15
+ '<%= config.bin %> <%= command.id %> MyTemplate_1 --json',
16
+ ];
17
+ async run() {
18
+ const { args } = await this.parse(TemplateDelete);
19
+ let apiName;
20
+ try {
21
+ apiName = assertValidTemplateApiName(args['api-name']);
22
+ }
23
+ catch (error) {
24
+ this.error(error instanceof Error ? error.message : String(error), { exit: 2 });
25
+ }
26
+ await this.withSpinner('Deleting template', () => CicdGateway.call({
27
+ endpoint: templateEndpoint(apiName),
28
+ method: 'DELETE',
29
+ }));
30
+ this.display(() => {
31
+ this.log(`Deleted template ${apiName}.`);
32
+ });
33
+ return { apiName };
34
+ }
35
+ }
36
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1,48 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { resolveTemplateWritePath, templateGetFlags } from '../../../lib/template-flags.js';
5
+ import { formatTemplateDetail, normalizeTemplate, templateEndpoint, writeTemplateDiskFile, } from '../../../lib/template-types.js';
6
+ export default class TemplateGet extends AgentiaCommand {
7
+ static args = {
8
+ 'api-name': Args.string({
9
+ description: 'Template API name',
10
+ required: true,
11
+ }),
12
+ };
13
+ static description = 'Get a Copado Job Template by API name (legacy retrieve ≈ get --write)';
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %> MyTemplate_1',
16
+ '<%= config.bin %> <%= command.id %> MyTemplate_1 --write',
17
+ '<%= config.bin %> <%= command.id %> MyTemplate_1 --json',
18
+ ];
19
+ static flags = templateGetFlags;
20
+ async run() {
21
+ const { args, flags } = await this.parse(TemplateGet);
22
+ let endpoint;
23
+ try {
24
+ endpoint = templateEndpoint(args['api-name']);
25
+ }
26
+ catch (error) {
27
+ this.error(error instanceof Error ? error.message : String(error), { exit: 2 });
28
+ }
29
+ const response = await this.withSpinner('Fetching template', () => CicdGateway.call({
30
+ endpoint,
31
+ method: 'GET',
32
+ }));
33
+ const template = normalizeTemplate(response);
34
+ let filePath;
35
+ const writePath = resolveTemplateWritePath(template.apiName, flags);
36
+ if (writePath !== undefined) {
37
+ filePath = await writeTemplateDiskFile(template, writePath);
38
+ }
39
+ this.display(() => {
40
+ this.log(formatTemplateDetail(template));
41
+ if (filePath !== undefined) {
42
+ this.log(`Wrote ${filePath}`);
43
+ }
44
+ });
45
+ return filePath === undefined ? template : { ...template, filePath };
46
+ }
47
+ }
48
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1,53 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { buildListPaginationQuery, displayListPagination, listPaginationFlags, } from '../../../lib/list-pagination.js';
5
+ import { formatTemplateTable, normalizeTemplatesListPage, TEMPLATE_LIST_TYPES, templatesEndpoint, } from '../../../lib/template-types.js';
6
+ export default class TemplateList extends AgentiaCommand {
7
+ static description = 'List Copado Job Templates';
8
+ static examples = [
9
+ '<%= config.bin %> <%= command.id %>',
10
+ '<%= config.bin %> <%= command.id %> --type all',
11
+ '<%= config.bin %> <%= command.id %> --name Demo --page-size 50',
12
+ '<%= config.bin %> <%= command.id %> --fetch-all --json',
13
+ ];
14
+ static flags = {
15
+ ...listPaginationFlags,
16
+ 'fetch-all': Flags.boolean({
17
+ default: false,
18
+ description: 'Fetch all matching templates (incompatible with --cursor on the gateway)',
19
+ }),
20
+ name: Flags.string({
21
+ description: 'Filter by name substring',
22
+ }),
23
+ type: Flags.string({
24
+ default: 'custom',
25
+ description: 'List Custom templates only, or all templates',
26
+ options: [...TEMPLATE_LIST_TYPES],
27
+ }),
28
+ };
29
+ async run() {
30
+ const { flags } = await this.parse(TemplateList);
31
+ const pagination = buildListPaginationQuery(flags);
32
+ const response = await this.withSpinner('Fetching templates', () => CicdGateway.call({
33
+ endpoint: templatesEndpoint({
34
+ ...pagination,
35
+ fetchAll: flags['fetch-all'] === true ? true : undefined,
36
+ name: flags.name,
37
+ type: flags.type,
38
+ }),
39
+ method: 'GET',
40
+ }));
41
+ const page = normalizeTemplatesListPage(response);
42
+ this.display(() => {
43
+ if (page.data.length === 0) {
44
+ this.log('No templates found.');
45
+ return;
46
+ }
47
+ this.log(formatTemplateTable(page.data));
48
+ displayListPagination(this.log.bind(this), page);
49
+ });
50
+ return page;
51
+ }
52
+ }
53
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1,45 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { buildTemplateUpsertPayload, templateUpsertFlags } from '../../../lib/template-flags.js';
5
+ import { formatTemplateDetail, normalizeTemplate, templateEndpoint, } from '../../../lib/template-types.js';
6
+ export default class TemplateUpsert extends AgentiaCommand {
7
+ static args = {
8
+ 'api-name': Args.string({
9
+ description: 'Template API name',
10
+ required: true,
11
+ }),
12
+ };
13
+ static description = 'Create or update a Copado Job Template by API name (legacy deploy ≈ upsert reading disk or --file)';
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %> MyTemplate_1',
16
+ '<%= config.bin %> <%= command.id %> MyTemplate_1 --file ./copado/templates/MyTemplate_1.metadata.json',
17
+ '<%= config.bin %> <%= command.id %> MyTemplate_1 --name "My Template" --steps-file ./steps.json --json',
18
+ ];
19
+ static flags = templateUpsertFlags;
20
+ async run() {
21
+ const { args, flags } = await this.parse(TemplateUpsert);
22
+ let payload;
23
+ try {
24
+ payload = await buildTemplateUpsertPayload(args['api-name'], flags);
25
+ }
26
+ catch (error) {
27
+ this.error(error instanceof Error ? error.message : String(error), { exit: 2 });
28
+ }
29
+ const response = await this.withSpinner('Upserting template', () => CicdGateway.call({
30
+ body: payload,
31
+ endpoint: templateEndpoint(args['api-name']),
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ },
35
+ method: 'PUT',
36
+ }));
37
+ const template = normalizeTemplate(response);
38
+ this.display(() => {
39
+ this.log(`Upserted template ${template.apiName ?? args['api-name']} (ID: ${template.id ?? 'unknown id'}).`);
40
+ this.log(formatTemplateDetail(template));
41
+ });
42
+ return template;
43
+ }
44
+ }
45
+ //# sourceMappingURL=upsert.js.map
@@ -1,5 +1,7 @@
1
1
  import {modules} from './runtime.js';
2
+ const AdvQuickDeployUnavailableError = modules["adv-operations.js"]["AdvQuickDeployUnavailableError"]
2
3
  const AdvRunFailedError = modules["adv-operations.js"]["AdvRunFailedError"]
4
+ const AdvWaitTimeoutError = modules["adv-operations.js"]["AdvWaitTimeoutError"]
3
5
  const addAdvComponents = modules["adv-operations.js"]["addAdvComponents"]
4
6
  const advRunErrorJson = modules["adv-operations.js"]["advRunErrorJson"]
5
7
  const assertAdvJobSucceeded = modules["adv-operations.js"]["assertAdvJobSucceeded"]
@@ -26,4 +28,4 @@ const selectedAdvComponents = modules["adv-operations.js"]["selectedAdvComponent
26
28
  const updateAdvDeploymentOptions = modules["adv-operations.js"]["updateAdvDeploymentOptions"]
27
29
  const validateAdvOrganization = modules["adv-operations.js"]["validateAdvOrganization"]
28
30
  const waitForAdvJob = modules["adv-operations.js"]["waitForAdvJob"]
29
- export {AdvRunFailedError, addAdvComponents, advRunErrorJson, assertAdvJobSucceeded, cancelAdvDeployment, createAdvDeployment, deriveAdvJobResult, getAdvAuthStatus, getAdvDeployment, getAdvJob, getAdvOrganization, getStoredAdvAuthSummary, listAdvComponentTypes, listAdvComponents, listAdvDeployments, listAdvJobs, listAdvOrganizations, parseAdvComponentSpec, readAdvComponentsFromJsonFile, readAdvComponentsFromTextFile, refreshAdvComponents, removeAdvComponents, runAdvDeploymentAction, selectedAdvComponents, updateAdvDeploymentOptions, validateAdvOrganization, waitForAdvJob};
31
+ export {AdvQuickDeployUnavailableError, AdvRunFailedError, AdvWaitTimeoutError, addAdvComponents, advRunErrorJson, assertAdvJobSucceeded, cancelAdvDeployment, createAdvDeployment, deriveAdvJobResult, getAdvAuthStatus, getAdvDeployment, getAdvJob, getAdvOrganization, getStoredAdvAuthSummary, listAdvComponentTypes, listAdvComponents, listAdvDeployments, listAdvJobs, listAdvOrganizations, parseAdvComponentSpec, readAdvComponentsFromJsonFile, readAdvComponentsFromTextFile, refreshAdvComponents, removeAdvComponents, runAdvDeploymentAction, selectedAdvComponents, updateAdvDeploymentOptions, validateAdvOrganization, waitForAdvJob};
@@ -4,8 +4,42 @@ import { createTransactionId, runWithGatewayTransactionContext } from './cicd-ga
4
4
  import { colorizeCliSeverityError, colorizeCliSeverityText } from './cli-severity-color.js';
5
5
  import { isCommandOutputCaptureActive } from './command-output-buffer.js';
6
6
  import { rememberIdeCommandError } from './ide-command-events.js';
7
+ import { redactErrorMessage, redactSecrets } from './secret-redaction.js';
7
8
  const TRANSACTION_ID_REPORTED = Symbol('agentiaTransactionIdReported');
8
9
  const EXPERIMENTAL_COMMAND_WARNING = 'This command is experimental and may change without notice.';
10
+ const SAFE_ERROR_FIELDS = [
11
+ 'categories',
12
+ 'code',
13
+ 'requestMethod',
14
+ 'requestUrl',
15
+ 'retryAfterSeconds',
16
+ 'statusCode',
17
+ 'suggestions',
18
+ ];
19
+ function recordValue(value) {
20
+ return typeof value === 'object' && value !== null ? value : {};
21
+ }
22
+ function safeErrorJson(err, base) {
23
+ const baseError = recordValue(base.error);
24
+ const source = recordValue(err);
25
+ const error = {
26
+ message: redactErrorMessage(err),
27
+ name: typeof baseError.name === 'string'
28
+ ? baseError.name
29
+ : err instanceof Error && err.name.length > 0
30
+ ? err.name
31
+ : 'Error',
32
+ };
33
+ for (const field of SAFE_ERROR_FIELDS) {
34
+ const value = source[field] ?? baseError[field];
35
+ if (value !== undefined)
36
+ error[field] = redactSecrets(value);
37
+ }
38
+ const oclif = recordValue(baseError.oclif);
39
+ if (typeof oclif.exit === 'number')
40
+ error.oclif = { exit: oclif.exit };
41
+ return error;
42
+ }
9
43
  export function elapsedSecondsSince(startedAtMs, nowMs = Date.now()) {
10
44
  return Math.max(0, Math.floor((nowMs - startedAtMs) / 1000));
11
45
  }
@@ -76,6 +110,7 @@ export class AgentiaCommand extends Command {
76
110
  const warnings = this.jsonWarnings();
77
111
  return {
78
112
  ...base,
113
+ error: safeErrorJson(err, base),
79
114
  ...(warnings.length > 0 ? { warnings } : {}),
80
115
  transactionId: this.commandTransactionId,
81
116
  };
@@ -10,6 +10,20 @@ const componentReferenceSchema = z.union([
10
10
  }),
11
11
  ]);
12
12
  const componentInputSchema = z.array(componentReferenceSchema).min(1).describe('Components as Type/Name strings or {type, fullName, excluded} objects.');
13
+ const deploymentIdSchema = z.number().int().positive().describe('Deployment ID.');
14
+ const deploymentIdInputSchema = {
15
+ deploymentId: deploymentIdSchema.optional().describe('Canonical deployment ID.'),
16
+ flow: deploymentIdSchema.optional().describe('Deprecated alias for deploymentId.'),
17
+ id: deploymentIdSchema.optional().describe('Deprecated alias for deploymentId.'),
18
+ };
19
+ function resolveDeploymentId(input) {
20
+ const supplied = [input.deploymentId, input.id, input.flow].filter((value) => value !== undefined);
21
+ if (supplied.length === 0)
22
+ throw new Error('Provide deploymentId.');
23
+ if (new Set(supplied).size !== 1)
24
+ throw new Error('Deployment ID aliases must have the same value.');
25
+ return supplied[0];
26
+ }
13
27
  function componentList(components) {
14
28
  return components.map((component) => {
15
29
  if (typeof component === 'string')
@@ -30,7 +44,7 @@ async function deploymentAction(args) {
30
44
  return {
31
45
  result: await runAdvDeploymentAction({
32
46
  backup: args.backup,
33
- id: args.id,
47
+ id: resolveDeploymentId(args),
34
48
  kind: args.kind,
35
49
  wait: args.wait,
36
50
  waitIntervalSeconds: args.interval,
@@ -66,9 +80,9 @@ export function registerAgentiaMcpAdvTools(server) {
66
80
  }, (args) => safelyHandleTool(async () => ({ result: await listAdvDeployments({ includeArchived: args.includeArchived }) })));
67
81
  server.registerTool('agentia_adv_deployment_get', {
68
82
  description: 'Get one Copado Pipelines Advanced deployment.',
69
- inputSchema: { id: z.number().int().positive().describe('Deployment ID.') },
83
+ inputSchema: deploymentIdInputSchema,
70
84
  title: 'Agentia ADV Deployment Get',
71
- }, (args) => safelyHandleTool(async () => ({ result: await getAdvDeployment(args.id) })));
85
+ }, (args) => safelyHandleTool(async () => ({ result: await getAdvDeployment(resolveDeploymentId(args)) })));
72
86
  server.registerTool('agentia_adv_deployment_create', {
73
87
  description: 'Create a Copado Pipelines Advanced deployment.',
74
88
  inputSchema: {
@@ -81,15 +95,15 @@ export function registerAgentiaMcpAdvTools(server) {
81
95
  server.registerTool('agentia_adv_deployment_options', {
82
96
  description: 'Update Copado Pipelines Advanced deployment options.',
83
97
  inputSchema: {
84
- id: z.number().int().positive().describe('Deployment ID.'),
98
+ ...deploymentIdInputSchema,
85
99
  set: z.array(z.string()).optional().describe('Options as name=value entries; booleans, null, and finite JavaScript Number values are converted.'),
86
100
  },
87
101
  title: 'Agentia ADV Deployment Options',
88
- }, (args) => safelyHandleTool(async () => ({ result: await updateAdvDeploymentOptions({ id: args.id, set: args.set }) })));
102
+ }, (args) => safelyHandleTool(async () => ({ result: await updateAdvDeploymentOptions({ id: resolveDeploymentId(args), set: args.set }) })));
89
103
  server.registerTool('agentia_adv_deployment_validate', {
90
104
  description: 'Start a check-only Copado Pipelines Advanced validation run.',
91
105
  inputSchema: {
92
- id: z.number().int().positive().describe('Deployment ID.'),
106
+ ...deploymentIdInputSchema,
93
107
  interval: z.number().positive().optional().describe('Seconds between polls when wait is true.'),
94
108
  timeout: z.number().positive().optional().describe('Maximum seconds to wait.'),
95
109
  wait: z.boolean().optional().describe('Wait for the run to finish.'),
@@ -100,7 +114,7 @@ export function registerAgentiaMcpAdvTools(server) {
100
114
  description: 'Start a real Copado Pipelines Advanced deployment run.',
101
115
  inputSchema: {
102
116
  confirm: z.boolean().optional().describe('Required true to start a deployment.'),
103
- id: z.number().int().positive().describe('Deployment ID.'),
117
+ ...deploymentIdInputSchema,
104
118
  interval: z.number().positive().optional().describe('Seconds between polls when wait is true.'),
105
119
  timeout: z.number().positive().optional().describe('Maximum seconds to wait.'),
106
120
  wait: z.boolean().optional().describe('Wait for the run to finish.'),
@@ -112,7 +126,7 @@ export function registerAgentiaMcpAdvTools(server) {
112
126
  inputSchema: {
113
127
  backup: z.boolean().optional().describe('Run backupThenDeploy instead of a quick deploy.'),
114
128
  confirm: z.boolean().optional().describe('Required true to start a quick deploy.'),
115
- id: z.number().int().positive().describe('Deployment ID.'),
129
+ ...deploymentIdInputSchema,
116
130
  interval: z.number().positive().optional().describe('Seconds between polls when wait is true.'),
117
131
  timeout: z.number().positive().optional().describe('Maximum seconds to wait.'),
118
132
  wait: z.boolean().optional().describe('Wait for the run to finish.'),
@@ -123,7 +137,7 @@ export function registerAgentiaMcpAdvTools(server) {
123
137
  description: 'Cancel the current Copado Pipelines Advanced run.',
124
138
  inputSchema: {
125
139
  confirm: z.boolean().optional().describe('Required true to request cancellation.'),
126
- id: z.number().int().positive().describe('Deployment ID.'),
140
+ ...deploymentIdInputSchema,
127
141
  interval: z.number().positive().optional().describe('Seconds between polls when wait is true.'),
128
142
  timeout: z.number().positive().optional().describe('Maximum seconds to wait.'),
129
143
  wait: z.boolean().optional().describe('Wait for the run to finish.'),
@@ -133,7 +147,7 @@ export function registerAgentiaMcpAdvTools(server) {
133
147
  requireConfirm(args.confirm, 'Pipelines Advanced deployment cancellation');
134
148
  return {
135
149
  result: await cancelAdvDeployment({
136
- id: args.id,
150
+ id: resolveDeploymentId(args),
137
151
  wait: args.wait,
138
152
  waitIntervalSeconds: args.interval,
139
153
  waitTimeoutSeconds: args.timeout,
@@ -148,37 +162,37 @@ export function registerAgentiaMcpAdvTools(server) {
148
162
  server.registerTool('agentia_adv_component_list', {
149
163
  description: 'List source components for a Copado Pipelines Advanced deployment.',
150
164
  inputSchema: {
151
- flow: z.number().int().positive().describe('Deployment ID.'),
165
+ ...deploymentIdInputSchema,
152
166
  includeManagedPackage: z.boolean().optional().describe('Include managed package components.'),
153
167
  type: z.string().describe('Comma-separated component type names.'),
154
168
  },
155
169
  title: 'Agentia ADV Component List',
156
- }, (args) => safelyHandleTool(async () => ({ result: await listAdvComponents(args) })));
170
+ }, (args) => safelyHandleTool(async () => ({ result: await listAdvComponents({ ...args, flow: resolveDeploymentId(args) }) })));
157
171
  server.registerTool('agentia_adv_component_refresh', {
158
172
  description: 'Refresh Copado Pipelines Advanced component comparison cache.',
159
173
  inputSchema: {
160
- flow: z.number().int().positive().describe('Deployment ID.'),
174
+ ...deploymentIdInputSchema,
161
175
  full: z.boolean().optional().describe('Delete cached comparison data before refreshing.'),
162
176
  type: z.string().describe('Comma-separated component type names.'),
163
177
  },
164
178
  title: 'Agentia ADV Component Refresh',
165
- }, (args) => safelyHandleTool(async () => ({ result: await refreshAdvComponents(args) })));
179
+ }, (args) => safelyHandleTool(async () => ({ result: await refreshAdvComponents({ ...args, flow: resolveDeploymentId(args) }) })));
166
180
  server.registerTool('agentia_adv_component_selected', {
167
181
  description: 'List selected components for a Copado Pipelines Advanced deployment.',
168
- inputSchema: { deploymentId: z.number().int().positive().describe('Deployment ID.') },
182
+ inputSchema: deploymentIdInputSchema,
169
183
  title: 'Agentia ADV Component Selected',
170
- }, (args) => safelyHandleTool(async () => ({ result: await selectedAdvComponents(args.deploymentId) })));
184
+ }, (args) => safelyHandleTool(async () => ({ result: await selectedAdvComponents(resolveDeploymentId(args)) })));
171
185
  server.registerTool('agentia_adv_component_add', {
172
186
  description: 'Add components to a Copado Pipelines Advanced deployment selection.',
173
187
  inputSchema: {
174
188
  components: componentInputSchema,
175
- deploymentId: z.number().int().positive().describe('Deployment ID.'),
189
+ ...deploymentIdInputSchema,
176
190
  },
177
191
  title: 'Agentia ADV Component Add',
178
192
  }, (args) => safelyHandleTool(async () => ({
179
193
  result: await addAdvComponents({
180
194
  components: componentList(args.components),
181
- deploymentId: args.deploymentId,
195
+ deploymentId: resolveDeploymentId(args),
182
196
  mode: componentAddMode(args.components),
183
197
  }),
184
198
  })));
@@ -186,37 +200,37 @@ export function registerAgentiaMcpAdvTools(server) {
186
200
  description: 'Remove components from a Copado Pipelines Advanced deployment selection.',
187
201
  inputSchema: {
188
202
  components: componentInputSchema,
189
- deploymentId: z.number().int().positive().describe('Deployment ID.'),
203
+ ...deploymentIdInputSchema,
190
204
  },
191
205
  title: 'Agentia ADV Component Remove',
192
206
  }, (args) => safelyHandleTool(async () => ({
193
- result: await removeAdvComponents({ components: componentList(args.components), deploymentId: args.deploymentId }),
207
+ result: await removeAdvComponents({ components: componentList(args.components), deploymentId: resolveDeploymentId(args) }),
194
208
  })));
195
209
  server.registerTool('agentia_adv_job_get', {
196
210
  description: 'Get the latest Copado Pipelines Advanced run for a deployment.',
197
- inputSchema: { deploymentId: z.number().int().positive().describe('Deployment ID.') },
211
+ inputSchema: deploymentIdInputSchema,
198
212
  title: 'Agentia ADV Job Get',
199
- }, (args) => safelyHandleTool(async () => ({ result: await getAdvJob(args.deploymentId) })));
213
+ }, (args) => safelyHandleTool(async () => ({ result: await getAdvJob(resolveDeploymentId(args)) })));
200
214
  server.registerTool('agentia_adv_job_list', {
201
215
  description: 'List Copado Pipelines Advanced run history for a deployment.',
202
216
  inputSchema: {
203
- deploymentId: z.number().int().positive().describe('Deployment ID.'),
217
+ ...deploymentIdInputSchema,
204
218
  page: z.number().int().min(0).optional().describe('Page number starting at 0.'),
205
219
  pageSize: z.number().int().positive().optional().describe('Rows per page.'),
206
220
  },
207
221
  title: 'Agentia ADV Job List',
208
- }, (args) => safelyHandleTool(async () => ({ result: await listAdvJobs(args) })));
222
+ }, (args) => safelyHandleTool(async () => ({ result: await listAdvJobs({ ...args, deploymentId: resolveDeploymentId(args) }) })));
209
223
  server.registerTool('agentia_adv_job_wait', {
210
224
  description: 'Wait for the latest Copado Pipelines Advanced run to finish.',
211
225
  inputSchema: {
212
- deploymentId: z.number().int().positive().describe('Deployment ID.'),
226
+ ...deploymentIdInputSchema,
213
227
  interval: z.number().positive().optional().describe('Seconds between polls.'),
214
228
  timeout: z.number().positive().optional().describe('Maximum seconds to wait.'),
215
229
  },
216
230
  title: 'Agentia ADV Job Wait',
217
231
  }, (args) => safelyHandleTool(async () => {
218
232
  const result = await waitForAdvJob({
219
- deploymentId: args.deploymentId,
233
+ deploymentId: resolveDeploymentId(args),
220
234
  intervalSeconds: args.interval,
221
235
  timeoutSeconds: args.timeout,
222
236
  });
@@ -93,6 +93,7 @@ const DELETE_TOOLS = [
93
93
  'agentia_data_filter_delete',
94
94
  'agentia_data_template_delete',
95
95
  'agentia_function_delete',
96
+ 'agentia_template_delete',
96
97
  'agentia_pipeline_connection_delete',
97
98
  'agentia_pipeline_stage_connection_delete',
98
99
  'agentia_project_delete',
@@ -146,6 +147,9 @@ const READ_TOOLS = [
146
147
  'agentia_function_list',
147
148
  'agentia_function_result_get',
148
149
  'agentia_function_result_log_get',
150
+ 'agentia_template_defaults',
151
+ 'agentia_template_get',
152
+ 'agentia_template_list',
149
153
  'agentia_health_check',
150
154
  'agentia_job_get',
151
155
  'agentia_job_list',
@@ -226,6 +230,7 @@ const UPDATE_TOOLS = [
226
230
  'agentia_data_template_save_detail',
227
231
  'agentia_environment_update',
228
232
  'agentia_function_upsert',
233
+ 'agentia_template_upsert',
229
234
  'agentia_pipeline_connection_update',
230
235
  'agentia_pipeline_stage_connection_update',
231
236
  'agentia_pipeline_update',