@orchagent/cli 0.2.17 → 0.2.19
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 +35 -19
- package/dist/commands/index.js +2 -0
- package/dist/commands/info.js +2 -12
- package/dist/commands/publish.js +19 -0
- package/dist/commands/tree.js +81 -0
- package/dist/lib/agent-ref.js +13 -0
- package/package.json +1 -1
package/dist/commands/delete.js
CHANGED
|
@@ -23,14 +23,30 @@ async function promptConfirm(message) {
|
|
|
23
23
|
const answer = await promptText(`${message} (y/N): `);
|
|
24
24
|
return answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes';
|
|
25
25
|
}
|
|
26
|
+
function parseAgentArg(value) {
|
|
27
|
+
const atIndex = value.lastIndexOf('@');
|
|
28
|
+
if (atIndex === -1 || atIndex === 0) {
|
|
29
|
+
return { name: value, version: 'latest' };
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
name: value.slice(0, atIndex),
|
|
33
|
+
version: value.slice(atIndex + 1) || 'latest',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
26
36
|
function registerDeleteCommand(program) {
|
|
27
37
|
program
|
|
28
|
-
.command('delete <agent
|
|
38
|
+
.command('delete <agent>')
|
|
29
39
|
.description('Delete an agent')
|
|
30
|
-
.option('--version <version>', 'Specific version to delete (default: latest)')
|
|
31
40
|
.option('-y, --yes', 'Skip confirmation prompt')
|
|
32
41
|
.option('--dry-run', 'Show what would be deleted without making changes')
|
|
33
|
-
.
|
|
42
|
+
.addHelpText('after', `
|
|
43
|
+
Examples:
|
|
44
|
+
orch delete my-agent # Delete latest version
|
|
45
|
+
orch delete my-agent@v1 # Delete specific version
|
|
46
|
+
orch delete my-agent --dry-run # Preview deletion
|
|
47
|
+
`)
|
|
48
|
+
.action(async (agent, options) => {
|
|
49
|
+
const { name: agentName, version } = parseAgentArg(agent);
|
|
34
50
|
const config = await (0, config_1.getResolvedConfig)();
|
|
35
51
|
if (!config.apiKey) {
|
|
36
52
|
throw new errors_1.CliError('Not logged in. Run `orch login` first.');
|
|
@@ -43,21 +59,21 @@ function registerDeleteCommand(program) {
|
|
|
43
59
|
throw new errors_1.CliError(`Agent '${agentName}' not found`);
|
|
44
60
|
}
|
|
45
61
|
// Select version
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
if (!
|
|
50
|
-
throw new errors_1.CliError(`Version '${
|
|
62
|
+
let selectedAgent;
|
|
63
|
+
if (version !== 'latest') {
|
|
64
|
+
selectedAgent = matching.find(a => a.version === version);
|
|
65
|
+
if (!selectedAgent) {
|
|
66
|
+
throw new errors_1.CliError(`Version '${version}' not found for agent '${agentName}'`);
|
|
51
67
|
}
|
|
52
68
|
}
|
|
53
69
|
else {
|
|
54
70
|
// Get latest version
|
|
55
|
-
|
|
71
|
+
selectedAgent = matching.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0];
|
|
56
72
|
}
|
|
57
73
|
// Check if confirmation is required
|
|
58
|
-
const deleteCheck = await (0, api_1.checkAgentDelete)(config,
|
|
74
|
+
const deleteCheck = await (0, api_1.checkAgentDelete)(config, selectedAgent.id);
|
|
59
75
|
// Show agent info
|
|
60
|
-
process.stdout.write(`\n${chalk_1.default.bold('Agent:')} ${
|
|
76
|
+
process.stdout.write(`\n${chalk_1.default.bold('Agent:')} ${selectedAgent.name}@${selectedAgent.version}\n`);
|
|
61
77
|
if (deleteCheck.stars_count > 0 || deleteCheck.fork_count > 0) {
|
|
62
78
|
process.stdout.write(`${chalk_1.default.bold('Stars:')} ${deleteCheck.stars_count} ${chalk_1.default.bold('Forks:')} ${deleteCheck.fork_count}\n`);
|
|
63
79
|
}
|
|
@@ -65,7 +81,7 @@ function registerDeleteCommand(program) {
|
|
|
65
81
|
// Handle dry-run
|
|
66
82
|
if (options.dryRun) {
|
|
67
83
|
process.stdout.write('\nDRY RUN - No changes will be made\n\n');
|
|
68
|
-
process.stdout.write(`Would delete: ${
|
|
84
|
+
process.stdout.write(`Would delete: ${selectedAgent.name}@${selectedAgent.version}\n`);
|
|
69
85
|
if (deleteCheck.stars_count > 0 || deleteCheck.fork_count > 0) {
|
|
70
86
|
process.stdout.write(chalk_1.default.yellow('Warning: This agent has stars or forks\n'));
|
|
71
87
|
}
|
|
@@ -77,14 +93,14 @@ function registerDeleteCommand(program) {
|
|
|
77
93
|
if (!options.yes) {
|
|
78
94
|
if (deleteCheck.requires_confirmation) {
|
|
79
95
|
process.stdout.write(chalk_1.default.yellow('Warning: This agent has stars or forks. Type the agent name to confirm deletion.\n\n'));
|
|
80
|
-
const confirmName = await promptText(`Type "${
|
|
81
|
-
if (confirmName !==
|
|
96
|
+
const confirmName = await promptText(`Type "${selectedAgent.name}" to confirm deletion: `);
|
|
97
|
+
if (confirmName !== selectedAgent.name) {
|
|
82
98
|
process.stdout.write(chalk_1.default.red('\nDeletion cancelled. Name did not match.\n'));
|
|
83
99
|
process.exit(1);
|
|
84
100
|
}
|
|
85
101
|
}
|
|
86
102
|
else {
|
|
87
|
-
const confirmed = await promptConfirm(`Delete ${
|
|
103
|
+
const confirmed = await promptConfirm(`Delete ${selectedAgent.name}@${selectedAgent.version}?`);
|
|
88
104
|
if (!confirmed) {
|
|
89
105
|
process.stdout.write(chalk_1.default.gray('Deletion cancelled.\n'));
|
|
90
106
|
process.exit(0);
|
|
@@ -93,10 +109,10 @@ function registerDeleteCommand(program) {
|
|
|
93
109
|
}
|
|
94
110
|
// Perform deletion
|
|
95
111
|
process.stdout.write('Deleting agent...\n');
|
|
96
|
-
const confirmationName = deleteCheck.requires_confirmation ?
|
|
97
|
-
await (0, api_1.deleteAgent)(config,
|
|
98
|
-
await (0, analytics_1.track)('cli_delete', { agent_name:
|
|
99
|
-
process.stdout.write(`✓ Deleted ${
|
|
112
|
+
const confirmationName = deleteCheck.requires_confirmation ? selectedAgent.name : undefined;
|
|
113
|
+
await (0, api_1.deleteAgent)(config, selectedAgent.id, confirmationName);
|
|
114
|
+
await (0, analytics_1.track)('cli_delete', { agent_name: selectedAgent.name, version: selectedAgent.version });
|
|
115
|
+
process.stdout.write(`✓ Deleted ${selectedAgent.name}@${selectedAgent.version}\n`);
|
|
100
116
|
process.stdout.write(chalk_1.default.gray('\nData will be retained for 30 days before permanent deletion.\n'));
|
|
101
117
|
});
|
|
102
118
|
}
|
package/dist/commands/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const github_1 = require("./github");
|
|
|
19
19
|
const doctor_1 = require("./doctor");
|
|
20
20
|
const status_1 = require("./status");
|
|
21
21
|
const workspace_1 = require("./workspace");
|
|
22
|
+
const tree_1 = require("./tree");
|
|
22
23
|
function registerCommands(program) {
|
|
23
24
|
(0, login_1.registerLoginCommand)(program);
|
|
24
25
|
(0, whoami_1.registerWhoamiCommand)(program);
|
|
@@ -38,4 +39,5 @@ function registerCommands(program) {
|
|
|
38
39
|
(0, doctor_1.registerDoctorCommand)(program);
|
|
39
40
|
(0, status_1.registerStatusCommand)(program);
|
|
40
41
|
(0, workspace_1.registerWorkspaceCommand)(program);
|
|
42
|
+
(0, tree_1.registerTreeCommand)(program);
|
|
41
43
|
}
|
package/dist/commands/info.js
CHANGED
|
@@ -3,17 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerInfoCommand = registerInfoCommand;
|
|
4
4
|
const config_1 = require("../lib/config");
|
|
5
5
|
const api_1 = require("../lib/api");
|
|
6
|
-
const
|
|
7
|
-
const DEFAULT_VERSION = 'latest';
|
|
8
|
-
function parseAgentRef(value) {
|
|
9
|
-
const [ref, versionPart] = value.split('@');
|
|
10
|
-
const version = versionPart?.trim() || DEFAULT_VERSION;
|
|
11
|
-
const segments = ref.split('/');
|
|
12
|
-
if (segments.length === 2) {
|
|
13
|
-
return { org: segments[0], agent: segments[1], version };
|
|
14
|
-
}
|
|
15
|
-
throw new errors_1.CliError('Invalid agent reference. Use org/agent format (e.g., joe/leak-finder)');
|
|
16
|
-
}
|
|
6
|
+
const agent_ref_1 = require("../lib/agent-ref");
|
|
17
7
|
function formatSchema(schema, indent = ' ') {
|
|
18
8
|
const lines = [];
|
|
19
9
|
const props = schema.properties || {};
|
|
@@ -112,7 +102,7 @@ function registerInfoCommand(program) {
|
|
|
112
102
|
.option('--json', 'Output as JSON')
|
|
113
103
|
.action(async (agentArg, options) => {
|
|
114
104
|
const config = await (0, config_1.getResolvedConfig)();
|
|
115
|
-
const { org, agent, version } = parseAgentRef(agentArg);
|
|
105
|
+
const { org, agent, version } = (0, agent_ref_1.parseAgentRef)(agentArg);
|
|
116
106
|
// Fetch agent metadata
|
|
117
107
|
const agentData = await downloadAgentWithFallback(config, org, agent, version);
|
|
118
108
|
if (options.json) {
|
package/dist/commands/publish.js
CHANGED
|
@@ -135,6 +135,25 @@ function registerPublishCommand(program) {
|
|
|
135
135
|
if (!manifest.name) {
|
|
136
136
|
throw new errors_1.CliError('orchagent.json must have name');
|
|
137
137
|
}
|
|
138
|
+
// Check for misplaced manifest fields at top level (common user error)
|
|
139
|
+
const manifestFields = ['manifest_version', 'dependencies', 'max_hops', 'timeout_ms', 'per_call_downstream_cap'];
|
|
140
|
+
const misplacedFields = manifestFields.filter(f => f in manifest && !manifest.manifest);
|
|
141
|
+
if (misplacedFields.length > 0) {
|
|
142
|
+
throw new errors_1.CliError(`Found manifest fields (${misplacedFields.join(', ')}) at top level of orchagent.json.\n` +
|
|
143
|
+
`These must be nested under a "manifest" key. Example:\n\n` +
|
|
144
|
+
` {\n` +
|
|
145
|
+
` "name": "${manifest.name}",\n` +
|
|
146
|
+
` "type": "${manifest.type || 'code'}",\n` +
|
|
147
|
+
` "manifest": {\n` +
|
|
148
|
+
` "manifest_version": 1,\n` +
|
|
149
|
+
` "dependencies": [...],\n` +
|
|
150
|
+
` "max_hops": 2,\n` +
|
|
151
|
+
` "timeout_ms": 60000,\n` +
|
|
152
|
+
` "per_call_downstream_cap": 50\n` +
|
|
153
|
+
` }\n` +
|
|
154
|
+
` }\n\n` +
|
|
155
|
+
`See docs/manifest.md for details.`);
|
|
156
|
+
}
|
|
138
157
|
// Read prompt (for prompt-based agents and skills)
|
|
139
158
|
let prompt;
|
|
140
159
|
if (manifest.type === 'prompt' || manifest.type === 'skill') {
|
|
@@ -0,0 +1,81 @@
|
|
|
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.registerTreeCommand = registerTreeCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const config_1 = require("../lib/config");
|
|
9
|
+
const api_1 = require("../lib/api");
|
|
10
|
+
const agent_ref_1 = require("../lib/agent-ref");
|
|
11
|
+
const errors_1 = require("../lib/errors");
|
|
12
|
+
function registerTreeCommand(program) {
|
|
13
|
+
program
|
|
14
|
+
.command('tree <agent>')
|
|
15
|
+
.description('Show dependency tree for an agent')
|
|
16
|
+
.option('--json', 'Output as JSON')
|
|
17
|
+
.option('--no-color', 'Disable colored output')
|
|
18
|
+
.action(async (agentArg, options) => {
|
|
19
|
+
const config = await (0, config_1.getResolvedConfig)();
|
|
20
|
+
if (!config.apiKey) {
|
|
21
|
+
throw new errors_1.CliError('Authentication required. Run: orch login');
|
|
22
|
+
}
|
|
23
|
+
const { org, agent, version } = (0, agent_ref_1.parseAgentRef)(agentArg);
|
|
24
|
+
const tree = await (0, api_1.request)(config, 'GET', `/agents/${org}/${agent}/${version}/tree`);
|
|
25
|
+
if (options.json) {
|
|
26
|
+
console.log(JSON.stringify(tree, null, 2));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const useColor = options.color !== false;
|
|
30
|
+
console.log();
|
|
31
|
+
console.log(formatTree(tree, useColor));
|
|
32
|
+
console.log();
|
|
33
|
+
console.log(`Summary: ${tree.summary.total_agents} agents, ` +
|
|
34
|
+
`${tree.summary.total_skills} skills, ` +
|
|
35
|
+
`max depth ${tree.summary.max_depth}`);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function formatTree(tree, useColor) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
const rootNode = {
|
|
41
|
+
agent: tree.agent,
|
|
42
|
+
accessible: true,
|
|
43
|
+
type: tree.type,
|
|
44
|
+
skills: tree.skills,
|
|
45
|
+
skills_locked: tree.skills_locked,
|
|
46
|
+
dependencies: tree.dependencies,
|
|
47
|
+
};
|
|
48
|
+
formatNode(rootNode, '', true, true, lines, useColor);
|
|
49
|
+
return lines.join('\n');
|
|
50
|
+
}
|
|
51
|
+
function formatNode(node, prefix, isLast, isRoot, lines, useColor) {
|
|
52
|
+
const connector = isRoot ? '' : isLast ? '└── ' : '├── ';
|
|
53
|
+
const childPrefix = isRoot ? '' : prefix + (isLast ? ' ' : '│ ');
|
|
54
|
+
// Format agent line
|
|
55
|
+
let agentStr = node.agent;
|
|
56
|
+
if (!node.accessible) {
|
|
57
|
+
agentStr = useColor ? chalk_1.default.dim(agentStr) : `(${agentStr})`;
|
|
58
|
+
}
|
|
59
|
+
if (node.skills_locked && useColor) {
|
|
60
|
+
agentStr = agentStr + chalk_1.default.yellow(' 🔒');
|
|
61
|
+
}
|
|
62
|
+
lines.push(prefix + connector + agentStr);
|
|
63
|
+
// Format skills
|
|
64
|
+
const allChildren = [
|
|
65
|
+
...node.skills.map(s => ({ type: 'skill', value: s })),
|
|
66
|
+
...node.dependencies.map(d => ({ type: 'dep', value: d })),
|
|
67
|
+
];
|
|
68
|
+
allChildren.forEach((child, idx) => {
|
|
69
|
+
const isLastChild = idx === allChildren.length - 1;
|
|
70
|
+
const childConnector = isLastChild ? '└── ' : '├── ';
|
|
71
|
+
if (child.type === 'skill') {
|
|
72
|
+
const skillStr = useColor
|
|
73
|
+
? chalk_1.default.magenta(child.value) + chalk_1.default.dim(' (skill)')
|
|
74
|
+
: `${child.value} (skill)`;
|
|
75
|
+
lines.push(childPrefix + childConnector + skillStr);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
formatNode(child.value, childPrefix, isLastChild, false, lines, useColor);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAgentRef = parseAgentRef;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
function parseAgentRef(value, defaultVersion = 'latest') {
|
|
6
|
+
const [ref, versionPart] = value.split('@');
|
|
7
|
+
const version = versionPart?.trim() || defaultVersion;
|
|
8
|
+
const segments = ref.split('/');
|
|
9
|
+
if (segments.length === 2) {
|
|
10
|
+
return { org: segments[0], agent: segments[1], version };
|
|
11
|
+
}
|
|
12
|
+
throw new errors_1.CliError('Invalid agent reference. Use org/agent[@version] format');
|
|
13
|
+
}
|