@copado/agentia-cli 0.42.0-alpha.0 → 0.45.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 (75) hide show
  1. package/README.md +471 -106
  2. package/dist/commands/ai/agent/ask.d.ts +28 -0
  3. package/dist/commands/ai/agent/ask.js +124 -0
  4. package/dist/commands/ai/agent/ask.js.map +1 -0
  5. package/dist/commands/ai/agent/chat.d.ts +29 -0
  6. package/dist/commands/ai/agent/chat.js +97 -0
  7. package/dist/commands/ai/agent/chat.js.map +1 -0
  8. package/dist/commands/auth/get.d.ts +3 -0
  9. package/dist/commands/auth/get.js +46 -1
  10. package/dist/commands/auth/get.js.map +1 -1
  11. package/dist/commands/auth/set.d.ts +5 -0
  12. package/dist/commands/auth/set.js +39 -0
  13. package/dist/commands/auth/set.js.map +1 -1
  14. package/dist/commands/auth/unset.d.ts +1 -0
  15. package/dist/commands/auth/unset.js +4 -0
  16. package/dist/commands/auth/unset.js.map +1 -1
  17. package/dist/commands/cicd/repository/create.d.ts +25 -0
  18. package/dist/commands/cicd/repository/create.js +45 -0
  19. package/dist/commands/cicd/repository/create.js.map +1 -0
  20. package/dist/commands/cicd/repository/delete.d.ts +11 -0
  21. package/dist/commands/cicd/repository/delete.js +29 -0
  22. package/dist/commands/cicd/repository/delete.js.map +1 -0
  23. package/dist/commands/cicd/repository/get.d.ts +10 -0
  24. package/dist/commands/cicd/repository/get.js +30 -0
  25. package/dist/commands/cicd/repository/get.js.map +1 -0
  26. package/dist/commands/cicd/repository/list.d.ts +8 -0
  27. package/dist/commands/cicd/repository/list.js +26 -0
  28. package/dist/commands/cicd/repository/list.js.map +1 -0
  29. package/dist/commands/cicd/repository/reset.d.ts +12 -0
  30. package/dist/commands/cicd/repository/reset.js +29 -0
  31. package/dist/commands/cicd/repository/reset.js.map +1 -0
  32. package/dist/commands/cicd/repository/update.d.ts +34 -0
  33. package/dist/commands/cicd/repository/update.js +64 -0
  34. package/dist/commands/cicd/repository/update.js.map +1 -0
  35. package/dist/commands/cicd/repository/validate.d.ts +10 -0
  36. package/dist/commands/cicd/repository/validate.js +33 -0
  37. package/dist/commands/cicd/repository/validate.js.map +1 -0
  38. package/dist/lib/ai-chat-session.d.ts +17 -0
  39. package/dist/lib/ai-chat-session.js +144 -0
  40. package/dist/lib/ai-chat-session.js.map +1 -0
  41. package/dist/lib/ai-config.d.ts +26 -0
  42. package/dist/lib/ai-config.js +113 -0
  43. package/dist/lib/ai-config.js.map +1 -0
  44. package/dist/lib/ai-gateway.d.ts +48 -0
  45. package/dist/lib/ai-gateway.js +298 -0
  46. package/dist/lib/ai-gateway.js.map +1 -0
  47. package/dist/lib/ai-operations.d.ts +26 -0
  48. package/dist/lib/ai-operations.js +177 -0
  49. package/dist/lib/ai-operations.js.map +1 -0
  50. package/dist/lib/ai-stream-parser.d.ts +12 -0
  51. package/dist/lib/ai-stream-parser.js +59 -0
  52. package/dist/lib/ai-stream-parser.js.map +1 -0
  53. package/dist/lib/ai-types.d.ts +80 -0
  54. package/dist/lib/ai-types.js +66 -0
  55. package/dist/lib/ai-types.js.map +1 -0
  56. package/dist/lib/auth-config.d.ts +21 -0
  57. package/dist/lib/auth-config.js +158 -6
  58. package/dist/lib/auth-config.js.map +1 -1
  59. package/dist/lib/credential-store.d.ts +13 -1
  60. package/dist/lib/credential-store.js +47 -2
  61. package/dist/lib/credential-store.js.map +1 -1
  62. package/dist/lib/mcp/ai-tools.d.ts +22 -0
  63. package/dist/lib/mcp/ai-tools.js +45 -0
  64. package/dist/lib/mcp/ai-tools.js.map +1 -0
  65. package/dist/lib/mcp/tools.d.ts +77 -2
  66. package/dist/lib/mcp/tools.js +169 -0
  67. package/dist/lib/mcp/tools.js.map +1 -1
  68. package/dist/lib/repository-flags.d.ts +117 -0
  69. package/dist/lib/repository-flags.js +208 -0
  70. package/dist/lib/repository-flags.js.map +1 -0
  71. package/dist/lib/repository-types.d.ts +94 -0
  72. package/dist/lib/repository-types.js +110 -0
  73. package/dist/lib/repository-types.js.map +1 -0
  74. package/oclif.manifest.json +891 -1
  75. package/package.json +10 -1
