@orchagent/cli 0.2.10 → 0.2.11
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.
- package/dist/commands/delete.js +90 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/run.js +10 -3
- package/dist/lib/api.js +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerDeleteCommand = registerDeleteCommand;
|
|
7
|
+
const promises_1 = __importDefault(require("readline/promises"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const config_1 = require("../lib/config");
|
|
10
|
+
const api_1 = require("../lib/api");
|
|
11
|
+
const errors_1 = require("../lib/errors");
|
|
12
|
+
const analytics_1 = require("../lib/analytics");
|
|
13
|
+
async function promptText(message) {
|
|
14
|
+
const rl = promises_1.default.createInterface({
|
|
15
|
+
input: process.stdin,
|
|
16
|
+
output: process.stdout,
|
|
17
|
+
});
|
|
18
|
+
const answer = await rl.question(message);
|
|
19
|
+
rl.close();
|
|
20
|
+
return answer.trim();
|
|
21
|
+
}
|
|
22
|
+
async function promptConfirm(message) {
|
|
23
|
+
const answer = await promptText(`${message} (y/N): `);
|
|
24
|
+
return answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes';
|
|
25
|
+
}
|
|
26
|
+
function registerDeleteCommand(program) {
|
|
27
|
+
program
|
|
28
|
+
.command('delete <agent-name>')
|
|
29
|
+
.description('Delete an agent')
|
|
30
|
+
.option('--version <version>', 'Specific version to delete (default: latest)')
|
|
31
|
+
.option('-y, --yes', 'Skip confirmation prompt')
|
|
32
|
+
.action(async (agentName, options) => {
|
|
33
|
+
const config = await (0, config_1.getResolvedConfig)();
|
|
34
|
+
if (!config.apiKey) {
|
|
35
|
+
throw new errors_1.CliError('Not logged in. Run `orch login` first.');
|
|
36
|
+
}
|
|
37
|
+
process.stdout.write('Finding agent...\n');
|
|
38
|
+
// Find the agent
|
|
39
|
+
const agents = await (0, api_1.listMyAgents)(config);
|
|
40
|
+
const matching = agents.filter(a => a.name === agentName);
|
|
41
|
+
if (matching.length === 0) {
|
|
42
|
+
throw new errors_1.CliError(`Agent '${agentName}' not found`);
|
|
43
|
+
}
|
|
44
|
+
// Select version
|
|
45
|
+
let agent;
|
|
46
|
+
if (options.version) {
|
|
47
|
+
agent = matching.find(a => a.version === options.version);
|
|
48
|
+
if (!agent) {
|
|
49
|
+
throw new errors_1.CliError(`Version '${options.version}' not found for agent '${agentName}'`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Get latest version
|
|
54
|
+
agent = matching.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0];
|
|
55
|
+
}
|
|
56
|
+
// Check if confirmation is required
|
|
57
|
+
const deleteCheck = await (0, api_1.checkAgentDelete)(config, agent.id);
|
|
58
|
+
// Show agent info
|
|
59
|
+
process.stdout.write(`\n${chalk_1.default.bold('Agent:')} ${agent.name}@${agent.version}\n`);
|
|
60
|
+
if (deleteCheck.stars_count > 0 || deleteCheck.fork_count > 0) {
|
|
61
|
+
process.stdout.write(`${chalk_1.default.bold('Stars:')} ${deleteCheck.stars_count} ${chalk_1.default.bold('Forks:')} ${deleteCheck.fork_count}\n`);
|
|
62
|
+
}
|
|
63
|
+
process.stdout.write('\n');
|
|
64
|
+
// Handle confirmation
|
|
65
|
+
if (!options.yes) {
|
|
66
|
+
if (deleteCheck.requires_confirmation) {
|
|
67
|
+
process.stdout.write(chalk_1.default.yellow('Warning: This agent has stars or forks. Type the agent name to confirm deletion.\n\n'));
|
|
68
|
+
const confirmName = await promptText(`Type "${agent.name}" to confirm deletion: `);
|
|
69
|
+
if (confirmName !== agent.name) {
|
|
70
|
+
process.stdout.write(chalk_1.default.red('\nDeletion cancelled. Name did not match.\n'));
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const confirmed = await promptConfirm(`Delete ${agent.name}@${agent.version}?`);
|
|
76
|
+
if (!confirmed) {
|
|
77
|
+
process.stdout.write(chalk_1.default.gray('Deletion cancelled.\n'));
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Perform deletion
|
|
83
|
+
process.stdout.write('Deleting agent...\n');
|
|
84
|
+
const confirmationName = deleteCheck.requires_confirmation ? agent.name : undefined;
|
|
85
|
+
await (0, api_1.deleteAgent)(config, agent.id, confirmationName);
|
|
86
|
+
await (0, analytics_1.track)('cli_delete', { agent_name: agent.name, version: agent.version });
|
|
87
|
+
process.stdout.write(`✓ Deleted ${agent.name}@${agent.version}\n`);
|
|
88
|
+
process.stdout.write(chalk_1.default.gray('\nData will be retained for 30 days before permanent deletion.\n'));
|
|
89
|
+
});
|
|
90
|
+
}
|
package/dist/commands/index.js
CHANGED
|
@@ -15,6 +15,7 @@ const keys_1 = require("./keys");
|
|
|
15
15
|
const run_1 = require("./run");
|
|
16
16
|
const info_1 = require("./info");
|
|
17
17
|
const skill_1 = require("./skill");
|
|
18
|
+
const delete_1 = require("./delete");
|
|
18
19
|
function registerCommands(program) {
|
|
19
20
|
(0, login_1.registerLoginCommand)(program);
|
|
20
21
|
(0, whoami_1.registerWhoamiCommand)(program);
|
|
@@ -30,4 +31,5 @@ function registerCommands(program) {
|
|
|
30
31
|
(0, llm_config_1.registerLlmConfigCommand)(program);
|
|
31
32
|
(0, keys_1.registerKeysCommand)(program);
|
|
32
33
|
(0, skill_1.registerSkillCommand)(program);
|
|
34
|
+
(0, delete_1.registerDeleteCommand)(program);
|
|
33
35
|
}
|
package/dist/commands/run.js
CHANGED
|
@@ -371,7 +371,9 @@ async function unzipBundle(zipPath, destDir) {
|
|
|
371
371
|
});
|
|
372
372
|
proc.on('close', (code) => {
|
|
373
373
|
if (code !== 0) {
|
|
374
|
-
|
|
374
|
+
const detail = stderr.trim() || `exit code ${code}`;
|
|
375
|
+
reject(new errors_1.CliError(`Failed to extract bundle: ${detail}\n` +
|
|
376
|
+
`Ensure the bundle is valid. Try re-publishing the agent.`));
|
|
375
377
|
}
|
|
376
378
|
else {
|
|
377
379
|
resolve();
|
|
@@ -566,9 +568,14 @@ async function executeBundleAgent(config, org, agentName, version, agentData, ar
|
|
|
566
568
|
else if (exitCode !== 0) {
|
|
567
569
|
// No stdout, check stderr
|
|
568
570
|
if (stderr.trim()) {
|
|
569
|
-
throw new errors_1.CliError(`Agent
|
|
571
|
+
throw new errors_1.CliError(`Agent exited with code ${exitCode}\n\nError output:\n${stderr.trim()}`);
|
|
570
572
|
}
|
|
571
|
-
throw new errors_1.CliError(`Agent exited with code ${exitCode} (no output)`
|
|
573
|
+
throw new errors_1.CliError(`Agent exited with code ${exitCode} (no output)\n\n` +
|
|
574
|
+
`Common causes:\n` +
|
|
575
|
+
` - Missing dependency (check requirements.txt)\n` +
|
|
576
|
+
` - Syntax error in entrypoint\n` +
|
|
577
|
+
` - Agent crashed before writing output\n\n` +
|
|
578
|
+
`Run with --verbose or check logs in dashboard.`);
|
|
572
579
|
}
|
|
573
580
|
}
|
|
574
581
|
finally {
|
package/dist/lib/api.js
CHANGED
|
@@ -52,6 +52,8 @@ exports.uploadCodeBundle = uploadCodeBundle;
|
|
|
52
52
|
exports.getMyAgent = getMyAgent;
|
|
53
53
|
exports.getAgentWithFallback = getAgentWithFallback;
|
|
54
54
|
exports.downloadCodeBundleAuthenticated = downloadCodeBundleAuthenticated;
|
|
55
|
+
exports.checkAgentDelete = checkAgentDelete;
|
|
56
|
+
exports.deleteAgent = deleteAgent;
|
|
55
57
|
class ApiError extends Error {
|
|
56
58
|
status;
|
|
57
59
|
payload;
|
|
@@ -261,3 +263,16 @@ async function downloadCodeBundleAuthenticated(config, agentId) {
|
|
|
261
263
|
const arrayBuffer = await response.arrayBuffer();
|
|
262
264
|
return Buffer.from(arrayBuffer);
|
|
263
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Check if an agent requires confirmation for deletion.
|
|
268
|
+
*/
|
|
269
|
+
async function checkAgentDelete(config, agentId) {
|
|
270
|
+
return request(config, 'GET', `/agents/${agentId}/delete-check`);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Soft delete an agent.
|
|
274
|
+
*/
|
|
275
|
+
async function deleteAgent(config, agentId, confirmationName) {
|
|
276
|
+
const params = confirmationName ? `?confirmation_name=${encodeURIComponent(confirmationName)}` : '';
|
|
277
|
+
return request(config, 'DELETE', `/agents/${agentId}${params}`);
|
|
278
|
+
}
|