Skip to content

Commit

Permalink
feat(cli): added aiAgents
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Heltewig committed Dec 28, 2024
1 parent 1820e3b commit 501a321
Show file tree
Hide file tree
Showing 12 changed files with 301 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ts-node/register/transpile-only",
"--preserve-symlinks"
],
"args":["./src/cognigy.ts","clone","--config", "./config.json", "--forceYes"],
"args":["./src/cognigy.ts","push", "aiAgent", "Neon", "--config", "./config.json", "--forceYes"],
"console": "integratedTerminal"
}
]
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Currently supported resources (`<resourceType>`):
- Endpoints (clone, restore, push, pull, diff)
- Snapshots (create)
- Extensions (pull)
- AI Agents (clone, push, pull)

For Endpoints, Transformers will be separately stores as TypeScript files

Expand Down Expand Up @@ -101,6 +102,13 @@ Clones a Virtual Agent from Cognigy.AI to disk
| ------ | ----- | ------ | ------- | --------------------------------------------------------------------- |
| <nobr>--type</nobr> | -t | String | `agent` | Which type of resource to clone (`agent` stands for the full project) |

Supported resource types for clone:
- agent (default, clones everything including AI Agents)
- flows
- endpoints
- lexicons
- aiAgents

### Command: restore

`cognigy restore`
Expand Down Expand Up @@ -289,7 +297,6 @@ Commit using the commitizen hook with semantic naming convetion promt
```bash
npx cz
```

### Pull Requests

Create PR with any kind of feature/bugfix folloving the [semantic message format](https://github.com/semantic-release/semantic-release#commit-message-format) to the develop branch.
Expand All @@ -301,3 +308,4 @@ Any PRs to develop needs to be merged as squash merges.
Create a PR from develop to main and do a merge commit. This will automatically trigger a new release.
To make the release publish a new minor version to the npm registry, the commit message needs to follow the [semantic message format] and having at least one of the commits to main from the last release with a fix.


19 changes: 9 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cognigy/cognigy-cli",
"version": "0.0.0-semantic-release",
"version": "1.6.0",
"description": "Cognigy Command Line Interface",
"main": "./build/cognigy.js",
"scripts": {
Expand Down Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"-": "0.0.1",
"@cognigy/rest-api-client": "0.19.0",
"@cognigy/rest-api-client": "^0.20.0",
"@google-cloud/translate": "8.0.2",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"axios": "1.7.8",
Expand Down
7 changes: 7 additions & 0 deletions src/commands/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { upperFirst } from '../utils/stringUtils';
import { cloneEndpoints } from '../lib/endpoints';
import { cloneFlows } from '../lib/flows';
import { cloneLexicons } from '../lib/lexicons';
import { cloneAiAgents } from '../lib/aiagents';

/**
* Clones a full Virtual Agent project to disk
Expand Down Expand Up @@ -43,6 +44,7 @@ export const clone = async ({ resourceType = 'agent', forceYes = false }): Promi
await cloneFlows(33);
await cloneEndpoints(33);
await cloneLexicons(33);
await cloneAiAgents();
break;

case "flows":
Expand All @@ -59,6 +61,11 @@ export const clone = async ({ resourceType = 'agent', forceYes = false }): Promi
case "lexicon":
await cloneLexicons(100);
break;

case "aiAgents":
case "aiAgent":
await cloneAiAgents();
break;
}

endProgressBar();
Expand Down
8 changes: 6 additions & 2 deletions src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { checkAgentDir, checkProject } from '../utils/checks';
import { diffFlows } from '../lib/flows';
import { diffEndpoints } from '../lib/endpoints';
import { diffLexicons } from '../lib/lexicons';
import { diffAiAgents } from '../lib/aiagents';

/**
* Provides a diff between a resource on disk and remote
Expand Down Expand Up @@ -29,8 +30,11 @@ export const diff = async (resourceType: string, resourceId: string, mode: strin
await diffLexicons(resourceId, mode);
break;

case "aiAgent":
await diffAiAgents(resourceId, mode);
break;

default:
console.log(`\n\nInvalid diff resource type ${resourceType}.`);
return;
console.log(`Resource type ${resourceType} can't be compared.`);
}
};
6 changes: 6 additions & 0 deletions src/commands/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { upperFirst } from '../utils/stringUtils';
import { pullLexicon } from '../lib/lexicons';
import { pullLocales } from '../lib/locales';
import { pullExtensions } from '../lib/extensions';
import { pullAiAgent } from '../lib/aiagents';

/**
* Pushes a single resource from disk to Cognigy.AI
Expand Down Expand Up @@ -59,6 +60,11 @@ export const pull = async ({ resourceType, resourceName, forceYes = false }): Pr
case "extensions":
await pullExtensions();
break;

case 'aiAgent':
await pullAiAgent(resourceName);
break;

default:
throw(new Error(`Resource type ${resourceType} can't be pulled.`));
}
Expand Down
7 changes: 7 additions & 0 deletions src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { pushEndpoint } from '../lib/endpoints';
import { checkAgentDir, checkResourceDir, checkProject } from '../utils/checks';
import { upperFirst } from '../utils/stringUtils';
import { pushLexicon } from '../lib/lexicons';
import { pushAiAgent } from '../lib/aiagents';

/**
* Pushes a single resource from disk to Cognigy.AI
Expand Down Expand Up @@ -55,6 +56,12 @@ export const push = async ({ resourceType, resourceName, options }): Promise<voi
await pushLexicon(resourceName, 100, options.timeout);
break;

case 'aiAgent':
startProgressBar(100);
await pushAiAgent(resourceName, 100);
endProgressBar();
break;

default:
console.log(`Resource type ${resourceType} can't be pushed.`);
}
Expand Down
13 changes: 10 additions & 3 deletions src/commands/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { upperFirst } from '../utils/stringUtils';
import { restoreFlows } from '../lib/flows';
import { restoreEndpoints } from '../lib/endpoints';
import { restoreLexicons } from '../lib/lexicons';
import { restoreAiAgents } from '../lib/aiagents';

/**
* Restores a Virtual Agent project from disk to Cognigy.AI
Expand Down Expand Up @@ -40,9 +41,10 @@ export const restore = async ({ resourceType = 'agent', forceYes = false }): Pro
switch (resourceType) {
case "agent":
await Promise.all([
restoreFlows(33),
restoreEndpoints(33),
restoreLexicons(33)
restoreFlows(25),
restoreEndpoints(25),
restoreLexicons(25),
restoreAiAgents(25)
]);
break;

Expand All @@ -60,6 +62,11 @@ export const restore = async ({ resourceType = 'agent', forceYes = false }): Pro
case "lexicon":
await restoreLexicons(100);
break;

case "aiAgents":
case "aiAgent":
await restoreAiAgents(100);
break;
}

endProgressBar();
Expand Down
Loading

0 comments on commit 501a321

Please sign in to comment.