@@ -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 { buildRepositoryCreatePayload, REPOSITORY_STRING_VALIDATION_KEYS, repositoryCreateFlags, validateNonEmptyStringFields, validateRepositoryMutationFlags, } from '../../../lib/repository-flags.js';
5
+ import { normalizeRepository, repositoriesEndpoint, } from '../../../lib/repository-types.js';
6
+ export default class RepositoryCreate extends AgentiaCommand {
7
+ static args = {
8
+ name: Args.string({
9
+ description: 'Name of the Copado Git repository to create',
10
+ required: true,
11
+ }),
12
+ };
13
+ static description = 'Create a Copado Git repository';
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %> my-repo --source-format DX --provider Github --uri https://github.com/org/repo.git',
16
+ '<%= config.bin %> <%= command.id %> my-repo --source-format DX --provider Gitlab --json',
17
+ ];
18
+ static flags = repositoryCreateFlags;
19
+ async run() {
20
+ const { args, flags } = await this.parse(RepositoryCreate);
21
+ const flagError = validateRepositoryMutationFlags(flags);
22
+ if (flagError !== undefined) {
23
+ this.error(flagError, { exit: 2 });
24
+ }
25
+ const payload = buildRepositoryCreatePayload(args.name, flags);
26
+ const validationError = validateNonEmptyStringFields(payload, REPOSITORY_STRING_VALIDATION_KEYS);
27
+ if (validationError !== undefined) {
28
+ this.error(validationError, { exit: 2 });
29
+ }
30
+ const response = await this.withSpinner('Creating repository', () => CicdGateway.call({
31
+ body: payload,
32
+ endpoint: repositoriesEndpoint(),
33
+ headers: {
34
+ 'Content-Type': 'application/json',
35
+ },
36
+ method: 'POST',
37
+ }));
38
+ const repository = normalizeRepository(response);
39
+ this.display(() => {
40
+ this.log(`Created repository ${repository.name ?? args.name} (ID: ${repository.id ?? 'unknown id'}).`);
41
+ });
42
+ return repository;
43
+ }
44
+ }
45
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EACL,4BAA4B,EAC5B,iCAAiC,EACjC,qBAAqB,EACrB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAEL,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,kCAAkC,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAU,IAAI,GAAG;QACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,gCAAgC,CAAA;IAC9D,MAAM,CAAU,QAAQ,GAAG;QACzB,wHAAwH;QACxH,yFAAyF;KAC1F,CAAA;IACD,MAAM,CAAU,KAAK,GAAG,qBAAqB,CAAA;IAEtC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QACxD,MAAM,SAAS,GAAG,+BAA+B,CAAC,KAAK,CAAC,CAAA;QAExD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAA;QAClC,CAAC;QAED,MAAM,OAAO,GAAG,4BAA4B,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC9D,MAAM,eAAe,GAAG,4BAA4B,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAA;QAEhG,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,CAAC,CAAA;QACxC,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAClE,WAAW,CAAC,IAAI,CAAqC;YACnD,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,oBAAoB,EAAE;YAChC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,MAAM;SACf,CAAC,CACH,CAAA;QACD,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QAEhD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,SAAS,UAAU,CAAC,EAAE,IAAI,YAAY,IAAI,CAAC,CAAA;QACxG,CAAC,CAAC,CAAA;QAEF,OAAO,UAAU,CAAA;IACnB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ export default class RepositoryDelete extends AgentiaCommand {
3
+ static args: {
4
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ run(): Promise<{
9
+ id: string;
10
+ }>;
11
+ }
@@ -0,0 +1,29 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { repositoryEndpoint } from '../../../lib/repository-types.js';
5
+ export default class RepositoryDelete extends AgentiaCommand {
6
+ static args = {
7
+ id: Args.string({
8
+ description: 'Copado Git repository ID',
9
+ required: true,
10
+ }),
11
+ };
12
+ static description = 'Delete a Copado Git repository by ID';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> repo-001',
15
+ '<%= config.bin %> <%= command.id %> repo-001 --json',
16
+ ];
17
+ async run() {
18
+ const { args } = await this.parse(RepositoryDelete);
19
+ await this.withSpinner('Deleting repository', () => CicdGateway.call({
20
+ endpoint: repositoryEndpoint(args.id),
21
+ method: 'DELETE',
22
+ }));
23
+ this.display(() => {
24
+ this.log(`Deleted repository (ID: ${args.id}).`);
25
+ });
26
+ return { id: args.id };
27
+ }
28
+ }
29
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,kCAAkC,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,sCAAsC,CAAA;IACpE,MAAM,CAAU,QAAQ,GAAG;QACzB,8CAA8C;QAC9C,qDAAqD;KACtD,CAAA;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAEjD,MAAM,IAAI,CAAC,WAAW,CAAC,qBAAqB,EAAE,GAAG,EAAE,CACjD,WAAW,CAAC,IAAI,CAAO;YACrB,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,MAAM,EAAE,QAAQ;SACjB,CAAC,CACH,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,2BAA2B,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;QAEF,OAAO,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAC,CAAA;IACtB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { type GitRepository } from '../../../lib/repository-types.js';
3
+ export default class RepositoryGet extends AgentiaCommand {
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ run(): Promise<GitRepository>;
10
+ }
@@ -0,0 +1,30 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { formatRepositoryDetail, normalizeRepository, repositoryEndpoint, } from '../../../lib/repository-types.js';
5
+ export default class RepositoryGet extends AgentiaCommand {
6
+ static args = {
7
+ id: Args.string({
8
+ description: 'Copado Git repository ID',
9
+ required: true,
10
+ }),
11
+ };
12
+ static description = 'Get a Copado Git repository by ID';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> repo-001',
15
+ '<%= config.bin %> <%= command.id %> repo-001 --json',
16
+ ];
17
+ async run() {
18
+ const { args } = await this.parse(RepositoryGet);
19
+ const response = await this.withSpinner('Fetching repository', () => CicdGateway.call({
20
+ endpoint: repositoryEndpoint(args.id),
21
+ method: 'GET',
22
+ }));
23
+ const repository = normalizeRepository(response);
24
+ this.display(() => {
25
+ this.log(formatRepositoryDetail(repository));
26
+ });
27
+ return repository;
28
+ }
29
+ }
30
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EACL,sBAAsB,EAEtB,mBAAmB,EACnB,kBAAkB,GAEnB,MAAM,kCAAkC,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,cAAc;IACvD,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,mCAAmC,CAAA;IACjE,MAAM,CAAU,QAAQ,GAAG;QACzB,8CAA8C;QAC9C,qDAAqD;KACtD,CAAA;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAE9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAClE,WAAW,CAAC,IAAI,CAAqC;YACnD,QAAQ,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,MAAM,EAAE,KAAK;SACd,CAAC,CACH,CAAA;QACD,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QAEhD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;QAEF,OAAO,UAAU,CAAA;IACnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { type PaginatedListResult } from '../../../lib/list-pagination.js';
3
+ import { type GitRepository } from '../../../lib/repository-types.js';
4
+ export default class RepositoryList extends AgentiaCommand {
5
+ static description: string;
6
+ static examples: string[];
7
+ run(): Promise<PaginatedListResult<GitRepository>>;
8
+ }
@@ -0,0 +1,26 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
3
+ import { displayListPagination } from '../../../lib/list-pagination.js';
4
+ import { formatRepositoryTable, normalizeRepositoriesListPage, repositoriesEndpoint, } from '../../../lib/repository-types.js';
5
+ export default class RepositoryList extends AgentiaCommand {
6
+ static description = 'List Copado Git repositories';
7
+ static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --json'];
8
+ async run() {
9
+ await this.parse(RepositoryList);
10
+ const response = await this.withSpinner('Fetching repositories', () => CicdGateway.call({
11
+ endpoint: repositoriesEndpoint(),
12
+ method: 'GET',
13
+ }));
14
+ const page = normalizeRepositoriesListPage(response);
15
+ this.display(() => {
16
+ if (page.data.length === 0) {
17
+ this.log('No repositories found.');
18
+ return;
19
+ }
20
+ this.log(formatRepositoryTable(page.data));
21
+ displayListPagination(this.log.bind(this), page);
22
+ });
23
+ return page;
24
+ }
25
+ }
26
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,qBAAqB,EAA2B,MAAM,iCAAiC,CAAA;AAC/F,OAAO,EACL,qBAAqB,EAErB,6BAA6B,EAC7B,oBAAoB,GAErB,MAAM,kCAAkC,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,cAAc;IACxD,MAAM,CAAU,WAAW,GAAG,8BAA8B,CAAA;IAC5D,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,EAAE,4CAA4C,CAAC,CAAA;IAEzG,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAEhC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,uBAAuB,EAAE,GAAG,EAAE,CACpE,WAAW,CAAC,IAAI,CAA2B;YACzC,QAAQ,EAAE,oBAAoB,EAAE;YAChC,MAAM,EAAE,KAAK;SACd,CAAC,CACH,CAAA;QACD,MAAM,IAAI,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAA;QAEpD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;gBAClC,OAAM;YACR,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC1C,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ export default class RepositoryReset extends AgentiaCommand {
3
+ static args: {
4
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ run(): Promise<{
9
+ id: string;
10
+ reset: true;
11
+ }>;
12
+ }
@@ -0,0 +1,29 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { repositoryResetEndpoint } from '../../../lib/repository-types.js';
5
+ export default class RepositoryReset extends AgentiaCommand {
6
+ static args = {
7
+ id: Args.string({
8
+ description: 'Copado Git repository ID',
9
+ required: true,
10
+ }),
11
+ };
12
+ static description = 'Reset a Copado Git repository';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> repo-001',
15
+ '<%= config.bin %> <%= command.id %> repo-001 --json',
16
+ ];
17
+ async run() {
18
+ const { args } = await this.parse(RepositoryReset);
19
+ await this.withSpinner('Resetting repository', () => CicdGateway.call({
20
+ endpoint: repositoryResetEndpoint(args.id),
21
+ method: 'PUT',
22
+ }));
23
+ this.display(() => {
24
+ this.log(`Reset repository (ID: ${args.id}).`);
25
+ });
26
+ return { id: args.id, reset: true };
27
+ }
28
+ }
29
+ //# sourceMappingURL=reset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/reset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,uBAAuB,EAAC,MAAM,kCAAkC,CAAA;AAExE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,cAAc;IACzD,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,+BAA+B,CAAA;IAC7D,MAAM,CAAU,QAAQ,GAAG;QACzB,8CAA8C;QAC9C,qDAAqD;KACtD,CAAA;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;QAEhD,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAClD,WAAW,CAAC,IAAI,CAAO;YACrB,QAAQ,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,EAAE,KAAK;SACd,CAAC,CACH,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,yBAAyB,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;QAEF,OAAO,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAC,CAAA;IACnC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { type GitRepository } from '../../../lib/repository-types.js';
3
+ export default class RepositoryUpdate extends AgentiaCommand {
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ readonly name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ readonly provider: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ readonly 'source-format': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ readonly 'auth-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ readonly 'branch-base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ readonly 'commit-base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ readonly 'extra-headers': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ readonly password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ readonly 'pull-request-base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ readonly 'tag-base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ readonly uri: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ readonly username: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ readonly 'clear-branch-base-url': import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
+ readonly 'clear-commit-base-url': import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
+ readonly 'clear-extra-headers': import("@oclif/core/interfaces").BooleanFlag<boolean>;
25
+ readonly 'clear-password': import("@oclif/core/interfaces").BooleanFlag<boolean>;
26
+ readonly 'clear-pull-request-base-url': import("@oclif/core/interfaces").BooleanFlag<boolean>;
27
+ readonly 'clear-tag-base-url': import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
+ readonly 'clear-uri': import("@oclif/core/interfaces").BooleanFlag<boolean>;
29
+ readonly 'clear-username': import("@oclif/core/interfaces").BooleanFlag<boolean>;
30
+ readonly 'allow-functions-git-cache': import("@oclif/core/interfaces").BooleanFlag<boolean>;
31
+ readonly 'copado-tunnel-enabled': import("@oclif/core/interfaces").BooleanFlag<boolean>;
32
+ };
33
+ run(): Promise<GitRepository>;
34
+ }
@@ -0,0 +1,64 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { buildRepositoryMutationPayload, collectRepositoryMutationFlagKeys, REPOSITORY_STRING_VALIDATION_KEYS, repositoryUpdateFlags, validateNonEmptyStringFields, validateRepositoryMutationFlags, } from '../../../lib/repository-flags.js';
5
+ import { normalizeRepository, repositoryEndpoint, withRequiredRepositoryFields, } from '../../../lib/repository-types.js';
6
+ export default class RepositoryUpdate extends AgentiaCommand {
7
+ static args = {
8
+ id: Args.string({
9
+ description: 'Copado Git repository ID',
10
+ required: true,
11
+ }),
12
+ };
13
+ static description = 'Update a Copado Git repository by ID';
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %> repo-001 --uri https://github.com/org/repo.git',
16
+ '<%= config.bin %> <%= command.id %> repo-001 --clear-password',
17
+ '<%= config.bin %> <%= command.id %> repo-001 --provider Gitlab --json',
18
+ ];
19
+ static flags = repositoryUpdateFlags;
20
+ async run() {
21
+ const { args, flags } = await this.parse(RepositoryUpdate);
22
+ const selectedKeys = collectRepositoryMutationFlagKeys(flags);
23
+ if (selectedKeys.length === 0) {
24
+ this.error('Must provide at least one flag to update.', {
25
+ exit: 2,
26
+ suggestions: [
27
+ `${this.config.bin} cicd repository update ${args.id} --uri <uri>`,
28
+ `${this.config.bin} cicd repository update ${args.id} --clear-password`,
29
+ ],
30
+ });
31
+ }
32
+ const flagError = validateRepositoryMutationFlags(flags);
33
+ if (flagError !== undefined) {
34
+ this.error(flagError, { exit: 2 });
35
+ }
36
+ const currentRepository = await this.withSpinner('Fetching repository', () => CicdGateway.call({
37
+ endpoint: repositoryEndpoint(args.id),
38
+ method: 'GET',
39
+ }));
40
+ const current = normalizeRepository(currentRepository);
41
+ const payload = withRequiredRepositoryFields(buildRepositoryMutationPayload(flags), current);
42
+ const validationError = validateNonEmptyStringFields(payload, REPOSITORY_STRING_VALIDATION_KEYS);
43
+ if (payload.name === undefined ||
44
+ payload.sourceFormat === undefined ||
45
+ payload.provider === undefined ||
46
+ validationError !== undefined) {
47
+ this.error('Repository name, source format, and provider are required to update a repository.', { exit: 2 });
48
+ }
49
+ const response = await this.withSpinner('Updating repository', () => CicdGateway.call({
50
+ body: payload,
51
+ endpoint: repositoryEndpoint(args.id),
52
+ headers: {
53
+ 'Content-Type': 'application/json',
54
+ },
55
+ method: 'PATCH',
56
+ }));
57
+ const repository = normalizeRepository(response);
58
+ this.display(() => {
59
+ this.log(`Updated repository ${repository.name ?? payload.name} (ID: ${repository.id ?? args.id}).`);
60
+ });
61
+ return repository;
62
+ }
63
+ }
64
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EACjC,iCAAiC,EACjC,qBAAqB,EACrB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAEL,mBAAmB,EACnB,kBAAkB,EAElB,4BAA4B,GAC7B,MAAM,kCAAkC,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,sCAAsC,CAAA;IACpE,MAAM,CAAU,QAAQ,GAAG;QACzB,oFAAoF;QACpF,+DAA+D;QAC/D,uEAAuE;KACxE,CAAA;IACD,MAAM,CAAU,KAAK,GAAG,qBAAqB,CAAA;IAEtC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QACxD,MAAM,YAAY,GAAG,iCAAiC,CAAC,KAAK,CAAC,CAAA;QAE7D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,CAAC,2CAA2C,EAAE;gBACtD,IAAI,EAAE,CAAC;gBACP,WAAW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AE,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,MAAM,EAAE,OAAO;SAChB,CAAC,CACH,CAAA;QACD,MAAM,UAAU,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QAEhD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,sBAAsB,UAAU,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,SAAS,UAAU,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QACtG,CAAC,CAAC,CAAA;QAEF,OAAO,UAAU,CAAA;IACnB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
2
+ import { type RepositoryValidateResult } from '../../../lib/repository-types.js';
3
+ export default class RepositoryValidate extends AgentiaCommand {
4
+ static args: {
5
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ run(): Promise<RepositoryValidateResult>;
10
+ }
@@ -0,0 +1,33 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AgentiaCommand } from '../../../lib/agentia-command.js';
3
+ import { CicdGateway } from '../../../lib/cicd-gateway.js';
4
+ import { normalizeRepositoryValidateResult, repositoryValidateEndpoint, } from '../../../lib/repository-types.js';
5
+ export default class RepositoryValidate extends AgentiaCommand {
6
+ static args = {
7
+ id: Args.string({
8
+ description: 'Copado Git repository ID',
9
+ required: true,
10
+ }),
11
+ };
12
+ static description = 'Validate Copado Git repository authentication';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> repo-001',
15
+ '<%= config.bin %> <%= command.id %> repo-001 --json',
16
+ ];
17
+ async run() {
18
+ const { args } = await this.parse(RepositoryValidate);
19
+ const response = await this.withSpinner('Validating repository', () => CicdGateway.call({
20
+ endpoint: repositoryValidateEndpoint(args.id),
21
+ method: 'POST',
22
+ }));
23
+ const result = normalizeRepositoryValidateResult(response);
24
+ this.display(() => {
25
+ this.log(`Repository validation ${result.validated ? 'succeeded' : 'failed'}.`);
26
+ if (result.message !== null && result.message !== undefined && result.message.trim().length > 0) {
27
+ this.log(result.message);
28
+ }
29
+ });
30
+ return result;
31
+ }
32
+ }
33
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/commands/cicd/repository/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EACL,iCAAiC,EACjC,0BAA0B,GAG3B,MAAM,kCAAkC,CAAA;AAEzC,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,cAAc;IAC5D,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC;YACd,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IACD,MAAM,CAAU,WAAW,GAAG,+CAA+C,CAAA;IAC7E,MAAM,CAAU,QAAQ,GAAG;QACzB,8CAA8C;QAC9C,qDAAqD;KACtD,CAAA;IAEM,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAEnD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,uBAAuB,EAAE,GAAG,EAAE,CACpE,WAAW,CAAC,IAAI,CAA6B;YAC3C,QAAQ,EAAE,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,MAAM,EAAE,MAAM;SACf,CAAC,CACH,CAAA;QACD,MAAM,MAAM,GAAG,iCAAiC,CAAC,QAAQ,CAAC,CAAA;QAE1D,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,yBAAyB,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAA;YAC/E,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type AiConnectionOverrides } from './ai-config.js';
2
+ import { type AiAgent, type AiContextOptions } from './ai-types.js';
3
+ export type AiChatSessionOptions = AiConnectionOverrides & AiContextOptions & {
4
+ agent: AiAgent;
5
+ dialogue?: string;
6
+ timeoutMs?: number;
7
+ };
8
+ export type AiChatSessionResult = {
9
+ dialogueId: string;
10
+ turns: number;
11
+ };
12
+ export type AiChatSessionIo = {
13
+ error: NodeJS.WritableStream;
14
+ input: NodeJS.ReadableStream;
15
+ output: NodeJS.WritableStream;
16
+ };
17
+ export declare function runAiChatSession(options: AiChatSessionOptions, io?: AiChatSessionIo): Promise<AiChatSessionResult>;
@@ -0,0 +1,144 @@
1
+ /* eslint-disable no-await-in-loop -- Interactive chat must process user turns and streams sequentially. */
2
+ import { createInterface } from 'node:readline';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ import { AiGateway } from './ai-gateway.js';
5
+ import { bootstrapAiDialogue } from './ai-operations.js';
6
+ import { assistantIdForAgent, enrichAiPrompt } from './ai-types.js';
7
+ function writeLine(stream, value = '') {
8
+ stream.write(`${value}\n`);
9
+ }
10
+ function defaultChatIo() {
11
+ return {
12
+ error: process.stderr,
13
+ input: process.stdin,
14
+ output: process.stdout,
15
+ };
16
+ }
17
+ function question(rl, prompt) {
18
+ return new Promise((resolve, reject) => {
19
+ const onClose = () => {
20
+ const error = new Error('Readline interface closed.');
21
+ error.code = 'ERR_USE_AFTER_CLOSE';
22
+ reject(error);
23
+ };
24
+ rl.once('close', onClose);
25
+ rl.question(prompt, (answer) => {
26
+ rl.off('close', onClose);
27
+ resolve(answer);
28
+ });
29
+ });
30
+ }
31
+ function isGracefulReadlineClose(error) {
32
+ if (error === null || typeof error !== 'object')
33
+ return false;
34
+ const value = error;
35
+ return value.code === 'ERR_USE_AFTER_CLOSE' || value.message === 'The operation was aborted' || value.message === 'Readline interface closed.';
36
+ }
37
+ function errorMessage(error) {
38
+ return error instanceof Error ? error.message : String(error);
39
+ }
40
+ function renderHelp(output) {
41
+ writeLine(output, 'Commands: /help, /clear, /agent <plan|build|test|release|operate|orchestrate>, /exit');
42
+ }
43
+ function normalizeAgent(value) {
44
+ if (['build', 'operate', 'orchestrate', 'plan', 'release', 'test'].includes(value)) {
45
+ return value;
46
+ }
47
+ return undefined;
48
+ }
49
+ export async function runAiChatSession(options, io = defaultChatIo()) {
50
+ let { agent } = options;
51
+ let bootstrap = await bootstrapAiDialogue({ ...options, agent, kind: 'chat' });
52
+ let turns = 0;
53
+ const rl = createInterface({
54
+ input: io.input,
55
+ output: io.output,
56
+ terminal: Boolean(io.input.isTTY),
57
+ });
58
+ const close = () => {
59
+ rl.close();
60
+ };
61
+ process.once('SIGINT', close);
62
+ try {
63
+ writeLine(io.output, `${agent} Agent chat`);
64
+ writeLine(io.output, `Dialogue: ${bootstrap.dialogue.id}`);
65
+ renderHelp(io.output);
66
+ while (true) {
67
+ const line = (await question(rl, '> ')).trim();
68
+ if (line.length === 0)
69
+ continue;
70
+ if (line === '/exit' || line === 'exit' || line === 'quit')
71
+ break;
72
+ if (line === '/help') {
73
+ renderHelp(io.output);
74
+ continue;
75
+ }
76
+ if (line === '/clear') {
77
+ bootstrap = await bootstrapAiDialogue({ ...options, agent, dialogue: undefined, kind: 'chat' });
78
+ writeLine(io.output, `Started new dialogue: ${bootstrap.dialogue.id}`);
79
+ continue;
80
+ }
81
+ if (line.startsWith('/agent ')) {
82
+ const nextAgent = normalizeAgent(line.slice('/agent '.length).trim());
83
+ if (nextAgent === undefined) {
84
+ writeLine(io.error, 'Unknown agent. Use plan, build, test, release, operate, or orchestrate.');
85
+ continue;
86
+ }
87
+ agent = nextAgent;
88
+ bootstrap = await bootstrapAiDialogue({ ...options, agent, dialogue: undefined, kind: 'chat' });
89
+ writeLine(io.output, `Switched to ${agent} agent. Dialogue: ${bootstrap.dialogue.id}`);
90
+ continue;
91
+ }
92
+ const requestId = uuidv4();
93
+ let completed = false;
94
+ const prompt = enrichAiPrompt(line, {
95
+ component: options.component,
96
+ sfOrg: options.sfOrg,
97
+ userStory: options.userStory,
98
+ workItem: options.workItem,
99
+ });
100
+ try {
101
+ await AiGateway.sendMessage(bootstrap.dialogue.id, {
102
+ assistantId: assistantIdForAgent(agent),
103
+ 'dev_context': null,
104
+ integrations: null,
105
+ prompt,
106
+ 'request_id': requestId,
107
+ 'system_prompt': null,
108
+ }, options, (chunk) => {
109
+ if (chunk.type === 'token' && typeof chunk.content === 'string')
110
+ io.output.write(chunk.content);
111
+ if ((chunk.type === 'status' || chunk.type === 'warning') && typeof chunk.content === 'string') {
112
+ writeLine(io.error, chunk.content);
113
+ }
114
+ if (chunk.type === 'error' && typeof chunk.content === 'string') {
115
+ throw new Error(chunk.content);
116
+ }
117
+ if (chunk.type === 'done' || chunk.type === 'performance' || chunk.type === 'stream_complete')
118
+ completed = true;
119
+ });
120
+ writeLine(io.output);
121
+ if (!completed)
122
+ throw new Error('AI stream ended before stream_complete. Response may be incomplete.');
123
+ turns += 1;
124
+ }
125
+ catch (error) {
126
+ writeLine(io.error, `AI turn failed: ${errorMessage(error)}`);
127
+ }
128
+ }
129
+ }
130
+ catch (error) {
131
+ if (isGracefulReadlineClose(error)) {
132
+ writeLine(io.output, 'Session ended.');
133
+ return { dialogueId: bootstrap.dialogue.id, turns };
134
+ }
135
+ throw error;
136
+ }
137
+ finally {
138
+ process.off('SIGINT', close);
139
+ rl.close();
140
+ }
141
+ writeLine(io.output, 'Session ended.');
142
+ return { dialogueId: bootstrap.dialogue.id, turns };
143
+ }
144
+ //# sourceMappingURL=ai-chat-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-chat-session.js","sourceRoot":"","sources":["../../src/lib/ai-chat-session.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,EAAC,eAAe,EAAiB,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAC,EAAE,IAAI,MAAM,EAAC,MAAM,MAAM,CAAA;AAGjC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAsC,mBAAmB,EAAE,cAAc,EAAC,MAAM,eAAe,CAAA;AAmBtG,SAAS,SAAS,CAAC,MAA6B,EAAE,KAAK,GAAG,EAAE;IAC1D,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAA;AAC5B,CAAC;AAED,SAAS,aAAa;IACpB,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,MAAM;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAA;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,EAAa,EAAE,MAAc;IAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,4BAA4B,CAAC,CACpD;YAAC,KAAyB,CAAC,IAAI,GAAG,qBAAqB,CAAA;YACxD,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAA;QAED,EAAE,CAAC,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QACf,IAAI,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;YACtC,OAAO,EAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAC,CAAA;QACnD,CAAC;QAED,MAAM,KAAK,CAAA;IACb,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC5B,EAAE,CAAC,KAAK,EAAE,CAAA;IACZ,CAAC;IAED,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACtC,OAAO,EAAC,UAAU,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAC,CAAA;AACnD,CAAC"}
@@ -0,0 +1,26 @@
1
+ export declare const AI_DEFAULT_WORKSPACE_NAME = "agentia-cli";
2
+ export declare const AI_DEFAULT_TIMEOUT_MS = 120000;
3
+ export declare const AI_GATEWAY_HOST_PREFIX = "copadogpt-api.";
4
+ export type AiConnectionOverrides = {
5
+ domain?: string;
6
+ gatewayUrl?: string;
7
+ org?: number | string;
8
+ pat?: string;
9
+ workspace?: string;
10
+ };
11
+ export type AiCredentials = {
12
+ baseUrl: string;
13
+ domain?: string;
14
+ gatewayUrl?: string;
15
+ orgId?: number;
16
+ pat: string;
17
+ workspaceId?: string;
18
+ };
19
+ export declare function normalizeAiGatewayUrl(value: string): string;
20
+ export declare function normalizeAiDomain(value: string): string;
21
+ export declare function normalizeAiOrgId(value: number | string): number;
22
+ export declare function normalizeAiUuid(value: string, label: string): string;
23
+ export declare function normalizeAiWorkspaceId(value: string): string;
24
+ export declare function normalizeAiDialogueId(value: string): string;
25
+ export declare function aiBaseUrl(domain: string, orgId: number): string;
26
+ export declare function resolveAiCredentials(overrides?: AiConnectionOverrides): AiCredentials;