-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge
register
and update
commands into deploy
- Loading branch information
Showing
5 changed files
with
31 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,10 @@ | ||
import { Command } from "commander"; | ||
|
||
import { PluginService } from "../services/plugin"; | ||
import { deployedUrl } from "../utils/deployed-url"; | ||
import { validateAndParseOpenApiSpec } from "../utils/openapi"; | ||
import { getHostname, getSpecUrl } from "../utils/url-utils"; | ||
|
||
export const registerCommand = new Command() | ||
.name("register") | ||
.description("Register a new plugin with a URL") | ||
.option("-u, --url <url>", "Specify the deployment URL") | ||
.action(async (options) => { | ||
const url = options.url || deployedUrl; | ||
|
||
if (!url) { | ||
console.error("Deployed URL could not be determined."); | ||
return; | ||
} | ||
|
||
const pluginId = getHostname(url); | ||
const specUrl = getSpecUrl(url); | ||
const { isValid, accountId } = await validateAndParseOpenApiSpec(specUrl); | ||
|
||
if (!isValid) { | ||
console.error("OpenAPI specification validation failed."); | ||
return; | ||
} | ||
|
||
if (!accountId) { | ||
console.error("Failed to parse account ID from OpenAPI specification."); | ||
return; | ||
} | ||
|
||
const result = await new PluginService().register({ | ||
pluginId, | ||
accountId, | ||
}); | ||
if (result) { | ||
console.log(`Plugin ${pluginId} registered successfully.`); | ||
} else { | ||
console.error("Plugin registration failed."); | ||
} | ||
.description("(Deprecated)") | ||
.action(async () => { | ||
console.log( | ||
"The 'register' command has been deprecated. Use 'deploy' instead.", | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,10 @@ | ||
import { Command } from "commander"; | ||
|
||
import { PluginService } from "../services/plugin"; | ||
import { deployedUrl } from "../utils/deployed-url"; | ||
import { validateAndParseOpenApiSpec } from "../utils/openapi"; | ||
import { getSpecUrl, getHostname } from "../utils/url-utils"; | ||
|
||
export const updateCommand = new Command() | ||
.name("update") | ||
.description("Update an existing AI agent plugin") | ||
.option("-u, --url <url>", "Specify the deployment URL") | ||
.action(async (options) => { | ||
const url = options.url || deployedUrl; | ||
|
||
if (!url) { | ||
console.error("Deployed URL could not be determined."); | ||
return; | ||
} | ||
|
||
const pluginId = getHostname(url); | ||
const specUrl = getSpecUrl(url); | ||
const { isValid, accountId } = await validateAndParseOpenApiSpec(specUrl); | ||
|
||
if (!isValid) { | ||
console.error("OpenAPI specification validation failed."); | ||
return; | ||
} | ||
|
||
if (!accountId) { | ||
console.error("Failed to parse account ID from OpenAPI specification."); | ||
return; | ||
} | ||
const pluginService = new PluginService(); | ||
const authentication = | ||
await pluginService.auth.getAuthentication(accountId); | ||
if (!authentication) { | ||
console.error("Authentication failed. Unable to update the plugin."); | ||
return; | ||
} | ||
|
||
try { | ||
await pluginService.update(pluginId, accountId); | ||
console.log(`Plugin ${pluginId} updated successfully.`); | ||
} catch (error) { | ||
console.error("Failed to update the plugin:", error); | ||
} | ||
.description("(Deprecated)") | ||
.action(async () => { | ||
console.log( | ||
"The 'update' command has been deprecated. Use 'deploy' instead.", | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters