cloud-pc-templates 1.3.1 → 1.4.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.
package/README.md CHANGED
@@ -106,6 +106,50 @@ Enter Hugging Face API Key: ****************************
106
106
  - Endpoint checked: http://localhost:3006/health
107
107
  ```
108
108
 
109
+ #### AI Agents
110
+
111
+ Manage and explore available AI agents from the registry.
112
+
113
+ **Agent Registry URL:**
114
+ ```
115
+ https://raw.githubusercontent.com/devashish234073/cloud-pc-templates-marketplace/refs/heads/main/JS-AGENTS/agent-registry.json
116
+ ```
117
+
118
+ ##### List All Agents
119
+
120
+ Display all available agents with their IDs, names, and ports:
121
+ ```bash
122
+ npx cloud-pc-templates ai agents list
123
+ ```
124
+
125
+ **Example output:**
126
+ ```bash
127
+ $ npx cloud-pc-templates ai agents list
128
+
129
+ Available Agents
130
+
131
+ ────────────────────────────────────────────────────────────────────────────────
132
+ ID: playwright connector
133
+ Name: Playwright Connector
134
+ Port: 3036
135
+ ────────────────────────────────────────────────────────────────────────────────
136
+ ID: mysql connector
137
+ Name: MySQL Connector
138
+ Port: 3037
139
+ ────────────────────────────────────────────────────────────────────────────────
140
+ ID: angular connector
141
+ Name: Angular Connector
142
+ Port: 3034
143
+ ────────────────────────────────────────────────────────────────────────────────
144
+ ```
145
+
146
+ ##### Get Agent Details
147
+
148
+ Display complete information for a specific agent:
149
+ ```bash
150
+ npx cloud-pc-templates ai agents "agent-id"
151
+ ```
152
+
109
153
  ### Command Discovery
110
154
 
111
155
  The CLI features intelligent command discovery. If you don't provide all required arguments, it shows available options:
@@ -139,6 +183,7 @@ cloud-pc-templates/
139
183
  │ ├── ollamacloud.js # Ollama Cloud login functionality
140
184
  │ ├── ollamalocal.js # Ollama Local login functionality
141
185
  │ ├── huggingface.js # Hugging Face login functionality
186
+ │ ├── agents.js # AI agents registry management
142
187
  │ └── launch.js # Website launcher
143
188
  ├── package.json # Project metadata and bin configuration
144
189
  └── README.md # This file
@@ -0,0 +1,87 @@
1
+ const AGENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/devashish234073/cloud-pc-templates-marketplace/refs/heads/main/JS-AGENTS/agent-registry.json';
2
+
3
+ async function fetchAgentsRegistry() {
4
+ try {
5
+ const response = await fetch(AGENTS_REGISTRY_URL);
6
+ if (!response.ok) {
7
+ throw new Error(`Failed to fetch agents registry: ${response.status} ${response.statusText}`);
8
+ }
9
+ return await response.json();
10
+ } catch (error) {
11
+ throw new Error(`Failed to fetch agents registry: ${error.message}`);
12
+ }
13
+ }
14
+
15
+ async function listAgents() {
16
+ try {
17
+ const agents = await fetchAgentsRegistry();
18
+
19
+ if (!Array.isArray(agents) || agents.length === 0) {
20
+ console.log('No agents found in registry');
21
+ return;
22
+ }
23
+
24
+ console.log('\nAvailable Agents\n');
25
+ console.log('─'.repeat(80));
26
+
27
+ agents.forEach((agent) => {
28
+ const idStr = `ID: ${agent.id}`.padEnd(40);
29
+ const nameStr = `Name: ${agent.name}`.padEnd(40);
30
+ const portStr = `Port: ${agent.port || 'N/A'}`;
31
+
32
+ console.log(idStr);
33
+ console.log(nameStr);
34
+ console.log(portStr);
35
+ console.log('─'.repeat(80));
36
+ });
37
+
38
+ } catch (error) {
39
+ console.error(`Error: ${error.message}`);
40
+ process.exit(1);
41
+ }
42
+ }
43
+
44
+ async function getAgentDetails(agentId) {
45
+ try {
46
+ const agents = await fetchAgentsRegistry();
47
+
48
+ if (!Array.isArray(agents)) {
49
+ console.error('Invalid registry format');
50
+ process.exit(1);
51
+ }
52
+
53
+ const agent = agents.find(a => a.id.toLowerCase() === agentId.toLowerCase());
54
+
55
+ if (!agent) {
56
+ console.error(`❌ Agent not found: "${agentId}"`);
57
+ console.log('\nAvailable agents:');
58
+ agents.forEach(a => console.log(` - ${a.id}`));
59
+ process.exit(1);
60
+ }
61
+
62
+ console.log(`\nAgent Details: ${agent.name}\n`);
63
+ console.log('─'.repeat(80));
64
+
65
+ Object.entries(agent).forEach(([key, value]) => {
66
+ const displayKey = key.charAt(0).toUpperCase() + key.slice(1);
67
+
68
+ if (typeof value === 'string' && value.length > 70) {
69
+ console.log(`${displayKey}:`);
70
+ console.log(` ${value}`);
71
+ } else {
72
+ console.log(`${displayKey}: ${value}`);
73
+ }
74
+ });
75
+
76
+ console.log('─'.repeat(80) + '\n');
77
+
78
+ } catch (error) {
79
+ console.error(`Error: ${error.message}`);
80
+ process.exit(1);
81
+ }
82
+ }
83
+
84
+ module.exports = {
85
+ listAgents,
86
+ getAgentDetails
87
+ };
package/index.js CHANGED
@@ -4,6 +4,7 @@ const { checkAndLoginOllamaCloud } = require('./handlers/ollamacloud');
4
4
  const { checkAndLoginOllamaLocal } = require('./handlers/ollamalocal');
5
5
  const { checkAndLoginHuggingFace } = require('./handlers/huggingface');
6
6
  const { launchWebsite } = require('./handlers/launch');
7
+ const { listAgents, getAgentDetails } = require('./handlers/agents');
7
8
 
8
9
  // Command tree structure
9
10
  const commandTree = {
@@ -36,6 +37,11 @@ const commandTree = {
36
37
  }
37
38
  }
38
39
  }
40
+ },
41
+ agents: {
42
+ description: 'Manage AI agents',
43
+ handler: aiAgents,
44
+ dynamic: true
39
45
  }
40
46
  }
41
47
  },
@@ -60,6 +66,8 @@ function help() {
60
66
  console.log(' npx cloud-pc-templates ai login loginMode ollamacloud');
61
67
  console.log(' npx cloud-pc-templates ai login loginMode ollamalocal');
62
68
  console.log(' npx cloud-pc-templates ai login loginMode huggingface');
69
+ console.log(' npx cloud-pc-templates ai agents list List all available agents');
70
+ console.log(' npx cloud-pc-templates ai agents "agent-name" Show agent details');
63
71
  }
64
72
 
65
73
  // Default AI function
@@ -78,6 +86,24 @@ async function aiLogin(mode) {
78
86
  }
79
87
  }
80
88
 
89
+ // AI Agents function
90
+ async function aiAgents(remainingArgs) {
91
+ if (!remainingArgs || remainingArgs.length === 0) {
92
+ console.log('Usage: npx cloud-pc-templates ai agents <list|agent-name>');
93
+ console.log(' list List all available agents');
94
+ console.log(' "agent-name" Show details for a specific agent');
95
+ return;
96
+ }
97
+
98
+ const subcommand = remainingArgs[0].toLowerCase();
99
+
100
+ if (subcommand === 'list') {
101
+ await listAgents();
102
+ } else {
103
+ await getAgentDetails(remainingArgs[0]);
104
+ }
105
+ }
106
+
81
107
  // Function to show available options at a certain level
82
108
  function showAvailableOptions(node, path) {
83
109
  if (!node || !node.subcommands) {
@@ -97,15 +123,27 @@ function showAvailableOptions(node, path) {
97
123
  function traverseCommandTree(args, startNode, startPath = []) {
98
124
  let currentNode = startNode;
99
125
  let path = startPath;
126
+ let argIndex = 1; // Start from the second argument (first is already matched in processArgs)
127
+
128
+ // Special handling for dynamic commands like agents
129
+ if (currentNode.dynamic && currentNode.handler) {
130
+ const remainingArgs = args.slice(1);
131
+ const result = currentNode.handler(remainingArgs);
132
+ if (result instanceof Promise) {
133
+ result.catch(err => console.error('Error:', err.message));
134
+ }
135
+ return;
136
+ }
100
137
 
101
- // Start from the second argument (first is already matched in processArgs)
102
- for (let i = 1; i < args.length; i++) {
103
- let arg = args[i].replace(/^--/, ''); // Remove -- prefix
138
+ // Normal command tree traversal
139
+ while (argIndex < args.length) {
140
+ let arg = args[argIndex].replace(/^--/, ''); // Remove -- prefix
104
141
 
105
142
  // Check if current node has subcommands
106
143
  if (currentNode.subcommands && currentNode.subcommands[arg]) {
107
144
  currentNode = currentNode.subcommands[arg];
108
145
  path.push(arg);
146
+ argIndex++;
109
147
  } else if (arg === 'help' || arg === '--help') {
110
148
  showAvailableOptions(currentNode, path);
111
149
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloud-pc-templates",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {