@castari/cli 0.1.11 → 0.2.1
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 +79 -90
- package/bin/cast.js +2 -0
- package/dist/commands/agents.d.ts +6 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +174 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/apikey.d.ts +6 -0
- package/dist/commands/apikey.d.ts.map +1 -0
- package/dist/commands/apikey.js +57 -0
- package/dist/commands/apikey.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -3
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +24 -64
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/invoke.d.ts +3 -0
- package/dist/commands/invoke.d.ts.map +1 -0
- package/dist/commands/invoke.js +50 -0
- package/dist/commands/invoke.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +123 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/secrets.d.ts +6 -0
- package/dist/commands/secrets.d.ts.map +1 -0
- package/dist/commands/secrets.js +90 -0
- package/dist/commands/secrets.js.map +1 -0
- package/dist/commands/stop.d.ts +3 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +25 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +76 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +27 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -34
- package/dist/index.js.map +1 -0
- package/dist/utils/errors.d.ts +6 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +42 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/output.d.ts +45 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +75 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +56 -35
- package/LICENSE +0 -21
- package/dist/commands/client-id.d.ts +0 -1
- package/dist/commands/client-id.js +0 -25
- package/dist/commands/dev.d.ts +0 -1
- package/dist/commands/dev.js +0 -17
- package/dist/commands/generate-secrets.d.ts +0 -1
- package/dist/commands/generate-secrets.js +0 -60
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.js +0 -899
- package/dist/commands/start.d.ts +0 -5
- package/dist/commands/start.js +0 -100
- package/dist/utils/client-auth.d.ts +0 -11
- package/dist/utils/client-auth.js +0 -21
- package/dist/utils/client-id.d.ts +0 -10
- package/dist/utils/client-id.js +0 -36
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { CastariClient } from '@castari/sdk';
|
|
6
|
+
import { blank, formatNumber, formatCost } from '../utils/output.js';
|
|
7
|
+
import { handleError } from '../utils/errors.js';
|
|
8
|
+
export const invokeCommand = new Command('invoke')
|
|
9
|
+
.description('Invoke an agent with a prompt')
|
|
10
|
+
.argument('<slug>', 'Agent slug')
|
|
11
|
+
.argument('[prompt]', 'Prompt to send to the agent')
|
|
12
|
+
.option('-i, --input <file>', 'Read prompt from file')
|
|
13
|
+
.action(async (slug, promptArg, options) => {
|
|
14
|
+
try {
|
|
15
|
+
// Get prompt from argument or file
|
|
16
|
+
let prompt;
|
|
17
|
+
if (options?.input) {
|
|
18
|
+
prompt = await readFile(options.input, 'utf-8');
|
|
19
|
+
}
|
|
20
|
+
else if (promptArg) {
|
|
21
|
+
prompt = promptArg;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.error(chalk.red('Error: Either a prompt or --input <file> is required'));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const spinner = ora(`Invoking ${slug}...`).start();
|
|
28
|
+
const client = new CastariClient();
|
|
29
|
+
await client.ensureAuthenticated();
|
|
30
|
+
spinner.text = `Invoking ${slug}... (this may take a while)`;
|
|
31
|
+
const result = await client.agents.invoke(slug, { prompt });
|
|
32
|
+
spinner.stop();
|
|
33
|
+
blank();
|
|
34
|
+
// Print the response
|
|
35
|
+
console.log(result.response_content);
|
|
36
|
+
// Print usage stats
|
|
37
|
+
blank();
|
|
38
|
+
console.log(chalk.gray('─'.repeat(50)));
|
|
39
|
+
console.log(chalk.gray(`Tokens: ${formatNumber(result.input_tokens)} in / ${formatNumber(result.output_tokens)} out`));
|
|
40
|
+
const cost = typeof result.total_cost_usd === 'string'
|
|
41
|
+
? parseFloat(result.total_cost_usd)
|
|
42
|
+
: result.total_cost_usd;
|
|
43
|
+
console.log(chalk.gray(`Cost: ${formatCost(cost)}`));
|
|
44
|
+
console.log(chalk.gray(`Duration: ${(result.duration_ms / 1000).toFixed(1)}s`));
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
handleError(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=invoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../src/commands/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,c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AAI,EAAE,CAAC;QACf,KAAK,EAAE,CAAC;QAER,qBAAqB;QACrB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAErC,oBAAoB;QACpB,KAAK,EAAE,CAAC;QACR,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CACR,WAAW,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAC9F,CACF,CAAC;QACF,MAAM,IAAI,GAAG,OAAO,MAAM,CAAC,cAAc,KAAK,QAAQ;YACpD,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC;YACnC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiGpC,eAAO,MAAM,YAAY,SA2CrB,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import open from 'open';
|
|
4
|
+
import { createServer } from 'node:http';
|
|
5
|
+
import { saveCredentials, CastariClient, getApiUrl } from '@castari/sdk';
|
|
6
|
+
import { info } from '../utils/output.js';
|
|
7
|
+
import { handleError } from '../utils/errors.js';
|
|
8
|
+
/**
|
|
9
|
+
* Find an available port for the local callback server
|
|
10
|
+
*/
|
|
11
|
+
async function findAvailablePort() {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const server = createServer();
|
|
14
|
+
server.listen(0, () => {
|
|
15
|
+
const address = server.address();
|
|
16
|
+
if (address && typeof address === 'object') {
|
|
17
|
+
const port = address.port;
|
|
18
|
+
server.close(() => resolve(port));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
reject(new Error('Failed to find available port'));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
server.on('error', reject);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Start a local server to receive the OAuth callback
|
|
29
|
+
*/
|
|
30
|
+
async function startCallbackServer(port) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const timeout = setTimeout(() => {
|
|
33
|
+
server.close();
|
|
34
|
+
reject(new Error('Login timed out. Please try again.'));
|
|
35
|
+
}, 120000); // 2 minute timeout
|
|
36
|
+
const server = createServer((req, res) => {
|
|
37
|
+
const url = new URL(req.url || '/', `http://localhost:${port}`);
|
|
38
|
+
if (url.pathname === '/callback') {
|
|
39
|
+
const token = url.searchParams.get('token');
|
|
40
|
+
const errorParam = url.searchParams.get('error');
|
|
41
|
+
if (errorParam) {
|
|
42
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
43
|
+
res.end(`
|
|
44
|
+
<html>
|
|
45
|
+
<body style="font-family: system-ui; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0;">
|
|
46
|
+
<div style="text-align: center;">
|
|
47
|
+
<h1 style="color: #e53e3e;">Login Failed</h1>
|
|
48
|
+
<p>${errorParam}</p>
|
|
49
|
+
<p>You can close this window.</p>
|
|
50
|
+
</div>
|
|
51
|
+
</body>
|
|
52
|
+
</html>
|
|
53
|
+
`);
|
|
54
|
+
clearTimeout(timeout);
|
|
55
|
+
server.close();
|
|
56
|
+
reject(new Error(errorParam));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (token) {
|
|
60
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
61
|
+
res.end(`
|
|
62
|
+
<html>
|
|
63
|
+
<body style="font-family: system-ui; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0;">
|
|
64
|
+
<div style="text-align: center;">
|
|
65
|
+
<h1 style="color: #38a169;">Login Successful!</h1>
|
|
66
|
+
<p>You can close this window and return to the terminal.</p>
|
|
67
|
+
</div>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
`);
|
|
71
|
+
clearTimeout(timeout);
|
|
72
|
+
server.close();
|
|
73
|
+
resolve(token);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
res.writeHead(404);
|
|
78
|
+
res.end('Not found');
|
|
79
|
+
});
|
|
80
|
+
server.listen(port, () => {
|
|
81
|
+
// Server is ready
|
|
82
|
+
});
|
|
83
|
+
server.on('error', (err) => {
|
|
84
|
+
clearTimeout(timeout);
|
|
85
|
+
reject(err);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export const loginCommand = new Command('login')
|
|
90
|
+
.description('Authenticate with Castari')
|
|
91
|
+
.action(async () => {
|
|
92
|
+
const spinner = ora('Preparing authentication...').start();
|
|
93
|
+
try {
|
|
94
|
+
// Find an available port for the callback
|
|
95
|
+
const port = await findAvailablePort();
|
|
96
|
+
spinner.text = 'Starting authentication server...';
|
|
97
|
+
// Get the API URL
|
|
98
|
+
const apiUrl = await getApiUrl();
|
|
99
|
+
const authUrl = `${apiUrl}/api/v1/auth/cli/login?port=${port}`;
|
|
100
|
+
// Start the callback server
|
|
101
|
+
const tokenPromise = startCallbackServer(port);
|
|
102
|
+
spinner.stop();
|
|
103
|
+
info(`Opening browser for authentication...`);
|
|
104
|
+
info(`If the browser doesn't open, visit: ${authUrl}`);
|
|
105
|
+
// Open the browser
|
|
106
|
+
await open(authUrl);
|
|
107
|
+
spinner.start('Waiting for authentication...');
|
|
108
|
+
// Wait for the callback
|
|
109
|
+
const token = await tokenPromise;
|
|
110
|
+
spinner.text = 'Saving credentials...';
|
|
111
|
+
// Save the token
|
|
112
|
+
await saveCredentials({ token });
|
|
113
|
+
// Verify the token works by getting user info
|
|
114
|
+
const client = new CastariClient({ token });
|
|
115
|
+
const user = await client.auth.me();
|
|
116
|
+
spinner.succeed(`Logged in as ${user.email}`);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
spinner.fail('Login failed');
|
|
120
|
+
handleError(err);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAkB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,KAAK,UAAU,iBAAiB;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC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oot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,eAAO,MAAM,aAAa,SAStB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { clearCredentials } from '@castari/sdk';
|
|
3
|
+
import { success } from '../utils/output.js';
|
|
4
|
+
import { handleError } from '../utils/errors.js';
|
|
5
|
+
export const logoutCommand = new Command('logout')
|
|
6
|
+
.description('Clear stored credentials')
|
|
7
|
+
.action(async () => {
|
|
8
|
+
try {
|
|
9
|
+
await clearCredentials();
|
|
10
|
+
success('Logged out successfully');
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
handleError(err);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,gBAAgB,EAAE,CAAC;QACzB,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/commands/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6FpC;;GAEG;AACH,eAAO,MAAM,cAAc,SAIC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { CastariClient } from '@castari/sdk';
|
|
5
|
+
import { info, hint, blank } from '../utils/output.js';
|
|
6
|
+
import { handleError } from '../utils/errors.js';
|
|
7
|
+
/**
|
|
8
|
+
* cast secrets list <slug>
|
|
9
|
+
*/
|
|
10
|
+
const listCommand = new Command('list')
|
|
11
|
+
.description('List secret keys for an agent')
|
|
12
|
+
.argument('<slug>', 'Agent slug')
|
|
13
|
+
.action(async (slug) => {
|
|
14
|
+
const spinner = ora('Fetching secrets...').start();
|
|
15
|
+
try {
|
|
16
|
+
const client = new CastariClient();
|
|
17
|
+
await client.ensureAuthenticated();
|
|
18
|
+
const secrets = await client.agents.listSecrets(slug);
|
|
19
|
+
spinner.stop();
|
|
20
|
+
if (secrets.length === 0) {
|
|
21
|
+
info(`No secrets set for agent '${slug}'`);
|
|
22
|
+
hint(`Set one with: cast secrets set ${slug} <key> <value>`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
blank();
|
|
26
|
+
console.log(chalk.bold(`Secrets for '${slug}':`));
|
|
27
|
+
blank();
|
|
28
|
+
for (const secret of secrets) {
|
|
29
|
+
console.log(` ${chalk.cyan('•')} ${secret.key}`);
|
|
30
|
+
}
|
|
31
|
+
blank();
|
|
32
|
+
info('Note: Secret values are never displayed for security');
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
spinner.fail('Failed to list secrets');
|
|
36
|
+
handleError(err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* cast secrets set <slug> <key> <value>
|
|
41
|
+
*/
|
|
42
|
+
const setCommand = new Command('set')
|
|
43
|
+
.description('Set a secret for an agent')
|
|
44
|
+
.argument('<slug>', 'Agent slug')
|
|
45
|
+
.argument('<key>', 'Secret key (e.g., API_KEY)')
|
|
46
|
+
.argument('<value>', 'Secret value')
|
|
47
|
+
.action(async (slug, key, value) => {
|
|
48
|
+
const spinner = ora('Setting secret...').start();
|
|
49
|
+
try {
|
|
50
|
+
const client = new CastariClient();
|
|
51
|
+
await client.ensureAuthenticated();
|
|
52
|
+
await client.agents.setSecret(slug, key, value);
|
|
53
|
+
spinner.succeed(`Secret '${key}' set for agent '${slug}'`);
|
|
54
|
+
hint('Redeploy the agent to apply changes');
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
spinner.fail('Failed to set secret');
|
|
58
|
+
handleError(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* cast secrets delete <slug> <key>
|
|
63
|
+
*/
|
|
64
|
+
const deleteCommand = new Command('delete')
|
|
65
|
+
.description('Delete a secret from an agent')
|
|
66
|
+
.argument('<slug>', 'Agent slug')
|
|
67
|
+
.argument('<key>', 'Secret key to delete')
|
|
68
|
+
.action(async (slug, key) => {
|
|
69
|
+
const spinner = ora('Deleting secret...').start();
|
|
70
|
+
try {
|
|
71
|
+
const client = new CastariClient();
|
|
72
|
+
await client.ensureAuthenticated();
|
|
73
|
+
await client.agents.deleteSecret(slug, key);
|
|
74
|
+
spinner.succeed(`Secret '${key}' deleted from agent '${slug}'`);
|
|
75
|
+
hint('Redeploy the agent to apply changes');
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
spinner.fail('Failed to delete secret');
|
|
79
|
+
handleError(err);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* cast secrets
|
|
84
|
+
*/
|
|
85
|
+
export const secretsCommand = new Command('secrets')
|
|
86
|
+
.description('Manage agent secrets')
|
|
87
|
+
.addCommand(listCommand)
|
|
88
|
+
.addCommand(setCommand)
|
|
89
|
+
.addCommand(deleteCommand);
|
|
90
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/commands/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAW,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KACpC,WAAW,CAAC,+BAA+B,CAAC;KAC5C,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;KAChC,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,KAAK,EAAE,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,CAAC,mBAAmB,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAEtD,OAAO,CAAC,IAAI,EAAE,CAAC;QAEf,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,6BAA6B,IAAI,GAAG,CAAC,CAAC;YAC3C,IAAI,CAAC,kCAAkC,IAAI,gBAAgB,CAAC,CAAC;YAC7D,OAAO;QACT,CAAC;QAED,KAAK,EAAE,CAAC;QACR,OAAO,CAAC,GAAG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OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,WAAW,SAoBpB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { CastariClient } from '@castari/sdk';
|
|
4
|
+
import { keyValue, blank } from '../utils/output.js';
|
|
5
|
+
import { handleError } from '../utils/errors.js';
|
|
6
|
+
export const stopCommand = new Command('stop')
|
|
7
|
+
.description('Stop a running agent')
|
|
8
|
+
.argument('<slug>', 'Agent slug')
|
|
9
|
+
.action(async (slug) => {
|
|
10
|
+
const spinner = ora(`Stopping ${slug}...`).start();
|
|
11
|
+
try {
|
|
12
|
+
const client = new CastariClient();
|
|
13
|
+
await client.ensureAuthenticated();
|
|
14
|
+
const agent = await client.agents.stop(slug);
|
|
15
|
+
spinner.succeed(`Agent '${slug}' stopped`);
|
|
16
|
+
blank();
|
|
17
|
+
keyValue('Status', agent.status);
|
|
18
|
+
blank();
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
spinner.fail('Failed to stop agent');
|
|
22
|
+
handleError(err);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=stop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.js","sourceRoot":"","sources":["../../src/commands/stop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAW,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,sBAAsB,CAAC;KACnC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;KAChC,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;IAEnD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QACnC,MAAM,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAEnC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,WAAW,CAAC,CAAC;QAC3C,KAAK,EAAE,CAAC;QACR,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,KAAK,EAAE,CAAC;IACV,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACrC,WAAW,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,eAAO,MAAM,YAAY,SAkFrB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import Table from 'cli-table3';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { CastariClient } from '@castari/sdk';
|
|
6
|
+
import { blank, formatNumber, formatCost, header } from '../utils/output.js';
|
|
7
|
+
import { handleError } from '../utils/errors.js';
|
|
8
|
+
export const usageCommand = new Command('usage')
|
|
9
|
+
.description('Show usage statistics')
|
|
10
|
+
.option('-d, --days <days>', 'Number of days to show (default: 30)', '30')
|
|
11
|
+
.option('--daily', 'Show daily breakdown')
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const spinner = ora('Fetching usage data...').start();
|
|
14
|
+
try {
|
|
15
|
+
const client = new CastariClient();
|
|
16
|
+
await client.ensureAuthenticated();
|
|
17
|
+
const days = parseInt(options.days, 10);
|
|
18
|
+
if (options.daily) {
|
|
19
|
+
// Show daily breakdown
|
|
20
|
+
const dailyUsage = await client.usage.daily({ days });
|
|
21
|
+
spinner.stop();
|
|
22
|
+
blank();
|
|
23
|
+
header(`Usage (last ${days} days)`);
|
|
24
|
+
blank();
|
|
25
|
+
if (dailyUsage.length === 0) {
|
|
26
|
+
console.log(chalk.gray(' No usage data available'));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const table = new Table({
|
|
30
|
+
head: [
|
|
31
|
+
chalk.white('Date'),
|
|
32
|
+
chalk.white('Invocations'),
|
|
33
|
+
chalk.white('Input Tokens'),
|
|
34
|
+
chalk.white('Output Tokens'),
|
|
35
|
+
chalk.white('Cost'),
|
|
36
|
+
],
|
|
37
|
+
style: {
|
|
38
|
+
head: [],
|
|
39
|
+
border: [],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
for (const day of dailyUsage) {
|
|
43
|
+
table.push([
|
|
44
|
+
day.date,
|
|
45
|
+
formatNumber(day.invocation_count),
|
|
46
|
+
formatNumber(day.input_tokens),
|
|
47
|
+
formatNumber(day.output_tokens),
|
|
48
|
+
formatCost(day.cost_usd),
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
console.log(table.toString());
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Show summary
|
|
55
|
+
const summary = await client.usage.summary({ days });
|
|
56
|
+
spinner.stop();
|
|
57
|
+
blank();
|
|
58
|
+
header(`Usage Summary (last ${days} days)`);
|
|
59
|
+
blank();
|
|
60
|
+
const table = new Table({
|
|
61
|
+
style: {
|
|
62
|
+
head: [],
|
|
63
|
+
border: [],
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
table.push([chalk.gray('Total Invocations'), formatNumber(summary.total_invocations)], [chalk.gray('Input Tokens'), formatNumber(summary.total_input_tokens)], [chalk.gray('Output Tokens'), formatNumber(summary.total_output_tokens)], [chalk.gray('Total Cost'), chalk.green(formatCost(summary.total_cost_usd))]);
|
|
67
|
+
console.log(table.toString());
|
|
68
|
+
blank();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
spinner.fail('Failed to fetch usage data');
|
|
73
|
+
handleError(err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/commands/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,uBAAuB,CAAC;KACpC,MAAM,CAAC,mBAAmB,EAAE,sCAAsC,EAAE,IAAI,CAAC;KACzE,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC;KACzC,MAAM,CAAC,KAAK,EAAE,OAA0C,EAAE,EAAE;IAC3D,MAAM,OAAO,GAAG,GAAG,CAAC,wBAAwB,CAAC,CAAC,KAAK,EAAE,CAAC;IAEtD,IAAI,CAA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IACnB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,aAAa,SAqBtB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import { CastariClient } from '@castari/sdk';
|
|
4
|
+
import { keyValue, blank } from '../utils/output.js';
|
|
5
|
+
import { handleError } from '../utils/errors.js';
|
|
6
|
+
export const whoamiCommand = new Command('whoami')
|
|
7
|
+
.description('Show current authenticated user')
|
|
8
|
+
.action(async () => {
|
|
9
|
+
const spinner = ora('Fetching user info...').start();
|
|
10
|
+
try {
|
|
11
|
+
const client = new CastariClient();
|
|
12
|
+
await client.ensureAuthenticated();
|
|
13
|
+
const user = await client.auth.me();
|
|
14
|
+
spinner.stop();
|
|
15
|
+
blank();
|
|
16
|
+
keyValue('Email', user.email);
|
|
17
|
+
keyValue('User ID', user.id);
|
|
18
|
+
keyValue('API Key', user.api_key_prefix ? `${user.api_key_prefix}...` : 'None');
|
|
19
|
+
keyValue('Created', new Date(user.created_at).toLocaleDateString());
|
|
20
|
+
blank();
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
spinner.fail('Failed to get user info');
|
|
24
|
+
handleError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAA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":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { loginCommand } from './commands/login.js';
|
|
4
|
+
import { logoutCommand } from './commands/logout.js';
|
|
5
|
+
import { whoamiCommand } from './commands/whoami.js';
|
|
6
|
+
import { apikeyCommand } from './commands/apikey.js';
|
|
7
|
+
import { agentsCommand } from './commands/agents.js';
|
|
8
|
+
import { deployCommand } from './commands/deploy.js';
|
|
9
|
+
import { stopCommand } from './commands/stop.js';
|
|
10
|
+
import { invokeCommand } from './commands/invoke.js';
|
|
11
|
+
import { secretsCommand } from './commands/secrets.js';
|
|
12
|
+
import { usageCommand } from './commands/usage.js';
|
|
13
|
+
const program = new Command();
|
|
14
|
+
program
|
|
15
|
+
.name('cast')
|
|
16
|
+
.description('Castari CLI - Deploy AI agents with one command')
|
|
17
|
+
.version('0.1.0');
|
|
18
|
+
// Auth commands
|
|
19
|
+
program.addCommand(loginCommand);
|
|
20
|
+
program.addCommand(logoutCommand);
|
|
21
|
+
program.addCommand(whoamiCommand);
|
|
22
|
+
program.addCommand(apikeyCommand);
|
|
23
|
+
// Agent management
|
|
24
|
+
program.addCommand(agentsCommand);
|
|
25
|
+
// Deployment
|
|
26
|
+
program.addCommand(deployCommand);
|
|
27
|
+
program.addCommand(stopCommand);
|
|
28
|
+
// Invocation
|
|
29
|
+
program.addCommand(invokeCommand);
|
|
30
|
+
// Secrets
|
|
31
|
+
program.addCommand(secretsCommand);
|
|
32
|
+
// Usage
|
|
33
|
+
program.addCommand(usageCommand);
|
|
34
|
+
// Parse arguments
|
|
35
|
+
program.parse();
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,MAAM,CAAC;KACZ,WAAW,CAAC,iDAAiD,CAAC;KAC9D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,gBAAgB;AAChB,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO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