@autenai/cli 0.1.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/dist/index.js +486 -0
- package/package.json +40 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_commander = require("commander");
|
|
28
|
+
|
|
29
|
+
// src/commands/login.ts
|
|
30
|
+
var import_inquirer = __toESM(require("inquirer"));
|
|
31
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
32
|
+
var import_ora = __toESM(require("ora"));
|
|
33
|
+
var import_sdk = require("@autenai/sdk");
|
|
34
|
+
|
|
35
|
+
// src/lib/config.ts
|
|
36
|
+
var fs = __toESM(require("fs"));
|
|
37
|
+
var path = __toESM(require("path"));
|
|
38
|
+
var os = __toESM(require("os"));
|
|
39
|
+
var CONFIG_DIR = path.join(os.homedir(), ".auten");
|
|
40
|
+
var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
41
|
+
function ensureConfigDir() {
|
|
42
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
43
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function readConfig() {
|
|
47
|
+
try {
|
|
48
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
49
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
function writeConfig(config) {
|
|
56
|
+
ensureConfigDir();
|
|
57
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
58
|
+
fs.chmodSync(CONFIG_FILE, 384);
|
|
59
|
+
}
|
|
60
|
+
function getApiKey() {
|
|
61
|
+
if (process.env.AUTEN_API_KEY) {
|
|
62
|
+
return process.env.AUTEN_API_KEY;
|
|
63
|
+
}
|
|
64
|
+
return readConfig().apiKey;
|
|
65
|
+
}
|
|
66
|
+
function getBaseUrl() {
|
|
67
|
+
return readConfig().baseUrl || process.env.AUTEN_BASE_URL || "https://auten.ai";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/lib/output.ts
|
|
71
|
+
var import_chalk = __toESM(require("chalk"));
|
|
72
|
+
function header(text) {
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(import_chalk.default.bold.cyan(text));
|
|
75
|
+
console.log(import_chalk.default.dim("\u2500".repeat(text.length + 4)));
|
|
76
|
+
}
|
|
77
|
+
function success(text) {
|
|
78
|
+
console.log(import_chalk.default.green("\u2713") + " " + text);
|
|
79
|
+
}
|
|
80
|
+
function error(text) {
|
|
81
|
+
console.error(import_chalk.default.red("\u2717") + " " + text);
|
|
82
|
+
}
|
|
83
|
+
function warn(text) {
|
|
84
|
+
console.log(import_chalk.default.yellow("!") + " " + text);
|
|
85
|
+
}
|
|
86
|
+
function info(text) {
|
|
87
|
+
console.log(import_chalk.default.dim("i") + " " + text);
|
|
88
|
+
}
|
|
89
|
+
function table(headers, rows) {
|
|
90
|
+
const widths = headers.map((h, i) => {
|
|
91
|
+
const maxRow = Math.max(...rows.map((r) => (r[i] || "").length));
|
|
92
|
+
return Math.max(h.length, maxRow) + 2;
|
|
93
|
+
});
|
|
94
|
+
const headerLine = headers.map((h, i) => import_chalk.default.bold(h.padEnd(widths[i]))).join(" ");
|
|
95
|
+
console.log(headerLine);
|
|
96
|
+
console.log(widths.map((w) => import_chalk.default.dim("\u2500".repeat(w))).join(" "));
|
|
97
|
+
for (const row of rows) {
|
|
98
|
+
const line = row.map((cell, i) => (cell || "").padEnd(widths[i])).join(" ");
|
|
99
|
+
console.log(line);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/commands/login.ts
|
|
104
|
+
async function loginCommand() {
|
|
105
|
+
console.log();
|
|
106
|
+
console.log(import_chalk2.default.bold("Auten.ai Login"));
|
|
107
|
+
console.log();
|
|
108
|
+
info(`Get your API key at: ${import_chalk2.default.underline("https://auten.ai/settings")} \u2192 API Keys`);
|
|
109
|
+
console.log();
|
|
110
|
+
const { apiKey } = await import_inquirer.default.prompt([
|
|
111
|
+
{
|
|
112
|
+
type: "password",
|
|
113
|
+
name: "apiKey",
|
|
114
|
+
message: "Paste your API key:",
|
|
115
|
+
mask: "*",
|
|
116
|
+
validate: (input) => {
|
|
117
|
+
if (!input.startsWith("auten_live_") && !input.startsWith("auten_test_")) {
|
|
118
|
+
return "API key should start with auten_live_ or auten_test_";
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]);
|
|
124
|
+
const spinner = (0, import_ora.default)("Validating API key...").start();
|
|
125
|
+
try {
|
|
126
|
+
const baseUrl = getBaseUrl();
|
|
127
|
+
const auten = new import_sdk.Auten({ apiKey, baseUrl, retries: 0 });
|
|
128
|
+
const providers = await auten.providers.list();
|
|
129
|
+
spinner.stop();
|
|
130
|
+
success("Authenticated successfully!");
|
|
131
|
+
if (providers.length > 0) {
|
|
132
|
+
info(`${providers.length} provider(s) connected: ${providers.map((p) => p.slug).join(", ")}`);
|
|
133
|
+
} else {
|
|
134
|
+
info("No providers connected yet. Connect them at auten.ai/settings/integrations");
|
|
135
|
+
}
|
|
136
|
+
const config = readConfig();
|
|
137
|
+
config.apiKey = apiKey;
|
|
138
|
+
writeConfig(config);
|
|
139
|
+
console.log();
|
|
140
|
+
success(`API key saved to ${import_chalk2.default.dim("~/.auten/config.json")}`);
|
|
141
|
+
} catch (err) {
|
|
142
|
+
spinner.stop();
|
|
143
|
+
error(`Authentication failed: ${err.message}`);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/commands/providers.ts
|
|
149
|
+
var import_ora2 = __toESM(require("ora"));
|
|
150
|
+
var import_sdk2 = require("@autenai/sdk");
|
|
151
|
+
function requireAuth() {
|
|
152
|
+
const apiKey = getApiKey();
|
|
153
|
+
if (!apiKey) {
|
|
154
|
+
error("Not logged in. Run: auten login");
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
return new import_sdk2.Auten({ apiKey, baseUrl: getBaseUrl() });
|
|
158
|
+
}
|
|
159
|
+
async function providersListCommand() {
|
|
160
|
+
const auten = requireAuth();
|
|
161
|
+
const spinner = (0, import_ora2.default)("Fetching providers...").start();
|
|
162
|
+
try {
|
|
163
|
+
const providers = await auten.providers.list();
|
|
164
|
+
spinner.stop();
|
|
165
|
+
if (providers.length === 0) {
|
|
166
|
+
header("Connected Providers");
|
|
167
|
+
info("No providers connected. Visit auten.ai/settings/integrations to connect.");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
header(`Connected Providers (${providers.length})`);
|
|
171
|
+
table(
|
|
172
|
+
["Provider", "Category", "Account", "Connected"],
|
|
173
|
+
providers.map((p) => [
|
|
174
|
+
p.slug,
|
|
175
|
+
p.category,
|
|
176
|
+
p.accountEmail || "-",
|
|
177
|
+
new Date(p.connectedAt).toLocaleDateString()
|
|
178
|
+
])
|
|
179
|
+
);
|
|
180
|
+
} catch (err) {
|
|
181
|
+
spinner.stop();
|
|
182
|
+
error(err.message);
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/commands/init.ts
|
|
188
|
+
var fs2 = __toESM(require("fs"));
|
|
189
|
+
var path2 = __toESM(require("path"));
|
|
190
|
+
var import_inquirer2 = __toESM(require("inquirer"));
|
|
191
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
192
|
+
async function initCommand(name) {
|
|
193
|
+
console.log();
|
|
194
|
+
console.log(import_chalk3.default.bold("Create a new Auten agent"));
|
|
195
|
+
console.log();
|
|
196
|
+
let projectName = name;
|
|
197
|
+
let description = "";
|
|
198
|
+
if (!projectName) {
|
|
199
|
+
const answers = await import_inquirer2.default.prompt([
|
|
200
|
+
{
|
|
201
|
+
type: "input",
|
|
202
|
+
name: "name",
|
|
203
|
+
message: "Agent name:",
|
|
204
|
+
default: "my-agent",
|
|
205
|
+
validate: (input) => input.trim() ? true : "Name is required"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
type: "input",
|
|
209
|
+
name: "description",
|
|
210
|
+
message: "Description (optional):"
|
|
211
|
+
}
|
|
212
|
+
]);
|
|
213
|
+
projectName = answers.name;
|
|
214
|
+
description = answers.description;
|
|
215
|
+
}
|
|
216
|
+
const dir = path2.resolve(projectName);
|
|
217
|
+
if (fs2.existsSync(dir)) {
|
|
218
|
+
error(`Directory "${projectName}" already exists`);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
222
|
+
fs2.mkdirSync(path2.join(dir, "tools"));
|
|
223
|
+
const config = {
|
|
224
|
+
name: projectName,
|
|
225
|
+
description,
|
|
226
|
+
tools: ["example-tool"],
|
|
227
|
+
schedule: {
|
|
228
|
+
cron: "0 9 * * *",
|
|
229
|
+
timezone: "UTC"
|
|
230
|
+
},
|
|
231
|
+
providers: []
|
|
232
|
+
};
|
|
233
|
+
fs2.writeFileSync(
|
|
234
|
+
path2.join(dir, "auten.config.json"),
|
|
235
|
+
JSON.stringify(config, null, 2)
|
|
236
|
+
);
|
|
237
|
+
const exampleTool = `/**
|
|
238
|
+
* Example Auten agent tool
|
|
239
|
+
*
|
|
240
|
+
* Available globals:
|
|
241
|
+
* Auth.getToken(provider) \u2014 Get OAuth token (auto-refreshed)
|
|
242
|
+
* HTTP.get/post/put/delete \u2014 HTTP requests
|
|
243
|
+
* AI.call(prompt) \u2014 LLM text response
|
|
244
|
+
* AI.json(prompt) \u2014 LLM JSON response
|
|
245
|
+
* Knowledge.get/set \u2014 Read/write persistent data
|
|
246
|
+
* log(message, data) \u2014 Logging
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
const { spec, previousResults } = __context__;
|
|
250
|
+
|
|
251
|
+
log('Hello from example-tool!');
|
|
252
|
+
|
|
253
|
+
// Example: fetch data from a provider
|
|
254
|
+
// const { accessToken } = await Auth.getToken('google-gmail');
|
|
255
|
+
// const emails = await HTTP.get('https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=5', {
|
|
256
|
+
// headers: { Authorization: 'Bearer ' + accessToken }
|
|
257
|
+
// });
|
|
258
|
+
|
|
259
|
+
// Example: use AI to analyze data
|
|
260
|
+
// const analysis = await AI.json(\`
|
|
261
|
+
// Analyze this data: \${JSON.stringify(data)}
|
|
262
|
+
// Return: { summary: string, action: string }
|
|
263
|
+
// \`);
|
|
264
|
+
|
|
265
|
+
return { success: true, message: 'Example tool executed' };
|
|
266
|
+
`;
|
|
267
|
+
fs2.writeFileSync(path2.join(dir, "tools", "example-tool.js"), exampleTool);
|
|
268
|
+
const packageJson = {
|
|
269
|
+
name: projectName,
|
|
270
|
+
version: "1.0.0",
|
|
271
|
+
private: true,
|
|
272
|
+
description: description || `Auten.ai agent: ${projectName}`,
|
|
273
|
+
scripts: {
|
|
274
|
+
deploy: "auten agent deploy",
|
|
275
|
+
run: "auten agent run --once"
|
|
276
|
+
},
|
|
277
|
+
dependencies: {
|
|
278
|
+
"@autenai/sdk": "^0.1.0"
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
fs2.writeFileSync(
|
|
282
|
+
path2.join(dir, "package.json"),
|
|
283
|
+
JSON.stringify(packageJson, null, 2)
|
|
284
|
+
);
|
|
285
|
+
fs2.writeFileSync(path2.join(dir, ".gitignore"), "node_modules/\n.env\ndata/\n");
|
|
286
|
+
fs2.writeFileSync(
|
|
287
|
+
path2.join(dir, ".env.example"),
|
|
288
|
+
"# Your Auten API key (get at https://auten.ai/settings \u2192 API Keys)\nAUTEN_API_KEY=\n"
|
|
289
|
+
);
|
|
290
|
+
console.log();
|
|
291
|
+
success(`Agent project created: ${import_chalk3.default.bold(projectName)}/`);
|
|
292
|
+
console.log();
|
|
293
|
+
info("Project structure:");
|
|
294
|
+
console.log(` ${import_chalk3.default.dim(projectName + "/")}`);
|
|
295
|
+
console.log(` \u251C\u2500\u2500 auten.config.json ${import_chalk3.default.dim("Agent configuration")}`);
|
|
296
|
+
console.log(` \u251C\u2500\u2500 package.json`);
|
|
297
|
+
console.log(` \u251C\u2500\u2500 .env.example`);
|
|
298
|
+
console.log(` \u2514\u2500\u2500 tools/`);
|
|
299
|
+
console.log(` \u2514\u2500\u2500 example-tool.js ${import_chalk3.default.dim("Your first tool")}`);
|
|
300
|
+
console.log();
|
|
301
|
+
info("Next steps:");
|
|
302
|
+
console.log(` 1. ${import_chalk3.default.cyan("cd " + projectName)}`);
|
|
303
|
+
console.log(` 2. Edit ${import_chalk3.default.cyan("tools/example-tool.js")}`);
|
|
304
|
+
console.log(` 3. ${import_chalk3.default.cyan("auten agent deploy")} to deploy`);
|
|
305
|
+
console.log(` 4. ${import_chalk3.default.cyan("auten agent run --once")} to test`);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/commands/agent.ts
|
|
309
|
+
var fs3 = __toESM(require("fs"));
|
|
310
|
+
var path3 = __toESM(require("path"));
|
|
311
|
+
var import_ora3 = __toESM(require("ora"));
|
|
312
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
313
|
+
var import_sdk3 = require("@autenai/sdk");
|
|
314
|
+
function requireAuth2() {
|
|
315
|
+
const apiKey = getApiKey();
|
|
316
|
+
if (!apiKey) {
|
|
317
|
+
error("Not logged in. Run: auten login");
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
return new import_sdk3.Auten({ apiKey, baseUrl: getBaseUrl() });
|
|
321
|
+
}
|
|
322
|
+
function readAgentConfig() {
|
|
323
|
+
const configPath = path3.resolve("auten.config.json");
|
|
324
|
+
if (!fs3.existsSync(configPath)) {
|
|
325
|
+
error("No auten.config.json found. Run: auten init");
|
|
326
|
+
process.exit(1);
|
|
327
|
+
}
|
|
328
|
+
return JSON.parse(fs3.readFileSync(configPath, "utf-8"));
|
|
329
|
+
}
|
|
330
|
+
function writeAgentConfig(config) {
|
|
331
|
+
fs3.writeFileSync(
|
|
332
|
+
path3.resolve("auten.config.json"),
|
|
333
|
+
JSON.stringify(config, null, 2)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
async function agentListCommand() {
|
|
337
|
+
const auten = requireAuth2();
|
|
338
|
+
const spinner = (0, import_ora3.default)("Fetching agents...").start();
|
|
339
|
+
try {
|
|
340
|
+
const agents = await auten.agents.list();
|
|
341
|
+
spinner.stop();
|
|
342
|
+
if (agents.length === 0) {
|
|
343
|
+
header("My Agents");
|
|
344
|
+
info("No agents yet. Run: auten init my-agent");
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
header(`My Agents (${agents.length})`);
|
|
348
|
+
table(
|
|
349
|
+
["ID", "Name", "Status", "Schedule"],
|
|
350
|
+
agents.map((a) => [
|
|
351
|
+
a.id.substring(0, 12) + "...",
|
|
352
|
+
a.name,
|
|
353
|
+
a.status,
|
|
354
|
+
a.schedule?.cron || "-"
|
|
355
|
+
])
|
|
356
|
+
);
|
|
357
|
+
} catch (err) {
|
|
358
|
+
spinner.stop();
|
|
359
|
+
error(err.message);
|
|
360
|
+
process.exit(1);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async function agentDeployCommand() {
|
|
364
|
+
const auten = requireAuth2();
|
|
365
|
+
const config = readAgentConfig();
|
|
366
|
+
const toolsDir = path3.resolve("tools");
|
|
367
|
+
if (!fs3.existsSync(toolsDir)) {
|
|
368
|
+
error("No tools/ directory found");
|
|
369
|
+
process.exit(1);
|
|
370
|
+
}
|
|
371
|
+
const tools = [];
|
|
372
|
+
for (const toolName of config.tools) {
|
|
373
|
+
const toolPath = path3.join(toolsDir, `${toolName}.js`);
|
|
374
|
+
if (!fs3.existsSync(toolPath)) {
|
|
375
|
+
warn(`Tool file not found: tools/${toolName}.js \u2014 skipping`);
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
const code = fs3.readFileSync(toolPath, "utf-8");
|
|
379
|
+
tools.push({ name: toolName, code });
|
|
380
|
+
}
|
|
381
|
+
if (tools.length === 0) {
|
|
382
|
+
error("No tools to deploy");
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
const spinner = (0, import_ora3.default)(`Deploying ${tools.length} tool(s)...`).start();
|
|
386
|
+
try {
|
|
387
|
+
if (config.agentId) {
|
|
388
|
+
const result = await auten.agents.deploy(config.agentId, {
|
|
389
|
+
tools,
|
|
390
|
+
schedule: config.schedule
|
|
391
|
+
});
|
|
392
|
+
spinner.stop();
|
|
393
|
+
success(`Deployed to agent ${import_chalk4.default.bold(config.agentId.substring(0, 12))}...`);
|
|
394
|
+
info(`Tools: ${result.tools.join(", ")}`);
|
|
395
|
+
} else {
|
|
396
|
+
const result = await auten.agents.create({
|
|
397
|
+
name: config.name,
|
|
398
|
+
description: config.description,
|
|
399
|
+
tools,
|
|
400
|
+
schedule: config.schedule
|
|
401
|
+
});
|
|
402
|
+
config.agentId = result.id;
|
|
403
|
+
writeAgentConfig(config);
|
|
404
|
+
spinner.stop();
|
|
405
|
+
success(`Agent created: ${import_chalk4.default.bold(result.id)}`);
|
|
406
|
+
info(`Tools: ${tools.map((t) => t.name).join(", ")}`);
|
|
407
|
+
info(`Status: ${result.status}`);
|
|
408
|
+
}
|
|
409
|
+
} catch (err) {
|
|
410
|
+
spinner.stop();
|
|
411
|
+
error(err.message);
|
|
412
|
+
process.exit(1);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
async function agentRunCommand(options) {
|
|
416
|
+
const auten = requireAuth2();
|
|
417
|
+
const config = readAgentConfig();
|
|
418
|
+
if (!config.agentId) {
|
|
419
|
+
error("Agent not deployed yet. Run: auten agent deploy");
|
|
420
|
+
process.exit(1);
|
|
421
|
+
}
|
|
422
|
+
const spinner = (0, import_ora3.default)("Triggering agent run...").start();
|
|
423
|
+
try {
|
|
424
|
+
const result = await auten.agents.run(config.agentId);
|
|
425
|
+
spinner.stop();
|
|
426
|
+
success(`Agent run triggered`);
|
|
427
|
+
info(`Execution ID: ${result.executionId || "started"}`);
|
|
428
|
+
info(`Status: ${result.status || "running"}`);
|
|
429
|
+
if (options.once) {
|
|
430
|
+
info("Waiting for completion...");
|
|
431
|
+
let status = "running";
|
|
432
|
+
while (status === "running") {
|
|
433
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
434
|
+
const agentStatus = await auten.agents.status(config.agentId);
|
|
435
|
+
status = agentStatus.status;
|
|
436
|
+
process.stdout.write(".");
|
|
437
|
+
}
|
|
438
|
+
console.log();
|
|
439
|
+
success(`Run complete: ${status}`);
|
|
440
|
+
}
|
|
441
|
+
} catch (err) {
|
|
442
|
+
spinner.stop();
|
|
443
|
+
error(err.message);
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
async function agentStatusCommand(id) {
|
|
448
|
+
const auten = requireAuth2();
|
|
449
|
+
const agentId = id || readAgentConfig().agentId;
|
|
450
|
+
if (!agentId) {
|
|
451
|
+
error("No agent ID. Deploy first or provide ID: auten agent status <id>");
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
const spinner = (0, import_ora3.default)("Fetching status...").start();
|
|
455
|
+
try {
|
|
456
|
+
const agent = await auten.agents.get(agentId);
|
|
457
|
+
spinner.stop();
|
|
458
|
+
header(agent.name);
|
|
459
|
+
console.log(` Status: ${import_chalk4.default.bold(agent.status)}`);
|
|
460
|
+
console.log(` Tools: ${agent.tools.map((t) => t.name).join(", ")}`);
|
|
461
|
+
if (agent.schedule) {
|
|
462
|
+
console.log(` Schedule: ${agent.schedule.cron} (${agent.schedule.timezone})`);
|
|
463
|
+
console.log(` Enabled: ${agent.schedule.enabled ? import_chalk4.default.green("yes") : import_chalk4.default.red("no")}`);
|
|
464
|
+
}
|
|
465
|
+
console.log(` Created: ${new Date(agent.createdAt).toLocaleString()}`);
|
|
466
|
+
console.log(` Updated: ${new Date(agent.updatedAt).toLocaleString()}`);
|
|
467
|
+
} catch (err) {
|
|
468
|
+
spinner.stop();
|
|
469
|
+
error(err.message);
|
|
470
|
+
process.exit(1);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// src/index.ts
|
|
475
|
+
var program = new import_commander.Command();
|
|
476
|
+
program.name("auten").description("Auten.ai CLI \u2014 build and deploy AI agents").version("0.1.0");
|
|
477
|
+
program.command("login").description("Authenticate with your Auten.ai API key").action(loginCommand);
|
|
478
|
+
var providersCmd = program.command("providers").description("Manage provider connections");
|
|
479
|
+
providersCmd.command("list").description("List connected providers").action(providersListCommand);
|
|
480
|
+
program.command("init [name]").description("Create a new agent project").action(initCommand);
|
|
481
|
+
var agentCmd = program.command("agent").description("Manage agents");
|
|
482
|
+
agentCmd.command("list").description("List your agents").action(agentListCommand);
|
|
483
|
+
agentCmd.command("deploy").description("Deploy agent from current directory").action(agentDeployCommand);
|
|
484
|
+
agentCmd.command("run").description("Trigger agent execution").option("--once", "Wait for completion").action(agentRunCommand);
|
|
485
|
+
agentCmd.command("status [id]").description("Show agent status").action(agentStatusCommand);
|
|
486
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autenai/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Auten.ai CLI — build and deploy AI agents from your terminal",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"auten": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup src/index.ts --format cjs --target node18 --clean",
|
|
14
|
+
"dev": "tsup src/index.ts --format cjs --target node18 --watch",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"auten",
|
|
19
|
+
"ai",
|
|
20
|
+
"agents",
|
|
21
|
+
"automation",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@autenai/sdk": "^0.1.0",
|
|
27
|
+
"commander": "^12.0.0",
|
|
28
|
+
"chalk": "^4.1.2",
|
|
29
|
+
"ora": "^5.4.1",
|
|
30
|
+
"inquirer": "^8.2.6"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/inquirer": "^9.0.0",
|
|
34
|
+
"tsup": "^8.0.0",
|
|
35
|
+
"typescript": "^5.3.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
}
|
|
40
|
+
}
|